@remnic/core 10.0.170 → 10.0.172
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 +1 -1
- package/dist/access-cli.js +1 -1
- package/dist/access-extraction-force-flush-preempt.js +1 -1
- package/dist/access-extraction-force-flush.js +1 -1
- package/dist/access-http-briefing.js +1 -1
- package/dist/access-http-query.js +1 -1
- package/dist/access-http.js +1 -1
- package/dist/access-identity-continuity-surface.js +1 -1
- package/dist/access-lcm-surface.js +1 -1
- package/dist/access-mcp.js +1 -1
- package/dist/access-observe-write-surface.js +1 -1
- package/dist/access-operations-batch.js +1 -1
- package/dist/access-operations.js +1 -1
- package/dist/access-recall-concurrency.js +1 -1
- package/dist/access-recall-response.js +1 -1
- package/dist/access-recall-surface.d.ts.map +1 -1
- package/dist/access-recall-surface.js +1 -1
- package/dist/access-service.js +1 -1
- package/dist/chat/chat-engine.d.ts +5 -3
- package/dist/chat/chat-engine.d.ts.map +1 -1
- package/dist/chat/chat-executor.d.ts +3 -4
- package/dist/chat/chat-executor.d.ts.map +1 -1
- package/dist/{chunk-QMFHKWHN.js → chunk-3MOL7YE7.js} +2 -2
- package/dist/{chunk-5YIOUS5T.js → chunk-KSIDZDW3.js} +49 -34
- package/dist/chunk-KSIDZDW3.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/correction/correction-access-wiring.d.ts +4 -1
- package/dist/correction/correction-access-wiring.d.ts.map +1 -1
- package/dist/explicit-capture.js +1 -1
- package/dist/index.js +1 -1
- package/dist/orchestration/backlog-scheduler.js +2 -2
- package/dist/orchestration/buffer-drain-runner.js +2 -2
- package/dist/orchestrator.js +1 -1
- package/dist/recall-navigation.js +1 -1
- package/package.json +2 -2
- package/src/access-recall-surface.ts +25 -24
- package/src/access-service-raw-excerpt-read-gate.test.ts +84 -2
- package/src/chat/chat-engine.ts +5 -3
- package/src/chat/chat-executor.test.ts +150 -0
- package/src/chat/chat-executor.ts +31 -20
- package/src/chat/chat-factory.ts +1 -1
- package/src/correction/correction-access-wiring.ts +4 -1
- package/dist/chunk-5YIOUS5T.js.map +0 -1
- /package/dist/{chunk-QMFHKWHN.js.map → chunk-3MOL7YE7.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
runWorkProductStatusCliCommand,
|
|
92
92
|
runWorkProjectCliCommand,
|
|
93
93
|
runWorkTaskCliCommand
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-KSIDZDW3.js";
|
|
95
95
|
import "./chunk-RK7SE3BL.js";
|
|
96
96
|
import "./chunk-GOZXQNIM.js";
|
|
97
97
|
import "./chunk-PQM3B54K.js";
|
|
@@ -119,7 +119,10 @@ declare function isEligibleCorrectionCandidate(m: MemoryFile): boolean;
|
|
|
119
119
|
* can never drift out of sync (review thread: correction-gate-config-mismatch):
|
|
120
120
|
* - nested: `config.correction.enabled`
|
|
121
121
|
* - flat: the `correctionEnabled` legacy key (ratchet-safe shape)
|
|
122
|
-
* Nested wins when present; both default to `true
|
|
122
|
+
* Nested wins when present; both default to `true`. Default-on predates the
|
|
123
|
+
* chat wiring: the executor's plan/apply tools are mutation-capable but sit
|
|
124
|
+
* behind the engine's interactive preview-confirm protocol, so enabled-by-
|
|
125
|
+
* default is intended for human-attended surfaces.
|
|
123
126
|
*/
|
|
124
127
|
export declare function isCorrectionFeatureEnabled(config: PluginConfig): boolean;
|
|
125
128
|
declare const CLASSIFY_SYSTEM_PROMPT = "You classify memory corrections and draft per-memory actions.\n\nGiven a correction statement and candidate memories, respond with a JSON object:\n{\n \"classification\": \"wrong\" | \"outdated\" | \"incomplete\" | \"wrong_scope\" | \"never_store\",\n \"confidence\": <number 0..1>,\n \"actions\": [<one or more correction actions>],\n \"relevance\": [{\"memoryId\": \"<id>\", \"why\": \"<one short sentence>\"}]\n}\n\nAction shapes:\n- {\"kind\":\"supersede\",\"loserId\":\"<id>\",\"replacement\":{\"content\":\"<new fact>\"}}\n- {\"kind\":\"supersede\",\"loserId\":\"<id>\",\"winnerId\":\"<existing id>\"}\n- {\"kind\":\"edit\",\"memoryId\":\"<id>\",\"patch\":\"<new full content>\"}\n- {\"kind\":\"retract\",\"memoryId\":\"<id>\"}\n- {\"kind\":\"rescope\",\"memoryId\":\"<id>\",\"toNamespace\":\"<ns>\"}\n- {\"kind\":\"redaction_rule\",\"pattern\":\"<bounded literal or regex>\"}\n\nOnly emit actions you are confident in. If uncertain, return confidence < 0.5 and few actions.";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"correction-access-wiring.d.ts","sourceRoot":"","sources":["../../src/correction/correction-access-wiring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAgB,YAAY,EAAE,MAAM,aAAa,CAAC;AAM1E,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EAEtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAA8B,MAAM,yBAAyB,CAAC;AASxF;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,YAAY,CAAC;IAC3B,6EAA6E;IAC7E,0BAA0B,CAAC,OAAO,EAAE;QAClC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,8EAA8E;IAC9E,yBAAyB,CAAC,OAAO,EAAE;QACjC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,M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AS,EAAE,MAAM,EACjB,MAAM,EAAE;IACN,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACjD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB,EACD,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,MAAM,CAAC,CAuBjB;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACjD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,MAAM,CA4BT;AAkDD;;;;;;;;;GASG;AACH,iBAAS,6BAA6B,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAK7D;AAkCD
|
|
1
|
+
{"version":3,"file":"correction-access-wiring.d.ts","sourceRoot":"","sources":["../../src/correction/correction-access-wiring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAgB,YAAY,EAAE,MAAM,aAAa,CAAC;AAM1E,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EAEtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAA8B,MAAM,yBAAyB,CAAC;AASxF;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,YAAY,CAAC;IAC3B,6EAA6E;IAC7E,0BAA0B,CAAC,OAAO,EAAE;QAClC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,M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f,sBAAsB,GACvB,CAAC"}
|
package/dist/explicit-capture.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
shouldSkipImplicitExtraction,
|
|
9
9
|
stripInlineExplicitCaptureNotes,
|
|
10
10
|
validateExplicitCaptureInput
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-KSIDZDW3.js";
|
|
12
12
|
import "./chunk-RK7SE3BL.js";
|
|
13
13
|
import "./chunk-GOZXQNIM.js";
|
|
14
14
|
import "./chunk-PQM3B54K.js";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BufferDrainRunner,
|
|
3
3
|
ClaimBufferStorage
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-3MOL7YE7.js";
|
|
5
|
+
import "../chunk-KSIDZDW3.js";
|
|
6
6
|
import "../chunk-RK7SE3BL.js";
|
|
7
7
|
import "../chunk-GOZXQNIM.js";
|
|
8
8
|
import "../chunk-PQM3B54K.js";
|
package/dist/orchestrator.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
mergeGraphExpandedResults,
|
|
7
7
|
qmdStartupCollectionChecksWithTimeout,
|
|
8
8
|
resolveEffectiveIdentityInjectionMode
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-KSIDZDW3.js";
|
|
10
10
|
import "./chunk-RK7SE3BL.js";
|
|
11
11
|
import "./chunk-GOZXQNIM.js";
|
|
12
12
|
import "./chunk-PQM3B54K.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remnic/core",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.172",
|
|
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.172"
|
|
3420
3420
|
},
|
|
3421
3421
|
"peerDependenciesMeta": {
|
|
3422
3422
|
"@remnic/coding-graph": {
|
|
@@ -1098,9 +1098,8 @@ export class AccessRecallSurface {
|
|
|
1098
1098
|
},
|
|
1099
1099
|
);
|
|
1100
1100
|
recallStartedAt = capturedRecallStartedAt;
|
|
1101
|
-
// Cancellation covers queueing
|
|
1102
|
-
//
|
|
1103
|
-
// begin that work after the caller has already canceled.
|
|
1101
|
+
// Cancellation covers queueing, capture, and post-capture shaping:
|
|
1102
|
+
// a check sits at each mid-I/O boundary below (issue #3547).
|
|
1104
1103
|
throwIfAborted(request.abortSignal, "recall X-ray aborted before postprocessing");
|
|
1105
1104
|
// Re-check namespace after capture: the recall may have served
|
|
1106
1105
|
// from a different namespace than the caller requested. Drop
|
|
@@ -1152,6 +1151,7 @@ export class AccessRecallSurface {
|
|
|
1152
1151
|
}
|
|
1153
1152
|
}),
|
|
1154
1153
|
);
|
|
1154
|
+
throwIfAborted(request.abortSignal, "recall X-ray aborted during tag filtering");
|
|
1155
1155
|
const tagged = snapshot.results.map((result, index) => ({
|
|
1156
1156
|
result,
|
|
1157
1157
|
tags: tagsByIndex[index] ?? [],
|
|
@@ -1233,6 +1233,7 @@ export class AccessRecallSurface {
|
|
|
1233
1233
|
authenticatedPrincipal,
|
|
1234
1234
|
)
|
|
1235
1235
|
: undefined;
|
|
1236
|
+
throwIfAborted(request.abortSignal, "recall X-ray aborted before raw-excerpt fetch");
|
|
1236
1237
|
const rawExcerpts =
|
|
1237
1238
|
disclosure === "raw" && !rawExcerptsSuppressed
|
|
1238
1239
|
? await this.deps.fetchRawExcerpts(disclosure, {
|
|
@@ -1262,6 +1263,7 @@ export class AccessRecallSurface {
|
|
|
1262
1263
|
// updated, tags, entityRef) in the token estimate, so the
|
|
1263
1264
|
// summary reflects real spend rather than only payload-body
|
|
1264
1265
|
// spend (Cursor Low review on PR #699).
|
|
1266
|
+
throwIfAborted(request.abortSignal, "recall X-ray aborted before result reads");
|
|
1265
1267
|
const memoryByIndex = await Promise.all(
|
|
1266
1268
|
snapshot.results.map(async (result) => {
|
|
1267
1269
|
try {
|
|
@@ -1272,9 +1274,11 @@ export class AccessRecallSurface {
|
|
|
1272
1274
|
}
|
|
1273
1275
|
}),
|
|
1274
1276
|
);
|
|
1277
|
+
throwIfAborted(request.abortSignal, "recall X-ray aborted during result reads");
|
|
1275
1278
|
const firstReadableIndex = memoryByIndex.findIndex((m) => m !== null);
|
|
1276
1279
|
const baseDir =
|
|
1277
1280
|
(await this.deps.orchestrator.getStorage(namespace)).dir;
|
|
1281
|
+
throwIfAborted(request.abortSignal, "recall X-ray aborted during result decoration");
|
|
1278
1282
|
const decorated = snapshot.results.map((result, index) => {
|
|
1279
1283
|
const memory = memoryByIndex[index];
|
|
1280
1284
|
if (!memory) {
|
|
@@ -1378,28 +1382,25 @@ export class AccessRecallSurface {
|
|
|
1378
1382
|
authenticatedPrincipal,
|
|
1379
1383
|
)
|
|
1380
1384
|
: undefined;
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
? { rawExcerptNamespace: xrayRawExcerptNamespace }
|
|
1394
|
-
: {}),
|
|
1395
|
-
...(xrayRawExcerptSessionIds !== undefined
|
|
1396
|
-
? { rawExcerptSessionIds: xrayRawExcerptSessionIds }
|
|
1397
|
-
: {}),
|
|
1398
|
-
...(xrayRawExcerptsSuppressed
|
|
1399
|
-
? { rawExcerptsSuppressed: xrayRawExcerptsSuppressed }
|
|
1400
|
-
: {}),
|
|
1401
|
-
}),
|
|
1385
|
+
throwIfAborted(request.abortSignal, "recall X-ray aborted before recall response build");
|
|
1386
|
+
const recallArgs: Parameters<
|
|
1387
|
+
AccessRecallSurfaceDeps["buildRecallResponseFromXraySnapshot"]
|
|
1388
|
+
>[0] = {
|
|
1389
|
+
query,
|
|
1390
|
+
sessionKey: recallSessionKey,
|
|
1391
|
+
snapshot: xrayResponse.snapshot,
|
|
1392
|
+
disclosure,
|
|
1393
|
+
startedAt: recallStartedAt,
|
|
1394
|
+
requestedMode: request.mode,
|
|
1395
|
+
normalizedMode: mode,
|
|
1396
|
+
storageCorpusVersionsAtRecallStart,
|
|
1402
1397
|
};
|
|
1398
|
+
if (xrayRawExcerptNamespace) recallArgs.rawExcerptNamespace = xrayRawExcerptNamespace;
|
|
1399
|
+
if (xrayRawExcerptSessionIds !== undefined) recallArgs.rawExcerptSessionIds = xrayRawExcerptSessionIds;
|
|
1400
|
+
if (xrayRawExcerptsSuppressed) recallArgs.rawExcerptsSuppressed = xrayRawExcerptsSuppressed;
|
|
1401
|
+
const recallResponse = await this.deps.buildRecallResponseFromXraySnapshot(recallArgs);
|
|
1402
|
+
throwIfAborted(request.abortSignal, "recall X-ray aborted after recall response build");
|
|
1403
|
+
return { ...xrayResponse, recall: recallResponse };
|
|
1403
1404
|
}
|
|
1404
1405
|
return xrayResponse;
|
|
1405
1406
|
}
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
projectNamespaceName,
|
|
40
40
|
projectTagProjectId,
|
|
41
41
|
} from "./coding/coding-namespace.js";
|
|
42
|
+
import type { RecallXraySnapshot } from "./recall-xray.js";
|
|
42
43
|
import type { StorageManager } from "./storage.js";
|
|
43
44
|
import type { RecallExecResult } from "./access-recall-concurrency.js";
|
|
44
45
|
import type { CodingContext, MemoryFile, PluginConfig } from "./types.js";
|
|
@@ -64,6 +65,12 @@ function makeRawExcerptProbe(options: {
|
|
|
64
65
|
snapshotNamespace: string;
|
|
65
66
|
sessionContext?: CodingContext;
|
|
66
67
|
sessionKey: string;
|
|
68
|
+
/** Called inside the readMemoryByPath stub — used to fire a mid-I/O abort. */
|
|
69
|
+
onMemoryRead?: (path: string) => void;
|
|
70
|
+
/** Value the readMemoryByPath stub resolves. */
|
|
71
|
+
memoryFixture?: MemoryFile;
|
|
72
|
+
/** Snapshot the recallWithXrayCapture stub returns (null → empty x-ray). */
|
|
73
|
+
xraySnapshot?: RecallXraySnapshot | null;
|
|
67
74
|
/** snapshot.memoryIds → getMemoryById fixtures (recall results path). */
|
|
68
75
|
memories?: ReadonlyMap<string, MemoryFile>;
|
|
69
76
|
/** Rows the LCM stub's `searchContextFull` returns. */
|
|
@@ -115,8 +122,9 @@ function makeRawExcerptProbe(options: {
|
|
|
115
122
|
|
|
116
123
|
const storage = probeCast<StorageManager>({
|
|
117
124
|
dir: "/synthetic/remnic-raw-excerpt-read-gate/store",
|
|
118
|
-
async readMemoryByPath() {
|
|
119
|
-
|
|
125
|
+
async readMemoryByPath(path: string) {
|
|
126
|
+
options.onMemoryRead?.(path);
|
|
127
|
+
return options.memoryFixture ?? null;
|
|
120
128
|
},
|
|
121
129
|
async getMemoryById(id: string) {
|
|
122
130
|
return options.memories?.get(id) ?? null;
|
|
@@ -150,6 +158,12 @@ function makeRawExcerptProbe(options: {
|
|
|
150
158
|
async recall() {
|
|
151
159
|
return "";
|
|
152
160
|
},
|
|
161
|
+
async recallWithXrayCapture() {
|
|
162
|
+
return {
|
|
163
|
+
snapshot: options.xraySnapshot ?? null,
|
|
164
|
+
recallStartedAt: Date.now(),
|
|
165
|
+
};
|
|
166
|
+
},
|
|
153
167
|
lcmEngine: {
|
|
154
168
|
enabled: true,
|
|
155
169
|
searchContextFull: async (
|
|
@@ -680,3 +694,71 @@ test("#3546: quotes under the attribution length floor claim nothing", async ()
|
|
|
680
694
|
"below-floor quotes keep the excerpt on the first result",
|
|
681
695
|
);
|
|
682
696
|
});
|
|
697
|
+
|
|
698
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
699
|
+
// #3547: an abort that lands during post-capture shaping stops the
|
|
700
|
+
// pipeline — shaping must not run to completion for a canceled caller.
|
|
701
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
702
|
+
|
|
703
|
+
test("#3547: abort during x-ray decoration reads throws AbortError instead of completing", async () => {
|
|
704
|
+
const controller = new AbortController();
|
|
705
|
+
const snapshot: RecallXraySnapshot = {
|
|
706
|
+
schemaVersion: "1",
|
|
707
|
+
query: "what database are we using?",
|
|
708
|
+
snapshotId: "xray-3547",
|
|
709
|
+
capturedAt: Date.now(),
|
|
710
|
+
sessionKey: SESSION_KEY,
|
|
711
|
+
namespace: "pi-geek",
|
|
712
|
+
tierExplain: null,
|
|
713
|
+
results: [
|
|
714
|
+
{
|
|
715
|
+
memoryId: "mem-a",
|
|
716
|
+
path: "facts/a.md",
|
|
717
|
+
servedBy: "hybrid",
|
|
718
|
+
scoreDecomposition: { final: 0.9 },
|
|
719
|
+
admittedBy: ["budget", "namespace"],
|
|
720
|
+
},
|
|
721
|
+
],
|
|
722
|
+
appliedResultLimit: 10,
|
|
723
|
+
appliedResults: [],
|
|
724
|
+
headroomResults: [],
|
|
725
|
+
filters: [],
|
|
726
|
+
budget: { chars: 8000, used: 100 },
|
|
727
|
+
};
|
|
728
|
+
const probe = makeRawExcerptProbe({
|
|
729
|
+
config: { principalFromSessionKeyRules: [{ match: "pi-geek:", principal: "pi-geek" }] },
|
|
730
|
+
snapshotNamespace: "pi-geek",
|
|
731
|
+
sessionKey: SESSION_KEY,
|
|
732
|
+
xraySnapshot: snapshot,
|
|
733
|
+
// The cancel lands mid-I/O: the first result read aborts the caller's
|
|
734
|
+
// signal, then the read resolves. Post-capture shaping must notice
|
|
735
|
+
// before continuing the pipeline.
|
|
736
|
+
onMemoryRead: () => controller.abort(),
|
|
737
|
+
memoryFixture: {
|
|
738
|
+
path: "facts/a.md",
|
|
739
|
+
content: "synthetic memory body",
|
|
740
|
+
frontmatter: {
|
|
741
|
+
id: "mem-a",
|
|
742
|
+
category: "preference",
|
|
743
|
+
created: "2026-11-01T00:00:00Z",
|
|
744
|
+
updated: "2026-11-01T00:00:00Z",
|
|
745
|
+
source: "test",
|
|
746
|
+
confidence: 0.9,
|
|
747
|
+
confidenceTier: "explicit",
|
|
748
|
+
tags: [],
|
|
749
|
+
},
|
|
750
|
+
},
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
await assert.rejects(
|
|
754
|
+
probe.service.recallXray({
|
|
755
|
+
query: "what database are we using?",
|
|
756
|
+
sessionKey: SESSION_KEY,
|
|
757
|
+
authenticatedPrincipal: "pi-geek",
|
|
758
|
+
disclosure: "section",
|
|
759
|
+
abortSignal: controller.signal,
|
|
760
|
+
}),
|
|
761
|
+
(err: Error) => err.name === "AbortError",
|
|
762
|
+
"a cancel that lands during result decoration must abort the pipeline",
|
|
763
|
+
);
|
|
764
|
+
});
|
package/src/chat/chat-engine.ts
CHANGED
|
@@ -52,12 +52,14 @@ export interface ChatToolExecutor {
|
|
|
52
52
|
scopeInspect(): Promise<string>;
|
|
53
53
|
/**
|
|
54
54
|
* Generate a correction plan. Returns a JSON string with a planId and
|
|
55
|
-
* a diff preview
|
|
56
|
-
* this is a stub that returns a not-available marker.
|
|
55
|
+
* a diff preview, backed by the Correction Contract (#1580) pipeline.
|
|
57
56
|
*/
|
|
58
57
|
correctionPlan(request: string): Promise<{ planId: string; preview: string }>;
|
|
59
58
|
/**
|
|
60
|
-
* Apply a correction plan. Returns a JSON result string.
|
|
59
|
+
* Apply a correction plan. Returns a JSON result string. Implementations
|
|
60
|
+
* pass `confirm: true` to the service; the engine's preview-confirm
|
|
61
|
+
* protocol is the consent that satisfies the apply gate, so this method
|
|
62
|
+
* must stay reachable only through the engine's confirmation flow.
|
|
61
63
|
*/
|
|
62
64
|
correctionApply(planId: string): Promise<string>;
|
|
63
65
|
/**
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { EngramAccessService } from "../access-service.js";
|
|
4
|
+
import type {
|
|
5
|
+
CorrectionOutcome,
|
|
6
|
+
CorrectionPlan,
|
|
7
|
+
CorrectionRequest,
|
|
8
|
+
} from "../correction/index.js";
|
|
9
|
+
import { createChatExecutor } from "./chat-executor.js";
|
|
10
|
+
|
|
11
|
+
interface ApplyOpts {
|
|
12
|
+
confirm?: boolean;
|
|
13
|
+
namespace?: string;
|
|
14
|
+
sessionKey?: string;
|
|
15
|
+
principal?: string;
|
|
16
|
+
abortSignal?: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface ListPendingOpts {
|
|
20
|
+
namespace?: string;
|
|
21
|
+
sessionKey?: string;
|
|
22
|
+
principal?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface CapturedCalls {
|
|
26
|
+
planRequests: CorrectionRequest[];
|
|
27
|
+
applyPlanIds: string[];
|
|
28
|
+
applyOpts: ApplyOpts[];
|
|
29
|
+
listOpts: ListPendingOpts[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Minimal correction surface; captures the args the executor sends. */
|
|
33
|
+
function fakeCorrectionService(calls: CapturedCalls, pending: CorrectionPlan[]): EngramAccessService {
|
|
34
|
+
// SAFETY: the double implements only the three correction methods the
|
|
35
|
+
// executor calls; no other EngramAccessService member is reached here.
|
|
36
|
+
const service = Object.create(EngramAccessService.prototype) as EngramAccessService;
|
|
37
|
+
service.correctionPlan = async (request: CorrectionRequest): Promise<CorrectionPlan> => {
|
|
38
|
+
calls.planRequests.push(request);
|
|
39
|
+
return {
|
|
40
|
+
planId: "corr-real-1",
|
|
41
|
+
request,
|
|
42
|
+
namespace: "ns",
|
|
43
|
+
affected: [],
|
|
44
|
+
classification: "wrong",
|
|
45
|
+
actions: [],
|
|
46
|
+
diff: "DIFF: rewrite fact",
|
|
47
|
+
confidence: 0.9,
|
|
48
|
+
warnings: [],
|
|
49
|
+
createdAt: "t",
|
|
50
|
+
expiresAt: "t+1h",
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
service.correctionApply = async (planId: string, opts: ApplyOpts): Promise<CorrectionOutcome> => {
|
|
54
|
+
calls.applyPlanIds.push(planId);
|
|
55
|
+
calls.applyOpts.push(opts);
|
|
56
|
+
return {
|
|
57
|
+
planId,
|
|
58
|
+
status: "applied",
|
|
59
|
+
results: [],
|
|
60
|
+
auditMemoryId: "audit-1",
|
|
61
|
+
appliedAt: "t",
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
service.correctionListPending = async (opts: ListPendingOpts): Promise<CorrectionPlan[]> => {
|
|
65
|
+
calls.listOpts.push(opts);
|
|
66
|
+
return pending;
|
|
67
|
+
};
|
|
68
|
+
return service;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function emptyCalls(): CapturedCalls {
|
|
72
|
+
return { planRequests: [], applyPlanIds: [], applyOpts: [], listOpts: [] };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
test("correctionPlan delegates to the access-service plan path", async () => {
|
|
76
|
+
const calls = emptyCalls();
|
|
77
|
+
const executor = createChatExecutor({
|
|
78
|
+
service: fakeCorrectionService(calls, []),
|
|
79
|
+
principal: "reader",
|
|
80
|
+
namespace: "team",
|
|
81
|
+
sessionKey: "sess-1",
|
|
82
|
+
});
|
|
83
|
+
const plan = await executor.correctionPlan("the deploy day is wrong");
|
|
84
|
+
assert.equal(plan.planId, "corr-real-1");
|
|
85
|
+
assert.equal(plan.preview, "DIFF: rewrite fact");
|
|
86
|
+
const request = calls.planRequests[0];
|
|
87
|
+
assert.equal(request?.text, "the deploy day is wrong");
|
|
88
|
+
assert.equal(request?.sessionKey, "sess-1");
|
|
89
|
+
assert.equal(request?.principal, "reader");
|
|
90
|
+
assert.equal(request?.namespace, "team");
|
|
91
|
+
// The stub marker must be gone.
|
|
92
|
+
assert.ok(!plan.planId.startsWith("stub-"));
|
|
93
|
+
assert.ok(!plan.preview.includes("not yet available"));
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("correctionPlan retrieves a pending plan preview for the engine sentinel", async () => {
|
|
97
|
+
const calls = emptyCalls();
|
|
98
|
+
const pending: CorrectionPlan[] = [
|
|
99
|
+
{
|
|
100
|
+
planId: "corr-9",
|
|
101
|
+
request: { text: "prior request" },
|
|
102
|
+
namespace: "ns",
|
|
103
|
+
affected: [],
|
|
104
|
+
classification: "outdated",
|
|
105
|
+
actions: [],
|
|
106
|
+
diff: "DIFF: pending preview",
|
|
107
|
+
confidence: 0.8,
|
|
108
|
+
warnings: [],
|
|
109
|
+
createdAt: "t",
|
|
110
|
+
expiresAt: "t+1h",
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
const executor = createChatExecutor({
|
|
114
|
+
service: fakeCorrectionService(calls, pending),
|
|
115
|
+
sessionKey: "sess-1",
|
|
116
|
+
});
|
|
117
|
+
const plan = await executor.correctionPlan("retrieve plan corr-9");
|
|
118
|
+
assert.equal(plan.planId, "corr-9");
|
|
119
|
+
assert.equal(plan.preview, "DIFF: pending preview");
|
|
120
|
+
assert.equal(calls.planRequests.length, 0, "sentinel must not mint a new plan");
|
|
121
|
+
assert.equal(calls.listOpts.length, 1);
|
|
122
|
+
await assert.rejects(
|
|
123
|
+
() => executor.correctionPlan("retrieve plan corr-missing"),
|
|
124
|
+
/not found|expired/i,
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("correctionApply delegates with confirm and the bound identity", async () => {
|
|
129
|
+
const calls = emptyCalls();
|
|
130
|
+
const executor = createChatExecutor({
|
|
131
|
+
service: fakeCorrectionService(calls, []),
|
|
132
|
+
principal: "writer",
|
|
133
|
+
namespace: "team",
|
|
134
|
+
sessionKey: "sess-2",
|
|
135
|
+
});
|
|
136
|
+
// SAFETY: correctionApply JSON.stringify's the service outcome, so the
|
|
137
|
+
// parsed shape is the CorrectionOutcome the fake returned.
|
|
138
|
+
const out = JSON.parse(await executor.correctionApply("corr-real-1")) as {
|
|
139
|
+
status: string;
|
|
140
|
+
auditMemoryId: string;
|
|
141
|
+
};
|
|
142
|
+
assert.equal(out.status, "applied");
|
|
143
|
+
assert.equal(out.auditMemoryId, "audit-1");
|
|
144
|
+
assert.equal(calls.applyPlanIds[0], "corr-real-1");
|
|
145
|
+
const opts = calls.applyOpts[0];
|
|
146
|
+
assert.equal(opts?.confirm, true);
|
|
147
|
+
assert.equal(opts?.sessionKey, "sess-2");
|
|
148
|
+
assert.equal(opts?.principal, "writer");
|
|
149
|
+
assert.equal(opts?.namespace, "team");
|
|
150
|
+
});
|
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
* session's principal/namespace/sessionKey so every tool call flows through
|
|
7
7
|
* access-service with the caller's identity (rule 42).
|
|
8
8
|
*
|
|
9
|
-
* Correction tools (correction_plan / correction_apply / memory_promote)
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* surfaces degrade gracefully.
|
|
9
|
+
* Correction tools (correction_plan / correction_apply / memory_promote)
|
|
10
|
+
* delegate to the Correction Contract (#1580) plan/apply pipeline through
|
|
11
|
+
* the access-service.
|
|
13
12
|
*/
|
|
14
13
|
|
|
15
14
|
import type { EngramAccessService } from "../access-service.js";
|
|
@@ -27,6 +26,10 @@ export interface ChatExecutorBindings {
|
|
|
27
26
|
*/
|
|
28
27
|
export function createChatExecutor(bindings: ChatExecutorBindings): ChatToolExecutor {
|
|
29
28
|
const { service, principal, namespace, sessionKey } = bindings;
|
|
29
|
+
const correctionScope: Parameters<EngramAccessService["correctionListPending"]>[0] = {};
|
|
30
|
+
if (namespace) correctionScope.namespace = namespace;
|
|
31
|
+
if (sessionKey) correctionScope.sessionKey = sessionKey;
|
|
32
|
+
if (principal) correctionScope.principal = principal;
|
|
30
33
|
|
|
31
34
|
return {
|
|
32
35
|
async memorySearch(query: string, maxResults?: number): Promise<string> {
|
|
@@ -86,28 +89,36 @@ export function createChatExecutor(bindings: ChatExecutorBindings): ChatToolExec
|
|
|
86
89
|
});
|
|
87
90
|
},
|
|
88
91
|
|
|
89
|
-
// ── Correction tools —
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
// single-file change here.
|
|
92
|
+
// ── Correction tools — Correction Contract (#1580) ─────────────────
|
|
93
|
+
// Thin adapters over the service's plan/apply pipeline. The engine's
|
|
94
|
+
// confirmation interception asks for a pending plan's preview via the
|
|
95
|
+
// "retrieve plan <id>" sentinel; that is a lookup, not a new plan.
|
|
94
96
|
|
|
95
97
|
async correctionPlan(request: string): Promise<{ planId: string; preview: string }> {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
const retrieve = /^retrieve plan (\S+)$/i.exec(request.trim());
|
|
99
|
+
if (retrieve) {
|
|
100
|
+
const pending = await service.correctionListPending(correctionScope);
|
|
101
|
+
const plan = pending.find((p) => p.planId === retrieve[1]);
|
|
102
|
+
if (!plan) {
|
|
103
|
+
throw new Error(`Correction plan ${retrieve[1]} not found or expired.`);
|
|
104
|
+
}
|
|
105
|
+
return { planId: plan.planId, preview: plan.diff };
|
|
106
|
+
}
|
|
107
|
+
const plan = await service.correctionPlan({
|
|
108
|
+
text: request,
|
|
109
|
+
...correctionScope,
|
|
110
|
+
});
|
|
111
|
+
return { planId: plan.planId, preview: plan.diff };
|
|
102
112
|
},
|
|
103
113
|
|
|
104
114
|
async correctionApply(planId: string): Promise<string> {
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
// The engine's confirmation protocol is the explicit consent; pass it
|
|
116
|
+
// through as confirm so the apply gate sees a confirmed call.
|
|
117
|
+
const outcome = await service.correctionApply(planId, {
|
|
118
|
+
confirm: true,
|
|
119
|
+
...correctionScope,
|
|
110
120
|
});
|
|
121
|
+
return JSON.stringify(outcome);
|
|
111
122
|
},
|
|
112
123
|
|
|
113
124
|
async memoryPromote(memoryId: string): Promise<string> {
|
package/src/chat/chat-factory.ts
CHANGED
|
@@ -62,7 +62,7 @@ export function createChatEngine(opts: ChatEngineFactoryOptions): ChatEngine | n
|
|
|
62
62
|
executor,
|
|
63
63
|
maxToolCallsPerTurn: opts.config.maxToolCallsPerTurn,
|
|
64
64
|
...(opts.config.model ? { model: opts.config.model } : {}),
|
|
65
|
-
correctionAvailable:
|
|
65
|
+
correctionAvailable: opts.service.correctionSurfaceVisible,
|
|
66
66
|
scopeInspectAvailable: false,
|
|
67
67
|
});
|
|
68
68
|
}
|
|
@@ -947,7 +947,10 @@ function toExecutorMemory(m: MemoryFile): ExecutorMemory {
|
|
|
947
947
|
* can never drift out of sync (review thread: correction-gate-config-mismatch):
|
|
948
948
|
* - nested: `config.correction.enabled`
|
|
949
949
|
* - flat: the `correctionEnabled` legacy key (ratchet-safe shape)
|
|
950
|
-
* Nested wins when present; both default to `true
|
|
950
|
+
* Nested wins when present; both default to `true`. Default-on predates the
|
|
951
|
+
* chat wiring: the executor's plan/apply tools are mutation-capable but sit
|
|
952
|
+
* behind the engine's interactive preview-confirm protocol, so enabled-by-
|
|
953
|
+
* default is intended for human-attended surfaces.
|
|
951
954
|
*/
|
|
952
955
|
export function isCorrectionFeatureEnabled(config: PluginConfig): boolean {
|
|
953
956
|
// parseConfig now resolves this into `resolveRecallAuxiliaryCapabilities(config).correction` (review
|