@remnic/core 10.0.128 → 10.0.130
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 +104 -103
- package/dist/access-cli.js +104 -103
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.js +104 -103
- package/dist/access-health-types.d.ts +8 -0
- package/dist/access-health-types.d.ts.map +1 -1
- package/dist/access-http-briefing.js +104 -103
- package/dist/access-http-query.js +104 -103
- package/dist/access-http.js +104 -103
- package/dist/access-identity-continuity-surface.js +104 -103
- package/dist/access-lcm-surface.js +104 -103
- package/dist/access-mcp.js +104 -103
- package/dist/access-observe-write-category.js +6 -6
- package/dist/access-observe-write-surface.js +104 -103
- package/dist/access-offline-manifest.js +5 -5
- package/dist/access-operations-batch.js +104 -103
- package/dist/access-operations.js +104 -103
- package/dist/access-recall-concurrency.js +104 -103
- package/dist/access-recall-response.js +104 -103
- package/dist/access-recall-surface.js +104 -103
- package/dist/access-schema.js +5 -5
- package/dist/access-service.d.ts.map +1 -1
- package/dist/access-service.js +104 -103
- package/dist/active-recall.js +13 -13
- package/dist/adapters/agy.d.ts +22 -0
- package/dist/adapters/agy.d.ts.map +1 -0
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.d.ts.map +1 -1
- package/dist/adapters/registry.js +2 -2
- package/dist/briefing.js +6 -6
- package/dist/buffer-ingress-counters.d.ts +100 -0
- package/dist/buffer-ingress-counters.d.ts.map +1 -0
- package/dist/buffer-ingress-counters.js +11 -0
- package/dist/buffer-turn-helpers.d.ts +6 -0
- package/dist/buffer-turn-helpers.d.ts.map +1 -1
- package/dist/buffer-turn-helpers.js +3 -1
- package/dist/buffer.d.ts +8 -1
- package/dist/buffer.d.ts.map +1 -1
- package/dist/buffer.js +3 -2
- package/dist/calibration.js +2 -2
- package/dist/causal-behavior.js +2 -2
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.js +9 -9
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.js +2 -2
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-ID65XTF3.js → chunk-2JAT4S7N.js} +2 -2
- package/dist/{chunk-BR7CZVMO.js → chunk-2UW3EM3U.js} +6 -1
- package/dist/chunk-2UW3EM3U.js.map +1 -0
- package/dist/{chunk-ORMJT23N.js → chunk-3OT6JDMD.js} +8 -8
- package/dist/{chunk-SU42FIJ7.js → chunk-3RW5ZCYO.js} +2 -2
- package/dist/{chunk-TJJPT2OV.js → chunk-3S7BUGYC.js} +2 -2
- package/dist/{chunk-7TC2PWKH.js → chunk-4KWR7M3Q.js} +2 -2
- package/dist/{chunk-WRGW76LI.js → chunk-5BE3FLKL.js} +6 -6
- package/dist/{chunk-JK2IVISS.js → chunk-5FWPLAKP.js} +2 -2
- package/dist/{chunk-PPPY2PCU.js → chunk-5OW73TEG.js} +2 -2
- package/dist/{chunk-DTTDMK7Q.js → chunk-5RONA5FF.js} +4 -4
- package/dist/{chunk-6FPJPSQK.js → chunk-6P5PIOWW.js} +2 -2
- package/dist/{chunk-HJ7M322C.js → chunk-6PQVAYQJ.js} +2 -2
- package/dist/{chunk-QKYOMKRG.js → chunk-7C7M2P43.js} +2 -2
- package/dist/{chunk-XMKUABIG.js → chunk-AAV726HQ.js} +3 -3
- package/dist/{chunk-ASINXIKX.js → chunk-AWKD2A73.js} +12 -12
- package/dist/{chunk-XUWDB53W.js → chunk-BAKCGJRQ.js} +3 -3
- package/dist/{chunk-ALLI23GW.js → chunk-BE5F6KFG.js} +2 -2
- package/dist/{chunk-MGCV3VGC.js → chunk-BOK5D46I.js} +2 -2
- package/dist/{chunk-FBXU7X27.js → chunk-BTY6DUFW.js} +2 -2
- package/dist/{chunk-FPBFDQZZ.js → chunk-CFJBSE7J.js} +11 -11
- package/dist/{chunk-WYABF2WA.js → chunk-CLVILSBR.js} +3 -3
- package/dist/{chunk-BFBS7OFQ.js → chunk-DC55RIEZ.js} +4 -4
- package/dist/{chunk-NYZ6ZNFO.js → chunk-FCW4FUF2.js} +5 -5
- package/dist/{chunk-7QDB7P3V.js → chunk-FMFCQRDM.js} +3 -3
- package/dist/{chunk-CUKYV5O3.js → chunk-GCHM5BYL.js} +30 -4
- package/dist/chunk-GCHM5BYL.js.map +1 -0
- package/dist/{chunk-K36RMINQ.js → chunk-GOZXQNIM.js} +3 -3
- package/dist/{chunk-YFUHFPV6.js → chunk-HILGHLPA.js} +10 -10
- package/dist/{chunk-EFHM4VDG.js → chunk-HLWXCDUQ.js} +2 -2
- package/dist/{chunk-JCPEXUNP.js → chunk-IUVTFQWY.js} +2 -2
- package/dist/{chunk-YPE3O5VH.js → chunk-JHKCS6EN.js} +2 -2
- package/dist/{chunk-UWU6KEZU.js → chunk-JVQNRSWO.js} +2 -2
- package/dist/{chunk-PAGVXEWG.js → chunk-KLUCX6OH.js} +2 -2
- package/dist/{chunk-ELBZT6RU.js → chunk-KVCFAWBZ.js} +2 -2
- package/dist/{chunk-W4Q65VJL.js → chunk-MZCGHPIJ.js} +2 -2
- package/dist/{chunk-2BBCM2PX.js → chunk-N36J3MIB.js} +2 -2
- package/dist/{chunk-AYBRQJXP.js → chunk-NVKWV4W3.js} +2 -2
- package/dist/{chunk-ZUMHQEW4.js → chunk-QHDBKC5Z.js} +4 -4
- package/dist/chunk-RADARJEC.js +156 -0
- package/dist/chunk-RADARJEC.js.map +1 -0
- package/dist/{chunk-3OLHDECL.js → chunk-RMU3O74L.js} +157 -150
- package/dist/chunk-RMU3O74L.js.map +1 -0
- package/dist/{chunk-MCTGYIYN.js → chunk-RXD46MY6.js} +2 -2
- package/dist/{chunk-TJY6AKWV.js → chunk-SULNVNTU.js} +2 -2
- package/dist/{chunk-34YQ7CVE.js → chunk-TL6QIZT7.js} +18 -14
- package/dist/chunk-TL6QIZT7.js.map +1 -0
- package/dist/{chunk-7T7I5D3F.js → chunk-TSJQ7C2T.js} +6 -6
- package/dist/{chunk-HQPFACXO.js → chunk-UH3FPX3L.js} +2 -2
- package/dist/{chunk-6SRYCJ5I.js → chunk-V6JECHY6.js} +5 -5
- package/dist/{chunk-YCJRYM3Q.js → chunk-VAMCJPJT.js} +3 -3
- package/dist/{chunk-QC2MHZDD.js → chunk-VEFGHRKV.js} +1 -1
- package/dist/{chunk-O62MMJWV.js → chunk-VO3HCFSR.js} +2 -2
- package/dist/{chunk-4DJSDH2M.js → chunk-W5GGKQVS.js} +5 -5
- package/dist/{chunk-TQ5NOVMT.js → chunk-X7EAMNKR.js} +2 -2
- package/dist/{chunk-G53I363P.js → chunk-XF2QQQXO.js} +2 -2
- package/dist/{chunk-GWFL6LUU.js → chunk-XUS2UQOO.js} +2 -2
- package/dist/{chunk-FZVROZKC.js → chunk-XVZA6VXC.js} +4 -4
- package/dist/{chunk-VPEIWMUT.js → chunk-YLTU2DC4.js} +2 -2
- package/dist/{chunk-PXZLVFNC.js → chunk-YQXD57ZS.js} +2 -2
- package/dist/{chunk-LR2X3FJM.js → chunk-YW63C4FO.js} +9 -9
- package/dist/{chunk-LU2GQ4Q4.js → chunk-YYHBB565.js} +2 -2
- package/dist/{chunk-2G72JBQB.js → chunk-ZCXZNK4G.js} +2 -2
- package/dist/{chunk-ZO377APE.js → chunk-ZMDXISMQ.js} +3 -3
- package/dist/cli.js +104 -103
- package/dist/coding/export-okf-codegraph.js +5 -5
- package/dist/coding/pre-action-gate.js +2 -2
- package/dist/compounding/engine.js +7 -7
- package/dist/config.js +13 -13
- package/dist/connectors/codex-materialize-runner.js +6 -6
- package/dist/connectors/index.js +6 -6
- package/dist/consolidation-provenance-check.js +2 -2
- package/dist/convergence-refresh.js +8 -8
- package/dist/corpus-watermark.js +8 -8
- package/dist/deep-recall-http-glue.js +6 -6
- package/dist/embedding-fallback.js +2 -2
- package/dist/entity-retrieval.js +8 -8
- package/dist/explicit-capture.js +104 -103
- package/dist/extraction-span-materialize.js +2 -2
- package/dist/extraction.js +13 -13
- package/dist/{graph-edge-decay-CXTNJ7IQ.js → graph-edge-decay-EKWXRBWF.js} +5 -5
- package/dist/graph-edge-decay-EKWXRBWF.js.map +1 -0
- package/dist/graph-jsonl.js +3 -3
- package/dist/graph-snapshot.js +3 -3
- package/dist/graph.js +2 -2
- package/dist/harmonic-retrieval.js +6 -6
- package/dist/index.js +167 -166
- package/dist/lcm/index.js +3 -3
- package/dist/local-llm.js +2 -2
- package/dist/location/index.js +7 -7
- package/dist/maintenance/memory-governance.js +6 -6
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +6 -6
- package/dist/maintenance/rebuild-memory-projection-runner.js +8 -8
- package/dist/maintenance/rebuild-memory-projection.js +7 -7
- package/dist/namespaces/migrate.js +7 -7
- package/dist/namespaces/storage.js +6 -6
- package/dist/offline-sync-changeset-generations.js +3 -3
- package/dist/offline-sync-embedding-generation.js +2 -2
- package/dist/offline-sync-snapshot-stream.js +5 -5
- package/dist/offline-sync.js +4 -4
- package/dist/operator-doctor-corpus.js +9 -9
- package/dist/operator-toolkit.js +23 -23
- package/dist/orchestration/backlog-scheduler.js +105 -104
- package/dist/orchestration/backlog-scheduler.js.map +1 -1
- package/dist/orchestration/buffer-drain-runner.js +105 -104
- package/dist/orchestration/maintenance.js +16 -16
- package/dist/orchestrator.js +104 -103
- package/dist/recall-navigation.js +104 -103
- package/dist/resume-bundles.js +16 -16
- package/dist/semantic-consolidation.js +10 -10
- package/dist/semantic-rule-promotion.js +6 -6
- package/dist/semantic-rule-verifier.js +6 -6
- package/dist/source-agent-qualifier.js +6 -6
- package/dist/standup/build.js +6 -6
- package/dist/storage/buffer-drain-claims.js +2 -2
- package/dist/storage/buffer-session-files.js +2 -2
- package/dist/storage.js +5 -5
- package/dist/summarizer.js +3 -3
- package/dist/support-passport/index.js +3 -3
- package/dist/transcript.js +2 -2
- package/dist/transfer/export-okf.js +6 -6
- package/dist/verified-recall.js +6 -6
- package/dist/who-knows-cli.js +7 -7
- package/dist/who-knows.js +6 -6
- package/package.json +2 -2
- package/src/access-health-types.ts +8 -0
- package/src/access-http.test.ts +18 -0
- package/src/access-service-health-ingress.test.ts +113 -0
- package/src/access-service.ts +14 -7
- package/src/adapters/agy.test.ts +75 -0
- package/src/adapters/agy.ts +45 -0
- package/src/adapters/grok-opencode.test.ts +1 -0
- package/src/adapters/registry.ts +2 -0
- package/src/buffer-ingress-counters.test.ts +310 -0
- package/src/buffer-ingress-counters.ts +278 -0
- package/src/buffer-ingress-invariant.test.ts +290 -0
- package/src/buffer-turn-helpers.ts +10 -0
- package/src/buffer.ts +19 -21
- package/dist/chunk-34YQ7CVE.js.map +0 -1
- package/dist/chunk-3OLHDECL.js.map +0 -1
- package/dist/chunk-BR7CZVMO.js.map +0 -1
- package/dist/chunk-CUKYV5O3.js.map +0 -1
- /package/dist/{graph-edge-decay-CXTNJ7IQ.js.map → buffer-ingress-counters.js.map} +0 -0
- /package/dist/{chunk-ID65XTF3.js.map → chunk-2JAT4S7N.js.map} +0 -0
- /package/dist/{chunk-ORMJT23N.js.map → chunk-3OT6JDMD.js.map} +0 -0
- /package/dist/{chunk-SU42FIJ7.js.map → chunk-3RW5ZCYO.js.map} +0 -0
- /package/dist/{chunk-TJJPT2OV.js.map → chunk-3S7BUGYC.js.map} +0 -0
- /package/dist/{chunk-7TC2PWKH.js.map → chunk-4KWR7M3Q.js.map} +0 -0
- /package/dist/{chunk-WRGW76LI.js.map → chunk-5BE3FLKL.js.map} +0 -0
- /package/dist/{chunk-JK2IVISS.js.map → chunk-5FWPLAKP.js.map} +0 -0
- /package/dist/{chunk-PPPY2PCU.js.map → chunk-5OW73TEG.js.map} +0 -0
- /package/dist/{chunk-DTTDMK7Q.js.map → chunk-5RONA5FF.js.map} +0 -0
- /package/dist/{chunk-6FPJPSQK.js.map → chunk-6P5PIOWW.js.map} +0 -0
- /package/dist/{chunk-HJ7M322C.js.map → chunk-6PQVAYQJ.js.map} +0 -0
- /package/dist/{chunk-QKYOMKRG.js.map → chunk-7C7M2P43.js.map} +0 -0
- /package/dist/{chunk-XMKUABIG.js.map → chunk-AAV726HQ.js.map} +0 -0
- /package/dist/{chunk-ASINXIKX.js.map → chunk-AWKD2A73.js.map} +0 -0
- /package/dist/{chunk-XUWDB53W.js.map → chunk-BAKCGJRQ.js.map} +0 -0
- /package/dist/{chunk-ALLI23GW.js.map → chunk-BE5F6KFG.js.map} +0 -0
- /package/dist/{chunk-MGCV3VGC.js.map → chunk-BOK5D46I.js.map} +0 -0
- /package/dist/{chunk-FBXU7X27.js.map → chunk-BTY6DUFW.js.map} +0 -0
- /package/dist/{chunk-FPBFDQZZ.js.map → chunk-CFJBSE7J.js.map} +0 -0
- /package/dist/{chunk-WYABF2WA.js.map → chunk-CLVILSBR.js.map} +0 -0
- /package/dist/{chunk-BFBS7OFQ.js.map → chunk-DC55RIEZ.js.map} +0 -0
- /package/dist/{chunk-NYZ6ZNFO.js.map → chunk-FCW4FUF2.js.map} +0 -0
- /package/dist/{chunk-7QDB7P3V.js.map → chunk-FMFCQRDM.js.map} +0 -0
- /package/dist/{chunk-K36RMINQ.js.map → chunk-GOZXQNIM.js.map} +0 -0
- /package/dist/{chunk-YFUHFPV6.js.map → chunk-HILGHLPA.js.map} +0 -0
- /package/dist/{chunk-EFHM4VDG.js.map → chunk-HLWXCDUQ.js.map} +0 -0
- /package/dist/{chunk-JCPEXUNP.js.map → chunk-IUVTFQWY.js.map} +0 -0
- /package/dist/{chunk-YPE3O5VH.js.map → chunk-JHKCS6EN.js.map} +0 -0
- /package/dist/{chunk-UWU6KEZU.js.map → chunk-JVQNRSWO.js.map} +0 -0
- /package/dist/{chunk-PAGVXEWG.js.map → chunk-KLUCX6OH.js.map} +0 -0
- /package/dist/{chunk-ELBZT6RU.js.map → chunk-KVCFAWBZ.js.map} +0 -0
- /package/dist/{chunk-W4Q65VJL.js.map → chunk-MZCGHPIJ.js.map} +0 -0
- /package/dist/{chunk-2BBCM2PX.js.map → chunk-N36J3MIB.js.map} +0 -0
- /package/dist/{chunk-AYBRQJXP.js.map → chunk-NVKWV4W3.js.map} +0 -0
- /package/dist/{chunk-ZUMHQEW4.js.map → chunk-QHDBKC5Z.js.map} +0 -0
- /package/dist/{chunk-MCTGYIYN.js.map → chunk-RXD46MY6.js.map} +0 -0
- /package/dist/{chunk-TJY6AKWV.js.map → chunk-SULNVNTU.js.map} +0 -0
- /package/dist/{chunk-7T7I5D3F.js.map → chunk-TSJQ7C2T.js.map} +0 -0
- /package/dist/{chunk-HQPFACXO.js.map → chunk-UH3FPX3L.js.map} +0 -0
- /package/dist/{chunk-6SRYCJ5I.js.map → chunk-V6JECHY6.js.map} +0 -0
- /package/dist/{chunk-YCJRYM3Q.js.map → chunk-VAMCJPJT.js.map} +0 -0
- /package/dist/{chunk-QC2MHZDD.js.map → chunk-VEFGHRKV.js.map} +0 -0
- /package/dist/{chunk-O62MMJWV.js.map → chunk-VO3HCFSR.js.map} +0 -0
- /package/dist/{chunk-4DJSDH2M.js.map → chunk-W5GGKQVS.js.map} +0 -0
- /package/dist/{chunk-TQ5NOVMT.js.map → chunk-X7EAMNKR.js.map} +0 -0
- /package/dist/{chunk-G53I363P.js.map → chunk-XF2QQQXO.js.map} +0 -0
- /package/dist/{chunk-GWFL6LUU.js.map → chunk-XUS2UQOO.js.map} +0 -0
- /package/dist/{chunk-FZVROZKC.js.map → chunk-XVZA6VXC.js.map} +0 -0
- /package/dist/{chunk-VPEIWMUT.js.map → chunk-YLTU2DC4.js.map} +0 -0
- /package/dist/{chunk-PXZLVFNC.js.map → chunk-YQXD57ZS.js.map} +0 -0
- /package/dist/{chunk-LR2X3FJM.js.map → chunk-YW63C4FO.js.map} +0 -0
- /package/dist/{chunk-LU2GQ4Q4.js.map → chunk-YYHBB565.js.map} +0 -0
- /package/dist/{chunk-2G72JBQB.js.map → chunk-ZCXZNK4G.js.map} +0 -0
- /package/dist/{chunk-ZO377APE.js.map → chunk-ZMDXISMQ.js.map} +0 -0
package/src/access-service.ts
CHANGED
|
@@ -2368,13 +2368,10 @@ export class EngramAccessService extends SupportPassportAccessServiceBase {
|
|
|
2368
2368
|
cache: this.corpusWatermarkCache,
|
|
2369
2369
|
caps,
|
|
2370
2370
|
});
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
} catch {
|
|
2376
|
-
projectionAvailable = false;
|
|
2377
|
-
}
|
|
2371
|
+
const projectionAvailable = await stat(getMemoryProjectionPath(storage.dir)).then(
|
|
2372
|
+
() => true,
|
|
2373
|
+
() => false,
|
|
2374
|
+
);
|
|
2378
2375
|
|
|
2379
2376
|
return {
|
|
2380
2377
|
ok: true,
|
|
@@ -2391,6 +2388,16 @@ export class EngramAccessService extends SupportPassportAccessServiceBase {
|
|
|
2391
2388
|
),
|
|
2392
2389
|
nativeKnowledgeEnabled: this.orchestrator.config.nativeKnowledge?.enabled === true,
|
|
2393
2390
|
projectionAvailable,
|
|
2391
|
+
// #3444: process-local buffer add-path counters, TOP LEVEL (not inside `extraction`).
|
|
2392
|
+
bufferIngress: this.orchestrator.buffer?.ingress?.snapshot() ?? {
|
|
2393
|
+
totals: {
|
|
2394
|
+
accepted: { turns: 0, chars: 0 },
|
|
2395
|
+
acceptedExactDuplicate: { turns: 0, chars: 0 },
|
|
2396
|
+
filtered: { turns: 0, chars: 0 },
|
|
2397
|
+
refused: { turns: 0, chars: 0 },
|
|
2398
|
+
},
|
|
2399
|
+
hours: [],
|
|
2400
|
+
},
|
|
2394
2401
|
extraction: visibleExtraction,
|
|
2395
2402
|
corpus: corpusCensus.watermarks,
|
|
2396
2403
|
// Describes THIS response's array (round 8): a separate scan could report
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { AdapterRegistry } from "./registry.js";
|
|
5
|
+
import { AgyAdapter } from "./agy.js";
|
|
6
|
+
import type { AdapterContext } from "./types.js";
|
|
7
|
+
|
|
8
|
+
function context(overrides: Partial<AdapterContext> = {}): AdapterContext {
|
|
9
|
+
return { headers: {}, ...overrides };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
test("AgyAdapter matches clientInfo names containing agy", () => {
|
|
13
|
+
const adapter = new AgyAdapter();
|
|
14
|
+
assert.equal(adapter.matches(context({ clientInfo: { name: "agy" } })), true);
|
|
15
|
+
assert.equal(adapter.matches(context({ clientInfo: { name: "agy-cli" } })), true);
|
|
16
|
+
assert.equal(adapter.matches(context({ clientInfo: { name: "Agy" } })), true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("AgyAdapter matches the configured client-id header", () => {
|
|
20
|
+
const adapter = new AgyAdapter();
|
|
21
|
+
assert.equal(
|
|
22
|
+
adapter.matches(context({ headers: { "X-Engram-Client-Id": "agy-cli" } })),
|
|
23
|
+
true,
|
|
24
|
+
);
|
|
25
|
+
assert.equal(
|
|
26
|
+
adapter.matches(context({ headers: { "X-Engram-Client-Id": "agy" } })),
|
|
27
|
+
true,
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("AgyAdapter rejects unrelated clients", () => {
|
|
32
|
+
const adapter = new AgyAdapter();
|
|
33
|
+
assert.equal(adapter.matches(context()), false);
|
|
34
|
+
assert.equal(adapter.matches(context({ clientInfo: { name: "claude-code" } })), false);
|
|
35
|
+
assert.equal(adapter.matches(context({ clientInfo: { name: "codex-mcp-client" } })), false);
|
|
36
|
+
assert.equal(
|
|
37
|
+
adapter.matches(context({ headers: { "X-Engram-Client-Id": "claude-code" } })),
|
|
38
|
+
false,
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("AgyAdapter resolves agy namespace and principal with header overrides", () => {
|
|
43
|
+
const adapter = new AgyAdapter();
|
|
44
|
+
assert.deepEqual(
|
|
45
|
+
adapter.resolveIdentity(context({ headers: { "mcp-session-id": "sess-1" } })),
|
|
46
|
+
{
|
|
47
|
+
namespace: "agy",
|
|
48
|
+
namespaceExplicit: false,
|
|
49
|
+
principal: "agy",
|
|
50
|
+
sessionKey: "sess-1",
|
|
51
|
+
adapterId: "agy",
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
assert.deepEqual(
|
|
55
|
+
adapter.resolveIdentity(
|
|
56
|
+
context({ headers: { "x-engram-namespace": "team-space" } }),
|
|
57
|
+
),
|
|
58
|
+
{
|
|
59
|
+
namespace: "team-space",
|
|
60
|
+
namespaceExplicit: true,
|
|
61
|
+
principal: "agy",
|
|
62
|
+
sessionKey: undefined,
|
|
63
|
+
adapterId: "agy",
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("registry resolves Agy requests before the Claude Code adapter", () => {
|
|
69
|
+
const registry = new AdapterRegistry();
|
|
70
|
+
const identity = registry.resolve(
|
|
71
|
+
context({ headers: { "x-engram-client-id": "agy-cli" } }),
|
|
72
|
+
);
|
|
73
|
+
assert.equal(identity?.adapterId, "agy");
|
|
74
|
+
assert.equal(identity?.namespace, "agy");
|
|
75
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { headerValue, type AdapterContext, type EngramAdapter, type ResolvedIdentity } from "./types.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Antigravity CLI (agy) adapter.
|
|
5
|
+
*
|
|
6
|
+
* Detection: agy's MCP clientInfo.name contains "agy" in the initialize
|
|
7
|
+
* handshake. The bundled stdio→HTTP proxy also sends
|
|
8
|
+
* X-Engram-Client-Id: agy-cli (matching the lifecycle hook runner's
|
|
9
|
+
* client id) so detection does not depend on the handshake alone.
|
|
10
|
+
*
|
|
11
|
+
* Namespace can be set with the X-Engram-Namespace header; the proxy
|
|
12
|
+
* forwards REMNIC_NAMESPACE/ENGRAM_NAMESPACE as that header.
|
|
13
|
+
*
|
|
14
|
+
* Principal overrides are intentionally handled only by the HTTP server's
|
|
15
|
+
* trustPrincipalHeader gate. Adapters must not independently trust
|
|
16
|
+
* X-Engram-Principal.
|
|
17
|
+
*/
|
|
18
|
+
export class AgyAdapter implements EngramAdapter {
|
|
19
|
+
readonly id = "agy";
|
|
20
|
+
|
|
21
|
+
matches(context: AdapterContext): boolean {
|
|
22
|
+
const clientName = context.clientInfo?.name?.toLowerCase() ?? "";
|
|
23
|
+
if (clientName.includes("agy")) return true;
|
|
24
|
+
|
|
25
|
+
const clientId = headerValue(context.headers, "x-engram-client-id");
|
|
26
|
+
if (clientId && (clientId.toLowerCase() === "agy-cli" || clientId.toLowerCase() === "agy")) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
resolveIdentity(context: AdapterContext): ResolvedIdentity {
|
|
34
|
+
const mcpSessionId = headerValue(context.headers, "mcp-session-id");
|
|
35
|
+
const namespaceHeader = headerValue(context.headers, "x-engram-namespace");
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
namespace: namespaceHeader ?? "agy",
|
|
39
|
+
namespaceExplicit: namespaceHeader !== undefined,
|
|
40
|
+
principal: "agy",
|
|
41
|
+
sessionKey: mcpSessionId ?? context.sessionKey,
|
|
42
|
+
adapterId: this.id,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/adapters/registry.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AdapterContext, EngramAdapter, ResolvedIdentity } from "./types.js";
|
|
2
2
|
import { ClaudeCodeAdapter } from "./claude-code.js";
|
|
3
3
|
import { CodexAdapter } from "./codex.js";
|
|
4
|
+
import { AgyAdapter } from "./agy.js";
|
|
4
5
|
import { DevinAdapter } from "./devin.js";
|
|
5
6
|
import { GrokAdapter } from "./grok.js";
|
|
6
7
|
import { OpenCodeAdapter } from "./opencode.js";
|
|
@@ -20,6 +21,7 @@ export class AdapterRegistry {
|
|
|
20
21
|
new HermesAdapter(),
|
|
21
22
|
new ReplitAdapter(),
|
|
22
23
|
new CodexAdapter(),
|
|
24
|
+
new AgyAdapter(),
|
|
23
25
|
new DevinAdapter(),
|
|
24
26
|
new ClaudeCodeAdapter(),
|
|
25
27
|
new GrokAdapter(),
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
BufferIngressCounters,
|
|
8
|
+
type BufferIngressSnapshot,
|
|
9
|
+
EMPTY_BUFFER_INGRESS_SNAPSHOT,
|
|
10
|
+
} from "./buffer-ingress-counters.js";
|
|
11
|
+
import { initLogger, resetLogger } from "./logger.js";
|
|
12
|
+
import type { BufferEntryState, BufferTurn } from "./types.js";
|
|
13
|
+
|
|
14
|
+
const HOUR_MS = 3_600_000;
|
|
15
|
+
|
|
16
|
+
function captureInfo() {
|
|
17
|
+
// SAFETY: implements LoggerBackend for log capture; error is a no-op because these tests never log errors.
|
|
18
|
+
const lines: string[] = [];
|
|
19
|
+
initLogger({
|
|
20
|
+
info: (msg: string) => lines.push(msg),
|
|
21
|
+
warn: () => {},
|
|
22
|
+
error: () => {},
|
|
23
|
+
debug: () => {},
|
|
24
|
+
});
|
|
25
|
+
return { lines, restore: resetLogger };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function fakeEntry(turns: BufferTurn[] = []): BufferEntryState {
|
|
29
|
+
return { turns, lastExtractionAt: null, extractionCount: 0 };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function turn(content: string): BufferTurn {
|
|
33
|
+
return { role: "user", content, timestamp: "2026-04-12T12:00:00.000Z", sessionKey: "kA" };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
test("aggregates accepted, its exact-duplicate sub-count and refusals in turns and chars", () => {
|
|
37
|
+
const counters = new BufferIngressCounters();
|
|
38
|
+
const entry = fakeEntry();
|
|
39
|
+
counters.noteAppendedTurn(entry, turn("alpha memory"));
|
|
40
|
+
counters.noteAppendedTurn(entry, turn("beta memory"));
|
|
41
|
+
counters.noteAppendedTurn(entry, turn("alpha memory")); // exact duplicate, still appended
|
|
42
|
+
counters.refuseOne(turn("refused offer"));
|
|
43
|
+
|
|
44
|
+
const snapshot = counters.snapshot();
|
|
45
|
+
assert.deepEqual(snapshot.totals.accepted, { turns: 3, chars: 35 });
|
|
46
|
+
assert.deepEqual(snapshot.totals.acceptedExactDuplicate, { turns: 1, chars: 12 });
|
|
47
|
+
assert.deepEqual(snapshot.totals.filtered, { turns: 0, chars: 0 });
|
|
48
|
+
assert.deepEqual(snapshot.totals.refused, { turns: 1, chars: 13 });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("refuseThrow counts and returns the original error; refuseAll counts every turn", () => {
|
|
52
|
+
const counters = new BufferIngressCounters();
|
|
53
|
+
const original = new Error("cap");
|
|
54
|
+
const returned = counters.refuseThrow(turn("x"), original);
|
|
55
|
+
assert.equal(returned, original);
|
|
56
|
+
const batch = [turn("a"), turn("bb")];
|
|
57
|
+
assert.equal(counters.refuseAll(batch.map((t) => ({ turn: t }))), null);
|
|
58
|
+
const snapshot = counters.snapshot();
|
|
59
|
+
assert.deepEqual(snapshot.totals.refused, { turns: 3, chars: 1 + 1 + 2 });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("the duplicate digest set follows the entry's turns (self-invalidating memo)", () => {
|
|
63
|
+
const counters = new BufferIngressCounters();
|
|
64
|
+
const entry = fakeEntry([turn("seeded")]);
|
|
65
|
+
counters.noteAppendedTurn(entry, turn("seeded")); // matches the seeded turn
|
|
66
|
+
assert.equal(counters.snapshot().totals.acceptedExactDuplicate.turns, 1);
|
|
67
|
+
// A drain reassigns the array: the old content is no longer tracked.
|
|
68
|
+
entry.turns = [turn("fresh")];
|
|
69
|
+
counters.noteAppendedTurn(entry, turn("seeded"));
|
|
70
|
+
assert.equal(counters.snapshot().totals.acceptedExactDuplicate.turns, 1);
|
|
71
|
+
// Retained turns participate too.
|
|
72
|
+
entry.turns = [];
|
|
73
|
+
entry.retainedTurns = [turn("kept")];
|
|
74
|
+
counters.noteAppendedTurn(entry, turn("kept"));
|
|
75
|
+
assert.equal(counters.snapshot().totals.acceptedExactDuplicate.turns, 2);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("counters-disabled control records nothing (differential seam)", () => {
|
|
79
|
+
const counters = new BufferIngressCounters(undefined, false);
|
|
80
|
+
const entry = fakeEntry();
|
|
81
|
+
counters.noteAppendedTurn(entry, turn("anything"));
|
|
82
|
+
assert.equal(counters.refuseOne(turn("anything")), null);
|
|
83
|
+
assert.deepEqual(counters.snapshot(), EMPTY_BUFFER_INGRESS_SNAPSHOT);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("snapshot drops hour buckets older than 24h while totals stay cumulative", () => {
|
|
87
|
+
let t = Date.parse("2026-04-12T12:00:00.000Z");
|
|
88
|
+
const counters = new BufferIngressCounters(() => t);
|
|
89
|
+
const entry = fakeEntry();
|
|
90
|
+
counters.noteAppendedTurn(entry, turn("old"));
|
|
91
|
+
assert.equal(counters.snapshot().hours.length, 1);
|
|
92
|
+
t += 30 * HOUR_MS; // 30 h later
|
|
93
|
+
counters.noteAppendedTurn(entry, turn("new"));
|
|
94
|
+
const snapshot = counters.snapshot();
|
|
95
|
+
assert.equal(snapshot.hours.length, 1);
|
|
96
|
+
assert.equal(snapshot.hours[0].accepted.turns, 1);
|
|
97
|
+
assert.equal(snapshot.totals.accepted.turns, 2);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("snapshot is a fresh read-only structure and never aliases internals", () => {
|
|
101
|
+
const counters = new BufferIngressCounters();
|
|
102
|
+
const entry = fakeEntry();
|
|
103
|
+
counters.noteAppendedTurn(entry, turn("note"));
|
|
104
|
+
const first = counters.snapshot();
|
|
105
|
+
first.totals.accepted.turns = 99;
|
|
106
|
+
first.hours.push({
|
|
107
|
+
hourStart: "tampered",
|
|
108
|
+
accepted: { turns: 0, chars: 0 },
|
|
109
|
+
acceptedExactDuplicate: { turns: 0, chars: 0 },
|
|
110
|
+
filtered: { turns: 0, chars: 0 },
|
|
111
|
+
refused: { turns: 0, chars: 0 },
|
|
112
|
+
});
|
|
113
|
+
const second = counters.snapshot();
|
|
114
|
+
assert.equal(second.totals.accepted.turns, 1);
|
|
115
|
+
assert.equal(second.hours.length, 1);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("hourly ring rolls with an injected clock and keeps the last 24 hours", () => {
|
|
119
|
+
let nowMs = 1_700_000_000_000;
|
|
120
|
+
const counters = new BufferIngressCounters(() => nowMs);
|
|
121
|
+
const entry = fakeEntry();
|
|
122
|
+
|
|
123
|
+
counters.noteAppendedTurn(entry, turn("a"));
|
|
124
|
+
const hourZero = Math.floor(nowMs / HOUR_MS) * HOUR_MS;
|
|
125
|
+
assert.deepEqual(counters.snapshot().hours, [
|
|
126
|
+
{
|
|
127
|
+
hourStart: new Date(hourZero).toISOString(),
|
|
128
|
+
accepted: { turns: 1, chars: 1 },
|
|
129
|
+
acceptedExactDuplicate: { turns: 0, chars: 0 },
|
|
130
|
+
filtered: { turns: 0, chars: 0 },
|
|
131
|
+
refused: { turns: 0, chars: 0 },
|
|
132
|
+
},
|
|
133
|
+
]);
|
|
134
|
+
|
|
135
|
+
// Same hour: counts land in the same bucket.
|
|
136
|
+
counters.noteAppendedTurn(entry, turn("b"));
|
|
137
|
+
assert.equal(counters.snapshot().hours.length, 1);
|
|
138
|
+
|
|
139
|
+
// Next hour: a second bucket appears, the first is preserved.
|
|
140
|
+
nowMs += HOUR_MS;
|
|
141
|
+
counters.refuseOne(turn("c"));
|
|
142
|
+
const hours = counters.snapshot().hours;
|
|
143
|
+
assert.equal(hours.length, 2);
|
|
144
|
+
assert.equal(hours[0].accepted.turns, 2);
|
|
145
|
+
assert.equal(hours[1].refused.turns, 1);
|
|
146
|
+
|
|
147
|
+
// Fill the ring: 24 distinct hours hold exactly 24 buckets, oldest first.
|
|
148
|
+
for (let i = 2; i <= 23; i += 1) {
|
|
149
|
+
nowMs += HOUR_MS;
|
|
150
|
+
counters.noteAppendedTurn(entry, turn(String(i)));
|
|
151
|
+
}
|
|
152
|
+
const full = counters.snapshot().hours;
|
|
153
|
+
assert.equal(full.length, 24);
|
|
154
|
+
assert.equal(new Date(full[0].hourStart).getTime(), hourZero);
|
|
155
|
+
|
|
156
|
+
// One more hour evicts the oldest bucket; the ring never exceeds 24.
|
|
157
|
+
nowMs += HOUR_MS;
|
|
158
|
+
counters.refuseOne(turn("d"));
|
|
159
|
+
const rolled = counters.snapshot().hours;
|
|
160
|
+
assert.equal(rolled.length, 24);
|
|
161
|
+
assert.ok(!rolled.some((hour) => hour.hourStart === new Date(hourZero).toISOString()));
|
|
162
|
+
const newest = rolled.at(-1);
|
|
163
|
+
assert.ok(newest !== undefined, "the ring keeps the newest hour after eviction");
|
|
164
|
+
assert.equal(newest.refused.turns, 1);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("totals survive hourly eviction (process-lifetime sums, not the ring)", () => {
|
|
168
|
+
let nowMs = 1_700_000_000_000;
|
|
169
|
+
const counters = new BufferIngressCounters(() => nowMs);
|
|
170
|
+
const entry = fakeEntry();
|
|
171
|
+
counters.noteAppendedTurn(entry, turn("a"));
|
|
172
|
+
nowMs += 30 * HOUR_MS;
|
|
173
|
+
counters.noteAppendedTurn(entry, turn("bb"));
|
|
174
|
+
assert.deepEqual(counters.snapshot().totals.accepted, { turns: 2, chars: 3 });
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("exactly one aggregate info line per hour, counts only", () => {
|
|
178
|
+
let nowMs = 1_700_000_000_000;
|
|
179
|
+
const counters = new BufferIngressCounters(() => nowMs);
|
|
180
|
+
const entry = fakeEntry();
|
|
181
|
+
const { lines, restore } = captureInfo();
|
|
182
|
+
try {
|
|
183
|
+
// First hour of the process: nothing to log yet (empty bucket).
|
|
184
|
+
counters.noteAppendedTurn(entry, turn("a"));
|
|
185
|
+
assert.equal(lines.length, 0);
|
|
186
|
+
|
|
187
|
+
// Hour rolls: ONE line describing the previous hour.
|
|
188
|
+
nowMs += HOUR_MS;
|
|
189
|
+
counters.refuseOne(turn("b"));
|
|
190
|
+
assert.equal(lines.length, 1);
|
|
191
|
+
assert.match(lines[0], /buffer ingress/);
|
|
192
|
+
assert.match(lines[0], /accepted=1\//);
|
|
193
|
+
assert.match(lines[0], /refused=0\//);
|
|
194
|
+
|
|
195
|
+
// No further log within the same hour, even with more records.
|
|
196
|
+
counters.noteAppendedTurn(entry, turn("c"));
|
|
197
|
+
assert.equal(lines.length, 1);
|
|
198
|
+
|
|
199
|
+
// Empty hours produce no log line (zero-noise): jump forward 3 hours.
|
|
200
|
+
nowMs += 3 * HOUR_MS;
|
|
201
|
+
counters.refuseOne(turn("d"));
|
|
202
|
+
assert.equal(lines.length, 2);
|
|
203
|
+
assert.match(lines[1], /refused=1\//);
|
|
204
|
+
} finally {
|
|
205
|
+
restore();
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test("log lines carry no content or session identifiers", () => {
|
|
210
|
+
let nowMs = 1_700_000_000_000;
|
|
211
|
+
const counters = new BufferIngressCounters(() => nowMs);
|
|
212
|
+
const entry = fakeEntry();
|
|
213
|
+
const { lines, restore } = captureInfo();
|
|
214
|
+
try {
|
|
215
|
+
counters.noteAppendedTurn(entry, turn("secret-session-kaze"));
|
|
216
|
+
nowMs += HOUR_MS;
|
|
217
|
+
counters.noteAppendedTurn(entry, turn("secret memory content"));
|
|
218
|
+
assert.equal(lines.length, 1);
|
|
219
|
+
assert.ok(!lines[0].includes("secret-session-kaze"));
|
|
220
|
+
assert.ok(!lines[0].includes("secret memory content"));
|
|
221
|
+
} finally {
|
|
222
|
+
restore();
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
test("EMPTY_BUFFER_INGRESS_SNAPSHOT is the zero snapshot for hosts without a buffer", () => {
|
|
227
|
+
const empty: BufferIngressSnapshot = EMPTY_BUFFER_INGRESS_SNAPSHOT;
|
|
228
|
+
assert.deepEqual(empty.totals, {
|
|
229
|
+
accepted: { turns: 0, chars: 0 },
|
|
230
|
+
acceptedExactDuplicate: { turns: 0, chars: 0 },
|
|
231
|
+
filtered: { turns: 0, chars: 0 },
|
|
232
|
+
refused: { turns: 0, chars: 0 },
|
|
233
|
+
});
|
|
234
|
+
assert.deepEqual(empty.hours, []);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
test("accepted and its exact-duplicate sub-count share one bucket when the hour rolls over mid-offer", () => {
|
|
238
|
+
// Scripted clock: the first now() call (accepted) lands at the end of hour
|
|
239
|
+
// H, the second (duplicate check path) in hour H+1. Before the fix each
|
|
240
|
+
// record() read the clock itself and the two counts split across buckets.
|
|
241
|
+
const h0 = 1_700_000_000_000 - (1_700_000_000_000 % HOUR_MS);
|
|
242
|
+
// now() is read once per offer (the duplicate check itself never reads the
|
|
243
|
+
// clock): first offer at the end of hour H, second offer in hour H+1.
|
|
244
|
+
const stamps = [h0 + HOUR_MS - 1, h0 + HOUR_MS - 1, h0 + HOUR_MS, h0 + HOUR_MS];
|
|
245
|
+
let calls = 0;
|
|
246
|
+
const clock = () => stamps[Math.min(calls++, stamps.length - 1)];
|
|
247
|
+
const counters = new BufferIngressCounters(clock);
|
|
248
|
+
const entry = fakeEntry();
|
|
249
|
+
counters.noteAppendedTurn(entry, turn("once"));
|
|
250
|
+
counters.noteAppendedTurn(entry, turn("once")); // duplicate, hour has rolled
|
|
251
|
+
const hours = counters.snapshot().hours;
|
|
252
|
+
const dup = hours.find((h) => h.acceptedExactDuplicate.turns === 1);
|
|
253
|
+
assert.ok(dup, "the duplicate sub-count must be recorded");
|
|
254
|
+
assert.equal(dup.accepted.turns, 2, "both accepted turns share the duplicate's bucket");
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
test("rebuilding the memo from a restored entry respects the digest cap", () => {
|
|
258
|
+
// A restored entry can hold more unique turns than DUPLICATE_DIGEST_CAP.
|
|
259
|
+
// The rebuild must keep only the most recent 4,096, so a re-offer of the
|
|
260
|
+
// oldest content is NOT recognised as a duplicate (bounded memory).
|
|
261
|
+
const counters = new BufferIngressCounters();
|
|
262
|
+
const many = Array.from({ length: 6_000 }, (_, i) => turn(`restored-${i}`));
|
|
263
|
+
const entry = fakeEntry(many);
|
|
264
|
+
counters.noteAppendedTurn(entry, turn("restored-0")); // re-offer of the oldest
|
|
265
|
+
const snapshot = counters.snapshot();
|
|
266
|
+
assert.equal(snapshot.totals.accepted.turns, 1);
|
|
267
|
+
assert.equal(snapshot.totals.acceptedExactDuplicate.turns, 0, "oldest digest evicted at rebuild");
|
|
268
|
+
counters.noteAppendedTurn(entry, turn("restored-5999")); // re-offer of the newest
|
|
269
|
+
assert.equal(counters.snapshot().totals.acceptedExactDuplicate.turns, 1, "newest digest retained");
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
// NOTE (not a test): an "offered turn missing from entry.turns" case cannot be
|
|
273
|
+
// constructed against the real contract — the buffer appends before counting,
|
|
274
|
+
// and fakeEntry arrays are caller-owned. The earlier draft of this file had
|
|
275
|
+
// such a test; it failed because the premise contradicts the layer's only
|
|
276
|
+
// valid input shape, not because counting was wrong. Memo validity therefore
|
|
277
|
+
// rests on entry-array identity (WeakRef-compared), covered by the
|
|
278
|
+
// self-invalidating-memo and retained-deletion tests below.
|
|
279
|
+
|
|
280
|
+
test("deleting retainedTurns invalidates the memo even when turns keep their identity", () => {
|
|
281
|
+
// The buffer observes BEFORE pushing (recordTurnUnlocked calls
|
|
282
|
+
// noteAppendedTurn, then pushes), so the offered turn is NOT in
|
|
283
|
+
// entry.turns at count time. Re-offering content that only exists in a
|
|
284
|
+
// deleted retained array must not count as a duplicate.
|
|
285
|
+
const counters = new BufferIngressCounters();
|
|
286
|
+
const entry = fakeEntry([turn("live")]);
|
|
287
|
+
entry.retainedTurns = [turn("kept-elsewhere")];
|
|
288
|
+
// Novel content: the first offer is not itself a duplicate, so the
|
|
289
|
+
// duplicate sub-count starts at zero and the probe is the only candidate.
|
|
290
|
+
const offered = turn("something-new");
|
|
291
|
+
counters.noteAppendedTurn(entry, offered); // builds memo with retained
|
|
292
|
+
entry.turns.push(offered);
|
|
293
|
+
// White-box through the layer's own test seam: memoForTest exposes the
|
|
294
|
+
// digest set only, never the validity refs.
|
|
295
|
+
const memoBefore = counters.memoForTest(entry);
|
|
296
|
+
assert.ok(memoBefore !== undefined && memoBefore.digests instanceof Set, "memo exists after first offer");
|
|
297
|
+
const d = (c: string) => createHash("sha256").update("user\0" + c).digest("base64");
|
|
298
|
+
assert.ok(memoBefore.digests.has(d("kept-elsewhere")), "memo covers retained content before deletion");
|
|
299
|
+
const sizeBefore = memoBefore.digests.size;
|
|
300
|
+
delete entry.retainedTurns;
|
|
301
|
+
const probe = turn("kept-elsewhere");
|
|
302
|
+
counters.noteAppendedTurn(entry, probe); // matches only removed content
|
|
303
|
+
entry.turns.push(probe);
|
|
304
|
+
// Same seam; identity compared, then dropped.
|
|
305
|
+
const memoAfter = counters.memoForTest(entry);
|
|
306
|
+
assert.notEqual(memoAfter, memoBefore, "memo rebuilt after retainedTurns deletion");
|
|
307
|
+
// The re-offered probe matches only removed content, so the duplicate
|
|
308
|
+
// sub-count stays at zero — the observable behavior the fix protects.
|
|
309
|
+
assert.equal(counters.snapshot().totals.acceptedExactDuplicate.turns, 0, "removed content is not a duplicate");
|
|
310
|
+
});
|