@mwillbanks/ast-mcp 0.6.3 → 0.6.5

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.
@@ -415,16 +415,14 @@ export async function computeNative(
415
415
  );
416
416
  const schema = `ast-mcp.${name}.v1`;
417
417
  if (name === "map" || name === "digest") {
418
+ const memberLimit = input.max_members ?? (name === "digest" ? 50 : 200);
418
419
  const mapped = flatMapFilesWithAbort(files, signal, (file) => [
419
420
  {
420
421
  diagnostics: file.facts.diagnostics,
421
422
  language: file.facts.languageId,
422
423
  partial: file.facts.partial,
423
424
  path: relative(root, file.path),
424
- symbols: symbolView(file, root).slice(
425
- 0,
426
- input.max_members ?? (name === "digest" ? 50 : 200),
427
- ),
425
+ symbols: symbolView(file, root).slice(0, memberLimit),
428
426
  },
429
427
  ]);
430
428
  const result = bounded(mapped, input);
@@ -432,7 +430,9 @@ export async function computeNative(
432
430
  files: result.items,
433
431
  schema,
434
432
  total: result.total,
435
- truncated: result.truncated,
433
+ truncated:
434
+ result.truncated ||
435
+ files.some((file) => file.facts.symbols.length > memberLimit),
436
436
  };
437
437
  }
