@journeykit/canon 0.45.0 → 0.47.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 (124) hide show
  1. package/dist/skills/SKILL.src.md +29 -18
  2. package/dist/skills/reference/canon-gate.md +17 -24
  3. package/dist/skills/reference/canon-inventory.md +1 -1
  4. package/dist/skills/reference/canon-plan-import.md +1 -1
  5. package/dist/skills/reference/canon-policy.md +29 -5
  6. package/dist/skills/reference/canon-report-dashboard.md +2 -6
  7. package/dist/skills/reference/canon-review.md +24 -3
  8. package/dist/skills/reference/canon-storage.md +76 -155
  9. package/dist/skills/reference/canon-subject.md +1 -8
  10. package/dist/skills/reference/role-implementer.md +6 -8
  11. package/dist/skills/reference/role-orchestrator.md +32 -28
  12. package/dist/skills/reference/role-planner.md +15 -4
  13. package/dist/skills/reference/role-reviewer.md +32 -1
  14. package/man/canon-adapter-authorize.1 +2 -2
  15. package/man/canon-adapter-validate.1 +2 -2
  16. package/man/canon-adapter.1 +2 -2
  17. package/man/canon-artifacts-prune.1 +4 -4
  18. package/man/canon-artifacts-store.1 +6 -4
  19. package/man/canon-artifacts-verify.1 +7 -7
  20. package/man/canon-artifacts.1 +5 -8
  21. package/man/canon-brief-approve.1 +18 -8
  22. package/man/canon-brief-check.1 +2 -2
  23. package/man/canon-brief-show.1 +2 -2
  24. package/man/canon-brief.1 +3 -3
  25. package/man/canon-change-defer.1 +3 -4
  26. package/man/canon-change-drop.1 +2 -2
  27. package/man/canon-change-new.1 +2 -2
  28. package/man/canon-change-reopen.1 +2 -2
  29. package/man/canon-change.1 +2 -2
  30. package/man/canon-completion.1 +2 -2
  31. package/man/canon-context-pack-add.1 +2 -2
  32. package/man/canon-context-pack-show.1 +2 -2
  33. package/man/canon-context-pack-verify.1 +2 -2
  34. package/man/canon-context-pack.1 +2 -2
  35. package/man/canon-context.1 +2 -2
  36. package/man/canon-dashboard.1 +2 -2
  37. package/man/canon-demo-init.1 +2 -2
  38. package/man/canon-demo-review.1 +2 -2
  39. package/man/canon-demo.1 +2 -2
  40. package/man/canon-dispatch-begin.1 +2 -2
  41. package/man/canon-dispatch-diff.1 +2 -2
  42. package/man/canon-dispatch-end.1 +2 -2
  43. package/man/canon-dispatch.1 +2 -2
  44. package/man/canon-divergence-accept.1 +2 -2
  45. package/man/canon-divergence-add.1 +2 -2
  46. package/man/canon-divergence-defer.1 +2 -2
  47. package/man/canon-divergence-list.1 +2 -2
  48. package/man/canon-divergence-resolve.1 +2 -2
  49. package/man/canon-divergence.1 +2 -2
  50. package/man/canon-evidence-add.1 +2 -2
  51. package/man/canon-evidence-approval-payload.1 +2 -2
  52. package/man/canon-evidence-audit.1 +2 -2
  53. package/man/canon-evidence.1 +2 -2
  54. package/man/canon-export.1 +2 -2
  55. package/man/canon-feature-new.1 +2 -2
  56. package/man/canon-feature.1 +2 -2
  57. package/man/canon-finding-add.1 +2 -2
  58. package/man/canon-finding-close.1 +2 -2
  59. package/man/canon-finding-list.1 +2 -2
  60. package/man/canon-finding.1 +2 -2
  61. package/man/canon-format.1 +2 -2
  62. package/man/canon-gate-check.1 +2 -2
  63. package/man/canon-gate-install-hooks.1 +2 -2
  64. package/man/canon-gate-promote.1 +2 -2
  65. package/man/canon-gate.1 +2 -2
  66. package/man/canon-ingest-plans.1 +2 -2
  67. package/man/canon-ingest-records.1 +2 -2
  68. package/man/canon-ingest.1 +2 -2
  69. package/man/canon-init.1 +2 -2
  70. package/man/canon-inventory-sync.1 +2 -2
  71. package/man/canon-inventory.1 +2 -2
  72. package/man/canon-ledger-compact.1 +2 -2
  73. package/man/canon-ledger.1 +2 -2
  74. package/man/canon-migrate.1 +3 -3
  75. package/man/canon-plugin-sync.1 +2 -2
  76. package/man/canon-plugin.1 +2 -2
  77. package/man/canon-policy-approve.1 +2 -2
  78. package/man/canon-policy-show.1 +2 -2
  79. package/man/canon-policy.1 +2 -2
  80. package/man/canon-prompt-add.1 +2 -2
  81. package/man/canon-prompt-show.1 +2 -2
  82. package/man/canon-prompt.1 +2 -2
  83. package/man/canon-purge.1 +2 -2
  84. package/man/canon-query.1 +5 -5
  85. package/man/canon-regime-show.1 +2 -2
  86. package/man/canon-regime.1 +2 -2
  87. package/man/canon-report-build.1 +2 -2
  88. package/man/canon-report-check.1 +2 -2
  89. package/man/canon-report-snapshot.1 +2 -2
  90. package/man/canon-report.1 +2 -2
  91. package/man/canon-retrieve.1 +2 -2
  92. package/man/canon-review-brief.1 +84 -0
  93. package/man/canon-review-change.1 +2 -2
  94. package/man/canon-review-scenario.1 +2 -2
  95. package/man/canon-review.1 +5 -2
  96. package/man/canon-scenario-new.1 +2 -2
  97. package/man/canon-scenario.1 +2 -2
  98. package/man/canon-schema.1 +2 -2
  99. package/man/canon-search.1 +2 -2
  100. package/man/canon-selftest.1 +2 -2
  101. package/man/canon-skills-check.1 +2 -2
  102. package/man/canon-skills-doctor.1 +2 -2
  103. package/man/canon-skills-install.1 +2 -2
  104. package/man/canon-skills-show.1 +2 -2
  105. package/man/canon-skills.1 +2 -2
  106. package/man/canon-status.1 +2 -2
  107. package/man/canon-strategy-approval-payload.1 +2 -2
  108. package/man/canon-strategy-promote.1 +2 -2
  109. package/man/canon-strategy-rollback.1 +2 -2
  110. package/man/canon-strategy.1 +2 -2
  111. package/man/canon-subject-adopt.1 +2 -2
  112. package/man/canon-subject-move.1 +2 -2
  113. package/man/canon-subject-new.1 +2 -2
  114. package/man/canon-subject-show.1 +2 -2
  115. package/man/canon-subject-unadopt.1 +2 -2
  116. package/man/canon-subject.1 +2 -2
  117. package/man/canon-task-done.1 +2 -2
  118. package/man/canon-task.1 +2 -2
  119. package/man/canon-trace.1 +2 -2
  120. package/man/canon.1 +4 -7
  121. package/package.json +5 -5
  122. package/man/canon-artifacts-move.1 +0 -63
  123. package/man/canon-tier-age.1 +0 -50
  124. package/man/canon-tier.1 +0 -39
