@superblocksteam/workspace-sync 2.0.188 → 2.0.189-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +7 -32
  2. package/dist/agent-skill-path-cases.d.ts +22 -0
  3. package/dist/agent-skill-path-cases.d.ts.map +1 -0
  4. package/dist/agent-skill-path-cases.js +52 -0
  5. package/dist/agent-skill-path-cases.js.map +1 -0
  6. package/dist/control-verifier.d.ts +33 -0
  7. package/dist/control-verifier.d.ts.map +1 -0
  8. package/dist/control-verifier.js +82 -0
  9. package/dist/control-verifier.js.map +1 -0
  10. package/dist/control.d.ts +94 -161
  11. package/dist/control.d.ts.map +1 -1
  12. package/dist/control.js +56 -7
  13. package/dist/control.js.map +1 -1
  14. package/dist/dbfs-transport.d.ts +4 -3
  15. package/dist/dbfs-transport.d.ts.map +1 -1
  16. package/dist/draft-helpers.d.ts +0 -23
  17. package/dist/draft-helpers.d.ts.map +1 -1
  18. package/dist/draft-helpers.js +5 -179
  19. package/dist/draft-helpers.js.map +1 -1
  20. package/dist/index.d.ts +0 -5
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +0 -5
  23. package/dist/index.js.map +1 -1
  24. package/dist/socket-dbfs-transport.d.ts +0 -1
  25. package/dist/socket-dbfs-transport.d.ts.map +1 -1
  26. package/dist/socket-dbfs-transport.js +0 -7
  27. package/dist/socket-dbfs-transport.js.map +1 -1
  28. package/dist/sync-engine.d.ts +37 -39
  29. package/dist/sync-engine.d.ts.map +1 -1
  30. package/dist/sync-engine.js +83 -138
  31. package/dist/sync-engine.js.map +1 -1
  32. package/dist/sync-paths.d.ts +41 -0
  33. package/dist/sync-paths.d.ts.map +1 -1
  34. package/dist/sync-paths.js +54 -0
  35. package/dist/sync-paths.js.map +1 -1
  36. package/dist/testing.d.ts +8 -18
  37. package/dist/testing.d.ts.map +1 -1
  38. package/dist/testing.js +22 -19
  39. package/dist/testing.js.map +1 -1
  40. package/package.json +8 -16
  41. package/dist/draft-journal-store.d.ts +0 -30
  42. package/dist/draft-journal-store.d.ts.map +0 -1
  43. package/dist/draft-journal-store.js +0 -7
  44. package/dist/draft-journal-store.js.map +0 -1
  45. package/dist/file-draft-journal-blob-store.d.ts +0 -14
  46. package/dist/file-draft-journal-blob-store.d.ts.map +0 -1
  47. package/dist/file-draft-journal-blob-store.js +0 -74
  48. package/dist/file-draft-journal-blob-store.js.map +0 -1
  49. package/dist/file-draft-journal-store.d.ts +0 -26
  50. package/dist/file-draft-journal-store.d.ts.map +0 -1
  51. package/dist/file-draft-journal-store.js +0 -123
  52. package/dist/file-draft-journal-store.js.map +0 -1
  53. package/dist/native-draft-session.d.ts +0 -28
  54. package/dist/native-draft-session.d.ts.map +0 -1
  55. package/dist/native-draft-session.js +0 -154
  56. package/dist/native-draft-session.js.map +0 -1
  57. package/dist/session-draft-journal-store.d.ts +0 -44
  58. package/dist/session-draft-journal-store.d.ts.map +0 -1
  59. package/dist/session-draft-journal-store.js +0 -150
  60. package/dist/session-draft-journal-store.js.map +0 -1
