wendkeep 0.72.1 → 0.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.en.md +37 -16
  3. package/README.md +37 -16
  4. package/docs/en/commands/changes-and-verification.md +10 -5
  5. package/docs/en/commands/maintenance-and-diagnostics.md +17 -9
  6. package/docs/en/commands/memory.md +16 -1
  7. package/docs/en/commands/observer.md +8 -1
  8. package/docs/en/commands/operating-profiles.md +28 -3
  9. package/docs/pt-BR/commands/changes-and-verification.md +10 -5
  10. package/docs/pt-BR/commands/maintenance-and-diagnostics.md +12 -5
  11. package/docs/pt-BR/commands/memory.md +16 -1
  12. package/docs/pt-BR/commands/observer.md +7 -1
  13. package/docs/pt-BR/commands/operating-profiles.md +28 -3
  14. package/hooks/brain-core.mjs +2 -0
  15. package/hooks/brain-inject.mjs +6 -6
  16. package/hooks/brain-recall.mjs +5 -1
  17. package/hooks/change-context.mjs +11 -0
  18. package/hooks/change-core.mjs +53 -21
  19. package/hooks/change-warn.mjs +2 -0
  20. package/hooks/evidence-context.mjs +41 -0
  21. package/hooks/evidence-recall.mjs +1 -0
  22. package/hooks/harness-doctor.mjs +13 -5
  23. package/hooks/memory-scope.mjs +1 -0
  24. package/hooks/vault-health.mjs +2 -2
  25. package/package.json +2 -2
  26. package/packages/cli/src/index.mjs +13 -3
  27. package/packages/integrations/src/host-hooks.mjs +1 -0
  28. package/packages/vault/src/evidence-recall.mjs +343 -0
  29. package/packages/vault/src/index.mjs +2 -0
  30. package/packages/vault/src/memory-handoff.mjs +58 -3
  31. package/packages/vault/src/memory-schema.mjs +12 -2
  32. package/packages/vault/src/memory-scope.mjs +119 -0
  33. package/packages/vault/src/memory-store.mjs +86 -24
  34. package/schema/observer/004-evidence-recall.sql +25 -0
  35. package/src/change.mjs +10 -4
  36. package/src/delivery.mjs +303 -0
  37. package/src/doctor.mjs +47 -10
  38. package/src/memory.mjs +95 -2
  39. package/src/observer-sql-store.mjs +141 -5
  40. package/src/release-provenance.mjs +47 -0
  41. package/src/skills-seed.mjs +25 -9
  42. package/src/sync-defs.mjs +5 -2
  43. package/src/sync.mjs +2 -2
  44. package/src/taxonomy.mjs +4 -0
  45. package/src/work-kind.mjs +62 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,67 @@ All notable changes to **wendkeep** are documented here. Format based on
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this project follows
5
5
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.74.0] — 2026-08-20
8
+
9
+ ### Added
10
+
11
+ - **Registradores de memória escopados.** Eventos novos declaram escopo de projeto, work session,
12
+ change, branch ou worktree. HEADs de branches paralelas coexistem, enquanto decisões,
13
+ constraints e blockers realmente incompatíveis continuam sob curadoria humana.
14
+ - **Migração append-only de escopo.** `memory rescope` mostra uma prévia sem valores e
15
+ `memory rescope --apply` anexa eventos de reescopo sem reescrever o ledger histórico; retry é
16
+ idempotente e candidates ambíguos não recebem vencedor automático.
17
+ - **Recall baseado em evidências.** O índice `.brain/EVIDENCE_INDEX.jsonl` divide Markdown por
18
+ headings, parágrafos, decisões, tarefas, requisitos e evidências, preservando origem, heading,
19
+ autoridade, validade, sessão, work session, change e hash.
20
+ - **Context broker por prompt.** `UserPromptSubmit` consulta o índice local, aplica ranking lexical
21
+ BM25 com frase exata, peso por campo, autoridade, validade, recência limitada e diversidade, e
22
+ injeta somente os melhores trechos dentro de um budget explícito.
23
+ - **FTS5 no Observer.** O schema SQL 4 mantém chunks por projeto, faz feature probe de FTS5 e usa o
24
+ mesmo ranking/proveniência do Keep Core com fallback lexical quando a extensão não está disponível.
25
+
26
+ ### Changed
27
+
28
+ - **Ambiguidade fica isolada.** Uma chave conflitante é omitida da projeção operacional e recebe
29
+ marcador de revisão; CORE e registros independentes continuam disponíveis.
30
+ - **`/brain-recall` retorna passagens.** Resultados agora apontam para o trecho do match e incluem
31
+ arquivo, heading, autoridade, data e validade, em vez de retornar somente nomes de sessões.
32
+
33
+ ### Performance
34
+
35
+ - Documentos excepcionalmente grandes usam amostragem distribuída limitada a 4 MiB no índice de
36
+ chunks, preservando o transporte gzip e evitando trabalho proporcional a transcripts gigantes.
37
+
38
+ ## [0.73.0] — 2026-08-20
39
+
40
+ ### Added
41
+
42
+ - **Work kind independente do perfil.** `inspection`, `maintenance`, `implementation`, `delivery`
43
+ e `recovery` passam a ser classificados separadamente de perfil, impacto de contrato e risco
44
+ operacional.
45
+ - **Delivery com autorização e receipt.** `delivery start/status/finish/abandon` captura repositório,
46
+ branch/worktree, SHA, change de origem e capabilities; comprova target, CI, versão, tag,
47
+ integridade npm e GitHub Release quando aplicável, sem criar change, spec ou ADR.
48
+ - **GUIDE realmente compacta.** `change new --guide` gera somente objetivo, critérios de aceite,
49
+ áreas afetadas, testes e resultado. Sem impacto de contrato, seu archive não fabrica design,
50
+ delta de spec ou ADR.
51
+
52
+ ### Changed
53
+
54
+ - **Doctor proporcional.** O diagnóstico separa erro estrutural, atenção de workflow, dívida
55
+ reparável e ambiguidade semântica. `--scope core|runtime` isola as superfícies e `--strict`
56
+ promove pendências a falha para CI/release.
57
+ - **Sync valida somente o Keep Core.** Trabalho em andamento no Wend Runtime deixa de transformar
58
+ uma instalação saudável em falha; a conclusão informa separadamente a saúde do Core.
59
+ - **Conflitos semânticos degradam por chave.** Candidates ativos aguardam curadoria sem bloquear o
60
+ bundle inteiro; corrupção de ledger, boundary, identidade ou projeção continua falhando fechada.
61
+
62
+ ### Fixed
63
+
64
+ - **Proveniência preserva lifecycle scripts.** A comparação de integridade executa `npm pack`
65
+ normalmente em uma cópia isolada, mantendo `prepack`/`postpack` e impedindo que a verificação
66
+ altere o working tree de origem.
67
+
7
68
  ## [0.72.1] — 2026-08-20
8
69
 
9
70
  ### Added
package/README.en.md CHANGED
@@ -84,11 +84,11 @@ Decisions, dead ends, the reason you chose X over Y — gone next session. The p
84
84
  |---|---|
85
85
  | **Capture** — every turn, on disk | `SessionStart` / `Stop` hooks write each session to a dated Markdown note: prompts, iterations, files touched, wikilinks. |
86
86
  | **Derive** — decisions, bugs, learnings | Pulled from the transcript into their own notes, backlinked to the session. Your history becomes navigable, not archival. |
87
- | **Recall** — injected back | Canonical `CORE` + operational `SHARED_MEMORY`, with explicit budgets, are injected on `startup`, `/clear`, and `/compact`; `DIGEST` remains a deep-recall index and legacy fallback. |
87
+ | **Recall** — injected back | Canonical `CORE` + operational `SHARED_MEMORY` enter on `startup`, `/clear`, and `/compact`; on every prompt, the local chunk index selects a few passages with source, authority, and validity under an explicit budget. |
88
88
  | **Cost** — what it all cost | Per‑model, cache‑aware token pricing per session — plus `cost --trend` with a run‑rate projection across the whole vault; research previews without a final rate remain unestimated. |
