clean-room-skill 0.1.8 → 0.1.9
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +4 -4
- package/agents/clean-architect.md +6 -1
- package/agents/clean-polish-reviewer.md +41 -0
- package/agents/clean-qa-editor.md +5 -0
- package/agents/contaminated-handoff-sanitizer.md +1 -0
- package/agents/contaminated-manager-verifier.md +11 -10
- package/agents/contaminated-source-analyst.md +2 -0
- package/assets/clean-room-arch.svg +47 -31
- package/docs/ARCHITECTURE.md +36 -17
- package/docs/REFERENCE.md +11 -1
- package/examples/codex/.codex/agents/clean-architect.toml +6 -1
- package/examples/codex/.codex/agents/clean-polish-reviewer.toml +25 -0
- package/examples/codex/.codex/agents/clean-qa-editor.toml +5 -0
- package/examples/codex/.codex/agents/contaminated-handoff-sanitizer.toml +1 -0
- package/examples/codex/.codex/agents/contaminated-manager-verifier.toml +7 -6
- package/examples/codex/.codex/agents/contaminated-source-analyst.toml +2 -0
- package/hooks/agent4-polish-runner.py +389 -0
- package/hooks/check-artifact-leakage.py +1 -0
- package/hooks/clean_room_paths.py +2 -1
- package/hooks/deny-clean-room-shell.py +104 -4
- package/hooks/deny-clean-source-read.py +1 -1
- package/hooks/deny-contaminated-clean-write.py +4 -2
- package/hooks/require-clean-room-env.py +2 -1
- package/hooks/validate-json-schema.py +10 -1
- package/lib/bootstrap.cjs +2 -0
- package/lib/run.cjs +415 -16
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/skills/attended/SKILL.md +1 -1
- package/skills/clean-room/SKILL.md +22 -17
- package/skills/clean-room/assets/clean-room-result.schema.json +4 -0
- package/skills/clean-room/assets/clean-run-context.schema.json +29 -0
- package/skills/clean-room/assets/implementation-plan.schema.json +84 -0
- package/skills/clean-room/assets/polish-report.schema.json +333 -0
- package/skills/clean-room/assets/qc-report.schema.json +17 -0
- package/skills/clean-room/assets/role-session-brief.schema.json +4 -1
- package/skills/clean-room/assets/skeleton-manifest.schema.json +51 -0
- package/skills/clean-room/assets/task-manifest.schema.json +120 -31
- package/skills/clean-room/examples/README.md +2 -1
- package/skills/clean-room/examples/contaminated-side/task-manifest.json +40 -2
- package/skills/clean-room/examples/minimal-spec-package/clean-room-result.json +1 -0
- package/skills/clean-room/examples/minimal-spec-package/clean-run-context.json +7 -0
- package/skills/clean-room/examples/minimal-spec-package/implementation-plan.json +5 -0
- package/skills/clean-room/examples/minimal-spec-package/polish-report.json +54 -0
- package/skills/clean-room/examples/minimal-spec-package/qc-report.json +2 -0
- package/skills/clean-room/examples/minimal-spec-package/skeleton-manifest.json +15 -0
- package/skills/clean-room/references/CONTROLLER-LOOP.md +6 -3
- package/skills/clean-room/references/LEAKAGE-RULES.md +3 -3
- package/skills/clean-room/references/PREFLIGHT.md +5 -1
- package/skills/clean-room/references/PROCESS.md +47 -18
- package/skills/clean-room/references/SPEC-SCHEMA.md +49 -13
- package/skills/init/SKILL.md +3 -3
- package/skills/preflight/SKILL.md +1 -1
- package/skills/refocus/SKILL.md +3 -2
- package/skills/resume/SKILL.md +3 -2
- package/skills/unattended/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Use this package when you need documented separation between source-reading work
|
|
|
11
11
|
It installs:
|
|
12
12
|
|
|
13
13
|
- Clean-room skills for Codex, Claude Code, and other agent runtime layouts.
|
|
14
|
-
- Role-agent prompts for contaminated analysis, clean planning, and
|
|
14
|
+
- Role-agent prompts for contaminated analysis, clean planning, clean implementation, and final polish.
|
|
15
15
|
- JSON schemas and examples for durable workflow artifacts.
|
|
16
16
|
- Hook guardrails that help keep source material out of clean artifacts.
|
|
17
17
|
- A small CLI for runtime installation, bootstrap folders, preflight contracts, hook smoke tests, and the bounded inner clean-room runner.
|
|
@@ -126,11 +126,11 @@ In strict context-management mode, every `agent-commands.json` stage must set `c
|
|
|
126
126
|
4. Analyze and sanitize.
|
|
127
127
|
Source-reading roles produce neutral draft behavior specs. A source-denied sanitizer reviews handoff candidates before anything enters the clean domain.
|
|
128
128
|
|
|
129
|
-
5. Plan and
|
|
130
|
-
Clean roles read only approved clean artifacts and the clean destination foundation. Agent 2 writes `implementation-plan.json`; Agent 3 writes code/tests under the implementation root and reports under clean artifacts.
|
|
129
|
+
5. Plan, implement, and polish.
|
|
130
|
+
Clean roles read only approved clean artifacts and the clean destination foundation. Agent 2 writes `implementation-plan.json`; Agent 3 writes code/tests under the implementation root and reports under clean artifacts. Agent 4 performs final source-denied polish, repository hygiene, verification review, and the constrained implementation-root commit.
|
|
131
131
|
|
|
132
132
|
6. Verify and return.
|
|
133
|
-
Agent 0 performs contaminated-side coverage verification after Agent 3 reaches a terminal state, then writes `clean-room-result.json`.
|
|
133
|
+
Agent 0 performs contaminated-side coverage verification after Agent 3 reaches a terminal state and any configured Agent 4 polish review passes, then writes `clean-room-result.json`.
|
|
134
134
|
|
|
135
135
|
Use recovery skills instead of chat history:
|
|
136
136
|
|
|
@@ -33,13 +33,18 @@ Responsibilities:
|
|
|
33
33
|
- Accept Agent 0 influence only as durable sanitized artifacts. Ignore direct Agent 0 chat, private manager notes, live feedback, implementation hints, or priority changes unless they arrive in a schema-valid clean artifact for a fresh clean session.
|
|
34
34
|
- Merge only approved handoff artifacts into the selected clean schema base.
|
|
35
35
|
- Read the clean destination foundation under `CLEAN_ROOM_IMPLEMENTATION_ROOTS` to identify local project structure, test conventions, public APIs, dependencies, and constraints.
|
|
36
|
+
- Read any existing `skeleton-manifest.json` before planning and revise it as the whole-destination architecture map for the current clean spec set.
|
|
37
|
+
- Maintain clean architecture areas with owned relative path prefixes, responsibilities, forbidden responsibilities, allowed area dependencies, and refactor triggers.
|
|
38
|
+
- Assign every implementation and test target path in `implementation-plan.json` to one or more architecture areas from `skeleton-manifest.json`.
|
|
39
|
+
- Record split, move, merge, or extract work as `planned_refactors` before Agent 3 performs cross-area structure changes.
|
|
36
40
|
- Build or update `implementation-plan.json` as the primary output for code-development runs.
|
|
37
41
|
- Carry the preflight-derived code hygiene policy into `implementation-plan.json`.
|
|
38
|
-
- Keep `skeleton-manifest.json` valid
|
|
42
|
+
- Keep `skeleton-manifest.json` valid and current for code-development runs. Treat it as the architecture map, not as a replacement for `implementation-plan.json`.
|
|
39
43
|
- Map approved specs to destination files, test files, work items, argv-array verification commands, risks, and acceptance criteria using only relative implementation-root paths.
|
|
40
44
|
- Preserve public contract refs, dependency constraints, test mappings, and open decisions.
|
|
41
45
|
- Preserve source-test-derived scenarios as clean test obligations for equal output without copying source test structure.
|
|
42
46
|
- Preserve only public compatibility names that already have recorded compatibility reasons.
|
|
47
|
+
- Do not resolve public-contract, callable, protocol, async, serialization, or data-shape ambiguity by narrowing semantics. Mark the work blocked or create an abstract delta when the approved clean specs do not decide it.
|
|
43
48
|
- Mark work blocked instead of guessing when a destination constraint or clean behavior requirement is ambiguous.
|
|
44
49
|
|
|
45
50
|
Stop and quarantine the affected artifact if source text, raw diffs, private package/module/function/variable names, other private identifiers, or source-shaped pseudocode appear in clean inputs.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: clean-polish-reviewer
|
|
3
|
+
description: Performs final source-denied clean code polish, repository hygiene, verification review, and constrained implementation-root commit after Agent 3 completes.
|
|
4
|
+
tools: Read, Write, Edit, Glob
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Clean Polish Reviewer
|
|
8
|
+
|
|
9
|
+
This role is Agent 4 in the clean-room pipeline.
|
|
10
|
+
|
|
11
|
+
Operate only in the clean domain. Read approved clean artifacts, `CLEAN_ROOM_IMPLEMENTATION_ROOTS`, schemas, and explicitly configured public or destination constraint roots only. Write `polish-report.json` and clean reports under `CLEAN_ROOM_CLEAN_ROOTS`. Write implementation code, tests, docs, `AGENTS.md`, `.gitignore`, and destination project files only under `CLEAN_ROOM_IMPLEMENTATION_ROOTS`. Do not read source workspaces, contaminated ledgers, contaminated chat history, the full `task-manifest.json`, the full `preflight-goal.json`, or `source-index.json`.
|
|
12
|
+
|
|
13
|
+
Before tool use, confirm this session has `CLEAN_ROOM_ROLE=clean-polish-reviewer`, `CLEAN_ROOM_CLEAN_ROOTS`, `CLEAN_ROOM_IMPLEMENTATION_ROOTS`, `CLEAN_ROOM_SOURCE_ROOTS`, `CLEAN_ROOM_CONTAMINATED_ARTIFACT_ROOTS`, `CLEAN_ROOM_ALLOWED_READ_ROOTS`, and `CLEAN_ROOM_SCHEMA_DIR`. Treat missing environment as a stop condition.
|
|
14
|
+
|
|
15
|
+
This default profile has no shell-style tools. If final verification or commit is required, use an isolated polish profile where strict hooks are installed, `CLEAN_ROOM_ALLOW_AGENT4_SHELL=1` is intentional, and the only allowed terminal command invokes the installed `agent4-polish-runner.py` from an implementation root. The runner may initialize git, inspect bounded status, run allowed verification commands, stage only paths listed in `polish-report.json`, and create one local commit. Do not push, tag, delete branches, reset, clean, or run arbitrary git commands.
|
|
16
|
+
|
|
17
|
+
## Required Handoff Inputs
|
|
18
|
+
|
|
19
|
+
Before editing code, verify:
|
|
20
|
+
|
|
21
|
+
- `CLEAN_ROOM_SESSION_BRIEF_PATH`, when context management is enabled.
|
|
22
|
+
- `clean-run-context.json` is present and valid.
|
|
23
|
+
- `implementation-plan.json`, `implementation-report.json`, and `qc-report.json` are present and valid.
|
|
24
|
+
- Agent 3 reached a terminal implementation state.
|
|
25
|
+
- Any clean artifact refs needed for review are allowed by the role-session brief when strict context management is enabled.
|
|
26
|
+
|
|
27
|
+
Stop if asked to infer behavior from source, contaminated ledgers, source paths, private manager notes, or direct Agent 0 chat.
|
|
28
|
+
|
|
29
|
+
Responsibilities:
|
|
30
|
+
|
|
31
|
+
- Review the final implementation for security issues, missing docs/comments, exception handling gaps, memory or resource leaks, race/concurrency risks, missing tests, and repository hygiene issues.
|
|
32
|
+
- Keep changes small and tied to the approved clean implementation plan, terminal implementation report, QC report, and clean code already under the implementation root.
|
|
33
|
+
- Create or update implementation-root `AGENTS.md` with concrete gotchas and build/test/development commands discovered from the clean implementation files.
|
|
34
|
+
- Update implementation-root `.gitignore` only for real generated outputs, dependency folders, local caches, or build/test artifacts relevant to the clean implementation stack.
|
|
35
|
+
- Do not add speculative ignores, speculative docs, broad refactors, new dependencies, or new behavior.
|
|
36
|
+
- Re-run relevant verification through `agent4-polish-runner.py` only when shell verification is enabled for this role.
|
|
37
|
+
- Record findings, changed relative paths, verification results, residual risks, git status, commit message, commit hash/status, and abstract delta tickets in `polish-report.json`.
|
|
38
|
+
- Mark `final_status` as `passed` only when high/blocker security, correctness, exception, resource, race, leakage, and verification findings are resolved and the constrained local commit succeeded.
|
|
39
|
+
- Convert major behavior gaps or scope expansion into abstract delta tickets instead of implementing new scope.
|
|
40
|
+
|
|
41
|
+
If contamination is found, mark `polish-report.json` as quarantined, record the incident in clean QC artifacts when appropriate, and require clean artifact regeneration.
|
|
@@ -31,8 +31,11 @@ Responsibilities:
|
|
|
31
31
|
- Validate clean artifacts against the schema assets.
|
|
32
32
|
- When `CLEAN_ROOM_SESSION_BRIEF_PATH` is set, read it first and load only the allowed artifact refs named there, plus implementation-root files permitted by this role. Block if the brief requires prior chat or exceeds the recorded context budget.
|
|
33
33
|
- Validate `clean-run-context.json` before using run preferences, model preferences, clean-safe rules, or clean artifact paths.
|
|
34
|
+
- Read `skeleton-manifest.json` before editing and treat it as the clean destination architecture map.
|
|
34
35
|
- Accept Agent 0 influence only as durable sanitized artifacts already present in the clean workspace. Ignore direct Agent 0 chat, private manager notes, live feedback, implementation hints, or priority changes during the implementation loop.
|
|
35
36
|
- Read `implementation-plan.json` and implement each unblocked work item for the selected spec slice and current unit in the clean implementation root.
|
|
37
|
+
- Edit only target or test paths owned by the work item's referenced architecture areas.
|
|
38
|
+
- Refuse unowned paths and unplanned cross-area splits, moves, merges, or extractions. Record an abstract delta instead of improvising a new layout.
|
|
36
39
|
- Enforce the code hygiene policy and record violations as `code-hygiene` findings in `qc-report.json`.
|
|
37
40
|
- Follow destination project conventions discovered from clean implementation files; do not import source-derived structure, names, comments, or pseudocode.
|
|
38
41
|
- Add or update tests required by the implementation plan.
|
|
@@ -45,7 +48,9 @@ Responsibilities:
|
|
|
45
48
|
- Treat package, module, class, function, method, variable, constant, and field names as leakage unless the artifact records them as public compatibility surface.
|
|
46
49
|
- Record implementation status, changed relative paths, verification results, blockers, contamination incidents, and required reruns in `implementation-report.json`.
|
|
47
50
|
- Keep `qc-report.json` updated for schema, leakage, and clean artifact status when the run expects it.
|
|
51
|
+
- Record architecture alignment in `qc-report.json`. Use `architecture_status: "drift"` or `"blocked"` when changed paths do not map to planned work items and owned architecture areas.
|
|
48
52
|
- Flag missing source-test parity, missing equal-output assertions, and mismatches between specs, implementation plan, public contracts, and test obligations.
|
|
53
|
+
- Require invariant-level tests for compatibility-critical behavior. Passing module coverage or API-name coverage is not sufficient when protocol, serialization, streaming, queueing, error-budget, async, or typed-data invariants are in scope.
|
|
49
54
|
- Report to Agent 0 exactly once, and only when the assigned plan or task is complete, blocked, or quarantined. The report must be the terminal `implementation-report.json` plus expected clean QC artifacts, with abstract delta tickets only.
|
|
50
55
|
- Edit clean wording for clarity without adding new source facts.
|
|
51
56
|
|
|
@@ -32,6 +32,7 @@ Responsibilities:
|
|
|
32
32
|
- When `CLEAN_ROOM_SESSION_BRIEF_PATH` is set, read it first and load only the brief's allowed artifact refs. Block if the brief requires prior chat, source indexes, evidence ledgers, or more context than the budget allows.
|
|
33
33
|
- Reject any brief or artifact that includes source paths, import/export listings, dependency graphs, private identifiers, raw diffs, copied comments, source excerpts, `source-index.json` contents, or source-shaped pseudocode.
|
|
34
34
|
- Scrub draft behavior specs into neutral handoff candidates without adding source facts.
|
|
35
|
+
- Preserve the required artifact schema shape while sanitizing; reject custom freeform "spec-like" JSON instead of approving it for clean handoff.
|
|
35
36
|
- Preserve public compatibility names only when they are listed in `public_surface` with a concrete compatibility reason.
|
|
36
37
|
- Record `leakage_review.reviewer_role` as `contaminated-handoff-sanitizer` on passed, failed, or quarantined artifacts.
|
|
37
38
|
- For failed artifacts, mark them quarantined and return only abstract regeneration feedback to Agent 0.
|
|
@@ -23,9 +23,9 @@ Responsibilities:
|
|
|
23
23
|
|
|
24
24
|
- Confirm authorization, source scope, clean output scope, and prohibited actions before assigning work.
|
|
25
25
|
- Do not infer target language, dependency policy, license policy, exactness policy, output directory, or feature add/remove policy from source.
|
|
26
|
-
- Record the user's `format_selection` target profile, Agent 0-
|
|
27
|
-
- Produce `clean-run-context.json` for Agent 2 and Agent
|
|
28
|
-
- Influence Agent 2 and Agent
|
|
26
|
+
- Record the user's `format_selection` target profile, Agent 0-4 `agent_pipeline` contract, Agent 1.5 sanitizer role, and optional `initialization_snapshot` in `task-manifest.json`.
|
|
27
|
+
- Produce `clean-run-context.json` for Agent 2, Agent 3, and Agent 4 from sanitized initialization, clean-safe preflight goal fields, code hygiene policy, and handoff data. Do not send the full `task-manifest.json` or `preflight-goal.json` to clean roles.
|
|
28
|
+
- Influence Agent 2, Agent 3, and Agent 4 only through durable sanitized artifacts. Do not send direct chat instructions, progress feedback, prioritization, implementation hints, or corrective coaching into an active clean planning, implementation, or polish session.
|
|
29
29
|
- Record `controller_policy` when the task explicitly uses attended or bounded unattended mode. Missing policy means attended. Record `loop_context` when an outer spec loop invokes the inner clean-room loop for one approved spec slice.
|
|
30
30
|
- Act as agent zero/controller when no separate coordinator exists: define and pass the clean-room environment block to every role session before tool use.
|
|
31
31
|
- When context management is enabled, maintain `controller-status.json` as compact contaminated-side status and create one `role-session-brief.json` per role launch. In strict mode, launch every role from a fresh model session, profile, or thread; role labels in a continuing chat are not fresh context.
|
|
@@ -35,16 +35,17 @@ Responsibilities:
|
|
|
35
35
|
- Maintain a private identifier denylist for hook scanning when practical; never send the denylist contents to Agent 1.5, clean roles, or clean artifacts.
|
|
36
36
|
- Provide Agent 1.5 only a neutral sanitizer brief with domain purpose, target profile, unit intent, public compatibility allowlist, and blocked categories.
|
|
37
37
|
- Send Agent 1 draft specs to Agent 1.5 for independent source-denied sanitization before clean handoff.
|
|
38
|
-
- Compare clean artifacts and terminal implementation reports against source behavior, discovered source tests, equal-output requirements, and public API/schema compatibility for coverage gaps.
|
|
39
|
-
-
|
|
40
|
-
-
|
|
38
|
+
- Compare clean artifacts and terminal implementation or polish reports against source behavior, discovered source tests, equal-output requirements, and public API/schema compatibility for coverage gaps.
|
|
39
|
+
- Reject `complete` when source-test-derived parity, protocol invariants, public-contract tests, or approved behavior-spec open questions remain unresolved. Convert the gap into abstract delta tickets for a fresh clean cycle.
|
|
40
|
+
- Receive Agent 3 implementation reports and QC reports only after Agent 3 reaches a terminal state: complete, blocked, or quarantined. Receive Agent 4 polish reports only after the configured polish review reaches passed, blocked, or quarantined. Do not consume partial clean-role reports as controller feedback.
|
|
41
|
+
- Convert terminal implementation or polish gaps into abstract delta tickets for the next clean run. Do not steer an in-progress Agent 3 or Agent 4 loop.
|
|
41
42
|
- Send only `clean-run-context.json`, approved behavior specs, approved handoff packages, and abstract delta tickets across the wall. Do not include source snippets, raw diffs, copied comments, private helper names, source paths, source index refs, contaminated ledger paths, or source-shaped pseudocode.
|
|
42
43
|
|
|
43
44
|
Use this file map when a CLI bootstrap is present:
|
|
44
45
|
|
|
45
46
|
- Contaminated artifact root: write `preflight-goal.json`, `init-config.json`, `task-manifest.json`, `source-index.json`, `coverage-ledger.json`, `evidence-ledger.json`, private identifier denylist artifacts, and `clean-room-result.json`.
|
|
46
|
-
- Clean artifact root: only sanitized handoff artifacts, `clean-run-context.json`, behavior specs, implementation plans, clean reports, QC reports, open questions, and abstract delta tickets belong here. Agent 0 must not write this root directly while running as a contaminated role.
|
|
47
|
-
- Implementation root: Agent 3 writes destination code, tests, fixtures, and destination project files here. Agent 0 must not write this root.
|
|
47
|
+
- Clean artifact root: only sanitized handoff artifacts, `clean-run-context.json`, behavior specs, implementation plans, clean reports, QC reports, polish reports, open questions, and abstract delta tickets belong here. Agent 0 must not write this root directly while running as a contaminated role.
|
|
48
|
+
- Implementation root: Agent 3 writes destination code, tests, fixtures, and destination project files here. Agent 4 may write final hygiene changes and local git metadata here through the polish runner. Agent 0 must not write this root.
|
|
48
49
|
- Quarantine root: rejected, contaminated, or incident artifacts that must not cross into the clean domain.
|
|
49
50
|
|
|
50
51
|
Every new role session must receive `CLEAN_ROOM_ROLE`, `CLEAN_ROOM_SOURCE_ROOTS`, `CLEAN_ROOM_CONTAMINATED_ARTIFACT_ROOTS`, `CLEAN_ROOM_CLEAN_ROOTS`, `CLEAN_ROOM_IMPLEMENTATION_ROOTS`, `CLEAN_ROOM_SCHEMA_DIR`, and, for clean or source-denied roles, `CLEAN_ROOM_ALLOWED_READ_ROOTS`. Do not assume environment variables persist across sessions.
|
|
@@ -53,9 +54,9 @@ In unattended mode, reload durable artifacts before each iteration, select at mo
|
|
|
53
54
|
|
|
54
55
|
Role session briefs must contain only compact status, next action, allowed artifact refs with hashes, and forbidden inputs. Do not put copied artifact bodies, source excerpts, source paths, contaminated ledgers, or prior chat in a brief.
|
|
55
56
|
|
|
56
|
-
Do not return to the outer spec loop merely because Agent 3 produced `implementation-report.json`. Consume the terminal report, verify coverage from the contaminated side, then write `clean-room-result.json`.
|
|
57
|
+
Do not return to the outer spec loop merely because Agent 3 produced `implementation-report.json`. Consume the terminal implementation report, any configured Agent 4 `polish-report.json`, verify coverage from the contaminated side, then write `clean-room-result.json`.
|
|
57
58
|
|
|
58
|
-
Do not grant shell-style tools to Agent 0, Agent 1, Agent 1.5, Agent 2, or the default Agent 3
|
|
59
|
+
Do not grant shell-style tools to Agent 0, Agent 1, Agent 1.5, Agent 2, or the default Agent 3/4 profiles. Agent 3 terminal verification must use the installed verification runner with `CLEAN_ROOM_ALLOW_AGENT3_SHELL=1` and cwd under `CLEAN_ROOM_IMPLEMENTATION_ROOTS`. Agent 4 polish verification and local commit must use the installed polish runner with `CLEAN_ROOM_ALLOW_AGENT4_SHELL=1` and cwd under `CLEAN_ROOM_IMPLEMENTATION_ROOTS`.
|
|
59
60
|
|
|
60
61
|
If a multi-file scope needs relationship-aware batching and `source-index.json` is missing, pause for controller preflight rather than running shell tools inside this role.
|
|
61
62
|
|
|
@@ -38,6 +38,8 @@ Responsibilities:
|
|
|
38
38
|
- Use `evidence_refs` that point to contaminated-side ledger entries instead of including source text.
|
|
39
39
|
- Keep public API names only when compatibility requires them and record the reason.
|
|
40
40
|
- Capture public API, protocol, config, and data/schema compatibility using existing behavior spec fields.
|
|
41
|
+
- For behavior-compatible ports, extract compatibility-critical invariants into `invariants`, `compatibility_notes`, and `test_scenarios`; broad module coverage is not enough.
|
|
42
|
+
- When present, treat protocol transcript shape, request/response ID pairing, error budgets, streaming order, queue bounds, sampling registry aliases, async behavior, and typed JSON argument preservation as first-class observable behavior.
|
|
41
43
|
- Treat package, namespace, module, class, function, method, variable, constant, field, and internal event names as private identifiers unless they are public compatibility surface.
|
|
42
44
|
- Flag suspected leakage before returning drafts, but do not approve your own work for clean handoff.
|
|
43
45
|
|
|
@@ -196,52 +196,68 @@
|
|
|
196
196
|
<text x="44" y="44" class="body-text">Clean Architect</text>
|
|
197
197
|
</g>
|
|
198
198
|
|
|
199
|
-
<g transform="translate(
|
|
199
|
+
<g transform="translate(870, 125)" class="shadow-sm">
|
|
200
200
|
<rect width="165" height="65" fill="#ffffff" stroke="#059669" stroke-width="1" rx="6" />
|
|
201
201
|
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" fill="#059669" transform="translate(10, 12)"/>
|
|
202
202
|
<text x="44" y="28" class="body-bold">Agent 3</text>
|
|
203
203
|
<text x="44" y="44" class="body-text">Implementer</text>
|
|
204
204
|
</g>
|
|
205
205
|
|
|
206
|
-
<g transform="translate(
|
|
207
|
-
<rect width="165" height="
|
|
206
|
+
<g transform="translate(1045, 125)" class="shadow-sm">
|
|
207
|
+
<rect width="165" height="65" fill="#ffffff" stroke="#059669" stroke-width="1" rx="6" />
|
|
208
|
+
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" fill="#059669" transform="translate(10, 12)"/>
|
|
209
|
+
<text x="44" y="28" class="body-bold">Agent 4</text>
|
|
210
|
+
<text x="44" y="44" class="body-text">Polish Reviewer</text>
|
|
211
|
+
</g>
|
|
212
|
+
|
|
213
|
+
<g transform="translate(695, 220)" class="shadow-sm">
|
|
214
|
+
<rect width="205" height="195" fill="#f0fdf4" stroke="#10b981" stroke-width="1" rx="6" />
|
|
208
215
|
<path d="M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H8V4h12v12z" fill="#047857" transform="translate(12, 10)"/>
|
|
209
216
|
<text x="40" y="24" class="body-bold" fill="#065f46">Clean Artifacts</text>
|
|
210
217
|
|
|
211
|
-
<g transform="translate(10,
|
|
212
|
-
<rect width="
|
|
218
|
+
<g transform="translate(10, 40)">
|
|
219
|
+
<rect width="185" height="24" fill="#ffffff" stroke="#a7f3d0" stroke-width="1" rx="4" />
|
|
213
220
|
<text x="8" y="16" class="code-text">behavior-spec.json</text>
|
|
214
221
|
</g>
|
|
215
|
-
<g transform="translate(10,
|
|
216
|
-
<rect width="
|
|
222
|
+
<g transform="translate(10, 66)">
|
|
223
|
+
<rect width="185" height="24" fill="#ffffff" stroke="#a7f3d0" stroke-width="1" rx="4" />
|
|
217
224
|
<text x="8" y="16" class="code-text">handoff-package.json</text>
|
|
218
225
|
</g>
|
|
219
|
-
<g transform="translate(10,
|
|
220
|
-
<rect width="
|
|
226
|
+
<g transform="translate(10, 92)">
|
|
227
|
+
<rect width="185" height="24" fill="#ffffff" stroke="#a7f3d0" stroke-width="1" rx="4" />
|
|
221
228
|
<text x="8" y="16" class="code-text">implementation-plan.json</text>
|
|
222
229
|
</g>
|
|
223
|
-
<g transform="translate(10,
|
|
224
|
-
<rect width="
|
|
230
|
+
<g transform="translate(10, 118)">
|
|
231
|
+
<rect width="185" height="24" fill="#ffffff" stroke="#a7f3d0" stroke-width="1" rx="4" />
|
|
225
232
|
<text x="8" y="16" class="code-text">implementation-report.json</text>
|
|
226
233
|
</g>
|
|
234
|
+
<g transform="translate(10, 144)">
|
|
235
|
+
<rect width="185" height="24" fill="#ffffff" stroke="#a7f3d0" stroke-width="1" rx="4" />
|
|
236
|
+
<text x="8" y="16" class="code-text">qc-report.json</text>
|
|
237
|
+
</g>
|
|
238
|
+
<g transform="translate(10, 170)">
|
|
239
|
+
<rect width="185" height="24" fill="#ffffff" stroke="#a7f3d0" stroke-width="1" rx="4" />
|
|
240
|
+
<text x="8" y="16" class="code-text">polish-report.json</text>
|
|
241
|
+
</g>
|
|
227
242
|
</g>
|
|
228
243
|
|
|
229
244
|
<g transform="translate(1000, 255)" class="shadow">
|
|
230
245
|
<rect width="200" height="130" fill="#f8fafc" stroke="#475569" stroke-width="1.5" rx="8" />
|
|
231
246
|
<circle cx="100" cy="45" r="18" fill="#059669" />
|
|
232
247
|
<path d="M94 45 l4 4 l8 -8" fill="none" stroke="#ffffff" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
233
|
-
<text x="100" y="
|
|
234
|
-
<text x="100" y="
|
|
248
|
+
<text x="100" y="82" class="section-title" font-size="16" text-anchor="middle">Approved</text>
|
|
249
|
+
<text x="100" y="102" class="section-title" font-size="16" text-anchor="middle">Polished Clean</text>
|
|
250
|
+
<text x="100" y="122" class="section-title" font-size="16" text-anchor="middle">Implementation</text>
|
|
235
251
|
</g>
|
|
236
252
|
|
|
237
|
-
<line x1="860" y1="157" x2="
|
|
238
|
-
<line x1="
|
|
239
|
-
<line x1="
|
|
240
|
-
<line x1="
|
|
253
|
+
<line x1="860" y1="157" x2="870" y2="157" stroke="#4b5563" stroke-width="1.5" marker-end="url(#arrow)" />
|
|
254
|
+
<line x1="1035" y1="157" x2="1045" y2="157" stroke="#4b5563" stroke-width="1.5" marker-end="url(#arrow)" />
|
|
255
|
+
<line x1="777" y1="220" x2="777" y2="190" stroke="#4b5563" stroke-width="1.5" marker-end="url(#arrow)" />
|
|
256
|
+
<line x1="1128" y1="190" x2="1128" y2="255" stroke="#4b5563" stroke-width="1.5" marker-end="url(#arrow)" />
|
|
241
257
|
|
|
242
|
-
<path d="M 695
|
|
243
|
-
<rect x="382" y="
|
|
244
|
-
<text x="480" y="
|
|
258
|
+
<path d="M 695 410 L 170 410 L 170 370" fill="none" stroke="#374151" stroke-width="1.5" stroke-dasharray="4 4" marker-end="url(#arrow-dash)" />
|
|
259
|
+
<rect x="382" y="398" width="196" height="22" fill="#ffffff" rx="4" />
|
|
260
|
+
<text x="480" y="414" class="body-bold" text-anchor="middle" font-size="12">Terminal report + deltas only</text>
|
|
245
261
|
|
|
246
262
|
|
|
247
263
|
<line x1="0" y1="460" x2="1240" y2="460" stroke="#e5e7eb" stroke-width="2" />
|
|
@@ -303,9 +319,9 @@
|
|
|
303
319
|
<rect width="136" height="100" fill="#ffffff" stroke="#2563eb" stroke-width="1" rx="6" />
|
|
304
320
|
<circle cx="68" cy="-12" r="12" fill="#2563eb" />
|
|
305
321
|
<text x="68" y="-7" class="step-num" text-anchor="middle">6</text>
|
|
306
|
-
<text x="68" y="
|
|
307
|
-
<text x="68" y="
|
|
308
|
-
<text x="68" y="
|
|
322
|
+
<text x="68" y="28" class="body-text" text-anchor="middle">6. Plan and</text>
|
|
323
|
+
<text x="68" y="44" class="body-text" text-anchor="middle">implement</text>
|
|
324
|
+
<text x="68" y="60" class="body-text" text-anchor="middle">clean slice</text>
|
|
309
325
|
</g>
|
|
310
326
|
<line x1="916" y1="575" x2="932" y2="575" stroke="#2563eb" stroke-width="1.5" marker-end="url(#arrow-blue)" />
|
|
311
327
|
|
|
@@ -313,10 +329,10 @@
|
|
|
313
329
|
<rect width="136" height="100" fill="#ffffff" stroke="#2563eb" stroke-width="1" rx="6" />
|
|
314
330
|
<circle cx="68" cy="-12" r="12" fill="#2563eb" />
|
|
315
331
|
<text x="68" y="-7" class="step-num" text-anchor="middle">7</text>
|
|
316
|
-
<text x="68" y="28" class="body-text" text-anchor="middle">7.
|
|
317
|
-
<text x="68" y="44" class="body-text" text-anchor="middle">
|
|
318
|
-
<text x="68" y="60" class="body-text" text-anchor="middle">
|
|
319
|
-
<text x="68" y="76" class="body-text" text-anchor="middle">
|
|
332
|
+
<text x="68" y="28" class="body-text" text-anchor="middle">7. Agent 4</text>
|
|
333
|
+
<text x="68" y="44" class="body-text" text-anchor="middle">polish review</text>
|
|
334
|
+
<text x="68" y="60" class="body-text" text-anchor="middle">and local</text>
|
|
335
|
+
<text x="68" y="76" class="body-text" text-anchor="middle">commit</text>
|
|
320
336
|
</g>
|
|
321
337
|
<line x1="1068" y1="575" x2="1084" y2="575" stroke="#2563eb" stroke-width="1.5" marker-end="url(#arrow-blue)" />
|
|
322
338
|
|
|
@@ -324,10 +340,10 @@
|
|
|
324
340
|
<rect width="136" height="100" fill="#ffffff" stroke="#2563eb" stroke-width="1" rx="6" />
|
|
325
341
|
<circle cx="68" cy="-12" r="12" fill="#2563eb" />
|
|
326
342
|
<text x="68" y="-7" class="step-num" text-anchor="middle">8</text>
|
|
327
|
-
<text x="68" y="28" class="body-text" text-anchor="middle">8.
|
|
328
|
-
<text x="68" y="44" class="body-text" text-anchor="middle">
|
|
329
|
-
<text x="68" y="60" class="body-text" text-anchor="middle">
|
|
330
|
-
<text x="68" y="76" class="body-text" text-anchor="middle">
|
|
343
|
+
<text x="68" y="28" class="body-text" text-anchor="middle">8. Agent 0</text>
|
|
344
|
+
<text x="68" y="44" class="body-text" text-anchor="middle">verifies</text>
|
|
345
|
+
<text x="68" y="60" class="body-text" text-anchor="middle">coverage or</text>
|
|
346
|
+
<text x="68" y="76" class="body-text" text-anchor="middle">returns gaps</text>
|
|
331
347
|
</g>
|
|
332
348
|
|
|
333
349
|
<g transform="translate(140, 650)">
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -51,7 +51,7 @@ To assist in logical unit decomposition, the workflow supports an optional sourc
|
|
|
51
51
|
|
|
52
52
|
* **Execution Boundary**: This tooling runs exclusively in the contaminated domain before clean-room role sessions are initialized.
|
|
53
53
|
* **Traversal Bounds**: Source indexing enforces file count, per-file byte, total byte, batch token, and segment caps. It validates file size again after reading, skips files that change during read, records directory walk errors, and prunes traversal after global limits are exhausted with an aggregate skipped entry.
|
|
54
|
-
* **Agent 0 Use**: Agent 0 consumes `source-index.json` only to create neutral `task-manifest.json` units and per-unit `source_index_refs`. The index stays contaminated-only and does not cross to Agent 1.5, Agent 2, Agent 3, or clean handoff packages.
|
|
54
|
+
* **Agent 0 Use**: Agent 0 consumes `source-index.json` only to create neutral `task-manifest.json` units and per-unit `source_index_refs`. The index stays contaminated-only and does not cross to Agent 1.5, Agent 2, Agent 3, Agent 4, or clean handoff packages.
|
|
55
55
|
* **Tool Trust Policy**: By default, tool discovery operates in `stat-only` mode and does not execute third-party binaries. It queries version strings only when explicitly invoked with `--probe-tools`. Tools discovered under `/opt/homebrew` or `/usr/local` remain stat-only unless `--allow-user-toolchain-probes` is also supplied. Project-local directories (such as `.bin` or `node_modules/.bin`) are ignored unless the environment variable `RE_SKILLS_TRUST_PROJECT_TOOLS=1` or the flag `--allow-working-project-tools` is supplied.
|
|
56
56
|
* **Local Tool Install Safety**: Explicit npm-backed helper installs are strict-version pinned and serialized with a cache-local lock before mutating `~/.cache/re-skills/clean-room-tools/npm`. Prefix creation failures, subprocess timeouts, and subprocess launch errors are returned as structured JSON facts instead of raw tracebacks.
|
|
57
57
|
|
|
@@ -94,8 +94,9 @@ flowchart LR
|
|
|
94
94
|
publicrefs["Allowed public refs<br/>CLEAN_ROOM_ALLOWED_READ_ROOTS"]
|
|
95
95
|
architect["Agent 2: clean-architect<br/>Plan implementation from clean specs and foundation"]
|
|
96
96
|
qa["Agent 3: clean-qa-editor<br/>Implement, record verification, terminal report"]
|
|
97
|
+
polish["Agent 4: clean-polish-reviewer<br/>Final code polish, repo hygiene, local commit"]
|
|
97
98
|
outputs["Clean artifacts<br/>implementation-plan.json<br/>qc-report.json<br/>test plan notes"]
|
|
98
|
-
imploutputs["Implementation outputs<br/>code
|
|
99
|
+
imploutputs["Implementation outputs<br/>code, tests, AGENTS.md, .gitignore<br/>implementation-report.json<br/>polish-report.json"]
|
|
99
100
|
end
|
|
100
101
|
|
|
101
102
|
subgraph guardrails["Guardrails and audit"]
|
|
@@ -128,6 +129,10 @@ flowchart LR
|
|
|
128
129
|
implroots --> qa
|
|
129
130
|
qa --> imploutputs
|
|
130
131
|
qa --> outputs
|
|
132
|
+
imploutputs --> polish
|
|
133
|
+
outputs --> polish
|
|
134
|
+
polish --> imploutputs
|
|
135
|
+
polish -. terminal polish report only<br/>abstract delta tickets .-> manager
|
|
131
136
|
qa -. terminal report only<br/>abstract delta tickets .-> manager
|
|
132
137
|
|
|
133
138
|
blocked -. quarantine do not hand off .-> ledgers
|
|
@@ -137,10 +142,10 @@ flowchart LR
|
|
|
137
142
|
denyread -. clean roles may read implementation roots .-> implroots
|
|
138
143
|
denyread -. Agent 1.5 cannot read source roots, clean roots, implementation roots, source-index.json, or preflight-goal.json .-> sanitizer
|
|
139
144
|
denywrite -. contaminated writes only to contaminated artifact roots .-> ledgers
|
|
140
|
-
denywrite -. Agent 2 writes clean artifacts only;
|
|
141
|
-
denywrite -.
|
|
145
|
+
denywrite -. Agent 2 writes clean artifacts only; Agents 3 and 4 write implementation roots .-> cleanroots
|
|
146
|
+
denywrite -. Agents 3 and 4 write code, tests, docs, and repo hygiene only here .-> implroots
|
|
142
147
|
denyshell -. no shell-style tools in role sessions .-> manager
|
|
143
|
-
denyshell -. no shell for Agent 2; explicit Agent 3
|
|
148
|
+
denyshell -. no shell for Agent 2; explicit Agent 3 and Agent 4 runners only .-> architect
|
|
144
149
|
scan -. post-write checks .-> outputs
|
|
145
150
|
scan -. Agent 1.5 staged-output checks .-> staged
|
|
146
151
|
|
|
@@ -149,7 +154,7 @@ flowchart LR
|
|
|
149
154
|
classDef wallClass fill:#f8fafc,stroke:#475569,color:#111827;
|
|
150
155
|
classDef guardClass fill:#f0fdf4,stroke:#15803d,color:#111827;
|
|
151
156
|
class source,preflight,manager,analyst,sanitizer,brief,ledgers,drafts,staged contaminatedDomain;
|
|
152
|
-
class cleanroots,implroots,publicrefs,architect,qa,outputs,imploutputs cleanDomain;
|
|
157
|
+
class cleanroots,implroots,publicrefs,architect,qa,polish,outputs,imploutputs cleanDomain;
|
|
153
158
|
class handoff,blocked wallClass;
|
|
154
159
|
class env,denyread,denywrite,denyshell,scan guardClass;
|
|
155
160
|
```
|
|
@@ -158,7 +163,7 @@ flowchart LR
|
|
|
158
163
|
|
|
159
164
|
## Agent Roles
|
|
160
165
|
|
|
161
|
-
The architecture delegates work across
|
|
166
|
+
The architecture delegates work across six distinct custom role agents to enforce separation between source reading, independent sanitization, clean planning, clean implementation, and final clean polish review.
|
|
162
167
|
|
|
163
168
|
### [Agent 0: Contaminated Manager Verifier](../agents/contaminated-manager-verifier.md)
|
|
164
169
|
* **Domain**: Contaminated (Source-readable)
|
|
@@ -169,11 +174,11 @@ The architecture delegates work across five distinct custom role agents to enfor
|
|
|
169
174
|
* Decomposes source scope into stable, neutral units that do not mirror private source layout.
|
|
170
175
|
* Controls execution flow and nested loop state.
|
|
171
176
|
* Provides Agent 1.5 only a neutral sanitizer brief containing domain purpose, target profile, unit intent, public compatibility allowlist, and blocked categories.
|
|
172
|
-
* Produces `clean-run-context.json` for Agent 2 and Agent
|
|
173
|
-
* Influences Agent 2 and Agent
|
|
177
|
+
* Produces `clean-run-context.json` for Agent 2, Agent 3, and Agent 4 instead of handing over the full `task-manifest.json` or full `preflight-goal.json`.
|
|
178
|
+
* Influences Agent 2, Agent 3, and Agent 4 only through durable sanitized artifacts, never direct chat, progress feedback, implementation hints, or priority changes.
|
|
174
179
|
* Performs final verification of clean specification and implementation coverage against the source scope.
|
|
175
180
|
* Writes the inner-loop `clean-room-result.json` only after contaminated-side coverage verification.
|
|
176
|
-
* Consumes Agent 3 reports only after Agent 3 reaches a terminal state, then sends only abstract delta tickets into a fresh clean artifact cycle.
|
|
181
|
+
* Consumes Agent 3 reports only after Agent 3 reaches a terminal state, and consumes Agent 4 reports only after the configured polish review reaches a terminal state, then sends only abstract delta tickets into a fresh clean artifact cycle.
|
|
177
182
|
|
|
178
183
|
### [Agent 1: Contaminated Source Analyst](../agents/contaminated-source-analyst.md)
|
|
179
184
|
* **Domain**: Contaminated (Source-readable, Read-only access to source)
|
|
@@ -206,7 +211,8 @@ The architecture delegates work across five distinct custom role agents to enfor
|
|
|
206
211
|
* Cannot write to `CLEAN_ROOM_IMPLEMENTATION_ROOTS`; the write hook rejects Agent 2 implementation-root writes.
|
|
207
212
|
* Merges approved handoff artifacts into the clean workspace.
|
|
208
213
|
* Writes `implementation-plan.json` with relative destination paths, tests, code hygiene policy, constraints, risks, and argv-array verification commands.
|
|
209
|
-
*
|
|
214
|
+
* Maintains `skeleton-manifest.json` as the clean destination architecture map for code-development runs, with owned path prefixes and refactor triggers.
|
|
215
|
+
* Assigns each implementation-plan target and test path to one or more architecture areas.
|
|
210
216
|
|
|
211
217
|
### [Agent 3: Clean Implementer Verifier](../agents/clean-qa-editor.md)
|
|
212
218
|
* **Domain**: Clean (Source-denied)
|
|
@@ -221,13 +227,24 @@ The architecture delegates work across five distinct custom role agents to enfor
|
|
|
221
227
|
* Does not report progress or ask Agent 0 for guidance during implementation.
|
|
222
228
|
* Emits one terminal report for Agent 0 only when the assigned spec slice is complete, blocked, or quarantined.
|
|
223
229
|
|
|
230
|
+
### [Agent 4: Clean Polish Reviewer](../agents/clean-polish-reviewer.md)
|
|
231
|
+
* **Domain**: Clean (Source-denied)
|
|
232
|
+
* **Write Target**: Clean polish reports in `CLEAN_ROOM_CLEAN_ROOTS`; code, docs, repo hygiene files, and local git metadata in `CLEAN_ROOM_IMPLEMENTATION_ROOTS`
|
|
233
|
+
* **Responsibilities**:
|
|
234
|
+
* Reviews final clean implementation for security, docs/comments, exception handling, resource leaks, race conditions, missing tests, and repository hygiene.
|
|
235
|
+
* Creates or updates implementation-root `AGENTS.md` with gotchas and build/test/dev commands discovered from clean implementation files.
|
|
236
|
+
* Updates `.gitignore` only for real generated outputs, dependencies, caches, or build/test artifacts.
|
|
237
|
+
* Writes `polish-report.json`.
|
|
238
|
+
* Uses `agent4-polish-runner.py` only with `CLEAN_ROOM_ALLOW_AGENT4_SHELL=1`, cwd under implementation roots, and strict hooks.
|
|
239
|
+
* May initialize git and create one local commit containing only paths listed in `polish-report.json`; it must not push, tag, reset, clean, or delete branches.
|
|
240
|
+
|
|
224
241
|
### Nested Controller Loop
|
|
225
242
|
|
|
226
243
|

