opencode-swarm 7.148.5 → 7.149.1
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/dist/background/candidate-contract.d.ts +1 -1
- package/dist/background/pending-delegations.d.ts +6 -0
- package/dist/background/pr-review-contract.d.ts +20 -0
- package/dist/cli/{config-doctor-6z7x0jnz.js → config-doctor-d3nsq1nz.js} +3 -3
- package/dist/cli/{core-0ph6pb2y.js → core-y9d858n6.js} +3 -3
- package/dist/cli/{curation-policy-fbvctttr.js → curation-policy-nck9g765.js} +6 -6
- package/dist/cli/{curator-pffqw3br.js → curator-f5m0hh2p.js} +32 -31
- package/dist/cli/{curator-llm-factory-mbsn281q.js → curator-llm-factory-mzh9ns5s.js} +32 -31
- package/dist/cli/{evidence-summary-service-9ajw5tpc.js → evidence-summary-service-601x7ne7.js} +15 -14
- package/dist/cli/{gate-evidence-wc8wzwaw.js → gate-evidence-kjs9vsx9.js} +9 -9
- package/dist/cli/{guardrail-explain-a8706sq1.js → guardrail-explain-j291sss5.js} +33 -32
- package/dist/cli/{guardrail-log-wx43bj32.js → guardrail-log-1jykfrqc.js} +6 -4
- package/dist/cli/{guardrail-reset-sy0vztrd.js → guardrail-reset-tr07m077.js} +32 -31
- package/dist/cli/{hive-promoter-jvyzykgx.js → hive-promoter-162ws6xp.js} +32 -31
- package/dist/cli/{index-x3d9asnz.js → index-1aztaa2s.js} +3 -3
- package/dist/cli/{index-c6jqkx9d.js → index-38ema5k2.js} +2 -2
- package/dist/cli/{index-nq4tkfpc.js → index-4sdhbxgq.js} +1 -1
- package/dist/cli/{index-vyg5b8ee.js → index-5gntxwxt.js} +5 -5
- package/dist/cli/{index-0yzt06r5.js → index-64d17yd0.js} +2 -2
- package/dist/cli/{index-3aev3a0c.js → index-7m8rk72d.js} +491 -369
- package/dist/cli/{index-vhefvcta.js → index-apwcvfjt.js} +2 -2
- package/dist/cli/{index-arjq717j.js → index-cna8m7my.js} +1 -1
- package/dist/cli/{index-59wqcatm.js → index-cqhf7fkw.js} +1 -1
- package/dist/cli/{index-jzz52as5.js → index-dkrz1vv5.js} +4 -4
- package/dist/cli/{index-kg4knw6r.js → index-dtmgt2xn.js} +11 -10
- package/dist/cli/{index-579qg534.js → index-eaq9b0qm.js} +1 -1
- package/dist/cli/{index-zhn0q7nf.js → index-ekvs3ade.js} +18 -17
- package/dist/cli/index-exn0ztsv.js +881 -0
- package/dist/cli/{index-ag9bv589.js → index-f53yyerg.js} +34 -33
- package/dist/cli/{index-q7ke7kwd.js → index-fc4x86sy.js} +9 -12
- package/dist/cli/{index-zf2vwa7y.js → index-hxbrsb40.js} +2 -2
- package/dist/cli/{index-k1s8gxjh.js → index-jb9tb1sd.js} +1 -1
- package/dist/cli/{index-haf092ak.js → index-jg2gwzvq.js} +11 -11
- package/dist/cli/{index-qwmrt51t.js → index-k2sm9677.js} +1 -1
- package/dist/cli/{index-5r2mcgpa.js → index-kgk65rde.js} +1 -1
- package/dist/cli/{index-vrp2zva8.js → index-m8dn0qnm.js} +1 -1
- package/dist/cli/{index-1w5nnyew.js → index-mdwtj4xm.js} +6 -6
- package/dist/cli/{index-j382eh60.js → index-n99s022c.js} +1 -1
- package/dist/cli/{index-yezd5ks6.js → index-pf22x0dr.js} +3 -1
- package/dist/cli/{index-8djgxw2w.js → index-prxrmc3b.js} +2 -2
- package/dist/cli/{index-kj6m9ry3.js → index-srwp8fs7.js} +4 -4
- package/dist/cli/{index-5zq3892p.js → index-t994f8fp.js} +4 -4
- package/dist/cli/{index-t25evmna.js → index-vy6q9d8j.js} +3 -2
- package/dist/cli/{index-ne45ew6z.js → index-xe83cwvn.js} +10 -10
- package/dist/cli/{index-ghbkknjz.js → index-xggpmtfx.js} +73 -42
- package/dist/cli/{index-qbsc2btq.js → index-yjj3s8af.js} +3 -3
- package/dist/cli/index.js +32 -31
- package/dist/cli/{knowledge-escalator-bvrtfdyb.js → knowledge-escalator-whkxxgxj.js} +14 -14
- package/dist/cli/{knowledge-events-rpvkevbm.js → knowledge-events-rnqzt87h.js} +12 -12
- package/dist/cli/{knowledge-link-spw879rs.js → knowledge-link-mzn8x0qd.js} +5 -5
- package/dist/cli/{knowledge-store-wjy2kshh.js → knowledge-store-7de59rnz.js} +6 -6
- package/dist/cli/{knowledge-validator-cq2cgfcx.js → knowledge-validator-bpk17jf4.js} +8 -8
- package/dist/cli/{pending-delegations-f4wvyzbf.js → pending-delegations-qzy6rnvw.js} +3 -3
- package/dist/cli/{pr-subscriptions-f4xw1rxy.js → pr-subscriptions-q862pvz1.js} +3 -3
- package/dist/cli/{runner-rk26nk58.js → runner-1aygs98c.js} +6 -6
- package/dist/cli/{scan-cursor-7n0zs72g.js → scan-cursor-0p51fh61.js} +7 -7
- package/dist/cli/{schema-e59spg93.js → schema-8g2nxhjf.js} +1 -1
- package/dist/cli/{scope-persistence-d75p900m.js → scope-persistence-hhkr0c46.js} +8 -10
- package/dist/cli/{skill-generator-c65y1h6a.js → skill-generator-pk9gcz7r.js} +16 -16
- package/dist/cli/{telemetry-1pnsftp0.js → telemetry-5deacb7w.js} +1 -1
- package/dist/cli/{workspace-snapshot-nq25j94x.js → workspace-snapshot-8269e1p9.js} +2 -2
- package/dist/cli/{worktree-collision-ownership-wqy7mgb3.js → worktree-collision-ownership-9v8e0dz7.js} +8 -8
- package/dist/cli/{worktree-isolation-ay9d58w4.js → worktree-isolation-1hwwfbdw.js} +32 -31
- package/dist/commands/close.d.ts +1 -0
- package/dist/events/core-events.d.ts +250 -0
- package/dist/failures/invocation-failure.d.ts +7 -0
- package/dist/full-auto/oversight.d.ts +5 -3
- package/dist/hooks/full-auto-delegation.d.ts +24 -0
- package/dist/hooks/full-auto-input-probe.d.ts +11 -0
- package/dist/hooks/pr-workflow-gate.d.ts +37 -6
- package/dist/hooks/steering-consumed.d.ts +12 -4
- package/dist/index.js +598 -613
- package/dist/observability/catalog.d.ts +9 -7
- package/dist/services/session-reflection.d.ts +7 -0
- package/dist/services/spec-drift-recovery.d.ts +9 -2
- package/dist/state.d.ts +10 -0
- package/dist/telemetry.d.ts +24 -1
- package/dist/tools/dispatch-lanes.d.ts +50 -1
- package/dist/tools/write-pr-review-artifact.d.ts +2 -0
- package/package.json +3 -1
- package/dist/cli/{curator-drift-fv4rttf4.js → curator-drift-2h1d2fnq.js} +1 -1
- package/dist/cli/{index-g8wwj0sz.js → index-vnn7qq8c.js} +3 -3
|
@@ -6,17 +6,17 @@ import {
|
|
|
6
6
|
resolveExecutableFromPath,
|
|
7
7
|
runEvaluation,
|
|
8
8
|
runExternalTool
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-n99s022c.js";
|
|
10
10
|
import {
|
|
11
11
|
normalizeToolNameLowerCase,
|
|
12
12
|
stableCanonicalStringify
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-cna8m7my.js";
|
|
14
14
|
import {
|
|
15
15
|
detectStraySwarmDirs,
|
|
16
16
|
readDoctorArtifact,
|
|
17
17
|
removeStraySwarmDir,
|
|
18
18
|
runConfigDoctor
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-kgk65rde.js";
|
|
20
20
|
import {
|
|
21
21
|
MAX_TRANSIENT_RETRIES,
|
|
22
22
|
archiveEvidence,
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
updateTaskStatus,
|
|
63
63
|
validateProjectRoot,
|
|
64
64
|
validateSymlinkBoundary
|
|
65
|
-
} from "./index-
|
|
65
|
+
} from "./index-ekvs3ade.js";
|
|
66
66
|
import {
|
|
67
67
|
EvaluationTaskV1Schema,
|
|
68
68
|
GateAuditManifestV1Schema,
|
|
@@ -79,7 +79,7 @@ import {
|
|
|
79
79
|
saveGateAuditResult,
|
|
80
80
|
savePromotionDecision,
|
|
81
81
|
saveTaskSetSnapshot
|
|
82
|
-
} from "./index-
|
|
82
|
+
} from "./index-prxrmc3b.js";
|
|
83
83
|
import {
|
|
84
84
|
loadDatabaseCtor
|
|
85
85
|
} from "./index-134d35c1.js";
|
|
@@ -105,12 +105,12 @@ import {
|
|
|
105
105
|
} from "./index-y8552snf.js";
|
|
106
106
|
import {
|
|
107
107
|
readRecentEscalations
|
|
108
|
-
} from "./index-
|
|
108
|
+
} from "./index-5gntxwxt.js";
|
|
109
109
|
import {
|
|
110
110
|
alreadyCuratedThisGeneration,
|
|
111
111
|
claimNextScanBatch,
|
|
112
112
|
resolveCohortId
|
|
113
|
-
} from "./index-
|
|
113
|
+
} from "./index-hxbrsb40.js";
|
|
114
114
|
import {
|
|
115
115
|
CURATOR_INIT_PROMPT,
|
|
116
116
|
CURATOR_PHASE_PROMPT,
|
|
@@ -153,13 +153,13 @@ import {
|
|
|
153
153
|
resolveRemoteRefsContainingHead,
|
|
154
154
|
resolveRemoteRefsContainingHeadAsync,
|
|
155
155
|
switchPrFeedbackTrackingCandidateAsync
|
|
156
|
-
} from "./index-
|
|
156
|
+
} from "./index-vnn7qq8c.js";
|
|
157
157
|
import {
|
|
158
158
|
buildCorrelationId,
|
|
159
159
|
listActive,
|
|
160
160
|
subscribe,
|
|
161
161
|
unsubscribe
|
|
162
|
-
} from "./index-
|
|
162
|
+
} from "./index-k2sm9677.js";
|
|
163
163
|
import {
|
|
164
164
|
BUNDLED_PROJECT_SKILL_ROOT,
|
|
165
165
|
DEFAULT_SKILL_MIN_CONFIDENCE,
|
|
@@ -180,7 +180,7 @@ import {
|
|
|
180
180
|
retireSkill,
|
|
181
181
|
selectCandidateEntries,
|
|
182
182
|
syncBundledProjectSkillsIfMissingAsync
|
|
183
|
-
} from "./index-
|
|
183
|
+
} from "./index-dkrz1vv5.js";
|
|
184
184
|
import {
|
|
185
185
|
appendUnactionable,
|
|
186
186
|
quarantineEntry,
|
|
@@ -191,11 +191,11 @@ import {
|
|
|
191
191
|
validateActionableFields,
|
|
192
192
|
validateLesson,
|
|
193
193
|
validateSkillPath
|
|
194
|
-
} from "./index-
|
|
194
|
+
} from "./index-srwp8fs7.js";
|
|
195
195
|
import {
|
|
196
196
|
authorizeCuration,
|
|
197
197
|
buildConfigFingerprintInput
|
|
198
|
-
} from "./index-
|
|
198
|
+
} from "./index-4sdhbxgq.js";
|
|
199
199
|
import {
|
|
200
200
|
cohortConfigFingerprint
|
|
201
201
|
} from "./index-rtry5xyf.js";
|
|
@@ -219,7 +219,7 @@ import {
|
|
|
219
219
|
scanBackgroundCoderReservationsForAdmission,
|
|
220
220
|
scanDelegationsForRecovery,
|
|
221
221
|
sweepStaleDelegations
|
|
222
|
-
} from "./index-
|
|
222
|
+
} from "./index-vy6q9d8j.js";
|
|
223
223
|
import {
|
|
224
224
|
WORKTREE_LIFECYCLE_LOCK_FILE,
|
|
225
225
|
recordWorktreeProvisioningOwner,
|
|
@@ -252,18 +252,18 @@ import {
|
|
|
252
252
|
transitionTaskWorkflowEvidence,
|
|
253
253
|
withTaskEvidenceTransaction,
|
|
254
254
|
writeWorkflowWalFile
|
|
255
|
-
} from "./index-
|
|
255
|
+
} from "./index-jg2gwzvq.js";
|
|
256
256
|
import {
|
|
257
257
|
provisionWorktree,
|
|
258
258
|
removeWorktree
|
|
259
|
-
} from "./index-
|
|
259
|
+
} from "./index-t994f8fp.js";
|
|
260
260
|
import {
|
|
261
261
|
MAX_PENDING_SCOPE_BINDINGS,
|
|
262
262
|
canonicalWorkspaceIdentity,
|
|
263
263
|
clearAllScopes,
|
|
264
264
|
clearScopeBindingFromDisk,
|
|
265
265
|
clearScopeBindings
|
|
266
|
-
} from "./index-
|
|
266
|
+
} from "./index-fc4x86sy.js";
|
|
267
267
|
import {
|
|
268
268
|
appendLedgerEvent,
|
|
269
269
|
computePlanHash,
|
|
@@ -278,7 +278,17 @@ import {
|
|
|
278
278
|
readPlanEpochIdentity,
|
|
279
279
|
replayFromLedgerWithStatus,
|
|
280
280
|
takeSnapshotEvent
|
|
281
|
-
} from "./index-
|
|
281
|
+
} from "./index-1aztaa2s.js";
|
|
282
|
+
import {
|
|
283
|
+
CORE_EVENT_LOCKED,
|
|
284
|
+
appendCoreEventSync,
|
|
285
|
+
appendCoreEventsSync,
|
|
286
|
+
finalizeCoreEventsForClose,
|
|
287
|
+
getCoreEventCoverage,
|
|
288
|
+
hasSpecDriftAuditEvent,
|
|
289
|
+
hasTaskRepairAuditEvent,
|
|
290
|
+
readCoreEvents
|
|
291
|
+
} from "./index-exn0ztsv.js";
|
|
282
292
|
import {
|
|
283
293
|
isPathWithinDeclaredScope,
|
|
284
294
|
sanitizeDiagnosticText
|
|
@@ -330,7 +340,7 @@ import {
|
|
|
330
340
|
transactFile,
|
|
331
341
|
transactKnowledge,
|
|
332
342
|
wordBigrams
|
|
333
|
-
} from "./index-
|
|
343
|
+
} from "./index-mdwtj4xm.js";
|
|
334
344
|
import {
|
|
335
345
|
MAX_EVENT_LOG_ENTRIES,
|
|
336
346
|
_internals as _internals2,
|
|
@@ -344,20 +354,32 @@ import {
|
|
|
344
354
|
recordKnowledgeEvent,
|
|
345
355
|
recordPhaseCloseIntent,
|
|
346
356
|
resolveKnowledgeEventsPath
|
|
347
|
-
} from "./index-
|
|
357
|
+
} from "./index-xe83cwvn.js";
|
|
348
358
|
import {
|
|
349
359
|
resolveWorktreeIsolationConfig
|
|
350
|
-
} from "./index-
|
|
360
|
+
} from "./index-38ema5k2.js";
|
|
351
361
|
import {
|
|
352
362
|
RetrospectiveEvidenceSchema
|
|
353
363
|
} from "./index-gprxjmm7.js";
|
|
364
|
+
import {
|
|
365
|
+
readSwarmFileAsync,
|
|
366
|
+
safeHook,
|
|
367
|
+
validateSwarmPath
|
|
368
|
+
} from "./index-4cgee5vh.js";
|
|
369
|
+
import {
|
|
370
|
+
bunSpawn,
|
|
371
|
+
bunSpawnSync,
|
|
372
|
+
bunWrite,
|
|
373
|
+
mergeEnvForChild,
|
|
374
|
+
sleep
|
|
375
|
+
} from "./index-r3mvsbtq.js";
|
|
354
376
|
import {
|
|
355
377
|
PlanSchema,
|
|
356
378
|
exports_loader,
|
|
357
379
|
init_loader,
|
|
358
380
|
loadPluginConfig,
|
|
359
381
|
loadPluginConfigWithMeta
|
|
360
|
-
} from "./index-
|
|
382
|
+
} from "./index-cqhf7fkw.js";
|
|
361
383
|
import {
|
|
362
384
|
DEFAULT_SKILL_OPT_CONFIG,
|
|
363
385
|
FALLBACK_MODELS_MAX,
|
|
@@ -371,7 +393,7 @@ import {
|
|
|
371
393
|
package_default,
|
|
372
394
|
resolveAutoReviewConfig,
|
|
373
395
|
stripKnownSwarmPrefix
|
|
374
|
-
} from "./index-
|
|
396
|
+
} from "./index-pf22x0dr.js";
|
|
375
397
|
import {
|
|
376
398
|
AGENT_TOOL_MAP,
|
|
377
399
|
ALL_AGENT_NAMES,
|
|
@@ -396,18 +418,6 @@ import {
|
|
|
396
418
|
getDeferredWarnings,
|
|
397
419
|
init_warning_buffer
|
|
398
420
|
} from "./index-4rhhvd1a.js";
|
|
399
|
-
import {
|
|
400
|
-
readSwarmFileAsync,
|
|
401
|
-
safeHook,
|
|
402
|
-
validateSwarmPath
|
|
403
|
-
} from "./index-4cgee5vh.js";
|
|
404
|
-
import {
|
|
405
|
-
bunSpawn,
|
|
406
|
-
bunSpawnSync,
|
|
407
|
-
bunWrite,
|
|
408
|
-
mergeEnvForChild,
|
|
409
|
-
sleep
|
|
410
|
-
} from "./index-r3mvsbtq.js";
|
|
411
421
|
import {
|
|
412
422
|
resolveHiveDataDir,
|
|
413
423
|
resolveHiveEventsPath,
|
|
@@ -423,10 +433,10 @@ import {
|
|
|
423
433
|
resolveLinkDir,
|
|
424
434
|
sanitizeLinkId,
|
|
425
435
|
writeLinkPointer
|
|
426
|
-
} from "./index-
|
|
436
|
+
} from "./index-jb9tb1sd.js";
|
|
427
437
|
import {
|
|
428
438
|
atomicWriteFile
|
|
429
|
-
} from "./index-
|
|
439
|
+
} from "./index-apwcvfjt.js";
|
|
430
440
|
import {
|
|
431
441
|
KNOWLEDGE_SCHEMA_VERSION,
|
|
432
442
|
OUTCOME_BLOCK_THRESHOLD,
|
|
@@ -438,7 +448,7 @@ import {
|
|
|
438
448
|
atomicWriteSwarmFileSync,
|
|
439
449
|
matchTempGrammar,
|
|
440
450
|
parseTargetBasename
|
|
441
|
-
} from "./index-
|
|
451
|
+
} from "./index-dtmgt2xn.js";
|
|
442
452
|
import {
|
|
443
453
|
assertProjectRoot,
|
|
444
454
|
hasExplicitProjectBoundary,
|
|
@@ -446,12 +456,12 @@ import {
|
|
|
446
456
|
listActiveLocks,
|
|
447
457
|
tryAcquireLock,
|
|
448
458
|
withEvidenceLock
|
|
449
|
-
} from "./index-
|
|
459
|
+
} from "./index-m8dn0qnm.js";
|
|
450
460
|
import {
|
|
451
461
|
emit,
|
|
452
462
|
getLastHeartbeat,
|
|
453
463
|
telemetry
|
|
454
|
-
} from "./index-
|
|
464
|
+
} from "./index-xggpmtfx.js";
|
|
455
465
|
import {
|
|
456
466
|
require_proper_lockfile
|
|
457
467
|
} from "./index-7g4c7s5r.js";
|
|
@@ -589,6 +599,7 @@ function formatLegacyQaBindingRecovery(identity, retryAction) {
|
|
|
589
599
|
}
|
|
590
600
|
|
|
591
601
|
// src/db/qa-gate-profile.ts
|
|
602
|
+
init_logger();
|
|
592
603
|
var _internals5 = {
|
|
593
604
|
getProfile,
|
|
594
605
|
getProfileLookupForIdentity,
|
|
@@ -816,7 +827,9 @@ function hasAnyProfileWithEnabledGate(directory, gate) {
|
|
|
816
827
|
const parsed = JSON.parse(row.gates);
|
|
817
828
|
if (parsed?.[gate] === true)
|
|
818
829
|
return true;
|
|
819
|
-
} catch {
|
|
830
|
+
} catch (err) {
|
|
831
|
+
warn(`[qa-gate-profile] skipping unparseable qa_gate_profile row while checking gate "${gate}": ${err instanceof Error ? err.message : String(err)}`);
|
|
832
|
+
}
|
|
820
833
|
}
|
|
821
834
|
return false;
|
|
822
835
|
}
|
|
@@ -1991,9 +2004,9 @@ var storedInputArgs = new Map;
|
|
|
1991
2004
|
|
|
1992
2005
|
// src/hooks/skill-propagation-gate.ts
|
|
1993
2006
|
init_schema();
|
|
1994
|
-
init_logger();
|
|
1995
2007
|
import * as fs4 from "fs";
|
|
1996
2008
|
import * as path6 from "path";
|
|
2009
|
+
init_logger();
|
|
1997
2010
|
|
|
1998
2011
|
// src/hooks/skill-scoring.ts
|
|
1999
2012
|
import * as fs3 from "fs";
|
|
@@ -4382,14 +4395,8 @@ function extractSkillsFieldFromPrompt(prompt) {
|
|
|
4382
4395
|
return "";
|
|
4383
4396
|
}
|
|
4384
4397
|
function writeWarnEvent(directory, record) {
|
|
4385
|
-
const filePath = path6.join(directory, ".swarm", "events.jsonl");
|
|
4386
4398
|
try {
|
|
4387
|
-
|
|
4388
|
-
if (!_internals10.existsSync(dir)) {
|
|
4389
|
-
_internals10.mkdirSync(dir, { recursive: true });
|
|
4390
|
-
}
|
|
4391
|
-
_internals10.appendFileSync(filePath, `${JSON.stringify(record)}
|
|
4392
|
-
`, "utf-8");
|
|
4399
|
+
appendCoreEventSync(directory, record);
|
|
4393
4400
|
} catch (err) {
|
|
4394
4401
|
warn(`[skill-propagation-gate] failed to write warning event: ${err instanceof Error ? err.message : String(err)}`);
|
|
4395
4402
|
}
|
|
@@ -5401,8 +5408,7 @@ init_logger();
|
|
|
5401
5408
|
import { spawnSync } from "child_process";
|
|
5402
5409
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
5403
5410
|
import { existsSync as existsSync6 } from "fs";
|
|
5404
|
-
import {
|
|
5405
|
-
import { dirname as dirname7 } from "path";
|
|
5411
|
+
import { readdir as readdir2 } from "fs/promises";
|
|
5406
5412
|
init_warning_buffer();
|
|
5407
5413
|
init_git_executable();
|
|
5408
5414
|
init_logger();
|
|
@@ -5440,32 +5446,17 @@ async function writeWal(filePath, wal) {
|
|
|
5440
5446
|
await writeWorkflowWalFile("coder-settlement", filePath, wal);
|
|
5441
5447
|
}
|
|
5442
5448
|
async function appendSettlementEvent(directory, action, wal, extra) {
|
|
5443
|
-
const line = `${JSON.stringify({
|
|
5444
|
-
type: "coder_settlement",
|
|
5445
|
-
action,
|
|
5446
|
-
timestamp: new Date().toISOString(),
|
|
5447
|
-
taskId: wal.taskId,
|
|
5448
|
-
transitionId: wal.transitionId,
|
|
5449
|
-
actor: wal.actor,
|
|
5450
|
-
...extra ?? {}
|
|
5451
|
-
})}
|
|
5452
|
-
`;
|
|
5453
5449
|
try {
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5450
|
+
appendCoreEventSync(directory, {
|
|
5451
|
+
type: "coder_settlement",
|
|
5452
|
+
action,
|
|
5453
|
+
timestamp: new Date().toISOString(),
|
|
5454
|
+
taskId: wal.taskId,
|
|
5455
|
+
transitionId: wal.transitionId,
|
|
5456
|
+
actor: wal.actor,
|
|
5457
|
+
...extra ?? {}
|
|
5458
|
+
});
|
|
5457
5459
|
} catch (error2) {
|
|
5458
|
-
const code = error2.code;
|
|
5459
|
-
if (code === "EBUSY" || code === "EPERM") {
|
|
5460
|
-
try {
|
|
5461
|
-
const eventsPath = validateSwarmPath(directory, "events.jsonl");
|
|
5462
|
-
await appendFile2(eventsPath, line, "utf-8");
|
|
5463
|
-
return;
|
|
5464
|
-
} catch (retryError) {
|
|
5465
|
-
criticalWarn(`[coder-settlement] lifecycle event write failed after retry (${action} ${wal.taskId}): ${retryError instanceof Error ? retryError.message : String(retryError)}`);
|
|
5466
|
-
return;
|
|
5467
|
-
}
|
|
5468
|
-
}
|
|
5469
5460
|
criticalWarn(`[coder-settlement] lifecycle event write failed (${action} ${wal.taskId}): ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
5470
5461
|
}
|
|
5471
5462
|
}
|
|
@@ -5608,7 +5599,7 @@ async function cleanupRecoveredWorktree(directory, descriptor) {
|
|
|
5608
5599
|
awaitingMergeByCallID,
|
|
5609
5600
|
cleanupStandardWorktreeForCallId,
|
|
5610
5601
|
standardWorktreeByCallID
|
|
5611
|
-
} = await import("./worktree-isolation-
|
|
5602
|
+
} = await import("./worktree-isolation-1hwwfbdw.js");
|
|
5612
5603
|
standardWorktreeByCallID.delete(descriptor.callID);
|
|
5613
5604
|
if (hasResidue)
|
|
5614
5605
|
awaitingMergeByCallID.set(descriptor.callID, {
|
|
@@ -5710,7 +5701,7 @@ async function recoverCoderSettlement(directory, taskId) {
|
|
|
5710
5701
|
awaitingMergeByCallID,
|
|
5711
5702
|
finishStandardWorktreeDispatch,
|
|
5712
5703
|
standardWorktreeByCallID
|
|
5713
|
-
} = await import("./worktree-isolation-
|
|
5704
|
+
} = await import("./worktree-isolation-1hwwfbdw.js");
|
|
5714
5705
|
const descriptor = wal.worktree;
|
|
5715
5706
|
const reconstructedDispatch = {
|
|
5716
5707
|
callID: descriptor.callID,
|
|
@@ -5980,17 +5971,15 @@ var _internals13 = {
|
|
|
5980
5971
|
};
|
|
5981
5972
|
|
|
5982
5973
|
// src/workflow/task-repair.ts
|
|
5983
|
-
import { appendFile as appendFile3, readFile as readFile4 } from "fs/promises";
|
|
5984
5974
|
async function recoverPreparedTaskRepairWithPlanLock(directory, taskId, actor, currentPlan) {
|
|
5985
5975
|
const walPath2 = validateSwarmPath(directory, `task-repairs/${taskId}.json`);
|
|
5986
|
-
const eventsPath = validateSwarmPath(directory, "events.jsonl");
|
|
5987
5976
|
const wal = await readWal2(walPath2, taskId);
|
|
5988
5977
|
if (wal === null)
|
|
5989
5978
|
return null;
|
|
5990
5979
|
if (wal.state === "ABORTED")
|
|
5991
5980
|
return null;
|
|
5992
5981
|
if (wal.state === "COMMITTED") {
|
|
5993
|
-
await ensureAuditEvent(directory,
|
|
5982
|
+
await ensureAuditEvent(directory, wal);
|
|
5994
5983
|
return null;
|
|
5995
5984
|
}
|
|
5996
5985
|
const task = currentPlan.phases.flatMap((phase) => phase.tasks).find((candidate) => candidate.id === taskId);
|
|
@@ -6030,57 +6019,15 @@ async function recoverPreparedTaskRepairUnderPlanLock(directory, taskId, actor,
|
|
|
6030
6019
|
async function readWal2(filePath, taskId) {
|
|
6031
6020
|
return readWorkflowWalFile("task-repair", filePath, taskId);
|
|
6032
6021
|
}
|
|
6033
|
-
async function readText(filePath) {
|
|
6034
|
-
try {
|
|
6035
|
-
return await readFile4(filePath, "utf-8");
|
|
6036
|
-
} catch (error2) {
|
|
6037
|
-
if (error2.code === "ENOENT")
|
|
6038
|
-
return null;
|
|
6039
|
-
throw error2;
|
|
6040
|
-
}
|
|
6041
|
-
}
|
|
6042
6022
|
async function writeWal2(filePath, wal) {
|
|
6043
6023
|
await writeWorkflowWalFile("task-repair", filePath, wal);
|
|
6044
6024
|
}
|
|
6045
|
-
function
|
|
6046
|
-
|
|
6047
|
-
return JSON.parse(line);
|
|
6048
|
-
} catch {
|
|
6049
|
-
return null;
|
|
6050
|
-
}
|
|
6051
|
-
}
|
|
6052
|
-
function findRepairEvent(content, taskId, transitionId) {
|
|
6053
|
-
if (!content)
|
|
6054
|
-
return false;
|
|
6055
|
-
const transitionNeedle = JSON.stringify(transitionId).slice(1, -1);
|
|
6056
|
-
const taskNeedle = JSON.stringify(taskId).slice(1, -1);
|
|
6057
|
-
if (!content.includes(transitionNeedle) || !content.includes(taskNeedle))
|
|
6058
|
-
return false;
|
|
6059
|
-
for (const line of content.split(`
|
|
6060
|
-
`)) {
|
|
6061
|
-
if (!line.trim())
|
|
6062
|
-
continue;
|
|
6063
|
-
const event = parseAuditEventLine(line);
|
|
6064
|
-
if (!event)
|
|
6065
|
-
continue;
|
|
6066
|
-
if (event.type === "task_workflow_repaired" && event.taskId === taskId && event.transitionId === transitionId) {
|
|
6067
|
-
return true;
|
|
6068
|
-
}
|
|
6069
|
-
}
|
|
6070
|
-
return false;
|
|
6071
|
-
}
|
|
6072
|
-
async function ensureAuditEvent(directory, eventsPath, wal) {
|
|
6073
|
-
if (findRepairEvent(await readText(eventsPath), wal.taskId, wal.transitionId))
|
|
6025
|
+
async function ensureAuditEvent(directory, wal) {
|
|
6026
|
+
if (hasTaskRepairAuditEvent(directory, wal.taskId, wal.transitionId)) {
|
|
6074
6027
|
return;
|
|
6075
|
-
const lock = await tryAcquireLock(directory, "events.jsonl", "task-repair-audit", `task-repair:${wal.taskId}:${wal.transitionId}`);
|
|
6076
|
-
if (!lock.acquired) {
|
|
6077
|
-
throw new Error("TASK_REPAIR_AUDIT_LOCKED");
|
|
6078
6028
|
}
|
|
6079
6029
|
try {
|
|
6080
|
-
|
|
6081
|
-
if (findRepairEvent(existing, wal.taskId, wal.transitionId))
|
|
6082
|
-
return;
|
|
6083
|
-
await appendFile3(eventsPath, `${JSON.stringify({
|
|
6030
|
+
appendCoreEventSync(directory, {
|
|
6084
6031
|
type: "task_workflow_repaired",
|
|
6085
6032
|
timestamp: new Date().toISOString(),
|
|
6086
6033
|
taskId: wal.taskId,
|
|
@@ -6092,15 +6039,15 @@ async function ensureAuditEvent(directory, eventsPath, wal) {
|
|
|
6092
6039
|
oldWorkflowState: wal.oldWorkflowState,
|
|
6093
6040
|
newWorkflowState: wal.newWorkflowState,
|
|
6094
6041
|
generation: wal.generation
|
|
6095
|
-
})
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
throw new Error("TASK_REPAIR_AUDIT_UNVERIFIED");
|
|
6042
|
+
}, { dedupeOnAuthorityKey: true });
|
|
6043
|
+
} catch (error2) {
|
|
6044
|
+
if (error2 instanceof Error && error2.message === CORE_EVENT_LOCKED) {
|
|
6045
|
+
throw new Error("TASK_REPAIR_AUDIT_LOCKED");
|
|
6100
6046
|
}
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6047
|
+
throw error2;
|
|
6048
|
+
}
|
|
6049
|
+
if (!hasTaskRepairAuditEvent(directory, wal.taskId, wal.transitionId)) {
|
|
6050
|
+
throw new Error("TASK_REPAIR_AUDIT_UNVERIFIED");
|
|
6104
6051
|
}
|
|
6105
6052
|
}
|
|
6106
6053
|
function workflowMatchesCommittedRepair(evidence, wal) {
|
|
@@ -6109,7 +6056,6 @@ function workflowMatchesCommittedRepair(evidence, wal) {
|
|
|
6109
6056
|
}
|
|
6110
6057
|
async function repairTaskWorkflowUnderPlanLock(options) {
|
|
6111
6058
|
const walPath2 = validateSwarmPath(options.directory, `task-repairs/${options.taskId}.json`);
|
|
6112
|
-
const eventsPath = validateSwarmPath(options.directory, "events.jsonl");
|
|
6113
6059
|
return withTaskEvidenceTransaction(options.directory, options.taskId, options.actor, async (transaction) => {
|
|
6114
6060
|
await assertNoUnsettledCoderDispatch(options.directory, options.taskId);
|
|
6115
6061
|
let evidence = transaction.read();
|
|
@@ -6127,7 +6073,7 @@ async function repairTaskWorkflowUnderPlanLock(options) {
|
|
|
6127
6073
|
throw new Error(`TASK_REPAIR_IDEMPOTENCY_CONFLICT: transition ${options.transitionId} was prepared with different reason or workflow CAS fields`);
|
|
6128
6074
|
}
|
|
6129
6075
|
if (existingWal?.state === "COMMITTED" && options.currentPlanStatus === "in_progress" && workflowMatchesCommittedRepair(evidence, existingWal)) {
|
|
6130
|
-
await ensureAuditEvent(options.directory,
|
|
6076
|
+
await ensureAuditEvent(options.directory, existingWal);
|
|
6131
6077
|
return {
|
|
6132
6078
|
plan: options.currentPlan,
|
|
6133
6079
|
alreadyApplied: true,
|
|
@@ -6180,7 +6126,7 @@ async function repairTaskWorkflowUnderPlanLock(options) {
|
|
|
6180
6126
|
}
|
|
6181
6127
|
}
|
|
6182
6128
|
await writeWal2(walPath2, { ...wal, state: "COMMITTED" });
|
|
6183
|
-
await ensureAuditEvent(options.directory,
|
|
6129
|
+
await ensureAuditEvent(options.directory, wal);
|
|
6184
6130
|
return {
|
|
6185
6131
|
plan,
|
|
6186
6132
|
alreadyApplied: false,
|
|
@@ -6633,6 +6579,69 @@ function repairCleanEvidencePipes(text) {
|
|
|
6633
6579
|
return { text: lines.join(`
|
|
6634
6580
|
`), repaired };
|
|
6635
6581
|
}
|
|
6582
|
+
function escapeCandidateField(value) {
|
|
6583
|
+
return value.trim().replace(/\|/g, "\\|");
|
|
6584
|
+
}
|
|
6585
|
+
function repairCandidateEvidencePipes(text, family) {
|
|
6586
|
+
let repaired = false;
|
|
6587
|
+
const lines = text.split(/\r?\n/).map((line) => {
|
|
6588
|
+
const fields = splitPipeFields(line);
|
|
6589
|
+
if (fields[0]?.trim() !== CANDIDATE_MARKER || fields.length <= CANDIDATE_FIELD_COUNT + 1 || fields.length > CANDIDATE_FIELD_COUNT + 17 || !isCandidateConfidence(fields.at(-1)?.trim())) {
|
|
6590
|
+
return line;
|
|
6591
|
+
}
|
|
6592
|
+
const normalized = fields.map(escapeCandidateField);
|
|
6593
|
+
const overflowEvidence = family === "base_explorer" ? normalized.slice(7, -2) : normalized.slice(8, -1);
|
|
6594
|
+
if (overflowEvidence.length < 3 || overflowEvidence.some((fragment) => fragment.length < 4)) {
|
|
6595
|
+
return line;
|
|
6596
|
+
}
|
|
6597
|
+
const rebuilt = family === "base_explorer" ? [
|
|
6598
|
+
...normalized.slice(0, 7),
|
|
6599
|
+
overflowEvidence.join(" \\| "),
|
|
6600
|
+
...normalized.slice(-2)
|
|
6601
|
+
] : [
|
|
6602
|
+
...normalized.slice(0, 8),
|
|
6603
|
+
overflowEvidence.join(" \\| "),
|
|
6604
|
+
normalized.at(-1) ?? ""
|
|
6605
|
+
];
|
|
6606
|
+
if (rebuilt.length !== CANDIDATE_FIELD_COUNT + 1)
|
|
6607
|
+
return line;
|
|
6608
|
+
repaired = true;
|
|
6609
|
+
return rebuilt.join(" | ");
|
|
6610
|
+
});
|
|
6611
|
+
return { text: lines.join(`
|
|
6612
|
+
`), repaired };
|
|
6613
|
+
}
|
|
6614
|
+
function resynchronizeLateCanonicalHeader(text, family) {
|
|
6615
|
+
const lines = text.split(/\r?\n/);
|
|
6616
|
+
const firstMarker = lines.findIndex((line) => {
|
|
6617
|
+
const marker = splitPipeFields(line)[0]?.trim();
|
|
6618
|
+
return marker === CANDIDATE_MARKER || marker === CLEAN_MARKER;
|
|
6619
|
+
});
|
|
6620
|
+
if (firstMarker < 0 || !analyzeCandidateLine(lines[firstMarker], family)?.valid) {
|
|
6621
|
+
return { text, repaired: false };
|
|
6622
|
+
}
|
|
6623
|
+
const headerIndexes = lines.flatMap((line, index) => line.trim() === CANDIDATE_HEADERS[family] ? [index] : []);
|
|
6624
|
+
if (!headerIndexes.some((index) => index > firstMarker)) {
|
|
6625
|
+
return { text, repaired: false };
|
|
6626
|
+
}
|
|
6627
|
+
if (declaredCanonicalFamilies(text).some((declared) => declared !== family)) {
|
|
6628
|
+
return { text, repaired: false };
|
|
6629
|
+
}
|
|
6630
|
+
const withoutHeaders = lines.filter((_line, index) => !headerIndexes.includes(index));
|
|
6631
|
+
const insertion = withoutHeaders.findIndex((line) => {
|
|
6632
|
+
const marker = splitPipeFields(line)[0]?.trim();
|
|
6633
|
+
return marker === CANDIDATE_MARKER || marker === CLEAN_MARKER;
|
|
6634
|
+
});
|
|
6635
|
+
return {
|
|
6636
|
+
text: [
|
|
6637
|
+
...withoutHeaders.slice(0, insertion),
|
|
6638
|
+
CANDIDATE_HEADERS[family],
|
|
6639
|
+
...withoutHeaders.slice(insertion)
|
|
6640
|
+
].join(`
|
|
6641
|
+
`),
|
|
6642
|
+
repaired: true
|
|
6643
|
+
};
|
|
6644
|
+
}
|
|
6636
6645
|
function isStrictProtocolDataLine(line, family) {
|
|
6637
6646
|
const clean = repairRedundantCleanConfidenceLine(line, family).line;
|
|
6638
6647
|
const fields = splitPipeFields(clean).map((field) => field.trim());
|
|
@@ -6701,7 +6710,15 @@ function normalizeCandidateArtifact(rawText, fallbackFamily) {
|
|
|
6701
6710
|
const pipeRepair = repairCleanEvidencePipes(cleanRepair.text);
|
|
6702
6711
|
if (pipeRepair.repaired)
|
|
6703
6712
|
repairKinds.push("clean-evidence-pipe-tail-merge");
|
|
6704
|
-
const
|
|
6713
|
+
const candidatePipeRepair = repairCandidateEvidencePipes(pipeRepair.text, fallbackFamily);
|
|
6714
|
+
if (candidatePipeRepair.repaired) {
|
|
6715
|
+
repairKinds.push("candidate-evidence-pipe-recovery-lossy");
|
|
6716
|
+
}
|
|
6717
|
+
const lateHeaderRepair = resynchronizeLateCanonicalHeader(candidatePipeRepair.text, fallbackFamily);
|
|
6718
|
+
if (lateHeaderRepair.repaired) {
|
|
6719
|
+
repairKinds.push("late-canonical-header-resynchronized");
|
|
6720
|
+
}
|
|
6721
|
+
const duplicateHeaderDrop = dropDuplicateHeaderRows(lateHeaderRepair.text);
|
|
6705
6722
|
if (duplicateHeaderDrop.dropped) {
|
|
6706
6723
|
repairKinds.push("duplicate-header-row-dropped");
|
|
6707
6724
|
}
|
|
@@ -7737,13 +7754,24 @@ var PrReviewHandoffSchema = exports_external.object({
|
|
|
7737
7754
|
summary: exports_external.string().trim().min(1).max(20000),
|
|
7738
7755
|
provenance: exports_external.array(exports_external.string().trim().min(1).max(4000)).min(1).max(1000)
|
|
7739
7756
|
}).strict();
|
|
7757
|
+
var PrReviewPartialBaseCoverageSchema = exports_external.object({
|
|
7758
|
+
missing_dimension: exports_external.enum([
|
|
7759
|
+
"intent-architecture",
|
|
7760
|
+
"correctness-state",
|
|
7761
|
+
"tests-falsifiability",
|
|
7762
|
+
"security-trust",
|
|
7763
|
+
"reliability-performance",
|
|
7764
|
+
"compatibility-delivery"
|
|
7765
|
+
])
|
|
7766
|
+
}).strict();
|
|
7740
7767
|
var WritePrReviewArtifactArgsSchema = exports_external.discriminatedUnion("kind", [
|
|
7741
7768
|
exports_external.object({
|
|
7742
7769
|
kind: exports_external.literal("findings"),
|
|
7743
7770
|
run_id: PrReviewRunIdSchema.optional(),
|
|
7744
7771
|
pr_head_sha: exports_external.string().trim().regex(/^[0-9a-f]{6,64}$/i),
|
|
7745
7772
|
boundary: exports_external.enum(PR_REVIEW_ARTIFACT_BOUNDARIES),
|
|
7746
|
-
records: exports_external.array(PrReviewFindingSchema).min(1).max(1000)
|
|
7773
|
+
records: exports_external.array(PrReviewFindingSchema).min(1).max(1000),
|
|
7774
|
+
partial_base_coverage: PrReviewPartialBaseCoverageSchema.optional()
|
|
7747
7775
|
}).strict(),
|
|
7748
7776
|
exports_external.object({
|
|
7749
7777
|
kind: exports_external.literal("handoff"),
|
|
@@ -7752,6 +7780,13 @@ var WritePrReviewArtifactArgsSchema = exports_external.discriminatedUnion("kind"
|
|
|
7752
7780
|
handoff: PrReviewHandoffSchema
|
|
7753
7781
|
}).strict()
|
|
7754
7782
|
]).superRefine((value, ctx) => {
|
|
7783
|
+
if (value.kind === "findings" && value.partial_base_coverage !== undefined && value.boundary !== "post_explorer") {
|
|
7784
|
+
ctx.addIssue({
|
|
7785
|
+
code: "custom",
|
|
7786
|
+
path: ["partial_base_coverage"],
|
|
7787
|
+
message: "is valid only for the post_explorer boundary"
|
|
7788
|
+
});
|
|
7789
|
+
}
|
|
7755
7790
|
const bytes = serializedPrReviewArtifactInputBytes(value);
|
|
7756
7791
|
const maxBytes = value.kind === "findings" ? PR_REVIEW_FINDINGS_WRITE_MAX_BYTES : PR_REVIEW_HANDOFF_WRITE_MAX_BYTES;
|
|
7757
7792
|
if (bytes > maxBytes) {
|
|
@@ -8586,6 +8621,15 @@ var PrReviewResilienceStateRecordSchema = exports_external.object({
|
|
|
8586
8621
|
attempts: exports_external.array(PrReviewResilienceAttemptRecordSchema).max(3),
|
|
8587
8622
|
circuit: PrReviewResilienceCircuitRecordSchema.optional()
|
|
8588
8623
|
}).strict();
|
|
8624
|
+
var PrReviewPartialBaseCoverageRecordSchema = exports_external.object({
|
|
8625
|
+
runId: exports_external.string().min(1).max(128),
|
|
8626
|
+
prHeadSha: exports_external.string().regex(/^[0-9a-f]{6,64}$/i),
|
|
8627
|
+
revisionDigest: exports_external.string().min(1).max(256),
|
|
8628
|
+
missingDimension: exports_external.enum(PR_REVIEW_BASE_DIMENSION_IDS),
|
|
8629
|
+
failureClass: exports_external.enum(["contract", "resource", "deadline"]),
|
|
8630
|
+
terminalEventId: exports_external.string().min(1).max(256),
|
|
8631
|
+
admittedAt: exports_external.string().datetime()
|
|
8632
|
+
}).strict();
|
|
8589
8633
|
var PrFeedbackLaneOwnershipSchema = exports_external.object({
|
|
8590
8634
|
laneId: exports_external.string().min(1),
|
|
8591
8635
|
ownedItemIds: exports_external.array(exports_external.string().min(1)).min(1)
|
|
@@ -8738,6 +8782,7 @@ var PrWorkflowGateStateSchema = exports_external.object({
|
|
|
8738
8782
|
prReviewBaseDispatches: exports_external.array(PrReviewBaseDispatchRecordSchema).max(MAX_WORKFLOW_BATCHES).optional(),
|
|
8739
8783
|
prReviewBaseDispatch: PrReviewBaseDispatchRecordSchema.optional(),
|
|
8740
8784
|
prReviewResilience: PrReviewResilienceStateRecordSchema.optional(),
|
|
8785
|
+
prReviewContractRetryDimensions: exports_external.array(PrReviewBaseDimensionIdSchema).max(PR_REVIEW_BASE_DIMENSION_IDS.length).optional(),
|
|
8741
8786
|
prReviewTriggerLedger: exports_external.array(PrReviewInlineTriggerRowSchema).length(PR_REVIEW_REQUIRED_TRIGGER_IDS.length).optional(),
|
|
8742
8787
|
prReviewTriggerEvalPath: exports_external.string().min(1).optional(),
|
|
8743
8788
|
prReviewTriggerEvalRunId: exports_external.string().min(1).optional(),
|
|
@@ -8748,6 +8793,9 @@ var PrWorkflowGateStateSchema = exports_external.object({
|
|
|
8748
8793
|
prReviewReservedRunId: exports_external.string().min(1).optional(),
|
|
8749
8794
|
prReviewArtifactRunId: exports_external.string().min(1).optional(),
|
|
8750
8795
|
prReviewFindingsPath: exports_external.string().min(1).optional(),
|
|
8796
|
+
prReviewPartialBaseCoverage: PrReviewPartialBaseCoverageRecordSchema.optional(),
|
|
8797
|
+
prReviewCoverageDisclosurePath: exports_external.string().min(1).max(512).optional(),
|
|
8798
|
+
prReviewCoverageDisclosureDigest: exports_external.string().regex(/^[0-9a-f]{64}$/).optional(),
|
|
8751
8799
|
prReviewArtifactBoundaries: exports_external.array(exports_external.enum(["post_explorer", "post_reviewer", "post_critic"])).max(3).optional(),
|
|
8752
8800
|
prReviewHandoffPath: exports_external.string().min(1).optional(),
|
|
8753
8801
|
prReviewHandoffRequired: exports_external.boolean().optional(),
|
|
@@ -8874,13 +8922,6 @@ var PR_WORKFLOW_SWEEPABLE_LANE_STATUSES = new Set(["pending", "running"]);
|
|
|
8874
8922
|
var CAS_ESCAPE_DISCLOSURE = "state revision unsalvageable; cleared without compare-and-swap";
|
|
8875
8923
|
var PR_WORKFLOW_LANE_LIVENESS_PROBE_TIMEOUT_MS = 5000;
|
|
8876
8924
|
var PR_WORKFLOW_PENDING_LIVENESS_THRESHOLD_MS = 3 * 60000;
|
|
8877
|
-
var PR_WORKFLOW_PENDING_LIVENESS_MODES = new Set([
|
|
8878
|
-
"swarm-pr-review:base",
|
|
8879
|
-
"swarm-pr-review:micro",
|
|
8880
|
-
"swarm-pr-review:council",
|
|
8881
|
-
"swarm-pr-review:reviewer",
|
|
8882
|
-
"swarm-pr-review:critic"
|
|
8883
|
-
]);
|
|
8884
8925
|
var LIVE_SESSION_STATUS_TYPES = new Set([
|
|
8885
8926
|
"busy",
|
|
8886
8927
|
"retry"
|
|
@@ -9022,7 +9063,7 @@ async function settlePresumedStalePrWorkflowLanes(directory, sessionID) {
|
|
|
9022
9063
|
});
|
|
9023
9064
|
} catch {}
|
|
9024
9065
|
try {
|
|
9025
|
-
|
|
9066
|
+
appendCoreEventSync(directory, {
|
|
9026
9067
|
type: "pr_workflow_lanes_presumed_stale",
|
|
9027
9068
|
timestamp: isoNow(),
|
|
9028
9069
|
sessionID,
|
|
@@ -9031,8 +9072,7 @@ async function settlePresumedStalePrWorkflowLanes(directory, sessionID) {
|
|
|
9031
9072
|
probeStatus: probe.degradedReason ?? "ok",
|
|
9032
9073
|
probedAliveLanes: probedAliveLaneIds.slice(0, MAX_DISCLOSED_LANE_IDS),
|
|
9033
9074
|
disclosure
|
|
9034
|
-
})
|
|
9035
|
-
`, "utf-8");
|
|
9075
|
+
});
|
|
9036
9076
|
} catch {}
|
|
9037
9077
|
return {
|
|
9038
9078
|
openLaneIds,
|
|
@@ -9123,9 +9163,7 @@ async function abortPrWorkflow(directory, sessionID, options = { kind: "recovery
|
|
|
9123
9163
|
reason: sanitizedReason
|
|
9124
9164
|
};
|
|
9125
9165
|
try {
|
|
9126
|
-
|
|
9127
|
-
await fsp2.appendFile(eventsPath, `${JSON.stringify(abortEvent)}
|
|
9128
|
-
`, "utf-8");
|
|
9166
|
+
appendCoreEventSync(directory, abortEvent);
|
|
9129
9167
|
} catch {}
|
|
9130
9168
|
const casEscape = recovery.salvaged && !recovery.revisionSalvageable;
|
|
9131
9169
|
await _test_exports2.beforeAbortClear?.();
|
|
@@ -9133,7 +9171,7 @@ async function abortPrWorkflow(directory, sessionID, options = { kind: "recovery
|
|
|
9133
9171
|
await clearPrWorkflowGateState(directory, sessionID, casEscape ? undefined : state.revision, { allowSalvagedRead: recovery.salvaged });
|
|
9134
9172
|
} catch (error2) {
|
|
9135
9173
|
try {
|
|
9136
|
-
|
|
9174
|
+
appendCoreEventSync(directory, {
|
|
9137
9175
|
type: "pr_workflow_abort_not_completed",
|
|
9138
9176
|
timestamp: isoNow(),
|
|
9139
9177
|
sessionID: state.sessionID,
|
|
@@ -9146,8 +9184,7 @@ async function abortPrWorkflow(directory, sessionID, options = { kind: "recovery
|
|
|
9146
9184
|
} : {},
|
|
9147
9185
|
failure: (error2 instanceof Error ? error2.message : String(error2)).slice(0, MAX_BASE_COVERAGE_DIAGNOSTIC_CHARS),
|
|
9148
9186
|
disclosure: "RETRACTION: the pr_workflow_aborted record for this session did NOT complete \u2014 " + "the clear failed and the gate state may still be active. Revalidate the current " + "session state before retrying the abort." + (overridesProbeRetention ? " The probe-retention override finalized no record: it runs only after the " + "clear succeeds, and this clear failed. Other lanes in the same settlement " + "batch may already have been finalized as presumed-stale, and a concurrent abort for this session may have finalized more \u2014 revalidate the lane records rather than assuming they are untouched." : "")
|
|
9149
|
-
})
|
|
9150
|
-
`, "utf-8");
|
|
9187
|
+
});
|
|
9151
9188
|
} catch {}
|
|
9152
9189
|
throw error2;
|
|
9153
9190
|
}
|
|
@@ -9282,6 +9319,28 @@ async function assertPrFeedbackTrackingCheckout(directory, prHeadSha) {
|
|
|
9282
9319
|
throw new Error(`BLOCKED: PR_FEEDBACK upstream "${attachedUpstream.remoteTrackingRef}" must point to the exact intake PR head "${prHeadSha}" before the first head bind`);
|
|
9283
9320
|
}
|
|
9284
9321
|
}
|
|
9322
|
+
function normalizeFailureSignatureText(value) {
|
|
9323
|
+
return value.toLowerCase().replace(/\b\d{4}-\d{2}-\d{2}t\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:z|[+-]\d{2}:\d{2})\b/g, "<iso-timestamp>").replace(/\b\d{10,16}\b/g, "<epoch>").replace(/\b((?:session|request|trace|correlation|run)(?:[_-]?id)?)\s*[:=]\s*([a-z0-9._:-]*[0-9_-][a-z0-9._:-]*)\b/g, "$1=<id>").replace(/\b((?:session|sess|request|req|trace|correlation|corr|run)(?:[_-]?id)?)\s+((?:(?:sess?|req|trace|corr|run)[_-][a-z0-9._:-]+|[a-z][a-z0-9._:-]*\d[a-z0-9._:-]*))\b/g, "$1 <id>").replace(/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/g, "<uuid>").replace(/\b[0-9a-f]{16,64}\b/g, "<hex>").replace(/[a-z]:\\[^\s)]+/gi, "<path>").replace(/(?:\/[\w.@:-]+)+/g, "<path>").replace(/\s+/g, " ").trim().slice(0, 160);
|
|
9324
|
+
}
|
|
9325
|
+
function classifyTerminalFailureSignature(record) {
|
|
9326
|
+
if (!TERMINAL_FAILED_DELEGATION_STATUSES.has(record.status))
|
|
9327
|
+
return null;
|
|
9328
|
+
const result = record.terminalResult?.result ?? record.result;
|
|
9329
|
+
if (!result)
|
|
9330
|
+
return `terminal-zero-output:${record.status}`;
|
|
9331
|
+
const outputRef = result.outputRef?.trim();
|
|
9332
|
+
const text = result.text?.trim() ?? "";
|
|
9333
|
+
if (!outputRef && text.length === 0 && (result.chars ?? 0) === 0) {
|
|
9334
|
+
return `terminal-zero-output:${record.status}`;
|
|
9335
|
+
}
|
|
9336
|
+
const errorText = result.error?.trim();
|
|
9337
|
+
if (errorText) {
|
|
9338
|
+
return `terminal-error-output:${record.status}:${normalizeFailureSignatureText(errorText)}`;
|
|
9339
|
+
}
|
|
9340
|
+
if (record.status === "completed")
|
|
9341
|
+
return null;
|
|
9342
|
+
return `terminal-nonzero-output:${record.status}`;
|
|
9343
|
+
}
|
|
9285
9344
|
var TERMINAL_FAILED_DELEGATION_STATUSES = new Set([
|
|
9286
9345
|
"completed",
|
|
9287
9346
|
"error",
|
|
@@ -9337,6 +9396,40 @@ function minimumConsolidatedLaneCover(sets) {
|
|
|
9337
9396
|
}
|
|
9338
9397
|
return best[full];
|
|
9339
9398
|
}
|
|
9399
|
+
var PR_REVIEW_COVERAGE_DISCLOSURE_MAX_BYTES = 4096;
|
|
9400
|
+
function coverageDisclosureRelativePath(runId) {
|
|
9401
|
+
return path12.join("pr-review", runId, "coverage-disclosure.json");
|
|
9402
|
+
}
|
|
9403
|
+
async function readAndVerifyCoverageDisclosure(directory, state) {
|
|
9404
|
+
const record = state.prReviewPartialBaseCoverage;
|
|
9405
|
+
const relativePath = state.prReviewCoverageDisclosurePath;
|
|
9406
|
+
const expectedDigest = state.prReviewCoverageDisclosureDigest;
|
|
9407
|
+
if (!record && !relativePath && !expectedDigest)
|
|
9408
|
+
return null;
|
|
9409
|
+
if (!record || !relativePath || !expectedDigest) {
|
|
9410
|
+
throw new Error("BLOCKED: PR_REVIEW partial base coverage disclosure state is incomplete");
|
|
9411
|
+
}
|
|
9412
|
+
const expectedPath = coverageDisclosureRelativePath(record.runId).split(path12.sep).join("/");
|
|
9413
|
+
if (relativePath !== expectedPath) {
|
|
9414
|
+
throw new Error("BLOCKED: PR_REVIEW partial base coverage disclosure path does not match its bound run");
|
|
9415
|
+
}
|
|
9416
|
+
const raw = await readBoundedSwarmRegularFile(directory, relativePath, PR_REVIEW_COVERAGE_DISCLOSURE_MAX_BYTES, "PR_REVIEW partial base coverage disclosure");
|
|
9417
|
+
const digest = createHash5("sha256").update(raw, "utf8").digest("hex");
|
|
9418
|
+
if (digest !== expectedDigest) {
|
|
9419
|
+
throw new Error("BLOCKED: PR_REVIEW partial base coverage disclosure digest does not match durable state");
|
|
9420
|
+
}
|
|
9421
|
+
let decoded;
|
|
9422
|
+
try {
|
|
9423
|
+
decoded = JSON.parse(raw);
|
|
9424
|
+
} catch {
|
|
9425
|
+
throw new Error("BLOCKED: PR_REVIEW partial base coverage disclosure is invalid JSON");
|
|
9426
|
+
}
|
|
9427
|
+
const parsed = PrReviewPartialBaseCoverageRecordSchema.safeParse(decoded);
|
|
9428
|
+
if (!parsed.success || JSON.stringify(parsed.data) !== JSON.stringify(record)) {
|
|
9429
|
+
throw new Error("BLOCKED: PR_REVIEW partial base coverage disclosure does not match durable state");
|
|
9430
|
+
}
|
|
9431
|
+
return record;
|
|
9432
|
+
}
|
|
9340
9433
|
async function assertPrReviewBaseCoverageSettled(directory, sessionID, gateContext) {
|
|
9341
9434
|
const state = await requireBoundState(directory, sessionID, "PR_REVIEW");
|
|
9342
9435
|
const batches = state.prReviewBaseDispatches ?? [];
|
|
@@ -9354,6 +9447,10 @@ async function assertPrReviewBaseCoverageSettled(directory, sessionID, gateConte
|
|
|
9354
9447
|
}
|
|
9355
9448
|
const missing = PR_REVIEW_BASE_DIMENSION_IDS.filter((dimension) => !covered.has(dimension));
|
|
9356
9449
|
if (missing.length > 0 || covered.size !== PR_REVIEW_BASE_DIMENSION_IDS.length) {
|
|
9450
|
+
const disclosure = await readAndVerifyCoverageDisclosure(directory, state);
|
|
9451
|
+
if (disclosure && missing.length === 1 && covered.size === PR_REVIEW_BASE_DIMENSION_IDS.length - 1 && disclosure.missingDimension === missing[0] && disclosure.prHeadSha === state.prHeadSha && disclosure.revisionDigest === ctx.revisionDigest && disclosure.runId === (state.prReviewArtifactRunId ?? state.prReviewReservedRunId)) {
|
|
9452
|
+
return state;
|
|
9453
|
+
}
|
|
9357
9454
|
throw new Error(`BLOCKED: PR_REVIEW base coverage is incomplete; missing dimensions: ${missing.join(", ") || "(none)"}${malformedDiagnostics.length > 0 ? `; first failed lane predicates: ${malformedDiagnostics.join(" | ")}` : ""}; valid dimensions: ${PR_REVIEW_BASE_DIMENSION_IDS.join(", ")}; expected candidate row: ${CANDIDATE_HEADERS.base_explorer}; expected clean row: ${CLEAN_TEMPLATES.base_explorer}`);
|
|
9358
9455
|
}
|
|
9359
9456
|
return state;
|
|
@@ -9855,6 +9952,7 @@ async function transitionPrReviewToFeedback(directory, sessionID, request) {
|
|
|
9855
9952
|
}));
|
|
9856
9953
|
}
|
|
9857
9954
|
var _test_exports2 = {
|
|
9955
|
+
classifyTerminalFailureSignature,
|
|
9858
9956
|
minimumConsolidatedLaneCover,
|
|
9859
9957
|
analyzePrReviewBatchRecordIntegrity,
|
|
9860
9958
|
MAX_COVER_UNIVERSE_BITS,
|
|
@@ -12116,8 +12214,8 @@ ${USAGE}`;
|
|
|
12116
12214
|
|
|
12117
12215
|
// src/services/spec-drift-recovery.ts
|
|
12118
12216
|
import { createHash as createHash6 } from "crypto";
|
|
12119
|
-
import {
|
|
12120
|
-
import { dirname as
|
|
12217
|
+
import { mkdir as mkdir4, readFile as readFile5, unlink as unlink2 } from "fs/promises";
|
|
12218
|
+
import { dirname as dirname9 } from "path";
|
|
12121
12219
|
var SPEC_DRIFT_RECOVERY_AGENT = "spec-drift-recovery";
|
|
12122
12220
|
var _internals16 = {
|
|
12123
12221
|
appendEvent,
|
|
@@ -12177,7 +12275,7 @@ function parseWal(raw) {
|
|
|
12177
12275
|
}
|
|
12178
12276
|
async function readFileText(filePath) {
|
|
12179
12277
|
try {
|
|
12180
|
-
return await
|
|
12278
|
+
return await readFile5(filePath, "utf-8");
|
|
12181
12279
|
} catch (error2) {
|
|
12182
12280
|
if (error2?.code === "ENOENT") {
|
|
12183
12281
|
return null;
|
|
@@ -12197,7 +12295,7 @@ async function unlinkIfExists(filePath) {
|
|
|
12197
12295
|
}
|
|
12198
12296
|
}
|
|
12199
12297
|
async function writeWal4(walPath2, wal) {
|
|
12200
|
-
await
|
|
12298
|
+
await mkdir4(dirname9(walPath2), { recursive: true });
|
|
12201
12299
|
await atomicWriteFile(walPath2, `${JSON.stringify(wal, null, 2)}
|
|
12202
12300
|
`);
|
|
12203
12301
|
}
|
|
@@ -12243,37 +12341,18 @@ async function ensureSnapshotEvent(directory, plan, transitionId) {
|
|
|
12243
12341
|
approvalMetadata: { specDriftTransitionId: transitionId }
|
|
12244
12342
|
});
|
|
12245
12343
|
}
|
|
12246
|
-
async function appendEvent(
|
|
12247
|
-
const existing = await _internals16.verifyEventPresence(
|
|
12344
|
+
async function appendEvent(directory, event) {
|
|
12345
|
+
const existing = await _internals16.verifyEventPresence(directory, event.type, event.transitionId);
|
|
12248
12346
|
if (existing)
|
|
12249
12347
|
return;
|
|
12250
|
-
|
|
12251
|
-
|
|
12252
|
-
const verified = await _internals16.verifyEventPresence(eventsPath, event.type, event.transitionId);
|
|
12348
|
+
appendCoreEventSync(directory, { ...event }, { dedupeOnAuthorityKey: true });
|
|
12349
|
+
const verified = await _internals16.verifyEventPresence(directory, event.type, event.transitionId);
|
|
12253
12350
|
if (!verified) {
|
|
12254
12351
|
throw new Error(`spec drift audit verification failed for transition ${event.transitionId}`);
|
|
12255
12352
|
}
|
|
12256
12353
|
}
|
|
12257
|
-
async function verifyEventPresence(
|
|
12258
|
-
|
|
12259
|
-
if (raw === null)
|
|
12260
|
-
return false;
|
|
12261
|
-
for (const line of raw.split(`
|
|
12262
|
-
`)) {
|
|
12263
|
-
const trimmed = line.trim();
|
|
12264
|
-
if (trimmed.length === 0)
|
|
12265
|
-
continue;
|
|
12266
|
-
let parsed;
|
|
12267
|
-
try {
|
|
12268
|
-
parsed = JSON.parse(trimmed);
|
|
12269
|
-
} catch (error2) {
|
|
12270
|
-
throw new Error(`events.jsonl is not valid JSONL near "${trimmed.slice(0, 80)}": ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
12271
|
-
}
|
|
12272
|
-
if (parsed.type === eventType && parsed.transitionId === transitionId) {
|
|
12273
|
-
return true;
|
|
12274
|
-
}
|
|
12275
|
-
}
|
|
12276
|
-
return false;
|
|
12354
|
+
async function verifyEventPresence(directory, eventType, transitionId) {
|
|
12355
|
+
return hasSpecDriftAuditEvent(directory, eventType, transitionId);
|
|
12277
12356
|
}
|
|
12278
12357
|
function buildTransitionId(mode, markerHash, previousHash, newHash) {
|
|
12279
12358
|
return sha2562(`${mode}:${markerHash}:${previousHash ?? "(null)"}:${newHash ?? "(null)"}`);
|
|
@@ -12316,7 +12395,6 @@ async function reconcileSpecDrift(directory, options) {
|
|
|
12316
12395
|
const markerPath = _internals16.validateSwarmPath(directory, "spec-staleness.json");
|
|
12317
12396
|
const walPath2 = _internals16.validateSwarmPath(directory, "spec-drift-recovery.json");
|
|
12318
12397
|
const snapshotPath = _internals16.validateSwarmPath(directory, "spec-snapshot.md");
|
|
12319
|
-
const eventsPath = _internals16.validateSwarmPath(directory, "events.jsonl");
|
|
12320
12398
|
const markerMaybe = await _internals16.readFileText(markerPath);
|
|
12321
12399
|
if (markerMaybe === null) {
|
|
12322
12400
|
return {
|
|
@@ -12463,7 +12541,7 @@ async function reconcileSpecDrift(directory, options) {
|
|
|
12463
12541
|
previousHash: wal.previousHash,
|
|
12464
12542
|
transitionId
|
|
12465
12543
|
});
|
|
12466
|
-
await _internals16.appendEvent(
|
|
12544
|
+
await _internals16.appendEvent(directory, event);
|
|
12467
12545
|
await _internals16.writeWal(walPath2, { ...wal, state: "COMMITTED" });
|
|
12468
12546
|
}
|
|
12469
12547
|
if (markerReplacedDuringPrepared) {
|
|
@@ -12888,7 +12966,7 @@ import * as path14 from "path";
|
|
|
12888
12966
|
|
|
12889
12967
|
// src/evaluation/gate-ground-truth.ts
|
|
12890
12968
|
init_zod();
|
|
12891
|
-
import { mkdir as
|
|
12969
|
+
import { mkdir as mkdir5, readFile as readFile6 } from "fs/promises";
|
|
12892
12970
|
import * as path13 from "path";
|
|
12893
12971
|
var GateGroundTruthV1Schema = exports_external.object({
|
|
12894
12972
|
v: exports_external.literal(1),
|
|
@@ -12941,11 +13019,11 @@ async function saveGateGroundTruth(directory, runId, input) {
|
|
|
12941
13019
|
}
|
|
12942
13020
|
const target = absolutePath(directory, runId);
|
|
12943
13021
|
assertProjectRoot(directory);
|
|
12944
|
-
await
|
|
13022
|
+
await mkdir5(path13.dirname(target), { recursive: true });
|
|
12945
13023
|
return withEvidenceLock(directory, relativePath(runId), "gate-ground-truth", runId, async () => {
|
|
12946
13024
|
let existingEvents = [];
|
|
12947
13025
|
try {
|
|
12948
|
-
existingEvents = parseStrict(await
|
|
13026
|
+
existingEvents = parseStrict(await readFile6(target, "utf8"));
|
|
12949
13027
|
} catch (error2) {
|
|
12950
13028
|
if (error2.code !== "ENOENT")
|
|
12951
13029
|
throw error2;
|
|
@@ -12974,7 +13052,7 @@ async function recordTestImpactGateGroundTruth(directory, runId, input) {
|
|
|
12974
13052
|
async function readGateGroundTruth(directory, runId) {
|
|
12975
13053
|
let content;
|
|
12976
13054
|
try {
|
|
12977
|
-
content = await
|
|
13055
|
+
content = await readFile6(absolutePath(directory, runId), "utf8");
|
|
12978
13056
|
} catch (error2) {
|
|
12979
13057
|
if (error2.code === "ENOENT") {
|
|
12980
13058
|
return { events: [], malformed: 0 };
|
|
@@ -13170,6 +13248,7 @@ async function computeGateStatistics(directory, minSamples = 6, runId) {
|
|
|
13170
13248
|
}
|
|
13171
13249
|
|
|
13172
13250
|
// src/services/cost-accounting.ts
|
|
13251
|
+
init_logger();
|
|
13173
13252
|
import * as fs8 from "fs";
|
|
13174
13253
|
import * as os from "os";
|
|
13175
13254
|
import * as path15 from "path";
|
|
@@ -13202,11 +13281,17 @@ function readTelemetryEvents(directory) {
|
|
|
13202
13281
|
}
|
|
13203
13282
|
} catch {}
|
|
13204
13283
|
const events = [];
|
|
13284
|
+
let unreadableSnapshots = 0;
|
|
13285
|
+
let firstUnreadableReason = "";
|
|
13205
13286
|
for (const file of snapshotFiles) {
|
|
13206
13287
|
let content = "";
|
|
13207
13288
|
try {
|
|
13208
13289
|
content = fs8.readFileSync(file, "utf-8");
|
|
13209
|
-
} catch {
|
|
13290
|
+
} catch (err) {
|
|
13291
|
+
unreadableSnapshots += 1;
|
|
13292
|
+
if (!firstUnreadableReason) {
|
|
13293
|
+
firstUnreadableReason = err instanceof Error ? err.message : String(err);
|
|
13294
|
+
}
|
|
13210
13295
|
continue;
|
|
13211
13296
|
}
|
|
13212
13297
|
for (const line of content.split(/\r?\n/)) {
|
|
@@ -13220,6 +13305,9 @@ function readTelemetryEvents(directory) {
|
|
|
13220
13305
|
} catch {}
|
|
13221
13306
|
}
|
|
13222
13307
|
}
|
|
13308
|
+
if (unreadableSnapshots > 0) {
|
|
13309
|
+
warn(`[cost-accounting] ${unreadableSnapshots} of ${snapshotFiles.length} snapshot file(s) were unreadable; cost totals undercount. First reason: ${firstUnreadableReason}`);
|
|
13310
|
+
}
|
|
13223
13311
|
try {
|
|
13224
13312
|
for (const f of snapshotFiles) {
|
|
13225
13313
|
try {
|
|
@@ -14115,13 +14203,10 @@ function writeCheckpointLog(log2, directory) {
|
|
|
14115
14203
|
}
|
|
14116
14204
|
function appendRetentionEvent(directory, event) {
|
|
14117
14205
|
try {
|
|
14118
|
-
|
|
14119
|
-
const line = `${JSON.stringify({
|
|
14206
|
+
appendCoreEventSync(directory, {
|
|
14120
14207
|
...event,
|
|
14121
14208
|
timestamp: new Date().toISOString()
|
|
14122
|
-
})
|
|
14123
|
-
`;
|
|
14124
|
-
fs10.appendFileSync(eventsPath, line);
|
|
14209
|
+
});
|
|
14125
14210
|
} catch {}
|
|
14126
14211
|
}
|
|
14127
14212
|
function loadCheckpointConfig(directory) {
|
|
@@ -16205,8 +16290,40 @@ function redactUrl(match) {
|
|
|
16205
16290
|
return `<url:${hashValue(match).slice(0, 12)}>`;
|
|
16206
16291
|
}
|
|
16207
16292
|
}
|
|
16293
|
+
var FILL_MAX_RUN = 8;
|
|
16294
|
+
var FILL = `[\\s\\p{Cc}\\p{Cf}\\p{Default_Ignorable_Code_Point}]{0,${FILL_MAX_RUN}}`;
|
|
16295
|
+
var CONTROL_CHAR_RUN = /[\p{Cc}\p{Cf}\p{Default_Ignorable_Code_Point}]+/gu;
|
|
16296
|
+
var MAX_SANITIZE_INPUT_CHARS = MAX_DISPLAY_BYTES * 8;
|
|
16297
|
+
function tolerantKeyword(word) {
|
|
16298
|
+
return word.split("").join(FILL);
|
|
16299
|
+
}
|
|
16300
|
+
var CREDENTIAL_KEYWORDS_LOWER = [
|
|
16301
|
+
"bearer",
|
|
16302
|
+
"token",
|
|
16303
|
+
"secret",
|
|
16304
|
+
"password",
|
|
16305
|
+
"authorization"
|
|
16306
|
+
].map(tolerantKeyword);
|
|
16307
|
+
var API_KEY_PATTERN = `${tolerantKeyword("api")}${FILL}[_-]?${FILL}${tolerantKeyword("key")}`;
|
|
16308
|
+
var CREDENTIAL_KEYWORD_ALTERNATION = `(?:${API_KEY_PATTERN}|${CREDENTIAL_KEYWORDS_LOWER.join("|")})`;
|
|
16309
|
+
var SCREAMING_SUFFIXES = ["TOKEN", "KEY", "SECRET", "PASSWORD", "AUTH"];
|
|
16310
|
+
var TOLERANT_BEARER_PREFIX = tolerantKeyword("Bearer");
|
|
16311
|
+
var CREDENTIAL_KV_PATTERN = new RegExp(`\\b(${CREDENTIAL_KEYWORD_ALTERNATION})\\b${FILL}[:=]${FILL}(?:${TOLERANT_BEARER_PREFIX}${FILL})?[^\\s,;]+`, "giu");
|
|
16312
|
+
var SCREAMING_KEY_HORIZONTAL_FILL_CHARS = "\\x00-\\x09\\x0e-\\x1f\\x7f-\\x9f\\p{Zs}\\p{Cf}\\p{Default_Ignorable_Code_Point}";
|
|
16313
|
+
var SCREAMING_KV_CANDIDATE_PATTERN = new RegExp(`\\b([A-Z0-9_${SCREAMING_KEY_HORIZONTAL_FILL_CHARS}]{1,80})${FILL}=${FILL}([^\\s]+)`, "gu");
|
|
16314
|
+
function screamingKeyContainsSuffix(key) {
|
|
16315
|
+
const stripped = key.replace(CONTROL_CHAR_RUN, "").replace(/\s+/g, "");
|
|
16316
|
+
return SCREAMING_SUFFIXES.some((suffix) => stripped.includes(suffix));
|
|
16317
|
+
}
|
|
16208
16318
|
function sanitizeFailureEvidenceDisplay(value) {
|
|
16209
|
-
const
|
|
16319
|
+
const bounded = value.slice(0, MAX_SANITIZE_INPUT_CHARS);
|
|
16320
|
+
const redacted = bounded.replace(/\bhttps?:\/\/[^\s'"<>]+/gi, (match) => redactUrl(match)).replace(CREDENTIAL_KV_PATTERN, (_, key) => {
|
|
16321
|
+
return `${key.replace(CONTROL_CHAR_RUN, "")}=<redacted>`;
|
|
16322
|
+
}).replace(SCREAMING_KV_CANDIDATE_PATTERN, (match, key) => {
|
|
16323
|
+
if (!screamingKeyContainsSuffix(key))
|
|
16324
|
+
return match;
|
|
16325
|
+
return `${key.replace(CONTROL_CHAR_RUN, "").replace(/\s+/g, "")}=<redacted>`;
|
|
16326
|
+
}).replace(CONTROL_CHAR_RUN, " ");
|
|
16210
16327
|
return boundedUtf8(redacted.trim());
|
|
16211
16328
|
}
|
|
16212
16329
|
function signalFrom(value) {
|
|
@@ -17295,7 +17412,7 @@ function formatLearningSummary(metrics) {
|
|
|
17295
17412
|
}
|
|
17296
17413
|
|
|
17297
17414
|
// src/services/recommendation-ledger.ts
|
|
17298
|
-
import { readFile as
|
|
17415
|
+
import { readFile as readFile7 } from "fs/promises";
|
|
17299
17416
|
import * as path20 from "path";
|
|
17300
17417
|
|
|
17301
17418
|
// src/learning/fingerprint.ts
|
|
@@ -17458,7 +17575,7 @@ function parseLedgerJsonl(content) {
|
|
|
17458
17575
|
}
|
|
17459
17576
|
async function readLedgerForTransaction(filePath) {
|
|
17460
17577
|
try {
|
|
17461
|
-
return parseLedgerJsonl(await
|
|
17578
|
+
return parseLedgerJsonl(await readFile7(filePath, "utf-8"));
|
|
17462
17579
|
} catch (err) {
|
|
17463
17580
|
if (err?.code === "ENOENT")
|
|
17464
17581
|
return [];
|
|
@@ -17468,7 +17585,7 @@ async function readLedgerForTransaction(filePath) {
|
|
|
17468
17585
|
async function readLedgerStrict(directory) {
|
|
17469
17586
|
const filePath = _internals23.resolveRecommendationLedgerPath(directory);
|
|
17470
17587
|
try {
|
|
17471
|
-
return parseLedgerJsonl(await
|
|
17588
|
+
return parseLedgerJsonl(await readFile7(filePath, "utf-8"));
|
|
17472
17589
|
} catch (err) {
|
|
17473
17590
|
if (err?.code === "ENOENT")
|
|
17474
17591
|
return [];
|
|
@@ -17747,13 +17864,13 @@ function buildPromotedExternalInputFromSkill(directory, skillSlug, usage, ageDay
|
|
|
17747
17864
|
|
|
17748
17865
|
// src/services/skill-reviser.ts
|
|
17749
17866
|
init_logger();
|
|
17750
|
-
import { readFile as
|
|
17867
|
+
import { readFile as readFile8, rename as rename3, writeFile as writeFile5 } from "fs/promises";
|
|
17751
17868
|
var REVISION_VIOLATION_THRESHOLD = 0.15;
|
|
17752
17869
|
var MAX_REVISION_CALLS_PER_PHASE = 3;
|
|
17753
17870
|
var DEFAULT_MAX_CALLS = 10;
|
|
17754
17871
|
async function getSkillVersion(skillPath) {
|
|
17755
17872
|
try {
|
|
17756
|
-
const content = await
|
|
17873
|
+
const content = await readFile8(skillPath, "utf-8");
|
|
17757
17874
|
const match = content.match(/^version:\s*(\d+)\s*$/m);
|
|
17758
17875
|
return match ? parseInt(match[1], 10) : 1;
|
|
17759
17876
|
} catch {
|
|
@@ -18386,7 +18503,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
|
|
|
18386
18503
|
};
|
|
18387
18504
|
}
|
|
18388
18505
|
async function sweepActiveNearDuplicates(directory, options = {}) {
|
|
18389
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
18506
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-yjj3s8af.js");
|
|
18390
18507
|
const { config } = loadPluginConfigWithMeta2(directory);
|
|
18391
18508
|
const sweepConfig = config.learning?.dedup_sweep;
|
|
18392
18509
|
if (sweepConfig?.enabled === false)
|
|
@@ -19347,8 +19464,19 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
19347
19464
|
already_digested: true
|
|
19348
19465
|
};
|
|
19349
19466
|
}
|
|
19350
|
-
const
|
|
19351
|
-
const phaseEvents =
|
|
19467
|
+
const eventsWindow = readCoreEvents(directory);
|
|
19468
|
+
const phaseEvents = eventsWindow.text.length > 0 ? _internals25.filterPhaseEvents(eventsWindow.text, phase) : [];
|
|
19469
|
+
if (eventsWindow.coverage === "truncated") {
|
|
19470
|
+
try {
|
|
19471
|
+
appendCoreEventSync(directory, {
|
|
19472
|
+
timestamp: new Date().toISOString(),
|
|
19473
|
+
event: "curator_skipped",
|
|
19474
|
+
scope: "phase_digest",
|
|
19475
|
+
phase,
|
|
19476
|
+
reason: "events_window_truncated"
|
|
19477
|
+
});
|
|
19478
|
+
} catch {}
|
|
19479
|
+
}
|
|
19352
19480
|
const contextMd = await readSwarmFileAsync(directory, "context.md");
|
|
19353
19481
|
const requiredAgents = ["reviewer", "test_engineer"];
|
|
19354
19482
|
const complianceObservations = _internals25.checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, phase);
|
|
@@ -19491,20 +19619,21 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
19491
19619
|
warn(`[curator] failed to persist application findings: ${err instanceof Error ? err.message : String(err)}`);
|
|
19492
19620
|
}
|
|
19493
19621
|
}
|
|
19494
|
-
|
|
19495
|
-
|
|
19496
|
-
await appendKnowledge(eventsPath, {
|
|
19622
|
+
try {
|
|
19623
|
+
appendCoreEventsSync(directory, complianceObservations.map((obs) => ({
|
|
19497
19624
|
type: "curator_compliance",
|
|
19498
19625
|
timestamp: obs.timestamp,
|
|
19499
19626
|
phase: obs.phase,
|
|
19500
19627
|
observation_type: obs.type,
|
|
19501
19628
|
severity: obs.severity,
|
|
19502
19629
|
description: obs.description
|
|
19503
|
-
});
|
|
19630
|
+
})));
|
|
19631
|
+
} catch (err) {
|
|
19632
|
+
warn(`[curator] failed to append compliance events: ${err instanceof Error ? err.message : String(err)}`);
|
|
19504
19633
|
}
|
|
19505
19634
|
if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
|
|
19506
19635
|
try {
|
|
19507
|
-
const skillModule = await import("./skill-generator-
|
|
19636
|
+
const skillModule = await import("./skill-generator-pk9gcz7r.js");
|
|
19508
19637
|
for (const cand of skillCandidates) {
|
|
19509
19638
|
if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
|
|
19510
19639
|
continue;
|
|
@@ -19976,7 +20105,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
|
|
|
19976
20105
|
} catch {}
|
|
19977
20106
|
}
|
|
19978
20107
|
if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
|
|
19979
|
-
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-
|
|
20108
|
+
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-whkxxgxj.js");
|
|
19980
20109
|
for (const { id } of contradictedEntries) {
|
|
19981
20110
|
try {
|
|
19982
20111
|
await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
|
|
@@ -20795,7 +20924,7 @@ async function runCuratorPostMortem(directory, options = {}) {
|
|
|
20795
20924
|
warnings.push("Failed to collect knowledge summary.");
|
|
20796
20925
|
}
|
|
20797
20926
|
try {
|
|
20798
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
20927
|
+
const { getScanStatus } = await import("./scan-cursor-0p51fh61.js");
|
|
20799
20928
|
const scanStatus = await getScanStatus(directory);
|
|
20800
20929
|
if (scanStatus.remaining_estimate > 0) {
|
|
20801
20930
|
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.`);
|
|
@@ -20967,9 +21096,9 @@ var _internals26 = {
|
|
|
20967
21096
|
verifyPostMortemKnowledgeActions,
|
|
20968
21097
|
repairPostMortemActions,
|
|
20969
21098
|
loadDefaultKnowledgeConfig: async (directory) => {
|
|
20970
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
21099
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-8g2nxhjf.js");
|
|
20971
21100
|
try {
|
|
20972
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
21101
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-yjj3s8af.js");
|
|
20973
21102
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
20974
21103
|
return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
20975
21104
|
} catch {
|
|
@@ -20977,11 +21106,11 @@ var _internals26 = {
|
|
|
20977
21106
|
}
|
|
20978
21107
|
},
|
|
20979
21108
|
applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
|
|
20980
|
-
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-
|
|
21109
|
+
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-f5m0hh2p.js");
|
|
20981
21110
|
return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
|
|
20982
21111
|
},
|
|
20983
21112
|
checkHivePromotions: async (entries, knowledgeConfig, directory) => {
|
|
20984
|
-
const { checkHivePromotions } = await import("./hive-promoter-
|
|
21113
|
+
const { checkHivePromotions } = await import("./hive-promoter-162ws6xp.js");
|
|
20985
21114
|
return checkHivePromotions(entries, knowledgeConfig, directory);
|
|
20986
21115
|
},
|
|
20987
21116
|
applyProposalTriage: async (directory, triage) => {
|
|
@@ -20990,7 +21119,7 @@ var _internals26 = {
|
|
|
20990
21119
|
activateProposal,
|
|
20991
21120
|
listSkills: listSkills2,
|
|
20992
21121
|
sanitizeSlug
|
|
20993
|
-
} = await import("./skill-generator-
|
|
21122
|
+
} = await import("./skill-generator-pk9gcz7r.js");
|
|
20994
21123
|
const result = {
|
|
20995
21124
|
approved: [],
|
|
20996
21125
|
rejected: [],
|
|
@@ -21032,7 +21161,7 @@ var _internals26 = {
|
|
|
21032
21161
|
return result;
|
|
21033
21162
|
},
|
|
21034
21163
|
readPriorDriftReports: async (directory) => {
|
|
21035
|
-
const { readPriorDriftReports } = await import("./curator-drift-
|
|
21164
|
+
const { readPriorDriftReports } = await import("./curator-drift-2h1d2fnq.js");
|
|
21036
21165
|
return readPriorDriftReports(directory);
|
|
21037
21166
|
},
|
|
21038
21167
|
readSwarmKnowledge: (directory) => readKnowledge(resolveSwarmKnowledgePath(directory))
|
|
@@ -21172,7 +21301,7 @@ function failedGateNames(decision) {
|
|
|
21172
21301
|
|
|
21173
21302
|
// src/hooks/hive-transaction.ts
|
|
21174
21303
|
var import_proper_lockfile4 = __toESM(require_proper_lockfile(), 1);
|
|
21175
|
-
import { appendFile as
|
|
21304
|
+
import { appendFile as appendFile2, mkdir as mkdir7, realpath as realpath2 } from "fs/promises";
|
|
21176
21305
|
import * as path25 from "path";
|
|
21177
21306
|
init_logger();
|
|
21178
21307
|
var HIVE_LOCK_STALE_MS = 5000;
|
|
@@ -21197,7 +21326,7 @@ async function transactHiveStore(mutate) {
|
|
|
21197
21326
|
const eventsPath = _internals27.resolveHiveEventsPath();
|
|
21198
21327
|
const diagnostics = [];
|
|
21199
21328
|
try {
|
|
21200
|
-
await
|
|
21329
|
+
await mkdir7(dataDir, { recursive: true });
|
|
21201
21330
|
} catch (err) {
|
|
21202
21331
|
diagnostics.push(`hive data dir create failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
21203
21332
|
return { committed: false, return: undefined, diagnostics };
|
|
@@ -21250,13 +21379,13 @@ async function transactHiveStore(mutate) {
|
|
|
21250
21379
|
const rejectBlock = `${outcome.rejects.map((r) => JSON.stringify(r)).join(`
|
|
21251
21380
|
`)}
|
|
21252
21381
|
`;
|
|
21253
|
-
await
|
|
21382
|
+
await appendFile2(rejectedPath, rejectBlock, "utf-8");
|
|
21254
21383
|
}
|
|
21255
21384
|
if (outcome.audit && outcome.audit.length > 0) {
|
|
21256
21385
|
const auditBlock = `${outcome.audit.map((a) => a.line).join(`
|
|
21257
21386
|
`)}
|
|
21258
21387
|
`;
|
|
21259
|
-
await
|
|
21388
|
+
await appendFile2(eventsPath, auditBlock, "utf-8");
|
|
21260
21389
|
try {
|
|
21261
21390
|
await trimHiveEventsUnderLock(eventsPath);
|
|
21262
21391
|
} catch (err) {
|
|
@@ -21316,11 +21445,11 @@ async function realpathQuiet(target) {
|
|
|
21316
21445
|
}
|
|
21317
21446
|
}
|
|
21318
21447
|
async function trimHiveEventsUnderLock(eventsPath) {
|
|
21319
|
-
const { readFile:
|
|
21448
|
+
const { readFile: readFile9 } = await import("fs/promises");
|
|
21320
21449
|
const { existsSync: existsSync15 } = await import("fs");
|
|
21321
21450
|
if (!existsSync15(eventsPath))
|
|
21322
21451
|
return;
|
|
21323
|
-
const content = await
|
|
21452
|
+
const content = await readFile9(eventsPath, "utf-8");
|
|
21324
21453
|
const lines = content.split(`
|
|
21325
21454
|
`).filter((l) => l.trim().length > 0);
|
|
21326
21455
|
if (lines.length <= MAX_EVENT_LOG_ENTRIES)
|
|
@@ -21339,7 +21468,7 @@ var _internals27 = {
|
|
|
21339
21468
|
resolveHiveKnowledgePath,
|
|
21340
21469
|
resolveHiveRejectedPath,
|
|
21341
21470
|
resolveHiveEventsPath,
|
|
21342
|
-
appendFile:
|
|
21471
|
+
appendFile: appendFile2,
|
|
21343
21472
|
path: path25
|
|
21344
21473
|
};
|
|
21345
21474
|
|
|
@@ -22087,20 +22216,14 @@ async function promoteFromSwarm(directory, lessonId, options, config) {
|
|
|
22087
22216
|
// src/hooks/knowledge-curator.ts
|
|
22088
22217
|
import { createHash as createHash10 } from "crypto";
|
|
22089
22218
|
import { existsSync as existsSync15 } from "fs";
|
|
22090
|
-
import {
|
|
22091
|
-
appendFile as appendFile7,
|
|
22092
|
-
mkdir as mkdir10,
|
|
22093
|
-
readFile as readFile11,
|
|
22094
|
-
realpath as realpath3,
|
|
22095
|
-
writeFile as writeFile7
|
|
22096
|
-
} from "fs/promises";
|
|
22219
|
+
import { readFile as readFile10, realpath as realpath3, writeFile as writeFile7 } from "fs/promises";
|
|
22097
22220
|
import * as path28 from "path";
|
|
22098
22221
|
|
|
22099
22222
|
// src/services/synonym-map.ts
|
|
22100
22223
|
var import_proper_lockfile5 = __toESM(require_proper_lockfile(), 1);
|
|
22101
22224
|
import {
|
|
22102
|
-
mkdir as
|
|
22103
|
-
readFile as
|
|
22225
|
+
mkdir as mkdir8,
|
|
22226
|
+
readFile as readFile9,
|
|
22104
22227
|
rename as rename4,
|
|
22105
22228
|
stat as stat3,
|
|
22106
22229
|
unlink as unlink3,
|
|
@@ -22254,14 +22377,14 @@ async function readSynonymMap(directory, maxPairs = DEFAULT_MAX_PAIRS) {
|
|
|
22254
22377
|
const st = await stat3(filePath);
|
|
22255
22378
|
if (st.size > ceiling)
|
|
22256
22379
|
return emptySynonymMap();
|
|
22257
|
-
const raw = await
|
|
22380
|
+
const raw = await readFile9(filePath, "utf-8");
|
|
22258
22381
|
return coerceSynonymMap(JSON.parse(raw), maxPairs);
|
|
22259
22382
|
} catch {
|
|
22260
22383
|
return emptySynonymMap();
|
|
22261
22384
|
}
|
|
22262
22385
|
}
|
|
22263
22386
|
async function writeSynonymMapAtomic(filePath, map) {
|
|
22264
|
-
await
|
|
22387
|
+
await mkdir8(path27.dirname(filePath), { recursive: true });
|
|
22265
22388
|
const tmp = `${filePath}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
22266
22389
|
try {
|
|
22267
22390
|
await writeFile6(tmp, JSON.stringify(map, null, 2), "utf-8");
|
|
@@ -22275,7 +22398,7 @@ async function writeSynonymMapAtomic(filePath, map) {
|
|
|
22275
22398
|
async function rebuildSynonymMap(directory, entries, maxPairs = DEFAULT_MAX_PAIRS) {
|
|
22276
22399
|
const filePath = resolveSynonymMapPath(directory);
|
|
22277
22400
|
const dir = path27.dirname(filePath);
|
|
22278
|
-
await
|
|
22401
|
+
await mkdir8(dir, { recursive: true });
|
|
22279
22402
|
let release = null;
|
|
22280
22403
|
try {
|
|
22281
22404
|
release = await import_proper_lockfile5.default.lock(dir, {
|
|
@@ -22326,9 +22449,9 @@ function hashContent(content) {
|
|
|
22326
22449
|
return createHash10("sha1").update(content).digest("hex");
|
|
22327
22450
|
}
|
|
22328
22451
|
async function loadConfigForPolicyCurator(directory) {
|
|
22329
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
22452
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-8g2nxhjf.js");
|
|
22330
22453
|
try {
|
|
22331
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
22454
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-yjj3s8af.js");
|
|
22332
22455
|
const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
|
|
22333
22456
|
return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
|
|
22334
22457
|
} catch {
|
|
@@ -22806,16 +22929,13 @@ RETRY: your last output was missing ${result.missing.join("; ")}; produce valid
|
|
|
22806
22929
|
}
|
|
22807
22930
|
async function appendCuratorSkippedEvent(directory, record) {
|
|
22808
22931
|
try {
|
|
22809
|
-
|
|
22810
|
-
await mkdir10(path28.dirname(filePath), { recursive: true });
|
|
22811
|
-
await appendFile7(filePath, `${JSON.stringify({
|
|
22932
|
+
appendCoreEventSync(directory, {
|
|
22812
22933
|
timestamp: new Date().toISOString(),
|
|
22813
22934
|
event: "curator_skipped",
|
|
22814
22935
|
entry_id: record.entry_id,
|
|
22815
22936
|
lesson: record.lesson.slice(0, 200),
|
|
22816
22937
|
reason: record.reason
|
|
22817
|
-
})
|
|
22818
|
-
`, "utf-8");
|
|
22938
|
+
});
|
|
22819
22939
|
} catch {}
|
|
22820
22940
|
}
|
|
22821
22941
|
var MESO_INSIGHT_BATCH_LIMIT = 20;
|
|
@@ -22850,7 +22970,7 @@ async function consumeInsightCandidates(directory, batchLimit = MESO_INSIGHT_BAT
|
|
|
22850
22970
|
if (!existsSync15(filePath))
|
|
22851
22971
|
return [];
|
|
22852
22972
|
const consumed = [];
|
|
22853
|
-
await transactFile(filePath, async (p) => readInsightJsonl2(await
|
|
22973
|
+
await transactFile(filePath, async (p) => readInsightJsonl2(await readFile10(p, "utf-8").catch(() => "")), async (p, data) => {
|
|
22854
22974
|
const body = data.length === 0 ? "" : `${data.map((c) => JSON.stringify(c)).join(`
|
|
22855
22975
|
`)}
|
|
22856
22976
|
`;
|
|
@@ -24707,9 +24827,9 @@ var import_proper_lockfile6 = __toESM(require_proper_lockfile(), 1);
|
|
|
24707
24827
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
24708
24828
|
import { existsSync as existsSync17, readFileSync as readFileSync14, writeFileSync as writeFileSync8 } from "fs";
|
|
24709
24829
|
import {
|
|
24710
|
-
appendFile as
|
|
24711
|
-
mkdir as
|
|
24712
|
-
readFile as
|
|
24830
|
+
appendFile as appendFile3,
|
|
24831
|
+
mkdir as mkdir9,
|
|
24832
|
+
readFile as readFile11,
|
|
24713
24833
|
rename as rename5,
|
|
24714
24834
|
truncate,
|
|
24715
24835
|
writeFile as writeFile8
|
|
@@ -25876,7 +25996,7 @@ class LocalJsonlMemoryProvider {
|
|
|
25876
25996
|
}
|
|
25877
25997
|
async withOutcomeStoreLock(fn) {
|
|
25878
25998
|
const storageDirectory = path31.dirname(this.pathFor("memories"));
|
|
25879
|
-
await
|
|
25999
|
+
await mkdir9(storageDirectory, { recursive: true });
|
|
25880
26000
|
const release = await lockfile6.lock(storageDirectory, {
|
|
25881
26001
|
realpath: false,
|
|
25882
26002
|
stale: 1e4,
|
|
@@ -26079,7 +26199,7 @@ function validateLoadedProposals(values, config) {
|
|
|
26079
26199
|
async function readJsonl(filePath) {
|
|
26080
26200
|
if (!existsSync17(filePath))
|
|
26081
26201
|
return [];
|
|
26082
|
-
const content = await
|
|
26202
|
+
const content = await readFile11(filePath, "utf-8");
|
|
26083
26203
|
const records = [];
|
|
26084
26204
|
for (const line of content.split(`
|
|
26085
26205
|
`)) {
|
|
@@ -26154,12 +26274,12 @@ function parseRewardEvent(value) {
|
|
|
26154
26274
|
};
|
|
26155
26275
|
}
|
|
26156
26276
|
async function appendJsonl(filePath, value) {
|
|
26157
|
-
await
|
|
26158
|
-
await
|
|
26277
|
+
await mkdir9(path31.dirname(filePath), { recursive: true });
|
|
26278
|
+
await appendFile3(filePath, `${JSON.stringify(value)}
|
|
26159
26279
|
`, "utf-8");
|
|
26160
26280
|
}
|
|
26161
26281
|
async function writeJsonlAtomic(filePath, values) {
|
|
26162
|
-
await
|
|
26282
|
+
await mkdir9(path31.dirname(filePath), { recursive: true });
|
|
26163
26283
|
const tmp = `${filePath}.tmp.${randomUUID6()}`;
|
|
26164
26284
|
const content = values.map((value) => JSON.stringify(value)).join(`
|
|
26165
26285
|
`) + (values.length > 0 ? `
|
|
@@ -26170,7 +26290,7 @@ async function writeJsonlAtomic(filePath, values) {
|
|
|
26170
26290
|
async function repairIncompleteJsonlTail(filePath) {
|
|
26171
26291
|
if (!existsSync17(filePath))
|
|
26172
26292
|
return;
|
|
26173
|
-
const content = await
|
|
26293
|
+
const content = await readFile11(filePath, "utf-8");
|
|
26174
26294
|
if (content.length === 0 || content.endsWith(`
|
|
26175
26295
|
`))
|
|
26176
26296
|
return;
|
|
@@ -26551,7 +26671,7 @@ function resolveRerankerCacheDir() {
|
|
|
26551
26671
|
|
|
26552
26672
|
// src/memory/jsonl-migration.ts
|
|
26553
26673
|
import { existsSync as existsSync18, renameSync as renameSync7, unlinkSync as unlinkSync6 } from "fs";
|
|
26554
|
-
import { copyFile, mkdir as
|
|
26674
|
+
import { copyFile, mkdir as mkdir10, readFile as readFile12, stat as stat4, writeFile as writeFile9 } from "fs/promises";
|
|
26555
26675
|
import * as path34 from "path";
|
|
26556
26676
|
var LEGACY_JSONL_MIGRATION_VERSION = 2;
|
|
26557
26677
|
var LEGACY_JSONL_MIGRATION_NAME = "legacy_jsonl_import_complete";
|
|
@@ -26589,7 +26709,7 @@ async function readLegacyJsonl(rootDirectory, config = {}) {
|
|
|
26589
26709
|
async function backupLegacyJsonl(rootDirectory, config = {}) {
|
|
26590
26710
|
const storageDir = resolveMemoryStorageDir(rootDirectory, config);
|
|
26591
26711
|
const backupDir = path34.join(storageDir, "backups");
|
|
26592
|
-
await
|
|
26712
|
+
await mkdir10(backupDir, { recursive: true });
|
|
26593
26713
|
const results = [];
|
|
26594
26714
|
for (const filename of [
|
|
26595
26715
|
"memories.jsonl",
|
|
@@ -26611,7 +26731,7 @@ async function backupLegacyJsonl(rootDirectory, config = {}) {
|
|
|
26611
26731
|
}
|
|
26612
26732
|
async function writeJsonlExport(rootDirectory, config, memories, proposals, outcomeEvents = []) {
|
|
26613
26733
|
const exportDir = path34.join(resolveMemoryStorageDir(rootDirectory, config), "export");
|
|
26614
|
-
await
|
|
26734
|
+
await mkdir10(exportDir, { recursive: true });
|
|
26615
26735
|
const memoriesPath = path34.join(exportDir, "memories.jsonl");
|
|
26616
26736
|
const proposalsPath = path34.join(exportDir, "proposals.jsonl");
|
|
26617
26737
|
const outcomesPath = path34.join(exportDir, "outcome-events.jsonl");
|
|
@@ -26649,7 +26769,7 @@ async function writeJsonlExport(rootDirectory, config, memories, proposals, outc
|
|
|
26649
26769
|
}
|
|
26650
26770
|
async function writeMigrationReport(rootDirectory, report, config = {}) {
|
|
26651
26771
|
const reportPath = path34.join(resolveMemoryStorageDir(rootDirectory, config), "migration-report.json");
|
|
26652
|
-
await
|
|
26772
|
+
await mkdir10(path34.dirname(reportPath), { recursive: true });
|
|
26653
26773
|
const reportTempPath = path34.join(path34.dirname(reportPath), `${path34.basename(reportPath)}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
|
|
26654
26774
|
try {
|
|
26655
26775
|
await writeFile9(reportTempPath, `${JSON.stringify(report, null, 2)}
|
|
@@ -26668,7 +26788,7 @@ async function readMigrationReport(rootDirectory, config = {}) {
|
|
|
26668
26788
|
if (!existsSync18(reportPath))
|
|
26669
26789
|
return null;
|
|
26670
26790
|
try {
|
|
26671
|
-
return JSON.parse(await
|
|
26791
|
+
return JSON.parse(await readFile12(reportPath, "utf-8"));
|
|
26672
26792
|
} catch {
|
|
26673
26793
|
return null;
|
|
26674
26794
|
}
|
|
@@ -26822,7 +26942,7 @@ async function readJsonlRows(filePath) {
|
|
|
26822
26942
|
if (!existsSync18(filePath)) {
|
|
26823
26943
|
return { rows: [], invalidRows: [], totalRows: 0 };
|
|
26824
26944
|
}
|
|
26825
|
-
const content = await
|
|
26945
|
+
const content = await readFile12(filePath, "utf-8");
|
|
26826
26946
|
const rows = [];
|
|
26827
26947
|
const invalidRows = [];
|
|
26828
26948
|
let totalRows = 0;
|
|
@@ -29975,7 +30095,8 @@ function gatherToolProblems(toolAggregates) {
|
|
|
29975
30095
|
failureCount: agg.failureCount,
|
|
29976
30096
|
totalCalls: agg.count,
|
|
29977
30097
|
failureRate: Math.round(failureRate * 100) / 100,
|
|
29978
|
-
avgDurationMs: Math.round(agg.totalDuration / agg.count)
|
|
30098
|
+
avgDurationMs: Math.round(agg.totalDuration / agg.count),
|
|
30099
|
+
...agg.failureReasons && agg.failureReasons.length > 0 ? { failureReasons: agg.failureReasons } : {}
|
|
29979
30100
|
});
|
|
29980
30101
|
}
|
|
29981
30102
|
}
|
|
@@ -30106,7 +30227,10 @@ async function gatherLedgerRejections(directory, sessionId) {
|
|
|
30106
30227
|
}
|
|
30107
30228
|
return readLedger(target);
|
|
30108
30229
|
};
|
|
30109
|
-
let content =
|
|
30230
|
+
let content = readCoreEvents(directory).text;
|
|
30231
|
+
if (content === "") {
|
|
30232
|
+
content = null;
|
|
30233
|
+
}
|
|
30110
30234
|
if (content === null) {
|
|
30111
30235
|
try {
|
|
30112
30236
|
const archiveRoot = path39.join(directory, ".swarm", "archive");
|
|
@@ -30126,6 +30250,8 @@ async function gatherLedgerRejections(directory, sessionId) {
|
|
|
30126
30250
|
continue;
|
|
30127
30251
|
try {
|
|
30128
30252
|
const parsed = JSON.parse(trimmed);
|
|
30253
|
+
if (parsed.type === "swarm-events-manifest")
|
|
30254
|
+
continue;
|
|
30129
30255
|
if (typeof parsed.type === "string" && REJECTION_LEDGER_EVENT_TYPES.has(parsed.type)) {
|
|
30130
30256
|
if (sessionId !== undefined) {
|
|
30131
30257
|
const eventSession = typeof parsed.sessionId === "string" ? parsed.sessionId : typeof parsed.sessionID === "string" ? parsed.sessionID : undefined;
|
|
@@ -30281,6 +30407,9 @@ function buildReflectionDataSummary(data) {
|
|
|
30281
30407
|
lines.push("TOOL PROBLEMS (tools with >20% failure rate or >2 failures):");
|
|
30282
30408
|
for (const p of data.toolProblems) {
|
|
30283
30409
|
lines.push(` - ${p.tool}: ${p.failureCount}/${p.totalCalls} failures (${Math.round(p.failureRate * 100)}%), avg ${p.avgDurationMs}ms`);
|
|
30410
|
+
if (p.failureReasons && p.failureReasons.length > 0) {
|
|
30411
|
+
lines.push(` reasons: ${p.failureReasons.join("; ")}`);
|
|
30412
|
+
}
|
|
30284
30413
|
}
|
|
30285
30414
|
lines.push("");
|
|
30286
30415
|
}
|
|
@@ -30396,7 +30525,7 @@ function buildSignalsBlock(data) {
|
|
|
30396
30525
|
if (p.failureCount > 0) {
|
|
30397
30526
|
reproBacked.push({
|
|
30398
30527
|
title: `Tool ${p.tool} failing (${p.failureCount}/${p.totalCalls}, ${Math.round(p.failureRate * 100)}%)`,
|
|
30399
|
-
evidence: `tool failure rate ${Math.round(p.failureRate * 100)}% (${p.failureCount}/${p.totalCalls})`
|
|
30528
|
+
evidence: `tool failure rate ${Math.round(p.failureRate * 100)}% (${p.failureCount}/${p.totalCalls})${p.failureReasons && p.failureReasons.length > 0 ? `; reasons: ${p.failureReasons.join("; ")}` : ""}`
|
|
30400
30529
|
});
|
|
30401
30530
|
}
|
|
30402
30531
|
}
|
|
@@ -30539,6 +30668,9 @@ function buildDeterministicReport(data) {
|
|
|
30539
30668
|
lines.push("");
|
|
30540
30669
|
for (const p of data.toolProblems) {
|
|
30541
30670
|
lines.push(`- **${p.tool}**: ${p.failureCount}/${p.totalCalls} failures (${Math.round(p.failureRate * 100)}%), avg ${p.avgDurationMs}ms per call`);
|
|
30671
|
+
if (p.failureReasons && p.failureReasons.length > 0) {
|
|
30672
|
+
lines.push(` - reasons: ${p.failureReasons.join("; ")}`);
|
|
30673
|
+
}
|
|
30542
30674
|
}
|
|
30543
30675
|
lines.push("");
|
|
30544
30676
|
}
|
|
@@ -30652,12 +30784,12 @@ var _internals35 = {
|
|
|
30652
30784
|
|
|
30653
30785
|
// src/services/skill-improver.ts
|
|
30654
30786
|
import { existsSync as existsSync22 } from "fs";
|
|
30655
|
-
import { mkdir as
|
|
30787
|
+
import { mkdir as mkdir12, readFile as readFile13 } from "fs/promises";
|
|
30656
30788
|
import * as path41 from "path";
|
|
30657
30789
|
init_logger();
|
|
30658
30790
|
|
|
30659
30791
|
// src/services/trajectory-cluster.ts
|
|
30660
|
-
import { mkdir as
|
|
30792
|
+
import { mkdir as mkdir11, writeFile as writeFile10 } from "fs/promises";
|
|
30661
30793
|
import * as path40 from "path";
|
|
30662
30794
|
init_logger();
|
|
30663
30795
|
var MACRO_TRAJECTORY_WINDOW = 200;
|
|
@@ -30826,7 +30958,7 @@ async function writeMotifProposals(directory, opts = {}) {
|
|
|
30826
30958
|
if (emitted.length === 0)
|
|
30827
30959
|
return result;
|
|
30828
30960
|
const proposalsDir = validateSwarmPath(directory, path40.join("skills", "proposals"));
|
|
30829
|
-
await
|
|
30961
|
+
await mkdir11(proposalsDir, { recursive: true });
|
|
30830
30962
|
const written = [];
|
|
30831
30963
|
for (const decision of emitted) {
|
|
30832
30964
|
const motif = selected[decision.index];
|
|
@@ -31016,7 +31148,7 @@ async function writeSuccessMotifProposals(directory, opts = {}) {
|
|
|
31016
31148
|
if (emitted.length === 0)
|
|
31017
31149
|
return result;
|
|
31018
31150
|
const proposalsDir = validateSwarmPath(directory, path40.join("skills", "proposals"));
|
|
31019
|
-
await
|
|
31151
|
+
await mkdir11(proposalsDir, { recursive: true });
|
|
31020
31152
|
const written = [];
|
|
31021
31153
|
for (const decision of emitted) {
|
|
31022
31154
|
const motif = selected[decision.index];
|
|
@@ -31159,7 +31291,7 @@ function timestampSlug(d) {
|
|
|
31159
31291
|
return d.toISOString().replace(/[:.]/g, "-");
|
|
31160
31292
|
}
|
|
31161
31293
|
async function atomicWrite(p, content) {
|
|
31162
|
-
await
|
|
31294
|
+
await mkdir12(path41.dirname(p), { recursive: true });
|
|
31163
31295
|
await atomicWriteSwarmFile(p, content);
|
|
31164
31296
|
}
|
|
31165
31297
|
async function gatherInventory(directory) {
|
|
@@ -31174,7 +31306,7 @@ async function gatherInventory(directory) {
|
|
|
31174
31306
|
for (const skill of skills.active) {
|
|
31175
31307
|
let content;
|
|
31176
31308
|
try {
|
|
31177
|
-
content = await
|
|
31309
|
+
content = await readFile13(skill.path, "utf-8");
|
|
31178
31310
|
} catch {
|
|
31179
31311
|
continue;
|
|
31180
31312
|
}
|
|
@@ -31350,7 +31482,7 @@ async function reconcileStaleActiveSkills(directory, options = {}) {
|
|
|
31350
31482
|
for (const skill of skills.active) {
|
|
31351
31483
|
let content;
|
|
31352
31484
|
try {
|
|
31353
|
-
content = await
|
|
31485
|
+
content = await readFile13(skill.path, "utf-8");
|
|
31354
31486
|
} catch {
|
|
31355
31487
|
continue;
|
|
31356
31488
|
}
|
|
@@ -33094,6 +33226,7 @@ var ARCHIVE_ARTIFACTS = [
|
|
|
33094
33226
|
"plan-ledger.jsonl",
|
|
33095
33227
|
"context.md",
|
|
33096
33228
|
"events.jsonl",
|
|
33229
|
+
"events-authority-index.json",
|
|
33097
33230
|
"handoff.md",
|
|
33098
33231
|
"handoff-prompt.md",
|
|
33099
33232
|
"handoff-consumed.md",
|
|
@@ -33127,6 +33260,7 @@ var ACTIVE_STATE_TO_CLEAN = [
|
|
|
33127
33260
|
"plan.md",
|
|
33128
33261
|
"plan-ledger.jsonl",
|
|
33129
33262
|
"events.jsonl",
|
|
33263
|
+
"events-authority-index.json",
|
|
33130
33264
|
"handoff.md",
|
|
33131
33265
|
"handoff-prompt.md",
|
|
33132
33266
|
"handoff-consumed.md",
|
|
@@ -33524,7 +33658,7 @@ async function runFinalizeStage(ctx) {
|
|
|
33524
33658
|
}
|
|
33525
33659
|
}
|
|
33526
33660
|
try {
|
|
33527
|
-
const { CuratorConfigSchema: CCS } = await import("./schema-
|
|
33661
|
+
const { CuratorConfigSchema: CCS } = await import("./schema-8g2nxhjf.js");
|
|
33528
33662
|
const { config: pmLoadedConfig } = _internals41.loadPluginConfigWithMeta(ctx.directory);
|
|
33529
33663
|
const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
|
|
33530
33664
|
if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
|
|
@@ -33563,6 +33697,12 @@ async function runArchiveStage(ctx) {
|
|
|
33563
33697
|
const msg = finalizeErr instanceof Error ? finalizeErr.message : String(finalizeErr);
|
|
33564
33698
|
ctx.warnings.push(`Context-map telemetry finalize before archive failed: ${msg}`);
|
|
33565
33699
|
}
|
|
33700
|
+
try {
|
|
33701
|
+
_internals41.finalizeCoreEvents(ctx.directory);
|
|
33702
|
+
} catch (finalizeErr) {
|
|
33703
|
+
const msg = finalizeErr instanceof Error ? finalizeErr.message : String(finalizeErr);
|
|
33704
|
+
ctx.warnings.push(`Core events finalize before archive failed: ${msg}`);
|
|
33705
|
+
}
|
|
33566
33706
|
const linkedKnowledgeShared = isLinked(ctx.directory);
|
|
33567
33707
|
if (linkedKnowledgeShared) {
|
|
33568
33708
|
ctx.warnings.push("Worktree is linked: shared knowledge (knowledge.jsonl, knowledge-rejected.jsonl) lives in the link store and is not archived or cleaned by /swarm close. Manage it via the link.");
|
|
@@ -34388,11 +34528,14 @@ var _internals41 = {
|
|
|
34388
34528
|
closePlanTerminalState: reconcileCloseTerminalStateForPlan,
|
|
34389
34529
|
endAgentSession,
|
|
34390
34530
|
flushAndDrainTelemetry: async () => {
|
|
34391
|
-
const { flushAndDrainTelemetry } = await import("./telemetry-
|
|
34531
|
+
const { flushAndDrainTelemetry } = await import("./telemetry-5deacb7w.js");
|
|
34392
34532
|
return flushAndDrainTelemetry();
|
|
34393
34533
|
},
|
|
34394
34534
|
finalizeContextTelemetry: (directory) => {
|
|
34395
34535
|
finalizeContextTelemetry(directory);
|
|
34536
|
+
},
|
|
34537
|
+
finalizeCoreEvents: (directory) => {
|
|
34538
|
+
finalizeCoreEventsForClose(directory);
|
|
34396
34539
|
}
|
|
34397
34540
|
};
|
|
34398
34541
|
|
|
@@ -34657,7 +34800,7 @@ init_schema();
|
|
|
34657
34800
|
|
|
34658
34801
|
// src/services/skill-consolidation.ts
|
|
34659
34802
|
import { existsSync as existsSync28 } from "fs";
|
|
34660
|
-
import { mkdir as
|
|
34803
|
+
import { mkdir as mkdir13, readFile as readFile14 } from "fs/promises";
|
|
34661
34804
|
import * as path48 from "path";
|
|
34662
34805
|
var DEFAULT_CONSOLIDATION_INTERVAL_HOURS = 24;
|
|
34663
34806
|
var DEFAULT_CONSOLIDATION_MAX_CALLS_PER_RUN = 1;
|
|
@@ -34671,7 +34814,7 @@ async function readState2(directory) {
|
|
|
34671
34814
|
if (!existsSync28(filePath))
|
|
34672
34815
|
return {};
|
|
34673
34816
|
try {
|
|
34674
|
-
const parsed = JSON.parse(await
|
|
34817
|
+
const parsed = JSON.parse(await readFile14(filePath, "utf-8"));
|
|
34675
34818
|
if (!parsed || typeof parsed !== "object")
|
|
34676
34819
|
return {};
|
|
34677
34820
|
return parsed;
|
|
@@ -34680,7 +34823,7 @@ async function readState2(directory) {
|
|
|
34680
34823
|
}
|
|
34681
34824
|
}
|
|
34682
34825
|
async function atomicWrite2(filePath, content) {
|
|
34683
|
-
await
|
|
34826
|
+
await mkdir13(path48.dirname(filePath), { recursive: true });
|
|
34684
34827
|
await atomicWriteSwarmFile(filePath, content);
|
|
34685
34828
|
}
|
|
34686
34829
|
async function writeState2(directory, state) {
|
|
@@ -35006,7 +35149,7 @@ import { promisify as promisify2 } from "util";
|
|
|
35006
35149
|
init_zod();
|
|
35007
35150
|
import * as child_process3 from "child_process";
|
|
35008
35151
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
35009
|
-
import { readdir as readdir4, readFile as
|
|
35152
|
+
import { readdir as readdir4, readFile as readFile15, stat as stat5 } from "fs/promises";
|
|
35010
35153
|
import * as path49 from "path";
|
|
35011
35154
|
import { promisify } from "util";
|
|
35012
35155
|
function getExecFileAsync() {
|
|
@@ -35133,7 +35276,7 @@ async function getStaticEdges(directory) {
|
|
|
35133
35276
|
const sourceFiles = await scanSourceFiles(directory);
|
|
35134
35277
|
for (const sourceFile of sourceFiles) {
|
|
35135
35278
|
try {
|
|
35136
|
-
const content = await
|
|
35279
|
+
const content = await readFile15(sourceFile, "utf-8");
|
|
35137
35280
|
const importRegex = /(?:import|require)\s*(?:\(?\s*['"`]|.*?from\s+['"`])([^'"`]+)['"`]/g;
|
|
35138
35281
|
for (let match = importRegex.exec(content);match !== null; match = importRegex.exec(content)) {
|
|
35139
35282
|
const importPath = match[1].trim();
|
|
@@ -35717,9 +35860,9 @@ var _internals45 = {
|
|
|
35717
35860
|
loadPluginConfigWithMeta,
|
|
35718
35861
|
loadCuratorDeps: async () => {
|
|
35719
35862
|
const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
|
|
35720
|
-
import("./schema-
|
|
35721
|
-
import("./curator-
|
|
35722
|
-
import("./curator-llm-factory-
|
|
35863
|
+
import("./schema-8g2nxhjf.js"),
|
|
35864
|
+
import("./curator-f5m0hh2p.js"),
|
|
35865
|
+
import("./curator-llm-factory-mzh9ns5s.js")
|
|
35723
35866
|
]);
|
|
35724
35867
|
return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
|
|
35725
35868
|
}
|
|
@@ -36360,7 +36503,7 @@ init_git_executable();
|
|
|
36360
36503
|
// src/services/knowledge-diagnostics.ts
|
|
36361
36504
|
init_package();
|
|
36362
36505
|
import { existsSync as existsSync31, readFileSync as readFileSync21 } from "fs";
|
|
36363
|
-
import { readFile as
|
|
36506
|
+
import { readFile as readFile16 } from "fs/promises";
|
|
36364
36507
|
import { join as join41 } from "path";
|
|
36365
36508
|
|
|
36366
36509
|
// src/services/version-check.ts
|
|
@@ -36437,7 +36580,7 @@ var INSIGHT_BACKLOG_WARN = 50;
|
|
|
36437
36580
|
async function readRawLines(filePath) {
|
|
36438
36581
|
if (!existsSync31(filePath))
|
|
36439
36582
|
return { entries: [], corrupt: 0 };
|
|
36440
|
-
const content = await
|
|
36583
|
+
const content = await readFile16(filePath, "utf-8");
|
|
36441
36584
|
const entries = [];
|
|
36442
36585
|
let corrupt = 0;
|
|
36443
36586
|
for (const line of content.split(`
|
|
@@ -36709,7 +36852,7 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
36709
36852
|
let scanCompleted = false;
|
|
36710
36853
|
let scanRemaining = 0;
|
|
36711
36854
|
try {
|
|
36712
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
36855
|
+
const { getScanStatus } = await import("./scan-cursor-0p51fh61.js");
|
|
36713
36856
|
const status = await getScanStatus(directory);
|
|
36714
36857
|
scanGeneration = status.generation;
|
|
36715
36858
|
scanCompleted = status.completed;
|
|
@@ -36717,19 +36860,19 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
36717
36860
|
} catch {}
|
|
36718
36861
|
let configMatch = null;
|
|
36719
36862
|
try {
|
|
36720
|
-
const { isLinked: isLinked2 } = await import("./knowledge-link-
|
|
36863
|
+
const { isLinked: isLinked2 } = await import("./knowledge-link-mzn8x0qd.js");
|
|
36721
36864
|
if (isLinked2(directory)) {
|
|
36722
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
36865
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-8g2nxhjf.js");
|
|
36723
36866
|
let config;
|
|
36724
36867
|
try {
|
|
36725
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
36868
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-yjj3s8af.js");
|
|
36726
36869
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
36727
36870
|
config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
36728
36871
|
} catch {
|
|
36729
36872
|
config = KnowledgeConfigSchema2.parse({});
|
|
36730
36873
|
}
|
|
36731
36874
|
const { cohortConfigFingerprint: cohortConfigFingerprint2 } = await import("./config-fingerprint-v22xh5a2.js");
|
|
36732
|
-
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-
|
|
36875
|
+
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-nck9g765.js");
|
|
36733
36876
|
const currentFp = cohortConfigFingerprint2(buildConfigFingerprintInput2(config));
|
|
36734
36877
|
const cohortFp = await readCohortConfigFingerprint(directory);
|
|
36735
36878
|
configMatch = cohortFp === null ? null : currentFp === cohortFp;
|
|
@@ -36764,7 +36907,7 @@ async function countPendingProposals(directory) {
|
|
|
36764
36907
|
if (!existsSync31(proposalsPath))
|
|
36765
36908
|
return 0;
|
|
36766
36909
|
try {
|
|
36767
|
-
const content = await
|
|
36910
|
+
const content = await readFile16(proposalsPath, "utf-8");
|
|
36768
36911
|
let n = 0;
|
|
36769
36912
|
for (const line of content.split(`
|
|
36770
36913
|
`)) {
|
|
@@ -36786,7 +36929,7 @@ async function safeJsonlCount(filePath) {
|
|
|
36786
36929
|
if (!filePath || !existsSync31(filePath))
|
|
36787
36930
|
return 0;
|
|
36788
36931
|
try {
|
|
36789
|
-
const content = await
|
|
36932
|
+
const content = await readFile16(filePath, "utf-8");
|
|
36790
36933
|
let n = 0;
|
|
36791
36934
|
for (const line of content.split(`
|
|
36792
36935
|
`)) {
|
|
@@ -37331,8 +37474,7 @@ async function checkCheckpointManifest(directory) {
|
|
|
37331
37474
|
}
|
|
37332
37475
|
}
|
|
37333
37476
|
async function checkEventStreamIntegrity(directory) {
|
|
37334
|
-
|
|
37335
|
-
if (!existsSync32(eventsPath)) {
|
|
37477
|
+
if (getCoreEventCoverage(directory) === "empty") {
|
|
37336
37478
|
return {
|
|
37337
37479
|
name: "Event Stream",
|
|
37338
37480
|
status: "\u2705",
|
|
@@ -37340,8 +37482,8 @@ async function checkEventStreamIntegrity(directory) {
|
|
|
37340
37482
|
};
|
|
37341
37483
|
}
|
|
37342
37484
|
try {
|
|
37343
|
-
const
|
|
37344
|
-
const lines =
|
|
37485
|
+
const window = readCoreEvents(directory);
|
|
37486
|
+
const lines = window.text.split(`
|
|
37345
37487
|
`).filter((line) => line.trim() !== "");
|
|
37346
37488
|
let malformedCount = 0;
|
|
37347
37489
|
for (const line of lines) {
|
|
@@ -37351,11 +37493,12 @@ async function checkEventStreamIntegrity(directory) {
|
|
|
37351
37493
|
malformedCount++;
|
|
37352
37494
|
}
|
|
37353
37495
|
}
|
|
37496
|
+
const coverageNote = window.coverage === "truncated" ? " (retained window \u2014 compacted history excluded)" : "";
|
|
37354
37497
|
if (malformedCount === 0) {
|
|
37355
37498
|
return {
|
|
37356
37499
|
name: "Event Stream",
|
|
37357
37500
|
status: "\u2705",
|
|
37358
|
-
detail: `events.jsonl is valid \u2014 ${lines.length} event(s)`
|
|
37501
|
+
detail: `events.jsonl is valid \u2014 ${lines.length} event(s)${coverageNote}`
|
|
37359
37502
|
};
|
|
37360
37503
|
}
|
|
37361
37504
|
return {
|
|
@@ -37372,8 +37515,7 @@ async function checkEventStreamIntegrity(directory) {
|
|
|
37372
37515
|
}
|
|
37373
37516
|
}
|
|
37374
37517
|
async function checkSteeringDirectives(directory) {
|
|
37375
|
-
|
|
37376
|
-
if (!existsSync32(eventsPath)) {
|
|
37518
|
+
if (getCoreEventCoverage(directory) === "empty") {
|
|
37377
37519
|
return {
|
|
37378
37520
|
name: "Steering Directives",
|
|
37379
37521
|
status: "\u2705",
|
|
@@ -37381,8 +37523,8 @@ async function checkSteeringDirectives(directory) {
|
|
|
37381
37523
|
};
|
|
37382
37524
|
}
|
|
37383
37525
|
try {
|
|
37384
|
-
const
|
|
37385
|
-
const lines =
|
|
37526
|
+
const window = readCoreEvents(directory);
|
|
37527
|
+
const lines = window.text.split(`
|
|
37386
37528
|
`).filter((line) => line.trim() !== "");
|
|
37387
37529
|
const directivesIssued = [];
|
|
37388
37530
|
const consumedIds = new Set;
|
|
@@ -37399,10 +37541,11 @@ async function checkSteeringDirectives(directory) {
|
|
|
37399
37541
|
}
|
|
37400
37542
|
const unconsumed = directivesIssued.filter((id) => !consumedIds.has(id));
|
|
37401
37543
|
if (unconsumed.length === 0) {
|
|
37544
|
+
const coverageNote = window.coverage === "truncated" ? " (within the retained event window)" : "";
|
|
37402
37545
|
return {
|
|
37403
37546
|
name: "Steering Directives",
|
|
37404
37547
|
status: "\u2705",
|
|
37405
|
-
detail:
|
|
37548
|
+
detail: `All steering directives acknowledged (or none issued)${coverageNote}`
|
|
37406
37549
|
};
|
|
37407
37550
|
}
|
|
37408
37551
|
return {
|
|
@@ -38033,7 +38176,7 @@ async function handleDoctorCommand(directory, args) {
|
|
|
38033
38176
|
const result = runConfigDoctor(config, directory);
|
|
38034
38177
|
let output;
|
|
38035
38178
|
if (enableAutoFix && result.hasAutoFixableIssues) {
|
|
38036
|
-
const { runConfigDoctorWithFixes } = await import("./config-doctor-
|
|
38179
|
+
const { runConfigDoctorWithFixes } = await import("./config-doctor-d3nsq1nz.js");
|
|
38037
38180
|
const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
|
|
38038
38181
|
applyLossy: true
|
|
38039
38182
|
});
|
|
@@ -38973,7 +39116,7 @@ async function handleEvidenceCommand(directory, args) {
|
|
|
38973
39116
|
return formatTaskEvidenceMarkdown(evidenceData);
|
|
38974
39117
|
}
|
|
38975
39118
|
async function handleEvidenceSummaryCommand(directory) {
|
|
38976
|
-
const { buildEvidenceSummary } = await import("./evidence-summary-service-
|
|
39119
|
+
const { buildEvidenceSummary } = await import("./evidence-summary-service-601x7ne7.js");
|
|
38977
39120
|
const artifact = await buildEvidenceSummary(directory);
|
|
38978
39121
|
if (!artifact) {
|
|
38979
39122
|
return "No plan found. Run `/swarm plan` to check plan status.";
|
|
@@ -46191,9 +46334,9 @@ import { createHash as createHash19, createHmac, randomBytes, randomUUID as rand
|
|
|
46191
46334
|
import {
|
|
46192
46335
|
chmod,
|
|
46193
46336
|
copyFile as copyFile2,
|
|
46194
|
-
mkdir as
|
|
46337
|
+
mkdir as mkdir14,
|
|
46195
46338
|
readdir as readdir5,
|
|
46196
|
-
readFile as
|
|
46339
|
+
readFile as readFile17,
|
|
46197
46340
|
realpath as realpath4,
|
|
46198
46341
|
rm as rm2,
|
|
46199
46342
|
stat as stat6,
|
|
@@ -46988,10 +47131,10 @@ function emitMaintenanceTelemetry(payload) {
|
|
|
46988
47131
|
}
|
|
46989
47132
|
var _internals60 = {
|
|
46990
47133
|
emit,
|
|
46991
|
-
readFile:
|
|
47134
|
+
readFile: readFile17,
|
|
46992
47135
|
writeFile: writeFile11,
|
|
46993
47136
|
copyFile: copyFile2,
|
|
46994
|
-
mkdir:
|
|
47137
|
+
mkdir: mkdir14,
|
|
46995
47138
|
stat: stat6,
|
|
46996
47139
|
readdir: readdir5,
|
|
46997
47140
|
resolveHiveDataDir,
|
|
@@ -47313,7 +47456,7 @@ init_schema();
|
|
|
47313
47456
|
init_logger();
|
|
47314
47457
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
47315
47458
|
import { existsSync as existsSync41, readFileSync as readFileSync32 } from "fs";
|
|
47316
|
-
import { mkdir as
|
|
47459
|
+
import { mkdir as mkdir15, readFile as readFile18, writeFile as writeFile12 } from "fs/promises";
|
|
47317
47460
|
import * as os9 from "os";
|
|
47318
47461
|
import * as path68 from "path";
|
|
47319
47462
|
init_knowledge_types();
|
|
@@ -47379,8 +47522,8 @@ var _internals62 = {
|
|
|
47379
47522
|
resolveLegacyHiveKnowledgePath,
|
|
47380
47523
|
existsSync: existsSync41,
|
|
47381
47524
|
readFileSync: readFileSync32,
|
|
47382
|
-
readFile:
|
|
47383
|
-
mkdir:
|
|
47525
|
+
readFile: readFile18,
|
|
47526
|
+
mkdir: mkdir15,
|
|
47384
47527
|
writeFile: writeFile12
|
|
47385
47528
|
};
|
|
47386
47529
|
async function migrateContextToKnowledge(directory, config) {
|
|
@@ -47405,7 +47548,7 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
47405
47548
|
skippedReason: "no-context-file"
|
|
47406
47549
|
};
|
|
47407
47550
|
}
|
|
47408
|
-
const contextContent = await
|
|
47551
|
+
const contextContent = await readFile18(contextPath, "utf-8");
|
|
47409
47552
|
if (contextContent.trim().length === 0) {
|
|
47410
47553
|
return {
|
|
47411
47554
|
migrated: false,
|
|
@@ -48194,14 +48337,14 @@ var _internals63 = {
|
|
|
48194
48337
|
};
|
|
48195
48338
|
|
|
48196
48339
|
// src/commands/link.ts
|
|
48197
|
-
import { mkdir as
|
|
48340
|
+
import { mkdir as mkdir17, writeFile as writeFile13 } from "fs/promises";
|
|
48198
48341
|
import * as path70 from "path";
|
|
48199
48342
|
init_schema();
|
|
48200
48343
|
|
|
48201
48344
|
// src/knowledge/family-migration.ts
|
|
48202
48345
|
var import_proper_lockfile7 = __toESM(require_proper_lockfile(), 1);
|
|
48203
48346
|
import { existsSync as existsSync42, readFileSync as readFileSync33 } from "fs";
|
|
48204
|
-
import { mkdir as
|
|
48347
|
+
import { mkdir as mkdir16 } from "fs/promises";
|
|
48205
48348
|
import * as path69 from "path";
|
|
48206
48349
|
|
|
48207
48350
|
// src/knowledge/family-manifest.ts
|
|
@@ -48484,7 +48627,7 @@ async function snapshotSourceFamily(storeDir) {
|
|
|
48484
48627
|
const snapshot = {};
|
|
48485
48628
|
let release = null;
|
|
48486
48629
|
try {
|
|
48487
|
-
await
|
|
48630
|
+
await mkdir16(storeDir, { recursive: true });
|
|
48488
48631
|
} catch {}
|
|
48489
48632
|
try {
|
|
48490
48633
|
release = await import_proper_lockfile7.default.lock(storeDir, {
|
|
@@ -48503,7 +48646,7 @@ async function snapshotSourceFamily(storeDir) {
|
|
|
48503
48646
|
return snapshot;
|
|
48504
48647
|
}
|
|
48505
48648
|
async function migrateKnowledgeFamily(destinationDir, sourceDir) {
|
|
48506
|
-
await
|
|
48649
|
+
await mkdir16(destinationDir, { recursive: true });
|
|
48507
48650
|
let destRelease = null;
|
|
48508
48651
|
try {
|
|
48509
48652
|
destRelease = await import_proper_lockfile7.default.lock(destinationDir, {
|
|
@@ -48653,7 +48796,7 @@ ${formatStatus(directory)}`;
|
|
|
48653
48796
|
const { config: loadedConfig } = loadPluginConfigWithMeta(directory);
|
|
48654
48797
|
const config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
|
|
48655
48798
|
const fingerprint = cohortConfigFingerprint(buildConfigFingerprintInput(config));
|
|
48656
|
-
await
|
|
48799
|
+
await mkdir17(linkDir, { recursive: true });
|
|
48657
48800
|
await writeFile13(path70.join(linkDir, "cohort-config.json"), JSON.stringify({ fingerprint, updated_at: new Date().toISOString() }, null, 2), "utf-8");
|
|
48658
48801
|
} catch {}
|
|
48659
48802
|
const relinkNote = existing ? `
|
|
@@ -53377,7 +53520,7 @@ function readDeadAnchorMemoryIds(directory) {
|
|
|
53377
53520
|
return new Set(Array.isArray(digest?.deadAnchorMemoryIds) ? digest.deadAnchorMemoryIds.filter((value) => typeof value === "string") : []);
|
|
53378
53521
|
}
|
|
53379
53522
|
// src/memory/consolidation-log.ts
|
|
53380
|
-
import { appendFile as
|
|
53523
|
+
import { appendFile as appendFile4, mkdir as mkdir19, readFile as readFile22 } from "fs/promises";
|
|
53381
53524
|
import * as path76 from "path";
|
|
53382
53525
|
var LOG_RELATIVE_PATH = path76.join("memory", "consolidation-log.jsonl");
|
|
53383
53526
|
var LOG_BASENAME = "consolidation-log.jsonl";
|
|
@@ -53394,7 +53537,7 @@ async function readConsolidationLog(target) {
|
|
|
53394
53537
|
const filePath = resolveLogPath2(target);
|
|
53395
53538
|
let raw;
|
|
53396
53539
|
try {
|
|
53397
|
-
raw = await
|
|
53540
|
+
raw = await readFile22(filePath, "utf-8");
|
|
53398
53541
|
} catch {
|
|
53399
53542
|
return [];
|
|
53400
53543
|
}
|
|
@@ -54041,14 +54184,14 @@ function truncate2(value, maxLength) {
|
|
|
54041
54184
|
}
|
|
54042
54185
|
|
|
54043
54186
|
// src/commands/memory-link.ts
|
|
54044
|
-
import { mkdir as
|
|
54187
|
+
import { mkdir as mkdir21, writeFile as writeFile15 } from "fs/promises";
|
|
54045
54188
|
import * as path79 from "path";
|
|
54046
54189
|
init_schema();
|
|
54047
54190
|
|
|
54048
54191
|
// src/memory/memory-family-migration.ts
|
|
54049
54192
|
var import_proper_lockfile9 = __toESM(require_proper_lockfile(), 1);
|
|
54050
54193
|
import { copyFileSync as copyFileSync4, existsSync as existsSync45, readFileSync as readFileSync35, unlinkSync as unlinkSync13 } from "fs";
|
|
54051
|
-
import { mkdir as
|
|
54194
|
+
import { mkdir as mkdir20, rename as rename8 } from "fs/promises";
|
|
54052
54195
|
import * as path78 from "path";
|
|
54053
54196
|
init_logger();
|
|
54054
54197
|
|
|
@@ -54340,7 +54483,7 @@ async function countRowsSafe(dbPath) {
|
|
|
54340
54483
|
async function migrateMemoryFamily(destRoot, sourceRoot) {
|
|
54341
54484
|
const destStoragePath = rootStoragePath(destRoot);
|
|
54342
54485
|
const sourceStoragePath = rootStoragePath(sourceRoot);
|
|
54343
|
-
await
|
|
54486
|
+
await mkdir20(destStoragePath, { recursive: true });
|
|
54344
54487
|
let destRelease = null;
|
|
54345
54488
|
try {
|
|
54346
54489
|
destRelease = await import_proper_lockfile9.default.lock(destStoragePath, {
|
|
@@ -54387,7 +54530,7 @@ async function migrateMemoryFamily(destRoot, sourceRoot) {
|
|
|
54387
54530
|
}
|
|
54388
54531
|
if (isCohortRoot(sourceRoot)) {
|
|
54389
54532
|
const backupDir = path78.join(destStoragePath, "backups");
|
|
54390
|
-
await
|
|
54533
|
+
await mkdir20(backupDir, { recursive: true });
|
|
54391
54534
|
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
54392
54535
|
const sourceDbPath = path78.join(sourceStoragePath, "memory.db");
|
|
54393
54536
|
if (existsSync45(sourceDbPath)) {
|
|
@@ -54523,7 +54666,7 @@ ${formatStatus2(directory)}`;
|
|
|
54523
54666
|
return `\u274C Failed to migrate the memory family into the cohort store: ${error2 instanceof Error ? error2.message : String(error2)}`;
|
|
54524
54667
|
}
|
|
54525
54668
|
try {
|
|
54526
|
-
await
|
|
54669
|
+
await mkdir21(cohortRoot.cohortRoot, { recursive: true });
|
|
54527
54670
|
const fingerprintInput = buildMemoryCohortFingerprintInput(memoryConfig);
|
|
54528
54671
|
const fingerprint = computeMemoryCohortFingerprint(fingerprintInput);
|
|
54529
54672
|
await writeFile15(path79.join(cohortRoot.cohortRoot, "memory-cohort-config.json"), JSON.stringify({
|
|
@@ -59064,7 +59207,7 @@ function getTestFilesFromConvention(sourceFiles, workingDir = process.cwd()) {
|
|
|
59064
59207
|
const absoluteFile = resolveWorkspacePath(file, workingDir);
|
|
59065
59208
|
const relativeFile = path85.relative(workingDir, absoluteFile);
|
|
59066
59209
|
const basename20 = path85.basename(absoluteFile);
|
|
59067
|
-
const
|
|
59210
|
+
const dirname36 = path85.dirname(absoluteFile);
|
|
59068
59211
|
const preferRelativeOutput = !path85.isAbsolute(file);
|
|
59069
59212
|
if (isConventionTestFilePath(relativeFile) || isConventionTestFilePath(file)) {
|
|
59070
59213
|
dedupePush(testFiles, toWorkspaceOutputPath(absoluteFile, workingDir, preferRelativeOutput));
|
|
@@ -59080,7 +59223,7 @@ function getTestFilesFromConvention(sourceFiles, workingDir = process.cwd()) {
|
|
|
59080
59223
|
const colocatedCandidates = [
|
|
59081
59224
|
...genericTestNames,
|
|
59082
59225
|
...languageSpecificTestNames
|
|
59083
|
-
].map((candidateName) => path85.join(
|
|
59226
|
+
].map((candidateName) => path85.join(dirname36, candidateName));
|
|
59084
59227
|
const testDirectoryNames = [
|
|
59085
59228
|
basename20,
|
|
59086
59229
|
...genericTestNames,
|
|
@@ -59089,7 +59232,7 @@ function getTestFilesFromConvention(sourceFiles, workingDir = process.cwd()) {
|
|
|
59089
59232
|
const repoLevelDirectories = getRepoLevelCandidateDirectories(workingDir, relativeFile, ext);
|
|
59090
59233
|
const possibleTestFiles = [
|
|
59091
59234
|
...colocatedCandidates,
|
|
59092
|
-
...TEST_DIRECTORY_NAMES.flatMap((dirName) => testDirectoryNames.map((candidateName) => path85.join(
|
|
59235
|
+
...TEST_DIRECTORY_NAMES.flatMap((dirName) => testDirectoryNames.map((candidateName) => path85.join(dirname36, dirName, candidateName))),
|
|
59093
59236
|
...repoLevelDirectories.flatMap((candidateDir) => testDirectoryNames.map((candidateName) => path85.join(candidateDir, candidateName)))
|
|
59094
59237
|
];
|
|
59095
59238
|
for (const testFile of possibleTestFiles) {
|
|
@@ -61666,34 +61809,17 @@ async function handleQaGatesCommand(directory, args, sessionID) {
|
|
|
61666
61809
|
}
|
|
61667
61810
|
|
|
61668
61811
|
// src/workflow/stage-a-repair.ts
|
|
61669
|
-
import {
|
|
61670
|
-
import { dirname as dirname38 } from "path";
|
|
61812
|
+
import { readdir as readdir8 } from "fs/promises";
|
|
61671
61813
|
init_logger();
|
|
61672
61814
|
var MAX_STAGE_A_REPAIR_SCAN = 200;
|
|
61673
|
-
var RETRYABLE_EVENT_CODES = new Set(["EBUSY", "EPERM"]);
|
|
61674
61815
|
async function appendStageARepairEvent(directory, payload) {
|
|
61675
|
-
const line = `${JSON.stringify({
|
|
61676
|
-
type: "stage_a_repair",
|
|
61677
|
-
timestamp: new Date().toISOString(),
|
|
61678
|
-
...payload
|
|
61679
|
-
})}
|
|
61680
|
-
`;
|
|
61681
61816
|
try {
|
|
61682
|
-
|
|
61683
|
-
|
|
61684
|
-
|
|
61817
|
+
appendCoreEventSync(directory, {
|
|
61818
|
+
type: "stage_a_repair",
|
|
61819
|
+
timestamp: new Date().toISOString(),
|
|
61820
|
+
...payload
|
|
61821
|
+
});
|
|
61685
61822
|
} catch (error2) {
|
|
61686
|
-
const code = error2.code;
|
|
61687
|
-
if (code && RETRYABLE_EVENT_CODES.has(code)) {
|
|
61688
|
-
try {
|
|
61689
|
-
const eventsPath = validateSwarmPath(directory, "events.jsonl");
|
|
61690
|
-
await appendFile10(eventsPath, line, "utf-8");
|
|
61691
|
-
return;
|
|
61692
|
-
} catch (retryError) {
|
|
61693
|
-
criticalWarn(`[stage-a-repair] audit event write failed after retry: ${retryError instanceof Error ? retryError.message : String(retryError)}`);
|
|
61694
|
-
return;
|
|
61695
|
-
}
|
|
61696
|
-
}
|
|
61697
61823
|
criticalWarn(`[stage-a-repair] audit event write failed: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
61698
61824
|
}
|
|
61699
61825
|
}
|
|
@@ -62768,6 +62894,7 @@ async function handleResetCommand(directory, args) {
|
|
|
62768
62894
|
"plan-export/SWARM_PLAN.json",
|
|
62769
62895
|
"checkpoints.json",
|
|
62770
62896
|
"events.jsonl",
|
|
62897
|
+
"events-authority-index.json",
|
|
62771
62898
|
"run-memory.jsonl",
|
|
62772
62899
|
"reproduction.json",
|
|
62773
62900
|
"issue-publication.json",
|
|
@@ -67246,7 +67373,6 @@ async function restoreGitCheckpoint(directory, selected) {
|
|
|
67246
67373
|
if (parsed.success !== true) {
|
|
67247
67374
|
return `Error: ${parsed.error || `Failed to restore checkpoint "${selected.label}"`}`;
|
|
67248
67375
|
}
|
|
67249
|
-
const eventsPath = validateSwarmPath(directory, "events.jsonl");
|
|
67250
67376
|
const rollbackEvent = {
|
|
67251
67377
|
type: "rollback",
|
|
67252
67378
|
label: selected.label,
|
|
@@ -67255,8 +67381,7 @@ async function restoreGitCheckpoint(directory, selected) {
|
|
|
67255
67381
|
source: "checkpoints.json"
|
|
67256
67382
|
};
|
|
67257
67383
|
try {
|
|
67258
|
-
|
|
67259
|
-
`);
|
|
67384
|
+
appendCoreEventSync(directory, rollbackEvent);
|
|
67260
67385
|
} catch (error2) {
|
|
67261
67386
|
log("Failed to write rollback event:", error2 instanceof Error ? error2.message : String(error2));
|
|
67262
67387
|
}
|
|
@@ -67403,7 +67528,6 @@ async function handleRollbackCommand(directory, args) {
|
|
|
67403
67528
|
`);
|
|
67404
67529
|
}
|
|
67405
67530
|
}
|
|
67406
|
-
const eventsPath = validateSwarmPath(directory, "events.jsonl");
|
|
67407
67531
|
const rollbackEvent = {
|
|
67408
67532
|
type: "rollback",
|
|
67409
67533
|
phase: targetPhase,
|
|
@@ -67411,8 +67535,7 @@ async function handleRollbackCommand(directory, args) {
|
|
|
67411
67535
|
timestamp: new Date().toISOString()
|
|
67412
67536
|
};
|
|
67413
67537
|
try {
|
|
67414
|
-
|
|
67415
|
-
`);
|
|
67538
|
+
appendCoreEventSync(directory, rollbackEvent);
|
|
67416
67539
|
} catch (error2) {
|
|
67417
67540
|
log("Failed to write rollback event:", error2 instanceof Error ? error2.message : String(error2));
|
|
67418
67541
|
}
|
|
@@ -69404,7 +69527,7 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
|
|
|
69404
69527
|
if (!input.dispatcher) {
|
|
69405
69528
|
throw new Error("no evaluation dispatcher available (cannot run validation)");
|
|
69406
69529
|
}
|
|
69407
|
-
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-
|
|
69530
|
+
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-1aygs98c.js");
|
|
69408
69531
|
const executor = createModelEvaluationExecutor2(input.dispatcher, input.sessionId);
|
|
69409
69532
|
const result = await _internals95.evaluateCandidateV1({
|
|
69410
69533
|
projectRoot: input.directory,
|
|
@@ -69920,7 +70043,7 @@ async function handleSpecifyCommand(_directory, args) {
|
|
|
69920
70043
|
|
|
69921
70044
|
// src/services/status-service.ts
|
|
69922
70045
|
import * as fsSync3 from "fs";
|
|
69923
|
-
import { readFile as
|
|
70046
|
+
import { readFile as readFile24 } from "fs/promises";
|
|
69924
70047
|
import * as path109 from "path";
|
|
69925
70048
|
init_loader();
|
|
69926
70049
|
init_schema();
|
|
@@ -70961,7 +71084,7 @@ async function safeLineCount(filePath) {
|
|
|
70961
71084
|
try {
|
|
70962
71085
|
if (!fsSync3.existsSync(filePath))
|
|
70963
71086
|
return 0;
|
|
70964
|
-
const content = await
|
|
71087
|
+
const content = await readFile24(filePath, "utf-8");
|
|
70965
71088
|
let n = 0;
|
|
70966
71089
|
for (const line of content.split(`
|
|
70967
71090
|
`)) {
|
|
@@ -71439,7 +71562,7 @@ function buildDetailedHelp(commandName, entry) {
|
|
|
71439
71562
|
async function handleHelpCommand(ctx) {
|
|
71440
71563
|
const targetCommand = ctx.args.join(" ");
|
|
71441
71564
|
if (!targetCommand) {
|
|
71442
|
-
const { buildHelpText } = await import("./index-
|
|
71565
|
+
const { buildHelpText } = await import("./index-f53yyerg.js");
|
|
71443
71566
|
return buildHelpText();
|
|
71444
71567
|
}
|
|
71445
71568
|
const tokens = targetCommand.split(/\s+/);
|
|
@@ -71448,7 +71571,7 @@ async function handleHelpCommand(ctx) {
|
|
|
71448
71571
|
return _internals98.buildDetailedHelp(resolved.key, resolved.entry);
|
|
71449
71572
|
}
|
|
71450
71573
|
const similar = _internals98.findSimilarCommands(targetCommand);
|
|
71451
|
-
const { buildHelpText: fullHelp } = await import("./index-
|
|
71574
|
+
const { buildHelpText: fullHelp } = await import("./index-f53yyerg.js");
|
|
71452
71575
|
if (similar.length > 0) {
|
|
71453
71576
|
return `Command '/swarm ${targetCommand}' not found.
|
|
71454
71577
|
|
|
@@ -71628,7 +71751,7 @@ var COMMAND_REGISTRY = {
|
|
|
71628
71751
|
},
|
|
71629
71752
|
"guardrail explain": {
|
|
71630
71753
|
handler: async (ctx) => {
|
|
71631
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
71754
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-j291sss5.js");
|
|
71632
71755
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
71633
71756
|
},
|
|
71634
71757
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -71638,7 +71761,7 @@ var COMMAND_REGISTRY = {
|
|
|
71638
71761
|
},
|
|
71639
71762
|
"guardrail reset": {
|
|
71640
71763
|
handler: async (ctx) => {
|
|
71641
|
-
const { handleGuardrailReset } = await import("./guardrail-reset-
|
|
71764
|
+
const { handleGuardrailReset } = await import("./guardrail-reset-tr07m077.js");
|
|
71642
71765
|
return handleGuardrailReset(ctx.args, ctx.sessionID);
|
|
71643
71766
|
},
|
|
71644
71767
|
description: "Reset one exact active invocation/action circuit after repair",
|
|
@@ -71647,7 +71770,7 @@ var COMMAND_REGISTRY = {
|
|
|
71647
71770
|
},
|
|
71648
71771
|
"guardrail-explain": {
|
|
71649
71772
|
handler: async (ctx) => {
|
|
71650
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
71773
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-j291sss5.js");
|
|
71651
71774
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
71652
71775
|
},
|
|
71653
71776
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -71657,7 +71780,7 @@ var COMMAND_REGISTRY = {
|
|
|
71657
71780
|
},
|
|
71658
71781
|
"guardrail-reset": {
|
|
71659
71782
|
handler: async (ctx) => {
|
|
71660
|
-
const { handleGuardrailReset } = await import("./guardrail-reset-
|
|
71783
|
+
const { handleGuardrailReset } = await import("./guardrail-reset-tr07m077.js");
|
|
71661
71784
|
return handleGuardrailReset(ctx.args, ctx.sessionID);
|
|
71662
71785
|
},
|
|
71663
71786
|
description: "Reset one exact active invocation/action circuit after repair",
|
|
@@ -71667,7 +71790,7 @@ var COMMAND_REGISTRY = {
|
|
|
71667
71790
|
},
|
|
71668
71791
|
"guardrail-log": {
|
|
71669
71792
|
handler: async (ctx) => {
|
|
71670
|
-
const { handleGuardrailLog } = await import("./guardrail-log-
|
|
71793
|
+
const { handleGuardrailLog } = await import("./guardrail-log-1jykfrqc.js");
|
|
71671
71794
|
return handleGuardrailLog(ctx.directory, ctx.args);
|
|
71672
71795
|
},
|
|
71673
71796
|
description: "Read the guardrail decision log (use --blocks-only for blocks)",
|
|
@@ -73601,6 +73724,7 @@ HARD CONSTRAINTS (apply regardless of skill load success):
|
|
|
73601
73724
|
- Treat the controller Git-state result as final for the attempt: \`clean\` proceeds; \`stashable\` permits one preparation call; \`recovery-required\` or \`indeterminate\` means report the typed \`required_action\`, abort/clear any already-active gate, and STOP unless \`retryable: true\`. Never loop on stash against an unmerged index or in-progress Git operation.
|
|
73602
73725
|
- RUN ALL BASE LANES: the default PR_REVIEW path covers all six repository-agnostic base dimensions from the skill on every PR. Use \`mode: "swarm-pr-review:base"\`, the exact \`workflow_lane\` identifiers, and the exact bound \`pr_head_sha\`. With the default \`pr_review_resilience\` policy enabled, depth tier M/L MUST stage attempt 0 as one singleton \`pr_review_wave_stage: "canary"\` batch followed by a \`"fanout"\` batch whose combined canary+fanout ownership partitions all six dimensions exactly once; tier L still requires six singleton combined lanes, and tier S keeps the legacy one-wave path. If a project disables \`pr_review_resilience\`, stay on the legacy one-wave base dispatch. The runtime rejects omitted stage metadata, partial, duplicate, mislabelled, or structurally invalid waves.
|
|
73603
73726
|
- RETRY STRUCTURALLY: retry only unresolved failed base obligations in later \`swarm-pr-review:base\` async batches with the same exact \`pr_head_sha\`. Under staged resilience, attempts are numbered by \`pr_review_wave_attempt\`: attempt 0 plus at most two retry attempts (1 and 2), each with one singleton canary batch and then its matching fanout batch when obligations remain. Blocking \`dispatch_lanes\` and direct Task explorer/reviewer/critic dispatch are not provenance-equivalent and are rejected. If the runtime returns typed \`retry_exhausted\` or \`circuit_open\`, or if the second retry still cannot close coverage, collect every lane to settlement, do not probe downstream writers or micro lanes, call \`abort_pr_workflow\` with \`mode: "PR_REVIEW"\`, \`kind: "recovery"\`, and a non-empty one-line \`reason\` naming the failed lane or correlated failure and exhausted retries, then call \`prepare_pr_workflow_checkout\` with \`operation: "restore"\` before reporting the blocker.
|
|
73727
|
+
- RECOVER CONTRACT FAILURES EXPLICITLY: when collection reports \`workflow_lane_failure_class: "contract"\`, retry that one singleton base dimension once with \`pr_review_contract_retry: true\`; this retry is outside staged \`pr_review_wave_attempt\` accounting and cannot be combined with stage metadata. If exactly five base dimensions settle successfully and one dimension remains terminally failed with a typed \`contract\`, \`resource\`, or \`deadline\` class, the \`post_explorer\` findings write may explicitly submit \`partial_base_coverage: { missing_dimension: "<exact lane>" }\`. Never infer or omit this disclosure: the runtime verifies five-of-six, persists an immutable coverage receipt, and rejects any other partial shape.
|
|
73604
73728
|
- USE ASYNC DISPATCH WITHOUT IDLING: each admissible base wave uses one \`dispatch_lanes_async\` call. With enabled tier-M/L staged resilience, this means one singleton canary call followed by one unresolved-only fanout call after canary admission; it never means one legacy call carrying the whole initial base wave. Record each \`batch_id\`, then keep doing non-dependent architect work while its lanes run. Poll with \`collect_lane_results\` without \`wait\` (or \`wait: false\`) to process settled lanes and continue independent work between polls; use \`wait: true\` only as the final join when no independent work remains.
|
|
73605
73729
|
- EVALUATE ALL RISK FAMILIES: after the base explorer lanes settle, evaluate every repository-agnostic trigger row against the exact diff/context pack. Record applicable families as \`MATCHED\` and inapplicable families as provenance-free \`NOT_TRIGGERED\` with concrete absence evidence; \`unclassified-risk\` always remains \`MATCHED\`. Launch \`swarm-pr-review:micro\` lanes only for the \`MATCHED\` IDs. The first micro dispatch MUST pass the complete exact eleven-row \`trigger_evaluation\`, which freezes it for this session; any subsequent same-session micro batch may omit it and reuse the frozen ledger, while an explicitly supplied copy must remain exactly identical. Use each dispatched trigger ID as \`workflow_lane\`. Missing an evaluation row or a matched-family attestation is BLOCKED; a \`NOT_TRIGGERED\` family must not create a micro artifact.
|
|
73606
73730
|
- RUN HEAD-BOUND VALIDATION: dispatch independent reviewers with \`mode: "swarm-pr-review:reviewer"\` and critics with \`mode: "swarm-pr-review:critic"\`, unique \`workflow_lane\` obligations, role-correct agents, and the same exact \`pr_head_sha\`. Critic dispatch is blocked until all declared reviewer obligations have successful artifacts.
|
|
@@ -76902,16 +77026,14 @@ async function forceRecordPlanCriticApproval(directory, sessionID, options = {})
|
|
|
76902
77026
|
payloadHashOverride: computePlanStructureHash(plan)
|
|
76903
77027
|
});
|
|
76904
77028
|
try {
|
|
76905
|
-
|
|
76906
|
-
await fs52.promises.appendFile(eventsPath, `${JSON.stringify({
|
|
77029
|
+
appendCoreEventSync(directory, {
|
|
76907
77030
|
type: "plan_critic_gate_manual_approval",
|
|
76908
77031
|
timestamp: recordedAt,
|
|
76909
77032
|
sessionID,
|
|
76910
77033
|
plan_id: planId,
|
|
76911
77034
|
user_confirmed: userConfirmed,
|
|
76912
77035
|
...sanitizedReason ? { reason: sanitizedReason } : {}
|
|
76913
|
-
})
|
|
76914
|
-
`, "utf-8");
|
|
77036
|
+
});
|
|
76915
77037
|
} catch (err) {
|
|
76916
77038
|
warn(`[delegation-gate] plan_critic_gate_manual_approval audit event write failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
76917
77039
|
}
|
|
@@ -78094,7 +78216,7 @@ function getDisplayBudget() {
|
|
|
78094
78216
|
async function rehydratePrSubscriptions(sessionID, directory) {
|
|
78095
78217
|
const map = new Map;
|
|
78096
78218
|
try {
|
|
78097
|
-
const { listActive: listActive2 } = await import("./pr-subscriptions-
|
|
78219
|
+
const { listActive: listActive2 } = await import("./pr-subscriptions-q862pvz1.js");
|
|
78098
78220
|
const records = await listActive2(directory);
|
|
78099
78221
|
for (const record of records) {
|
|
78100
78222
|
if (record.sessionID !== sessionID)
|
|
@@ -78510,7 +78632,7 @@ function isLaneOwnedByCurrentSession(branchName, expectedSessionId) {
|
|
|
78510
78632
|
return extracted === expectedSessionId;
|
|
78511
78633
|
}
|
|
78512
78634
|
async function inspectStandardWorktreeCollisionOwnership(identity) {
|
|
78513
|
-
const collisionOwnership = await import("./worktree-collision-ownership-
|
|
78635
|
+
const collisionOwnership = await import("./worktree-collision-ownership-9v8e0dz7.js");
|
|
78514
78636
|
return collisionOwnership.inspectStandardWorktreeCollisionOwnership(identity);
|
|
78515
78637
|
}
|
|
78516
78638
|
async function precreateStandardWorktreeSession(args) {
|
|
@@ -78658,7 +78780,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
78658
78780
|
const laneProfile = computeLaneRuntimeProfile(worktreeConfig.runtime_isolation, laneIndex, provisionResult.worktreePath);
|
|
78659
78781
|
if (laneProfile) {
|
|
78660
78782
|
try {
|
|
78661
|
-
const { writeLaneProfileToDiskReal } = await import("./core-
|
|
78783
|
+
const { writeLaneProfileToDiskReal } = await import("./core-y9d858n6.js");
|
|
78662
78784
|
await writeLaneProfileToDiskReal(provisionResult.worktreePath, laneProfile.laneIndex, laneProfile.envOverrides);
|
|
78663
78785
|
} catch {}
|
|
78664
78786
|
}
|
|
@@ -79316,7 +79438,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
79316
79438
|
}
|
|
79317
79439
|
clearWorktreeMergeStatus(statusKey);
|
|
79318
79440
|
try {
|
|
79319
|
-
const { removeLaneProfileFromDiskReal } = await import("./core-
|
|
79441
|
+
const { removeLaneProfileFromDiskReal } = await import("./core-y9d858n6.js");
|
|
79320
79442
|
await removeLaneProfileFromDiskReal(dispatch.handle.worktreePath, dispatch.laneIndex);
|
|
79321
79443
|
} catch {}
|
|
79322
79444
|
const state = serializationStateBySessionID.get(dispatch.parentSessionID);
|