@aburi/diff 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,22 +1,93 @@
1
- import { CallEdge, SerializeOptions } from "@aburi/core";
2
- import { Component, ComponentDiff, Dependency, DependencyDiff, DiffResult, IR, IRRef, MatchRationale, Signature, SliceRecord, Symbol, SymbolChange, SymbolDelta, SymbolId } from "@aburi/types";
1
+ import { CallEdge, IntegrityViolation, SerializeOptions } from "@aburi/core";
2
+ import { Component, ComponentDiff, Dependency, DependencyDiff, DependencyEndpoint, DependencyUnknown, DiffResult, IR, IRRef, MatchRationale, NotComparedFile, RelativePath, Signature, SkipReason, SliceRecord, Summary, Symbol, SymbolChange, SymbolDelta, SymbolId } from "@aburi/types";
3
3
 
4
4
  //#region src/components.d.ts
5
5
  /**
6
- * §6.1 — Component diff. Component identity is `id`; when a Component is present in both
7
- * base and head with the same id, the three delta booleans describe which axes actually
8
- * moved (roots reshuffle, public API globs, or framework hint list). `modified` deltas
9
- * are intentionally absent from this diff (§5.2.3): fields are reported as before/after
10
- * pairs via the `changed[]` entries so consumers can render them without stringifying
11
- * arrays.
6
+ * `docs/design/diff-algorithm.md` §6.1 — Component diff. Assumes `components[].id` is unique on each side (ir-schema.md §14
7
+ * #2) and does not check it: `buildDiff` establishes that before calling, and a caller
8
+ * reaching this export directly owns the obligation, because the lookup map here is
9
+ * last-write-wins and a repeat is lost rather than reported.
10
+ *
11
+ * Component identity is `id`; when a Component is present in both base and head with the same
12
+ * id, *any* field that differs makes it `changed` — the whole object is compared, not the three
13
+ * axes the delta names. Those two questions were conflated once: a rename, an added language or
14
+ * an edited description left the diff reporting `componentsChanged: 0` and an empty `changed[]`,
15
+ * so the projection layer had no before/after pair to render. The delta booleans stay exactly
16
+ * what they were — a summary of the three axes a reviewer scans for architectural movement — and
17
+ * a `changed[]` entry with all three `false` is a well-formed answer meaning "something else
18
+ * about this component moved", not a bug.
19
+ *
20
+ * `modified` deltas are intentionally absent from this diff (diff-algorithm.md §5.2.3): fields
21
+ * are reported as before/after pairs via the `changed[]` entries so consumers can render them
22
+ * without stringifying arrays.
12
23
  */
13
24
  declare function diffComponents(base: readonly Component[], head: readonly Component[]): ComponentDiff;
