@remnic/core 9.54.4 → 9.54.6
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 +24 -23
- package/dist/access-admin-ops-surface.js +55 -50
- package/dist/access-authorization-probe.d.ts +25 -22
- package/dist/access-authorization-probe.js +58 -51
- package/dist/access-boundary.d.ts +26 -23
- package/dist/access-boundary.js +59 -52
- package/dist/access-cli.js +115 -107
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.d.ts +1 -1
- package/dist/access-extraction-force-flush.d.ts +19 -18
- package/dist/access-extraction-force-flush.js +55 -50
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +22 -21
- package/dist/access-http-lifecycle-flush.d.ts +22 -21
- package/dist/access-http-offline-stream.d.ts +19 -18
- package/dist/access-http-query.js +55 -50
- package/dist/access-http.d.ts +55 -36
- package/dist/access-http.js +76 -65
- package/dist/access-identity-continuity-surface.d.ts +9 -9
- package/dist/access-identity-continuity-surface.js +55 -50
- package/dist/access-lcm-surface.d.ts +21 -20
- package/dist/access-lcm-surface.js +55 -50
- package/dist/access-mcp.d.ts +22 -21
- package/dist/access-mcp.js +63 -57
- package/dist/access-memory-search-fanout.d.ts +22 -2
- package/dist/access-memory-search-fanout.js +1 -1
- package/dist/{access-namespace-preflight-C7n4tgWC.d.ts → access-namespace-preflight-CCNn_6NE.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +55 -50
- package/dist/access-observe-write-surface.d.ts +22 -21
- package/dist/access-observe-write-surface.js +55 -50
- package/dist/access-offline-manifest.d.ts +10 -9
- package/dist/access-offline-manifest.js +12 -10
- package/dist/access-operations-batch.js +57 -52
- package/dist/access-operations.d.ts +23 -22
- package/dist/access-operations.js +61 -55
- package/dist/access-recall-concurrency.d.ts +21 -20
- package/dist/access-recall-concurrency.js +55 -50
- package/dist/access-recall-response.d.ts +19 -18
- package/dist/access-recall-response.js +55 -50
- package/dist/access-recall-surface.d.ts +19 -18
- package/dist/access-recall-surface.js +55 -50
- package/dist/access-schema.d.ts +2 -2
- package/dist/access-schema.js +5 -4
- package/dist/{access-service-CXvbxLK-.d.ts → access-service-DkSdXK4S.d.ts} +1314 -83
- package/dist/access-service-helpers.d.ts +22 -21
- package/dist/access-service.d.ts +31 -30
- package/dist/access-service.js +55 -50
- package/dist/access-surface-catalog.d.ts +22 -21
- package/dist/access-surface-catalog.js +209 -2
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/access-wearables-meetings-surface.d.ts +3 -3
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +14 -1
- package/dist/active-memory-bridge.js +6 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +4 -2
- package/dist/active-recall.js.map +1 -1
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/registry.js +3 -3
- package/dist/admin-console/public/what-helps-me/app.js +1594 -0
- package/dist/admin-console/public/what-helps-me/index.html +339 -0
- package/dist/admin-console/public/what-helps-me/model.js +685 -0
- package/dist/admin-console/public/what-helps-me/what-helps-me.css +1296 -0
- package/dist/ambient-provenance.d.ts +1 -1
- package/dist/artifact-search.d.ts +1 -1
- package/dist/{auto-sync-TDHLZPVP.js → auto-sync-NR3GPCOA.js} +4 -4
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +9 -9
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +33 -12
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/buffer.js +3 -3
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/calibration.js +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{catalog-BOOxl-I2.d.ts → catalog-DGFf8mD9.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +34 -13
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/{chunk-ZYLC7NFO.js → chunk-26ZXBTYN.js} +4 -4
- package/dist/chunk-26ZXBTYN.js.map +1 -0
- package/dist/{chunk-LLJMAULE.js → chunk-2FKEIPIT.js} +5 -5
- package/dist/{chunk-3CSX3ETE.js → chunk-2LWQSV6A.js} +23 -11
- package/dist/chunk-2LWQSV6A.js.map +1 -0
- package/dist/{chunk-JBPKEARU.js → chunk-2QSZNTDO.js} +7 -7
- package/dist/chunk-37DZZFFM.js +502 -0
- package/dist/chunk-37DZZFFM.js.map +1 -0
- package/dist/chunk-3HSRWJTC.js +9 -0
- package/dist/chunk-3HSRWJTC.js.map +1 -0
- package/dist/{chunk-XUAMCLY4.js → chunk-3TIZPSJC.js} +17 -13
- package/dist/chunk-3TIZPSJC.js.map +1 -0
- package/dist/{chunk-PDDTI7IC.js → chunk-43SEBY2M.js} +1 -1
- package/dist/{chunk-HWRD23DW.js → chunk-46SZBVDS.js} +3 -3
- package/dist/{chunk-6HPHEFXT.js → chunk-5FD7JMTX.js} +2 -2
- package/dist/{chunk-7BZOBA5J.js → chunk-5NB726GV.js} +70 -16
- package/dist/chunk-5NB726GV.js.map +1 -0
- package/dist/chunk-62OKGIJA.js +39 -0
- package/dist/chunk-62OKGIJA.js.map +1 -0
- package/dist/{chunk-IBKR2TFR.js → chunk-6CYHUWCO.js} +2 -2
- package/dist/{chunk-YN6ASZUG.js → chunk-6QPI2ITJ.js} +5 -5
- package/dist/{chunk-UU3G6GUP.js → chunk-76JJSXK7.js} +1 -1
- package/dist/chunk-76JJSXK7.js.map +1 -0
- package/dist/{chunk-PX2LSHYM.js → chunk-7BD6O7ZV.js} +189 -4
- package/dist/chunk-7BD6O7ZV.js.map +1 -0
- package/dist/chunk-7TBXNYLO.js +346 -0
- package/dist/chunk-7TBXNYLO.js.map +1 -0
- package/dist/{chunk-NH5IR2WM.js → chunk-BRR5EUTF.js} +6 -2
- package/dist/chunk-BRR5EUTF.js.map +1 -0
- package/dist/{chunk-NIS256NW.js → chunk-CIAI24TQ.js} +3 -3
- package/dist/{chunk-T2JHZWH6.js → chunk-D3LBIUWV.js} +11703 -7573
- package/dist/chunk-D3LBIUWV.js.map +1 -0
- package/dist/{chunk-7FGL6CGA.js → chunk-DVYRD4HY.js} +2 -2
- package/dist/{chunk-G7Z6EENO.js → chunk-EKTP7MNS.js} +4 -4
- package/dist/{chunk-S75M5ZRK.js → chunk-F2JRDPON.js} +16 -1
- package/dist/chunk-F2JRDPON.js.map +1 -0
- package/dist/{chunk-RZ4XGKOJ.js → chunk-FFRTNF3L.js} +8 -8
- package/dist/{chunk-VKXWK44Q.js → chunk-FONWBCVY.js} +3 -3
- package/dist/{chunk-DZD576ZU.js → chunk-FPLM2TKD.js} +2 -2
- package/dist/{chunk-ZPJ4QSGP.js → chunk-FTPONF6B.js} +2 -2
- package/dist/{chunk-LJS7KUPV.js → chunk-FWX7W5PM.js} +2 -2
- package/dist/{chunk-UTRO5UJU.js → chunk-G6DFSS6A.js} +5 -1
- package/dist/chunk-G6DFSS6A.js.map +1 -0
- package/dist/{chunk-6LAPLZOS.js → chunk-GJ776BC2.js} +8 -3
- package/dist/chunk-GJ776BC2.js.map +1 -0
- package/dist/{chunk-G4T7L557.js → chunk-GN3WRFJY.js} +6 -6
- package/dist/{chunk-QT2FRYI4.js → chunk-H7NAZ3UB.js} +2 -2
- package/dist/{chunk-APPFNGX6.js → chunk-HBUFQRIM.js} +2 -2
- package/dist/{chunk-UU7TRFNE.js → chunk-HGJ6NJ4E.js} +2 -2
- package/dist/{chunk-WB7JSQCP.js → chunk-HIEWDJ2O.js} +5 -2
- package/dist/{chunk-WB7JSQCP.js.map → chunk-HIEWDJ2O.js.map} +1 -1
- package/dist/{chunk-UES4BHA2.js → chunk-I3MSGFGD.js} +17 -6
- package/dist/chunk-I3MSGFGD.js.map +1 -0
- package/dist/{chunk-C4ZNGVK3.js → chunk-IKP5OYQQ.js} +2 -2
- package/dist/{chunk-KQAFEZQX.js → chunk-IPLYGWQF.js} +5 -5
- package/dist/{chunk-RDJRFDJY.js → chunk-IQ4NVWEF.js} +2 -2
- package/dist/{chunk-CGVHPCP2.js → chunk-JYG4OLWH.js} +2 -2
- package/dist/{chunk-WOPA3SGI.js → chunk-K26NWEOC.js} +8 -8
- package/dist/{chunk-K4QS7LXU.js → chunk-K2UGPTYY.js} +485 -44
- package/dist/chunk-K2UGPTYY.js.map +1 -0
- package/dist/{chunk-L6CQ7WIW.js → chunk-KFBOPMF6.js} +11 -11
- package/dist/chunk-KFBOPMF6.js.map +1 -0
- package/dist/{chunk-G7A5HLUS.js → chunk-KJH6W2I7.js} +2 -2
- package/dist/{chunk-IXEBUYO4.js → chunk-KM55SMLG.js} +11 -2
- package/dist/{chunk-IXEBUYO4.js.map → chunk-KM55SMLG.js.map} +1 -1
- package/dist/{chunk-HOIRB77A.js → chunk-L6Z5OAS4.js} +2 -2
- package/dist/chunk-LC2BDILZ.js +57 -0
- package/dist/chunk-LC2BDILZ.js.map +1 -0
- package/dist/{chunk-227UFSEQ.js → chunk-LEPOP46W.js} +4 -4
- package/dist/{chunk-6R4G7N4S.js → chunk-M4YHAODQ.js} +388 -748
- package/dist/chunk-M4YHAODQ.js.map +1 -0
- package/dist/{chunk-3JLPGJ43.js → chunk-MIH3CJPN.js} +5 -5
- package/dist/{chunk-QHFV6VNU.js → chunk-MK5VEWCR.js} +2 -2
- package/dist/chunk-NISZQW72.js +140 -0
- package/dist/chunk-NISZQW72.js.map +1 -0
- package/dist/{chunk-GUKBW4HL.js → chunk-NQMSEB5D.js} +6 -6
- package/dist/{chunk-G2LUMAUF.js → chunk-OCIP6YMD.js} +12 -5
- package/dist/chunk-OCIP6YMD.js.map +1 -0
- package/dist/{chunk-47P3RYZP.js → chunk-PG4QBPVG.js} +21 -11
- package/dist/chunk-PG4QBPVG.js.map +1 -0
- package/dist/{chunk-WRJVB3C2.js → chunk-PO7NXBG2.js} +2 -2
- package/dist/{chunk-QWGE2PUH.js → chunk-PT54WISF.js} +190 -56
- package/dist/chunk-PT54WISF.js.map +1 -0
- package/dist/{chunk-AZM4CCAC.js → chunk-QZLDRQ4I.js} +8 -8
- package/dist/{chunk-THPPCISA.js → chunk-RBII7637.js} +5 -5
- package/dist/{chunk-JDZPNCMA.js → chunk-RUNORG2P.js} +6 -3
- package/dist/chunk-RUNORG2P.js.map +1 -0
- package/dist/{chunk-JV5YUBIZ.js → chunk-RZQ6W2W4.js} +50 -44
- package/dist/chunk-RZQ6W2W4.js.map +1 -0
- package/dist/{chunk-RUMNY5DT.js → chunk-SMNYAMJD.js} +6 -2
- package/dist/chunk-SMNYAMJD.js.map +1 -0
- package/dist/{chunk-MKQBXQKU.js → chunk-TB6CBZ5V.js} +22 -15
- package/dist/chunk-TB6CBZ5V.js.map +1 -0
- package/dist/{chunk-VMMQDEN5.js → chunk-TO7ZTWJW.js} +2 -2
- package/dist/{chunk-K2TDK7GG.js → chunk-TWTUGCTY.js} +2 -2
- package/dist/{chunk-HLYR2TQL.js → chunk-UCTS3DDH.js} +2 -2
- package/dist/{chunk-JYIJNNN3.js → chunk-UG6VXIOK.js} +2 -2
- package/dist/{chunk-WM65LU67.js → chunk-UKYS3NU5.js} +2 -2
- package/dist/{chunk-WDBX6VER.js → chunk-UPLZNJKN.js} +5 -5
- package/dist/{chunk-C23BYTJV.js → chunk-UW5NPZJ2.js} +40 -12
- package/dist/chunk-UW5NPZJ2.js.map +1 -0
- package/dist/{chunk-2GFK22OZ.js → chunk-V6ERBR7U.js} +2 -2
- package/dist/{chunk-CYF6WVE7.js → chunk-W5ZKPI34.js} +139 -158
- package/dist/chunk-W5ZKPI34.js.map +1 -0
- package/dist/chunk-XX4HPFFM.js +370 -0
- package/dist/chunk-XX4HPFFM.js.map +1 -0
- package/dist/{chunk-ZMYDYNI4.js → chunk-XZHE2DEN.js} +4 -4
- package/dist/chunk-YXQEKCZM.js +223 -0
- package/dist/chunk-YXQEKCZM.js.map +1 -0
- package/dist/{chunk-GYPQL6XN.js → chunk-Z4N7SVVF.js} +35 -47
- package/dist/chunk-Z4N7SVVF.js.map +1 -0
- package/dist/{chunk-MAXVH44E.js → chunk-Z54EM5YZ.js} +7 -7
- package/dist/{chunk-YGLY6QFV.js → chunk-ZRZVLB7O.js} +2 -2
- package/dist/{chunk-4IIFL7GC.js → chunk-ZUKIUXHQ.js} +10 -10
- package/dist/{cli-DVUFIa5E.d.ts → cli-Bze8S0Qs.d.ts} +5 -5
- package/dist/cli.d.ts +22 -21
- package/dist/cli.js +90 -80
- package/dist/coding/pre-action-gate.d.ts +1 -1
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +33 -12
- 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 +4 -2
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +33 -12
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +32 -12
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/contradiction/index.d.ts +2 -2
- package/dist/contradiction/index.js +3 -1
- package/dist/contradiction-scan-JDTBXRGW.js +20 -0
- package/dist/converge-config.d.ts +1 -1
- package/dist/convergence-refresh.d.ts +2 -2
- package/dist/convergence-refresh.js +35 -14
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/backend.js +2 -2
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/corpus-watermark.d.ts +1 -1
- package/dist/corpus-watermark.js +25 -24
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/dependency-propagation-config.d.ts +1 -1
- package/dist/{dependency-propagation-delivery-XzF76C9n.d.ts → dependency-propagation-delivery-CzEfB31P.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 +2 -2
- package/dist/entity-retrieval.js +33 -12
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +9 -9
- package/dist/explicit-capture.js +7 -4
- package/dist/external-wiki-access.d.ts +22 -21
- package/dist/external-wiki-access.js +56 -51
- package/dist/external-wiki-collection-registration.d.ts +1 -1
- package/dist/external-wiki-collection.d.ts +1 -1
- package/dist/external-wiki-mcp-tools.d.ts +22 -21
- package/dist/extraction-error-classification.d.ts +1 -1
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-faithfulness.js +2 -2
- 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 +2 -2
- package/dist/extraction-liveness.d.ts +1 -1
- package/dist/extraction-normalization.d.ts +1 -1
- package/dist/extraction-prompt.d.ts +1 -1
- package/dist/extraction-source-grounding-rules.d.ts +1 -1
- package/dist/extraction-source-grounding.d.ts +1 -1
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +35 -19
- package/dist/fallback-llm.d.ts +14 -1
- package/dist/fallback-llm.js +1 -1
- package/dist/{first-start-migration-626C5554.js → first-start-migration-CRZCZAJN.js} +11 -3
- package/dist/first-start-migration-CRZCZAJN.js.map +1 -0
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-path-reconstruction.d.ts +1 -1
- package/dist/graph-path-scoring.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/harmonic-retrieval.js +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/index.d.ts +314 -308
- package/dist/index.js +304 -133
- package/dist/inline-script.d.ts +3 -0
- package/dist/inline-script.js +8 -0
- package/dist/inline-script.js.map +1 -0
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/engine.js +3 -3
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +6 -6
- 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 +2 -1
- package/dist/local-llm.js +2 -2
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +33 -12
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +33 -12
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +34 -13
- package/dist/{maintenance-BJzNIKBE.d.ts → maintenance-C8aRWfhq.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +22 -21
- package/dist/mcp-read-only-tools.js +1 -1
- 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-mutations.js +2 -2
- package/dist/memory-projection-store.d.ts +6 -2
- package/dist/memory-projection-store.js +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-snapshot.d.ts +1 -1
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +3 -3
- package/dist/namespaces/migrate.js +24 -23
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +8 -8
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +33 -12
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-file-io.d.ts +20 -0
- package/dist/offline-sync-file-io.js +18 -0
- package/dist/offline-sync-file-io.js.map +1 -0
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/offline-sync-impression-drain.js +5 -5
- package/dist/offline-sync.d.ts +8 -6
- package/dist/offline-sync.js +2 -1
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +26 -25
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +39 -36
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +38 -18
- package/dist/{orchestrator-BiXgBJBQ.d.ts → orchestrator-D85CzDDY.d.ts} +11 -8
- package/dist/orchestrator.d.ts +9 -9
- package/dist/orchestrator.js +117 -109
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-sz_dcuLg.d.ts → pipeline-DPcUifCO.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/public-http-D-SyWNj6.d.ts +25 -0
- package/dist/{purge-533FZLS4.js → purge-GB7PZHT2.js} +2 -2
- package/dist/{qmd-eAWObK4M.d.ts → qmd-dFCHp1r0.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-planner-llm.js +1 -1
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -1
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/cursor.d.ts +2 -1
- package/dist/reconcile/manifest.d.ts +2 -1
- package/dist/reconcile/manifest.js +6 -5
- package/dist/reconcile/plan.d.ts +2 -1
- package/dist/reconcile/plan.js +3 -2
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/replica-divergence.d.ts +1 -1
- package/dist/replica-peers-config.d.ts +1 -1
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +5 -3
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/salvage-envelope.d.ts +1 -1
- package/dist/schemas.d.ts +38 -38
- package/dist/{scope-profiles-BBQsXuyj.d.ts → scope-profiles-DICK7GtN.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 +6 -6
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +12 -12
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-HD8RkzVA.d.ts → semantic-consolidation-BP7NAX0N.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +34 -13
- package/dist/semantic-rule-promotion.js +33 -12
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +33 -12
- package/dist/{service-DIrtHHEg.d.ts → service-DT-pJyda.d.ts} +660 -660
- 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/source-agent-qualifier.d.ts +1 -1
- package/dist/source-agent-qualifier.js +31 -15
- package/dist/{storage-DqCzXi56.d.ts → storage-qOnaJ1Lw.d.ts} +49 -13
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +33 -12
- package/dist/summarizer.d.ts +1 -1
- package/dist/summarizer.js +5 -5
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/support-passport/index.d.ts +518 -0
- package/dist/support-passport/index.js +357 -0
- package/dist/support-passport/index.js.map +1 -0
- package/dist/temporal-supersession.d.ts +2 -2
- package/dist/temporal-timeline-recall.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +2 -2
- package/dist/tier-routing.d.ts +2 -2
- package/dist/tier-routing.js +7 -1
- package/dist/{tier-stats-2JCZYEF7.js → tier-stats-EXYSKSVN.js} +8 -2
- package/dist/{tier-stats-2JCZYEF7.js.map → tier-stats-EXYSKSVN.js.map} +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/autodetect.js +1 -1
- package/dist/transfer/backup.js +1 -1
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/types.d.ts +36 -36
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-d_j4vC6N.d.ts → types-ed-SvS2t.d.ts} +8 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +2 -2
- package/dist/verified-recall.js +33 -12
- package/dist/write-envelope.d.ts +1 -1
- package/dist/write-rate-limiter.d.ts +11 -5
- package/dist/write-rate-limiter.js +1 -1
- package/package.json +12 -2
- package/scripts/build-with-heap.mjs +11 -1
- package/src/access-authorization-probe.ts +20 -2
- package/src/access-boundary.ts +32 -0
- package/src/access-http.test.ts +1971 -643
- package/src/access-http.ts +81 -74
- package/src/access-mcp.ts +3 -1
- package/src/access-memory-search-fanout.ts +24 -1
- package/src/access-offline-manifest.ts +5 -0
- package/src/access-operations.ts +2 -0
- package/src/access-service-namespace.test.ts +14 -0
- package/src/access-service-observe-scope.test.ts +2 -0
- package/src/access-service-offline-file-content.test.ts +211 -0
- package/src/access-service.ts +628 -884
- package/src/access-surface-catalog.test.ts +40 -10
- package/src/access-surface-catalog.ts +15 -0
- package/src/active-memory-bridge.test.ts +151 -0
- package/src/active-memory-bridge.ts +95 -21
- package/src/briefing.test.ts +38 -0
- package/src/briefing.ts +3 -3
- package/src/cli.ts +6 -1
- package/src/config.ts +18 -9
- package/src/connectors/codex-materialize-runner.ts +2 -0
- package/src/contradiction/contradiction-scan.ts +2 -0
- package/src/contradiction/contradiction.test.ts +42 -0
- package/src/correction/correction-access-wiring.ts +8 -2
- package/src/correction/correction-storage-integration.test.ts +7 -0
- package/src/explicit-capture.test.ts +24 -0
- package/src/explicit-capture.ts +2 -0
- package/src/fallback-llm.test.ts +54 -0
- package/src/fallback-llm.ts +54 -9
- package/src/index.ts +3 -0
- package/src/inline-script.ts +6 -0
- package/src/local-llm-headers-timeout.test.ts +42 -0
- package/src/local-llm.ts +8 -8
- package/src/maintenance/first-start-migration.ts +2 -1
- package/src/maintenance/memory-governance.test.ts +25 -0
- package/src/maintenance/memory-governance.ts +4 -1
- package/src/maintenance/pattern-reinforcement.test.ts +20 -0
- package/src/maintenance/pattern-reinforcement.ts +2 -1
- package/src/maintenance/rebuild-memory-projection.ts +8 -8
- package/src/mcp-read-only-tools.ts +3 -0
- package/src/memory-projection-store.ts +25 -27
- package/src/offline-sync-file-io.ts +68 -0
- package/src/offline-sync.ts +43 -57
- package/src/orchestration/consolidation-run.ts +5 -4
- package/src/orchestration/contradiction-linking-coordinator.ts +7 -0
- package/src/orchestration/contradiction-localization.integration.test.ts +115 -0
- package/src/orchestration/lifecycle-policy-coordinator.ts +2 -1
- package/src/orchestration/qmd-result-resolver.test.ts +215 -14
- package/src/orchestration/qmd-result-resolver.ts +142 -82
- package/src/orchestration/recall-search-pipeline.test.ts +41 -0
- package/src/orchestration/recall-search-pipeline.ts +12 -0
- package/src/orchestration/semantic-consolidation-coordinator.ts +2 -1
- package/src/orchestration/tier-migration-coordinator.ts +23 -56
- package/src/orchestration/workspace-ops.test.ts +37 -0
- package/src/orchestration/workspace-ops.ts +5 -29
- package/src/orchestrator.ts +7 -8
- package/src/relay/mission-access.test.ts +11 -11
- package/src/relay/mission-ui.test.ts +3 -1
- package/src/storage/supersession-audit.ts +7 -1
- package/src/storage/supersession-side-effects.ts +17 -5
- package/src/storage/tombstone-blocked-capture-sync.ts +31 -0
- package/src/storage-contract/failure-semantics.test.ts +102 -0
- package/src/storage.ts +18 -19
- package/src/support-passport/access-http-base.ts +143 -0
- package/src/support-passport/access-http.ts +172 -0
- package/src/support-passport/access-operations.ts +272 -0
- package/src/support-passport/access-service-base.test.ts +193 -0
- package/src/support-passport/access-service-base.ts +176 -0
- package/src/support-passport/access-surface.test.ts +283 -0
- package/src/support-passport/access-surface.ts +286 -0
- package/src/support-passport/card-projection.test.ts +137 -0
- package/src/support-passport/card-projection.ts +348 -0
- package/src/support-passport/card-replacement.ts +126 -0
- package/src/support-passport/card-service-commit-forwarding.test.ts +160 -0
- package/src/support-passport/card-service.test.ts +2964 -0
- package/src/support-passport/card-service.ts +1184 -0
- package/src/support-passport/card-state.ts +158 -0
- package/src/support-passport/config-model-routing.test.ts +37 -0
- package/src/support-passport/config.test.ts +34 -0
- package/src/support-passport/config.ts +41 -0
- package/src/support-passport/contracts.test.ts +156 -0
- package/src/support-passport/contracts.ts +149 -0
- package/src/support-passport/errors.ts +30 -0
- package/src/support-passport/generated-batch.test.ts +185 -0
- package/src/support-passport/generated-batch.ts +338 -0
- package/src/support-passport/grant-contracts.ts +183 -0
- package/src/support-passport/grant-generated-batch-scope.test.ts +201 -0
- package/src/support-passport/grant-service-cache.test.ts +148 -0
- package/src/support-passport/grant-service-cancellation.test.ts +83 -0
- package/src/support-passport/grant-service-marker-cache.test.ts +62 -0
- package/src/support-passport/grant-service.test.ts +3496 -0
- package/src/support-passport/grant-service.ts +513 -0
- package/src/support-passport/grant-store-commit-hook.test.ts +123 -0
- package/src/support-passport/grant-store-order.test.ts +60 -0
- package/src/support-passport/grant-store-path-safety.test.ts +30 -0
- package/src/support-passport/grant-store-recovery.test.ts +448 -0
- package/src/support-passport/grant-store.ts +906 -0
- package/src/support-passport/index.ts +17 -0
- package/src/support-passport/mcp-tools.test.ts +222 -0
- package/src/support-passport/mcp-tools.ts +187 -0
- package/src/support-passport/model-adapter.test.ts +840 -0
- package/src/support-passport/model-adapter.ts +602 -0
- package/src/support-passport/model-audit-pinned-write.test.ts +59 -0
- package/src/support-passport/model-audit.ts +152 -0
- package/src/support-passport/model-bridge.test.ts +456 -0
- package/src/support-passport/model-bridge.ts +439 -0
- package/src/support-passport/model-contracts.ts +124 -0
- package/src/support-passport/model-service.test.ts +1731 -0
- package/src/support-passport/model-service.ts +399 -0
- package/src/support-passport/offline-sync-guard.ts +230 -0
- package/src/support-passport/owner-http.test.ts +671 -0
- package/src/support-passport/owner-lock.ts +70 -0
- package/src/support-passport/private-file.test.ts +99 -0
- package/src/support-passport/private-file.ts +498 -0
- package/src/support-passport/public-http.test.ts +476 -0
- package/src/support-passport/public-http.ts +601 -0
- package/src/support-passport/ui.test.ts +181 -0
- package/src/tier-routing.ts +28 -17
- package/src/training-export/converter.test.ts +24 -0
- package/src/training-export/converter.ts +2 -0
- package/src/types.ts +8 -1
- package/src/wearables/service.test.ts +13 -0
- package/src/wearables/service.ts +2 -0
- package/src/write-rate-limiter.test.ts +30 -6
- package/src/write-rate-limiter.ts +29 -18
- package/dist/chunk-3CSX3ETE.js.map +0 -1
- package/dist/chunk-47P3RYZP.js.map +0 -1
- package/dist/chunk-6LAPLZOS.js.map +0 -1
- package/dist/chunk-6R4G7N4S.js.map +0 -1
- package/dist/chunk-7BZOBA5J.js.map +0 -1
- package/dist/chunk-C23BYTJV.js.map +0 -1
- package/dist/chunk-CYF6WVE7.js.map +0 -1
- package/dist/chunk-G2LUMAUF.js.map +0 -1
- package/dist/chunk-GYPQL6XN.js.map +0 -1
- package/dist/chunk-JDZPNCMA.js.map +0 -1
- package/dist/chunk-JV5YUBIZ.js.map +0 -1
- package/dist/chunk-K4QS7LXU.js.map +0 -1
- package/dist/chunk-L6CQ7WIW.js.map +0 -1
- package/dist/chunk-MKQBXQKU.js.map +0 -1
- package/dist/chunk-NH5IR2WM.js.map +0 -1
- package/dist/chunk-PX2LSHYM.js.map +0 -1
- package/dist/chunk-QWGE2PUH.js.map +0 -1
- package/dist/chunk-RUMNY5DT.js.map +0 -1
- package/dist/chunk-S75M5ZRK.js.map +0 -1
- package/dist/chunk-T2JHZWH6.js.map +0 -1
- package/dist/chunk-UES4BHA2.js.map +0 -1
- package/dist/chunk-UTRO5UJU.js.map +0 -1
- package/dist/chunk-UU3G6GUP.js.map +0 -1
- package/dist/chunk-XUAMCLY4.js.map +0 -1
- package/dist/chunk-ZYLC7NFO.js.map +0 -1
- package/dist/contradiction-scan-HYLIRMJ2.js +0 -14
- package/dist/first-start-migration-626C5554.js.map +0 -1
- /package/dist/{auto-sync-TDHLZPVP.js.map → auto-sync-NR3GPCOA.js.map} +0 -0
- /package/dist/{chunk-LLJMAULE.js.map → chunk-2FKEIPIT.js.map} +0 -0
- /package/dist/{chunk-JBPKEARU.js.map → chunk-2QSZNTDO.js.map} +0 -0
- /package/dist/{chunk-PDDTI7IC.js.map → chunk-43SEBY2M.js.map} +0 -0
- /package/dist/{chunk-HWRD23DW.js.map → chunk-46SZBVDS.js.map} +0 -0
- /package/dist/{chunk-6HPHEFXT.js.map → chunk-5FD7JMTX.js.map} +0 -0
- /package/dist/{chunk-IBKR2TFR.js.map → chunk-6CYHUWCO.js.map} +0 -0
- /package/dist/{chunk-YN6ASZUG.js.map → chunk-6QPI2ITJ.js.map} +0 -0
- /package/dist/{chunk-NIS256NW.js.map → chunk-CIAI24TQ.js.map} +0 -0
- /package/dist/{chunk-7FGL6CGA.js.map → chunk-DVYRD4HY.js.map} +0 -0
- /package/dist/{chunk-G7Z6EENO.js.map → chunk-EKTP7MNS.js.map} +0 -0
- /package/dist/{chunk-RZ4XGKOJ.js.map → chunk-FFRTNF3L.js.map} +0 -0
- /package/dist/{chunk-VKXWK44Q.js.map → chunk-FONWBCVY.js.map} +0 -0
- /package/dist/{chunk-DZD576ZU.js.map → chunk-FPLM2TKD.js.map} +0 -0
- /package/dist/{chunk-ZPJ4QSGP.js.map → chunk-FTPONF6B.js.map} +0 -0
- /package/dist/{chunk-LJS7KUPV.js.map → chunk-FWX7W5PM.js.map} +0 -0
- /package/dist/{chunk-G4T7L557.js.map → chunk-GN3WRFJY.js.map} +0 -0
- /package/dist/{chunk-QT2FRYI4.js.map → chunk-H7NAZ3UB.js.map} +0 -0
- /package/dist/{chunk-APPFNGX6.js.map → chunk-HBUFQRIM.js.map} +0 -0
- /package/dist/{chunk-UU7TRFNE.js.map → chunk-HGJ6NJ4E.js.map} +0 -0
- /package/dist/{chunk-C4ZNGVK3.js.map → chunk-IKP5OYQQ.js.map} +0 -0
- /package/dist/{chunk-KQAFEZQX.js.map → chunk-IPLYGWQF.js.map} +0 -0
- /package/dist/{chunk-RDJRFDJY.js.map → chunk-IQ4NVWEF.js.map} +0 -0
- /package/dist/{chunk-CGVHPCP2.js.map → chunk-JYG4OLWH.js.map} +0 -0
- /package/dist/{chunk-WOPA3SGI.js.map → chunk-K26NWEOC.js.map} +0 -0
- /package/dist/{chunk-G7A5HLUS.js.map → chunk-KJH6W2I7.js.map} +0 -0
- /package/dist/{chunk-HOIRB77A.js.map → chunk-L6Z5OAS4.js.map} +0 -0
- /package/dist/{chunk-227UFSEQ.js.map → chunk-LEPOP46W.js.map} +0 -0
- /package/dist/{chunk-3JLPGJ43.js.map → chunk-MIH3CJPN.js.map} +0 -0
- /package/dist/{chunk-QHFV6VNU.js.map → chunk-MK5VEWCR.js.map} +0 -0
- /package/dist/{chunk-GUKBW4HL.js.map → chunk-NQMSEB5D.js.map} +0 -0
- /package/dist/{chunk-WRJVB3C2.js.map → chunk-PO7NXBG2.js.map} +0 -0
- /package/dist/{chunk-AZM4CCAC.js.map → chunk-QZLDRQ4I.js.map} +0 -0
- /package/dist/{chunk-THPPCISA.js.map → chunk-RBII7637.js.map} +0 -0
- /package/dist/{chunk-VMMQDEN5.js.map → chunk-TO7ZTWJW.js.map} +0 -0
- /package/dist/{chunk-K2TDK7GG.js.map → chunk-TWTUGCTY.js.map} +0 -0
- /package/dist/{chunk-HLYR2TQL.js.map → chunk-UCTS3DDH.js.map} +0 -0
- /package/dist/{chunk-JYIJNNN3.js.map → chunk-UG6VXIOK.js.map} +0 -0
- /package/dist/{chunk-WM65LU67.js.map → chunk-UKYS3NU5.js.map} +0 -0
- /package/dist/{chunk-WDBX6VER.js.map → chunk-UPLZNJKN.js.map} +0 -0
- /package/dist/{chunk-2GFK22OZ.js.map → chunk-V6ERBR7U.js.map} +0 -0
- /package/dist/{chunk-ZMYDYNI4.js.map → chunk-XZHE2DEN.js.map} +0 -0
- /package/dist/{chunk-MAXVH44E.js.map → chunk-Z54EM5YZ.js.map} +0 -0
- /package/dist/{chunk-YGLY6QFV.js.map → chunk-ZRZVLB7O.js.map} +0 -0
- /package/dist/{chunk-4IIFL7GC.js.map → chunk-ZUKIUXHQ.js.map} +0 -0
- /package/dist/{contradiction-scan-HYLIRMJ2.js.map → contradiction-scan-JDTBXRGW.js.map} +0 -0
- /package/dist/{purge-533FZLS4.js.map → purge-GB7PZHT2.js.map} +0 -0
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import type { StorageManager } from "../index.js";
|
|
2
|
+
import type { MemoryFile } from "../types.js";
|
|
3
|
+
import {
|
|
4
|
+
type StoredSupportPassportCard,
|
|
5
|
+
activeSupportPassportReplacementPredecessorIds,
|
|
6
|
+
computeSupportPassportOwnerKey,
|
|
7
|
+
projectSupportPassportCard,
|
|
8
|
+
} from "./card-projection.js";
|
|
9
|
+
import {
|
|
10
|
+
SupportPassportListCardsInputSchema,
|
|
11
|
+
SupportPassportNamespaceSchema,
|
|
12
|
+
} from "./contracts.js";
|
|
13
|
+
import { SupportPassportError } from "./errors.js";
|
|
14
|
+
import { type GeneratedBatchMarker, isCommittedGeneratedCard } from "./generated-batch.js";
|
|
15
|
+
import {
|
|
16
|
+
type SupportPassportCreateGrantInput,
|
|
17
|
+
SupportPassportCreateGrantInputSchema,
|
|
18
|
+
type SupportPassportCreatedGrant,
|
|
19
|
+
SupportPassportCreatedGrantSchema,
|
|
20
|
+
type SupportPassportGrantState,
|
|
21
|
+
SupportPassportListGrantsInputSchema,
|
|
22
|
+
type SupportPassportOwnerGrant,
|
|
23
|
+
SupportPassportOwnerGrantSchema,
|
|
24
|
+
SupportPassportPublicCardSchema,
|
|
25
|
+
type SupportPassportPublicGuide,
|
|
26
|
+
SupportPassportPublicGuideSchema,
|
|
27
|
+
type SupportPassportRevokeGrantInput,
|
|
28
|
+
SupportPassportRevokeGrantInputSchema,
|
|
29
|
+
} from "./grant-contracts.js";
|
|
30
|
+
import { type SupportPassportGrantStore, notifySupportPassportCommitted } from "./grant-store.js";
|
|
31
|
+
import { requireSupportPassportOwnerLock, withSupportPassportOwnerLock } from "./owner-lock.js";
|
|
32
|
+
|
|
33
|
+
export interface SupportPassportGrantServiceDependencies {
|
|
34
|
+
grantStore: SupportPassportGrantStore;
|
|
35
|
+
resolveOwner(
|
|
36
|
+
principal: string,
|
|
37
|
+
): Promise<{ principal: string; namespace: string; storage: StorageManager }>;
|
|
38
|
+
resolveNamespace(namespace: string): Promise<StorageManager>;
|
|
39
|
+
now?: () => Date;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type SupportPassportGrantOwnerScope = Awaited<
|
|
43
|
+
ReturnType<SupportPassportGrantServiceDependencies["resolveOwner"]>
|
|
44
|
+
>;
|
|
45
|
+
|
|
46
|
+
interface SupportPassportCardSnapshot {
|
|
47
|
+
version: string;
|
|
48
|
+
cardsById: ReadonlyMap<string, StoredSupportPassportCard>;
|
|
49
|
+
activeReplacementPredecessors: ReadonlySet<string>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface CachedOwnerCards {
|
|
53
|
+
version: string;
|
|
54
|
+
expiresAt: number;
|
|
55
|
+
cards: readonly StoredSupportPassportCard[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const MAX_OWNER_CARD_CACHE_ENTRIES = 256;
|
|
59
|
+
|
|
60
|
+
function invalidInput(): SupportPassportError {
|
|
61
|
+
return new SupportPassportError(
|
|
62
|
+
"invalid_input",
|
|
63
|
+
"The share link request is invalid.",
|
|
64
|
+
400,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export class SupportPassportGrantService {
|
|
69
|
+
private readonly grantStore: SupportPassportGrantStore;
|
|
70
|
+
private readonly resolveOwner: SupportPassportGrantServiceDependencies["resolveOwner"];
|
|
71
|
+
private readonly resolveNamespace: SupportPassportGrantServiceDependencies["resolveNamespace"];
|
|
72
|
+
private readonly now: () => Date;
|
|
73
|
+
private readonly ownerCardCache = new Map<string, CachedOwnerCards>();
|
|
74
|
+
|
|
75
|
+
constructor(dependencies: SupportPassportGrantServiceDependencies) {
|
|
76
|
+
this.grantStore = dependencies.grantStore;
|
|
77
|
+
this.resolveOwner = dependencies.resolveOwner;
|
|
78
|
+
this.resolveNamespace = dependencies.resolveNamespace;
|
|
79
|
+
this.now = dependencies.now ?? (() => new Date());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async createGrant(
|
|
83
|
+
input: SupportPassportCreateGrantInput,
|
|
84
|
+
options: { signal?: AbortSignal; onCommitted?: () => void | Promise<void> } = {},
|
|
85
|
+
): Promise<SupportPassportCreatedGrant> {
|
|
86
|
+
const requestedAt = this.now();
|
|
87
|
+
const parsed = SupportPassportCreateGrantInputSchema.safeParse(input);
|
|
88
|
+
if (!parsed.success) throw invalidInput();
|
|
89
|
+
const expiresAt = parsed.data.expiresAt ?? this.expiryFromDuration(requestedAt, parsed.data.durationMs);
|
|
90
|
+
const owner = await this.resolveOwnerScope(parsed.data.principal);
|
|
91
|
+
return await withSupportPassportOwnerLock(
|
|
92
|
+
owner.storage,
|
|
93
|
+
{ namespace: owner.namespace, principal: owner.principal },
|
|
94
|
+
async (ownerLock) => {
|
|
95
|
+
options.signal?.throwIfAborted();
|
|
96
|
+
const ownerKey = computeSupportPassportOwnerKey(owner.principal);
|
|
97
|
+
const snapshot = await this.readStoredCardSnapshot(
|
|
98
|
+
owner.storage,
|
|
99
|
+
owner.namespace,
|
|
100
|
+
ownerKey,
|
|
101
|
+
);
|
|
102
|
+
for (const cardRef of parsed.data.cards) {
|
|
103
|
+
const stored = snapshot.cardsById.get(cardRef.cardId);
|
|
104
|
+
if (
|
|
105
|
+
!stored ||
|
|
106
|
+
stored.namespace !== owner.namespace ||
|
|
107
|
+
stored.owner !== ownerKey ||
|
|
108
|
+
stored.card.status !== "active" ||
|
|
109
|
+
snapshot.activeReplacementPredecessors.has(cardRef.cardId)
|
|
110
|
+
) {
|
|
111
|
+
throw new SupportPassportError(
|
|
112
|
+
"invalid_card_status",
|
|
113
|
+
"Only approved support cards can be shared.",
|
|
114
|
+
409,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
if (stored.card.revision !== cardRef.revision) {
|
|
118
|
+
throw new SupportPassportError(
|
|
119
|
+
"revision_conflict",
|
|
120
|
+
"A support card changed after it was selected.",
|
|
121
|
+
409,
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
if (!this.publicCard(stored.card).success) {
|
|
125
|
+
throw new SupportPassportError(
|
|
126
|
+
"card_data_invalid",
|
|
127
|
+
"The support card data is invalid.",
|
|
128
|
+
500,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const created = await this.grantStore.create(
|
|
133
|
+
{
|
|
134
|
+
namespace: owner.namespace,
|
|
135
|
+
principal: owner.principal,
|
|
136
|
+
cards: parsed.data.cards,
|
|
137
|
+
expiresAt,
|
|
138
|
+
requestedAt,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
beforeCommit: async () => {
|
|
142
|
+
options.signal?.throwIfAborted();
|
|
143
|
+
await requireSupportPassportOwnerLock(ownerLock);
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
);
|
|
147
|
+
try {
|
|
148
|
+
await requireSupportPassportOwnerLock(ownerLock);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
await this.revokeCommittedGrant(created, owner);
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
if (options.signal?.aborted) {
|
|
154
|
+
await this.revokeCommittedGrant(created, owner);
|
|
155
|
+
options.signal.throwIfAborted();
|
|
156
|
+
}
|
|
157
|
+
const output = SupportPassportCreatedGrantSchema.parse({
|
|
158
|
+
grant: this.ownerGrant(created.state),
|
|
159
|
+
secret: created.secret,
|
|
160
|
+
});
|
|
161
|
+
notifySupportPassportCommitted(options.onCommitted);
|
|
162
|
+
return output;
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async listGrants(input: {
|
|
168
|
+
principal: string;
|
|
169
|
+
}): Promise<SupportPassportOwnerGrant[]> {
|
|
170
|
+
const parsed = SupportPassportListGrantsInputSchema.safeParse(input);
|
|
171
|
+
if (!parsed.success) throw invalidInput();
|
|
172
|
+
const owner = await this.resolveOwnerScope(parsed.data.principal);
|
|
173
|
+
return (
|
|
174
|
+
await this.grantStore.listForOwner(owner.namespace, owner.principal)
|
|
175
|
+
).map((state) => this.ownerGrant(state));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async revokeGrant(
|
|
179
|
+
input: SupportPassportRevokeGrantInput,
|
|
180
|
+
options: { signal?: AbortSignal; onCommitted?: () => void | Promise<void> } = {},
|
|
181
|
+
): Promise<SupportPassportOwnerGrant> {
|
|
182
|
+
const parsed = SupportPassportRevokeGrantInputSchema.safeParse(input);
|
|
183
|
+
if (!parsed.success) throw invalidInput();
|
|
184
|
+
const owner = await this.resolveOwnerScope(parsed.data.principal);
|
|
185
|
+
return await withSupportPassportOwnerLock(
|
|
186
|
+
owner.storage,
|
|
187
|
+
{ namespace: owner.namespace, principal: owner.principal },
|
|
188
|
+
async (ownerLock) => {
|
|
189
|
+
options.signal?.throwIfAborted();
|
|
190
|
+
const state = await this.grantStore.revoke(
|
|
191
|
+
{
|
|
192
|
+
grantId: parsed.data.grantId,
|
|
193
|
+
namespace: owner.namespace,
|
|
194
|
+
principal: owner.principal,
|
|
195
|
+
expectedStateVersion: parsed.data.expectedStateVersion,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
beforeCommit: async () => {
|
|
199
|
+
options.signal?.throwIfAborted();
|
|
200
|
+
await requireSupportPassportOwnerLock(ownerLock);
|
|
201
|
+
},
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
const output = this.ownerGrant(state);
|
|
205
|
+
notifySupportPassportCommitted(options.onCommitted);
|
|
206
|
+
return output;
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async readGrant(input: {
|
|
212
|
+
grantId: string;
|
|
213
|
+
secret: string;
|
|
214
|
+
}): Promise<SupportPassportPublicGuide> {
|
|
215
|
+
if (
|
|
216
|
+
!input ||
|
|
217
|
+
typeof input.grantId !== "string" ||
|
|
218
|
+
typeof input.secret !== "string"
|
|
219
|
+
) {
|
|
220
|
+
throw new SupportPassportError(
|
|
221
|
+
"grant_not_found",
|
|
222
|
+
"The share link was not found.",
|
|
223
|
+
404,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
return await this.readGrantAttempt(input);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
private async readGrantAttempt(input: {
|
|
230
|
+
grantId: string;
|
|
231
|
+
secret: string;
|
|
232
|
+
}): Promise<SupportPassportPublicGuide> {
|
|
233
|
+
const initialState = await this.grantStore.authenticate(
|
|
234
|
+
input.grantId,
|
|
235
|
+
input.secret,
|
|
236
|
+
);
|
|
237
|
+
const storage = await this.resolveNamespace(initialState.namespace);
|
|
238
|
+
const initialSnapshot = await this.readStoredCardSnapshot(
|
|
239
|
+
storage,
|
|
240
|
+
initialState.namespace,
|
|
241
|
+
initialState.principalHash,
|
|
242
|
+
);
|
|
243
|
+
const cards = this.readGrantCards(initialSnapshot, initialState);
|
|
244
|
+
const firstCard = cards[0];
|
|
245
|
+
if (!firstCard)
|
|
246
|
+
throw new SupportPassportError(
|
|
247
|
+
"grant_stale",
|
|
248
|
+
"The shared support guide has changed.",
|
|
249
|
+
410,
|
|
250
|
+
);
|
|
251
|
+
const updatedAt = cards.reduce((latest, card) => {
|
|
252
|
+
return Date.parse(card.updatedAt) > Date.parse(latest)
|
|
253
|
+
? card.updatedAt
|
|
254
|
+
: latest;
|
|
255
|
+
}, firstCard.updatedAt);
|
|
256
|
+
return await withSupportPassportOwnerLock(
|
|
257
|
+
storage,
|
|
258
|
+
{ namespace: initialState.namespace, ownerKey: initialState.ownerLockKey },
|
|
259
|
+
async (ownerLock) => {
|
|
260
|
+
return await this.grantStore.withAuthenticatedGrant(
|
|
261
|
+
input.grantId,
|
|
262
|
+
input.secret,
|
|
263
|
+
async (finalState) => {
|
|
264
|
+
if (finalState.namespace !== initialState.namespace) {
|
|
265
|
+
throw new SupportPassportError(
|
|
266
|
+
"grant_stale",
|
|
267
|
+
"The shared support guide has changed.",
|
|
268
|
+
410,
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
await requireSupportPassportOwnerLock(ownerLock);
|
|
272
|
+
const currentSnapshot = await this.readStoredCardSnapshot(
|
|
273
|
+
storage,
|
|
274
|
+
finalState.namespace,
|
|
275
|
+
finalState.principalHash,
|
|
276
|
+
);
|
|
277
|
+
const currentCards = this.readGrantCards(
|
|
278
|
+
currentSnapshot,
|
|
279
|
+
finalState,
|
|
280
|
+
);
|
|
281
|
+
await requireSupportPassportOwnerLock(ownerLock);
|
|
282
|
+
if (JSON.stringify(currentCards) !== JSON.stringify(cards)) {
|
|
283
|
+
throw new SupportPassportError(
|
|
284
|
+
"grant_stale",
|
|
285
|
+
"The shared support guide has changed.",
|
|
286
|
+
410,
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
return SupportPassportPublicGuideSchema.parse({
|
|
290
|
+
schemaVersion: 1,
|
|
291
|
+
grantId: finalState.grantId,
|
|
292
|
+
expiresAt: finalState.expiresAt,
|
|
293
|
+
updatedAt,
|
|
294
|
+
cards,
|
|
295
|
+
});
|
|
296
|
+
},
|
|
297
|
+
async () => await requireSupportPassportOwnerLock(ownerLock),
|
|
298
|
+
);
|
|
299
|
+
},
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
private readGrantCards(
|
|
304
|
+
snapshot: SupportPassportCardSnapshot,
|
|
305
|
+
state: SupportPassportGrantState,
|
|
306
|
+
) {
|
|
307
|
+
return state.cards.map((cardRef) => {
|
|
308
|
+
const stored = snapshot.cardsById.get(cardRef.cardId);
|
|
309
|
+
if (
|
|
310
|
+
!stored ||
|
|
311
|
+
stored.namespace !== state.namespace ||
|
|
312
|
+
stored.owner !== state.principalHash ||
|
|
313
|
+
stored.card.status !== "active" ||
|
|
314
|
+
stored.card.revision !== cardRef.revision ||
|
|
315
|
+
snapshot.activeReplacementPredecessors.has(cardRef.cardId)
|
|
316
|
+
) {
|
|
317
|
+
throw new SupportPassportError(
|
|
318
|
+
"grant_stale",
|
|
319
|
+
"The shared support guide has changed.",
|
|
320
|
+
410,
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
const publicCard = this.publicCard(stored.card);
|
|
324
|
+
if (!publicCard.success) {
|
|
325
|
+
throw new SupportPassportError(
|
|
326
|
+
"grant_stale",
|
|
327
|
+
"The shared support guide has changed.",
|
|
328
|
+
410,
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
return publicCard.data;
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
private async readStoredCardSnapshot(
|
|
336
|
+
storage: StorageManager,
|
|
337
|
+
namespace: string,
|
|
338
|
+
ownerKey: string,
|
|
339
|
+
): Promise<SupportPassportCardSnapshot> {
|
|
340
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
341
|
+
const markerCache = new Map<string, GeneratedBatchMarker | null>();
|
|
342
|
+
const before = this.cardSnapshotVersion(storage);
|
|
343
|
+
const cacheKey = JSON.stringify([storage.dir, namespace, ownerKey]);
|
|
344
|
+
const nowMs = this.now().getTime();
|
|
345
|
+
const cached = this.ownerCardCache.get(cacheKey);
|
|
346
|
+
let ownerCards: readonly StoredSupportPassportCard[];
|
|
347
|
+
if (cached && cached.version === before && cached.expiresAt >= nowMs) {
|
|
348
|
+
this.ownerCardCache.delete(cacheKey);
|
|
349
|
+
this.ownerCardCache.set(cacheKey, cached);
|
|
350
|
+
ownerCards = cached.cards;
|
|
351
|
+
} else {
|
|
352
|
+
this.ownerCardCache.delete(cacheKey);
|
|
353
|
+
ownerCards = this.projectOwnedCards(await storage.readAllMemories(), namespace, ownerKey);
|
|
354
|
+
}
|
|
355
|
+
const after = this.cardSnapshotVersion(storage);
|
|
356
|
+
if (before !== after) continue;
|
|
357
|
+
if (!cached || cached.version !== before || cached.expiresAt < nowMs) {
|
|
358
|
+
this.cacheOwnerCards(storage, cacheKey, after, ownerCards, nowMs);
|
|
359
|
+
}
|
|
360
|
+
const cards: StoredSupportPassportCard[] = [];
|
|
361
|
+
for (const card of ownerCards) {
|
|
362
|
+
if (await isCommittedGeneratedCard(storage, card, markerCache)) cards.push(card);
|
|
363
|
+
}
|
|
364
|
+
const snapshot = {
|
|
365
|
+
version: after,
|
|
366
|
+
cardsById: new Map(cards.map((card) => [card.card.cardId, card])),
|
|
367
|
+
activeReplacementPredecessors:
|
|
368
|
+
activeSupportPassportReplacementPredecessorIds(cards),
|
|
369
|
+
};
|
|
370
|
+
return snapshot;
|
|
371
|
+
}
|
|
372
|
+
throw new SupportPassportError("storage_conflict", "The support card list changed during review.", 409);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
private projectOwnedCards(
|
|
376
|
+
memories: MemoryFile[],
|
|
377
|
+
namespace: string,
|
|
378
|
+
ownerKey: string,
|
|
379
|
+
): StoredSupportPassportCard[] {
|
|
380
|
+
const cards = memories
|
|
381
|
+
.map((memory) => projectSupportPassportCard(memory))
|
|
382
|
+
.filter(
|
|
383
|
+
(card): card is StoredSupportPassportCard =>
|
|
384
|
+
card !== null && card.namespace === namespace && card.owner === ownerKey
|
|
385
|
+
);
|
|
386
|
+
const cardIds = new Set<string>();
|
|
387
|
+
for (const card of cards) {
|
|
388
|
+
if (cardIds.has(card.card.cardId)) {
|
|
389
|
+
throw new SupportPassportError("card_data_invalid", "Support card IDs must be unique.", 500);
|
|
390
|
+
}
|
|
391
|
+
cardIds.add(card.card.cardId);
|
|
392
|
+
}
|
|
393
|
+
return cards;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private cacheOwnerCards(
|
|
397
|
+
storage: StorageManager,
|
|
398
|
+
cacheKey: string,
|
|
399
|
+
version: string,
|
|
400
|
+
cards: readonly StoredSupportPassportCard[],
|
|
401
|
+
nowMs: number,
|
|
402
|
+
): void {
|
|
403
|
+
if (!storage.isHotCacheEnabled()) return;
|
|
404
|
+
const ttlMs = storage.hotCacheTtlMs();
|
|
405
|
+
if (!Number.isFinite(ttlMs) || ttlMs <= 0) return;
|
|
406
|
+
this.ownerCardCache.set(cacheKey, { version, cards, expiresAt: nowMs + ttlMs });
|
|
407
|
+
while (this.ownerCardCache.size > MAX_OWNER_CARD_CACHE_ENTRIES) {
|
|
408
|
+
const oldestKey = this.ownerCardCache.keys().next().value as string | undefined;
|
|
409
|
+
if (oldestKey === undefined) break;
|
|
410
|
+
this.ownerCardCache.delete(oldestKey);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
private cardSnapshotVersion(storage: StorageManager): string {
|
|
415
|
+
return `${storage.getCorpusScanVersion()}:${storage.hotCacheKeyId()}`;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
private async revokeCommittedGrant(
|
|
419
|
+
created: { state: SupportPassportGrantState; secret: string },
|
|
420
|
+
owner: SupportPassportGrantOwnerScope,
|
|
421
|
+
): Promise<void> {
|
|
422
|
+
try {
|
|
423
|
+
await this.grantStore.revoke({
|
|
424
|
+
grantId: created.state.grantId,
|
|
425
|
+
namespace: owner.namespace,
|
|
426
|
+
principal: owner.principal,
|
|
427
|
+
expectedStateVersion: created.state.stateVersion,
|
|
428
|
+
});
|
|
429
|
+
} catch {
|
|
430
|
+
throw new SupportPassportError(
|
|
431
|
+
"storage_conflict",
|
|
432
|
+
"A share link could not be stopped after owner access changed. Review the active share list.",
|
|
433
|
+
500,
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
private publicCard(card: {
|
|
439
|
+
cardId: string;
|
|
440
|
+
title: string;
|
|
441
|
+
statement: string;
|
|
442
|
+
category: string;
|
|
443
|
+
updatedAt: string;
|
|
444
|
+
}): ReturnType<typeof SupportPassportPublicCardSchema.safeParse> {
|
|
445
|
+
return SupportPassportPublicCardSchema.safeParse({
|
|
446
|
+
cardId: card.cardId,
|
|
447
|
+
title: card.title,
|
|
448
|
+
statement: card.statement,
|
|
449
|
+
category: card.category,
|
|
450
|
+
updatedAt: card.updatedAt,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
private expiryFromDuration(requestedAt: Date, durationMs: number | undefined): string {
|
|
455
|
+
if (durationMs === undefined) throw invalidInput();
|
|
456
|
+
const expiresAtMs = requestedAt.getTime() + durationMs;
|
|
457
|
+
if (!Number.isFinite(expiresAtMs)) throw invalidInput();
|
|
458
|
+
try {
|
|
459
|
+
return new Date(expiresAtMs).toISOString();
|
|
460
|
+
} catch {
|
|
461
|
+
throw invalidInput();
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
private async resolveOwnerScope(
|
|
466
|
+
principal: string,
|
|
467
|
+
): Promise<SupportPassportGrantOwnerScope> {
|
|
468
|
+
const requestedPrincipal = SupportPassportListCardsInputSchema.safeParse({
|
|
469
|
+
principal,
|
|
470
|
+
});
|
|
471
|
+
const owner = await this.resolveOwner(principal);
|
|
472
|
+
const namespace = SupportPassportNamespaceSchema.safeParse(owner.namespace);
|
|
473
|
+
const ownerPrincipal = SupportPassportListCardsInputSchema.safeParse({
|
|
474
|
+
principal: owner.principal,
|
|
475
|
+
});
|
|
476
|
+
if (
|
|
477
|
+
!requestedPrincipal.success ||
|
|
478
|
+
!namespace.success ||
|
|
479
|
+
!ownerPrincipal.success ||
|
|
480
|
+
ownerPrincipal.data.principal !== requestedPrincipal.data.principal
|
|
481
|
+
) {
|
|
482
|
+
throw new SupportPassportError(
|
|
483
|
+
"card_data_invalid",
|
|
484
|
+
"The support passport owner scope is invalid.",
|
|
485
|
+
500,
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
return {
|
|
489
|
+
...owner,
|
|
490
|
+
principal: ownerPrincipal.data.principal,
|
|
491
|
+
namespace: namespace.data,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
private ownerGrant(
|
|
496
|
+
state: SupportPassportGrantState,
|
|
497
|
+
): SupportPassportOwnerGrant {
|
|
498
|
+
const status = state.revokedAt
|
|
499
|
+
? "revoked"
|
|
500
|
+
: Date.parse(state.expiresAt) <= this.now().getTime()
|
|
501
|
+
? "expired"
|
|
502
|
+
: "active";
|
|
503
|
+
return SupportPassportOwnerGrantSchema.parse({
|
|
504
|
+
grantId: state.grantId,
|
|
505
|
+
stateVersion: state.stateVersion,
|
|
506
|
+
cards: state.cards,
|
|
507
|
+
createdAt: state.createdAt,
|
|
508
|
+
expiresAt: state.expiresAt,
|
|
509
|
+
revokedAt: state.revokedAt,
|
|
510
|
+
status,
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { test } from "node:test";
|
|
6
|
+
|
|
7
|
+
import { SupportPassportGrantStore } from "./grant-store.js";
|
|
8
|
+
|
|
9
|
+
test("commit notification failures do not orphan grants or hide revocations", async () => {
|
|
10
|
+
const root = await mkdtemp(path.join(tmpdir(), "remnic-support-grant-hook-"));
|
|
11
|
+
try {
|
|
12
|
+
const now = new Date("2026-08-11T12:00:00.000Z");
|
|
13
|
+
const store = new SupportPassportGrantStore({
|
|
14
|
+
memoryDir: root,
|
|
15
|
+
now: () => now,
|
|
16
|
+
});
|
|
17
|
+
const created = await store.create(
|
|
18
|
+
{
|
|
19
|
+
namespace: "alice",
|
|
20
|
+
principal: "owner:alice",
|
|
21
|
+
cards: [{ cardId: "card-1", revision: "a".repeat(64) }],
|
|
22
|
+
expiresAt: new Date(now.getTime() + 3_600_000).toISOString(),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
onCommitted: async () => {
|
|
26
|
+
throw new Error("simulated notification failure");
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
await new Promise<void>((resolve) => setImmediate(resolve));
|
|
31
|
+
|
|
32
|
+
assert.deepEqual(
|
|
33
|
+
(await store.listForOwner("alice", "owner:alice")).map((state) => state.grantId),
|
|
34
|
+
[created.state.grantId]
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const revoked = await store.revoke(
|
|
38
|
+
{
|
|
39
|
+
grantId: created.state.grantId,
|
|
40
|
+
namespace: "alice",
|
|
41
|
+
principal: "owner:alice",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
onCommitted: async () => {
|
|
45
|
+
throw new Error("simulated notification failure");
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
await new Promise<void>((resolve) => setImmediate(resolve));
|
|
50
|
+
|
|
51
|
+
assert.ok(revoked.revokedAt);
|
|
52
|
+
assert.equal((await store.listForOwner("alice", "owner:alice"))[0]?.revokedAt, revoked.revokedAt);
|
|
53
|
+
} finally {
|
|
54
|
+
await rm(root, { recursive: true, force: true });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("create does not notify before the owner index commits", async () => {
|
|
59
|
+
const root = await mkdtemp(path.join(tmpdir(), "remnic-support-grant-hook-order-"));
|
|
60
|
+
try {
|
|
61
|
+
const now = new Date("2026-08-11T12:00:00.000Z");
|
|
62
|
+
const store = new SupportPassportGrantStore({ memoryDir: root, now: () => now });
|
|
63
|
+
const inspected = store as unknown as {
|
|
64
|
+
writeOwnerIndex(): Promise<void>;
|
|
65
|
+
};
|
|
66
|
+
inspected.writeOwnerIndex = async () => {
|
|
67
|
+
throw new Error("simulated owner index failure");
|
|
68
|
+
};
|
|
69
|
+
let notified = false;
|
|
70
|
+
|
|
71
|
+
await assert.rejects(
|
|
72
|
+
store.create(
|
|
73
|
+
{
|
|
74
|
+
namespace: "alice",
|
|
75
|
+
principal: "owner:alice",
|
|
76
|
+
cards: [{ cardId: "card-1", revision: "a".repeat(64) }],
|
|
77
|
+
expiresAt: new Date(now.getTime() + 3_600_000).toISOString(),
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
onCommitted: () => {
|
|
81
|
+
notified = true;
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
/simulated owner index failure/
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
assert.equal(notified, false);
|
|
89
|
+
assert.deepEqual(await store.listForOwner("alice", "owner:alice"), []);
|
|
90
|
+
} finally {
|
|
91
|
+
await rm(root, { recursive: true, force: true });
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("idempotent revoke does not require another directory sync", async () => {
|
|
96
|
+
const root = await mkdtemp(path.join(tmpdir(), "remnic-support-grant-idempotent-revoke-"));
|
|
97
|
+
try {
|
|
98
|
+
const now = new Date("2026-08-11T12:00:00.000Z");
|
|
99
|
+
const store = new SupportPassportGrantStore({
|
|
100
|
+
memoryDir: root,
|
|
101
|
+
now: () => now,
|
|
102
|
+
syncDirectory: async () => {
|
|
103
|
+
throw new Error("simulated directory sync failure");
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
const created = await store.create({
|
|
107
|
+
namespace: "alice",
|
|
108
|
+
principal: "owner:alice",
|
|
109
|
+
cards: [{ cardId: "card-1", revision: "a".repeat(64) }],
|
|
110
|
+
expiresAt: new Date(now.getTime() + 3_600_000).toISOString(),
|
|
111
|
+
});
|
|
112
|
+
const input = {
|
|
113
|
+
grantId: created.state.grantId,
|
|
114
|
+
namespace: "alice",
|
|
115
|
+
principal: "owner:alice",
|
|
116
|
+
};
|
|
117
|
+
const revoked = await store.revoke(input);
|
|
118
|
+
|
|
119
|
+
assert.deepEqual(await store.revoke(input), revoked);
|
|
120
|
+
} finally {
|
|
121
|
+
await rm(root, { recursive: true, force: true });
|
|
122
|
+
}
|
|
123
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { test } from "node:test";
|
|
6
|
+
|
|
7
|
+
import type { SupportPassportGrantState } from "./grant-contracts.js";
|
|
8
|
+
import { SupportPassportGrantStore } from "./grant-store.js";
|
|
9
|
+
|
|
10
|
+
test("grant rollover stays bounded after cleanup failure and compares offset timestamps by instant", async () => {
|
|
11
|
+
const root = await mkdtemp(path.join(tmpdir(), "remnic-support-grant-order-"));
|
|
12
|
+
let nowMs = Date.parse("2026-08-11T06:00:00Z");
|
|
13
|
+
let nextGrantId = 1;
|
|
14
|
+
const store = new SupportPassportGrantStore({
|
|
15
|
+
memoryDir: root,
|
|
16
|
+
now: () => new Date(nowMs),
|
|
17
|
+
makeGrantId: () => `00000000-0000-4000-8000-${String(nextGrantId++).padStart(12, "0")}`,
|
|
18
|
+
});
|
|
19
|
+
const input = {
|
|
20
|
+
namespace: "alice",
|
|
21
|
+
principal: "owner:alice",
|
|
22
|
+
cards: [{ cardId: "card-1", revision: "a".repeat(64) }],
|
|
23
|
+
expiresAt: "2026-08-11T13:00:00Z",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const grants = [];
|
|
28
|
+
for (let index = 0; index < 100; index += 1) grants.push(await store.create(input));
|
|
29
|
+
nowMs = Date.parse("2026-08-11T11:00:00Z");
|
|
30
|
+
const older = await store.revoke({
|
|
31
|
+
grantId: grants[0]!.state.grantId,
|
|
32
|
+
namespace: input.namespace,
|
|
33
|
+
principal: input.principal,
|
|
34
|
+
});
|
|
35
|
+
const newer = await store.revoke({
|
|
36
|
+
grantId: grants[1]!.state.grantId,
|
|
37
|
+
namespace: input.namespace,
|
|
38
|
+
principal: input.principal,
|
|
39
|
+
});
|
|
40
|
+
const inspected = store as unknown as {
|
|
41
|
+
writeState(state: SupportPassportGrantState): Promise<void>;
|
|
42
|
+
removeStoredGrant(state: SupportPassportGrantState): Promise<void>;
|
|
43
|
+
};
|
|
44
|
+
await inspected.writeState({ ...older, createdAt: "2026-08-11T12:00:00+05:00" });
|
|
45
|
+
await inspected.writeState({ ...newer, createdAt: "2026-08-11T10:00:00Z" });
|
|
46
|
+
inspected.removeStoredGrant = async () => {
|
|
47
|
+
throw new Error("simulated cleanup failure");
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const replacement = await store.create(input);
|
|
51
|
+
const ids = new Set((await store.listForOwner(input.namespace, input.principal)).map((grant) => grant.grantId));
|
|
52
|
+
|
|
53
|
+
assert.equal(ids.size, 100);
|
|
54
|
+
assert.equal(ids.has(older.grantId), false);
|
|
55
|
+
assert.equal(ids.has(newer.grantId), true);
|
|
56
|
+
assert.equal(ids.has(replacement.state.grantId), true);
|
|
57
|
+
} finally {
|
|
58
|
+
await rm(root, { recursive: true, force: true });
|
|
59
|
+
}
|
|
60
|
+
});
|