opencode-agent-orchestration-kit 1.0.32 → 1.0.37

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 (88) hide show
  1. package/README.md +73 -4
  2. package/SECURITY.md +7 -0
  3. package/docs/cli.md +100 -0
  4. package/docs/installation.md +25 -5
  5. package/docs/quickstart.md +1 -1
  6. package/docs/releases/v1.0.33.md +72 -0
  7. package/docs/releases/v1.0.34.md +59 -0
  8. package/docs/releases/v1.0.35.md +62 -0
  9. package/docs/releases/v1.0.36.md +58 -0
  10. package/docs/releases/v1.0.37.md +53 -0
  11. package/docs/security.md +4 -0
  12. package/docs/supply-chain.md +9 -5
  13. package/docs/threat-model.md +244 -0
  14. package/docs/use-cases/README.md +31 -0
  15. package/docs/use-cases/direct-label-change/README.md +76 -0
  16. package/docs/use-cases/direct-label-change/before/package.json +8 -0
  17. package/docs/use-cases/direct-label-change/before/src/settings-label.mjs +1 -0
  18. package/docs/use-cases/direct-label-change/before/test/settings-label.test.mjs +8 -0
  19. package/docs/use-cases/direct-label-change/case.json +118 -0
  20. package/docs/use-cases/direct-label-change/expected/package.json +8 -0
  21. package/docs/use-cases/direct-label-change/expected/src/settings-label.mjs +1 -0
  22. package/docs/use-cases/direct-label-change/expected/test/settings-label.test.mjs +8 -0
  23. package/docs/use-cases/feature-tag-normalizer/README.md +78 -0
  24. package/docs/use-cases/feature-tag-normalizer/before/package.json +8 -0
  25. package/docs/use-cases/feature-tag-normalizer/before/src/normalize-tags.mjs +3 -0
  26. package/docs/use-cases/feature-tag-normalizer/before/test/normalize-tags.test.mjs +13 -0
  27. package/docs/use-cases/feature-tag-normalizer/case.json +119 -0
  28. package/docs/use-cases/feature-tag-normalizer/expected/package.json +8 -0
  29. package/docs/use-cases/feature-tag-normalizer/expected/src/normalize-tags.mjs +14 -0
  30. package/docs/use-cases/feature-tag-normalizer/expected/test/normalize-tags.test.mjs +18 -0
  31. package/docs/workflows.md +6 -0
  32. package/opencode/agents/lead.md +11 -2
  33. package/opencode/agents/review_api.md +26 -9
  34. package/opencode/agents/review_coordinator.md +60 -68
  35. package/opencode/agents/review_quality.md +27 -11
  36. package/opencode/agents/review_security.md +26 -10
  37. package/opencode/agents/review_tests.md +26 -9
  38. package/opencode/agents/reviewer.md +95 -80
  39. package/opencode/commands/autonomous.md +75 -0
  40. package/opencode/commands/evolve.md +3 -1
  41. package/opencode/commands/feature.md +6 -2
  42. package/opencode/commands/loop.md +12 -8
  43. package/opencode/commands/review-orchestrated.md +26 -24
  44. package/opencode/commands/review-preflight.md +8 -7
  45. package/opencode/commands/review.md +27 -10
  46. package/opencode/docs/ai/harness/README.md +5 -0
  47. package/opencode/docs/ai/harness/agents.md +27 -3
  48. package/opencode/docs/ai/harness/checks.md +18 -0
  49. package/opencode/docs/ai/harness/commands.md +44 -0
  50. package/opencode/docs/ai/harness/orchestrated-review.md +8 -1
  51. package/opencode/docs/ai/harness/orchestration-contracts.json +924 -0
  52. package/opencode/package-lock.json +14 -8
  53. package/opencode/package.json +1 -0
  54. package/opencode/plugins/shell-export-guard.ts +23 -0
  55. package/opencode/scripts/adversarial-harness.test.mjs +5 -2
  56. package/opencode/scripts/check-harness.mjs +873 -18
  57. package/opencode/scripts/check-harness.test.mjs +562 -0
  58. package/opencode/scripts/loop-state.mjs +88 -14
  59. package/opencode/scripts/loop-state.test.mjs +82 -5
  60. package/opencode/scripts/review-orchestrated-prepare.mjs +18 -1
  61. package/opencode/scripts/review-orchestrated-prepare.test.mjs +49 -0
  62. package/opencode/scripts/shell-export-policy.d.mts +4 -0
  63. package/opencode/scripts/shell-export-policy.mjs +272 -0
  64. package/opencode/scripts/shell-export-policy.test.mjs +96 -0
  65. package/opencode/skills/code-review-and-quality/SKILL.md +63 -321
  66. package/opencode/skills/code-review-and-quality/references/profiles/backend-clean-ddd-cqrs.md +60 -0
  67. package/opencode/skills/code-review-and-quality/references/profiles/backend.md +54 -0
  68. package/opencode/skills/code-review-and-quality/references/profiles/frontend-clean-layered.md +60 -0
  69. package/opencode/skills/code-review-and-quality/references/profiles/frontend.md +62 -0
  70. package/opencode/skills/code-review-and-quality/references/review-policy.md +258 -0
  71. package/package.json +5 -2
  72. package/scripts/check-supply-chain.mjs +16 -2
  73. package/scripts/check-supply-chain.test.mjs +52 -1
  74. package/scripts/check-threat-model.mjs +421 -0
  75. package/scripts/check-threat-model.test.mjs +304 -0
  76. package/scripts/check-use-cases.mjs +501 -0
  77. package/scripts/check-use-cases.test.mjs +225 -0
  78. package/scripts/check.sh +55 -1
  79. package/scripts/install-smoke.sh +24 -1
  80. package/scripts/manage-installation.mjs +567 -25
  81. package/scripts/manage-installation.test.mjs +418 -0
  82. package/scripts/oak.mjs +246 -0
  83. package/scripts/oak.test.mjs +329 -0
  84. package/scripts/package-smoke.mjs +57 -0
  85. package/scripts/package-smoke.test.mjs +75 -2
  86. package/scripts/version.mjs +1 -0
  87. package/scripts/version.test.mjs +3 -2
  88. package/supply-chain.json +1 -0
