clean-room-skill 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +2 -3
  3. package/.codex-plugin/plugin.json +1 -2
  4. package/README.md +108 -279
  5. package/agents/clean-architect.md +24 -8
  6. package/agents/clean-implementer-verifier-shell.md +36 -0
  7. package/agents/clean-qa-editor.md +31 -8
  8. package/agents/contaminated-handoff-sanitizer.md +37 -0
  9. package/agents/contaminated-manager-verifier.md +28 -9
  10. package/agents/contaminated-source-analyst.md +22 -4
  11. package/assets/clean-room-arch.svg +354 -0
  12. package/bin/install.js +1015 -300
  13. package/bin/verify.sh +78 -0
  14. package/docs/ARCHITECTURE.md +276 -0
  15. package/docs/REFERENCE.md +318 -0
  16. package/examples/codex/.codex/agents/clean-architect.toml +15 -6
  17. package/examples/codex/.codex/agents/clean-qa-editor.toml +22 -7
  18. package/examples/codex/.codex/agents/contaminated-handoff-sanitizer.toml +18 -0
  19. package/examples/codex/.codex/agents/contaminated-manager-verifier.toml +14 -5
  20. package/examples/codex/.codex/agents/contaminated-source-analyst.toml +11 -4
  21. package/hooks/agent3-verification-runner.py +514 -0
  22. package/hooks/check-artifact-leakage.py +133 -26
  23. package/hooks/clean-room-hook.py +38 -7
  24. package/hooks/clean_room_paths.py +193 -22
  25. package/hooks/deny-clean-room-shell.py +153 -0
  26. package/hooks/deny-clean-source-read.py +93 -36
  27. package/hooks/deny-contaminated-clean-write.py +59 -56
  28. package/hooks/require-clean-room-env.py +161 -6
  29. package/hooks/validate-handoff-package.py +54 -19
  30. package/hooks/validate-json-schema.py +271 -46
  31. package/lib/bootstrap.cjs +247 -0
  32. package/lib/dir-lock.cjs +142 -0
  33. package/lib/doctor.cjs +406 -0
  34. package/lib/fs-utils.cjs +103 -4
  35. package/lib/hooks.cjs +63 -39
  36. package/lib/install-artifacts.cjs +163 -0
  37. package/lib/install-plan.cjs +252 -0
  38. package/lib/preflight.cjs +474 -0
  39. package/lib/run.cjs +1040 -0
  40. package/lib/runtime-layout.cjs +258 -0
  41. package/package.json +13 -3
  42. package/plugin.json +2 -3
  43. package/skills/attended/SKILL.md +10 -6
  44. package/skills/clean-room/SKILL.md +82 -45
  45. package/skills/clean-room/assets/behavior-spec.schema.json +1 -0
  46. package/skills/clean-room/assets/clean-room-result.schema.json +103 -0
  47. package/skills/clean-room/assets/clean-run-context.schema.json +634 -0
  48. package/skills/clean-room/assets/contamination-incident.schema.json +1 -0
  49. package/skills/clean-room/assets/handoff-package.schema.json +3 -7
  50. package/skills/clean-room/assets/implementation-plan.schema.json +330 -0
  51. package/skills/clean-room/assets/implementation-report.schema.json +333 -0
  52. package/skills/clean-room/assets/init-config.schema.json +303 -0
  53. package/skills/clean-room/assets/preflight-goal.schema.json +517 -0
  54. package/skills/clean-room/assets/qc-report.schema.json +3 -0
  55. package/skills/clean-room/assets/task-manifest.schema.json +612 -3
  56. package/skills/clean-room/examples/README.md +22 -5
  57. package/skills/clean-room/examples/contaminated-side/init-config.json +64 -0
  58. package/skills/clean-room/examples/contaminated-side/preflight-goal.json +100 -0
  59. package/skills/clean-room/examples/contaminated-side/task-manifest.json +473 -0
  60. package/skills/clean-room/examples/minimal-spec-package/behavior-spec.json +1 -1
  61. package/skills/clean-room/examples/minimal-spec-package/clean-room-result.json +10 -0
  62. package/skills/clean-room/examples/minimal-spec-package/clean-run-context.json +151 -0
  63. package/skills/clean-room/examples/minimal-spec-package/contamination-incident.json +10 -0
  64. package/skills/clean-room/examples/minimal-spec-package/handoff-package.json +8 -2
  65. package/skills/clean-room/examples/minimal-spec-package/implementation-plan.json +98 -0
  66. package/skills/clean-room/examples/minimal-spec-package/implementation-report.json +30 -0
  67. package/skills/clean-room/examples/valid-handoff-package/behavior-spec.json +61 -0
  68. package/skills/clean-room/examples/valid-handoff-package/handoff-package.json +26 -0
  69. package/skills/clean-room/references/CONTROLLER-LOOP.md +100 -0
  70. package/skills/clean-room/references/LEAKAGE-RULES.md +18 -7
  71. package/skills/clean-room/references/PREFLIGHT.md +71 -0
  72. package/skills/clean-room/references/PROCESS.md +165 -71
  73. package/skills/clean-room/references/SPEC-SCHEMA.md +154 -14
  74. package/skills/clean-room/references/TARGET-LANGUAGE-GUIDE.md +7 -0
  75. package/skills/clean-room/scripts/build_source_index.py +34 -1118
  76. package/skills/clean-room/scripts/clean_room_tool_manager.py +120 -37
  77. package/skills/clean-room/scripts/clean_room_tooling.py +120 -28
  78. package/skills/clean-room/scripts/source_index/__init__.py +2 -0
  79. package/skills/clean-room/scripts/source_index/batching.py +213 -0
  80. package/skills/clean-room/scripts/source_index/discovery.py +331 -0
  81. package/skills/clean-room/scripts/source_index/metrics.py +67 -0
  82. package/skills/clean-room/scripts/source_index/native_scanners.py +245 -0
  83. package/skills/clean-room/scripts/source_index/python_js_scanners.py +124 -0
  84. package/skills/clean-room/scripts/source_index/relationships.py +185 -0
  85. package/skills/clean-room/scripts/source_index/scanner_utils.py +28 -0
  86. package/skills/clean-room/scripts/source_index/scanners.py +110 -0
  87. package/skills/clean-room/scripts/source_index/writer.py +40 -0
  88. package/skills/init/SKILL.md +60 -0
  89. package/skills/preflight/SKILL.md +56 -0
  90. package/skills/refocus/SKILL.md +67 -0
  91. package/skills/resume/SKILL.md +77 -0
  92. package/skills/start-over/SKILL.md +58 -0
  93. package/skills/unattended/SKILL.md +16 -7
  94. package/templates/docker/README.md +25 -0
  95. package/templates/docker/compose.clean-room.yml +21 -0
  96. package/templates/docker/examples/go-test.json +18 -0
  97. package/templates/docker/examples/node-typescript.json +17 -0
  98. package/templates/docker/examples/python-pytest.json +18 -0
  99. package/templates/docker/examples/rust-cargo.json +17 -0
  100. package/templates/docker/profiles/go126.Dockerfile +3 -0
  101. package/templates/docker/profiles/node22.Dockerfile +3 -0
  102. package/templates/docker/profiles/python312.Dockerfile +3 -0
  103. package/templates/docker/profiles/rust-stable.Dockerfile +3 -0
  104. package/hooks/hooks.json +0 -44
  105. package/skills/clean-room/examples/minimal-spec-package/task-manifest.json +0 -220
  106. /package/skills/clean-room/examples/{minimal-spec-package → contaminated-side}/coverage-ledger.json +0 -0
  107. /package/skills/clean-room/examples/{minimal-spec-package → contaminated-side}/evidence-ledger.json +0 -0
  108. /package/skills/clean-room/examples/{minimal-spec-package → contaminated-side}/source-index.json +0 -0
