@1agh/maude 0.60.7 → 1.0.3

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 (145) hide show
  1. package/apps/studio/acp/index.ts +1 -0
  2. package/apps/studio/ai-banner.tsx +1 -0
  3. package/apps/studio/annotations-context-toolbar.tsx +3 -1
  4. package/apps/studio/annotations-layer.tsx +33 -16
  5. package/apps/studio/api.ts +108 -18
  6. package/apps/studio/artboard-guides-overlay.tsx +5 -1
  7. package/apps/studio/assets-s3.ts +6 -1
  8. package/apps/studio/bin/_import-figma.mjs +8 -3
  9. package/apps/studio/build.ts +1 -1
  10. package/apps/studio/canvas-artifacts.ts +21 -0
  11. package/apps/studio/canvas-build.ts +14 -9
  12. package/apps/studio/canvas-comment-mount.tsx +27 -30
  13. package/apps/studio/canvas-icons.tsx +1 -1
  14. package/apps/studio/canvas-lib.tsx +94 -5
  15. package/apps/studio/canvas-list-watch.ts +14 -1
  16. package/apps/studio/canvas-shell.tsx +8 -0
  17. package/apps/studio/client/app.jsx +224 -45
  18. package/apps/studio/client/panels/GitPanel.jsx +121 -13
  19. package/apps/studio/client/panels/SettingsPanel.jsx +1 -1
  20. package/apps/studio/client/panels/SyncConsentDialog.jsx +182 -0
  21. package/apps/studio/client/panels/SyncPanel.jsx +595 -1
  22. package/apps/studio/client/styles/3-shell-maude.css +38 -0
  23. package/apps/studio/clip-ops.ts +8 -1
  24. package/apps/studio/cloud/endpoints.ts +265 -3
  25. package/apps/studio/collab/origins.ts +3 -1
  26. package/apps/studio/comments-overlay.tsx +5 -0
  27. package/apps/studio/config.schema.json +24 -0
  28. package/apps/studio/context-menu.tsx +40 -27
  29. package/apps/studio/context.ts +57 -8
  30. package/apps/studio/cursors-overlay.tsx +25 -13
  31. package/apps/studio/dist/client.bundle.js +686 -686
  32. package/apps/studio/dist/comment-mount.js +2 -2
  33. package/apps/studio/dist/styles.css +1 -1
  34. package/apps/studio/exporters/jobs.ts +77 -15
  35. package/apps/studio/exporters/remote.ts +201 -0
  36. package/apps/studio/exporters/video-encode-lib.ts +10 -4
  37. package/apps/studio/figma/to-strokes.ts +11 -9
  38. package/apps/studio/gifenc.d.ts +51 -0
  39. package/apps/studio/git/log-format.ts +88 -0
  40. package/apps/studio/git/safe-rel.ts +96 -0
  41. package/apps/studio/git/service.ts +46 -27
  42. package/apps/studio/hmr-broadcast.ts +10 -0
  43. package/apps/studio/http.ts +384 -6
  44. package/apps/studio/participants-chrome.tsx +1 -0
  45. package/apps/studio/photo-store.ts +7 -0
  46. package/apps/studio/react-augment.d.ts +17 -0
  47. package/apps/studio/runtime-bundle.ts +6 -1
  48. package/apps/studio/server.ts +43 -8
  49. package/apps/studio/sync/agent.ts +70 -82
  50. package/apps/studio/sync/asset-push.ts +28 -71
  51. package/apps/studio/sync/autocommit.ts +106 -5
  52. package/apps/studio/sync/cell-file-events.ts +117 -0
  53. package/apps/studio/sync/cell-pairing.ts +20 -5
  54. package/apps/studio/sync/cell-write-nudge.ts +244 -0
  55. package/apps/studio/sync/codec.ts +155 -3
  56. package/apps/studio/sync/cold-start-apply.ts +211 -0
  57. package/apps/studio/sync/ctl-heal.ts +253 -0
  58. package/apps/studio/sync/ctl-provider.ts +217 -0
  59. package/apps/studio/sync/decide-file.ts +335 -0
  60. package/apps/studio/sync/file-ledger.ts +581 -0
  61. package/apps/studio/sync/file-membership.ts +32 -0
  62. package/apps/studio/sync/file-plane.ts +1400 -0
  63. package/apps/studio/sync/file-pull.ts +41 -4
  64. package/apps/studio/sync/hub-link.ts +16 -1
  65. package/apps/studio/sync/hub-listing.ts +46 -0
  66. package/apps/studio/sync/hubs-config.ts +16 -0
  67. package/apps/studio/sync/index.ts +915 -308
  68. package/apps/studio/sync/journal-client.ts +200 -0
  69. package/apps/studio/sync/migrate-seed.ts +99 -67
  70. package/apps/studio/sync/poke.ts +50 -0
  71. package/apps/studio/sync/projection.ts +13 -0
  72. package/apps/studio/sync/pull-budget.ts +86 -0
  73. package/apps/studio/sync/settings.ts +110 -0
  74. package/apps/studio/sync/status.ts +68 -0
  75. package/apps/studio/sync/trash.ts +243 -0
  76. package/apps/studio/sync/untrusted.ts +30 -10
  77. package/apps/studio/test/_helpers.ts +8 -0
  78. package/apps/studio/test/canvas-build.test.ts +63 -0
  79. package/apps/studio/test/canvas-list-watch.test.ts +17 -0
  80. package/apps/studio/test/canvas-move-api.test.ts +31 -0
  81. package/apps/studio/test/canvas-origin-gate.test.ts +12 -0
  82. package/apps/studio/test/canvas-shell-build-error.test.ts +49 -0
  83. package/apps/studio/test/cloud-history-hardening.test.ts +165 -0
  84. package/apps/studio/test/cloud-history-posture.test.ts +230 -0
  85. package/apps/studio/test/cloud-session-role.test.ts +30 -0
  86. package/apps/studio/test/cloud-shell-surfaces.test.ts +39 -0
  87. package/apps/studio/test/cold-start-apply.test.ts +303 -0
  88. package/apps/studio/test/collab-stress.test.ts +9 -1
  89. package/apps/studio/test/export-lane.test.ts +245 -0
  90. package/apps/studio/test/fixtures/video-comp-fixture.tsx +1 -1
  91. package/apps/studio/test/git-log-format.test.ts +95 -0
  92. package/apps/studio/test/git-safe-rel.test.ts +132 -0
  93. package/apps/studio/test/hmr-broadcast.test.ts +26 -0
  94. package/apps/studio/test/peer-selection-follows-camera.test.tsx +131 -0
  95. package/apps/studio/test/shared-doc-cell-pairing.test.ts +5 -2
  96. package/apps/studio/test/sync-agent.test.ts +78 -0
  97. package/apps/studio/test/sync-asset-push.test.ts +71 -108
  98. package/apps/studio/test/sync-autocommit.test.ts +80 -0
  99. package/apps/studio/test/sync-cell-write-nudge.test.ts +346 -0
  100. package/apps/studio/test/sync-ctl-channel.test.ts +508 -0
  101. package/apps/studio/test/sync-decide-file.test.ts +420 -0
  102. package/apps/studio/test/sync-file-ledger.test.ts +334 -0
  103. package/apps/studio/test/sync-file-membership.test.ts +17 -1
  104. package/apps/studio/test/sync-file-plane.test.ts +976 -0
  105. package/apps/studio/test/sync-hub-listing.test.ts +46 -0
  106. package/apps/studio/test/sync-meta-codec.test.ts +76 -0
  107. package/apps/studio/test/sync-move-retirement.test.ts +231 -0
  108. package/apps/studio/test/sync-panel-surface.test.ts +20 -0
  109. package/apps/studio/test/sync-path-pull.test.ts +67 -1
  110. package/apps/studio/test/sync-pull-budget.test.ts +169 -0
  111. package/apps/studio/test/sync-seed-defers-to-hub.test.ts +83 -0
  112. package/apps/studio/test/sync-settings-routes.test.ts +195 -0
  113. package/apps/studio/test/sync-settings.test.ts +151 -0
  114. package/apps/studio/test/sync-status.test.ts +69 -0
  115. package/apps/studio/test/sync-trash.test.ts +132 -0
  116. package/apps/studio/test/workspace-containment.test.ts +45 -9
  117. package/apps/studio/tsconfig.json +9 -10
  118. package/apps/studio/use-annotation-resize.tsx +14 -3
  119. package/apps/studio/use-collab.tsx +3 -1
  120. package/apps/studio/whats-new.json +90 -0
  121. package/apps/studio/workspace-mode.ts +110 -62
  122. package/apps/studio/ws.ts +22 -1
  123. package/cli/bin/claude-design-server.mjs +19 -0
  124. package/cli/commands/design.mjs +25 -6
  125. package/cli/commands/hub-workspace.mjs +243 -22
  126. package/cli/commands/hub-workspace.test.mjs +171 -0
  127. package/cli/commands/hub.mjs +71 -1
  128. package/cli/lib/design-link.mjs +186 -1
  129. package/cli/lib/design-ownership.mjs +330 -0
  130. package/cli/lib/design-ownership.test.mjs +329 -0
  131. package/cli/lib/hubs-config.mjs +21 -0
  132. package/cli/lib/hubs-config.test.mjs +47 -1
  133. package/cli/lib/workspace-plan.mjs +298 -5
  134. package/cli/lib/workspace-plan.test.mjs +215 -1
  135. package/package.json +10 -10
  136. package/plugins/design/templates/_shell.html +43 -2
  137. package/plugins/design/templates/design-system-inspiration/SUB-AGENT-PROMPTS.md +1 -1
  138. package/plugins/design/templates/design-system-inspiration/core/preview/_motion-readme.md.tpl +1 -1
  139. package/apps/studio/server.mjs +0 -1312
  140. package/apps/studio/sync/asset-pull.ts +0 -210
  141. package/apps/studio/sync/asset-push-worker.ts +0 -84
  142. package/apps/studio/sync/asset-sweep.ts +0 -262
  143. package/apps/studio/test/sync-asset-pull.test.ts +0 -161
  144. package/apps/studio/test/sync-asset-push-worker.test.ts +0 -183
  145. package/apps/studio/test/sync-asset-sweep.test.ts +0 -243
