@1agh/maude 0.60.6 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/studio/acp/index.ts +1 -0
- package/apps/studio/ai-banner.tsx +1 -0
- package/apps/studio/annotations-context-toolbar.tsx +3 -1
- package/apps/studio/annotations-layer.tsx +33 -16
- package/apps/studio/api.ts +108 -18
- package/apps/studio/artboard-guides-overlay.tsx +5 -1
- package/apps/studio/assets-s3.ts +6 -1
- package/apps/studio/bin/_import-figma.mjs +8 -3
- package/apps/studio/build.ts +1 -1
- package/apps/studio/canvas-artifacts.ts +21 -0
- package/apps/studio/canvas-build.ts +14 -9
- package/apps/studio/canvas-comment-mount.tsx +27 -30
- package/apps/studio/canvas-icons.tsx +1 -1
- package/apps/studio/canvas-lib.tsx +94 -5
- package/apps/studio/canvas-list-watch.ts +14 -1
- package/apps/studio/canvas-shell.tsx +8 -0
- package/apps/studio/client/app.jsx +224 -45
- package/apps/studio/client/panels/GitPanel.jsx +121 -13
- package/apps/studio/client/panels/SettingsPanel.jsx +1 -1
- package/apps/studio/client/panels/SyncConsentDialog.jsx +182 -0
- package/apps/studio/client/panels/SyncPanel.jsx +595 -1
- package/apps/studio/client/styles/3-shell-maude.css +38 -0
- package/apps/studio/clip-ops.ts +8 -1
- package/apps/studio/cloud/endpoints.ts +265 -3
- package/apps/studio/collab/origins.ts +3 -1
- package/apps/studio/comments-overlay.tsx +5 -0
- package/apps/studio/config.schema.json +24 -0
- package/apps/studio/context-menu.tsx +40 -27
- package/apps/studio/context.ts +57 -8
- package/apps/studio/cursors-overlay.tsx +25 -13
- package/apps/studio/dist/client.bundle.js +686 -686
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/exporters/jobs.ts +77 -15
- package/apps/studio/exporters/remote.ts +190 -0
- package/apps/studio/exporters/video-encode-lib.ts +10 -4
- package/apps/studio/figma/to-strokes.ts +11 -9
- package/apps/studio/gifenc.d.ts +51 -0
- package/apps/studio/git/log-format.ts +88 -0
- package/apps/studio/git/safe-rel.ts +96 -0
- package/apps/studio/git/service.ts +46 -27
- package/apps/studio/hmr-broadcast.ts +10 -0
- package/apps/studio/http.ts +384 -6
- package/apps/studio/participants-chrome.tsx +1 -0
- package/apps/studio/photo-store.ts +7 -0
- package/apps/studio/react-augment.d.ts +17 -0
- package/apps/studio/runtime-bundle.ts +6 -1
- package/apps/studio/server.ts +43 -8
- package/apps/studio/sync/agent.ts +70 -82
- package/apps/studio/sync/asset-push.ts +28 -6
- package/apps/studio/sync/autocommit.ts +106 -5
- package/apps/studio/sync/cell-file-events.ts +117 -0
- package/apps/studio/sync/cell-pairing.ts +20 -5
- package/apps/studio/sync/cell-write-nudge.ts +244 -0
- package/apps/studio/sync/codec.ts +155 -3
- package/apps/studio/sync/cold-start-apply.ts +211 -0
- package/apps/studio/sync/ctl-heal.ts +253 -0
- package/apps/studio/sync/ctl-provider.ts +217 -0
- package/apps/studio/sync/decide-file.ts +335 -0
- package/apps/studio/sync/file-ledger.ts +581 -0
- package/apps/studio/sync/file-membership.ts +32 -0
- package/apps/studio/sync/file-plane.ts +1400 -0
- package/apps/studio/sync/file-pull.ts +41 -4
- package/apps/studio/sync/hub-link.ts +16 -1
- package/apps/studio/sync/hub-listing.ts +46 -0
- package/apps/studio/sync/hubs-config.ts +16 -0
- package/apps/studio/sync/index.ts +919 -214
- package/apps/studio/sync/journal-client.ts +200 -0
- package/apps/studio/sync/migrate-seed.ts +99 -67
- package/apps/studio/sync/poke.ts +50 -0
- package/apps/studio/sync/projection.ts +13 -0
- package/apps/studio/sync/pull-budget.ts +86 -0
- package/apps/studio/sync/settings.ts +110 -0
- package/apps/studio/sync/status.ts +68 -0
- package/apps/studio/sync/trash.ts +243 -0
- package/apps/studio/sync/untrusted.ts +30 -10
- package/apps/studio/test/_helpers.ts +8 -0
- package/apps/studio/test/canvas-build.test.ts +63 -0
- package/apps/studio/test/canvas-list-watch.test.ts +17 -0
- package/apps/studio/test/canvas-move-api.test.ts +31 -0
- package/apps/studio/test/canvas-origin-gate.test.ts +12 -0
- package/apps/studio/test/canvas-shell-build-error.test.ts +49 -0
- package/apps/studio/test/cloud-history-hardening.test.ts +165 -0
- package/apps/studio/test/cloud-history-posture.test.ts +230 -0
- package/apps/studio/test/cloud-session-role.test.ts +30 -0
- package/apps/studio/test/cloud-shell-surfaces.test.ts +39 -0
- package/apps/studio/test/cold-start-apply.test.ts +303 -0
- package/apps/studio/test/collab-stress.test.ts +9 -1
- package/apps/studio/test/export-lane.test.ts +245 -0
- package/apps/studio/test/fixtures/video-comp-fixture.tsx +1 -1
- package/apps/studio/test/git-log-format.test.ts +95 -0
- package/apps/studio/test/git-safe-rel.test.ts +132 -0
- package/apps/studio/test/hmr-broadcast.test.ts +26 -0
- package/apps/studio/test/peer-selection-follows-camera.test.tsx +131 -0
- package/apps/studio/test/shared-doc-cell-pairing.test.ts +5 -2
- package/apps/studio/test/sync-agent.test.ts +78 -0
- package/apps/studio/test/sync-asset-push.test.ts +90 -16
- package/apps/studio/test/sync-autocommit.test.ts +80 -0
- package/apps/studio/test/sync-cell-write-nudge.test.ts +346 -0
- package/apps/studio/test/sync-ctl-channel.test.ts +508 -0
- package/apps/studio/test/sync-decide-file.test.ts +420 -0
- package/apps/studio/test/sync-file-ledger.test.ts +334 -0
- package/apps/studio/test/sync-file-membership.test.ts +17 -1
- package/apps/studio/test/sync-file-plane.test.ts +976 -0
- package/apps/studio/test/sync-hub-listing.test.ts +46 -0
- package/apps/studio/test/sync-meta-codec.test.ts +76 -0
- package/apps/studio/test/sync-move-retirement.test.ts +231 -0
- package/apps/studio/test/sync-panel-surface.test.ts +20 -0
- package/apps/studio/test/sync-path-pull.test.ts +67 -1
- package/apps/studio/test/sync-pull-budget.test.ts +169 -0
- package/apps/studio/test/sync-seed-defers-to-hub.test.ts +83 -0
- package/apps/studio/test/sync-settings-routes.test.ts +195 -0
- package/apps/studio/test/sync-settings.test.ts +151 -0
- package/apps/studio/test/sync-status.test.ts +69 -0
- package/apps/studio/test/sync-trash.test.ts +132 -0
- package/apps/studio/test/workspace-containment.test.ts +45 -9
- package/apps/studio/tsconfig.json +9 -10
- package/apps/studio/use-annotation-resize.tsx +14 -3
- package/apps/studio/use-collab.tsx +3 -1
- package/apps/studio/whats-new.json +99 -0
- package/apps/studio/workspace-mode.ts +110 -62
- package/apps/studio/ws.ts +22 -1
- package/cli/bin/claude-design-server.mjs +19 -0
- package/cli/commands/design.mjs +25 -6
- package/cli/commands/hub-workspace.mjs +243 -22
- package/cli/commands/hub-workspace.test.mjs +171 -0
- package/cli/commands/hub.mjs +71 -1
- package/cli/lib/design-link.mjs +186 -1
- package/cli/lib/design-ownership.mjs +330 -0
- package/cli/lib/design-ownership.test.mjs +329 -0
- package/cli/lib/hubs-config.mjs +21 -0
- package/cli/lib/hubs-config.test.mjs +47 -1
- package/cli/lib/workspace-plan.mjs +298 -5
- package/cli/lib/workspace-plan.test.mjs +215 -1
- package/package.json +10 -10
- package/plugins/design/templates/_shell.html +43 -2
- package/plugins/design/templates/design-system-inspiration/SUB-AGENT-PROMPTS.md +1 -1
- package/plugins/design/templates/design-system-inspiration/core/preview/_motion-readme.md.tpl +1 -1
- package/apps/studio/server.mjs +0 -1312
- package/apps/studio/sync/asset-pull.ts +0 -210
- package/apps/studio/sync/asset-push-worker.ts +0 -84
- package/apps/studio/sync/asset-sweep.ts +0 -262
- package/apps/studio/test/sync-asset-pull.test.ts +0 -161
- package/apps/studio/test/sync-asset-push-worker.test.ts +0 -183
- package/apps/studio/test/sync-asset-sweep.test.ts +0 -243
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
// The nudge — the cell child's half of the doorbell (DDR-226 §4, Increment 3).
|
|
2
|
+
//
|
|
3
|
+
// This exists because Increment 3 shipped `POST /api/journal/report` with no
|
|
4
|
+
// caller, and nothing noticed for a release: the receiver's own tests were
|
|
5
|
+
// green, the route answered correctly, and the only symptom was that
|
|
6
|
+
// cloud → desktop took up to fifteen minutes while desktop → cloud took
|
|
7
|
+
// seconds. So the last describe block here is a REACHABILITY tripwire — it
|
|
8
|
+
// asserts the wiring exists, not just that the module is correct in isolation.
|
|
9
|
+
//
|
|
10
|
+
// What is pinned:
|
|
11
|
+
//
|
|
12
|
+
// 1. **It carries paths and nothing else.** A nudge that could state a hash
|
|
13
|
+
// would be a nudge that could lie about content.
|
|
14
|
+
// 2. **The filter.** Runtime state (`_state/`, `_history/`, …) and
|
|
15
|
+
// malformed paths never reach the wire — otherwise a single canvas save
|
|
16
|
+
// would nudge about a dozen per-machine files nobody syncs.
|
|
17
|
+
// 3. **The mute.** A path the healer just announced is a fact the hub stated;
|
|
18
|
+
// we do not bill it for hearing it back.
|
|
19
|
+
// 4. **Failure is latency, never loss.** A hub that refuses the nudge must
|
|
20
|
+
// not throw, must not retry forever, and must say so once.
|
|
21
|
+
|
|
22
|
+
import { describe, expect, test } from 'bun:test';
|
|
23
|
+
|
|
24
|
+
import { createCellWriteNudge } from '../sync/cell-write-nudge.ts';
|
|
25
|
+
|
|
26
|
+
interface Call {
|
|
27
|
+
url: string;
|
|
28
|
+
body: { paths?: unknown };
|
|
29
|
+
auth: string | null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A fetch double that records calls and answers with whatever `ok` says. */
|
|
33
|
+
function recorder(ok: (n: number) => boolean = () => true) {
|
|
34
|
+
const calls: Call[] = [];
|
|
35
|
+
const fetchImpl = (async (url: unknown, init: unknown) => {
|
|
36
|
+
const i = init as { headers?: Record<string, string>; body?: string };
|
|
37
|
+
calls.push({
|
|
38
|
+
url: String(url),
|
|
39
|
+
body: JSON.parse(i?.body ?? '{}'),
|
|
40
|
+
auth: i?.headers?.authorization ?? null,
|
|
41
|
+
});
|
|
42
|
+
const good = ok(calls.length);
|
|
43
|
+
return {
|
|
44
|
+
ok: good,
|
|
45
|
+
status: good ? 200 : 503,
|
|
46
|
+
json: async () => ({ noted: 0 }),
|
|
47
|
+
} as unknown as Response;
|
|
48
|
+
}) as unknown as typeof fetch;
|
|
49
|
+
return { calls, fetchImpl };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The `paths` array a recorded call carried — the only field a nudge may state. */
|
|
53
|
+
const pathsOf = (call: Call | undefined) => (call?.body.paths ?? []) as string[];
|
|
54
|
+
|
|
55
|
+
function nudger(over: Record<string, unknown> = {}) {
|
|
56
|
+
const { calls, fetchImpl } = (over.rec as ReturnType<typeof recorder>) ?? recorder();
|
|
57
|
+
return {
|
|
58
|
+
calls,
|
|
59
|
+
n: createCellWriteNudge({
|
|
60
|
+
hubUrl: 'http://127.0.0.1:4599',
|
|
61
|
+
token: 'tok',
|
|
62
|
+
fetchImpl,
|
|
63
|
+
coalesceMs: 0,
|
|
64
|
+
log: { warn() {}, error() {}, log() {} },
|
|
65
|
+
...over,
|
|
66
|
+
}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
describe('the wire — paths only, to the loopback hub, with the bearer', () => {
|
|
71
|
+
test('a noted path becomes one POST naming exactly it', async () => {
|
|
72
|
+
const { n, calls } = nudger();
|
|
73
|
+
n.note('assets/photo.png');
|
|
74
|
+
await n.flush();
|
|
75
|
+
|
|
76
|
+
expect(calls).toHaveLength(1);
|
|
77
|
+
expect(calls[0]?.url).toBe('http://127.0.0.1:4599/api/journal/report');
|
|
78
|
+
expect(calls[0]?.auth).toBe('Bearer tok');
|
|
79
|
+
expect(calls[0]?.body).toEqual({ paths: ['assets/photo.png'] });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('the body has NO field through which content could be stated', async () => {
|
|
83
|
+
const { n, calls } = nudger();
|
|
84
|
+
n.note('system/ds/brand.css');
|
|
85
|
+
await n.flush();
|
|
86
|
+
|
|
87
|
+
// The hub re-stats and re-hashes its own disk for every path it is handed.
|
|
88
|
+
// If this body ever grows a `sha256`/`size`/`deleted`, that property is
|
|
89
|
+
// gone and a supervised-but-untrusted process can speak about bytes.
|
|
90
|
+
expect(Object.keys(calls[0]?.body ?? {})).toEqual(['paths']);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('a trailing slash on the hub URL does not produce a double slash', async () => {
|
|
94
|
+
const { n, calls } = nudger({ hubUrl: 'http://127.0.0.1:4599/' });
|
|
95
|
+
n.note('a.css');
|
|
96
|
+
await n.flush();
|
|
97
|
+
expect(calls[0]?.url).toBe('http://127.0.0.1:4599/api/journal/report');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('a burst coalesces into one request, deduped', async () => {
|
|
101
|
+
const { n, calls } = nudger();
|
|
102
|
+
n.note('a.css');
|
|
103
|
+
n.note('b.css');
|
|
104
|
+
n.note('a.css');
|
|
105
|
+
await n.flush();
|
|
106
|
+
|
|
107
|
+
expect(calls).toHaveLength(1);
|
|
108
|
+
expect(pathsOf(calls[0]).sort()).toEqual(['a.css', 'b.css']);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('more than the route ceiling splits into several requests', async () => {
|
|
112
|
+
const { n, calls } = nudger();
|
|
113
|
+
for (let i = 0; i < 70; i++) n.note(`assets/f${i}.png`);
|
|
114
|
+
await n.flush();
|
|
115
|
+
|
|
116
|
+
expect(calls).toHaveLength(2);
|
|
117
|
+
expect(pathsOf(calls[0]).length).toBe(64);
|
|
118
|
+
expect(pathsOf(calls[1]).length).toBe(6);
|
|
119
|
+
expect(n.named()).toBe(70);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('nothing pending sends nothing', async () => {
|
|
123
|
+
const { n, calls } = nudger();
|
|
124
|
+
await n.flush();
|
|
125
|
+
expect(calls).toHaveLength(0);
|
|
126
|
+
expect(n.sent()).toBe(0);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
describe('the filter — the obvious noise never reaches the wire', () => {
|
|
131
|
+
const dropped = [
|
|
132
|
+
'_state/file-ledger/hub.json',
|
|
133
|
+
'_history/ui-home/1234.tsx',
|
|
134
|
+
'_canvas-state/home.view.json',
|
|
135
|
+
'_chat/c-abc.session.json',
|
|
136
|
+
'_server.json',
|
|
137
|
+
'_active.json',
|
|
138
|
+
'_sync.json',
|
|
139
|
+
'_untrusted/INDEX.json',
|
|
140
|
+
'_trash/old.tsx',
|
|
141
|
+
'ui/_server.json',
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
for (const rel of dropped) {
|
|
145
|
+
test(`runtime state is not sync's business: ${rel}`, async () => {
|
|
146
|
+
const { n, calls } = nudger();
|
|
147
|
+
n.note(rel);
|
|
148
|
+
await n.flush();
|
|
149
|
+
expect(calls).toHaveLength(0);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const malformed = ['', '/abs/path.css', '../escape.css', 'a\\b.css', 'node_modules/x/i.js'];
|
|
154
|
+
|
|
155
|
+
for (const rel of malformed) {
|
|
156
|
+
test(`refused by shape: ${JSON.stringify(rel)}`, async () => {
|
|
157
|
+
const { n, calls } = nudger();
|
|
158
|
+
n.note(rel);
|
|
159
|
+
await n.flush();
|
|
160
|
+
expect(calls).toHaveLength(0);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
test('a real design file gets through', async () => {
|
|
165
|
+
const { n, calls } = nudger();
|
|
166
|
+
n.note('system/smoke/preview/logo.svg');
|
|
167
|
+
await n.flush();
|
|
168
|
+
expect(calls).toHaveLength(1);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test('separators are judged, not rewritten', async () => {
|
|
172
|
+
// Every `fs:any` producer already emits forward slashes, so a backslash
|
|
173
|
+
// reaching here is not a Windows separator to be repaired — on POSIX it is
|
|
174
|
+
// a legal character in one filename, and rewriting it would nudge about a
|
|
175
|
+
// DIFFERENT file. The classifier refuses it, same as the hub would.
|
|
176
|
+
const { n, calls } = nudger();
|
|
177
|
+
n.note('system\\smoke\\brand.css');
|
|
178
|
+
await n.flush();
|
|
179
|
+
expect(calls).toHaveLength(0);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test('the client filter is a noise gate, NOT the membership decision', async () => {
|
|
183
|
+
// `ui/home.tsx` is canvas-owned — it travels as a CRDT doc, not on the file
|
|
184
|
+
// plane. We still nudge: the hub's classifier is the single membership
|
|
185
|
+
// oracle (DDR-226 §1) and answers `null` for it. Deciding membership here
|
|
186
|
+
// too would be a second oracle, and second oracles drift.
|
|
187
|
+
const { n, calls } = nudger();
|
|
188
|
+
n.note('ui/home.tsx');
|
|
189
|
+
await n.flush();
|
|
190
|
+
expect(calls).toHaveLength(1);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe('the mute — we do not bill the hub for hearing its own facts back', () => {
|
|
195
|
+
test('a muted path is dropped once, then nudges normally', async () => {
|
|
196
|
+
const { n, calls } = nudger();
|
|
197
|
+
|
|
198
|
+
n.mute('assets/pulled.png');
|
|
199
|
+
n.note('assets/pulled.png'); // the healer's own fs:any echo
|
|
200
|
+
await n.flush();
|
|
201
|
+
expect(calls).toHaveLength(0);
|
|
202
|
+
expect(n.muted()).toBe(1);
|
|
203
|
+
|
|
204
|
+
// The mute is consumed, not sticky: a genuine local edit to a file we just
|
|
205
|
+
// pulled must still reach the hub.
|
|
206
|
+
n.note('assets/pulled.png');
|
|
207
|
+
await n.flush();
|
|
208
|
+
expect(calls).toHaveLength(1);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
test('a mute expires', async () => {
|
|
212
|
+
let clock = 1_000;
|
|
213
|
+
const { n, calls } = nudger({ muteMs: 500, now: () => clock });
|
|
214
|
+
|
|
215
|
+
n.mute('assets/x.png');
|
|
216
|
+
clock += 600;
|
|
217
|
+
n.note('assets/x.png');
|
|
218
|
+
await n.flush();
|
|
219
|
+
|
|
220
|
+
expect(calls).toHaveLength(1);
|
|
221
|
+
expect(n.muted()).toBe(0);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
test('muting one path does not mute another', async () => {
|
|
225
|
+
const { n, calls } = nudger();
|
|
226
|
+
n.mute('a.css');
|
|
227
|
+
n.note('a.css');
|
|
228
|
+
n.note('b.css');
|
|
229
|
+
await n.flush();
|
|
230
|
+
expect(calls[0]?.body.paths).toEqual(['b.css']);
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
describe('failure is latency, never loss', () => {
|
|
235
|
+
test('an unreachable hub does not throw and does not lose the process', async () => {
|
|
236
|
+
const throwing = (async () => {
|
|
237
|
+
throw new Error('ECONNREFUSED');
|
|
238
|
+
}) as unknown as typeof fetch;
|
|
239
|
+
const n = createCellWriteNudge({
|
|
240
|
+
hubUrl: 'http://127.0.0.1:4599',
|
|
241
|
+
token: 'tok',
|
|
242
|
+
fetchImpl: throwing,
|
|
243
|
+
coalesceMs: 0,
|
|
244
|
+
log: { warn() {}, error() {}, log() {} },
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
n.note('a.css');
|
|
248
|
+
await n.flush(); // must resolve, not reject
|
|
249
|
+
expect(n.failures()).toBe(1);
|
|
250
|
+
expect(n.sent()).toBe(0);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test('a refused batch is dropped, not retried forever — walk-import is the backstop', async () => {
|
|
254
|
+
const rec = recorder(() => false);
|
|
255
|
+
const { n, calls } = nudger({ rec });
|
|
256
|
+
|
|
257
|
+
n.note('a.css');
|
|
258
|
+
await n.flush();
|
|
259
|
+
await n.flush();
|
|
260
|
+
await n.flush();
|
|
261
|
+
|
|
262
|
+
// One attempt per note. Re-queueing would turn a hub restart into an
|
|
263
|
+
// unbounded storm against a rate-limited route, and buy nothing the
|
|
264
|
+
// reconciler does not already guarantee.
|
|
265
|
+
expect(calls).toHaveLength(1);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
test('it says so once, not once per path', async () => {
|
|
269
|
+
const warnings: string[] = [];
|
|
270
|
+
const rec = recorder(() => false);
|
|
271
|
+
const { n } = nudger({
|
|
272
|
+
rec,
|
|
273
|
+
log: { warn: (m: string) => warnings.push(m), error() {}, log() {} },
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
n.note('a.css');
|
|
277
|
+
await n.flush();
|
|
278
|
+
n.note('b.css');
|
|
279
|
+
await n.flush();
|
|
280
|
+
|
|
281
|
+
expect(warnings).toHaveLength(1);
|
|
282
|
+
expect(warnings[0]).toMatch(/walk-import/);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
test('recovery clears the failure count and re-arms the warning', async () => {
|
|
286
|
+
const warnings: string[] = [];
|
|
287
|
+
let healthy = false;
|
|
288
|
+
const rec = recorder(() => healthy);
|
|
289
|
+
const { n } = nudger({
|
|
290
|
+
rec,
|
|
291
|
+
log: { warn: (m: string) => warnings.push(m), error() {}, log() {} },
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
n.note('a.css');
|
|
295
|
+
await n.flush();
|
|
296
|
+
expect(n.failures()).toBe(1);
|
|
297
|
+
|
|
298
|
+
healthy = true;
|
|
299
|
+
n.note('b.css');
|
|
300
|
+
await n.flush();
|
|
301
|
+
expect(n.failures()).toBe(0);
|
|
302
|
+
|
|
303
|
+
healthy = false;
|
|
304
|
+
n.note('c.css');
|
|
305
|
+
await n.flush();
|
|
306
|
+
expect(warnings).toHaveLength(2); // a NEW outage is worth a NEW line
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
test('stop() silences it — a torn-down child does not keep talking', async () => {
|
|
310
|
+
const { n, calls } = nudger();
|
|
311
|
+
n.stop();
|
|
312
|
+
n.note('a.css');
|
|
313
|
+
n.mute('b.css');
|
|
314
|
+
await n.flush();
|
|
315
|
+
expect(calls).toHaveLength(0);
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
describe('REACHABILITY — the bug this module was written to close', () => {
|
|
320
|
+
test('the route has a caller in the shipped runtime', async () => {
|
|
321
|
+
// Increment 3 shipped `POST /api/journal/report` and nothing that calls it.
|
|
322
|
+
// Every unit test passed. The hub answered correctly. The only symptom was
|
|
323
|
+
// that one sync direction was 300× slower than the other, which reads to a
|
|
324
|
+
// user as "cloud → desktop is broken".
|
|
325
|
+
//
|
|
326
|
+
// Grep, not import: the point is that the WIRING exists in the file that
|
|
327
|
+
// boots the cell child, which no amount of testing this module in isolation
|
|
328
|
+
// can establish.
|
|
329
|
+
const wiring = await Bun.file(new URL('../sync/cell-file-events.ts', import.meta.url)).text();
|
|
330
|
+
|
|
331
|
+
expect(wiring).toContain('createCellWriteNudge');
|
|
332
|
+
// Subscribed to the bus event both synthetic-write sources converge on.
|
|
333
|
+
expect(wiring).toMatch(/bus\.on\(\s*'fs:any'/);
|
|
334
|
+
// And the healer mutes what it announces, so the echo is not billed.
|
|
335
|
+
expect(wiring).toContain('nudge.mute');
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
test('the sender names the exact route the hub receiver serves', async () => {
|
|
339
|
+
const hubJournal = await Bun.file(new URL('../../hub/src/journal.mjs', import.meta.url)).text();
|
|
340
|
+
const sender = await Bun.file(new URL('../sync/cell-write-nudge.ts', import.meta.url)).text();
|
|
341
|
+
|
|
342
|
+
// The hub's constant is the authority; this pins the twin.
|
|
343
|
+
expect(hubJournal).toContain("JOURNAL_REPORT_PATH = '/api/journal/report'");
|
|
344
|
+
expect(sender).toContain('/api/journal/report');
|
|
345
|
+
});
|
|
346
|
+
});
|