recallnest 3.0.0 → 4.0.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 (246) hide show
  1. package/CHANGELOG.md +304 -0
  2. package/README.md +251 -258
  3. package/README_CN.md +226 -247
  4. package/assets/ui/app.js +6 -1
  5. package/bin/recallnest.mjs +20 -37
  6. package/docs/api-reference.md +8 -0
  7. package/docs/architecture.md +18 -13
  8. package/eval/cases-canary.json +107 -9
  9. package/integrations/examples/claude-agent-sdk/memory-agent.ts +2 -0
  10. package/integrations/examples/langchain/memory-chain.py +4 -0
  11. package/integrations/examples/openai-agents-sdk/memory-agent.py +4 -0
  12. package/package.json +12 -3
  13. package/src/activity-counter.ts +1 -0
  14. package/src/adaptive-retrieval.ts +23 -0
  15. package/src/api-server.ts +13 -11
  16. package/src/asset-sync.ts +26 -2
  17. package/src/audit-log.ts +2 -0
  18. package/src/auto-gc.ts +4 -3
  19. package/src/belief-history.ts +137 -31
  20. package/src/capture-engine.ts +459 -71
  21. package/src/cascade-forget.ts +7 -3
  22. package/src/checkpoint-mirror.ts +417 -0
  23. package/src/cli.ts +574 -54
  24. package/src/conflict-engine.ts +43 -15
  25. package/src/consolidation-engine.ts +24 -3
  26. package/src/context-collapse-renderer.ts +8 -1
  27. package/src/context-composer-stable.ts +5 -1
  28. package/src/context-composer.ts +11 -2
  29. package/src/distill-lock.ts +246 -74
  30. package/src/dream-pipeline.ts +3 -1
  31. package/src/embedder.ts +24 -0
  32. package/src/env-config.ts +136 -0
  33. package/src/flock.ts +97 -0
  34. package/src/forget-engine.ts +342 -58
  35. package/src/gateway-server.ts +4 -0
  36. package/src/ingest-plan.ts +56 -0
  37. package/src/ingest.ts +294 -121
  38. package/src/kg-contradiction.ts +753 -0
  39. package/src/kg-extractor.ts +17 -0
  40. package/src/kg-store.ts +1 -1
  41. package/src/known-item-eval.ts +455 -0
  42. package/src/llm-client.ts +13 -26
  43. package/src/llm-consolidation.ts +2 -2
  44. package/src/mcp-tool-deps.ts +6 -0
  45. package/src/mcp-tools-advanced.ts +80 -45
  46. package/src/mcp-tools-core.ts +23 -17
  47. package/src/mcp-tools-governance.ts +13 -7
  48. package/src/memory-assets.ts +144 -8
  49. package/src/memory-boundaries.ts +19 -0
  50. package/src/memory-evolution.ts +9 -0
  51. package/src/memory-lint.ts +1 -1
  52. package/src/memory-output.ts +311 -14
  53. package/src/memory-reconcile.ts +1437 -0
  54. package/src/memory-schema.ts +11 -0
  55. package/src/memory-store-port.ts +1 -0
  56. package/src/minis-archive.ts +151 -0
  57. package/src/noise-filter.ts +15 -2
  58. package/src/pii-detector.ts +31 -1
  59. package/src/pivot-apply.ts +55 -5
  60. package/src/pivot-evidence.ts +128 -0
  61. package/src/ppr-traversal.ts +25 -1
  62. package/src/preference-matcher.ts +40 -28
  63. package/src/prospective-memory.ts +7 -4
  64. package/src/retriever.ts +297 -57
  65. package/src/retroactive-boost.ts +3 -2
  66. package/src/runtime-config.ts +15 -1
  67. package/src/scope-policy.ts +1 -0
  68. package/src/session-distiller.ts +6 -2
  69. package/src/session-engine.ts +11 -4
  70. package/src/session-output.ts +20 -1
  71. package/src/session-schema.ts +5 -2
  72. package/src/session-store.ts +59 -12
  73. package/src/skill-promotion.ts +67 -1
  74. package/src/store-receipts.ts +109 -0
  75. package/src/store-write-budget.ts +37 -0
  76. package/src/store.ts +298 -57
  77. package/src/text-fingerprint.ts +25 -0
  78. package/src/trigger-store.ts +443 -0
  79. package/src/ui-server.ts +22 -21
  80. package/src/version-manager.ts +19 -5
  81. package/src/write-verifier.ts +16 -11
  82. package/src/__tests__/access-tracker-novelty.test.ts +0 -324
  83. package/src/__tests__/activity-counter.test.ts +0 -125
  84. package/src/__tests__/adaptive-fidelity.test.ts +0 -102
  85. package/src/__tests__/admission-control.test.ts +0 -206
  86. package/src/__tests__/age-label.test.ts +0 -33
  87. package/src/__tests__/anchor-generator.test.ts +0 -67
  88. package/src/__tests__/api-server-security.test.ts +0 -102
  89. package/src/__tests__/auto-consolidation.test.ts +0 -168
  90. package/src/__tests__/auto-recall.test.ts +0 -131
  91. package/src/__tests__/babel-integration.test.ts +0 -144
  92. package/src/__tests__/batch-dedup.test.ts +0 -65
  93. package/src/__tests__/belief-history.test.ts +0 -220
  94. package/src/__tests__/canary-eval.test.ts +0 -114
  95. package/src/__tests__/capture-engine.test.ts +0 -1328
  96. package/src/__tests__/capture-heuristic.test.ts +0 -171
  97. package/src/__tests__/cascade-forget.test.ts +0 -210
  98. package/src/__tests__/category-min-scores.test.ts +0 -116
  99. package/src/__tests__/cc8-cc1-essential-context.test.ts +0 -298
  100. package/src/__tests__/circuit-breaker.test.ts +0 -99
  101. package/src/__tests__/cluster-consolidation.test.ts +0 -1236
  102. package/src/__tests__/confidence-metadata.test.ts +0 -125
  103. package/src/__tests__/confidence-tracker.test.ts +0 -261
  104. package/src/__tests__/conflict-advisor.test.ts +0 -206
  105. package/src/__tests__/conflict-escalation.test.ts +0 -149
  106. package/src/__tests__/conflict-lifecycle.test.ts +0 -83
  107. package/src/__tests__/conflict-output.test.ts +0 -85
  108. package/src/__tests__/conflict-store.test.ts +0 -418
  109. package/src/__tests__/connector-v1.test.ts +0 -181
  110. package/src/__tests__/consolidation-engine.test.ts +0 -520
  111. package/src/__tests__/constructive-retrieval.test.ts +0 -509
  112. package/src/__tests__/context-collapse-renderer.test.ts +0 -214
  113. package/src/__tests__/context-composer-pins.test.ts +0 -64
  114. package/src/__tests__/context-composer-task-selection.test.ts +0 -24
  115. package/src/__tests__/context-reconstructor.test.ts +0 -65
  116. package/src/__tests__/context-renderer.test.ts +0 -91
  117. package/src/__tests__/continuity-eval.test.ts +0 -275
  118. package/src/__tests__/continuity-schema.test.ts +0 -97
  119. package/src/__tests__/contracts.test.ts +0 -262
  120. package/src/__tests__/conversation-importer.test.ts +0 -692
  121. package/src/__tests__/core-recall-eval.test.ts +0 -235
  122. package/src/__tests__/core-summary.test.ts +0 -109
  123. package/src/__tests__/data-checkup.test.ts +0 -304
  124. package/src/__tests__/decay-exemption.test.ts +0 -129
  125. package/src/__tests__/dedup-actions.test.ts +0 -58
  126. package/src/__tests__/dedup-guard.test.ts +0 -39
  127. package/src/__tests__/deterministic-id.test.ts +0 -39
  128. package/src/__tests__/distill-lock.test.ts +0 -305
  129. package/src/__tests__/distill-session-argshape.test.ts +0 -79
  130. package/src/__tests__/doctor.test.ts +0 -319
  131. package/src/__tests__/dream-pipeline.test.ts +0 -820
  132. package/src/__tests__/dream-scope-isolation.test.ts +0 -386
  133. package/src/__tests__/dream-write-batching.test.ts +0 -211
  134. package/src/__tests__/drill-down.test.ts +0 -108
  135. package/src/__tests__/embedder.test.ts +0 -122
  136. package/src/__tests__/emotion-decay.test.ts +0 -46
  137. package/src/__tests__/emotion-detector.test.ts +0 -56
  138. package/src/__tests__/emotion-phase1-integration.test.ts +0 -153
  139. package/src/__tests__/emotion-retrieval.test.ts +0 -56
  140. package/src/__tests__/entity-resolver.test.ts +0 -58
  141. package/src/__tests__/env-config-invariant.test.ts +0 -80
  142. package/src/__tests__/env-config.test.ts +0 -211
  143. package/src/__tests__/error-signature-boost.test.ts +0 -87
  144. package/src/__tests__/error-signature.test.ts +0 -95
  145. package/src/__tests__/error-taxonomy.test.ts +0 -129
  146. package/src/__tests__/ethics-layer.test.ts +0 -476
  147. package/src/__tests__/event-segmenter.test.ts +0 -153
  148. package/src/__tests__/feature-flags-integration.test.ts +0 -54
  149. package/src/__tests__/frequency-tracker.test.ts +0 -113
  150. package/src/__tests__/freshness.test.ts +0 -186
  151. package/src/__tests__/graph-export.test.ts +0 -489
  152. package/src/__tests__/hotness-blend.test.ts +0 -283
  153. package/src/__tests__/ingest-chunking.test.ts +0 -44
  154. package/src/__tests__/ingest-scope-prefix.test.ts +0 -69
  155. package/src/__tests__/ingest.test.ts +0 -360
  156. package/src/__tests__/interference-detector.test.ts +0 -203
  157. package/src/__tests__/kg-extractor.test.ts +0 -192
  158. package/src/__tests__/kg-store.test.ts +0 -300
  159. package/src/__tests__/llm-client-pivot.test.ts +0 -628
  160. package/src/__tests__/llm-consolidation.test.ts +0 -226
  161. package/src/__tests__/maintenance-locks.test.ts +0 -197
  162. package/src/__tests__/mcp-efficiency.test.ts +0 -288
  163. package/src/__tests__/mcp-related-scopes.test.ts +0 -151
  164. package/src/__tests__/memory-boundaries.test.ts +0 -282
  165. package/src/__tests__/memory-evolution-b2-b3-e1.test.ts +0 -362
  166. package/src/__tests__/memory-evolution.test.ts +0 -271
  167. package/src/__tests__/memory-health-rebalance.test.ts +0 -144
  168. package/src/__tests__/memory-lint.test.ts +0 -421
  169. package/src/__tests__/memory-output.test.ts +0 -224
  170. package/src/__tests__/memory-promotion.test.ts +0 -315
  171. package/src/__tests__/memory-utility.test.ts +0 -256
  172. package/src/__tests__/migrate-dedup-ids.test.ts +0 -65
  173. package/src/__tests__/multi-vector.test.ts +0 -242
  174. package/src/__tests__/narrative-architecture.test.ts +0 -456
  175. package/src/__tests__/noise-filter.test.ts +0 -205
  176. package/src/__tests__/noise-prototype-bank.test.ts +0 -280
  177. package/src/__tests__/obsidian-connector.test.ts +0 -363
  178. package/src/__tests__/omitted-reporting.test.ts +0 -98
  179. package/src/__tests__/openai-contract.test.ts +0 -513
  180. package/src/__tests__/pending-review.test.ts +0 -77
  181. package/src/__tests__/pii-redact.test.ts +0 -333
  182. package/src/__tests__/pivot-apply.test.ts +0 -373
  183. package/src/__tests__/pivot-distill-supervisor.test.ts +0 -457
  184. package/src/__tests__/pivot-distill.test.ts +0 -1178
  185. package/src/__tests__/post-retrieval-filter.test.ts +0 -178
  186. package/src/__tests__/ppr-traversal.test.ts +0 -256
  187. package/src/__tests__/prediction-engine.test.ts +0 -349
  188. package/src/__tests__/predictive-prospective-memory.test.ts +0 -416
  189. package/src/__tests__/preference-guard-smoke.test.ts +0 -211
  190. package/src/__tests__/preference-matcher.test.ts +0 -282
  191. package/src/__tests__/preference-slots.test.ts +0 -205
  192. package/src/__tests__/promotion-distinct-sources.test.ts +0 -162
  193. package/src/__tests__/prospective-memory.test.ts +0 -283
  194. package/src/__tests__/pull-from-macbook-sync-only.test.ts +0 -679
  195. package/src/__tests__/query-entity-detector.test.ts +0 -171
  196. package/src/__tests__/query-expander-alias.test.ts +0 -146
  197. package/src/__tests__/query-expander.test.ts +0 -34
  198. package/src/__tests__/recall-gate.test.ts +0 -266
  199. package/src/__tests__/recall-governor.test.ts +0 -227
  200. package/src/__tests__/recall-mode.test.ts +0 -64
  201. package/src/__tests__/resolve-db-path.test.ts +0 -130
  202. package/src/__tests__/resolve-tier.test.ts +0 -64
  203. package/src/__tests__/result-synthesizer.test.ts +0 -198
  204. package/src/__tests__/resume-context.test.ts +0 -4898
  205. package/src/__tests__/retrieval-eval.test.ts +0 -163
  206. package/src/__tests__/retrieval-trace.test.ts +0 -213
  207. package/src/__tests__/retrieve-audit-revision.test.ts +0 -255
  208. package/src/__tests__/retriever-boundary-weight.test.ts +0 -136
  209. package/src/__tests__/retriever-lazy-init-dispatch.test.ts +0 -123
  210. package/src/__tests__/retroactive-boost.test.ts +0 -223
  211. package/src/__tests__/salience-scoring.test.ts +0 -106
  212. package/src/__tests__/scope-inventory.test.ts +0 -200
  213. package/src/__tests__/scope-policy.test.ts +0 -69
  214. package/src/__tests__/scope-suggester.test.ts +0 -80
  215. package/src/__tests__/session-checkpoint.test.ts +0 -291
  216. package/src/__tests__/session-distiller.test.ts +0 -640
  217. package/src/__tests__/session-gc.test.ts +0 -215
  218. package/src/__tests__/skill-engine.test.ts +0 -552
  219. package/src/__tests__/skill-promotion.test.ts +0 -654
  220. package/src/__tests__/skill-verifier.test.ts +0 -122
  221. package/src/__tests__/source-heartbeat.test.ts +0 -254
  222. package/src/__tests__/stable-context-length-contract.test.ts +0 -62
  223. package/src/__tests__/store-patch-metadata.test.ts +0 -235
  224. package/src/__tests__/store-read-consistency.test.ts +0 -122
  225. package/src/__tests__/store-schema-migration.test.ts +0 -87
  226. package/src/__tests__/store-scope-audit.test.ts +0 -81
  227. package/src/__tests__/store-upsert.test.ts +0 -201
  228. package/src/__tests__/supersede-chain.test.ts +0 -154
  229. package/src/__tests__/synthesis-contract.test.ts +0 -252
  230. package/src/__tests__/synthesis-promotion.test.ts +0 -369
  231. package/src/__tests__/temporal-parser.test.ts +0 -241
  232. package/src/__tests__/temporal-validity.test.ts +0 -160
  233. package/src/__tests__/term-registry-terminal-roster.test.ts +0 -127
  234. package/src/__tests__/term-registry.test.ts +0 -121
  235. package/src/__tests__/tool-error-surfacing.test.ts +0 -98
  236. package/src/__tests__/tool-output-compressor.test.ts +0 -160
  237. package/src/__tests__/topic-tag.test.ts +0 -113
  238. package/src/__tests__/trusted-memory.test.ts +0 -867
  239. package/src/__tests__/ui-server-security.test.ts +0 -93
  240. package/src/__tests__/usage-tracker.test.ts +0 -287
  241. package/src/__tests__/utility-weight.test.ts +0 -57
  242. package/src/__tests__/verbatim-self-recall.test.ts +0 -279
  243. package/src/__tests__/version-manager.test.ts +0 -248
  244. package/src/__tests__/workflow-observation-skill-outcome.test.ts +0 -352
  245. package/src/__tests__/workflow-observation.test.ts +0 -433
  246. package/src/__tests__/write-verifier.test.ts +0 -122
