@remnic/core 10.0.94 → 10.0.96
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/abstraction-nodes.d.ts.map +1 -1
- package/dist/abstraction-nodes.js +7 -1
- package/dist/access-admin-ops-surface.js +91 -90
- package/dist/access-audit.js +2 -2
- package/dist/access-cli.js +91 -90
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.js +91 -90
- package/dist/access-http-briefing.js +91 -90
- package/dist/access-http-query.js +91 -90
- package/dist/access-http.js +91 -90
- package/dist/access-identity-continuity-surface.js +91 -90
- package/dist/access-lcm-surface.js +91 -90
- package/dist/access-mcp.js +91 -90
- package/dist/access-observe-write-surface.js +91 -90
- package/dist/access-operations-batch.js +91 -90
- package/dist/access-operations.js +91 -90
- package/dist/access-recall-concurrency.js +91 -90
- package/dist/access-recall-response.js +91 -90
- package/dist/access-recall-surface.js +91 -90
- package/dist/access-schema.d.ts +5 -5
- package/dist/access-service.js +91 -90
- package/dist/active-recall.js +16 -16
- package/dist/briefing.js +15 -15
- package/dist/buffer.js +7 -7
- package/dist/calibration.js +2 -2
- package/dist/{capsule-merge-6IDAYTKG.js → capsule-merge-ILR35DIB.js} +10 -10
- package/dist/causal-consolidation.js +16 -16
- package/dist/{chunk-QHARXWTC.js → chunk-2LCX6TAD.js} +2 -2
- package/dist/{chunk-UN4RVUG2.js → chunk-2R3ACFYN.js} +3 -3
- package/dist/{chunk-RQFXZYTF.js → chunk-33C4BK7I.js} +4 -4
- package/dist/{chunk-UBEKET2V.js → chunk-3R63SXC5.js} +4 -4
- package/dist/{chunk-LNGELD2M.js → chunk-3VWU3KF3.js} +2 -2
- package/dist/{chunk-FWRXW7CZ.js → chunk-4CXK3GT3.js} +29 -29
- package/dist/{chunk-DNY63QWJ.js → chunk-4HK7DYOL.js} +2 -2
- package/dist/{chunk-LLPMMMWG.js → chunk-4IJFJQPD.js} +2 -2
- package/dist/{chunk-GBJUTX44.js → chunk-4WKR4P7H.js} +2 -2
- package/dist/{chunk-ILY5SSOM.js → chunk-53ZVHXVZ.js} +6 -6
- package/dist/{chunk-FQAQ63QA.js → chunk-5AJIGWY4.js} +2 -2
- package/dist/{chunk-CIWMTNHW.js → chunk-5NFF2TSD.js} +2 -2
- package/dist/{chunk-D5XG2KPS.js → chunk-7E7J7QXB.js} +2 -2
- package/dist/{chunk-2WCLTWV2.js → chunk-7NVK6AGC.js} +2 -2
- package/dist/{chunk-PC5DRBGD.js → chunk-AP4BFWSW.js} +2 -2
- package/dist/{chunk-CL4JU3DF.js → chunk-B7L4ZYFY.js} +3 -3
- package/dist/{chunk-LQ5SS4OP.js → chunk-D6IGZYTN.js} +3 -3
- package/dist/{chunk-XJ2S5UBF.js → chunk-DWWX3FU3.js} +3 -3
- package/dist/{chunk-IL3RHBWM.js → chunk-EJ23D4JG.js} +3 -3
- package/dist/{chunk-F4QFU5IZ.js → chunk-EZ7XJJ5L.js} +2 -2
- package/dist/{chunk-FZZMLGWQ.js → chunk-F4BUSX3D.js} +2 -2
- package/dist/{chunk-LXATZLSC.js → chunk-FL3O34XF.js} +12 -5
- package/dist/chunk-FL3O34XF.js.map +1 -0
- package/dist/{chunk-DPPLNZ3A.js → chunk-FM4P7HSW.js} +4 -4
- package/dist/{chunk-QDESY76F.js → chunk-FQACH7MC.js} +2 -2
- package/dist/{chunk-XPXHQI6N.js → chunk-FVMEZ57K.js} +2 -2
- package/dist/{chunk-F2XNSIPP.js → chunk-G2CGIFRP.js} +10 -3
- package/dist/chunk-G2CGIFRP.js.map +1 -0
- package/dist/{chunk-ZDV5YWID.js → chunk-GLDIMGOS.js} +6 -6
- package/dist/{chunk-YIXJSW5M.js → chunk-HA5DASDG.js} +3 -3
- package/dist/{chunk-S3S72HRM.js → chunk-HCCRWSP7.js} +2 -2
- package/dist/{chunk-NMGHGTVR.js → chunk-HRMOKGQM.js} +6 -6
- package/dist/{chunk-OUVYYKYU.js → chunk-IBKGQ6EY.js} +2 -2
- package/dist/{chunk-RNG7S3FY.js → chunk-ICHLN5L6.js} +6 -6
- package/dist/chunk-ITAUMNQU.js +40 -0
- package/dist/chunk-ITAUMNQU.js.map +1 -0
- package/dist/{chunk-R23JWJD3.js → chunk-J426U7XK.js} +9 -9
- package/dist/{chunk-QMFAMOT2.js → chunk-JH5AV542.js} +2 -2
- package/dist/{chunk-WGGRZYSQ.js → chunk-KE3JWIZK.js} +8 -8
- package/dist/{chunk-SQ3GEIEL.js → chunk-KUQLUYIR.js} +5 -5
- package/dist/{chunk-RKABLU5M.js → chunk-KVHGCISP.js} +9 -9
- package/dist/{chunk-RUTN5MMC.js → chunk-LRLQ2PRP.js} +5 -5
- package/dist/{chunk-X5HGU2EM.js → chunk-NT772J7I.js} +2 -2
- package/dist/{chunk-BPK32FRM.js → chunk-NTDHSV7N.js} +61 -6
- package/dist/chunk-NTDHSV7N.js.map +1 -0
- package/dist/{chunk-4EZWSDFL.js → chunk-NX4XDDFQ.js} +3 -3
- package/dist/{chunk-IAYUTGF2.js → chunk-O3GZPLVY.js} +4 -4
- package/dist/{chunk-IGOW4TJE.js → chunk-O3JG4PD3.js} +2 -2
- package/dist/{chunk-UHMHJX5G.js → chunk-OIG4ZFMB.js} +4 -4
- package/dist/{chunk-IQ55QGY5.js → chunk-R4JYSBZE.js} +2 -2
- package/dist/{chunk-Z3FTSHT5.js → chunk-RUQE5C32.js} +2 -2
- package/dist/{chunk-ESLOLCD4.js → chunk-RUWKIPWJ.js} +2 -2
- package/dist/{chunk-W54Z2MOP.js → chunk-RXSGBO7Y.js} +2 -2
- package/dist/{chunk-D5S6RL32.js → chunk-TFMLRVMW.js} +166 -145
- package/dist/{chunk-D5S6RL32.js.map → chunk-TFMLRVMW.js.map} +1 -1
- package/dist/{chunk-BOK6BN5M.js → chunk-THV6PZ7V.js} +2 -2
- package/dist/{chunk-J7BIFOYP.js → chunk-U6TC6Z5B.js} +2 -2
- package/dist/{chunk-X2BVB74H.js → chunk-UZQXJDOE.js} +2 -2
- package/dist/{chunk-SUTEBYGI.js → chunk-V7T45MI6.js} +2 -2
- package/dist/{chunk-A4F7OIC5.js → chunk-WVIWDMFB.js} +2 -2
- package/dist/{chunk-BN2EBCLB.js → chunk-XPCUKWLE.js} +2 -2
- package/dist/{chunk-OJXK5C6Z.js → chunk-ZG4GNPRE.js} +7 -7
- package/dist/{chunk-TYRWSE4B.js → chunk-ZUMHQEW4.js} +2 -2
- package/dist/{chunk-DAOMWGO2.js → chunk-ZX5N5D6M.js} +4 -4
- package/dist/cli.js +91 -90
- package/dist/coding/export-okf-codegraph.js +14 -14
- package/dist/compounding/engine.js +16 -16
- package/dist/config.js +16 -16
- package/dist/connectors/codex-materialize-runner.js +15 -15
- package/dist/connectors/index.js +15 -15
- package/dist/consolidation-provenance-check.js +8 -8
- package/dist/consolidation-undo.js +6 -6
- package/dist/contradiction/index.js +6 -6
- package/dist/convergence-refresh.js +17 -17
- package/dist/corpus-watermark.js +17 -17
- package/dist/cue-anchors.d.ts.map +1 -1
- package/dist/cue-anchors.js +8 -2
- package/dist/{entity-canonical-id-migration-JJSTZF73.js → entity-canonical-id-migration-IG77BOGD.js} +5 -5
- package/dist/entity-mention-index-cache.js +2 -2
- package/dist/entity-retrieval.js +16 -16
- package/dist/explicit-capture.js +91 -90
- package/dist/extraction.js +21 -21
- package/dist/harmonic-construction.js +9 -3
- package/dist/harmonic-graph-version.d.ts +14 -0
- package/dist/harmonic-graph-version.d.ts.map +1 -0
- package/dist/harmonic-graph-version.js +17 -0
- package/dist/harmonic-retrieval.d.ts +19 -14
- package/dist/harmonic-retrieval.d.ts.map +1 -1
- package/dist/harmonic-retrieval.js +22 -17
- package/dist/index.js +105 -104
- package/dist/lcm/engine.js +3 -3
- package/dist/lcm/index.js +8 -8
- package/dist/local-llm.js +2 -2
- package/dist/location/index.js +16 -16
- package/dist/maintenance/memory-governance.js +15 -15
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +15 -15
- package/dist/maintenance/rebuild-memory-projection-runner.js +17 -17
- package/dist/maintenance/rebuild-memory-projection.js +16 -16
- package/dist/memory-browse.js +7 -7
- package/dist/namespaces/migrate.js +16 -16
- package/dist/namespaces/search.js +6 -6
- package/dist/namespaces/storage.js +15 -15
- package/dist/operator-doctor-corpus.js +18 -18
- package/dist/operator-toolkit.js +24 -24
- package/dist/orchestration/backlog-scheduler.js +92 -91
- package/dist/orchestration/backlog-scheduler.js.map +1 -1
- package/dist/orchestration/buffer-drain-runner.js +92 -91
- package/dist/orchestration/extraction-persist-failure.d.ts +25 -1
- package/dist/orchestration/extraction-persist-failure.d.ts.map +1 -1
- package/dist/orchestration/extraction-persist.d.ts +3 -6
- package/dist/orchestration/extraction-persist.d.ts.map +1 -1
- package/dist/orchestration/maintenance.js +25 -25
- package/dist/orchestrator.js +93 -92
- package/dist/page-versioning.js +6 -6
- package/dist/qmd.js +4 -4
- package/dist/recall-navigation.js +91 -90
- package/dist/recall-state-view-admission.js +7 -7
- package/dist/recall-why-service.js +7 -7
- package/dist/{resolution-OVVIF7ZY.js → resolution-G4SLHSEU.js} +7 -7
- package/dist/resolution-G4SLHSEU.js.map +1 -0
- package/dist/resume-bundles.js +17 -17
- package/dist/schemas.d.ts +9 -9
- package/dist/search/factory.js +5 -5
- package/dist/search/index.js +5 -5
- package/dist/semantic-consolidation.js +16 -16
- package/dist/semantic-rule-promotion.js +15 -15
- package/dist/semantic-rule-verifier.js +15 -15
- package/dist/source-agent-qualifier.js +18 -18
- package/dist/standup/build.js +15 -15
- package/dist/storage.js +14 -14
- package/dist/summarizer.js +3 -3
- package/dist/support-passport/index.js +3 -3
- package/dist/transfer/capsule-import.js +8 -8
- package/dist/transfer/export-okf.js +15 -15
- package/dist/verified-recall.js +15 -15
- package/dist/who-knows-cli.js +16 -16
- package/dist/who-knows.js +15 -15
- package/package.json +2 -2
- package/src/abstraction-nodes.ts +7 -2
- package/src/cue-anchors.ts +8 -3
- package/src/harmonic-graph-cache.test.ts +244 -0
- package/src/harmonic-graph-version.ts +46 -0
- package/src/harmonic-retrieval.ts +92 -2
- package/src/orchestration/extraction-persist-failure.test.ts +90 -0
- package/src/orchestration/extraction-persist-failure.ts +39 -1
- package/src/orchestration/extraction-persist.ts +29 -21
- package/src/orchestration/recall-internal.ts +1 -1
- package/src/orchestrator-persist-branch-failure.test.ts +271 -0
- package/dist/chunk-BPK32FRM.js.map +0 -1
- package/dist/chunk-F2XNSIPP.js.map +0 -1
- package/dist/chunk-LXATZLSC.js.map +0 -1
- /package/dist/{capsule-merge-6IDAYTKG.js.map → capsule-merge-ILR35DIB.js.map} +0 -0
- /package/dist/{chunk-QHARXWTC.js.map → chunk-2LCX6TAD.js.map} +0 -0
- /package/dist/{chunk-UN4RVUG2.js.map → chunk-2R3ACFYN.js.map} +0 -0
- /package/dist/{chunk-RQFXZYTF.js.map → chunk-33C4BK7I.js.map} +0 -0
- /package/dist/{chunk-UBEKET2V.js.map → chunk-3R63SXC5.js.map} +0 -0
- /package/dist/{chunk-LNGELD2M.js.map → chunk-3VWU3KF3.js.map} +0 -0
- /package/dist/{chunk-FWRXW7CZ.js.map → chunk-4CXK3GT3.js.map} +0 -0
- /package/dist/{chunk-DNY63QWJ.js.map → chunk-4HK7DYOL.js.map} +0 -0
- /package/dist/{chunk-LLPMMMWG.js.map → chunk-4IJFJQPD.js.map} +0 -0
- /package/dist/{chunk-GBJUTX44.js.map → chunk-4WKR4P7H.js.map} +0 -0
- /package/dist/{chunk-ILY5SSOM.js.map → chunk-53ZVHXVZ.js.map} +0 -0
- /package/dist/{chunk-FQAQ63QA.js.map → chunk-5AJIGWY4.js.map} +0 -0
- /package/dist/{chunk-CIWMTNHW.js.map → chunk-5NFF2TSD.js.map} +0 -0
- /package/dist/{chunk-D5XG2KPS.js.map → chunk-7E7J7QXB.js.map} +0 -0
- /package/dist/{chunk-2WCLTWV2.js.map → chunk-7NVK6AGC.js.map} +0 -0
- /package/dist/{chunk-PC5DRBGD.js.map → chunk-AP4BFWSW.js.map} +0 -0
- /package/dist/{chunk-CL4JU3DF.js.map → chunk-B7L4ZYFY.js.map} +0 -0
- /package/dist/{chunk-LQ5SS4OP.js.map → chunk-D6IGZYTN.js.map} +0 -0
- /package/dist/{chunk-XJ2S5UBF.js.map → chunk-DWWX3FU3.js.map} +0 -0
- /package/dist/{chunk-IL3RHBWM.js.map → chunk-EJ23D4JG.js.map} +0 -0
- /package/dist/{chunk-F4QFU5IZ.js.map → chunk-EZ7XJJ5L.js.map} +0 -0
- /package/dist/{chunk-FZZMLGWQ.js.map → chunk-F4BUSX3D.js.map} +0 -0
- /package/dist/{chunk-DPPLNZ3A.js.map → chunk-FM4P7HSW.js.map} +0 -0
- /package/dist/{chunk-QDESY76F.js.map → chunk-FQACH7MC.js.map} +0 -0
- /package/dist/{chunk-XPXHQI6N.js.map → chunk-FVMEZ57K.js.map} +0 -0
- /package/dist/{chunk-ZDV5YWID.js.map → chunk-GLDIMGOS.js.map} +0 -0
- /package/dist/{chunk-YIXJSW5M.js.map → chunk-HA5DASDG.js.map} +0 -0
- /package/dist/{chunk-S3S72HRM.js.map → chunk-HCCRWSP7.js.map} +0 -0
- /package/dist/{chunk-NMGHGTVR.js.map → chunk-HRMOKGQM.js.map} +0 -0
- /package/dist/{chunk-OUVYYKYU.js.map → chunk-IBKGQ6EY.js.map} +0 -0
- /package/dist/{chunk-RNG7S3FY.js.map → chunk-ICHLN5L6.js.map} +0 -0
- /package/dist/{chunk-R23JWJD3.js.map → chunk-J426U7XK.js.map} +0 -0
- /package/dist/{chunk-QMFAMOT2.js.map → chunk-JH5AV542.js.map} +0 -0
- /package/dist/{chunk-WGGRZYSQ.js.map → chunk-KE3JWIZK.js.map} +0 -0
- /package/dist/{chunk-SQ3GEIEL.js.map → chunk-KUQLUYIR.js.map} +0 -0
- /package/dist/{chunk-RKABLU5M.js.map → chunk-KVHGCISP.js.map} +0 -0
- /package/dist/{chunk-RUTN5MMC.js.map → chunk-LRLQ2PRP.js.map} +0 -0
- /package/dist/{chunk-X5HGU2EM.js.map → chunk-NT772J7I.js.map} +0 -0
- /package/dist/{chunk-4EZWSDFL.js.map → chunk-NX4XDDFQ.js.map} +0 -0
- /package/dist/{chunk-IAYUTGF2.js.map → chunk-O3GZPLVY.js.map} +0 -0
- /package/dist/{chunk-IGOW4TJE.js.map → chunk-O3JG4PD3.js.map} +0 -0
- /package/dist/{chunk-UHMHJX5G.js.map → chunk-OIG4ZFMB.js.map} +0 -0
- /package/dist/{chunk-IQ55QGY5.js.map → chunk-R4JYSBZE.js.map} +0 -0
- /package/dist/{chunk-Z3FTSHT5.js.map → chunk-RUQE5C32.js.map} +0 -0
- /package/dist/{chunk-ESLOLCD4.js.map → chunk-RUWKIPWJ.js.map} +0 -0
- /package/dist/{chunk-W54Z2MOP.js.map → chunk-RXSGBO7Y.js.map} +0 -0
- /package/dist/{chunk-BOK6BN5M.js.map → chunk-THV6PZ7V.js.map} +0 -0
- /package/dist/{chunk-J7BIFOYP.js.map → chunk-U6TC6Z5B.js.map} +0 -0
- /package/dist/{chunk-X2BVB74H.js.map → chunk-UZQXJDOE.js.map} +0 -0
- /package/dist/{chunk-SUTEBYGI.js.map → chunk-V7T45MI6.js.map} +0 -0
- /package/dist/{chunk-A4F7OIC5.js.map → chunk-WVIWDMFB.js.map} +0 -0
- /package/dist/{chunk-BN2EBCLB.js.map → chunk-XPCUKWLE.js.map} +0 -0
- /package/dist/{chunk-OJXK5C6Z.js.map → chunk-ZG4GNPRE.js.map} +0 -0
- /package/dist/{chunk-TYRWSE4B.js.map → chunk-ZUMHQEW4.js.map} +0 -0
- /package/dist/{chunk-DAOMWGO2.js.map → chunk-ZX5N5D6M.js.map} +0 -0
- /package/dist/{entity-canonical-id-migration-JJSTZF73.js.map → entity-canonical-id-migration-IG77BOGD.js.map} +0 -0
- /package/dist/{resolution-OVVIF7ZY.js.map → harmonic-graph-version.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/harmonic-retrieval.ts"],"sourcesContent":["import path from \"node:path\";\nimport { realpath } from \"node:fs/promises\";\nimport { listJsonFilesStrict, readJsonFile } from \"./json-store.js\";\nimport { throwIfAborted } from \"./abort-error.js\";\nimport { inferMemoryStatus, toMemoryPathRel } from \"./memory-lifecycle-ledger-utils.js\";\n import {\n HARMONIC_SOURCE_MEMORY_INSERTED_AT_KEY,\n resolveAbstractionNodeStoreDir,\n validateAbstractionNode,\n type AbstractionNode,\n } from \"./abstraction-nodes.js\";\nimport { resolveCueAnchorStoreDir, validateCueAnchor, type CueAnchor, type CueAnchorType } from \"./cue-anchors.js\";\nimport { compareDeterministicStrings } from \"./deterministic-order.js\";\nimport { countRecallTokenOverlap, normalizeRecallTokens } from \"./recall-tokenization.js\";\nimport { stripAttributesSuffix } from \"./structured-attributes.js\";\nimport { isValidityExpiredNow } from \"./temporal-validity.js\";\nimport { assertSafePathSegment, isRecord } from \"./store-contract.js\";\nimport { isSupportPassportPrivateMemory } from \"./support-passport/card-projection.js\";\nimport type { MemoryFile } from \"./types.js\";\nimport { readProjectedMemoryStates } from \"./memory-projection-batch.js\";\nimport { SecureStoreLockedError } from \"./secure-store/secure-fs.js\";\nimport { StorageManager } from \"./storage.js\";\nimport { RECALL_FALLBACK_DIRS } from \"./utils/category-dir.js\";\nimport { readHarmonicSourceMemory, readUnresolvedHarmonicSources } from \"./harmonic-source-lookup.js\";\n\n\ntype SourceMemoryMap = Map<string, MemoryFile>;\n\n\n// An index older than this is treated as unusable: the date window needed to\n// cover \"created since the last rebuild\" would stop being cheap.\nconst INDEX_MAX_AGE_MS = 7 * 86_400_000;\nconst DAY_MS = 86_400_000;\n\nfunction utcDaysSince(rebuiltMs: number, nowMs: number): string[] {\n const days: string[] = [];\n for (let day = Math.floor((rebuiltMs - DAY_MS) / DAY_MS) * DAY_MS; day <= nowMs; day += DAY_MS) {\n days.push(new Date(day).toISOString().slice(0, 10));\n }\n return days;\n}\n\n\n// Memories the projection has no row for were written after its last rebuild, so\n// their dated directory is normally one of `days`. Hot and cold tiers are probed\n// by exact path. Only recall-corpus categories are probed: `questions/` is a queue\n// and `artifacts/` is outside the recall surface, so neither can be a source.\nfunction unprojectedCandidatePaths(memoryDir: string, id: string, days: string[]): string[] {\n const paths: string[] = [];\n for (const root of [memoryDir, path.join(memoryDir, \"cold\")]) {\n for (const dir of RECALL_FALLBACK_DIRS) {\n paths.push(path.join(root, dir, `${id}.md`));\n for (const day of days) paths.push(path.join(root, dir, day, `${id}.md`));\n }\n }\n return paths;\n}\n\n/** Resolve indexed sources first, then use the durable unresolved-id path cache. */\nasync function readIndexedSourceMemories(options: {\n memoryDir: string;\n abortSignal?: AbortSignal;\n sourceMemoryIds: string[];\n nowMs: number;\n}): Promise<SourceMemoryMap | null> {\n // The ids go to SQL as bound parameters, so any id the projection holds is safe to look up.\n const batch = readProjectedMemoryStates(options.memoryDir, options.sourceMemoryIds);\n const rebuiltMs = Date.parse(batch?.rebuiltAt ?? \"\");\n if (!batch?.complete || !batch.rebuiltAt || !Number.isFinite(rebuiltMs) || options.nowMs - rebuiltMs > INDEX_MAX_AGE_MS) return null;\n const rootReal = await realpath(options.memoryDir).catch(() => null);\n if (rootReal === null) return null;\n\n const storage = new StorageManager(options.memoryDir);\n const days = utcDaysSince(rebuiltMs, options.nowMs);\n const sourceMemories: SourceMemoryMap = new Map();\n const pending: string[] = [];\n for (const id of options.sourceMemoryIds) {\n const state = batch.states.get(id);\n // An id is only ever joined into a path when it is a single safe segment.\n let safeId = true;\n try {\n assertSafePathSegment(id, \"sourceMemoryId\");\n } catch {\n safeId = false;\n }\n // state.path was containment-checked by the projection reader.\n const candidates = state\n ? [state.path, path.join(options.memoryDir, \"cold\", state.pathRel)]\n : safeId ? unprojectedCandidatePaths(options.memoryDir, id, days) : [];\n let found = false;\n for (const candidate of candidates) {\n const memory = await readHarmonicSourceMemory(storage, rootReal, candidate, options.abortSignal);\n if (memory?.frontmatter.id !== id) continue;\n sourceMemories.set(id, memory);\n found = true;\n break;\n }\n if (!found) pending.push(id);\n }\n if (pending.length === 0) return sourceMemories;\n\n const unresolved = await readUnresolvedHarmonicSources({\n storage, rootReal, rebuiltAt: batch.rebuiltAt, sourceMemoryIds: pending,\n nowMs: options.nowMs, abortSignal: options.abortSignal,\n });\n for (const [id, memory] of unresolved) sourceMemories.set(id, memory);\n return sourceMemories;\n}\n\nasync function readCorpusSourceMemories(options: {\n memoryDir: string;\n abortSignal?: AbortSignal;\n}): Promise<SourceMemoryMap> {\n const sourceMemories: SourceMemoryMap = new Map();\n try {\n const storage = new StorageManager(options.memoryDir);\n const [hotMemories, coldMemories] = await Promise.all([\n storage.readAllMemories({ abortSignal: options.abortSignal }),\n storage.readAllColdMemories({ abortSignal: options.abortSignal }),\n ]);\n for (const memory of [...hotMemories, ...coldMemories]) {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n sourceMemories.set(memory.frontmatter.id, memory);\n }\n } catch (err) {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n if (err instanceof SecureStoreLockedError) return new Map();\n // Source validation fails closed when the authorized memory directory is\n // unreadable. Source-less nodes remain eligible for retrieval.\n sourceMemories.clear();\n }\n return sourceMemories;\n}\n\nasync function readSourceMemories(options: {\n memoryDir: string;\n abortSignal?: AbortSignal;\n sourceMemoryIds: string[];\n nowMs?: number;\n}): Promise<SourceMemoryMap> {\n try {\n const indexed = await readIndexedSourceMemories({\n memoryDir: options.memoryDir,\n abortSignal: options.abortSignal,\n sourceMemoryIds: options.sourceMemoryIds,\n nowMs: options.nowMs ?? Date.now(),\n });\n if (indexed) return indexed;\n } catch (err) {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n if (err instanceof SecureStoreLockedError) return new Map();\n }\n return readCorpusSourceMemories(options);\n}\n\nfunction parseSourceMemoryInsertedAt(node: AbstractionNode): Map<string, string> {\n const insertedAtById = new Map<string, string>();\n const insertedAtRaw = node.metadata?.[HARMONIC_SOURCE_MEMORY_INSERTED_AT_KEY];\n if (!insertedAtRaw) return insertedAtById;\n try {\n const parsed = JSON.parse(insertedAtRaw) as unknown;\n if (!isRecord(parsed)) return insertedAtById;\n for (const [memoryId, value] of Object.entries(parsed)) {\n if (typeof value === \"string\") insertedAtById.set(memoryId, value);\n }\n } catch {\n // Malformed insertion metadata leaves ordering on the recordedAt fallback.\n }\n return insertedAtById;\n}\n\nfunction projectSourceBackedNode(\n node: AbstractionNode,\n sourceMemories: SourceMemoryMap,\n memoryDir: string,\n temporalExpiredInInjection: boolean,\n nowMs: number\n): AbstractionNode | null {\n const sourceMemoryIds = node.sourceMemoryIds ?? [];\n if (sourceMemoryIds.length === 0) return node;\n\n const activeSourceMemoryIds = sourceMemoryIds.filter((memoryId) => {\n const memory = sourceMemories.get(memoryId);\n return (\n memory !== undefined &&\n // #2332: a private support-passport record leaves the eligible set the\n // same way a rejected one does — a node title or anchor attribution\n // rebuilt from it would leak governed metadata into the deep-recall\n // frontier (and every other graph reader) before any content check runs.\n !isSupportPassportPrivateMemory(memory) &&\n inferMemoryStatus(memory.frontmatter, toMemoryPathRel(memoryDir, memory.path)) === \"active\" &&\n (temporalExpiredInInjection || !isValidityExpiredNow(memory.frontmatter, nowMs))\n );\n });\n if (activeSourceMemoryIds.length === 0) return null;\n\n // Newest-first source order keeps the projected title and summary on the most\n // recently inserted facts. Equal or missing timestamps fall back to ascending\n // id order, which matches the stored sourceMemoryIds order.\n const insertedAtById = parseSourceMemoryInsertedAt(node);\n const insertedAtMs = (memoryId: string): number => {\n const parsedMs = Date.parse(insertedAtById.get(memoryId) ?? \"\");\n return Number.isFinite(parsedMs) ? parsedMs : Date.parse(node.recordedAt);\n };\n activeSourceMemoryIds.sort(\n (left, right) =>\n insertedAtMs(right) - insertedAtMs(left) || compareDeterministicStrings(left, right)\n );\n\n const activeMemories = activeSourceMemoryIds.flatMap((memoryId) => {\n const memory = sourceMemories.get(memoryId);\n return memory ? [memory] : [];\n });\n const activeContents = activeMemories.map((memory) =>\n memory.frontmatter.structuredAttributes ? stripAttributesSuffix(memory.content) : memory.content\n );\n let metadata: Record<string, string> | undefined;\n const activeInsertedAt = activeSourceMemoryIds.flatMap((memoryId) => {\n const value = insertedAtById.get(memoryId);\n return typeof value === \"string\" ? [[memoryId, value] as const] : [];\n });\n if (activeInsertedAt.length > 0) {\n metadata = {\n [HARMONIC_SOURCE_MEMORY_INSERTED_AT_KEY]: JSON.stringify(Object.fromEntries(activeInsertedAt)),\n };\n }\n\n return {\n ...node,\n sourceMemoryIds: activeSourceMemoryIds,\n title: activeContents[0]?.slice(0, 80) ?? node.title,\n summary: activeContents.slice(0, 3).join(\"; \").slice(0, 400),\n tags: [...new Set(activeMemories.flatMap((memory) => memory.frontmatter.tags))].sort(compareDeterministicStrings),\n entityRefs: [\n ...new Set(\n activeMemories.flatMap((memory) =>\n typeof memory.frontmatter.entityRef === \"string\" ? [memory.frontmatter.entityRef] : []\n )\n ),\n ].sort(compareDeterministicStrings),\n metadata,\n };\n}\n\nfunction anchorMatchesProjectedNode(\n anchor: CueAnchor,\n nodeRef: string,\n node: AbstractionNode,\n allowLegacyAttribution: boolean\n): boolean {\n const activeSourceMemoryIds = node.sourceMemoryIds ?? [];\n if (activeSourceMemoryIds.length === 0) return true;\n if (!anchor.sourceMemoryIdsByNodeRef) return allowLegacyAttribution;\n const anchorSourceMemoryIds = anchor.sourceMemoryIdsByNodeRef[nodeRef] ?? [];\n return anchorSourceMemoryIds.some((sourceMemoryId) => activeSourceMemoryIds.includes(sourceMemoryId));\n}\n\nexport interface HarmonicMatchedAnchor {\n anchorId: string;\n anchorType: CueAnchorType;\n anchorValue: string;\n}\n\nexport interface HarmonicRetrievalResult {\n node: AbstractionNode;\n score: number;\n nodeScore: number;\n anchorScore: number;\n matchedFields: string[];\n matchedAnchors: HarmonicMatchedAnchor[];\n}\n\ninterface HarmonicCandidate {\n node: AbstractionNode;\n nodeScore: number;\n anchorScore: number;\n matchedFields: Set<string>;\n matchedAnchors: Map<string, HarmonicMatchedAnchor>;\n}\n\nfunction scoreNode(node: AbstractionNode, queryTokens: Set<string>): { score: number; matchedFields: string[] } {\n const matchedFields: string[] = [];\n let score = 0;\n\n const titleMatches = countRecallTokenOverlap(queryTokens, node.title);\n if (titleMatches > 0) {\n score += titleMatches * 3;\n matchedFields.push(\"title\");\n }\n\n const summaryMatches = countRecallTokenOverlap(queryTokens, node.summary);\n if (summaryMatches > 0) {\n score += summaryMatches * 3;\n matchedFields.push(\"summary\");\n }\n\n const tagMatches = countRecallTokenOverlap(queryTokens, node.tags?.join(\" \"));\n if (tagMatches > 0) {\n score += tagMatches * 2;\n matchedFields.push(\"tags\");\n }\n\n const entityMatches = countRecallTokenOverlap(queryTokens, node.entityRefs?.join(\" \"));\n if (entityMatches > 0) {\n score += entityMatches * 2;\n matchedFields.push(\"entityRefs\");\n }\n\n const kindMatches = countRecallTokenOverlap(queryTokens, `${node.kind} ${node.abstractionLevel}`);\n if (kindMatches > 0) {\n score += kindMatches;\n matchedFields.push(\"kind\");\n }\n\n return { score, matchedFields };\n}\n\nfunction scoreAnchor(\n anchor: CueAnchor,\n queryTokens: Set<string>,\n eligibleNodeTags: readonly string[]\n): { score: number; matchedFields: string[] } {\n const matchedFields: string[] = [];\n let score = 0;\n\n const valueMatches = countRecallTokenOverlap(queryTokens, anchor.anchorValue);\n const normalizedMatches = countRecallTokenOverlap(queryTokens, anchor.normalizedCue);\n const cueMatches = Math.max(valueMatches, normalizedMatches);\n if (cueMatches > 0) {\n score += cueMatches * 4;\n if (valueMatches > 0) matchedFields.push(\"anchorValue\");\n if (normalizedMatches > 0) matchedFields.push(\"anchor\");\n }\n\n const typeMatches = countRecallTokenOverlap(queryTokens, anchor.anchorType);\n if (typeMatches > 0) {\n score += typeMatches;\n matchedFields.push(\"anchorType\");\n }\n\n const tagMatches = countRecallTokenOverlap(queryTokens, eligibleNodeTags.join(\" \"));\n if (tagMatches > 0) {\n score += tagMatches * 2;\n matchedFields.push(\"anchorTags\");\n }\n\n return { score, matchedFields };\n}\n\nexport async function readAbstractionNodes(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n}): Promise<AbstractionNode[]> {\n const rootDir = resolveAbstractionNodeStoreDir(options.memoryDir, options.abstractionNodeStoreDir);\n const files = await listJsonFilesStrict(path.join(rootDir, \"nodes\"), { allowMissingDirectory: true });\n const nodes: AbstractionNode[] = [];\n for (const filePath of files) {\n try {\n nodes.push(validateAbstractionNode(await readJsonFile(filePath)));\n } catch {\n // fail-open: invalid artifacts stay visible via status tooling instead of recall\n }\n }\n return nodes;\n}\n\nexport async function readCueAnchors(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n}): Promise<CueAnchor[]> {\n const abstractionRoot = resolveAbstractionNodeStoreDir(options.memoryDir, options.abstractionNodeStoreDir);\n const rootDir = resolveCueAnchorStoreDir(abstractionRoot);\n const files = await listJsonFilesStrict(rootDir, { allowMissingDirectory: true });\n const anchors: CueAnchor[] = [];\n for (const filePath of files) {\n try {\n anchors.push(validateCueAnchor(await readJsonFile(filePath)));\n } catch {\n // fail-open: invalid artifacts stay visible via status tooling instead of recall\n }\n }\n return anchors;\n}\n\nexport interface ProjectedHarmonicGraph {\n nodes: AbstractionNode[];\n anchors: CueAnchor[];\n}\n\n/**\n * Read nodes + anchors and project BOTH against the namespace's current active\n * memories. This is the single projection every graph reader shares: a raw\n * `readAbstractionNodes` / `readCueAnchors` pair still carries the stored title,\n * summary, tags, and anchor attribution of a memory that was later rejected,\n * quarantined, or otherwise moved out of the active set, so a second reader\n * that skipped the projection could leak governed metadata even when the\n * memory itself is excluded from the final results.\n *\n * - A node whose every source memory left the active set is dropped.\n * - A surviving node's title/summary/tags/entityRefs are rebuilt from its\n * active sources only.\n * - An anchor keeps a node reference only while its attribution runs through\n * one of that node's surviving active sources, and is dropped once no\n * reference survives.\n */\nexport async function readProjectedHarmonicGraph(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n anchorsEnabled: boolean;\n abortSignal?: AbortSignal;\n temporalExpiredInInjection?: boolean;\n nowMs?: number;\n}): Promise<ProjectedHarmonicGraph> {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n const nodes = await readAbstractionNodes(options);\n const sourceMemoryIds = [...new Set(nodes.flatMap((node) => node.sourceMemoryIds ?? []))];\n const sourceMemories: SourceMemoryMap = sourceMemoryIds.length > 0\n ? await readSourceMemories({\n memoryDir: options.memoryDir,\n abortSignal: options.abortSignal,\n sourceMemoryIds,\n nowMs: options.nowMs,\n })\n : new Map();\n const nowMs = options.nowMs ?? Date.now();\n // A node whose full stored source set survived projection keeps legacy\n // anchor attribution (an anchor written before per-node source ids existed).\n const legacyCompatibleNodeRefs = new Set<string>();\n const projectedNodes = nodes.flatMap((node) => {\n const projected = projectSourceBackedNode(\n node,\n sourceMemories,\n options.memoryDir,\n options.temporalExpiredInInjection === true,\n nowMs\n );\n if (\n projected &&\n (node.sourceMemoryIds?.length ?? 0) > 0 &&\n projected.sourceMemoryIds?.length === node.sourceMemoryIds?.length\n ) {\n legacyCompatibleNodeRefs.add(node.nodeId);\n }\n return projected ? [projected] : [];\n });\n if (!options.anchorsEnabled) return { nodes: projectedNodes, anchors: [] };\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n const nodeIndex = new Map(projectedNodes.map((node) => [node.nodeId, node]));\n const anchors = (await readCueAnchors(options)).flatMap((anchor) => {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n const nodeRefs = anchor.nodeRefs.filter((nodeRef) => {\n const node = nodeIndex.get(nodeRef);\n return (\n node !== undefined &&\n anchorMatchesProjectedNode(anchor, nodeRef, node, legacyCompatibleNodeRefs.has(nodeRef))\n );\n });\n return nodeRefs.length > 0 ? [{ ...anchor, nodeRefs }] : [];\n });\n return { nodes: projectedNodes, anchors };\n}\n\nexport async function searchHarmonicRetrieval(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n query: string;\n maxResults: number;\n sessionKey?: string;\n anchorsEnabled: boolean;\n abortSignal?: AbortSignal;\n temporalExpiredInInjection?: boolean;\n}): Promise<HarmonicRetrievalResult[]> {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n const queryTokens = new Set(normalizeRecallTokens(options.query, [\"what\", \"which\"]));\n if (queryTokens.size === 0 || options.maxResults <= 0) return [];\n\n // One projection for every graph reader: nodes and anchors both arrive\n // already narrowed to the namespace's current active memories.\n const { nodes: eligibleNodes, anchors } = await readProjectedHarmonicGraph(options);\n const candidates = new Map<string, HarmonicCandidate>();\n\n for (const node of eligibleNodes) {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n const { score, matchedFields } = scoreNode(node, queryTokens);\n if (score <= 0) continue;\n candidates.set(node.nodeId, {\n node,\n nodeScore: score,\n anchorScore: 0,\n matchedFields: new Set(matchedFields),\n matchedAnchors: new Map(),\n });\n }\n\n if (options.anchorsEnabled) {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n const nodeIndex = new Map(eligibleNodes.map((node) => [node.nodeId, node]));\n for (const anchor of anchors) {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n // `nodeRefs` are the projection's surviving references already.\n const eligibleNodeRefs = anchor.nodeRefs;\n const eligibleNodeTags = new Set(eligibleNodeRefs.flatMap((nodeRef) => nodeIndex.get(nodeRef)?.tags ?? []));\n const eligibleAnchorTags = anchor.tags?.filter((tag) => eligibleNodeTags.has(tag)) ?? [];\n const { score, matchedFields } = scoreAnchor(anchor, queryTokens, eligibleAnchorTags);\n if (score <= 0) continue;\n for (const nodeRef of eligibleNodeRefs) {\n const node = nodeIndex.get(nodeRef);\n if (!node) continue;\n const existing = candidates.get(nodeRef) ?? {\n node,\n nodeScore: 0,\n anchorScore: 0,\n matchedFields: new Set<string>(),\n matchedAnchors: new Map<string, HarmonicMatchedAnchor>(),\n };\n existing.anchorScore += score;\n existing.matchedFields.add(\"anchor\");\n for (const field of matchedFields) existing.matchedFields.add(field);\n existing.matchedAnchors.set(anchor.anchorId, {\n anchorId: anchor.anchorId,\n anchorType: anchor.anchorType,\n anchorValue: anchor.anchorValue,\n });\n candidates.set(nodeRef, existing);\n }\n }\n }\n\n return [...candidates.values()]\n .map((candidate) => {\n let score = candidate.nodeScore + candidate.anchorScore;\n if (options.sessionKey && candidate.node.sessionKey === options.sessionKey) score += 0.5;\n return {\n node: candidate.node,\n score,\n nodeScore: candidate.nodeScore,\n anchorScore: candidate.anchorScore,\n matchedFields: [...candidate.matchedFields].sort(),\n matchedAnchors: [...candidate.matchedAnchors.values()].sort(\n (left, right) =>\n left.anchorType.localeCompare(right.anchorType) || left.anchorValue.localeCompare(right.anchorValue)\n ),\n };\n })\n .filter((result) => result.nodeScore > 0 || result.anchorScore > 0)\n .sort(\n (left, right) =>\n right.score - left.score ||\n right.anchorScore - left.anchorScore ||\n right.node.recordedAt.localeCompare(left.node.recordedAt)\n )\n .slice(0, options.maxResults);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AACjB,SAAS,gBAAgB;AA8BzB,IAAM,mBAAmB,IAAI;AAC7B,IAAM,SAAS;AAEf,SAAS,aAAa,WAAmB,OAAyB;AAChE,QAAM,OAAiB,CAAC;AACxB,WAAS,MAAM,KAAK,OAAO,YAAY,UAAU,MAAM,IAAI,QAAQ,OAAO,OAAO,OAAO,QAAQ;AAC9F,SAAK,KAAK,IAAI,KAAK,GAAG,EAAE,YAAY,EAAE,MAAM,GAAG,EAAE,CAAC;AAAA,EACpD;AACA,SAAO;AACT;AAOA,SAAS,0BAA0B,WAAmB,IAAY,MAA0B;AAC1F,QAAM,QAAkB,CAAC;AACzB,aAAW,QAAQ,CAAC,WAAW,KAAK,KAAK,WAAW,MAAM,CAAC,GAAG;AAC5D,eAAW,OAAO,sBAAsB;AACtC,YAAM,KAAK,KAAK,KAAK,MAAM,KAAK,GAAG,EAAE,KAAK,CAAC;AAC3C,iBAAW,OAAO,KAAM,OAAM,KAAK,KAAK,KAAK,MAAM,KA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AU;AAChC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/abstraction-nodes.ts"],"sourcesContent":["import { mkdir, unlink, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { listJsonFilesStrict, readJsonFile, withJsonStoreMutationLock, writeJsonFileAtomic } from \"./json-store.js\";\nimport { compareDeterministicStrings, mergeSortedUniqueStrings } from \"./deterministic-order.js\";\nimport { isNotFoundError } from \"./utils/errno.js\";\nimport {\n assertIsoRecordedAt,\n assertSafePathSegment,\n assertString,\n isRecord,\n optionalStringArray,\n recordStoreDay,\n validateStringRecord,\n} from \"./store-contract.js\";\n\nexport type AbstractionNodeKind = \"episode\" | \"topic\" | \"project\" | \"workflow\" | \"constraint\";\nexport type AbstractionLevel = \"micro\" | \"meso\" | \"macro\";\n\nexport interface AbstractionNode {\n schemaVersion: 1;\n nodeId: string;\n recordedAt: string;\n sessionKey: string;\n kind: AbstractionNodeKind;\n abstractionLevel: AbstractionLevel;\n title: string;\n summary: string;\n sourceMemoryIds?: string[];\n entityRefs?: string[];\n tags?: string[];\n metadata?: Record<string, string>;\n}\n\nexport interface AbstractionNodeStoreStatus {\n enabled: boolean;\n anchorsEnabled: boolean;\n rootDir: string;\n nodesDir: string;\n nodes: {\n total: number;\n valid: number;\n invalid: number;\n byKind: Partial<Record<AbstractionNodeKind, number>>;\n byLevel: Partial<Record<AbstractionLevel, number>>;\n latestNodeId?: string;\n latestRecordedAt?: string;\n latestSessionKey?: string;\n };\n latestNode?: AbstractionNode;\n invalidNodes: Array<{\n path: string;\n error: string;\n }>;\n}\n\nfunction validateKind(raw: unknown): AbstractionNodeKind {\n const value = assertString(raw, \"kind\");\n if (![\"episode\", \"topic\", \"project\", \"workflow\", \"constraint\"].includes(value)) {\n throw new Error(\"kind must be one of episode|topic|project|workflow|constraint\");\n }\n return value as AbstractionNodeKind;\n}\n\nfunction validateLevel(raw: unknown): AbstractionLevel {\n const value = assertString(raw, \"abstractionLevel\");\n if (![\"micro\", \"meso\", \"macro\"].includes(value)) {\n throw new Error(\"abstractionLevel must be one of micro|meso|macro\");\n }\n return value as AbstractionLevel;\n}\n\nexport function resolveAbstractionNodeStoreDir(memoryDir: string, overrideDir?: string): string {\n if (typeof overrideDir === \"string\" && overrideDir.trim().length > 0) {\n return overrideDir.trim();\n }\n return path.join(memoryDir, \"state\", \"abstraction-nodes\");\n}\n\nexport function validateAbstractionNode(raw: unknown): AbstractionNode {\n if (!isRecord(raw)) throw new Error(\"abstraction node must be an object\");\n if (raw.schemaVersion !== 1) throw new Error(\"schemaVersion must be 1\");\n\n return {\n schemaVersion: 1,\n nodeId: assertSafePathSegment(assertString(raw.nodeId, \"nodeId\"), \"nodeId\"),\n recordedAt: assertIsoRecordedAt(assertString(raw.recordedAt, \"recordedAt\")),\n sessionKey: assertString(raw.sessionKey, \"sessionKey\"),\n kind: validateKind(raw.kind),\n abstractionLevel: validateLevel(raw.abstractionLevel),\n title: assertString(raw.title, \"title\"),\n summary: assertString(raw.summary, \"summary\"),\n sourceMemoryIds: optionalStringArray(raw.sourceMemoryIds, \"sourceMemoryIds\"),\n entityRefs: optionalStringArray(raw.entityRefs, \"entityRefs\"),\n tags: optionalStringArray(raw.tags, \"tags\"),\n metadata: validateStringRecord(raw.metadata, \"metadata\"),\n };\n}\n\nexport async function recordAbstractionNode(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n node: AbstractionNode;\n}): Promise<string> {\n const rootDir = resolveAbstractionNodeStoreDir(options.memoryDir, options.abstractionNodeStoreDir);\n const validated = validateAbstractionNode(options.node);\n const day = recordStoreDay(validated.recordedAt);\n const nodesDir = path.join(rootDir, \"nodes\", day);\n const filePath = path.join(nodesDir, `${validated.nodeId}.json`);\n await mkdir(nodesDir, { recursive: true });\n await writeFile(filePath, JSON.stringify(validated, null, 2), \"utf8\");\n return filePath;\n}\n\nconst MAX_ABSTRACTION_NODE_VALUES = 50;\n\nfunction mergeSortedValues(existing: string[] | undefined, incoming: string[] | undefined): string[] {\n return mergeSortedUniqueStrings(existing, incoming).slice(0, MAX_ABSTRACTION_NODE_VALUES);\n}\n\nexport const HARMONIC_SOURCE_MEMORY_INSERTED_AT_KEY = \"remnic.harmonic.sourceMemoryInsertedAt.v1\";\n\nfunction sourceMemoryInsertedAt(node: AbstractionNode | undefined): Map<string, string> {\n const insertedAtById = new Map<string, string>();\n if (!node) return insertedAtById;\n let stored: Record<string, unknown> = {};\n try {\n const parsed = JSON.parse(node.metadata?.[HARMONIC_SOURCE_MEMORY_INSERTED_AT_KEY] ?? \"{}\") as unknown;\n stored = isRecord(parsed) ? parsed : {};\n } catch {\n stored = {};\n }\n for (const memoryId of node.sourceMemoryIds ?? []) {\n const insertedAt = stored[memoryId];\n insertedAtById.set(\n memoryId,\n typeof insertedAt === \"string\" && Number.isFinite(Date.parse(insertedAt)) ? insertedAt : node.recordedAt\n );\n }\n return insertedAtById;\n}\n\nfunction mergeRecentSourceMemoryIds(\n existing: AbstractionNode | undefined,\n incoming: AbstractionNode\n): { ids: string[]; insertedAtJson: string } {\n const insertedAtById = sourceMemoryInsertedAt(existing);\n const incomingSources = [...sourceMemoryInsertedAt(incoming).entries()].sort(\n ([leftId, leftAt], [rightId, rightAt]) =>\n Date.parse(leftAt) - Date.parse(rightAt) || compareDeterministicStrings(leftId, rightId)\n );\n let nextInsertedAtMs = Math.max(\n Date.now(),\n [...insertedAtById.values()].reduce((latest, insertedAt) => Math.max(latest, Date.parse(insertedAt) + 1), 0)\n );\n for (const [memoryId] of incomingSources) {\n if (insertedAtById.has(memoryId)) continue;\n insertedAtById.set(memoryId, new Date(nextInsertedAtMs).toISOString());\n nextInsertedAtMs++;\n }\n const retained = [...insertedAtById.entries()]\n .sort(\n ([leftId, leftAt], [rightId, rightAt]) =>\n Date.parse(rightAt) - Date.parse(leftAt) || compareDeterministicStrings(leftId, rightId)\n )\n .slice(0, MAX_ABSTRACTION_NODE_VALUES);\n const ids = retained.map(([memoryId]) => memoryId).sort(compareDeterministicStrings);\n const retainedInsertedAt = Object.fromEntries(ids.map((memoryId) => [memoryId, insertedAtById.get(memoryId)]));\n return { ids, insertedAtJson: JSON.stringify(retainedInsertedAt) };\n}\n\ntype AbstractionNodeFile = {\n filePath: string;\n node: AbstractionNode;\n};\n\nfunction compareNodeFiles(left: AbstractionNodeFile, right: AbstractionNodeFile): number {\n return (\n Date.parse(right.node.recordedAt) - Date.parse(left.node.recordedAt) ||\n compareDeterministicStrings(left.filePath, right.filePath)\n );\n}\n\nfunction compareIncomingNodes(left: AbstractionNode, right: AbstractionNode): number {\n return (\n Date.parse(left.recordedAt) - Date.parse(right.recordedAt) ||\n compareDeterministicStrings(canonicalNodeKey(left), canonicalNodeKey(right))\n );\n}\n\nfunction canonicalMetadata(metadata: Record<string, string> | undefined): Record<string, string> {\n return Object.fromEntries(\n Object.entries(metadata ?? {}).sort(([left], [right]) => compareDeterministicStrings(left, right))\n );\n}\n\nfunction canonicalNodeKey(node: AbstractionNode): string {\n return JSON.stringify({\n ...node,\n metadata: canonicalMetadata(node.metadata),\n });\n}\n\nfunction mergeAbstractionNodes(existing: AbstractionNode | undefined, incoming: AbstractionNode): AbstractionNode {\n const incomingIsNewest = !existing || Date.parse(existing.recordedAt) <= Date.parse(incoming.recordedAt);\n const newest = incomingIsNewest ? incoming : existing;\n const older = incomingIsNewest ? existing : incoming;\n if (!newest) throw new Error(\"abstraction node merge requires a node\");\n const retainedSources = mergeRecentSourceMemoryIds(existing, incoming);\n const mergedMetadata = canonicalMetadata({\n ...(older?.metadata ?? {}),\n ...(newest.metadata ?? {}),\n [HARMONIC_SOURCE_MEMORY_INSERTED_AT_KEY]: retainedSources.insertedAtJson,\n });\n return validateAbstractionNode({\n ...newest,\n sourceMemoryIds: retainedSources.ids,\n entityRefs: mergeSortedValues(existing?.entityRefs, incoming.entityRefs),\n tags: mergeSortedValues(existing?.tags, incoming.tags),\n metadata: mergedMetadata,\n });\n}\n\nexport async function upsertAbstractionNodes(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n nodes: AbstractionNode[];\n}): Promise<string[]> {\n const rootDir = resolveAbstractionNodeStoreDir(options.memoryDir, options.abstractionNodeStoreDir);\n const incomingNodes = options.nodes.map(validateAbstractionNode);\n if (incomingNodes.length === 0) return [];\n return withJsonStoreMutationLock(rootDir, async () => {\n const nodesDir = path.join(rootDir, \"nodes\");\n const nodeFiles = await listJsonFilesStrict(nodesDir, { allowMissingDirectory: true });\n const existingNodes = await Promise.all(\n nodeFiles.map(async (filePath) => ({\n filePath,\n node: validateAbstractionNode(await readJsonFile(filePath)),\n }))\n );\n const existingById = new Map<string, AbstractionNodeFile[]>();\n for (const existing of existingNodes) {\n const records = existingById.get(existing.node.nodeId) ?? [];\n records.push(existing);\n existingById.set(existing.node.nodeId, records);\n }\n const incomingById = new Map<string, AbstractionNode[]>();\n for (const incoming of incomingNodes) {\n const records = incomingById.get(incoming.nodeId) ?? [];\n records.push(incoming);\n incomingById.set(incoming.nodeId, records);\n }\n\n const filePaths: string[] = [];\n for (const nodeId of [...incomingById.keys()].sort(compareDeterministicStrings)) {\n const existing = (existingById.get(nodeId) ?? []).sort(compareNodeFiles);\n const incoming = (incomingById.get(nodeId) ?? []).sort(compareIncomingNodes);\n let merged: AbstractionNode | undefined;\n for (const next of [...existing].reverse()) merged = mergeAbstractionNodes(merged, next.node);\n for (const next of incoming) merged = mergeAbstractionNodes(merged, next);\n if (!merged) throw new Error(`abstraction node batch has no node: ${nodeId}`);\n const filePath =\n existing[0]?.filePath ?? path.join(nodesDir, recordStoreDay(merged.recordedAt), `${merged.nodeId}.json`);\n await writeJsonFileAtomic(filePath, merged);\n for (const duplicate of existing.slice(1)) {\n await unlink(duplicate.filePath).catch((error) => {\n if (!isNotFoundError(error)) throw error;\n });\n }\n filePaths.push(filePath);\n }\n return filePaths;\n });\n}\n\nexport async function upsertAbstractionNode(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n node: AbstractionNode;\n}): Promise<string> {\n const [filePath] = await upsertAbstractionNodes({ ...options, nodes: [options.node] });\n if (!filePath) throw new Error(\"abstraction node upsert did not write a file\");\n return filePath;\n}\n\nexport async function getAbstractionNodeStoreStatus(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n enabled: boolean;\n anchorsEnabled: boolean;\n}): Promise<AbstractionNodeStoreStatus> {\n const rootDir = resolveAbstractionNodeStoreDir(options.memoryDir, options.abstractionNodeStoreDir);\n const nodesDir = path.join(rootDir, \"nodes\");\n const files = await listJsonFilesStrict(nodesDir, { allowMissingDirectory: true });\n const nodes: AbstractionNode[] = [];\n const invalidNodes: Array<{ path: string; error: string }> = [];\n\n for (const filePath of files) {\n try {\n nodes.push(validateAbstractionNode(await readJsonFile(filePath)));\n } catch (error) {\n invalidNodes.push({\n path: filePath,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n nodes.sort(\n (a, b) => Date.parse(b.recordedAt) - Date.parse(a.recordedAt) || compareDeterministicStrings(a.nodeId, b.nodeId)\n );\n\n const byKind: Partial<Record<AbstractionNodeKind, number>> = {};\n const byLevel: Partial<Record<AbstractionLevel, number>> = {};\n for (const node of nodes) {\n byKind[node.kind] = (byKind[node.kind] ?? 0) + 1;\n byLevel[node.abstractionLevel] = (byLevel[node.abstractionLevel] ?? 0) + 1;\n }\n\n return {\n enabled: options.enabled,\n anchorsEnabled: options.anchorsEnabled,\n rootDir,\n nodesDir,\n nodes: {\n total: files.length,\n valid: nodes.length,\n invalid: invalidNodes.length,\n byKind,\n byLevel,\n latestNodeId: nodes[0]?.nodeId,\n latestRecordedAt: nodes[0]?.recordedAt,\n latestSessionKey: nodes[0]?.sessionKey,\n },\n latestNode: nodes[0],\n invalidNodes,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,OAAO,QAAQ,iBAAiB;AACzC,OAAO,UAAU;AAsDjB,SAAS,aAAa,KAAmC;AACvD,QAAM,QAAQ,aAAa,KAAK,MAAM;AACtC,MAAI,CAA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K;AAC/C,YAAQ,KAAK,gBAAgB,KAAK,QAAQ,KAAK,gBAAgB,KAAK,KAAK;AAAA,EAC3E;AAEA,SAAO;AAAA,IACL,SAAS,QAAQ;AAAA,IACjB,gBAAgB,QAAQ;AAAA,IACxB;AAAA,IACA;AAAA,IACA,OAAO;AAAA,MACL,OAAO,MAAM;AAAA,MACb,OAAO,MAAM;AAAA,MACb,SAAS,aAAa;AAAA,MACtB;AAAA,MACA;AAAA,MACA,cAAc,MAAM,CAAC,GAAG;AAAA,MACxB,kBAAkB,MAAM,CAAC,GAAG;AAAA,MAC5B,kBAAkB,MAAM,CAAC,GAAG;AAAA,IAC9B;AAAA,IACA,YAAY,MAAM,CAAC;AAAA,IACnB;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cue-anchors.ts"],"sourcesContent":["import { mkdir, unlink, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { resolveAbstractionNodeStoreDir, validateAbstractionNode, type AbstractionNode } from \"./abstraction-nodes.js\";\nimport { listJsonFilesStrict, readJsonFile, withJsonStoreMutationLock, writeJsonFileAtomic } from \"./json-store.js\";\nimport { compareDeterministicStrings, mergeSortedUniqueStrings } from \"./deterministic-order.js\";\nimport { isNotFoundError } from \"./utils/errno.js\";\nimport {\n assertIsoRecordedAt,\n assertSafePathSegment,\n assertString,\n isRecord,\n optionalStringArray,\n validateStringRecord,\n} from \"./store-contract.js\";\n\nexport type CueAnchorType = \"entity\" | \"file\" | \"tool\" | \"outcome\" | \"constraint\" | \"date\";\n\nexport interface CueAnchor {\n schemaVersion: 1;\n anchorId: string;\n anchorType: CueAnchorType;\n anchorValue: string;\n normalizedCue: string;\n recordedAt: string;\n sessionKey: string;\n nodeRefs: string[];\n sourceMemoryIdsByNodeRef?: Record<string, string[]>;\n tags?: string[];\n metadata?: Record<string, string>;\n}\n\nexport interface CueAnchorStoreStatus {\n enabled: boolean;\n anchorsEnabled: boolean;\n rootDir: string;\n anchors: {\n total: number;\n valid: number;\n invalid: number;\n byType: Partial<Record<CueAnchorType, number>>;\n totalNodeRefs: number;\n latestAnchorId?: string;\n latestRecordedAt?: string;\n latestSessionKey?: string;\n };\n latestAnchor?: CueAnchor;\n invalidAnchors: Array<{\n path: string;\n error: string;\n }>;\n}\n\nfunction validateAnchorType(raw: unknown): CueAnchorType {\n const value = assertString(raw, \"anchorType\");\n if (![\"entity\", \"file\", \"tool\", \"outcome\", \"constraint\", \"date\"].includes(value)) {\n throw new Error(\"anchorType must be one of entity|file|tool|outcome|constraint|date\");\n }\n return value as CueAnchorType;\n}\n\nfunction validateNodeRefs(raw: unknown): string[] {\n const nodeRefs = optionalStringArray(raw, \"nodeRefs\");\n if (!nodeRefs || nodeRefs.length === 0) {\n throw new Error(\"nodeRefs must contain at least one node reference\");\n }\n return nodeRefs.map((nodeRef, index) => assertSafePathSegment(nodeRef, `nodeRefs[${index}]`));\n}\n\nfunction validateSourceMemoryIdsByNodeRef(raw: unknown): Record<string, string[]> | undefined {\n if (raw === undefined) return undefined;\n if (!isRecord(raw)) throw new Error(\"sourceMemoryIdsByNodeRef must be an object of string arrays\");\n const entries: Array<[string, string[]]> = [];\n for (const [rawNodeRef, rawSourceMemoryIds] of Object.entries(raw)) {\n const nodeRef = assertSafePathSegment(\n assertString(rawNodeRef, \"sourceMemoryIdsByNodeRef key\"),\n \"sourceMemoryIdsByNodeRef.nodeRef\"\n );\n const sourceMemoryIds = optionalStringArray(rawSourceMemoryIds, `sourceMemoryIdsByNodeRef.${nodeRef}`);\n if (sourceMemoryIds) entries.push([nodeRef, mergeSortedUniqueStrings(sourceMemoryIds)]);\n }\n if (entries.length === 0) return undefined;\n return Object.fromEntries(entries.sort(([left], [right]) => compareDeterministicStrings(left, right)));\n}\n\nfunction mergeSourceMemoryIdsByNodeRef(\n existing: Record<string, string[]> | undefined,\n incoming: Record<string, string[]> | undefined\n): Record<string, string[]> | undefined {\n const merged = new Map<string, string[]>();\n for (const [nodeRef, sourceMemoryIds] of Object.entries(existing ?? {})) {\n merged.set(nodeRef, [...sourceMemoryIds]);\n }\n for (const [nodeRef, sourceMemoryIds] of Object.entries(incoming ?? {})) {\n merged.set(nodeRef, mergeSortedUniqueStrings(merged.get(nodeRef), sourceMemoryIds));\n }\n return validateSourceMemoryIdsByNodeRef(Object.fromEntries(merged));\n}\n\nfunction boundSourceMemoryIdsByNodeRef(\n sourceMemoryIdsByNodeRef: Record<string, string[]> | undefined,\n nodeRefs: string[],\n liveNodes?: Map<string, AbstractionNode>\n): Record<string, string[]> | undefined {\n if (!sourceMemoryIdsByNodeRef) return undefined;\n const retained = Object.fromEntries(\n nodeRefs.flatMap((nodeRef) => {\n const sourceMemoryIds = sourceMemoryIdsByNodeRef[nodeRef];\n if (!sourceMemoryIds) return [];\n const liveSourceMemoryIds = liveNodes?.get(nodeRef)?.sourceMemoryIds;\n if (liveNodes && !liveSourceMemoryIds) return [];\n const retainedSourceMemoryIds = mergeSortedUniqueStrings(sourceMemoryIds).filter((sourceMemoryId) =>\n liveSourceMemoryIds ? liveSourceMemoryIds.includes(sourceMemoryId) : true\n );\n return retainedSourceMemoryIds.length > 0 ? [[nodeRef, retainedSourceMemoryIds] as const] : [];\n })\n );\n return validateSourceMemoryIdsByNodeRef(retained);\n}\n\nexport function resolveCueAnchorStoreDir(abstractionNodeStoreDir: string, overrideDir?: string): string {\n if (typeof overrideDir === \"string\" && overrideDir.trim().length > 0) {\n return overrideDir.trim();\n }\n return path.join(abstractionNodeStoreDir, \"anchors\");\n}\n\nexport function validateCueAnchor(raw: unknown): CueAnchor {\n if (!isRecord(raw)) throw new Error(\"cue anchor must be an object\");\n if (raw.schemaVersion !== 1) throw new Error(\"schemaVersion must be 1\");\n\n return {\n schemaVersion: 1,\n anchorId: assertSafePathSegment(assertString(raw.anchorId, \"anchorId\"), \"anchorId\"),\n anchorType: validateAnchorType(raw.anchorType),\n anchorValue: assertString(raw.anchorValue, \"anchorValue\"),\n normalizedCue: assertString(raw.normalizedCue, \"normalizedCue\"),\n recordedAt: assertIsoRecordedAt(assertString(raw.recordedAt, \"recordedAt\")),\n sessionKey: assertString(raw.sessionKey, \"sessionKey\"),\n nodeRefs: validateNodeRefs(raw.nodeRefs),\n sourceMemoryIdsByNodeRef: validateSourceMemoryIdsByNodeRef(raw.sourceMemoryIdsByNodeRef),\n tags: optionalStringArray(raw.tags, \"tags\"),\n metadata: validateStringRecord(raw.metadata, \"metadata\"),\n };\n}\n\nexport async function recordCueAnchor(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n cueAnchorStoreDir?: string;\n anchor: CueAnchor;\n}): Promise<string> {\n const abstractionNodeStoreDir = options.abstractionNodeStoreDir?.trim().length\n ? options.abstractionNodeStoreDir.trim()\n : path.join(options.memoryDir, \"state\", \"abstraction-nodes\");\n const rootDir = resolveCueAnchorStoreDir(abstractionNodeStoreDir, options.cueAnchorStoreDir);\n const validated = validateCueAnchor(options.anchor);\n const boundedNodeRefs = boundNodeRefs(validated.nodeRefs);\n const bounded = validateCueAnchor({\n ...validated,\n nodeRefs: boundedNodeRefs,\n sourceMemoryIdsByNodeRef: boundSourceMemoryIdsByNodeRef(validated.sourceMemoryIdsByNodeRef, boundedNodeRefs),\n });\n const anchorDir = path.join(rootDir, bounded.anchorType);\n const filePath = path.join(anchorDir, `${bounded.anchorId}.json`);\n await mkdir(anchorDir, { recursive: true });\n await writeFile(filePath, JSON.stringify(bounded, null, 2), \"utf8\");\n return filePath;\n}\n\nfunction mergeSortedValues(existing: string[] | undefined, incoming: string[] | undefined): string[] {\n return mergeSortedUniqueStrings(existing, incoming);\n}\n\nfunction boundNodeRefs(nodeRefs: string[], liveNodes?: Map<string, AbstractionNode>): string[] {\n const uniqueRefs = mergeSortedUniqueStrings(nodeRefs);\n if (!liveNodes) return uniqueRefs.slice(0, 50);\n return uniqueRefs\n .filter((nodeRef) => liveNodes.has(nodeRef))\n .sort(\n (left, right) =>\n Date.parse(liveNodes.get(right)?.recordedAt ?? \"\") - Date.parse(liveNodes.get(left)?.recordedAt ?? \"\") ||\n compareDeterministicStrings(left, right)\n )\n .slice(0, 50);\n}\n\nasync function readLiveNodes(nodesDir: string): Promise<Map<string, AbstractionNode> | undefined> {\n const liveNodes = new Map<string, AbstractionNode>();\n let nodeFiles: string[];\n try {\n nodeFiles = await listJsonFilesStrict(nodesDir);\n } catch (error) {\n if (isNotFoundError(error)) return undefined;\n throw error;\n }\n for (const filePath of nodeFiles) {\n const node = validateAbstractionNode(await readJsonFile(filePath));\n const previous = liveNodes.get(node.nodeId);\n if (\n !previous ||\n Date.parse(previous.recordedAt) < Date.parse(node.recordedAt) ||\n (Date.parse(previous.recordedAt) === Date.parse(node.recordedAt) &&\n compareDeterministicStrings(previous.sessionKey, node.sessionKey) < 0)\n ) {\n liveNodes.set(node.nodeId, node);\n }\n }\n return liveNodes;\n}\n\nexport async function upsertCueAnchors(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n cueAnchorStoreDir?: string;\n anchors: CueAnchor[];\n}): Promise<string[]> {\n const abstractionNodeStoreDir = resolveAbstractionNodeStoreDir(options.memoryDir, options.abstractionNodeStoreDir);\n const incomingAnchors = options.anchors.map(validateCueAnchor);\n if (incomingAnchors.length === 0) return [];\n\n return withJsonStoreMutationLock(abstractionNodeStoreDir, async () => {\n const rootDir = resolveCueAnchorStoreDir(abstractionNodeStoreDir, options.cueAnchorStoreDir);\n const liveNodes = await readLiveNodes(path.join(abstractionNodeStoreDir, \"nodes\"));\n const incomingByKey = new Map<string, CueAnchor[]>();\n for (const anchor of incomingAnchors) {\n const key = `${anchor.anchorType}\\u0000${anchor.anchorId}`;\n const grouped = incomingByKey.get(key) ?? [];\n grouped.push(anchor);\n incomingByKey.set(key, grouped);\n }\n const filePaths: string[] = [];\n for (const key of [...incomingByKey.keys()].sort(compareDeterministicStrings)) {\n const grouped = incomingByKey.get(key) ?? [];\n grouped.sort(compareIncomingCueAnchors);\n const incoming = grouped.shift();\n if (!incoming) throw new Error(`cue anchor batch has no anchor: ${key}`);\n const filePath = path.join(rootDir, incoming.anchorType, `${incoming.anchorId}.json`);\n let existing: CueAnchor | undefined;\n try {\n existing = validateCueAnchor(await readJsonFile(filePath));\n } catch (error) {\n if (!isNotFoundError(error)) throw error;\n }\n let merged = mergeCueAnchors(existing, incoming, liveNodes);\n for (const next of grouped) merged = mergeCueAnchors(merged, next, liveNodes);\n await writeJsonFileAtomic(filePath, merged);\n filePaths.push(filePath);\n }\n return filePaths;\n });\n}\n\nfunction compareIncomingCueAnchors(left: CueAnchor, right: CueAnchor): number {\n const recordedAtComparison = Date.parse(left.recordedAt) - Date.parse(right.recordedAt);\n if (recordedAtComparison < 0) return -1;\n if (recordedAtComparison > 0) return 1;\n return compareDeterministicStrings(canonicalCueAnchorKey(left), canonicalCueAnchorKey(right));\n}\n\nfunction canonicalMetadata(metadata: Record<string, string> | undefined): Record<string, string> {\n return Object.fromEntries(\n Object.entries(metadata ?? {}).sort(([left], [right]) => compareDeterministicStrings(left, right))\n );\n}\n\nfunction canonicalCueAnchorKey(anchor: CueAnchor): string {\n return JSON.stringify({\n ...anchor,\n metadata: canonicalMetadata(anchor.metadata),\n });\n}\n\nfunction mergeCueAnchors(\n existing: CueAnchor | undefined,\n incoming: CueAnchor,\n liveNodes: Map<string, AbstractionNode> | undefined\n): CueAnchor {\n const incomingIsNewest = !existing || Date.parse(existing.recordedAt) <= Date.parse(incoming.recordedAt);\n const newest = incomingIsNewest ? incoming : existing;\n const older = incomingIsNewest ? existing : incoming;\n const mergedMetadata = canonicalMetadata({\n ...(older?.metadata ?? {}),\n ...(newest.metadata ?? {}),\n });\n const nodeRefs = boundNodeRefs(mergeSortedValues(existing?.nodeRefs, incoming.nodeRefs), liveNodes);\n return validateCueAnchor({\n ...newest,\n nodeRefs,\n sourceMemoryIdsByNodeRef: boundSourceMemoryIdsByNodeRef(\n mergeSourceMemoryIdsByNodeRef(existing?.sourceMemoryIdsByNodeRef, incoming.sourceMemoryIdsByNodeRef),\n nodeRefs,\n liveNodes\n ),\n tags: mergeSortedValues(existing?.tags, incoming.tags),\n metadata: mergedMetadata,\n });\n}\n\nexport async function upsertCueAnchor(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n cueAnchorStoreDir?: string;\n anchor: CueAnchor;\n}): Promise<string> {\n const [filePath] = await upsertCueAnchors({ ...options, anchors: [options.anchor] });\n if (!filePath) throw new Error(\"cue anchor upsert did not write a file\");\n return filePath;\n}\n\nexport async function pruneOrphanCueAnchors(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n cueAnchorStoreDir?: string;\n}): Promise<number> {\n const abstractionNodeStoreDir = resolveAbstractionNodeStoreDir(options.memoryDir, options.abstractionNodeStoreDir);\n return withJsonStoreMutationLock(abstractionNodeStoreDir, async () => {\n const cueAnchorStoreDir = resolveCueAnchorStoreDir(abstractionNodeStoreDir, options.cueAnchorStoreDir);\n const liveNodes = (await readLiveNodes(path.join(abstractionNodeStoreDir, \"nodes\"))) ?? new Map();\n let removed = 0;\n const anchorFiles = await listJsonFilesStrict(cueAnchorStoreDir, {\n allowMissingDirectory: true,\n });\n for (const filePath of anchorFiles) {\n let anchor: CueAnchor;\n try {\n anchor = validateCueAnchor(await readJsonFile(filePath));\n } catch {\n continue;\n }\n const nodeRefs = boundNodeRefs(anchor.nodeRefs, liveNodes);\n const sourceMemoryIdsByNodeRef = boundSourceMemoryIdsByNodeRef(\n anchor.sourceMemoryIdsByNodeRef,\n nodeRefs,\n liveNodes\n );\n if (nodeRefs.length === 0) {\n try {\n await unlink(filePath);\n removed++;\n } catch (error) {\n if (!isNotFoundError(error)) throw error;\n }\n continue;\n }\n if (\n nodeRefs.length !== anchor.nodeRefs.length ||\n nodeRefs.some((nodeRef, index) => nodeRef !== anchor.nodeRefs[index]) ||\n JSON.stringify(sourceMemoryIdsByNodeRef) !== JSON.stringify(anchor.sourceMemoryIdsByNodeRef)\n ) {\n await writeJsonFileAtomic(filePath, validateCueAnchor({ ...anchor, nodeRefs, sourceMemoryIdsByNodeRef }));\n }\n }\n return removed;\n });\n}\n\nexport async function getCueAnchorStoreStatus(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n cueAnchorStoreDir?: string;\n enabled: boolean;\n anchorsEnabled: boolean;\n}): Promise<CueAnchorStoreStatus> {\n const abstractionNodeStoreDir = options.abstractionNodeStoreDir?.trim().length\n ? options.abstractionNodeStoreDir.trim()\n : path.join(options.memoryDir, \"state\", \"abstraction-nodes\");\n const rootDir = resolveCueAnchorStoreDir(abstractionNodeStoreDir, options.cueAnchorStoreDir);\n const files = await listJsonFilesStrict(rootDir, { allowMissingDirectory: true });\n const anchors: CueAnchor[] = [];\n const invalidAnchors: Array<{ path: string; error: string }> = [];\n\n for (const filePath of files) {\n try {\n anchors.push(validateCueAnchor(await readJsonFile(filePath)));\n } catch (error) {\n invalidAnchors.push({\n path: filePath,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n anchors.sort(\n (a, b) => Date.parse(b.recordedAt) - Date.parse(a.recordedAt) || compareDeterministicStrings(a.anchorId, b.anchorId)\n );\n\n const byType: Partial<Record<CueAnchorType, number>> = {};\n let totalNodeRefs = 0;\n for (const anchor of anchors) {\n byType[anchor.anchorType] = (byType[anchor.anchorType] ?? 0) + 1;\n totalNodeRefs += anchor.nodeRefs.length;\n }\n\n return {\n enabled: options.enabled,\n anchorsEnabled: options.anchorsEnabled,\n rootDir,\n anchors: {\n total: files.length,\n valid: anchors.length,\n invalid: invalidAnchors.length,\n byType,\n totalNodeRefs,\n latestAnchorId: anchors[0]?.anchorId,\n latestRecordedAt: anchors[0]?.recordedAt,\n latestSessionKey: anchors[0]?.sessionKey,\n },\n latestAnchor: anchors[0],\n invalidAnchors,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,OAAO,QAAQ,iBAAiB;AACzC,OAAO,UAAU;AAmDjB,SAAS,mBAAmB,KAA6B;AACvD,QAAM,QAAQ,aAAa,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qBAAe,KAAK;AAAA,QAClB,MAAM;AAAA,QACN,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAC9D,CAAC;AAAA,IACH;AAAA,EACF;AAEA,UAAQ;AAAA,IACN,CAAC,GAAG,MAAM,KAAK,MAAM,EAAE,UAAU,IAAI,KAAK,MAAM,EAAE,UAAU,KAAK,4BAA4B,EAAE,UAAU,EAAE,QAAQ;AAAA,EACrH;AAEA,QAAM,SAAiD,CAAC;AACxD,MAAI,gBAAgB;AACpB,aAAW,UAAU,SAAS;AAC5B,WAAO,OAAO,UAAU,KAAK,OAAO,OAAO,UAAU,KAAK,KAAK;AAC/D,qBAAiB,OAAO,SAAS;AAAA,EACnC;AAEA,SAAO;AAAA,IACL,SAAS,QAAQ;AAAA,IACjB,gBAAgB,QAAQ;AAAA,IACxB;AAAA,IACA,SAAS;AAAA,MACP,OAAO,MAAM;AAAA,MACb,OAAO,QAAQ;AAAA,MACf,SAAS,eAAe;AAAA,MACxB;AAAA,MACA;AAAA,MACA,gBAAgB,QAAQ,CAAC,GAAG;AAAA,MAC5B,kBAAkB,QAAQ,CAAC,GAAG;AAAA,MAC9B,kBAAkB,QAAQ,CAAC,GAAG;AAAA,IAChC;AAAA,IACA,cAAc,QAAQ,CAAC;AAAA,IACvB;AAAA,EACF;AACF;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|