@1agh/maude 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/apps/hub/src/project-transactions/kernel.mjs +10 -1
  2. package/apps/studio/access/filters.ts +12 -5
  3. package/apps/studio/access/known-canvases.ts +24 -1
  4. package/apps/studio/access/refused-inputs.ts +89 -0
  5. package/apps/studio/actions/agents.ts +5 -0
  6. package/apps/studio/actions/defs/app.ts +12 -0
  7. package/apps/studio/actions.manifest.json +13 -1
  8. package/apps/studio/actions.parity.json +7 -1
  9. package/apps/studio/annotations/ui/element-node.tsx +139 -54
  10. package/apps/studio/annotations/ui/lod.tsx +1 -1
  11. package/apps/studio/annotations/ui/text-style.ts +1 -1
  12. package/apps/studio/annotations-layer.tsx +0 -12
  13. package/apps/studio/api.ts +42 -0
  14. package/apps/studio/artboard-live-gate.tsx +267 -0
  15. package/apps/studio/artboard-live.ts +336 -0
  16. package/apps/studio/artboard-webgl.ts +668 -0
  17. package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
  18. package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
  19. package/apps/studio/bin/_canvas-reasons.mjs +34 -0
  20. package/apps/studio/bin/_ds-check-live.mjs +37 -0
  21. package/apps/studio/bin/_ds-check.mjs +4 -1
  22. package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
  23. package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
  24. package/apps/studio/bin/_import-asset.mjs +2 -1
  25. package/apps/studio/bin/_perf-probe.mjs +2 -1
  26. package/apps/studio/bin/_studio-verb.mjs +24 -3
  27. package/apps/studio/bin/_thumb-blank.mjs +70 -0
  28. package/apps/studio/bin/_thumb-cover.mjs +35 -0
  29. package/apps/studio/bin/_thumbs-playwright.mjs +89 -12
  30. package/apps/studio/bin/ds-check.sh +5 -1
  31. package/apps/studio/bin/perf.sh +11 -1
  32. package/apps/studio/bin/server-up.sh +7 -2
  33. package/apps/studio/bin/smoke.sh +19 -0
  34. package/apps/studio/canvas-lib.tsx +131 -12
  35. package/apps/studio/client/canvas-url.js +13 -0
  36. package/apps/studio/client/home/HomeAccounts.jsx +262 -0
  37. package/apps/studio/client/home/Shelves.jsx +4 -3
  38. package/apps/studio/client/home/home-accounts-model.js +121 -0
  39. package/apps/studio/client/home/home-api.js +6 -0
  40. package/apps/studio/client/home/home-app.jsx +141 -40
  41. package/apps/studio/client/home/home-model.js +172 -6
  42. package/apps/studio/client/home/home.css +169 -5
  43. package/apps/studio/client/home/shell-mode.js +8 -1
  44. package/apps/studio/client/hooks/use-project-data.jsx +2 -0
  45. package/apps/studio/client/panels/ChatPanel.jsx +27 -20
  46. package/apps/studio/client/panels/CreateProject.jsx +19 -5
  47. package/apps/studio/client/panels/caps-cache.js +46 -0
  48. package/apps/studio/client/shell/viewport.jsx +36 -8
  49. package/apps/studio/client/v2/access/access-client.js +2 -0
  50. package/apps/studio/client/v2/access/access-host.jsx +12 -1
  51. package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
  52. package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
  53. package/apps/studio/client/v2/ai/Composer.jsx +27 -10
  54. package/apps/studio/client/v2/code/canvas-imports-card.jsx +15 -14
  55. package/apps/studio/client/v2/code/canvas-imports-words.js +44 -0
  56. package/apps/studio/client/v2/code/code-bus.js +5 -0
  57. package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
  58. package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
  59. package/apps/studio/client/v2/ds/library-host.jsx +45 -45
  60. package/apps/studio/client/v2/ds/make-host.jsx +13 -15
  61. package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
  62. package/apps/studio/client/v2/ds/review-host.jsx +7 -1
  63. package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
  64. package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
  65. package/apps/studio/client/v2/history/branch-actions.js +13 -9
  66. package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
  67. package/apps/studio/client/v2/history/git-model.js +3 -1
  68. package/apps/studio/client/v2/history/git-parts.jsx +16 -1
  69. package/apps/studio/client/v2/presence/faces.jsx +42 -14
  70. package/apps/studio/client/v2/shell/account-card.jsx +10 -4
  71. package/apps/studio/client/v2/shell/canvas-crash-guard.js +137 -0
  72. package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
  73. package/apps/studio/client/v2/shell/menu-runner.js +11 -0
  74. package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
  75. package/apps/studio/client/v2/shell/project-account-model.js +182 -0
  76. package/apps/studio/client/v2/shell/share-cluster-host.jsx +137 -10
  77. package/apps/studio/client/v2/shell/share-cluster.css +58 -0
  78. package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
  79. package/apps/studio/client/v2/shell/team-switch.js +94 -0
  80. package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
  81. package/apps/studio/client/v2/shell/use-account.js +8 -1
  82. package/apps/studio/collab/persistence.ts +9 -1
  83. package/apps/studio/collab/registry.ts +32 -0
  84. package/apps/studio/collab/room.ts +8 -0
  85. package/apps/studio/config-reload-wire.ts +53 -0
  86. package/apps/studio/dist/client.bundle.js +1232 -1232
  87. package/apps/studio/dist/styles.css +1 -1
  88. package/apps/studio/ds/board/specimen.tsx +12 -1
  89. package/apps/studio/ds/canvas-cli.ts +58 -2
  90. package/apps/studio/ds/check.ts +26 -1
  91. package/apps/studio/ds/cli.ts +7 -3
  92. package/apps/studio/ds/convert.ts +34 -6
  93. package/apps/studio/ds/ds-verb.ts +13 -0
  94. package/apps/studio/ds/post-build.ts +38 -0
  95. package/apps/studio/ds/upgrade-apply.ts +27 -5
  96. package/apps/studio/ds/upgrade-cli.ts +22 -2
  97. package/apps/studio/ds/upgrade-prove.ts +198 -15
  98. package/apps/studio/ds/upgrade-stage.ts +4 -1
  99. package/apps/studio/history/trash.ts +6 -0
  100. package/apps/studio/home/accounts.ts +87 -0
  101. package/apps/studio/home/index-reader.ts +24 -2
  102. package/apps/studio/home/routes.ts +19 -0
  103. package/apps/studio/http.ts +14 -2
  104. package/apps/studio/routes/ds-convert.ts +18 -0
  105. package/apps/studio/routes/trash.ts +16 -1
  106. package/apps/studio/server.ts +8 -10
  107. package/apps/studio/sync/accepted-cold-start.ts +28 -13
  108. package/apps/studio/sync/asset-push.ts +146 -23
  109. package/apps/studio/sync/asset-state.ts +3 -2
  110. package/apps/studio/sync/file-membership.ts +28 -3
  111. package/apps/studio/sync/file-plane.ts +40 -9
  112. package/apps/studio/sync/file-pull.ts +304 -33
  113. package/apps/studio/sync/hub-link.ts +1 -2
  114. package/apps/studio/sync/index.ts +308 -150
  115. package/apps/studio/sync/journal-client.ts +94 -5
  116. package/apps/studio/sync/pending-deletes.ts +100 -0
  117. package/apps/studio/sync/projection.ts +77 -12
  118. package/apps/studio/sync/seed-progress.ts +12 -1
  119. package/apps/studio/sync/status.ts +3 -1
  120. package/apps/studio/thumbs/service.ts +12 -2
  121. package/apps/studio/thumbs/validate.ts +7 -0
  122. package/apps/studio/ui-prefs-migrate.ts +4 -0
  123. package/apps/studio/video-comp.tsx +23 -0
  124. package/apps/studio/whats-new.json +72 -0
  125. package/cli/lib/bash-guard.mjs +13 -1
  126. package/cli/lib/design-help.gen.mjs +1 -1
  127. package/cli/lib/design-hook.mjs +20 -0
  128. package/cli/lib/studio-locate.mjs +35 -10
  129. package/package.json +8 -8