@@ -7,9 +7,9 @@
7
7
  "plugins": [
8
8
  {
9
9
  "name": "clean-room",
10
- "source": ".",
10
+ "source": "./",
11
11
  "description": "Spec-first clean-room workflow for authorized source analysis without replacement code.",
12
- "version": "0.1.0",
12
+ "version": "0.1.3",
13
13
  "author": {
14
14
  "name": "whit3rabbit"
15
15
  },
@@ -2,7 +2,7 @@
2
2
  "name": "clean-room",
3
3
  "displayName": "Clean Room",
4
4
  "description": "Spec-first clean-room workflow for authorized source analysis without replacement code.",
5
- "version": "0.1.0",
5
+ "version": "0.1.3",
6
6
  "author": {
7
7
  "name": "whit3rabbit"
8
8
  },
@@ -15,6 +15,5 @@
15
15
  "compliance"
16
16
  ],
17
17
  "skills": "./skills/",
18
- "agents": "./agents/",
19
- "hooks": "./hooks/hooks.json"
18
+ "agents": "./agents/"
20
19
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clean-room",
3
- "version": "0.1.0",
3
+ "version": "0.1.3",
4
4
  "description": "Spec-first clean-room workflow for authorized source analysis without replacement code.",
5
5
  "author": {
6
6
  "name": "whit3rabbit"
@@ -15,7 +15,6 @@
15
15
  "compliance"
16
16
  ],
17
17
  "skills": "./skills/",
18
- "hooks": "./hooks/hooks.json",
19
18
  "interface": {
20
19
  "displayName": "Clean Room",
21
20
  "shortDescription": "Produce clean-room behavioral specs",
package/README.md CHANGED
@@ -1,376 +1,205 @@
1
1
  # Clean Room
2
2
 
3
- Spec-first clean-room workflow for software to spec.
3
+ Clean Room is an agent workflow for turning authorized source analysis into clean behavioral specs, clean implementation plans, and clean destination code.
4
4
 
5
- This is a POC based on the ideas presented here:
5
+ It is a POC based on ideas from [malus.sh](https://malus.sh/blog.html). It is an engineering risk-reduction workflow, not legal advice, and it does not create a legal safe harbor.
6
6
 
7
- https://malus.sh/blog.html
7
+ ## What This Is / Does
8
8
 
9
- This plugin packages the `clean-room`, `attended`, and `unattended` skills, Claude role agents, Codex role-agent templates, JSON schemas, examples, and hook guardrails for separating contaminated source analysis from clean behavioral specification work.
9
+ Use this package when you need documented separation between source-reading work and clean implementation work.
10
10
 
11
- It is an engineering risk-reduction workflow. It is not legal advice and does not create a legal safe harbor.
11
+ It installs:
12
12
 
13
- ## Use This For
13
+ - Clean-room skills for Codex, Claude Code, and other agent runtime layouts.
14
+ - Role-agent prompts for contaminated analysis, clean planning, and clean implementation.
15
+ - JSON schemas and examples for durable workflow artifacts.
16
+ - Hook guardrails that help keep source material out of clean artifacts.
17
+ - A small CLI for runtime installation, bootstrap folders, preflight contracts, hook smoke tests, and the bounded inner clean-room runner.
14
18
 
15
- - Authorized source-to-spec migration planning.
16
- - Clean behavioral specifications for compatibility work.
17
- - Skeleton manifests, QC reports, open questions, and test plans.
18
- - Documented separation between source-reading roles and clean artifact roles.
19
+ The workflow creates clean behavioral spec packages and clean implementation outputs. It does not generate replacement code directly from source.
19
20
 
20
- ## Threat Model And Non-Goals
21
+ Core boundary:
21
22
 
22
- This workflow protects against:
23
+ - Contaminated roles may read authorized source and write contaminated artifacts.
24
+ - Source-denied roles may read only clean artifacts, implementation roots, schemas, and approved public/reference roots.
25
+ - Clean implementation code is written only under the clean implementation root.
26
+ - Raw source, source paths, private identifiers, raw diffs, copied comments, and source-shaped pseudocode must not cross into clean handoff artifacts.
23
27
 
24
- - accidental source expression crossing into clean specs
25
- - clean agents reading contaminated roots
26
- - contaminated agents writing clean artifacts
27
- - clean or contaminated agents writing outside their role artifact roots
28
- - unbounded unattended controller loops
28
+ For the full boundary model, see [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md). For CLI and troubleshooting details, see [docs/REFERENCE.md](docs/REFERENCE.md).
29
29
 
30
- It does not protect against:
30
+ ## How To Install
31
31
 
32
- - hostile local users
33
- - compromised host tooling
34
- - shared model context outside role isolation
35
- - legal conclusions
36
- - side channels through filenames, timing, or retained chat context
32
+ Requires Node.js `>=22`.
37
33
 
38
- ## Install
39
-
40
- Preferred direct installer:
34
+ Preferred interactive install:
41
35
 
42
36
  ```bash
43
37
  npx clean-room-skill@latest
44
38
  ```
45
39
 
46
- The installer prompts for runtime and scope when no flags are supplied. For non-interactive installs, pass the runtime and scope explicitly:
40
+ Non-interactive installs:
47
41
 
48
42
  ```bash
49
43
  npx clean-room-skill@latest --codex --global --yes
50
44
  npx clean-room-skill@latest --claude --global --yes
51
- npx clean-room-skill@latest --antigravity --global --yes
52
45
  npx clean-room-skill@latest --all --global --yes
53
46
  ```
54
47
 
55
- Supported runtime roots:
56
-
57
- - Codex global: `CODEX_HOME` or `~/.codex`
58
- - Claude Code global: `CLAUDE_CONFIG_DIR` or `~/.claude`
59
- - Antigravity global: `ANTIGRAVITY_PLUGIN_DIR` or `~/.gemini/config/plugins/clean-room-skill`
60
-
61
- Local installs are supported for Codex and Claude Code through `--local`. Antigravity local installs are rejected in v1.
62
-
63
48
  Hook modes:
64
49
 
65
- - `--hooks=safe`: default. Copies hooks and registers a wrapper that no-ops unless `CLEAN_ROOM_HOOK_ENFORCE=1` or clean-room environment variables are present.
66
- - `--hooks=copy-only` or `--no-hooks`: copies hook files but does not register Codex or Claude hook config.
67
- - `--hooks=strict`: registers fail-closed hooks for dedicated clean-room homes.
50
+ - `--hooks=safe`: default. Hooks are installed but enforce only during clean-room role sessions with the required environment.
51
+ - `--hooks=strict`: fail-closed hook mode for dedicated Codex or Claude clean-room homes.
52
+ - `--hooks=copy-only` or `--no-hooks`: copy hook files without registering runtime hook config.
68
53
 
69
- Useful maintenance commands:
70
-
71
- ```bash
72
- npx clean-room-skill@latest --dry-run --all --global
73
- npx clean-room-skill@latest --codex --global --uninstall --yes
74
- ```
54
+ Verified runtimes are Codex and Claude Code. Other runtime layouts are installed on a best-effort basis. See [docs/REFERENCE.md](docs/REFERENCE.md#runtime-support) for the full support table and install roots.
75
55
 
76
- The installer writes `clean-room-install-manifest.json` into each target root. Reinstalling replaces only manifest-managed files automatically. If a managed file was locally modified, the previous version is backed up under `clean-room-patches/<timestamp>/`. Unknown existing files are not overwritten in non-interactive mode.
56
+ Marketplace install is also supported.
77
57
 
78
- Marketplace install remains available.
79
-
80
- From Codex marketplace:
58
+ Codex:
81
59
 
82
60
  ```bash
83
61
  codex plugin marketplace add https://github.com/whit3rabbit/clean-room-skill.git
84
62
  ```
85
63
 
86
- Then install or enable `clean-room` from the `clean-room-skill` marketplace. Enable plugin hooks in trusted Codex config before relying on guardrails:
87
-
88
- ```toml
89
- [features]
90
- plugin_hooks = true
91
- ```
92
-
93
- From Claude Code marketplace:
64
+ Claude Code:
94
65
 
95
66
  ```text
96
67
  /plugin marketplace add https://github.com/whit3rabbit/clean-room-skill.git
97
68
  /plugin install clean-room@clean-room-skill
98
69
  ```
99
70
 
100
- Manual Antigravity install:
71
+ ## How To Run
101
72
 
102
- Clone this repository into your local plugins directory:
73
+ Optionally create neutral external run folders and a clean-safe repository stub:
103
74
 
104
75
  ```bash
105
- git clone https://github.com/whit3rabbit/clean-room-skill.git ~/.gemini/config/plugins/clean-room-skill
76
+ npx clean-room-skill@latest init
106
77
  ```
107
78
 
108
- Reload or restart the host if the plugin is not visible immediately.
109
-
110
- ## Invocation
79
+ The default artifact base is `~/Documents/CleanRoom/<task-id>/`. Keep active contaminated artifacts, clean artifacts, and clean implementation roots separate.
111
80
 
112
- In Claude Code, use the plugin skill namespace:
81
+ In Claude Code, invoke skills with the plugin namespace:
113
82
 
114
83
  ```text
115
84
  /clean-room
116
- /clean-room:clean-room
85
+ /clean-room:preflight
86
+ /clean-room:init
117
87
  /clean-room:attended
118
88
  /clean-room:unattended
89
+ /clean-room:resume
90
+ /clean-room:start-over
91
+ /clean-room:refocus
119
92
  ```
120
93
 
121
- `/clean-room` and `/clean-room:clean-room` start the setup wizard. `/clean-room:attended` starts the same wizard with attended review gates. `/clean-room:unattended` starts it with bounded unattended defaults: one unit per iteration, finite max iterations, and the configured safety stop conditions.
122
-
123
- In Codex, invoke the `clean-room` plugin or one of its bundled skills explicitly with `@` or the skills UI. Do not rely on Claude-style `/clean-room:...` namespacing in Codex.
94
+ In Codex, invoke the `clean-room` plugin or bundled skills through `@` or the skills UI. Do not rely on Claude-style slash namespacing in Codex.
124
95
 
125
- ## Operating Model
96
+ For unattended inner-loop execution from durable artifacts:
126
97
 
127
- Use separate workspaces, worktrees, repositories, or profiles for contaminated and clean work:
128
-
129
- - Contaminated source workspace: source-readable, read-only where practical.
130
- - Contaminated artifact workspace: source indexes, task manifests, coverage ledgers, evidence ledgers, draft specs, and abstract delta tickets. Configure as `CLEAN_ROOM_CONTAMINATED_ARTIFACT_ROOTS`.
131
- - Clean spec workspace: approved behavior specs, handoff packages, skeleton manifests, QC reports, and test plans.
132
- - Clean allowed reference workspace: public documentation or destination constraints explicitly approved for clean-role reads.
98
+ ```bash
99
+ npx clean-room-skill@latest run \
100
+ --task-manifest ~/Documents/CleanRoom/task-1234abcd/contaminated/task-manifest.json \
101
+ --agent-commands ./agent-commands.json \
102
+ --max-iterations 3
103
+ ```
133
104
 
134
- Prompt instructions alone are not a boundary. Use path separation, role-specific sessions, hook checks, schema validation, and artifact quarantine.
105
+ The `run` command executes one bounded inner clean-room loop for an already approved spec slice. It does not replace the outer spec-development workflow.
135
106
 
136
- ## Separation Diagram
107
+ ## Typical Workflow
137
108
 
138
109
  ![Clean Room Architecture](assets/clean-room-arch.svg)
139
110
 
140
- ### Flowchart Representation
141
-
142
- ```mermaid
143
- flowchart LR
144
- subgraph contaminated["Contaminated domain: source-readable"]
145
- source["Authorized source roots<br/>CLEAN_ROOM_SOURCE_ROOTS"]
146
- manager["Agent 0: contaminated-manager-verifier<br/>Scope, decompose, track coverage, verify"]
147
- analyst["Agent 1: contaminated-source-analyst<br/>Read source, write neutral tasks and specs"]
148
- ledgers["Contaminated artifacts<br/>CLEAN_ROOM_CONTAMINATED_ARTIFACT_ROOTS<br/>source-index.json<br/>task-manifest.json<br/>coverage-ledger.json<br/>evidence-ledger.json"]
149
- scrub["Leakage review<br/>Remove source expression"]
150
- end
151
-
152
- subgraph wall["Clean-room wall"]
153
- handoff["Approved handoff only<br/>handoff-package.json<br/>scrubbed behavior-spec.json"]
154
- blocked["Blocked from crossing<br/>source excerpts, raw diffs, copied comments,<br/>private identifiers, source-shaped pseudocode"]
155
- end
156
-
157
- subgraph clean["Clean domain: source-denied"]
158
- cleanroots["Clean artifact roots<br/>CLEAN_ROOM_CLEAN_ROOTS"]
159
- publicrefs["Allowed public refs<br/>CLEAN_ROOM_ALLOWED_READ_ROOTS"]
160
- architect["Agent 2: clean-architect<br/>Manage schema base and skeleton manifest"]
161
- qa["Agent 3: clean-qa-editor<br/>Validate schema, leakage, coverage, testability"]
162
- outputs["Clean outputs<br/>skeleton-manifest.json<br/>qc-report.json<br/>test plan notes"]
163
- end
164
-
165
- subgraph guardrails["Guardrails and audit"]
166
- env["require-clean-room-env.py"]
167
- denyread["deny-clean-source-read.py"]
168
- denywrite["deny-contaminated-clean-write.py<br/>write root policy"]
169
- denyshell["deny-clean-room-shell.py"]
170
- scan["check-artifact-leakage.py<br/>validate-json-schema.py"]
171
- end
172
-
173
- source --> manager
174
- manager --> analyst
175
- manager --> ledgers
176
- analyst --> ledgers
177
- analyst --> scrub
178
- scrub --> handoff
179
- handoff --> cleanroots
180
- cleanroots --> architect
181
- publicrefs --> architect
182
- architect --> outputs
183
- outputs --> qa
184
- qa --> outputs
185
- qa -. abstract delta tickets only .-> manager
186
-
187
- blocked -. quarantine do not hand off .-> ledgers
188
- env -. required for every role session .-> manager
189
- env -. required for every role session .-> architect
190
- denyread -. clean roles cannot read source roots .-> cleanroots
191
- denywrite -. contaminated writes only to contaminated artifact roots .-> ledgers
192
- denywrite -. clean writes only to clean roots .-> cleanroots
193
- denyshell -. no shell-style tools in role sessions .-> manager
194
- denyshell -. no shell-style tools in role sessions .-> architect
195
- scan -. post-write checks .-> outputs
196
-
197
- classDef contaminatedDomain fill:#fff7ed,stroke:#c2410c,color:#111827;
198
- classDef cleanDomain fill:#ecfeff,stroke:#0e7490,color:#111827;
199
- classDef wallClass fill:#f8fafc,stroke:#475569,color:#111827;
200
- classDef guardClass fill:#f0fdf4,stroke:#15803d,color:#111827;
201
- class source,manager,analyst,ledgers,scrub contaminatedDomain;
202
- class cleanroots,publicrefs,architect,qa,outputs cleanDomain;
203
- class handoff,blocked wallClass;
204
- class env,denyread,denywrite,denyshell,scan guardClass;
205
- ```
206
-
207
- ## Roles
111
+ 1. Record the goal contract.
112
+ Use `/clean-room:preflight` or `clean-room-skill preflight` before source discovery. This creates or validates `preflight-goal.json` on the contaminated/controller side.
208
113
 
209
- - Agent 0 / `contaminated-manager-verifier`: consumes contaminated source indexes, decomposes scope into logical batches, tracks coverage, verifies clean specs against source, and receives Agent 3 final QC reports.
210
- - Agent 1 / `contaminated-source-analyst`: reads authorized source and writes neutral task/spec material with evidence references, not code.
211
- - Agent 2 / `clean-architect`: reads approved clean artifacts, manages the selected clean schema base, and organizes artifacts into target-neutral skeleton manifests.
212
- - Agent 3 / `clean-qa-editor`: validates schema conformance, leakage risk, terminology, coverage gaps, and testability, then reports abstract findings back to Agent 0.
114
+ 2. Initialize preferences.
115
+ Use `/clean-room:init` to record artifact roots, target profile, model preferences, clean-safe rules, and contaminated-only rules. The active `init-config.json` stays out of the clean implementation repository.
213
116
 
214
- Claude role agents are in `agents/`. Codex role-agent templates are in `examples/codex/.codex/agents/`.
117
+ 3. Start the controller.
118
+ Use `/clean-room` or `/clean-room:attended` for human review gates. Use `/clean-room:unattended` only after preflight allows bounded unattended work with finite iteration limits and no open questions.
215
119
 
216
- ## Required Environment
120
+ 4. Analyze and sanitize.
121
+ Source-reading roles produce neutral draft behavior specs. A source-denied sanitizer reviews handoff candidates before anything enters the clean domain.
217
122
 
218
- Set and pass this environment block into every clean-room role session before tool use:
123
+ 5. Plan and implement.
124
+ 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.
219
125
 
220
- ```text
221
- CLEAN_ROOM_ROLE
222
- CLEAN_ROOM_SOURCE_ROOTS
223
- CLEAN_ROOM_CONTAMINATED_ARTIFACT_ROOTS
224
- CLEAN_ROOM_CLEAN_ROOTS
225
- CLEAN_ROOM_SCHEMA_DIR
226
- CLEAN_ROOM_ALLOWED_READ_ROOTS
227
- ```
126
+ 6. Verify and return.
127
+ Agent 0 performs contaminated-side coverage verification after Agent 3 reaches a terminal state, then writes `clean-room-result.json`.
228
128
 
229
- For clean roles, reads are deny-by-default. They may read only `CLEAN_ROOM_CLEAN_ROOTS` plus explicit public or destination constraint roots in `CLEAN_ROOM_ALLOWED_READ_ROOTS`. Source roots in `CLEAN_ROOM_SOURCE_ROOTS` stay denied.
129
+ Use recovery skills instead of chat history:
230
130
 
231
- Writes are also deny-by-default. Clean roles may write only under `CLEAN_ROOM_CLEAN_ROOTS`. Contaminated roles may write only under `CLEAN_ROOM_CONTAMINATED_ARTIFACT_ROOTS`. Source roots stay read-only for contaminated roles unless a separate, explicit process outside this plugin changes that policy.
131
+ - `resume`: continue from durable artifacts.
132
+ - `start-over`: archive or quarantine current artifacts without deletion, then restart with a fresh neutral task id.
133
+ - `refocus`: audit current artifacts against declared scope without expanding scope.
232
134
 
233
- Optional hook-only guardrail:
135
+ ## Commands / Skills
234
136
 
235
- ```text
236
- CLEAN_ROOM_PRIVATE_IDENTIFIER_DENYLIST
237
- ```
137
+ | Command or skill | Use it for |
138
+ | --- | --- |
139
+ | `clean-room-skill init` | Create neutral external run folders and a clean-safe `.clean-room/README.md` stub. |
140
+ | `clean-room-skill preflight` | Create or validate the Stage 0 goal contract. |
141
+ | `clean-room-skill run` | Execute the bounded inner clean-room runner for one approved spec slice. |
142
+ | `clean-room-skill doctor` | Smoke test generated Codex or Claude hook registration. |
143
+ | `clean-room-skill status` | Report installed runtime version, drift, and hook state. |
144
+ | `clean-room-skill update` | Refresh installed runtime files without onboarding. |
145
+ | `clean-room` | Start the setup wizard for authorized clean-room work. |
146
+ | `preflight` | Record the required goal, policy, output, and controller-mode contract. |
147
+ | `init` | Record run preferences, separated roots, schema profile, and model policy. |
148
+ | `attended` | Start the wizard in attended mode with human review gates. |
149
+ | `unattended` | Start the wizard in bounded unattended mode with finite loop limits. |
150
+ | `resume` | Continue an existing run from durable artifacts. |
151
+ | `start-over` | Non-destructively archive or quarantine current artifacts and restart. |
152
+ | `refocus` | Audit a run and route it back to missed gates without adding scope. |
238
153
 
239
- Set it to path-separated, line-oriented files containing private source package, module, class, function, method, variable, constant, field, or other internal identifiers to reject from clean artifacts. Blank lines and `#` comments are ignored. Files are bounded to 1,000,000 bytes each, 20,000 total terms, and 512 characters per term. Keep those files outside clean-role readable roots and do not paste their contents into model-visible artifacts.
154
+ Reference files:
240
155
 
241
- Do not grant shell-style tools to clean-room role sessions. Shell access can bypass path-aware read and write hooks.
156
+ - [docs/REFERENCE.md](docs/REFERENCE.md): CLI flags, hook modes, troubleshooting, and local verification.
157
+ - [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md): operating model, roles, environment, guardrails, and flow details.
158
+ - [skills/clean-room/references/PROCESS.md](skills/clean-room/references/PROCESS.md): detailed clean-room process.
159
+ - [skills/clean-room/references/LEAKAGE-RULES.md](skills/clean-room/references/LEAKAGE-RULES.md): clean handoff rules.
242
160
 
243
- For multi-file scopes, run `skills/clean-room/scripts/build_source_index.py` as controller preflight before clean-room role sessions. Store `source-index.json` under `CLEAN_ROOM_CONTAMINATED_ARTIFACT_ROOTS`, or pass `--contaminated-artifact-root` explicitly. The script refuses `--output` outside those roots. It is contaminated-only and must not be included in clean handoff packages.
161
+ ## Development
244
162
 
245
- Optional AST/indexing helpers are checked before the controller loop, not from clean-room role sessions:
163
+ Install dependencies:
246
164
 
247
165
  ```bash
248
- python3 skills/clean-room/scripts/clean_room_tool_manager.py --status
166
+ npm ci --ignore-scripts
249
167
  ```
250
168
 
251
- `--status` is stat-only by default. Use `--probe-tools` only when you want it to execute discovered tools with version commands:
169
+ Run tests:
252
170
 
253
171
  ```bash
254
- python3 skills/clean-room/scripts/clean_room_tool_manager.py --status --probe-tools
172
+ npm test
255
173
  ```
256
174
 
257
- Local helper installs are explicit and version-pinned, and they write to `~/.cache/re-skills/clean-room-tools/`:
175
+ Run installer tests only:
258
176
 
259
177
  ```bash
260
- python3 skills/clean-room/scripts/clean_room_tool_manager.py --install-local ast-grep --version <exact-version>
178
+ npm run test:install
261
179
  ```
262
180
 
263
- Target-project `.local/bin`, `.bin`, and `node_modules/.bin` are ignored unless the controller opts into `--allow-working-project-tools` or `RE_SKILLS_TRUST_PROJECT_TOOLS=1`. Npm prefix/global discovery also requires `--probe-tools` because it executes `npm`.
264
-
265
- ## Controller Modes
266
-
267
- Missing `controller_policy` means `attended`.
268
-
269
- - `attended`: agent zero pauses for human review at scope gate, clean handoff, QC deltas, blocked units, and final coverage.
270
- - `unattended`: agent zero runs a bounded controller loop. It reloads durable artifacts each iteration, selects at most one pending or gap unit, starts each role from fresh context with the required environment block, validates before advancing state, and stops on any configured safety or ambiguity condition.
271
-
272
- Agent zero generates the durable tasklist as neutral `task-manifest.json` `units`. For larger scopes, it may use `source-index.json` recommended batches and record `source_index_ref` plus per-unit `source_index_refs`. Progress is tracked in `coverage-ledger.json`, `evidence-ledger.json`, `qc-report.json`, and abstract delta tickets, not in prior chat history.
273
-
274
- ## Artifacts
275
-
276
- The schema contract lives in `skills/clean-room/assets/`:
277
-
278
- - `task-manifest.schema.json`
279
- - `source-index.schema.json`
280
- - `coverage-ledger.schema.json`
281
- - `evidence-ledger.schema.json`
282
- - `handoff-package.schema.json`
283
- - `behavior-spec.schema.json`
284
- - `skeleton-manifest.schema.json`
285
- - `qc-report.schema.json`
286
- - `contamination-incident.schema.json`
287
-
288
- Example artifact shapes are in `skills/clean-room/examples/minimal-spec-package/`. They are examples only, not outputs from a real source review.
289
-
290
- ## Workflow
291
-
292
- 1. Record authorization, scope, prohibited actions, evidence handling, and role root paths in `task-manifest.json`.
293
- 2. Record the user's selected target profile and Agent 0-3 pipeline in `task-manifest.json`.
294
- 3. Run source index preflight when the source scope needs relationship-aware batching.
295
- 4. Decompose the source scope into bounded, neutral `task-manifest.json` units. One unit may map to one source-index batch or, for large files, one preflight segment.
296
- 5. Write contaminated-side behavior specs from observed behavior, public contracts, states, errors, invariants, and test scenarios.
297
- 6. Scrub specs using `skills/clean-room/references/LEAKAGE-RULES.md`.
298
- 7. Move only approved structured artifacts into the clean workspace through `handoff-package.json`. Do not include `source-index.json`.
299
- 8. Build or merge the clean schema base and `skeleton-manifest.json` from clean specs, target profile, and target constraints.
300
- 9. Produce `qc-report.json` with schema status, leakage status, gaps, and testability notes.
301
- 10. Verify coverage from the contaminated side and repeat only with abstract delta tickets.
302
- 11. Stop at the spec package. Do not implement replacement code in this plugin workflow.
303
-
304
- ## Hook Guardrails
305
-
306
- Hook scaffolding lives in `hooks/` and is declared by `hooks/hooks.json`.
307
-
308
- `hooks/hooks.json` routes through `hooks/clean-room-hook.py`. In safe mode, the wrapper exits successfully unless `CLEAN_ROOM_HOOK_ENFORCE=1` or clean-room environment variables are present. In strict mode, it runs the configured checks immediately and fails closed when required role or path configuration is missing.
309
-
310
- `hooks/hooks.json` uses commands relative to the plugin package root, such as `python3 hooks/clean-room-hook.py --mode safe ...`. Confirm the host executes plugin hooks from that directory during install smoke tests.
311
-
312
- - `clean-room-hook.py`: safe/strict dispatch wrapper for the policy checks below.
313
- - `require-clean-room-env.py`: fails closed when required role and root environment is missing.
314
- - `deny-clean-room-shell.py`: denies shell-style tools for clean-room role sessions.
315
- - `deny-clean-source-read.py`: denies clean-role reads from source roots and unapproved paths.
316
- - `deny-contaminated-clean-write.py`: enforces role write roots. Clean roles write only under clean roots; contaminated roles write only under contaminated artifact roots.
317
- - `check-artifact-leakage.py`: scans clean artifacts for high-risk leakage markers, source-like identifiers, and optional private identifier denylist matches.
318
- - `validate-json-schema.py`: checks JSON syntax and common bundled clean-room schema constraints, including the conditional and bounded fields used by these schemas. Under clean roots, unknown JSON artifacts are rejected unless explicitly allowlisted through `CLEAN_ROOM_AUXILIARY_JSON_ALLOWLIST`. It is a lightweight guardrail, not a full JSON Schema 2020-12 validator.
319
- - `validate-handoff-package.py`: verifies handoff artifact paths stay under clean roots, do not point into source or contaminated roots, do not include `source-index.json`, and match declared `sha256` values.
320
-
321
- These scripts are guardrail and audit support. They are not a substitute for separate workspaces and role isolation.
322
-
323
- For release-quality schema assurance, run a full JSON Schema validator in addition to the bundled lightweight hook.
324
-
325
- ## References
326
-
327
- - `skills/clean-room/SKILL.md`: main skill instructions.
328
- - `skills/clean-room/references/PROCESS.md`: detailed process.
329
- - `skills/clean-room/references/LEAKAGE-RULES.md`: clean handoff rules.
330
- - `skills/clean-room/references/SPEC-SCHEMA.md`: artifact schema guidance.
331
- - `skills/clean-room/references/TARGET-LANGUAGE-GUIDE.md`: target constraint guidance.
332
-
333
- ## Dry Run
334
-
335
- From the repository root, run a minimal hook smoke test before relying on the workflow:
181
+ Run the full local verifier:
336
182
 
337
183
  ```bash
338
- export CLEAN_ROOM_ROLE=clean-qa-editor
339
- export CLEAN_ROOM_SOURCE_ROOTS="$PWD/source"
340
- export CLEAN_ROOM_CONTAMINATED_ARTIFACT_ROOTS="$PWD/contaminated-artifacts"
341
- export CLEAN_ROOM_CLEAN_ROOTS="$PWD/skills/clean-room/examples/minimal-spec-package"
342
- export CLEAN_ROOM_ALLOWED_READ_ROOTS=""
343
- export CLEAN_ROOM_SCHEMA_DIR="$PWD/skills/clean-room/assets"
184
+ npm run verify
185
+ ```
344
186
 
345
- printf '{"tool_input":{"file_path":"%s"}}' "$PWD/skills/clean-room/examples/minimal-spec-package/behavior-spec.json" \
346
- | python3 hooks/check-artifact-leakage.py
187
+ Documentation-only changes usually need review plus link/path checks, not the full test suite.
347
188
 
348
- printf '{"tool_input":{"file_path":"%s"}}' "$PWD/skills/clean-room/examples/minimal-spec-package/behavior-spec.json" \
349
- | python3 hooks/validate-json-schema.py
189
+ Useful development checks:
350
190
 
351
- python3 hooks/clean-room-hook.py --mode safe --check require-clean-room-env.py </dev/null
191
+ ```bash
192
+ node --check bin/install.js
193
+ node --test tests/run.test.js
194
+ npm pack --dry-run
352
195
  ```
353
196
 
354
- ## Local Verification
355
-
356
- After changing plugin metadata, hooks, schemas, or skill instructions, run the relevant checks from the plugin package root:
197
+ Python schema validation requires `jsonschema` with format extras:
357
198
 
358
199
  ```bash
359
- python3 -m json.tool plugin.json >/dev/null
360
- python3 -m json.tool .codex-plugin/plugin.json >/dev/null
361
- python3 -m json.tool .claude-plugin/plugin.json >/dev/null
362
- python3 -m json.tool hooks/hooks.json >/dev/null
363
- python3 -m py_compile hooks/*.py
364
- python3 -m py_compile skills/clean-room/scripts/*.py
365
- node --test
366
- npm pack --dry-run
367
- node bin/install.js --dry-run --all --global
368
- python3 skills/clean-room/scripts/build_source_index.py --help
369
- # Optional, if skill-creator quick_validate is installed:
370
- quick_validate skills/attended
371
- quick_validate skills/clean-room
372
- quick_validate skills/unattended
373
- for f in skills/clean-room/examples/minimal-spec-package/*.json; do printf '{"tool_input":{"file_path":"%s"}}' "$PWD/$f" | CLEAN_ROOM_SCHEMA_DIR="$PWD/skills/clean-room/assets" python3 hooks/validate-json-schema.py || exit 1; done
374
- for f in skills/clean-room/examples/minimal-spec-package/*.json; do if [ "$(basename "$f")" = source-index.json ]; then continue; fi; printf '{"tool_input":{"file_path":"%s"}}' "$PWD/$f" | CLEAN_ROOM_CLEAN_ROOTS="$PWD/skills/clean-room/examples/minimal-spec-package" python3 hooks/check-artifact-leakage.py || exit 1; done
375
- find . -maxdepth 4 -type d -name bin -print
200
+ python3 -m venv .venv
201
+ .venv/bin/python -m pip install "jsonschema[format]>=4.18,<5"
202
+ .venv/bin/python tests/validate_jsonschema.py
376
203
  ```
204
+
205
+ Use `st` for repository search.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: clean-architect
3
- description: Manages the selected clean schema base and organizes approved clean behavioral specs into target-neutral skeleton manifests without reading contaminated source or chat history.
3
+ description: Plans clean implementation from approved clean behavioral specs and the clean destination foundation without reading contaminated source or chat history.
4
4
  tools: Read, Write, Edit, Glob
5
5
  ---
6
6
 
@@ -8,20 +8,36 @@ tools: Read, Write, Edit, Glob
8
8
 
9
9
  This role is Agent 2 in the clean-room pipeline.
10
10
 
11
- Operate only in the clean domain. Read approved clean artifacts and explicitly configured public or destination constraint roots. Write only under `CLEAN_ROOM_CLEAN_ROOTS`. Do not read source workspaces, contaminated ledgers, or contaminated chat history.
11
+ Operate only in the clean domain from `CLEAN_ROOM_CLEAN_ROOTS` as the working directory. Read approved clean artifacts, `CLEAN_ROOM_IMPLEMENTATION_ROOTS`, and explicitly configured public or destination constraint roots. Write only under `CLEAN_ROOM_CLEAN_ROOTS`. Do not write code. Do not read source workspaces, contaminated ledgers, contaminated chat history, or the full `task-manifest.json`.
12
12
 
13
- Before tool use, confirm this session has `CLEAN_ROOM_ROLE=clean-architect`, `CLEAN_ROOM_CLEAN_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.
13
+ Before tool use, confirm this session has `CLEAN_ROOM_ROLE=clean-architect`, `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
14
 
15
15
  Do not use shell-style tools in this role.
16
16
 
17
+ ## Required Handoff Inputs
18
+
19
+ Before planning, verify:
20
+
21
+ - `clean-run-context.json` is present and valid.
22
+ - `clean-run-context.json` includes clean-safe `goal_contract` fields and `code_hygiene_policy`.
23
+ - approved `handoff-package.json` and approved behavior specs are present.
24
+ - the implementation root is available through `CLEAN_ROOM_IMPLEMENTATION_ROOTS`.
25
+
26
+ Stop if only a full `task-manifest.json`, full `preflight-goal.json`, source index, contaminated ledgers, source paths, or direct Agent 0 chat is provided.
27
+
17
28
  Responsibilities:
18
29
 
19
- - Manage the selected clean schema base from `task-manifest.json` `format_selection`.
30
+ - Treat `clean-run-context.json` as the only run context from Agent 0; stop if only a full `task-manifest.json` is provided.
31
+ - 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.
20
32
  - Merge only approved handoff artifacts into the selected clean schema base.
21
- - Build `skeleton-manifest.json` from approved behavior specs.
22
- - Keep target language generic unless the user or destination repo supplies a target.
23
- - Map specs to clean implementation areas without mirroring private source layout.
24
- - Record public contract refs, dependency constraints, test mappings, and open decisions.
33
+ - Read the clean destination foundation under `CLEAN_ROOM_IMPLEMENTATION_ROOTS` to identify local project structure, test conventions, public APIs, dependencies, and constraints.
34
+ - Build or update `implementation-plan.json` as the primary output for code-development runs.
35
+ - Carry the preflight-derived code hygiene policy into `implementation-plan.json`.
36
+ - Keep `skeleton-manifest.json` valid for compatibility when the run expects it, but do not treat it as the implementation plan.
37
+ - Map approved specs to destination files, test files, work items, argv-array verification commands, risks, and acceptance criteria using only relative implementation-root paths.
38
+ - Preserve public contract refs, dependency constraints, test mappings, and open decisions.
39
+ - Preserve source-test-derived scenarios as clean test obligations for equal output without copying source test structure.
25
40
  - Preserve only public compatibility names that already have recorded compatibility reasons.
41
+ - Mark work blocked instead of guessing when a destination constraint or clean behavior requirement is ambiguous.
26
42
 
27
43
  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,36 @@
1
+ ---
2
+ name: clean-implementer-verifier-shell
3
+ description: Shell-capable Agent 3 profile for isolated clean implementation verification homes.
4
+ tools: Read, Write, Edit, Glob, Bash
5
+ ---
6
+
7
+ # Clean Implementer Verifier Shell
8
+
9
+ This is the explicit shell-capable Agent 3 variant. Use it only in a dedicated clean-room home with strict hooks installed, source roots unmounted where practical, and `CLEAN_ROOM_ALLOW_AGENT3_SHELL=1` set deliberately.
10
+
11
+ Operate only in the clean domain. Read approved clean artifacts, `CLEAN_ROOM_IMPLEMENTATION_ROOTS`, and explicitly configured public or destination constraint roots only. Write clean reports under `CLEAN_ROOM_CLEAN_ROOTS`. Write code, tests, fixtures, and destination project files only under `CLEAN_ROOM_IMPLEMENTATION_ROOTS`. Do not read source workspaces, contaminated ledgers, contaminated chat history, or the full `task-manifest.json`.
12
+
13
+ Before tool use, confirm this session has `CLEAN_ROOM_ROLE=clean-qa-editor`, `CLEAN_ROOM_CLEAN_ROOTS`, `CLEAN_ROOM_IMPLEMENTATION_ROOTS`, `CLEAN_ROOM_SOURCE_ROOTS`, `CLEAN_ROOM_CONTAMINATED_ARTIFACT_ROOTS`, `CLEAN_ROOM_ALLOWED_READ_ROOTS`, `CLEAN_ROOM_SCHEMA_DIR`, and `CLEAN_ROOM_ALLOW_AGENT3_SHELL=1`. Treat missing environment as a stop condition.
14
+
15
+ Use `Bash` only for bounded verification commands from `implementation-plan.json`, through the installed `agent3-verification-runner.py`, with the command working directory inside `CLEAN_ROOM_IMPLEMENTATION_ROOTS`. Docker or Podman verification may be selected only with the runner's `--backend` flag and clean-safe container metadata. Treat shell access as verification support, not as a way to inspect source or contaminated roots.
16
+
17
+ Responsibilities:
18
+
19
+ - Validate clean artifacts against the schema assets.
20
+ - Validate `clean-run-context.json` before using run preferences, model preferences, clean-safe rules, or clean artifact paths.
21
+ - 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.
22
+ - Read `implementation-plan.json` and implement each unblocked work item in the clean implementation root.
23
+ - Follow destination project conventions discovered from clean implementation files; do not import source-derived structure, names, comments, or pseudocode.
24
+ - Add or update tests required by the implementation plan.
25
+ - Run bounded verification commands from the plan through the verification runner.
26
+ - Loop over planned work items until all are complete, blocked, or quarantined.
27
+ - Do not report progress, ask Agent 0 for guidance, or send partial findings while work remains in progress.
28
+ - Review leakage risk using `LEAKAGE-RULES.md`.
29
+ - Treat package, module, class, function, method, variable, constant, and field names as leakage unless the artifact records them as public compatibility surface.
30
+ - Record implementation status, changed relative paths, verification results, blockers, contamination incidents, and required reruns in `implementation-report.json`.
31
+ - Keep `qc-report.json` updated for schema, leakage, and clean artifact status when the run expects it.
32
+ - Flag missing source-test parity, missing equal-output assertions, and mismatches between specs, implementation plan, public contracts, and test obligations.
33
+ - 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.
34
+ - Edit clean wording for clarity without adding new source facts.
35
+
36
+ If contamination is found, mark the artifact quarantined and require regeneration from the contaminated side.