reading-stone 0.0.0-stage → 0.2.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 (72) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +11 -0
  3. package/README.md +301 -2
  4. package/dist/analysis.d.ts +341 -0
  5. package/dist/analysis.js +392 -0
  6. package/dist/cognitive.d.ts +163 -0
  7. package/dist/cognitive.js +380 -0
  8. package/dist/complexity.d.ts +102 -0
  9. package/dist/complexity.js +163 -0
  10. package/dist/coverage.d.ts +78 -0
  11. package/dist/coverage.js +635 -0
  12. package/dist/detector.d.ts +41 -0
  13. package/dist/detector.js +2134 -0
  14. package/dist/discovery.d.ts +330 -0
  15. package/dist/discovery.js +930 -0
  16. package/dist/doc-coverage.d.ts +155 -0
  17. package/dist/doc-coverage.js +543 -0
  18. package/dist/extract.d.ts +209 -0
  19. package/dist/extract.js +498 -0
  20. package/dist/index.d.ts +64 -0
  21. package/dist/index.js +63 -0
  22. package/dist/internal.d.ts +75 -0
  23. package/dist/internal.js +63 -0
  24. package/dist/main.d.ts +8 -0
  25. package/dist/main.js +39 -0
  26. package/dist/models.d.ts +185 -0
  27. package/dist/models.js +170 -0
  28. package/dist/program.d.ts +207 -0
  29. package/dist/program.js +662 -0
  30. package/dist/protocol.d.ts +88 -0
  31. package/dist/protocol.js +74 -0
  32. package/dist/quality/assertions.d.ts +81 -0
  33. package/dist/quality/assertions.js +425 -0
  34. package/dist/quality/collect.d.ts +66 -0
  35. package/dist/quality/collect.js +412 -0
  36. package/dist/quality/inference.d.ts +86 -0
  37. package/dist/quality/inference.js +603 -0
  38. package/dist/quality/matchers.d.ts +129 -0
  39. package/dist/quality/matchers.js +220 -0
  40. package/dist/quality/pairing.d.ts +133 -0
  41. package/dist/quality/pairing.js +770 -0
  42. package/dist/quality/pipeline.d.ts +59 -0
  43. package/dist/quality/pipeline.js +202 -0
  44. package/dist/quality/types.d.ts +127 -0
  45. package/dist/quality/types.js +92 -0
  46. package/dist/safeio.d.ts +107 -0
  47. package/dist/safeio.js +314 -0
  48. package/dist/server.d.ts +19 -0
  49. package/dist/server.js +451 -0
  50. package/dist/signals/adapter.d.ts +103 -0
  51. package/dist/signals/adapter.js +323 -0
  52. package/dist/signals/caller-index.d.ts +117 -0
  53. package/dist/signals/caller-index.js +147 -0
  54. package/dist/signals/caller.d.ts +76 -0
  55. package/dist/signals/caller.js +108 -0
  56. package/dist/signals/evidence.d.ts +233 -0
  57. package/dist/signals/evidence.js +578 -0
  58. package/dist/signals/interface.d.ts +68 -0
  59. package/dist/signals/interface.js +87 -0
  60. package/dist/signals/jsdoc.d.ts +27 -0
  61. package/dist/signals/jsdoc.js +233 -0
  62. package/dist/signals/naming.d.ts +26 -0
  63. package/dist/signals/naming.js +160 -0
  64. package/dist/signals/routing.d.ts +163 -0
  65. package/dist/signals/routing.js +416 -0
  66. package/dist/signals/types.d.ts +146 -0
  67. package/dist/signals/types.js +99 -0
  68. package/dist/signals/visibility.d.ts +23 -0
  69. package/dist/signals/visibility.js +82 -0
  70. package/dist/taxonomy.d.ts +89 -0
  71. package/dist/taxonomy.js +217 -0
  72. package/package.json +61 -4