89
89
  | **Multi‑agent** — one vault, both agents | `init` wires the session hooks into `.claude/settings.json` *and* `.codex/hooks.json`, and every note is tagged with the agent that wrote it: Claude Code is detected from its environment, anything else is recorded as Codex. One shared graph, whichever agent you are in. |
90
90
  | **Local‑first** — no cloud, no account | Everything is plain Markdown on your disk. An optional MCP server (`@bitbonsai/mcpvault`) lets the agent read/write the vault. |
91
- | **Local Observer** — many projects, one view | `wendkeep observer` keeps documents, sessions, agents, tokens, costs, calls, and transcripts in the Docker volume SQLite database; every project gets a **Consumption** tab in the read-only dashboard at `http://127.0.0.1:8787/`, loopback has no token, and unavailable hooks use a gzip outbox without blocking the session, including large transcripts. |
91
+ | **Local Observer** — many projects, one view | `wendkeep observer` keeps documents, FTS5 chunks, sessions, agents, tokens, costs, calls, and transcripts in SQLite; search returns the matching passage with provenance and falls back to the local lexical ranker when FTS5 is unavailable. |
92
92
 
93
93
  During historical migration, the Observer preserves differences between frontmatter totals and the
94
94
  ledger as explicit reconciliation rows, and disambiguates duplicate `session_id` values per file
@@ -100,7 +100,7 @@ The Codex scope guard treats `commit`, `push`, `pull`, `merge`, `publish`, and d
100
100
  operations as independent capabilities, including inside compound commands.
101
101
 
102
102
  - Node.js ≥ 18
