@morning-start/dsh-code-toolkit 0.28.0 → 0.29.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.
@@ -1,177 +1,149 @@
1
1
  # Caption loop
2
2
 
3
- You are running one long task with an explicit loop. The task is hard but
4
- already defined; what usually goes wrong is not the design — it is losing the
5
- thread: doing work you cannot prove, repeating a dead end you already hit, or
6
- reporting done when part of it was never checked. The loop is the countermeasure.
3
+ You are running one long task until it is actually done. You are not handed a plan: the
4
+ person gives you an **intent** — "make the export work" — and you derive the goal, the
5
+ acceptance criteria and the task list from it. Then you work the list one item per
6
+ iteration, and you change the list when the repository contradicts it.
7
+
8
+ That is a loop over a list you own. What goes wrong is not the design — it is losing the
9
+ thread: working without a proof, repeating a dead end, ticking an item that was never
10
+ true, or reporting done while items remain open.
7
11
 
8
12
  ## The loop
9
13
 
10
- Repeat until the acceptance criteria hold. Do not treat these as phases that run
11
- once; every iteration goes through all of them.
12
-
13
- Before the first iteration, decide which flow this is — **changing code** or
14
- **changing documentation** — and write it in the ledger head. Both flows share
15
- one spine: requirement → investigate → propose → **the person approves** →
16
- execute → summarize. Code adds a test gate and a confirmation step before the
17
- docs are updated. `references/flows.md` has both, step by step.
18
-
19
- The approval gate is not optional. Do not start executing a plan the person has
20
- not approved; a plan nobody read is not an approval.
21
-
22
- 1. **Read the ledger first.** The ledger is the only memory that survives
23
- compaction. If it exists, read the last entry before anything else, and never
24
- re-derive what it already settled.
25
- 2. **Observe the real state.** Run the check that would prove the current claim,
26
- or read the file you are about to change. Work from the repository, not from
27
- your memory of the conversation.
28
- 3. **Choose one step.** The smallest action that changes what you know or what
29
- the code does. One change per iteration: if a step needs two unrelated edits,
30
- it is two steps.
31
- 4. **Act.** Read before you edit. Make the anchor unique before you replace it —
32
- a loose anchor silently deletes the wrong block. After writing, read the
33
- changed region back.
34
- 5. **Verify.** Run the gate. The gate is a command whose exit status decides, not
35
- your opinion. A red gate is data, not failure: diagnose, adjust, and run the
36
- next iteration.
37
- 6. **Prove a new guard.** When you add a test, a check, or a guard, show it can
38
- fail: break the thing it protects, watch it go red, restore it, watch it go
39
- green. A guard you never saw fail is decoration.
40
- 7. **Record one caption entry, then commit.** Append to the ledger: what you
41
- saw, what you decided, what you did, the command and its result, and the
42
- outcome. Commit the batch while the gate is green.
43
- 8. **Re-plan.** Update what is settled, what is still open, and the next step.
44
- If a step changed the shape of the task, say so instead of pressing on.
14
+ Six stages, in this order. Each has a refusal: what to do instead of pushing through.
15
+
16
+ 1. **方案 — the approach.** What changes, where, why this way, what you will not do. Not a
17
+ task list yet. Write it so someone else could execute it without you: it goes into the
18
+ ledger head, and a proposal only you can read is not one. If the intent is not clear
19
+ enough to propose, stop: ask the two or three questions that would settle it, or name
20
+ the command that answers it first — `/code-design` when the need is still a need,
21
+ `/code-audit` when the question is what exists today — and say which approach you would
22
+ take and why you cannot start. **Never write a ledger for a task you cannot state.**
23
+
24
+ **The approval gate is not optional.** The person approves the approach, the criteria
25
+ and the tasks together — a plan nobody read is not an approval, and a plan you keep in
26
+ your head is not a plan. If it admits two materially different readings, ask before
27
+ writing it; that one question is worth interrupting for.
28
+
29
+ 2. **The goal.** One objective sentence, plus the criteria that prove it. When the person
30
+ asked for the work to run to completion, `create_goal` with that objective and a line
31
+ saying which ledger carries the tasks; when they asked to stop for them each turn, do
32
+ not open one.
33
+
34
+ 3. **Split it into small tasks.** Ordered outcomes, not activities — each provable on its
35
+ own, each naming its check. An item that needs two gates is two items. This is the
36
+ ledger's `## Plan`; `todo_write` mirrors it for the person watching.
37
+
38
+ 4. **Advance one item at a time.** Take the first unblocked item, not the most interesting
39
+ one. **Read the ledger first** — head, plan, last entry; it is the only memory that
40
+ survives compaction. Observe the real state, act (unique anchor, read the region back),
41
+ then **Verify**: run the item's gate, exit status decides. Prove a new guard by breaking
42
+ what it protects. **Record one caption entry** with saw, decided, did, evidence and
43
+ outcome, tick the item with that entry number, and commit while the gate is green.
44
+
45
+ 5. **Update the tasks as you learn.** Tick, rewrite `todo_write` from the plan, and edit
46
+ the plan when the evidence contradicted it — add, split, drop, reorder, naming the entry
47
+ that caused it. A plan edited without a reason is drift; a plan never edited means the
48
+ investigation found nothing.
49
+
50
+ 6. **Until the goal is met.** The run ends when the plan has no open items **and** every
51
+ criterion holds — not when the first plan is exhausted. Then `update_goal complete`,
52
+ reading it with `get_goal` first because the update needs its id and revision. When it
53
+ stalls, `blocked` with the concrete condition; being unsure is not blocked.
54
+
55
+ Before stage 1, decide the flow — **changing code** or **changing documentation** — and
56
+ write it in the ledger head. Both share the spine requirement → investigate → propose →
57
+ **the person approves** → execute → summarize; `references/flows.md` has each step.
45
58
 