@@ -26,7 +26,6 @@ export declare class SocketDbfsTransport implements DbfsTransport {
26
26
  private getBlob;
27
27
  getServerHash(): Promise<string>;
28
28
  setHash({ hash, source }: SetHashRequest): Promise<SetHashResult>;
29
- setDraftState(hasDraft: boolean): Promise<void>;
30
29
  private getManyBatch;
31
30
  }
32
31
  //# sourceMappingURL=socket-dbfs-transport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"socket-dbfs-transport.d.ts","sourceRoot":"","sources":["../src/socket-dbfs-transport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAAa,EACd,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EACL,KAAK,Y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AmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EACL,KAAK,YAAY,EAElB,MAAM,+BAA+B,CAAC;AAKvC,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,SAAS,EAAE,mBAAmB,GAAG,CAAC,MAAM,mBAAmB,CAAC,CAAC;IAC7D,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,aAAa;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAApC,YAA6B,OAAO,EAAE,0BAA0B,EAAI;IAEpE,OAAO,KAAK,MAAM,GAGjB;IAEK,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAErD;IAEK,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAKpD;IAEK,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAK1D;IAEK,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA2B3E;YAEa,OAAO;IAOf,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAQrC;IAEK,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAoBtE;YAEa,YAAY;CAoB3B"}
@@ -81,13 +81,6 @@ export class SocketDbfsTransport {
81
81
  ...(response.heldPaths ? { heldPaths: response.heldPaths } : {}),
82
82
  };
83
83
  }
