its-magic 0.1.2-35 → 0.1.2-37

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.
@@ -15,58 +15,37 @@ description: "its-magic auto: deterministic continuation orchestrator."
15
15
  - Scope is process/workflow orchestration only. Do not claim runtime product
16
16
  orchestration changes.
17
17
 
18
- ## Per-phase isolation enforcement (US-0048 / DEC-0029)
18
+ ## Full specification (US-0080 / DEC-0062)
19
+
20
+ Long prose, expanded mode semantics, and **Steps 1–13** detail live in
21
+ **`docs/engineering/auto-orchestration-reference.md`** (jointly normative). This file
22
+ keeps **contract excerpts** required for regression parity and default `/auto` loads.
19
23
 
20
- `/auto` must enforce fresh-context isolation as a fail-closed contract:
24
+ ## Per-phase isolation enforcement (US-0048 / DEC-0029)
21
25
 
22
- - `/auto` must not write phase deliverables itself. If phase work is performed in
23
- the orchestrator context, stop immediately with reason code
24
- `PHASE_CONTEXT_ISOLATION_VIOLATION`.
25
- - Each spawned phase must write isolation evidence with required fields
26
- (`phase_id`, `role`, `fresh_context_marker`, `timestamp`, `evidence_ref`) to
27
- the canonical evidence store (`docs/engineering/state.md`) before `/auto`
28
- proceeds to the next phase.
29
- - `/auto` must fail closed when evidence is missing/invalid/stale (see reason
30
- codes below). No silent continuation.
26
+ - Orchestrator must not write phase deliverables (`PHASE_CONTEXT_ISOLATION_VIOLATION`).
27
+ - Each spawned phase appends isolation evidence to `docs/engineering/state.md`
28
+ with `phase_id`, `role`, `fresh_context_marker`, `timestamp`, `evidence_ref`.
29
+ - Fail closed on missing/invalid/stale evidence.
31
30
 
32
- Reason codes (deterministic):
33
- - `PHASE_CONTEXT_ISOLATION_MISSING`
34
- - `PHASE_CONTEXT_ISOLATION_VIOLATION`
35
- - `ISOLATION_EVIDENCE_STALE`
36
- - `ISOLATION_EVIDENCE_INVALID`
31
+ Reason codes: `PHASE_CONTEXT_ISOLATION_MISSING`, `PHASE_CONTEXT_ISOLATION_VIOLATION`,
32
+ `ISOLATION_EVIDENCE_STALE`, `ISOLATION_EVIDENCE_INVALID`.
37
33
 
38
34
  ## Strict runtime proof enforcement (US-0056 / DEC-0038)
39
35
 
40
- `/auto` must enforce strict runtime attestation in addition to artifact-level
41
- isolation evidence:
42
-
43
- - Each completed phase must provide a runtime attestation tuple linked to the
44
- phase checkpoint evidence:
45
- - `orchestrator_run_id`
46
- - `runtime_proof_id`
47
- - `phase_id`
48
- - `role`
49
- - `proof_issued_at` (ISO UTC / RFC3339)
50
- - `proof_ttl_seconds`
51
- - `proof_hash`
52
- - `runtime_proof_id` must be unique per phase run; reused proof IDs are invalid.
53
- - Proof freshness must be validated against `proof_issued_at` + TTL policy.
54
- - Proof linkage must be deterministic and auditable to checkpoint evidence refs.
55
- - Fail closed on any strict-proof violation; no silent continuation.
56
-
57
- Strict-proof reason codes:
58
- - `RUNTIME_PROOF_MISSING`
59
- - `RUNTIME_PROOF_INVALID`
60
- - `RUNTIME_PROOF_REUSED`
61
- - `RUNTIME_PROOF_STALE`
62
- - `RUNTIME_PROOF_AMBIGUOUS_LINK`
36
+ - Each completed phase supplies tuple: `orchestrator_run_id`, `runtime_proof_id`,
37
+ `phase_id`, `role`, `proof_issued_at`, `proof_ttl_seconds`, `proof_hash`
38
+ (hash = SHA-256 sorted-key JSON per **DEC-0038**).
39
+ - `runtime_proof_id` unique per phase run; enforce TTL freshness and linkage.
40
+
41
+ Reason codes: `RUNTIME_PROOF_MISSING`, `RUNTIME_PROOF_INVALID`, `RUNTIME_PROOF_REUSED`,
42
+ `RUNTIME_PROOF_STALE`, `RUNTIME_PROOF_AMBIGUOUS_LINK`.
63
43
 
64
44
  ## Strict phase role enforcement (US-0069 / DEC-0051)
65
45
 
66
- `/auto` must enforce a deterministic **phase→role contract** with **preflight
67
- admission** before each phase spawn, **fail-closed checkpoint validation** after
68
- each phase completes, and **aligned strict-proof `role`** values. Post-hoc
69
- isolation markers alone are insufficient.
46
+ Post-hoc markers alone are insufficient: preflight expected role, capability gate,
47
+ post-completion match of isolation + strict-proof `role`, execute default deny unless
48
+ override governance is satisfied.
70
49
 
71
50
  ### Canonical phase→role matrix (fixed defaults)
72
51
 
@@ -84,391 +63,74 @@ isolation markers alone are insufficient.
84
63
  | `release` | `release` | `release` |
85
64
  | `refresh-context` | `curator`, `po` | `curator` |
86
65
 
