opencode-agent-orchestration-kit 1.0.31 → 1.0.32

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.
@@ -72,10 +72,23 @@ agent: lead
72
72
  approval_gate: explicit_before_writes
73
73
  max_iterations_per_invocation: 3
74
74
  completion_authority: reviewer_only
75
- state_path: .opencode/loops/<slug>.md
75
+ canonical_state_path: .opencode/loops/<slug>.json
76
+ history_path: .opencode/loops/<slug>.history.jsonl
77
+ lock_path: .opencode/loops/<slug>.lock
78
+ human_view_path: .opencode/loops/<slug>.md
76
79
  worktree_mode: explicit_opt_in
77
80
 
78
81
  developer -> reviewer -> developer (state sync)
82
+
83
+ ## Phase 1
84
+
85
+ node scripts/loop-state.mjs inspect
86
+
87
+ ## Phase 2
88
+
89
+ node scripts/loop-state.mjs resume
90
+
91
+ ## Phase 3
79
92
  `;
80
93
 
81
94
  function writeLoopFixture(cwd, command) {
@@ -84,6 +97,123 @@ function writeLoopFixture(cwd, command) {
84
97
  fs.appendFileSync(docsPath, "\n## `/loop`\n");
85
98
  }
86
99
 
100
+ test("adversarial corpus rejects a missing threat", () => {
101
+ const cwd = makeFixture();
102
+ try {
103
+ const rel = "docs/ai/evolution/benchmarks/adversarial-scenarios.jsonl";
104
+ const records = fs.readFileSync(path.join(cwd, rel), "utf8")
105
+ .trim()
106
+ .split("\n")
107
+ .map(JSON.parse)
108
+ .filter((record) => record.threat !== "network-exfiltration");
109
+ write(rel, `${records.map(JSON.stringify).join("\n")}\n`, cwd);
110
+
111
+ const result = runHarness(cwd);
112
+ assert.notEqual(result.status, 0, "checker accepted a missing adversarial threat");
113
+ assert.match(result.stderr, /missing threat network-exfiltration/);
114
+ } finally {
115
+ fs.rmSync(cwd, { recursive: true, force: true });
116
+ }
117
+ });
118
+
119
+ test("adversarial corpus rejects non-portable fixture values", () => {
120
+ const cwd = makeFixture();
121
+ try {
122
+ const rel = "docs/ai/evolution/benchmarks/adversarial-scenarios.jsonl";
123
+ write(
124
+ rel,
125
+ fs.readFileSync(path.join(cwd, rel), "utf8")
126
+ .replace("PATCH_CANARY_IGNORE_POLICY", "../private"),
127
+ cwd,
128
+ );
129
+
130
+ const result = runHarness(cwd);
131
+ assert.notEqual(result.status, 0, "checker accepted a local path in the portable corpus");
132
+ assert.match(result.stderr, /input_fixture must be a portable symbolic identifier/);
133
+ } finally {
134
+ fs.rmSync(cwd, { recursive: true, force: true });
135
+ }
136
+ });
137
+
138
+ test("adversarial surface rejects an allowlisted rtk wrapper", () => {
139
+ const cwd = makeFixture();
140
+ try {
141
+ const rel = "agents/review_security.md";
142
+ write(
143
+ rel,
144
+ fs.readFileSync(path.join(cwd, rel), "utf8")
145
+ .replace('"rtk *": ask', '"rtk *": allow'),
146
+ cwd,
147
+ );
148
+
149
+ const result = runHarness(cwd);
150
+ assert.notEqual(result.status, 0, "checker accepted an allowlisted shell wrapper");
151
+ assert.match(result.stderr, /wrapper command rtk \* must require approval/);
152
+ } finally {
153
+ fs.rmSync(cwd, { recursive: true, force: true });
154
+ }
155
+ });
156
+
157
+ test("adversarial surface rejects review network allow", () => {
158
+ const cwd = makeFixture();
159
+ try {
160
+ const rel = "agents/review_security.md";
161
+ write(
162
+ rel,
163
+ fs.readFileSync(path.join(cwd, rel), "utf8")
164
+ .replace("webfetch: deny", "webfetch: allow"),
165
+ cwd,
166
+ );
167
+
168
+ const result = runHarness(cwd);
169
+ assert.notEqual(result.status, 0, "checker accepted network access for orchestrated review");
170
+ assert.match(result.stderr, /review network permission must include webfetch: deny/);
171
+ } finally {
172
+ fs.rmSync(cwd, { recursive: true, force: true });
173
+ }
174
+ });
175
+
176
+ test("agent frontmatter rejects shell permissions nested under websearch", () => {
177
+ const cwd = makeFixture();
178
+ try {
179
+ const rel = "agents/review_tests.md";
180
+ write(
181
+ rel,
182
+ fs.readFileSync(path.join(cwd, rel), "utf8")
183
+ .replace(
184
+ " websearch: deny",
185
+ ' websearch: deny\n "shell canary*": allow',
186
+ ),
187
+ cwd,
188
+ );
189
+
190
+ const result = runHarness(cwd);
191
+ assert.notEqual(result.status, 0, "checker accepted a shell permission nested under websearch");
192
+ assert.match(result.stderr, /quoted command permission cannot be nested under websearch/);
193
+ } finally {
194
+ fs.rmSync(cwd, { recursive: true, force: true });
195
+ }
196
+ });
197
+
198
+ test("adversarial surface rejects a missing repository trust boundary", () => {
199
+ const cwd = makeFixture();
200
+ try {
201
+ const rel = "AGENTS.md";
202
+ write(
203
+ rel,
204
+ fs.readFileSync(path.join(cwd, rel), "utf8")
205
+ .replace("local documentation, and their metadata as", "local documentation, and their metadata as ordinary"),
206
+ cwd,
207
+ );
208
+
209
+ const result = runHarness(cwd);
210
+ assert.notEqual(result.status, 0, "checker accepted a missing repository trust boundary");
211
+ assert.match(result.stderr, /missing adversarial trust boundary/);
212
+ } finally {
213
+ fs.rmSync(cwd, { recursive: true, force: true });
214
+ }
215
+ });
216
+
87
217
  test("harness accepts prose evidence that mentions markdown filenames", () => {
88
218
  const cwd = makeFixture();
89
219
  try {
@@ -234,6 +364,67 @@ test("harness rejects loop when developer can approve itself", () => {
234
364
  }
235
365
  });
236
366
 
367
+ test("harness rejects loop without canonical structured state", () => {
368
+ const cwd = makeFixture();
369
+ try {
370
+ writeLoopFixture(
371
+ cwd,
372
+ validLoopCommand.replace(
373
+ "canonical_state_path: .opencode/loops/<slug>.json",
374
+ "canonical_state_path: .opencode/loops/<slug>.md",
375
+ ),
376
+ );
377
+
378
+ const result = runHarness(cwd);
379
+ assert.notEqual(result.status, 0, "checker accepted markdown as canonical loop state");
380
+ assert.match(
381
+ result.stderr,
382
+ /commands\/loop\.md: missing canonical_state_path: \.opencode\/loops\/<slug>\.json/,
383
+ );
384
+ } finally {
385
+ fs.rmSync(cwd, { recursive: true, force: true });
386
+ }
387
+ });
388
+
389
+ test("harness rejects a missing durable loop runtime", () => {
390
+ const cwd = makeFixture();
391
+ try {
392
+ fs.rmSync(path.join(cwd, "scripts/loop-state.mjs"));
393
+
394
+ const result = runHarness(cwd);
395
+ assert.notEqual(result.status, 0, "checker accepted a missing loop state runtime");
396
+ assert.match(result.stderr, /scripts\/loop-state\.mjs: missing regular file/);
397
+ } finally {
398
+ fs.rmSync(cwd, { recursive: true, force: true });
399
+ }
400
+ });
401
+
402
+ test("harness rejects loop resume writes before approval", () => {
403
+ const cwd = makeFixture();
404
+ try {
405
+ writeLoopFixture(
406
+ cwd,
407
+ validLoopCommand.replace(
408
+ "node scripts/loop-state.mjs inspect",
409
+ "node scripts/loop-state.mjs resume",
410
+ ),
411
+ );
412
+
413
+ const result = runHarness(cwd);
414
+ assert.notEqual(result.status, 0, "checker accepted resume before approval");
415
+ assert.match(
416
+ result.stderr,
417
+ /commands\/loop\.md: resume preflight must use read-only loop-state inspect/,
418
+ );
419
+ assert.match(
420
+ result.stderr,
421
+ /commands\/loop\.md: loop-state resume cannot run before approval/,
422
+ );
423
+ } finally {
424
+ fs.rmSync(cwd, { recursive: true, force: true });
425
+ }
426
+ });
427
+
237
428
  test("harness rejects evolve flow when evaluator/debugger/evolver order is inverted", () => {
238
429
  const cwd = makeFixture();
239
430
  try {