@remnic/core 9.65.2 → 9.65.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-admin-ops-surface.d.ts +44 -44
- package/dist/access-admin-ops-surface.js +14 -14
- package/dist/access-authorization-probe.d.ts +38 -38
- package/dist/access-authorization-probe.js +15 -15
- package/dist/access-boundary.d.ts +40 -40
- package/dist/access-boundary.js +14 -14
- package/dist/access-cli.js +52 -52
- package/dist/access-coding-context-resolution.d.ts +3 -1
- package/dist/access-extraction-force-flush.d.ts +25 -25
- package/dist/access-extraction-force-flush.js +14 -14
- package/dist/access-health-types.d.ts +3 -1
- package/dist/access-http-lcm-compaction.d.ts +39 -39
- package/dist/access-http-lifecycle-flush.d.ts +39 -39
- package/dist/access-http-offline-stream.d.ts +25 -25
- package/dist/access-http-query.d.ts +4 -2
- package/dist/access-http-query.js +16 -16
- package/dist/access-http.d.ts +51 -44
- package/dist/access-http.js +30 -30
- package/dist/access-identity-continuity-surface.d.ts +12 -12
- package/dist/access-identity-continuity-surface.js +14 -14
- package/dist/access-lcm-surface.d.ts +27 -27
- package/dist/access-lcm-surface.js +14 -14
- package/dist/access-mcp-admin-tools.d.ts +9 -1
- package/dist/access-mcp-admin-tools.js +3 -1
- package/dist/access-mcp-output-schemas.js +1 -1
- package/dist/access-mcp.d.ts +39 -39
- package/dist/access-mcp.js +24 -24
- package/dist/access-memory-search-fanout.d.ts +4 -2
- package/dist/{access-namespace-preflight-Dhvcl-T0.d.ts → access-namespace-preflight-B7Usyz-K.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +5 -3
- package/dist/access-namespace-preflight.js +14 -14
- package/dist/access-observe-write-surface.d.ts +39 -39
- package/dist/access-observe-write-surface.js +14 -14
- package/dist/access-offline-manifest.d.ts +12 -12
- package/dist/access-operations-batch.js +18 -18
- package/dist/access-operations.d.ts +40 -40
- package/dist/access-operations.js +21 -21
- package/dist/access-recall-concurrency.d.ts +40 -40
- package/dist/access-recall-concurrency.js +14 -14
- package/dist/access-recall-response.d.ts +24 -24
- package/dist/access-recall-response.js +14 -14
- package/dist/access-recall-surface.d.ts +24 -24
- package/dist/access-recall-surface.js +14 -14
- package/dist/access-schema.d.ts +45 -45
- package/dist/{access-service-Bke1alZO.d.ts → access-service-DkaIG3n8.d.ts} +219 -75
- package/dist/access-service-helpers.d.ts +40 -40
- package/dist/access-service.d.ts +47 -47
- package/dist/access-service.js +14 -14
- package/dist/access-surface-catalog.d.ts +40 -40
- package/dist/access-surface-catalog.js +20 -16
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/access-wearables-meetings-surface.d.ts +5 -3
- package/dist/action-confidence.d.ts +3 -1
- package/dist/active-memory-bridge.d.ts +3 -1
- package/dist/active-recall.d.ts +3 -1
- package/dist/active-recall.js +6 -1
- package/dist/active-recall.js.map +1 -1
- package/dist/ambient-provenance.d.ts +3 -1
- package/dist/artifact-search.d.ts +3 -1
- package/dist/behavior-learner.d.ts +3 -1
- package/dist/behavior-signals.d.ts +3 -1
- package/dist/bootstrap.d.ts +12 -12
- package/dist/briefing-window.d.ts +4 -2
- package/dist/briefing.d.ts +4 -2
- package/dist/briefing.js +3 -3
- package/dist/buffer-surprise-report.d.ts +3 -1
- package/dist/buffer-turn-helpers.d.ts +3 -1
- package/dist/buffer.d.ts +4 -2
- package/dist/bulk-import/index.d.ts +5 -3
- package/dist/calibration.d.ts +3 -1
- package/dist/capabilities.d.ts +3 -1
- package/dist/{catalog-DV6qnbr7.d.ts → catalog-CX2BZEJh.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +3 -1
- package/dist/causal-consolidation.js +7 -7
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/{chunk-R7JAM2XF.js → chunk-2VXWFYJE.js} +3 -3
- package/dist/{chunk-UXO5IMBK.js → chunk-4XDGYCZI.js} +2 -2
- package/dist/{chunk-OTHZWLUD.js → chunk-57HVIG5U.js} +2 -2
- package/dist/{chunk-EILZG5VC.js → chunk-6TAX66IA.js} +2 -2
- package/dist/{chunk-NKKD4ZAU.js → chunk-6VALIZKG.js} +2 -2
- package/dist/{chunk-BWLRUMOG.js → chunk-76PL4XLG.js} +435 -1
- package/dist/chunk-76PL4XLG.js.map +1 -0
- package/dist/{chunk-2E36UXVW.js → chunk-7KFIMGMP.js} +2 -2
- package/dist/{chunk-LGO6A7GJ.js → chunk-7QOO4LGC.js} +28 -28
- package/dist/{chunk-TBOJ76ER.js → chunk-AB3A7EFH.js} +18 -2
- package/dist/{chunk-TBOJ76ER.js.map → chunk-AB3A7EFH.js.map} +1 -1
- package/dist/{chunk-DZUJ46DO.js → chunk-AUO2LJ3K.js} +2 -2
- package/dist/{chunk-ZO6AXLEH.js → chunk-AYDDB3XI.js} +2 -2
- package/dist/{chunk-NTWN6HB2.js → chunk-AYYGRVRP.js} +2 -2
- package/dist/{chunk-7YQ4IYS2.js → chunk-AZAA5DNP.js} +2 -2
- package/dist/{chunk-4KYOLI6M.js → chunk-BKYPJUQL.js} +120 -14
- package/dist/chunk-BKYPJUQL.js.map +1 -0
- package/dist/{chunk-Z7PBQPJ4.js → chunk-BQUEAVNW.js} +2 -2
- package/dist/{chunk-35NN3ZFA.js → chunk-CTVWELNK.js} +21 -3
- package/dist/chunk-CTVWELNK.js.map +1 -0
- package/dist/{chunk-5YQ63T4B.js → chunk-D27J626P.js} +2 -2
- package/dist/{chunk-LZH5FR2W.js → chunk-DHTQP334.js} +2 -2
- package/dist/{chunk-Y7DK7HHJ.js → chunk-E4MVQQVX.js} +2 -2
- package/dist/{chunk-JYYBA7TF.js → chunk-EIVIB73I.js} +2 -2
- package/dist/{chunk-S2DPMJXH.js → chunk-EV3YFLCB.js} +2 -2
- package/dist/{chunk-TZNQUNKL.js → chunk-FC7TIRFS.js} +15 -1
- package/dist/chunk-FC7TIRFS.js.map +1 -0
- package/dist/{chunk-3I7ASZN3.js → chunk-G57LQRP6.js} +2 -2
- package/dist/{chunk-UIN2BWDD.js → chunk-GN55KU2P.js} +2 -2
- package/dist/{chunk-PE255F4T.js → chunk-GUXS322H.js} +2 -2
- package/dist/{chunk-V3MXUL3D.js → chunk-H5FW4S5Q.js} +319 -643
- package/dist/chunk-H5FW4S5Q.js.map +1 -0
- package/dist/chunk-I32NKXE2.js +879 -0
- package/dist/chunk-I32NKXE2.js.map +1 -0
- package/dist/{chunk-YB42WZCY.js → chunk-IQSC3V2E.js} +2 -2
- package/dist/{chunk-MN4KB2A4.js → chunk-MBDJJTAT.js} +3 -3
- package/dist/{chunk-SQI57UCJ.js → chunk-MRTUN665.js} +2 -2
- package/dist/{chunk-SBDCZ2AX.js → chunk-NXKJHSDN.js} +1 -1
- package/dist/chunk-NXKJHSDN.js.map +1 -0
- package/dist/{chunk-SPUJNJJC.js → chunk-NZWEEALH.js} +2 -2
- package/dist/{chunk-2XDWWPTN.js → chunk-OJD4WS2E.js} +2 -2
- package/dist/{chunk-ZWXJBFZU.js → chunk-OLWTCWQ2.js} +8 -8
- package/dist/{chunk-XRYZRW54.js → chunk-P4DHENRE.js} +2 -2
- package/dist/{chunk-J275IYMG.js → chunk-PAYGC3BD.js} +29 -2
- package/dist/chunk-PAYGC3BD.js.map +1 -0
- package/dist/{chunk-IID2CMUU.js → chunk-PDVQ5JU3.js} +2 -2
- package/dist/{chunk-7BY7V4YX.js → chunk-Q4WONDMJ.js} +4 -3
- package/dist/{chunk-7BY7V4YX.js.map → chunk-Q4WONDMJ.js.map} +1 -1
- package/dist/{chunk-5NM4OH4P.js → chunk-QFMO32TO.js} +3 -3
- package/dist/{chunk-SIHSCCUQ.js → chunk-QXIQPCCN.js} +1 -1
- package/dist/{chunk-2YI72KM3.js → chunk-R47WINCY.js} +2 -2
- package/dist/{chunk-ZQHI2BZB.js → chunk-RK4WXUI2.js} +2 -2
- package/dist/{chunk-QOS5LBZN.js → chunk-S7Q5CM7E.js} +2 -2
- package/dist/{chunk-GDFVPUJ5.js → chunk-TDKSCV62.js} +2 -2
- package/dist/{chunk-OCZIYAE5.js → chunk-TYUS5TLG.js} +3 -3
- package/dist/{chunk-GNCCUR6K.js → chunk-URHCUXKI.js} +2 -2
- package/dist/{chunk-TF77C7SV.js → chunk-VA5KMSAE.js} +7 -5
- package/dist/chunk-VA5KMSAE.js.map +1 -0
- package/dist/{chunk-SB7D4BT7.js → chunk-WN5FSGLE.js} +1545 -105
- package/dist/chunk-WN5FSGLE.js.map +1 -0
- package/dist/{chunk-YLDXWCZP.js → chunk-YF6UHWOV.js} +14 -9
- package/dist/chunk-YF6UHWOV.js.map +1 -0
- package/dist/{chunk-CT56C22C.js → chunk-Z4RPXHJH.js} +4 -4
- package/dist/{cli-cShQ13XG.d.ts → cli-ChKeYMZv.d.ts} +5 -5
- package/dist/cli.d.ts +25 -25
- package/dist/cli.js +44 -43
- package/dist/coding/pre-action-gate.d.ts +2 -60
- package/dist/compounding/engine.d.ts +4 -2
- package/dist/compounding/engine.js +3 -3
- package/dist/compounding/preference-consolidator.d.ts +3 -1
- package/dist/compression-optimizer.d.ts +3 -1
- package/dist/config.d.ts +3 -1
- package/dist/config.js +6 -1
- package/dist/connectors/codex-materialize-runner.d.ts +3 -1
- package/dist/connectors/codex-materialize-runner.js +3 -3
- package/dist/connectors/codex-materialize.d.ts +3 -1
- package/dist/connectors/index.d.ts +3 -1
- package/dist/connectors/index.js +3 -3
- package/dist/consolidation-provenance-check.d.ts +4 -2
- package/dist/consolidation-undo.d.ts +4 -2
- package/dist/contradiction/index.d.ts +10 -270
- package/dist/contradiction/index.js +11 -6
- package/dist/{contradiction-review-QKJH5DKD.js → contradiction-review-WRVLRWHS.js} +6 -2
- package/dist/{contradiction-scan-VOTQRRSX.js → contradiction-scan-AKUWPX5N.js} +5 -3
- package/dist/converge-config.d.ts +3 -1
- package/dist/convergence-refresh.d.ts +4 -2
- package/dist/convergence-refresh.js +5 -5
- package/dist/conversation-index/backend.d.ts +3 -1
- package/dist/conversation-index/chunker.d.ts +3 -1
- package/dist/conversation-index/faiss-adapter.d.ts +3 -1
- package/dist/conversation-index/indexer.d.ts +3 -1
- package/dist/conversation-index/search.d.ts +3 -1
- package/dist/corpus-watermark.d.ts +3 -1
- package/dist/corpus-watermark.js +5 -5
- package/dist/cross-lingual-recall.d.ts +3 -1
- package/dist/day-summary.d.ts +3 -1
- package/dist/delinearize.d.ts +3 -1
- package/dist/dependency-propagation-config.d.ts +3 -1
- package/dist/{dependency-propagation-delivery-CsGg-VwS.d.ts → dependency-propagation-delivery-B8ZMBBCY.d.ts} +1 -1
- package/dist/direct-answer-wiring.d.ts +3 -1
- package/dist/direct-answer.d.ts +3 -1
- package/dist/embedding-fallback.d.ts +3 -1
- package/dist/enrichment/index.d.ts +3 -1
- package/dist/entity-origin-fields.d.ts +3 -1
- package/dist/entity-retrieval.d.ts +4 -2
- package/dist/entity-retrieval.js +3 -3
- package/dist/entity-schema.d.ts +3 -1
- package/dist/episodic-context.d.ts +3 -1
- package/dist/explicit-capture.d.ts +12 -12
- package/dist/external-wiki-access.d.ts +40 -40
- package/dist/external-wiki-access.js +15 -15
- package/dist/external-wiki-collection-registration.d.ts +3 -1
- package/dist/external-wiki-collection.d.ts +3 -1
- package/dist/external-wiki-mcp-tools.d.ts +40 -40
- package/dist/extraction-error-classification.d.ts +3 -1
- package/dist/extraction-faithfulness.d.ts +3 -1
- package/dist/extraction-judge-telemetry.d.ts +3 -1
- package/dist/extraction-judge-training.d.ts +3 -1
- package/dist/extraction-judge.d.ts +3 -1
- package/dist/extraction-liveness.d.ts +3 -1
- package/dist/extraction-normalization.d.ts +3 -1
- package/dist/extraction-prompt.d.ts +3 -1
- package/dist/extraction-source-grounding-rules.d.ts +3 -1
- package/dist/extraction-source-grounding.d.ts +3 -1
- package/dist/extraction.d.ts +3 -1
- package/dist/extraction.js +3 -3
- package/dist/fallback-llm.d.ts +3 -1
- package/dist/graph-dashboard-diff.d.ts +3 -1
- package/dist/graph-dashboard-key.d.ts +3 -1
- package/dist/graph-dashboard-parser.d.ts +3 -1
- package/dist/graph-edge-reinforcement.d.ts +3 -1
- package/dist/graph-path-reconstruction.d.ts +3 -1
- package/dist/graph-path-scoring.d.ts +3 -1
- package/dist/graph-snapshot.d.ts +3 -1
- package/dist/graph.d.ts +3 -1
- package/dist/harmonic-retrieval.js +1 -1
- package/dist/importance.d.ts +3 -1
- package/dist/importers/index.d.ts +3 -1
- package/dist/in-flight-reads.d.ts +3 -1
- package/dist/index-CexDrJzC.d.ts +284 -0
- package/dist/index.d.ts +251 -29
- package/dist/index.js +129 -75
- package/dist/intent.d.ts +3 -1
- package/dist/lcm/engine.d.ts +3 -1
- package/dist/lcm/index.d.ts +3 -1
- package/dist/lcm/tools.d.ts +3 -1
- package/dist/lifecycle.d.ts +3 -1
- package/dist/live-connectors-runner.d.ts +3 -1
- package/dist/local-llm.d.ts +3 -1
- package/dist/local-model-endpoint.d.ts +3 -1
- package/dist/maintenance/memory-governance.d.ts +3 -1
- package/dist/maintenance/memory-governance.js +3 -3
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +4 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +3 -3
- package/dist/maintenance/rebuild-memory-projection.d.ts +4 -2
- package/dist/maintenance/rebuild-memory-projection.js +4 -4
- package/dist/{maintenance-jhMpeGne.d.ts → maintenance-nkdtSrVr.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +37 -37
- package/dist/memory-action-policy.d.ts +3 -1
- package/dist/memory-cache.d.ts +3 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +3 -1
- package/dist/memory-projection-store.d.ts +3 -1
- package/dist/memory-provenance.d.ts +3 -1
- package/dist/memory-snapshot.d.ts +3 -1
- package/dist/memory-subject-cli.d.ts +40 -40
- package/dist/memory-subject.d.ts +42 -42
- package/dist/memory-worth-outcomes.d.ts +4 -2
- package/dist/models-json.d.ts +3 -1
- package/dist/namespaces/migrate.d.ts +5 -3
- package/dist/namespaces/migrate.js +4 -4
- package/dist/namespaces/principal.d.ts +3 -1
- package/dist/namespaces/search.d.ts +3 -1
- package/dist/namespaces/storage.d.ts +5 -3
- package/dist/namespaces/storage.js +3 -3
- package/dist/native-knowledge.d.ts +3 -1
- package/dist/offline-sync-impression-drain.d.ts +3 -1
- package/dist/operator-doctor-corpus.d.ts +3 -1
- package/dist/operator-doctor-corpus.js +6 -6
- package/dist/operator-doctor-replica.d.ts +3 -1
- package/dist/operator-toolkit.d.ts +5 -3
- package/dist/operator-toolkit.js +15 -12
- package/dist/orchestration/compression-guideline-coordinator.d.ts +4 -2
- package/dist/orchestration/maintenance.d.ts +6 -4
- package/dist/orchestration/maintenance.js +9 -9
- package/dist/{orchestrator-DyGUC7re.d.ts → orchestrator-Bvq1-RQs.d.ts} +23 -9
- package/dist/orchestrator.d.ts +12 -12
- package/dist/orchestrator.js +52 -52
- package/dist/patterns-cli.d.ts +3 -1
- package/dist/{pipeline-C25Oxtp1.d.ts → pipeline-C8vfIiTX.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +3 -1
- package/dist/proactive-contention.d.ts +3 -1
- package/dist/provenance.d.ts +3 -1
- package/dist/{public-http-CMe7NQzj.d.ts → public-http-Cy0aYbys.d.ts} +1 -1
- package/dist/{qmd-DkDVCbgF.d.ts → qmd-B9p1SZTZ.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +4 -2
- package/dist/qmd-recall-cache.d.ts +3 -1
- package/dist/qmd.d.ts +4 -2
- package/dist/recall-concurrency-config.d.ts +3 -1
- package/dist/recall-disclosure-escalation.d.ts +3 -1
- package/dist/recall-explain-renderer.d.ts +3 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +3 -1
- package/dist/recall-planner-llm.d.ts +3 -1
- package/dist/recall-state.d.ts +3 -1
- package/dist/recall-tag-filter.d.ts +3 -1
- package/dist/recall-timings.d.ts +3 -1
- package/dist/recall-xray-cli.d.ts +3 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +3 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +3 -1
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/cursor.d.ts +3 -1
- package/dist/reconcile/manifest.d.ts +3 -1
- package/dist/reconcile/plan.d.ts +3 -1
- package/dist/replay/normalizers/chatgpt.d.ts +3 -1
- package/dist/replay/normalizers/claude.d.ts +3 -1
- package/dist/replay/normalizers/openclaw.d.ts +3 -1
- package/dist/replay/normalizers/shared.d.ts +3 -1
- package/dist/replay/runner.d.ts +3 -1
- package/dist/replay/types.d.ts +3 -1
- package/dist/replica-divergence.d.ts +3 -1
- package/dist/replica-peers-config.d.ts +3 -1
- package/dist/{resolution-MFY72STR.js → resolution-4552BNRV.js} +13 -3
- package/dist/resolve-auth-token.d.ts +3 -1
- package/dist/resume-bundles.js +4 -2
- package/dist/retrieval-agents.d.ts +4 -2
- package/dist/retrieval-tiers.d.ts +3 -1
- package/dist/routing/engine.d.ts +3 -1
- package/dist/routing/store.d.ts +3 -1
- package/dist/salvage-envelope.d.ts +3 -1
- package/dist/schemas.d.ts +44 -44
- package/dist/{scope-profiles-B9xMoFO-.d.ts → scope-profiles-DLrRxFWR.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +3 -1
- package/dist/search/factory.d.ts +3 -1
- package/dist/search/index.d.ts +3 -1
- package/dist/search/lancedb-backend.d.ts +3 -1
- package/dist/search/meilisearch-backend.d.ts +3 -1
- package/dist/search/noop-backend.d.ts +3 -1
- package/dist/search/orama-backend.d.ts +3 -1
- package/dist/search/port.d.ts +3 -1
- package/dist/search/remote-backend.d.ts +3 -1
- package/dist/{semantic-TddhF0y7.d.ts → semantic-BalR6EXU.d.ts} +1 -1
- package/dist/{semantic-consolidation-C4uykW84.d.ts → semantic-consolidation-DlN6xe20.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +4 -2
- package/dist/semantic-consolidation.js +4 -4
- package/dist/semantic-rule-promotion.js +3 -3
- package/dist/semantic-rule-verifier.d.ts +3 -1
- package/dist/semantic-rule-verifier.js +3 -3
- package/dist/{service-DCZDZNcV.d.ts → service-GkYyVfm9.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +3 -1
- package/dist/session-observer-state.d.ts +3 -1
- package/dist/shared-context/manager.d.ts +3 -1
- package/dist/signal.d.ts +3 -1
- package/dist/source-agent-qualifier.d.ts +3 -1
- package/dist/source-agent-qualifier.js +3 -3
- package/dist/{storage-CcKmEjL8.d.ts → storage-BIDzuKIn.d.ts} +1 -1
- package/dist/storage.d.ts +4 -2
- package/dist/storage.js +2 -2
- package/dist/subject-config.d.ts +3 -1
- package/dist/summarizer.d.ts +3 -1
- package/dist/summary-snapshot.d.ts +3 -1
- package/dist/support-passport/index.d.ts +43 -43
- package/dist/support-passport/index.js +17 -17
- package/dist/temporal-supersession.d.ts +4 -2
- package/dist/temporal-timeline-recall.d.ts +3 -1
- package/dist/temporal-validity.d.ts +3 -1
- package/dist/threading.d.ts +3 -1
- package/dist/tier-migration.d.ts +4 -2
- package/dist/tier-routing.d.ts +3 -1
- package/dist/topics.d.ts +3 -1
- package/dist/transcript.d.ts +3 -1
- package/dist/transfer/types.d.ts +20 -20
- package/dist/trust-score-stage.d.ts +3 -1
- package/dist/trust-score.d.ts +3 -1
- package/dist/{types-Pi0lfaEt.d.ts → types-BxAcOl5Q.d.ts} +323 -4
- package/dist/types.d.ts +3 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +3 -1
- package/dist/verified-recall.js +3 -3
- package/dist/who-knows-cli.d.ts +40 -40
- package/dist/who-knows-cli.js +4 -4
- package/dist/who-knows.d.ts +42 -42
- package/dist/who-knows.js +3 -3
- package/dist/write-envelope.d.ts +3 -1
- package/package.json +2 -2
- package/src/access-boundary.ts +4 -0
- package/src/access-http.ts +6 -5
- package/src/access-mcp-admin-tools.ts +24 -0
- package/src/access-mcp-output-schemas.ts +14 -0
- package/src/access-mcp.ts +2 -2
- package/src/access-operations-batch.ts +5 -0
- package/src/access-service.ts +27 -0
- package/src/access-surface-catalog.test.ts +24 -0
- package/src/access-surface-catalog.ts +4 -0
- package/src/coding/action-gate.test.ts +341 -0
- package/src/coding/action-gate.ts +556 -0
- package/src/config.ts +5 -0
- package/src/contradiction/contradiction-review.ts +50 -4
- package/src/contradiction/contradiction-scan.ts +14 -3
- package/src/contradiction/resolution.ts +50 -2
- package/src/index.ts +4 -3
- package/src/orchestration/recall-rerank-coordinator.ts +123 -4
- package/src/orchestration/recall-result-formatter.ts +6 -2
- package/src/orchestration/recall-search-pipeline.ts +14 -1
- package/src/preferences/drift-config.ts +118 -0
- package/src/preferences/drift-recall.ts +133 -0
- package/src/preferences/drift-types.ts +87 -0
- package/src/preferences/index.ts +12 -0
- package/src/preferences/preference-drift.test.ts +690 -0
- package/src/preferences/preference-drift.ts +724 -0
- package/src/review/review-deck-access.test.ts +325 -0
- package/src/review/review-deck-http-base.ts +133 -0
- package/src/review/review-deck-mutation.test.ts +417 -0
- package/src/review/review-deck-mutation.ts +677 -0
- package/src/review/review-deck-snapshot.ts +196 -0
- package/src/review/review-deck-surface.ts +117 -0
- package/src/review/review-deck.test.ts +347 -0
- package/src/review/review-deck.ts +311 -0
- package/src/storage.ts +4 -6
- package/src/types.ts +7 -3
- package/dist/chunk-35NN3ZFA.js.map +0 -1
- package/dist/chunk-4KYOLI6M.js.map +0 -1
- package/dist/chunk-BWLRUMOG.js.map +0 -1
- package/dist/chunk-J275IYMG.js.map +0 -1
- package/dist/chunk-SB7D4BT7.js.map +0 -1
- package/dist/chunk-SBDCZ2AX.js.map +0 -1
- package/dist/chunk-TF77C7SV.js.map +0 -1
- package/dist/chunk-TZNQUNKL.js.map +0 -1
- package/dist/chunk-V3MXUL3D.js.map +0 -1
- package/dist/chunk-XCTXS7VY.js +0 -402
- package/dist/chunk-XCTXS7VY.js.map +0 -1
- package/dist/chunk-YLDXWCZP.js.map +0 -1
- /package/dist/{chunk-R7JAM2XF.js.map → chunk-2VXWFYJE.js.map} +0 -0
- /package/dist/{chunk-UXO5IMBK.js.map → chunk-4XDGYCZI.js.map} +0 -0
- /package/dist/{chunk-OTHZWLUD.js.map → chunk-57HVIG5U.js.map} +0 -0
- /package/dist/{chunk-EILZG5VC.js.map → chunk-6TAX66IA.js.map} +0 -0
- /package/dist/{chunk-NKKD4ZAU.js.map → chunk-6VALIZKG.js.map} +0 -0
- /package/dist/{chunk-2E36UXVW.js.map → chunk-7KFIMGMP.js.map} +0 -0
- /package/dist/{chunk-LGO6A7GJ.js.map → chunk-7QOO4LGC.js.map} +0 -0
- /package/dist/{chunk-DZUJ46DO.js.map → chunk-AUO2LJ3K.js.map} +0 -0
- /package/dist/{chunk-ZO6AXLEH.js.map → chunk-AYDDB3XI.js.map} +0 -0
- /package/dist/{chunk-NTWN6HB2.js.map → chunk-AYYGRVRP.js.map} +0 -0
- /package/dist/{chunk-7YQ4IYS2.js.map → chunk-AZAA5DNP.js.map} +0 -0
- /package/dist/{chunk-Z7PBQPJ4.js.map → chunk-BQUEAVNW.js.map} +0 -0
- /package/dist/{chunk-5YQ63T4B.js.map → chunk-D27J626P.js.map} +0 -0
- /package/dist/{chunk-LZH5FR2W.js.map → chunk-DHTQP334.js.map} +0 -0
- /package/dist/{chunk-Y7DK7HHJ.js.map → chunk-E4MVQQVX.js.map} +0 -0
- /package/dist/{chunk-JYYBA7TF.js.map → chunk-EIVIB73I.js.map} +0 -0
- /package/dist/{chunk-S2DPMJXH.js.map → chunk-EV3YFLCB.js.map} +0 -0
- /package/dist/{chunk-3I7ASZN3.js.map → chunk-G57LQRP6.js.map} +0 -0
- /package/dist/{chunk-UIN2BWDD.js.map → chunk-GN55KU2P.js.map} +0 -0
- /package/dist/{chunk-PE255F4T.js.map → chunk-GUXS322H.js.map} +0 -0
- /package/dist/{chunk-YB42WZCY.js.map → chunk-IQSC3V2E.js.map} +0 -0
- /package/dist/{chunk-MN4KB2A4.js.map → chunk-MBDJJTAT.js.map} +0 -0
- /package/dist/{chunk-SQI57UCJ.js.map → chunk-MRTUN665.js.map} +0 -0
- /package/dist/{chunk-SPUJNJJC.js.map → chunk-NZWEEALH.js.map} +0 -0
- /package/dist/{chunk-2XDWWPTN.js.map → chunk-OJD4WS2E.js.map} +0 -0
- /package/dist/{chunk-ZWXJBFZU.js.map → chunk-OLWTCWQ2.js.map} +0 -0
- /package/dist/{chunk-XRYZRW54.js.map → chunk-P4DHENRE.js.map} +0 -0
- /package/dist/{chunk-IID2CMUU.js.map → chunk-PDVQ5JU3.js.map} +0 -0
- /package/dist/{chunk-5NM4OH4P.js.map → chunk-QFMO32TO.js.map} +0 -0
- /package/dist/{chunk-SIHSCCUQ.js.map → chunk-QXIQPCCN.js.map} +0 -0
- /package/dist/{chunk-2YI72KM3.js.map → chunk-R47WINCY.js.map} +0 -0
- /package/dist/{chunk-ZQHI2BZB.js.map → chunk-RK4WXUI2.js.map} +0 -0
- /package/dist/{chunk-QOS5LBZN.js.map → chunk-S7Q5CM7E.js.map} +0 -0
- /package/dist/{chunk-GDFVPUJ5.js.map → chunk-TDKSCV62.js.map} +0 -0
- /package/dist/{chunk-OCZIYAE5.js.map → chunk-TYUS5TLG.js.map} +0 -0
- /package/dist/{chunk-GNCCUR6K.js.map → chunk-URHCUXKI.js.map} +0 -0
- /package/dist/{chunk-CT56C22C.js.map → chunk-Z4RPXHJH.js.map} +0 -0
- /package/dist/{contradiction-review-QKJH5DKD.js.map → contradiction-review-WRVLRWHS.js.map} +0 -0
- /package/dist/{contradiction-scan-VOTQRRSX.js.map → contradiction-scan-AKUWPX5N.js.map} +0 -0
- /package/dist/{resolution-MFY72STR.js.map → resolution-4552BNRV.js.map} +0 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { request as httpRequest } from "node:http";
|
|
3
|
+
import test from "node:test";
|
|
4
|
+
|
|
5
|
+
import { EngramAccessHttpServer } from "../access-http.js";
|
|
6
|
+
import type { EngramAccessService } from "../access-service.js";
|
|
7
|
+
import type {
|
|
8
|
+
ReviewDeckActionReceipt,
|
|
9
|
+
ReviewDeckActionRequest,
|
|
10
|
+
ReviewDeckPage,
|
|
11
|
+
ReviewDeckUndoRequest,
|
|
12
|
+
} from "./review-deck.js";
|
|
13
|
+
|
|
14
|
+
const TOKEN = "test-token";
|
|
15
|
+
|
|
16
|
+
function deferred<T = void>(): {
|
|
17
|
+
promise: Promise<T>;
|
|
18
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
19
|
+
reject: (reason?: unknown) => void;
|
|
20
|
+
} {
|
|
21
|
+
let resolve!: (value: T | PromiseLike<T>) => void;
|
|
22
|
+
let reject!: (reason?: unknown) => void;
|
|
23
|
+
const promise = new Promise<T>((resolvePromise, rejectPromise) => {
|
|
24
|
+
resolve = resolvePromise;
|
|
25
|
+
reject = rejectPromise;
|
|
26
|
+
});
|
|
27
|
+
return { promise, resolve, reject };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function page(): ReviewDeckPage {
|
|
31
|
+
return { schemaVersion: 1, items: [], total: 0 };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function receipt(
|
|
35
|
+
action: ReviewDeckActionReceipt["action"] = "keep",
|
|
36
|
+
): ReviewDeckActionReceipt {
|
|
37
|
+
return {
|
|
38
|
+
schemaVersion: 1,
|
|
39
|
+
receiptId: "receipt-1",
|
|
40
|
+
itemId: "item-1",
|
|
41
|
+
action,
|
|
42
|
+
outcome: "applied",
|
|
43
|
+
effect: action,
|
|
44
|
+
undoAvailable: action !== "undo",
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function mockService(overrides: Partial<EngramAccessService> = {}): EngramAccessService {
|
|
49
|
+
return {
|
|
50
|
+
reviewDeckEnabled: true,
|
|
51
|
+
reviewDeckList: async () => page(),
|
|
52
|
+
reviewDeckAction: async () => receipt("keep"),
|
|
53
|
+
reviewDeckUndo: async () => receipt("undo"),
|
|
54
|
+
reviewQueue: async () => ({ found: true, runId: "existing-review" }),
|
|
55
|
+
...overrides,
|
|
56
|
+
} as unknown as EngramAccessService;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function startServer(
|
|
60
|
+
service: EngramAccessService,
|
|
61
|
+
extras: ConstructorParameters<typeof EngramAccessHttpServer>[0] extends infer T
|
|
62
|
+
? T extends { service: EngramAccessService }
|
|
63
|
+
? Omit<T, "service" | "port" | "adminConsoleEnabled">
|
|
64
|
+
: never
|
|
65
|
+
: never = { authToken: TOKEN },
|
|
66
|
+
): Promise<{ port: number; stop: () => Promise<void> }> {
|
|
67
|
+
const server = new EngramAccessHttpServer({
|
|
68
|
+
service,
|
|
69
|
+
port: 0,
|
|
70
|
+
adminConsoleEnabled: false,
|
|
71
|
+
...extras,
|
|
72
|
+
});
|
|
73
|
+
const status = await server.start();
|
|
74
|
+
return { port: status.port, stop: () => server.stop() };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function jsonRequest(
|
|
78
|
+
port: number,
|
|
79
|
+
path: string,
|
|
80
|
+
options: {
|
|
81
|
+
method?: string;
|
|
82
|
+
token?: string;
|
|
83
|
+
body?: unknown;
|
|
84
|
+
} = {},
|
|
85
|
+
): Promise<{ status: number; body: Record<string, unknown> }> {
|
|
86
|
+
const res = await fetch(`http://127.0.0.1:${port}${path}`, {
|
|
87
|
+
method: options.method ?? "GET",
|
|
88
|
+
headers: {
|
|
89
|
+
authorization: `Bearer ${options.token ?? TOKEN}`,
|
|
90
|
+
...(options.body !== undefined ? { "content-type": "application/json" } : {}),
|
|
91
|
+
},
|
|
92
|
+
body: options.body !== undefined ? JSON.stringify(options.body) : undefined,
|
|
93
|
+
});
|
|
94
|
+
return { status: res.status, body: (await res.json()) as Record<string, unknown> };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const keepBody: ReviewDeckActionRequest = {
|
|
98
|
+
schemaVersion: 1,
|
|
99
|
+
itemId: "item-1",
|
|
100
|
+
revision: "rv1:abc",
|
|
101
|
+
action: "keep",
|
|
102
|
+
idempotencyKey: "key-1",
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const undoBody: ReviewDeckUndoRequest = {
|
|
106
|
+
schemaVersion: 1,
|
|
107
|
+
receiptId: "receipt-1",
|
|
108
|
+
expectedRevision: "rv1:abc",
|
|
109
|
+
idempotencyKey: "key-undo",
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
test("canonical and engram alias list routes return schemaVersion 1", async () => {
|
|
113
|
+
const { port, stop } = await startServer(mockService());
|
|
114
|
+
try {
|
|
115
|
+
for (const prefix of ["/remnic/v1", "/engram/v1"] as const) {
|
|
116
|
+
const listed = await jsonRequest(port, `${prefix}/review/deck?limit=1`);
|
|
117
|
+
assert.equal(listed.status, 200);
|
|
118
|
+
assert.equal(listed.body.schemaVersion, 1);
|
|
119
|
+
const acted = await jsonRequest(port, `${prefix}/review/deck/action`, {
|
|
120
|
+
method: "POST",
|
|
121
|
+
body: keepBody,
|
|
122
|
+
});
|
|
123
|
+
assert.equal(acted.status, 200);
|
|
124
|
+
assert.equal(acted.body.schemaVersion, 1);
|
|
125
|
+
const undone = await jsonRequest(port, `${prefix}/review/deck/undo`, {
|
|
126
|
+
method: "POST",
|
|
127
|
+
body: undoBody,
|
|
128
|
+
});
|
|
129
|
+
assert.equal(undone.status, 200);
|
|
130
|
+
assert.equal(undone.body.schemaVersion, 1);
|
|
131
|
+
}
|
|
132
|
+
} finally {
|
|
133
|
+
await stop();
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test("invalid cursor, limit, action, revision, and missing idempotency key are client errors", async () => {
|
|
138
|
+
const { port, stop } = await startServer(mockService());
|
|
139
|
+
try {
|
|
140
|
+
const cases: Array<{ path: string; method?: string; body?: unknown; message: RegExp }> = [
|
|
141
|
+
{ path: "/engram/v1/review/deck?limit=1&cursor=%%%", message: /cursor is malformed/ },
|
|
142
|
+
{ path: "/engram/v1/review/deck", message: /limit is required/ },
|
|
143
|
+
{ path: "/engram/v1/review/deck?limit=abc", message: /limit must be an integer/ },
|
|
144
|
+
{ path: "/engram/v1/review/deck?limit=0", message: /limit must be an integer from 1 to 100/ },
|
|
145
|
+
{ path: "/engram/v1/review/deck?limit=101", message: /limit must be an integer from 1 to 100/ },
|
|
146
|
+
{
|
|
147
|
+
path: "/engram/v1/review/deck/action",
|
|
148
|
+
method: "POST",
|
|
149
|
+
body: { ...keepBody, action: "later" },
|
|
150
|
+
message: /action must be one of/,
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
path: "/engram/v1/review/deck/action",
|
|
154
|
+
method: "POST",
|
|
155
|
+
body: { ...keepBody, revision: "" },
|
|
156
|
+
message: /revision is required/,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
path: "/engram/v1/review/deck/action",
|
|
160
|
+
method: "POST",
|
|
161
|
+
body: { ...keepBody, idempotencyKey: undefined },
|
|
162
|
+
message: /idempotencyKey is required/,
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
path: "/engram/v1/review/deck/action",
|
|
166
|
+
method: "POST",
|
|
167
|
+
body: { ...keepBody, action: "prepare_fix", correctionText: " " },
|
|
168
|
+
message: /correctionText is required/,
|
|
169
|
+
},
|
|
170
|
+
];
|
|
171
|
+
for (const item of cases) {
|
|
172
|
+
const result = await jsonRequest(port, item.path, { method: item.method, body: item.body });
|
|
173
|
+
assert.equal(result.status, 400, item.path);
|
|
174
|
+
assert.match(String(result.body.error), item.message);
|
|
175
|
+
}
|
|
176
|
+
} finally {
|
|
177
|
+
await stop();
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test("POST body principal and namespace are ignored in favor of the boundary", async () => {
|
|
182
|
+
let seen: { namespace?: string; principal?: string } | undefined;
|
|
183
|
+
const { port, stop } = await startServer(
|
|
184
|
+
mockService({
|
|
185
|
+
reviewDeckAction: async (_req, opts) => {
|
|
186
|
+
seen = { namespace: opts.namespace, principal: opts.principal };
|
|
187
|
+
return receipt("keep");
|
|
188
|
+
},
|
|
189
|
+
}),
|
|
190
|
+
{ authToken: TOKEN, principal: "boundary-principal" },
|
|
191
|
+
);
|
|
192
|
+
try {
|
|
193
|
+
const result = await jsonRequest(
|
|
194
|
+
port,
|
|
195
|
+
"/engram/v1/review/deck/action?namespace=boundary-ns",
|
|
196
|
+
{
|
|
197
|
+
method: "POST",
|
|
198
|
+
body: {
|
|
199
|
+
...keepBody,
|
|
200
|
+
namespace: "body-ns",
|
|
201
|
+
principal: "body-principal",
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
);
|
|
205
|
+
assert.equal(result.status, 200);
|
|
206
|
+
assert.deepEqual(seen, { namespace: "boundary-ns", principal: "boundary-principal" });
|
|
207
|
+
} finally {
|
|
208
|
+
await stop();
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test("a read-only token cannot call action or undo", async () => {
|
|
213
|
+
const { port, stop } = await startServer(mockService(), {
|
|
214
|
+
authTokenEntriesGetter: () => [
|
|
215
|
+
{ token: "reader", capabilities: { version: 1, ops: ["review_deck_list"] } },
|
|
216
|
+
],
|
|
217
|
+
});
|
|
218
|
+
try {
|
|
219
|
+
const listed = await jsonRequest(port, "/engram/v1/review/deck?limit=1", { token: "reader" });
|
|
220
|
+
assert.equal(listed.status, 200);
|
|
221
|
+
const acted = await jsonRequest(port, "/engram/v1/review/deck/action", {
|
|
222
|
+
method: "POST",
|
|
223
|
+
token: "reader",
|
|
224
|
+
body: keepBody,
|
|
225
|
+
});
|
|
226
|
+
assert.equal(acted.status, 403);
|
|
227
|
+
const undone = await jsonRequest(port, "/engram/v1/review/deck/undo", {
|
|
228
|
+
method: "POST",
|
|
229
|
+
token: "reader",
|
|
230
|
+
body: undoBody,
|
|
231
|
+
});
|
|
232
|
+
assert.equal(undone.status, 403);
|
|
233
|
+
} finally {
|
|
234
|
+
await stop();
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
test("disabled gate returns 404 for deck routes while review-queue still works", async () => {
|
|
239
|
+
let queueCalled = false;
|
|
240
|
+
let deckCalled = false;
|
|
241
|
+
const { port, stop } = await startServer(
|
|
242
|
+
mockService({
|
|
243
|
+
reviewDeckEnabled: false,
|
|
244
|
+
reviewDeckList: async () => {
|
|
245
|
+
deckCalled = true;
|
|
246
|
+
return page();
|
|
247
|
+
},
|
|
248
|
+
reviewQueue: async () => {
|
|
249
|
+
queueCalled = true;
|
|
250
|
+
return { found: true, runId: "existing-review" };
|
|
251
|
+
},
|
|
252
|
+
}),
|
|
253
|
+
);
|
|
254
|
+
try {
|
|
255
|
+
for (const path of [
|
|
256
|
+
"/engram/v1/review/deck?limit=1",
|
|
257
|
+
"/remnic/v1/review/deck?limit=1",
|
|
258
|
+
"/engram/v1/review/deck/action",
|
|
259
|
+
"/remnic/v1/review/deck/undo",
|
|
260
|
+
]) {
|
|
261
|
+
const method = path.includes("/action") || path.includes("/undo") ? "POST" : "GET";
|
|
262
|
+
const result = await jsonRequest(port, path, {
|
|
263
|
+
method,
|
|
264
|
+
body: method === "POST" ? keepBody : undefined,
|
|
265
|
+
});
|
|
266
|
+
assert.equal(result.status, 404, path);
|
|
267
|
+
assert.equal(result.body.code, "not_found");
|
|
268
|
+
}
|
|
269
|
+
assert.equal(deckCalled, false);
|
|
270
|
+
const queue = await jsonRequest(port, "/engram/v1/review-queue");
|
|
271
|
+
assert.equal(queue.status, 200);
|
|
272
|
+
assert.equal(queueCalled, true);
|
|
273
|
+
} finally {
|
|
274
|
+
await stop();
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
test("cancellation reaches the deck action executor", async () => {
|
|
279
|
+
const started = deferred<void>();
|
|
280
|
+
const settled = deferred<void>();
|
|
281
|
+
const forceRelease = deferred<void>();
|
|
282
|
+
let observed: AbortSignal | undefined;
|
|
283
|
+
const { port, stop } = await startServer(
|
|
284
|
+
mockService({
|
|
285
|
+
reviewDeckAction: async (_req, opts) => {
|
|
286
|
+
observed = opts.signal;
|
|
287
|
+
started.resolve();
|
|
288
|
+
try {
|
|
289
|
+
await Promise.race([
|
|
290
|
+
forceRelease.promise,
|
|
291
|
+
new Promise<void>((_resolve, reject) => {
|
|
292
|
+
opts.signal?.addEventListener("abort", () => reject(opts.signal?.reason), { once: true });
|
|
293
|
+
}),
|
|
294
|
+
]);
|
|
295
|
+
} finally {
|
|
296
|
+
settled.resolve();
|
|
297
|
+
}
|
|
298
|
+
if (opts.signal?.aborted) throw opts.signal.reason;
|
|
299
|
+
return receipt("keep");
|
|
300
|
+
},
|
|
301
|
+
}),
|
|
302
|
+
);
|
|
303
|
+
try {
|
|
304
|
+
const client = httpRequest({
|
|
305
|
+
host: "127.0.0.1",
|
|
306
|
+
port,
|
|
307
|
+
path: "/engram/v1/review/deck/action",
|
|
308
|
+
method: "POST",
|
|
309
|
+
headers: {
|
|
310
|
+
authorization: `Bearer ${TOKEN}`,
|
|
311
|
+
"content-type": "application/json",
|
|
312
|
+
},
|
|
313
|
+
});
|
|
314
|
+
client.on("error", () => {});
|
|
315
|
+
client.end(JSON.stringify(keepBody));
|
|
316
|
+
await started.promise;
|
|
317
|
+
assert.ok(observed, "abort signal must reach the executor");
|
|
318
|
+
client.destroy();
|
|
319
|
+
await settled.promise;
|
|
320
|
+
assert.equal(observed.aborted, true);
|
|
321
|
+
} finally {
|
|
322
|
+
forceRelease.resolve();
|
|
323
|
+
await stop();
|
|
324
|
+
}
|
|
325
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
|
|
3
|
+
import { EngramAccessInputError } from "../access-service.js";
|
|
4
|
+
import type { OperationName } from "../access-boundary.js";
|
|
5
|
+
import { SupportPassportAccessHttpBase } from "../support-passport/access-http-base.js";
|
|
6
|
+
import type {
|
|
7
|
+
ReviewDeckActionRequest,
|
|
8
|
+
ReviewDeckUndoRequest,
|
|
9
|
+
} from "./review-deck.js";
|
|
10
|
+
|
|
11
|
+
const LIST_PATHS = ["/remnic/v1/review/deck", "/engram/v1/review/deck"] as const;
|
|
12
|
+
const ACTION_PATHS = ["/remnic/v1/review/deck/action", "/engram/v1/review/deck/action"] as const;
|
|
13
|
+
const UNDO_PATHS = ["/remnic/v1/review/deck/undo", "/engram/v1/review/deck/undo"] as const;
|
|
14
|
+
const LIMIT_MIN = 1;
|
|
15
|
+
const LIMIT_MAX = 100;
|
|
16
|
+
const CURSOR_RE = /^[^\s%]{1,2048}$/;
|
|
17
|
+
|
|
18
|
+
function requiredString(body: Record<string, unknown>, field: string): string {
|
|
19
|
+
const value = body[field];
|
|
20
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
21
|
+
throw new EngramAccessInputError(`${field} is required`);
|
|
22
|
+
}
|
|
23
|
+
return value.trim();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function parseLimit(raw: string | null): number {
|
|
27
|
+
if (raw === null || raw.length === 0) {
|
|
28
|
+
throw new EngramAccessInputError("limit is required and must be an integer");
|
|
29
|
+
}
|
|
30
|
+
if (!/^(?:0|[1-9]\d*)$/.test(raw)) {
|
|
31
|
+
throw new EngramAccessInputError("limit must be an integer");
|
|
32
|
+
}
|
|
33
|
+
const value = Number(raw);
|
|
34
|
+
if (!Number.isInteger(value) || value < LIMIT_MIN || value > LIMIT_MAX) {
|
|
35
|
+
throw new EngramAccessInputError(`limit must be an integer from ${LIMIT_MIN} to ${LIMIT_MAX}`);
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function parseCursor(raw: string | null): string | undefined {
|
|
41
|
+
if (raw === null) return undefined;
|
|
42
|
+
if (!CURSOR_RE.test(raw)) {
|
|
43
|
+
throw new EngramAccessInputError("cursor is malformed");
|
|
44
|
+
}
|
|
45
|
+
return raw;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function parseActionBody(body: Record<string, unknown>): ReviewDeckActionRequest {
|
|
49
|
+
const action = body.action;
|
|
50
|
+
if (action !== "keep" && action !== "not_true" && action !== "prepare_fix") {
|
|
51
|
+
throw new EngramAccessInputError("action must be one of: keep, not_true, prepare_fix");
|
|
52
|
+
}
|
|
53
|
+
const itemId = requiredString(body, "itemId");
|
|
54
|
+
const revision = requiredString(body, "revision");
|
|
55
|
+
const idempotencyKey = requiredString(body, "idempotencyKey");
|
|
56
|
+
if (action === "prepare_fix") {
|
|
57
|
+
const correctionText = requiredString(body, "correctionText");
|
|
58
|
+
return { schemaVersion: 1, itemId, revision, action, correctionText, idempotencyKey };
|
|
59
|
+
}
|
|
60
|
+
return { schemaVersion: 1, itemId, revision, action, idempotencyKey };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function parseUndoBody(body: Record<string, unknown>): ReviewDeckUndoRequest {
|
|
64
|
+
return {
|
|
65
|
+
schemaVersion: 1,
|
|
66
|
+
receiptId: requiredString(body, "receiptId"),
|
|
67
|
+
expectedRevision: requiredString(body, "expectedRevision"),
|
|
68
|
+
idempotencyKey: requiredString(body, "idempotencyKey"),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export abstract class ReviewDeckAccessHttpBase extends SupportPassportAccessHttpBase {
|
|
73
|
+
protected abstract enforceTokenOp(op: OperationName): void;
|
|
74
|
+
protected abstract resolveNamespace(req: IncomingMessage, bodyNamespace?: string): string | undefined;
|
|
75
|
+
protected abstract readonly maxBodyBytes: number;
|
|
76
|
+
|
|
77
|
+
protected async handleReviewDeckRequest(
|
|
78
|
+
req: IncomingMessage,
|
|
79
|
+
res: ServerResponse,
|
|
80
|
+
pathname: string,
|
|
81
|
+
abortSignal?: AbortSignal,
|
|
82
|
+
): Promise<boolean> {
|
|
83
|
+
const method = req.method;
|
|
84
|
+
const isList = method === "GET" && (pathname === LIST_PATHS[0] || pathname === LIST_PATHS[1]);
|
|
85
|
+
const isAction = method === "POST" && (pathname === ACTION_PATHS[0] || pathname === ACTION_PATHS[1]);
|
|
86
|
+
const isUndo = method === "POST" && (pathname === UNDO_PATHS[0] || pathname === UNDO_PATHS[1]);
|
|
87
|
+
if (!isList && !isAction && !isUndo) return false;
|
|
88
|
+
if (!this.service.reviewDeckEnabled) {
|
|
89
|
+
this.respondJson(res, 404, { error: "not_found", code: "not_found" });
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const parsed = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
94
|
+
const namespace = this.resolveNamespace(req, parsed.searchParams.get("namespace") ?? undefined);
|
|
95
|
+
const principal = this.resolveRequestPrincipal(req);
|
|
96
|
+
|
|
97
|
+
if (isList) {
|
|
98
|
+
this.enforceTokenOp("review_deck_list");
|
|
99
|
+
const page = await this.service.reviewDeckList({
|
|
100
|
+
namespace,
|
|
101
|
+
principal,
|
|
102
|
+
cursor: parseCursor(parsed.searchParams.get("cursor")),
|
|
103
|
+
limit: parseLimit(parsed.searchParams.get("limit")),
|
|
104
|
+
});
|
|
105
|
+
this.respondJson(res, 200, page);
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (isAction) this.enforceTokenOp("review_deck_action");
|
|
110
|
+
else this.enforceTokenOp("review_deck_undo");
|
|
111
|
+
const writeQuota = this.reserveWriteRateLimitSlot(req);
|
|
112
|
+
try {
|
|
113
|
+
const body = await this.readJsonBody(req, this.maxBodyBytes);
|
|
114
|
+
const result = isAction
|
|
115
|
+
? await this.service.reviewDeckAction(parseActionBody(body), {
|
|
116
|
+
namespace,
|
|
117
|
+
principal,
|
|
118
|
+
signal: abortSignal,
|
|
119
|
+
})
|
|
120
|
+
: await this.service.reviewDeckUndo(parseUndoBody(body), {
|
|
121
|
+
namespace,
|
|
122
|
+
principal,
|
|
123
|
+
signal: abortSignal,
|
|
124
|
+
});
|
|
125
|
+
writeQuota.commit();
|
|
126
|
+
this.respondJson(res, 200, result);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
writeQuota.release();
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
}
|