87
- ### Alternate-role scratchpad policy (single-valued resolution)
88
-
89
- Resolve **exactly one** expected role for phases with alternates using merged
90
- scratchpad (active + `.cursor/scratchpad.local.md`; template parity on install):
91
-
92
- - `AUTO_ROLE_RESEARCH`: `po` \| `tech-lead` — when **unset or empty**, default
93
- `tech-lead`; when set to any other value, fail closed with diagnostics (no
94
- unrelated-role fallback).
95
- - `AUTO_ROLE_PLAN_VERIFY`: `qa` \| `tech-lead` — when **unset or empty**,
96
- default `qa`; otherwise only `qa` or `tech-lead` allowed (else fail closed).
97
- - `AUTO_ROLE_REFRESH_CONTEXT`: `curator` \| `po` — when **unset or empty**,
98
- default `curator`; otherwise only `curator` or `po` allowed (else fail closed).
99
-
100
- ### Preflight capability gate (before spawn)
101
-
102
- Before spawning phase work, `/auto` must:
103
-
104
- 1. Resolve `phase_id` → expected canonical `role` (matrix + policy keys above).
105
- 2. For `execute`, apply **default deny**: expected role is `dev` unless **both**
106
- `AUTO_EXECUTE_ROLE_OVERRIDE=allowed_non_dev_execute` **and**
107
- `EXECUTE_OVERRIDE_GOVERNANCE_REF` point to a **parseable** approved exception
108
- record (for example `DEC-xxxx` or a documented anchor in
109
- `docs/engineering/state.md`).
110
- 3. Evaluate **role capability availability** for that boundary (subagent/tooling
111
- can satisfy the resolved role).
112
- 4. On missing capability: stop with `PHASE_ROLE_CAPABILITY_MISSING` including
113
- `phase_id`, expected role, observed capability result, and remediation. **Do
114
- not** spawn under a substitute unrelated role.
115
-
116
- ### Post-completion boundary validation
117
-
118
- When a phase completes, before advancing:
119
-
120
- - Isolation evidence `role` must equal the **same** preflight-resolved expected
121
- role for that `phase_id`. Else stop with `PHASE_ROLE_MISMATCH`.
122
- - Strict-proof tuple `role` must equal isolation `role` and the expected role.
123
- - `proof_hash` must be SHA-256 over canonical sorted-key JSON of
124
- `orchestrator_run_id`, `runtime_proof_id`, `phase_id`, `role`,
125
- `proof_issued_at`, `proof_ttl_seconds` (`DEC-0038` / architecture US-0069).
66
+ Alternate-role keys (merged scratchpad): `AUTO_ROLE_RESEARCH`, `AUTO_ROLE_PLAN_VERIFY`,
67
+ `AUTO_ROLE_REFRESH_CONTEXT` — single-valued resolution per **DEC-0051** (see reference).
126
68
 
127
- ### Resume / `start-from` parity
69
+ Execute override: requires `AUTO_EXECUTE_ROLE_OVERRIDE=allowed_non_dev_execute` **and**
70
+ parseable `EXECUTE_OVERRIDE_GOVERNANCE_REF`.
128
71
 
129
- Every `/auto` invocation (explicit `start-from`, `resume_brief`, or conservative
130
- `state.md` fallback) must **recompute** policy resolution and preflight from
131
- scratch; stale continuation artifacts must not bypass the gate.
132
-
133
- ### Role-enforcement reason codes (deterministic)
134
-
135
- - `PHASE_ROLE_CAPABILITY_MISSING`
136
- - `PHASE_ROLE_MISMATCH`
72
+ Role reason codes: `PHASE_ROLE_CAPABILITY_MISSING`, `PHASE_ROLE_MISMATCH`.
137
73
 
138
74
  ## Configurable phase selection policy (US-0070 / DEC-0052)
139
75
 
140
- `/auto` must treat the **resolved phase plan** as a first-class, fail-closed
141
- schedule: a single ordered subset of canonical phases computed from merged
142
- scratchpad (active + `.cursor/scratchpad.local.md`; template parity on install),
143
- **before** resume/`start-from` intersection and **before** any phase spawn.
76
+ Treat **resolved phase plan** as fail-closed schedule from merged scratchpad **before**
77
+ resume / `start-from` intersection. Canonical lifecycle:
144
78
 
145
- ### Canonical lifecycle order (baseline `full` plan)
79
+ `intake` `discovery` `research` `architecture` → `sprint-plan` →
80
+ `plan-verify` → `execute` → `qa` → `verify-work` → `release` → `refresh-context`
146
81
 
147
- Unless narrowed by policy, the canonical ordered phase list is:
82
+ Selectors and reinstatement: see reference. Phase-plan reason codes include
83
+ `PHASE_POLICY_CONFLICT`, `PHASE_PLAN_UNKNOWN_PHASE`, `START_FROM_PHASE_PLAN_EMPTY_INTERSECTION`.
148
84
 
