@1agh/maude 1.5.3 → 1.6.1

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.
@@ -277,7 +277,7 @@ export function isMaudeRuntimeState(p: string): boolean {
277
277
  p
278
278
  ) ||
279
279
  /(^|\/)_server\.(?:lock|log)$/.test(p) ||
280
- /(^|\/)_(?:history|trash|draw|photo|smoke|reports|canvas-state|state|chat|comments|untrusted|export-jobs)(?:\/|$)/.test(
280
+ /(^|\/)_(?:history|trash|draw|photo|smoke|reports|canvas-state|state|chat|comments|untrusted|export-jobs|cache)(?:\/|$)/.test(
281
281
  p
282
282
  ) ||
283
283
  // kgai per-machine graph projection (feature-kgai-ecosystem-integration,
@@ -110,6 +110,7 @@ import { createGitHubEndpoints } from './github/endpoints.ts';
110
110
  import type { InspectRegistry } from './inspect.ts';
111
111
  import { canvasSlug, writeLocator } from './locator.ts';
112
112
  import { prepareManagedProject } from './managed-projects.ts';
113
+ import { materializeMissing } from './materialize-client.ts';
113
114
  import { BIN_DIR, DEV_SERVER_ROOT, MEDIA_DIR, STICKERS_DIR } from './paths.ts';
114
115
  import { createPhotoStore, PHOTO_EDIT_MAX_BYTES } from './photo-store.ts';
115
116
  import { probeReadiness } from './readiness.ts';
@@ -480,6 +481,16 @@ export function readOnlyRefusalResponse(): Response {
480
481
  );
481
482
  }
482
483
 