46
59
  ## Dispatch
47
60
 
48
- Dispatch only when the work splits into slices that cannot collide. There are two
49
- lanes, and they have different rules:
50
-
51
- - **Analysis is read-only**, so it may fan out: one agent per area, each
52
- returning findings with `file:line` and the command that produced them. No
53
- writes, no conflicts; you merge.
54
- - **Build writes**, so it needs exclusive ownership: each agent owns a disjoint
55
- set of paths. Shared files — barrels, indexes, configs, lockfiles, shared
56
- tests — belong to exactly one owner, normally you.
61
+ Dispatch only when the work splits into slices that cannot collide.
57
62
 
58
- **How to dispatch.** The plugin gives you two ways, and only two:
63
+ - **Analysis is read-only**, so it may fan out: one agent per area, findings with
64
+ `file:line` and the command that produced them. No writes, no conflicts.
65
+ - **Build writes**, so each agent owns a **disjoint** set of paths. Shared files —
66
+ barrels, indexes, configs, lockfiles, shared tests — belong to **exactly one owner**,
67
+ normally you. **Never run two writers on the same path**, and never split one coupled
68
+ change across two agents.
59
69
 
60
- - `subagent` (or `subagent_fork` when the child needs this conversation) for a
61
- slice that is analysis, or a build slice whose paths no one else touches. Start
62
- independent slices in one message so they run together.
63
- - `/code-review sub`, `/code-simplify sub`, `/code-scrub sub` when the slice is
64
- exactly one of those checks. Do not hand-roll a review brief and then also run
65
- `/code-review sub` on the same paths — that is two writers of the same report.
70
+ Two mechanisms only: `subagent` / `subagent_fork` for an analysis slice or a build slice
71
+ nobody else touches; `/code-review sub`, `/code-simplify sub`, `/code-scrub sub` when the
72
+ slice is exactly that check. The child does not see this conversation — everything it
73
+ needs goes in the brief. Details: `references/dispatch.md`.
66
74
 
67
- The child does not see this conversation. Everything it needs goes in the brief.
75
+ ## Creating experts mid-run
68
76
 
69
- **An expert is a paragraph, not a file.** When a slice needs a specialist, write
70
- the specialism into the brief: who it is and what bar it holds, what it looks at,
71
- what counts as a finding, what does not, and the output shape. A brief that says
72
- "you are an expert reviewer" has said nothing; one that names the threshold and
73
- the false positives has. Read `references/experts.md` before writing one.
77
+ An expert is a paragraph, not a file: identity and bar, what it looks at, what counts as
78
+ a finding, what is not, output shape. Five steps:
74
79
 
75
- ## Creating experts mid-run
80
+ 1. **Write the brief first, in the ledger** — the question, the bar, what "done" is.
81
+ 2. **Decide the lane** — analysis (read-only, may fan out) or build (exclusive paths).
82
+ 3. **Dispatch, then keep working** — an expert is not a blocking call.
83
+ 4. **Merge against the brief** — accept only what answers it.
84
+ 5. **Record it** — what the expert was, what came back, what you did with it.
76
85
 
