@remnic/core 10.0.184 → 10.0.186

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.
Files changed (61) hide show
  1. package/dist/access-admin-ops-surface.js +6 -6
  2. package/dist/access-cli.js +6 -6
  3. package/dist/access-extraction-force-flush-preempt.js +6 -6
  4. package/dist/access-extraction-force-flush.js +6 -6
  5. package/dist/access-http-briefing.js +6 -6
  6. package/dist/access-http-query.js +6 -6
  7. package/dist/access-http.js +6 -6
  8. package/dist/access-identity-continuity-surface.js +6 -6
  9. package/dist/access-lcm-surface.js +6 -6
  10. package/dist/access-mcp.js +6 -6
  11. package/dist/access-observe-write-surface.js +6 -6
  12. package/dist/access-operations-batch.js +6 -6
  13. package/dist/access-operations.js +6 -6
  14. package/dist/access-recall-concurrency.js +6 -6
  15. package/dist/access-recall-response.js +6 -6
  16. package/dist/access-recall-surface.js +6 -6
  17. package/dist/access-service.js +6 -6
  18. package/dist/active-recall.js +1 -1
  19. package/dist/{auto-sync-24ATHF7G.js → auto-sync-OOEY2FSA.js} +3 -3
  20. package/dist/{chunk-WCED4XID.js → chunk-3GD5SFDT.js} +2 -2
  21. package/dist/{chunk-OELN4JIO.js → chunk-A3HLZMHD.js} +2 -2
  22. package/dist/{chunk-KUCMDUEZ.js → chunk-DYZDFOBX.js} +1 -1
  23. package/dist/chunk-DYZDFOBX.js.map +1 -0
  24. package/dist/{chunk-YTBBH5YH.js → chunk-LALPM2DN.js} +49 -12
  25. package/dist/chunk-LALPM2DN.js.map +1 -0
  26. package/dist/{chunk-DCEJRGAT.js → chunk-N2PXVLV3.js} +2 -2
  27. package/dist/{chunk-WGNAJEDV.js → chunk-NU5JRN3A.js} +2 -2
  28. package/dist/{chunk-4NVYPWMJ.js → chunk-QSVWIKNY.js} +7 -7
  29. package/dist/chunk-QSVWIKNY.js.map +1 -0
  30. package/dist/cli.js +6 -6
  31. package/dist/config.js +1 -1
  32. package/dist/explicit-capture.js +6 -6
  33. package/dist/extraction-judge.d.ts +4 -3
  34. package/dist/extraction-judge.d.ts.map +1 -1
  35. package/dist/extraction-judge.js +1 -1
  36. package/dist/index.js +6 -6
  37. package/dist/operator-toolkit.js +2 -2
  38. package/dist/orchestration/backlog-scheduler.js +7 -7
  39. package/dist/orchestration/buffer-drain-runner.js +7 -7
  40. package/dist/orchestration/extraction-queue-coordinator.d.ts +20 -0
  41. package/dist/orchestration/extraction-queue-coordinator.d.ts.map +1 -1
  42. package/dist/orchestration/turn-ingestion.d.ts.map +1 -1
  43. package/dist/orchestrator.js +6 -6
  44. package/dist/recall-navigation.js +6 -6
  45. package/dist/resume-bundles.js +2 -2
  46. package/package.json +2 -2
  47. package/src/config.test.ts +3 -3
  48. package/src/config.ts +6 -6
  49. package/src/extraction-judge-chain.test.ts +2 -2
  50. package/src/extraction-judge.ts +4 -3
  51. package/src/orchestration/extraction-queue-coordinator.ts +64 -3
  52. package/src/orchestration/extraction-queue-lane-bias.test.ts +185 -0
  53. package/src/orchestration/turn-ingestion.ts +7 -1
  54. package/dist/chunk-4NVYPWMJ.js.map +0 -1
  55. package/dist/chunk-KUCMDUEZ.js.map +0 -1
  56. package/dist/chunk-YTBBH5YH.js.map +0 -1
  57. /package/dist/{auto-sync-24ATHF7G.js.map → auto-sync-OOEY2FSA.js.map} +0 -0
  58. /package/dist/{chunk-WCED4XID.js.map → chunk-3GD5SFDT.js.map} +0 -0
  59. /package/dist/{chunk-OELN4JIO.js.map → chunk-A3HLZMHD.js.map} +0 -0
  60. /package/dist/{chunk-DCEJRGAT.js.map → chunk-N2PXVLV3.js.map} +0 -0
  61. /package/dist/{chunk-WGNAJEDV.js.map → chunk-NU5JRN3A.js.map} +0 -0
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  assembleRecallResponse
3
- } from "./chunk-YTBBH5YH.js";
3
+ } from "./chunk-LALPM2DN.js";
4
4
  import "./chunk-PQM3B54K.js";
5
- import "./chunk-OELN4JIO.js";
5
+ import "./chunk-A3HLZMHD.js";
6
6
  import "./chunk-GOZXQNIM.js";
7
7
  import "./chunk-H4CKS5B2.js";
8
8
  import "./chunk-W4F3C7N7.js";
@@ -105,7 +105,7 @@ import "./chunk-WWDO7ZWM.js";
105
105
  import "./chunk-VUC3DLQ5.js";
106
106
  import "./chunk-U7VEZ2XS.js";
107
107
  import "./chunk-ZKE4CO6B.js";
108
- import "./chunk-WGNAJEDV.js";
108
+ import "./chunk-NU5JRN3A.js";
109
109
  import "./chunk-B2NXOVZN.js";
110
110
  import "./chunk-7DFJ4JX2.js";
111
111
  import "./chunk-PQVLF42S.js";
@@ -153,7 +153,7 @@ import "./chunk-ROI7BK7H.js";
153
153
  import "./chunk-3T74IZB3.js";
154
154
  import "./chunk-E5IZTY4W.js";
155
155
  import "./chunk-IJKO5RVJ.js";
156
- import "./chunk-DCEJRGAT.js";
156
+ import "./chunk-N2PXVLV3.js";
157
157
  import "./chunk-CIC3WZVO.js";
158
158
  import "./chunk-KFY3SGN7.js";
159
159
  import "./chunk-CMTINOFS.js";
@@ -212,7 +212,7 @@ import "./chunk-A6CXG5WI.js";
212
212
  import "./chunk-QJ2AX6DU.js";
213
213
  import "./chunk-ULLGI6XR.js";
214
214
  import "./chunk-PT4DZDJA.js";
215
- import "./chunk-KUCMDUEZ.js";
215
+ import "./chunk-DYZDFOBX.js";
216
216
  import "./chunk-VN3RYYMS.js";
217
217
  import "./chunk-MLAMXQAW.js";
218
218
  import "./chunk-AIYXVWUH.js";
@@ -342,7 +342,7 @@ import "./chunk-43HUVDTD.js";
342
342
  import "./chunk-4RA3C3EV.js";
343
343
  import "./chunk-TOTT6S2V.js";
344
344
  import "./chunk-U4ECSKQE.js";
345
- import "./chunk-4NVYPWMJ.js";
345
+ import "./chunk-QSVWIKNY.js";
346
346
  import "./chunk-ZKOPY4WW.js";
347
347
  import "./chunk-62OKGIJA.js";
348
348
  import "./chunk-J5WI4QRP.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  AccessRecallSurface
3
- } from "./chunk-YTBBH5YH.js";
3
+ } from "./chunk-LALPM2DN.js";
4
4
  import "./chunk-PQM3B54K.js";
5
- import "./chunk-OELN4JIO.js";
5
+ import "./chunk-A3HLZMHD.js";
6
6
  import "./chunk-GOZXQNIM.js";
7
7
  import "./chunk-H4CKS5B2.js";
8
8
  import "./chunk-W4F3C7N7.js";
