nox-mem 3.3.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +82 -31
  2. package/dist/api/answer.js +22 -0
  3. package/dist/api-server.js +22 -3
  4. package/dist/cli/answer.js +39 -1
  5. package/dist/db.js +47 -24
  6. package/dist/doctor.js +108 -29
  7. package/dist/embed.js +53 -3
  8. package/dist/index.js +73 -17
  9. package/dist/lib/answer/index.js +3 -2
  10. package/dist/lib/answer/retrieval.js +6 -4
  11. package/dist/lib/answer/temporal.js +51 -0
  12. package/dist/lib/api-port.js +16 -0
  13. package/dist/lib/dates.js +98 -0
  14. package/dist/lib/db-path.js +57 -0
  15. package/dist/lib/ingest-many.js +49 -0
  16. package/dist/lib/op-audit.js +19 -12
  17. package/dist/lib/reranker.js +4 -1
  18. package/dist/mcp/tools/answer.js +23 -0
  19. package/dist/mcp-server.js +45 -6
  20. package/dist/reflect.js +2 -2
  21. package/dist/reindex-errors.js +45 -0
  22. package/dist/reindex.js +116 -23
  23. package/dist/search.js +111 -16
  24. package/package.json +7 -2
  25. package/prompts/consolidate.txt +13 -0
  26. package/prompts/digest.txt +5 -0
  27. package/dist/__tests__/brief-diversity.test.js +0 -266
  28. package/dist/__tests__/brief.test.js +0 -287
  29. package/dist/__tests__/churn.test.js +0 -66
  30. package/dist/__tests__/edge-typing.test.js +0 -99
  31. package/dist/__tests__/ingest-event.test.js +0 -151
  32. package/dist/__tests__/op-audit-e2e.test.js +0 -130
  33. package/dist/__tests__/pragma-alignment.test.js +0 -123
  34. package/dist/__tests__/reranker.test.js +0 -326
  35. package/dist/__tests__/retention.test.js +0 -99
  36. package/dist/__tests__/search-track-access.test.js +0 -49
  37. package/dist/__tests__/session-distill-sources.test.js +0 -98
  38. package/dist/__tests__/spo-injection.test.js +0 -172
  39. package/dist/__tests__/telemetry-per-chunk.test.js +0 -110
  40. package/dist/__tests__/temporal-detector.test.js +0 -103
  41. package/dist/lib/answer/__tests__/e2e-gemini.test.js +0 -229
  42. package/dist/lib/answer/__tests__/integration-sqlite.test.js +0 -388
  43. package/dist/lib/answer/__tests__/integration.test.js +0 -347
  44. package/dist/lib/answer/__tests__/prompt.test.js +0 -117
  45. package/dist/lib/answer/__tests__/t5-t10.test.js +0 -501
  46. package/dist/lib/api/__tests__/safe-error-message.test.js +0 -155
  47. package/dist/lib/auth/__tests__/localhost-guard.test.js +0 -144
  48. package/dist/lib/error-sanitizer/__tests__/sanitize.test.js +0 -354
  49. package/dist/lib/events/__tests__/bus.test.js +0 -208
  50. package/dist/lib/op-audit-extension/__tests__/ran-at-guard.test.js +0 -109
  51. package/dist/lib/regex-extract/__tests__/extractor.test.js +0 -197
  52. package/dist/lib/regex-extract/__tests__/frontmatter.test.js +0 -75
  53. package/dist/lib/regex-extract/__tests__/ingest-router-l4.test.js +0 -139
  54. package/dist/lib/regex-extract/__tests__/production-wire.test.js +0 -177
  55. package/dist/lib/regex-extract/__tests__/reconcile.test.js +0 -170
  56. package/dist/lib/regex-extract/__tests__/strip-code.test.js +0 -36
  57. package/dist/privacy/__tests__/filter.test.js +0 -352
  58. package/dist/providers/__tests__/conformance-extended.test.js +0 -249
  59. package/dist/providers/__tests__/conformance.test.js +0 -98
  60. package/dist/providers/__tests__/cost-cap.test.js +0 -151
  61. package/dist/providers/__tests__/e2e-real.test.js +0 -79
  62. package/dist/providers/__tests__/factory.test.js +0 -80
  63. package/dist/providers/__tests__/fallback.test.js +0 -223
  64. package/dist/providers/__tests__/gemini.test.js +0 -191
  65. package/dist/providers/__tests__/health.test.js +0 -128
  66. package/dist/providers/__tests__/telemetry.test.js +0 -219
