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