@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
|
@@ -53,7 +53,7 @@ import type { CommentLedger } from './comment-ledger.ts';
|
|
|
53
53
|
import { hashBytes } from './echo-guard.ts';
|
|
54
54
|
import type { SyncJournal } from './journal.ts';
|
|
55
55
|
import type { DocProjection, ProjectionPaths, ProposalLane } from './projection.ts';
|
|
56
|
-
import { readRecoveryBody, saveRecoveryBody } from './source-recovery.ts';
|
|
56
|
+
import { readRecoveryBody, readRecoveryCandidate, saveRecoveryBody } from './source-recovery.ts';
|
|
57
57
|
import { sourceError } from './source-validation.ts';
|
|
58
58
|
|
|
59
59
|
export type LaneDecision = 'agreed' | 'materialize' | 'propose' | 'hold';
|
|
@@ -107,6 +107,17 @@ export function commentsOwedToProject(
|
|
|
107
107
|
return owed.length > 0 ? JSON.stringify([...acceptedList, ...owed]) : null;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
/** An unresolved refused draft of this source is on record (unreadable counts: fail closed). */
|
|
111
|
+
function openConflict(historyDir: string | undefined, file: string): boolean {
|
|
112
|
+
if (!historyDir) return false;
|
|
113
|
+
try {
|
|
114
|
+
const c = readRecoveryCandidate(historyDir, file);
|
|
115
|
+
return c !== null && !c.resolved;
|
|
116
|
+
} catch {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
110
121
|
/**
|
|
111
122
|
* Pure decision for the source lanes. `knownBase` is the last value disk and
|
|
112
123
|
* the accepted replica agreed on (recovery slot), `baseHash` the journal's
|
|
@@ -154,6 +165,13 @@ export interface AcceptedColdStartInput {
|
|
|
154
165
|
* is the base — the recovery slot still holds the value before it.
|
|
155
166
|
*/
|
|
156
167
|
ownAccepted?: string | null;
|
|
168
|
+
/**
|
|
169
|
+
* #14 (2.0.5) — the css twin's `ownAccepted`: this disk's own css proposal a previous run left
|
|
170
|
+
* unanswered (an edit made offline, or just before quitting), which the drain has just had
|
|
171
|
+
* accepted. Without it a css edited while the studio was closed was judged against the css
|
|
172
|
+
* before that save, and refused as a conflict with the person's own older css.
|
|
173
|
+
*/
|
|
174
|
+
ownAcceptedCss?: string | null;
|
|
157
175
|
/**
|
|
158
176
|
* Did the project ever accept exactly this value? A disk with no record of
|
|
159
177
|
* its base that holds a value the store accepted at some revision holds an
|
|
@@ -214,7 +232,9 @@ export async function acceptedColdStart(
|
|
|
214
232
|
// What the project now holds IS the local file: the next save is based
|
|
215
233
|
// on it, even if it lands before the publication reaches this replica.
|
|
216
234
|
const base = r.html ?? localHtml;
|
|
217
|
-
|
|
235
|
+
// Persisted (v2-204): the creator has a base on record like any peer that received it, so
|
|
236
|
+
// an offline edit after a restart is proposed against it instead of held as a conflict.
|
|
237
|
+
i.projection.adoptBase(base, { remember: true });
|
|
218
238
|
// S6.13b — saved again on top of that create while it waited (offline,
|
|
219
239
|
// or a previous run): the disk is an edit of it, proposed as one.
|
|
220
240
|
if (base !== localHtml && !sourceError(i.paths.html, localHtml)) {
|
|
@@ -251,8 +271,18 @@ export async function acceptedColdStart(
|
|
|
251
271
|
(i.historyDir ? readRecoveryBody(i.historyDir, i.paths.html, 'base') : null),
|
|
252
272
|
baseHash: i.journal?.get(i.slug)?.bodyHash ?? null,
|
|
253
273
|
});
|
|
274
|
+
// "The project once accepted exactly these bytes" proves an OLDER accepted state (a checkout
|
|
275
|
+
// restored from a backup — every cloud cell wake) only when this Mac is not holding a refused
|
|
276
|
+
// save: the hub answers by content hash, across every document and revision, and a refused
|
|
277
|
+
// candidate is very often bytes the project took somewhere (the same artboards trashed on a
|
|
278
|
+
// twin canvas, a trash a restore undid). An open conflict episode on disk (its first refused
|
|
279
|
+
// draft, unresolved) keeps the hold — the person sees it again after a restart instead of
|
|
280
|
+
// losing it in silence (F15, v2-204).
|
|
254
281
|
const older =
|
|
255
|
-
d.decision === 'hold' &&
|
|
282
|
+
d.decision === 'hold' &&
|
|
283
|
+
localHtml !== null &&
|
|
284
|
+
!openConflict(i.historyDir, i.paths.html) &&
|
|
285
|
+
(await i.wasAccepted?.(localHtml)) === true;
|
|
256
286
|
verdicts.push({
|
|
257
287
|
lane: 'html',
|
|
258
288
|
...(older ? { decision: 'materialize' as const } : d),
|
|
@@ -263,19 +293,27 @@ export async function acceptedColdStart(
|
|
|
263
293
|
// ---- css — opaque text, journal-checkpointed
|
|
264
294
|
if (i.paths.css) {
|
|
265
295
|
const localCss = readText(i.paths.css);
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
296
|
+
if (i.ownAcceptedCss != null && localCss === i.ownAcceptedCss) {
|
|
297
|
+
// Disk IS the drained, accepted css; its publication may still be on the way.
|
|
298
|
+
verdicts.push({ lane: 'css', decision: 'agreed', local: localCss });
|
|
299
|
+
i.projection.adoptOwnAcceptedCss(i.ownAcceptedCss);
|
|
300
|
+
} else {
|
|
301
|
+
const d = decideSourceLane({
|
|
302
|
+
local: localCss,
|
|
303
|
+
accepted: cssFromDoc(i.doc) ?? '',
|
|
304
|
+
knownBase:
|
|
305
|
+
i.ownAcceptedCss ??
|
|
306
|
+
(i.historyDir ? readRecoveryBody(i.historyDir, i.paths.css, 'base') : null),
|
|
307
|
+
baseHash: i.journal?.get(i.slug)?.cssHash ?? null,
|
|
308
|
+
});
|
|
309
|
+
const older =
|
|
310
|
+
d.decision === 'hold' && localCss !== null && (await i.wasAccepted?.(localCss)) === true;
|
|
311
|
+
verdicts.push({
|
|
312
|
+
lane: 'css',
|
|
313
|
+
...(older ? { decision: 'materialize' as const } : d),
|
|
314
|
+
...(localCss !== null ? { local: localCss } : {}),
|
|
315
|
+
});
|
|
316
|
+
}
|
|
279
317
|
}
|
|
280
318
|
|
|
281
319
|
// ---- meta — the shared layout keys (viewport never travels)
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
createTransactionClient,
|
|
39
39
|
type Operation,
|
|
40
40
|
type ProposalResult,
|
|
41
|
+
type ReadLimits,
|
|
41
42
|
type Reservation,
|
|
42
43
|
type TransactionClient,
|
|
43
44
|
type TransactionClientOptions,
|
|
@@ -767,14 +768,18 @@ export function createAcceptedLink(opts: AcceptedLinkOptions) {
|
|
|
767
768
|
* p8-hub-undo-collision — a lane body the hub holds, by hash (null: not served / unreachable).
|
|
768
769
|
* The blob read is gated by the hub exactly like the history rows that name the hash.
|
|
769
770
|
*/
|
|
770
|
-
async blob(hash: string): Promise<string | null> {
|
|
771
|
+
async blob(hash: string, lim: ReadLimits = {}): Promise<string | null> {
|
|
771
772
|
if (!/^[0-9a-f]{64}$/.test(hash)) return null;
|
|
772
|
-
const b = (await client.read(`blobs/${hash}`, {})) as { body?: unknown };
|
|
773
|
+
const b = (await client.read(`blobs/${hash}`, {}, lim)) as { body?: unknown };
|
|
773
774
|
return typeof b?.body === 'string' ? b.body : null;
|
|
774
775
|
},
|
|
775
776
|
/** p8-hub-undo-collision — a doc's lane at the hub's newest revision (what an undo merges onto). */
|
|
776
|
-
async laneHead(
|
|
777
|
-
|
|
777
|
+
async laneHead(
|
|
778
|
+
doc: string,
|
|
779
|
+
lane: LaneProposal['lane'],
|
|
780
|
+
lim: ReadLimits = {}
|
|
781
|
+
): Promise<string | null> {
|
|
782
|
+
const r = (await client.read('lane', { doc, lane, rev: Number.MAX_SAFE_INTEGER }, lim)) as {
|
|
778
783
|
body?: unknown;
|
|
779
784
|
};
|
|
780
785
|
return typeof r?.body === 'string' ? r.body : null;
|
|
@@ -44,12 +44,18 @@ import { randomBytes } from 'node:crypto';
|
|
|
44
44
|
import { type Dirent, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
45
45
|
import path from 'node:path';
|
|
46
46
|
|
|
47
|
-
import {
|
|
47
|
+
import {
|
|
48
|
+
type CanvasGroupLike,
|
|
49
|
+
classifyProjectFile,
|
|
50
|
+
isFilePlaneClass,
|
|
51
|
+
MAX_SEGMENTS,
|
|
52
|
+
OLDER_HUB_DEPTH_REASON,
|
|
53
|
+
olderDoorRefusesDepth,
|
|
54
|
+
} from './file-membership.ts';
|
|
48
55
|
import { readLfsPointer } from './lfs-pointer.ts';
|
|
49
56
|
import { failureReason, retryAfterMs } from './retry-after.ts';
|
|
50
57
|
|
|
51
|
-
|
|
52
|
-
const MAX_SEGMENTS = 8;
|
|
58
|
+
export { OLDER_HUB_DEPTH_REASON };
|
|
53
59
|
|
|
54
60
|
/** A 2 GB file in an assets dir is a mistake — don't move it silently. */
|
|
55
61
|
const MAX_PUSH_BYTES = 512 * 1024 * 1024;
|
|
@@ -273,11 +279,21 @@ export function listPushableAssets(
|
|
|
273
279
|
.sort();
|
|
274
280
|
}
|
|
275
281
|
|
|
282
|
+
/**
|
|
283
|
+
* The hub's bucket key shape (`apps/hub/src/assets.mjs` ASSET_KEY): at most five
|
|
284
|
+
* segments under `assets/`, no spaces, each segment ≤ 64 characters. A top-level
|
|
285
|
+
* path it cannot key — an asset pack's `Models/GLTF format/…` — was sent to the
|
|
286
|
+
* bucket route anyway and refused `400` every boot (fix/205); it goes to the
|
|
287
|
+
* checkout route, which takes any classifier-admitted path.
|
|
288
|
+
*/
|
|
289
|
+
const BUCKET_KEY =
|
|
290
|
+
/^(?!.*(?:^|\/)\.\.(?:\/|$))[A-Za-z0-9][A-Za-z0-9._-]{0,63}(?:\/[A-Za-z0-9][A-Za-z0-9._-]{0,63}){0,4}$/;
|
|
291
|
+
|
|
276
292
|
/** Where a given asset pushes: the bucket-backed route (top-level `assets/`) or
|
|
277
293
|
* the checkout route (a nested `…/assets/…` served from disk). */
|
|
278
294
|
function routeFor(rel: string): { url: string } {
|
|
279
295
|
const parts = rel.split('/');
|
|
280
|
-
if (parts[0] === 'assets') {
|
|
296
|
+
if (parts[0] === 'assets' && BUCKET_KEY.test(parts.slice(1).join('/'))) {
|
|
281
297
|
// Top-level content-addressed → the bucket `/assets/<key>` route.
|
|
282
298
|
return { url: `/assets/${parts.slice(1).join('/')}` };
|
|
283
299
|
}
|
|
@@ -361,6 +377,8 @@ async function putWithRetry(ctx: {
|
|
|
361
377
|
/** Mutable per-sweep pause budget, shared across every asset. */
|
|
362
378
|
backoff: { remainingMs: number };
|
|
363
379
|
timeoutFor: (bytes: number) => number;
|
|
380
|
+
/** Told when the hub answered 429 — the caller narrows the sweep. */
|
|
381
|
+
onThrottled?: () => void;
|
|
364
382
|
}): Promise<Response> {
|
|
365
383
|
const send = (): Promise<Response> => {
|
|
366
384
|
const body = Bun.file(ctx.file);
|
|
@@ -379,6 +397,7 @@ async function putWithRetry(ctx: {
|
|
|
379
397
|
};
|
|
380
398
|
const first = await send();
|
|
381
399
|
if (first.status === 429) {
|
|
400
|
+
ctx.onThrottled?.();
|
|
382
401
|
const wait = retryAfterMs(first.headers?.get?.('retry-after') ?? null);
|
|
383
402
|
if (wait > ctx.backoff.remainingMs) return first;
|
|
384
403
|
ctx.backoff.remainingMs -= wait;
|
|
@@ -390,11 +409,52 @@ async function putWithRetry(ctx: {
|
|
|
390
409
|
}
|
|
391
410
|
|
|
392
411
|
/**
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
412
|
+
* How many uploads one sweep keeps on the wire (fix/205-sync-assets).
|
|
413
|
+
*
|
|
414
|
+
* It was ONE, "sequential on purpose" so a video upload could not starve the
|
|
415
|
+
* handshakes a fresh sync rides on. That made one hung PUT the whole lane's
|
|
416
|
+
* problem: the studyfi first sync (5,534 assets) sat on one SVG for its full
|
|
417
|
+
* budget. Four is enough that a slow file no longer stalls the rest and still
|
|
418
|
+
* far from saturating a link — the text lanes keep their share.
|
|
419
|
+
*/
|
|
420
|
+
export const UPLOAD_WIDTH_MAX = 4;
|
|
421
|
+
/** Reads per minute (the hub's advertised `readsPerMinute`) one upload lane is worth. */
|
|
422
|
+
const READS_PER_UPLOAD_LANE = 120;
|
|
423
|
+
const LIMITS_TIMEOUT_MS = 10_000;
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* The sweep's width: UPLOAD_WIDTH_MAX, narrowed when the hub says its rate is
|
|
427
|
+
* low (`/api/file-limits` `readsPerMinute`, #204). Hub-supplied (DDR-054), so
|
|
428
|
+
* it can only slow us down — to one — never widen past the maximum. A hub
|
|
429
|
+
* without the route (every journal-less hub this lane serves, most likely), or
|
|
430
|
+
* one that does not answer, gets the default: its 429s narrow the sweep anyway.
|
|
431
|
+
*/
|
|
432
|
+
async function uploadWidth(ctx: {
|
|
433
|
+
fetchImpl: typeof fetch;
|
|
434
|
+
base: string;
|
|
435
|
+
token: () => string;
|
|
436
|
+
}): Promise<number> {
|
|
437
|
+
try {
|
|
438
|
+
const res = await ctx.fetchImpl(`${ctx.base}/api/file-limits`, {
|
|
439
|
+
headers: { authorization: `Bearer ${ctx.token()}` },
|
|
440
|
+
signal: AbortSignal.timeout(LIMITS_TIMEOUT_MS),
|
|
441
|
+
});
|
|
442
|
+
if (!res.ok) return UPLOAD_WIDTH_MAX;
|
|
443
|
+
const body = (await res.json()) as { readsPerMinute?: unknown };
|
|
444
|
+
const rpm = body?.readsPerMinute;
|
|
445
|
+
if (typeof rpm !== 'number' || !Number.isFinite(rpm) || rpm <= 0) return UPLOAD_WIDTH_MAX;
|
|
446
|
+
return Math.max(1, Math.min(UPLOAD_WIDTH_MAX, Math.floor(rpm / READS_PER_UPLOAD_LANE)));
|
|
447
|
+
} catch {
|
|
448
|
+
return UPLOAD_WIDTH_MAX;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Mirror local assets up to the hub. Idempotent and skip-first (one batch probe
|
|
454
|
+
* per boot, per-file HEAD only on a hub without it; upload only on a miss), a
|
|
455
|
+
* few at a time (UPLOAD_WIDTH_MAX). A first-attempt timeout is tried once more
|
|
456
|
+
* after the rest of the sweep. Never throws; a failed upload is retried for
|
|
457
|
+
* free on the next boot.
|
|
398
458
|
*/
|
|
399
459
|
export async function pushAssets(opts: {
|
|
400
460
|
designRoot: string;
|
|
@@ -406,6 +466,12 @@ export async function pushAssets(opts: {
|
|
|
406
466
|
canvasGroups?: readonly CanvasGroupLike[];
|
|
407
467
|
/** The file-plane flag; absent ⇒ read from config/env the same way. */
|
|
408
468
|
syncFiles?: boolean;
|
|
469
|
+
/**
|
|
470
|
+
* fix/205 — the hub advertises `file-depth-v2`. False ⇒ a path deeper than 8 segments is not
|
|
471
|
+
* sent (an older hub answers `400 invalid path`, and one such path in the batch probe refuses
|
|
472
|
+
* the whole probe): it is reported as failed with OLDER_HUB_DEPTH_REASON, by name. Absent ⇒ true.
|
|
473
|
+
*/
|
|
474
|
+
hubTakesDeepPaths?: boolean;
|
|
409
475
|
fetchImpl?: typeof fetch;
|
|
410
476
|
log?: Pick<Console, 'log' | 'warn'>;
|
|
411
477
|
/** feature-sync-progress-modal — incremental progress (throttled; failures
|
|
@@ -474,30 +540,48 @@ export async function pushAssets(opts: {
|
|
|
474
540
|
|
|
475
541
|
// One question for the whole set, when the hub can answer it. Null = this hub
|
|
476
542
|
// predates the route, so every file falls back to its own probe below.
|
|
543
|
+
// fix/205 — a hub older than `file-depth-v2` refuses a path deeper than 8 segments. Never sent,
|
|
544
|
+
// never silent: each is named with the reason (the panel lists failures by path).
|
|
545
|
+
const tooDeep =
|
|
546
|
+
opts.hubTakesDeepPaths === false ? assets.filter((rel) => olderDoorRefusesDepth(rel)) : [];
|
|
547
|
+
for (const rel of tooDeep) out.failed.push({ key: rel, reason: OLDER_HUB_DEPTH_REASON });
|
|
548
|
+
const sendable =
|
|
549
|
+
tooDeep.length > 0 ? assets.filter((rel) => !olderDoorRefusesDepth(rel)) : assets;
|
|
550
|
+
if (tooDeep.length > 0)
|
|
551
|
+
log.warn?.(
|
|
552
|
+
`[sync/assets] ${tooDeep.length} file(s) sit deeper than ${base} takes (8 folders) — update the hub`
|
|
553
|
+
);
|
|
554
|
+
|
|
477
555
|
const known =
|
|
478
|
-
|
|
556
|
+
sendable.length > 0
|
|
479
557
|
? await probePresent({
|
|
480
558
|
fetchImpl,
|
|
481
559
|
base,
|
|
482
560
|
headers: { authorization: `Bearer ${opts.token()}` },
|
|
483
|
-
paths:
|
|
561
|
+
paths: sendable,
|
|
484
562
|
})
|
|
485
563
|
: null;
|
|
486
564
|
|
|
487
|
-
|
|
488
|
-
|
|
565
|
+
// fix/205 — what the batch already answered is settled NOW, not lazily in
|
|
566
|
+
// loop order: "5463 moving" for a set the hub held all but 74 of was the
|
|
567
|
+
// panel counting files nobody was going to send.
|
|
568
|
+
const queue = known ? sendable.filter((rel) => !known.has(rel)) : sendable;
|
|
569
|
+
if (known) out.skipped = sendable.length - queue.length;
|
|
570
|
+
if (assets.length > 0) emitProgress(queue[0] ?? null, false, true);
|
|
571
|
+
|
|
572
|
+
// How many uploads may be on the wire at once. See UPLOAD_WIDTH_MAX.
|
|
573
|
+
let width = queue.length > 0 ? await uploadWidth({ fetchImpl, base, token: opts.token }) : 1;
|
|
574
|
+
let stop = false;
|
|
575
|
+
/** Files whose FIRST attempt timed out — they get one more go after the rest of the sweep. */
|
|
576
|
+
const timedOut: string[] = [];
|
|
577
|
+
|
|
578
|
+
const one = async (rel: string, lastTry: boolean): Promise<void> => {
|
|
489
579
|
emitProgress(rel, false);
|
|
490
580
|
const url = `${base}${routeFor(rel).url}`;
|
|
491
581
|
const headers = { authorization: `Bearer ${opts.token()}` };
|
|
492
|
-
|
|
493
|
-
if (known.has(rel)) {
|
|
494
|
-
out.skipped += 1;
|
|
495
|
-
continue;
|
|
496
|
-
}
|
|
582
|
+
try {
|
|
497
583
|
// The batch answered, and it said this one is missing — no per-file probe
|
|
498
584
|
// can add anything, so go straight to the upload.
|
|
499
|
-
}
|
|
500
|
-
try {
|
|
501
585
|
const head = known
|
|
502
586
|
? null
|
|
503
587
|
: await fetchImpl(url, {
|
|
@@ -507,7 +591,7 @@ export async function pushAssets(opts: {
|
|
|
507
591
|
});
|
|
508
592
|
if (head?.ok) {
|
|
509
593
|
out.skipped += 1;
|
|
510
|
-
|
|
594
|
+
return;
|
|
511
595
|
}
|
|
512
596
|
// A hub that refuses the PROBE refuses the upload — pushing the body
|
|
513
597
|
// anyway just streams megabytes at a door that already said no. The
|
|
@@ -521,7 +605,12 @@ export async function pushAssets(opts: {
|
|
|
521
605
|
if (head && (head.status === 401 || head.status === 403)) {
|
|
522
606
|
out.failed.push({ key: rel, reason: await failureReason(head) });
|
|
523
607
|
emitProgress(rel, false, true);
|
|
524
|
-
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
// The cancel may land while the probe was out — never start a body after it.
|
|
611
|
+
if (stop || opts.cancelled?.()) {
|
|
612
|
+
stop = true;
|
|
613
|
+
return;
|
|
525
614
|
}
|
|
526
615
|
const put = await putWithRetry({
|
|
527
616
|
fetchImpl,
|
|
@@ -531,19 +620,30 @@ export async function pushAssets(opts: {
|
|
|
531
620
|
sleep,
|
|
532
621
|
backoff,
|
|
533
622
|
timeoutFor,
|
|
623
|
+
// The hub is pacing us: the rest of this sweep goes one file at a time.
|
|
624
|
+
onThrottled: () => {
|
|
625
|
+
width = 1;
|
|
626
|
+
},
|
|
534
627
|
});
|
|
535
628
|
if (put.ok) out.pushed.push(rel);
|
|
536
629
|
else if (put.status === 405) {
|
|
537
630
|
// `this hub does not accept file writes`: no checkout, so no file can ever land here. Stop the pass — the
|
|
538
631
|
// next file would get the same answer — and say it is not a failure; the media stays on this Mac.
|
|
539
632
|
out.refused = 'no-checkout';
|
|
540
|
-
|
|
633
|
+
stop = true;
|
|
541
634
|
} else {
|
|
542
635
|
out.failed.push({ key: rel, reason: await failureReason(put) });
|
|
543
636
|
emitProgress(rel, false, true);
|
|
544
637
|
}
|
|
545
638
|
} catch (err) {
|
|
546
639
|
const e = err as Error;
|
|
640
|
+
// One hung request used to cost the file its whole boot. A timeout is the
|
|
641
|
+
// likeliest refusal to be transient, so it waits for the end of the sweep
|
|
642
|
+
// and goes once more (lastTry) — a second timeout is reported.
|
|
643
|
+
if (e.name === 'TimeoutError' && !lastTry) {
|
|
644
|
+
timedOut.push(rel);
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
547
647
|
out.failed.push({
|
|
548
648
|
key: rel,
|
|
549
649
|
// "TimeoutError: The operation timed out" tells a person nothing about
|
|
@@ -552,6 +652,29 @@ export async function pushAssets(opts: {
|
|
|
552
652
|
});
|
|
553
653
|
emitProgress(rel, false, true);
|
|
554
654
|
}
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
let next = 0;
|
|
658
|
+
const worker = async (id: number): Promise<void> => {
|
|
659
|
+
// A worker past the current width retires (a 429 narrows the sweep to one).
|
|
660
|
+
while (!stop && id < width && next < queue.length) {
|
|
661
|
+
if (opts.cancelled?.()) {
|
|
662
|
+
stop = true;
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
665
|
+
const rel = queue[next++] as string;
|
|
666
|
+
await one(rel, false);
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
// The sweep's FIRST upload goes alone: the door's answer to it — 405 (no checkout: nothing can
|
|
670
|
+
// ever land, the media gate stops the lane), a 429 (pace us) — is known before the pool opens,
|
|
671
|
+
// so a door that says no gets one body, not `width` bodies already on the wire.
|
|
672
|
+
if (!stop && next < queue.length && !opts.cancelled?.())
|
|
673
|
+
await one(queue[next++] as string, false);
|
|
674
|
+
await Promise.all(Array.from({ length: width }, (_, id) => worker(id)));
|
|
675
|
+
for (const rel of timedOut) {
|
|
676
|
+
if (stop || opts.cancelled?.()) break;
|
|
677
|
+
await one(rel, true);
|
|
555
678
|
}
|
|
556
679
|
// No assets → no emits at all: a project without an assets/ dir should not
|
|
557
680
|
// grow an empty assets section in its Sync panel.
|
|
@@ -26,7 +26,7 @@ import { existsSync, lstatSync } from 'node:fs';
|
|
|
26
26
|
import path from 'node:path';
|
|
27
27
|
|
|
28
28
|
import { listPushableAssets } from './asset-push.ts';
|
|
29
|
-
import { type CanvasGroupLike, classifyProjectFile } from './file-membership.ts';
|
|
29
|
+
import { type CanvasGroupLike, classifyProjectFile, MAX_SEGMENTS } from './file-membership.ts';
|
|
30
30
|
import { hasLfsObject, lfsObjectsDir, readLfsPointer } from './lfs-pointer.ts';
|
|
31
31
|
|
|
32
32
|
export interface AssetWho {
|
|
@@ -73,7 +73,8 @@ export function isAssetStateRel(rel: unknown): rel is string {
|
|
|
73
73
|
// biome-ignore lint/suspicious/noControlCharactersInRegex: refusing them is the point.
|
|
74
74
|
if (/[\u0000-\u001f\u007f]/.test(rel)) return false;
|
|
75
75
|
const parts = rel.split('/');
|
|
76
|
-
|
|
76
|
+
// The classifier's depth cap (32 since fix/205) — a deep asset must be askable too.
|
|
77
|
+
if (parts.length < 2 || parts.length > MAX_SEGMENTS) return false;
|
|
77
78
|
return parts.every((p) => p && p !== '.' && p !== '..' && !p.startsWith('_'));
|
|
78
79
|
}
|
|
79
80
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// sync/code-module-consent.ts — may this hub DELIVER code modules (`.ts`/`.js`) to this checkout?
|
|
2
|
+
//
|
|
3
|
+
// DDR-054: a code module lands outside the sandboxed canvas origin — the agent and every
|
|
4
|
+
// `maude design *` helper read it — so only a hub this machine vouches for may move one. Three
|
|
5
|
+
// ways a hub is vouched for, and nothing a hub can say about itself is one of them:
|
|
6
|
+
//
|
|
7
|
+
// 1. `cell` — this process is a cell's own paired child: the hub and the checkout are one
|
|
8
|
+
// trust domain, there is no remote party.
|
|
9
|
+
// 2. `recorded` — `codeModulesAllowed: true` in the profile's hubs.json, written only by the
|
|
10
|
+
// person at `maude design link` (cli/lib/design-link.mjs `askCodeModuleConsent`)
|
|
11
|
+
// and carried across every re-save by `saveHubCredential` — a sign-in response
|
|
12
|
+
// can change the stored role, never this.
|
|
13
|
+
// 3. `cloud` — 2.0.4, Michal's decision ("automaticky pro Maude Cloud"): a Maude Cloud project
|
|
14
|
+
// the desktop app ITSELF opened from Home. The cloud's file door takes code-module
|
|
15
|
+
// uploads only from the project's OWNER role (DDR-217), so what arrives is the
|
|
16
|
+
// owner's own code; asking every member to say yes to it left a second Mac with
|
|
17
|
+
// 12 helpers `stuck` and the canvases importing them undrawable.
|
|
18
|
+
//
|
|
19
|
+
// Why (3) is computed here, per boot, and NOT recorded into hubs.json:
|
|
20
|
+
// - both inputs are out of a repo's and a hub's reach: `MAUDE_APP_BOUND_HUB` is set by the Rust
|
|
21
|
+
// shell from the app's own registry (a committed `linkedHub` never is — sync/link-consent.ts),
|
|
22
|
+
// and the cell zone is compiled in (`CELL_ZONE`, the same constant as Rust `windows.rs`), never
|
|
23
|
+
// read from config or from `MAUDE_CLOUD_URL` — a self-hosted control plane is not Maude Cloud;
|
|
24
|
+
// - a record would outlive its reason: a folder later re-linked to another hub, or a copy opened
|
|
25
|
+
// outside the app, would inherit a `true` nobody gave. Computing it can't be planted or go stale.
|
|
26
|
+
// - there is no per-hub consent row in Settings › Connections to keep in step with.
|
|
27
|
+
//
|
|
28
|
+
// An explicit recorded `false` still wins: a person who said no on this Mac keeps their no.
|
|
29
|
+
|
|
30
|
+
import { CELL_ZONE, cellDoorUrl } from '../client/v2/cloud/browser-door.js';
|
|
31
|
+
import { normHub } from './link-consent.ts';
|
|
32
|
+
|
|
33
|
+
export type CodeModuleConsentHow = 'cell' | 'recorded' | 'cloud';
|
|
34
|
+
|
|
35
|
+
export interface CodeModuleConsentInput {
|
|
36
|
+
/** this process is a paired cell child (sync/cell-pairing.ts) */
|
|
37
|
+
cellPairing: boolean;
|
|
38
|
+
/** the linked hub the runtime is about to dial (already past link consent) */
|
|
39
|
+
hubUrl: string;
|
|
40
|
+
/** the profile's stored hub record — only its local `codeModulesAllowed` is read */
|
|
41
|
+
storedRecord?: { codeModulesAllowed?: boolean } | null;
|
|
42
|
+
env?: Record<string, string | undefined>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Is `url` the front door of a Maude Cloud project cell? https, no port, no userinfo, no path, one
|
|
47
|
+
* cell label under the compiled-in zone (never `canvas`, `view-*`, `canvas-*` — `cellDoorUrl`).
|
|
48
|
+
*/
|
|
49
|
+
export function isMaudeCloudCell(url: unknown): boolean {
|
|
50
|
+
const hub = normHub(url);
|
|
51
|
+
if (!hub) return false;
|
|
52
|
+
let origin: string;
|
|
53
|
+
try {
|
|
54
|
+
const u = new URL(hub);
|
|
55
|
+
if (u.search || u.hash || (u.pathname !== '/' && u.pathname !== '')) return false;
|
|
56
|
+
origin = u.origin;
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (!origin.endsWith(`.${CELL_ZONE}`)) return false;
|
|
61
|
+
return cellDoorUrl(`${origin}/`) === `${origin}/`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Why this hub may deliver code modules here, or null when it may not. */
|
|
65
|
+
export function codeModuleConsent(o: CodeModuleConsentInput): CodeModuleConsentHow | null {
|
|
66
|
+
if (o.cellPairing) return 'cell';
|
|
67
|
+
const recorded = o.storedRecord?.codeModulesAllowed;
|
|
68
|
+
if (recorded === true) return 'recorded';
|
|
69
|
+
if (recorded === false) return null;
|
|
70
|
+
const env = o.env ?? process.env;
|
|
71
|
+
const hub = normHub(o.hubUrl);
|
|
72
|
+
if (hub && normHub(env.MAUDE_APP_BOUND_HUB) === hub && isMaudeCloudCell(hub)) return 'cloud';
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
@@ -313,6 +313,16 @@ export interface FileLedger {
|
|
|
313
313
|
outboxHas(hash: string): boolean;
|
|
314
314
|
|
|
315
315
|
flush(): void;
|
|
316
|
+
/**
|
|
317
|
+
* Hold the debounced write until the returned release is called (issue #204).
|
|
318
|
+
*
|
|
319
|
+
* A pass that lands thousands of files used to rewrite this file — 2.3 MB of JSON on a 5 000-file
|
|
320
|
+
* project, stringified twice per write — once a second for the whole pass, because every landing
|
|
321
|
+
* re-armed the 1 s debounce. While held, changes stay in memory and the caller decides when to
|
|
322
|
+
* write: every N landings and at the end of the pass, through `flush()`, which always writes.
|
|
323
|
+
* Holds nest; the last release re-arms the debounce if anything changed meanwhile.
|
|
324
|
+
*/
|
|
325
|
+
deferFlush(): () => void;
|
|
316
326
|
stop(): void;
|
|
317
327
|
/** Where this ledger persists. Tests and the panel read it. */
|
|
318
328
|
file(): string;
|
|
@@ -343,6 +353,8 @@ export interface FileLedgerOptions {
|
|
|
343
353
|
now?: () => number;
|
|
344
354
|
flushMs?: number;
|
|
345
355
|
log?: Pick<Console, 'warn'>;
|
|
356
|
+
/** Called after every write that reached the disk — the tests count them. */
|
|
357
|
+
onPersist?: () => void;
|
|
346
358
|
}
|
|
347
359
|
|
|
348
360
|
export function createFileLedger(opts: FileLedgerOptions): FileLedger {
|
|
@@ -439,7 +451,15 @@ export function createFileLedger(opts: FileLedgerOptions): FileLedger {
|
|
|
439
451
|
return out;
|
|
440
452
|
}
|
|
441
453
|
|
|
454
|
+
/** Open `deferFlush` holds, and whether something changed while one was open. */
|
|
455
|
+
let holds = 0;
|
|
456
|
+
let dirtyWhileHeld = false;
|
|
457
|
+
|
|
442
458
|
function schedule(): void {
|
|
459
|
+
if (holds > 0) {
|
|
460
|
+
dirtyWhileHeld = true;
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
443
463
|
if (timer !== null) return;
|
|
444
464
|
timer = setTimeout(() => {
|
|
445
465
|
timer = null;
|
|
@@ -464,6 +484,8 @@ export function createFileLedger(opts: FileLedgerOptions): FileLedger {
|
|
|
464
484
|
data.updatedAt = now();
|
|
465
485
|
atomicWrite(file, `${JSON.stringify(data, null, 2)}\n`);
|
|
466
486
|
lastPersisted = body;
|
|
487
|
+
dirtyWhileHeld = false;
|
|
488
|
+
opts.onPersist?.();
|
|
467
489
|
} catch (err) {
|
|
468
490
|
// Never throws into the sync hot path. A ledger we cannot persist costs
|
|
469
491
|
// a re-anchor next boot, which is noise rather than loss.
|
|
@@ -711,6 +733,19 @@ export function createFileLedger(opts: FileLedgerOptions): FileLedger {
|
|
|
711
733
|
}
|
|
712
734
|
persist();
|
|
713
735
|
},
|
|
736
|
+
deferFlush() {
|
|
737
|
+
holds += 1;
|
|
738
|
+
let released = false;
|
|
739
|
+
return () => {
|
|
740
|
+
if (released) return;
|
|
741
|
+
released = true;
|
|
742
|
+
holds -= 1;
|
|
743
|
+
if (holds === 0 && dirtyWhileHeld) {
|
|
744
|
+
dirtyWhileHeld = false;
|
|
745
|
+
schedule();
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
},
|
|
714
749
|
stop() {
|
|
715
750
|
if (timer !== null) {
|
|
716
751
|
clearTimeout(timer);
|
|
@@ -78,8 +78,23 @@ export function isFilePlaneClass(c: FileClass): c is FilePlaneClass {
|
|
|
78
78
|
/** Max relative-path length (matches the hub's checkout shape cap). */
|
|
79
79
|
export const MAX_REL_LEN = 512;
|
|
80
80
|
|
|
81
|
-
/**
|
|
82
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Max designRoot-relative depth, in segments — the hub mirror carries the same figure.
|
|
83
|
+
*
|
|
84
|
+
* It was 8 until fix/205-sync-assets: a 3D asset pack (`assets/kenney/…/Models/GLTF format/
|
|
85
|
+
* Textures/…`) sat deeper, both classifiers answered `never`, and the files were dropped with no
|
|
86
|
+
* row anywhere. The depth cap never guarded anything the shape rules do not (no `..`, no
|
|
87
|
+
* absolute, a conservative charset, MAX_REL_LEN); it only keeps a key from being absurd. 32 still
|
|
88
|
+
* does, and every walk that mirrors it stays bounded.
|
|
89
|
+
*/
|
|
90
|
+
export const MAX_SEGMENTS = 32;
|
|
91
|
+
|
|
92
|
+
/** The cap every hub before `file-depth-v2` refuses past (`olderDoorRefusesDepth`). */
|
|
93
|
+
export const LEGACY_MAX_SEGMENTS = 8;
|
|
94
|
+
|
|
95
|
+
/** The ledger / panel reason for a file held back from a hub without `file-depth-v2`. */
|
|
96
|
+
export const OLDER_HUB_DEPTH_REASON =
|
|
97
|
+
'The project’s server runs an older Maude that takes files at most 8 folders deep — update it to sync this file';
|
|
83
98
|
|
|
84
99
|
// The positive extension enumerations. Everything is lowercase; the lookup
|
|
85
100
|
// lowercases first — a DS legitimately ships `…P1020428.JPG`.
|
|
@@ -264,7 +279,7 @@ export interface ClassifyOptions {
|
|
|
264
279
|
* deliberately the same answer, so no caller can tell them apart and leak an
|
|
265
280
|
* oracle.
|
|
266
281
|
*
|
|
267
|
-
* Shape gates (all refusals → `never`): relative, `/`-separated, ≤
|
|
282
|
+
* Shape gates (all refusals → `never`): relative, `/`-separated, ≤ 32
|
|
268
283
|
* segments, ≤ 512 chars, no `..`/`.`/empty segment, no backslash, no drive
|
|
269
284
|
* letter, no control characters, no trailing-space segment, no
|
|
270
285
|
* `node_modules`, directory segments start alphanumeric, the final segment
|
|
@@ -373,6 +388,16 @@ export function olderDoorRefuses(rel: string): boolean {
|
|
|
373
388
|
return lower.endsWith('.json') && !OLDER_DOOR_JSON_SUFFIXES.some((s) => lower.endsWith(s));
|
|
374
389
|
}
|
|
375
390
|
|
|
391
|
+
/**
|
|
392
|
+
* Would a hub without `file-depth-v2` refuse this path for its depth alone? (fix/205)
|
|
393
|
+
*
|
|
394
|
+
* Every hub before it caps a path at LEGACY_MAX_SEGMENTS and answers anything deeper
|
|
395
|
+
* `400 invalid path`. Asked only about a path this side already admits. Studio-only.
|
|
396
|
+
*/
|
|
397
|
+
export function olderDoorRefusesDepth(rel: string): boolean {
|
|
398
|
+
return rel.split('/').length > LEGACY_MAX_SEGMENTS;
|
|
399
|
+
}
|
|
400
|
+
|
|
376
401
|
/** The segment shape rules alone — split parts, or null on refusal. */
|
|
377
402
|
|
|
378
403
|
/**
|