@yunhozz/arc 0.1.7 → 0.1.10

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.
Files changed (92) hide show
  1. package/MANIFEST.sha256 +86 -61
  2. package/README.md +1 -1
  3. package/claude/agents/{arc-coder.md → arc-implementer.md} +7 -7
  4. package/claude/agents/arc-planner.md +4 -4
  5. package/claude/agents/arc-qa.md +4 -4
  6. package/claude/agents/arc-reviewer.md +5 -5
  7. package/claude/agents/arc-scouter.md +3 -3
  8. package/claude/skill/SKILL.md +7 -7
  9. package/claude/skill/models.toml +3 -3
  10. package/claude/skill/references/commit.md +22 -7
  11. package/claude/skill/references/coordination.md +25 -18
  12. package/claude/skill/references/git-recovery.md +1 -1
  13. package/claude/skill/references/handoff-prep.md +25 -2
  14. package/claude/skill/references/handoff.md +106 -24
  15. package/claude/skill/references/planning.md +73 -22
  16. package/claude/skill/references/verification.md +155 -17
  17. package/claude/skill/runtime/acceptance.mjs +68 -0
  18. package/claude/skill/runtime/assignment.mjs +42 -0
  19. package/claude/skill/runtime/bootstrap.mjs +35 -0
  20. package/claude/skill/runtime/cooperative-schema.mjs +55 -0
  21. package/claude/skill/runtime/cooperative.mjs +136 -0
  22. package/claude/skill/runtime/evaluate.mjs +40 -4
  23. package/claude/skill/runtime/external.mjs +51 -0
  24. package/claude/skill/runtime/gate.mjs +7 -7
  25. package/claude/skill/runtime/git-evidence.mjs +46 -0
  26. package/claude/skill/runtime/operations.mjs +2 -2
  27. package/claude/skill/runtime/role-policy.json +64 -19
  28. package/claude/skill/runtime/schema.mjs +1 -0
  29. package/claude/skill/runtime/scope.mjs +36 -0
  30. package/claude/skill/runtime/store.mjs +25 -4
  31. package/claude/skill/runtime/verification.mjs +123 -0
  32. package/claude/skill/scripts/model_config.py +2 -2
  33. package/codex/agents/{arc-coder.toml → arc-implementer.toml} +8 -8
  34. package/codex/agents/arc-planner.toml +6 -6
  35. package/codex/agents/arc-qa.toml +6 -6
  36. package/codex/agents/arc-reviewer.toml +6 -6
  37. package/codex/agents/arc-scouter.toml +5 -5
  38. package/codex/skill/SKILL.md +9 -9
  39. package/codex/skill/models.toml +3 -3
  40. package/codex/skill/references/commit.md +23 -8
  41. package/codex/skill/references/coordination.md +25 -18
  42. package/codex/skill/references/git-recovery.md +2 -2
  43. package/codex/skill/references/handoff-prep.md +25 -2
  44. package/codex/skill/references/handoff-worktree.md +4 -4
  45. package/codex/skill/references/handoff.md +116 -34
  46. package/codex/skill/references/planning.md +76 -23
  47. package/codex/skill/references/verification.md +160 -22
  48. package/codex/skill/runtime/acceptance.mjs +68 -0
  49. package/codex/skill/runtime/assignment.mjs +42 -0
  50. package/codex/skill/runtime/bootstrap.mjs +35 -0
  51. package/codex/skill/runtime/cooperative-schema.mjs +55 -0
  52. package/codex/skill/runtime/cooperative.mjs +136 -0
  53. package/codex/skill/runtime/evaluate.mjs +40 -4
  54. package/codex/skill/runtime/external.mjs +51 -0
  55. package/codex/skill/runtime/gate.mjs +7 -7
  56. package/codex/skill/runtime/git-evidence.mjs +46 -0
  57. package/codex/skill/runtime/operations.mjs +2 -2
  58. package/codex/skill/runtime/role-policy.json +64 -19
  59. package/codex/skill/runtime/schema.mjs +1 -0
  60. package/codex/skill/runtime/scope.mjs +36 -0
  61. package/codex/skill/runtime/store.mjs +25 -4
  62. package/codex/skill/runtime/verification.mjs +123 -0
  63. package/codex/skill/scripts/model_config.py +3 -3
  64. package/lib/cli/root.mjs +1 -0
  65. package/lib/cli/workflow.mjs +21 -0
  66. package/lib/installer/manifest.mjs +1 -1
  67. package/lib/installer/plan.mjs +27 -13
  68. package/lib/installer/targets.mjs +1 -1
  69. package/lib/models/config.mjs +1 -1
  70. package/lib/models/profiles.mjs +1 -1
  71. package/lib/policy/placement.mjs +6 -6
  72. package/lib/policy/render.mjs +3 -3
  73. package/lib/policy/role-policy.json +64 -19
  74. package/lib/release/artifact.mjs +1 -1
  75. package/lib/runtime/acceptance.mjs +68 -0
  76. package/lib/runtime/assignment.mjs +42 -0
  77. package/lib/runtime/bootstrap.mjs +35 -0
  78. package/lib/runtime/cooperative-schema.mjs +55 -0
  79. package/lib/runtime/cooperative.mjs +136 -0
  80. package/lib/runtime/evaluate.mjs +40 -4
  81. package/lib/runtime/external.mjs +51 -0
  82. package/lib/runtime/gate.mjs +7 -7
  83. package/lib/runtime/git-evidence.mjs +46 -0
  84. package/lib/runtime/operations.mjs +2 -2
  85. package/lib/runtime/schema.mjs +1 -0
  86. package/lib/runtime/scope.mjs +36 -0
  87. package/lib/runtime/store.mjs +25 -4
  88. package/lib/runtime/verification.mjs +123 -0
  89. package/package.json +4 -2
  90. package/claude/skill/scripts/__pycache__/model_config.cpython-314.pyc +0 -0
  91. package/codex/skill/scripts/__pycache__/apply-models.cpython-314.pyc +0 -0
  92. package/codex/skill/scripts/__pycache__/model_config.cpython-314.pyc +0 -0
@@ -44,7 +44,7 @@ and records the actual absolute workspace/repository, branch or detached HEAD, H
44
44
  explicit choice and preparation evidence, and absolute document paths inside that target. Planner drafts for that
45
45
  verified workspace; Orchestrator saves directly in the selected target. Missing or mismatched evidence stops the
46
46
  affected drafting or save and is reported to Orchestrator. Planned scope and paths do not establish actual preparation.
47
- Initial target preparation does not authorize Coder; the complete handoff gate still applies.
47
+ Initial target preparation does not authorize Implementer; the complete handoff gate still applies.
48
48
 
49
49
 
50
50
  ## Planner drafting preparation and consolidated feedback
@@ -66,6 +66,14 @@ Initial design, required spec approval, and formal plan drafting/approval remain
66
66
  Allow additional Planner calls for substantive omissions or user-approved scope/evidence changes. There is no fixed
67
67
  call cap; never accept an incomplete draft to minimize calls. Do not add call-count conditions to Planner profiles.
68
68
 
69
+ The complete initial brief identifies original user requirements, criteria IDs, approved decisions and open decisions;
70
+ current behavior and connected source, generated, runtime, installer and documentation surfaces; conflicting rules and
71
+ resolution direction; exact current-stage deliverable and absolute output path. Keep the shared brief's fixed field order
72
+ in [coordination](coordination.md). Link accessible evidence and needed ranges instead of full dialogue or raw logs.
73
+ Consolidated feedback contains changed fields only and marks remaining fields `unchanged` relative to the received brief.
74
+ Do not call Planner again for already resolved questions. Missing target preparation or required decisions holds formal
75
+ drafting; initial design proposals may still precede target selection. Written-spec approval precedes dependent plan drafting.
76
+
69
77
  ## Design and planning
70
78
 