84
- async setDraftState(hasDraft) {
85
- await unwrapResponseDto(this.client.call.v3.application.draftState.set({
86
- applicationId: this.options.applicationId,
87
- branchName: this.options.branchName,
88
- hasDraft,
89
- }));
90
- }
91
84
  async getManyBatch(rootHash, batch) {
92
85
  const response = await unwrapResponseDto(this.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AY,CAAC,KAAc;IAClC,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;QAEjC,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,4DAA4D;AAC5D,SAAS,sBAAsB,CAAC,KAAc;IAC5C,IAAI,KAAK,YAAY,2BAA2B;QAAE,OAAO,IAAI,CAAC;IAC9D,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACf,KAAK,CAAC,IAAI,KAAK,CAAC;QAEhB,OAAO,IAAI,CAAC;IACd,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,CACL,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC;QACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;QAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC5B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAC9B,CAAC;AACJ,CAAC"}
@@ -3,7 +3,6 @@ import type { ApplicationHashChangeSource, CheckpointSkipReason } from "@superbl
3
3
  import { type BranchWriteGuard } from "./branch-write-guard.js";
4
4
  import type { DbfsTransport } from "./dbfs-transport.js";
5
5
  import { HashCache } from "./hash-cache.js";
6
- import type { NativeDraftJournal } from "./native-draft-session.js";
7
6
  import { type DownloadStats } from "./server-tree.js";
8
7
  import type { WorkspaceStateStore } from "./workspace-state-store.js";
9
8
  /**
@@ -24,49 +23,33 @@ export interface WorkspaceSyncEngineOptions {
24
23
  root: string;
25
24
  transport: DbfsTransport;
26
25
  state: WorkspaceStateStore;
27
- /** The native draft journal, when the host runs native sessions. */
28
- journal?: NativeDraftJournal;
29
26
  guard: BranchWriteGuard;
30
27
  tracer?: Tracer;
31
28
  meter?: Meter;
32
29
  faults?: FaultPoints;
33
30
  /** Seeded on rehydrate; a host may share one with other uploaders. */
34
31
  hashCache?: HashCache;
35
- /** Whether the tree holds unaccepted drafts. Defaults to its swap files. */
36
- hasDraft?: () => Promise<boolean>;
37
32
  }
38
33
  export interface CommitOptions {
39
34
  /**
40
- * Finalize the draft journal before the snapshot (the turn ended). Pass
41
- * false for a read-your-writes commit while a native session is still
42
- * running; the journal then stays open. Defaults to true.
35
+ * A turn end's stored hash from when the turn began. When commits during
36
+ * the turn (read-your-writes, which make no checkpoint) moved the stored
37
+ * hash past it, the commit moves the branch hash even though the tree
38
+ * already matches, so the server sees the commit's source and makes the
39
+ * turn's checkpoint. A turn that moved nothing skips setHash as usual.
43
40
  */
44
- finalizeJournal?: boolean;
45
- /**
46
- * Send the hash even when it matches the stored one, and report the draft
47
- * state even when it was already reported. The server records an accept or
48
- * reject against its last checkpoint and drafts, not the branch hash: an
49
- * accept of drafts the turn-end commit already uploaded must still reach it.
50
- */
51
- checkpoint?: boolean;
52
- /**
53
- * Settles the draft markers (accept, reject or clear) inside the commit
54
- * queue, after the branch guard passes and the draft journal is dropped,
55
- * and before the snapshot. No
56
- * other commit can then reconcile the journal or report draft state between
57
- * the markers changing and this commit.
58
- */
59
- settle?: () => Promise<void>;
41
+ turnBaseHash?: string;
60
42
  }
61
43
  export interface CommitResult {
62
44
  dbfsHash: string;
63
45
  commitId?: string;
64
- /** Why the server made no checkpoint, when it skipped one by design. */
65
- checkpointSkipped?: CheckpointSkipReason;
66
46
  /** False when the tree already matched the stored hash. */
67
47
  moved: boolean;
68
- /** Paths the journal reconcile found changed, when a journal is active. */
69
- journalChangedPaths?: string[];
48
+ /**
49
+ * Why the server made no new checkpoint for this commit. When set, any
50
+ * `commitId` names an earlier checkpoint, not a new one.
51
+ */
52
+ checkpointSkipped?: CheckpointSkipReason;
70
53
  /**
71
54
  * Protected paths whose changes the server holds for a user's approval.
72
55
  * The workspace then holds the server's tree, without those changes.
@@ -80,13 +63,27 @@ export interface FlushResult {
80
63
  uploadedItems: number;
81
64
  }
82
65
  export type RehydrateKind = "fresh" | "resumed" | "replayed" | "reloaded";
66
+ export interface PullResult {
67
+ /** True when the server's tree replaced the local one. */
68
+ filesChanged: boolean;
69
+ /** True when the loaded tree changed a root package file, so the dependencies need an install. */
70
+ packageFilesChanged: boolean;
71
+ }
83
72
  export interface RehydrateOutcome {
84
73
  outcome: RehydrateKind;
85
74
  /** The hash the state store holds afterwards. */
86
75
  dbfsHash: string;
87
76
  /** True when the local tree was replaced from DBFS. */
88
77
  filesChanged: boolean;
89
- /** `reloaded`: where the local diff that lost to the server was kept. */
78
+ /**
79
+ * True when the loaded tree changed a root package file (`package.json` or a
80
+ * lockfile), so the dependencies need an install. Absent reads as false.
81
+ */
82
+ packageFilesChanged?: boolean;
83
+ /**
84
+ * `reloaded`: where the local diff that lost to the server was kept;
85
+ * absent when the tree had nothing unsaved.
86
+ */
90
87
  orphanedPath?: string;
91
88
  /**
92
89
  * `replayed`: false when the guard refused the replay commit (typically the
@@ -94,10 +91,6 @@ export interface RehydrateOutcome {
94
91
  * `commit` replays it.
95
92
  */
96
93
  replayCommitted?: boolean;
97
- /** Set when a running journal (a killed native session) was reconciled. */
98
- interruptedJournal?: {
99
- changedPaths: string[];
100
- };
101
94
  /** The files written from DBFS and their bytes; zero when none were. */
102
95
  downloaded: DownloadStats;
103
96
  }
@@ -109,29 +102,34 @@ export interface WorkspaceSyncEvents {
109
102
  committed: {
110
103
  dbfsHash: string;
111
104
  commitId?: string;
105
+ checkpointSkipped?: CheckpointSkipReason;
112
106
  };
113
107
  "unsynced-changed": {
114
108
  unsynced: boolean;
115
109
  };
116
110
  }
117
111
  export interface WorkspaceSyncEngine {
118
- /** Reconciles the local tree, the stored hash and the server on boot. */
112
+ /**
113
+ * Reconciles the local tree, the stored hash and the server: on boot, and
114
+ * when the branch moved under a running workspace (a restore).
115
+ */
119
116
  rehydrate(options?: RehydrateOptions): Promise<RehydrateOutcome>;
120
117
  /** Uploads blobs for the current tree. Never moves the branch hash. */
121
118
  interimFlush(): Promise<FlushResult>;
122
119
  /** The turn-end commit. */
123
120
  commit(source: ApplicationHashChangeSource, options?: CommitOptions): Promise<CommitResult>;
124
121
  /**
125
- * Reports whether the tree holds drafts, even when that was already
126
- * reported. For a draft change that moves no hash, such as clearing markers.
122
+ * A stopped turn's end: puts the tree `hash` back on disk and moves the
123
+ * branch to it with `ai:reject`, which makes no checkpoint. The branch only
124
+ * moves when a commit during the turn moved it.
127
125
  */
128
- resendDraftState(options?: Pick<CommitOptions, "settle">): Promise<void>;
126
+ revert(hash: string): Promise<CommitResult>;
129
127
  /**
130
128
  * Loads the server's tree when the branch moved and this workspace has
131
129
  * nothing unsaved, for example after a user approved a held change.
132
- * Resolves true when it loaded a tree.
130
+ * Says whether it loaded a tree and whether that tree changed a package file.
133
131
  */
134
- pull(): Promise<boolean>;
132
+ pull(): Promise<PullResult>;
135
133
  /** True while the tree has changes the branch hash does not include. */
136
134
  readonly unsynced: boolean;
137
135
  /** The hash last committed or loaded, once known. */
@@ -1 +1 @@
1
- {"version":3,"file":"sync-engine.d.ts","sourceRoot":"","sources":["../src/sync-engine.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EACV,2BAA2B,EAC3B,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,kBAAkB,CAAC;AAiB1B,OAAO,KAAK,EAEV,mBAAmB,EACpB,MAAM,4BAA4B,CA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AC;IAClB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,EAAE,CAAC,CAAC,SAAS,MAAM,mBAAmB,EACpC,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,GAClD,MAAM,IAAI,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,0BAA0B,GAClC,mBAAmB,CAErB"}
@@ -1,6 +1,5 @@
1
1
  import * as fsp from "node:fs/promises";
2
2
  import { BranchWriteRejectedError, } from "./branch-write-guard.js";
3
- import { hasDraftsFailClosed } from "./draft-helpers.js";
4
3
  import { HashCache } from "./hash-cache.js";
5
4
  import { hashLocalDirectory } from "./hash-dir-tree.js";
6
5
  import { downloadServerTree, flattenTree, readServerTree, } from "./server-tree.js";
@@ -9,6 +8,27 @@ import { collectSnapshotUploadItems, isUploadRefusal, uploadSnapshotItems, } fro
9
8
  import { createSyncTelemetry, inSpan, } from "./sync-telemetry.js";
10
9
  const BLOB_BATCH = 64;
11
10
  const NOTHING_DOWNLOADED = { files: 0, bytes: 0 };
11
+ /** Root files that decide what the dependency install puts in `node_modules`. */
12
+ const PACKAGE_FILES = [
13
+ "package.json",
14
+ "pnpm-workspace.yaml",
15
+ "pnpm-lock.yaml",
16
+ "package-lock.json",
17
+ ];
18
+ /** True when a root package file differs between the two trees. A missing tree has no files. */
19
+ function packageFilesDiffer(local, loaded) {
20
+ return PACKAGE_FILES.some((name) => {
21
+ const hashOf = (tree) => {
22
+ const entry = tree?.contents.find((item) => item.name === name);
23
+ return entry?.type === "-" ? entry.hash : undefined;
24
+ };
25
+ return hashOf(local) !== hashOf(loaded);
26
+ });
27
+ }
28
+ const NOTHING_PULLED = {
29
+ filesChanged: false,
30
+ packageFilesChanged: false,
31
+ };
12
32
  /**
13
33
  * Creates the sync engine for one workspace. DBFS is the commit point: the
14
34
  * engine moves the branch hash only in {@link WorkspaceSyncEngine.commit} (and
@@ -30,7 +50,6 @@ class SyncEngine {
30
50
  writes = 0;
31
51
  committedWrites = 0;
32
52
  lastUnsynced = false;
33
- reportedDraft;
34
53
  constructor(options) {
35
54
  this.options = options;
36
55
  this.hashCache = options.hashCache ?? new HashCache();
@@ -67,26 +86,20 @@ class SyncEngine {
67
86
  }));
68
87
  }
69
88
  commit(source, options = {}) {
70
- const { settle } = options;
71
- return this.serialize(async () => {
72
- if (settle)
73
- await this.settleNow(settle);
74
- return this.commitNow(source, settle
75
- ? "skip"
76
- : options.finalizeJournal === false
77
- ? "keep"
78
- : "finalize", options.checkpoint ?? false);
79
- });
89
+ return this.serialize(() => this.commitNow(source, options.turnBaseHash));
80
90
  }
81
- resendDraftState(options = {}) {
82
- const { settle } = options;
91
+ revert(hash) {
83
92
  return this.serialize(async () => {
84
- if (settle)
85
- await this.settleNow(settle);
86
- await this.reportDraftState({
87
- force: true,
88
- beforeSend: () => this.assertOwnsBranch(),
93
+ const { root, transport } = this.options;
94
+ const tree = await readServerTree(transport, hash);
95
+ await downloadServerTree({
96
+ transport,
97
+ tree,
98
+ local: await this.hashLocalTree(),
99
+ root,
89
100
  });
101
+ this.hashCache.add_directory_recursive(tree);
102
+ return this.commitNow("ai:reject", undefined, hash);
90
103
  });
91
104
  }
92
105
  pull() {
@@ -94,13 +107,17 @@ class SyncEngine {
94
107
  const serverHash = await this.options.transport.getServerHash();
95
108
  const storedHash = (await this.options.state.read())?.dbfsHash;
96
109
  if (serverHash === storedHash)
97
- return false;
110
+ return NOTHING_PULLED;
98
111
  // Unsaved changes stay: the commit guard then reports the moved branch.
99
- if ((await this.hashLocalTree())?.hash !== storedHash)
100
- return false;
101
- await this.loadServerTree(serverHash);
112
+ const local = await this.hashLocalTree();
113
+ if (local?.hash !== storedHash)
114
+ return NOTHING_PULLED;
115
+ const tree = await this.loadServerTree(serverHash, local);
102
116
  this.updateUnsynced();
103
- return true;
117
+ return {
118
+ filesChanged: true,
119
+ packageFilesChanged: packageFilesDiffer(local, tree),
120
+ };
104
121
  });
105
122
  }
106
123
  rehydrate(options = {}) {
@@ -114,7 +131,7 @@ class SyncEngine {
114
131
  }));
115
132
  }
116
133
  async rehydrateNow({ replaySource = "ai:generate:post", }) {
117
- const { root, transport, state, journal } = this.options;
134
+ const { root, transport, state } = this.options;
118
135
  const serverHash = await transport.getServerHash();
119
136
  const storedHash = (await state.read())?.dbfsHash;
120
137
  const local = await this.hashLocalTree();
@@ -133,6 +150,7 @@ class SyncEngine {
133
150
  outcome: "fresh",
134
151
  dbfsHash: serverHash,
135
152
  filesChanged: true,
153
+ packageFilesChanged: packageFilesDiffer(undefined, tree),
136
154
  downloaded,
137
155
  };
138
156
  }
@@ -146,6 +164,7 @@ class SyncEngine {
146
164
  outcome: "resumed",
147
165
  dbfsHash: serverHash,
148
166
  filesChanged: false,
167
+ packageFilesChanged: false,
149
168
  downloaded: NOTHING_DOWNLOADED,
150
169
  };
151
170
  }
@@ -157,7 +176,7 @@ class SyncEngine {
157
176
  this.localHash = local.hash;
158
177
  let replayCommitted = true;
159
178
  try {
160
- await this.commitNow(replaySource, "skip");
179
+ await this.commitNow(replaySource);
161
180
  }
162
181
  catch (error) {
163
182
  if (!(error instanceof BranchWriteRejectedError) ||
@@ -169,6 +188,7 @@ class SyncEngine {
169
188
  outcome: "replayed",
170
189
  dbfsHash: this.committedHash ?? serverHash,
171
190
  filesChanged: false,
191
+ packageFilesChanged: false,
172
192
  replayCommitted,
173
193
  downloaded: NOTHING_DOWNLOADED,
174
194
  };
@@ -176,9 +196,13 @@ class SyncEngine {
176
196
  else {
177
197
  // The server moved (or this workspace never recorded a hash): keep the
178
198
  // local difference where an operator or agent can find it, then load
179
- // the server tree.
199
+ // the server tree. A tree that still matches the stored hash has
200
+ // nothing unsaved (the server moved under a clean workspace, as a
201
+ // restore does), so there is nothing to keep.
180
202
  const tree = await readServerTree(transport, serverHash);
181
- const orphanedPath = await this.keepOrphan(serverHash, storedHash, tree);
203
+ const orphanedPath = local.hash === storedHash
204
+ ? undefined
205
+ : await this.keepOrphan(serverHash, storedHash, tree);
182
206
  const downloaded = await downloadServerTree({
183
207
  transport,
184
208
  tree,
@@ -190,89 +214,58 @@ class SyncEngine {
190
214
  outcome: "reloaded",
191
215
  dbfsHash: serverHash,
192
216
  filesChanged: true,
193
- orphanedPath,
217
+ packageFilesChanged: packageFilesDiffer(local, tree),
218
+ ...(orphanedPath && { orphanedPath }),
194
219
  downloaded,
195
220
  };
196
221
  }
197
- if (journal && (await journal.phase()) === "running") {
198
- const reconciled = await journal.reconcile(false);
199
- if (reconciled) {
200
- result.interruptedJournal = { changedPaths: reconciled.changedPaths };
201
- // Without the branch the flag is not this workspace's to set; the
202
- // next commit reports it once the guard passes.
203
- if (reconciled.changedPaths.length > 0)
204
- await this.reportDraftState({
205
- only: true,
206
- beforeSend: () => this.assertOwnsBranch(),
207
- }).catch((error) => {
208
- if (!(error instanceof BranchWriteRejectedError))
209
- throw error;
210
- });
211
- }
212
- }
213
222
  if (result.outcome !== "replayed" || result.replayCommitted)
214
223
  this.committedWrites = writesAtStart;
215
224
  this.updateUnsynced();
216
225
  return result;
217
226
  }
218
- async commitNow(source, journalMode, checkpoint = false) {
219
- const { root, state, journal, guard } = this.options;
227
+ /** With `requireHash`, refuses to publish any snapshot but that tree. */
228
+ async commitNow(source, turnBaseHash, requireHash) {
229
+ const { root, state, guard } = this.options;
220
230
  const started = performance.now();
221
231
  let outcome = "error";
222
232
  try {
223
233
  return await inSpan(this.telemetry.tracer, "workspace.commit", async (span) => {
224
234
  span.setAttribute("workspace.sync.source", source);
225
- span.setAttribute("workspace.sync.checkpoint", checkpoint);
226
235
  const writesAtStart = this.writes;
227
- let journalChangedPaths;
228
- if (journal && journalMode !== "skip") {
229
- const reconciled = await journal.reconcile(journalMode === "finalize");
230
- journalChangedPaths = reconciled?.changedPaths;
231
- }
232
- const baseHash = (await state.read())?.dbfsHash;
233
- const assertCanCommit = async () => {
234
- try {
235
- await guard.assertCanCommit(baseHash);
236
- }
237
- catch (error) {
238
- if (error instanceof BranchWriteRejectedError) {
239
- outcome = "rejected";
240
- span.setAttribute("workspace.sync.rejection", error.reason);
241
- }
242
- throw error;
243
- }
244
- };
245
- // Drafts go before the hash: the server files an
246
- // `ai:generate:post` as a draft only while it holds isDraft=true.
247
- // Reported after, a turn's first drafts become a manual checkpoint,
248
- // and the accept that follows finds nothing new to checkpoint. The
249
- // guard runs first, so a workspace that lost the branch cannot
250
- // flip the shared flag.
251
- await this.reportDraftState({
252
- only: true,
253
- force: checkpoint,
254
- beforeSend: assertCanCommit,
255
- });
256
236
  await this.fault("after-write-before-flush");
257
237
  const snapshot = await snapshotLocalDirectoryWithDrafts(root);
258
238
  const hash = snapshot.hash;
239
+ // A writer still running after a revert's download would otherwise be published as the reverted tree.
240
+ if (requireHash !== undefined && hash !== requireHash)
241
+ throw new Error("The tree changed while it was being reverted");
259
242
  this.localHash = hash;
260
- if (hash === baseHash && !checkpoint) {
243
+ const baseHash = (await state.read())?.dbfsHash;
244
+ const moved = hash !== baseHash;
245
+ const movedDuringTurn = turnBaseHash !== undefined && baseHash !== turnBaseHash;
246
+ if (!moved && !movedDuringTurn) {
261
247
  this.committedHash = baseHash;
262
- await journal?.retireUploaded(hash);
263
248
  this.committedWrites = writesAtStart;
264
249
  this.updateUnsynced();
265
250
  outcome = "unchanged";
266
251
  span.setAttribute("workspace.sync.outcome", outcome);
267
- return {
268
- dbfsHash: hash,
269
- moved: false,
270
- ...(journalChangedPaths && { journalChangedPaths }),
271
- };
252
+ return { dbfsHash: hash, moved: false };
272
253
  }
273
254
  const uploadedItems = await this.upload(snapshot);
274
255
  span.setAttribute("workspace.sync.uploaded_items", uploadedItems);
275
256
  await this.fault("after-put-before-set");
257
+ const assertCanCommit = async () => {
258
+ try {
259
+ await guard.assertCanCommit(baseHash);
260
+ }
261
+ catch (error) {
262
+ if (error instanceof BranchWriteRejectedError) {
263
+ outcome = "rejected";
264
+ span.setAttribute("workspace.sync.rejection", error.reason);
265
+ }
266
+ throw error;
267
+ }
268
+ };
276
269
  await assertCanCommit();
277
270
  const result = await this.setHashRecovering(snapshot, { hash, baseHash, source }, assertCanCommit);
278
271
  if (result.checkpointSkipped)
@@ -287,24 +280,16 @@ class SyncEngine {
287
280
  }
288
281
  else
289
282
  await this.loadServerTree(committed, snapshot);
290
- await journal?.retireUploaded(hash);
291
283
  this.committedWrites = writesAtStart;
292
284
  this.updateUnsynced();
293
- // Only an accept or reject checkpoint clears the flag, and only
294
- // once the server has its hash. A plain commit never does: after a
295
- // failed accept the markers are gone, and clearing then would make
296
- // the AI tree publishable without its checkpoint.
297
- if (checkpoint)
298
- await this.reportDraftState({
299
- only: false,
300
- force: true,
301
- beforeSend: () => this.assertOwnsBranch(),
302
- });
303
285
  outcome = "committed";
304
286
  span.setAttribute("workspace.sync.outcome", outcome);
305
287
  this.emit("committed", {
306
288
  dbfsHash: committed,
307
289
  ...(result.commitId && { commitId: result.commitId }),
290
+ ...(result.checkpointSkipped && {
291
+ checkpointSkipped: result.checkpointSkipped,
292
+ }),
308
293
  });
309
294
  return {
310
295
  dbfsHash: committed,
@@ -314,7 +299,6 @@ class SyncEngine {
314
299
  ...(result.checkpointSkipped && {
315
300
  checkpointSkipped: result.checkpointSkipped,
316
301
  }),
317
- ...(journalChangedPaths && { journalChangedPaths }),
318
302
  };
319
303
  });
320
304
  }
@@ -380,7 +364,8 @@ class SyncEngine {
380
364
  }
381
365
  /**
382
366
  * Writes the server's tree over the paths where it differs from `local`
383
- * (by default the tree on disk now) and records its hash.
367
+ * (by default the tree on disk now) and records its hash. Returns the
368
+ * loaded tree.
384
369
  */
385
370
  async loadServerTree(serverHash, local) {
386
371
  const { root, transport } = this.options;
@@ -392,6 +377,7 @@ class SyncEngine {
392
377
  root,
393
378
  });
394
379
  await this.storeLoaded(serverHash, tree);
380
+ return tree;
395
381
  }
396
382
  async storeLoaded(hash, tree) {
397
383
  await this.options.state.write({ dbfsHash: hash });
@@ -452,47 +438,6 @@ class SyncEngine {
452
438
  deleted,
453
439
  });
454
440
  }
455
- /**
456
- * Runs `settle` once the guard lets this workspace write the branch, so a
457
- * refused settle leaves the markers and the server's draft flag as they
458
- * were. A running journal (its turn-end reconcile failed) is reconciled
459
- * first, so every marker is there to accept or restore. The journal is then
460
- * dropped, since its next reconcile would rebuild the markers `settle`
461
- * removes. Callers hold the queue.
462
- */
463
- async settleNow(settle) {
464
- await this.assertOwnsBranch();
465
- const { journal } = this.options;
466
- if (journal && (await journal.phase()) === "running")
467
- await journal.reconcile(false);
468
- await journal?.clear();
469
- await settle();
470
- }
471
- /**
472
- * The server's draft flag is shared by the branch, so only the workspace
473
- * the guard lets write the branch may change it: the lock holder, on the
474
- * hash it last committed.
475
- */
476
- async assertOwnsBranch() {
477
- await this.options.guard.assertCanCommit((await this.options.state.read())?.dbfsHash);
478
- }
479
- /**
480
- * Sends the tree's draft state when it changed, or always with `force`.
481
- * With `only`, sends it only when the tree's state is that value;
482
- * `beforeSend` runs only when it is about to be sent.
483
- */
484
- async reportDraftState(options = {}) {
485
- const { force = false, only, beforeSend } = options;
486
- const hasDraft = await (this.options.hasDraft?.() ??
487
- hasDraftsFailClosed(this.options.root));
488
- if (only !== undefined && hasDraft !== only)
489
- return;
490
- if (!force && hasDraft === this.reportedDraft)
491
- return;
492
- await beforeSend?.();
493
- await this.options.transport.setDraftState(hasDraft);
494
- this.reportedDraft = hasDraft;
495
- }
496
441
  async fault(point) {
497
442
  await this.options.faults?.[point]?.();
498
443
  }