77
- You may create an expert at any point in the loop — not only at the start. The
78
- trigger is a step that needs knowledge you do not have and cannot cheaply get:
79
- an unfamiliar subsystem, a domain rule (a schema, a protocol, a regulation), or
80
- an area wide enough that reading it yourself would cost more than briefing
81
- someone.
82
-
83
- Creating one is a step like any other, so it goes through the loop:
84
-
85
- 1. **Write the brief first, in the ledger.** Identity and bar, inputs, what
86
- counts, what does not, output shape, and the paths it may read or write. A
87
- brief you would not accept from a colleague is not ready.
88
- 2. **Decide the lane.** Analysis experts are read-only and may run in parallel.
89
- Build experts write, so each needs a disjoint path set and the shared files
90
- stay with you.
91
- 3. **Dispatch, then keep working.** Do not sit idle waiting for a read-only
92
- expert; do the next independent step. For a build expert, wait — two writers
93
- on one tree is the collision this whole section exists to prevent.
94
- 4. **Merge against the brief.** Read the result as a claim, not a fact: check
95
- the evidence it cites, and run the whole gate yourself afterwards. A green
96
- per-expert gate does not mean the merged tree is green.
97
- 5. **Record it.** One ledger entry per expert: name, lane, paths, gate, merged
98
- or rejected, and why. If an expert's findings keep getting rejected, the
99
- brief was wrong — fix the brief, not the child.
100
-
101
- **An expert is not a second opinion on your own work.** Do not dispatch a review
102
- of code you just wrote to an expert and treat its silence as proof; it did not
103
- see your reasoning, and it will not see what you did not write down.
104
-
105
- **Do not create an expert to avoid a decision.** If the next step is small, or
106
- you already know what to do, doing it is cheaper than briefing someone. Dispatch
107
- is for width and for knowledge, not for delegating judgement.
108
-
109
- A dispatch brief states the task, the exact paths the agent may read and write,
110
- what it must not touch, the gate it must run, and the output shape. An agent that
111
- needs a file outside its scope stops and reports instead of editing it.
112
-
113
- Never run two writers on the same path, and never dispatch one coupled change to
114
- two agents. After merging, run the whole gate yourself: a green per-agent gate
115
- does not mean the merged tree is green. Record each dispatch in the ledger —
116
- who, which lane, which paths, the gate, and whether it was merged.
86
+ Do not create an expert to avoid a decision, and not as a second opinion on your own
87
+ code. Method and worked briefs: `references/experts.md`.
117
88
 
118
89
  ## Rules that make the loop honest
119
90
 
120
- - **Never claim without evidence.** "Tests pass" is a command and its output,
121
- not a sentence.
122
- - **Keep the unverified list.** Anything you did not run, did not see, or could
123
- not reproduce goes there, and it stays in the final report.
124
- - **Dead ends are first-class.** Record the attempt, the command, and why it
125
- failed, so the next iteration does not repeat it.
126
- - **One gate per iteration.** Do not batch five changes and then test; a red
127
- result then tells you nothing.
128
- - **A green gate is not a working feature.** When the change is something a person
129
- uses — a command, a screen, a flow — one iteration must reach it the way they do:
130
- the real entry point, real data, and then look at what happened. A passing unit
131
- test says the unit is right; it does not say the capability exists. Record the
132
- click, the input, and the state afterwards the same way you record a command.
133
- - **Assume nothing about the host.** A statement about the host or a third party is
134
- a claim like any other. Read the installed version, or write the smallest probe
135
- that prints the answer. "The docs say it supports it" is a lead, not evidence; until
136
- the probe runs, the assumption goes in the unverified list and stays there.
137
- - **Stop on criteria, not on the list.** The task ends when the acceptance
138
- criteria hold, not when the to-do list is empty.
139
- - **Ask only at real forks.** Changing scope, an irreversible action, or a cost
140
- the user did not authorize — stop and ask. Everything else: continue.
91
+ - **No evidence, no claim.** "Done" is a command and its output.
92
+ - **Dead ends are first-class.** Record the command, the output, and why it failed; an
93
+ unrecorded one costs the next iteration the same discovery.
94
+ - **Stop on outcomes, not on activity.** The plan has no open items **and** the criteria
95
+ hold. A ticked item is not proof; the gate is.
96
+ - **One gate per iteration.** Do not batch five changes and then test.
97
+ - **A green gate is not a working feature.** When the change touches an entry point, one
98
+ iteration must take the real entry point the way a person does, with real data. Record
99
+ the click, the input, and the state afterwards.
100
+ - **Assume nothing about the host.** Read the installed version, or write the smallest
101
+ probe that prints the answer. "The docs say" is a lead, not evidence.
102
+ - **A rejection is information.** Go back to investigation with the objection; a second
103
+ rejection means the requirement is wrong — stop and ask.
104
+ - **Stop when the loop stops paying.** Two iterations with no new fact mean stop and hand
105
+ back what is blocked. A recorded "stuck here" beats a third attempt.
106
+ - **Ask only at real forks** — scope change, irreversible action, unauthorized cost.
107
+ Everything else: continue. Whatever is not verified stays in the unverified list.
141
108
 
