@remnic/core 1.1.11 → 1.1.12
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/README.md +3 -3
- package/dist/access-cli.js +67 -59
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +7 -4
- package/dist/access-http.js +30 -26
- package/dist/access-mcp.d.ts +9 -4
- package/dist/access-mcp.js +29 -25
- package/dist/access-schema.d.ts +188 -8
- package/dist/access-schema.js +12 -3
- package/dist/{access-service-BkXt3di1.d.ts → access-service-DDjzFALq.d.ts} +60 -11
- package/dist/access-service.d.ts +7 -4
- package/dist/access-service.js +26 -23
- package/dist/action-confidence.d.ts +83 -0
- package/dist/action-confidence.js +22 -0
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +4 -2
- package/dist/briefing.d.ts +1 -1
- package/dist/briefing.js +5 -5
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer.d.ts +1 -1
- package/dist/calibration.d.ts +1 -1
- package/dist/calibration.js +4 -4
- package/dist/{capsule-export-LLEVB2RG.js → capsule-export-7QNCBZOQ.js} +3 -3
- package/dist/{capsule-import-UW45R2MZ.js → capsule-import-EPBHD2EN.js} +3 -3
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +11 -11
- package/dist/{chunk-VQXK37XA.js → chunk-23ZZK64Y.js} +1 -1
- package/dist/chunk-23ZZK64Y.js.map +1 -0
- package/dist/{chunk-HJYHRE4S.js → chunk-242S3I2A.js} +2 -2
- package/dist/{chunk-MCC6KDQF.js → chunk-3B6KIRBH.js} +131 -13
- package/dist/chunk-3B6KIRBH.js.map +1 -0
- package/dist/chunk-4RA3C3EV.js +60 -0
- package/dist/chunk-4RA3C3EV.js.map +1 -0
- package/dist/{chunk-EYNQTST2.js → chunk-4YM32CRU.js} +4 -4
- package/dist/{chunk-6AUUAZEX.js → chunk-5NXIJZFX.js} +38 -8
- package/dist/chunk-5NXIJZFX.js.map +1 -0
- package/dist/chunk-6NKAQ74D.js +2237 -0
- package/dist/chunk-6NKAQ74D.js.map +1 -0
- package/dist/{chunk-PHNGXFQ6.js → chunk-7V22HTMD.js} +3 -3
- package/dist/{chunk-363MWCD3.js → chunk-7ZM3BFKK.js} +84 -62
- package/dist/chunk-7ZM3BFKK.js.map +1 -0
- package/dist/chunk-AC5LO7IU.js +308 -0
- package/dist/chunk-AC5LO7IU.js.map +1 -0
- package/dist/chunk-AH2JUU6X.js +336 -0
- package/dist/chunk-AH2JUU6X.js.map +1 -0
- package/dist/{chunk-VX2IUQFE.js → chunk-AQJNPMOA.js} +41 -11
- package/dist/chunk-AQJNPMOA.js.map +1 -0
- package/dist/{chunk-P73JTV34.js → chunk-BBE34QBJ.js} +4 -4
- package/dist/{chunk-KUHRUM6B.js → chunk-BZSQEPRW.js} +452 -139
- package/dist/chunk-BZSQEPRW.js.map +1 -0
- package/dist/chunk-C5BCH4ZS.js +317 -0
- package/dist/chunk-C5BCH4ZS.js.map +1 -0
- package/dist/{chunk-C5HUWVH2.js → chunk-CPKTBRS2.js} +6 -6
- package/dist/{chunk-IBX3VFOM.js → chunk-D4GAOFF6.js} +118 -2
- package/dist/chunk-D4GAOFF6.js.map +1 -0
- package/dist/chunk-DB5A3NHS.js +906 -0
- package/dist/chunk-DB5A3NHS.js.map +1 -0
- package/dist/{chunk-I6BQZSML.js → chunk-DZZPC36E.js} +10 -10
- package/dist/{chunk-O4XJUPSF.js → chunk-E2UCDP5S.js} +39 -2
- package/dist/chunk-E2UCDP5S.js.map +1 -0
- package/dist/{chunk-SRBJUAMP.js → chunk-FMEBPEAO.js} +11 -67
- package/dist/chunk-FMEBPEAO.js.map +1 -0
- package/dist/{chunk-4DXC6HQQ.js → chunk-FQDPCE3I.js} +5 -5
- package/dist/{chunk-NN3LPQ5D.js → chunk-HELQZFZO.js} +155 -16
- package/dist/chunk-HELQZFZO.js.map +1 -0
- package/dist/{chunk-57QNCUEZ.js → chunk-HL5LRPNA.js} +2 -2
- package/dist/{chunk-VTU2B4VF.js → chunk-HQZVVSVB.js} +2 -1
- package/dist/chunk-HQZVVSVB.js.map +1 -0
- package/dist/{chunk-6Z6UH6TK.js → chunk-HY3L4WKC.js} +69 -3
- package/dist/chunk-HY3L4WKC.js.map +1 -0
- package/dist/{chunk-QIGOEM65.js → chunk-IB3BFHGN.js} +5 -5
- package/dist/{chunk-RXTFCYQF.js → chunk-JESOB2HO.js} +6 -6
- package/dist/{chunk-2YMTO4ZJ.js → chunk-JKDVIE52.js} +9 -2
- package/dist/chunk-JKDVIE52.js.map +1 -0
- package/dist/{chunk-WGK4VHGP.js → chunk-MNU6ZBWT.js} +302 -140
- package/dist/chunk-MNU6ZBWT.js.map +1 -0
- package/dist/chunk-OAZ5MFUB.js +4124 -0
- package/dist/chunk-OAZ5MFUB.js.map +1 -0
- package/dist/{chunk-ZTSE2ZJ6.js → chunk-OIGNEXKZ.js} +50 -3
- package/dist/chunk-OIGNEXKZ.js.map +1 -0
- package/dist/chunk-OZKZ2TRP.js +3729 -0
- package/dist/chunk-OZKZ2TRP.js.map +1 -0
- package/dist/{chunk-GGD5W7TB.js → chunk-PD6O7AXF.js} +7 -2
- package/dist/chunk-PD6O7AXF.js.map +1 -0
- package/dist/{chunk-S3IP6R6K.js → chunk-PH4C2U43.js} +23 -3
- package/dist/chunk-PH4C2U43.js.map +1 -0
- package/dist/chunk-PYPOFEMK.js +294 -0
- package/dist/chunk-PYPOFEMK.js.map +1 -0
- package/dist/{chunk-EQINRHYR.js → chunk-QDZ2RLEC.js} +243 -7
- package/dist/chunk-QDZ2RLEC.js.map +1 -0
- package/dist/{chunk-KWBPHZUU.js → chunk-RK6F44Y6.js} +3 -2
- package/dist/chunk-RK6F44Y6.js.map +1 -0
- package/dist/{chunk-36CTNQY7.js → chunk-RVPLBATS.js} +42 -10
- package/dist/chunk-RVPLBATS.js.map +1 -0
- package/dist/chunk-SOAU2OE2.js +125 -0
- package/dist/chunk-SOAU2OE2.js.map +1 -0
- package/dist/{chunk-A4ACKWIW.js → chunk-U5JMRGKX.js} +55 -4
- package/dist/chunk-U5JMRGKX.js.map +1 -0
- package/dist/{chunk-LIO5X3CM.js → chunk-UVMUAWVT.js} +2 -2
- package/dist/chunk-VWT3F4IV.js +2161 -0
- package/dist/chunk-VWT3F4IV.js.map +1 -0
- package/dist/{chunk-PB5KW5PL.js → chunk-WEJG4TB5.js} +6 -6
- package/dist/{chunk-KBYWQWSB.js → chunk-X7HPGUVG.js} +2 -2
- package/dist/{chunk-Y5KDIOKF.js → chunk-XAMBKFQS.js} +383 -9
- package/dist/chunk-XAMBKFQS.js.map +1 -0
- package/dist/{chunk-ZL4S7ARC.js → chunk-Y3VMVTYX.js} +3 -3
- package/dist/{chunk-Z5S5HNGY.js → chunk-ZG7PTKBK.js} +21 -5
- package/dist/chunk-ZG7PTKBK.js.map +1 -0
- package/dist/{chunk-6XA7UN4Z.js → chunk-ZNQN6ZTA.js} +2 -2
- package/dist/{chunk-WTFWLUSX.js → chunk-ZVTKDVVM.js} +2 -2
- package/dist/{cli-Cvy2SNhF.d.ts → cli-BR8KpIU0.d.ts} +2 -2
- package/dist/cli.d.ts +7 -4
- package/dist/cli.js +44 -40
- package/dist/codex-cli-fallback.d.ts +1 -0
- package/dist/codex-cli-fallback.js +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/consolidation-provenance-check.d.ts +1 -1
- package/dist/consolidation-undo.d.ts +1 -1
- package/dist/{contradiction-scan-3Z6YW7YA.js → contradiction-scan-QTXAMBUA.js} +3 -2
- package/dist/contradiction-scan-QTXAMBUA.js.map +1 -0
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer-wiring.js +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/{engine-FOC3IJLA.js → engine-35M5BKQ7.js} +7 -7
- package/dist/entity-retrieval.d.ts +1 -1
- package/dist/entity-retrieval.js +5 -5
- package/dist/entity-schema.d.ts +1 -1
- package/dist/event-order-recall.d.ts +17 -0
- package/dist/event-order-recall.js +11 -0
- package/dist/event-order-recall.js.map +1 -0
- package/dist/evidence-pack.d.ts +3 -1
- package/dist/evidence-pack.js +5 -3
- package/dist/explicit-capture.d.ts +4 -2
- package/dist/explicit-cue-recall.d.ts +4 -1
- package/dist/explicit-cue-recall.js +4 -2
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +8 -7
- package/dist/fallback-llm.d.ts +2 -1
- package/dist/fallback-llm.js +4 -4
- package/dist/focused-list-recall.d.ts +17 -0
- package/dist/focused-list-recall.js +11 -0
- package/dist/focused-list-recall.js.map +1 -0
- package/dist/identity-continuity.d.ts +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/{index-1qIcnbG1.d.ts → index-DJ9QWMw-.d.ts} +3 -2
- package/dist/index.d.ts +49 -12
- package/dist/index.js +284 -114
- package/dist/index.js.map +1 -1
- package/dist/intent.d.ts +1 -1
- package/dist/intent.js +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +8 -4
- package/dist/local-llm.js +1 -1
- package/dist/mcp-memory-inspector-app.d.ts +106 -0
- package/dist/mcp-memory-inspector-app.js +20 -0
- package/dist/mcp-memory-inspector-app.js.map +1 -0
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/{memory-governance-F3QOJGEY.js → memory-governance-IMPQZXFC.js} +7 -7
- package/dist/memory-governance-IMPQZXFC.js.map +1 -0
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +57 -0
- package/dist/memory-provenance.js +13 -0
- package/dist/memory-provenance.js.map +1 -0
- package/dist/memory-worth-outcomes.d.ts +1 -1
- package/dist/models-json.d.ts +1 -1
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/objective-state-writers.d.ts +1 -1
- package/dist/objective-state-writers.js +2 -2
- package/dist/operator-toolkit.d.ts +1 -1
- package/dist/operator-toolkit.js +11 -11
- package/dist/{orchestrator-AOQMo7QI.d.ts → orchestrator-DDMPqU6R.d.ts} +9 -1
- package/dist/orchestrator.d.ts +4 -2
- package/dist/orchestrator.js +53 -46
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +3 -1
- package/dist/recall-explain-renderer.js +5 -3
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +3 -1
- package/dist/recall-xray-cli.d.ts +3 -1
- package/dist/recall-xray-cli.js +6 -4
- package/dist/recall-xray-renderer.d.ts +3 -1
- package/dist/recall-xray-renderer.js +5 -3
- package/dist/recall-xray.d.ts +8 -1
- package/dist/recall-xray.js +4 -2
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resolve-provider-secret.js +1 -1
- package/dist/response-guidance-recall.d.ts +18 -0
- package/dist/response-guidance-recall.js +11 -0
- package/dist/response-guidance-recall.js.map +1 -0
- package/dist/resume-bundles.js +3 -3
- package/dist/retrieval-agents.d.ts +1 -1
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/schemas.d.ts +22 -22
- package/dist/semantic-consolidation.d.ts +1 -1
- package/dist/semantic-consolidation.js +6 -6
- package/dist/semantic-rule-promotion.js +5 -5
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +6 -6
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/signal.d.ts +1 -1
- package/dist/storage.d.ts +3 -1
- package/dist/storage.js +4 -4
- package/dist/summarizer.d.ts +1 -1
- package/dist/summarizer.js +6 -6
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/targeted-fact-recall.d.ts +17 -0
- package/dist/targeted-fact-recall.js +11 -0
- package/dist/targeted-fact-recall.js.map +1 -0
- package/dist/telemetry-transcript.d.ts +7 -0
- package/dist/telemetry-transcript.js +16 -0
- package/dist/telemetry-transcript.js.map +1 -0
- package/dist/temporal-supersession.d.ts +1 -1
- package/dist/temporal-supersession.js +2 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +1 -1
- package/dist/tier-routing.d.ts +1 -1
- package/dist/tokens.js +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/trust-zones.d.ts +3 -2
- package/dist/trust-zones.js +1 -1
- package/dist/types.d.ts +60 -2
- package/dist/types.js +1 -1
- package/dist/user-model.d.ts +37 -0
- package/dist/user-model.js +28 -0
- package/dist/user-model.js.map +1 -0
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +6 -6
- package/package.json +1 -1
- package/dist/chunk-2YMTO4ZJ.js.map +0 -1
- package/dist/chunk-363MWCD3.js.map +0 -1
- package/dist/chunk-36CTNQY7.js.map +0 -1
- package/dist/chunk-6AUUAZEX.js.map +0 -1
- package/dist/chunk-6Z6UH6TK.js.map +0 -1
- package/dist/chunk-74WWN7ZW.js +0 -82
- package/dist/chunk-74WWN7ZW.js.map +0 -1
- package/dist/chunk-A4ACKWIW.js.map +0 -1
- package/dist/chunk-EQINRHYR.js.map +0 -1
- package/dist/chunk-GGD5W7TB.js.map +0 -1
- package/dist/chunk-IBX3VFOM.js.map +0 -1
- package/dist/chunk-KUHRUM6B.js.map +0 -1
- package/dist/chunk-KWBPHZUU.js.map +0 -1
- package/dist/chunk-MCC6KDQF.js.map +0 -1
- package/dist/chunk-NN3LPQ5D.js.map +0 -1
- package/dist/chunk-O4XJUPSF.js.map +0 -1
- package/dist/chunk-S2JJBLJG.js +0 -2101
- package/dist/chunk-S2JJBLJG.js.map +0 -1
- package/dist/chunk-S3IP6R6K.js.map +0 -1
- package/dist/chunk-SRBJUAMP.js.map +0 -1
- package/dist/chunk-VQXK37XA.js.map +0 -1
- package/dist/chunk-VTU2B4VF.js.map +0 -1
- package/dist/chunk-VX2IUQFE.js.map +0 -1
- package/dist/chunk-WGK4VHGP.js.map +0 -1
- package/dist/chunk-Y5KDIOKF.js.map +0 -1
- package/dist/chunk-Z5S5HNGY.js.map +0 -1
- package/dist/chunk-ZTSE2ZJ6.js.map +0 -1
- package/dist/contradiction-scan-3Z6YW7YA.js.map +0 -1
- /package/dist/{capsule-export-LLEVB2RG.js.map → action-confidence.js.map} +0 -0
- /package/dist/{capsule-import-UW45R2MZ.js.map → capsule-export-7QNCBZOQ.js.map} +0 -0
- /package/dist/{engine-FOC3IJLA.js.map → capsule-import-EPBHD2EN.js.map} +0 -0
- /package/dist/{chunk-HJYHRE4S.js.map → chunk-242S3I2A.js.map} +0 -0
- /package/dist/{chunk-EYNQTST2.js.map → chunk-4YM32CRU.js.map} +0 -0
- /package/dist/{chunk-PHNGXFQ6.js.map → chunk-7V22HTMD.js.map} +0 -0
- /package/dist/{chunk-P73JTV34.js.map → chunk-BBE34QBJ.js.map} +0 -0
- /package/dist/{chunk-C5HUWVH2.js.map → chunk-CPKTBRS2.js.map} +0 -0
- /package/dist/{chunk-I6BQZSML.js.map → chunk-DZZPC36E.js.map} +0 -0
- /package/dist/{chunk-4DXC6HQQ.js.map → chunk-FQDPCE3I.js.map} +0 -0
- /package/dist/{chunk-57QNCUEZ.js.map → chunk-HL5LRPNA.js.map} +0 -0
- /package/dist/{chunk-QIGOEM65.js.map → chunk-IB3BFHGN.js.map} +0 -0
- /package/dist/{chunk-RXTFCYQF.js.map → chunk-JESOB2HO.js.map} +0 -0
- /package/dist/{chunk-LIO5X3CM.js.map → chunk-UVMUAWVT.js.map} +0 -0
- /package/dist/{chunk-PB5KW5PL.js.map → chunk-WEJG4TB5.js.map} +0 -0
- /package/dist/{chunk-KBYWQWSB.js.map → chunk-X7HPGUVG.js.map} +0 -0
- /package/dist/{chunk-ZL4S7ARC.js.map → chunk-Y3VMVTYX.js.map} +0 -0
- /package/dist/{chunk-6XA7UN4Z.js.map → chunk-ZNQN6ZTA.js.map} +0 -0
- /package/dist/{chunk-WTFWLUSX.js.map → chunk-ZVTKDVVM.js.map} +0 -0
- /package/dist/{memory-governance-F3QOJGEY.js.map → engine-35M5BKQ7.js.map} +0 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
effectiveValidAt
|
|
3
|
+
} from "./chunk-MDYG7VI7.js";
|
|
1
4
|
import {
|
|
2
5
|
log
|
|
3
6
|
} from "./chunk-2ODBA7MQ.js";
|
|
@@ -40,7 +43,7 @@ function shouldSupersedeExisting(args) {
|
|
|
40
43
|
const candidateEntityNorm = normalizeSupersessionKey(candidate.entityRef);
|
|
41
44
|
const newEntityNorm = normalizeSupersessionKey(newEntityRef);
|
|
42
45
|
if (candidateEntityNorm !== newEntityNorm) return null;
|
|
43
|
-
const candidateCreated = Date.parse(candidate
|
|
46
|
+
const candidateCreated = Date.parse(effectiveValidAt(candidate));
|
|
44
47
|
const newCreated = Date.parse(newCreatedAt);
|
|
45
48
|
if (!Number.isFinite(candidateCreated) || !Number.isFinite(newCreated)) return null;
|
|
46
49
|
if (candidateCreated >= newCreated) return null;
|
|
@@ -60,6 +63,42 @@ function shouldSupersedeExisting(args) {
|
|
|
60
63
|
function normalizeValue(v) {
|
|
61
64
|
return v.trim().toLowerCase();
|
|
62
65
|
}
|
|
66
|
+
async function expireChildChunksForSupersededParent(args) {
|
|
67
|
+
const processedChunkIds = /* @__PURE__ */ new Set();
|
|
68
|
+
const chunks = args.allCandidates.filter(
|
|
69
|
+
(candidate) => candidate.frontmatter.parentId === args.parentId
|
|
70
|
+
);
|
|
71
|
+
for (const chunk of chunks) {
|
|
72
|
+
const chunkKey = chunk.frontmatter.id ?? chunk.path;
|
|
73
|
+
if (processedChunkIds.has(chunkKey)) continue;
|
|
74
|
+
try {
|
|
75
|
+
const freshChunk = await args.storage.readMemoryByPath(chunk.path);
|
|
76
|
+
if (!freshChunk) continue;
|
|
77
|
+
processedChunkIds.add(chunkKey);
|
|
78
|
+
const freshStatus = freshChunk.frontmatter.status ?? "active";
|
|
79
|
+
if (freshStatus !== "active" || freshChunk.frontmatter.supersededBy) continue;
|
|
80
|
+
await args.storage.writeMemoryFrontmatter(
|
|
81
|
+
freshChunk,
|
|
82
|
+
{
|
|
83
|
+
status: "superseded",
|
|
84
|
+
supersededBy: args.newMemoryId,
|
|
85
|
+
supersededAt: args.supersededAt,
|
|
86
|
+
updated: args.supersededAt,
|
|
87
|
+
...args.invalidAt && !freshChunk.frontmatter.invalid_at ? { invalid_at: args.invalidAt } : {}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
actor: "temporal-supersession",
|
|
91
|
+
reasonCode: "structured-attribute-update-child-chunk",
|
|
92
|
+
relatedMemoryIds: [args.newMemoryId, args.parentId]
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
} catch (err) {
|
|
96
|
+
log.warn(
|
|
97
|
+
`temporal-supersession: failed to expire child chunk ${chunk.frontmatter.id} for parent ${args.parentId}: ${err}`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
63
102
|
async function applyTemporalSupersession(args) {
|
|
64
103
|
const empty = { supersededIds: [], matchedKeys: [] };
|
|
65
104
|
if (!args.enabled) return empty;
|
|
@@ -79,7 +118,7 @@ async function applyTemporalSupersession(args) {
|
|
|
79
118
|
return empty;
|
|
80
119
|
}
|
|
81
120
|
const newMemoryFile = hotMemories.find((m) => m.frontmatter.id === args.newMemoryId);
|
|
82
|
-
const persistedCreatedAt = args.useCallerTimestamp ? args.createdAt : newMemoryFile
|
|
121
|
+
const persistedCreatedAt = args.useCallerTimestamp ? args.createdAt : newMemoryFile ? effectiveValidAt(newMemoryFile.frontmatter) : args.createdAt;
|
|
83
122
|
const supersededIds = [];
|
|
84
123
|
const matchedKeys = /* @__PURE__ */ new Set();
|
|
85
124
|
const processedIds = /* @__PURE__ */ new Set();
|
|
@@ -158,6 +197,14 @@ async function applyTemporalSupersession(args) {
|
|
|
158
197
|
if (wrote) {
|
|
159
198
|
supersededIds.push(memory.frontmatter.id);
|
|
160
199
|
for (const key of decision.matchedKeys) matchedKeys.add(key);
|
|
200
|
+
await expireChildChunksForSupersededParent({
|
|
201
|
+
storage: args.storage,
|
|
202
|
+
allCandidates,
|
|
203
|
+
parentId: fresh.frontmatter.id,
|
|
204
|
+
newMemoryId: args.newMemoryId,
|
|
205
|
+
supersededAt,
|
|
206
|
+
invalidAt: invalidAtPatch ?? fresh.frontmatter.invalid_at
|
|
207
|
+
});
|
|
161
208
|
}
|
|
162
209
|
} catch (err) {
|
|
163
210
|
log.warn(
|
|
@@ -187,4 +234,4 @@ export {
|
|
|
187
234
|
applyTemporalSupersession,
|
|
188
235
|
shouldFilterSupersededFromRecall
|
|
189
236
|
};
|
|
190
|
-
//# sourceMappingURL=chunk-
|
|
237
|
+
//# sourceMappingURL=chunk-OIGNEXKZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/temporal-supersession.ts"],"sourcesContent":["/**\n * Temporal Supersession (issue #375)\n *\n * When a new fact lands with `structuredAttributes` keyed on a known\n * `entityRef`, any prior fact whose supersession key collides with the new\n * fact's key is marked `status: \"superseded\"` and linked via\n * `supersededBy` / `supersededAt`. Recall filters those superseded memories\n * by default so agents see only the \"current\" value per entity attribute.\n *\n * The algorithm is intentionally O(N) over the memory corpus per write, but\n * skips cheaply when the new fact has no structuredAttributes. It reuses the\n * cached `readAllMemories()` path so cost is amortized with the rest of the\n * write pipeline.\n */\nimport type { MemoryFile, MemoryFrontmatter } from \"./types.js\";\nimport type { StorageManager } from \"./storage.js\";\nimport { log } from \"./logger.js\";\nimport { effectiveValidAt } from \"./temporal-validity.js\";\n\n/**\n * Shared normalization for supersession key components.\n *\n * Trims surrounding whitespace, lowercases, then collapses any run of\n * whitespace OR hyphens to a single hyphen, and strips any leading/trailing\n * hyphens that result. Both `computeSupersessionKey` and\n * `lookupAttributeByNormalizedKey` must use this so that keys produced at\n * write time and keys used at lookup time are identical regardless of how\n * the LLM encoded whitespace, hyphens, or casing (Finding B fix).\n *\n * Symmetry guarantee: `\"foo bar\"`, `\"foo-bar\"`, `\"foo - bar\"`, and\n * `\"foo bar\"` all canonicalize to `\"foo-bar\"`.\n *\n * Exported so external tests can verify the canonical form.\n */\nexport function normalizeSupersessionKey(raw: string): string {\n return raw\n .trim()\n .toLowerCase()\n .replace(/[\\s\\-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n\n/**\n * Stable supersession key for an (entityRef, attributeName) pair.\n *\n * The algorithm is:\n * - normalize the entityRef (trim, lower-case, collapse whitespace)\n * - normalize the attributeName the same way\n * - join with `::`\n *\n * Exported so tests and tools can recompute it without depending on storage.\n */\nexport function computeSupersessionKey(\n entityRef: string | undefined,\n attributeName: string,\n): string | null {\n if (!entityRef || typeof entityRef !== \"string\") return null;\n if (!attributeName || typeof attributeName !== \"string\") return null;\n const entity = normalizeSupersessionKey(entityRef);\n const attr = normalizeSupersessionKey(attributeName);\n if (entity.length === 0 || attr.length === 0) return null;\n return `${entity}::${attr}`;\n}\n\n/**\n * Compute the full set of supersession keys for a fact with structured\n * attributes. Returns an empty array if no keys can be derived.\n */\nexport function supersessionKeysForFact(spec: {\n entityRef?: string;\n structuredAttributes?: Record<string, string>;\n}): string[] {\n if (!spec.entityRef) return [];\n if (!spec.structuredAttributes) return [];\n const keys: string[] = [];\n for (const attrName of Object.keys(spec.structuredAttributes)) {\n const key = computeSupersessionKey(spec.entityRef, attrName);\n if (key) keys.push(key);\n }\n return keys;\n}\n\n/**\n * Look up a structured-attribute value by a raw key, normalizing both sides\n * with `normalizeSupersessionKey` before comparing. This ensures that keys\n * written by the LLM with mixed case, surrounding whitespace, or internal\n * whitespace (e.g. `\"City\"`, `\" city \"`, `\"job title\"`, `\"job-title\"`)\n * are all matched against normalized keys produced by `computeSupersessionKey`\n * (Finding B fix — uses the same helper so both sides are identical).\n *\n * The storage format is NOT changed — we only normalize at lookup time.\n */\nexport function lookupAttributeByNormalizedKey(\n attributes: Record<string, unknown>,\n rawKey: string,\n): unknown {\n const normalizedTarget = normalizeSupersessionKey(rawKey);\n for (const [k, v] of Object.entries(attributes)) {\n if (normalizeSupersessionKey(k) === normalizedTarget) return v;\n }\n return undefined;\n}\n\n/**\n * Decide whether an existing memory should be superseded by a newly-written\n * memory that carries the supplied supersession key set.\n *\n * Only memories that:\n * - are currently `active`\n * - share an `entityRef` with the new fact\n * - share at least one supersession key with the new fact\n * - are older than the new fact\n * - have a conflicting value (different string) for the overlapping key\n * are eligible. This keeps supersession local to the attribute that actually\n * changed — if fact A sets `{city: Austin, tool: vim}` and fact B sets\n * `{city: NYC}`, only the city attribute is superseded, not the tool.\n */\nexport function shouldSupersedeExisting(args: {\n candidate: MemoryFrontmatter;\n newEntityRef: string;\n newAttributes: Record<string, string>;\n newCreatedAt: string;\n newMemoryId: string;\n}): { matchedKeys: string[] } | null {\n const { candidate, newEntityRef, newAttributes, newCreatedAt, newMemoryId } = args;\n\n if (candidate.id === newMemoryId) return null;\n if (candidate.status && candidate.status !== \"active\") return null;\n if (!candidate.entityRef) return null;\n if (!candidate.structuredAttributes) return null;\n\n // Reuse the shared `normalizeSupersessionKey` helper so this comparison\n // cannot drift from the canonical form used to build supersession keys\n // elsewhere in this file.\n const candidateEntityNorm = normalizeSupersessionKey(candidate.entityRef);\n const newEntityNorm = normalizeSupersessionKey(newEntityRef);\n if (candidateEntityNorm !== newEntityNorm) return null;\n\n // Must be older than the new fact's effective validity start — equal\n // timestamps are ignored to avoid races within the same millisecond. When\n // replay/import supplies source time, valid_at must drive ordering instead\n // of wall-clock persistence time.\n const candidateCreated = Date.parse(effectiveValidAt(candidate));\n const newCreated = Date.parse(newCreatedAt);\n if (!Number.isFinite(candidateCreated) || !Number.isFinite(newCreated)) return null;\n if (candidateCreated >= newCreated) return null;\n\n const matchedKeys: string[] = [];\n for (const [attrName, newValue] of Object.entries(newAttributes)) {\n // Use normalized key lookup so mixed-case or whitespace-padded keys\n // stored by the LLM are matched correctly (Finding 2 fix).\n const candidateValue = lookupAttributeByNormalizedKey(\n candidate.structuredAttributes,\n attrName,\n );\n if (candidateValue === undefined) continue;\n // Only supersede on conflicting values — identical values are a no-op.\n if (normalizeValue(String(candidateValue)) === normalizeValue(newValue)) continue;\n const key = computeSupersessionKey(newEntityRef, attrName);\n if (key) matchedKeys.push(key);\n }\n\n return matchedKeys.length > 0 ? { matchedKeys } : null;\n}\n\nfunction normalizeValue(v: string): string {\n return v.trim().toLowerCase();\n}\n\nasync function expireChildChunksForSupersededParent(args: {\n storage: StorageManager;\n allCandidates: MemoryFile[];\n parentId: string;\n newMemoryId: string;\n supersededAt: string;\n invalidAt?: string;\n}): Promise<void> {\n const processedChunkIds = new Set<string>();\n const chunks = args.allCandidates.filter(\n (candidate) => candidate.frontmatter.parentId === args.parentId,\n );\n\n for (const chunk of chunks) {\n const chunkKey = chunk.frontmatter.id ?? chunk.path;\n if (processedChunkIds.has(chunkKey)) continue;\n\n try {\n const freshChunk = await args.storage.readMemoryByPath(chunk.path);\n if (!freshChunk) continue;\n processedChunkIds.add(chunkKey);\n const freshStatus = freshChunk.frontmatter.status ?? \"active\";\n if (freshStatus !== \"active\" || freshChunk.frontmatter.supersededBy) continue;\n\n await args.storage.writeMemoryFrontmatter(\n freshChunk,\n {\n status: \"superseded\",\n supersededBy: args.newMemoryId,\n supersededAt: args.supersededAt,\n updated: args.supersededAt,\n ...(args.invalidAt && !freshChunk.frontmatter.invalid_at\n ? { invalid_at: args.invalidAt }\n : {}),\n },\n {\n actor: \"temporal-supersession\",\n reasonCode: \"structured-attribute-update-child-chunk\",\n relatedMemoryIds: [args.newMemoryId, args.parentId],\n },\n );\n } catch (err) {\n log.warn(\n `temporal-supersession: failed to expire child chunk ${chunk.frontmatter.id} for parent ${args.parentId}: ${err}`,\n );\n }\n }\n}\n\nexport interface TemporalSupersessionResult {\n supersededIds: string[];\n matchedKeys: string[];\n}\n\n/**\n * Scan existing memories and mark any that are superseded by the\n * just-written memory. Fails open on I/O errors — the new memory is already\n * on disk, and supersession is a best-effort hygiene step.\n */\nexport async function applyTemporalSupersession(args: {\n storage: StorageManager;\n newMemoryId: string;\n entityRef?: string;\n structuredAttributes?: Record<string, string>;\n createdAt: string;\n enabled: boolean;\n /**\n * When true, skip the persisted `frontmatter.created` lookup and use\n * `args.createdAt` directly as the ordering anchor. Set this on the\n * hash-dedup short-circuit path where `newMemoryId` points to an existing\n * OLD fact (no new file is written) and its persisted timestamp would be\n * stale relative to the incoming promotion event (PR #402 Finding Uyui).\n */\n useCallerTimestamp?: boolean;\n}): Promise<TemporalSupersessionResult> {\n const empty: TemporalSupersessionResult = { supersededIds: [], matchedKeys: [] };\n if (!args.enabled) return empty;\n if (!args.entityRef) return empty;\n if (!args.structuredAttributes) return empty;\n if (Object.keys(args.structuredAttributes).length === 0) return empty;\n\n const newKeys = supersessionKeysForFact({\n entityRef: args.entityRef,\n structuredAttributes: args.structuredAttributes,\n });\n if (newKeys.length === 0) return empty;\n\n let hotMemories: MemoryFile[];\n try {\n hotMemories = await args.storage.readAllMemories();\n } catch (err) {\n log.warn(`temporal-supersession: readAllMemories failed: ${err}`);\n return empty;\n }\n\n // Finding 1 fix: use the on-disk effective validity start of the\n // newly-written memory rather than a wall-clock timestamp sampled after\n // `writeMemory` returns. In concurrent writers the two can differ by enough\n // to cause wrong-direction supersession. If source replay/import provided\n // valid_at, it must drive ordering; otherwise created remains the legacy\n // fallback. If the memory is not yet visible in the cache (edge case during\n // fast concurrent writes) fall back to args.createdAt.\n //\n // PR #402 round-12 (Finding Uyui): on the hash-dedup early-return path the\n // caller supplies the OLD matching fact's id as `newMemoryId` (no new file is\n // written). That makes `newMemoryFile.frontmatter.created` an arbitrarily\n // old timestamp. When `args.useCallerTimestamp` is set the caller explicitly\n // opts out of the persisted-timestamp lookup so `args.createdAt` (the\n // incoming event time: source valid_at when present, otherwise wall-clock) is\n // used directly, keeping ordering correct regardless of how old the matching\n // fact is.\n const newMemoryFile = hotMemories.find((m) => m.frontmatter.id === args.newMemoryId);\n const persistedCreatedAt = args.useCallerTimestamp\n ? args.createdAt\n : (newMemoryFile ? effectiveValidAt(newMemoryFile.frontmatter) : args.createdAt);\n\n const supersededIds: string[] = [];\n const matchedKeys = new Set<string>();\n\n // Process hot then cold. Hot-then-cold ordering is safer because hot\n // writes are more frequent and the CAS re-read guards against double-writes.\n // A Set<string> of already-processed ids ensures that a memory visible in\n // both tiers (same logical memory with different filesystem paths during a\n // migration race) is processed at most once. Keying on `frontmatter.id`\n // is correct because the same logical memory has the same id regardless of\n // which tier's directory it currently lives in (PR #402 Finding 1 fix).\n // Fall back to path-based keying when id is absent (defensive).\n const processedIds = new Set<string>();\n\n // Finding UOGi fix (round-6): readAllColdMemories() performs a full uncached\n // recursive directory scan of cold/. After Finding UTsP broadened the scan\n // to cover the entire cold root (not just facts/+corrections/), the per-call\n // cost grows with the cold tree size.\n //\n // The fix is a TTL-based in-memory cache inside StorageManager\n // (readAllColdMemories caches its result for COLD_SCAN_CACHE_TTL_MS) that is\n // shared across consecutive supersession calls within the same write burst.\n // The cache is invalidated automatically on any hot→cold demotion (which\n // calls invalidateAllMemoriesCache, which also clears the cold cache) and\n // expires after the TTL as a safety net.\n //\n // This means back-to-back structured-attribute writes in the same burst\n // (e.g. batch extraction) pay the cold I/O cost at most once, not N times.\n // Correctness is preserved because the cache TTL ensures eventual consistency\n // and the invalidation hook covers the hot→cold path.\n\n let coldMemories: MemoryFile[];\n try {\n coldMemories = await args.storage.readAllColdMemories();\n } catch (err) {\n log.warn(`temporal-supersession: readAllColdMemories failed: ${err}`);\n coldMemories = [];\n }\n\n // Combine hot and cold memories into a single scan. New memory itself is\n // excluded inline. We do NOT skip cold scan when hot produced zero\n // supersessions — the P1 finding is precisely that stale cold facts leak\n // when hot has no hits.\n const allCandidates: MemoryFile[] = [...hotMemories, ...coldMemories];\n\n for (const memory of allCandidates) {\n if (memory.frontmatter.id === args.newMemoryId) continue;\n const dedupeKey = memory.frontmatter.id ?? memory.path;\n if (processedIds.has(dedupeKey)) continue;\n // NOTE: do NOT call processedIds.add(dedupeKey) here. We defer marking\n // the id as processed until AFTER the CAS re-read succeeds. If we mark\n // it here and the re-read fails (e.g. the hot entry has already been\n // migrated to cold storage), the same logical id that appears later in\n // the cold tier scan would be silently skipped, leaving a stale cold\n // fact unsuperseded. Deferring ensures that a failed primary-tier read\n // grants the alternate tier a chance to process the same id (PR #402\n // round-6 Finding 1 fix).\n\n const decision = shouldSupersedeExisting({\n candidate: memory.frontmatter,\n newEntityRef: args.entityRef,\n newAttributes: args.structuredAttributes,\n newCreatedAt: persistedCreatedAt,\n newMemoryId: args.newMemoryId,\n });\n if (!decision) {\n // No supersession decision — safe to mark as processed now so the\n // alternate tier doesn't re-evaluate an identical non-matching entry.\n processedIds.add(dedupeKey);\n continue;\n }\n\n try {\n // CAS-style re-read immediately before the write. `readAllMemories()`\n // is a snapshot — with concurrent writers, another run may have already\n // superseded this candidate since we loaded it. If we blindly trust the\n // snapshot we can clobber a newer `supersededBy` link with a stale one.\n //\n // File storage offers no true locking, so the best we can do is:\n // 1. re-read the exact file we're about to mutate\n // 2. verify status is still \"active\" and no `supersededBy` is set\n // 3. only then issue the write\n // If the re-read shows a newer concurrent writer beat us to it, skip.\n // This CAS pattern applies equally to hot and cold tier candidates.\n // Mark as processed AFTER confirming the candidate is readable so that\n // a migration-race read failure on the hot entry does not silently\n // prevent the cold entry from being evaluated (Finding 1, round 6).\n const fresh = await args.storage.readMemoryByPath(memory.path);\n if (!fresh) {\n log.debug(\n `[engram] temporal supersession skipped candidate ${memory.frontmatter.id}: no longer readable at ${memory.path} — leaving id available for alternate tier`,\n );\n // Do NOT add to processedIds — allow the cold-tier copy to be\n // evaluated in the next iteration of the same scan.\n continue;\n }\n // Candidate is readable — mark the id as processed now to prevent the\n // alternate tier from double-writing.\n processedIds.add(dedupeKey);\n const freshStatus = fresh.frontmatter.status ?? \"active\";\n if (freshStatus !== \"active\" || fresh.frontmatter.supersededBy) {\n log.debug(\n `[engram] temporal supersession skipped candidate ${memory.frontmatter.id}: already superseded by concurrent writer`,\n );\n continue;\n }\n\n // Finding 2 fix: the `supersededAt` / `updated` timestamps written to the\n // old fact must never run backwards relative to its own persisted\n // `created` timestamp. If the caller-supplied `args.createdAt` (which\n // represents \"when the new replacing fact was authored\") is earlier than\n // either the new fact's persisted `created` (T_new) or the old fact's\n // persisted `created` (T_old), we'd be writing a nonsensical\n // `supersededAt` that precedes the old memory's own creation. Clamp to\n // the monotonic maximum so time only moves forward.\n // This monotonic clamp is applied for both hot and cold tier writes.\n const oldCreatedMs = new Date(fresh.frontmatter.created).getTime();\n const newCreatedMs = new Date(persistedCreatedAt).getTime();\n const argCreatedMs = new Date(args.createdAt).getTime();\n const maxMs = Math.max(\n Number.isFinite(oldCreatedMs) ? oldCreatedMs : 0,\n Number.isFinite(newCreatedMs) ? newCreatedMs : 0,\n Number.isFinite(argCreatedMs) ? argCreatedMs : 0,\n );\n const supersededAt = new Date(maxMs).toISOString();\n\n // Issue #680 — explicit fact lifecycle. When the new fact\n // supersedes this one, set the predecessor's `invalid_at` to the\n // successor's effective valid_at. Skip when the predecessor\n // already carries an `invalid_at` so manual / earlier values\n // are preserved (idempotent).\n //\n // Codex P1 on PR #713: in the hash-dedup early-return path\n // (`useCallerTimestamp: true`), `newMemoryFile` is actually the\n // OLD matching fact — no new file was written — so its\n // `valid_at` is the predecessor's own old timestamp, not the\n // successor's effective time. Use `persistedCreatedAt`\n // directly in that path so the predecessor's invalid_at lines\n // up with the caller's wall-clock, not the matching fact's old\n // valid_at. The non-dedup path keeps the previous behavior\n // (prefer the new file's explicit valid_at, fall back to its\n // persisted created).\n let invalidAtPatch: string | undefined;\n if (!fresh.frontmatter.invalid_at) {\n if (args.useCallerTimestamp) {\n invalidAtPatch = persistedCreatedAt;\n } else {\n const newValidAt = newMemoryFile?.frontmatter.valid_at?.trim();\n invalidAtPatch =\n newValidAt && newValidAt.length > 0 ? newValidAt : persistedCreatedAt;\n }\n }\n const wrote = await args.storage.writeMemoryFrontmatter(\n fresh,\n {\n status: \"superseded\",\n supersededBy: args.newMemoryId,\n supersededAt,\n updated: supersededAt,\n ...(invalidAtPatch ? { invalid_at: invalidAtPatch } : {}),\n },\n {\n actor: \"temporal-supersession\",\n reasonCode: \"structured-attribute-update\",\n relatedMemoryIds: [args.newMemoryId],\n },\n );\n if (wrote) {\n supersededIds.push(memory.frontmatter.id);\n for (const key of decision.matchedKeys) matchedKeys.add(key);\n await expireChildChunksForSupersededParent({\n storage: args.storage,\n allCandidates,\n parentId: fresh.frontmatter.id,\n newMemoryId: args.newMemoryId,\n supersededAt,\n invalidAt: invalidAtPatch ?? fresh.frontmatter.invalid_at,\n });\n }\n } catch (err) {\n log.warn(\n `temporal-supersession: failed to mark ${memory.frontmatter.id} superseded: ${err}`,\n );\n }\n }\n\n if (supersededIds.length > 0) {\n log.debug(\n `temporal-supersession: marked ${supersededIds.length} memories superseded by ${args.newMemoryId} (keys=${Array.from(matchedKeys).join(\",\")})`,\n );\n }\n\n return { supersededIds, matchedKeys: Array.from(matchedKeys) };\n}\n\n/**\n * Recall-side filter: returns true when the candidate should be excluded\n * from recall because it has been temporally superseded. When\n * `includeInRecall` is true, this always returns false (the fact is kept),\n * matching the audit/history opt-in described in the config.\n */\nexport function shouldFilterSupersededFromRecall(\n frontmatter: MemoryFrontmatter,\n options: { enabled: boolean; includeInRecall: boolean },\n): boolean {\n if (!options.enabled) return false;\n if (options.includeInRecall) return false;\n return frontmatter.status === \"superseded\";\n}\n"],"mappings":";;;;;;;;AAkCO,SAAS,yBAAyB,KAAqB;AAC5D,SAAO,IACJ,KAAK,EACL,YAAY,EACZ,QAAQ,YAAY,GAAG,EACvB,QAAQ,YAAY,EAAE;AAC3B;AAYO,SAAS,uBACd,WACA,eACe;AACf,MAAI,CAAC,aAAa,OAAO,cAAc,SAAU,QAAO;AACxD,MAAI,CAAC,iBAAiB,OAAO,kBAAkB,SAAU,QAAO;AAChE,QAAM,SAAS,yBAAyB,SAAS;AACjD,QAAM,OAAO,yBAAyB,aAAa;AACnD,MAAI,OAAO,WAAW,KAAK,KAAK,WAAW,EAAG,QAAO;AACrD,SAAO,GAAG,MAAM,KAAK,IAAI;AAC3B;AAMO,SAAS,wBAAwB,MAG3B;AACX,MAAI,CAAC,KAAK,UAAW,QAAO,CAAC;AAC7B,MAAI,CAAC,KAAK,qBAAsB,QAAO,CAAC;AACxC,QAAM,OAAiB,CAAC;AACxB,aAAW,YAAY,OAAO,KAAK,KAAK,oBAAoB,GAAG;AAC7D,UAAM,MAAM,uBAAuB,KAAK,WAAW,QAAQ;AAC3D,QAAI,IAAK,MAAK,KAAK,GAAG;AAAA,EACxB;AACA,SAAO;AACT;AAYO,SAAS,+BACd,YACA,QACS;AACT,QAAM,mBAAmB,yBAAyB,MAAM;AACxD,aAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,UAAU,GAAG;AAC/C,QAAI,yBAAyB,CAAC,MAAM,iBAAkB,QAAO;AAAA,EAC/D;AACA,SAAO;AACT;AAgBO,SAAS,wBAAwB,MAMH;AACnC,QAAM,EAAE,WAAW,cAAc,eAAe,cAAc,YAAY,IAAI;AAE9E,MAAI,UAAU,OAAO,YAAa,QAAO;AACzC,MAAI,UAAU,UAAU,UAAU,WAAW,SAAU,QAAO;AAC9D,M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