@rubytech/create-maxy 1.0.876 → 1.0.878

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 (71) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/lib/graph-trash/dist/index.js +1 -1
  3. package/payload/platform/lib/graph-trash/dist/index.js.map +1 -1
  4. package/payload/platform/lib/graph-trash/src/index.ts +1 -1
  5. package/payload/platform/neo4j/edge-annotations.json +11 -3
  6. package/payload/platform/plugins/admin/hooks/__tests__/pre-tool-use-base64-guard.test.sh +204 -0
  7. package/payload/platform/plugins/admin/hooks/archive-ingest-surface-gate.sh +11 -5
  8. package/payload/platform/plugins/admin/hooks/pre-tool-use.sh +96 -0
  9. package/payload/platform/plugins/admin/skills/onboarding/SKILL.md +5 -1
  10. package/payload/platform/plugins/cloudflare/scripts/setup-tunnel.sh +88 -9
  11. package/payload/platform/plugins/cloudflare/skills/setup-tunnel/SKILL.md +1 -1
  12. package/payload/platform/plugins/docs/references/admin-session.md +80 -0
  13. package/payload/platform/plugins/docs/references/platform.md +3 -1
  14. package/payload/platform/plugins/docs/references/plugins-guide.md +1 -0
  15. package/payload/platform/plugins/memory/PLUGIN.md +4 -1
  16. package/payload/platform/plugins/memory/mcp/dist/index.js +127 -0
  17. package/payload/platform/plugins/memory/mcp/dist/index.js.map +1 -1
  18. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-archive-derive-insights.test.d.ts +2 -0
  19. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-archive-derive-insights.test.d.ts.map +1 -0
  20. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-archive-derive-insights.test.js +97 -0
  21. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-archive-derive-insights.test.js.map +1 -0
  22. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-archive-enrich-rejection.test.d.ts +2 -0
  23. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-archive-enrich-rejection.test.d.ts.map +1 -0
  24. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-archive-enrich-rejection.test.js +184 -0
  25. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-archive-enrich-rejection.test.js.map +1 -0
  26. package/payload/platform/plugins/memory/mcp/dist/tools/conversation-archive-derive-insights.d.ts +89 -0
  27. package/payload/platform/plugins/memory/mcp/dist/tools/conversation-archive-derive-insights.d.ts.map +1 -0
  28. package/payload/platform/plugins/memory/mcp/dist/tools/conversation-archive-derive-insights.js +542 -0
  29. package/payload/platform/plugins/memory/mcp/dist/tools/conversation-archive-derive-insights.js.map +1 -0
  30. package/payload/platform/plugins/memory/mcp/dist/tools/conversation-archive-enrich-rejection.d.ts +41 -0
  31. package/payload/platform/plugins/memory/mcp/dist/tools/conversation-archive-enrich-rejection.d.ts.map +1 -0
  32. package/payload/platform/plugins/memory/mcp/dist/tools/conversation-archive-enrich-rejection.js +116 -0
  33. package/payload/platform/plugins/memory/mcp/dist/tools/conversation-archive-enrich-rejection.js.map +1 -0
  34. package/payload/platform/plugins/memory/skills/conversation-archive-enrich/SKILL.md +159 -0
  35. package/payload/platform/templates/agents/admin/IDENTITY.md +4 -0
  36. package/payload/platform/templates/specialists/agents/database-operator.md +3 -2
  37. package/payload/server/chunk-GOZP57CX.js +1373 -0
  38. package/payload/server/chunk-I4AQMEJA.js +11265 -0
  39. package/payload/server/chunk-INI2ED6U.js +2277 -0
  40. package/payload/server/chunk-JTZYXIUW.js +1373 -0
  41. package/payload/server/chunk-LQDUG4II.js +11336 -0
  42. package/payload/server/chunk-LU6TUP3E.js +2169 -0
  43. package/payload/server/chunk-RP25NRQY.js +660 -0
  44. package/payload/server/chunk-RRVBWC66.js +667 -0
  45. package/payload/server/client-pool-AIZ5QKFD.js +34 -0
  46. package/payload/server/client-pool-VYDOIFG7.js +34 -0
  47. package/payload/server/cloudflare-task-tracker-B6FXP3HI.js +20 -0
  48. package/payload/server/cloudflare-task-tracker-M7APAYEF.js +20 -0
  49. package/payload/server/maxy-edge.js +6 -5
  50. package/payload/server/public/assets/{Checkbox-BsqexMy3.js → Checkbox-CqsIsmEi.js} +1 -1
  51. package/payload/server/public/assets/admin-CZlNLb9T.js +352 -0
  52. package/payload/server/public/assets/data-CH-nQ7oX.js +1 -0
  53. package/payload/server/public/assets/graph-labels-D0qUVHtZ.js +1 -0
  54. package/payload/server/public/assets/graph-mpWDe4rf.js +1 -0
  55. package/payload/server/public/assets/{jsx-runtime-CGCRFPeX.css → jsx-runtime-Cy_HdZWV.css} +1 -1
  56. package/payload/server/public/assets/page-CnyySOZF.js +1 -0
  57. package/payload/server/public/assets/{page-qI0NJSs6.js → page-DcK36vDf.js} +2 -2
  58. package/payload/server/public/assets/public-SXA00FTv.js +5 -0
  59. package/payload/server/public/assets/{useVoiceRecorder-DVVSQc-9.js → useVoiceRecorder-DcByEBLy.js} +1 -1
  60. package/payload/server/public/data.html +5 -5
  61. package/payload/server/public/graph.html +6 -6
  62. package/payload/server/public/index.html +8 -8
  63. package/payload/server/public/public.html +5 -5
  64. package/payload/server/server.js +560 -448
  65. package/payload/server/public/assets/admin-pIeHRytz.js +0 -352
  66. package/payload/server/public/assets/data-rhAG7W2b.js +0 -1
  67. package/payload/server/public/assets/graph-DVAWZmkb.js +0 -1
  68. package/payload/server/public/assets/graph-labels-t_04n4zX.js +0 -1
  69. package/payload/server/public/assets/page-BM9O7QN8.js +0 -1
  70. package/payload/server/public/assets/public-oNo_2gt0.js +0 -5
  71. /package/payload/server/public/assets/{jsx-runtime-B8sGPXtT.js → jsx-runtime-BEjEWeaF.js} +0 -0