484
+ /**
485
+ * The URL the design root is served under by the static fall-through below —
486
+ * `/<designRoot relative to repoRoot>` (`/.design` by default). Canvas builds
487
+ * rewrite CSS `url()` onto it (canvas-build.ts `assetUrlBase`).
488
+ */
489
+ function designRootUrlBase(paths: { repoRoot: string; designRoot: string }): string {
490
+ const rel = relative(paths.repoRoot, paths.designRoot).split(sep).join('/');
491
+ return rel ? `/${rel.split('/').map(encodeURIComponent).join('/')}` : '';
492
+ }
493
+
483
494
  function safePathUnderRoot(reqUrl: string, repoRoot: string): string | null {
484
495
  let pathname: string;
485
496
  try {
@@ -675,6 +686,7 @@ export async function serveCanvasTsx(
675
686
  const built = await buildCanvasSandboxed({
676
687
  designRoot: ctx.paths.designRoot,
677
688
  canvasAbs: absPath,
689
+ assetUrlBase: designRootUrlBase(ctx.paths),
678
690
  });
679
691
  if (!built.ok) {
680
692
  return new Response(`Canvas build error: ${built.error}`, {
@@ -707,6 +719,7 @@ export async function serveCanvasTsx(
707
719
  // a synced module cannot make the build read the wider filesystem.
708
720
  // The cell worker has always armed this (canvas-build-worker.ts).
709
721
  restrictImportsTo: ctx.paths.designRoot,
722
+ assetUrlBase: designRootUrlBase(ctx.paths),
710
723
  });
711
724
  } catch (err) {
712
725
  if (err instanceof TranspileError) {
@@ -926,6 +939,7 @@ async function serveHistoricalCanvas(
926
939
  // Same unconditional allowlist as the live build above — a HISTORICAL
927
940
  // source is still tenant/peer-authored content.
928
941
  restrictImportsTo: ctx.paths.designRoot,
942
+ assetUrlBase: designRootUrlBase(ctx.paths),
929
943
  });
930
944
  cached = {
931
945
  js: result.js,
@@ -1041,6 +1055,49 @@ const RANGE_MEDIA_EXTS = new Set(['.mp4', '.m4v', '.mov', '.webm', '.mp3', '.wav
1041
1055
  * (`bytes=a-b`, suffix `bytes=-n`, open `bytes=a-`); malformed ranges fall back
1042
1056
  * to a full 200; an unsatisfiable one gets an honest 416.
1043
1057
  */
1058
+ /**
1059
+ * Serve a cell-materialized blob (`_cache/blobs/<sha>`) with the headers its
1060
+ * LOGICAL name would get on the static route — type, caching, nosniff and the
1061
+ * inert-SVG CSP are all judged on the path the canvas asked for, never on the
1062
+ * extension-less cache file (cell materializer Task 10).
1063
+ */
1064
+ async function serveMaterialized(
1065
+ cacheAbs: string,
1066
+ logicalAbs: string,
1067
+ req: Request
1068
+ ): Promise<Response> {
1069
+ const e = ext(logicalAbs);
1070
+ const policy = cacheControlFor(logicalAbs);
1071
+ const headers: Record<string, string> = {
1072
+ 'Content-Type': MIME[e] || 'application/octet-stream',
1073
+ 'Cache-Control': policy.cacheControl,
1074
+ 'X-Content-Type-Options': 'nosniff',
1075
+ // The blob's name IS its sha256 — a stronger validator than size+mtime.
1076
+ ...(policy.addEtag ? { ETag: `"${basename(cacheAbs)}"` } : {}),
1077
+ ...(e === '.svg' ? { 'Content-Security-Policy': INERT_DOCUMENT_CSP } : {}),
1078
+ };
1079
+ if (RANGE_MEDIA_EXTS.has(e)) return serveMediaFile(cacheAbs, req, headers);
1080
+ return new Response(Bun.file(cacheAbs), { headers });
1081
+ }
1082
+
1083
+ /**
1084
+ * A static-route miss: on a cell, ask the hub to materialize the file; else
1085
+ * (or when the hub has nothing) the 404 it always was. A transient miss —
1086
+ * the fill is still running, the cache is momentarily full — is a 503 with
1087
+ * Retry-After, not a 404 a browser would cache as "gone".
1088
+ */
1089
+ async function materializedOr404(designRoot: string, logicalAbs: string, req: Request) {
1090
+ const m = await materializeMissing(designRoot, logicalAbs);
1091
+ if (m && 'path' in m) return serveMaterialized(m.path, logicalAbs, req);
1092
+ if (m && 'unavailable' in m) {
1093
+ return new Response('Fetching this file from storage — retry shortly', {
1094
+ status: 503,
1095
+ headers: { 'Retry-After': String(m.retryAfterS), 'Cache-Control': 'no-store' },
1096
+ });
1097
+ }
1098
+ return new Response('Not found', { status: 404 });
1099
+ }
1100
+
1044
1101
  async function serveMediaFile(
1045
1102
  absPath: string,
1046
1103
  req: Request,
@@ -5721,6 +5778,10 @@ export function createHttp(
5721
5778
  const isLogoSubdir = /^logos\/[a-z0-9]{8}\.(svg|png)$/.test(name);
5722
5779
  if (isFlat || isLogoSubdir) {
5723
5780
  const abs = join(ctx.paths.designRoot, 'assets', name);
5781
+ // A cell's disk is a cache — absent here may still be servable.
5782
+ if (!(await Bun.file(abs).exists())) {
5783
+ return materializedOr404(ctx.paths.designRoot, abs, req);
5784
+ }
5724
5785
  // Range-aware for video/audio (scrubbing + WKWebView compat).
5725
5786
  if (RANGE_MEDIA_EXTS.has(ext(name))) {
5726
5787
  return serveMediaFile(abs, req, { 'X-Content-Type-Options': 'nosniff' });
@@ -5816,7 +5877,15 @@ export function createHttp(
5816
5877
 
5817
5878
  const file = Bun.file(fp);
5818
5879
  const exists = await file.exists();
5819
- if (!exists) return new Response('Not found', { status: 404 });
5880
+ if (!exists) {
5881
+ // A cell's disk is a cache: the bytes may be in the bucket and not
5882
+ // here. Only under the design root — the repo's other files are not
5883
+ // the file plane's.
5884
+ if (`${fp}/`.startsWith(`${ctx.paths.designRoot}/`)) {
5885
+ return materializedOr404(ctx.paths.designRoot, fp, req);
5886
+ }
5887
+ return new Response('Not found', { status: 404 });
5888
+ }
5820
5889
 
5821
5890
  const e = ext(fp);
5822
5891
  const underDesignRoot = `${fp}/`.startsWith(`${ctx.paths.designRoot}/`);
@@ -0,0 +1,102 @@
1
+ // The studio child's half of the cell materializer (Task 10).
2
+ //
3
+ // On a cell the disk is a cache: inert media the journal lists may be in the
4
+ // bucket and nowhere on disk. When the static route misses one, it asks the
5
+ // hub it runs inside — over loopback, with the per-boot token the hub minted
6
+ // for this process (`MAUDE_MATERIALIZE_TOKEN`) — to fill its blob cache, and
7
+ // serves the verified file the hub names.
8
+ //
9
+ // THE HUB'S ANSWER IS CHECKED, NOT TRUSTED (DDR-054: the hub is semi-trusted).
10
+ // It is a local path, and it is served only if it resolves — through symlinks
11
+ // — to `<MAUDE_MATERIALIZE_CACHE_DIR>/blobs/<64-hex>`: the hub-owned cache, NOT
12
+ // anything under the design root (a tenant's git clone, where a committed
13
+ // symlink could aim the check itself). Anything else is a miss.
14
+ //
15
+ // Off unless the hub turned it on: absent env ⇒ `null` ⇒ the route's 404,
16
+ // exactly as before (desktop, self-hosted hub).
17
+
18
+ import { realpathSync } from 'node:fs';
19
+ import { basename, dirname, join, relative, sep } from 'node:path';
20
+
21
+ import { classifyProjectFile } from './sync/file-membership.ts';
22
+
23
+ const SHA = /^[0-9a-f]{64}$/;
24
+ const LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '[::1]']);
25
+
26
+ /** How long the static route waits on the hop. The hub answers `timeout`
27
+ * (503) at its own deadline (15 s); this only bounds a hub that hangs. */
28
+ const HOP_TIMEOUT_MS = 20_000;
29
+
30
+ export type MaterializeAnswer =
31
+ | { path: string }
32
+ | { unavailable: true; retryAfterS: number }
33
+ | null;
34
+
35
+ /**
36
+ * Ask the hub to materialize `logicalAbs` (a missing file under `designRoot`).
37
+ * `null` means "not ours to serve" — the caller answers 404 as before.
38
+ */
39
+ export async function materializeMissing(
40
+ designRoot: string,
41
+ logicalAbs: string,
42
+ {
43
+ env = process.env,
44
+ fetchImpl = fetch,
45
+ }: { env?: NodeJS.ProcessEnv; fetchImpl?: typeof fetch } = {}
46
+ ): Promise<MaterializeAnswer> {
47
+ if (env.MAUDE_CELL_MATERIALIZE !== '1') return null;
48
+ const base = env.MAUDE_MATERIALIZE_URL;
49
+ const token = env.MAUDE_MATERIALIZE_TOKEN;
50
+ const cacheDir = env.MAUDE_MATERIALIZE_CACHE_DIR;
51
+ if (!base || !token || !cacheDir) return null;
52
+ let url: URL;
53
+ try {
54
+ url = new URL('/_materialize', base);
55
+ } catch {
56
+ return null;
57
+ }
58
+ // The token must never leave the container: loopback only.
59
+ if (url.protocol !== 'http:' || !LOOPBACK_HOSTS.has(url.hostname)) return null;
60
+
61
+ const rel = relative(designRoot, logicalAbs).split(sep).join('/');
62
+ if (!rel || rel.startsWith('..')) return null;
63
+ // Inert media only — code and companion text are real checkout files.
64
+ // (The hub re-judges this with the project's own canvas groups.)
65
+ if (classifyProjectFile(rel, {}) !== 'inert-media') return null;
66
+ url.searchParams.set('rel', rel);
67
+
68
+ let res: Response;
69
+ try {
70
+ res = await fetchImpl(url, {
71
+ headers: { authorization: `Bearer ${token}` },
72
+ signal: AbortSignal.timeout(HOP_TIMEOUT_MS),
73
+ });
74
+ } catch {
75
+ return { unavailable: true, retryAfterS: 5 };
76
+ }
77
+ if (res.status === 503) {
78
+ const after = Number(res.headers.get('retry-after'));
79
+ return { unavailable: true, retryAfterS: Number.isFinite(after) && after > 0 ? after : 5 };
80
+ }
81
+ if (!res.ok) return null;
82
+ let body: { path?: unknown };
83
+ try {
84
+ body = (await res.json()) as { path?: unknown };
85
+ } catch {
86
+ return null;
87
+ }
88
+ const path = typeof body?.path === 'string' ? body.path : '';
89
+ return path && isCacheBlob(cacheDir, path) ? { path } : null;
90
+ }
91
+
92
+ /** Does `p` resolve, through symlinks, to `<cacheDir>/blobs/<sha>`? */
93
+ export function isCacheBlob(cacheDir: string, p: string): boolean {
94
+ if (!SHA.test(basename(p))) return false;
95
+ try {
96
+ const blobs = realpathSync(join(cacheDir, 'blobs'));
97
+ const real = realpathSync(p);
98
+ return dirname(real) === blobs && SHA.test(basename(real));
99
+ } catch {
100
+ return false;
101
+ }
102
+ }
@@ -160,7 +160,7 @@ export function isRuntimeStateRel(p: string): boolean {
160
160
  p
161
161
  ) ||
162
162
  /(^|\/)_server\.(?:lock|log)$/.test(p) ||
163
- /(^|\/)_(?:history|trash|draw|photo|smoke|reports|canvas-state|state|chat|comments|untrusted|export-jobs)(?:\/|$)/.test(
163
+ /(^|\/)_(?:history|trash|draw|photo|smoke|reports|canvas-state|state|chat|comments|untrusted|export-jobs|cache)(?:\/|$)/.test(
164
164
  p
165
165
  ) ||
166
166
  /(^|\/)\.kgai(?:\/|$)/.test(p)
@@ -72,7 +72,7 @@ import {
72
72
  type FileClass,
73
73
  isFilePlaneClass,
74
74
  } from './file-membership.ts';
75
- import { fetchJournal, type JournalEntry } from './journal-client.ts';
75
+ import { fetchJournal, type JournalEntry, type JournalPage } from './journal-client.ts';
76
76
  import { createPullBudget } from './pull-budget.ts';
77
77
  import { failureReason, isBackpressure, retryAfterMs } from './retry-after.ts';
78
78
  import { classifyTransportError } from './transport-error.ts';
@@ -213,6 +213,23 @@ export const REANCHOR_STORM_LIMIT = 5;
213
213
  */
214
214
  export const REANCHOR_HOLD_RECOVERY_MS = 15 * 20_000; // 15 poll ticks (index.ts REMOTE_POLL_MS)
215
215
 
216
+ /**
217
+ * Journal pages one pass may read — `MAX_JOURNAL_PAGE` (2000) entries each.
218
+ *
219
+ * A pass used to read ONE page. On a log longer than that (Brno Alligators,
220
+ * 2026-10-01: cursor 294, hub head ~4875) the page came back `truncated`, the
221
+ * cursor never moved, and every pass re-read the same 2000 rows — the hub's
222
+ * newer rows never arrived at all. Worse, an owed full read (`since=0`) of one
223
+ * page then ran `pruneRemotes` over everything past it, so this machine
224
+ * "forgot" the hub held thousands of files, pushed them as "the hub must hold
225
+ * nothing", met 409 for each, and owed another full read for every conflict:
226
+ * 43 → 135 conflicts in ten minutes, 1602 by the afternoon.
227
+ *
228
+ * Bounded so a hostile or enormous log still costs a known amount per pass;
229
+ * whatever is left is read from the advanced cursor on the next one.
230
+ */
231
+ export const MAX_JOURNAL_PAGES_PER_PASS = 20;
232
+
216
233
  /**
217
234
  * How many FIRST-ANCHOR conflicts one pass will resolve before it stops and asks.
218
235
  *
@@ -410,6 +427,15 @@ export interface FilePlaneOptions {
410
427
  label: string;
411
428
  /** Increment 6. Off means a local absence is HELD, never propagated. */
412
429
  propagateDeletes?: boolean;
430
+ /**
431
+ * The outbound delete breaker is OFF: a deliberate bulk delete on this
432
+ * machine propagates in one pass. Computed by the caller from LOCAL consent
433
+ * (`hubs.json` `unlimitedDeletes`) — never from the hub. The hub still gates
434
+ * it: only an owner-role token deletes past its budget, anyone else gets the
435
+ * 429 that holds this plane. The INBOUND breaker is untouched — what the hub
436
+ * asks this machine to remove is still held past the limits.
437
+ */
438
+ unlimitedOutboundDeletes?: boolean;
413
439
  /**
414
440
  * The user's bulk answer to a first-anchor storm — `'keep-local'` pushes
415
441
  * ours over theirs, `'keep-cloud'` takes theirs and parks ours. Absent means
@@ -1511,6 +1537,32 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1511
1537
  await ensureHubLimits();
1512
1538
  requestsThisPass = 0;
1513
1539
 
1540
+ /**
1541
+ * Follow `truncated` to the end of the log (bounded). Stops — leaving the
1542
+ * merged page `truncated` — on any refusal, a re-anchor or an epoch change
1543
+ * mid-read: what was read is still true, it is just not everything.
1544
+ */
1545
+ const readRemainingPages = async (first: JournalPage): Promise<JournalPage> => {
1546
+ let merged = first;
1547
+ for (let n = 1; merged.truncated && n < MAX_JOURNAL_PAGES_PER_PASS; n += 1) {
1548
+ const last = merged.entries.at(-1)?.seq;
1549
+ if (last === undefined) break;
1550
+ const next = await fetchJournal({
1551
+ hubUrl: opts.hubUrl,
1552
+ token: opts.token(),
1553
+ since: last,
1554
+ epoch: merged.epoch,
1555
+ fetchImpl,
1556
+ onRefused: async (res) => {
1557
+ await refusal(res);
1558
+ },
1559
+ });
1560
+ if (next === null || next.reanchor || next.epoch !== merged.epoch) break;
1561
+ merged = { ...next, entries: [...merged.entries, ...next.entries] };
1562
+ }
1563
+ return merged;
1564
+ };
1565
+
1514
1566
  // ── 1. The hub's side ────────────────────────────────────────────────
1515
1567
  const payOwedRead = fullReadOwed && now() - lastOwedFullReadAt >= REANCHOR_HOLD_RECOVERY_MS;
1516
1568
  if (payOwedRead) {
@@ -1598,6 +1650,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1598
1650
  reanchorsInARow = 0;
1599
1651
  reanchorHeldSince = 0;
1600
1652
  }
1653
+ page = await readRemainingPages(page);
1601
1654
 
1602
1655
  // THE HUB'S SIDE IS THE LEDGER'S REPLICA, UPDATED BY THIS PAGE — not the
1603
1656
  // page itself. A delta says "these changed"; it says nothing at all about
@@ -1625,7 +1678,11 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1625
1678
  }
1626
1679
  ledger.noteRemote(rel, row.deleted ? null : row.sha256, row.seq);
1627
1680
  }
1628
- if (fullRead) ledger.pruneRemotes(new Set(delta.keys()));
1681
+ // Only a COMPLETE full read may say "the hub does not have this". A
1682
+ // truncated one is silent about every path past its last page, and
1683
+ // pruning on it retracted the hub's copy of thousands of files at once
1684
+ // (see MAX_JOURNAL_PAGES_PER_PASS).
1685
+ if (fullRead && !page.truncated) ledger.pruneRemotes(new Set(delta.keys()));
1629
1686
 
1630
1687
  // ── 2. Ours ──────────────────────────────────────────────────────────
1631
1688
  const local = scanLocalFiles(designRoot, ledger, opts.canvasGroups);
@@ -1809,6 +1866,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1809
1866
  * drain the first two are blind to, and survives a restart.
1810
1867
  */
1811
1868
  const overBreaker = (direction: 'out' | 'in', n: number): boolean => {
1869
+ if (direction === 'out' && opts.unlimitedOutboundDeletes === true) return false;
1812
1870
  const already = ledger.deletesInWindow(direction, DELETE_BUDGET_WINDOW_MS);
1813
1871
  if (n > DELETE_BREAKER_MAX) return true;
1814
1872
  if (
@@ -1983,14 +2041,15 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1983
2041
 
1984
2042
  // ── 5. Position ──────────────────────────────────────────────────────
1985
2043
  //
1986
- // Only advance the cursor when the pass actually consumed the page. A
1987
- // partial pass re-reads the same range next time, which is free (the
1988
- // decisions for already-converged paths are `noop`).
1989
- if (!page.truncated && out.failed.length === 0) {
1990
- ledger.setPosition(page.epoch, page.head);
1991
- } else {
1992
- ledger.setPosition(page.epoch, ledger.cursor());
1993
- }
2044
+ // Advance to what this pass READ — the head when it read to the end,
2045
+ // else the last entry it got. Every remote it learned is already in the
2046
+ // ledger (`noteRemote`, step 1), and every path the ledger tracks is
2047
+ // re-decided each pass, so a file that failed is retried from that
2048
+ // memory, not by re-reading its row. Holding the cursor on any failure
2049
+ // pinned it forever on a project that always has one (515 unreachable
2050
+ // rows on Alligators), which is half of what kept it at 294.
2051
+ const readTo = page.truncated ? (page.entries.at(-1)?.seq ?? 0) : page.head;
2052
+ ledger.setPosition(page.epoch, Math.max(ledger.cursor(), readTo));
1994
2053
  ledger.flush();
1995
2054
 
1996
2055
  if (out.pulled.length || out.pushed.length || out.conflicts.length) {
@@ -2150,6 +2209,22 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2150
2209
  out.pushed.push(rel);
2151
2210
  return true;
2152
2211
  }
2212
+ if (res.conflict && res.current !== null && res.current === here.hash) {
2213
+ // THE HUB ALREADY HOLDS EXACTLY THESE BYTES. A 409 whose `current`
2214
+ // is our own hash is agreement, not a conflict: the hub got the same
2215
+ // file another way (a bucket refill after a restart, another peer's
2216
+ // identical push) while we decided from an older view. Recording it
2217
+ // as a conflict owed a full read per file and parked nothing anyone
2218
+ // needed — the 2026-10-01 Alligators storm was mostly this.
2219
+ await ledger.adoptAfter(rel, here.hash, () => {}, {
2220
+ size: here.size,
2221
+ mtimeMs: here.mtimeMs,
2222
+ state: 'on-hub',
2223
+ });
2224
+ ledger.noteRemote(rel, here.hash);
2225
+ out.synced += 1;
2226
+ return true;
2227
+ }
2153
2228
  if (res.conflict) {
2154
2229
  // The hub moved under us. Do NOT retry blindly — re-decide next
2155
2230
  // pass against what it actually holds now, which is exactly what a
@@ -44,6 +44,8 @@ interface HubsFile {
44
44
  expiresAt?: number;
45
45
  /** Local consent — see `HubRecord.codeModulesAllowed` in hubs-config.ts. */
46
46
  codeModulesAllowed?: boolean;
47
+ /** Local consent — see `HubRecord.unlimitedDeletes` in hubs-config.ts. */
48
+ unlimitedDeletes?: boolean;
47
49
  }
48
50
  >;
49
51
  trusted?: string[];
@@ -149,12 +151,14 @@ export function saveHubCredential(
149
151
  // sign-in response can change what the hub claims your role is; it must not
150
152
  // be able to change what you agreed this hub may deliver.
151
153
  const priorConsent = cfg.hubs[normUrl]?.codeModulesAllowed;
154
+ const priorDeletes = cfg.hubs[normUrl]?.unlimitedDeletes;
152
155
  cfg.hubs[normUrl] = {
153
156
  token,
154
157
  linkedAt: Date.now(),
155
158
  ...(role ? { role } : {}),
156
159
  ...(typeof expiresAt === 'number' && Number.isFinite(expiresAt) ? { expiresAt } : {}),
157
160
  ...(typeof priorConsent === 'boolean' ? { codeModulesAllowed: priorConsent } : {}),
161
+ ...(typeof priorDeletes === 'boolean' ? { unlimitedDeletes: priorDeletes } : {}),
158
162
  };
159
163
  if (!Array.isArray(cfg.trusted)) cfg.trusted = [];
160
164
  if (!cfg.trusted.includes(normUrl)) cfg.trusted.push(normUrl);
@@ -53,6 +53,16 @@ export interface HubRecord {
53
53
  * the same direction every other default in this file leans.
54
54
  */
55
55
  codeModulesAllowed?: boolean;
56
+ /**
57
+ * LOCAL consent: this machine's outbound delete breaker is OFF for this hub,
58
+ * so a deliberate bulk cleanup propagates at once instead of 10 per pass and
59
+ * 25 per hour. Same discipline as `codeModulesAllowed` — written only by
60
+ * `maude design bulk-deletes`, never by a sign-in response. It pairs with the
61
+ * hub, which admits unlimited deletes only from an OWNER-role token
62
+ * (`apps/hub/src/journal.mjs` OWNER_DELETE_SOURCE): a non-owner who sets it
63
+ * just meets the hub's 429 sooner. Absent means the breaker is on.
64
+ */
65
+ unlimitedDeletes?: boolean;
56
66
  }
57
67
 
58
68
  export interface HubsConfig {
@@ -882,6 +882,9 @@ export function createSyncRuntime(
882
882
  // by a login response, or this cell's own loopback pairing — where the hub
883
883
  // and the checkout are one trust domain and there is no remote party.
884
884
  const allowCodeModules = cellPairing !== null || storedRecord?.codeModulesAllowed === true;
885
+ // Same shape of consent for the OUTBOUND delete breaker: only what this
886
+ // machine's owner recorded (`maude design bulk-deletes on`), never the hub.
887
+ const unlimitedDeletes = storedRecord?.unlimitedDeletes === true;
885
888
 
886
889
  // DDR-102 — the default factory multiplexes every provider over ONE shared
887
890
  // WebSocket per hub URL; the runtime owns its disposal (stop(), after the
@@ -4707,6 +4710,7 @@ export function createSyncRuntime(
4707
4710
  ledger: fileLedger,
4708
4711
  canvasGroups: ctx.cfg.canvasGroups,
4709
4712
  allowCodeModules,
4713
+ unlimitedOutboundDeletes: unlimitedDeletes,
4710
4714
  // Increment 6, DEFAULT ON: a hub-owned mirror that ignores
4711
4715
  // deletes contradicts the model it is selling — you delete a
4712
4716
  // file and it comes back. `linkedHub.propagateDeletes: false`
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "$schema": "./whats-new.schema.json",
3
3
  "entries": [
4
+ {
5
+ "id": "cloud-projects-bigger-than-the-disk",
6
+ "version": "1.6.0",
7
+ "date": "2026-10-01",
8
+ "kind": "improvement",
9
+ "title": "Big cloud projects open with every photo",
10
+ "summary": "A cloud workspace can now hold a project bigger than its own disk. Photos and videos stay in storage and are fetched, checked, when a canvas needs them, so every canvas renders with all its media. Large background images and fonts referenced from stylesheets now load too; they used to be silently missing.",
11
+ "surface": "design-ui"
12
+ },
13
+ {
14
+ "id": "desktop-sync-no-false-conflicts",
15
+ "version": "1.6.0",
16
+ "date": "2026-10-01",
17
+ "kind": "fix",
18
+ "title": "No more false sync conflicts on big projects",
19
+ "summary": "File sync on large projects no longer fills up with conflicts that were not real. It reads the whole change history and recognises files the cloud already has, so uploads finish instead of retrying forever.",
20
+ "surface": "design-ui"
21
+ },
4
22
  {
5
23
  "id": "whiteboard-text-sections-live-previews",
6
24
  "version": "1.5.0",
@@ -13,7 +13,14 @@ import { createRequire } from 'node:module';
13
13
  import { homedir } from 'node:os';
14
14
  import { basename, dirname, join, resolve } from 'node:path';
15
15
  import { parseArgs } from '../lib/argv.mjs';
16
- import { runAdopt, runDetach, runLink, runStatus, runUnlink } from '../lib/design-link.mjs';
16
+ import {
17
+ runAdopt,
18
+ runBulkDeletes,
19
+ runDetach,
20
+ runLink,
21
+ runStatus,
22
+ runUnlink,
23
+ } from '../lib/design-link.mjs';
17
24
  import { writeGitignoreBlock } from '../lib/gitignore-block.mjs';
18
25
  import { isCompiledBinary } from '../lib/pkg-root.mjs';
19
26
 
@@ -26,6 +33,7 @@ const SUBCOMMANDS = new Set([
26
33
  'detach',
27
34
  'status',
28
35
  'adopt',
36
+ 'bulk-deletes',
29
37
  'help',
30
38
  ]);
31
39
 
@@ -175,6 +183,7 @@ export async function run({ args, pkgRoot }) {
175
183
  if (sub === 'detach') return runDetach({ args });
176
184
  if (sub === 'status') return runStatus({ args });
177
185
  if (sub === 'adopt') return runAdopt({ args });
186
+ if (sub === 'bulk-deletes') return runBulkDeletes({ args });
178
187
  }
179
188
 
180
189
  // Run a whitelisted dev-server bash helper, resolving it from maude's OWN
@@ -325,7 +334,7 @@ function usage() {
325
334
  return `maude design <verb> [options]
326
335
 
327
336
  Lifecycle:
328
- serve · init · export · link · adopt · detach · unlink · status
337
+ serve · init · export · link · adopt · detach · unlink · status · bulk-deletes
329
338
 
330
339
  Dev-tooling (dispatch to the dev-server bash helpers — DDR-062):
331
340
  screenshot · server-up · prep · slug · bootstrap-check · runtime-health
@@ -24,6 +24,7 @@ import {
24
24
  normalizeUrl,
25
25
  removeHub,
26
26
  setHubCodeModules,
27
+ setHubUnlimitedDeletes,
27
28
  trustHub,
28
29
  } from './hubs-config.mjs';
29
30
 
@@ -381,6 +382,56 @@ export async function runDetach({ args, cwd = process.cwd() }) {
381
382
  );
382
383
  }
383
384
 
385
+ // ---------------------------------------------------------------- bulk-deletes
386
+
387
+ /**
388
+ * `maude design bulk-deletes on|off|status [--hub <url>]`
389
+ *
390
+ * Turns THIS machine's outbound delete breaker off (or back on) for the
391
+ * project's linked hub, so a deliberate cleanup propagates in one pass instead
392
+ * of 10 per pass and 25 per hour. Local consent, recorded in hubs.json as
393
+ * `unlimitedDeletes` — the studio reads it at sync start, so restart
394
+ * `maude design serve` / the desktop app after changing it.
395
+ *
396
+ * The hub decides the other half: it admits deletes past its budget only from
397
+ * an owner-role token. For anyone else this setting changes nothing but where
398
+ * the refusal comes from.
399
+ */
400
+ export async function runBulkDeletes({ args, cwd = process.cwd() }) {
401
+ const tail = args.slice(args.indexOf('bulk-deletes') + 1);
402
+ const { flags, positional } = parseArgs(tail);
403
+ const verb = positional[0] ?? 'status';
404
+ if (!['on', 'off', 'status'].includes(verb)) {
405
+ process.stderr.write('usage: maude design bulk-deletes on|off|status [--hub <url>]\n');
406
+ process.exit(2);
407
+ }
408
+ let url = typeof flags.hub === 'string' ? flags.hub : null;
409
+ if (!url) {
410
+ const designConfigPath = resolve(cwd, DESIGN_CONFIG_PATH);
411
+ const cfg = existsSync(designConfigPath) ? readDesignConfig(designConfigPath) : null;
412
+ url = cfg?.linkedHub?.url ?? null;
413
+ }
414
+ if (!url) {
415
+ process.stderr.write(
416
+ '[design bulk-deletes] no linked hub here — run it in a linked project or pass --hub <url>.\n'
417
+ );
418
+ process.exit(1);
419
+ }
420
+ const normUrl = normalizeUrl(url);
421
+ const record = getHub(normUrl);
422
+ if (!record) {
423
+ process.stderr.write(`[design bulk-deletes] ${normUrl} is not linked on this machine.\n`);
424
+ process.exit(1);
425
+ }
426
+ if (verb !== 'status') setHubUnlimitedDeletes(normUrl, verb === 'on');
427
+ const on = verb === 'status' ? record.unlimitedDeletes === true : verb === 'on';
428
+ process.stdout.write(
429
+ on
430
+ ? `[design bulk-deletes] ON for ${normUrl} — deletes on this machine propagate without the 10/pass · 25/hour breaker. The hub admits that only from an owner-role token. Restart the sync (maude design serve / the app) to apply.\n`
431
+ : `[design bulk-deletes] off for ${normUrl} — the delete breaker holds bulk deletes (10 per pass, 25 per hour).${verb === 'off' ? ' Restart the sync to apply.' : ''}\n`
432
+ );
433
+ }
434
+
384
435
  // ---------------------------------------------------------------- status
385
436
 
386
437
  export async function runStatus({ args, cwd = process.cwd() }) {
@@ -54,6 +54,7 @@ export function buildBlock(designRel = '.design', { s3Assets = false } = {}) {
54
54
  `${root}/_canvas-state/`, // per-machine canvas scratch + camera (`*.view.json`, DDR-115)
55
55
  `${root}/_chat/`, // ACP transcripts (per-machine)
56
56
  `${root}/_untrusted/`, // hub-synced untrusted file mirror (DDR-054)
57
+ `${root}/_cache/`, // cell blob cache — content-addressed, disposable, re-fetched from the bucket (cell materializer)
57
58
  `${root}/_comments/`, // hub-sync-only collab comments (DDR-102/DDR-115 — never git)
58
59
  // Cloud Phase 3 Task 2 — when an S3/R2 asset lane is configured, binary
59
60
  // media lives in the bucket and must STOP entering git: a 60 MB clip is
@@ -111,6 +111,7 @@ export function addHub(url, token, extra = {}) {
111
111
  // said about you at sign-in; `codeModulesAllowed` is what YOU said about the
112
112
  // hub, and a login response must not be able to change it.
113
113
  const priorConsent = prior?.codeModulesAllowed;
114
+ const priorDeletes = prior?.unlimitedDeletes;
114
115
  // THE EXPIRY BELONGS TO THE TOKEN, so it survives exactly when the token does.
115
116
  //
116
117
  // `expiresAt` is written only by the sign-in and renew paths in
@@ -133,6 +134,7 @@ export function addHub(url, token, extra = {}) {
133
134
  ...(priorRole ? { role: priorRole } : {}),
134
135
  ...(typeof priorExpiry === 'number' ? { expiresAt: priorExpiry } : {}),
135
136
  ...(typeof priorConsent === 'boolean' ? { codeModulesAllowed: priorConsent } : {}),
137
+ ...(typeof priorDeletes === 'boolean' ? { unlimitedDeletes: priorDeletes } : {}),
136
138
  ...extra,
137
139
  };
138
140
  saveHubsConfig(cfg);
@@ -155,6 +157,22 @@ export function setHubCodeModules(url, allowed) {
155
157
  return true;
156
158
  }
157
159
 
160
+ /**
161
+ * Record whether this machine's outbound delete breaker is off for `url`.
162
+ *
163
+ * The one writer for `unlimitedDeletes` (see the studio `HubRecord`). The hub
164
+ * still decides: it admits an unbounded stream of deletes only from an
165
+ * owner-role token.
166
+ */
167
+ export function setHubUnlimitedDeletes(url, on) {
168
+ const norm = normalizeUrl(url);
169
+ const cfg = loadHubsConfig();
170
+ if (!cfg.hubs[norm]) return false;
171
+ cfg.hubs[norm].unlimitedDeletes = on === true;
172
+ saveHubsConfig(cfg);
173
+ return true;
174
+ }
175
+
158
176
  /** Remove a hub entry. Returns true if anything was removed. */
159
177
  export function removeHub(url) {
160
178
  const norm = normalizeUrl(url);