@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.
- 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 +201 -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 -71
- 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 +915 -308
- 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 +71 -108
- 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 +90 -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
|
@@ -248,6 +248,18 @@ describe('canvas-origin gate — A1/A2 traversal + privilege containment', () =>
|
|
|
248
248
|
// budget. A GET here 403s at the gate, never 405 from a reached handler.
|
|
249
249
|
'/_api/sync/resync',
|
|
250
250
|
'/_api/sync/cancel-assets',
|
|
251
|
+
// feature-before-first-external-users Task 2 — the sync toggles write
|
|
252
|
+
// `.design/config.json` linkedHub and can restart the sync runtime.
|
|
253
|
+
// From the canvas origin this would let untrusted content turn
|
|
254
|
+
// delete-propagation on or settle a first-anchor hold against the
|
|
255
|
+
// user — MAIN-ORIGIN ONLY, absent from both allowlists.
|
|
256
|
+
'/_api/sync/settings',
|
|
257
|
+
// Ownership mutations (adopt/detach) rewrite `.gitignore` + the git
|
|
258
|
+
// index and can drop the hub link — MAIN-ORIGIN ONLY, same posture.
|
|
259
|
+
'/_api/sync/ownership',
|
|
260
|
+
// Task 3 (F-6) — restore MOVES parked files into the live project and
|
|
261
|
+
// prune DELETES them; untrusted canvas content gets neither primitive.
|
|
262
|
+
'/_api/sync/trash',
|
|
251
263
|
// ACP chat attachments (POST upload + GET thumbnail serve) are MAIN-ORIGIN
|
|
252
264
|
// ONLY — absent from CANVAS_SAFE_API + startCanvasServer's routes. The
|
|
253
265
|
// untrusted canvas origin must never read (or write) the user's pasted
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Spike finding M8 (studyfi-design AWS run, 2026-08-20) — the mount's catch
|
|
2
|
+
// showed `err.stack`, which for a failed dynamic import is the bare
|
|
3
|
+
// "TypeError: Failed to fetch dynamically imported module". The 422 body the
|
|
4
|
+
// server wrote ("Canvas build error: this canvas imports …") names the culprit
|
|
5
|
+
// and the rule — and the browser throws it away on non-2xx. The spike spent
|
|
6
|
+
// several rounds on token/cookie hypotheses before a manual curl surfaced the
|
|
7
|
+
// body.
|
|
8
|
+
//
|
|
9
|
+
// The shell is a static template, so this suite pins the WIRING the way
|
|
10
|
+
// canvas-shell-base.test.ts does: the diagnosis helper exists, and both import
|
|
11
|
+
// failure paths (initial mount + soft reload) route through it instead of
|
|
12
|
+
// printing the TypeError.
|
|
13
|
+
|
|
14
|
+
import { describe, expect, test } from 'bun:test';
|
|
15
|
+
import { readFileSync } from 'node:fs';
|
|
16
|
+
import { join } from 'node:path';
|
|
17
|
+
|
|
18
|
+
const SHELL = readFileSync(
|
|
19
|
+
join(import.meta.dir, '..', '..', '..', 'plugins', 'design', 'templates', '_shell.html'),
|
|
20
|
+
'utf8'
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
describe('a canvas build error reaches the person (M8)', () => {
|
|
24
|
+
test('the shell carries the import-failure diagnosis helper', () => {
|
|
25
|
+
expect(SHELL).toContain('function diagnoseImportFailure(');
|
|
26
|
+
// It refetches the module URL to recover the discarded response body…
|
|
27
|
+
expect(SHELL).toMatch(/diagnoseImportFailure[\s\S]{0,400}fetch\(url/);
|
|
28
|
+
// …and shows the body, not just the status line.
|
|
29
|
+
expect(SHELL).toMatch(/r\.text\(\)/);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('the initial mount catch routes through the diagnosis, not err.stack', () => {
|
|
33
|
+
expect(SHELL).toContain('diagnoseImportFailure(canvasUrl, err).then(showError)');
|
|
34
|
+
// The old shape — showError straight from the stack — must not come back.
|
|
35
|
+
expect(SHELL).not.toContain('showError((err && err.stack) || String(err))');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('the soft-reload holding toast gets the same diagnosis', () => {
|
|
39
|
+
const soft = SHELL.slice(SHELL.indexOf('function softReload'), SHELL.indexOf('function softReload') + 1500);
|
|
40
|
+
expect(soft).toContain('diagnoseImportFailure(canvasUrl, err)');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('a 2xx refetch falls back to the original error — the diagnosis never masks a module-level throw', () => {
|
|
44
|
+
// If the module fetches fine, the failure was inside the module (a runtime
|
|
45
|
+
// throw at import time). Showing an "HTTP 200" line there would point the
|
|
46
|
+
// person at the network when the bug is in their code.
|
|
47
|
+
expect(SHELL).toMatch(/if \(r\.ok\) return fallback/);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// The three MEDIUM findings from the 8134ca8f security re-review, pinned.
|
|
2
|
+
//
|
|
3
|
+
// These are BEHAVIOURAL, not source-text pins — the re-review's own closing
|
|
4
|
+
// note was that the posture suite pins the letter and not the behaviour, and
|
|
5
|
+
// that nothing exercised the two findings most worth a regression test.
|
|
6
|
+
//
|
|
7
|
+
// F1 a transient cloud failure, or a MUTABLE ref, must never be remembered
|
|
8
|
+
// as "this version does not exist". Caching either turns an outage (or a
|
|
9
|
+
// later commit) into a permanent 404 that only a restart clears.
|
|
10
|
+
// F2 the cell is not trusted to respect its own limits — an oversized
|
|
11
|
+
// response must be refused, not buffered for the whole timeout.
|
|
12
|
+
// F3 `git show` output is decoded across chunk boundaries, so a canvas with
|
|
13
|
+
// non-ASCII copy must survive a body larger than one pipe chunk.
|
|
14
|
+
|
|
15
|
+
import { describe, expect, test } from 'bun:test';
|
|
16
|
+
import { spawn } from 'node:child_process';
|
|
17
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
18
|
+
import { tmpdir } from 'node:os';
|
|
19
|
+
import { join } from 'node:path';
|
|
20
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
21
|
+
|
|
22
|
+
describe('F1 — only an authoritative absence is remembered', () => {
|
|
23
|
+
// The decision the route makes, extracted exactly as it is written there.
|
|
24
|
+
const shouldCache = (r: { ok: boolean; reason?: string }, sha: string): boolean =>
|
|
25
|
+
!r.ok && r.reason === 'not-found' && /^[0-9a-f]{7,40}$/.test(sha);
|
|
26
|
+
|
|
27
|
+
const REAL_SHA = 'a'.repeat(40);
|
|
28
|
+
|
|
29
|
+
test('an unreachable cell is NOT remembered — the outage would outlive itself', () => {
|
|
30
|
+
expect(shouldCache({ ok: false, reason: 'unreachable' }, REAL_SHA)).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('an unlinked project is NOT remembered — it says nothing about the version', () => {
|
|
34
|
+
expect(shouldCache({ ok: false, reason: 'not-linked' }, REAL_SHA)).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('a MUTABLE ref is never remembered, however authoritative the answer', () => {
|
|
38
|
+
// DiffView's "compare with saved" opens `?sha=HEAD` on a canvas that may
|
|
39
|
+
// not be committed yet. Cache that miss and committing the file leaves the
|
|
40
|
+
// preview permanently 404 — the exact read-failure-as-absence collapse
|
|
41
|
+
// this feature exists to delete.
|
|
42
|
+
for (const ref of ['HEAD', 'main', 'v1.2.0', 'HEAD~1']) {
|
|
43
|
+
expect(shouldCache({ ok: false, reason: 'not-found' }, ref)).toBe(false);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('a genuine absence at a real object name IS remembered', () => {
|
|
48
|
+
// Without this the DoS guard the negative cache exists to be is gone.
|
|
49
|
+
expect(shouldCache({ ok: false, reason: 'not-found' }, REAL_SHA)).toBe(true);
|
|
50
|
+
expect(shouldCache({ ok: false, reason: 'not-found' }, 'abc1234')).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('F2 — an oversized cell response is refused, not buffered', () => {
|
|
55
|
+
// `readCapped`'s contract, exercised over a real ReadableStream.
|
|
56
|
+
async function readCapped(res: Response, maxBytes: number): Promise<string | null> {
|
|
57
|
+
const declared = Number(res.headers.get('content-length'));
|
|
58
|
+
if (Number.isFinite(declared) && declared > maxBytes) return null;
|
|
59
|
+
if (!res.body) {
|
|
60
|
+
const t = await res.text();
|
|
61
|
+
return t.length > maxBytes ? null : t;
|
|
62
|
+
}
|
|
63
|
+
const reader = res.body.getReader();
|
|
64
|
+
const dec = new TextDecoder('utf8');
|
|
65
|
+
let out = '';
|
|
66
|
+
let seen = 0;
|
|
67
|
+
for (;;) {
|
|
68
|
+
const { done, value } = await reader.read();
|
|
69
|
+
if (done) break;
|
|
70
|
+
seen += value?.byteLength ?? 0;
|
|
71
|
+
if (seen > maxBytes) {
|
|
72
|
+
await reader.cancel().catch(() => {});
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
out += dec.decode(value, { stream: true });
|
|
76
|
+
}
|
|
77
|
+
return out + dec.decode();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const streamOf = (chunks: Uint8Array[], headers: Record<string, string> = {}) =>
|
|
81
|
+
new Response(
|
|
82
|
+
new ReadableStream({
|
|
83
|
+
start(c) {
|
|
84
|
+
for (const ch of chunks) c.enqueue(ch);
|
|
85
|
+
c.close();
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
88
|
+
{ headers }
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
test('a lying Content-Length is refused up front', () => {
|
|
92
|
+
const res = new Response('short', { headers: { 'content-length': String(99 * 1024 * 1024) } });
|
|
93
|
+
return expect(readCapped(res, 1024)).resolves.toBeNull();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('a body that EXCEEDS the cap without declaring it is refused mid-stream', async () => {
|
|
97
|
+
// The measurement, not the claim — a hostile cell simply omits the header.
|
|
98
|
+
const chunk = new Uint8Array(512).fill(0x61);
|
|
99
|
+
expect(await readCapped(streamOf([chunk, chunk, chunk, chunk]), 1024)).toBeNull();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('a legitimate body under the cap still reads whole', async () => {
|
|
103
|
+
const body = new TextEncoder().encode('export default function C(){}');
|
|
104
|
+
expect(await readCapped(streamOf([body]), 1024)).toBe('export default function C(){}');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('multi-byte content split across chunks survives the counted read', async () => {
|
|
108
|
+
// The stream decoder must not corrupt what the cap lets through.
|
|
109
|
+
const bytes = new TextEncoder().encode('č'.repeat(64));
|
|
110
|
+
const mid = 5; // deliberately mid-sequence
|
|
111
|
+
expect(await readCapped(streamOf([bytes.subarray(0, mid), bytes.subarray(mid)]), 4096)).toBe(
|
|
112
|
+
'č'.repeat(64)
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe('F3 — git output survives a multi-byte sequence split across chunks', () => {
|
|
118
|
+
test('StringDecoder preserves what per-chunk toString() corrupts', () => {
|
|
119
|
+
const bytes = Buffer.from('č'.repeat(3), 'utf8');
|
|
120
|
+
const a = bytes.subarray(0, 3); // splits the 2nd `č` in half
|
|
121
|
+
const b = bytes.subarray(3);
|
|
122
|
+
|
|
123
|
+
// What the runners used to do — silent U+FFFD on both sides of the seam.
|
|
124
|
+
expect(a.toString() + b.toString()).not.toBe('ččč');
|
|
125
|
+
|
|
126
|
+
const dec = new StringDecoder('utf8');
|
|
127
|
+
expect(dec.write(a) + dec.write(b) + dec.end()).toBe('ččč');
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('a real `git show` of a canvas larger than one pipe chunk is byte-exact', async () => {
|
|
131
|
+
const dir = mkdtempSync(join(tmpdir(), 'git-utf8-'));
|
|
132
|
+
try {
|
|
133
|
+
// >64 KiB so the pipe genuinely splits it, with non-ASCII throughout —
|
|
134
|
+
// this repo's own canvases carry Czech copy, which is what made a latent
|
|
135
|
+
// decoding bug a live data-integrity one.
|
|
136
|
+
const body = `// příliš žluťoučký kůň úpěl ďábelské ódy — ${'č'.repeat(40000)}\n`;
|
|
137
|
+
writeFileSync(join(dir, 'canvas.tsx'), body, 'utf8');
|
|
138
|
+
const git = (args: string[]) =>
|
|
139
|
+
new Promise<string>((res, rej) => {
|
|
140
|
+
const outDec = new StringDecoder('utf8');
|
|
141
|
+
let out = '';
|
|
142
|
+
const c = spawn('git', args, { cwd: dir, env: { ...process.env, LC_ALL: 'C' } });
|
|
143
|
+
c.stdout.on('data', (d) => {
|
|
144
|
+
out += outDec.write(d);
|
|
145
|
+
});
|
|
146
|
+
c.on('close', (code) =>
|
|
147
|
+
code === 0 ? res(out + outDec.end()) : rej(new Error(`git ${code}`))
|
|
148
|
+
);
|
|
149
|
+
c.on('error', rej);
|
|
150
|
+
});
|
|
151
|
+
await git(['init', '-b', 'main']);
|
|
152
|
+
await git(['config', 'user.email', 't@t.t']);
|
|
153
|
+
await git(['config', 'user.name', 'T']);
|
|
154
|
+
await git(['add', '-A']);
|
|
155
|
+
await git(['commit', '-m', 'x']);
|
|
156
|
+
const shown = await git(['show', 'HEAD:canvas.tsx']);
|
|
157
|
+
|
|
158
|
+
expect(shown).toBe(body);
|
|
159
|
+
expect(shown).not.toContain('�');
|
|
160
|
+
expect(shown.length).toBeGreaterThan(40000);
|
|
161
|
+
} finally {
|
|
162
|
+
rmSync(dir, { recursive: true, force: true });
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
// The cloud-managed posture, widened — feature-cloud-managed-git-posture.
|
|
2
|
+
//
|
|
3
|
+
// DDR-218 withdrew the working-tree half of the Changes panel when the cell
|
|
4
|
+
// commits this project. It withdrew the OFFER and not the machinery: the app
|
|
5
|
+
// went on polling `/_api/git/status`, probing the remote, badging the tree, and
|
|
6
|
+
// pointing History at the local repo — a repo that, in this posture, has no
|
|
7
|
+
// commits at all. The panel therefore said "Cloud is saving" and "No saved
|
|
8
|
+
// versions yet" in the same breath.
|
|
9
|
+
//
|
|
10
|
+
// Source-level, in the `cloud-managed-save-surfaces.test.ts` house style: what
|
|
11
|
+
// these pin is exactly what would regress — a poll re-added ungated, the loader
|
|
12
|
+
// choice migrating into the panel, or a "tidy-up" disabling the ONE local-git
|
|
13
|
+
// mechanism that must stay live.
|
|
14
|
+
|
|
15
|
+
import { describe, expect, test } from 'bun:test';
|
|
16
|
+
import { readFileSync } from 'node:fs';
|
|
17
|
+
import { join } from 'node:path';
|
|
18
|
+
|
|
19
|
+
const STUDIO = join(import.meta.dir, '..');
|
|
20
|
+
const APP = readFileSync(join(STUDIO, 'client', 'app.jsx'), 'utf8');
|
|
21
|
+
const PANEL = readFileSync(join(STUDIO, 'client', 'panels', 'GitPanel.jsx'), 'utf8');
|
|
22
|
+
const HTTP = readFileSync(join(STUDIO, 'http.ts'), 'utf8');
|
|
23
|
+
const ENDPOINTS = readFileSync(join(STUDIO, 'cloud', 'endpoints.ts'), 'utf8');
|
|
24
|
+
|
|
25
|
+
describe('the loader is chosen ONCE, where the posture is named', () => {
|
|
26
|
+
test('the call site swaps it; the panel never re-derives it', () => {
|
|
27
|
+
expect(APP).toContain('loadLog={cloudManaged ? gitLoadCloudLog : gitLoadLog}');
|
|
28
|
+
expect(APP).toContain("historySource={cloudManaged ? 'cloud' : 'local'}");
|
|
29
|
+
// The panel may READ the source, never compute it from `cloudManaged` —
|
|
30
|
+
// that would be the second derivation the posture constant exists to stop.
|
|
31
|
+
expect(PANEL).toContain("const cloudHistorySource = historySource === 'cloud';");
|
|
32
|
+
expect(PANEL).not.toMatch(/historySource\s*=\s*cloudManaged/);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('the cloud loader talks to the loopback proxy, never to a hub directly', () => {
|
|
36
|
+
expect(APP).toContain("'/_api/cloud/history?limit=40'");
|
|
37
|
+
// No hub URL, and therefore no token, anywhere in the client.
|
|
38
|
+
expect(APP).not.toContain('getHubToken');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('a failed load is reported, not rendered as an empty history', () => {
|
|
42
|
+
// Collapsing "could not reach" into "nothing saved yet" IS the bug.
|
|
43
|
+
expect(APP).toMatch(/if \(!r\.ok\) return null;/);
|
|
44
|
+
expect(PANEL).toContain('const [logFailed, setLogFailed] = useState(false);');
|
|
45
|
+
expect(PANEL).toContain('setLogFailed(entries == null);');
|
|
46
|
+
expect(PANEL).toContain('data-testid="git-history-unreachable"');
|
|
47
|
+
expect(PANEL).toContain('data-testid="git-history-retry"');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('the cloud empty state never offers the Save this posture withdrew', () => {
|
|
51
|
+
expect(PANEL).toContain('The cloud is saving this project');
|
|
52
|
+
// The old copy must still exist for the LOCAL branch — and only there.
|
|
53
|
+
expect(PANEL).toContain("Save a version and it'll show up here.");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('the header names the cloud project, falling back to the hub host', () => {
|
|
57
|
+
expect(PANEL).toContain(
|
|
58
|
+
'const headerProject = cloudHistorySource\n ? (cloudHistory?.project ?? cloudHistory?.hubHost ?? null)\n : project;'
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('while cloud-managed, the desktop runs NO local git of its own', () => {
|
|
64
|
+
test('the mount status fetch is gated, and reacts live', () => {
|
|
65
|
+
// Reactive on the posture, not mount-only: Connect must stop it and
|
|
66
|
+
// Disconnect must resume it, both without a reload.
|
|
67
|
+
expect(APP).toMatch(/if \(savingIsManaged\) \{\n\s*\/\/[\s\S]*?setGitStatus\(null\);/);
|
|
68
|
+
expect(APP).toMatch(/\}, \[savingIsManaged\]\);/);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('both refreshers refuse in that posture', () => {
|
|
72
|
+
const refreshers = APP.match(
|
|
73
|
+
/const refresh(GitStatus|RemoteSync) = useCallback\(async \(\) => \{[\s\S]{0,600}?\n {2}\}, \[\]\);/g
|
|
74
|
+
);
|
|
75
|
+
expect(refreshers?.length).toBe(2);
|
|
76
|
+
for (const fn of refreshers ?? []) expect(fn).toContain('savingIsManagedRef.current');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('the remote ahead/behind probe stops AND clears its last answer', () => {
|
|
80
|
+
// A stale ahead/behind would otherwise outlive the link and keep the
|
|
81
|
+
// "Get latest" nudge on a remote this project has nothing to do with.
|
|
82
|
+
expect(APP).toMatch(/if \(savingIsManaged\) \{[\s\S]{0,400}?setRemoteSync\(null\);/);
|
|
83
|
+
expect(APP).toContain(
|
|
84
|
+
'}, [savingIsManaged, gitStatus?.repo, changesOpen, refreshRemoteSync]);'
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('the WS push is gated too — otherwise it re-populates what the polls stopped', () => {
|
|
89
|
+
expect(APP).toContain('if (!savingIsManagedRef.current) setGitStatus(m.payload);');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('the tree M/A/D badges are withdrawn — the same claim, one row at a time', () => {
|
|
93
|
+
expect(APP).toMatch(/if \(savingIsManaged\) return m;/);
|
|
94
|
+
expect(APP).toContain('}, [gitStatus, savingIsManaged]);');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('the drafts switcher is withdrawn — a branch switch moves a HEAD the cell has never seen', () => {
|
|
98
|
+
expect(APP).toContain('{!savingIsManaged && (\n <RepoBranchSwitcher');
|
|
99
|
+
expect(APP).toContain('savingIsManaged={savingIsManaged}');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('the posture is declared above every effect that names it', () => {
|
|
103
|
+
// A dependency array evaluates during render, so a `const` below its first
|
|
104
|
+
// consumer is a temporal-dead-zone ReferenceError at boot, not a warning.
|
|
105
|
+
const declared = APP.indexOf('const savingIsManaged = cellManaged || cloudManaged;');
|
|
106
|
+
expect(declared).toBeGreaterThan(0);
|
|
107
|
+
expect(declared).toBeLessThan(APP.indexOf("fetch('/_api/git/status')"));
|
|
108
|
+
expect(declared).toBeLessThan(APP.indexOf('const dirtyByPath = useMemo'));
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe('what must NOT be withdrawn', () => {
|
|
113
|
+
test('the git-lifecycle watcher stays live — it is correctness, not a save surface', () => {
|
|
114
|
+
// DDR-051: a terminal `git checkout` flushes into Yjs and reloads the open
|
|
115
|
+
// canvases. Disabling it would silently desync anyone who uses git in a
|
|
116
|
+
// terminal — precisely the workflow DDR-218 promised would survive. A
|
|
117
|
+
// NEGATIVE assertion, so a future tidy-up cannot quietly add the gate.
|
|
118
|
+
const handler = APP.slice(APP.indexOf("m.type === 'git-lifecycle'"));
|
|
119
|
+
const body = handler.slice(0, handler.indexOf('}\n } catch {}'));
|
|
120
|
+
expect(body).toContain('setGitLifecycle(m.payload);');
|
|
121
|
+
expect(body).not.toContain('savingIsManaged');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('nothing touches .git — no hook, no config write', () => {
|
|
125
|
+
for (const src of [APP, HTTP, ENDPOINTS]) {
|
|
126
|
+
expect(src).not.toMatch(/\.git\/hooks/);
|
|
127
|
+
expect(src).not.toMatch(/core\.hooksPath/);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('the local /_api/git/* routes keep exactly their old gates', () => {
|
|
132
|
+
// "Presentation, not a control" (DDR-218) is KEPT, not reversed: what stops
|
|
133
|
+
// is Maude's own polling, not the user's ability to use git.
|
|
134
|
+
expect(HTTP).toContain("'/_api/git/status': async (req: Request) => {");
|
|
135
|
+
expect(HTTP).toContain("'/_api/git/log': async (req: Request) => {");
|
|
136
|
+
expect(HTTP).not.toContain('savingIsManaged');
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe('the new network surface', () => {
|
|
141
|
+
test('the studio route carries BOTH mandatory guards', () => {
|
|
142
|
+
const route = HTTP.slice(HTTP.indexOf("'/_api/cloud/history':"));
|
|
143
|
+
const body = route.slice(0, route.indexOf('\n },'));
|
|
144
|
+
expect(body).toContain("if (!sameOriginRead(req)) return new Response('cross-origin rejected'");
|
|
145
|
+
expect(body).toContain('if (!isTrustedRequestHost(req))');
|
|
146
|
+
expect(body).toContain("if (req.method !== 'GET')");
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('it is in NEITHER canvas allowlist (DDR-088 — it proxies a credential)', () => {
|
|
150
|
+
const safe = HTTP.slice(HTTP.indexOf('const CANVAS_SAFE_API = new Set(['));
|
|
151
|
+
expect(safe.slice(0, safe.indexOf('])')).includes('/_api/cloud/history')).toBe(false);
|
|
152
|
+
const canvasRoutes = HTTP.slice(HTTP.indexOf('function startCanvasServer'));
|
|
153
|
+
expect(canvasRoutes.includes("'/_api/cloud/history'")).toBe(false);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('a hub 401 is a plain read failure — it must never delete the credential', () => {
|
|
157
|
+
// `/_api/cloud/status`'s 401 path calls `signout()` (confused-deputy F6).
|
|
158
|
+
// A History poll is not that authority: a cell restarting mid-renewal would
|
|
159
|
+
// otherwise silently unlink a working project.
|
|
160
|
+
const fetchFn = ENDPOINTS.slice(ENDPOINTS.indexOf('async function hubFetch('));
|
|
161
|
+
const body = fetchFn.slice(0, fetchFn.indexOf('\n }\n'));
|
|
162
|
+
expect(body).not.toContain('signout');
|
|
163
|
+
expect(body).not.toContain('deleteHubCredential');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('the token and the hub error body never leave the server', () => {
|
|
167
|
+
// Assert the PROPERTY, not the line — the re-review's closing note was that
|
|
168
|
+
// these pins caught the letter and not the behaviour, and this one broke on
|
|
169
|
+
// the very fix it should have been indifferent to. A non-2xx must produce
|
|
170
|
+
// no body and no text; a bare status code is fine, the cell's message never is.
|
|
171
|
+
const fn = ENDPOINTS.slice(ENDPOINTS.indexOf('async function hubFetch('));
|
|
172
|
+
const body = fn.slice(0, fn.indexOf('\n }\n'));
|
|
173
|
+
expect(body).toContain('if (!res.ok) return { ok: false');
|
|
174
|
+
expect(body).not.toMatch(/if \(!res\.ok\)[\s\S]{0,120}await res\.(text|json)/);
|
|
175
|
+
// The token reaches exactly one place: the Authorization header.
|
|
176
|
+
expect((ENDPOINTS.match(/hub\.token/g) ?? []).length).toBe(1);
|
|
177
|
+
expect(APP).not.toContain('Bearer');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test('an uncredentialed link makes no network call at all', () => {
|
|
181
|
+
expect(ENDPOINTS).toContain(
|
|
182
|
+
"if (!hub) return { status: 200, json: { ok: false, reason: 'not-linked' } };"
|
|
183
|
+
);
|
|
184
|
+
expect(ENDPOINTS).toContain('if (!linked?.credentialed) return null;');
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test('the sha is validated on the desktop too, not only on the hub', () => {
|
|
188
|
+
// It reaches the preview route from the UNTRUSTED canvas origin (DDR-054);
|
|
189
|
+
// "the other end checks it" is how a guard ends up on neither end. Pin the
|
|
190
|
+
// GUARD, not the whole statement — the failure branch changed shape once
|
|
191
|
+
// already (it now reports a reason so a caller can tell absence from an
|
|
192
|
+
// outage), and this assertion should survive that.
|
|
193
|
+
const fn = ENDPOINTS.slice(ENDPOINTS.indexOf('async historyFile('));
|
|
194
|
+
const body = fn.slice(0, fn.indexOf('\n },'));
|
|
195
|
+
expect(body).toContain('[0-9a-f]{7,40}');
|
|
196
|
+
// The guard must come FIRST — before the path, the link, or any fetch.
|
|
197
|
+
expect(body.indexOf('[0-9a-f]{7,40}')).toBeLessThan(body.indexOf('hubFetch'));
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
describe('the version preview resolves a cloud-only sha', () => {
|
|
202
|
+
test('local first, then the cell, with the cache key unchanged', () => {
|
|
203
|
+
const fn = HTTP.slice(HTTP.indexOf('async function serveHistoricalCanvas('));
|
|
204
|
+
const body = fn.slice(0, fn.indexOf('\n}\n'));
|
|
205
|
+
expect(body).toContain('let source = await gitShowFile(ctx.paths.repoRoot, sha, repoRel);');
|
|
206
|
+
expect(body).toContain('await cloudHistoryApi(ctx).historyFile(sha, repoRel);');
|
|
207
|
+
// Historical content is immutable, so a cloud-sourced build must cache
|
|
208
|
+
// under the identical key a local one would have.
|
|
209
|
+
expect(body).toContain(
|
|
210
|
+
// biome-ignore lint/suspicious/noTemplateCurlyInString: asserting SOURCE text, not interpolating.
|
|
211
|
+
'const key = `${absPath}\\0${sha}\\0${RUNTIME_BOOT_ID}\\0${CHROME_EPOCH}`;'
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
test('the build budget still gates the miss path, and misses are remembered', () => {
|
|
216
|
+
const fn = HTTP.slice(HTTP.indexOf('async function serveHistoricalCanvas('));
|
|
217
|
+
const body = fn.slice(0, fn.indexOf('\n}\n'));
|
|
218
|
+
// The limiter must stay ABOVE the lookups (the recorded DoS invariant) —
|
|
219
|
+
// now guarding a network round trip as well as a git process.
|
|
220
|
+
expect(body.indexOf('historicalBuildAllowed()')).toBeLessThan(body.indexOf('gitShowFile'));
|
|
221
|
+
expect(body).toContain('historicalMissCache.has(key)');
|
|
222
|
+
expect(body).toContain('historicalMissCache.add(key);');
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test('the posture is asked of the module that owns it, not re-derived', () => {
|
|
226
|
+
// `historyFile` already answers null unless the folder is linked AND
|
|
227
|
+
// credentialed — which IS the cloud-managed condition.
|
|
228
|
+
expect(HTTP).not.toMatch(/serveHistoricalCanvas[\s\S]{0,2000}?credentialed/);
|
|
229
|
+
});
|
|
230
|
+
});
|
|
@@ -108,6 +108,36 @@ describe('the cloud shell states what it is', () => {
|
|
|
108
108
|
expect(cfg.cloud?.projectName).toBe('Alligators');
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
+
// The shape every test above this line assumed away. A self-hosted
|
|
112
|
+
// `maude hub workspace` sets MAUDE_WORKSPACE_MODE but never
|
|
113
|
+
// HUB_DASHBOARD_URL (only cli/lib/cell-plan.mjs writes that), and the
|
|
114
|
+
// studio used to default it to the vendor's SaaS — so the ONE way out a
|
|
115
|
+
// browser tab offers walked a self-hoster off their own deployment onto
|
|
116
|
+
// cloud.maude.sh. Every cloud-block test booted WITH the variable set, so
|
|
117
|
+
// the whole suite was blind to the deployment the bug applies to.
|
|
118
|
+
test('a self-hosted hub gets the cloud block WITHOUT a dashboard link', async () => {
|
|
119
|
+
const { root } = makeSandbox();
|
|
120
|
+
const port = nextPort();
|
|
121
|
+
const proc = await bootServer(root, port, {
|
|
122
|
+
MAUDE_WORKSPACE_MODE: '1',
|
|
123
|
+
MAUDE_WORKSPACE_ALLOW_DEV_MODULES: '1',
|
|
124
|
+
MAUDE_PROJECT_NAME: 'Alligators',
|
|
125
|
+
// deliberately NO HUB_DASHBOARD_URL — this is what self-hosted looks like
|
|
126
|
+
});
|
|
127
|
+
procs.push(proc);
|
|
128
|
+
const cfg = (await (await fetch(`http://localhost:${port}/_config`)).json()) as {
|
|
129
|
+
cloud?: { dashboardUrl?: string; projectName?: string };
|
|
130
|
+
};
|
|
131
|
+
// The block still exists: "you are in a browser tab on somebody else's
|
|
132
|
+
// machine" is just as true self-hosted, and C2's stated agent absence,
|
|
133
|
+
// the account chip and the sign-out all hang off it.
|
|
134
|
+
expect(cfg.cloud).toBeTruthy();
|
|
135
|
+
expect(cfg.cloud?.projectName).toBe('Alligators');
|
|
136
|
+
// Only the platform-specific field is gone — absent, so the client's
|
|
137
|
+
// truthiness check is the single gate.
|
|
138
|
+
expect(cfg.cloud?.dashboardUrl).toBeUndefined();
|
|
139
|
+
});
|
|
140
|
+
|
|
111
141
|
test('the canvas capability is echoed only when the proxy minted one', async () => {
|
|
112
142
|
const { base } = await bootCell();
|
|
113
143
|
const without = (await (await fetch(`${base}/_config`)).json()) as { canvasToken?: string };
|
|
@@ -129,3 +129,42 @@ describe('"not known yet" survives every layer between /_config and the DOM', ()
|
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
});
|
|
132
|
+
|
|
133
|
+
describe('the way back out exists only where there is somewhere to go', () => {
|
|
134
|
+
// A self-hosted `maude hub workspace` is workspace mode too — the whole
|
|
135
|
+
// point of "one studio, three shells" — so it gets the `cloud` block, the
|
|
136
|
+
// stated agent absence, the account chip and the sign-out. What it does NOT
|
|
137
|
+
// have is a dashboard: one hub serves one project, and `HUB_DASHBOARD_URL`
|
|
138
|
+
// is written only by the managed fleet (cli/lib/cell-plan.mjs).
|
|
139
|
+
//
|
|
140
|
+
// Both sides had defaulted that URL to the vendor's SaaS, so the ONE way out
|
|
141
|
+
// a browser tab offers walked every self-hoster off their own deployment
|
|
142
|
+
// onto cloud.maude.sh — a dead end for an account most of them do not have.
|
|
143
|
+
// Fixing the server alone would not have fixed the button; the client
|
|
144
|
+
// carried its own copy of the same fallback.
|
|
145
|
+
test('the client never names the vendor as a fallback destination', () => {
|
|
146
|
+
// The literal is the bug. `dashboardUrl` is either configured or absent.
|
|
147
|
+
expect(APP).not.toContain("'https://cloud.maude.sh'");
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test('the ← Dashboard anchor is gated on the URL, not on the shell', () => {
|
|
151
|
+
const at = APP.indexOf('data-testid="cloud-back"');
|
|
152
|
+
expect(at).toBeGreaterThan(0);
|
|
153
|
+
const block = APP.slice(at, at + 1200);
|
|
154
|
+
expect(block).toContain('{cloud.dashboardUrl ? (');
|
|
155
|
+
expect(block).toContain('href={cloud.dashboardUrl}');
|
|
156
|
+
// The project name is NOT gated with it: a tab must still say which
|
|
157
|
+
// project it is showing, dashboard or no dashboard.
|
|
158
|
+
expect(block).toContain('data-testid="cloud-project-name"');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test('the server sends the field only when it is configured', () => {
|
|
162
|
+
const HTTP = readFileSync(join(STUDIO, 'http.ts'), 'utf8');
|
|
163
|
+
// Conditional spread — the same shape `canvasToken` uses two fields down,
|
|
164
|
+
// so an absent value is absent rather than a string nobody can act on.
|
|
165
|
+
expect(HTTP).toContain(
|
|
166
|
+
'...(process.env.HUB_DASHBOARD_URL\n ? { dashboardUrl: process.env.HUB_DASHBOARD_URL }\n : {}),'
|
|
167
|
+
);
|
|
168
|
+
expect(HTTP).not.toContain("HUB_DASHBOARD_URL ?? 'https://cloud.maude.sh'");
|
|
169
|
+
});
|
|
170
|
+
});
|