@narumitw/pi-sync-daemon 0.8.0 → 0.9.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 (61) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cli.js +1 -1
  3. package/dist/consent.d.ts +14 -2
  4. package/dist/consent.js +134 -16
  5. package/dist/engine/backends/git/git-backend.d.ts +1 -2
  6. package/dist/engine/backends/git/git-backend.js +61 -30
  7. package/dist/engine/commands/command-types.d.ts +2 -1
  8. package/dist/engine/host.d.ts +1 -0
  9. package/dist/engine/ignore/ignore-initialization.d.ts +8 -1
  10. package/dist/engine/ignore/ignore-initialization.js +142 -40
  11. package/dist/engine/ignore/ignore-settings.d.ts +16 -1
  12. package/dist/engine/ignore/ignore-settings.js +94 -26
  13. package/dist/engine/ignore/ignore-source.d.ts +1 -1
  14. package/dist/engine/ignore/ignore-source.js +1 -1
  15. package/dist/engine/settings/config-file.js +1 -1
  16. package/dist/engine/settings/config.d.ts +3 -2
  17. package/dist/engine/settings/config.js +71 -28
  18. package/dist/engine/settings/settings-management.d.ts +3 -1
  19. package/dist/engine/settings/settings-management.js +8 -2
  20. package/dist/engine/settings/settings-types.d.ts +2 -0
  21. package/dist/engine/snapshot/session-paths.js +7 -2
  22. package/dist/engine/snapshot/snapshot-apply.d.ts +1 -1
  23. package/dist/engine/snapshot/snapshot-transaction-policy.d.ts +7 -2
  24. package/dist/engine/snapshot/snapshot-transaction-policy.js +37 -17
  25. package/dist/engine/snapshot/snapshot-transaction.js +55 -13
  26. package/dist/engine/snapshot/snapshot-types.d.ts +4 -0
  27. package/dist/engine/sync/agent-plan.js +1 -0
  28. package/dist/engine/sync/agent-sync.js +8 -1
  29. package/dist/engine/sync/continuous-sync.d.ts +3 -1
  30. package/dist/engine/sync/continuous-sync.js +32 -15
  31. package/dist/engine/sync/merge-acceptance.d.ts +8 -0
  32. package/dist/engine/sync/merge-acceptance.js +29 -0
  33. package/dist/engine/sync/merge-apply.js +7 -4
  34. package/dist/engine/sync/merge-journal.d.ts +6 -0
  35. package/dist/engine/sync/merge-journal.js +33 -14
  36. package/dist/engine/sync/merged-sync.js +31 -39
  37. package/dist/engine/sync/remote-snapshot.d.ts +2 -1
  38. package/dist/engine/sync/remote-snapshot.js +17 -2
  39. package/dist/engine/sync/session-push.js +20 -6
  40. package/dist/engine/sync/sync-error-guidance.js +16 -3
  41. package/dist/engine/sync/sync-mutations.js +75 -54
  42. package/dist/engine/sync/sync-policy.d.ts +5 -0
  43. package/dist/engine/sync/sync-policy.js +28 -3
  44. package/dist/engine/sync/sync-state.d.ts +2 -0
  45. package/dist/engine/sync/sync-state.js +3 -8
  46. package/dist/engine/sync/transfer-freshness.d.ts +31 -0
  47. package/dist/engine/sync/transfer-freshness.js +82 -0
  48. package/dist/engine/ui/sync-format.d.ts +16 -5
  49. package/dist/engine/ui/sync-format.js +23 -55
  50. package/dist/engine/ui/transfer-review.d.ts +2 -1
  51. package/dist/engine/ui/transfer-review.js +3 -3
  52. package/dist/engine-service.d.ts +1 -1
  53. package/dist/engine-service.js +124 -27
  54. package/dist/monitor.d.ts +4 -1
  55. package/dist/monitor.js +84 -32
  56. package/dist/server.d.ts +1 -0
  57. package/dist/server.js +46 -5
  58. package/dist/service-host.d.ts +1 -1
  59. package/dist/service-host.js +2 -1
  60. package/docs/architecture.md +14 -6
  61. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @narumitw/pi-sync-daemon
2
2
 
