wendkeep 0.66.3 → 0.66.5

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,40 @@ 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.66.5] — 2026-08-01
8
+
9
+ ### Fixed
10
+
11
+ - **A observabilidade Codex passa a registrar o grafo completo de subagentes.** Metadata é
12
+ lida incrementalmente mesmo em rollouts grandes; descendentes em dias posteriores ou níveis
13
+ aninhados são atribuídos uma única vez, enquanto transcripts top-level permanecem no bucket
14
+ principal e sinais duplicados ou atrasados não regridem o snapshot publicado.
15
+ - **SessionStop e SubagentStop convergem sob frontier causal e estado explícito.** O schema 2
16
+ distingue `complete`, `none` e `degraded`, coalesce rajadas com lease, preserva o último
17
+ snapshot íntegro diante de fonte incompleta e mantém cache/runtime reconstruíveis sem publicar
18
+ zero silencioso.
19
+ - **Rebuild, import e doctor agora reconciliam a observabilidade persistida.** Preview permanece
20
+ sem escrita, apply rejeita resultado parcial, import atualiza notas completas porém stale e o
21
+ doctor correlaciona checkpoint, manifest e dirty para expor degradação real.
22
+
23
+ ### Security
24
+
25
+ - **Diagnostics e provas públicas aplicam uma fronteira de privacidade estável.** Somente pares
26
+ allowlisted `{code,count}` podem ser persistidos; paths, identificadores, prompts e exceções
27
+ brutas ficam fora de fixtures, evidências e notas de release.
28
+
29
+ ## [0.66.4] — 2026-07-30
30
+
31
+ ### Fixed
32
+
33
+ - **`memory repair` fecha o acknowledgement apenas para a outbox que a própria execução
34
+ consumiu integralmente.** O receipt do projetor preserva idempotência e impede que attempts
35
+ históricos, parciais, causalmente divergentes ou concorrentes sejam reclassificados.
36
+ - **`memory recover-attempt <session>` recupera com segurança o estado já projetado pela
37
+ 0.66.3.** O dry-run é padrão e `--apply` altera somente o registry/checkpoint sob prova física,
38
+ lock e CAS; A→B→A, ledger/sidecars divergentes, outbox pendente e links inseguros falham sem
39
+ escrita. O diagnóstico agora orienta esse comando quando o acknowledgement ficou pendente.
40
+
7
41
  ## [0.66.3] — 2026-07-30
8
42
 
9
43
  ### Fixed
package/README.en.md CHANGED
@@ -211,10 +211,10 @@ The README is the map; the guides provide syntax, options, exit codes, examples,
211
211
  | **Operating profiles** | `profile`, `flow`, always-on Keep Core, and Wend Runtime governance | [Operating profiles](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/operating-profiles.md) |
212
212
  | **Changes and verification** | `change`, specs, sensors, TDD, evidence, and archive | [Changes and verification](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/changes-and-verification.md) |
213
213
  | **Shared memory** | CORE, SHARED, status, validation, repair, and curation | [Memory](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/memory.md) |
214
- | **Sessions and import** | hooks, registry, session focus, and Claude/Codex backfill | [Sessions and import](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/sessions-and-import.md) |
214
+ | **Sessions and import** | causal hooks, observability reconciliation, and Claude/Codex backfill | [Sessions and import](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/sessions-and-import.md) |
215
215
  | **Notes and knowledge** | BUG/APR/ADR, repairs, renumbering, lessons, and dashboard | [Notes and knowledge](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/notes-and-knowledge.md) |
216
- | **Costs and observability** | stats, aggregation, trends, and historical rebuild | [Costs and observability](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/costs-and-observability.md) |
217
- | **Maintenance and diagnostics** | doctor, definition drift, theme, version, and help | [Maintenance and diagnostics](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/maintenance-and-diagnostics.md) |
216
+ | **Costs and observability** | safe dry-run, tri-state, aggregation, trends, and historical rebuild | [Costs and observability](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/costs-and-observability.md) |
217
+ | **Maintenance and diagnostics** | doctor, frontier/manifest freshness, drift, version, and help | [Maintenance and diagnostics](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/maintenance-and-diagnostics.md) |
218
218
 
219
219
  Operations that deserve step-by-step guidance: [verify and exits 0/1/2](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/verify.md),
220
220
  [legacy-memory migration](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/memory-migration.md), and
