@remnic/core 10.0.187 → 10.0.189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-admin-ops-surface.js +39 -39
- package/dist/access-cli.js +39 -39
- package/dist/access-extraction-force-flush-preempt.js +39 -39
- package/dist/access-extraction-force-flush.d.ts.map +1 -1
- package/dist/access-extraction-force-flush.js +39 -39
- package/dist/access-http-briefing.js +39 -39
- package/dist/access-http-query.js +39 -39
- package/dist/access-http.js +39 -39
- package/dist/access-identity-continuity-surface.js +39 -39
- package/dist/access-lcm-surface.js +39 -39
- package/dist/access-mcp.js +39 -39
- package/dist/access-observe-helpers.d.ts +1 -4
- package/dist/access-observe-helpers.d.ts.map +1 -1
- package/dist/access-observe-helpers.js +1 -1
- package/dist/access-observe-write-surface.d.ts +0 -4
- package/dist/access-observe-write-surface.d.ts.map +1 -1
- package/dist/access-observe-write-surface.js +39 -39
- package/dist/access-operations-batch.js +39 -39
- package/dist/access-operations.js +39 -39
- package/dist/access-recall-concurrency.js +39 -39
- package/dist/access-recall-response.js +39 -39
- package/dist/access-recall-surface.js +39 -39
- package/dist/access-service.d.ts +0 -2
- package/dist/access-service.d.ts.map +1 -1
- package/dist/access-service.js +39 -39
- package/dist/active-recall.js +1 -1
- package/dist/briefing.js +2 -2
- package/dist/buffer-add-turns-bounded.js +2 -2
- package/dist/buffer-admission-idempotency.d.ts.map +1 -1
- package/dist/buffer-admission-idempotency.js +1 -1
- package/dist/buffer-persistence.d.ts +14 -0
- package/dist/buffer-persistence.d.ts.map +1 -1
- package/dist/buffer-persistence.js +3 -1
- package/dist/buffer.js +4 -4
- package/dist/calibration.js +3 -3
- package/dist/causal-consolidation.js +3 -3
- package/dist/{chunk-2ZS7CB5H.js → chunk-2I3ETW3G.js} +2 -2
- package/dist/{chunk-PSUSA5SM.js → chunk-2VNMSEZR.js} +2 -2
- package/dist/{chunk-LANV6I63.js → chunk-56BNHKZM.js} +7 -7
- package/dist/{chunk-3FEQNKMB.js → chunk-5WDUY2ZZ.js} +2 -2
- package/dist/{chunk-BANMPRSC.js → chunk-65DWWJKI.js} +2 -2
- package/dist/{chunk-O5ZCDK32.js → chunk-6AMFGXG2.js} +39 -11
- package/dist/chunk-6AMFGXG2.js.map +1 -0
- package/dist/{chunk-VZBKCRU7.js → chunk-6MDHK6NO.js} +2 -2
- package/dist/{chunk-2RAVHJCD.js → chunk-6OHCNTKU.js} +2 -2
- package/dist/{chunk-P5FF44G3.js → chunk-7X6EZ2QB.js} +4 -4
- package/dist/{chunk-K5RGHUX7.js → chunk-A32EBVCZ.js} +2 -2
- package/dist/{chunk-L2DYRQQH.js → chunk-ABPOW3SX.js} +73 -103
- package/dist/chunk-ABPOW3SX.js.map +1 -0
- package/dist/{chunk-KVM3BS5K.js → chunk-ATPY63F5.js} +2 -2
- package/dist/chunk-B256MMS7.js +205 -0
- package/dist/chunk-B256MMS7.js.map +1 -0
- package/dist/{chunk-MOWLANEJ.js → chunk-C6Y2YHJL.js} +2 -2
- package/dist/{chunk-IMT7NTFV.js → chunk-CIAQK2OU.js} +6 -1
- package/dist/{chunk-IMT7NTFV.js.map → chunk-CIAQK2OU.js.map} +1 -1
- package/dist/{chunk-AJVCM2E3.js → chunk-CYX7JI4O.js} +2 -2
- package/dist/{chunk-76KL37ON.js → chunk-D3FP4JQI.js} +2 -2
- package/dist/{chunk-TQXKUQFX.js → chunk-FZU62GIV.js} +7 -6
- package/dist/chunk-FZU62GIV.js.map +1 -0
- package/dist/{chunk-YDGQYG4L.js → chunk-H442UKDV.js} +8 -8
- package/dist/{chunk-FXDQO7VX.js → chunk-HL53XYHC.js} +3 -3
- package/dist/{chunk-4VFEN3WT.js → chunk-IMSLPQJB.js} +2 -2
- package/dist/{chunk-FKLSIQBF.js → chunk-K3JGILZC.js} +3 -3
- package/dist/{chunk-JRHOL6B5.js → chunk-K6BS5RB4.js} +2 -2
- package/dist/{chunk-HHCLV572.js → chunk-KVTUUU7H.js} +2 -2
- package/dist/{chunk-TRFSTCQK.js → chunk-LL6WEMTC.js} +34 -6
- package/dist/chunk-LL6WEMTC.js.map +1 -0
- package/dist/{chunk-2WITFW6F.js → chunk-NKHRIDYP.js} +2 -2
- package/dist/{chunk-KYZMCH4I.js → chunk-NN3LMWKA.js} +12 -4
- package/dist/chunk-NN3LMWKA.js.map +1 -0
- package/dist/{chunk-CYTTY4M2.js → chunk-OPXK5IQU.js} +47 -47
- package/dist/chunk-OPXK5IQU.js.map +1 -0
- package/dist/{chunk-CTWWMEGR.js → chunk-PCGBESAN.js} +2 -2
- package/dist/{chunk-MDXZIU5X.js → chunk-QGT5KNQT.js} +2 -2
- package/dist/{chunk-YJZDRM33.js → chunk-QXHWOUS6.js} +3 -3
- package/dist/{chunk-OVJAQWHO.js → chunk-RPOG6HLI.js} +2 -2
- package/dist/{chunk-2QQCCUXF.js → chunk-RVODERA5.js} +2 -2
- package/dist/{chunk-FQE5QN5Q.js → chunk-TAPF7T26.js} +2 -2
- package/dist/{chunk-7UTCETGK.js → chunk-TQODBIMW.js} +2 -2
- package/dist/{chunk-KZJEKKK6.js → chunk-VQQZJ6KJ.js} +3 -3
- package/dist/{chunk-I233SAGS.js → chunk-X3ERYOLO.js} +2 -2
- package/dist/{chunk-UCCXPMTP.js → chunk-XQF2KLV5.js} +2 -2
- package/dist/{chunk-LPYGM6RE.js → chunk-XWPYK5T4.js} +2 -2
- package/dist/{chunk-7EPEZYX3.js → chunk-YVXR7CPS.js} +2 -2
- package/dist/cli.js +39 -39
- package/dist/coding/export-okf-codegraph.js +1 -1
- package/dist/compounding/engine.js +3 -3
- package/dist/config.js +1 -1
- package/dist/connectors/codex-materialize-runner.js +2 -2
- package/dist/connectors/index.js +2 -2
- package/dist/convergence-refresh.js +4 -4
- package/dist/corpus-watermark.js +4 -4
- package/dist/entity-retrieval.js +2 -2
- package/dist/explicit-capture.js +39 -39
- package/dist/extraction.js +6 -6
- package/dist/harmonic-retrieval.js +2 -2
- package/dist/index.js +39 -39
- package/dist/local-llm-helpers.d.ts.map +1 -1
- package/dist/local-llm-helpers.js +2 -2
- package/dist/local-llm-transport.d.ts +82 -9
- package/dist/local-llm-transport.d.ts.map +1 -1
- package/dist/local-llm-transport.js +11 -3
- package/dist/local-llm.d.ts.map +1 -1
- package/dist/local-llm.js +3 -3
- package/dist/location/index.js +3 -3
- package/dist/maintenance/memory-governance.js +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +2 -2
- package/dist/maintenance/rebuild-memory-projection-runner.js +4 -4
- package/dist/maintenance/rebuild-memory-projection.js +3 -3
- package/dist/namespaces/migrate.js +3 -3
- package/dist/namespaces/storage.js +2 -2
- package/dist/operator-doctor-corpus.js +5 -5
- package/dist/operator-toolkit.js +8 -8
- package/dist/orchestration/backlog-scheduler.js +40 -40
- package/dist/orchestration/buffer-drain-runner.js +40 -40
- package/dist/orchestration/extraction-queue-coordinator.d.ts +14 -1
- package/dist/orchestration/extraction-queue-coordinator.d.ts.map +1 -1
- package/dist/orchestration/maintenance.js +13 -13
- package/dist/orchestrator.js +39 -39
- package/dist/recall-navigation.js +39 -39
- package/dist/resume-bundles.js +1 -1
- package/dist/semantic-consolidation.js +3 -3
- package/dist/semantic-rule-promotion.js +2 -2
- package/dist/semantic-rule-verifier.js +2 -2
- package/dist/source-agent-qualifier.js +2 -2
- package/dist/standup/build.js +2 -2
- package/dist/storage/entity-canonical-id-migration-runner.d.ts.map +1 -1
- package/dist/storage.js +1 -1
- package/dist/summarizer.js +4 -4
- package/dist/support-passport/index.js +4 -4
- package/dist/transfer/export-okf.js +2 -2
- package/dist/verified-recall.js +2 -2
- package/dist/who-knows-cli.js +3 -3
- package/dist/who-knows.js +2 -2
- package/package.json +2 -2
- package/src/access-extraction-force-flush-preempt-coordinator.test.ts +71 -0
- package/src/access-extraction-force-flush.ts +20 -56
- package/src/access-observe-helpers.test.ts +71 -88
- package/src/access-observe-helpers.ts +60 -73
- package/src/access-observe-write-surface.ts +1 -22
- package/src/access-service-observe-lcm-parity.test.ts +176 -89
- package/src/access-service-observe-scope.test.ts +18 -86
- package/src/access-service.ts +0 -13
- package/src/buffer-admission-idempotency.test.ts +115 -0
- package/src/buffer-admission-idempotency.ts +67 -11
- package/src/buffer-persistence.ts +46 -5
- package/src/local-llm-headers-timeout.test.ts +246 -16
- package/src/local-llm-helpers.ts +14 -4
- package/src/local-llm-transport.ts +253 -16
- package/src/local-llm.ts +7 -8
- package/src/orchestration/extraction-queue-coordinator.ts +34 -3
- package/src/storage/entity-canonical-id-migration-runner.test.ts +90 -0
- package/src/storage/entity-canonical-id-migration-runner.ts +10 -0
- package/dist/chunk-5YQXWVCP.js +0 -74
- package/dist/chunk-5YQXWVCP.js.map +0 -1
- package/dist/chunk-CYTTY4M2.js.map +0 -1
- package/dist/chunk-KYZMCH4I.js.map +0 -1
- package/dist/chunk-L2DYRQQH.js.map +0 -1
- package/dist/chunk-O5ZCDK32.js.map +0 -1
- package/dist/chunk-TQXKUQFX.js.map +0 -1
- package/dist/chunk-TRFSTCQK.js.map +0 -1
- /package/dist/{chunk-2ZS7CB5H.js.map → chunk-2I3ETW3G.js.map} +0 -0
- /package/dist/{chunk-PSUSA5SM.js.map → chunk-2VNMSEZR.js.map} +0 -0
- /package/dist/{chunk-LANV6I63.js.map → chunk-56BNHKZM.js.map} +0 -0
- /package/dist/{chunk-3FEQNKMB.js.map → chunk-5WDUY2ZZ.js.map} +0 -0
- /package/dist/{chunk-BANMPRSC.js.map → chunk-65DWWJKI.js.map} +0 -0
- /package/dist/{chunk-VZBKCRU7.js.map → chunk-6MDHK6NO.js.map} +0 -0
- /package/dist/{chunk-2RAVHJCD.js.map → chunk-6OHCNTKU.js.map} +0 -0
- /package/dist/{chunk-P5FF44G3.js.map → chunk-7X6EZ2QB.js.map} +0 -0
- /package/dist/{chunk-K5RGHUX7.js.map → chunk-A32EBVCZ.js.map} +0 -0
- /package/dist/{chunk-KVM3BS5K.js.map → chunk-ATPY63F5.js.map} +0 -0
- /package/dist/{chunk-MOWLANEJ.js.map → chunk-C6Y2YHJL.js.map} +0 -0
- /package/dist/{chunk-AJVCM2E3.js.map → chunk-CYX7JI4O.js.map} +0 -0
- /package/dist/{chunk-76KL37ON.js.map → chunk-D3FP4JQI.js.map} +0 -0
- /package/dist/{chunk-YDGQYG4L.js.map → chunk-H442UKDV.js.map} +0 -0
- /package/dist/{chunk-FXDQO7VX.js.map → chunk-HL53XYHC.js.map} +0 -0
- /package/dist/{chunk-4VFEN3WT.js.map → chunk-IMSLPQJB.js.map} +0 -0
- /package/dist/{chunk-FKLSIQBF.js.map → chunk-K3JGILZC.js.map} +0 -0
- /package/dist/{chunk-JRHOL6B5.js.map → chunk-K6BS5RB4.js.map} +0 -0
- /package/dist/{chunk-HHCLV572.js.map → chunk-KVTUUU7H.js.map} +0 -0
- /package/dist/{chunk-2WITFW6F.js.map → chunk-NKHRIDYP.js.map} +0 -0
- /package/dist/{chunk-CTWWMEGR.js.map → chunk-PCGBESAN.js.map} +0 -0
- /package/dist/{chunk-MDXZIU5X.js.map → chunk-QGT5KNQT.js.map} +0 -0
- /package/dist/{chunk-YJZDRM33.js.map → chunk-QXHWOUS6.js.map} +0 -0
- /package/dist/{chunk-OVJAQWHO.js.map → chunk-RPOG6HLI.js.map} +0 -0
- /package/dist/{chunk-2QQCCUXF.js.map → chunk-RVODERA5.js.map} +0 -0
- /package/dist/{chunk-FQE5QN5Q.js.map → chunk-TAPF7T26.js.map} +0 -0
- /package/dist/{chunk-7UTCETGK.js.map → chunk-TQODBIMW.js.map} +0 -0
- /package/dist/{chunk-KZJEKKK6.js.map → chunk-VQQZJ6KJ.js.map} +0 -0
- /package/dist/{chunk-I233SAGS.js.map → chunk-X3ERYOLO.js.map} +0 -0
- /package/dist/{chunk-UCCXPMTP.js.map → chunk-XQF2KLV5.js.map} +0 -0
- /package/dist/{chunk-LPYGM6RE.js.map → chunk-XWPYK5T4.js.map} +0 -0
- /package/dist/{chunk-7EPEZYX3.js.map → chunk-YVXR7CPS.js.map} +0 -0
package/dist/who-knows.js
CHANGED
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
loadWhoKnowsEntities,
|
|
10
10
|
tokenizeTopic,
|
|
11
11
|
validateWhoKnowsInput
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-YVXR7CPS.js";
|
|
13
|
+
import "./chunk-CIAQK2OU.js";
|
|
14
14
|
import "./chunk-QGVCFVX6.js";
|
|
15
15
|
import "./chunk-UHVXE24Y.js";
|
|
16
16
|
import "./chunk-BL7WULM5.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remnic/core",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.189",
|
|
4
4
|
"description": "Framework-agnostic Remnic memory engine — orchestrator, storage, extraction, search, trust zones",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -3416,7 +3416,7 @@
|
|
|
3416
3416
|
"core"
|
|
3417
3417
|
],
|
|
3418
3418
|
"peerDependencies": {
|
|
3419
|
-
"@remnic/coding-graph": "^10.0.
|
|
3419
|
+
"@remnic/coding-graph": "^10.0.189"
|
|
3420
3420
|
},
|
|
3421
3421
|
"peerDependenciesMeta": {
|
|
3422
3422
|
"@remnic/coding-graph": {
|
|
@@ -58,3 +58,74 @@ test("preemptRunning keeps the newest-slot fallback for keyless calls", () => {
|
|
|
58
58
|
assert.deepEqual(first.aborted, []);
|
|
59
59
|
assert.deepEqual(second.aborted, ["sess-b"]);
|
|
60
60
|
});
|
|
61
|
+
|
|
62
|
+
test("preemptKeyed latches a key: the retried generation is not re-preempted", () => {
|
|
63
|
+
const coordinator = new ExtractionQueueCoordinator();
|
|
64
|
+
const first: Capture = { key: "sess-a", aborted: [] };
|
|
65
|
+
captureSlot(coordinator, first, "sess-a");
|
|
66
|
+
coordinator.preemptKeyed("sess-a");
|
|
67
|
+
assert.deepEqual(first.aborted, ["sess-a"]);
|
|
68
|
+
|
|
69
|
+
// The retry arms a fresh slot; a second flush must let it finish (COS-825
|
|
70
|
+
// preemption livelock: repeated flushes killed every retried generation).
|
|
71
|
+
const retried: Capture = { key: "sess-a", aborted: [] };
|
|
72
|
+
captureSlot(coordinator, retried, "sess-a");
|
|
73
|
+
coordinator.preemptKeyed("sess-a");
|
|
74
|
+
assert.deepEqual(retried.aborted, [], "a key already preempted once must not be preempted again");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("a successful task for the key clears the latch and restores flush priority", async () => {
|
|
78
|
+
const coordinator = new ExtractionQueueCoordinator();
|
|
79
|
+
const first: Capture = { key: "sess-a", aborted: [] };
|
|
80
|
+
captureSlot(coordinator, first, "sess-a");
|
|
81
|
+
coordinator.preemptKeyed("sess-a");
|
|
82
|
+
assert.deepEqual(first.aborted, ["sess-a"]);
|
|
83
|
+
|
|
84
|
+
const { promise: gate, resolve: release } = Promise.withResolvers<void>();
|
|
85
|
+
coordinator.enqueue(() => gate, { key: "sess-a" });
|
|
86
|
+
release();
|
|
87
|
+
assert.equal(await coordinator.waitForIdle(2000), true);
|
|
88
|
+
|
|
89
|
+
const next: Capture = { key: "sess-a", aborted: [] };
|
|
90
|
+
captureSlot(coordinator, next, "sess-a");
|
|
91
|
+
coordinator.preemptKeyed("sess-a");
|
|
92
|
+
assert.deepEqual(next.aborted, ["sess-a"], "a completed episode resets priority");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("preemptRunning skips a latched same-key victim but still steals an unrelated slot", () => {
|
|
96
|
+
const coordinator = new ExtractionQueueCoordinator();
|
|
97
|
+
const first: Capture = { key: "sess-a", aborted: [] };
|
|
98
|
+
captureSlot(coordinator, first, "sess-a");
|
|
99
|
+
coordinator.preemptKeyed("sess-a");
|
|
100
|
+
assert.deepEqual(first.aborted, ["sess-a"]);
|
|
101
|
+
|
|
102
|
+
const retried: Capture = { key: "sess-a", aborted: [] };
|
|
103
|
+
const other: Capture = { key: "sess-b", aborted: [] };
|
|
104
|
+
captureSlot(coordinator, retried, "sess-a");
|
|
105
|
+
captureSlot(coordinator, other, "sess-b");
|
|
106
|
+
coordinator.preemptRunning("sess-a");
|
|
107
|
+
assert.deepEqual(retried.aborted, [], "latched same-key slot must survive the flush's slot steal");
|
|
108
|
+
assert.deepEqual(other.aborted, ["sess-b"], "unrelated slot steal keeps flush priority");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("keyless preemptRunning latches the victim's key too", () => {
|
|
112
|
+
const coordinator = new ExtractionQueueCoordinator();
|
|
113
|
+
const victim: Capture = { key: "sess-a", aborted: [] };
|
|
114
|
+
captureSlot(coordinator, victim, "sess-a");
|
|
115
|
+
coordinator.preemptRunning();
|
|
116
|
+
assert.deepEqual(victim.aborted, ["sess-a"]);
|
|
117
|
+
|
|
118
|
+
const retried: Capture = { key: "sess-a", aborted: [] };
|
|
119
|
+
captureSlot(coordinator, retried, "sess-a");
|
|
120
|
+
coordinator.preemptKeyed("sess-a");
|
|
121
|
+
assert.deepEqual(retried.aborted, []);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("preemptKeyed with no armed match does not latch the key", () => {
|
|
125
|
+
const coordinator = new ExtractionQueueCoordinator();
|
|
126
|
+
coordinator.preemptKeyed("sess-a");
|
|
127
|
+
const later: Capture = { key: "sess-a", aborted: [] };
|
|
128
|
+
captureSlot(coordinator, later, "sess-a");
|
|
129
|
+
coordinator.preemptKeyed("sess-a");
|
|
130
|
+
assert.deepEqual(later.aborted, ["sess-a"], "nothing was preempted, so priority is intact");
|
|
131
|
+
});
|
|
@@ -69,67 +69,32 @@ export async function extractionForceFlush(
|
|
|
69
69
|
committed = true;
|
|
70
70
|
request.onCommitted?.();
|
|
71
71
|
};
|
|
72
|
-
let abortHandler: (() => void) | undefined;
|
|
73
72
|
|
|
73
|
+
// COS-825: a force-flush caller going away (client abort or deadline) stops
|
|
74
|
+
// only the flush's OWN wait and drain. Extractions already queued by other
|
|
75
|
+
// observes are accepted work — they keep running and clear their own turns,
|
|
76
|
+
// so a disconnecting or timed-out flush caller can never stall the backlog.
|
|
74
77
|
const reservationScopeHint = pendingObserveScopeHint(request);
|
|
75
|
-
const cancelBeforeScopeResolution = (): void => {
|
|
76
|
-
const explicitNamespace = request.namespace?.trim();
|
|
77
|
-
if (explicitNamespace) {
|
|
78
|
-
deps.cancelPendingObserveExtractions?.(
|
|
79
|
-
request.sessionKey,
|
|
80
|
-
authenticatedPrincipal ?? sessionPrincipal,
|
|
81
|
-
explicitNamespace,
|
|
82
|
-
reservationScopeHint,
|
|
83
|
-
);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (reservationScopeHint !== undefined) {
|
|
87
|
-
deps.cancelPendingObservePreparations?.(request.sessionKey, reservationScopeHint);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
if (!namespacesEnabled) {
|
|
91
|
-
deps.cancelPendingObserveExtractions?.(request.sessionKey);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
78
|
|
|
95
79
|
try {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
onDeadline: cancelBeforeScopeResolution,
|
|
106
|
-
},
|
|
107
|
-
);
|
|
108
|
-
} catch (error) {
|
|
109
|
-
if (request.abortSignal?.aborted) cancelBeforeScopeResolution();
|
|
110
|
-
throw error;
|
|
111
|
-
}
|
|
112
|
-
const cancelScopedPendingObserveExtractions = (): void => {
|
|
113
|
-
deps.cancelPendingObserveExtractions?.(
|
|
114
|
-
request.sessionKey,
|
|
115
|
-
scope.principal,
|
|
116
|
-
scope.writeNamespace,
|
|
117
|
-
reservationScopeHint,
|
|
118
|
-
);
|
|
119
|
-
};
|
|
120
|
-
if (request.abortSignal?.aborted) cancelScopedPendingObserveExtractions();
|
|
80
|
+
const scope: MemoryScopePlan = await awaitSessionFlushPhase(
|
|
81
|
+
() => deps.resolveMemoryScopePlan(request),
|
|
82
|
+
{
|
|
83
|
+
abortSignal: request.abortSignal,
|
|
84
|
+
extractionDeadlineMs: deadlineAt,
|
|
85
|
+
reason: "access_force_flush",
|
|
86
|
+
deadlineStage: "scope_resolution",
|
|
87
|
+
},
|
|
88
|
+
);
|
|
121
89
|
throwIfAborted(request.abortSignal, "extraction force-flush aborted");
|
|
122
90
|
if (deadlineAt !== undefined && deadlineAt <= Date.now()) {
|
|
123
|
-
cancelScopedPendingObserveExtractions();
|
|
124
91
|
throw new EngramAccessInputError("extraction force-flush deadline exceeded before buffer drain");
|
|
125
92
|
}
|
|
126
|
-
abortHandler = cancelScopedPendingObserveExtractions;
|
|
127
|
-
request.abortSignal?.addEventListener("abort", abortHandler, { once: true });
|
|
128
93
|
// #3251: wait for in-flight observe extractions BEFORE draining —
|
|
129
94
|
// drain-first could queue the same accepted turns twice. Scoped key, so
|
|
130
95
|
// never waits on another scope.
|
|
131
96
|
if (waitForPendingObserveExtraction) {
|
|
132
|
-
let
|
|
97
|
+
let stopWaitingForPending: (() => void) | undefined;
|
|
133
98
|
await awaitSessionFlushPhase(
|
|
134
99
|
() =>
|
|
135
100
|
waitForPendingObserveExtraction(
|
|
@@ -137,8 +102,8 @@ export async function extractionForceFlush(
|
|
|
137
102
|
scope.principal,
|
|
138
103
|
scope.writeNamespace,
|
|
139
104
|
request.abortSignal,
|
|
140
|
-
(
|
|
141
|
-
|
|
105
|
+
(stop) => {
|
|
106
|
+
stopWaitingForPending = stop;
|
|
142
107
|
},
|
|
143
108
|
reservationScopeHint,
|
|
144
109
|
),
|
|
@@ -147,9 +112,9 @@ export async function extractionForceFlush(
|
|
|
147
112
|
extractionDeadlineMs: deadlineAt,
|
|
148
113
|
reason: "access_force_flush",
|
|
149
114
|
deadlineStage: "pending_observe_extraction",
|
|
115
|
+
// The flush budget stops the WAIT; the queued extractions continue.
|
|
150
116
|
onDeadline: () => {
|
|
151
|
-
|
|
152
|
-
cancelPendingObserveExtraction?.();
|
|
117
|
+
stopWaitingForPending?.();
|
|
153
118
|
},
|
|
154
119
|
}
|
|
155
120
|
);
|
|
@@ -175,9 +140,10 @@ export async function extractionForceFlush(
|
|
|
175
140
|
extractionDeadlineMs: deadlineAt,
|
|
176
141
|
reason: "access_force_flush",
|
|
177
142
|
deadlineStage: "buffer_drain",
|
|
143
|
+
// The flush budget aborts its OWN drain; queued observe extractions
|
|
144
|
+
// keep running (COS-825).
|
|
178
145
|
onDeadline: () => {
|
|
179
146
|
drainAbort.abort();
|
|
180
|
-
cancelScopedPendingObserveExtractions();
|
|
181
147
|
},
|
|
182
148
|
}
|
|
183
149
|
);
|
|
@@ -234,7 +200,5 @@ export async function extractionForceFlush(
|
|
|
234
200
|
throw new EngramAccessInputError(error.message);
|
|
235
201
|
}
|
|
236
202
|
throw error;
|
|
237
|
-
} finally {
|
|
238
|
-
if (abortHandler) request.abortSignal?.removeEventListener("abort", abortHandler);
|
|
239
203
|
}
|
|
240
204
|
}
|
|
@@ -2,18 +2,17 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
/**
|
|
5
|
-
* PendingObserveExtractionTracker settle hygiene
|
|
6
|
-
* callback only removed the pending entry when the extraction SUCCEEDED or
|
|
7
|
-
* was rejected with a preemption error. Any other rejection (a real
|
|
8
|
-
* extraction failure) left the entry — and its ever-growing `controllers`
|
|
9
|
-
* Set — in the map forever: the next observe for the key chained onto a
|
|
10
|
-
* dead promise and every later `cancel` walked stale controllers.
|
|
5
|
+
* PendingObserveExtractionTracker settle hygiene + COS-825 wait contract.
|
|
11
6
|
*
|
|
12
|
-
*
|
|
13
|
-
* it is still the current entry
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
7
|
+
* Settle hygiene: `track`'s settle callback removes the pending entry on ANY
|
|
8
|
+
* settle (fulfillment or rejection) while it is still the current entry, so
|
|
9
|
+
* a settled failure never wedges the key and overlapping stalled tracks stay
|
|
10
|
+
* bounded.
|
|
11
|
+
*
|
|
12
|
+
* COS-825 wait contract: `wait` observes its caller's abort signal and the
|
|
13
|
+
* registered cancellation ONLY to stop waiting. A dead force-flush caller
|
|
14
|
+
* must never cancel the tracked extractions — they were accepted by other
|
|
15
|
+
* observes and keep running.
|
|
17
16
|
*/
|
|
18
17
|
import test from "node:test";
|
|
19
18
|
|
|
@@ -26,10 +25,20 @@ function settle(): Promise<void> {
|
|
|
26
25
|
return promise;
|
|
27
26
|
}
|
|
28
27
|
|
|
28
|
+
function rejectable() {
|
|
29
|
+
const { promise, reject } = Promise.withResolvers<void>();
|
|
30
|
+
return { promise, reject };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function stalled(): Promise<void> {
|
|
34
|
+
const { promise } = Promise.withResolvers<void>();
|
|
35
|
+
return promise;
|
|
36
|
+
}
|
|
37
|
+
|
|
29
38
|
test("a settled non-preempted rejection clears the pending entry", async () => {
|
|
30
39
|
const tracker = new PendingObserveExtractionTracker();
|
|
31
40
|
const key = tracker.key("session-a", "alice", "default");
|
|
32
|
-
tracker.track(key, Promise.reject(new Error("extraction failed"))
|
|
41
|
+
tracker.track(key, Promise.reject(new Error("extraction failed")));
|
|
33
42
|
await settle();
|
|
34
43
|
|
|
35
44
|
// The entry is gone: the next wait finds nothing pending and returns
|
|
@@ -40,7 +49,7 @@ test("a settled non-preempted rejection clears the pending entry", async () => {
|
|
|
40
49
|
test("a settled success clears the pending entry for the next observe", async () => {
|
|
41
50
|
const tracker = new PendingObserveExtractionTracker();
|
|
42
51
|
const key = tracker.key("session-a", "alice", "default");
|
|
43
|
-
tracker.track(key, Promise.resolve()
|
|
52
|
+
tracker.track(key, Promise.resolve());
|
|
44
53
|
await settle();
|
|
45
54
|
await tracker.wait("session-a", "alice", "default");
|
|
46
55
|
});
|
|
@@ -48,8 +57,8 @@ test("a settled success clears the pending entry for the next observe", async ()
|
|
|
48
57
|
test("a chained non-preempted rejection clears the chained entry", async () => {
|
|
49
58
|
const tracker = new PendingObserveExtractionTracker();
|
|
50
59
|
const key = tracker.key("session-a", "alice", "default");
|
|
51
|
-
tracker.track(key, Promise.resolve()
|
|
52
|
-
tracker.track(key, Promise.reject(new Error("second failed"))
|
|
60
|
+
tracker.track(key, Promise.resolve());
|
|
61
|
+
tracker.track(key, Promise.reject(new Error("second failed")));
|
|
53
62
|
await settle();
|
|
54
63
|
await tracker.wait("session-a", "alice", "default");
|
|
55
64
|
});
|
|
@@ -57,7 +66,7 @@ test("a chained non-preempted rejection clears the chained entry", async () => {
|
|
|
57
66
|
test("a preempted rejection still clears the pending entry", async () => {
|
|
58
67
|
const tracker = new PendingObserveExtractionTracker();
|
|
59
68
|
const key = tracker.key("session-a", "alice", "default");
|
|
60
|
-
tracker.track(key, Promise.reject(preemptedExtractionError())
|
|
69
|
+
tracker.track(key, Promise.reject(preemptedExtractionError()));
|
|
61
70
|
await settle();
|
|
62
71
|
await tracker.wait("session-a", "alice", "default");
|
|
63
72
|
});
|
|
@@ -65,8 +74,8 @@ test("a preempted rejection still clears the pending entry", async () => {
|
|
|
65
74
|
test("a wait overlapping a failing extraction still surfaces the error", async () => {
|
|
66
75
|
const tracker = new PendingObserveExtractionTracker();
|
|
67
76
|
const key = tracker.key("session-a", "alice", "default");
|
|
68
|
-
const { promise: extraction, reject } =
|
|
69
|
-
tracker.track(key, extraction
|
|
77
|
+
const { promise: extraction, reject } = rejectable();
|
|
78
|
+
tracker.track(key, extraction);
|
|
70
79
|
const waiter = assert.rejects(() => tracker.wait("session-a", "alice", "default"), /extraction failed/);
|
|
71
80
|
await Promise.resolve();
|
|
72
81
|
reject(new Error("extraction failed"));
|
|
@@ -74,30 +83,14 @@ test("a wait overlapping a failing extraction still surfaces the error", async (
|
|
|
74
83
|
});
|
|
75
84
|
|
|
76
85
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* pre-fix vs 4.2MB with the shared per-key set). The fix reuses one Set per
|
|
82
|
-
* key; `abortTracked` iterates a snapshot so a reentrant `track` fired from
|
|
83
|
-
* an abort listener keeps prior semantics (not aborted by the in-flight
|
|
84
|
-
* pass, iteration terminates).
|
|
86
|
+
* Heap retention across overlapping stalled tracks (COS-825 follow-up of the
|
|
87
|
+
* controller-set fix): the tracker keeps ONE merged promise per key, and any
|
|
88
|
+
* settle deletes the entry, so retained heap stays flat. The child process
|
|
89
|
+
* with --expose-gc keeps CI free of gc hooks in the main tree.
|
|
85
90
|
*/
|
|
86
|
-
function stalled(): Promise<void> {
|
|
87
|
-
const { promise } = Promise.withResolvers<void>();
|
|
88
|
-
return promise;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function rejectingAfter(controller: AbortController): Promise<void> {
|
|
92
|
-
const { promise, reject } = Promise.withResolvers<void>();
|
|
93
|
-
controller.signal.addEventListener("abort", () => reject(controller.signal.reason), { once: true });
|
|
94
|
-
return promise;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
91
|
// Runs the retention loop in one short-lived child process with --expose-gc,
|
|
98
92
|
// so CI exercises it without exposing gc to the whole test tree. The
|
|
99
|
-
// assertion keeps a wide margin
|
|
100
|
-
// at the same track count), not a fixed runner heap limit.
|
|
93
|
+
// assertion keeps a wide margin, not a fixed runner heap limit.
|
|
101
94
|
function drain(stream: NodeJS.ReadableStream): Promise<string> {
|
|
102
95
|
return new Promise((resolve) => {
|
|
103
96
|
const chunks: string[] = [];
|
|
@@ -122,7 +115,7 @@ gc();
|
|
|
122
115
|
const before = process.memoryUsage().heapUsed;
|
|
123
116
|
const tracker = new PendingObserveExtractionTracker();
|
|
124
117
|
const key = tracker.key("session-a", "alice", "default");
|
|
125
|
-
for (let i = 0; i < 4000; i++) tracker.track(key, new Promise(() => {})
|
|
118
|
+
for (let i = 0; i < 4000; i++) tracker.track(key, new Promise(() => {}));
|
|
126
119
|
gc();
|
|
127
120
|
console.log(JSON.stringify(process.memoryUsage().heapUsed - before));`,
|
|
128
121
|
trackerSource,
|
|
@@ -144,65 +137,55 @@ test("retained heap stays bounded across overlapping stalled tracks", { timeout:
|
|
|
144
137
|
const retained = await retainedHeapInChild();
|
|
145
138
|
assert.ok(
|
|
146
139
|
retained < 32 * 1024 * 1024,
|
|
147
|
-
`retained ${(retained / 1048576).toFixed(1)}MB for 4000 tracks;
|
|
140
|
+
`retained ${(retained / 1048576).toFixed(1)}MB for 4000 tracks; per-key entries must not grow quadratically`,
|
|
148
141
|
);
|
|
149
142
|
});
|
|
150
143
|
|
|
151
|
-
test("
|
|
144
|
+
test("wait stops without cancelling tracked extractions when its abort signal fires", async () => {
|
|
152
145
|
const tracker = new PendingObserveExtractionTracker();
|
|
153
146
|
const key = tracker.key("session-a", "alice", "default");
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
147
|
+
const { promise: extraction, resolve } = Promise.withResolvers<void>();
|
|
148
|
+
tracker.track(key, extraction);
|
|
149
|
+
const abortController = new AbortController();
|
|
150
|
+
const waiter = tracker.wait("session-a", "alice", "default", abortController.signal);
|
|
151
|
+
await Promise.resolve();
|
|
152
|
+
abortController.abort();
|
|
153
|
+
// Returns promptly — it does NOT wait behind the still-running extraction,
|
|
154
|
+
// and it does not cancel or settle it (COS-825).
|
|
155
|
+
await waiter;
|
|
156
|
+
resolve();
|
|
157
|
+
await extraction;
|
|
158
|
+
await settle();
|
|
159
|
+
// The extraction settled cleanly and the entry cleared: no cancellation
|
|
160
|
+
// leaked into the accepted work.
|
|
161
|
+
await tracker.wait("session-a", "alice", "default");
|
|
162
162
|
});
|
|
163
163
|
|
|
164
|
-
test("
|
|
164
|
+
test("wait stops via the registered cancellation without cancelling tracked extractions", async () => {
|
|
165
165
|
const tracker = new PendingObserveExtractionTracker();
|
|
166
166
|
const key = tracker.key("session-a", "alice", "default");
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
tracker.cancel("session-a", "alice", "default");
|
|
178
|
-
assert.ok(first.signal.aborted);
|
|
179
|
-
assert.equal(reentrant.signal.aborted, false, "prior behavior: the in-flight abort pass must not abort later admissions");
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
test("each key aborts and cleans up in isolation", { timeout: 2000 }, async () => {
|
|
183
|
-
const tracker = new PendingObserveExtractionTracker();
|
|
184
|
-
const keyA = tracker.key("session-a", "alice", "default");
|
|
185
|
-
const keyB = tracker.key("session-b", "bob", "default");
|
|
186
|
-
const controllerA = new AbortController();
|
|
187
|
-
const controllerB = new AbortController();
|
|
188
|
-
tracker.track(keyA, rejectingAfter(controllerA), controllerA);
|
|
189
|
-
tracker.track(keyB, stalled(), controllerB);
|
|
190
|
-
tracker.cancel("session-a", "alice", "default");
|
|
191
|
-
assert.ok(controllerA.signal.aborted);
|
|
192
|
-
assert.equal(controllerB.signal.aborted, false);
|
|
167
|
+
const { promise: extraction, resolve } = Promise.withResolvers<void>();
|
|
168
|
+
tracker.track(key, extraction);
|
|
169
|
+
// The flush deadline path registers a stop and calls it; nothing else.
|
|
170
|
+
const { promise: stopRegistered, resolve: resolveStop } = Promise.withResolvers<() => void>();
|
|
171
|
+
const waiter = tracker.wait("session-a", "alice", "default", undefined, (stop) => resolveStop(stop));
|
|
172
|
+
const stop = await stopRegistered;
|
|
173
|
+
stop();
|
|
174
|
+
await waiter;
|
|
175
|
+
resolve();
|
|
176
|
+
await extraction;
|
|
193
177
|
await settle();
|
|
194
178
|
await tracker.wait("session-a", "alice", "default");
|
|
195
179
|
});
|
|
196
180
|
|
|
197
|
-
test("an
|
|
181
|
+
test("an entry settles once every generation settles and cleans up", { timeout: 2000 }, async () => {
|
|
198
182
|
const tracker = new PendingObserveExtractionTracker();
|
|
199
183
|
const key = tracker.key("session-a", "alice", "default");
|
|
200
|
-
const first =
|
|
201
|
-
tracker.track(key,
|
|
202
|
-
const second = new AbortController();
|
|
184
|
+
const { promise: first, reject } = rejectable();
|
|
185
|
+
tracker.track(key, first);
|
|
203
186
|
const { promise: secondExtraction, resolve } = Promise.withResolvers<void>();
|
|
204
|
-
tracker.track(key, secondExtraction
|
|
205
|
-
|
|
187
|
+
tracker.track(key, secondExtraction);
|
|
188
|
+
reject(preemptedExtractionError());
|
|
206
189
|
resolve();
|
|
207
190
|
await settle();
|
|
208
191
|
await tracker.wait("session-a", "alice", "default");
|
|
@@ -211,18 +194,18 @@ test("an aborted chain entry settles once every generation settles and cleans up
|
|
|
211
194
|
test("wait surfaces a chained non-preempted rejection", async () => {
|
|
212
195
|
const tracker = new PendingObserveExtractionTracker();
|
|
213
196
|
const key = tracker.key("session-a", "alice", "default");
|
|
214
|
-
tracker.track(key, Promise.resolve()
|
|
215
|
-
tracker.track(key, Promise.reject(new Error("extraction failed"))
|
|
197
|
+
tracker.track(key, Promise.resolve());
|
|
198
|
+
tracker.track(key, Promise.reject(new Error("extraction failed")));
|
|
216
199
|
await assert.rejects(tracker.wait("session-a", "alice", "default"), /extraction failed/);
|
|
217
200
|
});
|
|
218
201
|
|
|
219
202
|
test("a wait overlapping a preempted rejection returns without throwing", { timeout: 2000 }, async () => {
|
|
220
203
|
const tracker = new PendingObserveExtractionTracker();
|
|
221
204
|
const key = tracker.key("session-a", "alice", "default");
|
|
222
|
-
const
|
|
223
|
-
tracker.track(key,
|
|
205
|
+
const { promise: extraction, reject } = rejectable();
|
|
206
|
+
tracker.track(key, extraction);
|
|
224
207
|
const waiter = tracker.wait("session-a", "alice", "default");
|
|
225
208
|
await Promise.resolve();
|
|
226
|
-
|
|
209
|
+
reject(preemptedExtractionError());
|
|
227
210
|
await waiter;
|
|
228
211
|
});
|