@1agh/maude 2.0.1 → 2.0.2
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/studio/access/filters.ts +24 -2
- package/apps/studio/access/frame.ts +38 -0
- package/apps/studio/access/request.ts +81 -2
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +2 -0
- package/apps/studio/client/styles/_index.css +2 -0
- package/apps/studio/client/v2/assets/ds-library-view.jsx +263 -0
- package/apps/studio/client/v2/assets/ds-library.css +123 -0
- package/apps/studio/client/v2/assets/ds-library.js +175 -0
- package/apps/studio/client/v2/left-panel/assets-panel.jsx +60 -1
- package/apps/studio/dist/client.bundle.js +844 -844
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds-assets.ts +317 -0
- package/apps/studio/edit-ops/image-fit.ts +19 -2
- package/apps/studio/edit-ops/types.ts +5 -0
- package/apps/studio/editing/asset-drag.ts +8 -2
- package/apps/studio/editing/ds-asset-ref.ts +66 -0
- package/apps/studio/http.ts +17 -2
- package/apps/studio/materialize-client.ts +11 -0
- package/apps/studio/routes/ds-assets.ts +70 -0
- package/apps/studio/routes/edit.ts +1 -0
- package/apps/studio/routes/index.ts +4 -0
- package/apps/studio/sync/accepted-link.ts +28 -6
- package/apps/studio/sync/availability.ts +5 -0
- package/apps/studio/sync/create-collision.ts +96 -19
- package/apps/studio/sync/index.ts +10 -2
- package/apps/studio/sync/project-config-push.ts +8 -1
- package/apps/studio/sync/transaction-client.ts +54 -11
- package/apps/studio/sync/writer-registry.ts +2 -0
- package/package.json +8 -8
|
@@ -459,6 +459,12 @@ export function createAcceptedLink(opts: AcceptedLinkOptions) {
|
|
|
459
459
|
let createNote: { r: Reservation; file: string } | null = null;
|
|
460
460
|
/** doc → the gate a batched create of it holds until settled or re-queued. */
|
|
461
461
|
const createsInFlight = new Map<string, Promise<void>>();
|
|
462
|
+
/**
|
|
463
|
+
* 2.0.2 — a create the transaction client WITHDREW (the project already holds that document:
|
|
464
|
+
* the same file, or a module kept under its name) was not sent: its caller hears `in-project`,
|
|
465
|
+
* and its cold start joins the project's document instead of believing it created it.
|
|
466
|
+
*/
|
|
467
|
+
const IN_PROJECT: ProposalOutcome = { status: 'rejected', code: 'in-project' };
|
|
462
468
|
const proposeCreates = (ops: Operation[], reservation?: Reservation) =>
|
|
463
469
|
client
|
|
464
470
|
.propose({
|
|
@@ -467,7 +473,14 @@ export function createAcceptedLink(opts: AcceptedLinkOptions) {
|
|
|
467
473
|
operations: ops,
|
|
468
474
|
...(reservation ? { reservation } : {}),
|
|
469
475
|
})
|
|
470
|
-
.then(
|
|
476
|
+
.then((r) => ({
|
|
477
|
+
o: outcome(r),
|
|
478
|
+
out: new Set(
|
|
479
|
+
(Array.isArray(r.withdrawn) ? r.withdrawn : [])
|
|
480
|
+
.map((w) => (w as { doc?: unknown })?.doc)
|
|
481
|
+
.filter((d): d is string => typeof d === 'string')
|
|
482
|
+
),
|
|
483
|
+
}));
|
|
471
484
|
/** Note one create on disk before it is answered (fix 5.12d). */
|
|
472
485
|
function noteCreate(op: Operation): void {
|
|
473
486
|
if (!durable) return;
|
|
@@ -518,17 +531,26 @@ export function createAcceptedLink(opts: AcceptedLinkOptions) {
|
|
|
518
531
|
note?.r
|
|
519
532
|
);
|
|
520
533
|
if (note && existsSync(client.entryFile(note.r))) rmSync(note.file, { force: true });
|
|
521
|
-
void sealed.then((o) => {
|
|
522
|
-
|
|
534
|
+
void sealed.then(({ o, out }) => {
|
|
535
|
+
const withdrawn = batch.filter((c) => out.has(c.op.doc as string));
|
|
536
|
+
for (const c of withdrawn) c.resolve(IN_PROJECT);
|
|
537
|
+
const rest = batch.filter((c) => !out.has(c.op.doc as string));
|
|
538
|
+
if (o.status === 'accepted' || rest.length <= 1) {
|
|
523
539
|
release();
|
|
524
|
-
for (const c of
|
|
540
|
+
for (const c of rest) c.resolve(o);
|
|
525
541
|
return;
|
|
526
542
|
}
|
|
527
543
|
// Each create is queued (and so ahead of anything waiting on the gate)
|
|
528
544
|
// before the gate opens.
|
|
529
|
-
const each =
|
|
545
|
+
const each = rest.map((c) => proposeCreates([c.op]));
|
|
530
546
|
release();
|
|
531
|
-
each.forEach(
|
|
547
|
+
each.forEach(
|
|
548
|
+
(answer, i) =>
|
|
549
|
+
void answer.then(
|
|
550
|
+
(a) => rest[i].resolve(a.out.has(rest[i].op.doc as string) ? IN_PROJECT : a.o),
|
|
551
|
+
() => rest[i].resolve(o)
|
|
552
|
+
)
|
|
553
|
+
);
|
|
532
554
|
}, fail);
|
|
533
555
|
}
|
|
534
556
|
function queueCreate(op: Operation): Promise<ProposalOutcome> {
|
|
@@ -160,6 +160,11 @@ export function computeAvailability(input: AvailabilityInput): Availability {
|
|
|
160
160
|
if (path === null) continue;
|
|
161
161
|
}
|
|
162
162
|
if (path !== null && localPaths.has(path)) continue;
|
|
163
|
+
// A `_`-named file or folder is never a canvas (skip-dirs.ts `isCanvasFile`; the index never
|
|
164
|
+
// lists one), but the v2 conversion keeps a document for every `.tsx` in a canvas folder, shared
|
|
165
|
+
// modules included: `_kit` / `_frames` / `_social` drew as ghost canvases that never arrived and
|
|
166
|
+
// failed when clicked (2.0.1, alligators: "94 of 103").
|
|
167
|
+
if (path !== null && path.split('/').some((s) => s.startsWith('_'))) continue;
|
|
163
168
|
pending.push({ path, name: path === null ? null : nameOf(path), state });
|
|
164
169
|
}
|
|
165
170
|
pending.sort((a, b) =>
|
|
@@ -12,7 +12,20 @@
|
|
|
12
12
|
// there and the place is free", so a replay of the same refusal finishes the same rename — the same
|
|
13
13
|
// name, once — instead of starting another. A real content conflict (the same canvas edited on two
|
|
14
14
|
// sides) is not this case: that is a `base-conflict` on a lane, and keeps its own path.
|
|
15
|
+
//
|
|
16
|
+
// 2.0.2 — A COLLISION WITH THE SAME FILE IS NOT A COLLISION (Brno Alligators, 2026-11-03: a cloud
|
|
17
|
+
// cell's 2.0 conversion made a document for every `.tsx` of its checkout, the owner's Mac replayed
|
|
18
|
+
// its queued creates for those same files, and each was renamed — ten duplicate canvases). Before
|
|
19
|
+
// renaming, the project's document for the create is compared with this Mac's canvas: when it
|
|
20
|
+
// holds this Mac's source byte for byte (what the create carries, or the file on disk now — edited
|
|
21
|
+
// after the create), it IS this canvas, and the create is WITHDRAWN: nothing moves, and what queued
|
|
22
|
+
// behind it names the same document and goes as it is. Byte-equal source only: a create carries no
|
|
23
|
+
// base, so "the project's copy is newer from the same base" is not decidable here — that renames,
|
|
24
|
+
// as before. A `_` file is a module (decision maude/v2-p8-lead-underscore-file-is-a-module),
|
|
25
|
+
// imported by its name: it is never renamed — its create is withdrawn and the file stays, and the
|
|
26
|
+
// cold start holds a differing source as any lane conflict (both kept).
|
|
15
27
|
|
|
28
|
+
import { createHash } from 'node:crypto';
|
|
16
29
|
import {
|
|
17
30
|
existsSync,
|
|
18
31
|
mkdirSync,
|
|
@@ -29,9 +42,11 @@ import { canvasArtifacts, relocatedName } from '../canvas-artifacts.ts';
|
|
|
29
42
|
import { nextFreeCanvasName } from '../canvas-create.ts';
|
|
30
43
|
import { canvasSlugFromRel } from '../canvas-slug.ts';
|
|
31
44
|
import type { Paths } from '../context.ts';
|
|
45
|
+
import { isUnderscoreModuleRel } from '../skip-dirs.ts';
|
|
32
46
|
import type {
|
|
33
47
|
CreateConflictAnswer,
|
|
34
48
|
CreateRename,
|
|
49
|
+
CreateWithdrawal,
|
|
35
50
|
Operation,
|
|
36
51
|
ProposalResult,
|
|
37
52
|
} from './transaction-client.ts';
|
|
@@ -55,9 +70,20 @@ interface Journal {
|
|
|
55
70
|
tx: string;
|
|
56
71
|
at: number;
|
|
57
72
|
renames: JournalRename[];
|
|
73
|
+
/** 2.0.2 — creates withdrawn instead of renamed (the same file; a module; a canvas gone). */
|
|
74
|
+
withdrawn?: CreateWithdrawal[];
|
|
58
75
|
told?: boolean;
|
|
59
76
|
}
|
|
60
77
|
|
|
78
|
+
/** One live document of the project, as its bootstrap lists it (`lanes` carries the lane hashes). */
|
|
79
|
+
export interface LiveDoc {
|
|
80
|
+
doc: string;
|
|
81
|
+
path: string | null;
|
|
82
|
+
lanes?: Record<string, { hash: string | null } | undefined>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const sha256 = (s: string) => createHash('sha256').update(s, 'utf8').digest('hex');
|
|
86
|
+
|
|
61
87
|
const TX_FILE = /^tx_[A-Za-z0-9]+\.json$/;
|
|
62
88
|
const nameOf = (rel: string) => path.posix.basename(rel).replace(/\.tsx$/i, '');
|
|
63
89
|
|
|
@@ -122,7 +148,7 @@ export interface CreateCollisionDeps {
|
|
|
122
148
|
paths: Paths;
|
|
123
149
|
docNameFor: (slug: string) => string;
|
|
124
150
|
/** The project's live documents now (asked again), or null when it cannot tell. */
|
|
125
|
-
liveDocs: () => Promise<
|
|
151
|
+
liveDocs: () => Promise<LiveDoc[] | null>;
|
|
126
152
|
/**
|
|
127
153
|
* The runtime's part, before any file moves: the old canvas lets go of its
|
|
128
154
|
* file (the peer's canvas arrives there), the new one will join as its create.
|
|
@@ -162,24 +188,47 @@ export function createCollisionRenamer(deps: CreateCollisionDeps) {
|
|
|
162
188
|
renameSync(tmp, fileOf(j.tx));
|
|
163
189
|
};
|
|
164
190
|
|
|
165
|
-
/**
|
|
166
|
-
|
|
167
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Which of a refused proposal's creates the project already has under its name: the one the
|
|
193
|
+
* refusal names (a scoped session may not be told which), and (2.0.2) every other one the
|
|
194
|
+
* project lists — the kernel refuses at the FIRST taken name, and answering one per round left a
|
|
195
|
+
* batch of them past the round cap.
|
|
196
|
+
*/
|
|
197
|
+
function conflicting(
|
|
198
|
+
creates: Operation[],
|
|
199
|
+
result: ProposalResult,
|
|
200
|
+
live: LiveDoc[] | null
|
|
201
|
+
): Operation[] {
|
|
202
|
+
const docs = new Set((live ?? []).map((d) => d.doc));
|
|
203
|
+
const rels = new Set((live ?? []).map((d) => d.path?.toLowerCase()).filter((p) => !!p));
|
|
204
|
+
return creates.filter(
|
|
168
205
|
(o) =>
|
|
169
206
|
(result.doc !== undefined && o.doc === result.doc) ||
|
|
170
|
-
(result.path !== undefined && o.path === result.path)
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// The refusal does not say which (a scoped session may not be told): ask the project.
|
|
174
|
-
const live = await deps.liveDocs();
|
|
175
|
-
if (!live) return [];
|
|
176
|
-
const docs = new Set(live.map((d) => d.doc));
|
|
177
|
-
const rels = new Set(live.map((d) => d.path?.toLowerCase()).filter((p) => !!p));
|
|
178
|
-
return creates.filter(
|
|
179
|
-
(o) => docs.has(o.doc as string) || rels.has(String(o.path).toLowerCase())
|
|
207
|
+
(result.path !== undefined && o.path === result.path) ||
|
|
208
|
+
docs.has(o.doc as string) ||
|
|
209
|
+
rels.has(String(o.path).toLowerCase())
|
|
180
210
|
);
|
|
181
211
|
}
|
|
182
212
|
|
|
213
|
+
/**
|
|
214
|
+
* 2.0.2 — the project's document for this create holds this Mac's source byte for byte: what the
|
|
215
|
+
* create carries, or the file as it is now. Only the same document name counts (the kernel ties a
|
|
216
|
+
* name to its path, so another name at this path is not this canvas).
|
|
217
|
+
*/
|
|
218
|
+
function sameFile(o: Operation, live: LiveDoc[]): boolean {
|
|
219
|
+
const d = live.find((x) => x.doc === o.doc);
|
|
220
|
+
const hash = d?.lanes?.html?.hash;
|
|
221
|
+
if (!d || !hash || String(d.path).toLowerCase() !== String(o.path).toLowerCase()) return false;
|
|
222
|
+
const carried = (o.lanes as Record<string, unknown> | undefined)?.html;
|
|
223
|
+
if (typeof carried === 'string' && carried !== '' && sha256(carried) === hash) return true;
|
|
224
|
+
try {
|
|
225
|
+
const disk = readFileSync(path.join(deps.paths.designRoot, o.path as string), 'utf8');
|
|
226
|
+
return disk !== '' && sha256(disk) === hash;
|
|
227
|
+
} catch {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
183
232
|
async function choose(
|
|
184
233
|
tx: string,
|
|
185
234
|
ops: Operation[],
|
|
@@ -188,18 +237,34 @@ export function createCollisionRenamer(deps: CreateCollisionDeps) {
|
|
|
188
237
|
const creates = ops.filter(
|
|
189
238
|
(o) => o.op === 'doc.create' && typeof o.doc === 'string' && typeof o.path === 'string'
|
|
190
239
|
);
|
|
191
|
-
const
|
|
240
|
+
const listed = await deps.liveDocs();
|
|
241
|
+
const hit = conflicting(creates, result, listed);
|
|
192
242
|
if (!hit.length) return null;
|
|
193
|
-
const live =
|
|
243
|
+
const live = listed ?? [];
|
|
194
244
|
const liveDocs = new Set(live.map((d) => d.doc));
|
|
195
245
|
const liveRels = new Set(live.map((d) => d.path?.toLowerCase()).filter((p) => !!p));
|
|
196
246
|
const chosen = new Set<string>();
|
|
197
247
|
const proposed = new Set(creates.map((o) => String(o.path).toLowerCase()));
|
|
198
248
|
const renames: JournalRename[] = [];
|
|
249
|
+
const withdrawn: CreateWithdrawal[] = [];
|
|
199
250
|
for (const o of hit) {
|
|
200
251
|
const fromRel = o.path as string;
|
|
252
|
+
const doc = o.doc as string;
|
|
253
|
+
// The project already holds this very file: this Mac's canvas IS that document.
|
|
254
|
+
if (sameFile(o, live)) {
|
|
255
|
+
withdrawn.push({ doc, why: 'same' });
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
201
258
|
// A canvas no longer on this Mac has nothing to keep: the refusal stands for it.
|
|
202
|
-
if (!existsSync(path.join(deps.paths.designRoot, fromRel)))
|
|
259
|
+
if (!existsSync(path.join(deps.paths.designRoot, fromRel))) {
|
|
260
|
+
withdrawn.push({ doc, why: 'gone' });
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
// A module is imported by its name: a rename would break every canvas that imports it.
|
|
264
|
+
if (isUnderscoreModuleRel(fromRel)) {
|
|
265
|
+
withdrawn.push({ doc, why: 'module' });
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
203
268
|
const toRel = freeCreateRel(fromRel, (candidate) => {
|
|
204
269
|
const lower = candidate.toLowerCase();
|
|
205
270
|
const abs = path.join(deps.paths.designRoot, candidate);
|
|
@@ -220,8 +285,8 @@ export function createCollisionRenamer(deps: CreateCollisionDeps) {
|
|
|
220
285
|
toRel,
|
|
221
286
|
});
|
|
222
287
|
}
|
|
223
|
-
if (!renames.length) return null;
|
|
224
|
-
const j: Journal = { v: 1, tx, at: now(), renames };
|
|
288
|
+
if (!renames.length && !withdrawn.length) return null;
|
|
289
|
+
const j: Journal = { v: 1, tx, at: now(), renames, ...(withdrawn.length ? { withdrawn } : {}) };
|
|
225
290
|
write(j);
|
|
226
291
|
return j;
|
|
227
292
|
}
|
|
@@ -245,6 +310,17 @@ export function createCollisionRenamer(deps: CreateCollisionDeps) {
|
|
|
245
310
|
html: htmlOf(r.fromDoc),
|
|
246
311
|
}));
|
|
247
312
|
const settles = canvases.map((c) => deps.onRenaming(c));
|
|
313
|
+
for (const w of j.withdrawn ?? []) {
|
|
314
|
+
const rel = String(ops.find((x) => x.op === 'doc.create' && x.doc === w.doc)?.path);
|
|
315
|
+
const slug = slugOf(rel);
|
|
316
|
+
log.log(
|
|
317
|
+
w.why === 'same'
|
|
318
|
+
? `[sync/${slug}] the project already has ${rel} as it is on this Mac — joined, not renamed.`
|
|
319
|
+
: w.why === 'module'
|
|
320
|
+
? `[sync/${slug}] the project already has the module ${rel} — it keeps its name.`
|
|
321
|
+
: `[sync/${slug}] the project already has ${rel}, and this Mac no longer does.`
|
|
322
|
+
);
|
|
323
|
+
}
|
|
248
324
|
for (const c of canvases) {
|
|
249
325
|
moveCanvasArtifacts(deps.paths, c.fromRel, c.toRel, deps.fault);
|
|
250
326
|
log.log(
|
|
@@ -260,6 +336,7 @@ export function createCollisionRenamer(deps: CreateCollisionDeps) {
|
|
|
260
336
|
}));
|
|
261
337
|
return {
|
|
262
338
|
renames,
|
|
339
|
+
...(j.withdrawn?.length ? { withdrawn: j.withdrawn } : {}),
|
|
263
340
|
settled: (r) => {
|
|
264
341
|
for (const s of settles) s(r);
|
|
265
342
|
rmSync(fileOf(tx), { force: true });
|
|
@@ -3582,6 +3582,9 @@ export function createSyncRuntime(
|
|
|
3582
3582
|
renewalsSinceProgress++;
|
|
3583
3583
|
console.log(`[sync] hub credential renewed for ${linkedHub.url}`);
|
|
3584
3584
|
scheduleRenewal();
|
|
3585
|
+
// The owner's config push that ran on the stale credential (401) goes again on this one —
|
|
3586
|
+
// without it a cell stayed without its config.json until it next restarted (2.0.1 field).
|
|
3587
|
+
if (!outboundPaused()) void projectConfigPusher?.push();
|
|
3585
3588
|
return true;
|
|
3586
3589
|
} catch (err) {
|
|
3587
3590
|
console.warn(`[sync] hub credential renewal failed: ${(err as Error).message}`);
|
|
@@ -3930,9 +3933,14 @@ export function createSyncRuntime(
|
|
|
3930
3933
|
acceptedLink.createDoc(canvas.slug, rel, lanes).then(notOursIfRenamed(docName)),
|
|
3931
3934
|
};
|
|
3932
3935
|
let joined = await acceptedColdStart(coldStart);
|
|
3933
|
-
if (
|
|
3936
|
+
if (
|
|
3937
|
+
joined.kind === 'create-refused' &&
|
|
3938
|
+
(joined.code === 'renamed' || joined.code === 'in-project')
|
|
3939
|
+
) {
|
|
3934
3940
|
// S6.13b — this Mac's canvas moved to a free name while its create
|
|
3935
|
-
// waited; what stays at this path is the peer's canvas.
|
|
3941
|
+
// waited; what stays at this path is the peer's canvas. 2.0.2 — or
|
|
3942
|
+
// its create was withdrawn: the project already holds this document
|
|
3943
|
+
// (the same file, or a module that keeps its name), so it joins it.
|
|
3936
3944
|
joined = await acceptedColdStart({ ...coldStart, inProject: true });
|
|
3937
3945
|
}
|
|
3938
3946
|
renamedAway.delete(docName);
|
|
@@ -142,7 +142,14 @@ export function createProjectConfigPusher({
|
|
|
142
142
|
lastAccepted = body;
|
|
143
143
|
return 'refused' as const;
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
// 401 is the CREDENTIAL, not the answer: the runtime renews it and pushes again (2.0.1 field —
|
|
146
|
+
// recording it as answered left a cell without its config.json until the next restart). 403 is
|
|
147
|
+
// the hub saying this account is not the owner: final, not retried on every event.
|
|
148
|
+
if (res.status === 401) {
|
|
149
|
+
log.warn("[sync] the workspace did not take this project's config yet (401) — will retry.");
|
|
150
|
+
return 'refused' as const;
|
|
151
|
+
}
|
|
152
|
+
if (res.status === 403) {
|
|
146
153
|
lastAccepted = body;
|
|
147
154
|
log.warn(`[sync] the workspace did not take this project's config (${res.status}).`);
|
|
148
155
|
return 'refused' as const;
|
|
@@ -189,8 +189,19 @@ export interface CreateRename {
|
|
|
189
189
|
toPath: string;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
/**
|
|
193
|
+
* 2.0.2 — a refused create that is taken OUT of the proposal instead of renamed: the project
|
|
194
|
+
* already holds this very file (`same`), the file is a module that keeps its name (`module`), or
|
|
195
|
+
* the canvas is no longer on this Mac (`gone`). What queued behind it names the same document.
|
|
196
|
+
*/
|
|
197
|
+
export interface CreateWithdrawal {
|
|
198
|
+
doc: string;
|
|
199
|
+
why: 'same' | 'module' | 'gone';
|
|
200
|
+
}
|
|
201
|
+
|
|
192
202
|
export interface CreateConflictAnswer {
|
|
193
203
|
renames: CreateRename[];
|
|
204
|
+
withdrawn?: CreateWithdrawal[];
|
|
194
205
|
/** The renamed create has its FINAL answer (the refused entry is gone). */
|
|
195
206
|
settled: (result: ProposalResult) => void;
|
|
196
207
|
}
|
|
@@ -688,16 +699,18 @@ export function createTransactionClient(opts: TransactionClientOptions) {
|
|
|
688
699
|
function rewriteQueued(
|
|
689
700
|
by: Map<string, CreateRename>,
|
|
690
701
|
oldTx: string,
|
|
691
|
-
|
|
702
|
+
/** null — nothing is sent in its place (every create was withdrawn): the dependency goes. */
|
|
703
|
+
newTx: string | null,
|
|
692
704
|
after: number
|
|
693
705
|
): void {
|
|
694
706
|
for (const { file, entry } of readOutbox()) {
|
|
695
707
|
if (entry.createdAt <= after || !entry.action) continue;
|
|
696
708
|
const before = entry.action;
|
|
697
709
|
const operations = before.operations.map((o) => renamedOp(o, by));
|
|
698
|
-
const deps = before.dependsOn?.
|
|
710
|
+
const deps = before.dependsOn?.flatMap((d) => (d !== oldTx ? [d] : newTx ? [newTx] : []));
|
|
699
711
|
const changed =
|
|
700
712
|
operations.some((o, i) => o !== before.operations[i]) ||
|
|
713
|
+
deps?.length !== before.dependsOn?.length ||
|
|
701
714
|
!!deps?.some((d, i) => d !== before.dependsOn?.[i]);
|
|
702
715
|
if (!changed) continue;
|
|
703
716
|
const action = { ...before, operations, ...(deps ? { dependsOn: deps } : {}) };
|
|
@@ -723,7 +736,11 @@ export function createTransactionClient(opts: TransactionClientOptions) {
|
|
|
723
736
|
file: string,
|
|
724
737
|
entry: OutboxEntry,
|
|
725
738
|
result: ProposalResult
|
|
726
|
-
): Promise<
|
|
739
|
+
): Promise<
|
|
740
|
+
| { file: string; entry: OutboxEntry; answer: CreateConflictAnswer }
|
|
741
|
+
| { file: null; entry: null; answer: CreateConflictAnswer }
|
|
742
|
+
| null
|
|
743
|
+
> {
|
|
727
744
|
if (!opts.onCreateConflict || !entry.action) return null;
|
|
728
745
|
let answer: CreateConflictAnswer | null = null;
|
|
729
746
|
try {
|
|
@@ -733,18 +750,24 @@ export function createTransactionClient(opts: TransactionClientOptions) {
|
|
|
733
750
|
`[sync/tx] ${entry.label}: could not move it to a free name (${(err as Error).message})`
|
|
734
751
|
);
|
|
735
752
|
}
|
|
736
|
-
if (!answer
|
|
753
|
+
if (!answer || (!answer.renames.length && !answer.withdrawn?.length)) return null;
|
|
737
754
|
const by = new Map(answer.renames.map((r) => [r.fromDoc, r]));
|
|
755
|
+
// 2.0.2 — a withdrawn create leaves the proposal; nothing else changes for it.
|
|
756
|
+
const out = new Set((answer.withdrawn ?? []).map((w) => w.doc));
|
|
757
|
+
const operations = entry.action.operations
|
|
758
|
+
.filter((o) => !(o.op === 'doc.create' && typeof o.doc === 'string' && out.has(o.doc)))
|
|
759
|
+
.map((o) => (o.op === 'doc.create' ? renamedOp(o, by) : o));
|
|
760
|
+
if (!operations.length) {
|
|
761
|
+
// Nothing left to send: what waited on it no longer depends on it.
|
|
762
|
+
rewriteQueued(by, entry.transactionId, null, entry.createdAt);
|
|
763
|
+
rmSync(file, { force: true });
|
|
764
|
+
return { file: null, entry: null, answer };
|
|
765
|
+
}
|
|
738
766
|
// Derived, not drawn: a replay that rewrites the queue again names the
|
|
739
767
|
// same transaction (it is only ever written once, so never sent twice).
|
|
740
768
|
const transactionId = `tx_${sha256(`${entry.transactionId}:renamed`).slice(0, 32)}`;
|
|
741
769
|
rewriteQueued(by, entry.transactionId, transactionId, entry.createdAt);
|
|
742
|
-
const action = {
|
|
743
|
-
...entry.action,
|
|
744
|
-
operations: entry.action.operations.map((o) =>
|
|
745
|
-
o.op === 'doc.create' ? renamedOp(o, by) : o
|
|
746
|
-
),
|
|
747
|
-
};
|
|
770
|
+
const action = { ...entry.action, operations };
|
|
748
771
|
const next: OutboxEntry = {
|
|
749
772
|
...makeEntry(action, transactionId, {
|
|
750
773
|
transactionId,
|
|
@@ -818,14 +841,33 @@ export function createTransactionClient(opts: TransactionClientOptions) {
|
|
|
818
841
|
// S6.13b — the name was taken while this Mac was away: the canvas moves to
|
|
819
842
|
// the next free one and its create goes again (bounded: a name taken again
|
|
820
843
|
// meanwhile moves on once more).
|
|
844
|
+
// 2.0.2 — the creates taken out on the way (the same file; a module; a canvas gone).
|
|
845
|
+
const withdrawn: CreateWithdrawal[] = [];
|
|
846
|
+
let operations = entry.action?.operations ?? [];
|
|
821
847
|
for (let round = 0; isCreateConflict(entry, result); round++) {
|
|
822
848
|
const renamed = round < 5 ? await renameRefusedCreate(file, entry, result) : null;
|
|
823
849
|
if (!renamed) {
|
|
824
850
|
rmSync(file, { force: true });
|
|
825
851
|
break;
|
|
826
852
|
}
|
|
853
|
+
withdrawn.push(...(renamed.answer.withdrawn ?? []));
|
|
854
|
+
if (renamed.file === null) {
|
|
855
|
+
// Every create left the proposal: nothing was sent. When the project already holds each
|
|
856
|
+
// of them as it is here, that is the answer this change wanted; otherwise the refusal stands.
|
|
857
|
+
operations = [];
|
|
858
|
+
if (withdrawn.every((w) => w.why === 'same'))
|
|
859
|
+
result = {
|
|
860
|
+
protocol: result.protocol,
|
|
861
|
+
status: 'accepted',
|
|
862
|
+
code: 'withdrawn',
|
|
863
|
+
transactionId: entry.transactionId,
|
|
864
|
+
};
|
|
865
|
+
renamed.answer.settled(result);
|
|
866
|
+
break;
|
|
867
|
+
}
|
|
827
868
|
file = renamed.file;
|
|
828
869
|
entry = renamed.entry;
|
|
870
|
+
operations = entry.action?.operations ?? [];
|
|
829
871
|
const current = entry;
|
|
830
872
|
owned.add(file);
|
|
831
873
|
try {
|
|
@@ -835,11 +877,12 @@ export function createTransactionClient(opts: TransactionClientOptions) {
|
|
|
835
877
|
}
|
|
836
878
|
renamed.answer.settled(result);
|
|
837
879
|
}
|
|
880
|
+
// The caller of a withdrawn create learns it was not sent (accepted-link `createDoc`).
|
|
881
|
+
if (withdrawn.length) result = { ...result, withdrawn };
|
|
838
882
|
if (result.status === 'accepted') {
|
|
839
883
|
acks.push(Math.max(0, now() - madeAt));
|
|
840
884
|
if (acks.length > 200) acks.shift();
|
|
841
885
|
} else rejectedCount++;
|
|
842
|
-
const operations = entry.action?.operations ?? [];
|
|
843
886
|
opts.onResult?.(result, { label: entry.label, operations });
|
|
844
887
|
return { result, operations };
|
|
845
888
|
}
|
|
@@ -563,6 +563,8 @@ export const WRITER_REGISTRY: Record<string, WriterEntry> = {
|
|
|
563
563
|
'/_api/asset-state': { class: 'read' }, // routes/asset-state.ts (S8.19): disk + queue + hub presence, no effect
|
|
564
564
|
// routes/asset-details.ts (S8.21): the details of one asset and the Generated runs — reads of the project's own sidecars
|
|
565
565
|
'/_api/asset-details': { class: 'read' },
|
|
566
|
+
// routes/ds-assets.ts (2.0.2): a design system's own asset library, one folder per page — a read of versioned media
|
|
567
|
+
'/_api/ds/assets': { class: 'read' },
|
|
566
568
|
'/_api/asset-generated': { class: 'read' },
|
|
567
569
|
// routes/generate.ts (S8.16): the consent quote is this process's memory; `of` reads a take's `.gen.json`
|
|
568
570
|
'/_api/generate-takes/quote': { class: 'local' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1agh/maude",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Marketplace of Claude Code plugins by Michal Dovrtěl: `design` (canvas-first design iteration) + `flow` (generic agentic workflow loop with .ai second brain). Ships the `maude` CLI (with `mdcc` legacy alias) to scaffold workspace, run the design dev server, and manage configs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -65,13 +65,13 @@
|
|
|
65
65
|
"test:e2e:desktop:parity:cloud": "pnpm --filter @maude/desktop-e2e e2e:parity:cloud"
|
|
66
66
|
},
|
|
67
67
|
"optionalDependencies": {
|
|
68
|
-
"@1agh/maude-darwin-arm64": "2.0.
|
|
69
|
-
"@1agh/maude-darwin-x64": "2.0.
|
|
70
|
-
"@1agh/maude-linux-arm64": "2.0.
|
|
71
|
-
"@1agh/maude-linux-arm64-musl": "2.0.
|
|
72
|
-
"@1agh/maude-linux-x64": "2.0.
|
|
73
|
-
"@1agh/maude-linux-x64-musl": "2.0.
|
|
74
|
-
"@1agh/maude-win32-x64": "2.0.
|
|
68
|
+
"@1agh/maude-darwin-arm64": "2.0.2",
|
|
69
|
+
"@1agh/maude-darwin-x64": "2.0.2",
|
|
70
|
+
"@1agh/maude-linux-arm64": "2.0.2",
|
|
71
|
+
"@1agh/maude-linux-arm64-musl": "2.0.2",
|
|
72
|
+
"@1agh/maude-linux-x64": "2.0.2",
|
|
73
|
+
"@1agh/maude-linux-x64-musl": "2.0.2",
|
|
74
|
+
"@1agh/maude-win32-x64": "2.0.2"
|
|
75
75
|
},
|
|
76
76
|
"files": [
|
|
77
77
|
"cli",
|