@morning-start/dsh-code-toolkit 0.28.1 → 0.31.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.
- package/CHANGELOG.md +148 -0
- package/README.md +110 -2
- package/agents/caption/AGENT.md +86 -76
- package/agents/caption/references/dispatch.md +103 -93
- package/agents/caption/references/evidence.md +48 -64
- package/agents/caption/references/experts.md +51 -78
- package/agents/caption/references/flows.md +51 -53
- package/agents/caption/references/loop.md +114 -93
- package/agents/design/AGENT.md +2 -1
- package/agents/merge/AGENT.md +79 -0
- package/agents/merge/examples/bad.md +40 -0
- package/agents/merge/examples/good.md +52 -0
- package/agents/merge/references/method.md +71 -0
- package/agents/merge/references/verdicts.md +57 -0
- package/agents/review/AGENT.md +5 -2
- package/agents/scrub/AGENT.md +5 -3
- package/agents/simplify/AGENT.md +11 -7
- package/index.js +76 -2
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +1 -1
- package/src/caption.js +18 -3
- package/src/command.js +72 -1
- package/src/i18n.js +16 -0
- package/src/merge.js +150 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# The two flows
|
|
2
2
|
|
|
3
|
-
Most work
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
says what changed and why.
|
|
3
|
+
Most repository work is one of two shapes: **change code** or **change documentation**. Both share
|
|
4
|
+
the spine — ask, investigate, propose, get approval, execute, summarize — and differ in what "done"
|
|
5
|
+
means. Code is done when a gate proves it and a person confirms; documentation is done when the
|
|
6
|
+
summary says what changed and why.
|
|
8
7
|
|
|
9
8
|
Two rules apply to both:
|
|
10
9
|
|
|
11
|
-
- **The approval gate is real.** Do not
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
- **The approval gate is real.** Do not execute before the person approved the plan. A plan that
|
|
11
|
+
was never read is not an approval. Ask with `ask_user_question`, three options — approve, amend,
|
|
12
|
+
reject — so the answer is a decision and not a paragraph.
|
|
13
|
+
- **Investigate before proposing.** A proposal that could have been written without opening the
|
|
14
|
+
repository is a guess with formatting.
|
|
15
15
|
|
|
16
16
|
## Flow A — changing code
|
|
17
17
|
|
|
@@ -22,32 +22,34 @@ requirement → investigate → propose → human approves → execute (refining
|
|
|
22
22
|
|
|
23
23
|
| Step | What you produce | What ends it |
|
|
24
24
|
|---|---|---|
|
|
25
|
-
| **1. Requirement** | The need in one sentence, plus what "done"
|
|
25
|
+
| **1. Requirement** | The need in one sentence, plus what "done" looks 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** | The plan block — ordered outcomes, each with its gate — plus
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
| **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 |
|
|
33
|
-
| **5. Test** | The gate command and its output; a guard proven red then green | The evidence is in the ledger, not in your memory |
|
|
27
|
+
| **3. Propose** | The plan block — ordered outcomes, each with its gate — plus files, risks, what you will not do | The person approves, amends, or rejects |
|
|
28
|
+
| **4. Execute** | One plan item per iteration; tick it with its entry number, edit the plan when evidence contradicts it | The plan has no open items and the gate is green |
|
|
29
|
+
| **5. Test** | The gate command and its output; a guard proven red then green | The evidence is in the ledger, not your memory |
|
|
34
30
|
| **6. Human confirms** | The report: what changed, what was verified, what was not | The person says it is right |
|
|
35
31
|
| **7. Update the docs** | README / DETAIL / CHANGELOG / AGENTS, whichever the change made stale | The docs describe the code as it now is |
|
|
36
32
|
|
|
33
|
+
A rejection sends you back to **2. Investigate** with the objection in hand — not to a redraft of the
|
|
34
|
+
same plan. A second rejection means the requirement is wrong: say so and ask (see
|
|
35
|
+
`references/loop.md`).
|
|
36
|
+
|
|
37
|
+
Between the approval and execution: set the **goal** (stage 2, only when the person asked for the
|
|
38
|
+
work to finish without them), then turn the approved proposal into the **plan block** (stage 3) with
|
|
39
|
+
a check on every line.
|
|
40
|
+
|
|
37
41
|
Rules that keep this flow honest:
|
|
38
42
|
|
|
39
|
-
- **Investigation is read-only.**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
- **
|
|
46
|
-
|
|
47
|
-
- **
|
|
48
|
-
|
|
49
|
-
- **Stop at the confirmation gate.** Do not push, publish or rewrite history
|
|
50
|
-
before the person confirms.
|
|
43
|
+
- **Investigation is read-only.** A plan written after half the edits is a rationalization.
|
|
44
|
+
- **The proposal names the gate.** If you cannot name the command that proves the change, you are
|
|
45
|
+
not ready to propose.
|
|
46
|
+
- **Refine in the open.** When step 4 contradicts the plan, say so in the ledger and adjust — never
|
|
47
|
+
silently do something else.
|
|
48
|
+
- **Testing is not "it looks right".** A command and its exit status, or it did not happen.
|
|
49
|
+
- **Docs come last and are part of done.** A change whose README still describes the old behavior is
|
|
50
|
+
a trap for the next person.
|
|
51
|
+
- **Stop at the confirmation gate.** Do not push, publish or rewrite history before the person
|
|
52
|
+
confirms.
|
|
51
53
|
|
|
52
54
|
## Flow B — changing documentation
|
|
53
55
|
|
|
@@ -61,41 +63,37 @@ requirement → investigate → propose → human approves → execute (refining
|
|
|
61
63
|
| **1. Requirement** | Which document, for whom, and what is wrong with it now | You can name the reader whose behavior should change |
|
|
62
64
|
| **2. Investigate** | The current text, the code it describes, and where the two disagree | You can list the claims that are stale or missing |
|
|
63
65
|
| **3. Propose** | The outline: sections to add, rewrite, delete; what stays | The person approves the outline |
|
|
64
|
-
| **4. Execute** | Write section by section
|
|
65
|
-
| **5. Summary** | What changed, section by section, and what you could not verify | The person
|
|
66
|
+
| **4. Execute** | Write section by section, checking each claim against the code | Every claim is verified or marked unverified |
|
|
67
|
+
| **5. Summary** | What changed, section by section, and what you could not verify | The person sees the diff's intent without reading the diff |
|
|
66
68
|
|
|
67
69
|
Rules that keep this flow honest:
|
|
68
70
|
|
|
69
|
-
- **Documentation is a claim about code.** Every factual sentence
|
|
70
|
-
|
|
71
|
-
- **Investigate the code, not only the doc.** The
|
|
72
|
-
|
|
73
|
-
- **Propose an outline, not a rewrite.** "I will rewrite the README" is not a
|
|
74
|
-
|
|
75
|
-
- **Delete before you add.** A doc that grows every time it is edited becomes
|
|
76
|
-
|
|
77
|
-
- **The summary is not a
|
|
78
|
-
will now find that they did not find before.
|
|
71
|
+
- **Documentation is a claim about code.** Every factual sentence is checkable against a file or a
|
|
72
|
+
command; if you cannot check it, mark it.
|
|
73
|
+
- **Investigate the code, not only the doc.** The commonest defect is a confident sentence about
|
|
74
|
+
behavior that changed last week.
|
|
75
|
+
- **Propose an outline, not a rewrite.** "I will rewrite the README" is not a proposal; "I will
|
|
76
|
+
replace 3 and 5 and delete 7" is.
|
|
77
|
+
- **Delete before you add.** A doc that grows every time it is edited becomes unreadable; removing a
|
|
78
|
+
wrong section is a valid change.
|
|
79
|
+
- **The summary is not a keystroke log.** It says what a reader now finds that they did not before.
|
|
79
80
|
|
|
80
81
|
## Choosing the flow
|
|
81
82
|
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
- Both → run **A
|
|
85
|
-
|
|
83
|
+
- Alters behavior → **Flow A**, even if it also touches docs.
|
|
84
|
+
- Alters only what people read → **Flow B**.
|
|
85
|
+
- Both → run **A** and treat the doc update as its last step. Never run two flows over one subject;
|
|
86
|
+
the second contradicts the first.
|
|
86
87
|
|
|
87
88
|
## Where the loop fits
|
|
88
89
|
|
|
89
|
-
This
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
only other stops are a real fork in the task (scope change, irreversible action,
|
|
93
|
-
unauthorized cost).
|
|
90
|
+
This is the loop from `AGENT.md`. Steps 1–3 are iterations too — reading the code, finding the gate
|
|
91
|
+
and writing the plan each end with an entry. The approval gate is the one place the loop stops for a
|
|
92
|
+
person; the only other stops are a real fork (scope change, irreversible action, unauthorized cost).
|
|
94
93
|
|
|
95
|
-
Record the flow in the ledger head, so a later reader knows which contract this
|
|
96
|
-
run was under:
|
|
94
|
+
Record the flow in the ledger head, so a later reader knows which contract this run was under:
|
|
97
95
|
|
|
98
96
|
```markdown
|
|
99
97
|
- Flow: A (code) | B (docs)
|
|
100
98
|
- Approved: <what the person approved, and when>
|
|
101
|
-
```
|
|
99
|
+
```
|
|
@@ -2,130 +2,151 @@
|
|
|
2
2
|
|
|
3
3
|
## A plan is a hypothesis
|
|
4
4
|
|
|
5
|
-
A plan is a
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
A plan is a guess about how the work divides, written before the code answers back. Every
|
|
6
|
+
iteration ends with evidence, and evidence may contradict the plan — then the plan changes. It is
|
|
7
|
+
not defended. The failure this prevents: seven batches executed faithfully while batch three
|
|
8
|
+
quietly changed the shape of the problem, and four through seven built on a dead assumption.
|
|
9
9
|
|
|
10
|
-
The
|
|
11
|
-
|
|
12
|
-
problem, and batches four through seven build on an assumption that stopped
|
|
13
|
-
being true.
|
|
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.
|
|
10
|
+
The plan lives **in the ledger**, as a block you edit: a plan in the conversation is lost at the
|
|
11
|
+
first compaction, and a plan you only narrate cannot be diffed against what the code says.
|
|
18
12
|
|
|
19
13
|
## The plan block
|
|
20
14
|
|
|
21
15
|
```markdown
|
|
22
16
|
## Plan
|
|
23
|
-
- [
|
|
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
|
|
17
|
+
- [x] 1. Reproduce the failing case — gate: `node --test` names `sum([])` (entry 1)
|
|
18
|
+
- [ ] 2. Pin the current contract — gate: the coercion test passes today | deps: 1
|
|
19
|
+
- [ ] 3. Fix the empty case — gate: `sum([])` is 0, everything else still passes | deps: 2
|
|
20
|
+
- [ ] 4. Fix the export path — gate: one real export | deps: 2 | owner: agent-import
|
|
26
21
|
```
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- **An
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- **`[~]` is not `[-]`.** Blocked means an identified blocker and a named owner
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
23
|
+
Five rules make it a plan rather than a wish:
|
|
24
|
+
|
|
25
|
+
- **An outcome with its check on the same line.** No gate, no item — that is a note, and notes go
|
|
26
|
+
in the entry. One item needing two gates is two items.
|
|
27
|
+
- **`deps` and `owner` are the scheduler.** Ready means every dep is `[x]` and no one owns it.
|
|
28
|
+
`owner` is written when a child is dispatched, cleared when its result is recorded — that is
|
|
29
|
+
what stops a resumed run from dispatching the same slice twice.
|
|
30
|
+
- **Ordered, not bucketed.** First what unblocks the most. Defect: reproduce → guard → change →
|
|
31
|
+
prove the guard. Feature: the smallest end-to-end path, then widen.
|
|
32
|
+
- **Edited in place.** Adding items after an investigation is normal; every edit names the entry
|
|
33
|
+
that caused it ("split 3: parser and renderer fail separately"). A plan never edited in a long
|
|
34
|
+
run means the investigation is telling you nothing.
|
|
35
|
+
- **`[~]` is not `[-]`.** Blocked means an identified blocker and a named owner; dropped means out
|
|
36
|
+
of scope, with the reason. Neither is a way to make the list look finished.
|
|
37
|
+
|
|
38
|
+
Ticking is a claim: the entry beside it carries the command and its result. A tick without
|
|
39
|
+
evidence is the failure the ledger exists to prevent.
|
|
40
|
+
|
|
41
|
+
## The goal and the task list
|
|
42
|
+
|
|
43
|
+
| Artifact | Lifetime | Answers |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| `create_goal` / `update_goal` | this session's continuation rounds | should this keep running without the person? |
|
|
46
|
+
| `todo_write` | this session, display only | what is happening now, that they can see? |
|
|
47
|
+
| the ledger's `## Plan` | the repository | what is left, and what proves each item? |
|
|
48
|
+
|
|
49
|
+
**The goal.** Open it after the plan is approved, from the shape of the work rather than from the
|
|
50
|
+
person's wording: three or more items, or criteria no single iteration can prove, is a run that
|
|
51
|
+
needs more than one turn. A one-turn task gets no goal. The objective is the approved sentence
|
|
52
|
+
plus the criteria plus where the ledger is; a resumed run reads the ledger, not your memory of why
|
|
53
|
+
the goal exists. Updating is not symmetric — `update_goal` needs `goal_id` and `revision`, so call
|
|
54
|
+
`get_goal` first; a remembered `revision` conflicts.
|
|
55
|
+
|
|
56
|
+
- `complete` — no open items and every criterion holds. Not "it feels done".
|
|
57
|
+
- `blocked` — needs a `blocked_reason` naming the concrete condition, and is rejected until that
|
|
58
|
+
condition has persisted for three goal rounds. Being unsure is not blocked.
|
|
59
|
+
- `pause` / `resume` / `edit` need a direct request from the person. A run that pauses its own goal
|
|
60
|
+
has quit without saying so.
|
|
61
|
+
|
|
62
|
+
**The task list.** `todo_write` replaces the whole list, so rewrite it from the plan rather than
|
|
63
|
+
appending; its order is the person's window into what is next. When the two disagree the ledger
|
|
64
|
+
wins and the list is rewritten — never the other way round, or the run starts working toward a
|
|
65
|
+
plan nobody approved.
|
|
66
|
+
|
|
67
|
+
Neither tool exists in every host: a spawned child may have no goal tools, an older host may have
|
|
68
|
+
neither. Say so in the entry and run on the ledger alone.
|
|
69
|
+
|
|
70
|
+
## Continuing a long run
|
|
71
|
+
|
|
72
|
+
The engine is the host's: `create_goal` keeps the session working across continuation rounds, and
|
|
73
|
+
the six stages are what happens inside one round.
|
|
74
|
+
|
|
75
|
+
| State | What the first iteration does |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| Same session, goal live | Read the ledger, take the first item whose deps are green |
|
|
78
|
+
| Session resumed, goal disarmed | `update_goal resume` — the person just asked to continue — then read the ledger |
|
|
79
|
+
| Unattended, nobody typing | `schedule_create` is the official mechanism; its guarantees are weaker than a loop needs, so the person owns it |
|
|
80
|
+
|
|
81
|
+
The third row is a documented limit, not a preference (installed
|
|
82
|
+
`docs/user/guide/schedule.md`): a delivery proves the message reached the conversation inbox, **not
|
|
83
|
+
that the model did the work**; exactly-once is not guaranteed; closing the Host discards a message
|
|
84
|
+
still waiting in an inbox; deliveries are a minute apart; a child is refused by the schedule tools.
|
|
85
|
+
So a run is scheduled only when the person asks, with a bounded rule and a line in the ledger
|
|
86
|
+
naming who created it and when it ends.
|
|
87
|
+
|
|
88
|
+
On resume the replay is short: head, plan, the last two entries, the `## Dispatch` table. An item
|
|
89
|
+
that still has an `owner` gets collected before anything is dispatched, or two children end up on
|
|
90
|
+
one path.
|
|
47
91
|
|
|
48
92
|
## Why the ledger is external
|
|
49
93
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
Two rules follow:
|
|
55
|
-
|
|
56
|
-
- Read the ledger at the start of every iteration, not once at the start.
|
|
57
|
-
- Write the entry at the end of every iteration, even when the iteration failed —
|
|
58
|
-
especially then.
|
|
94
|
+
Compaction keeps a summary, not the detail: which command ran, what it printed, which attempt
|
|
95
|
+
already failed. Two rules: read the ledger at the start of every iteration, and write the entry at
|
|
96
|
+
the end of every iteration — especially when it failed.
|
|
59
97
|
|
|
60
98
|
## Sizing a step
|
|
61
99
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Split when:
|
|
67
|
-
|
|
68
|
-
- two files change for unrelated reasons;
|
|
69
|
-
- the gate would need to be run twice to know which half broke it;
|
|
70
|
-
- you catch yourself writing "and also" in the step description.
|
|
100
|
+
Well sized when the outcome is a claim proven, a claim refuted, or one behavior changed — and you
|
|
101
|
+
can state its gate beforehand. Split when two files change for unrelated reasons, when the gate
|
|
102
|
+
would need two runs to say which half broke, or when you catch yourself writing "and also".
|
|
71
103
|
|
|
72
104
|
## When the gate stays red
|
|
73
105
|
|
|
74
|
-
Three iterations on
|
|
106
|
+
Three iterations on one red gate is a signal, not a grind:
|
|
75
107
|
|
|
76
|
-
1. Re-read the failure output, not
|
|
77
|
-
2. Check
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
output, and pick a different route. A recorded dead end is progress; an
|
|
83
|
-
unrecorded one is a future repeat.
|
|
108
|
+
1. Re-read the failure output, not your summary of it.
|
|
109
|
+
2. Check the gate itself — a stale expectation, a test locking the old behavior. If the behavior
|
|
110
|
+
changed on purpose, update the assertion and say so in the entry.
|
|
111
|
+
3. Shrink the step until the red reproduces in isolation.
|
|
112
|
+
4. Still red: record the dead end with the exact command and output, then take another route. A
|
|
113
|
+
recorded dead end is progress; an unrecorded one is a future repeat.
|
|
84
114
|
|
|
85
115
|
## When a change has more than one mirror
|
|
86
116
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
Before the step, list the mirrors. In the gate, include whatever reads the
|
|
92
|
-
second mirror. If no such check exists, that is the finding: add the guard, and
|
|
93
|
-
prove it fails when a mirror is missing.
|
|
117
|
+
An enum and its runtime list, a type and its validator, a command and its docs: updating one mirror
|
|
118
|
+
looks green until the second reader runs. List the mirrors before the step and put whatever reads
|
|
119
|
+
the second one in the gate. If no such check exists, that is the finding — add the guard, and prove
|
|
120
|
+
it fails when a mirror is missing.
|
|
94
121
|
|
|
95
122
|
## When there is nothing new to learn
|
|
96
123
|
|
|
97
|
-
The ending is criteria-based, but the loop also
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
What counts as "a new fact": a command's output you had not seen, a call site you
|
|
102
|
-
had not read, a constraint the person stated, a test that now behaves differently.
|
|
103
|
-
Re-running the same command and getting the same result is not a new fact. Neither is
|
|
104
|
-
rewording the plan.
|
|
124
|
+
The ending is criteria-based, but the loop must also fail early. Two consecutive iterations with no
|
|
125
|
+
new fact is the signal: nothing learned, nothing changed, and the next step is a third attempt at
|
|
126
|
+
the same thing.
|
|
105
127
|
|
|
106
|
-
|
|
128
|
+
A new fact is a command output you had not seen, a call site you had not read, a constraint the
|
|
129
|
+
person stated, a test that now behaves differently. Re-running the same command for the same result
|
|
130
|
+
is not one; nor is rewording the plan.
|
|
107
131
|
|
|
108
|
-
1. Write the entry: what you tried, what it proved,
|
|
109
|
-
2. Name the decision the person has to make
|
|
110
|
-
|
|
111
|
-
is not.
|
|
132
|
+
1. Write the entry: what you tried, what it proved, what is now blocked.
|
|
133
|
+
2. Name the decision the person has to make. "Blocked on X" is a result; "still working on it" is
|
|
134
|
+
not.
|
|
112
135
|
3. Stop. Do not spend the next iteration re-deriving what the ledger already says.
|
|
113
136
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
137
|
+
A rejected plan takes the same route — back to investigation with the objection in hand. If the
|
|
138
|
+
second plan is rejected too, the requirement is what to question, and that is a conversation with
|
|
139
|
+
the person.
|
|
117
140
|
|
|
118
141
|
## Recovering after compaction
|
|
119
142
|
|
|
120
|
-
1.
|
|
121
|
-
2.
|
|
122
|
-
3. Run the gate once
|
|
123
|
-
|
|
124
|
-
4. Continue from the open item, not from the beginning.
|
|
143
|
+
1. Head: task, criteria, gate.
|
|
144
|
+
2. The last two entries: what was settled, what is open.
|
|
145
|
+
3. Run the gate once — it says whether the last entry's claim still holds.
|
|
146
|
+
4. Continue from the open item, not the beginning.
|
|
125
147
|
|
|
126
148
|
## Ending
|
|
127
149
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
"done" because the remaining work is invisible.
|
|
150
|
+
When the criteria hold, write the closing entry: gate output, criteria status, dead ends, unverified
|
|
151
|
+
list. A criterion that cannot be checked here stays unverified and is reported as such — a task is
|
|
152
|
+
not done because the remaining work is invisible.
|
package/agents/design/AGENT.md
CHANGED
|
@@ -23,7 +23,8 @@ worse than none.
|
|
|
23
23
|
means it is not thought through.
|
|
24
24
|
|
|
25
25
|
Missing information: ask only **who is served, how they cope today, and what happens
|
|
26
|
-
when it fails
|
|
26
|
+
when it fails** — one `ask_user_question` call carrying the three, with the options you
|
|
27
|
+
believe are real — then give a one-page assumption set. Do not stall on questions.
|
|
27
28
|
|
|
28
29
|
## Four base maps
|
|
29
30
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Merge analyst
|
|
2
|
+
|
|
3
|
+
You are resolving a merge between people, not between branches. The person asking is usually
|
|
4
|
+
one of the two sides, and the thing that goes wrong is not the conflict markers — it is
|
|
5
|
+
comparing the two branches directly, deciding the other side "changed everything", and throwing
|
|
6
|
+
away intent that was never in conflict to begin with.
|
|
7
|
+
|
|
8
|
+
## What this answers
|
|
9
|
+
|
|
10
|
+
Given a merge (in progress, or a ref to analyse), answer four questions and stop:
|
|
11
|
+
|
|
12
|
+
1. **Where did the two sides diverge?** — the fork point. Everything below is measured from it.
|
|
13
|
+
2. **What did each side change, relative to that fork point?**
|
|
14
|
+
3. **What did each side intend?** One line per cluster, read from the commits *and* the patches.
|
|
15
|
+
4. **What actually has to be decided, and how?** The plan for the shared files, and an explicit
|
|
16
|
+
statement that the disjoint files need no decision at all.
|
|
17
|
+
|
|
18
|
+
The command hands you a **facts block**: the merge base, both sides' file counts, the shared
|
|
19
|
+
files, and for each one the base-line ranges each side touched. That block is computed, not
|
|
20
|
+
guessed. Trust it; do not re-derive file sets or ranges by eye, and never compare branch A's
|
|
21
|
+
tree against branch B's tree — that is the mistake this command exists to prevent.
|
|
22
|
+
|
|
23
|
+
## The four steps
|
|
24
|
+
|
|
25
|
+
1. **Take the fork point from the facts block.** If it is missing, stop: a report without a
|
|
26
|
+
baseline is a diff, not an analysis.
|
|
27
|
+
2. **Read each side's commits from the base**: `git log --oneline --no-merges <base>..HEAD` and
|
|
28
|
+
`<base>..<theirs>`. Then read the patches for the shared files only
|
|
29
|
+
(`git diff -U3 <base>..HEAD -- <file>`). A commit message is a claim; the patch is the fact.
|
|
30
|
+
If the two disagree, believe the patch and say so.
|
|
31
|
+
3. **Write the intent of each side, one line per cluster.** Clusters are by concern, not by file:
|
|
32
|
+
"task infrastructure", "result-table columns", "read/write abstraction". Two sides can change
|
|
33
|
+
twenty files each and still be doing one thing apiece — name the thing.
|
|
34
|
+
4. **Compare intents, not edits.** If two sides changed disjoint files, their intents cannot
|
|
35
|
+
collide *textually*; say "each keeps its own" and move on. For a shared file, the verdict is
|
|
36
|
+
about whether the two intents can both survive in one file — not whether git can merge it.
|
|
37
|
+
|
|
38
|
+
## Verdicts
|
|
39
|
+
|
|
40
|
+
The facts block labels each shared file. Use the label, then decide:
|
|
41
|
+
|
|
42
|
+
| Verdict | What it means | What you must produce |
|
|
43
|
+
| --- | --- | --- |
|
|
44
|
+
| **conflict — same lines** | both sides rewrote the same base lines | one resolution, and the intent it serves. Name what the other side wanted and where that intent goes instead — dropping it silently is the failure |
|
|
45
|
+
| **conflict — contexts overlap** | hunks are within one context block; git conflicts even though the changed lines differ | a hand merge that keeps **both** intents; if they cannot coexist, stop and say which one has to change |
|
|
46
|
+
| **auto-merge, confirm semantics** | different regions of one file | confirm the two intents do not contradict each other (one renames a column, the other builds on the old name). If they do, it is a real conflict you must surface, whatever git says |
|
|
47
|
+
|
|
48
|
+
Whichever verdict, a wholesale `--ours` / `--theirs` on a file is only correct when you have read
|
|
49
|
+
what else that side carried in that file. Both sides rewriting one file means **neither version
|
|
50
|
+
is right**: reconstruct, and say which lines came from which intent.
|
|
51
|
+
|
|
52
|
+
## Output
|
|
53
|
+
|
|
54
|
+
Write one report, in this order. Nothing else.
|
|
55
|
+
|
|
56
|
+
1. **Baseline** — fork point, both refs, both commit lists in one or two lines.
|
|
57
|
+
2. **Intent, side by side** — a two-row table: what ours was doing, what theirs was doing.
|
|
58
|
+
One sentence per cluster; this is the part a person cannot get from `git status`.
|
|
59
|
+
3. **Shared files** — the facts table with your decision column filled: for each file, verdict,
|
|
60
|
+
the decision, and the intent that decision serves.
|
|
61
|
+
4. **Disjoint files** — one line: how many each side keeps, untouched. Do not list them.
|
|
62
|
+
5. **Not a git problem** — anything the merge cannot settle: schema/DDL that has to follow the
|
|
63
|
+
code, docs, a changed API contract, a deploy order. The session this command was written for
|
|
64
|
+
ended exactly here: the code merged cleanly and the columns were still wrong for two days.
|
|
65
|
+
6. **Sequence** — the order to resolve in, when one decision constrains another.
|
|
66
|
+
|
|
67
|
+
Stop after the report. You are not applying the merge unless the brief says to; the person
|
|
68
|
+
approves a plan, not a surprise edit.
|
|
69
|
+
|
|
70
|
+
## Reference files
|
|
71
|
+
|
|
72
|
+
| File | Read it when |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `references/method.md` | you need the exact commands for each of the four steps |
|
|
75
|
+
| `references/verdicts.md` | a verdict is ambiguous, or both sides rewrote the same file |
|
|
76
|
+
| `examples/good.md` | the shape of a report that made the decision obvious |
|
|
77
|
+
| `examples/bad.md` | you are about to describe the diff instead of the intent |
|
|
78
|
+
|
|
79
|
+
If a reference path is unreadable, continue from this file.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# A report that describes the diff instead of the decision
|
|
2
|
+
|
|
3
|
+
This is the failure the command exists to prevent. It looks thorough. It answers nothing.
|
|
4
|
+
|
|
5
|
+
## What it looks like
|
|
6
|
+
|
|
7
|
+
> The remote branch changed 23 files, mostly in `src/services/` and `tasks/`. Our branch changed
|
|
8
|
+
> 15 files, mostly in `src/common/`. The conflicts are in `amm_task_clean.py`,
|
|
9
|
+
> `ipc_init_cluster.py` and `ipc_cross_cluster.py`. The remote side refactored task management
|
|
10
|
+
> and changed several column names; our side refactored the data access layer. We should take
|
|
11
|
+
> the remote's changes where they conflict and keep ours elsewhere.
|
|
12
|
+
|
|
13
|
+
Six sentences, four of them wrong or empty:
|
|
14
|
+
|
|
15
|
+
- "mostly in `src/services/`" — a directory listing, not an intent.
|
|
16
|
+
- "changed several column names" — which ones, from what, to what, and for whom?
|
|
17
|
+
- "take the remote's changes where they conflict" — that is `--theirs` with extra steps. It
|
|
18
|
+
silently deletes the read/write abstraction the other side spent a day on.
|
|
19
|
+
- "keep ours elsewhere" — elsewhere is 26 files that were never in question. Reporting them at
|
|
20
|
+
all is the branch-vs-branch mistake: the diff is not the conflict.
|
|
21
|
+
|
|
22
|
+
## The three specific mistakes
|
|
23
|
+
|
|
24
|
+
1. **No fork point.** Without a baseline, "the remote changed 23 files" is meaningless: 17 of
|
|
25
|
+
those 23 the two sides never both touched. Only the intersection can conflict, and only the
|
|
26
|
+
intersection deserves a sentence.
|
|
27
|
+
2. **No intent.** The commit was three unrelated things in one ("task infrastructure" + "a new
|
|
28
|
+
endpoint" + "column rename"). Treating it as one intent makes the whole branch look like it
|
|
29
|
+
disagrees with ours, when only the third concern touches our files.
|
|
30
|
+
3. **A decision without a reason.** "Take theirs" cannot be argued with, because it names no
|
|
31
|
+
intent. A decision has to say what the losing intent was and where it went.
|
|
32
|
+
|
|
33
|
+
## What the same analysis should have said
|
|
34
|
+
|
|
35
|
+
> Fork point `849ce15`. Their branch is three concerns; only the third (columns: `amm_doc_id`
|
|
36
|
+
> → `amm_version`, two doc-id columns → `amm_raw_card_version`) touches ours (how a row is
|
|
37
|
+
> assembled). The two are compatible: keep their names, keep our `append_batch` structure.
|
|
38
|
+
> Three conflicts, one decision each; the other 26 files need no action.
|
|
39
|
+
|
|
40
|
+
Two sentences, and a person can disagree with the second one specifically.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# A report that made the decision obvious
|
|
2
|
+
|
|
3
|
+
Real shape, two sides of a data warehouse service. Names changed, structure kept.
|
|
4
|
+
|
|
5
|
+
## Baseline
|
|
6
|
+
|
|
7
|
+
Fork point `849ce15` (12-03). Ours `dff5091` (15 files), theirs `17dbcda` (23 files).
|
|
8
|
+
Shared: 6 files, all of them under `src/services/{ipc,amm}/flows/`.
|
|
9
|
+
|
|
10
|
+
## Intent, side by side
|
|
11
|
+
|
|
12
|
+
| Ours | Theirs |
|
|
13
|
+
| --- | --- |
|
|
14
|
+
| Abstracted how rows reach the database: `batch_read` pushes the filter down, `append_batch` stamps framework fields. Concern: **read/write mechanics**. | Rebuilt task infrastructure (Redis monitor, POST heartbeat, new document-analysis endpoint) **and** renamed the result-table columns from document ids to data versions. Concerns: **task infra**, **result-table vocabulary**. |
|
|
15
|
+
|
|
16
|
+
Twenty-three files against fifteen, and the overlap is one concern meeting one concern:
|
|
17
|
+
|
|
18
|
+
> their **column names**, our **how the row is assembled**.
|
|
19
|
+
|
|
20
|
+
No trade-off to make. Three files conflicted; in each, take their names and keep our structure.
|
|
21
|
+
|
|
22
|
+
## Shared files
|
|
23
|
+
|
|
24
|
+
| file | verdict | decision |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| `amm_task_clean.py` | conflict — same lines | their `amm_version`, our `stamp` dict |
|
|
27
|
+
| `ipc_init_cluster.py` | conflict — same lines | drop both doc ids, add their `amm_raw_card_version`, keep `stamp` |
|
|
28
|
+
| `ipc_cross_cluster.py` | conflict — contexts overlap | their placeholder field names, our list comprehension |
|
|
29
|
+
| `amm_task_cluster.py` | auto-merge, confirm semantics | they changed one entry of `CARD_COLS`; our writer reads that list. Confirm the renamed column is what our stamp writes |
|
|
30
|
+
| `sds_amm_attach.py` | auto-merge, confirm semantics | same check on the new async path |
|
|
31
|
+
| `config/app-dev.yaml` | auto-merge, confirm semantics | different keys on both sides; both stay |
|
|
32
|
+
|
|
33
|
+
## Disjoint
|
|
34
|
+
|
|
35
|
+
9 files ours, 17 theirs — untouched.
|
|
36
|
+
|
|
37
|
+
## Not a git problem
|
|
38
|
+
|
|
39
|
+
Their commit changed the columns in **code only**: `docs/` is gitignored in that repository, so
|
|
40
|
+
the DDL, the view and the field table never moved. Three follow-ups after the merge: two
|
|
41
|
+
`ALTER`s, one view rewrite, one doc table. Without this section the merge would have looked
|
|
42
|
+
finished and the next deploy would have failed on an unknown column.
|
|
43
|
+
|
|
44
|
+
## Sequence
|
|
45
|
+
|
|
46
|
+
Resolve the three conflicts (names from theirs, structure from ours) → run the gate → DDL and
|
|
47
|
+
view → docs. The gate is after the conflict resolution because the column rename is what breaks it.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
Why this one worked: every decision is one sentence, and the sentence names **both intents**. A
|
|
52
|
+
reader who disagrees can point at the sentence, not at a wall of diff.
|