3
+ ## 0.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - eb17fcc: Explain how to reduce sync scope when the agent-directory scan exceeds its limit. Replace outdated Check setup directions with current Diagnostics and storage settings paths.
8
+ - aa99878: Let Up and Down select sync confirmation actions immediately. Show directional counts and safety notes in the summary, with exact file paths available in View details instead of requiring a scroll through the entire file list.
9
+ - 8e32b4b: Exclude top-level `git/` package checkouts in new `.syncignore` starter files and list the starter rules in alphabetical order. Preserve existing rule files and recover interrupted creation with its original rules.
10
+
11
+ ## 0.9.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 5dfa289: Resolve local ignore-file policies for reviewed setup, inspection, transfer, and recovery while keeping legacy policies usable in mixed settings. Keep rule files local and publish only the portable policy fingerprint in version 6 snapshots. Create a missing starter after confirmation on Linux, macOS, and Windows; if automatic creation is unavailable, show the exact path and instructions for manual creation. Preserve the existing settings writer and keep in-app rule saves disabled.
16
+
17
+ ### Patch Changes
18
+
19
+ - 25777f7: Read Git history manifests in bounded batches to reduce subprocess launches. Keep the same history preview and validate all retained publications in the original order.
20
+
3
21
  ## 0.8.0
4
22
 
5
23
  ### Minor Changes
package/dist/cli.js CHANGED
@@ -39,7 +39,7 @@ export async function main(args) {
39
39
  log?.close(); /* Never follow a replaced diagnostic path. */
40
40
  }
41
41
  };
42
- const service = createEngineService(paths.root);
42
+ const service = createEngineService(paths.root, true);
43
43
  let server;
