opencode-swarm 7.137.0 → 7.137.2
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.
- package/.opencode/skills/swarm-pr-review/SKILL.md +35 -3
- package/.opencode/skills/swarm-pr-review/references/prompt-templates.md +7 -3
- package/dist/background/candidate-contract.d.ts +14 -0
- package/dist/cli/{config-doctor-vyx82nx2.js → config-doctor-xrbzq4r0.js} +2 -2
- package/dist/cli/{curation-policy-8tvs4pa0.js → curation-policy-xyradeax.js} +2 -2
- package/dist/cli/{curator-43xqs75k.js → curator-h1ea9skz.js} +13 -13
- package/dist/cli/{curator-llm-factory-8nywfdsh.js → curator-llm-factory-rk7pccwc.js} +13 -13
- package/dist/cli/{guardrail-explain-8kkqz8tx.js → guardrail-explain-sq1kcah3.js} +14 -14
- package/dist/cli/{guardrail-log-e2v9qw71.js → guardrail-log-7anp1z1n.js} +3 -3
- package/dist/cli/{hive-promoter-jt9ky0hn.js → hive-promoter-qsymj94z.js} +13 -13
- package/dist/cli/{index-d00q9kpq.js → index-02jqxmh8.js} +5 -5
- package/dist/cli/{index-pcwjz5de.js → index-1da1tvtn.js} +1 -1
- package/dist/cli/{index-72wzb81c.js → index-4t39wzzg.js} +1 -1
- package/dist/cli/{index-aze9n64z.js → index-5k0csd2m.js} +2 -2
- package/dist/cli/{index-fgkhpdc6.js → index-9casmxdt.js} +4 -4
- package/dist/cli/{index-j6ewv2pe.js → index-aygnzd04.js} +1 -1
- package/dist/cli/{index-k3mezk96.js → index-b2s3t517.js} +4 -2
- package/dist/cli/{index-92v63zzr.js → index-d735dzm7.js} +617 -192
- package/dist/cli/{index-y25nsyaq.js → index-gey6qegb.js} +1 -1
- package/dist/cli/{index-p124rnwb.js → index-jdqayy7h.js} +2 -2
- package/dist/cli/{index-wg98bsxz.js → index-kakb2jm0.js} +1 -1
- package/dist/cli/{index-j2ghsdzz.js → index-p0kez6cn.js} +15 -15
- package/dist/cli/{index-f24r6yqk.js → index-pwx989sa.js} +3 -3
- package/dist/cli/{index-91kk2e9j.js → index-rfrkt29c.js} +1 -1
- package/dist/cli/{index-mg26zd8x.js → index-s9at02fn.js} +1 -1
- package/dist/cli/{index-mwdzkr6k.js → index-vyh2prxv.js} +1 -1
- package/dist/cli/{index-d0nhz96c.js → index-ysh3a2nb.js} +2 -2
- package/dist/cli/index.js +13 -13
- package/dist/cli/{knowledge-escalator-9k0kbx6b.js → knowledge-escalator-e9zk371p.js} +3 -3
- package/dist/cli/{knowledge-events-8nz3sa2d.js → knowledge-events-dnyc1k78.js} +1 -1
- package/dist/cli/{knowledge-store-esghe3f9.js → knowledge-store-x4vqyhbz.js} +1 -1
- package/dist/cli/{knowledge-validator-bjxag1jp.js → knowledge-validator-72jdx5ze.js} +4 -4
- package/dist/cli/{runner-d820ws7y.js → runner-9rqc8y3m.js} +1 -1
- package/dist/cli/{scan-cursor-t212v00f.js → scan-cursor-z4xpes5f.js} +2 -2
- package/dist/cli/{schema-11gyrec3.js → schema-2dkw18zz.js} +1 -1
- package/dist/cli/{skill-generator-a07hpmw6.js → skill-generator-0q1jk6xd.js} +5 -5
- package/dist/council/council-evidence-writer.d.ts +2 -1
- package/dist/council/council-round-state.d.ts +110 -0
- package/dist/council/types.d.ts +0 -2
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/model-dispatcher.d.ts +19 -1
- package/dist/evaluation/pr-review-recovery.d.ts +41 -0
- package/dist/evaluation/public-api.d.ts +2 -0
- package/dist/evaluation/runner.d.ts +9 -0
- package/dist/hooks/pr-workflow-gate.d.ts +69 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +187 -183
- package/dist/tools/convene-council.d.ts +2 -17
- package/dist/tools/dispatch-lanes.d.ts +1 -0
- package/dist/tools/submit-phase-council-verdicts.d.ts +0 -1
- package/dist/tools/write-final-council-evidence.d.ts +4 -18
- package/evaluation-fixtures/pr-review-recovery/baseline/SKILL.md +1823 -0
- package/evaluation-fixtures/pr-review-recovery/baseline-manifest.json +1 -0
- package/evaluation-fixtures/pr-review-recovery/environment/score-recovery.cjs +135 -0
- package/evaluation-fixtures/pr-review-recovery/instruction.md +40 -0
- package/evaluation-fixtures/pr-review-recovery/scorer-fixtures/blind-full-wave-retry/model-output.json +1 -0
- package/evaluation-fixtures/pr-review-recovery/scorer-fixtures/contradictory/model-output.json +1 -0
- package/evaluation-fixtures/pr-review-recovery/scorer-fixtures/copied-contract/model-output.json +1 -0
- package/evaluation-fixtures/pr-review-recovery/scorer-fixtures/critical-without-harm/model-output.json +1 -0
- package/evaluation-fixtures/pr-review-recovery/scorer-fixtures/invented-harm/model-output.json +1 -0
- package/evaluation-fixtures/pr-review-recovery/scorer-fixtures/malformed/model-output.json +1 -0
- package/evaluation-fixtures/pr-review-recovery/scorer-fixtures/missing-reproduction/model-output.json +1 -0
- package/evaluation-fixtures/pr-review-recovery/scorer-fixtures/parser-only/model-output.json +1 -0
- package/evaluation-fixtures/pr-review-recovery/scorer-fixtures/passing/model-output.json +1 -0
- package/evaluation-fixtures/pr-review-recovery/scorer-fixtures/premature-systemic-claim/model-output.json +1 -0
- package/evaluation-fixtures/pr-review-recovery/scorer-fixtures/profile-b-fallback/model-output.json +1 -0
- package/evaluation-fixtures/pr-review-recovery/scorer-fixtures/underclaimed-harm/model-output.json +1 -0
- package/evaluation-fixtures/pr-review-recovery/scorer-fixtures/unsupported-severity/model-output.json +1 -0
- package/package.json +1 -1
|
@@ -8,20 +8,21 @@ import {
|
|
|
8
8
|
} from "./index-vm4xw9z3.js";
|
|
9
9
|
import {
|
|
10
10
|
captureWorkingTreeFingerprint,
|
|
11
|
+
createModelEvaluationExecutor,
|
|
11
12
|
pLimit,
|
|
12
13
|
resolveExecutableFromPath,
|
|
13
14
|
runEvaluation,
|
|
14
15
|
runExternalTool
|
|
15
|
-
} from "./index-
|
|
16
|
+
} from "./index-b2s3t517.js";
|
|
16
17
|
import {
|
|
17
18
|
stableCanonicalStringify
|
|
18
|
-
} from "./index-
|
|
19
|
+
} from "./index-aygnzd04.js";
|
|
19
20
|
import {
|
|
20
21
|
detectStraySwarmDirs,
|
|
21
22
|
readDoctorArtifact,
|
|
22
23
|
removeStraySwarmDir,
|
|
23
24
|
runConfigDoctor
|
|
24
|
-
} from "./index-
|
|
25
|
+
} from "./index-rfrkt29c.js";
|
|
25
26
|
import {
|
|
26
27
|
MAX_TRANSIENT_RETRIES,
|
|
27
28
|
archiveEvidence,
|
|
@@ -113,15 +114,15 @@ import {
|
|
|
113
114
|
retireSkill,
|
|
114
115
|
selectCandidateEntries,
|
|
115
116
|
syncBundledProjectSkillsIfMissingAsync
|
|
116
|
-
} from "./index-
|
|
117
|
+
} from "./index-pwx989sa.js";
|
|
117
118
|
import {
|
|
118
119
|
readRecentEscalations
|
|
119
|
-
} from "./index-
|
|
120
|
+
} from "./index-02jqxmh8.js";
|
|
120
121
|
import {
|
|
121
122
|
alreadyCuratedThisGeneration,
|
|
122
123
|
claimNextScanBatch,
|
|
123
124
|
resolveCohortId
|
|
124
|
-
} from "./index-
|
|
125
|
+
} from "./index-kakb2jm0.js";
|
|
125
126
|
import {
|
|
126
127
|
CURATOR_INIT_PROMPT,
|
|
127
128
|
CURATOR_PHASE_PROMPT,
|
|
@@ -174,11 +175,11 @@ import {
|
|
|
174
175
|
validateActionableFields,
|
|
175
176
|
validateLesson,
|
|
176
177
|
validateSkillPath
|
|
177
|
-
} from "./index-
|
|
178
|
+
} from "./index-jdqayy7h.js";
|
|
178
179
|
import {
|
|
179
180
|
authorizeCuration,
|
|
180
181
|
buildConfigFingerprintInput
|
|
181
|
-
} from "./index-
|
|
182
|
+
} from "./index-s9at02fn.js";
|
|
182
183
|
import {
|
|
183
184
|
cohortConfigFingerprint
|
|
184
185
|
} from "./index-rtry5xyf.js";
|
|
@@ -211,7 +212,7 @@ import {
|
|
|
211
212
|
transactFile,
|
|
212
213
|
transactKnowledge,
|
|
213
214
|
wordBigrams
|
|
214
|
-
} from "./index-
|
|
215
|
+
} from "./index-9casmxdt.js";
|
|
215
216
|
import {
|
|
216
217
|
MAX_EVENT_LOG_ENTRIES,
|
|
217
218
|
_internals,
|
|
@@ -221,7 +222,7 @@ import {
|
|
|
221
222
|
recordHiveKnowledgeEvent,
|
|
222
223
|
recordKnowledgeEvent,
|
|
223
224
|
resolveKnowledgeEventsPath
|
|
224
|
-
} from "./index-
|
|
225
|
+
} from "./index-4t39wzzg.js";
|
|
225
226
|
import {
|
|
226
227
|
resolveHiveDataDir,
|
|
227
228
|
resolveHiveEventsPath,
|
|
@@ -246,7 +247,7 @@ import {
|
|
|
246
247
|
init_loader,
|
|
247
248
|
loadPluginConfig,
|
|
248
249
|
loadPluginConfigWithMeta
|
|
249
|
-
} from "./index-
|
|
250
|
+
} from "./index-1da1tvtn.js";
|
|
250
251
|
import {
|
|
251
252
|
RetrospectiveEvidenceSchema
|
|
252
253
|
} from "./index-k5jrywpr.js";
|
|
@@ -262,7 +263,7 @@ import {
|
|
|
262
263
|
package_default,
|
|
263
264
|
resolveAutoReviewConfig,
|
|
264
265
|
stripKnownSwarmPrefix
|
|
265
|
-
} from "./index-
|
|
266
|
+
} from "./index-vyh2prxv.js";
|
|
266
267
|
import {
|
|
267
268
|
KNOWLEDGE_SCHEMA_VERSION,
|
|
268
269
|
OUTCOME_BLOCK_THRESHOLD,
|
|
@@ -410,8 +411,28 @@ var CANDIDATE_FIELDS = {
|
|
|
410
411
|
"confidence"
|
|
411
412
|
]
|
|
412
413
|
};
|
|
414
|
+
var CANDIDATE_MARKER = "[CANDIDATE]";
|
|
415
|
+
var CLEAN_MARKER = "[CLEAN]";
|
|
416
|
+
function formatCandidateHeader(family) {
|
|
417
|
+
return [
|
|
418
|
+
CANDIDATE_MARKER,
|
|
419
|
+
...CANDIDATE_FIELDS[family].map((name) => name === "file_line" ? "file:line" : name)
|
|
420
|
+
].join(" | ");
|
|
421
|
+
}
|
|
422
|
+
function formatCleanTemplate(family) {
|
|
423
|
+
const laneField = family === "base_explorer" ? "lane" : "micro_lane";
|
|
424
|
+
return [CLEAN_MARKER, laneField, "coverage_scope", "evidence"].join(" | ");
|
|
425
|
+
}
|
|
426
|
+
var CANDIDATE_HEADERS = {
|
|
427
|
+
base_explorer: formatCandidateHeader("base_explorer"),
|
|
428
|
+
micro_lane: formatCandidateHeader("micro_lane")
|
|
429
|
+
};
|
|
430
|
+
var CLEAN_TEMPLATES = {
|
|
431
|
+
base_explorer: formatCleanTemplate("base_explorer"),
|
|
432
|
+
micro_lane: formatCleanTemplate("micro_lane")
|
|
433
|
+
};
|
|
413
434
|
function candidateHeaderFamily(fields) {
|
|
414
|
-
if (fields[0]?.trim() !==
|
|
435
|
+
if (fields[0]?.trim() !== CANDIDATE_MARKER)
|
|
415
436
|
return null;
|
|
416
437
|
const normalized = fields.slice(1).map((field) => field.trim());
|
|
417
438
|
for (const family of ["base_explorer", "micro_lane"]) {
|
|
@@ -1943,6 +1964,7 @@ var CHECKOUT_MUTATION_ACTION_TIMEOUT_MS = 5 * 60000;
|
|
|
1943
1964
|
var MAX_CANDIDATE_ISSUES_PER_ARTIFACT = 8;
|
|
1944
1965
|
var MAX_BASE_COVERAGE_DIAGNOSTICS = 8;
|
|
1945
1966
|
var MAX_BASE_COVERAGE_DIAGNOSTIC_CHARS = 1000;
|
|
1967
|
+
var MAX_LANE_VALIDATION_VALUE_CHARS = 240;
|
|
1946
1968
|
var WORKFLOW_GATE_DIR = "pr-workflow-gates";
|
|
1947
1969
|
var trackedStatesByProjectSession = new Map;
|
|
1948
1970
|
var pendingStateMutationsByProjectSession = new Map;
|
|
@@ -2434,7 +2456,7 @@ async function assertPrReviewBaseCoverageSettled(directory, sessionID, gateConte
|
|
|
2434
2456
|
}
|
|
2435
2457
|
const missing = PR_REVIEW_BASE_DIMENSION_IDS.filter((dimension) => !covered.has(dimension));
|
|
2436
2458
|
if (missing.length > 0 || covered.size !== PR_REVIEW_BASE_DIMENSION_IDS.length) {
|
|
2437
|
-
throw new Error(`BLOCKED: PR_REVIEW base coverage is incomplete; missing dimensions: ${missing.join(", ") || "(none)"}${malformedDiagnostics.length > 0 ? `;
|
|
2459
|
+
throw new Error(`BLOCKED: PR_REVIEW base coverage is incomplete; missing dimensions: ${missing.join(", ") || "(none)"}${malformedDiagnostics.length > 0 ? `; first failed lane predicates: ${malformedDiagnostics.join(" | ")}` : ""}; valid dimensions: ${PR_REVIEW_BASE_DIMENSION_IDS.join(", ")}; expected candidate row: ${CANDIDATE_HEADERS.base_explorer}; expected clean row: ${CLEAN_TEMPLATES.base_explorer}`);
|
|
2438
2460
|
}
|
|
2439
2461
|
return state;
|
|
2440
2462
|
}
|
|
@@ -2787,6 +2809,7 @@ async function transitionPrReviewToFeedback(directory, sessionID, request) {
|
|
|
2787
2809
|
}
|
|
2788
2810
|
var _test_exports = {
|
|
2789
2811
|
minimumConsolidatedLaneCover,
|
|
2812
|
+
analyzePrReviewBatchRecordIntegrity,
|
|
2790
2813
|
MAX_COVER_UNIVERSE_BITS,
|
|
2791
2814
|
workflowGateStateRelativePath,
|
|
2792
2815
|
workflowGateStateLockRelativePath,
|
|
@@ -3356,47 +3379,169 @@ function derivePrReviewCriticInventoryForCoverageGate(directory, state, ctx, ori
|
|
|
3356
3379
|
}
|
|
3357
3380
|
return derivePrReviewCriticInventory(directory, state, ctx);
|
|
3358
3381
|
}
|
|
3359
|
-
function
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
});
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3382
|
+
function boundedLaneValidationValue(value) {
|
|
3383
|
+
let rendered;
|
|
3384
|
+
try {
|
|
3385
|
+
rendered = typeof value === "string" ? value : JSON.stringify(value);
|
|
3386
|
+
} catch {
|
|
3387
|
+
rendered = String(value);
|
|
3388
|
+
}
|
|
3389
|
+
const sanitized = [...rendered ?? String(value)].map((character) => {
|
|
3390
|
+
const code = character.charCodeAt(0);
|
|
3391
|
+
return code <= 31 || code === 127 ? " " : character;
|
|
3392
|
+
}).join("").trim();
|
|
3393
|
+
return sanitized.length <= MAX_LANE_VALIDATION_VALUE_CHARS ? sanitized : `${sanitized.slice(0, MAX_LANE_VALIDATION_VALUE_CHARS - 1)}\u2026`;
|
|
3394
|
+
}
|
|
3395
|
+
function failedLaneValidation(predicate, expected, actual) {
|
|
3396
|
+
return {
|
|
3397
|
+
ok: false,
|
|
3398
|
+
failure: {
|
|
3399
|
+
predicate,
|
|
3400
|
+
expected: boundedLaneValidationValue(expected),
|
|
3401
|
+
actual: boundedLaneValidationValue(actual)
|
|
3379
3402
|
}
|
|
3403
|
+
};
|
|
3404
|
+
}
|
|
3405
|
+
function formatPrReviewLaneValidationFailure(failure) {
|
|
3406
|
+
return `predicate=${failure.predicate} expected=${JSON.stringify(failure.expected)} actual=${JSON.stringify(failure.actual)}`.slice(0, MAX_BASE_COVERAGE_DIAGNOSTIC_CHARS);
|
|
3407
|
+
}
|
|
3408
|
+
function analyzeLaneRecordResultIntegrity(args) {
|
|
3409
|
+
const { record, result, expected } = args;
|
|
3410
|
+
if (expected.checkWorkflowLane && record.workflowLane !== expected.workflowLane) {
|
|
3411
|
+
return failedLaneValidation("record.workflow_lane", expected.workflowLane, record.workflowLane ?? "(missing)");
|
|
3380
3412
|
}
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3413
|
+
if (expected.checkWorkflowLane && !ownedLaneSetsEqual(record.ownedWorkflowLanes, expected.ownedWorkflowLanes)) {
|
|
3414
|
+
return failedLaneValidation("record.owned_workflow_lanes", expected.ownedWorkflowLanes, record.ownedWorkflowLanes ?? (record.workflowLane ? [record.workflowLane] : []));
|
|
3415
|
+
}
|
|
3416
|
+
if (record.mode !== expected.mode) {
|
|
3417
|
+
return failedLaneValidation("record.mode", expected.mode, record.mode ?? "(missing)");
|
|
3418
|
+
}
|
|
3419
|
+
if (record.workspace?.prHeadSha !== expected.prHeadSha) {
|
|
3420
|
+
return failedLaneValidation("record.pr_head_sha", expected.prHeadSha, record.workspace?.prHeadSha ?? "(missing)");
|
|
3421
|
+
}
|
|
3422
|
+
if (record.workspace?.gitHead !== expected.gitHead) {
|
|
3423
|
+
return failedLaneValidation("record.git_head", expected.gitHead, record.workspace?.gitHead ?? "(missing)");
|
|
3424
|
+
}
|
|
3425
|
+
if (args.requireCompleted && record.status !== "completed") {
|
|
3426
|
+
return failedLaneValidation("record.status", "completed", record.status);
|
|
3427
|
+
}
|
|
3428
|
+
if (result?.outputDegraded === true) {
|
|
3429
|
+
return failedLaneValidation("result.output_degraded", "not true", true);
|
|
3430
|
+
}
|
|
3431
|
+
if (result?.transcriptIncomplete === true) {
|
|
3432
|
+
return failedLaneValidation("result.transcript_incomplete", "not true", true);
|
|
3433
|
+
}
|
|
3434
|
+
if (result?.truncated === true) {
|
|
3435
|
+
return failedLaneValidation("result.truncated", "not true", true);
|
|
3436
|
+
}
|
|
3437
|
+
if ((result?.chars ?? 0) <= 0) {
|
|
3438
|
+
return failedLaneValidation("result.chars", "greater than 0", result?.chars ?? 0);
|
|
3439
|
+
}
|
|
3440
|
+
if (!result?.digest?.trim()) {
|
|
3441
|
+
return failedLaneValidation("result.digest", "non-empty digest", result?.digest ?? "(missing)");
|
|
3442
|
+
}
|
|
3443
|
+
if (!result?.outputRef?.trim()) {
|
|
3444
|
+
return failedLaneValidation("result.output_ref", "non-empty output ref", result?.outputRef ?? "(missing)");
|
|
3445
|
+
}
|
|
3446
|
+
return { ok: true };
|
|
3447
|
+
}
|
|
3448
|
+
function analyzePrReviewBatchRecordIntegrity(args) {
|
|
3449
|
+
const validatedAtMs = Date.parse(args.validatedAt);
|
|
3450
|
+
const expectedByLaneId = new Map(args.expectedLanes.map((lane) => [lane.laneId, lane]));
|
|
3451
|
+
const batchFailure = !Number.isFinite(validatedAtMs) ? failedLaneValidation("batch.validated_at", "valid ISO timestamp", args.validatedAt) : expectedByLaneId.size !== args.expectedLanes.length ? failedLaneValidation("batch.expected_lane_unique", "unique expected lane ids", args.expectedLanes.map((lane) => lane.laneId)) : null;
|
|
3452
|
+
const relevantRecords = args.records.filter((record) => record.laneId && expectedByLaneId.has(record.laneId));
|
|
3453
|
+
const recordsByLaneId = new Map;
|
|
3454
|
+
const recordCountBySubagentSessionId = new Map;
|
|
3455
|
+
for (const record of relevantRecords) {
|
|
3456
|
+
const laneRecords = recordsByLaneId.get(record.laneId) ?? [];
|
|
3457
|
+
laneRecords.push(record);
|
|
3458
|
+
recordsByLaneId.set(record.laneId, laneRecords);
|
|
3459
|
+
const sessionId = record.subagentSessionId?.trim();
|
|
3460
|
+
if (sessionId) {
|
|
3461
|
+
recordCountBySubagentSessionId.set(sessionId, (recordCountBySubagentSessionId.get(sessionId) ?? 0) + 1);
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
return args.expectedLanes.map((expectedLane) => {
|
|
3465
|
+
const expectedWorkflowLane = expectedLane.workflowLane;
|
|
3466
|
+
const expectedOwnedLanes = expectedLane.ownedWorkflowLanes?.length ? expectedLane.ownedWorkflowLanes : [expectedWorkflowLane];
|
|
3467
|
+
const failed = (failure) => ({
|
|
3468
|
+
ok: false,
|
|
3469
|
+
expectedLane,
|
|
3470
|
+
expectedWorkflowLane,
|
|
3471
|
+
expectedOwnedLanes,
|
|
3472
|
+
failure
|
|
3473
|
+
});
|
|
3474
|
+
if (batchFailure && !batchFailure.ok)
|
|
3475
|
+
return failed(batchFailure.failure);
|
|
3476
|
+
const laneRecords = recordsByLaneId.get(expectedLane.laneId) ?? [];
|
|
3477
|
+
if (laneRecords.length === 0) {
|
|
3478
|
+
return failed(failedLaneValidation("record.missing", "exactly one record", 0).failure);
|
|
3479
|
+
}
|
|
3480
|
+
if (laneRecords.length !== 1) {
|
|
3481
|
+
return failed(failedLaneValidation("record.duplicate_lane", "exactly one record", laneRecords.length).failure);
|
|
3482
|
+
}
|
|
3483
|
+
const record = laneRecords[0];
|
|
3385
3484
|
const subagentSessionId = record.subagentSessionId?.trim();
|
|
3386
|
-
if (
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3485
|
+
if (!subagentSessionId) {
|
|
3486
|
+
return failed(failedLaneValidation("record.subagent_session_id", "non-empty child session id", record.subagentSessionId ?? "(missing)").failure);
|
|
3487
|
+
}
|
|
3488
|
+
if (recordCountBySubagentSessionId.get(subagentSessionId) !== 1) {
|
|
3489
|
+
return failed(failedLaneValidation("record.duplicate_subagent_session_id", "one record per child session", recordCountBySubagentSessionId.get(subagentSessionId)).failure);
|
|
3490
|
+
}
|
|
3491
|
+
if (args.forbiddenSubagentSessionIds.has(subagentSessionId)) {
|
|
3492
|
+
return failed(failedLaneValidation("record.forbidden_subagent_session_id", "child session not reused from a forbidden phase", subagentSessionId).failure);
|
|
3493
|
+
}
|
|
3494
|
+
if (record.createdAt < validatedAtMs) {
|
|
3495
|
+
return failed(failedLaneValidation("record.created_at", `at or after ${args.validatedAt}`, new Date(record.createdAt).toISOString()).failure);
|
|
3496
|
+
}
|
|
3497
|
+
const recordIntegrity = analyzeLaneRecordResultIntegrity({
|
|
3498
|
+
record,
|
|
3499
|
+
result: record.result,
|
|
3500
|
+
expected: {
|
|
3501
|
+
mode: args.expectedMode,
|
|
3502
|
+
workflowLane: expectedWorkflowLane,
|
|
3503
|
+
ownedWorkflowLanes: expectedOwnedLanes,
|
|
3504
|
+
prHeadSha: args.expectedPrHeadSha ?? record.workspace?.prHeadSha ?? "",
|
|
3505
|
+
gitHead: args.expectedPrHeadSha ?? record.workspace?.gitHead ?? "",
|
|
3506
|
+
checkWorkflowLane: args.checkWorkflowLane
|
|
3507
|
+
},
|
|
3508
|
+
requireCompleted: true
|
|
3509
|
+
});
|
|
3510
|
+
if (!recordIntegrity.ok)
|
|
3511
|
+
return failed(recordIntegrity.failure);
|
|
3512
|
+
return {
|
|
3513
|
+
ok: true,
|
|
3514
|
+
record,
|
|
3515
|
+
expectedLane,
|
|
3516
|
+
expectedWorkflowLane,
|
|
3517
|
+
expectedOwnedLanes
|
|
3518
|
+
};
|
|
3519
|
+
});
|
|
3520
|
+
}
|
|
3521
|
+
function recordsPassingBatchIntegrity(directory, state, batchId, expectedLanes, expectedMode, validatedAt, checkWorkflowLane = true, forbiddenSubagentSessionIds = new Set, diagnostics) {
|
|
3522
|
+
const records = findByBatchId(directory, batchId, {
|
|
3523
|
+
parentSessionId: state.sessionID
|
|
3524
|
+
});
|
|
3525
|
+
const analyses = analyzePrReviewBatchRecordIntegrity({
|
|
3526
|
+
batchId,
|
|
3527
|
+
expectedLanes,
|
|
3528
|
+
expectedMode,
|
|
3529
|
+
validatedAt,
|
|
3530
|
+
checkWorkflowLane,
|
|
3531
|
+
forbiddenSubagentSessionIds,
|
|
3532
|
+
records,
|
|
3533
|
+
expectedPrHeadSha: state.prHeadSha
|
|
3534
|
+
});
|
|
3535
|
+
for (const analysis of analyses) {
|
|
3536
|
+
if (!analysis.ok && diagnostics && diagnostics.length < MAX_BASE_COVERAGE_DIAGNOSTICS) {
|
|
3537
|
+
diagnostics.push(`batch=${batchId} lane=${analysis.expectedLane.laneId} workflow_lane=${analysis.expectedWorkflowLane}: ${formatPrReviewLaneValidationFailure(analysis.failure)}`.slice(0, MAX_BASE_COVERAGE_DIAGNOSTIC_CHARS));
|
|
3393
3538
|
}
|
|
3394
3539
|
}
|
|
3395
|
-
return
|
|
3540
|
+
return analyses.filter((analysis) => analysis.ok);
|
|
3396
3541
|
}
|
|
3397
3542
|
function successfulObligationsFromExactBatch(directory, state, batchId, expectedLanes, expectedMode, validatedAt, checkWorkflowLane = true, forbiddenSubagentSessionIds = new Set, expectedRevisionDigest, diagnostics, reviewerClaims) {
|
|
3398
3543
|
const successful = new Set;
|
|
3399
|
-
for (const qualified of recordsPassingBatchIntegrity(directory, state, batchId, expectedLanes, expectedMode, validatedAt, checkWorkflowLane, forbiddenSubagentSessionIds)) {
|
|
3544
|
+
for (const qualified of recordsPassingBatchIntegrity(directory, state, batchId, expectedLanes, expectedMode, validatedAt, checkWorkflowLane, forbiddenSubagentSessionIds, diagnostics)) {
|
|
3400
3545
|
if (workflowArtifactHasContractMarker(directory, state, qualified.record, expectedMode, qualified.expectedWorkflowLane, qualified.expectedLane.reviewItemIds, expectedRevisionDigest, qualified.expectedOwnedLanes, diagnostics, reviewerClaims)) {
|
|
3401
3546
|
for (const obligation of qualified.expectedOwnedLanes) {
|
|
3402
3547
|
successful.add(obligation);
|
|
@@ -3416,25 +3561,98 @@ function ownedLaneSetsEqual(recordOwned, expectedOwned) {
|
|
|
3416
3561
|
}
|
|
3417
3562
|
return recordOwned.every((owned) => expectedSet.has(owned));
|
|
3418
3563
|
}
|
|
3419
|
-
function
|
|
3564
|
+
function analyzeLaneArtifactIntegrity(args) {
|
|
3565
|
+
const { record, result, artifact, expected } = args;
|
|
3566
|
+
if (!artifact) {
|
|
3567
|
+
return failedLaneValidation("artifact.readable", "readable stored artifact", "missing or invalid");
|
|
3568
|
+
}
|
|
3569
|
+
if (artifact.ref !== result.outputRef?.trim()) {
|
|
3570
|
+
return failedLaneValidation("artifact.ref", result.outputRef?.trim() ?? "(missing)", artifact.ref);
|
|
3571
|
+
}
|
|
3572
|
+
if (artifact.batchId !== record.batchId) {
|
|
3573
|
+
return failedLaneValidation("artifact.batch_id", record.batchId ?? "(missing)", artifact.batchId);
|
|
3574
|
+
}
|
|
3575
|
+
if (artifact.laneId !== record.laneId) {
|
|
3576
|
+
return failedLaneValidation("artifact.lane_id", record.laneId ?? "(missing)", artifact.laneId);
|
|
3577
|
+
}
|
|
3578
|
+
if (artifact.mode !== expected.mode) {
|
|
3579
|
+
return failedLaneValidation("artifact.mode", expected.mode, artifact.mode ?? "(missing)");
|
|
3580
|
+
}
|
|
3581
|
+
if (artifact.sessionId !== record.subagentSessionId) {
|
|
3582
|
+
return failedLaneValidation("artifact.session_id", record.subagentSessionId, artifact.sessionId ?? "(missing)");
|
|
3583
|
+
}
|
|
3584
|
+
if (artifact.parentSessionId !== record.parentSessionId) {
|
|
3585
|
+
return failedLaneValidation("artifact.parent_session_id", record.parentSessionId, artifact.parentSessionId ?? "(missing)");
|
|
3586
|
+
}
|
|
3587
|
+
if (artifact.agent !== record.swarmPrefixedAgent) {
|
|
3588
|
+
return failedLaneValidation("artifact.agent", record.swarmPrefixedAgent, artifact.agent);
|
|
3589
|
+
}
|
|
3590
|
+
if (artifact.role !== record.normalizedAgent) {
|
|
3591
|
+
return failedLaneValidation("artifact.role", record.normalizedAgent, artifact.role);
|
|
3592
|
+
}
|
|
3593
|
+
if (artifact.source !== "collect_lane_results") {
|
|
3594
|
+
return failedLaneValidation("artifact.source", "collect_lane_results", artifact.source);
|
|
3595
|
+
}
|
|
3596
|
+
if (artifact.workflowLane !== record.workflowLane) {
|
|
3597
|
+
return failedLaneValidation("artifact.workflow_lane_record", record.workflowLane ?? "(missing)", artifact.workflowLane ?? "(missing)");
|
|
3598
|
+
}
|
|
3599
|
+
if (artifact.workflowLane !== expected.workflowLane) {
|
|
3600
|
+
return failedLaneValidation("artifact.workflow_lane_expected", expected.workflowLane, artifact.workflowLane ?? "(missing)");
|
|
3601
|
+
}
|
|
3602
|
+
if (artifact.prHeadSha !== expected.prHeadSha) {
|
|
3603
|
+
return failedLaneValidation("artifact.pr_head_sha", expected.prHeadSha, artifact.prHeadSha ?? "(missing)");
|
|
3604
|
+
}
|
|
3605
|
+
if (artifact.gitHead !== expected.gitHead) {
|
|
3606
|
+
return failedLaneValidation("artifact.git_head", expected.gitHead, artifact.gitHead ?? "(missing)");
|
|
3607
|
+
}
|
|
3608
|
+
if (artifact.revisionDigest !== expected.revisionDigest) {
|
|
3609
|
+
return failedLaneValidation("artifact.revision_digest", expected.revisionDigest, artifact.revisionDigest ?? "(missing)");
|
|
3610
|
+
}
|
|
3611
|
+
if (expected.reviewScope !== undefined && record.workspace?.scope !== expected.reviewScope) {
|
|
3612
|
+
return failedLaneValidation("record.scope", expected.reviewScope, record.workspace?.scope ?? "(missing)");
|
|
3613
|
+
}
|
|
3614
|
+
if (expected.reviewScope !== undefined && artifact.scope !== expected.reviewScope) {
|
|
3615
|
+
return failedLaneValidation("artifact.scope", expected.reviewScope, artifact.scope ?? "(missing)");
|
|
3616
|
+
}
|
|
3617
|
+
if (artifact.digest !== result.digest) {
|
|
3618
|
+
return failedLaneValidation("artifact.digest", result.digest, artifact.digest);
|
|
3619
|
+
}
|
|
3620
|
+
if (artifact.chars !== result.chars) {
|
|
3621
|
+
return failedLaneValidation("artifact.chars", result.chars, artifact.chars);
|
|
3622
|
+
}
|
|
3623
|
+
return { ok: true };
|
|
3624
|
+
}
|
|
3625
|
+
function loadArtifactPassingLaneIntegrity(directory, state, record, expectedMode, expectedWorkflowLane, expectedRevisionDigest, diagnostics) {
|
|
3420
3626
|
const ref = record.result?.outputRef?.trim();
|
|
3421
3627
|
if (!ref)
|
|
3422
3628
|
return null;
|
|
3423
3629
|
const loaded = readLaneOutput(directory, ref);
|
|
3424
|
-
|
|
3425
|
-
return null;
|
|
3426
|
-
const artifact = loaded.artifact;
|
|
3427
|
-
const recordPrHeadSha = record.workspace?.prHeadSha;
|
|
3428
|
-
const recordGitHead = record.workspace?.gitHead;
|
|
3630
|
+
const artifact = loaded?.artifact ?? null;
|
|
3429
3631
|
const expectedReviewScope = state.mode === "PR_REVIEW" && state.prReviewBaseSha && state.prHeadSha ? `complete PR diff ${state.prReviewBaseSha}...${state.prHeadSha}` : undefined;
|
|
3430
|
-
|
|
3632
|
+
const integrity = analyzeLaneArtifactIntegrity({
|
|
3633
|
+
record,
|
|
3634
|
+
result: record.result,
|
|
3635
|
+
artifact,
|
|
3636
|
+
expected: {
|
|
3637
|
+
mode: expectedMode,
|
|
3638
|
+
workflowLane: expectedWorkflowLane,
|
|
3639
|
+
prHeadSha: record.workspace?.prHeadSha ?? "",
|
|
3640
|
+
gitHead: record.workspace?.gitHead ?? "",
|
|
3641
|
+
revisionDigest: expectedRevisionDigest,
|
|
3642
|
+
reviewScope: expectedReviewScope
|
|
3643
|
+
}
|
|
3644
|
+
});
|
|
3645
|
+
if (!integrity.ok) {
|
|
3646
|
+
if (diagnostics && diagnostics.length < MAX_BASE_COVERAGE_DIAGNOSTICS) {
|
|
3647
|
+
diagnostics.push(`batch=${record.batchId ?? "(missing)"} lane=${record.laneId ?? "(missing)"} workflow_lane=${expectedWorkflowLane} output_ref=${ref}: ${formatPrReviewLaneValidationFailure(integrity.failure)}`.slice(0, MAX_BASE_COVERAGE_DIAGNOSTIC_CHARS));
|
|
3648
|
+
}
|
|
3431
3649
|
return null;
|
|
3432
3650
|
}
|
|
3433
3651
|
return artifact;
|
|
3434
3652
|
}
|
|
3435
3653
|
function workflowArtifactHasContractMarker(directory, state, record, expectedMode, expectedWorkflowLane, reviewItemIds, expectedRevisionDigest, ownedWorkflowLanes, diagnostics, reviewerClaims) {
|
|
3436
3654
|
const ref = record.result?.outputRef?.trim();
|
|
3437
|
-
const artifact = expectedRevisionDigest ? loadArtifactPassingLaneIntegrity(directory, state, record, expectedMode, expectedWorkflowLane, expectedRevisionDigest) : null;
|
|
3655
|
+
const artifact = expectedRevisionDigest ? loadArtifactPassingLaneIntegrity(directory, state, record, expectedMode, expectedWorkflowLane, expectedRevisionDigest, diagnostics) : null;
|
|
3438
3656
|
if (!artifact)
|
|
3439
3657
|
return false;
|
|
3440
3658
|
if (expectedMode === "swarm-pr-review:reviewer" || expectedMode === "swarm-pr-review:critic") {
|
|
@@ -3454,6 +3672,30 @@ function workflowArtifactHasContractMarker(directory, state, record, expectedMod
|
|
|
3454
3672
|
if (feedbackVerdict) {
|
|
3455
3673
|
return Boolean(reviewItemIds?.length && reviewItemIds.every((itemId) => artifactHasExactPositiveVerdictRow(artifact.text, feedbackVerdict[0], itemId, feedbackVerdict[1])));
|
|
3456
3674
|
}
|
|
3675
|
+
if (expectedMode === "swarm-pr-review:base" || expectedMode === "swarm-pr-review:micro") {
|
|
3676
|
+
const reviewScope = state.mode === "PR_REVIEW" && state.prReviewBaseSha && state.prHeadSha ? `complete PR diff ${state.prReviewBaseSha}...${state.prHeadSha}` : undefined;
|
|
3677
|
+
const validation = validatePrReviewDiscoveryLaneCompletion({
|
|
3678
|
+
record,
|
|
3679
|
+
result: record.result,
|
|
3680
|
+
artifact,
|
|
3681
|
+
expected: {
|
|
3682
|
+
mode: expectedMode,
|
|
3683
|
+
workflowLane: expectedWorkflowLane,
|
|
3684
|
+
ownedWorkflowLanes,
|
|
3685
|
+
prHeadSha: state.prHeadSha ?? "",
|
|
3686
|
+
gitHead: state.prHeadSha ?? "",
|
|
3687
|
+
revisionDigest: expectedRevisionDigest ?? "",
|
|
3688
|
+
reviewScope
|
|
3689
|
+
}
|
|
3690
|
+
});
|
|
3691
|
+
if (!validation.ok) {
|
|
3692
|
+
if (diagnostics && diagnostics.length < MAX_BASE_COVERAGE_DIAGNOSTICS) {
|
|
3693
|
+
diagnostics.push(`batch=${record.batchId ?? "(missing)"} lane=${record.laneId ?? "(missing)"} workflow_lane=${expectedWorkflowLane} output_ref=${ref}: ${formatPrReviewLaneValidationFailure(validation.failure)}`.slice(0, MAX_BASE_COVERAGE_DIAGNOSTIC_CHARS));
|
|
3694
|
+
}
|
|
3695
|
+
return false;
|
|
3696
|
+
}
|
|
3697
|
+
return true;
|
|
3698
|
+
}
|
|
3457
3699
|
const coveredLanes = ownedWorkflowLanes?.length ? ownedWorkflowLanes : [expectedWorkflowLane];
|
|
3458
3700
|
const coverageAnalyses = coveredLanes.map((coveredLane) => ({
|
|
3459
3701
|
coveredLane,
|
|
@@ -3491,7 +3733,12 @@ function analyzePrReviewDiscoveryArtifact(text, expectedWorkflowLane, ownedWorkf
|
|
|
3491
3733
|
const header = selectCandidateHeader(canonicalText.split(/\r?\n/));
|
|
3492
3734
|
if (header === null || !header.markerBearing || header.family !== fallbackFamily) {
|
|
3493
3735
|
appendBoundedCandidateIssue(issues, `field header: expected one exact canonical ${fallbackFamily} [CANDIDATE] header before discovery rows`);
|
|
3494
|
-
return {
|
|
3736
|
+
return {
|
|
3737
|
+
covered: false,
|
|
3738
|
+
evidence: null,
|
|
3739
|
+
issues,
|
|
3740
|
+
failurePredicate: "discovery.header"
|
|
3741
|
+
};
|
|
3495
3742
|
}
|
|
3496
3743
|
const parsed = parseCandidates({
|
|
3497
3744
|
output_ref: "pr-workflow:discovery-artifact",
|
|
@@ -3525,7 +3772,12 @@ function analyzePrReviewDiscoveryArtifact(text, expectedWorkflowLane, ownedWorkf
|
|
|
3525
3772
|
appendBoundedCandidateIssue(issues, `row ${detail.row_index + 1} field ${detail.field}: ${detail.message}`);
|
|
3526
3773
|
}
|
|
3527
3774
|
if (parsed.error || parsed.diagnostics.parse_error_details.length > 0) {
|
|
3528
|
-
return {
|
|
3775
|
+
return {
|
|
3776
|
+
covered: false,
|
|
3777
|
+
evidence: null,
|
|
3778
|
+
issues,
|
|
3779
|
+
failurePredicate: "discovery.row"
|
|
3780
|
+
};
|
|
3529
3781
|
}
|
|
3530
3782
|
const matchingCandidate = parsed.candidates.find((candidate) => (candidate.lane ?? candidate.micro_lane) === expectedWorkflowLane);
|
|
3531
3783
|
if (matchingCandidate) {
|
|
@@ -3551,7 +3803,67 @@ function analyzePrReviewDiscoveryArtifact(text, expectedWorkflowLane, ownedWorkf
|
|
|
3551
3803
|
issues
|
|
3552
3804
|
};
|
|
3553
3805
|
}
|
|
3554
|
-
return {
|
|
3806
|
+
return {
|
|
3807
|
+
covered: false,
|
|
3808
|
+
evidence: null,
|
|
3809
|
+
issues,
|
|
3810
|
+
failurePredicate: "discovery.coverage"
|
|
3811
|
+
};
|
|
3812
|
+
}
|
|
3813
|
+
function validatePrReviewDiscoveryLaneCompletion(input) {
|
|
3814
|
+
const ownedWorkflowLanes = input.expected.ownedWorkflowLanes?.length ? [...input.expected.ownedWorkflowLanes] : [input.expected.workflowLane];
|
|
3815
|
+
const recordIntegrity = analyzeLaneRecordResultIntegrity({
|
|
3816
|
+
record: input.record,
|
|
3817
|
+
result: input.result,
|
|
3818
|
+
expected: {
|
|
3819
|
+
mode: input.expected.mode,
|
|
3820
|
+
workflowLane: input.expected.workflowLane,
|
|
3821
|
+
ownedWorkflowLanes,
|
|
3822
|
+
prHeadSha: input.expected.prHeadSha,
|
|
3823
|
+
gitHead: input.expected.gitHead,
|
|
3824
|
+
checkWorkflowLane: input.expected.checkWorkflowLane ?? true
|
|
3825
|
+
},
|
|
3826
|
+
requireCompleted: false
|
|
3827
|
+
});
|
|
3828
|
+
if (!recordIntegrity.ok)
|
|
3829
|
+
return recordIntegrity;
|
|
3830
|
+
const artifactIntegrity = analyzeLaneArtifactIntegrity({
|
|
3831
|
+
record: input.record,
|
|
3832
|
+
result: input.result,
|
|
3833
|
+
artifact: input.artifact,
|
|
3834
|
+
expected: {
|
|
3835
|
+
mode: input.expected.mode,
|
|
3836
|
+
workflowLane: input.expected.workflowLane,
|
|
3837
|
+
prHeadSha: input.expected.prHeadSha,
|
|
3838
|
+
gitHead: input.expected.gitHead,
|
|
3839
|
+
revisionDigest: input.expected.revisionDigest,
|
|
3840
|
+
reviewScope: input.expected.reviewScope
|
|
3841
|
+
}
|
|
3842
|
+
});
|
|
3843
|
+
if (!artifactIntegrity.ok)
|
|
3844
|
+
return artifactIntegrity;
|
|
3845
|
+
const artifact = input.artifact;
|
|
3846
|
+
const analyses = ownedWorkflowLanes.map((workflowLane) => ({
|
|
3847
|
+
workflowLane,
|
|
3848
|
+
analysis: analyzePrReviewDiscoveryArtifact(artifact.text, workflowLane, ownedWorkflowLanes)
|
|
3849
|
+
}));
|
|
3850
|
+
const failedCoverage = analyses.find(({ analysis }) => !analysis.covered);
|
|
3851
|
+
if (failedCoverage) {
|
|
3852
|
+
return failedLaneValidation(failedCoverage.analysis.failurePredicate ?? "discovery.coverage", `one valid ${input.expected.mode === "swarm-pr-review:base" ? "base_explorer" : "micro_lane"} [CANDIDATE] row or [CLEAN] attestation for ${failedCoverage.workflowLane}`, failedCoverage.analysis.issues.join("; ") || "no matching lane row");
|
|
3853
|
+
}
|
|
3854
|
+
if (ownedWorkflowLanes.length > 1) {
|
|
3855
|
+
const seenEvidence = new Map;
|
|
3856
|
+
for (const { workflowLane, analysis } of analyses) {
|
|
3857
|
+
if (analysis.evidence === null)
|
|
3858
|
+
continue;
|
|
3859
|
+
const priorLane = seenEvidence.get(analysis.evidence);
|
|
3860
|
+
if (priorLane) {
|
|
3861
|
+
return failedLaneValidation("discovery.duplicate_evidence", "distinct evidence for every owned workflow lane", `${priorLane} and ${workflowLane} share evidence`);
|
|
3862
|
+
}
|
|
3863
|
+
seenEvidence.set(analysis.evidence, workflowLane);
|
|
3864
|
+
}
|
|
3865
|
+
}
|
|
3866
|
+
return { ok: true };
|
|
3555
3867
|
}
|
|
3556
3868
|
function prReviewDiscoveryArtifactCoversLane(text, expectedWorkflowLane, ownedWorkflowLanes = [expectedWorkflowLane]) {
|
|
3557
3869
|
return analyzePrReviewDiscoveryArtifact(text, expectedWorkflowLane, ownedWorkflowLanes).covered;
|
|
@@ -18157,7 +18469,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
|
|
|
18157
18469
|
};
|
|
18158
18470
|
}
|
|
18159
18471
|
async function sweepActiveNearDuplicates(directory, options = {}) {
|
|
18160
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
18472
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-5k0csd2m.js");
|
|
18161
18473
|
const { config } = loadPluginConfigWithMeta2(directory);
|
|
18162
18474
|
const sweepConfig = config.learning?.dedup_sweep;
|
|
18163
18475
|
if (sweepConfig?.enabled === false)
|
|
@@ -19750,7 +20062,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
19750
20062
|
}
|
|
19751
20063
|
if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
|
|
19752
20064
|
try {
|
|
19753
|
-
const skillModule = await import("./skill-generator-
|
|
20065
|
+
const skillModule = await import("./skill-generator-0q1jk6xd.js");
|
|
19754
20066
|
for (const cand of skillCandidates) {
|
|
19755
20067
|
if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
|
|
19756
20068
|
continue;
|
|
@@ -20210,7 +20522,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
|
|
|
20210
20522
|
} catch {}
|
|
20211
20523
|
}
|
|
20212
20524
|
if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
|
|
20213
|
-
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-
|
|
20525
|
+
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-e9zk371p.js");
|
|
20214
20526
|
for (const { id } of contradictedEntries) {
|
|
20215
20527
|
try {
|
|
20216
20528
|
await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
|
|
@@ -21029,7 +21341,7 @@ async function runCuratorPostMortem(directory, options = {}) {
|
|
|
21029
21341
|
warnings.push("Failed to collect knowledge summary.");
|
|
21030
21342
|
}
|
|
21031
21343
|
try {
|
|
21032
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
21344
|
+
const { getScanStatus } = await import("./scan-cursor-z4xpes5f.js");
|
|
21033
21345
|
const scanStatus = await getScanStatus(directory);
|
|
21034
21346
|
if (scanStatus.remaining_estimate > 0) {
|
|
21035
21347
|
warnings.push(`Fair scan: reviewed ${knowledgeSummary.length} entries this sweep (generation ${scanStatus.generation}); ${scanStatus.remaining_estimate} more eligible entries will be visited in future curation sweeps.`);
|
|
@@ -21201,9 +21513,9 @@ var _internals24 = {
|
|
|
21201
21513
|
verifyPostMortemKnowledgeActions,
|
|
21202
21514
|
repairPostMortemActions,
|
|
21203
21515
|
loadDefaultKnowledgeConfig: async (directory) => {
|
|
21204
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
21516
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-2dkw18zz.js");
|
|
21205
21517
|
try {
|
|
21206
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
21518
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-5k0csd2m.js");
|
|
21207
21519
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
21208
21520
|
return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
21209
21521
|
} catch {
|
|
@@ -21211,11 +21523,11 @@ var _internals24 = {
|
|
|
21211
21523
|
}
|
|
21212
21524
|
},
|
|
21213
21525
|
applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
|
|
21214
|
-
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-
|
|
21526
|
+
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-h1ea9skz.js");
|
|
21215
21527
|
return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
|
|
21216
21528
|
},
|
|
21217
21529
|
checkHivePromotions: async (entries, knowledgeConfig, directory) => {
|
|
21218
|
-
const { checkHivePromotions } = await import("./hive-promoter-
|
|
21530
|
+
const { checkHivePromotions } = await import("./hive-promoter-qsymj94z.js");
|
|
21219
21531
|
return checkHivePromotions(entries, knowledgeConfig, directory);
|
|
21220
21532
|
},
|
|
21221
21533
|
applyProposalTriage: async (directory, triage) => {
|
|
@@ -21224,7 +21536,7 @@ var _internals24 = {
|
|
|
21224
21536
|
activateProposal,
|
|
21225
21537
|
listSkills: listSkills2,
|
|
21226
21538
|
sanitizeSlug
|
|
21227
|
-
} = await import("./skill-generator-
|
|
21539
|
+
} = await import("./skill-generator-0q1jk6xd.js");
|
|
21228
21540
|
const result = {
|
|
21229
21541
|
approved: [],
|
|
21230
21542
|
rejected: [],
|
|
@@ -23851,9 +24163,9 @@ function hashContent(content) {
|
|
|
23851
24163
|
return createHash9("sha1").update(content).digest("hex");
|
|
23852
24164
|
}
|
|
23853
24165
|
async function loadConfigForPolicyCurator(directory) {
|
|
23854
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
24166
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-2dkw18zz.js");
|
|
23855
24167
|
try {
|
|
23856
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
24168
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-5k0csd2m.js");
|
|
23857
24169
|
const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
|
|
23858
24170
|
return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
|
|
23859
24171
|
} catch {
|
|
@@ -26930,6 +27242,7 @@ var KNOWLEDGE_FAMILY_ARTIFACTS = new Set([
|
|
|
26930
27242
|
"knowledge-rejected.jsonl"
|
|
26931
27243
|
]);
|
|
26932
27244
|
var ACTIVE_STATE_DIRS_TO_CLEAN = [
|
|
27245
|
+
"council",
|
|
26933
27246
|
"evidence",
|
|
26934
27247
|
"session",
|
|
26935
27248
|
"scopes",
|
|
@@ -27198,7 +27511,7 @@ async function runFinalizeStage(ctx) {
|
|
|
27198
27511
|
}
|
|
27199
27512
|
}
|
|
27200
27513
|
try {
|
|
27201
|
-
const { CuratorConfigSchema: CCS } = await import("./schema-
|
|
27514
|
+
const { CuratorConfigSchema: CCS } = await import("./schema-2dkw18zz.js");
|
|
27202
27515
|
const { config: pmLoadedConfig } = _internals34.loadPluginConfigWithMeta(ctx.directory);
|
|
27203
27516
|
const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
|
|
27204
27517
|
if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
|
|
@@ -29428,9 +29741,9 @@ var _internals39 = {
|
|
|
29428
29741
|
loadPluginConfigWithMeta,
|
|
29429
29742
|
loadCuratorDeps: async () => {
|
|
29430
29743
|
const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
|
|
29431
|
-
import("./schema-
|
|
29432
|
-
import("./curator-
|
|
29433
|
-
import("./curator-llm-factory-
|
|
29744
|
+
import("./schema-2dkw18zz.js"),
|
|
29745
|
+
import("./curator-h1ea9skz.js"),
|
|
29746
|
+
import("./curator-llm-factory-rk7pccwc.js")
|
|
29434
29747
|
]);
|
|
29435
29748
|
return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
|
|
29436
29749
|
}
|
|
@@ -30335,7 +30648,7 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
30335
30648
|
let scanCompleted = false;
|
|
30336
30649
|
let scanRemaining = 0;
|
|
30337
30650
|
try {
|
|
30338
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
30651
|
+
const { getScanStatus } = await import("./scan-cursor-z4xpes5f.js");
|
|
30339
30652
|
const status = await getScanStatus(directory);
|
|
30340
30653
|
scanGeneration = status.generation;
|
|
30341
30654
|
scanCompleted = status.completed;
|
|
@@ -30345,17 +30658,17 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
30345
30658
|
try {
|
|
30346
30659
|
const { isLinked: isLinked2 } = await import("./knowledge-link-t94b79qe.js");
|
|
30347
30660
|
if (isLinked2(directory)) {
|
|
30348
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
30661
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-2dkw18zz.js");
|
|
30349
30662
|
let config;
|
|
30350
30663
|
try {
|
|
30351
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
30664
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-5k0csd2m.js");
|
|
30352
30665
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
30353
30666
|
config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
30354
30667
|
} catch {
|
|
30355
30668
|
config = KnowledgeConfigSchema2.parse({});
|
|
30356
30669
|
}
|
|
30357
30670
|
const { cohortConfigFingerprint: cohortConfigFingerprint2 } = await import("./config-fingerprint-v22xh5a2.js");
|
|
30358
|
-
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-
|
|
30671
|
+
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-xyradeax.js");
|
|
30359
30672
|
const currentFp = cohortConfigFingerprint2(buildConfigFingerprintInput2(config));
|
|
30360
30673
|
const cohortFp = await readCohortConfigFingerprint(directory);
|
|
30361
30674
|
configMatch = cohortFp === null ? null : currentFp === cohortFp;
|
|
@@ -31566,7 +31879,7 @@ async function handleDoctorCommand(directory, args) {
|
|
|
31566
31879
|
const result = runConfigDoctor(config, directory);
|
|
31567
31880
|
let output;
|
|
31568
31881
|
if (enableAutoFix && result.hasAutoFixableIssues) {
|
|
31569
|
-
const { runConfigDoctorWithFixes } = await import("./config-doctor-
|
|
31882
|
+
const { runConfigDoctorWithFixes } = await import("./config-doctor-xrbzq4r0.js");
|
|
31570
31883
|
const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
|
|
31571
31884
|
applyLossy: true
|
|
31572
31885
|
});
|
|
@@ -36407,13 +36720,14 @@ function errorCell(args) {
|
|
|
36407
36720
|
function parseModelVerdict(text) {
|
|
36408
36721
|
return ModelVerdictSchema.parse(JSON.parse(text.trim()));
|
|
36409
36722
|
}
|
|
36410
|
-
function modelPrompt(task, instruction, variant) {
|
|
36723
|
+
function modelPrompt(task, instruction, variant, fixtureDir) {
|
|
36411
36724
|
return [
|
|
36412
36725
|
"You are executing a read-only production gate audit against a curated defect fixture.",
|
|
36413
36726
|
`Defect id: ${task.id}`,
|
|
36414
36727
|
`Category: ${task.category}`,
|
|
36415
36728
|
variant === "defect" ? instruction : "This is a reviewed clean control. Report caught=false unless you find a concrete defect in the supplied implementation.",
|
|
36416
|
-
|
|
36729
|
+
`Inspect ONLY the files under: ${fixtureDir}`,
|
|
36730
|
+
"Do not modify them and do not inspect files outside that directory.",
|
|
36417
36731
|
"Return exactly one JSON object and no markdown:",
|
|
36418
36732
|
'{"v":1,"caught":true|false,"reason":"concise evidence"}'
|
|
36419
36733
|
].join(`
|
|
@@ -36691,11 +37005,11 @@ async function runCell(args) {
|
|
|
36691
37005
|
});
|
|
36692
37006
|
}
|
|
36693
37007
|
const dispatch = await args.options.dispatcher({
|
|
36694
|
-
|
|
37008
|
+
sessionDirectory: args.options.projectRoot,
|
|
36695
37009
|
agentName: args.gate === "reviewer" ? "reviewer" : "test_engineer",
|
|
36696
37010
|
modelId: args.model,
|
|
36697
37011
|
preferredSwarm: args.options.manifest.preferredSwarm,
|
|
36698
|
-
prompt: modelPrompt(args.task, instruction, args.variant),
|
|
37012
|
+
prompt: modelPrompt(args.task, instruction, args.variant, tempRoot),
|
|
36699
37013
|
timeoutMs: Math.min(args.options.manifest.maxTimeMs, 120000),
|
|
36700
37014
|
parentSessionId: args.options.parentSessionId,
|
|
36701
37015
|
abortSignal: args.signal
|
|
@@ -51400,7 +51714,7 @@ Ensure this is a git repository with commit history.`;
|
|
|
51400
51714
|
// src/commands/skill-opt.ts
|
|
51401
51715
|
init_schema();
|
|
51402
51716
|
import { copyFileSync as copyFileSync5, existsSync as existsSync57, mkdirSync as mkdirSync31, readFileSync as readFileSync43 } from "fs";
|
|
51403
|
-
import * as
|
|
51717
|
+
import * as path100 from "path";
|
|
51404
51718
|
|
|
51405
51719
|
// src/services/skill-optimizer/activation.ts
|
|
51406
51720
|
import {
|
|
@@ -51860,7 +52174,117 @@ async function rollbackCandidate(input) {
|
|
|
51860
52174
|
// src/services/skill-optimizer/controller.ts
|
|
51861
52175
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
51862
52176
|
import { existsSync as existsSync55, mkdirSync as mkdirSync29, readFileSync as readFileSync42, writeFileSync as writeFileSync19 } from "fs";
|
|
51863
|
-
import * as
|
|
52177
|
+
import * as path98 from "path";
|
|
52178
|
+
|
|
52179
|
+
// src/evaluation/pr-review-recovery.ts
|
|
52180
|
+
import * as fs48 from "fs/promises";
|
|
52181
|
+
import * as path96 from "path";
|
|
52182
|
+
var PR_REVIEW_RECOVERY_BASE_SHA = "3811fe5981072c7fa541523e9f08430f18594590";
|
|
52183
|
+
var FIXTURE_ROOT = "evaluation-fixtures/pr-review-recovery";
|
|
52184
|
+
var BASELINE_MANIFEST_PATH = `${FIXTURE_ROOT}/baseline-manifest.json`;
|
|
52185
|
+
var BASELINE_PAYLOAD_PATH = `${FIXTURE_ROOT}/baseline/SKILL.md`;
|
|
52186
|
+
var CANDIDATE_PAYLOAD_PATH = ".opencode/skills/swarm-pr-review/SKILL.md";
|
|
52187
|
+
var INSTRUCTION_PATH = `${FIXTURE_ROOT}/instruction.md`;
|
|
52188
|
+
var ENVIRONMENT_PATH = `${FIXTURE_ROOT}/environment`;
|
|
52189
|
+
var SCORER_PATH = `${ENVIRONMENT_PATH}/score-recovery.cjs`;
|
|
52190
|
+
function parseBaselineManifest(value) {
|
|
52191
|
+
if (value === null || typeof value !== "object" || Array.isArray(value) || Object.keys(value).sort().join("\x00") !== ["v", "sourceSha", "payloadPath", "sha256"].sort().join("\x00")) {
|
|
52192
|
+
throw new Error("PR-review recovery baseline manifest is invalid");
|
|
52193
|
+
}
|
|
52194
|
+
const manifest = value;
|
|
52195
|
+
if (manifest.v !== 1 || typeof manifest.sourceSha !== "string" || typeof manifest.payloadPath !== "string" || typeof manifest.sha256 !== "string") {
|
|
52196
|
+
throw new Error("PR-review recovery baseline manifest is invalid");
|
|
52197
|
+
}
|
|
52198
|
+
return manifest;
|
|
52199
|
+
}
|
|
52200
|
+
async function candidate(packageRoot, input) {
|
|
52201
|
+
return {
|
|
52202
|
+
...input,
|
|
52203
|
+
contentHash: await computeCandidateInputContentHash(packageRoot, input)
|
|
52204
|
+
};
|
|
52205
|
+
}
|
|
52206
|
+
async function task(packageRoot) {
|
|
52207
|
+
const input = {
|
|
52208
|
+
v: 1,
|
|
52209
|
+
id: "pr-review-controller-recovery",
|
|
52210
|
+
source: "curated",
|
|
52211
|
+
split: "train",
|
|
52212
|
+
category: "pr-review-recovery",
|
|
52213
|
+
protected: true,
|
|
52214
|
+
instructionPath: INSTRUCTION_PATH,
|
|
52215
|
+
environment: { kind: "fixture", path: ENVIRONMENT_PATH },
|
|
52216
|
+
scorer: {
|
|
52217
|
+
kind: "project",
|
|
52218
|
+
argv: [SCORER_PATH],
|
|
52219
|
+
timeoutMs: 30000,
|
|
52220
|
+
scoreRange: [0, 1]
|
|
52221
|
+
},
|
|
52222
|
+
provenance: {
|
|
52223
|
+
origin: "https://github.com/ZaxbyHub/opencode-swarm/issues/2075",
|
|
52224
|
+
license: "MIT"
|
|
52225
|
+
}
|
|
52226
|
+
};
|
|
52227
|
+
return {
|
|
52228
|
+
...input,
|
|
52229
|
+
contentHash: await computeTaskInputContentHash(packageRoot, input)
|
|
52230
|
+
};
|
|
52231
|
+
}
|
|
52232
|
+
async function verifyBaseline(packageRoot, requestedSourceSha) {
|
|
52233
|
+
if (requestedSourceSha !== PR_REVIEW_RECOVERY_BASE_SHA) {
|
|
52234
|
+
throw new Error(`PR-review recovery baseline source SHA must be ${PR_REVIEW_RECOVERY_BASE_SHA}`);
|
|
52235
|
+
}
|
|
52236
|
+
const manifest = parseBaselineManifest(JSON.parse(await fs48.readFile(path96.join(packageRoot, BASELINE_MANIFEST_PATH), "utf8")));
|
|
52237
|
+
if (manifest.sourceSha !== PR_REVIEW_RECOVERY_BASE_SHA || manifest.payloadPath !== BASELINE_PAYLOAD_PATH) {
|
|
52238
|
+
throw new Error("PR-review recovery baseline source SHA is invalid");
|
|
52239
|
+
}
|
|
52240
|
+
const payload = await fs48.readFile(path96.join(packageRoot, manifest.payloadPath));
|
|
52241
|
+
if (sha256(payload) !== manifest.sha256) {
|
|
52242
|
+
throw new Error("PR-review recovery baseline payload hash is invalid");
|
|
52243
|
+
}
|
|
52244
|
+
}
|
|
52245
|
+
async function evaluatePrReviewRecoveryV1(options) {
|
|
52246
|
+
const packageRoot = path96.resolve(options.packageRoot ?? options.projectRoot);
|
|
52247
|
+
await verifyBaseline(packageRoot, options.baselineSourceSha ?? PR_REVIEW_RECOVERY_BASE_SHA);
|
|
52248
|
+
const model = options.model ?? "configured";
|
|
52249
|
+
const baseline = await candidate(packageRoot, {
|
|
52250
|
+
v: 1,
|
|
52251
|
+
id: "pr-review-recovery-baseline",
|
|
52252
|
+
kind: "baseline",
|
|
52253
|
+
payloadPath: BASELINE_PAYLOAD_PATH,
|
|
52254
|
+
model,
|
|
52255
|
+
agent: "reviewer"
|
|
52256
|
+
});
|
|
52257
|
+
const current = await candidate(packageRoot, {
|
|
52258
|
+
v: 1,
|
|
52259
|
+
id: "pr-review-recovery-candidate",
|
|
52260
|
+
kind: "skill",
|
|
52261
|
+
payloadPath: CANDIDATE_PAYLOAD_PATH,
|
|
52262
|
+
model,
|
|
52263
|
+
agent: "reviewer"
|
|
52264
|
+
});
|
|
52265
|
+
const budgets = {
|
|
52266
|
+
maxTasks: 1,
|
|
52267
|
+
maxRepetitions: 1,
|
|
52268
|
+
maxConcurrency: 1,
|
|
52269
|
+
maxTaskTimeMs: 60000,
|
|
52270
|
+
maxRetries: 0,
|
|
52271
|
+
maxOutputBytes: 32 * 1024,
|
|
52272
|
+
...options.budgets
|
|
52273
|
+
};
|
|
52274
|
+
return runEvaluation({
|
|
52275
|
+
projectRoot: options.projectRoot,
|
|
52276
|
+
inputRoot: packageRoot,
|
|
52277
|
+
tasks: [await task(packageRoot)],
|
|
52278
|
+
baseline,
|
|
52279
|
+
candidate: current,
|
|
52280
|
+
split: "train",
|
|
52281
|
+
seed: options.seed ?? "pr-review-recovery-v1",
|
|
52282
|
+
models: [model],
|
|
52283
|
+
budgets,
|
|
52284
|
+
executor: createModelEvaluationExecutor(options.dispatcher, options.parentSessionId),
|
|
52285
|
+
abortSignal: options.abortSignal
|
|
52286
|
+
});
|
|
52287
|
+
}
|
|
51864
52288
|
|
|
51865
52289
|
// src/evaluation/statistics.ts
|
|
51866
52290
|
function normalize8(result) {
|
|
@@ -51881,16 +52305,16 @@ function collectPairs(candidateResults, referenceResults) {
|
|
|
51881
52305
|
const referenceResult = references.get(resultKey(candidateResult));
|
|
51882
52306
|
if (!referenceResult)
|
|
51883
52307
|
continue;
|
|
51884
|
-
const
|
|
52308
|
+
const candidate2 = normalize8(candidateResult);
|
|
51885
52309
|
const reference = normalize8(referenceResult);
|
|
51886
|
-
if (
|
|
52310
|
+
if (candidate2 === undefined || reference === undefined)
|
|
51887
52311
|
continue;
|
|
51888
52312
|
pairs.push({
|
|
51889
52313
|
key: resultKey(candidateResult),
|
|
51890
52314
|
category: candidateResult.category,
|
|
51891
52315
|
protected: candidateResult.protected || referenceResult.protected,
|
|
51892
52316
|
reference,
|
|
51893
|
-
candidate,
|
|
52317
|
+
candidate: candidate2,
|
|
51894
52318
|
referenceResult,
|
|
51895
52319
|
candidateResult
|
|
51896
52320
|
});
|
|
@@ -52074,6 +52498,7 @@ async function evaluateCandidateV1(options) {
|
|
|
52074
52498
|
}
|
|
52075
52499
|
var evaluationV1 = Object.freeze(Object.assign((options) => evaluateCandidateV1(options), {
|
|
52076
52500
|
evaluateCandidate: evaluateCandidateV1,
|
|
52501
|
+
evaluatePrReviewRecovery: evaluatePrReviewRecoveryV1,
|
|
52077
52502
|
runEvaluation,
|
|
52078
52503
|
decidePromotion: (input) => decidePromotion(input),
|
|
52079
52504
|
hashTaskInput: computeTaskInputContentHash,
|
|
@@ -52153,8 +52578,8 @@ ${section}`;
|
|
|
52153
52578
|
}
|
|
52154
52579
|
};
|
|
52155
52580
|
}
|
|
52156
|
-
function enforceTrustRegion(
|
|
52157
|
-
const v =
|
|
52581
|
+
function enforceTrustRegion(candidate2, budget) {
|
|
52582
|
+
const v = candidate2.diffSummary;
|
|
52158
52583
|
const breaches = [];
|
|
52159
52584
|
if (v.changedLines > budget.maxChangedLines) {
|
|
52160
52585
|
breaches.push(`changedLines ${v.changedLines} > ${budget.maxChangedLines}`);
|
|
@@ -52183,9 +52608,9 @@ function countChangedLines(a, b) {
|
|
|
52183
52608
|
return changed;
|
|
52184
52609
|
}
|
|
52185
52610
|
function draftCandidate(inputs) {
|
|
52186
|
-
const
|
|
52187
|
-
enforceTrustRegion(
|
|
52188
|
-
return
|
|
52611
|
+
const candidate2 = _internals78.draftDeterministic(inputs);
|
|
52612
|
+
enforceTrustRegion(candidate2, inputs.budget);
|
|
52613
|
+
return candidate2;
|
|
52189
52614
|
}
|
|
52190
52615
|
|
|
52191
52616
|
// src/services/skill-optimizer/deterministic-seed.ts
|
|
@@ -52221,7 +52646,7 @@ async function deterministicSeed(input) {
|
|
|
52221
52646
|
|
|
52222
52647
|
// src/services/skill-optimizer/smoke.ts
|
|
52223
52648
|
import { existsSync as existsSync54, lstatSync as lstatSync10, readFileSync as readFileSync41, realpathSync as realpathSync9 } from "fs";
|
|
52224
|
-
import * as
|
|
52649
|
+
import * as path97 from "path";
|
|
52225
52650
|
|
|
52226
52651
|
// src/hooks/spawn-helper.ts
|
|
52227
52652
|
import * as child_process9 from "child_process";
|
|
@@ -52230,7 +52655,7 @@ var _internals79 = {
|
|
|
52230
52655
|
spawn: child_process9.spawn
|
|
52231
52656
|
};
|
|
52232
52657
|
function spawnAsync(command, cwd, timeoutMs) {
|
|
52233
|
-
return new Promise((
|
|
52658
|
+
return new Promise((resolve33) => {
|
|
52234
52659
|
try {
|
|
52235
52660
|
const [rawCmd, ...args] = command;
|
|
52236
52661
|
const cmd = process.platform === "win32" && WIN32_CMD_BINARIES.has(rawCmd) && !rawCmd.includes(".") ? `${rawCmd}.cmd` : rawCmd;
|
|
@@ -52277,24 +52702,24 @@ function spawnAsync(command, cwd, timeoutMs) {
|
|
|
52277
52702
|
try {
|
|
52278
52703
|
proc.kill();
|
|
52279
52704
|
} catch {}
|
|
52280
|
-
|
|
52705
|
+
resolve33(null);
|
|
52281
52706
|
}, timeoutMs);
|
|
52282
52707
|
proc.on("close", (code) => {
|
|
52283
52708
|
if (done)
|
|
52284
52709
|
return;
|
|
52285
52710
|
done = true;
|
|
52286
52711
|
clearTimeout(timer);
|
|
52287
|
-
|
|
52712
|
+
resolve33({ exitCode: code ?? 1, stdout, stderr });
|
|
52288
52713
|
});
|
|
52289
52714
|
proc.on("error", () => {
|
|
52290
52715
|
if (done)
|
|
52291
52716
|
return;
|
|
52292
52717
|
done = true;
|
|
52293
52718
|
clearTimeout(timer);
|
|
52294
|
-
|
|
52719
|
+
resolve33(null);
|
|
52295
52720
|
});
|
|
52296
52721
|
} catch {
|
|
52297
|
-
|
|
52722
|
+
resolve33(null);
|
|
52298
52723
|
}
|
|
52299
52724
|
});
|
|
52300
52725
|
}
|
|
@@ -52310,8 +52735,8 @@ var _internals80 = {
|
|
|
52310
52735
|
}
|
|
52311
52736
|
},
|
|
52312
52737
|
escapedRoot: (root, target) => {
|
|
52313
|
-
const rel =
|
|
52314
|
-
return rel.startsWith("..") ||
|
|
52738
|
+
const rel = path97.relative(path97.resolve(root), path97.resolve(target));
|
|
52739
|
+
return rel.startsWith("..") || path97.isAbsolute(rel);
|
|
52315
52740
|
},
|
|
52316
52741
|
realpath: (p) => realpathSync9(p),
|
|
52317
52742
|
evaluateSkillChange,
|
|
@@ -52320,7 +52745,7 @@ var _internals80 = {
|
|
|
52320
52745
|
};
|
|
52321
52746
|
async function validateSkillSmoke(input) {
|
|
52322
52747
|
const notes = [];
|
|
52323
|
-
const repoRel =
|
|
52748
|
+
const repoRel = path97.join(".opencode", "skills", "generated", input.skillSlug, "SKILL.md");
|
|
52324
52749
|
if (!_internals80.validateSkillPath(repoRel)) {
|
|
52325
52750
|
return {
|
|
52326
52751
|
ok: false,
|
|
@@ -52328,7 +52753,7 @@ async function validateSkillSmoke(input) {
|
|
|
52328
52753
|
notes: [`skill path not in an allowlisted root: ${repoRel}`]
|
|
52329
52754
|
};
|
|
52330
52755
|
}
|
|
52331
|
-
const skillRoot =
|
|
52756
|
+
const skillRoot = path97.join(input.directory, ".opencode", "skills", "generated", input.skillSlug);
|
|
52332
52757
|
if (existsSync54(skillRoot)) {
|
|
52333
52758
|
if (_internals80.isSymbolicLink(skillRoot)) {
|
|
52334
52759
|
return {
|
|
@@ -52414,7 +52839,7 @@ function checkFrontmatter(content) {
|
|
|
52414
52839
|
return null;
|
|
52415
52840
|
}
|
|
52416
52841
|
function readIncumbentContent(directory, skillSlug) {
|
|
52417
|
-
const incumbent =
|
|
52842
|
+
const incumbent = path97.join(directory, ".opencode", "skills", "generated", skillSlug, "SKILL.md");
|
|
52418
52843
|
if (!existsSync54(incumbent))
|
|
52419
52844
|
return "";
|
|
52420
52845
|
try {
|
|
@@ -52425,16 +52850,16 @@ function readIncumbentContent(directory, skillSlug) {
|
|
|
52425
52850
|
}
|
|
52426
52851
|
|
|
52427
52852
|
// src/services/skill-optimizer/controller.ts
|
|
52428
|
-
var PROJECT_LOCK_PATH =
|
|
52429
|
-
var CONVERGENCE_FILE =
|
|
52853
|
+
var PROJECT_LOCK_PATH = path98.join(".swarm", "evolution", "skills", ".run.lock");
|
|
52854
|
+
var CONVERGENCE_FILE = path98.join(".swarm", "evolution", "skills", ".convergence.json");
|
|
52430
52855
|
async function prepareCandidatePayloads(inputRoot, candidateId2, skillSlug, baselineModel, candidateModel, baselineContent, candidateContent) {
|
|
52431
|
-
const payloadSubdir =
|
|
52856
|
+
const payloadSubdir = path98.join(inputRoot, "candidates", candidateId2);
|
|
52432
52857
|
if (!existsSync55(payloadSubdir))
|
|
52433
52858
|
mkdirSync29(payloadSubdir, { recursive: true });
|
|
52434
|
-
const baselinePayloadRel =
|
|
52435
|
-
const candidatePayloadRel =
|
|
52436
|
-
writeFileSync19(
|
|
52437
|
-
writeFileSync19(
|
|
52859
|
+
const baselinePayloadRel = path98.join("candidates", candidateId2, "baseline.md");
|
|
52860
|
+
const candidatePayloadRel = path98.join("candidates", candidateId2, "candidate.md");
|
|
52861
|
+
writeFileSync19(path98.join(payloadSubdir, "baseline.md"), baselineContent, "utf8");
|
|
52862
|
+
writeFileSync19(path98.join(payloadSubdir, "candidate.md"), candidateContent, "utf8");
|
|
52438
52863
|
const { computeCandidateInputContentHash: computeCandidateInputContentHash2 } = await import("./hashing-mjwn6j4y.js");
|
|
52439
52864
|
const baseline = {
|
|
52440
52865
|
v: 1,
|
|
@@ -52444,7 +52869,7 @@ async function prepareCandidatePayloads(inputRoot, candidateId2, skillSlug, base
|
|
|
52444
52869
|
model: baselineModel,
|
|
52445
52870
|
contentHash: ""
|
|
52446
52871
|
};
|
|
52447
|
-
const
|
|
52872
|
+
const candidate2 = {
|
|
52448
52873
|
v: 1,
|
|
52449
52874
|
id: `${skillSlug}-candidate-${randomUUID11().slice(0, 8)}`,
|
|
52450
52875
|
kind: "skill",
|
|
@@ -52453,8 +52878,8 @@ async function prepareCandidatePayloads(inputRoot, candidateId2, skillSlug, base
|
|
|
52453
52878
|
contentHash: ""
|
|
52454
52879
|
};
|
|
52455
52880
|
baseline.contentHash = await computeCandidateInputContentHash2(inputRoot, baseline);
|
|
52456
|
-
|
|
52457
|
-
return { baseline, candidate };
|
|
52881
|
+
candidate2.contentHash = await computeCandidateInputContentHash2(inputRoot, candidate2);
|
|
52882
|
+
return { baseline, candidate: candidate2 };
|
|
52458
52883
|
}
|
|
52459
52884
|
var _internals81 = {
|
|
52460
52885
|
tryAcquireLock,
|
|
@@ -52475,7 +52900,7 @@ async function acquireProjectLock(directory) {
|
|
|
52475
52900
|
};
|
|
52476
52901
|
}
|
|
52477
52902
|
async function acquireSkillLock(directory, skillSlug) {
|
|
52478
|
-
const lockPath =
|
|
52903
|
+
const lockPath = path98.join(".swarm", "evolution", "skills", skillSlug, ".skill.lock");
|
|
52479
52904
|
const result = await _internals81.tryAcquireLock(directory, lockPath, "skill-opt-controller", `skill-${skillSlug}`);
|
|
52480
52905
|
if (!result.acquired)
|
|
52481
52906
|
return null;
|
|
@@ -52540,7 +52965,7 @@ async function runRoundLocked(input, candidateId2) {
|
|
|
52540
52965
|
budget: input.config,
|
|
52541
52966
|
claimedTestTaskIds: input.claimedTestTaskIds ?? new Set
|
|
52542
52967
|
});
|
|
52543
|
-
const
|
|
52968
|
+
const candidate2 = draftCandidate(generatorInputs);
|
|
52544
52969
|
await recordTransition({
|
|
52545
52970
|
directory: input.directory,
|
|
52546
52971
|
skillSlug: input.skillSlug,
|
|
@@ -52549,16 +52974,16 @@ async function runRoundLocked(input, candidateId2) {
|
|
|
52549
52974
|
eventType: "draft",
|
|
52550
52975
|
actor: input.sessionId ?? "unknown",
|
|
52551
52976
|
origin: input.origin,
|
|
52552
|
-
reason:
|
|
52977
|
+
reason: candidate2.rationale,
|
|
52553
52978
|
contentHashBefore: baselineHash,
|
|
52554
|
-
contentHashAfter: computeContentHash2(
|
|
52979
|
+
contentHashAfter: computeContentHash2(candidate2.content),
|
|
52555
52980
|
payload: {
|
|
52556
|
-
metric:
|
|
52557
|
-
risks:
|
|
52558
|
-
diffSummary:
|
|
52981
|
+
metric: candidate2.metric,
|
|
52982
|
+
risks: candidate2.risks,
|
|
52983
|
+
diffSummary: candidate2.diffSummary
|
|
52559
52984
|
}
|
|
52560
52985
|
});
|
|
52561
|
-
if (
|
|
52986
|
+
if (candidate2.content === incumbent) {
|
|
52562
52987
|
await recordTransition({
|
|
52563
52988
|
directory: input.directory,
|
|
52564
52989
|
skillSlug: input.skillSlug,
|
|
@@ -52569,7 +52994,7 @@ async function runRoundLocked(input, candidateId2) {
|
|
|
52569
52994
|
origin: input.origin,
|
|
52570
52995
|
reason: "drafted candidate is identical to baseline (convergence)",
|
|
52571
52996
|
contentHashBefore: baselineHash,
|
|
52572
|
-
contentHashAfter: computeContentHash2(
|
|
52997
|
+
contentHashAfter: computeContentHash2(candidate2.content)
|
|
52573
52998
|
});
|
|
52574
52999
|
return {
|
|
52575
53000
|
candidateId: candidateId2,
|
|
@@ -52578,7 +53003,7 @@ async function runRoundLocked(input, candidateId2) {
|
|
|
52578
53003
|
stopReason: "equivalent-patch"
|
|
52579
53004
|
};
|
|
52580
53005
|
}
|
|
52581
|
-
writeArtifact(input.directory, input.skillSlug, candidateId2, "candidate.md",
|
|
53006
|
+
writeArtifact(input.directory, input.skillSlug, candidateId2, "candidate.md", candidate2.content);
|
|
52582
53007
|
if (input.dryRun) {
|
|
52583
53008
|
return {
|
|
52584
53009
|
candidateId: candidateId2,
|
|
@@ -52590,7 +53015,7 @@ async function runRoundLocked(input, candidateId2) {
|
|
|
52590
53015
|
const smoke = await validateSkillSmoke({
|
|
52591
53016
|
directory: input.directory,
|
|
52592
53017
|
skillSlug: input.skillSlug,
|
|
52593
|
-
candidateContent:
|
|
53018
|
+
candidateContent: candidate2.content,
|
|
52594
53019
|
incumbentContent: incumbent
|
|
52595
53020
|
});
|
|
52596
53021
|
if (!smoke.ok) {
|
|
@@ -52604,7 +53029,7 @@ async function runRoundLocked(input, candidateId2) {
|
|
|
52604
53029
|
origin: input.origin,
|
|
52605
53030
|
reason: smoke.notes.join("; "),
|
|
52606
53031
|
contentHashBefore: baselineHash,
|
|
52607
|
-
contentHashAfter: computeContentHash2(
|
|
53032
|
+
contentHashAfter: computeContentHash2(candidate2.content)
|
|
52608
53033
|
});
|
|
52609
53034
|
return {
|
|
52610
53035
|
candidateId: candidateId2,
|
|
@@ -52623,7 +53048,7 @@ async function runRoundLocked(input, candidateId2) {
|
|
|
52623
53048
|
origin: input.origin,
|
|
52624
53049
|
reason: smoke.notes.join("; "),
|
|
52625
53050
|
contentHashBefore: baselineHash,
|
|
52626
|
-
contentHashAfter: computeContentHash2(
|
|
53051
|
+
contentHashAfter: computeContentHash2(candidate2.content)
|
|
52627
53052
|
});
|
|
52628
53053
|
await recordTransition({
|
|
52629
53054
|
directory: input.directory,
|
|
@@ -52635,9 +53060,9 @@ async function runRoundLocked(input, candidateId2) {
|
|
|
52635
53060
|
origin: input.origin,
|
|
52636
53061
|
reason: "PR1 validation via evaluateCandidateV1 (split:test)",
|
|
52637
53062
|
contentHashBefore: baselineHash,
|
|
52638
|
-
contentHashAfter: computeContentHash2(
|
|
53063
|
+
contentHashAfter: computeContentHash2(candidate2.content)
|
|
52639
53064
|
});
|
|
52640
|
-
const decision = await runValidationWithTransientRetry(input,
|
|
53065
|
+
const decision = await runValidationWithTransientRetry(input, candidate2.content, incumbent, candidateId2);
|
|
52641
53066
|
const toState = decision.status === "accept" ? "accepted_pending_approval" : decision.status === "reject" ? "rejected" : "inconclusive";
|
|
52642
53067
|
await recordTransition({
|
|
52643
53068
|
directory: input.directory,
|
|
@@ -52649,7 +53074,7 @@ async function runRoundLocked(input, candidateId2) {
|
|
|
52649
53074
|
origin: input.origin,
|
|
52650
53075
|
reason: decision.reasons.join("; "),
|
|
52651
53076
|
contentHashBefore: baselineHash,
|
|
52652
|
-
contentHashAfter: computeContentHash2(
|
|
53077
|
+
contentHashAfter: computeContentHash2(candidate2.content),
|
|
52653
53078
|
evidenceRefs: decision.runId ? [decision.runId] : [],
|
|
52654
53079
|
payload: {
|
|
52655
53080
|
deadband: decision.deadband,
|
|
@@ -52673,18 +53098,18 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
|
|
|
52673
53098
|
while (true) {
|
|
52674
53099
|
try {
|
|
52675
53100
|
const evalInputRoot = input.inputRoot ?? input.directory;
|
|
52676
|
-
const { baseline, candidate } = await _internals81.prepareCandidatePayloads(evalInputRoot, candidateId2, input.skillSlug, input.baselineModel, input.candidateModel, baselineContent, candidateContent);
|
|
53101
|
+
const { baseline, candidate: candidate2 } = await _internals81.prepareCandidatePayloads(evalInputRoot, candidateId2, input.skillSlug, input.baselineModel, input.candidateModel, baselineContent, candidateContent);
|
|
52677
53102
|
if (!input.dispatcher) {
|
|
52678
53103
|
throw new Error("no evaluation dispatcher available (cannot run validation)");
|
|
52679
53104
|
}
|
|
52680
|
-
const { createModelEvaluationExecutor } = await import("./runner-
|
|
52681
|
-
const executor =
|
|
53105
|
+
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-9rqc8y3m.js");
|
|
53106
|
+
const executor = createModelEvaluationExecutor2(input.dispatcher, input.sessionId);
|
|
52682
53107
|
const result = await _internals81.evaluateCandidateV1({
|
|
52683
53108
|
projectRoot: input.directory,
|
|
52684
53109
|
inputRoot: input.inputRoot ?? input.directory,
|
|
52685
53110
|
tasks: input.validationTasks,
|
|
52686
53111
|
baseline,
|
|
52687
|
-
candidate,
|
|
53112
|
+
candidate: candidate2,
|
|
52688
53113
|
split: "test",
|
|
52689
53114
|
seed: randomUUID11(),
|
|
52690
53115
|
models: input.models,
|
|
@@ -52752,7 +53177,7 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
|
|
|
52752
53177
|
}
|
|
52753
53178
|
}
|
|
52754
53179
|
function readConvergenceState(directory) {
|
|
52755
|
-
const file =
|
|
53180
|
+
const file = path98.join(directory, CONVERGENCE_FILE);
|
|
52756
53181
|
if (!existsSync55(file))
|
|
52757
53182
|
return { nonImprovements: 0 };
|
|
52758
53183
|
try {
|
|
@@ -52762,10 +53187,10 @@ function readConvergenceState(directory) {
|
|
|
52762
53187
|
}
|
|
52763
53188
|
}
|
|
52764
53189
|
function writeConvergenceState(directory, nonImprovements) {
|
|
52765
|
-
const dir =
|
|
53190
|
+
const dir = path98.dirname(path98.join(directory, CONVERGENCE_FILE));
|
|
52766
53191
|
if (!existsSync55(dir))
|
|
52767
53192
|
mkdirSync29(dir, { recursive: true });
|
|
52768
|
-
writeFileSync19(
|
|
53193
|
+
writeFileSync19(path98.join(directory, CONVERGENCE_FILE), JSON.stringify({ nonImprovements }), "utf8");
|
|
52769
53194
|
}
|
|
52770
53195
|
async function runOptimizationLoop(input) {
|
|
52771
53196
|
const rounds = [];
|
|
@@ -52821,7 +53246,7 @@ async function runOptimizationLoop(input) {
|
|
|
52821
53246
|
|
|
52822
53247
|
// src/services/skill-optimizer/skill-eval-tasks.ts
|
|
52823
53248
|
import { existsSync as existsSync56, mkdirSync as mkdirSync30, writeFileSync as writeFileSync20 } from "fs";
|
|
52824
|
-
import * as
|
|
53249
|
+
import * as path99 from "path";
|
|
52825
53250
|
var DEFAULT_SKILL_EVAL_TASKS = [
|
|
52826
53251
|
{
|
|
52827
53252
|
id: "skill-eval-trigger-clarity",
|
|
@@ -52861,20 +53286,20 @@ function buildSkillEvalTasks(args) {
|
|
|
52861
53286
|
const tasks = args.tasks ?? DEFAULT_SKILL_EVAL_TASKS;
|
|
52862
53287
|
const result = [];
|
|
52863
53288
|
for (const spec of tasks) {
|
|
52864
|
-
const taskDir =
|
|
53289
|
+
const taskDir = path99.join(args.inputRoot, "skill-eval", spec.id);
|
|
52865
53290
|
if (!existsSync56(taskDir))
|
|
52866
53291
|
mkdirSync30(taskDir, { recursive: true });
|
|
52867
|
-
const instructionPath =
|
|
52868
|
-
writeFileSync20(
|
|
53292
|
+
const instructionPath = path99.join("skill-eval", spec.id, "instruction.md");
|
|
53293
|
+
writeFileSync20(path99.join(args.inputRoot, instructionPath), `${spec.instruction}
|
|
52869
53294
|
`, "utf8");
|
|
52870
|
-
const envRelPath =
|
|
52871
|
-
writeFileSync20(
|
|
52872
|
-
const phraseSpecPath =
|
|
52873
|
-
writeFileSync20(
|
|
53295
|
+
const envRelPath = path99.join("skill-eval", spec.id, "environment.md");
|
|
53296
|
+
writeFileSync20(path99.join(args.inputRoot, envRelPath), spec.environmentBody, "utf8");
|
|
53297
|
+
const phraseSpecPath = path99.join("skill-eval", spec.id, "phrase-spec.json");
|
|
53298
|
+
writeFileSync20(path99.join(args.inputRoot, phraseSpecPath), JSON.stringify({
|
|
52874
53299
|
required_phrases: spec.requiredPhrases,
|
|
52875
53300
|
forbidden_phrases: spec.forbiddenPhrases
|
|
52876
53301
|
}), "utf8");
|
|
52877
|
-
const
|
|
53302
|
+
const task2 = {
|
|
52878
53303
|
v: 1,
|
|
52879
53304
|
id: spec.id,
|
|
52880
53305
|
source: "curated",
|
|
@@ -52906,8 +53331,8 @@ function buildSkillEvalTasks(args) {
|
|
|
52906
53331
|
},
|
|
52907
53332
|
contentHash: ""
|
|
52908
53333
|
};
|
|
52909
|
-
|
|
52910
|
-
result.push(
|
|
53334
|
+
task2.contentHash = computeTaskContentHash(task2);
|
|
53335
|
+
result.push(task2);
|
|
52911
53336
|
}
|
|
52912
53337
|
return result;
|
|
52913
53338
|
}
|
|
@@ -52960,7 +53385,7 @@ ${JSON.stringify(result, null, 2)}
|
|
|
52960
53385
|
}
|
|
52961
53386
|
function readSkillOptConfigFromProject(directory) {
|
|
52962
53387
|
try {
|
|
52963
|
-
const cfgPath =
|
|
53388
|
+
const cfgPath = path100.join(directory, "opencode.json");
|
|
52964
53389
|
if (!existsSync57(cfgPath))
|
|
52965
53390
|
return { ...DEFAULT_SKILL_OPT_CONFIG };
|
|
52966
53391
|
const raw = JSON.parse(readFileSync43(cfgPath, "utf8"));
|
|
@@ -53010,18 +53435,18 @@ async function handleSkillOptRun(directory, args, runtime = {}) {
|
|
|
53010
53435
|
}, parsed.json);
|
|
53011
53436
|
}
|
|
53012
53437
|
const models = parsed.models.length > 0 ? parsed.models : ["default"];
|
|
53013
|
-
const inputRoot =
|
|
53438
|
+
const inputRoot = path100.join(directory, ".swarm", "evolution", "skills", "_eval-input");
|
|
53014
53439
|
if (!existsSync57(inputRoot))
|
|
53015
53440
|
mkdirSync31(inputRoot, { recursive: true });
|
|
53016
|
-
const scorerDir =
|
|
53441
|
+
const scorerDir = path100.join(inputRoot, "scoring");
|
|
53017
53442
|
if (!existsSync57(scorerDir))
|
|
53018
53443
|
mkdirSync31(scorerDir, { recursive: true });
|
|
53019
|
-
const scorerSource =
|
|
53020
|
-
const scorerDest =
|
|
53444
|
+
const scorerSource = path100.join(directory, "evaluation-fixtures", "skill-eval", "scoring", "score-skill-eval.cjs");
|
|
53445
|
+
const scorerDest = path100.join(scorerDir, "score-skill-eval.cjs");
|
|
53021
53446
|
if (existsSync57(scorerSource)) {
|
|
53022
53447
|
copyFileSync5(scorerSource, scorerDest);
|
|
53023
53448
|
}
|
|
53024
|
-
const scorerRelPath =
|
|
53449
|
+
const scorerRelPath = path100.join("scoring", "score-skill-eval.cjs");
|
|
53025
53450
|
const validationTasks = buildSkillEvalTasks({ inputRoot, scorerRelPath });
|
|
53026
53451
|
const result = await runOptimizationLoop({
|
|
53027
53452
|
directory,
|
|
@@ -53064,11 +53489,11 @@ async function handleSkillOptDiff(directory, args) {
|
|
|
53064
53489
|
if (idError)
|
|
53065
53490
|
return idError;
|
|
53066
53491
|
const baseline = readArtifact(directory, parsed.skillSlug, parsed.candidateId, "baseline.md") ?? "";
|
|
53067
|
-
const
|
|
53492
|
+
const candidate2 = readArtifact(directory, parsed.skillSlug, parsed.candidateId, "candidate.md") ?? "";
|
|
53068
53493
|
const replay = replayCandidate(directory, parsed.skillSlug, parsed.candidateId);
|
|
53069
53494
|
const baselineLines = baseline.split(`
|
|
53070
53495
|
`);
|
|
53071
|
-
const candidateLines =
|
|
53496
|
+
const candidateLines = candidate2.split(`
|
|
53072
53497
|
`);
|
|
53073
53498
|
const max = Math.max(baselineLines.length, candidateLines.length);
|
|
53074
53499
|
let added = 0;
|
|
@@ -53091,11 +53516,11 @@ async function handleSkillOptDiff(directory, args) {
|
|
|
53091
53516
|
candidateId: parsed.candidateId,
|
|
53092
53517
|
lastState: replay.state,
|
|
53093
53518
|
baselineBytes: baseline.length,
|
|
53094
|
-
candidateBytes:
|
|
53519
|
+
candidateBytes: candidate2.length,
|
|
53095
53520
|
linesAdded: added,
|
|
53096
53521
|
linesRemoved: removed,
|
|
53097
53522
|
baselinePreview: baseline.slice(0, 400),
|
|
53098
|
-
candidatePreview:
|
|
53523
|
+
candidatePreview: candidate2.slice(0, 400),
|
|
53099
53524
|
truncated: replay.truncated
|
|
53100
53525
|
}, parsed.json);
|
|
53101
53526
|
}
|
|
@@ -53194,12 +53619,12 @@ async function handleSpecifyCommand(_directory, args) {
|
|
|
53194
53619
|
init_loader();
|
|
53195
53620
|
init_schema();
|
|
53196
53621
|
import * as fsSync3 from "fs";
|
|
53197
|
-
import { readFile as
|
|
53198
|
-
import * as
|
|
53622
|
+
import { readFile as readFile22 } from "fs/promises";
|
|
53623
|
+
import * as path103 from "path";
|
|
53199
53624
|
|
|
53200
53625
|
// src/consensus/store.ts
|
|
53201
53626
|
import { readdir as readdir5, unlink as unlink3 } from "fs/promises";
|
|
53202
|
-
import * as
|
|
53627
|
+
import * as path101 from "path";
|
|
53203
53628
|
|
|
53204
53629
|
// src/consensus/contracts.ts
|
|
53205
53630
|
init_zod();
|
|
@@ -53370,10 +53795,10 @@ var SENTENCE_TERMINATOR_CLASS = "\\p{Sentence_Terminal}\\u2025\\u2026\\u22EF\\uF
|
|
|
53370
53795
|
var SINGLE_SENTENCE_RE = new RegExp(`^[^${SENTENCE_TERMINATOR_CLASS}]*(?:[${SENTENCE_TERMINATOR_CLASS}]+["')]?)?$`, "u");
|
|
53371
53796
|
|
|
53372
53797
|
// src/consensus/store.ts
|
|
53373
|
-
var CONSENSUS_RELATIVE_DIR =
|
|
53798
|
+
var CONSENSUS_RELATIVE_DIR = path101.join("evolution", "consensus");
|
|
53374
53799
|
var REPORT_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,159}$/;
|
|
53375
53800
|
function swarmPath(directory, ...segments) {
|
|
53376
|
-
return
|
|
53801
|
+
return path101.join(directory, ".swarm", ...segments);
|
|
53377
53802
|
}
|
|
53378
53803
|
async function countConsensusReportFiles(directory) {
|
|
53379
53804
|
const root = swarmPath(directory, CONSENSUS_RELATIVE_DIR);
|
|
@@ -53389,16 +53814,16 @@ async function countConsensusReportFiles(directory) {
|
|
|
53389
53814
|
|
|
53390
53815
|
// src/turbo/lean/state.ts
|
|
53391
53816
|
init_logger();
|
|
53392
|
-
import * as
|
|
53393
|
-
import * as
|
|
53817
|
+
import * as fs49 from "fs";
|
|
53818
|
+
import * as path102 from "path";
|
|
53394
53819
|
var STATE_FILE3 = "turbo-state.json";
|
|
53395
53820
|
function nowISO3() {
|
|
53396
53821
|
return new Date().toISOString();
|
|
53397
53822
|
}
|
|
53398
53823
|
function ensureSwarmDir2(directory) {
|
|
53399
|
-
const swarmDir =
|
|
53400
|
-
if (!
|
|
53401
|
-
|
|
53824
|
+
const swarmDir = path102.resolve(directory, ".swarm");
|
|
53825
|
+
if (!fs49.existsSync(swarmDir)) {
|
|
53826
|
+
fs49.mkdirSync(swarmDir, { recursive: true });
|
|
53402
53827
|
}
|
|
53403
53828
|
return swarmDir;
|
|
53404
53829
|
}
|
|
@@ -53441,17 +53866,17 @@ function markStateUnreadable2(directory, reason) {
|
|
|
53441
53866
|
}
|
|
53442
53867
|
function readPersisted2(directory) {
|
|
53443
53868
|
try {
|
|
53444
|
-
const filePath =
|
|
53445
|
-
if (!
|
|
53869
|
+
const filePath = path102.join(directory, ".swarm", STATE_FILE3);
|
|
53870
|
+
if (!fs49.existsSync(filePath)) {
|
|
53446
53871
|
const seed = emptyPersisted2();
|
|
53447
53872
|
try {
|
|
53448
53873
|
ensureSwarmDir2(directory);
|
|
53449
|
-
|
|
53874
|
+
fs49.writeFileSync(filePath, `${JSON.stringify(seed, null, 2)}
|
|
53450
53875
|
`, "utf-8");
|
|
53451
53876
|
} catch {}
|
|
53452
53877
|
return seed;
|
|
53453
53878
|
}
|
|
53454
|
-
const raw =
|
|
53879
|
+
const raw = fs49.readFileSync(filePath, "utf-8");
|
|
53455
53880
|
const parsed = JSON.parse(raw);
|
|
53456
53881
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || parsed.version !== 1 || !parsed.sessions || typeof parsed.sessions !== "object" || Array.isArray(parsed.sessions)) {
|
|
53457
53882
|
markStateUnreadable2(directory, `malformed shape (version=${parsed?.version}, sessions type=${Array.isArray(parsed?.sessions) ? "array" : typeof parsed?.sessions})`);
|
|
@@ -53477,7 +53902,7 @@ function writePersisted2(directory, persisted) {
|
|
|
53477
53902
|
let payload;
|
|
53478
53903
|
try {
|
|
53479
53904
|
ensureSwarmDir2(directory);
|
|
53480
|
-
filePath =
|
|
53905
|
+
filePath = path102.join(directory, ".swarm", STATE_FILE3);
|
|
53481
53906
|
tmpPath = `${filePath}.tmp.${Date.now()}`;
|
|
53482
53907
|
persisted.updatedAt = nowISO3();
|
|
53483
53908
|
payload = `${JSON.stringify(persisted, null, 2)}
|
|
@@ -53488,14 +53913,14 @@ function writePersisted2(directory, persisted) {
|
|
|
53488
53913
|
throw new Error(`Lean Turbo state persistence prepare failed: ${msg}`);
|
|
53489
53914
|
}
|
|
53490
53915
|
try {
|
|
53491
|
-
|
|
53492
|
-
|
|
53916
|
+
fs49.writeFileSync(tmpPath, payload, "utf-8");
|
|
53917
|
+
fs49.renameSync(tmpPath, filePath);
|
|
53493
53918
|
} catch (error2) {
|
|
53494
53919
|
const msg = error2 instanceof Error ? error2.message : String(error2);
|
|
53495
53920
|
error(`[turbo/lean/state] Failed to persist ${STATE_FILE3} atomically: ${msg}`);
|
|
53496
53921
|
try {
|
|
53497
|
-
if (
|
|
53498
|
-
|
|
53922
|
+
if (fs49.existsSync(tmpPath)) {
|
|
53923
|
+
fs49.unlinkSync(tmpPath);
|
|
53499
53924
|
}
|
|
53500
53925
|
} catch {}
|
|
53501
53926
|
throw new Error(`Lean Turbo state persistence failed: ${msg}`);
|
|
@@ -53598,7 +54023,7 @@ var _internals82 = {
|
|
|
53598
54023
|
};
|
|
53599
54024
|
function readSpecStalenessSnapshot(directory) {
|
|
53600
54025
|
try {
|
|
53601
|
-
const p =
|
|
54026
|
+
const p = path103.join(directory, ".swarm", "spec-staleness.json");
|
|
53602
54027
|
if (!fsSync3.existsSync(p))
|
|
53603
54028
|
return { stale: false };
|
|
53604
54029
|
const raw = fsSync3.readFileSync(p, "utf-8");
|
|
@@ -53634,9 +54059,9 @@ async function getStatusData(directory, agents, sessionId) {
|
|
|
53634
54059
|
let completedTasks = 0;
|
|
53635
54060
|
let totalTasks = 0;
|
|
53636
54061
|
for (const phase of plan.phases) {
|
|
53637
|
-
for (const
|
|
54062
|
+
for (const task2 of phase.tasks) {
|
|
53638
54063
|
totalTasks++;
|
|
53639
|
-
if (
|
|
54064
|
+
if (task2.status === "completed")
|
|
53640
54065
|
completedTasks++;
|
|
53641
54066
|
}
|
|
53642
54067
|
}
|
|
@@ -53736,7 +54161,7 @@ async function getStatusData(directory, agents, sessionId) {
|
|
|
53736
54161
|
const memoryConfig = MemoryConfigSchema.parse(loadPluginConfig(directory).memory ?? {});
|
|
53737
54162
|
provider = memoryConfig.provider;
|
|
53738
54163
|
if (memoryPointer) {
|
|
53739
|
-
const cohortConfigPath =
|
|
54164
|
+
const cohortConfigPath = path103.join(resolveLinkDir(memoryPointer.linkId), "memory", "memory-cohort-config.json");
|
|
53740
54165
|
if (fsSync3.existsSync(cohortConfigPath)) {
|
|
53741
54166
|
const stored = JSON.parse(fsSync3.readFileSync(cohortConfigPath, "utf-8"));
|
|
53742
54167
|
const versionCheck = classifyStoredFingerprintAlgorithmVersion(stored.algorithm_version);
|
|
@@ -54030,7 +54455,7 @@ async function safeLineCount(filePath) {
|
|
|
54030
54455
|
try {
|
|
54031
54456
|
if (!fsSync3.existsSync(filePath))
|
|
54032
54457
|
return 0;
|
|
54033
|
-
const content = await
|
|
54458
|
+
const content = await readFile22(filePath, "utf-8");
|
|
54034
54459
|
let n = 0;
|
|
54035
54460
|
for (const line of content.split(`
|
|
54036
54461
|
`)) {
|
|
@@ -54314,7 +54739,7 @@ function buildStatusMessage2(session, directory, sessionID) {
|
|
|
54314
54739
|
}
|
|
54315
54740
|
|
|
54316
54741
|
// src/commands/unlink.ts
|
|
54317
|
-
import * as
|
|
54742
|
+
import * as path104 from "path";
|
|
54318
54743
|
async function handleUnlinkCommand(directory, args) {
|
|
54319
54744
|
const pointer = readLinkPointer(directory);
|
|
54320
54745
|
if (!pointer) {
|
|
@@ -54327,7 +54752,7 @@ async function handleUnlinkCommand(directory, args) {
|
|
|
54327
54752
|
let familySummary = "";
|
|
54328
54753
|
if (copyBack) {
|
|
54329
54754
|
try {
|
|
54330
|
-
const result = await migrateKnowledgeFamily(
|
|
54755
|
+
const result = await migrateKnowledgeFamily(path104.join(directory, ".swarm"), linkDir);
|
|
54331
54756
|
for (const m of result.perMember) {
|
|
54332
54757
|
totalMerged += m.merged;
|
|
54333
54758
|
totalSkipped += m.skipped;
|
|
@@ -54505,7 +54930,7 @@ function buildDetailedHelp(commandName, entry) {
|
|
|
54505
54930
|
async function handleHelpCommand(ctx) {
|
|
54506
54931
|
const targetCommand = ctx.args.join(" ");
|
|
54507
54932
|
if (!targetCommand) {
|
|
54508
|
-
const { buildHelpText } = await import("./index-
|
|
54933
|
+
const { buildHelpText } = await import("./index-p0kez6cn.js");
|
|
54509
54934
|
return buildHelpText();
|
|
54510
54935
|
}
|
|
54511
54936
|
const tokens = targetCommand.split(/\s+/);
|
|
@@ -54514,7 +54939,7 @@ async function handleHelpCommand(ctx) {
|
|
|
54514
54939
|
return _internals14.buildDetailedHelp(resolved.key, resolved.entry);
|
|
54515
54940
|
}
|
|
54516
54941
|
const similar = _internals14.findSimilarCommands(targetCommand);
|
|
54517
|
-
const { buildHelpText: fullHelp } = await import("./index-
|
|
54942
|
+
const { buildHelpText: fullHelp } = await import("./index-p0kez6cn.js");
|
|
54518
54943
|
if (similar.length > 0) {
|
|
54519
54944
|
return `Command '/swarm ${targetCommand}' not found.
|
|
54520
54945
|
|
|
@@ -54691,7 +55116,7 @@ var COMMAND_REGISTRY = {
|
|
|
54691
55116
|
},
|
|
54692
55117
|
"guardrail explain": {
|
|
54693
55118
|
handler: async (ctx) => {
|
|
54694
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
55119
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-sq1kcah3.js");
|
|
54695
55120
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
54696
55121
|
},
|
|
54697
55122
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -54701,7 +55126,7 @@ var COMMAND_REGISTRY = {
|
|
|
54701
55126
|
},
|
|
54702
55127
|
"guardrail-explain": {
|
|
54703
55128
|
handler: async (ctx) => {
|
|
54704
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
55129
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-sq1kcah3.js");
|
|
54705
55130
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
54706
55131
|
},
|
|
54707
55132
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -54711,7 +55136,7 @@ var COMMAND_REGISTRY = {
|
|
|
54711
55136
|
},
|
|
54712
55137
|
"guardrail-log": {
|
|
54713
55138
|
handler: async (ctx) => {
|
|
54714
|
-
const { handleGuardrailLog } = await import("./guardrail-log-
|
|
55139
|
+
const { handleGuardrailLog } = await import("./guardrail-log-7anp1z1n.js");
|
|
54715
55140
|
return handleGuardrailLog(ctx.directory, ctx.args);
|
|
54716
55141
|
},
|
|
54717
55142
|
description: "Read the guardrail decision log (use --blocks-only for blocks)",
|
|
@@ -55656,24 +56081,24 @@ function validateAliases() {
|
|
|
55656
56081
|
continue;
|
|
55657
56082
|
}
|
|
55658
56083
|
const visited = new Set;
|
|
55659
|
-
const
|
|
56084
|
+
const path105 = [];
|
|
55660
56085
|
let current = target;
|
|
55661
56086
|
while (current) {
|
|
55662
56087
|
const currentEntry = COMMAND_REGISTRY[current];
|
|
55663
56088
|
if (!currentEntry)
|
|
55664
56089
|
break;
|
|
55665
56090
|
if (visited.has(current)) {
|
|
55666
|
-
const cycleStart =
|
|
56091
|
+
const cycleStart = path105.indexOf(current);
|
|
55667
56092
|
const fullChain = [
|
|
55668
56093
|
name,
|
|
55669
|
-
...
|
|
56094
|
+
...path105.slice(0, cycleStart > 0 ? cycleStart : path105.length),
|
|
55670
56095
|
current
|
|
55671
56096
|
].join(" \u2192 ");
|
|
55672
56097
|
errors.push(`Circular alias detected: ${fullChain}`);
|
|
55673
56098
|
break;
|
|
55674
56099
|
}
|
|
55675
56100
|
visited.add(current);
|
|
55676
|
-
|
|
56101
|
+
path105.push(current);
|
|
55677
56102
|
current = currentEntry.aliasOf || "";
|
|
55678
56103
|
}
|
|
55679
56104
|
}
|