opencode-agent-orchestration-kit 1.0.33 → 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 (63) hide show
  1. package/README.md +41 -3
  2. package/docs/cli.md +31 -3
  3. package/docs/releases/v1.0.34.md +59 -0
  4. package/docs/releases/v1.0.35.md +62 -0
  5. package/docs/releases/v1.0.36.md +58 -0
  6. package/docs/releases/v1.0.37.md +53 -0
  7. package/docs/supply-chain.md +2 -2
  8. package/opencode/agents/lead.md +11 -2
  9. package/opencode/agents/review_api.md +26 -9
  10. package/opencode/agents/review_coordinator.md +60 -68
  11. package/opencode/agents/review_quality.md +27 -11
  12. package/opencode/agents/review_security.md +26 -10
  13. package/opencode/agents/review_tests.md +26 -9
  14. package/opencode/agents/reviewer.md +95 -80
  15. package/opencode/commands/autonomous.md +75 -0
  16. package/opencode/commands/evolve.md +3 -1
  17. package/opencode/commands/feature.md +6 -2
  18. package/opencode/commands/loop.md +12 -8
  19. package/opencode/commands/review-orchestrated.md +26 -24
  20. package/opencode/commands/review-preflight.md +8 -7
  21. package/opencode/commands/review.md +27 -10
  22. package/opencode/docs/ai/harness/README.md +3 -0
  23. package/opencode/docs/ai/harness/agents.md +20 -3
  24. package/opencode/docs/ai/harness/checks.md +9 -0
  25. package/opencode/docs/ai/harness/commands.md +36 -0
  26. package/opencode/docs/ai/harness/orchestrated-review.md +8 -1
  27. package/opencode/docs/ai/harness/orchestration-contracts.json +34 -1
  28. package/opencode/package-lock.json +3 -3
  29. package/opencode/package.json +1 -1
  30. package/opencode/plugins/shell-export-guard.ts +23 -0
  31. package/opencode/scripts/adversarial-harness.test.mjs +5 -2
  32. package/opencode/scripts/check-harness.mjs +241 -10
  33. package/opencode/scripts/check-harness.test.mjs +190 -8
  34. package/opencode/scripts/loop-state.mjs +88 -14
  35. package/opencode/scripts/loop-state.test.mjs +82 -5
  36. package/opencode/scripts/review-orchestrated-prepare.mjs +18 -1
  37. package/opencode/scripts/review-orchestrated-prepare.test.mjs +49 -0
  38. package/opencode/scripts/shell-export-policy.d.mts +4 -0
  39. package/opencode/scripts/shell-export-policy.mjs +272 -0
  40. package/opencode/scripts/shell-export-policy.test.mjs +96 -0
  41. package/opencode/skills/code-review-and-quality/SKILL.md +63 -321
  42. package/opencode/skills/code-review-and-quality/references/profiles/backend-clean-ddd-cqrs.md +60 -0
  43. package/opencode/skills/code-review-and-quality/references/profiles/backend.md +54 -0
  44. package/opencode/skills/code-review-and-quality/references/profiles/frontend-clean-layered.md +60 -0
  45. package/opencode/skills/code-review-and-quality/references/profiles/frontend.md +62 -0
  46. package/opencode/skills/code-review-and-quality/references/review-policy.md +258 -0
  47. package/package.json +2 -2
  48. package/scripts/check-supply-chain.mjs +5 -1
  49. package/scripts/check-supply-chain.test.mjs +10 -6
  50. package/scripts/check.sh +6 -2
  51. package/scripts/oak.mjs +47 -1
  52. package/scripts/oak.test.mjs +53 -1
  53. package/scripts/package-smoke.test.mjs +2 -2
  54. package/scripts/version.test.mjs +2 -2
  55. package/supply-chain.json +1 -1
  56. package/docker/open-design/data/app.sqlite +0 -0
  57. package/docker/open-design/data/app.sqlite-shm +0 -0
  58. package/docker/open-design/data/app.sqlite-wal +0 -0
  59. package/docker/open-design/opencode-auth/log/2026-05-02T105802.log +0 -17
  60. package/docker/open-design/opencode-auth/log/2026-05-04T102127.log +0 -16
  61. package/docker/open-design/opencode-auth/opencode.db +0 -0
  62. package/docker/open-design/opencode-auth/opencode.db-shm +0 -0
  63. package/docker/open-design/opencode-auth/opencode.db-wal +0 -0
