opencode-agent-orchestration-kit 1.0.42 → 1.0.44

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 (46) hide show
  1. package/README.md +12 -5
  2. package/docker/open-design/data/app.sqlite +0 -0
  3. package/docker/open-design/data/app.sqlite-shm +0 -0
  4. package/docker/open-design/data/app.sqlite-wal +0 -0
  5. package/docker/open-design/opencode-auth/log/2026-05-02T105802.log +17 -0
  6. package/docker/open-design/opencode-auth/log/2026-05-04T102127.log +16 -0
  7. package/docker/open-design/opencode-auth/opencode.db +0 -0
  8. package/docker/open-design/opencode-auth/opencode.db-shm +0 -0
  9. package/docker/open-design/opencode-auth/opencode.db-wal +0 -0
  10. package/docs/compatibility.md +13 -1
  11. package/docs/installation.md +5 -0
  12. package/docs/models.md +1 -1
  13. package/docs/releases/v1.0.28.md +1 -2
  14. package/docs/releases/v1.0.29.md +1 -2
  15. package/docs/releases/v1.0.43.md +67 -0
  16. package/docs/releases/v1.0.44.md +67 -0
  17. package/docs/superpowers/specs/2026-07-20-safe-installation-lifecycle-design.md +9 -5
  18. package/opencode/agents/developer.md +8 -0
  19. package/opencode/agents/lead.md +51 -21
  20. package/opencode/agents/researcher.md +14 -0
  21. package/opencode/agents/review_coordinator.md +2 -2
  22. package/opencode/agents/reviewer.md +22 -0
  23. package/opencode/agents/specifier.md +8 -0
  24. package/opencode/commands/review-orchestrated.md +1 -1
  25. package/opencode/docs/ai/evolution/benchmarks/replay-fixtures-red.jsonl +2 -0
  26. package/opencode/docs/ai/evolution/benchmarks/router-scenarios-red.jsonl +2 -0
  27. package/opencode/docs/ai/harness/agents.md +53 -2
  28. package/opencode/docs/ai/harness/orchestrated-review.md +11 -3
  29. package/opencode/docs/ai/harness/playbooks/lead-ahe-flow.md +43 -0
  30. package/opencode/package-lock.json +30 -27
  31. package/opencode/scripts/check-harness.mjs +28 -4
  32. package/opencode/scripts/check-harness.test.mjs +74 -0
  33. package/opencode/scripts/collect-session-evidence.mjs +197 -9
  34. package/opencode/scripts/collect-session-evidence.test.mjs +151 -0
  35. package/opencode/scripts/replay-routing.test.mjs +58 -0
  36. package/opencode/scripts/review-orchestrated-prepare.mjs +1 -1
  37. package/opencode/scripts/review-orchestrated-prepare.test.mjs +9 -0
  38. package/opencode/scripts/update-skill-registry.mjs +3 -2
  39. package/package.json +1 -1
  40. package/scripts/benchmark-tool-paths.mjs +1 -1
  41. package/scripts/check-public-boundary.mjs +1 -0
  42. package/scripts/manage-installation.mjs +17 -5
  43. package/scripts/manage-installation.test.mjs +61 -0
  44. package/scripts/package-smoke.test.mjs +2 -2
  45. package/scripts/version.test.mjs +2 -2
  46. package/docs/synology.md +0 -30
@@ -3,7 +3,7 @@
3
3
  import fs from "node:fs";
4
4
  import os from "node:os";
5
5
  import path from "node:path";
6
- import { spawn } from "node:child_process";
6
+ import { spawn, spawnSync } from "node:child_process";
7
7
  import { pathToFileURL } from "node:url";
8
8
 