@@ -287,8 +287,10 @@ lost publication, or mismatched checkpoint blocks. See [migration](docs/en/comma
287
287
  and [diagnostics](docs/en/commands/maintenance-and-diagnostics.md).
288
288
 
289
289
  If status blocks, preserve the evidence and run `wendkeep memory repair --vault <vault>` to back up
290
- the corrupt ledger, retain valid lines, and re-project. Repair never reclassifies attempts. Valid
291
- pre-0.59 causal checkpoints and exactly re-derived assert-only historical prefixes are
290
+ the corrupt ledger, retain valid lines, and re-project. Repair remains structural: its only narrow
291
+ acknowledgement exception covers attempts entirely represented by the outbox consumed by that same
292
+ run; it does not scan or reclassify historical attempts. Valid pre-0.59 causal checkpoints and
293
+ exactly re-derived assert-only historical prefixes are
292
294
  CAS-migrated on both the attempt and `memory_checkpoint` to the correct physical boundary with
293
295
  backup/audit; divergent mirrors fail closed. A demonstrably superseded
294
296
  ambiguity uses `memory reconcile <session> --by-session <successor>
@@ -303,9 +305,12 @@ final modern source: the same session/activation/epoch and a higher turn advance
303
305
  superseded. Repair migrates the checkpoint and mirror only when it proves the exact previous
304
306
  replay, attempt identity, and absence of a real conflict; it creates a backup and audit without
305
307
  appending or rewriting events. Ambiguity stays queued for explicit curation. Do not publish or
306
- install 0.66.2; use 0.66.3. Decisions survive repair/replay;
307
- `blocked_by_core` cannot override CORE. Doctor only
308
- diagnoses. See [memory and curation](docs/en/commands/memory.md).
308
+ install 0.66.2; use 0.66.3 or later. Decisions survive repair/replay;
309
+ `blocked_by_core` cannot override CORE. Doctor only diagnoses. When status/doctor reports projected
310
+ acknowledgement pending on 0.66.4 or later, first run the targeted dry run
311
+ `memory recover-attempt <session> --vault <vault>`, then authorize `--apply`; it changes only
312
+ registry/checkpoint. See syntax, preconditions, and fail-closed behavior in
313
+ [memory and curation](docs/en/commands/memory.md).
309
314
 
310
315
  Session notes use one live `## Agentes, tokens e custos` snapshot. Main-agent and subagent hooks recompose it atomically, with costs, token dimensions, reasoning tokens and effort per model/source. Every hook that rewrites a session note takes a per-file lock and writes through a temp file + rename, so the `SubagentStop` fan-out (one hook run per subagent) can never leave a note half-written; a note whose frontmatter reads back damaged is left untouched rather than patched.
311
316
 
package/README.md CHANGED
@@ -211,10 +211,10 @@ The README is the map; the guides provide syntax, options, exit codes, examples,
211
211
  | **Operating profiles** | `profile`, `flow`, always-on Keep Core, and Wend Runtime governance | [Operating profiles](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/operating-profiles.md) |
212
212
  | **Changes and verification** | `change`, specs, sensors, TDD, evidence, and archive | [Changes and verification](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/changes-and-verification.md) |
213
213
  | **Shared memory** | CORE, SHARED, status, validation, repair, and curation | [Memory](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/memory.md) |
214
- | **Sessions and import** | hooks, registry, session focus, and Claude/Codex backfill | [Sessions and import](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/sessions-and-import.md) |
214
+ | **Sessions and import** | causal hooks, observability reconciliation, and Claude/Codex backfill | [Sessions and import](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/sessions-and-import.md) |
215
215
  | **Notes and knowledge** | BUG/APR/ADR, repairs, renumbering, lessons, and dashboard | [Notes and knowledge](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/notes-and-knowledge.md) |
216
- | **Costs and observability** | stats, aggregation, trends, and historical rebuild | [Costs and observability](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/costs-and-observability.md) |
217
- | **Maintenance and diagnostics** | doctor, definition drift, theme, version, and help | [Maintenance and diagnostics](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/maintenance-and-diagnostics.md) |
216
+ | **Costs and observability** | safe dry-run, tri-state, aggregation, trends, and historical rebuild | [Costs and observability](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/costs-and-observability.md) |
217
+ | **Maintenance and diagnostics** | doctor, frontier/manifest freshness, drift, version, and help | [Maintenance and diagnostics](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/maintenance-and-diagnostics.md) |
218
218
 
219
219
  Operations that deserve step-by-step guidance: [verify and exits 0/1/2](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/verify.md),
220
220
  [legacy-memory migration](https://github.com/rogersialves/wendkeep/blob/main/docs/en/commands/memory-migration.md), and
@@ -287,8 +287,10 @@ lost publication, or mismatched checkpoint blocks. See [migration](docs/en/comma
287
287
  and [diagnostics](docs/en/commands/maintenance-and-diagnostics.md).
288
288
 
289
289
  If status blocks, preserve the evidence and run `wendkeep memory repair --vault <vault>` to back up
290
- the corrupt ledger, retain valid lines, and re-project. Repair never reclassifies attempts. Valid
291
- pre-0.59 causal checkpoints and exactly re-derived assert-only historical prefixes are
290
+ the corrupt ledger, retain valid lines, and re-project. Repair remains structural: its only narrow
291
+ acknowledgement exception covers attempts entirely represented by the outbox consumed by that same
292
+ run; it does not scan or reclassify historical attempts. Valid pre-0.59 causal checkpoints and
293
+ exactly re-derived assert-only historical prefixes are
292
294
  CAS-migrated on both the attempt and `memory_checkpoint` to the correct physical boundary with
293
295
  backup/audit; divergent mirrors fail closed. A demonstrably superseded
294
296
  ambiguity uses `memory reconcile <session> --by-session <successor>
@@ -303,9 +305,12 @@ final modern source: the same session/activation/epoch and a higher turn advance
303
305
  superseded. Repair migrates the checkpoint and mirror only when it proves the exact previous
304
306
  replay, attempt identity, and absence of a real conflict; it creates a backup and audit without
305
307
  appending or rewriting events. Ambiguity stays queued for explicit curation. Do not publish or
306
- install 0.66.2; use 0.66.3. Decisions survive repair/replay;
307
- `blocked_by_core` cannot override CORE. Doctor only
308
- diagnoses. See [memory and curation](docs/en/commands/memory.md).
308
+ install 0.66.2; use 0.66.3 or later. Decisions survive repair/replay;
309
+ `blocked_by_core` cannot override CORE. Doctor only diagnoses. When status/doctor reports projected
310
+ acknowledgement pending on 0.66.4 or later, first run the targeted dry run
311
+ `memory recover-attempt <session> --vault <vault>`, then authorize `--apply`; it changes only
312
+ registry/checkpoint. See syntax, preconditions, and fail-closed behavior in
313
+ [memory and curation](docs/en/commands/memory.md).
309
314
 
310
315
  Session notes use one live `## Agentes, tokens e custos` snapshot. Main-agent and subagent hooks recompose it atomically, with costs, token dimensions, reasoning tokens and effort per model/source. Every hook that rewrites a session note takes a per-file lock and writes through a temp file + rename, so the `SubagentStop` fan-out (one hook run per subagent) can never leave a note half-written; a note whose frontmatter reads back damaged is left untouched rather than patched.
311
316
 
@@ -26,7 +26,7 @@ A consistent registry, complete price table, and transcript access for rebuilt s
26
26
  ```bash
27
27
  npx wendkeep stats [--vault <vault>] [--json]
28
28
  npx wendkeep cost [--since <date>] [--top [N]] [--trend day|week|month] [--write] [--json]
29
- npx wendkeep cost rebuild [--session <id|file>] [--limit N] [--apply] [--json]
29
+ npx wendkeep cost rebuild [--session <id|file>] [--limit N] [--max-graph-nodes N] [--max-fallback-days N] [--max-fallback-candidates N] [--apply] [--json]
30
30
  ```
31
31
 
32
32
  ## Options and exit codes
@@ -34,10 +34,18 @@ npx wendkeep cost rebuild [--session <id|file>] [--limit N] [--apply] [--json]
34
34
  - `wendkeep stats` emits one shareable line or JSON.
35
35
  - `wendkeep cost` aggregates total/model/day; `--trend` adds projection and `--write` refreshes
36
36
  `00-Custo.md`.
37
- - `wendkeep cost rebuild` is dry-run by default; `--apply` writes notes and
38
- `.brain/COST_REBUILD.json`.
39
- - Exit `0` means a consistent calculation; non-zero reports insufficient registry, price,
40
- transcript, or parsing state.
37
+ - `wendkeep cost rebuild` is dry-run by default and performs **zero writes**: it acquires no write
38
+ lock, changes no note, registry, or runtime state, and does not create `.brain/COST_REBUILD.json`.
39
+ - `--apply` publishes only `complete` or `none` candidates. The `none` state clears the section
40
+ only after a stable offline scan proves that no subagent was started.
41
+ - A `degraded` or `stale` candidate returns exit `1` and preserves the note without changes; the
42
+ batch continues so other safe sessions can be processed and the report can expose sanitized
43
+ diagnostic codes.
44
+ - The `--max-graph-nodes`, `--max-fallback-days`, and `--max-fallback-candidates` overrides are
45
+ exclusively for a targeted rebuild with `--session`. Using them without `--session` is invalid
46
+ usage and returns exit `2`; hooks, import, and bulk rebuild retain the default limits.
47
+ - Exit `0` means a consistent preview/apply; exit `1` means a partial `degraded`/`stale` result;
48
+ exit `2` means invalid syntax or context.
41
49
 
42
50
  ## Examples
43
51
 
@@ -45,12 +53,16 @@ npx wendkeep cost rebuild [--session <id|file>] [--limit N] [--apply] [--json]
45
53
  npx wendkeep stats --vault .MyApp-vault
46
54
  npx wendkeep cost --since 2026-07-01 --top 10 --trend week
47
55
  npx wendkeep cost rebuild --session 019abc --json
56
+ npx wendkeep cost rebuild --session 019abc --max-graph-nodes 8192 --json
57
+ npx wendkeep cost rebuild --session 019abc --apply
48
58
  ```
49
59
 
50
60
  ## Expected result
51
61
 
52
- Totals retain input/output/cache/reasoning dimensions by model and period. Rebuild shows a preview
53
- before changing notes and leaves a reproducible report when applied.
62
+ Totals retain input/output/cache/reasoning dimensions by model and period. Tri-state composition
63
+ returns `complete`, `none`, or `degraded`, plus a frontier, manifest, and sanitized diagnostics.
64
+ Run and review the dry-run before repeating the same command with `--apply`; a semantically
65
+ identical second apply preserves the note, checkpoint, report, and mtime.
54
66
 
55
67
  ## Common errors and diagnosis
56
68
 
@@ -58,6 +70,8 @@ before changing notes and leaves a reproducible report when applied.
58
70
  - Wrong-provider costs: validate the session identity chain.
59
71
  - Missing transcript: do not estimate silently; keep the gap visible.
60
72
  - Duplicated parent/subagent/fork totals: verify registry relationships and deduplication.
73
+ - `degraded`/`stale`: preserve the note and inspect diagnostics/frontier before authorizing apply.
74
+ - Rejected override: add `--session <id|file>` or remove the three targeted limits.
61
75
 
62
76
  ## Next steps
63
77
 
@@ -39,6 +39,11 @@ npx wendkeep --help
39
39
  events remain durable in the outbox/ledger is a recoverable warning.
40
40
  - An ambiguous attempt, a lost event ID (absent from ledger and outbox), `projected` state found
41
41
  only in the outbox, or a mismatched checkpoint is blocking.
42
+ - For session observability, `legacy`, `degraded`, `stale`, and `manifest-unproven` require
43
+ reconciliation or more evidence. Only fresh `none` and fresh `complete` are healthy: frontier,
44
+ checkpoint, root stat, and source manifest must agree.
45
+ - `doctor` remains read-only. It recommends the targeted dry-run first and only advises repeating
46
+ the command with `--apply` after human review.
42
47
  - `sync-defs --check` detects drift without writes; `--reseed` restores packaged `wk-*` skills.
43
48
  - `theme sync` reapplies the CSS snippet and graph groups without recreating the vault.
44
49
  - `wendkeep --version` prints the running version; `wendkeep --help` lists the public interface.
@@ -52,6 +57,8 @@ npx wendkeep --version
52
57
  npx wendkeep sync-defs --check --vault .MyApp-vault --project .
53
58
  npx wendkeep doctor --vault .MyApp-vault
54
59
  npx wendkeep memory status --gate --vault .MyApp-vault
60
+ npx wendkeep cost rebuild --session <id> --json
61
+ npx wendkeep cost rebuild --session <id> --apply
55
62
  ```
56
63
 
57
64
  ## Expected result
@@ -59,7 +66,9 @@ npx wendkeep memory status --gate --vault .MyApp-vault
59
66
  Doctor names sessions, registry, links, notes, prices, derived sections, and memory as healthy or
60
67
  provides a specific diagnostic/repair command. For memory, it distinguishes a valid initial empty
61
68
  state, recoverable pending replay, and lost/divergent lifecycle state. It never repairs implicitly
62
- or echoes private projector-error content into its report.
69
+ or echoes private projector-error content into its report. For session observability, it separates
70
+ fresh `none`/`complete` from legacy, degraded, stale, or manifest-unproven state and gives a
71
+ dry-run path before any write.
63
72
 
64
73
  ## Common errors and diagnosis
65
74
 
@@ -70,6 +79,9 @@ or echoes private projector-error content into its report.
70
79
  - `ambiguous`, lost publication, or a mismatched checkpoint: blocking; preserve registry, ledger,
71
80
  outbox, and SHARED so `last_memory_attempt` can be correlated before repair.
72
81
  - Corrupt bundle: preserve evidence and run `memory status --gate` before `memory repair`.
82
+ - `legacy`/`degraded`/`stale`/`manifest-unproven` observability: run
83
+ `wendkeep cost rebuild --session <id> --json`, review diagnostics, and only then authorize
84
+ `--apply`.
73
85
 
74
86
  ## Next steps
75
87
 
@@ -25,6 +25,7 @@ Pass the vault explicitly in automation. Preserve backups and evidence before re
25
25
  ```bash
26
26
  npx wendkeep memory status [--gate] --vault <vault>
27
27
  npx wendkeep memory repair --vault <vault>
28
+ npx wendkeep memory recover-attempt <session> [--apply] --vault <vault>
28
29
  npx wendkeep memory reconcile <ambiguous-session> --by-session <successor-session> --reason <reason> [--apply] --vault <vault>
29
30
  npx wendkeep memory promote <candidate> [--event <event-id>] --vault <vault>
30
31
  npx wendkeep memory reject <candidate> --vault <vault>
@@ -51,8 +52,23 @@ npx wendkeep validate-memory --vault <v2-vault>
51
52
  historical prefix only when revision, cursor, hash, identity, turns, and the
52
53
  `memory_checkpoint` mirror exactly reproduce the old semantics; the target is the current replay
53
54
  of that prefix, without absorbing later events. Both paths CAS-check the attempt and mirror and
54
- record backup/audit. Repair never reclassifies registry attempts or accepts a tuple, operation,
55
- or mirror that cannot be fully re-derived.
55
+ record backup/audit. The only narrow acknowledgement exception covers `enqueued`/`degraded`
56
+ attempts whose outbox was frozen and whose event IDs that same repair run consumed in full;
57
+ partial coverage does not change the attempt. Repair does not scan or reclassify historical
58
+ attempts and does not accept a tuple, operation, or mirror that cannot be fully re-derived.
59
+ - As of 0.66.4, `memory recover-attempt` targets one session and is a dry run by default. The
60
+ session must exist in the registry and its latest attempt must be `v2`, `applied`, and `enqueued`
61
+ or `degraded`, with non-empty, unique `event_ids`. Every event must be present in the ledger and
62
+ belong to the attempt's project/session/activation/epoch/turn; no later event from that session
63
+ or target event still in the outbox may exist, and SHARED/candidates must byte-for-byte reproduce
64
+ the full ledger projection. An already `projected` attempt is accepted only with a valid
65
+ checkpoint and returns `unchanged`.
66
+ - With `--apply`, `memory recover-attempt` changes only `SESSION_REGISTRY`: it marks
67
+ `last_memory_attempt`/`memory_status` as `projected` and stores the same checkpoint in the
68
+ attempt and `memory_checkpoint`. Ledger, CORE, SHARED, candidates, outbox, and notes remain
69
+ byte-identical. The command validates all authority again under `MEMORY.lock`, CAS-checks the
70
+ attempt, activation, epoch, turn, and checkpoint, and fails closed if any byte/context changes.
71
+ A busy lock is not reaped; retry after application returns `unchanged` without writing.
56
72
  - `memory reconcile` is a dry run by default. `--apply` requires two named sessions plus a reason,
57
73
  CAS-checks the exact attempt, backs up the registry, and limits mutation to the ambiguous attempt
58
74
  and its successor. Replay is CORE-aware, checkpoints use the physical ledger cursor, and the
@@ -81,11 +97,16 @@ npx wendkeep validate-memory --vault <v2-vault>
81
97
  identity, backup, audit, and CAS; it does not reorder, rewrite, or append a ledger event.
82
98
  - `validate-memory <CORE.md>` checks the 25-line cap, required sections, and secrets.
83
99
  - `validate-memory --vault` requires a complete v2 bundle and is not the legacy-vault gate.
100
+ - For `recover-attempt`, exit `0` means a valid dry run/apply, including `unchanged`; exit `1`
101
+ means a precondition, authority, CAS, topology, or lock check failed; exit `2` means a missing
102
+ session/`--vault`, unknown or duplicate option, extra argument, or invalid value.
84
103
 
85
104
  ## Examples
86
105
 
87
106
  ```bash
88
107
  npx wendkeep memory status --gate --vault .MyApp-vault
108
+ npx wendkeep memory recover-attempt session-123 --vault .MyApp-vault
109
+ npx wendkeep memory recover-attempt session-123 --apply --vault .MyApp-vault
89
110
  npx wendkeep memory reconcile old --by-session current --reason "delivery continued" --vault .MyApp-vault
90
111
  npx wendkeep memory reconcile old --by-session current --reason "delivery continued" --apply --vault .MyApp-vault
91
112
  npx wendkeep validate-memory .MyApp-vault/.brain/CORE.md
@@ -107,6 +128,14 @@ of a global projection that has already advanced with concurrent events.
107
128
  repair merely to manufacture the first event.
108
129
  - `degraded` with every event ID present in either the ledger or an intact outbox is recoverable;
109
130
  let idempotent replay finish. An event ID absent from both locations means lost publication.
131
+ - Status/doctor reports `projected acknowledgement pending` and suggests
132
+ `memory recover-attempt <session>`: preserve the artifacts, inspect the dry-run JSON first, and
133
+ use `--apply` only when `eligible: true`. `dry-run` confirms eligibility; `applied` updates
134
+ registry/checkpoint; `unchanged` means the recovery was already applied idempotently.
135
+ - `recover-attempt` rejects a missing/divergent event, a target still in the outbox, stale
136
+ SHARED/candidates, a historical attempt, mismatched session/causal context, invalid checkpoint,
137
+ or busy lock. Do not bypass the gate by editing files: rerun `memory status --gate`, preserve
138
+ evidence, and resolve the divergent authority.
110
139
  - An `ambiguous` attempt, an `applied` attempt without event IDs, a `projected` event found only in
111
140
  the outbox, or a mismatched checkpoint is blocking: preserve the artifacts and investigate
112
141
  before repair. If the ambiguity is demonstrably superseded by a successor session, inspect the
@@ -46,6 +46,14 @@ npx wendkeep import [options]
46
46
  - `Stop` accepts only a transcript-proven turn from the compatible active activation. Duplicates
47
47
  are no-ops; stale/superseded Stops neither publish memory nor overwrite a newer epoch's
48
48
  checkpoint.
49
+ - `Stop` receives an absolute **45 s** deadline from hook entry. Reads check the clock between
50
+ rollouts and on every chunk; reaching the limit returns `degraded` before the host timeout.
51
+ - `SubagentStop` receives an absolute **15 s** deadline. Signals arriving within the **250 ms**
52
+ window are coalesced: only the highest sequence recomposes/publishes, without losing the last
53
+ child.
54
+ - Observability is tri-state: `complete` publishes the full snapshot; `none` means zero proven by
55
+ a causal Stop or stable offline scan; `degraded` preserves the previous snapshot and allowlisted
56
+ diagnostics. An isolated `SubagentStop` never publishes `none`.
49
57
  - When compacting conversations into `## Iterações`, the hook escapes code delimiters cut by the
50
58
  size limit; inline backticks and fences never remain open and consume the following line.
51
59
  - `session list` reads `SESSION_REGISTRY`; `show` displays one session and `use` only changes human
@@ -53,6 +61,9 @@ npx wendkeep import [options]
53
61
  - `import --source all|claude|codex`, `--since`, `--limit`, `--from`, and `--codex-from` bound scope.
54
62
  - `--dry-run`/`--json` support audit before writes; `--stamp-ids` and `--rescan-decisions` address
55
63
  specific historical gaps.
64
+ - `import` reconciles observability even when no `wk-turn` is missing: a legacy schema, stale
65
+ frontier, or unproven manifest triggers recomposition without duplicating iterations. A fresh
66
+ checkpoint remains byte-identical; `degraded` is reported and does not change the note.
56
67
  - Exit `0` means consistent processing; non-zero reports invalid source/config/write instead of
57
68
  presenting silent partial success.
58
69
 
@@ -71,6 +82,8 @@ registry keeps one `SessionStart` epoch per activation plus the latest native tu
71
82
  `Stop` events may acknowledge turns in that epoch without closing it. Repeated imports of the
72
83
  same `session_id` deduplicate; human focus does not close or re-identify live hooks. Every
73
84
  automatic iteration remains valid Markdown even when a message must be truncated.
85
+ Duplicate/stale hooks converge on the same frontier, and imports may refresh only observability
86
+ without creating a new turn block.
74
87
 
75
88
  ## Common errors and diagnosis
76
89
 
@@ -82,6 +95,8 @@ automatic iteration remains valid Markdown even when a message must be truncated
82
95
  - Fork duplicates: bound source/date and inspect `forked_from_id`/`source.subagent`.
83
96
  - Codex does not capture: approve hooks and start a new session after `sync`.
84
97
  - Contaminated cost: validate `session_id → session_file → transcript_path → provider`.
98
+ - `degraded` observability: preserve the note and run a targeted rebuild dry-run; never force a
99
+ partial snapshot over the last `complete` one.
85
100
 
86
101
  ## Next steps
87
102
 
@@ -26,7 +26,7 @@ Registry consistente, tabela de preços completa e acesso aos transcripts das se
26
26
  ```bash
27
27
  npx wendkeep stats [--vault <cofre>] [--json]
28
28
  npx wendkeep cost [--since <data>] [--top [N]] [--trend day|week|month] [--write] [--json]
29
- npx wendkeep cost rebuild [--session <id|arquivo>] [--limit N] [--apply] [--json]
29
+ npx wendkeep cost rebuild [--session <id|arquivo>] [--limit N] [--max-graph-nodes N] [--max-fallback-days N] [--max-fallback-candidates N] [--apply] [--json]
30
30
  ```
31
31
 
32
32
  ## Opções e códigos de saída
@@ -34,10 +34,18 @@ npx wendkeep cost rebuild [--session <id|arquivo>] [--limit N] [--apply] [--json
34
34
  - `wendkeep stats` gera uma linha compartilhável ou JSON.
35
35
  - `wendkeep cost` agrega total/modelo/dia; `--trend` inclui projeção e `--write` atualiza
36
36
  `00-Custo.md`.
37
- - `wendkeep cost rebuild` é dry-run por padrão; `--apply` grava notas e
38
- `.brain/COST_REBUILD.json`.
39
- - Exit `0` indica cálculo consistente; não zero indica registry, preço, transcript ou parsing
40
- insuficiente.
37
+ - `wendkeep cost rebuild` é dry-run por padrão e tem **zero escrita**: não adquire lock de
38
+ gravação, não altera nota, registry ou runtime e não cria `.brain/COST_REBUILD.json`.
39
+ - `--apply` publica somente candidatos `complete` ou `none`. O estado `none` zera a seção
40
+ quando um scan offline estável comprovou que nenhum subagente foi iniciado.
41
+ - Um candidato `degraded` ou `stale` produz exit `1` e preserva a nota sem alteração; o lote
42
+ continua para que outras sessões seguras possam ser processadas e o relatório exponha os
43
+ códigos sanitizados.
44
+ - Os overrides `--max-graph-nodes`, `--max-fallback-days` e `--max-fallback-candidates` são
45
+ exclusivamente para rebuild direcionado com `--session`. Usá-los sem `--session` é uso inválido
46
+ e produz exit `2`; hooks, import e rebuild em lote mantêm os limites padrão.
47
+ - Exit `0` significa preview/aplicação consistente; exit `1` indica resultado parcial
48
+ `degraded`/`stale`; exit `2` indica sintaxe ou contexto inválido.
41
49
 
42
50
  ## Exemplos
43
51
 
@@ -45,12 +53,16 @@ npx wendkeep cost rebuild [--session <id|arquivo>] [--limit N] [--apply] [--json
45
53
  npx wendkeep stats --vault .MeuApp-vault
46
54
  npx wendkeep cost --since 2026-07-01 --top 10 --trend week
47
55
  npx wendkeep cost rebuild --session 019abc --json
56
+ npx wendkeep cost rebuild --session 019abc --max-graph-nodes 8192 --json
57
+ npx wendkeep cost rebuild --session 019abc --apply
48
58
  ```
49
59
 
50
60
  ## Resultado esperado
51
61
 
52
- Totais preservam dimensões de input/output/cache/reasoning por modelo e período. Rebuild mostra a
53
- prévia antes de alterar notas e deixa um relatório reproduzível quando aplicado.
62
+ Totais preservam dimensões de input/output/cache/reasoning por modelo e período. A composição
63
+ tri-state devolve `complete`, `none` ou `degraded`, mais frontier, manifest e diagnostics
64
+ sanitizados. Rode e revise o dry-run antes de repetir o mesmo comando com `--apply`; uma segunda
65
+ aplicação semanticamente idêntica preserva nota, checkpoint, relatório e mtime.
54
66
 
55
67
  ## Erros comuns e diagnóstico
56
68
 
@@ -58,6 +70,8 @@ prévia antes de alterar notas e deixa um relatório reproduzível quando aplica
58
70
  - Custos de provider errado: valide a cadeia de identidade da sessão.
59
71
  - Transcript ausente: não estime silenciosamente; mantenha a lacuna visível.
60
72
  - Total duplicado por subagent/fork: confirme relação pai/subagent e deduplicação do registry.
73
+ - `degraded`/`stale`: preserve a nota e investigue diagnostics/frontier antes de autorizar apply.
74
+ - Override rejeitado: acrescente `--session <id|arquivo>` ou remova os três limites direcionados.
61
75
 
62
76
  ## Próximos passos
63
77
 
@@ -39,6 +39,11 @@ npx wendkeep --help
39
39
  continuam duráveis na outbox/ledger é warning recuperável.
40
40
  - Attempt ambíguo, event ID perdido (ausente de ledger e outbox), estado `projected` apenas na
41
41
  outbox ou checkpoint divergente são falhas bloqueantes.
42
+ - Para observabilidade de sessão, `legacy`, `degraded`, `stale` e `manifest-unproven` exigem
43
+ reconciliação ou evidência adicional. Somente `none` fresco e `complete` fresco são saudáveis:
44
+ frontier, checkpoint, root stat e source manifest precisam concordar.
45
+ - O `doctor` permanece somente leitura/read-only. Ele recomenda primeiro o dry-run direcionado;
46
+ somente depois da revisão humana orienta repetir com `--apply`.
42
47
  - `sync-defs --check` detecta drift sem gravar; `--reseed` restaura skills `wk-*` do pacote.
43
48
  - `theme sync` reaplica snippet CSS e grupos do grafo sem recriar o cofre.
44
49
  - `wendkeep --version` imprime a versão executada; `wendkeep --help` lista a interface pública.
@@ -52,6 +57,8 @@ npx wendkeep --version
52
57
  npx wendkeep sync-defs --check --vault .MeuApp-vault --project .
53
58
  npx wendkeep doctor --vault .MeuApp-vault
54
59
  npx wendkeep memory status --gate --vault .MeuApp-vault
60
+ npx wendkeep cost rebuild --session <id> --json
61
+ npx wendkeep cost rebuild --session <id> --apply
55
62
  ```
56
63
 
57
64
  ## Resultado esperado
@@ -59,7 +66,9 @@ npx wendkeep memory status --gate --vault .MeuApp-vault
59
66
  O doctor nomeia sessões, registry, links, notas, preços, derivadas e memória como saudáveis ou
60
67
  fornece um comando específico de diagnóstico/reparo. Na memória, ele distingue vazio inicial
61
68
  válido, replay pendente recuperável e lifecycle perdido/divergente. Nenhum reparo é aplicado
62
- implicitamente nem o conteúdo privado do erro do projector é reproduzido no relatório.
69
+ implicitamente nem o conteúdo privado do erro do projector é reproduzido no relatório. Na
70
+ observabilidade de sessão, ele separa `none`/`complete` frescos de estado legado, degradado, stale
71
+ ou sem manifest comprovado e oferece um caminho dry-run antes de qualquer escrita.
63
72
 
64
73
  ## Erros comuns e diagnóstico
65
74
 
@@ -70,6 +79,8 @@ implicitamente nem o conteúdo privado do erro do projector é reproduzido no re
70
79
  - `ambiguous`, publicação perdida ou checkpoint divergente: bloqueante; preserve registry, ledger,
71
80
  outbox e SHARED para correlacionar `last_memory_attempt` antes de reparar.
72
81
  - Bundle corrompido: preserve a evidência e use `memory status --gate` antes de `memory repair`.
82
+ - Observabilidade `legacy`/`degraded`/`stale`/`manifest-unproven`: rode
83
+ `wendkeep cost rebuild --session <id> --json`, revise diagnostics e só então autorize `--apply`.
73
84
 
74
85
  ## Próximos passos
75
86
 
@@ -25,6 +25,7 @@ Informe o vault explicitamente em automações. Preserve backups e evidências a
25
25
  ```bash
26
26
  npx wendkeep memory status [--gate] --vault <cofre>
27
27
  npx wendkeep memory repair --vault <cofre>
28
+ npx wendkeep memory recover-attempt <sessão> [--apply] --vault <cofre>
28
29
  npx wendkeep memory reconcile <sessão-ambígua> --by-session <sessão-sucessora> --reason <motivo> [--apply] --vault <cofre>
29
30
  npx wendkeep memory promote <candidate> [--event <event-id>] --vault <cofre>
30
31
  npx wendkeep memory reject <candidate> --vault <cofre>
@@ -51,8 +52,24 @@ npx wendkeep validate-memory --vault <cofre-v2>
51
52
  assert-only somente quando revision, cursor, hash, identidade, turns e o espelho
52
53
  `memory_checkpoint` reproduzem exatamente a semântica antiga; o alvo é o replay atual daquele
53
54
  prefixo, sem absorver eventos posteriores. Ambos os casos fazem CAS do attempt e do espelho e
54
- registram backup/auditoria. O repair nunca reclassifica attempts do registry nem aceita tuple,
55
- operação ou espelho que não seja rederivado integralmente.
55
+ registram backup/auditoria. A única exceção estreita de acknowledgement cobre attempts
56
+ `enqueued`/`degraded` cuja outbox foi congelada e cujos event IDs a mesma execução do repair
57
+ consumiu integralmente; cobertura parcial não altera o attempt. O repair não varre nem
58
+ reclassifica attempts históricos e não aceita tuple, operação ou espelho que não seja
59
+ rederivado integralmente.
60
+ - Desde a 0.66.4, `memory recover-attempt` é dirigido a uma única sessão e faz dry-run por padrão.
61
+ A sessão deve existir no registry e possuir o último attempt `v2`, `applied`, em `enqueued` ou
62
+ `degraded`, com `event_ids` não vazios e únicos. Todos os eventos devem estar integralmente no
63
+ ledger, pertencer ao mesmo projeto/sessão/activation/epoch/turn do attempt, não pode haver evento
64
+ posterior da mesma sessão nem evento alvo restante na outbox, e SHARED/candidates devem
65
+ reproduzir byte a byte a projeção integral do ledger. Um attempt já `projected` só é aceito com
66
+ checkpoint válido e retorna `unchanged`.
67
+ - Com `--apply`, `memory recover-attempt` altera somente `SESSION_REGISTRY`: marca
68
+ `last_memory_attempt`/`memory_status` como `projected` e grava o checkpoint idêntico no attempt e
69
+ em `memory_checkpoint`. Ledger, CORE, SHARED, candidates, outbox e notas permanecem byte-intactos.
70
+ O comando valida novamente toda a autoridade sob `MEMORY.lock`, faz CAS do attempt, activation,
71
+ epoch, turno e checkpoint e falha fechado se qualquer byte/contexto mudar. Lock ocupado não é
72
+ colhido; retry após aplicação retorna `unchanged` sem escrita.
56
73
  - `memory reconcile` é dry-run por padrão. `--apply` exige duas sessões nomeadas e motivo, faz CAS
57
74
  do attempt exato, salva backup do registry e limita a mutação ao attempt ambíguo e à sucessora.
58
75
  O replay é CORE-aware, usa cursor físico do ledger no checkpoint e não reescreve ledger, CORE ou
@@ -78,11 +95,16 @@ npx wendkeep validate-memory --vault <cofre-v2>
78
95
  CAS; ele não reordena, reescreve nem acrescenta evento ao ledger.
79
96
  - `validate-memory <CORE.md>` valida cap de 25 linhas, seções e segredos.
80
97
  - `validate-memory --vault` exige bundle v2 completo; não é o gate correto para vault legado.
98
+ - Para `recover-attempt`, exit `0` indica dry-run/apply válido, inclusive `unchanged`; exit `1`
99
+ indica falha de pré-condição, autoridade, CAS, topologia ou lock; exit `2` indica
100
+ sessão/`--vault` ausente, opção desconhecida/duplicada, argumento extra ou valor inválido.
81
101
 
82
102
  ## Exemplos
83
103
 
84
104
  ```bash
85
105
  npx wendkeep memory status --gate --vault .MeuApp-vault
106
+ npx wendkeep memory recover-attempt sessao-123 --vault .MeuApp-vault
107
+ npx wendkeep memory recover-attempt sessao-123 --apply --vault .MeuApp-vault
86
108
  npx wendkeep memory reconcile antiga --by-session atual --reason "entrega continuada" --vault .MeuApp-vault
87
109
  npx wendkeep memory reconcile antiga --by-session atual --reason "entrega continuada" --apply --vault .MeuApp-vault
88
110
  npx wendkeep validate-memory .MeuApp-vault/.brain/CORE.md
@@ -104,6 +126,14 @@ prefixo válido de uma projeção global que já avançou com eventos concorrent
104
126
  fabricar o primeiro evento.
105
127
  - `degraded` com todos os event IDs presentes no ledger ou na outbox íntegra é recuperável; deixe o
106
128
  replay idempotente concluir. Event ID ausente nos dois lugares indica publicação perdida.
129
+ - Status/doctor informa `acknowledgement projetado pendente` e sugere
130
+ `memory recover-attempt <sessão>`: preserve os artefatos, revise primeiro o JSON do dry-run e só
131
+ use `--apply` se `eligible: true`. `dry-run` confirma elegibilidade; `applied` atualiza
132
+ registry/checkpoint; `unchanged` indica que a recuperação já foi aplicada de forma idempotente.
133
+ - `recover-attempt` recusa evento ausente/divergente, outbox alvo ainda presente, SHARED/candidates
134
+ stale, attempt histórico, sessão/contexto causal divergente, checkpoint inválido ou lock ocupado.
135
+ Não tente contornar o gate com edição manual: rode novamente `memory status --gate`, preserve a
136
+ evidência e resolva a autoridade divergente.
107
137
  - Attempt `ambiguous`, attempt `applied` sem event IDs, evento `projected` apenas na outbox ou
108
138
  checkpoint divergente são bloqueantes: preserve os artefatos e investigue antes de repair. Se a
109
139
  ambiguidade for comprovadamente substituída por uma sessão sucessora, revise o dry-run de
@@ -46,6 +46,13 @@ npx wendkeep import [opções]
46
46
  - `Stop` aceita somente o turno comprovado pelo transcript e pela activation ativa compatível.
47
47
  Duplicatas são no-op; Stops stale/superseded não publicam memória nem sobrescrevem o checkpoint
48
48
  de um epoch mais novo.
49
+ - `Stop` recebe deadline absoluto de **45 s** desde a entrada do hook. A leitura verifica o relógio
50
+ entre rollouts e a cada chunk; ao atingir o limite, devolve `degraded` antes do timeout do host.
51
+ - `SubagentStop` recebe deadline absoluto de **15 s**. Sinais que chegam na janela de **250 ms**
52
+ são coalescidos: somente a maior sequência recompõe/publica, sem perder o último filho.
53
+ - A observabilidade usa tri-state: `complete` publica o snapshot integral; `none` representa zero
54
+ comprovado por Stop causal ou scan offline estável; `degraded` preserva o snapshot anterior e
55
+ diagnostics allowlisted. `SubagentStop` isolado nunca publica `none`.
49
56
  - Ao compactar conversas em `## Iterações`, o hook escapa delimitadores de código cortados pelo
50
57
  limite de tamanho; backticks inline ou fences nunca ficam abertos para engolir a linha seguinte.
51
58
  - `session list` lê `SESSION_REGISTRY`; `show` exibe uma sessão e `use` muda apenas o foco humano
@@ -53,6 +60,9 @@ npx wendkeep import [opções]
53
60
  - `import --source all|claude|codex`, `--since`, `--limit`, `--from` e `--codex-from` limitam escopo.
54
61
  - `--dry-run`/`--json` permitem auditar antes de gravar; `--stamp-ids` e `--rescan-decisions`
55
62
  corrigem históricos específicos.
63
+ - `import` reconcilia a observabilidade mesmo quando nenhum `wk-turn` está ausente: schema legado,
64
+ frontier stale ou manifest não comprovado disparam recomposição sem duplicar iterações. Um
65
+ checkpoint fresco permanece byte-idêntico; `degraded` é reportado e não altera a nota.
56
66
  - Exit `0` indica processamento consistente; exit não zero indica configuração, fonte ou escrita
57
67
  inválida sem transformar isso em sucesso parcial silencioso.
58
68
 
@@ -70,7 +80,9 @@ Cada sessão canônica aponta para provider, transcript, arquivo de nota e custo
70
80
  O registry mantém um epoch de `SessionStart` por activation e o turno nativo mais recente; vários
71
81
  `Stop` podem confirmar turnos do mesmo epoch sem fechá-lo. Importações repetidas do mesmo
72
82
  `session_id` são deduplicadas; o foco humano não encerra nem altera a identidade dos hooks. Cada
73
- iteração automática permanece Markdown válido mesmo quando uma fala precisa ser truncada.
83
+ iteração automática permanece Markdown válido mesmo quando uma fala precisa ser truncada. Hooks
84
+ duplicados/stale convergem no mesmo frontier, e importações podem atualizar só a observabilidade
85
+ sem criar um novo bloco de turno.
74
86
 
75
87
  ## Erros comuns e diagnóstico
76
88
 
@@ -82,6 +94,8 @@ iteração automática permanece Markdown válido mesmo quando uma fala precisa
82
94
  - Duplicatas de forks: limite por fonte/data e revise `forked_from_id`/`source.subagent`.
83
95
  - Codex não captura: aprove os hooks e reinicie a sessão após `sync`.
84
96
  - Custo contaminado: valide `session_id → session_file → transcript_path → provider`.
97
+ - Observabilidade `degraded`: preserve a nota e rode o rebuild direcionado em dry-run; não force
98
+ um snapshot parcial sobre o último `complete`.
85
99
 
86
100
  ## Próximos passos
87
101