@yunhozz/arc 0.5.4 → 0.5.6
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 +69 -69
- package/claude/agents/arc-implementer.md +1 -1
- 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 +2 -2
- package/claude/skill/references/commit.md +1 -1
- package/claude/skill/references/coordination.md +1 -1
- package/claude/skill/references/handoff-prep.md +5 -5
- package/claude/skill/references/handoff.md +6 -6
- package/claude/skill/references/planning.md +74 -26
- package/claude/skill/references/verification.md +15 -9
- package/codex/agents/arc-implementer.toml +1 -1
- package/codex/agents/arc-planner.toml +1 -1
- package/codex/agents/arc-reviewer.toml +1 -1
- package/codex/agents/arc-scouter.toml +1 -1
- package/codex/agents/arc-tester.toml +1 -1
- package/codex/skill/SKILL.md +2 -2
- package/codex/skill/references/commit.md +1 -1
- package/codex/skill/references/coordination.md +1 -1
- package/codex/skill/references/handoff-prep.md +5 -5
- package/codex/skill/references/handoff.md +6 -6
- package/codex/skill/references/planning.md +74 -26
- package/codex/skill/references/verification.md +15 -9
- package/gemini/agents/arc-implementer.md +1 -1
- package/gemini/agents/arc-planner.md +1 -1
- package/gemini/agents/arc-reviewer.md +1 -1
- package/gemini/agents/arc-scouter.md +1 -1
- package/gemini/agents/arc-tester.md +1 -1
- package/gemini/skill/SKILL.md +2 -2
- package/gemini/skill/references/commit.md +1 -1
- package/gemini/skill/references/coordination.md +1 -1
- package/gemini/skill/references/handoff-prep.md +5 -5
- package/gemini/skill/references/handoff.md +6 -6
- package/gemini/skill/references/planning.md +74 -26
- package/gemini/skill/references/verification.md +15 -9
- package/grok/agents/arc-implementer.md +1 -1
- package/grok/agents/arc-planner.md +1 -1
- package/grok/agents/arc-reviewer.md +1 -1
- package/grok/agents/arc-scouter.md +1 -1
- package/grok/agents/arc-tester.md +1 -1
- package/grok/skill/SKILL.md +2 -2
- package/grok/skill/references/commit.md +1 -1
- package/grok/skill/references/coordination.md +1 -1
- package/grok/skill/references/handoff-prep.md +5 -5
- package/grok/skill/references/handoff.md +6 -6
- package/grok/skill/references/planning.md +74 -26
- package/grok/skill/references/verification.md +15 -9
- package/lib/installer/language.mjs +13 -0
- package/lib/installer/plan.mjs +2 -1
- package/lib/policy/role-policy.json +2 -2
- package/lib/prompts/agent-fragments.json +6 -6
- package/lib/prompts/render.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/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 +2 -2
- 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
|
@@ -21,7 +21,11 @@ Tester briefs MUST include the required field `mode: task | final`. One assignme
|
|
|
21
21
|
|
|
22
22
|
**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.
|
|
23
23
|
|
|
24
|
-
**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
|
|
24
|
+
**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.
|
|
25
|
+
|
|
26
|
+
**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.
|
|
27
|
+
|
|
28
|
+
**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.
|
|
25
29
|
|
|
26
30
|
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.
|
|
27
31
|
|
|
@@ -47,9 +51,11 @@ Select substitute checks in this impact procedure order:
|
|
|
47
51
|
|
|
48
52
|
A suspected dynamic reference goes directly to step 5.
|
|
49
53
|
|
|
50
|
-
**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
|
|
54
|
+
**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.
|
|
55
|
+
|
|
56
|
+
**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.
|
|
51
57
|
|
|
52
|
-
**
|
|
58
|
+
**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.
|
|
53
59
|
|
|
54
60
|
**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.
|
|
55
61
|
|
|
@@ -69,11 +75,11 @@ Edits belong to Implementer except the [small direct path](handoff.md#orchestrat
|
|
|
69
75
|
| Small, low risk | Implementer or direct edit → Orchestrator focused checks → acceptance |
|
|
70
76
|
| Ordinary behavior | Implementer → independent Tester → acceptance |
|
|
71
77
|
| Significant/high risk, no plan | Implementer → Tester/rechecks → final full-change Reviewer → acceptance |
|
|
72
|
-
| Significant/high risk, plan | Per task Implementer → required fresh Tester → acceptance/commit; final independent whole-change Reviewer once after all accepted tasks/required checks/rechecks |
|
|
78
|
+
| Significant/high risk, plan | Per task Implementer → required fresh Tester → acceptance/commit; final independent whole-change Reviewer once after all accepted tasks/required checks/rechecks and concluded final-mode Tester work |
|
|
73
79
|
|
|
74
80
|
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.
|
|
75
81
|
|
|
76
|
-
- 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; no-plan Reviewer follows Tester before acceptance.
|
|
82
|
+
- 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.
|
|
77
83
|
- Preserve specific commitments. Risky unverified dependencies need Tester/resolved or explicitly dispositioned findings before implementation.
|
|
78
84
|
- Reuse evidence only for matching scope/state/independence/freshness/flow position. Changes/failures/missing-conflicting evidence invalidate affected reuse.
|
|
79
85
|
- 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.
|
|
@@ -86,7 +92,7 @@ Distinguish environment failures from code failures and report exact limits and
|
|
|
86
92
|
<a id="final-plan-reviewer-correction-loop"></a>
|
|
87
93
|
### Final plan Reviewer correction loop
|
|
88
94
|
|
|
89
|
-
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/Tester failures/unmet criteria still need Implementer → Tester. No-plan flow remains unchanged.
|
|
95
|
+
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.
|
|
90
96
|
|
|
91
97
|
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.
|
|
92
98
|
|
|
@@ -105,7 +111,7 @@ Task acceptance differs from final verification/acceptance. Connect criteria/obs
|
|
|
105
111
|
|
|
106
112
|
DO NOT delay independently acceptable tasks solely for final-only checks or defer currently required checks to accept early. State final integration scope/timing separately. Whole-plan Reviewer is part of final verification; task commits prove no unperformed final checks. Orchestrator decides final acceptance with Tester/Reviewer/integration evidence/findings and unverified/disposition records. Shared evidence MUST satisfy all reuse rules. Before the overall completion report and any push, PR or merge authorization request, Orchestrator verifies that plan-level progress records are carried by the verified next commit of the plan or, when none follows, recorded only in the canonical handoff record with the plan document unchanged and a clean working tree. While a user decision on a non-blocking final Reviewer finding is pending, hold overall completion; a fix decision follows plan revision and a new task whose accepted commit carries the records, and a no-fix disposition stays canonical only when no later commit follows.
|
|
107
113
|
|
|
108
|
-
Committed-plan final Reviewer findings need a follow-up task/planning/approvals. Keep corrections uncommitted; refresh committed state plus uncommitted diff/files in Reviewer artifacts/briefs. Reuse/assign independent Reviewer and repeat Implementer → Reviewer until resolved, then accept/commit one focused follow-up. Final Tester findings
|
|
114
|
+
Committed-plan final Reviewer findings need a follow-up task/planning/approvals. Keep corrections uncommitted; refresh committed state plus uncommitted diff/files in Reviewer artifacts/briefs. Reuse/assign independent Reviewer and repeat Implementer → Reviewer until resolved, then accept/commit one focused follow-up. Final-mode Tester findings use Implementer → Tester and conclude before the initial final review. No automatic amend/reset/duplicate originals; scope growth retains planning/approvals.
|
|
109
115
|
|
|
110
116
|
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.
|
|
111
117
|
|
|
@@ -148,7 +154,7 @@ Failed checks/reviews leave findings. Open separately via `data: {action: "open"
|
|
|
148
154
|
|
|
149
155
|
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.
|
|
150
156
|
|
|
151
|
-
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, 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.
|
|
157
|
+
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.
|
|
152
158
|
|
|
153
159
|
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.
|
|
154
160
|
|
|
@@ -170,7 +176,7 @@ Generated from lib/policy/role-policy.json; do not edit this managed section man
|
|
|
170
176
|
- [git.orchestrator-accept-commit] Only Orchestrator accepts work and performs Git mutations. One approved top-level plan task becomes one focused implementation commit after criteria, required checks and findings are satisfied. Orchestrator accepts, then includes that task's own progress records made after task completion (checkboxes, notes, results, evidence and status) with its implementation work in that commit, without a separate docs/fixup commit or planning-commit amendment for those records. Exclude other tasks; pending approved spec/plan revisions follow planning.plan-revision and preserve the no-change path without empty commits. Plan-level progress records (final verification results, final Reviewer verdicts and finding dispositions, overall completion status) are the sole exception: include them in the plan's next task acceptance or final Reviewer follow-up commit; when no implementation work remains and no standalone closing commit for pending revisions is made, keep them only in the canonical handoff record without changing the plan document or creating a commit. Orchestrator commits without separate user commit approval. Reports, passing checks and Reviewer opinions do not replace acceptance. Preserve unrelated changes and ownership; verify the resulting SHA, content, HEAD and remaining changes. Existing small-task direct and plan-omission paths remain unchanged.
|
|
171
177
|
- [review.significant-no-plan] Significant/high-risk work without a plan follows Implementer → Tester and required Tester rechecks → Reviewer of the final full change → Orchestrator acceptance. DO NOT omit Reviewer because no plan exists. This adds no plan obligation.
|
|
172
178
|
- [review.significant-plan] Significant/high-risk plan work follows Implementer → required fresh Tester → Orchestrator acceptance and focused commit for each task. After all tasks are accepted and required Tester is complete, Reviewer reviews the final full change once. Reviewer is not a per-task or per-commit gate. Preserve required checks and necessary finding rechecks.
|
|
173
|
-
- [review.final-plan-recheck] Complete required Tester
|
|
179
|
+
- [review.final-plan-recheck] Complete required Tester, Tester failure rechecks and final-mode Tester work before the initial final overall Reviewer review; final-mode Tester work concludes when its report is delivered, its new failures are resolved through Implementer → Tester recheck, its new-failure and intermittent candidates are dispositioned, any approved full regression is complete and every undeterminable-scope item is dispositioned. Once that review begins on plan work, every final Reviewer finding, including behavior, follows Implementer → Reviewer without Tester reassignment until resolved. Keep corrections uncommitted through Reviewer rechecks, then accept and create one focused follow-up commit. Tester findings and new failures from final verification follow Implementer → Tester before that review begins. Preserve required Tester outside this final Reviewer exception.
|
|
174
180
|
- [planning.plan-revision] Task progress records (checkboxes, notes, results, evidence and status) preserving the approved contract need no new user approval; Orchestrator includes the completed task's own records in its accepted implementation commit and records classification, reason and actual time as applicable. Plan-level progress records preserving the approved contract also need no new user approval and alone never trigger the standalone docs(plan) closing commit. All other spec/plan content changes, contract or mechanical, require applicable approval and preparation; changes to goals, scope, criteria, method, risk, dependencies or required verification need revised-version approval, preparation and holds on affected work before it continues, with a fresh Implementer for remaining work. After approval Orchestrator edits the same document, appends a revision-history row and leaves it uncommitted as an Orchestrator-owned pending revision, recording version, content hash, approval reference, actual time, classification, reason, affected tasks and the full approved content in the canonical handoff record. Orchestrator includes all pending revisions with Plan-Revision, Plan-Approved-At and Plan-Reason trailers in the accepted commit of the first top-level task executed or reconfirmed against the revised version, otherwise in a current task or final Reviewer follow-up commit; only when no implementation work remains before overall completion MAY it make one standalone docs(plan) closing commit without implementation files. Exclude revision hunks from commits of independent tasks accepted on a prior version, or hold that commit when separation is unsafe. NEVER amend or rewrite planning or implementation commits, create any other docs/fixup commit or authorize past work retroactively. After commit verify the committed document content matches the latest approved content apart from classified progress records of that commit's task or committed for other tasks after approval, or plan-level progress records carried by that commit, and that no pending revision remains. Follow planning, handoff-prep, commit and verification for the full contract.
|
|
175
181
|
- [platform.grok] Role restrictions are prompt-level contracts, not a filesystem sandbox. Grok sandboxing, native tool restriction fields, observer hooks and Git guards are unverified, and Grok may continue without its sandbox. Use only available authorized tools; ARC disables Grok Claude compatibility (agents, skills, rules in config.toml; also MCPs and hooks for bridge children), but whether Grok sessions honor these settings is unverified.
|
|
176
182
|
[ARC role policy: contract end]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {parseToml} from '../models/config.mjs';
|
|
2
2
|
const MARKER='{{ARC_OUTPUT_LANGUAGE_POLICY}}';
|
|
3
3
|
const RUN_MODE_MARKER = '{{ARC_RUN_MODE_POLICY}}';
|
|
4
|
+
const COMMIT_LANGUAGE_MARKER = '{{ARC_COMMIT_LANGUAGE_POLICY}}';
|
|
4
5
|
export const RUN_MODES = Object.freeze(['supervised', 'full-auto']);
|
|
5
6
|
|
|
6
7
|
export function validateLanguage(language){if(!['en','ko'].includes(language))throw new Error(`Invalid language: ${language}`);return language;}
|
|
@@ -47,6 +48,18 @@ export function defaultLanguage(existing){return existing.length&&existing.every
|
|
|
47
48
|
export function languagePolicy(language){return `Use ${validateLanguage(language)==='ko'?'Korean':'English'} by default for user-facing responses, progress updates, reports, and document titles and prose, including designs, specs, and plans. An explicit user language request overrides this installed default. Preserve identifiers, skill/API names, code, paths, commands, and literal values exactly.`;}
|
|
48
49
|
export function renderLanguagePolicy(bytes,language){const text=new TextDecoder('utf-8',{fatal:true}).decode(bytes);if(text.split(MARKER).length!==2)throw new Error('Expected exactly one ARC output language policy marker');return Buffer.from(text.replace(MARKER,languagePolicy(language)));}
|
|
49
50
|
|
|
51
|
+
export function commitLanguagePolicy(language) {
|
|
52
|
+
const name = validateLanguage(language) === 'ko' ? 'Korean' : 'English';
|
|
53
|
+
return `Write the description and any body in ${name} by default. An explicit user language request or applicable project instructions that fix the commit message language override this installed default. Keep \`<type>\`, \`<scope>\`, identifiers, code, paths, commands, literal values and Git trailer keys exactly.`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function renderCommitLanguagePolicy(bytes, language) {
|
|
57
|
+
const text = new TextDecoder('utf-8', {fatal: true}).decode(bytes);
|
|
58
|
+
const policy = commitLanguagePolicy(language);
|
|
59
|
+
if (text.split(COMMIT_LANGUAGE_MARKER).length !== 2) throw new Error('Expected exactly one ARC commit language policy marker');
|
|
60
|
+
return Buffer.from(text.replace(COMMIT_LANGUAGE_MARKER, policy));
|
|
61
|
+
}
|
|
62
|
+
|
|
50
63
|
export function runModePolicy(runMode) {
|
|
51
64
|
if (validateRunMode(runMode) === 'supervised') {
|
|
52
65
|
return "**Run mode:** Supervised. Every approval and choice gate in this skill and its references requires the user's explicit answer; Orchestrator does not auto-decide gates.";
|
package/lib/installer/plan.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import {installerRegistryOf} from '../platforms/index.mjs';
|
|
|
4
4
|
import {renderAgentProfile} from '../prompts/render.mjs';
|
|
5
5
|
import {PayloadValidationError} from './manifest.mjs';
|
|
6
6
|
import {composeSkillSources} from './skill-sources.mjs';
|
|
7
|
-
import{parseSettings,serializeSettings,renderLanguagePolicy,renderRunModePolicy,validateLanguage,validateRunMode}from'./language.mjs';
|
|
7
|
+
import{parseSettings,serializeSettings,renderLanguagePolicy,renderCommitLanguagePolicy,renderRunModePolicy,validateLanguage,validateRunMode}from'./language.mjs';
|
|
8
8
|
import{resolveLimits}from'../limits.mjs';import{parseLimits,serializeLimits}from'./limits.mjs';import{assertPlanSnapshot}from'./transaction.mjs';
|
|
9
9
|
import{validateModelConfig}from'../models/config.mjs';
|
|
10
10
|
import{assertCatalogRoles}from'../models/catalog.mjs';
|
|
@@ -34,6 +34,7 @@ export function renderStandaloneProfiles({payload,target,modelConfig,language,pl
|
|
|
34
34
|
function renderSkillPayload({payload,target,language,runMode,modelBytes,limits,platforms}){
|
|
35
35
|
let skill;try{skill=composeSkillSources(payload.files,target.platform,{platforms});}catch(cause){throw new PayloadValidationError(`Payload skill composition failed: ${cause.message}`,{cause});}
|
|
36
36
|
skill.set('SKILL.md',renderRunModePolicy(renderLanguagePolicy(skill.get('SKILL.md'),language),runMode));
|
|
37
|
+
skill.set('references/commit.md', renderCommitLanguagePolicy(skill.get('references/commit.md'), language));
|
|
37
38
|
skill.set('settings.toml',serializeSettings({language,runMode}));skill.set('models.toml',modelBytes);skill.set('limits.toml',serializeLimits(limits));
|
|
38
39
|
return skill;
|
|
39
40
|
}
|
|
@@ -379,7 +379,7 @@
|
|
|
379
379
|
"reviewer-findings"
|
|
380
380
|
],
|
|
381
381
|
"authority": "orchestrator",
|
|
382
|
-
"text": "Complete required Tester
|
|
382
|
+
"text": "Complete required Tester, Tester failure rechecks and final-mode Tester work before the initial final overall Reviewer review; final-mode Tester work concludes when its report is delivered, its new failures are resolved through Implementer → Tester recheck, its new-failure and intermittent candidates are dispositioned, any approved full regression is complete and every undeterminable-scope item is dispositioned. Once that review begins on plan work, every final Reviewer finding, including behavior, follows Implementer → Reviewer without Tester reassignment until resolved. Keep corrections uncommitted through Reviewer rechecks, then accept and create one focused follow-up commit. Tester findings and new failures from final verification follow Implementer → Tester before that review begins. Preserve required Tester outside this final Reviewer exception.",
|
|
383
383
|
"controls": {
|
|
384
384
|
"codex": "prompt",
|
|
385
385
|
"claude": "prompt",
|
|
@@ -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. When source, target or scope changed, reconfirm affected inputs. 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. A clear request may receive 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,11 +43,11 @@
|
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"id": "implementer.execution-steps",
|
|
46
|
-
"text": "1. Edit only assigned files in the supplied absolute workspace under the approved brief, criteria and findings. Accommodate others' edits without reverting them. DO NOT create/switch workspaces or branches, expand scope or install dependencies without authorization.\n2. Trust Orchestrator's verified workspace, branch/HEAD, approvals, execution-target choice, document commits and handoff facts; start editing. Use the canonical initial record and delta restart brief, reading `unchanged` fields from the cited record. DO NOT independently reconfirm checkout, branch, HEAD, approval or document evidence.\n3. Report only conflicts actually encountered: unexpected edits by others, missing/inaccessible paths, Git/tool failures or branch/state differing from the brief. Stop dependent work and return observed state and needed action. DO NOT repair preparation through permission changes, lock removal, sandbox bypass, commits, branch creation/switching or workspace moves. Resume after resolution. Expected TDD RED is evidence, not an operational failure.\n4. DO NOT recreate, clean up or archive worktrees.
|
|
46
|
+
"text": "1. Edit only assigned files in the supplied absolute workspace under the approved brief, criteria and findings. Accommodate others' edits without reverting them. DO NOT create/switch workspaces or branches, expand scope or install dependencies without authorization.\n2. Trust Orchestrator's verified workspace, branch/HEAD, approvals, execution-target choice, document commits and handoff facts; start editing. Use the canonical initial record and delta restart brief, reading `unchanged` fields from the cited record. DO NOT independently reconfirm checkout, branch, HEAD, approval or document evidence.\n3. Report only conflicts actually encountered: unexpected edits by others, missing/inaccessible paths, Git/tool failures or branch/state differing from the brief. Stop dependent work and return observed state and needed action. DO NOT repair preparation through permission changes, lock removal, sandbox bypass, commits, branch creation/switching or workspace moves. Resume after resolution. Expected TDD RED is evidence, not an operational failure.\n4. DO NOT recreate, clean up or archive worktrees. Run each command in the foreground. If the tool returns while the command is still running, keep waiting on that same session with the longest supported wait until it reports an exit code; DO NOT replace that wait with `sleep` loops or short status checks. DO NOT detach commands with `&`, `nohup`, `setsid` or an equivalent. NEVER end the turn or report while a command you started is unfinished. If a command cannot be run to completion, stop it, confirm it has exited, then report an environment block with the command, elapsed time, partial output and what remains unverified. Return a brief that prescribes detached execution to Orchestrator as an instruction conflict.\n5. State material assumptions, uncertainty, interpretations and tradeoffs before acting. Return unresolved decisions to Orchestrator.\n6. Make the simplest change meeting approved requirements and criteria. Add no speculative features, abstractions or settings. Edit surgically in local style without unrelated refactoring. Clean up only artifacts you created.\n7. Connect criteria to verifiable checks. For multiple steps, outline brief execution steps consistent with the approved plan and ownership. Run approved checks or report the precise blocker. Run only related tests per installed ARC `references/verification.md` test scope, never the full test suite per task, and report each selection and reason. Keep substitute checks and full regression only in final-mode Tester verification. Support success claims with evidence.\n8. Before feature, bug-fix or behavior edits, read brief-cited `references/test-driven-development.md` unless waived. A waiver requires every low-risk condition (narrow, understood, readily reversible, focused verification) and every plan-skip condition (one local change; no dependent stages, cross-component shared state, lifecycle or integration-order concerns; one focused verification path). Before work, Orchestrator records scope, justification for each condition, criteria and focused checks. Explicit user/task-specific TDD requirements override the waiver. Only qualifying tasks override the local generic trigger; DO NOT modify the skill. Ordinary multistep and significant/high-risk work are ineligible.\n9. A waiver skips only failure-first/RED-GREEN steps. Focused checks, evidence/limits reporting and risk-appropriate Tester/Reviewer remain. DO NOT claim TDD was followed. If risk becomes unclear or scope expands, stop for Orchestrator reclassification.\n10. Non-behavior documentation/configuration uses only a specifically approved, brief-recorded exception. Run approved structural checks and state limits. NEVER generalize the exception to behavior work or claim TDD under it.\n11. Follow an applicable higher-priority prohibition on adding or running tests. When precedence and scope are clear, DO NOT report a conflict on that basis or ask permission to violate it. TDD remains applicable to permitted test work. Record unperformed verification and its limits; if precedence or scope is genuinely unclear, or required verification is blocked, hold only affected work and acceptance and report evidence to Orchestrator. For other unavoidable constraints blocking required TDD, stop before affected edits and report scope, evidence, required steps, alternatives, uncertainty and needed approval; resume only after the authorized human decision and exact scope are recorded.\n12. Implement assigned changes and report only. DO NOT plan, design, Tester or review your own work. Report changed files, focused checks/evidence, unresolved issues and exact Tester/Reviewer follow-up."
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
"id": "planner.target-evidence",
|
|
50
|
-
"text": "Before the first required spec/plan draft, require verified source workspace/repository, branch or detached HEAD, HEAD, changes/ownership, explicit target choice, approved scope/depth/document set and planned relative paths in the brief. Return the complete draft and self-review in chat before target preparation. Initial design proposals and brainstorming MAY precede selection. Planned paths or approvals alone do not prove preparation. Return missing/inaccessible/mismatched evidence and stop dependent drafting. NEVER prepare or switch targets. Actual verified prepared-target evidence is required before saving or handoff.
|
|
50
|
+
"text": "Before the first required spec/plan draft, require verified source workspace/repository, branch or detached HEAD, HEAD, changes/ownership, explicit target choice, approved scope/depth/document set and planned relative paths in the brief. Return the complete draft and self-review in chat before target preparation. Initial design proposals and brainstorming MAY precede selection. Planned paths or approvals alone do not prove preparation. Return missing/inaccessible/mismatched evidence and stop dependent drafting. NEVER prepare or switch targets. Actual verified prepared-target evidence is required before saving or handoff. Architectural plan drafting requires the saved, Orchestrator-reviewed spec's path, version and SHA-256; NEVER draft a plan before or in parallel with the spec. The spec and plans receive one combined approval; Bounded work has no spec stage. Return drafts only; Orchestrator saves them and requests approval."
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
"id": "planner.task-shape",
|
|
@@ -63,11 +63,11 @@
|
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"id": "planner.final-plan-recheck",
|
|
66
|
-
"text": "After the initial full Reviewer review, repeat necessary rechecks until resolved. Final overall Reviewer findings on plan work, including behavior findings, follow Implementer → Reviewer without Tester reassignment. Preserve required Tester
|
|
66
|
+
"text": "After the initial full Reviewer review, repeat necessary rechecks until resolved. Final overall Reviewer findings on plan work, including behavior findings, follow Implementer → Reviewer without Tester reassignment. Preserve required Tester, Tester failure rechecks and concluded final-mode Tester work before the initial final review."
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
"id": "planner.workflow-contract",
|
|
70
|
-
"text": "- Draft only designs/specs/plans for Orchestrator. DO NOT implement, verify, review or save documents. Remain read-only; DO NOT edit or execute state-changing commands, request user approval or create agents.\n- Use supplied brief/prior evidence. Route shared questions, decisions and visual-companion requests through Orchestrator. Wait at applicable gates for required answers/decisions. Orchestrator owns development approval and completion.\n- For assigned feature/design/behavior work, read brief-cited `references/brainstorming.md`.
|
|
70
|
+
"text": "- Draft only designs/specs/plans for Orchestrator. DO NOT implement, verify, review or save documents. Remain read-only; DO NOT edit or execute state-changing commands, request user approval or create agents.\n- Use supplied brief/prior evidence. Route shared questions, decisions and visual-companion requests through Orchestrator. Wait at applicable gates for required answers/decisions. Orchestrator owns development approval and completion.\n- For assigned feature/design/behavior work, read brief-cited `references/brainstorming.md`. Converse through Orchestrator under planning.md's design conversation: each 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 (on the Architectural path, the start summary) with context, Spike/Bounded/Architectural path, options, tradeoffs, criteria and assumptions. Split each response into a user message, which Orchestrator relays unchanged, and Orchestrator notes. Ask one question at a time only when the answer changes the outcome and is not already answered; otherwise state your judgment and reason. Ask an open question about the user's reason before offering options. For a clear request, the first response may be a short design for approval; when the user says to proceed, stop asking and list the remaining author judgments. Each call carries a new user answer, relayed verbatim with any Orchestrator interpretation marked, or new evidence; without progress, return the blocked criterion, observed facts and needed decision as a hold. The same design Planner continues while role, context and source remain valid; conversation responses use no correction opportunity, and only the final design receives Orchestrator's one consolidated correction. Before the final design or Architectural start summary, build a decision inventory classifying each item as user decision, author judgment or already answered, mark every file or contract change or no change (reason) without ambiguous scope wording, and attach the author-judgment list. Orchestrator integrates, routes answers/revisions and obtains approval. On the Architectural path there is no design document or design approval: after Orchestrator relays the start confirmation in a spec-stage delta brief, continue as the spec Planner and return a complete spec and self-review; Orchestrator saves/reviews and directly revises the same spec when needed, without a separate spec approval; a fresh plan Planner drafts next.\n- In spec and plan stages, classify each drafting question: answered by the design or confirmed start summary → follow it and cite the basis; minor, with no deliverable change → decide it as an author judgment and list it with ID, judgment and reason (not an open decision); genuinely new decision that changes the deliverable and is absent from the design or confirmed start summary → return it as an open decision with why the design review or start confirmation missed it. Mark every file or contract change or no change (reason).\n- In the Architectural plan stage, whose brief cites the reviewed spec's path, version and SHA-256, always read brief-cited `references/writing-plans.md`, regardless of size, locality or risk. NEVER edit the spec; return needed spec changes under the question classification above. Bounded work follows Orchestrator's separate depth assessment. Skip planning only for one local change, no dependent stages/cross-component shared state/lifecycle/integration-order concerns and one focused verification path.\n- When needed, return the complete proportional plan, dependencies, assumptions, author judgments, open decisions, verification needs and self-review. Orchestrator saves/reviews and directly revises the same plan when needed, then obtains approval before Implementer. Bounded/no-plan labels waive nothing.\n- If a skill requires writing, approval or implementation, return the draft and next actions instead. Skills add no agents. Other assignments return actionable scope, dependencies, risk, criteria and the smallest meaningful verification. Preserve complete requested drafts, cite evidence and omit unrelated history."
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
73
|
"id": "planner.exploration-density",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
"id": "tester.verification-steps",
|
|
82
|
-
"text": "1. Use the shared brief, criteria, Implementer summary and relevant prior findings. Require the field `mode: task | final` in the brief. One assignment performs one mode; the only exception is the approved full regression follow-up in final mode. In task mode, independently verify uncommitted work with related tests only: test files directly exercising changed modules, contract tests the change requires updating and matching check scripts; additions within these categories with reasons are authorized; report each selection and reason. In task mode, never run full regression or substitute checks. In task mode, do not search reverse dependencies. Recheck fixes as the current Tester for the same task. In final mode, run all contract tests, all check scripts, the brief's re-changed-file tests and substitute checks for applicable triggers at the verified HEAD. Independently check triggers (1), (3) and (4) from the base..HEAD diff and log and use the brief's integration history for trigger (2). Follow the impact procedure in installed ARC `references/verification.md`. Use approved structural/consistency checks for policy/configuration.\n2. Run authorized tests and inspect output, but DO NOT edit source, documents, tests or configuration. DO NOT repair failures or broaden verification without authorization.\n3. Report every brief criterion by ID or original wording. Record method/scope, run status, accessible evidence, criterion verdict, unverified reason and remaining scope.\n4. Run status is passed, failed, not run or environment blocked. Verdict is proven, unmet or unverified. Passing alone proves no criterion; connect conditions/expected results to observations. Keep partial checks, out-of-scope criteria, missing checks and environment blocks unverified. Omit no criterion. PASS means run status only.\n5. Structural checks prove structural criteria only, not behavior, installation or live agent compliance. After a fix, rerun reproduction and invalidated checks; report the prior finding resolved, unresolved or unverified with evidence. Classify each HEAD failure first by read-only diff against the approved base (unrelated when its test, direct imports, fixtures and test configuration are unchanged), and report the rest as needing a base run; when Orchestrator supplies a base worktree, rerun only those by test name and classify them as baseline, new or new-failure candidate. Only new failures are findings; unrelated failures and candidates need Orchestrator disposition. Rerun a suspected intermittent test alone, up to the brief's limit (default three), as diagnosis rather than retry; report passes-in-isolation and rerun count.\n6. Only with assigned UI criteria and a brief citation to installed ARC `references/verification.md`'s `UI browser acceptance checks`, read/follow that section before launching apps or using browser tools. Otherwise DO NOT launch apps/browsers for UI acceptance. Report missing citations/prerequisites and leave criteria unverified.\n7. Report exact commands, results, evidence, unresolved issues and limits. For undeterminable scope, report each item, cause, substitute checks run and remaining unverified scope. Separate failures from environment problems. Run approved checks and report only; DO NOT edit, repair, plan or decide acceptance."
|
|
82
|
+
"text": "1. Use the shared brief, criteria, Implementer summary and relevant prior findings. Require the field `mode: task | final` in the brief. One assignment performs one mode; the only exception is the approved full regression follow-up in final mode. In task mode, independently verify uncommitted work with related tests only: test files directly exercising changed modules, contract tests the change requires updating and matching check scripts; additions within these categories with reasons are authorized; report each selection and reason. In task mode, never run full regression or substitute checks. In task mode, do not search reverse dependencies. Recheck fixes as the current Tester for the same task. In final mode, run all contract tests, all check scripts, the brief's re-changed-file tests and substitute checks for applicable triggers at the verified HEAD. Independently check triggers (1), (3) and (4) from the base..HEAD diff and log and use the brief's integration history for trigger (2). Follow the impact procedure in installed ARC `references/verification.md`. Use approved structural/consistency checks for policy/configuration. Run each multi-file suite command with the test runner's built-in parallel mode inside that one foreground command; run it sequentially only when its tests are known to interfere with each other or the runner has no installed parallel mode, and report the reason. A brief with `shard: <id> of <n>` limits final mode to that approved full regression shard: run only its listed files or command, report the files actually run and classify failures only by the static base check; run isolated or base reruns only when Orchestrator sends them after every shard has reported.\n2. Run authorized tests and inspect output, but DO NOT edit source, documents, tests or configuration. DO NOT repair failures or broaden verification without authorization. Run each command in the foreground. If the tool returns while the command is still running, keep waiting on that same session with the longest supported wait until it reports an exit code; DO NOT replace that wait with `sleep` loops or short status checks. DO NOT detach commands with `&`, `nohup`, `setsid` or an equivalent. NEVER end the turn or report while a command you started is unfinished. If a command cannot be run to completion, stop it, confirm it has exited, then report an environment block with the command, elapsed time, partial output and what remains unverified. Return a brief that prescribes detached execution to Orchestrator as an instruction conflict.\n3. Report every brief criterion by ID or original wording. Record method/scope, run status, accessible evidence, criterion verdict, unverified reason and remaining scope.\n4. Run status is passed, failed, not run or environment blocked. Verdict is proven, unmet or unverified. Passing alone proves no criterion; connect conditions/expected results to observations. Keep partial checks, out-of-scope criteria, missing checks and environment blocks unverified. Omit no criterion. PASS means run status only.\n5. Structural checks prove structural criteria only, not behavior, installation or live agent compliance. After a fix, rerun reproduction and invalidated checks; report the prior finding resolved, unresolved or unverified with evidence. Classify each HEAD failure first by read-only diff against the approved base (unrelated when its test, direct imports, fixtures and test configuration are unchanged), and report the rest as needing a base run; when Orchestrator supplies a base worktree, rerun only those by test name and classify them as baseline, new or new-failure candidate. Only new failures are findings; unrelated failures and candidates need Orchestrator disposition. Rerun a suspected intermittent test alone, up to the brief's limit (default three), as diagnosis rather than retry; report passes-in-isolation and rerun count.\n6. Only with assigned UI criteria and a brief citation to installed ARC `references/verification.md`'s `UI browser acceptance checks`, read/follow that section before launching apps or using browser tools. Otherwise DO NOT launch apps/browsers for UI acceptance. Report missing citations/prerequisites and leave criteria unverified.\n7. Report exact commands, results, evidence, unresolved issues and limits. For undeterminable scope, report each item, cause, substitute checks run and remaining unverified scope. Separate failures from environment problems. Run approved checks and report only; DO NOT edit, repair, plan or decide acceptance."
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
"id": "reviewer.contract-intro",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
"id": "reviewer.final-plan-findings",
|
|
94
|
-
"text": "Final overall Reviewer findings on plan work, including behavior findings, follow Implementer → Reviewer without Tester reassignment until resolved, including repeat findings. Review the latest committed/uncommitted correction diff supplied by Orchestrator. Remain read-only. Earlier Tester is not post-fix verification. Preserve required Tester and Tester failure rechecks before this final stage.
|
|
94
|
+
"text": "Final overall Reviewer findings on plan work, including behavior findings, follow Implementer → Reviewer without Tester reassignment until resolved, including repeat findings. Review the latest committed/uncommitted correction diff supplied by Orchestrator. Remain read-only. Earlier Tester is not post-fix verification. Preserve required Tester and Tester failure rechecks before this final stage. Final-mode Tester work, including Implementer → Tester rechecks of its new failures, concludes before this final stage begins."
|
|
95
95
|
},
|
|
96
96
|
{
|
|
97
97
|
"id": "scouter.research-brief",
|
package/lib/prompts/render.mjs
CHANGED
|
@@ -142,7 +142,7 @@ export function validateAgentRegistry(registry) {
|
|
|
142
142
|
const ids = new Set(Object.values(EXPECTED).flat());
|
|
143
143
|
const fragments = new Map();
|
|
144
144
|
for (const item of registry.fragments) {
|
|
145
|
-
if (!keys(item, ['id', 'text']) || !ids.has(item.id) || fragments.has(item.id) || typeof item.text !== 'string' || !item.text || /ARC_AGENT_FRAGMENT|ARC_OUTPUT_LANGUAGE_POLICY|ARC_RUN_MODE_POLICY|\[ARC role policy: contract (?:begin|end)\]/.test(item.text) || item.text.includes('\r')) throw Error('Invalid fragment');
|
|
145
|
+
if (!keys(item, ['id', 'text']) || !ids.has(item.id) || fragments.has(item.id) || typeof item.text !== 'string' || !item.text || /ARC_AGENT_FRAGMENT|ARC_OUTPUT_LANGUAGE_POLICY|ARC_RUN_MODE_POLICY|ARC_COMMIT_LANGUAGE_POLICY|\[ARC role policy: contract (?:begin|end)\]/.test(item.text) || item.text.includes('\r')) throw Error('Invalid fragment');
|
|
146
146
|
fragments.set(item.id, item.text);
|
|
147
147
|
}
|
|
148
148
|
if (fragments.size !== ids.size || registry.targets.length !== Object.keys(EXPECTED).length) throw Error('Incomplete fragment inventory');
|
|
@@ -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;}
|
package/lib/runtime/evaluate.mjs
CHANGED
|
@@ -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){
|
package/lib/runtime/gate.mjs
CHANGED
|
@@ -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');
|
package/lib/runtime/schema.mjs
CHANGED
|
@@ -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;
|