14
25
  /**
15
- * §6.2 — Dependency diff. Identity is the composite `(from, to, via)` triple; direction
16
- * and effect changes are surfaced as an added + removed pair so `modified` is not part of
17
- * the schema (§6.2 tail).
26
+ * What one document knows about itself, for deciding whether the *other* document's silence
27
+ * about an edge is evidence.
28
+ *
29
+ * `symbolFiles` is keyed on the endpoint id exactly as `dependencies[]` spells it, and its
30
+ * values come from `symbols[].source.file` — the same space `stats.skippedFiles[].path` is in,
31
+ * and the same space `buildDiff` classifies Symbols by. Reading the file out of the id's path
32
+ * segment instead would introduce a second answer to "which file is this endpoint in", and
33
+ * nothing in the schema forces the two to agree; a Symbol reported `unknown` while its edges
34
+ * stayed `removed` is precisely the inconsistency this exists to remove.
35
+ *
36
+ * A Component endpoint is absent from the map, which is how it stays out of the reclassification
37
+ * without a special case: a Component is an aggregate over roots and has no file to lose.
38
+ */
39
+ interface DependencySideView {
40
+ /**
41
+ * `source.file` of every Symbol this document holds, by the id an endpoint would name it
42
+ * with. Keyed by `DependencyEndpoint` rather than `SymbolId` because that is the question
43
+ * being asked: the lookup happens with an endpoint whose kind is not yet known, and "absent"
44
+ * is the answer for a Component id. Demanding the kind up front would move that decision to
45
+ * the caller, where it would need a second Symbol-id silhouette test to make.
46
+ */
47
+ symbolFiles: ReadonlyMap<DependencyEndpoint, RelativePath>;
48
+ /**
49
+ * Files this document never analysed, by path, with the reason it gave. `RelativePath` on
50
+ * both sides of the file space is what states the bridge these two maps exist to make — one
51
+ * map's values are the other's keys — though the alias is unbranded, so it is intent rather
52
+ * than enforcement.
53
+ */
54
+ lostFiles: ReadonlyMap<RelativePath, SkipReason>;
55
+ }
56
+ /**
57
+ * Build a side view from a document. The only construction site there is.
58
+ *
59
+ * `buildDiff` reads `lostFiles` for its own Symbol classification too, from this same object,
60
+ * so "a Symbol reported unknown and the edges it took with it cannot disagree about which file
61
+ * went missing" is a property of the wiring rather than a claim in a comment.
62
+ *
63
+ * Exported because `DependencySideView` is public and `diffDependencies` requires one: without
64
+ * a factory a caller would have to reproduce the `symbols[].source.file` keying and the
65
+ * `stats.skippedFiles` read, and the likeliest outcome of that is a caller who gets it wrong.
66
+ */
67
+ declare function dependencySideView(ir: IR): DependencySideView;
68
+ /**
69
+ * `docs/design/diff-algorithm.md` §6.2 — Dependency diff. Identity is the composite
70
+ * `(from, to, via)` triple; direction and effect changes are surfaced as an added + removed
71
+ * pair so `modified` is not part of the schema (§6.2 tail). Uniqueness of that triple is the caller's obligation on the same
72
+ * terms as `diffComponents` above — a repeat here is indistinguishable in the output from
73
+ * the flip it encodes.
74
+ *
75
+ * `sides` is what separates a deletion from a loss (`docs/design/diff-algorithm.md` §6.2.1).
76
+ * It is required rather than optional: omitting it would classify every edge into a lost file
77
+ * as a deletion again — silently, and while still writing `unknown: []`, which this schema
78
+ * defines as "nothing was unknown" rather than "nobody looked". A caller with no skip list to
79
+ * offer says so by passing a side view whose `lostFiles` is empty, which is the honest spelling
80
+ * of an IR written before `stats.skippedFiles` existed.
81
+ *
82
+ * The return type declares `unknown` present, where the schema leaves it optional for documents
83
+ * that predate the field. A reader may find it missing; this function always writes it.
18
84
  */
19
- declare function diffDependencies(base: readonly Dependency[], head: readonly Dependency[]): DependencyDiff;
85
+ declare function diffDependencies(base: readonly Dependency[], head: readonly Dependency[], sides: {
86
+ base: DependencySideView;
87
+ head: DependencySideView;
88
+ }): DependencyDiff & {
89
+ unknown: DependencyUnknown[];
90
+ };
20
91
  //#endregion
21
92
  //#region src/delta.d.ts
22
93
  declare const DEFAULT_LINE_FUZZ = 2;
@@ -55,6 +126,13 @@ type GitRenameMap = ReadonlyMap<string, string>;
55
126
  /**
56
127
  * §3.1 — segments Symbols with identical `id` into paired matches. Runs first because it
57
128
  * is the highest-confidence signal (no heuristics, just hash lookup).
129
+ *
130
+ * Assumes `id` is unique on each side (ir-schema.md §14 #1) and does not check it:
131
+ * `buildDiff` establishes that before calling, and a caller reaching this export directly
132
+ * owns the obligation. A repeat on the head side loses all but the last entry to the lookup
133
+ * map and then removes every one of them from `remainingHead`; a repeat on the base side
134
+ * pairs the same head Symbol more than once. The later stages track consumed base Symbols
135
+ * by id and lose a repeat the same way.
58
136
  */
59
137
  declare function matchStageId(base: readonly Symbol[], head: readonly Symbol[]): {
60
138
  matched: SymbolPair[];
@@ -63,7 +141,9 @@ declare function matchStageId(base: readonly Symbol[], head: readonly Symbol[]):
63
141
  };