@@ -1,103 +1,57 @@
1
1
  # canon-storage
2
2
 
3
- canon stores every record in one of three capability **rungs**:
3
+ canon keeps every record in one place per record kind, on the disk of the working tree. The place follows from the kind and is not a setting. The only storage setting in `canon.yaml` is the optional `storage:` block.
4
4
 
5
- - `local` — diffable files in the repo (git-backed), zero network.
6
- - `hot` — live-queryable state (sqlite or postgres).
7
- - `cold` — bulk archive (s3).
5
+ ## Where each record lives
8
6
 
9
- A rung is a *role*; which backend implements it is a separate
10
- declaration. `routing:`/`aging:` name a rung (`local`/`hot`/`cold`),
11
- never a backend name. `tiers.<rung>.backend:` names the backend.
7
+ | record | place | in git |
8
+ | --- | --- | --- |
9
+ | `task`, `handoff`, `run` | `.canon/hot.db` (sqlite, one per working tree) | no |
10
+ | the other ten kinds (`change`, `evidence`, `strategy_item`, …) | `.canon/ledger/` (latest version) and `.canon/archive/` (superseded versions) | yes |
11
+ | evidence attachment bytes | `.canon/artifacts/sha256/<digest>` | yes; through git LFS with `attachments: lfs` |
12
+ | learn parquet | `.canon/learn/` | no |
12
13
 
13
- ## Backends and their config
14
+ `.canon/hot.db` is a sqlite file in WAL mode with a busy timeout: one writer at a time. canon creates it with mode `0600`, and the `-wal` and `-shm` files beside it too. No command needs an environment variable or a service.
14
15
 
