@erclx/canon 4.121.0 → 4.122.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 (96) hide show
  1. package/claude/.claude-plugin/plugin.json +1 -1
  2. package/claude/skills/auto-ship/SKILL.md +1 -1
  3. package/claude/skills/backlog-triage/REQUIREMENT.md +47 -0
  4. package/claude/skills/backlog-triage/SKILL.md +139 -0
  5. package/claude/skills/canon-rollout/SKILL.md +6 -6
  6. package/claude/skills/context-fold/REQUIREMENT.md +75 -0
  7. package/claude/skills/context-fold/SKILL.md +162 -0
  8. package/claude/skills/{docs-fold → context-fold}/references/anchor-sweep.md +1 -1
  9. package/claude/skills/{docs-fold → context-fold}/references/classify.md +4 -2
  10. package/claude/skills/context-fold/references/context-refresh.md +48 -0
  11. package/claude/skills/context-fold/references/promoted-pages.md +29 -0
  12. package/claude/skills/context-fold/references/receipt-sweep.md +43 -0
  13. package/claude/skills/context-fold/references/unusable-baseline.md +25 -0
  14. package/claude/skills/{docs-fold → context-fold}/references/wireframe-sweep.md +1 -1
  15. package/claude/skills/docs-fold/REQUIREMENT.md +8 -58
  16. package/claude/skills/docs-fold/SKILL.md +3 -278
  17. package/claude/skills/docs-sync/REQUIREMENT.md +1 -1
  18. package/claude/skills/docs-sync/SKILL.md +1 -1
  19. package/claude/skills/draft-context/REQUIREMENT.md +2 -2
  20. package/claude/skills/draft-context/SKILL.md +3 -3
  21. package/claude/skills/draft-docs/REQUIREMENT.md +1 -1
  22. package/claude/skills/draft-wireframes/REQUIREMENT.md +1 -1
  23. package/claude/skills/draft-wireframes/SKILL.md +2 -2
  24. package/claude/skills/git-pr/SKILL.md +8 -146
  25. package/claude/skills/git-pr/references/evidence.md +114 -0
  26. package/claude/skills/git-pr/references/labels.md +20 -0
  27. package/claude/skills/git-pr/references/task-number.md +26 -0
  28. package/claude/skills/git-ship/SKILL.md +1 -1
  29. package/claude/skills/memory-capture/REQUIREMENT.md +2 -2
  30. package/claude/skills/memory-capture/SKILL.md +5 -5
  31. package/claude/skills/memory-review/REQUIREMENT.md +1 -1
  32. package/claude/skills/memory-review/SKILL.md +5 -101
  33. package/claude/skills/memory-review/references/later-phases.md +108 -0
  34. package/claude/skills/plan-feature/REQUIREMENT.md +1 -1
  35. package/claude/skills/review-address/REQUIREMENT.md +1 -1
  36. package/claude/skills/review-address/SKILL.md +1 -1
  37. package/claude/skills/review-branch/SKILL.md +1 -1
  38. package/claude/skills/role-orchestrator/references/orchestrator-dispatch.md +1 -1
  39. package/claude/skills/role-orchestrator/references/orchestrator-parked.md +2 -0
  40. package/claude/skills/role-orchestrator/references/orchestrator-refill.md +2 -2
  41. package/claude/skills/session-resume/REQUIREMENT.md +1 -1
  42. package/claude/skills/session-worktree/SKILL.md +4 -10
  43. package/claude/skills/task-board/REQUIREMENT.md +1 -1
  44. package/claude/skills/task-board/SKILL.md +6 -80
  45. package/claude/skills/task-board/references/archive.md +54 -0
  46. package/claude/skills/task-board/references/decline.md +40 -0
  47. package/claude/skills/teach-workspace/SKILL.md +8 -105
  48. package/claude/skills/teach-workspace/references/lesson-craft.md +51 -1
  49. package/claude/skills/teach-workspace/references/promotion.md +41 -0
  50. package/docs/agents/architecture-record.md +26 -0
  51. package/docs/agents/commands.md +87 -154
  52. package/docs/agents/context-audit-checks.md +2 -20
  53. package/docs/agents/context-audit.md +1 -1
  54. package/docs/agents/context-classify.md +1 -1
  55. package/docs/agents/drift-surfaces.md +192 -0
  56. package/docs/agents/index.md +12 -4
  57. package/docs/agents/install-and-sync.md +2 -181
  58. package/docs/agents/markdown-audit-weight.md +73 -0
  59. package/docs/agents/markdown-audit.md +3 -90
  60. package/docs/agents/migrate.md +34 -0
  61. package/docs/agents/records-stale.md +62 -0
  62. package/docs/agents/records.md +5 -1
  63. package/docs/agents/sandbox.md +1 -1
  64. package/docs/agents/tasks-archive.md +81 -0
  65. package/docs/agents/tasks-plans.md +147 -0
  66. package/docs/agents/tasks-validate.md +131 -0
  67. package/docs/agents/tasks.md +6 -333
  68. package/docs/target-projects.md +3 -3
  69. package/docs/workflow/ai-workflow.md +32 -27
  70. package/governance/rules/core/045-memory.md +1 -1
  71. package/package.json +1 -1
  72. package/src/claude/cases/setup.ts +1 -1
  73. package/src/claude/cases/workflow.ts +22 -1
  74. package/src/commands/records.ts +146 -0
  75. package/src/commands/sandbox.ts +6 -4
  76. package/src/context/classify/extract.ts +1 -1
  77. package/src/context/classify/ollama.ts +1 -1
  78. package/src/context/classify/run.ts +1 -1
  79. package/src/gate/measures.ts +1 -1
  80. package/src/migrate/skill-names.ts +15 -2
  81. package/src/records/stale.ts +243 -0
  82. package/src/sandbox/expect.ts +1 -1
  83. package/src/tasks/archive.ts +28 -4
  84. package/src/tasks/record.ts +1 -1
  85. package/src/tasks/validate.ts +36 -3
  86. package/standards/memory.md +13 -1
  87. package/standards/tasks.md +1 -1
  88. package/tooling/astro/reference.md +1 -1
  89. package/tooling/base/configs/.husky/post-merge +1 -1
  90. package/tooling/claude/reference.md +1 -1
  91. package/tooling/go/reference.md +1 -1
  92. package/tooling/nextjs/reference.md +1 -1
  93. package/tooling/php/reference.md +1 -1
  94. package/tooling/python/reference.md +1 -1
  95. package/tooling/vite-react/reference.md +1 -1
  96. package/tooling/web/reference.md +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "canon",
3
3
  "description": "Automated governance, versioning, and discovery tools for Claude Code.",