@@ -165,6 +165,13 @@ export interface AcceptedColdStartInput {
165
165
  * is the base — the recovery slot still holds the value before it.
166
166
  */
167
167
  ownAccepted?: string | null;
168
+ /**
169
+ * #14 (2.0.5) — the css twin's `ownAccepted`: this disk's own css proposal a previous run left
170
+ * unanswered (an edit made offline, or just before quitting), which the drain has just had
171
+ * accepted. Without it a css edited while the studio was closed was judged against the css
172
+ * before that save, and refused as a conflict with the person's own older css.
173
+ */
174
+ ownAcceptedCss?: string | null;
168
175
  /**
169
176
  * Did the project ever accept exactly this value? A disk with no record of
170
177
  * its base that holds a value the store accepted at some revision holds an
@@ -286,19 +293,27 @@ export async function acceptedColdStart(
286
293
  // ---- css — opaque text, journal-checkpointed
287
294
  if (i.paths.css) {
288
295
  const localCss = readText(i.paths.css);
289
- const d = decideSourceLane({
290
- local: localCss,
291
- accepted: cssFromDoc(i.doc) ?? '',
292
- knownBase: i.historyDir ? readRecoveryBody(i.historyDir, i.paths.css, 'base') : null,
293
- baseHash: i.journal?.get(i.slug)?.cssHash ?? null,
294
- });
295
- const older =
296
- d.decision === 'hold' && localCss !== null && (await i.wasAccepted?.(localCss)) === true;
297
- verdicts.push({
298
- lane: 'css',
299
- ...(older ? { decision: 'materialize' as const } : d),
300
- ...(localCss !== null ? { local: localCss } : {}),
301
- });
296
+ if (i.ownAcceptedCss != null && localCss === i.ownAcceptedCss) {
297
+ // Disk IS the drained, accepted css; its publication may still be on the way.
298
+ verdicts.push({ lane: 'css', decision: 'agreed', local: localCss });
299
+ i.projection.adoptOwnAcceptedCss(i.ownAcceptedCss);
300
+ } else {
301
+ const d = decideSourceLane({
302
+ local: localCss,
303
+ accepted: cssFromDoc(i.doc) ?? '',
304
+ knownBase:
305
+ i.ownAcceptedCss ??
306
+ (i.historyDir ? readRecoveryBody(i.historyDir, i.paths.css, 'base') : null),
307
+ baseHash: i.journal?.get(i.slug)?.cssHash ?? null,
308
+ });
309
+ const older =
310
+ d.decision === 'hold' && localCss !== null && (await i.wasAccepted?.(localCss)) === true;
311
+ verdicts.push({
312
+ lane: 'css',
313
+ ...(older ? { decision: 'materialize' as const } : d),
314
+ ...(localCss !== null ? { local: localCss } : {}),
315
+ });
316
+ }
302
317
  }
303
318
 
304
319
  // ---- meta — the shared layout keys (viewport never travels)
@@ -44,12 +44,18 @@ import { randomBytes } from 'node:crypto';
44
44
  import { type Dirent, readdirSync, readFileSync, statSync } from 'node:fs';
45
45
  import path from 'node:path';
46
46
 
47
- import { type CanvasGroupLike, classifyProjectFile, isFilePlaneClass } from './file-membership.ts';
47
+ import {
48
+ type CanvasGroupLike,
49
+ classifyProjectFile,
50
+ isFilePlaneClass,
51
+ MAX_SEGMENTS,
52
+ OLDER_HUB_DEPTH_REASON,
53
+ olderDoorRefusesDepth,
54
+ } from './file-membership.ts';
48
55
  import { readLfsPointer } from './lfs-pointer.ts';
49
56
  import { failureReason, retryAfterMs } from './retry-after.ts';
50
57
 
51
- /** Max designRoot-relative depth (matches the classifier's 8-segment cap). */
52
- const MAX_SEGMENTS = 8;
58
+ export { OLDER_HUB_DEPTH_REASON };
53
59
 
54
60
  /** A 2 GB file in an assets dir is a mistake — don't move it silently. */
55
61
  const MAX_PUSH_BYTES = 512 * 1024 * 1024;
@@ -273,11 +279,21 @@ export function listPushableAssets(
273
279
  .sort();
274
280
  }
275
281
 
282
+ /**
283
+ * The hub's bucket key shape (`apps/hub/src/assets.mjs` ASSET_KEY): at most five
284
+ * segments under `assets/`, no spaces, each segment ≤ 64 characters. A top-level
285
+ * path it cannot key — an asset pack's `Models/GLTF format/…` — was sent to the
286
+ * bucket route anyway and refused `400` every boot (fix/205); it goes to the
287
+ * checkout route, which takes any classifier-admitted path.
288
+ */
289
+ const BUCKET_KEY =
290
+ /^(?!.*(?:^|\/)\.\.(?:\/|$))[A-Za-z0-9][A-Za-z0-9._-]{0,63}(?:\/[A-Za-z0-9][A-Za-z0-9._-]{0,63}){0,4}$/;
291
+
276
292
  /** Where a given asset pushes: the bucket-backed route (top-level `assets/`) or
277
293
  * the checkout route (a nested `…/assets/…` served from disk). */
278
294
  function routeFor(rel: string): { url: string } {
279
295
  const parts = rel.split('/');
280
- if (parts[0] === 'assets') {
296
+ if (parts[0] === 'assets' && BUCKET_KEY.test(parts.slice(1).join('/'))) {
281
297
  // Top-level content-addressed → the bucket `/assets/<key>` route.
282
298
  return { url: `/assets/${parts.slice(1).join('/')}` };
283
299
  }
@@ -361,6 +377,8 @@ async function putWithRetry(ctx: {
361
377
  /** Mutable per-sweep pause budget, shared across every asset. */
362
378
  backoff: { remainingMs: number };
363
379
  timeoutFor: (bytes: number) => number;
380
+ /** Told when the hub answered 429 — the caller narrows the sweep. */
381
+ onThrottled?: () => void;
364
382
  }): Promise<Response> {
365
383
  const send = (): Promise<Response> => {
366
384
  const body = Bun.file(ctx.file);
@@ -379,6 +397,7 @@ async function putWithRetry(ctx: {
379
397
  };
380
398
  const first = await send();
381
399
  if (first.status === 429) {
400
+ ctx.onThrottled?.();
382
401
  const wait = retryAfterMs(first.headers?.get?.('retry-after') ?? null);
383
402
  if (wait > ctx.backoff.remainingMs) return first;
384
403
  ctx.backoff.remainingMs -= wait;
@@ -390,11 +409,52 @@ async function putWithRetry(ctx: {
390
409
  }
391
410
 
392
411
  /**
393
- * Mirror local assets up to the hub. Idempotent and skip-first (one HEAD per
394
- * asset per boot; upload only on a miss), sequential on purpose — assets run
395
- * to videos, and saturating the link a fresh sync is also using would starve
396
- * the handshakes this rides behind. Never throws; a failed upload is retried
397
- * for free on the next boot.
412
+ * How many uploads one sweep keeps on the wire (fix/205-sync-assets).
413
+ *
414
+ * It was ONE, "sequential on purpose" so a video upload could not starve the
415
+ * handshakes a fresh sync rides on. That made one hung PUT the whole lane's
416
+ * problem: the studyfi first sync (5,534 assets) sat on one SVG for its full
417
+ * budget. Four is enough that a slow file no longer stalls the rest and still
418
+ * far from saturating a link — the text lanes keep their share.
419
+ */
420
+ export const UPLOAD_WIDTH_MAX = 4;
421
+ /** Reads per minute (the hub's advertised `readsPerMinute`) one upload lane is worth. */
422
+ const READS_PER_UPLOAD_LANE = 120;
423
+ const LIMITS_TIMEOUT_MS = 10_000;
424
+
425
+ /**
426
+ * The sweep's width: UPLOAD_WIDTH_MAX, narrowed when the hub says its rate is
427
+ * low (`/api/file-limits` `readsPerMinute`, #204). Hub-supplied (DDR-054), so
428
+ * it can only slow us down — to one — never widen past the maximum. A hub
429
+ * without the route (every journal-less hub this lane serves, most likely), or
430
+ * one that does not answer, gets the default: its 429s narrow the sweep anyway.
431
+ */
432
+ async function uploadWidth(ctx: {
433
+ fetchImpl: typeof fetch;
434
+ base: string;
435
+ token: () => string;
436
+ }): Promise<number> {
437
+ try {
438
+ const res = await ctx.fetchImpl(`${ctx.base}/api/file-limits`, {
439
+ headers: { authorization: `Bearer ${ctx.token()}` },
440
+ signal: AbortSignal.timeout(LIMITS_TIMEOUT_MS),
441
+ });
442
+ if (!res.ok) return UPLOAD_WIDTH_MAX;
443
+ const body = (await res.json()) as { readsPerMinute?: unknown };
444
+ const rpm = body?.readsPerMinute;
445
+ if (typeof rpm !== 'number' || !Number.isFinite(rpm) || rpm <= 0) return UPLOAD_WIDTH_MAX;
446
+ return Math.max(1, Math.min(UPLOAD_WIDTH_MAX, Math.floor(rpm / READS_PER_UPLOAD_LANE)));
447
+ } catch {
448
+ return UPLOAD_WIDTH_MAX;
449
+ }
450
+ }
451
+
452
+ /**
453
+ * Mirror local assets up to the hub. Idempotent and skip-first (one batch probe
454
+ * per boot, per-file HEAD only on a hub without it; upload only on a miss), a
455
+ * few at a time (UPLOAD_WIDTH_MAX). A first-attempt timeout is tried once more
456
+ * after the rest of the sweep. Never throws; a failed upload is retried for
457
+ * free on the next boot.
398
458
  */
399
459
  export async function pushAssets(opts: {
400
460
  designRoot: string;
@@ -406,6 +466,12 @@ export async function pushAssets(opts: {
406
466
  canvasGroups?: readonly CanvasGroupLike[];
407
467
  /** The file-plane flag; absent ⇒ read from config/env the same way. */
408
468
  syncFiles?: boolean;
469
+ /**
470
+ * fix/205 — the hub advertises `file-depth-v2`. False ⇒ a path deeper than 8 segments is not
471
+ * sent (an older hub answers `400 invalid path`, and one such path in the batch probe refuses
472
+ * the whole probe): it is reported as failed with OLDER_HUB_DEPTH_REASON, by name. Absent ⇒ true.
473
+ */
474
+ hubTakesDeepPaths?: boolean;
409
475
  fetchImpl?: typeof fetch;
410
476
  log?: Pick<Console, 'log' | 'warn'>;
411
477
  /** feature-sync-progress-modal — incremental progress (throttled; failures
@@ -474,30 +540,48 @@ export async function pushAssets(opts: {
474
540
 
475
541
  // One question for the whole set, when the hub can answer it. Null = this hub
476
542
  // predates the route, so every file falls back to its own probe below.
543
+ // fix/205 — a hub older than `file-depth-v2` refuses a path deeper than 8 segments. Never sent,
544
+ // never silent: each is named with the reason (the panel lists failures by path).
545
+ const tooDeep =
546
+ opts.hubTakesDeepPaths === false ? assets.filter((rel) => olderDoorRefusesDepth(rel)) : [];
547
+ for (const rel of tooDeep) out.failed.push({ key: rel, reason: OLDER_HUB_DEPTH_REASON });
548
+ const sendable =
549
+ tooDeep.length > 0 ? assets.filter((rel) => !olderDoorRefusesDepth(rel)) : assets;
550
+ if (tooDeep.length > 0)
551
+ log.warn?.(
552
+ `[sync/assets] ${tooDeep.length} file(s) sit deeper than ${base} takes (8 folders) — update the hub`
553
+ );
554
+
477
555
  const known =
478
- assets.length > 0
556
+ sendable.length > 0
479
557
  ? await probePresent({
480
558
  fetchImpl,
481
559
  base,
482
560
  headers: { authorization: `Bearer ${opts.token()}` },
483
- paths: assets,
561
+ paths: sendable,
484
562
  })
485
563
  : null;
486
564
 
487
- for (const rel of assets) {
488
- if (opts.cancelled?.()) break;
565
+ // fix/205 — what the batch already answered is settled NOW, not lazily in
566
+ // loop order: "5463 moving" for a set the hub held all but 74 of was the
567
+ // panel counting files nobody was going to send.
568
+ const queue = known ? sendable.filter((rel) => !known.has(rel)) : sendable;
569
+ if (known) out.skipped = sendable.length - queue.length;
570
+ if (assets.length > 0) emitProgress(queue[0] ?? null, false, true);
571
+
572
+ // How many uploads may be on the wire at once. See UPLOAD_WIDTH_MAX.
573
+ let width = queue.length > 0 ? await uploadWidth({ fetchImpl, base, token: opts.token }) : 1;
574
+ let stop = false;
575
+ /** Files whose FIRST attempt timed out — they get one more go after the rest of the sweep. */
576
+ const timedOut: string[] = [];
577
+
578
+ const one = async (rel: string, lastTry: boolean): Promise<void> => {
489
579
  emitProgress(rel, false);
490
580
  const url = `${base}${routeFor(rel).url}`;
491
581
  const headers = { authorization: `Bearer ${opts.token()}` };
492
- if (known) {
493
- if (known.has(rel)) {
494
- out.skipped += 1;
495
- continue;
496
- }
582
+ try {
497
583
  // The batch answered, and it said this one is missing — no per-file probe
498
584
  // can add anything, so go straight to the upload.
499
- }
500
- try {
501
585
  const head = known
502
586
  ? null
503
587
  : await fetchImpl(url, {
@@ -507,7 +591,7 @@ export async function pushAssets(opts: {
507
591
  });
508
592
  if (head?.ok) {
509
593
  out.skipped += 1;
510
- continue;
594
+ return;
511
595
  }
512
596
  // A hub that refuses the PROBE refuses the upload — pushing the body
513
597
  // anyway just streams megabytes at a door that already said no. The
@@ -521,7 +605,12 @@ export async function pushAssets(opts: {
521
605
  if (head && (head.status === 401 || head.status === 403)) {
522
606
  out.failed.push({ key: rel, reason: await failureReason(head) });
523
607
  emitProgress(rel, false, true);
524
- continue;
608
+ return;
609
+ }
610
+ // The cancel may land while the probe was out — never start a body after it.
611
+ if (stop || opts.cancelled?.()) {
612
+ stop = true;
613
+ return;
525
614
  }
526
615
  const put = await putWithRetry({
527
616
  fetchImpl,
@@ -531,19 +620,30 @@ export async function pushAssets(opts: {
531
620
  sleep,
532
621
  backoff,
533
622
  timeoutFor,
623
+ // The hub is pacing us: the rest of this sweep goes one file at a time.
624
+ onThrottled: () => {
625
+ width = 1;
626
+ },
534
627
  });
535
628
  if (put.ok) out.pushed.push(rel);
536
629
  else if (put.status === 405) {
537
630
  // `this hub does not accept file writes`: no checkout, so no file can ever land here. Stop the pass — the
538
631
  // next file would get the same answer — and say it is not a failure; the media stays on this Mac.
539
632
  out.refused = 'no-checkout';
540
- break;
633
+ stop = true;
541
634
  } else {
542
635
  out.failed.push({ key: rel, reason: await failureReason(put) });
543
636
  emitProgress(rel, false, true);
544
637
  }
545
638
  } catch (err) {
546
639
  const e = err as Error;
640
+ // One hung request used to cost the file its whole boot. A timeout is the
641
+ // likeliest refusal to be transient, so it waits for the end of the sweep
642
+ // and goes once more (lastTry) — a second timeout is reported.
643
+ if (e.name === 'TimeoutError' && !lastTry) {
644
+ timedOut.push(rel);
645
+ return;
646
+ }
547
647
  out.failed.push({
548
648
  key: rel,
549
649
  // "TimeoutError: The operation timed out" tells a person nothing about
@@ -552,6 +652,29 @@ export async function pushAssets(opts: {
552
652
  });
553
653
  emitProgress(rel, false, true);
554
654
  }
655
+ };
656
+
657
+ let next = 0;
658
+ const worker = async (id: number): Promise<void> => {
659
+ // A worker past the current width retires (a 429 narrows the sweep to one).
660
+ while (!stop && id < width && next < queue.length) {
661
+ if (opts.cancelled?.()) {
662
+ stop = true;
663
+ break;
664
+ }
665
+ const rel = queue[next++] as string;
666
+ await one(rel, false);
667
+ }
668
+ };
669
+ // The sweep's FIRST upload goes alone: the door's answer to it — 405 (no checkout: nothing can
670
+ // ever land, the media gate stops the lane), a 429 (pace us) — is known before the pool opens,
671
+ // so a door that says no gets one body, not `width` bodies already on the wire.
672
+ if (!stop && next < queue.length && !opts.cancelled?.())
673
+ await one(queue[next++] as string, false);
674
+ await Promise.all(Array.from({ length: width }, (_, id) => worker(id)));
675
+ for (const rel of timedOut) {
676
+ if (stop || opts.cancelled?.()) break;
677
+ await one(rel, true);
555
678
  }
556
679
  // No assets → no emits at all: a project without an assets/ dir should not
557
680
  // grow an empty assets section in its Sync panel.
@@ -26,7 +26,7 @@ import { existsSync, lstatSync } from 'node:fs';
26
26
  import path from 'node:path';
27
27
 
28
28
  import { listPushableAssets } from './asset-push.ts';
29
- import { type CanvasGroupLike, classifyProjectFile } from './file-membership.ts';
29
+ import { type CanvasGroupLike, classifyProjectFile, MAX_SEGMENTS } from './file-membership.ts';
30
30
  import { hasLfsObject, lfsObjectsDir, readLfsPointer } from './lfs-pointer.ts';
31
31
 
32
32
  export interface AssetWho {
@@ -73,7 +73,8 @@ export function isAssetStateRel(rel: unknown): rel is string {
73
73
  // biome-ignore lint/suspicious/noControlCharactersInRegex: refusing them is the point.
74
74
  if (/[\u0000-\u001f\u007f]/.test(rel)) return false;
75
75
  const parts = rel.split('/');
76
- if (parts.length < 2 || parts.length > 8) return false;
76
+ // The classifier's depth cap (32 since fix/205) — a deep asset must be askable too.
77
+ if (parts.length < 2 || parts.length > MAX_SEGMENTS) return false;
77
78
  return parts.every((p) => p && p !== '.' && p !== '..' && !p.startsWith('_'));
78
79
  }
79
80
 
@@ -78,8 +78,23 @@ export function isFilePlaneClass(c: FileClass): c is FilePlaneClass {
78
78
  /** Max relative-path length (matches the hub's checkout shape cap). */
79
79
  export const MAX_REL_LEN = 512;
80
80
 
81
- /** Max designRoot-relative depth (matches the hub's 8-segment cap). */
82
- export const MAX_SEGMENTS = 8;
81
+ /**
82
+ * Max designRoot-relative depth, in segments — the hub mirror carries the same figure.
83
+ *
84
+ * It was 8 until fix/205-sync-assets: a 3D asset pack (`assets/kenney/…/Models/GLTF format/
85
+ * Textures/…`) sat deeper, both classifiers answered `never`, and the files were dropped with no
86
+ * row anywhere. The depth cap never guarded anything the shape rules do not (no `..`, no
87
+ * absolute, a conservative charset, MAX_REL_LEN); it only keeps a key from being absurd. 32 still
88
+ * does, and every walk that mirrors it stays bounded.
89
+ */
90
+ export const MAX_SEGMENTS = 32;
91
+
92
+ /** The cap every hub before `file-depth-v2` refuses past (`olderDoorRefusesDepth`). */
93
+ export const LEGACY_MAX_SEGMENTS = 8;
94
+
95
+ /** The ledger / panel reason for a file held back from a hub without `file-depth-v2`. */
96
+ export const OLDER_HUB_DEPTH_REASON =
97
+ 'The project’s server runs an older Maude that takes files at most 8 folders deep — update it to sync this file';
83
98
 
84
99
  // The positive extension enumerations. Everything is lowercase; the lookup
85
100
  // lowercases first — a DS legitimately ships `…P1020428.JPG`.
@@ -264,7 +279,7 @@ export interface ClassifyOptions {
264
279
  * deliberately the same answer, so no caller can tell them apart and leak an
265
280
  * oracle.
266
281
  *
267
- * Shape gates (all refusals → `never`): relative, `/`-separated, ≤ 8
282
+ * Shape gates (all refusals → `never`): relative, `/`-separated, ≤ 32
268
283
  * segments, ≤ 512 chars, no `..`/`.`/empty segment, no backslash, no drive
269
284
  * letter, no control characters, no trailing-space segment, no
270
285
  * `node_modules`, directory segments start alphanumeric, the final segment
@@ -373,6 +388,16 @@ export function olderDoorRefuses(rel: string): boolean {
373
388
  return lower.endsWith('.json') && !OLDER_DOOR_JSON_SUFFIXES.some((s) => lower.endsWith(s));
374
389
  }
375
390
 
391
+ /**
392
+ * Would a hub without `file-depth-v2` refuse this path for its depth alone? (fix/205)
393
+ *
394
+ * Every hub before it caps a path at LEGACY_MAX_SEGMENTS and answers anything deeper
395
+ * `400 invalid path`. Asked only about a path this side already admits. Studio-only.
396
+ */
397
+ export function olderDoorRefusesDepth(rel: string): boolean {
398
+ return rel.split('/').length > LEGACY_MAX_SEGMENTS;
399
+ }
400
+
376
401
  /** The segment shape rules alone — split parts, or null on refusal. */
377
402
 
378
403
  /**
@@ -71,7 +71,10 @@ import {
71
71
  classifyProjectFile,
72
72
  type FileClass,
73
73
  isFilePlaneClass,
74
+ MAX_SEGMENTS,
75
+ OLDER_HUB_DEPTH_REASON,
74
76
  olderDoorRefuses,
77
+ olderDoorRefusesDepth,
75
78
  } from './file-membership.ts';
76
79
  import {
77
80
  fetchJournal,
@@ -84,6 +87,7 @@ import { createPullBudget } from './pull-budget.ts';
84
87
  import { createPullPacer, type PullPacer } from './pull-pacer.ts';
85
88
  import { activeCanvasWants } from './pull-priority.ts';
86
89
  import { failureReason, isBackpressure, refusalWords, retryAfterMs } from './retry-after.ts';
90
+ import { DELETED_HERE_HELD_REASON } from './seed-progress.ts';
87
91
  import { classifyTransportError } from './transport-error.ts';
88
92
 
89
93
  /** How long to wait for one file's bytes. Generous — these run to videos. */
@@ -375,8 +379,8 @@ function deliveryRank(state: DeliveryState): number {
375
379
  }
376
380
  }
377
381
 
378
- /** Walk depth ceiling — matches the classifier's own shape cap. */
379
- const MAX_WALK_DEPTH = 8;
382
+ /** Walk depth ceiling — the classifier's own shape cap (32 since fix/205). */
383
+ const MAX_WALK_DEPTH = MAX_SEGMENTS;
380
384
 
381
385
  /** Directories no plane path can live under. */
382
386
  const SKIPPED_DIRS = new Set(['_trash', '_history', '_untrusted', '_smoke', 'node_modules']);
@@ -581,6 +585,12 @@ export interface FilePlaneOptions {
581
585
  * true (every caller before this option, and every test hub, takes them).
582
586
  */
583
587
  hubTakesV2Files?: boolean;
588
+ /**
589
+ * fix/205 — the hub advertises `file-depth-v2` (`hasFileDepthV2`). False ⇒ a path deeper than
590
+ * 8 segments (`olderDoorRefusesDepth`) is held here with a reason and never offered. Absent ⇒
591
+ * true, like `hubTakesV2Files`.
592
+ */
593
+ hubTakesDeepPaths?: boolean;
584
594
  /**
585
595
  * Issue #204 — how fast this plane talks to the hub (concurrency + requests per minute). One per
586
596
  * plane so the adaptive width survives from pass to pass. Default: `createPullPacer()`.
@@ -2257,11 +2267,17 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2257
2267
  // answers `400 invalid path` to every 2.0-only file; asking costs a
2258
2268
  // request and tells nobody anything. Held with a reason instead — and
2259
2269
  // offered again the pass this hub advertises `file-classes-v2`.
2270
+ // fix/205 — the same for a path deeper than an older door takes (8 segments).
2271
+ const olderHubReason =
2272
+ here && remoteHash === null
2273
+ ? opts.hubTakesV2Files === false && olderDoorRefuses(rel)
2274
+ ? OLDER_HUB_REASON
2275
+ : opts.hubTakesDeepPaths === false && olderDoorRefusesDepth(rel)
2276
+ ? OLDER_HUB_DEPTH_REASON
2277
+ : null
2278
+ : null;
2260
2279
  if (
2261
- here &&
2262
- remoteHash === null &&
2263
- opts.hubTakesV2Files === false &&
2264
- olderDoorRefuses(rel) &&
2280
+ olderHubReason !== null &&
2265
2281
  isFilePlaneClass(
2266
2282
  classifyProjectFile(rel, {
2267
2283
  canvasGroups: opts.canvasGroups,
@@ -2273,17 +2289,17 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2273
2289
  !(
2274
2290
  kept?.state === 'refused' &&
2275
2291
  kept.blockedClass === 'refused' &&
2276
- kept.reason === OLDER_HUB_REASON &&
2292
+ kept.reason === olderHubReason &&
2277
2293
  kept.refusedHash === undefined
2278
2294
  )
2279
2295
  ) {
2280
2296
  ledger.setState(rel, 'refused', {
2281
- reason: OLDER_HUB_REASON,
2297
+ reason: olderHubReason,
2282
2298
  blockedClass: 'refused',
2283
2299
  refusedHash: undefined,
2284
2300
  });
2285
2301
  }
2286
- out.dropped.push({ rel, reason: OLDER_HUB_REASON });
2302
+ out.dropped.push({ rel, reason: olderHubReason });
2287
2303
  continue;
2288
2304
  }
2289
2305
 
@@ -2327,6 +2343,21 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2327
2343
  state: remoteHash !== null ? 'on-hub' : 'local-only',
2328
2344
  });
2329
2345
  out.synced += 1;
2346
+ } else if (
2347
+ !here &&
2348
+ remoteHash !== null &&
2349
+ !opts.propagateDeletes &&
2350
+ state.ancestor === remoteHash
2351
+ ) {
2352
+ // 2.0.5 rule (a) — DELETED HERE, KEPT THERE, AND SAID SO. With delete
2353
+ // sync off this is a deliberate hold (no resurrection, no delete), but
2354
+ // the row still read `on-hub` from the pass that once delivered it:
2355
+ // the field ledger claimed 7 614 of 7 617 delivered while 1 814 of
2356
+ // those files were not on the disk. Held with a reason instead; a
2357
+ // copy that comes back with the same bytes is agreement again.
2358
+ if (!(kept?.state === 'stuck' && kept.reason === DELETED_HERE_HELD_REASON)) {
2359
+ ledger.setState(rel, 'stuck', { reason: DELETED_HERE_HELD_REASON });
2360
+ }
2330
2361
  }
2331
2362
  continue;
2332
2363
  }