@linimin/pi-letscook 0.1.26
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 +196 -0
- package/LICENSE +21 -0
- package/PUBLISHING.md +60 -0
- package/README.md +219 -0
- package/agents/completion-auditor.md +43 -0
- package/agents/completion-bootstrapper.md +56 -0
- package/agents/completion-implementer.md +83 -0
- package/agents/completion-regrounder.md +66 -0
- package/agents/completion-reviewer.md +46 -0
- package/agents/completion-stop-judge.md +50 -0
- package/extensions/completion/index.ts +2572 -0
- package/package.json +38 -0
- package/scripts/context-proposal-test.sh +235 -0
- package/scripts/observability-status-test.sh +237 -0
- package/scripts/refocus-test.sh +77 -0
- package/scripts/release-check.sh +13 -0
- package/scripts/smoke-test.sh +74 -0
- package/skills/completion-protocol/SKILL.md +168 -0
- package/skills/completion-protocol/references/completion.md +287 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
PKG_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
5
|
+
TMPDIR="$(mktemp -d)"
|
|
6
|
+
trap 'rm -rf "$TMPDIR"' EXIT
|
|
7
|
+
|
|
8
|
+
cd "$TMPDIR"
|
|
9
|
+
git init -q
|
|
10
|
+
|
|
11
|
+
pi -e "$PKG_ROOT" -p "/cook smoke-test mission" >/tmp/pi-completion-smoke.out 2>/tmp/pi-completion-smoke.err &
|
|
12
|
+
PI_PID=$!
|
|
13
|
+
for _ in $(seq 1 60); do
|
|
14
|
+
if [[ -f .agent/profile.json && -f .agent/state.json && -f .agent/plan.json && -f .agent/active-slice.json ]]; then
|
|
15
|
+
break
|
|
16
|
+
fi
|
|
17
|
+
sleep 1
|
|
18
|
+
done
|
|
19
|
+
if [[ ! -f .agent/profile.json || ! -f .agent/state.json || ! -f .agent/plan.json || ! -f .agent/active-slice.json ]]; then
|
|
20
|
+
echo "completion bootstrap did not materialize canonical files in time" >&2
|
|
21
|
+
cat /tmp/pi-completion-smoke.err >&2 || true
|
|
22
|
+
kill "$PI_PID" >/dev/null 2>&1 || true
|
|
23
|
+
wait "$PI_PID" >/dev/null 2>&1 || true
|
|
24
|
+
exit 1
|
|
25
|
+
fi
|
|
26
|
+
kill "$PI_PID" >/dev/null 2>&1 || true
|
|
27
|
+
wait "$PI_PID" >/dev/null 2>&1 || true
|
|
28
|
+
|
|
29
|
+
bash .agent/verify_completion_control_plane.sh >/dev/null
|
|
30
|
+
bash .agent/verify_completion_stop.sh >/dev/null
|
|
31
|
+
|
|
32
|
+
python3 - <<'PY2'
|
|
33
|
+
import json
|
|
34
|
+
from pathlib import Path
|
|
35
|
+
path = Path('.agent/active-slice.json')
|
|
36
|
+
active = json.loads(path.read_text())
|
|
37
|
+
active.update({
|
|
38
|
+
'status': 'selected',
|
|
39
|
+
'slice_id': 'smoke-slice',
|
|
40
|
+
'goal': 'verify selected handoff schema',
|
|
41
|
+
'contract_ids': ['smoke-contract'],
|
|
42
|
+
'acceptance_criteria': ['criterion'],
|
|
43
|
+
'blocked_on': [],
|
|
44
|
+
'locked_notes': [],
|
|
45
|
+
'must_fix_findings': [],
|
|
46
|
+
'basis_commit': 'deadbeef',
|
|
47
|
+
'remaining_contract_ids_before': ['smoke-contract'],
|
|
48
|
+
'release_blocker_count_before': 1,
|
|
49
|
+
'high_value_gap_count_before': 0,
|
|
50
|
+
})
|
|
51
|
+
active.pop('priority', None)
|
|
52
|
+
active.pop('why_now', None)
|
|
53
|
+
path.write_text(json.dumps(active, indent=2) + '\n')
|
|
54
|
+
PY2
|
|
55
|
+
|
|
56
|
+
if bash .agent/verify_completion_control_plane.sh >/dev/null 2>&1; then
|
|
57
|
+
echo "expected control-plane verification to fail when selected active-slice omits priority/why_now" >&2
|
|
58
|
+
exit 1
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
python3 - <<'PY3'
|
|
62
|
+
import json
|
|
63
|
+
from pathlib import Path
|
|
64
|
+
path = Path('.agent/active-slice.json')
|
|
65
|
+
active = json.loads(path.read_text())
|
|
66
|
+
active['priority'] = 1
|
|
67
|
+
active['why_now'] = 'smoke test exact handoff'
|
|
68
|
+
path.write_text(json.dumps(active, indent=2) + '\n')
|
|
69
|
+
PY3
|
|
70
|
+
|
|
71
|
+
bash .agent/verify_completion_control_plane.sh >/dev/null
|
|
72
|
+
bash .agent/verify_completion_stop.sh >/dev/null
|
|
73
|
+
|
|
74
|
+
echo "smoke test passed: $TMPDIR"
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: completion-protocol
|
|
3
|
+
description: Shared completion workflow protocol for long-running coding tasks with canonical .agent state, one-slice execution, mandatory role dispatch, recovery, and final stop criteria. Use when driving persistent end-to-end completion work across multiple sessions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Completion Protocol
|
|
7
|
+
|
|
8
|
+
Load this skill whenever you are operating inside the `completion` workflow.
|
|
9
|
+
|
|
10
|
+
This skill defines shared protocol facts only. Role-specific behavior belongs in the dedicated completion agents:
|
|
11
|
+
|
|
12
|
+
- `completion-bootstrapper`
|
|
13
|
+
- `completion-regrounder`
|
|
14
|
+
- `completion-implementer`
|
|
15
|
+
- `completion-reviewer`
|
|
16
|
+
- `completion-auditor`
|
|
17
|
+
- `completion-stop-judge`
|
|
18
|
+
|
|
19
|
+
## Shared Rules
|
|
20
|
+
|
|
21
|
+
- Current repo truth beats stale notes, stale summaries, and conversation memory.
|
|
22
|
+
- `plan.json` is the persistent machine-readable slice backlog. Rebuild it during every re-grounding wave and keep it truthful after every committed slice.
|
|
23
|
+
- `state.json` is the persistent machine-readable workflow controller. Keep `current_phase`, `continuation_policy`, `continuation_reason`, `next_mandatory_role`, and `next_mandatory_action` truthful after every transition.
|
|
24
|
+
- Every slice in `plan.json` must have non-empty `acceptance_criteria` — concrete, verifiable conditions that define done. A slice without acceptance criteria is invalid and must not be selected.
|
|
25
|
+
- Acceptance criteria are immutable after lock except for removing a criterion already satisfied with evidence or adding a missing criterion discovered during implementation.
|
|
26
|
+
- If implementation discovers roadmap-level drift — such as invalid slice boundaries, missing prerequisite slices, dependency reordering, or a blocker that changes the current slice contract — the implementer must not silently redesign the plan. It must report the new truth and return control for canonical reconciliation by `completion-regrounder`.
|
|
27
|
+
- During re-ground, evaluate each slice's `acceptance_criteria` against current repo truth and update `status` and `evidence` accordingly.
|
|
28
|
+
- A slice may only transition to `done` when every acceptance criterion is satisfied with proof in `evidence`.
|
|
29
|
+
- Run exactly one implementation slice at a time.
|
|
30
|
+
- A slice is not complete unless it lands as a new commit.
|
|
31
|
+
- Before selecting or advancing to the next slice after a committed slice, the tracked and unignored worktree must be clean. If it is not clean, treat that dirty state as a blocker to next-slice progression and reopen or continue the latest slice for reconciliation.
|
|
32
|
+
- Docs, config, and runbooks must stay truthful to shipped behavior.
|
|
33
|
+
- `.agent/verify_completion_stop.sh` is a generated repo-level baseline verifier. Onboarding should create a working version from current repo truth rather than an unconditional failing placeholder.
|
|
34
|
+
- Keep slice-specific proof in repo tests or deterministic checks. Refresh `.agent/verify_completion_stop.sh` only when the repo's top-level verification surfaces change or the verifier becomes stale.
|
|
35
|
+
- The workflow topology is flat and primary-driven: the main pi session remains the workflow root and invokes at most one completion role at a time.
|
|
36
|
+
- No completion role may invoke another completion role during the normal workflow.
|
|
37
|
+
- Completion is a sticky workflow. If canonical state says continuation is required, the workflow root must keep advancing through mandatory roles until canonical state switches to `await_user_input`, `blocked`, `paused`, or `done`.
|
|
38
|
+
- `continuation_policy == continue` means the workflow root must not stop after a slice or ask the user whether to continue. It must dispatch the next mandatory role directly.
|
|
39
|
+
- `continuation_policy == await_user_input` means the workflow root must ask only for the exact missing input and then stop.
|
|
40
|
+
- `continuation_policy == blocked` means the workflow root must report the blocker and stop.
|
|
41
|
+
- `continuation_policy == paused` means the user explicitly paused the workflow.
|
|
42
|
+
- `continuation_policy == done` means canonical final stop reconciliation is complete and the workflow may stop.
|
|
43
|
+
- Use `completion-bootstrapper` only for first-time setup or missing tracked contract-file repair.
|
|
44
|
+
- Use `completion-regrounder` for canonical re-grounding, slice selection, post-review or post-audit reconciliation, and final stop reconciliation.
|
|
45
|
+
- Default scratch space for temporary files is repo-local `.agent/tmp/`.
|
|
46
|
+
- Do not write scratch artifacts to `/tmp` or `/private/tmp` by default.
|
|
47
|
+
- If a tool or platform behavior explicitly requires OS temp, prefer a scoped path such as `$TMPDIR/pi-completion/<repo-name>/` and treat it as disposable.
|
|
48
|
+
- Never keep canonical state, required verification evidence, or the only copy of a deliverable exclusively in temp paths.
|
|
49
|
+
|
|
50
|
+
## Primary Driver Contract
|
|
51
|
+
|
|
52
|
+
When `completion-protocol` is loaded by the main pi session, that session becomes the workflow driver only.
|
|
53
|
+
|
|
54
|
+
The workflow driver may:
|
|
55
|
+
|
|
56
|
+
- read current repo truth and canonical `.agent` state
|
|
57
|
+
- update canonical `.agent/**` state truthfully when needed for handoff
|
|
58
|
+
- choose which completion role to invoke next according to the mandatory dispatch table below
|
|
59
|
+
- summarize or compare role outputs for the user
|
|
60
|
+
- append canonical `.agent/slice-history.jsonl` records, but only as a faithful transcription of actual completion-role outputs
|
|
61
|
+
- append canonical `.agent/stop-check-history.jsonl` `judgment` records during the final stop wave, but only as a faithful transcription of actual `completion-stop-judge` outputs
|
|
62
|
+
|
|
63
|
+
The workflow driver must not, while completion is active and a slice is selected or in progress:
|
|
64
|
+
|
|
65
|
+
- directly edit non-`.agent/**` tracked product, docs, config, or test files for that slice
|
|
66
|
+
- directly create the slice commit
|
|
67
|
+
- directly mark a slice implemented, accepted, reopened, reviewed, audited, or judged without the corresponding role output
|
|
68
|
+
- bypass the completion roles for convenience
|
|
69
|
+
- hand control back to the user between slices merely to ask whether to continue when `continuation_policy == continue`
|
|
70
|
+
|
|
71
|
+
If the workflow driver detects that the next mandatory action belongs to a completion role, it must invoke that role rather than doing the slice work itself.
|
|
72
|
+
|
|
73
|
+
## Mandatory Dispatch Table
|
|
74
|
+
|
|
75
|
+
1. If tracked protocol contract files are missing or first-time onboarding is required, invoke `completion-bootstrapper`.
|
|
76
|
+
2. If canonical `.agent` execution state is missing, invalid, contradictory, stale, or ambiguous after compaction or recovery, invoke `completion-regrounder`.
|
|
77
|
+
3. If no slice is selected, invoke `completion-regrounder` to reconcile `.agent/plan.json` and return the next exact handoff payload.
|
|
78
|
+
4. If a slice is `selected` or `in_progress` and no new slice commit exists yet, invoke `completion-implementer`.
|
|
79
|
+
5. If the latest committed slice lacks a review result, invoke `completion-reviewer`.
|
|
80
|
+
6. If the latest committed slice lacks an audit result, invoke `completion-auditor`.
|
|
81
|
+
7. If review or audit have returned and canonical reconciliation is needed, invoke `completion-regrounder`. `completion-regrounder` must not select or hand off a next slice while the latest committed slice leaves the tracked and unignored worktree dirty; instead it must reopen or continue that latest slice for reconciliation.
|
|
82
|
+
8. If all planned slices are done and final closure is being evaluated, invoke the required `completion-stop-judge` sessions directly.
|
|
83
|
+
9. After each required `completion-stop-judge` result is faithfully recorded, rerun `bash .agent/verify_completion_stop.sh` and invoke `completion-regrounder` for final stop reconciliation.
|
|
84
|
+
|
|
85
|
+
The workflow driver must not substitute itself for any mandatory dispatch target above.
|
|
86
|
+
|
|
87
|
+
## Canonical Files
|
|
88
|
+
|
|
89
|
+
Tracked repo-contract files:
|
|
90
|
+
|
|
91
|
+
- `.agent/README.md`
|
|
92
|
+
- `.agent/mission.md`
|
|
93
|
+
- `.agent/profile.json`
|
|
94
|
+
- `.agent/verify_completion_stop.sh`
|
|
95
|
+
- `.agent/verify_completion_control_plane.sh`
|
|
96
|
+
|
|
97
|
+
Ignored canonical execution-state files:
|
|
98
|
+
|
|
99
|
+
- `.agent/state.json`
|
|
100
|
+
- `.agent/plan.json`
|
|
101
|
+
- `.agent/active-slice.json`
|
|
102
|
+
- `.agent/slice-history.jsonl`
|
|
103
|
+
- `.agent/stop-check-history.jsonl`
|
|
104
|
+
- `.agent/*.log`
|
|
105
|
+
|
|
106
|
+
## Canonical Inputs
|
|
107
|
+
|
|
108
|
+
Read these when making completion decisions:
|
|
109
|
+
|
|
110
|
+
- `.agent/mission.md`
|
|
111
|
+
- `.agent/README.md`
|
|
112
|
+
- `.agent/profile.json`
|
|
113
|
+
- `.agent/state.json`
|
|
114
|
+
- `.agent/plan.json`
|
|
115
|
+
- `.agent/active-slice.json`
|
|
116
|
+
- `.agent/slice-history.jsonl`
|
|
117
|
+
- `.agent/stop-check-history.jsonl`
|
|
118
|
+
|
|
119
|
+
Optional context only:
|
|
120
|
+
|
|
121
|
+
- `.agent/backlog.md`
|
|
122
|
+
- `.agent/handoff.md`
|
|
123
|
+
- `.agent/compact.md`
|
|
124
|
+
|
|
125
|
+
## Scratch Space
|
|
126
|
+
|
|
127
|
+
- Use `.agent/tmp/` for repo-local temporary files created during completion work.
|
|
128
|
+
- `.agent/tmp/` is scratch space only. Do not treat it as canonical state or durable handoff storage.
|
|
129
|
+
- Keep `.agent/tmp/` ignored in `.gitignore` alongside other non-contract `.agent/*` execution artifacts.
|
|
130
|
+
- Use OS temp only when a tool explicitly requires it, and prefer `$TMPDIR/pi-completion/<repo-name>/` over broad `/tmp` usage.
|
|
131
|
+
|
|
132
|
+
## Compaction And Recovery
|
|
133
|
+
|
|
134
|
+
Canonical truth remains in `.agent/**`.
|
|
135
|
+
|
|
136
|
+
After context compaction, suspected memory loss, stalled-role recovery, or any ambiguous completion state, the workflow driver must re-read:
|
|
137
|
+
|
|
138
|
+
- `.agent/state.json`
|
|
139
|
+
- `.agent/plan.json`
|
|
140
|
+
- `.agent/active-slice.json`
|
|
141
|
+
|
|
142
|
+
The workflow driver must invoke `completion-regrounder` before continuing whenever any of the following is true:
|
|
143
|
+
|
|
144
|
+
- `requires_reground` is `true`
|
|
145
|
+
- `requires_reground` is unknown because canonical state is missing or unreadable
|
|
146
|
+
- `next_mandatory_action` is missing, unknown, or ambiguous
|
|
147
|
+
- `active-slice.json` does not match `.agent/plan.json`
|
|
148
|
+
- acceptance criteria for the selected or active slice are missing or unclear
|
|
149
|
+
- the exact implementer handoff snapshot in `.agent/active-slice.json` is missing, stale, or contradictory
|
|
150
|
+
|
|
151
|
+
The workflow driver must not continue implementation, review, audit, or stop evaluation from compacted conversation memory alone.
|
|
152
|
+
|
|
153
|
+
After compaction or recovery, `completion-implementer` must also re-read canonical `.agent/state.json`, `.agent/plan.json`, and `.agent/active-slice.json` before resuming work. If `.agent/active-slice.json` still contains a truthful exact handoff snapshot, continue from canonical state rather than asking the user to resend the original caller payload.
|
|
154
|
+
|
|
155
|
+
## Shared Report Header
|
|
156
|
+
|
|
157
|
+
All completion reports must begin with:
|
|
158
|
+
|
|
159
|
+
- `MISSION ANCHOR: ...`
|
|
160
|
+
- `Remaining contract IDs: ...`
|
|
161
|
+
|
|
162
|
+
If a role-specific fixed format uses before/after wording, keep the same mission-anchor first line and then follow that role's exact format.
|
|
163
|
+
|
|
164
|
+
## References
|
|
165
|
+
|
|
166
|
+
Read these bundled references when you need the full protocol or scaffolding material:
|
|
167
|
+
|
|
168
|
+
- `references/completion.md`
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# completion
|
|
2
|
+
|
|
3
|
+
`completion` is a repo-local control-plane protocol for long-running software-project completion work.
|
|
4
|
+
|
|
5
|
+
## Tracked Repo-Contract Files
|
|
6
|
+
|
|
7
|
+
- `.agent/README.md`
|
|
8
|
+
- `.agent/mission.md`
|
|
9
|
+
- `.agent/profile.json`
|
|
10
|
+
- `.agent/verify_completion_stop.sh`
|
|
11
|
+
- `.agent/verify_completion_control_plane.sh`
|
|
12
|
+
|
|
13
|
+
## Ignored Canonical Execution State
|
|
14
|
+
|
|
15
|
+
- `.agent/state.json`
|
|
16
|
+
- `.agent/plan.json`
|
|
17
|
+
- `.agent/active-slice.json`
|
|
18
|
+
- `.agent/slice-history.jsonl`
|
|
19
|
+
- `.agent/stop-check-history.jsonl`
|
|
20
|
+
- `.agent/*.log`
|
|
21
|
+
|
|
22
|
+
## Scratch Space
|
|
23
|
+
|
|
24
|
+
- Use repo-local `.agent/tmp/` as the default temporary workspace for completion.
|
|
25
|
+
- Keep `.agent/tmp/` ignored in `.gitignore` alongside other non-contract `.agent/*` execution artifacts.
|
|
26
|
+
- Do not write scratch artifacts to `/tmp` or `/private/tmp` by default.
|
|
27
|
+
- If a tool explicitly requires OS temp, prefer a scoped path such as `$TMPDIR/pi-completion/<repo-name>/` and treat it as disposable.
|
|
28
|
+
- Do not store canonical state, required verification evidence, or the only copy of a deliverable exclusively in scratch paths.
|
|
29
|
+
|
|
30
|
+
## Fixed Profile Schema
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"schema_version": 1,
|
|
35
|
+
"protocol_id": "completion",
|
|
36
|
+
"project_name": "<repo-name>",
|
|
37
|
+
"required_stop_judges": 3,
|
|
38
|
+
"priority_policy_id": "completion-default",
|
|
39
|
+
"docs_surfaces": ["README.md", "docs/"]
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Fixed State Model
|
|
44
|
+
|
|
45
|
+
`state.json` carries the current authoritative summary.
|
|
46
|
+
|
|
47
|
+
Required fields:
|
|
48
|
+
|
|
49
|
+
- `schema_version`
|
|
50
|
+
- `mission_anchor`
|
|
51
|
+
- `current_phase`
|
|
52
|
+
- `continuation_policy`
|
|
53
|
+
- `continuation_reason`
|
|
54
|
+
- `project_done`
|
|
55
|
+
- `requires_reground`
|
|
56
|
+
- `slices_since_last_reground`
|
|
57
|
+
- `remaining_release_blockers`
|
|
58
|
+
- `remaining_high_value_gaps`
|
|
59
|
+
- `unsatisfied_contract_ids`
|
|
60
|
+
- `release_blocker_ids`
|
|
61
|
+
- `next_mandatory_action`
|
|
62
|
+
- `next_mandatory_role`
|
|
63
|
+
- `remaining_stop_judges`
|
|
64
|
+
- `last_reground_at`
|
|
65
|
+
- `last_auditor_verdict`
|
|
66
|
+
- `contract_status`
|
|
67
|
+
- `latest_completed_slice`
|
|
68
|
+
- `latest_verified_slice`
|
|
69
|
+
|
|
70
|
+
`continuation_policy` must be one of:
|
|
71
|
+
|
|
72
|
+
- `continue`
|
|
73
|
+
- `await_user_input`
|
|
74
|
+
- `blocked`
|
|
75
|
+
- `paused`
|
|
76
|
+
- `done`
|
|
77
|
+
|
|
78
|
+
`next_mandatory_role` must be one of:
|
|
79
|
+
|
|
80
|
+
- `completion-bootstrapper`
|
|
81
|
+
- `completion-regrounder`
|
|
82
|
+
- `completion-implementer`
|
|
83
|
+
- `completion-reviewer`
|
|
84
|
+
- `completion-auditor`
|
|
85
|
+
- `completion-stop-judge`
|
|
86
|
+
- `null`
|
|
87
|
+
|
|
88
|
+
`current_phase` must be one of:
|
|
89
|
+
|
|
90
|
+
- `reground`
|
|
91
|
+
- `implement`
|
|
92
|
+
- `post_commit_review`
|
|
93
|
+
- `post_commit_audit`
|
|
94
|
+
- `post_commit_reconcile`
|
|
95
|
+
- `stop_wave`
|
|
96
|
+
- `awaiting_user`
|
|
97
|
+
- `blocked`
|
|
98
|
+
- `done`
|
|
99
|
+
|
|
100
|
+
Rules:
|
|
101
|
+
|
|
102
|
+
1. `continuation_policy == continue` means the workflow root must keep advancing and must not stop after a slice to ask whether to continue.
|
|
103
|
+
2. `continuation_policy == await_user_input` means the workflow root must ask only for the exact missing input and then stop.
|
|
104
|
+
3. `continuation_policy == blocked` means the workflow root must report the blocker and stop.
|
|
105
|
+
4. `continuation_policy == paused` means the user explicitly paused the workflow.
|
|
106
|
+
5. `continuation_policy == done` means canonical final stop reconciliation is complete and the workflow may stop.
|
|
107
|
+
|
|
108
|
+
`plan.json` carries the ordered persistent slice backlog.
|
|
109
|
+
|
|
110
|
+
Required fields:
|
|
111
|
+
|
|
112
|
+
- `schema_version`
|
|
113
|
+
- `mission_anchor`
|
|
114
|
+
- `last_reground_at`
|
|
115
|
+
- `plan_basis`
|
|
116
|
+
- `candidate_slices`
|
|
117
|
+
|
|
118
|
+
Each `candidate_slices[]` entry must include:
|
|
119
|
+
|
|
120
|
+
- `slice_id`
|
|
121
|
+
- `goal`
|
|
122
|
+
- `acceptance_criteria`
|
|
123
|
+
- `contract_ids`
|
|
124
|
+
- `priority`
|
|
125
|
+
- `status` where status is one of `planned`, `selected`, `in_progress`, `blocked`, `done`, `cancelled`
|
|
126
|
+
- `why_now`
|
|
127
|
+
- `blocked_on`
|
|
128
|
+
- `evidence`
|
|
129
|
+
|
|
130
|
+
### Acceptance Criteria Contract
|
|
131
|
+
|
|
132
|
+
`acceptance_criteria` is a non-empty list of concrete, verifiable conditions that define when a slice is done.
|
|
133
|
+
|
|
134
|
+
Rules:
|
|
135
|
+
|
|
136
|
+
1. Set at re-ground time. Every slice in `candidate_slices` must have `acceptance_criteria` populated during the re-ground wave that first introduces or re-evaluates it. A slice with empty `acceptance_criteria` is invalid.
|
|
137
|
+
2. Immutable after lock. Once a slice's `acceptance_criteria` are set, subsequent re-ground waves must not weaken, replace, or silently drop criteria. The only allowed mutations are:
|
|
138
|
+
- removing a criterion because repo truth already satisfies it, with `evidence` updated to prove it
|
|
139
|
+
- adding a criterion discovered during implementation that was missing from the original assessment
|
|
140
|
+
3. Done requires all satisfied. A slice may only transition to `done` when every acceptance criterion is satisfied and `evidence` contains the proof for each one.
|
|
141
|
+
4. Re-ground validation. During re-ground, the current slice backlog must be revalidated against repo truth. A slice previously marked `done` whose criteria no longer hold must be reopened.
|
|
142
|
+
5. Clean handoff before next slice. After a committed slice is reviewed and audited, the tracked and unignored worktree must be clean before the next slice is selected.
|
|
143
|
+
|
|
144
|
+
`active-slice.json` carries one current slice cursor.
|
|
145
|
+
|
|
146
|
+
When `status` is `selected`, `in_progress`, `committed`, or `done`, `active-slice.json` must also carry the exact implementer handoff snapshot so `completion-implementer` can resume after compaction without asking the user to resend the original caller payload.
|
|
147
|
+
|
|
148
|
+
Required exact handoff fields:
|
|
149
|
+
|
|
150
|
+
- `acceptance_criteria`
|
|
151
|
+
- `priority`
|
|
152
|
+
- `why_now`
|
|
153
|
+
- `blocked_on`
|
|
154
|
+
- `locked_notes`
|
|
155
|
+
- `must_fix_findings`
|
|
156
|
+
- `basis_commit`
|
|
157
|
+
- `remaining_contract_ids_before`
|
|
158
|
+
- `release_blocker_count_before`
|
|
159
|
+
- `high_value_gap_count_before`
|
|
160
|
+
|
|
161
|
+
Allowed `status` values:
|
|
162
|
+
|
|
163
|
+
- `idle`
|
|
164
|
+
- `selected`
|
|
165
|
+
- `in_progress`
|
|
166
|
+
- `committed`
|
|
167
|
+
- `done`
|
|
168
|
+
|
|
169
|
+
`slice-history.jsonl` is append-only and only accepts:
|
|
170
|
+
|
|
171
|
+
- `implemented`
|
|
172
|
+
- `reviewed`
|
|
173
|
+
- `audited`
|
|
174
|
+
- `accepted`
|
|
175
|
+
- `reopened`
|
|
176
|
+
|
|
177
|
+
Minimum record shape:
|
|
178
|
+
|
|
179
|
+
- `schema_version`
|
|
180
|
+
- `type`
|
|
181
|
+
- `recorded_at`
|
|
182
|
+
- `slice_id`
|
|
183
|
+
- `commit_sha`
|
|
184
|
+
- `head_sha`
|
|
185
|
+
|
|
186
|
+
`stop-check-history.jsonl` is append-only and only accepts:
|
|
187
|
+
|
|
188
|
+
- `judgment`
|
|
189
|
+
|
|
190
|
+
Minimum record shape:
|
|
191
|
+
|
|
192
|
+
- `schema_version`
|
|
193
|
+
- `type`
|
|
194
|
+
- `recorded_at`
|
|
195
|
+
- `head_sha`
|
|
196
|
+
- `can_stop`
|
|
197
|
+
- `blocker_count`
|
|
198
|
+
- `high_value_gap_count`
|
|
199
|
+
|
|
200
|
+
Empty history files are legal.
|
|
201
|
+
|
|
202
|
+
## One-Slice Lifecycle
|
|
203
|
+
|
|
204
|
+
1. Re-ground from current repo truth.
|
|
205
|
+
2. Choose exactly one highest-value slice.
|
|
206
|
+
3. Mark that slice in canonical state.
|
|
207
|
+
4. Implement the smallest correct tracked-file change.
|
|
208
|
+
5. Add tests or deterministic proof that satisfy one or more `acceptance_criteria`.
|
|
209
|
+
6. Run focused verification first, then broader verification if needed.
|
|
210
|
+
7. Commit.
|
|
211
|
+
8. Update canonical state and append one `implemented` record.
|
|
212
|
+
9. Run read-only review and audit.
|
|
213
|
+
10. Confirm the tracked and unignored worktree is clean before selecting the next slice.
|
|
214
|
+
11. Append `reviewed`, `audited`, and `accepted` or `reopened`.
|
|
215
|
+
12. Repeat until the stop wave concludes the repo may stop.
|
|
216
|
+
|
|
217
|
+
## Workflow Topology
|
|
218
|
+
|
|
219
|
+
The workflow topology is mandatory and flat:
|
|
220
|
+
|
|
221
|
+
1. The main pi session stays the workflow root.
|
|
222
|
+
2. The main pi session invokes at most one completion role at a time.
|
|
223
|
+
3. `completion-bootstrapper` is used only for first-time setup or missing tracked contract-file repair.
|
|
224
|
+
4. `completion-regrounder` is the mandatory role for canonical `.agent` reconciliation, slice selection, post-review or post-audit reconciliation, and final stop reconciliation.
|
|
225
|
+
5. `completion-implementer`, `completion-reviewer`, `completion-auditor`, and `completion-stop-judge` are sibling roles invoked directly by the workflow root.
|
|
226
|
+
6. No completion role may invoke another completion role during the normal workflow.
|
|
227
|
+
|
|
228
|
+
## Primary Workflow Driver Contract
|
|
229
|
+
|
|
230
|
+
The main pi session may:
|
|
231
|
+
|
|
232
|
+
- read repo truth and canonical `.agent` state
|
|
233
|
+
- update canonical `.agent/**` state truthfully for handoff
|
|
234
|
+
- invoke the correct completion role according to the mandatory dispatch table
|
|
235
|
+
- append canonical history records as a faithful transcription of actual role outputs
|
|
236
|
+
|
|
237
|
+
It must not, while a slice is selected or in progress:
|
|
238
|
+
|
|
239
|
+
- directly edit non-`.agent/**` tracked product/docs/config/test files for that slice
|
|
240
|
+
- directly create the slice commit
|
|
241
|
+
- directly claim review/audit/acceptance/judgment outcomes without the corresponding role output
|
|
242
|
+
- bypass mandatory completion-role dispatch for convenience
|
|
243
|
+
- hand control back to the user between slices merely to ask whether to continue when `continuation_policy == continue`
|
|
244
|
+
|
|
245
|
+
## Mandatory Dispatch Table
|
|
246
|
+
|
|
247
|
+
1. If tracked protocol contract files are missing or first-time onboarding is required, invoke `completion-bootstrapper`.
|
|
248
|
+
2. If canonical `.agent` execution state is missing, stale, invalid, contradictory, or ambiguous after compaction or recovery, invoke `completion-regrounder` first.
|
|
249
|
+
3. If no slice is selected, invoke `completion-regrounder` to reconcile `.agent/plan.json` and return the next exact handoff payload.
|
|
250
|
+
4. If a slice is `selected` or `in_progress` and no new commit exists for it yet, invoke `completion-implementer`.
|
|
251
|
+
5. If the latest committed slice lacks review, invoke `completion-reviewer`.
|
|
252
|
+
6. If the latest committed slice lacks audit, invoke `completion-auditor`.
|
|
253
|
+
7. If canonical reconciliation is needed after review or audit, invoke `completion-regrounder`.
|
|
254
|
+
8. If all slices are done and final closure is under evaluation, invoke the required `completion-stop-judge` sessions directly.
|
|
255
|
+
9. After the required judgments are recorded, rerun `bash .agent/verify_completion_stop.sh` and invoke `completion-regrounder` for final stop reconciliation.
|
|
256
|
+
|
|
257
|
+
## Compaction And Recovery
|
|
258
|
+
|
|
259
|
+
After context compaction, suspected memory loss, stalled-role recovery, or any ambiguous completion state, the workflow root must re-read:
|
|
260
|
+
|
|
261
|
+
- `.agent/state.json`
|
|
262
|
+
- `.agent/plan.json`
|
|
263
|
+
- `.agent/active-slice.json`
|
|
264
|
+
|
|
265
|
+
The workflow root must invoke `completion-regrounder` before continuing whenever any of the following is true:
|
|
266
|
+
|
|
267
|
+
- `requires_reground` is `true`
|
|
268
|
+
- `requires_reground` is unknown because canonical state is missing or unreadable
|
|
269
|
+
- `next_mandatory_action` is missing, unknown, or ambiguous
|
|
270
|
+
- `active-slice.json` does not match `.agent/plan.json`
|
|
271
|
+
- acceptance criteria for the selected or active slice are missing or unclear
|
|
272
|
+
- the exact implementer handoff snapshot in `.agent/active-slice.json` is missing, stale, or contradictory
|
|
273
|
+
|
|
274
|
+
The workflow root must not continue implementation, review, audit, or stop evaluation from compacted conversation memory alone.
|
|
275
|
+
|
|
276
|
+
## Default Priority Policy
|
|
277
|
+
|
|
278
|
+
`completion-default` ranks candidate slices in this order:
|
|
279
|
+
|
|
280
|
+
1. shipped behavior versus docs/config mismatch
|
|
281
|
+
2. safety, security, data-loss, fail-open, or fail-closed critical behavior
|
|
282
|
+
3. startup, install, migration, or restart critical path
|
|
283
|
+
4. operator emergency, rollback, or recovery path
|
|
284
|
+
5. normal primary lifecycle path
|
|
285
|
+
6. docs/config/runbook parity
|
|
286
|
+
7. regression depth
|
|
287
|
+
8. final closure and hygiene
|