@@ -1,347 +0,0 @@
1
- /**
2
- * src/lib/answer/__tests__/integration.test.ts
3
- *
4
- * T1-T4 integration tests: end-to-end answer() with mocked retrieval +
5
- * mocked LLM provider. No network, no DB, deterministic.
6
- *
7
- * Runner: node:test (node --test)
8
- *
9
- * Coverage (15+ cases):
10
- * - retrieval wrapper: marker_id assignment, dedupe by content_hash, topK cap
11
- * - prompt builder: system/user shape, chunk markers preserved
12
- * - provider: selectProvider returns gemini default, mock honours queue
13
- * - end-to-end: tokens accounted, latency_ms > 0, citations resolved
14
- * - empty retrieval → canonical "no memory matches"
15
- * - hallucinated citation → retry with strict prompt
16
- * - hallucination after retry → throws AnswerError(hallucination_after_retry)
17
- * - provider throws → AnswerError(llm_error)
18
- * - empty question → AnswerError(invalid_input)
19
- * - env model override
20
- * - retrieval ordering: marker_id 1..N in result citations
21
- */
22
- import { describe, it } from "node:test";
23
- import assert from "node:assert/strict";
24
- import { answer, AnswerError, parseCitations, retrieveContext, __setRawSearchForTests, selectProvider, MockProvider, buildPrompt, buildRetryPrompt, } from "../index.js";
25
- // ─── Fixtures ──────────────────────────────────────────────────────────────
26
- function fixtureChunks() {
27
- return [
28
- {
29
- chunk_id: 101,
30
- file_path: "memory/entities/decision/d41.md",
31
- line_range: "L10-L20",
32
- content: "D41 #1: default model is gemini-2.5-flash-lite per Toto morning review.",
33
- content_hash: "h-d41",
34
- score: 0.92,
35
- },
36
- {
37
- chunk_id: 202,
38
- file_path: "memory/entities/feedback/salience.md",
39
- content: "Salience formula: salience = recency × pain × importance.",
40
- content_hash: "h-salience",
41
- score: 0.88,
42
- },
43
- {
44
- chunk_id: 303,
45
- file_path: "memory/entities/lesson/never-sed-binary.md",
46
- content: "Never sed -i on .db files — corrupts page boundaries.",
47
- content_hash: "h-sed",
48
- score: 0.71,
49
- },
50
- // Near-duplicate of 303 — should be deduped by content_hash.
51
- {
52
- chunk_id: 304,
53
- file_path: "memory/entities/lesson/never-sed-binary.md",
54
- content: "Never sed -i on .db files — corrupts page boundaries.",
55
- content_hash: "h-sed",
56
- score: 0.65,
57
- },
58
- ];
59
- }
60
- function bindFixtureSearch(chunks = fixtureChunks()) {
61
- __setRawSearchForTests(async (_q, _k) => {
62
- void _q;
63
- void _k;
64
- return chunks;
65
- });
66
- }
67
- // ─── retrieval.ts ──────────────────────────────────────────────────────────
68
- describe("retrieveContext", () => {
69
- it("returns chunks with marker_id assigned 1..N in score-desc order", async () => {
70
- bindFixtureSearch();
71
- const got = await retrieveContext("anything", 8);
72
- assert.ok(got.length > 0);
73
- assert.strictEqual(got[0]?.marker_id, "chunk_1");
74
- assert.strictEqual(got[1]?.marker_id, "chunk_2");
75
- // chunk_id 101 has highest score → must be marker_id chunk_1
76
- assert.strictEqual(got[0]?.chunk_id, 101);
77
- });
78
- it("dedupes near-duplicates by content_hash, keeping highest score", async () => {
79
- bindFixtureSearch();
80
- const got = await retrieveContext("anything", 8);
81
- const ids = got.map((c) => c.chunk_id);
82
- assert.ok(ids.includes(303), "high-score dup survivor present");
83
- assert.ok(!ids.includes(304), "low-score dup filtered out");
84
- });
85
- it("caps results to topK", async () => {
86
- bindFixtureSearch();
87
- const got = await retrieveContext("anything", 2);
88
- assert.strictEqual(got.length, 2);
89
- assert.strictEqual(got[0]?.marker_id, "chunk_1");
90
- assert.strictEqual(got[1]?.marker_id, "chunk_2");
91
- });
92
- it("returns [] for empty question", async () => {
93
- bindFixtureSearch();
94
- const got = await retrieveContext(" ", 8);
95
- assert.deepStrictEqual(got, []);
96
- });
97
- it("returns [] when topK is 0", async () => {
98
- bindFixtureSearch();
99
- const got = await retrieveContext("anything", 0);
100
- assert.deepStrictEqual(got, []);
101
- });
102
- });
103
- // ─── prompt.ts ─────────────────────────────────────────────────────────────
104
- describe("buildPrompt", () => {
105
- it("system message contains anti-hallucination guard", () => {
106
- const chunks = [
107
- {
108
- chunk_id: 1,
109
- marker_id: "chunk_1",
110
- file_path: "x.md",
111
- content: "alpha",
112
- score: 1,
113
- },
114
- ];
115
- const { system, user } = buildPrompt("q", chunks);
116
- assert.ok(system.includes("Answer ONLY"));
117
- assert.ok(system.includes("Cite EVERY"));
118
- assert.ok(user.includes("[chunk_1]"));
119
- assert.ok(user.includes("alpha"));
120
- });
121
- it("retry prompt uses STRICT MODE language", () => {
122
- const chunks = [
123
- {
124
- chunk_id: 1,
125
- marker_id: "chunk_1",
126
- file_path: "x.md",
127
- content: "alpha",
128
- score: 1,
129
- },
130
- ];
131
- const { system } = buildRetryPrompt("q", chunks);
132
- assert.ok(system.includes("STRICT MODE"));
133
- assert.ok(system.includes("only cite markers literally listed"));
134
- });
135
- });
136
- // ─── provider.ts ───────────────────────────────────────────────────────────
137
- describe("selectProvider", () => {
138
- it("returns gemini placeholder by default", () => {
139
- const p = selectProvider();
140
- assert.strictEqual(p.name, "gemini");
141
- });
142
- it("returns mock when name='mock'", () => {
143
- const p = selectProvider("mock");
144
- assert.strictEqual(p.name, "mock");
145
- });
146
- it("falls back to gemini for unknown provider name", () => {
147
- const p = selectProvider("does-not-exist");
148
- assert.strictEqual(p.name, "gemini");
149
- });
150
- });
151
- describe("MockProvider", () => {
152
- it("dequeues canned responses in order", async () => {
153
- const m = new MockProvider(["first", "second"], 0);
154
- const a = await m.complete({
155
- system: "s",
156
- user: "u",
157
- maxTokens: 100,
158
- temperature: 0,
159
- model: "mock",
160
- });
161
- const b = await m.complete({
162
- system: "s",
163
- user: "u",
164
- maxTokens: 100,
165
- temperature: 0,
166
- model: "mock",
167
- });
168
- assert.strictEqual(a.text, "first");
169
- assert.strictEqual(b.text, "second");
170
- });
171
- it("reports tokensIn/tokensOut > 0", async () => {
172
- const m = new MockProvider(["hello world"], 0);
173
- const r = await m.complete({
174
- system: "system prompt",
175
- user: "user prompt",
176
- maxTokens: 100,
177
- temperature: 0,
178
- model: "mock",
179
- });
180
- assert.ok(r.tokensIn > 0);
181
- assert.ok(r.tokensOut > 0);
182
- assert.ok(r.latencyMs >= 0);
183
- });
184
- });
185
- // ─── end-to-end answer() ───────────────────────────────────────────────────
186
- describe("answer() end-to-end", () => {
187
- it("happy path: returns answer + citations + metadata", async () => {
188
- bindFixtureSearch();
189
- const provider = new MockProvider(["Default model is gemini-2.5-flash-lite [chunk_1]."], 0);
190
- const res = await answer({
191
- question: "What is the default answer model?",
192
- providerOverride: provider,
193
- });
194
- assert.ok(res.answer.includes("[chunk_1]"));
195
- assert.strictEqual(res.citations.length, 1);
196
- assert.strictEqual(res.citations[0]?.chunk_id, 101);
197
- assert.strictEqual(res.citations[0]?.marker_id, "chunk_1");
198
- assert.ok(res.metadata.tokens_in > 0);
199
- assert.ok(res.metadata.tokens_out > 0);
200
- assert.ok(res.metadata.latency_ms >= 0);
201
- assert.strictEqual(res.metadata.provider, "mock");
202
- assert.strictEqual(res.metadata.retrieval_count, 3);
203
- assert.strictEqual(res.metadata.retry_count, 0);
204
- assert.strictEqual(res.metadata.fallback_used, false);
205
- assert.strictEqual(res.metadata.failed_reason, undefined);
206
- });
207
- it("empty retrieval → canonical 'no memory matches'", async () => {
208
- __setRawSearchForTests(async () => []);
209
- const provider = new MockProvider(["should not be called"], 0);
210
- const res = await answer({
211
- question: "Nothing matches this",
212
- providerOverride: provider,
213
- });
214
- assert.match(res.answer, /no memory matches/i);
215
- assert.deepStrictEqual(res.citations, []);
216
- assert.strictEqual(res.metadata.retrieval_count, 0);
217
- assert.strictEqual(res.metadata.tokens_in, 0);
218
- assert.strictEqual(res.metadata.tokens_out, 0);
219
- assert.strictEqual(res.metadata.failed_reason, "retrieval_empty");
220
- });
221
- it("provider error throws AnswerError(llm_error)", async () => {
222
- bindFixtureSearch();
223
- const provider = new MockProvider([], 0);
224
- provider.throwNext(new Error("network timeout"));
225
- await assert.rejects(() => answer({ question: "q", providerOverride: provider }), (err) => {
226
- assert.ok(err instanceof AnswerError);
227
- assert.strictEqual(err.reason, "llm_error");
228
- return true;
229
- });
230
- });
231
- it("hallucinated citation triggers retry and recovers", async () => {
232
- bindFixtureSearch();
233
- // First response cites chunk_99 (out of range, retrieval has only 3).
234
- // Retry response cites chunk_1 (valid).
235
- const provider = new MockProvider([
236
- "Per memory [chunk_99] the answer is gemini-2.5-flash-lite.",
237
- "Per memory [chunk_1] the answer is gemini-2.5-flash-lite.",
238
- ], 0);
239
- const res = await answer({
240
- question: "Which model is default?",
241
- providerOverride: provider,
242
- });
243
- assert.ok(res.answer.includes("[chunk_1]"));
244
- assert.strictEqual(res.metadata.fallback_used, true);
245
- assert.strictEqual(res.metadata.retry_count, 1);
246
- assert.strictEqual(res.metadata.failed_reason, undefined);
247
- assert.strictEqual(res.citations.length, 1);
248
- assert.strictEqual(res.citations[0]?.chunk_id, 101);
249
- });
250
- it("hallucination after retry throws AnswerError(hallucination_after_retry)", async () => {
251
- bindFixtureSearch();
252
- const provider = new MockProvider([
253
- "Bogus [chunk_99] answer.",
254
- "Still bogus [chunk_77] answer.",
255
- ], 0);
256
- await assert.rejects(() => answer({ question: "q", providerOverride: provider }), (err) => {
257
- assert.ok(err instanceof AnswerError);
258
- assert.strictEqual(err.reason, "hallucination_after_retry");
259
- assert.strictEqual(err.metadata.fallback_used, true);
260
- assert.strictEqual(err.metadata.retry_count, 1);
261
- return true;
262
- });
263
- });
264
- it("invalid_input: empty question rejected", async () => {
265
- await assert.rejects(() => answer({ question: "" }), (err) => {
266
- assert.ok(err instanceof AnswerError);
267
- assert.strictEqual(err.reason, "invalid_input");
268
- return true;
269
- });
270
- });
271
- it("env override NOX_ANSWER_MODEL flows into metadata.model", async () => {
272
- bindFixtureSearch();
273
- const prev = process.env.NOX_ANSWER_MODEL;
274
- process.env.NOX_ANSWER_MODEL = "gemini-2.5-flash";
275
- try {
276
- const provider = new MockProvider(["Answer [chunk_1]"], 0);
277
- const res = await answer({
278
- question: "Which model?",
279
- providerOverride: provider,
280
- });
281
- assert.strictEqual(res.metadata.model, "gemini-2.5-flash");
282
- }
283
- finally {
284
- if (prev === undefined)
285
- delete process.env.NOX_ANSWER_MODEL;
286
- else
287
- process.env.NOX_ANSWER_MODEL = prev;
288
- }
289
- });
290
- it("retrieveOverride injection path works without binding search", async () => {
291
- // No __setRawSearchForTests call — using opts.retrieveOverride directly.
292
- const provider = new MockProvider(["Direct [chunk_1]"], 0);
293
- const res = await answer({
294
- question: "test",
295
- providerOverride: provider,
296
- retrieveOverride: async () => [
297
- {
298
- chunk_id: 999,
299
- marker_id: "chunk_1",
300
- file_path: "inline.md",
301
- content: "inline content",
302
- },
303
- ],
304
- });
305
- assert.strictEqual(res.citations[0]?.chunk_id, 999);
306
- assert.strictEqual(res.metadata.retrieval_count, 1);
307
- });
308
- });
309
- // ─── parseCitations() unit tests ───────────────────────────────────────────
310
- describe("parseCitations", () => {
311
- const chunks = [
312
- { chunk_id: 11, marker_id: "chunk_1", file_path: "a.md", content: "alpha", score: 1 },
313
- { chunk_id: 22, marker_id: "chunk_2", file_path: "b.md", content: "beta", score: 0.5 },
314
- ];
315
- it("extracts valid markers into citations", () => {
316
- const { citations, hallucinated } = parseCitations("alpha is [chunk_1] and beta is [chunk_2]", chunks);
317
- assert.strictEqual(citations.length, 2);
318
- assert.deepStrictEqual(hallucinated, []);
319
- assert.strictEqual(citations[0]?.chunk_id, 11);
320
- assert.strictEqual(citations[1]?.chunk_id, 22);
321
- });
322
- it("flags out-of-range markers as hallucinated", () => {
323
- const { citations, hallucinated } = parseCitations("Bogus [chunk_99] reference", chunks);
324
- assert.strictEqual(citations.length, 0);
325
- assert.deepStrictEqual(hallucinated, ["chunk_99"]);
326
- });
327
- it("dedupes repeated markers in the same response", () => {
328
- const { citations } = parseCitations("[chunk_1] foo [chunk_1] bar [chunk_1]", chunks);
329
- assert.strictEqual(citations.length, 1);
330
- });
331
- it("returns empty arrays for text with no markers", () => {
332
- const { citations, hallucinated } = parseCitations("no citations here", chunks);
333
- assert.deepStrictEqual(citations, []);
334
- assert.deepStrictEqual(hallucinated, []);
335
- });
336
- it("snippet is trimmed to ≤200 chars", () => {
337
- const longChunk = {
338
- chunk_id: 1,
339
- marker_id: "chunk_1",
340
- file_path: "long.md",
341
- content: "x".repeat(500),
342
- score: 1,
343
- };
344
- const { citations } = parseCitations("[chunk_1]", [longChunk]);
345
- assert.ok((citations[0]?.snippet.length ?? 0) <= 200);
346
- });
347
- });
@@ -1,117 +0,0 @@
1
- /**
2
- * src/lib/answer/__tests__/prompt.test.ts
3
- *
4
- * Focused tests for prompt assembly (T3). 10+ cases covering:
5
- * - system prompt content (anti-hallucination clause, citation rule)
6
- * - chunk marker preservation in user prompt
7
- * - empty context → fallback indicator
8
- * - long context → truncation honours char budget
9
- * - chunk ordering in rendered prompt = marker_id ascending
10
- * - retry prompt uses STRICT MODE language
11
- * - deterministic snapshot (same inputs → same outputs)
12
- */
13
- import { describe, it } from "node:test";
14
- import assert from "node:assert/strict";
15
- import { buildPrompt, buildRetryPrompt } from "../prompt.js";
16
- function mkChunk(i, content, score) {
17
- return {
18
- chunk_id: i * 100,
19
- marker_id: `chunk_${i}`,
20
- file_path: `f${i}.md`,
21
- content,
22
- score,
23
- };
24
- }
25
- describe("buildPrompt — system prompt", () => {
26
- it("anti-hallucination guard present", () => {
27
- const { system } = buildPrompt("q", [mkChunk(1, "x", 1)]);
28
- assert.ok(system.includes("Answer ONLY"));
29
- assert.ok(system.includes("no memory matches"));
30
- });
31
- it("explicit citation rule present", () => {
32
- const { system } = buildPrompt("q", [mkChunk(1, "x", 1)]);
33
- assert.ok(system.includes("Cite EVERY"));
34
- assert.ok(system.includes("[chunk_N]"));
35
- assert.ok(system.includes("Never invent"));
36
- });
37
- });
38
- describe("buildPrompt — user prompt", () => {
39
- it("preserves chunk markers verbatim", () => {
40
- const chunks = [
41
- mkChunk(1, "alpha content", 0.9),
42
- mkChunk(2, "beta content", 0.7),
43
- mkChunk(3, "gamma content", 0.5),
44
- ];
45
- const { user } = buildPrompt("test question", chunks);
46
- assert.ok(user.includes("[chunk_1] alpha content"));
47
- assert.ok(user.includes("[chunk_2] beta content"));
48
- assert.ok(user.includes("[chunk_3] gamma content"));
49
- });
50
- it("includes the question verbatim", () => {
51
- const { user } = buildPrompt("Why is salience recency × pain × importance?", [
52
- mkChunk(1, "x", 1),
53
- ]);
54
- assert.ok(user.includes("Why is salience recency × pain × importance?"));
55
- });
56
- it("empty chunks produces fallback indicator", () => {
57
- const { user } = buildPrompt("q", []);
58
- assert.ok(user.includes("(No context retrieved.)"));
59
- });
60
- it("renders chunks in marker_id ascending order even if input score-sorted", () => {
61
- const chunks = [
62
- mkChunk(3, "third", 0.9), // highest score
63
- mkChunk(1, "first", 0.5),
64
- mkChunk(2, "second", 0.7),
65
- ];
66
- const { user } = buildPrompt("q", chunks);
67
- const i1 = user.indexOf("[chunk_1]");
68
- const i2 = user.indexOf("[chunk_2]");
69
- const i3 = user.indexOf("[chunk_3]");
70
- assert.ok(i1 < i2);
71
- assert.ok(i2 < i3);
72
- });
73
- it("truncates lowest-score chunks first when over budget", () => {
74
- // Very small token budget — forces truncation.
75
- const big = "x".repeat(2000);
76
- const chunks = [
77
- mkChunk(1, big, 0.95), // high score — keep
78
- mkChunk(2, big, 0.05), // low score — drop
79
- mkChunk(3, big, 0.5),
80
- ];
81
- const { user } = buildPrompt("q", chunks, /*maxTokens*/ 900);
82
- assert.ok(user.includes("[chunk_1]"), "highest score kept");
83
- assert.ok(!user.includes("[chunk_2]"), "lowest score dropped");
84
- });
85
- it("keeps at least one chunk even when budget < single-chunk size", () => {
86
- const enormous = "x".repeat(50_000);
87
- const chunks = [mkChunk(1, enormous, 0.95)];
88
- const { user } = buildPrompt("q", chunks, /*maxTokens*/ 100);
89
- assert.ok(user.includes("[chunk_1]"), "must keep ≥1 chunk");
90
- });
91
- it("deterministic: same input → same output", () => {
92
- const chunks = [mkChunk(1, "alpha", 0.9), mkChunk(2, "beta", 0.7)];
93
- const a = buildPrompt("q", chunks);
94
- const b = buildPrompt("q", chunks);
95
- assert.strictEqual(a.system, b.system);
96
- assert.strictEqual(a.user, b.user);
97
- });
98
- });
99
- describe("buildRetryPrompt", () => {
100
- it("uses STRICT MODE language", () => {
101
- const { system } = buildRetryPrompt("q", [mkChunk(1, "x", 1)]);
102
- assert.ok(system.includes("STRICT MODE"));
103
- });
104
- it("same user-prompt layout as buildPrompt", () => {
105
- const chunks = [mkChunk(1, "alpha", 0.9), mkChunk(2, "beta", 0.7)];
106
- const a = buildPrompt("q", chunks);
107
- const b = buildRetryPrompt("q", chunks);
108
- // System differs by design; user prompt content is identical.
109
- assert.strictEqual(a.user, b.user);
110
- assert.notStrictEqual(a.system, b.system);
111
- });
112
- it("reaffirms zero-hallucination contract", () => {
113
- const { system } = buildRetryPrompt("q", [mkChunk(1, "x", 1)]);
114
- assert.ok(system.includes("only cite markers literally listed"));
115
- assert.ok(system.includes("Do NOT speculate"));
116
- });
117
- });