@1agh/maude 2.0.4 → 2.0.8

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 (272) hide show
  1. package/apps/hub/src/project-transactions/kernel.mjs +10 -1
  2. package/apps/studio/access/closure.ts +156 -16
  3. package/apps/studio/access/filters.ts +39 -5
  4. package/apps/studio/access/known-canvases.ts +24 -1
  5. package/apps/studio/access/refused-inputs.ts +89 -0
  6. package/apps/studio/actions/agents.ts +59 -0
  7. package/apps/studio/actions/ctx.ts +3 -0
  8. package/apps/studio/actions/defs/app.ts +12 -0
  9. package/apps/studio/actions/defs/sync.ts +13 -0
  10. package/apps/studio/actions/defs/view.ts +59 -3
  11. package/apps/studio/actions/keymap.gen.ts +35 -0
  12. package/apps/studio/actions/menu.ts +2 -0
  13. package/apps/studio/actions/types.ts +3 -1
  14. package/apps/studio/actions.manifest.json +148 -1
  15. package/apps/studio/actions.parity.json +31 -1
  16. package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
  17. package/apps/studio/annotations/ui/element-node.tsx +139 -54
  18. package/apps/studio/annotations/ui/lod.tsx +1 -1
  19. package/apps/studio/annotations/ui/ride.ts +2 -1
  20. package/apps/studio/annotations/ui/text-style.ts +1 -1
  21. package/apps/studio/annotations-context-toolbar.tsx +5 -4
  22. package/apps/studio/annotations-layer.tsx +4 -15
  23. package/apps/studio/api.ts +425 -128
  24. package/apps/studio/artboard-activity-overlay.tsx +4 -4
  25. package/apps/studio/artboard-ai-copies.tsx +4 -4
  26. package/apps/studio/artboard-freeze.ts +108 -0
  27. package/apps/studio/artboard-live-gate.tsx +636 -0
  28. package/apps/studio/artboard-live.ts +831 -0
  29. package/apps/studio/artboard-placeholder.ts +197 -0
  30. package/apps/studio/artboard-still-raster.ts +485 -0
  31. package/apps/studio/artboard-still-warmup.ts +221 -0
  32. package/apps/studio/artboard-still.ts +1188 -0
  33. package/apps/studio/artboard-webgl.ts +669 -0
  34. package/apps/studio/asset-placeholder.tsx +237 -132
  35. package/apps/studio/asset-upload-bars.tsx +4 -4
  36. package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
  37. package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
  38. package/apps/studio/bin/_canvas-reasons.mjs +34 -0
  39. package/apps/studio/bin/_ds-check-live.mjs +37 -0
  40. package/apps/studio/bin/_ds-check.mjs +4 -1
  41. package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
  42. package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
  43. package/apps/studio/bin/_import-asset.mjs +2 -1
  44. package/apps/studio/bin/_perf-probe-open.mjs +364 -0
  45. package/apps/studio/bin/_perf-probe.mjs +2 -1
  46. package/apps/studio/bin/_perf-shared.mjs +12 -7
  47. package/apps/studio/bin/_pw-launch.mjs +26 -1
  48. package/apps/studio/bin/_studio-verb.mjs +24 -3
  49. package/apps/studio/bin/_thumb-blank.mjs +70 -0
  50. package/apps/studio/bin/_thumb-cover.mjs +35 -0
  51. package/apps/studio/bin/_thumbs-playwright.mjs +89 -12
  52. package/apps/studio/bin/ds-check.sh +5 -1
  53. package/apps/studio/bin/perf.sh +30 -1
  54. package/apps/studio/bin/server-up.sh +7 -2
  55. package/apps/studio/bin/smoke.sh +19 -0
  56. package/apps/studio/bridge/dgn-protocol.ts +35 -0
  57. package/apps/studio/canvas-build-sandbox.ts +69 -13
  58. package/apps/studio/canvas-camera.ts +90 -0
  59. package/apps/studio/canvas-comment-mount.tsx +9 -9
  60. package/apps/studio/canvas-lib.tsx +289 -44
  61. package/apps/studio/canvas-pages-view.tsx +465 -0
  62. package/apps/studio/canvas-pages.ts +305 -0
  63. package/apps/studio/canvas-rows.ts +62 -0
  64. package/apps/studio/canvas-shell.tsx +62 -16
  65. package/apps/studio/canvas-theme-icons.tsx +41 -0
  66. package/apps/studio/canvas-theme-pill.tsx +15 -6
  67. package/apps/studio/canvas-theme.ts +12 -11
  68. package/apps/studio/client/app.jsx +7 -0
  69. package/apps/studio/client/canvas-url.js +36 -1
  70. package/apps/studio/client/home/HomeAccounts.jsx +262 -0
  71. package/apps/studio/client/home/Shelves.jsx +4 -3
  72. package/apps/studio/client/home/home-accounts-model.js +121 -0
  73. package/apps/studio/client/home/home-api.js +6 -0
  74. package/apps/studio/client/home/home-app.jsx +141 -40
  75. package/apps/studio/client/home/home-model.js +172 -6
  76. package/apps/studio/client/home/home.css +169 -5
  77. package/apps/studio/client/home/shell-mode.js +8 -1
  78. package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
  79. package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
  80. package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
  81. package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
  82. package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
  83. package/apps/studio/client/hooks/use-project-data.jsx +13 -2
  84. package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
  85. package/apps/studio/client/index-loader.ts +41 -21
  86. package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
  87. package/apps/studio/client/panels/ChatPanel.jsx +27 -20
  88. package/apps/studio/client/panels/CreateProject.jsx +19 -5
  89. package/apps/studio/client/panels/caps-cache.js +46 -0
  90. package/apps/studio/client/shell/viewport.jsx +66 -22
  91. package/apps/studio/client/tree/tree.jsx +17 -0
  92. package/apps/studio/client/v2/access/access-client.js +2 -0
  93. package/apps/studio/client/v2/access/access-host.jsx +12 -1
  94. package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
  95. package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
  96. package/apps/studio/client/v2/ai/Composer.jsx +27 -10
  97. package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
  98. package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
  99. package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
  100. package/apps/studio/client/v2/code/canvas-imports-card.jsx +19 -14
  101. package/apps/studio/client/v2/code/canvas-imports-words.js +60 -0
  102. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
  103. package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
  104. package/apps/studio/client/v2/code/code-bus.js +5 -0
  105. package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
  106. package/apps/studio/client/v2/code/code-consent.js +67 -0
  107. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
  108. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
  109. package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
  110. package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
  111. package/apps/studio/client/v2/ds/library-host.jsx +45 -45
  112. package/apps/studio/client/v2/ds/make-host.jsx +13 -15
  113. package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
  114. package/apps/studio/client/v2/ds/review-host.jsx +7 -1
  115. package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
  116. package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
  117. package/apps/studio/client/v2/history/branch-actions.js +13 -9
  118. package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
  119. package/apps/studio/client/v2/history/git-model.js +3 -1
  120. package/apps/studio/client/v2/history/git-parts.jsx +16 -1
  121. package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
  122. package/apps/studio/client/v2/layers/layers-request.js +49 -0
  123. package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
  124. package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
  125. package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
  126. package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
  127. package/apps/studio/client/v2/presence/faces.jsx +42 -14
  128. package/apps/studio/client/v2/shell/account-card.jsx +10 -4
  129. package/apps/studio/client/v2/shell/canvas-crash-guard.js +172 -0
  130. package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
  131. package/apps/studio/client/v2/shell/floating-panels.css +37 -1
  132. package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
  133. package/apps/studio/client/v2/shell/menu-runner.js +11 -0
  134. package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
  135. package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
  136. package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
  137. package/apps/studio/client/v2/shell/pages-pick.js +49 -0
  138. package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
  139. package/apps/studio/client/v2/shell/project-account-model.js +182 -0
  140. package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
  141. package/apps/studio/client/v2/shell/share-cluster-host.jsx +140 -11
  142. package/apps/studio/client/v2/shell/share-cluster.css +58 -0
  143. package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
  144. package/apps/studio/client/v2/shell/shell-parity.json +8 -0
  145. package/apps/studio/client/v2/shell/team-switch.js +94 -0
  146. package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
  147. package/apps/studio/client/v2/shell/use-account.js +8 -1
  148. package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
  149. package/apps/studio/collab/persistence.ts +9 -1
  150. package/apps/studio/collab/registry.ts +32 -0
  151. package/apps/studio/collab/room.ts +8 -0
  152. package/apps/studio/comments-overlay.tsx +12 -11
  153. package/apps/studio/config-reload-wire.ts +56 -0
  154. package/apps/studio/config.schema.json +6 -0
  155. package/apps/studio/context.ts +37 -1
  156. package/apps/studio/dist/client.bundle.js +1198 -1198
  157. package/apps/studio/dist/comment-mount.js +2 -2
  158. package/apps/studio/dist/styles.css +1 -1
  159. package/apps/studio/ds/board/board.css +6 -0
  160. package/apps/studio/ds/board/ds-bar.tsx +21 -3
  161. package/apps/studio/ds/board/specimen.tsx +16 -2
  162. package/apps/studio/ds/board/template.ts +39 -19
  163. package/apps/studio/ds/canvas-cli.ts +58 -2
  164. package/apps/studio/ds/check.ts +26 -1
  165. package/apps/studio/ds/cli.ts +14 -4
  166. package/apps/studio/ds/component-list.ts +2 -1
  167. package/apps/studio/ds/convert.ts +34 -6
  168. package/apps/studio/ds/default.ts +6 -1
  169. package/apps/studio/ds/ds-resolver.ts +58 -8
  170. package/apps/studio/ds/ds-verb.ts +13 -0
  171. package/apps/studio/ds/engine.ts +3 -1
  172. package/apps/studio/ds/folder-systems.ts +199 -0
  173. package/apps/studio/ds/pairing-css.ts +2 -1
  174. package/apps/studio/ds/post-build.ts +38 -0
  175. package/apps/studio/ds/rename.ts +10 -3
  176. package/apps/studio/ds/shell-fallbacks.ts +2 -1
  177. package/apps/studio/ds/upgrade-apply.ts +27 -5
  178. package/apps/studio/ds/upgrade-cli.ts +22 -2
  179. package/apps/studio/ds/upgrade-prove.ts +198 -15
  180. package/apps/studio/ds/upgrade-stage.ts +10 -3
  181. package/apps/studio/editing/ai-point-ring.tsx +4 -4
  182. package/apps/studio/editing/ai-scope-outline.tsx +4 -4
  183. package/apps/studio/editing/align-bar.tsx +4 -4
  184. package/apps/studio/editing/anchor-report.ts +3 -2
  185. package/apps/studio/editing/artboard-handles.tsx +4 -4
  186. package/apps/studio/editing/corner-dots.tsx +4 -4
  187. package/apps/studio/editing/crop-mode.tsx +4 -4
  188. package/apps/studio/editing/drop-chip.tsx +4 -4
  189. package/apps/studio/editing/empty-report.ts +3 -2
  190. package/apps/studio/editing/focus-model.tsx +4 -4
  191. package/apps/studio/editing/gap-bands.tsx +3 -3
  192. package/apps/studio/editing/hold-rings.tsx +4 -4
  193. package/apps/studio/editing/lock-badge.tsx +3 -3
  194. package/apps/studio/editing/long-page.ts +23 -1
  195. package/apps/studio/editing/nudge.tsx +2 -2
  196. package/apps/studio/editing/page-activity.ts +4 -3
  197. package/apps/studio/editing/paste-bar.tsx +4 -4
  198. package/apps/studio/editing/pen/overlay.tsx +4 -3
  199. package/apps/studio/editing/place-freely.tsx +3 -3
  200. package/apps/studio/editing/reorder-slot.tsx +3 -3
  201. package/apps/studio/editing/selection.tsx +4 -4
  202. package/apps/studio/editing/size-ghost.tsx +4 -4
  203. package/apps/studio/editing/tab-order.tsx +4 -4
  204. package/apps/studio/editing/text-in-place.tsx +4 -4
  205. package/apps/studio/editing/undo-preview.tsx +3 -3
  206. package/apps/studio/equal-spacing-handles.tsx +3 -3
  207. package/apps/studio/frame-clock.ts +89 -0
  208. package/apps/studio/history/trash.ts +6 -0
  209. package/apps/studio/home/accounts.ts +87 -0
  210. package/apps/studio/home/index-reader.ts +24 -2
  211. package/apps/studio/home/routes.ts +19 -0
  212. package/apps/studio/http.ts +80 -34
  213. package/apps/studio/index/ds-usage.ts +4 -1
  214. package/apps/studio/index-cache.ts +272 -0
  215. package/apps/studio/inspect-overlay.tsx +4 -3
  216. package/apps/studio/inspect.ts +7 -2
  217. package/apps/studio/link-chip-overlay.tsx +4 -3
  218. package/apps/studio/measure-overlay.tsx +4 -3
  219. package/apps/studio/present/pointer-dot.tsx +3 -2
  220. package/apps/studio/present/present-media.ts +6 -2
  221. package/apps/studio/present/present-stage.tsx +3 -2
  222. package/apps/studio/preview/preview-camera.tsx +3 -2
  223. package/apps/studio/routes/ds-convert.ts +18 -0
  224. package/apps/studio/routes/sync.ts +176 -0
  225. package/apps/studio/routes/trash.ts +16 -1
  226. package/apps/studio/safe-zones-overlay.tsx +3 -2
  227. package/apps/studio/server.ts +8 -10
  228. package/apps/studio/skip-dirs.ts +103 -47
  229. package/apps/studio/studio-page-host.ts +70 -0
  230. package/apps/studio/sync/accepted-cold-start.ts +28 -13
  231. package/apps/studio/sync/asset-push.ts +146 -23
  232. package/apps/studio/sync/asset-state.ts +3 -2
  233. package/apps/studio/sync/code-module-consent.ts +86 -0
  234. package/apps/studio/sync/file-ledger.ts +24 -0
  235. package/apps/studio/sync/file-membership.ts +28 -3
  236. package/apps/studio/sync/file-plane.ts +497 -61
  237. package/apps/studio/sync/file-pull.ts +304 -33
  238. package/apps/studio/sync/held-deletes.ts +230 -0
  239. package/apps/studio/sync/hub-link.ts +1 -2
  240. package/apps/studio/sync/hubs-config.ts +59 -2
  241. package/apps/studio/sync/index.ts +405 -163
  242. package/apps/studio/sync/journal-client.ts +94 -5
  243. package/apps/studio/sync/pending-deletes.ts +100 -0
  244. package/apps/studio/sync/projection.ts +77 -12
  245. package/apps/studio/sync/seed-progress.ts +104 -3
  246. package/apps/studio/sync/settings.ts +36 -1
  247. package/apps/studio/sync/status.ts +17 -1
  248. package/apps/studio/sync/writer-registry.ts +5 -0
  249. package/apps/studio/text-caret.ts +5 -3
  250. package/apps/studio/thumbs/service.ts +12 -2
  251. package/apps/studio/thumbs/validate.ts +7 -0
  252. package/apps/studio/toolbars/toolbar-rect.ts +3 -2
  253. package/apps/studio/ui-prefs-migrate.ts +4 -0
  254. package/apps/studio/use-annotation-resize.tsx +4 -3
  255. package/apps/studio/use-artboard-drag.tsx +3 -2
  256. package/apps/studio/use-element-resize.tsx +7 -6
  257. package/apps/studio/use-grid-track-handles.tsx +5 -4
  258. package/apps/studio/use-selection-set.tsx +64 -4
  259. package/apps/studio/use-spacing-handles.tsx +7 -6
  260. package/apps/studio/video-comp.tsx +75 -39
  261. package/apps/studio/video-play-overlay.tsx +4 -3
  262. package/apps/studio/whats-new.json +99 -0
  263. package/cli/commands/design.mjs +5 -2
  264. package/cli/commands/hub.mjs +10 -1
  265. package/cli/lib/bash-guard.mjs +27 -1
  266. package/cli/lib/design-help.gen.mjs +1 -1
  267. package/cli/lib/design-hook.mjs +20 -0
  268. package/cli/lib/design-link.mjs +42 -17
  269. package/cli/lib/hub-purge.mjs +183 -0
  270. package/cli/lib/studio-locate.mjs +35 -10
  271. package/package.json +8 -8
  272. package/plugins/design/templates/_shell.html +164 -1