438
438
  if (name === "show") {
@@ -566,7 +566,15 @@ export async function computeNative(
566
566
  if (name === "cycles") {
567
567
  const limit = input.limit ?? input.top_k ?? 200;
568
568
  const result = graphCycles(visibleEdges, limit, signal);
569
- return { ...result, schema };
569
+ const page = bounded(result.cycles, {
570
+ ...input,
571
+ budget: input.budget ?? 1_000_000,
572
+ });
573
+ return {
574
+ cycles: page.items,
575
+ schema,
576
+ truncated: result.truncated || page.truncated,
577
+ };
570
578
  }
571
579
  if (name === "deps" || name === "reverse_deps") {
572
580
  const selectedPath = input.file ?? input.path;
@@ -10,7 +10,12 @@ import {
10
10
  import type { ToolInput, ToolName } from "./code-intelligence.ts";
11
11
  export type CpuJob =
12
12
  | { kind: "compiler-config"; source: string }
13
- | { kind: "parse"; languageId: ParserLanguageId; source: string }
13
+ | {
14
+ kind: "parse";
15
+ languageId: ParserLanguageId;
16
+ source: string;
17
+ maxReplyBytes?: number;
18
+ }
14
19
  | {
15
20
  kind: "compute";
16
21
  name: ToolName;
@@ -45,7 +50,11 @@ scope.onmessage = async ({ data }) => {
45
50
  data.aliases,
46
51
  );
47
52
  const bytes = Buffer.byteLength(JSON.stringify(value));
48
- if (bytes > 16 * 1024 * 1024)
53
+ const maxBytes =
54
+ data.kind === "parse"
55
+ ? (data.maxReplyBytes ?? 16 * 1024 * 1024)
56
+ : 16 * 1024 * 1024;
57
+ if (bytes > maxBytes)
49
58
  throw Object.assign(
50
59
  new Error(
51
60
  "Parsed data exceeds the request byte limit; narrow paths, glob, or scan_limit",
@@ -189,7 +189,9 @@ function toolDescription(name: (typeof TOOL_NAMES)[number]): string {
189
189
  surface: "Returns exported native AST symbols.",
190
190
  trace: "Returns a bounded native call trace.",
191
191
  };
192
- return descriptions[name];
192
+ return name === "squeeze"
193
+ ? descriptions[name]
194
+ : `${descriptions[name]} Bulk budget omissions return incomplete, truncated coverage with bounded reasons and paths; narrow scope before treating absent results as complete.`;
193
195
  }
194
196
 
195
197
  async function requestRoot(input: ToolInput): Promise<string> {
@@ -443,11 +445,12 @@ async function requestedFiles(
443
445
  return files.sort();
444
446
  }
445
447
 
448
+ type BudgetOmission = "sourceSize" | "sourceBytes" | "parsedFacts";
446
449
  type ScanOmissions = {
447
450
  scanLimit: number;
448
451
  unreadable: number;
449
452
  unsupported: number;
450
- };
453
+ } & Record<BudgetOmission, number>;
451
454
 
452
455
  type ScanCoverage = {
453
456
  candidates: number;
@@ -457,6 +460,9 @@ type ScanCoverage = {
457
460
  scanLimit: string[];
458
461
  unreadable: string[];
459
462
  unsupported: string[];
463
+ sourceSize: string[];
464
+ sourceBytes: string[];
465
+ parsedFacts: string[];
460
466
  };
461
467
  omittedPathsTruncated: boolean;
462
468
  omissions: ScanOmissions;
@@ -470,6 +476,7 @@ async function sourceFor(
470
476
  filePath: string,
471
477
  workspace: WorkspaceHandle | undefined,
472
478
  signal?: AbortSignal,
479
+ maxBytes = MAX_SOURCE_BYTES,
473
480
  ): Promise<string> {
474
481
  throwIfAborted(signal);
475
482
  if (workspace && workspace.selectedRevision.selector.kind !== "working") {
@@ -480,7 +487,7 @@ async function sourceFor(
480
487
  workspace.selectedRevision,
481
488
  filePath,
482
489
  signal,
483
- MAX_SOURCE_BYTES,
490
+ maxBytes,
484
491
  ),
485
492
  ).toString("utf8");
486
493
  } catch (error) {
@@ -490,9 +497,13 @@ async function sourceFor(
490
497
  }
491
498
  }
492
499
  const file = Bun.file(filePath);
493
- if ((await file.stat()).size > MAX_SOURCE_BYTES)
500
+ if ((await file.stat()).size > maxBytes)
501
+ throw capacityError("Source exceeds the parser byte limit");
502
+ // Bound the read even when the file grows after stat.
503
+ const source = await file.slice(0, maxBytes + 1).text();
504
+ if (Buffer.byteLength(source) > maxBytes)
494
505
  throw capacityError("Source exceeds the parser byte limit");
495
- return file.text();
506
+ return source;
496
507
  }
497
508
 
498
509
  function abortError(signal: AbortSignal): Error {
@@ -577,9 +588,25 @@ async function loadFiles(
577
588
  .map((item) => relative(root, item.path));
578
589
  const files: NativeFile[] = [];
579
590
  const unreadable: string[] = [];
591
+ const budgetPaths: Record<BudgetOmission, string[]> = {
592
+ sourceSize: [],
593
+ sourceBytes: [],
594
+ parsedFacts: [],
595
+ };
596
+ const explicit = [
597
+ ...(input.paths ?? []),
598
+ ...(input.file ? [input.file] : []),
599
+ ...(input.path ? [input.path] : []),
600
+ ];
601
+ const exactFile =
602
+ !input.glob &&
603
+ selected.length === 1 &&
604
+ explicit.length === 1 &&
605
+ path.resolve(root, explicit[0] as string) === selected[0];
580
606
  let sourceBytes = 0;
581
- for (const item of selectedEligible) {
607
+ for (const [index, item] of selectedEligible.entries()) {
582
608
  throwIfAborted(signal);
609
+ let budgetReason: BudgetOmission = "sourceSize";
583
610
  try {
584
611
  if (
585
612
  (!workspace ||
@@ -587,49 +614,83 @@ async function loadFiles(
587
614
  (await Bun.file(item.path).stat()).size > MAX_SOURCE_BYTES
588
615
  )
589
616
  throw capacityError("Source exceeds the parser byte limit");
590
- const source = await sourceFor(item.path, workspace, signal);
591
- const bytes = Buffer.byteLength(source);
592
- if (bytes > MAX_SOURCE_BYTES)
593
- throw capacityError("Source exceeds the parser byte limit");
594
- sourceBytes += bytes;
595
- if (sourceBytes > MAX_REQUEST_BYTES)
596
- throw capacityError("Selected sources exceed the request byte limit");
617
+ const remainingBytes = MAX_REQUEST_BYTES - sourceBytes;
618
+ if (remainingBytes < MAX_SOURCE_BYTES) budgetReason = "sourceBytes";
619
+ const source = await sourceFor(
620
+ item.path,
621
+ workspace,
622
+ signal,
623
+ Math.min(MAX_SOURCE_BYTES, remainingBytes),
624
+ );
625
+ sourceBytes += Buffer.byteLength(source);
597
626
  throwIfAborted(signal);
627
+ budgetReason = "parsedFacts";
598
628
  const facts = await cpu.run<NativeFile["facts"]>({
599
629
  kind: "parse",
600
630
  languageId: item.language,
601
631
  source,
602
632
  });
603
633
  files.push({ facts, path: item.path, source });
634
+ // The parser's node cap also produces incomplete facts.
635
+ if (facts.partial)
636
+ budgetPaths.parsedFacts.push(relative(root, item.path));
604
637
  } catch (error) {
605
- if (signal?.aborted) throw abortError(signal);
606
- if ((error as { code?: string })?.code === "intelligence_budget_exceeded")
607
- throw error;
638
+ if (signal.aborted) throw abortError(signal);
639
+ if (
640
+ (error as { code?: string })?.code === "intelligence_budget_exceeded"
641
+ ) {
642
+ if (exactFile) throw error;
643
+ if (budgetReason === "sourceSize") {
644
+ budgetPaths.sourceSize.push(relative(root, item.path));
645
+ continue;
646
+ }
647
+ // Stop at aggregate exhaustion. Report every remaining candidate without
648
+ // reading or parsing it, so resource use stays bounded and deterministic.
649
+ budgetPaths[budgetReason].push(
650
+ ...selectedEligible
651
+ .slice(index)
652
+ .map((entry) => relative(root, entry.path)),
653
+ );
654
+ break;
655
+ }
608
656
  unreadable.push(relative(root, item.path));
609
657
  }
610
658
  }
611
- const omittedPathCount =
612
- unsupported.length + limited.length + unreadable.length;
659
+ const omittedPaths = {
660
+ scanLimit: limited,
661
+ unreadable,
662
+ unsupported,
663
+ ...budgetPaths,
664
+ };
665
+ const omissions = Object.fromEntries(
666
+ Object.entries(omittedPaths).map(([reason, paths]) => [
667
+ reason,
668
+ paths.length,
669
+ ]),
670
+ ) as ScanOmissions;
671
+ const incomplete =
672
+ limited.length > 0 ||
673
+ unreadable.length > 0 ||
674
+ Object.values(budgetPaths).some((paths) => paths.length > 0);
613
675
  return {
614
676
  files,
615
677
  root,
616
678
  scan: {
617
679
  candidates: selected.length,
618
680
  eligible: eligible.length,
619
- exhaustive: limited.length === 0 && unreadable.length === 0,
620
- omissions: {
621
- scanLimit: limited.length,
622
- unreadable: unreadable.length,
623
- unsupported: unsupported.length,
624
- },
625
- omittedPaths: {
626
- scanLimit: limited.slice(0, MAX_OMITTED_PATHS),
627
- unreadable: unreadable.slice(0, MAX_OMITTED_PATHS),
628
- unsupported: unsupported.slice(0, MAX_OMITTED_PATHS),
629
- },
630
- omittedPathsTruncated: omittedPathCount > MAX_OMITTED_PATHS,
681
+ exhaustive: !incomplete,
682
+ omissions,
683
+ omittedPaths: Object.fromEntries(
684
+ Object.entries(omittedPaths).map(([reason, paths]) => [
685
+ reason,
686
+ paths.slice(0, MAX_OMITTED_PATHS),
687
+ ]),
688
+ ) as ScanCoverage["omittedPaths"],
689
+ omittedPathsTruncated: Object.values(omittedPaths).some(
690
+ (paths) => paths.length > MAX_OMITTED_PATHS,
691
+ ),
631
692
  parsed: files.length,
632
- truncated: limited.length > 0,
693
+ truncated: incomplete,
633
694
  },
634
695
  };
635
696
  }
@@ -663,8 +724,22 @@ function emptyScanCoverage(): ScanCoverage {
663
724
  candidates: 0,
664
725
  eligible: 0,
665
726
  exhaustive: true,
666
- omissions: { scanLimit: 0, unreadable: 0, unsupported: 0 },
667
- omittedPaths: { scanLimit: [], unreadable: [], unsupported: [] },
727
+ omissions: {
728
+ scanLimit: 0,
729
+ unreadable: 0,
730
+ unsupported: 0,
731
+ sourceSize: 0,
732
+ sourceBytes: 0,
733
+ parsedFacts: 0,
734
+ },
735
+ omittedPaths: {
736
+ scanLimit: [],
737
+ unreadable: [],
738
+ unsupported: [],
739
+ sourceSize: [],
740
+ sourceBytes: [],
741
+ parsedFacts: [],
742
+ },
668
743
  omittedPathsTruncated: false,
669
744
  parsed: 0,
670
745
  truncated: false,
@@ -700,13 +775,14 @@ function compactIdentity(value: string | null | undefined): string | null {
700
775
  }
701
776
 
702
777
  function compactScan(scan: ScanCoverage) {
703
- const omitted =
704
- scan.omissions.scanLimit +
705
- scan.omissions.unreadable +
706
- scan.omissions.unsupported;
778
+ const omitted = Object.values(scan.omissions).reduce(
779
+ (sum, count) => sum + count,
780
+ 0,
781
+ );
707
782
  return {
708
783
  candidates: scan.candidates,
709
784
  eligible: scan.eligible,
785
+ exhaustive: scan.exhaustive,
710
786
  omitted: omitted === 0 ? 0 : scan.omissions,
711
787
  parsed: scan.parsed,
712
788
  ...(omitted === 0
@@ -727,11 +803,14 @@ async function withScopeMetadata(
727
803
  const workspace = currentWorkspace();
728
804
  return {
729
805
  ...payload,
806
+ exhaustive:
807
+ scan.exhaustive && resultOmissions === 0 && payload.truncated !== true,
730
808
  generation: await generationFor(workspace),
731
809
  repository: workspace?.repositoryId ?? null,
732
810
  revision: workspace?.selectedRevision.revisionId ?? null,
733
811
  scan: compactScan(scan),
734
- truncated: payload.truncated === true || resultOmissions > 0,
812
+ truncated:
813
+ scan.truncated || payload.truncated === true || resultOmissions > 0,
735
814
  workspace: workspace?.workspaceId ?? null,
736
815
  };
737
816
  }
@@ -868,7 +947,7 @@ class RequestCpu {
868
947
  const message = (event: MessageEvent<CpuReply>) => {
869
948
  cleanup();
870
949
  if (event.data.ok) {
871
- this.transferredBytes += event.data.bytes;
950
+ if (job.kind === "parse") this.transferredBytes += event.data.bytes;
872
951
  if (this.transferredBytes > MAX_REQUEST_BYTES)
873
952
  reject(capacityError("Parsed data exceeds the request byte limit"));
874
953
  else resolve(event.data.value as T);
@@ -898,7 +977,14 @@ class RequestCpu {
898
977
  this.worker.addEventListener("error", failed);
899
978
  this.signal.addEventListener("abort", aborted, { once: true });
900
979
  try {
901
- this.worker.postMessage(job);
980
+ this.worker.postMessage(
981
+ job.kind === "parse"
982
+ ? {
983
+ ...job,
984
+ maxReplyBytes: MAX_REQUEST_BYTES - this.transferredBytes,
985
+ }
986
+ : job,
987
+ );
902
988
  } catch (error) {
903
989
  cleanup();
904
990
  reject(error);
@@ -201,7 +201,7 @@ export default function registerFileTools(
201
201
  readOnlyHint: false,
202
202
  },
203
203
  description:
204
- "Creates or replaces multiple files in one declared files batch. Existing files require a fresh expectedSha256 by default; safety.require_hash=false makes it optional, but any supplied hash is still verified.",
204
+ "Creates or replaces 1–50 files and creates authorized missing parents without marker files. Existing files require a fresh expectedSha256 by default; safety.require_hash=false makes it optional, but any supplied hash is still verified.",
205
205
  inputSchema: boundedFileBatch(
206
206
  writeTarget,
207
207
  "file_write requires between 1 and 50 files",
@@ -239,7 +239,7 @@ export default function registerFileTools(
239
239
  readOnlyHint: false,
240
240
  },
241
241
  description:
242
- "Patches multiple files in one declared files batch. Each value contains a patchStrategy, ordered aiderBlocks or astRules, and optional preview mode. A fresh expectedSha256 is required by default; safety.require_hash=false makes it optional, but supplied hashes remain enforced. Preview applies the strategy without formatting or committing; formatting runs only at commit, including previewReceipt commit.",
242
+ "Patches multiple files in one declared files batch. Each value contains a patchStrategy, ordered aiderBlocks or astRules, and optional preview mode. A fresh expectedSha256 is required by default; safety.require_hash=false makes it optional, but supplied hashes remain enforced. Preview applies the strategy without formatting or committing; formatting runs only at commit, including previewReceipt commit. Receipts are reserved across the batch and consumed after mutation completion; confirmed no-change or verified rollback permits retry until expiry, while changed source or uncertain recovery requires a new preview.",
243
243
  inputSchema: boundedFileBatch(
244
244
  z
245
245
  .object({
@@ -27,12 +27,11 @@ import { currentWorkspace } from "../intelligence/workspace/context.ts";
27
27
  import {
28
28
  applyFileChattr,
29
29
  type FileChattr,
30
- resultingFileChattr,
30
+ readFileChattrSnapshot,
31
+ FileChattrSnapshots,
31
32
  } from "../runtime/attributes";
32
33
  import { deleteFilesSafely } from "../runtime/file-delete";
33
34
  import { renameFilesSafely } from "../runtime/file-rename";
34
- import { readFileSnapshot } from "../runtime/file-snapshot";
35
- import { sha256File } from "../runtime/hash";
36
35
  import { withFileLocks } from "../runtime/locks";
37
36
  import { resolveWritablePath } from "../runtime/paths";
38
37
  import { requireExpectedHash, verifyExpectedHash } from "../runtime/policy";
@@ -60,7 +59,7 @@ export default function registerLifecycleTools(
60
59
  readOnlyHint: false,
61
60
  },
62
61
  description:
63
- "Applies the shared chattr contract to multiple files in one declared files batch under deterministic locks.",
62
+ "Applies guarded attributes through verified file handles to 1–50 files under deterministic locks; cancellation and incomplete rollback return structured failures.",
64
63
  inputSchema: boundedFileBatch(
65
64
  z.object({
66
65
  chattr,
@@ -95,34 +94,20 @@ export default function registerLifecycleTools(
95
94
  const fence = async (): Promise<void> => {
96
95
  await Promise.all(leases.map((lease) => lease.fence()));
97
96
  };
98
- const snapshots = new Map<
99
- string,
100
- {
101
- attributes: Awaited<
102
- ReturnType<typeof resultingFileChattr>
103
- >;
104
- content: Buffer;
105
- sha256: string;
106
- }
107
- >();
97
+ await using snapshots = new FileChattrSnapshots();
108
98
  for (const { filePath, request } of entries) {
109
99
  await requireExpectedHash(
110
100
  request.expectedSha256,
111
101
  "file_chattr",
112
102
  );
113
- const captured = await readFileSnapshot(
103
+ const captured = await readFileChattrSnapshot(
114
104
  filePath,
115
105
  signal,
116
106
  );
117
- const content = captured.content;
107
+ snapshots.set(filePath, captured);
118
108
  const actual = captured.sha256;
119
109
  if (request.expectedSha256)
120
110
  verifyExpectedHash(request.expectedSha256, actual);
121
- snapshots.set(filePath, {
122
- attributes: await resultingFileChattr(filePath),
123
- content,
124
- sha256: actual,
125
- });
126
111
  }
127
112
  const workspace = currentWorkspace() ?? null;
128
113
  const plan = entries.map(({ filePath }) => {
@@ -132,8 +117,8 @@ export default function registerLifecycleTools(
132
117
  return {
133
118
  candidateSha256: snapshot.sha256,
134
119
  filePath,
135
- sourceContentBase64:
136
- snapshot.content.toString("base64"),
120
+ sourceContentBase64: null,
121
+ sourceBlob: snapshot.sourceBlob,
137
122
  sourceGid:
138
123
  process.platform === "win32"
139
124
  ? null
@@ -157,6 +142,7 @@ export default function registerLifecycleTools(
157
142
  workspaceId: workspace.workspaceId,
158
143
  })
159
144
  : randomUUID();
145
+ snapshots.disposable = false;
160
146
  await beginMutation({
161
147
  files: plan,
162
148
  operationId,
@@ -165,6 +151,7 @@ export default function registerLifecycleTools(
165
151
  });
166
152
  const applied: string[] = [];
167
153
  try {
154
+ await snapshots.verify(signal);
168
155
  for (const { filePath, request } of entries) {
169
156
  signal?.throwIfAborted();
170
157
  const snapshot = snapshots.get(filePath);
@@ -174,12 +161,19 @@ export default function registerLifecycleTools(
174
161
  filePath,
175
162
  sha256: snapshot.sha256,
176
163
  });
177
- applied.push(filePath);
178
164
  files[filePath] = {
179
165
  chattr: await applyFileChattr(
180
166
  filePath,
181
167
  request.chattr as FileChattr,
182
168
  fence,
169
+ {
170
+ ...snapshot,
171
+ signal,
172
+ beforeMutation: () => {
173
+ if (!applied.includes(filePath))
174
+ applied.push(filePath);
175
+ },
176
+ },
183
177
  ),
184
178
  };
185
179
  }
@@ -194,6 +188,7 @@ export default function registerLifecycleTools(
194
188
  return { filePath, sha256: snapshot.sha256 };
195
189
  }),
196
190
  );
191
+ snapshots.disposable = true;
197
192
  } catch (error) {
198
193
  await failMutation(operationId, error).catch(
199
194
  () => undefined,
@@ -201,10 +196,6 @@ export default function registerLifecycleTools(
201
196
  const rollbackErrors: unknown[] = [];
202
197
  for (const filePath of applied.reverse())
203
198
  try {
204
- verifyExpectedHash(
205
- snapshots.get(filePath)!.sha256,
206
- await sha256File(filePath),
207
- );
208
199
  await applyFileChattr(
209
200
  filePath,
210
201
  process.platform === "win32"
@@ -214,16 +205,28 @@ export default function registerLifecycleTools(
214
205
  }
215
206
  : snapshots.get(filePath)?.attributes,
216
207
  fence,
208
+ snapshots.get(filePath)!,
217
209
  );
218
210
  } catch (rollbackError) {
219
- rollbackErrors.push(rollbackError);
211
+ rollbackErrors.push(
212
+ Object.assign(
213
+ new Error("Attribute rollback failed", {
214
+ cause: rollbackError,
215
+ }),
216
+ { details: { affectedPaths: [filePath] } },
217
+ ),
218
+ );
220
219
  }
221
220
  if (rollbackErrors.length > 0)
222
- throw new AggregateError(
223
- [error, ...rollbackErrors],
224
- "file_chattr failed and rollback was incomplete",
221
+ throw Object.assign(
222
+ new AggregateError(
223
+ [error, ...rollbackErrors],
224
+ "file_chattr failed and rollback was incomplete",
225
+ ),
226
+ { details: { affectedPaths: applied } },
225
227
  );
226
228
  await recordMutationRollback(operationId);
229
+ snapshots.disposable = true;
227
230
  throw error;
228
231
  }
229
232
  },
@@ -253,7 +256,7 @@ export default function registerLifecycleTools(
253
256
  readOnlyHint: false,
254
257
  },
255
258
  description:
256
- "Deletes files in one declared files batch after reference preflight and removes empty ancestor directories. A fresh expectedSha256 is required by default; safety.require_hash=false makes it optional, but supplied hashes remain enforced.",
259
+ "Deletes 1–50 files after one reference inventory per root and removes only authorized empty ancestors. A fresh expectedSha256 is required by default; safety.require_hash=false makes it optional, but supplied hashes remain enforced.",
257
260
  inputSchema: boundedFileBatch(
258
261
  z.object({
259
262
  expectedSha256: z.string().length(64).optional(),
@@ -293,7 +296,7 @@ export default function registerLifecycleTools(
293
296
  readOnlyHint: false,
294
297
  },
295
298
  description:
296
- "Renames files in one declared files batch without overwriting destinations. A fresh expectedSha256 is required by default; safety.require_hash=false makes it optional, but supplied hashes remain enforced.",
299
+ "Renames 1–50 files without replacement and creates authorized missing destination parents without marker files. A fresh expectedSha256 is required by default; safety.require_hash=false makes it optional, but supplied hashes remain enforced.",
297
300
  inputSchema: boundedFileBatch(
298
301
  z.object({
299
302
  destination: z.string().min(1),
@@ -26,6 +26,7 @@ Do not treat `$ast-mcp/references/...` as a filesystem expansion.
26
26
  4. Call `file_hash` immediately before mutation. Supply each fresh `expectedSha256` in one path-keyed `files` batch.
27
27
  5. Send ordered `astRules` or `aiderBlocks` with the selected `patchStrategy` through `file_patch`.
28
28
  6. Use `file_write` for new files and `file_rename` for guarded moves to absent destinations.
29
+ Both create authorized missing parents. Do not create marker files to prepare destination directories.
29
30
  7. Use `file_chattr` for metadata and `file_delete` for deletion. Verify results and run repository validation.
30
31
 
31
32
  Use `run` for search and previews only. Never request `write: true`.
@@ -75,7 +75,9 @@ Keep the returned `workspaceId` and pass it explicitly.
75
75
  `run` supports search and rewrite previews only. `write: true` fails with `use_file_patch`.
76
76
  Use narrow one-match AST rules where practical. `expectedMatches` is optional; explicit counts protect reviewed intent.
77
77
  Preview does not format. Commit applies enabled formatting, including receipt commits.
78
+ Mutation batches contain at most 50 requests. Rename batches create authorized missing parents without marker files.
78
79
  Batch preflight checks all targets. Do not assume whole-batch crash atomicity.
80
+ Inspect incomplete and truncated bulk intelligence coverage, including budget omissions. Narrow the scope before treating missing matches as evidence.
79
81
 
80
82
  ## Stop and recover
81
83
 
@@ -26,6 +26,7 @@ Do not treat `$ast-mcp/references/...` as a filesystem expansion.
26
26
  4. Call `file_hash` immediately before mutation. Supply each fresh `expectedSha256` in one path-keyed `files` batch.
27
27
  5. Send ordered `astRules` or `aiderBlocks` with the selected `patchStrategy` through `file_patch`.
28
28
  6. Use `file_write` for new files and `file_rename` for guarded moves to absent destinations.
29
+ Both create authorized missing parents. Do not create marker files to prepare destination directories.
29
30
  7. Use `file_chattr` for metadata and `file_delete` for deletion. Verify results and run repository validation.
30
31
 
31
32
  Use `run` for search and previews only. Never request `write: true`.
@@ -20,7 +20,9 @@
20
20
  `run.write: true` fails with `use_file_patch`. Never use it as a mutation escape hatch.
21
21
  Preview returns an unformatted candidate. Commit runs enabled formatters.
22
22
  A receipt commit supplies `previewReceipt` without `patchStrategy`, patch operations, or `preview`.
23
- Receipts bind the inspected candidate and effective context. Rebuild a stale receipt rather than bypassing it.
23
+ Receipts bind the inspected candidate, workspace, configuration, and expiry. The complete batch reserves receipts against concurrent replay.
24
+ Receipts are consumed only after mutation completion succeeds. Confirmed no-change failures or verified rollback release reservations.
25
+ Changed sources or uncertain recovery invalidate receipts. Reinspect and preview again after stale, expired, or uncertain results.
24
26
 
25
27
  Each file has one lock and an atomic replacement.
26
28
  Batch preflight checks all targets before committing entries. Do not assume crash atomicity across files.
@@ -69,11 +71,15 @@ Use shared `chattr` metadata for permissions or ownership; do not add independen
69
71
  Use `file_rename` for moves.
70
72
  Hash every source and verify each absent destination.
71
73
  The tool checks source delete policy and destination write policy.
74
+ Moves create authorized missing destination parents without marker files. Parent policies and physical paths are revalidated before side effects.
72
75
  Moves never replace destinations. Ordinary failures attempt rollback; moves are not crash-atomic.
76
+ Rollback removes only operation-owned empty directories and preserves directories created or replaced by other actors.
73
77
 
74
78
  Use `file_delete` for files.
75
79
  The tool checks references before deletion; referenced source requires explicit `forceReferences`.
76
- Cleanup removes empty ancestors only after successful file deletion.
80
+ Cleanup removes authorized empty ancestors only after successful file deletion.
81
+ Reference inventory and parsing are shared across all targets in a batch. Explicit overrides remain required for unverifiable references.
82
+ Default cancellation returns the string error code `aborted`. Incomplete rollback reports bounded cause codes and affected paths; inspect recovery information before retrying.
77
83
 
78
84
  ## Rejection recovery
79
85
 
@@ -55,7 +55,7 @@ Do not transfer options between tools.
55
55
 
56
56
  Use absolute paths when workspace selection or the working directory could be unclear.
57
57
  File inspection batches accept 1–50 paths or read targets.
58
- Mutation `files` objects contain 1–50 path-keyed entries.
58
+ Mutation `files` objects contain 1–50 path-keyed entries. Rename destinations can have authorized missing parents; marker files are unnecessary.
59
59
  File tools accept optional `workspaceId` and `revision`.
60
60
 
61
61
  A read target accepts `filePath`, `mode`, `language`, `lines`, `range`, `maxBytes`, `selectors`, and `symbols`.
@@ -107,6 +107,9 @@ All these numeric bounds require positive integers.
107
107
  `search` and `find_related` require `query`, `target`, or `path`.
108
108
  `run` requires `pattern`; `rewrite` previews a replacement.
109
109
  `run.write: true` fails with `use_file_patch`; commit through `file_patch`.
110
+ Bulk source-size, aggregate source-byte, and parsed-data omissions return partial results with bounded reason counts and paths.
111
+ Inspect incomplete coverage, `exhaustive`, and `truncated` before treating absent matches or edges as complete evidence.
112
+ Oversized exact-file requests retain typed errors. Mutation verification remains strict.
110
113
  `squeeze` requires supplied `text` or `query`. It does not read a file path.
111
114
  `impact` accepts `paths`, but rejects singular `file` and `path`.
112
115