@yunhozz/arc 0.5.5 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MANIFEST.sha256 +83 -74
- package/claude/agents/arc-implementer.md +2 -2
- package/claude/agents/arc-planner.md +1 -1
- package/claude/agents/arc-reviewer.md +1 -1
- package/claude/agents/arc-scouter.md +1 -1
- package/claude/agents/arc-tester.md +1 -1
- package/claude/skill/SKILL.md +3 -3
- package/claude/skill/references/arc-visual-companion.md +2 -21
- package/claude/skill/references/commit.md +3 -30
- package/claude/skill/references/coordination.md +20 -126
- package/claude/skill/references/git-recovery.md +3 -3
- package/claude/skill/references/handoff-prep.md +9 -24
- package/claude/skill/references/handoff.md +19 -108
- package/claude/skill/references/limits.md +4 -15
- package/claude/skill/references/planning.md +56 -95
- package/claude/skill/references/verification.md +16 -118
- package/claude/skill/references/worktree-creation.md +1 -1
- package/codex/agents/arc-implementer.toml +3 -1
- package/codex/agents/arc-planner.toml +4 -0
- package/codex/agents/arc-reviewer.toml +6 -0
- package/codex/agents/arc-scouter.toml +6 -0
- package/codex/agents/arc-tester.toml +6 -0
- package/codex/skill/SKILL.md +3 -3
- package/codex/skill/references/arc-visual-companion.md +3 -27
- package/codex/skill/references/commit.md +3 -30
- package/codex/skill/references/coordination.md +19 -126
- package/codex/skill/references/git-recovery.md +2 -7
- package/codex/skill/references/handoff-prep.md +9 -24
- package/codex/skill/references/handoff.md +18 -107
- package/codex/skill/references/limits.md +5 -16
- package/codex/skill/references/planning.md +56 -95
- package/codex/skill/references/verification.md +15 -117
- package/gemini/agents/arc-implementer.md +1 -1
- package/gemini/skill/SKILL.md +3 -3
- package/gemini/skill/references/arc-visual-companion.md +2 -21
- package/gemini/skill/references/commit.md +3 -30
- package/gemini/skill/references/coordination.md +23 -129
- package/gemini/skill/references/git-recovery.md +3 -3
- package/gemini/skill/references/handoff-prep.md +9 -24
- package/gemini/skill/references/handoff.md +19 -108
- package/gemini/skill/references/limits.md +4 -15
- package/gemini/skill/references/planning.md +56 -95
- package/gemini/skill/references/verification.md +16 -118
- package/grok/agents/arc-implementer.md +1 -1
- package/grok/skill/SKILL.md +2 -2
- package/grok/skill/references/arc-visual-companion.md +2 -21
- package/grok/skill/references/commit.md +3 -30
- package/grok/skill/references/coordination.md +21 -127
- package/grok/skill/references/git-recovery.md +3 -3
- package/grok/skill/references/handoff-prep.md +9 -24
- package/grok/skill/references/handoff.md +19 -108
- package/grok/skill/references/limits.md +4 -15
- package/grok/skill/references/planning.md +56 -95
- package/grok/skill/references/verification.md +16 -118
- package/lib/policy/role-policy.json +1 -1
- package/lib/prompts/agent-fragments.json +20 -9
- package/lib/prompts/render.mjs +16 -5
- package/lib/runtime/adapters/codex.mjs +1 -1
- package/lib/runtime/assignment.mjs +3 -2
- package/lib/runtime/cooperative.mjs +36 -3
- package/lib/runtime/evaluate.mjs +21 -6
- package/lib/runtime/gate.mjs +2 -1
- package/lib/runtime/schema.mjs +16 -0
- package/lib/runtime/target-preparation.mjs +7 -2
- package/lib/runtime/verification.mjs +1 -1
- package/package.json +1 -1
- package/shared/skill/references/arc-visual-companion-common.md +39 -0
- package/shared/skill/references/commit-common.md +45 -0
- package/shared/skill/references/coordination-common.md +193 -0
- package/shared/skill/references/git-recovery-common.md +15 -0
- package/shared/skill/references/handoff-common.md +182 -0
- package/shared/skill/references/handoff-prep-common.md +53 -0
- package/shared/skill/references/limits-common.md +34 -0
- package/shared/skill/references/planning-common.md +185 -0
- package/shared/skill/references/verification-common.md +170 -0
- package/shared/skill/runtime/adapters/codex.mjs +1 -1
- package/shared/skill/runtime/assignment.mjs +3 -2
- package/shared/skill/runtime/cooperative.mjs +36 -3
- package/shared/skill/runtime/evaluate.mjs +21 -6
- package/shared/skill/runtime/gate.mjs +2 -1
- package/shared/skill/runtime/role-policy.json +1 -1
- package/shared/skill/runtime/schema.mjs +16 -0
- package/shared/skill/runtime/target-preparation.mjs +7 -2
- package/shared/skill/runtime/verification.mjs +1 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Verification and acceptance — shared text
|
|
2
|
+
|
|
3
|
+
This file holds text shared by every platform's verification.md. Each part belongs to the section that links to it and has the same force there.
|
|
4
|
+
|
|
5
|
+
<a id="test-scope-and-result-comparison"></a>
|
|
6
|
+
## Test scope and result comparison
|
|
7
|
+
|
|
8
|
+
Tester briefs MUST include the required field `mode: task | final`. One assignment performs one mode; the only exception is the approved full regression follow-up in final mode.
|
|
9
|
+
|
|
10
|
+
**Task mode** assigns a fresh Tester for each top-level task requiring Tester verification. Task checks and rechecks verify uncommitted work and run only tests related to the change: test files that directly exercise a changed module, contract tests that the change requires updating, and the matching check scripts. The brief lists the minimum set; executors MAY add only items in these three categories, each with a reason. Other additions need Orchestrator authorization. Report every selected item and why. Read only to confirm the brief and identify tests in those categories. In task mode, NEVER run full regression or substitute checks. In task mode, DO NOT search reverse dependencies. Failures follow Implementer → Tester recheck, reusing the current Tester for the same task. This rule takes precedence over the upstream TDD per-task project-suite instruction; upstream text is unchanged. Report every failure observed in any run by name.
|
|
11
|
+
|
|
12
|
+
**Final mode** runs once after all tasks are accepted and committed, as one fresh Tester assignment at the verified HEAD of the execution target worktree. Run (1) all contract tests, (2) all check scripts, (3) the related tests of re-changed files and (4) substitute checks for applicable triggers. Final mode does not rerun the union of tests that task Tester already passed. A re-changed file is a file that a task's Tester verified, as a changed file or a related test file it ran, and that a later commit changed after that task's focused commit (`git diff --name-only <task commit> HEAD`), plus every non-documentation file changed in base..HEAD by a commit that no task Tester verified. Orchestrator computes the list and cites it in the brief; Tester cross-checks it with read-only `git diff`, MAY add items only within the three categories above with reasons, and reports the reason when the list is empty. Tester records `git status --porcelain` at start and end; a state that is not clean is an environment block that holds final verification. While it runs, neither Orchestrator nor any Implementer writes in that workspace. A new failure from final verification follows Implementer → Tester. The final Reviewer starts only after final-mode Tester work concludes: the final Tester report is delivered, every new failure is resolved through Implementer → Tester recheck, every new-failure candidate and intermittent candidate is dispositioned, any approved full regression is complete and every undeterminable-scope item is dispositioned under **Undeterminable scope** below. Reviewer output produced before that point is not the initial final review.
|
|
13
|
+
|
|
14
|
+
**Command execution:** Implementer and Tester briefs MUST NOT prescribe detached execution such as `&`, `nohup` or `setsid`; they require long commands to run in the foreground and be waited on in the same session until an exit code. Orchestrator does not run a Tester's assigned suites in its place unless Tester reports an environment block with evidence and the user chooses that run.
|
|
15
|
+
|
|
16
|
+
**Suite parallelism:** A Tester runs each multi-file suite command with the test runner's built-in parallel mode inside that one foreground command; a parallel mode that needs a package or plugin not already installed counts as no parallel mode. It runs a suite sequentially only when its tests are known to interfere with each other or the runner has no parallel mode, and reports the reason. Briefs MUST NOT split a suite into sequential groups for any other reason; splitting across Testers follows **Full regression shards** below. This changes how a command runs, not which tests run.
|
|
17
|
+
|
|
18
|
+
Read-only reverse dependency search is allowed in final mode. Use the project's affected tool only in list or dry-run form with no writes, installs or cache generation; otherwise report an environment block and continue with the next step of the impact procedure.
|
|
19
|
+
|
|
20
|
+
**Trigger substitute checks** run in final mode for each applicable trigger: (1) the change modifies a shared module; (2) changes made by others were integrated after the approved base, by merge, rebase onto a newer base or cherry-pick; (3) the change modifies dependency manifests or lockfiles, language or runtime versions, or build or test configuration; (4) the change removes, renames or changes the signature of a public interface such as an exported function, CLI option or configuration key. A shared module is code, configuration, schema, data or generator input that more than one task, role, component or execution or delivery path imports, loads or renders at run time, including its mirrors and generated outputs; documentation read only by people and modules used by a single component are not shared. Decide from actual consumers; when they cannot be determined, treat the module as shared.
|
|
21
|
+
|
|
22
|
+
Planner records a provisional trigger judgment with the substitute-check list and reasons in the plan. Orchestrator cites its provisional judgment and reasons in the final-mode Tester brief. Tester independently checks triggers (1), (3) and (4) from the base..HEAD diff and log and checks trigger (2) using the integration history cited by Orchestrator. If trigger applicability is undeterminable, report it as unverified. If no trigger applies, omit substitute checks and report the reason. Change size, risk level alone and out-of-scope failures seen during task checks are not triggers; report such failures as findings.
|
|
23
|
+
|
|
24
|
+
| Trigger | Substitute check | Undeterminable when |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| (1) Shared module | Trace reverse dependencies transitively and run tests reached. Include static import, require, load and path-string references, including mirrors and generated outputs. If the set cannot be determined, expand once to the nearest package manifest directory, otherwise the test directory. | A suspected dynamic reference. |
|
|
27
|
+
| (2) Integrated changes | Add incoming changes and conflict-resolution files to the changed set and apply the same impact procedure. Reuse external CI or verification evidence only for the same commit or tree hash. | An uncertain integration history. |
|
|
28
|
+
| (3) Dependencies | Use the lockfile diff to find packages whose resolved version changed, including transitive dependencies. Run tests for modules that import those packages. | A missing or unreadable lockfile. |
|
|
29
|
+
| (3) Language, runtime, build or test configuration | Run one representative test per package or test directory. Use project-declared smoke tests first, otherwise select the lexicographically first test file per directory, and record why each test was selected. | An unidentifiable package or test layout. |
|
|
30
|
+
| (4) Public interface | Search for in-repository callers by identifiers, CLI option strings and configuration keys and run their tests. Final mode already runs all contract tests. Report that consumers outside the repository are unverified because they are outside this search scope. | A suspected dynamic reference. |
|
|
31
|
+
|
|
32
|
+
Select substitute checks in this impact procedure order:
|
|
33
|
+
|
|
34
|
+
1. Reuse evidence for the same commit or tree hash and record the basis.
|
|
35
|
+
2. Use the project's affected tool under the final-mode conditions above.
|
|
36
|
+
3. Trace reverse dependencies and record why steps 1 and 2 were not used.
|
|
37
|
+
4. If the affected set remains unclear, expand the boundary one step to the nearest package manifest directory, otherwise the test directory.
|
|
38
|
+
5. If the scope still cannot be determined, report as undeterminable (unverified).
|
|
39
|
+
|
|
40
|
+
A suspected dynamic reference goes directly to step 5.
|
|
41
|
+
|
|
42
|
+
**Undeterminable scope** requires Tester to report each item, cause, substitute checks run and remaining unverified scope. Orchestrator asks the user to (i) approve full regression, (ii) substitute the project CI full test results, or (iii) disposition as unverified. Until the user decides, final acceptance and the final Reviewer are held, while independent work continues. Resolution of unknown state is never auto-decided in Full Auto. A disposition as unverified does not turn a criterion into proven.
|
|
43
|
+
|
|
44
|
+
**Approved full regression** requires explicit user approval, and the current final-mode Tester runs it as a follow-up; no new Tester is assigned except shard Testers under **Full regression shards** below. On resume, bridge resumes the same dispatch and native continues the same assignment. For bridge, each segment starts a new lease.timeoutMinutes timer. When resuming either route, if the same assignment cannot continue, report an environment block and hold; the user decides whether to assign a new Tester. Approval is valid only for that workflow and HEAD and expires when HEAD changes. If HEAD changes before the final Reviewer starts, an expired approval needs re-approval and a rerun at the new HEAD, or a fresh disposition under **Undeterminable scope**, before the Reviewer starts. The approved full regression runs once per approval. Approved full regression failures follow the base check below.
|
|
45
|
+
|
|
46
|
+
**Full regression shards:** Orchestrator MAY split an approved full regression into shards only when, from recorded prior run times, it is likely to exceed one Tester's time limit for its route, such as the bridge `arc_tester` 60-minute lease, or when independent suites, such as a sequential Python suite and a Node suite, can run at the same time; it records the reason. A shard is one whole suite command or a set of whole test files, never a subset of test names. Before dispatch Orchestrator lists every test file and suite command of the approved full regression at the verified HEAD as the inventory and writes a shard manifest that assigns each item to exactly one shard, so that the shards do not overlap and their union equals the inventory. Tests known to share state, such as fixed ports, the same temporary or workspace paths, the git common directory or global configuration, go in one shard. The current final-mode Tester runs one shard as its follow-up; each other shard goes to a fresh Tester whose `mode: final` brief adds `shard: <id> of <n>`, the shard's files or command and the manifest. The current final-mode Tester's follow-up brief also adds `shard: <id> of <n>` and its shard's files or command. Each shard Tester runs only its shard with no other final-mode checks, reports the files it actually ran and classifies failures only by the static check under **Baseline** below. All shards run at the same verified HEAD in the same workspace; each Tester records `git status --porcelain` at start and end, and no one writes in that workspace until every shard ends. Orchestrator reserves the whole shard batch under [limits](limits.md#counting-and-reservations) and serializes shards that do not fit; each shard Tester is a created and active instance, and the follow-up adds none. When the runner has a parallelism option, Orchestrator sets it per shard so that the combined workers stay within the host's available parallelism. After every shard has reported, Orchestrator sends the shard failures that need a base run to the current final-mode Tester, which reruns each alone at HEAD, with no other test command running in that workspace, up to the brief's isolated rerun limit; a pass alone is an intermittent candidate, and a failure alone follows the base check below; this rerun classifies the failure and is not the intermittency check under **Result comparison**. A rerun at HEAD that the environment blocks leaves that failure a new-failure candidate for Orchestrator disposition. Orchestrator merges the shard results and verifies that every inventory item has complete results exactly once; an item without complete results is a new-failure candidate and leaves the run incomplete. A blocked or timed-out shard follows the resume rule above; its items stay unverified, and the user decides whether a new Tester runs only the items without complete results. Sharding splits the one approved run and adds no run. The approved full regression is complete only when every shard has reported, coverage is verified and every shard failure is classified or dispositioned. Record the reason, inventory, manifest, Tester IDs and per-shard results with the approved full regression record.
|
|
47
|
+
|
|
48
|
+
**CI substitution** requires results for the same commit SHA as the verified HEAD or a matching tree hash with evidence, all jobs completed, accessible per-test-name results, results collected read-only by Orchestrator and cited in the brief, and an explicit user approval record. Use CI results as evidence only for the tests and scope they cover when every condition is met; otherwise a new-failure candidate or unverified is the applicable classification. This collection grants no external action authority.
|
|
49
|
+
|
|
50
|
+
**Baseline:** No baseline run is recorded in advance, and no base worktree is prepared in advance. Tester classifies each failure in two steps. First, a static check against the approved base: task Tester, which verifies uncommitted work, uses read-only `git diff --name-only <approved base>` plus the untracked files from `git status --porcelain`; final verification Tester uses `git diff --name-only <approved base> HEAD`. Tester checks whether the test file, the modules it directly imports or loads, the fixtures or data it reads, or its test configuration changed. If none changed, it is an unrelated failure: report it separately with that evidence; it is not a finding, and Orchestrator dispositions it. Because it rests on the diff, not a run, NEVER report it as a baseline failure. If any changed, or the check cannot decide (for example a dynamic import, a failure without a test name, or a file-level load failure), report the failure as needing a base run, with the changed paths. Second, only for those failures, Orchestrator prepares a clean detached worktree of the approved base revision at `<git-common-dir>/arc/base/<workflow>`, never under a managed worktree directory (such as `.claude/worktrees/`) or inside the execution target worktree, reuses it for that workflow, runs no tests there, and sends its path and prerequisite state (prepared, or not prepared with the needed commands) to the current Tester. After all final dispositions Orchestrator removes it only if it is still clean; this ARC-owned base worktree is the only exception to the Preservation rule's worktree-deletion ban, and any other state holds removal for the user. Tester runs only those test names alone in the base worktree, for example with Node `--test-name-pattern` or a Python node id. A failure under the same name at base is a baseline failure; a pass at base, or a test or file absent at base, makes it a new failure; a base run that was not performed, was blocked by the environment, failed to load or lacks the name makes it a new-failure candidate. NEVER absorb a candidate as a baseline failure. Check a file-level load or collection failure by loading the same file at base; an identical load failure at base stays a new-failure candidate (same at base) for Orchestrator disposition. If base needs prerequisites or the sandbox prevents running there, Tester installs or generates nothing and reports an environment block; Orchestrator then prepares the prerequisites or assigns a separate Tester whose workspace is the base worktree. If both are blocked, those failures stay new-failure candidates for Orchestrator disposition. Static checks and base reruns classify failures; they are not intermittency diagnosis.
|
|
51
|
+
|
|
52
|
+
<a id="risk-scaled-execution"></a>
|
|
53
|
+
## Risk-scaled execution
|
|
54
|
+
|
|
55
|
+
The [fast gate](handoff.md#orchestrator-direct-path-for-small-tasks) references this risk definition; refresh affected evidence when inputs change and preserve independent verification boundaries.
|
|
56
|
+
|
|
57
|
+
<a id="risk-scaled-execution-2"></a>
|
|
58
|
+
## Risk-scaled execution
|
|
59
|
+
|
|
60
|
+
Ordinary/significant tasks need fresh Tester before acceptance. Low risk requires narrow/understood/reversible/focused-verifiable work. Ordinary behavior fails these without significant triggers. Shared role/behavior contracts/state, lifecycle/integration order, security/permissions, data loss/migration, public interfaces and costly install/deploy/rollback are significant. Substantial behavior/contracts are significant regardless of file count. Unclear risk requires investigation/higher flow. Environment failure waives no check or depth judgment.
|
|
61
|
+
|
|
62
|
+
- Task boundaries alone add no Tester/review. Reviewer is never a plan-task/commit prerequisite. Plans review once at final relevant state after task acceptances/checks and concluded final-mode Tester work; no-plan Reviewer follows Tester before acceptance.
|
|
63
|
+
- Preserve specific commitments. Risky unverified dependencies need Tester/resolved or explicitly dispositioned findings before implementation.
|
|
64
|
+
- Reuse evidence only for matching scope/state/independence/freshness/flow position. Changes/failures/missing-conflicting evidence invalidate affected reuse.
|
|
65
|
+
- Tester independently checks without edits. Reviewer performs no Tester/planning/editing/delegation/completion decisions. Orchestrator routes fixes to Implementer and required Tester rechecks; direct-check failures return to normal flow. Accept after findings/gaps resolved or dispositioned.
|
|
66
|
+
- Fresh-per-task applies to Implementer/Tester, not Reviewer. Reuse Reviewer only with independence, valid context and refreshed scope/target/evidence, never an old verdict or waived timing/coverage.
|
|
67
|
+
|
|
68
|
+
Record which risk/instruction/approved obligations each check satisfies. DO NOT automatically assign Tester/Reviewer for clear low-risk scope with sufficient evidence and no requirement. Metadata counts alone prove no significance; one permission/loss rule may. Vague file deletion is not low-risk evidence; reclassify installer/manifest impacts. Confirm cleanup targets unused, required materials intact, ignore patterns scoped and diff approved before focused-check-only acceptance.
|
|
69
|
+
|
|
70
|
+
Distinguish environment failures from code failures and report exact limits and gaps. Use Planner/Scouter only for unresolved planning/discovery. Reviewer covers substantial correctness/factual/security/data/interface risks. Orchestrator assigns support as needed. Claim only verified outputs. Read cited `references/test-driven-development.md`, preserving exceptions.
|
|
71
|
+
|
|
72
|
+
<a id="final-plan-reviewer-correction-loop"></a>
|
|
73
|
+
### Final plan Reviewer correction loop
|
|
74
|
+
|
|
75
|
+
Only final overall Reviewer findings on plan work, including behavior, follow Implementer → Reviewer without Tester reassignment until resolved. One initial full review permits necessary rechecks. Before it, risk checks/final-mode Tester work/Tester failures/unmet criteria still need Implementer → Tester and conclude. No-plan flow remains unchanged.
|
|
76
|
+
|
|
77
|
+
Expanded scope/separate obligations/gaps hold affected work for resolution/approval. Orchestrator assigns/accepts; Reviewer stays read-only without Tester/acceptance. NEVER present old Tester as post-fix execution. Report actual actor/target/check/result/limits only.
|
|
78
|
+
|
|
79
|
+
<a id="evidence-after-plan-revision-commit"></a>
|
|
80
|
+
## Evidence after plan revision commit
|
|
81
|
+
|
|
82
|
+
Verify every committed document blob against its latest approved content hash and full approved copy. If no progress records have been committed since approval, the SHA-256 of the committed document content (not the Git blob OID) MUST equal the latest approved `contentHash`. Otherwise the diff from the latest approved copy MUST contain only classified progress records belonging to that commit's task or committed for other tasks after approval (including R-8 separation), or classified plan-level progress records carried by that commit. Record the SHA-256 of the expected content used for this comparison in the canonical record; NEVER overwrite approved copies. Verify each pending revision's status is `committed` and no pending revision remains before overall completion. Link commit SHA in the canonical record only, not the document. Preserve actual approval chronology; later committed content proves no earlier approval.
|
|
83
|
+
|
|
84
|
+
Existing commit evidence links remain valid because history is unchanged. For a contract revision, affected checks and rechecks MUST be rerun against the revised version. Stale evidence from plan-file changes requires refresh under existing rules. Preserve exact-HEAD/document/policy/fingerprint requirements; NEVER rewrite old fingerprints to suggest execution at a new state. Refresh briefs/gates before dependencies. Structure proves no live compliance.
|
|
85
|
+
|
|
86
|
+
<a id="reviewer-timing-and-task-acceptance"></a>
|
|
87
|
+
## Task acceptance and final plan acceptance
|
|
88
|
+
|
|
89
|
+
Task acceptance differs from final verification/acceptance. Connect criteria/observations/current checks/findings, not checkboxes/reports/passing commands alone. Use fresh Tester where required or low-risk focused checks. For same-task Tester findings and required Tester rechecks, reuse the current Tester while scope/workspace/ownership/context remain valid. Final overall Reviewer findings on plan work follow Implementer → Reviewer without Tester reassignment; see the [final plan Reviewer correction loop](verification.md#final-plan-reviewer-correction-loop).
|
|
90
|
+
|
|
91
|
+
<a id="reviewer-timing-and-task-acceptance-2"></a>
|
|
92
|
+
## Task acceptance and final plan acceptance
|
|
93
|
+
|
|
94
|
+
Orchestrator writes approved-base final base..HEAD diff/changed-file list to `<git-common-dir>/arc/review/<slug>.diff`, using handoff slug and absolute brief citation; inline if small/write denied. Reviewer reads artifact, not Git commands, stating limits.
|
|
95
|
+
|
|
96
|
+
<a id="ui-browser-acceptance-checks"></a>
|
|
97
|
+
### UI browser acceptance checks
|
|
98
|
+
|
|
99
|
+
Briefs MUST supply workspace, existing launch command/URL, account/test-data scope, allowed interactions and this section's accessible citation. Use existing approved environment/tool/browser-skill instructions. No source/docs/tests/config edits, dependencies or environment changes. Missing prerequisites/tools/environment leave exact reported limits/unverified criteria.
|
|
100
|
+
|
|
101
|
+
<a id="criterion-evidence-and-finding-handoff"></a>
|
|
102
|
+
### Criterion evidence and finding handoff
|
|
103
|
+
|
|
104
|
+
Report every criterion by ID or wording: method/scope, run status, evidence, verdict, unverified reason/remaining scope. Run status: passed/failed/not run/environment blocked. Verdict: proven/unmet/unverified. Connect conditions/expectations to actual observations; partial/out-of-scope/missing/environment gaps stay unverified. PASS means run status only. Structure proves structure only.
|
|
105
|
+
|
|
106
|
+
Current-task failures/unmet criteria default to current Implementer/current Tester under coordination context/boundary/amendment rules; findings alone create no task. Before Reviewer, rerun reproduction/invalidated checks, reporting actor/target/results/limits and prior finding resolved/unresolved/unverified with evidence. Repeat Implementer→Tester if unresolved; Tester reuse is no stale-evidence reuse. Environment/missing/out-of-scope are gaps, not presumed code defects; Reviewer cannot replace Tester.
|
|
107
|
+
|
|
108
|
+
Reviewer behavior findings report criterion/expectation/problem/source/reproduction/evidence, separating source inference/execution. No Tester execution. Outside final-plan exception route Implementer→Tester; other Reviewer rechecks depend on scope/independence. Continue source review of structure/design/facts/security; observable security/interfaces may need both Tester/Reviewer.
|
|
109
|
+
|
|
110
|
+
Accept from criterion verdicts/findings/rechecks/gaps, not overall run status. Disposition never proves unverified. Low-risk work also links each criterion to focused evidence.
|
|
111
|
+
|
|
112
|
+
<a id="completion-continuity"></a>
|
|
113
|
+
## Completion continuity
|
|
114
|
+
|
|
115
|
+
Once approval/depth/target/handoff hold, continue execution/correction/reverification/required Tester-Reviewer/disposition/acceptance/report. Preserve timing without new task-level gates. Reports/probes/commands never complete remaining approved scope. DO NOT make authorized execution an optional offer awaiting response. Probe-only ends at question/evidence/limits; combined work follows planning. Omission changes neither risk nor acceptance. Hold only actual affected conditions and report resume requirements. Structure proves no live compliance.
|
|
116
|
+
|
|
117
|
+
<a id="verification-lifecycle-in-the-cooperative-cli"></a>
|
|
118
|
+
## Verification lifecycle in the cooperative CLI
|
|
119
|
+
|
|
120
|
+
Supported `workflow` is approved complete spec+plan. No-plan/small-task/omission is `cooperative.unsupported`, not policy violation/new documents. CLI executes no checks/Reviewer. Actors/results/verdicts are `operator-attested`, not identity/independence/semantic/enforcement proof.
|
|
121
|
+
|
|
122
|
+
1. Orchestrator (`actor.role: "orchestrator"`) registers through `record`/`acceptance-evidence` with `data: {kind: "task", task: {...}}`. Task includes `id`, absolute `paths`, `criteria`, `requiredChecks`, `dependencies`, `approvalRef`, `approvalVersion`, `documentVersion`, `scopeVersion`, `targetVersion`. Pending-only registration is not acceptance/commit. Descriptor: `{executable, args, cwd, env, outputs}`; executable/cwd/outputs absolute, cwd/outputs inside workspace. No Reviewer in task checks.
|
|
123
|
+
2. `status` observes `changeFingerprints.tasks[taskId]`/`changeFingerprints.final` independently from read-only Git inventory/index and current regular-file bytes/modes/deletions. Task covers owned paths, final the repository. Symlinks/submodules/unmerged indexes hold. This is no atomic observation/execution sandbox. RuntimeHash drift stays stale/hold without automatic stored-version update/migration/reapproval.
|
|
124
|
+
3. Check preparation: `operation: "check"`, `taskId`, `arguments: {scope: "task", actor: {id, role: "tester"}, descriptor, changeFingerprint, findingIds?}`. Tester identity attestation MUST differ from Implementer/Orchestrator; cross-task Tester/Implementer reuse is rejected. Descriptor exactly matches registration. After durable intent, execute only existing authorized scope.
|
|
125
|
+
4. `result`/`reconcile` records `intentId`, `{status, messageRef, data}` with same actor/descriptor/scope, taskId where applicable, fingerprint and `verdict: "proven" | "unmet" | "unverified"`. Even succeeded/proven applies only to that version. It replaces neither semantic proof nor acceptance. Failed/unknown/mismatch/unverified is not passing evidence. Preserve history.
|
|
126
|
+
|
|
127
|
+
Failed checks/reviews leave findings. Open separately via `data: {action: "open", id, checkId, message}`. After fixes record `data: {action: "resolve", id, actor: {id, role: "implementer"}, changeFingerprint}` plus evidence messageRef. Actor MUST be assigned to the task or relevant overall task. Resolved becomes closed only after later prepare `findingIds` and same-version successful revalidation. Prior Tester failures retain Implementer→Tester.
|
|
128
|
+
|
|
129
|
+
Final-mode Tester results are not cooperative checks; record them in the plan-level progress record and the canonical handoff record. Record undeterminable dispositions, approved full regression and CI substitution there as well.
|
|
130
|
+
|
|
131
|
+
Final review uses `operation: "review"`, `scope: "final"`, `actor.role: "reviewer"`, `descriptor: {kind: "source-review", paths: [...]}` without taskId. Initial final review needs all tasks accepted/current required Tester/concluded final-mode Tester work, never task acceptance/commit prerequisite. Plan-final findings repeat Implementer resolution→Reviewer without Tester reassignment; old Tester is not subsequent-fix execution. Separate unresolved Tester remains.
|
|
132
|
+
|
|
133
|
+
Scope/document/approval records preserve history. `data.affectedTaskIds` invalidates those tasks/dependents and task/check/acceptance evidence; omitted IDs hold all. Final evidence becomes stale. Preserve unaffected independent evidence. Orchestrator determines semantic impact. Affected tasks need new current-scope approval/contracts before preparation, not revived old approvals; fresh checks/reviews/revalidation too. Current evidence supersedes failures without deletion. Acceptance/commit/completion stay Orchestrator decisions.
|
|
134
|
+
|
|
135
|
+
<a id="task-acceptance-and-focused-commit-reconciliation-in-the-cooperative-cli"></a>
|
|
136
|
+
### Task acceptance and focused commit reconciliation in the cooperative CLI
|
|
137
|
+
|
|
138
|
+
Plan-mode `prepare` supports `operation: "accept"`/`operation: "commit"`. Acceptance attests `actor.role: "orchestrator"`, taskId and arguments messageRef/same criteria/current exact Tester checkIds/all findingIds/current fingerprint. Latest required descriptors MUST be passed/proven and findings closed by fixes/Tester. Successful attestation marks accepted; reports/checks alone do not. `operator-attested` means operator confirms semantics/identity.
|
|
139
|
+
|
|
140
|
+
Acceptance pins actual index tree/staged diff/paths/fingerprint. Stage approved paths beforehand and confirm Tester for that index. Unrelated/other-task paths or in-scope unstaged/untracked changes hold. Code cannot identify semantically unrelated same-file hunks; Orchestrator reads diff.
|
|
141
|
+
|
|
142
|
+
Commit preparation references `arguments: {"acceptanceId": "acceptance requestId"}`. Check current approval/contract/Tester/findings/index match acceptance and persist expected parent/tree/paths/residual paths. CLI stages/commits nothing. Orchestrator makes one matching focused commit.
|
|
143
|
+
|
|
144
|
+
Submit intentId/`actor.role: "orchestrator"` and `result: {"status": "succeeded", "messageRef": "actual result evidence", "data": {"commit": "full OID"}}` through reconcile/result. CLI rereads local object/parent/tree/paths/HEAD/index/residual changes. Only complete match updates target HEAD/committed. Preserve failed/unknown/mismatch/history; never arbitrary target updates. Same request/completed intent permits no repeated effect. Inspect/resolve/reconcile existing intent after failure.
|
|
145
|
+
|
|
146
|
+
NEVER rewrite Tester fingerprints after commit. Separate post-commit observations detect changes. Final review needs current task evidence/final fingerprint. RuntimeHash drift keeps existing stale/hold without automatic version update.
|
|
147
|
+
|
|
148
|
+
<a id="external-operations-and-recovery-in-the-cooperative-cli"></a>
|
|
149
|
+
## External operations and recovery in the cooperative CLI
|
|
150
|
+
|
|
151
|
+
Three phases cover state/documents/assignment; scope/verification/acceptance/focused commits; external approval/results/audit recovery. Inspect nine areas/limits with `status.support`. Support is spec+plan `plan`, not no-plan/omission. CLI executes no native/provider/push/merge/deploy/publish calls.
|
|
152
|
+
|
|
153
|
+
Operator-confirmed approvals/results are `operator-attested`, `nativeVerified: false`, `remoteVerified: false`; no outside-call blocking or independent remote verification.
|
|
154
|
+
|
|
155
|
+
Record already confirmed external approval using `evidence: {kind: "external-approval", messageRef, data: {operation, scope, descriptor}}`. `scope` is unique absolute checkout paths. Local commit approval grants no external approval. Record exact action/scope/target and all descriptor fields:
|
|
156
|
+
|
|
157
|
+
| operation | descriptor fields |
|
|
158
|
+
|---|---|
|
|
159
|
+
| push | repository, destination, refspec, sourceOid, expectedRemoteOid |
|
|
160
|
+
| merge | repository, changeRef, targetRef, expectedTargetOid |
|
|
161
|
+
| deploy | service, project, environment, artifactId, destination |
|
|
162
|
+
| publish | service, namespace, name, version, artifactHash, destination |
|
|
163
|
+
|
|
164
|
+
Git OIDs are full lowercase 40/64-character hex; artifactHash is `sha256:<64-hex>`. Without remote observation OIDs are asserted expectations, not verified state. Destination is secret-free. No URL userinfo/query/fragment/password/token/credentials. Recognized secrets are rejected before persistence, but arbitrary-string secrecy cannot be guaranteed.
|
|
165
|
+
|
|
166
|
+
`prepare` accepts `{requestId, expectedRevision, actor: {id, role: "orchestrator"}, operation, arguments: {approvalRef, scope, descriptor}}`; approvalRef matches external approval messageRef. Persist only exact approval/scope/target/runtime versions with no unresolved effects. After `allow`/`persisted: true`, Orchestrator executes separately approved scope; CLI expands no authority.
|
|
167
|
+
|
|
168
|
+
`result`/`reconcile` accept `{requestId, expectedRevision, actor, intentId, result: {status, messageRef, data: {operation, scope, descriptor}}}`, with prepare requestId as intentId. Mismatch/unknown/stale outcomes hold while preserving attestations. After interruption inspect intent/`state.requests`/`state.audit`/`state.results` through `status` and investigate actual effects. Reconcile that same intent, not fresh preparation or replayed approvals.
|
|
169
|
+
|
|
170
|
+
Cancellation also requires `notExecutedEvidence: {messageRef}`; approval remains consumed. No automatic update/migration/renewed permission to fix drift. Report holds. Succeeded results remain attestations, not remote proof. `audit` links request→decision→intent→result→resolution but is locally editable, not tamper-proof. NEVER retry uncertain external outcomes.
|
|
@@ -22,7 +22,7 @@ export function normalizeCodexEvent(input,context={}){
|
|
|
22
22
|
if(typeof context.describeTool!=='function')throw Error('Trusted semantic tool provider unavailable');
|
|
23
23
|
const semantic=context.describeTool(structuredClone(input));
|
|
24
24
|
if(!object(semantic)||!text(semantic.operation)||!Array.isArray(semantic.paths)||!object(semantic.descriptor))throw Error('Complete semantic tool descriptor required');
|
|
25
|
-
if(['Agent','spawn_agent'].includes(input.tool_name)&&semantic.operation!=='assign-agent')throw Error('
|
|
25
|
+
if(['Agent','spawn_agent'].includes(input.tool_name)&&semantic.operation!=='assign-agent')throw Error(toolPath+' tool requires assignment validation');
|
|
26
26
|
return {request:{requestId:context.requestId,platform:'codex',actorRef:context.actorRef,taskId:context.taskId,cwd:input.cwd,toolName:input.tool_name,arguments:structuredClone(input.tool_input),operation:semantic.operation,paths:structuredClone(semantic.paths),descriptor:structuredClone(semantic.descriptor)},coverage};
|
|
27
27
|
}
|
|
28
28
|
/** Only documented PreToolUse fields are emitted. hold is a native deny. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {fingerprintRequest} from './store.mjs';
|
|
2
2
|
import {absolute,within} from './scope.mjs';
|
|
3
|
+
import {hasExactPlanningKinds,expectedCooperativePlanningKinds} from './schema.mjs';
|
|
3
4
|
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'));
|
|
4
5
|
const same=(a,b)=>JSON.stringify(a)===JSON.stringify(b);
|
|
5
6
|
const text=value=>typeof value==='string'&&value.length>0;
|
|
@@ -22,8 +23,8 @@ export function prepareCooperativeAssignment({policy,state,request,observations}
|
|
|
22
23
|
if(task&&(task.invalidated||task.status==='held'||task.dependencies?.some(id=>{const predecessor=state.tasks.find(t=>t.id===id);return !predecessor||predecessor.invalidated||!['accepted','committed'].includes(predecessor.status);})))return hold(state,'task-stale','Affected task or predecessor requires renewed readiness and approval');
|
|
23
24
|
const scope=state.scopes?.findLast(s=>s.scopeVersion===state.scopeVersion&&(!s.data.affectedTaskIds||s.data.affectedTaskIds.includes(request.taskId)));
|
|
24
25
|
if(!task||!task.paths?.length||args.paths.some(p=>!task.paths.some(base=>within(base,p)))||scope&&args.paths.some(p=>!scope.data.paths?.some(base=>within(base,p))))return hold(state,'assignment-scope','Assignment must stay inside approved task and recorded scope');
|
|
25
|
-
const documents=args.documents,git=observations.git;
|
|
26
|
-
if(!
|
|
26
|
+
const documents=args.documents,git=observations.git,kinds=expectedCooperativePlanningKinds(state);
|
|
27
|
+
if(!hasExactPlanningKinds(documents,kinds)||!git.docsCommit||!setEqual(git.docsCommit.paths,documents.map(d=>d.gitPath))||!same(git.docsCommit.documents,documents)||documents.some(d=>d.commit!==git.docsCommit.commit)||!hasExactPlanningKinds(git.documents,kinds)||documents.some(d=>!git.documents.some(o=>o.path===d.path&&o.gitPath===d.gitPath&&o.kind===d.kind&&o.observedHash===d.contentHash&&o.currentHash===d.contentHash)))return hold(state,'documents','Exact committed spec and plan plus current bytes must match approval');
|
|
27
28
|
const approval=state.records.filter(r=>r.kind==='approval'&&(!r.data.affectedTaskIds||r.data.affectedTaskIds.includes(request.taskId))).at(-1);
|
|
28
29
|
if(task.approvalRef!==args.approvalRef||task.approvalVersion!==args.approvalVersion||task.documentVersion!==args.documentVersion||task.scopeVersion!==state.scopeVersion||task.targetVersion!==state.targetVersion||!approval||approval.source!=='operator-attested'||approval.messageRef!==args.approvalRef||approval.targetVersion!==state.targetVersion||approval.scopeVersion!==state.scopeVersion||approval.data.approvalVersion!==args.approvalVersion||approval.data.documentVersion!==args.documentVersion||!same(approval.data.documents,documents)||documents.some(d=>d.approvalRef!==args.approvalRef))return hold(state,'approval','Current document and approval versions must match');
|
|
29
30
|
const intent={requestId:request.requestId,taskId:request.taskId,operation:request.operation,status:'prepared',role:args.role,paths:[...args.paths],operations:[...args.operations],correlation:args.correlation,documents:structuredClone(documents),docsCommit:git.docsCommit.commit,approvalRef:args.approvalRef,approvalVersion:args.approvalVersion,documentVersion:args.documentVersion,target:structuredClone(state.target),targetVersion:state.targetVersion,scopeVersion:state.scopeVersion,revision:state.revision+1,fingerprint:fingerprintRequest(request),source:'operator-attested'};
|
|
@@ -13,6 +13,7 @@ import {fingerprintRequest,saveDurableState,applyCooperativeCommitTransition,app
|
|
|
13
13
|
import {commandResult,cooperativeVersions} from './bootstrap.mjs';
|
|
14
14
|
import {evaluateCooperative,reconcileCooperativeResult} from './evaluate.mjs';
|
|
15
15
|
import {evaluateTargetPreparation,readTargetPreparationEvidence} from './target-preparation.mjs';
|
|
16
|
+
import {expectedCooperativePlanningKinds,hasExactPlanningKinds,preparedTargetIntent} from './schema.mjs';
|
|
16
17
|
const same=(a,b)=>JSON.stringify(a)===JSON.stringify(b);
|
|
17
18
|
const sameCheckout=(a,b)=>['realpath','gitCommonDir','gitDir'].every(k=>a[k]===b[k]);
|
|
18
19
|
/** Only trusted code may inject observation/storage. CLI JSON cannot set either. */
|
|
@@ -59,8 +60,17 @@ export async function runCooperativeCommand({cwd,workflowId,command,input,observ
|
|
|
59
60
|
const changes=state.tasks.length?await readChanges({state}):undefined;
|
|
60
61
|
const plannerArtifacts=plannerWork?await readPlannerArtifacts(state,command==='record'&&input.evidence.kind==='planner-evidence'?input.evidence:undefined):undefined;
|
|
61
62
|
const plannerHistory=command==='record'&&input.evidence.kind==='planner-stage'?await readPlannerHistory(state,statePath,input.evidence.data.document?.path):{};
|
|
63
|
+
let reviewedSpec;
|
|
64
|
+
if(command==='record'&&input.evidence.kind==='planner-stage'&&input.evidence.data.document?.kind==='plan'){
|
|
65
|
+
const intent=preparedTargetIntent(state),spec=intent?.documents.find(d=>d.kind==='spec');
|
|
66
|
+
if(spec){
|
|
67
|
+
let observed;
|
|
68
|
+
try{observed=await readTargetPreparationEvidence({state,targetIntent:intent,destination:{realpath:state.target.realpath,path:spec.path},observe,readChanges});}catch{}
|
|
69
|
+
reviewedSpec={path:spec.path,hash:observed?.destination?.document?.hash};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
62
72
|
let destinationReview=false;
|
|
63
|
-
let decision=evaluateCooperative({state,request:{command,input},evidence:{target:currentTarget,versions,git,changes,requestFingerprint,plannerArtifacts,...plannerHistory}});
|
|
73
|
+
let decision=evaluateCooperative({state,request:{command,input},evidence:{target:currentTarget,versions,git,changes,requestFingerprint,plannerArtifacts,...plannerHistory,reviewedSpec}});
|
|
64
74
|
if(command==='record'&&input.evidence.kind==='planner-review'){
|
|
65
75
|
const data=input.evidence.data,stage=state.plannerLedger?.stages.find(s=>s.id===data.stageId),intent=state.targetIntents?.find(i=>i.id===stage?.targetIntentId),transition=state.targetTransitions?.find(t=>t.intentId===intent?.id&&t.targetVersion===state.targetVersion),document=intent?.documents.find(d=>d.kind===stage?.document.kind);
|
|
66
76
|
if(transition&&document){
|
|
@@ -70,7 +80,11 @@ export async function runCooperativeCommand({cwd,workflowId,command,input,observ
|
|
|
70
80
|
decision=valid?{decision:'allow',ruleIds:['cooperative.target-preparation']}:{decision:'hold',ruleIds:['cooperative.target-preparation'],reason:'Current destination bytes and complete source-bound review required'};
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
|
-
if(command==='record'&&['document','approval'].includes(input.evidence.kind)
|
|
83
|
+
if(command==='record'&&['document','approval'].includes(input.evidence.kind)){
|
|
84
|
+
const {kind,data}=input.evidence;
|
|
85
|
+
const documents=kind==='approval'&&Array.isArray(data.documents)?data.documents:[data];
|
|
86
|
+
if(state.targetIntents?.some(intent=>!state.targetTransitions?.some(t=>t.intentId===intent.id)&&intent.documents.some(doc=>documents.some(d=>d?.kind===doc.kind&&[doc.path,path.join(intent.sourceTarget.realpath,doc.path)].includes(d.path)))))decision={decision:'hold',ruleIds:['cooperative.target-preparation'],reason:'Prepared target transition required before document records'};
|
|
87
|
+
}
|
|
74
88
|
if(command==='record'&&input.evidence.kind==='approval'){
|
|
75
89
|
const data=input.evidence.data,intent=state.targetIntents?.find(i=>state.targetTransitions?.some(t=>t.intentId===i.id&&t.targetVersion===state.targetVersion)&&i.documents.some(d=>d.kind===data.kind));
|
|
76
90
|
if(intent){
|
|
@@ -81,6 +95,25 @@ export async function runCooperativeCommand({cwd,workflowId,command,input,observ
|
|
|
81
95
|
if(stage?.scopeVersion!==state.scopeVersion||![document.path,path.join(state.target.realpath,document.path)].includes(data.path)||!review||observed?.destination?.document?.hash!==data.contentHash||!same(currentTarget,state.target)||!same(versions,state.versions)||input.actor.role!=='orchestrator')decision={decision:'hold',ruleIds:['cooperative.target-preparation'],reason:'Current reviewed destination bytes required for approval'};
|
|
82
96
|
}
|
|
83
97
|
}
|
|
98
|
+
if(command==='record'&&input.evidence.kind==='approval'&&Array.isArray(input.evidence.data.documents)&&decision.decision==='allow'){
|
|
99
|
+
const intent=preparedTargetIntent(state),documents=input.evidence.data.documents;
|
|
100
|
+
if(intent){
|
|
101
|
+
let valid=input.actor.role==='orchestrator'&&same(currentTarget,state.target)&&same(versions,state.versions)&&hasExactPlanningKinds(documents,expectedCooperativePlanningKinds(state));
|
|
102
|
+
for(const doc of intent.documents){
|
|
103
|
+
if(!valid)break;
|
|
104
|
+
const absolutePath=path.join(state.target.realpath,doc.path);
|
|
105
|
+
const entry=documents.find(d=>d.kind===doc.kind&&[doc.path,absolutePath].includes(d.path));
|
|
106
|
+
const firstStage=state.plannerLedger?.stages.find(s=>s.id===intent.firstStageId);
|
|
107
|
+
const stage=firstStage?.document.kind===doc.kind?firstStage:state.plannerLedger?.stages.find(s=>s.document.kind===doc.kind&&s.document.path===absolutePath&&s.targetVersion===state.targetVersion);
|
|
108
|
+
const review=entry&&state.records.findLast(r=>r.kind==='planner-review'&&r.source==='operator-attested'&&r.scopeVersion===state.scopeVersion&&r.targetVersion===state.targetVersion&&r.data?.stageId===stage?.id&&r.data?.resultRef===stage?.result?.ref&&r.data?.full===true&&r.data?.complete===true&&r.data?.hash===entry.contentHash);
|
|
109
|
+
if(!review||stage?.scopeVersion!==state.scopeVersion){valid=false;break;}
|
|
110
|
+
let observed;
|
|
111
|
+
try{observed=await readTargetPreparationEvidence({state,targetIntent:intent,destination:{realpath:state.target.realpath,path:doc.path},observe,readChanges});}catch{}
|
|
112
|
+
valid=same(observed?.destination?.target,state.target)&&observed.destination.document?.hash===entry.contentHash;
|
|
113
|
+
}
|
|
114
|
+
if(!valid)decision={decision:'hold',ruleIds:['cooperative.target-preparation'],reason:'Current reviewed bytes required for every approved document'};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
84
117
|
if(command==='record'&&input.evidence.kind==='target-preparation'){
|
|
85
118
|
let observed;
|
|
86
119
|
try{const intent=state.targetIntents?.find(i=>i.id===input.evidence.data.intentId);observed=await readTargetPreparationEvidence({state,targetIntent:intent,destination:input.evidence.data.destination,observe,readChanges});}catch{}
|
|
@@ -171,7 +204,7 @@ export async function runCooperativeCommand({cwd,workflowId,command,input,observ
|
|
|
171
204
|
const task=state.tasks.find(t=>t.id===id),approval=state.records.findLast(r=>r.kind==='approval'&&(!r.data.affectedTaskIds||r.data.affectedTaskIds.includes(id)));
|
|
172
205
|
if(!task||task.invalidated||task.scopeVersion!==state.scopeVersion||!approval||approval.revision<=marker.revision||approval.scopeVersion!==state.scopeVersion||approval.targetVersion!==state.targetVersion||task.approvalRef!==approval.messageRef||task.approvalVersion!==approval.data.approvalVersion||task.documentVersion!==approval.data.documentVersion){ready=false;break;}
|
|
173
206
|
const documents=approval.data.documents;
|
|
174
|
-
if(!
|
|
207
|
+
if(!hasExactPlanningKinds(documents,expectedCooperativePlanningKinds(state))){ready=false;break;}
|
|
175
208
|
try{const observed=await readGit({target:currentTarget,documents});if(!same(observed.target,currentTarget)||!observed.docsCommit||!same(observed.docsCommit.documents,documents)||documents.some(d=>d.commit!==observed.docsCommit.commit||d.approvalRef!==approval.messageRef||!observed.documents?.some(o=>o.path===d.path&&o.gitPath===d.gitPath&&o.observedHash===d.contentHash&&o.currentHash===d.contentHash))){ready=false;break;}}
|
|
176
209
|
catch{ready=false;break;}
|
|
177
210
|
const scope=state.scopes.find(s=>s.scopeVersion===state.scopeVersion);if(!scope||task.paths.some(p=>!scope.data.paths.some(base=>within(base,p)))){ready=false;break;}
|
|
@@ -15,7 +15,7 @@ import {prepareCooperativeAssignment} from './assignment.mjs';
|
|
|
15
15
|
*/
|
|
16
16
|
import path from 'node:path';
|
|
17
17
|
import {legacyCooperativeRoleDenial,validateCooperativeState,validateCooperativeCommand} from './cooperative-schema.mjs';
|
|
18
|
-
import {validateWorkflowState, validateRequest, validateEvidence,validatePlannerStage} from './schema.mjs';
|
|
18
|
+
import {validateWorkflowState, validateRequest, validateEvidence,validatePlannerStage,hasExactPlanningKinds,planningDocumentKinds} from './schema.mjs';
|
|
19
19
|
import {ROLES, ROLE_OPERATIONS, GIT_OPERATIONS, EXTERNAL_OPERATIONS, canonicalCooperativeRole} from './operations.mjs';
|
|
20
20
|
const same=(a,b)=>JSON.stringify(a)===JSON.stringify(b);
|
|
21
21
|
const within=(base,file)=>{const relative=path.relative(base,file);return relative===''||(!relative.startsWith('..'+path.sep)&&relative!=='..'&&!path.isAbsolute(relative));};
|
|
@@ -68,7 +68,7 @@ export function evaluate(policy, state, request, evidence){
|
|
|
68
68
|
if(d.role==='implementer'){
|
|
69
69
|
if(state.mode==='plan'){
|
|
70
70
|
// T3 supplies verified Git object evidence. Local assertions never satisfy this gate.
|
|
71
|
-
if(!state.documents
|
|
71
|
+
if(!hasExactPlanningKinds(state.documents,planningDocumentKinds(state.planningDepth)))return result('hold','runtime.docs-commit','approved complete planning-document set required',['approved-documents','docs-only-commit']);
|
|
72
72
|
const docs=fact('docs-commit')?.data;
|
|
73
73
|
const approved=state.documents.every(d=>state.approvals.some(a=>a.id===d.approvalRef&&a.contentHash===d.contentHash&&evidence.provenance.some(p=>p.id===a.id&&p.source===a.source&&p.verification.sourceRef===p.messageRef&&p.messageRef===a.messageRef&&p.contentHash===d.contentHash)));
|
|
74
74
|
if(!approved||!docs||!docs.commit||!docs.parent||!docs.tree||!same(docs.documents,state.documents)||!same([...docs.paths??[]].sort(),state.documents.map(d=>d.gitPath).sort())||state.documents.some(d=>d.commit!==docs.commit))return result('hold','runtime.docs-commit','Git object and approval verification required',['verified-docs-only-commit']);
|
|
@@ -88,7 +88,12 @@ export function evaluate(policy, state, request, evidence){
|
|
|
88
88
|
const stage=state.plannerLedger?.stages.find(s=>s.id===d.plannerCall?.stageId),proof=fact('planner-call');
|
|
89
89
|
const contract=stage&&{document:stage.document,inputVersion:stage.inputVersion,criteriaVersion:stage.criteriaVersion,scopeVersion:stage.scopeVersion};
|
|
90
90
|
if(!stage||stage.workflowId!==state.workflowId||stage.approvalRef!==approval.id||!same(approval.scope.plannerStage,contract)||!d.paths.includes(stage.document.path)||proof?.sourceRef!==correlation.sourceRef||!same({stageId:proof?.data.stageId,inputVersion:proof?.data.inputVersion,criteriaVersion:proof?.data.criteriaVersion,scopeVersion:proof?.data.scopeVersion},{stageId:stage.id,inputVersion:stage.inputVersion,criteriaVersion:stage.criteriaVersion,scopeVersion:stage.scopeVersion}))return result('hold','runtime.planner-call','Current approved Planner stage and provider evidence required',['planner-stage-ledger','planner-call-evidence']);
|
|
91
|
-
if(
|
|
91
|
+
if(state.planningDepth==='Bounded'&&stage.document.kind==='spec')return result('hold','runtime.planner-call','Bounded depth has no spec stage',['approved-spec']);
|
|
92
|
+
if(stage.document.kind==='plan'&&state.planningDepth!=='Bounded'){
|
|
93
|
+
const reviewedSpecStage=state.plannerLedger.stages.some(s=>s.workflowId===state.workflowId&&s.document.kind==='spec'&&s.ready===true&&s.review.full===true&&s.review.complete===true&&s.scopeVersion===stage.scopeVersion);
|
|
94
|
+
const approvedSpec=reviewedSpecStage||state.documents.some(doc=>doc.kind==='spec'&&state.approvals.some(a=>a.id===doc.approvalRef&&a.contentHash===doc.contentHash&&evidence.provenance.some(p=>p.id===a.id&&p.messageRef===a.messageRef&&p.contentHash===doc.contentHash&&p.verification.sourceRef===a.messageRef)));
|
|
95
|
+
if(!approvedSpec)return result('hold','runtime.planner-call','Reviewed spec prerequisite required',['approved-spec']);
|
|
96
|
+
}
|
|
92
97
|
const planner=evaluatePlannerCall({stage,request:{...d.plannerCall,requestId:request.requestId},evidence:{artifacts:proof.data.artifacts,semanticProvenance:'operator-attested'}});
|
|
93
98
|
if(planner.decision!=='allow')return planner;
|
|
94
99
|
next.plannerLedger.stages[next.plannerLedger.stages.findIndex(s=>s.id===stage.id)]=planner.proposedTransition;
|
|
@@ -108,7 +113,7 @@ export function evaluate(policy, state, request, evidence){
|
|
|
108
113
|
const relative=p=>typeof p==='string'&&p.length>0&&!/[\\\x00\r\n:]/.test(p)&&!p.startsWith('/')&&!p.split('/').some(x=>!x||x==='.'||x==='..');
|
|
109
114
|
if(!observed||!same(observed,d)||d.parent!==state.target.head||!d.indexTree||!Array.isArray(d.paths)||!d.paths.length||!d.paths.every(relative)||new Set(d.paths).size!==d.paths.length||!same([...d.paths.map(p=>path.join(state.target.realpath,...p.split('/')))].sort(),[...request.paths].sort()))return result('hold','git.orchestrator-accept-commit','actual Git objects and relative path verification required',['git-evidence']);
|
|
110
115
|
if(d.kind==='documents'){
|
|
111
|
-
if(state.mode!=='plan'
|
|
116
|
+
if(state.mode!=='plan'||!hasExactPlanningKinds(state.documents,planningDocumentKinds(state.planningDepth))||!same([...d.paths].sort(),state.documents.map(x=>x.gitPath).sort())||state.documents.some(doc=>doc.path!==path.join(state.target.realpath,...doc.gitPath.split('/'))||!state.approvals.some(a=>a.id===doc.approvalRef&&a.contentHash===doc.contentHash&&evidence.provenance.some(p=>p.id===a.id&&p.source===a.source&&p.messageRef===a.messageRef&&p.contentHash===doc.contentHash&&p.verification.sourceRef===a.messageRef))))return result('hold','runtime.docs-commit','exact approved documents required',['approved-documents']);
|
|
112
117
|
}else{
|
|
113
118
|
const accepted=state.acceptances.find(a=>a.taskId===task.id&&a.fingerprint===d.fingerprint&&state.identities.some(i=>i.actorRef===a.actorRef&&i.role==='orchestrator'));
|
|
114
119
|
if(d.kind!=='task'||!accepted||task.status!=='accepted'||request.paths.some(p=>!task.paths.some(base=>within(base,p))))return result('hold','git.orchestrator-accept-commit','accepted task verification required',['git-evidence']);
|
|
@@ -222,8 +227,18 @@ export function evaluateCooperativePlanner({state,request,evidence}={}){
|
|
|
222
227
|
if(data.targetIntentId){const intent=state.targetIntents?.find(i=>i.id===data.targetIntentId);if(!intent||intent.firstStageId!==data.id||intent.sourceTargetVersion!==state.targetVersion||intent.documents.some(d=>d.kind==='spec')&&data.document.kind!=='spec'||!intent.documents.some(d=>d.kind===data.document.kind&&path.join(state.target.realpath,d.path)===data.document.path))return result('hold','Current target intent and matching first document required');}
|
|
223
228
|
const targetIntent=state.targetIntents?.find(i=>i.id===data.targetIntentId);
|
|
224
229
|
const approvedOmission=targetIntent?.depth==='Bounded'&&targetIntent.firstStageId===data.id&&targetIntent.documents.length===1&&targetIntent.documents[0].kind==='plan';
|
|
225
|
-
|
|
226
|
-
|
|
230
|
+
if(data.document.kind==='plan'&&!approvedOmission){
|
|
231
|
+
const refs=approval.data.prerequisiteRefs;
|
|
232
|
+
const current=r=>r.source==='operator-attested'&&r.scopeVersion===state.scopeVersion&&r.targetVersion===state.targetVersion;
|
|
233
|
+
if(preparedIntent){
|
|
234
|
+
const spec=preparedIntent.documents.find(d=>d.kind==='spec');
|
|
235
|
+
const reviewedSpec=state.targetDocuments?.findLast(d=>d.intentId===preparedIntent.id&&d.path===spec?.path&&d.scopeVersion===state.scopeVersion&&d.targetVersion===state.targetVersion);
|
|
236
|
+
const review=reviewedSpec&&state.records.find(r=>r.kind==='planner-review'&&r.messageRef===reviewedSpec.reviewRef&¤t(r)&&r.data?.full===true&&r.data?.complete===true&&r.data?.hash===reviewedSpec.hash);
|
|
237
|
+
const approvedSpec=reviewedSpec?.approvalRef&&state.records.find(r=>r.kind==='approval'&&r.messageRef===reviewedSpec.approvalRef&&r.data.kind==='spec'&¤t(r)&&[reviewedSpec.path,path.join(state.target.realpath,reviewedSpec.path)].includes(r.data.path)&&r.data.contentHash===reviewedSpec.hash);
|
|
238
|
+
if(!review||approval.actor?.role!=='orchestrator'||!Array.isArray(refs)||!(refs.includes(reviewedSpec.reviewRef)||approvedSpec&&refs.includes(approvedSpec.messageRef)))return result('hold','Reviewed spec prerequisite is required for plan drafting');
|
|
239
|
+
if(evidence.reviewedSpec?.hash!==reviewedSpec.hash)return result('hold','Reviewed spec bytes changed');
|
|
240
|
+
}else if(!Array.isArray(refs)||!refs.some(ref=>state.records.some(r=>r.kind==='approval'&&r.messageRef===ref&&r.data.kind==='spec'&¤t(r))))return result('hold','Reviewed spec prerequisite is required for plan drafting');
|
|
241
|
+
}
|
|
227
242
|
const previous=[...ledger.stages,...(evidence.plannerHistory??[]).map(h=>h.stage)].filter(s=>s.document.path===data.document.path&&s.document.kind===data.document.kind&&s.document.phase===data.document.phase);
|
|
228
243
|
if(evidence.plannerHistoryError)return result('hold','Planner history could not be verified: '+evidence.plannerHistoryError);
|
|
229
244
|
if(previous.length){
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {validateGitPreflight,validateGitCommitResult} from './git-evidence.mjs';
|
|
2
2
|
export {validateGitPreflight,validateGitCommitResult} from './git-evidence.mjs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import {hasExactPlanningKinds,planningDocumentKinds} from './schema.mjs';
|
|
4
5
|
|
|
5
6
|
const reconciliations=new WeakMap();
|
|
6
7
|
export function verifiedReconciliation(decision,state,next,expectedCommit){const proof=reconciliations.get(decision);return !!proof&&proof.before===JSON.stringify(state)&&proof.after===JSON.stringify(next)&&(expectedCommit===undefined||proof.expected===JSON.stringify(expectedCommit));}
|
|
@@ -33,7 +34,7 @@ export async function runGate({phase,state,request,gitEvidence,expectedCommit,re
|
|
|
33
34
|
return path.relative(state.target.realpath,file).split(path.sep).join('/');
|
|
34
35
|
}),d.paths))return hold('Request paths differ from commit paths');
|
|
35
36
|
if(d.kind==='documents'){
|
|
36
|
-
if(state.mode!=='plan'
|
|
37
|
+
if(state.mode!=='plan'||!hasExactPlanningKinds(state.documents,planningDocumentKinds(state.planningDepth))||!samePaths(d.paths,state.documents.map(x=>x.gitPath)))return hold('Complete exact approved planning-document set required','runtime.docs-commit');
|
|
37
38
|
for(const document of state.documents){
|
|
38
39
|
const approvals=state.approvals?.filter(a=>a.id===document.approvalRef);
|
|
39
40
|
if(!hash(document.contentHash)||document.path!==path.join(state.target.realpath,...document.gitPath.split('/'))||approvals?.length!==1||!['user-message','human-confirmation'].includes(approvals[0].source)||!approvals[0].messageRef||approvals[0].contentHash!==document.contentHash)return hold('Approved document hash unavailable','runtime.docs-commit');
|
|
@@ -428,7 +428,7 @@
|
|
|
428
428
|
"preceding-approval"
|
|
429
429
|
],
|
|
430
430
|
"authority": "orchestrator",
|
|
431
|
-
"text": "Follow planning.md's Planner drafting preparation and review procedure, including preflight, ledger, evidence classification, target preparation, preceding approvals, provenance and reference gates. Before Planner dispatch, evaluate F1–F8 direct-path eligibility and Bounded plan-omission eligibility independently. Enter each path only when all of that path's existing conditions are proven; if neither path qualifies, use normal full evaluation. Send one complete stage-specific initial brief. Reuse the same Planner instance only within the design/brainstorming stage while its role, context and source remain valid
|
|
431
|
+
"text": "Follow planning.md's Planner drafting preparation and review procedure, including preflight, ledger, evidence classification, target preparation, preceding approvals, provenance and reference gates. Before Planner dispatch, evaluate F1–F8 direct-path eligibility and Bounded plan-omission eligibility independently. Enter each path only when all of that path's existing conditions are proven; if neither path qualifies, use normal full evaluation. Send one complete stage-specific initial brief. Reuse the same Planner instance only within the design/brainstorming stage while its role, context and source remain valid, except that on the Architectural path that Planner continues as the spec Planner after start confirmation through a spec-stage delta brief; use a fresh Planner instance for each plan stage, and for an Architectural spec stage when that Planner is unavailable or its role, context or source is no longer valid, whose initial brief contains every required field, saved document paths and approved versions (for the Architectural plan stage, the reviewed spec path, version and SHA-256). Follow-up briefs send changed fields and cite an accessible prior brief for unchanged fields. Reuse evidence only for the same source set, absolute locator, resolved path, content fingerprint, purpose and approval scope in an accessible matching context. Reconfirm affected inputs when source, target or scope changed. Planner returns a complete proportional first draft and self-review. Orchestrator reviews and directly revises the same spec or plan when needed. A missing or failed first draft does not transfer initial authorship to Orchestrator. New product decisions outside approved scope require user input before Orchestrator revises the document. For design and brainstorming, follow planning.md's design conversation: each Planner response is exactly one of one question, 2–3 approaches with a recommendation and a selection question, one design section with a confirmation question, or the final design (Architectural: the start summary). Ask one question at a time only when the answer changes the outcome and is not already answered; otherwise state the judgment and its reason. Ask an open question about the user's reason before offering options. For a clear request, Planner MAY return a short design for approval at once; when the user says to proceed, stop asking and list the remaining author judgments in the final design or start summary. Relay user answers verbatim and mark added interpretation separately. Every call needs a new user answer or new evidence; without progress, report the blocked criterion, observed facts and needed decision, and hold. Conversation responses use no correction opportunity. Orchestrator reviews the final design once with the fixed checklist, including decision-inventory completeness and no ambiguous scope wording, and sends one consolidated correction using changed fields only. On the Architectural path the start summary receives no consolidated correction; Orchestrator checks its decision inventory and scope notation before presenting it, and the spec draft takes Orchestrator's review and direct revision. Further calls require user-approved material scope/evidence changes or concrete unmet checklist items after correction, plus meaningful new input or criterion-state progress. State changed input, target criterion, expected artifact and expected progress. Repeated unmet criteria without new input, evidence or progress hold the stage; report the criterion, observed evidence and exact unblock input/decision. DO NOT split omissions, repeat resolved items or count rewording/agent replacement as progress. DO NOT invoke Planner only for reformatting, re-expression, save errors or patch-application errors; Orchestrator handles these. Evaluate separate substantive work under the normal Planner gate. For Bounded work, obtain design approval before plan drafting. For Architectural work, obtain one start confirmation (scope and explicit target; no design document or design approval) before spec drafting, let the design Planner continue as the spec Planner (a fresh spec Planner when it is unavailable or invalid), then draft the plan with a fresh Planner, assigning the plan Planner only after the spec is saved and reviewed and its path, version and SHA-256 are fixed; NEVER draft them concurrently; then obtain one combined spec+plan approval. Bounded work has no spec stage; required plans keep their own approval. Add no fixed call cap or profile call-count conditions, and NEVER accept an incomplete draft. Keep user progress brief and based on Planner status without relaying draft content. At approval, present the integrated, saved and reviewed Markdown without repeating its body in chat.",
|
|
432
432
|
"controls": {
|
|
433
433
|
"codex": "prompt",
|
|
434
434
|
"claude": "prompt",
|
|
@@ -43,6 +43,7 @@ export function validateWorkflowState(s,{allowLegacyOperations=true,preserveStor
|
|
|
43
43
|
if(['policyHash','runtimeHash','adapterHash'].some(k=>!hash(s.versions[k])))fail('hash algorithm');
|
|
44
44
|
if(!object(s.target)||!absolute(s.target.realpath)||['repository','worktree','baseHead','head'].some(k=>!text(s.target[k]))||!(s.target.branch===null||text(s.target.branch)))fail('target');
|
|
45
45
|
if(!['plan','small-task','no-plan'].includes(s.mode))fail('mode');
|
|
46
|
+
if(s.planningDepth!==undefined&&!['Architectural','Bounded'].includes(s.planningDepth))fail('planning depth');
|
|
46
47
|
for(const k of ['documents','approvals','tasks','assignments','identities','leases','checks','findings','acceptances','commits','audit','capabilities','requests'])if(!Array.isArray(s[k]))fail(k);
|
|
47
48
|
const stored=s,normalized=normalizeStoredOperations(s);
|
|
48
49
|
if(!allowLegacyOperations&&normalized!==s&&(!legacyOperationsFrom||hasNewStoredOperationAliases(s,legacyOperationsFrom)))fail('legacy operation in new state');
|
|
@@ -66,6 +67,21 @@ export function validateWorkflowState(s,{allowLegacyOperations=true,preserveStor
|
|
|
66
67
|
if(s.plannerLedger!==undefined){validatePlannerLedger(s.plannerLedger);if(s.plannerLedger.stages.some(stage=>stage.workflowId!==s.workflowId))fail('Planner workflow binding');}
|
|
67
68
|
return preserveStoredOperations?stored:s;
|
|
68
69
|
}
|
|
70
|
+
export function planningDocumentKinds(depth){
|
|
71
|
+
return depth==='Bounded'?['plan']:['plan','spec'];
|
|
72
|
+
}
|
|
73
|
+
export function hasExactPlanningKinds(documents,kinds){
|
|
74
|
+
if(!Array.isArray(documents)||documents.length!==kinds.length)return false;
|
|
75
|
+
const actual=documents.map(d=>d?.kind).sort();
|
|
76
|
+
return kinds.every((kind,index)=>kind===actual[index]);
|
|
77
|
+
}
|
|
78
|
+
export function preparedTargetIntent(state){
|
|
79
|
+
return state.targetIntents?.find(i=>state.targetTransitions?.some(t=>t.intentId===i.id&&t.targetVersion===state.targetVersion));
|
|
80
|
+
}
|
|
81
|
+
export function expectedCooperativePlanningKinds(state){
|
|
82
|
+
const intent=preparedTargetIntent(state);
|
|
83
|
+
return intent?[...new Set(intent.documents.map(d=>d.kind))].sort():planningDocumentKinds();
|
|
84
|
+
}
|
|
69
85
|
export function validateRequest(r){
|
|
70
86
|
if(!object(r)||['requestId','actorRef','taskId','toolName'].some(k=>!text(r[k]))||!isPlatformId(r.platform)||!OPERATIONS.includes(r.operation)||!absolute(r.cwd)||!object(r.arguments)||!object(r.descriptor)||!strings(r.paths)||r.paths.some(p=>!absolute(p)))fail('request');
|
|
71
87
|
return r;
|
|
@@ -38,7 +38,7 @@ export function validateTargetPreparationRecord(kind,data){
|
|
|
38
38
|
if(kind==='intent'&&(!Number.isSafeInteger(data.sourceTargetVersion)||data.sourceTargetVersion<1||!['realpath','gitCommonDir','gitDir'].every(k=>typeof data.sourceTarget[k]==='string'&&path.isAbsolute(data.sourceTarget[k])&&path.normalize(data.sourceTarget[k])===data.sourceTarget[k])||!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(data.sourceTarget.head)||!(data.sourceTarget.branch===null||text(data.sourceTarget.branch))||!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(data.base)||new Set(data.documents.map(d=>d.path)).size!==data.documents.length))throw Error('Invalid target preparation intent identity');
|
|
39
39
|
if(kind==='checkpoint'&&(!text(data.intentId)||!text(data.stageId)||!text(data.resultRef)||!text(data.selfReviewRef)))throw Error('Invalid target preparation checkpoint');
|
|
40
40
|
if(kind==='transition'&&(!text(data.intentId)||!text(data.checkpointRef)||!Number.isSafeInteger(data.expectedRevision)||data.expectedRevision<0))throw Error('Invalid target preparation transition');
|
|
41
|
-
if(kind==='destination'&&(!text(data.intentId)||!text(data.transitionRef)||!text(data.stageId)||!text(data.resultRef)||!text(data.selfReviewRef)||!relative(data.path)||!/^sha256:[a-f0-9]{64}$/.test(data.hash)||![0o100644,0o100755].includes(data.mode)||!text(data.reviewRef)
|
|
41
|
+
if(kind==='destination'&&(!text(data.intentId)||!text(data.transitionRef)||!text(data.stageId)||!text(data.resultRef)||!text(data.selfReviewRef)||!relative(data.path)||!/^sha256:[a-f0-9]{64}$/.test(data.hash)||![0o100644,0o100755].includes(data.mode)||!text(data.reviewRef)||(data.approvalRef!==undefined&&!text(data.approvalRef))||!Number.isSafeInteger(data.targetVersion)||data.targetVersion<1))throw Error('Invalid target preparation destination');
|
|
42
42
|
return data;
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -49,6 +49,7 @@ export function evaluateTargetPreparation({state,request,evidence}={}){
|
|
|
49
49
|
if(state.targetIntents?.some(intent=>!state.targetTransitions?.some(transition=>transition.intentId===intent.id)))return hold('Existing target preparation intent is still active');
|
|
50
50
|
const approval=state.records?.find(r=>r.kind==='approval'&&r.messageRef===request.approvalRef&&r.source==='operator-attested'&&r.actor?.role==='orchestrator'&&r.targetVersion===state.targetVersion&&r.scopeVersion===state.scopeVersion);
|
|
51
51
|
const approved=approval?.data?.targetPreparation;
|
|
52
|
+
if(request.depth==='Bounded'&&request.documents.some(d=>d.kind==='spec'))return hold('Bounded depth has no spec stage');
|
|
52
53
|
if(!['Bounded','Architectural'].includes(request.depth)||(request.depth==='Architectural'&&(!request.documents.some(d=>d.kind==='spec')||!request.documents.some(d=>d.kind==='plan'))))return hold('Approved depth requires its complete document set');
|
|
53
54
|
if(!text(request.approvalRef)||!text(request.depth)||['depth','selectionRef','kind','candidate','base','workflowId','firstStageId','sourceTargetVersion'].some(k=>approved?.[k]!==request[k])||!same(approved?.sourceTarget,request.sourceTarget)||!same(approved?.documents,request.documents)||request.workflowId!==state.workflowId||request.sourceTargetVersion!==state.targetVersion||!same(request.sourceTarget,state.target)||!same(evidence?.source?.target,state.target)||!text(evidence?.source?.fingerprint)||!state.selections?.some(s=>s.messageRef===request.selectionRef&&s.targetVersion===state.targetVersion)||state.targetIntents?.some(i=>i.id===request.id)||request.base!==state.target.head)return hold('Current approval, document set, source, explicit choice and preservation snapshot required');
|
|
54
55
|
return {decision:'allow',ruleIds:['cooperative.target-preparation'],proposedTransition:{intent:{...structuredClone(request),scopeVersion:state.scopeVersion,sourceFingerprint:evidence.source.fingerprint,...(evidence.source.snapshot?{sourceSnapshot:structuredClone(evidence.source.snapshot)}:{}),source:'operator-attested'}}};
|
|
@@ -70,8 +71,12 @@ export function evaluateTargetPreparation({state,request,evidence}={}){
|
|
|
70
71
|
if(request.type==='destination'){
|
|
71
72
|
const intent=state.targetIntents?.find(i=>i.id===request.intentId),document=intent?.documents?.find(d=>d.path===request.path),transition=state.targetTransitions?.find(t=>t.intentId===request.intentId&&t.messageRef===request.transitionRef&&t.targetVersion===state.targetVersion),checkpoint=state.targetCheckpoints?.find(c=>c.intentId===request.intentId&&c.messageRef===transition?.checkpointRef),stage=state.plannerLedger?.stages?.find(s=>s.id===request.stageId),chat=stage?.result?.chatDraft,observed=evidence?.destination?.document;
|
|
72
73
|
const review=state.records?.find(r=>r.kind==='planner-review'&&r.messageRef===request.reviewRef&&r.scopeVersion===state.scopeVersion&&r.targetVersion===state.targetVersion&&r.source==='operator-attested'),approval=state.records?.find(r=>r.kind==='approval'&&r.messageRef===request.approvalRef&&r.scopeVersion===state.scopeVersion&&r.targetVersion===state.targetVersion&&r.source==='operator-attested');
|
|
74
|
+
if(intent&&document&&request.approvalRef===undefined&&!(intent.depth==='Architectural'&&document.kind==='spec'))return hold('Document approval required for this destination');
|
|
73
75
|
if(!intent||!document||intent.firstStageId!==request.stageId||!transition||!same(transition.target,state.target)||request.targetVersion!==state.targetVersion||!checkpoint||checkpoint.stageId!==request.stageId||checkpoint.resultRef!==request.resultRef||checkpoint.selfReviewRef!==request.selfReviewRef||stage?.targetIntentId!==intent.id||stage.result?.ref!==request.resultRef||stage.result.status!=='succeeded'||chat?.intentId!==intent.id||chat.complete!==true||chat.selfReviewRef!==request.selfReviewRef||!same(evidence?.destination?.target,state.target)||observed?.verification?.status!=='verified'||observed.verification.source!=='local-bytes'||observed.path!==request.path||observed.hash!==request.hash||observed.mode!==request.mode)return hold('Current transition, source attestation and observed destination bytes required');
|
|
74
|
-
|
|
76
|
+
const approvedPath=[request.path,path.join(state.target.realpath,request.path)];
|
|
77
|
+
const matchesApproval=entry=>entry?.kind===document.kind&&entry.contentHash===request.hash&&approvedPath.includes(entry.path);
|
|
78
|
+
const approved=request.approvalRef===undefined||(Array.isArray(approval?.data?.documents)?stage?.document?.kind===document.kind&&approval.data.documents.filter(matchesApproval).length===1:matchesApproval(approval?.data));
|
|
79
|
+
if(stage.scopeVersion!==state.scopeVersion||review?.data?.resultRef!==request.resultRef||review.data.full!==true||review.data.complete!==true||review.data.hash!==request.hash||!Array.isArray(stage.criteria)||!Array.isArray(review.data.criteria)||review.data.criteria.length!==stage.criteria.length||new Set(review.data.criteria.map(c=>c.id)).size!==stage.criteria.length||review.data.criteria.some(c=>!stage.criteria.some(s=>s.id===c.id)||c.status!=='resolved'||!text(c.judgmentRef))||!approved)return hold('Current full review and document approval required');
|
|
75
80
|
return {decision:'allow',ruleIds:['cooperative.target-preparation'],proposedTransition:{destination:{...structuredClone(request),scopeVersion:state.scopeVersion,sourceLink:'operator-attested',verification:{status:'verified',source:'local-bytes'}}}};
|
|
76
81
|
}
|
|
77
82
|
if(request?.type!=='checkpoint')return hold('Unsupported target preparation request');
|
|
@@ -67,7 +67,7 @@ function record({state,request,evidence}){
|
|
|
67
67
|
export function evaluateCooperativeVerification({state,request,evidence}={}){
|
|
68
68
|
const denial=legacyCooperativeRoleDenial(request);
|
|
69
69
|
if(denial)return {...base(state),...denial};
|
|
70
|
-
if(state?.mode!=='plan')return hold(state,'unsupported','Only the
|
|
70
|
+
if(state?.mode!=='plan')return hold(state,'unsupported','Only the plan path is supported');
|
|
71
71
|
if(!request||request.expectedRevision!==state.revision)return hold(state,'revision','Stale verification request');
|
|
72
72
|
if(request.actor?.role!=='orchestrator')return hold(state,'verification-actor','Orchestrator statement required');
|
|
73
73
|
if(request.operation==='verification-record')return record({state,request,evidence});
|