149
- `intake` `discovery` `research` `architecture` → `sprint-plan` →
150
- `plan-verify` `execute` `qa` `verify-work` → `release` →
151
- `refresh-context`
152
-
153
- When `SECURITY_REVIEW=1`, insert `/security-review` in **design** mode
154
- immediately after `architecture` and before `sprint-plan`, and in **code** mode
155
- immediately after `execute` and before `qa`, as documented in **Steps** below.
156
- Record these inserts in `resolved_phase_plan` breadcrumbs using the same
157
- deterministic labels the orchestrator already uses for security boundaries.
158
-
159
- ### Scratchpad selectors (exactly one active policy mode)
160
-
161
- At most one of the following may be materially active after merge. If two or
162
- more non-default selectors conflict, fail closed with `PHASE_POLICY_CONFLICT`
163
- and **do not** materialize a plan:
164
-
165
- - `AUTO_PHASE_PLAN=full` — full canonical lifecycle (including security-review
166
- inserts when enabled). Default when unset and no other selector is set.
167
- - `AUTO_PHASE_EXCLUDE=<csv>` — start from `full`, remove listed phase IDs
168
- (validate each token; unknown id → `PHASE_PLAN_UNKNOWN_PHASE`).
169
- - `AUTO_PHASE_INCLUDE=<csv>` — schedule **only** listed ids, then **re-sort**
170
- into canonical lifecycle order. Unknown id → `PHASE_PLAN_UNKNOWN_PHASE`.
171
- Empty result after parsing → `PHASE_PLAN_EMPTY_INCLUDE`.
172
- - `AUTO_PHASE_PROFILE=<name>` — expand a **named profile** from the registry
173
- below. Unknown profile → `PHASE_PLAN_UNKNOWN_PROFILE`.
174
-
175
- **Conflict rule**: `AUTO_PHASE_PLAN` is default-only when it is unset, empty, or
176
- exactly `full`. Any explicit non-`full` `AUTO_PHASE_PLAN` value is invalid
177
- (fail closed with `PHASE_PLAN_INVALID_AUTO_PHASE_PLAN`) — use `INCLUDE` /
178
- `EXCLUDE` / `PROFILE` instead.
179
-
180
- ### Profile registry (baseline)
181
-
182
- - `default` — equivalent to `full` (optional explicit alias; same behavior as
183
- unset policy).
184
-
185
- **High-risk profile sketch** (illustrative; `R-0049`): `profile_high_risk_dev_fast`
186
- may only be selected when **both** hold: `AUTO_PHASE_PROFILE=profile_high_risk_dev_fast`
187
- and `AUTO_PHASE_HIGH_RISK_ACK=<operator_token>` matches the profile spec
188
- version documented in `decisions/DEC-0052.md` / research `R-0049`. Missing ack →
189
- `PHASE_PLAN_HIGH_RISK_ACK_REQUIRED`. High-risk profiles may define **narrower**
190
- reinstatement rules **only** as documented for that profile; default profile
191
- behavior applies otherwise.
192
-
193
- ### Plan materialization pipeline (evaluation order)
194
-
195
- On every `/auto` entry (including resume, backlog-drain, bulk execute, and
196
- team-mode runs), **recompute** from merged scratchpad:
197
-
198
- 1. Parse merged scratchpad policy inputs for phase selection + `SECURITY_REVIEW`.
199
- 2. Detect active policy mode; on conflict → `PHASE_POLICY_CONFLICT` (no plan).
200
- 3. Expand mode to a **candidate** ordered phase list in canonical order.
201
- 4. Apply **non-skippable reinstatement** for the **default profile** (and for
202
- any profile that does not explicitly document a narrower exception with ack):
203
- - **Safety gates**: always reinstate if removed: `qa`, `verify-work`,
204
- `release`.
205
- - **Evidence-chain closure**: if the candidate retains any phase from
206
- `execute` onward (`execute`, optional `security-review-code`, `qa`,
207
- `verify-work`, `release`, `refresh-context`), reinstate (if removed) the
208
- contiguous canonical prefix from `intake` through `plan-verify` so later
209
- gates retain valid upstream isolation + strict-proof chain semantics.
210
- - When `SECURITY_REVIEW=1`, reinstate the corresponding `security-review-*`
211
- insert when the adjacent retained phases would otherwise violate the
212
- documented security boundary contract.
213
- Record each reinstatement in breadcrumbs with reason `non_skippable_gate`
214
- (or a more specific documented code).
215
- 5. Record **operator-visible plan breadcrumbs** to `docs/engineering/state.md`
216
- **before** first spawn (append-bottom per `DEC-0040`):
217
- - `phase_policy_mode` (`full|exclude|include|profile`)
218
- - `resolved_phase_plan` (ordered `phase_id` list)
219
- - `skipped_phases` (id + reason: `policy_exclude`, `non_skippable_gate`,
220
- `default_full_plan`, etc.)
221
- - `orchestrator_run_id` (when known for this run)
222
- 6. **Do not** silently revive phases omitted by policy on continuation: every
223
- entry re-reads scratchpad bytes and recomputes the plan class.
224
-
225
- ### `start-from` and resume intersection with the resolved plan
226
-
227
- After computing the **resolved phase plan**, resolve the **nominal** start
228
- phase using **Deterministic resume-source precedence** (explicit `start-from`
229
- → `resume_brief` → `state` fallback → fail-fast).
230
-
231
- Then **intersect**:
232
-
233
- - Keep phases that appear in the resolved plan **in plan order**, starting at
234
- the first plan phase whose canonical position is **at or after** the nominal
235
- anchor phase (canonical order matches the baseline list above, including
236
- security inserts when enabled).
237
- - If the intersection is empty, fail closed with
238
- `START_FROM_PHASE_PLAN_EMPTY_INTERSECTION` and diagnostics listing
239
- `resolved_phase_plan` vs `requested_start_phase` / resume inference.
240
-
241
- ### Compatibility with `US-0069` / `DEC-0051`
242
-
243
- - Role resolution and preflight apply **only** to phases present in the
244
- intersected schedule. Skipping `research` does **not** change the expected
245
- role for `architecture` or any other retained phase.
246
- - Skipped phases produce **no** spawn and **no** alternate-role substitution
247
- for a different phase.
248
-
249
- ### Phase-plan reason codes (deterministic)
250
-
251
- Add to operator diagnostics and breadcrumb records:
252
-
253
- - `PHASE_POLICY_CONFLICT`
254
- - `PHASE_PLAN_UNKNOWN_PHASE`
255
- - `PHASE_PLAN_EMPTY_INCLUDE`
256
- - `PHASE_PLAN_UNKNOWN_PROFILE`
257
- - `PHASE_PLAN_INVALID_AUTO_PHASE_PLAN`
258
- - `PHASE_PLAN_HIGH_RISK_ACK_REQUIRED`
259
- - `START_FROM_PHASE_PLAN_EMPTY_INTERSECTION`
260
-
261
- ### Phase boundary operator visibility (AC-10)
262
-
263
- At each phase boundary (after completing a scheduled phase), record a compact
264
- **phase boundary status** entry (for example in `docs/engineering/state.md`
265
- continuation breadcrumbs) including:
266
-
267
- - `resolved_phase_plan` snapshot (or stable hash pointer to the run’s plan record)
268
- - `skipped_phases` summary (id + reason code)
269
- - `phase_boundary` (completed `phase_id`)
270
- - `next_scheduled_phase` (or `none` when complete/stopped)
85
+ Phase boundary visibility (**AC-10**): record `resolved_phase_plan` snapshot,
86
+ `skipped_phases`, `phase_boundary`, `next_scheduled_phase` on `state.md`.
271
87
 