142
109
  ## The ledger
143
110
 
144
- Write the ledger to `docs/caption/<slug>.md`, creating the directory if needed.
145
- Keep the head of the file as the contract: the task in one sentence, the
146
- acceptance criteria, and the gate command. Then one entry per iteration:
111
+ Write it to `docs/caption/<slug>.md`, creating the directory if needed. Three parts:
112
+
113
+ **Head** — `# Caption: <title>`, then `- Task`, `- Criteria`, `- Gate`, `- Flow`,
114
+ `- Approved`. First values win; a closing entry may repeat `- Gate:`.
115
+
116
+ **Plan** — the open work, one line per item with the check that proves it: `[ ]` open,
117
+ `[x]` done, `[~]` blocked, `[-]` dropped. **Edit it in place**; never append a second
118
+ plan — the plan is current state, the entries are history. Tick with the entry number.
119
+
120
+ `todo_write` mirrors that plan for the person watching: rewrite the whole list from the
121
+ plan each iteration, in order, the current item `in_progress`. **The ledger wins** every
122
+ disagreement — the todo list dies with the session, the ledger does not.
123
+
124
+ **Entries** — appended, one per iteration: `## 3. <title>`, then `- Saw`, `- Decided`,
125
+ `- Did`, `- Evidence`, `- Outcome: done | dead end | unverified`.
147
126
 
148
- ```markdown
149
- ## 3. <short title>
150
- - Saw: <the state that made this the next step>
151
- - Decided: <why this step, and what it would prove>
152
- - Did: <files touched, commands run>
153
- - Evidence: `<command>` → <result, exit status>
154
- - Outcome: done | dead end | unverified
155
- ```
127
+ Shape and ordering rules: `references/loop.md`.
156
128
 
157
129
  ## When the task ends
158
130
 
159
- Report what changed, the gate output, each criterion and whether it holds, the
160
- dead ends, and the unverified list. Do not summarize the loop away — the user
161
- needs to see what was not checked.
131
+ Report what changed, the gate output, each criterion, the dead ends, the unverified list,
132
+ and how the plan ended. Do not summarize the loop away. `references/loop.md` has the
133
+ closing shape.
162
134
 
163
135
  ## Reference files
164
136
 
165
137
  | File | Read it when |
166
138
  | --- | --- |
167
- | `references/loop.md` | A step stalls, the gate stays red, or you need to split a step |
168
- | `references/flows.md` | Before the first step: is this a code change or a doc change, and what does each step owe the person |
169
- | `references/evidence.md` | Choosing a gate, proving a guard, or recording a dead end |
170
- | `references/dispatch.md` | Before handing work to another agent, or when deciding whether to parallelize |
171
- | `references/experts.md` | You are about to write an expert into a brief, and want the shape of one that works |
172
- | `examples/loop.md` | You want the shape of a healthy run before writing entries |
173
- | `examples/dispatch.md` | You are about to fan out and want the shape of a safe split |
174
- | `examples/theater.md` | The run feels busy but nothing is being proven |
139
+ | `references/loop.md` | a step stalls, the gate stays red, or you need to split an item |
140
+ | `references/flows.md` | before the first item: code change or doc change, and what each owes |
141
+ | `references/evidence.md` | choosing a gate, proving a guard, or recording a dead end |
142
+ | `references/dispatch.md` | before handing work to another agent, or deciding to parallelize |
143
+ | `references/experts.md` | you are about to write an expert brief |
144
+ | `examples/loop.md` | the shape of a healthy run before writing entries |
145
+ | `examples/dispatch.md` | the shape of a safe split |
146
+ | `examples/theater.md` | the run feels busy but nothing is being proven |
175
147
 
176
148
  If a reference path is unreadable, continue from this file — the core instructions are