103
- - An AI coding agent with hooks. `init` wires **Claude Code** and **Codex** automatically — Codex gets eight compatible hooks, including the scoped `PreToolUse` guard, and enumerates them untrusted, so approve its “Hooks need review” prompt once at startup (see [Notes & roadmap](#notes--roadmap))
103
+ - An AI coding agent with hooks. `init` wires **Claude Code** and **Codex** automatically — Codex gets twelve compatible hooks, including per-prompt recall and the scoped `PreToolUse` guard, and enumerates them untrusted, so approve its “Hooks need review” prompt once at startup (see [Notes & roadmap](#notes--roadmap))
104
104
  - Obsidian (to view the graph) — optional but the point
105
105
 
106
106
  ## Install & set up
@@ -115,7 +115,7 @@ npx wendkeep init
115
115
 
116
116
  1. Create the vault folder taxonomy and a templated `README.md` (default vault: `<project>/.<project-name>-vault`, e.g. `.MyApp-vault`; override with `--vault`).
117
117
  2. Write a provider-neutral **`.wendkeep.json`** binding at the project root and a matching `.brain/PROJECT.json` marker in the vault, then merge the session hooks into **`.claude/settings.json`**. The binding is provider-neutral by design: any agent resolves the same vault from its session `cwd`, with no machine-global environment variable. Older registrations already in `.claude/settings.json` are adopted automatically.
118
- 3. Wire the Codex hooks in **`.codex/hooks.json`** — eleven compatible entries: `brain-inject` + `session-start` + `observer-publish` on `SessionStart`, `session-ensure` + `change-context` on `UserPromptSubmit`, `session-stop` + `observer-publish` + `change-nag` on `Stop`, `subagent-stop` + `observer-publish` on `SubagentStop`, and `change-guard` on `PreToolUse` for `Bash`, `exec_command`, `apply_patch`, and mutable MCP tools, always in the `npx wendkeep hook <name>` form. `observer-publish` keeps the sanitized index projection and also sends the local SQL authority with documents, consumption, and transcripts; it does not replace the local lifecycle. The guard accepts object, raw-string, and argv Codex payloads; before a mutation it compares the session with the project, Git root, remote, branch, and worktree, denying missing or divergent targets. The other four stay out because Codex offers no equivalent payload, tool, or event: `change-warn` (no reliable `tool_input.file_path`), `plan-capture` (no `ExitPlanMode`), `decision-capture` (`AskUserQuestion` is Claude-only), and `task-log` (`TaskCompleted` is not in Codex's event enum). Codex scope blocks use `permissionDecision: "deny"`; `ask` is never emitted in `PreToolUse`. The merge remains non-destructive, preserves third-party hooks, and migrates legacy `timeout` to `timeoutSec`. **Codex enumerates every hook as untrusted and runs none until you approve the “Hooks need review” prompt at startup — `init` cannot pre-approve them**.
118
+ 3. Wire the Codex hooks in **`.codex/hooks.json`** — twelve compatible entries: `brain-inject` + `session-start` + `observer-publish` on `SessionStart`, `session-ensure` + `evidence-context` + `change-context` on `UserPromptSubmit`, `session-stop` + `observer-publish` + `change-nag` on `Stop`, `subagent-stop` + `observer-publish` on `SubagentStop`, and `change-guard` on `PreToolUse` for `Bash`, `exec_command`, `apply_patch`, and mutable MCP tools, always in the `npx wendkeep hook <name>` form. `observer-publish` keeps the sanitized index projection and also sends the local SQL authority with documents, consumption, and transcripts; it does not replace the local lifecycle. The guard accepts object, raw-string, and argv Codex payloads; before a mutation it compares the session with the project, Git root, remote, branch, and worktree, denying missing or divergent targets. The other four stay out because Codex offers no equivalent payload, tool, or event: `change-warn` (no reliable `tool_input.file_path`), `plan-capture` (no `ExitPlanMode`), `decision-capture` (`AskUserQuestion` is Claude-only), and `task-log` (`TaskCompleted` is not in Codex's event enum). Codex scope blocks use `permissionDecision: "deny"`; `ask` is never emitted in `PreToolUse`. The merge remains non-destructive, preserves third-party hooks, and migrates legacy `timeout` to `timeoutSec`. **Codex enumerates every hook as untrusted and runs none until you approve the “Hooks need review” prompt at startup — `init` cannot pre-approve them**.
119
119
  4. Add the **`wendkeep-vault`** MCP server to `.mcp.json` so the agent can read/write the vault. Skip with `--no-mcp` — e.g. when the agent already has a vault MCP. (`--no-mcp` skips *only wendkeep's own* MCP; companion MCPs still follow `--companions`.)
120
120
  5. Offer to pin **companion** plugins/MCP (multi-choice; **none** pre-checked — wendkeep is a neutral harness and presumes no third-party plugin). Each is wired the most agent-agnostic way it supports:
121
121
  - **`context-mode`** — context optimizer + FTS5 memory, wired as a Claude Code plugin. It ships its own MCP server, so wendkeep deliberately adds no `.mcp.json` entry (registering both cold-started two servers at once). On non-Claude agents, add the MCP by hand: `npx -y context-mode`.
@@ -125,9 +125,9 @@ npx wendkeep init
125
125
 
126
126
  Control with `--companions <csv>` or `--no-companions`. The Claude Code plugin layer (`extraKnownMarketplaces` + `enabledPlugins`) is wired as a bonus where the companion has one.
127
127
  6. Install a **color system** into the vault's `.obsidian/`: a CSS snippet that accents notes by type (session/decision/bug/learning, via the `cssclasses` the hooks emit) plus graph color groups by folder. Non-destructive merge into `appearance.json`/`graph.json`; skip with `--no-colors`. Re-apply it any time on an existing vault with `wendkeep theme sync` — Obsidian owns `graph.json` and can drop the color groups (a grey graph); the re-sync restores them without a full re-`init`.
128
- 7. Seed **Shared Project Memory v2** without overwriting existing artifacts: `.brain/CORE.md` (hand-curated canonical truth), `.brain/SHARED_MEMORY.md` (generated operational state), `.brain/MEMORY_EVENTS.jsonl` (append-only ledger), `.brain/MEMORY_CANDIDATES.jsonl` (curation queue), and `.brain/COMPACTION_PROTOCOL.md`. The durable outbox appears under `.brain/memory-outbox/` when events exist; `DIGEST.md` and `index.jsonl` remain deep recall. Everything stays local to the vault.
128
+ 7. Seed **Shared Project Memory v2** without overwriting existing artifacts: `.brain/CORE.md`, `.brain/SHARED_MEMORY.md`, `.brain/MEMORY_EVENTS.jsonl`, `.brain/MEMORY_CANDIDATES.jsonl`, and `.brain/COMPACTION_PROTOCOL.md`. The durable outbox appears under `.brain/memory-outbox/`; `EVIDENCE_INDEX.jsonl` is rebuilt locally from chunks while `DIGEST.md`/`index.jsonl` remain compatible. Everything stays in the vault.
129
129
  8. Seed the **definitions + skills layer**: `.brain/agents/` + `.brain/skills/` (versioned source of truth), including the native process skills `wk-workflow` / `wk-tdd` / `wk-debugging` / `wk-brainstorming` / `wk-planning` / `wk-verify` (some ship templates — e.g. `wk-verify`'s `verdict-template.json` + reviewer prompt). `init` runs `wendkeep sync-defs` for you, delivering the skills to `.claude/skills/` and `.agents/skills/`, and the agent definitions (`.brain/agents/*.toml`) to `.codex/agents/`, plus a managed section in `AGENTS.md` that indexes the skills for Codex; `sync-defs --check` detects stale copies (re-run `sync-defs` after editing `.brain`).
130
- 9. Seed the **change/spec lifecycle**: the `07-Specs/` + `08-Mudanças/` folders and a native `wendkeep.sensors.json` — critical memory validation/health sensors plus one for each of `typecheck` / `test` / `lint` / `build` found in your `package.json`. `memory-health` blocks delivery on corruption, projection divergence, or an active conflict; pending outbox events and ordinary candidates are warnings. Add sensors with `wendkeep sensors add`. Drives `wendkeep change` / `wendkeep verify` — see **Change lifecycle** below.
130
+ 9. Seed the **change/spec lifecycle**: the `07-Specs/` + `08-Mudanças/` folders and a native `wendkeep.sensors.json` — critical memory validation/health sensors plus one for each of `typecheck` / `test` / `lint` / `build` found in your `package.json`. `memory-health` blocks delivery on corruption or projection divergence; semantic conflicts degrade only the affected keys and await curation. Pending outbox events and ordinary candidates are warnings. Add sensors with `wendkeep sensors add`. Drives `wendkeep change` / `wendkeep verify` — see **Change lifecycle** below.
131
131
 
132
132
  ```bash
133
133
  npx wendkeep init --vault "~/vaults/work" --project . --yes # non-interactive (no companions unless you ask)
@@ -257,7 +257,7 @@ deliberate opt-in and runs that command's own validations:
257
257
  |---|---|---|
258
258
  | `OFF` | LLM-native harness | No Wend router, skill gate, or gates; explicit selection only. |
259
259
  | `FLOW` | E → V | Microcontract with Git baseline, allowlist, sensor, and receipt, without a change. |
260
- | `GUIDE` | P → E → V | Compact guided change. |
260
+ | `GUIDE` | P → E → V | Compact change; no automatic design/spec/ADR when contract impact is none. |
261
261
  | `GOVERN` | P → R → E → V | Current a2 loop and compatible fallback. |
262
262
  | `ASSURE` | P → R → E → V → C | Governance with confirmation and handoff. |
263
263
 
@@ -317,13 +317,25 @@ positive causal turn and sequence that agree in the registry.
317
317
  “Small” describes size, not risk. The harness uses this matrix to choose and record a temporary
318
318
  route; semantic inference remains in the agent, not Wend Runtime:
319
319
 
320
- | Situation | Suggested profile |
321
- |---|---|
322
- | Question, inspection, or diagnosis with no mutation | No profile transition |
323
- | Local, reversible fix with an allowlist and no contract/spec change | `FLOW` (`E → V`) |
324
- | Small behavior change that needs a change but not formal Wend Runtime review | `GUIDE` (`P → E → V`) |
325
- | Normal, ambiguous, public-contract, security, dependency, CI/release, or policy change | `GOVERN` (`P R → E → V`) |
326
- | Work requiring explicit confirmation and handoff | `ASSURE` (`P R → E → V → C`) |
320
+ | Situation | Work kind | Suggested profile | New change |
321
+ |---|---|---|---|
322
+ | Question, inspection, or diagnosis with no mutation | `inspection` | No transition | No |
323
+ | Local, reversible fix with an allowlist and no contract/spec change | `maintenance` | `FLOW` (`E → V`) | No |
324
+ | Small behavior change without formal review | `implementation` | `GUIDE` (`P → E → V`) | Yes, compact |
325
+ | Public contract, security, schema, dependency, CI/release workflow, or policy | `implementation` | `GOVERN`/`ASSURE` | Yes |
326
+ | Merge, push, tag, or publication of approved behavior | `delivery` | `ASSURE` | No |
327
+ | Operational recovery without code/config correction | `recovery` | `FLOW`/`ASSURE` | No |
328
+
329
+ Work kind, profile, contract impact, and operational risk are independent dimensions. A
330
+ `delivery` records authorized capabilities and an append-only receipt without creating a change,
331
+ spec, or ADR. If delivery requires a code/config edit, it pauses and work returns to
332
+ `implementation`:
333
+
334
+ ```bash
335
+ npx wendkeep delivery start release-0-74-0 --allow git:merge --allow git:push --allow publish --source-change <slug> --source-commit <sha>
336
+ npx wendkeep delivery status release-0-74-0
337
+ npx wendkeep delivery finish release-0-74-0 --target main --ci-url <url> --version 0.74.0 --npm-integrity <sha512> --release-url <url>
338
+ ```
327
339
 
328
340
  If the harness does not record a lease, a small fix remains under the configured profile —
329
341
  `GOVERN` by default. `OFF` does not mean “simple task”: it is a persistent human choice that hands
@@ -344,6 +356,11 @@ and owner+lease locks validate physical topology. Concurrent promotion elects on
344
356
  retry through `--change-slug`. Read the complete
345
357
  [Operating profiles guide](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/operating-profiles.md).
346
358
 
359
+ `wendkeep doctor` separates structural errors, workflow attention, repairable debt, and semantic
360
+ ambiguity. Use `--scope core` for Keep Core health, `--scope runtime` for governance, and
361
+ `--strict` in CI/release; `wendkeep sync` validates Core only so work in progress does not become
362
+ an installation failure.
363
+
347
364
  ## Shared Project Memory v2
348
365
 
349
366
  Hot memory now separates human authorship, operational state, and evidence:
@@ -352,6 +369,8 @@ Hot memory now separates human authorship, operational state, and evidence:
352
369
  - **`SHARED_MEMORY.md` is generated operational state.** The `Stop` hook turns the session handoff into sanitized events; the projector deterministically reduces the ledger and publishes a verifiable revision, cursor, and hash. Facts are `verified` only with local evidence; unsupported reports remain `reported`, and disagreements become candidates for human judgment.
353
370
  - **`MEMORY_EVENTS.jsonl` is the append-only authority.** `Stop` makes events durable in the outbox before acknowledging the attempt; the projector runs outside the registry lock and retries reuse the same IDs. Repeating an identical `event_id`/payload is a no-op; reusing the ID with different bytes is observable corruption.
354
371
  - **`MEMORY_CANDIDATES.jsonl` is the curation queue.** Conflicts and legacy content are never silently promoted. `promote` and `reject` record the decision as a new event; promotion preserves the selected event's JSON type, session, activation/epoch, and source turn.
372
+ - **Registers are scoped.** `git.local-head`, handoffs, verdicts, and change status carry project, work-session, change, branch, or worktree scope. Two branches do not create a global conflict; only events in the same scope and causal lineage may advance automatically.
373
+ - **`EVIDENCE_INDEX.jsonl` is local recall.** Markdown is chunked by headings and blocks without requiring the Observer. Ranking combines BM25, exact phrases, field weights, authority, validity, bounded recency, and source diversity; `UserPromptSubmit` injects only relevant passages with provenance.
355
374
 
356
375
  Artifacts stay under `.brain/` only. Sanitization strips secrets, tokens, local paths, transcripts, and harness payloads both before persistence and before injection. Events carry a `project_id`, and one vault never accepts another project's events.
357
376
 
@@ -373,6 +392,8 @@ Codex uses `session_id`/`turn_id` plus transcript order, with no artificial caus
373
392
  npx --no-install wendkeep memory status --gate --vault .MyApp-vault
374
393
  npx --no-install wendkeep memory migrate --vault .MyApp-vault # preview, zero writes
375
394
  npx --no-install wendkeep memory migrate --apply --vault .MyApp-vault # backup + candidates + v2 bundle
395
+ npx --no-install wendkeep memory rescope --vault .MyApp-vault # preview without values
396
+ npx --no-install wendkeep memory rescope --apply --vault .MyApp-vault # append-only and idempotent
376
397
  ```
377
398
 
378
399
  ### Health and recovery
@@ -487,10 +508,10 @@ Beyond capturing sessions, wendkeep is a **harness**: a native, zero‑dependenc
487
508
  explore → propose → apply (TDD) → verify → archive
488
509
  ```
489
510
 
490
- - **Propose** — `wendkeep change new <slug>` scaffolds `08-Mudanças/<slug>/` (`proposta.md`, `design.md`, `tarefas.md`; `--simple` skips the design). It becomes the global *current* change. When the change declares `spec_impact: required`, you author the delta yourself at `specs/<capability>/spec.md` — there is no placeholder to delete. Multiple changes may remain open: `change list`/`status` and the hooks show every pending one, while commands without `--change` act on the current one alone. `change use <slug>` changes focus and `change continue <archived> <new>` creates an auditable continuation.
511
+ - **Propose** — `wendkeep change new <slug>` scaffolds `08-Mudanças/<slug>/` (`proposta.md`, `design.md`, `tarefas.md`; `--simple` skips the design). `--guide` creates the compact GUIDE contract and omits automatic design/spec/ADR when `contract_impact:none`. It becomes the global *current* change. When the change declares `spec_impact: required`, you author the delta yourself at `specs/<capability>/spec.md` — there is no placeholder to delete. Multiple changes may remain open: `change list`/`status` and the hooks show every pending one, while commands without `--change` act on the current one alone. `change use <slug>` changes focus and `change continue <archived> <new>` creates an auditable continuation.
491
512
  - **Apply** — implement each `tarefas.md` task. Mark machine proof with one or more `[sensor:<id>]` tags on the same task: every distinct ID enters the gate once, in declaration order. Also mark satisfied requirements with one or more `[req:<ID>]` tags.
492
513
  - **Verify** — `wendkeep verify` runs the sensors your tasks declared (from `wendkeep.sensors.json` at the project root) and writes `evidencia.json`. A red `critical` fails the gate; a red `warning` is advisory. Failures retain only a bounded, sanitized diagnostic; green output is not persisted. `verify --deep` builds a self-contained package with complete effective requirements (living contract + this change's delta), so the independent verifier never needs to reconstruct unarchived requirements from `07-Specs`. Every change needs a `verdict.json` to archive; `verify --deep` writes a trivial one automatically when the change declares no `[req:]`.
493
- - **Archive** — `wendkeep change archive <slug>` **gates** on the evidence (blocks unless every declared critical sensor is green), promotes each capability's spec delta (`ADDED`/`MODIFIED`/`REMOVED`) into the living `07-Specs/<capability>.md`, moves the change to `_arquivo/`, and mints an ADR in `04-Decisões/`.
514
+ - **Archive** — `wendkeep change archive <slug>` **gates** on the evidence (blocks unless every declared critical sensor is green), promotes each applicable spec delta (`ADDED`/`MODIFIED`/`REMOVED`) into the living `07-Specs/<capability>.md` and moves the change to `_arquivo/`. GOVERN/ASSURE mint an ADR in `04-Decisões/`; compact GUIDE with no contract impact does not mint one automatically.
494
515
 
495
516
  > The gate blocks unless the scaffold is filled, no task is open, evidence is fresh, and every declared requirement is covered. **`--force` waives exactly one of those — the open-task check — and is the human's call, never the agent's.** An unfilled scaffold, a red critical sensor, stale evidence, an orphan requirement or a missing verdict block regardless.
496
517
 
package/README.md CHANGED
@@ -84,11 +84,11 @@ Decisions, dead ends, the reason you chose X over Y — gone next session. The p
84
84
  |---|---|
85
85
  | **Capture** — every turn, on disk | `SessionStart` / `Stop` hooks write each session to a dated Markdown note: prompts, iterations, files touched, wikilinks. |
86
86
  | **Derive** — decisions, bugs, learnings | Pulled from the transcript into their own notes, backlinked to the session. Your history becomes navigable, not archival. |
87
- | **Recall** — injected back | Canonical `CORE` + operational `SHARED_MEMORY`, with explicit budgets, are injected on `startup`, `/clear`, and `/compact`; `DIGEST` remains a deep-recall index and legacy fallback. |
87
+ | **Recall** — injected back | Canonical `CORE` + operational `SHARED_MEMORY` enter on `startup`, `/clear`, and `/compact`; on every prompt, the local chunk index selects a few passages with source, authority, and validity under an explicit budget. |
88
88
  | **Cost** — what it all cost | Per‑model, cache‑aware token pricing per session — plus `cost --trend` with a run‑rate projection across the whole vault; research previews without a final rate remain unestimated. |
89
89
  | **Multi‑agent** — one vault, both agents | `init` wires the session hooks into `.claude/settings.json` *and* `.codex/hooks.json`, and every note is tagged with the agent that wrote it: Claude Code is detected from its environment, anything else is recorded as Codex. One shared graph, whichever agent you are in. |
90
90
  | **Local‑first** — no cloud, no account | Everything is plain Markdown on your disk. An optional MCP server (`@bitbonsai/mcpvault`) lets the agent read/write the vault. |
91
- | **Local Observer** — many projects, one view | `wendkeep observer` keeps documents, sessions, agents, tokens, costs, calls, and transcripts in the Docker volume SQLite database; every project gets a **Consumption** tab in the read-only dashboard at `http://127.0.0.1:8787/`, loopback has no token, and unavailable hooks use a gzip outbox without blocking the session, including large transcripts. |
91
+ | **Local Observer** — many projects, one view | `wendkeep observer` keeps documents, FTS5 chunks, sessions, agents, tokens, costs, calls, and transcripts in SQLite; search returns the matching passage with provenance and falls back to the local lexical ranker when FTS5 is unavailable. |
92
92
 
93
93
  During historical migration, the Observer preserves differences between frontmatter totals and the
94
94
  ledger as explicit reconciliation rows, and disambiguates duplicate `session_id` values per file
@@ -100,7 +100,7 @@ The Codex scope guard treats `commit`, `push`, `pull`, `merge`, `publish`, and d
100
100
  operations as independent capabilities, including inside compound commands.
101
101
 
102
102
  - Node.js ≥ 18
103
- - An AI coding agent with hooks. `init` wires **Claude Code** and **Codex** automatically — Codex gets eight compatible hooks, including the scoped `PreToolUse` guard, and enumerates them untrusted, so approve its “Hooks need review” prompt once at startup (see [Notes & roadmap](#notes--roadmap))
103
+ - An AI coding agent with hooks. `init` wires **Claude Code** and **Codex** automatically — Codex gets twelve compatible hooks, including per-prompt recall and the scoped `PreToolUse` guard, and enumerates them untrusted, so approve its “Hooks need review” prompt once at startup (see [Notes & roadmap](#notes--roadmap))
104
104
  - Obsidian (to view the graph) — optional but the point
105
105
 
106
106
  ## Install & set up
@@ -115,7 +115,7 @@ npx wendkeep init
115
115
 
116
116
  1. Create the vault folder taxonomy and a templated `README.md` (default vault: `<project>/.<project-name>-vault`, e.g. `.MyApp-vault`; override with `--vault`).
117
117
  2. Write a provider-neutral **`.wendkeep.json`** binding at the project root and a matching `.brain/PROJECT.json` marker in the vault, then merge the session hooks into **`.claude/settings.json`**. The binding is provider-neutral by design: any agent resolves the same vault from its session `cwd`, with no machine-global environment variable. Older registrations already in `.claude/settings.json` are adopted automatically.
118
- 3. Wire the Codex hooks in **`.codex/hooks.json`** — eleven compatible entries: `brain-inject` + `session-start` + `observer-publish` on `SessionStart`, `session-ensure` + `change-context` on `UserPromptSubmit`, `session-stop` + `observer-publish` + `change-nag` on `Stop`, `subagent-stop` + `observer-publish` on `SubagentStop`, and `change-guard` on `PreToolUse` for `Bash`, `exec_command`, `apply_patch`, and mutable MCP tools, always in the `npx wendkeep hook <name>` form. `observer-publish` keeps the sanitized index projection and also sends the local SQL authority with documents, consumption, and transcripts; it does not replace the local lifecycle. The guard accepts object, raw-string, and argv Codex payloads; before a mutation it compares the session with the project, Git root, remote, branch, and worktree, denying missing or divergent targets. The other four stay out because Codex offers no equivalent payload, tool, or event: `change-warn` (no reliable `tool_input.file_path`), `plan-capture` (no `ExitPlanMode`), `decision-capture` (`AskUserQuestion` is Claude-only), and `task-log` (`TaskCompleted` is not in Codex's event enum). Codex scope blocks use `permissionDecision: "deny"`; `ask` is never emitted in `PreToolUse`. The merge remains non-destructive, preserves third-party hooks, and migrates legacy `timeout` to `timeoutSec`. **Codex enumerates every hook as untrusted and runs none until you approve the “Hooks need review” prompt at startup — `init` cannot pre-approve them**.
118
+ 3. Wire the Codex hooks in **`.codex/hooks.json`** — twelve compatible entries: `brain-inject` + `session-start` + `observer-publish` on `SessionStart`, `session-ensure` + `evidence-context` + `change-context` on `UserPromptSubmit`, `session-stop` + `observer-publish` + `change-nag` on `Stop`, `subagent-stop` + `observer-publish` on `SubagentStop`, and `change-guard` on `PreToolUse` for `Bash`, `exec_command`, `apply_patch`, and mutable MCP tools, always in the `npx wendkeep hook <name>` form. `observer-publish` keeps the sanitized index projection and also sends the local SQL authority with documents, consumption, and transcripts; it does not replace the local lifecycle. The guard accepts object, raw-string, and argv Codex payloads; before a mutation it compares the session with the project, Git root, remote, branch, and worktree, denying missing or divergent targets. The other four stay out because Codex offers no equivalent payload, tool, or event: `change-warn` (no reliable `tool_input.file_path`), `plan-capture` (no `ExitPlanMode`), `decision-capture` (`AskUserQuestion` is Claude-only), and `task-log` (`TaskCompleted` is not in Codex's event enum). Codex scope blocks use `permissionDecision: "deny"`; `ask` is never emitted in `PreToolUse`. The merge remains non-destructive, preserves third-party hooks, and migrates legacy `timeout` to `timeoutSec`. **Codex enumerates every hook as untrusted and runs none until you approve the “Hooks need review” prompt at startup — `init` cannot pre-approve them**.
119
119
  4. Add the **`wendkeep-vault`** MCP server to `.mcp.json` so the agent can read/write the vault. Skip with `--no-mcp` — e.g. when the agent already has a vault MCP. (`--no-mcp` skips *only wendkeep's own* MCP; companion MCPs still follow `--companions`.)
120
120
  5. Offer to pin **companion** plugins/MCP (multi-choice; **none** pre-checked — wendkeep is a neutral harness and presumes no third-party plugin). Each is wired the most agent-agnostic way it supports:
121
121
  - **`context-mode`** — context optimizer + FTS5 memory, wired as a Claude Code plugin. It ships its own MCP server, so wendkeep deliberately adds no `.mcp.json` entry (registering both cold-started two servers at once). On non-Claude agents, add the MCP by hand: `npx -y context-mode`.
@@ -125,9 +125,9 @@ npx wendkeep init
125
125
 
126
126
  Control with `--companions <csv>` or `--no-companions`. The Claude Code plugin layer (`extraKnownMarketplaces` + `enabledPlugins`) is wired as a bonus where the companion has one.
127
127
  6. Install a **color system** into the vault's `.obsidian/`: a CSS snippet that accents notes by type (session/decision/bug/learning, via the `cssclasses` the hooks emit) plus graph color groups by folder. Non-destructive merge into `appearance.json`/`graph.json`; skip with `--no-colors`. Re-apply it any time on an existing vault with `wendkeep theme sync` — Obsidian owns `graph.json` and can drop the color groups (a grey graph); the re-sync restores them without a full re-`init`.
128
- 7. Seed **Shared Project Memory v2** without overwriting existing artifacts: `.brain/CORE.md` (hand-curated canonical truth), `.brain/SHARED_MEMORY.md` (generated operational state), `.brain/MEMORY_EVENTS.jsonl` (append-only ledger), `.brain/MEMORY_CANDIDATES.jsonl` (curation queue), and `.brain/COMPACTION_PROTOCOL.md`. The durable outbox appears under `.brain/memory-outbox/` when events exist; `DIGEST.md` and `index.jsonl` remain deep recall. Everything stays local to the vault.
128
+ 7. Seed **Shared Project Memory v2** without overwriting existing artifacts: `.brain/CORE.md`, `.brain/SHARED_MEMORY.md`, `.brain/MEMORY_EVENTS.jsonl`, `.brain/MEMORY_CANDIDATES.jsonl`, and `.brain/COMPACTION_PROTOCOL.md`. The durable outbox appears under `.brain/memory-outbox/`; `EVIDENCE_INDEX.jsonl` is rebuilt locally from chunks while `DIGEST.md`/`index.jsonl` remain compatible. Everything stays in the vault.
129
129
  8. Seed the **definitions + skills layer**: `.brain/agents/` + `.brain/skills/` (versioned source of truth), including the native process skills `wk-workflow` / `wk-tdd` / `wk-debugging` / `wk-brainstorming` / `wk-planning` / `wk-verify` (some ship templates — e.g. `wk-verify`'s `verdict-template.json` + reviewer prompt). `init` runs `wendkeep sync-defs` for you, delivering the skills to `.claude/skills/` and `.agents/skills/`, and the agent definitions (`.brain/agents/*.toml`) to `.codex/agents/`, plus a managed section in `AGENTS.md` that indexes the skills for Codex; `sync-defs --check` detects stale copies (re-run `sync-defs` after editing `.brain`).
130
- 9. Seed the **change/spec lifecycle**: the `07-Specs/` + `08-Mudanças/` folders and a native `wendkeep.sensors.json` — critical memory validation/health sensors plus one for each of `typecheck` / `test` / `lint` / `build` found in your `package.json`. `memory-health` blocks delivery on corruption, projection divergence, or an active conflict; pending outbox events and ordinary candidates are warnings. Add sensors with `wendkeep sensors add`. Drives `wendkeep change` / `wendkeep verify` — see **Change lifecycle** below.
130
+ 9. Seed the **change/spec lifecycle**: the `07-Specs/` + `08-Mudanças/` folders and a native `wendkeep.sensors.json` — critical memory validation/health sensors plus one for each of `typecheck` / `test` / `lint` / `build` found in your `package.json`. `memory-health` blocks delivery on corruption or projection divergence; semantic conflicts degrade only the affected keys and await curation. Pending outbox events and ordinary candidates are warnings. Add sensors with `wendkeep sensors add`. Drives `wendkeep change` / `wendkeep verify` — see **Change lifecycle** below.
131
131
 
132
132
  ```bash
133
133
  npx wendkeep init --vault "~/vaults/work" --project . --yes # non-interactive (no companions unless you ask)
@@ -257,7 +257,7 @@ deliberate opt-in and runs that command's own validations:
257
257
  |---|---|---|
258
258
  | `OFF` | LLM-native harness | No Wend router, skill gate, or gates; explicit selection only. |
259
259
  | `FLOW` | E → V | Microcontract with Git baseline, allowlist, sensor, and receipt, without a change. |
260
- | `GUIDE` | P → E → V | Compact guided change. |
260
+ | `GUIDE` | P → E → V | Compact change; no automatic design/spec/ADR when contract impact is none. |
261
261
  | `GOVERN` | P → R → E → V | Current a2 loop and compatible fallback. |
262
262
  | `ASSURE` | P → R → E → V → C | Governance with confirmation and handoff. |
263
263
 
@@ -317,13 +317,25 @@ positive causal turn and sequence that agree in the registry.
317
317
  “Small” describes size, not risk. The harness uses this matrix to choose and record a temporary
318
318
  route; semantic inference remains in the agent, not Wend Runtime:
319
319
 
320
- | Situation | Suggested profile |
321
- |---|---|
322
- | Question, inspection, or diagnosis with no mutation | No profile transition |
323
- | Local, reversible fix with an allowlist and no contract/spec change | `FLOW` (`E → V`) |
324
- | Small behavior change that needs a change but not formal Wend Runtime review | `GUIDE` (`P → E → V`) |
325
- | Normal, ambiguous, public-contract, security, dependency, CI/release, or policy change | `GOVERN` (`P R → E → V`) |
326
- | Work requiring explicit confirmation and handoff | `ASSURE` (`P R → E → V → C`) |
320
+ | Situation | Work kind | Suggested profile | New change |
321
+ |---|---|---|---|
322
+ | Question, inspection, or diagnosis with no mutation | `inspection` | No transition | No |
323
+ | Local, reversible fix with an allowlist and no contract/spec change | `maintenance` | `FLOW` (`E → V`) | No |
324
+ | Small behavior change without formal review | `implementation` | `GUIDE` (`P → E → V`) | Yes, compact |
325
+ | Public contract, security, schema, dependency, CI/release workflow, or policy | `implementation` | `GOVERN`/`ASSURE` | Yes |
326
+ | Merge, push, tag, or publication of approved behavior | `delivery` | `ASSURE` | No |
327
+ | Operational recovery without code/config correction | `recovery` | `FLOW`/`ASSURE` | No |
328
+
329
+ Work kind, profile, contract impact, and operational risk are independent dimensions. A
330
+ `delivery` records authorized capabilities and an append-only receipt without creating a change,
331
+ spec, or ADR. If delivery requires a code/config edit, it pauses and work returns to
332
+ `implementation`:
333
+
334
+ ```bash
335
+ npx wendkeep delivery start release-0-74-0 --allow git:merge --allow git:push --allow publish --source-change <slug> --source-commit <sha>
336
+ npx wendkeep delivery status release-0-74-0
337
+ npx wendkeep delivery finish release-0-74-0 --target main --ci-url <url> --version 0.74.0 --npm-integrity <sha512> --release-url <url>
338
+ ```
327
339
 
328
340
  If the harness does not record a lease, a small fix remains under the configured profile —
329
341
  `GOVERN` by default. `OFF` does not mean “simple task”: it is a persistent human choice that hands
@@ -344,6 +356,11 @@ and owner+lease locks validate physical topology. Concurrent promotion elects on
344
356
  retry through `--change-slug`. Read the complete
345
357
  [Operating profiles guide](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/operating-profiles.md).
346
358
 
359
+ `wendkeep doctor` separates structural errors, workflow attention, repairable debt, and semantic
360
+ ambiguity. Use `--scope core` for Keep Core health, `--scope runtime` for governance, and
361
+ `--strict` in CI/release; `wendkeep sync` validates Core only so work in progress does not become
362
+ an installation failure.
363
+
347
364
  ## Shared Project Memory v2
348
365
 
349
366
  Hot memory now separates human authorship, operational state, and evidence:
@@ -352,6 +369,8 @@ Hot memory now separates human authorship, operational state, and evidence:
352
369
  - **`SHARED_MEMORY.md` is generated operational state.** The `Stop` hook turns the session handoff into sanitized events; the projector deterministically reduces the ledger and publishes a verifiable revision, cursor, and hash. Facts are `verified` only with local evidence; unsupported reports remain `reported`, and disagreements become candidates for human judgment.
353
370
  - **`MEMORY_EVENTS.jsonl` is the append-only authority.** `Stop` makes events durable in the outbox before acknowledging the attempt; the projector runs outside the registry lock and retries reuse the same IDs. Repeating an identical `event_id`/payload is a no-op; reusing the ID with different bytes is observable corruption.
354
371
  - **`MEMORY_CANDIDATES.jsonl` is the curation queue.** Conflicts and legacy content are never silently promoted. `promote` and `reject` record the decision as a new event; promotion preserves the selected event's JSON type, session, activation/epoch, and source turn.
372
+ - **Registers are scoped.** `git.local-head`, handoffs, verdicts, and change status carry project, work-session, change, branch, or worktree scope. Two branches do not create a global conflict; only events in the same scope and causal lineage may advance automatically.
373
+ - **`EVIDENCE_INDEX.jsonl` is local recall.** Markdown is chunked by headings and blocks without requiring the Observer. Ranking combines BM25, exact phrases, field weights, authority, validity, bounded recency, and source diversity; `UserPromptSubmit` injects only relevant passages with provenance.
355
374
 
356
375
  Artifacts stay under `.brain/` only. Sanitization strips secrets, tokens, local paths, transcripts, and harness payloads both before persistence and before injection. Events carry a `project_id`, and one vault never accepts another project's events.
357
376
 
@@ -373,6 +392,8 @@ Codex uses `session_id`/`turn_id` plus transcript order, with no artificial caus
373
392
  npx --no-install wendkeep memory status --gate --vault .MyApp-vault
374
393
  npx --no-install wendkeep memory migrate --vault .MyApp-vault # preview, zero writes
375
394
  npx --no-install wendkeep memory migrate --apply --vault .MyApp-vault # backup + candidates + v2 bundle
395
+ npx --no-install wendkeep memory rescope --vault .MyApp-vault # preview without values
396
+ npx --no-install wendkeep memory rescope --apply --vault .MyApp-vault # append-only and idempotent
376
397
  ```
377
398
 
378
399
  ### Health and recovery
@@ -487,10 +508,10 @@ Beyond capturing sessions, wendkeep is a **harness**: a native, zero‑dependenc
487
508
  explore → propose → apply (TDD) → verify → archive
488
509
  ```
489
510
 
490
- - **Propose** — `wendkeep change new <slug>` scaffolds `08-Mudanças/<slug>/` (`proposta.md`, `design.md`, `tarefas.md`; `--simple` skips the design). It becomes the global *current* change. When the change declares `spec_impact: required`, you author the delta yourself at `specs/<capability>/spec.md` — there is no placeholder to delete. Multiple changes may remain open: `change list`/`status` and the hooks show every pending one, while commands without `--change` act on the current one alone. `change use <slug>` changes focus and `change continue <archived> <new>` creates an auditable continuation.
511
+ - **Propose** — `wendkeep change new <slug>` scaffolds `08-Mudanças/<slug>/` (`proposta.md`, `design.md`, `tarefas.md`; `--simple` skips the design). `--guide` creates the compact GUIDE contract and omits automatic design/spec/ADR when `contract_impact:none`. It becomes the global *current* change. When the change declares `spec_impact: required`, you author the delta yourself at `specs/<capability>/spec.md` — there is no placeholder to delete. Multiple changes may remain open: `change list`/`status` and the hooks show every pending one, while commands without `--change` act on the current one alone. `change use <slug>` changes focus and `change continue <archived> <new>` creates an auditable continuation.
491
512
  - **Apply** — implement each `tarefas.md` task. Mark machine proof with one or more `[sensor:<id>]` tags on the same task: every distinct ID enters the gate once, in declaration order. Also mark satisfied requirements with one or more `[req:<ID>]` tags.
492
513
  - **Verify** — `wendkeep verify` runs the sensors your tasks declared (from `wendkeep.sensors.json` at the project root) and writes `evidencia.json`. A red `critical` fails the gate; a red `warning` is advisory. Failures retain only a bounded, sanitized diagnostic; green output is not persisted. `verify --deep` builds a self-contained package with complete effective requirements (living contract + this change's delta), so the independent verifier never needs to reconstruct unarchived requirements from `07-Specs`. Every change needs a `verdict.json` to archive; `verify --deep` writes a trivial one automatically when the change declares no `[req:]`.
493
- - **Archive** — `wendkeep change archive <slug>` **gates** on the evidence (blocks unless every declared critical sensor is green), promotes each capability's spec delta (`ADDED`/`MODIFIED`/`REMOVED`) into the living `07-Specs/<capability>.md`, moves the change to `_arquivo/`, and mints an ADR in `04-Decisões/`.
514
+ - **Archive** — `wendkeep change archive <slug>` **gates** on the evidence (blocks unless every declared critical sensor is green), promotes each applicable spec delta (`ADDED`/`MODIFIED`/`REMOVED`) into the living `07-Specs/<capability>.md` and moves the change to `_arquivo/`. GOVERN/ASSURE mint an ADR in `04-Decisões/`; compact GUIDE with no contract impact does not mint one automatically.
494
515
 
495
516
  > The gate blocks unless the scaffold is filled, no task is open, evidence is fresh, and every declared requirement is covered. **`--force` waives exactly one of those — the open-task check — and is the human's call, never the agent's.** An unfilled scaffold, a red critical sensor, stale evidence, an orphan requirement or a missing verdict block regardless.
496
517
 
@@ -25,7 +25,7 @@ Initialize the project, keep the vault healthy, and provide a valid `wendkeep.se
25
25
  ## Syntax
26
26
 
27
27
  ```bash
28
- npx wendkeep change new <slug>
28
+ npx wendkeep change new <slug> [--simple|--guide]
29
29
  npx wendkeep change status [slug]
30
30
  npx wendkeep spec effective --change <slug>
31
31
  npx wendkeep sensors list
@@ -35,8 +35,10 @@ npx wendkeep change archive <slug>
35
35
 
36
36
  ## Options and exit codes
37
37
 
38
- - `wendkeep change new <slug> [--simple]` creates a change; `--simple` only skips design, is not
39
- `FLOW`, and preserves the legacy lifecycle/ADR contract.
38
+ - `wendkeep change new <slug> [--simple|--guide]` creates a change. `--simple` only skips design,
39
+ is not `FLOW`, and preserves the legacy lifecycle/ADR contract. `--guide` creates the compact
40
+ GUIDE contract (objective, acceptance, areas, tests, and result), with no automatic
41
+ design/spec/ADR when `contract_impact:none`.
40
42
  - `change use`, `list`, `show`, `status`, `diff`, `done`, and `undone` inspect or update work
41
43
  without archiving it.
42
44
  - `change continue <archived> <new>` starts follow-up work without inheriting stale proof.
@@ -52,6 +54,7 @@ npx wendkeep change archive <slug>
52
54
 
53
55
  ```bash
54
56
  npx wendkeep change new tenant-login
57
+ npx wendkeep change new internal-adjustment --guide
55
58
  npx wendkeep spec effective --change tenant-login
56
59
  npx wendkeep change done 1.1 --change tenant-login
57
60
  npx wendkeep verify --change tenant-login
@@ -67,8 +70,10 @@ npx wendkeep sensors add api-contracts "npm run test:contracts" --severity criti
67
70
 
68
71
  ## Expected result
69
72
 
70
- An archived change promotes its delta into the living spec, preserves proposal/design/tasks/proof,
71
- and mints an ADR. Archive passes only with closed tasks, green required sensors, and a fresh verdict.
73
+ An archived change promotes its delta into the living spec when applicable and preserves proposal,
74
+ tasks/proof, and design when present. GOVERN/ASSURE mint an ADR; compact GUIDE with no contract
75
+ impact does not mint one automatically. Archive passes only with closed tasks, green required
76
+ sensors, and a fresh verdict.
72
77
 
73
78
  ## Tool-scope fence
74
79
 
@@ -23,7 +23,7 @@ Run from the project root or provide `--project` and `--vault` explicitly.
23
23
  ## Syntax
24
24
 
25
25
  ```bash
26
- npx --no-install wendkeep doctor [--vault <vault>]
26
+ npx --no-install wendkeep doctor [--vault <vault>] [--scope all|core|runtime] [--strict]
27
27
  npx --no-install wendkeep memory curate --vault <vault>
28
28
  npx --no-install wendkeep sync-defs [--check|--reseed] --vault <vault> --project <root>
29
29
  npx --no-install wendkeep theme sync --vault <vault>
@@ -33,7 +33,10 @@ npx --no-install wendkeep --help
33
33
 
34
34
  ## Options and exit codes
35
35
 
36
- - `doctor` is read-only; exit `0` accepts recoverable warnings, while non-zero means failure.
36
+ - `doctor` is read-only. By default only structural errors produce a non-zero exit; `--strict`
37
+ also fails on workflow attention, repairable debt, semantic degradation, and warnings.
38
+ - `--scope core` checks the installation, binding, ledger, and Keep Core only. `--scope runtime`
39
+ checks changes, sensors, and governance only. The default `all` reports both surfaces.
37
40
  - `doctor` uses human-readable output with `[integrity]` and `[memory]` sections, friendly
38
41
  categories, and a copyable next action. The `vault-health.mjs` hook remains the JSON surface for
39
42
  automation; neither surface applies curation.
@@ -44,8 +47,9 @@ npx --no-install wendkeep --help
44
47
  IDs, and checkpoint) with outbox, ledger, and SHARED; they do not infer health from revision alone.
45
48
  - `revision: 0` after a valid migration, with no v2 attempt, is healthy. A `degraded` attempt whose
46
49
  events remain durable in the outbox/ledger is a recoverable warning.
47
- - An ambiguous attempt, a lost event ID (absent from ledger and outbox), `projected` state found
48
- only in the outbox, or a mismatched checkpoint is blocking.
50
+ - An ambiguous publication attempt, a lost event ID (absent from ledger and outbox), `projected`
51
+ state found only in the outbox, or a mismatched checkpoint is a structural block. Active
52
+ semantic candidates degrade memory by key and remain available for explicit curation.
49
53
  - For session observability, `legacy`, `degraded`, `stale`, and `manifest-unproven` require
50
54
  reconciliation or more evidence. Only fresh `none` and fresh `complete` are healthy: frontier,
51
55
  checkpoint, root stat, and source manifest must agree.
@@ -63,6 +67,8 @@ Post-update checklist:
63
67
  npx --no-install wendkeep --version
64
68
  npx --no-install wendkeep sync-defs --check --vault .MyApp-vault --project .
65
69
  npx --no-install wendkeep doctor --vault .MyApp-vault
70
+ npx --no-install wendkeep doctor --scope core --vault .MyApp-vault
71
+ npx --no-install wendkeep doctor --scope runtime --strict --vault .MyApp-vault
66
72
  npx --no-install wendkeep memory status --gate --vault .MyApp-vault
67
73
  npx --no-install wendkeep memory curate --vault .MyApp-vault
68
74
  npx --no-install wendkeep memory candidates --active --vault .MyApp-vault
@@ -72,10 +78,11 @@ npx --no-install wendkeep cost rebuild --session <id> --json --vault .MyApp-vaul
72
78
 
73
79
  ## Expected result
74
80
 
75
- Doctor names sessions, registry, links, notes, prices, derived sections, and memory as healthy or
81
+ Doctor separates structural errors, workflow attention, repairable debt, and semantic ambiguity.
82
+ It names sessions, registry, links, notes, prices, derived sections, and memory as healthy or
76
83
  provides a specific diagnostic/repair command. For memory, it distinguishes a valid initial empty
77
- state, recoverable pending replay, and lost/divergent lifecycle state. It never repairs implicitly
78
- or echoes private projector-error content into its report. For session observability, it separates
84
+ state, recoverable pending replay, key-scoped conflicts, and lost/divergent lifecycle state. It
85
+ never repairs implicitly or echoes private projector-error content into its report. For session observability, it separates
79
86
  fresh `none`/`complete` from legacy, degraded, stale, or manifest-unproven state and gives a
80
87
  dry-run path before any write.
81
88
 
@@ -87,10 +94,11 @@ dry-run path before any write.
87
94
  `npx --no-install wendkeep memory migrate --apply --vault <vault>` with the resolved Vault, but
88
95
  migration remains opt-in and must be planned separately.
89
96
  - `degraded` plus an intact outbox: warning; preserve the outbox and allow idempotent replay.
90
- - `ambiguous`, lost publication, or a mismatched checkpoint: blocking; preserve registry, ledger,
97
+ - Ambiguous publication, lost publication, or a mismatched checkpoint: blocking; preserve registry, ledger,
91
98
  outbox, and SHARED so `last_memory_attempt` can be correlated before repair.
92
99
  - Corrupt bundle: preserve evidence and run `memory status --gate` before `memory repair`.
93
- - An active semantic conflict requires a human decision: `memory repair` does not choose a winner.
100
+ - An active semantic conflict degrades only the affected memory key and requires a human decision:
101
+ `memory repair` does not choose a winner.
94
102
  Start with the guided menu `memory curate --vault <vault>`. For advanced inspection or a
95
103
  non-interactive terminal, list safe IDs with `memory candidates --active --vault <vault>`, review
96
104
  the evidence, and then use
@@ -30,6 +30,7 @@ Pass the vault explicitly in automation. Preserve backups and evidence before re
30
30
  npx wendkeep memory status [--gate] --vault <vault>
31
31
  npx wendkeep memory curate --vault <vault>
32
32
  npx wendkeep memory candidates [--active] --vault <vault>
33
+ npx wendkeep memory rescope [--apply] --vault <vault>
33
34
  npx wendkeep memory repair --vault <vault>
34
35
  npx wendkeep memory recover-attempt <session> [--apply] --vault <vault>
35
36
  npx wendkeep memory reconcile <ambiguous-session> --by-session <successor-session> --reason <reason> [--apply] --vault <vault>
@@ -51,7 +52,7 @@ npx wendkeep validate-memory --vault <v2-vault>
51
52
  non-TTY environment it exits `2` without changing bytes and recommends the advanced fallback
52
53
  `memory candidates --active`.
53
54
  - `memory candidates` is read-only and prints deterministic JSON containing only `candidate_id`,
54
- `reason`, `status`, `memory_key`, and `event_ids`; it does not expose memory values or content and
55
+ `reason`, `status`, `memory_key`, scope when present, and `event_ids`; it does not expose memory values or content and
55
56
  does not create a lock or mutate the bundle. `--active` omits terminal candidates (`resolved`,
56
57
  `rejected`, and `superseded`). A missing status is normalized to `active`.
57
58
  - For `memory candidates`, exit `0` means a valid inventory (including empty or conflicted), exit
@@ -95,6 +96,18 @@ npx wendkeep validate-memory --vault <v2-vault>
95
96
  and its successor. Replay is CORE-aware, checkpoints use the physical ledger cursor, and the
96
97
  command neither rewrites ledger/CORE/notes nor consumes the outbox. Retrying the same applied
97
98
  decision is idempotent.
99
+ - `memory rescope` is a dry run by default and lists only planned IDs, keys, and scopes. With
100
+ `--apply`, it appends explicit project, work-session, change, branch, or worktree events while
101
+ preserving historic bytes as the ledger prefix. Ambiguous candidates are neither migrated nor
102
+ assigned a winner; retry returns `unchanged`.
103
+ - Registers such as `git.local-head`, `handoff.latest`, `quality.latest-*`, and
104
+ `change.<slug>.status` compete only inside the same scope. Automatic resolution still requires
105
+ the same project and causal lineage; incompatible decisions, constraints, and blockers remain
106
+ human-curated. An ambiguous key is omitted from SHARED without removing CORE or independent keys.
107
+ - `.brain/EVIDENCE_INDEX.jsonl` chunks documents by heading and block and records file, heading,
108
+ type, change, session, work session, authority, date, validity, and hash. `/brain-recall` and the
109
+ `UserPromptSubmit` hook use BM25, exact phrase, field weights, authority, validity, bounded
110
+ recency, and diversity to return the matching passage with provenance.
98
111
  - Every memory path validates the physical topology of `.brain`, ledger, outbox, CORE, SHARED,
99
112
  candidates, registry, notes, backups, temporary files, and sidecars before reading or writing.
100
113
  Junctions, symlinks, reparse points, or hardlinks fail closed without touching external bytes.
@@ -136,6 +149,8 @@ npx wendkeep validate-memory --vault <v2-vault>
136
149
  npx wendkeep memory status --gate --vault .MyApp-vault
137
150
  npx wendkeep memory curate --vault .MyApp-vault
138
151
  npx wendkeep memory candidates --active --vault .MyApp-vault
152
+ npx wendkeep memory rescope --vault .MyApp-vault
153
+ npx wendkeep memory rescope --apply --vault .MyApp-vault
139
154
  npx wendkeep memory recover-attempt session-123 --vault .MyApp-vault
140
155
  npx wendkeep memory recover-attempt session-123 --apply --vault .MyApp-vault
141
156
  npx wendkeep memory reconcile old --by-session current --reason "delivery continued" --vault .MyApp-vault
@@ -96,6 +96,12 @@ cost/token total recorded in frontmatter is preserved through an explicit reconc
96
96
  the detailed ledger does not add up; that row does not invent calls. Historical sessions sharing
97
97
  one `session_id` receive a canonical per-file identity so one rollup cannot overwrite the other.
98
98
 
99
+ In schema 4, each ingested document is also projected into chunks carrying path, heading,
100
+ authority, time, and validity. The Observer feature-probes FTS5 and uses the index when the
101
+ extension is available; otherwise it preserves the same semantics through a lexical fallback.
102
+ Search returns the passage containing the match and its provenance rather than only the beginning
103
+ of the document.
104
+
99
105
  `init` projects `observer-publish` into `SessionStart`, `Stop`, and `SubagentStop` after the primary
100
106
  hooks. When the server is unavailable, it writes snapshots to `.brain/observer-outbox/` and SQL
101
107
  events to `.brain/observer-sql-outbox/` without blocking the session; a later run retries the
@@ -139,7 +145,8 @@ complete, archive, repair, or promote state.
139
145
  rollups, calls, and transcripts.
140
146
  - `GET /v1/projects/:project_id/memory/tree` — document tree and metadata.
141
147
  - `GET /v1/projects/:project_id/memory/document?path=...` — complete Markdown content.
142
- - `GET /v1/projects/:project_id/memory/search?q=...` — path and body search.
148
+ - `GET /v1/projects/:project_id/memory/search?q=...` — ranked chunk search with matching passage
149
+ and provenance; uses a lexical fallback when FTS5 is unavailable.
143
150
  - `GET /v1/projects/:project_id/sync` — mode, counts, conflicts, and latest event.
144
151
  - `PUT /v1/projects/:project_id/sync` — compatibility configuration; SQL remains authoritative.
145
152
  - `GET /v1/projects/:project_id/memory/export` — read-only export with complete content.