@@ -0,0 +1,129 @@
1
+ import type { AssertionKind } from "./types.js";
2
+ /**
3
+ * The normative matcher classification table (FR-007/FR-008; research R6;
4
+ * data-model.md Section 4, rendered verbatim) — the total routing from
5
+ * assertion forms to the closed `AssertionKind` vocabulary.
6
+ *
7
+ * FR-007 pins the table as normative data precisely so
8
+ * implementation-time discretion cannot reshape it: every standard
9
+ * vitest/jest `expect()` matcher and `node:assert` function is routed to
10
+ * a kind or explicitly to none. This module is pure fixed data plus pure
11
+ * classification functions — no compiler interaction, no I/O, no hidden
12
+ * state (the src/signals/routing.ts precedent: normative data gets its
13
+ * own module and a doc-parity test).
14
+ *
15
+ * Safety mechanisms, in the routing.ts and taxonomy.ts tradition:
16
+ *
17
+ * - Doc parity: tests/quality/matchers.test.ts (T004) parses
18
+ * data-model.md Section 4's tables and diffs every row against this
19
+ * module's entries, order included (the disposition-table anti-drift
20
+ * pattern), so the code table and the normative prose cannot drift
21
+ * apart.
22
+ * - Total miss path: a form absent from the table routes to `custom` —
23
+ * never an exception, never a drop (US3-6). An unknown matcher (custom
24
+ * `expect.extend` vocabulary) and an unknown `assert` member are
25
+ * recognized assertions of an unrecognized kind, not errors.
26
+ *
27
+ * The kind set is Gaze's assertion-type set (porting contract
28
+ * `docs/porting/taxonomy-reference.md`; the report-schema enum), and the
29
+ * routing principle is parity with Gaze's Go-native detector: each form
30
+ * takes the kind Gaze assigns its testify analog (data-model Section 3,
31
+ * amended by OpenSpec change `align-assertion-types`):
32
+ *
33
+ * - `equality` — value checks of every shape: exact and structural
34
+ * equality, closeness, object shape, with-argument mock forms, ordered
35
+ * relations (testify `Greater`/`Less`), containment and patterns
36
+ * (`Contains`/`Regexp`), truthiness (`True`/`False`), length (`Len`),
37
+ * type and instance checks (`IsType`).
38
+ * - `error_check` — the error channel: the `toThrow` family, every
39
+ * matcher under `.rejects`, the `assert.throws` family, and
40
+ * `assert.ifError` (testify `NoError`).
41
+ * - `nil_check` — null/undefined presence (testify `Nil`/`NotNil`).
42
+ * - `diff_check` — snapshot matchers (go-cmp `Diff`).
43
+ * - `custom` — mock occurrence/count forms, predicate matchers,
44
+ * `assert.fail`, and unknown or custom matchers.
45
+ *
46
+ * Negation never changes the kind: `.not.` and `not`-prefixed assert
47
+ * functions preserve it.
48
+ *
49
+ * `node:assert/strict` changes call semantics, not routing (data-model
50
+ * Section 4.2): the syntactic form routes identically, which is why the
51
+ * table keys on member names alone.
52
+ */
53
+ /**
54
+ * The Section 4.1 expect-matcher routing table, transcribed verbatim in
55
+ * data-model.md table order: matcher name → classification kind. An
56
+ * immutable `Map` (own-data lookups, never the prototype chain) whose
57
+ * insertion order IS the document order — the doc-parity suite diffs
58
+ * entries in order, so a reordered or missing row fails conformance.
59
+ *
60
+ * Rows are rendered one per matcher with inline literals — normative
61
+ * data is transcribed, not factored into per-kind family constants: each
62
+ * row is independently pinned (a one-row data-model amendment edits one
63
+ * row here) and independently diffed by the conformance suite (the
64
+ * routing.ts transcription discipline).
65
+ */
66
+ export declare const EXPECT_MATCHER_KINDS: ReadonlyMap<string, AssertionKind>;
67
+ /**
68
+ * The Section 4.2 `node:assert` routing table, transcribed verbatim in
69
+ * data-model.md table order (flattened over the document's
70
+ * ` / `-separated two-form rows): assert member name → classification
71
+ * kind. The memberless bare call `assert(value)` is not an entry — it is
72
+ * the `undefined` member in `classifyAssertCall`, routed to `equality`
73
+ * like `assert.ok` (testify `True`).
74
+ *
75
+ * `not`-prefixed functions carry their base kind (US3-7: negation flips
76
+ * polarity, never the kind).
77
+ */
78
+ export declare const ASSERT_FUNCTION_KINDS: ReadonlyMap<string, AssertionKind>;
79
+ /**
80
+ * Classifies one `expect()` chain invocation (FR-008; data-model Section
81
+ * 4.1's matcher table plus its modifier table) — a pure function over
82
+ * the chain's spelled form.
83
+ *
84
+ * Modifier semantics, applied to the invoked matcher's kind:
85
+ *
86
+ * - `.not.` anywhere in the chain preserves the kind (negation flips
87
+ * polarity, never the relation's family).
88
+ * - `.resolves.` preserves the kind.
89
+ * - `.rejects.` routes to `error_check` regardless of matcher — checked
90
+ * first, so it wins in any combination.
91
+ * - Any other intermediate property is inert chain context: the
92
+ * classification follows the invoked matcher alone.
93
+ * - `await` wrappers are transparent BY CONSTRUCTION: the chain
94
+ * reconstructor (src/quality/assertions.ts) unwraps
95
+ * `AwaitExpression`s before the modifier list reaches this function,
96
+ * so an awaited chain classifies identically (US3-10). This function
97
+ * never sees an await.
98
+ *
99
+ * The miss path is total: an unknown or custom matcher name (the
100
+ * `expect.extend` vocabulary) routes to `custom` — never an exception,
101
+ * never a drop.
102
+ *
103
+ * @param matcher The invoked property's name — the matcher (`"toBe"` in
104
+ * `expect(x).not.toBe(y)`).
105
+ * @param modifiers The intermediate property names between the `expect`
106
+ * call and the invoked matcher, in chain order (`["not"]` in
107
+ * `expect(x).not.toBe(y)`; `[]` for a bare `expect(x).toBe(y)`).
108
+ * @returns The classified `AssertionKind` (`custom` on a miss).
109
+ */
110
+ export declare function classifyExpectChain(matcher: string, modifiers: readonly string[]): AssertionKind;
111
+ /**
112
+ * Classifies one `node:assert` call form (FR-008; data-model Section
113
+ * 4.2's table) — a pure function over the call's spelled form.
114
+ *
115
+ * `node:assert/strict` changes call semantics, not routing: the member
116
+ * name routes identically, so the binding's module specifier never
117
+ * reaches this table (the closed specifier set and binding forms are the
118
+ * assert-binding table's concern in src/quality/assertions.ts).
119
+ *
120
+ * The miss path is total: an unknown member call on an assert binding
121
+ * routes to `custom` — never an exception, never a drop.
122
+ *
123
+ * @param member The invoked member's name (`"equal"` for
124
+ * `assert.equal(a, b)`), or `undefined` for the memberless bare
125
+ * truthiness call `assert(value)`, which routes to `equality` like
126
+ * `assert.ok` (testify `True`).
127
+ * @returns The classified `AssertionKind` (`custom` on a miss).
128
+ */
129
+ export declare function classifyAssertCall(member: string | undefined): AssertionKind;
@@ -0,0 +1,220 @@
1
+ /**
2
+ * The normative matcher classification table (FR-007/FR-008; research R6;
3
+ * data-model.md Section 4, rendered verbatim) — the total routing from
4
+ * assertion forms to the closed `AssertionKind` vocabulary.
5
+ *
6
+ * FR-007 pins the table as normative data precisely so
7
+ * implementation-time discretion cannot reshape it: every standard
8
+ * vitest/jest `expect()` matcher and `node:assert` function is routed to
9
+ * a kind or explicitly to none. This module is pure fixed data plus pure
10
+ * classification functions — no compiler interaction, no I/O, no hidden
11
+ * state (the src/signals/routing.ts precedent: normative data gets its
12
+ * own module and a doc-parity test).
13
+ *
14
+ * Safety mechanisms, in the routing.ts and taxonomy.ts tradition:
15
+ *
16
+ * - Doc parity: tests/quality/matchers.test.ts (T004) parses
17
+ * data-model.md Section 4's tables and diffs every row against this
18
+ * module's entries, order included (the disposition-table anti-drift
19
+ * pattern), so the code table and the normative prose cannot drift
20
+ * apart.
21
+ * - Total miss path: a form absent from the table routes to `custom` —
22
+ * never an exception, never a drop (US3-6). An unknown matcher (custom
23
+ * `expect.extend` vocabulary) and an unknown `assert` member are
24
+ * recognized assertions of an unrecognized kind, not errors.
25
+ *
26
+ * The kind set is Gaze's assertion-type set (porting contract
27
+ * `docs/porting/taxonomy-reference.md`; the report-schema enum), and the
28
+ * routing principle is parity with Gaze's Go-native detector: each form
29
+ * takes the kind Gaze assigns its testify analog (data-model Section 3,
30
+ * amended by OpenSpec change `align-assertion-types`):
31
+ *
32
+ * - `equality` — value checks of every shape: exact and structural
33
+ * equality, closeness, object shape, with-argument mock forms, ordered
34
+ * relations (testify `Greater`/`Less`), containment and patterns
35
+ * (`Contains`/`Regexp`), truthiness (`True`/`False`), length (`Len`),
36
+ * type and instance checks (`IsType`).
37
+ * - `error_check` — the error channel: the `toThrow` family, every
38
+ * matcher under `.rejects`, the `assert.throws` family, and
39
+ * `assert.ifError` (testify `NoError`).
40
+ * - `nil_check` — null/undefined presence (testify `Nil`/`NotNil`).
41
+ * - `diff_check` — snapshot matchers (go-cmp `Diff`).
42
+ * - `custom` — mock occurrence/count forms, predicate matchers,
43
+ * `assert.fail`, and unknown or custom matchers.
44
+ *
45
+ * Negation never changes the kind: `.not.` and `not`-prefixed assert
46
+ * functions preserve it.
47
+ *
48
+ * `node:assert/strict` changes call semantics, not routing (data-model
49
+ * Section 4.2): the syntactic form routes identically, which is why the
50
+ * table keys on member names alone.
51
+ */
52
+ /**
53
+ * The Section 4.1 expect-matcher routing table, transcribed verbatim in
54
+ * data-model.md table order: matcher name → classification kind. An
55
+ * immutable `Map` (own-data lookups, never the prototype chain) whose
56
+ * insertion order IS the document order — the doc-parity suite diffs
57
+ * entries in order, so a reordered or missing row fails conformance.
58
+ *
59
+ * Rows are rendered one per matcher with inline literals — normative
60
+ * data is transcribed, not factored into per-kind family constants: each
61
+ * row is independently pinned (a one-row data-model amendment edits one
62
+ * row here) and independently diffed by the conformance suite (the
63
+ * routing.ts transcription discipline).
64
+ */
65
+ export const EXPECT_MATCHER_KINDS = new Map([
66
+ // --- equality: value forms ---
67
+ ["toBe", "equality"],
68
+ ["toEqual", "equality"],
69
+ ["toStrictEqual", "equality"],
70
+ ["toBeCloseTo", "equality"],
71
+ ["toMatchObject", "equality"],
72
+ // --- equality: with-args mock forms ---
73
+ ["toHaveBeenCalledWith", "equality"],
74
+ ["toHaveBeenLastCalledWith", "equality"],
75
+ ["toHaveBeenNthCalledWith", "equality"],
76
+ ["toHaveReturnedWith", "equality"],
77
+ ["toHaveLastReturnedWith", "equality"],
78
+ ["toHaveNthReturnedWith", "equality"],
79
+ // --- equality: legacy jest aliases ---
80
+ ["toBeCalledWith", "equality"],
81
+ ["lastCalledWith", "equality"],
82
+ ["nthCalledWith", "equality"],
83
+ // --- equality: ordered relations (testify Greater/Less) ---
84
+ ["toBeGreaterThan", "equality"],
85
+ ["toBeGreaterThanOrEqual", "equality"],
86
+ ["toBeLessThan", "equality"],
87
+ ["toBeLessThanOrEqual", "equality"],
88
+ // --- equality: containment and patterns (testify Contains/Regexp) ---
89
+ ["toContain", "equality"],
90
+ ["toContainEqual", "equality"],
91
+ ["toMatch", "equality"],
92
+ // --- error_check: the error channel ---
93
+ ["toThrow", "error_check"],
94
+ ["toThrowError", "error_check"],
95
+ ["toThrowErrorMatchingSnapshot", "error_check"],
96
+ ["toThrowErrorMatchingInlineSnapshot", "error_check"],
97
+ // --- formerly unclassified, routed by testify analog ---
98
+ ["toBeTruthy", "equality"],
99
+ ["toBeFalsy", "equality"],
100
+ ["toBeNull", "nil_check"],
101
+ ["toBeUndefined", "nil_check"],
102
+ ["toBeDefined", "nil_check"],
103
+ ["toBeNaN", "equality"],
104
+ ["toBeInstanceOf", "equality"],
105
+ ["toHaveBeenCalled", "custom"],
106
+ ["toHaveBeenCalledTimes", "custom"],
107
+ ["toHaveReturned", "custom"],
108
+ ["toHaveReturnedTimes", "custom"],
109
+ ["toBeCalled", "custom"],
110
+ ["toBeCalledTimes", "custom"],
111
+ ["toHaveProperty", "equality"],
112
+ ["toHaveLength", "equality"],
113
+ ["toMatchSnapshot", "diff_check"],
114
+ ["toMatchInlineSnapshot", "diff_check"],
115
+ ["toBeTypeOf", "equality"],
116
+ ["toSatisfy", "custom"],
117
+ ]);
118
+ /**
119
+ * The Section 4.2 `node:assert` routing table, transcribed verbatim in
120
+ * data-model.md table order (flattened over the document's
121
+ * ` / `-separated two-form rows): assert member name → classification
122
+ * kind. The memberless bare call `assert(value)` is not an entry — it is
123
+ * the `undefined` member in `classifyAssertCall`, routed to `equality`
124
+ * like `assert.ok` (testify `True`).
125
+ *
126
+ * `not`-prefixed functions carry their base kind (US3-7: negation flips
127
+ * polarity, never the kind).
128
+ */
129
+ export const ASSERT_FUNCTION_KINDS = new Map([
130
+ // --- truthiness, error, and unconditional-failure forms ---
131
+ ["ok", "equality"],
132
+ ["ifError", "error_check"],
133
+ ["fail", "custom"],
134
+ // --- equality (each with its not-sibling) ---
135
+ ["equal", "equality"],
136
+ ["notEqual", "equality"],
137
+ ["strictEqual", "equality"],
138
+ ["notStrictEqual", "equality"],
139
+ ["deepEqual", "equality"],
140
+ ["notDeepEqual", "equality"],
141
+ ["deepStrictEqual", "equality"],
142
+ ["notDeepStrictEqual", "equality"],
143
+ // --- equality: patterns (testify Regexp) ---
144
+ ["match", "equality"],
145
+ ["doesNotMatch", "equality"],
146
+ // --- error_check ---
147
+ ["throws", "error_check"],
148
+ ["doesNotThrow", "error_check"],
149
+ ["rejects", "error_check"],
150
+ ["doesNotReject", "error_check"],
151
+ ]);
152
+ /**
153
+ * The chain modifier that reroutes classification to the error channel
154
+ * (data-model Section 4.1's modifier table): `.rejects.` asserts about
155
+ * the rejection channel, so the row is an `error_check` regardless of
156
+ * the invoked matcher.
157
+ */
158
+ const ERROR_CHANNEL_MODIFIER = "rejects";
159
+ /**
160
+ * Classifies one `expect()` chain invocation (FR-008; data-model Section
161
+ * 4.1's matcher table plus its modifier table) — a pure function over
162
+ * the chain's spelled form.
163
+ *
164
+ * Modifier semantics, applied to the invoked matcher's kind:
165
+ *
166
+ * - `.not.` anywhere in the chain preserves the kind (negation flips
167
+ * polarity, never the relation's family).
168
+ * - `.resolves.` preserves the kind.
169
+ * - `.rejects.` routes to `error_check` regardless of matcher — checked
170
+ * first, so it wins in any combination.
171
+ * - Any other intermediate property is inert chain context: the
172
+ * classification follows the invoked matcher alone.
173
+ * - `await` wrappers are transparent BY CONSTRUCTION: the chain
174
+ * reconstructor (src/quality/assertions.ts) unwraps
175
+ * `AwaitExpression`s before the modifier list reaches this function,
176
+ * so an awaited chain classifies identically (US3-10). This function
177
+ * never sees an await.
178
+ *
179
+ * The miss path is total: an unknown or custom matcher name (the
180
+ * `expect.extend` vocabulary) routes to `custom` — never an exception,
181
+ * never a drop.
182
+ *
183
+ * @param matcher The invoked property's name — the matcher (`"toBe"` in
184
+ * `expect(x).not.toBe(y)`).
185
+ * @param modifiers The intermediate property names between the `expect`
186
+ * call and the invoked matcher, in chain order (`["not"]` in
187
+ * `expect(x).not.toBe(y)`; `[]` for a bare `expect(x).toBe(y)`).
188
+ * @returns The classified `AssertionKind` (`custom` on a miss).
189
+ */
190
+ export function classifyExpectChain(matcher, modifiers) {
191
+ if (modifiers.includes(ERROR_CHANNEL_MODIFIER)) {
192
+ return "error_check";
193
+ }
194
+ return EXPECT_MATCHER_KINDS.get(matcher) ?? "custom";
195
+ }
196
+ /**
197
+ * Classifies one `node:assert` call form (FR-008; data-model Section
198
+ * 4.2's table) — a pure function over the call's spelled form.
199
+ *
200
+ * `node:assert/strict` changes call semantics, not routing: the member
201
+ * name routes identically, so the binding's module specifier never
202
+ * reaches this table (the closed specifier set and binding forms are the
203
+ * assert-binding table's concern in src/quality/assertions.ts).
204
+ *
205
+ * The miss path is total: an unknown member call on an assert binding
206
+ * routes to `custom` — never an exception, never a drop.
207
+ *
208
+ * @param member The invoked member's name (`"equal"` for
209
+ * `assert.equal(a, b)`), or `undefined` for the memberless bare
210
+ * truthiness call `assert(value)`, which routes to `equality` like
211
+ * `assert.ok` (testify `True`).
212
+ * @returns The classified `AssertionKind` (`custom` on a miss).
213
+ */
214
+ export function classifyAssertCall(member) {
215
+ if (member === undefined) {
216
+ return "equality";
217
+ }
218
+ return ASSERT_FUNCTION_KINDS.get(member) ?? "custom";
219
+ }
220
+ //# sourceMappingURL=matchers.js.map
@@ -0,0 +1,133 @@
1
+ import type { Writable } from "node:stream";
2
+ import { type Node } from "typescript/unstable/ast";
3
+ import type { ExtractionRecord } from "../extract.js";
4
+ import { type Effect } from "../models.js";
5
+ import { type ProgramContext } from "../program.js";
6
+ import type { TestFunction } from "./collect.js";
7
+ /**
8
+ * The pairing strategies, in evaluation priority order (data-model.md
9
+ * Section 6; FR-004/FR-005's pinned confidences):
10
+ *
11
+ * - `naming` — the test's title or nearest enclosing describe title
12
+ * equals a target name: exact (case-sensitive) `90`, case-insensitive
13
+ * only `70`.
14
+ * - `calls` — the test's callback subtree contains a call expression
15
+ * resolving to the target: `80`.
16
+ * - `imports` — the test's file statically imports and references the
17
+ * target through a named specifier: `75`.
18
+ *
19
+ * The union is the closed strategy vocabulary the `Pairing` record and
20
+ * the row `confidence` values are pinned against; the full
21
+ * first-match-wins evaluation order is naming → calls → imports (FR-005).
22
+ */
23
+ export type PairingStrategy = "naming" | "calls" | "imports";
24
+ /**
25
+ * The closed confidence vocabulary (data-model.md Section 5.3): one fixed
26
+ * integer per strategy tier — naming exact `90`, naming case-insensitive
27
+ * `70`, direct calls `80`, import graph `75`. A literal union, not
28
+ * `number`, so the pin is compile-time enforced and an out-of-vocabulary
29
+ * confidence cannot typecheck (iteration-2 review fix F6).
30
+ */
31
+ export type PairingConfidence = 90 | 70 | 80 | 75;
32
+ /**
33
+ * One established test-to-target pair (data-model.md Section 5.3): the
34
+ * test and target are reference-identity carries of the collector's and
35
+ * the pipeline's own objects — not copies — so downstream stages
36
+ * (assertion collection, inference) keep AST access.
37
+ */
38
+ export interface Pairing {
39
+ /** The collected test function, by reference into the collector's output. */
40
+ readonly test: TestFunction;
41
+ /** The paired target record, by reference into the prepared records. */
42
+ readonly target: ExtractionRecord;
43
+ /** The strategy that established the pair. */
44
+ readonly strategy: PairingStrategy;
45
+ /** The strategy's fixed confidence — the closed union Section 5.3 pins. */
46
+ readonly confidence: PairingConfidence;
47
+ }
48
+ /**
49
+ * The pairing-support view over one pipeline run's prepared analysis
50
+ * (data-model.md Section 5.4), built once per run by
51
+ * `buildTargetIndex`:
52
+ *
53
+ * - `records` — the in-scope source records in `(file, line, name)` order
54
+ * (the identical `analyze` set; FR-006's target parity), the order
55
+ * every strategy's output follows.
56
+ * - `byName` — declared name → the records carrying it, in record order
57
+ * (the naming strategy's lookup).
58
+ * - `byNode` — declaration node → record (the checker-mode strategies'
59
+ * symbol-declaration matching, US2).
60
+ * - `effects` — the `detectEffects` output per record (the inference
61
+ * stage's input, threaded here so pairing and inference share one
62
+ * detection result — never a second walk).
63
+ * - `context` — the live `ProgramContext`; the pipeline entry owns
64
+ * disposal, the index only lends read access.
65
+ */
66
+ export interface TargetIndex {
67
+ /** The in-scope records, `(file, line, name)`-sorted. */
68
+ readonly records: readonly ExtractionRecord[];
69
+ /** Declared name → the records carrying it, in record order. */
70
+ readonly byName: ReadonlyMap<string, readonly ExtractionRecord[]>;
71
+ /** Declaration node → record (checker-mode symbol matching). */
72
+ readonly byNode: ReadonlyMap<Node, ExtractionRecord>;
73
+ /** The per-record effect sets (`detectEffects`' output). */
74
+ readonly effects: ReadonlyMap<ExtractionRecord, readonly Effect[]>;
75
+ /** The live analysis context; read-only lending, never owned. */
76
+ readonly context: ProgramContext;
77
+ }
78
+ /**
79
+ * Builds the pairing-support `TargetIndex` over one pipeline run's
80
+ * prepared analysis (data-model.md Section 5.4).
81
+ *
82
+ * The records are sorted by the analyze record order —
83
+ * `compareFileLineName` over `(relPath, line, name)` — so `records` and
84
+ * every `byName` list are deterministic and match `analyze`'s reported
85
+ * order even when a caller (hand-built test fixtures included) passes an
86
+ * unsorted list. The sort is idempotent over `prepareAnalysis` output,
87
+ * which is already in that order.
88
+ *
89
+ * @param records The in-scope source records (the identical `analyze`
90
+ * set, FR-006's target parity).
91
+ * @param effects The `detectEffects` output per record.
92
+ * @param context The live `ProgramContext` of the same run; lent
93
+ * read-only, never disposed here.
94
+ * @returns The index every pairing strategy consults.
95
+ */
96
+ export declare function buildTargetIndex(records: readonly ExtractionRecord[], effects: ReadonlyMap<ExtractionRecord, readonly Effect[]>, context: ProgramContext): TargetIndex;
97
+ /**
98
+ * Pairs the collected test functions with their target records
99
+ * (FR-004/FR-005): per test, the strategies evaluate in fixed priority
100
+ * order — naming → calls → imports — first-match-wins: evaluation stops
101
+ * at the first strategy with any match, and only that strategy's pairs
102
+ * are emitted (a test paired by naming never evaluates calls or imports;
103
+ * a test paired by calls never evaluates imports). Each test's winning
104
+ * emission flows through the per-test pair-key first-wins dedup
105
+ * (`dedupeByPairKey`, FR-005's amended soundness pin).
106
+ *
107
+ * The imports tier is file-scoped: its evidence (the referenced imported
108
+ * targets) is memoized per test file inside this call, computed only when
109
+ * a test actually reaches the third tier — never recomputed per test, and
110
+ * never at all for a file whose every test pairs by naming or calls
111
+ * (research R4's pinned traffic bound: one `getSymbolAtLocation` query
112
+ * per import specifier per test file).
113
+ *
114
+ * Each test pairs independently — one test's matches never affect
115
+ * another's — and unpaired tests produce no pairs, never confidence-0
116
+ * rows. Every walk the tiers own is depth-bounded by the shared
117
+ * `MAPPING_WALK_DEPTH_BUDGET` (F2), with per-test and per-file skips
118
+ * diagnosed to `stderr`.
119
+ *
120
+ * @param tests The collected test functions (the collector's sorted output).
121
+ * @param index The pairing-support target index for the same run.
122
+ * @param rootPath Realpath-resolved absolute analysis root — the
123
+ * program-mode source-name base for the file-scoped import walk (the
124
+ * collect.ts threading precedent: passed explicitly, never re-derived;
125
+ * never consulted in parse-only mode).
126
+ * @param stderr The diagnostic sink for depth-budget skips (the server's
127
+ * stderr; never stdout — protocol fidelity).
128
+ * @returns The pairs: per test in input order, each test's matches in
129
+ * analyze record order `(file, line, name)`, wire-indistinguishable
130
+ * targets (same-file and colliding-package same-named records alike)
131
+ * collapsed to the first record.
132
+ */
133
+ export declare function pairTests(tests: readonly TestFunction[], index: TargetIndex, rootPath: string, stderr?: Writable): Pairing[];