@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,348 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { lstat } from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
import type { OfflineSyncExcludeFile } from "../offline-sync-file-io.js";
|
|
5
|
+
import { stripAttributesSuffix } from "../structured-attributes.js";
|
|
6
|
+
import type { MemoryFile } from "../types.js";
|
|
7
|
+
import {
|
|
8
|
+
type SupportPassportCard,
|
|
9
|
+
SupportPassportCardCategorySchema,
|
|
10
|
+
SupportPassportCardSchema,
|
|
11
|
+
SupportPassportCardStatusSchema,
|
|
12
|
+
SupportPassportMemoryIdSchema,
|
|
13
|
+
SupportPassportNamespaceSchema,
|
|
14
|
+
SupportPassportSourceMemoryIdSchema,
|
|
15
|
+
computeSupportPassportCardRevision,
|
|
16
|
+
} from "./contracts.js";
|
|
17
|
+
|
|
18
|
+
export const SUPPORT_PASSPORT_CARD_TAG = "support-passport-card";
|
|
19
|
+
export const SUPPORT_PASSPORT_AUDIT_TAG = "support-passport-audit";
|
|
20
|
+
|
|
21
|
+
export function isSupportPassportPrivateMemory(memory: {
|
|
22
|
+
frontmatter: {
|
|
23
|
+
tags?: readonly string[];
|
|
24
|
+
structuredAttributes?: Readonly<Record<string, string>>;
|
|
25
|
+
};
|
|
26
|
+
}): boolean {
|
|
27
|
+
const tags = memory.frontmatter.tags;
|
|
28
|
+
if (tags?.includes(SUPPORT_PASSPORT_CARD_TAG) === true || tags?.includes(SUPPORT_PASSPORT_AUDIT_TAG) === true) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return Object.keys(memory.frontmatter.structuredAttributes ?? {})
|
|
32
|
+
.some((key) => key.startsWith("support-passport-"));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function excludeSupportPassportPrivateMemories<T extends Pick<MemoryFile, "frontmatter">>(
|
|
36
|
+
memories: readonly T[]
|
|
37
|
+
): T[] {
|
|
38
|
+
return memories.filter((memory) => !isSupportPassportPrivateMemory(memory));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function createSupportPassportPrivateFileExclusion(storage: {
|
|
42
|
+
readMemoryByPath(filePath: string): Promise<MemoryFile | null>;
|
|
43
|
+
}): OfflineSyncExcludeFile {
|
|
44
|
+
const classifications = new Map<string, { identity: string; excluded: Promise<boolean> }>();
|
|
45
|
+
return async ({ filePath }) => {
|
|
46
|
+
let file: Awaited<ReturnType<typeof lstat>>;
|
|
47
|
+
try {
|
|
48
|
+
file = await lstat(filePath);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") {
|
|
51
|
+
classifications.delete(filePath);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
const identity = `${file.dev}:${file.ino}:${file.size}:${file.mtimeMs}:${file.ctimeMs}`;
|
|
57
|
+
const cached = classifications.get(filePath);
|
|
58
|
+
if (cached?.identity === identity) return await cached.excluded;
|
|
59
|
+
const excluded = storage
|
|
60
|
+
.readMemoryByPath(filePath)
|
|
61
|
+
.then((memory) => (memory ? isSupportPassportPrivateMemory(memory) : false));
|
|
62
|
+
classifications.set(filePath, { identity, excluded });
|
|
63
|
+
try {
|
|
64
|
+
return await excluded;
|
|
65
|
+
} catch (error) {
|
|
66
|
+
if (classifications.get(filePath)?.excluded === excluded) classifications.delete(filePath);
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const SUPPORT_PASSPORT_ATTRIBUTE_KEYS = Object.freeze({
|
|
73
|
+
namespace: "support-passport-namespace",
|
|
74
|
+
namespaceEncoding: "support-passport-namespace-encoding",
|
|
75
|
+
owner: "support-passport-owner",
|
|
76
|
+
title: "support-passport-title",
|
|
77
|
+
category: "support-passport-category",
|
|
78
|
+
order: "support-passport-order",
|
|
79
|
+
reviewBy: "support-passport-review-by",
|
|
80
|
+
sourceMemoryIds: "support-passport-source-ids",
|
|
81
|
+
replacesDraftId: "support-passport-replaces-draft-id",
|
|
82
|
+
replacedRevision: "support-passport-replaced-revision",
|
|
83
|
+
draftReplacementPrepared: "support-passport-draft-replacement-prepared",
|
|
84
|
+
replacementComplete: "support-passport-replacement-complete",
|
|
85
|
+
generatedBatchId: "support-passport-generated-batch-id",
|
|
86
|
+
generatedBatchSize: "support-passport-generated-batch-size",
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const SUPPORT_PASSPORT_NAMESPACE_ENCODING = "base64url-v1";
|
|
90
|
+
const SUPPORT_PASSPORT_NAMESPACE_CHUNK_PREFIX = "support-passport-namespace-";
|
|
91
|
+
const SUPPORT_PASSPORT_NAMESPACE_CHUNK_SIZE = 1_024;
|
|
92
|
+
const LegacySupportPassportNamespaceSchema = SupportPassportNamespaceSchema.refine(
|
|
93
|
+
(namespace) =>
|
|
94
|
+
!namespace.includes("/") &&
|
|
95
|
+
!namespace.includes("\\") &&
|
|
96
|
+
!namespace.includes("..") &&
|
|
97
|
+
!namespace.includes("]") &&
|
|
98
|
+
!namespace.includes("\0") &&
|
|
99
|
+
!namespace.includes("\n") &&
|
|
100
|
+
!namespace.includes("\r")
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
export function encodeSupportPassportNamespaceAttributes(namespace: string): Record<string, string> {
|
|
104
|
+
const canonical = SupportPassportNamespaceSchema.parse(namespace);
|
|
105
|
+
const encoded = Buffer.from(canonical, "utf8").toString("base64url");
|
|
106
|
+
const chunks = encoded.match(new RegExp(`.{1,${SUPPORT_PASSPORT_NAMESPACE_CHUNK_SIZE}}`, "g")) ?? [];
|
|
107
|
+
const digest = createHash("sha256").update(encoded).digest("hex");
|
|
108
|
+
return Object.fromEntries([
|
|
109
|
+
[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.namespace, chunks[0] ?? ""],
|
|
110
|
+
[
|
|
111
|
+
SUPPORT_PASSPORT_ATTRIBUTE_KEYS.namespaceEncoding,
|
|
112
|
+
`${SUPPORT_PASSPORT_NAMESPACE_ENCODING}:${chunks.length}:${digest}`,
|
|
113
|
+
],
|
|
114
|
+
...chunks.slice(1).map((chunk, index) => [`${SUPPORT_PASSPORT_NAMESPACE_CHUNK_PREFIX}${index + 1}`, chunk]),
|
|
115
|
+
]);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function decodeSupportPassportNamespaceAttributes(attributes: Readonly<Record<string, string>>): string | null {
|
|
119
|
+
const firstChunk = attributes[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.namespace];
|
|
120
|
+
const encoding = attributes[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.namespaceEncoding];
|
|
121
|
+
if (encoding === undefined) {
|
|
122
|
+
const legacy = LegacySupportPassportNamespaceSchema.safeParse(firstChunk);
|
|
123
|
+
return legacy.success ? legacy.data : null;
|
|
124
|
+
}
|
|
125
|
+
const match = /^base64url-v1:([1-9]\d*):([a-f0-9]{64})$/.exec(encoding);
|
|
126
|
+
if (!match || typeof firstChunk !== "string") return null;
|
|
127
|
+
const chunkCount = Number(match[1]);
|
|
128
|
+
if (!Number.isSafeInteger(chunkCount)) return null;
|
|
129
|
+
const chunkIndexes = Object.keys(attributes).flatMap((key) => {
|
|
130
|
+
const chunkMatch = /^support-passport-namespace-(\d+)$/.exec(key);
|
|
131
|
+
return chunkMatch ? [Number(chunkMatch[1])] : [];
|
|
132
|
+
});
|
|
133
|
+
if (
|
|
134
|
+
chunkIndexes.length !== chunkCount - 1 ||
|
|
135
|
+
chunkIndexes.some((index) => !Number.isSafeInteger(index) || index < 1 || index >= chunkCount)
|
|
136
|
+
)
|
|
137
|
+
return null;
|
|
138
|
+
const chunks = [firstChunk];
|
|
139
|
+
for (let index = 1; index < chunkCount; index += 1) {
|
|
140
|
+
const chunk = attributes[`${SUPPORT_PASSPORT_NAMESPACE_CHUNK_PREFIX}${index}`];
|
|
141
|
+
if (typeof chunk !== "string" || chunk.length === 0) return null;
|
|
142
|
+
chunks.push(chunk);
|
|
143
|
+
}
|
|
144
|
+
const encoded = chunks.join("");
|
|
145
|
+
if (createHash("sha256").update(encoded).digest("hex") !== match[2]) return null;
|
|
146
|
+
const decoded = Buffer.from(encoded, "base64url").toString("utf8");
|
|
147
|
+
if (Buffer.from(decoded, "utf8").toString("base64url") !== encoded) return null;
|
|
148
|
+
const namespace = SupportPassportNamespaceSchema.safeParse(decoded);
|
|
149
|
+
return namespace.success ? namespace.data : null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface StoredSupportPassportCard {
|
|
153
|
+
card: SupportPassportCard;
|
|
154
|
+
memory: MemoryFile;
|
|
155
|
+
order: number;
|
|
156
|
+
sourceMemoryIds: string[];
|
|
157
|
+
namespace: string;
|
|
158
|
+
owner: string;
|
|
159
|
+
replacesDraftId?: string;
|
|
160
|
+
replacedRevision?: string;
|
|
161
|
+
draftReplacementPrepared: boolean;
|
|
162
|
+
generatedBatchId?: string;
|
|
163
|
+
generatedBatchSize?: number;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function computeSupportPassportOwnerKey(principal: string): string {
|
|
167
|
+
return createHash("sha256").update(principal).digest("hex");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function activeSupportPassportReplacementPredecessorIds(
|
|
171
|
+
cards: readonly StoredSupportPassportCard[],
|
|
172
|
+
): Set<string> {
|
|
173
|
+
return new Set(
|
|
174
|
+
cards
|
|
175
|
+
.filter((item) => item.card.status === "active")
|
|
176
|
+
.map((item) => item.memory.frontmatter.supersedes)
|
|
177
|
+
.filter((cardId): cardId is string => typeof cardId === "string"),
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function parseSourceMemoryIds(frontmatter: MemoryFile["frontmatter"]): string[] | null {
|
|
182
|
+
const lineage = frontmatter.lineage;
|
|
183
|
+
const legacyValue = frontmatter.structuredAttributes?.[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.sourceMemoryIds];
|
|
184
|
+
const rawIds = lineage ?? (legacyValue === undefined || legacyValue === "" ? [] : legacyValue.split(","));
|
|
185
|
+
if (rawIds.length > 5) return null;
|
|
186
|
+
const normalized: string[] = [];
|
|
187
|
+
for (const rawId of rawIds) {
|
|
188
|
+
const parsed = SupportPassportSourceMemoryIdSchema.safeParse(rawId);
|
|
189
|
+
if (!parsed.success) return null;
|
|
190
|
+
normalized.push(parsed.data);
|
|
191
|
+
}
|
|
192
|
+
if (new Set(normalized).size !== normalized.length) return null;
|
|
193
|
+
return normalized;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
interface SupportPassportCardMetadata {
|
|
197
|
+
fields: Omit<SupportPassportCard, "revision" | "statement">;
|
|
198
|
+
order: number;
|
|
199
|
+
sourceMemoryIds: string[];
|
|
200
|
+
namespace: string;
|
|
201
|
+
owner: string;
|
|
202
|
+
replacesDraftId?: string;
|
|
203
|
+
replacedRevision?: string;
|
|
204
|
+
draftReplacementPrepared: boolean;
|
|
205
|
+
generatedBatchId?: string;
|
|
206
|
+
generatedBatchSize?: number;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function parseSupportPassportCardMetadata(
|
|
210
|
+
memory: Pick<MemoryFile, "frontmatter">,
|
|
211
|
+
): SupportPassportCardMetadata | null {
|
|
212
|
+
const frontmatter = memory.frontmatter;
|
|
213
|
+
const attributes = frontmatter.structuredAttributes;
|
|
214
|
+
if (frontmatter.category !== "preference") return null;
|
|
215
|
+
if (!frontmatter.tags?.includes(SUPPORT_PASSPORT_CARD_TAG)) return null;
|
|
216
|
+
if (
|
|
217
|
+
!attributes ||
|
|
218
|
+
frontmatter.blockedBy ||
|
|
219
|
+
frontmatter.archivedAt ||
|
|
220
|
+
frontmatter.supersededBy
|
|
221
|
+
)
|
|
222
|
+
return null;
|
|
223
|
+
|
|
224
|
+
const category = SupportPassportCardCategorySchema.safeParse(
|
|
225
|
+
attributes[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.category],
|
|
226
|
+
);
|
|
227
|
+
const status = SupportPassportCardStatusSchema.safeParse(frontmatter.status);
|
|
228
|
+
const rawOrder = attributes[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.order];
|
|
229
|
+
const order = Number(rawOrder);
|
|
230
|
+
const sourceMemoryIds = parseSourceMemoryIds(frontmatter);
|
|
231
|
+
const namespace = decodeSupportPassportNamespaceAttributes(attributes);
|
|
232
|
+
const owner = attributes[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.owner];
|
|
233
|
+
let replacesDraftId: string | undefined;
|
|
234
|
+
const rawReplacesDraftId =
|
|
235
|
+
attributes[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.replacesDraftId];
|
|
236
|
+
if (rawReplacesDraftId !== undefined) {
|
|
237
|
+
const parsedReplacesDraftId =
|
|
238
|
+
SupportPassportMemoryIdSchema.safeParse(rawReplacesDraftId);
|
|
239
|
+
if (!parsedReplacesDraftId.success) return null;
|
|
240
|
+
replacesDraftId = parsedReplacesDraftId.data;
|
|
241
|
+
}
|
|
242
|
+
let replacedRevision: string | undefined;
|
|
243
|
+
const rawReplacedRevision =
|
|
244
|
+
attributes[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.replacedRevision];
|
|
245
|
+
if (rawReplacedRevision !== undefined) {
|
|
246
|
+
if (!/^[a-f0-9]{64}$/.test(rawReplacedRevision)) return null;
|
|
247
|
+
replacedRevision = rawReplacedRevision;
|
|
248
|
+
}
|
|
249
|
+
const generatedBatchId = attributes[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.generatedBatchId];
|
|
250
|
+
const rawGeneratedBatchSize = attributes[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.generatedBatchSize];
|
|
251
|
+
let generatedBatchSize: number | undefined;
|
|
252
|
+
if (generatedBatchId !== undefined) {
|
|
253
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(generatedBatchId)) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
if (
|
|
257
|
+
typeof rawGeneratedBatchSize !== "string" ||
|
|
258
|
+
!/^[1-8]$/.test(rawGeneratedBatchSize)
|
|
259
|
+
) {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
generatedBatchSize = Number(rawGeneratedBatchSize);
|
|
263
|
+
} else if (rawGeneratedBatchSize !== undefined) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
if (
|
|
267
|
+
!category.success ||
|
|
268
|
+
!status.success ||
|
|
269
|
+
status.data === "superseded" ||
|
|
270
|
+
typeof rawOrder !== "string" ||
|
|
271
|
+
!/^(?:0|[1-9]\d*)$/.test(rawOrder) ||
|
|
272
|
+
!Number.isSafeInteger(order) ||
|
|
273
|
+
namespace === null ||
|
|
274
|
+
typeof owner !== "string" ||
|
|
275
|
+
!/^[a-f0-9]{64}$/.test(owner) ||
|
|
276
|
+
!sourceMemoryIds
|
|
277
|
+
)
|
|
278
|
+
return null;
|
|
279
|
+
const fields = SupportPassportCardSchema.omit({
|
|
280
|
+
revision: true,
|
|
281
|
+
statement: true,
|
|
282
|
+
}).safeParse({
|
|
283
|
+
cardId: frontmatter.id,
|
|
284
|
+
title: attributes[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.title],
|
|
285
|
+
category: category.data,
|
|
286
|
+
status: status.data,
|
|
287
|
+
updatedAt: frontmatter.updated,
|
|
288
|
+
reviewBy: attributes[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.reviewBy],
|
|
289
|
+
});
|
|
290
|
+
if (!fields.success) return null;
|
|
291
|
+
return {
|
|
292
|
+
fields: fields.data,
|
|
293
|
+
order,
|
|
294
|
+
sourceMemoryIds,
|
|
295
|
+
namespace,
|
|
296
|
+
owner,
|
|
297
|
+
replacesDraftId,
|
|
298
|
+
replacedRevision,
|
|
299
|
+
draftReplacementPrepared:
|
|
300
|
+
attributes[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.draftReplacementPrepared] ===
|
|
301
|
+
"true",
|
|
302
|
+
generatedBatchId,
|
|
303
|
+
generatedBatchSize,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export function hasLiveSupportPassportCard(memory: Pick<MemoryFile, "frontmatter" | "content">): boolean {
|
|
308
|
+
const metadata = parseSupportPassportCardMetadata(memory);
|
|
309
|
+
if (metadata?.fields.status !== "active" && metadata?.fields.status !== "pending_review") return false;
|
|
310
|
+
return SupportPassportCardSchema.omit({ revision: true }).safeParse({
|
|
311
|
+
...metadata.fields,
|
|
312
|
+
statement: stripAttributesSuffix(memory.content),
|
|
313
|
+
}).success;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export function projectSupportPassportCard(
|
|
317
|
+
memory: MemoryFile,
|
|
318
|
+
): StoredSupportPassportCard | null {
|
|
319
|
+
const metadata = parseSupportPassportCardMetadata(memory);
|
|
320
|
+
if (!metadata) return null;
|
|
321
|
+
|
|
322
|
+
const fields = {
|
|
323
|
+
...metadata.fields,
|
|
324
|
+
statement: stripAttributesSuffix(memory.content),
|
|
325
|
+
};
|
|
326
|
+
const normalized = SupportPassportCardSchema.omit({
|
|
327
|
+
revision: true,
|
|
328
|
+
}).safeParse(fields);
|
|
329
|
+
if (!normalized.success) return null;
|
|
330
|
+
const parsed = SupportPassportCardSchema.safeParse({
|
|
331
|
+
...normalized.data,
|
|
332
|
+
revision: computeSupportPassportCardRevision(normalized.data),
|
|
333
|
+
});
|
|
334
|
+
if (!parsed.success) return null;
|
|
335
|
+
return {
|
|
336
|
+
card: parsed.data,
|
|
337
|
+
memory,
|
|
338
|
+
order: metadata.order,
|
|
339
|
+
sourceMemoryIds: metadata.sourceMemoryIds,
|
|
340
|
+
namespace: metadata.namespace,
|
|
341
|
+
owner: metadata.owner,
|
|
342
|
+
replacesDraftId: metadata.replacesDraftId,
|
|
343
|
+
replacedRevision: metadata.replacedRevision,
|
|
344
|
+
draftReplacementPrepared: metadata.draftReplacementPrepared,
|
|
345
|
+
generatedBatchId: metadata.generatedBatchId,
|
|
346
|
+
generatedBatchSize: metadata.generatedBatchSize,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { StorageManager } from "../index.js";
|
|
2
|
+
import { log } from "../logger.js";
|
|
3
|
+
import { stripAttributesSuffix } from "../structured-attributes.js";
|
|
4
|
+
import {
|
|
5
|
+
SUPPORT_PASSPORT_ATTRIBUTE_KEYS,
|
|
6
|
+
type StoredSupportPassportCard,
|
|
7
|
+
computeSupportPassportOwnerKey,
|
|
8
|
+
encodeSupportPassportNamespaceAttributes,
|
|
9
|
+
projectSupportPassportCard,
|
|
10
|
+
} from "./card-projection.js";
|
|
11
|
+
import { ownsMemory } from "./card-state.js";
|
|
12
|
+
import { SupportPassportError } from "./errors.js";
|
|
13
|
+
|
|
14
|
+
export async function validateSupportPassportReplacementPrior(
|
|
15
|
+
storage: StorageManager,
|
|
16
|
+
replacement: StoredSupportPassportCard,
|
|
17
|
+
namespace: string,
|
|
18
|
+
principal: string
|
|
19
|
+
): Promise<void> {
|
|
20
|
+
const priorId = replacement.memory.frontmatter.supersedes;
|
|
21
|
+
if (!priorId) return;
|
|
22
|
+
const priorMemory = await storage.getMemoryById(priorId);
|
|
23
|
+
const priorIsOwned = priorMemory ? ownsMemory(priorMemory, namespace, principal) : false;
|
|
24
|
+
const alreadyRetired =
|
|
25
|
+
priorIsOwned &&
|
|
26
|
+
priorMemory?.frontmatter.status === "superseded" &&
|
|
27
|
+
priorMemory.frontmatter.supersededBy === replacement.card.cardId;
|
|
28
|
+
const prior = priorMemory && priorIsOwned && !alreadyRetired ? projectSupportPassportCard(priorMemory) : null;
|
|
29
|
+
if (prior?.card.status === "rejected" || alreadyRetired) return;
|
|
30
|
+
if (!priorMemory || prior?.card.status !== "active") {
|
|
31
|
+
throw new SupportPassportError("storage_conflict", "The prior support card changed before replacement.", 409);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function prepareSupportPassportReplacementPrior(input: {
|
|
36
|
+
storage: StorageManager;
|
|
37
|
+
replacement: StoredSupportPassportCard;
|
|
38
|
+
principal: string;
|
|
39
|
+
namespace: string;
|
|
40
|
+
now: () => Date;
|
|
41
|
+
requireOwnerLock: () => Promise<void>;
|
|
42
|
+
onCommitted?: () => void;
|
|
43
|
+
}): Promise<string | null> {
|
|
44
|
+
const { storage, replacement, principal, namespace } = input;
|
|
45
|
+
const priorId = replacement.memory.frontmatter.supersedes;
|
|
46
|
+
if (!priorId) return null;
|
|
47
|
+
const priorMemory = await storage.getMemoryById(priorId);
|
|
48
|
+
const priorIsOwned = priorMemory ? ownsMemory(priorMemory, namespace, principal) : false;
|
|
49
|
+
const alreadyRetired =
|
|
50
|
+
priorIsOwned &&
|
|
51
|
+
priorMemory?.frontmatter.status === "superseded" &&
|
|
52
|
+
priorMemory.frontmatter.supersededBy === replacement.card.cardId;
|
|
53
|
+
const prior = priorMemory && priorIsOwned && !alreadyRetired ? projectSupportPassportCard(priorMemory) : null;
|
|
54
|
+
if (prior?.card.status === "rejected") return null;
|
|
55
|
+
if (!priorMemory || (!alreadyRetired && prior?.card.status !== "active")) {
|
|
56
|
+
throw new SupportPassportError("storage_conflict", "The prior support card changed before replacement.", 409);
|
|
57
|
+
}
|
|
58
|
+
if (alreadyRetired) return priorId;
|
|
59
|
+
const retiredAt = input.now().toISOString();
|
|
60
|
+
await input.requireOwnerLock();
|
|
61
|
+
const retired = await storage.writeMemoryFrontmatterIfUnchanged(
|
|
62
|
+
priorMemory,
|
|
63
|
+
{
|
|
64
|
+
status: "superseded",
|
|
65
|
+
supersededBy: replacement.card.cardId,
|
|
66
|
+
supersededAt: retiredAt,
|
|
67
|
+
supersessionCause: "direct",
|
|
68
|
+
updated: retiredAt,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
actor: principal,
|
|
72
|
+
reasonCode: "support-passport-replacement-pending",
|
|
73
|
+
relatedMemoryIds: [replacement.card.cardId],
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
if (!retired) {
|
|
77
|
+
throw new SupportPassportError("storage_conflict", "The prior support card changed before replacement.", 409);
|
|
78
|
+
}
|
|
79
|
+
input.onCommitted?.();
|
|
80
|
+
return priorId;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export async function completeSupportPassportReplacementPrior(input: {
|
|
84
|
+
storage: StorageManager;
|
|
85
|
+
priorId: string;
|
|
86
|
+
replacement: StoredSupportPassportCard;
|
|
87
|
+
principal: string;
|
|
88
|
+
namespace: string;
|
|
89
|
+
requireOwnerLock: () => Promise<void>;
|
|
90
|
+
}): Promise<boolean> {
|
|
91
|
+
const { storage, priorId, replacement, principal, namespace } = input;
|
|
92
|
+
const replacementId = replacement.card.cardId;
|
|
93
|
+
const prior = await storage.getMemoryById(priorId);
|
|
94
|
+
if (
|
|
95
|
+
!prior ||
|
|
96
|
+
!ownsMemory(prior, namespace, principal) ||
|
|
97
|
+
prior.frontmatter.status !== "superseded" ||
|
|
98
|
+
prior.frontmatter.supersededBy !== replacementId
|
|
99
|
+
) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
await input.requireOwnerLock();
|
|
103
|
+
const completed = await storage.supersedeMemory(
|
|
104
|
+
priorId,
|
|
105
|
+
replacementId,
|
|
106
|
+
"support-passport-replacement",
|
|
107
|
+
{ supersessionCause: "direct" },
|
|
108
|
+
{
|
|
109
|
+
actor: principal,
|
|
110
|
+
requireActive: true,
|
|
111
|
+
acceptExactReplay: true,
|
|
112
|
+
expectedSnapshot: prior,
|
|
113
|
+
audit: {
|
|
114
|
+
content: stripAttributesSuffix(prior.content),
|
|
115
|
+
tags: ["supersession", "auto-resolved", "support-passport-audit"],
|
|
116
|
+
structuredAttributes: {
|
|
117
|
+
...encodeSupportPassportNamespaceAttributes(namespace),
|
|
118
|
+
[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.owner]: computeSupportPassportOwnerKey(principal),
|
|
119
|
+
},
|
|
120
|
+
source: "support-passport",
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
if (!completed) log.warn("support passport could not complete replacement retirement side effects");
|
|
125
|
+
return completed;
|
|
126
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import type { StorageManager } from "../index.js";
|
|
5
|
+
import type { MemoryFile } from "../types.js";
|
|
6
|
+
import type { HeldFileLockController } from "../utils/serialize-mutations.js";
|
|
7
|
+
import {
|
|
8
|
+
SUPPORT_PASSPORT_ATTRIBUTE_KEYS,
|
|
9
|
+
SUPPORT_PASSPORT_CARD_TAG,
|
|
10
|
+
type StoredSupportPassportCard,
|
|
11
|
+
computeSupportPassportOwnerKey,
|
|
12
|
+
projectSupportPassportCard,
|
|
13
|
+
} from "./card-projection.js";
|
|
14
|
+
import type { SupportPassportCard } from "./contracts.js";
|
|
15
|
+
import { SupportPassportCardService } from "./card-service.js";
|
|
16
|
+
|
|
17
|
+
const PRINCIPAL = "owner:alice";
|
|
18
|
+
const NAMESPACE = "alice";
|
|
19
|
+
|
|
20
|
+
function memory(id: string, status: "pending_review" | "rejected", replacesDraftId?: string): MemoryFile {
|
|
21
|
+
return {
|
|
22
|
+
path: `/memory/preferences/${id}.md`,
|
|
23
|
+
content: "Offer me a quiet place and time.",
|
|
24
|
+
frontmatter: {
|
|
25
|
+
id,
|
|
26
|
+
category: "preference",
|
|
27
|
+
source: "support-passport",
|
|
28
|
+
confidence: 1,
|
|
29
|
+
confidenceTier: "explicit",
|
|
30
|
+
created: "2026-08-11T12:00:00.000Z",
|
|
31
|
+
updated: "2026-08-11T12:00:00.000Z",
|
|
32
|
+
status,
|
|
33
|
+
tags: [SUPPORT_PASSPORT_CARD_TAG],
|
|
34
|
+
structuredAttributes: {
|
|
35
|
+
[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.namespace]: NAMESPACE,
|
|
36
|
+
[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.owner]: computeSupportPassportOwnerKey(PRINCIPAL),
|
|
37
|
+
[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.title]: "Quiet space",
|
|
38
|
+
[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.category]: "environment",
|
|
39
|
+
[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.order]: "0",
|
|
40
|
+
[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.reviewBy]: "2026-09-01T12:00:00.000Z",
|
|
41
|
+
[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.sourceMemoryIds]: "",
|
|
42
|
+
...(replacesDraftId
|
|
43
|
+
? {
|
|
44
|
+
[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.replacesDraftId]: replacesDraftId,
|
|
45
|
+
[SUPPORT_PASSPORT_ATTRIBUTE_KEYS.draftReplacementPrepared]: "true",
|
|
46
|
+
}
|
|
47
|
+
: {}),
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
} as MemoryFile;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
test("rejected-draft recovery forwards the commit notification", async () => {
|
|
54
|
+
const replaced = memory("draft-one", "rejected");
|
|
55
|
+
const replacement = projectSupportPassportCard(memory("draft-two", "pending_review", "draft-one"));
|
|
56
|
+
assert.ok(replacement);
|
|
57
|
+
const storage = {
|
|
58
|
+
getMemoryById: async (id: string) => (id === "draft-one" ? replaced : null),
|
|
59
|
+
} as unknown as StorageManager;
|
|
60
|
+
const service = new SupportPassportCardService({
|
|
61
|
+
resolveOwner: async () => ({ principal: PRINCIPAL, namespace: NAMESPACE, storage }),
|
|
62
|
+
});
|
|
63
|
+
let commitNotifications = 0;
|
|
64
|
+
const inspected = service as unknown as {
|
|
65
|
+
recoverReplacedDraft(
|
|
66
|
+
target: StorageManager,
|
|
67
|
+
card: StoredSupportPassportCard,
|
|
68
|
+
lock: HeldFileLockController,
|
|
69
|
+
principal: string,
|
|
70
|
+
namespace: string,
|
|
71
|
+
onCommitted?: () => void
|
|
72
|
+
): Promise<void>;
|
|
73
|
+
finishPreparedDraftReplacement(
|
|
74
|
+
target: StorageManager,
|
|
75
|
+
replacementId: string,
|
|
76
|
+
lock: HeldFileLockController,
|
|
77
|
+
principal: string,
|
|
78
|
+
namespace: string,
|
|
79
|
+
onCommitted?: () => void
|
|
80
|
+
): Promise<SupportPassportCard>;
|
|
81
|
+
};
|
|
82
|
+
inspected.finishPreparedDraftReplacement = async (
|
|
83
|
+
_target,
|
|
84
|
+
_replacementId,
|
|
85
|
+
_lock,
|
|
86
|
+
_principal,
|
|
87
|
+
_namespace,
|
|
88
|
+
onCommitted
|
|
89
|
+
) => {
|
|
90
|
+
onCommitted?.();
|
|
91
|
+
return replacement.card;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
await inspected.recoverReplacedDraft(
|
|
95
|
+
storage,
|
|
96
|
+
replacement,
|
|
97
|
+
{} as HeldFileLockController,
|
|
98
|
+
PRINCIPAL,
|
|
99
|
+
NAMESPACE,
|
|
100
|
+
() => {
|
|
101
|
+
commitNotifications += 1;
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
assert.equal(commitNotifications, 1);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test("pre-write card recovery forwards the commit notification", async () => {
|
|
109
|
+
const replacementMemory = memory("draft-two", "pending_review", "draft-one");
|
|
110
|
+
const storage = {
|
|
111
|
+
getCorpusScanVersion: () => "1:0",
|
|
112
|
+
readAllMemories: async () => [replacementMemory],
|
|
113
|
+
} as unknown as StorageManager;
|
|
114
|
+
const service = new SupportPassportCardService({
|
|
115
|
+
resolveOwner: async () => ({ principal: PRINCIPAL, namespace: NAMESPACE, storage }),
|
|
116
|
+
});
|
|
117
|
+
let commitNotifications = 0;
|
|
118
|
+
const inspected = service as unknown as {
|
|
119
|
+
readStoredCards(
|
|
120
|
+
target: StorageManager,
|
|
121
|
+
lock: HeldFileLockController,
|
|
122
|
+
principal: string,
|
|
123
|
+
namespace: string,
|
|
124
|
+
onCommitted?: () => void
|
|
125
|
+
): Promise<StoredSupportPassportCard[]>;
|
|
126
|
+
recoverReplacementTransition(
|
|
127
|
+
target: StorageManager,
|
|
128
|
+
candidate: MemoryFile,
|
|
129
|
+
lock: HeldFileLockController,
|
|
130
|
+
principal: string,
|
|
131
|
+
namespace: string,
|
|
132
|
+
options?: { rollbackConflictedApproval?: boolean },
|
|
133
|
+
onCommitted?: () => void
|
|
134
|
+
): Promise<MemoryFile>;
|
|
135
|
+
};
|
|
136
|
+
inspected.recoverReplacementTransition = async (
|
|
137
|
+
_target,
|
|
138
|
+
candidate,
|
|
139
|
+
_lock,
|
|
140
|
+
_principal,
|
|
141
|
+
_namespace,
|
|
142
|
+
_options,
|
|
143
|
+
onCommitted
|
|
144
|
+
) => {
|
|
145
|
+
onCommitted?.();
|
|
146
|
+
return candidate;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
await inspected.readStoredCards(
|
|
150
|
+
storage,
|
|
151
|
+
{} as HeldFileLockController,
|
|
152
|
+
PRINCIPAL,
|
|
153
|
+
NAMESPACE,
|
|
154
|
+
() => {
|
|
155
|
+
commitNotifications += 1;
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
assert.equal(commitNotifications, 1);
|
|
160
|
+
});
|