71
79
  `brainstorming` and `writing-plans` are instructions for existing roles, not extra agents. This ARC controls
@@ -92,12 +100,12 @@ approved obligations separately.
92
100
  (SKILL.md Role gate);
93
101
  the direct path uses only a scope record.
94
102
  2. Spike: apply Probe scope above; distinguish probe-only authorization from a sufficiently specified combined scope.
95
- Bounded: approve a short design before Coder or an Orchestrator direct edit (Planner's design
96
- before Coder; a direct edit uses only an approved scope record). Architectural: approve
103
+ Bounded: approve a short design before Implementer or an Orchestrator direct edit (Planner's design
104
+ before Implementer; a direct edit uses only an approved scope record). Architectural: approve
97
105
  design, then Planner returns complete spec draft and self-review findings; Orchestrator integrates, saves,
98
106
  self-reviews, and obtains written-spec approval
99
107
  before implementation planning. Planner is read-only and cannot request approval.
100
- 3. After approved design/spec and before Coder, Orchestrator assesses plan depth separately from file count, LOC,
108
+ 3. After approved design/spec and before Implementer, Orchestrator assesses plan depth separately from file count, LOC,
101
109
  or bounded
102
110
  scope. Architectural work always uses local `writing-plans` and requires written plan approval, regardless of
103
111
  locality, risk, or size. For bounded work, skip planning only for one local change with no dependent stages,
@@ -109,8 +117,8 @@ approved obligations separately.
109
117
  returning its complete proportional draft, assumptions/open decisions, verification requirements, and self-review.
110
118
  Orchestrator integrates, saves to the user's path or `docs/superpowers/plans/YYYY-MM-DD-<feature-name>.md`,
111
119
  self-reviews,
112
- then obtains plan approval before Coder.
113
- 5. Every Coder first start and restart requires all applicable design/spec/plan approvals and passing
120
+ then obtains plan approval before Implementer.
121
+ 5. Every Implementer first start and restart requires all applicable design/spec/plan approvals and passing
114
122
  the Common handoff gate in SKILL.md and handoff.md, with approved artifacts, brief, and relevant findings.
115
123
  Non-behavior
116
124
  configuration/documentation may skip inapplicable design/planning stages, but still requires the handoff gate.
@@ -141,12 +149,12 @@ These requirements apply to required plans; existing plan-omission paths gain no
141
149
 
142
150
  ### Dependency and readiness record
143
151
 
144
- After plan approval and before the first Coder assignment, Orchestrator records all top-level task IDs in the
152
+ After plan approval and before the first Implementer assignment, Orchestrator records all top-level task IDs in the
145
153
  accessible canonical handoff record, linked to the approved plan version. For each task record explicit and implicit
146
154
  predecessors, required inputs, outputs and shared contracts, owned files, conflicting shared resources, required
147
155
  checks/QA path, ready/held status and reasons. Record the initial ready batch and capacity/serialization reasons.
148
156
  Analyze shared APIs, contracts, generated artifacts and resources even when tasks edit different files. Unresolved
149
- shared contracts or insufficient dependency information block the affected tasks; same-file concurrent Coder edits
157
+ shared contracts or insufficient dependency information block the affected tasks; same-file concurrent Implementer edits
150
158
  are blocked even for different lines. Do not infer independence from file separation or plan listing order.
151
159
 
152
160
  A task is ready only when all applicable approvals and execution preparation are complete, required inputs/contracts
@@ -154,7 +162,7 @@ are available and settled, predecessors have required evidence and Orchestrator
154
162
  commits (or accepted no-change records), ownership/resources do not conflict, its required check/QA path is available,
155
163
  and a subagent slot exists under both the configured ARC full-tree cap shared by all roles and any lower actual runtime
156
164
  limit (see [limits](limits.md)). Report runtime limits; ARC's cap is not a claim of runtime capability. Start all ready
157
- independent tasks with fresh Coders concurrently within capacity; record each hold or serialization reason instead of
165
+ independent tasks with fresh Implementers concurrently within capacity; record each hold or serialization reason instead of
158
166
  silently following list order. Preserve existing risk gates, risk-scaled QA/Reviewer timing and execution-target
159
167
  restrictions.
160
168
 
@@ -206,24 +214,24 @@ Bounded plan-skip, or non-behavior documentation/configuration paths; preserve e
206
214
  Normal order: initial design approval → execution-target choice → target preparation and verification →
207
215
  formal spec drafting (when required), saving and self-review → written-spec approval → formal plan drafting
208
216
  (when required), saving and self-review → individual plan approvals → complete applicable set → existing-commit
209
- verification and one batch docs commit of remaining approved documents → final Git verification → Coder handoff.
217
+ verification and one batch docs commit of remaining approved documents → final Git verification → Implementer handoff.
210
218
  Written-spec approval precedes dependent plan drafting. On document-omission paths skip only the inapplicable document
211
- steps; preserve target choice, preparation, state/ownership checks and Coder gates.
219
+ steps; preserve target choice, preparation, state/ownership checks and Implementer gates.
212
220
 
213
221
  While documents are being written, reviewed, or approved, do not stage documents or commit planning documents.
214
222
  Selection and initial target preparation happen before formal drafting; document completion is a staging/commit gate,
215
- not an initial preparation gate. An incomplete set or missing applicable approval blocks document commit and Coder,
216
- not the initial choice request. No early Coder work is authorized by approval of only some documents.
223
+ not an initial preparation gate. An incomplete set or missing applicable approval blocks document commit and Implementer,
224
+ not the initial choice request. No early Implementer work is authorized by approval of only some documents.
217
225
 
218
226
  This ARC explicitly defers the local `brainstorming` instruction to commit the spec before written-spec review:
219
227
  save and self-review the spec, obtain written-spec approval without committing it, then write and obtain approval for
220
228
  all applicable plans. Commit the spec only in the final batch preparation. Do not modify external skills.
221
229
  `writing-plans` implementation-step commit instructions
222
- are not permission for document commits during planning or for starting Coder.
230
+ are not permission for document commits during planning or for starting Implementer.
223
231
 
224
232
  | Path | Applicable approvals and preparation |
225
233
  |------|--------------------------------------|
226
- | Spike probe | Approve the feasibility question, probe method/scope, acceptance criteria, and constraints. Do not force specs/plans for still-unknown implementation; no new spec obligation is added by this gate. If Coder executes the probe, pass the Common handoff gate after probe approval. Read-only Orchestrator/Planner investigation without Coder does not trigger that gate. |
234
+ | Spike probe | Approve the feasibility question, probe method/scope, acceptance criteria, and constraints. Do not force specs/plans for still-unknown implementation; no new spec obligation is added by this gate. If Implementer executes the probe, pass the Common handoff gate after probe approval. Read-only Orchestrator/Planner investigation without Implementer does not trigger that gate. |
227
235
  | Bounded, plan skipped | Approve the short design and record the existing plan-skip criteria/rationale; this gate adds no new spec obligation. Complete applicable approvals, select the target, prepare any actual approved documents, or record valid document absence, then pass the Common handoff gate. |
228
236
  | Bounded, plan required | Approve the short design and every required plan; write a spec only when Orchestrator's recorded plan-depth judgment requires it, then obtain its individual written-spec approval before dependent plan drafting. Select and prepare the target before formal drafting; complete all applicable artifacts before one docs batch and the Common handoff gate. |
229
237
  | Architectural | Approve design, then written spec, then every required plan using `writing-plans`; select and prepare the target before formal drafting; complete the document set before batch preparation, final verification, and the Common handoff gate. |
@@ -235,16 +243,47 @@ Document omission skips only document obligations, never explicit
235
243
  execution-target choice, Git state/ownership checks, or handoff evidence.
236
244
 
237
245
  If planning reveals new scope, reassess the list, depth, and dependencies and obtain additional required approvals