@@ -232,6 +232,7 @@ function checkOrchestrationContracts() {
232
232
  : [];
233
233
  checkSortedUniqueStrings("workflow ids", workflowIds);
234
234
  const canonicalWorkflowIds = [
235
+ "autonomous",
235
236
  "design",
236
237
  "direct-development",
237
238
  "direct-research",
@@ -260,6 +261,7 @@ function checkOrchestrationContracts() {
260
261
  const retryScopes = new Set();
261
262
  if (Array.isArray(contract.retry_policies)) {
262
263
  const approvedRetries = {
264
+ "autonomous-iterations": ["autonomous", 6, true, "block"],
263
265
  "developer-default": ["developer", 2, true, "escalate-review"],
264
266
  "loop-iterations": ["loop", 3, true, "ask-user"],
265
267
  "reviewer-default": ["reviewer", 2, true, "block"],
@@ -285,8 +287,8 @@ function checkOrchestrationContracts() {
285
287
  fail(`${orchestrationContractRel}: retry scope ${policy.scope} must be unique`);
286
288
  }
287
289
  retryScopes.add(policy.scope);
288
- if (!Number.isInteger(policy.max_attempts) || policy.max_attempts < 1 || policy.max_attempts > 3) {
289
- fail(`${orchestrationContractRel}: ${label} max_attempts must be between 1 and 3`);
290
+ if (!Number.isInteger(policy.max_attempts) || policy.max_attempts < 1 || policy.max_attempts > 6) {
291
+ fail(`${orchestrationContractRel}: ${label} max_attempts must be between 1 and 6`);
290
292
  }
291
293
  if (typeof policy.requires_new_evidence !== "boolean") {
292
294
  fail(`${orchestrationContractRel}: ${label} requires_new_evidence must be boolean`);
@@ -309,6 +311,12 @@ function checkOrchestrationContracts() {
309
311
  const usedEntrypoints = new Set();
310
312
  const entrypointWorkflows = new Map();
311
313
  const approvedStageSequences = {
314
+ autonomous: [
315
+ "lead:required",
316
+ "developer:required",
317
+ "reviewer:required",
318
+ "developer:state-sync",
319
+ ],
312
320
  design: ["designer:required"],
313
321
  "direct-development": ["developer:required"],
314
322
  "direct-research": ["researcher:required"],
@@ -365,6 +373,7 @@ function checkOrchestrationContracts() {
365
373
  scope: ["scoper:required", "researcher:required", "specifier:required"],
366
374
  };
367
375
  const approvedCompletionAuthorities = {
376
+ autonomous: ["agent", "reviewer"],
368
377
  design: ["agent", "designer"],
369
378
  "direct-development": ["result-contract", null],
370
379
  "direct-research": ["agent", "researcher"],
@@ -771,6 +780,46 @@ function checkCommandDocsCoverage() {
771
780
  }
772
781
  }
773
782
 
783
+ function checkAutonomousContract() {
784
+ const rel = "commands/autonomous.md";
785
+ if (!exists(rel)) {
786
+ fail(`${rel}: missing command`);
787
+ return;
788
+ }
789
+ const text = contractText(read(rel));
790
+ for (const token of [
791
+ "authorization: explicit_command_invocation",
792
+ "execution_scope: local_checkout_only",
793
+ "max_iterations_per_invocation: 6",
794
+ "planned_iteration_budget: task_specific_1_to_6",
795
+ "hard_safety_ceiling: 6",
796
+ "completion_authority: reviewer_only",
797
+ "validation_gate: deterministic_per_iteration",
798
+ "canonical_state_path: .opencode/loops/<slug>.json",
799
+ "history_path: .opencode/loops/<slug>.history.jsonl",
800
+ "lock_path: .opencode/loops/<slug>.lock",
801
+ "human_view_path: .opencode/loops/<slug>.md",
802
+ "worktree_mode: prohibited",
803
+ "scheduling: prohibited",
804
+ "parallelism: prohibited",
805
+ "external_writes: prohibited",
806
+ "auto_commit_push_merge_deploy: prohibited",
807
+ "reviewer_execution: task_subagent_only",
808
+ "reviewer_evidence: required_subagent_attestation",
809
+ "oak state init --root .",
810
+ "task reviewer",
811
+ "oak state attest-review --root .",
812
+ "developer -> reviewer -> developer (state sync)",
813
+ "Do not create worktrees, schedule runs, execute parallel branches, use network",
814
+ "two iterations without observable progress",
815
+ "repeated failure",
816
+ "Final reviewer approval stops the cycle immediately.",
817
+ "An explicit schema migration requires renewed human approval before `oak state resume`",
818
+ ]) {
819
+ if (!text.includes(token)) fail(`${rel}: missing ${token}`);
820
+ }
821
+ }
822
+
774
823
  function checkLoopContract() {
775
824
  const rel = "commands/loop.md";
776
825
  if (!exists(rel)) {
@@ -863,6 +912,107 @@ function checkFrontmatter() {
863
912
  }
864
913
  }
865
914
 
915
+ function checkCanonicalReviewPolicy() {
916
+ const policyRel = "skills/code-review-and-quality/references/review-policy.md";
917
+ const skillRel = "skills/code-review-and-quality/SKILL.md";
918
+ const profiles = [
919
+ ["backend", "skills/code-review-and-quality/references/profiles/backend.md"],
920
+ ["backend-clean-ddd-cqrs", "skills/code-review-and-quality/references/profiles/backend-clean-ddd-cqrs.md"],
921
+ ["frontend", "skills/code-review-and-quality/references/profiles/frontend.md"],
922
+ ["frontend-clean-layered", "skills/code-review-and-quality/references/profiles/frontend-clean-layered.md"],
923
+ ];
924
+
925
+ for (const rel of [policyRel, ...profiles.map(([, rel]) => rel)]) {
926
+ if (!exists(rel)) {
927
+ fail(`${rel}: missing canonical review surface`);
928
+ continue;
929
+ }
930
+ const stat = fs.lstatSync(path.join(root, rel));
931
+ if (stat.isSymbolicLink() || !stat.isFile()) {
932
+ fail(`${rel}: must be a regular non-symlink file`);
933
+ }
934
+ }
935
+
936
+ if (exists(policyRel)) {
937
+ const policy = read(policyRel);
938
+ for (const heading of [
939
+ "## Seven Review Gates",
940
+ "## Independent Verification",
941
+ "## Causality",
942
+ "## Findings Contract",
943
+ "## Review Stage And Verdict",
944
+ "## Blocking Rules",
945
+ "## Pre-existing Debt",
946
+ "## Specialist And Coordinator Limits",
947
+ "## Final Review Output",
948
+ ]) {
949
+ if (!policy.includes(heading)) fail(`${policyRel}: missing heading ${heading}`);
950
+ }
951
+ const normalized = contractText(policy);
952
+ for (const token of [
953
+ "introduced | worsened | pre_existing | unknown",
954
+ "blocking | non_blocking | pre_existing | needs_human_verification",
955
+ "review_stage: preflight | partial | final",
956
+ "verdict: not_run | pass | pass_with_observations | needs_changes | blocked",
957
+ "Never block solely because hypothetical external callers may exist",
958
+ "Only the general reviewer can consolidate evidence",
959
+ ]) {
960
+ if (!normalized.includes(token)) fail(`${policyRel}: missing canonical token ${token}`);
961
+ }
962
+ }
963
+
964
+ const skill = exists(skillRel) ? read(skillRel) : "";
965
+ for (const [profile] of profiles) {
966
+ if (!skill.includes(`references/profiles/${profile}.md`)) {
967
+ fail(`${skillRel}: missing profile routing ${profile}`);
968
+ }
969
+ }
970
+ if (!contractText(skill).includes("explicit declaration") || !contractText(skill).includes("layout alone does not activate")) {
971
+ fail(`${skillRel}: strict architecture profile requires explicit declaration`);
972
+ }
973
+
974
+ const reviewerRel = "agents/reviewer.md";
975
+ const reviewer = read(reviewerRel);
976
+ for (const token of [
977
+ "canonical_policy: required",
978
+ "primary_evidence: diff_and_original_artifacts",
979
+ "developer_summary_is_not_evidence",
980
+ "causality: required",
981
+ "review_stage: final",
982
+ "final_verdict_authority: reviewer",
983
+ "pre_existing_debt: non_blocking",
984
+ ]) {
985
+ if (!reviewer.includes(token)) fail(`${reviewerRel}: missing ${token}`);
986
+ }
987
+ if (!frontmatterBlock(reviewerRel).includes('"code-review-and-quality": allow')) {
988
+ fail(`${reviewerRel}: missing canonical review skill permission`);
989
+ }
990
+
991
+ for (const rel of [
992
+ "agents/review_quality.md",
993
+ "agents/review_security.md",
994
+ "agents/review_tests.md",
995
+ "agents/review_api.md",
996
+ ]) {
997
+ const text = read(rel);
998
+ for (const token of [
999
+ "canonical_policy: required",
1000
+ "causality: required",
1001
+ "review_stage: partial",
1002
+ "verdict: not_run",
1003
+ "integral_verdict: forbidden",
1004
+ "disposition",
1005
+ "causality",
1006
+ "profiles",
1007
+ "categories",
1008
+ "read_scope",
1009
+ "omitted_coverage",
1010
+ ]) {
1011
+ if (!text.includes(token)) fail(`${rel}: missing ${token}`);
1012
+ }
1013
+ }
1014
+ }
1015
+
866
1016
  function checkOrchestratedReviewContract() {
867
1017
  const preflightCommandRel = "commands/review-preflight.md";
868
1018
  const commandRel = "commands/review-orchestrated.md";
@@ -876,7 +1026,15 @@ function checkOrchestratedReviewContract() {
876
1026
 
877
1027
  if (exists("commands/review.md")) {
878
1028
  const review = read("commands/review.md");
879
- for (const token of ["agent: reviewer", "Review the current diff", "git diff"]) {
1029
+ for (const token of [
1030
+ "agent: reviewer",
1031
+ "subtask: false",
1032
+ "Review the current diff",
1033
+ "git diff",
1034
+ "canonical_policy: required",
1035
+ "review_stage: final",
1036
+ "final_verdict_authority: reviewer",
1037
+ ]) {
880
1038
  if (!review.includes(token)) fail(`commands/review.md: existing /review contract changed or missing ${token}`);
881
1039
  }
882
1040
  if (review.includes("review_coordinator") || review.includes("review-orchestrated")) {
@@ -889,7 +1047,7 @@ function checkOrchestratedReviewContract() {
889
1047
  for (const token of [
890
1048
  "agent: lead",
891
1049
  "recommended daily path",
892
- "rtk node scripts/review-orchestrated-prepare.mjs --dry-run",
1050
+ "OPENCODE_CONFIG_DIR",
893
1051
  "manifest.json",
894
1052
  "shared-review-context.md",
895
1053
  "patches/",
@@ -897,6 +1055,8 @@ function checkOrchestratedReviewContract() {
897
1055
  "Do not invoke reviewers",
898
1056
  "Do not claim an AI review was performed",
899
1057
  "Do not ask follow-up questions",
1058
+ "review_stage: preflight",
1059
+ "verdict: not_run",
900
1060
  ]) {
901
1061
  if (!command.includes(token)) fail(`${preflightCommandRel}: missing ${token}`);
902
1062
  }
@@ -906,7 +1066,7 @@ function checkOrchestratedReviewContract() {
906
1066
  const command = read(commandRel);
907
1067
  for (const token of [
908
1068
  "agent: review_coordinator",
909
- "node scripts/review-orchestrated-prepare.mjs $ARGUMENTS",
1069
+ "OPENCODE_CONFIG_DIR",
910
1070
  "manifest.json",
911
1071
  "shared-review-context.md",
912
1072
  "patches/",
@@ -927,6 +1087,8 @@ function checkOrchestratedReviewContract() {
927
1087
  "Always enumerate `review_quality`",
928
1088
  "skipped",
929
1089
  "lite",
1090
+ "review_stage: partial",
1091
+ "verdict: not_run",
930
1092
  ]) {
931
1093
  if (!command.includes(token)) fail(`${commandRel}: missing ${token}`);
932
1094
  }
@@ -967,11 +1129,9 @@ function checkOrchestratedReviewContract() {
967
1129
  fail("agents/review_coordinator.md: harmless preparer existence checks must not abort --agents");
968
1130
  }
969
1131
  for (const token of [
970
- "node scripts/review-orchestrated-prepare.mjs*",
971
- "node ./scripts/review-orchestrated-prepare.mjs*",
972
1132
  "node *scripts/review-orchestrated-prepare.mjs*",
973
- "Use a relative path",
974
- "Call the preparer exactly once",
1133
+ "OPENCODE_CONFIG_DIR",
1134
+ "Call it once",
975
1135
  "execution_plan.mode",
976
1136
  "preflight_only",
977
1137
  "--agents",
@@ -981,7 +1141,7 @@ function checkOrchestratedReviewContract() {
981
1141
  "at most one finding",
982
1142
  "Do not run `git diff`",
983
1143
  "timed_out",
984
- "always enumerate all four reviewers",
1144
+ "Always enumerate all four reviewers",
985
1145
  ]) {
986
1146
  if (!coordinator.includes(token)) fail(`agents/review_coordinator.md: missing preparer permission/routing token ${token}`);
987
1147
  }
@@ -2685,6 +2845,74 @@ function checkRetryPoliciesContract() {
2685
2845
  }
2686
2846
  }
2687
2847
 
2848
+ function checkShellExportGuardContract() {
2849
+ const policyRel = "scripts/shell-export-policy.mjs";
2850
+ const policyTestRel = "scripts/shell-export-policy.test.mjs";
2851
+ const pluginRel = "plugins/shell-export-guard.ts";
2852
+
2853
+ for (const rel of [policyRel, policyTestRel, pluginRel]) {
2854
+ if (!exists(rel)) fail(`${rel}: missing shell export guard surface`);
2855
+ }
2856
+
2857
+ if (!exists(policyRel) || !exists(policyTestRel) || !exists(pluginRel)) return;
2858
+
2859
+ const policy = read(policyRel);
2860
+ for (const token of [
2861
+ "classifyShellExport",
2862
+ "shell-export-environment-enumeration",
2863
+ "shell-export-sensitive-name",
2864
+ "shell-export-secret-source",
2865
+ "-p",
2866
+ ]) {
2867
+ if (!policy.includes(token)) {
2868
+ fail(`${policyRel}: missing shell export guard token ${token}`);
2869
+ }
2870
+ }
2871
+
2872
+ const plugin = read(pluginRel);
2873
+ for (const token of [
2874
+ "tool.execute.before",
2875
+ "classifyShellExport",
2876
+ "shell-export-guard",
2877
+ "bash",
2878
+ "shell",
2879
+ ]) {
2880
+ if (!plugin.includes(token)) {
2881
+ fail(`${pluginRel}: missing shell export guard token ${token}`);
2882
+ }
2883
+ }
2884
+ if (/\$\{?command\}?/.test(plugin)) {
2885
+ fail(`${pluginRel}: shell export guard must not include the raw command in diagnostics`);
2886
+ }
2887
+
2888
+ const policyTests = read(policyTestRel);
2889
+ for (const token of [
2890
+ "export",
2891
+ "API_KEY",
2892
+ "PATH",
2893
+ "NODE_ENV",
2894
+ "pi --export",
2895
+ "quoted prose",
2896
+ ]) {
2897
+ if (!policyTests.includes(token)) {
2898
+ fail(`${policyTestRel}: missing shell export policy scenario ${token}`);
2899
+ }
2900
+ }
2901
+
2902
+ const checksDocs = read("docs/ai/harness/checks.md");
2903
+ const readmeDocs = read("docs/ai/harness/README.md");
2904
+ for (const [rel, text] of [
2905
+ ["docs/ai/harness/checks.md", checksDocs],
2906
+ ["docs/ai/harness/README.md", readmeDocs],
2907
+ ]) {
2908
+ for (const token of ["shell-export", "defense in depth", "sandbox"]) {
2909
+ if (!text.includes(token)) {
2910
+ fail(`${rel}: missing shell export policy documentation token ${token}`);
2911
+ }
2912
+ }
2913
+ }
2914
+ }
2915
+
2688
2916
  checkConfig();
2689
2917
  checkAgentsIndex();
2690
2918
  checkFrontmatter();
@@ -2692,6 +2920,7 @@ checkOrchestrationContracts();
2692
2920
  checkAgentDocsCoverage();
2693
2921
  checkCommandDocsCoverage();
2694
2922
  checkLoopContract();
2923
+ checkAutonomousContract();
2695
2924
  checkLeadRouterContract();
2696
2925
  checkFeatureContract();
2697
2926
  checkPlanContract();
@@ -2711,6 +2940,7 @@ checkCommandContracts();
2711
2940
  checkSkillRegistryPresence();
2712
2941
  checkLeadSkillResolution();
2713
2942
  checkAgentSkillLoading();
2943
+ checkCanonicalReviewPolicy();
2714
2944
  checkSkillRegistryGenerator();
2715
2945
  checkInitCommand();
2716
2946
  checkAutoForecastContract();
@@ -2722,6 +2952,7 @@ checkOrchestratedReviewContract();
2722
2952
  checkHitlDurableContract();
2723
2953
  checkRoutingDeclarativoContract();
2724
2954
  checkRetryPoliciesContract();
2955
+ checkShellExportGuardContract();
2725
2956
 
2726
2957
  if (errors.length > 0) {
2727
2958
  console.error("Harness check failed:");
@@ -94,6 +94,19 @@ test("orchestration contract file is required", () => {
94
94
  }
95
95
  });
96
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
+
97
110
  test("orchestration contract file must be regular and non-symlink", () => {
98
111
  const cwd = makeFixture();
99
112
  const external = path.join(cwd, "external-contract.json");
@@ -329,18 +342,13 @@ test("orchestration retry limits are bounded", () => {
329
342
  const cwd = makeFixture();
330
343
  try {
331
344
  const contract = readOrchestrationContract(cwd);
332
- contract.retry_policies = [{
333
- id: "developer-default",
334
- scope: "developer",
335
- max_attempts: 4,
336
- requires_new_evidence: true,
337
- on_exhaustion: "escalate-review",
338
- }];
345
+ const policy = contract.retry_policies.find((candidate) => candidate.id === "developer-default");
346
+ policy.max_attempts = 7;
339
347
  writeOrchestrationContract(cwd, contract);
340
348
 
341
349
  const result = runHarness(cwd);
342
350
  assert.notEqual(result.status, 0, "checker accepted an unbounded retry policy");
343
- assert.match(result.stderr, /retry developer-default max_attempts must be between 1 and 3/);
351
+ assert.match(result.stderr, /retry developer-default max_attempts must be between 1 and 6/);
344
352
  } finally {
345
353
  fs.rmSync(cwd, { recursive: true, force: true });
346
354
  }
@@ -477,6 +485,107 @@ function writeLoopFixture(cwd, command) {
477
485
  fs.appendFileSync(docsPath, "\n## `/loop`\n");
478
486
  }
479
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
+
480
589
  test("adversarial corpus rejects a missing threat", () => {
481
590
  const cwd = makeFixture();
482
591
  try {
@@ -1767,3 +1876,76 @@ test("harness rejects commands.md without Retry Policies section", () => {
1767
1876
  fs.rmSync(cwd, { recursive: true, force: true });
1768
1877
  }
1769
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
+ });