272
88
  ## Inputs
273
- - Merged scratchpad policy (`US-0073` / `DEC-0055`): resolve flags from **local >
274
- materialized `.cursor/scratchpad.md` > `.cursor/scratchpad.local.example.md`**
275
- (installers materialize baseline when missing; missing required keys after merge
276
- must fail closed with `[SCRATCHPAD_MERGE_ERROR]` diagnostics, not silent defaults).
277
- - `AUTO_FLOW_MODE` and `PHASE_MODE` from merged scratchpad
278
- - `AUTO_IMPLEMENTATION_LOOP`, `AUTO_LOOP_MAX_CYCLES` from merged scratchpad
279
- - `AUTO_PAUSE_REQUEST`, `AUTO_PAUSE_POLICY` from merged scratchpad
280
- - `SECURITY_REVIEW`, `COMPLIANCE_PROFILES` from merged scratchpad
281
- - `AUTO_EXECUTE_BULK`, `AUTO_EXECUTE_MAX_ITEMS`, `AUTO_EXECUTE_ON_BLOCK`,
282
- `AUTO_EXECUTE_SELECTION`, `AUTO_TEAM_SCOPE_ENFORCE` from merged scratchpad
283
- - `AUTO_ROLE_RESEARCH`, `AUTO_ROLE_PLAN_VERIFY`, `AUTO_ROLE_REFRESH_CONTEXT`,
284
- `AUTO_EXECUTE_ROLE_OVERRIDE`, `EXECUTE_OVERRIDE_GOVERNANCE_REF` from merged
285
- scratchpad (US-0069 / DEC-0051)
286
- - `AUTO_PHASE_PLAN`, `AUTO_PHASE_EXCLUDE`, `AUTO_PHASE_INCLUDE`,
287
- `AUTO_PHASE_PROFILE`, `AUTO_PHASE_HIGH_RISK_ACK` from merged scratchpad
288
- (US-0070 / DEC-0052)
289
- - `TEAM_MODE`, `TEAM_MEMBER`, `ACTIVE_TASK_IDS` from merged scratchpad context
290
- - Current product and engineering docs
291
- - Optional explicit argument: `start-from=<phase>`
292
- - Optional explicit argument: `--execute-bulk` (one-run explicit override)
293
- - Resume-source artifacts:
294
- - `handoffs/resume_brief.md`
295
- - `docs/engineering/state.md`
89
+
90
+ Merged scratchpad (**US-0073** / **DEC-0055**), automation flags (`AUTO_*`, `SECURITY_REVIEW`,
91
+ `TEAM_*`), phase-plan keys `AUTO_PHASE_PLAN`, `AUTO_PHASE_EXCLUDE`, `AUTO_PHASE_INCLUDE`,
92
+ `AUTO_PHASE_PROFILE`, `AUTO_PHASE_HIGH_RISK_ACK`, product/engineering docs,
93
+ optional `start-from=<phase>`, optional `--execute-bulk`, `handoffs/resume_brief.md`,
94
+ `docs/engineering/state.md`.
296
95
 
297
96
  ## Canonical status contract (US-0045)
298
97
 
299
- - Story status authority is `docs/product/backlog.md` only.
300
- - `docs/product/acceptance.md` and `docs/engineering/state.md` are derived views.
301
- - `/auto` must not infer implementation readiness from non-canonical status
302
- artifacts when they conflict with backlog status.
98
+ Story status authority: `docs/product/backlog.md` only; do not infer readiness from
99
+ contradictory derived views.
303
100
 
304
101
  ## Outputs (artifacts)
305
- - Updated phase artifacts for each step
306
- - `docs/engineering/state.md`
307
- - `handoffs/resume_brief.md` if stopped
308
- - `sprints/S0001/qa-findings.md` and `handoffs/qa_to_dev.md` when loop finds issues
309
- - Deterministic continuation breadcrumbs in relevant artifacts
102
+
103
+ Phase artifacts, `docs/engineering/state.md`, `handoffs/resume_brief.md` when stopped,
104
+ QA loop handoffs when applicable, continuation breadcrumbs including `resolution_source`
105
+ (`argument|resume_brief|state_fallback`) and related resume metadata per reference.
310
106
 
311
107
  ## Stop conditions
312
- - Decision gate triggered
313
- - Missing critical input
314
- - `AUTO_PAUSE_REQUEST=1` reached at a safe boundary
315
- - `AUTO_LOOP_MAX_CYCLES` reached with unresolved defects
108
+
109
+ Decision gate, missing critical input, `AUTO_PAUSE_REQUEST` at safe boundary,
110
+ `AUTO_LOOP_MAX_CYCLES` with unresolved defects.
316
111
 
317
112
  ## Optional backlog-drain mode (US-0044 / DEC-0022)
318
113
 