4
- "version": "4.121.0",
4
+ "version": "4.122.0",
5
5
  "author": {
6
6
  "name": "Eric Le",
7
7
  "url": "https://github.com/erclx"
@@ -137,7 +137,7 @@ Read origin as causation rather than authorship, so staleness this run induced i
137
137
 
138
138
  Bound the repair at one pass, the way Step 3 bounds verify. When that re-read shows the finding still standing, stop: `❌ A self-introduced finding survived one fix pass. See .canon/review/branch-<slug>.md. Fix and run /git-ship.`
139
139
 
140
- This chain owns the receipt's lifetime, which is what makes the Output block's citation resolve on a run that reaches it. The `docs-fold` sweep under Step 8 reaches only reports whose branch is gone, which collects this one a branch later rather than during the run that wrote it.
140
+ This chain owns the receipt's lifetime, which is what makes the Output block's citation resolve on a run that reaches it. The `context-fold` sweep under Step 8 reaches only reports whose branch is gone, which collects this one a branch later rather than during the run that wrote it.
141
141
 
142
142
  ## Step 8: ship
143
143
 
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: backlog-triage
3
+ description: Why the backlog gets a measured verdict per row with a lean toward decline, and why filing and applying are split by the operator's answer
4
+ ---
5
+
6
+ # Backlog triage requirement
7
+
8
+ ## Gap
9
+
10
+ Without this skill, the backlog only grows. `task-board` declines or archives one named task, and nothing reads the backlog as a whole, so a row stays until somebody happens to remember it and decides by hand. The orchestrator's backlog re-test only clears a row upward onto the board, so no sweep ever takes one off. A backlog past fifty rows had no surface that could say which of them still mattered.
11
+
12
+ Three failure modes cost more than the rest. A pass that judges a row by what its task file says rather than by the tree keeps every row, since a task file reads as live the day it was written and every day after. A pass that applies its own verdicts decides rows on silence, which ships a decline nobody approved on a board with no history to restore it from. And a keep that carries no measurement is the default nobody argues with, so a triage without a lean toward decline ends with the same backlog it started with.
13
+
14
+ ## Must
15
+
16
+ - Measure every row against the tree and the log during the pass, carrying a count, a path, or a commit rather than the task file's own claim
17
+ - Suggest decline for any row this pass cannot argue for, putting the burden of proof on keep and promote
18
+ - Name the commit or pull request per outcome position before suggesting archive
19
+ - File into an ordinary intake folder, so the intake list and answer verbs read and write it unchanged
20
+ - Carry the verdict in the suggestion line and the task stem in the item heading, rather than in new fields
21
+ - Split filing from applying by the operator's answer, so filing writes only inside the intake folder and applying writes only what was approved
22
+ - Apply through the existing decline, outcome, and archive verbs
23
+ - Leave the folder slug on every task a verdict touched, so a re-run writes nothing twice
24
+ - Refuse to apply under a planner or worker session, and hand a promote to a live orchestrator rather than writing the ordering file beside it
25
+
26
+ ## Must not
27
+
28
+ - Fill an operator's answer slot, or infer a verdict from an empty one or from a free-text answer
29
+ - Read a suggestion carrying no verdict token as keep
30
+ - Treat age as evidence for or against a row
31
+ - Retry an archive with guessed outcome positions after a refusal
32
+ - Change the intake standard, the intake skills, or the task verbs to fit triage
33
+
34
+ ## Guards
35
+
36
+ - No backlog file: stop
37
+ - Unread items in the newest triage folder: stop and name the answer skill
38
+ - An item carrying no answer slot: stop and name the folder to repair
39
+ - Apply under a session named for the planner or worker role: stop before writing
40
+
41
+ ## Out of scope
42
+
43
+ - Filing a brain dump, which `plan-intake` owns
44
+ - Answering the filed items, which `plan-intake-answer` owns
45
+ - Creating a task, or archiving and declining one named task outside a triage, which `task-board` owns
46
+ - Ordering the rows a promote lands under `## Needs a plan`, which the orchestrator's refill sweep owns
47
+ - Skipping rows kept at a recent triage, which waits on a second triage measuring the re-read cost
@@ -0,0 +1,139 @@
1
+ ---
2
+ name: backlog-triage
3
+ description: Files a measured verdict for every backlog row into an intake folder, suggesting decline, archive, keep, or promote and leaning toward decline, then applies the verdicts the operator approved through the task verbs. Use when asked to "triage the backlog", "prune the backlog", "which backlog rows are still worth doing", "clear out the backlog", or "apply the backlog triage". Do NOT use to file a brain dump, which is `plan-intake`, to answer the filed items, which is `plan-intake-answer`, or to create, archive, or decline one named task, which is `task-board`.
4
+ ---
5
+
6
+ # Backlog triage
7
+
8
+ A backlog only grows while nothing can decline a row. This pass reads every row against the current tree, files one verdict per row for the operator, and later applies what they approved.
9
+
10
+ The record is an ordinary intake folder at `.canon/intake/<nn>-backlog-triage/`. Read `${CLAUDE_SKILL_DIR}/../../standards/intake.md` before writing any file in it, since it holds the item format, the frontmatter, the index shape, and the answer contract this skill is bound by. Read `${CLAUDE_SKILL_DIR}/../../standards/tasks.md` before applying, since it holds the backlog, the ordering file, and the `Declined:` line.
11
+
12
+ ## Guards
13
+
14
+ - Resolve `.canon/tasks/` and `.canon/intake/` at the main worktree root, not `pwd`. Run `git worktree list --porcelain | grep -m 1 '^worktree ' | cut -d' ' -f2-`, falling back to `pwd` outside a git repo.
15
+ - If `.canon/tasks/backlog.md` does not exist at that root, stop: `❌ No backlog at .canon/tasks/backlog.md. Nothing to triage.`
16
+ - Never fill a `You:` slot, and never read an empty one as agreement. Answering runs through `plan-intake-answer` or the operator's own edit, which is what keeps silence from deciding a row.
17
+ - Branch on each `canon` record's `ok` and `reason` rather than on the exit code, which a shell function wrapping `canon` can flatten to zero.
18
+
19
+ ## Step 1: detect the phase
20
+
21
+ Run `canon intake list --json` and take the folders whose slug ends in `-backlog-triage`. Read the newest by ordinal. Where the installed binary carries no such subcommand, stop and report it, since opening a folder beside one awaiting apply leaves the first stranded and applying needs the same verb.
22
+
23
+ - **No folder, or the newest is fully applied.** Run the file phase.
24
+ - **Unread above zero.** Stop: `❌ <n> items in <slug> are unread. Run /canon:plan-intake-answer, then re-run this skill to apply.`
25
+ - **Malformed above zero.** Stop: `❌ <n> items in <slug> carry no answer slot. Repair them in the cluster files before applying.`
26
+ - **Every item answered, some not yet applied.** Run the apply phase.
27
+
28
+ An item is applied once its task has moved under `.canon/tasks/declined/` or `.canon/tasks/archive/`, or once its live task file carries a `## Findings` line naming the folder slug. A task whose file sits in none of the three folders counts as applied only once `backlog.md` no longer names it, since its dangling line is the one thing apply has left to remove. Test that per item rather than trusting a count, since a run can stop partway. An item apply skipped for an unreadable answer stays unapplied, so the folder stays in the apply phase until the operator rewrites that answer.
29
+
30
+ ## File phase
31
+
32
+ Writes only inside `.canon/intake/<nn>-backlog-triage/`, so it runs under any role, including a planner session.
33
+
34
+ ### Step 2: claim the folder
35
+
36
+ Run `canon records ordinal intake backlog-triage --claim --json` and take its `name`. The verb creates the folder in the same act, so two sessions opening at once never share one. Where the installed binary carries no such subcommand, report it and stop rather than picking an ordinal by hand.
37
+
38
+ ### Step 3: read every row
39
+
40
+ List each link in `.canon/tasks/backlog.md` and open its task file. Read its origin line (`Plan:`, `Groundwork:`, `Intake:`, or `Issue:`), its `## Outcomes`, and its `## Findings`. Read `.canon/tasks/priority.md` once, so a promote can name what sits at the bottom of `## Needs a plan`.
41
+
42
+ A row whose link resolves to no file gets an item anyway, carrying `decline` and naming the missing path, since the backlog line is the only thing left pointing at it.
43
+
44
+ ### Step 4: measure each row
45
+
46
+ Measure every claim the task makes against the tree and `git log` during this pass. Grep for the construct its defect names and count the sites, check whether each open outcome's behavior exists, and search the log for a commit or pull request that shipped it under another task. Never carry a figure from the task file forward as current, since the task states what was true when it was filed.
47
+
48
+ Name the commit the pass measured against in the overview body.
49
+
50
+ ### Step 5: pick the verdict
51
+
52
+ Keep and promote carry the burden of proof. A row nobody can argue for from this pass's measurement is declined.
53
+
54
+ - **keep**: the defect or gap reproduces this pass, stated with a count or a path.
55
+ - **promote**: it reproduces, and the thing it was waiting on has cleared, naming what cleared it.
56
+ - **archive**: every open outcome is measured shipped, naming the commit or pull request per outcome position.
57
+ - **decline**: anything else, including a defect the tree no longer holds, work superseded by another task, and a row whose argument rests only on its original filing.
58
+
59
+ Age is evidence in neither direction. A row untouched for months is not more declinable than one filed yesterday, and a row filed yesterday is not more worth keeping.
60
+
61
+ ### Step 6: write the items
62
+
63
+ Write one item per row in the intake item format, one cluster file per domain the task touches, numbered in read order. Head each item `### N. <task stem>` so apply can find the task from the heading alone.
64
+
65
+ - `Problem:` states what this pass measured, with the count, path, or commit behind it
66
+ - `Fix:` states what applying the verdict does to the board
67
+ - `Worth it:` carries the verdict's reason in one clause
68
+ - `Open:` reads `decline, archive, keep, or promote?` on every item
69
+ - `Suggested:` opens with exactly one of the four verdict tokens, then the reason. An archive suggestion lists every outcome position it closes, as `archive 1, 3: shipped in #NNN`
70
+ - `Overlaps:` names a live board task that already carries the work, where one does
71
+ - `You:` ships empty
72
+
73
+ Write `00-overview.md` last, per the intake standard, with the verdict counts by token and an open-questions list linking each item. Where the pass runs out of context before the index, write `99-next-session.md` naming the last row filed, since a compaction drops the rest.
74
+
75
+ ## Apply phase
76
+
77
+ Writes the board and task files. Refuses when this session's name starts with `planner-` or `worker-`: read it from `canon sessions list --self --json` before writing anything, and stop: `❌ Apply writes the board, which the <role> role bans. Run it from an operator or orchestrator session.` A refused or failed read proceeds, since it is indistinguishable from a solo project running no named sessions.
78
+
79
+ Every write here is a main-root write. Route a change inside an existing file the way `session-worktree` states, and report it rather than proceeding silently when that skill does not resolve.
80
+
81
+ ### Step 7: read the answers
82
+
83
+ Run `canon intake list <slug> --json` and read each item's `answer` and `suggested`.
84
+
85
+ - An answer of `ok` takes the suggested verdict. A `suggested` that opens with no verdict token is malformed: report the item and skip it, never treating it as keep.
86
+ - An answer opening with a verdict token overrides the suggestion. An override to archive names its own outcome positions, and one that names none is reported and skipped.
87
+ - Any other answer, such as a free-text note, is reported and skipped. Never guess a verdict from prose.
88
+ - An item already applied, by the test in Step 1, is skipped silently, which is what makes a re-run write nothing twice.
89
+
90
+ ### Step 8: run each verdict
91
+
92
+ Take the task stem from the item heading. Every verdict leaves the folder slug on its task, which is how Step 1 and `task-board`'s unlinked-origin scan both see the folder as acted on.
93
+
94
+ - **decline**: `canon tasks decline <stem> --reason "<reason>, backlog triage <slug> item <cluster>#<n>" --json`. The verb clears the backlog line.
95
+ - **decline on a missing file**: when the stem resolves to no file in `.canon/tasks/`, `declined/`, or `archive/`, the verb would refuse as `no-match`, so skip it. Drop the dangling line from `backlog.md` directly and report it as removed with no task behind it. Any other verdict on such an item is reported and skipped, since there is no file to keep, archive, or promote.
96
+ - **archive**: `canon tasks outcome <stem> --close <p> ... --json` for the named positions, then `canon tasks archive <stem> --json`. Outcomes already closed report as closed rather than refusing, so archive still runs. Archive leaves `backlog.md` alone, so drop the task's backlog line once it succeeds, then append the `## Findings` line naming the evidence to the archived file.
97
+ - **keep**: append the `## Findings` line naming what reproduced. The backlog line stays.
98
+ - **promote**: move the backlog line to the bottom of `## Needs a plan` in `.canon/tasks/priority.md`, with a `Waiting on` cell stating what cleared and ending in `last`, then append the `## Findings` line.
99
+
100
+ Write the `## Findings` line as `- <YYYY-MM-DD>, backlog triage <slug>: <verdict>, <evidence>`. It is the last write on every verdict with a task file behind it, since Step 1 reads it as applied and a line written ahead of a refused move would mark a row done that never moved.
101
+
102
+ Before any promote, check the roster the way `task-board` step 4 does: a live session in this repository whose name starts with `orchestrator-` and whose `sessionId` is not this one. When one is found, write the `## Findings` line but not `priority.md` or `backlog.md`, and message that session with the row and its cell so it places the row itself.
103
+
104
+ ### Step 9: route on a refusal
105
+
106
+ Report every refusal on its item and continue with the rest, since one row's refusal says nothing about another's.
107
+
108
+ - `decline` refusing with `no-match`: the task already moved elsewhere. Report and skip. A missing-file item never reaches the verb, per Step 8.
109
+ - `outcome` refusing, or `archive` refusing with `open-outcomes`: the verdict named too few positions. Report the positions still open and leave the row on the backlog. Never retry with guessed positions.
110
+ - A promote whose row already sits in `priority.md`: report it, skip the move, and still write the `## Findings` line.
111
+
112
+ Close with `canon tasks validate --json` and report every finding it raises against a row this run touched. After a shell write under `.canon/tasks/`, regenerate the index with `canon indexes regen --no-stage --root <main-root> <main-root>/.canon/tasks/index.md`, since no hook fires on `Bash`.
113
+
114
+ ## Output
115
+
116
+ File phase:
117
+
118
+ ```plaintext
119
+ 📂 Opened .canon/intake/<nn>-backlog-triage/
120
+
121
+ **Filed:** <N> rows across <N> clusters, measured against <sha>
122
+ **Suggested:** <n> decline, <n> archive, <n> keep, <n> promote
123
+
124
+ Next: /canon:plan-intake-answer to answer the `You:` slots, then /canon:backlog-triage to apply
125
+ ```
126
+
127
+ Apply phase, naming the path every write landed at:
128
+
129
+ ```plaintext
130
+ ✅ Applied .canon/intake/<nn>-backlog-triage/
131
+
132
+ **Declined:** .canon/tasks/declined/<stem>.md
133
+ **Archived:** .canon/tasks/archive/<stem>.md
134
+ **Kept:** .canon/tasks/<stem>.md
135
+ **Promoted:** .canon/tasks/<stem>.md, bottom of ## Needs a plan
136
+ **Skipped:** <item>, <reason>
137
+ ```
138
+
139
+ Drop a line that carries no rows.
@@ -17,7 +17,7 @@ One wave takes one toolkit change to every target and ends with a pull request p
17
17
  - The invocation or the launch prompt names the worker role, a target path, or both: worker. Skip to `## The worker role` and run no phase above it.
18
18
  - Neither is named: orchestrator. Run the three phases in order.
19
19
 
20
- The role is read off the prompt because nothing else carries it. A dispatched worker starts in the target's own checkout, which is a repository like any other from the session's side, so a test on the working directory answers the same for a worker in a target and an operator who invoked this from one. Reading the role wrong in that direction starts a second wave from inside a consuming project, which is why the dispatch below names the role and the path both rather than relying on either alone.
20
+ The role is read off the prompt because nothing else carries it. A test on the working directory answers the same for a worker in a target and an operator who invoked this from one, and reading the role wrong starts a second wave from inside a consuming project.
21
21
 
22
22
  Do not invoke `canon:role-worker` from either role. That body states the role for a session building one branch under one plan in this repository, and it resolves session scratch against a main worktree root a target does not carry, so a rollout worker reading it hunts for a plan nobody wrote.
23
23
 
@@ -30,7 +30,7 @@ Do not invoke `canon:role-worker` from either role. That body states the role fo
30
30
 
31
31
  ## The fixed shape every target receives
32
32
 
33
- Every target in every wave takes the same branch and the same title, written from here rather than chosen per session. Four hand-driven repairs produced four titles across two scopes, neither of them this one, and three named the toolkit in the half of the shape that withholds it.
33
+ Every target in every wave takes the same branch and the same title, written from here rather than chosen per session.
34
34
 
35
35
  - Branch: `chore/agents`, in every target and every wave.
36
36
  - Title: `chore(agents): <what changed in that target>`.
@@ -48,7 +48,7 @@ One branch name across every target is also what lets the return leg resolve. `c
48
48
 
49
49
  1. Pin the wave. Record the commit of this repository that the wave carries and name it in this session's own reports. Name it in no target's body.
50
50
  2. Enumerate. Run `canon targets list --json` under `CANON_NON_INTERACTIVE=1`, adding `--sweep <root...>` to reach targets installed before the index existed. Read the `bound` object back before treating any count as the population, since it names the roots walked, the depth, where the walk stopped, and what it could not read. The bound a sweep can never state is the machine, so a target on another one sits outside every answer it gives.
51
- 3. Pick the clone that is current. A row carries every checkout of that project under `paths` and leads with the one a sync ran in, which records where an install happened rather than what the checkout holds today. Fetch each candidate, compare it against the origin's default branch, and dispatch into one that is level. Refuse one that is behind rather than branching from a stale base, since three clones read as still owing the repair in one census and every one of them was behind its remote and nothing else.
51
+ 3. Pick the clone that is current. A row carries every checkout of that project under `paths` and leads with the one a sync ran in, which records where an install happened rather than what the checkout holds today. Fetch each candidate, compare it against the origin's default branch, and dispatch into one that is level. Refuse one that is behind rather than branching from a stale base, since a stale clone reads as still owing a repair its remote already carries.
52
52
 
53
53
  ### Check, then dispatch
54
54
 
@@ -88,10 +88,10 @@ Report each dispatch by naming the target, the clone, the branch, the model, and
88
88
 
89
89
  1. Address every finding whatever its severity. A minor is a finding, and a reviewer calling one non-blocking does not close the pass that raised it.
90
90
  2. Resolve who holds the branch before dispatching anybody. Run `canon sessions list --branch chore/agents --repository <clone> --json` and read the count rather than the first row.
91
- - A live session holds it: send that session the findings and name `canon:review-address` for it to run, which is step 7 of `## The worker role` and the step that session already stands at. Never name this skill in that message. This body carries `disable-model-invocation: true`, which blocks the `Skill` tool rather than only suppressing an auto-trigger, and a session acting on an inbound message reaches a skill that way and no other, so a message naming this one halts the address leg with the branch built and the findings unread. A launch prompt is the one route to a flagged body, which is why the dispatch above names this skill and this message must not. Assuming the worker was gone is what one hand-driven pass got wrong. All four sessions that opened those pull requests were still alive holding their worktrees hours later, and of two fresh addressers sent over them, one refused on the worktree lock and one cut a second worktree on the same branch, which would have put two sessions pushing to one ref.
91
+ - A live session holds it: send that session the findings and name `canon:review-address` for it to run, which is step 7 of `## The worker role` and the step that session already stands at. Never name this skill in that message. This body carries `disable-model-invocation: true`, which blocks the `Skill` tool rather than only suppressing an auto-trigger, and a session acting on an inbound message reaches a skill that way and no other, so a message naming this one halts the address leg with the branch built and the findings unread. A launch prompt is the one route to a flagged body, which is why the dispatch above names this skill and this message must not. Never assume the worker is gone, since a fresh addresser sent over a live one either refuses on the worktree lock or cuts a second worktree on the same branch.
92
92
  - No live session holds it: dispatch a fresh worker into that clone and brief it with the findings, since it holds none of the reasoning behind the diff.
93
93
  - More than one row: report the ambiguity and stop rather than picking among candidates.
94
- 3. Re-review when the answer lands, scoped to the commits added since. A worker's reply never closes a target. One fix for two minor findings closed both and introduced four more, every one of them in prose that fix added, and a loop trusting the reply merges that.
94
+ 3. Re-review when the answer lands, scoped to the commits added since. A worker's reply never closes a target, since a fix can introduce findings of its own in the prose it adds.
95
95
  4. A target leaves the wave when a pass posts `## Review closed` and not before.
96
96
  5. Run until every target closes. No count bounds the loop. What guards it is this session reviewing every round itself, so it holds what each pass found and can see a target failing to converge, where a dispatched reviewer reads one pass and knows nothing of the one before it. A worker introducing a finding per fix has nothing mechanical stopping it, which is accepted rather than overlooked.
97
97
 
@@ -101,7 +101,7 @@ One session, one target, from the worktree entry to the merge of the branch it o
101
101
 
102
102
  1. Confirm the clone is current. Fetch, then compare against the origin's default branch. Report a checkout that is behind and stop, rather than branching from a stale base.
103
103
  2. Enter a worktree. Invoke `canon:session-worktree chore/agents`, which takes the branch as its tier 0 argument and enters a linked worktree inside this target. Branching in the checkout itself is what this avoids, since the operator may be working in it.
104
- 3. Check what this target holds. Invoke `canon:target-check`, which reports per domain what the target carries against what the toolkit ships and repairs nothing. It runs before any repair so the wave reads one stated set of domains per target rather than whatever each session decided to examine.
104
+ 3. Check what this target holds. Invoke `canon:target-check`, which reports per domain what the target carries against what the toolkit ships and repairs nothing, so the wave reads one stated set of domains per target.
105
105
  4. Diagnose and repair. Invoke `canon:canon-operator`, which reads `canon sync --check . --json` and routes each finding to the command or the skill that owns it. Do not restate that routing here and do not edit a managed file by hand.
106
106
  5. Commit and open the pull request through `canon:git-commit` and `canon:git-pr`, handing each the fixed shape above rather than taking the title the generator derives from the diff.
107
107
  6. Announce as the pull request opens, carrying its URL, its number, and the branch, to whoever dispatched this session, sending it through `canon:session-relay`. That transition is the one moment only this session can observe.
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: context-fold
3
+ description: What the planning-doc reconcile is for, the gaps it closes, and why the diff decides completion alone
4
+ ---
5
+
6
+ # Context fold requirement
7
+
8
+ ## Gap
9
+
10
+ Without this skill, the planning docs describe the scope the session opened with. An outcome the diff shipped stays unchecked, so the board reports finished work as open and the next session re-plans it. A requirement or architecture decision that changed mid-cycle lives only in the conversation and dies with it. Plans for closed tasks accumulate in the live folder, so the folder stops indicating what is in flight.
11
+
12
+ A decision's verification anchor has the same shape of gap in the other direction. The reasoning keeps reading as current while the number it cites moves underneath, and an amendment written without an anchor leaves nothing recording which numbers were checked and which nobody has read since.
13
+
14
+ A handoff file has the same shape of gap as an unmarked outcome. A page a learning workspace produced and an operator already picked a destination for sits in gitignored scratch until something lands it, and the session that produced it is gone by the time a branch exists to carry the write. Left unfolded it reads as promoted while the destination holds nothing.
15
+
16
+ The receipt half of that sweep was missing entirely. A review receipt was deleted per shipped branch and a memory-review receipt was skipped, because the exclusion protecting the checklist and audit prefixes caught a third by accident. Nothing but an operator asking collected it, and a collection that waits on someone remembering to ask is one a folder outgrows, so the skipped population grew per shipped branch and never shrank until it was most of the folder.
17
+
18
+ The trigger side carries a gap of its own. "Sync the docs" names either corpus to the person saying it, so a description leaving its corpus to the opening clause alone competes with its public-facing sibling on nothing the routing field states, and the planning surface the request was about goes untouched.
19
+
20
+ This skill writes canonical docs at the end of a long build and never reviews what it wrote. An appended figure or a branch-narrated re-measurement lands unchecked the same way a session's own edits do, so what the fold produces carries the exact defect the standards it cites already ban.
21
+
22
+ ## Must
23
+
24
+ - Name the context entries and the task board in a trigger phrase rather than in the opening clause alone, so a bare request to sync the docs separates this skill from `docs-sync` on something both descriptions state
25
+ - Take completion from the diff and everything else from the session, since completion is a fact about the repository rather than about the conversation
26
+ - Match an outcome on the behavior it names, never on a filename or a commit subject
27
+ - Leave an outcome unchecked when the diff is ambiguous. An unmarked shipped outcome costs one manual edit and a wrongly marked one hides work that never happened.
28
+ - Write tracked docs at the current worktree root and the task board at the main root, since only the first commits with the branch
29
+ - Count every other citation before archiving a plan, comparing resolved targets rather than raw strings or bare filenames
30
+ - Retarget a closed task at the archived plan, so the reasoning behind finished work stays reachable
31
+ - Write a decision to the domain context entry it constrains unless it fills an architecture slot, since reach admits nearly every decision to an always-loaded file
32
+ - Merge or retire an architecture entry before adding one at the record's stated cap, and name which in the report, so the cap never turns into compressed prose or two decisions packed under one heading
33
+ - Anchor a decision entry this run writes or amends whose reasoning cites a measured number, re-reading the number against the tree before writing the marker
34
+ - Report an anchored decision whose cited path the diff touched, since the number was read before the branch moved what it counted
35
+ - Scan every memory-review receipt rather than the one matching this slug, since the skill that writes them runs after this one in the ship chain and a slug is unique per feature
36
+ - Collect a memory-review receipt whose items are all decided, folding each skip into its memory entry first, since a declined item is recorded nowhere else and a promoted one is already in git
37
+ - Leave a memory-review receipt holding a pending item, and report the count. A branch shipping is not an operator deciding what the receipt proposed.
38
+ - Leave the current branch's review receipt alone, since the chain that wrote it cites it in its own closing line and this skill cannot read whether that citation is still live
39
+ - Land each block of a promotion handoff at the destination its heading names, then delete the file so a later run does not fold it twice
40
+ - Take a promotion destination as already decided, since the operator confirmed it where the page was produced
41
+ - Classify the fold's whole diff baseline through `canon context classify diff`, calling the verb rather than reimplementing its pattern or its prompt in the skill body, since an earlier commit on the branch carries a doc edit the fold is equally responsible for
42
+ - Apply a `REPLACE` or `HISTORY` finding, and a regex-decided `MOVE` finding, against the quote it names, report a model-decided `MOVE` finding naming the surface it belongs on rather than cutting it, or keep a finding with a one-line reason, rather than leaving a finding unanswered
43
+ - Rewrite a restated or superseded statement in place rather than appending the replacement beside it, on every canonical doc type this skill writes
44
+ - Report a refusal or a missing `context classify` subcommand as one line and continue the fold either way, since a check that cannot run is not a reason to leave the fold's own output unshipped
45
+
46
+ ## Must not
47
+
48
+ - Infer a new task from the diff. Only outcomes already on the board get marked.
49
+ - Touch task files the session did not change
50
+ - Widen what a writing step reads when the baseline is unusable. Widening a read is safe and widening a write stubs a surface for every file in the repository.
51
+ - Edit `CLAUDE.md` inline. Every change there goes through a diff-and-approve gate, so this skill only flags.
52
+ - Create a context entry, or move or delete a plan. A plan is settled by the merge, and `canon tasks archive` carries it.
53
+ - Overwrite a file a promotion block routes to. A destination that already holds a page is a merge for a person, and folding over it discards work this skill never read.
54
+ - Write an anchor onto a decision the run did not amend, or refresh one without re-reading the number. A date from a pass that measured nothing is the false confidence the marker exists to prevent.
55
+ - Anchor an entry written before the rule, which dates it by blame rather than by a read
56
+ - Pick or configure a classifier backend. The project setting decides it, and this skill reports the resolved `modelLayer` as returned.
57
+ - Stop the fold on a classify finding, a refusal, or a missing subcommand. All three report and continue.
58
+ - Apply a finding against a quote found more than once or not found at all. Report that it could not be located instead of guessing.
59
+ - Re-run the classifier after applying a finding, which loops it over its own edit
60
+ - Cut a model-decided `MOVE` finding. The model's own prompt defines `MOVE` more broadly than the regex layer does, for correct content sitting on the wrong surface rather than a deletion candidate, so cutting one can discard content that belongs elsewhere rather than removing detail that never belonged at all.
61
+ - Paste a regex-decided `MOVE` finding's content into another canonical doc after cutting it. It never belonged on the wireframe surface at all, so cutting is the whole fix, not a relocation.
62
+ - Scope Step 10 to the files Steps 3 and 7 wrote this run. An earlier commit on the branch carries a doc edit the fold is equally responsible for, and the verb's own extraction already answers whether anything in range qualifies.
63
+
64
+ ## Guards
65
+
66
+ - Neither a `canon/` nor a `.claude/` directory: stop and name the command that sets one up
67
+ - No session divergence and no queued outcome the diff shipped: stop with a pass, since both conditions have to hold
68
+
69
+ ## Out of scope
70
+
71
+ - Creating a task file or moving one off the board, which `task-board` owns
72
+ - Public-facing docs, which `docs-sync` owns, apart from landing a page a promotion handoff already carries a confirmed destination for. This skill reconciles the context entries, the planning records, and the task board, and both descriptions name their corpus in the trigger so a request saying only "sync the docs" lands on one of the pair rather than on either.
73
+ - Deciding where a promoted page belongs, which is settled with the operator by the surface that produced the page
74
+ - Regenerating the task index, owned by a hook
75
+ - Re-measuring an architecture claim to decide whether its number moved. The sweep keys on a cited path entering the diff, so a claim whose number moved with no cited path in the diff goes unflagged.
@@ -0,0 +1,162 @@
1
+ ---
2
+ name: context-fold
3
+ description: Folds a session into the project's context entries, requirements, architecture, and wireframes, marks the outcomes the diff shipped `[x]` on the task board, and archives the plans those tasks cite. Use when asked to "fold the session into context", "update the context entries", "sync the planning records", when design or requirements changed mid-cycle, after a pivot, or before shipping. Do NOT use for `README.md` or `docs/`, which is `docs-sync`, or to create or archive a task file, which is `task-board`.
4
+ ---
5
+
6
+ # Context fold
7
+
8
+ ## Guards
9
+
10
+ - If neither a `canon/` nor a `.claude/` directory exists, stop: `❌ No canon/ or .claude/ directory found. Run canon claude init to set up the workflow.`
11
+
12
+ The skip for a session that changed nothing lives at the end of Step 2, because it needs the diff to decide. It drops the doc rewrite alone. The diff-driven sweeps in Steps 4 and 5 still run.
13
+
14
+ ## Diff baseline
15
+
16
+ Steps 2, 4, 5, and 7 share one diff on the usable path. An unusable baseline splits them, per the rule below. Resolve the base ref once and reuse it:
17
+
18
+ ```bash
19
+ git merge-base HEAD origin/main 2>/dev/null || git merge-base HEAD main 2>/dev/null
20
+ ```
21
+
22
+ Take the union of `git diff --name-only <base> HEAD`, `git diff --name-only HEAD`, and `git ls-files --others --exclude-standard`. Read content with `git diff <base> HEAD` and `git diff HEAD`.
23
+
24
+ Prefer `origin/main` over local `main`. On `main` itself the local ref resolves to HEAD, so every committed change drops out of the set and the skill goes blind to the work it is meant to read.
25
+
26
+ The baseline is unusable when no merge base resolves against either ref, or when the base came from local `main` and equals HEAD. On an unusable baseline, read `${CLAUDE_SKILL_DIR}/references/unusable-baseline.md` before Step 2 for what each step reads instead.
27
+
28
+ ## Step 1: read current docs
29
+
30
+ Read these in parallel from the current worktree root (`pwd`), not the main worktree root. These are tracked files and edits must commit with the branch. A project the surface move has not reached holds each of them under `.claude/` rather than `canon/`, so read and write each at whichever root already carries it. Skip any that exist at neither:
31
+
32
+ - `canon/REQUIREMENTS.md`
33
+ - `canon/ARCHITECTURE.md`
34
+ - `canon/DESIGN.md`
35
+ - `canon/wireframes/index.md` and every surface file it links to, following a grouped surface's own `index.md` and the siblings it lists rather than stopping at the top-level folder
36
+
37
+ Read the task board from the main worktree root instead, resolving that root the way `session-worktree` does. It is gitignored scratch and never commits with the branch:
38
+
39
+ - `.canon/tasks/index.md` first, then the task files this session touched. That narrow read serves the marking step, which is the only step here that opens a task file.
40
+
41
+ ## Step 2: identify what changed
42
+
43
+ Two sources feed this step. The session carries judgments no diff can show. The diff carries facts about the repository the session may never have mentioned.
44
+
45
+ Review the session for decisions that diverged from the original plan:
46
+
47
+ - Requirements added, removed, or changed scope
48
+ - Architecture or technical decisions made or revised
49
+ - Design or UX decisions that differ from DESIGN.md or any wireframe surface file, flat or nested under its own subfolder
50
+ - Tasks blocked or newly identified
51
+
52
+ Then resolve the diff baseline and match it against the board. From `.canon/tasks/index.md` at the main worktree root, pick the task files whose title or description relates to the changed paths and read the ones Step 1 skipped.
53
+
54
+ Path matching only chooses which files to open. Behavior decides each outcome. For each unchecked outcome, decide whether the diff shipped the behavior that outcome names.
55
+
56
+ Completion is the one judgment here that is a fact about the repository rather than a fact about the conversation, so the diff decides it and the session does not. Requirements, architecture, and design stay session-sourced.
57
+
58
+ Keep the match conservative:
59
+
60
+ - Mark only outcomes already written on the board. Never infer a new task from the diff.
61
+ - Match on the behavior an outcome describes, not on filenames or commit subjects. The path match above only narrowed which task files to open.
62
+ - Leave an outcome `[ ]` when the diff is ambiguous. An unmarked shipped outcome costs one manual edit, while a wrongly marked one hides work that never happened.
63
+
64
+ Skip Step 3 when the session shows no divergence **and** the diff matches no queued outcome, reporting `✅ No doc updates needed. Session matched the original plan.` Both conditions have to hold. Shipping a queued task exactly as planned is the ordinary case and it reads as no divergence, so a session-only skip would drop the marking step with it.
65
+
66
+ Then run Steps 4 through 9. Step 3 is the only one this skips, because it is the only one driven by the session rather than by the diff or the board. A project with an empty task board making a mechanical change satisfies both conditions above, and stopping here would put an uncovered surface out of reach in every such project.
67
+
68
+ This changes which steps the skill reaches and never widens what any of them reads. Steps 4, 5, and 7 still take the same scoped set the Diff baseline section defines.
69
+
70
+ ## Step 3: update
71
+
72
+ For each doc with relevant changes, apply updates following these rules. Read a standard this skill names, here or in a later step, from `${CLAUDE_SKILL_DIR}/../../standards/` when the project does not have it.
73
+
74
+ **`.canon/tasks/`**
75
+
76
+ - Mark completed outcomes `[x]` in the task's own file through `canon tasks outcome <stem> --close <n> --json`, repeating `--close` for each. Positions count every outcome checkbox in file order from 1, which the read above already gives. Do not move or archive the file.
77
+ - Write a newly identified task as its own file, following `${CLAUDE_SKILL_DIR}/../../standards/tasks.md` for the filename and frontmatter.
78
+ - Do not touch task files this session did not change.
79
+ - Never hand-edit `.canon/tasks/index.md`. A hook regenerates it.
80
+
81
+ The verb resolves the board at the main worktree root in-process, which is the route `session-worktree` states for an edit inside an existing main-root file.
82
+
83
+ Read `ok` and `reason` out of that record rather than the exit. An operator's shell profile may wrap `canon` in a function that runs the binary and then a second command and takes the second status, which flattens every non-zero exit to zero. A refusal arriving as success leaves the outcome unmarked while the chain moves on, so the board reports shipped work as open and the next session re-plans it.
84
+
85
+ **REQUIREMENTS.md, ARCHITECTURE.md, DESIGN.md, a wireframe surface file (flat or nested)**
86
+
87
+ - Update only the sections affected by session decisions.
88
+ - Do not rewrite sections unrelated to what changed.
89
+ - Rewrite a restated or superseded statement in place rather than appending the replacement beside it. State the fact that stands and keep the earlier reasoning only where it is the alternative that lost, per `${CLAUDE_SKILL_DIR}/../../standards/context.md` and `${CLAUDE_SKILL_DIR}/../../standards/architecture.md`.
90
+ - Follow `${CLAUDE_SKILL_DIR}/../../standards/markdown.md` and the `write-human` skill for all edits.
91
+ - Write a session decision into the `canon/context/` entry for the domain it constrains, under that entry's `## Decisions`, by default. Touch `canon/ARCHITECTURE.md` only for a decision that fills one of the slots `${CLAUDE_SKILL_DIR}/../../standards/architecture.md` names, however many domains its reasoning reaches.
92
+ - Read the entry cap the record states before adding a decision to it. At the cap, merge two decisions or retire one to the domain entry it constrains, and name which in the report. Never compress a decision's prose to fit, and never pack two decisions under one heading.
93
+ - Close a decision entry in `canon/ARCHITECTURE.md` with its verification anchor whenever this run writes that entry or amends its reasoning and that reasoning cites a measured number. Re-read the number against the tree first, since the marker records the read rather than the edit. `${CLAUDE_SKILL_DIR}/../../standards/architecture.md` fixes the sentence.
94
+ - Leave every decision entry this run did not write alone, anchored or not. The rule is scoped forward, so an entry written before it is dated by blame rather than by a read. Step 5 reports a stale anchor and no step writes one on an entry it did not amend.
95
+
96
+ Write each updated file immediately. Claude Code's tool permission dialog is the confirmation gate. Do not wait for user input.
97
+
98
+ ## Step 4: wireframe coverage sweep
99
+
100
+ Skip this step silently when `canon/wireframes/` does not exist or has no surface files. When the baseline is unusable, scope it to the working tree and untracked files, and skip it only when that set is empty, reporting `⚠ No diff to scope against. Skipped the wireframe sweep.`
101
+
102
+ Reuse the diff from the baseline above and filter for UI-affecting paths. UI-affecting paths are framework-dependent. Default heuristic: any file under a `components/`, `features/`, `pages/`, `app/`, `routes/`, or `screens/` folder, plus any `*.tsx`, `*.jsx`, `*.vue`, or `*.svelte` file anywhere in the diff.
103
+
104
+ Skip silently when the filter leaves nothing, which is every branch touching no UI. Otherwise read `${CLAUDE_SKILL_DIR}/references/wireframe-sweep.md` for the slug derivation, the two findings it reports, the stub it writes, and the output lines.
105
+
106
+ ## Step 5: architecture anchor sweep
107
+
108
+ Skip this step silently when `canon/ARCHITECTURE.md` does not exist at `pwd` or carries no decision entry with a verification anchor. A record written before the rule holds none, and a project is not told on every ship that nothing has been checked when the standard calls that state correct. When the baseline is unusable, scope the sweep to the working tree and untracked files, and skip it only when that set is empty, reporting `⚠ No diff to scope against. Skipped the anchor sweep.`
109
+
110
+ This step reports and never writes. The record carries no frontmatter, so an anchor is a sentence sharing a paragraph with the claim it marks, and a pass editing prose to mark prose has no structural guard against editing the claim beside it. A surface whose marker sits in YAML gets that separation for free and this one cannot.
111
+
112
+ Step 3 holds the writer, and the two never meet. Anchoring fires when this run amends a decision, and this sweep fires when the diff moves a path under one, so a single step covering both would gate the anchor obligation on a signal that has nothing to do with it.
113
+
114
+ Follow `${CLAUDE_SKILL_DIR}/../../standards/architecture.md` for the anchor sentence this step matches on.
115
+
116
+ Past the skip above, read `${CLAUDE_SKILL_DIR}/references/anchor-sweep.md` for how an entry's cited paths are collected, the finding the diff fires, and the report line.
117
+
118
+ ## Step 6: flag CLAUDE.md drift
119
+
120
+ If this session established or changed a cross-cutting behavior rule that belongs in root `CLAUDE.md` (a new always-on convention, a revised workflow rule), surface a one-line warning:
121
+
122
+ `⚠ CLAUDE.md may need a rule from this session. Review and edit by hand.`
123
+
124
+ Do not edit `CLAUDE.md` inline. Every `CLAUDE.md` change goes through the show-diff-and-approve gate, so this step only flags. Skip silently when the session made no cross-cutting behavior decision.
125
+
126
+ ## Step 7: refresh context entries
127
+
128
+ Read `canon/context/index.md` at `pwd` to see which domain entries exist. Skip this step silently if the directory does not exist or has no entries.
129
+
130
+ Otherwise read `${CLAUDE_SKILL_DIR}/references/context-refresh.md` for its two sources, the routed facts and the diff, the widening a removed capability takes, when a new entry is created, and the output lines.
131
+
132
+ ## Step 8: fold promoted pages
133
+
134
+ Skip this step silently when no teach promotion handoff exists at `.canon/tmp/handoff/teach-promotion/<slug>.md` at the main worktree root, deriving `<slug>` per `${CLAUDE_SKILL_DIR}/../../standards/slug.md` with the `latest` fallback. Otherwise read `${CLAUDE_SKILL_DIR}/references/promoted-pages.md` for how each block lands, the handoff delete, and the output lines.
135
+
136
+ ## Step 9: sweep consumed receipts
137
+
138
+ Read `${CLAUDE_SKILL_DIR}/references/receipt-sweep.md` for which review and memory receipts this session sweeps, which it keeps, and the output lines. Skip this step silently when nothing qualifies.
139
+
140
+ ## Step 10: classify the fold's diff baseline
141
+
142
+ Skip this step silently only when the Diff baseline section could not resolve a base ref at all, reporting `⚠ No diff to scope against. Skipped the classify check.` The verb needs a resolvable ref to run against, which is the one condition it cannot answer for itself.
143
+
144
+ Otherwise read `${CLAUDE_SKILL_DIR}/references/classify.md` for the invocation, its scope, the record fields, applying a finding, the one-line keep reason, the unreachable and missing-subcommand lines, and the report shape. `${CLAUDE_SKILL_DIR}` names this skill's own directory, resolved once when the skill loaded, several steps before this one. Read the reference by that resolved path rather than guessing a `.claude/skills/context-fold/references/classify.md` path from the toolkit's install-time layout, which is a different root than the one this skill's own files live under. The invocation is `canon context classify diff --base <base> --json`, and it runs whether or not that reference resolves. Findings never stop the fold.
145
+
146
+ ## After completion
147
+
148
+ Output one line per file updated:
149
+
150
+ `✅ Updated: <path written>`
151
+
152
+ When Step 3 met the architecture record's cap, add one line naming what it did there:
153
+
154
+ `↪ Architecture at cap: merged <heading> into <heading>` or `↪ Architecture at cap: retired <heading> to <context entry>`
155
+
156
+ Step 10 adds its own lines when it applied or reported a finding, in the exact shape `${CLAUDE_SKILL_DIR}/references/classify.md` gives them under its own Report section. Do not shorten or paraphrase those lines here or in the reply, since the quote and the reason are what a reader checks the finding against.
157
+
158
+ If no files were updated and nothing was swept, output:
159
+
160
+ `✅ No changes needed.`
161
+
162
+ Suppress that line when Step 2 already reported no doc updates. It closes the run on its own, and emitting both leaves a quiet session reporting success twice for one outcome.
@@ -5,7 +5,7 @@ description: How an anchored decision's cited paths are collected, the finding t
5
5
 
6
6
  # Architecture anchor staleness sweep
7
7
 
8
- Mechanics for Step 5 of `docs-fold`. The body owns the skip conditions, the report-only constraint, and the standard citation, and this file owns what the sweep does once the diff touches a path an anchored decision cites.
8
+ Mechanics for Step 5 of `context-fold`. The body owns the skip conditions, the report-only constraint, and the standard citation, and this file owns what the sweep does once the diff touches a path an anchored decision cites.
9
9
 
10
10
  ## Anchored entries
11
11
 
@@ -5,7 +5,7 @@ description: The classify diff invocation, the record fields to read, applying a
5
5
 
6
6
  # Classify the fold's diff baseline
7
7
 
8
- Mechanics for Step 10 of `docs-fold`. The body owns the skip condition and the shared baseline, and this file owns the invocation, what the record carries, and what applying a finding does.
8
+ Mechanics for Step 10 of `context-fold`. The body owns the skip condition and the shared baseline, and this file owns the invocation, what the record carries, and what applying a finding does.
9
9
 
10
10
  ## Invocation
11
11
 
@@ -15,7 +15,9 @@ Call the verb rather than reimplementing its pattern or prompt in this skill:
15
15
  canon context classify diff --base <base> --json
16
16
  ```
17
17
 
18
- Reuse the base the Diff baseline section already resolved. Never pick or configure a backend here. The project setting decides it, and this step reports `modelLayer` as the record returns it.
18
+ Never substitute a different verb for it, such as `canon autoship classify` (a different check, over a different scope) or `canon docs <name>` (a documentation lookup, not a classification).
19
+
20
+ Reuse the base the Diff baseline section already resolved for Steps 2, 4, 5, and 7 rather than resolving a second time. Never pick or configure a backend here. The project setting decides it, and this step reports `modelLayer` as the record returns it.
19
21
 
20
22
  ## Reading the record
21
23
 
@@ -0,0 +1,48 @@
1
+ ---
2
+ title: Refresh context entries
3
+ description: How context-fold Step 7 folds routed facts and diff-scoped rewrites into canon/context entries, when it creates an entry, and the lines it reports
4
+ ---
5
+
6
+ # Refresh context entries
7
+
8
+ Step 7 of `context-fold`, reached in order once `canon/context/index.md` lists at least one entry.
9
+
10
+ Two sources feed this step, the same split Step 2 runs on. The diff carries what the repository changed. The routed facts carry what the session learned, which a diff cannot show.
11
+
12
+ **Routed facts.** Derive `<slug>` per `${CLAUDE_SKILL_DIR}/../../standards/slug.md`, falling back to `latest` on an empty result, and read `.canon/tmp/handoff/memory-routing/<slug>.md` at the main worktree root. `memory-capture` writes it, one H2 per target entry naming the path, with the fact underneath. Fold each fact into the entry its heading names, which for a nested `canon/context/<domain>/index.md` heading is the sibling file the fact belongs under rather than the generated index itself. Then delete the handoff file so a later run does not fold it twice.
13
+
14
+ This half is not diff-scoped and must not be. A gotcha a session hit while working is exactly the fact the diff never shows, and scoping it to changed files would drop the entries worth keeping. The handoff is a named input rather than a scan, so the reach stays bounded to what capture decided.
15
+
16
+ Skip this half silently when the file is absent, which is every run where nothing routed.
17
+
18
+ **The diff.** When the baseline is unusable, scope this half to the working tree and untracked files, and skip it only when that set is empty, reporting `⚠ No diff to scope against. Skipped the context refresh.` The routed half still runs, since it reads a file rather than a diff.
19
+
20
+ Reuse the diff from the baseline above, names and content both. For each domain listed in `canon/context/index.md`, read its own entry: a flat `canon/context/<domain>.md`, or, for a domain split into a folder, its `canon/context/<domain>/index.md` and every sibling file that index links. Follow the index rather than globbing the folder, since a folder can hold a file the index does not list yet.
21
+
22
+ - Map the entry's section headings, whether they sit in one flat file or spread across a nested domain's sibling files, to the changed files. An entry is relevant when its prose references files, modules, or decisions touched by the diff.
23
+ - For each relevant entry, rewrite only the sections affected by the diff. Same pattern as `docs-sync`. Do not touch unrelated sections. Never rewrite a split domain's own `index.md` directly, since a regen overwrites it the same way it overwrites the top-level catalog. Rewrite the sibling file the affected section actually lives in instead.
24
+ - Rewrite a restated or superseded statement in place rather than appending beside it, the same rule Step 3 applies to the other four canonical doc types.
25
+ - Write a reference to another entry as the path that entry sits at, rather than as its bare filename. `${CLAUDE_SKILL_DIR}/../../standards/context.md` states the form, and a bare name strands the reference once a domain splits into subfolders.
26
+
27
+ ## When the diff removes a capability
28
+
29
+ The mapping above is scoped by file, and a removal invalidates claims that mapping cannot reach. Run this only when the diff deletes a command, a flag, a constant, or a folder. Ordinary feature work takes the narrow rule alone, since widening it on every ship churns prose nothing put in doubt.
30
+
31
+ Grep the tree for the name that went, rather than for the paths the diff carries. A capability removed by name is cited by that name, which reaches a file the diff never touched.
32
+
33
+ - An entry this run already rewrote is read whole before it is left. A refresh that updates the top and leaves a contradicting claim below reads worse than an untouched entry, because the current opening lends authority to the stale remainder. This is the one case that overrides "do not touch unrelated sections", and it overrides it only inside an entry the run edited anyway.
34
+ - A claim comparing two surfaces is checked even where its file is outside the diff. Such a claim holds only while both surfaces do, so moving one inverts it with nobody editing the file it sits in.
35
+
36
+ Report each hit as an ordinary rewrite.
37
+
38
+ Create a new entry only for a domain `canon/context/index.md` already lists but carries no file for, following `${CLAUDE_SKILL_DIR}/../../standards/context.md` for its shape. Before treating a domain as carrying no file, confirm it holds no entry under either spelling, `canon/context/<domain>.md` or `canon/context/<domain>/index.md`, since a domain already split into a folder still passes a check that only looked for the flat file. A row in the catalog is the deliberate decision, taken by whoever added it. This step only fills in what that decision left open, and only until the next `canon indexes regen` pass, which rebuilds the catalog from each entry's own frontmatter plus every sibling's and drops a row whose file still does not exist. Create the file before that regen runs, or the row this bar exists to fill in is gone. A domain the catalog does not list at all is a different case: report it and stop, rather than creating an entry or a catalog row for it.
39
+
40
+ Write each updated entry immediately. Output one line per file, naming the path this run actually wrote rather than always the flat template:
41
+
42
+ `✅ Context: canon/context/<domain>.md` for a flat entry, or `✅ Context: canon/context/<domain>/<sub-area>.md` for the sibling file a nested edit landed in
43
+
44
+ Add a line naming the handoff when one was consumed:
45
+
46
+ `🧹 Folded: .canon/tmp/handoff/memory-routing/<slug>.md`
47
+
48
+ The base lint-staged config runs `canon indexes regen` on every committed `*.md`, so `canon/context/index.md` refreshes automatically on commit. No manual step needed.