@remnic/core 9.3.693 → 9.3.695
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-boundary.d.ts +13 -12
- package/dist/access-boundary.js +36 -28
- package/dist/access-cli.js +62 -59
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +12 -11
- package/dist/access-http.js +40 -32
- package/dist/access-mcp.d.ts +19 -11
- package/dist/access-mcp.js +39 -31
- package/dist/access-operations.d.ts +56 -13
- package/dist/access-operations.js +66 -30
- package/dist/access-schema.js +3 -3
- package/dist/{access-service-DxCpgyVW.d.ts → access-service-BqBQeUJd.d.ts} +99 -3
- package/dist/access-service.d.ts +8 -7
- package/dist/access-service.js +35 -27
- package/dist/access-surface-catalog.d.ts +12 -11
- package/dist/access-surface-catalog.js +15 -0
- package/dist/access-surface-catalog.js.map +1 -1
- 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 +1 -1
- package/dist/{auto-sync-RWXT6P5M.js → auto-sync-PFW2NJZY.js} +8 -8
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +9 -8
- package/dist/briefing.d.ts +1 -1
- package/dist/briefing.js +12 -5
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer.d.ts +1 -1
- package/dist/calibration.d.ts +1 -1
- package/dist/calibration.js +2 -2
- package/dist/capabilities.d.ts +1 -1
- package/dist/{capsule-crypto-7FJQINUR.js → capsule-crypto-YO5QJ6L3.js} +2 -2
- package/dist/{catalog-BEWLjdOr.d.ts → catalog-D7YDNNF7.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-behavior.js +2 -2
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +17 -16
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.js +2 -2
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-UPTZYUYJ.js → chunk-24D66MMN.js} +2 -1
- package/dist/chunk-24D66MMN.js.map +1 -0
- package/dist/{chunk-THKNO6OX.js → chunk-32XTY2DQ.js} +52 -51
- package/dist/chunk-32XTY2DQ.js.map +1 -0
- package/dist/{chunk-YN4ZT4CW.js → chunk-3LYJIA76.js} +1 -1
- package/dist/{chunk-ADUAF5EV.js → chunk-3P2XEQSV.js} +2 -2
- package/dist/{chunk-KYH53EFD.js → chunk-4NNDJOAO.js} +8 -8
- package/dist/{chunk-QFG23CRE.js → chunk-52QIAN76.js} +2 -2
- package/dist/chunk-5AT62NQH.js +553 -0
- package/dist/chunk-5AT62NQH.js.map +1 -0
- package/dist/{chunk-TAPSNIMA.js → chunk-5CEJH5ZN.js} +4 -4
- package/dist/{chunk-4RGWCRIJ.js → chunk-5TYA4OCF.js} +4 -4
- package/dist/{chunk-FM7KLRKN.js → chunk-6GAUF4OU.js} +3 -3
- package/dist/{chunk-6C2BMUZA.js → chunk-AF6DSAWD.js} +2 -2
- package/dist/{chunk-2NLLXCJG.js → chunk-BXLOS5AJ.js} +2 -2
- package/dist/{chunk-32KD5IHZ.js → chunk-CLXTDOKV.js} +2 -2
- package/dist/{chunk-ARV3AUOM.js → chunk-DL6H3D7S.js} +2 -2
- package/dist/{chunk-X7Y7WX73.js → chunk-DQEMWVMT.js} +1 -1
- package/dist/{chunk-3BRA3N5A.js → chunk-EC3A6M43.js} +2 -2
- package/dist/{chunk-UTUYAPLY.js → chunk-EK6FYL2E.js} +38 -3
- package/dist/chunk-EK6FYL2E.js.map +1 -0
- package/dist/{chunk-ZLXGFAML.js → chunk-FZMH66NT.js} +2 -2
- package/dist/{chunk-HXNMDPHN.js → chunk-G663XUEG.js} +2 -2
- package/dist/{chunk-TYEOAFH3.js → chunk-G6SVZWPB.js} +10 -1
- package/dist/chunk-G6SVZWPB.js.map +1 -0
- package/dist/chunk-HKET3ZOI.js +381 -0
- package/dist/chunk-HKET3ZOI.js.map +1 -0
- package/dist/{chunk-YOI3ELXF.js → chunk-IF362TF6.js} +2 -2
- package/dist/{chunk-WIKNVFBS.js → chunk-J45OCIVH.js} +2 -2
- package/dist/{chunk-UDJLF3BO.js → chunk-JI6HWBYL.js} +2 -2
- package/dist/{chunk-ECZPWSB5.js → chunk-JJT3AGL4.js} +4 -4
- package/dist/{chunk-RHWFMBO5.js → chunk-JMAKCWJ3.js} +96 -7
- package/dist/chunk-JMAKCWJ3.js.map +1 -0
- package/dist/{chunk-4NFVPDIL.js → chunk-LM6JB2EG.js} +2 -2
- package/dist/{chunk-AFWEUTMS.js → chunk-LPIWEKZ3.js} +2 -2
- package/dist/{chunk-LD53WPMU.js → chunk-LQ6JI4VH.js} +4 -4
- package/dist/{chunk-U2OBZSGG.js → chunk-MNFAGE5D.js} +2 -2
- package/dist/{chunk-VFVG4NS2.js → chunk-MOBRVKWE.js} +23 -12
- package/dist/chunk-MOBRVKWE.js.map +1 -0
- package/dist/{chunk-MQTPUPLP.js → chunk-N4PD5IY3.js} +834 -51
- package/dist/chunk-N4PD5IY3.js.map +1 -0
- package/dist/{chunk-5HGPDRQZ.js → chunk-NFMDHE45.js} +2 -2
- package/dist/chunk-NFMDHE45.js.map +1 -0
- package/dist/{chunk-MCV2DD6F.js → chunk-NLZO5NO6.js} +2 -2
- package/dist/{chunk-3VVH6ZQW.js → chunk-Q6ZHGGNJ.js} +2 -2
- package/dist/{chunk-4IQNAOP3.js → chunk-Q7SFJURX.js} +2 -2
- package/dist/{chunk-MXZWKOOR.js → chunk-QJM2XAJD.js} +11 -11
- package/dist/{chunk-6ZNIUGXB.js → chunk-QQW2LIEA.js} +4 -4
- package/dist/{chunk-GCOSQBQ2.js → chunk-QVTSLRKT.js} +3 -3
- package/dist/{chunk-F7BVJ3IE.js → chunk-RWST6NOL.js} +166 -102
- package/dist/chunk-RWST6NOL.js.map +1 -0
- package/dist/{chunk-NUZ3N445.js → chunk-SPVIG2R3.js} +10 -10
- package/dist/{chunk-2D27ODNX.js → chunk-TIVZ4MCG.js} +2 -2
- package/dist/{chunk-5KBNNUXS.js → chunk-TT7BJWGI.js} +2 -2
- package/dist/{chunk-KQAFEZQX.js → chunk-VDX2J7OX.js} +2 -2
- package/dist/{chunk-E6BOD3UJ.js → chunk-VPAFWWCL.js} +2 -2
- package/dist/chunk-VQ7B2Q6M.js +112 -0
- package/dist/chunk-VQ7B2Q6M.js.map +1 -0
- package/dist/{chunk-UOCLRM74.js → chunk-W54EAJT4.js} +2 -2
- package/dist/{chunk-QVG4LAQO.js → chunk-WR6KFJKA.js} +7 -7
- package/dist/{chunk-YQGHW5ML.js → chunk-WRFKZEO6.js} +4 -4
- package/dist/{chunk-WYB44HHV.js → chunk-XUNQLJT2.js} +20 -8
- package/dist/chunk-XUNQLJT2.js.map +1 -0
- package/dist/{chunk-66HROLW5.js → chunk-XWT4JXXA.js} +2 -2
- package/dist/{chunk-SAC5V6JT.js → chunk-XXA6T3O4.js} +2 -2
- package/dist/{chunk-KF74X62T.js → chunk-YGKUAX2B.js} +4 -4
- package/dist/{chunk-W4ELOUNX.js → chunk-YOZNTNNA.js} +2 -2
- package/dist/{chunk-DQHZA7Y3.js → chunk-ZXUOAFUG.js} +1 -1
- package/dist/chunk-ZXUOAFUG.js.map +1 -0
- package/dist/{cli-DoQsv4ut.d.ts → cli-DBDgdvh9.d.ts} +3 -3
- package/dist/cli.d.ts +11 -10
- package/dist/cli.js +58 -50
- package/dist/coding/optional-coding-graph.js +7 -104
- package/dist/coding/optional-coding-graph.js.map +1 -1
- package/dist/compounding/engine.d.ts +1 -1
- package/dist/compounding/engine.js +12 -5
- 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 +1 -1
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +12 -5
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +12 -5
- package/dist/consolidation-provenance-check.d.ts +3 -3
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/contradiction/index.d.ts +1 -1
- 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/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- 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 +1 -1
- package/dist/entity-retrieval.js +13 -5
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +9 -8
- package/dist/extraction-faithfulness.d.ts +211 -0
- package/dist/extraction-faithfulness.js +35 -0
- 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-judge.js +4 -4
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +7 -7
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/fallback-llm.js +2 -2
- package/dist/{graph-edge-decay-D7OESCBR.js → graph-edge-decay-JLOF3YW4.js} +3 -3
- package/dist/graph-snapshot.js +3 -3
- package/dist/graph.js +2 -2
- package/dist/identity-continuity.d.ts +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/index.d.ts +12 -11
- package/dist/index.js +101 -99
- package/dist/index.js.map +1 -1
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +3 -3
- 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-llm.js +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +13 -5
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +13 -5
- package/dist/maintenance/rebuild-memory-projection.js +14 -6
- package/dist/mcp-memory-inspector-app.d.ts +12 -11
- 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-worth-outcomes.d.ts +1 -1
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +2 -2
- package/dist/namespaces/migrate.js +20 -12
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +6 -6
- package/dist/namespaces/storage.d.ts +2 -2
- package/dist/namespaces/storage.js +13 -5
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +1 -1
- package/dist/operator-toolkit.js +26 -19
- package/dist/orchestration/maintenance.d.ts +2 -2
- package/dist/orchestration/maintenance.js +15 -7
- package/dist/{orchestrator-CNJCYjZ1.d.ts → orchestrator-Dv8JQu3-.d.ts} +20 -3
- package/dist/orchestrator.d.ts +6 -5
- package/dist/orchestrator.js +47 -46
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.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-planner-llm.d.ts +1 -1
- package/dist/recall-planner-llm.js +2 -2
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.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/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +2 -2
- package/dist/retrieval-agents.d.ts +1 -1
- 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/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/factory.js +5 -5
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +5 -5
- 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-D5U0Mrdb.d.ts → semantic-consolidation-CgREi9E0.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +13 -6
- package/dist/semantic-rule-promotion.js +13 -5
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +13 -5
- 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 +1 -1
- package/dist/signal.d.ts +1 -1
- package/dist/{state-NCHQ4TRG.js → state-ITXJKXRE.js} +2 -2
- package/dist/storage.d.ts +11 -1
- package/dist/storage.js +12 -4
- package/dist/summarizer.d.ts +1 -1
- package/dist/summarizer.js +6 -6
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.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 +1 -1
- package/dist/tier-routing.d.ts +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/{trace-WM7V4CKI.js → trace-ZFVRH4GO.js} +3 -3
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/backup.js +2 -2
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/capsule-import.js +2 -2
- package/dist/{tui-RI7P6PBS.js → tui-55UJMJX7.js} +3 -3
- package/dist/tui-55UJMJX7.js.map +1 -0
- package/dist/{types-2NoBoRBM.d.ts → types-CeZYSC-E.d.ts} +51 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +13 -5
- package/package.json +2 -2
- package/src/access-boundary.ts +17 -0
- package/src/access-http.ts +27 -3
- package/src/access-mcp.ts +99 -2
- package/src/access-operations.ts +259 -0
- package/src/access-service.ts +82 -0
- package/src/access-surface-catalog.test.ts +1 -1
- package/src/access-surface-catalog.ts +15 -0
- package/src/cli.ts +1 -0
- package/src/coding/architecture-surfaces.test.ts +2 -0
- package/src/coding/codegraph-runtime.ts +773 -0
- package/src/coding/codegraph-surfaces.test.ts +880 -0
- package/src/coding/codegraph-surfaces.ts +771 -0
- package/src/coding/coding-knowledge-config.ts +7 -0
- package/src/coding/decision-surfaces.test.ts +2 -0
- package/src/coding/session-delta-surfaces.test.ts +2 -0
- package/src/config.test.ts +18 -0
- package/src/config.ts +30 -0
- package/src/console/state.ts +32 -0
- package/src/extraction-faithfulness.test.ts +1112 -0
- package/src/extraction-faithfulness.ts +993 -0
- package/src/faithfulness-graph-guard.test.ts +252 -0
- package/src/local-llm.ts +1 -0
- package/src/orchestrator.ts +169 -45
- package/src/storage.ts +19 -0
- package/src/types.ts +61 -0
- package/dist/chunk-5HGPDRQZ.js.map +0 -1
- package/dist/chunk-DQHZA7Y3.js.map +0 -1
- package/dist/chunk-F7BVJ3IE.js.map +0 -1
- package/dist/chunk-JNKH2XWQ.js +0 -183
- package/dist/chunk-JNKH2XWQ.js.map +0 -1
- package/dist/chunk-MQTPUPLP.js.map +0 -1
- package/dist/chunk-RHWFMBO5.js.map +0 -1
- package/dist/chunk-THKNO6OX.js.map +0 -1
- package/dist/chunk-TYEOAFH3.js.map +0 -1
- package/dist/chunk-UPTZYUYJ.js.map +0 -1
- package/dist/chunk-UTUYAPLY.js.map +0 -1
- package/dist/chunk-VFVG4NS2.js.map +0 -1
- package/dist/chunk-WYB44HHV.js.map +0 -1
- /package/dist/{auto-sync-RWXT6P5M.js.map → auto-sync-PFW2NJZY.js.map} +0 -0
- /package/dist/{capsule-crypto-7FJQINUR.js.map → capsule-crypto-YO5QJ6L3.js.map} +0 -0
- /package/dist/{chunk-YN4ZT4CW.js.map → chunk-3LYJIA76.js.map} +0 -0
- /package/dist/{chunk-ADUAF5EV.js.map → chunk-3P2XEQSV.js.map} +0 -0
- /package/dist/{chunk-KYH53EFD.js.map → chunk-4NNDJOAO.js.map} +0 -0
- /package/dist/{chunk-QFG23CRE.js.map → chunk-52QIAN76.js.map} +0 -0
- /package/dist/{chunk-TAPSNIMA.js.map → chunk-5CEJH5ZN.js.map} +0 -0
- /package/dist/{chunk-4RGWCRIJ.js.map → chunk-5TYA4OCF.js.map} +0 -0
- /package/dist/{chunk-FM7KLRKN.js.map → chunk-6GAUF4OU.js.map} +0 -0
- /package/dist/{chunk-6C2BMUZA.js.map → chunk-AF6DSAWD.js.map} +0 -0
- /package/dist/{chunk-2NLLXCJG.js.map → chunk-BXLOS5AJ.js.map} +0 -0
- /package/dist/{chunk-32KD5IHZ.js.map → chunk-CLXTDOKV.js.map} +0 -0
- /package/dist/{chunk-ARV3AUOM.js.map → chunk-DL6H3D7S.js.map} +0 -0
- /package/dist/{chunk-X7Y7WX73.js.map → chunk-DQEMWVMT.js.map} +0 -0
- /package/dist/{chunk-3BRA3N5A.js.map → chunk-EC3A6M43.js.map} +0 -0
- /package/dist/{chunk-ZLXGFAML.js.map → chunk-FZMH66NT.js.map} +0 -0
- /package/dist/{chunk-HXNMDPHN.js.map → chunk-G663XUEG.js.map} +0 -0
- /package/dist/{chunk-YOI3ELXF.js.map → chunk-IF362TF6.js.map} +0 -0
- /package/dist/{chunk-WIKNVFBS.js.map → chunk-J45OCIVH.js.map} +0 -0
- /package/dist/{chunk-UDJLF3BO.js.map → chunk-JI6HWBYL.js.map} +0 -0
- /package/dist/{chunk-ECZPWSB5.js.map → chunk-JJT3AGL4.js.map} +0 -0
- /package/dist/{chunk-4NFVPDIL.js.map → chunk-LM6JB2EG.js.map} +0 -0
- /package/dist/{chunk-AFWEUTMS.js.map → chunk-LPIWEKZ3.js.map} +0 -0
- /package/dist/{chunk-LD53WPMU.js.map → chunk-LQ6JI4VH.js.map} +0 -0
- /package/dist/{chunk-U2OBZSGG.js.map → chunk-MNFAGE5D.js.map} +0 -0
- /package/dist/{chunk-MCV2DD6F.js.map → chunk-NLZO5NO6.js.map} +0 -0
- /package/dist/{chunk-3VVH6ZQW.js.map → chunk-Q6ZHGGNJ.js.map} +0 -0
- /package/dist/{chunk-4IQNAOP3.js.map → chunk-Q7SFJURX.js.map} +0 -0
- /package/dist/{chunk-MXZWKOOR.js.map → chunk-QJM2XAJD.js.map} +0 -0
- /package/dist/{chunk-6ZNIUGXB.js.map → chunk-QQW2LIEA.js.map} +0 -0
- /package/dist/{chunk-GCOSQBQ2.js.map → chunk-QVTSLRKT.js.map} +0 -0
- /package/dist/{chunk-NUZ3N445.js.map → chunk-SPVIG2R3.js.map} +0 -0
- /package/dist/{chunk-2D27ODNX.js.map → chunk-TIVZ4MCG.js.map} +0 -0
- /package/dist/{chunk-5KBNNUXS.js.map → chunk-TT7BJWGI.js.map} +0 -0
- /package/dist/{chunk-KQAFEZQX.js.map → chunk-VDX2J7OX.js.map} +0 -0
- /package/dist/{chunk-E6BOD3UJ.js.map → chunk-VPAFWWCL.js.map} +0 -0
- /package/dist/{chunk-UOCLRM74.js.map → chunk-W54EAJT4.js.map} +0 -0
- /package/dist/{chunk-QVG4LAQO.js.map → chunk-WR6KFJKA.js.map} +0 -0
- /package/dist/{chunk-YQGHW5ML.js.map → chunk-WRFKZEO6.js.map} +0 -0
- /package/dist/{chunk-66HROLW5.js.map → chunk-XWT4JXXA.js.map} +0 -0
- /package/dist/{chunk-SAC5V6JT.js.map → chunk-XXA6T3O4.js.map} +0 -0
- /package/dist/{chunk-KF74X62T.js.map → chunk-YGKUAX2B.js.map} +0 -0
- /package/dist/{chunk-W4ELOUNX.js.map → chunk-YOZNTNNA.js.map} +0 -0
- /package/dist/{state-NCHQ4TRG.js.map → extraction-faithfulness.js.map} +0 -0
- /package/dist/{graph-edge-decay-D7OESCBR.js.map → graph-edge-decay-JLOF3YW4.js.map} +0 -0
- /package/dist/{tui-RI7P6PBS.js.map → state-ITXJKXRE.js.map} +0 -0
- /package/dist/{trace-WM7V4CKI.js.map → trace-ZFVRH4GO.js.map} +0 -0
|
@@ -0,0 +1,771 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codegraph parity surface contract + handler (issue #1554).
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the decision-surfaces.ts / architecture-surfaces.ts pattern: one
|
|
5
|
+
* shared implementation behind the MCP, HTTP, and CLI surfaces. All three
|
|
6
|
+
* transports dispatch through the `codegraph_*` boundary operations, which
|
|
7
|
+
* call {@link handleCodegraphTool} via the service delegate.
|
|
8
|
+
*
|
|
9
|
+
* Gate (rule 39): `codingKnowledge.enabled + codegraphTools + runtime
|
|
10
|
+
* availability` -- one predicate (`codegraphSurfaceVisible`), checked
|
|
11
|
+
* identically on every surface. The tools/list visibility gate uses the
|
|
12
|
+
* config-only predicate; the call-time gate re-checks config AND runtime
|
|
13
|
+
* availability AND (for tools that touch a per-session project) a coding
|
|
14
|
+
* context.
|
|
15
|
+
*
|
|
16
|
+
* Reuse, don't fork (rule 22): `manage_adr` reuses Track A's decision
|
|
17
|
+
* records (`coding/decision-records.ts`); `get_architecture` composes
|
|
18
|
+
* Track A's architecture card with live graph stats. Zero duplicated ADR
|
|
19
|
+
* or architecture-card logic.
|
|
20
|
+
*/
|
|
21
|
+
import type { PluginConfig, CodingContext } from "../types.js";
|
|
22
|
+
import {
|
|
23
|
+
codegraphRuntimeAvailable,
|
|
24
|
+
codegraphSurfaceVisible,
|
|
25
|
+
getCodegraphStore,
|
|
26
|
+
listCodegraphProjects,
|
|
27
|
+
deleteCodegraphProject,
|
|
28
|
+
CodegraphRuntimeError,
|
|
29
|
+
type CodegraphStore,
|
|
30
|
+
type CodegraphSchemaStatsResult,
|
|
31
|
+
} from "./codegraph-runtime.js";
|
|
32
|
+
import {
|
|
33
|
+
DECISION_SUBCOMMANDS,
|
|
34
|
+
handleCodingDecision,
|
|
35
|
+
isDecisionRecordSurfaceEnabled,
|
|
36
|
+
type DecisionSurfaceContext,
|
|
37
|
+
type DecisionSurfaceRequest,
|
|
38
|
+
type DecisionSurfaceResponse,
|
|
39
|
+
} from "./decision-surfaces.js";
|
|
40
|
+
|
|
41
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
42
|
+
// Canonical tool names — mirror the external codebase-memory-mcp surface
|
|
43
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
44
|
+
|
|
45
|
+
export const CODEGRAPH_TOOL_NAMES = [
|
|
46
|
+
"index",
|
|
47
|
+
"list_projects",
|
|
48
|
+
"delete_project",
|
|
49
|
+
"index_status",
|
|
50
|
+
"search_graph",
|
|
51
|
+
"trace_path",
|
|
52
|
+
"detect_changes",
|
|
53
|
+
"query_graph",
|
|
54
|
+
"get_schema",
|
|
55
|
+
"get_snippet",
|
|
56
|
+
"get_architecture",
|
|
57
|
+
"search_code",
|
|
58
|
+
"manage_adr",
|
|
59
|
+
"ingest_traces",
|
|
60
|
+
] as const;
|
|
61
|
+
|
|
62
|
+
export type CodegraphToolName = (typeof CODEGRAPH_TOOL_NAMES)[number];
|
|
63
|
+
|
|
64
|
+
const TOOL_NAME_SET: ReadonlySet<string> = new Set(CODEGRAPH_TOOL_NAMES as readonly string[]);
|
|
65
|
+
|
|
66
|
+
/** Type guard — narrows an unknown string to a {@link CodegraphToolName}. */
|
|
67
|
+
export function isCodegraphToolName(value: unknown): value is CodegraphToolName {
|
|
68
|
+
return typeof value === "string" && TOOL_NAME_SET.has(value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Human-readable list for error messages (rule 51). */
|
|
72
|
+
export function formatCodegraphToolNames(): string {
|
|
73
|
+
return CODEGRAPH_TOOL_NAMES.join(", ");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
77
|
+
// Surface request / response shapes
|
|
78
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Canonical surface request — one shape for all three transports. `tool`
|
|
82
|
+
* selects which codegraph operation runs; `sessionKey`/`principal`/`project`
|
|
83
|
+
* scope the per-project GraphStore lookup; remaining fields are
|
|
84
|
+
* tool-specific and validated by the handler.
|
|
85
|
+
*/
|
|
86
|
+
export interface CodegraphSurfaceRequest {
|
|
87
|
+
readonly tool: CodegraphToolName;
|
|
88
|
+
readonly sessionKey?: string;
|
|
89
|
+
readonly principal?: string;
|
|
90
|
+
/** Explicit project id; defaults to the session's coding-context projectId. */
|
|
91
|
+
readonly project?: string;
|
|
92
|
+
// search_graph / search_code
|
|
93
|
+
readonly query?: string;
|
|
94
|
+
readonly limit?: number;
|
|
95
|
+
// trace_path
|
|
96
|
+
readonly start?: string;
|
|
97
|
+
readonly direction?: string;
|
|
98
|
+
readonly depth?: number;
|
|
99
|
+
// get_snippet
|
|
100
|
+
readonly qualifiedName?: string;
|
|
101
|
+
readonly path?: string;
|
|
102
|
+
// query_graph (structured; Cypher passthrough is rejected)
|
|
103
|
+
readonly structuredQuery?: Record<string, unknown>;
|
|
104
|
+
// detect_changes
|
|
105
|
+
readonly head?: string;
|
|
106
|
+
// index
|
|
107
|
+
readonly repoRoot?: string;
|
|
108
|
+
readonly mode?: string;
|
|
109
|
+
// delete_project
|
|
110
|
+
readonly confirm?: boolean;
|
|
111
|
+
// manage_adr (delegates to Track A's decision records)
|
|
112
|
+
readonly subcommand?: string;
|
|
113
|
+
readonly id?: string;
|
|
114
|
+
readonly title?: string;
|
|
115
|
+
readonly status?: string;
|
|
116
|
+
readonly context?: string;
|
|
117
|
+
readonly decision?: string;
|
|
118
|
+
readonly consequences?: string;
|
|
119
|
+
readonly entityRefs?: string[];
|
|
120
|
+
readonly supersedesId?: string;
|
|
121
|
+
// ingest_traces
|
|
122
|
+
readonly traces?: unknown[];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export type CodegraphSurfaceResponse =
|
|
126
|
+
| { tool: CodegraphToolName; ok: true; result: unknown }
|
|
127
|
+
| { tool: CodegraphToolName; ok: false; code: string; message: string };
|
|
128
|
+
|
|
129
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
130
|
+
// Runtime-delegate outcomes — the handler surfaces these verbatim so the
|
|
131
|
+
// surface never reports stub success for index / ingest / status / detect.
|
|
132
|
+
// Each delegate is OPTIONAL: when the runtime (@remnic/coding-graph) is
|
|
133
|
+
// unavailable, the access-service omits it and the handler degrades with a
|
|
134
|
+
// clean code instead of pretending success (P1 fix, issue #1554 review).
|
|
135
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
136
|
+
|
|
137
|
+
/** Outcome of a reindex run (mirrors @remnic/coding-graph ReindexResult). */
|
|
138
|
+
export type CodegraphReindexOutcome =
|
|
139
|
+
| { ok: true; mode: string; filesIngested: number; head: string | null }
|
|
140
|
+
| { ok: false; code: string; message: string };
|
|
141
|
+
|
|
142
|
+
/** Outcome of an index-status probe (mirrors IndexStatus). The status body
|
|
143
|
+
* is opaque at the surface layer — the runtime delegate returns the real
|
|
144
|
+
* IndexStatus shape from @remnic/coding-graph and the surface passes it
|
|
145
|
+
* through as `result: unknown` (core must not depend on the optional
|
|
146
|
+
* package's exact type). */
|
|
147
|
+
export type CodegraphIndexStatusOutcome =
|
|
148
|
+
| { ok: true; status: Record<string, unknown> }
|
|
149
|
+
| { ok: false; code: string; message: string };
|
|
150
|
+
|
|
151
|
+
/** Outcome of a detect_changes / blast-radius computation. */
|
|
152
|
+
export type CodegraphDetectChangesOutcome =
|
|
153
|
+
| { ok: true; affected: readonly unknown[] }
|
|
154
|
+
| { ok: false; code: string; message: string };
|
|
155
|
+
|
|
156
|
+
/** Outcome of trace ingestion (persisted edges). */
|
|
157
|
+
export type CodegraphIngestTracesOutcome =
|
|
158
|
+
| { ok: true; accepted: number; persisted: number }
|
|
159
|
+
| { ok: false; code: string; message: string };
|
|
160
|
+
|
|
161
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
162
|
+
// Allow-lists for enum-ish params — rule 51 (reject loudly, list options)
|
|
163
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
164
|
+
|
|
165
|
+
const TRACE_DIRECTIONS = ["inbound", "outbound", "both"] as const;
|
|
166
|
+
const TRACE_DIRECTION_SET: ReadonlySet<string> = new Set(TRACE_DIRECTIONS as readonly string[]);
|
|
167
|
+
|
|
168
|
+
const INDEX_MODES = ["auto", "full", "incremental"] as const;
|
|
169
|
+
const INDEX_MODE_SET: ReadonlySet<string> = new Set(INDEX_MODES as readonly string[]);
|
|
170
|
+
|
|
171
|
+
const MANAGE_ADR_SUBCOMMANDS = DECISION_SUBCOMMANDS;
|
|
172
|
+
|
|
173
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
174
|
+
// Handler context — the surface service wires this per call
|
|
175
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Dependencies the handler borrows from the service. The service constructs
|
|
179
|
+
* this context per call; the handler never touches the orchestrator or
|
|
180
|
+
* access-service directly. `throwInputError` lets the handler raise the
|
|
181
|
+
* surface-appropriate error class without a circular import.
|
|
182
|
+
*/
|
|
183
|
+
export interface CodegraphSurfaceContext {
|
|
184
|
+
readonly config: PluginConfig;
|
|
185
|
+
/** Resolved memory dir (used as the default codegraph root). */
|
|
186
|
+
readonly memoryDir: string;
|
|
187
|
+
/** Authenticated principal (HTTP header / MCP session / CLI flag). */
|
|
188
|
+
readonly principal: string;
|
|
189
|
+
getCodingContext(sessionKey: string): CodingContext | null;
|
|
190
|
+
/** Open (or fetch cached) per-project GraphStore. */
|
|
191
|
+
resolveStore(request: CodegraphSurfaceRequest): Promise<CodegraphStore>;
|
|
192
|
+
/** Walk the principal's codegraph dir. */
|
|
193
|
+
listDirs(dir: string): readonly string[];
|
|
194
|
+
/** Remove a file (best-effort, used by delete_project). */
|
|
195
|
+
removeFile(filePath: string): void;
|
|
196
|
+
/** Throw the surface-appropriate input-validation error. */
|
|
197
|
+
throwInputError(message: string): never;
|
|
198
|
+
/** Delegate manage_adr record/supersede to Track A's decision handler. */
|
|
199
|
+
delegateDecisionRecord(request: DecisionSurfaceRequest): Promise<DecisionSurfaceResponse>;
|
|
200
|
+
/** Composed architecture card + graph stats builder (Track A reuse). */
|
|
201
|
+
buildArchitectureCard(repoRoot: string): Promise<unknown>;
|
|
202
|
+
/**
|
|
203
|
+
* Run a reindex via @remnic/coding-graph's executeReindex. Optional — when
|
|
204
|
+
* omitted (runtime unavailable), the index handler degrades with a clean
|
|
205
|
+
* code instead of stub success (P1 fix).
|
|
206
|
+
*/
|
|
207
|
+
runReindex?(store: CodegraphStore, repoRoot: string, mode: string): Promise<CodegraphReindexOutcome>;
|
|
208
|
+
/**
|
|
209
|
+
* Report index status via @remnic/coding-graph's getIndexStatus. Optional —
|
|
210
|
+
* when omitted, index_status degrades with a clean code (no placeholder).
|
|
211
|
+
*/
|
|
212
|
+
reportIndexStatus?(store: CodegraphStore, repoRoot: string): Promise<CodegraphIndexStatusOutcome>;
|
|
213
|
+
/**
|
|
214
|
+
* Detect changes / blast radius via @remnic/coding-graph's detect-changes
|
|
215
|
+
* pipeline. Optional — when omitted, detect_changes degrades cleanly.
|
|
216
|
+
*/
|
|
217
|
+
detectChanges?(store: CodegraphStore, repoRoot: string, head: string): Promise<CodegraphDetectChangesOutcome>;
|
|
218
|
+
/**
|
|
219
|
+
* Persist runtime call traces as HTTP_CALLS edges via the store's write
|
|
220
|
+
* path. Optional — when omitted, ingest_traces degrades cleanly. The
|
|
221
|
+
* returned `persisted` count is the number of traces actually written.
|
|
222
|
+
*/
|
|
223
|
+
ingestTraces?(store: CodegraphStore, traces: readonly unknown[]): Promise<CodegraphIngestTracesOutcome>;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* The single shared implementation behind the MCP, HTTP, and CLI codegraph
|
|
228
|
+
* tool surfaces. All three transports dispatch through the `codegraph_*`
|
|
229
|
+
* boundary operations, which call this function via the service delegate.
|
|
230
|
+
*/
|
|
231
|
+
export async function handleCodegraphTool(
|
|
232
|
+
request: CodegraphSurfaceRequest,
|
|
233
|
+
ctx: CodegraphSurfaceContext,
|
|
234
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
235
|
+
// Gate 1: config-only predicate. Runtime availability check follows per
|
|
236
|
+
// tool so that `list_projects` (which does not need a store) still works
|
|
237
|
+
// when the package is missing -- it returns the empty list with a clean
|
|
238
|
+
// code rather than throwing.
|
|
239
|
+
if (!codegraphSurfaceVisible(ctx.config)) {
|
|
240
|
+
return disabledResponse(request.tool, "codegraph tools are disabled in config");
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
switch (request.tool) {
|
|
244
|
+
case "list_projects":
|
|
245
|
+
return handleListProjects(request, ctx);
|
|
246
|
+
case "get_schema":
|
|
247
|
+
return withStore(request, ctx, (store) => handleGetSchema(store, request.tool));
|
|
248
|
+
case "search_graph":
|
|
249
|
+
return withStore(request, ctx, (store) => handleSearchGraph(store, request, ctx));
|
|
250
|
+
case "search_code":
|
|
251
|
+
return withStore(request, ctx, (store) => handleSearchCode(store, request, ctx));
|
|
252
|
+
case "trace_path":
|
|
253
|
+
return withStore(request, ctx, (store) => handleTracePath(store, request, ctx));
|
|
254
|
+
case "get_snippet":
|
|
255
|
+
return withStore(request, ctx, (store) => handleGetSnippet(store, request, ctx));
|
|
256
|
+
case "query_graph":
|
|
257
|
+
return withStore(request, ctx, (store) => handleQueryGraph(store, request, ctx));
|
|
258
|
+
case "index_status":
|
|
259
|
+
return withStore(request, ctx, (store) => handleIndexStatus(store, request, ctx));
|
|
260
|
+
case "detect_changes":
|
|
261
|
+
return withStore(request, ctx, (store) => handleDetectChanges(store, request, ctx));
|
|
262
|
+
case "index":
|
|
263
|
+
return handleIndex(request, ctx);
|
|
264
|
+
case "delete_project":
|
|
265
|
+
return handleDeleteProject(request, ctx);
|
|
266
|
+
case "get_architecture":
|
|
267
|
+
return handleGetArchitecture(request, ctx);
|
|
268
|
+
case "manage_adr":
|
|
269
|
+
return handleManageAdr(request, ctx);
|
|
270
|
+
case "ingest_traces":
|
|
271
|
+
return withStore(request, ctx, (store) => handleIngestTraces(store, request, ctx));
|
|
272
|
+
default: {
|
|
273
|
+
// Exhaustive: the switch above covers CODEGRAPH_TOOL_NAMES. The
|
|
274
|
+
// default branch exists so a future tool added to the union without
|
|
275
|
+
// a handler here fails closed rather than silently no-oping.
|
|
276
|
+
const _exhaustive: never = request.tool;
|
|
277
|
+
void _exhaustive;
|
|
278
|
+
ctx.throwInputError(`unknown codegraph tool: ${request.tool}`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function disabledResponse(tool: CodegraphToolName, message: string): CodegraphSurfaceResponse {
|
|
284
|
+
return { tool, ok: false, code: "disabled", message };
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Resolve the per-project store and run `fn`. Translates
|
|
289
|
+
* {@link CodegraphRuntimeError} codes into the surface response shape so
|
|
290
|
+
* the transport layer never has to pattern-match on error class.
|
|
291
|
+
*/
|
|
292
|
+
async function withStore(
|
|
293
|
+
request: CodegraphSurfaceRequest,
|
|
294
|
+
ctx: CodegraphSurfaceContext,
|
|
295
|
+
fn: (store: CodegraphStore) => Promise<CodegraphSurfaceResponse>,
|
|
296
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
297
|
+
let store: CodegraphStore;
|
|
298
|
+
try {
|
|
299
|
+
store = await ctx.resolveStore(request);
|
|
300
|
+
} catch (err) {
|
|
301
|
+
if (err instanceof CodegraphRuntimeError) {
|
|
302
|
+
return { tool: request.tool, ok: false, code: err.code, message: err.message };
|
|
303
|
+
}
|
|
304
|
+
throw err;
|
|
305
|
+
}
|
|
306
|
+
return fn(store);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
310
|
+
// Per-tool handlers — thin adapters over the store's structured API.
|
|
311
|
+
// No query logic in the surface layer (issue #1554 design).
|
|
312
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
313
|
+
|
|
314
|
+
async function handleListProjects(
|
|
315
|
+
request: CodegraphSurfaceRequest,
|
|
316
|
+
ctx: CodegraphSurfaceContext,
|
|
317
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
318
|
+
const projects = listCodegraphProjects({
|
|
319
|
+
config: ctx.config,
|
|
320
|
+
memoryDir: ctx.memoryDir,
|
|
321
|
+
principal: ctx.principal,
|
|
322
|
+
listDir: ctx.listDirs,
|
|
323
|
+
});
|
|
324
|
+
return { tool: request.tool, ok: true, result: { projects } };
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async function handleGetSchema(
|
|
328
|
+
store: CodegraphStore,
|
|
329
|
+
tool: CodegraphToolName,
|
|
330
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
331
|
+
const stats = store.schemaStats();
|
|
332
|
+
// Thread 12 (cursor bugbot): a closed-store / invalid-query failure arrives
|
|
333
|
+
// as { ok: false, code }. The surface MUST mirror that to ok:false so MCP/HTTP
|
|
334
|
+
// clients honoring CodegraphSurfaceResponse.ok do not treat failures as
|
|
335
|
+
// successes (search_code already did this; the other read handlers did not).
|
|
336
|
+
if (!stats.ok) {
|
|
337
|
+
return { tool, ok: false, code: stats.code, message: "schemaStats failed" };
|
|
338
|
+
}
|
|
339
|
+
return { tool, ok: true, result: stats };
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
async function handleSearchGraph(
|
|
343
|
+
store: CodegraphStore,
|
|
344
|
+
request: CodegraphSurfaceRequest,
|
|
345
|
+
ctx: CodegraphSurfaceContext,
|
|
346
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
347
|
+
const query = requireString(request.query, "query", ctx);
|
|
348
|
+
const limit = clampPositiveInteger(request.limit, 50, "limit", ctx);
|
|
349
|
+
// Map the surface `query` to the store's SearchQuery shape: the store's
|
|
350
|
+
// searchGraph reads `namePattern` (not `query`) for symbol-name matching.
|
|
351
|
+
const result = store.searchGraph({ namePattern: query, limit });
|
|
352
|
+
if (!result.ok) {
|
|
353
|
+
return { tool: request.tool, ok: false, code: result.code, message: "searchGraph failed" };
|
|
354
|
+
}
|
|
355
|
+
return { tool: request.tool, ok: true, result };
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** Symbol kinds search_code limits results to (issue #1554 rejection table). */
|
|
359
|
+
const SEARCH_CODE_KINDS = ["function", "class", "method"] as const;
|
|
360
|
+
|
|
361
|
+
async function handleSearchCode(
|
|
362
|
+
store: CodegraphStore,
|
|
363
|
+
request: CodegraphSurfaceRequest,
|
|
364
|
+
ctx: CodegraphSurfaceContext,
|
|
365
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
366
|
+
const query = requireString(request.query, "query", ctx);
|
|
367
|
+
const limit = clampPositiveInteger(request.limit, 50, "limit", ctx);
|
|
368
|
+
// search_code limits results to code symbol kinds (function/class/method).
|
|
369
|
+
// The store's SearchQuery.label takes a SINGLE kind, so query per kind and
|
|
370
|
+
// merge + dedupe by nodeId. The earlier `kinds` array was silently
|
|
371
|
+
// ignored by GraphStore.searchGraph, making this an unfiltered name search
|
|
372
|
+
// (issue #1554 review threads: kind filter must be real, not cosmetic).
|
|
373
|
+
const seen = new Set<string>();
|
|
374
|
+
const merged: unknown[] = [];
|
|
375
|
+
for (const kind of SEARCH_CODE_KINDS) {
|
|
376
|
+
if (merged.length >= limit) break;
|
|
377
|
+
const result = store.searchGraph({ label: kind, namePattern: query, limit });
|
|
378
|
+
if (!result.ok) {
|
|
379
|
+
return { tool: request.tool, ok: false, code: result.code, message: "searchGraph failed" };
|
|
380
|
+
}
|
|
381
|
+
for (const hit of result.hits as readonly Record<string, unknown>[]) {
|
|
382
|
+
const id = typeof hit?.nodeId === "string" ? hit.nodeId : JSON.stringify(hit);
|
|
383
|
+
if (seen.has(id)) continue;
|
|
384
|
+
seen.add(id);
|
|
385
|
+
merged.push(hit);
|
|
386
|
+
if (merged.length >= limit) break;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return { tool: request.tool, ok: true, result: { hits: merged } };
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
async function handleTracePath(
|
|
393
|
+
store: CodegraphStore,
|
|
394
|
+
request: CodegraphSurfaceRequest,
|
|
395
|
+
ctx: CodegraphSurfaceContext,
|
|
396
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
397
|
+
const start = requireString(request.start, "start", ctx);
|
|
398
|
+
const direction = request.direction ?? "outbound";
|
|
399
|
+
if (!TRACE_DIRECTION_SET.has(direction)) {
|
|
400
|
+
ctx.throwInputError(
|
|
401
|
+
`direction must be one of ${TRACE_DIRECTIONS.join(", ")}; got ${JSON.stringify(direction)}`,
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
const depth = clampPositiveInteger(request.depth ?? 2, 2, "depth", ctx);
|
|
405
|
+
// Map the surface direction names to the store's contract: the store
|
|
406
|
+
// expects `incoming`/`outgoing`/`both` and `maxDepth` (not depth).
|
|
407
|
+
const storeDirection = direction === "outbound" ? "outgoing" : direction === "inbound" ? "incoming" : direction;
|
|
408
|
+
const result = store.traverse({ start, direction: storeDirection, maxDepth: depth });
|
|
409
|
+
if (!result.ok) {
|
|
410
|
+
return { tool: request.tool, ok: false, code: result.code, message: "traverse failed" };
|
|
411
|
+
}
|
|
412
|
+
return { tool: request.tool, ok: true, result };
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
async function handleGetSnippet(
|
|
416
|
+
store: CodegraphStore,
|
|
417
|
+
request: CodegraphSurfaceRequest,
|
|
418
|
+
ctx: CodegraphSurfaceContext,
|
|
419
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
420
|
+
const qualifiedName = requireString(request.qualifiedName, "qualifiedName", ctx);
|
|
421
|
+
const result = await store.snippetFor({ qualifiedName });
|
|
422
|
+
if (!result.ok) {
|
|
423
|
+
return { tool: request.tool, ok: false, code: result.code, message: "snippetFor failed" };
|
|
424
|
+
}
|
|
425
|
+
return { tool: request.tool, ok: true, result };
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
async function handleQueryGraph(
|
|
429
|
+
store: CodegraphStore,
|
|
430
|
+
request: CodegraphSurfaceRequest,
|
|
431
|
+
ctx: CodegraphSurfaceContext,
|
|
432
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
433
|
+
// Cypher passthrough is rejected: the store exposes a STRUCTURED query
|
|
434
|
+
// API (searchGraph / traverse / schemaStats / deadCode); a string
|
|
435
|
+
// Cypher query against `query` is the documented rejection-table case.
|
|
436
|
+
if (typeof request.query === "string" && isLikelyCypher(request.query)) {
|
|
437
|
+
ctx.throwInputError(
|
|
438
|
+
"codegraph_query_graph does not accept Cypher text; pass a structured query via structuredQuery (issue #1554 rejection table)",
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
if (request.structuredQuery === undefined) {
|
|
442
|
+
ctx.throwInputError("codegraph_query_graph requires structuredQuery");
|
|
443
|
+
}
|
|
444
|
+
// The structured query is forwarded verbatim; the store validates the
|
|
445
|
+
// inner shape. The surface never interprets query internals.
|
|
446
|
+
const result = store.searchGraph(request.structuredQuery);
|
|
447
|
+
if (!result.ok) {
|
|
448
|
+
return { tool: request.tool, ok: false, code: result.code, message: "searchGraph failed" };
|
|
449
|
+
}
|
|
450
|
+
return { tool: request.tool, ok: true, result };
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
async function handleIndexStatus(
|
|
454
|
+
store: CodegraphStore,
|
|
455
|
+
request: CodegraphSurfaceRequest,
|
|
456
|
+
ctx: CodegraphSurfaceContext,
|
|
457
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
458
|
+
const repoRoot = resolveRepoRoot(request, ctx);
|
|
459
|
+
// Delegate to @remnic/coding-graph's getIndexStatus via the runtime. When
|
|
460
|
+
// the runtime delegate is absent (package missing), degrade with a clean
|
|
461
|
+
// code instead of a placeholder success (issue #1554 review thread).
|
|
462
|
+
if (!ctx.reportIndexStatus) {
|
|
463
|
+
return {
|
|
464
|
+
tool: request.tool,
|
|
465
|
+
ok: false,
|
|
466
|
+
code: "runtime_unavailable",
|
|
467
|
+
message: "index_status requires @remnic/coding-graph; the runtime is unavailable.",
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
void store; // store resolved by withStore; the delegate opens its own read path.
|
|
471
|
+
const outcome = await ctx.reportIndexStatus(store, repoRoot);
|
|
472
|
+
if (!outcome.ok) {
|
|
473
|
+
return { tool: request.tool, ok: false, code: outcome.code, message: outcome.message };
|
|
474
|
+
}
|
|
475
|
+
return { tool: request.tool, ok: true, result: outcome.status };
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
async function handleDetectChanges(
|
|
479
|
+
store: CodegraphStore,
|
|
480
|
+
request: CodegraphSurfaceRequest,
|
|
481
|
+
ctx: CodegraphSurfaceContext,
|
|
482
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
483
|
+
const head = requireString(request.head, "head", ctx);
|
|
484
|
+
// Delegate to @remnic/coding-graph's detect-changes + blast-radius
|
|
485
|
+
// pipeline (issue #1553). When the runtime delegate is absent, degrade
|
|
486
|
+
// with a clean code instead of a placeholder success (review thread).
|
|
487
|
+
if (!ctx.detectChanges) {
|
|
488
|
+
return {
|
|
489
|
+
tool: request.tool,
|
|
490
|
+
ok: false,
|
|
491
|
+
code: "runtime_unavailable",
|
|
492
|
+
message: "detect_changes requires @remnic/coding-graph; the runtime is unavailable.",
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
const repoRoot = resolveRepoRoot(request, ctx);
|
|
496
|
+
void store;
|
|
497
|
+
const outcome = await ctx.detectChanges(store, repoRoot, head);
|
|
498
|
+
if (!outcome.ok) {
|
|
499
|
+
return { tool: request.tool, ok: false, code: outcome.code, message: outcome.message };
|
|
500
|
+
}
|
|
501
|
+
return { tool: request.tool, ok: true, result: { head, affected: outcome.affected } };
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
async function handleIndex(
|
|
505
|
+
request: CodegraphSurfaceRequest,
|
|
506
|
+
ctx: CodegraphSurfaceContext,
|
|
507
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
508
|
+
const repoRoot = requireString(request.repoRoot, "repoRoot", ctx);
|
|
509
|
+
const modeRaw = request.mode ?? "auto";
|
|
510
|
+
if (!INDEX_MODE_SET.has(modeRaw)) {
|
|
511
|
+
ctx.throwInputError(`mode must be one of ${INDEX_MODES.join(", ")}; got ${JSON.stringify(modeRaw)}`);
|
|
512
|
+
}
|
|
513
|
+
// Open the per-project store. The reindex itself is invoked explicitly
|
|
514
|
+
// via ctx.runReindex below — GraphStore.open only creates/applies the
|
|
515
|
+
// schema; it does NOT parse or ingest files (P1 fix: previously the
|
|
516
|
+
// handler returned ok:true after open + schemaStats without reindexing).
|
|
517
|
+
//
|
|
518
|
+
// Open the per-project store. The reindex itself is invoked explicitly
|
|
519
|
+
// via ctx.runReindex below — GraphStore.open only creates/applies the
|
|
520
|
+
// schema; it does NOT parse or ingest files (P1 fix: previously the
|
|
521
|
+
// handler returned ok:true after open + schemaStats without reindexing).
|
|
522
|
+
//
|
|
523
|
+
// Project derivation for repoRoot-only callers lives in the SHARED
|
|
524
|
+
// resolveStore (access-service.ts) so every store-backed tool — index,
|
|
525
|
+
// search_graph, get_schema, index_status — reopens the SAME DB. No
|
|
526
|
+
// per-handler duplication (issue #1554 review threads 7/9/11).
|
|
527
|
+
const resolveReq = { ...request, repoRoot } as CodegraphSurfaceRequest;
|
|
528
|
+
let store: CodegraphStore;
|
|
529
|
+
try {
|
|
530
|
+
store = await ctx.resolveStore(resolveReq);
|
|
531
|
+
} catch (err) {
|
|
532
|
+
if (err instanceof CodegraphRuntimeError) {
|
|
533
|
+
return { tool: request.tool, ok: false, code: err.code, message: err.message };
|
|
534
|
+
}
|
|
535
|
+
throw err;
|
|
536
|
+
}
|
|
537
|
+
// Run the reindex executor. When the runtime delegate is absent (package
|
|
538
|
+
// missing), degrade with a clean code instead of stub success.
|
|
539
|
+
if (!ctx.runReindex) {
|
|
540
|
+
return {
|
|
541
|
+
tool: request.tool,
|
|
542
|
+
ok: false,
|
|
543
|
+
code: "runtime_unavailable",
|
|
544
|
+
message: "index requires @remnic/coding-graph's reindex executor; the runtime is unavailable.",
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
const outcome = await ctx.runReindex(store, repoRoot, modeRaw);
|
|
548
|
+
if (!outcome.ok) {
|
|
549
|
+
return { tool: request.tool, ok: false, code: outcome.code, message: outcome.message };
|
|
550
|
+
}
|
|
551
|
+
const stats = store.schemaStats();
|
|
552
|
+
return {
|
|
553
|
+
tool: request.tool,
|
|
554
|
+
ok: true,
|
|
555
|
+
result: {
|
|
556
|
+
repoRoot,
|
|
557
|
+
mode: outcome.mode,
|
|
558
|
+
filesIngested: outcome.filesIngested,
|
|
559
|
+
head: outcome.head,
|
|
560
|
+
stats,
|
|
561
|
+
},
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
async function handleDeleteProject(
|
|
566
|
+
request: CodegraphSurfaceRequest,
|
|
567
|
+
ctx: CodegraphSurfaceContext,
|
|
568
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
569
|
+
const projectId = resolveProjectId(request, ctx);
|
|
570
|
+
if (request.confirm !== true) {
|
|
571
|
+
// Rule 48: destructive operations are never defaulted to proceed.
|
|
572
|
+
return {
|
|
573
|
+
tool: request.tool,
|
|
574
|
+
ok: false,
|
|
575
|
+
code: "confirm_required",
|
|
576
|
+
message: "codegraph_delete_project requires confirm: true (rule 48)",
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
try {
|
|
580
|
+
const result = await deleteCodegraphProject({
|
|
581
|
+
config: ctx.config,
|
|
582
|
+
memoryDir: ctx.memoryDir,
|
|
583
|
+
principal: ctx.principal,
|
|
584
|
+
projectId,
|
|
585
|
+
confirm: true,
|
|
586
|
+
removeFile: ctx.removeFile,
|
|
587
|
+
});
|
|
588
|
+
return { tool: request.tool, ok: true, result };
|
|
589
|
+
} catch (err) {
|
|
590
|
+
if (err instanceof CodegraphRuntimeError) {
|
|
591
|
+
return { tool: request.tool, ok: false, code: err.code, message: err.message };
|
|
592
|
+
}
|
|
593
|
+
throw err;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
async function handleGetArchitecture(
|
|
598
|
+
request: CodegraphSurfaceRequest,
|
|
599
|
+
ctx: CodegraphSurfaceContext,
|
|
600
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
601
|
+
const codingContext = resolveCodingContext(request, ctx);
|
|
602
|
+
const repoRoot = request.repoRoot ?? codingContext.rootPath;
|
|
603
|
+
// Composition (issue #1554): deterministic architecture card from Track A
|
|
604
|
+
// (no live graph) + live graph stats from the per-project store. Two
|
|
605
|
+
// existing sources, one composed response -- no duplicated card logic.
|
|
606
|
+
const card = await ctx.buildArchitectureCard(repoRoot);
|
|
607
|
+
let stats: CodegraphSchemaStatsResult;
|
|
608
|
+
try {
|
|
609
|
+
const store = await ctx.resolveStore(request);
|
|
610
|
+
stats = store.schemaStats();
|
|
611
|
+
} catch (err) {
|
|
612
|
+
if (err instanceof CodegraphRuntimeError) {
|
|
613
|
+
// Architecture card still returns; graph stats degrade to a clean
|
|
614
|
+
// "unavailable" code rather than failing the whole composition.
|
|
615
|
+
stats = { ok: false, code: err.code };
|
|
616
|
+
} else {
|
|
617
|
+
throw err;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return {
|
|
621
|
+
tool: request.tool,
|
|
622
|
+
ok: true,
|
|
623
|
+
result: { card, graphStats: stats },
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
async function handleManageAdr(
|
|
628
|
+
request: CodegraphSurfaceRequest,
|
|
629
|
+
ctx: CodegraphSurfaceContext,
|
|
630
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
631
|
+
const subcommand = request.subcommand;
|
|
632
|
+
if (typeof subcommand !== "string" || !(MANAGE_ADR_SUBCOMMANDS as readonly string[]).includes(subcommand)) {
|
|
633
|
+
ctx.throwInputError(
|
|
634
|
+
`manage_adr subcommand must be one of ${MANAGE_ADR_SUBCOMMANDS.join(", ")}; got ${JSON.stringify(subcommand)}`,
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
// Rule 22 reuse: codegraph_manage_adr is a *presentation* of Track A's
|
|
638
|
+
// decision records under the parity tool name. Same store, same status
|
|
639
|
+
// lifecycle, zero duplicate ADR logic. The identity test (issue #1554
|
|
640
|
+
// done-when) asserts that `manage_adr record` and `coding_decision record`
|
|
641
|
+
// write byte-identical records -- both routes call handleCodingDecision.
|
|
642
|
+
const codingContext = resolveCodingContext(request, ctx);
|
|
643
|
+
if (!isDecisionRecordSurfaceEnabled(ctx.config.codingKnowledge, codingContext)) {
|
|
644
|
+
return disabledResponse(
|
|
645
|
+
request.tool,
|
|
646
|
+
"manage_adr requires codingKnowledge.enabled + decisionRecords + an attached coding context",
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
const decisionRequest: DecisionSurfaceRequest = {
|
|
650
|
+
subcommand: subcommand as DecisionSurfaceRequest["subcommand"],
|
|
651
|
+
sessionKey: request.sessionKey,
|
|
652
|
+
id: request.id,
|
|
653
|
+
title: request.title,
|
|
654
|
+
status: request.status,
|
|
655
|
+
context: request.context,
|
|
656
|
+
decision: request.decision,
|
|
657
|
+
consequences: request.consequences,
|
|
658
|
+
entityRefs: request.entityRefs,
|
|
659
|
+
supersedesId: request.supersedesId,
|
|
660
|
+
};
|
|
661
|
+
const result = await ctx.delegateDecisionRecord(decisionRequest);
|
|
662
|
+
return { tool: request.tool, ok: true, result };
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
async function handleIngestTraces(
|
|
666
|
+
store: CodegraphStore,
|
|
667
|
+
request: CodegraphSurfaceRequest,
|
|
668
|
+
ctx: CodegraphSurfaceContext,
|
|
669
|
+
): Promise<CodegraphSurfaceResponse> {
|
|
670
|
+
if (!Array.isArray(request.traces)) {
|
|
671
|
+
ctx.throwInputError("codegraph_ingest_traces requires traces: an array of call-site observations");
|
|
672
|
+
}
|
|
673
|
+
// Persist traces as HTTP_CALLS edges via the store's write path. The
|
|
674
|
+
// trace→edge upgrade lives in the runtime delegate (P1 fix: previously
|
|
675
|
+
// the handler returned accepted: traces.length without persisting). When
|
|
676
|
+
// the runtime delegate is absent, degrade with a clean code.
|
|
677
|
+
if (!ctx.ingestTraces) {
|
|
678
|
+
return {
|
|
679
|
+
tool: request.tool,
|
|
680
|
+
ok: false,
|
|
681
|
+
code: "runtime_unavailable",
|
|
682
|
+
message: "ingest_traces requires @remnic/coding-graph's store write path; the runtime is unavailable.",
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
const outcome = await ctx.ingestTraces(store, request.traces);
|
|
686
|
+
if (!outcome.ok) {
|
|
687
|
+
return { tool: request.tool, ok: false, code: outcome.code, message: outcome.message };
|
|
688
|
+
}
|
|
689
|
+
return {
|
|
690
|
+
tool: request.tool,
|
|
691
|
+
ok: true,
|
|
692
|
+
result: {
|
|
693
|
+
accepted: outcome.accepted,
|
|
694
|
+
persisted: outcome.persisted,
|
|
695
|
+
},
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
700
|
+
// Helpers — validation + project resolution
|
|
701
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
702
|
+
|
|
703
|
+
function requireString(value: unknown, field: string, ctx: CodegraphSurfaceContext): string {
|
|
704
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
705
|
+
ctx.throwInputError(`codegraph: ${field} is required and must be a non-empty string`);
|
|
706
|
+
}
|
|
707
|
+
return value as string;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function clampPositiveInteger(
|
|
711
|
+
value: number | undefined,
|
|
712
|
+
defaultValue: number,
|
|
713
|
+
field: string,
|
|
714
|
+
ctx: CodegraphSurfaceContext,
|
|
715
|
+
): number {
|
|
716
|
+
if (value === undefined) return defaultValue;
|
|
717
|
+
if (typeof value !== "number" || !Number.isFinite(value) || !Number.isInteger(value) || value < 1) {
|
|
718
|
+
ctx.throwInputError(`codegraph: ${field} must be a positive integer; got ${JSON.stringify(value)}`);
|
|
719
|
+
}
|
|
720
|
+
return Math.min(value, 200);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
function resolveCodingContext(request: CodegraphSurfaceRequest, ctx: CodegraphSurfaceContext): CodingContext {
|
|
724
|
+
if (!request.sessionKey) {
|
|
725
|
+
ctx.throwInputError("codegraph tool requires a sessionKey with an attached coding context");
|
|
726
|
+
}
|
|
727
|
+
const codingContext = ctx.getCodingContext(request.sessionKey);
|
|
728
|
+
if (codingContext === null) {
|
|
729
|
+
ctx.throwInputError(
|
|
730
|
+
`no coding context attached to session ${request.sessionKey}; attach one via set_coding_context first`,
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
return codingContext;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
function resolveProjectId(request: CodegraphSurfaceRequest, ctx: CodegraphSurfaceContext): string {
|
|
737
|
+
if (typeof request.project === "string" && request.project.trim().length > 0) {
|
|
738
|
+
return request.project.trim();
|
|
739
|
+
}
|
|
740
|
+
return resolveCodingContext(request, ctx).projectId;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Resolve the repo root for index_status / detect_changes. Prefers an
|
|
745
|
+
* explicit `repoRoot` on the request; falls back to the session's coding
|
|
746
|
+
* context rootPath (the same fallback get_architecture uses). Throws a
|
|
747
|
+
* surface input error when neither is available so the runtime delegate
|
|
748
|
+
* never receives an empty root.
|
|
749
|
+
*/
|
|
750
|
+
function resolveRepoRoot(request: CodegraphSurfaceRequest, ctx: CodegraphSurfaceContext): string {
|
|
751
|
+
if (typeof request.repoRoot === "string" && request.repoRoot.trim().length > 0) {
|
|
752
|
+
return request.repoRoot.trim();
|
|
753
|
+
}
|
|
754
|
+
return resolveCodingContext(request, ctx).rootPath;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Cheap heuristic for the rejection table: a string starting with a Cypher
|
|
759
|
+
* keyword (`MATCH`, `RETURN`, `WHERE`, ...) is rejected as Cypher text.
|
|
760
|
+
*/
|
|
761
|
+
function isLikelyCypher(input: string): boolean {
|
|
762
|
+
return /^\s*(MATCH|RETURN|WHERE|CREATE|MERGE|DELETE|WITH|OPTIONAL|CALL|YIELD|UNWIND)\b/i.test(input);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// Re-export the runtime helpers the access-service delegate uses so the
|
|
766
|
+
// surface module is the single import for callers wiring the boundary.
|
|
767
|
+
export {
|
|
768
|
+
codegraphSurfaceVisible,
|
|
769
|
+
codegraphRuntimeAvailable,
|
|
770
|
+
getCodegraphStore,
|
|
771
|
+
};
|