@@ -105,7 +105,7 @@ import "./chunk-WWDO7ZWM.js";
105
105
  import "./chunk-VUC3DLQ5.js";
106
106
  import "./chunk-U7VEZ2XS.js";
107
107
  import "./chunk-ZKE4CO6B.js";
108
- import "./chunk-WGNAJEDV.js";
108
+ import "./chunk-NU5JRN3A.js";
109
109
  import "./chunk-B2NXOVZN.js";
110
110
  import "./chunk-7DFJ4JX2.js";
111
111
  import "./chunk-PQVLF42S.js";
@@ -153,7 +153,7 @@ import "./chunk-ROI7BK7H.js";
153
153
  import "./chunk-3T74IZB3.js";
154
154
  import "./chunk-E5IZTY4W.js";
155
155
  import "./chunk-IJKO5RVJ.js";
156
- import "./chunk-DCEJRGAT.js";
156
+ import "./chunk-N2PXVLV3.js";
157
157
  import "./chunk-CIC3WZVO.js";
158
158
  import "./chunk-KFY3SGN7.js";
159
159
  import "./chunk-CMTINOFS.js";
@@ -212,7 +212,7 @@ import "./chunk-A6CXG5WI.js";
212
212
  import "./chunk-QJ2AX6DU.js";
213
213
  import "./chunk-ULLGI6XR.js";
214
214
  import "./chunk-PT4DZDJA.js";
215
- import "./chunk-KUCMDUEZ.js";
215
+ import "./chunk-DYZDFOBX.js";
216
216
  import "./chunk-VN3RYYMS.js";
217
217
  import "./chunk-MLAMXQAW.js";
218
218
  import "./chunk-AIYXVWUH.js";
@@ -342,7 +342,7 @@ import "./chunk-43HUVDTD.js";
342
342
  import "./chunk-4RA3C3EV.js";
343
343
  import "./chunk-TOTT6S2V.js";
344
344
  import "./chunk-U4ECSKQE.js";
345
- import "./chunk-4NVYPWMJ.js";
345
+ import "./chunk-QSVWIKNY.js";
346
346
  import "./chunk-ZKOPY4WW.js";
347
347
  import "./chunk-62OKGIJA.js";
348
348
  import "./chunk-J5WI4QRP.js";
@@ -4,9 +4,9 @@ import {
4
4
  buildProjectedGovernanceProposedActions,
5
5
  hasGroupedGovernanceActions,
6
6
  shapeMemorySummary
7
- } from "./chunk-YTBBH5YH.js";
7
+ } from "./chunk-LALPM2DN.js";
8
8
  import "./chunk-PQM3B54K.js";
9
- import "./chunk-OELN4JIO.js";
9
+ import "./chunk-A3HLZMHD.js";
10
10
  import "./chunk-GOZXQNIM.js";
11
11
  import "./chunk-H4CKS5B2.js";
12
12
  import "./chunk-W4F3C7N7.js";
@@ -109,7 +109,7 @@ import "./chunk-WWDO7ZWM.js";
109
109
  import "./chunk-VUC3DLQ5.js";
110
110
  import "./chunk-U7VEZ2XS.js";
111
111
  import "./chunk-ZKE4CO6B.js";
112
- import "./chunk-WGNAJEDV.js";
112
+ import "./chunk-NU5JRN3A.js";
113
113
  import "./chunk-B2NXOVZN.js";
114
114
  import "./chunk-7DFJ4JX2.js";
115
115
  import "./chunk-PQVLF42S.js";
@@ -157,7 +157,7 @@ import "./chunk-ROI7BK7H.js";
157
157
  import "./chunk-3T74IZB3.js";
158
158
  import "./chunk-E5IZTY4W.js";
159
159
  import "./chunk-IJKO5RVJ.js";
160
- import "./chunk-DCEJRGAT.js";
160
+ import "./chunk-N2PXVLV3.js";
161
161
  import "./chunk-CIC3WZVO.js";
162
162
  import "./chunk-KFY3SGN7.js";
163
163
  import "./chunk-CMTINOFS.js";
@@ -216,7 +216,7 @@ import "./chunk-A6CXG5WI.js";
216
216
  import "./chunk-QJ2AX6DU.js";
217
217
  import "./chunk-ULLGI6XR.js";
218
218
  import "./chunk-PT4DZDJA.js";
219
- import "./chunk-KUCMDUEZ.js";
219
+ import "./chunk-DYZDFOBX.js";
220
220
  import "./chunk-VN3RYYMS.js";
221
221
  import "./chunk-MLAMXQAW.js";
222
222
  import "./chunk-AIYXVWUH.js";
@@ -346,7 +346,7 @@ import "./chunk-43HUVDTD.js";
346
346
  import "./chunk-4RA3C3EV.js";
347
347
  import "./chunk-TOTT6S2V.js";
348
348
  import "./chunk-U4ECSKQE.js";
349
- import "./chunk-4NVYPWMJ.js";
349
+ import "./chunk-QSVWIKNY.js";
350
350
  import "./chunk-ZKOPY4WW.js";
351
351
  import "./chunk-62OKGIJA.js";
352
352
  import "./chunk-J5WI4QRP.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_REASONING_MODEL
3
- } from "./chunk-4NVYPWMJ.js";
3
+ } from "./chunk-QSVWIKNY.js";
4
4
  import "./chunk-ZKOPY4WW.js";
5
5
  import "./chunk-62OKGIJA.js";
6
6
  import "./chunk-J5WI4QRP.js";
@@ -2,9 +2,9 @@ import {
2
2
  dateInTimezone,
3
3
  defaultTimezone,
4
4
  describeErrorForOperator
5
- } from "./chunk-OELN4JIO.js";
5
+ } from "./chunk-A3HLZMHD.js";
6
6
  import "./chunk-UOBPK2OS.js";
7
- import "./chunk-KUCMDUEZ.js";
7
+ import "./chunk-DYZDFOBX.js";
8
8
  import "./chunk-CIO7GCWE.js";
9
9
  import "./chunk-FE43YKNJ.js";
10
10
  import "./chunk-QW27DOHG.js";
