reading-stone 0.0.0-stage → 0.2.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.
Files changed (72) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +11 -0
  3. package/README.md +274 -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 +54 -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,498 @@
1
+ import { isArrowFunction, isBindingElement, isCallExpression, isClassDeclaration, isConstructorDeclaration, isExportAssignment, isFunctionDeclaration, isFunctionExpression, isGetAccessorDeclaration, isIdentifier, isImportDeclaration, isMethodDeclaration, isNamedImports, isNamespaceImport, isPropertyAccessExpression, isPropertyAssignment, isPropertyDeclaration, isSetAccessorDeclaration, isVariableDeclaration, } from "typescript/unstable/ast";
2
+ import { compareFileLineName, relativeUnderBase } from "./internal.js";
3
+ /**
4
+ * The AST visit depth budget (research R15): far beyond real-world nesting,
5
+ * low enough that the recursive walk cannot exhaust the native stack on
6
+ * adversarial input. Fixed, not caller-configurable — the same bound shape
7
+ * as safeio's byte cap.
8
+ */
9
+ const AST_DEPTH_BUDGET = 2000;
10
+ /**
11
+ * The bare timer globals of the closed scheduling set (research R6):
12
+ * matched as whole callee identifiers, receiver-blind. Exported because
13
+ * `detector.ts`'s FR-016 spawn forms match the same globals — the two
14
+ * modules share the one set and can never disagree on it.
15
+ */
16
+ export const TIMER_GLOBAL_NAMES = new Set([
17
+ "setTimeout",
18
+ "setInterval",
19
+ "queueMicrotask",
20
+ ]);
21
+ const PROMISE_CALLBACK_METHODS = new Set([
22
+ "then",
23
+ "catch",
24
+ "finally",
25
+ ]);
26
+ /** The per-file abort sentinel for the depth budget (never escapes this module). */
27
+ class AstDepthExceeded extends Error {
28
+ constructor() {
29
+ super("ast depth exceeds budget");
30
+ }
31
+ }
32
+ /**
33
+ * Extracts every R4-form function-like from the context's in-scope sources
34
+ * (FR-007, FR-008; research R4, R12).
35
+ *
36
+ * @param realRoot Realpath-resolved absolute analysis root (discovery's
37
+ * `resolveRoot` output); program-mode source names relativize against it.
38
+ * @param context The bootstrapped `ProgramContext` in either mode; the
39
+ * context is only read during the call.
40
+ * @param stderr Injected diagnostic sink for per-file depth-budget skips;
41
+ * stdout is never touched.
42
+ * @returns The extraction records, sorted by `(relPath, line, name)` with
43
+ * full-key ties resolved by source order through sort stability.
44
+ */
45
+ export function extractFunctions(realRoot, context, stderr) {
46
+ const records = [];
47
+ for (const [relPath, sourceFile] of collectSources(realRoot, context)) {
48
+ extractFromFile(relPath, sourceFile, stderr, records);
49
+ }
50
+ records.sort(compareRecords);
51
+ return records;
52
+ }
53
+ /**
54
+ * The walk set: parse-only sources arrive keyed by root-relative path;
55
+ * program-mode names are the compiler's absolute file names, filtered to
56
+ * the in-scope files that relativize strictly beneath `realRoot`. The
57
+ * configured program's default libraries live outside the analysis root
58
+ * and cannot pass the containment test, so exactly the analyzed tree's
59
+ * sources are walked. Exported as a pure widening (spec 005 T003,
60
+ * FR-011; research R2) for the doc-coverage consumer
61
+ * (src/doc-coverage.ts): its symbol-surface walk iterates this one walk
62
+ * set instead of re-deriving the in-scope sources, so FR-004's
63
+ * file-set parity with `analyze` stays structural.
64
+ *
65
+ * @param realRoot Realpath-resolved absolute analysis root.
66
+ * @param context The bootstrapped context in either mode.
67
+ * @returns `(relPath, SourceFile)` pairs in context order.
68
+ */
69
+ export function collectSources(realRoot, context) {
70
+ if (context.mode === "parse-only") {
71
+ return [...context.sources];
72
+ }
73
+ const pairs = [];
74
+ for (const fileName of context.program.getSourceFileNames()) {
75
+ const relPath = relativeUnderBase(realRoot, fileName);
76
+ if (relPath === null) {
77
+ continue;
78
+ }
79
+ const sourceFile = context.program.getSourceFile(fileName);
80
+ if (sourceFile === undefined) {
81
+ continue;
82
+ }
83
+ pairs.push([relPath, sourceFile]);
84
+ }
85
+ return pairs;
86
+ }
87
+ /**
88
+ * Walks one source file into `records`, or nothing on a depth abort (the
89
+ * counter tripping or the native stack exhausting first): the file's
90
+ * records are buffered so a pathological file can be excluded whole (R15 —
91
+ * "the file contributes no records"), with exactly one diagnostic written
92
+ * before the walk continues with the next file.
93
+ *
94
+ * @param relPath Root-relative POSIX path, echoed in the skip diagnostic.
95
+ * @param sourceFile The parsed source to walk.
96
+ * @param stderr Injected diagnostic sink for the depth-budget skip.
97
+ * @param records The accumulating cross-file record list.
98
+ */
99
+ function extractFromFile(relPath, sourceFile, stderr, records) {
100
+ const fileRecords = [];
101
+ const walker = new FileWalker(relPath, sourceFile, fileRecords);
102
+ try {
103
+ walker.walk();
104
+ }
105
+ catch (error) {
106
+ // Both abort modes are the same per-file degradation (R15): the depth
107
+ // counter tripping, or the native stack exhausting first inside the
108
+ // lazy node materialization — the same depth condition manifesting
109
+ // through the environment's stack size instead of the counter, so it
110
+ // shares the one diagnostic line and the whole-file discard.
111
+ if (!(error instanceof AstDepthExceeded || error instanceof RangeError)) {
112
+ throw error;
113
+ }
114
+ stderr.write(`reading-stone: skipping ${relPath}: ast depth exceeds budget\n`);
115
+ return;
116
+ }
117
+ for (const record of fileRecords) {
118
+ records.push(record);
119
+ }
120
+ }
121
+ /**
122
+ * The FR-008 order, via the shared `(file, line, name)` comparator
123
+ * (src/internal.ts): codepoint comparison for the string keys and `0` on
124
+ * full-key ties so the platform-default stable sort resolves them by
125
+ * emission (source) order — the getter-before-setter resolution for a
126
+ * one-line accessor pair. The record's file key is `relPath`, the same
127
+ * root-relative POSIX spelling the wire payloads carry as `file`.
128
+ *
129
+ * @param a Left record.
130
+ * @param b Right record.
131
+ * @returns The three-key comparison result.
132
+ */
133
+ function compareRecords(a, b) {
134
+ return compareFileLineName({ file: a.relPath, line: a.line, name: a.name }, { file: b.relPath, line: b.line, name: b.name });
135
+ }
136
+ /**
137
+ * One file's extraction walk: a single pre-order descent that maintains the
138
+ * R5 scope-tracker state, the R6 deferral flag, and the per-file record
139
+ * buffer. Records are created at the function-like node itself — the R4
140
+ * expression forms (variable-, property-, and default-assigned arrows and
141
+ * function expressions) resolve their names from the node's parent shape,
142
+ * so every form's record lands in source order without a second pass.
143
+ */
144
+ class FileWalker {
145
+ relPath;
146
+ sourceFile;
147
+ records;
148
+ current;
149
+ deferred = false;
150
+ constructor(relPath, sourceFile, records) {
151
+ this.relPath = relPath;
152
+ this.sourceFile = sourceFile;
153
+ this.records = records;
154
+ this.current = { kind: "module", names: new Set(), parent: undefined };
155
+ }
156
+ /** Runs the walk from the source file root (depth 0). */
157
+ walk() {
158
+ this.visit(this.sourceFile, 0);
159
+ }
160
+ visit(node, depth) {
161
+ if (depth > AST_DEPTH_BUDGET) {
162
+ throw new AstDepthExceeded();
163
+ }
164
+ if (isFunctionDeclaration(node)) {
165
+ this.visitFunctionDeclaration(node, depth);
166
+ return;
167
+ }
168
+ if (isMethodDeclaration(node) ||
169
+ isConstructorDeclaration(node) ||
170
+ isGetAccessorDeclaration(node) ||
171
+ isSetAccessorDeclaration(node)) {
172
+ this.visitMethodLike(node, depth);
173
+ return;
174
+ }
175
+ if (isArrowFunction(node) || isFunctionExpression(node)) {
176
+ this.visitFunctionExpressionLike(node, depth);
177
+ return;
178
+ }
179
+ if (isCallExpression(node)) {
180
+ this.visitCallExpression(node, depth);
181
+ return;
182
+ }
183
+ this.declareInCurrentScope(node);
184
+ this.walkChildren(node, depth);
185
+ }
186
+ /**
187
+ * Form 1: a function declaration declares its name into the enclosing
188
+ * scope (overload signatures and ambient declarations bind too), but only
189
+ * a body-bearing declaration is a record — an anonymous one is
190
+ * grammatically `export default function`, so it names `"default"`.
191
+ */
192
+ visitFunctionDeclaration(node, depth) {
193
+ if (node.name !== undefined) {
194
+ this.current.names.add(node.name.text);
195
+ }
196
+ if (node.body === undefined) {
197
+ this.walkChildren(node, depth);
198
+ return;
199
+ }
200
+ const name = node.name !== undefined ? node.name.text : "default";
201
+ const enclosing = this.current;
202
+ this.enterFunctionScope(node.parameters);
203
+ this.emitRecord(name, node);
204
+ this.walkChildren(node, depth);
205
+ this.current = enclosing;
206
+ }
207
+ /**
208
+ * Forms 2, 3, and 9: methods, accessors, and constructors — class members
209
+ * and object-literal members share one node kind. Body-less members
210
+ * (abstract methods) walk without a record; a body-bearing member is a
211
+ * record under the member name (`"constructor"` for constructors).
212
+ */
213
+ visitMethodLike(node, depth) {
214
+ if (node.body === undefined) {
215
+ this.walkChildren(node, depth);
216
+ return;
217
+ }
218
+ const name = isConstructorDeclaration(node)
219
+ ? "constructor"
220
+ : propertyNameText(node.name, this.sourceFile);
221
+ const enclosing = this.current;
222
+ this.enterFunctionScope(node.parameters);
223
+ this.emitRecord(name, node);
224
+ this.walkChildren(node, depth);
225
+ this.current = enclosing;
226
+ }
227
+ /**
228
+ * Forms 4, 6, 7, and 10: arrow functions and function expressions always
229
+ * scope their parameters (an anonymous callback still introduces a frame
230
+ * the chain must show), and become records exactly when their parent
231
+ * shape names them — a variable initializer, an object-literal or class
232
+ * property initializer, or an `export default` expression. Every other
233
+ * position (call arguments, IIFE callees, returns, array elements) is an
234
+ * unassigned function expression: walked, scoped, never recorded.
235
+ */
236
+ visitFunctionExpressionLike(node, depth) {
237
+ const name = this.recordNameForExpression(node);
238
+ const enclosing = this.current;
239
+ this.enterFunctionScope(node.parameters);
240
+ if (name !== null) {
241
+ this.emitRecord(name, node);
242
+ }
243
+ this.walkChildren(node, depth);
244
+ this.current = enclosing;
245
+ }
246
+ /**
247
+ * The R4 name for an expression form, from the parent shape: the variable
248
+ * name (an identifier — a destructuring pattern cannot initialize from a
249
+ * function), the object-literal or class property name, or `"default"`
250
+ * for the `export default` expression. `null` when the parent does not
251
+ * name the function (including the parenthesized-initializer boundary:
252
+ * R4's table reads the initializer node itself).
253
+ */
254
+ recordNameForExpression(node) {
255
+ const parent = node.parent;
256
+ if (isVariableDeclaration(parent) && parent.initializer === node) {
257
+ return isIdentifier(parent.name) ? parent.name.text : null;
258
+ }
259
+ if (isPropertyAssignment(parent) && parent.initializer === node) {
260
+ return propertyNameText(parent.name, this.sourceFile);
261
+ }
262
+ if (isPropertyDeclaration(parent) && parent.initializer === node) {
263
+ return propertyNameText(parent.name, this.sourceFile);
264
+ }
265
+ if (isExportAssignment(parent) && parent.expression === node) {
266
+ return "default";
267
+ }
268
+ return null;
269
+ }
270
+ /**
271
+ * A call expression is walked manually — callee first, then arguments —
272
+ * so a function-like argument of a scheduling construct is entered with
273
+ * the deferral flag set for its whole subtree (R6: everything the
274
+ * callback lexically contains is deferred, because it executes after the
275
+ * enclosing function returns). Type arguments are type-only and skipped.
276
+ */
277
+ visitCallExpression(node, depth) {
278
+ this.visit(node.expression, depth + 1);
279
+ const scheduling = isSchedulingCall(node);
280
+ for (const argument of node.arguments) {
281
+ const isCallback = isArrowFunction(argument) || isFunctionExpression(argument);
282
+ if (!scheduling || !isCallback) {
283
+ this.visit(argument, depth + 1);
284
+ continue;
285
+ }
286
+ const enclosing = this.deferred;
287
+ this.deferred = true;
288
+ this.visit(argument, depth + 1);
289
+ this.deferred = enclosing;
290
+ }
291
+ }
292
+ /** The default descent: every child, in source order, one depth deeper. */
293
+ walkChildren(node, depth) {
294
+ node.forEachChild((child) => {
295
+ this.visit(child, depth + 1);
296
+ return undefined;
297
+ });
298
+ }
299
+ /**
300
+ * Collects the binding names a declaration introduces into the current
301
+ * scope — R5's explicit enumeration: variable declarations (including
302
+ * destructured names), classes, and imports (function declarations are
303
+ * handled where their records are emitted). Enum, namespace, and
304
+ * catch-clause bindings fall outside that enumeration and are a
305
+ * documented tracker boundary: writes to them resolve the same way
306
+ * writes to any untracked name do, under the detector's
307
+ * unresolved-name policy.
308
+ */
309
+ declareInCurrentScope(node) {
310
+ const names = this.current.names;
311
+ if (isVariableDeclaration(node)) {
312
+ collectBindingNames(node.name, names);
313
+ return;
314
+ }
315
+ if (isClassDeclaration(node)) {
316
+ if (node.name !== undefined) {
317
+ names.add(node.name.text);
318
+ }
319
+ return;
320
+ }
321
+ if (isImportDeclaration(node)) {
322
+ const clause = node.importClause;
323
+ if (clause?.name !== undefined) {
324
+ names.add(clause.name.text);
325
+ }
326
+ const bindings = clause?.namedBindings;
327
+ if (bindings !== undefined) {
328
+ if (isNamespaceImport(bindings)) {
329
+ names.add(bindings.name.text);
330
+ }
331
+ else if (isNamedImports(bindings)) {
332
+ for (const element of bindings.elements) {
333
+ names.add(element.name.text);
334
+ }
335
+ }
336
+ }
337
+ }
338
+ }
339
+ /**
340
+ * Pushes the function scope for a function-like's parameters; the frame
341
+ * keeps collecting the body's locals until the walk restores the
342
+ * enclosing scope.
343
+ */
344
+ enterFunctionScope(parameters) {
345
+ const frame = {
346
+ kind: "function",
347
+ names: new Set(),
348
+ parent: this.current,
349
+ };
350
+ for (const parameter of parameters) {
351
+ collectBindingNames(parameter.name, frame.names);
352
+ }
353
+ this.current = frame;
354
+ }
355
+ /**
356
+ * Emits one record in source order: identity and line computed now (the
357
+ * consumer may dispose the context immediately after extraction), the
358
+ * scope chain a reference snapshot of the live frames (complete by
359
+ * return), and the deferral flag the walk's current state.
360
+ */
361
+ emitRecord(name, node) {
362
+ const position = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile));
363
+ this.records.push({
364
+ name,
365
+ relPath: this.relPath,
366
+ line: position.line + 1,
367
+ node,
368
+ scopeChain: this.chainOf(this.current),
369
+ deferred: this.deferred,
370
+ });
371
+ }
372
+ /** The live-frame chain, outermost-first, ending at the record's own scope. */
373
+ chainOf(innermost) {
374
+ const chain = [];
375
+ for (let frame = innermost; frame !== undefined; frame = frame.parent) {
376
+ chain.push(frame);
377
+ }
378
+ chain.reverse();
379
+ return chain;
380
+ }
381
+ }
382
+ /**
383
+ * The record name for a property-name position (methods, accessors,
384
+ * object-literal and class properties): the node's source spelling —
385
+ * getStart through getEnd, no trivia — which is the identifier's text for
386
+ * identifier names and the literal's source text for string and numeric
387
+ * literal names, computed names, and private names. Deterministic for the
388
+ * same tree, never fabricated. Exported because doc-coverage's class-member
389
+ * rows carry the same source-spelling identity — the collectBindingNames
390
+ * widening precedent.
391
+ *
392
+ * @param name The property-name node.
393
+ * @param sourceFile The declaring source, for the text slice.
394
+ * @returns The name's text.
395
+ */
396
+ export function propertyNameText(name, sourceFile) {
397
+ return name.getText(sourceFile);
398
+ }
399
+ /**
400
+ * Collects a binding name into a scope frame, recursing through
401
+ * destructuring patterns (`const { a, b: c } = ...`, `const [x, y] = ...`)
402
+ * so every bound spelling is tracked; pattern holes bind nothing. Exported
403
+ * because the detector's scope machinery resolves the same parameter and
404
+ * variable spellings — the one collector, never a mirrored copy.
405
+ *
406
+ * @param name The binding-name node.
407
+ * @param names The frame's accumulating name set.
408
+ */
409
+ export function collectBindingNames(name, names) {
410
+ if (isIdentifier(name)) {
411
+ names.add(name.text);
412
+ return;
413
+ }
414
+ for (const element of name.elements) {
415
+ if (isBindingElement(element) && element.name !== undefined) {
416
+ collectBindingNames(element.name, names);
417
+ }
418
+ }
419
+ }
420
+ /**
421
+ * Whether a call is one of the closed scheduling constructs (R6): a bare
422
+ * `setTimeout`/`setInterval`/`queueMicrotask` reference, Node's
423
+ * `process.nextTick`, a promise `.then`/`.catch`/`.finally` continuation,
424
+ * or an `addEventListener` registration. Exported so the detector's
425
+ * deferral attribution consumes precisely the callbacks this module's
426
+ * `deferred` flag names — never a wider or narrower set (Constitution
427
+ * Principle I: the two walks agree on what "deferred" means).
428
+ *
429
+ * @param node The call expression.
430
+ * @returns Whether the callee matches the scheduling set.
431
+ */
432
+ export function isSchedulingCall(node) {
433
+ const callee = node.expression;
434
+ if (isIdentifier(callee)) {
435
+ return TIMER_GLOBAL_NAMES.has(callee.text);
436
+ }
437
+ if (!isPropertyAccessExpression(callee)) {
438
+ return false;
439
+ }
440
+ const method = callee.name.text;
441
+ if (PROMISE_CALLBACK_METHODS.has(method) || method === "addEventListener") {
442
+ return true;
443
+ }
444
+ return (method === "nextTick" &&
445
+ isIdentifier(callee.expression) &&
446
+ callee.expression.text === "process");
447
+ }
448
+ /**
449
+ * Whether a function-like node is one of the R4 forms that owns its own
450
+ * extraction record — the shared half of the FR-009 attribution boundary:
451
+ * `extractFunctions` emits a record for exactly these, so a per-record
452
+ * consumer walk stops at exactly these (a nested form's constructs belong
453
+ * to its own record) and traverses unassigned function expressions into
454
+ * the enclosing record instead. The conditions mirror the walker dispatch
455
+ * above (body presence for the declaration and member forms, a
456
+ * name-giving parent position for the expression forms); exported so
457
+ * both per-record consumer walks — the complexity engine's attribution
458
+ * walk (FR-022) and the detector's FR-009 walk — consume the one form
459
+ * table with no duplicated dispatch to drift.
460
+ *
461
+ * @param node The node to test.
462
+ * @returns Whether the node's body belongs to its own extraction record.
463
+ */
464
+ export function isExtractedFunctionLike(node) {
465
+ if (isFunctionDeclaration(node)) {
466
+ return node.body !== undefined;
467
+ }
468
+ if (isMethodDeclaration(node) ||
469
+ isConstructorDeclaration(node) ||
470
+ isGetAccessorDeclaration(node) ||
471
+ isSetAccessorDeclaration(node)) {
472
+ return node.body !== undefined;
473
+ }
474
+ if (isArrowFunction(node) || isFunctionExpression(node)) {
475
+ return isNamedExpressionPosition(node);
476
+ }
477
+ return false;
478
+ }
479
+ /**
480
+ * Whether an expression form sits in a parent position that names it —
481
+ * the R4 record condition for arrows and function expressions (a
482
+ * destructuring pattern cannot initialize from a function, so only an
483
+ * identifier variable name names one).
484
+ *
485
+ * @param node The arrow or function expression.
486
+ * @returns Whether the parent shape gives the function a record name.
487
+ */
488
+ function isNamedExpressionPosition(node) {
489
+ const parent = node.parent;
490
+ if (isVariableDeclaration(parent)) {
491
+ return parent.initializer === node && isIdentifier(parent.name);
492
+ }
493
+ if (isPropertyAssignment(parent) || isPropertyDeclaration(parent)) {
494
+ return parent.initializer === node;
495
+ }
496
+ return isExportAssignment(parent) && parent.expression === node;
497
+ }
498
+ //# sourceMappingURL=extract.js.map
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Package entry point (T018, T033; research R9) — the public Reading Stone
3
+ * surface: `VERSION`, the canonical side-effect taxonomy, the shared
4
+ * record models, and the analysis engine's public surface — the analyze,
5
+ * complexity, and coverage method entries, the detector's effect
6
+ * computations, the pattern helpers, and the pipeline's context and
7
+ * record types — re-exported from their modules.
8
+ *
9
+ * The classification signal pipeline (T033) rides the same barrel: the
10
+ * `classify_signals` entry with the fan-out core it shares with `analyze`,
11
+ * the `Signal` wire record and its serializer, the `RecordEvidence`
12
+ * evidence-snapshot type, the five extractor rules, and the normative
13
+ * routing table with its closed vocabulary lists.
14
+ *
15
+ * The test-mapping pipeline (004 T032; research R9) rides it too: the
16
+ * `test_mapping` method entry, the `MappingRow` wire record with its
17
+ * serializer and the `TestMappingResult` envelope, and the normative
18
+ * matcher tables with their classification lookups.
19
+ *
20
+ * The doc-coverage and cognitive-complexity pipelines (005 T025)
21
+ * ride it too: the `doc_coverage` method entry with the `SymbolRow`
22
+ * wire record, its `SymbolKind` vocabulary and serializer, the
23
+ * `cognitive_complexity` entry with the `CognitiveRow` record and
24
+ * its serializer, and the `DocCoverageResult` and
25
+ * `CognitiveComplexityResult` envelopes.
26
+ *
27
+ * An explicit, exhaustive barrel (convention pack AP-001) makes the
28
+ * vocabulary consumable package API instead of orphaned code (Zero-Waste
29
+ * Mandate): later analysis methods and downstream consumers import from
30
+ * the package root rather than reaching into module internals. Type-only
31
+ * names use `export type` clauses so the split between runtime values and
32
+ * compile-time types stays explicit.
33
+ */
34
+ export declare const VERSION = "0.2.0";
35
+ export type { PatternSet, PreparedAnalysis, } from "./analysis.js";
36
+ export { analyze, classifySignals, normalizePatterns, pathInScope, } from "./analysis.js";
37
+ export type { CognitiveRow } from "./cognitive.js";
38
+ export { cognitiveComplexity, serializeCognitiveRow, } from "./cognitive.js";
39
+ export { computeComplexity } from "./complexity.js";
40
+ export { parseCoverage } from "./coverage.js";
41
+ export { assembleFunctionRecords, detectEffects, } from "./detector.js";
42
+ export type { SymbolKind, SymbolRow, } from "./doc-coverage.js";
43
+ export { docCoverage, serializeSymbolRow, } from "./doc-coverage.js";
44
+ export type { ExtractionRecord } from "./extract.js";
45
+ export type { Classification, Effect, FunctionRecord, } from "./models.js";
46
+ export { derivePackage, serializeClassification, serializeEffect, serializeFunctionRecord, } from "./models.js";
47
+ export type { ProgramContext } from "./program.js";
48
+ export type { CognitiveComplexityResult, DocCoverageResult, } from "./protocol.js";
49
+ export { ASSERT_FUNCTION_KINDS, classifyAssertCall, classifyExpectChain, EXPECT_MATCHER_KINDS, } from "./quality/matchers.js";
50
+ export { testMapping } from "./quality/pipeline.js";
51
+ export type { AssertionKind, MappingRow, TestMappingResult, } from "./quality/types.js";
52
+ export { serializeMappingRow } from "./quality/types.js";
53
+ export { classifyPairs } from "./signals/adapter.js";
54
+ export { callerSignal } from "./signals/caller.js";
55
+ export type { RecordEvidence } from "./signals/evidence.js";
56
+ export { interfaceSignal } from "./signals/interface.js";
57
+ export { docstringSignal } from "./signals/jsdoc.js";
58
+ export { namingSignal } from "./signals/naming.js";
59
+ export { CONTRACTUAL_PREFIXES, DIRECT_TAGS, INCIDENTAL_PREFIXES, INCIDENTAL_VERBS, INDIRECT_VERBS, ROUTING_TABLE, } from "./signals/routing.js";
60
+ export type { Signal } from "./signals/types.js";
61
+ export { serializeSignal } from "./signals/types.js";
62
+ export { visibilitySignal } from "./signals/visibility.js";
63
+ export type { SideEffectAlias, SideEffectType, Tier, } from "./taxonomy.js";
64
+ export { ALIAS_MAP, resolveSideEffectType, SIDE_EFFECT_TYPES, TIER_MAP, } from "./taxonomy.js";
package/dist/index.js ADDED
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Package entry point (T018, T033; research R9) — the public Reading Stone
3
+ * surface: `VERSION`, the canonical side-effect taxonomy, the shared
4
+ * record models, and the analysis engine's public surface — the analyze,
5
+ * complexity, and coverage method entries, the detector's effect
6
+ * computations, the pattern helpers, and the pipeline's context and
7
+ * record types — re-exported from their modules.
8
+ *
9
+ * The classification signal pipeline (T033) rides the same barrel: the
10
+ * `classify_signals` entry with the fan-out core it shares with `analyze`,
11
+ * the `Signal` wire record and its serializer, the `RecordEvidence`
12
+ * evidence-snapshot type, the five extractor rules, and the normative
13
+ * routing table with its closed vocabulary lists.
14
+ *
15
+ * The test-mapping pipeline (004 T032; research R9) rides it too: the
16
+ * `test_mapping` method entry, the `MappingRow` wire record with its
17
+ * serializer and the `TestMappingResult` envelope, and the normative
18
+ * matcher tables with their classification lookups.
19
+ *
20
+ * The doc-coverage and cognitive-complexity pipelines (005 T025)
21
+ * ride it too: the `doc_coverage` method entry with the `SymbolRow`
22
+ * wire record, its `SymbolKind` vocabulary and serializer, the
23
+ * `cognitive_complexity` entry with the `CognitiveRow` record and
24
+ * its serializer, and the `DocCoverageResult` and
25
+ * `CognitiveComplexityResult` envelopes.
26
+ *
27
+ * An explicit, exhaustive barrel (convention pack AP-001) makes the
28
+ * vocabulary consumable package API instead of orphaned code (Zero-Waste
29
+ * Mandate): later analysis methods and downstream consumers import from
30
+ * the package root rather than reaching into module internals. Type-only
31
+ * names use `export type` clauses so the split between runtime values and
32
+ * compile-time types stays explicit.
33
+ */
34
+ export const VERSION = "0.2.0";
35
+ export { analyze, classifySignals, normalizePatterns, pathInScope, } from "./analysis.js";
36
+ export { cognitiveComplexity, serializeCognitiveRow, } from "./cognitive.js";
37
+ export { computeComplexity } from "./complexity.js";
38
+ export { parseCoverage } from "./coverage.js";
39
+ export { assembleFunctionRecords, detectEffects, } from "./detector.js";
40
+ export { docCoverage, serializeSymbolRow, } from "./doc-coverage.js";
41
+ export { derivePackage, serializeClassification, serializeEffect, serializeFunctionRecord, } from "./models.js";
42
+ export { ASSERT_FUNCTION_KINDS, classifyAssertCall, classifyExpectChain, EXPECT_MATCHER_KINDS, } from "./quality/matchers.js";
43
+ export { testMapping } from "./quality/pipeline.js";
44
+ export { serializeMappingRow } from "./quality/types.js";
45
+ export { classifyPairs } from "./signals/adapter.js";
46
+ export { callerSignal } from "./signals/caller.js";
47
+ export { interfaceSignal } from "./signals/interface.js";
48
+ export { docstringSignal } from "./signals/jsdoc.js";
49
+ export { namingSignal } from "./signals/naming.js";
50
+ export { CONTRACTUAL_PREFIXES, DIRECT_TAGS, INCIDENTAL_PREFIXES, INCIDENTAL_VERBS, INDIRECT_VERBS, ROUTING_TABLE, } from "./signals/routing.js";
51
+ export { serializeSignal } from "./signals/types.js";
52
+ export { visibilitySignal } from "./signals/visibility.js";
53
+ export { ALIAS_MAP, resolveSideEffectType, SIDE_EFFECT_TYPES, TIER_MAP, } from "./taxonomy.js";
54
+ //# sourceMappingURL=index.js.map