@remnic/core 10.0.136 → 10.0.138
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/access-admin-ops-surface.js +152 -152
- package/dist/access-cli.js +152 -152
- package/dist/access-extraction-force-flush-preempt.d.ts +11 -0
- package/dist/access-extraction-force-flush-preempt.d.ts.map +1 -0
- package/dist/access-extraction-force-flush-preempt.js +576 -0
- package/dist/access-extraction-force-flush.js +152 -152
- package/dist/access-http-briefing.js +152 -152
- package/dist/access-http-query.js +152 -152
- package/dist/access-http.js +152 -152
- package/dist/access-identity-continuity-surface.js +152 -152
- package/dist/access-lcm-surface.js +152 -152
- package/dist/access-mcp.js +152 -152
- package/dist/access-observe-write-category.js +10 -10
- package/dist/access-observe-write-surface.d.ts.map +1 -1
- package/dist/access-observe-write-surface.js +152 -152
- package/dist/access-offline-manifest.js +15 -15
- package/dist/access-operations-batch.js +152 -152
- package/dist/access-operations.js +152 -152
- package/dist/access-recall-concurrency.js +152 -152
- package/dist/access-recall-diagnostics.js +8 -8
- package/dist/access-recall-response.js +152 -152
- package/dist/access-recall-surface.js +152 -152
- package/dist/access-schema.js +9 -9
- package/dist/access-service.js +152 -152
- package/dist/access-surface-catalog.js +4 -4
- package/dist/active-memory-bridge.js +7 -7
- package/dist/active-recall.js +31 -31
- package/dist/{auto-sync-BO5YZKM6.js → auto-sync-PSZJHHXB.js} +5 -5
- package/dist/briefing.js +21 -21
- package/dist/buffer-turn.d.ts +11 -0
- package/dist/buffer-turn.d.ts.map +1 -1
- package/dist/buffer.js +10 -10
- package/dist/calibration.js +3 -3
- package/dist/causal-consolidation.js +22 -22
- package/dist/{chunk-T4KY6UYF.js → chunk-274UY54Z.js} +2 -2
- package/dist/{chunk-3TVCG6ST.js → chunk-2DWTO7XP.js} +6 -6
- package/dist/{chunk-STKNZY7A.js → chunk-2NJ74RQU.js} +2 -2
- package/dist/{chunk-4H7TUVWQ.js → chunk-2VS3DAXE.js} +3 -3
- package/dist/{chunk-MEQPK3KG.js → chunk-3BRHOVRU.js} +3 -3
- package/dist/{chunk-HLWXCDUQ.js → chunk-3DAWHP5K.js} +5 -5
- package/dist/{chunk-KVCFAWBZ.js → chunk-3PZDG5ZH.js} +2 -2
- package/dist/{chunk-5RZ4DAP6.js → chunk-5IGWEYNV.js} +3 -3
- package/dist/{chunk-U5I2G4VU.js → chunk-5WZT6WQW.js} +4 -4
- package/dist/{chunk-TL6QIZT7.js → chunk-66MBMBSH.js} +2 -2
- package/dist/{chunk-KLUCX6OH.js → chunk-77SYM565.js} +14 -14
- package/dist/{chunk-ZGGFGUUF.js → chunk-A33VT7GC.js} +2 -2
- package/dist/{chunk-5RCXMLI5.js → chunk-AV6R66KO.js} +3 -3
- package/dist/{chunk-BL545EH7.js → chunk-CFSCKCT5.js} +15 -14
- package/dist/chunk-CFSCKCT5.js.map +1 -0
- package/dist/{chunk-S3LWB6K3.js → chunk-CKG7T4AD.js} +2 -2
- package/dist/{chunk-YNTVQWLX.js → chunk-DI2QWY6J.js} +16 -16
- package/dist/{chunk-3RW5ZCYO.js → chunk-DIBOWE53.js} +2 -2
- package/dist/{chunk-QRZNVNNS.js → chunk-EEY326VH.js} +3 -3
- package/dist/{chunk-OIGJZHDU.js → chunk-EUL3S3LE.js} +7 -7
- package/dist/{chunk-YNDLCWXS.js → chunk-EZ25VE3G.js} +4 -4
- package/dist/{chunk-DUTLMAUC.js → chunk-F4DXTUHY.js} +2 -2
- package/dist/{chunk-DK2VBJ6Q.js → chunk-FAPJG3OG.js} +4 -4
- package/dist/{chunk-M2XR6B6V.js → chunk-FEUWI5QH.js} +2 -2
- package/dist/{chunk-VO3HCFSR.js → chunk-GAVFANAB.js} +2 -2
- package/dist/{chunk-SPHBQTWE.js → chunk-GOYLBPSW.js} +3 -3
- package/dist/{chunk-37T5ZO5P.js → chunk-HOSS72UP.js} +2 -2
- package/dist/{chunk-3TU6OBI7.js → chunk-I3UBDUHO.js} +2 -2
- package/dist/{chunk-HA6V3CLH.js → chunk-JCWI43TO.js} +2 -2
- package/dist/{chunk-6LNWA6IT.js → chunk-JEAMQL63.js} +13 -13
- package/dist/{chunk-XBNGH2FV.js → chunk-JG6AHBJW.js} +2 -2
- package/dist/{chunk-3F6COEHZ.js → chunk-JVNGFQJN.js} +1 -1
- package/dist/chunk-JVNGFQJN.js.map +1 -0
- package/dist/{chunk-PA5FI6A5.js → chunk-JY327EH4.js} +2 -2
- package/dist/{chunk-WYSCN5TA.js → chunk-K4DBE5MH.js} +9 -9
- package/dist/{chunk-KIICCGSV.js → chunk-KCLHHANX.js} +3 -3
- package/dist/{chunk-QOI4PNVG.js → chunk-KCVPKFDG.js} +2 -2
- package/dist/{chunk-EFMAYZOB.js → chunk-L6CMR5OI.js} +2 -2
- package/dist/{chunk-Y3TA66MZ.js → chunk-LEH4FVBJ.js} +20 -20
- package/dist/{chunk-AHA5VQGP.js → chunk-LEII44QG.js} +4 -4
- package/dist/chunk-LEO4MQ3S.js +140 -0
- package/dist/chunk-LEO4MQ3S.js.map +1 -0
- package/dist/{chunk-4VL2H5Q3.js → chunk-LL7WIK2Z.js} +2 -2
- package/dist/{chunk-GW23JXGJ.js → chunk-LT35JWKZ.js} +2 -2
- package/dist/{chunk-U5OVNYJX.js → chunk-MP6V4CLP.js} +9 -9
- package/dist/{chunk-NEXJ3OOZ.js → chunk-MXE42X3I.js} +6 -6
- package/dist/{chunk-LR6QP72R.js → chunk-N6JGLQV7.js} +2 -2
- package/dist/{chunk-J6U6KUMK.js → chunk-N7IJEGSE.js} +2 -2
- package/dist/{chunk-5ZS73P3U.js → chunk-NB2BKYUS.js} +2 -2
- package/dist/{chunk-KN44QS5F.js → chunk-NOZDET3Q.js} +6 -6
- package/dist/{chunk-C2KE5DMD.js → chunk-O6ZSWHVR.js} +4 -4
- package/dist/{chunk-C73N66PR.js → chunk-OBPOIZNR.js} +2 -2
- package/dist/{chunk-TSJQ7C2T.js → chunk-OFMK76LD.js} +16 -16
- package/dist/{chunk-LK3LXSJQ.js → chunk-OI3UMEW3.js} +5 -5
- package/dist/{chunk-6Z7BRM7C.js → chunk-OJJ73HLA.js} +3 -3
- package/dist/{chunk-CLVILSBR.js → chunk-OZNBZJ3S.js} +22 -22
- package/dist/{chunk-GUI7MLKC.js → chunk-PKPW7MXT.js} +4 -4
- package/dist/{chunk-SCQO7JOF.js → chunk-PKV3NNM2.js} +2 -2
- package/dist/{chunk-XCZQ7MID.js → chunk-PNT3SZRY.js} +21 -21
- package/dist/{chunk-IXX4SKF5.js → chunk-POB7N5UM.js} +2 -2
- package/dist/{chunk-2OIQHXN4.js → chunk-PQ5FYNY2.js} +2 -2
- package/dist/{chunk-JDY34KBL.js → chunk-QUMKDRCF.js} +4 -4
- package/dist/{chunk-CGEOIR4F.js → chunk-QZ5JZNXN.js} +475 -329
- package/dist/chunk-QZ5JZNXN.js.map +1 -0
- package/dist/{chunk-V6JECHY6.js → chunk-SBRUTD5O.js} +6 -6
- package/dist/{chunk-ZKHDDEPF.js → chunk-SRW4IKHM.js} +2 -2
- package/dist/{chunk-BTY6DUFW.js → chunk-SU63UQPL.js} +7 -7
- package/dist/{chunk-TVDJEUV5.js → chunk-SX4BR26Y.js} +2 -2
- package/dist/{chunk-OIG4ZFMB.js → chunk-SZK2DX5U.js} +5 -5
- package/dist/{chunk-5BE3FLKL.js → chunk-TAUHAP5J.js} +4 -4
- package/dist/{chunk-NS7U4ZYU.js → chunk-TSUSHXBW.js} +2 -2
- package/dist/{chunk-YMFPFXEX.js → chunk-TYOS62PM.js} +5 -5
- package/dist/{chunk-BFDXJHYG.js → chunk-U3GJUARA.js} +2 -2
- package/dist/{chunk-P3WRNWWM.js → chunk-UPE7TJWN.js} +2 -2
- package/dist/{chunk-OE35LFBF.js → chunk-VF3EVRUN.js} +3 -3
- package/dist/{chunk-VY3DHUL7.js → chunk-VRWQUUZ7.js} +8 -8
- package/dist/{chunk-FEWOSD33.js → chunk-VSZEV7HG.js} +6 -6
- package/dist/{chunk-K2VRKCPA.js → chunk-XBW7U7GM.js} +4 -4
- package/dist/{chunk-UA2NDTIU.js → chunk-YAVIBVCU.js} +4 -4
- package/dist/{chunk-HKQ3LH34.js → chunk-YDOLJQ55.js} +5 -5
- package/dist/{chunk-JGM3OWPQ.js → chunk-YMNFHNZH.js} +2 -2
- package/dist/{chunk-DJ7WVEWX.js → chunk-YVXM5QFL.js} +2 -2
- package/dist/{chunk-FMFCQRDM.js → chunk-ZANNIXXE.js} +3 -3
- package/dist/{chunk-OJXK5C6Z.js → chunk-ZG4GNPRE.js} +7 -7
- package/dist/{chunk-B3DR2JBZ.js → chunk-ZZYJNT2J.js} +4 -4
- package/dist/cli.js +152 -152
- package/dist/coding/export-okf-codegraph.js +20 -20
- package/dist/compounding/engine.js +22 -22
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +31 -31
- package/dist/connectors/codex-materialize-runner.js +21 -21
- package/dist/connectors/index.js +23 -23
- package/dist/contradiction/index.js +12 -12
- package/dist/{contradiction-scan-IBPYGQZF.js → contradiction-scan-DTQFAW22.js} +6 -6
- package/dist/convergence-refresh.js +22 -22
- package/dist/corpus-watermark.js +23 -23
- package/dist/dashboard-runtime.js +2 -2
- package/dist/deep-recall-http-glue.js +10 -10
- package/dist/embedding-fallback.js +2 -2
- package/dist/entity-retrieval.js +20 -20
- package/dist/event-order-recall.js +2 -2
- package/dist/explicit-capture.js +152 -152
- package/dist/extraction-normalization.js +1 -1
- package/dist/extraction-window-drain.d.ts +21 -0
- package/dist/extraction-window-drain.d.ts.map +1 -1
- package/dist/extraction-window-drain.js +5 -3
- package/dist/extraction.js +32 -32
- package/dist/{first-start-migration-FILJH3RO.js → first-start-migration-BPVJ4HJQ.js} +8 -8
- package/dist/graph-edge-decay-EKWXRBWF.js +1 -1
- package/dist/harmonic-retrieval.js +20 -20
- package/dist/index.js +291 -291
- package/dist/lcm/engine.js +3 -3
- package/dist/lcm/index.js +8 -8
- package/dist/local-llm-config.js +2 -2
- package/dist/location/index.js +23 -23
- package/dist/maintenance/memory-governance.js +20 -20
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +20 -20
- package/dist/maintenance/rebuild-memory-projection-runner.js +22 -22
- package/dist/maintenance/rebuild-memory-projection.js +21 -21
- package/dist/memory-browse.js +9 -9
- package/dist/namespaces/migrate.js +22 -22
- package/dist/namespaces/search.js +4 -4
- package/dist/namespaces/storage.js +21 -21
- package/dist/offline-sync-changeset-generations.js +3 -3
- package/dist/offline-sync-embedding-generation.js +2 -2
- package/dist/offline-sync-impression-drain.js +3 -3
- package/dist/offline-sync-snapshot-stream.js +6 -6
- package/dist/offline-sync.js +5 -5
- package/dist/operator-doctor-corpus.js +24 -24
- package/dist/operator-toolkit.js +41 -41
- package/dist/orchestration/backlog-scheduler.js +153 -153
- package/dist/orchestration/buffer-drain-runner.js +153 -153
- package/dist/orchestration/extraction-drain.d.ts +13 -0
- package/dist/orchestration/extraction-drain.d.ts.map +1 -1
- package/dist/orchestration/extraction-queue-coordinator.d.ts +10 -0
- package/dist/orchestration/extraction-queue-coordinator.d.ts.map +1 -1
- package/dist/orchestration/maintenance.js +34 -34
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +156 -156
- package/dist/qmd.js +4 -4
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-navigate-access.js +2 -2
- package/dist/recall-navigate-disclosure.js +2 -2
- package/dist/recall-navigate.js +2 -2
- package/dist/recall-navigation.js +152 -152
- package/dist/recall-state-view-admission.js +5 -5
- package/dist/recall-why-service.js +15 -15
- package/dist/recall-why.js +6 -6
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/cursor.js +2 -2
- package/dist/reconcile/manifest.js +3 -3
- package/dist/reconcile/plan.js +2 -2
- package/dist/{resolution-G4SLHSEU.js → resolution-7XBNQVKU.js} +9 -9
- package/dist/resolution-7XBNQVKU.js.map +1 -0
- package/dist/resume-bundles.js +33 -33
- package/dist/search/factory.js +3 -3
- package/dist/search/index.js +3 -3
- package/dist/semantic-consolidation.js +22 -22
- package/dist/semantic-rule-promotion.js +20 -20
- package/dist/semantic-rule-verifier.js +20 -20
- package/dist/source-agent-qualifier.js +29 -29
- package/dist/standup/build.js +21 -21
- package/dist/storage.js +19 -19
- package/dist/summarizer.js +1 -1
- package/dist/support-passport/index.js +12 -12
- package/dist/tier-routing.js +4 -4
- package/dist/{tier-stats-FXEUJN73.js → tier-stats-FLFKN7Y6.js} +8 -8
- package/dist/transfer/export-okf.js +20 -20
- package/dist/types.d.ts +5 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/verified-recall.js +20 -20
- package/dist/who-knows-cli.js +21 -21
- package/dist/who-knows.js +20 -20
- package/package.json +2 -2
- package/src/access-extraction-force-flush-preempt-coordinator.test.ts +60 -0
- package/src/access-extraction-force-flush-preempt.test.ts +41 -0
- package/src/access-extraction-force-flush-preempt.ts +56 -0
- package/src/access-observe-write-surface.ts +2 -14
- package/src/buffer-turn.ts +8 -0
- package/src/config.ts +2 -0
- package/src/extraction-window-drain.test.ts +66 -0
- package/src/extraction-window-drain.ts +113 -2
- package/src/orchestration/extraction-drain-parts.test.ts +260 -0
- package/src/orchestration/extraction-drain.ts +186 -23
- package/src/orchestration/extraction-queue-coordinator.ts +23 -0
- package/src/orchestrator-flush.test.ts +3 -0
- package/src/orchestrator.ts +1 -0
- package/src/part-failure-threshold.test.ts +91 -0
- package/src/types.ts +5 -6
- package/dist/chunk-3F6COEHZ.js.map +0 -1
- package/dist/chunk-BL545EH7.js.map +0 -1
- package/dist/chunk-CGEOIR4F.js.map +0 -1
- package/dist/chunk-LZIOY7ZU.js +0 -57
- package/dist/chunk-LZIOY7ZU.js.map +0 -1
- /package/dist/{contradiction-scan-IBPYGQZF.js.map → access-extraction-force-flush-preempt.js.map} +0 -0
- /package/dist/{auto-sync-BO5YZKM6.js.map → auto-sync-PSZJHHXB.js.map} +0 -0
- /package/dist/{chunk-T4KY6UYF.js.map → chunk-274UY54Z.js.map} +0 -0
- /package/dist/{chunk-3TVCG6ST.js.map → chunk-2DWTO7XP.js.map} +0 -0
- /package/dist/{chunk-STKNZY7A.js.map → chunk-2NJ74RQU.js.map} +0 -0
- /package/dist/{chunk-4H7TUVWQ.js.map → chunk-2VS3DAXE.js.map} +0 -0
- /package/dist/{chunk-MEQPK3KG.js.map → chunk-3BRHOVRU.js.map} +0 -0
- /package/dist/{chunk-HLWXCDUQ.js.map → chunk-3DAWHP5K.js.map} +0 -0
- /package/dist/{chunk-KVCFAWBZ.js.map → chunk-3PZDG5ZH.js.map} +0 -0
- /package/dist/{chunk-5RZ4DAP6.js.map → chunk-5IGWEYNV.js.map} +0 -0
- /package/dist/{chunk-U5I2G4VU.js.map → chunk-5WZT6WQW.js.map} +0 -0
- /package/dist/{chunk-TL6QIZT7.js.map → chunk-66MBMBSH.js.map} +0 -0
- /package/dist/{chunk-KLUCX6OH.js.map → chunk-77SYM565.js.map} +0 -0
- /package/dist/{chunk-ZGGFGUUF.js.map → chunk-A33VT7GC.js.map} +0 -0
- /package/dist/{chunk-5RCXMLI5.js.map → chunk-AV6R66KO.js.map} +0 -0
- /package/dist/{chunk-S3LWB6K3.js.map → chunk-CKG7T4AD.js.map} +0 -0
- /package/dist/{chunk-YNTVQWLX.js.map → chunk-DI2QWY6J.js.map} +0 -0
- /package/dist/{chunk-3RW5ZCYO.js.map → chunk-DIBOWE53.js.map} +0 -0
- /package/dist/{chunk-QRZNVNNS.js.map → chunk-EEY326VH.js.map} +0 -0
- /package/dist/{chunk-OIGJZHDU.js.map → chunk-EUL3S3LE.js.map} +0 -0
- /package/dist/{chunk-YNDLCWXS.js.map → chunk-EZ25VE3G.js.map} +0 -0
- /package/dist/{chunk-DUTLMAUC.js.map → chunk-F4DXTUHY.js.map} +0 -0
- /package/dist/{chunk-DK2VBJ6Q.js.map → chunk-FAPJG3OG.js.map} +0 -0
- /package/dist/{chunk-M2XR6B6V.js.map → chunk-FEUWI5QH.js.map} +0 -0
- /package/dist/{chunk-VO3HCFSR.js.map → chunk-GAVFANAB.js.map} +0 -0
- /package/dist/{chunk-SPHBQTWE.js.map → chunk-GOYLBPSW.js.map} +0 -0
- /package/dist/{chunk-37T5ZO5P.js.map → chunk-HOSS72UP.js.map} +0 -0
- /package/dist/{chunk-3TU6OBI7.js.map → chunk-I3UBDUHO.js.map} +0 -0
- /package/dist/{chunk-HA6V3CLH.js.map → chunk-JCWI43TO.js.map} +0 -0
- /package/dist/{chunk-6LNWA6IT.js.map → chunk-JEAMQL63.js.map} +0 -0
- /package/dist/{chunk-XBNGH2FV.js.map → chunk-JG6AHBJW.js.map} +0 -0
- /package/dist/{chunk-PA5FI6A5.js.map → chunk-JY327EH4.js.map} +0 -0
- /package/dist/{chunk-WYSCN5TA.js.map → chunk-K4DBE5MH.js.map} +0 -0
- /package/dist/{chunk-KIICCGSV.js.map → chunk-KCLHHANX.js.map} +0 -0
- /package/dist/{chunk-QOI4PNVG.js.map → chunk-KCVPKFDG.js.map} +0 -0
- /package/dist/{chunk-EFMAYZOB.js.map → chunk-L6CMR5OI.js.map} +0 -0
- /package/dist/{chunk-Y3TA66MZ.js.map → chunk-LEH4FVBJ.js.map} +0 -0
- /package/dist/{chunk-AHA5VQGP.js.map → chunk-LEII44QG.js.map} +0 -0
- /package/dist/{chunk-4VL2H5Q3.js.map → chunk-LL7WIK2Z.js.map} +0 -0
- /package/dist/{chunk-GW23JXGJ.js.map → chunk-LT35JWKZ.js.map} +0 -0
- /package/dist/{chunk-U5OVNYJX.js.map → chunk-MP6V4CLP.js.map} +0 -0
- /package/dist/{chunk-NEXJ3OOZ.js.map → chunk-MXE42X3I.js.map} +0 -0
- /package/dist/{chunk-LR6QP72R.js.map → chunk-N6JGLQV7.js.map} +0 -0
- /package/dist/{chunk-J6U6KUMK.js.map → chunk-N7IJEGSE.js.map} +0 -0
- /package/dist/{chunk-5ZS73P3U.js.map → chunk-NB2BKYUS.js.map} +0 -0
- /package/dist/{chunk-KN44QS5F.js.map → chunk-NOZDET3Q.js.map} +0 -0
- /package/dist/{chunk-C2KE5DMD.js.map → chunk-O6ZSWHVR.js.map} +0 -0
- /package/dist/{chunk-C73N66PR.js.map → chunk-OBPOIZNR.js.map} +0 -0
- /package/dist/{chunk-TSJQ7C2T.js.map → chunk-OFMK76LD.js.map} +0 -0
- /package/dist/{chunk-LK3LXSJQ.js.map → chunk-OI3UMEW3.js.map} +0 -0
- /package/dist/{chunk-6Z7BRM7C.js.map → chunk-OJJ73HLA.js.map} +0 -0
- /package/dist/{chunk-CLVILSBR.js.map → chunk-OZNBZJ3S.js.map} +0 -0
- /package/dist/{chunk-GUI7MLKC.js.map → chunk-PKPW7MXT.js.map} +0 -0
- /package/dist/{chunk-SCQO7JOF.js.map → chunk-PKV3NNM2.js.map} +0 -0
- /package/dist/{chunk-XCZQ7MID.js.map → chunk-PNT3SZRY.js.map} +0 -0
- /package/dist/{chunk-IXX4SKF5.js.map → chunk-POB7N5UM.js.map} +0 -0
- /package/dist/{chunk-2OIQHXN4.js.map → chunk-PQ5FYNY2.js.map} +0 -0
- /package/dist/{chunk-JDY34KBL.js.map → chunk-QUMKDRCF.js.map} +0 -0
- /package/dist/{chunk-V6JECHY6.js.map → chunk-SBRUTD5O.js.map} +0 -0
- /package/dist/{chunk-ZKHDDEPF.js.map → chunk-SRW4IKHM.js.map} +0 -0
- /package/dist/{chunk-BTY6DUFW.js.map → chunk-SU63UQPL.js.map} +0 -0
- /package/dist/{chunk-TVDJEUV5.js.map → chunk-SX4BR26Y.js.map} +0 -0
- /package/dist/{chunk-OIG4ZFMB.js.map → chunk-SZK2DX5U.js.map} +0 -0
- /package/dist/{chunk-5BE3FLKL.js.map → chunk-TAUHAP5J.js.map} +0 -0
- /package/dist/{chunk-NS7U4ZYU.js.map → chunk-TSUSHXBW.js.map} +0 -0
- /package/dist/{chunk-YMFPFXEX.js.map → chunk-TYOS62PM.js.map} +0 -0
- /package/dist/{chunk-BFDXJHYG.js.map → chunk-U3GJUARA.js.map} +0 -0
- /package/dist/{chunk-P3WRNWWM.js.map → chunk-UPE7TJWN.js.map} +0 -0
- /package/dist/{chunk-OE35LFBF.js.map → chunk-VF3EVRUN.js.map} +0 -0
- /package/dist/{chunk-VY3DHUL7.js.map → chunk-VRWQUUZ7.js.map} +0 -0
- /package/dist/{chunk-FEWOSD33.js.map → chunk-VSZEV7HG.js.map} +0 -0
- /package/dist/{chunk-K2VRKCPA.js.map → chunk-XBW7U7GM.js.map} +0 -0
- /package/dist/{chunk-UA2NDTIU.js.map → chunk-YAVIBVCU.js.map} +0 -0
- /package/dist/{chunk-HKQ3LH34.js.map → chunk-YDOLJQ55.js.map} +0 -0
- /package/dist/{chunk-JGM3OWPQ.js.map → chunk-YMNFHNZH.js.map} +0 -0
- /package/dist/{chunk-DJ7WVEWX.js.map → chunk-YVXM5QFL.js.map} +0 -0
- /package/dist/{chunk-FMFCQRDM.js.map → chunk-ZANNIXXE.js.map} +0 -0
- /package/dist/{chunk-OJXK5C6Z.js.map → chunk-ZG4GNPRE.js.map} +0 -0
- /package/dist/{chunk-B3DR2JBZ.js.map → chunk-ZZYJNT2J.js.map} +0 -0
- /package/dist/{resolution-G4SLHSEU.js.map → contradiction-scan-DTQFAW22.js.map} +0 -0
- /package/dist/{first-start-migration-FILJH3RO.js.map → first-start-migration-BPVJ4HJQ.js.map} +0 -0
- /package/dist/{tier-stats-FXEUJN73.js.map → tier-stats-FLFKN7Y6.js.map} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyed force-flush preemption must abort ONLY the armed slot matching the
|
|
3
|
+
* caller's session key.
|
|
4
|
+
*
|
|
5
|
+
* Follow-up to the caller-key forwarding: `preemptRunning(preferredKey?)`
|
|
6
|
+
* falls back to the newest armed slot whenever no key-matched slot is armed,
|
|
7
|
+
* so a force-flush whose own extraction is not (yet) armed still killed an
|
|
8
|
+
* unrelated background task - the exact failure PR #3468 reports. The
|
|
9
|
+
* coordinator therefore gains `preemptKeyed(key)`: abort every armed slot
|
|
10
|
+
* whose key matches, and abort nothing when none does. `preemptRunning`
|
|
11
|
+
* keeps its newest-slot fallback for the keyless call sites (front-enqueue
|
|
12
|
+
* flush path).
|
|
13
|
+
*/
|
|
14
|
+
import assert from "node:assert/strict";
|
|
15
|
+
import test from "node:test";
|
|
16
|
+
import { ExtractionQueueCoordinator } from "./orchestration/extraction-queue-coordinator.js";
|
|
17
|
+
|
|
18
|
+
interface Capture {
|
|
19
|
+
key: string;
|
|
20
|
+
aborted: string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function captureSlot(
|
|
24
|
+
coordinator: ExtractionQueueCoordinator,
|
|
25
|
+
capture: Capture,
|
|
26
|
+
key: string,
|
|
27
|
+
): void {
|
|
28
|
+
const slot = coordinator.registerPreemptSlot(key);
|
|
29
|
+
slot.arm(() => void capture.aborted.push(key));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
test("preemptKeyed aborts only the armed slot with the matching key", () => {
|
|
33
|
+
const coordinator = new ExtractionQueueCoordinator();
|
|
34
|
+
const mine: Capture = { key: "sess-a", aborted: [] };
|
|
35
|
+
const other: Capture = { key: "sess-b", aborted: [] };
|
|
36
|
+
captureSlot(coordinator, mine, "sess-a");
|
|
37
|
+
captureSlot(coordinator, other, "sess-b");
|
|
38
|
+
coordinator.preemptKeyed("sess-a");
|
|
39
|
+
assert.deepEqual(mine.aborted, ["sess-a"]);
|
|
40
|
+
assert.deepEqual(other.aborted, []);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("preemptKeyed aborts nothing when no armed slot matches", () => {
|
|
44
|
+
const coordinator = new ExtractionQueueCoordinator();
|
|
45
|
+
const other: Capture = { key: "sess-b", aborted: [] };
|
|
46
|
+
captureSlot(coordinator, other, "sess-b");
|
|
47
|
+
coordinator.preemptKeyed("sess-c");
|
|
48
|
+
assert.deepEqual(other.aborted, []);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("preemptRunning keeps the newest-slot fallback for keyless calls", () => {
|
|
52
|
+
const coordinator = new ExtractionQueueCoordinator();
|
|
53
|
+
const first: Capture = { key: "sess-a", aborted: [] };
|
|
54
|
+
const second: Capture = { key: "sess-b", aborted: [] };
|
|
55
|
+
captureSlot(coordinator, first, "sess-a");
|
|
56
|
+
captureSlot(coordinator, second, "sess-b");
|
|
57
|
+
coordinator.preemptRunning();
|
|
58
|
+
assert.deepEqual(first.aborted, []);
|
|
59
|
+
assert.deepEqual(second.aborted, ["sess-b"]);
|
|
60
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The force-flush preemption callback must preempt the CALLER'S OWN session
|
|
3
|
+
* extraction slot, never an arbitrary newest-armed slot.
|
|
4
|
+
*
|
|
5
|
+
* `preemptRunning(preferredKey?)` already prefers a key-matched slot and only
|
|
6
|
+
* falls back to the newest armed slot when no key is given. The write surface
|
|
7
|
+
* passed no key, so every force-flush killed whichever background task armed
|
|
8
|
+
* last — typically the backlog scheduler's buffer drain — instead of the
|
|
9
|
+
* caller's own queued extraction. That turned each force-flush into collateral
|
|
10
|
+
* damage for the 8,972-turn extraction backlog (observed 2026-11-17: repeated
|
|
11
|
+
* `extraction preempted for force-flush` failures on unrelated sessions).
|
|
12
|
+
*/
|
|
13
|
+
import assert from "node:assert/strict";
|
|
14
|
+
import test from "node:test";
|
|
15
|
+
import { forceFlushPreemptCallback } from "./access-extraction-force-flush-preempt.js";
|
|
16
|
+
|
|
17
|
+
test("forwards the caller session key as keyed-only preemption", () => {
|
|
18
|
+
const keyed: string[] = [];
|
|
19
|
+
const unkeyed: number[] = [];
|
|
20
|
+
const callback = forceFlushPreemptCallback("pi:session-a", {
|
|
21
|
+
preemptRunning: () => void unkeyed.push(1),
|
|
22
|
+
preemptKeyed: (key) => void keyed.push(key),
|
|
23
|
+
});
|
|
24
|
+
callback();
|
|
25
|
+
assert.deepEqual(keyed, ["pi:session-a"]);
|
|
26
|
+
assert.deepEqual(unkeyed, []);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("falls back to newest-slot preemption when no session key is known", () => {
|
|
30
|
+
const unkeyed: number[] = [];
|
|
31
|
+
const callback = forceFlushPreemptCallback(undefined, {
|
|
32
|
+
preemptRunning: () => void unkeyed.push(1),
|
|
33
|
+
});
|
|
34
|
+
callback();
|
|
35
|
+
assert.deepEqual(unkeyed, [1]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("a missing coordinator is a no-op, not a throw", () => {
|
|
39
|
+
const callback = forceFlushPreemptCallback("pi:session-a", undefined);
|
|
40
|
+
assert.doesNotThrow(() => callback());
|
|
41
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The force-flush preemption callback factory.
|
|
3
|
+
*
|
|
4
|
+
* A keyed force-flush must abort ONLY the armed slot matching the caller's
|
|
5
|
+
* session (`coordinator.preemptKeyed`) - `preemptRunning(preferredKey?)`
|
|
6
|
+
* falls back to the newest armed slot whenever no key-matched slot is armed,
|
|
7
|
+
* which killed unrelated background drains exactly when the caller's own
|
|
8
|
+
* extraction was not yet armed (the failure PR #3468 reports). The keyless
|
|
9
|
+
* call keeps `preemptRunning`'s newest-slot fallback, which the front-enqueue
|
|
10
|
+
* flush path relies on.
|
|
11
|
+
*/
|
|
12
|
+
import { extractionForceFlush } from "./access-extraction-force-flush.js";
|
|
13
|
+
import type { AccessObserveWriteSurfaceDeps } from "./access-observe-write-surface.js";
|
|
14
|
+
import { PendingObserveExtractionTracker } from "./access-observe-helpers.js";
|
|
15
|
+
import type { EngramAccessExtractionForceFlushRequest, EngramAccessExtractionForceFlushResponse } from "./access-service.js";
|
|
16
|
+
|
|
17
|
+
export function forceFlushPreemptCallback(
|
|
18
|
+
sessionKey: string | undefined,
|
|
19
|
+
coordinator:
|
|
20
|
+
| {
|
|
21
|
+
preemptRunning?: (preferredKey?: string) => void;
|
|
22
|
+
preemptKeyed?: (key: string) => void;
|
|
23
|
+
}
|
|
24
|
+
| undefined,
|
|
25
|
+
): () => void {
|
|
26
|
+
return () => {
|
|
27
|
+
if (sessionKey !== undefined) {
|
|
28
|
+
coordinator?.preemptKeyed?.(sessionKey);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
coordinator?.preemptRunning?.();
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The force-flush call with the keyed preemption callback attached, so the
|
|
36
|
+
* write surface stays under the file-size ratchet (issue #1995). */
|
|
37
|
+
export function forceFlushPreemptCall(
|
|
38
|
+
deps: AccessObserveWriteSurfaceDeps,
|
|
39
|
+
request: EngramAccessExtractionForceFlushRequest,
|
|
40
|
+
pending: PendingObserveExtractionTracker,
|
|
41
|
+
): Promise<EngramAccessExtractionForceFlushResponse> {
|
|
42
|
+
return extractionForceFlush(
|
|
43
|
+
deps,
|
|
44
|
+
request,
|
|
45
|
+
(sessionKey, principal, namespace, abortSignal, registerCancellation, scopeHint) =>
|
|
46
|
+
pending.wait(
|
|
47
|
+
sessionKey,
|
|
48
|
+
principal,
|
|
49
|
+
namespace,
|
|
50
|
+
abortSignal,
|
|
51
|
+
registerCancellation,
|
|
52
|
+
scopeHint,
|
|
53
|
+
forceFlushPreemptCallback(sessionKey, deps.orchestrator.extractionQueueCoordinator),
|
|
54
|
+
),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -33,6 +33,7 @@ import { buildWithBriefingLocation, reapplyCategoryCoercion, splitCanonicalWrite
|
|
|
33
33
|
import { abortError } from "./abort-error.js";
|
|
34
34
|
import { withBriefingDeadline } from "./briefing-deadline.js";
|
|
35
35
|
import { extractionForceFlush } from "./access-extraction-force-flush.js";
|
|
36
|
+
import { forceFlushPreemptCall } from "./access-extraction-force-flush-preempt.js";
|
|
36
37
|
import { ObserveTranscriptPersister, observeTranscriptSessionKey } from "./access-observe-transcript.js";
|
|
37
38
|
import { createObserveStageTimer } from "./access-observe-stage-timing.js";
|
|
38
39
|
import { archiveObservedTurns } from "./access-observe-lcm-archive.js";
|
|
@@ -932,20 +933,7 @@ export class AccessObserveWriteSurface {
|
|
|
932
933
|
async extractionForceFlush(
|
|
933
934
|
request: EngramAccessExtractionForceFlushRequest
|
|
934
935
|
): Promise<EngramAccessExtractionForceFlushResponse> {
|
|
935
|
-
return
|
|
936
|
-
this.deps,
|
|
937
|
-
request,
|
|
938
|
-
(sessionKey, principal, namespace, abortSignal, registerCancellation, scopeHint) =>
|
|
939
|
-
this.pendingObserveExtractions.wait(
|
|
940
|
-
sessionKey,
|
|
941
|
-
principal,
|
|
942
|
-
namespace,
|
|
943
|
-
abortSignal,
|
|
944
|
-
registerCancellation,
|
|
945
|
-
scopeHint,
|
|
946
|
-
() => this.deps.orchestrator.extractionQueueCoordinator?.preemptRunning(),
|
|
947
|
-
)
|
|
948
|
-
);
|
|
936
|
+
return forceFlushPreemptCall(this.deps, request, this.pendingObserveExtractions);
|
|
949
937
|
}
|
|
950
938
|
async workTask(request: {
|
|
951
939
|
action: "create" | "get" | "list" | "update" | "transition" | "delete";
|
package/src/buffer-turn.ts
CHANGED
|
@@ -57,4 +57,12 @@ export interface BufferTurn extends SourceConnectorProvenance, BufferTurnOwner,
|
|
|
57
57
|
* the drain's in-memory chunk copies, never on buffered or claimed turns.
|
|
58
58
|
*/
|
|
59
59
|
extractionDuplicateOf?: true;
|
|
60
|
+
/**
|
|
61
|
+
* In-flight drain marker (payload-cap drain): this turn is one verbatim
|
|
62
|
+
* slice of a buffered turn whose content exceeded the per-call payload
|
|
63
|
+
* cap. The marker is set only on the drain's in-memory chunk copies,
|
|
64
|
+
* never persisted and never spliced into the content (verbatim-quote
|
|
65
|
+
* requirement) — the model sees only real conversation text.
|
|
66
|
+
*/
|
|
67
|
+
extractionPartOf?: { part: number; of: number };
|
|
60
68
|
}
|
package/src/config.ts
CHANGED
|
@@ -2877,6 +2877,8 @@ export function parseConfig(
|
|
|
2877
2877
|
? cfg.extractionBreakerAuthCooldownMs : 1_800_000,
|
|
2878
2878
|
// Trigger-drain drop threshold: consecutive failed extraction attempts
|
|
2879
2879
|
// before the failing buffer chunk is dropped (side-file copied first).
|
|
2880
|
+
extractionCallMaxChars:
|
|
2881
|
+
parsePositiveInteger(cfg.extractionCallMaxChars, "extractionCallMaxChars") ?? 12_000,
|
|
2880
2882
|
extractionChunkDropAfterFailures: parseIntegerAtLeast(
|
|
2881
2883
|
cfg.extractionChunkDropAfterFailures,
|
|
2882
2884
|
5,
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
classifyDrainResult,
|
|
6
6
|
extractionWindowBudgetChars,
|
|
7
7
|
mergeDrainResults,
|
|
8
|
+
splitOversizedTurns,
|
|
8
9
|
} from "./extraction-window-drain.js";
|
|
9
10
|
import type { ExtractionRunResult } from "./orchestration/extraction-run.js";
|
|
10
11
|
import type { BufferTurn } from "./types.js";
|
|
@@ -121,3 +122,68 @@ test("extractionWindowBudgetChars applies the learned local window only when the
|
|
|
121
122
|
"no registry (legacy host or test double): no budget",
|
|
122
123
|
);
|
|
123
124
|
});
|
|
125
|
+
|
|
126
|
+
test("splitOversizedTurns leaves a fitting turn untouched", () => {
|
|
127
|
+
const turns = [makeTurn("short")];
|
|
128
|
+
const plan = splitOversizedTurns(turns, 100);
|
|
129
|
+
assert.deepEqual(plan.turns, turns);
|
|
130
|
+
assert.equal(plan.partParents.size, 0);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("splitOversizedTurns splits an oversized turn into marked parts covering all content", () => {
|
|
134
|
+
const parent = makeTurn(
|
|
135
|
+
"First sentence here. Second sentence also here. Third sentence keeps going. Fourth is the tail.",
|
|
136
|
+
);
|
|
137
|
+
const plan = splitOversizedTurns([parent], 40);
|
|
138
|
+
assert.ok(plan.turns.length > 1, "expected several parts");
|
|
139
|
+
for (const [index, part] of plan.turns.entries()) {
|
|
140
|
+
assert.deepEqual(part.extractionPartOf, { part: index + 1, of: plan.turns.length });
|
|
141
|
+
assert.ok(part.content.length <= 40, `part ${index} over budget`);
|
|
142
|
+
assert.equal(plan.partParents.get(part), parent);
|
|
143
|
+
}
|
|
144
|
+
const joined = plan.turns.map((part) => part.content).join("");
|
|
145
|
+
assert.equal(joined, parent.content, "every part extracted — nothing dropped");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test("splitOversizedTurns never splices marker text into the content", () => {
|
|
149
|
+
const parent = makeTurn("Alpha part one. Beta part two. Gamma part three. Delta part four.");
|
|
150
|
+
const plan = splitOversizedTurns([parent], 30);
|
|
151
|
+
for (const part of plan.turns) {
|
|
152
|
+
assert.ok(parent.content.includes(part.content), "part text must be verbatim slices");
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test("splitOversizedTurns clamps at the max part count and reports the clamp", () => {
|
|
157
|
+
const parent = makeTurn("one. two. three. four. five. six. seven. eight. nine. ten.");
|
|
158
|
+
const plan = splitOversizedTurns([parent], 8, 4);
|
|
159
|
+
assert.ok(plan.turns.length <= 4);
|
|
160
|
+
assert.equal(plan.clamped, true);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test("extractionWindowBudgetChars applies the configured call cap below the model budget", () => {
|
|
164
|
+
const registry = {
|
|
165
|
+
calculateContextSizes: () => ({ maxInputChars: 28800 }),
|
|
166
|
+
};
|
|
167
|
+
const budget = extractionWindowBudgetChars({
|
|
168
|
+
registry,
|
|
169
|
+
localExtractionActive: true,
|
|
170
|
+
model: "m",
|
|
171
|
+
maxContext: 12288,
|
|
172
|
+
callMaxChars: 12000,
|
|
173
|
+
});
|
|
174
|
+
assert.equal(budget, 12000);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("extractionWindowBudgetChars keeps the smaller registry budget", () => {
|
|
178
|
+
const registry = {
|
|
179
|
+
calculateContextSizes: () => ({ maxInputChars: 8000 }),
|
|
180
|
+
};
|
|
181
|
+
const budget = extractionWindowBudgetChars({
|
|
182
|
+
registry,
|
|
183
|
+
localExtractionActive: true,
|
|
184
|
+
model: "m",
|
|
185
|
+
maxContext: 12288,
|
|
186
|
+
callMaxChars: 12000,
|
|
187
|
+
});
|
|
188
|
+
assert.equal(budget, 8000);
|
|
189
|
+
});
|
|
@@ -104,7 +104,118 @@ export function extractionWindowBudgetChars(input: {
|
|
|
104
104
|
localExtractionActive: boolean;
|
|
105
105
|
model: string;
|
|
106
106
|
maxContext: number | undefined;
|
|
107
|
+
/** Configured per-call payload cap (`extractionCallMaxChars`). */
|
|
108
|
+
callMaxChars?: number;
|
|
107
109
|
}): number {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
const callMax = input.callMaxChars ?? Number.POSITIVE_INFINITY;
|
|
111
|
+
const cap = Number.isFinite(callMax) && callMax > 0 ? callMax : Number.POSITIVE_INFINITY;
|
|
112
|
+
if (!input.registry || !input.localExtractionActive) return cap;
|
|
113
|
+
return Math.min(cap, input.registry.calculateContextSizes(input.model, input.maxContext).maxInputChars);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Split `content` into budget-fitting slices at sentence/paragraph
|
|
118
|
+
* boundaries; a segment longer than the budget hard-cuts at the boundary.
|
|
119
|
+
* The slices are contiguous and verbatim — join("") restores the input.
|
|
120
|
+
*/
|
|
121
|
+
function splitSegments(content: string): string[] {
|
|
122
|
+
const out: string[] = [];
|
|
123
|
+
let start = 0;
|
|
124
|
+
let index = 0;
|
|
125
|
+
while (index < content.length) {
|
|
126
|
+
const ch = content[index];
|
|
127
|
+
if (ch === "\n") {
|
|
128
|
+
let end = index;
|
|
129
|
+
while (end < content.length && content[end] === "\n") end += 1;
|
|
130
|
+
out.push(content.slice(start, end));
|
|
131
|
+
start = end;
|
|
132
|
+
index = end;
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (ch === "." || ch === "!" || ch === "?") {
|
|
136
|
+
let end = index + 1;
|
|
137
|
+
while (end < content.length && (content[end] === " " || content[end] === "\t")) end += 1;
|
|
138
|
+
out.push(content.slice(start, end));
|
|
139
|
+
start = end;
|
|
140
|
+
index = end;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
index += 1;
|
|
144
|
+
}
|
|
145
|
+
if (start < content.length) out.push(content.slice(start));
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function splitTurnContent(content: string, maxChars: number): string[] {
|
|
150
|
+
const segments = splitSegments(content);
|
|
151
|
+
const parts: string[] = [];
|
|
152
|
+
let current = "";
|
|
153
|
+
for (const segment of segments) {
|
|
154
|
+
let piece = segment;
|
|
155
|
+
while (piece.length > 0) {
|
|
156
|
+
const room = maxChars - current.length;
|
|
157
|
+
if (piece.length <= room) {
|
|
158
|
+
current += piece;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
if (current.length > 0) {
|
|
162
|
+
parts.push(current);
|
|
163
|
+
current = "";
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
parts.push(piece.slice(0, maxChars));
|
|
167
|
+
piece = piece.slice(maxChars);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (current.length > 0) parts.push(current);
|
|
171
|
+
return parts;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Replace each turn over `maxChars` with in-memory part copies marked
|
|
176
|
+
* `extractionPartOf {part,of}` (payload-cap drain). Parts keep order and
|
|
177
|
+
* carry verbatim contiguous slices so joining them restores the turn —
|
|
178
|
+
* nothing is dropped by the split itself. A turn needing more than
|
|
179
|
+
* `maxParts` emits `maxParts` parts and reports `clamped` so the caller
|
|
180
|
+
* can log the bounded loss rather than hide it.
|
|
181
|
+
*/
|
|
182
|
+
export interface OversizedTurnSplit<T extends { content: string }> {
|
|
183
|
+
turns: T[];
|
|
184
|
+
partParents: Map<T, T>;
|
|
185
|
+
clampedParents: Set<T>;
|
|
186
|
+
clamped: boolean;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export function splitOversizedTurns<T extends { content: string }>(
|
|
190
|
+
turns: readonly T[],
|
|
191
|
+
maxChars: number,
|
|
192
|
+
maxParts = 8,
|
|
193
|
+
): OversizedTurnSplit<T> {
|
|
194
|
+
const partParents = new Map<T, T>();
|
|
195
|
+
const clampedParents = new Set<T>();
|
|
196
|
+
const budget = Math.floor(maxChars);
|
|
197
|
+
if (!(Number.isFinite(budget) && budget > 0)) {
|
|
198
|
+
return { turns: [...turns], partParents, clampedParents, clamped: false };
|
|
199
|
+
}
|
|
200
|
+
const out: T[] = [];
|
|
201
|
+
let clamped = false;
|
|
202
|
+
for (const turn of turns) {
|
|
203
|
+
if (turn.content.length <= budget) {
|
|
204
|
+
out.push(turn);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const slices = splitTurnContent(turn.content, budget);
|
|
208
|
+
const emitted = slices.slice(0, maxParts);
|
|
209
|
+
if (slices.length > maxParts) {
|
|
210
|
+
clamped = true;
|
|
211
|
+
clampedParents.add(turn);
|
|
212
|
+
}
|
|
213
|
+
const of = emitted.length;
|
|
214
|
+
for (const [index, slice] of emitted.entries()) {
|
|
215
|
+
const part = { ...turn, content: slice, extractionPartOf: { part: index + 1, of } };
|
|
216
|
+
partParents.set(part, turn);
|
|
217
|
+
out.push(part);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return { turns: out, partParents, clampedParents, clamped };
|
|
110
221
|
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
import { SmartBuffer } from "../buffer.js";
|
|
7
|
+
import { parseConfig } from "../config.js";
|
|
8
|
+
import { StorageManager } from "../storage.js";
|
|
9
|
+
import type { BufferTurn } from "../types.js";
|
|
10
|
+
import { ExtractionDrain, type DrainRunOptions } from "./extraction-drain.js";
|
|
11
|
+
import type { ExtractionRunResult } from "./extraction-run.js";
|
|
12
|
+
|
|
13
|
+
function makeTurn(content: string, overrides: Partial<BufferTurn> = {}): BufferTurn {
|
|
14
|
+
return { role: "user", content, timestamp: "2026-11-17T12:00:00.000Z", sessionKey: "s1", ...overrides };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const DONE: ExtractionRunResult = { status: "completed", persistedCount: 1, durableOutputCount: 1 };
|
|
18
|
+
const DEFERRED: ExtractionRunResult = {
|
|
19
|
+
status: "skipped",
|
|
20
|
+
reason: "breaker_open",
|
|
21
|
+
retainedBuffer: true,
|
|
22
|
+
failureClass: "provider_retryable",
|
|
23
|
+
persistedCount: 0,
|
|
24
|
+
durableOutputCount: 0,
|
|
25
|
+
};
|
|
26
|
+
const FAILED: ExtractionRunResult = {
|
|
27
|
+
status: "skipped",
|
|
28
|
+
reason: "empty_extraction_result",
|
|
29
|
+
retainedBuffer: true,
|
|
30
|
+
failureClass: "parse_empty",
|
|
31
|
+
persistedCount: 0,
|
|
32
|
+
durableOutputCount: 0,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
interface DrainOptions {
|
|
36
|
+
turns: BufferTurn[];
|
|
37
|
+
results: ExtractionRunResult[];
|
|
38
|
+
runs?: number;
|
|
39
|
+
budgetChars?: number;
|
|
40
|
+
maxTurnChars?: number;
|
|
41
|
+
dropAfter?: number;
|
|
42
|
+
saveCopies?: { reason: string; contents: string }[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A real buffer on real storage, drained with a stub runExtraction that
|
|
46
|
+
* clears like the coordinator does for a `clearMatchingTurns` drain. */
|
|
47
|
+
async function withDrain(opts: DrainOptions): Promise<{
|
|
48
|
+
calls: BufferTurn[][];
|
|
49
|
+
buffer: SmartBuffer;
|
|
50
|
+
}> {
|
|
51
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "remnic-parts-drain-"));
|
|
52
|
+
const calls: BufferTurn[][] = [];
|
|
53
|
+
const buffer = new SmartBuffer(
|
|
54
|
+
parseConfig({ memoryDir: root, bufferMaxTurnsPerSession: 2000 }),
|
|
55
|
+
new StorageManager(root),
|
|
56
|
+
);
|
|
57
|
+
try {
|
|
58
|
+
for (const entry of opts.turns) await buffer.addTurn("s1", entry);
|
|
59
|
+
await buffer.flushPendingSave();
|
|
60
|
+
const drain = new ExtractionDrain({
|
|
61
|
+
config: {
|
|
62
|
+
extractionMinUserTurns: 1,
|
|
63
|
+
extractionMinChars: 0,
|
|
64
|
+
extractionMaxTurnChars: opts.maxTurnChars ?? 60,
|
|
65
|
+
extractionChunkDropAfterFailures: opts.dropAfter ?? 3,
|
|
66
|
+
},
|
|
67
|
+
extractionWindowBudgetChars: () => opts.budgetChars ?? 100,
|
|
68
|
+
measureRenderedTurns: (turns) => turns.reduce((total, seen) => total + seen.content.length, 0),
|
|
69
|
+
runExtraction: async (turns, options) => {
|
|
70
|
+
calls.push([...turns]);
|
|
71
|
+
const result = opts.results.shift() ?? DONE;
|
|
72
|
+
if (result.status === "completed") {
|
|
73
|
+
await buffer.clearAfterExtraction(
|
|
74
|
+
"s1",
|
|
75
|
+
turns,
|
|
76
|
+
options?.clearMatchingTurns === true ? { allowNonPrefix: true } : undefined,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
},
|
|
81
|
+
getStorage: async () => ({
|
|
82
|
+
saveDroppedExtractionChunk: async (_bufferKey: string, reason: string, turns: readonly BufferTurn[]) => {
|
|
83
|
+
opts.saveCopies?.push({ reason, contents: turns.map((seen) => seen.content).join("") });
|
|
84
|
+
return `/recovery/${turns.length}.json`;
|
|
85
|
+
},
|
|
86
|
+
}),
|
|
87
|
+
buffer: {
|
|
88
|
+
dropExtractionChunk: (bufferKey, turns, dropOptions) =>
|
|
89
|
+
buffer.dropExtractionChunk(bufferKey, turns, dropOptions),
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
const options: DrainRunOptions = {
|
|
93
|
+
bufferKey: "s1",
|
|
94
|
+
clearBufferAfterExtraction: true,
|
|
95
|
+
clearMatchingTurns: true,
|
|
96
|
+
skipUserTurnThreshold: false,
|
|
97
|
+
failOnExtractionFailure: false,
|
|
98
|
+
forceExtractionAttempt: false,
|
|
99
|
+
};
|
|
100
|
+
for (let runIndex = 0; runIndex < (opts.runs ?? 1); runIndex += 1) {
|
|
101
|
+
await drain.run(opts.turns, options);
|
|
102
|
+
}
|
|
103
|
+
return { calls, buffer };
|
|
104
|
+
} finally {
|
|
105
|
+
await rm(root, { recursive: true, force: true });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function allExtractedText(calls: readonly BufferTurn[][]): string {
|
|
110
|
+
return calls.flat().map((seen) => seen.content).join("");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
test("an oversized turn drains as ordered parts and the parent clears once", async () => {
|
|
114
|
+
// 150 chars at a 60-char part budget -> 3 parts; the 100-char call budget
|
|
115
|
+
// packs one part per chunk, so every part is a separate extraction call.
|
|
116
|
+
const parent = makeTurn(`${"a".repeat(50)}. ${"b".repeat(50)}. ${"c".repeat(45)}`);
|
|
117
|
+
const { calls, buffer } = await withDrain({ turns: [parent], results: [DONE, DONE, DONE] });
|
|
118
|
+
assert.equal(calls.length, 2, "the parts pack greedily into budget-fitting chunks");
|
|
119
|
+
assert.deepEqual(
|
|
120
|
+
calls.flat().map((seen) => seen.extractionPartOf),
|
|
121
|
+
[
|
|
122
|
+
{ part: 1, of: 3 },
|
|
123
|
+
{ part: 2, of: 3 },
|
|
124
|
+
{ part: 3, of: 3 },
|
|
125
|
+
],
|
|
126
|
+
"each part copy carries its in-flight marker",
|
|
127
|
+
);
|
|
128
|
+
assert.equal(allExtractedText(calls), parent.content, "every part extracted — verbatim coverage, nothing dropped");
|
|
129
|
+
assert.deepEqual(buffer.getTurns("s1"), [], "the parent clears when its last part drains");
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test("parts keep sentence boundaries and carry no marker text in content", async () => {
|
|
133
|
+
const parent = makeTurn(`${"a".repeat(50)}. ${"b".repeat(50)}. ${"c".repeat(45)}`);
|
|
134
|
+
const { calls } = await withDrain({ turns: [parent], results: [DONE, DONE, DONE] });
|
|
135
|
+
const parts = calls.flat();
|
|
136
|
+
for (const part of parts) {
|
|
137
|
+
assert.ok(part.content.trimEnd().endsWith(".") || part === parts.at(-1), `part ends on a sentence edge: ${part.content}`);
|
|
138
|
+
assert.ok(!part.content.includes("extractionPartOf"), "no marker text is spliced into content");
|
|
139
|
+
assert.ok(!part.content.includes("part"), "no ordinal text is spliced into content");
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("the parent stays buffered until every part drains", async () => {
|
|
144
|
+
const parent = makeTurn(`${"a".repeat(50)}. ${"b".repeat(50)}. ${"c".repeat(45)}`);
|
|
145
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "remnic-parts-retry-"));
|
|
146
|
+
const buffer = new SmartBuffer(
|
|
147
|
+
parseConfig({ memoryDir: root, bufferMaxTurnsPerSession: 2000 }),
|
|
148
|
+
new StorageManager(root),
|
|
149
|
+
);
|
|
150
|
+
try {
|
|
151
|
+
await buffer.addTurn("s1", parent);
|
|
152
|
+
await buffer.flushPendingSave();
|
|
153
|
+
const results = [DEFERRED, DONE, DONE, DONE];
|
|
154
|
+
const drain = new ExtractionDrain({
|
|
155
|
+
config: {
|
|
156
|
+
extractionMinUserTurns: 1,
|
|
157
|
+
extractionMinChars: 0,
|
|
158
|
+
extractionMaxTurnChars: 60,
|
|
159
|
+
extractionChunkDropAfterFailures: 3,
|
|
160
|
+
},
|
|
161
|
+
extractionWindowBudgetChars: () => 100,
|
|
162
|
+
measureRenderedTurns: (turns) => turns.reduce((total, seen) => total + seen.content.length, 0),
|
|
163
|
+
runExtraction: async (turns, options) => {
|
|
164
|
+
const result = results.shift() ?? DONE;
|
|
165
|
+
if (result.status === "completed") {
|
|
166
|
+
await buffer.clearAfterExtraction(
|
|
167
|
+
"s1",
|
|
168
|
+
turns,
|
|
169
|
+
options?.clearMatchingTurns === true ? { allowNonPrefix: true } : undefined,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
},
|
|
174
|
+
getStorage: async () => ({ saveDroppedExtractionChunk: async () => "/recovery/x.json" }),
|
|
175
|
+
buffer: {
|
|
176
|
+
dropExtractionChunk: (bufferKey, turns, dropOptions) =>
|
|
177
|
+
buffer.dropExtractionChunk(bufferKey, turns, dropOptions),
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
const options: DrainRunOptions = {
|
|
181
|
+
bufferKey: "s1",
|
|
182
|
+
clearBufferAfterExtraction: true,
|
|
183
|
+
clearMatchingTurns: true,
|
|
184
|
+
skipUserTurnThreshold: false,
|
|
185
|
+
failOnExtractionFailure: false,
|
|
186
|
+
forceExtractionAttempt: false,
|
|
187
|
+
};
|
|
188
|
+
await drain.run([parent], options);
|
|
189
|
+
assert.deepEqual(
|
|
190
|
+
buffer.getTurns("s1").map((seen) => seen.content),
|
|
191
|
+
[parent.content],
|
|
192
|
+
"the deferred first part leaves the whole parent buffered",
|
|
193
|
+
);
|
|
194
|
+
await drain.run([parent], options);
|
|
195
|
+
assert.deepEqual(buffer.getTurns("s1"), [], "the retry drains all parts and clears the parent");
|
|
196
|
+
} finally {
|
|
197
|
+
await rm(root, { recursive: true, force: true });
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("a turn past the part limit clamps, and the parent leaves through a recovery copy", async () => {
|
|
202
|
+
// 600 chars at a 60-char part budget needs 10 parts; the cap emits 8.
|
|
203
|
+
const parent = makeTurn(Array.from({ length: 10 }, (_v, i) => `${String(i)}${"x".repeat(58)}.`).join(" "));
|
|
204
|
+
const saveCopies: { reason: string; contents: string }[] = [];
|
|
205
|
+
const { calls, buffer } = await withDrain({
|
|
206
|
+
turns: [parent],
|
|
207
|
+
results: Array.from({ length: 8 }, () => DONE),
|
|
208
|
+
budgetChars: 80,
|
|
209
|
+
saveCopies,
|
|
210
|
+
});
|
|
211
|
+
const partMarkers = calls.flat().map((seen) => seen.extractionPartOf?.part);
|
|
212
|
+
assert.deepEqual(partMarkers, [1, 2, 3, 4, 5, 6, 7, 8], "exactly the capped eight parts extract");
|
|
213
|
+
assert.equal(saveCopies.length, 1, "the clamped parent leaves via the recovery-copy path");
|
|
214
|
+
assert.equal(saveCopies[0]?.contents, parent.content, "the recovery copy holds the FULL parent, not slices");
|
|
215
|
+
assert.deepEqual(buffer.getTurns("s1"), [], "the buffer releases the clamped turn");
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test("a part chunk that keeps failing drops the parent with its full content", async () => {
|
|
219
|
+
const parent = makeTurn(`${"a".repeat(50)}. ${"b".repeat(50)}. ${"c".repeat(45)}`);
|
|
220
|
+
const saveCopies: { reason: string; contents: string }[] = [];
|
|
221
|
+
const { buffer } = await withDrain({
|
|
222
|
+
turns: [parent],
|
|
223
|
+
results: [FAILED, FAILED],
|
|
224
|
+
dropAfter: 2,
|
|
225
|
+
runs: 2,
|
|
226
|
+
saveCopies,
|
|
227
|
+
});
|
|
228
|
+
assert.equal(saveCopies.length, 1, "one recovery copy for the dropped parent");
|
|
229
|
+
assert.equal(saveCopies[0]?.contents, parent.content, "the copy preserves the full parent content");
|
|
230
|
+
assert.deepEqual(buffer.getTurns("s1"), [], "the parent is dropped, not the unmatched slice copies");
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
test("an oversized turn inside a fitting window still splits", async () => {
|
|
234
|
+
// A 150-char turn under a 12k-style call budget would previously lose its
|
|
235
|
+
// tail to the per-turn render clamp; the split keeps every byte.
|
|
236
|
+
const parent = makeTurn(`${"a".repeat(50)}. ${"b".repeat(50)}. ${"c".repeat(45)}`);
|
|
237
|
+
const small = makeTurn("short note", { timestamp: "2026-11-17T12:00:01.000Z" });
|
|
238
|
+
const { calls, buffer } = await withDrain({
|
|
239
|
+
turns: [parent, small],
|
|
240
|
+
results: [DONE, DONE, DONE, DONE],
|
|
241
|
+
budgetChars: 12000,
|
|
242
|
+
});
|
|
243
|
+
const text = allExtractedText(calls);
|
|
244
|
+
assert.ok(text.includes(parent.content), "the split turn is fully extracted");
|
|
245
|
+
assert.ok(text.includes(small.content), "the sibling turn is extracted");
|
|
246
|
+
assert.deepEqual(buffer.getTurns("s1"), [], "the whole window drains");
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test("a window of exact duplicates that is also oversized extracts every copy's content", async () => {
|
|
250
|
+
// Dedupe cannot fan representatives out into parts, so the oversized window
|
|
251
|
+
// takes the split path and each buffered identity still clears.
|
|
252
|
+
const content = `${"a".repeat(50)}. ${"b".repeat(50)}. ${"c".repeat(45)}`;
|
|
253
|
+
const first = makeTurn(content);
|
|
254
|
+
const duplicate = makeTurn(content, { timestamp: "2026-11-17T12:00:02.000Z" });
|
|
255
|
+
const { buffer } = await withDrain({
|
|
256
|
+
turns: [first, duplicate],
|
|
257
|
+
results: Array.from({ length: 8 }, () => DONE),
|
|
258
|
+
});
|
|
259
|
+
assert.deepEqual(buffer.getTurns("s1"), [], "both buffered identities drain");
|
|
260
|
+
});
|