64
142
  /**
65
143
  * §3.2 — git rename detection. When a rename map is available (typical of ref-driven
66
- * scans), rewrite the base id with the head-side file path and look for a hit.
144
+ * scans), rewrite the base id with the head-side file path and look for a hit. Two base
145
+ * files renamed onto one target predict the same head id, so the claimants are collected
146
+ * before one is chosen.
67
147
  *
68
148
  * The rewriter only touches the `file` portion of the id — the `<language>:` prefix and
69
149
  * the trailing `#<qualified-name>` segment stay unchanged so a moved file with the same
@@ -76,11 +156,10 @@ declare function matchStageGitRename(remainingBase: readonly Symbol[], remaining
76
156
  remainingHead: Symbol[];
77
157
  };
78
158
  /**
79
- * §3.3 — group base Symbols by `fingerprint.logic` and match head Symbols whose logic
80
- * fingerprint is in the map. Two disambiguation branches:
81
- * - single candidate → paired with `logic-fingerprint`
82
- * - multiple candidates → best `nameSimilarity` wins if ≥ 0.85; otherwise leave both
83
- * sides in remaining for stage 4 to re-evaluate
159
+ * §3.3 — group both sides by `fingerprint.logic` and pair within each group. Two branches:
160
+ * - single base candidate → paired with `logic-fingerprint`, no similarity test
161
+ * - several → `nameSimilarity` disambiguates at ≥ 0.85; a group that cannot reach it is left
162
+ * whole for stage 4 to re-evaluate
84
163
  *
85
164
  * Dropped symbols are excluded (§3.3 tail) — their logic fingerprint is the sentinel
86
165
  * `"000000000000"` and would collide with every other dropped Symbol in the workspace.
@@ -96,17 +175,35 @@ declare function matchStageLogicFingerprint(remainingBase: readonly Symbol[], re
96
175
  * `signatureNullness` distinguishes symbols with no signature (`interface`, `type`,
97
176
  * `class`) from callable ones so that a class body is never paired against a function.
98
177
  *
99
- * The composite score:
100
- * 0.5 * nameSimilarity + 0.3 * signatureSimilarity + 0.2 * ownerSimilarity
178
+ * §3.4.6's owner gate runs before the score: a pair whose owners are not the same class, or
179
+ * one a rename of the other, is not the same Symbol however well the rest agrees, and no
180
+ * weight small enough to leave the name axis meaning something can outvote a matching member
181
+ * name and signature.
182
+ *
183
+ * The composite score, over the pairs that clear it:
184
+ * 0.5 * memberSimilarity + 0.3 * signatureSimilarity + 0.2 * OWNER_AXIS_SATISFIED
185
+ *
186
+ * `memberSimilarity` reads the last segment, not the whole qualified name: the gate has
187
+ * already settled the owner, and reading it again on the name axis charges for it twice —
188
+ * which is what kept a renamed class from ever pairing (§3.4.6).
101
189
  *
102
- * §3.4.3 threshold table:
103
- * - 1-token name → 1.0 (unreachable → never paired; false-positive shield)
104
- * - 2-token name → 0.95 (strict, avoids `getUser` vs `getUsers`)
105
- * - default → 0.85
190
+ * §3.4.3 threshold table, applied per head by the token count of its last name segment:
191
+ * - 1 token → 1.0 (an exact match on both remaining axes)
192
+ * - 2 tokens → 0.95 (strict, avoids `getUser` vs `getUsers`)
193
+ * - default → 0.85
106
194
  *
107
- * §3.4.3 tail — if both sides are signature-less, we skip pairing entirely because
108
- * signatureSimilarity always returns 1.0 for `null + null` and would flood the bucket with
109
- * false pairings.
195
+ * §3.4.3 also names two Symbols the stage does not read at all, because for them the score is
196
+ * high on evidence it does not have rather than on a resemblance: one whose signature is
197
+ * null, since `signatureSimilarity(null, null)` is 1.0 and the bucket key restricts it to
198
+ * candidates that are equally signature-less; and one whose qualified name carries a single
199
+ * distinct token, since that is the whole of what its identity amounts to. Neither can be
200
+ * expressed as a threshold — the second wants a bar above the top of the scale.
201
+ *
202
+ * Every pairing in a bucket that clears its head’s threshold becomes a candidate, and the
203
+ * candidates are settled in score order rather than one head at a time — see
204
+ * `acceptInScoreOrder`. That doubles the pairings scored, from a bucket that shrank as heads
205
+ * consumed it to the full bucket every time; `createNameScorer` more than pays for it by
206
+ * tokenising each distinct name once per pass instead of once per comparison.
110
207
  */