319
- `/auto` supports an optional multi-story backlog-drain mode. Default behavior
320
- remains unchanged unless explicitly enabled.
321
-
322
- Canonical controls from `.cursor/scratchpad.md`:
323
- - `AUTO_BACKLOG_DRAIN`: `0|1` (default `0`)
324
- - `AUTO_BACKLOG_MAX_STORIES`: integer `>=1` (default `1`)
325
- - `AUTO_BACKLOG_ON_BLOCK`: `stop|skip` (default `stop`)
326
- - `AUTO_STORY_SELECTION`: `priority_then_backlog_order` (default)
327
-
328
- Deterministic behavior when enabled (`AUTO_BACKLOG_DRAIN=1`):
329
- - Select next eligible OPEN story via `AUTO_STORY_SELECTION`.
330
- - Run full story lifecycle (`discovery -> ... -> release -> refresh-context`).
331
- - After each story completion, continue to next eligible story until:
332
- - `AUTO_BACKLOG_MAX_STORIES` limit reached, or
333
- - no eligible stories remain, or
334
- - stop condition / decision gate occurs.
335
- - On blocked story:
336
- - `AUTO_BACKLOG_ON_BLOCK=stop` -> stop immediately.
337
- - `AUTO_BACKLOG_ON_BLOCK=skip` -> record skip reason and continue.
338
-
339
- Default-safe behavior:
340
- - With `AUTO_BACKLOG_DRAIN=0`, preserve existing single-segment continuation.
114
+ Canonical controls: `AUTO_BACKLOG_DRAIN`, `AUTO_BACKLOG_MAX_STORIES`, `AUTO_BACKLOG_ON_BLOCK`,
115
+ `AUTO_STORY_SELECTION`. Reason codes include `BACKLOG_MAX_STORIES_REACHED`. Full semantics:
116
+ reference.
341
117
 
342
118
  ## Optional bulk execute mode (US-0047 / DEC-0024)
343
119
 
344
- `/auto` supports an explicit bulk execute orchestration mode for continuous
345
- planned-item delivery. Default behavior remains unchanged unless explicitly
346
- enabled.
347
-
348
- Canonical controls from `.cursor/scratchpad.md`:
349
- - `AUTO_EXECUTE_BULK`: `0|1` (default `0`)
350
- - `AUTO_EXECUTE_MAX_ITEMS`: integer `>=1` (default `1`)
351
- - `AUTO_EXECUTE_ON_BLOCK`: `stop|skip` (default `stop`)
352
- - `AUTO_EXECUTE_SELECTION`: `planned_then_priority` (default)
353
- - `AUTO_TEAM_SCOPE_ENFORCE`: `0|1` (default `1`)
354
-
355
- Explicit activation contract:
356
- - Bulk execute mode is activated when either:
357
- - explicit argument `--execute-bulk` is present for this run, or
358
- - `AUTO_EXECUTE_BULK=1` in scratchpad.
359
- - Without explicit activation, preserve current non-bulk continuation behavior.
360
-
361
- Deterministic behavior when enabled:
362
- - Select next eligible planned work item via `AUTO_EXECUTE_SELECTION`.
363
- - Process each item with strict isolation:
364
- - fresh subagent per phase boundary
365
- - fresh subagent per execute<->QA loop cycle
366
- - Apply bounded stop criteria:
367
- - stop at `AUTO_EXECUTE_MAX_ITEMS`, or
368
- - stop/skip on blocked item per policy, or
369
- - stop when no eligible items remain.
370
-
371
- Team mode guardrails (`TEAM_MODE=1`):
372
- - Snapshot and record team context inputs:
373
- - `TEAM_MODE`, `TEAM_MEMBER`, `ACTIVE_TASK_IDS`
374
- - If `AUTO_TEAM_SCOPE_ENFORCE=1`, only tasks in current member scope are
375
- executable.
376
- - Out-of-scope tasks must be deterministically handled with no writes:
377
- - `stop` policy -> `EXEC_TEAM_SCOPE_BLOCKED`
378
- - `skip` policy -> `EXEC_TEAM_SCOPE_SKIPPED`
120
+ Explicit `--execute-bulk` or `AUTO_EXECUTE_BULK=1`. Reason codes include
121
+ `EXEC_BULK_MAX_ITEMS_REACHED`, `EXEC_TEAM_SCOPE_BLOCKED`, `EXEC_TEAM_SCOPE_SKIPPED`. Full
122
+ semantics: reference.
379
123
 
380
124
  ## Sync policy contract (US-0038 / DEC-0018)
381
125
 
