@remnic/core 10.0.168 → 10.0.170
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.js +181 -179
- package/dist/access-cli.js +181 -179
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.js +11 -11
- package/dist/access-extraction-force-flush-preempt.js +181 -179
- package/dist/access-extraction-force-flush.js +181 -179
- package/dist/access-http-briefing.js +181 -179
- package/dist/access-http-query.js +181 -179
- package/dist/access-http.js +181 -179
- package/dist/access-identity-continuity-surface.js +181 -179
- package/dist/access-lcm-surface.js +181 -179
- package/dist/access-mcp.js +181 -179
- package/dist/access-observe-write-category.js +11 -11
- package/dist/access-observe-write-surface.js +181 -179
- package/dist/access-offline-manifest.js +9 -9
- package/dist/access-operations-batch.js +181 -179
- package/dist/access-operations.js +181 -179
- package/dist/access-recall-concurrency.js +181 -179
- package/dist/access-recall-diagnostics.js +2 -2
- package/dist/access-recall-excerpt-attribution.d.ts +19 -0
- package/dist/access-recall-excerpt-attribution.d.ts.map +1 -0
- package/dist/access-recall-excerpt-attribution.js +8 -0
- package/dist/access-recall-response.js +181 -179
- package/dist/access-recall-surface.d.ts.map +1 -1
- package/dist/access-recall-surface.js +181 -179
- package/dist/access-schema.js +10 -10
- package/dist/access-service.js +181 -179
- package/dist/active-recall.js +30 -29
- package/dist/active-recall.js.map +1 -1
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/registry.js +3 -3
- package/dist/{auto-sync-L3M4RKJD.js → auto-sync-ACP5U5A3.js} +3 -3
- package/dist/behavior-learner.js +1 -1
- package/dist/binary-lifecycle/scanner.d.ts +2 -4
- package/dist/binary-lifecycle/scanner.d.ts.map +1 -1
- package/dist/briefing.js +19 -19
- package/dist/buffer-add-turns-bounded.d.ts +11 -1
- package/dist/buffer-add-turns-bounded.d.ts.map +1 -1
- package/dist/buffer-add-turns-bounded.js +3 -3
- package/dist/buffer-session-cap.d.ts +2 -2
- package/dist/buffer-session-cap.d.ts.map +1 -1
- package/dist/buffer-session-cap.js +1 -1
- package/dist/buffer.d.ts +3 -2
- package/dist/buffer.d.ts.map +1 -1
- package/dist/buffer.js +13 -13
- package/dist/calibration.d.ts +19 -2
- package/dist/calibration.d.ts.map +1 -1
- package/dist/calibration.js +28 -5
- package/dist/calibration.js.map +1 -1
- package/dist/{capsule-crypto-GWVG7LGC.js → capsule-crypto-7FJQINUR.js} +2 -2
- package/dist/{capsule-merge-VHBRF65A.js → capsule-merge-BADOICNP.js} +2 -2
- package/dist/causal-behavior.js +2 -2
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.js +23 -23
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.js +3 -3
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-OWHERGF2.js → chunk-2NLLXCJG.js} +2 -2
- package/dist/{chunk-CKELO7Q6.js → chunk-2OAFPBQB.js} +2 -2
- package/dist/{chunk-2DL3OFLD.js → chunk-45GEJRIG.js} +2 -2
- package/dist/{chunk-5IZL4DCV.js → chunk-4DF5LMBJ.js} +2 -2
- package/dist/{chunk-A5UOREWD.js → chunk-4DLGKTM6.js} +2 -2
- package/dist/{chunk-WEFFO2MJ.js → chunk-4E2Z44CV.js} +2 -2
- package/dist/{chunk-X67XNZ64.js → chunk-4LVQSHHN.js} +14 -14
- package/dist/{chunk-RB7NXZ2E.js → chunk-4X7HQKAG.js} +2 -2
- package/dist/{chunk-I74SUMNI.js → chunk-5ACIRCBO.js} +65 -3
- package/dist/chunk-5ACIRCBO.js.map +1 -0
- package/dist/{chunk-LPUEBFX2.js → chunk-5JCYPBY5.js} +2 -2
- package/dist/{chunk-IMULTENA.js → chunk-5SOSQTVE.js} +2 -2
- package/dist/{chunk-D6BOOYNJ.js → chunk-5YIOUS5T.js} +384 -345
- package/dist/chunk-5YIOUS5T.js.map +1 -0
- package/dist/{chunk-5PUZV73Z.js → chunk-6VFMEBXY.js} +12 -12
- package/dist/{chunk-333SBFXB.js → chunk-7AAMJQFW.js} +2 -2
- package/dist/{chunk-BKTCVXMK.js → chunk-7SNEJNA3.js} +96 -23
- package/dist/chunk-7SNEJNA3.js.map +1 -0
- package/dist/{chunk-PFLN6TTW.js → chunk-A2XFG462.js} +2 -2
- package/dist/{chunk-WEHSQBFR.js → chunk-AIF6V2OX.js} +9 -4
- package/dist/chunk-AIF6V2OX.js.map +1 -0
- package/dist/{chunk-HXFIILGF.js → chunk-BFPF5N3H.js} +4 -4
- package/dist/{chunk-QFTK6EDM.js → chunk-BFZFNXOC.js} +13 -13
- package/dist/{chunk-7OCKK5M5.js → chunk-BJOQQCYC.js} +9 -9
- package/dist/{chunk-ZX546Y3Y.js → chunk-CY2C5LM4.js} +3 -3
- package/dist/{chunk-73TPOGS4.js → chunk-DC55RIEZ.js} +9 -9
- package/dist/{chunk-ZDZJNXL6.js → chunk-DK2VBJ6Q.js} +4 -4
- package/dist/{chunk-CLVILSBR.js → chunk-DNXQVCIC.js} +22 -22
- package/dist/{chunk-7VIJUZYW.js → chunk-E53NLIAP.js} +3 -3
- package/dist/{chunk-2LA3H54D.js → chunk-E5IZTY4W.js} +2 -2
- package/dist/{chunk-J74YOBB3.js → chunk-EBI6FI5U.js} +12 -12
- package/dist/{chunk-YYXYZM2I.js → chunk-ETTV5F53.js} +2 -2
- package/dist/{chunk-FRYCXXTB.js → chunk-FSORYJRP.js} +3 -3
- package/dist/{chunk-TH6OYP6I.js → chunk-GOZXQNIM.js} +3 -3
- package/dist/{chunk-TNRGWJYT.js → chunk-GUF2JKG5.js} +2 -2
- package/dist/{chunk-AL3TCNSJ.js → chunk-H3MLOQ7F.js} +24 -53
- package/dist/chunk-H3MLOQ7F.js.map +1 -0
- package/dist/{chunk-SIONKXLU.js → chunk-H6TCS5XX.js} +18 -15
- package/dist/chunk-H6TCS5XX.js.map +1 -0
- package/dist/{chunk-FEUWI5QH.js → chunk-HHPY5SSE.js} +2 -2
- package/dist/{chunk-QPFM6DHY.js → chunk-HHVK2JRE.js} +2 -2
- package/dist/{chunk-YY57TRKN.js → chunk-HR3DKJCU.js} +2 -2
- package/dist/{chunk-FMFCQRDM.js → chunk-IJKO5RVJ.js} +3 -3
- package/dist/{chunk-UMEUU66X.js → chunk-IK7NPYYU.js} +2 -2
- package/dist/{chunk-ILNPU5W5.js → chunk-IMA4DJ7K.js} +5 -45
- package/dist/chunk-IMA4DJ7K.js.map +1 -0
- package/dist/chunk-IUGOGDCP.js +39 -0
- package/dist/chunk-IUGOGDCP.js.map +1 -0
- package/dist/{chunk-CKZWLAHN.js → chunk-JDH2BA2P.js} +2 -2
- package/dist/{chunk-QVXEXGIM.js → chunk-JNBSTHVT.js} +2 -2
- package/dist/chunk-JVVWCZ2P.js +18 -0
- package/dist/chunk-JVVWCZ2P.js.map +1 -0
- package/dist/{chunk-OBPOIZNR.js → chunk-KBHUGMUW.js} +2 -2
- package/dist/{chunk-OZKVVUJB.js → chunk-KIM5VNZN.js} +2 -2
- package/dist/{chunk-ZWDDY4WF.js → chunk-KW4XA7GM.js} +3 -3
- package/dist/{chunk-OAQRZ4SV.js → chunk-L5EE2CXU.js} +2 -2
- package/dist/{chunk-QNUNAXBE.js → chunk-L7LZDISF.js} +1 -9
- package/dist/{chunk-QNUNAXBE.js.map → chunk-L7LZDISF.js.map} +1 -1
- package/dist/{chunk-RO5EGRAI.js → chunk-LAOJHOTG.js} +2 -2
- package/dist/{chunk-FOTFLHBN.js → chunk-LH57QATU.js} +3 -2
- package/dist/chunk-LH57QATU.js.map +1 -0
- package/dist/{chunk-BFPQJNFZ.js → chunk-LXSDEPEK.js} +60 -11
- package/dist/{chunk-BFPQJNFZ.js.map → chunk-LXSDEPEK.js.map} +1 -1
- package/dist/{chunk-3PNJZTDV.js → chunk-NDPS6OU2.js} +2 -2
- package/dist/{chunk-N7AIFTSH.js → chunk-NJG63FY2.js} +1 -1
- package/dist/{chunk-N7AIFTSH.js.map → chunk-NJG63FY2.js.map} +1 -1
- package/dist/{chunk-BUKK5SWA.js → chunk-NKAGGDSL.js} +3 -3
- package/dist/{chunk-BUKK5SWA.js.map → chunk-NKAGGDSL.js.map} +1 -1
- package/dist/{chunk-U3BCW7GX.js → chunk-OGQL7QC7.js} +3 -3
- package/dist/{chunk-K3FH3LAQ.js → chunk-OJXK5C6Z.js} +4 -4
- package/dist/{chunk-HDLNSDLK.js → chunk-P3XO7HE3.js} +2 -2
- package/dist/{chunk-RFLC6PKQ.js → chunk-PQIFYBUX.js} +2 -2
- package/dist/{chunk-WLT6LTQP.js → chunk-PRRWKTK6.js} +2 -2
- package/dist/{chunk-LWZNSQN3.js → chunk-PUQQPLVV.js} +3 -3
- package/dist/{chunk-LWZNSQN3.js.map → chunk-PUQQPLVV.js.map} +1 -1
- package/dist/{chunk-4L25GAYL.js → chunk-Q7OKGBZY.js} +2 -2
- package/dist/{chunk-ZQUOUPP3.js → chunk-QJBULLKG.js} +4 -4
- package/dist/{chunk-W7N7NWG5.js → chunk-QKAFFVSO.js} +2 -2
- package/dist/{chunk-EZG54YDS.js → chunk-QKBFVLDH.js} +2 -2
- package/dist/{chunk-MOUSHJAR.js → chunk-QMFHKWHN.js} +5 -5
- package/dist/{chunk-QLQUAVVP.js → chunk-QRCE77YX.js} +16 -16
- package/dist/chunk-QRCE77YX.js.map +1 -0
- package/dist/{chunk-4D2EY4WM.js → chunk-R2AJAAHJ.js} +6 -6
- package/dist/{chunk-5BE3FLKL.js → chunk-R3UQIS3F.js} +8 -8
- package/dist/{chunk-B3M56D2A.js → chunk-RDHEBINJ.js} +2 -2
- package/dist/{chunk-L7SEYUHS.js → chunk-RHQL2RIM.js} +3 -3
- package/dist/{chunk-2MWKUVHT.js → chunk-RK7SE3BL.js} +5 -5
- package/dist/{chunk-CUPILBIP.js → chunk-SA2YALFU.js} +2 -2
- package/dist/{chunk-VRHY7Y5A.js → chunk-SAPC7N43.js} +3 -3
- package/dist/{chunk-6QWFZ3X5.js → chunk-SOQOUZ2Y.js} +2 -2
- package/dist/{chunk-VHXRLD6S.js → chunk-T2JZF45K.js} +2 -2
- package/dist/{chunk-HLWXCDUQ.js → chunk-T4MKFTJF.js} +5 -5
- package/dist/{chunk-WQUGCOKF.js → chunk-TFA6HPOA.js} +4 -4
- package/dist/{chunk-YZYAYUJQ.js → chunk-TLRIRISJ.js} +4 -4
- package/dist/{chunk-LVGTH6IQ.js → chunk-UFX24WNJ.js} +14 -14
- package/dist/{chunk-OM5ESBES.js → chunk-UH3FPX3L.js} +2 -2
- package/dist/{chunk-4NBUHYUV.js → chunk-V5W67PQV.js} +3 -3
- package/dist/{chunk-TAD6QMMD.js → chunk-VAQIBC2L.js} +2 -2
- package/dist/{chunk-3Q3XD3NO.js → chunk-W2E2WFXL.js} +3 -3
- package/dist/{chunk-UYIBNDQE.js → chunk-W2UV6VE3.js} +2 -2
- package/dist/{chunk-AVWOULJH.js → chunk-W35ICLYZ.js} +2 -2
- package/dist/{chunk-HDDRVXX4.js → chunk-W5LJ3SJ7.js} +2 -2
- package/dist/{chunk-FGT7CUYZ.js → chunk-WF2LYKOB.js} +2 -2
- package/dist/{chunk-JIF22AXI.js → chunk-WGKIXNLY.js} +5 -2
- package/dist/{chunk-JIF22AXI.js.map → chunk-WGKIXNLY.js.map} +1 -1
- package/dist/{chunk-FFWFFAP3.js → chunk-WI2WTIMY.js} +14 -8
- package/dist/chunk-WI2WTIMY.js.map +1 -0
- package/dist/{chunk-OWM2VWNX.js → chunk-X5MFCZDL.js} +82 -44
- package/dist/chunk-X5MFCZDL.js.map +1 -0
- package/dist/{chunk-UVYI6VIX.js → chunk-X7Y7WX73.js} +1 -1
- package/dist/{chunk-22V3CMIW.js → chunk-XJTRIHTH.js} +8 -8
- package/dist/{chunk-3SL52JKD.js → chunk-XVZA6VXC.js} +4 -4
- package/dist/{chunk-WWQMZBDI.js → chunk-XYNUEXLC.js} +7 -7
- package/dist/{chunk-HDWISXFH.js → chunk-Y65XX5PC.js} +2 -2
- package/dist/{chunk-3YOX2BQD.js → chunk-YE77U5HZ.js} +3 -3
- package/dist/{chunk-U2PSE7MB.js → chunk-YLTU2DC4.js} +2 -2
- package/dist/{chunk-BPCR5DZP.js → chunk-YRD525ZO.js} +6 -6
- package/dist/chunk-YRD525ZO.js.map +1 -0
- package/dist/{chunk-SBRUTD5O.js → chunk-YSATDEBY.js} +5 -5
- package/dist/{chunk-TBBDFYXW.js → chunk-YVUNHNB6.js} +2 -3
- package/dist/chunk-YVUNHNB6.js.map +1 -0
- package/dist/{chunk-GBSXTTLP.js → chunk-YY5UXARJ.js} +24 -12
- package/dist/chunk-YY5UXARJ.js.map +1 -0
- package/dist/{chunk-L272A5QW.js → chunk-YYDUBGUF.js} +30 -22
- package/dist/chunk-YYDUBGUF.js.map +1 -0
- package/dist/{chunk-5QDTZIGH.js → chunk-ZJ3CEAJD.js} +2 -2
- package/dist/{chunk-GMO3BGOF.js → chunk-ZOJUWVAU.js} +1 -1
- package/dist/{chunk-T4BT4FQN.js → chunk-ZYP4YEEI.js} +3 -3
- package/dist/cli.js +181 -179
- package/dist/coding/export-okf-codegraph.js +30 -30
- package/dist/coding/pre-action-gate.js +2 -2
- package/dist/compounding/engine.js +20 -20
- package/dist/config-deprecations.d.ts +3 -0
- package/dist/config-deprecations.d.ts.map +1 -0
- package/dist/config-deprecations.js +9 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +30 -29
- package/dist/connectors/codex-marketplace.d.ts.map +1 -1
- package/dist/connectors/codex-materialize-runner.js +20 -20
- package/dist/connectors/codex-materialize.d.ts.map +1 -1
- package/dist/connectors/codex-materialize.js +1 -1
- package/dist/connectors/index.js +21 -21
- package/dist/consolidation-provenance-check.js +2 -2
- package/dist/convergence-refresh.js +22 -22
- package/dist/conversation-index/backend.js +2 -2
- package/dist/corpus-watermark.js +21 -21
- package/dist/deep-recall-http-glue.js +11 -11
- package/dist/deep-recall.js +2 -2
- package/dist/embedding-fallback.js +2 -2
- package/dist/entity-retrieval.js +21 -21
- package/dist/event-order-recall.js +3 -3
- package/dist/explicit-capture.js +181 -179
- package/dist/extraction-judge.js +1 -1
- package/dist/extraction-normalization.js +1 -1
- package/dist/extraction-span-materialize.js +2 -2
- package/dist/extraction.js +35 -35
- package/dist/{first-start-migration-BPVJ4HJQ.js → first-start-migration-PPPP54X6.js} +5 -5
- package/dist/{graph-edge-decay-BC3IO2J4.js → graph-edge-decay-EKWXRBWF.js} +6 -6
- package/dist/graph-edge-decay-EKWXRBWF.js.map +1 -0
- package/dist/graph-jsonl.js +4 -4
- package/dist/graph-snapshot.js +4 -4
- package/dist/graph.js +5 -5
- package/dist/harmonic-retrieval.js +19 -19
- package/dist/index.js +272 -269
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.js +7 -7
- package/dist/lifecycle.d.ts +0 -6
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +1 -1
- package/dist/local-llm.js +2 -2
- package/dist/location/index.js +31 -21
- package/dist/location/provider-setup.d.ts +26 -1
- package/dist/location/provider-setup.d.ts.map +1 -1
- package/dist/maintenance/memory-governance.js +20 -20
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +19 -19
- package/dist/maintenance/rebuild-memory-projection-runner.js +22 -22
- package/dist/maintenance/rebuild-memory-projection.js +21 -21
- package/dist/memory-browse.js +6 -6
- package/dist/memory-controller.d.ts.map +1 -1
- package/dist/memory-controller.js +1 -1
- package/dist/{migrate-from-identity-anchor-MJYB6NNN.js → migrate-from-identity-anchor-TZSZXJ6L.js} +2 -2
- package/dist/migrate-from-identity-anchor-TZSZXJ6L.js.map +1 -0
- package/dist/model-registry.d.ts +0 -5
- package/dist/model-registry.d.ts.map +1 -1
- package/dist/model-registry.js +1 -1
- package/dist/namespaces/migrate.js +20 -20
- package/dist/namespaces/search.js +9 -9
- package/dist/namespaces/storage.d.ts.map +1 -1
- package/dist/namespaces/storage.js +19 -19
- package/dist/offline-sync-changeset-generations.js +4 -4
- package/dist/offline-sync-embedding-generation.js +3 -3
- package/dist/offline-sync-snapshot-stream.js +7 -7
- package/dist/offline-sync.js +6 -6
- package/dist/operator-doctor-corpus.js +22 -22
- package/dist/operator-toolkit.js +42 -41
- package/dist/orchestration/backlog-scheduler.d.ts +4 -0
- package/dist/orchestration/backlog-scheduler.d.ts.map +1 -1
- package/dist/orchestration/backlog-scheduler.js +192 -184
- package/dist/orchestration/backlog-scheduler.js.map +1 -1
- package/dist/orchestration/buffer-drain-runner.js +182 -180
- package/dist/orchestration/extraction-persist-citation.d.ts +2 -2
- package/dist/orchestration/extraction-persist-citation.d.ts.map +1 -1
- package/dist/orchestration/extraction-persist.d.ts.map +1 -1
- package/dist/orchestration/maintenance.js +30 -30
- package/dist/orchestration/recall-internal.d.ts.map +1 -1
- package/dist/orchestration/semantic-consolidation-coordinator.d.ts.map +1 -1
- package/dist/orchestration/turn-ingestion-buffered.d.ts.map +1 -1
- package/dist/orchestration/workspace-ops.d.ts.map +1 -1
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +183 -181
- package/dist/peers/index.d.ts +2 -1
- package/dist/peers/index.d.ts.map +1 -1
- package/dist/peers/index.js +3 -3
- package/dist/peers/interaction-log-append.d.ts +8 -0
- package/dist/peers/interaction-log-append.d.ts.map +1 -0
- package/dist/peers/storage.d.ts +22 -8
- package/dist/peers/storage.d.ts.map +1 -1
- package/dist/policy-runtime.js +2 -2
- package/dist/qmd.js +4 -4
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-navigate-access.js +2 -2
- package/dist/recall-navigate-disclosure.js +2 -2
- package/dist/recall-navigate.js +2 -2
- package/dist/recall-navigation.js +181 -179
- package/dist/recall-state-view-admission.js +6 -6
- package/dist/recall-state-view-packet.d.ts.map +1 -1
- package/dist/recall-state-view-packet.js +30 -8
- package/dist/recall-state-view-packet.js.map +1 -1
- package/dist/recall-why-service.js +6 -6
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/manifest.js +2 -2
- package/dist/resume-bundles.js +31 -30
- package/dist/retrieval.js +2 -2
- package/dist/search/factory.js +8 -8
- package/dist/search/index.js +14 -14
- package/dist/semantic-consolidation.d.ts +10 -16
- package/dist/semantic-consolidation.d.ts.map +1 -1
- package/dist/semantic-consolidation.js +24 -24
- package/dist/semantic-rule-promotion.js +19 -19
- package/dist/semantic-rule-verifier.js +19 -19
- package/dist/source-agent-qualifier.js +25 -25
- package/dist/source-attribution.d.ts +3 -3
- package/dist/source-attribution.d.ts.map +1 -1
- package/dist/source-attribution.js +1 -1
- package/dist/standup/build.js +19 -19
- package/dist/storage/links-frontmatter.d.ts +3 -0
- package/dist/storage/links-frontmatter.d.ts.map +1 -0
- package/dist/storage.d.ts +1 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +18 -18
- package/dist/summarizer.d.ts +7 -1
- package/dist/summarizer.d.ts.map +1 -1
- package/dist/summarizer.js +4 -4
- package/dist/support-passport/index.js +16 -16
- package/dist/tier-routing.js +2 -2
- package/dist/{tier-stats-FLFKN7Y6.js → tier-stats-XWJSVEHC.js} +5 -5
- package/dist/transfer/autodetect.js +3 -3
- package/dist/transfer/backup.js +2 -2
- package/dist/transfer/capsule-export.js +3 -3
- package/dist/transfer/capsule-import.js +3 -3
- package/dist/transfer/export-okf.js +19 -19
- package/dist/transfer/import-json.js +2 -2
- package/dist/transfer/import-md.js +2 -2
- package/dist/transfer/types.d.ts +15 -3
- package/dist/transfer/types.d.ts.map +1 -1
- package/dist/transfer/types.js +3 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-learner.js +2 -2
- package/dist/utility-runtime.js +3 -3
- package/dist/verified-recall.js +19 -19
- package/dist/who-knows-cli.js +20 -20
- package/dist/who-knows.js +19 -19
- package/package.json +2 -2
- package/src/access-cli.test.ts +9 -9
- package/src/access-recall-excerpt-attribution.ts +69 -0
- package/src/access-recall-surface.ts +23 -23
- package/src/access-service-raw-excerpt-read-gate.test.ts +192 -11
- package/src/backlog-scheduler.test.ts +31 -0
- package/src/binary-lifecycle/scanner.ts +35 -14
- package/src/buffer-add-turns-bounded.ts +16 -2
- package/src/buffer-session-cap.ts +4 -4
- package/src/buffer.ts +5 -5
- package/src/calibration.ts +56 -4
- package/src/config-deprecations.ts +14 -0
- package/src/config.ts +2 -1
- package/src/connectors/codex-marketplace-git.test.ts +267 -0
- package/src/connectors/codex-marketplace.ts +76 -13
- package/src/connectors/codex-materialize.ts +29 -55
- package/src/lifecycle.ts +0 -8
- package/src/location/provider-setup.test.ts +273 -2
- package/src/location/provider-setup.ts +138 -32
- package/src/memory-controller.test.ts +11 -0
- package/src/memory-controller.ts +5 -1
- package/src/model-registry.ts +0 -11
- package/src/namespaces/storage.ts +1 -0
- package/src/orchestration/backlog-scheduler.ts +12 -3
- package/src/orchestration/extraction-persist-citation.ts +5 -3
- package/src/orchestration/extraction-persist.ts +15 -14
- package/src/orchestration/recall-internal.ts +2 -3
- package/src/orchestration/semantic-consolidation-coordinator.ts +40 -33
- package/src/orchestration/semantic-consolidation-split.test.ts +72 -0
- package/src/orchestration/turn-ingestion-buffered.test.ts +52 -1
- package/src/orchestration/turn-ingestion-buffered.ts +26 -8
- package/src/orchestration/workspace-ops.test.ts +23 -0
- package/src/orchestration/workspace-ops.ts +6 -5
- package/src/orchestrator.ts +1 -0
- package/src/peers/index.ts +1 -1
- package/src/peers/interaction-log-append.ts +132 -0
- package/src/peers/peers.test.ts +30 -0
- package/src/peers/profile-reasoner.ts +1 -1
- package/src/peers/storage.ts +4 -105
- package/src/recall-state-view-packet.test.ts +40 -0
- package/src/recall-state-view-packet.ts +46 -9
- package/src/semantic-consolidation.ts +35 -27
- package/src/source-attribution.test.ts +57 -0
- package/src/source-attribution.ts +46 -43
- package/src/storage/links-frontmatter.ts +69 -0
- package/src/storage-links-parse.test.ts +153 -0
- package/src/storage.ts +8 -21
- package/src/summarizer-shutdown.test.ts +49 -16
- package/src/summarizer.ts +13 -5
- package/src/testing/subjects/dependency-propagation.test.ts +5 -4
- package/src/testing/subjects/memory-maintenance.test.ts +293 -0
- package/src/transfer/capsule-export.ts +2 -1
- package/src/transfer/capsule-taxonomy-version.test.ts +70 -0
- package/src/transfer/types.ts +13 -3
- package/src/types.ts +1 -0
- package/dist/chunk-AL3TCNSJ.js.map +0 -1
- package/dist/chunk-BKTCVXMK.js.map +0 -1
- package/dist/chunk-BPCR5DZP.js.map +0 -1
- package/dist/chunk-D6BOOYNJ.js.map +0 -1
- package/dist/chunk-FFWFFAP3.js.map +0 -1
- package/dist/chunk-FOTFLHBN.js.map +0 -1
- package/dist/chunk-GBSXTTLP.js.map +0 -1
- package/dist/chunk-I74SUMNI.js.map +0 -1
- package/dist/chunk-ILNPU5W5.js.map +0 -1
- package/dist/chunk-L272A5QW.js.map +0 -1
- package/dist/chunk-OWM2VWNX.js.map +0 -1
- package/dist/chunk-QLQUAVVP.js.map +0 -1
- package/dist/chunk-SIONKXLU.js.map +0 -1
- package/dist/chunk-TBBDFYXW.js.map +0 -1
- package/dist/chunk-WEHSQBFR.js.map +0 -1
- /package/dist/{capsule-crypto-GWVG7LGC.js.map → access-recall-excerpt-attribution.js.map} +0 -0
- /package/dist/{auto-sync-L3M4RKJD.js.map → auto-sync-ACP5U5A3.js.map} +0 -0
- /package/dist/{graph-edge-decay-BC3IO2J4.js.map → capsule-crypto-7FJQINUR.js.map} +0 -0
- /package/dist/{capsule-merge-VHBRF65A.js.map → capsule-merge-BADOICNP.js.map} +0 -0
- /package/dist/{chunk-OWHERGF2.js.map → chunk-2NLLXCJG.js.map} +0 -0
- /package/dist/{chunk-CKELO7Q6.js.map → chunk-2OAFPBQB.js.map} +0 -0
- /package/dist/{chunk-2DL3OFLD.js.map → chunk-45GEJRIG.js.map} +0 -0
- /package/dist/{chunk-5IZL4DCV.js.map → chunk-4DF5LMBJ.js.map} +0 -0
- /package/dist/{chunk-A5UOREWD.js.map → chunk-4DLGKTM6.js.map} +0 -0
- /package/dist/{chunk-WEFFO2MJ.js.map → chunk-4E2Z44CV.js.map} +0 -0
- /package/dist/{chunk-X67XNZ64.js.map → chunk-4LVQSHHN.js.map} +0 -0
- /package/dist/{chunk-RB7NXZ2E.js.map → chunk-4X7HQKAG.js.map} +0 -0
- /package/dist/{chunk-LPUEBFX2.js.map → chunk-5JCYPBY5.js.map} +0 -0
- /package/dist/{chunk-IMULTENA.js.map → chunk-5SOSQTVE.js.map} +0 -0
- /package/dist/{chunk-5PUZV73Z.js.map → chunk-6VFMEBXY.js.map} +0 -0
- /package/dist/{chunk-333SBFXB.js.map → chunk-7AAMJQFW.js.map} +0 -0
- /package/dist/{chunk-PFLN6TTW.js.map → chunk-A2XFG462.js.map} +0 -0
- /package/dist/{chunk-HXFIILGF.js.map → chunk-BFPF5N3H.js.map} +0 -0
- /package/dist/{chunk-QFTK6EDM.js.map → chunk-BFZFNXOC.js.map} +0 -0
- /package/dist/{chunk-7OCKK5M5.js.map → chunk-BJOQQCYC.js.map} +0 -0
- /package/dist/{chunk-ZX546Y3Y.js.map → chunk-CY2C5LM4.js.map} +0 -0
- /package/dist/{chunk-73TPOGS4.js.map → chunk-DC55RIEZ.js.map} +0 -0
- /package/dist/{chunk-ZDZJNXL6.js.map → chunk-DK2VBJ6Q.js.map} +0 -0
- /package/dist/{chunk-CLVILSBR.js.map → chunk-DNXQVCIC.js.map} +0 -0
- /package/dist/{chunk-7VIJUZYW.js.map → chunk-E53NLIAP.js.map} +0 -0
- /package/dist/{chunk-2LA3H54D.js.map → chunk-E5IZTY4W.js.map} +0 -0
- /package/dist/{chunk-J74YOBB3.js.map → chunk-EBI6FI5U.js.map} +0 -0
- /package/dist/{chunk-YYXYZM2I.js.map → chunk-ETTV5F53.js.map} +0 -0
- /package/dist/{chunk-FRYCXXTB.js.map → chunk-FSORYJRP.js.map} +0 -0
- /package/dist/{chunk-TH6OYP6I.js.map → chunk-GOZXQNIM.js.map} +0 -0
- /package/dist/{chunk-TNRGWJYT.js.map → chunk-GUF2JKG5.js.map} +0 -0
- /package/dist/{chunk-FEUWI5QH.js.map → chunk-HHPY5SSE.js.map} +0 -0
- /package/dist/{chunk-QPFM6DHY.js.map → chunk-HHVK2JRE.js.map} +0 -0
- /package/dist/{chunk-YY57TRKN.js.map → chunk-HR3DKJCU.js.map} +0 -0
- /package/dist/{chunk-FMFCQRDM.js.map → chunk-IJKO5RVJ.js.map} +0 -0
- /package/dist/{chunk-UMEUU66X.js.map → chunk-IK7NPYYU.js.map} +0 -0
- /package/dist/{chunk-CKZWLAHN.js.map → chunk-JDH2BA2P.js.map} +0 -0
- /package/dist/{chunk-QVXEXGIM.js.map → chunk-JNBSTHVT.js.map} +0 -0
- /package/dist/{chunk-OBPOIZNR.js.map → chunk-KBHUGMUW.js.map} +0 -0
- /package/dist/{chunk-OZKVVUJB.js.map → chunk-KIM5VNZN.js.map} +0 -0
- /package/dist/{chunk-ZWDDY4WF.js.map → chunk-KW4XA7GM.js.map} +0 -0
- /package/dist/{chunk-OAQRZ4SV.js.map → chunk-L5EE2CXU.js.map} +0 -0
- /package/dist/{chunk-RO5EGRAI.js.map → chunk-LAOJHOTG.js.map} +0 -0
- /package/dist/{chunk-3PNJZTDV.js.map → chunk-NDPS6OU2.js.map} +0 -0
- /package/dist/{chunk-U3BCW7GX.js.map → chunk-OGQL7QC7.js.map} +0 -0
- /package/dist/{chunk-K3FH3LAQ.js.map → chunk-OJXK5C6Z.js.map} +0 -0
- /package/dist/{chunk-HDLNSDLK.js.map → chunk-P3XO7HE3.js.map} +0 -0
- /package/dist/{chunk-RFLC6PKQ.js.map → chunk-PQIFYBUX.js.map} +0 -0
- /package/dist/{chunk-WLT6LTQP.js.map → chunk-PRRWKTK6.js.map} +0 -0
- /package/dist/{chunk-4L25GAYL.js.map → chunk-Q7OKGBZY.js.map} +0 -0
- /package/dist/{chunk-ZQUOUPP3.js.map → chunk-QJBULLKG.js.map} +0 -0
- /package/dist/{chunk-W7N7NWG5.js.map → chunk-QKAFFVSO.js.map} +0 -0
- /package/dist/{chunk-EZG54YDS.js.map → chunk-QKBFVLDH.js.map} +0 -0
- /package/dist/{chunk-MOUSHJAR.js.map → chunk-QMFHKWHN.js.map} +0 -0
- /package/dist/{chunk-4D2EY4WM.js.map → chunk-R2AJAAHJ.js.map} +0 -0
- /package/dist/{chunk-5BE3FLKL.js.map → chunk-R3UQIS3F.js.map} +0 -0
- /package/dist/{chunk-B3M56D2A.js.map → chunk-RDHEBINJ.js.map} +0 -0
- /package/dist/{chunk-L7SEYUHS.js.map → chunk-RHQL2RIM.js.map} +0 -0
- /package/dist/{chunk-2MWKUVHT.js.map → chunk-RK7SE3BL.js.map} +0 -0
- /package/dist/{chunk-CUPILBIP.js.map → chunk-SA2YALFU.js.map} +0 -0
- /package/dist/{chunk-VRHY7Y5A.js.map → chunk-SAPC7N43.js.map} +0 -0
- /package/dist/{chunk-6QWFZ3X5.js.map → chunk-SOQOUZ2Y.js.map} +0 -0
- /package/dist/{chunk-VHXRLD6S.js.map → chunk-T2JZF45K.js.map} +0 -0
- /package/dist/{chunk-HLWXCDUQ.js.map → chunk-T4MKFTJF.js.map} +0 -0
- /package/dist/{chunk-WQUGCOKF.js.map → chunk-TFA6HPOA.js.map} +0 -0
- /package/dist/{chunk-YZYAYUJQ.js.map → chunk-TLRIRISJ.js.map} +0 -0
- /package/dist/{chunk-LVGTH6IQ.js.map → chunk-UFX24WNJ.js.map} +0 -0
- /package/dist/{chunk-OM5ESBES.js.map → chunk-UH3FPX3L.js.map} +0 -0
- /package/dist/{chunk-4NBUHYUV.js.map → chunk-V5W67PQV.js.map} +0 -0
- /package/dist/{chunk-TAD6QMMD.js.map → chunk-VAQIBC2L.js.map} +0 -0
- /package/dist/{chunk-3Q3XD3NO.js.map → chunk-W2E2WFXL.js.map} +0 -0
- /package/dist/{chunk-UYIBNDQE.js.map → chunk-W2UV6VE3.js.map} +0 -0
- /package/dist/{chunk-AVWOULJH.js.map → chunk-W35ICLYZ.js.map} +0 -0
- /package/dist/{chunk-HDDRVXX4.js.map → chunk-W5LJ3SJ7.js.map} +0 -0
- /package/dist/{chunk-FGT7CUYZ.js.map → chunk-WF2LYKOB.js.map} +0 -0
- /package/dist/{chunk-UVYI6VIX.js.map → chunk-X7Y7WX73.js.map} +0 -0
- /package/dist/{chunk-22V3CMIW.js.map → chunk-XJTRIHTH.js.map} +0 -0
- /package/dist/{chunk-3SL52JKD.js.map → chunk-XVZA6VXC.js.map} +0 -0
- /package/dist/{chunk-WWQMZBDI.js.map → chunk-XYNUEXLC.js.map} +0 -0
- /package/dist/{chunk-HDWISXFH.js.map → chunk-Y65XX5PC.js.map} +0 -0
- /package/dist/{chunk-3YOX2BQD.js.map → chunk-YE77U5HZ.js.map} +0 -0
- /package/dist/{chunk-U2PSE7MB.js.map → chunk-YLTU2DC4.js.map} +0 -0
- /package/dist/{chunk-SBRUTD5O.js.map → chunk-YSATDEBY.js.map} +0 -0
- /package/dist/{chunk-5QDTZIGH.js.map → chunk-ZJ3CEAJD.js.map} +0 -0
- /package/dist/{chunk-GMO3BGOF.js.map → chunk-ZOJUWVAU.js.map} +0 -0
- /package/dist/{chunk-T4BT4FQN.js.map → chunk-ZYP4YEEI.js.map} +0 -0
- /package/dist/{migrate-from-identity-anchor-MJYB6NNN.js.map → config-deprecations.js.map} +0 -0
- /package/dist/{first-start-migration-BPVJ4HJQ.js.map → first-start-migration-PPPP54X6.js.map} +0 -0
- /package/dist/{tier-stats-FLFKN7Y6.js.map → tier-stats-XWJSVEHC.js.map} +0 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operator memory-maintenance subject for the scenario-matrix harness
|
|
3
|
+
* (issue #3642).
|
|
4
|
+
*
|
|
5
|
+
* Every canonical row exercises the three maintenance surfaces that matched
|
|
6
|
+
* the `maintenance/**` lifecycle glob but had no registered subject:
|
|
7
|
+
*
|
|
8
|
+
* - `forgetMemory` (maintenance/forget.ts): soft-deletes a fact memory —
|
|
9
|
+
* frontmatter status flip plus the live tombstone that blocks
|
|
10
|
+
* re-extraction resurrection.
|
|
11
|
+
* - `ensureCronJob` (maintenance/memory-governance-cron.ts): idempotent
|
|
12
|
+
* registration of a governance job inside jobs.json, including the
|
|
13
|
+
* updateExisting merge path.
|
|
14
|
+
* - `summarizeTiers` / `explainTierForMemory` (maintenance/tier-stats.ts):
|
|
15
|
+
* tier/status accounting over the same memories the forget mutated.
|
|
16
|
+
*
|
|
17
|
+
* Dimension mapping:
|
|
18
|
+
* - remembered-binding rows pre-seed jobs.json with the job already
|
|
19
|
+
* registered under a stale schedule — the binding a restarted process
|
|
20
|
+
* would find on disk.
|
|
21
|
+
* - the provider-rebinding row additionally drives `updateExisting` with a
|
|
22
|
+
* changed schedule and asserts the merge reports `updated: true`.
|
|
23
|
+
* - the dedupe/replay row re-runs `ensureCronJob` and `forgetMemory` and
|
|
24
|
+
* asserts both are idempotent: no second job, an AlreadyForgotten
|
|
25
|
+
* rejection, and byte-identical jobs.json.
|
|
26
|
+
* - the restart/reload row rebuilds the storage facade and re-parses
|
|
27
|
+
* jobs.json from disk — nothing may be lost across a process boundary.
|
|
28
|
+
* - flush-transition rows keep the same contract: these surfaces are
|
|
29
|
+
* write-through (no buffered flush exists), so on-disk state must be
|
|
30
|
+
* complete and readable the moment each call resolves.
|
|
31
|
+
*/
|
|
32
|
+
import assert from "node:assert/strict";
|
|
33
|
+
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
34
|
+
import os from "node:os";
|
|
35
|
+
import path from "node:path";
|
|
36
|
+
|
|
37
|
+
import {
|
|
38
|
+
forgetMemory,
|
|
39
|
+
ForgetMemoryAlreadyForgottenError,
|
|
40
|
+
type ForgetMemoryResult,
|
|
41
|
+
} from "../../maintenance/forget.js";
|
|
42
|
+
import { ensureCronJob } from "../../maintenance/memory-governance-cron.js";
|
|
43
|
+
import {
|
|
44
|
+
explainTierForMemory,
|
|
45
|
+
summarizeTiers,
|
|
46
|
+
type TierExplainResult,
|
|
47
|
+
type TierSummary,
|
|
48
|
+
} from "../../maintenance/tier-stats.js";
|
|
49
|
+
import type { StorageManager } from "../../storage.js";
|
|
50
|
+
import type { MemoryFile, MemoryFrontmatter, PluginConfig } from "../../types.js";
|
|
51
|
+
import { type LifecycleSubject, runLifecycleMatrix } from "../lifecycle-matrix.js";
|
|
52
|
+
|
|
53
|
+
const NOW = "2026-06-01T00:00:00.000Z";
|
|
54
|
+
const CRON_ID = "engram-subject-nightly";
|
|
55
|
+
const FORGET_ID = "fact-alpha";
|
|
56
|
+
const LEGACY_SCHEDULE = "0 2 * * *";
|
|
57
|
+
const CURRENT_SCHEDULE = "0 3 * * *";
|
|
58
|
+
|
|
59
|
+
interface EnsureResult {
|
|
60
|
+
created: boolean;
|
|
61
|
+
updated: boolean;
|
|
62
|
+
jobId: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface MaintenanceState {
|
|
66
|
+
dir: string;
|
|
67
|
+
jobsPath: string;
|
|
68
|
+
hot: MemoryFile[];
|
|
69
|
+
archived: MemoryFile[];
|
|
70
|
+
cold: MemoryFile[];
|
|
71
|
+
frontmatterWrites: Array<{ id: string; patch: Partial<MemoryFrontmatter> }>;
|
|
72
|
+
tombstones: unknown[];
|
|
73
|
+
ensureFirst: EnsureResult | null;
|
|
74
|
+
ensureReplay: EnsureResult | null;
|
|
75
|
+
forgetResult: ForgetMemoryResult | null;
|
|
76
|
+
summary: TierSummary | null;
|
|
77
|
+
reloadedJobs: string | null;
|
|
78
|
+
reloadedSummary: TierSummary | null;
|
|
79
|
+
explain: TierExplainResult | null;
|
|
80
|
+
jobsJsonAfterFirst: string | null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function makeMemory(id: string, overrides: Partial<MemoryFrontmatter> = {}): MemoryFile {
|
|
84
|
+
// SAFETY: the fixture literal fills exactly the fields the maintenance
|
|
85
|
+
// paths read; MemoryFrontmatter carries optional slots the fixture omits.
|
|
86
|
+
return {
|
|
87
|
+
path: `/virtual/${id}.md`,
|
|
88
|
+
content: `synthetic body for ${id}`,
|
|
89
|
+
frontmatter: {
|
|
90
|
+
id,
|
|
91
|
+
category: "preference",
|
|
92
|
+
created: "2026-01-01T00:00:00.000Z",
|
|
93
|
+
updated: "2026-01-01T00:00:00.000Z",
|
|
94
|
+
source: "test",
|
|
95
|
+
...overrides,
|
|
96
|
+
} as MemoryFrontmatter,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function makeStorage(state: MaintenanceState): StorageManager {
|
|
101
|
+
const stub: Partial<StorageManager> = {
|
|
102
|
+
readAllMemories: async () => state.hot,
|
|
103
|
+
readArchivedMemories: async () => state.archived,
|
|
104
|
+
readAllColdMemories: async () => state.cold,
|
|
105
|
+
writeMemoryFrontmatter: async (memory, patch) => {
|
|
106
|
+
Object.assign(memory.frontmatter, patch);
|
|
107
|
+
state.frontmatterWrites.push({ id: memory.frontmatter.id, patch });
|
|
108
|
+
return true;
|
|
109
|
+
},
|
|
110
|
+
appendTombstone: async (input) => {
|
|
111
|
+
state.tombstones.push(input);
|
|
112
|
+
return "stub-tombstone";
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
// SAFETY: the test double exposes only the StorageManager methods the three
|
|
116
|
+
// maintenance surfaces call; a full StorageManager needs a real memory dir.
|
|
117
|
+
return stub as StorageManager;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function makeConfig(memoryDir: string): PluginConfig {
|
|
121
|
+
const config: Partial<PluginConfig> = {
|
|
122
|
+
memoryDir,
|
|
123
|
+
qmdTierMigrationEnabled: true,
|
|
124
|
+
qmdTierDemotionMinAgeDays: 14,
|
|
125
|
+
qmdTierDemotionValueThreshold: 0.35,
|
|
126
|
+
qmdTierPromotionValueThreshold: 0.7,
|
|
127
|
+
memoryUtilityLearningEnabled: false,
|
|
128
|
+
promotionByOutcomeEnabled: false,
|
|
129
|
+
lifecyclePolicyEnabled: false,
|
|
130
|
+
lifecycleStaleDecayThreshold: 0,
|
|
131
|
+
lifecyclePromoteHeatThreshold: 0,
|
|
132
|
+
};
|
|
133
|
+
// SAFETY: same reduced-config shape tier-stats.test.ts uses; the learning
|
|
134
|
+
// flags stay off so explainTierForMemory takes the null-runtime path.
|
|
135
|
+
return config as PluginConfig;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function buildJob() {
|
|
139
|
+
return {
|
|
140
|
+
id: CRON_ID,
|
|
141
|
+
schedule: CURRENT_SCHEDULE,
|
|
142
|
+
enabled: true,
|
|
143
|
+
payload: { kind: "nightly-governance" },
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function readJobIds(jobsPath: string): Promise<string[]> {
|
|
148
|
+
// SAFETY: jobs.json is written by this fixture's own ensureCronJob calls;
|
|
149
|
+
// the {jobs:[{id}]} shape is the file contract exercised under test.
|
|
150
|
+
const parsed = JSON.parse(await readFile(jobsPath, "utf8")) as { jobs: Array<{ id?: unknown }> };
|
|
151
|
+
return parsed.jobs.map((job) => String(job.id));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const subject: LifecycleSubject<MaintenanceState> = {
|
|
155
|
+
async setup(row) {
|
|
156
|
+
const dir = await mkdtemp(path.join(os.tmpdir(), "remnic-memory-maintenance-"));
|
|
157
|
+
const jobsPath = path.join(dir, "jobs.json");
|
|
158
|
+
try {
|
|
159
|
+
// remembered-binding rows model an earlier process having already
|
|
160
|
+
// registered the job under a stale schedule.
|
|
161
|
+
const seeded = row.dimensions.rememberedBinding
|
|
162
|
+
? { jobs: [{ ...buildJob(), schedule: LEGACY_SCHEDULE }] }
|
|
163
|
+
: { jobs: [] };
|
|
164
|
+
await writeFile(jobsPath, JSON.stringify(seeded, null, 2) + "\n", "utf8");
|
|
165
|
+
} catch (err) {
|
|
166
|
+
await rm(dir, { recursive: true, force: true });
|
|
167
|
+
throw err;
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
dir,
|
|
171
|
+
jobsPath,
|
|
172
|
+
hot: [
|
|
173
|
+
makeMemory(FORGET_ID, {
|
|
174
|
+
category: "fact",
|
|
175
|
+
status: "active",
|
|
176
|
+
contentHash: "hash-fact-alpha",
|
|
177
|
+
}),
|
|
178
|
+
makeMemory("pref-beta", { status: "active" }),
|
|
179
|
+
],
|
|
180
|
+
archived: [],
|
|
181
|
+
cold: [makeMemory("cold-gamma", { status: "archived" })],
|
|
182
|
+
frontmatterWrites: [],
|
|
183
|
+
tombstones: [],
|
|
184
|
+
ensureFirst: null,
|
|
185
|
+
ensureReplay: null,
|
|
186
|
+
forgetResult: null,
|
|
187
|
+
summary: null,
|
|
188
|
+
reloadedJobs: null,
|
|
189
|
+
reloadedSummary: null,
|
|
190
|
+
explain: null,
|
|
191
|
+
jobsJsonAfterFirst: null,
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
async exercise(state, row) {
|
|
196
|
+
const storage = makeStorage(state);
|
|
197
|
+
const rebound = row.dimensions.providerIdentity === "rebound";
|
|
198
|
+
const options = rebound
|
|
199
|
+
? { updateExisting: true, updateFields: ["schedule", "payload"] }
|
|
200
|
+
: {};
|
|
201
|
+
|
|
202
|
+
state.ensureFirst = await ensureCronJob(state.jobsPath, CRON_ID, buildJob, options);
|
|
203
|
+
state.forgetResult = await forgetMemory(storage, {
|
|
204
|
+
id: FORGET_ID,
|
|
205
|
+
reason: "matrix forget",
|
|
206
|
+
now: () => new Date(NOW),
|
|
207
|
+
});
|
|
208
|
+
state.summary = await summarizeTiers(storage);
|
|
209
|
+
state.explain = await explainTierForMemory(storage, FORGET_ID, makeConfig(state.dir));
|
|
210
|
+
|
|
211
|
+
if (row.dimensions.dedupeOrReplay) {
|
|
212
|
+
state.jobsJsonAfterFirst = await readFile(state.jobsPath, "utf8");
|
|
213
|
+
state.ensureReplay = await ensureCronJob(state.jobsPath, CRON_ID, buildJob, options);
|
|
214
|
+
await assert.rejects(
|
|
215
|
+
forgetMemory(storage, { id: FORGET_ID, now: () => new Date(NOW) }),
|
|
216
|
+
ForgetMemoryAlreadyForgottenError,
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (row.dimensions.restart) {
|
|
221
|
+
// A restarted process sees only what is on disk: re-parse jobs.json and
|
|
222
|
+
// rebuild the storage facade over the same persisted memory records.
|
|
223
|
+
state.reloadedJobs = await readFile(state.jobsPath, "utf8");
|
|
224
|
+
state.reloadedSummary = await summarizeTiers(makeStorage(state));
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
async invariants(state, row) {
|
|
229
|
+
const seeded = row.dimensions.rememberedBinding;
|
|
230
|
+
const rebound = row.dimensions.providerIdentity === "rebound";
|
|
231
|
+
|
|
232
|
+
const first = state.ensureFirst;
|
|
233
|
+
assert.ok(first, "ensureCronJob returned a result");
|
|
234
|
+
assert.equal(first.jobId, CRON_ID);
|
|
235
|
+
assert.equal(first.created, !seeded, "job is created only when no binding was seeded");
|
|
236
|
+
assert.equal(first.updated, rebound, "only the rebinding row rewrites the seeded job");
|
|
237
|
+
|
|
238
|
+
const jobIds = await readJobIds(state.jobsPath);
|
|
239
|
+
assert.deepEqual(jobIds, [CRON_ID], "jobs.json holds exactly one registration");
|
|
240
|
+
|
|
241
|
+
const forget = state.forgetResult;
|
|
242
|
+
assert.ok(forget, "forgetMemory returned a result");
|
|
243
|
+
assert.equal(forget.id, FORGET_ID);
|
|
244
|
+
assert.equal(forget.priorStatus, "active");
|
|
245
|
+
assert.equal(forget.forgottenAt, NOW);
|
|
246
|
+
assert.equal(forget.reason, "matrix forget");
|
|
247
|
+
|
|
248
|
+
const forgotten = state.hot.find((m) => m.frontmatter.id === FORGET_ID);
|
|
249
|
+
assert.equal(forgotten?.frontmatter.status, "forgotten");
|
|
250
|
+
assert.equal(forgotten?.frontmatter.forgottenAt, NOW);
|
|
251
|
+
assert.equal(forgotten?.frontmatter.forgottenReason, "matrix forget");
|
|
252
|
+
assert.ok(state.tombstones.length >= 1, "fact forget emits a live tombstone");
|
|
253
|
+
|
|
254
|
+
const summary = state.summary;
|
|
255
|
+
assert.ok(summary, "summarizeTiers returned a summary");
|
|
256
|
+
assert.equal(summary.total, 3);
|
|
257
|
+
assert.equal(summary.byTier.hot, 2);
|
|
258
|
+
assert.equal(summary.byTier.cold, 1);
|
|
259
|
+
assert.equal(summary.byStatus.forgotten, 1);
|
|
260
|
+
assert.equal(summary.forgottenCount, 1);
|
|
261
|
+
|
|
262
|
+
const explain = state.explain;
|
|
263
|
+
assert.ok(explain, "explainTierForMemory returned a result");
|
|
264
|
+
assert.equal(explain.id, FORGET_ID);
|
|
265
|
+
assert.equal(explain.currentTier, "hot");
|
|
266
|
+
assert.equal(explain.status, "forgotten");
|
|
267
|
+
assert.ok(Number.isFinite(explain.valueScore), "value score computed");
|
|
268
|
+
assert.ok(explain.decision, "tier transition decision present");
|
|
269
|
+
|
|
270
|
+
if (row.dimensions.dedupeOrReplay) {
|
|
271
|
+
const replay = state.ensureReplay;
|
|
272
|
+
assert.ok(replay, "replay ensureCronJob returned a result");
|
|
273
|
+
assert.equal(replay.created, false, "replay must not create a second job");
|
|
274
|
+
assert.equal(replay.updated, false, "replay with identical spec must not rewrite");
|
|
275
|
+
const jobsJsonNow = await readFile(state.jobsPath, "utf8");
|
|
276
|
+
assert.equal(jobsJsonNow, state.jobsJsonAfterFirst, "replay leaves jobs.json byte-identical");
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (row.dimensions.restart) {
|
|
280
|
+
// SAFETY: reloadedJobs was read from a jobs.json produced by this
|
|
281
|
+
// fixture's ensureCronJob call in the same row.
|
|
282
|
+
const parsed = JSON.parse(state.reloadedJobs ?? "") as { jobs: Array<{ id?: unknown }> };
|
|
283
|
+
assert.deepEqual(parsed.jobs.map((job) => String(job.id)), [CRON_ID]);
|
|
284
|
+
assert.equal(state.reloadedSummary?.forgottenCount, 1, "forgotten status survives a reload");
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
async teardown(state) {
|
|
289
|
+
await rm(state.dir, { recursive: true, force: true });
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
runLifecycleMatrix("memory-maintenance", subject);
|
|
@@ -499,7 +499,8 @@ function shouldInclude(
|
|
|
499
499
|
*
|
|
500
500
|
* Defaults (chosen to be safe + least-surprising):
|
|
501
501
|
* - `version` — `0.1.0` (capsule authors override per release).
|
|
502
|
-
* - `schemaVersion` — `taxonomy-v1`
|
|
502
|
+
* - `schemaVersion` — `taxonomy-v1` (the only member of
|
|
503
|
+
* {@link CAPSULE_TAXONOMY_VERSIONS}; see issue 3572).
|
|
503
504
|
* - `parentCapsule` — `null` (explicit "no parent" sentinel).
|
|
504
505
|
* - `description` — empty string. Capsule authors override.
|
|
505
506
|
* - `retrievalPolicy` — empty `tierWeights` map + `directAnswerEnabled: false`.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CapsuleTaxonomySchema schemaVersion registry — issue 3572.
|
|
3
|
+
*
|
|
4
|
+
* CapsuleBlockSchema accepted any non-empty string as the capsule's taxonomy
|
|
5
|
+
* schemaVersion (the "free-form placeholder" hack). These tests pin the
|
|
6
|
+
* contract: only taxonomy versions in the known registry parse, unknown ones
|
|
7
|
+
* are refused with a message naming the known versions, and export with an
|
|
8
|
+
* unknown override fails the same way.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import assert from "node:assert/strict";
|
|
12
|
+
import test from "node:test";
|
|
13
|
+
|
|
14
|
+
import { makeTempDir } from "../testing/tmp-dir.js";
|
|
15
|
+
import { exportCapsule } from "./capsule-export.js";
|
|
16
|
+
import { CAPSULE_TAXONOMY_VERSIONS, CapsuleBlockSchema } from "./types.js";
|
|
17
|
+
|
|
18
|
+
function baseBlock() {
|
|
19
|
+
return {
|
|
20
|
+
id: "capsule-test",
|
|
21
|
+
version: "0.1.0",
|
|
22
|
+
schemaVersion: CAPSULE_TAXONOMY_VERSIONS[0],
|
|
23
|
+
parentCapsule: null,
|
|
24
|
+
parent: null,
|
|
25
|
+
description: "",
|
|
26
|
+
retrievalPolicy: { tierWeights: {}, directAnswerEnabled: false },
|
|
27
|
+
includes: {
|
|
28
|
+
taxonomy: false,
|
|
29
|
+
identityAnchors: false,
|
|
30
|
+
peerProfiles: false,
|
|
31
|
+
procedural: false,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
test("known taxonomy versions parse", () => {
|
|
37
|
+
for (const v of CAPSULE_TAXONOMY_VERSIONS) {
|
|
38
|
+
const parsed = CapsuleBlockSchema.parse({ ...baseBlock(), schemaVersion: v });
|
|
39
|
+
assert.equal(parsed.schemaVersion, v);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("unknown taxonomy versions are refused, naming the registry", () => {
|
|
44
|
+
const result = CapsuleBlockSchema.safeParse({ ...baseBlock(), schemaVersion: "taxonomy-v9" });
|
|
45
|
+
assert.equal(result.success, false);
|
|
46
|
+
if (!result.success) {
|
|
47
|
+
assert.match(result.error.issues[0].message, /taxonomy-v1/);
|
|
48
|
+
}
|
|
49
|
+
// Empty string stays refused too.
|
|
50
|
+
assert.equal(CapsuleBlockSchema.safeParse({ ...baseBlock(), schemaVersion: "" }).success, false);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("export refuses an unknown schemaVersion override", async () => {
|
|
54
|
+
const root = await makeTempDir("cap-taxonomy-root-");
|
|
55
|
+
const outDir = await makeTempDir("cap-taxonomy-out-");
|
|
56
|
+
await assert.rejects(
|
|
57
|
+
exportCapsule({
|
|
58
|
+
name: "taxonomy-refusal-capsule",
|
|
59
|
+
root,
|
|
60
|
+
outDir,
|
|
61
|
+
pluginVersion: "0.0.0-test",
|
|
62
|
+
now: 1_700_000_000_000,
|
|
63
|
+
// SAFETY: the invalid literal is the point of this test; the cast
|
|
64
|
+
// defeats the enum's compile-time narrowing so safeParse can reject
|
|
65
|
+
// "taxonomy-v9" at runtime.
|
|
66
|
+
capsule: { schemaVersion: "taxonomy-v9" as "taxonomy-v1" },
|
|
67
|
+
}),
|
|
68
|
+
/taxonomy-v1/,
|
|
69
|
+
);
|
|
70
|
+
});
|
package/src/transfer/types.ts
CHANGED
|
@@ -142,14 +142,24 @@ export const CapsuleParentSchema = z.object({
|
|
|
142
142
|
|
|
143
143
|
export type CapsuleParent = z.infer<typeof CapsuleParentSchema>;
|
|
144
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Known taxonomy schema versions a capsule may be authored against
|
|
147
|
+
* (issue 3572). Exporters must emit one of these; importers refuse anything
|
|
148
|
+
* else instead of silently accepting a version they cannot interpret.
|
|
149
|
+
*/
|
|
150
|
+
export const CAPSULE_TAXONOMY_VERSIONS = ["taxonomy-v1"] as const;
|
|
151
|
+
|
|
145
152
|
export const CapsuleBlockSchema = z.object({
|
|
146
153
|
id: CapsuleIdSchema,
|
|
147
154
|
version: SemverLikeSchema,
|
|
148
155
|
/**
|
|
149
|
-
* Taxonomy schema version the capsule was authored against.
|
|
150
|
-
*
|
|
156
|
+
* Taxonomy schema version the capsule was authored against. Must be a
|
|
157
|
+
* member of {@link CAPSULE_TAXONOMY_VERSIONS}; the error names the known
|
|
158
|
+
* versions so writers can pick one.
|
|
151
159
|
*/
|
|
152
|
-
schemaVersion: z.
|
|
160
|
+
schemaVersion: z.enum(CAPSULE_TAXONOMY_VERSIONS, {
|
|
161
|
+
message: `capsule.schemaVersion must be one of: ${CAPSULE_TAXONOMY_VERSIONS.join(", ")}`,
|
|
162
|
+
}),
|
|
153
163
|
/**
|
|
154
164
|
* Optional reference to the parent capsule this one was forked or derived
|
|
155
165
|
* from. `null` (not `undefined`) is the explicit "no parent" sentinel so
|
package/src/types.ts
CHANGED
|
@@ -1884,6 +1884,7 @@ export interface PluginConfig
|
|
|
1884
1884
|
cmcBehaviorMinFrequency: number;
|
|
1885
1885
|
cmcBehaviorMinSessions: number;
|
|
1886
1886
|
cmcBehaviorConfidenceThreshold: number;
|
|
1887
|
+
/** @deprecated No effect: lifecycle scoring has no causal impact signal (#3667). Parsed so existing configs load. */
|
|
1887
1888
|
cmcLifecycleCausalImpactWeight: number;
|
|
1888
1889
|
|
|
1889
1890
|
// PEDC (Prediction-Error-Driven Calibration) — model-user alignment
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connectors/codex-materialize.ts","../src/connectors/materialize-paths.ts","../src/connectors/materialize-skills.ts"],"sourcesContent":["/**\n * codex-materialize.ts — Codex CLI native memory artifact materialization (#378)\n *\n * Periodically writes Remnic memories into the file layout that Codex CLI's\n * phase-2 consolidation reads directly under `<codex_home>/memories/`:\n *\n * memory_summary.md — always-loaded at session start (tight budget)\n * MEMORY.md — searchable handbook (task-group schema)\n * raw_memories.md — mechanical merge of raw memories, latest first\n * rollout_summaries/<slug>.md — per-session recaps\n *\n * Codex's own read path is agnostic to which producer wrote these files — it\n * tags reads by `memory_md` / `memory_summary` / `raw_memories` /\n * `rollout_summaries` / `skills`. By materializing Remnic content into this\n * exact layout we let Codex pick up Remnic memories without a single MCP call.\n *\n * Safety invariants\n * ─────────────────\n * - **Atomic writes.** Every file is rendered under `.remnic-tmp/` and then\n * `rename()`d into place so Codex never observes a half-written file.\n * - **Sentinel-based opt-in.** If `<codex_home>/memories/.remnic-managed` is\n * missing, we SKIP materialization entirely and log a warning. This honors\n * user hand-edits to the directory — a user who manually curated their\n * Codex memory layout will never have those edits overwritten.\n * - **Schema validation.** `MEMORY.md` content is validated against the\n * task-group schema before write. Invalid content throws and nothing is\n * written.\n * - **Idempotent no-ops.** A content hash is written into the sentinel. If\n * the re-rendered hash matches the previous run, we skip writes entirely.\n * - **Token budget.** `memory_summary.md` is truncated to fit under the\n * configured script-aware token estimate, leaving headroom under Codex's\n * 5000-token summary cap.\n *\n * Privacy\n * ───────\n * This module does not persist any user content outside `<codex_home>/memories`\n * — it only mirrors the memories that Remnic already wrote. It does not log\n * memory content to stdout; it logs file names, counts, and hashes.\n */\n\nimport {\n createHash,\n} from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { log } from \"../logger.js\";\nimport { readEnvVar, resolveHomeDir } from \"../runtime/env.js\";\nimport type { MemoryFile } from \"../types.js\";\nimport { estimateTokenCount } from \"../token-estimate.js\";\nimport type { SkillBundle } from \"../procedural/skill-projection.js\";\nimport { expandTildePath } from \"../utils/path.js\";\nimport { ensureSafeManagedSubdir } from \"./materialize-paths.js\";\nimport {\n commitSkillFiles,\n planSkillFiles,\n retiredSkillsAlreadyRemoved,\n skillFilePath,\n skillFileRelPath,\n stageSkillFiles,\n type SkillFile,\n} from \"./materialize-skills.js\";\n\n// ─── Types ─────────────────────────────────────────────────────────────────\n\n/**\n * Input for {@link materializeForNamespace}. Prefer passing pre-loaded\n * `memories` so this module stays I/O-agnostic and trivially testable.\n */\nexport interface MaterializeOptions {\n /** Pre-loaded Remnic memories for this namespace (required). */\n memories: MemoryFile[];\n /** Override `<codex_home>`. Defaults to `$CODEX_HOME` or `~/.codex`. */\n codexHome?: string;\n /** Maximum estimated token size of memory_summary.md. Default 4500. */\n maxSummaryTokens?: number;\n /** Maximum age of rollout_summaries/*.md in days. Default 30. */\n rolloutRetentionDays?: number;\n /** Per-session rollout summaries to render. */\n rolloutSummaries?: RolloutSummaryInput[];\n /**\n * Projected procedural skill bundles (issue #2369). `undefined` leaves\n * `skills/` untouched; an array — even an empty one — is authoritative for\n * the slugs Remnic projected, so retired procedures get their folder\n * removed. Folders this materializer never projected are never touched.\n */\n skills?: SkillBundle[];\n /** Current time, injected for deterministic tests. */\n now?: Date;\n /** Optional logger override for tests. */\n logger?: { info: (msg: string) => void; warn: (msg: string) => void; debug?: (msg: string) => void };\n}\n\n/** Input describing one Codex rollout summary file. */\nexport interface RolloutSummaryInput {\n /** Stable slug for the file (becomes `<slug>.md`). */\n slug: string;\n /** Working directory used during the rollout. */\n cwd?: string;\n /** Path to the raw Codex rollout log, if known. */\n rolloutPath?: string;\n /** ISO-8601 timestamp of the last update. */\n updatedAt?: string;\n /** Opaque thread / session id. */\n threadId?: string;\n /** Markdown body for the recap. */\n body: string;\n /** Freeform keywords / search hints. */\n keywords?: string[];\n}\n\n/** Result of a materialization run. */\nexport interface MaterializeResult {\n /** Namespace that was materialized. */\n namespace: string;\n /** `<codex_home>/memories` path this run targeted. */\n memoriesDir: string;\n /** Was anything actually written (vs. skipped / idempotent no-op)? */\n wrote: boolean;\n /** True if the sentinel was missing and we skipped with a warning. */\n skippedNoSentinel: boolean;\n /** True if the hash matched the previous run and we short-circuited. */\n skippedIdempotent: boolean;\n /** Files that were written this run (relative to `memoriesDir`). */\n filesWritten: string[];\n /** Content hash computed for this run. */\n contentHash: string;\n}\n\n/** On-disk shape of the `.remnic-managed` sentinel. */\ninterface SentinelFile {\n version: number;\n namespace: string;\n updated_at: string;\n content_hash: string;\n /**\n * Slugs under `skills/` that THIS materializer projected (issue #2369).\n * Absent on sentinels written before skill projection existed, which reads\n * as \"we have projected nothing\", so hand-created folders stay untouched.\n */\n projected_skills?: string[];\n}\n\n// ─── Constants ─────────────────────────────────────────────────────────────\n\n/** Bump when the on-disk layout or semantics change. */\nexport const MATERIALIZE_VERSION = 1;\n\n/** Sentinel file name at the root of the materialized memories dir. */\nexport const SENTINEL_FILE = \".remnic-managed\";\n\n/** Scratch directory used for atomic renames. */\nexport const TMP_DIR = \".remnic-tmp\";\n\n/** File names we own. Anything else in the directory is considered user-managed. */\nconst OWNED_FILES = new Set<string>([\n \"memory_summary.md\",\n \"MEMORY.md\",\n \"raw_memories.md\",\n]);\n\n/** Sub-directory for per-session rollout recaps. */\nconst ROLLOUT_SUBDIR = \"rollout_summaries\";\n\n// ─── Public entry points ───────────────────────────────────────────────────\n\n/**\n * Materialize a Remnic namespace into Codex's native memory layout.\n *\n * Returns a {@link MaterializeResult} describing what happened. Callers\n * should treat \"skipped\" as success — the sentinel / idempotent cases are\n * expected and intentional.\n *\n * @throws if `MEMORY.md` fails schema validation (we do not write garbage).\n */\nexport function materializeForNamespace(\n namespace: string,\n options: MaterializeOptions,\n): MaterializeResult {\n const logger = options.logger ?? {\n info: (msg) => log.info(`[codex-materialize] ${msg}`),\n warn: (msg) => log.warn(`[codex-materialize] ${msg}`),\n debug: (msg) => log.debug(`[codex-materialize] ${msg}`),\n };\n const memoriesDir = resolveCodexMemoriesDir(options.codexHome);\n const now = options.now ?? new Date();\n // Honor `0` as \"no summary budget\" — parseConfig already clamps to non-\n // negative integers, so any provided number is meaningful. Only fall back\n // to the default when the caller did not provide the option at all.\n const maxSummaryTokens =\n typeof options.maxSummaryTokens === \"number\" && options.maxSummaryTokens >= 0\n ? options.maxSummaryTokens\n : 4500;\n const rolloutRetentionDays =\n typeof options.rolloutRetentionDays === \"number\" && options.rolloutRetentionDays >= 0\n ? options.rolloutRetentionDays\n : 30;\n\n // ── Sentinel check ─────────────────────────────────────────────────────\n // We deliberately do NOT `mkdirSync(memoriesDir)` before reading the\n // sentinel: creating `~/.codex/memories/` for every user (including ones\n // who never use Codex) would make Remnic's post-consolidation hook leave\n // empty opt-in directories behind on disk. Instead we only check whether\n // the sentinel already exists — if the parent dir doesn't exist, the\n // sentinel can't exist either and we fall straight through to the skip\n // path without touching the filesystem. The `mkdirSync` for `memoriesDir`\n // happens later, only once we know we're actually going to write.\n const sentinelPath = path.join(memoriesDir, SENTINEL_FILE);\n const existingSentinel = readSentinel(sentinelPath);\n if (!existingSentinel) {\n // Log at `debug` when the entire memories dir doesn't exist — that's\n // the common \"user never opted in\" case and should not be noisy.\n // Keep the `warn` level only when the dir exists but lacks a sentinel,\n // which is the \"user hand-curated layout, don't overwrite\" case that\n // genuinely warrants attention.\n if (fs.existsSync(memoriesDir)) {\n logger.warn(\n `sentinel ${SENTINEL_FILE} missing in ${memoriesDir}; skipping materialization to preserve hand-edits`,\n );\n } else {\n logger.debug?.(\n `skipping materialization — ${memoriesDir} does not exist (user not opted in)`,\n );\n }\n return {\n namespace,\n memoriesDir,\n wrote: false,\n skippedNoSentinel: true,\n skippedIdempotent: false,\n filesWritten: [],\n contentHash: \"\",\n };\n }\n\n // Now that we know the user has opted in (sentinel exists), it's safe to\n // ensure the memories dir is present. In practice this is almost always a\n // no-op because the sentinel read above already succeeded, but a defensive\n // mkdirSync protects against a race where the dir was removed between the\n // sentinel read and the first write.\n fs.mkdirSync(memoriesDir, { recursive: true });\n\n // ── Render ─────────────────────────────────────────────────────────────\n const memories = [...options.memories];\n // Track whether the caller actually supplied a rollout set. `undefined`\n // means \"don't touch rollout_summaries/\"; an empty array is still\n // authoritative and means \"we own this dir and it should be empty\".\n const rolloutsSupplied = options.rolloutSummaries !== undefined;\n const rolloutSummaries = options.rolloutSummaries ?? [];\n\n // Prune-before-render: MEMORY.md and memory_summary.md both embed rollout\n // filenames in their body, so they must only ever see the *retained* set.\n // Running pruneRollouts after the renderers (as an earlier revision did)\n // caused MEMORY.md to list `rollout_summaries/<slug>.md` paths for rollouts\n // that were then pruned and never written — a broken link pointing at a\n // ghost file. See review feedback on PR #392.\n const retainedRollouts = pruneRollouts(rolloutSummaries, rolloutRetentionDays, now);\n\n // Deduplicate on sanitized filename. Two different slugs (\"Session 1\" and\n // \"session!!!1\") can sanitize to the same output (\"session-1\"), which would\n // otherwise make the first entry's tmp file get overwritten and cause the\n // later rename step to crash with ENOENT. For each collision slot we keep\n // the entry with the newest `updatedAt` so an unsorted input (or a caller\n // that accidentally appends older recaps after newer ones) can't have an\n // older recap clobber a newer one.\n // We do this at the retained-input level (not just at the written-file\n // level) so MEMORY.md's \"rollout_summary_files\" section lists each slot\n // exactly once and matches what actually gets written to disk.\n const dedupedRollouts: RolloutSummaryInput[] = [];\n const seenNames = new Map<string, number>();\n const parseTs = (value: string | undefined): number => {\n if (!value) return Number.NEGATIVE_INFINITY;\n const parsed = Date.parse(value);\n return Number.isFinite(parsed) ? parsed : Number.NEGATIVE_INFINITY;\n };\n for (const r of retainedRollouts) {\n const name = `${sanitizeSlug(r.slug)}.md`;\n const existingIdx = seenNames.get(name);\n if (existingIdx === undefined) {\n seenNames.set(name, dedupedRollouts.length);\n dedupedRollouts.push(r);\n continue;\n }\n // Newest-wins: only replace the existing entry if the incoming one has a\n // strictly newer timestamp. Ties keep the earlier entry (stable for\n // unsorted inputs) because overwriting on ties would flip rendering output\n // for benign call-order changes.\n const existing = dedupedRollouts[existingIdx];\n if (parseTs(r.updatedAt) > parseTs(existing.updatedAt)) {\n dedupedRollouts[existingIdx] = r;\n }\n }\n\n const memorySummary = renderMemorySummary({\n namespace,\n memories,\n rolloutSummaries: dedupedRollouts,\n maxTokens: maxSummaryTokens,\n });\n\n const memoryMd = renderMemoryMd({\n namespace,\n memories,\n rolloutSummaries: dedupedRollouts,\n });\n\n // Fail fast on schema issues — do not write garbage.\n const validation = validateMemoryMd(memoryMd);\n if (!validation.valid) {\n const reason = validation.errors.join(\"; \");\n logger.warn(`MEMORY.md failed schema validation: ${reason}`);\n throw new Error(`codex-materialize: MEMORY.md schema validation failed: ${reason}`);\n }\n\n const rawMemories = renderRawMemories({ memories });\n\n const rolloutFiles = dedupedRollouts.map((r) => ({\n name: `${sanitizeSlug(r.slug)}.md`,\n body: renderRolloutSummary(r),\n }));\n const destRolloutsDir = path.join(memoriesDir, ROLLOUT_SUBDIR);\n const retainedRolloutNames = new Set(rolloutFiles.map((r) => r.name));\n\n // Skill bundles (issue #2369) — planning, ownership, and disk layout live in\n // materialize-skills.ts.\n const skillPlan = planSkillFiles(options.skills, existingSentinel.projected_skills ?? []);\n\n // ── Idempotence check ──────────────────────────────────────────────────\n const hash = computeContentHash({\n namespace,\n memorySummary,\n memoryMd,\n rawMemories,\n rolloutFiles,\n skillFiles: skillPlan.files,\n });\n\n if (existingSentinel.content_hash === hash) {\n // Idempotence early-return is only safe when the managed files we would\n // have written are still on disk. If a user or external process deleted\n // `MEMORY.md` / `memory_summary.md` / `raw_memories.md` (or any retained\n // rollout file) while the sentinel's hash stayed the same, we must fall\n // through and rewrite — otherwise Codex would be stuck with missing\n // artifacts until a memory-content change happens to flip the hash.\n const requiredFiles = [\n path.join(memoriesDir, \"memory_summary.md\"),\n path.join(memoriesDir, \"MEMORY.md\"),\n path.join(memoriesDir, \"raw_memories.md\"),\n ...rolloutFiles.map((r) => path.join(memoriesDir, ROLLOUT_SUBDIR, r.name)),\n ...skillPlan.files.map((s) => skillFilePath(memoriesDir, s.slug)),\n ];\n const allPresent = requiredFiles.every((f) => fs.existsSync(f));\n const rolloutsClean =\n !rolloutsSupplied ||\n rolloutDirectoryMatchesRetainedSet(\n ensureSafeManagedSubdir(memoriesDir, destRolloutsDir, ROLLOUT_SUBDIR),\n retainedRolloutNames,\n );\n const skillsClean = retiredSkillsAlreadyRemoved(memoriesDir, skillPlan.retiredSlugs);\n if (allPresent && rolloutsClean && skillsClean) {\n logger.debug?.(`no-op materialization for namespace=${namespace} (hash unchanged)`);\n return {\n namespace,\n memoriesDir,\n wrote: false,\n skippedNoSentinel: false,\n skippedIdempotent: true,\n filesWritten: [],\n contentHash: hash,\n };\n }\n logger.debug?.(\n `hash unchanged for namespace=${namespace} but managed files need refresh — forcing rewrite`,\n );\n }\n\n // ── Atomic writes ──────────────────────────────────────────────────────\n // Use a unique, per-run staging sub-directory so two overlapping runs\n // (e.g. a session-end trigger overlapping with a consolidation post-hook)\n // can't stomp each other's tmp files mid-rename. The old \"fixed TMP_DIR,\n // wipe-on-entry\" layout meant run B would delete run A's staging area out\n // from under it, causing ENOENT on A's rename loop. Per-run uniqueness\n // turns the shared dir into an insulated workspace. See review feedback on\n // PR #392.\n const runTag = `${process.pid}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n const tmpDir = path.join(memoriesDir, `${TMP_DIR}-${runTag}`);\n // Opportunistic GC for stale scratch dirs left behind by a previous\n // crashed run. We only remove entries whose mtime is older than the\n // stale-threshold below — that way we never delete another in-flight\n // run's staging area out from under it. The threshold is deliberately\n // generous (1h) because a healthy materialize completes in milliseconds\n // and there's no legitimate reason for a live staging dir to be older.\n //\n // NB: we compare against `Date.now()` (wall-clock), not against the\n // injected `options.now`. Tests and deterministic replays commonly\n // inject a non-current timestamp, but file mtimes on disk are always\n // wall-clock, so mixing the two would either false-positive delete\n // fresh dirs (test-time in the past) or false-negative skip stale ones\n // (test-time in the future).\n const TMP_STALE_MS = 60 * 60 * 1000;\n const wallClockMs = Date.now();\n try {\n for (const entry of fs.readdirSync(memoriesDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n if (!entry.name.startsWith(TMP_DIR)) continue;\n const stalePath = path.join(memoriesDir, entry.name);\n try {\n const stat = fs.statSync(stalePath);\n if (wallClockMs - stat.mtimeMs < TMP_STALE_MS) continue;\n fs.rmSync(stalePath, { recursive: true, force: true });\n } catch {\n // ignore — another concurrent run may own it, or we lack perms\n }\n }\n } catch {\n // ignore — dir may not exist yet\n }\n fs.mkdirSync(tmpDir, { recursive: true });\n fs.mkdirSync(path.join(tmpDir, ROLLOUT_SUBDIR), { recursive: true });\n\n const filesWritten: string[] = [];\n\n fs.writeFileSync(path.join(tmpDir, \"memory_summary.md\"), memorySummary);\n filesWritten.push(\"memory_summary.md\");\n\n fs.writeFileSync(path.join(tmpDir, \"MEMORY.md\"), memoryMd);\n filesWritten.push(\"MEMORY.md\");\n\n fs.writeFileSync(path.join(tmpDir, \"raw_memories.md\"), rawMemories);\n filesWritten.push(\"raw_memories.md\");\n\n for (const rollout of rolloutFiles) {\n fs.writeFileSync(path.join(tmpDir, ROLLOUT_SUBDIR, rollout.name), rollout.body);\n filesWritten.push(path.join(ROLLOUT_SUBDIR, rollout.name));\n }\n\n stageSkillFiles(tmpDir, skillPlan.files);\n for (const skill of skillPlan.files) {\n filesWritten.push(skillFileRelPath(skill.slug));\n }\n\n // Rename into place. Atomic per-file is sufficient — Codex reads each file\n // independently and tolerates an inconsistent in-between snapshot across\n // files for the duration of the rename loop (milliseconds).\n for (const rel of [\"memory_summary.md\", \"MEMORY.md\", \"raw_memories.md\"]) {\n const src = path.join(tmpDir, rel);\n const dest = path.join(memoriesDir, rel);\n fs.renameSync(src, dest);\n }\n\n const safeDestRolloutsDir = ensureSafeManagedSubdir(memoriesDir, destRolloutsDir, ROLLOUT_SUBDIR);\n // Only garbage-collect rollout files when the caller actually supplied a\n // `rolloutSummaries` array — otherwise we'd wipe legitimately\n // user/Codex-created recap files on every session-end run, since those\n // calls typically omit the rollout set entirely. When rollouts were\n // supplied (even as an empty array — meaning \"we own this dir and it\n // should be empty\"), we clear the stale files we previously owned.\n if (rolloutsSupplied) {\n let existingRollouts: fs.Dirent[];\n try {\n existingRollouts = fs.readdirSync(safeDestRolloutsDir, { withFileTypes: true });\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err;\n existingRollouts = [];\n }\n for (const entry of existingRollouts) {\n if (!entry.isFile()) continue;\n if (!entry.name.endsWith(\".md\")) continue;\n if (retainedRolloutNames.has(entry.name)) continue;\n try {\n fs.unlinkSync(path.join(safeDestRolloutsDir, entry.name));\n } catch (err) {\n throw new Error(\n `codex-materialize: failed to prune stale rollout summary ${entry.name}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n }\n\n for (const rollout of rolloutFiles) {\n const src = path.join(tmpDir, ROLLOUT_SUBDIR, rollout.name);\n const dest = path.join(safeDestRolloutsDir, rollout.name);\n fs.renameSync(src, dest);\n }\n\n commitSkillFiles(memoriesDir, tmpDir, skillPlan);\n\n // Update sentinel last so a crash leaves hash mismatched → next run rewrites.\n const sentinel: SentinelFile = {\n version: MATERIALIZE_VERSION,\n namespace,\n updated_at: now.toISOString(),\n content_hash: hash,\n projected_skills: skillPlan.supplied\n ? skillPlan.files.map((s) => s.slug)\n : (existingSentinel.projected_skills ?? []),\n };\n writeSentinelAtomically(sentinelPath, sentinel);\n\n try {\n fs.rmSync(tmpDir, { recursive: true, force: true });\n } catch {\n // ignore\n }\n\n logger.info(\n `materialized namespace=${namespace} files=${filesWritten.length} hash=${hash.slice(0, 12)}`,\n );\n\n return {\n namespace,\n memoriesDir,\n wrote: true,\n skippedNoSentinel: false,\n skippedIdempotent: false,\n filesWritten,\n contentHash: hash,\n };\n}\n\n/**\n * Create (or refresh) the `.remnic-managed` sentinel. Callers must do this\n * explicitly the first time they want Remnic to start managing a directory —\n * we never write it implicitly, because its presence is the user's opt-in.\n */\nexport function ensureSentinel(memoriesDir: string, namespace: string, now: Date = new Date()): void {\n fs.mkdirSync(memoriesDir, { recursive: true });\n const sentinelPath = path.join(memoriesDir, SENTINEL_FILE);\n if (fs.existsSync(sentinelPath)) {\n readSentinel(sentinelPath);\n return;\n }\n const sentinel: SentinelFile = {\n version: MATERIALIZE_VERSION,\n namespace,\n updated_at: now.toISOString(),\n content_hash: \"\",\n };\n writeSentinelAtomically(sentinelPath, sentinel);\n}\n\n// ─── Rendering ─────────────────────────────────────────────────────────────\n\ninterface RenderContext {\n namespace: string;\n memories: MemoryFile[];\n rolloutSummaries: RolloutSummaryInput[];\n // Historically this interface exposed a `now: Date` field, but neither\n // `renderMemoryMd` nor `renderMemorySummary` ever read it (rendered output\n // is purely a function of `namespace`, `memories`, and `rolloutSummaries`).\n // The field was flagged as dead weight in PR #392 review and removed.\n // If a future renderer needs a timestamp, re-add it here and update both\n // call sites and the schema test.\n}\n\ninterface SummaryRenderContext extends RenderContext {\n maxTokens: number;\n}\n\n/**\n * Render `memory_summary.md` — the always-loaded file.\n * Budget-capped at `maxTokens` whitespace tokens.\n */\nexport function renderMemorySummary(ctx: SummaryRenderContext): string {\n const lines: string[] = [];\n lines.push(\"# Memory Summary\");\n lines.push(\"\");\n lines.push(`_namespace: ${ctx.namespace}_`);\n lines.push(`_source: remnic_`);\n lines.push(\"\");\n\n const highValue = selectSummaryMemories(ctx.memories, 12);\n if (highValue.length > 0) {\n lines.push(\"## Top memories\");\n lines.push(\"\");\n for (const mem of highValue) {\n lines.push(`- ${oneLineSummary(mem)}`);\n }\n lines.push(\"\");\n }\n\n if (ctx.rolloutSummaries.length > 0) {\n lines.push(\"## Recent rollouts\");\n lines.push(\"\");\n const sorted = [...ctx.rolloutSummaries]\n .sort((a, b) => (b.updatedAt ?? \"\").localeCompare(a.updatedAt ?? \"\"))\n .slice(0, 5);\n for (const r of sorted) {\n const when = r.updatedAt ? ` (${r.updatedAt})` : \"\";\n lines.push(`- ${r.slug}${when}`);\n }\n lines.push(\"\");\n }\n\n // Collapse trailing newlines to one without the anchored /\\n+$/ quantifier,\n // which backtracks polynomially (CodeQL js/polynomial-redos).\n const joined = lines.join(\"\\n\");\n let joinedEnd = joined.length;\n while (joinedEnd > 0 && joined[joinedEnd - 1] === \"\\n\") joinedEnd--;\n const full = joinedEnd === joined.length ? joined : `${joined.slice(0, joinedEnd)}\\n`;\n return truncateToTokenBudget(full, ctx.maxTokens);\n}\n\n/**\n * Render `MEMORY.md` — the searchable handbook in Codex's task-group schema.\n */\nexport function renderMemoryMd(ctx: RenderContext): string {\n const lines: string[] = [];\n lines.push(`# Task Group: ${ctx.namespace}`);\n lines.push(`scope: ${ctx.namespace}`);\n lines.push(`applies_to: cwd=*; reuse_rule=namespace-match`);\n lines.push(\"\");\n\n // One \"task\" per top-level topic cluster. For the first cut we group by\n // memory category so the schema validator always sees at least one task.\n const byCategory = groupMemoriesByCategory(ctx.memories);\n let taskIndex = 1;\n if (byCategory.size === 0) {\n lines.push(`## Task ${taskIndex}: baseline — no memories yet`);\n lines.push(\"\");\n lines.push(\"### rollout_summary_files\");\n for (const r of ctx.rolloutSummaries) {\n lines.push(\n `- rollout_summaries/${sanitizeSlug(r.slug)}.md (cwd=${r.cwd ?? \"*\"}, rollout_path=${r.rolloutPath ?? \"\"}, updated_at=${r.updatedAt ?? \"\"}, thread_id=${r.threadId ?? \"\"})`,\n );\n }\n if (ctx.rolloutSummaries.length === 0) {\n lines.push(\"- (none)\");\n }\n lines.push(\"\");\n lines.push(\"### keywords\");\n lines.push(`- ${ctx.namespace}`);\n lines.push(\"\");\n taskIndex += 1;\n } else {\n for (const [category, mems] of byCategory) {\n lines.push(`## Task ${taskIndex}: ${category} memories, outcome=surface-to-codex`);\n lines.push(\"\");\n lines.push(\"### rollout_summary_files\");\n const relevantRollouts = ctx.rolloutSummaries.slice(0, 5);\n if (relevantRollouts.length === 0) {\n lines.push(\"- (none)\");\n } else {\n for (const r of relevantRollouts) {\n lines.push(\n `- rollout_summaries/${sanitizeSlug(r.slug)}.md (cwd=${r.cwd ?? \"*\"}, rollout_path=${r.rolloutPath ?? \"\"}, updated_at=${r.updatedAt ?? \"\"}, thread_id=${r.threadId ?? \"\"})`,\n );\n }\n }\n lines.push(\"\");\n lines.push(\"### keywords\");\n const keywords = collectKeywords(mems, category, ctx.namespace);\n lines.push(`- ${keywords.join(\", \")}`);\n lines.push(\"\");\n taskIndex += 1;\n }\n }\n\n lines.push(\"## User preferences\");\n const prefs = pickCategory(ctx.memories, [\"preference\"]);\n if (prefs.length === 0) {\n lines.push(\"- (none recorded)\");\n } else {\n for (const pref of prefs.slice(0, 20)) {\n lines.push(`- ${oneLineSummary(pref)}`);\n }\n }\n lines.push(\"\");\n\n lines.push(\"## Reusable knowledge\");\n const knowledge = pickCategory(ctx.memories, [\"fact\", \"decision\", \"principle\", \"rule\", \"skill\"]);\n if (knowledge.length === 0) {\n lines.push(\"- (none recorded)\");\n } else {\n for (const mem of knowledge.slice(0, 30)) {\n lines.push(`- ${oneLineSummary(mem)}`);\n }\n }\n lines.push(\"\");\n\n lines.push(\"## Failures and how to do differently\");\n const corrections = pickCategory(ctx.memories, [\"correction\"]);\n if (corrections.length === 0) {\n lines.push(\"- (none recorded)\");\n } else {\n for (const mem of corrections.slice(0, 20)) {\n lines.push(`- ${oneLineSummary(mem)}`);\n }\n }\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n}\n\n/** Render `raw_memories.md` — mechanical dump, latest first. */\nexport function renderRawMemories(ctx: { memories: MemoryFile[] }): string {\n const sorted = [...ctx.memories].sort((a, b) => {\n const aUpdated = a.frontmatter.updated ?? a.frontmatter.created ?? \"\";\n const bUpdated = b.frontmatter.updated ?? b.frontmatter.created ?? \"\";\n return bUpdated.localeCompare(aUpdated);\n });\n\n const lines: string[] = [\"# Raw Memories\", \"\", \"_source: remnic — latest first_\", \"\"];\n for (const mem of sorted) {\n const fm = mem.frontmatter;\n const id = fm.id ?? \"unknown\";\n const category = fm.category ?? \"unknown\";\n const updated = fm.updated ?? fm.created ?? \"\";\n lines.push(`## ${id} (${category}, updated=${updated})`);\n lines.push(\"\");\n lines.push(mem.content.trim());\n lines.push(\"\");\n }\n return lines.join(\"\\n\");\n}\n\n/** Render a single rollout summary file. */\nexport function renderRolloutSummary(input: RolloutSummaryInput): string {\n const lines: string[] = [];\n lines.push(`# Rollout Summary: ${input.slug}`);\n lines.push(\"\");\n const meta: string[] = [];\n if (input.cwd) meta.push(`cwd=${input.cwd}`);\n if (input.rolloutPath) meta.push(`rollout_path=${input.rolloutPath}`);\n if (input.updatedAt) meta.push(`updated_at=${input.updatedAt}`);\n if (input.threadId) meta.push(`thread_id=${input.threadId}`);\n if (meta.length > 0) {\n lines.push(`_${meta.join(\"; \")}_`);\n lines.push(\"\");\n }\n if (input.keywords && input.keywords.length > 0) {\n lines.push(`**keywords:** ${input.keywords.join(\", \")}`);\n lines.push(\"\");\n }\n lines.push(input.body.trim());\n lines.push(\"\");\n return lines.join(\"\\n\");\n}\n\n// ─── Schema validation ─────────────────────────────────────────────────────\n\nexport interface MemoryMdValidation {\n valid: boolean;\n errors: string[];\n}\n\n/**\n * Validate that a rendered `MEMORY.md` matches Codex's task-group schema.\n * We enforce the minimum set of structural requirements called out in #378:\n *\n * - one `# Task Group:` header\n * - `scope:` and `applies_to:` lines directly beneath it\n * - at least one `## Task N:` section\n * - each task section has `### rollout_summary_files` and `### keywords`\n * - `## User preferences`, `## Reusable knowledge`,\n * `## Failures and how to do differently` sections all present\n */\nexport function validateMemoryMd(content: string): MemoryMdValidation {\n const errors: string[] = [];\n const lines = content.split(/\\r?\\n/u);\n\n const taskGroupIndex = lines.findIndex((l) => /^#\\s+Task Group:\\s+\\S+/u.test(l));\n if (taskGroupIndex === -1) {\n errors.push(\"missing `# Task Group:` header\");\n } else {\n const tail = lines.slice(taskGroupIndex + 1, taskGroupIndex + 5);\n if (!tail.some((l) => /^scope:\\s*\\S+/u.test(l))) {\n errors.push(\"missing `scope:` line under Task Group header\");\n }\n if (!tail.some((l) => /^applies_to:\\s*\\S+/u.test(l))) {\n errors.push(\"missing `applies_to:` line under Task Group header\");\n }\n }\n\n const taskHeaders = lines.filter((l) => /^##\\s+Task\\s+\\d+:/u.test(l));\n if (taskHeaders.length === 0) {\n errors.push(\"at least one `## Task N:` section is required\");\n }\n\n // For every task section, make sure we have rollout_summary_files + keywords\n // before the next `##` header at the same level.\n const sectionRegex = /^##\\s+/u;\n for (let i = 0; i < lines.length; i++) {\n if (!/^##\\s+Task\\s+\\d+:/u.test(lines[i])) continue;\n let hasRollout = false;\n let hasKeywords = false;\n for (let j = i + 1; j < lines.length; j++) {\n if (sectionRegex.test(lines[j])) break;\n if (/^###\\s+rollout_summary_files\\s*$/u.test(lines[j])) hasRollout = true;\n if (/^###\\s+keywords\\s*$/u.test(lines[j])) hasKeywords = true;\n }\n if (!hasRollout) errors.push(`task block at line ${i + 1} missing \\`### rollout_summary_files\\``);\n if (!hasKeywords) errors.push(`task block at line ${i + 1} missing \\`### keywords\\``);\n }\n\n const requiredSections = [\n /^##\\s+User preferences\\s*$/u,\n /^##\\s+Reusable knowledge\\s*$/u,\n /^##\\s+Failures and how to do differently\\s*$/u,\n ];\n for (const re of requiredSections) {\n if (!lines.some((l) => re.test(l))) {\n errors.push(`missing required section: ${re.source}`);\n }\n }\n\n return { valid: errors.length === 0, errors };\n}\n\n// ─── Helpers ───────────────────────────────────────────────────────────────\n\nfunction resolveCodexHome(override?: string): string {\n if (override && override.trim().length > 0) {\n return path.resolve(expandTildePath(override.trim()));\n }\n const fromEnv = readEnvVar(\"CODEX_HOME\");\n if (fromEnv && fromEnv.trim().length > 0) {\n return path.resolve(expandTildePath(fromEnv.trim()));\n }\n return path.resolve(resolveHomeDir(), \".codex\");\n}\n\nexport function resolveCodexMemoriesDir(codexHome?: string): string {\n return path.join(resolveCodexHome(codexHome), \"memories\");\n}\n\nexport function hasCodexMaterializeSentinel(codexHome?: string): boolean {\n return readSentinel(path.join(resolveCodexMemoriesDir(codexHome), SENTINEL_FILE)) !== null;\n}\n\nfunction rolloutDirectoryMatchesRetainedSet(\n rolloutsDir: string,\n retainedNames: Set<string>,\n): boolean {\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(rolloutsDir, { withFileTypes: true });\n } catch {\n return retainedNames.size === 0;\n }\n for (const entry of entries) {\n if (!entry.isFile()) continue;\n if (!entry.name.endsWith(\".md\")) continue;\n if (!retainedNames.has(entry.name)) return false;\n }\n return true;\n}\n\nfunction readSentinel(sentinelPath: string): SentinelFile | null {\n if (!fs.existsSync(sentinelPath)) return null;\n try {\n const raw = fs.readFileSync(sentinelPath, \"utf-8\");\n const parsed = JSON.parse(raw) as Partial<SentinelFile>;\n if (\n typeof parsed !== \"object\" ||\n parsed === null ||\n typeof parsed.version !== \"number\" ||\n typeof parsed.namespace !== \"string\" ||\n typeof parsed.updated_at !== \"string\" ||\n typeof parsed.content_hash !== \"string\"\n ) {\n throw new Error(\"invalid sentinel schema\");\n }\n // A sentinel written before issue #2369 has no `projected_skills`, which\n // reads as \"nothing projected\" — so an unrelated skills/ folder written by\n // a user or another tool is never treated as ours.\n const projected = Array.isArray(parsed.projected_skills)\n ? parsed.projected_skills.filter((slug): slug is string => typeof slug === \"string\")\n : [];\n return {\n version: parsed.version,\n namespace: parsed.namespace,\n updated_at: parsed.updated_at,\n content_hash: parsed.content_hash,\n projected_skills: projected,\n };\n } catch (err) {\n throw new Error(\n `codex-materialize: corrupt ${SENTINEL_FILE} sentinel at ${sentinelPath}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n}\n\nfunction writeSentinelAtomically(\n sentinelPath: string,\n sentinel: SentinelFile,\n): void {\n const tmpPath = `${sentinelPath}.${process.pid}.${Date.now()}.${Math.random()\n .toString(16)\n .slice(2)}.tmp`;\n try {\n fs.writeFileSync(tmpPath, `${JSON.stringify(sentinel, null, 2)}\\n`, {\n flag: \"wx\",\n });\n fs.renameSync(tmpPath, sentinelPath);\n } catch (err) {\n try {\n fs.rmSync(tmpPath, { force: true });\n } catch {\n // ignore cleanup failures; preserve the original write/rename error\n }\n throw err;\n }\n}\n\nfunction selectSummaryMemories(memories: MemoryFile[], limit: number): MemoryFile[] {\n const scored = memories\n .filter((m) => !m.frontmatter.status || m.frontmatter.status === \"active\")\n .map((m) => {\n const confidence = typeof m.frontmatter.confidence === \"number\" ? m.frontmatter.confidence : 0;\n const importance =\n typeof m.frontmatter.importance === \"object\" &&\n m.frontmatter.importance !== null &&\n typeof (m.frontmatter.importance as { score?: number }).score === \"number\"\n ? ((m.frontmatter.importance as { score: number }).score ?? 0)\n : 0;\n const updated = m.frontmatter.updated ?? m.frontmatter.created ?? \"\";\n return { memory: m, score: importance * 2 + confidence, updated };\n });\n\n scored.sort((a, b) => {\n if (b.score !== a.score) return b.score - a.score;\n return b.updated.localeCompare(a.updated);\n });\n\n return scored.slice(0, limit).map((s) => s.memory);\n}\n\nfunction oneLineSummary(memory: MemoryFile): string {\n const raw = memory.content.replace(/\\s+/gu, \" \").trim();\n if (raw.length <= 160) return raw;\n return `${raw.slice(0, 157)}...`;\n}\n\nfunction groupMemoriesByCategory(memories: MemoryFile[]): Map<string, MemoryFile[]> {\n const map = new Map<string, MemoryFile[]>();\n for (const memory of memories) {\n if (memory.frontmatter.status && memory.frontmatter.status !== \"active\") continue;\n const category = memory.frontmatter.category ?? \"unknown\";\n const list = map.get(category) ?? [];\n list.push(memory);\n map.set(category, list);\n }\n return map;\n}\n\nfunction pickCategory(memories: MemoryFile[], categories: string[]): MemoryFile[] {\n const allowed = new Set(categories);\n return memories.filter(\n (m) =>\n (!m.frontmatter.status || m.frontmatter.status === \"active\") &&\n allowed.has(m.frontmatter.category ?? \"\"),\n );\n}\n\nfunction collectKeywords(memories: MemoryFile[], category: string, namespace: string): string[] {\n const keywords = new Set<string>();\n keywords.add(category);\n keywords.add(namespace);\n for (const mem of memories.slice(0, 10)) {\n for (const tag of mem.frontmatter.tags ?? []) {\n if (typeof tag === \"string\" && tag.trim().length > 0) keywords.add(tag.trim());\n }\n }\n return [...keywords].slice(0, 16);\n}\n\nfunction pruneRollouts(\n rollouts: RolloutSummaryInput[],\n retentionDays: number,\n now: Date,\n): RolloutSummaryInput[] {\n // Negative retention → \"infinite retention\" escape hatch. `parseConfig`\n // clamps the knob to >= 0, so in practice only callers passing a negative\n // value intentionally get the all-pass behavior.\n if (retentionDays < 0) return rollouts;\n // retentionDays === 0 → cutoff is exactly `now`, which prunes every\n // rollout whose `updatedAt` is in the past (i.e. all of them in practice).\n // This matches the documented semantics of \"retain for 0 days\".\n const cutoffMs = now.getTime() - retentionDays * 24 * 60 * 60 * 1000;\n return rollouts.filter((r) => {\n if (!r.updatedAt) return true;\n const t = Date.parse(r.updatedAt);\n if (!Number.isFinite(t)) return true;\n return t >= cutoffMs;\n });\n}\n\nfunction sanitizeSlug(slug: string): string {\n const sanitized = slug\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/gu, \"-\")\n .slice(0, 96);\n const trimmed = trimHyphenEdges(sanitized);\n return trimmed || \"rollout\";\n}\n\nfunction trimHyphenEdges(value: string): string {\n let start = 0;\n let end = value.length;\n while (start < end && value[start] === \"-\") start += 1;\n while (end > start && value[end - 1] === \"-\") end -= 1;\n return value.slice(start, end);\n}\n/** Shared script-aware approximation used by the budget check. */\nexport function approximateTokenCount(text: string): number {\n return estimateTokenCount(text);\n}\n\n/**\n * Truncate `text` so it fits under `maxTokens`. We drop trailing lines until\n * under budget, then append a marker so readers can see that truncation occurred.\n */\nexport function truncateToTokenBudget(text: string, maxTokens: number): string {\n if (maxTokens <= 0) return \"\";\n if (approximateTokenCount(text) <= maxTokens) return text;\n\n const lineMarker = \"_[truncated for summary budget]_\";\n const tailMarker = \"[truncated]\";\n if (approximateTokenCount(tailMarker) > maxTokens) return \"\";\n const lineMarkerTokens = approximateTokenCount(lineMarker);\n\n const lines = text.split(/\\r?\\n/u);\n const lineBudget = Math.max(0, maxTokens - lineMarkerTokens);\n while (lines.length > 0 && approximateTokenCount(lines.join(\"\\n\")) > lineBudget) {\n lines.pop();\n }\n lines.push(lineMarker);\n let result = lines.join(\"\\n\");\n\n if (approximateTokenCount(result) > maxTokens) {\n const codePoints = [...result];\n let low = 0;\n let high = codePoints.length;\n while (low < high) {\n const mid = Math.ceil((low + high) / 2);\n const prefix = codePoints.slice(0, mid).join(\"\");\n const candidate = prefix.length > 0 ? `${prefix} ${tailMarker}` : tailMarker;\n if (approximateTokenCount(candidate) <= maxTokens) low = mid;\n else high = mid - 1;\n }\n const prefix = codePoints.slice(0, low).join(\"\");\n result = prefix.length > 0 ? `${prefix} ${tailMarker}` : tailMarker;\n }\n return result;\n}\n\nfunction computeContentHash(input: {\n namespace: string;\n memorySummary: string;\n memoryMd: string;\n rawMemories: string;\n rolloutFiles: Array<{ name: string; body: string }>;\n skillFiles: Array<{ slug: string; body: string }>;\n}): string {\n const hash = createHash(\"sha256\");\n hash.update(`v${MATERIALIZE_VERSION}\\n`);\n hash.update(`namespace=${input.namespace}\\n`);\n hash.update(\"---memory_summary---\\n\");\n hash.update(input.memorySummary);\n hash.update(\"\\n---memory_md---\\n\");\n hash.update(input.memoryMd);\n hash.update(\"\\n---raw_memories---\\n\");\n hash.update(input.rawMemories);\n const sortedRollouts = [...input.rolloutFiles].sort((a, b) => a.name.localeCompare(b.name));\n for (const r of sortedRollouts) {\n hash.update(`\\n---rollout:${r.name}---\\n`);\n hash.update(r.body);\n }\n // Sorted by slug so call order cannot flip the hash (§26).\n const sortedSkills = [...input.skillFiles].sort((a, b) => (a.slug < b.slug ? -1 : a.slug > b.slug ? 1 : 0));\n for (const s of sortedSkills) {\n hash.update(`\\n---skill:${s.slug}---\\n`);\n hash.update(s.body);\n }\n return hash.digest(\"hex\");\n}\n\n// ─── Stat helper for tests / debugging ─────────────────────────────────────\n\n/**\n * Return basic stats about a materialized memories dir. Useful for tests and\n * debug CLI output. Returns `null` if the dir does not exist.\n */\nexport function describeMemoriesDir(memoriesDir: string): {\n exists: boolean;\n hasSentinel: boolean;\n files: string[];\n sentinel: SentinelFile | null;\n} | null {\n if (!fs.existsSync(memoriesDir)) return null;\n const sentinelPath = path.join(memoriesDir, SENTINEL_FILE);\n const sentinel = readSentinel(sentinelPath);\n const files: string[] = [];\n for (const entry of fs.readdirSync(memoriesDir, { withFileTypes: true })) {\n if (entry.isFile() && OWNED_FILES.has(entry.name)) files.push(entry.name);\n }\n const rolloutsDir = path.join(memoriesDir, ROLLOUT_SUBDIR);\n if (fs.existsSync(rolloutsDir)) {\n try {\n for (const entry of fs.readdirSync(rolloutsDir, { withFileTypes: true })) {\n if (entry.isFile() && entry.name.endsWith(\".md\")) {\n files.push(path.join(ROLLOUT_SUBDIR, entry.name));\n }\n }\n } catch {\n // ignore\n }\n }\n return {\n exists: true,\n hasSentinel: sentinel !== null,\n files: files.sort(),\n sentinel,\n };\n}\n","/**\n * materialize-paths.ts — containment guard for the materializer's managed\n * sub-directories (`rollout_summaries/`, `skills/`).\n *\n * Extracted from codex-materialize.ts so the skills section (issue #2369) and\n * the rollout section share ONE containment implementation instead of forking\n * the check (rule 22).\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { pathIsInside } from \"../utils/path-containment.js\";\n\n/**\n * Resolve a managed sub-directory of `memoriesDir`, creating it when absent,\n * and refuse a symlinked or escaping target. Returns the (unchanged) path so\n * callers can use it directly.\n */\nexport function ensureSafeManagedSubdir(memoriesDir: string, subdir: string, label: string): string {\n const memoriesReal = fs.realpathSync(memoriesDir);\n\n try {\n const stat = fs.lstatSync(subdir);\n if (stat.isSymbolicLink()) {\n throw new Error(\"is a symbolic link\");\n }\n if (!stat.isDirectory()) {\n throw new Error(\"is not a directory\");\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw new Error(\n `codex-materialize: unsafe ${label} directory at ${subdir}: ${\n err instanceof Error ? err.message : String(err)\n }`,\n );\n }\n fs.mkdirSync(subdir, { recursive: true });\n }\n\n const subdirReal = fs.realpathSync(subdir);\n if (!pathIsInside(memoriesReal, subdirReal)) {\n throw new Error(\n `codex-materialize: unsafe ${label} directory at ${subdir}: resolves outside ${memoriesDir}`,\n );\n }\n\n return path.normalize(subdir);\n}\n","/**\n * materialize-skills.ts — the `skills/` section of the Codex materializer\n * (issue #2369).\n *\n * Extracted from codex-materialize.ts (which sits at its structural LOC cap)\n * so the skill staging / commit / prune rules live in one small module. Format\n * and slug rules stay in the host-agnostic `procedural/skill-projection.ts`;\n * this module only decides what lands on disk.\n *\n * Ownership rule: Remnic removes ONLY the slugs a previous run recorded in the\n * sentinel's `projected_skills`. A skill folder a user (or another tool)\n * created is never in that list, so it is never a removal candidate.\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { renderSkillBundle, SKILL_FILE_NAME, type SkillBundle } from \"../procedural/skill-projection.js\";\nimport { isValidSkillSlug } from \"../skills-registry.js\";\nimport { ensureSafeManagedSubdir } from \"./materialize-paths.js\";\n\n/** Sub-directory for projected procedural skill bundles. */\nexport const SKILLS_SUBDIR = \"skills\";\n\nexport interface SkillFile {\n slug: string;\n body: string;\n}\n\nexport interface SkillPlan {\n /** False when the caller omitted `skills` — leave `skills/` untouched. */\n supplied: boolean;\n /** Bundles to write, deduplicated on slug. */\n files: SkillFile[];\n /** Previously projected slugs this run no longer projects. */\n retiredSlugs: string[];\n}\n\n/**\n * Decide what this run writes and removes. `undefined` bundles mean \"not our\n * business this run\"; an empty array is authoritative and retires everything\n * previously projected.\n */\nexport function planSkillFiles(\n bundles: SkillBundle[] | undefined,\n previouslyProjectedSlugs: readonly string[],\n): SkillPlan {\n const files: SkillFile[] = [];\n const seen = new Set<string>();\n for (const bundle of bundles ?? []) {\n // Invalid or duplicate slugs are dropped so two bundles can never target\n // one folder and leave the second rename with no source (§37).\n if (!isValidSkillSlug(bundle.slug) || seen.has(bundle.slug)) continue;\n seen.add(bundle.slug);\n files.push({ slug: bundle.slug, body: renderSkillBundle(bundle) });\n }\n const previous = previouslyProjectedSlugs.filter((slug) => isValidSkillSlug(slug));\n return {\n supplied: bundles !== undefined,\n files,\n retiredSlugs: bundles === undefined ? [] : previous.filter((slug) => !seen.has(slug)),\n };\n}\n\n/** Absolute path of a projected bundle's SKILL.md under `memoriesDir`. */\nexport function skillFilePath(memoriesDir: string, slug: string): string {\n return path.join(memoriesDir, SKILLS_SUBDIR, slug, SKILL_FILE_NAME);\n}\n\n/** Relative path recorded in `MaterializeResult.filesWritten`. */\nexport function skillFileRelPath(slug: string): string {\n return path.join(SKILLS_SUBDIR, slug, SKILL_FILE_NAME);\n}\n\n/**\n * True when no retired folder is still on disk. Guards the idempotent\n * early-return: a hash match is only a safe no-op if the removals also landed.\n */\nexport function retiredSkillsAlreadyRemoved(memoriesDir: string, retiredSlugs: readonly string[]): boolean {\n return retiredSlugs.every((slug) => !fs.existsSync(path.join(memoriesDir, SKILLS_SUBDIR, slug)));\n}\n\n/** Render bundles into the per-run staging directory. */\nexport function stageSkillFiles(tmpDir: string, files: readonly SkillFile[]): void {\n for (const file of files) {\n const stagedDir = path.join(tmpDir, SKILLS_SUBDIR, file.slug);\n fs.mkdirSync(stagedDir, { recursive: true });\n fs.writeFileSync(path.join(stagedDir, SKILL_FILE_NAME), file.body);\n }\n}\n\n/**\n * Remove retired folders, then rename each staged SKILL.md into place. Per-file\n * renames (never directory renames) so an existing folder cannot cause\n * ENOTEMPTY and so Codex never observes a half-written file.\n */\nexport function commitSkillFiles(memoriesDir: string, tmpDir: string, plan: SkillPlan): void {\n if (!plan.supplied) return;\n if (plan.files.length === 0 && plan.retiredSlugs.length === 0) return;\n\n const skillsDir = ensureSafeManagedSubdir(memoriesDir, path.join(memoriesDir, SKILLS_SUBDIR), SKILLS_SUBDIR);\n for (const slug of plan.retiredSlugs) {\n const retiredDir = path.join(skillsDir, slug);\n try {\n // Never follow a symlink out of the managed tree while pruning.\n if (fs.lstatSync(retiredDir).isSymbolicLink()) continue;\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") continue;\n throw err;\n }\n try {\n fs.rmSync(retiredDir, { recursive: true, force: true });\n } catch (err) {\n throw new Error(\n `codex-materialize: failed to remove retired skill ${slug}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n for (const file of plan.files) {\n const destDir = path.join(skillsDir, file.slug);\n fs.mkdirSync(destDir, { recursive: true });\n fs.renameSync(\n path.join(tmpDir, SKILLS_SUBDIR, file.slug, SKILL_FILE_NAME),\n path.join(destDir, SKILL_FILE_NAME),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;AAAA,EACE;AAAA,OACK;AACP,OAAOA,SAAQ;AACf,OAAOC,WAAU;;;ACnCjB,OAAO,QAAQ;AACf,OAAO,UAAU;AASV,SAAS,wBAAwB,aAAqB,QAAgB,OAAuB;AAClG,QAAM,eAAe,GAAG,aAAa,WAAW;AAEhD,MAAI;AACF,UAAM,OAAO,GAAG,UAAU,MAAM;AAChC,QAAI,KAAK,eAAe,GAAG;AACzB,YAAM,IAAI,MAAM,oBAAoB;AAAA,IACtC;AACA,QAAI,CAAC,KAAK,YAAY,GAAG;AACvB,YAAM,IAAI,MAAM,oBAAoB;AAAA,IACtC;AAAA,EACF,SAAS,KAAK;AACZ,QAAK,IAA8B,SAAS,UAAU;AACpD,YAAM,IAAI;AAAA,QACR,6BAA6B,KAAK,iBAAiB,MAAM,KACvD,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CACjD;AAAA,MACF;AAAA,IACF;AACA,OAAG,UAAU,QAAQ,EAAE,WAAW,KAAK,CAAC;AAAA,EAC1C;AAEA,QAAM,aAAa,GAAG,aAAa,MAAM;AACzC,MAAI,CAAC,aAAa,cAAc,UAAU,GA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