carrick 0.3.173 → 0.3.175

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 (45) hide show
  1. package/dist/facts/fetch.d.ts +21 -16
  2. package/dist/facts/fetch.js +38 -40
  3. package/dist/facts/fetch.js.map +1 -1
  4. package/dist/facts/lines.d.ts +2 -1
  5. package/dist/facts/lines.js +144 -42
  6. package/dist/facts/lines.js.map +1 -1
  7. package/dist/facts/repo-match.d.ts +28 -0
  8. package/dist/facts/repo-match.js +86 -0
  9. package/dist/facts/repo-match.js.map +1 -0
  10. package/dist/facts/store.d.ts +3 -1
  11. package/dist/facts/store.js.map +1 -1
  12. package/dist/held/daemon.d.ts +5 -1
  13. package/dist/held/daemon.js +70 -4
  14. package/dist/held/daemon.js.map +1 -1
  15. package/dist/held/runtime.js +50 -7
  16. package/dist/held/runtime.js.map +1 -1
  17. package/dist/held/state.d.ts +3 -1
  18. package/dist/held/state.js.map +1 -1
  19. package/dist/hook/edit-flow.js +8 -2
  20. package/dist/hook/edit-flow.js.map +1 -1
  21. package/dist/hook/not-checked.js +6 -2
  22. package/dist/hook/not-checked.js.map +1 -1
  23. package/dist/hook/owed.d.ts +12 -0
  24. package/dist/hook/owed.js +35 -0
  25. package/dist/hook/owed.js.map +1 -0
  26. package/dist/hook/post-read.js +7 -4
  27. package/dist/hook/post-read.js.map +1 -1
  28. package/dist/hook/read-answer.d.ts +4 -1
  29. package/dist/hook/read-answer.js +30 -5
  30. package/dist/hook/read-answer.js.map +1 -1
  31. package/dist/hook/reuse.d.ts +27 -0
  32. package/dist/hook/reuse.js +48 -0
  33. package/dist/hook/reuse.js.map +1 -1
  34. package/dist/hook/stop-wait.js +10 -3
  35. package/dist/hook/stop-wait.js.map +1 -1
  36. package/dist/hook/worktree.d.ts +2 -0
  37. package/dist/hook/worktree.js +5 -0
  38. package/dist/hook/worktree.js.map +1 -1
  39. package/dist/init/run.js +10 -1
  40. package/dist/init/run.js.map +1 -1
  41. package/dist/render.d.ts +1 -0
  42. package/dist/render.js +20 -3
  43. package/dist/render.js.map +1 -1
  44. package/package.json +6 -6
  45. package/plugin/.claude-plugin/plugin.json +1 -1
@@ -1,6 +1,5 @@
1
1
  import type { RefreshOptions } from "../hook/refresh.ts";
2
2
  import type { StatusResult } from "../contract.ts";
3
- import type { LocalRepo } from "./store.ts";
4
3
  /** After a retriable error, the next trigger may ask again this soon. */
5
4
  export declare const FACTS_BUILDING_RETRY_MS = 60000;
6
5
  /**
@@ -23,23 +22,29 @@ export type FactsRefreshOptions = {
23
22
  start?: RefreshOptions["start"];
24
23
  };
25
24
  };
26
- /** Each repo of the local index and where it is checked out (`.carrick/index.json`). */
27
- export declare function localRepos(root: string): Array<{
28
- name: string;
29
- path: string;
30
- remote: string | null;
31
- }>;
32
- /**
33
- * The fact file's repos matched to their checkouts here. A header repo that
34
- * is a remote (`owner/name`, as the index stores a GitHub repo) maps only to
35
- * the one checkout whose origin names exactly that; a bare name maps only to
36
- * the one checkout of exactly that name. No match, or more than one, leaves
37
- * the repo unmapped: its rows are never read. Two header repos that map to
38
- * one checkout (`api` and `owner/api`) are both left unmapped.
39
- */
40
- export declare function matchRepos(repos: readonly string[], local: ReturnType<typeof localRepos>): LocalRepo[];
41
25
  /** Ask the cloud for the project's fact file and bring the local one up to date. Never throws. */