@@ -67,7 +67,7 @@ import {
67
67
  resolveCanvasBodyRel,
68
68
  } from './canvas-path.ts';
69
69
  import { type CellPairing, resolveCellPairing, sanitizeForLog } from './cell-pairing.ts';
70
- import { codeModuleConsent } from './code-module-consent.ts';
70
+ import { type CodeConsentControl, createCodeConsentControl } from './code-module-consent.ts';
71
71
  import {
72
72
  canvasPathFromDoc,
73
73
  clearMovedTo,
@@ -90,8 +90,18 @@ import { createDocNameResolver } from './doc-name.ts';
90
90
  import { createDocumentDiscovery } from './document-discovery.ts';
91
91
  import { createEchoGuard, hashBytes } from './echo-guard.ts';
92
92
  import { createFileLedger } from './file-ledger.ts';
93
- import { createFilePlane, MAX_DORUCEKA_ROWS } from './file-plane.ts';
94
- import { type FilePullResult, pullFiles } from './file-pull.ts';
93
+ import {
94
+ createFilePlane,
95
+ DELETE_BUDGET_WINDOW_MS,
96
+ MAX_DORUCEKA_ROWS,
97
+ normalizeIgnoreFolders,
98
+ } from './file-plane.ts';
99
+ import {
100
+ createLegacyPullGate,
101
+ createPullFailureMemory,
102
+ type FilePullResult,
103
+ pullFiles,
104
+ } from './file-pull.ts';
95
105
  import {
96
106
  declaredFormat,
97
107
  formatFromHub,
@@ -102,12 +112,19 @@ import {
102
112
  withFormatParam,
103
113
  } from './format-sync.ts';
104
114
  import { createFsReader, type FsReader } from './fs-mirror.ts';
115
+ import { createHeldDeletes, type HeldDeletesControl, heldDeleteDetail } from './held-deletes.ts';
105
116
  import { canvasLanes, namedField, type RowNamed } from './history-fields.ts';
106
117
  import { type HubDocRow, hubHolds, indexHubDocs } from './hub-listing.ts';
107
118
  import { HUB_UNDO_READ_MAX_BYTES, hubTextUndoConflict } from './hub-text-undo.ts';
108
- import { accessFor, getHubRecord } from './hubs-config.ts';
119
+ import { accessFor, getHubRecord, watchHubsConfig } from './hubs-config.ts';
109
120
  import { loadJournal, type SyncJournal } from './journal.ts';
110
- import { hasAnnotationsV2, hasFileClassesV2, hasLedger, hubHealth } from './journal-client.ts';
121
+ import {
122
+ hasAnnotationsV2,
123
+ hasFileClassesV2,
124
+ hasFileDepthV2,
125
+ hasLedger,
126
+ probeFileLane,
127
+ } from './journal-client.ts';
111
128
  import type { RestoreOptions } from './local-kernel.ts';
112
129
  import { isLoopbackHost } from './loopback.ts';
113
130
  import { createMediaGate, MEDIA_STAYS_LINE, readServerSignature } from './media-gate.ts';
@@ -126,6 +143,7 @@ import {
126
143
  parkReducer,
127
144
  parseCellState,
128
145
  } from './park.ts';
146
+ import { takePendingDeletes } from './pending-deletes.ts';
129
147
  import { hasSelfRetryingWork } from './presentation.ts';
130
148
  import { createProjectConfigPusher } from './project-config-push.ts';
131
149
  import { createDocProjection, type DocProjection } from './projection.ts';
@@ -143,7 +161,13 @@ import {
143
161
  tombstonedSlugs,
144
162
  } from './remote-docs.ts';
145
163
  import { createRevisionBarrier } from './revision-barrier.ts';
146
- import { computeSeedProgress } from './seed-progress.ts';
164
+ import {
165
+ codeConsentHeldDetail,
166
+ codeConsentHeldPaths,
167
+ computeSeedProgress,
168
+ heldWords,
169
+ } from './seed-progress.ts';
170
+ import { livePropagateDeletes, readSyncSettings } from './settings.ts';
147
171
  import { mergeSource } from './source-merge.ts';
148
172
  import { replaySourceOp, type SourceOp } from './source-ops.ts';
149
173
  import { createSyncStatusStore, type FilePlaneStatus, type SyncStatusStore } from './status.ts';
@@ -320,6 +344,9 @@ export const DISCOVERY_DEBOUNCE_MS = 400;
320
344
  */
321
345
  export const REMOTE_POLL_MS = 20_000;
322
346
 
347
+ /** 2.0.5 — how soon an unanswered lane probe asks the hub again. */
348
+ const LANE_REPROBE_MS = 60_000;
349
+
323
350
  /**
324
351
  * Does this studio run the FILE plane (Plane B) against its linked hub?
325
352
  *
@@ -510,6 +537,11 @@ export interface AwarenessRegistry {
510
537
  pin?(slug: string): void;
511
538
  /** Release the shared-doc pin on runtime stop. */
512
539
  unpin?(slug: string): void;
540
+ /**
541
+ * fix/205 — throw away an unpinned room with no browser in it (no flush); with
542
+ * `forgetCache` its persisted cache too. See `collab/registry.ts` `discard`.
543
+ */
544
+ discard?(slug: string, opts?: { forgetCache?: boolean }): Promise<boolean>;
513
545
  }
514
546
 
515
547
  /** Factory the runtime calls per discovered canvas. Default uses Hocuspocus. */
@@ -566,6 +598,10 @@ export interface SyncRuntime {
566
598
  * schedule. Test seam, and the hook behind a manual "check now".
567
599
  */
568
600
  pullRemoteNow(): Promise<void>;
601
+ /** fix/207 — this runtime's live shared-code consent (the in-app sheet's control). */
602
+ codeConsent?(): CodeConsentControl | null;
603
+ /** Issue #207 (7b) — the held local deletes and the person's answer (Sync details). */
604
+ heldDeletes?(): HeldDeletesControl | null;
569
605
  /** Number of active per-canvas agents. */
570
606
  size(): number;
571
607
  /** Test inspection — get the agent for a slug if one was created. */
@@ -1087,6 +1123,12 @@ export function createSyncRuntime(
1087
1123
  : ctx.cfg.linkedHub;
1088
1124
  if (!linked) return null;
1089
1125
  const linkedHub = linked;
1126
+ /**
1127
+ * Issue #207 — folders this project does not sync, read from the project config per pass (a
1128
+ * choice made mid-upload applies at the next pass; cleaned, so a committed `..` entry is dropped).
1129
+ */
1130
+ const planeIgnoreFolders = (): string[] =>
1131
+ normalizeIgnoreFolders(readSyncSettings(ctx.paths.repoRoot)?.ignoreFolders);
1090
1132
  // p8-hub-folder-boundary — a hub's own studio, while the owner has declared no
1091
1133
  // canvas folders, takes and scans every folder the hub's kernel takes. Read per
1092
1134
  // call: the owner may declare groups mid-session (the project-config door), and
@@ -1270,13 +1312,17 @@ export function createSyncRuntime(
1270
1312
  // (2.0.4) the Maude Cloud cell the desktop app itself bound this copy to
1271
1313
  // (`MAUDE_APP_BOUND_HUB` + the compiled-in cell zone; never a committed
1272
1314
  // linkedHub, never a self-hosted hub). See sync/code-module-consent.ts.
1273
- const allowCodeModules =
1274
- codeModuleConsent({
1275
- cellPairing: cellPairing !== null,
1276
- hubUrl: linkedHub.url,
1277
- storedRecord,
1278
- env: process.env,
1279
- }) !== null;
1315
+ //
1316
+ // fix/207 — LIVE, not fixed at boot: the person can answer in the app (Sync details / the
1317
+ // canvas-waiting card → `POST /_api/sync/code-consent/set`) or re-link in a terminal, and the
1318
+ // next pass admits what was held (the file plane reads `allowCodeModules()` at every gate).
1319
+ // The control re-reads the profile's hubs.json through `getHubRecord` — the same local record.
1320
+ const codeConsent = createCodeConsentControl({
1321
+ cellPairing: cellPairing !== null,
1322
+ hubUrl: linkedHub.url,
1323
+ env: process.env,
1324
+ });
1325
+ const allowCodeModules = (): boolean => codeConsent.allowed();
1280
1326
  // Same shape of consent for the OUTBOUND delete breaker: only what this
1281
1327
  // machine's owner recorded (`maude design bulk-deletes on`), never the hub.
1282
1328
  const unlimitedDeletes = storedRecord?.unlimitedDeletes === true;
@@ -1354,6 +1400,8 @@ export function createSyncRuntime(
1354
1400
  // two-doc agent path has no proposal lane and stays legacy.
1355
1401
  /** Resolves once a previous run's outbox is drained: doc → own accepted html. */
1356
1402
  let outboxDrained: Promise<Map<string, string>> = Promise.resolve(new Map());
1403
+ /** #14 — the same drain's css: doc → own accepted css (filled by the time it resolves). */
1404
+ const drainedCss = new Map<string, string>();
1357
1405
  /** S6.13 — documents whose `doc.create` that drain had accepted: made BY
1358
1406
  * THIS MAC in a previous run, so they join as a create, not a reconcile. */
1359
1407
  const drainedCreates = new Set<string>();
@@ -1593,6 +1641,8 @@ export function createSyncRuntime(
1593
1641
  * `true` = journal-less hub ⇒ this legacy client carries the upward lane.
1594
1642
  */
1595
1643
  let legacyLane: boolean | null = null;
1644
+ /** fix/205 — the hub advertised `file-depth-v2` (set with the lane verdict). */
1645
+ let legacyHubTakesDeepPaths = false;
1596
1646
  /** A pass was owed before the lane was decided — run it on the verdict. */
1597
1647
  let legacyBootPush: string | null = null;
1598
1648
  /**
@@ -1627,6 +1677,7 @@ export function createSyncRuntime(
1627
1677
  // Read at call time — silent renewal swaps the credential in place.
1628
1678
  token: () => token,
1629
1679
  canvasGroups: ctx.cfg.canvasGroups,
1680
+ hubTakesDeepPaths: legacyHubTakesDeepPaths,
1630
1681
  cancelled: () => legacyPushCancel || stopped,
1631
1682
  // feature-sync-progress-modal — same `sync:status` payload as ever, so
1632
1683
  // the Sync panel needs no idea which lane fed it. Guarded on `stopped`:
@@ -1894,6 +1945,8 @@ export function createSyncRuntime(
1894
1945
  * suite long before it shows up as a bug.
1895
1946
  */
1896
1947
  let fileEventsProbe: AbortController | null = null;
1948
+ /** 2.0.5 — the hub did not answer the lane probe: ask again, never fall back. */
1949
+ let laneProbeTimer: ReturnType<typeof setTimeout> | null = null;
1897
1950
  /**
1898
1951
  * The Sync v2 file plane — ONE lane, both directions, one decision table.
1899
1952
  *
@@ -1910,6 +1963,8 @@ export function createSyncRuntime(
1910
1963
  * Built with the plane; never in a cell (a cell IS the hub).
1911
1964
  */
1912
1965
  let heldReporter: ReturnType<typeof createHeldReporter> | null = null;
1966
+ /** Issue #207 (7b) — Delete on the hub too / Keep on the hub, for the held local deletes. */
1967
+ let heldDeletesControl: HeldDeletesControl | null = null;
1913
1968
  /** Cumulative files sent up this boot — the doručenka's push half. */
1914
1969
  let filePushed = 0;
1915
1970
  /** Debounce for a plane pass triggered by a local write. */
@@ -1923,6 +1978,7 @@ export function createSyncRuntime(
1923
1978
  let pokesSeen = 0;
1924
1979
  /** Assigned by `start()`; the seam `pullRemoteNow()` and tests reach. */
1925
1980
  let remotePull: (() => Promise<void>) | null = null;
1981
+ let codeConsentUnwatch: (() => void) | null = null;
1926
1982
  let documentDiscovery: ReturnType<typeof createDocumentDiscovery> | null = null;
1927
1983
  let documentDiscoveryUnsub: (() => void) | null = null;
1928
1984
  /**
@@ -2312,7 +2368,7 @@ export function createSyncRuntime(
2312
2368
  const desc = descriptors.get(slug);
2313
2369
  const provider = providers.get(slug);
2314
2370
  const movedTo = provider ? movedToFromDoc(provider.document) : null;
2315
- await releaseOne(slug);
2371
+ await releaseOne(slug, { gone: true });
2316
2372
  if (!desc) return;
2317
2373
  // HOLD until the canvas provably lives at its new path — parking the old
2318
2374
  // copy while the new document is still materialising would leave a window
@@ -2396,7 +2452,17 @@ export function createSyncRuntime(
2396
2452
  noteDetach(statusDetaches, slug, () => doc.off('update', onUpdate));
2397
2453
  }
2398
2454
 
2399
- async function releaseOne(slug: string): Promise<boolean> {
2455
+ /**
2456
+ * `gone` — the canvas LEFT the project (deleted here or in the project, moved
2457
+ * away on another machine), as opposed to being let go of while it still
2458
+ * lives (a `syncable: false` sidecar, a refused pull, a local move). A gone
2459
+ * canvas's collab room is discarded with its cache (fix/205): its Y.Doc is
2460
+ * the deleted lineage, and the hub has dropped its own copy, so a canvas
2461
+ * re-created at the same slug that re-attached to it merged the hub's new
2462
+ * body onto the old one — the body doubled and receivers refused it as
2463
+ * invalid source.
2464
+ */
2465
+ async function releaseOne(slug: string, how: { gone?: boolean } = {}): Promise<boolean> {
2400
2466
  const known = agents.has(slug) || projections.has(slug) || providers.has(slug);
2401
2467
  if (!known) return false;
2402
2468
  runDetaches(awarenessDetaches, slug);
@@ -2437,6 +2503,13 @@ export function createSyncRuntime(
2437
2503
  /* best-effort */
2438
2504
  }
2439
2505
  }
2506
+ if (how.gone) {
2507
+ try {
2508
+ await opts.registry?.discard?.(slug, { forgetCache: true });
2509
+ } catch {
2510
+ /* best-effort — attachCanvas discards a leftover room too */
2511
+ }
2512
+ }
2440
2513
  descriptors.delete(slug);
2441
2514
  // Drop the row too — a released canvas that stayed `pending` in the status
2442
2515
  // payload would be a permanent "still syncing" the user can never clear.
@@ -2903,6 +2976,17 @@ export function createSyncRuntime(
2903
2976
  : o.op === 'doc.create'
2904
2977
  ? (o.lanes as Record<string, unknown> | undefined)?.html
2905
2978
  : undefined;
2979
+ // #14 — the css twin's save is judged the same way (see accepted-cold-start.ts)
2980
+ const css =
2981
+ o.op === 'lane.replace' && o.lane === 'css'
2982
+ ? o.content
2983
+ : o.op === 'doc.create'
2984
+ ? (o.lanes as Record<string, unknown> | undefined)?.css
2985
+ : undefined;
2986
+ if (typeof o.doc === 'string' && typeof css === 'string') {
2987
+ if (result.status === 'accepted') drainedCss.set(o.doc, css);
2988
+ else drainedCss.delete(o.doc);
2989
+ }
2906
2990
  if (typeof o.doc !== 'string' || typeof html !== 'string') continue;
2907
2991
  if (result.status === 'accepted') own.set(o.doc, html);
2908
2992
  else own.delete(o.doc);
@@ -2931,6 +3015,11 @@ export function createSyncRuntime(
2931
3015
  const slug = slugFromDocName(stone.name);
2932
3016
  if (slug) tombstoned.add(slug);
2933
3017
  }
3018
+ // #7 — a deletion made while no studio ran (an in-process `ds convert --restore`) is a
3019
+ // deletion too: the boot pull must not fetch it back; it is told below, once the outbound
3020
+ // lane is up (sync/pending-deletes.ts).
3021
+ const offlineDeletes = takePendingDeletes(ctx.paths.designRoot);
3022
+ for (const d of offlineDeletes) tombstoned.add(d.slug);
2934
3023
  noteHubListing(remoteListing?.documents ?? null);
2935
3024
  const remoteDiff = diffRemoteDocs(
2936
3025
  localCanvases.map((c) => docNameFor(c.slug)),
@@ -3917,6 +4006,8 @@ export function createSyncRuntime(
3917
4006
  // previous run left (S6.13) has made it a member by now.
3918
4007
  const drained = await outboxDrained;
3919
4008
  const ownAccepted = drained.get(docName) ?? null;
4009
+ const ownAcceptedCss = drainedCss.get(docName) ?? null;
4010
+ drainedCss.delete(docName);
3920
4011
  // S6.13b — a canvas this Mac renamed because its name was taken joins
3921
4012
  // as that renamed create did.
3922
4013
  const renamed = renamedCreates.get(docName);
@@ -3954,6 +4045,7 @@ export function createSyncRuntime(
3954
4045
  journal: journal ?? undefined,
3955
4046
  commentLedger: commentLedgerFor(ctx.paths.designRoot),
3956
4047
  ownAccepted,
4048
+ ownAcceptedCss,
3957
4049
  wasAccepted: (content) => acceptedLink.client.holdsValue(content),
3958
4050
  createDoc:
3959
4051
  createdHere !== null
@@ -4507,6 +4599,10 @@ export function createSyncRuntime(
4507
4599
  // provider. NB: cold-start seeding of a divergent local+hub doc is the
4508
4600
  // duplication trap (Risk 1) — made safe by Phase E (migrate-seed); the
4509
4601
  // flag stays OFF until then.
4602
+ // fix/205 — a room left over from an earlier attach of this slug (no
4603
+ // provider pins it, no browser is in it) holds that earlier doc's
4604
+ // lineage. Never re-attach to it: start from a fresh doc, as at boot.
4605
+ if (useSharedDoc) await opts.registry?.discard?.(canvas.slug);
4510
4606
  const sharedYDoc = useSharedDoc ? opts.registry?.getDoc?.(canvas.slug) : undefined;
4511
4607
  if (useSharedDoc && sharedYDoc) {
4512
4608
  opts.registry?.pin?.(canvas.slug);
@@ -4910,7 +5006,12 @@ export function createSyncRuntime(
4910
5006
  );
4911
5007
  if (added.length === 0 && removed.length === 0) return;
4912
5008
  if (removed.length > 0) {
4913
- for (const slug of removed) await releaseOne(slug);
5009
+ for (const slug of removed) {
5010
+ // Gone from this disk is gone from here; a body still on disk
5011
+ // (a `syncable: false` sidecar) keeps its room.
5012
+ const body = descriptors.get(slug)?.html;
5013
+ await releaseOne(slug, { gone: !body || !existsSync(body) });
5014
+ }
4914
5015
  console.log(`[sync] released ${removed.length} canvas(es): ${removed.join(', ')}`);
4915
5016
  // The marker set shrank. It describes what a peer can WRITE to, so a
4916
5017
  // stale entry over-lists — the safe direction, and still wrong: it is
@@ -5001,6 +5102,11 @@ export function createSyncRuntime(
5001
5102
  createdUnsub = ctx.bus.on('canvas-created', (p: { slug?: unknown }) =>
5002
5103
  noteToHub(p?.slug, true)
5003
5104
  );
5105
+ // #7 — the deletions written down while no studio ran, told the way the routes tell them.
5106
+ for (const d of offlineDeletes) {
5107
+ console.log(`[sync] telling the project ${d.rel} was deleted while Maude was closed.`);
5108
+ ctx.bus.emit('canvas-deleted', { slug: d.slug });
5109
+ }
5004
5110
 
5005
5111
  /**
5006
5112
  * Apply the project's deletions to this machine.
@@ -5027,7 +5133,7 @@ export function createSyncRuntime(
5027
5133
  if (gone.length === 0) return;
5028
5134
  for (const slug of gone) {
5029
5135
  const canvas = descriptors.get(slug);
5030
- await releaseOne(slug);
5136
+ await releaseOne(slug, { gone: true });
5031
5137
  if (canvas) {
5032
5138
  quarantineCanvas({
5033
5139
  designRoot: ctx.paths.designRoot,
@@ -5237,7 +5343,9 @@ export function createSyncRuntime(
5237
5343
  // Issue #204 — rows this Mac refuses are HELD, not waiting: they never move on their own, so
5238
5344
  // the line says how many and why instead of "N waiting" every 20 s forever.
5239
5345
  const held = p.held ?? 0;
5240
- if (held > 0) bits.push(`${held} held: shared code not accepted on this Mac`);
5346
+ // fix/207 — one phrase per reason: a PNG deleted here is never "shared code" (Michal's
5347
+ // 6 942 "held: shared code not accepted" were mostly render PNGs moved out of the project).
5348
+ if (held > 0) bits.push(...heldWords(p));
5241
5349
  if (r.backedOff) bits.push(`${r.backedOff} backing off`);
5242
5350
  if (r.storageMisses) bits.push(`${r.storageMisses} still coming from cloud storage`);
5243
5351
  // NOTHING MOVING ⇒ SAY IT ONCE. A converged or only-held/blocked project prints its line when
@@ -5299,14 +5407,37 @@ export function createSyncRuntime(
5299
5407
  }
5300
5408
  return bytes > 0 ? { bytes, ms } : null;
5301
5409
  };
5410
+ const legacyPullGate = createLegacyPullGate({ baseMs: REMOTE_POLL_MS });
5411
+ const legacyPullFailures = createPullFailureMemory();
5302
5412
  const noteFilePull = (result: FilePullResult): void => {
5303
5413
  fileTotals.synced = result.skipped + result.pulled.length;
5304
5414
  fileTotals.pulled += result.pulled.length;
5305
5415
  fileTotals.conflicts += result.conflicts.length;
5416
+ // 2.0.5 — a file that could not land is HELD, and the panel says which and
5417
+ // why, like any other held file (it used to be a log line, every pass).
5418
+ const waiting = [
5419
+ ...(result.held ?? []),
5420
+ ...result.failed.filter((f) => !/budget/.test(f.reason)),
5421
+ ];
5422
+ const held: NonNullable<FilePlaneStatus['held']> =
5423
+ waiting.length > 0
5424
+ ? [
5425
+ {
5426
+ kind: 'pull-failed',
5427
+ count: waiting.length,
5428
+ paths: waiting.map((w) => w.rel).slice(0, 200),
5429
+ detail: `${waiting.length} file(s) from the project could not be saved on this Mac (${
5430
+ waiting[0]?.reason ?? 'unknown reason'
5431
+ }). Sync tries them again later, less often; nothing else waits for them.`,
5432
+ },
5433
+ ]
5434
+ : [];
5306
5435
  // A journal-less hub's pass is the whole comparison there: say so, once the lane is decided.
5307
5436
  statusStore?.updateFiles?.({
5308
5437
  ...fileTotals,
5309
5438
  ...(legacyLane === true ? { lane: 'v1' as const } : {}),
5439
+ ...(held.length > 0 ? { held } : {}),
5440
+ ...(result.failed.length > 0 ? { failed: result.failed.length } : {}),
5310
5441
  });
5311
5442
  };
5312
5443
  /**
@@ -5328,6 +5459,18 @@ export function createSyncRuntime(
5328
5459
  // target user never opens a terminal — so a control whose only output
5329
5460
  // is a log line is a control nobody can act on.
5330
5461
  const held = filePlaneHeld(result);
5462
+ // fix/207 — what THIS Mac holds by its own answer, with the one place to change it (Sync
5463
+ // details' "Allow shared code…"). Not while allowed: the next pass is already bringing them.
5464
+ if (!allowCodeModules()) {
5465
+ const codeHeld = codeConsentHeldPaths(fileLedger?.rows() ?? {});
5466
+ if (codeHeld.length > 0)
5467
+ held.push({
5468
+ kind: 'code-consent',
5469
+ count: codeHeld.length,
5470
+ paths: codeHeld.slice(0, 200),
5471
+ detail: codeConsentHeldDetail(codeHeld.length),
5472
+ });
5473
+ }
5331
5474
  // THE DENOMINATOR, from the LEDGER — not from this pass.
5332
5475
  //
5333
5476
  // `fileTotals` below is derived from per-pass results, and a pass that
@@ -5361,6 +5504,8 @@ export function createSyncRuntime(
5361
5504
  // Read once: calling it inside the spread evaluated it twice and made
5362
5505
  // its `null` case the object's type.
5363
5506
  const blockedMedia = filePlane?.blocked() ?? null;
5507
+ const ignoreFoldersNow = planeIgnoreFolders();
5508
+ const purgeNow = heldDeletesControl?.view().purge ?? null;
5364
5509
  statusStore?.updateFiles?.({
5365
5510
  ...fileTotals,
5366
5511
  pushed: filePushed,
@@ -5390,6 +5535,11 @@ export function createSyncRuntime(
5390
5535
  },
5391
5536
  }
5392
5537
  : {}),
5538
+ // Issue #207 — a render sequence going up, and the folders the project leaves out.
5539
+ ...(result.largeSequences ? { largeSequences: result.largeSequences } : {}),
5540
+ ...(ignoreFoldersNow.length > 0 ? { ignoreFolders: ignoreFoldersNow } : {}),
5541
+ // Issue #207 (7b) — an owner purge of held deletes in progress (or why it stopped).
5542
+ ...(purgeNow ? { deletePurge: purgeNow } : {}),
5393
5543
  });
5394
5544
  if (result.rateLimited) {
5395
5545
  // Once per boot (the store dedupes by id): a pause is not an error,
@@ -5439,14 +5589,26 @@ export function createSyncRuntime(
5439
5589
  await runPlanePass({ floor: false });
5440
5590
  return;
5441
5591
  }
5442
- const result = await pullFiles({
5443
- designRoot: ctx.paths.designRoot,
5444
- hubUrl: linkedHub.url,
5445
- token: () => token,
5446
- canvasGroups: ctx.cfg.canvasGroups,
5447
- allowCodeModules,
5448
- });
5449
- noteFilePull(result);
5592
+ // 2.0.5 — THE v1 PULL RUNS ONLY ON A HUB THAT SAID IT HAS NO JOURNAL. While
5593
+ // the lane probe is unanswered (or still in flight) no file lane runs: a
5594
+ // ledger hub that was merely slow must not get the legacy pull, which has
5595
+ // no ledger, resurrects what this person deleted, and cannot hold a file.
5596
+ if (legacyLane !== true) return;
5597
+ // One pass at a time; a pass that moved nothing backs off. Against a slow
5598
+ // hub every 20 s tick used to start ANOTHER pass over the same 200 files.
5599
+ await legacyPullGate.run(() =>
5600
+ pullFiles({
5601
+ designRoot: ctx.paths.designRoot,
5602
+ hubUrl: linkedHub.url,
5603
+ token: () => token,
5604
+ canvasGroups: ctx.cfg.canvasGroups,
5605
+ allowCodeModules: allowCodeModules(),
5606
+ failures: legacyPullFailures,
5607
+ }).then((result) => {
5608
+ if (!stopped) noteFilePull(result);
5609
+ return result;
5610
+ })
5611
+ );
5450
5612
  };
5451
5613
  documentDiscovery = createDocumentDiscovery({
5452
5614
  run: pullRemoteOnce,
@@ -5472,6 +5634,13 @@ export function createSyncRuntime(
5472
5634
  await discovery.flush();
5473
5635
  await pullFilesOnce();
5474
5636
  };
5637
+ // fix/207 — an answer written by ANOTHER writer (a terminal re-link, a second window) is taken
5638
+ // the same way as the in-app one: re-read, and a changed answer runs a pass at once.
5639
+ if (!cellPairing) {
5640
+ codeConsentUnwatch = watchHubsConfig(() => {
5641
+ if (codeConsent.refresh() && !stopped) void remotePull?.().catch(() => {});
5642
+ });
5643
+ }
5475
5644
  remotePollTimer = setInterval(pollRemote, REMOTE_POLL_MS);
5476
5645
  // `setInterval` keeps a Bun process alive; a poll is not a reason for the
5477
5646
  // dev server to refuse to exit.
@@ -5775,143 +5944,195 @@ export function createSyncRuntime(
5775
5944
  // Not started in a cell: there the CHILD holds this channel (ws.ts), and
5776
5945
  // its job is healing the UI rather than triggering pulls.
5777
5946
  if (!cellPairing && ctx.cfg.linkedHub?.fileEvents !== false) {
5778
- fileEventsProbe = new AbortController();
5779
- void hubHealth({ hubUrl: linkedHub.url, signal: fileEventsProbe.signal })
5780
- .then(({ capabilities: caps, formatVersion: hubFormat }) => {
5781
- if (stopped) return;
5782
- // V2-1.12 §5.5 — `/health` names the project's format.
5783
- noteHubFormatSeen(hubFormat);
5784
- // DDR-242 — a hub that predates the annotations-v2 model still keeps
5785
- // boards as SVG: its workspace checkout and kernel would not carry
5786
- // this studio's `.annotations.json` edits. Say so loudly; the
5787
- // annotations themselves stay safe (a v1 hub never writes the v2
5788
- // replica, and this studio never reads its SVG as authoritative).
5789
- if (caps !== null && !hasAnnotationsV2(caps)) {
5790
- console.warn(
5791
- `[sync] ${linkedHub.url} does not advertise annotations-v2 — update the hub; ` +
5792
- 'whiteboard edits will not reach its checkout until it is'
5793
- );
5794
- }
5795
- if (!hasLedger(caps)) {
5796
- // No journal on this hub ⇒ the legacy client carries the upward
5797
- // lane, exactly as the pre-v2 desktop did (Open decision 4).
5798
- decidePushLane(true);
5799
- return;
5800
- }
5801
- // The hub carries a journal, so the file plane becomes the ONE lane
5802
- // for this project. Built here rather than at start(): a client must
5803
- // never send a journal request to a hub that would not understand
5804
- // it (compat matrix §10 — BINDING).
5805
- if (syncFilesOn && !filePlane) {
5806
- fileLedger = createFileLedger({
5807
- designRoot: ctx.paths.designRoot,
5808
- hubUrl: linkedHub.url,
5809
- });
5810
- filePlane = createFilePlane({
5811
- designRoot: ctx.paths.designRoot,
5812
- hubUrl: linkedHub.url,
5813
- token: () => token,
5814
- // THE FILE PLANE CAN NOW ASK FOR A CREDENTIAL. It could not
5815
- // before: renewal was reachable only from the doc lane's
5816
- // WebSocket auth failure, so a token that expired mid-seed left
5817
- // hundreds of files refused with nothing ever asking for a new
5818
- // one (2026-09-03). Same single-flight entry point the doc lane
5819
- // uses — never a second renewal path.
5820
- onAuthFailure: () => {
5821
- void renewCredentialNow();
5822
- },
5823
- // V2-1.12 §5.4 — a 426 is the FORMAT door, never a credential
5824
- // failure: mirror what the hub named; nothing is renewed.
5825
- onFormatRefused: (fv) => noteHubFormatSeen(fv),
5826
- outboundPaused,
5827
- fetchImpl: hubFetch,
5828
- // A DELIVERED FILE IS PROGRESS. `renewalsSinceProgress` counted
5829
- // only doc handshakes, and a converged doc lane has none left to
5830
- // land — so during a long seed the cap was reached and the
5831
- // runtime stopped renewing while the file plane was still
5832
- // working.
5833
- onProgress: () => {
5834
- renewalsSinceProgress = 0;
5835
- lastFileProgressAt = Date.now();
5836
- },
5837
- // S10.3b — a delivered file is a PEER's change (the DS outside watcher's `peer`).
5838
- onDelivered: (rel) => ctx.bus.emit('file-plane:delivered', { rel }),
5839
- ledger: fileLedger,
5840
- canvasGroups: ctx.cfg.canvasGroups,
5841
- allowCodeModules,
5842
- canUploadCodeModules: cellPairing !== null || isProjectOwner,
5843
- // Issue #175 — a 1.x hub's door refuses the 2.0-only files with a 400; it is not
5844
- // offered them (they are held, with a reason, in Sync details).
5845
- hubTakesV2Files: hasFileClassesV2(caps),
5846
- unlimitedOutboundDeletes: unlimitedDeletes,
5847
- // Increment 6, DEFAULT ON: a hub-owned mirror that ignores
5848
- // deletes contradicts the model it is selling — you delete a
5849
- // file and it comes back. `linkedHub.propagateDeletes: false`
5850
- // is the per-project opt-out; the breakers hold either way.
5851
- propagateDeletes: linkedHub.propagateDeletes !== false,
5852
- // The answer to a first-anchor hold. A config key rather than a
5853
- // prompt because the hold outlives the pass that raised it, and
5854
- // DDR-177's user has no terminal to answer in.
5855
- ...(linkedHub.resolveFirstAnchor === 'keep-local' ||
5856
- linkedHub.resolveFirstAnchor === 'keep-cloud'
5857
- ? { resolveFirstAnchor: linkedHub.resolveFirstAnchor }
5858
- : {}),
5859
- // Same exposure class as `syncMeta.by`, and the same reasoning:
5860
- // a conflict copy nobody can attribute is a conflict copy nobody
5861
- // resolves.
5862
- label: hostname().slice(0, 32),
5863
- });
5864
- // S8.19 — the plane's held report (`/_asset-probe` held + sweep.final). This block
5865
- // is already `!cellPairing`; the token is read per send (silent renewal).
5866
- heldReporter = createHeldReporter({
5867
- designRoot: ctx.paths.designRoot,
5868
- canvasGroups: ctx.cfg.canvasGroups,
5869
- send: (rels) => reportHeld({ fetchImpl: hubFetch, base: linkedHub.url, token, rels }),
5870
- });
5947
+ // 2.0.5 — THE LANE IS DECIDED FROM AN ANSWER. `probeFileLane` retries with
5948
+ // a backoff and a longer ceiling; a hub that still has not answered is
5949
+ // asked again in a minute, and until then NO file lane runs (pushes and
5950
+ // the v1 pull both wait on `legacyLane`). It used to read one 4 s timeout
5951
+ // as "no journal" and run the legacy lane for the whole boot.
5952
+ let laneUnansweredSaid = false;
5953
+ const reprobeLane = (): void => {
5954
+ if (stopped) return;
5955
+ laneProbeTimer = setTimeout(probeLane, LANE_REPROBE_MS);
5956
+ laneProbeTimer.unref?.();
5957
+ };
5958
+ const probeLane = (): void => {
5959
+ laneProbeTimer = null;
5960
+ if (stopped) return;
5961
+ fileEventsProbe = new AbortController();
5962
+ void probeFileLane({ hubUrl: linkedHub.url, signal: fileEventsProbe.signal })
5963
+ .then(({ lane, capabilities: caps, formatVersion: hubFormat }) => {
5964
+ if (stopped) return;
5965
+ if (lane === 'unknown') {
5966
+ if (!laneUnansweredSaid) {
5967
+ laneUnansweredSaid = true;
5968
+ console.warn(
5969
+ `[sync/files] ${linkedHub.url} did not answer its health check — project files wait (nothing is lost) and sync asks again every ${Math.round(LANE_REPROBE_MS / 1000)} s.`
5970
+ );
5971
+ }
5972
+ reprobeLane();
5973
+ return;
5974
+ }
5975
+ // V2-1.12 §5.5 — `/health` names the project's format.
5976
+ noteHubFormatSeen(hubFormat);
5977
+ // DDR-242 — a hub that predates the annotations-v2 model still keeps
5978
+ // boards as SVG: its workspace checkout and kernel would not carry
5979
+ // this studio's `.annotations.json` edits. Say so loudly; the
5980
+ // annotations themselves stay safe (a v1 hub never writes the v2
5981
+ // replica, and this studio never reads its SVG as authoritative).
5982
+ if (caps !== null && !hasAnnotationsV2(caps)) {
5983
+ console.warn(
5984
+ `[sync] ${linkedHub.url} does not advertise annotations-v2 — update the hub; ` +
5985
+ 'whiteboard edits will not reach its checkout until it is'
5986
+ );
5987
+ }
5988
+ // fix/205 — whether this hub's doors take paths deeper than 8 segments (both lanes).
5989
+ legacyHubTakesDeepPaths = hasFileDepthV2(caps);
5990
+ if (!hasLedger(caps)) {
5991
+ // No journal on this hub ⇒ the legacy client carries the upward
5992
+ // lane, exactly as the pre-v2 desktop did (Open decision 4).
5993
+ decidePushLane(true);
5994
+ return;
5995
+ }
5996
+ // The hub carries a journal, so the file plane becomes the ONE lane
5997
+ // for this project. Built here rather than at start(): a client must
5998
+ // never send a journal request to a hub that would not understand
5999
+ // it (compat matrix §10 — BINDING).
6000
+ if (syncFilesOn && !filePlane) {
6001
+ fileLedger = createFileLedger({
6002
+ designRoot: ctx.paths.designRoot,
6003
+ hubUrl: linkedHub.url,
6004
+ });
6005
+ filePlane = createFilePlane({
6006
+ designRoot: ctx.paths.designRoot,
6007
+ hubUrl: linkedHub.url,
6008
+ token: () => token,
6009
+ // THE FILE PLANE CAN NOW ASK FOR A CREDENTIAL. It could not
6010
+ // before: renewal was reachable only from the doc lane's
6011
+ // WebSocket auth failure, so a token that expired mid-seed left
6012
+ // hundreds of files refused with nothing ever asking for a new
6013
+ // one (2026-09-03). Same single-flight entry point the doc lane
6014
+ // uses — never a second renewal path.
6015
+ onAuthFailure: () => {
6016
+ void renewCredentialNow();
6017
+ },
6018
+ // V2-1.12 §5.4 — a 426 is the FORMAT door, never a credential
6019
+ // failure: mirror what the hub named; nothing is renewed.
6020
+ onFormatRefused: (fv) => noteHubFormatSeen(fv),
6021
+ outboundPaused,
6022
+ fetchImpl: hubFetch,
6023
+ // A DELIVERED FILE IS PROGRESS. `renewalsSinceProgress` counted
6024
+ // only doc handshakes, and a converged doc lane has none left to
6025
+ // land — so during a long seed the cap was reached and the
6026
+ // runtime stopped renewing while the file plane was still
6027
+ // working.
6028
+ onProgress: () => {
6029
+ renewalsSinceProgress = 0;
6030
+ lastFileProgressAt = Date.now();
6031
+ },
6032
+ // S10.3b — a delivered file is a PEER's change (the DS outside watcher's `peer`).
6033
+ onDelivered: (rel) => ctx.bus.emit('file-plane:delivered', { rel }),
6034
+ ledger: fileLedger,
6035
+ canvasGroups: ctx.cfg.canvasGroups,
6036
+ allowCodeModules,
6037
+ canUploadCodeModules: cellPairing !== null || isProjectOwner,
6038
+ // Issue #175 — a 1.x hub's door refuses the 2.0-only files with a 400; it is not
6039
+ // offered them (they are held, with a reason, in Sync details).
6040
+ hubTakesV2Files: hasFileClassesV2(caps),
6041
+ // fix/205 — an older hub refuses paths deeper than 8 segments; held, with a reason.
6042
+ hubTakesDeepPaths: hasFileDepthV2(caps),
6043
+ unlimitedOutboundDeletes: unlimitedDeletes,
6044
+ // Increment 6, DEFAULT ON: a hub-owned mirror that ignores
6045
+ // deletes contradicts the model it is selling — you delete a
6046
+ // file and it comes back. `linkedHub.propagateDeletes: false`
6047
+ // is the per-project opt-out; the breakers hold either way.
6048
+ // Issue #207 — read every pass (like the ignore list): a change in config.json
6049
+ // applies at the next pass, not at the next restart.
6050
+ propagateDeletes: () =>
6051
+ livePropagateDeletes(ctx.paths.repoRoot, linkedHub.propagateDeletes !== false),
6052
+ // The answer to a first-anchor hold. A config key rather than a
6053
+ // prompt because the hold outlives the pass that raised it, and
6054
+ // DDR-177's user has no terminal to answer in.
6055
+ ...(linkedHub.resolveFirstAnchor === 'keep-local' ||
6056
+ linkedHub.resolveFirstAnchor === 'keep-cloud'
6057
+ ? { resolveFirstAnchor: linkedHub.resolveFirstAnchor }
6058
+ : {}),
6059
+ // Issue #207 — folders the project does not sync (Sync details › Don't sync this folder).
6060
+ ignoreFolders: planeIgnoreFolders,
6061
+ // Same exposure class as `syncMeta.by`, and the same reasoning:
6062
+ // a conflict copy nobody can attribute is a conflict copy nobody
6063
+ // resolves.
6064
+ label: hostname().slice(0, 32),
6065
+ });
6066
+ // S8.19 — the plane's held report (`/_asset-probe` held + sweep.final). This block
6067
+ // is already `!cellPairing`; the token is read per send (silent renewal).
6068
+ heldReporter = createHeldReporter({
6069
+ designRoot: ctx.paths.designRoot,
6070
+ canvasGroups: ctx.cfg.canvasGroups,
6071
+ send: (rels) =>
6072
+ reportHeld({ fetchImpl: hubFetch, base: linkedHub.url, token, rels }),
6073
+ });
6074
+ // Issue #207 (7b) — the answer to "Deleted on this Mac, held". The role only decides
6075
+ // which door to TRY (the hub's own check decides the rest); the count of deletes this
6076
+ // Mac sent is its ledger's outbound window.
6077
+ {
6078
+ const ledgerNow = fileLedger;
6079
+ heldDeletesControl = createHeldDeletes({
6080
+ plane: () => filePlane,
6081
+ sentInWindow: () => ledgerNow.deletesInWindow('out', DELETE_BUDGET_WINDOW_MS),
6082
+ isOwner: () => isProjectOwner,
6083
+ hubUrl: linkedHub.url,
6084
+ token: () => token,
6085
+ fetchImpl: hubFetch,
6086
+ runPass: () => schedulePlanePass(),
6087
+ });
6088
+ }
6089
+ console.log(
6090
+ '[sync/files] journal file plane active — one lane, both directions, per-file delivery state in the Sync panel.'
6091
+ );
6092
+ // Anything the local disk already differs on goes now, rather than
6093
+ // at the first 20 s tick.
6094
+ schedulePlanePass();
6095
+ }
6096
+ // A ledger hub with the plane ON owns pushes; with the file-plane
6097
+ // flag OFF the legacy client still carries the DDR-217 assets lane.
6098
+ decidePushLane(filePlane === null);
6099
+ makeFileEventsCtl = () =>
6100
+ createCtlProvider({
6101
+ url: linkedHub.url,
6102
+ token,
6103
+ onDocuments: () => documentDiscovery?.schedule(),
6104
+ // S5.3 — server.ts forwards it to the AI run registry (`registry.poke`).
6105
+ onRuns: (seq) => ctx.bus.emit('hub:runs', { seq }),
6106
+ onPoke: () => {
6107
+ // Reuses `pollRemoteSoon` rather than calling the file lanes
6108
+ // directly, for two reasons: it already coalesces a burst into
6109
+ // one pass (a fresh link appends hundreds of rows), and it is
6110
+ // the exact path a reconnect takes — one behaviour to reason
6111
+ // about instead of two that can drift.
6112
+ //
6113
+ // The PULL itself is unchanged: missing-only, idempotent, and
6114
+ // re-validating everything it accepts. So a poke can at worst
6115
+ // cost one early pass, and the scheduled poll remains the
6116
+ // reconciler underneath it.
6117
+ pokesSeen += 1;
6118
+ pollRemoteSoon({ cooled: true });
6119
+ },
6120
+ });
6121
+ // A desktop that parked before the capability probe answered keeps
6122
+ // the channel closed; the unpark builds it.
6123
+ if (!parkedNow) fileEventsCtl = makeFileEventsCtl();
5871
6124
  console.log(
5872
- '[sync/files] journal file plane active — one lane, both directions, per-file delivery state in the Sync panel.'
6125
+ '[sync/ctl] file-event channel attached — cloud changes now arrive in seconds instead of on the 20 s tick.'
5873
6126
  );
5874
- // Anything the local disk already differs on goes now, rather than
5875
- // at the first 20 s tick.
5876
- schedulePlanePass();
5877
- }
5878
- // A ledger hub with the plane ON owns pushes; with the file-plane
5879
- // flag OFF the legacy client still carries the DDR-217 assets lane.
5880
- decidePushLane(filePlane === null);
5881
- makeFileEventsCtl = () =>
5882
- createCtlProvider({
5883
- url: linkedHub.url,
5884
- token,
5885
- onDocuments: () => documentDiscovery?.schedule(),
5886
- // S5.3 — server.ts forwards it to the AI run registry (`registry.poke`).
5887
- onRuns: (seq) => ctx.bus.emit('hub:runs', { seq }),
5888
- onPoke: () => {
5889
- // Reuses `pollRemoteSoon` rather than calling the file lanes
5890
- // directly, for two reasons: it already coalesces a burst into
5891
- // one pass (a fresh link appends hundreds of rows), and it is
5892
- // the exact path a reconnect takes — one behaviour to reason
5893
- // about instead of two that can drift.
5894
- //
5895
- // The PULL itself is unchanged: missing-only, idempotent, and
5896
- // re-validating everything it accepts. So a poke can at worst
5897
- // cost one early pass, and the scheduled poll remains the
5898
- // reconciler underneath it.
5899
- pokesSeen += 1;
5900
- pollRemoteSoon({ cooled: true });
5901
- },
5902
- });
5903
- // A desktop that parked before the capability probe answered keeps
5904
- // the channel closed; the unpark builds it.
5905
- if (!parkedNow) fileEventsCtl = makeFileEventsCtl();
5906
- console.log(
5907
- '[sync/ctl] file-event channel attached — cloud changes now arrive in seconds instead of on the 20 s tick.'
5908
- );
5909
- })
5910
- .catch(() => {
5911
- // No capability probe ⇒ no channel ⇒ exactly today's behaviour —
5912
- // which, for pushes, is the legacy client.
5913
- decidePushLane(true);
5914
- });
6127
+ })
6128
+ .catch((err) => {
6129
+ // A throw in the verdict's own handling is not an answer about the
6130
+ // hub: never a reason to pick the legacy lane (2.0.5). Ask again.
6131
+ console.error('[sync/files] the lane probe failed:', err);
6132
+ if (legacyLane === null) reprobeLane();
6133
+ });
6134
+ };
6135
+ probeLane();
5915
6136
  } else if (!cellPairing) {
5916
6137
  // The probe is opted out (`linkedHub.fileEvents: false`), so no verdict
5917
6138
  // will ever arrive — the legacy client is the lane, as it always was.
@@ -5932,6 +6153,8 @@ export function createSyncRuntime(
5932
6153
  revisionBarrier.stop();
5933
6154
  fileEventsProbe?.abort();
5934
6155
  fileEventsProbe = null;
6156
+ if (laneProbeTimer !== null) clearTimeout(laneProbeTimer);
6157
+ laneProbeTimer = null;
5935
6158
  if (filePassTimer !== null) clearTimeout(filePassTimer);
5936
6159
  filePassTimer = null;
5937
6160
  planeResultSink = null;
@@ -5941,6 +6164,7 @@ export function createSyncRuntime(
5941
6164
  fileLedger = null;
5942
6165
  filePlane = null;
5943
6166
  heldReporter = null;
6167
+ heldDeletesControl = null;
5944
6168
  // The control channel is a doorbell into this runtime; it goes with it.
5945
6169
  // Reported on the way out so the poke-miss question is answerable from a
5946
6170
  // session's log rather than from a hunch (DDR-226 §10).
@@ -5983,6 +6207,8 @@ export function createSyncRuntime(
5983
6207
  documentDiscoveryUnsub?.();
5984
6208
  documentDiscoveryUnsub = null;
5985
6209
  projectConfigUnsub?.();
6210
+ codeConsentUnwatch?.();
6211
+ codeConsentUnwatch = null;
5986
6212
  documentDiscovery?.stop();
5987
6213
  documentDiscovery = null;
5988
6214
  remotePull = null;
@@ -6127,6 +6353,8 @@ export function createSyncRuntime(
6127
6353
  }),
6128
6354
  rescanNow: () => discoveryRescan?.flush() ?? Promise.resolve(),
6129
6355
  pullRemoteNow: () => remotePull?.() ?? Promise.resolve(),
6356
+ codeConsent: () => codeConsent,
6357
+ heldDeletes: () => heldDeletesControl,
6130
6358
  // Under sharedDoc the per-canvas handler is a projection, not an agent;
6131
6359
  // count both so size() reflects the synced-canvas count in either mode.
6132
6360
  size: () => agents.size + projections.size,
@@ -6565,10 +6793,22 @@ export function createSyncRuntime(
6565
6793
  return { status: 'taken' };
6566
6794
  }
6567
6795
  if (sides.mine === null) return { status: 'rejected', code: 'no-local-version' };
6796
+ // #14 — the css twin's side first (read before the html proposal can move anything): a
6797
+ // conflict on the css lane is the canvas's conflict too, and Keep mine that answered only
6798
+ // the html left the css held here and the project's css in the project — the notice went,
6799
+ // and came back after the next restart.
6800
+ const css = projection.heldCss();
6568
6801
  // Mine, on top of the version that won — a new action, never a rewind.
6569
6802
  const r = await projection.proposeLane('html', sides.mine, { baseContent: sides.theirs });
6570
6803
  if (!r) return null;
6571
- if (r.status === 'accepted') statusStore?.clearSourceConflict?.(slug);
6804
+ if (r.status !== 'accepted') return { status: r.status, ...(r.code ? { code: r.code } : {}) };
6805
+ if (css && css.mine !== null) {
6806
+ const c = await projection.proposeLane('css', css.mine, { baseContent: css.theirs });
6807
+ if (!c) return null;
6808
+ if (c.status !== 'accepted')
6809
+ return { status: c.status, ...(c.code ? { code: c.code } : {}) };
6810
+ }
6811
+ statusStore?.clearSourceConflict?.(slug);
6572
6812
  return { status: r.status, ...(r.code ? { code: r.code } : {}) };
6573
6813
  },
6574
6814
  beginAiAction: (key, label, meta) => {
@@ -6780,9 +7020,11 @@ export function filePlaneHeld(
6780
7020
  kind: result.deleteHeld.direction === 'out' ? 'delete-out' : 'delete-in',
6781
7021
  count: result.deleteHeld.count,
6782
7022
  paths: result.deleteHeld.paths,
7023
+ ...(result.deleteHeld.folders ? { folders: result.deleteHeld.folders } : {}),
6783
7024
  detail:
6784
7025
  result.deleteHeld.direction === 'out'
6785
- ? `${result.deleteHeld.count} files are gone from this machine — more than sync will remove from the project without you saying so. Nothing was deleted anywhere else. Set linkedHub.propagateDeletes: false to stop asking, or delete them again once you have confirmed this was deliberate.`
7026
+ ? // Issue #207 (7b) — the row's two buttons are the answer (Delete on the hub too · Keep on the hub).
7027
+ heldDeleteDetail(result.deleteHeld.count, result.deleteHeld.folders ?? [])
6786
7028
  : `The project wants to remove ${result.deleteHeld.count} files here — more than sync will delete without you saying so. Nothing was removed. They stay until you accept or the project puts them back.`,
6787
7029
  });
6788
7030
  }