15
- | backend | rung role | `tiers.<rung>` config | credentials / network |
16
- | ---------- | --------- | ---------------------------------- | --------------------- |
17
- | `git` | local | `root:` (relative to canon.yaml) | none — zero network |
18
- | `sqlite` | hot | `path:` (relative to canon.yaml) | none |
19
- | `postgres` | hot | `dsn_env:` + `schema:` | live network + creds |
20
- | `s3` | cold | `bucket_env:` + `prefix:` | live network + creds |
21
-
22
- `canon init` scaffolds `sqlite` as the zero-dependency `hot` default
23
- (WAL journal + busy timeout, fine for one operator's batch ingest).
24
- sqlite is a **single-writer store**: for heavy multi-agent concurrent
25
- writers, swap the `hot` rung to `postgres` — same hot role, a one-block
26
- canon.yaml swap (the scaffold ships the postgres stanza commented right
27
- beside the sqlite one). A postgres/s3 rung that can't attach fails loud
28
- at startup — never a silent fallback to local files.
16
+ ## The `storage:` block
29
17
 
30
18
  ```yaml
31
- tiers:
32
- local: { backend: git, root: .canon/ledger }
33
- hot: { backend: sqlite, path: .canon/hot.db }
34
- # hot: { backend: postgres, dsn_env: CANON_PG_DSN, schema: canon }
35
- cold: { backend: s3, bucket_env: CANON_BUCKET, prefix: canon/ }
19
+ storage:
20
+ mode: local # the only value, and the value when the key is absent
21
+ attachments: git # git (default) or lfs
36
22
  ```
37
23
 
38
- Using a backend name (`git`/`pg`/`s3`) where a rung is expected is
39
- rejected with a hint:
24
+ `canon init` writes the block. Both fields take a closed set of values: `mode` is `local`, `attachments` is `git` or `lfs`. Any other value (`mode: remote` included) and any other key under `storage:` is refused with `CONFIG_INVALID`, reason `STORAGE`, and the field names the key.
40
25
 
41
- ```
42
- canon.yaml TierPolicy: `git` is a BACKEND name, not a rung — canon.yaml's
43
- `routing`/`aging`/`tiers` keys now name a capability rung
44
- (local/hot/cold); declare the backend separately via
45
- `tiers.<rung>.backend: git`
46
- ```
26
+ ## An old canon.yaml is refused, and `canon migrate` fixes it
47
27
 
48
- ## Routing a record kind
28
+ The keys `tiers:`, `routing:`, `aging:` and `artifact_store:` are gone. A command that opens the record store and finds one of them exits `2` with `CONFIG_INVALID`, reason `STORAGE`, the field naming the key, and writes nothing. `canon migrate`, `canon format`, `canon brief check` and `canon schema` do not open the store and do not refuse. Run the preview, then commit it:
49
29
 
50
- `routing:` is the only place a kind's rung is decided. Keys are the
51
- stable snake_case kind wire strings (`change`, `evidence`,
52
- `strategy_item`, …) — the same string the record's own `kind` field
53
- serializes to. Values are `local`/`hot`/`cold`.
54
-
55
- ```yaml
56
- routing:
57
- scenario: local # change this to move FUTURE `scenario` writes
30
+ ```bash
31
+ canon migrate
32
+ canon migrate --commit --plan-digest "$PLAN_DIGEST"
58
33
  ```
59
34
 
60
- Changing a routing value moves future writes only; re-run reads
61
- resolve the policy live. An unknown kind or rung name is a loud config
62
- parse error. Every record kind needs a `routing:` entry — an unrouted
63
- kind fails hard at its first write/query, never silently dropped.
64
-
65
- ## Aging a kind to another rung
66
-
67
- `aging:` moves records from their routed rung to a `to:` rung once
68
- their age exceeds `after:`:
35
+ The commit removes the four blocks and the comment right above each, writes `storage:` where `tiers:` was (at the end of the file when there was none) and keeps every other byte of `canon.yaml`. `--revert` restores the file from `.canon/migrate-backup/`. A second run finds nothing to do. Migrate moves no file: `.canon/hot.db` and `.canon/ledger` stay where they are.
69
36
 
70
- ```yaml
71
- aging:
72
- handoff: { after: 30d, to: cold } # <n>d/h/m/s — one integer, one unit
73
- ```
37
+ Migrate reads the old values and does this with them:
74
38
 
75
- `canon tier age` applies every `aging:` rule once. It is
76
- content-digest idempotent: re-running finds nothing left to move
77
- (`moved == 0`); a partial run (destination written, source not deleted)
78
- re-selects the record but the destination write is a no-op. A kind
79
- split across two rungs (some aged, some not) still reads correctly —
80
- `canon query` fans out.
39
+ | old setting | migrate |
40
+ | --- | --- |
41
+ | `tiers.hot` on postgres, `tiers.cold` on s3, or a `routing` or `aging` entry that points at either | applies, and the preview warns `STORAGE_ROWS_NOT_CARRIED` naming the schema, the bucket or the entry. canon reads no Postgres rows and no S3 objects: they stay where they are, and `.canon/hot.db` starts empty |
42
+ | `tiers.local.root` other than `.canon/ledger`, or `tiers.hot.path` other than `.canon/hot.db` | refuses (exit `2`, `CONFIG_INVALID`/`STORAGE`, the field is the key). Move the directory to the default place and run again |
43
+ | a `routing` or `aging` entry that sends a ledger kind to a local place other than its own (`evidence: hot` on sqlite, `task: local`) | refuses, the field is the entry. The rows are local, and removing the entry would hide them |
44
+ | `routing.trajectory`, `aging.trajectory` | removed without a warning |
45
+ | `artifact_store` on an object store | refuses: the bytes the gate reads are not on disk. Download them into `.canon/artifacts/sha256/` first (the CHANGELOG has the steps) |
46
+ | `artifact_store: { backend: local }`, or no `artifact_store` | applies |
81
47
 
82
- **Done when:** after `canon tier age --commit --plan-digest <digest from the
83
- preview>`, a bare `canon tier age` previews no effect (`moved` is `0`).
48
+ ## Reading records
84
49
 
85
- ## Running `canon tier age` / `canon query`
86
-
87
- Both read the `canon.yaml` of `--repo <dir>` (default: the nearest ancestor
88
- directory holding one).
50
+ `canon query --kind <kind>` opens only the store of that kind. A damaged `.canon/hot.db` stops `--kind task`, `--kind handoff` and `--kind run` and leaves every ledger kind readable. A `.canon/hot.db` that does not exist yet reads as empty, and a read does not create it.
89
51
 
90
52
  ```bash
91
- # Preview what would move (the bare run is read-only; writes/deletes nothing).
92
- canon tier age
93
-
94
- # Apply every `aging:` rule once (the destructive move+delete), with the
95
- # `planDigest` the preview printed.
96
- canon tier age --commit --plan-digest "$PLAN_DIGEST"
97
-
98
- # Read a kind, fanning out across its routed rung AND its aging
99
- # destination, merged by time. --kind is the kind wire string — the
100
- # same vocabulary as routing:/aging: (`change`, `handoff`, …).
53
+ # Read a kind. --kind is the kind wire string (`change`, `handoff`, …):
54
+ # the stable snake_case name the record's own `kind` field holds.
101
55
  canon query --kind handoff --since 2026-06-01T00:00:00Z
102
56
 
103
57
  # Machine-readable output instead of the human table.
@@ -114,7 +68,7 @@ canon query --kind trajectory --json --limit 50 --fields at,kind --cursor <nextC
114
68
 
115
69
  ## The ledger is latest-only; the archive holds history
116
70
 
117
- The `local` rung's directory (`.canon/ledger`) holds the current record of
71
+ The directory `.canon/ledger` holds the current record of
118
72
  each key. Appending a newer version (evidence for a scenario and role, a
119
73
  closed finding, a rewritten scenario, a subject's next status) moves the
120
74
  versions it supersedes to `.canon/archive`: same `kind=<kind>/…` layout and
@@ -131,9 +85,7 @@ canon ledger compact --commit --plan-digest "$PLAN_DIGEST"
131
85
  ```
132
86
 
133
87
  A crash between the write and the move leaves a readable ledger that the next
134
- append or `canon ledger compact` finishes. The archive is local, not routed
135
- through `tiers:`; a `tiers.local.root` whose directory is not named `ledger`
136
- has no archive and keeps every version.
88
+ append or `canon ledger compact` finishes.
137
89
 
138
90
  **Done when:** after `canon ledger compact --commit --plan-digest <digest
139
91
  from the preview>`, a bare `canon ledger compact` previews no effect.
@@ -155,31 +107,18 @@ is `evidence` everywhere (the 0.29 spelling `evidence_record` is gone). A
155
107
  then `canon migrate --commit --plan-digest <digest>`, moves it. Full rule:
156
108
  `docs/design/ledger-layout.md`.
157
109
 
158
- ## Where artifact bytes live (`artifact_store:`)
110
+ ## Where artifact bytes live (`attachments:`)
159
111
 
160
- ```yaml
161
- artifact_store: { backend: local } # default
162
- # artifact_store: { backend: cold, prefix: artifacts/ } # an `s3` tier of `tiers:`
163
- ```
112
+ Evidence attachment bytes are plain files at `.canon/artifacts/sha256/<digest>`, tracked by git. The digest is the sha256 of the bytes. A `<digest>.zst` in that directory is no blob: the store reads the digest as missing, `canon artifacts verify` skips it and `canon artifacts prune` does not delete it. The gate and `canon artifacts verify [--full]` read these files; `--full` hashes the bytes again.
164
113
 
165
- `local` is `.canon/artifacts/sha256/`, git-tracked and credential-free. An
166
- object-store tier gets `evidence add`, `review scenario` and `artifacts store`
167
- uploads under `<prefix>sha256/<digest>.zst` and keeps nothing locally. The
168
- `.zst` object is one zstd frame (level 19) of the bound bytes; the digest is
169
- the sha256 of the bytes before compression, so a record's digest means what
170
- it always did. To read a blob without canon, download it and run
171
- `zstd -d <digest>.zst` (`zstd -t` checks it). An object an older canon wrote
172
- at `<prefix>sha256/<digest>` (plain bytes) stays valid: the gate, `verify`,
173
- `move` and `prune` read both names; canon writes only `.zst`. A canon 0.39 or
174
- older reads a `.zst` blob as missing, so upgrade every canon that reads the
175
- tier before the first `.zst` is written. The local `.canon/artifacts/sha256/`
176
- is never compressed (git's own delta compression works on plain blobs). The
177
- gate and `canon artifacts verify [--full]` ask the store and refuse, never
178
- pass, when it cannot be reached. `canon artifacts move --tier <tier>` (a preview; `--commit --plan-digest <digest>` acts)
179
- uploads, reads back and verifies every local blob, then writes the
180
- `artifact_store:` block, removes the local copies and ignores
181
- `.canon/artifacts/`; commit the removals, `.gitignore` and `canon.yaml`. It is
182
- resumable and a second run finds nothing to do.
114
+ `attachments: git` (the default) leaves the files to git. `attachments: lfs` stores them with git LFS. canon does not speak the LFS protocol: it writes the real bytes to the same path, and git's LFS filter turns them into a pointer on `git add`. canon adds four things:
115
+
116
+ - **The filter file comes first.** Before it writes bytes, canon writes `.canon/artifacts/.gitattributes` with the line `sha256/* filter=lfs diff=lfs merge=lfs -text` when that line is missing. `canon migrate` adds the line too. `canon init --check` fails when it is missing and names `canon migrate` as the fix.
117
+ - **No git-lfs, no write.** `evidence add`, `review scenario --artifact` and `artifacts store` write bytes only when `git lfs version` succeeds and `git config filter.lfs.clean` has a value. Otherwise they exit `2` with `ARTIFACTS_STORE_REQUIRED` and write nothing, so no bytes reach git as plain text. Install git-lfs and run `git lfs install`.
118
+ - **A pointer is bytes not received.** A blob file of 1 KiB or less that starts with `version https://git-lfs.github.com/spec/v1` and whose `oid sha256:` is the blob's own digest is an LFS pointer. `canon artifacts verify` reports it with the state `lfs_pointer` (exit `1`) and `canon gate check` counts the attachment as a violation. Run `git lfs pull`.
119
+ - **Reads need no git-lfs.** `gate check`, `artifacts verify` and `query` run without it.
120
+
121
+ A blob already committed as plain bytes stays plain. `git add --renormalize` and `git lfs migrate` are your git commands, not canon's.
183
122
 
184
123
  The store only grows: a report written anew on every run adds a blob per run.
185
124
  `canon artifacts prune [--keep-days N]` (a preview; `--commit --plan-digest
@@ -189,9 +128,7 @@ evidence per task and per `(project_id, scenario_id)` binds it, what the gate an
189
128
  `artifacts verify` read), `current-review` (a review still in effect binds it),
190
129
  `staged` (a record not promoted yet binds it) and `within-keep-days` (with
191
130
  `--keep-days N`, evidence or a review of the last `N` days, in the ledger or its
192
- archive, binds it). Everything else in the configured store goes: the local
193
- directory, or the objects of the tier `artifact_store:` names by the same rule
194
- (a copy left in the local directory of such a repo is judged by it too). The
131
+ archive, binds it). Everything else in `.canon/artifacts/sha256/` goes. The
195
132
  preview counts the blobs and bytes that go and stay, lists the blobs to delete
196
133
  a page at a time (`--limit`, `--cursor`, `--all`) and offers no `--commit` when
197
134
  there is nothing to delete. The plan digest covers the blobs to delete, the
@@ -199,13 +136,11 @@ blobs to keep with their reasons and every record read, so evidence added since
199
136
  the preview is `PLAN_STALE` and nothing is deleted. A repo whose records,
200
137
  staging area or archive cannot be read in full is refused: a blob is never
201
138
  deleted on a guess. After a prune, `artifacts verify` and `gate check` answer as
202
- they did. A deleted local blob leaves the working tree: commit the removal. It
139
+ they did. A deleted blob leaves the working tree: commit the removal. It
203
140
  stays in git history, and shrinking that history is the repo owner's call, not
204
- the command's. A deleted object of a tier cannot be undone, and the preview says
205
- so with the object count. A delete that fails stops the run: with nothing deleted yet
206
- it is `ARTIFACTS_STORE_FAILED` (an object) or `WRITE_FAILED` (a local file); after
207
- some, `ARTIFACTS_PRUNE_INCOMPLETE` names what was deleted, and a new preview
208
- lists what remains.
141
+ the command's. A delete that fails stops the run: with nothing deleted yet it is
142
+ `WRITE_FAILED`; after some, `ARTIFACTS_PRUNE_INCOMPLETE` names what was deleted,
143
+ and a new preview lists what remains.
209
144
 
210
145
  A blob write stages `.canon/artifacts/sha256/.tmp-<sha256>-<pid>-<nanos>` and
211
146
  renames it when it is complete; a write killed in between (SIGKILL, a power
@@ -227,23 +162,15 @@ file is no finished blob, so deleting it changes no record. One that was
227
162
  already committed is a tracked file: take it out of the commit (`git rm`, then
228
163
  commit); the preview's `staleTemps.gitNote` says so.
229
164
 
230
- ## What `canon report build` does and doesn't read
165
+ ## What `canon report build` reads
231
166
 
232
167
  canon exposes layered `stg_`/`int_`/`mart_` query views; `canon report build`
233
- builds its numbers from the `mart_` views. Those read ONLY local roots
234
- — the git ledger, the sqlite `hot` db file (local, no credential; read
235
- since 0.18) and a LOCAL `.canon/r2` parquet mirror. `canon report build`
236
- never opens a live DB connection or the live bucket, so:
237
-
238
- - Kinds routed to a postgres `hot` rung do NOT appear in `canon report
239
- build`; kinds routed to `canon init`'s default sqlite `hot` rung do.
240
- - Kinds routed to `cold` (s3) appear only if a local `.canon/r2` mirror
241
- has been separately materialized — there is no automatic sync.
242
-
243
- These kinds are not lost: read them with `canon query --kind <kind>`.
244
- The gap is named loud, not under-counted — when any routed kind isn't
245
- report-readable, `canon report build` renders a `## Kinds not read directly`
246
- section listing them and emits a matching stderr `WARN`.
168
+ builds its numbers from the `mart_` views. They read every record directly: the
169
+ ledger (`source_tier` `git`), `.canon/hot.db` (`source_tier` `hot`) and the
170
+ learn parquet under `.canon/learn/`. A record held by both the ledger and
171
+ `.canon/hot.db` is counted once. A `.canon/hot.db` that does not exist reads as
172
+ no rows and is not created; one that is no database fails the report, exit `1`,
173
+ naming the path. `canon report build` opens no network connection.
247
174
 
248
175
  ## Retention, export, and access audit
249
176
 
@@ -254,24 +181,20 @@ the plan recomputed now has the same digest (`PLAN_STALE`, exit 2, when the
254
181
  data moved). The only purgeable kinds are
255
182
  `run` and `trajectory`, plus the retired `session` and `event` (kept for this
256
183
  release only so stored rows can be deleted — delete them now, after the next
257
- release only direct database access remains; they read no routing, so they
258
- find rows in every configured tier even after `canon migrate` removes the
259
- `routing:`/`aging:` keys); the cutoff applies to every
260
- routed rung and every configured aging destination, including retained
261
- historical versions. For `trajectory`, the command also purges the
262
- operator-local Parquet learn store under `learn.root` in `canon.yaml`;
263
- an unavailable configured learn root is an explicit error, never a
264
- successful zero-row purge. The operation is idempotent. Apply mode
265
- preflights all attached destinations before the first delete, but storage
266
- backends are not one transaction: a failure after a prior delete returns
267
- an explicit `partial` result with matched/deleted counts and a nonzero
268
- status. Purge never rewrites Git history or deletes source transcript
269
- files. A tier that `canon.yaml` declares but that cannot attach (its bucket
270
- variable or DSN is unset) stops a commit, `RETENTION_TIERS_REQUIRED`, before
271
- anything is deleted; the preview of such a repository says so: it lists the
272
- removal set and the tier under `unavailable`, and its first `meta.next` step names
273
- the tier and what to set instead of a `--commit` command. Set the value and run
274
- the preview again to get the commit command.
184
+ release only direct database access remains). The cutoff applies to the ledger,
185
+ `.canon/hot.db` and the retained historical versions in the archive; a retired
186
+ kind reads no setting, so it finds its rows in both stores. For `trajectory`,
187
+ the command also purges the operator-local Parquet learn store under
188
+ `learn.root` in `canon.yaml`; an unavailable configured learn root is an
189
+ explicit error, never a successful zero-row purge, and a learn file that is no
190
+ Parquet file is `RETENTION_STORE_CORRUPT` (exit `2`, not retryable), which
191
+ stops `export --kind trajectory` too. The operation is idempotent. Apply mode
192
+ preflights both stores before the first delete, but the ledger and
193
+ `.canon/hot.db` are not one transaction: a failure after a prior delete returns
194
+ an explicit `partial` result with matched/deleted counts and a nonzero status.
195
+ `data.stores` lists one entry per store (`store` is `ledger` or `hot`,
196
+ `matched`, `deleted`). Purge never rewrites Git history or deletes source
197
+ transcript files.
275
198
 
276
199
  **Done when:** after `canon purge --kind <kind> --before <time> --commit
277
200
  --plan-digest <digest from the preview>`, a bare `canon purge` with the same
@@ -286,8 +209,7 @@ answers with what it would write and writes nothing.
286
209
 
287
210
  `canon export --kind <kind> [--before <RFC3339 date or date-time>] [--after <RFC3339 date or date-time>]
288
211
  [--output <file>] [--json] [--limit <n> | --all] [--cursor <c>]` emits a versioned manifest containing source scope,
289
- counts, digests, and redacted metadata. It does not authorize backend access;
290
- credentials remain an operator prerequisite. New output files are mode
212
+ counts, digests, and redacted metadata. New output files are mode
291
213
  `0600`. Raw event detail text is excluded unless `--include-sensitive` is
292
214
  passed and `.canon/policy.yaml` explicitly contains:
293
215
 
@@ -444,8 +366,8 @@ retry (the command exits `2` and writes no record).
444
366
 
445
367
  ## The repository write lock
446
368
 
447
- A committed destructive command (`canon purge`, `canon tier age`, `canon ledger
448
- compact`, `canon artifacts move`, `canon artifacts prune`, `canon migrate`) recomputes its plan, checks
369
+ A committed destructive command (`canon purge`, `canon ledger compact`,
370
+ `canon artifacts prune`, `canon migrate`) recomputes its plan, checks
449
371
  its digest and then makes the effects, and nothing may change the plan in
450
372
  between. It holds an OS file lock on `.canon/repo-write.lock` for the whole
451
373
  span, from before it recomputes the plan to after its last effect; a preview
@@ -467,7 +389,7 @@ call that needs the lock makes the file, in any repository.
467
389
  A fresh `canon init` writes these lines to `.gitignore` (each under a
468
390
  comment, only the missing ones):
469
391
 
470
- - `.canon/hot.db*` — the sqlite hot tier and its WAL/SHM sidecars.
392
+ - `.canon/hot.db*` — the sqlite hot database and its WAL/SHM sidecars.
471
393
  - `.canon/audit/` — the query/export/purge access log.
472
394
  - `.canon/ledger/kind=scenario/` — the scenario index; every reader
473
395
  rebuilds it.
@@ -480,8 +402,7 @@ comment, only the missing ones):
480
402
  every writer of what its plan reads hold.
481
403
  - `.canon/dashboard-snapshot/` — the snapshot `canon dashboard`
482
404
  regenerates on every run.
483
- - `.canon/learn/` and `.canon/r2/` — local learn scratch and the local
484
- object-store stand-in `canon report build` writes.
405
+ - `.canon/learn/` — local learn scratch.
485
406
 
486
407
  A rerun on a repo that already has `canon.yaml` only refreshes
487
408
  `AGENTS.md`; `canon migrate` adds the lines an existing `.gitignore`
@@ -464,9 +464,7 @@ closed again (`CLOSED`) and a change that is not deferred cannot be reopened
464
464
  <change>` on a closed change are refused (reason `CLOSED`).
465
465
 
466
466
  A closed change drops out of the requirements: the subject no longer answers
467
- for it and the scenarios only closed changes made are not asked for. A repo
468
- whose `canon.yaml` has no `change_state` line under `routing:` refuses the
469
- three leaves with `CONFIG_INVALID`; `canon migrate` adds the line.
467
+ for it and the scenarios only closed changes made are not asked for.
470
468
 
471
469
  - `canon status --json`: `data.subjects[].setAsideChanges` (each `change`,
472
470
  `state`, `reason`, `refs`, `approver`, `at`) and `setAsideScenarios` (each
@@ -773,11 +771,6 @@ uses, so status and the gate cannot disagree about a gap:
773
771
 
774
772
  Status fails closed rather than suggest progress the gate would refuse:
775
773
 
776
- - When `scenario`, `subject`, `review` or `finding` routes away from the
777
- `local` rung (the only rung status and the gate read), its records
778
- would read as empty. The only `next:` step is
779
- `canon init --check`, with the reason naming the
780
- `routing.<kind>: local` setting to restore.
781
774
  - When `spec_coverage` is present but unusable, `canon gate check`
782
775
  refuses. The first `next:` step is `canon gate check`, with the reason
783
776
  naming the section to fix, and no subject is suggested to move to its
@@ -155,7 +155,7 @@ usage: canon inventory sync [--spec-root <DIR>] [--dry-run] [--input]
155
155
  canon inventory sync --json
156
156
  ```
157
157
  ```text
158
- # Read stored records across every storage tier
158
+ # Read stored records
159
159
  usage: canon query --kind <change|task|scenario|run|handoff|review|divergence|trajectory|strategy_item|evidence|subject|finding|change_state> [--since <TIMESTAMP>] [--plugin <PLUGIN_ID> | --history] [--change <CHANGE_ID>] [--status <STATUS>] [--domain <NAME>] [--include-sensitive] [--limit <N> | --all] [--cursor <CURSOR>] [--fields <FIELDS>]
160
160
  ```
161
161
  ```bash
@@ -300,14 +300,12 @@ canon evidence add --input '[{"scenario":"auth.login.01","class":"test-run","ref
300
300
  A record binds exactly what its own write names (`--report`,
301
301
  `--artifact`): nothing is carried forward from an earlier record, so name
302
302
  every file the record should prove again. canon stores the bytes by digest
303
- in the artifact store (by default `.canon/artifacts/sha256/`, committed
304
- with the ledger; an object store when `canon.yaml`'s `artifact_store:` block
305
- names one, in which case nothing is kept locally) and `canon gate check`
303
+ in `.canon/artifacts/sha256/` (committed with the ledger; with
304
+ `storage.attachments: lfs` through git LFS, and the write is refused with
305
+ `ARTIFACTS_STORE_REQUIRED` when git-lfs is missing) and `canon gate check`
306
306
  re-checks them, so the working-tree report may be gitignored. Run
307
- `canon artifacts verify` to ask the store yourself; it refuses, never
308
- passes, when an object store cannot be reached. Moving an existing store
309
- (`canon artifacts move --tier`) and deleting the blobs no record binds
310
- (`canon artifacts prune`) are the repo owner's call: do not run them.
307
+ `canon artifacts verify` to check the store yourself. Deleting the blobs no
308
+ record binds (`canon artifacts prune`) is the repo owner's call: do not run it.
311
309
  For a scenario about what users see, let the test report carry its
312
310
  screenshots: Playwright's JUnit reporter attaches, per test case, what a
313
311
  test attaches (`testInfo.attach(name, {path})`, or `screenshot: 'on'`), and
@@ -37,14 +37,6 @@ usage: canon adapter validate --response <FILE>
37
37
  canon adapter validate --response adapter-response.json --json
38
38
  ```
39
39
  ```text
40
- # Move the local artifact blobs to an object-store tier, verify them, and remove the local copies
41
- usage: canon artifacts move --tier <TIER> [--commit --plan-digest <PLAN_DIGEST>] [--input]
42
- # a bare run previews and prints planDigest; `--commit --plan-digest <PLAN_DIGEST>` with that digest acts
43
- ```
44
- ```bash
45
- canon artifacts move --tier cold --json
46
- ```
47
- ```text
48
40
  # Delete the artifact blobs no record binds any more (the bare run previews; --commit --plan-digest deletes)
49
41
  usage: canon artifacts prune [--keep-days <N>] [--limit <N> | --all] [--cursor <CURSOR>] [--commit --plan-digest <PLAN_DIGEST>] [--input]
50
42
  # a bare run previews and prints planDigest; `--commit --plan-digest <PLAN_DIGEST>` with that digest acts
@@ -60,13 +52,20 @@ usage: canon artifacts store [--max-artifact-mib <N>] [--dry-run] [--input]
60
52
  canon artifacts store --json
61
53
  ```
62
54
  ```text
63
- # Check that the artifact store holds every file the latest evidence and current reviews bind (--full re-hashes the stored bytes)
55
+ # Check that the artifact store holds every file the latest evidence and current reviews bind
64
56
  usage: canon artifacts verify [--full]
65
57
  ```
66
58
  ```bash
67
59
  canon artifacts verify --json
68
60
  ```
69
61
  ```text
62
+ # Record the human's approval of the brief, bound to its text; refused while `brief check` has blockers
63
+ usage: canon brief approve [<CHANGE_ID>]* [--approver <NAME> | --delegated] [--note <TEXT> | --delegated] [--relayed-via <NAME> | --delegated] [--actor <ACTOR_ID>] [--digest <DIGEST> | --delegated]* [--input]
64
+ ```
65
+ ```bash
66
+ canon brief approve add-search --approver alice --note "approved as written" --json
67
+ ```
68
+ ```text
70
69
  # Write the shell completion script for canon (bash, zsh or fish)
71
70
  usage: canon completion <SHELL>
72
71
  ```
@@ -273,7 +272,7 @@ usage: canon purge --kind <run|trajectory|session|event> --before <TIMESTAMP> [-
273
272
  canon purge --kind run --before 2020-01-01T00:00:00Z --json
274
273
  ```
275
274
  ```text
276
- # Read stored records across every storage tier
275
+ # Read stored records
277
276
  usage: canon query --kind <change|task|scenario|run|handoff|review|divergence|trajectory|strategy_item|evidence|subject|finding|change_state> [--since <TIMESTAMP>] [--plugin <PLUGIN_ID> | --history] [--change <CHANGE_ID>] [--status <STATUS>] [--domain <NAME>] [--include-sensitive] [--limit <N> | --all] [--cursor <CURSOR>] [--fields <FIELDS>]
278
277
  ```
279
278
  ```bash
@@ -427,14 +426,6 @@ usage: canon subject unadopt <SUBJECT_ID> --change <CHANGE_ID> [--dry-run] [--in
427
426
  canon subject unadopt demo --change add-login --json
428
427
  ```
429
428
  ```text
430
- # Apply canon.yaml aging rules, moving old records to their destination tier
431
- usage: canon tier age [--commit --plan-digest <PLAN_DIGEST>] [--input]
432
- # a bare run previews and prints planDigest; `--commit --plan-digest <PLAN_DIGEST>` with that digest acts
433
- ```
434
- ```bash
435
- canon tier age --json
436
- ```
437
- ```text
438
429
  # Follow a finding's review loop in time order: review, finding, fix, re-review, evidence
439
430
  usage: canon trace <TRACE_ID>
440
431
  ```
@@ -510,6 +501,21 @@ implementer's context, and have it record its real session id as
510
501
  `--session` (#39). A reviewer that cannot run the tests says so and does
511
502
  not sign off.
512
503
 
504
+ ## Approve under a delegation
505
+
506
+ The owner can delegate the approval of briefs to a role while they sleep or are busy: a `delegation:` entry in
507
+ `.canon/policy.yaml` (`approver`, `to`, `acts: [brief-approve]`, `requires: clean-plan-review`), in force only while the
508
+ policy is the one a human approved. You never write the entry, and `canon brief approve` never approves a changed
509
+ `delegation:` along with a brief (`policyHeld` says so): the human reads it and runs `canon policy approve`.
510
+
511
+ When `canon status` or `canon brief show <slug>` names a delegation step for your role, follow the order and stop for no human:
512
+
513
+ 1. A reviewer in a separate process and session records the plan review: `canon review brief <slug> --actor <reviewer id> --session <its session> --round <n> --verdict approve|revise --digest <slug>=<digest>`, where `<digest>` is the last line `canon brief show <slug> --body` printed, and each finding with `canon finding add --change <slug> --review <review id> --round <n> --seq <k> --severity blocker`: P0 and P1 are `blocker` (with `--introduced-rev` or `--introduced-unknown`), P2 `should-fix`, P3 `note`.
514
+ 2. On `revise`, or an open `blocker`, the planner fixes the brief, runs `canon brief check`, closes the findings (`canon finding close <slug> --round <n> --seq <k> --disposition fixed`, or `rejected --reason "<why>"`), and a new independent reviewer records the next round. The earlier review no longer counts: it was of another text. Repeat until the latest review is an `approve` with no open `blocker`. If round 3 still leaves P0 or P1 findings, stop and report to the owner.
515
+ 3. Approve with one call: `canon brief approve <slug> --as orchestrator --actor <your actor id> --delegated` (several slugs take one call; none is written unless every one is approvable). There is no name, answer, relay tool or digest to give: canon writes them. `DELEGATION_REQUIRED` names the condition not met in its `reason` (`NO_GRANT`, `POLICY_UNAPPROVED`, `NO_REVIEW`, `REVIEW_REVISE`, `SAME_ACTOR`, `OPEN_BLOCKER`), and nothing is written.
516
+
517
+ The reviewer must be another actor than the one approving: canon compares the actor ids only, so the separate session is yours to keep. The `Approved:` line says `(delegated to <role> <actor> under policy <digest> after review <id>)`, and `status`, `brief show` and the dashboard show it apart from a human's answer and a relayed one. To take a delegation back the owner deletes the entry and runs `canon policy approve`.
518
+
513
519
  ## Relay the human's answer
514
520
 
515
521
  When `status` or `meta.next` shows a step with `x-canon.actor: human` (the brief's
@@ -595,7 +601,7 @@ its preview, never from an old digest.
595
601
  |---|---|
596
602
  | "Edit the policy so the gate passes." | A changed policy fails closed (`POLICY_APPROVAL_STALE`); ask the human to re-approve or restore it from git. |
597
603
  | "The reviewer can be me under another label." | The reviewer is a separate process with its own real session id (#39). |
598
- | "Approve the brief; the human said they are busy." | An answer they did not give is not recorded. Show the brief, ask, and record only an explicit approval with `--relayed-via`. |
604
+ | "Approve the brief; the human said they are busy." | An answer they did not give is not recorded. If `delegation:` of the approved policy holds an entry for your role, `canon brief approve --delegated` is the call; otherwise show the brief, ask, and record only an explicit approval with `--relayed-via`. |
599
605
  | "Override the refusal to ship." | Fix the gap the refusal names; `--override-reason` waives only the `require_review` gaps and the brief gap, is recorded on the subject, and is for the human's call, not a shortcut. |
600
606
  | "Run the commit now, the preview looked fine earlier." | A bare run previews; `--commit --plan-digest` acts only on the plan you just previewed (`PLAN_STALE` otherwise). Preview again, then act. |
601
607
  | "I have corrected this agent before." | A correction repeated across runs belongs in a scenario, the policy or a gate, not more prose. Tell the human. |
@@ -637,8 +643,8 @@ read the refusal in `error` of `canon subject move demo --to shipped --json`.
637
643
 
638
644
  ## Destructive commands preview first
639
645
 
640
- `canon purge`, `canon tier age`, `canon ledger compact`, `canon artifacts
641
- move` and `canon migrate` delete or rewrite existing data. A bare run only
646
+ `canon purge`, `canon ledger compact`, `canon artifacts prune` and
647
+ `canon migrate` delete or rewrite existing data. A bare run only
642
648
  previews: exit 0, nothing written, a report with `planDigest` and
643
649
  `effects[]`. Read the effects, then act with `--commit --plan-digest
644
650
  <planDigest>`; it refuses (`PLAN_STALE`, exit 2) when the plan recomputed
@@ -648,21 +654,19 @@ read that changed since is `PLAN_STALE` too, and `meta.next[0]` is the preview
648
654
  to run again. A commit holds the repository write lock for its whole run:
649
655
  another command that writes waits for it, and one that waited 30 seconds
650
656
  answers `REPO_LOCK_UNAVAILABLE` (exit 2, retryable): run it again. A document passed
651
- with `--input` never carries `--commit` or `--plan-digest`, and these six
657
+ with `--input` never carries `--commit` or `--plan-digest`, and these four
652
658
  leaves take one object only (`INPUT_INVALID`).
653
659
 
654
660
  ```bash
655
661
  canon purge --kind session --before 2026-01-01
656
- canon tier age
662
+ canon artifacts prune
657
663
  canon ledger compact
658
664
  ```
659
665
 
660
- `canon artifacts move --tier <tier>` moves the local artifact store to an
661
- object store and removes the local blobs, `canon artifacts prune` deletes the
666
+ `canon artifacts prune` deletes the
662
667
  blobs no record binds any more and the stale `.tmp-` files a killed write left
663
- in the store (a deleted local blob stays in git history; a deleted object of a
664
- tier is gone for good; `canon artifacts verify` only counts the temp files), and
665
- `purge` deletes records. They
668
+ in the store (a deleted blob stays in git history; `canon artifacts verify`
669
+ only counts the temp files), and `purge` deletes records. They
666
670
  are the repo owner's decisions, not steps of the loop: run the preview, give
667
671
  the human the effects, and run the commit only on their answer. If the repo is
668
672
  large, the store is slow or the human has not asked for it, do not run it.
@@ -24,6 +24,13 @@ in your ids. Use only the options on a line; never guess one. Ask `canon schema
24
24
  Every leaf takes `--as <ROLE>` and `--json`; `--repo <DIR>` too, except `completion`, `schema`, `skills show`. `--input <JSON|FILE|->` runs a leaf from one JSON document (an array is a batch) and is only on the lines ending `[--input]`. Its document keys are the option names in camelCase, singular even when the option repeats (the value is then an array; none is the key left out, `[]` is refused), and `operands` holds the operands. `--fields <FIELDS>` is a comma list of the paths `canon schema <COMMAND> --json` declares under `outputs[].fields.paths`; a path is the record's own key, spelled as the answer spells it.
25
25
  A `usage:` line shows the syntax and is not itself a command to run (the runnable example under it is): `<X>` is a value, `[x]` optional, `a | b` a choice, `(a | b)` exactly one is required, `[--x <V>]*` may repeat, `<X>+` is one or more, `[--a --b <V>]` go together. An option that is not on the line does not exist: it is refused (`USAGE`).
26
26
 
27
+ ```text
28
+ # Record the human's approval of the brief, bound to its text; refused while `brief check` has blockers
29
+ usage: canon brief approve [<CHANGE_ID>]* [--approver <NAME> | --delegated] [--note <TEXT> | --delegated] [--relayed-via <NAME> | --delegated] [--actor <ACTOR_ID>] [--digest <DIGEST> | --delegated]* [--input]
30
+ ```
31
+ ```bash
32
+ canon brief approve add-search --approver alice --note "approved as written" --json
33
+ ```
27
34
  ```text
28
35
  # Read the brief against the rules
29
36
  usage: canon brief check [<CHANGE_ID>]
@@ -95,7 +102,7 @@ usage: canon gate check [--release]
95
102
  canon gate check --json
96
103
  ```
97
104
  ```text
98
- # Read stored records across every storage tier
105
+ # Read stored records
99
106
  usage: canon query --kind <change|task|scenario|run|handoff|review|divergence|trajectory|strategy_item|evidence|subject|finding|change_state> [--since <TIMESTAMP>] [--plugin <PLUGIN_ID> | --history] [--change <CHANGE_ID>] [--status <STATUS>] [--domain <NAME>] [--include-sensitive] [--limit <N> | --all] [--cursor <CURSOR>] [--fields <FIELDS>]
100
107
  ```
101
108
  ```bash
@@ -309,6 +316,13 @@ ids); the human step comes after it. A policy that no longer matches its approva
309
316
  adds or changes a step of the brief is a scope change and needs a new
310
317
  answer.
311
318
 
319
+ When the owner delegated the approval (`delegation:` in the approved policy; `canon status` and `canon brief show` say so), a clean
320
+ brief does not wait for a human: an independent reviewer records a plan review (`canon review brief`), and on `revise` or an open
321
+ `blocker` you fix the brief, run `canon brief check`, close the findings (`canon finding close <slug> --round <n> --seq <k>
322
+ --disposition fixed`, or `rejected --reason "<why>"` for a finding you do not accept), and a new independent reviewer records the
323
+ next round. The earlier round no longer counts once the brief changes. After round 3 with P0 or P1 findings still open, stop and
324
+ report to the owner. The orchestrator then approves with `canon brief approve <slug> --as orchestrator --actor <id> --delegated`.
325
+
312
326
  When no human can answer one of the brief's questions, write the question
313
327
  into Questions and assumptions, state the assumption you will build on, and
314
328
  say so in your report. That applies to the brief's questions, never to the
@@ -348,9 +362,6 @@ editing files or by `subject unadopt`; you ask, then record their answer.
348
362
  change is refused (reason `CLOSED`).
349
363
  - Evidence, reviews and findings stay as they are; the warning
350
364
  `CHANGE_RECORDS_KEPT` lists what the closed change keeps.
351
- - A repo whose `canon.yaml` has no `change_state` line under `routing:` refuses
352
- these leaves with `CONFIG_INVALID`; `canon migrate` previews and, committed
353
- with its plan digest, adds the line.
354
365
 
355
366
  A closed change drops out of what the subject and the gate require. `canon
356
367
  status --json` lists it per subject in `setAsideChanges` and its scenarios in