9
9
  function fail(message) {
@@ -130,6 +130,154 @@ function firstTextPart(parts) {
130
130
  return null;
131
131
  }
132
132
 
133
+ // ---------------------------------------------------------------------------
134
+ // Phase-0 telemetry (iteration-025).
135
+ // These signals live ONLY in this collector's output; they are never injected
136
+ // into agent handoff prompts. All fields are additive and optional so existing
137
+ // consumers of execution-trees.jsonl keep working unchanged.
138
+ //
139
+ // Semantics:
140
+ // - request_turn_id: `<root_session_id>:t<n>` numbered by root user-message
141
+ // time; each spawn maps to the latest root turn active at its spawn moment,
142
+ // which makes multi-turn sessions classifiable per request instead of per
143
+ // session head.
144
+ // - t_handoff_start/t_handoff_end: paired spawn boundaries. For spawn i,
145
+ // t_handoff_start is the completion time of the previous hop (root start for
146
+ // the first hop) and t_handoff_end is the new spawn's creation time, so
147
+ // gap_ms is the observable consolidation gap before each delegation.
148
+ // Overlapping hops produce negative gaps (reported honestly, not clamped).
149
+ // - diff_size: measured at collection time against the tree root directory
150
+ // (`git diff --numstat`), never at gate decision time; consumers must treat
151
+ // it as a post-hoc approximation (captured_at: "collection").
152
+ // - review_skipped_reason: enum-valid marker extracted from session summaries.
153
+ // ---------------------------------------------------------------------------
154
+
155
+ const REVIEW_SKIPPED_REASONS = new Set([
156
+ "small_gate_pass",
157
+ "protected_surface",
158
+ "destructive_diff",
159
+ "tests_required",
160
+ "scope_not_small",
161
+ "human_decision",
162
+ ]);
163
+
164
+ const REVIEW_SKIPPED_REASON_PATTERN = /review_skipped_reason:\s*([a-z_]+)/;
165
+
166
+ function buildRequestTurns(turnTimes, rootSessionId) {
167
+ if (!Array.isArray(turnTimes) || turnTimes.length === 0) return [];
168
+ return [...turnTimes]
169
+ .filter((time) => typeof time === "number")
170
+ .sort((left, right) => left - right)
171
+ .map((tStart, index) => ({ turn_id: `${rootSessionId}:t${index + 1}`, t_start: tStart }));
172
+ }
173
+
174
+ function resolveRequestTurnId(requestTurns, spawnTime) {
175
+ if (typeof spawnTime !== "number" || requestTurns.length === 0) return null;
176
+ let matched = null;
177
+ for (const turn of requestTurns) {
178
+ if (turn.t_start <= spawnTime) matched = turn.turn_id;
179
+ }
180
+ return matched;
181
+ }
182
+
183
+ function buildHandoffs(childSessions, rootSession, requestTurns) {
184
+ const rootStart = typeof rootSession?.time_created === "number" ? rootSession.time_created : null;
185
+ let predecessorEnd = rootStart;
186
+ return childSessions.map((child, index) => {
187
+ const tSpawn = typeof child.time_created === "number" ? child.time_created : null;
188
+ const tComplete = typeof child.time_updated === "number" ? child.time_updated : null;
189
+ const gapMs = predecessorEnd !== null && tSpawn !== null ? tSpawn - predecessorEnd : null;
190
+ const handoff = {
191
+ sequence: index + 1,
192
+ agent: child.agent || null,
193
+ session_id: child.session_id,
194
+ request_turn_id: resolveRequestTurnId(requestTurns, tSpawn),
195
+ t_handoff_start: predecessorEnd,
196
+ t_handoff_end: tSpawn,
197
+ gap_ms: gapMs,
198
+ t_spawn: tSpawn,
199
+ t_complete: tComplete,
200
+ };
201
+ if (tComplete !== null) predecessorEnd = tComplete;
202
+ return handoff;
203
+ });
204
+ }
205
+
206
+ function deriveReviewSkippedReason(sortedRows, rootSession) {
207
+ const orderedRows = [
208
+ ...(rootSession ? [rootSession] : []),
209
+ ...sortedRows.filter((row) => row.session_id !== rootSession?.session_id),
210
+ ];
211
+ for (const row of orderedRows) {
212
+ const summary = row.assistant_summary;
213
+ if (typeof summary !== "string") continue;
214
+ const match = summary.match(REVIEW_SKIPPED_REASON_PATTERN);
215
+ if (match && REVIEW_SKIPPED_REASONS.has(match[1])) return match[1];
216
+ }
217
+ return null;
218
+ }
219
+
220
+ function unavailableDiffSize() {
221
+ return {
222
+ available: false,
223
+ files_changed: null,
224
+ insertions: null,
225
+ deletions: null,
226
+ captured_at: "collection",
227
+ };
228
+ }
229
+
230
+ function measureDiffSize(directory) {
231
+ const fallback = unavailableDiffSize();
232
+ if (typeof directory !== "string" || directory.length === 0) return fallback;
233
+ let stat;
234
+ try {
235
+ stat = fs.statSync(directory);
236
+ } catch {
237
+ return fallback;
238
+ }
239
+ if (!stat.isDirectory()) return fallback;
240
+ try {
241
+ const probe = spawnSync(
242
+ "git",
243
+ ["-C", directory, "rev-parse", "--is-inside-work-tree"],
244
+ { encoding: "utf8", timeout: 10_000 },
245
+ );
246
+ if (probe.status !== 0 || probe.stdout.trim() !== "true") return fallback;
247
+ const numstat = spawnSync(
248
+ "git",
249
+ ["-C", directory, "diff", "--numstat"],
250
+ { encoding: "utf8", timeout: 15_000, maxBuffer: 32 * 1024 * 1024 },
251
+ );
252
+ if (numstat.status !== 0) return fallback;
253
+ let filesChanged = 0;
254
+ let insertions = 0;
255
+ let deletions = 0;
256
+ for (const line of numstat.stdout.split("\n")) {
257
+ if (!line.trim()) continue;
258
+ const [added, removed] = line.split("\t");
259
+ filesChanged += 1;
260
+ if (/^\d+$/.test(added)) insertions += Number(added);
261
+ if (/^\d+$/.test(removed)) deletions += Number(removed);
262
+ }
263
+ // Untracked files are part of the visible work-tree delta even though
264
+ // `git diff --numstat` omits them; count them so small-gate metrics see
265
+ // brand-new files too.
266
+ const untracked = spawnSync(
267
+ "git",
268
+ ["-C", directory, "ls-files", "--others", "--exclude-standard"],
269
+ { encoding: "utf8", timeout: 15_000 },
270
+ );
271
+ if (untracked.status === 0) {
272
+ filesChanged += untracked.stdout.split("\n").filter((entry) => entry.trim()).length;
273
+ }
274
+ return { ...fallback, available: true, files_changed: filesChanged, insertions, deletions };
275
+ } catch {
276
+ return fallback;
277
+ }
278
+ }
279
+
280
+
133
281
  function loadPreviousCursor(iteration, outputDir) {
134
282
  if (!iteration) return null;
135
283
  const runsDir = path.dirname(path.dirname(outputDir));
@@ -217,6 +365,8 @@ async function summarizeSqlite(dbPath, previousCursor, fullRescan) {
217
365
  partsByMessage.set(part.message_id, list);
218
366
  }
219
367
 
368
+ const userTurnTimesBySession = new Map();
369
+
220
370
  const normalized = [];
221
371
  let skipped = 0;
222
372
  const skipReasons = {};
@@ -245,6 +395,13 @@ async function summarizeSqlite(dbPath, previousCursor, fullRescan) {
245
395
  if (role === "assistant") assistantMessages.push(message);
246
396
  }
247
397
 
398
+ userTurnTimesBySession.set(
399
+ session.id,
400
+ userMessages
401
+ .map((message) => message.time_created)
402
+ .filter((time) => typeof time === "number"),
403
+ );
404
+
248
405
  const firstUser = userMessages[0];
249
406
  const lastAssistant = assistantMessages.at(-1);
250
407
  const userPrompt = firstUser ? firstTextPart(partsByMessage.get(firstUser.id) || []) : null;
@@ -302,6 +459,7 @@ async function summarizeSqlite(dbPath, previousCursor, fullRescan) {
302
459
  skip_reasons: skipReasons,
303
460
  },
304
461
  normalized,
462
+ userTurnTimesBySession,
305
463
  };
306
464
  }
