@remnic/core 9.49.0 → 9.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abstraction-nodes.d.ts +12 -1
- package/dist/abstraction-nodes.js +9 -2
- package/dist/access-admin-ops-surface.d.ts +10 -10
- package/dist/access-admin-ops-surface.js +48 -48
- package/dist/access-authorization-probe.d.ts +10 -10
- package/dist/access-authorization-probe.js +49 -49
- package/dist/access-boundary.d.ts +10 -10
- package/dist/access-boundary.js +48 -48
- package/dist/access-cli.js +132 -127
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.d.ts +1 -1
- package/dist/access-extraction-force-flush.d.ts +10 -10
- package/dist/access-extraction-force-flush.js +48 -48
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +10 -10
- package/dist/access-http-lifecycle-flush.d.ts +10 -10
- package/dist/access-http-offline-stream.d.ts +10 -10
- package/dist/access-http-query.js +48 -48
- package/dist/access-http.d.ts +10 -10
- package/dist/access-http.js +60 -60
- package/dist/access-identity-continuity-surface.d.ts +8 -8
- package/dist/access-identity-continuity-surface.js +48 -48
- package/dist/access-lcm-surface.d.ts +10 -10
- package/dist/access-lcm-surface.js +48 -48
- package/dist/access-mcp.d.ts +10 -10
- package/dist/access-mcp.js +55 -55
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight--H6HwN85.d.ts → access-namespace-preflight-DuDU301-.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +48 -48
- package/dist/access-observe-write-surface.d.ts +10 -10
- package/dist/access-observe-write-surface.js +48 -48
- package/dist/access-offline-manifest.d.ts +8 -8
- package/dist/access-offline-manifest.js +3 -3
- package/dist/access-operations-batch.js +51 -51
- package/dist/access-operations.d.ts +13 -13
- package/dist/access-operations.js +54 -54
- package/dist/access-recall-concurrency.d.ts +10 -10
- package/dist/access-recall-concurrency.js +48 -48
- package/dist/access-recall-response.d.ts +10 -10
- package/dist/access-recall-response.js +48 -48
- package/dist/access-recall-surface.d.ts +10 -10
- package/dist/access-recall-surface.js +48 -48
- package/dist/access-schema.d.ts +105 -105
- package/dist/access-schema.js +4 -4
- package/dist/{access-service-DvXOzCrM.d.ts → access-service--_3T_v23.d.ts} +7 -7
- package/dist/access-service-helpers.d.ts +10 -10
- package/dist/access-service.d.ts +10 -10
- package/dist/access-service.js +48 -48
- package/dist/access-surface-catalog.d.ts +10 -10
- package/dist/access-wearables-meetings-surface.d.ts +3 -3
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +3 -2
- package/dist/active-recall.js.map +1 -1
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/ambient-provenance.d.ts +1 -1
- package/dist/artifact-search.d.ts +1 -1
- package/dist/{auto-sync-7O6RP2RT.js → auto-sync-QFQGOEO2.js} +4 -4
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +8 -8
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +12 -12
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/buffer.js +4 -4
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/calibration.js +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{capsule-crypto-YO5QJ6L3.js → capsule-crypto-7FJQINUR.js} +2 -2
- package/dist/{capsule-merge-6GFHWECG.js → capsule-merge-KXTRZ23Z.js} +4 -4
- package/dist/{catalog-Iwbk9h5E.d.ts → catalog-DjUmUIal.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-behavior.js +3 -3
- package/dist/causal-chain.js +3 -3
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +16 -16
- package/dist/causal-retrieval.js +3 -3
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/causal-trajectory.d.ts +51 -2
- package/dist/causal-trajectory.js +8 -2
- package/dist/{chunk-EY64JLOM.js → chunk-24BKGKGO.js} +30 -19
- package/dist/chunk-24BKGKGO.js.map +1 -0
- package/dist/{chunk-ICP53SKG.js → chunk-2HIJHXB3.js} +2 -2
- package/dist/{chunk-BXLOS5AJ.js → chunk-2NLLXCJG.js} +2 -2
- package/dist/{chunk-LZGCJSQR.js → chunk-3LD4N2TF.js} +151 -37
- package/dist/chunk-3LD4N2TF.js.map +1 -0
- package/dist/{chunk-5JRC6BYS.js → chunk-47J4EDGR.js} +11 -11
- package/dist/{chunk-2VHLLPTX.js → chunk-4EABKPZS.js} +4 -4
- package/dist/{chunk-RJV6Q2FT.js → chunk-4JWJMRPJ.js} +2 -2
- package/dist/{chunk-MXPB6PJQ.js → chunk-4S3ECH3U.js} +2 -2
- package/dist/{chunk-CGASUJVP.js → chunk-5V6IXHPI.js} +4 -4
- package/dist/{chunk-R5IGA2NH.js → chunk-5XCN4XBU.js} +4 -4
- package/dist/{chunk-2RPJ4NEE.js → chunk-64BHFFKZ.js} +2 -2
- package/dist/{chunk-FQC3DHH2.js → chunk-66SE3BNH.js} +2 -2
- package/dist/{chunk-TERNBNJB.js → chunk-6FC3IZ26.js} +2 -2
- package/dist/{chunk-K7VKAHFE.js → chunk-6XGEBQ3R.js} +4 -4
- package/dist/{chunk-JFLOOTXU.js → chunk-7BLWBSRL.js} +3 -3
- package/dist/{chunk-ABR2HEJO.js → chunk-7NDM2PNK.js} +3 -3
- package/dist/{chunk-JXZ7NLYH.js → chunk-7VWZ4LRW.js} +2 -2
- package/dist/{chunk-RN53QBM4.js → chunk-A4QMKFFO.js} +5 -1
- package/dist/chunk-A4QMKFFO.js.map +1 -0
- package/dist/chunk-ACPCA4NO.js +321 -0
- package/dist/chunk-ACPCA4NO.js.map +1 -0
- package/dist/chunk-AMTEYNYK.js +72 -0
- package/dist/chunk-AMTEYNYK.js.map +1 -0
- package/dist/{chunk-R6YJI3HE.js → chunk-AW4QUFQF.js} +1 -1
- package/dist/{chunk-P65YJEEL.js → chunk-AXFWMRKI.js} +2 -2
- package/dist/{chunk-WG5HSQ4P.js → chunk-BAKXNQ3C.js} +2 -2
- package/dist/{chunk-NM2WP3B7.js → chunk-BJYET5TX.js} +2 -2
- package/dist/{chunk-HLKPRWF4.js → chunk-DATDLJAO.js} +6 -6
- package/dist/chunk-DJUKBGAD.js +260 -0
- package/dist/chunk-DJUKBGAD.js.map +1 -0
- package/dist/{chunk-DX3XRGLH.js → chunk-DQTCGVFK.js} +2 -2
- package/dist/{chunk-IPBNC77A.js → chunk-E633OXMH.js} +11 -11
- package/dist/{chunk-J7T4MX7P.js → chunk-EEAMSNSG.js} +12 -1
- package/dist/chunk-EEAMSNSG.js.map +1 -0
- package/dist/{chunk-Z5UC3OKB.js → chunk-ELQCS47S.js} +7 -7
- package/dist/{chunk-FMXJ555A.js → chunk-EURCX6PS.js} +2 -2
- package/dist/{chunk-MZZR3J6M.js → chunk-FV7YQTN3.js} +2 -2
- package/dist/chunk-G73MCJKL.js +20 -0
- package/dist/chunk-G73MCJKL.js.map +1 -0
- package/dist/{chunk-3R6D33UF.js → chunk-GGBSF2X7.js} +2 -2
- package/dist/{chunk-SYUBB3WM.js → chunk-GKEYXXKX.js} +2 -2
- package/dist/{chunk-5AGR7SAI.js → chunk-GSEPRIZC.js} +3 -3
- package/dist/{chunk-UTVZKHJK.js → chunk-GUKBW4HL.js} +2 -2
- package/dist/chunk-GXSOUIA4.js +293 -0
- package/dist/chunk-GXSOUIA4.js.map +1 -0
- package/dist/{chunk-2F6NP3NT.js → chunk-HDQUQBPW.js} +2 -2
- package/dist/{chunk-6HMYUWXR.js → chunk-HTP6XRUI.js} +2 -2
- package/dist/{chunk-UYUYZ4WY.js → chunk-IARXXZU4.js} +2 -2
- package/dist/{chunk-MNB5RMAY.js → chunk-IIFFC3RL.js} +2 -2
- package/dist/{chunk-VDX2J7OX.js → chunk-IPLYGWQF.js} +6 -6
- package/dist/{chunk-NZBZ7IS2.js → chunk-JDCQK3C5.js} +2 -2
- package/dist/{chunk-C3KVFJH5.js → chunk-JI62YGPI.js} +2 -2
- package/dist/{chunk-LULR4IUW.js → chunk-KATEWTQJ.js} +2 -2
- package/dist/{chunk-BMCHFWGX.js → chunk-KMWYZTIE.js} +2 -2
- package/dist/{chunk-JGSKJHF7.js → chunk-KQS72GCR.js} +2 -2
- package/dist/{chunk-3S63QIFQ.js → chunk-LAQ33B5D.js} +1 -1
- package/dist/chunk-LAQ33B5D.js.map +1 -0
- package/dist/chunk-LNTUXKBT.js +224 -0
- package/dist/chunk-LNTUXKBT.js.map +1 -0
- package/dist/{chunk-2RIWJUSQ.js → chunk-LQKXVQZR.js} +12 -12
- package/dist/{chunk-LQL7ARIC.js → chunk-LTOAJXZB.js} +4 -4
- package/dist/{chunk-QKD65RGL.js → chunk-LYMNZZIM.js} +2 -2
- package/dist/{chunk-W4FBGYGK.js → chunk-M4MP34AQ.js} +189 -5
- package/dist/chunk-M4MP34AQ.js.map +1 -0
- package/dist/{chunk-3PY7VHV7.js → chunk-MCA2X4WH.js} +2 -2
- package/dist/{chunk-S5NZBKKQ.js → chunk-N3CXAYPJ.js} +3 -3
- package/dist/{chunk-WQIHRA5F.js → chunk-N3LL5NEU.js} +2 -2
- package/dist/{chunk-Z4U6U3M3.js → chunk-NKL25FCF.js} +2 -2
- package/dist/{chunk-LMDRGRJ2.js → chunk-NOB2T2FC.js} +2 -2
- package/dist/{chunk-P2OTGMTR.js → chunk-NSGU76YO.js} +2 -2
- package/dist/{chunk-L6DCVUCA.js → chunk-O76MWTVS.js} +2 -2
- package/dist/{chunk-WZFAPHIK.js → chunk-OIOZ6MOP.js} +3 -3
- package/dist/{chunk-DNHVPZOD.js → chunk-P26YHAQH.js} +201 -1
- package/dist/chunk-P26YHAQH.js.map +1 -0
- package/dist/{chunk-UMOO7IY7.js → chunk-P2KBDJJ6.js} +2 -2
- package/dist/{chunk-KVJRXN2E.js → chunk-P4QOYG52.js} +125 -13
- package/dist/chunk-P4QOYG52.js.map +1 -0
- package/dist/chunk-P77QX3ID.js +332 -0
- package/dist/chunk-P77QX3ID.js.map +1 -0
- package/dist/{chunk-SXWHN7GC.js → chunk-PDEKQWDV.js} +2 -2
- package/dist/{chunk-ENEA47UC.js → chunk-PLCHU56K.js} +3 -3
- package/dist/{chunk-IXPKESVP.js → chunk-PWIMF7LP.js} +37 -37
- package/dist/{chunk-RHTO4HTL.js → chunk-PWLB4TRK.js} +2 -2
- package/dist/{chunk-RVYVMQK4.js → chunk-QSYL5CXK.js} +3 -3
- package/dist/{chunk-B6KGGRUL.js → chunk-QWLW3VQH.js} +2 -2
- package/dist/{chunk-YQIVWS7Y.js → chunk-RBPH3GZV.js} +405 -101
- package/dist/chunk-RBPH3GZV.js.map +1 -0
- package/dist/{chunk-JBPKEARU.js → chunk-RKNJBZ55.js} +4 -4
- package/dist/{chunk-QCECHYZL.js → chunk-RVO6TCTU.js} +6 -6
- package/dist/{chunk-SHDZNSK4.js → chunk-S2SJEOTM.js} +2 -2
- package/dist/{chunk-ULWHRQEQ.js → chunk-S75UQ3T3.js} +3 -3
- package/dist/{chunk-LXOM6IQU.js → chunk-SEF4IOFE.js} +2 -2
- package/dist/{chunk-I3YHVVT4.js → chunk-SHYIMIX5.js} +2 -2
- package/dist/{chunk-IZANPXMV.js → chunk-T35UJI5R.js} +86 -82
- package/dist/chunk-T35UJI5R.js.map +1 -0
- package/dist/{chunk-G5OB4XZX.js → chunk-VANZKHTN.js} +4 -4
- package/dist/{chunk-I4TQST3L.js → chunk-VFS3MK5F.js} +2 -2
- package/dist/chunk-VUDMT5CP.js +86 -0
- package/dist/chunk-VUDMT5CP.js.map +1 -0
- package/dist/{chunk-CMQZNEIF.js → chunk-WFLBP5GC.js} +8 -1
- package/dist/chunk-WFLBP5GC.js.map +1 -0
- package/dist/{chunk-SMPVHGHG.js → chunk-WPZX7MEA.js} +3 -3
- package/dist/{chunk-ZRWB5D4H.js → chunk-WT6UL3UA.js} +2 -2
- package/dist/{chunk-DQEMWVMT.js → chunk-X7Y7WX73.js} +1 -1
- package/dist/{chunk-JHMAYABJ.js → chunk-XL3TATMJ.js} +4 -4
- package/dist/{chunk-MC6XO7T4.js → chunk-YLBE6PLR.js} +2 -2
- package/dist/{chunk-OLX2HJFW.js → chunk-YLHM5BQQ.js} +4 -4
- package/dist/{chunk-EZ25VE3G.js → chunk-YNDLCWXS.js} +4 -4
- package/dist/{chunk-GF22HWS2.js → chunk-Z54EM5YZ.js} +4 -4
- package/dist/{chunk-GVX3NAUU.js → chunk-ZDAYWJV6.js} +2 -2
- package/dist/{chunk-EYAIZBLM.js → chunk-ZJIFYUJI.js} +5 -5
- package/dist/{chunk-CNQQMB67.js → chunk-ZN4EYMKJ.js} +2 -2
- package/dist/{cli-PyAUaozE.d.ts → cli-BLNmNEMT.d.ts} +16 -14
- package/dist/cli.d.ts +13 -13
- package/dist/cli.js +96 -94
- package/dist/coding/pre-action-gate.d.ts +66 -0
- package/dist/coding/pre-action-gate.js +22 -0
- package/dist/commitment-ledger.js +2 -2
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +13 -13
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +3 -2
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +12 -12
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +12 -12
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-provenance-check.js +4 -4
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/consolidation-undo.js +3 -3
- package/dist/contradiction/index.d.ts +2 -2
- package/dist/contradiction/index.js +3 -3
- package/dist/converge-config.d.ts +1 -1
- package/dist/convergence-refresh.d.ts +2 -2
- package/dist/convergence-refresh.js +15 -15
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/corpus-watermark.d.ts +1 -1
- package/dist/corpus-watermark.js +23 -23
- package/dist/cue-anchors.d.ts +19 -1
- package/dist/cue-anchors.js +10 -2
- package/dist/dashboard-runtime.js +2 -2
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/dependency-propagation-config.d.ts +10 -0
- package/dist/dependency-propagation-config.js +10 -0
- package/dist/dependency-propagation-config.js.map +1 -0
- package/dist/deterministic-order.d.ts +4 -0
- package/dist/deterministic-order.js +10 -0
- package/dist/deterministic-order.js.map +1 -0
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +12 -12
- package/dist/entity-schema.d.ts +1 -1
- package/dist/evals.js +2 -2
- package/dist/explicit-capture.d.ts +8 -8
- package/dist/explicit-capture.js +6 -6
- package/dist/external-wiki-access.d.ts +10 -10
- package/dist/external-wiki-access.js +49 -49
- package/dist/external-wiki-collection-registration.d.ts +1 -1
- package/dist/external-wiki-collection.d.ts +1 -1
- package/dist/external-wiki-mcp-tools.d.ts +10 -10
- package/dist/extraction-error-classification.d.ts +1 -1
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction-liveness.d.ts +1 -1
- package/dist/extraction-normalization.d.ts +14 -0
- package/dist/extraction-normalization.js +22 -0
- package/dist/extraction-normalization.js.map +1 -0
- package/dist/extraction-prompt.d.ts +4 -3
- package/dist/extraction-prompt.js +3 -1
- package/dist/extraction-source-grounding-rules.d.ts +1 -1
- package/dist/extraction-source-grounding.d.ts +1 -1
- package/dist/extraction.d.ts +18 -1
- package/dist/extraction.js +21 -19
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/{first-start-migration-ZSHEFEI3.js → first-start-migration-626C5554.js} +5 -5
- package/dist/{forget-DNAJ66ZD.js → forget-GJ42LCBW.js} +2 -2
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/harmonic-construction.d.ts +43 -0
- package/dist/harmonic-construction.js +26 -0
- package/dist/harmonic-construction.js.map +1 -0
- package/dist/harmonic-retrieval.d.ts +1 -0
- package/dist/harmonic-retrieval.js +10 -4
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/index.d.ts +698 -696
- package/dist/index.js +207 -161
- package/dist/intent.d.ts +1 -1
- package/dist/json-store.d.ts +15 -1
- package/dist/json-store.js +11 -3
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +4 -4
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/maintenance/archive-observations.js +2 -2
- package/dist/maintenance/atomic-file.d.ts +5 -0
- package/dist/maintenance/atomic-file.js +12 -0
- package/dist/maintenance/atomic-file.js.map +1 -0
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +12 -12
- package/dist/maintenance/migrate-observations.js +3 -3
- package/dist/maintenance/observation-ledger-utils.d.ts +1 -1
- package/dist/maintenance/observation-ledger-utils.js +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +13 -13
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +14 -14
- package/dist/maintenance/rebuild-observations.js +3 -3
- package/dist/{maintenance-j7sfNQdK.d.ts → maintenance-DKbKZi3u.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +10 -10
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-snapshot.d.ts +1 -1
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +3 -3
- package/dist/namespaces/migrate.js +22 -22
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +9 -9
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +12 -12
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/objective-state-writers.js +3 -3
- package/dist/objective-state.js +2 -2
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/offline-sync-impression-drain.js +2 -2
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +24 -24
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +33 -32
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +18 -18
- package/dist/{orchestrator-Haa9xVPV.d.ts → orchestrator-BRwD7ceU.d.ts} +7 -7
- package/dist/orchestrator.d.ts +8 -8
- package/dist/orchestrator.js +132 -127
- package/dist/page-versioning.js +3 -3
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-1h2GpiHP.d.ts → pipeline-DC-1C9T8.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/{qmd-UdwoF71D.d.ts → qmd-DdeCEZdb.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/qmd.js +4 -4
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-state.js +2 -2
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -1
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/cursor.d.ts +1 -1
- package/dist/reconcile/manifest.d.ts +1 -1
- package/dist/reconcile/plan.d.ts +1 -1
- package/dist/relevance.js +2 -2
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/replica-divergence.d.ts +1 -1
- package/dist/replica-peers-config.d.ts +1 -1
- package/dist/{resolution-3K27T4VO.js → resolution-MDPNOEG6.js} +4 -4
- package/dist/resolution-MDPNOEG6.js.map +1 -0
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +8 -7
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/salvage-envelope.d.ts +1 -1
- package/dist/salvage-envelope.js +3 -3
- package/dist/schemas.d.ts +213 -116
- package/dist/schemas.js +1 -1
- package/dist/{scope-profiles-APjhSe-w.d.ts → scope-profiles-BXVq4Jv0.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/factory.js +8 -8
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +13 -13
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/lancedb-backend.js +2 -2
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.js +2 -2
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/orama-backend.js +2 -2
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-CrySDbk3.d.ts → semantic-consolidation-CGYxfa8F.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +13 -13
- package/dist/semantic-rule-promotion.js +12 -12
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +12 -12
- package/dist/{service-Da_BI4S8.d.ts → service-CBDBQFCN.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +11 -11
- package/dist/signal.d.ts +1 -1
- package/dist/source-agent-qualifier.d.ts +1 -1
- package/dist/source-agent-qualifier.js +16 -16
- package/dist/{storage-D1apCiCS.d.ts → storage-V--MQi7w.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +11 -11
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.d.ts +13 -2
- package/dist/temporal-supersession.js +1 -1
- package/dist/temporal-timeline-recall.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +2 -2
- package/dist/tier-routing.d.ts +1 -1
- package/dist/{tier-stats-OPTSBNRH.js → tier-stats-2JCZYEF7.js} +5 -5
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/autodetect.js +1 -1
- package/dist/transfer/backup.js +2 -2
- package/dist/transfer/capsule-export.js +3 -3
- package/dist/transfer/capsule-import.js +5 -5
- package/dist/transfer/types.d.ts +66 -66
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/trust-zones.js +2 -2
- package/dist/{types-D_Au9qJO.d.ts → types-D_a6Sqjz.d.ts} +25 -8
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-learner.js +3 -3
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/utility-runtime.js +4 -4
- package/dist/utility-telemetry.js +2 -2
- package/dist/verified-recall.js +12 -12
- package/dist/work-product-ledger.js +2 -2
- package/dist/write-envelope.d.ts +1 -1
- package/dist/write-envelope.js +2 -2
- package/package.json +32 -2
- package/src/abstraction-nodes.ts +182 -4
- package/src/causal-trajectory.ts +258 -3
- package/src/cli/harmonic-search.ts +23 -0
- package/src/cli/research-status-commands.ts +2 -1
- package/src/cli.ts +1 -24
- package/src/coding/pre-action-gate.test.ts +516 -0
- package/src/coding/pre-action-gate.ts +320 -0
- package/src/config.test.ts +85 -0
- package/src/config.ts +2 -0
- package/src/cue-anchors.test.ts +90 -0
- package/src/cue-anchors.ts +264 -11
- package/src/dependency-frontmatter.test.ts +83 -0
- package/src/dependency-propagation-config.ts +94 -0
- package/src/deterministic-order.ts +14 -0
- package/src/extraction-normalization.ts +71 -0
- package/src/extraction-prompt.ts +45 -11
- package/src/extraction.ts +48 -32
- package/src/faithfulness-graph-guard.test.ts +27 -0
- package/src/harmonic-construction.test.ts +1799 -0
- package/src/harmonic-construction.ts +367 -0
- package/src/harmonic-retrieval.ts +166 -25
- package/src/index.ts +4 -5
- package/src/json-store.ts +354 -12
- package/src/orchestration/consolidation-run.ts +192 -0
- package/src/orchestration/contradiction-linking-coordinator.ts +35 -1
- package/src/orchestration/dependency-propagation-triggers.test.ts +286 -0
- package/src/orchestration/dependency-propagation.test.ts +487 -0
- package/src/orchestration/dependency-propagation.ts +263 -0
- package/src/orchestration/dependency-revalidation.ts +173 -0
- package/src/orchestration/extraction-persist-deps.ts +93 -0
- package/src/orchestration/extraction-persist.ts +101 -94
- package/src/orchestration/harmonic-construction-persist.ts +86 -0
- package/src/orchestration/recall-internal.ts +1 -0
- package/src/orchestrator.ts +2 -1
- package/src/schemas.ts +15 -0
- package/src/storage.ts +14 -0
- package/src/temporal-supersession.ts +29 -1
- package/src/testing/orchestrator-lite.ts +27 -8
- package/src/testing/subjects/extraction-lifecycle.test.ts +91 -50
- package/src/types.ts +22 -7
- package/dist/chunk-3S63QIFQ.js.map +0 -1
- package/dist/chunk-CMQZNEIF.js.map +0 -1
- package/dist/chunk-DNHVPZOD.js.map +0 -1
- package/dist/chunk-EY64JLOM.js.map +0 -1
- package/dist/chunk-FZZ2QTJI.js +0 -111
- package/dist/chunk-FZZ2QTJI.js.map +0 -1
- package/dist/chunk-IZANPXMV.js.map +0 -1
- package/dist/chunk-J7T4MX7P.js.map +0 -1
- package/dist/chunk-KVJRXN2E.js.map +0 -1
- package/dist/chunk-LPSF4OQH.js +0 -47
- package/dist/chunk-LPSF4OQH.js.map +0 -1
- package/dist/chunk-LZGCJSQR.js.map +0 -1
- package/dist/chunk-OADWQ5CR.js +0 -115
- package/dist/chunk-OADWQ5CR.js.map +0 -1
- package/dist/chunk-RN53QBM4.js.map +0 -1
- package/dist/chunk-W4FBGYGK.js.map +0 -1
- package/dist/chunk-YQIVWS7Y.js.map +0 -1
- /package/dist/{auto-sync-7O6RP2RT.js.map → auto-sync-QFQGOEO2.js.map} +0 -0
- /package/dist/{capsule-crypto-YO5QJ6L3.js.map → capsule-crypto-7FJQINUR.js.map} +0 -0
- /package/dist/{capsule-merge-6GFHWECG.js.map → capsule-merge-KXTRZ23Z.js.map} +0 -0
- /package/dist/{chunk-ICP53SKG.js.map → chunk-2HIJHXB3.js.map} +0 -0
- /package/dist/{chunk-BXLOS5AJ.js.map → chunk-2NLLXCJG.js.map} +0 -0
- /package/dist/{chunk-5JRC6BYS.js.map → chunk-47J4EDGR.js.map} +0 -0
- /package/dist/{chunk-2VHLLPTX.js.map → chunk-4EABKPZS.js.map} +0 -0
- /package/dist/{chunk-RJV6Q2FT.js.map → chunk-4JWJMRPJ.js.map} +0 -0
- /package/dist/{chunk-MXPB6PJQ.js.map → chunk-4S3ECH3U.js.map} +0 -0
- /package/dist/{chunk-CGASUJVP.js.map → chunk-5V6IXHPI.js.map} +0 -0
- /package/dist/{chunk-R5IGA2NH.js.map → chunk-5XCN4XBU.js.map} +0 -0
- /package/dist/{chunk-2RPJ4NEE.js.map → chunk-64BHFFKZ.js.map} +0 -0
- /package/dist/{chunk-FQC3DHH2.js.map → chunk-66SE3BNH.js.map} +0 -0
- /package/dist/{chunk-TERNBNJB.js.map → chunk-6FC3IZ26.js.map} +0 -0
- /package/dist/{chunk-K7VKAHFE.js.map → chunk-6XGEBQ3R.js.map} +0 -0
- /package/dist/{chunk-JFLOOTXU.js.map → chunk-7BLWBSRL.js.map} +0 -0
- /package/dist/{chunk-ABR2HEJO.js.map → chunk-7NDM2PNK.js.map} +0 -0
- /package/dist/{chunk-JXZ7NLYH.js.map → chunk-7VWZ4LRW.js.map} +0 -0
- /package/dist/{chunk-R6YJI3HE.js.map → chunk-AW4QUFQF.js.map} +0 -0
- /package/dist/{chunk-P65YJEEL.js.map → chunk-AXFWMRKI.js.map} +0 -0
- /package/dist/{chunk-WG5HSQ4P.js.map → chunk-BAKXNQ3C.js.map} +0 -0
- /package/dist/{chunk-NM2WP3B7.js.map → chunk-BJYET5TX.js.map} +0 -0
- /package/dist/{chunk-HLKPRWF4.js.map → chunk-DATDLJAO.js.map} +0 -0
- /package/dist/{chunk-DX3XRGLH.js.map → chunk-DQTCGVFK.js.map} +0 -0
- /package/dist/{chunk-IPBNC77A.js.map → chunk-E633OXMH.js.map} +0 -0
- /package/dist/{chunk-Z5UC3OKB.js.map → chunk-ELQCS47S.js.map} +0 -0
- /package/dist/{chunk-FMXJ555A.js.map → chunk-EURCX6PS.js.map} +0 -0
- /package/dist/{chunk-MZZR3J6M.js.map → chunk-FV7YQTN3.js.map} +0 -0
- /package/dist/{chunk-3R6D33UF.js.map → chunk-GGBSF2X7.js.map} +0 -0
- /package/dist/{chunk-SYUBB3WM.js.map → chunk-GKEYXXKX.js.map} +0 -0
- /package/dist/{chunk-5AGR7SAI.js.map → chunk-GSEPRIZC.js.map} +0 -0
- /package/dist/{chunk-UTVZKHJK.js.map → chunk-GUKBW4HL.js.map} +0 -0
- /package/dist/{chunk-2F6NP3NT.js.map → chunk-HDQUQBPW.js.map} +0 -0
- /package/dist/{chunk-6HMYUWXR.js.map → chunk-HTP6XRUI.js.map} +0 -0
- /package/dist/{chunk-UYUYZ4WY.js.map → chunk-IARXXZU4.js.map} +0 -0
- /package/dist/{chunk-MNB5RMAY.js.map → chunk-IIFFC3RL.js.map} +0 -0
- /package/dist/{chunk-VDX2J7OX.js.map → chunk-IPLYGWQF.js.map} +0 -0
- /package/dist/{chunk-NZBZ7IS2.js.map → chunk-JDCQK3C5.js.map} +0 -0
- /package/dist/{chunk-C3KVFJH5.js.map → chunk-JI62YGPI.js.map} +0 -0
- /package/dist/{chunk-LULR4IUW.js.map → chunk-KATEWTQJ.js.map} +0 -0
- /package/dist/{chunk-BMCHFWGX.js.map → chunk-KMWYZTIE.js.map} +0 -0
- /package/dist/{chunk-JGSKJHF7.js.map → chunk-KQS72GCR.js.map} +0 -0
- /package/dist/{chunk-2RIWJUSQ.js.map → chunk-LQKXVQZR.js.map} +0 -0
- /package/dist/{chunk-LQL7ARIC.js.map → chunk-LTOAJXZB.js.map} +0 -0
- /package/dist/{chunk-QKD65RGL.js.map → chunk-LYMNZZIM.js.map} +0 -0
- /package/dist/{chunk-3PY7VHV7.js.map → chunk-MCA2X4WH.js.map} +0 -0
- /package/dist/{chunk-S5NZBKKQ.js.map → chunk-N3CXAYPJ.js.map} +0 -0
- /package/dist/{chunk-WQIHRA5F.js.map → chunk-N3LL5NEU.js.map} +0 -0
- /package/dist/{chunk-Z4U6U3M3.js.map → chunk-NKL25FCF.js.map} +0 -0
- /package/dist/{chunk-LMDRGRJ2.js.map → chunk-NOB2T2FC.js.map} +0 -0
- /package/dist/{chunk-P2OTGMTR.js.map → chunk-NSGU76YO.js.map} +0 -0
- /package/dist/{chunk-L6DCVUCA.js.map → chunk-O76MWTVS.js.map} +0 -0
- /package/dist/{chunk-WZFAPHIK.js.map → chunk-OIOZ6MOP.js.map} +0 -0
- /package/dist/{chunk-UMOO7IY7.js.map → chunk-P2KBDJJ6.js.map} +0 -0
- /package/dist/{chunk-SXWHN7GC.js.map → chunk-PDEKQWDV.js.map} +0 -0
- /package/dist/{chunk-ENEA47UC.js.map → chunk-PLCHU56K.js.map} +0 -0
- /package/dist/{chunk-IXPKESVP.js.map → chunk-PWIMF7LP.js.map} +0 -0
- /package/dist/{chunk-RHTO4HTL.js.map → chunk-PWLB4TRK.js.map} +0 -0
- /package/dist/{chunk-RVYVMQK4.js.map → chunk-QSYL5CXK.js.map} +0 -0
- /package/dist/{chunk-B6KGGRUL.js.map → chunk-QWLW3VQH.js.map} +0 -0
- /package/dist/{chunk-JBPKEARU.js.map → chunk-RKNJBZ55.js.map} +0 -0
- /package/dist/{chunk-QCECHYZL.js.map → chunk-RVO6TCTU.js.map} +0 -0
- /package/dist/{chunk-SHDZNSK4.js.map → chunk-S2SJEOTM.js.map} +0 -0
- /package/dist/{chunk-ULWHRQEQ.js.map → chunk-S75UQ3T3.js.map} +0 -0
- /package/dist/{chunk-LXOM6IQU.js.map → chunk-SEF4IOFE.js.map} +0 -0
- /package/dist/{chunk-I3YHVVT4.js.map → chunk-SHYIMIX5.js.map} +0 -0
- /package/dist/{chunk-G5OB4XZX.js.map → chunk-VANZKHTN.js.map} +0 -0
- /package/dist/{chunk-I4TQST3L.js.map → chunk-VFS3MK5F.js.map} +0 -0
- /package/dist/{chunk-SMPVHGHG.js.map → chunk-WPZX7MEA.js.map} +0 -0
- /package/dist/{chunk-ZRWB5D4H.js.map → chunk-WT6UL3UA.js.map} +0 -0
- /package/dist/{chunk-DQEMWVMT.js.map → chunk-X7Y7WX73.js.map} +0 -0
- /package/dist/{chunk-JHMAYABJ.js.map → chunk-XL3TATMJ.js.map} +0 -0
- /package/dist/{chunk-MC6XO7T4.js.map → chunk-YLBE6PLR.js.map} +0 -0
- /package/dist/{chunk-OLX2HJFW.js.map → chunk-YLHM5BQQ.js.map} +0 -0
- /package/dist/{chunk-EZ25VE3G.js.map → chunk-YNDLCWXS.js.map} +0 -0
- /package/dist/{chunk-GF22HWS2.js.map → chunk-Z54EM5YZ.js.map} +0 -0
- /package/dist/{chunk-GVX3NAUU.js.map → chunk-ZDAYWJV6.js.map} +0 -0
- /package/dist/{chunk-EYAIZBLM.js.map → chunk-ZJIFYUJI.js.map} +0 -0
- /package/dist/{chunk-CNQQMB67.js.map → chunk-ZN4EYMKJ.js.map} +0 -0
- /package/dist/{resolution-3K27T4VO.js.map → coding/pre-action-gate.js.map} +0 -0
- /package/dist/{first-start-migration-ZSHEFEI3.js.map → first-start-migration-626C5554.js.map} +0 -0
- /package/dist/{forget-DNAJ66ZD.js.map → forget-GJ42LCBW.js.map} +0 -0
- /package/dist/{tier-stats-OPTSBNRH.js.map → tier-stats-2JCZYEF7.js.map} +0 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readCausalTrajectoryRecordsStrict,
|
|
3
|
+
readCausalTrajectoryRevisionToken,
|
|
4
|
+
resolveCausalTrajectoryStoreDir
|
|
5
|
+
} from "./chunk-M4MP34AQ.js";
|
|
6
|
+
|
|
7
|
+
// src/coding/pre-action-gate.ts
|
|
8
|
+
import { createHash } from "crypto";
|
|
9
|
+
import path from "path";
|
|
10
|
+
var PRE_ACTION_FINGERPRINT_VERSION = 1;
|
|
11
|
+
var PRE_ACTION_WARNING_VERSION = 1;
|
|
12
|
+
var PRE_ACTION_GATE_DEFAULT_TIMEOUT_MS = 50;
|
|
13
|
+
var ACTION_STRATEGIES = /* @__PURE__ */ new Set([
|
|
14
|
+
"RUN_CHECK",
|
|
15
|
+
"CHANGE_IMPLEMENTATION",
|
|
16
|
+
"CHANGE_TEST",
|
|
17
|
+
"CHANGE_CONFIGURATION",
|
|
18
|
+
"CHANGE_DEPENDENCY",
|
|
19
|
+
"INVALIDATE_CACHE",
|
|
20
|
+
"RETRY_ACTION",
|
|
21
|
+
"INSPECT_STATE"
|
|
22
|
+
]);
|
|
23
|
+
var EDIT_KINDS = /* @__PURE__ */ new Set(["create", "update", "delete", "rename"]);
|
|
24
|
+
var MAX_COMMAND_CHARS = 128;
|
|
25
|
+
var MAX_ARGUMENTS = 32;
|
|
26
|
+
var MAX_ARGUMENT_CHARS = 128;
|
|
27
|
+
var MAX_PATH_CHARS = 512;
|
|
28
|
+
var MAX_SLOT_CHARS = 128;
|
|
29
|
+
var MAX_CITATION_CHARS = 180;
|
|
30
|
+
function bound(value, max, field) {
|
|
31
|
+
const normalized = value.trim();
|
|
32
|
+
if (normalized.length > max) throw new Error(`${field} exceeds ${max} characters`);
|
|
33
|
+
return normalized;
|
|
34
|
+
}
|
|
35
|
+
function sanitizePayloadString(input) {
|
|
36
|
+
return input.replace(/(?:\/home\/[^\s/]+|\/Users\/[^\s/]+|[A-Za-z]:\\Users\\[^\s\\]+)/g, "$HOME").replace(/sk-[a-zA-Z0-9_-]{10,}/g, "<secret>").replace(/bearer\s+[a-zA-Z0-9._-]+/gi, "bearer <secret>").trim();
|
|
37
|
+
}
|
|
38
|
+
function normalizeRepositoryPath(filePath, codingContext) {
|
|
39
|
+
const root = path.resolve(codingContext.rootPath);
|
|
40
|
+
const absolute = path.isAbsolute(filePath) ? path.resolve(filePath) : path.resolve(root, filePath);
|
|
41
|
+
const relative = path.relative(root, absolute);
|
|
42
|
+
if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
43
|
+
throw new Error("edit path must be contained by codingContext.rootPath");
|
|
44
|
+
}
|
|
45
|
+
return bound(relative.split(path.sep).join("/"), MAX_PATH_CHARS, "repo-relative path");
|
|
46
|
+
}
|
|
47
|
+
function normalizeCommandArgument(argument, codingContext, secretValue) {
|
|
48
|
+
const value = bound(sanitizePayloadString(argument), MAX_ARGUMENT_CHARS, "command argument");
|
|
49
|
+
if (secretValue || value.includes("<secret>")) return "<secret>";
|
|
50
|
+
if (/^--(?:token|key|secret|password|authorization)=/i.test(value)) {
|
|
51
|
+
return `${value.slice(0, value.indexOf("=") + 1)}<secret>`;
|
|
52
|
+
}
|
|
53
|
+
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value)) return "<uuid>";
|
|
54
|
+
if (/^[0-9a-f]{7,64}$/i.test(value)) return "<sha>";
|
|
55
|
+
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/.test(value)) return "<timestamp>";
|
|
56
|
+
if (/^\d+(?:\.\d+)?(?:ms|s|m|h|d)$/.test(value)) return "<duration>";
|
|
57
|
+
if (/^-?\d+(?:\.\d+)?$/.test(value)) return "<number>";
|
|
58
|
+
const pathLike = path.isAbsolute(value) || !/^[a-z][a-z0-9+.-]*:\/\//i.test(value) && /[\\/]/.test(value) && !value.startsWith("--");
|
|
59
|
+
if (pathLike) {
|
|
60
|
+
let relative;
|
|
61
|
+
try {
|
|
62
|
+
relative = normalizeRepositoryPath(value, codingContext);
|
|
63
|
+
} catch {
|
|
64
|
+
return "<external-path>";
|
|
65
|
+
}
|
|
66
|
+
return /(?:^|\/)(?:tmp|temp)(?:\/|$)|\.tmp$/i.test(relative) ? `<repo-temp-path:${relative}>` : `<repo-path:${relative}>`;
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
function normalizeActionIntent(intent, strategyId, codingContext) {
|
|
71
|
+
if (!ACTION_STRATEGIES.has(strategyId)) throw new Error(`unsupported action strategy: ${strategyId}`);
|
|
72
|
+
let payload;
|
|
73
|
+
if (intent.kind === "command") {
|
|
74
|
+
const command = bound(sanitizePayloadString(intent.command), MAX_COMMAND_CHARS, "command");
|
|
75
|
+
const args = intent.args ?? [];
|
|
76
|
+
if (args.length > MAX_ARGUMENTS) throw new Error(`command args exceed ${MAX_ARGUMENTS} entries`);
|
|
77
|
+
const normalizedArgs = args.map((argument, index) => {
|
|
78
|
+
const prior = index > 0 ? args[index - 1] : void 0;
|
|
79
|
+
const secretValue = prior !== void 0 && /^--(?:token|key|secret|password|authorization)$/i.test(prior);
|
|
80
|
+
return normalizeCommandArgument(argument, codingContext, secretValue);
|
|
81
|
+
});
|
|
82
|
+
payload = JSON.stringify({ kind: "command", strategyId, command, args: normalizedArgs });
|
|
83
|
+
} else if (intent.kind === "edit") {
|
|
84
|
+
if (!EDIT_KINDS.has(intent.editKind)) throw new Error(`unsupported edit kind: ${intent.editKind}`);
|
|
85
|
+
const relativePath = normalizeRepositoryPath(intent.filePath, codingContext);
|
|
86
|
+
payload = JSON.stringify({
|
|
87
|
+
kind: "edit",
|
|
88
|
+
strategyId,
|
|
89
|
+
filePath: relativePath,
|
|
90
|
+
editKind: intent.editKind,
|
|
91
|
+
symbol: intent.symbol ? bound(intent.symbol, MAX_SLOT_CHARS, "symbol") : void 0,
|
|
92
|
+
range: intent.range ? bound(intent.range, MAX_SLOT_CHARS, "range") : void 0,
|
|
93
|
+
diffShape: intent.diffShape ? bound(intent.diffShape, MAX_SLOT_CHARS, "diffShape") : void 0
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
throw new Error("action intent kind must be command or edit");
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
kind: intent.kind,
|
|
100
|
+
strategyId,
|
|
101
|
+
fingerprint: `v1:sha256:${createHash("sha256").update(payload).digest("hex")}`
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function matchTrajectory(record, projectId, normalized) {
|
|
105
|
+
const identity = record.actionIdentity;
|
|
106
|
+
return record.outcomeKind === "failure" && record.codingContext?.projectId === projectId && identity?.fingerprintVersion === PRE_ACTION_FINGERPRINT_VERSION && identity.strategyId === normalized.strategyId && identity.fingerprint === normalized.fingerprint;
|
|
107
|
+
}
|
|
108
|
+
function boundedCitation(value, fallback) {
|
|
109
|
+
const sanitized = sanitizePayloadString(value ?? fallback).replace(/\s+/g, " ");
|
|
110
|
+
return sanitized.slice(0, MAX_CITATION_CHARS);
|
|
111
|
+
}
|
|
112
|
+
var PreActionFailureGate = class {
|
|
113
|
+
cache = /* @__PURE__ */ new Map();
|
|
114
|
+
maxCacheSize;
|
|
115
|
+
readStrict;
|
|
116
|
+
getRevision;
|
|
117
|
+
clock;
|
|
118
|
+
timeoutMs;
|
|
119
|
+
constructor(deps = {}) {
|
|
120
|
+
this.readStrict = deps.readStrict ?? readCausalTrajectoryRecordsStrict;
|
|
121
|
+
this.getRevision = deps.getRevision ?? readCausalTrajectoryRevisionToken;
|
|
122
|
+
this.clock = deps.clock ?? Date.now;
|
|
123
|
+
this.maxCacheSize = deps.maxCacheSize ?? 500;
|
|
124
|
+
this.timeoutMs = Math.max(1, deps.timeoutMs ?? PRE_ACTION_GATE_DEFAULT_TIMEOUT_MS);
|
|
125
|
+
}
|
|
126
|
+
clearCache() {
|
|
127
|
+
this.cache.clear();
|
|
128
|
+
}
|
|
129
|
+
async evaluate(request) {
|
|
130
|
+
const deadline = this.clock() + this.timeoutMs;
|
|
131
|
+
const controller = new AbortController();
|
|
132
|
+
const abortFromExternal = () => controller.abort();
|
|
133
|
+
request.signal?.addEventListener("abort", abortFromExternal, { once: true });
|
|
134
|
+
if (request.signal?.aborted) controller.abort();
|
|
135
|
+
let resolveTimeout;
|
|
136
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
137
|
+
resolveTimeout = resolve;
|
|
138
|
+
});
|
|
139
|
+
const timer = setTimeout(() => {
|
|
140
|
+
controller.abort();
|
|
141
|
+
resolveTimeout({ status: "ERROR_FAIL_OPEN", reason: `PreActionFailureGate timed out after ${this.timeoutMs}ms` });
|
|
142
|
+
}, this.timeoutMs);
|
|
143
|
+
try {
|
|
144
|
+
return await Promise.race([
|
|
145
|
+
this.evaluateInternal(request, controller.signal, deadline),
|
|
146
|
+
timeoutPromise
|
|
147
|
+
]);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
return { status: "ERROR_FAIL_OPEN", reason: error instanceof Error ? error.message : String(error) };
|
|
150
|
+
} finally {
|
|
151
|
+
clearTimeout(timer);
|
|
152
|
+
request.signal?.removeEventListener("abort", abortFromExternal);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async evaluateInternal(request, signal, deadline) {
|
|
156
|
+
if (!request.memoryDir?.trim()) return { status: "ERROR_FAIL_OPEN", reason: "memoryDir is required" };
|
|
157
|
+
if (!request.sessionKey?.trim()) return { status: "ERROR_FAIL_OPEN", reason: "sessionKey is required" };
|
|
158
|
+
if (!request.codingContext?.projectId?.trim() || !request.codingContext.rootPath?.trim()) {
|
|
159
|
+
return { status: "ERROR_FAIL_OPEN", reason: "codingContext with projectId and rootPath is required" };
|
|
160
|
+
}
|
|
161
|
+
let normalized;
|
|
162
|
+
try {
|
|
163
|
+
normalized = normalizeActionIntent(request.intent, request.strategyId, request.codingContext);
|
|
164
|
+
} catch (error) {
|
|
165
|
+
return { status: "ERROR_FAIL_OPEN", reason: error instanceof Error ? error.message : String(error) };
|
|
166
|
+
}
|
|
167
|
+
const revisionOptions = {
|
|
168
|
+
memoryDir: request.memoryDir,
|
|
169
|
+
causalTrajectoryStoreDir: request.causalTrajectoryStoreDir
|
|
170
|
+
};
|
|
171
|
+
const preRevision = await this.getRevision(revisionOptions);
|
|
172
|
+
const branch = request.codingContext.branch ?? "";
|
|
173
|
+
const storeId = createHash("sha256").update(resolveCausalTrajectoryStoreDir(request.memoryDir, request.causalTrajectoryStoreDir)).digest("hex");
|
|
174
|
+
const cacheKey = createHash("sha256").update(JSON.stringify([
|
|
175
|
+
request.codingContext.projectId,
|
|
176
|
+
branch,
|
|
177
|
+
request.sessionKey,
|
|
178
|
+
PRE_ACTION_FINGERPRINT_VERSION,
|
|
179
|
+
preRevision,
|
|
180
|
+
normalized.fingerprint,
|
|
181
|
+
storeId
|
|
182
|
+
])).digest("hex");
|
|
183
|
+
const cached = this.cache.get(cacheKey);
|
|
184
|
+
if (cached) return cached;
|
|
185
|
+
if (signal.aborted || this.clock() >= deadline) return { status: "ERROR_FAIL_OPEN", reason: "deadline exceeded" };
|
|
186
|
+
const scan = await this.readStrict({ ...revisionOptions, signal });
|
|
187
|
+
if (signal.aborted || this.clock() >= deadline) return { status: "ERROR_FAIL_OPEN", reason: "deadline exceeded" };
|
|
188
|
+
if (scan.invalidTrajectories.length > 0) {
|
|
189
|
+
return { status: "ERROR_FAIL_OPEN", reason: `store contains ${scan.invalidTrajectories.length} invalid record(s)` };
|
|
190
|
+
}
|
|
191
|
+
const postRevision = await this.getRevision(revisionOptions);
|
|
192
|
+
const stableRevision = preRevision === postRevision;
|
|
193
|
+
const match = scan.trajectories.filter((record) => matchTrajectory(record, request.codingContext.projectId, normalized)).sort((left, right) => {
|
|
194
|
+
const recordedAtOrder = right.recordedAt.localeCompare(left.recordedAt);
|
|
195
|
+
return recordedAtOrder !== 0 ? recordedAtOrder : left.trajectoryId.localeCompare(right.trajectoryId);
|
|
196
|
+
})[0];
|
|
197
|
+
const result = match ? {
|
|
198
|
+
status: "MATCH_WARN",
|
|
199
|
+
advisoryText: `[PreActionFailureGate ${PRE_ACTION_WARNING_VERSION}] A similar action failed before. Prior act: "${boundedCitation(match.actionSummary, "recorded action")}". Failure: "${boundedCitation(match.outcomeSummary, "recorded failure")}". Next safe check: "${boundedCitation(match.followUpSummary, "verify prerequisites before retrying")}".`,
|
|
200
|
+
fingerprint: normalized.fingerprint,
|
|
201
|
+
matchedTrajectoryId: match.trajectoryId,
|
|
202
|
+
revision: postRevision
|
|
203
|
+
} : { status: "NO_MATCH", fingerprint: normalized.fingerprint, revision: postRevision };
|
|
204
|
+
if (stableRevision && !signal.aborted && this.clock() < deadline) this.setCache(cacheKey, result);
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
setCache(key, result) {
|
|
208
|
+
if (this.cache.size >= this.maxCacheSize) {
|
|
209
|
+
const oldest = this.cache.keys().next().value;
|
|
210
|
+
if (oldest !== void 0) this.cache.delete(oldest);
|
|
211
|
+
}
|
|
212
|
+
this.cache.set(key, result);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export {
|
|
217
|
+
PRE_ACTION_FINGERPRINT_VERSION,
|
|
218
|
+
PRE_ACTION_WARNING_VERSION,
|
|
219
|
+
PRE_ACTION_GATE_DEFAULT_TIMEOUT_MS,
|
|
220
|
+
sanitizePayloadString,
|
|
221
|
+
normalizeActionIntent,
|
|
222
|
+
PreActionFailureGate
|
|
223
|
+
};
|
|
224
|
+
//# sourceMappingURL=chunk-LNTUXKBT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/coding/pre-action-gate.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport {\n readCausalTrajectoryRecordsStrict,\n readCausalTrajectoryRevisionToken,\n resolveCausalTrajectoryStoreDir,\n type ActionIntent,\n type ActionStrategyId,\n type CausalTrajectoryRecord,\n type CausalTrajectoryStrictReadResult,\n type EditKind,\n} from \"../causal-trajectory.js\";\nimport type { CodingContext } from \"../types.js\";\n\nexport const PRE_ACTION_FINGERPRINT_VERSION = 1;\nexport const PRE_ACTION_WARNING_VERSION = 1;\nexport const PRE_ACTION_GATE_DEFAULT_TIMEOUT_MS = 50;\n\nexport type PreActionGateStatus = \"NO_MATCH\" | \"MATCH_WARN\" | \"ERROR_FAIL_OPEN\";\n\nexport interface PreActionGateRequest {\n sessionKey: string;\n strategyId: ActionStrategyId;\n intent: ActionIntent;\n codingContext: CodingContext;\n memoryDir?: string;\n causalTrajectoryStoreDir?: string;\n signal?: AbortSignal;\n}\n\nexport interface PreActionGateResult {\n status: PreActionGateStatus;\n reason?: string;\n advisoryText?: string;\n fingerprint?: string;\n matchedTrajectoryId?: string;\n revision?: string;\n}\n\nexport interface NormalizedActionIntent {\n kind: \"command\" | \"edit\";\n strategyId: ActionStrategyId;\n fingerprint: string;\n}\n\nexport interface PreActionGateDependencies {\n readStrict?: (options: {\n memoryDir: string;\n causalTrajectoryStoreDir?: string;\n signal?: AbortSignal;\n }) => Promise<CausalTrajectoryStrictReadResult>;\n getRevision?: (options: {\n memoryDir: string;\n causalTrajectoryStoreDir?: string;\n }) => Promise<string>;\n clock?: () => number;\n maxCacheSize?: number;\n timeoutMs?: number;\n}\n\nconst ACTION_STRATEGIES: ReadonlySet<ActionStrategyId> = new Set([\n \"RUN_CHECK\",\n \"CHANGE_IMPLEMENTATION\",\n \"CHANGE_TEST\",\n \"CHANGE_CONFIGURATION\",\n \"CHANGE_DEPENDENCY\",\n \"INVALIDATE_CACHE\",\n \"RETRY_ACTION\",\n \"INSPECT_STATE\",\n]);\nconst EDIT_KINDS: ReadonlySet<EditKind> = new Set([\"create\", \"update\", \"delete\", \"rename\"]);\nconst MAX_COMMAND_CHARS = 128;\nconst MAX_ARGUMENTS = 32;\nconst MAX_ARGUMENT_CHARS = 128;\nconst MAX_PATH_CHARS = 512;\nconst MAX_SLOT_CHARS = 128;\nconst MAX_CITATION_CHARS = 180;\n\nfunction bound(value: string, max: number, field: string): string {\n const normalized = value.trim();\n if (normalized.length > max) throw new Error(`${field} exceeds ${max} characters`);\n return normalized;\n}\n\nexport function sanitizePayloadString(input: string): string {\n return input\n .replace(/(?:\\/home\\/[^\\s/]+|\\/Users\\/[^\\s/]+|[A-Za-z]:\\\\Users\\\\[^\\s\\\\]+)/g, \"$HOME\")\n .replace(/sk-[a-zA-Z0-9_-]{10,}/g, \"<secret>\")\n .replace(/bearer\\s+[a-zA-Z0-9._-]+/gi, \"bearer <secret>\")\n .trim();\n}\n\nfunction normalizeRepositoryPath(filePath: string, codingContext: CodingContext): string {\n const root = path.resolve(codingContext.rootPath);\n const absolute = path.isAbsolute(filePath) ? path.resolve(filePath) : path.resolve(root, filePath);\n const relative = path.relative(root, absolute);\n if (relative === \"..\" || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {\n throw new Error(\"edit path must be contained by codingContext.rootPath\");\n }\n return bound(relative.split(path.sep).join(\"/\"), MAX_PATH_CHARS, \"repo-relative path\");\n}\n\nfunction normalizeCommandArgument(\n argument: string,\n codingContext: CodingContext,\n secretValue: boolean,\n): string {\n const value = bound(sanitizePayloadString(argument), MAX_ARGUMENT_CHARS, \"command argument\");\n if (secretValue || value.includes(\"<secret>\")) return \"<secret>\";\n if (/^--(?:token|key|secret|password|authorization)=/i.test(value)) {\n return `${value.slice(0, value.indexOf(\"=\") + 1)}<secret>`;\n }\n if (/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value)) return \"<uuid>\";\n if (/^[0-9a-f]{7,64}$/i.test(value)) return \"<sha>\";\n if (/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$/.test(value)) return \"<timestamp>\";\n if (/^\\d+(?:\\.\\d+)?(?:ms|s|m|h|d)$/.test(value)) return \"<duration>\";\n if (/^-?\\d+(?:\\.\\d+)?$/.test(value)) return \"<number>\";\n const pathLike = path.isAbsolute(value)\n || (!/^[a-z][a-z0-9+.-]*:\\/\\//i.test(value) && /[\\\\/]/.test(value) && !value.startsWith(\"--\"));\n if (pathLike) {\n let relative: string;\n try {\n relative = normalizeRepositoryPath(value, codingContext);\n } catch {\n return \"<external-path>\";\n }\n return /(?:^|\\/)(?:tmp|temp)(?:\\/|$)|\\.tmp$/i.test(relative)\n ? `<repo-temp-path:${relative}>`\n : `<repo-path:${relative}>`;\n }\n return value;\n}\n\nexport function normalizeActionIntent(\n intent: ActionIntent,\n strategyId: ActionStrategyId,\n codingContext: CodingContext,\n): NormalizedActionIntent {\n if (!ACTION_STRATEGIES.has(strategyId)) throw new Error(`unsupported action strategy: ${strategyId}`);\n\n let payload: string;\n if (intent.kind === \"command\") {\n const command = bound(sanitizePayloadString(intent.command), MAX_COMMAND_CHARS, \"command\");\n const args = intent.args ?? [];\n if (args.length > MAX_ARGUMENTS) throw new Error(`command args exceed ${MAX_ARGUMENTS} entries`);\n const normalizedArgs = args.map((argument, index) => {\n const prior = index > 0 ? args[index - 1] : undefined;\n const secretValue = prior !== undefined\n && /^--(?:token|key|secret|password|authorization)$/i.test(prior);\n return normalizeCommandArgument(argument, codingContext, secretValue);\n });\n payload = JSON.stringify({ kind: \"command\", strategyId, command, args: normalizedArgs });\n } else if (intent.kind === \"edit\") {\n if (!EDIT_KINDS.has(intent.editKind)) throw new Error(`unsupported edit kind: ${intent.editKind}`);\n const relativePath = normalizeRepositoryPath(intent.filePath, codingContext);\n payload = JSON.stringify({\n kind: \"edit\",\n strategyId,\n filePath: relativePath,\n editKind: intent.editKind,\n symbol: intent.symbol ? bound(intent.symbol, MAX_SLOT_CHARS, \"symbol\") : undefined,\n range: intent.range ? bound(intent.range, MAX_SLOT_CHARS, \"range\") : undefined,\n diffShape: intent.diffShape ? bound(intent.diffShape, MAX_SLOT_CHARS, \"diffShape\") : undefined,\n });\n } else {\n throw new Error(\"action intent kind must be command or edit\");\n }\n\n return {\n kind: intent.kind,\n strategyId,\n fingerprint: `v1:sha256:${createHash(\"sha256\").update(payload).digest(\"hex\")}`,\n };\n}\n\nfunction matchTrajectory(\n record: CausalTrajectoryRecord,\n projectId: string,\n normalized: NormalizedActionIntent,\n): boolean {\n const identity = record.actionIdentity;\n return record.outcomeKind === \"failure\"\n && record.codingContext?.projectId === projectId\n && identity?.fingerprintVersion === PRE_ACTION_FINGERPRINT_VERSION\n && identity.strategyId === normalized.strategyId\n && identity.fingerprint === normalized.fingerprint;\n}\n\nfunction boundedCitation(value: string | undefined, fallback: string): string {\n const sanitized = sanitizePayloadString(value ?? fallback).replace(/\\s+/g, \" \");\n return sanitized.slice(0, MAX_CITATION_CHARS);\n}\n\nexport class PreActionFailureGate {\n private readonly cache = new Map<string, PreActionGateResult>();\n private readonly maxCacheSize: number;\n private readonly readStrict: NonNullable<PreActionGateDependencies[\"readStrict\"]>;\n private readonly getRevision: NonNullable<PreActionGateDependencies[\"getRevision\"]>;\n private readonly clock: () => number;\n private readonly timeoutMs: number;\n\n constructor(deps: PreActionGateDependencies = {}) {\n this.readStrict = deps.readStrict ?? readCausalTrajectoryRecordsStrict;\n this.getRevision = deps.getRevision ?? readCausalTrajectoryRevisionToken;\n this.clock = deps.clock ?? Date.now;\n this.maxCacheSize = deps.maxCacheSize ?? 500;\n this.timeoutMs = Math.max(1, deps.timeoutMs ?? PRE_ACTION_GATE_DEFAULT_TIMEOUT_MS);\n }\n\n public clearCache(): void {\n this.cache.clear();\n }\n\n async evaluate(request: PreActionGateRequest): Promise<PreActionGateResult> {\n const deadline = this.clock() + this.timeoutMs;\n const controller = new AbortController();\n const abortFromExternal = () => controller.abort();\n request.signal?.addEventListener(\"abort\", abortFromExternal, { once: true });\n if (request.signal?.aborted) controller.abort();\n\n let resolveTimeout!: (result: PreActionGateResult) => void;\n const timeoutPromise = new Promise<PreActionGateResult>((resolve) => {\n resolveTimeout = resolve;\n });\n const timer = setTimeout(() => {\n controller.abort();\n resolveTimeout({ status: \"ERROR_FAIL_OPEN\", reason: `PreActionFailureGate timed out after ${this.timeoutMs}ms` });\n }, this.timeoutMs);\n\n try {\n return await Promise.race([\n this.evaluateInternal(request, controller.signal, deadline),\n timeoutPromise,\n ]);\n } catch (error) {\n return { status: \"ERROR_FAIL_OPEN\", reason: error instanceof Error ? error.message : String(error) };\n } finally {\n clearTimeout(timer);\n request.signal?.removeEventListener(\"abort\", abortFromExternal);\n }\n }\n\n private async evaluateInternal(\n request: PreActionGateRequest,\n signal: AbortSignal,\n deadline: number,\n ): Promise<PreActionGateResult> {\n if (!request.memoryDir?.trim()) return { status: \"ERROR_FAIL_OPEN\", reason: \"memoryDir is required\" };\n if (!request.sessionKey?.trim()) return { status: \"ERROR_FAIL_OPEN\", reason: \"sessionKey is required\" };\n if (!request.codingContext?.projectId?.trim() || !request.codingContext.rootPath?.trim()) {\n return { status: \"ERROR_FAIL_OPEN\", reason: \"codingContext with projectId and rootPath is required\" };\n }\n\n let normalized: NormalizedActionIntent;\n try {\n normalized = normalizeActionIntent(request.intent, request.strategyId, request.codingContext);\n } catch (error) {\n return { status: \"ERROR_FAIL_OPEN\", reason: error instanceof Error ? error.message : String(error) };\n }\n\n const revisionOptions = {\n memoryDir: request.memoryDir,\n causalTrajectoryStoreDir: request.causalTrajectoryStoreDir,\n };\n const preRevision = await this.getRevision(revisionOptions);\n const branch = request.codingContext.branch ?? \"\";\n const storeId = createHash(\"sha256\")\n .update(resolveCausalTrajectoryStoreDir(request.memoryDir, request.causalTrajectoryStoreDir))\n .digest(\"hex\");\n const cacheKey = createHash(\"sha256\").update(JSON.stringify([\n request.codingContext.projectId,\n branch,\n request.sessionKey,\n PRE_ACTION_FINGERPRINT_VERSION,\n preRevision,\n normalized.fingerprint,\n storeId,\n ])).digest(\"hex\");\n const cached = this.cache.get(cacheKey);\n if (cached) return cached;\n\n if (signal.aborted || this.clock() >= deadline) return { status: \"ERROR_FAIL_OPEN\", reason: \"deadline exceeded\" };\n const scan = await this.readStrict({ ...revisionOptions, signal });\n if (signal.aborted || this.clock() >= deadline) return { status: \"ERROR_FAIL_OPEN\", reason: \"deadline exceeded\" };\n if (scan.invalidTrajectories.length > 0) {\n return { status: \"ERROR_FAIL_OPEN\", reason: `store contains ${scan.invalidTrajectories.length} invalid record(s)` };\n }\n\n const postRevision = await this.getRevision(revisionOptions);\n const stableRevision = preRevision === postRevision;\n const match = scan.trajectories\n .filter((record) => matchTrajectory(record, request.codingContext.projectId, normalized))\n .sort((left, right) => {\n const recordedAtOrder = right.recordedAt.localeCompare(left.recordedAt);\n return recordedAtOrder !== 0\n ? recordedAtOrder\n : left.trajectoryId.localeCompare(right.trajectoryId);\n })[0];\n const result: PreActionGateResult = match\n ? {\n status: \"MATCH_WARN\",\n advisoryText: `[PreActionFailureGate ${PRE_ACTION_WARNING_VERSION}] A similar action failed before. Prior act: \"${boundedCitation(match.actionSummary, \"recorded action\")}\". Failure: \"${boundedCitation(match.outcomeSummary, \"recorded failure\")}\". Next safe check: \"${boundedCitation(match.followUpSummary, \"verify prerequisites before retrying\")}\".`,\n fingerprint: normalized.fingerprint,\n matchedTrajectoryId: match.trajectoryId,\n revision: postRevision,\n }\n : { status: \"NO_MATCH\", fingerprint: normalized.fingerprint, revision: postRevision };\n\n if (stableRevision && !signal.aborted && this.clock() < deadline) this.setCache(cacheKey, result);\n return result;\n }\n\n private setCache(key: string, result: PreActionGateResult): void {\n if (this.cache.size >= this.maxCacheSize) {\n const oldest = this.cache.keys().next().value;\n if (oldest !== undefined) this.cache.delete(oldest);\n }\n this.cache.set(key, result);\n }\n}\n"],"mappings":";;;;;;;AAAA,SAAS,kBAAkB;AAC3B,OAAO,UAAU;AAaV,IAAM,iCAAiC;AACvC,IAAM,6BAA6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ACF;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WearablesInputError
|
|
3
3
|
} from "./chunk-V7IZKJI3.js";
|
|
4
|
+
import {
|
|
5
|
+
AdapterRegistry
|
|
6
|
+
} from "./chunk-RKNJBZ55.js";
|
|
4
7
|
import {
|
|
5
8
|
WriteRateLimiter
|
|
6
9
|
} from "./chunk-MKQBXQKU.js";
|
|
7
|
-
import {
|
|
8
|
-
AdapterRegistry
|
|
9
|
-
} from "./chunk-JBPKEARU.js";
|
|
10
10
|
import {
|
|
11
11
|
nonEmptyQueryParam,
|
|
12
12
|
optionalQueryString,
|
|
@@ -21,17 +21,17 @@ import {
|
|
|
21
21
|
processChatMessage,
|
|
22
22
|
sessionBelongsToPrincipal,
|
|
23
23
|
subscribeChatTranscript
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-7BLWBSRL.js";
|
|
25
25
|
import {
|
|
26
26
|
RelayMissionStoreError
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-6XGEBQ3R.js";
|
|
28
28
|
import {
|
|
29
29
|
validateRequest
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-LYMNZZIM.js";
|
|
31
31
|
import {
|
|
32
32
|
executeResolution,
|
|
33
33
|
isValidResolutionVerb
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-BAKXNQ3C.js";
|
|
35
35
|
import {
|
|
36
36
|
isDefaultReviewNamespace,
|
|
37
37
|
listPairs,
|
|
@@ -50,21 +50,21 @@ import {
|
|
|
50
50
|
import {
|
|
51
51
|
authorizationProbeNamespaces,
|
|
52
52
|
probeOperationAuthorization
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-7VWZ4LRW.js";
|
|
54
54
|
import {
|
|
55
55
|
CorrectionContractError,
|
|
56
56
|
getOperation,
|
|
57
57
|
resolveQueryNamespaceWritablePreflight
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-PWIMF7LP.js";
|
|
59
59
|
import {
|
|
60
60
|
isTrustZoneName
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-KQS72GCR.js";
|
|
62
62
|
import {
|
|
63
63
|
subscribeGraphEvents
|
|
64
64
|
} from "./chunk-DEUNUKTD.js";
|
|
65
65
|
import {
|
|
66
66
|
isRecallDisclosure
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-LAQ33B5D.js";
|
|
68
68
|
import {
|
|
69
69
|
OFFLINE_SYNC_APPLY_MAX_BODY_BYTES,
|
|
70
70
|
OFFLINE_SYNC_FILE_CONTENT_MAX_CHUNK_BYTES,
|
|
@@ -3263,4 +3263,4 @@ export {
|
|
|
3263
3263
|
MeetingsInputError,
|
|
3264
3264
|
EngramAccessHttpServer
|
|
3265
3265
|
};
|
|
3266
|
-
//# sourceMappingURL=chunk-
|
|
3266
|
+
//# sourceMappingURL=chunk-LQKXVQZR.js.map
|
|
@@ -7,17 +7,17 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
listMemoryGovernanceRuns,
|
|
9
9
|
readMemoryGovernanceRunArtifact
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-WPZX7MEA.js";
|
|
11
11
|
import {
|
|
12
12
|
StorageManager
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-24BKGKGO.js";
|
|
14
14
|
import {
|
|
15
15
|
normalizeProjectionPreview,
|
|
16
16
|
normalizeProjectionTags
|
|
17
17
|
} from "./chunk-SCU65EZI.js";
|
|
18
18
|
import {
|
|
19
19
|
commitPreparedFileAtomically
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-AW4QUFQF.js";
|
|
21
21
|
import {
|
|
22
22
|
assertInjectedStorageRooted,
|
|
23
23
|
readProjectedEntityMentionRows,
|
|
@@ -1001,4 +1001,4 @@ export {
|
|
|
1001
1001
|
verifyMemoryProjection,
|
|
1002
1002
|
repairMemoryProjection
|
|
1003
1003
|
};
|
|
1004
|
-
//# sourceMappingURL=chunk-
|
|
1004
|
+
//# sourceMappingURL=chunk-LTOAJXZB.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isValidCapsuleSince
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IPLYGWQF.js";
|
|
4
4
|
import {
|
|
5
5
|
CAPSULE_ID_PATTERN
|
|
6
6
|
} from "./chunk-WEHSQBFR.js";
|
|
@@ -475,4 +475,4 @@ export {
|
|
|
475
475
|
actionConfidenceRequestSchema,
|
|
476
476
|
validateRequest
|
|
477
477
|
};
|
|
478
|
-
//# sourceMappingURL=chunk-
|
|
478
|
+
//# sourceMappingURL=chunk-LYMNZZIM.js.map
|
|
@@ -15,11 +15,12 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
listJsonFiles,
|
|
17
17
|
readJsonFile
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-P77QX3ID.js";
|
|
19
19
|
|
|
20
20
|
// src/causal-trajectory.ts
|
|
21
21
|
import path from "path";
|
|
22
|
-
import { mkdir, writeFile } from "fs/promises";
|
|
22
|
+
import { link, lstat, mkdir, readdir, readFile, rename, rm, stat, writeFile } from "fs/promises";
|
|
23
|
+
import { createHash } from "crypto";
|
|
23
24
|
function validateMetadata(raw) {
|
|
24
25
|
return validateStringRecord(raw, "metadata");
|
|
25
26
|
}
|
|
@@ -29,6 +30,81 @@ function resolveCausalTrajectoryStoreDir(memoryDir, overrideDir) {
|
|
|
29
30
|
}
|
|
30
31
|
return path.join(memoryDir, "state", "causal-trajectories");
|
|
31
32
|
}
|
|
33
|
+
async function readCausalTrajectoryRevisionToken(options) {
|
|
34
|
+
const rootDir = resolveCausalTrajectoryStoreDir(options.memoryDir, options.causalTrajectoryStoreDir);
|
|
35
|
+
const revPath = path.join(rootDir, "revision.json");
|
|
36
|
+
try {
|
|
37
|
+
const raw = await readFile(revPath, "utf8");
|
|
38
|
+
const parsed = JSON.parse(raw);
|
|
39
|
+
if (!isRecord(parsed) || typeof parsed.revisionToken !== "string" || parsed.revisionToken.length === 0) {
|
|
40
|
+
throw new Error("revision.json must contain a non-empty revisionToken");
|
|
41
|
+
}
|
|
42
|
+
return parsed.revisionToken;
|
|
43
|
+
} catch (err) {
|
|
44
|
+
const code = err?.code;
|
|
45
|
+
if (code === "ENOENT") {
|
|
46
|
+
return "rev-0";
|
|
47
|
+
}
|
|
48
|
+
throw new Error(`Failed to read causal trajectory revision token: ${err instanceof Error ? err.message : String(err)}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function advanceCausalTrajectoryRevisionToken(options) {
|
|
52
|
+
const rootDir = resolveCausalTrajectoryStoreDir(options.memoryDir, options.causalTrajectoryStoreDir);
|
|
53
|
+
await mkdir(rootDir, { recursive: true });
|
|
54
|
+
const newToken = `rev-${Date.now()}-${createHash("sha256").update(String(Math.random())).digest("hex").slice(0, 8)}`;
|
|
55
|
+
const revPath = path.join(rootDir, "revision.json");
|
|
56
|
+
const tmpPath = path.join(rootDir, `.revision.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`);
|
|
57
|
+
const payload = JSON.stringify({ revisionToken: newToken, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2);
|
|
58
|
+
try {
|
|
59
|
+
await writeFile(tmpPath, payload, "utf8");
|
|
60
|
+
await rename(tmpPath, revPath);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
await rm(tmpPath, { force: true }).catch(() => {
|
|
63
|
+
});
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
return newToken;
|
|
67
|
+
}
|
|
68
|
+
function validateCodingContext(raw) {
|
|
69
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
70
|
+
const obj = raw;
|
|
71
|
+
if (typeof obj.projectId !== "string" || obj.projectId.trim().length === 0) {
|
|
72
|
+
throw new Error("codingContext.projectId must be a non-empty string");
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
projectId: obj.projectId.trim(),
|
|
76
|
+
branch: obj.branch === null ? null : optionalString(obj.branch),
|
|
77
|
+
defaultBranch: obj.defaultBranch === null ? null : optionalString(obj.defaultBranch)
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function validateActionIdentity(raw) {
|
|
81
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
82
|
+
const obj = raw;
|
|
83
|
+
if (obj.fingerprintVersion !== 1) return void 0;
|
|
84
|
+
const strategyId = assertString(obj.strategyId, "actionIdentity.strategyId");
|
|
85
|
+
const allowedStrategies = [
|
|
86
|
+
"RUN_CHECK",
|
|
87
|
+
"CHANGE_IMPLEMENTATION",
|
|
88
|
+
"CHANGE_TEST",
|
|
89
|
+
"CHANGE_CONFIGURATION",
|
|
90
|
+
"CHANGE_DEPENDENCY",
|
|
91
|
+
"INVALIDATE_CACHE",
|
|
92
|
+
"RETRY_ACTION",
|
|
93
|
+
"INSPECT_STATE"
|
|
94
|
+
];
|
|
95
|
+
if (!allowedStrategies.includes(strategyId)) {
|
|
96
|
+
throw new Error(`actionIdentity.strategyId must be one of ${allowedStrategies.join("|")}`);
|
|
97
|
+
}
|
|
98
|
+
const fingerprint = assertString(obj.fingerprint, "actionIdentity.fingerprint");
|
|
99
|
+
if (!/^v1:sha256:[a-f0-9]{64}$/.test(fingerprint)) {
|
|
100
|
+
throw new Error("actionIdentity.fingerprint must be a v1 sha256 fingerprint");
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
fingerprintVersion: 1,
|
|
104
|
+
fingerprint,
|
|
105
|
+
strategyId
|
|
106
|
+
};
|
|
107
|
+
}
|
|
32
108
|
function validateCausalTrajectoryRecord(raw) {
|
|
33
109
|
if (!isRecord(raw)) throw new Error("causal trajectory record must be an object");
|
|
34
110
|
if (raw.schemaVersion !== 1) throw new Error("schemaVersion must be 1");
|
|
@@ -50,7 +126,9 @@ function validateCausalTrajectoryRecord(raw) {
|
|
|
50
126
|
objectiveStateSnapshotRefs: optionalStringArray(raw.objectiveStateSnapshotRefs, "objectiveStateSnapshotRefs"),
|
|
51
127
|
entityRefs: optionalStringArray(raw.entityRefs, "entityRefs"),
|
|
52
128
|
tags: optionalStringArray(raw.tags, "tags"),
|
|
53
|
-
metadata: validateMetadata(raw.metadata)
|
|
129
|
+
metadata: validateMetadata(raw.metadata),
|
|
130
|
+
codingContext: validateCodingContext(raw.codingContext),
|
|
131
|
+
actionIdentity: validateActionIdentity(raw.actionIdentity)
|
|
54
132
|
};
|
|
55
133
|
}
|
|
56
134
|
async function recordCausalTrajectory(options) {
|
|
@@ -59,8 +137,42 @@ async function recordCausalTrajectory(options) {
|
|
|
59
137
|
const day = recordStoreDay(validated.recordedAt);
|
|
60
138
|
const trajectoriesDir = path.join(rootDir, "trajectories", day);
|
|
61
139
|
const filePath = path.join(trajectoriesDir, `${validated.trajectoryId}.json`);
|
|
140
|
+
try {
|
|
141
|
+
await lstat(filePath);
|
|
142
|
+
throw new Error(`causal trajectory already exists: ${validated.trajectoryId}`);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
if (error.code !== "ENOENT") throw error;
|
|
145
|
+
}
|
|
146
|
+
const tmpPath = path.join(
|
|
147
|
+
trajectoriesDir,
|
|
148
|
+
`.${validated.trajectoryId}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`
|
|
149
|
+
);
|
|
62
150
|
await mkdir(trajectoriesDir, { recursive: true });
|
|
63
|
-
|
|
151
|
+
const payload = JSON.stringify(validated, null, 2);
|
|
152
|
+
try {
|
|
153
|
+
await writeFile(tmpPath, payload, "utf8");
|
|
154
|
+
try {
|
|
155
|
+
await link(tmpPath, filePath);
|
|
156
|
+
} catch (error) {
|
|
157
|
+
const code = error.code;
|
|
158
|
+
if (!["EPERM", "ENOTSUP", "EOPNOTSUPP"].includes(code ?? "")) throw error;
|
|
159
|
+
await writeFile(filePath, payload, { encoding: "utf8", flag: "wx" });
|
|
160
|
+
}
|
|
161
|
+
await rm(tmpPath, { force: true });
|
|
162
|
+
} catch (error) {
|
|
163
|
+
await rm(tmpPath, { force: true }).catch(() => {
|
|
164
|
+
});
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
await advanceCausalTrajectoryRevisionToken({
|
|
169
|
+
memoryDir: options.memoryDir,
|
|
170
|
+
causalTrajectoryStoreDir: options.causalTrajectoryStoreDir
|
|
171
|
+
});
|
|
172
|
+
} catch (error) {
|
|
173
|
+
await rm(filePath, { force: true });
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
64
176
|
if (options.actionGraphRecallEnabled === true) {
|
|
65
177
|
try {
|
|
66
178
|
const { appendCausalTrajectoryGraphEdges } = await import("./causal-trajectory-graph.js");
|
|
@@ -114,6 +226,75 @@ async function readCausalTrajectoryRecords(options) {
|
|
|
114
226
|
}
|
|
115
227
|
return { files, trajectories, invalidTrajectories };
|
|
116
228
|
}
|
|
229
|
+
async function readCausalTrajectoryRecordsStrict(options) {
|
|
230
|
+
const rootDir = resolveCausalTrajectoryStoreDir(options.memoryDir, options.causalTrajectoryStoreDir);
|
|
231
|
+
const trajectoriesDir = path.join(rootDir, "trajectories");
|
|
232
|
+
if (options.signal?.aborted) {
|
|
233
|
+
throw new Error("Read aborted");
|
|
234
|
+
}
|
|
235
|
+
let statRes;
|
|
236
|
+
try {
|
|
237
|
+
statRes = await lstat(trajectoriesDir);
|
|
238
|
+
} catch (err) {
|
|
239
|
+
const code = err?.code;
|
|
240
|
+
if (code === "ENOENT") {
|
|
241
|
+
return { status: "absent", files: [], trajectories: [], invalidTrajectories: [] };
|
|
242
|
+
}
|
|
243
|
+
throw new Error(`Unreadable causal trajectory directory: ${err instanceof Error ? err.message : String(err)}`);
|
|
244
|
+
}
|
|
245
|
+
if (statRes.isSymbolicLink()) {
|
|
246
|
+
throw new Error("Causal trajectory directory must not be a symbolic link");
|
|
247
|
+
}
|
|
248
|
+
if (!statRes.isDirectory()) {
|
|
249
|
+
throw new Error("Causal trajectory path is not a directory");
|
|
250
|
+
}
|
|
251
|
+
const files = [];
|
|
252
|
+
const scanDir = async (dirPath) => {
|
|
253
|
+
if (options.signal?.aborted) {
|
|
254
|
+
throw new Error("Read aborted");
|
|
255
|
+
}
|
|
256
|
+
const entries = await readdir(dirPath, { withFileTypes: true });
|
|
257
|
+
for (const entry of entries) {
|
|
258
|
+
if (options.signal?.aborted) {
|
|
259
|
+
throw new Error("Read aborted");
|
|
260
|
+
}
|
|
261
|
+
const fullPath = path.join(dirPath, entry.name);
|
|
262
|
+
if (entry.isSymbolicLink()) {
|
|
263
|
+
throw new Error(`Causal trajectory entry must not be a symbolic link: ${fullPath}`);
|
|
264
|
+
}
|
|
265
|
+
if (entry.isDirectory()) {
|
|
266
|
+
await scanDir(fullPath);
|
|
267
|
+
} else if (entry.isFile() && entry.name.endsWith(".json") && !entry.name.startsWith(".")) {
|
|
268
|
+
const s = await stat(fullPath);
|
|
269
|
+
if (s.isFile()) {
|
|
270
|
+
files.push(fullPath);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
await scanDir(trajectoriesDir);
|
|
276
|
+
if (files.length === 0) {
|
|
277
|
+
return { status: "empty", files: [], trajectories: [], invalidTrajectories: [] };
|
|
278
|
+
}
|
|
279
|
+
const trajectories = [];
|
|
280
|
+
const invalidTrajectories = [];
|
|
281
|
+
for (const filePath of files) {
|
|
282
|
+
if (options.signal?.aborted) {
|
|
283
|
+
throw new Error("Read aborted");
|
|
284
|
+
}
|
|
285
|
+
try {
|
|
286
|
+
const content = await readFile(filePath, "utf8");
|
|
287
|
+
const raw = JSON.parse(content);
|
|
288
|
+
trajectories.push(validateCausalTrajectoryRecord(raw));
|
|
289
|
+
} catch (error) {
|
|
290
|
+
invalidTrajectories.push({
|
|
291
|
+
path: filePath,
|
|
292
|
+
error: error instanceof Error ? error.message : String(error)
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return { status: "ok", files, trajectories, invalidTrajectories };
|
|
297
|
+
}
|
|
117
298
|
function filterTrajectoriesByLookbackDays(trajectories, lookbackDays, nowMs = Date.now()) {
|
|
118
299
|
const days = Math.max(1, Math.floor(lookbackDays));
|
|
119
300
|
const cutoff = nowMs - days * 864e5;
|
|
@@ -209,11 +390,14 @@ async function searchCausalTrajectories(options) {
|
|
|
209
390
|
|
|
210
391
|
export {
|
|
211
392
|
resolveCausalTrajectoryStoreDir,
|
|
393
|
+
readCausalTrajectoryRevisionToken,
|
|
394
|
+
advanceCausalTrajectoryRevisionToken,
|
|
212
395
|
validateCausalTrajectoryRecord,
|
|
213
396
|
recordCausalTrajectory,
|
|
214
397
|
readCausalTrajectoryRecords,
|
|
398
|
+
readCausalTrajectoryRecordsStrict,
|
|
215
399
|
filterTrajectoriesByLookbackDays,
|
|
216
400
|
getCausalTrajectoryStoreStatus,
|
|
217
401
|
searchCausalTrajectories
|
|
218
402
|
};
|
|
219
|
-
//# sourceMappingURL=chunk-
|
|
403
|
+
//# sourceMappingURL=chunk-M4MP34AQ.js.map
|