44
44
  try {
45
45
  server = await startServer(paths.root, service.execute, {
package/dist/consent.d.ts CHANGED
@@ -7,6 +7,7 @@ interface Consent {
7
7
  nonce: string;
8
8
  setups: Record<string, {
9
9
  fingerprint: string;
10
+ automaticFingerprint?: string;
10
11
  model?: ClientFacts["model"];
11
12
  sessionDir?: string;
12
13
  cwd?: string;
@@ -17,10 +18,21 @@ export declare class ConsentPublicationError extends Error {
17
18
  }
18
19
  /** A different interactive binding cannot silently resume an older unattended grant after exit/restart. */
19
20
  export declare function revokeChangedBindings(root: string, peers: readonly ClientFacts[]): void;
20
- /** Explicit offline repair only. The caller must exclude daemon owners and state migration. */
21
+ export declare function revokeAfterExitGrants(root: string): number;
21
22
  export declare function revokeRetainedGrants(root: string): number;
22
23
  export declare function readConsent(root: string): Consent | undefined;
23
24
  export declare function consentFingerprint(root: string, config: AnySyncConfig): string;
25
+ export declare function automaticPolicyAuthorized(root: string, config: AnySyncConfig): boolean;
26
+ export declare function reviewAutomaticPolicy(execution: Execution, config: AnySyncConfig, expectedFingerprint: string): Promise<boolean>;
27
+ export declare function captureAutomaticAuthorization(execution: Execution, expectedFingerprint?: string): Promise<{
28
+ config: AnySyncConfig;
29
+ validate: (current?: AnySyncConfig) => void;
30
+ refresh: () => Promise<void>;
31
+ }>;
32
+ export declare function participantBinding(execution: Pick<Execution, "participants">): string;
24
33
  export declare function requireHandover(execution: Execution): Promise<void>;
25
- export declare function authorizeAfterExit(execution: Execution, payload: unknown): Promise<boolean>;
34
+ export declare function authorizeAfterExit(execution: Execution, payload: unknown): Promise<{
35
+ config: AnySyncConfig;
36
+ afterExit: boolean;
37
+ } | undefined>;
26
38
  export {};
package/dist/consent.js CHANGED
@@ -3,6 +3,8 @@ import { closeSync, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readFi
3
3
  import path from "node:path";
4
4
  import { syncCheckConfigFingerprint } from "./engine/settings/config.js";
5
5
  import { stateDir } from "./engine/state/state-directory.js";
6
+ import { startupTransferEnabled } from "./engine/sync/agent-policy.js";
7
+ import { syncSessionsSelected } from "./engine/sync/sync-policy.js";
6
8
  import { safeTerminalText } from "./engine/ui/terminal-text.js";
7
9
  import { record } from "./protocol.js";
8
10
  function file(root) {
@@ -82,7 +84,9 @@ export function revokeChangedBindings(root, peers) {
82
84
  if (changed)
83
85
  publishConsent(consent);
84
86
  }
85
- /** Explicit offline repair only. The caller must exclude daemon owners and state migration. */
87
+ export function revokeAfterExitGrants(root) {
88
+ return revokeRetainedGrants(root);
89
+ }
86
90
  export function revokeRetainedGrants(root) {
87
91
  const consent = readConsent(root);
88
92
  if (!consent)
@@ -129,6 +133,8 @@ export function readConsent(root) {
129
133
  if (!record(entry) ||
130
134
  typeof entry.fingerprint !== "string" ||
131
135
  !/^[a-f0-9]{64}$/u.test(entry.fingerprint) ||
136
+ (entry.automaticFingerprint !== undefined &&
137
+ (typeof entry.automaticFingerprint !== "string" || !/^[a-f0-9]{64}$/u.test(entry.automaticFingerprint))) ||
132
138
  typeof entry.afterExit !== "boolean" ||
133
139
  (entry.cwd !== undefined &&
134
140
  (typeof entry.cwd !== "string" || !path.isAbsolute(entry.cwd) || entry.cwd.includes("\0"))) ||
@@ -167,6 +173,119 @@ export function consentFingerprint(root, config) {
167
173
  .update(syncCheckConfigFingerprint(config))
168
174
  .digest("hex");
169
175
  }
176
+ export function automaticPolicyAuthorized(root, config) {
177
+ if (config.reservedIgnoreNames === undefined)
178
+ return true;
179
+ const saved = readConsent(root)?.setups[config.setupName];
180
+ return saved?.automaticFingerprint !== undefined && saved.automaticFingerprint === consentFingerprint(root, config);
181
+ }
182
+ export async function reviewAutomaticPolicy(execution, config, expectedFingerprint) {
183
+ if (consentFingerprint(execution.root, config) !== expectedFingerprint)
184
+ throw new Error("Setup changed; reopen the automatic transfer review.");
185
+ if (config.reservedIgnoreNames === undefined || automaticPolicyAuthorized(execution.root, config))
186
+ return false;
187
+ const consent = readConsent(execution.root);
188
+ if (!consent)
189
+ return false;
190
+ const consentToken = JSON.stringify(consent);
191
+ const peers = participantBinding(execution);
192
+ const binding = JSON.stringify(execution.facts());
193
+ const { loadConfigForCheck } = await import("./engine/settings/config.js");
194
+ const fingerprint = syncCheckConfigFingerprint(config);
195
+ const validate = () => {
196
+ execution.validate();
197
+ execution.signal.throwIfAborted();
198
+ if (participantBinding(execution) !== peers ||
199
+ JSON.stringify(execution.facts()) !== binding ||
200
+ JSON.stringify(readConsent(execution.root)) !== consentToken)
201
+ throw new Error("Participants or consent changed during automatic transfer review.");
202
+ };
203
+ const current = await loadConfigForCheck(undefined, execution.signal);
204
+ validate();
205
+ if (syncCheckConfigFingerprint(current) !== fingerprint)
206
+ return false;
207
+ const modes = [
208
+ startupTransferEnabled(config) && "Automatic transfer at startup",
209
+ config.automatic &&
210
+ syncSessionsSelected(config) &&
211
+ "Push selected files on shutdown (including sessions when selected)",
212
+ config.continuous && config.agentMode && "Continuous sync and Autonomous model requests",
213
+ ].filter(Boolean);
214
+ if (modes.length === 0)
215
+ throw new Error("No automatic transfer mode is enabled under the current local rules.");
216
+ const accepted = await execution.request("confirm", {
217
+ title: "Allow the enabled automatic sync modes for this setup?",
218
+ message: [
219
+ `Setup: ${safeTerminalText(config.setupName)}`,
220
+ `Destination: ${safeTerminalText(config.connectionName)} · ${safeTerminalText(config.storagePath)}`,
221
+ ...(config.ignorePolicy
222
+ ? [
223
+ `Local ignore file: ${safeTerminalText(config.ignorePolicy.filename)}`,
224
+ "Review this file before you approve its scope.",
225
+ ]
226
+ : []),
227
+ `Enabled modes: ${modes.join("; ")}`,
228
+ "Their usual baseline, remote selection, and ownership checks still apply. This does not allow work after the last Pi exits. A settings or rule-file change requires a new review.",
229
+ ].join("\n"),
230
+ });
231
+ validate();
232
+ if (accepted !== true)
233
+ return false;
234
+ const latest = await loadConfigForCheck(undefined, execution.signal);
235
+ await config.validateIgnorePolicy?.();
236
+ validate();
237
+ if (syncCheckConfigFingerprint(latest) !== fingerprint)
238
+ throw new Error("Setup changed during automatic transfer review.");
239
+ const saved = consent.setups[config.setupName];
240
+ const automaticFingerprint = consentFingerprint(execution.root, config);
241
+ publishConsent({
242
+ ...consent,
243
+ setups: {
244
+ ...consent.setups,
245
+ [config.setupName]: {
246
+ ...saved,
247
+ fingerprint: saved?.fingerprint ?? automaticFingerprint,
248
+ afterExit: saved?.afterExit ?? false,
249
+ automaticFingerprint,
250
+ },
251
+ },
252
+ });
253
+ return true;
254
+ }
255
+ export async function captureAutomaticAuthorization(execution, expectedFingerprint) {
256
+ const consent = readConsent(execution.root);
257
+ if (!consent)
258
+ throw new Error("Automatic work requires reviewed daemon handover first.");
259
+ const consentToken = JSON.stringify(consent);
260
+ const peers = participantBinding(execution);
261
+ const { loadConfigForCheck } = await import("./engine/settings/config.js");
262
+ const validateParticipants = () => {
263
+ execution.validate();
264
+ if (participantBinding(execution) !== peers || JSON.stringify(readConsent(execution.root)) !== consentToken)
265
+ throw new Error("Daemon participants or consent changed before automatic work completed.");
266
+ };
267
+ validateParticipants();
268
+ const config = await loadConfigForCheck(undefined, execution.signal);
269
+ validateParticipants();
270
+ const fingerprint = syncCheckConfigFingerprint(config);
271
+ if (expectedFingerprint !== undefined ? fingerprint !== expectedFingerprint : config.reservedIgnoreNames !== undefined)
272
+ throw new Error("Settings changed before automatic work; use the reviewed foreground command.");
273
+ if (!automaticPolicyAuthorized(execution.root, config))
274
+ throw new Error("Automatic transfer requires separate approval for the current setup and policy. Run reviewed /sync first.");
275
+ const validate = (current) => {
276
+ validateParticipants();
277
+ if (current && syncCheckConfigFingerprint(current) !== fingerprint)
278
+ throw new Error("Settings changed before automatic work completed.");
279
+ };
280
+ const refresh = async () => {
281
+ validate();
282
+ validate(await loadConfigForCheck(undefined, execution.signal));
283
+ };
284
+ return { config, validate, refresh };
285
+ }
286
+ export function participantBinding(execution) {
287
+ return JSON.stringify(execution.participants().toSorted((left, right) => left.id.localeCompare(right.id)));
288
+ }
170
289
  export async function requireHandover(execution) {
171
290
  if (readConsent(execution.root))
172
291
  return;
@@ -194,9 +313,12 @@ export async function authorizeAfterExit(execution, payload) {
194
313
  if (!record(payload) || typeof payload.afterExit !== "boolean" || typeof payload.fingerprint !== "string")
195
314
  throw new Error("Invalid daemon authorization.");
196
315
  await requireHandover(execution);
197
- const { loadConfig } = await import("./engine/settings/config.js");
198
- const config = await loadConfig();
316
+ const peers = participantBinding(execution);
317
+ const { loadConfigForCheck } = await import("./engine/settings/config.js");
318
+ const config = await loadConfigForCheck(undefined, execution.signal);
199
319
  execution.validate();
320
+ if (participantBinding(execution) !== peers)
321
+ throw new Error("Participants changed during daemon authorization.");
200
322
  const facts = execution.facts();
201
323
  const binding = JSON.stringify({ model: facts?.model, sessionDir: facts?.sessionDir, cwd: facts?.cwd });
202
324
  const fingerprint = consentFingerprint(execution.root, config);
@@ -222,22 +344,17 @@ export async function authorizeAfterExit(execution, payload) {
222
344
  : `Selected content: ${paths(config.include)}`;
223
345
  const accepted = await execution.request("confirm", {
224
346
  title: payload.afterExit ? "Allow continuous sync after all Pi clients exit?" : "Revoke unattended sync?",
225
- message: `Setup: ${safeTerminalText(config.setupName)}\n${selection}\nModel: ${safeTerminalText(facts?.model?.provider ?? "unavailable")}/${safeTerminalText(facts?.model?.id ?? "unavailable")}\n\n${payload.afterExit ? "The daemon may transfer selected private content and send conflict evidence to this independently available provider after Pi exits. Existing budgets, exclusions, journals, and stale-evidence checks still apply. No parent conversation or tools are sent. Changing this setup or model invalidates this permission." : "The daemon may remain alive, but no new transfer or model request may start with zero clients."}`,
347
+ message: `Setup: ${safeTerminalText(config.setupName)}\n${selection}\nModel: ${safeTerminalText(facts?.model?.provider ?? "unavailable")}/${safeTerminalText(facts?.model?.id ?? "unavailable")}\n\n${payload.afterExit ? `The daemon may transfer selected private content and send conflict evidence to this independently available provider after Pi exits. Existing budgets, exclusions, journals, and stale-evidence checks still apply. No parent conversation or tools are sent. Changing this setup or model invalidates this permission.${config.reservedIgnoreNames !== undefined ? " This also approves the enabled automatic modes for this setup while Pi clients are attached." : ""}` : "The daemon may remain alive, but no new transfer or model request may start with zero clients."}`,
226
348
  });
227
349
  execution.validate();
228
350
  if (accepted !== true)
229
- return false;
230
- const latest = await loadConfig();
351
+ return undefined;
352
+ const latest = await loadConfigForCheck(undefined, execution.signal);
231
353
  execution.validate();
232
- if (config.ignorePolicy) {
233
- const { ignorePolicyValidator } = await import("./engine/snapshot/snapshot-transaction-policy.js");
234
- await ignorePolicyValidator({
235
- ...config,
236
- signal: execution.signal,
237
- validateMutation: () => execution.validate(),
238
- })?.();
239
- }
240
- if (consentFingerprint(execution.root, latest) !== fingerprint ||
354
+ await config.validateIgnorePolicy?.();
355
+ execution.validate();
356
+ if (participantBinding(execution) !== peers ||
357
+ consentFingerprint(execution.root, latest) !== fingerprint ||
241
358
  JSON.stringify({
242
359
  model: execution.facts()?.model,
243
360
  sessionDir: execution.facts()?.sessionDir,
@@ -258,8 +375,9 @@ export async function authorizeAfterExit(execution, payload) {
258
375
  sessionDir: facts?.sessionDir,
259
376
  cwd: facts?.cwd,
260
377
  afterExit: payload.afterExit,
378
+ ...(payload.afterExit && config.reservedIgnoreNames !== undefined ? { automaticFingerprint: fingerprint } : {}),
261
379
  },
262
380
  },
263
381
  });
264
- return true;
382
+ return { config, afterExit: payload.afterExit };
265
383
  }
@@ -35,8 +35,7 @@ export declare class GitSyncBackend implements SyncBackend {
35
35
  private resolveSnapshotReference;
36
36
  private headForSha;
37
37
  private fetchRemoteHead;
38
- private readManifest;
39
- private showFile;
38
+ private tryReadHistoryManifestBatch;
40
39
  private createCommit;
41
40
  private ensureCache;
42
41
  private initializeCache;
@@ -9,10 +9,12 @@ import { throwIfAborted } from "../../sync/signals.js";
9
9
  import { syncErrorGuidance } from "../../sync/sync-error-guidance.js";
10
10
  import { SyncBackendConflictError, SyncBackendPublicationOutcomeUnknownError, } from "../sync-backend.js";
11
11
  import { normalizeGitBranch, normalizeGitDirectory, normalizeGitRemote, normalizeGitRemoteIdentity, validateGitNamespace, } from "./git-config.js";
12
- import { GitCommandError, readGitBlobs, runGit } from "./git-runner.js";
12
+ import { GitCommandError, parseGitBlobBatch, readGitBlobs, runGit } from "./git-runner.js";
13
13
  import { GIT_MANIFEST_VERSION, MAX_GIT_MANIFEST_BYTES, MAX_GIT_TREE_OUTPUT_BYTES, parseGitTree, prepareGitSnapshot, requireGitManifest, validateGitPublicationTree, validateGitSnapshot, } from "./git-storage.js";
14
14
  const COMMAND_TIMEOUT_MS = 30_000;
15
15
  const POST_COMMIT_TIMEOUT_MS = 45_000;
16
+ const HISTORY_MANIFEST_BATCH_SIZE = 8;
17
+ const MANIFEST_BATCH_FRAME_BYTES = 96;
16
18
  const gitCacheMutationQueues = new Map();
17
19
  export class GitSyncBackend {
18
20
  config;
@@ -182,20 +184,28 @@ export class GitSyncBackend {
182
184
  }
183
185
  async listHistory(signal) {
184
186
  const sha = await this.fetchRemoteHead(signal);
187
+ throwIfAborted(signal);
185
188
  if (!sha)
186
189
  return [];
187
190
  const result = await this.git(["rev-list", "--first-parent", "--reverse", "--max-count=100", sha], { signal });
188
191
  const commits = result.stdout.toString("utf8").trim().split("\n").filter(Boolean);
189
192
  const entries = [];
190
- for (const commit of commits) {
191
- const { manifest } = await this.readPublication(commit, signal);
192
- entries.push({
193
- snapshotRef: commit,
194
- snapshotId: manifest.snapshotId,
195
- createdAt: manifest.createdAt,
196
- machine: manifest.machine,
197
- syncSessions: manifest.syncSessions,
198
- });
193
+ throwIfAborted(signal);
194
+ for (let offset = 0; offset < commits.length; offset += HISTORY_MANIFEST_BATCH_SIZE) {
195
+ const group = commits.slice(offset, offset + HISTORY_MANIFEST_BATCH_SIZE);
196
+ const manifests = await this.tryReadHistoryManifestBatch(group, signal);
197
+ for (const [index, commit] of group.entries()) {
198
+ throwIfAborted(signal);
199
+ const { manifest } = await this.readPublication(commit, signal, manifests?.[index]);
200
+ throwIfAborted(signal);
201
+ entries.push({
202
+ snapshotRef: commit,
203
+ snapshotId: manifest.snapshotId,
204
+ createdAt: manifest.createdAt,
205
+ machine: manifest.machine,
206
+ syncSessions: manifest.syncSessions,
207
+ });
208
+ }
199
209
  }
200
210
  return entries;
201
211
  }
@@ -314,27 +324,27 @@ export class GitSyncBackend {
314
324
  }
315
325
  }, signal);
316
326
  }
317
- async readManifest(commit, signal) {
318
- requireCommitSha(commit);
319
- const bytes = await this.showFile(commit, this.manifestPath(), signal, MAX_GIT_MANIFEST_BYTES);
320
- let parsed;
327
+ async tryReadHistoryManifestBatch(commits, signal) {
321
328
  try {
322
- parsed = JSON.parse(bytes.toString("utf8"));
323
- }
324
- catch (error) {
325
- throw new Error("Git publication manifest is malformed.", { cause: error });
329
+ for (const commit of commits)
330
+ requireCommitSha(commit);
331
+ const manifestPath = this.manifestPath();
332
+ const maxContentBytes = commits.length * MAX_GIT_MANIFEST_BYTES;
333
+ const result = await this.git(["cat-file", "--batch"], {
334
+ input: `${commits.map((commit) => `${commit}:${manifestPath}`).join("\n")}\n`,
335
+ maxOutputBytes: maxContentBytes + commits.length * MANIFEST_BATCH_FRAME_BYTES,
336
+ signal,
337
+ });
338
+ throwIfAborted(signal);
339
+ if (result.stderr.length > 0)
340
+ return undefined;
341
+ const blobs = parseGitBlobBatch(result.stdout, commits.length, maxContentBytes);
342
+ return blobs.every((blob) => blob.length <= MAX_GIT_MANIFEST_BYTES) ? blobs : undefined;
326
343
  }
327
- if (parsed &&
328
- typeof parsed === "object" &&
329
- "snapshotVersion" in parsed &&
330
- parsed.snapshotVersion === IGNORE_SNAPSHOT_VERSION &&
331
- !isUtf8(bytes)) {
332
- throw new Error("Git publication manifest is not valid UTF-8.");
344
+ catch {
345
+ throwIfAborted(signal);
346
+ return undefined;
333
347
  }
334
- return requireGitManifest(parsed);
335
- }
336
- showFile(commit, filePath, signal, maxOutputBytes) {
337
- return this.git(["show", `${commit}:${filePath}`], { signal, maxOutputBytes }).then((result) => result.stdout);
338
348
  }
339
349
  async createCommit(snapshot, files, manifest, parent, signal) {
340
350
  const manifestBytes = Buffer.from(`${JSON.stringify(manifest)}\n`, "utf8");
@@ -514,8 +524,12 @@ export class GitSyncBackend {
514
524
  filePath(filePath) {
515
525
  return posixJoin(this.publicationPath(), "files", filePath);
516
526
  }
517
- async readPublication(commit, signal) {
518
- const manifest = await this.readManifest(commit, signal);
527
+ async readPublication(commit, signal, manifestBytes) {
528
+ requireCommitSha(commit);
529
+ const bytes = manifestBytes ??
530
+ (await this.git(["show", `${commit}:${this.manifestPath()}`], { signal, maxOutputBytes: MAX_GIT_MANIFEST_BYTES }))
531
+ .stdout;
532
+ const manifest = parseGitManifest(bytes);
519
533
  const entries = await this.readPublicationTree(commit, signal, manifest.snapshotVersion === IGNORE_SNAPSHOT_VERSION);
520
534
  const payloadEntries = validateGitPublicationTree(entries, manifest, this.manifestPath(), (filePath) => this.filePath(filePath));
521
535
  return { manifest, payloadEntries };
@@ -572,6 +586,23 @@ function gitDestination(config) {
572
586
  }
573
587
  return `${host} · ${config.destination.branch}:${config.destination.directory}`;
574
588
  }
589
+ function parseGitManifest(bytes) {
590
+ let parsed;
591
+ try {
592
+ parsed = JSON.parse(bytes.toString("utf8"));
593
+ }
594
+ catch (error) {
595
+ throw new Error("Git publication manifest is malformed.", { cause: error });
596
+ }
597
+ if (parsed &&
598
+ typeof parsed === "object" &&
599
+ "snapshotVersion" in parsed &&
600
+ parsed.snapshotVersion === IGNORE_SNAPSHOT_VERSION &&
601
+ !isUtf8(bytes)) {
602
+ throw new Error("Git publication manifest is not valid UTF-8.");
603
+ }
604
+ return requireGitManifest(parsed);
605
+ }
575
606
  function remoteHead(sha, manifest, identity) {
576
607
  return {
577
608
  snapshotRef: sha,
@@ -9,6 +9,7 @@ export interface CommandOptions {
9
9
  reload: boolean;
10
10
  auto: boolean;
11
11
  setup?: string;
12
+ automaticFingerprint?: string;
12
13
  signal?: AbortSignal;
13
14
  onCommit?: () => void;
14
15
  /** In-memory startup diagnostics only; never persisted or sent to a backend. */
@@ -18,7 +19,7 @@ export interface CommandOptions {
18
19
  /** Internal cycle authorization, ownership and durable request reservation; never command arguments. */
19
20
  background?: {
20
21
  validate(config?: AnySyncConfig): void;
21
- reserve(key: string, signal?: AbortSignal): Promise<void>;
22
+ reserve?(key: string, signal?: AbortSignal): Promise<void>;
22
23
  };
23
24
  /** Manager-only, separately confirmed retry; never parsed from command arguments. */
24
25
  agentRetryRefusal?: boolean;
@@ -55,6 +55,7 @@ export interface ConfigAuthority {
55
55
  replace(document: import("./settings/config-file.js").LocalConfigDocument, value: Record<string, unknown>): Promise<void>;
56
56
  }
57
57
  export interface EngineHost {
58
+ ignoreFileOperationsAvailable?: boolean;
58
59
  root(): string;
59
60
  config?: ConfigAuthority;
60
61
  allowConfigMigration?(): boolean;
@@ -1,6 +1,13 @@
1
1
  import { type IgnoreSource } from "./ignore-source.js";
2
+ export declare class AutomaticIgnoreCreationUnavailable extends Error {
3
+ }
4
+ export declare function checkAutomaticIgnoreCreation(root: string, signal: AbortSignal): Promise<void>;
5
+ export declare function readPendingIgnoreCreation(root: string, signal: AbortSignal): Promise<{
6
+ token: string;
7
+ text: string;
8
+ }>;
2
9
  export declare function initializeDefaultIgnoreSource(root: string, signal?: AbortSignal): Promise<IgnoreSource>;
3
- export declare function prepareDefaultIgnoreSource(root: string, signal?: AbortSignal): Promise<{
10
+ export declare function prepareDefaultIgnoreSource(root: string, signal?: AbortSignal, reviewedCreation?: string | null): Promise<{
4
11
  source: IgnoreSource;
5
12
  created: boolean;
6
13
  }>;