@1agh/maude 2.0.3 → 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.
- package/README.md +6 -5
- package/apps/hub/src/project-transactions/kernel.mjs +10 -1
- package/apps/studio/access/filters.ts +12 -5
- package/apps/studio/access/known-canvases.ts +24 -1
- package/apps/studio/access/refused-inputs.ts +89 -0
- package/apps/studio/access/request.ts +0 -1
- package/apps/studio/acp/adapter-stderr.ts +43 -13
- package/apps/studio/acp/background-tasks.ts +155 -0
- package/apps/studio/acp/bridge.ts +44 -5
- package/apps/studio/acp/connected-fact.ts +15 -4
- package/apps/studio/acp/index.ts +14 -5
- package/apps/studio/actions/agents.ts +10 -0
- package/apps/studio/actions/defs/app.ts +12 -0
- package/apps/studio/actions/defs/view.ts +12 -0
- package/apps/studio/actions.manifest.json +25 -1
- package/apps/studio/actions.parity.json +13 -1
- package/apps/studio/annotations/ui/element-node.tsx +139 -54
- package/apps/studio/annotations/ui/lod.tsx +1 -1
- package/apps/studio/annotations/ui/text-style.ts +1 -1
- package/apps/studio/annotations-layer.tsx +0 -12
- package/apps/studio/api.ts +73 -24
- package/apps/studio/artboard-live-gate.tsx +267 -0
- package/apps/studio/artboard-live.ts +336 -0
- package/apps/studio/artboard-webgl.ts +668 -0
- package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
- package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
- package/apps/studio/bin/_canvas-reasons.mjs +34 -0
- package/apps/studio/bin/_ds-check-live.mjs +37 -0
- package/apps/studio/bin/_ds-check.mjs +4 -1
- package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
- package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
- package/apps/studio/bin/_import-asset.mjs +2 -1
- package/apps/studio/bin/_perf-probe.mjs +2 -1
- package/apps/studio/bin/_png-playwright.mjs +10 -1
- package/apps/studio/bin/_pw-launch.mjs +14 -0
- package/apps/studio/bin/_studio-verb.mjs +24 -3
- package/apps/studio/bin/_thumb-blank.mjs +70 -0
- package/apps/studio/bin/_thumb-cover.mjs +35 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +93 -13
- package/apps/studio/bin/ds-check.sh +5 -1
- package/apps/studio/bin/perf.sh +11 -1
- package/apps/studio/bin/server-up.sh +7 -2
- package/apps/studio/bin/smoke.sh +19 -0
- package/apps/studio/boot-progress.ts +31 -0
- package/apps/studio/canvas-build-sandbox.ts +275 -42
- package/apps/studio/canvas-build-worker.ts +10 -0
- package/apps/studio/canvas-create.ts +24 -0
- package/apps/studio/canvas-lib.tsx +131 -12
- package/apps/studio/canvas-module-cache.ts +93 -0
- package/apps/studio/canvas-source/errors.ts +39 -0
- package/apps/studio/canvas-source/waiting.ts +290 -0
- package/apps/studio/client/actions/shell-key-handlers.js +5 -0
- package/apps/studio/client/app.jsx +19 -9
- package/apps/studio/client/canvas-url.js +13 -0
- package/apps/studio/client/github.js +23 -3
- package/apps/studio/client/home/HomeAccounts.jsx +262 -0
- package/apps/studio/client/home/Shelves.jsx +4 -3
- package/apps/studio/client/home/home-accounts-model.js +121 -0
- package/apps/studio/client/home/home-api.js +36 -19
- package/apps/studio/client/home/home-app.jsx +141 -40
- package/apps/studio/client/home/home-model.js +172 -6
- package/apps/studio/client/home/home.css +169 -5
- package/apps/studio/client/home/shell-mode.js +8 -1
- package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
- package/apps/studio/client/hooks/use-project-data.jsx +2 -0
- package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
- package/apps/studio/client/hooks/use-tabs.jsx +64 -35
- package/apps/studio/client/index-loader.ts +23 -3
- package/apps/studio/client/panels/ChatPanel.jsx +49 -57
- package/apps/studio/client/panels/CreateProject.jsx +19 -5
- package/apps/studio/client/panels/DiffView.jsx +314 -248
- package/apps/studio/client/panels/TeamProjects.jsx +119 -69
- package/apps/studio/client/panels/acp-runtime.js +25 -0
- package/apps/studio/client/panels/caps-cache.js +46 -0
- package/apps/studio/client/panels/chat-finish.js +66 -0
- package/apps/studio/client/shell/frame-cap.js +53 -0
- package/apps/studio/client/shell/viewport.jsx +45 -8
- package/apps/studio/client/styles/_index.css +2 -0
- package/apps/studio/client/tree/tree.jsx +48 -21
- package/apps/studio/client/v2/access/access-client.js +2 -0
- package/apps/studio/client/v2/access/access-host.jsx +12 -1
- package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
- package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
- package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
- package/apps/studio/client/v2/ai/Composer.jsx +27 -10
- package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
- package/apps/studio/client/v2/ai/ai-run.css +87 -3
- package/apps/studio/client/v2/ai/background-model.js +113 -0
- package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
- package/apps/studio/client/v2/ai/run-api.js +7 -3
- package/apps/studio/client/v2/ai/runs-store.js +2 -1
- package/apps/studio/client/v2/annotations/vote-store.js +11 -5
- package/apps/studio/client/v2/assets/asset-state-lane.js +6 -3
- package/apps/studio/client/v2/assets/assets-bus.js +10 -8
- package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
- package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
- package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
- package/apps/studio/client/v2/assets/spotlight.css +153 -0
- package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
- package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
- package/apps/studio/client/v2/assets/tile.jsx +3 -0
- package/apps/studio/client/v2/assets/use-assets.js +2 -1
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
- package/apps/studio/client/v2/canvases/covers.js +11 -5
- package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
- package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
- package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
- package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
- package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
- package/apps/studio/client/v2/canvases/use-pins.js +2 -1
- package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
- package/apps/studio/client/v2/code/canvas-imports-card.jsx +15 -14
- package/apps/studio/client/v2/code/canvas-imports-words.js +44 -0
- package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
- package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
- package/apps/studio/client/v2/code/code-bus.js +5 -0
- package/apps/studio/client/v2/code/code.css +67 -0
- package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
- package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
- package/apps/studio/client/v2/create/name-dialog.css +10 -0
- package/apps/studio/client/v2/ds/advanced-host.jsx +11 -23
- package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
- package/apps/studio/client/v2/ds/library-host.jsx +45 -45
- package/apps/studio/client/v2/ds/make-host.jsx +13 -12
- package/apps/studio/client/v2/ds/off-system-host.jsx +18 -16
- package/apps/studio/client/v2/ds/review-host.jsx +7 -1
- package/apps/studio/client/v2/ds/truth-host.jsx +15 -14
- package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
- package/apps/studio/client/v2/empty/arriving.jsx +29 -12
- package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
- package/apps/studio/client/v2/empty/not-local.jsx +31 -1
- package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
- package/apps/studio/client/v2/export/last-finished.js +2 -1
- package/apps/studio/client/v2/history/branch-actions.js +13 -9
- package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
- package/apps/studio/client/v2/history/git-model.js +21 -5
- package/apps/studio/client/v2/history/git-parts.jsx +76 -43
- package/apps/studio/client/v2/history/history.css +6 -0
- package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
- package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
- package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
- package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
- package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
- package/apps/studio/client/v2/presence/faces.jsx +42 -14
- package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
- package/apps/studio/client/v2/search/search-recent.js +3 -1
- package/apps/studio/client/v2/search/search-remote.js +6 -4
- package/apps/studio/client/v2/settings/connections-model.js +1 -1
- package/apps/studio/client/v2/shell/account-card.jsx +10 -4
- package/apps/studio/client/v2/shell/canvas-crash-guard.js +137 -0
- package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
- package/apps/studio/client/v2/shell/menu-runner.js +12 -0
- package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
- package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
- package/apps/studio/client/v2/shell/project-account-model.js +182 -0
- package/apps/studio/client/v2/shell/recovery-store.js +2 -1
- package/apps/studio/client/v2/shell/served-routes.js +120 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +139 -11
- package/apps/studio/client/v2/shell/share-cluster.css +58 -0
- package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
- package/apps/studio/client/v2/shell/shell-activity.js +19 -0
- package/apps/studio/client/v2/shell/team-switch.js +94 -0
- package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
- package/apps/studio/client/v2/shell/use-account.js +8 -1
- package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
- package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
- package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
- package/apps/studio/cloud/endpoints.ts +23 -1
- package/apps/studio/collab/persistence.ts +9 -1
- package/apps/studio/collab/registry.ts +32 -0
- package/apps/studio/collab/room.ts +8 -0
- package/apps/studio/config-reload-wire.ts +53 -0
- package/apps/studio/dist/client.bundle.js +1098 -1102
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds/board/specimen.tsx +12 -1
- package/apps/studio/ds/canvas-cli.ts +58 -2
- package/apps/studio/ds/check.ts +26 -1
- package/apps/studio/ds/cli.ts +7 -3
- package/apps/studio/ds/convert.ts +34 -6
- package/apps/studio/ds/ds-verb.ts +13 -0
- package/apps/studio/ds/post-build.ts +38 -0
- package/apps/studio/ds/upgrade-apply.ts +27 -5
- package/apps/studio/ds/upgrade-cli.ts +22 -2
- package/apps/studio/ds/upgrade-prove.ts +198 -15
- package/apps/studio/ds/upgrade-stage.ts +4 -1
- package/apps/studio/editing/minimap-context.tsx +3 -3
- package/apps/studio/editing/page-activity.ts +251 -0
- package/apps/studio/editing/rotate-handle.tsx +9 -5
- package/apps/studio/editing/sticky-name.tsx +4 -4
- package/apps/studio/history/restore-artboard-action.ts +40 -0
- package/apps/studio/history/trash.ts +6 -0
- package/apps/studio/home/accounts.ts +87 -0
- package/apps/studio/home/hub.ts +77 -175
- package/apps/studio/home/index-reader.ts +24 -2
- package/apps/studio/home/routes.ts +66 -8
- package/apps/studio/http.ts +131 -68
- package/apps/studio/index-flight.ts +40 -0
- package/apps/studio/managed-projects.ts +52 -24
- package/apps/studio/migrate/hub.ts +7 -1
- package/apps/studio/routes/canvas-source.ts +44 -2
- package/apps/studio/routes/ds-convert.ts +18 -0
- package/apps/studio/routes/history.ts +28 -5
- package/apps/studio/routes/hub-signin.ts +115 -0
- package/apps/studio/routes/index.ts +4 -0
- package/apps/studio/routes/table.ts +7 -0
- package/apps/studio/routes/trash.ts +19 -1
- package/apps/studio/server.ts +19 -10
- package/apps/studio/sync/accepted-cold-start.ts +54 -16
- package/apps/studio/sync/accepted-link.ts +9 -4
- package/apps/studio/sync/asset-push.ts +146 -23
- package/apps/studio/sync/asset-state.ts +3 -2
- package/apps/studio/sync/code-module-consent.ts +74 -0
- package/apps/studio/sync/file-ledger.ts +35 -0
- package/apps/studio/sync/file-membership.ts +28 -3
- package/apps/studio/sync/file-plane.ts +483 -86
- package/apps/studio/sync/file-pull.ts +304 -33
- package/apps/studio/sync/hub-browser-signin.ts +377 -0
- package/apps/studio/sync/hub-link.ts +1 -2
- package/apps/studio/sync/hub-text-undo.ts +30 -10
- package/apps/studio/sync/index.ts +381 -161
- package/apps/studio/sync/journal-client.ts +94 -5
- package/apps/studio/sync/pending-deletes.ts +100 -0
- package/apps/studio/sync/projection.ts +121 -14
- package/apps/studio/sync/pull-pacer.ts +160 -0
- package/apps/studio/sync/pull-priority.ts +119 -0
- package/apps/studio/sync/seed-progress.ts +58 -3
- package/apps/studio/sync/status.ts +3 -1
- package/apps/studio/sync/transaction-client.ts +71 -6
- package/apps/studio/sync/workspace-signin.ts +6 -256
- package/apps/studio/sync/writer-registry.ts +5 -1
- package/apps/studio/thumbs/service.ts +12 -2
- package/apps/studio/thumbs/validate.ts +7 -0
- package/apps/studio/ui-prefs-migrate.ts +4 -0
- package/apps/studio/video-comp.tsx +23 -0
- package/apps/studio/video-links-overlay.tsx +3 -2
- package/apps/studio/whats-new.json +126 -0
- package/cli/lib/bash-guard.mjs +13 -1
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/design-hook.mjs +20 -0
- package/cli/lib/studio-locate.mjs +35 -10
- package/cli/lib/workspace-plan.mjs +14 -0
- package/package.json +8 -8
|
@@ -67,6 +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
71
|
import {
|
|
71
72
|
canvasPathFromDoc,
|
|
72
73
|
clearMovedTo,
|
|
@@ -90,7 +91,12 @@ import { createDocumentDiscovery } from './document-discovery.ts';
|
|
|
90
91
|
import { createEchoGuard, hashBytes } from './echo-guard.ts';
|
|
91
92
|
import { createFileLedger } from './file-ledger.ts';
|
|
92
93
|
import { createFilePlane, MAX_DORUCEKA_ROWS } from './file-plane.ts';
|
|
93
|
-
import {
|
|
94
|
+
import {
|
|
95
|
+
createLegacyPullGate,
|
|
96
|
+
createPullFailureMemory,
|
|
97
|
+
type FilePullResult,
|
|
98
|
+
pullFiles,
|
|
99
|
+
} from './file-pull.ts';
|
|
94
100
|
import {
|
|
95
101
|
declaredFormat,
|
|
96
102
|
formatFromHub,
|
|
@@ -103,10 +109,16 @@ import {
|
|
|
103
109
|
import { createFsReader, type FsReader } from './fs-mirror.ts';
|
|
104
110
|
import { canvasLanes, namedField, type RowNamed } from './history-fields.ts';
|
|
105
111
|
import { type HubDocRow, hubHolds, indexHubDocs } from './hub-listing.ts';
|
|
106
|
-
import { hubTextUndoConflict } from './hub-text-undo.ts';
|
|
112
|
+
import { HUB_UNDO_READ_MAX_BYTES, hubTextUndoConflict } from './hub-text-undo.ts';
|
|
107
113
|
import { accessFor, getHubRecord } from './hubs-config.ts';
|
|
108
114
|
import { loadJournal, type SyncJournal } from './journal.ts';
|
|
109
|
-
import {
|
|
115
|
+
import {
|
|
116
|
+
hasAnnotationsV2,
|
|
117
|
+
hasFileClassesV2,
|
|
118
|
+
hasFileDepthV2,
|
|
119
|
+
hasLedger,
|
|
120
|
+
probeFileLane,
|
|
121
|
+
} from './journal-client.ts';
|
|
110
122
|
import type { RestoreOptions } from './local-kernel.ts';
|
|
111
123
|
import { isLoopbackHost } from './loopback.ts';
|
|
112
124
|
import { createMediaGate, MEDIA_STAYS_LINE, readServerSignature } from './media-gate.ts';
|
|
@@ -125,9 +137,11 @@ import {
|
|
|
125
137
|
parkReducer,
|
|
126
138
|
parseCellState,
|
|
127
139
|
} from './park.ts';
|
|
140
|
+
import { takePendingDeletes } from './pending-deletes.ts';
|
|
128
141
|
import { hasSelfRetryingWork } from './presentation.ts';
|
|
129
142
|
import { createProjectConfigPusher } from './project-config-push.ts';
|
|
130
143
|
import { createDocProjection, type DocProjection } from './projection.ts';
|
|
144
|
+
import { followUpDelayMs } from './pull-pacer.ts';
|
|
131
145
|
import {
|
|
132
146
|
acceptedListing,
|
|
133
147
|
describeRemoteDiff,
|
|
@@ -318,6 +332,9 @@ export const DISCOVERY_DEBOUNCE_MS = 400;
|
|
|
318
332
|
*/
|
|
319
333
|
export const REMOTE_POLL_MS = 20_000;
|
|
320
334
|
|
|
335
|
+
/** 2.0.5 — how soon an unanswered lane probe asks the hub again. */
|
|
336
|
+
const LANE_REPROBE_MS = 60_000;
|
|
337
|
+
|
|
321
338
|
/**
|
|
322
339
|
* Does this studio run the FILE plane (Plane B) against its linked hub?
|
|
323
340
|
*
|
|
@@ -508,6 +525,11 @@ export interface AwarenessRegistry {
|
|
|
508
525
|
pin?(slug: string): void;
|
|
509
526
|
/** Release the shared-doc pin on runtime stop. */
|
|
510
527
|
unpin?(slug: string): void;
|
|
528
|
+
/**
|
|
529
|
+
* fix/205 — throw away an unpinned room with no browser in it (no flush); with
|
|
530
|
+
* `forgetCache` its persisted cache too. See `collab/registry.ts` `discard`.
|
|
531
|
+
*/
|
|
532
|
+
discard?(slug: string, opts?: { forgetCache?: boolean }): Promise<boolean>;
|
|
511
533
|
}
|
|
512
534
|
|
|
513
535
|
/** Factory the runtime calls per discovered canvas. Default uses Hocuspocus. */
|
|
@@ -734,6 +756,12 @@ export interface SyncRuntime {
|
|
|
734
756
|
} | null>;
|
|
735
757
|
/** S1.18 — the manifest rows a stable link resolves over (history/links.ts). Null when legacy. */
|
|
736
758
|
acceptedLinkDocs?(): Promise<{ entry: string; path: string | null; retired: boolean }[] | null>;
|
|
759
|
+
/**
|
|
760
|
+
* F14 (2.0.4, #166) — before a restore reads the canvas's newest version: this disk's change the
|
|
761
|
+
* project has not taken yet goes up first (projection.ts `settleDisk`). null: no synced canvas
|
|
762
|
+
* at that path, or not in accepted mode — nothing to wait for.
|
|
763
|
+
*/
|
|
764
|
+
settleSource?(repoRel: string, ms?: number): Promise<'settled' | 'held' | 'pending' | null>;
|
|
737
765
|
/**
|
|
738
766
|
* Restore a canvas to a revision as a NEW action. S1.13: `o.lanes` — one artboard / object /
|
|
739
767
|
* kept-aside version, the studio's lanes as ONE `restore` action (local-kernel.ts RestoreOptions).
|
|
@@ -1258,8 +1286,17 @@ export function createSyncRuntime(
|
|
|
1258
1286
|
//
|
|
1259
1287
|
// Now: an explicit per-hub consent recorded at link time and never rewritten
|
|
1260
1288
|
// by a login response, or this cell's own loopback pairing — where the hub
|
|
1261
|
-
// and the checkout are one trust domain and there is no remote party
|
|
1262
|
-
|
|
1289
|
+
// and the checkout are one trust domain and there is no remote party — or
|
|
1290
|
+
// (2.0.4) the Maude Cloud cell the desktop app itself bound this copy to
|
|
1291
|
+
// (`MAUDE_APP_BOUND_HUB` + the compiled-in cell zone; never a committed
|
|
1292
|
+
// linkedHub, never a self-hosted hub). See sync/code-module-consent.ts.
|
|
1293
|
+
const allowCodeModules =
|
|
1294
|
+
codeModuleConsent({
|
|
1295
|
+
cellPairing: cellPairing !== null,
|
|
1296
|
+
hubUrl: linkedHub.url,
|
|
1297
|
+
storedRecord,
|
|
1298
|
+
env: process.env,
|
|
1299
|
+
}) !== null;
|
|
1263
1300
|
// Same shape of consent for the OUTBOUND delete breaker: only what this
|
|
1264
1301
|
// machine's owner recorded (`maude design bulk-deletes on`), never the hub.
|
|
1265
1302
|
const unlimitedDeletes = storedRecord?.unlimitedDeletes === true;
|
|
@@ -1337,6 +1374,8 @@ export function createSyncRuntime(
|
|
|
1337
1374
|
// two-doc agent path has no proposal lane and stays legacy.
|
|
1338
1375
|
/** Resolves once a previous run's outbox is drained: doc → own accepted html. */
|
|
1339
1376
|
let outboxDrained: Promise<Map<string, string>> = Promise.resolve(new Map());
|
|
1377
|
+
/** #14 — the same drain's css: doc → own accepted css (filled by the time it resolves). */
|
|
1378
|
+
const drainedCss = new Map<string, string>();
|
|
1340
1379
|
/** S6.13 — documents whose `doc.create` that drain had accepted: made BY
|
|
1341
1380
|
* THIS MAC in a previous run, so they join as a create, not a reconcile. */
|
|
1342
1381
|
const drainedCreates = new Set<string>();
|
|
@@ -1576,6 +1615,8 @@ export function createSyncRuntime(
|
|
|
1576
1615
|
* `true` = journal-less hub ⇒ this legacy client carries the upward lane.
|
|
1577
1616
|
*/
|
|
1578
1617
|
let legacyLane: boolean | null = null;
|
|
1618
|
+
/** fix/205 — the hub advertised `file-depth-v2` (set with the lane verdict). */
|
|
1619
|
+
let legacyHubTakesDeepPaths = false;
|
|
1579
1620
|
/** A pass was owed before the lane was decided — run it on the verdict. */
|
|
1580
1621
|
let legacyBootPush: string | null = null;
|
|
1581
1622
|
/**
|
|
@@ -1610,6 +1651,7 @@ export function createSyncRuntime(
|
|
|
1610
1651
|
// Read at call time — silent renewal swaps the credential in place.
|
|
1611
1652
|
token: () => token,
|
|
1612
1653
|
canvasGroups: ctx.cfg.canvasGroups,
|
|
1654
|
+
hubTakesDeepPaths: legacyHubTakesDeepPaths,
|
|
1613
1655
|
cancelled: () => legacyPushCancel || stopped,
|
|
1614
1656
|
// feature-sync-progress-modal — same `sync:status` payload as ever, so
|
|
1615
1657
|
// the Sync panel needs no idea which lane fed it. Guarded on `stopped`:
|
|
@@ -1877,6 +1919,8 @@ export function createSyncRuntime(
|
|
|
1877
1919
|
* suite long before it shows up as a bug.
|
|
1878
1920
|
*/
|
|
1879
1921
|
let fileEventsProbe: AbortController | null = null;
|
|
1922
|
+
/** 2.0.5 — the hub did not answer the lane probe: ask again, never fall back. */
|
|
1923
|
+
let laneProbeTimer: ReturnType<typeof setTimeout> | null = null;
|
|
1880
1924
|
/**
|
|
1881
1925
|
* The Sync v2 file plane — ONE lane, both directions, one decision table.
|
|
1882
1926
|
*
|
|
@@ -1984,6 +2028,15 @@ export function createSyncRuntime(
|
|
|
1984
2028
|
const r = await lane.reconcile();
|
|
1985
2029
|
lastPlaneResult = r;
|
|
1986
2030
|
planeResultSink?.(r);
|
|
2031
|
+
// ISSUE #204 — WHILE WORK REMAINS, THE NEXT PASS STARTS NOW. A pass that stopped on a count
|
|
2032
|
+
// ceiling (or skipped a file still inside a short backoff) used to sit out the rest of the
|
|
2033
|
+
// 20 s tick, and on a 5 041-file first sync that idle time was a large share of 1.5 h. Only
|
|
2034
|
+
// a HEALTHY capped pass follows up at once — one that moved files and met no wall — so a
|
|
2035
|
+
// pass whose requests all failed can never become a tight loop (issue #109); a byte-budget
|
|
2036
|
+
// stop keeps the tick, so the 2 GiB pass ceiling (DDR-226 F6) stays a per-tick bound.
|
|
2037
|
+
const followUp = planeFollowUpMs(r);
|
|
2038
|
+
if (followUp === 0) planePassAgain = true;
|
|
2039
|
+
else if (followUp !== null) schedulePlanePassAfter(followUp);
|
|
1987
2040
|
// S8.19 — the held set rides AFTER the pass (the plane now has a picture of the disk);
|
|
1988
2041
|
// single-flight, floored, never throws, and never awaited by the pass's waiters.
|
|
1989
2042
|
if (!cellPairing) void heldReporter?.afterPass();
|
|
@@ -2001,6 +2054,9 @@ export function createSyncRuntime(
|
|
|
2001
2054
|
planePassWaiter = run;
|
|
2002
2055
|
await run;
|
|
2003
2056
|
}
|
|
2057
|
+
/** Issue #204 — when the next pass should run without waiting for the tick (see `runPlanePass`). */
|
|
2058
|
+
const planeFollowUpMs = (r: import('./file-plane.ts').FilePlaneResult): number | null =>
|
|
2059
|
+
followUpDelayMs(r, { pollMs: REMOTE_POLL_MS, floorMs: MIN_PASS_INTERVAL_MS });
|
|
2004
2060
|
/** Re-arm the debounce timer at a specific delay (the floor's deferral). */
|
|
2005
2061
|
function schedulePlanePassAfter(ms: number): void {
|
|
2006
2062
|
if (stopped || filePassTimer !== null) return;
|
|
@@ -2283,7 +2339,7 @@ export function createSyncRuntime(
|
|
|
2283
2339
|
const desc = descriptors.get(slug);
|
|
2284
2340
|
const provider = providers.get(slug);
|
|
2285
2341
|
const movedTo = provider ? movedToFromDoc(provider.document) : null;
|
|
2286
|
-
await releaseOne(slug);
|
|
2342
|
+
await releaseOne(slug, { gone: true });
|
|
2287
2343
|
if (!desc) return;
|
|
2288
2344
|
// HOLD until the canvas provably lives at its new path — parking the old
|
|
2289
2345
|
// copy while the new document is still materialising would leave a window
|
|
@@ -2367,7 +2423,17 @@ export function createSyncRuntime(
|
|
|
2367
2423
|
noteDetach(statusDetaches, slug, () => doc.off('update', onUpdate));
|
|
2368
2424
|
}
|
|
2369
2425
|
|
|
2370
|
-
|
|
2426
|
+
/**
|
|
2427
|
+
* `gone` — the canvas LEFT the project (deleted here or in the project, moved
|
|
2428
|
+
* away on another machine), as opposed to being let go of while it still
|
|
2429
|
+
* lives (a `syncable: false` sidecar, a refused pull, a local move). A gone
|
|
2430
|
+
* canvas's collab room is discarded with its cache (fix/205): its Y.Doc is
|
|
2431
|
+
* the deleted lineage, and the hub has dropped its own copy, so a canvas
|
|
2432
|
+
* re-created at the same slug that re-attached to it merged the hub's new
|
|
2433
|
+
* body onto the old one — the body doubled and receivers refused it as
|
|
2434
|
+
* invalid source.
|
|
2435
|
+
*/
|
|
2436
|
+
async function releaseOne(slug: string, how: { gone?: boolean } = {}): Promise<boolean> {
|
|
2371
2437
|
const known = agents.has(slug) || projections.has(slug) || providers.has(slug);
|
|
2372
2438
|
if (!known) return false;
|
|
2373
2439
|
runDetaches(awarenessDetaches, slug);
|
|
@@ -2408,6 +2474,13 @@ export function createSyncRuntime(
|
|
|
2408
2474
|
/* best-effort */
|
|
2409
2475
|
}
|
|
2410
2476
|
}
|
|
2477
|
+
if (how.gone) {
|
|
2478
|
+
try {
|
|
2479
|
+
await opts.registry?.discard?.(slug, { forgetCache: true });
|
|
2480
|
+
} catch {
|
|
2481
|
+
/* best-effort — attachCanvas discards a leftover room too */
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2411
2484
|
descriptors.delete(slug);
|
|
2412
2485
|
// Drop the row too — a released canvas that stayed `pending` in the status
|
|
2413
2486
|
// payload would be a permanent "still syncing" the user can never clear.
|
|
@@ -2874,6 +2947,17 @@ export function createSyncRuntime(
|
|
|
2874
2947
|
: o.op === 'doc.create'
|
|
2875
2948
|
? (o.lanes as Record<string, unknown> | undefined)?.html
|
|
2876
2949
|
: undefined;
|
|
2950
|
+
// #14 — the css twin's save is judged the same way (see accepted-cold-start.ts)
|
|
2951
|
+
const css =
|
|
2952
|
+
o.op === 'lane.replace' && o.lane === 'css'
|
|
2953
|
+
? o.content
|
|
2954
|
+
: o.op === 'doc.create'
|
|
2955
|
+
? (o.lanes as Record<string, unknown> | undefined)?.css
|
|
2956
|
+
: undefined;
|
|
2957
|
+
if (typeof o.doc === 'string' && typeof css === 'string') {
|
|
2958
|
+
if (result.status === 'accepted') drainedCss.set(o.doc, css);
|
|
2959
|
+
else drainedCss.delete(o.doc);
|
|
2960
|
+
}
|
|
2877
2961
|
if (typeof o.doc !== 'string' || typeof html !== 'string') continue;
|
|
2878
2962
|
if (result.status === 'accepted') own.set(o.doc, html);
|
|
2879
2963
|
else own.delete(o.doc);
|
|
@@ -2902,6 +2986,11 @@ export function createSyncRuntime(
|
|
|
2902
2986
|
const slug = slugFromDocName(stone.name);
|
|
2903
2987
|
if (slug) tombstoned.add(slug);
|
|
2904
2988
|
}
|
|
2989
|
+
// #7 — a deletion made while no studio ran (an in-process `ds convert --restore`) is a
|
|
2990
|
+
// deletion too: the boot pull must not fetch it back; it is told below, once the outbound
|
|
2991
|
+
// lane is up (sync/pending-deletes.ts).
|
|
2992
|
+
const offlineDeletes = takePendingDeletes(ctx.paths.designRoot);
|
|
2993
|
+
for (const d of offlineDeletes) tombstoned.add(d.slug);
|
|
2905
2994
|
noteHubListing(remoteListing?.documents ?? null);
|
|
2906
2995
|
const remoteDiff = diffRemoteDocs(
|
|
2907
2996
|
localCanvases.map((c) => docNameFor(c.slug)),
|
|
@@ -3888,6 +3977,8 @@ export function createSyncRuntime(
|
|
|
3888
3977
|
// previous run left (S6.13) has made it a member by now.
|
|
3889
3978
|
const drained = await outboxDrained;
|
|
3890
3979
|
const ownAccepted = drained.get(docName) ?? null;
|
|
3980
|
+
const ownAcceptedCss = drainedCss.get(docName) ?? null;
|
|
3981
|
+
drainedCss.delete(docName);
|
|
3891
3982
|
// S6.13b — a canvas this Mac renamed because its name was taken joins
|
|
3892
3983
|
// as that renamed create did.
|
|
3893
3984
|
const renamed = renamedCreates.get(docName);
|
|
@@ -3925,6 +4016,7 @@ export function createSyncRuntime(
|
|
|
3925
4016
|
journal: journal ?? undefined,
|
|
3926
4017
|
commentLedger: commentLedgerFor(ctx.paths.designRoot),
|
|
3927
4018
|
ownAccepted,
|
|
4019
|
+
ownAcceptedCss,
|
|
3928
4020
|
wasAccepted: (content) => acceptedLink.client.holdsValue(content),
|
|
3929
4021
|
createDoc:
|
|
3930
4022
|
createdHere !== null
|
|
@@ -4478,6 +4570,10 @@ export function createSyncRuntime(
|
|
|
4478
4570
|
// provider. NB: cold-start seeding of a divergent local+hub doc is the
|
|
4479
4571
|
// duplication trap (Risk 1) — made safe by Phase E (migrate-seed); the
|
|
4480
4572
|
// flag stays OFF until then.
|
|
4573
|
+
// fix/205 — a room left over from an earlier attach of this slug (no
|
|
4574
|
+
// provider pins it, no browser is in it) holds that earlier doc's
|
|
4575
|
+
// lineage. Never re-attach to it: start from a fresh doc, as at boot.
|
|
4576
|
+
if (useSharedDoc) await opts.registry?.discard?.(canvas.slug);
|
|
4481
4577
|
const sharedYDoc = useSharedDoc ? opts.registry?.getDoc?.(canvas.slug) : undefined;
|
|
4482
4578
|
if (useSharedDoc && sharedYDoc) {
|
|
4483
4579
|
opts.registry?.pin?.(canvas.slug);
|
|
@@ -4881,7 +4977,12 @@ export function createSyncRuntime(
|
|
|
4881
4977
|
);
|
|
4882
4978
|
if (added.length === 0 && removed.length === 0) return;
|
|
4883
4979
|
if (removed.length > 0) {
|
|
4884
|
-
for (const slug of removed)
|
|
4980
|
+
for (const slug of removed) {
|
|
4981
|
+
// Gone from this disk is gone from here; a body still on disk
|
|
4982
|
+
// (a `syncable: false` sidecar) keeps its room.
|
|
4983
|
+
const body = descriptors.get(slug)?.html;
|
|
4984
|
+
await releaseOne(slug, { gone: !body || !existsSync(body) });
|
|
4985
|
+
}
|
|
4885
4986
|
console.log(`[sync] released ${removed.length} canvas(es): ${removed.join(', ')}`);
|
|
4886
4987
|
// The marker set shrank. It describes what a peer can WRITE to, so a
|
|
4887
4988
|
// stale entry over-lists — the safe direction, and still wrong: it is
|
|
@@ -4972,6 +5073,11 @@ export function createSyncRuntime(
|
|
|
4972
5073
|
createdUnsub = ctx.bus.on('canvas-created', (p: { slug?: unknown }) =>
|
|
4973
5074
|
noteToHub(p?.slug, true)
|
|
4974
5075
|
);
|
|
5076
|
+
// #7 — the deletions written down while no studio ran, told the way the routes tell them.
|
|
5077
|
+
for (const d of offlineDeletes) {
|
|
5078
|
+
console.log(`[sync] telling the project ${d.rel} was deleted while Maude was closed.`);
|
|
5079
|
+
ctx.bus.emit('canvas-deleted', { slug: d.slug });
|
|
5080
|
+
}
|
|
4975
5081
|
|
|
4976
5082
|
/**
|
|
4977
5083
|
* Apply the project's deletions to this machine.
|
|
@@ -4998,7 +5104,7 @@ export function createSyncRuntime(
|
|
|
4998
5104
|
if (gone.length === 0) return;
|
|
4999
5105
|
for (const slug of gone) {
|
|
5000
5106
|
const canvas = descriptors.get(slug);
|
|
5001
|
-
await releaseOne(slug);
|
|
5107
|
+
await releaseOne(slug, { gone: true });
|
|
5002
5108
|
if (canvas) {
|
|
5003
5109
|
quarantineCanvas({
|
|
5004
5110
|
designRoot: ctx.paths.designRoot,
|
|
@@ -5193,12 +5299,35 @@ export function createSyncRuntime(
|
|
|
5193
5299
|
p: import('./seed-progress.ts').SeedProgress,
|
|
5194
5300
|
r: import('./file-plane.ts').FilePlaneResult
|
|
5195
5301
|
): void => {
|
|
5196
|
-
if (p.phase === 'converged') return;
|
|
5197
5302
|
const blockedTotal = p.blocked.reduce((n, b) => n + b.count, 0);
|
|
5198
5303
|
const bits = [`${p.delivered} / ${p.tracked} delivered`];
|
|
5199
|
-
|
|
5304
|
+
// Failing files are not "waiting": they retry with backoff, and the line names one and why.
|
|
5305
|
+
const retrying = p.retrying ?? 0;
|
|
5306
|
+
const waiting = Math.max(0, p.remaining - retrying);
|
|
5307
|
+
if (waiting > 0) bits.push(`${waiting} waiting`);
|
|
5308
|
+
if (retrying > 0 && p.retryingFile) {
|
|
5309
|
+
bits.push(
|
|
5310
|
+
`${retrying} retrying — ${p.retryingFile.rel}: ${p.retryingFile.reason}${retrying > 1 ? ` (and ${retrying - 1} more)` : ''}`
|
|
5311
|
+
);
|
|
5312
|
+
}
|
|
5200
5313
|
if (blockedTotal > 0) bits.push(`${blockedTotal} need attention`);
|
|
5314
|
+
// Issue #204 — rows this Mac refuses are HELD, not waiting: they never move on their own, so
|
|
5315
|
+
// the line says how many and why instead of "N waiting" every 20 s forever.
|
|
5316
|
+
const held = p.held ?? 0;
|
|
5317
|
+
if (held > 0) bits.push(`${held} held: shared code not accepted on this Mac`);
|
|
5201
5318
|
if (r.backedOff) bits.push(`${r.backedOff} backing off`);
|
|
5319
|
+
if (r.storageMisses) bits.push(`${r.storageMisses} still coming from cloud storage`);
|
|
5320
|
+
// NOTHING MOVING ⇒ SAY IT ONCE. A converged or only-held/blocked project prints its line when
|
|
5321
|
+
// it changes, never again on a timer — that is what made "12 waiting" repeat forever.
|
|
5322
|
+
if (waiting === 0 && !r.rateLimited) {
|
|
5323
|
+
if (p.phase === 'converged' && held === 0) return;
|
|
5324
|
+
const still = `[sync/files] ${bits.join(' · ')}`;
|
|
5325
|
+
if (still === lastProgressLine) return;
|
|
5326
|
+
lastProgressLine = still;
|
|
5327
|
+
lastProgressLogAt = Date.now();
|
|
5328
|
+
console.log(still);
|
|
5329
|
+
return;
|
|
5330
|
+
}
|
|
5202
5331
|
let tail = '';
|
|
5203
5332
|
if (r.rateLimited) {
|
|
5204
5333
|
const secs = Math.max(1, Math.round((r.rateLimited.until - Date.now()) / 1000));
|
|
@@ -5247,14 +5376,37 @@ export function createSyncRuntime(
|
|
|
5247
5376
|
}
|
|
5248
5377
|
return bytes > 0 ? { bytes, ms } : null;
|
|
5249
5378
|
};
|
|
5379
|
+
const legacyPullGate = createLegacyPullGate({ baseMs: REMOTE_POLL_MS });
|
|
5380
|
+
const legacyPullFailures = createPullFailureMemory();
|
|
5250
5381
|
const noteFilePull = (result: FilePullResult): void => {
|
|
5251
5382
|
fileTotals.synced = result.skipped + result.pulled.length;
|
|
5252
5383
|
fileTotals.pulled += result.pulled.length;
|
|
5253
5384
|
fileTotals.conflicts += result.conflicts.length;
|
|
5385
|
+
// 2.0.5 — a file that could not land is HELD, and the panel says which and
|
|
5386
|
+
// why, like any other held file (it used to be a log line, every pass).
|
|
5387
|
+
const waiting = [
|
|
5388
|
+
...(result.held ?? []),
|
|
5389
|
+
...result.failed.filter((f) => !/budget/.test(f.reason)),
|
|
5390
|
+
];
|
|
5391
|
+
const held: NonNullable<FilePlaneStatus['held']> =
|
|
5392
|
+
waiting.length > 0
|
|
5393
|
+
? [
|
|
5394
|
+
{
|
|
5395
|
+
kind: 'pull-failed',
|
|
5396
|
+
count: waiting.length,
|
|
5397
|
+
paths: waiting.map((w) => w.rel).slice(0, 200),
|
|
5398
|
+
detail: `${waiting.length} file(s) from the project could not be saved on this Mac (${
|
|
5399
|
+
waiting[0]?.reason ?? 'unknown reason'
|
|
5400
|
+
}). Sync tries them again later, less often; nothing else waits for them.`,
|
|
5401
|
+
},
|
|
5402
|
+
]
|
|
5403
|
+
: [];
|
|
5254
5404
|
// A journal-less hub's pass is the whole comparison there: say so, once the lane is decided.
|
|
5255
5405
|
statusStore?.updateFiles?.({
|
|
5256
5406
|
...fileTotals,
|
|
5257
5407
|
...(legacyLane === true ? { lane: 'v1' as const } : {}),
|
|
5408
|
+
...(held.length > 0 ? { held } : {}),
|
|
5409
|
+
...(result.failed.length > 0 ? { failed: result.failed.length } : {}),
|
|
5258
5410
|
});
|
|
5259
5411
|
};
|
|
5260
5412
|
/**
|
|
@@ -5295,7 +5447,9 @@ export function createSyncRuntime(
|
|
|
5295
5447
|
? { passCapped: 'requests' as const }
|
|
5296
5448
|
: result.budgetExhausted
|
|
5297
5449
|
? { passCapped: 'bytes' as const }
|
|
5298
|
-
:
|
|
5450
|
+
: result.filesCapped
|
|
5451
|
+
? { passCapped: 'files' as const }
|
|
5452
|
+
: {}),
|
|
5299
5453
|
previous: lastSeedProgress,
|
|
5300
5454
|
deliveredSince: throughputSample(result),
|
|
5301
5455
|
})
|
|
@@ -5351,9 +5505,9 @@ export function createSyncRuntime(
|
|
|
5351
5505
|
}`,
|
|
5352
5506
|
});
|
|
5353
5507
|
}
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5508
|
+
// Per-file failures are named by the plane itself — once per file and reason, with when it
|
|
5509
|
+
// tries again (#204 follow-up). Repeating every failed row here on every pass was what made
|
|
5510
|
+
// a file that kept failing read as noise rather than as one named problem.
|
|
5357
5511
|
// A pass that landed bytes widened the hub-written set, so the
|
|
5358
5512
|
// untrusted-context markers have to describe it. Cheap and idempotent —
|
|
5359
5513
|
// the writer rebuilds the whole set each call — but only when something
|
|
@@ -5385,14 +5539,26 @@ export function createSyncRuntime(
|
|
|
5385
5539
|
await runPlanePass({ floor: false });
|
|
5386
5540
|
return;
|
|
5387
5541
|
}
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5542
|
+
// 2.0.5 — THE v1 PULL RUNS ONLY ON A HUB THAT SAID IT HAS NO JOURNAL. While
|
|
5543
|
+
// the lane probe is unanswered (or still in flight) no file lane runs: a
|
|
5544
|
+
// ledger hub that was merely slow must not get the legacy pull, which has
|
|
5545
|
+
// no ledger, resurrects what this person deleted, and cannot hold a file.
|
|
5546
|
+
if (legacyLane !== true) return;
|
|
5547
|
+
// One pass at a time; a pass that moved nothing backs off. Against a slow
|
|
5548
|
+
// hub every 20 s tick used to start ANOTHER pass over the same 200 files.
|
|
5549
|
+
await legacyPullGate.run(() =>
|
|
5550
|
+
pullFiles({
|
|
5551
|
+
designRoot: ctx.paths.designRoot,
|
|
5552
|
+
hubUrl: linkedHub.url,
|
|
5553
|
+
token: () => token,
|
|
5554
|
+
canvasGroups: ctx.cfg.canvasGroups,
|
|
5555
|
+
allowCodeModules,
|
|
5556
|
+
failures: legacyPullFailures,
|
|
5557
|
+
}).then((result) => {
|
|
5558
|
+
if (!stopped) noteFilePull(result);
|
|
5559
|
+
return result;
|
|
5560
|
+
})
|
|
5561
|
+
);
|
|
5396
5562
|
};
|
|
5397
5563
|
documentDiscovery = createDocumentDiscovery({
|
|
5398
5564
|
run: pullRemoteOnce,
|
|
@@ -5721,143 +5887,175 @@ export function createSyncRuntime(
|
|
|
5721
5887
|
// Not started in a cell: there the CHILD holds this channel (ws.ts), and
|
|
5722
5888
|
// its job is healing the UI rather than triggering pulls.
|
|
5723
5889
|
if (!cellPairing && ctx.cfg.linkedHub?.fileEvents !== false) {
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
}
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
//
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5890
|
+
// 2.0.5 — THE LANE IS DECIDED FROM AN ANSWER. `probeFileLane` retries with
|
|
5891
|
+
// a backoff and a longer ceiling; a hub that still has not answered is
|
|
5892
|
+
// asked again in a minute, and until then NO file lane runs (pushes and
|
|
5893
|
+
// the v1 pull both wait on `legacyLane`). It used to read one 4 s timeout
|
|
5894
|
+
// as "no journal" and run the legacy lane for the whole boot.
|
|
5895
|
+
let laneUnansweredSaid = false;
|
|
5896
|
+
const reprobeLane = (): void => {
|
|
5897
|
+
if (stopped) return;
|
|
5898
|
+
laneProbeTimer = setTimeout(probeLane, LANE_REPROBE_MS);
|
|
5899
|
+
laneProbeTimer.unref?.();
|
|
5900
|
+
};
|
|
5901
|
+
const probeLane = (): void => {
|
|
5902
|
+
laneProbeTimer = null;
|
|
5903
|
+
if (stopped) return;
|
|
5904
|
+
fileEventsProbe = new AbortController();
|
|
5905
|
+
void probeFileLane({ hubUrl: linkedHub.url, signal: fileEventsProbe.signal })
|
|
5906
|
+
.then(({ lane, capabilities: caps, formatVersion: hubFormat }) => {
|
|
5907
|
+
if (stopped) return;
|
|
5908
|
+
if (lane === 'unknown') {
|
|
5909
|
+
if (!laneUnansweredSaid) {
|
|
5910
|
+
laneUnansweredSaid = true;
|
|
5911
|
+
console.warn(
|
|
5912
|
+
`[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.`
|
|
5913
|
+
);
|
|
5914
|
+
}
|
|
5915
|
+
reprobeLane();
|
|
5916
|
+
return;
|
|
5917
|
+
}
|
|
5918
|
+
// V2-1.12 §5.5 — `/health` names the project's format.
|
|
5919
|
+
noteHubFormatSeen(hubFormat);
|
|
5920
|
+
// DDR-242 — a hub that predates the annotations-v2 model still keeps
|
|
5921
|
+
// boards as SVG: its workspace checkout and kernel would not carry
|
|
5922
|
+
// this studio's `.annotations.json` edits. Say so loudly; the
|
|
5923
|
+
// annotations themselves stay safe (a v1 hub never writes the v2
|
|
5924
|
+
// replica, and this studio never reads its SVG as authoritative).
|
|
5925
|
+
if (caps !== null && !hasAnnotationsV2(caps)) {
|
|
5926
|
+
console.warn(
|
|
5927
|
+
`[sync] ${linkedHub.url} does not advertise annotations-v2 — update the hub; ` +
|
|
5928
|
+
'whiteboard edits will not reach its checkout until it is'
|
|
5929
|
+
);
|
|
5930
|
+
}
|
|
5931
|
+
// fix/205 — whether this hub's doors take paths deeper than 8 segments (both lanes).
|
|
5932
|
+
legacyHubTakesDeepPaths = hasFileDepthV2(caps);
|
|
5933
|
+
if (!hasLedger(caps)) {
|
|
5934
|
+
// No journal on this hub ⇒ the legacy client carries the upward
|
|
5935
|
+
// lane, exactly as the pre-v2 desktop did (Open decision 4).
|
|
5936
|
+
decidePushLane(true);
|
|
5937
|
+
return;
|
|
5938
|
+
}
|
|
5939
|
+
// The hub carries a journal, so the file plane becomes the ONE lane
|
|
5940
|
+
// for this project. Built here rather than at start(): a client must
|
|
5941
|
+
// never send a journal request to a hub that would not understand
|
|
5942
|
+
// it (compat matrix §10 — BINDING).
|
|
5943
|
+
if (syncFilesOn && !filePlane) {
|
|
5944
|
+
fileLedger = createFileLedger({
|
|
5945
|
+
designRoot: ctx.paths.designRoot,
|
|
5946
|
+
hubUrl: linkedHub.url,
|
|
5947
|
+
});
|
|
5948
|
+
filePlane = createFilePlane({
|
|
5949
|
+
designRoot: ctx.paths.designRoot,
|
|
5950
|
+
hubUrl: linkedHub.url,
|
|
5951
|
+
token: () => token,
|
|
5952
|
+
// THE FILE PLANE CAN NOW ASK FOR A CREDENTIAL. It could not
|
|
5953
|
+
// before: renewal was reachable only from the doc lane's
|
|
5954
|
+
// WebSocket auth failure, so a token that expired mid-seed left
|
|
5955
|
+
// hundreds of files refused with nothing ever asking for a new
|
|
5956
|
+
// one (2026-09-03). Same single-flight entry point the doc lane
|
|
5957
|
+
// uses — never a second renewal path.
|
|
5958
|
+
onAuthFailure: () => {
|
|
5959
|
+
void renewCredentialNow();
|
|
5960
|
+
},
|
|
5961
|
+
// V2-1.12 §5.4 — a 426 is the FORMAT door, never a credential
|
|
5962
|
+
// failure: mirror what the hub named; nothing is renewed.
|
|
5963
|
+
onFormatRefused: (fv) => noteHubFormatSeen(fv),
|
|
5964
|
+
outboundPaused,
|
|
5965
|
+
fetchImpl: hubFetch,
|
|
5966
|
+
// A DELIVERED FILE IS PROGRESS. `renewalsSinceProgress` counted
|
|
5967
|
+
// only doc handshakes, and a converged doc lane has none left to
|
|
5968
|
+
// land — so during a long seed the cap was reached and the
|
|
5969
|
+
// runtime stopped renewing while the file plane was still
|
|
5970
|
+
// working.
|
|
5971
|
+
onProgress: () => {
|
|
5972
|
+
renewalsSinceProgress = 0;
|
|
5973
|
+
lastFileProgressAt = Date.now();
|
|
5974
|
+
},
|
|
5975
|
+
// S10.3b — a delivered file is a PEER's change (the DS outside watcher's `peer`).
|
|
5976
|
+
onDelivered: (rel) => ctx.bus.emit('file-plane:delivered', { rel }),
|
|
5977
|
+
ledger: fileLedger,
|
|
5978
|
+
canvasGroups: ctx.cfg.canvasGroups,
|
|
5979
|
+
allowCodeModules,
|
|
5980
|
+
canUploadCodeModules: cellPairing !== null || isProjectOwner,
|
|
5981
|
+
// Issue #175 — a 1.x hub's door refuses the 2.0-only files with a 400; it is not
|
|
5982
|
+
// offered them (they are held, with a reason, in Sync details).
|
|
5983
|
+
hubTakesV2Files: hasFileClassesV2(caps),
|
|
5984
|
+
// fix/205 — an older hub refuses paths deeper than 8 segments; held, with a reason.
|
|
5985
|
+
hubTakesDeepPaths: hasFileDepthV2(caps),
|
|
5986
|
+
unlimitedOutboundDeletes: unlimitedDeletes,
|
|
5987
|
+
// Increment 6, DEFAULT ON: a hub-owned mirror that ignores
|
|
5988
|
+
// deletes contradicts the model it is selling — you delete a
|
|
5989
|
+
// file and it comes back. `linkedHub.propagateDeletes: false`
|
|
5990
|
+
// is the per-project opt-out; the breakers hold either way.
|
|
5991
|
+
propagateDeletes: linkedHub.propagateDeletes !== false,
|
|
5992
|
+
// The answer to a first-anchor hold. A config key rather than a
|
|
5993
|
+
// prompt because the hold outlives the pass that raised it, and
|
|
5994
|
+
// DDR-177's user has no terminal to answer in.
|
|
5995
|
+
...(linkedHub.resolveFirstAnchor === 'keep-local' ||
|
|
5996
|
+
linkedHub.resolveFirstAnchor === 'keep-cloud'
|
|
5997
|
+
? { resolveFirstAnchor: linkedHub.resolveFirstAnchor }
|
|
5998
|
+
: {}),
|
|
5999
|
+
// Same exposure class as `syncMeta.by`, and the same reasoning:
|
|
6000
|
+
// a conflict copy nobody can attribute is a conflict copy nobody
|
|
6001
|
+
// resolves.
|
|
6002
|
+
label: hostname().slice(0, 32),
|
|
6003
|
+
});
|
|
6004
|
+
// S8.19 — the plane's held report (`/_asset-probe` held + sweep.final). This block
|
|
6005
|
+
// is already `!cellPairing`; the token is read per send (silent renewal).
|
|
6006
|
+
heldReporter = createHeldReporter({
|
|
6007
|
+
designRoot: ctx.paths.designRoot,
|
|
6008
|
+
canvasGroups: ctx.cfg.canvasGroups,
|
|
6009
|
+
send: (rels) =>
|
|
6010
|
+
reportHeld({ fetchImpl: hubFetch, base: linkedHub.url, token, rels }),
|
|
6011
|
+
});
|
|
6012
|
+
console.log(
|
|
6013
|
+
'[sync/files] journal file plane active — one lane, both directions, per-file delivery state in the Sync panel.'
|
|
6014
|
+
);
|
|
6015
|
+
// Anything the local disk already differs on goes now, rather than
|
|
6016
|
+
// at the first 20 s tick.
|
|
6017
|
+
schedulePlanePass();
|
|
6018
|
+
}
|
|
6019
|
+
// A ledger hub with the plane ON owns pushes; with the file-plane
|
|
6020
|
+
// flag OFF the legacy client still carries the DDR-217 assets lane.
|
|
6021
|
+
decidePushLane(filePlane === null);
|
|
6022
|
+
makeFileEventsCtl = () =>
|
|
6023
|
+
createCtlProvider({
|
|
6024
|
+
url: linkedHub.url,
|
|
6025
|
+
token,
|
|
6026
|
+
onDocuments: () => documentDiscovery?.schedule(),
|
|
6027
|
+
// S5.3 — server.ts forwards it to the AI run registry (`registry.poke`).
|
|
6028
|
+
onRuns: (seq) => ctx.bus.emit('hub:runs', { seq }),
|
|
6029
|
+
onPoke: () => {
|
|
6030
|
+
// Reuses `pollRemoteSoon` rather than calling the file lanes
|
|
6031
|
+
// directly, for two reasons: it already coalesces a burst into
|
|
6032
|
+
// one pass (a fresh link appends hundreds of rows), and it is
|
|
6033
|
+
// the exact path a reconnect takes — one behaviour to reason
|
|
6034
|
+
// about instead of two that can drift.
|
|
6035
|
+
//
|
|
6036
|
+
// The PULL itself is unchanged: missing-only, idempotent, and
|
|
6037
|
+
// re-validating everything it accepts. So a poke can at worst
|
|
6038
|
+
// cost one early pass, and the scheduled poll remains the
|
|
6039
|
+
// reconciler underneath it.
|
|
6040
|
+
pokesSeen += 1;
|
|
6041
|
+
pollRemoteSoon({ cooled: true });
|
|
6042
|
+
},
|
|
6043
|
+
});
|
|
6044
|
+
// A desktop that parked before the capability probe answered keeps
|
|
6045
|
+
// the channel closed; the unpark builds it.
|
|
6046
|
+
if (!parkedNow) fileEventsCtl = makeFileEventsCtl();
|
|
5817
6047
|
console.log(
|
|
5818
|
-
'[sync/
|
|
6048
|
+
'[sync/ctl] file-event channel attached — cloud changes now arrive in seconds instead of on the 20 s tick.'
|
|
5819
6049
|
);
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
url: linkedHub.url,
|
|
5830
|
-
token,
|
|
5831
|
-
onDocuments: () => documentDiscovery?.schedule(),
|
|
5832
|
-
// S5.3 — server.ts forwards it to the AI run registry (`registry.poke`).
|
|
5833
|
-
onRuns: (seq) => ctx.bus.emit('hub:runs', { seq }),
|
|
5834
|
-
onPoke: () => {
|
|
5835
|
-
// Reuses `pollRemoteSoon` rather than calling the file lanes
|
|
5836
|
-
// directly, for two reasons: it already coalesces a burst into
|
|
5837
|
-
// one pass (a fresh link appends hundreds of rows), and it is
|
|
5838
|
-
// the exact path a reconnect takes — one behaviour to reason
|
|
5839
|
-
// about instead of two that can drift.
|
|
5840
|
-
//
|
|
5841
|
-
// The PULL itself is unchanged: missing-only, idempotent, and
|
|
5842
|
-
// re-validating everything it accepts. So a poke can at worst
|
|
5843
|
-
// cost one early pass, and the scheduled poll remains the
|
|
5844
|
-
// reconciler underneath it.
|
|
5845
|
-
pokesSeen += 1;
|
|
5846
|
-
pollRemoteSoon({ cooled: true });
|
|
5847
|
-
},
|
|
5848
|
-
});
|
|
5849
|
-
// A desktop that parked before the capability probe answered keeps
|
|
5850
|
-
// the channel closed; the unpark builds it.
|
|
5851
|
-
if (!parkedNow) fileEventsCtl = makeFileEventsCtl();
|
|
5852
|
-
console.log(
|
|
5853
|
-
'[sync/ctl] file-event channel attached — cloud changes now arrive in seconds instead of on the 20 s tick.'
|
|
5854
|
-
);
|
|
5855
|
-
})
|
|
5856
|
-
.catch(() => {
|
|
5857
|
-
// No capability probe ⇒ no channel ⇒ exactly today's behaviour —
|
|
5858
|
-
// which, for pushes, is the legacy client.
|
|
5859
|
-
decidePushLane(true);
|
|
5860
|
-
});
|
|
6050
|
+
})
|
|
6051
|
+
.catch((err) => {
|
|
6052
|
+
// A throw in the verdict's own handling is not an answer about the
|
|
6053
|
+
// hub: never a reason to pick the legacy lane (2.0.5). Ask again.
|
|
6054
|
+
console.error('[sync/files] the lane probe failed:', err);
|
|
6055
|
+
if (legacyLane === null) reprobeLane();
|
|
6056
|
+
});
|
|
6057
|
+
};
|
|
6058
|
+
probeLane();
|
|
5861
6059
|
} else if (!cellPairing) {
|
|
5862
6060
|
// The probe is opted out (`linkedHub.fileEvents: false`), so no verdict
|
|
5863
6061
|
// will ever arrive — the legacy client is the lane, as it always was.
|
|
@@ -5878,6 +6076,8 @@ export function createSyncRuntime(
|
|
|
5878
6076
|
revisionBarrier.stop();
|
|
5879
6077
|
fileEventsProbe?.abort();
|
|
5880
6078
|
fileEventsProbe = null;
|
|
6079
|
+
if (laneProbeTimer !== null) clearTimeout(laneProbeTimer);
|
|
6080
|
+
laneProbeTimer = null;
|
|
5881
6081
|
if (filePassTimer !== null) clearTimeout(filePassTimer);
|
|
5882
6082
|
filePassTimer = null;
|
|
5883
6083
|
planeResultSink = null;
|
|
@@ -6331,6 +6531,12 @@ export function createSyncRuntime(
|
|
|
6331
6531
|
const r = await acceptedLink.laneAt(slug, lane, revision);
|
|
6332
6532
|
return r.body || null;
|
|
6333
6533
|
},
|
|
6534
|
+
settleSource: async (repoRel, ms) => {
|
|
6535
|
+
if (!acceptedOn() || !acceptedLink) return null;
|
|
6536
|
+
const slug = slugForRepoRel(repoRel);
|
|
6537
|
+
const projection = slug ? projections.get(slug) : undefined;
|
|
6538
|
+
return projection ? projection.settleDisk(ms) : null;
|
|
6539
|
+
},
|
|
6334
6540
|
acceptedRestore: async (repoRel, revision, o) => {
|
|
6335
6541
|
if (!acceptedOn() || !acceptedLink) return null;
|
|
6336
6542
|
const slug = slugForRepoRel(repoRel);
|
|
@@ -6418,8 +6624,10 @@ export function createSyncRuntime(
|
|
|
6418
6624
|
);
|
|
6419
6625
|
return ids.ok ? ids.actionIds : null;
|
|
6420
6626
|
},
|
|
6421
|
-
|
|
6422
|
-
|
|
6627
|
+
// #166 R3 — aborted at the check's deadline, capped while they stream in
|
|
6628
|
+
blob: (hash, signal) => link.blob(hash, { signal, maxBytes: HUB_UNDO_READ_MAX_BYTES }),
|
|
6629
|
+
head: (doc, signal) =>
|
|
6630
|
+
link.laneHead(doc, 'annotations', { signal, maxBytes: HUB_UNDO_READ_MAX_BYTES }),
|
|
6423
6631
|
});
|
|
6424
6632
|
},
|
|
6425
6633
|
acceptedTrash: async () => {
|
|
@@ -6503,10 +6711,22 @@ export function createSyncRuntime(
|
|
|
6503
6711
|
return { status: 'taken' };
|
|
6504
6712
|
}
|
|
6505
6713
|
if (sides.mine === null) return { status: 'rejected', code: 'no-local-version' };
|
|
6714
|
+
// #14 — the css twin's side first (read before the html proposal can move anything): a
|
|
6715
|
+
// conflict on the css lane is the canvas's conflict too, and Keep mine that answered only
|
|
6716
|
+
// the html left the css held here and the project's css in the project — the notice went,
|
|
6717
|
+
// and came back after the next restart.
|
|
6718
|
+
const css = projection.heldCss();
|
|
6506
6719
|
// Mine, on top of the version that won — a new action, never a rewind.
|
|
6507
6720
|
const r = await projection.proposeLane('html', sides.mine, { baseContent: sides.theirs });
|
|
6508
6721
|
if (!r) return null;
|
|
6509
|
-
if (r.status
|
|
6722
|
+
if (r.status !== 'accepted') return { status: r.status, ...(r.code ? { code: r.code } : {}) };
|
|
6723
|
+
if (css && css.mine !== null) {
|
|
6724
|
+
const c = await projection.proposeLane('css', css.mine, { baseContent: css.theirs });
|
|
6725
|
+
if (!c) return null;
|
|
6726
|
+
if (c.status !== 'accepted')
|
|
6727
|
+
return { status: c.status, ...(c.code ? { code: c.code } : {}) };
|
|
6728
|
+
}
|
|
6729
|
+
statusStore?.clearSourceConflict?.(slug);
|
|
6510
6730
|
return { status: r.status, ...(r.code ? { code: r.code } : {}) };
|
|
6511
6731
|
},
|
|
6512
6732
|
beginAiAction: (key, label, meta) => {
|