@@ -96,4 +96,4 @@ function startWearablesAutoSync(settings, deps) {
96
96
  export {
97
97
  startWearablesAutoSync
98
98
  };
99
- //# sourceMappingURL=auto-sync-24ATHF7G.js.map
99
+ //# sourceMappingURL=auto-sync-OOEY2FSA.js.map
@@ -2,7 +2,7 @@ import {
2
2
  ExtractionDrain,
3
3
  TurnIngestionCoordinator,
4
4
  shouldSkipImplicitExtraction
5
- } from "./chunk-YTBBH5YH.js";
5
+ } from "./chunk-LALPM2DN.js";
6
6
  import {
7
7
  headerConnector,
8
8
  renderExtractionConversation,
@@ -447,4 +447,4 @@ export {
447
447
  ClaimBufferStorage,
448
448
  BufferDrainRunner
449
449
  };
450
- //# sourceMappingURL=chunk-WCED4XID.js.map
450
+ //# sourceMappingURL=chunk-3GD5SFDT.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-UOBPK2OS.js";
4
4
  import {
5
5
  getVerdictKind
6
- } from "./chunk-KUCMDUEZ.js";
6
+ } from "./chunk-DYZDFOBX.js";
7
7
  import {
8
8
  collectPersonEntityRefs,
9
9
  isHighImpactPersonalFact
@@ -1364,4 +1364,4 @@ export {
1364
1364
  syncWearableSource,
1365
1365
  defaultTimezone
1366
1366
  };
1367
- //# sourceMappingURL=chunk-OELN4JIO.js.map
1367
+ //# sourceMappingURL=chunk-A3HLZMHD.js.map
@@ -496,4 +496,4 @@ export {
496
496
  createVerdictCache,
497
497
  createDeferCountMap
498
498
  };
499
- //# sourceMappingURL=chunk-KUCMDUEZ.js.map
499
+ //# sourceMappingURL=chunk-DYZDFOBX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/extraction-judge.ts"],"sourcesContent":["/**\n * Extraction Judge — LLM-as-judge fact-worthiness gate (issue #376).\n *\n * Evaluates extracted facts against a durability rubric before they are\n * persisted. Facts that are unlikely to be useful 30+ days from now or\n * across sessions are rejected (or shadow-logged depending on config).\n *\n * Design constraints:\n * - Corrections and principles are auto-approved (safety bypass).\n * - Critical-importance facts are auto-approved.\n * - Batches respect extractionJudgeBatchSize.\n * - Content-hash caching avoids redundant LLM calls.\n * - LLM calls use extractionJudgeTimeoutMs (default 90s: measured 2.1-2.5 s\n * per compact verdict request with a batch-scaled completion budget on a\n * small fast judge model; 13-22 s per compact call, 41 s verbose, on the\n * big shared core model, and 20s+ per attempt under queue contention —\n * the old 20s default aborted 300 judge calls in one observed hour;\n * it papered over 59-305s verbose replies).\n */\n\nimport { createHash } from \"node:crypto\";\nimport { log } from \"./logger.js\";\nimport type { PluginConfig, ImportanceLevel } from \"./types.js\";\nimport type { LocalLlmClient } from \"./local-llm.js\";\nimport { type FallbackLlmClient, gatewayTaskChainOptions } from \"./fallback-llm.js\";\nimport { extractJsonCandidates } from \"./json-extract.js\";\nimport { normalizeProcedureSteps } from \"./procedural/procedure-types.js\";\nimport { OUTPUT_LANGUAGE_POLICY } from \"./extraction-prompt.js\";\n\n// ---------------------------------------------------------------------------\n// Public interfaces\n// ---------------------------------------------------------------------------\n\nexport interface JudgeCandidate {\n text: string;\n category: string;\n confidence: number;\n tags?: string[];\n /** Local importance level, set by caller before judging. */\n importanceLevel?: ImportanceLevel;\n}\n\n/**\n * Verdict kinds (issue #562, PR 1).\n *\n * - `\"accept\"`: fact is durable, persist it.\n * - `\"reject\"`: fact is not durable, drop it.\n * - `\"defer\"`: fact is ambiguous; push it back into the buffer for another\n * pass with fresh context. Inspired by MemReader (arxiv 2604.07877).\n *\n * PR 1 only introduces the type. No emit path produces `\"defer\"` yet — the\n * defer-capable prompt, buffer re-routing, telemetry, and GRPO data\n * collection are landing in PRs 2, 3, and 4 respectively.\n */\nexport type JudgeVerdictKind = \"accept\" | \"reject\" | \"defer\";\n\n/**\n * Judge verdict shape.\n *\n * Back-compat note: `kind` is optional. Verdicts serialized before PR 1\n * (both in-memory cache entries and any persisted caches) only carry\n * `{ durable, reason }`. Downstream consumers must either read `durable`\n * directly, or use {@link getVerdictKind} / {@link isDurableVerdict} which\n * gracefully fall back to the boolean when `kind` is missing, and ignore\n * unknown future `kind` values rather than crashing.\n */\nexport interface JudgeVerdict {\n /**\n * True iff the fact should be persisted. For `\"defer\"` verdicts this is\n * `false` — a deferred fact is not (yet) persisted, so callers that only\n * look at `durable` will treat defer as \"skip this turn\", which matches\n * the pre-PR-1 fail-closed behavior for non-accepted verdicts.\n */\n durable: boolean;\n reason: string;\n /**\n * Optional explicit verdict kind. Added in PR 1 of issue #562. Legacy\n * verdicts (including cache entries produced before this field existed)\n * do not set `kind`; use {@link getVerdictKind} to read this safely.\n */\n kind?: JudgeVerdictKind;\n}\n\n/**\n * Resolve a verdict's effective kind.\n *\n * - If `kind` is explicitly set to one of the known values, return it.\n * - If `kind` is absent, infer from `durable` (back-compat with pre-PR-1\n * cache entries and emit paths that have not been updated yet).\n * - If `kind` is set to an unrecognised value (forward-compat, e.g. a\n * future cache entry loaded by an older build), fall back to `durable`\n * so we never crash on unknown strings.\n */\nexport function getVerdictKind(verdict: JudgeVerdict): JudgeVerdictKind {\n const raw = verdict.kind;\n if (raw === \"accept\" || raw === \"reject\" || raw === \"defer\") {\n return raw;\n }\n return verdict.durable ? \"accept\" : \"reject\";\n}\n\n/**\n * Type guard: returns `true` only for verdicts that should be persisted.\n * Treats both `\"reject\"` and `\"defer\"` as \"not durable\" — defer means the\n * caller should re-evaluate later, not write now.\n */\nexport function isDurableVerdict(verdict: JudgeVerdict): boolean {\n return getVerdictKind(verdict) === \"accept\";\n}\n\n/**\n * Validate a cache entry loaded from persistence / another process.\n *\n * Strict: accepts legacy `{ durable, reason }` entries and new entries\n * whose `kind` is one of the three known `JudgeVerdictKind` values.\n * Rejects structurally wrong types and unknown `kind` strings so the\n * type-guard narrowing is sound — callers that receive\n * `value is JudgeVerdict` can safely treat `kind` as the declared\n * union.\n *\n * Forward-compat is handled by {@link normalizeCachedVerdict}, which\n * drops unknown `kind` strings before validation so a newer build's\n * cache entry still loads instead of being rejected.\n */\nexport function isValidCachedVerdict(value: unknown): value is JudgeVerdict {\n if (typeof value !== \"object\" || value === null) return false;\n const v = value as Record<string, unknown>;\n if (typeof v.durable !== \"boolean\") return false;\n if (typeof v.reason !== \"string\") return false;\n if (v.kind !== undefined) {\n if (v.kind !== \"accept\" && v.kind !== \"reject\" && v.kind !== \"defer\") {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Forward-compatible cache-entry loader.\n *\n * Drops unknown `kind` strings to `undefined` (so `getVerdictKind` can\n * fall back to `durable`), then validates structurally. Non-string\n * `kind` values are still treated as structural violations and rejected.\n * Returns the sanitised verdict, or `null` when the entry is structurally\n * unusable.\n */\nexport function normalizeCachedVerdict(value: unknown): JudgeVerdict | null {\n if (typeof value !== \"object\" || value === null) return null;\n const v = value as Record<string, unknown>;\n if (typeof v.durable !== \"boolean\") return null;\n if (typeof v.reason !== \"string\") return null;\n let kind: JudgeVerdictKind | undefined;\n if (v.kind !== undefined) {\n if (typeof v.kind !== \"string\") return null;\n if (v.kind === \"accept\" || v.kind === \"reject\" || v.kind === \"defer\") {\n kind = v.kind;\n }\n // Unknown string `kind`: dropped to undefined for forward-compat.\n }\n const out: JudgeVerdict = { durable: v.durable, reason: v.reason };\n if (kind !== undefined) out.kind = kind;\n return out;\n}\n\nexport interface JudgeBatchResult {\n verdicts: Map<number, JudgeVerdict>;\n /** Number of verdicts served from cache. */\n cached: number;\n /** Number of verdicts produced by an LLM call. */\n judged: number;\n /** Total wall-clock time in milliseconds. */\n elapsed: number;\n /**\n * Number of verdicts in this batch that resolved to `\"defer\"` (issue #562,\n * PR 2). Callers can use this to decide whether to retain buffer turns for\n * the next extraction pass.\n */\n deferred: number;\n /**\n * Number of defers that were forcibly converted to `\"reject\"` because the\n * same candidate text had already been deferred at least\n * `extractionJudgeMaxDeferrals` times. Rolled out of `deferred` — a\n * candidate counted here is *not* also in `deferred`.\n */\n deferredCappedToReject: number;\n}\n\n/**\n * Per-verdict observation emitted by `judgeFactDurability` when an\n * `onVerdict` callback is supplied (issue #562, PR 3). Used to wire the\n * observation ledger / telemetry stream without coupling the judge module\n * directly to filesystem I/O. One event is emitted for every resolved\n * verdict, including auto-approved and cache-hit paths.\n */\nexport interface JudgeVerdictObservation {\n verdict: JudgeVerdict;\n /** The original `JudgeCandidate` passed in (same reference). */\n candidate: JudgeCandidate;\n /** SHA-256 of `text\\0category`, same key the cache/deferCounter use. */\n contentHash: string;\n /** Verdict resolution path. Useful for debugging + dashboards. */\n source: \"auto-approve\" | \"cache\" | \"llm\" | \"llm-cap-rejected\" | \"fail-open\";\n /**\n * How many times this candidate had already been deferred before this\n * verdict resolved. 0 when the candidate had never been deferred.\n */\n priorDeferrals: number;\n /**\n * Milliseconds from batch start to now. Shared across verdicts emitted in\n * the same batch.\n */\n elapsedMs: number;\n}\n\n// ---------------------------------------------------------------------------\n// Prompt (embedded; mirrors prompts/extraction_judge.prompt.md)\n// ---------------------------------------------------------------------------\n\nexport const JUDGE_SYSTEM_PROMPT = `You are a memory curator evaluating whether extracted facts are **durable** — worth storing for long-term recall across sessions.\n\nA fact is **durable** if it will still be useful 30+ days from now and is relevant across multiple sessions, not just the current task.\n\nThe user message is a JSON array of candidates: [{\"index\": 0, \"text\": \"...\", \"category\": \"...\", \"confidence\": 0.5}, ...].\n\nVerdicts:\n- \"accept\" — durable. Personal preferences, identities, relationships; decisions with rationale that affect future work; corrections to previously held beliefs; principles, rules, or constraints the user wants respected; stable facts about projects, tools, or workflows; commitments, deadlines, or obligations.\n- \"reject\" — not durable. Transient task details (\"currently debugging line 42\"); ephemeral state (\"the build is running now\"); routine operations (\"ran npm install\"); conversational filler; anything stale within hours; step-by-step instructions for a one-time task.\n- \"defer\" — MIGHT be durable but the candidate alone cannot say: ambiguous referents (\"he said they'd follow up\"), in-progress statements that may become durable once completed, future commitments with unclear subject or timeline. Defer is NOT a soft reject: use it only when another turn of context would genuinely change the verdict; when torn between accept and reject, lean accept — losing a useful fact is worse than keeping a marginal one.\n\nReply with a JSON object with a single \"verdicts\" key, exactly one object per input candidate:\n{\"verdicts\": [{\"index\": <candidate index>, \"kind\": \"accept\" | \"reject\" | \"defer\"}]}\n\nRules:\n1. The top level must be one object {\"verdicts\": [...]} — JSON mode rejects a bare top-level array.\n2. Copy each object's \"index\" from the input candidate. One object per candidate, exactly.\n3. No other fields — no \"reason\", no \"durable\", no commentary.\n4. Output valid JSON only. No markdown fences.\n5. ${OUTPUT_LANGUAGE_POLICY}\n\nExample output:\n{\"verdicts\": [{\"index\": 0, \"kind\": \"accept\"}, {\"index\": 1, \"kind\": \"reject\"}, {\"index\": 2, \"kind\": \"defer\"}]}`;\n\n// ---------------------------------------------------------------------------\n// Judge request assembly (PR 3264 follow-up)\n// ---------------------------------------------------------------------------\n\n/** Completion tokens reserved per candidate verdict (measured 13 on a small judge model). */\nconst JUDGE_TOKENS_PER_CANDIDATE = 24;\n/** Ceiling on one judge reply: the old flat budget. */\nexport const MAX_JUDGE_TOKENS = 2048;\n/**\n * Extra completion tokens for a judge call routed through the Responses API. Reasoning tokens count against\n * `max_output_tokens`, so the compact verdict budget alone can be spent before a reasoning-enabled model answers; the\n * unparsed batch would then fail open as durable. A cap, not a target: a non-reasoning model still writes a short reply.\n */\nexport const JUDGE_REASONING_HEADROOM_TOKENS = 1024;\n/** Largest batch whose verdict array fits MAX_JUDGE_TOKENS; a larger configured batch is split. */\nexport const MAX_JUDGE_BATCH = Math.floor(MAX_JUDGE_TOKENS / JUDGE_TOKENS_PER_CANDIDATE);\n\n/**\n * Compact completion budget for one judge call. A verdict is\n * `{\"index\":12,\"kind\":\"reject\"}` (~14 tokens), so the old flat 2048 only gave\n * a slow model room to produce 59-305s replies that hid inside the timeout.\n * Scales with the batch size (about 24 tokens per candidate verdict, measured\n * 13 per verdict on a small judge model) so a large batch is never truncated;\n * capped at 2048, the old flat budget.\n */\nexport function judgeMaxTokens(batchSize: number): number {\n return Math.min(MAX_JUDGE_TOKENS, Math.max(64, batchSize * JUDGE_TOKENS_PER_CANDIDATE));\n}\n\n/** One indexed candidate entry in a judge request payload. */\nexport interface JudgeRequestEntry {\n index: number;\n text: string;\n category: string;\n confidence: number;\n}\n\n/** Full judge LLM request: messages plus the completion budget. */\nexport interface JudgeRequest {\n messages: Array<{ role: \"system\" | \"user\"; content: string }>;\n maxTokens: number;\n}\n\n/** Build a full judge request body: messages plus the completion budget. */\nexport function buildJudgeRequest(entries: readonly JudgeRequestEntry[]): JudgeRequest {\n return {\n messages: [\n { role: \"system\", content: JUDGE_SYSTEM_PROMPT },\n { role: \"user\", content: JSON.stringify(entries) },\n ],\n maxTokens: judgeMaxTokens(entries.length),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Content-hash cache (in-memory, per-process fallback)\n// ---------------------------------------------------------------------------\n\n/** Maximum entries before evicting the oldest half. */\nconst VERDICT_CACHE_MAX_SIZE = 10_000;\n\n/** Module-level fallback cache, used when callers do not pass their own. */\nconst defaultVerdictCache = new Map<string, JudgeVerdict>();\n\n/**\n * Per-content-hash deferral counter (issue #562, PR 2).\n *\n * When the judge emits a `\"defer\"` verdict for a candidate whose content\n * has already been deferred `extractionJudgeMaxDeferrals` times, the verdict\n * is forcibly converted to `\"reject\"` so a pathological LLM response cannot\n * produce an infinite defer loop.\n *\n * Module-level with a size cap so stale test state cannot leak between runs\n * in the unlikely case a caller does not clear it between processes.\n */\nconst defaultDeferCounts = new Map<string, number>();\nconst DEFER_COUNT_MAX_SIZE = 20_000;\n\nfunction cacheKey(text: string, category: string): string {\n return createHash(\"sha256\").update(`${text}\\0${category}`).digest(\"hex\");\n}\n\n/**\n * Resolve the effective defer cap from config, defaulting to 2 when the\n * config value is missing or non-positive. Matches the PR 2 spec.\n */\nfunction resolveDeferCap(config: PluginConfig): number {\n const raw = (config as { extractionJudgeMaxDeferrals?: number })\n .extractionJudgeMaxDeferrals;\n if (typeof raw === \"number\" && Number.isFinite(raw) && raw >= 1) {\n return Math.floor(raw);\n }\n return 2;\n}\n\n/**\n * Enforce the max-size invariant on a verdict cache. When the cache exceeds\n * VERDICT_CACHE_MAX_SIZE, the oldest half of entries are deleted (Map\n * iteration order is insertion order).\n */\nfunction enforceMaxCacheSize(cache: Map<string, JudgeVerdict>): void {\n if (cache.size <= VERDICT_CACHE_MAX_SIZE) return;\n const deleteCount = Math.floor(cache.size / 2);\n let deleted = 0;\n for (const key of cache.keys()) {\n if (deleted >= deleteCount) break;\n cache.delete(key);\n deleted++;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Categories that bypass the judge (safety / correctness)\n// ---------------------------------------------------------------------------\n\nconst AUTO_APPROVE_CATEGORIES = new Set([\"correction\", \"principle\"]);\n\n/** Explicit trigger phrasing — procedures must match to persist (issue #519). */\nconst PROCEDURE_TRIGGER_RE =\n /(when you|whenever|before you|before running|always\\s|first\\b.*\\bthen|to deploy|to ship|run these steps|follow these steps|how (i|we)\\s|recipe for|workflow|each time you)/i;\n\n/**\n * Deterministic gate for extracted `procedure` memories: ≥2 steps with non-empty\n * intents and explicit trigger wording in title and/or steps.\n */\nexport function validateProcedureExtraction(input: {\n content: string;\n procedureSteps?: unknown;\n}): JudgeVerdict {\n const steps = normalizeProcedureSteps(input.procedureSteps);\n if (steps.length < 2) {\n return { durable: false, reason: \"Procedure requires at least two steps with intents\" };\n }\n const combined = [input.content, ...steps.map((s) => s.intent)].join(\" \").toLowerCase();\n if (!PROCEDURE_TRIGGER_RE.test(combined)) {\n return { durable: false, reason: \"Procedure missing explicit trigger phrasing\" };\n }\n return { durable: true, reason: \"Procedure structure validated\" };\n}\n\n// ---------------------------------------------------------------------------\n// Core judge function\n// ---------------------------------------------------------------------------\n\n/**\n * Evaluate a batch of candidate facts for durability.\n *\n * Auto-approves corrections, principles, and critical-importance facts.\n * Remaining candidates are batched (up to extractionJudgeBatchSize),\n * checked against an in-memory content-hash cache, and sent to the LLM\n * for verdict.\n */\nexport async function judgeFactDurability(\n candidates: JudgeCandidate[],\n config: PluginConfig,\n localLlm: LocalLlmClient | null,\n fallbackLlm: FallbackLlmClient | null,\n cache?: Map<string, JudgeVerdict>,\n deferCounts?: Map<string, number>,\n onVerdict?: (observation: JudgeVerdictObservation) => void,\n): Promise<JudgeBatchResult> {\n const startMs = Date.now();\n const verdicts = new Map<number, JudgeVerdict>();\n let cached = 0;\n let judged = 0;\n let deferred = 0;\n let deferredCappedToReject = 0;\n\n // Use caller-provided cache for per-orchestrator scoping, or fall back\n // to the module-level default cache.\n const verdictCache = cache ?? defaultVerdictCache;\n const deferCountMap = deferCounts ?? defaultDeferCounts;\n const deferCap = resolveDeferCap(config);\n\n // Lazy emit (Codex P2): when `onVerdict` is undefined (default path —\n // telemetry off), payload construction is skipped entirely. Callers\n // pass a factory instead of a pre-built observation so the `sha256`\n // `contentHash` and surrounding object allocation only run when a\n // subscriber is present. For large batches with telemetry off this\n // removes per-verdict overhead that would otherwise fire on every\n // auto-approved / cache / fail-open path.\n const emit = (build: () => JudgeVerdictObservation): void => {\n if (!onVerdict) return;\n let observation: JudgeVerdictObservation;\n try {\n observation = build();\n } catch (err) {\n log.debug(\n `extraction-judge: onVerdict builder threw (non-fatal): ${err instanceof Error ? err.message : String(err)}`,\n );\n return;\n }\n try {\n onVerdict(observation);\n } catch (err) {\n // Fail-open: telemetry errors must never block extraction.\n log.debug(\n `extraction-judge: onVerdict callback threw (non-fatal): ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n };\n\n if (candidates.length === 0) {\n return {\n verdicts,\n cached,\n judged,\n elapsed: 0,\n deferred,\n deferredCappedToReject,\n };\n }\n\n // Indices that need LLM judgment\n const pendingIndices: number[] = [];\n\n for (let i = 0; i < candidates.length; i++) {\n const c = candidates[i];\n\n // Auto-approve safety categories\n if (AUTO_APPROVE_CATEGORIES.has(c.category)) {\n const v: JudgeVerdict = {\n durable: true,\n reason: `Auto-approved: ${c.category} category bypasses judge`,\n };\n verdicts.set(i, v);\n emit(() => ({\n verdict: v,\n candidate: c,\n contentHash: cacheKey(c.text, c.category),\n source: \"auto-approve\",\n priorDeferrals: 0,\n elapsedMs: Date.now() - startMs,\n }));\n continue;\n }\n\n // Auto-approve critical importance\n if (c.importanceLevel === \"critical\") {\n const v: JudgeVerdict = {\n durable: true,\n reason: \"Auto-approved: critical importance\",\n };\n verdicts.set(i, v);\n emit(() => ({\n verdict: v,\n candidate: c,\n contentHash: cacheKey(c.text, c.category),\n source: \"auto-approve\",\n priorDeferrals: 0,\n elapsedMs: Date.now() - startMs,\n }));\n continue;\n }\n\n // Check cache\n const key = cacheKey(c.text, c.category);\n const cachedVerdict = verdictCache.get(key);\n if (cachedVerdict) {\n verdicts.set(i, cachedVerdict);\n cached++;\n emit(() => ({\n verdict: cachedVerdict,\n candidate: c,\n contentHash: key,\n source: \"cache\",\n priorDeferrals: deferCountMap.get(key) ?? 0,\n elapsedMs: Date.now() - startMs,\n }));\n continue;\n }\n\n pendingIndices.push(i);\n }\n\n // If all resolved without LLM, return early\n if (pendingIndices.length === 0) {\n return {\n verdicts,\n cached,\n judged,\n elapsed: Date.now() - startMs,\n deferred,\n deferredCappedToReject,\n };\n }\n\n // Batch the pending candidates up to batchSize\n const batchSize = Math.min(config.extractionJudgeBatchSize, MAX_JUDGE_BATCH);\n // Defer bookkeeping spans the WHOLE call, not one batch: identical candidates can land in different batches, and each key\n // must advance the defer cap once and decide against the same prior count (the snapshot taken at its first sighting).\n const deferredThisCall = new Set<string>();\n const priorDefersSeen = new Map<string, number>();\n for (let batchStart = 0; batchStart < pendingIndices.length; batchStart += batchSize) {\n const batchIndices = pendingIndices.slice(batchStart, batchStart + batchSize);\n const request = buildJudgeRequest(\n batchIndices.map((idx) => ({\n index: idx,\n text: candidates[idx].text,\n category: candidates[idx].category,\n confidence: candidates[idx].confidence,\n })),\n );\n\n try {\n const llmResponse = await callJudgeLlm(request, config, localLlm, fallbackLlm);\n\n if (llmResponse) {\n const parsed = parseJudgeResponse(llmResponse, batchIndices);\n // Per-call defer-increment dedupe (codex P2): a single extraction\n // pass must not advance the cap more than once for identical\n // candidate content, even if the same text appears several times in\n // one LLM response or in different batches of one call. Duplicate\n // hits share the first sighting's `priorDeferrals` snapshot.\n for (const [idx, rawVerdict] of parsed.entries()) {\n const c = candidates[idx];\n const key = cacheKey(c.text, c.category);\n let verdict = rawVerdict;\n let source: JudgeVerdictObservation[\"source\"] = \"llm\";\n if (!priorDefersSeen.has(key)) priorDefersSeen.set(key, deferCountMap.get(key) ?? 0);\n const priorDefers = priorDefersSeen.get(key) ?? 0;\n\n // Defer cap (issue #562, PR 2). A candidate that has already been\n // deferred `deferCap` times is forcibly rejected so a pathological\n // LLM response cannot produce an infinite defer loop.\n if (getVerdictKind(verdict) === \"defer\") {\n if (priorDefers >= deferCap) {\n verdict = {\n durable: false,\n reason: `Defer cap reached (${deferCap} prior defers); rejecting`,\n kind: \"reject\",\n };\n source = \"llm-cap-rejected\";\n // Only clear + count the cap conversion once per batch for\n // this key — duplicates in the same response all resolve to\n // reject but should not inflate the cap-rejection counter.\n if (!deferredThisCall.has(key)) {\n deferCountMap.delete(key);\n deferredCappedToReject++;\n deferredThisCall.add(key);\n }\n } else if (!deferredThisCall.has(key)) {\n deferCountMap.set(key, priorDefers + 1);\n deferred++;\n deferredThisCall.add(key);\n // Bound the per-process defer-counter map.\n if (deferCountMap.size > DEFER_COUNT_MAX_SIZE) {\n const drop = Math.floor(deferCountMap.size / 2);\n let dropped = 0;\n for (const k of deferCountMap.keys()) {\n if (dropped >= drop) break;\n deferCountMap.delete(k);\n dropped++;\n }\n }\n }\n // else: duplicate defer for a key already counted this call —\n // no additional counter increment, verdict still marked defer.\n } else {\n // On accept/reject, clear any outstanding defer counter so a\n // future reappearance of the same text starts fresh.\n deferCountMap.delete(key);\n priorDefersSeen.set(key, 0);\n deferredThisCall.delete(key);\n }\n\n verdicts.set(idx, verdict);\n judged++;\n // Cache non-defer verdicts. Defer is intentionally NOT cached:\n // caching it would short-circuit the re-evaluation pass that is\n // the entire point of the defer verdict.\n if (getVerdictKind(verdict) !== \"defer\") {\n verdictCache.set(key, verdict);\n }\n emit(() => ({\n verdict,\n candidate: c,\n contentHash: key,\n source,\n priorDeferrals: priorDefers,\n elapsedMs: Date.now() - startMs,\n }));\n }\n // Evict oldest entries if cache exceeds max size\n enforceMaxCacheSize(verdictCache);\n }\n } catch (err) {\n // Fail-open: if the LLM call fails, approve all candidates in this batch\n log.warn(\n `extraction-judge: LLM call failed, approving batch (fail-open): ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n\n // Fill in any missing verdicts from this batch (fail-open: approve).\n // Clear defer counts so a transient outage doesn't leave stale state\n // that causes later defers to hit the cap early.\n for (const idx of batchIndices) {\n if (!verdicts.has(idx)) {\n const c = candidates[idx];\n const hash = cacheKey(c.text, c.category);\n // Capture the prior deferral count BEFORE clearing so the\n // telemetry event reflects the true state rather than always 0.\n const priorDefers = deferCountMap.get(hash) ?? 0;\n deferCountMap.delete(hash);\n priorDefersSeen.set(hash, 0);\n deferredThisCall.delete(hash);\n const v: JudgeVerdict = {\n durable: true,\n reason: \"Approved by default (judge unavailable or parse error)\",\n };\n verdicts.set(idx, v);\n emit(() => {\n return {\n verdict: v,\n candidate: c,\n contentHash: hash,\n source: \"fail-open\",\n priorDeferrals: priorDefers,\n elapsedMs: Date.now() - startMs,\n };\n });\n }\n }\n }\n\n return {\n verdicts,\n cached,\n judged,\n elapsed: Date.now() - startMs,\n deferred,\n deferredCappedToReject,\n };\n}\n\n// ---------------------------------------------------------------------------\n// LLM call helpers\n// ---------------------------------------------------------------------------\n\nasync function callJudgeLlm(\n request: JudgeRequest,\n config: PluginConfig,\n localLlm: LocalLlmClient | null,\n fallbackLlm: FallbackLlmClient | null,\n): Promise<string | null> {\n const { messages, maxTokens } = request;\n\n const modelOverride = config.extractionJudgeModel || undefined;\n\n // When modelSource is \"gateway\", skip localLlm and go directly to fallback\n // (the gateway-routed backend). This respects the operator's explicit\n // routing preference.\n const skipLocal = config.modelSource === \"gateway\";\n\n // Route judge-gated extractions through the SAME shared resolution as every\n // other background task (taskModelChain > gatewayAgentId in gateway mode), so\n // the judge never silently falls back to the persona/default chain when a\n // task chain is configured (gotcha #22, #39). Issue #1365 / PR #1425.\n const gatewayChain = gatewayTaskChainOptions(config);\n\n // Try local LLM first (unless modelSource says gateway)\n if (localLlm && !skipLocal) {\n try {\n const result = await (localLlm as any).chatCompletion(messages, {\n temperature: 0.1,\n maxTokens,\n // A verdict needs no reasoning: keep a thinking-capable model from spending the compact budget on it.\n disableThinking: true,\n responseFormat: { type: \"json_object\" },\n timeoutMs: config.extractionJudgeTimeoutMs,\n // The client applies timeoutMs per attempt and retries an abort once:\n // one deadline signal bounds the whole call to the configured time.\n signal: AbortSignal.timeout(config.extractionJudgeTimeoutMs),\n operation: \"extraction-judge\",\n ...(modelOverride ? { model: modelOverride } : {}),\n });\n if (result?.content) {\n return result.content;\n }\n } catch (err) {\n log.debug(\n `extraction-judge: local LLM failed, trying fallback: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n // Try fallback LLM\n if (fallbackLlm) {\n try {\n const result = await fallbackLlm.chatCompletion(\n messages as Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n {\n temperature: 0.1,\n maxTokens,\n reasoningHeadroomTokens: JUDGE_REASONING_HEADROOM_TOKENS,\n timeoutMs: config.extractionJudgeTimeoutMs,\n ...(modelOverride ? { model: modelOverride } : {}),\n ...gatewayChain,\n },\n );\n if (result?.content) {\n return result.content;\n }\n } catch (err) {\n log.debug(\n `extraction-judge: fallback LLM failed: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n return null;\n}\n\ninterface JudgeVerdictItem {\n index?: number;\n kind?: string;\n action?: string;\n durable?: boolean;\n reason?: string;\n}\n\n/** What a judge model may return: a bare array, or one object wrapping verdicts. */\ninterface JudgeEnvelope {\n verdicts?: JudgeVerdictItem[];\n index?: number;\n}\n\ntype ParsedJudgeJson = JudgeVerdictItem[] | JudgeEnvelope | null | undefined;\n\n/**\n * Normalise the object shapes a judge model returns to a verdict array.\n * Requested shape {\"verdicts\": [...]} (response_format json_object forces a\n * top-level object); a single verdict object counts as one verdict at its\n * index, never the whole batch; legacy: any array-valued key.\n */\nfunction unwrapJudgeEnvelope(parsed: ParsedJudgeJson): JudgeVerdictItem[] | null {\n if (!parsed || Array.isArray(parsed)) return null;\n if (Array.isArray(parsed.verdicts)) return parsed.verdicts;\n if (Number.isInteger(parsed.index)) return [parsed];\n for (const v of Object.values(parsed)) {\n if (Array.isArray(v)) return v;\n }\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Response parsing\n// ---------------------------------------------------------------------------\n\nfunction parseJudgeResponse(\n raw: string,\n expectedIndices: number[],\n): Map<number, JudgeVerdict> {\n const result = new Map<number, JudgeVerdict>();\n const expectedSet = new Set(expectedIndices);\n\n try {\n // Try direct parse first, then fall back to JSON extraction\n let parsed: ParsedJudgeJson;\n try {\n parsed = JSON.parse(raw);\n } catch {\n const candidates = extractJsonCandidates(raw);\n if (candidates.length > 0) {\n parsed = JSON.parse(candidates[0]);\n }\n }\n\n if (!Array.isArray(parsed)) {\n const unwrapped = unwrapJudgeEnvelope(parsed);\n if (unwrapped === null) {\n log.debug(\"extraction-judge: response is not an array, cannot parse\");\n return result;\n }\n parsed = unwrapped;\n }\n\n for (const item of parsed) {\n if (\n typeof item !== \"object\" ||\n item === null ||\n typeof (item as any).index !== \"number\"\n ) {\n continue;\n }\n const idx = (item as any).index as number;\n if (!expectedSet.has(idx)) continue;\n\n // Parse kind first — it's the primary signal in PR 2 and above.\n // Fall back to durable for pre-PR-2 model responses that only return\n // the boolean.\n let kind: JudgeVerdictKind | undefined;\n const rawKind = (item as any).kind;\n const rawAction = (item as any).action;\n if (rawKind === \"accept\" || rawKind === \"reject\" || rawKind === \"defer\") {\n kind = rawKind;\n } else if (\n rawAction === \"accept\" ||\n rawAction === \"reject\" ||\n rawAction === \"defer\"\n ) {\n // Tolerate `action` as an alias — MemReader uses that word in the\n // paper and models may echo it.\n kind = rawAction;\n }\n\n const hasDurable = typeof (item as any).durable === \"boolean\";\n const durableFromModel = hasDurable\n ? ((item as any).durable as boolean)\n : undefined;\n\n // Resolve the durable flag from kind when present; otherwise trust\n // the model's boolean; otherwise fail-open to durable=true.\n let durable: boolean;\n if (kind === \"accept\") {\n durable = true;\n } else if (kind === \"reject\" || kind === \"defer\") {\n durable = false;\n } else if (durableFromModel !== undefined) {\n durable = durableFromModel;\n } else {\n durable = true; // fail-open\n }\n\n const reason =\n typeof (item as any).reason === \"string\"\n ? ((item as any).reason as string).slice(0, 120)\n : \"No reason provided\";\n\n const verdict: JudgeVerdict = { durable, reason };\n if (kind !== undefined) verdict.kind = kind;\n result.set(idx, verdict);\n }\n } catch (err) {\n log.debug(\n `extraction-judge: failed to parse response: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// Cache management (exposed for testing)\n// ---------------------------------------------------------------------------\n\n/** Clear the in-memory default verdict cache. Primarily for tests. */\nexport function clearVerdictCache(): void {\n defaultVerdictCache.clear();\n defaultDeferCounts.clear();\n}\n\n/** Return the current default verdict cache size. Primarily for tests. */\nexport function verdictCacheSize(): number {\n return defaultVerdictCache.size;\n}\n\n/** Create a new per-instance verdict cache. Orchestrators should hold one. */\nexport function createVerdictCache(): Map<string, JudgeVerdict> {\n return new Map();\n}\n\n/**\n * Create a new per-instance defer-counter map. Orchestrators should hold one\n * alongside their verdict cache so defer counts survive across extraction\n * passes within a single orchestrator but do not leak across orchestrators.\n */\nexport function createDeferCountMap(): Map<string, number> {\n return new Map();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,SAAS,kBAAkB;AAyEpB,SAAS,eAAe,SAAyC;AACtE,QAAM,MAAM,QAAQ;AACpB,MAAI,QAAQ,YAAY,QAAQ,YAAY,QAAQ,SAAS;AAC3D,WAAO;AAAA,EACT;AACA,SAAO,QAAQ,UAAU,WAAW;AACtC;AAOO,SAAS,iBAAiB,SAAgC;AAC/D,SAAO,eAAe,OAAO,MAAM;AACrC;AAgBO,SAAS,qBAAqB,OAAuC;AAC1E,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,QAAM,IAAI;AACV,MAAI,OAAO,EAAE,YAAY,UAAW,QAAO;AAC3C,MAAI,OAAO,EAAE,WAAW,SAAU,QAAO;AACzC,MAAI,EAAE,SAAS,QAAW;AACxB,QAAI,EAAE,SAAS,YAAY,EAAE,SAAS,YAAY,EAAE,SAAS,SAAS;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAWO,SAAS,uBAAuB,OAAqC;AAC1E,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,QAAM,IAAI;AACV,MAAI,OAAO,EAAE,YAAY,UAAW,QAAO;AAC3C,MAAI,OAAO,EAAE,WAAW,SAAU,QAAO;AACzC,MAAI;AACJ,MAAI,EAAE,SAAS,QAAW;AACxB,QAAI,OAAO,EAAE,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AA,IACjG;AAAA,EACF;AAEA,SAAO;AACT;AAOO,SAAS,oBAA0B;AACxC,sBAAoB,MAAM;AAC1B,qBAAmB,MAAM;AAC3B;AAGO,SAAS,mBAA2B;AACzC,SAAO,oBAAoB;AAC7B;AAGO,SAAS,qBAAgD;AAC9D,SAAO,oBAAI,IAAI;AACjB;AAOO,SAAS,sBAA2C;AACzD,SAAO,oBAAI,IAAI;AACjB;","names":[]}
@@ -12,7 +12,7 @@ import {
12
12
  loadSyncState,
13
13
  syncWearableSource,
14
14
  wearableSourceLabel
15
- } from "./chunk-OELN4JIO.js";
15
+ } from "./chunk-A3HLZMHD.js";
16
16
  import {
17
17
  runGraphEdgeDecayMaintenanceAcrossNamespaces
18
18
  } from "./chunk-GOZXQNIM.js";