@@ -0,0 +1,97 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { readFileSync } from "node:fs";
3
+ import { dirname, resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = dirname(__filename);
7
+ const PACKAGE_ROOT = resolve(__dirname, "..", "..", "..");
8
+ const TOOL_PATH = resolve(PACKAGE_ROOT, "src/tools/conversation-archive-derive-insights.ts");
9
+ const INDEX_PATH = resolve(PACKAGE_ROOT, "src/index.ts");
10
+ function readTool() {
11
+ return readFileSync(TOOL_PATH, "utf-8");
12
+ }
13
+ function readIndex() {
14
+ return readFileSync(INDEX_PATH, "utf-8");
15
+ }
16
+ describe("conversation-archive-derive-insights tool — Task 892", () => {
17
+ it("runs on Claude Code OAuth (Haiku), not the API key", () => {
18
+ const src = readTool();
19
+ expect(src).toMatch(/from\s+["'][^"']*oauth-llm\b/);
20
+ expect(src).toContain("callOauthLlm");
21
+ expect(src).toContain("HAIKU_MODEL");
22
+ });
23
+ it("paginates the chunk walk via chunkOffset + chunkLimit", () => {
24
+ const src = readTool();
25
+ expect(src).toContain("chunkOffset");
26
+ expect(src).toContain("chunkLimit");
27
+ });
28
+ it("walks :Section:Conversation chunks of a named :ConversationArchive", () => {
29
+ const src = readTool();
30
+ expect(src).toContain(":Section:Conversation");
31
+ expect(src).toContain(":ConversationArchive");
32
+ expect(src).toContain(":HAS_SECTION");
33
+ });
34
+ it("emits proposals with chunkElementId + kind + contentHash + evidenceSnippet + mergeCypher", () => {
35
+ const src = readTool();
36
+ expect(src).toContain("chunkElementId");
37
+ expect(src).toContain("contentHash");
38
+ expect(src).toContain("evidenceSnippet");
39
+ expect(src).toContain("mergeCypher");
40
+ expect(src).toContain("mergeParams");
41
+ });
42
+ it("contentHash is sha256 over kind + payload (deterministic re-run collapse)", () => {
43
+ const src = readTool();
44
+ expect(src).toContain('"sha256"');
45
+ });
46
+ it("per-kind MERGE Cyphers cover mention, task, preference, observed-relationship", () => {
47
+ const src = readTool();
48
+ expect(src).toContain(":MENTIONS");
49
+ expect(src).toContain(":OBSERVED_IN");
50
+ expect(src).toContain(":REFERENCES");
51
+ expect(src).toContain(":RELATED_TO");
52
+ });
53
+ it("stamps createdByTool on every wired write so verification cypher can count them", () => {
54
+ const src = readTool();
55
+ // The cypher writes `createdByTool = 'conversation-archive-derive-insights'`
56
+ // as a SET clause inside the MERGE templates for each of the four kinds.
57
+ expect(src).toMatch(/createdByTool\s*=\s*'conversation-archive-derive-insights'/);
58
+ });
59
+ it("limits evidenceSnippet to 80 characters per spec", () => {
60
+ const src = readTool();
61
+ expect(src).toMatch(/EVIDENCE_SNIPPET_MAX_CHARS\s*=\s*80/);
62
+ });
63
+ it("registered in memory-mcp index.ts with boot log line", () => {
64
+ const idx = readIndex();
65
+ expect(idx).toContain("conversation-archive-derive-insights");
66
+ expect(idx).toContain("[memory-mcp] registered tool=conversation-archive-derive-insights");
67
+ });
68
+ it("declares confidence-floor instruction in the system prompt, not as a numeric post-filter", () => {
69
+ const src = readTool();
70
+ // The doctrine: tell Haiku to omit hedged claims, do NOT trust a model-emitted
71
+ // numeric confidence (uncalibrated). The system prompt carries the instruction.
72
+ expect(src).toMatch(/hedge|defend|would not say|courtroom/i);
73
+ });
74
+ it("loud-fails when the operator names a non-existent archive (no silent fallback)", () => {
75
+ const src = readTool();
76
+ expect(src).toMatch(/archive-not-found|no archive matched/i);
77
+ });
78
+ // Task 980 — durable rejection memory is wired into the same walk; the
79
+ // per-chunk log line must carry `rejections-filtered=` so operators can grep
80
+ // server.log and prove the filter ran. Field absence == filter not wired.
81
+ it("per-chunk log carries rejections-filtered= field (Task 980)", () => {
82
+ const src = readTool();
83
+ expect(src).toContain("rejections-filtered=");
84
+ });
85
+ it("loads rejections once per page via loadRejections helper (Task 980)", () => {
86
+ const src = readTool();
87
+ expect(src).toMatch(/loadRejections\(accountId\)/);
88
+ expect(src).toMatch(/rejectionKey\(/);
89
+ });
90
+ it("exports rejectionsJsonlPath / rejectionKey / loadRejections for the rejection tool (Task 980)", () => {
91
+ const src = readTool();
92
+ expect(src).toMatch(/export function rejectionsJsonlPath/);
93
+ expect(src).toMatch(/export function rejectionKey/);
94
+ expect(src).toMatch(/export function loadRejections/);
95
+ });
96
+ });
97
+ //# sourceMappingURL=conversation-archive-derive-insights.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-archive-derive-insights.test.js","sourceRoot":"","sources":["../../../src/tools/__tests__/conversation-archive-derive-insights.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACtC,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC1D,MAAM,SAAS,GAAG,OAAO,CACvB,YAAY,EACZ,mDAAmD,CACpD,CAAC;AACF,MAAM,UAAU,GAAG,OAAO,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;AAEzD,SAAS,QAAQ;IACf,OAAO,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED,QAAQ,CAAC,sDAAsD,EAAE,GAAG,EAAE;IACpE,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;QACpD,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QACtC,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACvC,CAAC,CAAC,CA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,EAAE;QACxF,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,uCAAuC,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,uEAAuE;IACvE,6EAA6E;IAC7E,0EAA0E;IAC1E,EAAE,CAAC,6DAA6D,EAAE,GAAG,EAAE;QACrE,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qEAAqE,EAAE,GAAG,EAAE;QAC7E,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;QACnD,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+FAA+F,EAAE,GAAG,EAAE;QACvG,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC;QAC3D,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;QACpD,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,gCAAgC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=conversation-archive-enrich-rejection.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-archive-enrich-rejection.test.d.ts","sourceRoot":"","sources":["../../../src/tools/__tests__/conversation-archive-enrich-rejection.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,184 @@
1
+ import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
+ import { readFileSync, mkdtempSync, mkdirSync, rmSync, writeFileSync, } from "node:fs";
3
+ import { dirname, resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { tmpdir } from "node:os";
6
+ import { conversationArchiveEnrichRejection } from "../conversation-archive-enrich-rejection.js";
7
+ import { loadRejections, rejectionKey, rejectionsJsonlPath, } from "../conversation-archive-derive-insights.js";
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+ const PACKAGE_ROOT = resolve(__dirname, "..", "..", "..");
11
+ const TOOL_PATH = resolve(PACKAGE_ROOT, "src/tools/conversation-archive-enrich-rejection.ts");
12
+ const INDEX_PATH = resolve(PACKAGE_ROOT, "src/index.ts");
13
+ const PLUGIN_PATH = resolve(PACKAGE_ROOT, "..", "PLUGIN.md");
14
+ function readTool() {
15
+ return readFileSync(TOOL_PATH, "utf-8");
16
+ }
17
+ function readIndex() {
18
+ return readFileSync(INDEX_PATH, "utf-8");
19
+ }
20
+ describe("conversation-archive-enrich-rejection tool — Task 980", () => {
21
+ it("exposes record + undo modes only", () => {
22
+ const src = readTool();
23
+ expect(src).toMatch(/RejectionMode\s*=\s*"record"\s*\|\s*"undo"/);
24
+ });
25
+ it("imports the JSONL path constant + key helper from the derive-insights module (single source-of-truth)", () => {
26
+ const src = readTool();
27
+ expect(src).toMatch(/rejectionsJsonlPath/);
28
+ expect(src).toMatch(/rejectionKey/);
29
+ expect(src).toMatch(/from\s+["']\.\/conversation-archive-derive-insights/);
30
+ });
31
+ it("uses atomic rename on undo (tmp file → rename → live path)", () => {
32
+ const src = readTool();
33
+ expect(src).toMatch(/renameSync/);
34
+ expect(src).toMatch(/\.tmp/);
35
+ });
36
+ it("uses appendFileSync on record (O_APPEND atomic for sub-PIPE_BUF writes)", () => {
37
+ const src = readTool();
38
+ expect(src).toMatch(/appendFileSync/);
39
+ });
40
+ it("stamps rejectedAt + rejectedBySession on every line", () => {
41
+ const src = readTool();
42
+ expect(src).toContain("rejectedAt");
43
+ expect(src).toContain("rejectedBySession");
44
+ });
45
+ it("emits stored + rejection-undone log lines per spec", () => {
46
+ const src = readTool();
47
+ expect(src).toMatch(/\[conversation-archive-enrich\] rejected /);
48
+ expect(src).toMatch(/\[conversation-archive-enrich\] rejection-undone /);
49
+ });
50
+ it("registered in memory-mcp index.ts with boot log line", () => {
51
+ const idx = readIndex();
52
+ expect(idx).toContain("conversation-archive-enrich-rejection");
53
+ expect(idx).toContain("[memory-mcp] registered tool=conversation-archive-enrich-rejection");
54
+ });
55
+ it("listed in PLUGIN.md tools section", () => {
56
+ const plugin = readFileSync(PLUGIN_PATH, "utf-8");
57
+ expect(plugin).toMatch(/-\s+conversation-archive-enrich-rejection/);
58
+ });
59
+ });
60
+ describe("conversation-archive-enrich-rejection — runtime", () => {
61
+ let scratchDir;
62
+ let origPlatformRoot;
63
+ beforeEach(() => {
64
+ scratchDir = mkdtempSync(resolve(tmpdir(), "rejection-test-"));
65
+ origPlatformRoot = process.env.PLATFORM_ROOT;
66
+ // The path resolver computes ../data/accounts from PLATFORM_ROOT — point
67
+ // PLATFORM_ROOT at scratchDir/platform so the JSONL lands under scratchDir/data.
68
+ process.env.PLATFORM_ROOT = resolve(scratchDir, "platform");
69
+ });
70
+ afterEach(() => {
71
+ if (origPlatformRoot === undefined) {
72
+ delete process.env.PLATFORM_ROOT;
73
+ }
74
+ else {
75
+ process.env.PLATFORM_ROOT = origPlatformRoot;
76
+ }
77
+ rmSync(scratchDir, { recursive: true, force: true });
78
+ });
79
+ it("record then undo round-trips the JSONL count back to zero", () => {
80
+ const params = {
81
+ accountId: "acct-980-test",
82
+ archiveElementId: "4:archive:1",
83
+ chunkElementId: "4:chunk:1",
84
+ kind: "mention",
85
+ contentHash: "deadbeef",
86
+ };
87
+ const recorded = conversationArchiveEnrichRejection({
88
+ ...params,
89
+ mode: "record",
90
+ });
91
+ expect(recorded.beforeCount).toBe(0);
92
+ expect(recorded.afterCount).toBe(1);
93
+ const dupRecorded = conversationArchiveEnrichRejection({
94
+ ...params,
95
+ mode: "record",
96
+ });
97
+ // Idempotent: second record is a no-op.
98
+ expect(dupRecorded.beforeCount).toBe(1);
99
+ expect(dupRecorded.afterCount).toBe(1);
100
+ const undone = conversationArchiveEnrichRejection({
101
+ ...params,
102
+ mode: "undo",
103
+ });
104
+ expect(undone.beforeCount).toBe(1);
105
+ expect(undone.afterCount).toBe(0);
106
+ const undoneAgain = conversationArchiveEnrichRejection({
107
+ ...params,
108
+ mode: "undo",
109
+ });
110
+ // Undoing a non-existent key is a silent no-op.
111
+ expect(undoneAgain.beforeCount).toBe(0);
112
+ expect(undoneAgain.afterCount).toBe(0);
113
+ });
114
+ it("undo clears EVERY matching line, not just one (residual race window)", async () => {
115
+ // Simulate the documented race: two record-style lines for the same key
116
+ // bypass the idempotency guard (which only fires when the read+write are
117
+ // observed in-process by the same caller). Write them directly to disk.
118
+ const accountId = "acct-980-dup";
119
+ const path = rejectionsJsonlPath(accountId);
120
+ mkdirSync(dirname(path), { recursive: true });
121
+ const line = JSON.stringify({
122
+ archiveElementId: "4:archive:dup",
123
+ chunkElementId: "4:chunk:dup",
124
+ kind: "mention",
125
+ contentHash: "abcd",
126
+ rejectedAt: new Date().toISOString(),
127
+ rejectedBySession: null,
128
+ });
129
+ writeFileSync(path, line + "\n" + line + "\n");
130
+ const undone = conversationArchiveEnrichRejection({
131
+ accountId,
132
+ archiveElementId: "4:archive:dup",
133
+ chunkElementId: "4:chunk:dup",
134
+ kind: "mention",
135
+ contentHash: "abcd",
136
+ mode: "undo",
137
+ });
138
+ expect(undone.beforeCount).toBe(2);
139
+ // afterCount MUST report 0, not beforeCount - 1.
140
+ expect(undone.afterCount).toBe(0);
141
+ // And the filter side must see no remaining keys.
142
+ expect(loadRejections(accountId).has(rejectionKey("4:chunk:dup", "mention", "abcd"))).toBe(false);
143
+ });
144
+ it("loadRejections returns the recorded key (round-trip with filter side)", () => {
145
+ const params = {
146
+ accountId: "acct-980-rt",
147
+ archiveElementId: "4:archive:2",
148
+ chunkElementId: "4:chunk:42",
149
+ kind: "preference",
150
+ contentHash: "f00d",
151
+ };
152
+ conversationArchiveEnrichRejection({
153
+ ...params,
154
+ mode: "record",
155
+ });
156
+ const set = loadRejections(params.accountId);
157
+ expect(set.has(rejectionKey(params.chunkElementId, params.kind, params.contentHash))).toBe(true);
158
+ });
159
+ it("loadRejections skips a malformed line and emits rejection-parse-skip", () => {
160
+ const accountId = "acct-980-corrupt";
161
+ const path = rejectionsJsonlPath(accountId);
162
+ mkdirSync(dirname(path), { recursive: true });
163
+ writeFileSync(path, [
164
+ '{"chunkElementId":"good","kind":"mention","contentHash":"aa"}',
165
+ "{ this is not valid json",
166
+ '{"chunkElementId":"alsogood","kind":"task","contentHash":"bb"}',
167
+ ].join("\n") + "\n");
168
+ const stderrChunks = [];
169
+ const origWrite = process.stderr.write.bind(process.stderr);
170
+ process.stderr.write = (s) => {
171
+ stderrChunks.push(s);
172
+ return true;
173
+ };
174
+ try {
175
+ const set = loadRejections(accountId);
176
+ expect(set.size).toBe(2);
177
+ }
178
+ finally {
179
+ process.stderr.write = origWrite;
180
+ }
181
+ expect(stderrChunks.some((s) => s.includes("rejection-parse-skip"))).toBe(true);
182
+ });
183
+ });
184
+ //# sourceMappingURL=conversation-archive-enrich-rejection.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-archive-enrich-rejection.test.js","sourceRoot":"","sources":["../../../src/tools/__tests__/conversation-archive-enrich-rejection.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,WAAW,EACX,SAAS,EACT,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;A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CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * conversation-archive-derive-insights MCP tool — Task 892.
3
+ *
4
+ * Chunk-anchored Phase 2 for :ConversationArchive. Walks the
5
+ * :Section:Conversation chunks of one named archive in pages, asks Haiku
6
+ * (via OAuth — admin-side LLM never runs on the API key) for high-confidence
7
+ * claims, and returns a list of operator-facing proposals. The tool itself
8
+ * is read-only: every wire is dispatched by the conversation-archive-enrich
9
+ * skill via the operator gate, never by this tool.
10
+ *
11
+ * Idempotency lives on a MERGE-key shape of (chunkElementId, kind, contentHash):
12
+ * - MENTIONS / REFERENCES / RELATED_TO edges carry contentHash as a
13
+ * relationship-merge-key, so a re-run of the same chunk text against the
14
+ * same target collapses to the existing row.
15
+ * - Preference nodes use a node-merge-key on (accountId, contentHash).
16
+ *
17
+ * Confidence floor is enforced in the system prompt as a hedging-avoidance
18
+ * instruction — Haiku confidences are not calibrated, so a numeric post-filter
19
+ * would be theatre. The prompt tells the model to emit only claims it would
20
+ * defend in a courtroom and omit anything it would hedge on.
21
+ *
22
+ * Per-row dispatch (the skill executes; this tool emits the cypher):
23
+ * mention → (:Section:Conversation)-[:MENTIONS {contentHash}]->(:Person|:Organization)
24
+ * task → (:Task)-[:REFERENCES {contentHash}]->(:Section:Conversation)
25
+ * (the skill calls mcp__tasks__task-create first,
26
+ * then this REFERENCES edge via raw cypher.)
27
+ * preference → MERGE (p:Preference {accountId, contentHash})
28
+ * then (p)-[:OBSERVED_IN]->(chunk)
29
+ * observed-relationship → (:Person|:Organization)-[:RELATED_TO {contentHash, operatorConfirmed:true}]->(:Person|:Organization)
30
+ */
31
+ export declare function rejectionsJsonlPath(accountId: string): string;
32
+ export declare function rejectionKey(chunkElementId: string, kind: string, contentHash: string): string;
33
+ export declare function loadRejections(accountId: string): Set<string>;
34
+ declare const PROPOSAL_KINDS: readonly ["mention", "task", "preference", "observed-relationship"];
35
+ type ProposalKind = (typeof PROPOSAL_KINDS)[number];
36
+ export interface DeriveInsightsParams {
37
+ accountId: string;
38
+ /** elementId of the :ConversationArchive the operator named. */
39
+ archiveElementId: string;
40
+ /** Zero-based chunk offset for pagination. Default 0. */
41
+ chunkOffset?: number;
42
+ /** Max chunks per page (1..MAX_CHUNK_LIMIT). Default DEFAULT_CHUNK_LIMIT. */
43
+ chunkLimit?: number;
44
+ /** Optional override for the SDK-injected session id (provenance stamping). */
45
+ sessionId?: string;
46
+ }
47
+ export interface Proposal {
48
+ /** elementId of the source :Section:Conversation chunk. */
49
+ chunkElementId: string;
50
+ /** One of the four supported kinds. */
51
+ kind: ProposalKind;
52
+ /** Deterministic sha256 over kind + payload — idempotency key on re-runs. */
53
+ contentHash: string;
54
+ /** ≤80 chars verbatim or near-verbatim quote from the chunk. */
55
+ evidenceSnippet: string;
56
+ /** Human-readable description the skill surfaces to the operator. */
57
+ proposedAction: string;
58
+ /** Ready-to-execute cypher the skill runs on `wire` via maxy-graph-write_neo4j_cypher. */
59
+ mergeCypher: string;
60
+ /** Parameters for `mergeCypher`. Includes contentHash, chunkElementId, payload fields. */
61
+ mergeParams: Record<string, unknown>;
62
+ /**
63
+ * Disambiguation hint for `mention` and `observed-relationship` — the operator
64
+ * resolves these to existing :Person/:Organization elementIds via memory-search
65
+ * before the skill executes `mergeCypher`. Null for `preference` and `task`.
66
+ */
67
+ disambiguation: {
68
+ /** A subject the operator must resolve to an existing graph node. */
69
+ needsResolution: Array<{
70
+ role: "subject" | "object";
71
+ displayName: string;
72
+ proposedLabels: Array<"Person" | "Organization">;
73
+ }>;
74
+ } | null;
75
+ }
76
+ export interface DeriveInsightsResult {
77
+ archiveElementId: string;
78
+ archiveTitle: string | null;
79
+ totalChunks: number;
80
+ walkedFrom: number;
81
+ walkedTo: number;
82
+ proposalsRemaining: boolean;
83
+ proposals: Proposal[];
84
+ /** Per-page diagnostics — chunks that produced zero high-confidence proposals. */
85
+ emptyChunkElementIds: string[];
86
+ }
87
+ export declare function conversationArchiveDeriveInsights(params: DeriveInsightsParams): Promise<DeriveInsightsResult>;
88
+ export {};
89
+ //# sourceMappingURL=conversation-archive-derive-insights.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-archive-derive-insights.d.ts","sourceRoot":"","sources":["../../src/tools/conversation-archive-derive-insights.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAiCH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAS7D;AAID,wBAAgB,YAAY,CAC1B,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,MAAM,CAER;AAID,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAwC7D;AAYD,QAAA,MAAM,cAAc,qEAKV,CAAC;AACX,KAAK,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAMpD,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,2DAA2D;IAC3D,cAAc,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,IAAI,EAAE,YAAY,CAAC;IACnB,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,eAAe,EAAE,MAAM,CAAC;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