@1agh/maude 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/actions/agents.ts +5 -0
- package/apps/studio/actions/defs/app.ts +12 -0
- package/apps/studio/actions.manifest.json +13 -1
- package/apps/studio/actions.parity.json +7 -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 +42 -0
- 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/_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 +89 -12
- 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/canvas-lib.tsx +131 -12
- package/apps/studio/client/canvas-url.js +13 -0
- 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 +6 -0
- 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-project-data.jsx +2 -0
- package/apps/studio/client/panels/ChatPanel.jsx +27 -20
- package/apps/studio/client/panels/CreateProject.jsx +19 -5
- package/apps/studio/client/panels/caps-cache.js +46 -0
- package/apps/studio/client/shell/viewport.jsx +36 -8
- 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/Composer.jsx +27 -10
- 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/code-bus.js +5 -0
- package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
- 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 -15
- package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
- package/apps/studio/client/v2/ds/review-host.jsx +7 -1
- package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
- package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
- 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 +3 -1
- package/apps/studio/client/v2/history/git-parts.jsx +16 -1
- package/apps/studio/client/v2/presence/faces.jsx +42 -14
- 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 +11 -0
- 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/share-cluster-host.jsx +137 -10
- 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/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/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 +1232 -1232
- 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/history/trash.ts +6 -0
- package/apps/studio/home/accounts.ts +87 -0
- package/apps/studio/home/index-reader.ts +24 -2
- package/apps/studio/home/routes.ts +19 -0
- package/apps/studio/http.ts +14 -2
- package/apps/studio/routes/ds-convert.ts +18 -0
- package/apps/studio/routes/trash.ts +16 -1
- package/apps/studio/server.ts +8 -10
- package/apps/studio/sync/accepted-cold-start.ts +28 -13
- package/apps/studio/sync/asset-push.ts +146 -23
- package/apps/studio/sync/asset-state.ts +3 -2
- package/apps/studio/sync/file-membership.ts +28 -3
- package/apps/studio/sync/file-plane.ts +40 -9
- package/apps/studio/sync/file-pull.ts +304 -33
- package/apps/studio/sync/hub-link.ts +1 -2
- package/apps/studio/sync/index.ts +308 -150
- package/apps/studio/sync/journal-client.ts +94 -5
- package/apps/studio/sync/pending-deletes.ts +100 -0
- package/apps/studio/sync/projection.ts +77 -12
- package/apps/studio/sync/seed-progress.ts +12 -1
- package/apps/studio/sync/status.ts +3 -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/whats-new.json +72 -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/package.json +8 -8
|
@@ -91,7 +91,12 @@ import { createDocumentDiscovery } from './document-discovery.ts';
|
|
|
91
91
|
import { createEchoGuard, hashBytes } from './echo-guard.ts';
|
|
92
92
|
import { createFileLedger } from './file-ledger.ts';
|
|
93
93
|
import { createFilePlane, MAX_DORUCEKA_ROWS } from './file-plane.ts';
|
|
94
|
-
import {
|
|
94
|
+
import {
|
|
95
|
+
createLegacyPullGate,
|
|
96
|
+
createPullFailureMemory,
|
|
97
|
+
type FilePullResult,
|
|
98
|
+
pullFiles,
|
|
99
|
+
} from './file-pull.ts';
|
|
95
100
|
import {
|
|
96
101
|
declaredFormat,
|
|
97
102
|
formatFromHub,
|
|
@@ -107,7 +112,13 @@ import { type HubDocRow, hubHolds, indexHubDocs } from './hub-listing.ts';
|
|
|
107
112
|
import { HUB_UNDO_READ_MAX_BYTES, hubTextUndoConflict } from './hub-text-undo.ts';
|
|
108
113
|
import { accessFor, getHubRecord } from './hubs-config.ts';
|
|
109
114
|
import { loadJournal, type SyncJournal } from './journal.ts';
|
|
110
|
-
import {
|
|
115
|
+
import {
|
|
116
|
+
hasAnnotationsV2,
|
|
117
|
+
hasFileClassesV2,
|
|
118
|
+
hasFileDepthV2,
|
|
119
|
+
hasLedger,
|
|
120
|
+
probeFileLane,
|
|
121
|
+
} from './journal-client.ts';
|
|
111
122
|
import type { RestoreOptions } from './local-kernel.ts';
|
|
112
123
|
import { isLoopbackHost } from './loopback.ts';
|
|
113
124
|
import { createMediaGate, MEDIA_STAYS_LINE, readServerSignature } from './media-gate.ts';
|
|
@@ -126,6 +137,7 @@ import {
|
|
|
126
137
|
parkReducer,
|
|
127
138
|
parseCellState,
|
|
128
139
|
} from './park.ts';
|
|
140
|
+
import { takePendingDeletes } from './pending-deletes.ts';
|
|
129
141
|
import { hasSelfRetryingWork } from './presentation.ts';
|
|
130
142
|
import { createProjectConfigPusher } from './project-config-push.ts';
|
|
131
143
|
import { createDocProjection, type DocProjection } from './projection.ts';
|
|
@@ -320,6 +332,9 @@ export const DISCOVERY_DEBOUNCE_MS = 400;
|
|
|
320
332
|
*/
|
|
321
333
|
export const REMOTE_POLL_MS = 20_000;
|
|
322
334
|
|
|
335
|
+
/** 2.0.5 — how soon an unanswered lane probe asks the hub again. */
|
|
336
|
+
const LANE_REPROBE_MS = 60_000;
|
|
337
|
+
|
|
323
338
|
/**
|
|
324
339
|
* Does this studio run the FILE plane (Plane B) against its linked hub?
|
|
325
340
|
*
|
|
@@ -510,6 +525,11 @@ export interface AwarenessRegistry {
|
|
|
510
525
|
pin?(slug: string): void;
|
|
511
526
|
/** Release the shared-doc pin on runtime stop. */
|
|
512
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>;
|
|
513
533
|
}
|
|
514
534
|
|
|
515
535
|
/** Factory the runtime calls per discovered canvas. Default uses Hocuspocus. */
|
|
@@ -1354,6 +1374,8 @@ export function createSyncRuntime(
|
|
|
1354
1374
|
// two-doc agent path has no proposal lane and stays legacy.
|
|
1355
1375
|
/** Resolves once a previous run's outbox is drained: doc → own accepted html. */
|
|
1356
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>();
|
|
1357
1379
|
/** S6.13 — documents whose `doc.create` that drain had accepted: made BY
|
|
1358
1380
|
* THIS MAC in a previous run, so they join as a create, not a reconcile. */
|
|
1359
1381
|
const drainedCreates = new Set<string>();
|
|
@@ -1593,6 +1615,8 @@ export function createSyncRuntime(
|
|
|
1593
1615
|
* `true` = journal-less hub ⇒ this legacy client carries the upward lane.
|
|
1594
1616
|
*/
|
|
1595
1617
|
let legacyLane: boolean | null = null;
|
|
1618
|
+
/** fix/205 — the hub advertised `file-depth-v2` (set with the lane verdict). */
|
|
1619
|
+
let legacyHubTakesDeepPaths = false;
|
|
1596
1620
|
/** A pass was owed before the lane was decided — run it on the verdict. */
|
|
1597
1621
|
let legacyBootPush: string | null = null;
|
|
1598
1622
|
/**
|
|
@@ -1627,6 +1651,7 @@ export function createSyncRuntime(
|
|
|
1627
1651
|
// Read at call time — silent renewal swaps the credential in place.
|
|
1628
1652
|
token: () => token,
|
|
1629
1653
|
canvasGroups: ctx.cfg.canvasGroups,
|
|
1654
|
+
hubTakesDeepPaths: legacyHubTakesDeepPaths,
|
|
1630
1655
|
cancelled: () => legacyPushCancel || stopped,
|
|
1631
1656
|
// feature-sync-progress-modal — same `sync:status` payload as ever, so
|
|
1632
1657
|
// the Sync panel needs no idea which lane fed it. Guarded on `stopped`:
|
|
@@ -1894,6 +1919,8 @@ export function createSyncRuntime(
|
|
|
1894
1919
|
* suite long before it shows up as a bug.
|
|
1895
1920
|
*/
|
|
1896
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;
|
|
1897
1924
|
/**
|
|
1898
1925
|
* The Sync v2 file plane — ONE lane, both directions, one decision table.
|
|
1899
1926
|
*
|
|
@@ -2312,7 +2339,7 @@ export function createSyncRuntime(
|
|
|
2312
2339
|
const desc = descriptors.get(slug);
|
|
2313
2340
|
const provider = providers.get(slug);
|
|
2314
2341
|
const movedTo = provider ? movedToFromDoc(provider.document) : null;
|
|
2315
|
-
await releaseOne(slug);
|
|
2342
|
+
await releaseOne(slug, { gone: true });
|
|
2316
2343
|
if (!desc) return;
|
|
2317
2344
|
// HOLD until the canvas provably lives at its new path — parking the old
|
|
2318
2345
|
// copy while the new document is still materialising would leave a window
|
|
@@ -2396,7 +2423,17 @@ export function createSyncRuntime(
|
|
|
2396
2423
|
noteDetach(statusDetaches, slug, () => doc.off('update', onUpdate));
|
|
2397
2424
|
}
|
|
2398
2425
|
|
|
2399
|
-
|
|
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> {
|
|
2400
2437
|
const known = agents.has(slug) || projections.has(slug) || providers.has(slug);
|
|
2401
2438
|
if (!known) return false;
|
|
2402
2439
|
runDetaches(awarenessDetaches, slug);
|
|
@@ -2437,6 +2474,13 @@ export function createSyncRuntime(
|
|
|
2437
2474
|
/* best-effort */
|
|
2438
2475
|
}
|
|
2439
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
|
+
}
|
|
2440
2484
|
descriptors.delete(slug);
|
|
2441
2485
|
// Drop the row too — a released canvas that stayed `pending` in the status
|
|
2442
2486
|
// payload would be a permanent "still syncing" the user can never clear.
|
|
@@ -2903,6 +2947,17 @@ export function createSyncRuntime(
|
|
|
2903
2947
|
: o.op === 'doc.create'
|
|
2904
2948
|
? (o.lanes as Record<string, unknown> | undefined)?.html
|
|
2905
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
|
+
}
|
|
2906
2961
|
if (typeof o.doc !== 'string' || typeof html !== 'string') continue;
|
|
2907
2962
|
if (result.status === 'accepted') own.set(o.doc, html);
|
|
2908
2963
|
else own.delete(o.doc);
|
|
@@ -2931,6 +2986,11 @@ export function createSyncRuntime(
|
|
|
2931
2986
|
const slug = slugFromDocName(stone.name);
|
|
2932
2987
|
if (slug) tombstoned.add(slug);
|
|
2933
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);
|
|
2934
2994
|
noteHubListing(remoteListing?.documents ?? null);
|
|
2935
2995
|
const remoteDiff = diffRemoteDocs(
|
|
2936
2996
|
localCanvases.map((c) => docNameFor(c.slug)),
|
|
@@ -3917,6 +3977,8 @@ export function createSyncRuntime(
|
|
|
3917
3977
|
// previous run left (S6.13) has made it a member by now.
|
|
3918
3978
|
const drained = await outboxDrained;
|
|
3919
3979
|
const ownAccepted = drained.get(docName) ?? null;
|
|
3980
|
+
const ownAcceptedCss = drainedCss.get(docName) ?? null;
|
|
3981
|
+
drainedCss.delete(docName);
|
|
3920
3982
|
// S6.13b — a canvas this Mac renamed because its name was taken joins
|
|
3921
3983
|
// as that renamed create did.
|
|
3922
3984
|
const renamed = renamedCreates.get(docName);
|
|
@@ -3954,6 +4016,7 @@ export function createSyncRuntime(
|
|
|
3954
4016
|
journal: journal ?? undefined,
|
|
3955
4017
|
commentLedger: commentLedgerFor(ctx.paths.designRoot),
|
|
3956
4018
|
ownAccepted,
|
|
4019
|
+
ownAcceptedCss,
|
|
3957
4020
|
wasAccepted: (content) => acceptedLink.client.holdsValue(content),
|
|
3958
4021
|
createDoc:
|
|
3959
4022
|
createdHere !== null
|
|
@@ -4507,6 +4570,10 @@ export function createSyncRuntime(
|
|
|
4507
4570
|
// provider. NB: cold-start seeding of a divergent local+hub doc is the
|
|
4508
4571
|
// duplication trap (Risk 1) — made safe by Phase E (migrate-seed); the
|
|
4509
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);
|
|
4510
4577
|
const sharedYDoc = useSharedDoc ? opts.registry?.getDoc?.(canvas.slug) : undefined;
|
|
4511
4578
|
if (useSharedDoc && sharedYDoc) {
|
|
4512
4579
|
opts.registry?.pin?.(canvas.slug);
|
|
@@ -4910,7 +4977,12 @@ export function createSyncRuntime(
|
|
|
4910
4977
|
);
|
|
4911
4978
|
if (added.length === 0 && removed.length === 0) return;
|
|
4912
4979
|
if (removed.length > 0) {
|
|
4913
|
-
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
|
+
}
|
|
4914
4986
|
console.log(`[sync] released ${removed.length} canvas(es): ${removed.join(', ')}`);
|
|
4915
4987
|
// The marker set shrank. It describes what a peer can WRITE to, so a
|
|
4916
4988
|
// stale entry over-lists — the safe direction, and still wrong: it is
|
|
@@ -5001,6 +5073,11 @@ export function createSyncRuntime(
|
|
|
5001
5073
|
createdUnsub = ctx.bus.on('canvas-created', (p: { slug?: unknown }) =>
|
|
5002
5074
|
noteToHub(p?.slug, true)
|
|
5003
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
|
+
}
|
|
5004
5081
|
|
|
5005
5082
|
/**
|
|
5006
5083
|
* Apply the project's deletions to this machine.
|
|
@@ -5027,7 +5104,7 @@ export function createSyncRuntime(
|
|
|
5027
5104
|
if (gone.length === 0) return;
|
|
5028
5105
|
for (const slug of gone) {
|
|
5029
5106
|
const canvas = descriptors.get(slug);
|
|
5030
|
-
await releaseOne(slug);
|
|
5107
|
+
await releaseOne(slug, { gone: true });
|
|
5031
5108
|
if (canvas) {
|
|
5032
5109
|
quarantineCanvas({
|
|
5033
5110
|
designRoot: ctx.paths.designRoot,
|
|
@@ -5299,14 +5376,37 @@ export function createSyncRuntime(
|
|
|
5299
5376
|
}
|
|
5300
5377
|
return bytes > 0 ? { bytes, ms } : null;
|
|
5301
5378
|
};
|
|
5379
|
+
const legacyPullGate = createLegacyPullGate({ baseMs: REMOTE_POLL_MS });
|
|
5380
|
+
const legacyPullFailures = createPullFailureMemory();
|
|
5302
5381
|
const noteFilePull = (result: FilePullResult): void => {
|
|
5303
5382
|
fileTotals.synced = result.skipped + result.pulled.length;
|
|
5304
5383
|
fileTotals.pulled += result.pulled.length;
|
|
5305
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
|
+
: [];
|
|
5306
5404
|
// A journal-less hub's pass is the whole comparison there: say so, once the lane is decided.
|
|
5307
5405
|
statusStore?.updateFiles?.({
|
|
5308
5406
|
...fileTotals,
|
|
5309
5407
|
...(legacyLane === true ? { lane: 'v1' as const } : {}),
|
|
5408
|
+
...(held.length > 0 ? { held } : {}),
|
|
5409
|
+
...(result.failed.length > 0 ? { failed: result.failed.length } : {}),
|
|
5310
5410
|
});
|
|
5311
5411
|
};
|
|
5312
5412
|
/**
|
|
@@ -5439,14 +5539,26 @@ export function createSyncRuntime(
|
|
|
5439
5539
|
await runPlanePass({ floor: false });
|
|
5440
5540
|
return;
|
|
5441
5541
|
}
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
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
|
+
);
|
|
5450
5562
|
};
|
|
5451
5563
|
documentDiscovery = createDocumentDiscovery({
|
|
5452
5564
|
run: pullRemoteOnce,
|
|
@@ -5775,143 +5887,175 @@ export function createSyncRuntime(
|
|
|
5775
5887
|
// Not started in a cell: there the CHILD holds this channel (ws.ts), and
|
|
5776
5888
|
// its job is healing the UI rather than triggering pulls.
|
|
5777
5889
|
if (!cellPairing && ctx.cfg.linkedHub?.fileEvents !== false) {
|
|
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
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
//
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
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();
|
|
5871
6047
|
console.log(
|
|
5872
|
-
'[sync/
|
|
6048
|
+
'[sync/ctl] file-event channel attached — cloud changes now arrive in seconds instead of on the 20 s tick.'
|
|
5873
6049
|
);
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
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
|
-
});
|
|
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();
|
|
5915
6059
|
} else if (!cellPairing) {
|
|
5916
6060
|
// The probe is opted out (`linkedHub.fileEvents: false`), so no verdict
|
|
5917
6061
|
// will ever arrive — the legacy client is the lane, as it always was.
|
|
@@ -5932,6 +6076,8 @@ export function createSyncRuntime(
|
|
|
5932
6076
|
revisionBarrier.stop();
|
|
5933
6077
|
fileEventsProbe?.abort();
|
|
5934
6078
|
fileEventsProbe = null;
|
|
6079
|
+
if (laneProbeTimer !== null) clearTimeout(laneProbeTimer);
|
|
6080
|
+
laneProbeTimer = null;
|
|
5935
6081
|
if (filePassTimer !== null) clearTimeout(filePassTimer);
|
|
5936
6082
|
filePassTimer = null;
|
|
5937
6083
|
planeResultSink = null;
|
|
@@ -6565,10 +6711,22 @@ export function createSyncRuntime(
|
|
|
6565
6711
|
return { status: 'taken' };
|
|
6566
6712
|
}
|
|
6567
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();
|
|
6568
6719
|
// Mine, on top of the version that won — a new action, never a rewind.
|
|
6569
6720
|
const r = await projection.proposeLane('html', sides.mine, { baseContent: sides.theirs });
|
|
6570
6721
|
if (!r) return null;
|
|
6571
|
-
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);
|
|
6572
6730
|
return { status: r.status, ...(r.code ? { code: r.code } : {}) };
|
|
6573
6731
|
},
|
|
6574
6732
|
beginAiAction: (key, label, meta) => {
|