opencode-swarm 7.148.1 → 7.148.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 +6 -4
- package/.opencode/skills/swarm-pr-review/references/findings-persistence-contract.md +33 -1
- package/.opencode/skills/swarm-pr-review/references/lane-output-recoverability.md +2 -2
- package/.opencode/skills/swarm-pr-review/references/parser-dry-run.md +1 -2
- package/.opencode/skills/swarm-pr-review/references/prompt-templates.md +11 -3
- package/dist/background/pending-delegations.d.ts +1 -1
- package/dist/background/pr-review-contract.d.ts +148 -0
- package/dist/background/pr-review-trigger-contract.d.ts +1 -0
- package/dist/cli/{config-doctor-w6zphy4w.js → config-doctor-6danhdcy.js} +2 -2
- package/dist/cli/{core-65qyqw2f.js → core-0ghwny8q.js} +1 -1
- package/dist/cli/{curation-policy-166wdjs4.js → curation-policy-hkdghd3a.js} +4 -4
- package/dist/cli/{curator-llm-factory-y43mx297.js → curator-llm-factory-6n47j5qn.js} +24 -24
- package/dist/cli/{curator-2jhdfjqg.js → curator-wvm7qbkk.js} +24 -24
- package/dist/cli/{evidence-summary-service-7qpganmn.js → evidence-summary-service-0xwrkmf9.js} +9 -9
- package/dist/cli/{gate-evidence-p79xv25a.js → gate-evidence-6e5yhcy6.js} +4 -4
- package/dist/cli/{guardrail-explain-76sy950j.js → guardrail-explain-tgv7rvap.js} +25 -25
- package/dist/cli/{guardrail-log-pm0w6ney.js → guardrail-log-k0zk6rbs.js} +3 -3
- package/dist/cli/{guardrail-reset-tkkg0bfz.js → guardrail-reset-4fw16xmb.js} +24 -24
- package/dist/cli/{hive-promoter-w4batwr6.js → hive-promoter-zemwxxw1.js} +24 -24
- package/dist/cli/{index-s3s2egzn.js → index-03wz9h63.js} +26 -26
- package/dist/cli/{index-ch6sjm8q.js → index-092deqxs.js} +1 -0
- package/dist/cli/{index-shazb5b6.js → index-2zz8b0rb.js} +1 -1
- package/dist/cli/{index-m97qwwrk.js → index-3pbvdde0.js} +2 -2
- package/dist/cli/{index-t6ys1386.js → index-5vyej8pc.js} +4 -4
- package/dist/cli/{index-5wypz451.js → index-7jaq84cg.js} +1 -1
- package/dist/cli/{index-c23yxr1s.js → index-84ytts36.js} +3 -3
- package/dist/cli/{index-q0gfmyzx.js → index-crpkb5x6.js} +5 -5
- package/dist/cli/{index-kpgj4ha6.js → index-ebt47fnp.js} +1 -1
- package/dist/cli/{index-kztxn1ww.js → index-hsq8nyen.js} +561 -177
- package/dist/cli/{index-e9d2829t.js → index-k2ad2vtb.js} +1 -1
- package/dist/cli/{index-qzstn430.js → index-m5z2fgs4.js} +1 -1
- package/dist/cli/{index-dwg0z10h.js → index-mbcyz77e.js} +4 -4
- package/dist/cli/{index-qwzpsh3w.js → index-mgcffsk0.js} +1 -1
- package/dist/cli/{index-mfhpk4c6.js → index-ndqhtgrc.js} +1 -1
- package/dist/cli/{index-k5ze5v89.js → index-nqwn8sf0.js} +1 -1
- package/dist/cli/{index-81n4ky69.js → index-nxydm56k.js} +2 -2
- package/dist/cli/{index-hxqjf4me.js → index-pzt7ed53.js} +4 -4
- package/dist/cli/{index-py2rsw1a.js → index-q6kscnts.js} +2 -2
- package/dist/cli/{index-jtnk7k6w.js → index-r9g7ymv2.js} +1 -1
- package/dist/cli/{index-2bsnwcmp.js → index-s0nss8c4.js} +1 -1
- package/dist/cli/{index-w49v4xd6.js → index-s0s1e5jp.js} +5 -5
- package/dist/cli/{index-x46mmaep.js → index-wgrvq2bc.js} +6 -6
- package/dist/cli/{index-fv5cc1rd.js → index-x4kgn37c.js} +1 -1
- package/dist/cli/{index-f115c8y6.js → index-x9jppg8b.js} +1 -1
- package/dist/cli/{index-shm69en5.js → index-x9q0b3a8.js} +2 -2
- package/dist/cli/{index-627mz27c.js → index-xn7h24x4.js} +3 -3
- package/dist/cli/{index-3yh2e5ca.js → index-zpn3wqvp.js} +6 -5
- package/dist/cli/index.js +24 -24
- package/dist/cli/{knowledge-escalator-21n4ztqx.js → knowledge-escalator-rfw35yt1.js} +9 -9
- package/dist/cli/{knowledge-events-h5d5eayv.js → knowledge-events-wmjm5wn6.js} +7 -7
- package/dist/cli/{knowledge-link-vgxe7gz9.js → knowledge-link-5dctq0ax.js} +3 -3
- package/dist/cli/{knowledge-store-y10m7x4f.js → knowledge-store-f2ev6s5p.js} +4 -4
- package/dist/cli/{knowledge-validator-dzm9sg0f.js → knowledge-validator-6cmwpx9e.js} +6 -6
- package/dist/cli/{pending-delegations-78zaaxz4.js → pending-delegations-h4gr264y.js} +1 -1
- package/dist/cli/{runner-rarzeth8.js → runner-9g2pcg10.js} +4 -4
- package/dist/cli/{scan-cursor-zn2qf06a.js → scan-cursor-x1ma7edk.js} +5 -5
- package/dist/cli/{schema-ynwy7abm.js → schema-g5ggmb47.js} +1 -1
- package/dist/cli/{scope-persistence-sh30937s.js → scope-persistence-gt0zpp6a.js} +5 -5
- package/dist/cli/{skill-generator-r3knfwrp.js → skill-generator-q6m110d5.js} +11 -11
- package/dist/cli/{worktree-collision-ownership-29md3k1n.js → worktree-collision-ownership-e0p490vw.js} +1 -1
- package/dist/cli/{worktree-isolation-yj7ssh24.js → worktree-isolation-akwwt8n5.js} +24 -24
- package/dist/hooks/pr-workflow-gate.d.ts +26 -1
- package/dist/index.js +83 -76
- package/dist/tools/write-pr-review-artifact.d.ts +7 -0
- package/dist/tools/write-pr-review-trigger-eval.d.ts +3 -1
- package/package.json +1 -1
|
@@ -6,17 +6,17 @@ import {
|
|
|
6
6
|
resolveExecutableFromPath,
|
|
7
7
|
runEvaluation,
|
|
8
8
|
runExternalTool
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-ebt47fnp.js";
|
|
10
10
|
import {
|
|
11
11
|
normalizeToolNameLowerCase,
|
|
12
12
|
stableCanonicalStringify
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-s0nss8c4.js";
|
|
14
14
|
import {
|
|
15
15
|
detectStraySwarmDirs,
|
|
16
16
|
readDoctorArtifact,
|
|
17
17
|
removeStraySwarmDir,
|
|
18
18
|
runConfigDoctor
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-7jaq84cg.js";
|
|
20
20
|
import {
|
|
21
21
|
MAX_TRANSIENT_RETRIES,
|
|
22
22
|
archiveEvidence,
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
updateTaskStatus,
|
|
63
63
|
validateProjectRoot,
|
|
64
64
|
validateSymlinkBoundary
|
|
65
|
-
} from "./index-
|
|
65
|
+
} from "./index-5vyej8pc.js";
|
|
66
66
|
import {
|
|
67
67
|
EvaluationTaskV1Schema,
|
|
68
68
|
GateAuditManifestV1Schema,
|
|
@@ -79,7 +79,7 @@ import {
|
|
|
79
79
|
saveGateAuditResult,
|
|
80
80
|
savePromotionDecision,
|
|
81
81
|
saveTaskSetSnapshot
|
|
82
|
-
} from "./index-
|
|
82
|
+
} from "./index-x4kgn37c.js";
|
|
83
83
|
import {
|
|
84
84
|
loadDatabaseCtor
|
|
85
85
|
} from "./index-134d35c1.js";
|
|
@@ -105,12 +105,12 @@ import {
|
|
|
105
105
|
} from "./index-y8552snf.js";
|
|
106
106
|
import {
|
|
107
107
|
readRecentEscalations
|
|
108
|
-
} from "./index-
|
|
108
|
+
} from "./index-crpkb5x6.js";
|
|
109
109
|
import {
|
|
110
110
|
alreadyCuratedThisGeneration,
|
|
111
111
|
claimNextScanBatch,
|
|
112
112
|
resolveCohortId
|
|
113
|
-
} from "./index-
|
|
113
|
+
} from "./index-nxydm56k.js";
|
|
114
114
|
import {
|
|
115
115
|
CURATOR_INIT_PROMPT,
|
|
116
116
|
CURATOR_PHASE_PROMPT,
|
|
@@ -180,7 +180,7 @@ import {
|
|
|
180
180
|
retireSkill,
|
|
181
181
|
selectCandidateEntries,
|
|
182
182
|
syncBundledProjectSkillsIfMissingAsync
|
|
183
|
-
} from "./index-
|
|
183
|
+
} from "./index-pzt7ed53.js";
|
|
184
184
|
import {
|
|
185
185
|
appendUnactionable,
|
|
186
186
|
quarantineEntry,
|
|
@@ -191,11 +191,11 @@ import {
|
|
|
191
191
|
validateActionableFields,
|
|
192
192
|
validateLesson,
|
|
193
193
|
validateSkillPath
|
|
194
|
-
} from "./index-
|
|
194
|
+
} from "./index-mbcyz77e.js";
|
|
195
195
|
import {
|
|
196
196
|
authorizeCuration,
|
|
197
197
|
buildConfigFingerprintInput
|
|
198
|
-
} from "./index-
|
|
198
|
+
} from "./index-r9g7ymv2.js";
|
|
199
199
|
import {
|
|
200
200
|
cohortConfigFingerprint
|
|
201
201
|
} from "./index-rtry5xyf.js";
|
|
@@ -215,7 +215,7 @@ import {
|
|
|
215
215
|
findByBatchId,
|
|
216
216
|
readDelegations,
|
|
217
217
|
sweepStaleDelegations
|
|
218
|
-
} from "./index-
|
|
218
|
+
} from "./index-092deqxs.js";
|
|
219
219
|
import {
|
|
220
220
|
WORKTREE_LIFECYCLE_LOCK_FILE,
|
|
221
221
|
recordWorktreeProvisioningOwner,
|
|
@@ -248,18 +248,18 @@ import {
|
|
|
248
248
|
transitionTaskWorkflowEvidence,
|
|
249
249
|
withTaskEvidenceTransaction,
|
|
250
250
|
writeWorkflowWalFile
|
|
251
|
-
} from "./index-
|
|
251
|
+
} from "./index-q6kscnts.js";
|
|
252
252
|
import {
|
|
253
253
|
provisionWorktree,
|
|
254
254
|
removeWorktree
|
|
255
|
-
} from "./index-
|
|
255
|
+
} from "./index-ndqhtgrc.js";
|
|
256
256
|
import {
|
|
257
257
|
MAX_PENDING_SCOPE_BINDINGS,
|
|
258
258
|
canonicalWorkspaceIdentity,
|
|
259
259
|
clearAllScopes,
|
|
260
260
|
clearScopeBindingFromDisk,
|
|
261
261
|
clearScopeBindings
|
|
262
|
-
} from "./index-
|
|
262
|
+
} from "./index-84ytts36.js";
|
|
263
263
|
import {
|
|
264
264
|
appendLedgerEvent,
|
|
265
265
|
computePlanHash,
|
|
@@ -274,7 +274,7 @@ import {
|
|
|
274
274
|
readPlanEpochIdentity,
|
|
275
275
|
replayFromLedgerWithStatus,
|
|
276
276
|
takeSnapshotEvent
|
|
277
|
-
} from "./index-
|
|
277
|
+
} from "./index-x9jppg8b.js";
|
|
278
278
|
import {
|
|
279
279
|
isPathWithinDeclaredScope,
|
|
280
280
|
sanitizeDiagnosticText
|
|
@@ -326,7 +326,7 @@ import {
|
|
|
326
326
|
transactFile,
|
|
327
327
|
transactKnowledge,
|
|
328
328
|
wordBigrams
|
|
329
|
-
} from "./index-
|
|
329
|
+
} from "./index-wgrvq2bc.js";
|
|
330
330
|
import {
|
|
331
331
|
MAX_EVENT_LOG_ENTRIES,
|
|
332
332
|
_internals as _internals2,
|
|
@@ -340,10 +340,10 @@ import {
|
|
|
340
340
|
recordKnowledgeEvent,
|
|
341
341
|
recordPhaseCloseIntent,
|
|
342
342
|
resolveKnowledgeEventsPath
|
|
343
|
-
} from "./index-
|
|
343
|
+
} from "./index-s0s1e5jp.js";
|
|
344
344
|
import {
|
|
345
345
|
resolveWorktreeIsolationConfig
|
|
346
|
-
} from "./index-
|
|
346
|
+
} from "./index-x9q0b3a8.js";
|
|
347
347
|
import {
|
|
348
348
|
RetrospectiveEvidenceSchema
|
|
349
349
|
} from "./index-gprxjmm7.js";
|
|
@@ -353,7 +353,7 @@ import {
|
|
|
353
353
|
init_loader,
|
|
354
354
|
loadPluginConfig,
|
|
355
355
|
loadPluginConfigWithMeta
|
|
356
|
-
} from "./index-
|
|
356
|
+
} from "./index-nqwn8sf0.js";
|
|
357
357
|
import {
|
|
358
358
|
DEFAULT_SKILL_OPT_CONFIG,
|
|
359
359
|
FALLBACK_MODELS_MAX,
|
|
@@ -367,7 +367,7 @@ import {
|
|
|
367
367
|
package_default,
|
|
368
368
|
resolveAutoReviewConfig,
|
|
369
369
|
stripKnownSwarmPrefix
|
|
370
|
-
} from "./index-
|
|
370
|
+
} from "./index-mgcffsk0.js";
|
|
371
371
|
import {
|
|
372
372
|
AGENT_TOOL_MAP,
|
|
373
373
|
ALL_AGENT_NAMES,
|
|
@@ -419,10 +419,10 @@ import {
|
|
|
419
419
|
resolveLinkDir,
|
|
420
420
|
sanitizeLinkId,
|
|
421
421
|
writeLinkPointer
|
|
422
|
-
} from "./index-
|
|
422
|
+
} from "./index-m5z2fgs4.js";
|
|
423
423
|
import {
|
|
424
424
|
atomicWriteFile
|
|
425
|
-
} from "./index-
|
|
425
|
+
} from "./index-2zz8b0rb.js";
|
|
426
426
|
import {
|
|
427
427
|
KNOWLEDGE_SCHEMA_VERSION,
|
|
428
428
|
OUTCOME_BLOCK_THRESHOLD,
|
|
@@ -434,7 +434,7 @@ import {
|
|
|
434
434
|
atomicWriteSwarmFileSync,
|
|
435
435
|
matchTempGrammar,
|
|
436
436
|
parseTargetBasename
|
|
437
|
-
} from "./index-
|
|
437
|
+
} from "./index-zpn3wqvp.js";
|
|
438
438
|
import {
|
|
439
439
|
assertProjectRoot,
|
|
440
440
|
hasExplicitProjectBoundary,
|
|
@@ -5604,7 +5604,7 @@ async function cleanupRecoveredWorktree(directory, descriptor) {
|
|
|
5604
5604
|
awaitingMergeByCallID,
|
|
5605
5605
|
cleanupStandardWorktreeForCallId,
|
|
5606
5606
|
standardWorktreeByCallID
|
|
5607
|
-
} = await import("./worktree-isolation-
|
|
5607
|
+
} = await import("./worktree-isolation-akwwt8n5.js");
|
|
5608
5608
|
standardWorktreeByCallID.delete(descriptor.callID);
|
|
5609
5609
|
if (hasResidue)
|
|
5610
5610
|
awaitingMergeByCallID.set(descriptor.callID, {
|
|
@@ -5706,7 +5706,7 @@ async function recoverCoderSettlement(directory, taskId) {
|
|
|
5706
5706
|
awaitingMergeByCallID,
|
|
5707
5707
|
finishStandardWorktreeDispatch,
|
|
5708
5708
|
standardWorktreeByCallID
|
|
5709
|
-
} = await import("./worktree-isolation-
|
|
5709
|
+
} = await import("./worktree-isolation-akwwt8n5.js");
|
|
5710
5710
|
const descriptor = wal.worktree;
|
|
5711
5711
|
const reconstructedDispatch = {
|
|
5712
5712
|
callID: descriptor.callID,
|
|
@@ -6370,7 +6370,7 @@ async function commitTaskTerminalUnderPlanLock(options) {
|
|
|
6370
6370
|
// src/hooks/pr-workflow-gate.ts
|
|
6371
6371
|
init_zod();
|
|
6372
6372
|
import { createHash as createHash5, randomUUID as randomUUID3 } from "crypto";
|
|
6373
|
-
import { readFileSync as readFileSync5 } from "fs";
|
|
6373
|
+
import { readFileSync as readFileSync5, statSync as statSync5 } from "fs";
|
|
6374
6374
|
import * as fsp2 from "fs/promises";
|
|
6375
6375
|
import * as path12 from "path";
|
|
6376
6376
|
|
|
@@ -7663,6 +7663,258 @@ function digestText(text) {
|
|
|
7663
7663
|
return createHash4("sha256").update(text).digest("hex");
|
|
7664
7664
|
}
|
|
7665
7665
|
|
|
7666
|
+
// src/background/pr-review-contract.ts
|
|
7667
|
+
init_zod();
|
|
7668
|
+
var PR_REVIEW_REVIEWER_CLASSIFICATIONS = [
|
|
7669
|
+
"CONFIRMED",
|
|
7670
|
+
"DISPROVED",
|
|
7671
|
+
"UNVERIFIED",
|
|
7672
|
+
"PRE_EXISTING"
|
|
7673
|
+
];
|
|
7674
|
+
var PR_REVIEW_REVIEWER_EVIDENCE_TYPES = [
|
|
7675
|
+
"STRUCTURALLY_PROVEN",
|
|
7676
|
+
"EXECUTION_PROVEN",
|
|
7677
|
+
"STATIC_TRACE_PROVEN",
|
|
7678
|
+
"PLAUSIBLE_BUT_UNVERIFIED"
|
|
7679
|
+
];
|
|
7680
|
+
var PR_REVIEW_SEVERITIES = [
|
|
7681
|
+
"CRITICAL",
|
|
7682
|
+
"HIGH",
|
|
7683
|
+
"MEDIUM",
|
|
7684
|
+
"LOW",
|
|
7685
|
+
"INFO",
|
|
7686
|
+
"NONE"
|
|
7687
|
+
];
|
|
7688
|
+
var PR_REVIEW_CRITIC_STATUSES = [
|
|
7689
|
+
"UPHELD",
|
|
7690
|
+
"DOWNGRADED",
|
|
7691
|
+
"DISPROVED",
|
|
7692
|
+
"NEEDS_MORE_EVIDENCE"
|
|
7693
|
+
];
|
|
7694
|
+
var PR_REVIEW_FINDING_STATUSES = [
|
|
7695
|
+
"PENDING",
|
|
7696
|
+
"CONFIRMED",
|
|
7697
|
+
"DISPROVED",
|
|
7698
|
+
"PRE_EXISTING"
|
|
7699
|
+
];
|
|
7700
|
+
var PR_REVIEW_FINDING_ACTIONS = [
|
|
7701
|
+
"route_to_reviewer",
|
|
7702
|
+
"route_to_critic",
|
|
7703
|
+
"report",
|
|
7704
|
+
"suppress_with_reason",
|
|
7705
|
+
"handoff_to_feedback"
|
|
7706
|
+
];
|
|
7707
|
+
var PR_REVIEW_ARTIFACT_BOUNDARIES = [
|
|
7708
|
+
"post_explorer",
|
|
7709
|
+
"post_reviewer",
|
|
7710
|
+
"post_critic"
|
|
7711
|
+
];
|
|
7712
|
+
var PR_REVIEW_FINDINGS_MAX_BYTES = 10 * 1024 * 1024;
|
|
7713
|
+
var PR_REVIEW_FINDINGS_WRITE_MAX_BYTES = 3 * 1024 * 1024;
|
|
7714
|
+
var PR_REVIEW_HANDOFF_MAX_BYTES = 128 * 1024;
|
|
7715
|
+
var PR_REVIEW_HANDOFF_WRITE_MAX_BYTES = 120 * 1024;
|
|
7716
|
+
var PR_REVIEW_DISCARDED_EXAMPLE_ITEM_ID = "discarded-id";
|
|
7717
|
+
function serializedPrReviewArtifactInputBytes(value) {
|
|
7718
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
7719
|
+
}
|
|
7720
|
+
var PrReviewRunIdSchema = exports_external.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/, "run_id must be a safe relative identifier");
|
|
7721
|
+
var PrReviewFindingSchema = exports_external.object({
|
|
7722
|
+
finding_id: exports_external.string().trim().min(1).max(128),
|
|
7723
|
+
status: exports_external.enum(PR_REVIEW_FINDING_STATUSES),
|
|
7724
|
+
file_line: exports_external.string().trim().min(1).max(1000),
|
|
7725
|
+
evidence: exports_external.string().trim().min(1).max(20000),
|
|
7726
|
+
next_action: exports_external.enum(PR_REVIEW_FINDING_ACTIONS),
|
|
7727
|
+
severity: exports_external.enum(PR_REVIEW_SEVERITIES).optional(),
|
|
7728
|
+
category: exports_external.string().trim().min(1).max(128).optional()
|
|
7729
|
+
}).strict();
|
|
7730
|
+
var PrReviewHandoffSchema = exports_external.object({
|
|
7731
|
+
pr_url: exports_external.string().url().max(2000),
|
|
7732
|
+
finding_ids: exports_external.array(exports_external.string().trim().min(1).max(128)).min(1).max(1000),
|
|
7733
|
+
summary: exports_external.string().trim().min(1).max(20000),
|
|
7734
|
+
provenance: exports_external.array(exports_external.string().trim().min(1).max(4000)).min(1).max(1000)
|
|
7735
|
+
}).strict();
|
|
7736
|
+
var WritePrReviewArtifactArgsSchema = exports_external.discriminatedUnion("kind", [
|
|
7737
|
+
exports_external.object({
|
|
7738
|
+
kind: exports_external.literal("findings"),
|
|
7739
|
+
run_id: PrReviewRunIdSchema.optional(),
|
|
7740
|
+
pr_head_sha: exports_external.string().trim().regex(/^[0-9a-f]{6,64}$/i),
|
|
7741
|
+
boundary: exports_external.enum(PR_REVIEW_ARTIFACT_BOUNDARIES),
|
|
7742
|
+
records: exports_external.array(PrReviewFindingSchema).min(1).max(1000)
|
|
7743
|
+
}).strict(),
|
|
7744
|
+
exports_external.object({
|
|
7745
|
+
kind: exports_external.literal("handoff"),
|
|
7746
|
+
run_id: PrReviewRunIdSchema.optional(),
|
|
7747
|
+
pr_head_sha: exports_external.string().trim().regex(/^[0-9a-f]{6,64}$/i),
|
|
7748
|
+
handoff: PrReviewHandoffSchema
|
|
7749
|
+
}).strict()
|
|
7750
|
+
]).superRefine((value, ctx) => {
|
|
7751
|
+
const bytes = serializedPrReviewArtifactInputBytes(value);
|
|
7752
|
+
const maxBytes = value.kind === "findings" ? PR_REVIEW_FINDINGS_WRITE_MAX_BYTES : PR_REVIEW_HANDOFF_WRITE_MAX_BYTES;
|
|
7753
|
+
if (bytes > maxBytes) {
|
|
7754
|
+
ctx.addIssue({
|
|
7755
|
+
code: "custom",
|
|
7756
|
+
path: [value.kind === "findings" ? "records" : "handoff"],
|
|
7757
|
+
message: `serialized UTF-8 payload must be at most ${maxBytes} bytes (got ${bytes})`
|
|
7758
|
+
});
|
|
7759
|
+
}
|
|
7760
|
+
});
|
|
7761
|
+
var introducedByPrSchema = exports_external.string().regex(/^(?:introduced_by_pr\s*:\s*)?(?:YES|NO|UNKNOWN)$/i);
|
|
7762
|
+
var PrReviewReviewerVerdictFieldsSchema = exports_external.tuple([
|
|
7763
|
+
exports_external.literal("[REVIEWED]"),
|
|
7764
|
+
exports_external.string().min(1),
|
|
7765
|
+
exports_external.enum(PR_REVIEW_REVIEWER_CLASSIFICATIONS),
|
|
7766
|
+
exports_external.enum(PR_REVIEW_REVIEWER_EVIDENCE_TYPES),
|
|
7767
|
+
exports_external.enum(PR_REVIEW_SEVERITIES),
|
|
7768
|
+
introducedByPrSchema,
|
|
7769
|
+
exports_external.string().min(1),
|
|
7770
|
+
exports_external.string().min(8),
|
|
7771
|
+
exports_external.string().min(5),
|
|
7772
|
+
exports_external.string().min(3)
|
|
7773
|
+
]).superRefine((fields, ctx) => {
|
|
7774
|
+
if (fields[2] === "DISPROVED" && fields[4] !== "NONE") {
|
|
7775
|
+
ctx.addIssue({
|
|
7776
|
+
code: "custom",
|
|
7777
|
+
path: [4],
|
|
7778
|
+
message: "DISPROVED reviewer severity must be NONE"
|
|
7779
|
+
});
|
|
7780
|
+
}
|
|
7781
|
+
});
|
|
7782
|
+
var PrReviewCriticVerdictFieldsSchema = exports_external.tuple([
|
|
7783
|
+
exports_external.literal("[CRITIC]"),
|
|
7784
|
+
exports_external.string().min(1),
|
|
7785
|
+
exports_external.enum(PR_REVIEW_CRITIC_STATUSES),
|
|
7786
|
+
exports_external.enum(PR_REVIEW_SEVERITIES),
|
|
7787
|
+
exports_external.string().min(6),
|
|
7788
|
+
exports_external.string().min(6)
|
|
7789
|
+
]).superRefine((fields, ctx) => {
|
|
7790
|
+
const status = fields[2];
|
|
7791
|
+
const severity = fields[3];
|
|
7792
|
+
if (status === "NEEDS_MORE_EVIDENCE") {
|
|
7793
|
+
ctx.addIssue({
|
|
7794
|
+
code: "custom",
|
|
7795
|
+
path: [2],
|
|
7796
|
+
message: "NEEDS_MORE_EVIDENCE is not a terminal transport verdict"
|
|
7797
|
+
});
|
|
7798
|
+
}
|
|
7799
|
+
if (status === "DISPROVED" && severity !== "NONE") {
|
|
7800
|
+
ctx.addIssue({
|
|
7801
|
+
code: "custom",
|
|
7802
|
+
path: [3],
|
|
7803
|
+
message: "DISPROVED critic severity must be NONE"
|
|
7804
|
+
});
|
|
7805
|
+
}
|
|
7806
|
+
if (status === "UPHELD" && !["CRITICAL", "HIGH", "MEDIUM"].includes(severity)) {
|
|
7807
|
+
ctx.addIssue({
|
|
7808
|
+
code: "custom",
|
|
7809
|
+
path: [3],
|
|
7810
|
+
message: "UPHELD critic severity must be CRITICAL, HIGH, or MEDIUM"
|
|
7811
|
+
});
|
|
7812
|
+
}
|
|
7813
|
+
if (status === "DOWNGRADED" && severity === "CRITICAL") {
|
|
7814
|
+
ctx.addIssue({
|
|
7815
|
+
code: "custom",
|
|
7816
|
+
path: [3],
|
|
7817
|
+
message: "DOWNGRADED critic severity cannot be CRITICAL"
|
|
7818
|
+
});
|
|
7819
|
+
}
|
|
7820
|
+
});
|
|
7821
|
+
var PR_REVIEW_VERDICT_ROW_DESCRIPTORS = {
|
|
7822
|
+
reviewer: {
|
|
7823
|
+
marker: "[REVIEWED]",
|
|
7824
|
+
fieldCount: 10,
|
|
7825
|
+
fieldRoles: [
|
|
7826
|
+
"marker",
|
|
7827
|
+
"item_id",
|
|
7828
|
+
"classification",
|
|
7829
|
+
"evidence_type",
|
|
7830
|
+
"severity",
|
|
7831
|
+
"introduced_by_pr",
|
|
7832
|
+
"file:line",
|
|
7833
|
+
"rationale",
|
|
7834
|
+
"probe",
|
|
7835
|
+
"reviewer_notes"
|
|
7836
|
+
],
|
|
7837
|
+
schema: PrReviewReviewerVerdictFieldsSchema
|
|
7838
|
+
},
|
|
7839
|
+
critic: {
|
|
7840
|
+
marker: "[CRITIC]",
|
|
7841
|
+
fieldCount: 6,
|
|
7842
|
+
fieldRoles: [
|
|
7843
|
+
"marker",
|
|
7844
|
+
"item_id",
|
|
7845
|
+
"status",
|
|
7846
|
+
"severity",
|
|
7847
|
+
"rationale",
|
|
7848
|
+
"required_change"
|
|
7849
|
+
],
|
|
7850
|
+
schema: PrReviewCriticVerdictFieldsSchema
|
|
7851
|
+
}
|
|
7852
|
+
};
|
|
7853
|
+
function parsePrReviewVerdictRow(line, kind) {
|
|
7854
|
+
const descriptor = PR_REVIEW_VERDICT_ROW_DESCRIPTORS[kind];
|
|
7855
|
+
const fields = [];
|
|
7856
|
+
let current = "";
|
|
7857
|
+
let usedCanonicalEscape = false;
|
|
7858
|
+
for (let index = 0;index < line.length; index++) {
|
|
7859
|
+
const char = line[index];
|
|
7860
|
+
if (char === "\\") {
|
|
7861
|
+
const next = line[index + 1];
|
|
7862
|
+
if (next === "\\") {
|
|
7863
|
+
current += "\\";
|
|
7864
|
+
usedCanonicalEscape = true;
|
|
7865
|
+
index++;
|
|
7866
|
+
continue;
|
|
7867
|
+
}
|
|
7868
|
+
if (next === "|") {
|
|
7869
|
+
current += "|";
|
|
7870
|
+
usedCanonicalEscape = true;
|
|
7871
|
+
index++;
|
|
7872
|
+
continue;
|
|
7873
|
+
}
|
|
7874
|
+
if (next === "n") {
|
|
7875
|
+
current += `
|
|
7876
|
+
`;
|
|
7877
|
+
usedCanonicalEscape = true;
|
|
7878
|
+
index++;
|
|
7879
|
+
continue;
|
|
7880
|
+
}
|
|
7881
|
+
if (next === "r") {
|
|
7882
|
+
current += "\r";
|
|
7883
|
+
usedCanonicalEscape = true;
|
|
7884
|
+
index++;
|
|
7885
|
+
continue;
|
|
7886
|
+
}
|
|
7887
|
+
current += "\\";
|
|
7888
|
+
continue;
|
|
7889
|
+
}
|
|
7890
|
+
if (char === "|") {
|
|
7891
|
+
fields.push(current.trim());
|
|
7892
|
+
current = "";
|
|
7893
|
+
continue;
|
|
7894
|
+
}
|
|
7895
|
+
current += char;
|
|
7896
|
+
}
|
|
7897
|
+
fields.push(current.trim());
|
|
7898
|
+
if (fields[0] !== descriptor.marker)
|
|
7899
|
+
return null;
|
|
7900
|
+
if (fields.length > descriptor.fieldCount) {
|
|
7901
|
+
const retained = fields.slice(0, descriptor.fieldCount - 1);
|
|
7902
|
+
retained.push(fields.slice(descriptor.fieldCount - 1).join("|"));
|
|
7903
|
+
return {
|
|
7904
|
+
marker: descriptor.marker,
|
|
7905
|
+
fields: retained,
|
|
7906
|
+
recoveredOverflow: true,
|
|
7907
|
+
overflowClass: fields.length === descriptor.fieldCount + 1 && fields[fields.length - 1] === "" ? "legacy-fidelity-safe" : "legacy-lossy"
|
|
7908
|
+
};
|
|
7909
|
+
}
|
|
7910
|
+
return {
|
|
7911
|
+
marker: descriptor.marker,
|
|
7912
|
+
fields,
|
|
7913
|
+
recoveredOverflow: false,
|
|
7914
|
+
overflowClass: fields.length === descriptor.fieldCount ? usedCanonicalEscape ? "canonical" : "legacy-fidelity-safe" : "legacy-lossy"
|
|
7915
|
+
};
|
|
7916
|
+
}
|
|
7917
|
+
|
|
7666
7918
|
// src/background/pr-review-trigger-contract.ts
|
|
7667
7919
|
init_zod();
|
|
7668
7920
|
var PR_REVIEW_TRIGGER_DEFINITIONS = [
|
|
@@ -7734,6 +7986,7 @@ var PR_REVIEW_TRIGGER_DEFINITIONS = [
|
|
|
7734
7986
|
}
|
|
7735
7987
|
];
|
|
7736
7988
|
var PR_REVIEW_REQUIRED_TRIGGER_IDS = PR_REVIEW_TRIGGER_DEFINITIONS.map((definition) => definition.id);
|
|
7989
|
+
var PR_REVIEW_TRIGGER_RECEIPT_MAX_BYTES = 2 * 1024 * 1024;
|
|
7737
7990
|
var TriggerIdSchema = exports_external.enum(PR_REVIEW_REQUIRED_TRIGGER_IDS, { error: "unknown PR_REVIEW trigger_id" });
|
|
7738
7991
|
var TriggerEvidenceSchema = exports_external.string().trim().min(1).max(4000);
|
|
7739
7992
|
var PrReviewInlineTriggerRowSchema = exports_external.discriminatedUnion("result", [
|
|
@@ -8488,6 +8741,7 @@ var PrWorkflowGateStateSchema = exports_external.object({
|
|
|
8488
8741
|
prReviewBatchCoherence: exports_external.record(exports_external.string().min(1), PrReviewBatchCoherenceRecordSchema).refine((entries) => Object.keys(entries).length <= MAX_WORKFLOW_BATCHES, `prReviewBatchCoherence may not exceed ${MAX_WORKFLOW_BATCHES} entries`).optional(),
|
|
8489
8742
|
prReviewRetiredReviewerSessionIds: exports_external.array(exports_external.string().min(1)).max(MAX_RETIRED_REVIEWER_SESSION_IDS).optional(),
|
|
8490
8743
|
prReviewRetiredConsolidatedLanes: exports_external.array(exports_external.string().min(1)).max(MAX_RETIRED_CONSOLIDATED_LANES).optional(),
|
|
8744
|
+
prReviewReservedRunId: exports_external.string().min(1).optional(),
|
|
8491
8745
|
prReviewArtifactRunId: exports_external.string().min(1).optional(),
|
|
8492
8746
|
prReviewFindingsPath: exports_external.string().min(1).optional(),
|
|
8493
8747
|
prReviewArtifactBoundaries: exports_external.array(exports_external.enum(["post_explorer", "post_reviewer", "post_critic"])).max(3).optional(),
|
|
@@ -9140,8 +9394,8 @@ async function assertPrReviewValidationSettled(directory, sessionID, phase, gate
|
|
|
9140
9394
|
return state;
|
|
9141
9395
|
}
|
|
9142
9396
|
var PR_REVIEW_HANDOFF_RELATIVE_PATH_PATTERN = /^pr-review\/([A-Za-z0-9][A-Za-z0-9._-]{0,127})\/feedback-handoff\.json$/;
|
|
9143
|
-
var
|
|
9144
|
-
var
|
|
9397
|
+
var PR_REVIEW_FEEDBACK_CONSENT_MAX_BYTES = 64 * 1024;
|
|
9398
|
+
var PR_REVIEW_RUN_RESERVATION_MAX_BYTES = 16 * 1024;
|
|
9145
9399
|
var PrReviewFeedbackHandoffArtifactSchema = exports_external.object({
|
|
9146
9400
|
schema_version: exports_external.literal(1),
|
|
9147
9401
|
run_id: exports_external.string().min(1).max(128),
|
|
@@ -9152,6 +9406,28 @@ var PrReviewFeedbackHandoffArtifactSchema = exports_external.object({
|
|
|
9152
9406
|
summary: exports_external.string().min(1).max(20000),
|
|
9153
9407
|
provenance: exports_external.array(exports_external.string().min(1).max(4000)).min(1).max(1000)
|
|
9154
9408
|
}).strict();
|
|
9409
|
+
var PrReviewRunReservationSchema = exports_external.object({
|
|
9410
|
+
schema_version: exports_external.literal(1),
|
|
9411
|
+
session_id: exports_external.string().min(1),
|
|
9412
|
+
workflow_instance_id: exports_external.string().min(1),
|
|
9413
|
+
run_id: exports_external.string().min(1).max(128),
|
|
9414
|
+
reserved_at: exports_external.string().datetime()
|
|
9415
|
+
}).strict();
|
|
9416
|
+
var PrReviewFeedbackConsentSchema = exports_external.object({
|
|
9417
|
+
schema_version: exports_external.literal(1),
|
|
9418
|
+
state: exports_external.enum(["offered", "confirmed"]),
|
|
9419
|
+
session_id: exports_external.string().min(1),
|
|
9420
|
+
source_workflow_instance_id: exports_external.string().min(1),
|
|
9421
|
+
run_id: exports_external.string().min(1).max(128),
|
|
9422
|
+
handoff_path: exports_external.string().min(1).max(512),
|
|
9423
|
+
handoff_digest: exports_external.string().regex(/^[a-f0-9]{64}$/),
|
|
9424
|
+
pr_url: exports_external.string().url().max(2000),
|
|
9425
|
+
pr_head_sha: exports_external.string().regex(/^[0-9a-f]{6,64}$/i),
|
|
9426
|
+
finding_ids_digest: exports_external.string().regex(/^[a-f0-9]{64}$/),
|
|
9427
|
+
confirmation_command: exports_external.string().min(1).max(4000),
|
|
9428
|
+
offered_at: exports_external.string().datetime(),
|
|
9429
|
+
confirmed_at: exports_external.string().datetime().optional()
|
|
9430
|
+
}).strict();
|
|
9155
9431
|
function normalizePrReviewFeedbackHandoffPath(handoffPath) {
|
|
9156
9432
|
const normalized = handoffPath.trim().replace(/\\/g, "/");
|
|
9157
9433
|
const relative3 = normalized.startsWith(".swarm/") ? normalized.slice(".swarm/".length) : normalized;
|
|
@@ -9160,6 +9436,13 @@ function normalizePrReviewFeedbackHandoffPath(handoffPath) {
|
|
|
9160
9436
|
return null;
|
|
9161
9437
|
return { runId: matched[1], relativePath: relative3 };
|
|
9162
9438
|
}
|
|
9439
|
+
function buildAcceptedPrFeedbackContinuationCommands(confirmationCommand, relativeHandoffPath, requestedPrUrl) {
|
|
9440
|
+
const commands = new Set([confirmationCommand]);
|
|
9441
|
+
if (!requestedPrUrl) {
|
|
9442
|
+
commands.add(`/swarm pr-feedback continue from .swarm/${relativeHandoffPath}`);
|
|
9443
|
+
}
|
|
9444
|
+
return commands;
|
|
9445
|
+
}
|
|
9163
9446
|
async function readBoundedSwarmRegularFile(directory, relativePath, maxBytes, label) {
|
|
9164
9447
|
const absPath = validateSwarmPath(directory, relativePath);
|
|
9165
9448
|
const swarmRoot = path12.resolve(directory, ".swarm");
|
|
@@ -9225,6 +9508,68 @@ function normalizeComparableFsPath(value) {
|
|
|
9225
9508
|
const normalized = path12.normalize(path12.resolve(value));
|
|
9226
9509
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
9227
9510
|
}
|
|
9511
|
+
function prReviewRunReservationRelativePath(runId) {
|
|
9512
|
+
return `pr-review/${runId}/run-reservation.json`;
|
|
9513
|
+
}
|
|
9514
|
+
function prReviewFeedbackConsentRelativePath(runId) {
|
|
9515
|
+
return `pr-review/${runId}/feedback-consent.json`;
|
|
9516
|
+
}
|
|
9517
|
+
function hashPrReviewFindingIds(ids) {
|
|
9518
|
+
return createHash5("sha256").update([...new Set(ids)].sort().join("\x00"), "utf8").digest("hex");
|
|
9519
|
+
}
|
|
9520
|
+
async function readPrReviewRunReservation(directory, runId) {
|
|
9521
|
+
try {
|
|
9522
|
+
const raw = await readBoundedSwarmRegularFile(directory, prReviewRunReservationRelativePath(runId), PR_REVIEW_RUN_RESERVATION_MAX_BYTES, "PR_REVIEW run reservation");
|
|
9523
|
+
const parsed = PrReviewRunReservationSchema.safeParse(JSON.parse(raw));
|
|
9524
|
+
if (!parsed.success) {
|
|
9525
|
+
throw new Error("BLOCKED: PR_REVIEW run reservation is invalid");
|
|
9526
|
+
}
|
|
9527
|
+
return parsed.data;
|
|
9528
|
+
} catch (error2) {
|
|
9529
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
9530
|
+
if (message.includes("does not exist"))
|
|
9531
|
+
return null;
|
|
9532
|
+
throw error2;
|
|
9533
|
+
}
|
|
9534
|
+
}
|
|
9535
|
+
async function readPrReviewFeedbackConsent(directory, runId) {
|
|
9536
|
+
try {
|
|
9537
|
+
const raw = await readBoundedSwarmRegularFile(directory, prReviewFeedbackConsentRelativePath(runId), PR_REVIEW_FEEDBACK_CONSENT_MAX_BYTES, "PR_REVIEW feedback consent artifact");
|
|
9538
|
+
const parsed = PrReviewFeedbackConsentSchema.safeParse(JSON.parse(raw));
|
|
9539
|
+
if (!parsed.success) {
|
|
9540
|
+
throw new Error("BLOCKED: PR_REVIEW feedback consent artifact is invalid");
|
|
9541
|
+
}
|
|
9542
|
+
return parsed.data;
|
|
9543
|
+
} catch (error2) {
|
|
9544
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
9545
|
+
if (message.includes("does not exist"))
|
|
9546
|
+
return null;
|
|
9547
|
+
throw error2;
|
|
9548
|
+
}
|
|
9549
|
+
}
|
|
9550
|
+
async function writePrReviewFeedbackConsent(directory, record) {
|
|
9551
|
+
const relativePath = prReviewFeedbackConsentRelativePath(record.run_id);
|
|
9552
|
+
const absolutePath = validateSwarmPath(directory, relativePath);
|
|
9553
|
+
if (record.state === "confirmed") {
|
|
9554
|
+
await writeAtomicJson(directory, absolutePath, record);
|
|
9555
|
+
return;
|
|
9556
|
+
}
|
|
9557
|
+
const parent = path12.dirname(absolutePath);
|
|
9558
|
+
const tempPath = path12.join(parent, `.feedback-consent.${randomUUID3()}.tmp`);
|
|
9559
|
+
await fsp2.mkdir(parent, { recursive: true });
|
|
9560
|
+
try {
|
|
9561
|
+
await fsp2.writeFile(tempPath, `${JSON.stringify(record, null, 2)}
|
|
9562
|
+
`, {
|
|
9563
|
+
encoding: "utf8",
|
|
9564
|
+
flag: "wx"
|
|
9565
|
+
});
|
|
9566
|
+
await fsp2.link(tempPath, absolutePath);
|
|
9567
|
+
} finally {
|
|
9568
|
+
await fsp2.rm(tempPath, { force: true }).catch(() => {
|
|
9569
|
+
return;
|
|
9570
|
+
});
|
|
9571
|
+
}
|
|
9572
|
+
}
|
|
9228
9573
|
async function readPrReviewFeedbackHandoffArtifact(directory, relativePath) {
|
|
9229
9574
|
const raw = await readBoundedSwarmRegularFile(directory, relativePath, PR_REVIEW_HANDOFF_MAX_BYTES, "PR_REVIEW feedback handoff artifact");
|
|
9230
9575
|
let parsedJson;
|
|
@@ -9297,6 +9642,11 @@ function canonicalGitHubPrUrl(value) {
|
|
|
9297
9642
|
return null;
|
|
9298
9643
|
}
|
|
9299
9644
|
}
|
|
9645
|
+
function assertMatchingPrReviewFeedbackConsent(record, input) {
|
|
9646
|
+
if (record.session_id !== input.sessionID || record.run_id !== input.runId || record.handoff_path !== input.handoffPath || record.handoff_digest !== input.handoffDigest || canonicalGitHubPrUrl(record.pr_url) !== canonicalGitHubPrUrl(input.prUrl) || record.pr_head_sha.toLowerCase() !== input.prHeadSha.toLowerCase() || record.finding_ids_digest !== input.findingIdsDigest || record.source_workflow_instance_id !== input.sourceWorkflowInstanceId) {
|
|
9647
|
+
throw new Error("BLOCKED: PR_REVIEW feedback consent artifact does not match the requested handoff; remove the stale sidecar or repeat the exact continuation offer");
|
|
9648
|
+
}
|
|
9649
|
+
}
|
|
9300
9650
|
function workflowIdentity(state) {
|
|
9301
9651
|
return state.workflowInstanceId ?? `legacy-${createHash5("sha256").update(`${state.sessionID}\x00${state.mode}\x00${state.activatedAt}`).digest("hex").slice(0, 32)}`;
|
|
9302
9652
|
}
|
|
@@ -9376,6 +9726,7 @@ async function transitionPrReviewToFeedback(directory, sessionID, request) {
|
|
|
9376
9726
|
return preliminary;
|
|
9377
9727
|
}
|
|
9378
9728
|
let sourceIdentity;
|
|
9729
|
+
let expectedConsentSourceIdentity;
|
|
9379
9730
|
let sourceRevision = 0;
|
|
9380
9731
|
let provenance;
|
|
9381
9732
|
if (preliminary) {
|
|
@@ -9391,17 +9742,39 @@ async function transitionPrReviewToFeedback(directory, sessionID, request) {
|
|
|
9391
9742
|
throw new Error("BLOCKED: PR_REVIEW feedback handoff finding IDs do not match the authoritative final findings ledger");
|
|
9392
9743
|
}
|
|
9393
9744
|
sourceIdentity = workflowIdentity(ready);
|
|
9745
|
+
expectedConsentSourceIdentity = sourceIdentity;
|
|
9394
9746
|
sourceRevision = ready.revision;
|
|
9395
9747
|
provenance = "active-review-v1";
|
|
9396
9748
|
} else {
|
|
9397
|
-
|
|
9398
|
-
|
|
9749
|
+
const reservation = await readPrReviewRunReservation(directory, request.runId);
|
|
9750
|
+
if (!reservation || reservation.session_id !== normalizedSessionID || reservation.run_id !== request.runId) {
|
|
9751
|
+
throw new Error("BLOCKED: completed PR_REVIEW continuation requires the matching durable run reservation for this session");
|
|
9399
9752
|
}
|
|
9400
|
-
|
|
9753
|
+
expectedConsentSourceIdentity = reservation.workflow_instance_id;
|
|
9754
|
+
sourceIdentity = expectedConsentSourceIdentity;
|
|
9401
9755
|
provenance = "external-v1";
|
|
9402
9756
|
}
|
|
9757
|
+
const consent = await readPrReviewFeedbackConsent(directory, request.runId);
|
|
9758
|
+
if (!consent) {
|
|
9759
|
+
throw new Error("BLOCKED: PR_FEEDBACK continuation requires explicit confirmation; repeat the exact continuation command first");
|
|
9760
|
+
}
|
|
9761
|
+
assertMatchingPrReviewFeedbackConsent(consent, {
|
|
9762
|
+
sessionID: normalizedSessionID,
|
|
9763
|
+
runId: request.runId,
|
|
9764
|
+
handoffPath: normalizedHandoff.relativePath,
|
|
9765
|
+
handoffDigest: preliminaryRead.digest,
|
|
9766
|
+
prUrl: artifact.pr_url,
|
|
9767
|
+
prHeadSha: artifact.pr_head_sha,
|
|
9768
|
+
findingIdsDigest: hashPrReviewFindingIds(artifact.finding_ids),
|
|
9769
|
+
sourceWorkflowInstanceId: expectedConsentSourceIdentity
|
|
9770
|
+
});
|
|
9771
|
+
const exactCommand = request.exactCommand?.trim();
|
|
9772
|
+
const acceptedContinuationCommands = buildAcceptedPrFeedbackContinuationCommands(consent.confirmation_command, normalizedHandoff.relativePath, request.prUrl);
|
|
9773
|
+
if (request.confirmedByUser !== true || !exactCommand || !acceptedContinuationCommands.has(exactCommand)) {
|
|
9774
|
+
throw new Error(`BLOCKED: PR_FEEDBACK continuation requires explicit confirmation with the offered command: ${consent.confirmation_command}`);
|
|
9775
|
+
}
|
|
9403
9776
|
await _test_exports2.beforePrFeedbackTransitionLock?.();
|
|
9404
|
-
return withSessionStateMutation(directory, normalizedSessionID, async () => {
|
|
9777
|
+
return withPrWorkflowCheckoutMutationLock(directory, () => withSessionStateMutation(directory, normalizedSessionID, async () => {
|
|
9405
9778
|
const current = await readPrWorkflowGateStateFromDisk(directory, normalizedSessionID);
|
|
9406
9779
|
if (current?.mode === "PR_FEEDBACK") {
|
|
9407
9780
|
assertSamePrFeedbackHandoff(current, normalizedHandoff.relativePath, preliminaryRead, request.prUrl);
|
|
@@ -9414,6 +9787,12 @@ async function transitionPrReviewToFeedback(directory, sessionID, request) {
|
|
|
9414
9787
|
} else if (current) {
|
|
9415
9788
|
throw new Error("BLOCKED: another PR workflow became active while validating the external handoff");
|
|
9416
9789
|
}
|
|
9790
|
+
if (provenance === "external-v1") {
|
|
9791
|
+
const lockedReservation = await readPrReviewRunReservation(directory, request.runId);
|
|
9792
|
+
if (!lockedReservation || lockedReservation.session_id !== normalizedSessionID || lockedReservation.workflow_instance_id !== expectedConsentSourceIdentity) {
|
|
9793
|
+
throw new Error("BLOCKED: PR_REVIEW run reservation changed during external feedback transition");
|
|
9794
|
+
}
|
|
9795
|
+
}
|
|
9417
9796
|
const lockedRead = await readPrReviewFeedbackHandoffArtifact(directory, normalizedHandoff.relativePath);
|
|
9418
9797
|
if (lockedRead.digest !== preliminaryRead.digest) {
|
|
9419
9798
|
throw new Error("BLOCKED: PR_REVIEW feedback handoff artifact changed during transition");
|
|
@@ -9421,6 +9800,30 @@ async function transitionPrReviewToFeedback(directory, sessionID, request) {
|
|
|
9421
9800
|
if (artifactPr !== canonicalGitHubPrUrl(lockedRead.artifact.pr_url) || lockedRead.artifact.run_id !== request.runId || lockedRead.artifact.pr_head_sha.toLowerCase() !== artifact.pr_head_sha.toLowerCase() || !sameHandoffIds(lockedRead.artifact.finding_ids, artifact.finding_ids)) {
|
|
9422
9801
|
throw new Error("BLOCKED: PR_REVIEW feedback handoff artifact changed during transition");
|
|
9423
9802
|
}
|
|
9803
|
+
const lockedConsent = await readPrReviewFeedbackConsent(directory, request.runId);
|
|
9804
|
+
if (!lockedConsent) {
|
|
9805
|
+
throw new Error("BLOCKED: PR_REVIEW feedback consent artifact disappeared during transition");
|
|
9806
|
+
}
|
|
9807
|
+
assertMatchingPrReviewFeedbackConsent(lockedConsent, {
|
|
9808
|
+
sessionID: normalizedSessionID,
|
|
9809
|
+
runId: request.runId,
|
|
9810
|
+
handoffPath: normalizedHandoff.relativePath,
|
|
9811
|
+
handoffDigest: lockedRead.digest,
|
|
9812
|
+
prUrl: lockedRead.artifact.pr_url,
|
|
9813
|
+
prHeadSha: lockedRead.artifact.pr_head_sha,
|
|
9814
|
+
findingIdsDigest: hashPrReviewFindingIds(lockedRead.artifact.finding_ids),
|
|
9815
|
+
sourceWorkflowInstanceId: expectedConsentSourceIdentity
|
|
9816
|
+
});
|
|
9817
|
+
if (!buildAcceptedPrFeedbackContinuationCommands(lockedConsent.confirmation_command, normalizedHandoff.relativePath, request.prUrl).has(exactCommand)) {
|
|
9818
|
+
throw new Error("BLOCKED: PR_FEEDBACK continuation command changed during transition");
|
|
9819
|
+
}
|
|
9820
|
+
if (lockedConsent.state === "offered") {
|
|
9821
|
+
await writePrReviewFeedbackConsent(directory, {
|
|
9822
|
+
...lockedConsent,
|
|
9823
|
+
state: "confirmed",
|
|
9824
|
+
confirmed_at: isoNow()
|
|
9825
|
+
});
|
|
9826
|
+
}
|
|
9424
9827
|
const timestamp = isoNow();
|
|
9425
9828
|
const nextState = {
|
|
9426
9829
|
schemaVersion: GATE_SCHEMA_VERSION,
|
|
@@ -9445,7 +9848,7 @@ async function transitionPrReviewToFeedback(directory, sessionID, request) {
|
|
|
9445
9848
|
return writeStateWhileLocked(directory, nextState, {
|
|
9446
9849
|
replaceWorkflowInstanceId: provenance === "active-review-v1" ? current?.workflowInstanceId : undefined
|
|
9447
9850
|
});
|
|
9448
|
-
});
|
|
9851
|
+
}));
|
|
9449
9852
|
}
|
|
9450
9853
|
var _test_exports2 = {
|
|
9451
9854
|
minimumConsolidatedLaneCover,
|
|
@@ -9455,6 +9858,7 @@ var _test_exports2 = {
|
|
|
9455
9858
|
parseCanonicalCandidateRows,
|
|
9456
9859
|
resolvePrReviewRowFamily,
|
|
9457
9860
|
pipeFieldsCapped,
|
|
9861
|
+
indexVerdictRows,
|
|
9458
9862
|
reviewerVerdictRowDigest,
|
|
9459
9863
|
workflowGateStateRelativePath,
|
|
9460
9864
|
workflowGateStateLockRelativePath,
|
|
@@ -9895,6 +10299,10 @@ function derivePrReviewCandidateInventory(directory, state, ctx) {
|
|
|
9895
10299
|
const triggerPath = validateSwarmPath(directory, state.prReviewTriggerEvalPath);
|
|
9896
10300
|
let triggerArtifact;
|
|
9897
10301
|
try {
|
|
10302
|
+
const triggerStat = statSync5(triggerPath);
|
|
10303
|
+
if (!triggerStat.isFile() || triggerStat.size > PR_REVIEW_TRIGGER_RECEIPT_MAX_BYTES) {
|
|
10304
|
+
throw new Error("trigger evaluation artifact exceeds its read bound");
|
|
10305
|
+
}
|
|
9898
10306
|
triggerArtifact = JSON.parse(readFileSync5(triggerPath, "utf-8"));
|
|
9899
10307
|
} catch {
|
|
9900
10308
|
throw new Error("BLOCKED: PR_REVIEW trigger evaluation artifact is missing or invalid");
|
|
@@ -10549,7 +10957,7 @@ function workflowArtifactHasContractMarker(directory, state, record, expectedMod
|
|
|
10549
10957
|
}
|
|
10550
10958
|
return true;
|
|
10551
10959
|
}
|
|
10552
|
-
function analyzePrReviewDiscoveryArtifact(text, expectedWorkflowLane, ownedWorkflowLanes = [expectedWorkflowLane], mode) {
|
|
10960
|
+
function analyzePrReviewDiscoveryArtifact(text, expectedWorkflowLane, ownedWorkflowLanes = [expectedWorkflowLane], mode, acceptPartial = false) {
|
|
10553
10961
|
const fallbackFamily = resolvePrReviewRowFamily(expectedWorkflowLane, mode);
|
|
10554
10962
|
const issues = [];
|
|
10555
10963
|
const normalized = normalizeCandidateArtifact(text, fallbackFamily);
|
|
@@ -10583,7 +10991,7 @@ function analyzePrReviewDiscoveryArtifact(text, expectedWorkflowLane, ownedWorkf
|
|
|
10583
10991
|
source: "collect_lane_results",
|
|
10584
10992
|
produced_at: "1970-01-01T00:00:00.000Z"
|
|
10585
10993
|
}, {
|
|
10586
|
-
accept_partial:
|
|
10994
|
+
accept_partial: acceptPartial,
|
|
10587
10995
|
accept_degraded: false,
|
|
10588
10996
|
degraded: false,
|
|
10589
10997
|
row_format_version: 1,
|
|
@@ -10701,7 +11109,7 @@ function validatePrReviewDiscoveryLaneCompletion(input) {
|
|
|
10701
11109
|
const artifact = input.artifact;
|
|
10702
11110
|
const analyses = ownedWorkflowLanes.map((workflowLane) => ({
|
|
10703
11111
|
workflowLane,
|
|
10704
|
-
analysis: analyzePrReviewDiscoveryArtifact(artifact.text, workflowLane, ownedWorkflowLanes, input.expected.mode)
|
|
11112
|
+
analysis: analyzePrReviewDiscoveryArtifact(artifact.text, workflowLane, ownedWorkflowLanes, input.expected.mode, input.result.transcriptIncomplete === true)
|
|
10705
11113
|
}));
|
|
10706
11114
|
const salvagedLanes = [];
|
|
10707
11115
|
const recoveries = [];
|
|
@@ -10782,26 +11190,6 @@ function prReviewDiscoveryArtifactCoversLane(text, expectedWorkflowLane, ownedWo
|
|
|
10782
11190
|
function extractLaneCoverageEvidenceText(text, expectedWorkflowLane, ownedWorkflowLanes = [expectedWorkflowLane], mode) {
|
|
10783
11191
|
return analyzePrReviewDiscoveryArtifact(text, expectedWorkflowLane, ownedWorkflowLanes, mode).evidence;
|
|
10784
11192
|
}
|
|
10785
|
-
var REVIEWER_CLASSIFICATIONS = new Set([
|
|
10786
|
-
"CONFIRMED",
|
|
10787
|
-
"DISPROVED",
|
|
10788
|
-
"UNVERIFIED",
|
|
10789
|
-
"PRE_EXISTING"
|
|
10790
|
-
]);
|
|
10791
|
-
var REVIEWER_EVIDENCE_TYPES = new Set([
|
|
10792
|
-
"STRUCTURALLY_PROVEN",
|
|
10793
|
-
"EXECUTION_PROVEN",
|
|
10794
|
-
"STATIC_TRACE_PROVEN",
|
|
10795
|
-
"PLAUSIBLE_BUT_UNVERIFIED"
|
|
10796
|
-
]);
|
|
10797
|
-
var REVIEW_SEVERITIES = new Set([
|
|
10798
|
-
"CRITICAL",
|
|
10799
|
-
"HIGH",
|
|
10800
|
-
"MEDIUM",
|
|
10801
|
-
"LOW",
|
|
10802
|
-
"INFO",
|
|
10803
|
-
"NONE"
|
|
10804
|
-
]);
|
|
10805
11193
|
var REVIEW_SEVERITY_RANK = new Map([
|
|
10806
11194
|
["NONE", 0],
|
|
10807
11195
|
["INFO", 1],
|
|
@@ -10810,12 +11198,6 @@ var REVIEW_SEVERITY_RANK = new Map([
|
|
|
10810
11198
|
["HIGH", 4],
|
|
10811
11199
|
["CRITICAL", 5]
|
|
10812
11200
|
]);
|
|
10813
|
-
var CRITIC_STATUSES = new Set([
|
|
10814
|
-
"UPHELD",
|
|
10815
|
-
"DOWNGRADED",
|
|
10816
|
-
"DISPROVED",
|
|
10817
|
-
"NEEDS_MORE_EVIDENCE"
|
|
10818
|
-
]);
|
|
10819
11201
|
var FEEDBACK_CLASSIFICATIONS = new Set([
|
|
10820
11202
|
"CONFIRMED",
|
|
10821
11203
|
"PARTIAL",
|
|
@@ -10830,13 +11212,25 @@ var FEEDBACK_NO_CHANGE_CLASSIFICATIONS = new Set([
|
|
|
10830
11212
|
"NEEDS_MORE_EVIDENCE",
|
|
10831
11213
|
"NEEDS_USER_DECISION"
|
|
10832
11214
|
]);
|
|
10833
|
-
function indexVerdictRows(text, marker
|
|
11215
|
+
function indexVerdictRows(text, marker) {
|
|
10834
11216
|
const markerRows = [];
|
|
10835
11217
|
const rowsByItemId = new Map;
|
|
11218
|
+
const recoveries = [];
|
|
10836
11219
|
for (const line of text.split(/\r?\n/)) {
|
|
10837
|
-
const
|
|
10838
|
-
if (
|
|
11220
|
+
const row = parsePrReviewVerdictRow(line, marker === "[REVIEWED]" ? "reviewer" : "critic");
|
|
11221
|
+
if (!row)
|
|
10839
11222
|
continue;
|
|
11223
|
+
const fields = row.fields;
|
|
11224
|
+
if (row.recoveredOverflow) {
|
|
11225
|
+
const recovery = row.overflowClass;
|
|
11226
|
+
const itemId2 = fields[1] ?? "(missing)";
|
|
11227
|
+
recoveries.push({ marker, itemId: itemId2, recovery });
|
|
11228
|
+
warn("PR_REVIEW recovered a legacy verdict row with unescaped pipe overflow", {
|
|
11229
|
+
marker,
|
|
11230
|
+
itemId: itemId2,
|
|
11231
|
+
recovery
|
|
11232
|
+
});
|
|
11233
|
+
}
|
|
10840
11234
|
markerRows.push(fields);
|
|
10841
11235
|
const itemId = fields[1] ?? "";
|
|
10842
11236
|
const rows = rowsByItemId.get(itemId);
|
|
@@ -10845,19 +11239,11 @@ function indexVerdictRows(text, marker, fieldCount) {
|
|
|
10845
11239
|
else
|
|
10846
11240
|
rowsByItemId.set(itemId, [fields]);
|
|
10847
11241
|
}
|
|
10848
|
-
return { markerRows, rowsByItemId };
|
|
11242
|
+
return { markerRows, rowsByItemId, recoveries };
|
|
10849
11243
|
}
|
|
10850
11244
|
function validateReviewerVerdictFields(fields) {
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
const introduced = fields[5].replace(/^introduced_by_pr\s*:\s*/i, "").toUpperCase();
|
|
10854
|
-
if (!REVIEWER_CLASSIFICATIONS.has(fields[2]) || !REVIEWER_EVIDENCE_TYPES.has(fields[3]) || !REVIEW_SEVERITIES.has(fields[4]) || !["YES", "NO", "UNKNOWN"].includes(introduced))
|
|
10855
|
-
return null;
|
|
10856
|
-
if (fields[2] === "DISPROVED" && fields[4] !== "NONE")
|
|
10857
|
-
return null;
|
|
10858
|
-
if (fields[7].length < 8 || fields[8].length < 5 || fields[9].length < 3)
|
|
10859
|
-
return null;
|
|
10860
|
-
return fields;
|
|
11245
|
+
const parsed = PrReviewReviewerVerdictFieldsSchema.safeParse(fields);
|
|
11246
|
+
return parsed.success ? [...parsed.data] : null;
|
|
10861
11247
|
}
|
|
10862
11248
|
function reviewerVerdictRowDigest(fields) {
|
|
10863
11249
|
return createHash5("sha256").update(fields.join("\x00")).digest("hex");
|
|
@@ -10868,8 +11254,10 @@ function parseLaneItemVerdicts(text, itemIds, phase, reviewerClaims) {
|
|
|
10868
11254
|
function parsePrReviewVerdictRows(text, itemIds, phase, reviewerClaims) {
|
|
10869
11255
|
const parsed = new Map;
|
|
10870
11256
|
const marker = phase === "reviewer" ? "[REVIEWED]" : "[CRITIC]";
|
|
10871
|
-
const { markerRows, rowsByItemId } = indexVerdictRows(text, marker
|
|
11257
|
+
const { markerRows, rowsByItemId, recoveries } = indexVerdictRows(text, marker);
|
|
10872
11258
|
for (const itemId of itemIds) {
|
|
11259
|
+
if (itemId === PR_REVIEW_DISCARDED_EXAMPLE_ITEM_ID)
|
|
11260
|
+
continue;
|
|
10873
11261
|
if (phase === "reviewer") {
|
|
10874
11262
|
const rows2 = rowsByItemId.get(itemId);
|
|
10875
11263
|
const fields = rows2?.length === 1 ? validateReviewerVerdictFields(rows2[0]) : null;
|
|
@@ -10891,12 +11279,12 @@ function parsePrReviewVerdictRows(text, itemIds, phase, reviewerClaims) {
|
|
|
10891
11279
|
severity: verdict.severity
|
|
10892
11280
|
});
|
|
10893
11281
|
}
|
|
10894
|
-
return { markerRows, parsed };
|
|
11282
|
+
return { markerRows, parsed, recoveries };
|
|
10895
11283
|
}
|
|
10896
11284
|
function analyzePrReviewVerdictRowContract(text, itemIds, phase, reviewerClaims) {
|
|
10897
11285
|
const marker = phase === "reviewer" ? "[REVIEWED]" : "[CRITIC]";
|
|
10898
11286
|
const assigned = new Set(itemIds);
|
|
10899
|
-
const { markerRows, parsed } = parsePrReviewVerdictRows(text, itemIds, phase, reviewerClaims);
|
|
11287
|
+
const { markerRows, parsed, recoveries } = parsePrReviewVerdictRows(text, itemIds, phase, reviewerClaims);
|
|
10900
11288
|
const observedIds = markerRows.map((fields) => fields[1] || "(missing)");
|
|
10901
11289
|
const unexpectedIds = [
|
|
10902
11290
|
...new Set(observedIds.filter((itemId) => !assigned.has(itemId)))
|
|
@@ -10910,7 +11298,8 @@ function analyzePrReviewVerdictRowContract(text, itemIds, phase, reviewerClaims)
|
|
|
10910
11298
|
observedIds,
|
|
10911
11299
|
invalidOrMissingIds,
|
|
10912
11300
|
unexpectedIds
|
|
10913
|
-
})
|
|
11301
|
+
}),
|
|
11302
|
+
recoveries
|
|
10914
11303
|
};
|
|
10915
11304
|
}
|
|
10916
11305
|
function verdictRowIdsMatchExactly(markerRows, itemIds) {
|
|
@@ -10935,35 +11324,27 @@ function verdictRowsContainOnlyAssignedIds(markerRows, itemIds) {
|
|
|
10935
11324
|
return markerRows.every((fields) => assigned.has(fields[1] ?? ""));
|
|
10936
11325
|
}
|
|
10937
11326
|
function parseCriticVerdict(text, itemId, reviewerSeverity) {
|
|
10938
|
-
const rows = indexVerdictRows(text, "[CRITIC]"
|
|
11327
|
+
const rows = indexVerdictRows(text, "[CRITIC]").rowsByItemId.get(itemId);
|
|
10939
11328
|
if (!rows || rows.length !== 1)
|
|
10940
11329
|
return null;
|
|
10941
11330
|
return validateCriticVerdictFields(rows[0], reviewerSeverity);
|
|
10942
11331
|
}
|
|
10943
11332
|
function validateCriticVerdictFields(fields, reviewerSeverity) {
|
|
10944
|
-
|
|
10945
|
-
|
|
10946
|
-
if (fields[2] === "NEEDS_MORE_EVIDENCE")
|
|
10947
|
-
return null;
|
|
10948
|
-
if (fields[2] === "DISPROVED" && fields[3] !== "NONE")
|
|
10949
|
-
return null;
|
|
10950
|
-
if (fields[2] === "UPHELD" && !["CRITICAL", "HIGH", "MEDIUM"].includes(fields[3]))
|
|
10951
|
-
return null;
|
|
10952
|
-
if (fields[2] === "DOWNGRADED" && fields[3] === "CRITICAL")
|
|
11333
|
+
const parsed = PrReviewCriticVerdictFieldsSchema.safeParse(fields);
|
|
11334
|
+
if (!parsed.success)
|
|
10953
11335
|
return null;
|
|
11336
|
+
const verdict = parsed.data;
|
|
10954
11337
|
if (reviewerSeverity) {
|
|
10955
11338
|
const reviewerRank = REVIEW_SEVERITY_RANK.get(reviewerSeverity);
|
|
10956
|
-
const criticRank = REVIEW_SEVERITY_RANK.get(
|
|
11339
|
+
const criticRank = REVIEW_SEVERITY_RANK.get(verdict[3]);
|
|
10957
11340
|
if (reviewerRank === undefined || criticRank === undefined)
|
|
10958
11341
|
return null;
|
|
10959
|
-
if (
|
|
11342
|
+
if (verdict[2] === "UPHELD" && criticRank !== reviewerRank)
|
|
10960
11343
|
return null;
|
|
10961
|
-
if (
|
|
11344
|
+
if (verdict[2] === "DOWNGRADED" && criticRank >= reviewerRank)
|
|
10962
11345
|
return null;
|
|
10963
11346
|
}
|
|
10964
|
-
|
|
10965
|
-
return null;
|
|
10966
|
-
return { status: fields[2], severity: fields[3] };
|
|
11347
|
+
return { status: verdict[2], severity: verdict[3] };
|
|
10967
11348
|
}
|
|
10968
11349
|
function artifactHasExactPositiveVerdictRow(text, marker, itemId, positiveVerdict) {
|
|
10969
11350
|
const rows = text.split(/\r?\n/).map((line) => pipeFieldsCapped(line, 4)).filter((fields) => fields[0] === marker && fields[1] === itemId);
|
|
@@ -17362,7 +17743,7 @@ function buildPromotedExternalInputFromSkill(directory, skillSlug, usage, ageDay
|
|
|
17362
17743
|
|
|
17363
17744
|
// src/services/skill-reviser.ts
|
|
17364
17745
|
init_logger();
|
|
17365
|
-
import { readFile as readFile9, rename as rename3, writeFile as
|
|
17746
|
+
import { readFile as readFile9, rename as rename3, writeFile as writeFile5 } from "fs/promises";
|
|
17366
17747
|
var REVISION_VIOLATION_THRESHOLD = 0.15;
|
|
17367
17748
|
var MAX_REVISION_CALLS_PER_PHASE = 3;
|
|
17368
17749
|
var DEFAULT_MAX_CALLS = 10;
|
|
@@ -17505,7 +17886,7 @@ async function reviseSkill(params) {
|
|
|
17505
17886
|
};
|
|
17506
17887
|
}
|
|
17507
17888
|
const tmpPath = `${params.skillPath}.tmp-${process.pid}-${Date.now()}`;
|
|
17508
|
-
await
|
|
17889
|
+
await writeFile5(tmpPath, revised, "utf-8");
|
|
17509
17890
|
await rename3(tmpPath, params.skillPath);
|
|
17510
17891
|
const newVersion = params.currentVersion + 1;
|
|
17511
17892
|
const entry = {
|
|
@@ -17582,7 +17963,7 @@ async function reviseSkill(params) {
|
|
|
17582
17963
|
};
|
|
17583
17964
|
}
|
|
17584
17965
|
const tmpPath = `${params.skillPath}.tmp-${process.pid}-${Date.now()}`;
|
|
17585
|
-
await
|
|
17966
|
+
await writeFile5(tmpPath, `${finalOutput}
|
|
17586
17967
|
`, "utf-8");
|
|
17587
17968
|
await rename3(tmpPath, params.skillPath);
|
|
17588
17969
|
const newVersion = expectedVersion;
|
|
@@ -18001,7 +18382,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
|
|
|
18001
18382
|
};
|
|
18002
18383
|
}
|
|
18003
18384
|
async function sweepActiveNearDuplicates(directory, options = {}) {
|
|
18004
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
18385
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-xn7h24x4.js");
|
|
18005
18386
|
const { config } = loadPluginConfigWithMeta2(directory);
|
|
18006
18387
|
const sweepConfig = config.learning?.dedup_sweep;
|
|
18007
18388
|
if (sweepConfig?.enabled === false)
|
|
@@ -19119,7 +19500,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
19119
19500
|
}
|
|
19120
19501
|
if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
|
|
19121
19502
|
try {
|
|
19122
|
-
const skillModule = await import("./skill-generator-
|
|
19503
|
+
const skillModule = await import("./skill-generator-q6m110d5.js");
|
|
19123
19504
|
for (const cand of skillCandidates) {
|
|
19124
19505
|
if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
|
|
19125
19506
|
continue;
|
|
@@ -19591,7 +19972,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
|
|
|
19591
19972
|
} catch {}
|
|
19592
19973
|
}
|
|
19593
19974
|
if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
|
|
19594
|
-
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-
|
|
19975
|
+
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-rfw35yt1.js");
|
|
19595
19976
|
for (const { id } of contradictedEntries) {
|
|
19596
19977
|
try {
|
|
19597
19978
|
await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
|
|
@@ -20410,7 +20791,7 @@ async function runCuratorPostMortem(directory, options = {}) {
|
|
|
20410
20791
|
warnings.push("Failed to collect knowledge summary.");
|
|
20411
20792
|
}
|
|
20412
20793
|
try {
|
|
20413
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
20794
|
+
const { getScanStatus } = await import("./scan-cursor-x1ma7edk.js");
|
|
20414
20795
|
const scanStatus = await getScanStatus(directory);
|
|
20415
20796
|
if (scanStatus.remaining_estimate > 0) {
|
|
20416
20797
|
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.`);
|
|
@@ -20582,9 +20963,9 @@ var _internals26 = {
|
|
|
20582
20963
|
verifyPostMortemKnowledgeActions,
|
|
20583
20964
|
repairPostMortemActions,
|
|
20584
20965
|
loadDefaultKnowledgeConfig: async (directory) => {
|
|
20585
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
20966
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-g5ggmb47.js");
|
|
20586
20967
|
try {
|
|
20587
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
20968
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-xn7h24x4.js");
|
|
20588
20969
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
20589
20970
|
return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
20590
20971
|
} catch {
|
|
@@ -20592,11 +20973,11 @@ var _internals26 = {
|
|
|
20592
20973
|
}
|
|
20593
20974
|
},
|
|
20594
20975
|
applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
|
|
20595
|
-
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-
|
|
20976
|
+
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-wvm7qbkk.js");
|
|
20596
20977
|
return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
|
|
20597
20978
|
},
|
|
20598
20979
|
checkHivePromotions: async (entries, knowledgeConfig, directory) => {
|
|
20599
|
-
const { checkHivePromotions } = await import("./hive-promoter-
|
|
20980
|
+
const { checkHivePromotions } = await import("./hive-promoter-zemwxxw1.js");
|
|
20600
20981
|
return checkHivePromotions(entries, knowledgeConfig, directory);
|
|
20601
20982
|
},
|
|
20602
20983
|
applyProposalTriage: async (directory, triage) => {
|
|
@@ -20605,7 +20986,7 @@ var _internals26 = {
|
|
|
20605
20986
|
activateProposal,
|
|
20606
20987
|
listSkills: listSkills2,
|
|
20607
20988
|
sanitizeSlug
|
|
20608
|
-
} = await import("./skill-generator-
|
|
20989
|
+
} = await import("./skill-generator-q6m110d5.js");
|
|
20609
20990
|
const result = {
|
|
20610
20991
|
approved: [],
|
|
20611
20992
|
rejected: [],
|
|
@@ -21707,7 +22088,7 @@ import {
|
|
|
21707
22088
|
mkdir as mkdir10,
|
|
21708
22089
|
readFile as readFile11,
|
|
21709
22090
|
realpath as realpath3,
|
|
21710
|
-
writeFile as
|
|
22091
|
+
writeFile as writeFile7
|
|
21711
22092
|
} from "fs/promises";
|
|
21712
22093
|
import * as path28 from "path";
|
|
21713
22094
|
|
|
@@ -21719,7 +22100,7 @@ import {
|
|
|
21719
22100
|
rename as rename4,
|
|
21720
22101
|
stat as stat3,
|
|
21721
22102
|
unlink as unlink3,
|
|
21722
|
-
writeFile as
|
|
22103
|
+
writeFile as writeFile6
|
|
21723
22104
|
} from "fs/promises";
|
|
21724
22105
|
import * as path27 from "path";
|
|
21725
22106
|
var SYNONYM_MAP_FILENAME = "synonym-map.json";
|
|
@@ -21879,7 +22260,7 @@ async function writeSynonymMapAtomic(filePath, map) {
|
|
|
21879
22260
|
await mkdir9(path27.dirname(filePath), { recursive: true });
|
|
21880
22261
|
const tmp = `${filePath}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
21881
22262
|
try {
|
|
21882
|
-
await
|
|
22263
|
+
await writeFile6(tmp, JSON.stringify(map, null, 2), "utf-8");
|
|
21883
22264
|
await rename4(tmp, filePath);
|
|
21884
22265
|
} finally {
|
|
21885
22266
|
try {
|
|
@@ -21941,9 +22322,9 @@ function hashContent(content) {
|
|
|
21941
22322
|
return createHash10("sha1").update(content).digest("hex");
|
|
21942
22323
|
}
|
|
21943
22324
|
async function loadConfigForPolicyCurator(directory) {
|
|
21944
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
22325
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-g5ggmb47.js");
|
|
21945
22326
|
try {
|
|
21946
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
22327
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-xn7h24x4.js");
|
|
21947
22328
|
const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
|
|
21948
22329
|
return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
|
|
21949
22330
|
} catch {
|
|
@@ -22469,7 +22850,7 @@ async function consumeInsightCandidates(directory, batchLimit = MESO_INSIGHT_BAT
|
|
|
22469
22850
|
const body = data.length === 0 ? "" : `${data.map((c) => JSON.stringify(c)).join(`
|
|
22470
22851
|
`)}
|
|
22471
22852
|
`;
|
|
22472
|
-
await
|
|
22853
|
+
await writeFile7(p, body, "utf-8");
|
|
22473
22854
|
}, (all) => {
|
|
22474
22855
|
if (all.length === 0)
|
|
22475
22856
|
return null;
|
|
@@ -24327,7 +24708,7 @@ import {
|
|
|
24327
24708
|
readFile as readFile12,
|
|
24328
24709
|
rename as rename5,
|
|
24329
24710
|
truncate,
|
|
24330
|
-
writeFile as
|
|
24711
|
+
writeFile as writeFile8
|
|
24331
24712
|
} from "fs/promises";
|
|
24332
24713
|
import * as path31 from "path";
|
|
24333
24714
|
|
|
@@ -25779,7 +26160,7 @@ async function writeJsonlAtomic(filePath, values) {
|
|
|
25779
26160
|
const content = values.map((value) => JSON.stringify(value)).join(`
|
|
25780
26161
|
`) + (values.length > 0 ? `
|
|
25781
26162
|
` : "");
|
|
25782
|
-
await
|
|
26163
|
+
await writeFile8(tmp, content, "utf-8");
|
|
25783
26164
|
await rename5(tmp, filePath);
|
|
25784
26165
|
}
|
|
25785
26166
|
async function repairIncompleteJsonlTail(filePath) {
|
|
@@ -25804,7 +26185,7 @@ import {
|
|
|
25804
26185
|
existsSync as existsSync19,
|
|
25805
26186
|
mkdirSync as mkdirSync11,
|
|
25806
26187
|
readFileSync as readFileSync15,
|
|
25807
|
-
statSync as
|
|
26188
|
+
statSync as statSync10,
|
|
25808
26189
|
writeFileSync as writeFileSync9
|
|
25809
26190
|
} from "fs";
|
|
25810
26191
|
import { createRequire as createRequire3 } from "module";
|
|
@@ -26166,7 +26547,7 @@ function resolveRerankerCacheDir() {
|
|
|
26166
26547
|
|
|
26167
26548
|
// src/memory/jsonl-migration.ts
|
|
26168
26549
|
import { existsSync as existsSync18, renameSync as renameSync7, unlinkSync as unlinkSync6 } from "fs";
|
|
26169
|
-
import { copyFile, mkdir as mkdir12, readFile as readFile13, stat as stat4, writeFile as
|
|
26550
|
+
import { copyFile, mkdir as mkdir12, readFile as readFile13, stat as stat4, writeFile as writeFile9 } from "fs/promises";
|
|
26170
26551
|
import * as path34 from "path";
|
|
26171
26552
|
var LEGACY_JSONL_MIGRATION_VERSION = 2;
|
|
26172
26553
|
var LEGACY_JSONL_MIGRATION_NAME = "legacy_jsonl_import_complete";
|
|
@@ -26232,7 +26613,7 @@ async function writeJsonlExport(rootDirectory, config, memories, proposals, outc
|
|
|
26232
26613
|
const outcomesPath = path34.join(exportDir, "outcome-events.jsonl");
|
|
26233
26614
|
const memoriesTempPath = path34.join(path34.dirname(memoriesPath), `${path34.basename(memoriesPath)}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
|
|
26234
26615
|
try {
|
|
26235
|
-
await
|
|
26616
|
+
await writeFile9(memoriesTempPath, toJsonl(memories), "utf-8");
|
|
26236
26617
|
renameSync7(memoriesTempPath, memoriesPath);
|
|
26237
26618
|
} catch (err) {
|
|
26238
26619
|
try {
|
|
@@ -26242,7 +26623,7 @@ async function writeJsonlExport(rootDirectory, config, memories, proposals, outc
|
|
|
26242
26623
|
}
|
|
26243
26624
|
const proposalsTempPath = path34.join(path34.dirname(proposalsPath), `${path34.basename(proposalsPath)}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
|
|
26244
26625
|
try {
|
|
26245
|
-
await
|
|
26626
|
+
await writeFile9(proposalsTempPath, toJsonl(proposals), "utf-8");
|
|
26246
26627
|
renameSync7(proposalsTempPath, proposalsPath);
|
|
26247
26628
|
} catch (err) {
|
|
26248
26629
|
try {
|
|
@@ -26252,7 +26633,7 @@ async function writeJsonlExport(rootDirectory, config, memories, proposals, outc
|
|
|
26252
26633
|
}
|
|
26253
26634
|
const outcomesTempPath = path34.join(path34.dirname(outcomesPath), `${path34.basename(outcomesPath)}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
|
|
26254
26635
|
try {
|
|
26255
|
-
await
|
|
26636
|
+
await writeFile9(outcomesTempPath, toJsonl(outcomeEvents), "utf-8");
|
|
26256
26637
|
renameSync7(outcomesTempPath, outcomesPath);
|
|
26257
26638
|
} catch (err) {
|
|
26258
26639
|
try {
|
|
@@ -26267,7 +26648,7 @@ async function writeMigrationReport(rootDirectory, report, config = {}) {
|
|
|
26267
26648
|
await mkdir12(path34.dirname(reportPath), { recursive: true });
|
|
26268
26649
|
const reportTempPath = path34.join(path34.dirname(reportPath), `${path34.basename(reportPath)}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
|
|
26269
26650
|
try {
|
|
26270
|
-
await
|
|
26651
|
+
await writeFile9(reportTempPath, `${JSON.stringify(report, null, 2)}
|
|
26271
26652
|
`, "utf-8");
|
|
26272
26653
|
renameSync7(reportTempPath, reportPath);
|
|
26273
26654
|
} catch (err) {
|
|
@@ -27488,13 +27869,13 @@ class SQLiteMemoryProvider {
|
|
|
27488
27869
|
}
|
|
27489
27870
|
try {
|
|
27490
27871
|
const wal = `${dbPath}-wal`;
|
|
27491
|
-
const st =
|
|
27872
|
+
const st = statSync10(wal);
|
|
27492
27873
|
if (st.size > 0)
|
|
27493
27874
|
walPath2 = wal;
|
|
27494
27875
|
} catch {}
|
|
27495
27876
|
try {
|
|
27496
27877
|
const shm = `${dbPath}-shm`;
|
|
27497
|
-
const st =
|
|
27878
|
+
const st = statSync10(shm);
|
|
27498
27879
|
if (st.size > 0)
|
|
27499
27880
|
shmPath = shm;
|
|
27500
27881
|
} catch {}
|
|
@@ -28965,7 +29346,7 @@ init_logger();
|
|
|
28965
29346
|
import * as path38 from "path";
|
|
28966
29347
|
|
|
28967
29348
|
// src/memory/memory-link.ts
|
|
28968
|
-
import { existsSync as existsSync20, mkdirSync as mkdirSync12, readFileSync as readFileSync16, rmSync as rmSync2, statSync as
|
|
29349
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync12, readFileSync as readFileSync16, rmSync as rmSync2, statSync as statSync11 } from "fs";
|
|
28969
29350
|
import * as path37 from "path";
|
|
28970
29351
|
init_logger();
|
|
28971
29352
|
var MEMORY_LINK_POINTER_FILENAME = "memory-link.json";
|
|
@@ -29025,7 +29406,7 @@ var _resolutionCache = new Map;
|
|
|
29025
29406
|
function pointerStatFingerprint(directory) {
|
|
29026
29407
|
const pointerPath = resolveMemoryLinkPointerPath(directory);
|
|
29027
29408
|
try {
|
|
29028
|
-
const st =
|
|
29409
|
+
const st = statSync11(pointerPath);
|
|
29029
29410
|
return `${st.mtimeMs}:${st.ctimeMs}:${st.size}`;
|
|
29030
29411
|
} catch {
|
|
29031
29412
|
return null;
|
|
@@ -30272,7 +30653,7 @@ import * as path41 from "path";
|
|
|
30272
30653
|
init_logger();
|
|
30273
30654
|
|
|
30274
30655
|
// src/services/trajectory-cluster.ts
|
|
30275
|
-
import { mkdir as mkdir13, writeFile as
|
|
30656
|
+
import { mkdir as mkdir13, writeFile as writeFile10 } from "fs/promises";
|
|
30276
30657
|
import * as path40 from "path";
|
|
30277
30658
|
init_logger();
|
|
30278
30659
|
var MACRO_TRAJECTORY_WINDOW = 200;
|
|
@@ -30450,7 +30831,7 @@ async function writeMotifProposals(directory, opts = {}) {
|
|
|
30450
30831
|
continue;
|
|
30451
30832
|
const slug = `motif-${slugify(motif.signature)}`;
|
|
30452
30833
|
const filePath = path40.join(proposalsDir, `${slug}.md`);
|
|
30453
|
-
await
|
|
30834
|
+
await writeFile10(filePath, buildMotifProposal(motif, {
|
|
30454
30835
|
fingerprint: decision.fingerprint,
|
|
30455
30836
|
producedAt
|
|
30456
30837
|
}), "utf-8");
|
|
@@ -30640,7 +31021,7 @@ async function writeSuccessMotifProposals(directory, opts = {}) {
|
|
|
30640
31021
|
continue;
|
|
30641
31022
|
const slug = workflowSlug(motif.signature);
|
|
30642
31023
|
const filePath = path40.join(proposalsDir, `${slug}.md`);
|
|
30643
|
-
await
|
|
31024
|
+
await writeFile10(filePath, buildWorkflowProposal(motif, {
|
|
30644
31025
|
fingerprint: decision.fingerprint,
|
|
30645
31026
|
producedAt
|
|
30646
31027
|
}), "utf-8");
|
|
@@ -33139,7 +33520,7 @@ async function runFinalizeStage(ctx) {
|
|
|
33139
33520
|
}
|
|
33140
33521
|
}
|
|
33141
33522
|
try {
|
|
33142
|
-
const { CuratorConfigSchema: CCS } = await import("./schema-
|
|
33523
|
+
const { CuratorConfigSchema: CCS } = await import("./schema-g5ggmb47.js");
|
|
33143
33524
|
const { config: pmLoadedConfig } = _internals41.loadPluginConfigWithMeta(ctx.directory);
|
|
33144
33525
|
const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
|
|
33145
33526
|
if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
|
|
@@ -34621,7 +35002,7 @@ import { promisify as promisify2 } from "util";
|
|
|
34621
35002
|
init_zod();
|
|
34622
35003
|
import * as child_process3 from "child_process";
|
|
34623
35004
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
34624
|
-
import { readdir as
|
|
35005
|
+
import { readdir as readdir4, readFile as readFile16, stat as stat5 } from "fs/promises";
|
|
34625
35006
|
import * as path49 from "path";
|
|
34626
35007
|
import { promisify } from "util";
|
|
34627
35008
|
function getExecFileAsync() {
|
|
@@ -34724,7 +35105,7 @@ async function scanSourceFiles(dir) {
|
|
|
34724
35105
|
const results = [];
|
|
34725
35106
|
const skipDirs = new Set(["node_modules", ".swarm", "dist", "build"]);
|
|
34726
35107
|
try {
|
|
34727
|
-
const entries = await
|
|
35108
|
+
const entries = await readdir4(dir, { withFileTypes: true });
|
|
34728
35109
|
for (const entry of entries) {
|
|
34729
35110
|
const fullPath = path49.join(dir, entry.name);
|
|
34730
35111
|
if (entry.isDirectory()) {
|
|
@@ -35332,9 +35713,9 @@ var _internals45 = {
|
|
|
35332
35713
|
loadPluginConfigWithMeta,
|
|
35333
35714
|
loadCuratorDeps: async () => {
|
|
35334
35715
|
const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
|
|
35335
|
-
import("./schema-
|
|
35336
|
-
import("./curator-
|
|
35337
|
-
import("./curator-llm-factory-
|
|
35716
|
+
import("./schema-g5ggmb47.js"),
|
|
35717
|
+
import("./curator-wvm7qbkk.js"),
|
|
35718
|
+
import("./curator-llm-factory-6n47j5qn.js")
|
|
35338
35719
|
]);
|
|
35339
35720
|
return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
|
|
35340
35721
|
}
|
|
@@ -35834,7 +36215,7 @@ ${USAGE8}`;
|
|
|
35834
36215
|
// src/services/diagnose-service.ts
|
|
35835
36216
|
init_package();
|
|
35836
36217
|
import * as child_process5 from "child_process";
|
|
35837
|
-
import { existsSync as existsSync32, readdirSync as readdirSync6, readFileSync as readFileSync22, statSync as
|
|
36218
|
+
import { existsSync as existsSync32, readdirSync as readdirSync6, readFileSync as readFileSync22, statSync as statSync13 } from "fs";
|
|
35838
36219
|
import * as path53 from "path";
|
|
35839
36220
|
import { fileURLToPath } from "url";
|
|
35840
36221
|
|
|
@@ -36324,7 +36705,7 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
36324
36705
|
let scanCompleted = false;
|
|
36325
36706
|
let scanRemaining = 0;
|
|
36326
36707
|
try {
|
|
36327
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
36708
|
+
const { getScanStatus } = await import("./scan-cursor-x1ma7edk.js");
|
|
36328
36709
|
const status = await getScanStatus(directory);
|
|
36329
36710
|
scanGeneration = status.generation;
|
|
36330
36711
|
scanCompleted = status.completed;
|
|
@@ -36332,19 +36713,19 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
36332
36713
|
} catch {}
|
|
36333
36714
|
let configMatch = null;
|
|
36334
36715
|
try {
|
|
36335
|
-
const { isLinked: isLinked2 } = await import("./knowledge-link-
|
|
36716
|
+
const { isLinked: isLinked2 } = await import("./knowledge-link-5dctq0ax.js");
|
|
36336
36717
|
if (isLinked2(directory)) {
|
|
36337
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
36718
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-g5ggmb47.js");
|
|
36338
36719
|
let config;
|
|
36339
36720
|
try {
|
|
36340
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
36721
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-xn7h24x4.js");
|
|
36341
36722
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
36342
36723
|
config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
36343
36724
|
} catch {
|
|
36344
36725
|
config = KnowledgeConfigSchema2.parse({});
|
|
36345
36726
|
}
|
|
36346
36727
|
const { cohortConfigFingerprint: cohortConfigFingerprint2 } = await import("./config-fingerprint-v22xh5a2.js");
|
|
36347
|
-
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-
|
|
36728
|
+
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-hkdghd3a.js");
|
|
36348
36729
|
const currentFp = cohortConfigFingerprint2(buildConfigFingerprintInput2(config));
|
|
36349
36730
|
const cohortFp = await readCohortConfigFingerprint(directory);
|
|
36350
36731
|
configMatch = cohortFp === null ? null : currentFp === cohortFp;
|
|
@@ -36751,7 +37132,7 @@ async function checkConfigBackups(directory) {
|
|
|
36751
37132
|
}
|
|
36752
37133
|
async function checkGitRepository(directory) {
|
|
36753
37134
|
try {
|
|
36754
|
-
if (!existsSync32(directory) || !
|
|
37135
|
+
if (!existsSync32(directory) || !statSync13(directory).isDirectory()) {
|
|
36755
37136
|
return {
|
|
36756
37137
|
name: "Git Repository",
|
|
36757
37138
|
status: "\u274C",
|
|
@@ -37648,7 +38029,7 @@ async function handleDoctorCommand(directory, args) {
|
|
|
37648
38029
|
const result = runConfigDoctor(config, directory);
|
|
37649
38030
|
let output;
|
|
37650
38031
|
if (enableAutoFix && result.hasAutoFixableIssues) {
|
|
37651
|
-
const { runConfigDoctorWithFixes } = await import("./config-doctor-
|
|
38032
|
+
const { runConfigDoctorWithFixes } = await import("./config-doctor-6danhdcy.js");
|
|
37652
38033
|
const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
|
|
37653
38034
|
applyLossy: true
|
|
37654
38035
|
});
|
|
@@ -38588,7 +38969,7 @@ async function handleEvidenceCommand(directory, args) {
|
|
|
38588
38969
|
return formatTaskEvidenceMarkdown(evidenceData);
|
|
38589
38970
|
}
|
|
38590
38971
|
async function handleEvidenceSummaryCommand(directory) {
|
|
38591
|
-
const { buildEvidenceSummary } = await import("./evidence-summary-service-
|
|
38972
|
+
const { buildEvidenceSummary } = await import("./evidence-summary-service-0xwrkmf9.js");
|
|
38592
38973
|
const artifact = await buildEvidenceSummary(directory);
|
|
38593
38974
|
if (!artifact) {
|
|
38594
38975
|
return "No plan found. Run `/swarm plan` to check plan status.";
|
|
@@ -44777,12 +45158,12 @@ import {
|
|
|
44777
45158
|
chmod,
|
|
44778
45159
|
copyFile as copyFile2,
|
|
44779
45160
|
mkdir as mkdir16,
|
|
44780
|
-
readdir as
|
|
45161
|
+
readdir as readdir5,
|
|
44781
45162
|
readFile as readFile18,
|
|
44782
45163
|
realpath as realpath4,
|
|
44783
45164
|
rm as rm2,
|
|
44784
45165
|
stat as stat6,
|
|
44785
|
-
writeFile as
|
|
45166
|
+
writeFile as writeFile11
|
|
44786
45167
|
} from "fs/promises";
|
|
44787
45168
|
import * as path66 from "path";
|
|
44788
45169
|
var HIVE_QUARANTINE_TOKEN_TTL_MS = 15 * 60 * 1000;
|
|
@@ -45574,11 +45955,11 @@ function emitMaintenanceTelemetry(payload) {
|
|
|
45574
45955
|
var _internals60 = {
|
|
45575
45956
|
emit,
|
|
45576
45957
|
readFile: readFile18,
|
|
45577
|
-
writeFile:
|
|
45958
|
+
writeFile: writeFile11,
|
|
45578
45959
|
copyFile: copyFile2,
|
|
45579
45960
|
mkdir: mkdir16,
|
|
45580
45961
|
stat: stat6,
|
|
45581
|
-
readdir:
|
|
45962
|
+
readdir: readdir5,
|
|
45582
45963
|
resolveHiveDataDir,
|
|
45583
45964
|
resolveHiveKnowledgePath,
|
|
45584
45965
|
transactHiveStore,
|
|
@@ -45898,7 +46279,7 @@ init_schema();
|
|
|
45898
46279
|
init_logger();
|
|
45899
46280
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
45900
46281
|
import { existsSync as existsSync41, readFileSync as readFileSync32 } from "fs";
|
|
45901
|
-
import { mkdir as mkdir17, readFile as readFile19, writeFile as
|
|
46282
|
+
import { mkdir as mkdir17, readFile as readFile19, writeFile as writeFile12 } from "fs/promises";
|
|
45902
46283
|
import * as os9 from "os";
|
|
45903
46284
|
import * as path68 from "path";
|
|
45904
46285
|
init_knowledge_types();
|
|
@@ -45966,7 +46347,7 @@ var _internals62 = {
|
|
|
45966
46347
|
readFileSync: readFileSync32,
|
|
45967
46348
|
readFile: readFile19,
|
|
45968
46349
|
mkdir: mkdir17,
|
|
45969
|
-
writeFile:
|
|
46350
|
+
writeFile: writeFile12
|
|
45970
46351
|
};
|
|
45971
46352
|
async function migrateContextToKnowledge(directory, config) {
|
|
45972
46353
|
const sentinelPath = path68.join(directory, ".swarm", ".knowledge-migrated");
|
|
@@ -46779,7 +47160,7 @@ var _internals63 = {
|
|
|
46779
47160
|
};
|
|
46780
47161
|
|
|
46781
47162
|
// src/commands/link.ts
|
|
46782
|
-
import { mkdir as mkdir19, writeFile as
|
|
47163
|
+
import { mkdir as mkdir19, writeFile as writeFile13 } from "fs/promises";
|
|
46783
47164
|
import * as path70 from "path";
|
|
46784
47165
|
init_schema();
|
|
46785
47166
|
|
|
@@ -47239,7 +47620,7 @@ ${formatStatus(directory)}`;
|
|
|
47239
47620
|
const config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
|
|
47240
47621
|
const fingerprint = cohortConfigFingerprint(buildConfigFingerprintInput(config));
|
|
47241
47622
|
await mkdir19(linkDir, { recursive: true });
|
|
47242
|
-
await
|
|
47623
|
+
await writeFile13(path70.join(linkDir, "cohort-config.json"), JSON.stringify({ fingerprint, updated_at: new Date().toISOString() }, null, 2), "utf-8");
|
|
47243
47624
|
} catch {}
|
|
47244
47625
|
const relinkNote = existing ? `
|
|
47245
47626
|
(Re-linked from previous link "${existing.linkId}".)` : "";
|
|
@@ -47265,7 +47646,7 @@ var MIN_MAX_CYCLES = 1;
|
|
|
47265
47646
|
var MAX_MAX_CYCLES = 5;
|
|
47266
47647
|
async function readLatestLoopState(directory) {
|
|
47267
47648
|
try {
|
|
47268
|
-
const { readdirSync: readdirSync9, statSync:
|
|
47649
|
+
const { readdirSync: readdirSync9, statSync: statSync17, readFileSync: readFileSync34 } = await import("fs");
|
|
47269
47650
|
const loopDir = `${directory}/.swarm/loop`;
|
|
47270
47651
|
let latestMtime = 0;
|
|
47271
47652
|
let latestPath = null;
|
|
@@ -47276,7 +47657,7 @@ async function readLatestLoopState(directory) {
|
|
|
47276
47657
|
continue;
|
|
47277
47658
|
const statePath = `${loopDir}/${entry.name}/state.json`;
|
|
47278
47659
|
try {
|
|
47279
|
-
const mtime =
|
|
47660
|
+
const mtime = statSync17(statePath).mtimeMs;
|
|
47280
47661
|
if (mtime > latestMtime) {
|
|
47281
47662
|
latestMtime = mtime;
|
|
47282
47663
|
latestPath = statePath;
|
|
@@ -47905,7 +48286,7 @@ import {
|
|
|
47905
48286
|
openSync as openSync11,
|
|
47906
48287
|
readSync as readSync7,
|
|
47907
48288
|
realpathSync as realpathSync8,
|
|
47908
|
-
statSync as
|
|
48289
|
+
statSync as statSync18
|
|
47909
48290
|
} from "fs";
|
|
47910
48291
|
var import_proper_lockfile8 = __toESM(require_proper_lockfile(), 1);
|
|
47911
48292
|
|
|
@@ -52626,7 +53007,7 @@ function truncate2(value, maxLength) {
|
|
|
52626
53007
|
}
|
|
52627
53008
|
|
|
52628
53009
|
// src/commands/memory-link.ts
|
|
52629
|
-
import { mkdir as mkdir23, writeFile as
|
|
53010
|
+
import { mkdir as mkdir23, writeFile as writeFile15 } from "fs/promises";
|
|
52630
53011
|
import * as path79 from "path";
|
|
52631
53012
|
init_schema();
|
|
52632
53013
|
|
|
@@ -53111,7 +53492,7 @@ ${formatStatus2(directory)}`;
|
|
|
53111
53492
|
await mkdir23(cohortRoot.cohortRoot, { recursive: true });
|
|
53112
53493
|
const fingerprintInput = buildMemoryCohortFingerprintInput(memoryConfig);
|
|
53113
53494
|
const fingerprint = computeMemoryCohortFingerprint(fingerprintInput);
|
|
53114
|
-
await
|
|
53495
|
+
await writeFile15(path79.join(cohortRoot.cohortRoot, "memory-cohort-config.json"), JSON.stringify({
|
|
53115
53496
|
fingerprint,
|
|
53116
53497
|
algorithm_version: FINGERPRINT_ALGORITHM_VERSION,
|
|
53117
53498
|
config: fingerprintInput,
|
|
@@ -60251,7 +60632,7 @@ async function handleQaGatesCommand(directory, args, sessionID) {
|
|
|
60251
60632
|
}
|
|
60252
60633
|
|
|
60253
60634
|
// src/workflow/stage-a-repair.ts
|
|
60254
|
-
import { appendFile as appendFile10, mkdir as mkdir24, readdir as
|
|
60635
|
+
import { appendFile as appendFile10, mkdir as mkdir24, readdir as readdir8 } from "fs/promises";
|
|
60255
60636
|
import { dirname as dirname38 } from "path";
|
|
60256
60637
|
init_logger();
|
|
60257
60638
|
var MAX_STAGE_A_REPAIR_SCAN = 200;
|
|
@@ -60326,7 +60707,7 @@ async function repairWedgedStageA(directory, options) {
|
|
|
60326
60707
|
let entries;
|
|
60327
60708
|
try {
|
|
60328
60709
|
const evidenceDir = validateSwarmPath(directory, "evidence");
|
|
60329
|
-
entries = await
|
|
60710
|
+
entries = await readdir8(evidenceDir);
|
|
60330
60711
|
} catch {
|
|
60331
60712
|
return { results: [], truncated: false };
|
|
60332
60713
|
}
|
|
@@ -66569,7 +66950,7 @@ import {
|
|
|
66569
66950
|
openSync as openSync18,
|
|
66570
66951
|
readFileSync as readFileSync42,
|
|
66571
66952
|
renameSync as renameSync15,
|
|
66572
|
-
statSync as
|
|
66953
|
+
statSync as statSync22,
|
|
66573
66954
|
unlinkSync as unlinkSync20,
|
|
66574
66955
|
writeFileSync as writeFileSync17,
|
|
66575
66956
|
writeFileSync as writeFileSyncAsync
|
|
@@ -66659,7 +67040,7 @@ var _internals90 = {
|
|
|
66659
67040
|
renameSync: renameSync15,
|
|
66660
67041
|
unlinkSync: unlinkSync20,
|
|
66661
67042
|
existsSync: existsSync56,
|
|
66662
|
-
statSync:
|
|
67043
|
+
statSync: statSync22
|
|
66663
67044
|
};
|
|
66664
67045
|
async function appendEvent2(directory, eventInput) {
|
|
66665
67046
|
assertProjectRoot(directory);
|
|
@@ -67940,7 +68321,7 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
|
|
|
67940
68321
|
if (!input.dispatcher) {
|
|
67941
68322
|
throw new Error("no evaluation dispatcher available (cannot run validation)");
|
|
67942
68323
|
}
|
|
67943
|
-
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-
|
|
68324
|
+
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-9g2pcg10.js");
|
|
67944
68325
|
const executor = createModelEvaluationExecutor2(input.dispatcher, input.sessionId);
|
|
67945
68326
|
const result = await _internals95.evaluateCandidateV1({
|
|
67946
68327
|
projectRoot: input.directory,
|
|
@@ -68462,7 +68843,7 @@ init_loader();
|
|
|
68462
68843
|
init_schema();
|
|
68463
68844
|
|
|
68464
68845
|
// src/consensus/store.ts
|
|
68465
|
-
import { readdir as
|
|
68846
|
+
import { readdir as readdir9, unlink as unlink6 } from "fs/promises";
|
|
68466
68847
|
import * as path107 from "path";
|
|
68467
68848
|
|
|
68468
68849
|
// src/consensus/contracts.ts
|
|
@@ -68642,7 +69023,7 @@ function swarmPath(directory, ...segments) {
|
|
|
68642
69023
|
async function countConsensusReportFiles(directory) {
|
|
68643
69024
|
const root = swarmPath(directory, CONSENSUS_RELATIVE_DIR);
|
|
68644
69025
|
try {
|
|
68645
|
-
const entries = await
|
|
69026
|
+
const entries = await readdir9(root, { withFileTypes: true });
|
|
68646
69027
|
return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".json") && REPORT_ID_RE.test(entry.name.slice(0, -".json".length))).length;
|
|
68647
69028
|
} catch (error2) {
|
|
68648
69029
|
if (error2.code === "ENOENT")
|
|
@@ -69385,8 +69766,8 @@ async function countProposals(directory) {
|
|
|
69385
69766
|
const proposalsDir = validateSwarmPath(directory, "skills/proposals");
|
|
69386
69767
|
if (!fsSync3.existsSync(proposalsDir))
|
|
69387
69768
|
return 0;
|
|
69388
|
-
const { readdir:
|
|
69389
|
-
const entries = await
|
|
69769
|
+
const { readdir: readdir10 } = await import("fs/promises");
|
|
69770
|
+
const entries = await readdir10(proposalsDir);
|
|
69390
69771
|
return entries.filter((f) => f.endsWith(".md")).length;
|
|
69391
69772
|
} catch {
|
|
69392
69773
|
return 0;
|
|
@@ -69846,7 +70227,7 @@ function buildDetailedHelp(commandName, entry) {
|
|
|
69846
70227
|
async function handleHelpCommand(ctx) {
|
|
69847
70228
|
const targetCommand = ctx.args.join(" ");
|
|
69848
70229
|
if (!targetCommand) {
|
|
69849
|
-
const { buildHelpText } = await import("./index-
|
|
70230
|
+
const { buildHelpText } = await import("./index-03wz9h63.js");
|
|
69850
70231
|
return buildHelpText();
|
|
69851
70232
|
}
|
|
69852
70233
|
const tokens = targetCommand.split(/\s+/);
|
|
@@ -69855,7 +70236,7 @@ async function handleHelpCommand(ctx) {
|
|
|
69855
70236
|
return _internals98.buildDetailedHelp(resolved.key, resolved.entry);
|
|
69856
70237
|
}
|
|
69857
70238
|
const similar = _internals98.findSimilarCommands(targetCommand);
|
|
69858
|
-
const { buildHelpText: fullHelp } = await import("./index-
|
|
70239
|
+
const { buildHelpText: fullHelp } = await import("./index-03wz9h63.js");
|
|
69859
70240
|
if (similar.length > 0) {
|
|
69860
70241
|
return `Command '/swarm ${targetCommand}' not found.
|
|
69861
70242
|
|
|
@@ -69896,10 +70277,13 @@ async function handlePrFeedbackCommandWithTransition(ctx) {
|
|
|
69896
70277
|
return handlePrFeedbackCommand(ctx.directory, ctx.args);
|
|
69897
70278
|
}
|
|
69898
70279
|
if (parsed.continuation) {
|
|
70280
|
+
const exactCommand = parsed.prUrl ? `/swarm pr-feedback ${parsed.prUrl} continue from ${parsed.continuation.handoffPath}` : `/swarm pr-feedback continue from ${parsed.continuation.handoffPath}`;
|
|
69899
70281
|
await transitionPrReviewToFeedback(ctx.directory, ctx.sessionID, {
|
|
69900
70282
|
runId: parsed.continuation.runId,
|
|
69901
70283
|
handoffPath: parsed.continuation.handoffPath,
|
|
69902
|
-
prUrl: parsed.prUrl
|
|
70284
|
+
prUrl: parsed.prUrl,
|
|
70285
|
+
exactCommand,
|
|
70286
|
+
confirmedByUser: true
|
|
69903
70287
|
});
|
|
69904
70288
|
} else {
|
|
69905
70289
|
await activatePrWorkflow(ctx.directory, ctx.sessionID, "PR_FEEDBACK", {
|
|
@@ -70032,7 +70416,7 @@ var COMMAND_REGISTRY = {
|
|
|
70032
70416
|
},
|
|
70033
70417
|
"guardrail explain": {
|
|
70034
70418
|
handler: async (ctx) => {
|
|
70035
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
70419
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-tgv7rvap.js");
|
|
70036
70420
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
70037
70421
|
},
|
|
70038
70422
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -70042,7 +70426,7 @@ var COMMAND_REGISTRY = {
|
|
|
70042
70426
|
},
|
|
70043
70427
|
"guardrail reset": {
|
|
70044
70428
|
handler: async (ctx) => {
|
|
70045
|
-
const { handleGuardrailReset } = await import("./guardrail-reset-
|
|
70429
|
+
const { handleGuardrailReset } = await import("./guardrail-reset-4fw16xmb.js");
|
|
70046
70430
|
return handleGuardrailReset(ctx.args, ctx.sessionID);
|
|
70047
70431
|
},
|
|
70048
70432
|
description: "Reset one exact active invocation/action circuit after repair",
|
|
@@ -70051,7 +70435,7 @@ var COMMAND_REGISTRY = {
|
|
|
70051
70435
|
},
|
|
70052
70436
|
"guardrail-explain": {
|
|
70053
70437
|
handler: async (ctx) => {
|
|
70054
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
70438
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-tgv7rvap.js");
|
|
70055
70439
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
70056
70440
|
},
|
|
70057
70441
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -70061,7 +70445,7 @@ var COMMAND_REGISTRY = {
|
|
|
70061
70445
|
},
|
|
70062
70446
|
"guardrail-reset": {
|
|
70063
70447
|
handler: async (ctx) => {
|
|
70064
|
-
const { handleGuardrailReset } = await import("./guardrail-reset-
|
|
70448
|
+
const { handleGuardrailReset } = await import("./guardrail-reset-4fw16xmb.js");
|
|
70065
70449
|
return handleGuardrailReset(ctx.args, ctx.sessionID);
|
|
70066
70450
|
},
|
|
70067
70451
|
description: "Reset one exact active invocation/action circuit after repair",
|
|
@@ -70071,7 +70455,7 @@ var COMMAND_REGISTRY = {
|
|
|
70071
70455
|
},
|
|
70072
70456
|
"guardrail-log": {
|
|
70073
70457
|
handler: async (ctx) => {
|
|
70074
|
-
const { handleGuardrailLog } = await import("./guardrail-log-
|
|
70458
|
+
const { handleGuardrailLog } = await import("./guardrail-log-k0zk6rbs.js");
|
|
70075
70459
|
return handleGuardrailLog(ctx.directory, ctx.args);
|
|
70076
70460
|
},
|
|
70077
70461
|
description: "Read the guardrail decision log (use --blocks-only for blocks)",
|
|
@@ -76914,7 +77298,7 @@ function isLaneOwnedByCurrentSession(branchName, expectedSessionId) {
|
|
|
76914
77298
|
return extracted === expectedSessionId;
|
|
76915
77299
|
}
|
|
76916
77300
|
async function inspectStandardWorktreeCollisionOwnership(identity) {
|
|
76917
|
-
const collisionOwnership = await import("./worktree-collision-ownership-
|
|
77301
|
+
const collisionOwnership = await import("./worktree-collision-ownership-e0p490vw.js");
|
|
76918
77302
|
return collisionOwnership.inspectStandardWorktreeCollisionOwnership(identity);
|
|
76919
77303
|
}
|
|
76920
77304
|
async function precreateStandardWorktreeSession(args) {
|
|
@@ -77062,7 +77446,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
77062
77446
|
const laneProfile = computeLaneRuntimeProfile(worktreeConfig.runtime_isolation, laneIndex, provisionResult.worktreePath);
|
|
77063
77447
|
if (laneProfile) {
|
|
77064
77448
|
try {
|
|
77065
|
-
const { writeLaneProfileToDiskReal } = await import("./core-
|
|
77449
|
+
const { writeLaneProfileToDiskReal } = await import("./core-0ghwny8q.js");
|
|
77066
77450
|
await writeLaneProfileToDiskReal(provisionResult.worktreePath, laneProfile.laneIndex, laneProfile.envOverrides);
|
|
77067
77451
|
} catch {}
|
|
77068
77452
|
}
|
|
@@ -77720,7 +78104,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
77720
78104
|
}
|
|
77721
78105
|
clearWorktreeMergeStatus(statusKey);
|
|
77722
78106
|
try {
|
|
77723
|
-
const { removeLaneProfileFromDiskReal } = await import("./core-
|
|
78107
|
+
const { removeLaneProfileFromDiskReal } = await import("./core-0ghwny8q.js");
|
|
77724
78108
|
await removeLaneProfileFromDiskReal(dispatch.handle.worktreePath, dispatch.laneIndex);
|
|
77725
78109
|
} catch {}
|
|
77726
78110
|
const state = serializationStateBySessionID.get(dispatch.parentSessionID);
|