opencode-swarm 7.159.0 → 7.159.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/engineering-conventions/SKILL.md +20 -0
- package/.opencode/skills/execute/SKILL.md +2 -2
- package/dist/cli/{coder-settlement-66mqw0xt.js → coder-settlement-hny3vh3e.js} +9 -9
- package/dist/cli/{config-doctor-nkx61b9e.js → config-doctor-00ex0s3k.js} +2 -2
- package/dist/cli/{core-b3db7gf6.js → core-03tedwzg.js} +1 -1
- package/dist/cli/{curation-policy-vn3m5nq2.js → curation-policy-z0a5akng.js} +6 -6
- package/dist/cli/{curator-llm-factory-c4y1mrr5.js → curator-llm-factory-24bfn7h1.js} +31 -31
- package/dist/cli/{curator-w4ntvkz5.js → curator-n81nzdw8.js} +31 -31
- package/dist/cli/{evidence-summary-service-vadgnzk6.js → evidence-summary-service-nz7y1w2a.js} +13 -13
- package/dist/cli/{gate-evidence-0chatz5e.js → gate-evidence-dxafmzrn.js} +6 -6
- package/dist/cli/guardrail-explain-b3k9xrx9.js +67 -0
- package/dist/cli/{guardrail-log-t3c9g8tc.js → guardrail-log-t8c7acxg.js} +5 -5
- package/dist/cli/{guardrail-reset-wvdb5sv5.js → guardrail-reset-0ft2gf03.js} +31 -31
- package/dist/cli/{hive-promoter-mfq3ee0n.js → hive-promoter-brq9cx7c.js} +31 -31
- package/dist/cli/{index-nwkr6tvv.js → index-0zerbq1v.js} +1 -1
- package/dist/cli/{index-h52hs4e9.js → index-1e9rzhmr.js} +2 -2
- package/dist/cli/{index-b1tenv2s.js → index-1xcve0gc.js} +7 -1
- package/dist/cli/{index-8jnzp5ct.js → index-200myvdx.js} +2 -2
- package/dist/cli/{index-mc9qgkwd.js → index-6sheh3yp.js} +3 -3
- package/dist/cli/{index-k4arrwrz.js → index-7tjamatf.js} +8 -8
- package/dist/cli/{index-vywbn766.js → index-8ahjx7vt.js} +4 -4
- package/dist/cli/{index-pvzaryhr.js → index-8gh97gkz.js} +1 -1
- package/dist/cli/{index-3e8600a7.js → index-9ev0bbqh.js} +883 -252
- package/dist/cli/{index-xagq35tf.js → index-av3gnekk.js} +1 -1
- package/dist/cli/{index-k48kgm6z.js → index-b2dh37cf.js} +5 -5
- package/dist/cli/{index-ynjy98vv.js → index-b5s1n149.js} +5 -5
- package/dist/cli/{index-erdsawqz.js → index-bmst1sje.js} +6 -6
- package/dist/cli/{index-e2s08v0q.js → index-caqjwnak.js} +2 -2
- package/dist/cli/{index-tcbjjppb.js → index-dgt8z19x.js} +1 -1
- package/dist/cli/{index-6e6qxf5q.js → index-e1jcdpdg.js} +1 -1
- package/dist/cli/{index-gprxjmm7.js → index-ebz97mks.js} +3 -1
- package/dist/cli/{index-pfnj5pvs.js → index-egc8d995.js} +1 -1
- package/dist/cli/{index-we3nf5as.js → index-eh1gh043.js} +4 -4
- package/dist/cli/{index-z54qw70y.js → index-jd7mz4yg.js} +1 -1
- package/dist/cli/{index-8kfbdrxa.js → index-k7kvrwbj.js} +33 -33
- package/dist/cli/{index-7s1hmrfh.js → index-ky2r092m.js} +2 -2
- package/dist/cli/{index-xmz69g65.js → index-m0gfzxw1.js} +2 -2
- package/dist/cli/{index-ghjs1n7k.js → index-mcan50mx.js} +4 -4
- package/dist/cli/{index-04yrxg0z.js → index-nmp47dmm.js} +2 -2
- package/dist/cli/{index-9vt2hknx.js → index-p2m1skjz.js} +1 -1
- package/dist/cli/{index-h1g8w4v0.js → index-prknc0xn.js} +129 -44
- package/dist/cli/{index-zcmwwp1x.js → index-q8yma345.js} +2 -2
- package/dist/cli/{index-35grv4jg.js → index-qypnqmcj.js} +7 -7
- package/dist/cli/{index-1sdb57jv.js → index-rq461prn.js} +6 -6
- package/dist/cli/{index-b82tq895.js → index-v7wm4mw8.js} +3 -3
- package/dist/cli/{index-5zgf140g.js → index-vq4d1h7t.js} +1 -1
- package/dist/cli/{index-8fqb0ynp.js → index-w1rhyqw2.js} +1 -1
- package/dist/cli/{index-hte1e31d.js → index-wzc6vzq6.js} +2 -2
- package/dist/cli/{index-fcp41snp.js → index-y55hqgcj.js} +4 -4
- package/dist/cli/index.js +31 -31
- package/dist/cli/{knowledge-escalator-x85t1e66.js → knowledge-escalator-rxagfxnk.js} +12 -12
- package/dist/cli/{knowledge-events-bwx99mxc.js → knowledge-events-ymwdv799.js} +10 -10
- package/dist/cli/{knowledge-link-cj2abbae.js → knowledge-link-n1825n09.js} +5 -5
- package/dist/cli/{knowledge-store-21m81zsa.js → knowledge-store-nxm4xvvq.js} +6 -6
- package/dist/cli/{knowledge-validator-yxcadg1p.js → knowledge-validator-gtmq35k8.js} +8 -8
- package/dist/cli/{pending-delegations-b8qka5nf.js → pending-delegations-zdgazhdf.js} +3 -3
- package/dist/cli/{pr-review-reentry-authorization-wv3ck5kh.js → pr-review-reentry-authorization-jgzb0pma.js} +31 -31
- package/dist/cli/{pr-subscriptions-j9j70bmd.js → pr-subscriptions-pxv24d5k.js} +4 -4
- package/dist/cli/{runner-sj5sf36c.js → runner-fzgkhx6a.js} +6 -6
- package/dist/cli/{scan-cursor-m3w0tapb.js → scan-cursor-fasdj7kj.js} +7 -7
- package/dist/cli/{schema-0b0dqn28.js → schema-3x28z3rp.js} +1 -1
- package/dist/cli/{scope-persistence-199f7yqc.js → scope-persistence-p8dnxfhx.js} +8 -8
- package/dist/cli/{skill-generator-a2ekcbe2.js → skill-generator-6tjyffgd.js} +14 -14
- package/dist/cli/{telemetry-r8e8zey7.js → telemetry-3rh94wv3.js} +1 -1
- package/dist/cli/{worktree-collision-ownership-5qaab3q7.js → worktree-collision-ownership-3bbn1n2r.js} +5 -5
- package/dist/cli/{worktree-isolation-esesc842.js → worktree-isolation-1470tnxc.js} +31 -31
- package/dist/config/evidence-schema.d.ts +51 -0
- package/dist/config/schema.d.ts +20 -0
- package/dist/evaluation/contracts.d.ts +5 -5
- package/dist/evaluation/ephemeral-agent-dispatcher.d.ts +2 -0
- package/dist/evaluation/model-dispatcher.d.ts +2 -2
- package/dist/index.js +191 -191
- package/dist/observability/catalog.d.ts +5 -3
- package/dist/review/contracts.d.ts +2 -1
- package/dist/review/evidence.d.ts +12 -0
- package/dist/services/cost-accounting.d.ts +100 -0
- package/dist/services/status-service.d.ts +12 -0
- package/dist/telemetry.d.ts +1 -1
- package/dist/tools/sast-baseline.d.ts +120 -3
- package/dist/tools/sast-scan.d.ts +25 -1
- package/opencode-swarm.schema.json +40 -0
- package/package.json +1 -1
- package/dist/cli/guardrail-explain-ax2qmsp4.js +0 -67
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
resolveExecutableFromPath,
|
|
7
7
|
runEvaluation,
|
|
8
8
|
runExternalTool
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-jd7mz4yg.js";
|
|
10
10
|
import {
|
|
11
11
|
finalizeShellAuditForClose,
|
|
12
12
|
isPolicyProtectedPath,
|
|
@@ -15,13 +15,13 @@ import {
|
|
|
15
15
|
protectedRoots,
|
|
16
16
|
redactDecisionLineForArchive,
|
|
17
17
|
stableCanonicalStringify
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-nmp47dmm.js";
|
|
19
19
|
import {
|
|
20
20
|
detectStraySwarmDirs,
|
|
21
21
|
readDoctorArtifact,
|
|
22
22
|
removeStraySwarmDir,
|
|
23
23
|
runConfigDoctor
|
|
24
|
-
} from "./index-
|
|
24
|
+
} from "./index-e1jcdpdg.js";
|
|
25
25
|
import {
|
|
26
26
|
MAX_TRANSIENT_RETRIES,
|
|
27
27
|
archiveEvidence,
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
validateProjectRoot,
|
|
69
69
|
validateSymlinkBoundary,
|
|
70
70
|
validateTargetWithinRoot
|
|
71
|
-
} from "./index-
|
|
71
|
+
} from "./index-7tjamatf.js";
|
|
72
72
|
import {
|
|
73
73
|
EvaluationTaskV1Schema,
|
|
74
74
|
GateAuditManifestV1Schema,
|
|
@@ -85,7 +85,7 @@ import {
|
|
|
85
85
|
saveGateAuditResult,
|
|
86
86
|
savePromotionDecision,
|
|
87
87
|
saveTaskSetSnapshot
|
|
88
|
-
} from "./index-
|
|
88
|
+
} from "./index-ky2r092m.js";
|
|
89
89
|
import {
|
|
90
90
|
canonicalHash,
|
|
91
91
|
canonicalJson,
|
|
@@ -129,15 +129,15 @@ import {
|
|
|
129
129
|
retireSkill,
|
|
130
130
|
selectCandidateEntries,
|
|
131
131
|
syncBundledProjectSkillsIfMissingAsync
|
|
132
|
-
} from "./index-
|
|
132
|
+
} from "./index-y55hqgcj.js";
|
|
133
133
|
import {
|
|
134
134
|
readRecentEscalations
|
|
135
|
-
} from "./index-
|
|
135
|
+
} from "./index-b2dh37cf.js";
|
|
136
136
|
import {
|
|
137
137
|
alreadyCuratedThisGeneration,
|
|
138
138
|
claimNextScanBatch,
|
|
139
139
|
resolveCohortId
|
|
140
|
-
} from "./index-
|
|
140
|
+
} from "./index-m0gfzxw1.js";
|
|
141
141
|
import {
|
|
142
142
|
CURATOR_INIT_PROMPT,
|
|
143
143
|
CURATOR_PHASE_PROMPT,
|
|
@@ -161,7 +161,7 @@ import {
|
|
|
161
161
|
listActive,
|
|
162
162
|
subscribe,
|
|
163
163
|
unsubscribe
|
|
164
|
-
} from "./index-
|
|
164
|
+
} from "./index-6sheh3yp.js";
|
|
165
165
|
import {
|
|
166
166
|
clearWorktreeMergeStatus,
|
|
167
167
|
getAllWorktreeMergeFailures,
|
|
@@ -173,7 +173,7 @@ import {
|
|
|
173
173
|
listCoderSettlementWalStates,
|
|
174
174
|
recoverCoderSettlement,
|
|
175
175
|
recoverStaleCoderSettlements
|
|
176
|
-
} from "./index-
|
|
176
|
+
} from "./index-rq461prn.js";
|
|
177
177
|
import {
|
|
178
178
|
parsePorcelainV2Snapshot,
|
|
179
179
|
resolveCommitCountSince,
|
|
@@ -206,7 +206,7 @@ import {
|
|
|
206
206
|
WORKTREE_LIFECYCLE_LOCK_FILE,
|
|
207
207
|
recordWorktreeProvisioningOwner,
|
|
208
208
|
removeWorktreeProvisioningOwner
|
|
209
|
-
} from "./index-
|
|
209
|
+
} from "./index-w1rhyqw2.js";
|
|
210
210
|
import {
|
|
211
211
|
appendUnactionable,
|
|
212
212
|
quarantineEntry,
|
|
@@ -217,11 +217,11 @@ import {
|
|
|
217
217
|
validateActionableFields,
|
|
218
218
|
validateLesson,
|
|
219
219
|
validateSkillPath
|
|
220
|
-
} from "./index-
|
|
220
|
+
} from "./index-8ahjx7vt.js";
|
|
221
221
|
import {
|
|
222
222
|
authorizeCuration,
|
|
223
223
|
buildConfigFingerprintInput
|
|
224
|
-
} from "./index-
|
|
224
|
+
} from "./index-egc8d995.js";
|
|
225
225
|
import {
|
|
226
226
|
cohortConfigFingerprint
|
|
227
227
|
} from "./index-rtry5xyf.js";
|
|
@@ -252,12 +252,12 @@ import {
|
|
|
252
252
|
transitionTaskWorkflowEvidence,
|
|
253
253
|
withTaskEvidenceTransaction,
|
|
254
254
|
writeWorkflowWalFile
|
|
255
|
-
} from "./index-
|
|
255
|
+
} from "./index-eh1gh043.js";
|
|
256
256
|
import {
|
|
257
257
|
makeWorktreeBranchName,
|
|
258
258
|
provisionWorktree,
|
|
259
259
|
removeWorktree
|
|
260
|
-
} from "./index-
|
|
260
|
+
} from "./index-8gh97gkz.js";
|
|
261
261
|
import {
|
|
262
262
|
DEFAULT_STALE_DELEGATION_TIMEOUT_MS,
|
|
263
263
|
DELEGATION_COMPACTION_HIGH_WATER_BYTES,
|
|
@@ -272,7 +272,7 @@ import {
|
|
|
272
272
|
scanBackgroundCoderReservationsForAdmission,
|
|
273
273
|
scanDelegationsForRecovery,
|
|
274
274
|
sweepStaleDelegations
|
|
275
|
-
} from "./index-
|
|
275
|
+
} from "./index-caqjwnak.js";
|
|
276
276
|
import {
|
|
277
277
|
compositeSessionKey,
|
|
278
278
|
sessionKeySuffix
|
|
@@ -283,7 +283,7 @@ import {
|
|
|
283
283
|
clearAllScopes,
|
|
284
284
|
clearScopeBindingFromDisk,
|
|
285
285
|
clearScopeBindings
|
|
286
|
-
} from "./index-
|
|
286
|
+
} from "./index-b5s1n149.js";
|
|
287
287
|
import {
|
|
288
288
|
appendLedgerEvent,
|
|
289
289
|
computePlanHash,
|
|
@@ -298,7 +298,7 @@ import {
|
|
|
298
298
|
readPlanEpochIdentity,
|
|
299
299
|
replayFromLedgerWithStatus,
|
|
300
300
|
takeSnapshotEvent
|
|
301
|
-
} from "./index-
|
|
301
|
+
} from "./index-v7wm4mw8.js";
|
|
302
302
|
import {
|
|
303
303
|
CORE_EVENT_LOCKED,
|
|
304
304
|
appendCoreEventSync,
|
|
@@ -308,7 +308,7 @@ import {
|
|
|
308
308
|
hasSpecDriftAuditEvent,
|
|
309
309
|
hasTaskRepairAuditEvent,
|
|
310
310
|
readCoreEvents
|
|
311
|
-
} from "./index-
|
|
311
|
+
} from "./index-0zerbq1v.js";
|
|
312
312
|
import {
|
|
313
313
|
sanitizeDiagnosticText
|
|
314
314
|
} from "./index-556ja8an.js";
|
|
@@ -357,7 +357,7 @@ import {
|
|
|
357
357
|
transactFile,
|
|
358
358
|
transactKnowledge,
|
|
359
359
|
wordBigrams
|
|
360
|
-
} from "./index-
|
|
360
|
+
} from "./index-bmst1sje.js";
|
|
361
361
|
import {
|
|
362
362
|
MAX_EVENT_LOG_ENTRIES,
|
|
363
363
|
_internals as _internals2,
|
|
@@ -373,13 +373,13 @@ import {
|
|
|
373
373
|
recordKnowledgeEvent,
|
|
374
374
|
recordPhaseCloseIntent,
|
|
375
375
|
resolveKnowledgeEventsPath
|
|
376
|
-
} from "./index-
|
|
376
|
+
} from "./index-qypnqmcj.js";
|
|
377
377
|
import {
|
|
378
378
|
resolveWorktreeIsolationConfig
|
|
379
|
-
} from "./index-
|
|
379
|
+
} from "./index-wzc6vzq6.js";
|
|
380
380
|
import {
|
|
381
381
|
RetrospectiveEvidenceSchema
|
|
382
|
-
} from "./index-
|
|
382
|
+
} from "./index-ebz97mks.js";
|
|
383
383
|
import {
|
|
384
384
|
estimateTokens,
|
|
385
385
|
readSwarmFileAsync,
|
|
@@ -399,7 +399,7 @@ import {
|
|
|
399
399
|
init_loader,
|
|
400
400
|
loadPluginConfig,
|
|
401
401
|
loadPluginConfigWithMeta
|
|
402
|
-
} from "./index-
|
|
402
|
+
} from "./index-dgt8z19x.js";
|
|
403
403
|
import {
|
|
404
404
|
DEFAULT_HARNESS_EVOLUTION_CONFIG,
|
|
405
405
|
DEFAULT_PR_REVIEW_RESILIENCE_CONFIG,
|
|
@@ -415,7 +415,7 @@ import {
|
|
|
415
415
|
package_default,
|
|
416
416
|
resolveAutoReviewConfig,
|
|
417
417
|
stripKnownSwarmPrefix
|
|
418
|
-
} from "./index-
|
|
418
|
+
} from "./index-1xcve0gc.js";
|
|
419
419
|
import {
|
|
420
420
|
init_git_executable,
|
|
421
421
|
resolveGitExecutable,
|
|
@@ -455,10 +455,10 @@ import {
|
|
|
455
455
|
resolveLinkDir,
|
|
456
456
|
sanitizeLinkId,
|
|
457
457
|
writeLinkPointer
|
|
458
|
-
} from "./index-
|
|
458
|
+
} from "./index-vq4d1h7t.js";
|
|
459
459
|
import {
|
|
460
460
|
atomicWriteFile
|
|
461
|
-
} from "./index-
|
|
461
|
+
} from "./index-1e9rzhmr.js";
|
|
462
462
|
import {
|
|
463
463
|
KNOWLEDGE_SCHEMA_VERSION,
|
|
464
464
|
OUTCOME_BLOCK_THRESHOLD,
|
|
@@ -470,7 +470,7 @@ import {
|
|
|
470
470
|
atomicWriteSwarmFileSync,
|
|
471
471
|
matchTempGrammar,
|
|
472
472
|
parseTargetBasename
|
|
473
|
-
} from "./index-
|
|
473
|
+
} from "./index-q8yma345.js";
|
|
474
474
|
import {
|
|
475
475
|
assertProjectRoot,
|
|
476
476
|
hasExplicitProjectBoundary,
|
|
@@ -478,7 +478,7 @@ import {
|
|
|
478
478
|
listActiveLocks,
|
|
479
479
|
tryAcquireLock,
|
|
480
480
|
withEvidenceLock
|
|
481
|
-
} from "./index-
|
|
481
|
+
} from "./index-av3gnekk.js";
|
|
482
482
|
import {
|
|
483
483
|
invalidateCachedArtifact,
|
|
484
484
|
resetSwarmArtifactCache
|
|
@@ -487,7 +487,7 @@ import {
|
|
|
487
487
|
emit,
|
|
488
488
|
getLastHeartbeat,
|
|
489
489
|
telemetry
|
|
490
|
-
} from "./index-
|
|
490
|
+
} from "./index-prknc0xn.js";
|
|
491
491
|
import {
|
|
492
492
|
require_proper_lockfile
|
|
493
493
|
} from "./index-7g4c7s5r.js";
|
|
@@ -15777,38 +15777,339 @@ async function computeGateStatistics(directory, minSamples = 6, runId) {
|
|
|
15777
15777
|
}
|
|
15778
15778
|
|
|
15779
15779
|
// src/services/cost-accounting.ts
|
|
15780
|
-
init_logger();
|
|
15781
15780
|
import * as fs8 from "fs";
|
|
15781
|
+
init_logger();
|
|
15782
15782
|
import * as os from "os";
|
|
15783
15783
|
import * as path16 from "path";
|
|
15784
|
+
var ZERO_USAGE = {
|
|
15785
|
+
tokens_input: 0,
|
|
15786
|
+
tokens_output: 0,
|
|
15787
|
+
tokens_reasoning: 0,
|
|
15788
|
+
tokens_cache: 0
|
|
15789
|
+
};
|
|
15790
|
+
var MAX_EVIDENCE_ITEMS = 8;
|
|
15791
|
+
var MAX_COST_STRING_LENGTH = 128;
|
|
15792
|
+
var MAX_PROVIDER_REPORTED_COST_USD = 1e9;
|
|
15793
|
+
var MAX_TELEMETRY_FILE_BYTES = 4 * 1024 * 1024;
|
|
15794
|
+
function projectCostEvidence(evidence2) {
|
|
15795
|
+
const reports = evidence2.filter((item) => item.kind === "provider_reported" && item.reason !== "missing_cost");
|
|
15796
|
+
const compatibleReports = reports.filter((item) => item.amount_usd !== null && item.amount_usd <= MAX_PROVIDER_REPORTED_COST_USD && item.currency === "USD");
|
|
15797
|
+
const incompatibleReport = reports.some((item) => item.amount_usd !== null && item.amount_usd <= MAX_PROVIDER_REPORTED_COST_USD && (item.currency !== "USD" || item.reason !== "authoritative"));
|
|
15798
|
+
const reportConflict = hasReportConflict(reports);
|
|
15799
|
+
if (!reportConflict && !incompatibleReport && compatibleReports.length > 0) {
|
|
15800
|
+
return {
|
|
15801
|
+
cost_usd: roundUsd(compatibleReports[0].amount_usd ?? 0),
|
|
15802
|
+
cost_source: "reported",
|
|
15803
|
+
evidence_status: "complete",
|
|
15804
|
+
reason: "authoritative",
|
|
15805
|
+
currency: "USD"
|
|
15806
|
+
};
|
|
15807
|
+
}
|
|
15808
|
+
const estimate = evidence2.find((item) => item.kind === "normalized_estimate" && item.amount_usd !== null && item.currency === "USD" && item.reason === "authoritative");
|
|
15809
|
+
const hasHardIncompatibleReport = reports.some((item) => item.amount_usd !== null && item.amount_usd <= MAX_PROVIDER_REPORTED_COST_USD && (item.currency !== "USD" || item.reason === "unsupported_currency"));
|
|
15810
|
+
if (!reportConflict && !hasHardIncompatibleReport && estimate) {
|
|
15811
|
+
return {
|
|
15812
|
+
cost_usd: roundUsd(estimate.amount_usd ?? 0),
|
|
15813
|
+
cost_source: "estimated",
|
|
15814
|
+
evidence_status: "complete",
|
|
15815
|
+
reason: "authoritative",
|
|
15816
|
+
currency: "USD"
|
|
15817
|
+
};
|
|
15818
|
+
}
|
|
15819
|
+
return {
|
|
15820
|
+
cost_usd: null,
|
|
15821
|
+
cost_source: "unavailable",
|
|
15822
|
+
evidence_status: "inconclusive",
|
|
15823
|
+
reason: reportConflict ? "conflict" : incompatibleReport ? reports[0]?.reason ?? "unsupported_currency" : "missing_cost",
|
|
15824
|
+
currency: reports[0]?.currency ?? "unknown"
|
|
15825
|
+
};
|
|
15826
|
+
}
|
|
15784
15827
|
function summarizeTelemetryCosts(directory) {
|
|
15785
15828
|
const summary = createEmptySummary();
|
|
15786
|
-
|
|
15829
|
+
const folded = foldTelemetryEvents(readTelemetryEvents(directory));
|
|
15830
|
+
summary.conflict_count = folded.stats.conflict_count;
|
|
15831
|
+
summary.join_miss_count = folded.stats.join_miss_count;
|
|
15832
|
+
summary.telemetry_error_count = folded.stats.telemetry_error_count;
|
|
15833
|
+
if (folded.stats.join_miss_count > 0 || folded.stats.telemetry_error_count > 0) {
|
|
15834
|
+
summary.evidence_status = "inconclusive";
|
|
15835
|
+
}
|
|
15836
|
+
if (folded.stats.rejected_corrections > 0 || folded.stats.conflict_count > 0) {
|
|
15837
|
+
summary.evidence_status = "inconclusive";
|
|
15838
|
+
}
|
|
15839
|
+
summary.accepted_corrections = folded.stats.accepted_corrections;
|
|
15840
|
+
summary.rejected_corrections = folded.stats.rejected_corrections;
|
|
15841
|
+
summary.duplicate_corrections = folded.stats.duplicate_corrections;
|
|
15842
|
+
for (const event of folded.events) {
|
|
15787
15843
|
if (event.event !== "delegation_end")
|
|
15788
15844
|
continue;
|
|
15789
15845
|
addDelegationEvent(summary, event);
|
|
15790
15846
|
}
|
|
15791
15847
|
return finalizeSummary(summary);
|
|
15792
15848
|
}
|
|
15849
|
+
function foldTelemetryEvents(events) {
|
|
15850
|
+
const stats = {
|
|
15851
|
+
conflict_count: 0,
|
|
15852
|
+
join_miss_count: 0,
|
|
15853
|
+
telemetry_error_count: 0,
|
|
15854
|
+
accepted_corrections: 0,
|
|
15855
|
+
rejected_corrections: 0,
|
|
15856
|
+
duplicate_corrections: 0
|
|
15857
|
+
};
|
|
15858
|
+
const rows = new Map;
|
|
15859
|
+
const states = new Map;
|
|
15860
|
+
const legacy = [];
|
|
15861
|
+
const corrections = [];
|
|
15862
|
+
for (const event of events) {
|
|
15863
|
+
const eventKind = event.event;
|
|
15864
|
+
if (eventKind === "delegation_cost_join" && event.reason === "join_miss") {
|
|
15865
|
+
stats.join_miss_count++;
|
|
15866
|
+
continue;
|
|
15867
|
+
}
|
|
15868
|
+
if (eventKind === "delegation_cost_join" && (event.reason === "unreadable" || event.reason === "malformed")) {
|
|
15869
|
+
stats.telemetry_error_count++;
|
|
15870
|
+
continue;
|
|
15871
|
+
}
|
|
15872
|
+
if (eventKind !== "delegation_end" && eventKind !== "delegation_cost_correction")
|
|
15873
|
+
continue;
|
|
15874
|
+
if (eventKind === "delegation_end") {
|
|
15875
|
+
const recordId = boundedId(event.record_id ?? event.recordId);
|
|
15876
|
+
if (!recordId) {
|
|
15877
|
+
legacy.push(event);
|
|
15878
|
+
continue;
|
|
15879
|
+
}
|
|
15880
|
+
const fingerprint = boundedDigest(event.identity_fingerprint);
|
|
15881
|
+
const initialVersion = validVersion(event.version);
|
|
15882
|
+
if (!fingerprint || initialVersion !== 1) {
|
|
15883
|
+
legacy.push(event);
|
|
15884
|
+
stats.rejected_corrections++;
|
|
15885
|
+
continue;
|
|
15886
|
+
}
|
|
15887
|
+
const snapshot = { ...event, record_id: recordId };
|
|
15888
|
+
const digest2 = boundedDigest(event.digest) ?? costSnapshotDigest(snapshot);
|
|
15889
|
+
if (rows.has(recordId)) {
|
|
15890
|
+
stats.rejected_corrections++;
|
|
15891
|
+
continue;
|
|
15892
|
+
}
|
|
15893
|
+
rows.set(recordId, snapshot);
|
|
15894
|
+
states.set(recordId, {
|
|
15895
|
+
version: initialVersion,
|
|
15896
|
+
digest: digest2,
|
|
15897
|
+
fingerprint
|
|
15898
|
+
});
|
|
15899
|
+
if (parseCostSource(event.cost_source) === "unavailable") {
|
|
15900
|
+
const evidence2 = readEventEvidence(event);
|
|
15901
|
+
if (evidence2.some((item) => item.reason === "conflict"))
|
|
15902
|
+
stats.conflict_count++;
|
|
15903
|
+
}
|
|
15904
|
+
continue;
|
|
15905
|
+
}
|
|
15906
|
+
corrections.push(event);
|
|
15907
|
+
}
|
|
15908
|
+
corrections.sort((left, right) => {
|
|
15909
|
+
const leftRecord = boundedId(left.record_id ?? left.recordId) ?? "";
|
|
15910
|
+
const rightRecord = boundedId(right.record_id ?? right.recordId) ?? "";
|
|
15911
|
+
if (leftRecord !== rightRecord)
|
|
15912
|
+
return leftRecord.localeCompare(rightRecord);
|
|
15913
|
+
return (validVersion(left.version) ?? Number.MAX_SAFE_INTEGER) - (validVersion(right.version) ?? Number.MAX_SAFE_INTEGER);
|
|
15914
|
+
});
|
|
15915
|
+
for (const event of corrections) {
|
|
15916
|
+
const recordId = boundedId(event.record_id ?? event.recordId);
|
|
15917
|
+
const state = recordId ? states.get(recordId) : undefined;
|
|
15918
|
+
const current = recordId ? rows.get(recordId) : undefined;
|
|
15919
|
+
if (!recordId || !state || !current) {
|
|
15920
|
+
stats.rejected_corrections++;
|
|
15921
|
+
continue;
|
|
15922
|
+
}
|
|
15923
|
+
const fingerprint = boundedDigest(event.identity_fingerprint);
|
|
15924
|
+
if (!fingerprint || fingerprint !== state.fingerprint) {
|
|
15925
|
+
stats.rejected_corrections++;
|
|
15926
|
+
continue;
|
|
15927
|
+
}
|
|
15928
|
+
const nextVersion = validVersion(event.version);
|
|
15929
|
+
if (nextVersion === null || nextVersion !== state.version + 1) {
|
|
15930
|
+
stats.rejected_corrections++;
|
|
15931
|
+
continue;
|
|
15932
|
+
}
|
|
15933
|
+
const replacement = {
|
|
15934
|
+
...current,
|
|
15935
|
+
event: "delegation_end",
|
|
15936
|
+
record_id: recordId,
|
|
15937
|
+
version: event.version,
|
|
15938
|
+
digest: event.digest,
|
|
15939
|
+
cost_evidence: event.cost_evidence,
|
|
15940
|
+
evidence_status: event.evidence_status,
|
|
15941
|
+
evidence_reason: event.evidence_reason,
|
|
15942
|
+
currency: event.currency,
|
|
15943
|
+
cost_usd: event.cost_usd,
|
|
15944
|
+
cost_source: event.cost_source,
|
|
15945
|
+
tokens_input: event.tokens_input,
|
|
15946
|
+
tokens_output: event.tokens_output,
|
|
15947
|
+
tokens_reasoning: event.tokens_reasoning,
|
|
15948
|
+
tokens_cache: event.tokens_cache
|
|
15949
|
+
};
|
|
15950
|
+
const digest2 = boundedDigest(event.digest) ?? costSnapshotDigest(replacement);
|
|
15951
|
+
if (digest2 === state.digest) {
|
|
15952
|
+
stats.duplicate_corrections++;
|
|
15953
|
+
states.set(recordId, {
|
|
15954
|
+
version: nextVersion,
|
|
15955
|
+
digest: state.digest,
|
|
15956
|
+
fingerprint: state.fingerprint
|
|
15957
|
+
});
|
|
15958
|
+
continue;
|
|
15959
|
+
}
|
|
15960
|
+
const currentEvidence = readEventEvidence(current);
|
|
15961
|
+
const nextEvidence = readEventEvidence(replacement);
|
|
15962
|
+
if (hasReportConflict(nextEvidence)) {
|
|
15963
|
+
stats.conflict_count++;
|
|
15964
|
+
stats.rejected_corrections++;
|
|
15965
|
+
continue;
|
|
15966
|
+
}
|
|
15967
|
+
if (!isCostUpgrade(currentEvidence, nextEvidence)) {
|
|
15968
|
+
stats.rejected_corrections++;
|
|
15969
|
+
continue;
|
|
15970
|
+
}
|
|
15971
|
+
rows.set(recordId, replacement);
|
|
15972
|
+
states.set(recordId, {
|
|
15973
|
+
version: nextVersion,
|
|
15974
|
+
digest: digest2,
|
|
15975
|
+
fingerprint: state.fingerprint
|
|
15976
|
+
});
|
|
15977
|
+
stats.accepted_corrections++;
|
|
15978
|
+
}
|
|
15979
|
+
return {
|
|
15980
|
+
events: [...legacy, ...rows.values()],
|
|
15981
|
+
stats,
|
|
15982
|
+
versions: Object.fromEntries([...states].map(([recordId, state]) => [recordId, state.version]))
|
|
15983
|
+
};
|
|
15984
|
+
}
|
|
15985
|
+
function boundedId(value) {
|
|
15986
|
+
return typeof value === "string" && /^[A-Za-z0-9_-]{1,32}$/.test(value) ? value : null;
|
|
15987
|
+
}
|
|
15988
|
+
function boundedDigest(value) {
|
|
15989
|
+
return typeof value === "string" && /^[a-f0-9]{32,64}$/.test(value) ? value : undefined;
|
|
15990
|
+
}
|
|
15991
|
+
function validVersion(value) {
|
|
15992
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 1e5 ? value : null;
|
|
15993
|
+
}
|
|
15994
|
+
function readEventEvidence(event) {
|
|
15995
|
+
const value = event.cost_evidence ?? event.evidence;
|
|
15996
|
+
if (!Array.isArray(value))
|
|
15997
|
+
return legacyEventEvidence(event);
|
|
15998
|
+
return value.slice(0, MAX_EVIDENCE_ITEMS).flatMap((item) => {
|
|
15999
|
+
if (!isRecord(item))
|
|
16000
|
+
return [];
|
|
16001
|
+
const kind = item.kind === "provider_reported" || item.kind === "normalized_estimate" ? item.kind : null;
|
|
16002
|
+
const sourcePath = isCostSourcePath(item.source_path) ? item.source_path : null;
|
|
16003
|
+
const amount = readBoundedReportedCost(item.amount_usd);
|
|
16004
|
+
const usage = isRecord(item.usage) ? readPinnedTokens(item.usage) : { ...ZERO_USAGE };
|
|
16005
|
+
if (!kind || !sourcePath)
|
|
16006
|
+
return [];
|
|
16007
|
+
return [
|
|
16008
|
+
{
|
|
16009
|
+
kind,
|
|
16010
|
+
amount_usd: amount,
|
|
16011
|
+
currency: normalizeCurrency(item.currency),
|
|
16012
|
+
source_path: sourcePath,
|
|
16013
|
+
reason: isCostEvidenceReason(item.reason) ? item.reason : amount === null ? "missing_cost" : "authoritative",
|
|
16014
|
+
usage,
|
|
16015
|
+
model: typeof item.model === "string" ? item.model.slice(0, MAX_COST_STRING_LENGTH) : undefined,
|
|
16016
|
+
digest: boundedDigest(item.digest)
|
|
16017
|
+
}
|
|
16018
|
+
];
|
|
16019
|
+
});
|
|
16020
|
+
}
|
|
16021
|
+
function legacyEventEvidence(event) {
|
|
16022
|
+
const amount = readBoundedReportedCost(event.cost_usd);
|
|
16023
|
+
return [
|
|
16024
|
+
{
|
|
16025
|
+
kind: parseCostSource(event.cost_source) === "estimated" ? "normalized_estimate" : "provider_reported",
|
|
16026
|
+
amount_usd: amount,
|
|
16027
|
+
currency: "USD",
|
|
16028
|
+
source_path: "legacy.cost",
|
|
16029
|
+
reason: amount === null ? "legacy" : "authoritative",
|
|
16030
|
+
usage: {
|
|
16031
|
+
tokens_input: readFiniteNonNegative(event.tokens_input) ?? 0,
|
|
16032
|
+
tokens_output: readFiniteNonNegative(event.tokens_output) ?? 0,
|
|
16033
|
+
tokens_reasoning: readFiniteNonNegative(event.tokens_reasoning) ?? 0,
|
|
16034
|
+
tokens_cache: readFiniteNonNegative(event.tokens_cache) ?? 0
|
|
16035
|
+
}
|
|
16036
|
+
}
|
|
16037
|
+
];
|
|
16038
|
+
}
|
|
16039
|
+
function isCostSourcePath(value) {
|
|
16040
|
+
return value === "assistant.cost" || value === "step-finish.cost" || value === "response.info.cost" || value === "response.cost" || value === "legacy.cost" || value === "pricing.model";
|
|
16041
|
+
}
|
|
16042
|
+
function isCostEvidenceReason(value) {
|
|
16043
|
+
return value === "authoritative" || value === "missing_cost" || value === "invalid_number" || value === "pricing_missing" || value === "unsupported_currency" || value === "conflict" || value === "unbilled" || value === "join_miss" || value === "legacy" || value === "unreadable" || value === "partial";
|
|
16044
|
+
}
|
|
16045
|
+
function costSnapshotDigest(event) {
|
|
16046
|
+
const canonical = JSON.stringify({
|
|
16047
|
+
cost_usd: event.cost_usd ?? null,
|
|
16048
|
+
cost_source: parseCostSource(event.cost_source),
|
|
16049
|
+
tokens_input: readFiniteNonNegative(event.tokens_input) ?? 0,
|
|
16050
|
+
tokens_output: readFiniteNonNegative(event.tokens_output) ?? 0,
|
|
16051
|
+
tokens_reasoning: readFiniteNonNegative(event.tokens_reasoning) ?? 0,
|
|
16052
|
+
tokens_cache: readFiniteNonNegative(event.tokens_cache) ?? 0,
|
|
16053
|
+
cost_evidence: Array.isArray(event.cost_evidence) ? event.cost_evidence.slice(0, MAX_EVIDENCE_ITEMS) : undefined
|
|
16054
|
+
});
|
|
16055
|
+
let hash = 2166136261;
|
|
16056
|
+
for (let i = 0;i < canonical.length; i++)
|
|
16057
|
+
hash = Math.imul(hash ^ canonical.charCodeAt(i), 16777619);
|
|
16058
|
+
return `${(hash >>> 0).toString(16).padStart(8, "0")}${canonical.length.toString(16).padStart(8, "0")}`.slice(0, 32);
|
|
16059
|
+
}
|
|
16060
|
+
function evidenceAuthority(evidence2) {
|
|
16061
|
+
const projection = projectCostEvidence(evidence2);
|
|
16062
|
+
return projection.cost_source === "reported" ? 2 : projection.cost_source === "estimated" ? 1 : 0;
|
|
16063
|
+
}
|
|
16064
|
+
function isCostUpgrade(current, next) {
|
|
16065
|
+
const currentProjection = projectCostEvidence(current);
|
|
16066
|
+
const nextProjection = projectCostEvidence(next);
|
|
16067
|
+
const currentAuthority = evidenceAuthority(current);
|
|
16068
|
+
const nextAuthority = evidenceAuthority(next);
|
|
16069
|
+
if (nextAuthority > currentAuthority)
|
|
16070
|
+
return true;
|
|
16071
|
+
if (nextAuthority < currentAuthority)
|
|
16072
|
+
return false;
|
|
16073
|
+
if (currentProjection.cost_usd !== nextProjection.cost_usd)
|
|
16074
|
+
return true;
|
|
16075
|
+
const currentUsage = current.reduce(mergeUsage, { ...ZERO_USAGE });
|
|
16076
|
+
const nextUsage = next.reduce(mergeUsage, { ...ZERO_USAGE });
|
|
16077
|
+
return Object.keys(currentUsage).some((key) => nextUsage[key] > currentUsage[key]);
|
|
16078
|
+
}
|
|
15793
16079
|
function readTelemetryEvents(directory) {
|
|
15794
16080
|
const swarmDir = path16.join(directory, ".swarm");
|
|
15795
16081
|
const files = [
|
|
15796
16082
|
path16.join(swarmDir, "telemetry.jsonl.1"),
|
|
15797
16083
|
path16.join(swarmDir, "telemetry.jsonl")
|
|
15798
16084
|
];
|
|
15799
|
-
|
|
16085
|
+
let tmpDir;
|
|
16086
|
+
try {
|
|
16087
|
+
tmpDir = fs8.mkdtempSync(path16.join(os.tmpdir(), "telemetry-snapshot-"));
|
|
16088
|
+
} catch {
|
|
16089
|
+
return [{ event: "delegation_cost_join", reason: "unreadable" }];
|
|
16090
|
+
}
|
|
15800
16091
|
const snapshotFiles = [];
|
|
16092
|
+
let telemetryErrors = 0;
|
|
15801
16093
|
try {
|
|
15802
16094
|
for (const file of files) {
|
|
15803
16095
|
if (!fs8.existsSync(file))
|
|
15804
16096
|
continue;
|
|
15805
16097
|
const snap = path16.join(tmpDir, path16.basename(file));
|
|
15806
16098
|
try {
|
|
16099
|
+
const stat3 = fs8.statSync(file);
|
|
16100
|
+
if (!stat3.isFile() || stat3.size > MAX_TELEMETRY_FILE_BYTES) {
|
|
16101
|
+
telemetryErrors++;
|
|
16102
|
+
continue;
|
|
16103
|
+
}
|
|
15807
16104
|
fs8.copyFileSync(file, snap);
|
|
15808
16105
|
snapshotFiles.push(snap);
|
|
15809
|
-
} catch {
|
|
16106
|
+
} catch {
|
|
16107
|
+
telemetryErrors++;
|
|
16108
|
+
}
|
|
15810
16109
|
}
|
|
15811
|
-
} catch {
|
|
16110
|
+
} catch {
|
|
16111
|
+
telemetryErrors++;
|
|
16112
|
+
}
|
|
15812
16113
|
const events = [];
|
|
15813
16114
|
let unreadableSnapshots = 0;
|
|
15814
16115
|
let firstUnreadableReason = "";
|
|
@@ -15831,10 +16132,13 @@ function readTelemetryEvents(directory) {
|
|
|
15831
16132
|
const parsed = JSON.parse(trimmed);
|
|
15832
16133
|
if (isRecord(parsed))
|
|
15833
16134
|
events.push(parsed);
|
|
15834
|
-
} catch {
|
|
16135
|
+
} catch {
|
|
16136
|
+
telemetryErrors++;
|
|
16137
|
+
}
|
|
15835
16138
|
}
|
|
15836
16139
|
}
|
|
15837
16140
|
if (unreadableSnapshots > 0) {
|
|
16141
|
+
telemetryErrors += unreadableSnapshots;
|
|
15838
16142
|
warn(`[cost-accounting] ${unreadableSnapshots} of ${snapshotFiles.length} snapshot file(s) were unreadable; cost totals undercount. First reason: ${firstUnreadableReason}`);
|
|
15839
16143
|
}
|
|
15840
16144
|
try {
|
|
@@ -15845,8 +16149,59 @@ function readTelemetryEvents(directory) {
|
|
|
15845
16149
|
}
|
|
15846
16150
|
fs8.rmdirSync(tmpDir);
|
|
15847
16151
|
} catch {}
|
|
16152
|
+
if (telemetryErrors > 0) {
|
|
16153
|
+
events.push({ event: "delegation_cost_join", reason: "unreadable" });
|
|
16154
|
+
}
|
|
15848
16155
|
return events;
|
|
15849
16156
|
}
|
|
16157
|
+
function readPinnedTokens(record) {
|
|
16158
|
+
const tokens = isRecord(record.tokens) ? record.tokens : isRecord(record.usage) ? record.usage : record;
|
|
16159
|
+
return {
|
|
16160
|
+
tokens_input: readFiniteNonNegative(tokens.tokens_input ?? tokens.input ?? tokens.input_tokens ?? tokens.prompt_tokens) ?? 0,
|
|
16161
|
+
tokens_output: readFiniteNonNegative(tokens.tokens_output ?? tokens.output ?? tokens.output_tokens ?? tokens.completion_tokens) ?? 0,
|
|
16162
|
+
tokens_reasoning: readFiniteNonNegative(tokens.tokens_reasoning ?? tokens.reasoning ?? tokens.reasoning_tokens) ?? 0,
|
|
16163
|
+
tokens_cache: readFiniteNonNegative(tokens.tokens_cache) ?? readCacheTokens(tokens) ?? 0
|
|
16164
|
+
};
|
|
16165
|
+
}
|
|
16166
|
+
function mergeUsage(total, next) {
|
|
16167
|
+
const usage = "usage" in next && next.usage ? next.usage : next;
|
|
16168
|
+
return {
|
|
16169
|
+
tokens_input: Math.max(total.tokens_input, usage.tokens_input),
|
|
16170
|
+
tokens_output: Math.max(total.tokens_output, usage.tokens_output),
|
|
16171
|
+
tokens_reasoning: Math.max(total.tokens_reasoning, usage.tokens_reasoning),
|
|
16172
|
+
tokens_cache: Math.max(total.tokens_cache, usage.tokens_cache)
|
|
16173
|
+
};
|
|
16174
|
+
}
|
|
16175
|
+
function readFiniteNonNegative(value) {
|
|
16176
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
|
|
16177
|
+
}
|
|
16178
|
+
function readBoundedReportedCost(value) {
|
|
16179
|
+
const amount = readFiniteNonNegative(value);
|
|
16180
|
+
return amount !== null && amount <= MAX_PROVIDER_REPORTED_COST_USD ? amount : null;
|
|
16181
|
+
}
|
|
16182
|
+
function normalizeCurrency(value) {
|
|
16183
|
+
if (typeof value !== "string" || value.trim() === "")
|
|
16184
|
+
return "unknown";
|
|
16185
|
+
const currency = value.trim().slice(0, MAX_COST_STRING_LENGTH).toUpperCase();
|
|
16186
|
+
return currency || "unknown";
|
|
16187
|
+
}
|
|
16188
|
+
function hasReportConflict(reports) {
|
|
16189
|
+
const monetary = reports.filter((item) => item.kind === "provider_reported" && item.amount_usd !== null);
|
|
16190
|
+
for (let i = 0;i < monetary.length; i++) {
|
|
16191
|
+
for (let j = i + 1;j < monetary.length; j++) {
|
|
16192
|
+
const left = monetary[i];
|
|
16193
|
+
const right = monetary[j];
|
|
16194
|
+
if (left.currency !== right.currency)
|
|
16195
|
+
return true;
|
|
16196
|
+
if (left.currency === "USD" && !withinCostTolerance(left.amount_usd ?? 0, right.amount_usd ?? 0))
|
|
16197
|
+
return true;
|
|
16198
|
+
}
|
|
16199
|
+
}
|
|
16200
|
+
return false;
|
|
16201
|
+
}
|
|
16202
|
+
function withinCostTolerance(left, right) {
|
|
16203
|
+
return Math.abs(left - right) <= Math.max(0.000000001, Math.max(Math.abs(left), Math.abs(right)) * 0.000001);
|
|
16204
|
+
}
|
|
15850
16205
|
function readNumber(record, keys) {
|
|
15851
16206
|
for (const key of keys) {
|
|
15852
16207
|
const value = record[key];
|
|
@@ -15860,6 +16215,22 @@ function readNumber(record, keys) {
|
|
|
15860
16215
|
}
|
|
15861
16216
|
return null;
|
|
15862
16217
|
}
|
|
16218
|
+
function readCacheTokens(record) {
|
|
16219
|
+
const cacheRecord = isRecord(record.cache) ? record.cache : record;
|
|
16220
|
+
const read = readNumber(cacheRecord, [
|
|
16221
|
+
"read",
|
|
16222
|
+
"cache_read_input_tokens",
|
|
16223
|
+
"cached_input_tokens"
|
|
16224
|
+
]);
|
|
16225
|
+
const write = readNumber(cacheRecord, [
|
|
16226
|
+
"write",
|
|
16227
|
+
"cache_write_input_tokens",
|
|
16228
|
+
"write_input_tokens"
|
|
16229
|
+
]);
|
|
16230
|
+
if (read === null && write === null)
|
|
16231
|
+
return null;
|
|
16232
|
+
return (read ?? 0) + (write ?? 0);
|
|
16233
|
+
}
|
|
15863
16234
|
function isRecord(value) {
|
|
15864
16235
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15865
16236
|
}
|
|
@@ -15882,18 +16253,51 @@ function createEmptySummary() {
|
|
|
15882
16253
|
reported: { delegations: 0, cost_usd: 0 },
|
|
15883
16254
|
estimated: { delegations: 0, cost_usd: 0 },
|
|
15884
16255
|
unavailable: { delegations: 0, cost_usd: 0 }
|
|
15885
|
-
}
|
|
16256
|
+
},
|
|
16257
|
+
total_legacy_usd: 0,
|
|
16258
|
+
conflict_count: 0,
|
|
16259
|
+
legacy_count: 0,
|
|
16260
|
+
join_miss_count: 0,
|
|
16261
|
+
telemetry_error_count: 0,
|
|
16262
|
+
accepted_corrections: 0,
|
|
16263
|
+
rejected_corrections: 0,
|
|
16264
|
+
duplicate_corrections: 0,
|
|
16265
|
+
evidence_status: "complete",
|
|
16266
|
+
currencies: []
|
|
15886
16267
|
};
|
|
15887
16268
|
}
|
|
15888
16269
|
function addDelegationEvent(summary, event) {
|
|
15889
|
-
const
|
|
15890
|
-
const
|
|
15891
|
-
const
|
|
16270
|
+
const legacyCostSource = parseCostSource(event.cost_source);
|
|
16271
|
+
const legacyCost = readNumber(event, ["cost_usd"]) ?? 0;
|
|
16272
|
+
const hasRecord = boundedId(event.record_id ?? event.recordId) !== null;
|
|
16273
|
+
const evidence2 = readEventEvidence(event);
|
|
16274
|
+
const projection = projectCostEvidence(evidence2);
|
|
16275
|
+
const costSource = hasRecord ? projection.cost_source : legacyCostSource;
|
|
16276
|
+
const cost = hasRecord ? projection.cost_usd ?? 0 : legacyCost;
|
|
16277
|
+
if (!hasRecord) {
|
|
16278
|
+
summary.legacy_count++;
|
|
16279
|
+
summary.total_legacy_usd += legacyCost;
|
|
16280
|
+
summary.evidence_status = "inconclusive";
|
|
16281
|
+
}
|
|
16282
|
+
if (projection.evidence_status === "inconclusive")
|
|
16283
|
+
summary.evidence_status = "inconclusive";
|
|
16284
|
+
for (const item of evidence2) {
|
|
16285
|
+
if (item.currency !== "unknown" && !summary.currencies.includes(item.currency))
|
|
16286
|
+
summary.currencies.push(item.currency);
|
|
16287
|
+
}
|
|
16288
|
+
const legacyUsage = {
|
|
15892
16289
|
tokens_input: readNumber(event, ["tokens_input"]) ?? 0,
|
|
15893
16290
|
tokens_output: readNumber(event, ["tokens_output"]) ?? 0,
|
|
15894
16291
|
tokens_reasoning: readNumber(event, ["tokens_reasoning"]) ?? 0,
|
|
15895
16292
|
tokens_cache: readNumber(event, ["tokens_cache"]) ?? 0
|
|
15896
16293
|
};
|
|
16294
|
+
const evidenceUsage = evidence2.reduce((acc, item) => ({
|
|
16295
|
+
tokens_input: Math.max(acc.tokens_input, item.usage.tokens_input),
|
|
16296
|
+
tokens_output: Math.max(acc.tokens_output, item.usage.tokens_output),
|
|
16297
|
+
tokens_reasoning: Math.max(acc.tokens_reasoning, item.usage.tokens_reasoning),
|
|
16298
|
+
tokens_cache: Math.max(acc.tokens_cache, item.usage.tokens_cache)
|
|
16299
|
+
}), { ...ZERO_USAGE });
|
|
16300
|
+
const usage = hasRecord ? evidenceUsage : legacyUsage;
|
|
15897
16301
|
summary.delegations++;
|
|
15898
16302
|
summary.total_cost_usd += cost;
|
|
15899
16303
|
summary.total_input_tokens += usage.tokens_input;
|
|
@@ -15957,6 +16361,7 @@ function finalizeSummary(summary) {
|
|
|
15957
16361
|
summary.total_cost_usd = roundUsd(summary.total_cost_usd);
|
|
15958
16362
|
summary.total_reported_usd = roundUsd(summary.total_reported_usd);
|
|
15959
16363
|
summary.total_estimated_usd = roundUsd(summary.total_estimated_usd);
|
|
16364
|
+
summary.total_legacy_usd = roundUsd(summary.total_legacy_usd);
|
|
15960
16365
|
for (const source of Object.values(summary.by_source)) {
|
|
15961
16366
|
source.cost_usd = roundUsd(source.cost_usd);
|
|
15962
16367
|
}
|
|
@@ -16217,12 +16622,15 @@ async function handleBenchmarkCommand(directory, args) {
|
|
|
16217
16622
|
}
|
|
16218
16623
|
];
|
|
16219
16624
|
if (maxCostUsd !== null) {
|
|
16625
|
+
const costEvidenceComplete = costSummary !== undefined && costSummary.delegations > 0 && costSummary.evidence_status === "complete";
|
|
16220
16626
|
checks.push({
|
|
16221
16627
|
name: "Total cost",
|
|
16222
16628
|
value: costSummary?.total_cost_usd ?? 0,
|
|
16223
16629
|
threshold: maxCostUsd,
|
|
16224
16630
|
operator: "<=",
|
|
16225
|
-
passed: (costSummary?.total_cost_usd ?? 0) <= maxCostUsd
|
|
16631
|
+
passed: costEvidenceComplete && (costSummary?.total_cost_usd ?? 0) <= maxCostUsd,
|
|
16632
|
+
evidence_status: costEvidenceComplete ? "complete" : "inconclusive",
|
|
16633
|
+
reason: costEvidenceComplete ? (costSummary?.total_cost_usd ?? 0) <= maxCostUsd ? undefined : "thresholdExceeded" : "budgetInconclusive"
|
|
16226
16634
|
});
|
|
16227
16635
|
}
|
|
16228
16636
|
if (gateAudit && gateAuditSummary) {
|
|
@@ -16315,6 +16723,10 @@ async function handleBenchmarkCommand(directory, args) {
|
|
|
16315
16723
|
if (ciGate) {
|
|
16316
16724
|
lines.push("### CI Gate", ciGate.passed ? "\u2705 PASSED" : "\u274C FAILED");
|
|
16317
16725
|
for (const c of ciGate.checks) {
|
|
16726
|
+
if (c.name === "Total cost" && c.evidence_status === "inconclusive") {
|
|
16727
|
+
lines.push(`- Total cost: inconclusive (budget evidence unavailable) <= $${c.threshold.toFixed(6)} \u274C`);
|
|
16728
|
+
continue;
|
|
16729
|
+
}
|
|
16318
16730
|
let valueStr;
|
|
16319
16731
|
if (c.name === "Complexity Delta" || c.name === "Public API Delta") {
|
|
16320
16732
|
valueStr = `${c.value}`;
|
|
@@ -16403,7 +16815,9 @@ async function handleBenchmarkCommand(directory, args) {
|
|
|
16403
16815
|
value: c.value,
|
|
16404
16816
|
threshold: c.threshold,
|
|
16405
16817
|
operator: c.operator,
|
|
16406
|
-
passed: c.passed
|
|
16818
|
+
passed: c.passed,
|
|
16819
|
+
...c.evidence_status ? { evidence_status: c.evidence_status } : {},
|
|
16820
|
+
...c.reason ? { reason: c.reason } : {}
|
|
16407
16821
|
}))
|
|
16408
16822
|
};
|
|
16409
16823
|
lines.push("[BENCHMARK_JSON]", JSON.stringify(json, null, 2), "[/BENCHMARK_JSON]");
|
|
@@ -21040,7 +21454,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
|
|
|
21040
21454
|
};
|
|
21041
21455
|
}
|
|
21042
21456
|
async function sweepActiveNearDuplicates(directory, options = {}) {
|
|
21043
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
21457
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-mcan50mx.js");
|
|
21044
21458
|
const { config } = loadPluginConfigWithMeta2(directory);
|
|
21045
21459
|
const sweepConfig = config.learning?.dedup_sweep;
|
|
21046
21460
|
if (sweepConfig?.enabled === false)
|
|
@@ -22170,7 +22584,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
22170
22584
|
}
|
|
22171
22585
|
if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
|
|
22172
22586
|
try {
|
|
22173
|
-
const skillModule = await import("./skill-generator-
|
|
22587
|
+
const skillModule = await import("./skill-generator-6tjyffgd.js");
|
|
22174
22588
|
for (const cand of skillCandidates) {
|
|
22175
22589
|
if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
|
|
22176
22590
|
continue;
|
|
@@ -22642,7 +23056,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
|
|
|
22642
23056
|
} catch {}
|
|
22643
23057
|
}
|
|
22644
23058
|
if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
|
|
22645
|
-
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-
|
|
23059
|
+
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-rxagfxnk.js");
|
|
22646
23060
|
for (const { id } of contradictedEntries) {
|
|
22647
23061
|
try {
|
|
22648
23062
|
await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
|
|
@@ -23461,7 +23875,7 @@ async function runCuratorPostMortem(directory, options = {}) {
|
|
|
23461
23875
|
warnings.push("Failed to collect knowledge summary.");
|
|
23462
23876
|
}
|
|
23463
23877
|
try {
|
|
23464
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
23878
|
+
const { getScanStatus } = await import("./scan-cursor-fasdj7kj.js");
|
|
23465
23879
|
const scanStatus = await getScanStatus(directory);
|
|
23466
23880
|
if (scanStatus.remaining_estimate > 0) {
|
|
23467
23881
|
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.`);
|
|
@@ -23633,9 +24047,9 @@ var _internals27 = {
|
|
|
23633
24047
|
verifyPostMortemKnowledgeActions,
|
|
23634
24048
|
repairPostMortemActions,
|
|
23635
24049
|
loadDefaultKnowledgeConfig: async (directory) => {
|
|
23636
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
24050
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-3x28z3rp.js");
|
|
23637
24051
|
try {
|
|
23638
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
24052
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-mcan50mx.js");
|
|
23639
24053
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
23640
24054
|
return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
23641
24055
|
} catch {
|
|
@@ -23643,11 +24057,11 @@ var _internals27 = {
|
|
|
23643
24057
|
}
|
|
23644
24058
|
},
|
|
23645
24059
|
applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
|
|
23646
|
-
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-
|
|
24060
|
+
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-n81nzdw8.js");
|
|
23647
24061
|
return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
|
|
23648
24062
|
},
|
|
23649
24063
|
checkHivePromotions: async (entries, knowledgeConfig, directory) => {
|
|
23650
|
-
const { checkHivePromotions } = await import("./hive-promoter-
|
|
24064
|
+
const { checkHivePromotions } = await import("./hive-promoter-brq9cx7c.js");
|
|
23651
24065
|
return checkHivePromotions(entries, knowledgeConfig, directory);
|
|
23652
24066
|
},
|
|
23653
24067
|
applyProposalTriage: async (directory, triage) => {
|
|
@@ -23656,7 +24070,7 @@ var _internals27 = {
|
|
|
23656
24070
|
activateProposal,
|
|
23657
24071
|
listSkills: listSkills2,
|
|
23658
24072
|
sanitizeSlug
|
|
23659
|
-
} = await import("./skill-generator-
|
|
24073
|
+
} = await import("./skill-generator-6tjyffgd.js");
|
|
23660
24074
|
const result = {
|
|
23661
24075
|
approved: [],
|
|
23662
24076
|
rejected: [],
|
|
@@ -24986,9 +25400,9 @@ function hashContent(content) {
|
|
|
24986
25400
|
return createHash13("sha1").update(content).digest("hex");
|
|
24987
25401
|
}
|
|
24988
25402
|
async function loadConfigForPolicyCurator(directory) {
|
|
24989
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
25403
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-3x28z3rp.js");
|
|
24990
25404
|
try {
|
|
24991
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
25405
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-mcan50mx.js");
|
|
24992
25406
|
const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
|
|
24993
25407
|
return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
|
|
24994
25408
|
} catch {
|
|
@@ -29042,7 +29456,7 @@ import {
|
|
|
29042
29456
|
existsSync as existsSync19,
|
|
29043
29457
|
mkdirSync as mkdirSync11,
|
|
29044
29458
|
readFileSync as readFileSync16,
|
|
29045
|
-
statSync as
|
|
29459
|
+
statSync as statSync11,
|
|
29046
29460
|
writeFileSync as writeFileSync9
|
|
29047
29461
|
} from "fs";
|
|
29048
29462
|
import { createRequire as createRequire3 } from "module";
|
|
@@ -30726,13 +31140,13 @@ class SQLiteMemoryProvider {
|
|
|
30726
31140
|
}
|
|
30727
31141
|
try {
|
|
30728
31142
|
const wal = `${dbPath}-wal`;
|
|
30729
|
-
const st =
|
|
31143
|
+
const st = statSync11(wal);
|
|
30730
31144
|
if (st.size > 0)
|
|
30731
31145
|
walPath = wal;
|
|
30732
31146
|
} catch {}
|
|
30733
31147
|
try {
|
|
30734
31148
|
const shm = `${dbPath}-shm`;
|
|
30735
|
-
const st =
|
|
31149
|
+
const st = statSync11(shm);
|
|
30736
31150
|
if (st.size > 0)
|
|
30737
31151
|
shmPath = shm;
|
|
30738
31152
|
} catch {}
|
|
@@ -32203,7 +32617,7 @@ init_logger();
|
|
|
32203
32617
|
import * as path39 from "path";
|
|
32204
32618
|
|
|
32205
32619
|
// src/memory/memory-link.ts
|
|
32206
|
-
import { existsSync as existsSync20, mkdirSync as mkdirSync12, readFileSync as readFileSync17, rmSync as rmSync2, statSync as
|
|
32620
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync12, readFileSync as readFileSync17, rmSync as rmSync2, statSync as statSync12 } from "fs";
|
|
32207
32621
|
import * as path38 from "path";
|
|
32208
32622
|
init_logger();
|
|
32209
32623
|
var MEMORY_LINK_POINTER_FILENAME = "memory-link.json";
|
|
@@ -32263,7 +32677,7 @@ var _resolutionCache = new Map;
|
|
|
32263
32677
|
function pointerStatFingerprint(directory) {
|
|
32264
32678
|
const pointerPath = resolveMemoryLinkPointerPath(directory);
|
|
32265
32679
|
try {
|
|
32266
|
-
const st =
|
|
32680
|
+
const st = statSync12(pointerPath);
|
|
32267
32681
|
return `${st.mtimeMs}:${st.ctimeMs}:${st.size}`;
|
|
32268
32682
|
} catch {
|
|
32269
32683
|
return null;
|
|
@@ -37241,7 +37655,7 @@ async function runFinalizeStage(ctx) {
|
|
|
37241
37655
|
}
|
|
37242
37656
|
}
|
|
37243
37657
|
try {
|
|
37244
|
-
const { CuratorConfigSchema: CCS } = await import("./schema-
|
|
37658
|
+
const { CuratorConfigSchema: CCS } = await import("./schema-3x28z3rp.js");
|
|
37245
37659
|
const { config: pmLoadedConfig } = _internals41.loadPluginConfigWithMeta(ctx.directory);
|
|
37246
37660
|
const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
|
|
37247
37661
|
if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
|
|
@@ -38127,7 +38541,7 @@ var _internals41 = {
|
|
|
38127
38541
|
closePlanTerminalState: reconcileCloseTerminalStateForPlan,
|
|
38128
38542
|
endAgentSession,
|
|
38129
38543
|
flushAndDrainTelemetry: async () => {
|
|
38130
|
-
const { flushAndDrainTelemetry } = await import("./telemetry-
|
|
38544
|
+
const { flushAndDrainTelemetry } = await import("./telemetry-3rh94wv3.js");
|
|
38131
38545
|
return flushAndDrainTelemetry();
|
|
38132
38546
|
},
|
|
38133
38547
|
finalizeContextTelemetry: (directory) => {
|
|
@@ -38647,6 +39061,7 @@ function renderCostSummary(summary) {
|
|
|
38647
39061
|
`Delegations: ${summary.delegations}`,
|
|
38648
39062
|
`Tokens: input ${summary.total_input_tokens.toLocaleString()}, output ${summary.total_output_tokens.toLocaleString()}, reasoning ${summary.total_reasoning_tokens.toLocaleString()}, cache ${summary.total_cache_tokens.toLocaleString()}`,
|
|
38649
39063
|
`Cost source: reported ${formatUsd(summary.total_reported_usd)}, estimated ${formatUsd(summary.total_estimated_usd)}, unavailable ${summary.unavailable_delegations}`,
|
|
39064
|
+
`Evidence: ${summary.evidence_status}; joins missed ${summary.join_miss_count}; telemetry errors ${summary.telemetry_error_count}; corrections accepted ${summary.accepted_corrections}, rejected ${summary.rejected_corrections}, duplicate ${summary.duplicate_corrections}`,
|
|
38650
39065
|
"",
|
|
38651
39066
|
"### By Agent"
|
|
38652
39067
|
];
|
|
@@ -39464,9 +39879,9 @@ var _internals45 = {
|
|
|
39464
39879
|
loadPluginConfigWithMeta,
|
|
39465
39880
|
loadCuratorDeps: async () => {
|
|
39466
39881
|
const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
|
|
39467
|
-
import("./schema-
|
|
39468
|
-
import("./curator-
|
|
39469
|
-
import("./curator-llm-factory-
|
|
39882
|
+
import("./schema-3x28z3rp.js"),
|
|
39883
|
+
import("./curator-n81nzdw8.js"),
|
|
39884
|
+
import("./curator-llm-factory-24bfn7h1.js")
|
|
39470
39885
|
]);
|
|
39471
39886
|
return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
|
|
39472
39887
|
}
|
|
@@ -39966,7 +40381,7 @@ ${USAGE9}`;
|
|
|
39966
40381
|
// src/services/diagnose-service.ts
|
|
39967
40382
|
init_package();
|
|
39968
40383
|
import * as child_process5 from "child_process";
|
|
39969
|
-
import { existsSync as existsSync32, readdirSync as readdirSync6, readFileSync as readFileSync23, statSync as
|
|
40384
|
+
import { existsSync as existsSync32, readdirSync as readdirSync6, readFileSync as readFileSync23, statSync as statSync14 } from "fs";
|
|
39970
40385
|
import * as path54 from "path";
|
|
39971
40386
|
import { fileURLToPath } from "url";
|
|
39972
40387
|
|
|
@@ -40475,7 +40890,7 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
40475
40890
|
let scanCompleted = false;
|
|
40476
40891
|
let scanRemaining = 0;
|
|
40477
40892
|
try {
|
|
40478
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
40893
|
+
const { getScanStatus } = await import("./scan-cursor-fasdj7kj.js");
|
|
40479
40894
|
const status = await getScanStatus(directory);
|
|
40480
40895
|
scanGeneration = status.generation;
|
|
40481
40896
|
scanCompleted = status.completed;
|
|
@@ -40483,19 +40898,19 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
40483
40898
|
} catch {}
|
|
40484
40899
|
let configMatch = null;
|
|
40485
40900
|
try {
|
|
40486
|
-
const { isLinked: isLinked2 } = await import("./knowledge-link-
|
|
40901
|
+
const { isLinked: isLinked2 } = await import("./knowledge-link-n1825n09.js");
|
|
40487
40902
|
if (isLinked2(directory)) {
|
|
40488
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
40903
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-3x28z3rp.js");
|
|
40489
40904
|
let config;
|
|
40490
40905
|
try {
|
|
40491
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
40906
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-mcan50mx.js");
|
|
40492
40907
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
40493
40908
|
config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
40494
40909
|
} catch {
|
|
40495
40910
|
config = KnowledgeConfigSchema2.parse({});
|
|
40496
40911
|
}
|
|
40497
40912
|
const { cohortConfigFingerprint: cohortConfigFingerprint2 } = await import("./config-fingerprint-v22xh5a2.js");
|
|
40498
|
-
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-
|
|
40913
|
+
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-z0a5akng.js");
|
|
40499
40914
|
const currentFp = cohortConfigFingerprint2(buildConfigFingerprintInput2(config));
|
|
40500
40915
|
const cohortFp = await readCohortConfigFingerprint(directory);
|
|
40501
40916
|
configMatch = cohortFp === null ? null : currentFp === cohortFp;
|
|
@@ -40902,7 +41317,7 @@ async function checkConfigBackups(directory) {
|
|
|
40902
41317
|
}
|
|
40903
41318
|
async function checkGitRepository(directory) {
|
|
40904
41319
|
try {
|
|
40905
|
-
if (!existsSync32(directory) || !
|
|
41320
|
+
if (!existsSync32(directory) || !statSync14(directory).isDirectory()) {
|
|
40906
41321
|
return {
|
|
40907
41322
|
name: "Git Repository",
|
|
40908
41323
|
status: "\u274C",
|
|
@@ -41808,7 +42223,7 @@ async function handleDoctorCommand(directory, args) {
|
|
|
41808
42223
|
const result = runConfigDoctor(config, directory);
|
|
41809
42224
|
let output;
|
|
41810
42225
|
if (enableAutoFix && result.hasAutoFixableIssues) {
|
|
41811
|
-
const { runConfigDoctorWithFixes } = await import("./config-doctor-
|
|
42226
|
+
const { runConfigDoctorWithFixes } = await import("./config-doctor-00ex0s3k.js");
|
|
41812
42227
|
const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
|
|
41813
42228
|
applyLossy: true
|
|
41814
42229
|
});
|
|
@@ -42748,7 +43163,7 @@ async function handleEvidenceCommand(directory, args) {
|
|
|
42748
43163
|
return formatTaskEvidenceMarkdown(evidenceData);
|
|
42749
43164
|
}
|
|
42750
43165
|
async function handleEvidenceSummaryCommand(directory) {
|
|
42751
|
-
const { buildEvidenceSummary } = await import("./evidence-summary-service-
|
|
43166
|
+
const { buildEvidenceSummary } = await import("./evidence-summary-service-nz7y1w2a.js");
|
|
42752
43167
|
const artifact = await buildEvidenceSummary(directory);
|
|
42753
43168
|
if (!artifact) {
|
|
42754
43169
|
return "No plan found. Run `/swarm plan` to check plan status.";
|
|
@@ -47515,9 +47930,11 @@ function hasBundledRules(projectRoot) {
|
|
|
47515
47930
|
import * as crypto3 from "crypto";
|
|
47516
47931
|
import * as fs26 from "fs";
|
|
47517
47932
|
import * as path62 from "path";
|
|
47518
|
-
var BASELINE_SCHEMA_VERSION = "1.
|
|
47933
|
+
var BASELINE_SCHEMA_VERSION = "1.1.0";
|
|
47934
|
+
var LEGACY_BASELINE_SCHEMA_VERSION = "1.0.0";
|
|
47519
47935
|
var MAX_BASELINE_FINDINGS = 2000;
|
|
47520
47936
|
var MAX_BASELINE_BYTES = 2 * 1048576;
|
|
47937
|
+
var MAX_BLOCKED_LIST = 20;
|
|
47521
47938
|
var LOCK_RETRY_DELAYS_MS = [50, 100, 200, 400, 800];
|
|
47522
47939
|
function normalizeFindingPath(directory, file) {
|
|
47523
47940
|
const resolved = path62.isAbsolute(file) ? file : path62.resolve(directory, file);
|
|
@@ -47576,6 +47993,7 @@ function assignOccurrenceIndices(findings, directory) {
|
|
|
47576
47993
|
const relFile = normalizeFindingPath(directory, finding.location.file);
|
|
47577
47994
|
const lineNum = finding.location.line;
|
|
47578
47995
|
let baseKey;
|
|
47996
|
+
let reflowKey = "";
|
|
47579
47997
|
try {
|
|
47580
47998
|
if (relFile.startsWith(".."))
|
|
47581
47999
|
throw new Error("escapes workspace");
|
|
@@ -47591,6 +48009,8 @@ function assignOccurrenceIndices(findings, directory) {
|
|
|
47591
48009
|
`);
|
|
47592
48010
|
const hash2 = crypto3.createHash("sha256").update(window).digest("hex").slice(0, 16);
|
|
47593
48011
|
baseKey = `${relFile}|${finding.rule_id}|${hash2}`;
|
|
48012
|
+
const lineHash = crypto3.createHash("sha256").update(getLine(lines, idx)).digest("hex").slice(0, 16);
|
|
48013
|
+
reflowKey = `${relFile}|${finding.rule_id}|${lineHash}`;
|
|
47594
48014
|
} catch {
|
|
47595
48015
|
baseKey = `${relFile}|${finding.rule_id}|L${lineNum}|UNSTABLE`;
|
|
47596
48016
|
}
|
|
@@ -47601,10 +48021,38 @@ function assignOccurrenceIndices(findings, directory) {
|
|
|
47601
48021
|
finding,
|
|
47602
48022
|
index: occIdx,
|
|
47603
48023
|
stable: fp.stable,
|
|
47604
|
-
fingerprint: fp.fingerprint
|
|
48024
|
+
fingerprint: fp.fingerprint,
|
|
48025
|
+
reflowKey
|
|
47605
48026
|
};
|
|
47606
48027
|
});
|
|
47607
48028
|
}
|
|
48029
|
+
function partitionAgainstBaseline(indexed, baselineFingerprints, baselineReflowKeys) {
|
|
48030
|
+
const reflowCounts = new Map;
|
|
48031
|
+
for (const key of baselineReflowKeys) {
|
|
48032
|
+
if (!key)
|
|
48033
|
+
continue;
|
|
48034
|
+
reflowCounts.set(key, (reflowCounts.get(key) ?? 0) + 1);
|
|
48035
|
+
}
|
|
48036
|
+
const preExisting = [];
|
|
48037
|
+
const moved = [];
|
|
48038
|
+
const newFindings = [];
|
|
48039
|
+
for (const { finding, stable, fingerprint, reflowKey } of indexed) {
|
|
48040
|
+
if (stable && baselineFingerprints.has(fingerprint)) {
|
|
48041
|
+
preExisting.push(finding);
|
|
48042
|
+
if (reflowKey) {
|
|
48043
|
+
const count = reflowCounts.get(reflowKey) ?? 0;
|
|
48044
|
+
if (count > 0)
|
|
48045
|
+
reflowCounts.set(reflowKey, count - 1);
|
|
48046
|
+
}
|
|
48047
|
+
} else if (stable && reflowKey && (reflowCounts.get(reflowKey) ?? 0) > 0) {
|
|
48048
|
+
reflowCounts.set(reflowKey, (reflowCounts.get(reflowKey) ?? 1) - 1);
|
|
48049
|
+
moved.push(finding);
|
|
48050
|
+
} else {
|
|
48051
|
+
newFindings.push(finding);
|
|
48052
|
+
}
|
|
48053
|
+
}
|
|
48054
|
+
return { preExisting, moved, newFindings };
|
|
48055
|
+
}
|
|
47608
48056
|
async function waitForLockRetry(delayMs, abortSignal) {
|
|
47609
48057
|
if (abortSignal?.aborted)
|
|
47610
48058
|
return false;
|
|
@@ -47695,25 +48143,96 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
47695
48143
|
try {
|
|
47696
48144
|
const raw = fs26.readFileSync(baselinePath, "utf-8");
|
|
47697
48145
|
const parsed = JSON.parse(raw);
|
|
47698
|
-
if (parsed.schema_version === BASELINE_SCHEMA_VERSION) {
|
|
48146
|
+
if (parsed.schema_version === BASELINE_SCHEMA_VERSION || parsed.schema_version === LEGACY_BASELINE_SCHEMA_VERSION) {
|
|
47699
48147
|
existing = parsed;
|
|
47700
48148
|
}
|
|
47701
48149
|
} catch {}
|
|
47702
48150
|
const scannedRelFiles = new Set(scannedFiles.map((f) => normalizeFindingPath(directory, f)));
|
|
47703
48151
|
const indexed = _internals56.assignOccurrenceIndices(findings, directory);
|
|
47704
48152
|
if (existing && !opts?.force) {
|
|
47705
|
-
const prunedFingerprints =
|
|
48153
|
+
const prunedFingerprints = [];
|
|
48154
|
+
const prunedReflowKeys = [];
|
|
48155
|
+
existing.fingerprints.forEach((fp, i) => {
|
|
47706
48156
|
const relFile = fp.slice(0, fp.indexOf("|"));
|
|
47707
|
-
|
|
48157
|
+
if (scannedRelFiles.has(relFile))
|
|
48158
|
+
return;
|
|
48159
|
+
prunedFingerprints.push(fp);
|
|
48160
|
+
prunedReflowKeys.push(existing.reflow_keys?.[i] ?? "");
|
|
47708
48161
|
});
|
|
47709
48162
|
const prunedSnapshot = existing.findings_snapshot.filter((f) => {
|
|
47710
48163
|
return !scannedRelFiles.has(normalizeFindingPath(directory, f.location.file));
|
|
47711
48164
|
});
|
|
47712
48165
|
const prunedFilesIndexed = existing.files_indexed.filter((f) => !scannedRelFiles.has(f));
|
|
48166
|
+
const priorFingerprintSet = new Set;
|
|
48167
|
+
const priorReflowCounts = new Map;
|
|
48168
|
+
existing.fingerprints.forEach((fp, i) => {
|
|
48169
|
+
const relFile = fp.slice(0, fp.indexOf("|"));
|
|
48170
|
+
if (!scannedRelFiles.has(relFile))
|
|
48171
|
+
return;
|
|
48172
|
+
priorFingerprintSet.add(fp);
|
|
48173
|
+
const key = existing.reflow_keys?.[i] ?? "";
|
|
48174
|
+
if (key) {
|
|
48175
|
+
priorReflowCounts.set(key, (priorReflowCounts.get(key) ?? 0) + 1);
|
|
48176
|
+
}
|
|
48177
|
+
});
|
|
48178
|
+
let blockedCount = 0;
|
|
48179
|
+
const blockedList = [];
|
|
48180
|
+
const triageEntries = [];
|
|
48181
|
+
const absorbedAt = new Date().toISOString();
|
|
48182
|
+
const actor = opts?.actor?.trim() ? opts.actor.trim() : "unknown-session";
|
|
48183
|
+
for (const { finding, stable, fingerprint, reflowKey } of indexed) {
|
|
48184
|
+
if (stable && priorFingerprintSet.has(fingerprint)) {
|
|
48185
|
+
if (reflowKey) {
|
|
48186
|
+
const count = priorReflowCounts.get(reflowKey) ?? 0;
|
|
48187
|
+
if (count > 0)
|
|
48188
|
+
priorReflowCounts.set(reflowKey, count - 1);
|
|
48189
|
+
}
|
|
48190
|
+
continue;
|
|
48191
|
+
}
|
|
48192
|
+
if (stable && reflowKey && (priorReflowCounts.get(reflowKey) ?? 0) > 0) {
|
|
48193
|
+
priorReflowCounts.set(reflowKey, (priorReflowCounts.get(reflowKey) ?? 1) - 1);
|
|
48194
|
+
continue;
|
|
48195
|
+
}
|
|
48196
|
+
const relFile = normalizeFindingPath(directory, finding.location.file);
|
|
48197
|
+
if (!opts?.refreshRationale) {
|
|
48198
|
+
blockedCount++;
|
|
48199
|
+
if (blockedList.length < MAX_BLOCKED_LIST) {
|
|
48200
|
+
blockedList.push({
|
|
48201
|
+
fingerprint,
|
|
48202
|
+
rel_file: relFile,
|
|
48203
|
+
rule_id: finding.rule_id
|
|
48204
|
+
});
|
|
48205
|
+
}
|
|
48206
|
+
continue;
|
|
48207
|
+
}
|
|
48208
|
+
triageEntries.push({
|
|
48209
|
+
fingerprint,
|
|
48210
|
+
rel_file: relFile,
|
|
48211
|
+
rule_id: finding.rule_id,
|
|
48212
|
+
rationale: opts.refreshRationale,
|
|
48213
|
+
actor,
|
|
48214
|
+
absorbed_at: absorbedAt
|
|
48215
|
+
});
|
|
48216
|
+
}
|
|
48217
|
+
if (blockedCount > 0) {
|
|
48218
|
+
const sample = blockedList.slice(0, 5);
|
|
48219
|
+
const sampleText = sample.map((b) => `${b.rel_file} (${b.rule_id})`).join(", ");
|
|
48220
|
+
const ellipsis = blockedCount > sample.length ? ", \u2026" : "";
|
|
48221
|
+
return {
|
|
48222
|
+
status: "absorption_blocked",
|
|
48223
|
+
path: baselinePath,
|
|
48224
|
+
blocked: blockedList,
|
|
48225
|
+
message: `capture_baseline would absorb ${blockedCount} finding(s) not present in the prior baseline ` + `(${sampleText}${ellipsis}). ` + `Pass baseline_refresh_rationale to record an audited refresh \u2014 the baseline was left unchanged (fail-closed).`
|
|
48226
|
+
};
|
|
48227
|
+
}
|
|
47713
48228
|
const mergedFingerprints = [
|
|
47714
48229
|
...prunedFingerprints,
|
|
47715
48230
|
...indexed.map((i) => i.fingerprint)
|
|
47716
48231
|
];
|
|
48232
|
+
const mergedReflowKeys = [
|
|
48233
|
+
...prunedReflowKeys,
|
|
48234
|
+
...indexed.map((i) => i.reflowKey)
|
|
48235
|
+
];
|
|
47717
48236
|
const mergedSnapshot = [
|
|
47718
48237
|
...prunedSnapshot,
|
|
47719
48238
|
...indexed.map((i) => i.finding)
|
|
@@ -47725,6 +48244,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
47725
48244
|
const truncated2 = mergedSnapshot.length > MAX_BASELINE_FINDINGS;
|
|
47726
48245
|
const cappedSnapshot2 = truncated2 ? mergedSnapshot.slice(-MAX_BASELINE_FINDINGS) : mergedSnapshot;
|
|
47727
48246
|
const cappedFingerprints2 = truncated2 ? mergedFingerprints.slice(-MAX_BASELINE_FINDINGS) : mergedFingerprints;
|
|
48247
|
+
const cappedReflowKeys2 = truncated2 ? mergedReflowKeys.slice(-MAX_BASELINE_FINDINGS) : mergedReflowKeys;
|
|
47728
48248
|
let cappedFilesIndexed = mergedFilesIndexed;
|
|
47729
48249
|
if (truncated2) {
|
|
47730
48250
|
const survivingFiles = new Set;
|
|
@@ -47734,6 +48254,9 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
47734
48254
|
}
|
|
47735
48255
|
cappedFilesIndexed = Array.from(survivingFiles);
|
|
47736
48256
|
}
|
|
48257
|
+
const cappedFingerprintSet = new Set(cappedFingerprints2);
|
|
48258
|
+
const retainedTriage = (existing.triage_log ?? []).filter((e) => cappedFingerprintSet.has(e.fingerprint));
|
|
48259
|
+
const mergedTriageLog = [...retainedTriage, ...triageEntries].slice(-MAX_BASELINE_FINDINGS);
|
|
47737
48260
|
const now3 = new Date().toISOString();
|
|
47738
48261
|
const bundle2 = {
|
|
47739
48262
|
schema_version: BASELINE_SCHEMA_VERSION,
|
|
@@ -47743,14 +48266,16 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
47743
48266
|
engine,
|
|
47744
48267
|
files_indexed: cappedFilesIndexed,
|
|
47745
48268
|
fingerprints: cappedFingerprints2,
|
|
48269
|
+
reflow_keys: cappedReflowKeys2,
|
|
47746
48270
|
findings_snapshot: cappedSnapshot2,
|
|
48271
|
+
triage_log: mergedTriageLog,
|
|
47747
48272
|
truncated: truncated2
|
|
47748
48273
|
};
|
|
47749
48274
|
const json2 = JSON.stringify(bundle2, null, 2);
|
|
47750
48275
|
if (json2.length > MAX_BASELINE_BYTES) {
|
|
47751
48276
|
return {
|
|
47752
48277
|
status: "error",
|
|
47753
|
-
message: `Baseline would exceed size cap (${json2.length} bytes > ${MAX_BASELINE_BYTES})`
|
|
48278
|
+
message: `Baseline would exceed size cap (${json2.length} bytes > ${MAX_BASELINE_BYTES} bytes)`
|
|
47754
48279
|
};
|
|
47755
48280
|
}
|
|
47756
48281
|
if (opts?.abortSignal?.aborted) {
|
|
@@ -47766,14 +48291,17 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
47766
48291
|
return {
|
|
47767
48292
|
status: "merged",
|
|
47768
48293
|
path: baselinePath,
|
|
47769
|
-
fingerprint_count: cappedFingerprints2.length
|
|
48294
|
+
fingerprint_count: cappedFingerprints2.length,
|
|
48295
|
+
absorbed_finding_count: triageEntries.length
|
|
47770
48296
|
};
|
|
47771
48297
|
}
|
|
47772
48298
|
const newFingerprints = indexed.map((i) => i.fingerprint);
|
|
48299
|
+
const newReflowKeys = indexed.map((i) => i.reflowKey);
|
|
47773
48300
|
const newSnapshot = indexed.map((i) => i.finding);
|
|
47774
48301
|
const truncated = newSnapshot.length > MAX_BASELINE_FINDINGS;
|
|
47775
48302
|
const cappedSnapshot = truncated ? newSnapshot.slice(0, MAX_BASELINE_FINDINGS) : newSnapshot;
|
|
47776
48303
|
const cappedFingerprints = truncated ? newFingerprints.slice(0, MAX_BASELINE_FINDINGS) : newFingerprints;
|
|
48304
|
+
const cappedReflowKeys = truncated ? newReflowKeys.slice(0, MAX_BASELINE_FINDINGS) : newReflowKeys;
|
|
47777
48305
|
const now2 = new Date().toISOString();
|
|
47778
48306
|
const bundle = {
|
|
47779
48307
|
schema_version: BASELINE_SCHEMA_VERSION,
|
|
@@ -47783,7 +48311,9 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
47783
48311
|
engine,
|
|
47784
48312
|
files_indexed: Array.from(scannedRelFiles),
|
|
47785
48313
|
fingerprints: cappedFingerprints,
|
|
48314
|
+
reflow_keys: cappedReflowKeys,
|
|
47786
48315
|
findings_snapshot: cappedSnapshot,
|
|
48316
|
+
triage_log: [],
|
|
47787
48317
|
truncated
|
|
47788
48318
|
};
|
|
47789
48319
|
const json = JSON.stringify(bundle, null, 2);
|
|
@@ -47829,7 +48359,7 @@ function loadBaseline(directory, phase) {
|
|
|
47829
48359
|
try {
|
|
47830
48360
|
const raw = fs26.readFileSync(baselinePath, "utf-8");
|
|
47831
48361
|
const parsed = JSON.parse(raw);
|
|
47832
|
-
if (parsed.schema_version !== BASELINE_SCHEMA_VERSION) {
|
|
48362
|
+
if (parsed.schema_version !== BASELINE_SCHEMA_VERSION && parsed.schema_version !== LEGACY_BASELINE_SCHEMA_VERSION) {
|
|
47833
48363
|
return {
|
|
47834
48364
|
status: "invalid_schema",
|
|
47835
48365
|
errors: [`Unknown schema version: ${String(parsed.schema_version)}`]
|
|
@@ -47841,9 +48371,25 @@ function loadBaseline(directory, phase) {
|
|
|
47841
48371
|
errors: ["Missing or invalid fingerprints array"]
|
|
47842
48372
|
};
|
|
47843
48373
|
}
|
|
48374
|
+
let reflowKeys = [];
|
|
48375
|
+
if (parsed.schema_version === BASELINE_SCHEMA_VERSION) {
|
|
48376
|
+
if (parsed.reflow_keys === undefined) {
|
|
48377
|
+
reflowKeys = [];
|
|
48378
|
+
} else if (!Array.isArray(parsed.reflow_keys) || parsed.reflow_keys.some((k) => typeof k !== "string") || parsed.reflow_keys.length !== parsed.fingerprints.length) {
|
|
48379
|
+
return {
|
|
48380
|
+
status: "invalid_schema",
|
|
48381
|
+
errors: [
|
|
48382
|
+
"reflow_keys must be a string array aligned 1:1 with fingerprints"
|
|
48383
|
+
]
|
|
48384
|
+
};
|
|
48385
|
+
} else {
|
|
48386
|
+
reflowKeys = parsed.reflow_keys;
|
|
48387
|
+
}
|
|
48388
|
+
}
|
|
47844
48389
|
return {
|
|
47845
48390
|
status: "found",
|
|
47846
48391
|
fingerprints: new Set(parsed.fingerprints),
|
|
48392
|
+
reflowKeys,
|
|
47847
48393
|
bundle: parsed
|
|
47848
48394
|
};
|
|
47849
48395
|
} catch (e) {
|
|
@@ -47859,6 +48405,7 @@ function loadBaseline(directory, phase) {
|
|
|
47859
48405
|
var _internals56 = {
|
|
47860
48406
|
fingerprintFinding,
|
|
47861
48407
|
assignOccurrenceIndices,
|
|
48408
|
+
partitionAgainstBaseline,
|
|
47862
48409
|
captureOrMergeBaseline,
|
|
47863
48410
|
loadBaseline
|
|
47864
48411
|
};
|
|
@@ -48199,10 +48746,18 @@ async function sastScan(input, directory, config) {
|
|
|
48199
48746
|
if (abort_signal?.aborted) {
|
|
48200
48747
|
return cancelledScanResult(allFindings, filesScanned);
|
|
48201
48748
|
}
|
|
48202
|
-
const captureResult = await captureOrMergeBaseline(directory, phase, captureFindings, engine, scannedFilePaths, {
|
|
48203
|
-
|
|
48749
|
+
const captureResult = await captureOrMergeBaseline(directory, phase, captureFindings, engine, scannedFilePaths, {
|
|
48750
|
+
abortSignal: abort_signal,
|
|
48751
|
+
refreshRationale: input.baseline_refresh_rationale,
|
|
48752
|
+
actor: input.session_id
|
|
48753
|
+
});
|
|
48754
|
+
const captureStatus = captureResult.status === "written" ? "baseline_captured" : captureResult.status === "merged" ? "baseline_merged" : captureResult.status === "absorption_blocked" ? "baseline_absorption_blocked" : undefined;
|
|
48204
48755
|
if (captureResult.status === "error") {
|
|
48205
48756
|
warn(`SAST Baseline: capture failed \u2014 ${captureResult.message}`);
|
|
48757
|
+
} else if (captureResult.status === "absorption_blocked") {
|
|
48758
|
+
warn(`SAST Baseline: ${captureResult.message}`);
|
|
48759
|
+
} else if (captureResult.status === "merged" && captureResult.absorbed_finding_count > 0) {
|
|
48760
|
+
warn(`SAST Baseline: merged and absorbed ${captureResult.absorbed_finding_count} novel finding(s) ` + "under the supplied refresh rationale. If this capture ran after a gate failure, " + "those findings may be coder-introduced \u2014 verify before proceeding.");
|
|
48206
48761
|
}
|
|
48207
48762
|
const finalFindings2 = allFindings.slice(0, MAX_FINDINGS);
|
|
48208
48763
|
const summary2 = {
|
|
@@ -48230,33 +48785,31 @@ async function sastScan(input, directory, config) {
|
|
|
48230
48785
|
findings: finalFindings2,
|
|
48231
48786
|
summary: summary2,
|
|
48232
48787
|
status: captureStatus,
|
|
48233
|
-
finding_count: captureResult.status
|
|
48788
|
+
finding_count: captureResult.status === "written" || captureResult.status === "merged" ? captureResult.fingerprint_count : undefined,
|
|
48789
|
+
...captureResult.status === "merged" && captureResult.absorbed_finding_count > 0 ? { absorbed_finding_count: captureResult.absorbed_finding_count } : {},
|
|
48234
48790
|
baseline_used: false
|
|
48235
48791
|
};
|
|
48236
48792
|
}
|
|
48237
48793
|
let newFindings;
|
|
48238
48794
|
let preExistingFindings;
|
|
48795
|
+
let movedFindings;
|
|
48239
48796
|
let baselineUsed = false;
|
|
48240
48797
|
let truncatedPreExisting = false;
|
|
48798
|
+
let truncatedMoved = false;
|
|
48241
48799
|
if (phase !== undefined && Number.isInteger(phase) && phase >= 1) {
|
|
48242
48800
|
const baselineResult = loadBaseline(directory, phase);
|
|
48243
48801
|
if (baselineResult.status === "found") {
|
|
48244
48802
|
baselineUsed = true;
|
|
48245
48803
|
const baselineSet = baselineResult.fingerprints;
|
|
48246
48804
|
const indexed = assignOccurrenceIndices(allFindings, directory);
|
|
48247
|
-
const
|
|
48248
|
-
|
|
48249
|
-
for (const { finding, stable, fingerprint } of indexed) {
|
|
48250
|
-
if (!stable || !baselineSet.has(fingerprint)) {
|
|
48251
|
-
rawNew.push(finding);
|
|
48252
|
-
} else {
|
|
48253
|
-
rawPreExisting.push(finding);
|
|
48254
|
-
}
|
|
48255
|
-
}
|
|
48256
|
-
newFindings = rawNew.slice(0, MAX_FINDINGS);
|
|
48805
|
+
const partition = partitionAgainstBaseline(indexed, baselineSet, baselineResult.reflowKeys ?? []);
|
|
48806
|
+
newFindings = partition.newFindings.slice(0, MAX_FINDINGS);
|
|
48257
48807
|
const preExistingBudget = Math.max(0, MAX_FINDINGS - newFindings.length);
|
|
48258
|
-
preExistingFindings =
|
|
48259
|
-
truncatedPreExisting =
|
|
48808
|
+
preExistingFindings = partition.preExisting.slice(0, preExistingBudget);
|
|
48809
|
+
truncatedPreExisting = partition.preExisting.length > preExistingBudget;
|
|
48810
|
+
const movedBudget = Math.max(0, preExistingBudget - preExistingFindings.length);
|
|
48811
|
+
movedFindings = partition.moved.slice(0, movedBudget);
|
|
48812
|
+
truncatedMoved = partition.moved.length > movedBudget;
|
|
48260
48813
|
} else if (baselineResult.status === "invalid_schema") {
|
|
48261
48814
|
warn(`SAST Baseline: could not load baseline for phase ${phase} \u2014 ${baselineResult.errors.join(", ")}. Falling back to legacy behavior.`);
|
|
48262
48815
|
}
|
|
@@ -48271,7 +48824,8 @@ async function sastScan(input, directory, config) {
|
|
|
48271
48824
|
} else {
|
|
48272
48825
|
finalFindings = [
|
|
48273
48826
|
...newFindings ?? [],
|
|
48274
|
-
...preExistingFindings ?? []
|
|
48827
|
+
...preExistingFindings ?? [],
|
|
48828
|
+
...movedFindings ?? []
|
|
48275
48829
|
].slice(0, MAX_FINDINGS);
|
|
48276
48830
|
}
|
|
48277
48831
|
const findingsBySeverity = countBySeverity(finalFindings);
|
|
@@ -48315,6 +48869,7 @@ async function sastScan(input, directory, config) {
|
|
|
48315
48869
|
...baselineUsed && {
|
|
48316
48870
|
new_findings: newFindings,
|
|
48317
48871
|
pre_existing_findings: preExistingFindings,
|
|
48872
|
+
moved_findings: movedFindings,
|
|
48318
48873
|
baseline_used: true
|
|
48319
48874
|
}
|
|
48320
48875
|
}, abort_signal);
|
|
@@ -48328,9 +48883,12 @@ async function sastScan(input, directory, config) {
|
|
|
48328
48883
|
if (baselineUsed) {
|
|
48329
48884
|
result.new_findings = newFindings;
|
|
48330
48885
|
result.pre_existing_findings = preExistingFindings;
|
|
48886
|
+
result.moved_findings = movedFindings;
|
|
48331
48887
|
result.baseline_used = true;
|
|
48332
48888
|
if (truncatedPreExisting)
|
|
48333
48889
|
result.truncated_pre_existing = true;
|
|
48890
|
+
if (truncatedMoved)
|
|
48891
|
+
result.truncated_moved_findings = true;
|
|
48334
48892
|
}
|
|
48335
48893
|
return result;
|
|
48336
48894
|
}
|
|
@@ -48341,8 +48899,9 @@ var sast_scan = createSwarmTool({
|
|
|
48341
48899
|
directory: exports_external.string().describe("Directory to scan for security vulnerabilities"),
|
|
48342
48900
|
changed_files: exports_external.array(exports_external.string()).optional().describe("List of files to scan (leave empty to scan none)"),
|
|
48343
48901
|
severity_threshold: exports_external.enum(["low", "medium", "high", "critical"]).optional().default("medium").describe("Minimum severity that causes failure"),
|
|
48344
|
-
capture_baseline: exports_external.boolean().optional().describe("When true, capture/merge a phase-scoped baseline of pre-existing findings. Requires phase. Subsequent scans with phase only fail on NEW findings."),
|
|
48345
|
-
phase: exports_external.number().int().min(1).optional().describe("Current phase number (positive integer >= 1). Required with capture_baseline. Enables baseline diff when provided on non-capture scans.")
|
|
48902
|
+
capture_baseline: exports_external.boolean().optional().describe("When true, capture/merge a phase-scoped baseline of pre-existing findings. Requires phase. Subsequent scans with phase only fail on NEW findings. Merging findings not previously in the baseline (any file) is BLOCKED unless baseline_refresh_rationale is provided."),
|
|
48903
|
+
phase: exports_external.number().int().min(1).optional().describe("Current phase number (positive integer >= 1). Required with capture_baseline. Enables baseline diff when provided on non-capture scans."),
|
|
48904
|
+
baseline_refresh_rationale: exports_external.string().trim().min(1).max(500).optional().describe('Audited rationale required when capture_baseline would absorb findings not previously in the baseline \u2014 for already-indexed AND first-time files (e.g. "pre-delegation capture for task 2.1; findings verified pre-existing"). Recorded per finding in the baseline triage log. Only meaningful with capture_baseline: true.')
|
|
48346
48905
|
},
|
|
48347
48906
|
execute: async (args, directory, ctx) => {
|
|
48348
48907
|
let safeArgs;
|
|
@@ -48350,12 +48909,14 @@ var sast_scan = createSwarmTool({
|
|
|
48350
48909
|
if (args && typeof args === "object") {
|
|
48351
48910
|
const rawPhase = args.phase;
|
|
48352
48911
|
const rawCapture = args.capture_baseline;
|
|
48912
|
+
const rawRationale = args.baseline_refresh_rationale;
|
|
48353
48913
|
safeArgs = {
|
|
48354
48914
|
directory: args.directory,
|
|
48355
48915
|
changed_files: args.changed_files,
|
|
48356
48916
|
severity_threshold: args.severity_threshold,
|
|
48357
48917
|
phase: typeof rawPhase === "number" && Number.isInteger(rawPhase) && rawPhase >= 1 ? rawPhase : undefined,
|
|
48358
|
-
capture_baseline: typeof rawCapture === "boolean" ? rawCapture : undefined
|
|
48918
|
+
capture_baseline: typeof rawCapture === "boolean" ? rawCapture : undefined,
|
|
48919
|
+
baseline_refresh_rationale: typeof rawRationale === "string" && rawRationale.trim().length >= 1 && rawRationale.trim().length <= 500 ? rawRationale.trim() : undefined
|
|
48359
48920
|
};
|
|
48360
48921
|
} else {
|
|
48361
48922
|
safeArgs = {
|
|
@@ -48363,7 +48924,8 @@ var sast_scan = createSwarmTool({
|
|
|
48363
48924
|
changed_files: undefined,
|
|
48364
48925
|
severity_threshold: undefined,
|
|
48365
48926
|
capture_baseline: undefined,
|
|
48366
|
-
phase: undefined
|
|
48927
|
+
phase: undefined,
|
|
48928
|
+
baseline_refresh_rationale: undefined
|
|
48367
48929
|
};
|
|
48368
48930
|
}
|
|
48369
48931
|
} catch {
|
|
@@ -48372,7 +48934,8 @@ var sast_scan = createSwarmTool({
|
|
|
48372
48934
|
changed_files: undefined,
|
|
48373
48935
|
severity_threshold: undefined,
|
|
48374
48936
|
capture_baseline: undefined,
|
|
48375
|
-
phase: undefined
|
|
48937
|
+
phase: undefined,
|
|
48938
|
+
baseline_refresh_rationale: undefined
|
|
48376
48939
|
};
|
|
48377
48940
|
}
|
|
48378
48941
|
if (safeArgs.directory === undefined) {
|
|
@@ -48398,6 +48961,8 @@ var sast_scan = createSwarmTool({
|
|
|
48398
48961
|
severity_threshold: safeArgs.severity_threshold ?? "medium",
|
|
48399
48962
|
capture_baseline: safeArgs.capture_baseline,
|
|
48400
48963
|
phase: safeArgs.phase,
|
|
48964
|
+
baseline_refresh_rationale: safeArgs.baseline_refresh_rationale,
|
|
48965
|
+
session_id: ctx?.sessionID,
|
|
48401
48966
|
abort_signal: ctx?.abort
|
|
48402
48967
|
};
|
|
48403
48968
|
const result = await _internals57.sastScan(input, directory);
|
|
@@ -50488,7 +51053,7 @@ import {
|
|
|
50488
51053
|
readFileSync as readFileSync32,
|
|
50489
51054
|
renameSync as renameSync12,
|
|
50490
51055
|
rmSync as rmSync7,
|
|
50491
|
-
statSync as
|
|
51056
|
+
statSync as statSync18,
|
|
50492
51057
|
unlinkSync as unlinkSync12,
|
|
50493
51058
|
writeSync
|
|
50494
51059
|
} from "fs";
|
|
@@ -56094,7 +56659,7 @@ var MIN_MAX_CYCLES = 1;
|
|
|
56094
56659
|
var MAX_MAX_CYCLES = 5;
|
|
56095
56660
|
async function readLatestLoopState(directory) {
|
|
56096
56661
|
try {
|
|
56097
|
-
const { readdirSync: readdirSync9, statSync:
|
|
56662
|
+
const { readdirSync: readdirSync9, statSync: statSync20, readFileSync: readFileSync38 } = await import("fs");
|
|
56098
56663
|
const loopDir = `${directory}/.swarm/loop`;
|
|
56099
56664
|
let latestMtime = 0;
|
|
56100
56665
|
let latestPath = null;
|
|
@@ -56105,7 +56670,7 @@ async function readLatestLoopState(directory) {
|
|
|
56105
56670
|
continue;
|
|
56106
56671
|
const statePath = `${loopDir}/${entry.name}/state.json`;
|
|
56107
56672
|
try {
|
|
56108
|
-
const mtime =
|
|
56673
|
+
const mtime = statSync20(statePath).mtimeMs;
|
|
56109
56674
|
if (mtime > latestMtime) {
|
|
56110
56675
|
latestMtime = mtime;
|
|
56111
56676
|
latestPath = statePath;
|
|
@@ -56743,7 +57308,7 @@ import {
|
|
|
56743
57308
|
openSync as openSync13,
|
|
56744
57309
|
readSync as readSync7,
|
|
56745
57310
|
realpathSync as realpathSync8,
|
|
56746
|
-
statSync as
|
|
57311
|
+
statSync as statSync21
|
|
56747
57312
|
} from "fs";
|
|
56748
57313
|
var import_proper_lockfile9 = __toESM(require_proper_lockfile(), 1);
|
|
56749
57314
|
|
|
@@ -74182,12 +74747,16 @@ function autoReviewEvidenceRelativePath(trigger, scopeHash, phase) {
|
|
|
74182
74747
|
}
|
|
74183
74748
|
return path99.join("evidence", "auto-review", `${trigger}-${scopeHash.slice(0, 64)}.json`);
|
|
74184
74749
|
}
|
|
74750
|
+
var _internals89 = {
|
|
74751
|
+
bunWrite,
|
|
74752
|
+
renameSync: fs46.renameSync
|
|
74753
|
+
};
|
|
74185
74754
|
async function persistAutoReviewEvidence(directory, evidence2, options = {}) {
|
|
74186
74755
|
const target = validateSwarmPath(directory, autoReviewEvidenceRelativePath(evidence2.trigger, evidence2.scope.hash, evidence2.phase));
|
|
74187
74756
|
fs46.mkdirSync(path99.dirname(target), { recursive: true });
|
|
74188
74757
|
const tempPath = `${target}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
74189
74758
|
try {
|
|
74190
|
-
await bunWrite(tempPath, `${JSON.stringify(evidence2, null, 2)}
|
|
74759
|
+
await _internals89.bunWrite(tempPath, `${JSON.stringify(evidence2, null, 2)}
|
|
74191
74760
|
`);
|
|
74192
74761
|
const safeTemp = validateSwarmPath(directory, path99.relative(path99.join(directory, ".swarm"), tempPath));
|
|
74193
74762
|
const tempStat = fs46.lstatSync(safeTemp);
|
|
@@ -74203,7 +74772,7 @@ async function persistAutoReviewEvidence(directory, evidence2, options = {}) {
|
|
|
74203
74772
|
if (!revalidatedStat.isFile() || revalidatedStat.isSymbolicLink()) {
|
|
74204
74773
|
throw new Error("auto-review evidence temp path changed before commit");
|
|
74205
74774
|
}
|
|
74206
|
-
|
|
74775
|
+
_internals89.renameSync(revalidatedTemp, safeTarget);
|
|
74207
74776
|
invalidateCachedArtifact(safeTarget);
|
|
74208
74777
|
return safeTarget;
|
|
74209
74778
|
} finally {
|
|
@@ -74450,7 +75019,7 @@ function scopeFreshnessMismatches(reviewed, current) {
|
|
|
74450
75019
|
}
|
|
74451
75020
|
function createScopeVerifier(input, reviewed, maxBytes) {
|
|
74452
75021
|
return async () => {
|
|
74453
|
-
const current = await
|
|
75022
|
+
const current = await _internals90.collectReviewDiff({
|
|
74454
75023
|
directory: input.directory,
|
|
74455
75024
|
selector: input.selector,
|
|
74456
75025
|
maxBytes
|
|
@@ -74459,7 +75028,7 @@ function createScopeVerifier(input, reviewed, maxBytes) {
|
|
|
74459
75028
|
};
|
|
74460
75029
|
}
|
|
74461
75030
|
async function stalePersistenceResult(input, maxBytes, message, modelCalls) {
|
|
74462
|
-
const current = await
|
|
75031
|
+
const current = await _internals90.collectReviewDiff({
|
|
74463
75032
|
directory: input.directory,
|
|
74464
75033
|
selector: input.selector,
|
|
74465
75034
|
maxBytes
|
|
@@ -74746,10 +75315,20 @@ async function dispatchReviewerWithFallback(input, prompt, timeoutMs, promptByte
|
|
|
74746
75315
|
return { result: attempts[0], attempts };
|
|
74747
75316
|
}
|
|
74748
75317
|
function addCost(evidence2, dispatches) {
|
|
75318
|
+
const MAX_REVIEW_COST_EVIDENCE = 32;
|
|
74749
75319
|
evidence2.cost.model_calls = dispatches.length;
|
|
74750
75320
|
evidence2.cost.prompt_bytes = dispatches.reduce((sum, dispatch) => sum + dispatch.promptBytes, 0);
|
|
74751
75321
|
for (const dispatch of dispatches) {
|
|
74752
75322
|
const fields = dispatch.costFields;
|
|
75323
|
+
for (const item of fields?.cost_evidence ?? []) {
|
|
75324
|
+
if (evidence2.cost.cost_evidence.length >= MAX_REVIEW_COST_EVIDENCE)
|
|
75325
|
+
break;
|
|
75326
|
+
evidence2.cost.cost_evidence.push(item);
|
|
75327
|
+
}
|
|
75328
|
+
if (fields?.evidence_status !== "complete") {
|
|
75329
|
+
evidence2.cost.evidence_status = "inconclusive";
|
|
75330
|
+
evidence2.cost.evidence_reason = fields?.evidence_reason ?? "missing_cost";
|
|
75331
|
+
}
|
|
74753
75332
|
evidence2.cost.tokens_input += fields?.tokens_input ?? 0;
|
|
74754
75333
|
evidence2.cost.tokens_output += fields?.tokens_output ?? 0;
|
|
74755
75334
|
evidence2.cost.tokens_reasoning += fields?.tokens_reasoning ?? 0;
|
|
@@ -74798,7 +75377,9 @@ function baseEvidence(input, diff, status) {
|
|
|
74798
75377
|
tokens_reasoning: 0,
|
|
74799
75378
|
tokens_cache: 0,
|
|
74800
75379
|
cost_usd: null,
|
|
74801
|
-
cost_source: "unavailable"
|
|
75380
|
+
cost_source: "unavailable",
|
|
75381
|
+
cost_evidence: [],
|
|
75382
|
+
evidence_status: "complete"
|
|
74802
75383
|
}
|
|
74803
75384
|
};
|
|
74804
75385
|
}
|
|
@@ -74847,7 +75428,7 @@ async function persistErrorResult(input, diff, result, error2, dispatches, promp
|
|
|
74847
75428
|
evidence2.review.error = error2;
|
|
74848
75429
|
addCost(evidence2, dispatches);
|
|
74849
75430
|
try {
|
|
74850
|
-
result.evidencePath = await
|
|
75431
|
+
result.evidencePath = await _internals90.persistEvidence(input.directory, evidence2);
|
|
74851
75432
|
} catch {
|
|
74852
75433
|
if (input.config.final_review.mode === "gate") {
|
|
74853
75434
|
result.blocked = true;
|
|
@@ -74864,7 +75445,7 @@ async function runReviewEngine(input) {
|
|
|
74864
75445
|
const gateMode = input.config.final_review.mode === "gate";
|
|
74865
75446
|
const maxBytes = input.trigger === "task_completion" ? input.config.max_diff_kb * 1024 : input.config.final_review.max_diff_bytes;
|
|
74866
75447
|
const timeoutMs = input.trigger === "task_completion" ? input.config.timeout_ms : input.config.final_review.timeout_ms;
|
|
74867
|
-
const diff = await
|
|
75448
|
+
const diff = await _internals90.collectReviewDiff({
|
|
74868
75449
|
directory: input.directory,
|
|
74869
75450
|
selector: input.selector,
|
|
74870
75451
|
maxBytes
|
|
@@ -74880,7 +75461,7 @@ async function runReviewEngine(input) {
|
|
|
74880
75461
|
evidence3.policy.digest = evidence3.scope.manifest.review_policy_digest;
|
|
74881
75462
|
let evidencePath2;
|
|
74882
75463
|
try {
|
|
74883
|
-
evidencePath2 = await
|
|
75464
|
+
evidencePath2 = await _internals90.persistEvidence(input.directory, evidence3, { verifyCurrent: createScopeVerifier(input, diff, maxBytes) });
|
|
74884
75465
|
} catch (error2) {
|
|
74885
75466
|
if (error2 instanceof ReviewScopeStaleError) {
|
|
74886
75467
|
return stalePersistenceResult(input, maxBytes, "Review scope changed before clean evidence could be committed.", 0);
|
|
@@ -74904,7 +75485,7 @@ async function runReviewEngine(input) {
|
|
|
74904
75485
|
});
|
|
74905
75486
|
const reviewManifest = await materializeAutoReviewManifest(input.directory, diff.manifest, input.config);
|
|
74906
75487
|
if (input.phase !== undefined && (input.trigger === "phase_completion" || input.trigger === "plan_completion")) {
|
|
74907
|
-
const existing =
|
|
75488
|
+
const existing = _internals90.readPhaseEvidence(input.directory, input.phase);
|
|
74908
75489
|
const integrity = existing ? validateAutoReviewEvidenceIntegrity(input.directory, existing, {
|
|
74909
75490
|
scopeHash: diff.scopeHash,
|
|
74910
75491
|
phase: input.phase,
|
|
@@ -75032,7 +75613,7 @@ async function runReviewEngine(input) {
|
|
|
75032
75613
|
validation: byId.get(finding.finding_id)
|
|
75033
75614
|
}));
|
|
75034
75615
|
}
|
|
75035
|
-
const currentScope = await
|
|
75616
|
+
const currentScope = await _internals90.collectReviewDiff({
|
|
75036
75617
|
directory: input.directory,
|
|
75037
75618
|
selector: input.selector,
|
|
75038
75619
|
maxBytes
|
|
@@ -75113,7 +75694,7 @@ async function runReviewEngine(input) {
|
|
|
75113
75694
|
findingValidations: findings.map((finding) => finding.validation).filter((item) => Boolean(item))
|
|
75114
75695
|
});
|
|
75115
75696
|
receiptId = receipt.id;
|
|
75116
|
-
receiptPath = await
|
|
75697
|
+
receiptPath = await _internals90.persistReceipt(input.directory, receipt, {
|
|
75117
75698
|
verifyCurrent: createScopeVerifier(input, diff, maxBytes)
|
|
75118
75699
|
});
|
|
75119
75700
|
evidence2.receipt_path = receiptPath;
|
|
@@ -75143,7 +75724,7 @@ async function runReviewEngine(input) {
|
|
|
75143
75724
|
}
|
|
75144
75725
|
let evidencePath;
|
|
75145
75726
|
try {
|
|
75146
|
-
evidencePath = await
|
|
75727
|
+
evidencePath = await _internals90.persistEvidence(input.directory, evidence2, {
|
|
75147
75728
|
verifyCurrent: createScopeVerifier(input, diff, maxBytes)
|
|
75148
75729
|
});
|
|
75149
75730
|
} catch (error2) {
|
|
@@ -75181,7 +75762,7 @@ async function runReviewEngine(input) {
|
|
|
75181
75762
|
input.injectAdvisory?.(input.sessionID, advisoryMessage(input, result));
|
|
75182
75763
|
return result;
|
|
75183
75764
|
}
|
|
75184
|
-
var
|
|
75765
|
+
var _internals90 = {
|
|
75185
75766
|
collectReviewDiff,
|
|
75186
75767
|
persistEvidence: persistAutoReviewEvidence,
|
|
75187
75768
|
persistReceipt: persistReviewReceipt,
|
|
@@ -75452,7 +76033,7 @@ async function handleReviewCommand(ctx) {
|
|
|
75452
76033
|
} catch (error2) {
|
|
75453
76034
|
return `Review configuration error: ${error2 instanceof Error ? error2.message : String(error2)}`;
|
|
75454
76035
|
}
|
|
75455
|
-
const result = await
|
|
76036
|
+
const result = await _internals91.runReviewEngine({
|
|
75456
76037
|
directory: ctx.directory,
|
|
75457
76038
|
sessionID: ctx.sessionID,
|
|
75458
76039
|
trigger: "manual",
|
|
@@ -75466,10 +76047,10 @@ async function handleReviewCommand(ctx) {
|
|
|
75466
76047
|
validatorModel,
|
|
75467
76048
|
validatorFallbackModels
|
|
75468
76049
|
});
|
|
75469
|
-
const evidence2 =
|
|
76050
|
+
const evidence2 = _internals91.readEvidence(result.evidencePath, ctx.directory);
|
|
75470
76051
|
return parsed.json ? renderJson(result, evidence2, parsed.selector) : renderHuman(result, evidence2, parsed.selector);
|
|
75471
76052
|
}
|
|
75472
|
-
var
|
|
76053
|
+
var _internals91 = {
|
|
75473
76054
|
runReviewEngine,
|
|
75474
76055
|
readEvidence
|
|
75475
76056
|
};
|
|
@@ -75711,7 +76292,7 @@ async function handleRollbackCommand(directory, args) {
|
|
|
75711
76292
|
// src/commands/sdd.ts
|
|
75712
76293
|
import * as fs50 from "fs";
|
|
75713
76294
|
import * as path103 from "path";
|
|
75714
|
-
var
|
|
76295
|
+
var _internals92 = {
|
|
75715
76296
|
writeProjectedSpecSync
|
|
75716
76297
|
};
|
|
75717
76298
|
var SWARM_SPEC_REL = path103.join(".swarm", "spec.md");
|
|
@@ -76111,7 +76692,7 @@ ${USAGE14}`;
|
|
|
76111
76692
|
|
|
76112
76693
|
${USAGE14}`;
|
|
76113
76694
|
}
|
|
76114
|
-
const result2 =
|
|
76695
|
+
const result2 = _internals92.writeProjectedSpecSync(directory, {
|
|
76115
76696
|
source: "speckit",
|
|
76116
76697
|
feature: resolution.feature,
|
|
76117
76698
|
dryRun: parsed.dryRun,
|
|
@@ -76169,7 +76750,7 @@ ${formatList(result2.projection.warnings)}` : ""
|
|
|
76169
76750
|
].join(`
|
|
76170
76751
|
`);
|
|
76171
76752
|
}
|
|
76172
|
-
const result =
|
|
76753
|
+
const result = _internals92.writeProjectedSpecSync(directory, {
|
|
76173
76754
|
changeId: parsed.changeId,
|
|
76174
76755
|
dryRun: parsed.dryRun,
|
|
76175
76756
|
overwrite: parsed.overwrite
|
|
@@ -76314,7 +76895,7 @@ import {
|
|
|
76314
76895
|
openSync as openSync20,
|
|
76315
76896
|
readFileSync as readFileSync46,
|
|
76316
76897
|
renameSync as renameSync16,
|
|
76317
|
-
statSync as
|
|
76898
|
+
statSync as statSync25,
|
|
76318
76899
|
unlinkSync as unlinkSync22,
|
|
76319
76900
|
writeFileSync as writeFileSync18,
|
|
76320
76901
|
writeFileSync as writeFileSyncAsync
|
|
@@ -76396,7 +76977,7 @@ function writeFileFsyncedThenRename(tempPath, targetPath, data) {
|
|
|
76396
76977
|
throw err;
|
|
76397
76978
|
}
|
|
76398
76979
|
}
|
|
76399
|
-
var
|
|
76980
|
+
var _internals93 = {
|
|
76400
76981
|
withEvidenceLock,
|
|
76401
76982
|
writeFileFsyncedThenRename,
|
|
76402
76983
|
writeFileSync: writeFileSyncAsync,
|
|
@@ -76404,7 +76985,7 @@ var _internals92 = {
|
|
|
76404
76985
|
renameSync: renameSync16,
|
|
76405
76986
|
unlinkSync: unlinkSync22,
|
|
76406
76987
|
existsSync: existsSync57,
|
|
76407
|
-
statSync:
|
|
76988
|
+
statSync: statSync25
|
|
76408
76989
|
};
|
|
76409
76990
|
async function appendEvent2(directory, eventInput) {
|
|
76410
76991
|
assertProjectRoot(directory);
|
|
@@ -76415,7 +76996,7 @@ async function appendEvent2(directory, eventInput) {
|
|
|
76415
76996
|
throw new Error(`invalid candidate id: ${eventInput.candidateId}`);
|
|
76416
76997
|
}
|
|
76417
76998
|
const filePath = ledgerPath2(directory, eventInput.skillSlug, eventInput.candidateId);
|
|
76418
|
-
return
|
|
76999
|
+
return _internals93.withEvidenceLock(directory, path104.join(".swarm", "evolution", "skills", eventInput.skillSlug, eventInput.candidateId, "lifecycle.jsonl"), "skill-opt-ledger", "append-skill-opt-event", async () => {
|
|
76419
77000
|
ensureCandidateDir(directory, eventInput.skillSlug, eventInput.candidateId);
|
|
76420
77001
|
const existing = existsSync57(filePath) ? readFileSync46(filePath, "utf8") : "";
|
|
76421
77002
|
const events = parseEventsFromText(existing);
|
|
@@ -76447,8 +77028,8 @@ async function appendEvent2(directory, eventInput) {
|
|
|
76447
77028
|
const validContent = events.map((e) => JSON.stringify(e)).join(`
|
|
76448
77029
|
`) + (events.length > 0 ? `
|
|
76449
77030
|
` : "");
|
|
76450
|
-
|
|
76451
|
-
const verify = parseEventsFromText(
|
|
77031
|
+
_internals93.writeFileFsyncedThenRename(tempPath, filePath, validContent + line);
|
|
77032
|
+
const verify = parseEventsFromText(_internals93.readFileSync(filePath, "utf8"));
|
|
76452
77033
|
const last = verify.length > 0 ? verify[verify.length - 1] : null;
|
|
76453
77034
|
if (!last || last.seq !== event.seq || last.hashAfter !== event.hashAfter) {
|
|
76454
77035
|
throw new Error(`skill-opt ledger append verification failed for candidate ${event.candidateId} seq ${event.seq}`);
|
|
@@ -76552,7 +77133,7 @@ function writeStateProjection(directory, skillSlug, candidateId2, replay) {
|
|
|
76552
77133
|
updatedAt: new Date().toISOString()
|
|
76553
77134
|
};
|
|
76554
77135
|
const tempPath = `${target}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
76555
|
-
|
|
77136
|
+
_internals93.writeFileFsyncedThenRename(tempPath, target, `${JSON.stringify(projection, null, 2)}
|
|
76556
77137
|
`);
|
|
76557
77138
|
}
|
|
76558
77139
|
function writeArtifact(directory, skillSlug, candidateId2, fileName, content) {
|
|
@@ -76560,7 +77141,7 @@ function writeArtifact(directory, skillSlug, candidateId2, fileName, content) {
|
|
|
76560
77141
|
const dir = ensureCandidateDir(directory, skillSlug, candidateId2);
|
|
76561
77142
|
const target = path104.join(dir, fileName);
|
|
76562
77143
|
const tempPath = `${target}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
76563
|
-
|
|
77144
|
+
_internals93.writeFileFsyncedThenRename(tempPath, target, content);
|
|
76564
77145
|
return target;
|
|
76565
77146
|
}
|
|
76566
77147
|
function readArtifact(directory, skillSlug, candidateId2, fileName) {
|
|
@@ -76653,16 +77234,16 @@ function currentCandidateState(directory, skillSlug, candidateId2) {
|
|
|
76653
77234
|
function writeSkillFileAtomic(targetPath, content) {
|
|
76654
77235
|
const tempPath = `${targetPath}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
76655
77236
|
try {
|
|
76656
|
-
|
|
76657
|
-
|
|
77237
|
+
_internals94.writeFileSync(tempPath, content, "utf8");
|
|
77238
|
+
_internals94.renameSync(tempPath, targetPath);
|
|
76658
77239
|
} finally {
|
|
76659
77240
|
try {
|
|
76660
77241
|
if (existsSync58(tempPath))
|
|
76661
|
-
|
|
77242
|
+
_internals94.unlinkSync(tempPath);
|
|
76662
77243
|
} catch {}
|
|
76663
77244
|
}
|
|
76664
77245
|
}
|
|
76665
|
-
var
|
|
77246
|
+
var _internals94 = {
|
|
76666
77247
|
writeFileSync: writeFileSync19,
|
|
76667
77248
|
renameSync: renameSync17,
|
|
76668
77249
|
unlinkSync: unlinkSync23
|
|
@@ -77244,7 +77825,7 @@ function buildGeneratorInputs(args) {
|
|
|
77244
77825
|
}
|
|
77245
77826
|
};
|
|
77246
77827
|
}
|
|
77247
|
-
var
|
|
77828
|
+
var _internals95 = {
|
|
77248
77829
|
draftDeterministic: defaultDeterministicDraft
|
|
77249
77830
|
};
|
|
77250
77831
|
function defaultDeterministicDraft(inputs) {
|
|
@@ -77314,7 +77895,7 @@ function countChangedLines(a, b) {
|
|
|
77314
77895
|
return changed;
|
|
77315
77896
|
}
|
|
77316
77897
|
function draftCandidate(inputs) {
|
|
77317
|
-
const candidate2 =
|
|
77898
|
+
const candidate2 = _internals95.draftDeterministic(inputs);
|
|
77318
77899
|
enforceTrustRegion(candidate2, inputs.budget);
|
|
77319
77900
|
return candidate2;
|
|
77320
77901
|
}
|
|
@@ -77357,7 +77938,7 @@ import * as path108 from "path";
|
|
|
77357
77938
|
// src/hooks/spawn-helper.ts
|
|
77358
77939
|
import * as child_process7 from "child_process";
|
|
77359
77940
|
var WIN32_CMD_BINARIES = new Set(["npm", "npx", "pnpm", "yarn"]);
|
|
77360
|
-
var
|
|
77941
|
+
var _internals96 = {
|
|
77361
77942
|
spawn: child_process7.spawn
|
|
77362
77943
|
};
|
|
77363
77944
|
function spawnAsync(command, cwd, timeoutMs) {
|
|
@@ -77365,7 +77946,7 @@ function spawnAsync(command, cwd, timeoutMs) {
|
|
|
77365
77946
|
try {
|
|
77366
77947
|
const [rawCmd, ...args] = command;
|
|
77367
77948
|
const cmd = process.platform === "win32" && WIN32_CMD_BINARIES.has(rawCmd) && !rawCmd.includes(".") ? `${rawCmd}.cmd` : rawCmd;
|
|
77368
|
-
const proc =
|
|
77949
|
+
const proc = _internals96.spawn(cmd, args, {
|
|
77369
77950
|
cwd,
|
|
77370
77951
|
stdio: ["ignore", "pipe", "pipe"]
|
|
77371
77952
|
});
|
|
@@ -77431,7 +78012,7 @@ function spawnAsync(command, cwd, timeoutMs) {
|
|
|
77431
78012
|
}
|
|
77432
78013
|
|
|
77433
78014
|
// src/services/skill-optimizer/smoke.ts
|
|
77434
|
-
var
|
|
78015
|
+
var _internals97 = {
|
|
77435
78016
|
validateSkillPath,
|
|
77436
78017
|
isSymbolicLink: (p) => {
|
|
77437
78018
|
try {
|
|
@@ -77452,7 +78033,7 @@ var _internals96 = {
|
|
|
77452
78033
|
async function validateSkillSmoke(input) {
|
|
77453
78034
|
const notes = [];
|
|
77454
78035
|
const repoRel = path108.join(".opencode", "skills", "generated", input.skillSlug, "SKILL.md");
|
|
77455
|
-
if (!
|
|
78036
|
+
if (!_internals97.validateSkillPath(repoRel)) {
|
|
77456
78037
|
return {
|
|
77457
78038
|
ok: false,
|
|
77458
78039
|
verdict: "VIOLATED",
|
|
@@ -77461,16 +78042,16 @@ async function validateSkillSmoke(input) {
|
|
|
77461
78042
|
}
|
|
77462
78043
|
const skillRoot = path108.join(input.directory, ".opencode", "skills", "generated", input.skillSlug);
|
|
77463
78044
|
if (existsSync59(skillRoot)) {
|
|
77464
|
-
if (
|
|
78045
|
+
if (_internals97.isSymbolicLink(skillRoot)) {
|
|
77465
78046
|
return {
|
|
77466
78047
|
ok: false,
|
|
77467
78048
|
verdict: "VIOLATED",
|
|
77468
78049
|
notes: ["skill root is a symlink (reparse denied)"]
|
|
77469
78050
|
};
|
|
77470
78051
|
}
|
|
77471
|
-
const realRoot =
|
|
77472
|
-
const realProjectDir =
|
|
77473
|
-
if (
|
|
78052
|
+
const realRoot = _internals97.realpath(skillRoot);
|
|
78053
|
+
const realProjectDir = _internals97.realpath(input.directory);
|
|
78054
|
+
if (_internals97.escapedRoot(realProjectDir, realRoot)) {
|
|
77474
78055
|
return {
|
|
77475
78056
|
ok: false,
|
|
77476
78057
|
verdict: "VIOLATED",
|
|
@@ -77488,7 +78069,7 @@ async function validateSkillSmoke(input) {
|
|
|
77488
78069
|
notes: [`frontmatter: ${fmError}`]
|
|
77489
78070
|
};
|
|
77490
78071
|
}
|
|
77491
|
-
const rejected = await
|
|
78072
|
+
const rejected = await _internals97.isRejectedSkillContent(input.directory, input.skillSlug, input.candidateContent);
|
|
77492
78073
|
if (rejected) {
|
|
77493
78074
|
return {
|
|
77494
78075
|
ok: false,
|
|
@@ -77498,7 +78079,7 @@ async function validateSkillSmoke(input) {
|
|
|
77498
78079
|
]
|
|
77499
78080
|
};
|
|
77500
78081
|
}
|
|
77501
|
-
const evalResult = await
|
|
78082
|
+
const evalResult = await _internals97.evaluateSkillChange({
|
|
77502
78083
|
directory: input.directory,
|
|
77503
78084
|
slug: input.skillSlug,
|
|
77504
78085
|
candidateContent: input.candidateContent,
|
|
@@ -77517,7 +78098,7 @@ async function validateSkillSmoke(input) {
|
|
|
77517
78098
|
notes.push(`phrase-eval passed (score ${evalResult.candidateScore.toFixed(2)})`);
|
|
77518
78099
|
}
|
|
77519
78100
|
if (input.checkCommand && input.checkCommand.length > 0) {
|
|
77520
|
-
const cmdResult = await
|
|
78101
|
+
const cmdResult = await _internals97.spawnAsync(input.checkCommand, input.directory, input.checkTimeoutMs ?? 60000);
|
|
77521
78102
|
if (!cmdResult || cmdResult.exitCode !== 0) {
|
|
77522
78103
|
return {
|
|
77523
78104
|
ok: false,
|
|
@@ -77587,7 +78168,7 @@ async function prepareCandidatePayloads(inputRoot, candidateId2, skillSlug, base
|
|
|
77587
78168
|
candidate2.contentHash = await computeCandidateInputContentHash2(inputRoot, candidate2);
|
|
77588
78169
|
return { baseline, candidate: candidate2 };
|
|
77589
78170
|
}
|
|
77590
|
-
var
|
|
78171
|
+
var _internals98 = {
|
|
77591
78172
|
tryAcquireLock,
|
|
77592
78173
|
emitTelemetry: emit,
|
|
77593
78174
|
evaluateCandidateV1,
|
|
@@ -77595,7 +78176,7 @@ var _internals97 = {
|
|
|
77595
78176
|
};
|
|
77596
78177
|
async function acquireProjectLock(directory) {
|
|
77597
78178
|
assertProjectRoot(directory);
|
|
77598
|
-
const result = await
|
|
78179
|
+
const result = await _internals98.tryAcquireLock(directory, PROJECT_LOCK_PATH, "skill-opt-controller", "project-run");
|
|
77599
78180
|
if (!result.acquired)
|
|
77600
78181
|
return null;
|
|
77601
78182
|
return async () => {
|
|
@@ -77609,7 +78190,7 @@ async function acquireProjectLock(directory) {
|
|
|
77609
78190
|
async function acquireSkillLock(directory, skillSlug) {
|
|
77610
78191
|
assertProjectRoot(directory);
|
|
77611
78192
|
const lockPath = path109.join(".swarm", "evolution", "skills", skillSlug, ".skill.lock");
|
|
77612
|
-
const result = await
|
|
78193
|
+
const result = await _internals98.tryAcquireLock(directory, lockPath, "skill-opt-controller", `skill-${skillSlug}`);
|
|
77613
78194
|
if (!result.acquired)
|
|
77614
78195
|
return null;
|
|
77615
78196
|
return async () => {
|
|
@@ -77806,13 +78387,13 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
|
|
|
77806
78387
|
while (true) {
|
|
77807
78388
|
try {
|
|
77808
78389
|
const evalInputRoot = input.inputRoot ?? input.directory;
|
|
77809
|
-
const { baseline, candidate: candidate2 } = await
|
|
78390
|
+
const { baseline, candidate: candidate2 } = await _internals98.prepareCandidatePayloads(evalInputRoot, candidateId2, input.skillSlug, input.baselineModel, input.candidateModel, baselineContent, candidateContent);
|
|
77810
78391
|
if (!input.dispatcher) {
|
|
77811
78392
|
throw new Error("no evaluation dispatcher available (cannot run validation)");
|
|
77812
78393
|
}
|
|
77813
|
-
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-
|
|
78394
|
+
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-fzgkhx6a.js");
|
|
77814
78395
|
const executor = createModelEvaluationExecutor2(input.dispatcher, input.sessionId);
|
|
77815
|
-
const result = await withProtectedSetIntegrity([evalInputRoot, ...protectedRoots(input.directory)], () =>
|
|
78396
|
+
const result = await withProtectedSetIntegrity([evalInputRoot, ...protectedRoots(input.directory)], () => _internals98.evaluateCandidateV1({
|
|
77816
78397
|
projectRoot: input.directory,
|
|
77817
78398
|
inputRoot: input.inputRoot ?? input.directory,
|
|
77818
78399
|
tasks: input.validationTasks,
|
|
@@ -77870,7 +78451,7 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
|
|
|
77870
78451
|
deadband: input.config.deadband
|
|
77871
78452
|
};
|
|
77872
78453
|
}
|
|
77873
|
-
|
|
78454
|
+
_internals98.emitTelemetry?.("loop_detected", {
|
|
77874
78455
|
skillSlug: input.skillSlug,
|
|
77875
78456
|
reason: message.slice(0, 160),
|
|
77876
78457
|
source: "skill-opt-controller"
|
|
@@ -78725,13 +79306,46 @@ function getCompactionMetrics(sessionId) {
|
|
|
78725
79306
|
}
|
|
78726
79307
|
|
|
78727
79308
|
// src/services/status-service.ts
|
|
78728
|
-
var
|
|
79309
|
+
var _internals99 = {
|
|
78729
79310
|
loadLeanTurboRunState,
|
|
78730
79311
|
hasActiveLeanTurbo,
|
|
78731
79312
|
hasActiveFullAuto,
|
|
78732
79313
|
getActiveFullAutoSessionID,
|
|
78733
|
-
loadFullAutoRunState
|
|
79314
|
+
loadFullAutoRunState,
|
|
79315
|
+
summarizeTelemetryCosts
|
|
78734
79316
|
};
|
|
79317
|
+
var MAX_TRACKED_TELEMETRY_COST_SUMMARIES = 32;
|
|
79318
|
+
var telemetryCostSummaryCache = new Map;
|
|
79319
|
+
function getTelemetryCostSummary(directory) {
|
|
79320
|
+
const stamp = readTelemetryCostStamp(directory);
|
|
79321
|
+
const cached = telemetryCostSummaryCache.get(directory);
|
|
79322
|
+
if (cached && cached.stamp === stamp)
|
|
79323
|
+
return cached.summary;
|
|
79324
|
+
const summary = _internals99.summarizeTelemetryCosts(directory);
|
|
79325
|
+
telemetryCostSummaryCache.set(directory, { stamp, summary });
|
|
79326
|
+
while (telemetryCostSummaryCache.size > MAX_TRACKED_TELEMETRY_COST_SUMMARIES) {
|
|
79327
|
+
const oldest = telemetryCostSummaryCache.keys().next().value;
|
|
79328
|
+
if (oldest === undefined)
|
|
79329
|
+
break;
|
|
79330
|
+
telemetryCostSummaryCache.delete(oldest);
|
|
79331
|
+
}
|
|
79332
|
+
return summary;
|
|
79333
|
+
}
|
|
79334
|
+
function readTelemetryCostStamp(directory) {
|
|
79335
|
+
const swarmDir = path114.join(directory, ".swarm");
|
|
79336
|
+
const files = [
|
|
79337
|
+
path114.join(swarmDir, "telemetry.jsonl.1"),
|
|
79338
|
+
path114.join(swarmDir, "telemetry.jsonl")
|
|
79339
|
+
];
|
|
79340
|
+
return files.map((file) => {
|
|
79341
|
+
try {
|
|
79342
|
+
const stat9 = fsSync4.statSync(file);
|
|
79343
|
+
return stat9.isFile() ? `${stat9.mtimeMs}:${stat9.ctimeMs}:${stat9.size}` : "missing";
|
|
79344
|
+
} catch {
|
|
79345
|
+
return "missing";
|
|
79346
|
+
}
|
|
79347
|
+
}).join("|");
|
|
79348
|
+
}
|
|
78735
79349
|
async function collectBackgroundWorkStatus(directory) {
|
|
78736
79350
|
try {
|
|
78737
79351
|
await maintainBackgroundDelegations(directory, {
|
|
@@ -78999,11 +79613,11 @@ async function getStatusData(directory, agents, sessionId, options) {
|
|
|
78999
79613
|
} catch {
|
|
79000
79614
|
status.memoryCohort = { linked: false };
|
|
79001
79615
|
}
|
|
79002
|
-
status.fullAutoActive =
|
|
79616
|
+
status.fullAutoActive = _internals99.hasActiveFullAuto();
|
|
79003
79617
|
if (status.fullAutoActive) {
|
|
79004
|
-
const sid =
|
|
79618
|
+
const sid = _internals99.getActiveFullAutoSessionID();
|
|
79005
79619
|
if (sid) {
|
|
79006
|
-
const runState =
|
|
79620
|
+
const runState = _internals99.loadFullAutoRunState(directory, sid);
|
|
79007
79621
|
if (runState?.lastEscalation) {
|
|
79008
79622
|
status.fullAutoEscalation = {
|
|
79009
79623
|
reason: runState.lastEscalation.reason,
|
|
@@ -79033,11 +79647,24 @@ async function getStatusData(directory, agents, sessionId, options) {
|
|
|
79033
79647
|
};
|
|
79034
79648
|
}
|
|
79035
79649
|
}
|
|
79036
|
-
|
|
79650
|
+
status = enrichWithLeanTurbo(status, directory);
|
|
79651
|
+
try {
|
|
79652
|
+
const costs = getTelemetryCostSummary(directory);
|
|
79653
|
+
status.costs = {
|
|
79654
|
+
totalCostUsd: costs.total_cost_usd,
|
|
79655
|
+
delegations: costs.delegations,
|
|
79656
|
+
unavailableDelegations: costs.unavailable_delegations,
|
|
79657
|
+
evidenceStatus: costs.evidence_status,
|
|
79658
|
+
conflictCount: costs.conflict_count,
|
|
79659
|
+
joinMissCount: costs.join_miss_count,
|
|
79660
|
+
telemetryErrorCount: costs.telemetry_error_count
|
|
79661
|
+
};
|
|
79662
|
+
} catch {}
|
|
79663
|
+
return status;
|
|
79037
79664
|
}
|
|
79038
79665
|
function enrichWithLeanTurbo(status, directory) {
|
|
79039
79666
|
const turboMode = hasActiveTurboMode();
|
|
79040
|
-
const leanActive =
|
|
79667
|
+
const leanActive = _internals99.hasActiveLeanTurbo();
|
|
79041
79668
|
let turboStrategy = "off";
|
|
79042
79669
|
if (leanActive) {
|
|
79043
79670
|
turboStrategy = "lean";
|
|
@@ -79068,7 +79695,7 @@ function enrichWithLeanTurbo(status, directory) {
|
|
|
79068
79695
|
}
|
|
79069
79696
|
}
|
|
79070
79697
|
if (leanSessionID) {
|
|
79071
|
-
const runState =
|
|
79698
|
+
const runState = _internals99.loadLeanTurboRunState(directory, leanSessionID);
|
|
79072
79699
|
if (runState) {
|
|
79073
79700
|
status.leanTurboPhase = runState.phase;
|
|
79074
79701
|
status.leanMaxParallelCoders = runState.maxParallelCoders;
|
|
@@ -79110,6 +79737,10 @@ function formatStatusMarkdown(status) {
|
|
|
79110
79737
|
`**Tasks**: ${status.completedTasks}/${status.totalTasks} complete`,
|
|
79111
79738
|
`**Agents**: ${status.agentCount} registered`
|
|
79112
79739
|
];
|
|
79740
|
+
if (status.costs && status.costs.delegations > 0) {
|
|
79741
|
+
const evidence2 = status.costs.evidenceStatus === "complete" ? "complete evidence" : `inconclusive evidence (${status.costs.unavailableDelegations} unavailable, ${status.costs.conflictCount} conflicts, ${status.costs.joinMissCount} join misses, ${status.costs.telemetryErrorCount} telemetry errors)`;
|
|
79742
|
+
lines.push("", `**Cost**: $${status.costs.totalCostUsd.toFixed(6)} across ${status.costs.delegations} delegations \u2014 ${evidence2}`);
|
|
79743
|
+
}
|
|
79113
79744
|
if (status.lastActivity) {
|
|
79114
79745
|
const label = status.lastActivity.agoLabel;
|
|
79115
79746
|
const annotation = status.lastActivity.agoLabel !== "never" && status.lastActivity.agoMs !== null && status.lastActivity.agoMs > 120 * 1000 ? " \u26A0\uFE0F possibly stalled" : "";
|
|
@@ -79432,7 +80063,7 @@ init_logger();
|
|
|
79432
80063
|
var TURBO_BYPASS_DISCLOSURE = "Bypassed: Stage B (reviewer + test_engineer) for Tier 0-2 tasks; phase_complete Gates 1-5 " + "(completion-verify, drift-verifier, hallucination-guard, mutation-gate, phase-council). " + "Still enforced: Stage A (lint, imports, pre_check_batch); Tier 3 Stage B; Gate 5b " + "(architecture-supervisor); Gate 6 (final-council); Gate 7 (full-auto).";
|
|
79433
80064
|
|
|
79434
80065
|
// src/commands/turbo.ts
|
|
79435
|
-
var
|
|
80066
|
+
var _internals100 = {
|
|
79436
80067
|
loadPluginConfigWithMeta
|
|
79437
80068
|
};
|
|
79438
80069
|
async function handleTurboCommand(directory, args, sessionID) {
|
|
@@ -79492,7 +80123,7 @@ async function handleTurboCommand(directory, args, sessionID) {
|
|
|
79492
80123
|
if (arg0 === "on") {
|
|
79493
80124
|
let strategy = "standard";
|
|
79494
80125
|
try {
|
|
79495
|
-
const { config } =
|
|
80126
|
+
const { config } = _internals100.loadPluginConfigWithMeta(directory);
|
|
79496
80127
|
if (config.turbo?.strategy === "lean") {
|
|
79497
80128
|
strategy = "lean";
|
|
79498
80129
|
}
|
|
@@ -79589,7 +80220,7 @@ function enableLeanTurbo(session, directory, sessionID) {
|
|
|
79589
80220
|
let maxParallelCoders = 4;
|
|
79590
80221
|
let conflictPolicy = "serialize";
|
|
79591
80222
|
try {
|
|
79592
|
-
const { config } =
|
|
80223
|
+
const { config } = _internals100.loadPluginConfigWithMeta(directory);
|
|
79593
80224
|
const leanConfig = config.turbo?.lean;
|
|
79594
80225
|
if (leanConfig) {
|
|
79595
80226
|
maxParallelCoders = leanConfig.max_parallel_coders ?? 4;
|
|
@@ -79797,7 +80428,7 @@ function findSimilarCommands(query) {
|
|
|
79797
80428
|
}
|
|
79798
80429
|
const scored = VALID_COMMANDS.map((cmd) => {
|
|
79799
80430
|
const cmdLower = cmd.toLowerCase();
|
|
79800
|
-
const fullScore =
|
|
80431
|
+
const fullScore = _internals101.levenshteinDistance(q, cmdLower);
|
|
79801
80432
|
let tokenScore = Infinity;
|
|
79802
80433
|
if (cmd.includes(" ") || cmd.includes("-")) {
|
|
79803
80434
|
const qTokens = q.split(/[\s-]+/);
|
|
@@ -79810,7 +80441,7 @@ function findSimilarCommands(query) {
|
|
|
79810
80441
|
for (const ct of cmdTokens) {
|
|
79811
80442
|
if (ct.length === 0)
|
|
79812
80443
|
continue;
|
|
79813
|
-
const dist =
|
|
80444
|
+
const dist = _internals101.levenshteinDistance(qt, ct);
|
|
79814
80445
|
if (dist < minDist)
|
|
79815
80446
|
minDist = dist;
|
|
79816
80447
|
}
|
|
@@ -79820,7 +80451,7 @@ function findSimilarCommands(query) {
|
|
|
79820
80451
|
}
|
|
79821
80452
|
const dashStrippedQ = q.replace(/-/g, "");
|
|
79822
80453
|
const dashStrippedCmd = cmdLower.replace(/-/g, "");
|
|
79823
|
-
const dashScore =
|
|
80454
|
+
const dashScore = _internals101.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
|
|
79824
80455
|
const score = Math.min(fullScore, tokenScore, dashScore);
|
|
79825
80456
|
return { cmd, score };
|
|
79826
80457
|
});
|
|
@@ -79855,16 +80486,16 @@ function buildDetailedHelp(commandName, entry) {
|
|
|
79855
80486
|
async function handleHelpCommand(ctx) {
|
|
79856
80487
|
const targetCommand = ctx.args.join(" ");
|
|
79857
80488
|
if (!targetCommand) {
|
|
79858
|
-
const { buildHelpText } = await import("./index-
|
|
80489
|
+
const { buildHelpText } = await import("./index-k7kvrwbj.js");
|
|
79859
80490
|
return buildHelpText();
|
|
79860
80491
|
}
|
|
79861
80492
|
const tokens = targetCommand.split(/\s+/);
|
|
79862
|
-
const resolved =
|
|
80493
|
+
const resolved = _internals101.resolveCommand(tokens);
|
|
79863
80494
|
if (resolved) {
|
|
79864
|
-
return
|
|
80495
|
+
return _internals101.buildDetailedHelp(resolved.key, resolved.entry);
|
|
79865
80496
|
}
|
|
79866
|
-
const similar =
|
|
79867
|
-
const { buildHelpText: fullHelp } = await import("./index-
|
|
80497
|
+
const similar = _internals101.findSimilarCommands(targetCommand);
|
|
80498
|
+
const { buildHelpText: fullHelp } = await import("./index-k7kvrwbj.js");
|
|
79868
80499
|
if (similar.length > 0) {
|
|
79869
80500
|
return `Command '/swarm ${targetCommand}' not found.
|
|
79870
80501
|
|
|
@@ -80126,7 +80757,7 @@ var COMMAND_REGISTRY = {
|
|
|
80126
80757
|
toolNoArgs: true
|
|
80127
80758
|
},
|
|
80128
80759
|
help: {
|
|
80129
|
-
handler: (ctx) =>
|
|
80760
|
+
handler: (ctx) => _internals101.handleHelpCommand(ctx),
|
|
80130
80761
|
description: "Show help for swarm commands",
|
|
80131
80762
|
category: "core",
|
|
80132
80763
|
args: "[command]",
|
|
@@ -80195,7 +80826,7 @@ var COMMAND_REGISTRY = {
|
|
|
80195
80826
|
},
|
|
80196
80827
|
"guardrail explain": {
|
|
80197
80828
|
handler: async (ctx) => {
|
|
80198
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
80829
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-b3k9xrx9.js");
|
|
80199
80830
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
80200
80831
|
},
|
|
80201
80832
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -80205,7 +80836,7 @@ var COMMAND_REGISTRY = {
|
|
|
80205
80836
|
},
|
|
80206
80837
|
"guardrail reset": {
|
|
80207
80838
|
handler: async (ctx) => {
|
|
80208
|
-
const { handleGuardrailReset } = await import("./guardrail-reset-
|
|
80839
|
+
const { handleGuardrailReset } = await import("./guardrail-reset-0ft2gf03.js");
|
|
80209
80840
|
return handleGuardrailReset(ctx.args, ctx.sessionID);
|
|
80210
80841
|
},
|
|
80211
80842
|
description: "Reset one exact active invocation/action circuit after repair",
|
|
@@ -80214,7 +80845,7 @@ var COMMAND_REGISTRY = {
|
|
|
80214
80845
|
},
|
|
80215
80846
|
"guardrail-explain": {
|
|
80216
80847
|
handler: async (ctx) => {
|
|
80217
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
80848
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-b3k9xrx9.js");
|
|
80218
80849
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
80219
80850
|
},
|
|
80220
80851
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -80224,7 +80855,7 @@ var COMMAND_REGISTRY = {
|
|
|
80224
80855
|
},
|
|
80225
80856
|
"guardrail-reset": {
|
|
80226
80857
|
handler: async (ctx) => {
|
|
80227
|
-
const { handleGuardrailReset } = await import("./guardrail-reset-
|
|
80858
|
+
const { handleGuardrailReset } = await import("./guardrail-reset-0ft2gf03.js");
|
|
80228
80859
|
return handleGuardrailReset(ctx.args, ctx.sessionID);
|
|
80229
80860
|
},
|
|
80230
80861
|
description: "Reset one exact active invocation/action circuit after repair",
|
|
@@ -80234,7 +80865,7 @@ var COMMAND_REGISTRY = {
|
|
|
80234
80865
|
},
|
|
80235
80866
|
"guardrail-log": {
|
|
80236
80867
|
handler: async (ctx) => {
|
|
80237
|
-
const { handleGuardrailLog } = await import("./guardrail-log-
|
|
80868
|
+
const { handleGuardrailLog } = await import("./guardrail-log-t8c7acxg.js");
|
|
80238
80869
|
return handleGuardrailLog(ctx.directory, ctx.args);
|
|
80239
80870
|
},
|
|
80240
80871
|
description: "Read the guardrail decision log (use --blocks-only for blocks)",
|
|
@@ -81240,7 +81871,7 @@ function validateToolPolicy() {
|
|
|
81240
81871
|
}
|
|
81241
81872
|
return { valid: warnings.length === 0, warnings };
|
|
81242
81873
|
}
|
|
81243
|
-
var
|
|
81874
|
+
var _internals101 = {
|
|
81244
81875
|
handleHelpCommand,
|
|
81245
81876
|
validateAliases,
|
|
81246
81877
|
validateToolPolicy,
|
|
@@ -81250,16 +81881,16 @@ var _internals100 = {
|
|
|
81250
81881
|
findSimilarCommands,
|
|
81251
81882
|
buildDetailedHelp
|
|
81252
81883
|
};
|
|
81253
|
-
var validation =
|
|
81884
|
+
var validation = _internals101.validateAliases();
|
|
81254
81885
|
if (!validation.valid) {
|
|
81255
81886
|
throw new Error(`COMMAND_REGISTRY alias validation failed:
|
|
81256
81887
|
${validation.errors.join(`
|
|
81257
81888
|
`)}`);
|
|
81258
81889
|
}
|
|
81259
|
-
|
|
81890
|
+
_internals101.emitValidationWarnings("COMMAND_REGISTRY alias warnings", validation.warnings);
|
|
81260
81891
|
try {
|
|
81261
|
-
const toolPolicyValidation =
|
|
81262
|
-
|
|
81892
|
+
const toolPolicyValidation = _internals101.validateToolPolicy();
|
|
81893
|
+
_internals101.emitValidationWarnings("COMMAND_REGISTRY toolPolicy warnings", toolPolicyValidation.warnings);
|
|
81263
81894
|
} catch (e) {
|
|
81264
81895
|
warn(`COMMAND_REGISTRY toolPolicy validation failed (non-fatal): ${e.message}`);
|
|
81265
81896
|
}
|
|
@@ -83191,7 +83822,7 @@ function formatCommandNotFound(tokens) {
|
|
|
83191
83822
|
const attemptedCommand = tokens[0] || "";
|
|
83192
83823
|
const MAX_DISPLAY = 100;
|
|
83193
83824
|
const displayCommand = attemptedCommand.length > MAX_DISPLAY ? `${attemptedCommand.slice(0, MAX_DISPLAY)}...` : attemptedCommand;
|
|
83194
|
-
const similar =
|
|
83825
|
+
const similar = _internals101.findSimilarCommands(attemptedCommand);
|
|
83195
83826
|
const header = `Command \`/swarm ${displayCommand}\` not found.`;
|
|
83196
83827
|
const suggestions = similar.length > 0 ? `Did you mean:
|
|
83197
83828
|
${similar.map((cmd) => ` - /swarm ${cmd}`).join(`
|
|
@@ -86227,7 +86858,7 @@ function getDisplayFinalPromptPressure() {
|
|
|
86227
86858
|
async function rehydratePrSubscriptions(sessionID, directory) {
|
|
86228
86859
|
const map = new Map;
|
|
86229
86860
|
try {
|
|
86230
|
-
const { listActive: listActive2 } = await import("./pr-subscriptions-
|
|
86861
|
+
const { listActive: listActive2 } = await import("./pr-subscriptions-pxv24d5k.js");
|
|
86231
86862
|
const records = await listActive2(directory);
|
|
86232
86863
|
for (const record of records) {
|
|
86233
86864
|
if (record.sessionID !== sessionID)
|
|
@@ -86432,7 +87063,7 @@ async function createSessionWithinBudget(promise, label, onLateResolve) {
|
|
|
86432
87063
|
}
|
|
86433
87064
|
}, () => {});
|
|
86434
87065
|
try {
|
|
86435
|
-
return await withTimeout(promise,
|
|
87066
|
+
return await withTimeout(promise, _internals103.worktreeSessionCreateTimeoutMs, new Error(`${label} deadline expired after ${_internals103.worktreeSessionCreateTimeoutMs}ms`));
|
|
86436
87067
|
} catch (error2) {
|
|
86437
87068
|
timedOut = true;
|
|
86438
87069
|
throw error2;
|
|
@@ -86570,8 +87201,8 @@ var WORKTREE_LIST_TIMEOUT_MS = 15000;
|
|
|
86570
87201
|
async function preProvisionCollisionCheck(taskId, directory, _sessionId) {
|
|
86571
87202
|
let proc;
|
|
86572
87203
|
try {
|
|
86573
|
-
proc =
|
|
86574
|
-
|
|
87204
|
+
proc = _internals103.bunSpawn([
|
|
87205
|
+
_internals103.resolveGitExecutable(),
|
|
86575
87206
|
"-C",
|
|
86576
87207
|
directory,
|
|
86577
87208
|
"worktree",
|
|
@@ -86673,13 +87304,13 @@ function isLaneOwnedByCurrentSession(branchName, expectedSessionId) {
|
|
|
86673
87304
|
return extracted === expectedSessionId;
|
|
86674
87305
|
}
|
|
86675
87306
|
async function inspectStandardWorktreeCollisionOwnership(identity) {
|
|
86676
|
-
const collisionOwnership = await import("./worktree-collision-ownership-
|
|
87307
|
+
const collisionOwnership = await import("./worktree-collision-ownership-3bbn1n2r.js");
|
|
86677
87308
|
return collisionOwnership.inspectStandardWorktreeCollisionOwnership(identity);
|
|
86678
87309
|
}
|
|
86679
87310
|
async function runRecoveryGit(directory, args, timeoutMs = 15000) {
|
|
86680
87311
|
let proc;
|
|
86681
87312
|
try {
|
|
86682
|
-
proc =
|
|
87313
|
+
proc = _internals103.bunSpawn([_internals103.resolveGitExecutable(), "-C", directory, ...args], {
|
|
86683
87314
|
stdin: "ignore",
|
|
86684
87315
|
stdout: "pipe",
|
|
86685
87316
|
stderr: "pipe",
|
|
@@ -86742,7 +87373,7 @@ async function publishRecoveryAuthorityForSettlement(input) {
|
|
|
86742
87373
|
if (input.dispatch.recoveryClaim || !input.provenance) {
|
|
86743
87374
|
return { ok: true };
|
|
86744
87375
|
}
|
|
86745
|
-
const identity = await
|
|
87376
|
+
const identity = await _internals103.buildWorktreeRecoveryPublishIdentity({
|
|
86746
87377
|
directory: input.directory,
|
|
86747
87378
|
dispatch: input.dispatch,
|
|
86748
87379
|
taskId: input.taskId,
|
|
@@ -86756,7 +87387,7 @@ async function publishRecoveryAuthorityForSettlement(input) {
|
|
|
86756
87387
|
reason: "worktree recovery publish identity could not be derived from the merge provenance"
|
|
86757
87388
|
};
|
|
86758
87389
|
}
|
|
86759
|
-
const published =
|
|
87390
|
+
const published = _internals103.publishWorktreeRecoveryAuthority(input.directory, identity);
|
|
86760
87391
|
return published.ok ? { ok: true } : { ok: false, code: published.code, reason: published.reason };
|
|
86761
87392
|
}
|
|
86762
87393
|
function isExactRecoveryClaimantStillActive(authority) {
|
|
@@ -86818,12 +87449,12 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
86818
87449
|
})
|
|
86819
87450
|
};
|
|
86820
87451
|
let recoveryLaunch;
|
|
86821
|
-
const lifecycleLock = await
|
|
87452
|
+
const lifecycleLock = await _internals103.tryAcquireWorktreeLifecycleLock(args.directory, WORKTREE_LIFECYCLE_LOCK_FILE, "worktree-provisioning", args.taskId);
|
|
86822
87453
|
if (!lifecycleLock.acquired) {
|
|
86823
87454
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, "STANDARD_WORKTREE_LIFECYCLE_BUSY: init orphan recovery is active; retry this coder dispatch after recovery completes.");
|
|
86824
87455
|
}
|
|
86825
87456
|
try {
|
|
86826
|
-
const collision = await
|
|
87457
|
+
const collision = await _internals103.preProvisionCollisionCheck(args.taskId, args.directory, args.parentSessionID);
|
|
86827
87458
|
if (collision.uncertainty) {
|
|
86828
87459
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `STANDARD_WORKTREE_COLLISION_SCAN_UNCERTAIN: ${collision.uncertainty}. Destructive cleanup and provisioning were blocked.`);
|
|
86829
87460
|
}
|
|
@@ -86832,17 +87463,17 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
86832
87463
|
const ownerInfo = collision.ownerSessionId ? ` owned by session ${collision.ownerSessionId}` : " with uncertain ownership";
|
|
86833
87464
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `PREPROVISION_COLLISION: task ${args.taskId} already has a lane on branch ${collision.existingBranch ?? "unknown"}${ownerInfo}; cleanup and provisioning were blocked.`);
|
|
86834
87465
|
}
|
|
86835
|
-
for (const dispatch of
|
|
87466
|
+
for (const dispatch of _internals103.standardWorktreeByCallID.values()) {
|
|
86836
87467
|
if (dispatch.handle.branchName === collision.existingBranch) {
|
|
86837
87468
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `PREPROVISION_COLLISION_ACTIVE: branch ${collision.existingBranch} is still tracked by an active standard-worktree dispatch.`);
|
|
86838
87469
|
}
|
|
86839
87470
|
}
|
|
86840
|
-
for (const record of
|
|
87471
|
+
for (const record of _internals103.awaitingMergeByCallID.values()) {
|
|
86841
87472
|
if (record.branch === collision.existingBranch) {
|
|
86842
87473
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `PREPROVISION_COLLISION_AWAITING_MERGE: branch ${collision.existingBranch} is still awaiting merge-back.`);
|
|
86843
87474
|
}
|
|
86844
87475
|
}
|
|
86845
|
-
const recoveryCandidate = maybeSelectRecoverableAuthority(
|
|
87476
|
+
const recoveryCandidate = maybeSelectRecoverableAuthority(_internals103.lookupWorktreeRecoveryAuthoritiesByTask(args.directory, {
|
|
86846
87477
|
parentSessionId: args.parentSessionID,
|
|
86847
87478
|
taskId: resolveRecoveryTaskId(args)
|
|
86848
87479
|
}), collision);
|
|
@@ -86853,7 +87484,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
86853
87484
|
let recoveredChildSessionId = "";
|
|
86854
87485
|
let claimed;
|
|
86855
87486
|
try {
|
|
86856
|
-
claimed = await
|
|
87487
|
+
claimed = await _internals103.claimWorktreeRecoveryAuthority(args.directory, {
|
|
86857
87488
|
authorityDigest: recoveryCandidate.authority.authorityDigest,
|
|
86858
87489
|
claimantCallID: args.callID,
|
|
86859
87490
|
claimantSessionId: args.parentSessionID,
|
|
@@ -86913,7 +87544,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
86913
87544
|
}
|
|
86914
87545
|
});
|
|
86915
87546
|
} catch (error2) {
|
|
86916
|
-
|
|
87547
|
+
_internals103.replayWorktreeRecoveryClaimJournal(args.directory);
|
|
86917
87548
|
if (recoveredChildSessionId) {
|
|
86918
87549
|
await teardownEphemeralSession(client.session, recoveredChildSessionId);
|
|
86919
87550
|
}
|
|
@@ -86950,7 +87581,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
86950
87581
|
};
|
|
86951
87582
|
}
|
|
86952
87583
|
if (!recoveryLaunch) {
|
|
86953
|
-
const ownership = await
|
|
87584
|
+
const ownership = await _internals103.inspectStandardWorktreeCollisionOwnership({
|
|
86954
87585
|
directory: args.directory,
|
|
86955
87586
|
parentSessionId: args.parentSessionID,
|
|
86956
87587
|
taskId: args.taskId,
|
|
@@ -86975,31 +87606,31 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
86975
87606
|
}
|
|
86976
87607
|
}
|
|
86977
87608
|
if (collisionPathExists) {
|
|
86978
|
-
const preserveResult = await
|
|
87609
|
+
const preserveResult = await _internals103.preserveDirtyWorktreeAtPath(collision.worktreePath, collision.existingBranch, "denied", args.directory, worktreeConfig.worktree_dir);
|
|
86979
87610
|
if (preserveResult.outcome === "preserve-failed") {
|
|
86980
87611
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `STANDARD_WORKTREE_PRESERVATION_FAILED_ABORT_CLEANUP: pre-provision collision for task ${args.taskId} could not be preserved (${preserveResult.error}). Cleanup and provisioning were blocked.`);
|
|
86981
87612
|
}
|
|
86982
|
-
const removeResult = await
|
|
87613
|
+
const removeResult = await _internals103.removeWorktree(collision.worktreePath, args.directory, { force: true, worktreeDir: worktreeConfig.worktree_dir });
|
|
86983
87614
|
if ("error" in removeResult) {
|
|
86984
87615
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `STANDARD_WORKTREE_COLLISION_REMOVE_FAILED: ${removeResult.error}. Provisioning was blocked.`);
|
|
86985
87616
|
}
|
|
86986
|
-
const cleanupResult = await
|
|
87617
|
+
const cleanupResult = await _internals103.postMergeCleanup(args.directory, collision.existingBranch);
|
|
86987
87618
|
if ("error" in cleanupResult) {
|
|
86988
87619
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `STANDARD_WORKTREE_COLLISION_BRANCH_CLEANUP_FAILED: ${cleanupResult.error}. Provisioning was blocked.`);
|
|
86989
87620
|
}
|
|
86990
87621
|
} else {
|
|
86991
|
-
const pruneResult = await
|
|
87622
|
+
const pruneResult = await _internals103.pruneStaleWorktreeMetadata(args.directory);
|
|
86992
87623
|
if ("error" in pruneResult) {
|
|
86993
87624
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `STANDARD_WORKTREE_COLLISION_PRUNE_FAILED: ${pruneResult.error}. Provisioning was blocked without deleting the lane branch.`);
|
|
86994
87625
|
}
|
|
86995
87626
|
}
|
|
86996
|
-
const verification = await
|
|
87627
|
+
const verification = await _internals103.preProvisionCollisionCheck(args.taskId, args.directory, args.parentSessionID);
|
|
86997
87628
|
if (verification.uncertainty || verification.collision) {
|
|
86998
87629
|
hardStopStandardWorktreeLifecycle(args.parentSessionID, `STANDARD_WORKTREE_COLLISION_CLEANUP_UNVERIFIED: ${verification.uncertainty ?? "git still reports the colliding lane after cleanup"}. Provisioning was blocked.`);
|
|
86999
87630
|
}
|
|
87000
87631
|
}
|
|
87001
87632
|
}
|
|
87002
|
-
|
|
87633
|
+
_internals103.recordWorktreeProvisioningOwner(args.directory, {
|
|
87003
87634
|
callID: args.callID,
|
|
87004
87635
|
parentSessionId: args.parentSessionID,
|
|
87005
87636
|
worktreeSessionId: args.parentSessionID,
|
|
@@ -87046,7 +87677,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
87046
87677
|
canonicalPath2 = args.directory;
|
|
87047
87678
|
let provisionResult;
|
|
87048
87679
|
try {
|
|
87049
|
-
provisionResult = await
|
|
87680
|
+
provisionResult = await _internals103.provisionWorktree(args.directory, args.taskId, args.parentSessionID, {
|
|
87050
87681
|
purpose: "lane",
|
|
87051
87682
|
worktreeDir: worktreeConfig.worktree_dir,
|
|
87052
87683
|
mergeStrategy: worktreeConfig.merge_strategy,
|
|
@@ -87054,11 +87685,11 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
87054
87685
|
scope: args.scope
|
|
87055
87686
|
});
|
|
87056
87687
|
} catch (error2) {
|
|
87057
|
-
|
|
87688
|
+
_internals103.removeWorktreeProvisioningOwner(args.directory, args.callID, provisioningOwnerIdentity);
|
|
87058
87689
|
throw error2;
|
|
87059
87690
|
}
|
|
87060
87691
|
if ("error" in provisionResult) {
|
|
87061
|
-
|
|
87692
|
+
_internals103.removeWorktreeProvisioningOwner(args.directory, args.callID, provisioningOwnerIdentity);
|
|
87062
87693
|
const message = `STANDARD_WORKTREE_PROVISION_FAILED: ${provisionResult.error}.`;
|
|
87063
87694
|
handleStandardWorktreeFailure(args.parentSessionID, worktreeConfig.policy, message);
|
|
87064
87695
|
return;
|
|
@@ -87082,7 +87713,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
87082
87713
|
const laneProfile = computeLaneRuntimeProfile(worktreeConfig.runtime_isolation, laneIndex, handle.worktreePath);
|
|
87083
87714
|
if (laneProfile) {
|
|
87084
87715
|
try {
|
|
87085
|
-
const { writeLaneProfileToDiskReal } = await import("./core-
|
|
87716
|
+
const { writeLaneProfileToDiskReal } = await import("./core-03tedwzg.js");
|
|
87086
87717
|
await writeLaneProfileToDiskReal(handle.worktreePath, laneProfile.laneIndex, laneProfile.envOverrides);
|
|
87087
87718
|
} catch {}
|
|
87088
87719
|
}
|
|
@@ -87111,26 +87742,26 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
87111
87742
|
}
|
|
87112
87743
|
});
|
|
87113
87744
|
} catch (error2) {
|
|
87114
|
-
await
|
|
87745
|
+
await _internals103.removeWorktree(handle.worktreePath, args.directory, {
|
|
87115
87746
|
force: true,
|
|
87116
87747
|
worktreeDir: worktreeConfig.worktree_dir
|
|
87117
87748
|
}).catch((cleanupError) => {
|
|
87118
87749
|
log(`[worktree-isolation] session-create failure cleanup could not remove lane ${handle.worktreePath}: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
|
|
87119
87750
|
});
|
|
87120
|
-
|
|
87751
|
+
_internals103.removeWorktreeProvisioningOwner(args.directory, args.callID, provisioningOwnerIdentity);
|
|
87121
87752
|
const detail = error2 instanceof Error ? error2.message : String(error2);
|
|
87122
87753
|
const message = `STANDARD_WORKTREE_SESSION_CREATE_FAILED: ${detail}.`;
|
|
87123
87754
|
handleStandardWorktreeFailure(args.parentSessionID, worktreeConfig.policy, message);
|
|
87124
87755
|
return;
|
|
87125
87756
|
}
|
|
87126
87757
|
if (!createResult?.data?.id) {
|
|
87127
|
-
await
|
|
87758
|
+
await _internals103.removeWorktree(handle.worktreePath, args.directory, {
|
|
87128
87759
|
force: true,
|
|
87129
87760
|
worktreeDir: worktreeConfig.worktree_dir
|
|
87130
87761
|
}).catch((cleanupError) => {
|
|
87131
87762
|
log(`[worktree-isolation] session-create failure cleanup could not remove lane ${handle.worktreePath}: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
|
|
87132
87763
|
});
|
|
87133
|
-
|
|
87764
|
+
_internals103.removeWorktreeProvisioningOwner(args.directory, args.callID, provisioningOwnerIdentity);
|
|
87134
87765
|
const createError = createResult.error;
|
|
87135
87766
|
const detail = typeof createError === "string" ? createError : JSON.stringify(createError ?? "missing session id");
|
|
87136
87767
|
const message = `STANDARD_WORKTREE_SESSION_CREATE_FAILED: ${detail}.`;
|
|
@@ -87169,8 +87800,8 @@ async function preserveBackgroundWorktreeOwnershipForCallId(callID) {
|
|
|
87169
87800
|
return { outcome: "not-found" };
|
|
87170
87801
|
let refProc;
|
|
87171
87802
|
try {
|
|
87172
|
-
refProc =
|
|
87173
|
-
|
|
87803
|
+
refProc = _internals103.bunSpawn([
|
|
87804
|
+
_internals103.resolveGitExecutable(),
|
|
87174
87805
|
"-C",
|
|
87175
87806
|
dispatch.handle.worktreePath,
|
|
87176
87807
|
"rev-parse",
|
|
@@ -87214,8 +87845,8 @@ async function preserveBackgroundWorktreeOwnershipForCallId(callID) {
|
|
|
87214
87845
|
const tag = `swarm-preserved-owner/${session}/${lane}/${callDigest}`;
|
|
87215
87846
|
let tagProc;
|
|
87216
87847
|
try {
|
|
87217
|
-
tagProc =
|
|
87218
|
-
|
|
87848
|
+
tagProc = _internals103.bunSpawn([
|
|
87849
|
+
_internals103.resolveGitExecutable(),
|
|
87219
87850
|
"-C",
|
|
87220
87851
|
dispatch.handle.worktreePath,
|
|
87221
87852
|
"tag",
|
|
@@ -87265,8 +87896,8 @@ async function preserveDirtyWorktreeForCallId(callID, reason, _directory, _workt
|
|
|
87265
87896
|
}
|
|
87266
87897
|
let statusProc;
|
|
87267
87898
|
try {
|
|
87268
|
-
statusProc =
|
|
87269
|
-
|
|
87899
|
+
statusProc = _internals103.bunSpawn([
|
|
87900
|
+
_internals103.resolveGitExecutable(),
|
|
87270
87901
|
"-C",
|
|
87271
87902
|
worktreePath,
|
|
87272
87903
|
"status",
|
|
@@ -87308,7 +87939,7 @@ async function preserveDirtyWorktreeForCallId(callID, reason, _directory, _workt
|
|
|
87308
87939
|
}
|
|
87309
87940
|
let addProc;
|
|
87310
87941
|
try {
|
|
87311
|
-
addProc =
|
|
87942
|
+
addProc = _internals103.bunSpawn([_internals103.resolveGitExecutable(), "-C", worktreePath, "add", "-A"], {
|
|
87312
87943
|
stdin: "ignore",
|
|
87313
87944
|
stdout: "pipe",
|
|
87314
87945
|
stderr: "pipe",
|
|
@@ -87342,8 +87973,8 @@ async function preserveDirtyWorktreeForCallId(callID, reason, _directory, _workt
|
|
|
87342
87973
|
const commitMessage = `swarm-preserved: ${reason} for callID ${sanitizedCallID} at ${isoDate}`;
|
|
87343
87974
|
let commitProc;
|
|
87344
87975
|
try {
|
|
87345
|
-
commitProc =
|
|
87346
|
-
|
|
87976
|
+
commitProc = _internals103.bunSpawn([
|
|
87977
|
+
_internals103.resolveGitExecutable(),
|
|
87347
87978
|
"-C",
|
|
87348
87979
|
worktreePath,
|
|
87349
87980
|
"commit",
|
|
@@ -87381,8 +88012,8 @@ async function preserveDirtyWorktreeForCallId(callID, reason, _directory, _workt
|
|
|
87381
88012
|
}
|
|
87382
88013
|
let hashProc;
|
|
87383
88014
|
try {
|
|
87384
|
-
hashProc =
|
|
87385
|
-
|
|
88015
|
+
hashProc = _internals103.bunSpawn([
|
|
88016
|
+
_internals103.resolveGitExecutable(),
|
|
87386
88017
|
"-C",
|
|
87387
88018
|
worktreePath,
|
|
87388
88019
|
"rev-parse",
|
|
@@ -87428,7 +88059,7 @@ async function preserveDirtyWorktreeForCallId(callID, reason, _directory, _workt
|
|
|
87428
88059
|
const tagName = `swarm-preserved-${sanitizedCallID}-${shortHash}`;
|
|
87429
88060
|
let tagProc;
|
|
87430
88061
|
try {
|
|
87431
|
-
tagProc =
|
|
88062
|
+
tagProc = _internals103.bunSpawn([_internals103.resolveGitExecutable(), "-C", worktreePath, "tag", tagName], {
|
|
87432
88063
|
stdin: "ignore",
|
|
87433
88064
|
stdout: "pipe",
|
|
87434
88065
|
stderr: "pipe",
|
|
@@ -87464,8 +88095,8 @@ async function preserveDirtyWorktreeForCallId(callID, reason, _directory, _workt
|
|
|
87464
88095
|
async function preserveDirtyWorktreeAtPath(worktreePath, branchName, reason, _directory, _worktree_dir) {
|
|
87465
88096
|
let statusProc;
|
|
87466
88097
|
try {
|
|
87467
|
-
statusProc =
|
|
87468
|
-
|
|
88098
|
+
statusProc = _internals103.bunSpawn([
|
|
88099
|
+
_internals103.resolveGitExecutable(),
|
|
87469
88100
|
"-C",
|
|
87470
88101
|
worktreePath,
|
|
87471
88102
|
"status",
|
|
@@ -87507,7 +88138,7 @@ async function preserveDirtyWorktreeAtPath(worktreePath, branchName, reason, _di
|
|
|
87507
88138
|
}
|
|
87508
88139
|
let addProc;
|
|
87509
88140
|
try {
|
|
87510
|
-
addProc =
|
|
88141
|
+
addProc = _internals103.bunSpawn([_internals103.resolveGitExecutable(), "-C", worktreePath, "add", "-A"], {
|
|
87511
88142
|
stdin: "ignore",
|
|
87512
88143
|
stdout: "pipe",
|
|
87513
88144
|
stderr: "pipe",
|
|
@@ -87542,8 +88173,8 @@ async function preserveDirtyWorktreeAtPath(worktreePath, branchName, reason, _di
|
|
|
87542
88173
|
const commitMessage = `swarm-preserved: ${reason} for worktree ${sanitizedPath} at ${isoDate}`;
|
|
87543
88174
|
let commitProc;
|
|
87544
88175
|
try {
|
|
87545
|
-
commitProc =
|
|
87546
|
-
|
|
88176
|
+
commitProc = _internals103.bunSpawn([
|
|
88177
|
+
_internals103.resolveGitExecutable(),
|
|
87547
88178
|
"-C",
|
|
87548
88179
|
worktreePath,
|
|
87549
88180
|
"commit",
|
|
@@ -87581,8 +88212,8 @@ async function preserveDirtyWorktreeAtPath(worktreePath, branchName, reason, _di
|
|
|
87581
88212
|
}
|
|
87582
88213
|
let hashProc;
|
|
87583
88214
|
try {
|
|
87584
|
-
hashProc =
|
|
87585
|
-
|
|
88215
|
+
hashProc = _internals103.bunSpawn([
|
|
88216
|
+
_internals103.resolveGitExecutable(),
|
|
87586
88217
|
"-C",
|
|
87587
88218
|
worktreePath,
|
|
87588
88219
|
"rev-parse",
|
|
@@ -87628,7 +88259,7 @@ async function preserveDirtyWorktreeAtPath(worktreePath, branchName, reason, _di
|
|
|
87628
88259
|
const tagName = `swarm-preserved-worktree-${sanitizedBranch}-${shortHash}`;
|
|
87629
88260
|
let tagProc;
|
|
87630
88261
|
try {
|
|
87631
|
-
tagProc =
|
|
88262
|
+
tagProc = _internals103.bunSpawn([_internals103.resolveGitExecutable(), "-C", worktreePath, "tag", tagName], {
|
|
87632
88263
|
stdin: "ignore",
|
|
87633
88264
|
stdout: "pipe",
|
|
87634
88265
|
stderr: "pipe",
|
|
@@ -87682,7 +88313,7 @@ async function cleanupStandardWorktreeForCallId(callID, reason, directory, workt
|
|
|
87682
88313
|
parentSessionID = awaiting.parentSessionID;
|
|
87683
88314
|
}
|
|
87684
88315
|
if (dispatch?.recoveryClaim && (reason === "denied" || reason === "cancelled")) {
|
|
87685
|
-
const renewResult =
|
|
88316
|
+
const renewResult = _internals103.renewWorktreeRecoveryClaim(directory, {
|
|
87686
88317
|
authorityDigest: dispatch.recoveryClaim.authorityDigest,
|
|
87687
88318
|
claimantCallID: callID,
|
|
87688
88319
|
claimRevision: dispatch.recoveryClaim.claimRevision,
|
|
@@ -87699,7 +88330,7 @@ async function cleanupStandardWorktreeForCallId(callID, reason, directory, workt
|
|
|
87699
88330
|
pushAdvisory(session3, message);
|
|
87700
88331
|
throw new Error(message);
|
|
87701
88332
|
}
|
|
87702
|
-
const releaseResult =
|
|
88333
|
+
const releaseResult = _internals103.releaseWorktreeRecoveryClaim(directory, {
|
|
87703
88334
|
authorityDigest: dispatch.recoveryClaim.authorityDigest,
|
|
87704
88335
|
claimantCallID: callID,
|
|
87705
88336
|
claimRevision: dispatch.recoveryClaim.claimRevision,
|
|
@@ -87728,7 +88359,7 @@ async function cleanupStandardWorktreeForCallId(callID, reason, directory, workt
|
|
|
87728
88359
|
let preserveResult;
|
|
87729
88360
|
if (reason === "denied" || reason === "cancelled") {
|
|
87730
88361
|
try {
|
|
87731
|
-
preserveResult = await
|
|
88362
|
+
preserveResult = await _internals103.preserveDirtyWorktreeForCallId(callID, reason, directory, worktree_dir);
|
|
87732
88363
|
} catch (err) {
|
|
87733
88364
|
log(`[swarm] cleanupStandardWorktreeForCallId: preserveDirtyWorktreeForCallId threw for ${callID}: ${err}`);
|
|
87734
88365
|
preserveResult = {
|
|
@@ -87739,7 +88370,7 @@ async function cleanupStandardWorktreeForCallId(callID, reason, directory, workt
|
|
|
87739
88370
|
}
|
|
87740
88371
|
if (preserveResult.outcome === "clean") {
|
|
87741
88372
|
try {
|
|
87742
|
-
preserveResult = await
|
|
88373
|
+
preserveResult = await _internals103.preserveDirtyWorktreeForCallId(callID, reason, directory, worktree_dir);
|
|
87743
88374
|
} catch (err) {
|
|
87744
88375
|
log(`[swarm] cleanupStandardWorktreeForCallId: final preservation check threw for ${callID}: ${err}`);
|
|
87745
88376
|
preserveResult = {
|
|
@@ -87763,7 +88394,7 @@ async function cleanupStandardWorktreeForCallId(callID, reason, directory, workt
|
|
|
87763
88394
|
}
|
|
87764
88395
|
let removedWorktree = false;
|
|
87765
88396
|
try {
|
|
87766
|
-
const result = await
|
|
88397
|
+
const result = await _internals103.removeWorktree(worktreePath, directory, {
|
|
87767
88398
|
force: true,
|
|
87768
88399
|
worktreeDir: worktree_dir
|
|
87769
88400
|
});
|
|
@@ -87773,7 +88404,7 @@ async function cleanupStandardWorktreeForCallId(callID, reason, directory, workt
|
|
|
87773
88404
|
}
|
|
87774
88405
|
let cleanedBranch = false;
|
|
87775
88406
|
try {
|
|
87776
|
-
const result = await
|
|
88407
|
+
const result = await _internals103.postMergeCleanup(directory, branchName);
|
|
87777
88408
|
cleanedBranch = !("error" in result);
|
|
87778
88409
|
} catch (err) {
|
|
87779
88410
|
log(`[swarm] cleanupStandardWorktreeForCallId: postMergeCleanup failed for ${callID}: ${err}`);
|
|
@@ -87823,7 +88454,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
87823
88454
|
const renewRecoveryClaimLease = (phase, provenance) => {
|
|
87824
88455
|
if (!dispatch.recoveryClaim)
|
|
87825
88456
|
return;
|
|
87826
|
-
const renewed =
|
|
88457
|
+
const renewed = _internals103.renewWorktreeRecoveryClaim(directory, {
|
|
87827
88458
|
authorityDigest: dispatch.recoveryClaim.authorityDigest,
|
|
87828
88459
|
claimantCallID: resolvedCallID,
|
|
87829
88460
|
claimRevision: dispatch.recoveryClaim.claimRevision,
|
|
@@ -87841,7 +88472,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
87841
88472
|
const releaseRecoveryClaim = (provenance) => {
|
|
87842
88473
|
if (!dispatch.recoveryClaim)
|
|
87843
88474
|
return;
|
|
87844
|
-
const released =
|
|
88475
|
+
const released = _internals103.releaseWorktreeRecoveryClaim(directory, {
|
|
87845
88476
|
authorityDigest: dispatch.recoveryClaim.authorityDigest,
|
|
87846
88477
|
claimantCallID: resolvedCallID,
|
|
87847
88478
|
claimRevision: dispatch.recoveryClaim.claimRevision,
|
|
@@ -87877,7 +88508,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
87877
88508
|
}
|
|
87878
88509
|
const mergeResult = await (async () => {
|
|
87879
88510
|
if (!dispatch.recoveryClaim) {
|
|
87880
|
-
return
|
|
88511
|
+
return _internals103.attemptMergeBackFromDirty(dispatch.handle.worktreePath, dispatch.handle.branchName, directory, getMergeStrategy({ merge_strategy: dispatch.mergeStrategy }), {
|
|
87881
88512
|
operationId: settlement.operationId,
|
|
87882
88513
|
resume: settlement.resume,
|
|
87883
88514
|
onBeforeMerge: settlement.onBeforeMerge
|
|
@@ -87901,7 +88532,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
87901
88532
|
if (settlement.onBeforeMerge) {
|
|
87902
88533
|
await settlement.onBeforeMerge(provenance);
|
|
87903
88534
|
}
|
|
87904
|
-
const recovered = await
|
|
88535
|
+
const recovered = await _internals103.recoverMergeBackFromImmutableCoordinates(directory, coordinates);
|
|
87905
88536
|
if ("merged" in recovered && recovered.merged) {
|
|
87906
88537
|
if (recovered.sourceCommitOrder && recovered.rewrittenCommitOrder) {
|
|
87907
88538
|
dispatch.recoveryClaim.settlement = {
|
|
@@ -87990,7 +88621,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
87990
88621
|
settlement: dispatch.recoveryClaim.settlement
|
|
87991
88622
|
};
|
|
87992
88623
|
if (cleanupResult.removedWorktree && cleanupResult.cleanedBranch) {
|
|
87993
|
-
const finalized =
|
|
88624
|
+
const finalized = _internals103.finalizeWorktreeRecoveryAuthority(directory, request);
|
|
87994
88625
|
if (!finalized.ok) {
|
|
87995
88626
|
return failRecoverySettlement("recovery-claim-finalize", `The merged recovery lane was cleaned up but could not finalize its exact claim; ${describeRecoveryMutationFailure({
|
|
87996
88627
|
action: "finalize",
|
|
@@ -88007,7 +88638,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
88007
88638
|
}
|
|
88008
88639
|
clearWorktreeMergeStatus(statusKey);
|
|
88009
88640
|
try {
|
|
88010
|
-
const { removeLaneProfileFromDiskReal } = await import("./core-
|
|
88641
|
+
const { removeLaneProfileFromDiskReal } = await import("./core-03tedwzg.js");
|
|
88011
88642
|
await removeLaneProfileFromDiskReal(dispatch.handle.worktreePath, dispatch.laneIndex);
|
|
88012
88643
|
} catch {}
|
|
88013
88644
|
const state = serializationStateBySessionID.get(dispatch.parentSessionID);
|
|
@@ -88111,7 +88742,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
88111
88742
|
awaitingMergeByCallID.delete(resolvedCallID);
|
|
88112
88743
|
if (dispatch.recoveryClaim) {
|
|
88113
88744
|
try {
|
|
88114
|
-
|
|
88745
|
+
_internals103.releaseWorktreeRecoveryClaim(directory, {
|
|
88115
88746
|
authorityDigest: dispatch.recoveryClaim.authorityDigest,
|
|
88116
88747
|
claimantCallID: resolvedCallID,
|
|
88117
88748
|
claimRevision: dispatch.recoveryClaim.claimRevision,
|
|
@@ -88172,7 +88803,7 @@ async function readLaneEnvFileFromDisk(worktreePath, laneIndex) {
|
|
|
88172
88803
|
}
|
|
88173
88804
|
return result;
|
|
88174
88805
|
}
|
|
88175
|
-
var
|
|
88806
|
+
var _internals103 = {
|
|
88176
88807
|
provisionWorktree,
|
|
88177
88808
|
removeWorktree,
|
|
88178
88809
|
attemptMergeBackFromDirty,
|
|
@@ -88210,4 +88841,4 @@ var _internals102 = {
|
|
|
88210
88841
|
resolveGitExecutable
|
|
88211
88842
|
};
|
|
88212
88843
|
|
|
88213
|
-
export { PrReviewRunIdSchema, resetActionCircuitExternally, getBlockingActionCircuit, dcNormalizeCommand, dcUnwrapWrappers, dcSplitSegments, dcExtractRecursiveRmTargets, dcEvaluateRecursiveDeleteTargets, dcCheckJunctionCreation, dcExtractWindowsCmdTargets, dcExtractPowerShellTargets, getSharedClassifierGuardrailBlock, classifyCommand, normalizeSwarmCommandInput, canonicalCommandKey, formatCommandNotFound, executeSwarmCommand, SWARM_COMMAND_TOOL_COMMANDS, SWARM_COMMAND_TOOL_ALLOWLIST, HUMAN_ONLY_SWARM_COMMANDS, classifySwarmCommandToolUse, classifySwarmCommandChatFallbackUse, detectPosixWrites, detectWindowsWrites, resolveWriteTargets, getAgentSession, parseLeanLaneIndex, computeLaneRuntimeProfile, MAX_TRACKED_STANDARD_WORKTREE_CALLS, awaitingMergeByCallID, standardWorktreeByCallID, standardWorktreeSerializationSessions, getStandardWorktreeDegradationReason, resetStandardWorktreeIsolationState, checkStandardWorktreeSerializationRelease, sanitizeWorktreeTaskId, preProvisionCollisionCheck, isLaneOwnedByCurrentSession, precreateStandardWorktreeSession, preserveBackgroundWorktreeOwnershipForCallId, preserveDirtyWorktreeForCallId, preserveDirtyWorktreeAtPath, cleanupStandardWorktreeForCallId, abortStandardWorktreeDispatch, finishStandardWorktreeDispatch, readLaneEnvFileFromDisk,
|
|
88844
|
+
export { PrReviewRunIdSchema, resetActionCircuitExternally, getBlockingActionCircuit, dcNormalizeCommand, dcUnwrapWrappers, dcSplitSegments, dcExtractRecursiveRmTargets, dcEvaluateRecursiveDeleteTargets, dcCheckJunctionCreation, dcExtractWindowsCmdTargets, dcExtractPowerShellTargets, getSharedClassifierGuardrailBlock, classifyCommand, normalizeSwarmCommandInput, canonicalCommandKey, formatCommandNotFound, executeSwarmCommand, SWARM_COMMAND_TOOL_COMMANDS, SWARM_COMMAND_TOOL_ALLOWLIST, HUMAN_ONLY_SWARM_COMMANDS, classifySwarmCommandToolUse, classifySwarmCommandChatFallbackUse, detectPosixWrites, detectWindowsWrites, resolveWriteTargets, getAgentSession, parseLeanLaneIndex, computeLaneRuntimeProfile, MAX_TRACKED_STANDARD_WORKTREE_CALLS, awaitingMergeByCallID, standardWorktreeByCallID, standardWorktreeSerializationSessions, getStandardWorktreeDegradationReason, resetStandardWorktreeIsolationState, checkStandardWorktreeSerializationRelease, sanitizeWorktreeTaskId, preProvisionCollisionCheck, isLaneOwnedByCurrentSession, precreateStandardWorktreeSession, preserveBackgroundWorktreeOwnershipForCallId, preserveDirtyWorktreeForCallId, preserveDirtyWorktreeAtPath, cleanupStandardWorktreeForCallId, abortStandardWorktreeDispatch, finishStandardWorktreeDispatch, readLaneEnvFileFromDisk, _internals103 as _internals, readPrReviewReentryBindingContext, prWorkflowSessionFileStem, handleAcknowledgeSpecDriftCommand, handleAgentsCommand, handleAnalyzeCommand, handleApproveWriteCommand, handleArchiveCommand, handleAutoProceedCommand, handleBenchmarkCommand, handleBrainstormCommand, handleCheckpointCommand, handleCiSimulateCommand, handleClarifyCommand, createCuratorLLMDelegate, _internals26 as _internals1, normalizeRecommendationEntryIdToken, parseKnowledgeRecommendations, parseKnowledgeRecommendationsWithDiagnostics, parseStructuredCuratorBlocks, readCuratorSummary, writeCuratorSummary, appendCuratorRecommendation, mergeCuratorPhaseSummary, filterPhaseEvents, checkPhaseCompliance, runCuratorInit, runCuratorPhase, applyCuratorKnowledgeUpdates, isHiveEligible, countDistinctProjects, checkHivePromotions, _internals30 as _internals2, createHivePromoterHook, promoteToHive, promoteFromSwarm, safeRealpathSync, handleCloseCommand, handleCodebaseReviewCommand, handleConcurrencyCommand, handleConfigCommand, handleConsolidateCommand, handleCostsCommand, handleCouncilCommand, handleCurateCommand, handleDarkMatterCommand, handleDeepDiveCommand, handleDeepResearchCommand, getPluginConfigDir, getPluginCachePaths, getPluginLockFilePaths, VERSION_PINNED_LEAF, discoverVersionPinnedCachePaths, readCachePackageVersion, handleDiagnoseCommand, handleDoctorCommand, handleEvidenceCommand, handleEvidenceSummaryCommand, handleExportCommand, handleFullAutoCommand, handleGateAuditCommand, handleGateStatsCommand, handleHandoffCommand, handleBlueprintValidateCommand, handleBlueprintCurrentCommand, handleBlueprintHistoryCommand, handleBlueprintDiffCommand, handleBlueprintExportCommand, handleHarnessCandidateValidateCommand, handleHarnessCandidateShowCommand, handleHarnessCandidateDiffCommand, handleHistoryCommand, handleKnowledgeQuarantineCommand, handleKnowledgeRestoreCommand, handleKnowledgeMigrateCommand, handleKnowledgeListCommand, handleKnowledgeUnactionableCommand, handleKnowledgeRetryHardeningCommand, handleLearningCommand, handleLinkCommand, handleMemoryCommand, handleMemoryStatusCommand, handleMemoryValueLogCommand, handleMemoryMigrateCommand, handleMemoryImportCommand, handleMemoryExportCommand, handlePlanCommand, handlePreflightCommand, handlePromoteCommand, handleQaGatesCommand, handleRecoverCommand, handleResetCommand, handleResetSessionCommand, handleRetrieveCommand, handleReviewCommand, handleRollbackCommand, handleSddStatusCommand, handleSddValidateCommand, handleSddProjectCommand, handleSddCommand, handleSimulateCommand, handleSpecifyCommand, handleStatusCommand, handleSyncPlanCommand, handleTurboCommand, handleUnlinkCommand, handleWriteRetroCommand, handleHelpCommand, COMMAND_REGISTRY, VALID_COMMANDS, _internals101 as _internals3, resolveCommand };
|