307
465
 
@@ -411,7 +569,7 @@ function treeRepresentativeSummary(sessions) {
411
569
  .at(-1).assistant_summary;
412
570
  }
413
571
 
414
- function buildExecutionTrees(sqliteRows, rawRows, previousCursor, fullRescan) {
572
+ function buildExecutionTrees(sqliteRows, rawRows, previousCursor, fullRescan, userTurnTimesBySession = null) {
415
573
  const sqliteMap = new Map(sqliteRows.map((row) => [row.session_id, row]));
416
574
  const rawBySessionId = new Map(rawRows.map((row) => [row.session_id, row]));
417
575
  const grouped = new Map();
@@ -474,6 +632,18 @@ function buildExecutionTrees(sqliteRows, rawRows, previousCursor, fullRescan) {
474
632
  source_formats: [...new Set(["opencode-sqlite", ...matchedRawIds.map(() => "opencode-raw-json")])],
475
633
  };
476
634
 
635
+ const requestTurns = buildRequestTurns(
636
+ userTurnTimesBySession?.get(rootSession.session_id),
637
+ rootSession.session_id,
638
+ );
639
+ tree.telemetry = {
640
+ method_version: 1,
641
+ request_turns: requestTurns,
642
+ handoffs: buildHandoffs(childSessions, rootSession, requestTurns),
643
+ review_skipped_reason: deriveReviewSkippedReason(sortedRows, rootSession),
644
+ diff_size: unavailableDiffSize(),
645
+ };
646
+
477
647
  if (
478
648
  !fullRescan &&
479
649
  previousCursor &&
@@ -527,8 +697,12 @@ export async function collectExecutionTreeByRoot(dbPath, rootSessionId) {
527
697
  const result = await summarizeSqlite(dbPath, null, true);
528
698
  const rootSession = result.normalized.find((row) => row.session_id === rootSessionId);
529
699
  if (!rootSession || rootSession.parent_session_id !== null) return null;
530
- const built = buildExecutionTrees(result.normalized, [], null, true);
531
- return built.trees.find((tree) => tree.root_session_id === rootSessionId) || null;
700
+ const built = buildExecutionTrees(result.normalized, [], null, true, result.userTurnTimesBySession);
701
+ const tree = built.trees.find((candidate) => candidate.root_session_id === rootSessionId) || null;
702
+ if (tree?.telemetry) {
703
+ tree.telemetry.diff_size = measureDiffSize(tree.root_directory);
704
+ }
705
+ return tree;
532
706
  }
533
707
 
534
708
  function makeCursor(previousCursor, treeSummary, trees, supplementalRawSummary, fullRescan) {
@@ -576,25 +750,39 @@ export async function main(argv = process.argv.slice(2)) {
576
750
  const summaries = [];
577
751
  let sqliteRows = [];
578
752
  let rawRows = [];
753
+ let userTurnTimesBySession = null;
579
754
 
580
755
  const previousCursor = args.fullRescan ? null : loadPreviousCursor(args.iteration, outputDir);
581
756
 
582
757
  for (const sourcePath of sourcePaths) {
583
758
  if (!fs.existsSync(sourcePath)) continue;
584
759
  const kind = detectSource(sourcePath);
585
- const result =
586
- kind === "opencode-sqlite"
587
- ? await summarizeSqlite(sourcePath, previousCursor, args.fullRescan)
588
- : summarizeRawDir(sourcePath);
760
+ let result;
761
+ if (kind === "opencode-sqlite") {
762
+ result = await summarizeSqlite(sourcePath, previousCursor, args.fullRescan);
763
+ } else {
764
+ result = { source: null, normalized: [] };
765
+ const rawResult = summarizeRawDir(sourcePath);
766
+ result.source = rawResult.source;
767
+ result.normalized = rawResult.normalized;
768
+ result.userTurnTimesBySession = new Map();
769
+ }
589
770
  summaries.push(result.source);
590
771
  if (kind === "opencode-sqlite") {
591
772
  sqliteRows = sqliteRows.concat(result.normalized);
773
+ userTurnTimesBySession = new Map([
774
+ ...(userTurnTimesBySession || []),
775
+ ...result.userTurnTimesBySession,
776
+ ]);
592
777
  } else {
593
778
  rawRows = rawRows.concat(result.normalized);
594
779
  }
595
780
  }
596
781
 
597
- const built = buildExecutionTrees(sqliteRows, rawRows, previousCursor, args.fullRescan);
782
+ const built = buildExecutionTrees(sqliteRows, rawRows, previousCursor, args.fullRescan, userTurnTimesBySession);
783
+ for (const tree of built.trees) {
784
+ tree.telemetry.diff_size = measureDiffSize(tree.root_directory);
785
+ }
598
786
  const acceptedSessionIds = new Set(built.trees.flatMap((tree) => tree.session_ids));
599
787
  const filteredSessionRows = sortSessions(sqliteRows.filter((row) => acceptedSessionIds.has(row.session_id)));
600
788
  const cursor = makeCursor(previousCursor, built.treeSummary, built.trees, built.supplementalRawSummary, args.fullRescan);
@@ -577,3 +577,154 @@ test("streamSqliteJson rejects on sqlite3 runtime error (non-zero exit)", async
577
577
  assert.notEqual(result.status, 0);
578
578
  assert.match(result.stderr, /sqlite3 runtime error|session/);
579
579
  });
580
+
581
+ test("execution trees expose phase-0 telemetry with paired handoff timestamps and turn correlation", async () => {
582
+ const tmp = makeTempDir();
583
+ try {
584
+ const dbPath = path.join(tmp, "opencode.db");
585
+ createFixtureDb(dbPath);
586
+
587
+ const tree = await collectExecutionTreeByRoot(dbPath, "ses_root_1");
588
+
589
+ const telemetry = tree.telemetry;
590
+ assert.ok(telemetry, "tree must carry phase-0 telemetry");
591
+ assert.equal(telemetry.method_version, 1);
592
+ assert.deepEqual(telemetry.request_turns, [
593
+ { turn_id: "ses_root_1:t1", t_start: 1000 },
594
+ ]);
595
+
596
+ assert.equal(telemetry.handoffs.length, 2);
597
+ const [handoffOne, handoffTwo] = telemetry.handoffs;
598
+ assert.deepEqual(handoffOne, {
599
+ sequence: 1,
600
+ agent: "researcher",
601
+ session_id: "ses_child_1",
602
+ request_turn_id: "ses_root_1:t1",
603
+ t_handoff_start: 1000,
604
+ t_handoff_end: 1100,
605
+ gap_ms: 100,
606
+ t_spawn: 1100,
607
+ t_complete: 2100,
608
+ });
609
+ // paired spawn -> completion of predecessor; overlap shows up as negative gap
610
+ assert.deepEqual(handoffTwo, {
611
+ sequence: 2,
612
+ agent: "reviewer",
613
+ session_id: "ses_grandchild_1",
614
+ request_turn_id: "ses_root_1:t1",
615
+ t_handoff_start: 2100,
616
+ t_handoff_end: 1150,
617
+ gap_ms: -950,
618
+ t_spawn: 1150,
619
+ t_complete: 2200,
620
+ });
621
+
622
+ assert.deepEqual(telemetry.diff_size, {
623
+ available: false,
624
+ files_changed: null,
625
+ insertions: null,
626
+ deletions: null,
627
+ captured_at: "collection",
628
+ });
629
+ assert.equal(telemetry.review_skipped_reason, null);
630
+ } finally {
631
+ fs.rmSync(tmp, { recursive: true, force: true });
632
+ }
633
+ });
634
+
635
+ test("phase-0 telemetry maps spawns to the latest root user turn", async () => {
636
+ const tmp = makeTempDir();
637
+ try {
638
+ const dbPath = path.join(tmp, "opencode.db");
639
+ createFixtureDb(dbPath);
640
+ run("sqlite3", [
641
+ dbPath,
642
+ `
643
+ insert into message (id, session_id, time_created, time_updated, data) values
644
+ ('msg_user_root_1b', 'ses_root_1', 1500, 1500, '{"role":"user","time":{"created":1500}}'),
645
+ ('msg_user_child_2', 'ses_child_1', 1600, 1600, '{"role":"user","time":{"created":1600}}');
646
+ insert into part (id, message_id, session_id, time_created, time_updated, data) values
647
+ ('prt_user_root_1b', 'msg_user_root_1b', 'ses_root_1', 1500, 1500, '{"type":"text","text":"Follow-up request on the harness issue."}'),
648
+ ('prt_user_child_2', 'msg_user_child_2', 'ses_child_1', 1600, 1600, '{"type":"text","text":"Second research pass."}');
649
+ insert into session (
650
+ id, project_id, parent_id, slug, directory, title, version, time_created, time_updated, path, agent, model, cost, tokens_input, tokens_output, tokens_reasoning, tokens_cache_read, tokens_cache_write
651
+ ) values (
652
+ 'ses_child_2', 'proj_1', 'ses_root_1', 'bold-otter', '/tmp/repo', 'Research follow-up (@researcher subagent)', '1.15.12', 1700, 1900, '', 'researcher',
653
+ '{"id":"synthetic-model","providerID":"synthetic-provider","variant":"synthetic-variant"}', 0.1, 10, 5, 0, 0, 0
654
+ );
655
+ `,
656
+ ]);
657
+
658
+ const tree = await collectExecutionTreeByRoot(dbPath, "ses_root_1");
659
+
660
+ assert.deepEqual(tree.telemetry.request_turns, [
661
+ { turn_id: "ses_root_1:t1", t_start: 1000 },
662
+ { turn_id: "ses_root_1:t2", t_start: 1500 },
663
+ ]);
664
+ const bySession = new Map(
665
+ tree.telemetry.handoffs.map((handoff) => [handoff.session_id, handoff]),
666
+ );
667
+ assert.equal(bySession.get("ses_child_1").request_turn_id, "ses_root_1:t1");
668
+ assert.equal(bySession.get("ses_grandchild_1").request_turn_id, "ses_root_1:t1");
669
+ assert.equal(bySession.get("ses_child_2").request_turn_id, "ses_root_1:t2");
670
+ } finally {
671
+ fs.rmSync(tmp, { recursive: true, force: true });
672
+ }
673
+ });
674
+
675
+ test("phase-0 telemetry captures enum-valid review_skipped_reason and rejects unknown tokens", async () => {
676
+ const tmp = makeTempDir();
677
+ try {
678
+ const dbPath = path.join(tmp, "opencode.db");
679
+ createFixtureDb(dbPath);
680
+ run("sqlite3", [
681
+ dbPath,
682
+ `update part set data = json_object('type','text','text','Closed with review skipped. review_skipped_reason: small_gate_pass')
683
+ where id = 'prt_assistant_root_1';`,
684
+ ]);
685
+
686
+ const tree = await collectExecutionTreeByRoot(dbPath, "ses_root_1");
687
+ assert.equal(tree.telemetry.review_skipped_reason, "small_gate_pass");
688
+
689
+ run("sqlite3", [
690
+ dbPath,
691
+ `update part set data = json_object('type','text','text','review_skipped_reason: because_i_said_so')
692
+ where id = 'prt_assistant_root_1';`,
693
+ ]);
694
+ const rejectTree = await collectExecutionTreeByRoot(dbPath, "ses_root_1");
695
+ assert.equal(rejectTree.telemetry.review_skipped_reason, null);
696
+ } finally {
697
+ fs.rmSync(tmp, { recursive: true, force: true });
698
+ }
699
+ });
700
+
701
+ test("phase-0 telemetry measures diff size for a real local git repo", async () => {
702
+ const tmp = makeTempDir();
703
+ try {
704
+ const repoDir = path.join(tmp, "repo");
705
+ fs.mkdirSync(repoDir, { recursive: true });
706
+ run("git", ["init", "-q", repoDir]);
707
+ run("git", ["-C", repoDir, "config", "user.email", "test@example.invalid"]);
708
+ run("git", ["-C", repoDir, "config", "user.name", "Test"]);
709
+ fs.writeFileSync(path.join(repoDir, "a.txt"), "one\n");
710
+ run("git", ["-C", repoDir, "add", "."]);
711
+ run("git", ["-C", repoDir, "commit", "-qm", "base"]);
712
+ fs.writeFileSync(path.join(repoDir, "a.txt"), "one\ntwo\nthree\n");
713
+ fs.writeFileSync(path.join(repoDir, "b.txt"), "new\n");
714
+
715
+ const dbPath = path.join(tmp, "opencode.db");
716
+ createFixtureDb(dbPath);
717
+ run("sqlite3", [dbPath, `update session set directory = '${repoDir}' where id in ('ses_root_1','ses_child_1','ses_grandchild_1');`]);
718
+
719
+ const tree = await collectExecutionTreeByRoot(dbPath, "ses_root_1");
720
+ assert.deepEqual(tree.telemetry.diff_size, {
721
+ available: true,
722
+ files_changed: 2,
723
+ insertions: 2,
724
+ deletions: 0,
725
+ captured_at: "collection",
726
+ });
727
+ } finally {
728
+ fs.rmSync(tmp, { recursive: true, force: true });
729
+ }
730
+ });
@@ -6,6 +6,7 @@ import path from "node:path";
6
6
  import { spawnSync } from "node:child_process";
7
7
  import test from "node:test";
8
8
  import { fileURLToPath } from "node:url";
9
+ import { evaluateReplay } from "./replay-routing.mjs";
9
10
 
10
11
  const scriptDir = path.dirname(fileURLToPath(import.meta.url));
11
12
  const root = path.dirname(scriptDir);
@@ -18,6 +19,14 @@ const fixturesPath = path.join(
18
19
  root,
19
20
  "docs/ai/evolution/benchmarks/replay-fixtures.jsonl",
20
21
  );
22
+ const redCorpusPath = path.join(
23
+ root,
24
+ "docs/ai/evolution/benchmarks/router-scenarios-red.jsonl",
25
+ );
26
+ const redFixturesPath = path.join(
27
+ root,
28
+ "docs/ai/evolution/benchmarks/replay-fixtures-red.jsonl",
29
+ );
21
30
  const coverageChannels = [
22
31
  "session_events",
23
32
  "skill_events",
@@ -1452,3 +1461,52 @@ test("missing stop evidence is inconclusive", () => {
1452
1461
  });
1453
1462
  });
1454
1463
  });
1464
+
1465
+ test("phase-0 red fixtures fail deterministically with the natural routing symptoms", () => {
1466
+ const scenarios = readJsonl(redCorpusPath);
1467
+ const fixtures = readJsonl(redFixturesPath);
1468
+ assert.deepEqual(
1469
+ fixtures.map((fixture) => fixture.scenario_id).sort(),
1470
+ scenarios.map((scenario) => scenario.id).sort(),
1471
+ );
1472
+
1473
+ const report = evaluateReplay({
1474
+ scenarios,
1475
+ observations: fixtures,
1476
+ mode: "deterministic",
1477
+ });
1478
+ // Intentional red-pending regression net: these fail until the small-gate
1479
+ // fast path changes real routing; the classic corpus stays all-green.
1480
+ assert.equal(report.operational_status, "ok");
1481
+ assert.equal(report.status, "fail");
1482
+
1483
+ const byId = new Map(
1484
+ report.scenario_results.map((result) => [result.scenario_id, result]),
1485
+ );
1486
+ const copyTrivial = byId.get("freeform-tiny-copy-trivial");
1487
+ assert.ok(copyTrivial, "missing copy-trivial red scenario");
1488
+ assert.equal(copyTrivial.status, "fail");
1489
+ const copyFails = new Map(
1490
+ copyTrivial.assertions
1491
+ .filter((assertion) => assertion.status === "fail")
1492
+ .map((assertion) => [assertion.id, assertion]),
1493
+ );
1494
+ assert.equal(copyFails.get("forbidden-agents")?.reason_code, "forbidden-agent-observed");
1495
+ assert.deepEqual(copyFails.get("forbidden-agents")?.evidence_sequences, [5]);
1496
+ assert.equal(copyFails.get("review-policy")?.reason_code, "reviewer-forbidden");
1497
+ assert.deepEqual(copyFails.get("delegation-budget")?.reason_code, "delegation-budget-exceeded");
1498
+
1499
+ const seedPipeline = byId.get("freeform-tiny-toy-single-file-full-pipeline");
1500
+ assert.ok(seedPipeline, "missing toy single-file full-pipeline red scenario");
1501
+ assert.equal(seedPipeline.status, "fail");
1502
+ const seedForbidden = seedPipeline.assertions.find(
1503
+ (assertion) => assertion.id === "forbidden-agents",
1504
+ );
1505
+ assert.equal(seedForbidden?.status, "fail");
1506
+ assert.deepEqual(seedForbidden?.evidence_sequences, [2, 4, 9]);
1507
+ const seedReviewPolicy = seedPipeline.assertions.find(
1508
+ (assertion) => assertion.id === "review-policy",
1509
+ );
1510
+ assert.equal(seedReviewPolicy?.status, "fail");
1511
+ assert.equal(seedReviewPolicy?.reason_code, "reviewer-forbidden");
1512
+ });
@@ -339,7 +339,7 @@ function buildExecutionPlan(classification, recommendedReviewers, options) {
339
339
  verdict: "not_run",
340
340
  dry_run_alias: false,
341
341
  ai_review: planned.length > 0 ? "experimental_specialized_agents" : "not_run",
342
- strategy: "Experimental costly mode; run selected specialized reviewers sequentially with timeout and partial-failure reporting.",
342
+ strategy: "Experimental costly mode; run selected specialized reviewers in parallel, launching every task call in one turn, with a per-reviewer timeout and partial-failure reporting.",
343
343
  planned_reviewers: planned,
344
344
  max_reviewers_to_execute: 4,
345
345
  reviewer_timeout_ms: timeoutMs,
@@ -344,6 +344,15 @@ test("--full-agents mode caps planned specialized reviewers at four", () => {
344
344
  assert.equal(plan.max_reviewers_to_execute, 4);
345
345
  });
346
346
 
347
+ test("--full-agents strategy instructs parallel execution, not sequential", () => {
348
+ const options = parseArgs(["--full-agents"]);
349
+ const plan = buildExecutionPlan("full", ["review_quality", "review_security"], options);
350
+
351
+ assert.match(plan.strategy, /in parallel/);
352
+ assert.doesNotMatch(plan.strategy, /sequentially/);
353
+ assert.equal(plan.reviewer_timeout_ms, options.budgets.reviewer_timeout_ms);
354
+ });
355
+
347
356
  test("reviewer timeout and failure statuses are recorded as partial results", () => {
348
357
  const manifest = {
349
358
  failed_reviewers: [],
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from "node:fs";
3
+ import os from "node:os";
3
4
  import path from "node:path";
4
5
  import { fileURLToPath } from "node:url";
5
6
 
@@ -10,7 +11,8 @@ const root = path.resolve(__dirname, "..");
10
11
  const registryMdRel = "docs/ai/harness/skill_registry.md";
11
12
  const registryJsonRel = "docs/ai/harness/skill_registry.json";
12
13
  const builtInSkillsDir = path.join(root, "skills");
13
- const userSkillsDir = path.join(process.env.HOME, ".agents", "skills");
14
+ const home = os.homedir();
15
+ const userSkillsDir = path.join(home, ".agents", "skills");
14
16
 
15
17
  const SCHEMA_VERSION = 2;
16
18
 
@@ -164,7 +166,6 @@ function displayPath(skillFile, source) {
164
166
  return path.relative(root, skillFile).split(path.sep).join("/");
165
167
  }
166
168
 
167
- const home = process.env.HOME;
168
169
  if (home && skillFile.startsWith(`${home}${path.sep}`)) {
169
170
  return `~/${path.relative(home, skillFile).split(path.sep).join("/")}`;
170
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-agent-orchestration-kit",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "private": false,
5
5
  "description": "Open-source multi-agent orchestration harness for OpenCode with specialized agents, durable workflows, review gates, and reproducible software-engineering processes.",
6
6
  "keywords": [
@@ -143,7 +143,7 @@ async function benchmarkFixture(fixture, iterations, temporaryRoot) {
143
143
  const result = await createInstallationManager({
144
144
  sourceRoot: fixture.sourceRoot,
145
145
  repositoryRoot: fixture.root,
146
- versionProvider: () => "1.0.42",
146
+ versionProvider: () => "1.0.44",
147
147
  }).run("install", { targetRoot });
148
148
  if (result.exitCode !== 0) throw invalid(`installation benchmark failed for ${fixture.id}`);
149
149
  } finally {
@@ -21,6 +21,7 @@ const REQUIRED_FILES = [
21
21
  // from fragments so this scanner does not trip over its own rules.
22
22
  const PRIVATE_MARKERS = [
23
23
  ["/", "Users", "/"].join(""),
24
+ ["juancan", "as"].join(""),
24
25
  ["synology", ".", "me"].join(""),
25
26
  ["auth", ".", "json"].join(""),
26
27
  ["OPENAI", "_", "API", "_", "KEY"].join(""),
@@ -903,7 +903,8 @@ function ensureDirectory(fullPath, mode, fsOps = fs) {
903
903
  fsOps.chmodSync(fullPath, mode);
904
904
  }
905
905
 
906
- function fsyncDirectory(fullPath, fsOps = fs) {
906
+ export function fsyncDirectory(fullPath, fsOps = fs, platform = process.platform) {
907
+ if (platform === "win32") return;
907
908
  const descriptor = fsOps.openSync(fullPath, "r");
908
909
  try {
909
910
  while (true) {
@@ -1118,15 +1119,26 @@ export function createInstallationManager(options) {
1118
1119
  ensureDirectory(oakPath, 0o700, fsOps);
1119
1120
  const lock = { transaction_id: transactionId, pid, command, created_at: clock().toISOString() };
1120
1121
  const lockPath = path.join(oakPath, "lock.json");
1121
- const descriptor = fsOps.openSync(lockPath, "wx", 0o600);
1122
+ let descriptor;
1123
+ let lockCreated = false;
1122
1124
  try {
1125
+ descriptor = fsOps.openSync(lockPath, "wx", 0o600);
1126
+ lockCreated = true;
1123
1127
  fsOps.writeFileSync(descriptor, `${canonicalJson(lock)}\n`);
1124
1128
  fsOps.fsyncSync(descriptor);
1125
- } finally {
1126
1129
  fsOps.closeSync(descriptor);
1130
+ descriptor = undefined;
1131
+ fsyncDirectory(oakPath, fsOps);
1132
+ return lock;
1133
+ } catch (error) {
1134
+ if (descriptor !== undefined) {
1135
+ try { fsOps.closeSync(descriptor); } catch {}
1136
+ }
1137
+ if (lockCreated) {
1138
+ try { fsOps.unlinkSync(lockPath); } catch {}
1139
+ }
1140
+ throw error;
1127
1141
  }
1128
- fsyncDirectory(oakPath, fsOps);
1129
- return lock;
1130
1142
  }
1131
1143
 
1132
1144
  function releaseLock(targetRoot) {