|
|
227
244
|
|
|
228
|
-
The outer loop owns spec development: scope, behavior specs, acceptance criteria, and abstract delta resolution. The inner clean-room loop owns one approved spec slice. It repeats analyze, sanitize, plan, implement, QC, and contaminated-side coverage verification until it can return `spec-slice-complete`, `spec-slice-blocked`, `spec-delta-required`, `contamination-suspected`, `iteration-limit-reached`, or `no-progress-detected`.
|
|
245
|
+
The outer loop owns spec development: scope, behavior specs, acceptance criteria, and abstract delta resolution. The inner clean-room loop owns one approved spec slice. It repeats analyze, sanitize, plan, implement, QC, optional final polish review, and contaminated-side coverage verification until it can return `spec-slice-complete`, `spec-slice-blocked`, `spec-delta-required`, `contamination-suspected`, `iteration-limit-reached`, or `no-progress-detected`.
|
|
229
246
|
|
|
230
|
-
Agent 3's terminal report is not enough to return. Agent 0 must consume
|
|
247
|
+
Agent 3's terminal report is not enough to return. If configured, Agent 4 must produce a passing `polish-report.json`. Agent 0 must then consume the terminal clean reports, verify contaminated-side coverage, and write `clean-room-result.json`.
|
|
231
248
|
|
|
232
249
|
`clean-room-skill run` is the executable v1 inner-loop runner. It requires preflight refs, the required handoff sequence, unattended `controller_policy`, schema-valid `loop_context`, and a user-supplied agent command adapter. It does not automate outer spec development. The runner:
|
|
233
250
|
|
|
@@ -236,6 +253,7 @@ Agent 3's terminal report is not enough to return. Agent 0 must consume that rep
|
|
|
236
253
|
* Selects at most one pending or gap unit inside `loop_context.approved_scope_refs`.
|
|
237
254
|
* Spawns configured role commands with `shell: false`, bounded output, and bounded timeout.
|
|
238
255
|
* In strict context-management mode, requires each configured stage to provide `context.fresh_session: true` and `context.brief_path`, then validates the session brief before spawn.
|
|
256
|
+
* Supports the optional `clean-polish-review` phase between `clean-implement-qc` and `contaminated-coverage-verify`.
|
|
239
257
|
* Validates schema, leakage, and handoff integrity before advancing state.
|
|
240
258
|
* Records controller memory in contaminated-side `controller-run-ledger.json`.
|
|
241
259
|
* Writes `clean-room-result.json` before returning to the outer spec loop.
|
|
@@ -252,13 +270,13 @@ Every clean-room role session requires a populated environment block before any
|
|
|
252
270
|
* `CLEAN_ROOM_SOURCE_ROOTS`: Source roots (only readable by source-reading contaminated roles, not Agent 1.5).
|
|
253
271
|
* `CLEAN_ROOM_CONTAMINATED_ARTIFACT_ROOTS`: Target write directory for contaminated roles.
|
|
254
272
|
* `CLEAN_ROOM_CLEAN_ROOTS`: Target write directory for clean artifacts and reports.
|
|
255
|
-
* `CLEAN_ROOM_IMPLEMENTATION_ROOTS`: Target write directory for Agent 3 clean implementation code and tests.
|
|
273
|
+
* `CLEAN_ROOM_IMPLEMENTATION_ROOTS`: Target write directory for Agent 3 clean implementation code and tests, plus Agent 4 implementation-root hygiene changes and local git metadata.
|
|
256
274
|
* `CLEAN_ROOM_ALLOWED_READ_ROOTS`: Approved reference docs or constraints readable by clean and source-denied roles.
|
|
257
275
|
* `CLEAN_ROOM_SCHEMA_DIR`: Path to the directory containing JSON schema assets.
|
|
258
276
|
|
|
259
277
|
When context management is enabled, role sessions also receive `CLEAN_ROOM_SESSION_BRIEF_PATH`, `CLEAN_ROOM_ROLE_SESSION_ID`, and, in strict mode, `CLEAN_ROOM_FRESH_CONTEXT_REQUIRED=1`. The brief is the low-context launch packet: compact status, next action, allowed artifact refs with SHA-256, and forbidden inputs. `controller-status.json` stays contaminated-side and is not clean input.
|
|
260
278
|
|
|
261
|
-
Note: Even though clean and source-denied roles (such as Agent 1.5, 2, and
|
|
279
|
+
Note: Even though clean and source-denied roles (such as Agent 1.5, 2, 3, and 4) are restricted from accessing contaminated or source workspaces, they must still be configured with the full environment block. The hook guardrails require these paths to validate that tool inputs do not cross-pollinate or violate boundary constraints.
|
|
262
280
|
|
|
263
281
|
---
|
|
264
282
|
|
|
@@ -272,10 +290,11 @@ Post-write hook failures are deny-by-default and redacted. If an artifact disapp
|
|
|
272
290
|
|
|
273
291
|
* [clean-room-hook.py](../hooks/clean-room-hook.py): The main safe/strict dispatch wrapper for the policy checks.
|
|
274
292
|
* [agent3-verification-runner.py](../hooks/agent3-verification-runner.py): Runs Agent 3 argv-array verification commands with `shell=False`, sanitized env, bounded output, timeout, root traversal checks, and a small allowlist covering npm, pnpm, yarn, bun, and deno test commands; pytest directly or through `python -m` / `python3 -m`; `cargo test`; `go test`; and `zig build test`.
|
|
293
|
+
* [agent4-polish-runner.py](../hooks/agent4-polish-runner.py): Runs Agent 4 bounded status, verification, git init, staging, and one local commit from implementation roots only, using paths and policy recorded in `polish-report.json`.
|
|
275
294
|
* [require-clean-room-env.py](../hooks/require-clean-room-env.py): Fails closed if the required role and root environment variables are missing, if trust-domain roots overlap, or if clean, implementation, or contaminated artifact root names appear source-derived.
|
|
276
|
-
* [deny-clean-room-shell.py](../hooks/deny-clean-room-shell.py): Denies shell-style tool execution inside clean-room role sessions except installed Agent 3 verification-runner invocations under implementation roots.
|
|
295
|
+
* [deny-clean-room-shell.py](../hooks/deny-clean-room-shell.py): Denies shell-style tool execution inside clean-room role sessions except installed Agent 3 verification-runner invocations under implementation roots and installed Agent 4 polish-runner invocations under implementation roots.
|
|
277
296
|
* [deny-clean-source-read.py](../hooks/deny-clean-source-read.py): Enforces that clean roles and Agent 1.5 cannot read source roots or unapproved paths; clean roles may read implementation roots, and source-denied roles are denied direct `preflight-goal.json` reads. Agent 1.5 is also denied clean roots, implementation roots, and direct `source-index.json` reads.
|
|
278
|
-
* [deny-contaminated-clean-write.py](../hooks/deny-contaminated-clean-write.py): Enforces role write roots. Agent 2 writes clean artifacts only, Agent 3 writes implementation files and clean reports, and contaminated roles write only to `CLEAN_ROOM_CONTAMINATED_ARTIFACT_ROOTS`.
|
|
297
|
+
* [deny-contaminated-clean-write.py](../hooks/deny-contaminated-clean-write.py): Enforces role write roots. Agent 2 writes clean artifacts only, Agent 3 writes implementation files and clean reports, Agent 4 writes clean polish reports and implementation-root polish changes, and contaminated roles write only to `CLEAN_ROOM_CONTAMINATED_ARTIFACT_ROOTS`.
|
|
279
298
|
* [check-artifact-leakage.py](../hooks/check-artifact-leakage.py): Scans clean artifacts and Agent 1.5 staged contaminated artifacts for high-risk leakage markers, source-like identifiers, and private identifier denylist terms. The private identifier denylist (loaded via `CLEAN_ROOM_PRIVATE_IDENTIFIER_DENYLIST`) is subject to hard limits to protect hook execution performance: a maximum of 1,000,000 bytes per file, 20,000 total terms, and 512 characters per individual term.
|
|
280
299
|
* [validate-json-schema.py](../hooks/validate-json-schema.py): Verifies JSON syntax and structural conformance against schemas under `CLEAN_ROOM_SCHEMA_DIR`, including controller-side `preflight-goal.schema.json` and `init-config.schema.json`. Under clean roots, any unrecognized JSON files that do not conform to canonical schemas will trigger a failure unless they are explicitly registered in the path-separated `CLEAN_ROOM_AUXILIARY_JSON_ALLOWLIST` environment variable.
|
|
281
300
|
* [validate-handoff-package.py](../hooks/validate-handoff-package.py): Verifies that handoff packages stay within clean roots, do not reference contaminated paths, `task-manifest.json`, `preflight-goal.json`, or `source-index.json`, and match declared `sha256` checksums.
|
package/docs/REFERENCE.md
CHANGED
|
@@ -235,7 +235,7 @@ Minimal agent command adapter shape for advisory or disabled context management:
|
|
|
235
235
|
}
|
|
236
236
|
```
|
|
237
237
|
|
|
238
|
-
Supported phases are `contaminated-analysis`, `sanitize-handoff`, `clean-plan`, `clean-implement-qc`, and `contaminated-coverage-verify`. The coverage verification phase is required.
|
|
238
|
+
Supported phases are `contaminated-analysis`, `sanitize-handoff`, `clean-plan`, `clean-implement-qc`, optional `clean-polish-review`, and `contaminated-coverage-verify`. The coverage verification phase is required. When present, `clean-polish-review` must run after `clean-implement-qc` and before `contaminated-coverage-verify`.
|
|
239
239
|
|
|
240
240
|
When `task-manifest.json` sets `context_management.mode` to `role-session-briefs` and `context_management.enforcement` to `strict`, every configured stage must include `context.fresh_session: true` and `context.brief_path`. The runner validates the brief before spawn, passes only the brief path plus environment facts in the stage prompt, and records the brief ref/hash in `controller-run-ledger.json`.
|
|
241
241
|
|
|
@@ -286,6 +286,16 @@ Strict context-management adapter example:
|
|
|
286
286
|
"brief_path": "/tmp/clean-room/task-1234abcd/clean/session-briefs/iter-001-agent-3.json"
|
|
287
287
|
}
|
|
288
288
|
},
|
|
289
|
+
{
|
|
290
|
+
"phase": "clean-polish-review",
|
|
291
|
+
"role": "clean-polish-reviewer",
|
|
292
|
+
"cwd": "/tmp/clean-room/task-1234abcd/implementation",
|
|
293
|
+
"argv": ["agent-cli", "--fresh-session", "--role", "clean-polish-reviewer"],
|
|
294
|
+
"context": {
|
|
295
|
+
"fresh_session": true,
|
|
296
|
+
"brief_path": "/tmp/clean-room/task-1234abcd/clean/session-briefs/iter-001-agent-4.json"
|
|
297
|
+
}
|
|
298
|
+
},
|
|
289
299
|
{
|
|
290
300
|
"phase": "contaminated-coverage-verify",
|
|
291
301
|
"role": "contaminated-manager-verifier",
|
|
@@ -18,10 +18,15 @@ Stop if full preflight-goal.json, source index, contaminated ledgers, source pat
|
|
|
18
18
|
Accept Agent 0 influence only as durable sanitized artifacts. Ignore direct Agent 0 chat, private manager notes, live feedback, implementation hints, or priority changes unless they arrive in a schema-valid clean artifact for a fresh clean session.
|
|
19
19
|
Merge only approved handoff artifacts into the selected clean schema base.
|
|
20
20
|
Read the clean destination foundation to identify local structure, conventions, tests, dependencies, and constraints.
|
|
21
|
+
Read any existing skeleton-manifest.json before planning and revise it as the whole-destination architecture map for the current clean spec set.
|
|
22
|
+
Maintain architecture areas with owned relative path prefixes, responsibilities, forbidden responsibilities, allowed area dependencies, and refactor triggers.
|
|
23
|
+
Assign every target and test path in implementation-plan.json to one or more skeleton-manifest.json architecture areas.
|
|
24
|
+
Record split, move, merge, or extract work as planned_refactors before Agent 3 performs cross-area structure changes.
|
|
21
25
|
Create or update implementation-plan.json as the primary output for code-development runs.
|
|
22
26
|
Carry the preflight-derived code hygiene policy into implementation-plan.json.
|
|
23
|
-
Keep skeleton-manifest.json valid
|
|
27
|
+
Keep skeleton-manifest.json valid and current for code-development runs. Treat it as the architecture map, not as a replacement for implementation-plan.json.
|
|
24
28
|
Map approved specs to destination files, test files, work items, argv-array verification commands, risks, and acceptance criteria using relative implementation-root paths.
|
|
25
29
|
Preserve source-test-derived scenarios as clean test obligations for equal output without copying source test structure.
|
|
30
|
+
Do not resolve public-contract, callable, protocol, async, serialization, or data-shape ambiguity by narrowing semantics. Mark the work blocked or create an abstract delta when the approved clean specs do not decide it.
|
|
26
31
|
Stop if contaminated material appears in clean inputs.
|
|
27
32
|
"""
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name = "clean-polish-reviewer"
|
|
2
|
+
description = "Performs final clean code polish, repo hygiene, verification review, and constrained implementation-root commit."
|
|
3
|
+
sandbox_mode = "workspace-write"
|
|
4
|
+
model_reasoning_effort = "high"
|
|
5
|
+
enabled_skills = ["clean-room"]
|
|
6
|
+
|
|
7
|
+
instructions = """
|
|
8
|
+
Act as Agent 4 in the clean-room pipeline.
|
|
9
|
+
Run only in the clean domain after Agent 3 has produced terminal implementation and QC reports.
|
|
10
|
+
Before tool use, require CLEAN_ROOM_ROLE=clean-polish-reviewer, CLEAN_ROOM_CLEAN_ROOTS, CLEAN_ROOM_IMPLEMENTATION_ROOTS, CLEAN_ROOM_SOURCE_ROOTS, CLEAN_ROOM_CONTAMINATED_ARTIFACT_ROOTS, CLEAN_ROOM_ALLOWED_READ_ROOTS, and CLEAN_ROOM_SCHEMA_DIR.
|
|
11
|
+
Read approved clean artifacts, CLEAN_ROOM_IMPLEMENTATION_ROOTS, schemas, and explicitly configured public or destination constraint roots only.
|
|
12
|
+
Write polish-report.json and clean reports under CLEAN_ROOM_CLEAN_ROOTS. Write implementation code, tests, docs, AGENTS.md, .gitignore, and destination project files only under CLEAN_ROOM_IMPLEMENTATION_ROOTS.
|
|
13
|
+
Do not read source workspaces, contaminated ledgers, contaminated chat history, source-index.json, the full task-manifest.json, or the full preflight-goal.json.
|
|
14
|
+
When CLEAN_ROOM_SESSION_BRIEF_PATH is set, read it first and load only the allowed artifact refs named there, plus implementation-root files permitted by this role.
|
|
15
|
+
Review final clean code for security issues, missing docs/comments, exception handling gaps, memory or resource leaks, race/concurrency risks, missing tests, and repository hygiene issues.
|
|
16
|
+
Keep changes small and tied to the approved clean implementation plan, terminal implementation report, QC report, and clean code already under the implementation root.
|
|
17
|
+
Create or update implementation-root AGENTS.md with concrete gotchas and build/test/development commands discovered from clean implementation files.
|
|
18
|
+
Update implementation-root .gitignore only for real generated outputs, dependency folders, local caches, or build/test artifacts relevant to the clean implementation stack.
|
|
19
|
+
Do not add speculative ignores, speculative docs, broad refactors, new dependencies, or new behavior.
|
|
20
|
+
Do not use shell commands from this default profile. Use a separate isolated polish profile only when CLEAN_ROOM_ALLOW_AGENT4_SHELL=1, strict hooks are installed, the command cwd is inside CLEAN_ROOM_IMPLEMENTATION_ROOTS, and the command invokes the installed agent4-polish-runner.py.
|
|
21
|
+
The polish runner may initialize git, inspect bounded status, run allowed verification commands, stage only paths listed in polish-report.json, and create one local commit. Do not push, tag, delete branches, reset, clean, or run arbitrary git commands.
|
|
22
|
+
Record findings, changed relative paths, verification results, residual risks, git status, commit message, commit hash/status, and abstract delta tickets in polish-report.json.
|
|
23
|
+
Mark final_status as passed only when high/blocker security, correctness, exception, resource, race, leakage, and verification findings are resolved and the constrained local commit succeeded.
|
|
24
|
+
Convert major behavior gaps or scope expansion into abstract delta tickets instead of implementing new scope.
|
|
25
|
+
"""
|