@cortexkit/opencode-magic-context 0.49.92 → 0.49.95
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/auto-search-worker.js +4 -4
- package/dist/chunk-embedding-write-worker.js +3 -3
- package/dist/{compartment-chunk-embedding-rp4asvk0.js → compartment-chunk-embedding-4nn3hsw2.js} +2 -2
- package/dist/{context-e8qd2v00.js → context-h9x9m2p3.js} +192 -68
- package/dist/{embedding-backfill-w0yq71q2.js → embedding-backfill-wdrqkw09.js} +6 -6
- package/dist/embedding-worker.js +3 -3
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts +5 -2
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
- package/dist/features/magic-context/history-gap-recovery.d.ts +42 -0
- package/dist/features/magic-context/history-gap-recovery.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-synapse.d.ts +18 -5
- package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts +3 -0
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/message-visibility.d.ts +10 -0
- package/dist/features/magic-context/message-visibility.d.ts.map +1 -0
- package/dist/features/magic-context/search.d.ts +4 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/session-decision-calibration.d.ts.map +1 -1
- package/dist/features/magic-context/session-project-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/history-boundary-repair.d.ts +2 -2
- package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-measured-request.d.ts +1 -0
- package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts +3 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts +1 -0
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts +4 -0
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +1 -0
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts +4 -0
- package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +2 -0
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-stage-logger.d.ts +6 -0
- package/dist/hooks/magic-context/transform-stage-logger.d.ts.map +1 -1
- package/dist/{index-3f3d548g.js → index-2gewejcz.js} +18 -9
- package/dist/{index-n71006wq.js → index-2v9qpmb3.js} +5 -5
- package/dist/{index-zzhcshdk.js → index-3tmbvn0z.js} +9 -9
- package/dist/{index-f25ha337.js → index-3ywyr4zx.js} +1 -1
- package/dist/{index-hbn5g7rt.js → index-47hst5me.js} +1 -1
- package/dist/{index-xg1zjht5.js → index-7dzaamqg.js} +6 -6
- package/dist/{index-5y9w2ax7.js → index-7r11k4xr.js} +2 -2
- package/dist/{index-5pmf4jpj.js → index-7skgrbsg.js} +100 -52
- package/dist/{index-6rk44cer.js → index-c81tggen.js} +1 -1
- package/dist/{index-0twg41mh.js → index-ejgp0z9p.js} +1 -1
- package/dist/{index-hre29c1a.js → index-esacb9d0.js} +1 -1
- package/dist/{index-5a9kwapd.js → index-ewta5h87.js} +4 -4
- package/dist/{index-6r99v53h.js → index-j7n64sg4.js} +162 -60
- package/dist/{index-r3tdqqtq.js → index-jm62g83a.js} +180 -64
- package/dist/{index-anwy2mfb.js → index-pc49a7zt.js} +162 -31
- package/dist/{index-ydhymf0b.js → index-qmm8xpbc.js} +4 -4
- package/dist/{index-3n376ann.js → index-tedck05r.js} +4 -4
- package/dist/{index-j2w79s9r.js → index-tm799pq7.js} +1 -1
- package/dist/{index-01h7tqe3.js → index-tr4ep2ej.js} +21 -6
- package/dist/{index-wvbg9m0h.js → index-wqwjawer.js} +27 -11
- package/dist/index-xe34pwb6.js +119 -0
- package/dist/{index-xn9efn18.js → index-xjaf9g90.js} +13 -6
- package/dist/{index-6nqz8hsz.js → index-y915t3ey.js} +1 -1
- package/dist/{index-41bma6qs.js → index-yzzxb5e1.js} +2 -2
- package/dist/{index-901exj0f.js → index-zk6gtf43.js} +45 -9
- package/dist/index.js +27 -27
- package/dist/{message-index-bounded-f6fc00ze.js → message-index-bounded-d3x8rhpz.js} +4 -4
- package/dist/migration-worker.js +1 -1
- package/dist/{project-embedding-registry-8je0xg18.js → project-embedding-registry-az68q792.js} +5 -5
- package/dist/raw-ordinal-warmup-worker.js +5 -5
- package/dist/{read-session-chunk-y2ew3630.js → read-session-chunk-70r1snq3.js} +3 -3
- package/dist/{recomp-orchestrator-ggtcvb9g.js → recomp-orchestrator-cn4r2gz6.js} +15 -15
- package/dist/{render-q8c6wrq9.js → render-g45k3gts.js} +10 -10
- package/dist/{search-archive-pz1jf655.js → search-archive-s9t3exc1.js} +9 -7
- package/dist/{search-gjyrwapc.js → search-b0cb342r.js} +13 -13
- package/dist/shared/storage-file-mutex.d.ts.map +1 -1
- package/dist/{storage-tags-7raphcw6.js → storage-tags-xvbje7jm.js} +2 -2
- package/dist/{store-yr443ye8.js → store-91kawq9a.js} +2 -2
- package/dist/{store-reader-qbq6q4v0.js → store-reader-dgh3ssxx.js} +1 -1
- package/dist/tools/ctx-expand/search-archive.d.ts +3 -2
- package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -1
- package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
- package/dist/tools/ctx-expand/v2-archive-reader.d.ts +2 -0
- package/dist/tools/ctx-expand/v2-archive-reader.d.ts.map +1 -1
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-pmzdd3s2.js → transform-postprocess-phase-r1xhsjrh.js} +16 -16
- package/dist/v2/auto-search-worker.js +4 -4
- package/dist/v2/chunk-embedding-write-worker.js +3 -3
- package/dist/v2/{compartment-chunk-embedding-w7ht0t9v.js → compartment-chunk-embedding-a7ddvz7v.js} +2 -2
- package/dist/v2/{context-qqbpzk1q.js → context-2hssw26q.js} +351 -111
- package/dist/v2/{embedding-backfill-95m72gxa.js → embedding-backfill-gveter8p.js} +6 -6
- package/dist/v2/embedding-worker.js +3 -3
- package/dist/v2/fold/memory-cache.d.ts +2 -0
- package/dist/v2/fold/memory-cache.d.ts.map +1 -1
- package/dist/v2/fold/native-replay.d.ts +22 -5
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/revert-message-state.d.ts.map +1 -1
- package/dist/v2/hooks/session-project-backfill.d.ts +2 -1
- package/dist/v2/hooks/session-project-backfill.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-70g28hyg.js → message-index-bounded-tbwrff24.js} +4 -4
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-fcxf4qht.js → project-embedding-registry-2zeycxek.js} +5 -5
- package/dist/v2/raw-ordinal-warmup-worker.js +5 -5
- package/dist/v2/{read-session-chunk-9rf0n9e6.js → read-session-chunk-cvgsfsgr.js} +3 -3
- package/dist/v2/{recomp-orchestrator-cwghhjc9.js → recomp-orchestrator-k4cj62f2.js} +15 -15
- package/dist/v2/{render-e852zmxz.js → render-ys7a3zks.js} +10 -10
- package/dist/v2/{search-archive-tmn6b5w8.js → search-archive-k2yh0jj3.js} +9 -7
- package/dist/v2/{search-jd3vczhn.js → search-x1cac8t6.js} +12 -12
- package/dist/v2/{server-vsqmkvxc.js → server-00adcfjd.js} +1 -1
- package/dist/v2/{server-rkj44mez.js → server-476anw1w.js} +1 -1
- package/dist/v2/{server-barj0mjz.js → server-5016ccyn.js} +1 -1
- package/dist/v2/{server-72k2r3kt.js → server-6aj72z52.js} +4 -4
- package/dist/v2/{server-7x5a46hf.js → server-6nh36020.js} +70 -61
- package/dist/v2/{server-fj3pekz2.js → server-88pjnecb.js} +1 -1
- package/dist/v2/{server-js2v309w.js → server-bfct1yvb.js} +99 -51
- package/dist/v2/{server-6t3asmx8.js → server-cd93xyyx.js} +162 -31
- package/dist/v2/{server-ysjjcatk.js → server-cvm1qrqc.js} +2 -2
- package/dist/v2/{server-rz6g5xne.js → server-e6xneh68.js} +1 -1
- package/dist/v2/{server-d4trxrj3.js → server-gj259dqy.js} +45 -9
- package/dist/v2/{server-8ps3717t.js → server-prrx17q3.js} +4 -4
- package/dist/v2/{server-7e89a2kf.js → server-qy58c11s.js} +13 -6
- package/dist/v2/{server-9011eteb.js → server-s81b3nct.js} +2 -2
- package/dist/v2/{server-p4g021y5.js → server-s8mk882p.js} +27 -11
- package/dist/v2/{server-mgxqfprb.js → server-srtq37nh.js} +1 -1
- package/dist/v2/{server-bvr9xs8h.js → server-vbr1rdkg.js} +6 -6
- package/dist/v2/{server-vtgeyhq6.js → server-vtkbxzw1.js} +21 -6
- package/dist/v2/{server-ps6zrzwj.js → server-xepfjgv5.js} +162 -60
- package/dist/v2/server-y0pd600x.js +119 -0
- package/dist/v2/{server-b4efn08m.js → server-zc8s06gx.js} +1 -1
- package/dist/v2/server.js +4 -4
- package/dist/v2/{storage-tags-wgsemtw1.js → storage-tags-y20j3jdp.js} +2 -2
- package/dist/v2/{store-enef5jcn.js → store-b95snz31.js} +2 -2
- package/dist/v2/{store-reader-jbaqv1yp.js → store-reader-qt2msa8z.js} +1 -1
- package/dist/v2/store-reader.d.ts +1 -1
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{v2-archive-reader-dm1aeqk2.js → v2-archive-reader-q92kwkr5.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-cke368np.js → wrapup-orchestrator-ydqkxkhj.js} +15 -15
- package/dist/{v2-archive-reader-39ye0d3b.js → v2-archive-reader-x62hsr4c.js} +1 -1
- package/dist/{wrapup-orchestrator-ggnk0r4r.js → wrapup-orchestrator-kt81d6et.js} +16 -16
- package/package.json +1 -1
- package/src/config/schema/magic-context.ts +1 -1
- package/src/shared/storage-file-mutex-review.test.ts +110 -0
- package/src/shared/storage-file-mutex.ts +12 -0
- package/dist/index-52x68mj4.js +0 -58
- package/dist/v2/server-52x68mj4.js +0 -58
|
@@ -214,7 +214,7 @@ import {
|
|
|
214
214
|
snapRangeToCompartments,
|
|
215
215
|
getActiveCompartmentRun,
|
|
216
216
|
startCompartmentAgent
|
|
217
|
-
} from "./index-
|
|
217
|
+
} from "./index-2gewejcz.js";
|
|
218
218
|
import {
|
|
219
219
|
formatWindowDerivationLine,
|
|
220
220
|
getSdkWindowGeometry,
|
|
@@ -280,6 +280,7 @@ import {
|
|
|
280
280
|
resolveCompactionModeRecord,
|
|
281
281
|
getCompactionModeRecord,
|
|
282
282
|
setCompactionModeRecord,
|
|
283
|
+
EMERGENCY_DRAIN_FAILURE_BACKOFF_MS,
|
|
283
284
|
clearPersistedReasoningWatermark,
|
|
284
285
|
getEmergencyInputSample,
|
|
285
286
|
clearEmergencyDropSample,
|
|
@@ -303,6 +304,7 @@ import {
|
|
|
303
304
|
setPersistedTodoSyntheticAnchor,
|
|
304
305
|
clearPersistedTodoSyntheticAnchor,
|
|
305
306
|
setNoteLastReadAt,
|
|
307
|
+
getHistorianFailureState,
|
|
306
308
|
clearHistorianFailureState,
|
|
307
309
|
getOverflowState,
|
|
308
310
|
loadTransformPassStateSnapshot,
|
|
@@ -370,7 +372,7 @@ import {
|
|
|
370
372
|
getTagsByNumbers2,
|
|
371
373
|
getDroppedTagsByNumbers2,
|
|
372
374
|
getMaxDroppedTagNumber2
|
|
373
|
-
} from "./index-
|
|
375
|
+
} from "./index-zk6gtf43.js";
|
|
374
376
|
import {
|
|
375
377
|
BoundedSessionMap,
|
|
376
378
|
observeTemporalDecisions,
|
|
@@ -397,7 +399,7 @@ import {
|
|
|
397
399
|
DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
398
400
|
DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
399
401
|
DREAM_TASK_PROMOTION_DEFAULTS
|
|
400
|
-
} from "./index-
|
|
402
|
+
} from "./index-y915t3ey.js";
|
|
401
403
|
import {
|
|
402
404
|
areRustHistorianSyntheticParts2,
|
|
403
405
|
isRawCompactionSummaryInfo2,
|
|
@@ -429,6 +431,7 @@ import {
|
|
|
429
431
|
cleanUserText2,
|
|
430
432
|
withRawSessionMessageCache2,
|
|
431
433
|
readRawSessionMessages2,
|
|
434
|
+
getRawSessionMessageOrdinalCount2,
|
|
432
435
|
visitRawSessionMessages2,
|
|
433
436
|
visitRawSessionMessagesAsync2,
|
|
434
437
|
prepareRawSessionOrdinals2,
|
|
@@ -443,7 +446,7 @@ import {
|
|
|
443
446
|
readRawSessionMessageById2,
|
|
444
447
|
readSessionChunk2,
|
|
445
448
|
readRawSessionSeedTail2
|
|
446
|
-
} from "./index-
|
|
449
|
+
} from "./index-7r11k4xr.js";
|
|
447
450
|
import {
|
|
448
451
|
buildDreamTaskRuntimeConfigs2,
|
|
449
452
|
userMemoryCollectionEnabled2
|
|
@@ -467,7 +470,7 @@ import {
|
|
|
467
470
|
runSqliteOptimize,
|
|
468
471
|
openDatabase,
|
|
469
472
|
openCurrentDatabase
|
|
470
|
-
} from "./index-
|
|
473
|
+
} from "./index-c81tggen.js";
|
|
471
474
|
import {
|
|
472
475
|
unescapeXml,
|
|
473
476
|
resolveWorkspaceShareCategories,
|
|
@@ -498,8 +501,12 @@ import {
|
|
|
498
501
|
toSynapseLaneDescriptor,
|
|
499
502
|
formatSynapseLaneDescriptor,
|
|
500
503
|
SynapseEmbeddingProvider
|
|
501
|
-
} from "./index-
|
|
504
|
+
} from "./index-j7n64sg4.js";
|
|
502
505
|
import {
|
|
506
|
+
readHistoryGapMark,
|
|
507
|
+
clearHistoryGapMark,
|
|
508
|
+
claimHistoryGapCheck,
|
|
509
|
+
recordHistoryGapAdmission,
|
|
503
510
|
getCompartments,
|
|
504
511
|
getLastCompartmentEndMessage,
|
|
505
512
|
getLastCompartmentEndMessageId,
|
|
@@ -582,10 +589,10 @@ import {
|
|
|
582
589
|
GLOBAL_USER_PROFILE_PROJECT_PATH,
|
|
583
590
|
getProjectState,
|
|
584
591
|
bumpProjectUserProfileVersion
|
|
585
|
-
} from "./index-
|
|
592
|
+
} from "./index-pc49a7zt.js";
|
|
586
593
|
import {
|
|
587
594
|
getLastIndexedOrdinal
|
|
588
|
-
} from "./index-
|
|
595
|
+
} from "./index-esacb9d0.js";
|
|
589
596
|
import {
|
|
590
597
|
SESSION_NOTE_CONDITION_ERROR,
|
|
591
598
|
getNoteByIdInScope,
|
|
@@ -623,7 +630,7 @@ import {
|
|
|
623
630
|
getCachedLocalEmbeddingPooling,
|
|
624
631
|
preflightLocalEmbeddingPooling,
|
|
625
632
|
getLocalEmbeddingNativeMemoryStats
|
|
626
|
-
} from "./index-
|
|
633
|
+
} from "./index-xjaf9g90.js";
|
|
627
634
|
import {
|
|
628
635
|
withQueryEmbeddingDeadline,
|
|
629
636
|
describeShadowBackfillWriteRefusal2,
|
|
@@ -645,7 +652,7 @@ import {
|
|
|
645
652
|
embedSessionCompartmentChunks2,
|
|
646
653
|
getEmbeddingCoverageStatus2,
|
|
647
654
|
getAutoEmbeddingSessionCoverage2
|
|
648
|
-
} from "./index-
|
|
655
|
+
} from "./index-tedck05r.js";
|
|
649
656
|
import {
|
|
650
657
|
saveEmbeddingIfHashMatches,
|
|
651
658
|
invalidateProject2,
|
|
@@ -671,7 +678,7 @@ import {
|
|
|
671
678
|
readGitFileChangeTimesSince,
|
|
672
679
|
verificationFileExists,
|
|
673
680
|
normalizeVerificationFiles
|
|
674
|
-
} from "./index-
|
|
681
|
+
} from "./index-qmm8xpbc.js";
|
|
675
682
|
import {
|
|
676
683
|
computeCueContentHash,
|
|
677
684
|
hasMuralCueColumns,
|
|
@@ -719,13 +726,13 @@ import {
|
|
|
719
726
|
resolveMemoriesByIdsForSearch2,
|
|
720
727
|
unifiedSearch2,
|
|
721
728
|
formatSearchResults2
|
|
722
|
-
} from "./index-
|
|
729
|
+
} from "./index-7skgrbsg.js";
|
|
723
730
|
import {
|
|
724
731
|
scheduleReconciliation,
|
|
725
732
|
scheduleIncrementalIndex,
|
|
726
733
|
getMessageIndexQueueHeapStats,
|
|
727
734
|
clearSessionTracking
|
|
728
|
-
} from "./index-
|
|
735
|
+
} from "./index-47hst5me.js";
|
|
729
736
|
import {
|
|
730
737
|
resolveModelCacheTtl,
|
|
731
738
|
resolveContextWindowGeometry,
|
|
@@ -824,7 +831,7 @@ import {
|
|
|
824
831
|
abortSessionFailClosed2,
|
|
825
832
|
evaluateEmergencyFailClosed2,
|
|
826
833
|
runPostTransformPhase2
|
|
827
|
-
} from "./index-
|
|
834
|
+
} from "./index-3tmbvn0z.js";
|
|
828
835
|
import {
|
|
829
836
|
flushIgnoredMessages2,
|
|
830
837
|
clearIgnoredMessages2,
|
|
@@ -834,7 +841,7 @@ import {
|
|
|
834
841
|
import {
|
|
835
842
|
setRecompStarting2,
|
|
836
843
|
setRecompTerminal2
|
|
837
|
-
} from "./index-
|
|
844
|
+
} from "./index-ewta5h87.js";
|
|
838
845
|
import {
|
|
839
846
|
ANNOUNCEMENT_VERSION2,
|
|
840
847
|
ANNOUNCEMENT_FEATURES2,
|
|
@@ -849,13 +856,14 @@ import {
|
|
|
849
856
|
renderMessageByOrdinal2,
|
|
850
857
|
renderVerboseRangeForTool2,
|
|
851
858
|
renderItemByTag2
|
|
852
|
-
} from "./index-
|
|
859
|
+
} from "./index-yzzxb5e1.js";
|
|
853
860
|
import {
|
|
854
861
|
readV2ArchiveOffThread2
|
|
855
|
-
} from "./index-
|
|
862
|
+
} from "./index-7dzaamqg.js";
|
|
856
863
|
import {
|
|
864
|
+
unresolvedLiveTailRefusal2,
|
|
857
865
|
renderSearchArchiveOffThread2
|
|
858
|
-
} from "./index-
|
|
866
|
+
} from "./index-wqwjawer.js";
|
|
859
867
|
import {
|
|
860
868
|
takeCoveredInstructionRows,
|
|
861
869
|
cloneKeepingCoveredInstructionMarks
|
|
@@ -1154,6 +1162,7 @@ function buildDreamTaskPrompt(task, args) {
|
|
|
1154
1162
|
import { randomUUID } from "node:crypto";
|
|
1155
1163
|
import { existsSync } from "node:fs";
|
|
1156
1164
|
var LEASE_TTL_MS = 10 * 60 * 1000;
|
|
1165
|
+
var DEAD_DIRECTORY_RECHECK_MS = 24 * 60 * 60 * 1000;
|
|
1157
1166
|
var SESSION_PAGE_SIZE = 100;
|
|
1158
1167
|
var SESSION_QUERY_CHUNK_SIZE = 250;
|
|
1159
1168
|
var YIELD_EVERY_PROCESSED_SESSIONS = 25;
|
|
@@ -1197,13 +1206,27 @@ function withImmediateTransaction(db, fn) {
|
|
|
1197
1206
|
function defaultYieldFn() {
|
|
1198
1207
|
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
1199
1208
|
}
|
|
1209
|
+
function readBackfillLease(db, harness) {
|
|
1210
|
+
return db.prepare(`SELECT status, lease_expires_at
|
|
1211
|
+
FROM session_project_backfill_state
|
|
1212
|
+
WHERE harness = ?`).get(harness);
|
|
1213
|
+
}
|
|
1214
|
+
function isCompletedAndNotDue(lease, now) {
|
|
1215
|
+
return lease?.status === "completed" && (lease.lease_expires_at === null || lease.lease_expires_at > now);
|
|
1216
|
+
}
|
|
1200
1217
|
function acquireBackfillLease(db, harness, holderId, now) {
|
|
1218
|
+
try {
|
|
1219
|
+
if (isCompletedAndNotDue(readBackfillLease(db, harness), now))
|
|
1220
|
+
return "already_completed";
|
|
1221
|
+
} catch (error) {
|
|
1222
|
+
if (!(error instanceof Error) || error.message !== "no such table: session_project_backfill_state") {
|
|
1223
|
+
throw error;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1201
1226
|
ensureBackfillStateTable(db);
|
|
1202
1227
|
return withImmediateTransaction(db, () => {
|
|
1203
|
-
const current = db
|
|
1204
|
-
|
|
1205
|
-
WHERE harness = ?`).get(harness);
|
|
1206
|
-
if (current?.status === "completed")
|
|
1228
|
+
const current = readBackfillLease(db, harness);
|
|
1229
|
+
if (isCompletedAndNotDue(current, now))
|
|
1207
1230
|
return "already_completed";
|
|
1208
1231
|
if (current?.status === "running" && current.lease_expires_at !== null && current.lease_expires_at > now) {
|
|
1209
1232
|
return "blocked_by_lease";
|
|
@@ -1232,11 +1255,11 @@ function renewBackfillLease(db, harness, holderId, now) {
|
|
|
1232
1255
|
SET lease_expires_at = ?
|
|
1233
1256
|
WHERE harness = ? AND status = 'running' AND holder_id = ?`).run(now + LEASE_TTL_MS, harness, holderId).changes === 1;
|
|
1234
1257
|
}
|
|
1235
|
-
function markBackfillCompleted(db, harness, holderId, now) {
|
|
1258
|
+
function markBackfillCompleted(db, harness, holderId, now, recheckAt) {
|
|
1236
1259
|
ensureBackfillStateTable(db);
|
|
1237
1260
|
return db.prepare(`UPDATE session_project_backfill_state
|
|
1238
|
-
SET status = 'completed', lease_expires_at =
|
|
1239
|
-
WHERE harness = ? AND status = 'running' AND holder_id = ?`).run(now, harness, holderId).changes === 1;
|
|
1261
|
+
SET status = 'completed', lease_expires_at = ?, completed_at = ?
|
|
1262
|
+
WHERE harness = ? AND status = 'running' AND holder_id = ?`).run(recheckAt, now, harness, holderId).changes === 1;
|
|
1240
1263
|
}
|
|
1241
1264
|
function markBackfillRetryPending(db, harness, holderId, now) {
|
|
1242
1265
|
ensureBackfillStateTable(db);
|
|
@@ -1279,9 +1302,10 @@ function createPageReader(source) {
|
|
|
1279
1302
|
if (typeof source === "function") {
|
|
1280
1303
|
return async (afterSessionId, limit) => source(afterSessionId, limit);
|
|
1281
1304
|
}
|
|
1282
|
-
|
|
1305
|
+
let sessions;
|
|
1283
1306
|
let offset = 0;
|
|
1284
1307
|
return async (_afterSessionId, limit) => {
|
|
1308
|
+
sessions ??= dedupeSessions(source);
|
|
1285
1309
|
const page = sessions.slice(offset, offset + limit);
|
|
1286
1310
|
offset += page.length;
|
|
1287
1311
|
return page;
|
|
@@ -1297,7 +1321,6 @@ async function runSessionProjectBackfillPass(db, source, options = {}) {
|
|
|
1297
1321
|
const resolveIdentity = options.resolveIdentity ?? ((directory) => resolveProjectIdentityForSession(directory, options.allowHomeProject));
|
|
1298
1322
|
const yieldFn = options.yieldFn ?? defaultYieldFn;
|
|
1299
1323
|
const holderId = options.holderId ?? randomUUID();
|
|
1300
|
-
const readPage = createPageReader(source);
|
|
1301
1324
|
const result = {
|
|
1302
1325
|
status: "completed",
|
|
1303
1326
|
totalSessions: 0,
|
|
@@ -1308,13 +1331,15 @@ async function runSessionProjectBackfillPass(db, source, options = {}) {
|
|
|
1308
1331
|
skippedEmptyDirectories: 0,
|
|
1309
1332
|
durationMs: 0
|
|
1310
1333
|
};
|
|
1311
|
-
const
|
|
1334
|
+
const baseLeaseKey = options.leaseKey ?? harness;
|
|
1335
|
+
const leaseKey = options.allowHomeProject ? `${baseLeaseKey}:allow-home-project` : baseLeaseKey;
|
|
1312
1336
|
const leaseStatus = acquireBackfillLease(db, leaseKey, holderId, now());
|
|
1313
1337
|
if (leaseStatus !== "acquired") {
|
|
1314
1338
|
result.status = leaseStatus;
|
|
1315
1339
|
result.durationMs = performance.now() - startedAt;
|
|
1316
1340
|
return result;
|
|
1317
1341
|
}
|
|
1342
|
+
const readPage = createPageReader(source);
|
|
1318
1343
|
const finishWithLostLease = () => {
|
|
1319
1344
|
result.status = "lost_lease";
|
|
1320
1345
|
result.durationMs = performance.now() - startedAt;
|
|
@@ -1406,13 +1431,9 @@ async function runSessionProjectBackfillPass(db, source, options = {}) {
|
|
|
1406
1431
|
if (sourcePage.length < SESSION_PAGE_SIZE)
|
|
1407
1432
|
break;
|
|
1408
1433
|
}
|
|
1409
|
-
const
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
return finishWithLostLease();
|
|
1413
|
-
}
|
|
1414
|
-
result.status = "retry_pending";
|
|
1415
|
-
} else if (!markBackfillCompleted(db, leaseKey, holderId, now())) {
|
|
1434
|
+
const completedAt = now();
|
|
1435
|
+
const recheckAt = result.skippedDeadDirectories > 0 ? completedAt + DEAD_DIRECTORY_RECHECK_MS : null;
|
|
1436
|
+
if (!markBackfillCompleted(db, leaseKey, holderId, completedAt, recheckAt)) {
|
|
1416
1437
|
return finishWithLostLease();
|
|
1417
1438
|
}
|
|
1418
1439
|
result.durationMs = performance.now() - startedAt;
|
|
@@ -4204,15 +4225,39 @@ function hasCurrentDocsProposal(projectDir) {
|
|
|
4204
4225
|
const hashes = docsBaseHashes(projectDir);
|
|
4205
4226
|
return listPendingDocsProposals(projectDir).some((path) => Object.entries(hashes).every(([name, value]) => readFileSync(path, "utf8").includes(`Base SHA-256 ${name}: ${value}`)));
|
|
4206
4227
|
}
|
|
4207
|
-
function git(projectDir, args) {
|
|
4228
|
+
function git(projectDir, args, options) {
|
|
4208
4229
|
return execFileSync("git", args, {
|
|
4209
4230
|
windowsHide: true,
|
|
4210
4231
|
cwd: projectDir,
|
|
4211
4232
|
encoding: "utf8",
|
|
4212
4233
|
timeout: 1e4,
|
|
4213
|
-
maxBuffer: 2000000
|
|
4234
|
+
maxBuffer: 2000000,
|
|
4235
|
+
...options
|
|
4214
4236
|
}).trim();
|
|
4215
4237
|
}
|
|
4238
|
+
function gitExitStatus(error) {
|
|
4239
|
+
if (!error || typeof error !== "object")
|
|
4240
|
+
return;
|
|
4241
|
+
const { status, code, signal } = error;
|
|
4242
|
+
return typeof status === "number" && !code && !signal ? status : undefined;
|
|
4243
|
+
}
|
|
4244
|
+
function isCheckpointCommit(projectDir, anchor) {
|
|
4245
|
+
if (typeof anchor !== "string" || !/^[a-f0-9]{40}$/.test(anchor))
|
|
4246
|
+
return false;
|
|
4247
|
+
try {
|
|
4248
|
+
return git(projectDir, ["cat-file", "-t", anchor], { stdio: "pipe" }) === "commit";
|
|
4249
|
+
} catch (error) {
|
|
4250
|
+
if (gitExitStatus(error) === undefined)
|
|
4251
|
+
throw error;
|
|
4252
|
+
try {
|
|
4253
|
+
git(projectDir, ["cat-file", "-e", anchor], { stdio: "pipe" });
|
|
4254
|
+
} catch (existenceError) {
|
|
4255
|
+
if (gitExitStatus(existenceError) === 1)
|
|
4256
|
+
return false;
|
|
4257
|
+
}
|
|
4258
|
+
throw error;
|
|
4259
|
+
}
|
|
4260
|
+
}
|
|
4216
4261
|
function gitOutputPrefix(projectDir, args) {
|
|
4217
4262
|
try {
|
|
4218
4263
|
return git(projectDir, args);
|
|
@@ -4233,14 +4278,16 @@ function docsChangeSet(projectDir, storedAnchor) {
|
|
|
4233
4278
|
if (realpathSync(git(projectDir, ["rev-parse", "--show-toplevel"])) !== realpathSync(projectDir))
|
|
4234
4279
|
return null;
|
|
4235
4280
|
const head = git(projectDir, ["rev-parse", "HEAD"]);
|
|
4236
|
-
const recorded = Boolean(storedAnchor);
|
|
4237
4281
|
let anchor = storedAnchor;
|
|
4238
|
-
|
|
4239
|
-
|
|
4282
|
+
const recovered = anchor != null && !isCheckpointCommit(projectDir, anchor);
|
|
4283
|
+
if (recovered)
|
|
4284
|
+
anchor = undefined;
|
|
4285
|
+
const recorded = Boolean(anchor);
|
|
4240
4286
|
if (!anchor)
|
|
4241
4287
|
anchor = git(projectDir, ["log", "-1", "--format=%H", "--", ...FILES]);
|
|
4288
|
+
const emptyRecovery = recovered ? { head, text: "", unchanged: false, relevant: false, recoveredAnchor: anchor || null } : null;
|
|
4242
4289
|
if (!anchor)
|
|
4243
|
-
return
|
|
4290
|
+
return emptyRecovery;
|
|
4244
4291
|
if (recorded && anchor === head)
|
|
4245
4292
|
return { head, text: "", unchanged: true, relevant: false };
|
|
4246
4293
|
if (recorded) {
|
|
@@ -4342,7 +4389,7 @@ ${stat}`
|
|
|
4342
4389
|
...excluded.map((path) => `:(exclude)${path}`)
|
|
4343
4390
|
]);
|
|
4344
4391
|
if (!raw)
|
|
4345
|
-
return
|
|
4392
|
+
return emptyRecovery;
|
|
4346
4393
|
const commits = raw.split(/^commit /m);
|
|
4347
4394
|
const text = raw.slice(0, 24000);
|
|
4348
4395
|
return {
|
|
@@ -4351,7 +4398,8 @@ ${stat}`
|
|
|
4351
4398
|
relevant: true,
|
|
4352
4399
|
text: `${text}${raw.length > text.length ? `
|
|
4353
4400
|
[cut ${raw.length - text.length} bytes]` : ""}${commits.length > 201 ? `
|
|
4354
|
-
[cut commits beyond newest 200]` : ""}
|
|
4401
|
+
[cut commits beyond newest 200]` : ""}`,
|
|
4402
|
+
...recovered ? { recoveredAnchor: anchor } : {}
|
|
4355
4403
|
};
|
|
4356
4404
|
} catch (error) {
|
|
4357
4405
|
if (storedAnchor)
|
|
@@ -11227,6 +11275,9 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
11227
11275
|
anchor = JSON.parse(storedAnchor ?? "null")?.head;
|
|
11228
11276
|
} catch {}
|
|
11229
11277
|
const changes = task === "maintain-docs" ? docsChangeSet(docsDir, anchor) : null;
|
|
11278
|
+
if (changes?.recoveredAnchor !== undefined) {
|
|
11279
|
+
log2("[dreamer] maintain-docs: stored checkpoint was no longer a commit; restarted from the docs files' last commit, if any");
|
|
11280
|
+
}
|
|
11230
11281
|
const existingDocs = task === "maintain-docs" ? {
|
|
11231
11282
|
architecture: existsSync5(`${docsDir}/ARCHITECTURE.md`),
|
|
11232
11283
|
structure: existsSync5(`${docsDir}/STRUCTURE.md`)
|
|
@@ -11296,7 +11347,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
11296
11347
|
return { status: "completed", detail: reason };
|
|
11297
11348
|
}
|
|
11298
11349
|
if (task === "maintain-docs" && changes && (changes.unchanged || !changes.relevant)) {
|
|
11299
|
-
const reason = changes.unchanged ? "no commits since last run" : "diff does not describe a documented area";
|
|
11350
|
+
const reason = changes.unchanged ? "no commits since last run" : changes.recoveredAnchor !== undefined ? "no relevant commits or no git repository" : "diff does not describe a documented area";
|
|
11300
11351
|
helpers.recordRun("completed", null, { progress: reason });
|
|
11301
11352
|
return {
|
|
11302
11353
|
status: "completed",
|
|
@@ -11307,7 +11358,15 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
11307
11358
|
if (task === "maintain-docs" && hasCurrentDocsProposal(docsDir)) {
|
|
11308
11359
|
const reason = "pending proposal matches current docs";
|
|
11309
11360
|
helpers.recordRun("completed", null, { progress: reason });
|
|
11310
|
-
return {
|
|
11361
|
+
return {
|
|
11362
|
+
status: "completed",
|
|
11363
|
+
detail: reason,
|
|
11364
|
+
...changes?.recoveredAnchor ? {
|
|
11365
|
+
schedulePatch: {
|
|
11366
|
+
taskStateJson: JSON.stringify({ head: changes.recoveredAnchor })
|
|
11367
|
+
}
|
|
11368
|
+
} : {}
|
|
11369
|
+
};
|
|
11311
11370
|
}
|
|
11312
11371
|
const curateChunks = curateMemories ? chunkCurateMemories(curateMemories, Math.max(4000, Math.floor(resolveRetrospectiveUsableInputTokens(config, deps) * 2))) : [];
|
|
11313
11372
|
const batches = task === "curate" ? curateChunks : [{ memories: [], crossChunkCandidates: [] }];
|
|
@@ -13919,7 +13978,11 @@ function getUnsummarizedTailInfo(db, sessionId, triggerBudget, usage, executeThr
|
|
|
13919
13978
|
}
|
|
13920
13979
|
const rawEligibility = getRawHistoryEligibility(db, sessionId);
|
|
13921
13980
|
if (!rawEligibility.hasRawBeyondLastCompartment) {
|
|
13922
|
-
return {
|
|
13981
|
+
return {
|
|
13982
|
+
...TAIL_INFO_DEFAULTS,
|
|
13983
|
+
nextStartOrdinal: rawEligibility.offset,
|
|
13984
|
+
noRawBeyondSummary: true
|
|
13985
|
+
};
|
|
13923
13986
|
}
|
|
13924
13987
|
const boundary = resolveOpenCodeProtectedTailBoundary({
|
|
13925
13988
|
db,
|
|
@@ -13979,6 +14042,12 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
|
|
|
13979
14042
|
executeThresholdPercentage
|
|
13980
14043
|
}))
|
|
13981
14044
|
return { shouldFire: false };
|
|
14045
|
+
let historyGapMark = readHistoryGapMark(db, sessionId);
|
|
14046
|
+
const gapCoverageEnd = historyGapMark ? getLastCompartmentEndMessage(db, sessionId) : -1;
|
|
14047
|
+
if (historyGapMark && gapCoverageEnd > historyGapMark.endOrdinal) {
|
|
14048
|
+
clearHistoryGapMark(db, sessionId, historyGapMark.id);
|
|
14049
|
+
historyGapMark = null;
|
|
14050
|
+
}
|
|
13982
14051
|
const lazyInMemoryTail = typeof inMemoryTail === "function" ? inMemoryTail : undefined;
|
|
13983
14052
|
let resolvedInMemoryTail = typeof inMemoryTail === "function" ? undefined : inMemoryTail;
|
|
13984
14053
|
if (resolvedInMemoryTail) {
|
|
@@ -13992,6 +14061,7 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
|
|
|
13992
14061
|
}
|
|
13993
14062
|
const taggerFloor = taggerFloorOverride !== undefined && taggerFloorOverride > 0 ? taggerFloorOverride : resolvedInMemoryTail ? deriveTagLoadFloor2(db, sessionId, resolvedInMemoryTail.messages.map((m) => m.id)) : 0;
|
|
13994
14063
|
const proactiveFloorForGate = getProactiveCompartmentTriggerPercentage(executeThresholdPercentage);
|
|
14064
|
+
let cheapSkip;
|
|
13995
14065
|
if (usage.percentage < proactiveFloorForGate) {
|
|
13996
14066
|
try {
|
|
13997
14067
|
const boundFloor = resolvedInMemoryTail || lazyInMemoryTail ? taggerFloor : 0;
|
|
@@ -14001,15 +14071,53 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
|
|
|
14001
14071
|
const seed = sessionDecisionCalibration(db, sessionId);
|
|
14002
14072
|
const eligibleUpperBound = Math.ceil((persistedBound + untaggedUpperBound) * Math.max(1, seed.proseRatio, seed.toolsRatio, seed.systemRatio));
|
|
14003
14073
|
if (eligibleUpperBound < triggerBudget) {
|
|
14004
|
-
|
|
14005
|
-
sessionLog2(sessionId, `compartment trigger: cheap-skip at ${usage.percentage.toFixed(1)}% (below proactive floor ${proactiveFloorForGate}%) — live-tail upper bound ${eligibleUpperBound}${memorySuffix} < triggerBudget ${triggerBudget}; no size trigger possible, skipped full raw read`);
|
|
14006
|
-
return { shouldFire: false };
|
|
14074
|
+
cheapSkip = { eligibleUpperBound, persistedBound, untaggedUpperBound };
|
|
14007
14075
|
}
|
|
14008
14076
|
}
|
|
14009
14077
|
} catch (error) {
|
|
14010
14078
|
sessionLog2(sessionId, `compartment trigger: cheap-gate skipped (falling through to full read): ${error instanceof Error ? error.message : String(error)}`);
|
|
14011
14079
|
}
|
|
14012
14080
|
}
|
|
14081
|
+
const forceMaterializationPercentage = escalationBands(executeThresholdPercentage).forceMaterializationPercentage;
|
|
14082
|
+
let historyGapAdmission;
|
|
14083
|
+
if (historyGapMark && usage.percentage < forceMaterializationPercentage) {
|
|
14084
|
+
const now = Date.now();
|
|
14085
|
+
const checkedAt = historyGapMark.checkedAt;
|
|
14086
|
+
if (checkedAt === undefined || checkedAt > now || now - checkedAt >= EMERGENCY_DRAIN_FAILURE_BACKOFF_MS) {
|
|
14087
|
+
const { failureCount, lastFailureAt } = getHistorianFailureState(db, sessionId);
|
|
14088
|
+
const failedAt = lastFailureAt ?? 0;
|
|
14089
|
+
const admittedRuns = historyGapMark.admittedRuns ?? 0;
|
|
14090
|
+
const previousRunFailed = failureCount > (historyGapMark.failureCountAtAdmission ?? failureCount);
|
|
14091
|
+
if (previousRunFailed && admittedRuns >= 2) {
|
|
14092
|
+
clearHistoryGapMark(db, sessionId, historyGapMark.id);
|
|
14093
|
+
historyGapMark = null;
|
|
14094
|
+
} else if (failedAt <= 0 || failedAt > now || now - failedAt >= EMERGENCY_DRAIN_FAILURE_BACKOFF_MS) {
|
|
14095
|
+
const count = resolvedInMemoryTail?.absoluteMessageCount ?? getRawSessionMessageOrdinalCount2(sessionId);
|
|
14096
|
+
if (count <= Math.max(0, gapCoverageEnd)) {
|
|
14097
|
+
clearHistoryGapMark(db, sessionId, historyGapMark.id);
|
|
14098
|
+
} else {
|
|
14099
|
+
const inspectedCount = historyGapMark.inspectedCount ?? 0;
|
|
14100
|
+
const canAdmit = admittedRuns < 2 && (admittedRuns === 0 || previousRunFailed);
|
|
14101
|
+
const shouldInspect = canAdmit && count > inspectedCount;
|
|
14102
|
+
const nextFrontier = shouldInspect || count < inspectedCount ? count : inspectedCount;
|
|
14103
|
+
if (claimHistoryGapCheck(db, sessionId, historyGapMark, now, nextFrontier) && shouldInspect) {
|
|
14104
|
+
historyGapAdmission = {
|
|
14105
|
+
id: historyGapMark.id,
|
|
14106
|
+
checkedAt: now,
|
|
14107
|
+
admittedRuns: admittedRuns + 1,
|
|
14108
|
+
failureCount
|
|
14109
|
+
};
|
|
14110
|
+
}
|
|
14111
|
+
}
|
|
14112
|
+
}
|
|
14113
|
+
}
|
|
14114
|
+
}
|
|
14115
|
+
if (cheapSkip && !historyGapAdmission) {
|
|
14116
|
+
const { eligibleUpperBound, persistedBound, untaggedUpperBound } = cheapSkip;
|
|
14117
|
+
const memorySuffix = resolvedInMemoryTail ? ` (persisted=${persistedBound}, untagged-memory≤${untaggedUpperBound})` : "";
|
|
14118
|
+
sessionLog2(sessionId, `compartment trigger: cheap-skip at ${usage.percentage.toFixed(1)}% (below proactive floor ${proactiveFloorForGate}%) — live-tail upper bound ${eligibleUpperBound}${memorySuffix} < triggerBudget ${triggerBudget}; no size trigger possible, skipped full raw read`);
|
|
14119
|
+
return { shouldFire: false };
|
|
14120
|
+
}
|
|
14013
14121
|
if (lazyInMemoryTail) {
|
|
14014
14122
|
try {
|
|
14015
14123
|
const policyVersion = loadProtectedTailMeta(db, sessionId).protectedTailPolicyVersion;
|
|
@@ -14036,6 +14144,8 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
|
|
|
14036
14144
|
}
|
|
14037
14145
|
}
|
|
14038
14146
|
if (!tailInfo.hasNewRawHistory) {
|
|
14147
|
+
if (historyGapMark && tailInfo.noRawBeyondSummary)
|
|
14148
|
+
clearHistoryGapMark(db, sessionId, historyGapMark.id);
|
|
14039
14149
|
try {
|
|
14040
14150
|
const lastCompartmentEnd = getLastCompartmentEndMessage(db, sessionId);
|
|
14041
14151
|
sessionLog2(sessionId, `compartment trigger: skipped — no new raw history (usage=${usage.percentage.toFixed(1)}% nextStartOrdinal=${tailInfo.nextStartOrdinal} lastCompartmentEnd=${lastCompartmentEnd})`);
|
|
@@ -14055,13 +14165,19 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
|
|
|
14055
14165
|
sessionLog2(sessionId, "compartment trigger: waiting for new history after no forward progress");
|
|
14056
14166
|
return { shouldFire: false };
|
|
14057
14167
|
}
|
|
14168
|
+
if (historyGapAdmission && tailInfo.boundarySnapshot && hasRunnableCompartmentWindow(tailInfo.boundarySnapshot) && recordHistoryGapAdmission(db, sessionId, historyGapAdmission)) {
|
|
14169
|
+
return {
|
|
14170
|
+
shouldFire: true,
|
|
14171
|
+
reason: "history_gap",
|
|
14172
|
+
boundarySnapshot: tailInfo.boundarySnapshot
|
|
14173
|
+
};
|
|
14174
|
+
}
|
|
14058
14175
|
const canClearReasoning = reasoningProjection?.canClearReasoning ?? modelAcceptsEmptyContent(reasoningProjection?.providerID);
|
|
14059
14176
|
const projectedPostDropPercentage = estimateProjectedPostDropPercentage(db, sessionId, usage, preloadedActiveTags ?? getActiveTagsBySession2(db, sessionId), keepReasoningTokens, sessionMeta.clearedReasoningThroughTag, canClearReasoning, reasoningProjection?.budgetCutoff, eligiblePendingDropTagIds);
|
|
14060
14177
|
const relativePostDropTarget = executeThresholdPercentage * POST_DROP_TARGET_RATIO;
|
|
14061
14178
|
const ridePermitted = reclaimRide !== undefined && (reclaimRide.permission ? reclaimRidePermitted(reclaimRide, reclaimRide.permission) : hasReclaimRide(reclaimRide));
|
|
14062
14179
|
const rideLabel = reclaimRide ? reclaimRideLabel(reclaimRide) : "ride=none";
|
|
14063
14180
|
const dropsCanLand = ridePermitted;
|
|
14064
|
-
const forceMaterializationPercentage = escalationBands(executeThresholdPercentage).forceMaterializationPercentage;
|
|
14065
14181
|
if (usage.percentage >= forceMaterializationPercentage) {
|
|
14066
14182
|
if (dropsCanLand && projectedPostDropPercentage !== null && projectedPostDropPercentage <= relativePostDropTarget) {
|
|
14067
14183
|
sessionLog2(sessionId, `historian redundancy skip: summarizer not needed this pass — force band is ${forceMaterializationPercentage}%; queued/automatic drops are projected to reclaim to ${projectedPostDropPercentage.toFixed(1)}% (target ${relativePostDropTarget.toFixed(1)}%) on this pass (${rideLabel})`);
|
|
@@ -16344,7 +16460,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16344
16460
|
const db = readDatabase();
|
|
16345
16461
|
if (!db)
|
|
16346
16462
|
return { ok: false, error: "db unavailable" };
|
|
16347
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
16463
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-cn4r2gz6.js"));
|
|
16348
16464
|
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-0779tyd9.js"));
|
|
16349
16465
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
16350
16466
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
@@ -16429,7 +16545,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16429
16545
|
const db = readDatabase();
|
|
16430
16546
|
if (!db)
|
|
16431
16547
|
return { ok: false, error: "db unavailable" };
|
|
16432
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16548
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-kt81d6et.js"));
|
|
16433
16549
|
const model = await args.readSelectedSessionModel?.(sessionId) ?? liveSessionState.liveModelBySession.get(sessionId);
|
|
16434
16550
|
const window = resolveOpenCodeWrapupWindow(db, sessionId, model);
|
|
16435
16551
|
if (!window)
|
|
@@ -16890,14 +17006,12 @@ function writeTransformDecisionRow(dbPath, row) {
|
|
|
16890
17006
|
try {
|
|
16891
17007
|
db.exec("PRAGMA busy_timeout=0");
|
|
16892
17008
|
configureContextDatabasePragmas2(db);
|
|
16893
|
-
writeTransformDecisionRowOnDatabase(db, row
|
|
17009
|
+
writeTransformDecisionRowOnDatabase(db, row);
|
|
16894
17010
|
} finally {
|
|
16895
17011
|
closeQuietly(db);
|
|
16896
17012
|
}
|
|
16897
17013
|
}
|
|
16898
|
-
function writeTransformDecisionRowOnDatabase(db, row
|
|
16899
|
-
if (configureBusyTimeout)
|
|
16900
|
-
db.exec("PRAGMA busy_timeout=0");
|
|
17014
|
+
function writeTransformDecisionRowOnDatabase(db, row) {
|
|
16901
17015
|
const systemHashPrev = row.materialized ? row.systemHashPrev : null;
|
|
16902
17016
|
const systemHashNew = row.materialized ? row.systemHashNew : null;
|
|
16903
17017
|
const m0ModelKeyPrev = row.materialized ? row.m0ModelKeyPrev : null;
|
|
@@ -28163,10 +28277,11 @@ function createCtxExpandTool(deps) {
|
|
|
28163
28277
|
}
|
|
28164
28278
|
const { start, end, verbose } = mode;
|
|
28165
28279
|
const lastCompartmentEnd = getLastCompartmentEndMessage(deps.db, sessionId);
|
|
28166
|
-
|
|
28167
|
-
|
|
28168
|
-
|
|
28169
|
-
const
|
|
28280
|
+
const refusal = unresolvedLiveTailRefusal2(deps.db, sessionId, start, end, lastCompartmentEnd);
|
|
28281
|
+
if (refusal)
|
|
28282
|
+
return refusal;
|
|
28283
|
+
const liveTailAfter = lastCompartmentEnd >= 0 && start > lastCompartmentEnd ? lastCompartmentEnd : undefined;
|
|
28284
|
+
const effectiveEnd = lastCompartmentEnd >= start ? Math.min(end, lastCompartmentEnd) : end;
|
|
28170
28285
|
if (verbose && source) {
|
|
28171
28286
|
if (!path)
|
|
28172
28287
|
throw new Error("Search archive worker unavailable: private archive has no off-thread source");
|
|
@@ -28175,13 +28290,14 @@ function createCtxExpandTool(deps) {
|
|
|
28175
28290
|
start,
|
|
28176
28291
|
end: effectiveEnd,
|
|
28177
28292
|
tokenBudget: CTX_EXPAND_TOKEN_BUDGET,
|
|
28178
|
-
expandTools: deps.expandTools
|
|
28293
|
+
expandTools: deps.expandTools,
|
|
28294
|
+
liveTailAfter
|
|
28179
28295
|
});
|
|
28180
28296
|
if (text === null)
|
|
28181
28297
|
throw new Error("Search archive worker unavailable: unexpected verbose reply");
|
|
28182
28298
|
return text;
|
|
28183
28299
|
}
|
|
28184
|
-
const archived = await renderSearchArchiveOffThread2(deps.db, sessionId, start, effectiveEnd, CTX_EXPAND_TOKEN_BUDGET);
|
|
28300
|
+
const archived = await renderSearchArchiveOffThread2(deps.db, sessionId, start, effectiveEnd, CTX_EXPAND_TOKEN_BUDGET, false, liveTailAfter);
|
|
28185
28301
|
if (archived)
|
|
28186
28302
|
return archived;
|
|
28187
28303
|
if (verbose) {
|
|
@@ -30003,8 +30119,7 @@ function createCtxSearchTool(deps) {
|
|
|
30003
30119
|
return `Error: ${error.message}`;
|
|
30004
30120
|
throw error;
|
|
30005
30121
|
}
|
|
30006
|
-
const
|
|
30007
|
-
const messageOrdinalCutoff = lastCompartmentEnd >= 0 ? lastCompartmentEnd : 0;
|
|
30122
|
+
const messageOrdinalCutoff = Math.max(0, getLastCompartmentEndMessage(deps.db, toolContext.sessionID));
|
|
30008
30123
|
const visibleMemoryIds = getVisibleMemoryIds(deps.db, toolContext.sessionID);
|
|
30009
30124
|
const diagnostics = createUnifiedSearchDiagnostics2();
|
|
30010
30125
|
const projectPath = deps.resolveProjectPath(toolContext.directory);
|
|
@@ -30040,6 +30155,7 @@ function createCtxSearchTool(deps) {
|
|
|
30040
30155
|
isEmbeddingRuntimeEnabled: () => embeddingEnabled === true,
|
|
30041
30156
|
readMessages: deps.readMessages,
|
|
30042
30157
|
maxMessageOrdinal: messageOrdinalCutoff,
|
|
30158
|
+
includeDroppedTailMessages: true,
|
|
30043
30159
|
gitCommitsEnabled,
|
|
30044
30160
|
sources: normalizeSources(args.sources),
|
|
30045
30161
|
visibleMemoryIds,
|