177
- self-sufficient.
149
+ self-sufficient.
@@ -10,8 +10,20 @@ Ledger head:
10
10
  - Task: make `sum()` return 0 for an empty list without changing existing results.
11
11
  - Criteria: full suite green; `sum([])` is `0`; `sum([1,'2'])` still throws.
12
12
  - Gate: `node --test`
13
+ - Flow: A (code)
14
+ - Approved: plan below, 2026-11-29
15
+
16
+ ## Plan
17
+ - [ ] 1. Reproduce the failure — gate: `node --test` names `sum([])`
18
+ - [ ] 2. Pin the current contract — gate: the coercion test passes on today's code
19
+ - [ ] 3. Fix the empty case — gate: `sum([])` is 0, everything else still passes
20
+ - [ ] 4. Prove the guard — gate: breaking coercion turns entry 3's test red
13
21
  ```
14
22
 
23
+ The plan was edited once, after entry 2: item 2's original wording ("add a throw for
24
+ non-numeric strings") was wrong, because the current contract coerces. Splitting and
25
+ rewording it there is the loop working, not the plan failing.
26
+
15
27
  Entries:
16
28
 
17
29
  ```markdown
@@ -24,8 +24,16 @@ requirement → investigate → propose → human approves → execute (refining
24
24
  |---|---|---|
25
25
  | **1. Requirement** | The need in one sentence, plus what "done" would look like | You can say it back without adding anything |
26
26
  | **2. Investigate** | The real state: files, call sites, tests, the current gate, the constraints in AGENTS.md | You can name the files you will touch and the command that proves the change |
27
- | **3. Propose** | A plan: the change, the files, the gate, the risks, what you will not do | The person approves, amends, or rejects |
28
- | **4. Execute** | One step per iteration; refine the plan when a step teaches you something | The gate is green and every criterion holds |
27
+ | **3. Propose** | The plan block — ordered outcomes, each with its gate — plus the files, the risks, what you will not do | The person approves, amends, or rejects |
28
+
29
+ A rejection sends you back to **2. Investigate**, with the objection in hand — not to
30
+ a redraft of the same plan. A second rejection means the requirement is wrong: say so
31
+ and ask (see `references/loop.md`).
32
+
33
+ After the approval, two steps come before execution: set the **goal** (stage 2 — only when
34
+ the person asked for the work to finish without them), then turn the approved proposal into
35
+ the **plan block** (stage 3), each item with its check. Execution takes one item at a time.
36
+ | **4. Execute** | One plan item per iteration; tick it with its entry number, and edit the plan when the evidence contradicts it | The plan has no open items and the gate is green |
29
37
  | **5. Test** | The gate command and its output; a guard proven red then green | The evidence is in the ledger, not in your memory |
30
38
  | **6. Human confirms** | The report: what changed, what was verified, what was not | The person says it is right |
31
39
  | **7. Update the docs** | README / DETAIL / CHANGELOG / AGENTS, whichever the change made stale | The docs describe the code as it now is |
@@ -1,6 +1,6 @@
1
1
  # The loop in depth
2
2
 
3
- ## Why a loop and not a plan
3
+ ## A plan is a hypothesis
4
4
 
5
5
  A plan is a hypothesis about how the work divides. It is written before the code
6
6
  answers back. The loop is how the hypothesis gets corrected: every iteration
@@ -12,6 +12,77 @@ executed faithfully while the third batch quietly changed the shape of the
12
12
  problem, and batches four through seven build on an assumption that stopped
13
13
  being true.
14
14
 
15
+ That is why the plan lives **in the ledger**, as a block you edit, and not in your
16
+ head. A plan in the conversation is lost at the first compaction; a plan you only
17
+ narrate cannot be diffed between iterations.
18
+
19
+ ## The plan block
20
+
21
+ ```markdown
22
+ ## Plan
23
+ - [ ] 1. Reproduce the failing case — gate: `node --test` names `sum([])`
24
+ - [ ] 2. Pin the current contract — gate: the coercion test passes today
25
+ - [ ] 3. Fix the empty case — gate: `sum([])` is 0, everything else still passes
26
+ ```
27
+
28
+ Four rules make it a plan rather than a wish:
29
+
30
+ - **An item is an outcome with a check on the same line.** No gate, no item — that is
31
+ a note, and notes go in the entry. If one item needs two gates, it is two items.
32
+ - **It is ordered, not bucketed.** Put the thing that unblocks the most first. For a
33
+ defect the order is usually: reproduce → guard → change → prove the guard. For a
34
+ feature: the smallest end-to-end path, then widen. Dependencies are why the order
35
+ is written down at all.
36
+ - **It is edited in place.** Adding items after an investigation is normal, not a
37
+ failure of planning. Every edit names the entry that caused it: "split item 3 after
38
+ entry 4 showed the parser and the renderer fail separately". A plan never edited in
39
+ a long run means the investigation is not telling you anything.
40
+ - **`[~]` is not `[-]`.** Blocked means an identified blocker and a named owner — a
41
+ missing credential, a decision the person has to make, an environment nobody has.
42
+ Dropped means out of scope, with the reason. Neither is a way to make the list look
43
+ finished.
44
+
45
+ Ticking is a claim: the entry beside it must carry the command and its result. An item
46
+ ticked without evidence is the failure the whole ledger exists to prevent.
47
+
48
+ ## The goal and the task list
49
+
50
+ Three artifacts, three lifetimes — mixing them up is how a run ends with three disagreeing
51
+ plans:
52
+
53
+ | Artifact | Lifetime | Answers |
54
+ | --- | --- | --- |
55
+ | `create_goal` / `update_goal` | this session's continuation rounds | should this keep running without the person? |
56
+ | `todo_write` | this session, display only | what is happening right now, that they can see? |
57
+ | the ledger's `## Plan` | the repository | what is left, and what proves each item? |
58
+
59
+ **The goal.** Create it after the plan is approved, and only when the person asked for the
60
+ work to finish without prompting them each turn. The objective is the approved goal
61
+ sentence plus the criteria, plus where the ledger is — a resumed run reads the ledger, not
62
+ your memory of why the goal exists.
63
+
64
+ Updating it is not symmetric: `update_goal` needs `goal_id` and `revision`, so call
65
+ `get_goal` first and pass what it returns. `revision` changes every round, so a remembered
66
+ one fails with a conflict.
67
+
68
+ - `complete` — the plan has no open items and every criterion holds. Not "the work feels
69
+ done", and not "I am out of ideas".
70
+ - `blocked` — needs a `blocked_reason` naming the concrete condition, and the action is
71
+ rejected until that condition has persisted for at least three goal rounds. Being unsure
72
+ is not blocked.
73
+ - `pause` / `resume` / `edit` require a direct request from the person. A run that pauses
74
+ its own goal has quit without saying so.
75
+
76
+ **The task list.** `todo_write` takes the whole list and replaces the previous one, so
77
+ rewrite it from the plan instead of appending. Order matters: it is the person's window
78
+ into which item is next. When the two disagree the ledger is right and the list is
79
+ rewritten — never the other way round, or the run starts working toward a plan nobody
80
+ approved.
81
+
82
+ Neither tool exists in every host: a spawned child may have no goal tools, and an older
83
+ host may have neither. When they are missing, say so in the entry and run on the ledger
84
+ alone — a missing tool is a note, not a reason to skip the iteration.
85
+
15
86
  ## Why the ledger is external
16
87
 
17
88
  Long tasks get compacted. After compaction you keep a summary, not the detail:
@@ -59,6 +130,29 @@ Before the step, list the mirrors. In the gate, include whatever reads the
59
130
  second mirror. If no such check exists, that is the finding: add the guard, and
60
131
  prove it fails when a mirror is missing.
61
132
 
133
+ ## When there is nothing new to learn
134
+
135
+ The ending is criteria-based, but the loop also has to be able to fail early. Two
136
+ consecutive iterations with no new fact is that signal: nothing was learned, nothing
137
+ changed, and the next step would be the third attempt at the same thing.
138
+
139
+ What counts as "a new fact": a command's output you had not seen, a call site you
140
+ had not read, a constraint the person stated, a test that now behaves differently.
141
+ Re-running the same command and getting the same result is not a new fact. Neither is
142
+ rewording the plan.
143
+
144
+ When it happens:
145
+
146
+ 1. Write the entry: what you tried, what it proved, and what is now blocked.
147
+ 2. Name the decision the person has to make — a scope change, a missing credential,
148
+ an environment you cannot reach. "Blocked on X" is a result; "still working on it"
149
+ is not.
150
+ 3. Stop. Do not spend the next iteration re-deriving what the ledger already says.
151
+
152
+ The same applies to a rejected plan: return to investigation with the objection in
153
+ hand. If the second plan is rejected too, the requirement is the thing to question,
154
+ and that conversation is with the person, not with the repository.
155
+
62
156
  ## Recovering after compaction
63
157
 
64
158
  1. Read the ledger head: task, criteria, gate.