42
26
  export declare function refreshFacts(root: string, options?: FactsRefreshOptions): Promise<RefreshOutcome>;
27
+ /**
28
+ * How long `fetchFactsNow` waits on a fact file the cloud is building. The
29
+ * cloud builds a missing file on the first ask, within 25 s
30
+ * (carrick-cloud `docs/internal/reference/edit-facts-wire.md`).
31
+ */
32
+ export declare const FACTS_FIRST_WAIT_MS = 40000;
33
+ /** The pause between two asks while the cloud is building. */
34
+ export declare const FACTS_FIRST_PAUSE_MS = 3000;
35
+ /**
36
+ * Bring the fact file here now, asking again while the cloud is still building
37
+ * it, for at most `waitMs`. `carrick init` runs this so that the first session
38
+ * starts with a fact file: started only by the first session's hooks, the file
39
+ * landed up to a minute into that session, after the agent's first reads and
40
+ * edits. Never throws; a workspace left without a file gets it from the
41
+ * session-start refresh as before.
42
+ */
43
+ export declare function fetchFactsNow(root: string, options?: FactsRefreshOptions & {
44
+ waitMs?: number;
45
+ pauseMs?: number;
46
+ sleep?: (ms: number) => Promise<void>;
47
+ }): Promise<RefreshOutcome>;
43
48
  /**
44
49
  * Start the refresh for `root` detached, at most once per `FACTS_STALE_MS`
45
50
  * across every hook and session. Returns whether it started. Never throws.
@@ -22,9 +22,9 @@ import { hasMarker } from "../root.js";
22
22
  import { claimRefresh, cooldownMs, forwardInBackground, markerPath, scriptBeside, startDetached } from "../hook/refresh.js";
23
23
  import { status as readStatus } from "../cli.js";
24
24
  import { snapshotProjectSlug } from "../hook/reuse.js";
25
- import { splitRemote } from "../git-remote.js";
26
25
  import { chainLinesEnabled, contractLinesEnabled, factsEnabled } from "./enabled.js";
27
26
  import { buildFacts, closeQuietly, FACTS_STALE_MS, factsPath, loadSqlite, SCHEMA, touchFetched } from "./store.js";
27
+ import { localRepos, matchRepos } from "./repo-match.js";
28
28
  const log = createLogger("carrick-facts");
29
29
  /** After a retriable error, the next trigger may ask again this soon. */
30
30
  export const FACTS_BUILDING_RETRY_MS = 60_000;
@@ -36,44 +36,6 @@ export const FACTS_BUILDING_RETRY_MS = 60_000;
36
36
  */
37
37
  export const FACTS_FAILED_WAIT_MS = 10 * 60_000;
38
38
  export const FACTS_MARKER = "last-facts-refresh";
39
- /** Each repo of the local index and where it is checked out (`.carrick/index.json`). */
40
- export function localRepos(root) {
41
- try {
42
- const index = JSON.parse(fs.readFileSync(path.join(root, ".carrick", "index.json"), "utf8"));
43
- return (index.repos ?? [])
44
- .filter((repo) => typeof repo.name === "string" && typeof repo.path === "string")
45
- .map((repo) => {
46
- const remote = (repo.services ?? []).map((service) => service.enrichment?.remote).find((value) => typeof value === "string");
47
- return { name: repo.name, path: repo.path, remote: remote ?? null };
48
- });
49
- }
50
- catch {
51
- return [];
52
- }
53
- }
54
- /**
55
- * The fact file's repos matched to their checkouts here. A header repo that
56
- * is a remote (`owner/name`, as the index stores a GitHub repo) maps only to
57
- * the one checkout whose origin names exactly that; a bare name maps only to
58
- * the one checkout of exactly that name. No match, or more than one, leaves
59
- * the repo unmapped: its rows are never read. Two header repos that map to
60
- * one checkout (`api` and `owner/api`) are both left unmapped.
61
- */
62
- export function matchRepos(repos, local) {
63
- const out = [];
64
- for (const repo of repos) {
65
- const found = repo.includes("/")
66
- ? local.filter((entry) => entry.remote !== null && ownerName(entry.remote) === repo)
67
- : local.filter((entry) => entry.name === repo);
68
- if (found.length === 1)
69
- out.push({ repo, path: found[0].path });
70
- }
71
- return out.filter((entry) => out.filter((other) => other.path === entry.path).length === 1);
72
- }
73
- /** The `owner/name` an origin names, in either spelling git accepts, or the text itself. */
74
- function ownerName(remote) {
75
- return splitRemote(remote)?.name ?? remote;
76
- }
77
39
  /** Whether a staged URL is https on an `amazonaws.com` host (a presigned S3 URL). */