382
- `/auto` may evaluate sync eligibility only at phase-completion boundaries.
383
- It remains process-level guidance (no runtime git orchestrator changes).
384
-
385
- Canonical policy controls from `.cursor/scratchpad.md`:
386
- - `SYNC_POLICY_MODE`:
387
- `disabled|manual|by_phase|by_milestone|custom_phase_list`
388
- - `SYNC_CUSTOM_PHASES`: comma-separated canonical phase IDs for
389
- `custom_phase_list` mode
390
- - `ALLOW_AUTO_PUSH`: `0|1`
391
- - `AUTO_PUSH_BRANCH_ALLOWLIST`: comma-separated branches/patterns
392
-
393
- Deterministic policy semantics:
394
- - `disabled`: skip sync evaluation entirely (`SYNC_DISABLED`).
395
- - `manual`: no auto-sync attempts (`MANUAL_MODE_NO_AUTO`).
396
- - `by_phase`: evaluate at every phase completion boundary.
397
- - `by_milestone`: evaluate only at milestone completion boundary.
398
- - `custom_phase_list`: evaluate only when completed phase is listed.
399
- - Unset/invalid mode fails closed to `manual`.
400
-
401
- Guarded auto-push eligibility chain (all required):
402
- 1. Boundary is eligible for configured mode.
403
- 2. `ALLOW_AUTO_PUSH=1`.
404
- 3. QA-first safety passes (feature work cannot auto-push before QA pass;
405
- manual user-invoked sync remains allowed).
406
- 4. No unresolved blocking QA findings / critical unresolved issues.
407
- 5. Branch safety passes: protected/default branches are denied by default unless
408
- explicitly allowlisted.
409
- 6. Mandatory pre-push checks pass:
410
- - `TEST_COMMAND` is required
411
- - optional `LINT_COMMAND` / `TYPECHECK_COMMAND` run only when configured
412
- - failures or timeout result in `no_push`
413
-
414
- If any condition fails, verdict is deterministic `no_push` with reason code.
415
-
416
- Reason-code baseline:
417
- - `SYNC_DISABLED`
418
- - `MANUAL_MODE_NO_AUTO`
419
- - `SYNC_TRIGGER_NOT_ELIGIBLE`
420
- - `AUTO_PUSH_NOT_ENABLED`
421
- - `PRE_QA_AUTOPUSH_FORBIDDEN`
422
- - `BLOCKING_QA_FINDINGS`
423
- - `BRANCH_NOT_ALLOWLISTED`
424
- - `TEST_COMMAND_MISSING`
425
- - `TEST_FAILED`
426
- - `TEST_TIMEOUT`
427
- - `OPTIONAL_CHECK_FAILED`
428
- - `SYNC_PUSHED`
429
- - `BACKLOG_DRAIN_DISABLED`
430
- - `BACKLOG_STORY_BLOCKED_STOP`
431
- - `BACKLOG_STORY_BLOCKED_SKIPPED`
432
- - `BACKLOG_MAX_STORIES_REACHED`
433
- - `BACKLOG_NO_ELIGIBLE_STORIES`
434
- - `EXEC_BULK_DISABLED`
435
- - `EXEC_BULK_ITEM_BLOCKED_STOP`
436
- - `EXEC_BULK_ITEM_BLOCKED_SKIPPED`
437
- - `EXEC_BULK_MAX_ITEMS_REACHED`
438
- - `EXEC_BULK_NO_ELIGIBLE_ITEMS`
439
- - `EXEC_TEAM_SCOPE_BLOCKED`
440
- - `EXEC_TEAM_SCOPE_SKIPPED`
441
- - `RUNTIME_PROOF_MISSING`
442
- - `RUNTIME_PROOF_INVALID`
443
- - `RUNTIME_PROOF_REUSED`
444
- - `RUNTIME_PROOF_STALE`
445
- - `RUNTIME_PROOF_AMBIGUOUS_LINK`
446
- - `PHASE_ROLE_CAPABILITY_MISSING`
447
- - `PHASE_ROLE_MISMATCH`
448
- - `PHASE_POLICY_CONFLICT`
449
- - `PHASE_PLAN_UNKNOWN_PHASE`
450
- - `PHASE_PLAN_EMPTY_INCLUDE`
451
- - `PHASE_PLAN_UNKNOWN_PROFILE`
452
- - `PHASE_PLAN_INVALID_AUTO_PHASE_PLAN`
453
- - `PHASE_PLAN_HIGH_RISK_ACK_REQUIRED`
454
- - `START_FROM_PHASE_PLAN_EMPTY_INTERSECTION`
455
-
456
- ## Canonical `start-from` contract
457
-
458
- - Accepted canonical phase IDs:
459
- - `intake`
460
- - `discovery`
461
- - `research`
462
- - `architecture`
463
- - `sprint-plan`
464
- - `plan-verify`
465
- - `execute`
466
- - `qa`
467
- - `verify-work`
468
- - `release`
469
- - `refresh-context`
470
- - Only canonical IDs are accepted. Alias values (for example `sprint_plan`,
471
- `verifywork`) are invalid and must fail fast.
126
+ Phase-completion boundary evaluation only. **Guarded auto-push eligibility chain**
127
+ (checklist in reference). Reason codes include `BRANCH_NOT_ALLOWLISTED`, `TEST_COMMAND_MISSING`,
128
+ `SYNC_PUSHED`. Full list: reference.
129
+
130
+ ## Canonical `start-from` phase IDs
131
+
132
+ `intake`, `discovery`, `research`, `architecture`, `sprint-plan`, `plan-verify`,
133
+ `execute`, `qa`, `verify-work`, `release`, `refresh-context` — aliases invalid.
472
134
 
473
135
  ## Deterministic resume-source precedence
474
136
 
@@ -479,27 +141,14 @@ Resolve start phase in strict order:
479
141
  3. Conservative `docs/engineering/state.md` fallback
480
142
  4. Fail fast on ambiguity/conflict/unrecoverable inputs
481
143
 
482
- Deterministic precedence behavior:
483
- - If explicit `start-from` is valid, it wins and lower-priority sources do not
484
- affect selected start phase.
485
- - `state.md` fallback is used only when `resume_brief.md` is absent.
486
- - If `resume_brief.md` is present but stale or unparseable, fail fast instead
487
- of silently falling back.
488
-
489
- ## Conflict and stale/unparseable policy
490
-
491
- - Explicit valid override always wins and is logged as override.
492
- - No override + `resume_brief` conflicts with `state` inference: fail fast.
493
- - `resume_brief` exists but stale: fail fast.
494
- - `resume_brief` exists but unparseable: fail fast.
495
- - `state` fallback yields multiple candidate phases: fail fast.
496
- - `state` fallback yields no trustworthy boundary: fail fast.
144
+ If `resume_brief.md` is present but stale or unparseable, fail fast instead
145
+ of silently falling back.
497
146
 
