@remnic/core 9.40.0 → 9.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-admin-ops-surface.d.ts +10 -10
- package/dist/access-admin-ops-surface.js +5 -4
- package/dist/access-authorization-probe.d.ts +10 -10
- package/dist/access-authorization-probe.js +6 -5
- package/dist/access-boundary.d.ts +10 -10
- package/dist/access-boundary.js +5 -4
- package/dist/access-cli.js +16 -15
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.d.ts +10 -10
- package/dist/access-extraction-force-flush.js +5 -4
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +10 -10
- package/dist/access-http-lifecycle-flush.d.ts +10 -10
- package/dist/access-http.d.ts +10 -10
- package/dist/access-http.js +10 -9
- package/dist/access-identity-continuity-surface.d.ts +8 -8
- package/dist/access-identity-continuity-surface.js +5 -4
- package/dist/access-lcm-surface.d.ts +10 -10
- package/dist/access-lcm-surface.js +5 -4
- package/dist/access-mcp.d.ts +10 -10
- package/dist/access-mcp.js +8 -7
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-BbDJBq0e.d.ts → access-namespace-preflight-47dOyty9.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +5 -4
- package/dist/access-observe-write-surface.d.ts +10 -10
- package/dist/access-observe-write-surface.js +5 -4
- package/dist/access-operations-batch.js +6 -5
- package/dist/access-operations.d.ts +13 -13
- package/dist/access-operations.js +7 -6
- package/dist/access-recall-concurrency.d.ts +10 -10
- package/dist/access-recall-concurrency.js +5 -4
- package/dist/access-recall-response.d.ts +10 -10
- package/dist/access-recall-response.js +5 -4
- package/dist/access-recall-surface.d.ts +10 -10
- package/dist/access-recall-surface.js +5 -4
- package/dist/access-schema.d.ts +84 -84
- package/dist/{access-service-B2h6rITp.d.ts → access-service-D1BkxwSf.d.ts} +7 -7
- package/dist/access-service-helpers.d.ts +10 -10
- package/dist/access-service.d.ts +10 -10
- package/dist/access-service.js +5 -4
- package/dist/access-surface-catalog.d.ts +10 -10
- package/dist/access-wearables-meetings-surface.d.ts +3 -3
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +2 -2
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +8 -8
- package/dist/briefing.d.ts +2 -2
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{catalog-Bz2LxGNb.d.ts → catalog-DPQynQZG.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/{chunk-443XCR34.js → chunk-3SG4FGDV.js} +53 -41
- package/dist/chunk-3SG4FGDV.js.map +1 -0
- package/dist/{chunk-XPQ5ZTL6.js → chunk-6I2C3EOH.js} +6 -6
- package/dist/chunk-7VIB7PAE.js +142 -0
- package/dist/chunk-7VIB7PAE.js.map +1 -0
- package/dist/{chunk-AYICY7IE.js → chunk-AXUU7SG3.js} +2 -2
- package/dist/{chunk-RK6WMGTX.js → chunk-CQ5MR2HQ.js} +13 -9
- package/dist/chunk-CQ5MR2HQ.js.map +1 -0
- package/dist/{chunk-KW4ZFTUS.js → chunk-CWPDM66T.js} +5 -5
- package/dist/{chunk-NEO4QCID.js → chunk-FHEJ22B7.js} +10 -4
- package/dist/chunk-FHEJ22B7.js.map +1 -0
- package/dist/{chunk-EBWOOJEP.js → chunk-GDC4INBF.js} +2 -2
- package/dist/{chunk-UIVRPXRR.js → chunk-KXGN6G2Y.js} +3 -3
- package/dist/chunk-KXGN6G2Y.js.map +1 -0
- package/dist/{chunk-AXHMCRS3.js → chunk-OYFDEJZB.js} +23 -6
- package/dist/chunk-OYFDEJZB.js.map +1 -0
- package/dist/{chunk-SD4A6IZY.js → chunk-PWKZV4A3.js} +2 -2
- package/dist/{chunk-XYXYEDPL.js → chunk-Q4XL7LJW.js} +26 -5
- package/dist/chunk-Q4XL7LJW.js.map +1 -0
- package/dist/{chunk-MOHZIKZM.js → chunk-TM72UOX2.js} +2 -2
- package/dist/{chunk-GLBK35BT.js → chunk-UGCUVLOL.js} +14 -10
- package/dist/chunk-UGCUVLOL.js.map +1 -0
- package/dist/{chunk-Q6QYN56R.js → chunk-UQVGDEAJ.js} +2 -2
- package/dist/{chunk-KYYRJVE6.js → chunk-XRWVXPEM.js} +2 -2
- package/dist/{cli-CO8qKPM5.d.ts → cli-IUhV-lmk.d.ts} +5 -5
- package/dist/cli.d.ts +12 -12
- package/dist/cli.js +15 -14
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -2
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/contradiction/index.d.ts +2 -2
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/corpus-watermark.d.ts +7 -1
- package/dist/corpus-watermark.js +2 -2
- 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.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +8 -8
- package/dist/extraction-error-classification.d.ts +1 -1
- package/dist/extraction-faithfulness.d.ts +1 -1
- 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-liveness.d.ts +1 -1
- package/dist/extraction-liveness.js +3 -1
- package/dist/extraction-source-grounding-rules.d.ts +1 -1
- package/dist/extraction-source-grounding.d.ts +1 -1
- package/dist/extraction.d.ts +1 -1
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/index.d.ts +407 -407
- package/dist/index.js +16 -15
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/{maintenance-D2jkiT9r.d.ts → maintenance-DVBLXkFw.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +10 -10
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +4 -3
- package/dist/namespaces/migrate.js +1 -1
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +3 -3
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +5 -4
- package/dist/operator-toolkit.js +7 -6
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/{orchestrator-SHaRXCUF.d.ts → orchestrator-fYTncnLy.d.ts} +7 -7
- package/dist/orchestrator.d.ts +8 -8
- package/dist/orchestrator.js +16 -15
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-B5_tS1Yc.d.ts → pipeline-Cs76XC-p.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/{qmd-CkEV_SPG.d.ts → qmd-WJwvBgiF.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray.d.ts +1 -1
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/replica-divergence.d.ts +1 -1
- package/dist/replica-peers-config.d.ts +1 -1
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +3 -3
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/salvage-envelope.d.ts +1 -1
- package/dist/schemas.d.ts +76 -76
- package/dist/{scope-profiles-DeAdnocS.d.ts → scope-profiles-CQ0NAleS.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/index.d.ts +1 -1
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-DR_h-JUD.d.ts → semantic-consolidation-BWxOBMtz.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/{service-BTb94UPJ.d.ts → service-CLuMO-pa.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +9 -9
- package/dist/signal.d.ts +1 -1
- package/dist/source-agent-qualifier.d.ts +1 -1
- package/dist/{storage-ax2EIsVS.d.ts → storage-Blr71GpS.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.d.ts +2 -2
- package/dist/temporal-timeline-recall.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +2 -2
- package/dist/tier-routing.d.ts +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/types.d.ts +66 -66
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-CCGL-9NX.d.ts → types-CqWwMPr_.d.ts} +41 -59
- package/dist/types.d.ts +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/access-http.test.ts +2 -2
- package/src/access-service-health.test.ts +39 -17
- package/src/access-service.ts +25 -3
- package/src/cli.ts +3 -3
- package/src/corpus-watermark.test.ts +16 -0
- package/src/corpus-watermark.ts +28 -5
- package/src/extraction-liveness.test.ts +81 -19
- package/src/extraction-liveness.ts +96 -98
- package/src/extraction-watermark.test.ts +290 -0
- package/src/namespaces/migrate.ts +10 -2
- package/src/operator-doctor-corpus.test.ts +7 -0
- package/src/operator-doctor-corpus.ts +1 -1
- package/src/operator-toolkit.ts +8 -8
- package/src/orchestration/extraction-watermark.ts +188 -0
- package/dist/chunk-443XCR34.js.map +0 -1
- package/dist/chunk-AXHMCRS3.js.map +0 -1
- package/dist/chunk-GLBK35BT.js.map +0 -1
- package/dist/chunk-NEO4QCID.js.map +0 -1
- package/dist/chunk-RK6WMGTX.js.map +0 -1
- package/dist/chunk-UIVRPXRR.js.map +0 -1
- package/dist/chunk-XYXYEDPL.js.map +0 -1
- /package/dist/{chunk-XPQ5ZTL6.js.map → chunk-6I2C3EOH.js.map} +0 -0
- /package/dist/{chunk-AYICY7IE.js.map → chunk-AXUU7SG3.js.map} +0 -0
- /package/dist/{chunk-KW4ZFTUS.js.map → chunk-CWPDM66T.js.map} +0 -0
- /package/dist/{chunk-EBWOOJEP.js.map → chunk-GDC4INBF.js.map} +0 -0
- /package/dist/{chunk-SD4A6IZY.js.map → chunk-PWKZV4A3.js.map} +0 -0
- /package/dist/{chunk-MOHZIKZM.js.map → chunk-TM72UOX2.js.map} +0 -0
- /package/dist/{chunk-Q6QYN56R.js.map → chunk-UQVGDEAJ.js.map} +0 -0
- /package/dist/{chunk-KYYRJVE6.js.map → chunk-XRWVXPEM.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/corpus-watermark.ts"],"sourcesContent":["/**\n * Corpus watermark (issue #2149) — a cheap, comparable fingerprint of a\n * daemon's active-memory corpus.\n *\n * Deployment shape this addresses: two daemons behind an active/backup VIP,\n * each owning its own memory directory. Nothing compared the two corpora, so a\n * pair could diverge for months (e.g. one holding ~190k files, its backup\n * ~340k with different histories) with no signal until a manual audit. This\n * module ships the WATERMARK primitive and the read surfaces that expose it;\n * peer polling and divergence alerting are a follow-up.\n *\n * The digest is a CENSUS fingerprint (per day-partition file counts), NOT a\n * content hash — two daemons that agree on how many memory FILES live in\n * each `<tier>:<category>/<day>` partition produce the same digest, so a\n * differing digest is a cheap divergence signal without reading or hashing file\n * bodies. Buckets are tier-aware (`hot:` / `cold:`): demoted memories stay\n * reachable via cold recall, so the census counts BOTH tiers and a hot/cold\n * split shows in the digest rather than being silently folded together (issue\n * #2156 finding D). `newestWriteAt` stays scoped to the newest HOT partition\n * only, so the freshness probe stays O(one day's active files) even on a 100k+\n * corpus.\n *\n * Robustness (issue #2156 review rounds):\n * - `/health` and `remnic doctor` resolve their namespace set through the ONE\n * {@link resolveCorpusNamespaceRoots} helper — config-driven enumeration\n * unioned with the PERSISTED namespace catalog read from config — so both\n * surfaces enumerate the same tenants and cannot drift.\n * - The `/health` builder serves through a stale-while-revalidate\n * {@link CorpusWatermarkCache}, so a probe NEVER awaits the recursive corpus\n * scan (it returns the cached/stale value and refreshes in the background).\n * - Each namespace's census brackets its hot+cold walk with a corpus-mutation\n * sentinel and retries when a tier migration races it, so a transient\n * double-count/miss is never cached as a false divergence.\n * - An unreadable corpus root (EACCES) is OMITTED, not published as a false\n * empty; a missing root (ENOENT — a not-yet-created namespace) is a genuine\n * empty corpus.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { capabilityAllowsNamespace, type TokenCapabilities } from \"./access-token-capabilities.js\";\nimport { listNamespaces } from \"./namespaces/migrate.js\";\nimport type { PluginConfig } from \"./types.js\";\n\nexport interface CorpusWatermark {\n namespace: string;\n /**\n * Count of memory files under the census scan roots (hot + cold). This is a\n * FILE census, not a status-filtered active count: reading each file's\n * frontmatter status would defeat the cheap-probe design, so an in-place\n * status change (e.g. archived-in-place) is not reflected here.\n */\n memoryFileCount: number;\n /** Newest `YYYY-MM-DD` day-partition seen in the HOT tier, or null when none is dated. */\n newestPartition: string | null;\n /** ISO max mtime within the newest HOT partition, or null when it has no files. */\n newestWriteAt: string | null;\n /** sha256 hex over the deterministic per-partition census. */\n digest: string;\n computedAt: string;\n}\n\n/** Explicit bucket for paths that do not match the `<category>/<day>` shape. */\nexport const UNPARTITIONED_BUCKET = \"unpartitioned\";\n\n/** Storage tier a memory file lives in. */\nexport type CorpusTier = \"hot\" | \"cold\";\n\nconst DAY_PARTITION_RE = /^\\d{4}-\\d{2}-\\d{2}$/;\n/** Cold-tier root segment (relative to a namespace base dir): `<baseDir>/cold/...`. */\nconst COLD_TIER_DIR = \"cold\";\n\n/**\n * True when `token` is not just `YYYY-MM-DD`-shaped but a REAL calendar day.\n * The regex alone accepts impossible dates (e.g. `2026-99-99`) that would then\n * sort lexically above every valid partition and corrupt `newestPartition`\n * (issue #2156 round-6); round-tripping through a UTC Date rejects month/day\n * overflow. A malformed dir falls back to the unpartitioned bucket.\n */\nfunction isRealCalendarDay(token: string): boolean {\n if (!DAY_PARTITION_RE.test(token)) return false;\n const [year, month, day] = token.split(\"-\").map(Number);\n const date = new Date(Date.UTC(year, month - 1, day));\n return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;\n}\n\ninterface ParsedPath {\n readonly bucket: string;\n readonly date: string | null;\n readonly tier: CorpusTier;\n}\n\nfunction parsePartition(baseDir: string, filePath: string): ParsedPath {\n const rel = path.relative(baseDir, filePath).split(path.sep).join(\"/\");\n const parts = rel.split(\"/\");\n // Cold-tier files live under `<baseDir>/cold/<category>/<day>/...`; hot files\n // sit directly under `<baseDir>/<category>/<day>/...`. Strip the leading\n // `cold/` segment so the category/day parse is tier-agnostic, then prefix the\n // bucket with the tier so a hot and cold partition of the same day never\n // collide (they must diverge the digest, not fold together).\n const tier: CorpusTier = parts[0] === COLD_TIER_DIR ? \"cold\" : \"hot\";\n const categoryParts = tier === \"cold\" ? parts.slice(1) : parts;\n if (categoryParts.length >= 2 && isRealCalendarDay(categoryParts[1])) {\n return { bucket: `${tier}:${categoryParts[0]}/${categoryParts[1]}`, date: categoryParts[1], tier };\n }\n return { bucket: `${tier}:${UNPARTITIONED_BUCKET}`, date: null, tier };\n}\n\n/**\n * Build the per-partition census: bucket key -> file count. Bucket keys are\n * tier-aware (`hot:`/`cold:`). Paths not matching a day-partition land in the\n * explicit tier {@link UNPARTITIONED_BUCKET}; they are never silently dropped.\n * Pure — no filesystem access.\n */\nexport function buildPartitionCensus(paths: readonly string[], baseDir: string): Map<string, number> {\n const census = new Map<string, number>();\n for (const filePath of paths) {\n const { bucket } = parsePartition(baseDir, filePath);\n census.set(bucket, (census.get(bucket) ?? 0) + 1);\n }\n return census;\n}\n\n/**\n * Deterministic census -> digest. Bucket keys are SORTED before serialization\n * (AGENTS.md pattern 26: insertion order must not affect a hash), then emitted\n * as `\"<bucket>:<count>\"` lines joined by `\\n` and hashed with sha256. Pure —\n * separately exported so it can be unit-tested without a filesystem.\n */\nexport function digestPartitionCensus(census: ReadonlyMap<string, number> | Record<string, number>): string {\n const entries = census instanceof Map ? [...census.entries()] : Object.entries(census);\n const serialized = entries\n .sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))\n .map(([bucket, count]) => `${bucket}:${count}`)\n .join(\"\\n\");\n return createHash(\"sha256\").update(serialized).digest(\"hex\");\n}\n\n/**\n * Compute a watermark for a single namespace from an already-collected path\n * list (both tiers, under `baseDir`) plus its memory base directory. Never\n * throws on an empty list — an empty corpus yields the digest of the empty\n * census and null timestamps. Only the newest HOT partition's files are\n * `stat`-ed, so freshness stays cheap even on a 100k+ corpus.\n */\nexport async function computeCorpusWatermark(input: {\n namespace: string;\n paths: readonly string[];\n baseDir: string;\n now?: Date;\n}): Promise<CorpusWatermark> {\n const { namespace, paths, baseDir } = input;\n\n const census = new Map<string, number>();\n let newestPartition: string | null = null;\n const parsedByPath: ParsedPath[] = [];\n for (const filePath of paths) {\n const parsed = parsePartition(baseDir, filePath);\n parsedByPath.push(parsed);\n census.set(parsed.bucket, (census.get(parsed.bucket) ?? 0) + 1);\n // Freshness is the newest ACTIVE (hot) write. Cold memories are demoted and\n // keep their original (older) partition date, so they never advance the\n // freshness probe and their files are never stat-ed below.\n if (parsed.tier === \"hot\" && parsed.date !== null && (newestPartition === null || parsed.date > newestPartition)) {\n newestPartition = parsed.date;\n }\n }\n\n const digest = digestPartitionCensus(census);\n\n let newestWriteAt: string | null = null;\n if (newestPartition !== null) {\n let maxMtimeMs = Number.NEGATIVE_INFINITY;\n for (let i = 0; i < paths.length; i += 1) {\n if (parsedByPath[i].tier !== \"hot\" || parsedByPath[i].date !== newestPartition) continue;\n try {\n const st = await stat(paths[i]);\n if (st.mtimeMs > maxMtimeMs) maxMtimeMs = st.mtimeMs;\n } catch (err) {\n // A file vanishing between scan and stat (ENOENT) is an expected race —\n // skip it. A backend read failure (EACCES/EIO/…) means the corpus is\n // unreadable: propagate so the namespace is omitted, not published with\n // a stale/null freshness (issue #2156 round-6).\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err;\n }\n }\n if (maxMtimeMs > Number.NEGATIVE_INFINITY) {\n newestWriteAt = new Date(maxMtimeMs).toISOString();\n }\n }\n\n // Stamp AFTER the (possibly slow) stat loop so an age-based HA consumer never\n // sees a timestamp earlier than when the scan actually finished (finding\n // round-4). An explicit `now` (tests / determinism) still wins.\n const computedAt = (input.now ?? new Date()).toISOString();\n\n return {\n namespace,\n memoryFileCount: paths.length,\n newestPartition,\n newestWriteAt,\n digest,\n computedAt,\n };\n}\n\n/** Minimal storage surface a watermark needs — satisfied by StorageManager. */\nexport interface CorpusStorage {\n readonly dir: string;\n /** Hot-tier active memory paths (the recall corpus). */\n collectActiveMemoryPaths(options?: { propagateReadErrors?: boolean }): Promise<string[]>;\n /** Cold-tier (demoted-but-reachable) memory paths (issue #2156 finding D). */\n collectColdMemoryPaths(options?: { propagateReadErrors?: boolean }): Promise<string[]>;\n /**\n * Optional combined hot+cold corpus-mutation sentinel. When present, the\n * census brackets its scan with it and retries on change so a tier migration\n * racing the walkers is not cached as a false divergence. Absent (test fakes)\n * ⇒ single-pass.\n */\n getCorpusScanVersion?(): string | Promise<string>;\n}\n\n/** Max census re-scans when a corpus mutation keeps racing the walkers. */\nconst CENSUS_RACE_MAX_ATTEMPTS = 3;\n\n/**\n * Compute one namespace's watermark from its storage, spanning BOTH tiers so a\n * cold-tier divergence is caught. Reads are STRICT: the collectors propagate a\n * backend read failure (EACCES on the root OR any nested category dir, ENOTDIR,\n * …) so an unreadable corpus is OMITTED by the caller rather than published as a\n * false empty census; a missing root (ENOENT — a not-yet-created namespace)\n * stays a genuine empty corpus. The hot+cold walk is bracketed by the\n * corpus-mutation sentinel (when the storage exposes one) and retried on change;\n * if it never stabilizes (sustained tier churn) this THROWS rather than caching\n * a transient double-count/miss as a false divergence.\n */\nasync function computeNamespaceWatermark(\n namespace: string,\n storage: CorpusStorage,\n now?: Date,\n): Promise<CorpusWatermark> {\n const readVersion = storage.getCorpusScanVersion?.bind(storage);\n const maxAttempts = readVersion ? CENSUS_RACE_MAX_ATTEMPTS : 1;\n for (let attempt = 0; attempt < maxAttempts; attempt += 1) {\n const before = readVersion ? await readVersion() : null;\n const [hotPaths, coldPaths] = await Promise.all([\n storage.collectActiveMemoryPaths({ propagateReadErrors: true }),\n storage.collectColdMemoryPaths({ propagateReadErrors: true }),\n ]);\n const result = await computeCorpusWatermark({ namespace, paths: [...hotPaths, ...coldPaths], baseDir: storage.dir, now });\n const after = readVersion ? await readVersion() : null;\n if (before === after) return result;\n // A tier write (e.g. hot→cold migration) raced the two walkers, so the\n // count/digest may double-count or miss the in-flight memory. Retry for a\n // consistent snapshot.\n }\n throw new Error(`corpus census for namespace \"${namespace}\" did not stabilize after ${maxAttempts} attempts`);\n}\n\n/**\n * Compute watermarks for a set of namespaces. A namespace whose storage is\n * unavailable (or unreadable) is skipped rather than failing the whole read, so\n * a single bad namespace never blanks the health/doctor payload.\n */\nexport async function computeCorpusWatermarks(\n namespaces: readonly string[],\n storageFor: (namespace: string) => CorpusStorage | Promise<CorpusStorage>,\n now?: Date,\n): Promise<CorpusWatermark[]> {\n const watermarks: CorpusWatermark[] = [];\n for (const namespace of namespaces) {\n try {\n watermarks.push(await computeNamespaceWatermark(namespace, await storageFor(namespace), now));\n } catch {\n // Storage unavailable/unreadable for this namespace — degrade gracefully.\n }\n }\n return watermarks;\n}\n\n/** A namespace and the memory root its corpus lives under. */\nexport interface CorpusNamespaceRoot {\n /** Representative namespace label for this root (default wins on collapse). */\n readonly namespace: string;\n readonly rootDir: string;\n /**\n * Every configured namespace name that resolves to `rootDir` (aliases that\n * collapsed onto one physical root, e.g. `global` + `shared` when namespaces\n * are disabled). `/health` filters visibility against ALL of these so a token\n * scoped to a non-representative alias still sees the shared corpus (issue\n * #2156 round-10). Always includes `namespace`.\n */\n readonly namespaces: readonly string[];\n}\n\n/**\n * Resolve the namespace set the corpus census covers, shared by the `/health`\n * builder AND the `remnic doctor` corpus check (issue #2156 finding C) so the\n * two surfaces enumerate the SAME tenants — and, critically, resolve each\n * namespace's ROOT the SAME way — and cannot drift. Enumeration is purely\n * config-driven (`listNamespaces({ config })`): it discovers the default,\n * shared, policy, and on-disk `namespaces/<ns>` tenants and resolves every root\n * through the namespace storage router, exactly as the live daemon's\n * `getStorage(namespace)` does. It still works when the namespace catalog is\n * opted out. The catalog is deliberately NOT unioned in: a catalog-registered\n * tenant with no directory has an empty corpus (nothing to fingerprint), and\n * trusting `catalog.storageDir` here could make the doctor scan a different root\n * than `/health` for the same namespace (issue #2156 round-8). Deduped by\n * resolved root so a namespaces-disabled / flat-root deployment reports its\n * single shared corpus once, under the default-namespace label.\n */\nexport async function resolveCorpusNamespaceRoots(options: {\n config: PluginConfig;\n propagateDiscoveryErrors?: boolean;\n}): Promise<CorpusNamespaceRoot[]> {\n const { config } = options;\n const configDriven = await listNamespaces({\n config,\n propagateDiscoveryErrors: options.propagateDiscoveryErrors,\n });\n // Default namespace first so it wins the representative label when several\n // configured names collapse onto one root (namespaces disabled → memoryDir).\n const ordered = [\n ...configDriven.filter((entry) => entry.namespace === config.defaultNamespace),\n ...configDriven.filter((entry) => entry.namespace !== config.defaultNamespace),\n ];\n const seenNamespaces = new Set<string>();\n const byRoot = new Map<string, { namespace: string; rootDir: string; namespaces: string[] }>();\n for (const entry of ordered) {\n if (seenNamespaces.has(entry.namespace)) continue;\n seenNamespaces.add(entry.namespace);\n const existing = byRoot.get(entry.rootDir);\n if (existing) {\n existing.namespaces.push(entry.namespace); // an alias collapsing onto a seen root\n } else {\n byRoot.set(entry.rootDir, { namespace: entry.namespace, rootDir: entry.rootDir, namespaces: [entry.namespace] });\n }\n }\n const roots: CorpusNamespaceRoot[] = [...byRoot.values()];\n if (roots.length === 0) {\n roots.push({ namespace: config.defaultNamespace, rootDir: config.memoryDir, namespaces: [config.defaultNamespace] });\n }\n return roots;\n}\n\n/**\n * Divergence detection tolerates a watermark that is stale by up to a minute\n * (peers are compared on a slow cadence); a health/readiness probe does NOT\n * tolerate a full corpus scan (a recursive realpath-per-Markdown-file walk) on\n * every request. This TTL is that trade-off: recompute a namespace's watermark\n * at most once per window; probes in between serve the cached census (whose\n * `computedAt` shows its staleness).\n */\nexport const WATERMARK_CACHE_TTL_MS = 60_000;\n\n/**\n * Cap on concurrent background corpus scans. A probe that finds many namespaces\n * cold/expired would otherwise fan out one recursive hot/cold walk PER namespace\n * at once, a periodic unbounded filesystem-work burst that can starve recall and\n * storage (issue #2156 round-9). Excess refreshes queue and start as slots free;\n * single-flight still dedupes duplicate requests for the same namespace.\n */\nconst MAX_CONCURRENT_WATERMARK_REFRESHES = 4;\n\n/**\n * Instance-scoped (AGENTS.md pattern 5 — never a bare module global)\n * stale-while-revalidate cache in front of the per-namespace corpus scan.\n * {@link get} NEVER awaits the scan: it returns the freshest already-computed\n * watermark (stale allowed, or undefined for a cold namespace) and triggers a\n * single-flight background refresh when the entry is missing or expired. So a\n * `/health` probe is always O(1) — it never blocks on a recursive corpus walk,\n * even on the first request after startup or after a TTL expiry. Owned by the\n * long-lived access service instance.\n */\nexport class CorpusWatermarkCache {\n private readonly entries = new Map<string, { value: CorpusWatermark; expiresAt: number }>();\n private readonly inFlight = new Map<string, Promise<void>>();\n private readonly ttlMs: number;\n private readonly clock: () => number;\n private rootsEntry: { value: CorpusNamespaceRoot[]; expiresAt: number } | undefined;\n private rootsInFlight: Promise<void> | undefined;\n private rootsRefreshError: unknown;\n private readonly queued = new Map<string, () => void>();\n private activeRefreshes = 0;\n private readonly maxConcurrentRefreshes: number;\n\n constructor(options: { ttlMs?: number; clock?: () => number; maxConcurrentRefreshes?: number } = {}) {\n this.ttlMs = options.ttlMs ?? WATERMARK_CACHE_TTL_MS;\n this.clock = options.clock ?? Date.now;\n this.maxConcurrentRefreshes = Math.max(1, options.maxConcurrentRefreshes ?? MAX_CONCURRENT_WATERMARK_REFRESHES);\n }\n\n get(namespace: string, compute: () => Promise<CorpusWatermark>): CorpusWatermark | undefined {\n const cached = this.entries.get(namespace);\n const fresh = cached !== undefined && this.clock() < cached.expiresAt;\n if (!fresh) this.refresh(namespace, compute);\n return cached?.value;\n }\n\n private refresh(namespace: string, compute: () => Promise<CorpusWatermark>): void {\n // Single-flight + not-already-queued: one background scan per namespace.\n if (this.inFlight.has(namespace) || this.queued.has(namespace)) return;\n const run = (): void => {\n this.activeRefreshes += 1;\n const pending = compute()\n .then((value) => {\n this.entries.set(namespace, { value, expiresAt: this.clock() + this.ttlMs });\n })\n .catch(() => {\n // Failed/unreadable scan: never cache it; keep serving any stale value.\n })\n .finally(() => {\n this.inFlight.delete(namespace);\n this.activeRefreshes -= 1;\n this.drainQueue();\n });\n this.inFlight.set(namespace, pending);\n };\n // Bound the concurrent fan-out: run now if a slot is free, else queue.\n if (this.activeRefreshes < this.maxConcurrentRefreshes) {\n run();\n } else {\n this.queued.set(namespace, run);\n }\n }\n\n private drainQueue(): void {\n while (this.activeRefreshes < this.maxConcurrentRefreshes && this.queued.size > 0) {\n const next = this.queued.entries().next().value;\n if (!next) break;\n const [namespace, run] = next;\n this.queued.delete(namespace);\n run();\n }\n }\n\n\n /**\n * Stale-while-revalidate the resolved namespace roots (issue #2156 round-7).\n * Namespace enumeration (config scan + persisted-catalog parse) is O(tenants)\n * filesystem work; without this it ran on every probe ahead of the watermark\n * cache. NEVER awaits: returns the cached/stale roots (or undefined when cold)\n * and single-flights a background refresh.\n */\n getResolvedRoots(compute: () => Promise<CorpusNamespaceRoot[]>): CorpusNamespaceRoot[] | undefined {\n const fresh = this.rootsEntry !== undefined && this.clock() < this.rootsEntry.expiresAt;\n if (!fresh && this.rootsInFlight === undefined) {\n this.rootsInFlight = compute()\n .then((value) => {\n this.rootsEntry = { value, expiresAt: this.clock() + this.ttlMs };\n this.rootsRefreshError = undefined;\n })\n .catch((error: unknown) => {\n this.rootsRefreshError = error;\n // Keep serving any stale roots; callers that require completeness\n // inspect the refresh status before trusting them.\n })\n .finally(() => {\n this.rootsInFlight = undefined;\n });\n }\n return this.rootsEntry?.value;\n }\n\n getResolvedRootsStatus(compute: () => Promise<CorpusNamespaceRoot[]>): {\n roots: CorpusNamespaceRoot[] | undefined;\n refreshError: unknown;\n } {\n const roots = this.getResolvedRoots(compute);\n return { roots, refreshError: this.rootsRefreshError };\n }\n /** Await every background refresh — in-flight AND queued (issue #2156 round-9) —\n * plus any roots refresh (shutdown / deterministic tests). */\n async whenIdle(): Promise<void> {\n while (this.inFlight.size > 0 || this.rootsInFlight !== undefined || this.queued.size > 0) {\n const pending: Promise<unknown>[] = [...this.inFlight.values()];\n if (this.rootsInFlight) pending.push(this.rootsInFlight);\n if (pending.length === 0) {\n this.drainQueue(); // queued work with no running peer — start it\n await Promise.resolve();\n continue;\n }\n await Promise.all(pending);\n }\n }\n}\n\n/** Orchestrator surface the service watermark builder reads — satisfied by Orchestrator. */\nexport interface CorpusWatermarkHost {\n config: PluginConfig;\n getStorage(namespace: string): CorpusStorage | Promise<CorpusStorage>;\n}\n\nexport interface ServiceCorpusWatermarkOptions {\n /** Stale-while-revalidate cache so probes never await the corpus scan. */\n cache?: CorpusWatermarkCache;\n /**\n * Presenting token capabilities. When the token is namespace-restricted the\n * fleet view is filtered to the namespaces it may access (issue #2156 finding\n * B); an unrestricted/legacy token keeps the full fleet view.\n */\n caps?: TokenCapabilities | null;\n now?: Date;\n}\n\n/**\n * Build the per-namespace watermark array served on `/health`. Namespaces are\n * resolved through {@link resolveCorpusNamespaceRoots} (shared with the doctor),\n * filtered to the caller's capabilities, then served through the (optional)\n * stale-while-revalidate cache so a probe never blocks on a scan. Degrades to an\n * empty array — never throws — if enumeration is unavailable; an individual\n * namespace whose scan fails is omitted, not allowed to blank the payload.\n */\nexport async function computeServiceCorpusWatermarks(\n host: CorpusWatermarkHost,\n options: ServiceCorpusWatermarkOptions = {},\n): Promise<CorpusWatermark[]> {\n return (await computeServiceCorpusCensus(host, options)).watermarks;\n}\n\n/**\n * Watermarks PLUS whether every configured namespace made it into the set.\n *\n * Completeness is returned ATOMICALLY with the data rather than stashed in a\n * side channel: every early exit here (enumeration threw, roots still warming,\n * a per-namespace scan failed, a cache entry not yet populated) yields an\n * incomplete set, and a caller that certifies convergence against a partial\n * census would hide the divergence of whatever was dropped (issue #2149).\n */\nexport async function computeServiceCorpusCensus(\n host: CorpusWatermarkHost,\n options: ServiceCorpusWatermarkOptions = {},\n): Promise<{ watermarks: CorpusWatermark[]; complete: boolean }> {\n let roots: CorpusNamespaceRoot[] | undefined;\n if (options.cache) {\n const { roots: cachedRoots, refreshError } = options.cache.getResolvedRootsStatus(() =>\n resolveCorpusNamespaceRoots({ config: host.config, propagateDiscoveryErrors: true }),\n );\n if (refreshError !== undefined) return { watermarks: [], complete: false };\n roots = cachedRoots;\n } else {\n try {\n roots = await resolveCorpusNamespaceRoots({\n config: host.config,\n propagateDiscoveryErrors: true,\n });\n } catch {\n return { watermarks: [], complete: false }; // never enumerated — not an empty corpus\n }\n }\n // Enumeration still warming (cold): served on a later probe, and NOT complete.\n if (!roots) return { watermarks: [], complete: false };\n const visible = roots.filter((root) => root.namespaces.some((ns) => capabilityAllowsNamespace(options.caps, ns)));\n const watermarks: CorpusWatermark[] = [];\n let complete = true;\n for (const { namespace } of visible) {\n const compute = async (): Promise<CorpusWatermark> =>\n computeNamespaceWatermark(namespace, await host.getStorage(namespace), options.now);\n if (options.cache) {\n const cached = options.cache.get(namespace, compute);\n if (cached) watermarks.push(cached);\n else complete = false; // still warming — the set is not the full census yet\n } else {\n try {\n watermarks.push(await compute());\n } catch {\n // One tenant's storage/scan failed — omit just that namespace.\n complete = false;\n }\n }\n }\n return { watermarks, complete };\n}\n\n\n"],"mappings":";;;;;;;;AAsCA,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,OAAO,UAAU;AAwBV,IAAM,uBAAuB;AAKpC,IAAM,mBAAmB;AAEzB,IAAM,gBAAgB;AAStB,SAAS,kBAAkB,OAAwB;AACjD,MAAI,CAAC,iBAAiB,KAAK,K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OAAO;AACL,QAAI;AACF,cAAQ,MAAM,4BAA4B;AAAA,QACxC,QAAQ,KAAK;AAAA,QACb,0BAA0B;AAAA,MAC5B,CAAC;AAAA,IACH,QAAQ;AACN,aAAO,EAAE,YAAY,CAAC,GAAG,UAAU,MAAM;AAAA,IAC3C;AAAA,EACF;AAEA,MAAI,CAAC,MAAO,QAAO,EAAE,YAAY,CAAC,GAAG,UAAU,MAAM;AACrD,QAAM,UAAU,MAAM,OAAO,CAAC,SAAS,KAAK,WAAW,KAAK,CAAC,OAAO,0BAA0B,QAAQ,MAAM,EAAE,CAAC,CAAC;AAChH,QAAM,aAAgC,CAAC;AACvC,MAAI,WAAW;AACf,aAAW,EAAE,UAAU,KAAK,SAAS;AACnC,UAAM,UAAU,YACd,0BAA0B,WAAW,MAAM,KAAK,WAAW,SAAS,GAAG,QAAQ,GAAG;AACpF,QAAI,QAAQ,OAAO;AACjB,YAAM,SAAS,QAAQ,MAAM,IAAI,WAAW,OAAO;AACnD,UAAI,OAAQ,YAAW,KAAK,MAAM;AAAA,UAC7B,YAAW;AAAA,IAClB,OAAO;AACL,UAAI;AACF,mBAAW,KAAK,MAAM,QAAQ,CAAC;AAAA,MACjC,QAAQ;AAEN,mBAAW;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACA,SAAO,EAAE,YAAY,SAAS;AAChC;","names":[]}
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
defineOperation,
|
|
29
29
|
parseNamespacePreflightWriteOp,
|
|
30
30
|
resolveAuthorizedNamespaceWritablePreflight
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-Q4XL7LJW.js";
|
|
32
32
|
import {
|
|
33
33
|
projectTagProjectId
|
|
34
34
|
} from "./chunk-BUE5E2HL.js";
|
|
@@ -494,4 +494,4 @@ defineOperation({ name: "graph_events", description: "SSE graph events.", schema
|
|
|
494
494
|
defineOperation({ name: "chat_message", description: "Chat message.", schema: strictSchema({ message: S.str, chatSessionId: S.str }), handler: async (_i, _ctx) => ({ result: { ok: true } }) });
|
|
495
495
|
defineOperation({ name: "chat_events", description: "SSE chat events.", schema: strictSchema({}), handler: async (_i, _ctx) => ({ result: { stream: "sse" } }) });
|
|
496
496
|
defineOperation({ name: "adapters_status", description: "Adapter registry metadata (issue #1850 round 5). Marker op: the HTTP transport builds the response from its own adapterRegistry, but the op still must be registered so it appears in listRegisteredOperations and enforceTokenOp can gate it for scoped tokens.", schema: strictSchema({}), handler: async (_i, _ctx) => ({ result: { ok: true } }) });
|
|
497
|
-
//# sourceMappingURL=chunk-
|
|
497
|
+
//# sourceMappingURL=chunk-PWKZV4A3.js.map
|
|
@@ -43,6 +43,9 @@ import {
|
|
|
43
43
|
boundRecallContextComposition,
|
|
44
44
|
composeRecallContext
|
|
45
45
|
} from "./chunk-AHVEHR6K.js";
|
|
46
|
+
import {
|
|
47
|
+
readAggregateExtractionWatermark
|
|
48
|
+
} from "./chunk-7VIB7PAE.js";
|
|
46
49
|
import {
|
|
47
50
|
buildProposedActions,
|
|
48
51
|
buildQualityScore,
|
|
@@ -101,7 +104,7 @@ import {
|
|
|
101
104
|
import {
|
|
102
105
|
CorpusWatermarkCache,
|
|
103
106
|
computeServiceCorpusCensus
|
|
104
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-OYFDEJZB.js";
|
|
105
108
|
import {
|
|
106
109
|
namespaceCollectionName
|
|
107
110
|
} from "./chunk-IOQFPVGY.js";
|
|
@@ -211,7 +214,7 @@ import {
|
|
|
211
214
|
import {
|
|
212
215
|
ExtractionLivenessWarnThrottle,
|
|
213
216
|
computeExtractionLivenessStatus
|
|
214
|
-
} from "./chunk-
|
|
217
|
+
} from "./chunk-3SG4FGDV.js";
|
|
215
218
|
import {
|
|
216
219
|
sanitizeMemoryContent
|
|
217
220
|
} from "./chunk-5GKPFL3S.js";
|
|
@@ -10437,8 +10440,26 @@ var EngramAccessService = class {
|
|
|
10437
10440
|
const storage = await this.orchestrator.getStorage(resolvedNamespace);
|
|
10438
10441
|
const searchBackend = this.orchestrator.config.searchBackend ?? "qmd";
|
|
10439
10442
|
const qmdEnabled = resolveQmdCapabilities(this.orchestrator.config).qmd === true;
|
|
10440
|
-
const extraction = await computeExtractionLivenessStatus(this.orchestrator, this.extractionLivenessWarn);
|
|
10441
10443
|
const caps = tokenCapabilityStore.getStore();
|
|
10444
|
+
const extractionWatermark = await readAggregateExtractionWatermark({
|
|
10445
|
+
config: this.orchestrator.config,
|
|
10446
|
+
rootStorage: this.orchestrator.storage,
|
|
10447
|
+
storageForNamespace: (candidate) => this.orchestrator.getStorage(candidate),
|
|
10448
|
+
rootsCache: this.corpusWatermarkCache
|
|
10449
|
+
});
|
|
10450
|
+
const extraction = await computeExtractionLivenessStatus(
|
|
10451
|
+
this.orchestrator,
|
|
10452
|
+
extractionWatermark,
|
|
10453
|
+
caps?.namespaces !== void 0 ? void 0 : this.extractionLivenessWarn
|
|
10454
|
+
);
|
|
10455
|
+
const visibleExtraction = caps?.namespaces !== void 0 ? {
|
|
10456
|
+
...extraction,
|
|
10457
|
+
lastExtractionAt: null,
|
|
10458
|
+
bufferedSessionCount: 0,
|
|
10459
|
+
pendingTurnCount: 0,
|
|
10460
|
+
oldestBufferedTurnAgeMs: null,
|
|
10461
|
+
degradedReason: extraction.degraded ? "daemon extraction pipeline degraded" : null
|
|
10462
|
+
} : extraction;
|
|
10442
10463
|
const corpusCensus = await computeServiceCorpusCensus(this.orchestrator, {
|
|
10443
10464
|
cache: this.corpusWatermarkCache,
|
|
10444
10465
|
caps
|
|
@@ -10465,7 +10486,7 @@ var EngramAccessService = class {
|
|
|
10465
10486
|
),
|
|
10466
10487
|
nativeKnowledgeEnabled: this.orchestrator.config.nativeKnowledge?.enabled === true,
|
|
10467
10488
|
projectionAvailable,
|
|
10468
|
-
extraction,
|
|
10489
|
+
extraction: visibleExtraction,
|
|
10469
10490
|
corpus: corpusCensus.watermarks,
|
|
10470
10491
|
// Describes THIS response's array (round 8): a separate scan could report
|
|
10471
10492
|
// complete while the shipped corpus was partial, and peers trust it.
|
|
@@ -13323,4 +13344,4 @@ export {
|
|
|
13323
13344
|
EngramAccessService,
|
|
13324
13345
|
AccessAdminOpsSurface
|
|
13325
13346
|
};
|
|
13326
|
-
//# sourceMappingURL=chunk-
|
|
13347
|
+
//# sourceMappingURL=chunk-Q4XL7LJW.js.map
|