@@ -1,679 +0,0 @@
1
- import { describe, expect, it } from "bun:test";
2
- import {
3
- chmodSync,
4
- existsSync,
5
- mkdirSync,
6
- mkdtempSync,
7
- readFileSync,
8
- renameSync,
9
- statSync,
10
- symlinkSync,
11
- writeFileSync,
12
- } from "node:fs";
13
- import { tmpdir } from "node:os";
14
- import { dirname, join, resolve } from "node:path";
15
- import { spawnSync } from "node:child_process";
16
-
17
- const REPO_ROOT = resolve(import.meta.dir, "../..");
18
- const SCRIPT = join(REPO_ROOT, "scripts", "pull-from-macbook.sh");
19
- const TEST_TIMEOUT_MS = 30_000;
20
-
21
- interface Harness {
22
- root: string;
23
- home: string;
24
- remoteHome: string;
25
- report: string;
26
- rsyncLog: string;
27
- sshLog: string;
28
- registrarMarker: string;
29
- ingestMarker: string;
30
- env: NodeJS.ProcessEnv;
31
- }
32
-
33
- interface RsyncCall {
34
- args: string[];
35
- sourceArg: string;
36
- targetArg: string;
37
- dryRun: boolean;
38
- ignoreTimes: boolean;
39
- }
40
-
41
- function executable(path: string, source: string): void {
42
- writeFileSync(path, source, { mode: 0o700 });
43
- chmodSync(path, 0o700);
44
- }
45
-
46
- function fixture(path: string, content: string): void {
47
- mkdirSync(dirname(path), { recursive: true });
48
- writeFileSync(path, content);
49
- }
50
-
51
- function fakeRsyncSource(): string {
52
- return [
53
- "#!/usr/bin/env bun",
54
- 'import { appendFileSync, copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, readlinkSync, renameSync, statSync, symlinkSync, writeFileSync } from "node:fs";',
55
- 'import { basename, dirname, extname, join, relative, sep } from "node:path";',
56
- 'const args = process.argv.slice(2);',
57
- 'const sourceArg = args.at(-2) || "";',
58
- 'const targetArg = args.at(-1) || "";',
59
- 'const dryRun = args.includes("--dry-run");',
60
- 'const ignoreTimes = args.includes("--ignore-times");',
61
- 'const optionValues = new Set(["-e", "--exclude", "--include", "--out-format", "--rsync-path", "--timeout"]);',
62
- 'for (let index = 0; index < args.length - 2; index += 1) {',
63
- ' const arg = args[index];',
64
- ' if (optionValues.has(arg)) { if (index + 1 >= args.length - 2) process.exit(64); index += 1; continue; }',
65
- ' if (!arg.startsWith("-")) process.exit(64);',
66
- '}',
67
- 'appendFileSync(process.env.FAKE_RSYNC_LOG, JSON.stringify({ args: args.slice(0, -2), sourceArg, targetArg, dryRun, ignoreTimes }) + "\\n");',
68
- 'if (!dryRun && process.env.FAKE_CREATE_REPORT_DURING_SYNC && !existsSync(process.env.FAKE_CREATE_REPORT_DURING_SYNC)) writeFileSync(process.env.FAKE_CREATE_REPORT_DURING_SYNC, "racing-writer");',
69
- 'if (!dryRun && process.env.FAKE_BREAK_MAPPING_TMP) {',
70
- ' const report = process.env.FAKE_BREAK_MAPPING_TMP;',
71
- ' const prefix = basename(report) + ".tmp.";',
72
- ' const temporary = readdirSync(dirname(report))',
73
- ' .filter((name) => name.startsWith(prefix) && !name.endsWith(".saved"))',
74
- ' .map((name) => join(dirname(report), name))',
75
- ' .find((path) => statSync(path).isFile());',
76
- ' if (temporary) { renameSync(temporary, temporary + ".saved"); mkdirSync(temporary); }',
77
- '}',
78
- 'if (!sourceArg.startsWith("mac:")) process.exit(64);',
79
- 'const remoteHome = process.env.FAKE_REMOTE_HOME;',
80
- 'let remoteRaw = sourceArg.slice(4);',
81
- 'let sourcePath = remoteRaw;',
82
- 'if (remoteRaw === "~") sourcePath = remoteHome;',
83
- 'else if (remoteRaw.startsWith("~/")) sourcePath = join(remoteHome, remoteRaw.slice(2));',
84
- 'else if (!remoteRaw.startsWith("/")) sourcePath = join(remoteHome, remoteRaw);',
85
- 'if (!existsSync(sourcePath)) process.exit(23);',
86
- 'function walk(root) {',
87
- ' const files = [];',
88
- ' for (const entry of readdirSync(root, { withFileTypes: true })) {',
89
- ' const path = join(root, entry.name);',
90
- ' if (entry.isDirectory()) files.push(...walk(path));',
91
- ' else if (entry.isFile() || entry.isSymbolicLink()) files.push(path);',
92
- ' }',
93
- ' return files.sort();',
94
- '}',
95
- 'function included(path) {',
96
- ' const normalizedSource = sourcePath.split(sep).join("/");',
97
- ' const name = basename(path);',
98
- ' if (statSync(sourcePath).isFile()) return true;',
99
- ' if (normalizedSource.includes("/.gemini/tmp")) return name.startsWith("session-") && extname(name) === ".json";',
100
- ' if (normalizedSource.includes("/local-agent-mode-sessions")) return extname(name) === ".jsonl" && name !== "audit.jsonl";',
101
- ' if (normalizedSource.includes("/antigravity-cli/brain")) return name === "transcript_full.jsonl";',
102
- ' if (normalizedSource.includes("/antigravity-rescue/conversations")) return extname(name) === ".pb";',
103
- ' return extname(name) === ".jsonl";',
104
- '}',
105
- 'const sourceIsDirectory = statSync(sourcePath).isDirectory();',
106
- 'const files = (sourceIsDirectory ? walk(sourcePath) : [sourcePath]).filter(included);',
107
- 'if (dryRun && !ignoreTimes && process.env.FAKE_RSYNC_MUTATE_ON_VERIFY_SOURCE && sourceArg.includes(process.env.FAKE_RSYNC_MUTATE_ON_VERIFY_SOURCE) && files.length > 0) appendFileSync(files[0], "late-change");',
108
- 'const prefix = args.some((arg) => arg.includes("__RN_MAP__")) ? "__RN_MAP__" : "__RN_CHANGE__";',
109
- 'function copySource(source, destination) {',
110
- ' mkdirSync(dirname(destination), { recursive: true });',
111
- ' if (lstatSync(source).isSymbolicLink()) symlinkSync(readlinkSync(source), destination);',
112
- ' else copyFileSync(source, destination);',
113
- '}',
114
- 'const forcedFailure = Boolean(process.env.FAKE_RSYNC_FAIL_SOURCE && sourceArg.includes(process.env.FAKE_RSYNC_FAIL_SOURCE));',
115
- 'if (!dryRun && forcedFailure && files.length > 0) {',
116
- ' const source = files[0];',
117
- ' const rel = sourceIsDirectory ? relative(sourcePath, source).split(sep).join("/") : basename(source);',
118
- ' const destination = sourceIsDirectory ? join(targetArg, rel) : targetArg;',
119
- ' copySource(source, destination);',
120
- ' process.exit(23);',
121
- '}',
122
- 'for (const source of files) {',
123
- ' const rel = sourceIsDirectory ? relative(sourcePath, source).split(sep).join("/") : basename(source);',
124
- ' const destination = sourceIsDirectory ? join(targetArg, rel) : targetArg;',
125
- ' if (dryRun) {',
126
- ' const changed = !existsSync(destination) || !readFileSync(source).equals(readFileSync(destination));',
127
- ' const item = lstatSync(source).isSymbolicLink() ? "cL+++++++++" : ">f+++++++++";',
128
- ' if (ignoreTimes || changed) process.stdout.write(prefix + item + "|" + rel + "\\n");',
129
- ' continue;',
130
- ' }',
131
- ' copySource(source, destination);',
132
- '}',
133
- ].join("\n") + "\n";
134
- }
135
-
136
- function fakeSshSource(): string {
137
- return [
138
- "#!/usr/bin/env bun",
139
- 'import { appendFileSync, existsSync, statSync } from "node:fs";',
140
- 'import { join } from "node:path";',
141
- 'const args = process.argv.slice(2);',
142
- 'const command = args.join(" ");',
143
- 'appendFileSync(process.env.FAKE_SSH_LOG, command + "\\n");',
144
- 'if (process.env.FAKE_SSH_ONLINE !== "1") process.exit(255);',
145
- 'if (command.includes("echo online")) { console.log("online"); process.exit(0); }',
146
- 'if (process.env.FAKE_SSH_FAIL_PROBE && command.includes(process.env.FAKE_SSH_FAIL_PROBE)) process.exit(255);',
147
- 'if (command.includes("$HOME/.codex") && command.includes("session_index.jsonl")) { const path = join(process.env.FAKE_REMOTE_HOME, ".codex/session_index.jsonl"); process.exit(!existsSync(path) ? 2 : statSync(path).isFile() ? 0 : 3); }',
148
- 'if (command.includes("$HOME/.kimi-code") && command.includes("session_index.jsonl")) { const path = join(process.env.FAKE_REMOTE_HOME, ".kimi-code/session_index.jsonl"); process.exit(!existsSync(path) ? 2 : statSync(path).isFile() ? 0 : 3); }',
149
- 'if (command.includes("antigravity-rescue")) { const path = join(process.env.FAKE_REMOTE_HOME, "Downloads/antigravity-rescue/conversations"); process.exit(!existsSync(path) ? 2 : statSync(path).isDirectory() ? 0 : 3); }',
150
- 'process.exit(0);',
151
- ].join("\n") + "\n";
152
- }
153
-
154
- function makeHarness(): Harness {
155
- const root = mkdtempSync(join(tmpdir(), "pull-sync-only-"));
156
- const home = join(root, "home");
157
- const remoteHome = join(root, "remote-home");
158
- const fakeBin = join(root, "bin");
159
- const report = join(root, "mapping.tsv");
160
- const rsyncLog = join(root, "rsync.jsonl");
161
- const sshLog = join(root, "ssh.log");
162
- const registrarMarker = join(root, "registrar-called");
163
- const ingestMarker = join(root, "ingest-called");
164
-
165
- mkdirSync(fakeBin, { recursive: true });
166
- mkdirSync(join(home, "recallnest", "scripts"), { recursive: true });
167
- executable(join(fakeBin, "rsync"), fakeRsyncSource());
168
- executable(join(fakeBin, "ssh"), fakeSshSource());
169
- executable(
170
- join(home, "recallnest", "scripts", "codex-projectless-register.py"),
171
- [
172
- "#!/bin/bash",
173
- 'printf "called\\n" > "$FAKE_REGISTRAR_MARKER"',
174
- ].join("\n") + "\n",
175
- );
176
- executable(
177
- join(home, "recallnest", "scripts", "incremental-ingest.sh"),
178
- [
179
- "#!/bin/bash",
180
- 'printf "called\\n" > "$FAKE_INGEST_MARKER"',
181
- ].join("\n") + "\n",
182
- );
183
-
184
- fixture(join(remoteHome, ".claude", "projects", "p", "cc.jsonl"), "{\"source\":\"cc\"}\n");
185
- fixture(join(remoteHome, ".codex", "sessions", "2026", "codex.jsonl"), "{\"source\":\"codex\"}\n");
186
- fixture(join(remoteHome, ".codex", "archived_sessions", "archived.jsonl"), "{\"source\":\"archive\"}\n");
187
- fixture(
188
- join(remoteHome, ".codex", "session_index.jsonl"),
189
- "{\"id\":\"mac-codex\",\"updated_at\":\"2026-08-03T00:00:00Z\"}\n",
190
- );
191
- fixture(join(remoteHome, ".kimi-code", "sessions", "k1", "wire.jsonl"), "{\"source\":\"kimi\"}\n");
192
- fixture(join(remoteHome, ".kimi-code", "session_index.jsonl"), "{\"sessionId\":\"mac-kimi\"}\n");
193
- fixture(join(remoteHome, ".gemini", "tmp", "g1", "chats", "session-g.json"), "{\"source\":\"gemini\"}\n");
194
- fixture(
195
- join(
196
- remoteHome,
197
- "Library",
198
- "Application Support",
199
- "Claude",
200
- "local-agent-mode-sessions",
201
- "d1",
202
- ".claude",
203
- "projects",
204
- "p",
205
- "desktop-one.jsonl",
206
- ),
207
- "{\"source\":\"desktop\"}\n",
208
- );
209
- fixture(
210
- join(remoteHome, ".gemini", "antigravity-cli", "brain", "b1", "transcript_full.jsonl"),
211
- "{\"source\":\"agy-brain\"}\n",
212
- );
213
- fixture(
214
- join(remoteHome, "Downloads", "antigravity-rescue", "conversations", "legacy.pb"),
215
- "legacy-original",
216
- );
217
- fixture(
218
- join(remoteHome, ".gemini", "antigravity-cli", "conversations", "remote-cli.db"),
219
- "remote-cli-original",
220
- );
221
- fixture(
222
- join(remoteHome, ".gemini", "antigravity", "conversations", "remote-app.db"),
223
- "remote-app-original",
224
- );
225
-
226
- for (let index = 1; index <= 24; index += 1) {
227
- fixture(
228
- join(home, "machine-data", "macbook-agy", "conversations", "existing-" + index + ".db"),
229
- "mini-existing-" + index,
230
- );
231
- }
232
-
233
- const env: NodeJS.ProcessEnv = {
234
- ...process.env,
235
- LC_ALL: "C",
236
- PULL_FROM_MACBOOK_HOME: home,
237
- PULL_FROM_MACBOOK_RSYNC: join(fakeBin, "rsync"),
238
- PULL_FROM_MACBOOK_SSH: join(fakeBin, "ssh"),
239
- FAKE_REMOTE_HOME: remoteHome,
240
- FAKE_RSYNC_LOG: rsyncLog,
241
- FAKE_SSH_LOG: sshLog,
242
- FAKE_SSH_ONLINE: "1",
243
- FAKE_REGISTRAR_MARKER: registrarMarker,
244
- FAKE_INGEST_MARKER: ingestMarker,
245
- PULL_FROM_MACBOOK_LOG: join(root, "pull.log"),
246
- PULL_FROM_MACBOOK_LOG_DIR: join(root, "logs"),
247
- };
248
-
249
- return {
250
- root,
251
- home,
252
- remoteHome,
253
- report,
254
- rsyncLog,
255
- sshLog,
256
- registrarMarker,
257
- ingestMarker,
258
- env,
259
- };
260
- }
261
-
262
- function run(harness: Harness, args: string[], extraEnv: NodeJS.ProcessEnv = {}) {
263
- return spawnSync("/bin/bash", [SCRIPT, ...args], {
264
- env: { ...harness.env, ...extraEnv },
265
- encoding: "utf8",
266
- timeout: 30_000,
267
- });
268
- }
269
-
270
- function syncOnly(harness: Harness) {
271
- return run(harness, ["--sync-only", "--mapping-report", harness.report]);
272
- }
273
-
274
- function rsyncCalls(harness: Harness): RsyncCall[] {
275
- if (!existsSync(harness.rsyncLog)) return [];
276
- return readFileSync(harness.rsyncLog, "utf8")
277
- .trim()
278
- .split("\n")
279
- .filter(Boolean)
280
- .map((line) => JSON.parse(line) as RsyncCall);
281
- }
282
-
283
- function normalizedRsyncArgs(args: string[]): string[] {
284
- return args.filter(
285
- (arg) =>
286
- arg !== "--dry-run"
287
- && arg !== "--ignore-times"
288
- && arg !== "--itemize-changes"
289
- && !arg.startsWith("--out-format="),
290
- );
291
- }
292
-
293
- function unexpectedPositionalArgs(args: string[]): string[] {
294
- const valueOptions = new Set(["-e", "--exclude", "--include", "--out-format", "--rsync-path", "--timeout"]);
295
- const unexpected: string[] = [];
296
- for (let index = 0; index < args.length; index += 1) {
297
- const arg = args[index];
298
- if (valueOptions.has(arg)) {
299
- index += 1;
300
- continue;
301
- }
302
- if (!arg.startsWith("-")) unexpected.push(arg);
303
- }
304
- return unexpected;
305
- }
306
-
307
- function dbContents(directory: string): Record<string, string> {
308
- const result: Record<string, string> = {};
309
- for (let index = 1; index <= 24; index += 1) {
310
- const name = "existing-" + index + ".db";
311
- result[name] = readFileSync(join(directory, name), "utf8");
312
- }
313
- return result;
314
- }
315
-
316
- describe("pull-from-macbook --sync-only", () => {
317
- it("syncs allowed sources, verifies identical rsync arguments, and emits per-file mappings without ingest", () => {
318
- const harness = makeHarness();
319
- expect(harness.env.HOME).toBe(process.env.HOME);
320
- const localDbDir = join(harness.home, "machine-data", "macbook-agy", "conversations");
321
- const localDbBefore = dbContents(localDbDir);
322
- const remoteCliDb = join(harness.remoteHome, ".gemini", "antigravity-cli", "conversations", "remote-cli.db");
323
- const remoteAppDb = join(harness.remoteHome, ".gemini", "antigravity", "conversations", "remote-app.db");
324
- const remoteCliBefore = readFileSync(remoteCliDb, "utf8");
325
- const remoteAppBefore = readFileSync(remoteAppDb, "utf8");
326
-
327
- const result = syncOnly(harness);
328
-
329
- expect(result.status).toBe(0);
330
- expect(existsSync(harness.ingestMarker)).toBe(false);
331
- expect(existsSync(harness.registrarMarker)).toBe(false);
332
- expect(readFileSync(join(harness.home, ".claude", "projects", "p", "cc.jsonl"), "utf8")).toContain("cc");
333
- expect(
334
- readFileSync(
335
- join(harness.home, "recallnest", "data", "desktop-import", "desktop-one.jsonl"),
336
- "utf8",
337
- ),
338
- ).toContain("desktop");
339
- expect(readFileSync(join(harness.home, ".codex", "session_index.jsonl"), "utf8")).toContain("mac-codex");
340
- expect(readFileSync(join(harness.home, ".kimi-code", "session_index.jsonl"), "utf8")).toContain("mac-kimi");
341
-
342
- const mapping = readFileSync(harness.report, "utf8");
343
- expect(mapping.split("\n")[0]).toBe(
344
- "source_kind\tsource_file\tlocal_target\tderived_target\tstatus",
345
- );
346
- expect(mapping).toContain("claude-code\tmac:~/.claude/projects/p/cc.jsonl");
347
- expect(mapping).toContain(
348
- join(harness.home, "recallnest", "data", "desktop-import", "desktop-one.jsonl"),
349
- );
350
- expect(mapping).toContain("desktop-flat\t");
351
- expect(mapping).toContain("codex-index-merge\t");
352
- for (const line of mapping.trim().split("\n").slice(1)) {
353
- expect(line.split("\t")).toHaveLength(5);
354
- }
355
- const desktopTransportRows = mapping
356
- .trim()
357
- .split("\n")
358
- .slice(1)
359
- .map((line) => line.split("\t"))
360
- .filter(([sourceKind]) => sourceKind === "claude-desktop");
361
- expect(desktopTransportRows.length).toBeGreaterThan(0);
362
- expect(
363
- desktopTransportRows.every((fields) => fields[4] === "local-verified:derived-pending"),
364
- ).toBe(true);
365
- expect(statSync(harness.report).mode & 0o777).toBe(0o600);
366
- expect(existsSync(join(harness.home, ".codex", ".codex-global-state.json"))).toBe(false);
367
-
368
- const calls = rsyncCalls(harness);
369
- const grouped = new Map<string, RsyncCall[]>();
370
- for (const call of calls) {
371
- grouped.set(call.sourceArg, [...(grouped.get(call.sourceArg) || []), call]);
372
- }
373
- expect(grouped.size).toBe(10);
374
- for (const sourceCalls of grouped.values()) {
375
- expect(sourceCalls).toHaveLength(3);
376
- const real = sourceCalls.find((call) => !call.dryRun);
377
- const verify = sourceCalls.find((call) => call.dryRun && !call.ignoreTimes);
378
- const inventory = sourceCalls.find((call) => call.dryRun && call.ignoreTimes);
379
- expect(real).toBeDefined();
380
- expect(verify).toBeDefined();
381
- expect(inventory).toBeDefined();
382
- expect(normalizedRsyncArgs(verify!.args)).toEqual(real!.args);
383
- expect(normalizedRsyncArgs(inventory!.args)).toEqual(real!.args);
384
- expect(verify!.targetArg).toBe(real!.targetArg);
385
- expect(inventory!.targetArg).toBe(real!.targetArg);
386
- expect(unexpectedPositionalArgs(real!.args)).toEqual([]);
387
- }
388
- const desktopSource = "mac:Library/Application Support/Claude/local-agent-mode-sessions/";
389
- const desktopCalls = grouped.get(desktopSource);
390
- expect(desktopCalls).toHaveLength(3);
391
- expect(desktopCalls!.every((call) => call.args.includes("-s"))).toBe(true);
392
- expect(
393
- calls.some((call) =>
394
- call.sourceArg.includes("/.gemini/antigravity-cli/conversations/")
395
- || call.sourceArg.includes("/.gemini/antigravity/conversations/")
396
- ),
397
- ).toBe(false);
398
- const wrapperSource = readFileSync(SCRIPT, "utf8");
399
- expect(wrapperSource).not.toContain("mac:~/.gemini/antigravity-cli/conversations/");
400
- expect(wrapperSource).not.toContain("mac:~/.gemini/antigravity/conversations/");
401
-
402
- expect(dbContents(localDbDir)).toEqual(localDbBefore);
403
- expect(readFileSync(remoteCliDb, "utf8")).toBe(remoteCliBefore);
404
- expect(readFileSync(remoteAppDb, "utf8")).toBe(remoteAppBefore);
405
- const sshCalls = readFileSync(harness.sshLog, "utf8");
406
- expect(sshCalls).toContain("echo online");
407
- expect(sshCalls).toContain("$HOME/.codex");
408
- expect(sshCalls).toContain("$HOME/.kimi-code");
409
- expect(sshCalls).toContain("antigravity-rescue");
410
- }, TEST_TIMEOUT_MS);
411
-
412
- it("fails offline in sync-only mode but keeps the routine offline run successful", () => {
413
- const syncHarness = makeHarness();
414
- const syncResult = run(
415
- syncHarness,
416
- ["--sync-only", "--mapping-report", syncHarness.report],
417
- { FAKE_SSH_ONLINE: "0" },
418
- );
419
- expect(syncResult.status).not.toBe(0);
420
- expect(readFileSync(syncHarness.report, "utf8")).toContain("transport\tmac\t-\t-\toffline");
421
- expect(existsSync(syncHarness.registrarMarker)).toBe(false);
422
- expect(existsSync(syncHarness.ingestMarker)).toBe(false);
423
- expect(rsyncCalls(syncHarness)).toHaveLength(0);
424
-
425
- const routineHarness = makeHarness();
426
- const routineResult = run(routineHarness, [], { FAKE_SSH_ONLINE: "0" });
427
- expect(routineResult.status).toBe(0);
428
- expect(existsSync(routineHarness.registrarMarker)).toBe(true);
429
- expect(existsSync(routineHarness.ingestMarker)).toBe(false);
430
-
431
- const existingReportHarness = makeHarness();
432
- fixture(existingReportHarness.report, "keep-existing-report");
433
- const existingReportResult = syncOnly(existingReportHarness);
434
- expect(existingReportResult.status).not.toBe(0);
435
- expect(readFileSync(existingReportHarness.report, "utf8")).toBe("keep-existing-report");
436
- expect(existsSync(existingReportHarness.sshLog)).toBe(false);
437
-
438
- const racingReportHarness = makeHarness();
439
- const racingReportResult = run(
440
- racingReportHarness,
441
- ["--sync-only", "--mapping-report", racingReportHarness.report],
442
- { FAKE_CREATE_REPORT_DURING_SYNC: racingReportHarness.report },
443
- );
444
- expect(racingReportResult.status).not.toBe(0);
445
- expect(readFileSync(racingReportHarness.report, "utf8")).toBe("racing-writer");
446
- }, TEST_TIMEOUT_MS);
447
-
448
- it("fails before flattening when Desktop basenames collide", () => {
449
- const harness = makeHarness();
450
- fixture(
451
- join(
452
- harness.remoteHome,
453
- "Library",
454
- "Application Support",
455
- "Claude",
456
- "local-agent-mode-sessions",
457
- "d2",
458
- ".claude",
459
- "projects",
460
- "other",
461
- "Desktop-One.jsonl",
462
- ),
463
- "{\"source\":\"collision\"}\n",
464
- );
465
-
466
- const result = syncOnly(harness);
467
-
468
- expect(result.status).not.toBe(0);
469
- expect(readFileSync(harness.report, "utf8")).toContain("basename-collision");
470
- expect(
471
- existsSync(join(harness.home, "recallnest", "data", "desktop-import", "desktop-one.jsonl")),
472
- ).toBe(false);
473
- expect(existsSync(harness.ingestMarker)).toBe(false);
474
-
475
- const symlinkHarness = makeHarness();
476
- const linkedContent = join(symlinkHarness.remoteHome, "linked-content.jsonl");
477
- fixture(linkedContent, "{\"source\":\"must-not-follow\"}\n");
478
- const linkedSession = join(
479
- symlinkHarness.remoteHome,
480
- "Library",
481
- "Application Support",
482
- "Claude",
483
- "local-agent-mode-sessions",
484
- "d2",
485
- ".claude",
486
- "projects",
487
- "other",
488
- "linked.jsonl",
489
- );
490
- mkdirSync(dirname(linkedSession), { recursive: true });
491
- symlinkSync(linkedContent, linkedSession);
492
-
493
- const symlinkResult = syncOnly(symlinkHarness);
494
-
495
- expect(symlinkResult.status).not.toBe(0);
496
- expect(readFileSync(symlinkHarness.report, "utf8")).toContain("unsafe-symlink");
497
- expect(
498
- existsSync(join(symlinkHarness.home, "recallnest", "data", "desktop-import", "linked.jsonl")),
499
- ).toBe(false);
500
-
501
- const destinationHarness = makeHarness();
502
- const outsideTarget = join(destinationHarness.root, "outside-target.jsonl");
503
- fixture(outsideTarget, "outside-must-not-be-ingested");
504
- const destinationLink = join(
505
- destinationHarness.home,
506
- "recallnest",
507
- "data",
508
- "desktop-import",
509
- "desktop-one.jsonl",
510
- );
511
- mkdirSync(dirname(destinationLink), { recursive: true });
512
- symlinkSync(outsideTarget, destinationLink);
513
-
514
- const destinationResult = syncOnly(destinationHarness);
515
-
516
- expect(destinationResult.status).not.toBe(0);
517
- expect(readFileSync(destinationHarness.report, "utf8")).toContain(
518
- "unsafe-destination-symlink",
519
- );
520
- expect(readFileSync(outsideTarget, "utf8")).toBe("outside-must-not-be-ingested");
521
- }, TEST_TIMEOUT_MS);
522
-
523
- it("surfaces a Desktop copy failure and does not ingest", () => {
524
- const harness = makeHarness();
525
- mkdirSync(
526
- join(harness.home, "recallnest", "data", "desktop-import", "desktop-one.jsonl"),
527
- { recursive: true },
528
- );
529
-
530
- const result = syncOnly(harness);
531
-
532
- expect(result.status).not.toBe(0);
533
- expect(readFileSync(harness.report, "utf8")).toContain("copy-failed:IsADirectoryError");
534
- expect(existsSync(harness.ingestMarker)).toBe(false);
535
- }, TEST_TIMEOUT_MS);
536
-
537
- it("does not derive from a failed or partial source sync", () => {
538
- const desktopHarness = makeHarness();
539
- const desktopImport = join(
540
- desktopHarness.home,
541
- "recallnest",
542
- "data",
543
- "desktop-import",
544
- "desktop-one.jsonl",
545
- );
546
- fixture(desktopImport, "known-good-desktop");
547
-
548
- const desktopResult = run(
549
- desktopHarness,
550
- ["--sync-only", "--mapping-report", desktopHarness.report],
551
- { FAKE_RSYNC_FAIL_SOURCE: "local-agent-mode-sessions" },
552
- );
553
-
554
- expect(desktopResult.status).not.toBe(0);
555
- expect(readFileSync(desktopImport, "utf8")).toBe("known-good-desktop");
556
- expect(readFileSync(desktopHarness.report, "utf8")).toContain(
557
- "derived-skipped:source-sync-failed",
558
- );
559
-
560
- const indexHarness = makeHarness();
561
- const kimiIndex = join(indexHarness.home, ".kimi-code", "session_index.jsonl");
562
- fixture(kimiIndex, "{\"sessionId\":\"mini-only\"}\n");
563
-
564
- const indexResult = run(
565
- indexHarness,
566
- ["--sync-only", "--mapping-report", indexHarness.report],
567
- { FAKE_RSYNC_FAIL_SOURCE: ".kimi-code/session_index.jsonl" },
568
- );
569
-
570
- expect(indexResult.status).not.toBe(0);
571
- expect(readFileSync(kimiIndex, "utf8")).toContain("mini-only");
572
- expect(readFileSync(kimiIndex, "utf8")).not.toContain("mac-kimi");
573
- expect(readFileSync(indexHarness.report, "utf8")).toContain(
574
- "kimi-index-merge\t" + join(indexHarness.home, ".kimi-code", "session_index.macbook.jsonl"),
575
- );
576
- expect(readFileSync(indexHarness.report, "utf8")).toContain(
577
- "derived-skipped:source-sync-failed",
578
- );
579
- }, TEST_TIMEOUT_MS);
580
-
581
- it("distinguishes absent probes from partial, transport, and wrong-type failures", () => {
582
- const legacyHarness = makeHarness();
583
- const legacyResult = run(
584
- legacyHarness,
585
- ["--sync-only", "--mapping-report", legacyHarness.report],
586
- { FAKE_RSYNC_FAIL_SOURCE: "antigravity-rescue/conversations" },
587
- );
588
- const legacyMapping = readFileSync(legacyHarness.report, "utf8");
589
- expect(legacyResult.status).not.toBe(0);
590
- expect(legacyMapping).toContain("agy-legacy-pb\t");
591
- expect(legacyMapping).toContain("sync-failed:23");
592
- expect(legacyMapping).not.toContain(
593
- "agy-legacy-pb\tmac:~/Downloads/antigravity-rescue/conversations/\t"
594
- + join(legacyHarness.home, "machine-data", "macbook-agy", "legacy-pb")
595
- + "/\t"
596
- + join(legacyHarness.home, "machine-data", "macbook-agy", "legacy-pb")
597
- + "/\tsource-absent",
598
- );
599
-
600
- const probeHarness = makeHarness();
601
- const probeResult = run(
602
- probeHarness,
603
- ["--sync-only", "--mapping-report", probeHarness.report],
604
- { FAKE_SSH_FAIL_PROBE: "$HOME/.codex" },
605
- );
606
- expect(probeResult.status).not.toBe(0);
607
- expect(readFileSync(probeHarness.report, "utf8")).toContain("probe-failed:255");
608
- expect(
609
- rsyncCalls(probeHarness).some((call) =>
610
- call.sourceArg === "mac:~/.codex/session_index.jsonl"
611
- ),
612
- ).toBe(false);
613
-
614
- const wrongTypeHarness = makeHarness();
615
- const wrongTypeIndex = join(
616
- wrongTypeHarness.remoteHome,
617
- ".codex",
618
- "session_index.jsonl",
619
- );
620
- renameSync(wrongTypeIndex, wrongTypeIndex + ".saved");
621
- mkdirSync(wrongTypeIndex);
622
- const wrongTypeResult = syncOnly(wrongTypeHarness);
623
- const wrongTypeMapping = readFileSync(wrongTypeHarness.report, "utf8");
624
- expect(wrongTypeResult.status).not.toBe(0);
625
- expect(wrongTypeMapping).toContain("probe-failed:3");
626
- expect(wrongTypeMapping).not.toContain(
627
- "codex-session-index\tmac:~/.codex/session_index.jsonl\t"
628
- + join(wrongTypeHarness.home, ".codex", "session_index.macbook.jsonl")
629
- + "\t"
630
- + join(wrongTypeHarness.home, ".codex", "session_index.jsonl")
631
- + "\tsource-absent",
632
- );
633
-
634
- const absentHarness = makeHarness();
635
- const absentIndex = join(absentHarness.remoteHome, ".codex", "session_index.jsonl");
636
- renameSync(absentIndex, absentIndex + ".saved");
637
- const absentResult = syncOnly(absentHarness);
638
- expect(absentResult.status).toBe(0);
639
- expect(readFileSync(absentHarness.report, "utf8")).toContain(
640
- "codex-session-index\tmac:~/.codex/session_index.jsonl\t"
641
- + join(absentHarness.home, ".codex", "session_index.macbook.jsonl")
642
- + "\t"
643
- + join(absentHarness.home, ".codex", "session_index.jsonl")
644
- + "\tsource-absent",
645
- );
646
- }, TEST_TIMEOUT_MS);
647
-
648
- it("surfaces mapping append failures without installing a report or ingesting", () => {
649
- const harness = makeHarness();
650
- const result = run(
651
- harness,
652
- ["--sync-only", "--mapping-report", harness.report],
653
- { FAKE_BREAK_MAPPING_TMP: harness.report },
654
- );
655
-
656
- expect(result.status).not.toBe(0);
657
- expect(result.stdout + result.stderr).toContain("sync-only 映射报告追加失败");
658
- expect(existsSync(harness.report)).toBe(false);
659
- expect(existsSync(harness.ingestMarker)).toBe(false);
660
- }, TEST_TIMEOUT_MS);
661
-
662
- it("marks files pending when a live source changes after inventory", () => {
663
- const liveSourceHarness = makeHarness();
664
- const liveSourceResult = run(
665
- liveSourceHarness,
666
- ["--sync-only", "--mapping-report", liveSourceHarness.report],
667
- { FAKE_RSYNC_MUTATE_ON_VERIFY_SOURCE: ".claude/projects/" },
668
- );
669
- const liveSourceRows = readFileSync(liveSourceHarness.report, "utf8")
670
- .trim()
671
- .split("\n")
672
- .slice(1)
673
- .map((line) => line.split("\t"))
674
- .filter(([sourceKind]) => sourceKind === "claude-code");
675
- expect(liveSourceResult.status).not.toBe(0);
676
- expect(liveSourceRows.some((fields) => fields[4] === "pending:1")).toBe(true);
677
- expect(liveSourceRows.some((fields) => fields[4] === "verified")).toBe(false);
678
- }, TEST_TIMEOUT_MS);
679
- });