238
- before dependent drafting or commit. Changed approved documents require approval of the revised version. If implementation reveals new
239
- scope, stop affected execution until that scope's documents, approvals, and preparation are complete. Do not amend old
240
- commits to retroactively include it. An already-running Coder must stop before edits dependent on new plans; inspect
246
+ before dependent drafting or commit. Changed approved document bodies require approval of the revised version, except
247
+ mechanical execution records defined below. If implementation reveals new scope, stop affected execution until that
248
+ scope's documents, approvals, and preparation are complete. Then reflect the approved plan version in its original
249
+ planning-document commit under the update contract below; never retroactively authorize work before actual approval.
250
+ An already-running Implementer must stop before edits dependent on new plans; inspect
241
251
  current changes/Git state and do not retroactively claim preparation. A restart without document changes follows Choice
242
252
  lifetime and restart record in [handoff.md](handoff.md).
243
253
 
254
+ ## Plan updates during execution
255
+
256
+ Mechanical execution records may be recorded without new user approval: checkbox completion, actual results, evidence
257
+ links and task completion state that preserve the approved execution contract. Record their classification, reason and
258
+ actual recording time in the canonical handoff record. Required checks' removal, invented success, unsupported acceptance
259
+ or scope changes mixed with a completion mark are not mechanical records.
260
+
261
+ Changes to goals, task scope or boundaries, acceptance criteria, method, risk, dependencies or required verification
262
+ require revised-version approval before affected work. Hold affected execution, obtain necessary design/spec/plan approvals
263
+ in order, and complete target, ownership, checks and handoff preparation before resuming. Other approved body corrections
264
+ follow the document-version approval rules; classify typos, paths, commands and explanations by their semantic effect.
265
+
266
+ Both mechanical records and approved contract revisions amend the original planning-document commit at a safe checkpoint.
267
+ Make no separate document commit or fixup commit, including for newly approved scope. Preserve implementation task commits.
268
+ This history update does not make actual approval time retroactive: the latest plan in the original commit is not evidence
269
+ that its contents were approved from the outset. Never use rewritten history to justify work started before approval.
270
+
271
+ In the canonical handoff record preserve plan absolute/Git paths; before and after content hashes and versions; prior and
272
+ revised approval references and actual times; change reason and classification; affected tasks and hold/preparation/resume
273
+ evidence. For mechanical records explain why no new approval is needed and record the time. Preserve recoverable document
274
+ contents, not hashes alone, and each old-to-new SHA mapping for the original document commit and descendant task commits.
275
+ Do not overwrite earlier approval references or the contents they approved.
276
+
277
+ Orchestrator alone performs the safe rewrite in [handoff-prep](handoff-prep.md#execution-time-plan-amendment) and
278
+ [commit](commit.md#execution-time-plan-document-updates). Shared/published or unknown history, merges, unclear ownership,
279
+ unexpected HEAD/dirty state and replay conflicts stop affected work. No force push or fallback document commit.
280
+ After rewriting, connect evidence to the new state under [verification](verification.md#evidence-after-plan-history-rewrite).
281
+ This contract adds no Git automation, runtime enforcement, authority or exemption from required checks/QA/Reviewer gates.
282
+
244
283
  ### Evidence refresh and limits
245
284
 
246
285
  Missing or mismatched evidence, unfinished approvals, unclear ownership, or unresolved failure blocks the affected
247
- save, execution-target request, Git mutation, or Coder handoff: stop and report to Orchestrator.
286
+ save, execution-target request, Git mutation, or Implementer handoff: stop and report to Orchestrator.
248
287
  Orchestrator resolves the issue and reverifies affected evidence before resumption. Reverify evidence when scope,
249
288
  approved versions, paths, target, or relevant Git state changes. Preserve unrelated changes under handoff rules;
250
289
  read-only investigation remains allowed.
@@ -253,6 +292,7 @@ Do not retroactively treat an early save or commit as satisfying these gates or
253
292
  order and any evidence gap. Structural checks prove only the repository's written policy contract, not consuming-agent
254
293
  runtime compliance. Without execution records for role returns, approvals, saves, and Git actions, leave runtime
255
294
  compliance unverified. Do not add runtime infrastructure or modify external skills for these checks.
295
+ The narrow exception below applies only to the explicitly approved cooperative CLI path within this repository.
256
296
 
257
297
  ### Managed worktree preparation
258
298
 
@@ -269,8 +309,21 @@ skill. Missing files stop the stage; report paths without global fallback. Keep
269
309
  [ARC role policy: contract begin]
270
310
  Generated from lib/policy/role-policy.json; do not edit this managed section manually.
271
311
  - [git.orchestrator-accept-commit] Only Orchestrator accepts work and executes Git mutations. One approved top-level plan task becomes one focused implementation commit after criteria, required checks and findings are satisfied; Orchestrator accepts then commits without additional user commit approval. Reports, passing checks and Reviewer opinions do not replace acceptance. Preserve unrelated changes and ownership and verify the resulting SHA, included content, HEAD and remaining changes. Existing small-task direct and plan-omission paths are unchanged.
272
- - [review.significant-no-plan] For significant/high-risk work without a plan: Coder → QA and required QA rechecks → Reviewer of the final full change → Orchestrator acceptance. MUST NOT omit Reviewer merely because no plan exists. This creates no new plan obligation.
273
- - [review.significant-plan] For significant/high-risk plan work: each task uses Coder → fresh QA as required → Orchestrator acceptance and focused commit. After all tasks are accepted and required QA is complete, Reviewer reviews the final full change once. Reviewer is NOT a per-task or per-commit required gate. Preserve required checks and necessary finding rechecks.
274
- - [review.final-plan-recheck] For final overall Reviewer findings on plan work, including behavior findings, use Coder → Reviewer without QA reassignment; repeat until resolved. This exception applies only at the final plan stage. Preserve required QA and QA failure rechecks before initial final review and outside this exception.
275
- - [platform.codex] Role restrictions are prompt-level contracts, not a filesystem sandbox. No documented role-specific Git hook or generic per-agent tool allowlist is assumed. Existing shell capabilities are retained because static read access after shell reduction has not been verified; Coder and QA need shell for approved checks.
312
+ - [review.significant-no-plan] For significant/high-risk work without a plan: Implementer → QA and required QA rechecks → Reviewer of the final full change → Orchestrator acceptance. MUST NOT omit Reviewer merely because no plan exists. This creates no new plan obligation.
313
+ - [review.significant-plan] For significant/high-risk plan work: each task uses Implementer → fresh QA as required → Orchestrator acceptance and focused commit. After all tasks are accepted and required QA is complete, Reviewer reviews the final full change once. Reviewer is NOT a per-task or per-commit required gate. Preserve required checks and necessary finding rechecks.
314
+ - [review.final-plan-recheck] For final overall Reviewer findings on plan work, including behavior findings, use Implementer → Reviewer without QA reassignment; repeat until resolved. This exception applies only at the final plan stage. Preserve required QA and QA failure rechecks before initial final review and outside this exception.
315
+ - [planning.plan-amend] During approved task execution, mechanical plan progress records need no new user approval; changed goals, scope, criteria, method, risk, dependencies or required verification require revised-version approval and preparation before affected work. In both cases Orchestrator amends the original planning-document commit at a safe boundary, without a separate document or fixup commit. Preserve actual approval chronology, recoverable old/new contents, hashes, versions and SHA mappings; never retroactively authorize earlier work. Rewrite only unpublished, unshared local linear history with clear ownership and no merges; stop on unknown publication, ownership, unexpected state or replay conflicts, without force push or a fallback document commit. Preserve implementation task boundaries and revalidate affected evidence. See planning, handoff-prep, commit and verification for the full contract.
316
+ - [planning.planner-brief] Before formal drafting, Orchestrator supplies one complete stage-specific brief with original requirements and criteria IDs, approved/open decisions, verified target and ownership, document paths and preceding approved versions, current behavior and connected source/generated/runtime/installer/documentation surfaces, policy conflicts, depth, dependencies, checks, holds and exact deliverable. Preserve shared brief field order. Review the complete draft once and consolidate substantive feedback as changed fields with other fields marked unchanged. Preserve sequential design, spec and plan approvals; no fixed call cap or incomplete drafts, and no calls for already resolved questions.
317
+ - [platform.codex] Role restrictions are prompt-level contracts, not a filesystem sandbox. No documented role-specific Git hook or generic per-agent tool allowlist is assumed. Existing shell capabilities are retained because static read access after shell reduction has not been verified; Implementer and QA need shell for approved checks.
276
318
  [ARC role policy: contract end]
319
+
320
+ ## Approved cooperative execution path within the repository
321
+
322
+ The explicitly approved `arc workflow` CLI in this repository connects document commits to the initial Implementer assignment in plan mode.
323
+ Its scope is decisions and records within the repository's cooperative path. It adds no authority to install native hooks/providers/installers or block direct tool calls.
324
+ `no-plan`/omission is unsupported by this CLI, and this boundary remains in Phases 2 and 3. This does not imply an omission policy violation or a new obligation to write documents.
325
+
326
+ Orchestrator records the SHA-256 values of the user-approved spec and plan, their shared docs-only commit, document version and approval version.
327
+ The CLI verifies the exact changed paths in actual Git objects and the current document bytes before persisting an assignment intent.
328
+ A new workflow or late document commit cannot prove earlier execution was compliant. Earlier agent history and execution outside this path remain unverified.
329
+ Approval attestations and native returns are `operator-attested`; an agent ID is not an authenticated identity.
@@ -9,14 +9,14 @@ For Orchestrator, **Evidence verdict**: each criterion is proven, unmet, or unve
9
9
 
10
10
  ## Risk-scaled execution
11
11
 
12
- Orchestrator assigns edits exclusively to Coder except under the Orchestrator direct path in [handoff](handoff.md#orchestrator-direct-path-for-small-tasks), and determines affected
12
+ Orchestrator assigns edits exclusively to Implementer except under the Orchestrator direct path in [handoff](handoff.md#orchestrator-direct-path-for-small-tasks), and determines affected
13
13
  behavior, risk, and smallest meaningful verification.
14
14
 
15
15
  | Risk | Minimum flow |
16
16
  |---|---|
17
- | Small, low risk | Coder, or Orchestrator direct path → Orchestrator's focused checks → acceptance |
18
- | Ordinary behavior | Coder → independent QA → acceptance |
19
- | Significant/high risk | Coder → QA → independent Reviewer of the final full change → acceptance; with a plan, each plan task Coder → FRESH QA → acceptance/commit satisfies the QA step, then independent Reviewer once on the final full change after all plan tasks |
17
+ | Small, low risk | Implementer, or Orchestrator direct path → Orchestrator's focused checks → acceptance |
18
+ | Ordinary behavior | Implementer → independent QA → acceptance |
19
+ | Significant/high risk | Implementer → QA → independent Reviewer of the final full change → acceptance; with a plan, each plan task Implementer → FRESH QA → acceptance/commit satisfies the QA step, then independent Reviewer once on the final full change after all plan tasks |
20
20
 
21
21
  Ordinary and significant plan tasks need a FRESH QA before acceptance; only small, low-risk tasks may be accepted on
22
22
  Orchestrator focused checks. Small, low risk means narrow, understood, readily reversible, and verifiable by focused
@@ -34,13 +34,13 @@ boundary and resolve or explicitly disposition findings before dependent impleme
34
34
  Reuse evidence only when scope, relevant state, independence, freshness, and flow
35
35
  position satisfy each covered requirement; changes, failures, or missing/conflicting evidence invalidate affected reuse.
36
36
  QA checks independently without edits; Reviewer reviews without QA, planning, edits, delegation, or completion
37
- decisions. Orchestrator routes fixes to Coder (a failed direct-path check returns to the normal flow),
37
+ decisions. Orchestrator routes fixes to Implementer (a failed direct-path check returns to the normal flow),
38
38
  obtains affected QA rechecks outside the final plan Reviewer correction exception and required final review, and accepts after findings/evidence gaps are resolved or
39
39
  explicitly dispositioned.
40
40
 
41
41
  Criterion verdicts follow the Evidence verdict.
42
42
 
43
- Fresh-per-task rules apply to Coder and QA, not Reviewer. Orchestrator may reuse a Reviewer only while independent
43
+ Fresh-per-task rules apply to Implementer and QA, not Reviewer. Orchestrator may reuse a Reviewer only while independent
44
44
  of implementation and self-review, relevant assignment context remains valid, and refreshed review scope, target
45
45
  state, and evidence are provided; otherwise assign another independent Reviewer. Reusing a Reviewer does not reuse
46
46
  an earlier verdict or waive required review timing or coverage.
@@ -48,9 +48,9 @@ an earlier verdict or waive required review timing or coverage.
48
48
  ### Final plan Reviewer correction loop
49
49
 
50
50
  For a plan's final overall Reviewer findings, including behavior findings, Orchestrator assigns
51
- Coder → Reviewer recheck with no QA reassignment. Repeat corrections and Reviewer rechecks until findings are resolved;
51
+ Implementer → Reviewer recheck with no QA reassignment. Repeat corrections and Reviewer rechecks until findings are resolved;
52
52
  the initial single full review does not prohibit necessary rechecks. Before the initial final overall Reviewer,
53
- risk-required checks and QA execution failures or unmet criteria still require Coder correction → QA recheck.
53
+ risk-required checks and QA execution failures or unmet criteria still require Implementer correction → QA recheck.
54
54
  This exception applies only to findings from the final overall Reviewer of work with a plan.
55
55
  Work without a plan retains its existing verification flow. Scope expansion, separate mandatory obligations,
56
56
  or unresolved evidence gaps hold affected work for Orchestrator to resolve and obtain required approvals.
@@ -68,8 +68,8 @@ Completion continuity below; a role report alone does not complete the work.
68
68
 
69
69
 
70
70
  The Risk-scaled execution section above holds the risk table, risk definitions, evidence-reuse rule, and role order,
71
- including Reviewer timing. Product/test edits belong exclusively to Coder except under the Orchestrator direct path;
72
- Orchestrator may inspect/run checks but routes code corrections to Coder. Determine the minimum
71
+ including Reviewer timing. Product/test edits belong exclusively to Implementer except under the Orchestrator direct path;
72
+ Orchestrator may inspect/run checks but routes code corrections to Implementer. Determine the minimum
73
73
  flow from risk and any specific instruction or approved commitment, and record which requirements each check or review
74
74
  satisfies. For small, low-risk work with clear scope and acceptance evidence and no such requirement,
75
75
  Orchestrator's focused checks suffice; do not call QA or Reviewer automatically. Significant/high-risk work requires
@@ -84,7 +84,7 @@ An environment failure is distinct from a code failure; report the exact limitat
84
84
 
85
85
  Use additional Planner/Scouter only for unresolved planning/discovery questions. Reviewer covers substantial changes and
86
86
  correctness, factual, security, data, or interface risks. Orchestrator may use Planner/Scouter/Reviewer when justified
87
- and assigns all Coder/QA work. Specialists report unresolved questions to Orchestrator, who assigns support only when needed.
87
+ and assigns all Implementer/QA work. Specialists report unresolved questions to Orchestrator, who assigns support only when needed.
88
88
 
89
89
  QA runs applicable existing functional/test checks, or approved structural/consistency checks for policy and
90
90
  configuration changes. Reviewer reads the assigned diff/source for correctness, factual accuracy, and security. Outside the final plan Reviewer correction exception, after a
@@ -93,11 +93,24 @@ independent of the work and self-review and when evidence meets required scope a
93
93
  Before completion, resolve or explicitly disposition findings and confirm acceptance evidence. Claim checks only
94
94
  with verified output.
95
95
 
96
+ ## Evidence after plan history rewrite
97
+
98
+ After an approved execution-time plan rewrite, verify new HEAD, approved plan version/content and old-to-new SHA mapping;
99
+ descendant implementation content and task boundaries; and remaining staged/unstaged/untracked state. Preserve the actual
100
+ approval chronology and recoverable previous contents in the canonical handoff record. The latest version in the original
101
+ commit does not establish approval before its actual approval time.
102
+
103
+ SHA change alone does not invalidate all prior acceptance evidence. Check whether evidence bound to an exact HEAD,
104
+ document or policy can be linked to the new state. If it cannot be linked, or its meaning is affected, repeat affected
105
+ checks and required rechecks. Preserve existing runtime evidence invalidation and exact-state requirements; do not rewrite
106
+ old fingerprints to imply a run against the new HEAD. Refresh affected briefs and gates before dependent work.
107
+ Structural checks establish written-contract alignment, not live agent compliance or successful Git history replay.
108
+
96
109
  ## Task acceptance and final plan acceptance
97
110
 
98
111
  Task-local acceptance is distinct from overall final plan verification and acceptance. Orchestrator connects each task's
99
112
  acceptance criteria to actual evidence, currently required checks and findings before accepting it; checkbox
100
- completion, a Coder report or passing commands alone do not establish acceptance.
113
+ completion, a Implementer report or passing commands alone do not establish acceptance.
101
114
 
102
115
  Task acceptance and its focused commit require only the task's risk-scaled evidence: a FRESH QA instance per task that
103
116
  needs QA (default to the current QA for post-fix rechecks of the same task while the approved scope, workspace,
@@ -111,11 +124,11 @@ A task commit record does not mark unperformed final verification complete. Orch
111
124
  acceptance using final QA/Reviewer/integration evidence and findings, preserving unverified scope and explicit dispositions.
112
125
  Valid evidence may cover both task and plan requirements only under the existing scope/state/independence/freshness/flow
113
126
  rules. For final Reviewer findings on already committed plan work, Orchestrator defines a follow-up task and required
114
- planning/approvals. Coder leaves corrections uncommitted during rechecks. Orchestrator refreshes the latest committed
127
+ planning/approvals. Implementer leaves corrections uncommitted during rechecks. Orchestrator refreshes the latest committed
115
128
  state plus uncommitted diff and changed-file list in the Reviewer artifact/brief. Reuse an independent Reviewer or
116
- assign another independent Reviewer as needed. Repeat Coder → Reviewer without QA reassignment until findings are
129
+ assign another independent Reviewer as needed. Repeat Implementer → Reviewer without QA reassignment until findings are
117
130
  resolved; Orchestrator then accepts the corrections and creates one focused follow-up commit.
118
- Final QA findings retain Coder correction and QA recheck before a new focused commit.
131
+ Final QA findings retain Implementer correction and QA recheck before a new focused commit.
119
132
  Do not automatically amend/reset or duplicate the original task commit. Scope expansion keeps existing new
120
133
  planning and approval obligations.
121
134
 
@@ -144,19 +157,19 @@ verdicts.
144
157
  Structural checks prove structural criteria only; they do not prove actual behavior, installation, or live agent runtime
145
158
  compliance.
146
159
 
147
- For QA execution failure or an unmet criterion within the current task, Orchestrator defaults to the current Coder
160
+ For QA execution failure or an unmet criterion within the current task, Orchestrator defaults to the current Implementer
148
161
  for correction and the current QA for a post-fix recheck, subject to the context, task-boundary and amendment rules in
149
162
  [coordination](coordination.md). The finding alone does not create a new task. QA reruns the
150
163
  reproduction path and invalidated related checks before Reviewer, reporting the actual actor, target state, outcomes, and limitations,
151
164
  and the prior finding resolved, unresolved, or unverified with evidence. Reusing QA does not reuse stale evidence.
152
- An unresolved finding returns to Coder correction and another QA recheck before Reviewer.
165
+ An unresolved finding returns to Implementer correction and another QA recheck before Reviewer.
153
166
  Environment blocks, missing checks, and out-of-scope criteria are evidence gaps, not presumed code defects; Orchestrator
154
167
  handles those gaps under the existing disposition policy without substituting Reviewer review for QA evidence.
155
168
 
156
169
  For an acceptance-linked behavior finding, Reviewer reports the criterion, expected behavior, observed problem, related
157
170
  source, reproduction conditions and steps, and evidence to Orchestrator, distinguishing source-inferred reproduction
158
171
  from execution-observed results without running QA tests. Outside the final plan Reviewer correction exception,
159
- Orchestrator routes it to Coder correction and QA post-fix recheck. Outside the required final plan correction loop,
172
+ Orchestrator routes it to Implementer correction and QA post-fix recheck. Outside the required final plan correction loop,
160
173
  Orchestrator decides when a Reviewer recheck is warranted by the changed scope and independence. Reviewer continues handling
161
174
  structure, design, factual, and security findings that execution checks cannot settle; observable security/interface
162
175
  issues may require both QA verification and Reviewer source review.
@@ -181,11 +194,136 @@ ends at its approved question's evidence and limits; a combined scope continues
181
194
  Document omission changes neither verification risk nor acceptance responsibility. Hold only affected work for an
182
195
  actual unmet condition and report what is needed to resume. Structural evidence does not prove live agent compliance.
183
196
 
197
+ ## Verification lifecycle in the cooperative CLI
198
+
199
+ The supported `workflow` path is an approved complete spec+plan. No-plan, small-task and document omission paths remain
200
+ `cooperative.unsupported`; this outcome does not imply a violation of existing ARC policy or a new obligation to write documents.
201
+ The CLI does not execute checks or invoke Reviewer. All actors, results and verdicts are `operator-attested`; they do not prove
202
+ identity, actual independence, semantic sufficiency or enforced execution.
203
+
204
+ An Orchestrator actor (`actor.role: "orchestrator"`) registers a verification contract by recording
205
+ `data: {kind: "task", task: {...}}` in `acceptance-evidence` through `record`. The task specifies `id`, absolute `paths`,
206
+ `criteria`, `requiredChecks`, `dependencies`, `approvalRef`, `approvalVersion`, `documentVersion`,
207
+ `scopeVersion` and `targetVersion`. Only pending tasks can be registered; this record is neither acceptance nor a commit.
208
+ Each requiredChecks descriptor is `{executable, args, cwd, env, outputs}`; executable, cwd and outputs are absolute paths.
209
+ cwd and outputs must be within the workspace. Do not include Reviewer in task requiredChecks.
210
+
211
+ `changeFingerprints.tasks[taskId]` and `changeFingerprints.final` in `status` are independent observations.
212
+ They include read-only Git inventory/index observations and current regular-file bytes, modes and deletions. Task fingerprints
213
+ cover owned paths; the final fingerprint covers the whole repository snapshot. Unsupported observations such as symlinks,
214
+ submodules and unmerged indexes cause a hold. This is not a sandbox that atomically locks observation and execution.
215
+ Leave runtimeHash drift as stale/hold; do not automatically update the stored version or convert it through migration or renewed approval.
216
+
217
+ `operation: "check"` in `prepare` accepts `taskId` and
218
+ `arguments: {scope: "task", actor: {id, role: "qa"}, descriptor, changeFingerprint, findingIds?}`.
219
+ Actor ID attestations must be independent of Implementer and Orchestrator; QA/Implementer reuse across tasks is rejected. The descriptor must
220
+ exactly match the registered requiredChecks. After the intent is persisted, the responsible role executes within its existing approved scope.
221
+ `result` or `reconcile` records `intentId` and `{status, messageRef, data}`. data specifies the same
222
+ `actor`, `descriptor` and `scope` as the intent, `taskId` for tasks, `changeFingerprint`, and
223
+ `verdict: "proven" | "unmet" | "unverified"`. Even a succeeded/proven result is valid only for that change version.
224
+ This is an operator verdict record; it does not replace semantic proof of a criterion or Orchestrator acceptance.
225
+ Failures, unknown, mismatch and unverified outcomes are not passing evidence. Preserve previous results and failure records.
226
+
227
+ A failed check/review leaves an open finding. Link a separate finding to an existing check/review through `record` with
228
+ `data: {action: "open", id, checkId, message}`. After a Implementer fix, record
229
+ `data: {action: "resolve", id, actor: {id, role: "implementer"}, changeFingerprint}` and the fix evidence messageRef.
230
+ The actor must be the Implementer assigned to that task, or a relevant task for an overall finding. This marks the finding resolved;
231
+ it becomes closed only when a subsequent prepare includes it in `findingIds` and revalidation passes for the same change version.
232
+ Earlier QA failures retain the Implementer→QA recheck requirement.
233
+
234
+ `operation: "review"` uses `scope: "final"`, `actor.role: "reviewer"` and
235
+ `descriptor: {kind: "source-review", paths: [...]}`, without taskId. The initial final review requires acceptance of all tasks
236
+ and current required task QA evidence. Reviewer is not a prerequisite gate for task acceptance or focused commits.
237
+ For final Reviewer findings in supported plan work, repeat Implementer resolution→Reviewer revalidation without QA reassignment.
238
+ Do not present earlier QA evidence as execution evidence for a subsequent fix. This exception does not omit separate unresolved QA failures.
239
+
240
+ Scope, document and approval change records do not overwrite history. Specifying `data.affectedTaskIds` invalidates task,
241
+ verification and acceptance evidence for those tasks and their dependency chain; omitting it holds all tasks. Final evidence also becomes stale.
242
+ Preserve evidence for unaffected independent tasks. Orchestrator determines semantic impact. Affected tasks require a new approval record
243
+ for the current scope and an updated task contract before preparation; earlier approvals cannot revive them. New checks/reviews and
244
+ finding revalidation are also required. Current evidence supersedes earlier failures without deleting them; acceptance, commits and final completion remain Orchestrator decisions.
245
+
246
+ ### Task acceptance and focused commit reconciliation in the cooperative CLI
247
+
248
+ In the current plan mode, `prepare` supports `operation: "accept"` and `operation: "commit"`.
249
+ Acceptance is an Orchestrator attestation specifying `actor.role: "orchestrator"`, `taskId`, and, in `arguments`,
250
+ `messageRef`, the same `criteria` as the task, exact `checkIds` for current required QA, all task
251
+ `findingIds` and the current `changeFingerprint`. The latest QA result for each required descriptor must be
252
+ passed/proven, and findings must be closed through Implementer fixes and QA rechecks.
253
+ A successful attestation marks the task accepted; passing commands or Implementer reports alone do not constitute acceptance.
254
+ The provenance is `operator-attested`; the operator confirms semantic criterion satisfaction and actor identities.
255
+
256
+ At acceptance, the code pins the actual index tree, staged diff, paths and task fingerprint together. Orchestrator stages only
257
+ approved task paths beforehand and confirms required QA for that index state. Unrelated paths, changes from another registered
258
+ task, or unstaged/untracked changes within scope cause a hold. The code cannot automatically distinguish semantically unrelated
259
+ hunks within the same file; Orchestrator reads the actual diff to confirm them.
260
+
261
+ `operation: "commit"` in `prepare` references the exact acceptance through `arguments: {"acceptanceId": "acceptance requestId"}`.
262
+ The code checks that the current approval, task contract, QA, findings and index match acceptance, then persists a durable intent
263
+ with the expected parent, tree, paths and residual paths. The CLI does not stage or commit.
264
+ Orchestrator creates one focused implementation commit matching these expectations.
265
+
266
+ Then submit `intentId`, `actor.role: "orchestrator"`, and
267
+ `result: {"status": "succeeded", "messageRef": "actual result evidence", "data": {"commit": "full OID"}}`
268
+ through `reconcile` or result-form `result`. The CLI rereads the actual commit object, parent, tree, paths, HEAD, index and residual changes from local Git.
269
+ Only a complete match updates target HEAD and marks the task committed. Failure, unknown and mismatch observations and actual
270
+ history are preserved; the target is not updated arbitrarily. Reusing the same request or a completed intent does not authorize
271
+ a second effect. After a failure, read the actual state, resolve the cause and reconcile the existing intent.
272
+
273
+ Do not rewrite earlier QA fingerprints after a successful commit. Separate post-commit file/index observations detect subsequent
274
+ changes. Under the existing rules, final review requires current task evidence and the final fingerprint.
275
+ A changed runtimeHash follows the existing stale/hold rules; the stored version is not automatically updated.
276
+
184
277
  [ARC role policy: contract begin]
185
278
  Generated from lib/policy/role-policy.json; do not edit this managed section manually.
186
279
  - [git.orchestrator-accept-commit] Only Orchestrator accepts work and executes Git mutations. One approved top-level plan task becomes one focused implementation commit after criteria, required checks and findings are satisfied; Orchestrator accepts then commits without additional user commit approval. Reports, passing checks and Reviewer opinions do not replace acceptance. Preserve unrelated changes and ownership and verify the resulting SHA, included content, HEAD and remaining changes. Existing small-task direct and plan-omission paths are unchanged.
187
- - [review.significant-no-plan] For significant/high-risk work without a plan: Coder → QA and required QA rechecks → Reviewer of the final full change → Orchestrator acceptance. MUST NOT omit Reviewer merely because no plan exists. This creates no new plan obligation.
188
- - [review.significant-plan] For significant/high-risk plan work: each task uses Coder → fresh QA as required → Orchestrator acceptance and focused commit. After all tasks are accepted and required QA is complete, Reviewer reviews the final full change once. Reviewer is NOT a per-task or per-commit required gate. Preserve required checks and necessary finding rechecks.
189
- - [review.final-plan-recheck] For final overall Reviewer findings on plan work, including behavior findings, use Coder → Reviewer without QA reassignment; repeat until resolved. This exception applies only at the final plan stage. Preserve required QA and QA failure rechecks before initial final review and outside this exception.
190
- - [platform.codex] Role restrictions are prompt-level contracts, not a filesystem sandbox. No documented role-specific Git hook or generic per-agent tool allowlist is assumed. Existing shell capabilities are retained because static read access after shell reduction has not been verified; Coder and QA need shell for approved checks.
280
+ - [review.significant-no-plan] For significant/high-risk work without a plan: Implementer → QA and required QA rechecks → Reviewer of the final full change → Orchestrator acceptance. MUST NOT omit Reviewer merely because no plan exists. This creates no new plan obligation.
281
+ - [review.significant-plan] For significant/high-risk plan work: each task uses Implementer → fresh QA as required → Orchestrator acceptance and focused commit. After all tasks are accepted and required QA is complete, Reviewer reviews the final full change once. Reviewer is NOT a per-task or per-commit required gate. Preserve required checks and necessary finding rechecks.
282
+ - [review.final-plan-recheck] For final overall Reviewer findings on plan work, including behavior findings, use Implementer → Reviewer without QA reassignment; repeat until resolved. This exception applies only at the final plan stage. Preserve required QA and QA failure rechecks before initial final review and outside this exception.
283
+ - [planning.plan-amend] During approved task execution, mechanical plan progress records need no new user approval; changed goals, scope, criteria, method, risk, dependencies or required verification require revised-version approval and preparation before affected work. In both cases Orchestrator amends the original planning-document commit at a safe boundary, without a separate document or fixup commit. Preserve actual approval chronology, recoverable old/new contents, hashes, versions and SHA mappings; never retroactively authorize earlier work. Rewrite only unpublished, unshared local linear history with clear ownership and no merges; stop on unknown publication, ownership, unexpected state or replay conflicts, without force push or a fallback document commit. Preserve implementation task boundaries and revalidate affected evidence. See planning, handoff-prep, commit and verification for the full contract.
284
+ - [platform.codex] Role restrictions are prompt-level contracts, not a filesystem sandbox. No documented role-specific Git hook or generic per-agent tool allowlist is assumed. Existing shell capabilities are retained because static read access after shell reduction has not been verified; Implementer and QA need shell for approved checks.
191
285
  [ARC role policy: contract end]
286
+
287
+
288
+ ## External operations and recovery in the cooperative CLI
289
+
290
+ The three phases support state, documents and assignment; scope, verification, acceptance and focused commits; and external approval, results and audit recovery.
291
+ Use `status.support` to inspect all nine areas and their limits. The supported mode is `plan` with spec+plan; no-plan and omission are unsupported. The CLI does not execute native/provider calls or push, merge, deploy or publish.
292
+ User approvals and execution results confirmed by the operator are `operator-attested`, with `nativeVerified: false` and
293
+ `remoteVerified: false`. Blocking direct calls outside the CLI and independent remote verification are not provided.
294
+
295
+ Orchestrator records an explicit approval it has already confirmed through `record` with
296
+ `evidence: {kind: "external-approval", messageRef, data: {operation, scope, descriptor}}`.
297
+ `scope` is an array of unique absolute paths within the checkout. Local commit approval does not authorize external operations.
298
+ Include the exact action, scope and target in the approval, and record every descriptor field below.
299
+
300
+ | operation | descriptor fields |
301
+ |---|---|
302
+ | push | repository, destination, refspec, sourceOid, expectedRemoteOid |
303
+ | merge | repository, changeRef, targetRef, expectedTargetOid |
304
+ | deploy | service, project, environment, artifactId, destination |
305
+ | publish | service, namespace, name, version, artifactHash, destination |
306
+
307
+ Git OIDs are full 40/64-character lowercase hex values; artifactHash is `sha256:<64-hex>`. Without a remote observation,
308
+ an OID is an expected value asserted by the user, not verified remote state. destination must be an identifier without secrets.
309
+ Do not submit URL userinfo, query or fragment components, or authentication information such as passwords, tokens or credentials.
310
+ The CLI rejects recognized credential inputs before persistence, but cannot determine whether every arbitrary string contains a secret.
311
+
312
+ Pass `{requestId, expectedRevision, actor: {id, role: "orchestrator"}, operation,
313
+ arguments: {approvalRef, scope, descriptor}}` to `prepare`. approvalRef matches the external approval messageRef.
314
+ An intent is persisted only when the exact approval, scope/target versions and runtime version match and no effect is unresolved.
315
+ After confirming `allow` and `persisted: true`, Orchestrator performs the external operation within its separately approved scope.
316
+ This CLI does not expand that execution authority.
317
+
318
+ `result`/`reconcile` accepts `{requestId, expectedRevision, actor, intentId,
319
+ result: {status, messageRef, data: {operation, scope, descriptor}}}`. intentId is the prepare requestId.
320
+ Target mismatches, unknown outcomes and stale results cause a hold while preserving earlier attestations. After an interruption,
321
+ use `status` to inspect the intent, `state.requests`, `state.audit` and `state.results`, and investigate whether the effect occurred.
322
+ Reconcile the investigation result against the same intent rather than preparing again or reusing the same approval to execute again.
323
+ Cancellation additionally requires a `notExecutedEvidence: {messageRef}` attestation that the operation was not executed.
324
+ The approval remains consumed after cancellation. Do not resolve version drift through automatic updates, migration or renewed permission.
325
+ Report the cause of the hold to Orchestrator.
326
+
327
+ Even succeeded results are operator attestations, not independent remote verification. `audit` retains the
328
+ request→decision→intent→result→resolution linkage, but is a locally editable record rather than tamper-proof security evidence.
329
+ Do not retry while the actual external outcome is uncertain.
@@ -0,0 +1,68 @@
1
+ import path from 'node:path';
2
+ import {fingerprintRequest} from './store.mjs';
3
+ import {validateGitPreflight,validateGitCommitResult} from './git-evidence.mjs';
4
+ import {within} from './scope.mjs';
5
+ const reconciliations=new WeakMap();
6
+ export function verifiedCooperativeReconciliation(decision,state){const proof=reconciliations.get(decision);return !!proof&&proof.before===fingerprintRequest(state)&&proof.after===fingerprintRequest(decision.proposedTransition);}
7
+ const completed=(state,id)=>state.tasks?.some(t=>t.id===id&&t.status==='committed'&&!t.invalidated)&&state.commits?.some(c=>c.taskId===id&&c.observationSource==='local-git'&&state.intents.some(i=>i.operation==='commit'&&i.requestId===c.requestId&&i.taskId===id&&i.status==='succeeded'));
8
+ const same=(a,b)=>JSON.stringify(a)===JSON.stringify(b);
9
+ const text=v=>typeof v==='string'&&v.length>0;
10
+ const list=v=>Array.isArray(v)&&v.every(text)&&new Set(v).size===v.length;
11
+ const exact=(a,b)=>list(a)&&list(b)&&same([...a].sort(),[...b].sort());
12
+ const fields=(v,keys)=>v&&typeof v==='object'&&!Array.isArray(v)&&Object.keys(v).every(k=>keys.includes(k));
13
+ const semanticLimit='Semantically unrelated hunks inside the same file require Orchestrator inspection; path and byte evidence cannot distinguish them automatically.';
14
+ const base=state=>({expectedRevision:state?.revision??0,coverage:{enforcement:'cooperative',provenance:'operator-attested',nativeVerified:false},semanticLimit,requiredEvidence:[],nextActions:[],proposedTransition:null});
15
+ const hold=(state,reason)=>({...base(state),decision:'hold',ruleIds:['cooperative.acceptance'],reason});
16
+ const allow=(state,transition)=>({...base(state),decision:'allow',ruleIds:['cooperative.acceptance'],proposedTransition:transition});
17
+ const approval=(state,id)=>state.records.filter(r=>r.kind==='approval'&&(!r.data.affectedTaskIds||r.data.affectedTaskIds.includes(id))).at(-1);
18
+ function authorized(state,task){const a=approval(state,task?.id);return state.mode==='plan'&&task&&!task.invalidated&&a?.source==='operator-attested'&&a.targetVersion===state.targetVersion&&task.targetVersion===state.targetVersion&&task.scopeVersion===a.scopeVersion&&task.approvalRef===a.messageRef&&task.approvalVersion===a.data.approvalVersion&&task.documentVersion===a.data.documentVersion;}
19
+ function checkEvidence(state,task,a,changes){
20
+ if(!same(a.criteria,task.criteria)||!task.criteria.length||!list(a.checkIds)||!list(a.findingIds)||a.changeFingerprint!==changes?.tasks?.[task.id])return false;
21
+ const checks=state.checks.filter(c=>c.scope==='task'&&c.taskId===task.id);
22
+ const latest=task.requiredChecks.map(d=>checks.filter(c=>same(c.descriptor,d)).at(-1));
23
+ if(!task.requiredChecks.length||latest.some(c=>!c||c.stale||c.status!=='passed'||c.verdict!=='proven'||!text(c.resultRef)||c.source!=='operator-attested'||c.verificationActor?.role!=='qa'||!text(c.verificationActor.id)||state.assignments.some(a=>a.agentId===c.verificationActor.id)||c.changeFingerprint!==a.changeFingerprint)||!exact(a.checkIds,latest.map(c=>c?.id)))return false;
24
+ const findings=state.findings.filter(f=>f.scope==='task'&&f.taskId===task.id);
25
+ return exact(a.findingIds,findings.map(f=>f.id))&&findings.every(f=>f.status==='closed'&&text(f.resolutionRef)&&text(f.recheckRef)&&f.resolutionActor?.role==='implementer'&&f.recheckActor?.role==='qa'&&f.changeFingerprint===a.changeFingerprint);
26
+ }
27
+ function waitingFor(state,task,predecessor){
28
+ if(task.status!=='pending'||state.intents.some(i=>i.taskId===task.id&&i.operation==='assign-agent'&&['prepared','unknown','mismatch','succeeded'].includes(i.status)))return false;
29
+ const seen=new Set(),queue=[...(task.dependencies??[])];while(queue.length){const id=queue.pop();if(id===predecessor)return true;if(seen.has(id))continue;seen.add(id);queue.push(...(state.tasks.find(t=>t.id===id)?.dependencies??[]));}return false;
30
+ }
31
+ function dirtyOtherTask(state,task,git){return git.stagedPaths?.some(name=>state.tasks.some(t=>t.id!==task.id&&!completed(state,t.id)&&!waitingFor(state,t,task.id)&&t.paths.some(p=>within(p,path.join(state.target.realpath,...name.split('/'))))));}
32
+ function freshAcceptance(state,task,acceptance,changes){return acceptance&&!acceptance.stale&&authorized(state,task)&&acceptance.taskFingerprint===fingerprintRequest({...task,status:'pending'})&&same(acceptance.approval,approval(state,task.id))&&same(acceptance.target,state.target)&&same(acceptance.versions,state.versions)&&checkEvidence(state,task,acceptance,changes);}
33
+ /** Operator attests semantic sufficiency; code binds exact current evidence only. */
34
+ export function evaluateCooperativeAcceptance({state,request,evidence}={}){
35
+ const task=state?.tasks?.find(t=>t.id===request?.taskId),a=request?.arguments,g=evidence?.git;
36
+ if(request?.expectedRevision!==state?.revision||request.actor?.role!=='orchestrator'||!authorized(state,task)||task.status!=='pending'||state.acceptances.some(v=>v.taskId===task.id&&!v.stale)||state.commits.some(v=>v.taskId===task.id))return hold(state,'Current pending approved task and Orchestrator acceptance required');
37
+ if(!fields(a,['messageRef','criteria','checkIds','findingIds','changeFingerprint'])||!text(a.messageRef)||!checkEvidence(state,task,a,evidence?.changes)||state.checks.some(c=>a.checkIds?.includes(c.id)&&c.verificationActor?.id===request.actor.id))return hold(state,'Exact criteria, current required QA checks and closed findings required');
38
+ const descriptor={kind:'task',parent:state.target.head,indexTree:g?.indexTree,fingerprint:g?.stagedFingerprint,paths:g?.stagedPaths};
39
+ const invalid=validateGitPreflight({target:state.target,descriptor,scope:task.paths,gitEvidence:g});
40
+ if(invalid||dirtyOtherTask(state,task,g))return hold(state,invalid??'Index includes another task changes');
41
+ return allow(state,{acceptance:{...structuredClone(a),id:request.requestId,taskId:task.id,actor:structuredClone(request.actor),source:'operator-attested',descriptor:structuredClone(descriptor),taskFingerprint:fingerprintRequest({...task,status:'pending'}),approval:structuredClone(approval(state,task.id)),target:structuredClone(state.target),versions:structuredClone(state.versions)}});
42
+ }
43
+ /** Prepares a durable intent; never stages or executes a commit. */
44
+ export function prepareCooperativeCommit({state,request,gitEvidence,evidence}={}){
45
+ const task=state?.tasks?.find(t=>t.id===request?.taskId),a=state?.acceptances?.find(a=>a.id===request?.arguments?.acceptanceId&&a.taskId===request.taskId);
46
+ if(request?.expectedRevision!==state?.revision||request.actor?.role!=='orchestrator'||!fields(request.arguments,['acceptanceId'])||task?.status!=='accepted'||!freshAcceptance(state,task,a,evidence?.changes)||state.commits.some(c=>c.taskId===task.id)||state.intents.some(i=>i.operation==='commit'&&i.taskId===task.id&&['prepared','unknown','mismatch'].includes(i.status)))return hold(state,'Exact current acceptance and no prior task commit or unresolved commit required');
47
+ const invalid=validateGitPreflight({target:state.target,descriptor:a.descriptor,scope:task.paths,gitEvidence});
48
+ if(invalid||dirtyOtherTask(state,task,gitEvidence))return hold(state,invalid??'Index includes another task changes');
49
+ const expected={parent:a.descriptor.parent,tree:a.descriptor.indexTree,paths:[...a.descriptor.paths],fingerprint:a.descriptor.fingerprint,remainingPaths:[...new Set([...gitEvidence.workingPaths,...gitEvidence.untrackedPaths])].sort()};
50
+ return allow(state,{intent:{requestId:request.requestId,operation:'commit',taskId:task.id,status:'prepared',acceptanceId:a.id,acceptanceFingerprint:fingerprintRequest(a),expected,target:structuredClone(state.target),versions:structuredClone(state.versions),fingerprint:fingerprintRequest(request),source:'operator-attested'}});
51
+ }
52
+ /** Results are local Git observations, correlated with an operator statement.
53
+ * Mismatch observations remain historical evidence and never rebind the target. */
54
+ export function reconcileCooperativeCommit({state,intent,result,gitEvidence}={}){
55
+ if(!intent||intent.operation!=='commit'||!['prepared','unknown','mismatch'].includes(intent.status)||state.commits.some(c=>c.taskId===intent.taskId))return hold(state,'Matching unresolved commit intent required; replay cannot authorize another effect');
56
+ const task=state.tasks.find(t=>t.id===intent.taskId),a=state.acceptances.find(a=>a.id===intent.acceptanceId),g=gitEvidence;
57
+ const observation=g?structuredClone(g):null;
58
+ const transition={observation,result:{...structuredClone(result),status:'mismatch',source:'operator-attested'}};
59
+ const reject=reason=>({...hold(state,reason),proposedTransition:transition});
60
+ if(!result||!text(result.messageRef)||!fields(result.data,['commit'])||!['succeeded','failed','unknown','mismatch'].includes(result.status))return reject('Exact commit result statement required');
61
+ if(result.status!=='succeeded'){transition.result.status=result.status;return reject('Execution did not establish a successful commit');}
62
+ if(task?.status!=='accepted'||!authorized(state,task)||a?.stale||!a||intent.acceptanceFingerprint!==fingerprintRequest(a)||a.taskFingerprint!==fingerprintRequest({...task,status:'pending'})||!same(a.approval,approval(state,task.id))||!checkEvidence(state,task,a,{tasks:{[task.id]:a.changeFingerprint}})||!same(intent.target,state.target)||!same(intent.versions,state.versions)||!g?.commit||result.data.commit!==g.commit.commit||g.stagedPaths?.length||g.indexTree!==g.commit.tree)return reject('Acceptance, observed commit or clean resulting index mismatch');
63
+ const actual={...g.commit,target:g.target,remainingPaths:[...new Set([...g.workingPaths??[],...g.untrackedPaths??[]])].sort()};
64
+ const invalid=validateGitCommitResult({target:state.target,expected:intent.expected,result:actual,scope:task.paths});
65
+ if(invalid)return reject(invalid);
66
+ transition.result.status='succeeded';transition.commit={...actual,taskId:task.id,requestId:intent.requestId,acceptanceId:a.id,source:'operator-attested',observationSource:'local-git',fingerprint:a.changeFingerprint};transition.target=structuredClone(g.target);
67
+ const decision=allow(state,transition);reconciliations.set(decision,{before:fingerprintRequest(state),after:fingerprintRequest(transition)});return decision;
68
+ }