carrick 0.3.134 → 0.3.136
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/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/capture/api.d.ts +11 -2
- package/sidecar/dist/src/capture/index.js +89 -1
- package/sidecar/dist/src/capture/machine-paths.d.ts +44 -0
- package/sidecar/dist/src/capture/machine-paths.js +97 -0
- package/sidecar/dist/src/capture/node-builder.d.ts +2 -0
- package/sidecar/dist/src/capture/node-builder.js +1 -1
- package/sidecar/dist/src/index.js +17 -11
- package/sidecar/dist/src/library-claims.d.ts +37 -3
- package/sidecar/dist/src/library-claims.js +408 -65
- package/sidecar/dist/src/type-inferrer.d.ts +63 -19
- package/sidecar/dist/src/type-inferrer.js +192 -71
- package/sidecar/dist/src/types.d.ts +30 -3
- package/sidecar/dist/src/validators.d.ts +18 -0
- package/sidecar/dist/src/validators.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carrick",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.136",
|
|
4
4
|
"carrickCache": {
|
|
5
5
|
"cache_version": 22,
|
|
6
6
|
"intent_cache_version": 2
|
|
@@ -114,11 +114,11 @@
|
|
|
114
114
|
"zod": "^3.23.0"
|
|
115
115
|
},
|
|
116
116
|
"optionalDependencies": {
|
|
117
|
-
"@carrick-tools/cli-darwin-arm64": "0.3.
|
|
118
|
-
"@carrick-tools/cli-darwin-x64": "0.3.
|
|
119
|
-
"@carrick-tools/cli-linux-arm64": "0.3.
|
|
120
|
-
"@carrick-tools/cli-linux-x64": "0.3.
|
|
121
|
-
"@carrick-tools/cli-win32-x64": "0.3.
|
|
117
|
+
"@carrick-tools/cli-darwin-arm64": "0.3.136",
|
|
118
|
+
"@carrick-tools/cli-darwin-x64": "0.3.136",
|
|
119
|
+
"@carrick-tools/cli-linux-arm64": "0.3.136",
|
|
120
|
+
"@carrick-tools/cli-linux-x64": "0.3.136",
|
|
121
|
+
"@carrick-tools/cli-win32-x64": "0.3.136"
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
124
|
"@types/node": "^24.13.3"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carrick",
|
|
3
3
|
"description": "Claude Code plugin for Carrick, which indexes TypeScript codebases across service and repository boundaries. After each edit it adds the file's routes, calls, and cross-service type mismatches to the session, and it registers Carrick's language server. It pairs with the Carrick MCP server, which lets agents search functions by intent rather than name.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.136",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Carrick",
|
|
7
7
|
"email": "hello@carrick.tools"
|
|
@@ -236,10 +236,15 @@ export type SelfCheckOutcome = 'ok' | 'allowlisted_external' | 'decayed_internal
|
|
|
236
236
|
* into a function that builds the request body from it, and the body that
|
|
237
237
|
* function builds cannot be typed, so the argument is not the body and no
|
|
238
238
|
* contract is published (carrick#2628).
|
|
239
|
+
* - `reshaped_by_callback`: a consumer call's untyped result is handed
|
|
240
|
+
* unread to a callback in its chain (`.mapOk`, `.then`, `.andThen`, any
|
|
241
|
+
* name) that builds a new value from it, and nothing in the chain states
|
|
242
|
+
* the body, so the value the chain ends in is not the response the call
|
|
243
|
+
* receives and no contract is published (carrick#3004).
|
|
239
244
|
* - `not_recorded`: the position carries a top type and this layer has no
|
|
240
245
|
* cause for it.
|
|
241
246
|
*/
|
|
242
|
-
export type TypeProvenanceReason = 'declared' | 'unresolved_import' | 'budget_exhausted' | 'no_payload_evidence' | 'machinery_envelope' | 'coerced_input' | 'no_success_payload' | 'no_request_body' | 'projected_value_only' | 'serialised_body_unread' | 'body_built_by_callee' | 'result_member_missing' | 'not_recorded';
|
|
247
|
+
export type TypeProvenanceReason = 'declared' | 'unresolved_import' | 'budget_exhausted' | 'no_payload_evidence' | 'machinery_envelope' | 'coerced_input' | 'no_success_payload' | 'no_request_body' | 'projected_value_only' | 'serialised_body_unread' | 'body_built_by_callee' | 'reshaped_by_callback' | 'result_member_missing' | 'not_recorded';
|
|
243
248
|
/**
|
|
244
249
|
* One `any`/`unknown` finding inside a captured or inferred type, with its
|
|
245
250
|
* position and its cause. Sorted by `path` wherever a list is emitted, so the
|
|
@@ -382,8 +387,12 @@ export interface CaptureStubResult {
|
|
|
382
387
|
/** Number of emitted specifiers rewritten by the post-emit pass
|
|
383
388
|
* (tsconfig-paths mappings and absolute internal import types). */
|
|
384
389
|
specifier_rewrites: number;
|
|
385
|
-
/** True when the source repo had no node_modules at capture time
|
|
390
|
+
/** True when the source repo had no node_modules at capture time, or a
|
|
391
|
+
* dependency its package.json declares does not resolve from the service
|
|
392
|
+
* root (carrick#2999). */
|
|
386
393
|
bare_checkout: boolean;
|
|
394
|
+
/** The first few declared dependencies that did not resolve, sorted. */
|
|
395
|
+
unresolved_dependencies: string[];
|
|
387
396
|
ts_version: string;
|
|
388
397
|
errors: string[];
|
|
389
398
|
}
|
|
@@ -35,6 +35,7 @@ import { findAugmentationFiles } from './augmentations.js';
|
|
|
35
35
|
import { installedVersions, lockfileVersions } from './lockfile.js';
|
|
36
36
|
import { installedResolutionEdges, RESOLUTION_FILE } from './resolution-edges.js';
|
|
37
37
|
import { rewriteEmittedSpecifiers } from './paths-rewrite.js';
|
|
38
|
+
import { substituteMachinePathImports } from './machine-paths.js';
|
|
38
39
|
import { installedPackageSpecifier, typesPackageOf, withInstalledPackages } from './installed-package.js';
|
|
39
40
|
import { selfCheckStub } from './self-check.js';
|
|
40
41
|
import { collectSpecifiers, isRelative, packageNameOf } from './specifiers.js';
|
|
@@ -107,6 +108,7 @@ function fail(stubDir, packageName, errors) {
|
|
|
107
108
|
augmentation_files: [],
|
|
108
109
|
specifier_rewrites: 0,
|
|
109
110
|
bare_checkout: false,
|
|
111
|
+
unresolved_dependencies: [],
|
|
110
112
|
ts_version: ts.version,
|
|
111
113
|
errors,
|
|
112
114
|
};
|
|
@@ -448,6 +450,23 @@ export function captureStub(opts) {
|
|
|
448
450
|
entryDir,
|
|
449
451
|
});
|
|
450
452
|
const specifierRewrites = denoRewrites + placed.rewrites + rewritten.rewrites;
|
|
453
|
+
// What the rewrite could not map still names a machine path (carrick#2943).
|
|
454
|
+
const machinePaths = substituteMachinePathImports({
|
|
455
|
+
files: emittedFiles.map((rel) => path.join(typesDir, rel)),
|
|
456
|
+
surfaceAbsPath,
|
|
457
|
+
tree: stubGuard.narrow(typesDir),
|
|
458
|
+
labelRoot: opts.scanRoot ?? repoRoot,
|
|
459
|
+
});
|
|
460
|
+
if (machinePaths.size > 0) {
|
|
461
|
+
resolved = resolved.map((anchor) => {
|
|
462
|
+
const found = machinePaths.get(anchor.request.alias);
|
|
463
|
+
if (!found)
|
|
464
|
+
return anchor;
|
|
465
|
+
const paths = [...new Set([...(anchor.unresolved?.paths ?? []), ...found.paths])];
|
|
466
|
+
const specifiers = [...new Set([...found.modules, ...(anchor.unresolved?.specifiers ?? [])])];
|
|
467
|
+
return { ...anchor, unresolved: { paths, specifiers } };
|
|
468
|
+
});
|
|
469
|
+
}
|
|
451
470
|
// ---- Pin external deps: installed node_modules first, lockfile fallback ----
|
|
452
471
|
// Externals are collected AFTER the rewrite pass: a rewritten paths
|
|
453
472
|
// specifier is internal, not a dependency.
|
|
@@ -500,7 +519,20 @@ export function captureStub(opts) {
|
|
|
500
519
|
console.error(`[sidecar] capture ${packageName}: ${edgeCount} dependency edge(s) recorded from the installed tree, ` +
|
|
501
520
|
`${resolution.unrecorded} left to the registry`);
|
|
502
521
|
const dependencyRoot = deno?.config.workspaceRoot ?? repoRoot;
|
|
503
|
-
const
|
|
522
|
+
const nodeModulesPresent = fs.existsSync(path.join(dependencyRoot, 'node_modules'));
|
|
523
|
+
const declared = deno || !nodeModulesPresent
|
|
524
|
+
? { unresolved: [], runtimeDeclared: 0, runtimeResolved: 0 }
|
|
525
|
+
: declaredDependencyResolution(dependencyRoot);
|
|
526
|
+
const unresolvedDependencies = declared.unresolved;
|
|
527
|
+
// Bare: no node_modules, or every declared runtime dependency dangles (a
|
|
528
|
+
// missing pnpm store). One missing package, or missing devDependencies,
|
|
529
|
+
// leaves the installed ones usable (carrick#2999).
|
|
530
|
+
const bareCheckout = !deno &&
|
|
531
|
+
(!nodeModulesPresent || (declared.runtimeDeclared > 0 && declared.runtimeResolved === 0));
|
|
532
|
+
if (unresolvedDependencies.length > 0) {
|
|
533
|
+
console.error(`[sidecar] capture ${packageName}: declared dependencies do not resolve` +
|
|
534
|
+
`${bareCheckout ? ' (bare checkout)' : ''}: ${unresolvedDependencies.join(', ')}`);
|
|
535
|
+
}
|
|
504
536
|
stubGuard.writeFile(path.join(stubDir, 'package.json'), JSON.stringify({
|
|
505
537
|
name: packageName,
|
|
506
538
|
version: '0.0.0-carrick',
|
|
@@ -550,10 +582,66 @@ export function captureStub(opts) {
|
|
|
550
582
|
augmentation_files: augmentationFiles.sort(),
|
|
551
583
|
specifier_rewrites: specifierRewrites,
|
|
552
584
|
bare_checkout: bareCheckout,
|
|
585
|
+
unresolved_dependencies: unresolvedDependencies,
|
|
553
586
|
ts_version: ts.version,
|
|
554
587
|
errors,
|
|
555
588
|
};
|
|
556
589
|
}
|
|
590
|
+
/** How many unresolved packages a capture result names. */
|
|
591
|
+
const UNRESOLVED_DEPENDENCIES_NAMED = 5;
|
|
592
|
+
/**
|
|
593
|
+
* How `root/package.json` dependencies resolve from `root`: no
|
|
594
|
+
* `node_modules/<name>` in `root` or any parent directory means unresolved.
|
|
595
|
+
* `existsSync` follows links, so a pnpm link into a missing store reads as
|
|
596
|
+
* unresolved (carrick#2999). `unresolved` is the first few names across
|
|
597
|
+
* dependencies and devDependencies, sorted; the runtime counts cover
|
|
598
|
+
* `dependencies` only. Declared names only, one stat per ancestor.
|
|
599
|
+
*/
|
|
600
|
+
function declaredDependencyResolution(root) {
|
|
601
|
+
const none = { unresolved: [], runtimeDeclared: 0, runtimeResolved: 0 };
|
|
602
|
+
let manifest;
|
|
603
|
+
try {
|
|
604
|
+
manifest = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
605
|
+
}
|
|
606
|
+
catch {
|
|
607
|
+
return none;
|
|
608
|
+
}
|
|
609
|
+
if (manifest === null || typeof manifest !== 'object')
|
|
610
|
+
return none;
|
|
611
|
+
const names = (field) => {
|
|
612
|
+
const group = manifest[field];
|
|
613
|
+
return group !== null && typeof group === 'object' ? Object.keys(group) : [];
|
|
614
|
+
};
|
|
615
|
+
const resolves = (name) => {
|
|
616
|
+
let dir = path.resolve(root);
|
|
617
|
+
for (;;) {
|
|
618
|
+
if (fs.existsSync(path.join(dir, 'node_modules', name)))
|
|
619
|
+
return true;
|
|
620
|
+
const parent = path.dirname(dir);
|
|
621
|
+
if (parent === dir)
|
|
622
|
+
return false;
|
|
623
|
+
dir = parent;
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
const runtime = new Set(names('dependencies'));
|
|
627
|
+
const all = new Set([...runtime, ...names('devDependencies')]);
|
|
628
|
+
let runtimeResolved = 0;
|
|
629
|
+
const unresolved = [];
|
|
630
|
+
for (const name of [...all].sort()) {
|
|
631
|
+
if (resolves(name)) {
|
|
632
|
+
if (runtime.has(name))
|
|
633
|
+
runtimeResolved++;
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
unresolved.push(name);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return {
|
|
640
|
+
unresolved: unresolved.slice(0, UNRESOLVED_DEPENDENCIES_NAMED),
|
|
641
|
+
runtimeDeclared: runtime.size,
|
|
642
|
+
runtimeResolved,
|
|
643
|
+
};
|
|
644
|
+
}
|
|
557
645
|
/**
|
|
558
646
|
* Phase B: build the program of the final entry and emit its declarations.
|
|
559
647
|
*
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* No stub names a module by a machine path (carrick#2943).
|
|
3
|
+
*
|
|
4
|
+
* The specifier rewrite maps an absolute specifier onto a file of the stub's
|
|
5
|
+
* tree or onto an installed package. What it cannot map stays as printed: a
|
|
6
|
+
* type that a printer could name only by where its module sits on this
|
|
7
|
+
* machine, such as a workspace sibling's source reached through a
|
|
8
|
+
* `node_modules` link, which the declaration emit does not carry. That path
|
|
9
|
+
* resolves on the machine that ran the capture, to a source file outside the
|
|
10
|
+
* stub, and nowhere else: the upload rewrites it to `<checkout>/...`, so the
|
|
11
|
+
* stored stub and a fresh one disagree about the same alias.
|
|
12
|
+
*
|
|
13
|
+
* Each such reference becomes `unknown` at its own position. In the surface
|
|
14
|
+
* the position is reported per alias, so the self-check labels the finding
|
|
15
|
+
* there as a reference that did not resolve rather than as declared; the rest
|
|
16
|
+
* of the alias's type survives. Any other tree file gets the dangling-import
|
|
17
|
+
* repair (carrick#1397), which writes `unknown` where the import's names were
|
|
18
|
+
* used. The stub then reads the same on every machine.
|
|
19
|
+
*
|
|
20
|
+
* Seam: node builtins + `typescript`, like the rest of this directory.
|
|
21
|
+
*/
|
|
22
|
+
import type { WriteGuard } from './guarded-fs.js';
|
|
23
|
+
/** A specifier that names a module by where it sits on one machine. */
|
|
24
|
+
export declare function isMachinePath(specifier: string): boolean;
|
|
25
|
+
/** What the surface substitution replaced in one alias. */
|
|
26
|
+
export interface MachinePathPositions {
|
|
27
|
+
/** Member paths now `unknown`, in the deep walk's notation (`''` = root). */
|
|
28
|
+
paths: string[];
|
|
29
|
+
/** The modules they named, relative to `labelRoot` (never absolute). */
|
|
30
|
+
modules: string[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Replace every machine-path import in the stub's tree with `unknown`.
|
|
34
|
+
* `files` are absolute tree paths; `surfaceAbsPath` is one of them. Returns
|
|
35
|
+
* the positions replaced in the surface, by alias.
|
|
36
|
+
*/
|
|
37
|
+
export declare function substituteMachinePathImports(args: {
|
|
38
|
+
files: readonly string[];
|
|
39
|
+
surfaceAbsPath: string;
|
|
40
|
+
/** A guard over the stub's types tree. */
|
|
41
|
+
tree: WriteGuard;
|
|
42
|
+
/** The root a module is named from in a label (the scanned repo's). */
|
|
43
|
+
labelRoot: string;
|
|
44
|
+
}): Map<string, MachinePathPositions>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* No stub names a module by a machine path (carrick#2943).
|
|
3
|
+
*
|
|
4
|
+
* The specifier rewrite maps an absolute specifier onto a file of the stub's
|
|
5
|
+
* tree or onto an installed package. What it cannot map stays as printed: a
|
|
6
|
+
* type that a printer could name only by where its module sits on this
|
|
7
|
+
* machine, such as a workspace sibling's source reached through a
|
|
8
|
+
* `node_modules` link, which the declaration emit does not carry. That path
|
|
9
|
+
* resolves on the machine that ran the capture, to a source file outside the
|
|
10
|
+
* stub, and nowhere else: the upload rewrites it to `<checkout>/...`, so the
|
|
11
|
+
* stored stub and a fresh one disagree about the same alias.
|
|
12
|
+
*
|
|
13
|
+
* Each such reference becomes `unknown` at its own position. In the surface
|
|
14
|
+
* the position is reported per alias, so the self-check labels the finding
|
|
15
|
+
* there as a reference that did not resolve rather than as declared; the rest
|
|
16
|
+
* of the alias's type survives. Any other tree file gets the dangling-import
|
|
17
|
+
* repair (carrick#1397), which writes `unknown` where the import's names were
|
|
18
|
+
* used. The stub then reads the same on every machine.
|
|
19
|
+
*
|
|
20
|
+
* Seam: node builtins + `typescript`, like the rest of this directory.
|
|
21
|
+
*/
|
|
22
|
+
import ts from 'typescript';
|
|
23
|
+
import * as fs from 'node:fs';
|
|
24
|
+
import * as path from 'node:path';
|
|
25
|
+
import { childPath } from './node-builder.js';
|
|
26
|
+
import { repairDanglingImports } from './repair-dangling.js';
|
|
27
|
+
import { collectSpecifiers } from './specifiers.js';
|
|
28
|
+
/** A specifier that names a module by where it sits on one machine. */
|
|
29
|
+
export function isMachinePath(specifier) {
|
|
30
|
+
return path.posix.isAbsolute(specifier) || /^[A-Za-z]:[\\/]/.test(specifier) || specifier.startsWith('\\\\');
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Replace every machine-path import in the stub's tree with `unknown`.
|
|
34
|
+
* `files` are absolute tree paths; `surfaceAbsPath` is one of them. Returns
|
|
35
|
+
* the positions replaced in the surface, by alias.
|
|
36
|
+
*/
|
|
37
|
+
export function substituteMachinePathImports(args) {
|
|
38
|
+
const failing = new Map();
|
|
39
|
+
for (const file of args.files) {
|
|
40
|
+
if (path.resolve(file) === path.resolve(args.surfaceAbsPath))
|
|
41
|
+
continue;
|
|
42
|
+
const machine = [...collectSpecifiers(fs.readFileSync(file, 'utf8'))].filter(isMachinePath);
|
|
43
|
+
if (machine.length > 0)
|
|
44
|
+
failing.set(file, new Set(machine));
|
|
45
|
+
}
|
|
46
|
+
if (failing.size > 0)
|
|
47
|
+
repairDanglingImports(failing, args.tree);
|
|
48
|
+
return substituteInSurface(args.surfaceAbsPath, args.tree, args.labelRoot);
|
|
49
|
+
}
|
|
50
|
+
function substituteInSurface(surfaceAbsPath, tree, labelRoot) {
|
|
51
|
+
const byAlias = new Map();
|
|
52
|
+
const text = fs.readFileSync(surfaceAbsPath, 'utf8');
|
|
53
|
+
if (!/import\s*\(/.test(text))
|
|
54
|
+
return byAlias;
|
|
55
|
+
const source = ts.createSourceFile(surfaceAbsPath, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
56
|
+
const edits = [];
|
|
57
|
+
for (const statement of source.statements) {
|
|
58
|
+
if (!ts.isTypeAliasDeclaration(statement))
|
|
59
|
+
continue;
|
|
60
|
+
const found = { paths: [], modules: [] };
|
|
61
|
+
const visit = (node, at) => {
|
|
62
|
+
const specifier = importTypeSpecifier(node);
|
|
63
|
+
if (specifier !== undefined && isMachinePath(specifier)) {
|
|
64
|
+
edits.push({ start: node.getStart(source), end: node.getEnd() });
|
|
65
|
+
if (!found.paths.includes(at))
|
|
66
|
+
found.paths.push(at);
|
|
67
|
+
const module = moduleLabel(specifier, labelRoot);
|
|
68
|
+
if (!found.modules.includes(module))
|
|
69
|
+
found.modules.push(module);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
node.forEachChild((child) => visit(child, childPath(node, child, at)));
|
|
73
|
+
};
|
|
74
|
+
visit(statement.type, '');
|
|
75
|
+
if (found.paths.length > 0)
|
|
76
|
+
byAlias.set(statement.name.text, found);
|
|
77
|
+
}
|
|
78
|
+
if (edits.length === 0)
|
|
79
|
+
return byAlias;
|
|
80
|
+
edits.sort((a, b) => b.start - a.start);
|
|
81
|
+
let out = text;
|
|
82
|
+
for (const edit of edits)
|
|
83
|
+
out = `${out.slice(0, edit.start)}unknown${out.slice(edit.end)}`;
|
|
84
|
+
tree.writeFile(surfaceAbsPath, out);
|
|
85
|
+
return byAlias;
|
|
86
|
+
}
|
|
87
|
+
/** The string an `import("...")` type names, when `node` is one. */
|
|
88
|
+
function importTypeSpecifier(node) {
|
|
89
|
+
if (!ts.isImportTypeNode(node) || !ts.isLiteralTypeNode(node.argument))
|
|
90
|
+
return undefined;
|
|
91
|
+
const literal = node.argument.literal;
|
|
92
|
+
return ts.isStringLiteral(literal) ? literal.text : undefined;
|
|
93
|
+
}
|
|
94
|
+
/** `specifier` relative to `root`, with forward slashes. */
|
|
95
|
+
function moduleLabel(specifier, root) {
|
|
96
|
+
return path.relative(path.resolve(root), path.resolve(specifier)).split(path.sep).join('/');
|
|
97
|
+
}
|
|
@@ -67,6 +67,8 @@ export declare function substituteUndeclaredNames(node: ts.TypeNode, program: ts
|
|
|
67
67
|
node: ts.TypeNode;
|
|
68
68
|
substitutions: UndeclaredSubstitution[];
|
|
69
69
|
};
|
|
70
|
+
/** The deep walk's path for `child` inside `parent`, extending `path`. */
|
|
71
|
+
export declare function childPath(parent: ts.Node, child: ts.Node, path: string): string;
|
|
70
72
|
/**
|
|
71
73
|
* Bare names in a printed type node that nothing in the producer's program
|
|
72
74
|
* declares (carrick#1165).
|
|
@@ -174,7 +174,7 @@ export function substituteUndeclaredNames(node, program, destination) {
|
|
|
174
174
|
return { node: rewritten, substitutions };
|
|
175
175
|
}
|
|
176
176
|
/** The deep walk's path for `child` inside `parent`, extending `path`. */
|
|
177
|
-
function childPath(parent, child, path) {
|
|
177
|
+
export function childPath(parent, child, path) {
|
|
178
178
|
if (ts.isPropertySignature(parent) && parent.type === child) {
|
|
179
179
|
const name = ts.isIdentifier(parent.name) || ts.isStringLiteral(parent.name)
|
|
180
180
|
? parent.name.text
|
|
@@ -61,16 +61,16 @@ function initializedLoader() {
|
|
|
61
61
|
return projectLoader;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* carrick#
|
|
65
|
-
* `
|
|
66
|
-
* scanner's binary:
|
|
67
|
-
* not a whole number
|
|
64
|
+
* carrick#2629: the most readings one batch's unwidened reading may make,
|
|
65
|
+
* when `CARRICK_UNWIDENED_READINGS_CAP` sets it. A switch for tests that
|
|
66
|
+
* drive the scanner's binary: 0 forces every reading past the cap, on any
|
|
67
|
+
* machine. Unset or not a whole number, the inferrer's default stands.
|
|
68
68
|
*/
|
|
69
|
-
function
|
|
70
|
-
const value = process.env.
|
|
69
|
+
function unwidenedLimitsFromEnv() {
|
|
70
|
+
const value = process.env.CARRICK_UNWIDENED_READINGS_CAP;
|
|
71
71
|
if (value === undefined || !/^\d+$/.test(value.trim()))
|
|
72
72
|
return undefined;
|
|
73
|
-
return Number(value.trim());
|
|
73
|
+
return { readings: Number(value.trim()) };
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* Get the project-backed components, building the project if this is the
|
|
@@ -94,7 +94,7 @@ function projectComponents(key = '') {
|
|
|
94
94
|
project,
|
|
95
95
|
repoRoot,
|
|
96
96
|
packageOf: (filePath) => loader.packageOf(filePath),
|
|
97
|
-
|
|
97
|
+
unwidenedLimits: unwidenedLimitsFromEnv(),
|
|
98
98
|
});
|
|
99
99
|
built = {
|
|
100
100
|
typeBundler: new TypeBundler({ project, repoRoot }),
|
|
@@ -351,13 +351,19 @@ function handleInfer(request) {
|
|
|
351
351
|
}
|
|
352
352
|
// One count for the request, whichever programs its items span.
|
|
353
353
|
let done = 0;
|
|
354
|
-
|
|
354
|
+
let readingSteps = 0;
|
|
355
|
+
const report = atMostEvery(PROGRESS_INTERVAL_MS, () => writeProgress(request.request_id, 'infer', readingSteps === 0
|
|
356
|
+
? `${done} of ${request.requests.length}`
|
|
357
|
+
: `${done} of ${request.requests.length}, unwidened reading step ${readingSteps}`));
|
|
355
358
|
const results = [...groups].map(([key, items]) => {
|
|
356
359
|
const built = projectComponents(key);
|
|
357
360
|
return built.typeInferrer.infer(items, request.extraction_config, () => {
|
|
358
361
|
done += 1;
|
|
359
362
|
report();
|
|
360
|
-
}, request.model_symbols, labelledMembersFor(built, key, items, request.server_claims))
|
|
363
|
+
}, request.model_symbols, labelledMembersFor(built, key, items, request.server_claims), () => {
|
|
364
|
+
readingSteps += 1;
|
|
365
|
+
report();
|
|
366
|
+
});
|
|
361
367
|
});
|
|
362
368
|
const result = results.length === 1
|
|
363
369
|
? results[0]
|
|
@@ -637,7 +643,7 @@ function handleListLibrarySurface(request) {
|
|
|
637
643
|
const { claimsVerifier } = projectComponents();
|
|
638
644
|
const fromDir = path.resolve(projectLoader.getRepoRoot(), request.from_dir);
|
|
639
645
|
log(`Listing the declared surface of ${request.packages.length} specifier(s) from ${fromDir}`);
|
|
640
|
-
const { surfaces, surface_sha256 } = claimsVerifier.listSurface(fromDir, request.packages, request.max_entries ?? SURFACE_MAX_ENTRIES, request.exports ?? {});
|
|
646
|
+
const { surfaces, surface_sha256 } = claimsVerifier.listSurface(fromDir, request.packages, request.max_entries ?? SURFACE_MAX_ENTRIES, request.exports ?? {}, { handlers: request.handlers, resultCandidates: request.result_candidates, maxHandlerMembers: request.max_handler_members });
|
|
641
647
|
return { request_id: request.request_id, status: 'success', surfaces, surface_sha256 };
|
|
642
648
|
}
|
|
643
649
|
catch (err) {
|
|
@@ -50,6 +50,11 @@ type Outcome = {
|
|
|
50
50
|
*/
|
|
51
51
|
members?: readonly ts.Declaration[];
|
|
52
52
|
bodyMembers?: readonly ts.Declaration[];
|
|
53
|
+
/**
|
|
54
|
+
* Stamped: why a receive op's `request` was dropped while the op
|
|
55
|
+
* itself verified (carrick#2968). Only `request_member_missing`.
|
|
56
|
+
*/
|
|
57
|
+
requestDropped?: string;
|
|
53
58
|
} | {
|
|
54
59
|
verdict: 'failed' | 'unchecked';
|
|
55
60
|
reason: string;
|
|
@@ -86,6 +91,15 @@ export interface ModuleGraph {
|
|
|
86
91
|
/** How the program resolves `name` from `from`; `undefined` where there is no graph, and Node resolution answers. */
|
|
87
92
|
resolveModule(name: string, from: string, options: ts.CompilerOptions): ts.ResolvedModuleFull | undefined;
|
|
88
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Test instrumentation, never on the wire: how many times the lister built a
|
|
96
|
+
* handler parameter's members and printed a type, since the caller last
|
|
97
|
+
* reset them (carrick#2977).
|
|
98
|
+
*/
|
|
99
|
+
export declare const surfaceReadCounts: {
|
|
100
|
+
handlerMemberBuilds: number;
|
|
101
|
+
typePrints: number;
|
|
102
|
+
};
|
|
89
103
|
export declare class LibraryClaimsVerifier {
|
|
90
104
|
private readonly project;
|
|
91
105
|
private readonly graph;
|
|
@@ -124,9 +138,20 @@ export declare class LibraryClaimsVerifier {
|
|
|
124
138
|
* (`receiverExpression` on the export's `importLine`, read through
|
|
125
139
|
* `DeclarationReader.returnOf`) and lists from it.
|
|
126
140
|
*
|
|
141
|
+
* A member of an `instance:` receiver whose call returns another object
|
|
142
|
+
* that routes are registered on lists that object as its `scope_receiver`
|
|
143
|
+
* (carrick#2774), built as the verifier builds a scope step, under a cap of
|
|
144
|
+
* its own and left out of the hash.
|
|
145
|
+
*
|
|
146
|
+
* Each member's handler-parameter members (carrick#2674 S3) are listed
|
|
147
|
+
* only when `options.handlers` is set, and each signature's result
|
|
148
|
+
* candidates (carrick#2817) only when `options.resultCandidates` is
|
|
149
|
+
* (carrick#2966): on a large package either costs more than the rest of the
|
|
150
|
+
* listing.
|
|
151
|
+
*
|
|
127
152
|
* `surface_sha256` is the full-surface hash (see `fullSurfaceSha256`).
|
|
128
153
|
*/
|
|
129
|
-
listSurface(fromDir: string, packages: string[], maxEntries: number, only?: Readonly<Record<string, string[]
|
|
154
|
+
listSurface(fromDir: string, packages: string[], maxEntries: number, only?: Readonly<Record<string, string[]>>, options?: SurfaceOptions): ListedSurface;
|
|
130
155
|
/** `read` over a probe file holding `lines` in `fromDir`, removed again afterwards. */
|
|
131
156
|
private readProbe;
|
|
132
157
|
}
|
|
@@ -140,8 +165,8 @@ export interface ListedSurface {
|
|
|
140
165
|
* array of `[package, exports]` for every surface that listed at least one
|
|
141
166
|
* export, sorted by `package` (code unit order). A specifier that lists
|
|
142
167
|
* nothing (unresolved, local, no value exports) is left out, so asking for a
|
|
143
|
-
* subpath a version does not have changes nothing. Handler members
|
|
144
|
-
* hashed. Type text already names
|
|
168
|
+
* subpath a version does not have changes nothing. Handler members, result
|
|
169
|
+
* candidates and scope receivers are not hashed. Type text already names
|
|
145
170
|
* the request's directory as `<root>`.
|
|
146
171
|
*/
|
|
147
172
|
export declare function fullSurfaceSha256(surfaces: readonly LibrarySurface[]): string;
|
|
@@ -177,4 +202,13 @@ export interface LabelledMembers {
|
|
|
177
202
|
/** How each label read came out (`verified`, or the reason it was not), for the log. */
|
|
178
203
|
outcomes?: Readonly<Record<string, number>>;
|
|
179
204
|
}
|
|
205
|
+
/** What a surface listing adds beyond the hashed surface, each only when asked (carrick#2966). */
|
|
206
|
+
export interface SurfaceOptions {
|
|
207
|
+
/** Each member's `handlers` (carrick#2674 S3). */
|
|
208
|
+
handlers?: boolean;
|
|
209
|
+
/** Each signature's `result_candidates` (carrick#2817). */
|
|
210
|
+
resultCandidates?: boolean;
|
|
211
|
+
/** Handler-parameter members the whole call may list (default `HANDLER_LISTING_BUDGET`, carrick#3016). */
|
|
212
|
+
maxHandlerMembers?: number;
|
|
213
|
+
}
|
|
180
214
|
export {};
|