@@ -64,6 +64,394 @@ function writeRouterScenarios(cwd, scenarios) {
64
64
  );
65
65
  }
66
66
 
67
+ const orchestrationContractRel =
68
+ "docs/ai/harness/orchestration-contracts.json";
69
+
70
+ function readOrchestrationContract(cwd) {
71
+ return JSON.parse(
72
+ fs.readFileSync(path.join(cwd, orchestrationContractRel), "utf8"),
73
+ );
74
+ }
75
+
76
+ function writeOrchestrationContract(cwd, contract) {
77
+ write(
78
+ orchestrationContractRel,
79
+ `${JSON.stringify(contract, null, 2)}\n`,
80
+ cwd,
81
+ );
82
+ }
83
+
84
+ test("orchestration contract file is required", () => {
85
+ const cwd = makeFixture();
86
+ try {
87
+ fs.rmSync(path.join(cwd, orchestrationContractRel), { force: true });
88
+
89
+ const result = runHarness(cwd);
90
+ assert.notEqual(result.status, 0, "checker accepted a missing orchestration contract");
91
+ assert.match(result.stderr, /missing orchestration contract/);
92
+ } finally {
93
+ fs.rmSync(cwd, { recursive: true, force: true });
94
+ }
95
+ });
96
+
97
+ test("shell export guard surfaces are required", () => {
98
+ const cwd = makeFixture();
99
+ try {
100
+ fs.rmSync(path.join(cwd, "plugins/shell-export-guard.ts"));
101
+
102
+ const result = runHarness(cwd);
103
+ assert.notEqual(result.status, 0, "checker accepted a missing shell export guard");
104
+ assert.match(result.stderr, /plugins\/shell-export-guard\.ts: missing shell export guard surface/);
105
+ } finally {
106
+ fs.rmSync(cwd, { recursive: true, force: true });
107
+ }
108
+ });
109
+
110
+ test("orchestration contract file must be regular and non-symlink", () => {
111
+ const cwd = makeFixture();
112
+ const external = path.join(cwd, "external-contract.json");
113
+ try {
114
+ fs.writeFileSync(external, "{}\n");
115
+ fs.rmSync(path.join(cwd, orchestrationContractRel));
116
+ fs.symlinkSync(external, path.join(cwd, orchestrationContractRel));
117
+
118
+ const result = runHarness(cwd);
119
+ assert.notEqual(result.status, 0, "checker followed a symlinked orchestration contract");
120
+ assert.match(result.stderr, /regular non-symlink/);
121
+ } finally {
122
+ fs.rmSync(cwd, { recursive: true, force: true });
123
+ }
124
+ });
125
+
126
+ test("orchestration contract rejects an unknown top-level key", () => {
127
+ const cwd = makeFixture();
128
+ try {
129
+ const contract = readOrchestrationContract(cwd);
130
+ writeOrchestrationContract(cwd, { ...contract, scheduler: {} });
131
+
132
+ const result = runHarness(cwd);
133
+ assert.notEqual(result.status, 0, "checker accepted an unknown orchestration key");
134
+ assert.match(result.stderr, /must contain exactly/);
135
+ } finally {
136
+ fs.rmSync(cwd, { recursive: true, force: true });
137
+ }
138
+ });
139
+
140
+ test("orchestration contract header is closed", async (t) => {
141
+ for (const [label, mutate, pattern] of [
142
+ [
143
+ "schema version",
144
+ (contract) => ({ ...contract, schema_version: 2 }),
145
+ /schema_version must be 1/,
146
+ ],
147
+ [
148
+ "contract identity",
149
+ (contract) => ({ ...contract, contract_id: "other-contract" }),
150
+ /contract_id must be oak-orchestration/,
151
+ ],
152
+ ]) {
153
+ await t.test(label, () => {
154
+ const cwd = makeFixture();
155
+ try {
156
+ writeOrchestrationContract(cwd, mutate(readOrchestrationContract(cwd)));
157
+ const result = runHarness(cwd);
158
+ assert.notEqual(result.status, 0, `checker accepted invalid ${label}`);
159
+ assert.match(result.stderr, pattern);
160
+ } finally {
161
+ fs.rmSync(cwd, { recursive: true, force: true });
162
+ }
163
+ });
164
+ }
165
+ });
166
+
167
+ test("orchestration contract requires the canonical evidence catalog", () => {
168
+ const cwd = makeFixture();
169
+ try {
170
+ const contract = readOrchestrationContract(cwd);
171
+ writeOrchestrationContract(cwd, {
172
+ ...contract,
173
+ evidence_types: ["static_contract"],
174
+ });
175
+
176
+ const result = runHarness(cwd);
177
+ assert.notEqual(result.status, 0, "checker accepted an incomplete evidence catalog");
178
+ assert.match(result.stderr, /evidence_types must match the canonical catalog/);
179
+ } finally {
180
+ fs.rmSync(cwd, { recursive: true, force: true });
181
+ }
182
+ });
183
+
184
+ test("orchestration contract requires every harness agent", () => {
185
+ const cwd = makeFixture();
186
+ try {
187
+ const contract = readOrchestrationContract(cwd);
188
+ writeOrchestrationContract(cwd, { ...contract, agents: [] });
189
+
190
+ const result = runHarness(cwd);
191
+ assert.notEqual(result.status, 0, "checker accepted an empty agent catalog");
192
+ assert.match(result.stderr, /agent catalog must match harness agents/);
193
+ } finally {
194
+ fs.rmSync(cwd, { recursive: true, force: true });
195
+ }
196
+ });
197
+
198
+ test("orchestration agent contracts match frontmatter authority", async (t) => {
199
+ for (const [label, mutate, pattern] of [
200
+ [
201
+ "mode",
202
+ (agent) => ({ ...agent, mode: "subagent" }),
203
+ /agent lead mode must match frontmatter/,
204
+ ],
205
+ [
206
+ "write permission",
207
+ (agent) => ({
208
+ ...agent,
209
+ permission_invariants: {
210
+ ...agent.permission_invariants,
211
+ repository_write: "allow",
212
+ },
213
+ }),
214
+ /agent lead repository_write must match frontmatter/,
215
+ ],
216
+ [
217
+ "delegation allowlist",
218
+ (agent) => ({
219
+ ...agent,
220
+ delegates_to: agent.delegates_to.filter((id) => id !== "developer"),
221
+ }),
222
+ /agent lead delegates_to must match selected profile/,
223
+ ],
224
+ [
225
+ "closed shape",
226
+ (agent) => ({ ...agent, prompt: "forbidden" }),
227
+ /agent lead must contain exactly/,
228
+ ],
229
+ ]) {
230
+ await t.test(label, () => {
231
+ const cwd = makeFixture();
232
+ try {
233
+ const contract = readOrchestrationContract(cwd);
234
+ contract.agents = contract.agents.map((agent) =>
235
+ agent.id === "lead" ? mutate(agent) : agent
236
+ );
237
+ writeOrchestrationContract(cwd, contract);
238
+
239
+ const result = runHarness(cwd);
240
+ assert.notEqual(result.status, 0, `checker accepted invalid agent ${label}`);
241
+ assert.match(result.stderr, pattern);
242
+ } finally {
243
+ fs.rmSync(cwd, { recursive: true, force: true });
244
+ }
245
+ });
246
+ }
247
+ });
248
+
249
+ test("orchestration contract requires one exact inventory profile", () => {
250
+ const cwd = makeFixture();
251
+ try {
252
+ const contract = readOrchestrationContract(cwd);
253
+ writeOrchestrationContract(cwd, { ...contract, profiles: {} });
254
+
255
+ const result = runHarness(cwd);
256
+ assert.notEqual(result.status, 0, "checker accepted no inventory profile");
257
+ assert.match(result.stderr, /must select exactly one inventory profile/);
258
+ } finally {
259
+ fs.rmSync(cwd, { recursive: true, force: true });
260
+ }
261
+ });
262
+
263
+ test("orchestration profile preserves surface-specific delegations", () => {
264
+ const cwd = makeFixture();
265
+ try {
266
+ const contract = readOrchestrationContract(cwd);
267
+ contract.profiles.public.delegation_extensions = {
268
+ scoper: ["debugger"],
269
+ };
270
+ writeOrchestrationContract(cwd, contract);
271
+
272
+ const result = runHarness(cwd);
273
+ assert.notEqual(result.status, 0, "checker accepted a foreign delegation extension");
274
+ assert.match(result.stderr, /agent scoper delegates_to must match selected profile/);
275
+ } finally {
276
+ fs.rmSync(cwd, { recursive: true, force: true });
277
+ }
278
+ });
279
+
280
+ test("orchestration command contracts match command frontmatter", async (t) => {
281
+ for (const [label, mutate, pattern] of [
282
+ [
283
+ "root agent",
284
+ (command) => ({ ...command, root_agent: "developer" }),
285
+ /command feature root_agent must match frontmatter/,
286
+ ],
287
+ [
288
+ "subtask",
289
+ (command) => ({ ...command, subtask: true }),
290
+ /command feature subtask must match frontmatter/,
291
+ ],
292
+ [
293
+ "closed shape",
294
+ (command) => ({ ...command, prompt: "forbidden" }),
295
+ /command feature must contain exactly/,
296
+ ],
297
+ ]) {
298
+ await t.test(label, () => {
299
+ const cwd = makeFixture();
300
+ try {
301
+ const contract = readOrchestrationContract(cwd);
302
+ contract.commands = contract.commands.map((command) =>
303
+ command.id === "feature" ? mutate(command) : command
304
+ );
305
+ writeOrchestrationContract(cwd, contract);
306
+
307
+ const result = runHarness(cwd);
308
+ assert.notEqual(result.status, 0, `checker accepted invalid command ${label}`);
309
+ assert.match(result.stderr, pattern);
310
+ } finally {
311
+ fs.rmSync(cwd, { recursive: true, force: true });
312
+ }
313
+ });
314
+ }
315
+ });
316
+
317
+ test("orchestration workflow references declared agents", () => {
318
+ const cwd = makeFixture();
319
+ try {
320
+ const contract = readOrchestrationContract(cwd);
321
+ contract.workflows = [{
322
+ id: "invalid-flow",
323
+ entrypoints: ["freeform"],
324
+ stages: [{ agent: "ghost", requirement: "required" }],
325
+ barriers: [],
326
+ retry_policy: null,
327
+ completion_authority: { kind: "result-contract", agent: null },
328
+ required_evidence: ["static_contract"],
329
+ adaptive: true,
330
+ }];
331
+ writeOrchestrationContract(cwd, contract);
332
+
333
+ const result = runHarness(cwd);
334
+ assert.notEqual(result.status, 0, "checker accepted an unknown stage agent");
335
+ assert.match(result.stderr, /workflow invalid-flow stage agent must reference an agent/);
336
+ } finally {
337
+ fs.rmSync(cwd, { recursive: true, force: true });
338
+ }
339
+ });
340
+
341
+ test("orchestration retry limits are bounded", () => {
342
+ const cwd = makeFixture();
343
+ try {
344
+ const contract = readOrchestrationContract(cwd);
345
+ const policy = contract.retry_policies.find((candidate) => candidate.id === "developer-default");
346
+ policy.max_attempts = 7;
347
+ writeOrchestrationContract(cwd, contract);
348
+
349
+ const result = runHarness(cwd);
350
+ assert.notEqual(result.status, 0, "checker accepted an unbounded retry policy");
351
+ assert.match(result.stderr, /retry developer-default max_attempts must be between 1 and 6/);
352
+ } finally {
353
+ fs.rmSync(cwd, { recursive: true, force: true });
354
+ }
355
+ });
356
+
357
+ test("orchestration routing requires known targets", () => {
358
+ const cwd = makeFixture();
359
+ try {
360
+ const contract = readOrchestrationContract(cwd);
361
+ contract.routing_rules = [{
362
+ id: "invalid-route",
363
+ target: "ghost",
364
+ precedence: 1,
365
+ }];
366
+ writeOrchestrationContract(cwd, contract);
367
+
368
+ const result = runHarness(cwd);
369
+ assert.notEqual(result.status, 0, "checker accepted an unknown routing target");
370
+ assert.match(result.stderr, /routing rule invalid-route target must reference an agent or ask-user/);
371
+ } finally {
372
+ fs.rmSync(cwd, { recursive: true, force: true });
373
+ }
374
+ });
375
+
376
+ test("orchestration catalog preserves approved behavior", async (t) => {
377
+ for (const [label, mutate, pattern] of [
378
+ [
379
+ "command workflow",
380
+ (contract) => ({
381
+ ...contract,
382
+ commands: contract.commands.map((command) =>
383
+ command.id === "feature" ? { ...command, workflow: "plan" } : command
384
+ ),
385
+ }),
386
+ /command feature workflow must match its entrypoint/,
387
+ ],
388
+ [
389
+ "required workflow stage",
390
+ (contract) => ({
391
+ ...contract,
392
+ workflows: contract.workflows.map((workflow) =>
393
+ workflow.id === "plan"
394
+ ? { ...workflow, stages: workflow.stages.filter((stage) => stage.agent !== "specifier") }
395
+ : workflow
396
+ ),
397
+ }),
398
+ /workflow plan stages must match the approved sequence/,
399
+ ],
400
+ [
401
+ "retry invariant",
402
+ (contract) => ({
403
+ ...contract,
404
+ retry_policies: contract.retry_policies.map((policy) =>
405
+ policy.id === "developer-default" ? { ...policy, max_attempts: 3 } : policy
406
+ ),
407
+ }),
408
+ /retry developer-default must match the approved policy/,
409
+ ],
410
+ [
411
+ "routing invariant",
412
+ (contract) => ({
413
+ ...contract,
414
+ routing_rules: contract.routing_rules.map((rule) =>
415
+ rule.id === "reviewable-change" ? { ...rule, target: "developer" } : rule
416
+ ),
417
+ }),
418
+ /routing rule reviewable-change must match the approved rule/,
419
+ ],
420
+ [
421
+ "routing catalog",
422
+ (contract) => ({
423
+ ...contract,
424
+ routing_rules: contract.routing_rules.filter((rule) => rule.id !== "visual-impact"),
425
+ }),
426
+ /routing rule catalog must match the approved catalog/,
427
+ ],
428
+ [
429
+ "completion authority",
430
+ (contract) => ({
431
+ ...contract,
432
+ workflows: contract.workflows.map((workflow) =>
433
+ workflow.id === "loop"
434
+ ? { ...workflow, completion_authority: { kind: "agent", agent: "lead" } }
435
+ : workflow
436
+ ),
437
+ }),
438
+ /workflow loop completion authority must match the approved authority/,
439
+ ],
440
+ ]) {
441
+ await t.test(label, () => {
442
+ const cwd = makeFixture();
443
+ try {
444
+ writeOrchestrationContract(cwd, mutate(readOrchestrationContract(cwd)));
445
+ const result = runHarness(cwd);
446
+ assert.notEqual(result.status, 0, `checker accepted changed ${label}`);
447
+ assert.match(result.stderr, pattern);
448
+ } finally {
449
+ fs.rmSync(cwd, { recursive: true, force: true });
450
+ }
451
+ });
452
+ }
453
+ });
454
+
67
455
  const validLoopCommand = `---
68
456
  description: Run a bounded and verifiable engineering loop.
69
457
  agent: lead
@@ -97,6 +485,107 @@ function writeLoopFixture(cwd, command) {
97
485
  fs.appendFileSync(docsPath, "\n## `/loop`\n");
98
486
  }
99
487
 
488
+ const validAutonomousCommand = `---
489
+ description: Runs a bounded, local autonomous workflow.
490
+ agent: lead
491
+ ---
492
+
493
+ authorization: explicit_command_invocation
494
+ execution_scope: local_checkout_only
495
+ max_iterations_per_invocation: 6
496
+ planned_iteration_budget: task_specific_1_to_6
497
+ hard_safety_ceiling: 6
498
+ completion_authority: reviewer_only
499
+ validation_gate: deterministic_per_iteration
500
+ canonical_state_path: .opencode/loops/<slug>.json
501
+ history_path: .opencode/loops/<slug>.history.jsonl
502
+ lock_path: .opencode/loops/<slug>.lock
503
+ human_view_path: .opencode/loops/<slug>.md
504
+ worktree_mode: prohibited
505
+ scheduling: prohibited
506
+ parallelism: prohibited
507
+ external_writes: prohibited
508
+ auto_commit_push_merge_deploy: prohibited
509
+ reviewer_execution: task_subagent_only
510
+ reviewer_evidence: required_subagent_attestation
511
+
512
+ developer -> reviewer -> developer (state sync)
513
+
514
+ oak state init --root .
515
+ task reviewer
516
+ oak state attest-review --root .
517
+
518
+ Do not create worktrees, schedule runs, execute parallel branches, use network or write-capable MCP connectors, or publish changes.
519
+ two iterations without observable progress
520
+ repeated failure
521
+ Final reviewer approval stops the cycle immediately.
522
+ An explicit schema migration requires renewed human approval before \`oak state resume\`; do not reuse earlier approval.
523
+ `;
524
+
525
+ function writeAutonomousFixture(cwd, command) {
526
+ write("commands/autonomous.md", command, cwd);
527
+ const docsPath = path.join(cwd, "docs/ai/harness/commands.md");
528
+ fs.appendFileSync(docsPath, "\n## `/autonomous`\n");
529
+ }
530
+
531
+ test("harness rejects autonomous work without reviewer-subagent attestation", () => {
532
+ const cwd = makeFixture();
533
+ try {
534
+ writeAutonomousFixture(
535
+ cwd,
536
+ validAutonomousCommand
537
+ .replace("reviewer_execution: task_subagent_only", "reviewer_execution: primary_agent")
538
+ .replace("reviewer_evidence: required_subagent_attestation", "reviewer_evidence: optional"),
539
+ );
540
+
541
+ const result = runHarness(cwd);
542
+ assert.notEqual(result.status, 0, "checker accepted autonomous work without an independent reviewer attestation");
543
+ assert.match(result.stderr, /commands\/autonomous\.md: missing reviewer_execution: task_subagent_only/);
544
+ } finally {
545
+ fs.rmSync(cwd, { recursive: true, force: true });
546
+ }
547
+ });
548
+
549
+ test("harness rejects autonomous work without a bounded task budget and immediate reviewer stop", () => {
550
+ const cwd = makeFixture();
551
+ try {
552
+ writeAutonomousFixture(
553
+ cwd,
554
+ validAutonomousCommand
555
+ .replace("planned_iteration_budget: task_specific_1_to_6", "planned_iteration_budget: fixed")
556
+ .replace("hard_safety_ceiling: 6", "hard_safety_ceiling: none")
557
+ .replace("Final reviewer approval stops the cycle immediately.", "Reviewer approval may continue the cycle."),
558
+ );
559
+
560
+ const result = runHarness(cwd);
561
+ assert.notEqual(result.status, 0, "checker accepted an unbounded autonomous contract");
562
+ assert.match(result.stderr, /commands\/autonomous\.md: missing planned_iteration_budget: task_specific_1_to_6/);
563
+ assert.match(result.stderr, /commands\/autonomous\.md: missing hard_safety_ceiling: 6/);
564
+ assert.match(result.stderr, /commands\/autonomous\.md: missing Final reviewer approval stops the cycle immediately\./);
565
+ } finally {
566
+ fs.rmSync(cwd, { recursive: true, force: true });
567
+ }
568
+ });
569
+
570
+ test("harness rejects autonomous work without renewed approval after a schema migration", () => {
571
+ const cwd = makeFixture();
572
+ try {
573
+ writeAutonomousFixture(
574
+ cwd,
575
+ validAutonomousCommand.replace(
576
+ "An explicit schema migration requires renewed human approval before `oak state resume`; do not reuse earlier approval.",
577
+ "A migration may reuse earlier approval.",
578
+ ),
579
+ );
580
+
581
+ const result = runHarness(cwd);
582
+ assert.notEqual(result.status, 0, "checker accepted schema migration without approval renewal");
583
+ assert.match(result.stderr, /commands\/autonomous\.md: missing An explicit schema migration requires renewed human approval before `oak state resume`/);
584
+ } finally {
585
+ fs.rmSync(cwd, { recursive: true, force: true });
586
+ }
587
+ });
588
+
100
589
  test("adversarial corpus rejects a missing threat", () => {
101
590
  const cwd = makeFixture();
102
591
  try {
@@ -1387,3 +1876,76 @@ test("harness rejects commands.md without Retry Policies section", () => {
1387
1876
  fs.rmSync(cwd, { recursive: true, force: true });
1388
1877
  }
1389
1878
  });
1879
+
1880
+ test("harness rejects a missing canonical review profile", () => {
1881
+ const cwd = makeFixture();
1882
+ try {
1883
+ fs.rmSync(
1884
+ path.join(cwd, "skills/code-review-and-quality/references/profiles/frontend.md"),
1885
+ );
1886
+
1887
+ const result = runHarness(cwd);
1888
+ assert.notEqual(result.status, 0, "checker accepted a missing frontend review profile");
1889
+ assert.match(result.stderr, /frontend\.md: missing canonical review surface/);
1890
+ } finally {
1891
+ fs.rmSync(cwd, { recursive: true, force: true });
1892
+ }
1893
+ });
1894
+
1895
+ test("harness rejects strict architecture routing without explicit declaration", () => {
1896
+ const cwd = makeFixture();
1897
+ try {
1898
+ const rel = "skills/code-review-and-quality/SKILL.md";
1899
+ write(
1900
+ rel,
1901
+ fs.readFileSync(path.join(cwd, rel), "utf8")
1902
+ .replaceAll("explicit declaration", "implicit inference")
1903
+ .replaceAll("layout alone does not activate", "layout activates"),
1904
+ cwd,
1905
+ );
1906
+
1907
+ const result = runHarness(cwd);
1908
+ assert.notEqual(result.status, 0, "checker accepted implicit strict architecture routing");
1909
+ assert.match(result.stderr, /strict architecture profile requires explicit declaration/);
1910
+ } finally {
1911
+ fs.rmSync(cwd, { recursive: true, force: true });
1912
+ }
1913
+ });
1914
+
1915
+ test("harness rejects reviewer without causal final authority", () => {
1916
+ const cwd = makeFixture();
1917
+ try {
1918
+ const rel = "agents/reviewer.md";
1919
+ write(
1920
+ rel,
1921
+ fs.readFileSync(path.join(cwd, rel), "utf8")
1922
+ .replaceAll("causality: required", "causality: omitted"),
1923
+ cwd,
1924
+ );
1925
+
1926
+ const result = runHarness(cwd);
1927
+ assert.notEqual(result.status, 0, "checker accepted reviewer without causality");
1928
+ assert.match(result.stderr, /agents\/reviewer\.md: missing causality: required/);
1929
+ } finally {
1930
+ fs.rmSync(cwd, { recursive: true, force: true });
1931
+ }
1932
+ });
1933
+
1934
+ test("harness rejects a specialist that claims a final verdict", () => {
1935
+ const cwd = makeFixture();
1936
+ try {
1937
+ const rel = "agents/review_quality.md";
1938
+ write(
1939
+ rel,
1940
+ fs.readFileSync(path.join(cwd, rel), "utf8")
1941
+ .replaceAll("review_stage: partial", "review_stage: final"),
1942
+ cwd,
1943
+ );
1944
+
1945
+ const result = runHarness(cwd);
1946
+ assert.notEqual(result.status, 0, "checker accepted a final specialist review");
1947
+ assert.match(result.stderr, /agents\/review_quality\.md: missing review_stage: partial/);
1948
+ } finally {
1949
+ fs.rmSync(cwd, { recursive: true, force: true });
1950
+ }
1951
+ });