498
147
  ## Fail-fast error code contract
499
148
 
500
149
  All resume-resolution failures must use:
501
150
 
502
- `[AUTO_RESUME_ERROR] <code>: <summary>. Source=<source>. Fix: <action>.`
151
+ [AUTO_RESUME_ERROR] <code>: <summary>. Source=<source>. Fix: <action>.
503
152
 
504
153
  Required codes:
505
154
  - `INVALID_START_FROM`
@@ -510,139 +159,29 @@ Required codes:
510
159
  - `STATE_PHASE_AMBIGUOUS`
511
160
  - `STATE_PHASE_UNRECOVERABLE`
512
161
 
513
- ## Steps
162
+ ## Steps (compact; full detail in reference)
163
+
514
164
  1. Read automation flags from merged scratchpad and **materialize the resolved
515
- phase plan** per **Configurable phase selection policy (US-0070 / DEC-0052)**:
516
- detect exactly-one policy mode, expand, apply non-skippable reinstatement,
517
- validate tokens/profile/ack requirements, and append plan breadcrumbs
518
- (`phase_policy_mode`, `resolved_phase_plan`, `skipped_phases` + reasons) to
519
- `docs/engineering/state.md` **before** any phase spawn. On failure, emit
520
- deterministic phase-plan reason codes and stop (no partial schedule).
521
- 2. Parse optional `start-from=<phase>` and validate canonical phase ID rules.
522
- Parse optional `--execute-bulk` and treat it as explicit one-run override.
523
- 3. Resolve **nominal** start phase using deterministic precedence:
524
- - explicit argument -> resume brief -> state fallback -> fail-fast.
525
- - Emit `[AUTO_RESUME_ERROR] ...` message on resolver failure.
526
- 3a. **Intersect** the nominal start anchor with the resolved phase plan (plan
527
- order preserved; drop scheduled phases strictly before the anchor in canonical
528
- order). **Empty intersection** → fail fast with
529
- `START_FROM_PHASE_PLAN_EMPTY_INTERSECTION` and diagnostics listing
530
- `resolved_phase_plan` vs `requested_start_phase` / inferred resume anchor.
531
- Set the executable schedule to this intersection.
532
- 4. Record continuation breadcrumb metadata in `docs/engineering/state.md`:
533
- - `invocation_mode=auto`
534
- - `requested_start_from`
535
- - `resolved_start_phase` (first phase of the intersected schedule)
536
- - `resolution_source` (`argument|resume_brief|state_fallback`)
537
- - `resolution_status` (`resolved|fail-fast`)
538
- - `timestamp`
539
- 5. Spawn a fresh subagent for each remaining phase in **the intersected
540
- resolved schedule order** (not the full canonical list when phases are
541
- omitted), starting at `resolved_start_phase`:
542
- default full path:
543
- intake -> discovery -> research -> architecture -> sprint plan ->
544
- plan verify -> execute -> QA -> verify work -> release -> refresh context.
545
- If `SECURITY_REVIEW=1`, run `/security-review` in a fresh security subagent:
546
- - in `design` mode immediately after architecture and before sprint plan,
547
- - in `code` mode immediately after execute and before QA.
548
- If `SECURITY_REVIEW=0` (default), skip both checks with zero overhead.
549
- - If `AUTO_BACKLOG_DRAIN=1`, repeat story lifecycle for next eligible OPEN
550
- story using deterministic selection policy until bounded stop criteria.
551
- **Reload merged scratchpad phase-selection inputs and recompute the phase
552
- plan at each story boundary** (same policy class as single-segment runs).
553
- - If bulk execute mode is active (`--execute-bulk` or
554
- `AUTO_EXECUTE_BULK=1`), iterate eligible planned items using
555
- `AUTO_EXECUTE_SELECTION` with bounded item count
556
- (`AUTO_EXECUTE_MAX_ITEMS`) and deterministic block/skip semantics.
557
- **Reload merged scratchpad phase-selection inputs and recompute the phase
558
- plan at each item boundary** (no silent revival of omitted phases).
559
- - In team mode with enforcement enabled, run pre-mutation scope checks against
560
- `TEAM_MEMBER` and `ACTIVE_TASK_IDS`; out-of-scope tasks produce deterministic
561
- reason codes and no writes.
562
- - **US-0069 / DEC-0051**: Before each phase spawn, resolve the single-valued
563
- expected role (matrix + `AUTO_ROLE_RESEARCH`, `AUTO_ROLE_PLAN_VERIFY`,
564
- `AUTO_ROLE_REFRESH_CONTEXT`), enforce execute default deny / override
565
- contract, and run the preflight capability gate; on failure stop with
566
- `PHASE_ROLE_CAPABILITY_MISSING` (no unrelated-role spawn).
567
- - **US-0069 / DEC-0051**: After each phase completes, validate isolation
568
- `role` and strict-proof `role` against the preflight-resolved expected
569
- role; on conflict stop with `PHASE_ROLE_MISMATCH`.
570
- 6. Pass only the phase input files and current objective to each spawned
571
- subagent. Do not pass prior conversational reasoning as phase context.
572
- 7. If `AUTO_IMPLEMENTATION_LOOP=1`, alternate fresh subagents for execute and QA
573
- (`dev`, then `qa`, then new `dev`, then new `qa`) until no blocking findings
574
- or `AUTO_LOOP_MAX_CYCLES` is reached.
575
- - After each cycle, verify that both phases wrote new isolation evidence
576
- entries (distinct `fresh_context_marker` per phase per cycle).
577
- 8. If `AUTO_PAUSE_REQUEST=1`, stop at the next safe boundary
578
- (`AUTO_PAUSE_POLICY`) and spawn `/pause` in a fresh curator subagent.
579
- 9. Preserve existing stop conditions and gates without bypass:
580
- - decision gate
581
- - missing critical input
582
- - pause request at safe boundary
583
- - loop max cycles reached
584
- 10. On stop (or completion), write breadcrumbs:
585
- - `stop_reason` (`completed|decision_gate|missing_input|pause_request|loop_max`)
586
- - `stop_phase`
587
- - `timestamp`
588
- 11. If stopped before completion, update `handoffs/resume_brief.md` with the
589
- intended next phase and stop metadata.
590
- 11a. At each phase boundary, verify isolation evidence exists for the completed
591
- phase in `docs/engineering/state.md` and includes all required fields. If
592
- missing/invalid/stale, stop with the appropriate reason code and remediation
593
- guidance (run the phase again in a fresh subagent context and write new
594
- evidence). Append **phase boundary status** per **Configurable phase
595
- selection policy (US-0070 / DEC-0052)** (selected/skipped summary + next
596
- scheduled phase).
597
- 11b. At each phase boundary, verify strict runtime attestation tuple exists and
598
- is valid for the completed phase (`orchestrator_run_id`,
599
- `runtime_proof_id`, `phase_id`, `role`, `proof_issued_at`,
600
- `proof_ttl_seconds`, `proof_hash`).
601
- - Missing tuple: `RUNTIME_PROOF_MISSING`
602
- - Invalid schema/hash/linkage: `RUNTIME_PROOF_INVALID`
603
- - Reused `runtime_proof_id`: `RUNTIME_PROOF_REUSED`
604
- - Expired proof TTL / stale proof: `RUNTIME_PROOF_STALE`
605
- - Ambiguous proof-to-checkpoint linkage: `RUNTIME_PROOF_AMBIGUOUS_LINK`
606
- - Remediation: rerun affected phase in fresh subagent context, write new
607
- strict-proof tuple + checkpoint evidence, then continue.
608
- 12. At each phase boundary, evaluate sync policy only when mode requires it and
609
- record a deterministic sync verdict entry with:
610
- - `phase_boundary`
611
- - `policy_mode`
612
- - `trigger_source` (`manual|auto`)
613
- - `branch`
614
- - `checks` (`test|lint|typecheck`: `pass|fail|skipped`)
615
- - `qa_status_snapshot`
616
- - `push_decision` (`pushed|blocked|not_eligible`)
617
- - `reason_code`
618
- - `evidence_refs`
619
- 13. When backlog-drain mode or bulk execute mode is enabled, append per-item run
620
- summary entries:
621
- - `item_id`
622
- - `item_kind` (`story|sprint`)
623
- - `story_id`
624
- - `sprint_id`
625
- - `story_start_phase`
626
- - `story_stop_phase`
627
- - `story_outcome` (`released|blocked|skipped`)
628
- - `story_reason_code`
629
- - `team_context_snapshot` (`TEAM_MODE`, `TEAM_MEMBER`, `ACTIVE_TASK_IDS`)
630
- - `timestamp`
165
+ phase plan** per **Configurable phase selection policy (US-0070 / DEC-0052)**; append
166
+ plan breadcrumbs to `docs/engineering/state.md` **before** first spawn.
167
+ 2. Parse `start-from` / `--execute-bulk`; resolve nominal start phase; intersect with plan.
168
+ 3. Record continuation metadata (`invocation_mode=auto`, `requested_start_from`,
169
+ `resolved_start_phase`, `resolution_source`, `resolution_status`, `timestamp`).
170
+ 4. Spawn fresh subagents per intersected schedule; enforce **US-0069** preflight/post checks.
171
+ 5. Implementation loop, pause, stop breadcrumbs (`stop_reason` such as `completed|decision_gate|missing_input|pause_request|loop_max`, `stop_phase`, `timestamp`), `resume_brief` updates — reference.
172
+ 6. 11a. Isolation evidence verification at each boundary.
173
+ 7. 11b. At each phase boundary, verify strict runtime attestation tuple exists
174
+ and is valid for the completed phase (`orchestrator_run_id`, `runtime_proof_id`,
175
+ `phase_id`, `role`, `proof_issued_at`, `proof_ttl_seconds`, `proof_hash`).
176
+ 8. Sync verdict recording when eligible reference.
177
+ 9. Backlog-drain / bulk per-item summaries when enabled reference.
631
178
 