@@ -302,7 +302,7 @@ import {
302
302
  buildResumeBundleFromState,
303
303
  getResumeBundleStatus,
304
304
  recordResumeBundle
305
- } from "./chunk-WGNAJEDV.js";
305
+ } from "./chunk-NU5JRN3A.js";
306
306
  import {
307
307
  getWorkProductLedgerStatus,
308
308
  recordWorkProductLedgerEntry,
@@ -473,7 +473,7 @@ import {
473
473
  runOperatorRepair,
474
474
  runOperatorSetup,
475
475
  summarizeNamespaceMaintenanceHealth
476
- } from "./chunk-DCEJRGAT.js";
476
+ } from "./chunk-N2PXVLV3.js";
477
477
  import {
478
478
  NamespaceCatalog,
479
479
  isNamespaceKind,
@@ -624,7 +624,7 @@ import {
624
624
  getVerdictKind,
625
625
  judgeFactDurability,
626
626
  validateProcedureExtraction
627
- } from "./chunk-KUCMDUEZ.js";
627
+ } from "./chunk-DYZDFOBX.js";
628
628
  import {
629
629
  REDACTION_RULES_SUBDIR,
630
630
  contentMatchesRedactionRules,
@@ -957,7 +957,7 @@ import {
957
957
  validateCorrectionAction,
958
958
  validateCorrectionRequest,
959
959
  validateRedactionPattern
960
- } from "./chunk-4NVYPWMJ.js";
960
+ } from "./chunk-QSVWIKNY.js";
961
961
  import {
962
962
  compileCorrectionRule,
963
963
  correctionsFilePath,
@@ -4863,7 +4863,7 @@ var TierMigrationCoordinator = class {
4863
4863
  };
4864
4864
 
4865
4865
  // src/orchestration/extraction-queue-coordinator.ts
4866
- var ExtractionQueueCoordinator = class {
4866
+ var ExtractionQueueCoordinator = class _ExtractionQueueCoordinator {
4867
4867
  /** Maximum tasks that run at the same time (config `extractionQueueConcurrency`). */
4868
4868
  concurrency;
4869
4869
  /**
@@ -4886,6 +4886,15 @@ var ExtractionQueueCoordinator = class {
4886
4886
  /** Preempt slots of the currently running tasks, keyed by slot identity. */
4887
4887
  preemptSlots = /* @__PURE__ */ new Map();
4888
4888
  preemptSeq = 0;
4889
+ /** Running tasks per lane — the backlog share and the foreground floor. */
4890
+ activeBacklog = 0;
4891
+ activeForeground = 0;
4892
+ /**
4893
+ * Slots kept available for foreground (non-backlog) tasks while backlog
4894
+ * work also waits. A floor of one keeps live sessions extracting even at
4895
+ * full backlog pressure; backlog tasks fill the rest.
4896
+ */
4897
+ static FOREGROUND_FLOOR = 1;
4889
4898
  /** Resolves the processor's park while a new task arrives mid-drain. */
4890
4899
  wake;
4891
4900
  constructor(concurrency = 2) {
@@ -4912,7 +4921,7 @@ var ExtractionQueueCoordinator = class {
4912
4921
  enqueue(task, options) {
4913
4922
  if (!this.accepting) return false;
4914
4923
  const key = options?.key;
4915
- const entry = { run: task, key };
4924
+ const entry = { run: task, key, backlog: options?.backlog, front: options?.front };
4916
4925
  if (options?.front) {
4917
4926
  this.preemptRunning(options.key);
4918
4927
  this.queue.unshift(entry);
@@ -4968,7 +4977,8 @@ var ExtractionQueueCoordinator = class {
4968
4977
  const armed = Array.from(this.preemptSlots.values()).filter((slot) => slot.armed !== void 0);
4969
4978
  if (armed.length === 0) return;
4970
4979
  const preferred = preferredKey !== void 0 ? armed.find((slot) => slot.key === preferredKey) : void 0;
4971
- const chosen = preferred ?? armed.reduce((a, b) => (b.armed?.seq ?? -1) > (a.armed?.seq ?? -1) ? b : a);
4980
+ const victims = armed.some((slot) => slot.backlog !== true) ? armed.filter((slot) => slot.backlog !== true) : armed;
4981
+ const chosen = preferred ?? victims.reduce((a, b) => (b.armed?.seq ?? -1) > (a.armed?.seq ?? -1) ? b : a);
4972
4982
  const abort = chosen.armed?.abort;
4973
4983
  chosen.armed = void 0;
4974
4984
  abort?.();
@@ -5053,11 +5063,30 @@ var ExtractionQueueCoordinator = class {
5053
5063
  }
5054
5064
  /** Take the next queue entry whose key is not already running or reserved (FIFO within a key). */
5055
5065
  takeRunnable() {
5066
+ if (this.queue[0]?.front === true) {
5067
+ const front = this.takeFirstMatching((entry) => entry.front === true);
5068
+ if (front) return front;
5069
+ }
5070
+ if (this.activeForeground < _ExtractionQueueCoordinator.FOREGROUND_FLOOR) {
5071
+ const foreground = this.takeFirstMatching((entry) => entry.backlog !== true);
5072
+ if (foreground) return foreground;
5073
+ }
5074
+ if (this.activeBacklog < Math.max(this.concurrency - 1, 1)) {
5075
+ const backlog = this.takeFirstMatching((entry) => entry.backlog === true);
5076
+ if (backlog) return backlog;
5077
+ }
5078
+ return this.takeFirstMatching((entry) => entry.backlog !== true);
5079
+ }
5080
+ /** First queue entry satisfying `match` whose key is free to run. */
5081
+ takeFirstMatching(match) {
5056
5082
  for (let index = 0; index < this.queue.length; index += 1) {
5057
5083
  const entry = this.queue[index];
5084
+ if (!match(entry)) continue;
5058
5085
  if (entry.key !== void 0 && (this.activeKeys.has(entry.key) || this.reservedKeys.has(entry.key))) continue;
5059
5086
  this.queue.splice(index, 1);
5060
5087
  if (entry.key !== void 0) this.activeKeys.add(entry.key);
5088
+ if (entry.backlog === true) this.activeBacklog += 1;
5089
+ else this.activeForeground += 1;
5061
5090
  return entry;
5062
5091
  }
5063
5092
  return void 0;
@@ -5065,13 +5094,15 @@ var ExtractionQueueCoordinator = class {
5065
5094
  /** Run one entry with its own preempt slot; failures are classified + logged. */
5066
5095
  async runEntry(entry) {
5067
5096
  const slot = {};
5068
- this.preemptSlots.set(slot, { key: entry.key });
5097
+ this.preemptSlots.set(slot, { key: entry.key, backlog: entry.backlog });
5069
5098
  try {
5070
5099
  await entry.run(this.createPreemptHandle(slot));
5071
5100
  } catch (err) {
5072
5101
  this.logExtractionQueueFailure(err, "task");
5073
5102
  } finally {
5074
5103
  this.preemptSlots.delete(slot);
5104
+ if (entry.backlog === true) this.activeBacklog -= 1;
5105
+ else this.activeForeground -= 1;
5075
5106
  if (entry.key !== void 0) this.activeKeys.delete(entry.key);
5076
5107
  }
5077
5108
  }
@@ -22113,7 +22144,13 @@ var TurnIngestionCoordinator = class {
22113
22144
  if (sharingNode) this.snapshotSharing.release(sharingNode);
22114
22145
  exit.report();
22115
22146
  }
22116
- }, { front: options.preemptRunning === true, key: bufferKey });
22147
+ }, {
22148
+ front: options.preemptRunning === true,
22149
+ key: bufferKey,
22150
+ // Claim/drain tasks (options.execution carries the claim-backed buffer)
22151
+ // take the backlog lane: biased to fill all-but-foreground-floor slots.
22152
+ backlog: options.execution !== void 0
22153
+ });
22117
22154
  if (!accepted) {
22118
22155
  if (sharingNode) this.snapshotSharing.release(sharingNode);
22119
22156
  settleTask(new Error("extraction queue is stopped"));
@@ -23813,7 +23850,7 @@ var OrchestratorInitCoordinator = class {
23813
23850
  if (signal.aborted || !this.isCurrentStartupEpoch(epoch)) return;
23814
23851
  if (!this.deps.wearablesAutoSyncHandle && this.deps.config.wearables.enabled && this.deps.config.wearables.autoSyncEnabled && Object.values(this.deps.config.wearables.sources).some((source) => source.enabled)) {
23815
23852
  try {
23816
- const { startWearablesAutoSync } = await import("./auto-sync-24ATHF7G.js");
23853
+ const { startWearablesAutoSync } = await import("./auto-sync-OOEY2FSA.js");
23817
23854
  if (signal.aborted || !this.isCurrentStartupEpoch(epoch)) return;
23818
23855
  this.deps.wearablesAutoSyncHandle = startWearablesAutoSync(
23819
23856
  {
@@ -68044,4 +68081,4 @@ export {
68044
68081
  EngramAccessService,
68045
68082
  AccessAdminOpsSurface
68046
68083
  };
68047
- //# sourceMappingURL=chunk-YTBBH5YH.js.map
68084
+ //# sourceMappingURL=chunk-LALPM2DN.js.map