78
40
  function stagedUrlAllowed(url) {
79
41
  try {
@@ -100,7 +62,7 @@ async function knownFile(root, env) {
100
62
  try {
101
63
  const open = new sqlite.DatabaseSync(file, { readOnly: true });
102
64
  db = open;
103
- const meta = new Map(open.prepare("SELECT key, value FROM meta WHERE key IN ('digest', 'writer', 'contract')").all().map((raw) => [String(raw["key"]), String(raw["value"])]));
65
+ const meta = new Map(open.prepare("SELECT key, value FROM meta WHERE key IN ('digest', 'writer', 'contract', 'commits')").all().map((raw) => [String(raw["key"]), String(raw["value"])]));
104
66
  const digest = meta.get("digest");
105
67
  const writer = Number(meta.get("writer"));
106
68
  if (!digest || !Number.isInteger(writer))
@@ -113,6 +75,13 @@ async function knownFile(root, env) {
113
75
  // Likewise with the chain line on and no `chains` table.
114
76
  if (chainLinesEnabled(env) && !hasTable("chains"))
115
77
  return null;
78
+ // A checkout the index lists now that the file's repo table does not map (a folder
79
+ // renamed from its repo, built before the origin was read; a clone made since): the
80
+ // file is built again, whatever its digest.
81
+ const stored = open.prepare("SELECT repo, path FROM repos").all().map((raw) => `${String(raw["repo"])}\0${String(raw["path"])}`);
82
+ const names = Object.keys(JSON.parse(meta.get("commits") ?? "{}"));
83
+ if (matchRepos(names, localRepos(root)).some((entry) => !stored.includes(`${entry.repo}\0${entry.path}`)))
84
+ return null;
116
85
  // Whether the file carries contract rows follows the file, not the switch.
117
86
  return { digest, writer, contract: meta.get("contract") === "1" };
118
87
  }
@@ -201,6 +170,35 @@ export async function refreshFacts(root, options = {}) {
201
170
  return "none";
202
171
  }
203
172
  }
173
+ /**
174
+ * How long `fetchFactsNow` waits on a fact file the cloud is building. The
175
+ * cloud builds a missing file on the first ask, within 25 s
176
+ * (carrick-cloud `docs/internal/reference/edit-facts-wire.md`).
177
+ */
178
+ export const FACTS_FIRST_WAIT_MS = 40_000;
179
+ /** The pause between two asks while the cloud is building. */
180
+ export const FACTS_FIRST_PAUSE_MS = 3_000;
181
+ /**
182
+ * Bring the fact file here now, asking again while the cloud is still building
183
+ * it, for at most `waitMs`. `carrick init` runs this so that the first session
184
+ * starts with a fact file: started only by the first session's hooks, the file
185
+ * landed up to a minute into that session, after the agent's first reads and
186
+ * edits. Never throws; a workspace left without a file gets it from the
187
+ * session-start refresh as before.
188
+ */
189
+ export async function fetchFactsNow(root, options = {}) {
190
+ const env = options.env ?? process.env;
191
+ if (env["CARRICK_NO_FACTS_REFRESH"])
192
+ return "none";
193
+ const pause = options.pauseMs ?? FACTS_FIRST_PAUSE_MS;
194
+ const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
195
+ for (let asked = 1;; asked += 1) {
196
+ const outcome = await refreshFacts(root, options);
197
+ if (outcome !== "retry" || asked * pause >= (options.waitMs ?? FACTS_FIRST_WAIT_MS))
198
+ return outcome;
199
+ await sleep(pause);
200
+ }
201
+ }
204
202
  /**
205
203
  * Start the refresh for `root` detached, at most once per `FACTS_STALE_MS`
206
204
  * across every hook and session. Returns whether it started. Never throws.
@@ -1 +1 @@
1
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,GAAG,EAAE,2BAA2B,EAAE,cAAc,CAAC,CAAC;IAC9E,IAAI,CAAC;QACH,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,GAAG,QAAQ,GAAG,uBAAuB,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAC5H,CAAC;IAAC,MAAM,CAAC;QACP,yDAAyD;IAC3D,CAAC;AACH,CAAC"}
@@ -152,7 +152,7 @@ export declare function pickLines(found: Found, said: ReadonlySet<string>, claim
152
152
  * line between tiers 2 and 3: for a changed function the cloud walked to from
153
153
  * routes' handlers (`k: "chain"`), one line naming the first of its routes
154
154
  * whose line holds here, in the route's lead and its contract row's first
155
- * group. A `read` edit never gets the contract or chain kind, even with them.
155
+ * group. A `read` edit never gets the contract kind; with `options.chain` it gets the chain kind alone, one line for the file (`chainCandidates`), and with `options.chainOnly` (the Read switch is off) nothing else, and the file is not `answered`.
156
156
  */
157
157
  export declare function factLines(root: string, edits: readonly FactEdit[], session: string | undefined, options?: {
158
158
  home?: string;
@@ -162,6 +162,7 @@ export declare function factLines(root: string, edits: readonly FactEdit[], sess
162
162
  exclude?: ReadonlySet<string>;
163
163
  contract?: boolean;
164
164
  chain?: boolean;
165
+ chainOnly?: boolean;
165
166
  store?: FactStore | null;
166
167
  }): Promise<FactOutcome>;
167
168
  export {};
@@ -18,7 +18,7 @@ import path from "node:path";
18
18
  import { performance } from "node:perf_hooks";
19
19
  import { createLogger } from "../log.js";
20
20
  import { factsSaid } from "../hook/reuse.js";
21
- import { commonGitDir, linkedCheckoutTop } from "../hook/worktree.js";
21
+ import { linkedCheckoutTop, mainCheckoutOf } from "../hook/worktree.js";
22
22
  import { gapsOfLines, rangesOf, rangesOfLines, touched } from "./match.js";
23
23
  import { factsEnabled } from "./enabled.js";
24
24
  import { FACTS_STALE_MS, openFacts } from "./store.js";
@@ -50,11 +50,6 @@ const MAX_PROOF_FAILURES = 3;
50
50
  * `matched` (a pair a model found) prints after `op`, at most `MAX_MATCHED_LINES`.
51
51
  */
52
52
  const KINDS = ["contract", "op", "matched", "fn", "name", "pkg"];
53
- /** The main checkout a linked worktree belongs to, from its `.git` file. */
54
- function mainCheckoutOf(worktreeTop) {
55
- const common = commonGitDir(worktreeTop);
56
- return common ? path.dirname(common) : null;
57
- }
58
53
  function real(dir) {
59
54
  try {
60
55
  return fs.realpathSync(dir);
@@ -163,6 +158,19 @@ function rowKey(row) {
163
158
  const CONTRACT_GROUPS_PRINTED = 2;
164
159
  /** A request row prints one group: its line follows every response line, so it stays short. */
165
160
  const CONTRACT_REQUEST_GROUPS_PRINTED = 1;
161
+ /**
162
+ * The routes beyond the one a chain line names, as a count only (the Edit line
163
+ * and the Read line say it the same way): "" for a function with one route.
164
+ * The count is a floor ("at least") unless the row states it exact.
165
+ */
166
+ function otherRoutes(row) {
167
+ if (row.total <= 1)
168
+ return "";
169
+ const others = row.total - 1;
170
+ return ` and ${row.total_exact === true ? "" : "at least "}${others} other route${others === 1 ? "" : "s"}`;
171
+ }
172
+ /** The most callers a chain line names; the rest are counted. */
173
+ const CHAIN_CALLERS_PRINTED = 3;
166
174
  /** Whether `row` is one the laptop may print: its first group carries its wording (the cloud decides which rows are worded). */
167
175
  function printable(row) {
168
176
  return typeof row.groups[0]?.lead === "string";
@@ -291,7 +299,7 @@ export function pickLines(found, said, claims, now, options = {}) {
291
299
  * line between tiers 2 and 3: for a changed function the cloud walked to from
292
300
  * routes' handlers (`k: "chain"`), one line naming the first of its routes
293
301
  * whose line holds here, in the route's lead and its contract row's first
294
- * group. A `read` edit never gets the contract or chain kind, even with them.
302
+ * group. A `read` edit never gets the contract kind; with `options.chain` it gets the chain kind alone, one line for the file (`chainCandidates`), and with `options.chainOnly` (the Read switch is off) nothing else, and the file is not `answered`.
295
303
  */
296
304
  export async function factLines(root, edits, session, options = {}) {
297
305
  const started = performance.now();
@@ -394,6 +402,53 @@ export async function factLines(root, edits, session, options = {}) {
394
402
  }
395
403
  return { words: `${parts.join(", ")}${group.more}${group.tail}`, onDisk };
396
404
  };
405
+ // The callers of a route in services other than its own, from its
406
+ // contract rows (response, then request): typed places, then untyped ones.
407
+ // A place a response group holds keeps that group's `tail` (", which
408
+ // expects: <type>", worded and shortened by the cloud: the one way the
409
+ // type is composed); any other place has none.
410
+ const callerPlaces = (rows, service) => {
411
+ const out = new Map();
412
+ const add = (repo, owner, file, line, tail, loc) => {
413
+ if (owner === service)
414
+ return;
415
+ const at = loc ?? (line === null ? `${repo}/${file}` : `${repo}/${file}:${line}`);
416
+ if (!out.has(at) || (out.get(at).tail === "" && tail !== ""))
417
+ out.set(at, { repo, loc: at, tail });
418
+ };
419
+ const ordered = [...rows].sort((a, b) => (a.direction === b.direction ? 0 : a.direction === "response" ? -1 : 1));
420
+ for (const row of ordered) {
421
+ for (const group of row.groups) {
422
+ const tail = row.direction === "response" && typeof group.tail === "string" ? group.tail : "";
423
+ for (const one of group.places.slice(0, group.shown))
424
+ add(one.repo, one.service, one.file, one.line, tail, one.loc);
425
+ }
426
+ }
427
+ for (const row of ordered)
428
+ for (const one of row.untyped)
429
+ add(one.repo, one.service, one.file, one.line, "");
430
+ return [...out.values()];
431
+ };
432
+ // `places` as the line words them: a place on disk by its place, one off
433
+ // disk with the note (null when its repo has no full commit in the file),
434
+ // each followed by its type words; callers are split by ";" when any has them.
435
+ const callerWords = (at, places) => {
436
+ const onDisk = [];
437
+ const parts = [];
438
+ for (const place of places) {
439
+ const local = checkouts.place(place.repo, at);
440
+ if (local !== null) {
441
+ onDisk.push({ repo: place.repo, file: place.loc.slice(place.repo.length + 1).replace(/:\d+$/, "") });
442
+ parts.push(`${place.loc}${place.tail}`);
443
+ continue;
444
+ }
445
+ const commit = indexedCommit(commits, place.repo);
446
+ if (commit === null)
447
+ return null;
448
+ parts.push(`${place.loc} (another repo, indexed at ${commit.slice(0, 8)}, not checked out here)${place.tail}`);
449
+ }
450
+ return { words: parts.join(places.some((place) => place.tail !== "") ? "; " : ", "), onDisk };
451
+ };
397
452
  // The contract candidates of one row: its first two groups (a request row: its first), each a line.
398
453
  const contractCandidates = (at, row) => row.groups.slice(0, row.direction === "request" ? CONTRACT_REQUEST_GROUPS_PRINTED : CONTRACT_GROUPS_PRINTED).flatMap((group, index) => {
399
454
  const composed = groupWords(at, group);
@@ -412,37 +467,73 @@ export async function factLines(root, edits, session, options = {}) {
412
467
  // The chain candidates of the changed functions `names` of the edited
413
468
  // file at `at`: per chain row, one candidate per kept route, all under
414
469
  // the row's one key, so `pickLines` prints the first that holds and the
415
- // rest fall silent. A route is skipped when its contract row is gone or
416
- // not printable, was taken by tier 1 or 2 in this action, or its group
417
- // 0 was said (`skipIf`). The line names the route's hop files and its
418
- // registration file (other than the edited file), and its group's places
419
- // on disk: each must read as at the index commit.
420
- const chainCandidates = (at, names) => names.flatMap((name) => facts.chains(at.repo, at.rel, name).flatMap((chain) => chain.routes.flatMap((route) => {
421
- const row = facts
422
- .contracts(route.repo, route.file)
423
- .find((one) => one.side === route.side && one.label === route.label && one.line === route.line && one.direction === "response" && printable(one));
424
- if (row === undefined || takenIds.has(takenId(row)))
425
- return [];
426
- const group = row.groups[0];
427
- const composed = groupWords(at, group);
428
- if (composed === null)
429
- return [];
430
- const peers = [...new Set([...route.path.map((hop) => hop.file), route.file])]
431
- .filter((file) => !(route.repo === at.repo && file === at.rel))
432
- .map((file) => ({ repo: route.repo, file }));
433
- const others = [...peers, ...composed.onDisk];
434
- const groupKey = contractKey(row, 0);
435
- return [
436
- {
437
- key: `chain::${chain.repo}::${chain.file}::${chain.name}`,
438
- text: `${route.lead}${composed.words}`,
439
- named: pathsOf(others),
440
- holds: peersHold(at, others),
441
- skipIf: [groupKey],
442
- alsoClaims: [groupKey, rowKey(row)],
443
- },
444
- ];
445
- })));
470
+ // rest fall silent. A name with no chain row looks on the next named
471
+ // thing out (`outer`, innermost first). A route is skipped when neither
472
+ // its response nor its request contract row is printable, the response
473
+ // row was taken by tier 1 or 2 in this action, or its group 0 was said
474
+ // (`skipIf`). The line names the callers in other services from both
475
+ // rows (typed places and untyped ones: fact rows only, the cloud drops a
476
+ // model's reading), the route's hop files and its registration file
477
+ // (other than the edited file): each place on disk must read as at the
478
+ // index commit.
479
+ // On a Read (`read`) the same lines are found for every named thing in the
480
+ // file, but only the best one is said: fewest hops, then most callers in
481
+ // other services, then the order found. A route the read file registers is
482
+ // skipped (its own op line says it).
483
+ const chainCandidates = (at, names, outer, read = false) => {
484
+ const ranked = [];
485
+ for (const name of names) {
486
+ let rows = facts.chains(at.repo, at.rel, name);
487
+ for (const encloser of outer.get(name) ?? []) {
488
+ if (rows.length > 0)
489
+ break;
490
+ rows = facts.chains(at.repo, at.rel, encloser);
491
+ }
492
+ for (const chain of rows) {
493
+ for (const route of chain.routes) {
494
+ if (read && route.repo === at.repo && route.file === at.rel)
495
+ continue;
496
+ const same = facts.contracts(route.repo, route.file).filter((one) => one.side === route.side && one.label === route.label && one.line === route.line && printable(one));
497
+ const response = same.find((one) => one.direction === "response");
498
+ const base = response ?? same[0];
499
+ if (base === undefined || (response !== undefined && takenIds.has(takenId(response))))
500
+ continue;
501
+ const callers = callerPlaces(same, route.service);
502
+ if (callers.length === 0)
503
+ continue;
504
+ const words = callerWords(at, callers.slice(0, CHAIN_CALLERS_PRINTED));
505
+ if (words === null)
506
+ continue;
507
+ const peers = [...new Set([...route.path.map((hop) => hop.file), route.file])]
508
+ .filter((file) => !(route.repo === at.repo && file === at.rel))
509
+ .map((file) => ({ repo: route.repo, file }));
510
+ const others = [...peers, ...words.onDisk];
511
+ const groupKey = contractKey(base, 0);
512
+ const hop = route.path[0];
513
+ const hopAt = hop.call === null ? hop.file : `${hop.file}:${hop.call}`;
514
+ const where = route.depth === 1 ? `(${hopAt})` : `, through ${hop.name} (${hopAt})`;
515
+ const rest = callers.length > CHAIN_CALLERS_PRINTED ? ` and ${callers.length - CHAIN_CALLERS_PRINTED} more` : "";
516
+ ranked.push({
517
+ depth: route.depth,
518
+ callers: callers.length,
519
+ candidate: {
520
+ key: `chain::${chain.repo}::${chain.file}::${chain.name}`,
521
+ text: `Carrick: ${chain.name} (${chain.file}:${chain.line}) runs in the handler of ${route.label}${route.depth === 1 ? " " : ""}${where}${otherRoutes(chain)}. Other services call that route: ${words.words}${rest}. If your change adds a side effect or changes what the route returns, open those callers first.`,
522
+ named: pathsOf(others),
523
+ holds: peersHold(at, others),
524
+ skipIf: [groupKey],
525
+ alsoClaims: [groupKey, ...(response !== undefined ? [rowKey(response)] : [])],
526
+ },
527
+ });
528
+ }
529
+ }
530
+ }
531
+ if (!read)
532
+ return ranked.map((one) => one.candidate);
533
+ // Array.prototype.sort is stable: equal ranks keep the order found.
534
+ const best = ranked.filter((one) => !said.has(one.candidate.key) && !(one.candidate.key in claims) && options.exclude?.has(one.candidate.key) !== true).sort((a, b) => a.depth - b.depth || b.callers - a.callers)[0];
535
+ return best === undefined ? [] : [best.candidate];
536
+ };
446
537
  for (const edit of edits) {
447
538
  const at = locate(edit.file, store.repos);
448
539
  if (at === null)
@@ -522,11 +613,22 @@ export async function factLines(root, edits, session, options = {}) {
522
613
  for (const span of scan.spans)
523
614
  declared.set(span.name, (declared.get(span.name) ?? 0) + 1);
524
615
  const names = reach.names.filter((name) => declared.get(name) === 1);
525
- // The chain kind's lookup, after every file's tiers 1-2 (a Read never says one).
526
- if (options.contract === true && options.chain === true && !edit.read && names.length > 0) {
616
+ // The chain kind's lookup, after every file's tiers 1-2. A Read looks up
617
+ // every named thing in the file and says the best one (`chainCandidates`).
618
+ if (options.contract === true && options.chain === true && names.length > 0) {
527
619
  const start = new Map(scan.spans.map((span) => [span.name, span.start]));
528
- chained.push({ at, names: [...names].sort((a, b) => start.get(a) - start.get(b)) });
620
+ // Each name's enclosing named things, innermost first (once-declared names only).
621
+ const outer = new Map();
622
+ for (const name of names) {
623
+ const own = scan.spans.find((span) => span.name === name);
624
+ const around = scan.spans.filter((span) => span !== own && span.start <= own.start && span.end >= own.end && declared.get(span.name) === 1);
625
+ outer.set(name, around.sort((a, b) => a.end - a.start - (b.end - b.start)).map((span) => span.name));
626
+ }
627
+ chained.push({ at, names: [...names].sort((a, b) => start.get(a) - start.get(b)), outer, read: edit.read === true });
529
628
  }
629
+ // A Read of the chain kind alone (the Read switch is off): no op, fn or name lookup, and the file is never answered.
630
+ if (edit.read && options.chainOnly === true)
631
+ continue;
530
632
  // The op rows this edit reaches: tier 1 of the contract kind.
531
633
  const reachedOps = [];
532
634
  const opRan = isolated("op", () => {
@@ -604,7 +706,7 @@ export async function factLines(root, edits, session, options = {}) {
604
706
  }
605
707
  for (const one of chained) {
606
708
  try {
607
- tiers[2].push(...chainCandidates(one.at, one.names));
709
+ tiers[2].push(...chainCandidates(one.at, one.names, one.outer, one.read));
608
710
  }
609
711
  catch (error) {
610
712
  log("chain fact lines failed", String(error));