111
208
  declare function matchStageNameSignature(remainingBase: readonly Symbol[], remainingHead: readonly Symbol[]): {
112
209
  matched: SymbolPair[];
@@ -114,13 +211,32 @@ declare function matchStageNameSignature(remainingBase: readonly Symbol[], remai
114
211
  remainingHead: Symbol[];
115
212
  };
116
213
  /**
117
- * §3.4.5 — dropped-only weak matcher. For dropped Symbols the fingerprint is zeroed and
118
- * name/signature are the only remaining signals. Score is a coarse "did the last name
119
- * segment or file basename survive?" — if either half matches we pair (threshold 0.5).
214
+ * §3.4.5 — dropped-only weak matcher. For dropped Symbols the fingerprint is zeroed, so the
215
+ * only signals left are the trailing segment of the qualified name and the file basename.
216
+ * Either one alone is enough to pair, which is deliberately lax: §3.4.5 accepts a
217
+ * false-positive risk because dropped Symbols sit outside the IR's main review surface.
218
+ *
219
+ * What it does not accept is a signal that identifies nothing. A basename hit on `index.ts`
220
+ * — the most common filename in a TypeScript monorepo — paired every dropped Symbol of one
221
+ * kind under one with every other, at a score they all tied on, and the results landed in
222
+ * `summary.moved`, which `--fail-on moved` gates on. So a half counts only when exactly one
223
+ * dropped base and one dropped head carry that key: such a key names a pair, where a key
224
+ * several Symbols carry names a group, and a group is not a pairing.
225
+ *
226
+ * That makes the candidates the identifying keys themselves — at most one pairing each,
227
+ * two axes, so at most `2 × min(base, head)` of them rather than the cross-product a shared
228
+ * basename used to produce.
120
229
  *
121
- * This is deliberately lax; diff-algorithm.md §3.4.5 already accepts that dropped Symbols live
122
- * outside the main IR review surface, so occasional false pairings only affect the
123
- * "Drop-rule variation" fold-out section in the Markdown projection.
230
+ * "Exactly one" is counted over the Symbols this stage is handed, not over every dropped
231
+ * Symbol in the Document — stages 1 and 2 have already taken theirs, and a key they emptied
232
+ * out identifies again. That is the intended reading, since the question is which leftover a
233
+ * key picks out, but it is also how a shared `index.ts` comes back: three dropped classes
234
+ * under one, two of them matched by id, and the basename identifies the two that are left.
235
+ *
236
+ * It also leaves nothing for §3.4.5's 0.5-per-half scale to rank, so §3.8's sweep is the
237
+ * wrong instrument: it settles conflicts by score, and with none to settle by it would drop
238
+ * one identified pairing for another over nothing but the id it sorts under. `bestPairing`
239
+ * takes a maximum matching instead.
124
240
  */
125
241
  declare function matchStageDroppedWeak(remainingBase: readonly Symbol[], remainingHead: readonly Symbol[]): {
126
242
  matched: SymbolPair[];
@@ -129,6 +245,18 @@ declare function matchStageDroppedWeak(remainingBase: readonly Symbol[], remaini
129
245
  };
130
246
  //#endregion
131
247
  //#region src/diff.d.ts
248
+ /**
249
+ * The two counters `buildDiff` always writes, narrowed off `Summary`'s optionals.
250
+ *
251
+ * They are optional on the wire so a diff written before they existed stays valid, and that
252
+ * optionality is about *documents*, not about this function — a caller holding a value it just
253
+ * built should not have to re-decide what "absent" would have meant. Same reason
254
+ * `diffDependencies` declares its `unknown` array present.
255
+ */
256
+ interface UnknownCounters {
257
+ unknown: number;
258
+ depsUnknown: number;
259
+ }
132
260
  interface DiffInput {
133
261
  baseIR: IR;
134
262
  headIR: IR;
@@ -152,7 +280,19 @@ interface DiffInput {
152
280
  * pipe the result through additional steps (Markdown projection, `--fail-on` gate) before
153
281
  * serialisation.
154
282
  */
155
- declare function buildDiff(input: DiffInput): DiffResult;
283
+ declare function buildDiff(input: DiffInput): DiffResult & {
284
+ notCompared: NotComparedFile[];
285
+ summary: Summary & UnknownCounters;
286
+ };
287
+ /**
288
+ * The files a document's scan never analysed, by path, with why.
289
+ *
290
+ * `stats.skippedFiles` is Class B: absent means the writer predates the field, not that
291
+ * nothing was lost. An empty map is the honest answer either way — with no enumeration
292
+ * there is no absence this function can explain, and guessing from
293
+ * `totalFiles > parsedFiles` would attach a reason to whichever Symbols happened to be
294
+ * missing. The CLI says so on stderr instead; a diff cannot invent the list.
295
+ */
156
296
  /**
157
297
  * Byte-deterministic serialiser for a DiffResult. Delegates to `@aburi/core`
158
298
  * `serializeCanonical` so the sort order, NFC normalisation, and codepoint key sort are
@@ -161,18 +301,32 @@ declare function buildDiff(input: DiffInput): DiffResult;
161
301
  declare function writeCanonicalDiff(diff: DiffResult, options?: SerializeOptions): string;
162
302
  //#endregion
163
303
  //#region src/errors.d.ts
164
- /**
165
- * Coded error class for every @aburi/diff failure. Consumers branch on `code` without
166
- * parsing message text. Codes are stable and additions are non-breaking; renames are not.
167
- */
168
304
  type DiffErrorCode = /** `base.$schema` and `head.$schema` disagree; a diff across schema versions cannot be trusted (§9.1). */"schema-mismatch" /** `config.diff.lineFuzz` was outside the documented [0, 10] range (diff-algorithm.md §5.2.1). */ | "invalid-line-fuzz"
169
305
  /**
170
- * `baseIR` or `headIR` failed the top-level shape check that `buildDiff` enforces
171
- * before touching any Symbol. Missing / non-array `symbols`, `components`,
172
- * `dependencies`, or an absent `$schema` — anything that would otherwise crash with a
173
- * cryptic `TypeError: undefined is not iterable` deep in a matching stage.
306
+ * `baseIR` or `headIR` is not a Document of the shape `aburi.ir.v1` requires. `buildDiff`
307
+ * establishes that before touching any Symbol, by running invariant #20
308
+ * (`checkDocumentShape`): every field the schema requires, at every depth, named by the
309
+ * record it sits in and the field inside it — so a missing `stats` or `workspace`, a
310
+ * `symbols[3]` with no `fingerprint`, and a `stats.effectPropagation` with no `sccCount`
311
+ * all raise this. Anything here would otherwise crash during classification or the delta
312
+ * with a `TypeError` naming neither the record nor the field.
313
+ *
314
+ * A non-empty `$schema` is raised under this code too. That one is `buildDiff`'s own
315
+ * requirement rather than the schema's — two Documents that both say `""` agree with each
316
+ * other, so `schema-mismatch` would never fire on the pair.
317
+ *
318
+ * Not the semantic invariants: those are statements about a Document whose answer the diff
319
+ * does not depend on, and refusing an unsorted `symbols[]` would withhold a diff the
320
+ * matcher can produce.
174
321
  */
175
322
  | "ir-shape-invalid"
323
+ /**
324
+ * `baseIR` or `headIR` repeats an identity the diff keys on: a `symbols[].id`, a
325
+ * `components[].id`, or a `dependencies[]` `(from, to, via)` triple. Distinct from
326
+ * `ir-shape-invalid` because the Document is well-formed — the collision changes the
327
+ * answer rather than preventing one, and ir-schema.md §14 #1 / #2 / #13 already forbid it.
328
+ */
329
+ | "ir-identity-collision"
176
330
  /**
177
331
  * A `SliceRecord` broke the derivation invariant of slice-view.md §7.1 / §8.2:
178
332
  * `members[]` empty, `members[]` not in strictly ascending order, or `id` not
@@ -186,10 +340,20 @@ interface DiffErrorDetail {
186
340
  code: DiffErrorCode;
187
341
  /** Offending value (schema id, fuzz value, etc.) when applicable. */
188
342
  value?: string;
343
+ /**
344
+ * Populated only for `ir-shape-invalid`, one entry per breach of invariant #20.
345
+ *
346
+ * The message quotes the first and counts the rest, which is enough to start on and not
347
+ * enough to finish: a caller fixing a hand-assembled Document needs the others without
348
+ * running the diff again per field. `CoreErrorDetail.violations` carries the same array
349
+ * for the same reason, and the two are the same `IntegrityViolation` type.
350
+ */
351
+ violations?: readonly IntegrityViolation[];
189
352
  }
190
353
  declare class DiffError extends Error {
191
354
  readonly code: DiffErrorCode;
192
355
  readonly value: string | undefined;
356
+ readonly violations: readonly IntegrityViolation[] | undefined;
193
357
  constructor(message: string, detail: DiffErrorDetail, options?: {
194
358
  cause?: unknown;
195
359
  });
@@ -229,6 +393,15 @@ declare function signatureSimilarity(base: Signature | null | undefined, head: S
229
393
  * The result is de-duplicated so `InvoiceService.createInvoice` collapses to
230
394
  * `["invoice", "service", "create"]` — Jaccard similarity relies on set semantics, so
231
395
  * repeated tokens must not double-count.
396
+ *
397
+ * **The camel boundary is ASCII.** `isCamelBoundary` compares code points against `a`–`z`,
398
+ * `A`–`Z` and `0`–`9`, so a name written in a script with no ASCII case boundary and no
399
+ * separator comes back whole: `获取用户信息` and `ユーザー情報を取得する` are one token each,
400
+ * and so is `получитьПользователя` — its camel hump does not register. A separator still
401
+ * splits (`ユーザー.取得` gives two), and a mixed name splits on its ASCII half.
402
+ *
403
+ * That makes the token count a poor measure of how much such a name says, which matters
404
+ * wherever a count is read as a proxy for that — see §3.4.3's admissibility rule.
232
405
  */
233
406
  declare function tokenizeName(input: string): string[];
234
407
  /**
@@ -237,7 +410,11 @@ declare function tokenizeName(input: string): string[];
237
410
  * purpose of §3.4.1). Empty on one side only returns 0.0.
238
411
  */
239
412
  declare function jaccard(a: readonly string[], b: readonly string[]): number;
240
- /** name-token Jaccard shortcut used by nameSimilarity and ownerSimilarity call sites. */
413
+ /**
414
+ * Jaccard over the tokens of two strings. Part of the module's surface rather than an
415
+ * internal shortcut: the two formulas below go through a token table they share for one
416
+ * matching pass, so this has no caller inside this file.
417
+ */
241
418
  declare function jaccardTokens(a: string, b: string): number;
242
419
  /**
243
420
  * §3.4.1 — Jaccard over the tokens of the full qualified name. The last segment is not
@@ -246,20 +423,36 @@ declare function jaccardTokens(a: string, b: string): number;
246
423
  */
247
424
  declare function nameSimilarity(baseName: string, headName: string): number;
248
425
  /**
249
- * §3.4.6 — owner similarity: same as nameSimilarity but restricted to everything **before**
250
- * the last segment. Compensates for the R-8 same-name-different-class collision, where
251
- * `UserRepo.getUser` should not be pair-swapped with `AdminRepo.getUser`.
426
+ * §3.4.1 — Jaccard over the tokens of the **last segment**: the member name with its owner
427
+ * removed. What §3.4's composite reads, because §3.4.6 decides the owner separately and
428
+ * reading it on both axes charges for it twice.
429
+ */
430
+ declare function memberSimilarity(baseName: string, headName: string): number;
431
+ /**
432
+ * §3.4.6 (R-8) — whether two Symbols are close enough in *scope* to be the same Symbol: the
433
+ * same owner, or one whose owner was renamed. A gate rather than a score, because grading the
434
+ * owner cannot do what R-8 asks. `UserRepo.findById` and `AdminRepo.findById` agree on their
435
+ * member name and their signature, so a shared `Repo` token at weight 0.2 carries them to
436
+ * 0.8667 against a 0.85 threshold — while `UsersRepository.findById`, which *is* the rename,
437
+ * shares no owner token and scores 0.8000. The collision outscores the rename, and raising the
438
+ * weight only moves both: at 0.3 two three-token class names sharing two tokens land on
439
+ * exactly 0.85.
252
440
  *
253
441
  * Owner extraction:
254
442
  * - `Class::method` → `Class`
255
443
  * - `A.B.C.method` → `A.B.C`
256
444
  * - `topLevel` → `` (empty)
257
445
  *
258
- * When both owners are empty (top-level functions), returns 1.0 because both live in the
259
- * same "no-owner" bucket. When one is empty and the other is not, returns 0.0 because the
260
- * two Symbols live in structurally different scopes.
446
+ * Two empty owners are compatible: top-level Symbols share the one outer scope. One empty and
447
+ * one not are never compatible — the two live at different depths.
448
+ *
449
+ * Otherwise the owners must correspond segment for segment, and within a segment every token
450
+ * on each side must find a distinct partner on the other under `sameWord`. Both sides must be
451
+ * covered, so `UserRepo` and `UserRepoV2` are two classes rather than one renamed — an added
452
+ * token is as much evidence of a sibling as of a rename, and R-8's business is refusing the
453
+ * collision.
261
454
  */
262
- declare function ownerSimilarity(baseName: string, headName: string): number;
455
+ declare function ownersAreCompatible(baseName: string, headName: string): boolean;
263
456
  /** §3.4.1 tail note — used by drop-4.5 weak matcher and threshold lookup. */
264
457
  declare function lastSegment(qname: string): string;
265
458
  //#endregion
@@ -355,5 +548,4 @@ declare function classifyStatus(base: Symbol, head: Symbol): SymbolStatus;
355
548
  type DropDirection = "to-dropped" | "to-kept";
356
549
  declare function dropDirection(head: Symbol): DropDirection;
357
550
  //#endregion
358
- export { DEFAULT_LINE_FUZZ, type DeltaOptions, DiffError, type DiffErrorCode, type DiffErrorDetail, type DiffInput, type DropDirection, type GitRenameMap, MAX_LINE_FUZZ, MIN_LINE_FUZZ, type SliceInput, type SliceRecordViolation, type SliceViolationKind, type SymbolPair, type SymbolStatus, assertSliceRecordInvariant, buildDiff, classifyStatus, computeSlices, computeSymbolDelta, diffComponents, diffDependencies, dropDirection, jaccard, jaccardTokens, lastSegment, matchStageDroppedWeak, matchStageGitRename, matchStageId, matchStageLogicFingerprint, matchStageNameSignature, nameSimilarity, ownerSimilarity, signatureSimilarity, sliceAnchor, sliceRecordViolation, tokenizeName, writeCanonicalDiff };
359
- //# sourceMappingURL=index.d.mts.map
551
+ export { DEFAULT_LINE_FUZZ, type DeltaOptions, type DependencySideView, DiffError, type DiffErrorCode, type DiffErrorDetail, type DiffInput, type DropDirection, type GitRenameMap, MAX_LINE_FUZZ, MIN_LINE_FUZZ, type SliceInput, type SliceRecordViolation, type SliceViolationKind, type SymbolPair, type SymbolStatus, assertSliceRecordInvariant, buildDiff, classifyStatus, computeSlices, computeSymbolDelta, dependencySideView, diffComponents, diffDependencies, dropDirection, jaccard, jaccardTokens, lastSegment, matchStageDroppedWeak, matchStageGitRename, matchStageId, matchStageLogicFingerprint, matchStageNameSignature, memberSimilarity, nameSimilarity, ownersAreCompatible, signatureSimilarity, sliceAnchor, sliceRecordViolation, tokenizeName, writeCanonicalDiff };