632
179
  ## Backward compatibility
633
180
 
634
- - Manual and interactive workflows remain unchanged by default.
635
- - `/resume` remains valid for context loading and guided continuation.
636
- - Deterministic precedence and fail-fast behavior apply when `/auto` continuation
637
- is invoked.
181
+ Default manual/interactive unchanged; `/resume` remains valid; deterministic precedence
182
+ applies for `/auto` continuation.
638
183
 
639
184
  ## Deterministic artifact ordering guard (US-0058 / DEC-0040)
640
185
 
641
- - When `/auto` coordinates phases that write mutable artifacts, each phase must
642
- follow `docs/engineering/artifact-ordering-policy.md`.
643
- - Ordering policies are mandatory:
644
- - `state.md`: append-bottom
645
- - `backlog.md` / `acceptance.md`: sorted-canonical
646
- - release/handoff surfaces: policy-specific (prepend/append) as documented.
647
- - If a required placement anchor is missing or ambiguous, fail closed with
648
- `ARTIFACT_ORDERING_ANCHOR_AMBIGUOUS` and do not continue.
186
+ Follow `docs/engineering/artifact-ordering-policy.md` (`state.md` append-bottom, etc.);
187
+ `ARTIFACT_ORDERING_ANCHOR_AMBIGUOUS` fail-closed.