@yunhozz/arc 0.2.4 → 0.2.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 +88 -78
- package/claude/agents/arc-implementer.md +8 -23
- package/claude/agents/arc-planner.md +14 -23
- package/claude/agents/arc-qa.md +9 -19
- package/claude/agents/arc-reviewer.md +11 -20
- package/claude/agents/arc-scouter.md +10 -17
- package/claude/skill/SKILL.md +9 -9
- package/claude/skill/models.toml +11 -11
- package/claude/skill/references/arc-visual-companion.md +3 -3
- package/claude/skill/references/brainstorming.md +153 -62
- package/claude/skill/references/commit.md +6 -6
- package/claude/skill/references/coordination.md +20 -8
- package/claude/skill/references/git-recovery.md +2 -2
- package/claude/skill/references/handoff-prep.md +7 -5
- package/claude/skill/references/handoff.md +62 -9
- package/claude/skill/references/limits.md +5 -5
- package/claude/skill/references/planning.md +22 -16
- package/claude/skill/references/scripts/start-server.sh +7 -0
- package/claude/skill/references/superpowers-provenance.json +4 -4
- package/claude/skill/references/verification.md +6 -4
- package/claude/skill/runtime/bootstrap.mjs +2 -2
- package/claude/skill/runtime/cooperative-schema.mjs +32 -1
- package/claude/skill/runtime/cooperative.mjs +68 -13
- package/claude/skill/runtime/evaluate.mjs +85 -6
- package/claude/skill/runtime/git-evidence.mjs +98 -0
- package/claude/skill/runtime/operations.mjs +2 -2
- package/claude/skill/runtime/role-policy.json +6 -6
- package/claude/skill/runtime/store.mjs +10 -0
- package/claude/skill/runtime/target-preparation.mjs +110 -0
- package/claude/skill/runtime/verification.mjs +6 -4
- package/claude/skill/scripts/model_config.py +17 -5
- package/codex/agents/arc-implementer.toml +10 -25
- package/codex/agents/arc-planner.toml +12 -19
- package/codex/agents/arc-qa.toml +7 -15
- package/codex/agents/arc-reviewer.toml +9 -16
- package/codex/agents/arc-scouter.toml +8 -13
- package/codex/skill/SKILL.md +9 -9
- package/codex/skill/models.toml +13 -13
- package/codex/skill/references/arc-visual-companion.md +3 -3
- package/codex/skill/references/brainstorming.md +153 -62
- package/codex/skill/references/commit.md +6 -6
- package/codex/skill/references/coordination.md +20 -8
- package/codex/skill/references/git-recovery.md +2 -2
- package/codex/skill/references/handoff-prep.md +5 -5
- package/codex/skill/references/handoff-worktree.md +4 -4
- package/codex/skill/references/handoff.md +61 -8
- package/codex/skill/references/limits.md +5 -5
- package/codex/skill/references/planning.md +23 -17
- package/codex/skill/references/scripts/start-server.sh +7 -0
- package/codex/skill/references/superpowers-provenance.json +4 -4
- package/codex/skill/references/verification.md +6 -4
- package/codex/skill/runtime/bootstrap.mjs +2 -2
- package/codex/skill/runtime/cooperative-schema.mjs +32 -1
- package/codex/skill/runtime/cooperative.mjs +68 -13
- package/codex/skill/runtime/evaluate.mjs +85 -6
- package/codex/skill/runtime/git-evidence.mjs +98 -0
- package/codex/skill/runtime/operations.mjs +2 -2
- package/codex/skill/runtime/role-policy.json +6 -6
- package/codex/skill/runtime/store.mjs +10 -0
- package/codex/skill/runtime/target-preparation.mjs +110 -0
- package/codex/skill/runtime/verification.mjs +6 -4
- package/codex/skill/scripts/model_config.py +25 -6
- package/lib/installer/global-config.mjs +1 -1
- package/lib/installer/manifest.mjs +6 -2
- package/lib/installer/plan.mjs +8 -5
- package/lib/installer/preset.mjs +7 -4
- package/lib/installer/runtime-assets.mjs +1 -0
- package/lib/management/operations.mjs +1 -1
- package/lib/models/catalog-anthropic.mjs +46 -0
- package/lib/models/catalog.mjs +62 -0
- package/lib/models/codex-catalog.mjs +103 -0
- package/lib/models/config.mjs +19 -11
- package/lib/models/index.mjs +1 -1
- package/lib/policy/role-policy.json +6 -6
- package/lib/prompts/agent-fragments.json +254 -0
- package/lib/prompts/render.mjs +199 -0
- package/lib/runtime/bootstrap.mjs +2 -2
- package/lib/runtime/cooperative-schema.mjs +32 -1
- package/lib/runtime/cooperative.mjs +68 -13
- package/lib/runtime/evaluate.mjs +85 -6
- package/lib/runtime/git-evidence.mjs +98 -0
- package/lib/runtime/operations.mjs +2 -2
- package/lib/runtime/store.mjs +10 -0
- package/lib/runtime/target-preparation.mjs +110 -0
- package/lib/runtime/verification.mjs +6 -4
- package/lib/tui/app.mjs +15 -9
- package/lib/tui/custom-preset.mjs +122 -0
- package/lib/tui/render.mjs +3 -2
- package/lib/tui/setup.mjs +65 -8
- package/package.json +1 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<a id="handoff-contract"></a>
|
|
2
2
|
# Handoff contract
|
|
3
3
|
|
|
4
|
-
Orchestrator reads before every first-start
|
|
4
|
+
Orchestrator reads this before every first-start or restart preparation; Implementer trusts the verified brief and profile and reads only cited sections. Initial preparation follows [handoff-prep](handoff-prep.md).
|
|
5
5
|
|
|
6
6
|
<a id="instruction-sources-bounded-read-recovery-visual-evidence-and-resumption"></a>
|
|
7
7
|
## Instruction sources, bounded read recovery, visual evidence and resumption
|
|
8
8
|
|
|
9
|
-
Keep shared brief field order, recording source/status within fields. Distinguish user instructions, discovered workspace instructions, installed references and inputs by source/applicability/version or approval/access.
|
|
9
|
+
Keep shared brief field order, recording source/status within fields. Distinguish user instructions, discovered workspace instructions, installed references and inputs by source/applicability/version or approval/access. A missing root AGENTS.md does not negate user instructions. Missing required skills/references/approved inputs and conflicts hold dependent work.
|
|
10
10
|
|
|
11
11
|
Optional alternatives need exact locator, material identity, approved version, purpose, method, preconditions, equivalent evidence and return conditions pre-authorized in the brief. Verify alternate locations identify the same material/version. Only side-effect-free reads; no chained search, guessed paths, mutation retries or environment/dependency/permission changes. Return required-input omissions, authority/target/ownership mismatches, partial changes, unknown states and unapproved/ambiguous/failed alternatives immediately. Report first failure/alternative/observations/limits and held dependent/independent work. Orchestrator validates scope/evidence before independent release; unresolved required checks still block acceptance.
|
|
12
12
|
|
|
13
13
|
Visual briefs include exact approved source/version/approval/access, criterion IDs/properties/method and actual-output identity/revision/basis. Implementer reports differ from fresh QA comparison. Report pass/mismatch/unverified with evidence/limits; return new UI interpretations/substitutions.
|
|
14
14
|
|
|
15
|
-
Resume briefs preserve valid unchanged
|
|
15
|
+
Resume briefs preserve valid approval for unchanged scope, completed work, failures and their resolution, valid and invalid evidence, holds and the next objective. Record changed facts and revalidate gates without repeating completed work. Preserve role/Git/QA/final Reviewer/acceptance/commit boundaries.
|
|
16
16
|
|
|
17
17
|
<a id="workspace-handoff"></a>
|
|
18
18
|
## Workspace handoff
|
|
@@ -20,9 +20,9 @@ Resume briefs preserve valid unchanged-scope approval, completed work, failures/
|
|
|
20
20
|
<a id="checkout-approval"></a>
|
|
21
21
|
### Checkout approval
|
|
22
22
|
|
|
23
|
-
Before every Implementer start
|
|
23
|
+
Before every Implementer start or restart, verify access to the supplied absolute workspace and its intended repository. Record the actual path, branch or detached HEAD, HEAD, and staged, unstaged and untracked state. An inaccessible or wrong repository or unresolved HEAD stops work; do not automatically initialize Git or switch repositories.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
The first required spec/plan draft follows choice and verified source evidence and precedes actual preparation; saving follows verified preparation. Initial design may precede choice. Preparation alone authorizes no Implementer. All approvals/full documents/verified batch or valid absence/final Git checks remain. Separate planned scope/paths, actual preparation and drafting/save/approval/commit, recording chronology/gaps.
|
|
26
26
|
|
|
27
27
|
After initial design approval record explicit selection: current checkout, new task branch from verified base there, or managed worktree/task branch. Without choice/valid reuse, wait. Reuse through unchanged-scope/target drafting/implementation. Authorized HEAD/dirty changes alone do not invalidate choice; verify preservation/ownership. Changed scope/target requires fresh choice before dependent drafting/preparation without waiting for full documents. Never fall back automatically.
|
|
28
28
|
|
|
@@ -39,7 +39,7 @@ Orchestrator verifies all before start/restart:
|
|
|
39
39
|
6. Final path/branch/HEAD/state after mutations; no unresolved failure/partial completion.
|
|
40
40
|
7. Brief preparation/final-verification facts/evidence.
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
Before the first direct edit, use approved scope records and the same gates. Any failure/missing condition blocks handoff, not authorized read-only investigation/preparation/recovery. Revalidate changes to approved content/target/branch/HEAD/state. Implementer reports actual conflicts under its profile; Orchestrator resolves and repasses gates.
|
|
43
43
|
|
|
44
44
|
<a id="handoff-evidence"></a>
|
|
45
45
|
### Handoff evidence
|
|
@@ -52,6 +52,7 @@ One canonical record includes:
|
|
|
52
52
|
- Document SHA/message/paths/approved content; reused versus batch commits or valid absence/depth rationale.
|
|
53
53
|
- Absolute approved artifacts, full set/versions/coverage/dependencies/order and no pending writing/approval.
|
|
54
54
|
- Final verification, failures/partial completion/recovery and each start/restart's approval/choice/reuse.
|
|
55
|
+
- Each plan task ID and current Implementer conversation ID, status, last result and reuse/replacement decision. Before same-task replacement, record the prior ID and status, allowed reason and supporting evidence; hold if the reason is not established. Record the returned ID after a successful initial or replacement call, and reconcile an uncertain call result before another assignment.
|
|
55
56
|
- Worktree source/target paths/common directory/base/branch/name/returned path/app attachment/operationId/registration/source preservation/transfer evidence. No automatic recreation/cleanup/archive.
|
|
56
57
|
|
|
57
58
|
Give all five roles the same actual workspace/selected checkout, preparation evidence and absolute artifacts. Roles stay there and report missing/inaccessible/conflicting paths/unexpected branches before dependent work, never create/switch workspaces/branches. Tell Implementer others share the repository and unrelated work must be preserved.
|
|
@@ -95,7 +96,7 @@ Selected worktrees require common directory, registration, app-managed current-c
|
|
|
95
96
|
|
|
96
97
|
Before feature/bug/behavior edits use local `test-driven-development` except explicit ARC exceptions. Full rules live in the profile. Waiver requires all low-risk and plan-skip/direct conditions, recorded scope/justification/criteria/checks before work. User/task-specific TDD overrides it; only qualifying tasks override local generic triggers without changing skills. Ordinary multistep/significant/high-risk work is ineligible.
|
|
97
98
|
|
|
98
|
-
Waiver skips RED-GREEN only, preserving focused checks/risk-scaled QA/Reviewer; never claim TDD.
|
|
99
|
+
Waiver skips RED-GREEN only, preserving focused checks/risk-scaled QA/Reviewer; never claim TDD. 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 the evidence. Other blocked required steps need recorded decision/required human approval, not internal substitutes. Non-behavior docs/config use specifically approved exceptions only, never generalize to behavior.
|
|
99
100
|
|
|
100
101
|
<a id="orchestrator-direct-path-for-small-tasks"></a>
|
|
101
102
|
## Orchestrator direct path for small tasks
|
|
@@ -109,6 +110,58 @@ Record target choice/reuse before first edit; scope approval alone selects no ta
|
|
|
109
110
|
|
|
110
111
|
Add no plans/automatic commits to omission paths; follow guidance/user requests.
|
|
111
112
|
|
|
113
|
+
|
|
114
|
+
### Fast gate
|
|
115
|
+
|
|
116
|
+
Select the existing direct path only when all eight conditions are `proven`. Record each as `proven`, `unmet`, or `unverified` with evidence; any `unmet`, `unverified`, missing or ambiguous condition requires full evaluation. Missing required inputs or operational failure also holds dependent work; full evaluation is no bypass.
|
|
117
|
+
|
|
118
|
+
- **F1**: Scope authorization identifies outcome, scope, criteria and edit boundaries, with no unresolved material behavior, method or risk decision.
|
|
119
|
+
- **F2**: One local, understood, reversible change with understood impact and outcome.
|
|
120
|
+
- **F3**: No dependent stages, cross-component shared state, lifecycle or integration-order concerns.
|
|
121
|
+
- **F4**: Meets [risk-scaled execution](verification.md#risk-scaled-execution) low-risk conditions and no existing direct-path exclusion applies.
|
|
122
|
+
- **F5**: One focused verification path covers criteria and identifies required independent QA/Reviewer.
|
|
123
|
+
- **F6**: Explicit target choice or valid reuse, current workspace and change state, preservation and no active ownership conflict are established.
|
|
124
|
+
- **F7**: Applicable TDD is identified; any waiver or non-behavior exception meets existing conditions and is recorded beforehand. Explicit user/task TDD overrides waiver.
|
|
125
|
+
- **F8**: Applicable instruction source-set and approval, target, criteria and verification evidence are accessible, consistent and unambiguous.
|
|
126
|
+
|
|
127
|
+
Security/permissions and public-interface changes are never eligible under the existing significant-risk exclusions. File count, LOC and apparent simplicity prove none of F2–F5. This gate does not replace the first direct edit gate, Implementer start/restart gate, target choice, TDD, independent QA and Reviewer, acceptance or commit; existing triggers determine whether each gate applies. The fast path does not add untriggered role, QA/Reviewer, acceptance or commit obligations. Preserve all existing platform restrictions.
|
|
128
|
+
|
|
129
|
+
### Instruction fingerprint
|
|
130
|
+
|
|
131
|
+
Record the actual applicable source-set: platform ARC SKILL, these initial reference sections, applicable workspace instructions, and triggered references/skills; record user/platform messages by message and approval reference, not invented file hashes. Record native role profile source/version when assigned; a new role receives actual instructions, profile, needed paths and criteria, not merely a hash. Do not assume disk profile changes updated an active role.
|
|
132
|
+
|
|
133
|
+
Distinguish user-provided instructions, workspace instructions, installed references and task inputs by source, applicability and access state: available, absent, inaccessible, conflicting or unverified. For every file record source kind, absolute and resolved path, read sections, available revision, SHA-256 of entire file bytes, access state, observation and read-context references. Neither HEAD nor installer manifest substitutes for actual installed-source hash. Use only already identified source paths; do not search or guess. An uncertain source-set makes F8 `unverified`.
|
|
134
|
+
|
|
135
|
+
Reuse read content only for the same source-set, absolute source locators, resolved paths, hashes, scope and same conversation context with meaning still available. Different absolute locators cannot be reused even if they resolve to the same path. New context, inaccessible record or context loss requires rereading; changed source/hash requires rereading and reassessing affected judgments. Verify the current source-set/hash at a new fast judgment, first-edit or assignment/restart/resumption gate, before acceptance, and on known source changes; reuse observations within the same gate. If hashing fails, do not reuse; follow existing read recovery and hold required inaccessible inputs. When Node is already available, batch identified absolute paths with built-in `node:fs` realpath/readFileSync and `node:crypto` SHA-256; install nothing and print no source content.
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
For identified absolute sources only, when Node is already available, this read-only example prints paths and hashes, not contents:
|
|
139
|
+
|
|
140
|
+
```sh
|
|
141
|
+
node --input-type=module -e '
|
|
142
|
+
import fs from "node:fs";
|
|
143
|
+
import crypto from "node:crypto";
|
|
144
|
+
const sources = process.argv.slice(1);
|
|
145
|
+
if (!sources.length) throw new Error("No instruction sources");
|
|
146
|
+
for (const source of sources) {
|
|
147
|
+
const resolvedPath = fs.realpathSync(source);
|
|
148
|
+
const contentHash = "sha256:" + crypto.createHash("sha256").update(fs.readFileSync(resolvedPath)).digest("hex");
|
|
149
|
+
process.stdout.write(JSON.stringify({source, resolvedPath, contentHash}) + "\n");
|
|
150
|
+
}
|
|
151
|
+
' -- '/absolute/identified/source-1' '/absolute/identified/source-2'
|
|
152
|
+
```
|
|
153
|
+
A new conversation or lost context requires reread; unchanged HEAD alone does not prove instruction, file or check evidence current.
|
|
154
|
+
|
|
155
|
+
### Task envelope
|
|
156
|
+
|
|
157
|
+
Place the compact envelope in the existing canonical handoff record or existing inline scope record, not a new file, store or API. Record task path and outcome; instructions; target; approval; scope and criteria; risk and depth; TDD; verification; refresh. Specifically include task ID/path, source fingerprint/read context, workspace/branch/HEAD/change state/preservation/ownership, scope approval and target choice, edit boundaries/criteria, F1–F8 evidence/risk/depth, TDD or recorded exception, criterion checks/QA/Reviewer/acceptance, and observations/changes/revalidation/holds. Link accessible records; inaccessible references do not replace required content. Embed it in the existing eight specialist brief fields in their fixed order, without a ninth field or full history.
|
|
158
|
+
|
|
159
|
+
The nine fields are `task`, `instructions`, `target`, `authorization`, `scopeCriteria`, `riskDepth`, `tdd`, `verification`, and `refresh`; task records the task ID/path and selected path `fast-direct` or `full`, and verification includes criteria-specific checks and their evidence.
|
|
160
|
+
|
|
161
|
+
### Evidence refresh
|
|
162
|
+
|
|
163
|
+
Evaluate target choice validity separately from evidence validity. Approved HEAD or expected dirty changes do not invalidate target choice by themselves: record current state, preservation and ownership, and assess affected criteria/checks. Revalidate only affected evidence; a related file change after a check leaves that check unverified until repeated as needed. Changed instructions require reassessing linked fast/risk/TDD/authorization judgments. Preserve unaffected evidence and valid approvals. Unclear impact, missing or inaccessible evidence, ownership conflict, failure or partial/unknown state requires existing hold and recovery; workspace/target change or loss of trust follows target-choice rules. For a target change, obtain a new choice where required and state confirmation before dependent edit. Scope/criteria/method/risk changes follow existing approval and fresh-role rules. A failed direct check or QA finding returns to existing Implementer/recheck ownership.
|
|
164
|
+
|
|
112
165
|
<a id="cooperative-cli-verification-handoff"></a>
|
|
113
166
|
## Cooperative CLI verification handoff
|
|
114
167
|
|
|
@@ -118,7 +171,7 @@ On scope/docs/approval changes inspect `affectedTaskIds`/dependencies, preserve
|
|
|
118
171
|
|
|
119
172
|
[ARC role policy: contract begin]
|
|
120
173
|
Generated from lib/policy/role-policy.json; do not edit this managed section manually.
|
|
121
|
-
- [git.specialists-deny] Specialists must not change Git state during implementation or recovery: no stage, commit, push, merge, rebase, reset, branch creation/switching or worktree creation/removal. Explicit Orchestrator assignment cannot authorize these actions; return them to Orchestrator. Read-only Git inspection within the assigned scope
|
|
174
|
+
- [git.specialists-deny] Specialists must not change Git state during implementation or recovery: no stage, commit, push, merge, rebase, reset, branch creation/switching or worktree creation/removal. Explicit Orchestrator assignment cannot authorize these actions; return them to Orchestrator. Read-only Git inspection remains allowed within the assigned scope.
|
|
122
175
|
- [role.implementer-implementation] Edit only assigned, approved files and run focused checks under the existing TDD contract. Report changed files, RED/GREEN or approved exception evidence, results, limits and follow-up. Do not plan, independently QA/review your own work, accept the task or declare overall completion. Git mutations remain forbidden after successful implementation. Implementer and fresh QA handoffs include the exact approved visual source, version, approval and access state; criterion IDs, required properties and comparison method; and actual-output identity, revision and comparison basis. Record pass, mismatch or unverified with accessible evidence and limits. Implementer self-report does not replace fresh QA and its actual comparison. A missing output-to-revision link is unverified; record a visible difference separately as mismatch without inferring current branch UI state. Missing source/output, inaccessible evidence or unapproved interpretation holds the affected visual claim for Orchestrator. Do not silently substitute or redesign.
|
|
123
176
|
- [review.significant-no-plan] Significant/high-risk work without a plan follows Implementer → QA and required QA rechecks → Reviewer of the final full change → Orchestrator acceptance. Do not omit Reviewer because no plan exists. This adds no plan obligation.
|
|
124
177
|
- [review.significant-plan] Significant/high-risk plan work follows Implementer → required fresh QA → Orchestrator acceptance and focused commit for each task. After all tasks are accepted and required QA is complete, Reviewer reviews the final full change once. Reviewer is not a per-task or per-commit gate. Preserve required checks and necessary finding rechecks.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<a id="subagent-limits"></a>
|
|
2
2
|
# Subagent limits
|
|
3
3
|
|
|
4
|
-
Before first creation, Orchestrator reads this reference and adjacent `../limits.toml` (installed at `skills/arc/limits.toml`). Require `version = 1` and positive safe-integer `max_total_subagents`/`max_concurrent_subagents`. Installation defaults are `100`/`5`. Missing, malformed or unreadable policy blocks creation
|
|
4
|
+
Before the first creation, Orchestrator reads this reference and the adjacent `../limits.toml` (installed at `skills/arc/limits.toml`). Require `version = 1` and positive safe-integer `max_total_subagents`/`max_concurrent_subagents`. Installation defaults are `100`/`5`. Missing, malformed or unreadable policy blocks creation. Report it without assuming defaults. Freeze settings for one ARC session/tree; reinstalling affects new sessions.
|
|
5
5
|
|
|
6
6
|
<a id="counting-and-reservations"></a>
|
|
7
7
|
## Counting and reservations
|
|
8
8
|
|
|
9
9
|
- Track instance IDs, parent IDs, pending reservations, creation outcomes and active/completed state in the session ledger. Exclude Orchestrator, but count every created descendant, including nested/non-ARC agents.
|
|
10
|
-
- Completion never refunds cumulative creation.
|
|
11
|
-
- Waiting, blocked, running and resumable idle instances consume concurrency until
|
|
10
|
+
- Completion never refunds cumulative creation. A follow-up or resume using the same instance adds nothing; fresh instances, new-instance retries and replacements increment the total.
|
|
11
|
+
- Waiting, blocked, running and resumable idle instances consume concurrency until completion or termination is confirmed. Obey lower actual runtime capacity, including native retention of completed instances. ARC counts do not prove free native slots.
|
|
12
12
|
|
|
13
13
|
Reserve the full proposed parallel batch before dispatch, satisfying both:
|
|
14
14
|
|
|
@@ -20,9 +20,9 @@ Reserve before each call. Confirmed creation becomes a created/active ID. Releas
|
|
|
20
20
|
<a id="continuation-and-exhaustion"></a>
|
|
21
21
|
## Continuation and exhaustion
|
|
22
22
|
|
|
23
|
-
Preserve the ledger across continuation
|
|
23
|
+
Preserve the ledger across continuation, resume and compaction, and reconcile actual IDs before dispatch. Never reset lost counters to zero. Incomplete reconstruction holds creation and reports unknown budget; use a conservative upper bound only when records support it.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Confirmed completion or termination frees active capacity. Exhaustion holds creation and reports remaining work/budget; it never waives QA/Reviewer, role freshness, approval, ownership, dependency or same-file edit gates.
|
|
26
26
|
|
|
27
27
|
Cumulative limits and scheduling are prompt policy, not hard runtime controls. Text tests prove package consistency, not live compliance/native support.
|
|
28
28
|
Codex `[agents].max_concurrent_threads_per_session` and Claude `settings.json.env.CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS` constrain their respective sessions.
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
<a id="planning-contract"></a>
|
|
2
2
|
# Planning contract
|
|
3
3
|
|
|
4
|
-
Read before depth judgments, spec
|
|
4
|
+
Read before depth judgments, spec or plan drafting and approval, and first saves.
|
|
5
5
|
|
|
6
6
|
<a id="authorization-and-scope"></a>
|
|
7
7
|
## Authorization and scope
|
|
8
8
|
|
|
9
|
+
Use the [fast gate and envelope](handoff.md#orchestrator-direct-path-for-small-tasks) alongside these existing scope and approval rules; reuse valid approvals and hold changed scope under these rules.
|
|
10
|
+
|
|
9
11
|
An explicit execution request authorizes only sufficiently specified scope from that request or a description the user explicitly references. Confirm intent/outcome/constraints/document depth/verification risk and no unresolved material behavior/method/risk decision. Record approval evidence, scope, criteria, constraints and depth. Orchestrator may choose routine execution/check details, not unapproved product behavior/material scope. Restating/handoff/restart of unchanged scope needs no new approval.
|
|
10
12
|
|
|
11
13
|
Silence, ambiguous assent, other-work approval and vague blanket improvements are insufficient. Planner's new material choices are not automatically approved. Request missing decisions through Orchestrator. Required specs/plans retain separate ordered approval.
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
Hold affected work for material changes to scope, method or risk, and report the missing decision, evidence and remaining scope. Target change, unclear ownership, unexpected state, unresolved failure or missing inputs also hold under [handoff](handoff.md)/[recovery](git-recovery.md). Distinguish new authorization from existing-scope execution issues; routine correction/reverification needs no duplicate approval. Revalidate after resolution.
|
|
14
16
|
|
|
15
17
|
<a id="probe-scope"></a>
|
|
16
18
|
### Probe scope
|
|
@@ -22,24 +24,26 @@ If explicitly requested probe+implementation is fully specified, classify the wh
|
|
|
22
24
|
<a id="formal-drafting-boundary"></a>
|
|
23
25
|
## Formal drafting boundary
|
|
24
26
|
|
|
25
|
-
Initial design/brainstorming may precede target choice.
|
|
27
|
+
Initial design/brainstorming may precede target choice. Before the first required spec/plan draft, record verified source workspace/repository, branch/HEAD, changes/ownership, explicit choice, approved scope/depth/document set and planned relative paths. Planner returns the complete first draft and self-review in chat before target preparation. Revalidate source and selected target at the focused preparation gate, prepare the chosen target, compare actual target and preservation, then review and save in the verified prepared target. Planned paths prove no preparation. Missing or mismatched evidence holds affected work; preparation alone never starts Implementer.
|
|
26
28
|
|
|
27
|
-
Small-task direct edits follow only [handoff](handoff.md#orchestrator-direct-path-for-small-tasks), stopping/reclassifying changed scope/risk. Otherwise follow this reference. `brainstorming`/`writing-plans` instruct existing roles, not extra agents; ARC routing/approval overrides alternate executors. Missing required skills block their stage. Integration
|
|
29
|
+
Small-task direct edits follow only [handoff](handoff.md#orchestrator-direct-path-for-small-tasks), stopping/reclassifying changed scope/risk. Otherwise follow this reference. `brainstorming`/`writing-plans` instruct existing roles, not extra agents; ARC routing/approval overrides alternate executors. Missing required skills block their stage. Integration includes saving, reviewing and directly revising the same spec or plan after the complete Planner first draft; design/brainstorming retain their Planner drafting path.
|
|
28
30
|
|
|
29
|
-
For Korean requests
|
|
31
|
+
For Korean requests and briefs, Planner uses Korean titles and prose unless another language is requested, preserving identifiers, skill/API names, code, paths, commands and literals. Orchestrator preserves agreed language when saving.
|
|
30
32
|
|
|
31
33
|
<a id="planner-drafting-preparation-and-consolidated-feedback"></a>
|
|
32
34
|
## Planner drafting preparation and consolidated feedback
|
|
33
35
|
|
|
34
36
|
Planner reports initial/revision progress only to Orchestrator: brief stage/feedback/blocker/next step, never body/excerpts/incremental drafts. Return complete draft/self-review. Raw responses may appear in app/tool surfaces; prompt policy cannot hide them. User updates stay brief/status-based without draft content. At approval present integrated/saved/reviewed Markdown without repeating its body in chat.
|
|
35
37
|
|
|
38
|
+
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. Orchestrator can read a few already identified files directly; route material research and broad static exploration to Scouter.
|
|
39
|
+
|
|
36
40
|
1. Preflight relevant policy/references/profiles/tests/parity/manifest/conflicts. Apply formal-target and coordination provenance/input/local-skill gates, including required paths, approved bounded read alternatives and return conditions. Missing inputs/conflicts hold drafting. Read recovery grants no preparation/check/write/approval authority.
|
|
37
41
|
2. Maintain a compact ledger of original requirements/IDs, approved/open decisions, exclusions and scope deltas. Consolidate intervening user changes into one brief delta. Separate approvals, path/line-verified facts, assumptions and open decisions.
|
|
38
|
-
3. Send one complete stage-specific initial brief
|
|
39
|
-
4. Planner returns complete proportional draft
|
|
40
|
-
5. Further calls after correction need approved material scope/evidence changes or concrete unmet checklist items plus meaningful new input/criterion progress. State changed input/target criterion/expected artifact/progress. Existing-scope omissions need no renewed scope approval. Repeated unmet criteria without new input/evidence/progress hold the stage; report criterion/observation/exact unblock decision. Do not repeat resolved questions or count rewording/agent replacement as progress.
|
|
42
|
+
3. Reuse a relevant Planner instance across related stages when role, context and source remain valid. Send one complete stage-specific initial brief. Include verified source/HEAD/ownership, selected target intent and planned paths (or prepared target for later stages), and scope/exclusions/depth/dependencies/shared contracts/criteria/checks/evidence/holds. Include preceding approved versions and paths, current behavior and connected source/generated/runtime/installer/docs, policy conflicts/resolution direction and exact deliverable. Visual work includes approved sources/versions/criteria/open interpretations. Follow-up briefs send changed fields and cite an accessible prior brief for unchanged fields; inaccessible conversations or hashes alone cannot replace required inputs. Reuse evidence only for the same source set, absolute locator, resolved path, content fingerprint, purpose, approval scope and accessible context. When source, target or scope changed, reconfirm affected inputs.
|
|
43
|
+
4. Planner returns the complete proportional first draft and self-review. Orchestrator saves and reviews it against the fixed checklist: scope/evidence; targets/ownership/paths; policy/conflicts; task boundaries/dependencies/criteria; checks/evidence/holds; roles/approval/commit boundaries; completeness. For spec or plan, Orchestrator directly revises the same document, including substantive omissions, before requesting approval. New product decisions outside approved scope require user input first; Orchestrator then revises the document. Missing or failed first drafts stop the stage and do not transfer initial authorship.
|
|
44
|
+
5. For design and brainstorming, finish the checklist before one consolidated correction covering every substantive omission with criterion/defect/evidence/expected fix. Use deltas/`unchanged`; never split by omission. Further calls after correction need approved material scope/evidence changes or concrete unmet checklist items plus meaningful new input/criterion progress. State changed input/target criterion/expected artifact/progress. Existing-scope omissions need no renewed scope approval. Repeated unmet criteria without new input/evidence/progress hold the stage; report criterion/observation/exact unblock decision. Do not repeat resolved questions or count rewording/agent replacement as progress.
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
For design and brainstorming, allow initial draft and one consolidated correction. Orchestrator handles reformatting, re-expression, save and patch errors without Planner calls. Separate substantive work uses normal gates. Design/spec/plan stages remain separately ordered; spec approval precedes dependent planning. Add no fixed call cap/profile count condition or incomplete-draft acceptance.
|
|
43
47
|
|
|
44
48
|
<a id="design-and-planning"></a>
|
|
45
49
|
<a id="design-path-and-plan-depth"></a>
|
|
@@ -53,9 +57,11 @@ Record depth separately from risk. Risk controls checks/review, not design paths
|
|
|
53
57
|
4. Record dependencies/depth reasons. Planner returns complete plan/assumptions/open decisions/checks/self-review. Orchestrator saves/reviews/obtains approval before Implementer at user path or `docs/superpowers/plans/YYYY-MM-DD-<feature-name>.md`. Default spec path is `docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md`.
|
|
54
58
|
5. Every Implementer first start/restart needs applicable approvals/artifacts/brief/findings and full handoff. Non-behavior docs/config omit only inapplicable stages. Direct edits need approved scope record and same first-edit gates.
|
|
55
59
|
|
|
56
|
-
If Bounded requires written spec, record necessity/scope using approved short design as basis. Planner returns proportional full spec/self-review; Orchestrator saves/reviews/obtains individual approval before dependent plan
|
|
60
|
+
If Bounded requires written spec, record necessity/scope using approved short design as basis. Planner returns proportional full spec/self-review; After actual preparation, Orchestrator saves/reviews/obtains individual approval in the prepared target before the dependent plan. Short design approval never substitutes. This applies recorded judgment, not new spec necessity. Required plans alone imply no written spec.
|
|
61
|
+
|
|
62
|
+
Only Planner authors the first complete spec or plan draft and self-review. Orchestrator reviews and directly revises the same document before approval. Unavailable/failed Planner stops first drafting rather than transferring authorship. Design approval does not transfer initial authorship.
|
|
57
63
|
|
|
58
|
-
|
|
64
|
+
For initial fast judgment apply the [fast gate](handoff.md#orchestrator-direct-path-for-small-tasks); its sufficient conditions do not change these depth decisions.
|
|
59
65
|
|
|
60
66
|
<a id="top-level-plan-tasks"></a>
|
|
61
67
|
## Top-level plan tasks
|
|
@@ -85,7 +91,7 @@ Before first Architectural spec, required Bounded spec or plan save, read this a
|
|
|
85
91
|
| Spec | Approved design scope/evidence, complete Planner draft/self-review, Orchestrator integration/save/review ownership and absolute path. Required Bounded specs also need depth judgment, short design, necessity/scope |
|
|
86
92
|
| Plan | Approved design and required approved spec/version/evidence, depth judgment, plan list/dependencies, complete Planner draft/self-review, ownership and absolute path |
|
|
87
93
|
|
|
88
|
-
Saving for review does not require prior written-spec approval, but does require valid target choice/actual preparation. Individually approved specs enter the document set before dependent planning. Never call uncommitted files committed. Missing
|
|
94
|
+
Saving for review does not require prior written-spec approval, but does require valid target choice/actual preparation. Individually approved specs enter the document set before dependent planning. Never call uncommitted files committed. Missing or mismatched evidence stops the affected save.
|
|
89
95
|
|
|
90
96
|
<a id="complete-planning-document-set"></a>
|
|
91
97
|
## Complete planning-document set
|
|
@@ -94,7 +100,7 @@ Include all current-scope required specs/plans, excluding future projects. Recor
|
|
|
94
100
|
|
|
95
101
|
A required plan implies no spec. Bounded follows recorded judgment; spec stages cover Architectural/required Bounded only, plan stages required plans only. Add no spec duty to Spike/plan-skip/non-behavior paths.
|
|
96
102
|
|
|
97
|
-
Order: initial design approval → explicit target →
|
|
103
|
+
Order: initial design approval → explicit target and source snapshot → first required draft/self-review → focused preparation gate → actual preparation/comparison → save/review/individual approval → dependent plans drafting/save/review/individual approval → full set → verify existing commits/batch remaining approvals → final Git → Implementer. Omission skips only inapplicable documents with rationale. Complete documents precede staging/commit/handoff, not initial preparation/choice request. Partial approvals authorize no early implementation.
|
|
98
104
|
|
|
99
105
|
Defer local `brainstorming`'s early spec commit: save/self-review/approve uncommitted spec, approve all plans, then final batch. Modify no external skill. `writing-plans` implementation commits grant neither planning-document commits nor early Implementer.
|
|
100
106
|
|
|
@@ -102,8 +108,8 @@ Defer local `brainstorming`'s early spec commit: save/self-review/approve uncomm
|
|
|
102
108
|
|---|---|
|
|
103
109
|
| Spike | Approve question/method/scope/criteria/constraints; no forced unknown-implementation docs. Implementer probes require handoff; read-only Orchestrator/Planner probes without Implementer do not trigger it |
|
|
104
110
|
| Bounded, plan skipped | Approve short design; record omission conditions. Complete approvals, target choice, actual docs or valid absence, then handoff |
|
|
105
|
-
| Bounded, plan required | Approve design/all required plans; approve necessary specs before dependent planning.
|
|
106
|
-
| Architectural | Design → written spec → all `writing-plans` plans.
|
|
111
|
+
| Bounded, plan required | Approve design/all required plans; approve necessary specs before dependent planning. Draft the first required document before target preparation; complete set before batch/handoff |
|
|
112
|
+
| Architectural | Design → written spec → all `writing-plans` plans. First spec draft before target preparation; full set before batch/final checks/handoff |
|
|
107
113
|
| Non-behavior docs/config | Record scope/criteria/inapplicability. Preserve target/Git/docs-or-absence/handoff |
|
|
108
114
|
|
|
109
115
|
New planning scope requires list/depth/dependency reassessment and approvals before dependent drafting/commit. Approved-body changes need revised approval except mechanical records below. New implementation scope holds execution until docs/approvals/preparation complete. Running Implementer stops before newly dependent edits; inspect actual changes/Git without retrospective preparation claims. Reflect approved versions through original-commit updates below. Unchanged-document restarts follow handoff lifetime.
|
|
@@ -113,7 +119,7 @@ New planning scope requires list/depth/dependency reassessment and approvals bef
|
|
|
113
119
|
|
|
114
120
|
Mechanical checkboxes/results/evidence/completion preserving the approved contract need no new approval; record classification/reason/actual time. Removing checks, invented success, unsupported acceptance or mixed scope changes are not mechanical.
|
|
115
121
|
|
|
116
|
-
|
|
122
|
+
Changes to goals, task boundaries, scope, criteria, method, risk, dependencies or checks require revised approval before affected work. Hold, obtain ordered design/spec/plan approvals and prepare target/ownership/checks/handoff. Other body corrections follow version approval; classify typos/paths/commands/explanations by semantic effect.
|
|
117
123
|
|
|
118
124
|
Both kinds amend the original planning commit at safe boundaries, never separate docs/fixup commits, including new scope. Preserve implementation commits. Rewriting does not backdate approval; latest content in an old commit proves no earlier authorization.
|
|
119
125
|
|
|
@@ -151,7 +157,7 @@ Generated from lib/policy/role-policy.json; do not edit this managed section man
|
|
|
151
157
|
- [review.significant-plan] Significant/high-risk plan work follows Implementer → required fresh QA → Orchestrator acceptance and focused commit for each task. After all tasks are accepted and required QA is complete, Reviewer reviews the final full change once. Reviewer is not a per-task or per-commit gate. Preserve required checks and necessary finding rechecks.
|
|
152
158
|
- [review.final-plan-recheck] Final overall Reviewer findings on plan work, including behavior findings, follow Implementer → Reviewer without QA reassignment until resolved. This exception applies only at the final plan stage. Preserve required QA and QA failure rechecks before the initial final review and outside this exception.
|
|
153
159
|
- [planning.plan-amend] Mechanical plan progress records during approved execution need no new user approval. Changes to goals, scope, criteria, method, risk, dependencies or required verification need revised-version approval and preparation before affected work. In both cases Orchestrator amends the original planning-document commit at a safe boundary, with no separate document or fixup commit. Preserve actual approval chronology, recoverable old/new content, hashes, versions and SHA mappings; never authorize past work retroactively. Rewrite only unpublished, unshared local linear history with clear ownership and no merges. Unknown publication/ownership, unexpected state or replay conflicts stop rewriting; no force push or fallback document commit. Preserve implementation task boundaries and revalidate affected evidence. Follow planning, handoff-prep, commit and verification for the full contract.
|
|
154
|
-
- [planning.planner-brief] Follow planning.md's Planner drafting preparation and
|
|
160
|
+
- [planning.planner-brief] 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 across related stages when its role, context and source remain valid. 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, allow the initial draft and one consolidated correction. Orchestrator reviews once with the fixed checklist and sends one consolidated correction using changed fields only. 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. Preserve separate sequential design/spec/plan approvals. 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.
|
|
155
161
|
- [platform.codex] Role restrictions are prompt-level contracts, not a filesystem sandbox. ARC supplies no native observer hook or role-specific Git guard. Existing shell capabilities are retained because static read access after shell reduction has not been verified; Implementer and QA need shell for approved checks.
|
|
156
162
|
[ARC role policy: contract end]
|
|
157
163
|
|
|
@@ -114,6 +114,13 @@ umask 077
|
|
|
114
114
|
SESSION_ID="$$-$(date +%s)"
|
|
115
115
|
|
|
116
116
|
if [[ -n "$PROJECT_DIR" ]]; then
|
|
117
|
+
# Make the project dir absolute now: the script cds into its own directory
|
|
118
|
+
# before starting the server, which would re-root a relative path there.
|
|
119
|
+
# mkdir -p keeps the existing behavior of creating a missing project dir.
|
|
120
|
+
if ! PROJECT_DIR="$(mkdir -p -- "$PROJECT_DIR" && CDPATH='' cd -- "$PROJECT_DIR" && pwd)"; then
|
|
121
|
+
echo "{\"error\": \"Cannot create or enter --project-dir\"}"
|
|
122
|
+
exit 1
|
|
123
|
+
fi
|
|
117
124
|
SESSION_DIR="${PROJECT_DIR}/.superpowers/brainstorm/${SESSION_ID}"
|
|
118
125
|
# Persist the bound port and key per project so a restart reuses them and an
|
|
119
126
|
# already-open browser tab reconnects to the same URL with a valid cookie.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"repository": "https://github.com/obra/superpowers",
|
|
4
|
-
"revision": "
|
|
5
|
-
"fetchedAt": "2026-
|
|
4
|
+
"revision": "22f0b463e7a5e579904dd6211a520321035526f7",
|
|
5
|
+
"fetchedAt": "2026-11-06T16:48:59.704Z",
|
|
6
6
|
"skills": [
|
|
7
7
|
"brainstorming",
|
|
8
8
|
"writing-plans",
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
],
|
|
11
11
|
"files": {
|
|
12
12
|
"LICENSE": "a37e0e9697144819e1d965176ac4ae5bc3fa02d11e7812036bbcadf6dafe2400",
|
|
13
|
-
"brainstorming/SKILL.md": "
|
|
13
|
+
"brainstorming/SKILL.md": "2c9ca71f94886f9ca9f4aef055f7cafb3e1a9bdf3aeebf8f4cb547c69405d207",
|
|
14
14
|
"brainstorming/builder-check-prompt.md": "36d51a4723d6f0a3ce5811a0ea3b3a8424f07533947e1355f5d8cb8cce40c55e",
|
|
15
15
|
"brainstorming/scripts/frame-template.html": "6a8a4e58bd6a44b904e2e3c57de774481d909204597e1498de53f1b2fecc4c4e",
|
|
16
16
|
"brainstorming/scripts/helper.js": "43c6d69954a46ec34a2a262bcc62a9a7e83e839c739f199cb72646d397c686e3",
|
|
17
17
|
"brainstorming/scripts/server.cjs": "763abf96510e0b892a1141397b31aa82ef900cf87ed34dde94bc8782baf4a7ca",
|
|
18
|
-
"brainstorming/scripts/start-server.sh": "
|
|
18
|
+
"brainstorming/scripts/start-server.sh": "314dd68dc00e8dd94c7491aca8a5f004c7fddffc161e2b07482f29f48d13659a",
|
|
19
19
|
"brainstorming/scripts/stop-server.sh": "0b5ccbbd57f62d3ed88993f7940b5ee0e5c0fc9b21c550c623da4f6292e47daf",
|
|
20
20
|
"brainstorming/visual-companion.md": "6ffcb038b53254bd31debaa15e12dcd4ff24bd63d690e0b644ac6396701cf2e2",
|
|
21
21
|
"writing-plans/SKILL.md": "a6c67c1900064347c2a329990dd3c555657c51c3ec53b259a08aa01a2c26139a",
|
|
@@ -8,14 +8,16 @@ Read before verification design, QA/Reviewer assignment, correction rechecks or
|
|
|
8
8
|
<a id="visual-evidence-and-adjudication"></a>
|
|
9
9
|
## Visual evidence and adjudication
|
|
10
10
|
|
|
11
|
-
Each criterion needs exact approved source
|
|
11
|
+
Each criterion needs the exact approved source, version, approval and access state; IDs, properties and comparison method; and a link between output and revision. Implementer reporting does not replace fresh QA. Record pass/mismatch/unverified and connect to criterion verdicts; pass needs accessible supporting evidence. Missing linkage is unverified; visible difference is mismatch, separately, without inferring current branch UI. Hold comparison when materials are inaccessible or interpretation approval is missing.
|
|
12
12
|
|
|
13
|
-
Policy
|
|
13
|
+
Policy, generated-file and manifest checks prove structure, not role behavior, installed builds, Claude Code CLI compliance or fidelity. Report changes, exclusions, checks run and omitted, criterion evidence and limits, and platform availability. Report baseline failures separately; independent progress does not relax checks.
|
|
14
14
|
|
|
15
15
|
<a id="risk-scaled-execution"></a>
|
|
16
16
|
## Risk-scaled execution
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
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.
|
|
19
|
+
|
|
20
|
+
Edits belong to Implementer except the [small direct path](handoff.md#orchestrator-direct-path-for-small-tasks). Orchestrator determines behavior, risk and minimum meaningful checks.
|
|
19
21
|
|
|
20
22
|
| Risk | Minimum flow |
|
|
21
23
|
|---|---|
|
|
@@ -34,7 +36,7 @@ Ordinary/significant tasks need fresh QA before acceptance. Low risk requires na
|
|
|
34
36
|
|
|
35
37
|
Record which risk/instruction/approved obligations each check satisfies. Do not automatically assign QA/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.
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
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.
|
|
38
40
|
|
|
39
41
|
<a id="final-plan-reviewer-correction-loop"></a>
|
|
40
42
|
### Final plan Reviewer correction loop
|
|
@@ -6,7 +6,7 @@ import {observeCooperativeTarget,validateObservedTarget,validateWorkflowId,workf
|
|
|
6
6
|
import {saveDurableState} from './store.mjs';
|
|
7
7
|
export const COOPERATIVE_RUNTIME_MODULES=Object.freeze([
|
|
8
8
|
'cli.mjs','command.mjs','bootstrap.mjs','cooperative-schema.mjs','cooperative.mjs','evaluate.mjs',
|
|
9
|
-
'scope.mjs','store.mjs','git-evidence.mjs','assignment.mjs','verification.mjs','acceptance.mjs','external.mjs','schema.mjs','operations.mjs','gate.mjs','adapters/codex.mjs','adapters/claude.mjs','capabilities.mjs','identity.mjs','git-query.mjs'
|
|
9
|
+
'scope.mjs','store.mjs','git-evidence.mjs','assignment.mjs','verification.mjs','acceptance.mjs','external.mjs','schema.mjs','operations.mjs','gate.mjs','adapters/codex.mjs','adapters/claude.mjs','capabilities.mjs','identity.mjs','git-query.mjs','target-preparation.mjs'
|
|
10
10
|
]);
|
|
11
11
|
export const cooperativeCoverage=()=>({enforcement:'cooperative',provenance:'operator-attested',nativeVerified:false});
|
|
12
12
|
export function commandResult({workflowId,state,input,decision='allow',ruleId='cooperative.recorded',persisted=false,...extra}){
|
|
@@ -16,7 +16,7 @@ export async function cooperativeVersions(){
|
|
|
16
16
|
const hash=bytes=>'sha256:'+crypto.createHash('sha256').update(bytes).digest('hex');
|
|
17
17
|
let policy;try{policy=await fs.readFile(new URL('../policy/role-policy.json',import.meta.url));}catch(error){if(error.code!=='ENOENT')throw error;policy=await fs.readFile(new URL('./role-policy.json',import.meta.url));}
|
|
18
18
|
const runtime=await Promise.all(COOPERATIVE_RUNTIME_MODULES.map(file=>fs.readFile(new URL(file,import.meta.url))));
|
|
19
|
-
return {policy:'1',runtime:'cooperative-
|
|
19
|
+
return {policy:'1',runtime:'cooperative-6',policyHash:hash(policy),runtimeHash:hash(Buffer.concat(runtime))};
|
|
20
20
|
}
|
|
21
21
|
export async function initializeCooperativeWorkflow({cwd,workflowId,input,observe=observeCooperativeTarget,storage={}}){
|
|
22
22
|
validateWorkflowId(workflowId);validateCooperativeCommand({command:'init',input});
|
|
@@ -2,6 +2,8 @@ import {ROLES} from './operations.mjs';
|
|
|
2
2
|
import {assertSecretFree} from './external.mjs';
|
|
3
3
|
import {object,text,validatePlannerLedger} from './schema.mjs';
|
|
4
4
|
import {absolute,validateWorkflowId} from './scope.mjs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {validateTargetPreparationRecord} from './target-preparation.mjs';
|
|
5
7
|
const fail=message=>{throw Error('Cooperative schema: '+message);};
|
|
6
8
|
const hash=value=>typeof value==='string'&&/^sha256:[a-f0-9]{64}$/.test(value);
|
|
7
9
|
const revision=value=>Number.isSafeInteger(value)&&value>=0;
|
|
@@ -9,6 +11,24 @@ const actor=value=>object(value)&&text(value.id)&&Object.keys(value).every(k=>['
|
|
|
9
11
|
const statement=value=>object(value)&&text(value.messageRef)&&object(value.data);
|
|
10
12
|
function fields(value,allowed){if(!object(value)||Object.keys(value).some(k=>!allowed.includes(k)))fail('unexpected input field');}
|
|
11
13
|
function json(value){try{const encoded=JSON.stringify(value);if(encoded===undefined)fail('JSON input');}catch{fail('JSON input');}}
|
|
14
|
+
const exact=(value,keys)=>object(value)&&Object.keys(value).length===keys.length&&keys.every(key=>Object.hasOwn(value,key));
|
|
15
|
+
const oid=value=>typeof value==='string'&&/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(value);
|
|
16
|
+
const time=value=>typeof value==='string'&&Number.isFinite(Date.parse(value))&&/(?:Z|[+-]\d\d:\d\d)$/.test(value);
|
|
17
|
+
const unique=value=>Array.isArray(value)&&new Set(value).size===value.length;
|
|
18
|
+
const gitPath=value=>text(value)&&!/[\\\x00\r\n:]/.test(value)&&!value.startsWith('/')&&!value.split('/').some(part=>!part||part==='.'||part==='..');
|
|
19
|
+
const ref=value=>text(value)&&/^refs\/[A-Za-z0-9][A-Za-z0-9._\/-]*$/.test(value)&&!value.includes('..')&&!value.includes('//')&&!value.endsWith('/')&&!value.endsWith('.')&&!value.endsWith('.lock');
|
|
20
|
+
const approval=value=>exact(value,['ref','version','hash','approvedAt'])&&text(value.ref)&&Number.isSafeInteger(value.version)&&value.version>0&&hash(value.hash)&&time(value.approvedAt);
|
|
21
|
+
const document=value=>exact(value,['version','hash','content'])&&Number.isSafeInteger(value.version)&&value.version>0&&hash(value.hash)&&typeof value.content==='string'&&Buffer.byteLength(value.content)<=1024*1024;
|
|
22
|
+
export function validatePlanAmendArguments(a){
|
|
23
|
+
if(!exact(a,['classification','reason','changedAt','affectedTaskIds','plan','history','approvals','writers','ownership','publication','remotes','recovery'])||!['contract','mechanical'].includes(a.classification)||!text(a.reason)||!time(a.changedAt)||!unique(a.affectedTaskIds)||!a.affectedTaskIds.length||!a.affectedTaskIds.every(text))fail('plan-amend request');
|
|
24
|
+
if(!exact(a.plan,['path','gitPath','old','new'])||!absolute(a.plan.path)||!gitPath(a.plan.gitPath)||!document(a.plan.old)||!document(a.plan.new)||a.plan.new.version<=a.plan.old.version)fail('plan-amend document');
|
|
25
|
+
if(!exact(a.history,['base','planCommit','head','branch'])||![a.history.base,a.history.planCommit,a.history.head].every(oid)||!text(a.history.branch)||/[\x00\r\n]/.test(a.history.branch))fail('plan-amend history');
|
|
26
|
+
if(!exact(a.approvals,['original','amendment'])||!approval(a.approvals.original)||!(a.classification==='mechanical'&&a.approvals.amendment===null||approval(a.approvals.amendment)))fail('plan-amend approvals');
|
|
27
|
+
if(!Array.isArray(a.writers)||!a.writers.length||a.writers.some(w=>!exact(w,['assignmentId','stoppedAt','evidenceRef'])||!text(w.assignmentId)||!time(w.stoppedAt)||!text(w.evidenceRef))||!unique(a.writers.map(w=>w.assignmentId)))fail('plan-amend writers');
|
|
28
|
+
if(!['exclusive','shared','unknown'].includes(a.ownership)||!['unpublished','published','unknown'].includes(a.publication)||!Array.isArray(a.remotes)||a.remotes.some(r=>!exact(r,['name','identity','complete','refs','observedAt','evidenceRef'])||!text(r.name)||!hash(r.identity)||r.complete!==true||!time(r.observedAt)||!text(r.evidenceRef)||!Array.isArray(r.refs)||r.refs.some(x=>!exact(x,['name','oid'])||!ref(x.name)||!oid(x.oid))||!unique(r.refs.map(x=>x.name)))||!unique(a.remotes.map(r=>r.name)))fail('plan-amend remote snapshot');
|
|
29
|
+
if(!exact(a.recovery,['ref','oid'])||!ref(a.recovery.ref)||!a.recovery.ref.startsWith('refs/arc/recovery/')||!oid(a.recovery.oid)||path.normalize(a.plan.path)!==a.plan.path)fail('plan-amend recovery');
|
|
30
|
+
return a;
|
|
31
|
+
}
|
|
12
32
|
export function validateCooperativeCommand(command){
|
|
13
33
|
assertSecretFree(command);fields(command,['command','input']);const {input,command:name}=command;
|
|
14
34
|
if(!['init','record','status','reconcile','prepare','result'].includes(name))fail('command');
|
|
@@ -25,7 +45,7 @@ export function validateCooperativeCommand(command){
|
|
|
25
45
|
if(name==='record'){
|
|
26
46
|
fields(input.evidence,['kind','messageRef','data']);
|
|
27
47
|
if(input.evidence?.data?.affectedTaskIds!==undefined&&(!Array.isArray(input.evidence.data.affectedTaskIds)||!input.evidence.data.affectedTaskIds.every(text)||new Set(input.evidence.data.affectedTaskIds).size!==input.evidence.data.affectedTaskIds.length))fail('affected task IDs');
|
|
28
|
-
if(!statement(input.evidence)||!['note','approval','external-approval','document','scope','check','finding','review','acceptance-evidence','planner-stage','planner-evidence','planner-result','planner-review'].includes(input.evidence.kind))fail('evidence');
|
|
48
|
+
if(!statement(input.evidence)||!['note','approval','external-approval','document','scope','check','finding','review','acceptance-evidence','planner-stage','planner-evidence','planner-result','planner-review','target-preparation'].includes(input.evidence.kind))fail('evidence');
|
|
29
49
|
}
|
|
30
50
|
if(resultStatement){
|
|
31
51
|
fields(input.result,['status','messageRef','data','notExecutedEvidence']);
|
|
@@ -33,6 +53,7 @@ export function validateCooperativeCommand(command){
|
|
|
33
53
|
if(input.result.status==='cancelled'&&(!object(input.result.notExecutedEvidence)||!text(input.result.notExecutedEvidence.messageRef)))fail('cancel requires not-executed evidence');
|
|
34
54
|
}
|
|
35
55
|
if((name==='prepare'||name==='result'&&!resultStatement)&&!text(input.operation))fail('operation');
|
|
56
|
+
if(name==='prepare'&&input.operation==='plan-amend')validatePlanAmendArguments(input.arguments);
|
|
36
57
|
return command;
|
|
37
58
|
}
|
|
38
59
|
export function validateCooperativeState(state){
|
|
@@ -44,13 +65,23 @@ export function validateCooperativeState(state){
|
|
|
44
65
|
for(const key of ['actors','selections','assignments','identities','leases','scopes','approvals','documents','tasks','requests','intents','results','checks','findings','acceptances','commits','audit','unresolved','records','targetHistory'])if(!Array.isArray(state[key]))fail(key);
|
|
45
66
|
if(state.tasks.some(t=>!object(t)||!text(t.id)||!Array.isArray(t.paths)||!Array.isArray(t.criteria)||!Array.isArray(t.requiredChecks)||!Array.isArray(t.dependencies))||new Set(state.tasks.map(t=>t.id)).size!==state.tasks.length)fail('task contracts');
|
|
46
67
|
if(state.commitObservations!==undefined&&(!Array.isArray(state.commitObservations)||state.commitObservations.some(o=>!object(o)||o.source!=='local-git'||!text(o.intentId)||!revision(o.revision))))fail('commit observations');
|
|
68
|
+
if(state.planAmendObservations!==undefined&&(!Array.isArray(state.planAmendObservations)||state.planAmendObservations.some(o=>!object(o)||o.source!=='local-git'||!text(o.intentId)||!revision(o.revision))))fail('plan-amend observations');
|
|
69
|
+
if(state.planAmendments!==undefined&&(!Array.isArray(state.planAmendments)||state.planAmendments.some(a=>!object(a)||a.source!=='operator-attested'||a.observationSource!=='local-git'||!text(a.intentId)||!absolute(a.path)||!hash(a.oldHash)||!hash(a.newHash)||!oid(a.oldCommit)||!oid(a.newCommit)||!Array.isArray(a.mapping)||!a.mapping.length)))fail('plan-amend connections');
|
|
47
70
|
if(!revision(state.scopeVersion)||!revision(state.targetVersion))fail('scope/target version');
|
|
48
71
|
if(state.actors.some(a=>!actor(a.actor)||a.source!=='operator-attested')||state.selections.some(s=>s.source!=='operator-attested'||!text(s.messageRef)))fail('attestations');
|
|
49
72
|
for(const key of ['scopes','approvals','documents','checks','findings','acceptances','commits'])if(state[key].some(entry=>!object(entry)||entry.source!=='operator-attested'))fail('attestation source');
|
|
50
73
|
if(state.records.some(r=>!actor(r.actor)||r.source!=='operator-attested'||!text(r.kind)||!statement(r)))fail('records');
|
|
51
74
|
if(state.requests.some(r=>!text(r.requestId)||!hash(r.requestFingerprint)||!object(r.decision))||new Set(state.requests.map(r=>r.requestId)).size!==state.requests.length)fail('request replay');
|
|
52
75
|
if(state.intents.some(i=>!text(i.requestId)||!['prepared','succeeded','failed','unknown','mismatch','cancelled'].includes(i.status)||!hash(i.fingerprint))||new Set(state.intents.map(i=>i.requestId)).size!==state.intents.length)fail('intents');
|
|
76
|
+
for(const intent of state.intents.filter(i=>i.operation==='plan-amend')){validatePlanAmendArguments(intent.arguments);if(!object(intent.target)||!object(intent.versions)||!object(intent.observation)||intent.source!=='operator-attested'||intent.checkpoint!==undefined&&!object(intent.checkpoint))fail('plan-amend intent');}
|
|
53
77
|
if(state.results.some(r=>!text(r.requestId)||!['succeeded','failed','unknown','mismatch','cancelled'].includes(r.status)||r.source!=='operator-attested'||!object(r.data)))fail('results');
|
|
54
78
|
if(state.plannerLedger!==undefined){validatePlannerLedger(state.plannerLedger);if(state.plannerLedger.stages.some(stage=>stage.workflowId!==state.workflowId||!Array.isArray(stage.artifacts)))fail('Planner workflow binding or artifacts');}
|
|
79
|
+
for(const key of ['targetIntents','targetCheckpoints','targetTransitions','targetDocuments'])if(state[key]!==undefined&&!Array.isArray(state[key]))fail(key);
|
|
80
|
+
const preparationIntents=state.targetIntents??[],checkpoints=state.targetCheckpoints??[],transitions=state.targetTransitions??[],documents=state.targetDocuments??[];
|
|
81
|
+
if(new Set(preparationIntents.map(i=>i.id)).size!==preparationIntents.length)fail('target intent identity');
|
|
82
|
+
for(const intent of preparationIntents){try{validateTargetPreparationRecord('intent',intent);}catch{fail('target intent');}const approved=state.records.find(r=>r.kind==='approval'&&r.messageRef===intent.approvalRef&&r.source==='operator-attested'&&r.actor?.role==='orchestrator'&&r.scopeVersion===intent.scopeVersion&&r.targetVersion===intent.sourceTargetVersion)?.data?.targetPreparation;if(intent.source!=='operator-attested'||intent.workflowId!==state.workflowId||!revision(intent.scopeVersion)||!hash(intent.sourceFingerprint)||!object(intent.sourceSnapshot)||!approved||['depth','selectionRef','kind','candidate','base','workflowId','firstStageId','sourceTargetVersion'].some(k=>approved[k]!==intent[k])||JSON.stringify(approved.sourceTarget)!==JSON.stringify(intent.sourceTarget)||JSON.stringify(approved.documents)!==JSON.stringify(intent.documents))fail('target intent provenance');}
|
|
83
|
+
for(const checkpoint of checkpoints){try{validateTargetPreparationRecord('checkpoint',{type:'checkpoint',...checkpoint});}catch{fail('target checkpoint');}if(checkpoint.source!=='operator-attested'||!text(checkpoint.messageRef)||!preparationIntents.some(i=>i.id===checkpoint.intentId&&i.firstStageId===checkpoint.stageId)||!state.records.some(r=>r.kind==='target-preparation'&&r.messageRef===checkpoint.messageRef&&r.source==='operator-attested'))fail('target checkpoint provenance');}
|
|
84
|
+
for(const transition of transitions){const request=transition.validation?.request;try{validateTargetPreparationRecord('transition',request);}catch{fail('target transition');}if(!object(transition.target)||!text(transition.messageRef)||!Number.isSafeInteger(transition.targetVersion)||transition.targetVersion!==transition.sourceTargetVersion+1||request.intentId!==transition.intentId||request.checkpointRef!==transition.checkpointRef||!preparationIntents.some(i=>i.id===transition.intentId)||!checkpoints.some(c=>c.intentId===transition.intentId&&c.messageRef===transition.checkpointRef)||!state.records.some(r=>r.kind==='target-preparation'&&r.messageRef===transition.messageRef&&r.source==='operator-attested'))fail('target transition provenance');}
|
|
85
|
+
for(const document of documents){try{validateTargetPreparationRecord('destination',document);}catch{fail('target document');}if(document.sourceLink!=='operator-attested'||document.verification?.status!=='verified'||document.verification?.source!=='local-bytes'||!text(document.messageRef)||!transitions.some(t=>t.intentId===document.intentId&&t.messageRef===document.transitionRef&&t.targetVersion===document.targetVersion)||!state.records.some(r=>r.kind==='target-preparation'&&r.messageRef===document.messageRef&&r.source==='operator-attested'))fail('target document provenance');}
|
|
55
86
|
assertSecretFree(state);json(state);return state;
|
|
56
87
|
}
|