@@ -0,0 +1,420 @@
1
+ // The ONE file decision — Sync v2 Increment 3 (DDR-226 §4).
2
+ //
3
+ // A decision table earns trust two ways, and this file does both.
4
+ //
5
+ // **Row by row**, because each row encodes a specific incident or rule and
6
+ // deserves to be named: DDR-076's "absence is not authority", the Syncthing
7
+ // edit-beats-delete rule, the self-echo that made the old fast lane need a
8
+ // probe-guard, the epoch-degraded downgrade.
9
+ //
10
+ // **And exhaustively**, because the rows are only worth anything if they are
11
+ // TOTAL. The generator below walks the entire {local × remote × ancestor ×
12
+ // tombstone × epoch × self × propagate} space and asserts the invariants that
13
+ // must hold for every point in it — the ones a hand-written case list is
14
+ // exactly the wrong tool for. Two of those invariants are the whole safety
15
+ // argument of the arc: nothing ever overwrites a local change without parking
16
+ // it first, and a file the hub has never heard of is never deleted.
17
+
18
+ import { describe, expect, test } from 'bun:test';
19
+
20
+ import {
21
+ conflictCopyName,
22
+ decideFile,
23
+ type FileAction,
24
+ type FileState,
25
+ isMaudeConflictCopy,
26
+ } from '../sync/decide-file.ts';
27
+
28
+ const A = 'a'.repeat(64); // one content
29
+ const B = 'b'.repeat(64); // another
30
+ const C = 'c'.repeat(64); // a third
31
+ const EMPTY = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'; // sha256('')
32
+
33
+ const at = (over: Partial<FileState> = {}): FileState => ({
34
+ path: 'system/ds/brand.css',
35
+ local: null,
36
+ remote: null,
37
+ ancestor: null,
38
+ ...over,
39
+ });
40
+
41
+ describe('decideFile — the clean cases', () => {
42
+ test('equal sides move nothing and adopt the ancestor', () => {
43
+ const d = decideFile(at({ local: A, remote: A, ancestor: null }));
44
+ expect(d.action).toBe('noop');
45
+ expect(d.adoptAncestor).toBe(true);
46
+ });
47
+
48
+ test('they moved, we did not ⇒ PULL', () => {
49
+ expect(decideFile(at({ local: A, remote: B, ancestor: A })).action).toBe('pull');
50
+ });
51
+
52
+ test('we moved, they did not ⇒ PUSH', () => {
53
+ expect(decideFile(at({ local: B, remote: A, ancestor: A })).action).toBe('push');
54
+ });
55
+
56
+ test('a file only the hub has ⇒ PULL (creation)', () => {
57
+ expect(decideFile(at({ local: null, remote: A, ancestor: null })).action).toBe('pull');
58
+ });
59
+
60
+ test('a file only we have ⇒ PUSH (creation)', () => {
61
+ expect(decideFile(at({ local: A, remote: null, ancestor: null })).action).toBe('push');
62
+ });
63
+
64
+ test('neither side has it ⇒ nothing', () => {
65
+ expect(decideFile(at()).action).toBe('noop');
66
+ });
67
+ });
68
+
69
+ describe('decideFile — absence is never authority (DDR-076, generalized)', () => {
70
+ test('a hub that LOST a file gets it back; it does not take ours', () => {
71
+ // The founding incident's shape: a fresh/rolled-back hub answering "I do
72
+ // not have that" must never read as "delete yours".
73
+ const d = decideFile(at({ local: A, remote: null, ancestor: A }));
74
+ expect(d.action).toBe('push');
75
+ expect(d.reason).toContain('absence is not authority');
76
+ });
77
+
78
+ test('and that holds even when our copy is EMPTY', () => {
79
+ // Emptiness is just a hash here. There is no branch where "nothing" wins
80
+ // for being nothing (DDR-223, generalized).
81
+ expect(decideFile(at({ local: EMPTY, remote: null, ancestor: EMPTY })).action).toBe('push');
82
+ });
83
+
84
+ test('an empty local file the hub has content for is an ordinary PULL, not a rescue', () => {
85
+ expect(decideFile(at({ local: EMPTY, remote: A, ancestor: EMPTY })).action).toBe('pull');
86
+ });
87
+
88
+ test('an empty file we just truncated is an ordinary PUSH', () => {
89
+ expect(decideFile(at({ local: EMPTY, remote: A, ancestor: A })).action).toBe('push');
90
+ });
91
+ });
92
+
93
+ describe('decideFile — divergence parks, never merges', () => {
94
+ test('both moved ⇒ conflict-aside, local parked FIRST', () => {
95
+ const d = decideFile(at({ local: B, remote: C, ancestor: A }));
96
+ expect(d.action).toBe('conflict-aside');
97
+ expect(d.parkLocal).toBe(true);
98
+ });
99
+
100
+ test('both present, differing, never reconciled here ⇒ conflict-aside', () => {
101
+ // The first-anchor case: no ancestor to appeal to, so we cannot know who
102
+ // moved. Guessing here is how a person loses an afternoon.
103
+ const d = decideFile(at({ local: A, remote: B, ancestor: null }));
104
+ expect(d.action).toBe('conflict-aside');
105
+ expect(d.parkLocal).toBe(true);
106
+ });
107
+ });
108
+
109
+ describe('decideFile — self-echo (why the fast lane needed a probe-guard)', () => {
110
+ test('a remote row carrying our own in-flight hash is adopted, not fought', () => {
111
+ const d = decideFile(at({ local: A, remote: B, ancestor: A, selfInFlight: true }));
112
+ expect(d.action).toBe('noop');
113
+ expect(d.adoptAncestor).toBe(true);
114
+ expect(d.reason).toContain('own in-flight write');
115
+ });
116
+
117
+ test('without the self flag the same state is an ordinary pull', () => {
118
+ expect(decideFile(at({ local: A, remote: B, ancestor: A })).action).toBe('pull');
119
+ });
120
+ });
121
+
122
+ describe('decideFile — deletion (Syncthing rules, emission gated)', () => {
123
+ test('deleted here and the hub still at our ancestor ⇒ HELD while emission is off', () => {
124
+ const d = decideFile(at({ local: null, remote: A, ancestor: A }));
125
+ expect(d.action).toBe('noop');
126
+ expect(d.reason).toContain('holding rather than resurrecting');
127
+ });
128
+
129
+ test('…and PROPAGATES once emission is on', () => {
130
+ const d = decideFile(at({ local: null, remote: A, ancestor: A, propagateDeletes: true }));
131
+ expect(d.action).toBe('propagate-delete');
132
+ });
133
+
134
+ test('an EDIT beats a delete', () => {
135
+ // Deleted here, but somebody changed it after we last saw it. Their work
136
+ // wins over our absence, in both flag states.
137
+ for (const propagateDeletes of [false, true]) {
138
+ const d = decideFile(at({ local: null, remote: B, ancestor: A, propagateDeletes }));
139
+ expect(d.action).toBe('pull');
140
+ }
141
+ });
142
+
143
+ test('a tombstone we agree with QUARANTINES, never unlinks', () => {
144
+ const d = decideFile(at({ local: A, remote: null, ancestor: A, remoteTombstone: true }));
145
+ expect(d.action).toBe('quarantine');
146
+ });
147
+
148
+ test('a tombstone for something we never had is simply adopted', () => {
149
+ const d = decideFile(at({ local: null, remote: null, ancestor: null, remoteTombstone: true }));
150
+ expect(d.action).toBe('noop');
151
+ expect(d.adoptAncestor).toBe(true);
152
+ });
153
+
154
+ test('a tombstone we disagree with REVIVES', () => {
155
+ const d = decideFile(at({ local: B, remote: null, ancestor: A, remoteTombstone: true }));
156
+ expect(d.action).toBe('revive');
157
+ });
158
+
159
+ test('a tombstone against a file we never reconciled revives too', () => {
160
+ // No ancestor ⇒ we cannot claim the tombstone describes our bytes.
161
+ expect(decideFile(at({ local: A, ancestor: null, remoteTombstone: true })).action).toBe(
162
+ 'revive'
163
+ );
164
+ });
165
+ });
166
+
167
+ describe('decideFile — a degraded epoch downgrades every overwrite', () => {
168
+ test('a PULL over a local change becomes keep-local + park-remote', () => {
169
+ const d = decideFile(at({ local: A, remote: B, ancestor: A, epochChanged: true }));
170
+ expect(d.action).toBe('noop');
171
+ expect(d.parkRemote).toBe(true);
172
+ expect(d.parkLocal).toBeUndefined();
173
+ });
174
+
175
+ test('a conflict becomes keep-local + park-remote too', () => {
176
+ const d = decideFile(at({ local: B, remote: C, ancestor: A, epochChanged: true }));
177
+ expect(d.action).toBe('noop');
178
+ expect(d.parkRemote).toBe(true);
179
+ });
180
+
181
+ test('but a file we have never had still downloads — there is nothing to endanger', () => {
182
+ expect(decideFile(at({ local: null, remote: A, epochChanged: true })).action).toBe('pull');
183
+ });
184
+
185
+ test('and a push is unaffected — uploading risks nothing local', () => {
186
+ expect(decideFile(at({ local: B, remote: A, ancestor: A, epochChanged: true })).action).toBe(
187
+ 'push'
188
+ );
189
+ });
190
+ });
191
+
192
+ /* ------------------------------------------------------------------------- */
193
+
194
+ describe('decideFile — TOTAL over the whole state space', () => {
195
+ const hashes = [null, A, B, EMPTY] as const;
196
+ const bools = [false, true] as const;
197
+
198
+ /** Every reachable point of the space. */
199
+ function* everyState(): Generator<FileState> {
200
+ for (const local of hashes) {
201
+ for (const remote of hashes) {
202
+ for (const ancestor of hashes) {
203
+ for (const remoteTombstone of bools) {
204
+ for (const epochChanged of bools) {
205
+ for (const selfInFlight of bools) {
206
+ for (const propagateDeletes of bools) {
207
+ yield {
208
+ path: 'system/ds/x.css',
209
+ local,
210
+ remote,
211
+ ancestor,
212
+ remoteTombstone,
213
+ epochChanged,
214
+ selfInFlight,
215
+ propagateDeletes,
216
+ };
217
+ }
218
+ }
219
+ }
220
+ }
221
+ }
222
+ }
223
+ }
224
+ }
225
+
226
+ const ALL: FileAction[] = [
227
+ 'noop',
228
+ 'pull',
229
+ 'push',
230
+ 'conflict-aside',
231
+ 'quarantine',
232
+ 'propagate-delete',
233
+ 'revive',
234
+ ];
235
+
236
+ test('every point produces a decision, and never throws', () => {
237
+ let n = 0;
238
+ for (const s of everyState()) {
239
+ const d = decideFile(s);
240
+ expect(ALL).toContain(d.action);
241
+ expect(typeof d.reason).toBe('string');
242
+ expect(d.reason.length).toBeGreaterThan(0);
243
+ n += 1;
244
+ }
245
+ // 4 × 4 × 4 × 2 × 2 × 2 × 2 = 1024
246
+ expect(n).toBe(1024);
247
+ });
248
+
249
+ test('INVARIANT: a local change is never overwritten without being parked', () => {
250
+ // The eraser class, stated as a property. If the local bytes differ from
251
+ // the ancestor, the person has unreconciled work at that path — and the
252
+ // only decisions allowed to land remote bytes over it are the ones that
253
+ // park local first.
254
+ for (const s of everyState()) {
255
+ const d = decideFile(s);
256
+ const localHasUnreconciledWork = s.local !== null && s.local !== s.ancestor;
257
+ const landsRemoteBytes = d.action === 'pull' || d.action === 'quarantine';
258
+ if (localHasUnreconciledWork && landsRemoteBytes) {
259
+ expect({ ...s, action: d.action, parkLocal: d.parkLocal }).toMatchObject({
260
+ parkLocal: true,
261
+ });
262
+ }
263
+ }
264
+ });
265
+
266
+ test('INVARIANT: `conflict-aside` ALWAYS parks local', () => {
267
+ for (const s of everyState()) {
268
+ const d = decideFile(s);
269
+ if (d.action === 'conflict-aside') expect(d.parkLocal).toBe(true);
270
+ }
271
+ });
272
+
273
+ test('INVARIANT: a delete never propagates while emission is off', () => {
274
+ for (const s of everyState()) {
275
+ if (s.propagateDeletes) continue;
276
+ expect(decideFile(s).action).not.toBe('propagate-delete');
277
+ }
278
+ });
279
+
280
+ test('INVARIANT: a delete NEVER propagates without an ancestor', () => {
281
+ // No ancestor means this machine never reconciled the path, so a local
282
+ // absence says nothing about whether it was ever here. Propagating that
283
+ // is the branch-switch mass-delete hazard.
284
+ for (const s of everyState()) {
285
+ if (s.ancestor !== null) continue;
286
+ expect(decideFile(s).action).not.toBe('propagate-delete');
287
+ }
288
+ });
289
+
290
+ test('INVARIANT: nothing is pushed when there is nothing local to push', () => {
291
+ for (const s of everyState()) {
292
+ const d = decideFile(s);
293
+ if (d.action === 'push' || d.action === 'revive') expect(s.local).not.toBeNull();
294
+ }
295
+ });
296
+
297
+ test('INVARIANT: nothing is pulled when the hub has nothing to give', () => {
298
+ for (const s of everyState()) {
299
+ const d = decideFile(s);
300
+ if (d.action === 'pull') {
301
+ expect(s.remote).not.toBeNull();
302
+ expect(s.remoteTombstone).toBe(false);
303
+ }
304
+ }
305
+ });
306
+
307
+ test('INVARIANT: a degraded epoch never lands remote bytes over local ones', () => {
308
+ for (const s of everyState()) {
309
+ if (!s.epochChanged) continue;
310
+ const d = decideFile(s);
311
+ if (s.local !== null && d.action === 'pull') {
312
+ // The only pull allowed with a local file present is one where the
313
+ // local file IS the ancestor and the tombstone is absent… and even
314
+ // that is downgraded. So: none.
315
+ expect(s.local).toBeNull();
316
+ }
317
+ }
318
+ });
319
+
320
+ test('INVARIANT: identical sides are always free', () => {
321
+ for (const s of everyState()) {
322
+ if (s.local === null || s.local !== s.remote || s.remoteTombstone) continue;
323
+ const d = decideFile(s);
324
+ expect(d.action).toBe('noop');
325
+ expect(d.adoptAncestor).toBe(true);
326
+ }
327
+ });
328
+
329
+ test('the decision depends on nothing but its inputs', () => {
330
+ for (const s of everyState()) {
331
+ expect(decideFile({ ...s })).toEqual(decideFile({ ...s }));
332
+ }
333
+ });
334
+ });
335
+
336
+ /* ------------------------------------------------------------------------- */
337
+
338
+ describe('conflict copies are attributable, and never mistaken for Syncthing’s', () => {
339
+ test('the name carries the path, a timestamp and a label', () => {
340
+ const name = conflictCopyName('system/ds/brand.css', Date.UTC(2026, 7, 17, 9, 30, 0), 'laptop');
341
+ expect(name).toBe('system/ds/brand.maude-conflict-2026-08-17T09-30-00-000-laptop.css');
342
+ });
343
+
344
+ test('and it is NEVER Syncthing’s pattern', () => {
345
+ // `~/git` runs real Syncthing. Emitting `*.sync-conflict-*` would make a
346
+ // conflict unattributable — you could not tell which program parked the
347
+ // file — and would invite the classifier to sync Syncthing's own copies.
348
+ const name = conflictCopyName('a/b.png', Date.now(), 'x');
349
+ expect(name).not.toContain('sync-conflict');
350
+ expect(isMaudeConflictCopy(name)).toBe(true);
351
+ expect(isMaudeConflictCopy('a/b.sync-conflict-20260807-113434-WELXGEB.png')).toBe(false);
352
+ });
353
+
354
+ test('a hostile label cannot escape the filename', () => {
355
+ const name = conflictCopyName('a/b.png', 0, '../../etc/passwd');
356
+ expect(name).not.toContain('..');
357
+ expect(name).not.toContain('/etc/');
358
+ expect(name.startsWith('a/')).toBe(true);
359
+ });
360
+
361
+ test('multi-dot names keep their whole extension', () => {
362
+ const name = conflictCopyName('assets/x.photo.json', 0, 'p');
363
+ expect(name.endsWith('.photo.json')).toBe(true);
364
+ });
365
+
366
+ test('an extensionless file still gets a usable name', () => {
367
+ expect(conflictCopyName('LICENSE', 0, 'p')).toContain('LICENSE.maude-conflict-');
368
+ });
369
+ });
370
+
371
+ describe('B6 (post-1.0 burn-down) — a degraded epoch damps the deletion row too', () => {
372
+ test('a tombstone we would agree with HOLDS under a degraded epoch', () => {
373
+ const d = decideFile({
374
+ local: 'X',
375
+ remote: null,
376
+ ancestor: 'X',
377
+ remoteTombstone: true,
378
+ epochChanged: true,
379
+ });
380
+ // The "agreement" is local === ancestor, and the degrade just
381
+ // disqualified exactly those ancestors — no quarantine on their strength.
382
+ expect(d.action).toBe('noop');
383
+ expect(d.reason).toContain('degraded');
384
+ });
385
+
386
+ test('the same tombstone quarantines on a CLEAN epoch (the damp is the delta)', () => {
387
+ const d = decideFile({
388
+ local: 'X',
389
+ remote: null,
390
+ ancestor: 'X',
391
+ remoteTombstone: true,
392
+ epochChanged: false,
393
+ });
394
+ expect(d.action).toBe('quarantine');
395
+ });
396
+
397
+ test('a tombstone for a file this machine does not have stays a noop either way', () => {
398
+ for (const epochChanged of [true, false]) {
399
+ const d = decideFile({
400
+ local: null,
401
+ remote: null,
402
+ ancestor: 'X',
403
+ remoteTombstone: true,
404
+ epochChanged,
405
+ });
406
+ expect(d.action).toBe('noop');
407
+ }
408
+ });
409
+
410
+ test('a CONTESTED tombstone still revives under degrade — an edit beats a delete regardless', () => {
411
+ const d = decideFile({
412
+ local: 'Y',
413
+ remote: null,
414
+ ancestor: 'X',
415
+ remoteTombstone: true,
416
+ epochChanged: true,
417
+ });
418
+ expect(d.action).toBe('revive');
419
+ });
420
+ });