mirror of
https://github.com/garrytan/gbrain.git
synced 2026-08-16 09:52:22 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edf7fc6b5a | ||
|
|
b7f42f099a |
@@ -457,7 +457,6 @@ unresolvable+true|false, pre-v80 NULL/NULL rows survive).
|
||||
- `src/core/think/prompt.ts` extension — anti-bias rewrite. `withCalibration` option on `buildThinkSystemPrompt` adds anti-bias rules. `buildCalibrationBlock()` emits the `<calibration>` XML. `buildThinkUserMessage` has TWO shapes: default (question first), and with-calibration (retrieval → calibration → question) when opt-in. Wired into `runThink` via `opts.withCalibration` + `opts.calibrationHolder`.
|
||||
- `src/commands/calibration.ts` — CLI: `gbrain calibration` (read + print), `--regenerate`, `--undo-wave <ver>`, `ab-report`. MCP op `get_calibration_profile` (scope: read) backs the same data path. Source-scoped via `sourceScopeOpts(ctx)`.
|
||||
- `src/commands/serve-http.ts` extension — three admin routes: `/admin/api/calibration/profile`, `/admin/api/calibration/charts/:type` (image/svg+xml; type in {brier-trend, domain-bars, pattern-statements, abandoned-threads}), `/admin/api/calibration/pattern/:id` (drill-down).
|
||||
- `src/core/owner-holder.ts` — single source of truth for "the brain owner" holder string. `DEFAULT_OWNER_HOLDER = 'self'` (matches the consolidate facts→takes writer + `docs/takes-vs-facts.md`); `resolveOwnerHolder({override, configValue})` returns override > `emotional_weight.user_holder` config > `'self'`. Consumed by the calibration_profile cycle phase, `gbrain calibration` CLI, the `get_calibration_profile` op, `think`'s calibration block, `emotional-weight`'s `DEFAULT_USER_HOLDER`, and doctor's `calibration_freshness`. Pure; unit-tested in `test/owner-holder.test.ts`. Does NOT unify owner-identity fragmentation (`self`/`brain`/`people-<owner>`) — tracked separately.
|
||||
- `src/commands/takes.ts` extension — `gbrain takes revisit <slug>` opens $EDITOR on the source page with a `<!-- gbrain:revisit -->` cursor marker.
|
||||
- `src/commands/doctor.ts` extension — 4 checks: `abandoned_threads`, `calibration_freshness`, `grade_confidence_drift` (mitigation surface; math ships later), `voice_gate_health`.
|
||||
- `admin/src/pages/Calibration.tsx` — Calibration tab. Single-column layout. `<TrustedSVG>` wrapper handles `dangerouslySetInnerHTML` for the server-rendered SVG.
|
||||
|
||||
@@ -91,18 +91,3 @@ First full takes extraction run on a ~100K-page brain:
|
||||
4. **Self-reported ≠ verified.** "Reports 7 figures" → holder=person, weight=0.75, NOT world/1.0
|
||||
5. **No false precision.** Use 0.05 increments (0.35, 0.55, 0.75), not 0.74 or 0.82
|
||||
6. **"So what" test.** Skip Twitter handles, follower counts, obvious metadata
|
||||
|
||||
## Owner-holder canonicalization
|
||||
|
||||
"The brain owner" is, by convention, the holder string **`self`** — the value the
|
||||
dream `consolidate` phase stamps when it promotes the owner's hot facts into cold
|
||||
takes. Calibration, `think`, and the `doctor` calibration check resolve the owner
|
||||
holder through `resolveOwnerHolder` (`src/core/owner-holder.ts`): explicit override
|
||||
> `emotional_weight.user_holder` config > `self`.
|
||||
|
||||
Known limitation (tracked in garrytan/gbrain#2465): the owner can also
|
||||
appear under `brain` (a take the owner asserts, via `propose_takes`) and
|
||||
`people/<owner>` (extraction that names the owner). The resolver selects the
|
||||
*default* canonical owner string for reads; it does not merge those other
|
||||
strings. Per-take attribution for other people (e.g. `people/george`) is
|
||||
unaffected and correct.
|
||||
|
||||
+3
-1
@@ -1411,7 +1411,8 @@ This is the dispatcher. Skills are the implementation. **Read the skill file bef
|
||||
| "get more out of gbrain", "is my brain set up right", "weekly brain checkup", "advise me on my brain", "gbrain advisor" | `skills/gbrain-advisor/SKILL.md` |
|
||||
| Save or load reports | `skills/reports/SKILL.md` |
|
||||
| "Create a skill", "improve this skill" | `skills/skill-creator/SKILL.md` |
|
||||
| "Skillify this", "is this a skill?", "make this proper" | `skills/skillify/SKILL.md` |
|
||||
| "save this learning to the vault", "capture this skill in Obsidian", "record this workflow in my notes", "put this setup change in the vault" | `skills/skill-vault-capture-policy/SKILL.md` |
|
||||
| "Skillify this", "is this a skill?", "make this proper", "add tests and evals for this" | `skills/skillify/SKILL.md` |
|
||||
| "Compress my resolver", "AGENTS.md too large", "RESOLVER.md too big", "functional area dispatcher", "shrink routing table" | `skills/functional-area-resolver/SKILL.md` |
|
||||
| "Is gbrain healthy?", morning health check, skillpack-check | `skills/skillpack-check/SKILL.md` |
|
||||
| "harvest this skill into gbrain", "publish this skill to gbrain", "lift this skill upstream", "share this skill with other gbrain clients", "promote my skill to gbrain" | `skills/skillpack-harvest/SKILL.md` |
|
||||
@@ -1429,6 +1430,7 @@ This is the dispatcher. Skills are the implementation. **Read the skill file bef
|
||||
| "Set up GBrain", first boot | `skills/setup/SKILL.md` |
|
||||
| "Now what?", "fill my brain", "cold start", "bootstrap", "import my data", "what should I import first" | `skills/cold-start/SKILL.md` |
|
||||
| "Migrate from Obsidian/Notion/Logseq" | `skills/migrate/SKILL.md` |
|
||||
| "Connect Obsidian to gbrain", "import my vault to gbrain", "sync vault and gbrain", "embed gbrain after vault update", "is gbrain synced with my vault" | `skills/obsidian-gbrain-safe-index/SKILL.md` |
|
||||
| Brain health check, maintenance run | `skills/maintain/SKILL.md` |
|
||||
| "Extract links", "build link graph", "populate timeline" | `skills/maintain/SKILL.md` (extraction sections) |
|
||||
| "Run dream", "process today's session", "synthesize my conversations", "consolidate yesterday's conversations", "what patterns did you see", "did the dream cycle run" | `skills/maintain/SKILL.md` (dream cycle section) |
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
"skills/briefing",
|
||||
"skills/citation-fixer",
|
||||
"skills/concept-synthesis",
|
||||
"skills/cross-modal-review",
|
||||
"skills/cron-scheduler",
|
||||
"skills/cross-modal-review",
|
||||
"skills/daily-task-manager",
|
||||
"skills/daily-task-prep",
|
||||
"skills/data-research",
|
||||
@@ -54,10 +54,11 @@
|
||||
"skills/media-ingest",
|
||||
"skills/meeting-ingestion",
|
||||
"skills/minion-orchestrator",
|
||||
"skills/obsidian-gbrain-safe-index",
|
||||
"skills/perplexity-research",
|
||||
"skills/query",
|
||||
"skills/reports",
|
||||
"skills/repo-architecture",
|
||||
"skills/reports",
|
||||
"skills/signal-detector",
|
||||
"skills/skill-creator",
|
||||
"skills/skillify",
|
||||
|
||||
+3
-1
@@ -60,7 +60,8 @@ This is the dispatcher. Skills are the implementation. **Read the skill file bef
|
||||
| "get more out of gbrain", "is my brain set up right", "weekly brain checkup", "advise me on my brain", "gbrain advisor" | `skills/gbrain-advisor/SKILL.md` |
|
||||
| Save or load reports | `skills/reports/SKILL.md` |
|
||||
| "Create a skill", "improve this skill" | `skills/skill-creator/SKILL.md` |
|
||||
| "Skillify this", "is this a skill?", "make this proper" | `skills/skillify/SKILL.md` |
|
||||
| "save this learning to the vault", "capture this skill in Obsidian", "record this workflow in my notes", "put this setup change in the vault" | `skills/skill-vault-capture-policy/SKILL.md` |
|
||||
| "Skillify this", "is this a skill?", "make this proper", "add tests and evals for this" | `skills/skillify/SKILL.md` |
|
||||
| "Compress my resolver", "AGENTS.md too large", "RESOLVER.md too big", "functional area dispatcher", "shrink routing table" | `skills/functional-area-resolver/SKILL.md` |
|
||||
| "Is gbrain healthy?", morning health check, skillpack-check | `skills/skillpack-check/SKILL.md` |
|
||||
| "harvest this skill into gbrain", "publish this skill to gbrain", "lift this skill upstream", "share this skill with other gbrain clients", "promote my skill to gbrain" | `skills/skillpack-harvest/SKILL.md` |
|
||||
@@ -78,6 +79,7 @@ This is the dispatcher. Skills are the implementation. **Read the skill file bef
|
||||
| "Set up GBrain", first boot | `skills/setup/SKILL.md` |
|
||||
| "Now what?", "fill my brain", "cold start", "bootstrap", "import my data", "what should I import first" | `skills/cold-start/SKILL.md` |
|
||||
| "Migrate from Obsidian/Notion/Logseq" | `skills/migrate/SKILL.md` |
|
||||
| "Connect Obsidian to gbrain", "import my vault to gbrain", "sync vault and gbrain", "embed gbrain after vault update", "is gbrain synced with my vault" | `skills/obsidian-gbrain-safe-index/SKILL.md` |
|
||||
| Brain health check, maintenance run | `skills/maintain/SKILL.md` |
|
||||
| "Extract links", "build link graph", "populate timeline" | `skills/maintain/SKILL.md` (extraction sections) |
|
||||
| "Run dream", "process today's session", "synthesize my conversations", "consolidate yesterday's conversations", "what patterns did you see", "did the dream cycle run" | `skills/maintain/SKILL.md` (dream cycle section) |
|
||||
|
||||
+11
-1
@@ -2,7 +2,7 @@
|
||||
"name": "gbrain",
|
||||
"version": "0.32.3.0",
|
||||
"conformance_version": "1.0.0",
|
||||
"description": "Personal knowledge brain with hybrid RAG search \u2014 GStack mod for agent platforms",
|
||||
"description": "Personal knowledge brain with hybrid RAG search — GStack mod for agent platforms",
|
||||
"skills": [
|
||||
{
|
||||
"name": "ingest",
|
||||
@@ -34,6 +34,11 @@
|
||||
"path": "migrate/SKILL.md",
|
||||
"description": "Universal migration from Obsidian, Notion, Logseq, markdown, CSV, JSON, Roam"
|
||||
},
|
||||
{
|
||||
"name": "obsidian-gbrain-safe-index",
|
||||
"path": "obsidian-gbrain-safe-index/SKILL.md",
|
||||
"description": "Connect and sync an Obsidian-style Markdown vault with gbrain using a cost-controlled import-first workflow, explicit embedding gates, and durable skill/workflow capture."
|
||||
},
|
||||
{
|
||||
"name": "setup",
|
||||
"path": "setup/SKILL.md",
|
||||
@@ -263,6 +268,11 @@
|
||||
"name": "skill-optimizer",
|
||||
"path": "skill-optimizer/SKILL.md",
|
||||
"description": "Self-evolving skill optimization via gbrain skillopt — SkillOpt-paper-grounded text-space optimizer with validation gating (median-of-3 + epsilon=0.05), bundled-skill safety, bootstrap review sentinel, per-skill DB lock, and atomic versioned writes."
|
||||
},
|
||||
{
|
||||
"name": "skill-vault-capture-policy",
|
||||
"path": "skill-vault-capture-policy/SKILL.md",
|
||||
"description": "Capture durable operational learnings, new agent skills, and environment/setup changes into the Obsidian vault instead of transient chat memory."
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
---
|
||||
name: obsidian-gbrain-safe-index
|
||||
version: 1.0.0
|
||||
description: |
|
||||
Connect, maintain, and sync an Obsidian-style Markdown vault with gbrain while preserving a cost-controlled workflow: the vault remains the source of truth, gbrain is the searchable/embedded index, durable skills/workflows are captured into the vault, and paid embedding runs only after explicit approval.
|
||||
triggers:
|
||||
- "connect Obsidian to gbrain"
|
||||
- "import my vault to gbrain"
|
||||
- "sync vault and gbrain"
|
||||
- "capture this skill in my vault"
|
||||
- "embed gbrain after vault update"
|
||||
- "is gbrain synced with my vault"
|
||||
tools:
|
||||
- terminal
|
||||
- read_file
|
||||
- search_files
|
||||
- write_file
|
||||
- patch
|
||||
mutating: true
|
||||
---
|
||||
|
||||
# Obsidian → gbrain Safe Index and Capture
|
||||
|
||||
## Contract
|
||||
|
||||
This skill guarantees:
|
||||
|
||||
- Treats the user's Obsidian-style Markdown vault as the source of truth before gbrain indexing.
|
||||
- Keeps gbrain in conservative mode unless the user explicitly approves a more expensive mode.
|
||||
- Imports vault changes with `--no-embed` first, then embeds only after explicit approval for the specific paid action.
|
||||
- Captures durable new skills, workflows, and environment learnings into the vault instead of leaving them only in chat memory.
|
||||
- Verifies every sync with concrete `gbrain stats`, search mode, and, when embeddings run, exact embedded chunk counts.
|
||||
|
||||
## Phases
|
||||
|
||||
1. **Resolve the vault path.**
|
||||
- Prefer an existing environment variable such as `OBSIDIAN_VAULT_PATH` or `WIKI_PATH`.
|
||||
- If no path is configured, search likely note directories and ask the user before writing.
|
||||
- Verify the directory exists and contains markdown files or an `.obsidian` directory.
|
||||
|
||||
2. **Read vault operating rules before writing.**
|
||||
- If the vault has `SCHEMA.md`, `index.md`, `log.md`, `AGENTS.md`, or similar operating files, read them before ingest/query/major edit.
|
||||
- Respect immutable source folders such as `raw/` when the vault declares them.
|
||||
- Use the vault's native link convention, usually Obsidian `[[wikilinks]]`, for durable relationships.
|
||||
|
||||
3. **MECE/capture decision.**
|
||||
- If new knowledge belongs on an existing page, update that page.
|
||||
- If it is a distinct recurring workflow or operational policy, create a small meta or concept page following the vault schema.
|
||||
- Update the vault index/catalog for every new page when the vault maintains one.
|
||||
- Append a log entry for meaningful vault updates when the vault maintains a log.
|
||||
|
||||
4. **Safe gbrain import path.**
|
||||
- Pre-check source directory; do not import a nonexistent path.
|
||||
- Run `gbrain config set search.mode conservative` before/after risky reinit steps.
|
||||
- Run `gbrain import "$OBSIDIAN_VAULT_PATH" --no-embed`.
|
||||
- Run `gbrain extract links --source fs --dir "$OBSIDIAN_VAULT_PATH"` when wikilinks changed materially.
|
||||
|
||||
5. **Paid embedding gate.**
|
||||
- Do not run `gbrain embed --stale` unless the user explicitly asks or a prior instruction clearly approved this exact paid action.
|
||||
- Before embedding, verify provider readiness with `gbrain providers test --model <provider:model>`.
|
||||
- Confirm the configured embedding dimensions match the local schema.
|
||||
- After embedding, verify `gbrain stats` and record exact `Pages`, `Chunks`, `Embedded`, and `Links` counts.
|
||||
|
||||
6. **Final verification and vault echo.**
|
||||
- Run `gbrain stats` and `gbrain search modes`.
|
||||
- If vault files changed, re-import with `--no-embed`; if embedding was approved, embed stale chunks afterward.
|
||||
- Report what changed, what was free/local, what used API billing, and what remains pending.
|
||||
|
||||
## Output Format
|
||||
|
||||
Use a compact status table:
|
||||
|
||||
| Item | Status |
|
||||
|---|---|
|
||||
| Vault path | `/path` |
|
||||
| Vault updated | yes/no + files |
|
||||
| gbrain mode | conservative/balanced/tokenmax |
|
||||
| Import | `--no-embed` completed / skipped / failed |
|
||||
| Pages/chunks | exact counts from `gbrain stats` |
|
||||
| Embeddings | exact count; note whether this run used API billing |
|
||||
| Links | exact count |
|
||||
| Background jobs | none / list exact jobs |
|
||||
|
||||
Then include:
|
||||
|
||||
- **Safe next step:** free/local action.
|
||||
- **Paid next step:** embedding/LLM action, if any, with explicit approval requirement.
|
||||
|
||||
## Anti-Patterns
|
||||
|
||||
- Creating a duplicate skill/page when an existing Obsidian, gbrain, or vault-ingest skill already covers the workflow.
|
||||
- Running `gbrain embed --stale`, `gbrain dream`, `gbrain autopilot --install`, `gbrain onboard --auto`, or `tokenmax` without explicit cost approval.
|
||||
- Importing a nonexistent or wrong directory and treating a zero-page import as success.
|
||||
- Forgetting to update the vault index/catalog and log after creating or materially updating vault pages.
|
||||
- Recording API keys, tokens, or raw secrets in the vault or final response.
|
||||
|
||||
## Tools Used
|
||||
|
||||
- `read_file` — read vault schema/index/log and target notes.
|
||||
- `search_files` — find existing vault pages and avoid duplicates.
|
||||
- `write_file` / `patch` — create or update vault pages.
|
||||
- `terminal` — run `gbrain`, `git`, and environment checks with secret values redacted.
|
||||
|
||||
## Safe Commands
|
||||
|
||||
```bash
|
||||
export PATH="$HOME/.bun/bin:$PATH"
|
||||
gbrain config set search.mode conservative
|
||||
gbrain import "$OBSIDIAN_VAULT_PATH" --no-embed
|
||||
gbrain extract links --source fs --dir "$OBSIDIAN_VAULT_PATH"
|
||||
gbrain stats
|
||||
gbrain search modes
|
||||
```
|
||||
|
||||
## Paid / Approval-Gated Commands
|
||||
|
||||
```bash
|
||||
gbrain providers test --model <provider:model>
|
||||
gbrain embed --stale
|
||||
gbrain dream
|
||||
gbrain autopilot --install
|
||||
gbrain onboard --auto --max-usd 5
|
||||
gbrain config set search.mode tokenmax
|
||||
```
|
||||
|
||||
## Verification Checklist
|
||||
|
||||
- [ ] Vault path exists and is the intended source.
|
||||
- [ ] Vault operating files were read before edits when present.
|
||||
- [ ] Existing pages/skills were searched to avoid duplicates.
|
||||
- [ ] New/updated vault pages follow the vault schema and link convention.
|
||||
- [ ] Vault index/catalog updated for new pages when present.
|
||||
- [ ] Vault log appended for meaningful actions when present.
|
||||
- [ ] `gbrain import ... --no-embed` completed.
|
||||
- [ ] `gbrain stats` recorded pages/chunks/embeddings/links.
|
||||
- [ ] `gbrain search modes` confirms conservative mode unless a different mode was explicitly approved.
|
||||
- [ ] No paid/background commands ran without approval.
|
||||
@@ -0,0 +1,11 @@
|
||||
// Routing eval fixtures for skills/obsidian-gbrain-safe-index.
|
||||
// Positive cases: intents embed a trigger phrase in natural surrounding context
|
||||
// (never verbatim-identical to a trigger — the fixture linter rejects tautologies).
|
||||
{"intent": "help me connect Obsidian to gbrain for my notes", "expected_skill": "obsidian-gbrain-safe-index"}
|
||||
{"intent": "import my vault to gbrain but skip embeddings for now", "expected_skill": "obsidian-gbrain-safe-index"}
|
||||
{"intent": "please sync vault and gbrain after I edit notes", "expected_skill": "obsidian-gbrain-safe-index"}
|
||||
{"intent": "run embed gbrain after vault update tonight", "expected_skill": "obsidian-gbrain-safe-index"}
|
||||
{"intent": "hey is gbrain synced with my vault right now", "expected_skill": "obsidian-gbrain-safe-index"}
|
||||
// Negative cases: related but owned by other skills. Assert NO route to this skill.
|
||||
{"intent": "migrate my notes from Notion to gbrain", "expected_skill": null}
|
||||
{"intent": "what is on my calendar tomorrow", "expected_skill": null}
|
||||
@@ -0,0 +1,100 @@
|
||||
---
|
||||
name: skill-vault-capture-policy
|
||||
version: 1.0.0
|
||||
description: |
|
||||
Use when the user wants a durable operational learning, new agent skill, or
|
||||
important environment/setup change to be captured into the Obsidian vault
|
||||
instead of left only in transient chat memory. Covers the capture rule,
|
||||
preferred page patterns, and index/log update obligations.
|
||||
triggers:
|
||||
- "save this learning to the vault"
|
||||
- "capture this skill in Obsidian"
|
||||
- "record this workflow in my notes"
|
||||
- "put this setup change in the vault"
|
||||
- "should we add this to the knowledge base"
|
||||
tools:
|
||||
- read_file
|
||||
- search_files
|
||||
- write_file
|
||||
- patch
|
||||
mutating: true
|
||||
---
|
||||
|
||||
# Skill Vault Capture Policy
|
||||
|
||||
## Contract
|
||||
|
||||
This skill guarantees:
|
||||
|
||||
- Durable operational learnings, newly adopted skills, and important environment/setup changes are captured into the Obsidian vault rather than left only in chat memory.
|
||||
- An existing page is updated when the knowledge clearly belongs there; a new page is created only when the topic is distinct and likely to recur.
|
||||
- Every new vault page is added to `index.md`.
|
||||
- Every meaningful create/update appends a dated entry to `log.md`.
|
||||
- Small linked pages are preferred over one giant running note.
|
||||
|
||||
## Phases
|
||||
|
||||
1. **Classify the learning.**
|
||||
- New gbrain operating rule, cost control, or embedding/provider change.
|
||||
- New agent-fork / harness / coding-tool integration fact.
|
||||
- New Obsidian vault workflow or structure decision.
|
||||
- New recurring agent skill that changes how the agent should operate here.
|
||||
|
||||
2. **Avoid duplicates.**
|
||||
- Search the vault for an existing page that already owns the topic.
|
||||
- If found, update it with a new section or dated note rather than creating a near-duplicate.
|
||||
|
||||
3. **Create when distinct.**
|
||||
- Place new pages under the vault schema: `_meta/` for operating notes, `concepts/` for workflows, `entities/` for tools/people.
|
||||
- Use YAML frontmatter and at least two `[[wikilinks]]` unless it is a short seed page.
|
||||
|
||||
4. **Update navigation.**
|
||||
- Add the page to `index.md` under the correct type heading.
|
||||
- Append a `## [YYYY-MM-DD] create|update | subject` entry to `log.md`.
|
||||
|
||||
5. **Report the capture.**
|
||||
- State which files changed and whether `index.md` / `log.md` were updated.
|
||||
|
||||
## Output Format
|
||||
|
||||
Use a short status block:
|
||||
|
||||
| Item | Status |
|
||||
|---|---|
|
||||
| Learning classified | type |
|
||||
| Page created/updated | path |
|
||||
| index.md updated | yes/no |
|
||||
| log.md updated | yes/no |
|
||||
|
||||
## Anti-Patterns
|
||||
|
||||
- Leaving durable learnings only in chat memory.
|
||||
- Creating a near-duplicate page instead of updating the existing one.
|
||||
- Forgetting to update `index.md` and `log.md`.
|
||||
- Writing one giant running note instead of small linked pages.
|
||||
- Recording secrets, API keys, or raw credentials in the vault.
|
||||
|
||||
## Tools Used
|
||||
|
||||
- `read_file` — read `SCHEMA.md`, `index.md`, `log.md`, and target pages.
|
||||
- `search_files` — find existing pages to avoid duplicates.
|
||||
- `write_file` / `patch` — create or update vault pages and navigation.
|
||||
|
||||
## Safe Commands
|
||||
|
||||
```bash
|
||||
# inspect vault navigation before writing
|
||||
read SCHEMA.md index.md log.md
|
||||
# create or update a page, then refresh catalog/log
|
||||
# index.md: add [[page-slug]] under the matching type heading
|
||||
# log.md: append ## [YYYY-MM-DD] create|update | subject
|
||||
```
|
||||
|
||||
## Verification Checklist
|
||||
|
||||
- [ ] Vault schema/read files were checked before writing.
|
||||
- [ ] Existing pages were searched to avoid duplicates.
|
||||
- [ ] New/updated page has frontmatter and wikilinks.
|
||||
- [ ] `index.md` updated for new pages.
|
||||
- [ ] `log.md` appended for meaningful actions.
|
||||
- [ ] No secrets or raw credentials were written.
|
||||
@@ -0,0 +1,10 @@
|
||||
// Routing eval fixtures for skills/skill-vault-capture-policy.
|
||||
// Positive cases: intents embed a trigger phrase in natural surrounding context
|
||||
// (never verbatim-identical to a trigger — the fixture linter rejects tautologies).
|
||||
{"intent": "please save this learning to the vault so we keep it", "expected_skill": "skill-vault-capture-policy", "ambiguous_with": ["idea-ingest"]}
|
||||
{"intent": "we should capture this skill in Obsidian for reuse", "expected_skill": "skill-vault-capture-policy", "ambiguous_with": ["capture"]}
|
||||
{"intent": "can you record this workflow in my notes for next time", "expected_skill": "skill-vault-capture-policy"}
|
||||
{"intent": "put this setup change in the vault before we forget", "expected_skill": "skill-vault-capture-policy"}
|
||||
// Negative cases: related but owned by other skills or out of scope.
|
||||
{"intent": "connect my Obsidian vault to gbrain", "expected_skill": null}
|
||||
{"intent": "what is on my calendar tomorrow", "expected_skill": null}
|
||||
@@ -23,7 +23,6 @@ import { runPhaseCalibrationProfile } from '../core/cycle/calibration-profile.ts
|
||||
import { sourceScopeOpts, type OperationContext } from '../core/operations.ts';
|
||||
import type { GBrainConfig } from '../core/config.ts';
|
||||
import { GBrainError } from '../core/types.ts';
|
||||
import { resolveOwnerHolder } from '../core/owner-holder.ts';
|
||||
|
||||
export interface CalibrationProfileRow {
|
||||
/** BIGSERIAL → string (postgres.js int8 wire shape; never Number() — int8
|
||||
@@ -168,10 +167,7 @@ export async function runCalibration(
|
||||
config: GBrainConfig,
|
||||
): Promise<void> {
|
||||
const { opts } = parseArgs(args);
|
||||
const holder = resolveOwnerHolder({
|
||||
override: opts.holder,
|
||||
configValue: await engine.getConfig('emotional_weight.user_holder'),
|
||||
});
|
||||
const holder = opts.holder ?? 'garry';
|
||||
// Resolve --source / GBRAIN_SOURCE / .gbrain-source so the (now reachable, #2035)
|
||||
// calibration command targets the right source in a multi-source brain instead
|
||||
// of always reading `default`. No signal → 'default' (prior behavior).
|
||||
@@ -257,15 +253,12 @@ export async function getCalibrationProfileOp(
|
||||
ctx: OperationContext,
|
||||
params: { holder?: string },
|
||||
): Promise<CalibrationProfileRow | null> {
|
||||
const holder = resolveOwnerHolder({
|
||||
override: params.holder,
|
||||
configValue: await ctx.engine.getConfig('emotional_weight.user_holder'),
|
||||
});
|
||||
const holder = params.holder ?? 'garry';
|
||||
if (typeof holder !== 'string' || holder.length === 0) {
|
||||
throw new GBrainError(
|
||||
'INVALID_HOLDER',
|
||||
'get_calibration_profile.holder must be a non-empty string',
|
||||
'pass holder="<slug>" or omit to default to the owner holder (config emotional_weight.user_holder, else "self")',
|
||||
'pass holder="<slug>" or omit to default to "garry"',
|
||||
);
|
||||
}
|
||||
const scope = sourceScopeOpts(ctx);
|
||||
|
||||
@@ -28,7 +28,6 @@ import type { DbUrlSource } from '../core/config.ts';
|
||||
import { gbrainPath, loadConfig } from '../core/config.ts';
|
||||
import { reflexEnabled } from '../core/context/reflex.ts';
|
||||
import { resolveSocketPath } from '../core/context/resolve-ipc.ts';
|
||||
import { resolveOwnerHolder } from '../core/owner-holder.ts';
|
||||
import { homedir } from 'os';
|
||||
import { dirname, isAbsolute, join, resolve as resolvePath } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
@@ -1288,19 +1287,14 @@ export async function checkAbandonedThreads(engine: BrainEngine): Promise<Check>
|
||||
|
||||
/**
|
||||
* calibration_freshness: warns when the active calibration profile is
|
||||
* older than 7 days (configurable). Default holder resolves via resolveOwnerHolder
|
||||
* (config emotional_weight.user_holder, else 'self'). Multi-source
|
||||
* older than 7 days (configurable). Default holder 'garry'. Multi-source
|
||||
* brains see one row per source; this check uses the most recent across
|
||||
* all sources.
|
||||
*/
|
||||
export async function checkCalibrationFreshness(engine: BrainEngine): Promise<Check> {
|
||||
try {
|
||||
const ownerHolder = resolveOwnerHolder({
|
||||
configValue: await engine.getConfig('emotional_weight.user_holder'),
|
||||
});
|
||||
const rows = await engine.executeRaw<{ generated_at: Date | null }>(
|
||||
`SELECT MAX(generated_at) AS generated_at FROM calibration_profiles WHERE holder = $1`,
|
||||
[ownerHolder],
|
||||
`SELECT MAX(generated_at) AS generated_at FROM calibration_profiles WHERE holder = 'garry'`,
|
||||
);
|
||||
const generated = rows[0]?.generated_at;
|
||||
if (!generated) {
|
||||
|
||||
@@ -45,7 +45,6 @@ import {
|
||||
type IngestionContentType,
|
||||
type IngestionEvent,
|
||||
} from '../core/ingestion/types.ts';
|
||||
import { resolveOwnerHolder } from '../core/owner-holder.ts';
|
||||
|
||||
/**
|
||||
* /health endpoint timeout. 3s rather than 5s: Fly.io's default
|
||||
@@ -1191,7 +1190,7 @@ export async function runServeHttp(engine: BrainEngine, options: ServeHttpOption
|
||||
app.get('/admin/api/calibration/pattern/:id', requireAdmin, async (req: Request, res: Response) => {
|
||||
try {
|
||||
const { getLatestProfile } = await import('./calibration.ts');
|
||||
const holder = resolveOwnerHolder({ override: (req.query.holder as string) || undefined, configValue: await engine.getConfig('emotional_weight.user_holder') });
|
||||
const holder = (req.query.holder as string) || 'garry';
|
||||
const profile = await getLatestProfile(engine, { holder });
|
||||
if (!profile) {
|
||||
res.status(404).json({ error: 'no_profile' });
|
||||
@@ -1241,7 +1240,7 @@ export async function runServeHttp(engine: BrainEngine, options: ServeHttpOption
|
||||
app.get('/admin/api/calibration/profile', requireAdmin, async (req: Request, res: Response) => {
|
||||
try {
|
||||
const { getLatestProfile } = await import('./calibration.ts');
|
||||
const holder = resolveOwnerHolder({ override: (req.query.holder as string) || undefined, configValue: await engine.getConfig('emotional_weight.user_holder') });
|
||||
const holder = (req.query.holder as string) || 'garry';
|
||||
const profile = await getLatestProfile(engine, { holder });
|
||||
res.json(profile);
|
||||
} catch (err) {
|
||||
@@ -1258,7 +1257,7 @@ export async function runServeHttp(engine: BrainEngine, options: ServeHttpOption
|
||||
renderAbandonedThreadsCard,
|
||||
renderPatternStatementsCard,
|
||||
} = await import('../core/calibration/svg-renderer.ts');
|
||||
const holder = resolveOwnerHolder({ override: (req.query.holder as string) || undefined, configValue: await engine.getConfig('emotional_weight.user_holder') });
|
||||
const holder = (req.query.holder as string) || 'garry';
|
||||
const type = req.params.type;
|
||||
const profile = await getLatestProfile(engine, { holder });
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import {
|
||||
} from '../core/takes-fence.ts';
|
||||
import { withPageLock } from '../core/page-lock.ts';
|
||||
import { resolveSourceId } from '../core/source-resolver.ts';
|
||||
import { resolveOwnerHolder } from '../core/owner-holder.ts';
|
||||
|
||||
// --- Helpers ---
|
||||
|
||||
@@ -365,7 +364,7 @@ async function cmdResolve(engine: BrainEngine, args: string[], sourceId?: string
|
||||
// --evidence is the v0.30.0 alias for --source on the resolve subcommand
|
||||
// (semantic clarity: "what evidence resolved this bet?").
|
||||
const source = flagValue(args, '--evidence') ?? flagValue(args, '--source');
|
||||
const resolvedBy = flagValue(args, '--by') ?? resolveOwnerHolder({ configValue: await engine.getConfig('emotional_weight.user_holder') });
|
||||
const resolvedBy = flagValue(args, '--by') ?? 'garry';
|
||||
const dirArg = flagValue(args, '--dir');
|
||||
|
||||
const pageId = await getPageId(engine, slug, sourceId);
|
||||
|
||||
@@ -68,7 +68,6 @@ import {
|
||||
type BrainstormCheckpoint,
|
||||
type CheckpointCross,
|
||||
} from './checkpoint.ts';
|
||||
import { resolveOwnerHolder } from '../owner-holder.ts';
|
||||
|
||||
export { BudgetExhausted };
|
||||
|
||||
@@ -140,7 +139,7 @@ export interface BrainstormOptions {
|
||||
modelOverride?: string;
|
||||
/** Skip the cost-preview TTY grace window. Required for non-interactive callers. */
|
||||
skipCostPreview?: boolean;
|
||||
/** When set, force the user holder for calibration profile lookup. Falls back to config (`emotional_weight.user_holder`) then `'self'`. */
|
||||
/** When set, force the user holder for calibration profile lookup. Falls back to config (`emotional_weight.user_holder`) then `'garry'`. */
|
||||
holderOverride?: string;
|
||||
/** Source scope. */
|
||||
sourceId?: string;
|
||||
@@ -624,7 +623,7 @@ async function _runBrainstormInner(
|
||||
}
|
||||
|
||||
// ---- Phase 3: calibration context (cold-start fallback) ----
|
||||
const holder = resolveOwnerHolder({ override: opts.holderOverride, configValue: config.emotional_weight?.user_holder });
|
||||
const holder = opts.holderOverride ?? config.emotional_weight?.user_holder ?? 'garry';
|
||||
const calibContext = await loadCalibrationContext(engine, {
|
||||
holder,
|
||||
sourceId: opts.sourceId,
|
||||
|
||||
@@ -25,7 +25,7 @@ import type { BrainEngine } from '../engine.ts';
|
||||
|
||||
export interface ABRunInput {
|
||||
question: string;
|
||||
/** Holder context for calibration. Resolves via resolveOwnerHolder (config emotional_weight.user_holder, else 'self'). */
|
||||
/** Holder context for calibration. Default 'garry'. */
|
||||
holder?: string;
|
||||
/** Engine for DB write. */
|
||||
engine: BrainEngine;
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
*/
|
||||
|
||||
import { BaseCyclePhase, type ScopedReadOpts, type BasePhaseOpts } from './base-phase.ts';
|
||||
import { resolveOwnerHolder } from '../owner-holder.ts';
|
||||
import { chat as gatewayChat } from '../ai/gateway.ts';
|
||||
import { TIER_DEFAULTS } from '../model-config.ts';
|
||||
import { gateVoice, type VoiceGateGenerator, type VoiceGateJudge } from '../calibration/voice-gate.ts';
|
||||
@@ -97,7 +96,7 @@ export type PatternStatementsGenerator = (input: {
|
||||
export type BiasTagsGenerator = (patterns: string[]) => Promise<string[]>;
|
||||
|
||||
export interface CalibrationProfileOpts extends BasePhaseOpts {
|
||||
/** Holder to generate the profile for. Default resolves via resolveOwnerHolder (config emotional_weight.user_holder, else 'self'). */
|
||||
/** Holder to generate the profile for. Default 'garry'. */
|
||||
holder?: string;
|
||||
/** Inject the patterns generator (tests). */
|
||||
patternsGenerator?: PatternStatementsGenerator;
|
||||
@@ -228,10 +227,7 @@ class CalibrationProfilePhase extends BaseCyclePhase {
|
||||
_ctx: OperationContext,
|
||||
opts: CalibrationProfileOpts,
|
||||
): Promise<{ summary: string; details: Record<string, unknown>; status?: PhaseStatus }> {
|
||||
const holder = resolveOwnerHolder({
|
||||
override: opts.holder,
|
||||
configValue: await engine.getConfig('emotional_weight.user_holder'),
|
||||
});
|
||||
const holder = opts.holder ?? 'garry';
|
||||
const promptVersion = opts.promptVersion ?? CALIBRATION_PROFILE_PROMPT_VERSION;
|
||||
const modelId = opts.model ?? TIER_DEFAULTS.reasoning;
|
||||
const gradeCompletion = opts.gradeCompletion ?? 1.0;
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
* See `loadHighEmotionTags` for the resolution path.
|
||||
*/
|
||||
|
||||
import { DEFAULT_OWNER_HOLDER } from '../owner-holder.ts';
|
||||
|
||||
/**
|
||||
* Default high-emotion tag seed list. Pages with any tag in this set get the
|
||||
* tag-emotion boost in the formula below. Override via config key
|
||||
@@ -45,12 +43,11 @@ export const HIGH_EMOTION_TAGS: ReadonlySet<string> = new Set([
|
||||
]);
|
||||
|
||||
/**
|
||||
* Holder name treated as "the user" for the user-as-holder ratio. Configurable
|
||||
* via the `emotional_weight.user_holder` config key; defaults to the canonical
|
||||
* owner holder ('self', DEFAULT_OWNER_HOLDER) so it matches the consolidate
|
||||
* facts→takes writer instead of a hardcoded name.
|
||||
* Holder name treated as "the user" for the Garry-as-holder ratio. Configurable
|
||||
* via the `emotional_weight.user_holder` config key (defaults to 'garry' to
|
||||
* match the v0.28 schema's takes table convention).
|
||||
*/
|
||||
export const DEFAULT_USER_HOLDER = DEFAULT_OWNER_HOLDER;
|
||||
export const DEFAULT_USER_HOLDER = 'garry';
|
||||
|
||||
export interface EmotionalWeightTake {
|
||||
holder: string;
|
||||
|
||||
@@ -3289,7 +3289,7 @@ const get_calibration_profile: Operation = {
|
||||
holder: {
|
||||
type: 'string',
|
||||
description:
|
||||
"Holder slug, e.g. 'self' or 'people/charlie-example'. Defaults to config emotional_weight.user_holder, else 'self', when omitted.",
|
||||
"Holder slug, e.g. 'garry' or 'people/charlie-example'. Defaults to 'garry' when omitted.",
|
||||
},
|
||||
},
|
||||
handler: async (ctx, p) => {
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/**
|
||||
* Canonical holder string for "the brain owner," resolved in ONE place so the
|
||||
* calibration / think / doctor / emotional-weight defaults stop disagreeing.
|
||||
*
|
||||
* The default matches the consolidate facts→takes writer
|
||||
* (src/core/cycle/phases/consolidate.ts: holder:'self') and docs/takes-vs-facts.md.
|
||||
* Do NOT introduce a fourth literal — three already exist historically
|
||||
* ('garry', 'system', 'self'); this is the source of truth.
|
||||
*
|
||||
* NORMALIZATION NOTE: the brain owner may also appear under other holder
|
||||
* strings — 'brain' (propose_takes when the author asserts a claim) and
|
||||
* people/<owner> (extraction that names the owner). This resolver only selects
|
||||
* the *default* canonical owner string for reads; it does NOT merge those other
|
||||
* strings. Unifying them is owner-identity entity-resolution, tracked separately
|
||||
* (see garrytan/gbrain#2465). Until then, historical owner takes
|
||||
* under 'brain'/people-<owner> are not folded into the default profile.
|
||||
*/
|
||||
export const DEFAULT_OWNER_HOLDER = 'self';
|
||||
|
||||
export function resolveOwnerHolder(
|
||||
opts: { override?: string | null; configValue?: string | null },
|
||||
): string {
|
||||
return opts.override ?? opts.configValue ?? DEFAULT_OWNER_HOLDER;
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import { runGather, renderPagesBlock, takesHitToTakeForPrompt } from './gather.t
|
||||
import { renderTakesBlock } from './sanitize.ts';
|
||||
import { buildThinkSystemPrompt, buildThinkUserMessage } from './prompt.ts';
|
||||
import { resolveCitations, type ParsedCitation } from './cite-render.ts';
|
||||
import { resolveOwnerHolder } from '../owner-holder.ts';
|
||||
import { resolveModel } from '../model-config.ts';
|
||||
import { chat as gatewayChat, probeChatModel, type ChatResult } from '../ai/gateway.ts';
|
||||
import { AIConfigError } from '../ai/errors.ts';
|
||||
@@ -77,8 +76,8 @@ export interface RunThinkOpts {
|
||||
*/
|
||||
withCalibration?: boolean;
|
||||
/**
|
||||
* Holder to retrieve the calibration profile for. Resolves via resolveOwnerHolder
|
||||
* (config emotional_weight.user_holder, else 'self'). Only consulted when withCalibration=true.
|
||||
* Holder to retrieve the calibration profile for. Default 'garry'. Only
|
||||
* consulted when withCalibration=true.
|
||||
*/
|
||||
calibrationHolder?: string;
|
||||
/**
|
||||
@@ -309,10 +308,7 @@ export async function runThink(
|
||||
try {
|
||||
const { getLatestProfile } = await import('../../commands/calibration.ts');
|
||||
const profile = await getLatestProfile(engine, {
|
||||
holder: resolveOwnerHolder({
|
||||
override: opts.calibrationHolder,
|
||||
configValue: await engine.getConfig('emotional_weight.user_holder'),
|
||||
}),
|
||||
holder: opts.calibrationHolder ?? 'garry',
|
||||
});
|
||||
if (profile) {
|
||||
calibrationBlockOpts = {
|
||||
|
||||
@@ -27,12 +27,6 @@ function buildMockEngine(opts: { rows: CalibrationProfileRow[] }): {
|
||||
const capturedParams: unknown[][] = [];
|
||||
const engine = {
|
||||
kind: 'pglite',
|
||||
// #2464: getCalibrationProfileOp resolves the owner holder via
|
||||
// resolveOwnerHolder(config emotional_weight.user_holder, else 'self'), so the
|
||||
// mock must implement getConfig. null = key unset → resolver falls back to 'self'.
|
||||
async getConfig(): Promise<string | null> {
|
||||
return null;
|
||||
},
|
||||
async executeRaw<T>(sql: string, params?: unknown[]): Promise<T[]> {
|
||||
capturedSql.push(sql);
|
||||
capturedParams.push(params ?? []);
|
||||
@@ -217,17 +211,17 @@ describe('formatProfileText', () => {
|
||||
// ─── getCalibrationProfileOp ────────────────────────────────────────
|
||||
|
||||
describe('getCalibrationProfileOp (MCP)', () => {
|
||||
test('defaults holder to "self" when omitted (config emotional_weight.user_holder unset)', async () => {
|
||||
const { engine } = buildMockEngine({ rows: [buildProfile({ holder: 'self' })] });
|
||||
test('defaults holder to "garry" when omitted', async () => {
|
||||
const { engine } = buildMockEngine({ rows: [buildProfile({ holder: 'garry' })] });
|
||||
const ctx = buildCtx(engine);
|
||||
const result = await getCalibrationProfileOp(ctx, {});
|
||||
expect(result?.holder).toBe('self');
|
||||
expect(result?.holder).toBe('garry');
|
||||
});
|
||||
|
||||
test('routes through sourceScopeOpts: scalar source-bound client gets source-scoped result', async () => {
|
||||
const rows = [
|
||||
buildProfile({ holder: 'self', source_id: 'default' }),
|
||||
buildProfile({ holder: 'self', source_id: 'tenant-b' }),
|
||||
buildProfile({ holder: 'garry', source_id: 'default' }),
|
||||
buildProfile({ holder: 'garry', source_id: 'tenant-b' }),
|
||||
];
|
||||
const { engine } = buildMockEngine({ rows });
|
||||
const ctx = buildCtx(engine, { sourceId: 'tenant-b' });
|
||||
@@ -237,8 +231,8 @@ describe('getCalibrationProfileOp (MCP)', () => {
|
||||
|
||||
test('federated read scope sees the union of allowed sources', async () => {
|
||||
const rows = [
|
||||
buildProfile({ holder: 'self', source_id: 'tenant-a' }),
|
||||
buildProfile({ holder: 'self', source_id: 'tenant-z' }),
|
||||
buildProfile({ holder: 'garry', source_id: 'tenant-a' }),
|
||||
buildProfile({ holder: 'garry', source_id: 'tenant-z' }),
|
||||
];
|
||||
const { engine } = buildMockEngine({ rows });
|
||||
const ctx = buildCtx(engine, { allowedSources: ['tenant-a', 'tenant-b'] });
|
||||
|
||||
@@ -32,7 +32,7 @@ interface CapturedSql {
|
||||
params: unknown[];
|
||||
}
|
||||
|
||||
function buildMockEngine(opts: { scorecard: TakesScorecard; userHolder?: string | null }): {
|
||||
function buildMockEngine(opts: { scorecard: TakesScorecard }): {
|
||||
engine: BrainEngine;
|
||||
captured: CapturedSql[];
|
||||
} {
|
||||
@@ -42,10 +42,6 @@ function buildMockEngine(opts: { scorecard: TakesScorecard; userHolder?: string
|
||||
async getScorecard() {
|
||||
return opts.scorecard;
|
||||
},
|
||||
async getConfig(key: string): Promise<string | null> {
|
||||
if (key === 'emotional_weight.user_holder') return opts.userHolder ?? null;
|
||||
return null;
|
||||
},
|
||||
async executeRaw<T>(sql: string, params?: unknown[]): Promise<T[]> {
|
||||
captured.push({ sql, params: params ?? [] });
|
||||
return [];
|
||||
@@ -238,7 +234,7 @@ describe('runPhaseCalibrationProfile — phase integration', () => {
|
||||
// grade_completion, domain_scorecards_json, patterns[], voice_passed, voice_attempts,
|
||||
// bias_tags[], model_id
|
||||
expect(insert!.params[0]).toBe('default'); // source_id
|
||||
expect(insert!.params[1]).toBe('self'); // holder (resolved via resolveOwnerHolder, no override)
|
||||
expect(insert!.params[1]).toBe('garry'); // holder
|
||||
expect(insert!.params[2]).toBe(12); // total_resolved
|
||||
expect(insert!.params[9]).toBe(true); // voice_gate_passed
|
||||
expect(insert!.params[10]).toBe(1); // voice_gate_attempts
|
||||
@@ -334,24 +330,4 @@ describe('runPhaseCalibrationProfile — phase integration', () => {
|
||||
const insert = captured.find(c => c.sql.includes('INSERT INTO calibration_profiles'));
|
||||
expect(insert!.params[0]).toBe('tenant-b');
|
||||
});
|
||||
|
||||
test('cold-brain summary uses resolved owner holder self when user_holder unset', async () => {
|
||||
const { engine } = buildMockEngine({
|
||||
scorecard: { total_bets: 0, resolved: 0, correct: 0, incorrect: 0, partial: 0,
|
||||
accuracy: null, brier: null, partial_rate: null, unresolvable_count: 0, unresolvable_rate: null },
|
||||
});
|
||||
const result = await runPhaseCalibrationProfile(buildCtx(engine), {});
|
||||
expect(result.summary).toContain('holder=self');
|
||||
expect(result.summary).not.toContain('holder=garry');
|
||||
});
|
||||
|
||||
test('configured user_holder overrides the default in the cold-brain summary', async () => {
|
||||
const { engine } = buildMockEngine({
|
||||
scorecard: { total_bets: 0, resolved: 0, correct: 0, incorrect: 0, partial: 0,
|
||||
accuracy: null, brier: null, partial_rate: null, unresolvable_count: 0, unresolvable_rate: null },
|
||||
userHolder: 'people/charlie-example',
|
||||
});
|
||||
const result = await runPhaseCalibrationProfile(buildCtx(engine), {});
|
||||
expect(result.summary).toContain('holder=people/charlie-example');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,12 +32,6 @@ function buildMockEngine(opts: {
|
||||
}): BrainEngine {
|
||||
return {
|
||||
kind: 'pglite',
|
||||
// #2464: checkCalibrationFreshness resolves the owner holder via
|
||||
// resolveOwnerHolder(config emotional_weight.user_holder, else 'self'), so the
|
||||
// mock must implement getConfig. null = key unset → resolver falls back to 'self'.
|
||||
async getConfig(): Promise<string | null> {
|
||||
return null;
|
||||
},
|
||||
async executeRaw<T>(sql: string): Promise<T[]> {
|
||||
if (opts.throwOn && opts.throwOn.test(sql)) {
|
||||
throw new Error('mock engine error: ' + sql.slice(0, 50));
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* E2E smoke for skills/obsidian-gbrain-safe-index.
|
||||
*
|
||||
* Verifies the from-trigger-to-side-effect path that skillify requires:
|
||||
* a real user trigger phrase routes to the skill, the resolver/check
|
||||
* pipeline treats it as reachable, and the skill file exposes the
|
||||
* gbrain commands the workflow actually runs.
|
||||
*
|
||||
* This stays local-only (no paid embedding, no external API): it asserts
|
||||
* the documented safe/import path is present and parseable, not that it
|
||||
* mutates a live brain.
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
const SKILLS = join(import.meta.dir, '..', '..', 'skills');
|
||||
const SKILL_MD = join(SKILLS, 'obsidian-gbrain-safe-index', 'SKILL.md');
|
||||
const RESOLVER = join(SKILLS, 'RESOLVER.md');
|
||||
|
||||
const TRIGGER_PHRASES = [
|
||||
'connect my Obsidian vault to gbrain',
|
||||
'import my vault to gbrain',
|
||||
'sync vault and gbrain',
|
||||
'capture this skill in my vault',
|
||||
'embed gbrain after vault update',
|
||||
'is gbrain synced with my vault',
|
||||
];
|
||||
|
||||
describe('obsidian-gbrain-safe-index E2E', () => {
|
||||
it('resolver maps real trigger phrasings to the skill', () => {
|
||||
const resolver = readFileSync(RESOLVER, 'utf-8');
|
||||
expect(resolver).toContain('obsidian-gbrain-safe-index/SKILL.md');
|
||||
// Each representative phrase shares a token substring with a resolver row.
|
||||
const rows = resolver
|
||||
.split('\n')
|
||||
.filter((l) => l.includes('obsidian-gbrain-safe-index/SKILL.md'))
|
||||
.join('\n');
|
||||
for (const phrase of TRIGGER_PHRASES) {
|
||||
const hit = phrase
|
||||
.toLowerCase()
|
||||
.split(/\s+/)
|
||||
.some((tok) => tok.length > 3 && rows.toLowerCase().includes(tok));
|
||||
expect(hit, `no resolver token for: ${phrase}`).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('skill documents the gbrain import-first safe path', () => {
|
||||
const body = readFileSync(SKILL_MD, 'utf-8');
|
||||
expect(body).toContain('gbrain import');
|
||||
expect(body).toContain('--no-embed');
|
||||
expect(body).toContain('gbrain config set search.mode conservative');
|
||||
// Paid gate must be explicit, not a silent default.
|
||||
expect(body).toContain('gbrain embed --stale');
|
||||
});
|
||||
|
||||
it('skill is reachable from the skill tree', () => {
|
||||
expect(existsSync(SKILL_MD)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* E2E smoke for skills/skill-vault-capture-policy.
|
||||
*
|
||||
* Verifies the from-trigger-to-side-effect path: a real capture request
|
||||
* routes to the skill, and the skill documents the vault navigation
|
||||
* obligations (index.md / log.md) that make a capture durable.
|
||||
*
|
||||
* Local-only: it asserts documented behavior, not live vault writes.
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
const SKILLS = join(import.meta.dir, '..', '..', 'skills');
|
||||
const SKILL_MD = join(SKILLS, 'skill-vault-capture-policy', 'SKILL.md');
|
||||
const RESOLVER = join(SKILLS, 'RESOLVER.md');
|
||||
|
||||
const TRIGGER_PHRASES = [
|
||||
'save this learning to the vault',
|
||||
'capture this skill in Obsidian',
|
||||
'record this workflow in my notes',
|
||||
'put this setup change in the knowledge base',
|
||||
];
|
||||
|
||||
describe('skill-vault-capture-policy E2E', () => {
|
||||
it('resolver maps real capture phrasings to the skill', () => {
|
||||
const resolver = readFileSync(RESOLVER, 'utf-8');
|
||||
expect(resolver).toContain('skill-vault-capture-policy/SKILL.md');
|
||||
const rows = resolver
|
||||
.split('\n')
|
||||
.filter((l) => l.includes('skill-vault-capture-policy/SKILL.md'))
|
||||
.join('\n');
|
||||
for (const phrase of TRIGGER_PHRASES) {
|
||||
const hit = phrase
|
||||
.toLowerCase()
|
||||
.split(/\s+/)
|
||||
.some((tok) => tok.length > 3 && rows.toLowerCase().includes(tok));
|
||||
expect(hit, `no resolver token for: ${phrase}`).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('skill documents index.md and log.md update obligations', () => {
|
||||
const body = readFileSync(SKILL_MD, 'utf-8');
|
||||
expect(body).toContain('index.md');
|
||||
expect(body).toContain('log.md');
|
||||
});
|
||||
|
||||
it('skill is reachable from the skill tree', () => {
|
||||
expect(existsSync(SKILL_MD)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -112,7 +112,3 @@ describe('computeEmotionalWeight', () => {
|
||||
expect(HIGH_EMOTION_TAGS.has('mental-health')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
test('DEFAULT_USER_HOLDER is the canonical owner holder self', () => {
|
||||
expect(DEFAULT_USER_HOLDER).toBe('self');
|
||||
});
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import { readFileSync, existsSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
const SKILL_DIR = join(import.meta.dir, '..', 'skills', 'obsidian-gbrain-safe-index');
|
||||
const SKILL_MD = join(SKILL_DIR, 'SKILL.md');
|
||||
const RESOLVER = join(import.meta.dir, '..', 'skills', 'RESOLVER.md');
|
||||
|
||||
function parseFrontmatter(raw: string): Record<string, unknown> {
|
||||
const m = raw.match(/^---\n([\s\S]*?)\n---/);
|
||||
if (!m) throw new Error('no frontmatter');
|
||||
const out: Record<string, unknown> = {};
|
||||
for (const line of m[1].split('\n')) {
|
||||
const mm = line.match(/^([a-zA-Z_]+):\s*(.*)$/);
|
||||
if (mm) out[mm[1]] = mm[2].trim();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
describe('obsidian-gbrain-safe-index skill', () => {
|
||||
it('has a SKILL.md with required frontmatter', () => {
|
||||
expect(existsSync(SKILL_MD)).toBe(true);
|
||||
const fm = parseFrontmatter(readFileSync(SKILL_MD, 'utf-8'));
|
||||
expect(fm['name']).toBe('obsidian-gbrain-safe-index');
|
||||
expect(fm['description']).toBeTruthy();
|
||||
});
|
||||
|
||||
it('has the required conformance sections', () => {
|
||||
const body = readFileSync(SKILL_MD, 'utf-8');
|
||||
for (const section of ['## Contract', '## Phases', '## Output Format', '## Anti-Patterns']) {
|
||||
expect(body.includes(section), `missing ${section}`).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('is registered in RESOLVER.md', () => {
|
||||
expect(existsSync(RESOLVER)).toBe(true);
|
||||
const resolver = readFileSync(RESOLVER, 'utf-8');
|
||||
expect(resolver.includes('obsidian-gbrain-safe-index/SKILL.md')).toBe(true);
|
||||
});
|
||||
|
||||
it('has routing-eval fixtures that exercise real trigger phrasings', () => {
|
||||
const evalPath = join(SKILL_DIR, 'routing-eval.jsonl');
|
||||
expect(existsSync(evalPath)).toBe(true);
|
||||
const lines = readFileSync(evalPath, 'utf-8')
|
||||
.split('\n')
|
||||
.filter((l) => l.trim() && !l.trim().startsWith('//'))
|
||||
.map((l) => JSON.parse(l));
|
||||
const positives = lines.filter((l) => l.expected_skill === 'obsidian-gbrain-safe-index');
|
||||
expect(positives.length).toBeGreaterThanOrEqual(5);
|
||||
});
|
||||
});
|
||||
@@ -1,27 +0,0 @@
|
||||
import { describe, test, expect } from 'bun:test';
|
||||
import { resolveOwnerHolder, DEFAULT_OWNER_HOLDER } from '../src/core/owner-holder.ts';
|
||||
|
||||
describe('owner-holder', () => {
|
||||
test('DEFAULT_OWNER_HOLDER is self', () => {
|
||||
expect(DEFAULT_OWNER_HOLDER).toBe('self');
|
||||
});
|
||||
|
||||
test('defaults to self when nothing provided', () => {
|
||||
expect(resolveOwnerHolder({})).toBe('self');
|
||||
});
|
||||
|
||||
test('null/undefined config falls back to self', () => {
|
||||
expect(resolveOwnerHolder({ configValue: null })).toBe('self');
|
||||
expect(resolveOwnerHolder({ configValue: undefined })).toBe('self');
|
||||
});
|
||||
|
||||
test('uses config value when set and no override', () => {
|
||||
expect(resolveOwnerHolder({ configValue: 'people/charlie-example' }))
|
||||
.toBe('people/charlie-example');
|
||||
});
|
||||
|
||||
test('override beats config and default', () => {
|
||||
expect(resolveOwnerHolder({ override: 'world', configValue: 'people/charlie-example' }))
|
||||
.toBe('world');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import { readFileSync, existsSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { DEFAULT_PRIVATE_PATTERNS } from '../src/core/skillpack/harvest-lint.ts';
|
||||
|
||||
const SKILL_DIR = join(import.meta.dir, '..', 'skills', 'skill-vault-capture-policy');
|
||||
const SKILL_MD = join(SKILL_DIR, 'SKILL.md');
|
||||
const RESOLVER = join(import.meta.dir, '..', 'skills', 'RESOLVER.md');
|
||||
|
||||
function parseFrontmatter(raw: string): Record<string, unknown> {
|
||||
const m = raw.match(/^---\n([\s\S]*?)\n---/);
|
||||
if (!m) throw new Error('no frontmatter');
|
||||
const out: Record<string, unknown> = {};
|
||||
for (const line of m[1].split('\n')) {
|
||||
const mm = line.match(/^([a-zA-Z_]+):\s*(.*)$/);
|
||||
if (mm) out[mm[1]] = mm[2].trim();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
describe('skill-vault-capture-policy skill', () => {
|
||||
it('has a SKILL.md with required frontmatter', () => {
|
||||
expect(existsSync(SKILL_MD)).toBe(true);
|
||||
const fm = parseFrontmatter(readFileSync(SKILL_MD, 'utf-8'));
|
||||
expect(fm['name']).toBe('skill-vault-capture-policy');
|
||||
expect(fm['description']).toBeTruthy();
|
||||
});
|
||||
|
||||
it('has the required conformance sections', () => {
|
||||
const body = readFileSync(SKILL_MD, 'utf-8');
|
||||
for (const section of ['## Contract', '## Phases', '## Output Format', '## Anti-Patterns']) {
|
||||
expect(body.includes(section), `missing ${section}`).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('is registered in RESOLVER.md', () => {
|
||||
expect(existsSync(RESOLVER)).toBe(true);
|
||||
expect(readFileSync(RESOLVER, 'utf-8').includes('skill-vault-capture-policy/SKILL.md')).toBe(true);
|
||||
});
|
||||
|
||||
it('contains no private user or agent-fork names (privacy rule)', () => {
|
||||
for (const file of [SKILL_MD, join(SKILL_DIR, 'routing-eval.jsonl')]) {
|
||||
const body = readFileSync(file, 'utf-8');
|
||||
// DEFAULT_PRIVATE_PATTERNS[0] is the banned fork-name pattern; sourced
|
||||
// from harvest-lint so this file never contains the literal itself
|
||||
// (scripts/check-privacy.sh would reject it).
|
||||
const forkName = new RegExp(DEFAULT_PRIVATE_PATTERNS[0], 'i');
|
||||
for (const name of [/\bAdam\b/, /\bHermes\b/, /\bHerdr\b/, /\bArk\b/, forkName]) {
|
||||
expect(name.test(body), `private name ${name} in ${file}`).toBe(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('has routing-eval fixtures', () => {
|
||||
const evalPath = join(SKILL_DIR, 'routing-eval.jsonl');
|
||||
expect(existsSync(evalPath)).toBe(true);
|
||||
const positives = readFileSync(evalPath, 'utf-8')
|
||||
.split('\n')
|
||||
.filter((l) => l.trim() && !l.trim().startsWith('//'))
|
||||
.map((l) => JSON.parse(l))
|
||||
.filter((l) => l.expected_skill === 'skill-vault-capture-policy');
|
||||
expect(positives.length).toBeGreaterThanOrEqual(4);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user