carrick 0.3.154 → 0.3.155
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/bin/carrick.mjs +26 -4
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/contract.d.ts +10 -0
- package/dist/contract.js.map +1 -1
- package/dist/facts/diff.d.ts +27 -0
- package/dist/facts/diff.js +134 -0
- package/dist/facts/diff.js.map +1 -0
- package/dist/facts/enabled.d.ts +2 -0
- package/dist/facts/enabled.js +9 -0
- package/dist/facts/enabled.js.map +1 -0
- package/dist/facts/fetch.d.ts +48 -0
- package/dist/facts/fetch.js +235 -0
- package/dist/facts/fetch.js.map +1 -0
- package/dist/facts/files.d.ts +21 -0
- package/dist/facts/files.js +58 -0
- package/dist/facts/files.js.map +1 -0
- package/dist/facts/lines.d.ts +70 -0
- package/dist/facts/lines.js +335 -0
- package/dist/facts/lines.js.map +1 -0
- package/dist/facts/match.d.ts +91 -0
- package/dist/facts/match.js +1122 -0
- package/dist/facts/match.js.map +1 -0
- package/dist/facts/peers.d.ts +48 -0
- package/dist/facts/peers.js +143 -0
- package/dist/facts/peers.js.map +1 -0
- package/dist/facts/refresh-run.d.ts +2 -0
- package/dist/facts/refresh-run.js +18 -0
- package/dist/facts/refresh-run.js.map +1 -0
- package/dist/facts/rules/packages.d.ts +16 -0
- package/dist/facts/rules/packages.js +157 -0
- package/dist/facts/rules/packages.js.map +1 -0
- package/dist/facts/rules/same-name.d.ts +28 -0
- package/dist/facts/rules/same-name.js +131 -0
- package/dist/facts/rules/same-name.js.map +1 -0
- package/dist/facts/store.d.ts +119 -0
- package/dist/facts/store.js +341 -0
- package/dist/facts/store.js.map +1 -0
- package/dist/git-remote.d.ts +6 -0
- package/dist/git-remote.js +37 -0
- package/dist/git-remote.js.map +1 -0
- package/dist/hook/apply-patch.d.ts +23 -0
- package/dist/hook/apply-patch.js +92 -0
- package/dist/hook/apply-patch.js.map +1 -1
- package/dist/hook/bash-targets.d.ts +8 -0
- package/dist/hook/bash-targets.js +23 -11
- package/dist/hook/bash-targets.js.map +1 -1
- package/dist/hook/edit-flow.d.ts +29 -2
- package/dist/hook/edit-flow.js +80 -29
- package/dist/hook/edit-flow.js.map +1 -1
- package/dist/hook/late.d.ts +29 -0
- package/dist/hook/late.js +121 -26
- package/dist/hook/late.js.map +1 -1
- package/dist/hook/post-bash.js +45 -22
- package/dist/hook/post-bash.js.map +1 -1
- package/dist/hook/post-edit.d.ts +16 -1
- package/dist/hook/post-edit.js +177 -13
- package/dist/hook/post-edit.js.map +1 -1
- package/dist/hook/post-read.js +8 -12
- package/dist/hook/post-read.js.map +1 -1
- package/dist/hook/post-search.d.ts +2 -0
- package/dist/hook/post-search.js +25 -0
- package/dist/hook/post-search.js.map +1 -0
- package/dist/hook/probe.d.ts +18 -3
- package/dist/hook/probe.js +30 -6
- package/dist/hook/probe.js.map +1 -1
- package/dist/hook/rechecks.d.ts +66 -11
- package/dist/hook/rechecks.js +115 -29
- package/dist/hook/rechecks.js.map +1 -1
- package/dist/hook/refresh.d.ts +9 -0
- package/dist/hook/refresh.js +10 -0
- package/dist/hook/refresh.js.map +1 -1
- package/dist/hook/reuse.d.ts +16 -2
- package/dist/hook/reuse.js +49 -6
- package/dist/hook/reuse.js.map +1 -1
- package/dist/hook/session-key.d.ts +12 -0
- package/dist/hook/session-key.js +30 -0
- package/dist/hook/session-key.js.map +1 -0
- package/dist/hook/session-start.js +14 -7
- package/dist/hook/session-start.js.map +1 -1
- package/dist/hook/stop-wait.d.ts +2 -9
- package/dist/hook/stop-wait.js +96 -113
- package/dist/hook/stop-wait.js.map +1 -1
- package/dist/hook/stop.js +13 -8
- package/dist/hook/stop.js.map +1 -1
- package/dist/hook/subagent-stop.d.ts +2 -0
- package/dist/hook/subagent-stop.js +45 -0
- package/dist/hook/subagent-stop.js.map +1 -0
- package/dist/hook/timings.d.ts +72 -0
- package/dist/hook/timings.js +175 -0
- package/dist/hook/timings.js.map +1 -0
- package/dist/hook/user-prompt.js +17 -13
- package/dist/hook/user-prompt.js.map +1 -1
- package/dist/hook/worktree.d.ts +11 -0
- package/dist/hook/worktree.js +27 -1
- package/dist/hook/worktree.js.map +1 -1
- package/dist/init/repo-copies.d.ts +6 -0
- package/dist/init/repo-copies.js +7 -3
- package/dist/init/repo-copies.js.map +1 -1
- package/dist/init/repos.d.ts +2 -2
- package/dist/init/repos.js +1 -34
- package/dist/init/repos.js.map +1 -1
- package/dist/init/settings.js +25 -13
- package/dist/init/settings.js.map +1 -1
- package/dist/render.d.ts +8 -33
- package/dist/render.js +31 -122
- package/dist/render.js.map +1 -1
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/hooks/hooks.json +44 -3
- package/sidecar/dist/src/capture/anchors.d.ts +12 -1
- package/sidecar/dist/src/capture/anchors.js +28 -47
- package/sidecar/dist/src/capture/api.d.ts +41 -1
- package/sidecar/dist/src/capture/augmentations.d.ts +2 -0
- package/sidecar/dist/src/capture/augmentations.js +1 -1
- package/sidecar/dist/src/capture/check-classify.d.ts +12 -1
- package/sidecar/dist/src/capture/check-classify.js +43 -0
- package/sidecar/dist/src/capture/check-deep.d.ts +44 -1
- package/sidecar/dist/src/capture/check-deep.js +161 -2
- package/sidecar/dist/src/capture/check.js +23 -2
- package/sidecar/dist/src/capture/checkout.d.ts +9 -3
- package/sidecar/dist/src/capture/checkout.js +12 -5
- package/sidecar/dist/src/capture/deep-walk.d.ts +25 -0
- package/sidecar/dist/src/capture/deep-walk.js +41 -0
- package/sidecar/dist/src/capture/deno-project.d.ts +22 -0
- package/sidecar/dist/src/capture/deno-project.js +48 -1
- package/sidecar/dist/src/capture/index.d.ts +2 -1
- package/sidecar/dist/src/capture/index.js +14 -4
- package/sidecar/dist/src/capture/machinery.d.ts +8 -53
- package/sidecar/dist/src/capture/machinery.js +10 -157
- package/sidecar/dist/src/capture/self-check.d.ts +7 -0
- package/sidecar/dist/src/capture/self-check.js +44 -1
- package/sidecar/dist/src/capture/site-node.d.ts +166 -0
- package/sidecar/dist/src/capture/site-node.js +570 -0
- package/sidecar/dist/src/capture/tool-env.d.ts +12 -0
- package/sidecar/dist/src/capture/tool-env.js +26 -0
- package/sidecar/dist/src/library-claims.js +211 -20
- package/sidecar/dist/src/node-index.d.ts +2 -0
- package/sidecar/dist/src/node-index.js +5 -1
- package/sidecar/dist/src/position-rows.d.ts +39 -4
- package/sidecar/dist/src/position-rows.js +233 -16
- package/sidecar/dist/src/project-loader.js +13 -5
- package/sidecar/dist/src/retype.d.ts +13 -0
- package/sidecar/dist/src/retype.js +126 -0
- package/sidecar/dist/src/type-inferrer.d.ts +33 -145
- package/sidecar/dist/src/type-inferrer.js +68 -524
- package/sidecar/dist/src/types.d.ts +55 -2
- package/sidecar/dist/src/validators.d.ts +800 -142
- package/sidecar/dist/src/validators.js +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carrick",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.155",
|
|
4
4
|
"carrickCache": {
|
|
5
5
|
"cache_version": 22,
|
|
6
6
|
"intent_cache_version": 2
|
|
@@ -115,11 +115,11 @@
|
|
|
115
115
|
"zod": "^3.23.0"
|
|
116
116
|
},
|
|
117
117
|
"optionalDependencies": {
|
|
118
|
-
"@carrick-tools/cli-darwin-arm64": "0.3.
|
|
119
|
-
"@carrick-tools/cli-darwin-x64": "0.3.
|
|
120
|
-
"@carrick-tools/cli-linux-arm64": "0.3.
|
|
121
|
-
"@carrick-tools/cli-linux-x64": "0.3.
|
|
122
|
-
"@carrick-tools/cli-win32-x64": "0.3.
|
|
118
|
+
"@carrick-tools/cli-darwin-arm64": "0.3.155",
|
|
119
|
+
"@carrick-tools/cli-darwin-x64": "0.3.155",
|
|
120
|
+
"@carrick-tools/cli-linux-arm64": "0.3.155",
|
|
121
|
+
"@carrick-tools/cli-linux-x64": "0.3.155",
|
|
122
|
+
"@carrick-tools/cli-win32-x64": "0.3.155"
|
|
123
123
|
},
|
|
124
124
|
"devDependencies": {
|
|
125
125
|
"@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.155",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Carrick",
|
|
7
7
|
"email": "hello@carrick.tools"
|
package/plugin/hooks/hooks.json
CHANGED
|
@@ -20,6 +20,26 @@
|
|
|
20
20
|
"timeout": 5
|
|
21
21
|
}
|
|
22
22
|
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"matcher": "Bash",
|
|
26
|
+
"hooks": [
|
|
27
|
+
{
|
|
28
|
+
"type": "command",
|
|
29
|
+
"command": "carrick hook post-bash",
|
|
30
|
+
"timeout": 15
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"matcher": "Grep|Glob|mcp__.*",
|
|
36
|
+
"hooks": [
|
|
37
|
+
{
|
|
38
|
+
"type": "command",
|
|
39
|
+
"command": "carrick hook post-search",
|
|
40
|
+
"timeout": 5
|
|
41
|
+
}
|
|
42
|
+
]
|
|
23
43
|
}
|
|
24
44
|
],
|
|
25
45
|
"SessionStart": [
|
|
@@ -38,9 +58,30 @@
|
|
|
38
58
|
"hooks": [
|
|
39
59
|
{
|
|
40
60
|
"type": "command",
|
|
41
|
-
"command": "carrick hook stop
|
|
42
|
-
"timeout":
|
|
43
|
-
|
|
61
|
+
"command": "carrick hook stop",
|
|
62
|
+
"timeout": 10
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"SubagentStop": [
|
|
68
|
+
{
|
|
69
|
+
"hooks": [
|
|
70
|
+
{
|
|
71
|
+
"type": "command",
|
|
72
|
+
"command": "carrick hook subagent-stop",
|
|
73
|
+
"timeout": 5
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"UserPromptSubmit": [
|
|
79
|
+
{
|
|
80
|
+
"hooks": [
|
|
81
|
+
{
|
|
82
|
+
"type": "command",
|
|
83
|
+
"command": "carrick hook user-prompt",
|
|
84
|
+
"timeout": 5
|
|
44
85
|
}
|
|
45
86
|
]
|
|
46
87
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* or a recorded demotion -- never a silently wrong line.
|
|
6
6
|
*/
|
|
7
7
|
import ts from 'typescript';
|
|
8
|
-
import type { CaptureAnchorRequest, InferAnchorRequest } from './api.js';
|
|
8
|
+
import type { CaptureAnchorRequest, InferAnchorRequest, TypeProvenanceReason } from './api.js';
|
|
9
9
|
import type { UnresolvedAtAnchor } from './deep-walk.js';
|
|
10
10
|
export interface ResolvedAnchor {
|
|
11
11
|
request: CaptureAnchorRequest;
|
|
@@ -55,6 +55,17 @@ export interface ResolvedAnchor {
|
|
|
55
55
|
* record states for a literal anchor, whose text is what the index serves.
|
|
56
56
|
*/
|
|
57
57
|
namesUnemittedModule?: true;
|
|
58
|
+
/**
|
|
59
|
+
* carrick#3995: why the alias is untyped, decided here: `machinery_envelope`
|
|
60
|
+
* for a demotion off framework machinery, `site_unreadable` for every other
|
|
61
|
+
* demotion, `not_located` for an abstain because the anchor named no
|
|
62
|
+
* payload, `no_success_payload` for a response table with no success row.
|
|
63
|
+
* Absent on a typed alias and on an abstain decided from the code whose
|
|
64
|
+
* reason is stated elsewhere. A located bare `any`/`unknown` with no cause
|
|
65
|
+
* here is stamped `declared` by the self-check (carrick#4046). Recorded as the record's `unread_cause`,
|
|
66
|
+
* which only the index reads: never a verdict input, never in `surface_hash`.
|
|
67
|
+
*/
|
|
68
|
+
unreadCause?: TypeProvenanceReason;
|
|
58
69
|
}
|
|
59
70
|
/**
|
|
60
71
|
* Repo-root-relative source file -> the specifier the surface entry imports
|
|
@@ -8,6 +8,7 @@ import ts from 'typescript';
|
|
|
8
8
|
import * as path from 'node:path';
|
|
9
9
|
import { printTypeForDestination, substituteUndeclaredNames, undeclaredNamesIn, } from './node-builder.js';
|
|
10
10
|
import { typeIsOrContainsMachinery } from './machinery.js';
|
|
11
|
+
import { firstExactLocatorMatch } from './site-node.js';
|
|
11
12
|
import { readResultLabel } from './result-label.js';
|
|
12
13
|
import { installedPackageSpecifier } from './installed-package.js';
|
|
13
14
|
import { realPath } from './service-config.js';
|
|
@@ -64,16 +65,17 @@ export function moduleExport(checker, sourceFile, name) {
|
|
|
64
65
|
*/
|
|
65
66
|
export function resolveAnchor(program, request, args) {
|
|
66
67
|
const checker = program.getTypeChecker();
|
|
67
|
-
const demote = (reason) => ({
|
|
68
|
+
const demote = (reason, cause) => ({
|
|
68
69
|
request,
|
|
69
70
|
aliasText: 'unknown',
|
|
70
71
|
serialization: 'structural_fallback',
|
|
71
72
|
failureReason: reason,
|
|
73
|
+
unreadCause: cause,
|
|
72
74
|
});
|
|
73
75
|
if (request.kind === 'literal') {
|
|
74
76
|
const text = request.type_text.trim();
|
|
75
77
|
if (!text) {
|
|
76
|
-
return demote('empty literal type text');
|
|
78
|
+
return demote('empty literal type text', 'site_unreadable');
|
|
77
79
|
}
|
|
78
80
|
const bareIdentifier = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(text);
|
|
79
81
|
const siblingSpec = bareIdentifier
|
|
@@ -126,13 +128,13 @@ export function resolveAnchor(program, request, args) {
|
|
|
126
128
|
const sourceAbs = resolveSourceFile(args.repoRoot, request.source_file);
|
|
127
129
|
const sourceFile = program.getSourceFile(sourceAbs);
|
|
128
130
|
if (!sourceFile) {
|
|
129
|
-
return demote(`source file not in program: ${request.source_file}
|
|
131
|
+
return demote(`source file not in program: ${request.source_file}`, 'site_unreadable');
|
|
130
132
|
}
|
|
131
133
|
const spec = entryRelativeSpecifier(args.entryDir, args.repoRoot, request.source_file, args.resolveFromEntry);
|
|
132
134
|
if (request.kind === 'symbol') {
|
|
133
135
|
const exported = moduleExport(checker, sourceFile, request.symbol_name);
|
|
134
136
|
if (!exported) {
|
|
135
|
-
return demote(`'${request.symbol_name}' is not an export of ${request.source_file}
|
|
137
|
+
return demote(`'${request.symbol_name}' is not an export of ${request.source_file}`, 'site_unreadable');
|
|
136
138
|
}
|
|
137
139
|
// The anchor is the ELEMENT symbol; array_depth restores the use-site's
|
|
138
140
|
// `[]` levels (#248/#306) so an array-vs-scalar mismatch stays visible.
|
|
@@ -162,7 +164,7 @@ export function resolveAnchor(program, request, args) {
|
|
|
162
164
|
// emitting a surface line that references a value in type position.
|
|
163
165
|
return demote(`'${request.symbol_name}' is a value export with no type-space meaning, ` +
|
|
164
166
|
`and no sibling type alias derives from it (e.g. \`typeof ${request.symbol_name}\`); ` +
|
|
165
|
-
'demoted so the surface line stays valid');
|
|
167
|
+
'demoted so the surface line stays valid', 'site_unreadable');
|
|
166
168
|
}
|
|
167
169
|
const arrayDepth = Math.max(0, request.array_depth ?? 0);
|
|
168
170
|
const declared = checker.getDeclaredTypeOfSymbol(resolvedExport);
|
|
@@ -181,6 +183,8 @@ export function resolveAnchor(program, request, args) {
|
|
|
181
183
|
serialization: 'structural_fallback',
|
|
182
184
|
abstainReason: `'${request.symbol_name}' is a response table keyed by status code with no ` +
|
|
183
185
|
'success row that states a body, so this consumer states no response contract',
|
|
186
|
+
// carrick#4046: no success body is the reason, not a declared `unknown`.
|
|
187
|
+
unreadCause: 'no_success_payload',
|
|
184
188
|
};
|
|
185
189
|
}
|
|
186
190
|
if (table?.kind === 'body') {
|
|
@@ -212,21 +216,21 @@ export function resolveAnchor(program, request, args) {
|
|
|
212
216
|
// Design-doc Capture step 1 guards, all three verified failure modes.
|
|
213
217
|
const exported = moduleExport(checker, sourceFile, request.symbol_name);
|
|
214
218
|
if (!exported) {
|
|
215
|
-
return demote(`handler '${request.symbol_name}' is not an export of ${request.source_file}
|
|
219
|
+
return demote(`handler '${request.symbol_name}' is not an export of ${request.source_file}`, 'site_unreadable');
|
|
216
220
|
}
|
|
217
221
|
const declaration = exported.valueDeclaration ?? exported.declarations?.[0];
|
|
218
222
|
const handlerType = checker.getTypeOfSymbolAtLocation(exported, declaration ?? sourceFile);
|
|
219
223
|
const callSignatures = handlerType.getCallSignatures();
|
|
220
224
|
if (callSignatures.length === 0) {
|
|
221
|
-
return demote(`handler '${request.symbol_name}' has no call signatures
|
|
225
|
+
return demote(`handler '${request.symbol_name}' has no call signatures`, 'site_unreadable');
|
|
222
226
|
}
|
|
223
227
|
if (callSignatures.length > 1) {
|
|
224
228
|
// ReturnType<> silently resolves the LAST overload only.
|
|
225
|
-
return demote(`handler '${request.symbol_name}' is an overload set (${callSignatures.length} signatures)
|
|
229
|
+
return demote(`handler '${request.symbol_name}' is an overload set (${callSignatures.length} signatures)`, 'site_unreadable');
|
|
226
230
|
}
|
|
227
231
|
if ((callSignatures[0].getTypeParameters() ?? []).length > 0) {
|
|
228
232
|
// Type parameters erase to their constraint/unknown under ReturnType<>.
|
|
229
|
-
return demote(`handler '${request.symbol_name}' is generic
|
|
233
|
+
return demote(`handler '${request.symbol_name}' is generic`, 'site_unreadable');
|
|
230
234
|
}
|
|
231
235
|
const returned = callSignatures[0].getReturnType();
|
|
232
236
|
const unresolved = unresolvedAtAnchor(program, sourceFile, checker.getAwaitedType(returned) ?? returned, declaration ?? sourceFile);
|
|
@@ -248,13 +252,13 @@ export function resolveAnchor(program, request, args) {
|
|
|
248
252
|
const param = locateHandlerParam(sourceFile, request, request.param_name);
|
|
249
253
|
if (!param) {
|
|
250
254
|
return demote(`no handler parameter '${request.param_name}' resolved in ` +
|
|
251
|
-
`${request.source_file} (${paramLocatorHints(request)})
|
|
255
|
+
`${request.source_file} (${paramLocatorHints(request)})`, 'site_unreadable');
|
|
252
256
|
}
|
|
253
257
|
return finishInferAnchor(program, sourceFile, request, param, args.placeholder, undefined, args.repoRoot);
|
|
254
258
|
}
|
|
255
259
|
const found = locate(sourceFile, request);
|
|
256
260
|
if (!found) {
|
|
257
|
-
return demote(locatorFailureReason(request));
|
|
261
|
+
return demote(locatorFailureReason(request), 'site_unreadable');
|
|
258
262
|
}
|
|
259
263
|
// carrick#1785: the line fallback takes the first expression on the line,
|
|
260
264
|
// and a declaration's NAME is an expression to `ts.isExpression`. On a line
|
|
@@ -275,6 +279,7 @@ export function resolveAnchor(program, request, args) {
|
|
|
275
279
|
`${describeNode(sourceFile, request.source_file, declaration)}; a ` +
|
|
276
280
|
`declaration's name is not a payload, so the anchor abstains rather ` +
|
|
277
281
|
`than publish the declared entity's own type`,
|
|
282
|
+
unreadCause: 'not_located',
|
|
278
283
|
};
|
|
279
284
|
}
|
|
280
285
|
}
|
|
@@ -292,7 +297,7 @@ export function resolveAnchor(program, request, args) {
|
|
|
292
297
|
let reaimNote;
|
|
293
298
|
const builderReaim = reaimBuilderChainPayload(checker, located);
|
|
294
299
|
if (builderReaim.kind === 'demote') {
|
|
295
|
-
return demote(builderReaim.reason);
|
|
300
|
+
return demote(builderReaim.reason, 'site_unreadable');
|
|
296
301
|
}
|
|
297
302
|
if (builderReaim.kind === 'reaim') {
|
|
298
303
|
located = builderReaim.node;
|
|
@@ -308,11 +313,12 @@ export function resolveAnchor(program, request, args) {
|
|
|
308
313
|
*/
|
|
309
314
|
function finishInferAnchor(program, sourceFile, request, located, placeholder, reaimNote, repoRoot) {
|
|
310
315
|
const checker = program.getTypeChecker();
|
|
311
|
-
const demote = (reason) => ({
|
|
316
|
+
const demote = (reason, cause) => ({
|
|
312
317
|
request,
|
|
313
318
|
aliasText: 'unknown',
|
|
314
319
|
serialization: 'structural_fallback',
|
|
315
320
|
failureReason: reason,
|
|
321
|
+
unreadCause: cause,
|
|
316
322
|
});
|
|
317
323
|
const rawType = checker.getTypeAtLocation(located);
|
|
318
324
|
let type = rawType;
|
|
@@ -387,6 +393,7 @@ function finishInferAnchor(program, sourceFile, request, located, placeholder, r
|
|
|
387
393
|
`bare top type ('${checker.typeToString(type)}'); the anchor names no ` +
|
|
388
394
|
`payload span, expression or parameter, so it abstains rather than ` +
|
|
389
395
|
`publish a top type as a contract`,
|
|
396
|
+
unreadCause: 'not_located',
|
|
390
397
|
};
|
|
391
398
|
}
|
|
392
399
|
// carrick#371 fail-closed guard: a producer anchor whose resolved type IS or
|
|
@@ -400,16 +407,16 @@ function finishInferAnchor(program, sourceFile, request, located, placeholder, r
|
|
|
400
407
|
// type. No source locator points at a distinct clean payload here (the payload
|
|
401
408
|
// lives inside the wrapper's response builder), so degrade to `unknown` —
|
|
402
409
|
// abstain, never a concrete verdict off the machinery.
|
|
403
|
-
if (typeIsOrContainsMachinery(program, type,
|
|
410
|
+
if (typeIsOrContainsMachinery(program, type, repoRoot)) {
|
|
404
411
|
return demote('resolved type is or contains framework machinery (Response/Request-shaped); ' +
|
|
405
|
-
'degraded to unknown rather than emit a wrapper envelope as a response contract');
|
|
412
|
+
'degraded to unknown rather than emit a wrapper envelope as a response contract', 'machinery_envelope');
|
|
406
413
|
}
|
|
407
414
|
if (!placeholder) {
|
|
408
|
-
return demote('internal: no placeholder destination for infer anchor');
|
|
415
|
+
return demote('internal: no placeholder destination for infer anchor', 'site_unreadable');
|
|
409
416
|
}
|
|
410
417
|
const printed = printTypeForDestination(program, type, placeholder);
|
|
411
418
|
if (!printed.text) {
|
|
412
|
-
return demote(printed.failure ?? 'node builder print failed');
|
|
419
|
+
return demote(printed.failure ?? 'node builder print failed', 'site_unreadable');
|
|
413
420
|
}
|
|
414
421
|
const atAnchor = unresolvedAtAnchor(program, sourceFile, type, located);
|
|
415
422
|
// carrick#1377: a member the print named undeclared and this rewrote to
|
|
@@ -1241,38 +1248,12 @@ function tightestCoveringNode(sourceFile, start, end) {
|
|
|
1241
1248
|
return best;
|
|
1242
1249
|
}
|
|
1243
1250
|
/**
|
|
1244
|
-
*
|
|
1245
|
-
*
|
|
1246
|
-
*
|
|
1251
|
+
* The node a locator's text names: the first exact match on or after the line
|
|
1252
|
+
* among the nodes a value type can be read at (`firstExactLocatorMatch`,
|
|
1253
|
+
* carrick#3500).
|
|
1247
1254
|
*/
|
|
1248
|
-
function normalizeLocatorText(text) {
|
|
1249
|
-
return text
|
|
1250
|
-
.replace(/\s+/g, ' ')
|
|
1251
|
-
.replace(/\s*(\?\.|\.)\s*/g, '$1')
|
|
1252
|
-
.trim();
|
|
1253
|
-
}
|
|
1254
1255
|
function nodeByExpressionText(sourceFile, text, fromLine) {
|
|
1255
|
-
|
|
1256
|
-
let best;
|
|
1257
|
-
const visit = (node) => {
|
|
1258
|
-
if (best)
|
|
1259
|
-
return;
|
|
1260
|
-
if (isPreferredTarget(node)) {
|
|
1261
|
-
const nodeText = normalizeLocatorText(node.getText(sourceFile));
|
|
1262
|
-
if (nodeText === wanted) {
|
|
1263
|
-
// On or after the line, or COVERING it: a chain broken before its dot
|
|
1264
|
-
// starts a line above the line the analyzer reports for the call.
|
|
1265
|
-
const endLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line + 1;
|
|
1266
|
-
if (fromLine === undefined || endLine >= fromLine) {
|
|
1267
|
-
best = node;
|
|
1268
|
-
return;
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
node.forEachChild(visit);
|
|
1273
|
-
};
|
|
1274
|
-
visit(sourceFile);
|
|
1275
|
-
return best;
|
|
1256
|
+
return firstExactLocatorMatch(sourceFile, text, fromLine, isPreferredTarget);
|
|
1276
1257
|
}
|
|
1277
1258
|
function firstExpressionOnLine(sourceFile, line) {
|
|
1278
1259
|
let best;
|
|
@@ -102,6 +102,11 @@ export interface LiteralAnchorRequest {
|
|
|
102
102
|
* reads it.
|
|
103
103
|
*/
|
|
104
104
|
absent_body_tolerated?: true;
|
|
105
|
+
/**
|
|
106
|
+
* carrick#3995: why the text is a placeholder, when the driver knows.
|
|
107
|
+
* Copied onto the alias's record; no verdict reads it.
|
|
108
|
+
*/
|
|
109
|
+
unread_cause?: TypeProvenanceReason;
|
|
105
110
|
}
|
|
106
111
|
/**
|
|
107
112
|
* The declaration a bare name in printed type text meant (carrick#1836).
|
|
@@ -241,10 +246,17 @@ export type SelfCheckOutcome = 'ok' | 'allowlisted_external' | 'decayed_internal
|
|
|
241
246
|
* name) that builds a new value from it, and nothing in the chain states
|
|
242
247
|
* the body, so the value the chain ends in is not the response the call
|
|
243
248
|
* receives and no contract is published (carrick#3004).
|
|
249
|
+
* - `not_located`: the scan found no value in the code for this payload, so
|
|
250
|
+
* no type was read for it: no request located one, or the only locator was
|
|
251
|
+
* a line (carrick#3995).
|
|
252
|
+
* - `site_unreadable`: the scan located the site, but the compiler could not
|
|
253
|
+
* read a type at it (carrick#3995).
|
|
254
|
+
* - `unplaced_top_type`: the printed shape holds a top type at a member no
|
|
255
|
+
* layer placed (carrick#3995). Stamped at the entry's root.
|
|
244
256
|
* - `not_recorded`: the position carries a top type and this layer has no
|
|
245
257
|
* cause for it.
|
|
246
258
|
*/
|
|
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';
|
|
259
|
+
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_located' | 'site_unreadable' | 'unplaced_top_type' | 'not_recorded';
|
|
248
260
|
/**
|
|
249
261
|
* One `any`/`unknown` finding inside a captured or inferred type, with its
|
|
250
262
|
* position and its cause. Sorted by `path` wherever a list is emitted, so the
|
|
@@ -358,6 +370,14 @@ export interface CaptureAliasRecord {
|
|
|
358
370
|
* type alone.
|
|
359
371
|
*/
|
|
360
372
|
absent_body_tolerated?: true;
|
|
373
|
+
/**
|
|
374
|
+
* carrick#3995: why the alias is untyped. A literal anchor's own
|
|
375
|
+
* `unread_cause` when the driver sent one, otherwise the cause the capture
|
|
376
|
+
* decided at the anchor (`machinery_envelope`, `site_unreadable`,
|
|
377
|
+
* `not_located`). Read only to say why the entry is untyped: never a
|
|
378
|
+
* verdict input, never in `surface_hash`.
|
|
379
|
+
*/
|
|
380
|
+
unread_cause?: TypeProvenanceReason;
|
|
361
381
|
/**
|
|
362
382
|
* carrick#3135: lowercase hex SHA-256 of everything the judge reads for
|
|
363
383
|
* this alias from its own stub: the alias's `export type` statement, every
|
|
@@ -582,6 +602,13 @@ export interface CheckVerdict {
|
|
|
582
602
|
* observation as a verdict.
|
|
583
603
|
*/
|
|
584
604
|
notes: string[];
|
|
605
|
+
/**
|
|
606
|
+
* On a `foreign:<side>` verdict only (carrick#1047 J1-1): why that side
|
|
607
|
+
* could not be judged. `hit`: its type reads another service's
|
|
608
|
+
* declaration. `budget`: the walk ran out of budget before it could rule
|
|
609
|
+
* one out. `no_program`: no program could be built to walk it in.
|
|
610
|
+
*/
|
|
611
|
+
foreign_kind?: 'hit' | 'budget' | 'no_program';
|
|
585
612
|
}
|
|
586
613
|
/**
|
|
587
614
|
* A service degraded SERVICE-WIDE: install failure, or a stub-tree diagnostic
|
|
@@ -617,6 +644,19 @@ export interface CheckResult {
|
|
|
617
644
|
* signal, or a non-zero exit with no parseable diagnostics): every pair is then
|
|
618
645
|
* unverifiable, and this says whether it died of memory (carrick#2209). */
|
|
619
646
|
compiler_end?: CompilerEnd;
|
|
647
|
+
/** Wall time of each phase of a check that ran to its end, in whole
|
|
648
|
+
* milliseconds. For the scanner's log only: no verdict reads it. Absent on
|
|
649
|
+
* every early return (carrick#1047). */
|
|
650
|
+
phase_ms?: CheckPhaseMs;
|
|
651
|
+
}
|
|
652
|
+
/** Where a check's time went (carrick#1047). */
|
|
653
|
+
export interface CheckPhaseMs {
|
|
654
|
+
assemble: number;
|
|
655
|
+
probes: number;
|
|
656
|
+
install: number;
|
|
657
|
+
tsc: number;
|
|
658
|
+
probe_program: number;
|
|
659
|
+
classify: number;
|
|
620
660
|
}
|
|
621
661
|
/** How the check's compiler process ended. */
|
|
622
662
|
export interface CompilerEnd {
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* one silently corrupts the closure. Cheap syntactic prefilter first, real
|
|
13
13
|
* parse only on candidates.
|
|
14
14
|
*/
|
|
15
|
+
import ts from 'typescript';
|
|
16
|
+
export declare function declaresAugmentation(sourceFile: ts.SourceFile): boolean;
|
|
15
17
|
/**
|
|
16
18
|
* Absolute paths of files in `fileNames` that declare global or module
|
|
17
19
|
* augmentations. Files that fail to read/parse are skipped (they will fail
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import ts from 'typescript';
|
|
16
16
|
import * as fs from 'node:fs';
|
|
17
17
|
const PREFILTER = /declare\s+(?:global|module)\b/;
|
|
18
|
-
function declaresAugmentation(sourceFile) {
|
|
18
|
+
export function declaresAugmentation(sourceFile) {
|
|
19
19
|
// Augmentations only have their augmentation semantics inside a module;
|
|
20
20
|
// in a script file `declare module "x"` is an ambient module declaration,
|
|
21
21
|
// which the closure treatment still wants shipped when present.
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* classifying by diagnostic code + file + line (never by line position alone):
|
|
8
8
|
*
|
|
9
9
|
* poison (stub-file diagnostic) -> unverifiable [highest precedence]
|
|
10
|
+
* a side reads another service's -> unverifiable (foreign:<side>,
|
|
11
|
+
* declaration (or could not rule it out) carrick#1047)
|
|
10
12
|
* surface import error (probe lines 1-2)-> unverifiable
|
|
11
13
|
* IsAny gate fired (TS2344) -> gate_caught_baked_any
|
|
12
14
|
* IsUnknown/IsNever gate fired (TS2344) -> unverifiable
|
|
@@ -34,7 +36,7 @@
|
|
|
34
36
|
import type { CheckVerdict } from './api.js';
|
|
35
37
|
import { type ProbePlan, type Side } from './check-probe.js';
|
|
36
38
|
import { type ScrubContext } from './check-scrub.js';
|
|
37
|
-
import type { PairDeepFindings } from './check-deep.js';
|
|
39
|
+
import type { PairDeepFindings, PairForeignFindings } from './check-deep.js';
|
|
38
40
|
import type { DispatchUnion } from './check-union.js';
|
|
39
41
|
import { type PairFieldReport } from './check-fields.js';
|
|
40
42
|
export interface RawDiagnostic {
|
|
@@ -88,6 +90,11 @@ export interface ClassifyInput {
|
|
|
88
90
|
* JSON body that is a string.
|
|
89
91
|
*/
|
|
90
92
|
rawTextSide?: Side;
|
|
93
|
+
/**
|
|
94
|
+
* What each side reads of another service's declarations (carrick#1047
|
|
95
|
+
* J1-1). Absent when neither side can reach one.
|
|
96
|
+
*/
|
|
97
|
+
foreign?: PairForeignFindings;
|
|
91
98
|
}
|
|
92
99
|
/** Classify one pair into exactly one bucket, honouring the precedence order. */
|
|
93
100
|
export declare function classifyPair(input: ClassifyInput): CheckVerdict;
|
|
@@ -98,3 +105,7 @@ export declare function classifyPair(input: ClassifyInput): CheckVerdict;
|
|
|
98
105
|
export declare const CONSUMER_WIDER_NOTE: string;
|
|
99
106
|
/** The note on a pair whose consumer reads no response body (carrick#1162). */
|
|
100
107
|
export declare const CONSUMER_READS_NO_BODY_NOTE = "the consumer reads no response body (its expected response is void), so the producer response is not compared with a read";
|
|
108
|
+
/** carrick#1047 J1-1: a side's type reads a declaration `other` declares. */
|
|
109
|
+
export declare function foreignHitReason(side: Side, other: string): string;
|
|
110
|
+
/** carrick#1047 J1-1: no program could be built to rule that out. */
|
|
111
|
+
export declare function foreignUnwalkedReason(side: Side): string;
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* classifying by diagnostic code + file + line (never by line position alone):
|
|
8
8
|
*
|
|
9
9
|
* poison (stub-file diagnostic) -> unverifiable [highest precedence]
|
|
10
|
+
* a side reads another service's -> unverifiable (foreign:<side>,
|
|
11
|
+
* declaration (or could not rule it out) carrick#1047)
|
|
10
12
|
* surface import error (probe lines 1-2)-> unverifiable
|
|
11
13
|
* IsAny gate fired (TS2344) -> gate_caught_baked_any
|
|
12
14
|
* IsUnknown/IsNever gate fired (TS2344) -> unverifiable
|
|
@@ -119,6 +121,34 @@ export function classifyPair(input) {
|
|
|
119
121
|
};
|
|
120
122
|
}
|
|
121
123
|
}
|
|
124
|
+
// 1b. A side whose type reads a declaration only another service declares
|
|
125
|
+
// (carrick#1047 J1-1): a global merged in from a stub loaded beside it.
|
|
126
|
+
// Each service compiles alone, so neither compiles that type, and the
|
|
127
|
+
// verdict would hang on which other pairs this run probed. A walk that
|
|
128
|
+
// could not rule it out fails closed. The producer is named first, as
|
|
129
|
+
// poison names it.
|
|
130
|
+
for (const side of ['producer', 'consumer']) {
|
|
131
|
+
const found = input.foreign?.[side];
|
|
132
|
+
if (!found)
|
|
133
|
+
continue;
|
|
134
|
+
const service = plan.spec[side].service_name;
|
|
135
|
+
const [kind, reason] = found === 'unwalked'
|
|
136
|
+
? ['no_program', foreignUnwalkedReason(side)]
|
|
137
|
+
: 'exhaustedAt' in found
|
|
138
|
+
? [
|
|
139
|
+
'budget',
|
|
140
|
+
`the ${side} type is too deep or wide to verify at ${found.exhaustedAt === '<root>' ? 'its root' : `'${found.exhaustedAt}'`}`,
|
|
141
|
+
]
|
|
142
|
+
: ['hit', foreignHitReason(side, found.service)];
|
|
143
|
+
return {
|
|
144
|
+
...base,
|
|
145
|
+
bucket: 'unverifiable',
|
|
146
|
+
gate: `foreign:${side}`,
|
|
147
|
+
diagnostic: foreignDiagnostic(service, typeof found !== 'string' && 'service' in found ? found.service : undefined),
|
|
148
|
+
...notAFact(reason, side),
|
|
149
|
+
foreign_kind: kind,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
122
152
|
// 2. Surface import error (missing/renamed export): probe import lines.
|
|
123
153
|
const importDiag = probeDiags.find((d) => plan.importLines.includes(d.line));
|
|
124
154
|
if (importDiag) {
|
|
@@ -481,3 +511,16 @@ function factness(input, strict = false) {
|
|
|
481
511
|
}
|
|
482
512
|
return { resolved: true };
|
|
483
513
|
}
|
|
514
|
+
/** carrick#1047 J1-1: a side's type reads a declaration `other` declares. */
|
|
515
|
+
export function foreignHitReason(side, other) {
|
|
516
|
+
return `the ${side} type uses declarations from '${other}'`;
|
|
517
|
+
}
|
|
518
|
+
/** carrick#1047 J1-1: no program could be built to rule that out. */
|
|
519
|
+
export function foreignUnwalkedReason(side) {
|
|
520
|
+
return `the ${side} type may use declarations from another service`;
|
|
521
|
+
}
|
|
522
|
+
function foreignDiagnostic(service, other) {
|
|
523
|
+
return other === undefined
|
|
524
|
+
? `the type for '${service}' may use declarations from another service that '${service}' never compiles with; compatibility cannot be verified.`
|
|
525
|
+
: `the type for '${service}' uses declarations from '${other}', which '${service}' never compiles with; compatibility cannot be verified.`;
|
|
526
|
+
}
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import ts from 'typescript';
|
|
24
24
|
import type { TypeProvenance } from './api.js';
|
|
25
|
-
import { type ProbePlan } from './check-probe.js';
|
|
25
|
+
import { type ProbePlan, type Side } from './check-probe.js';
|
|
26
|
+
import type { AssembledWorkspace } from './check-workspace.js';
|
|
26
27
|
/** Deep findings for one pair, per probe side. */
|
|
27
28
|
export interface PairDeepFindings {
|
|
28
29
|
sent: TypeProvenance[];
|
|
@@ -52,3 +53,45 @@ export declare function openProbeProgram(probesDir: string, plans: ProbePlan[]):
|
|
|
52
53
|
* as unresolved rather than resolved.
|
|
53
54
|
*/
|
|
54
55
|
export declare function probeDeepFindings(opened: ProbeProgram | undefined, plans: ProbePlan[]): Map<string, PairDeepFindings>;
|
|
56
|
+
/**
|
|
57
|
+
* What one side of a pair reads of another service's declarations
|
|
58
|
+
* (carrick#1047 J1-1): the first position and the service that declares it,
|
|
59
|
+
* where the walk ran out of budget before it could rule one out, or
|
|
60
|
+
* `unwalked` when no program could be built to walk it in.
|
|
61
|
+
*/
|
|
62
|
+
export type SideForeign = {
|
|
63
|
+
service: string;
|
|
64
|
+
path: string;
|
|
65
|
+
} | {
|
|
66
|
+
exhaustedAt: string;
|
|
67
|
+
} | 'unwalked';
|
|
68
|
+
/** Per side of a pair; a side absent here reads only its own service. */
|
|
69
|
+
export type PairForeignFindings = Partial<Record<Side, SideForeign>>;
|
|
70
|
+
/**
|
|
71
|
+
* Which probed sides read a declaration that only another service declares
|
|
72
|
+
* (carrick#1047 J1-1).
|
|
73
|
+
*
|
|
74
|
+
* Each service compiles alone. The judge loads every probed stub into one
|
|
75
|
+
* program, so a global-scope file of one stub (a script, a `declare global`, a
|
|
76
|
+
* module augmentation) can merge into a name another stub's type reads, and
|
|
77
|
+
* that type is then one neither service compiles. A side can only read
|
|
78
|
+
* another stub's declaration through such a file: a stub that names a sibling
|
|
79
|
+
* by its package name does not resolve in this workspace (carrick#2970). So a
|
|
80
|
+
* side is walked only when the program holds a global-scope file of another
|
|
81
|
+
* stub, and otherwise costs nothing.
|
|
82
|
+
*
|
|
83
|
+
* A declaration in another stub's tree is not foreign when its text equals a
|
|
84
|
+
* declaration of the same symbol in the side's own tree: a typing file two
|
|
85
|
+
* services both carry says the same thing in each.
|
|
86
|
+
*
|
|
87
|
+
* Nor is one that merges into a built-in global, one TypeScript's default
|
|
88
|
+
* library declares (`interface Array<T>`, `Date`, `Promise`), unless it lies
|
|
89
|
+
* in the tree of the pair's other side. Both sides read the same built-in in
|
|
90
|
+
* the judge's program, so a third service's augmentation of it cannot move
|
|
91
|
+
* the verdict; the other side's can, as that side's own compile has it and
|
|
92
|
+
* this side's does not.
|
|
93
|
+
*
|
|
94
|
+
* Fails closed. A walk out of budget is `exhaustedAt`; a run with no program
|
|
95
|
+
* whose workspace holds another stub's global-scope file is `unwalked`.
|
|
96
|
+
*/
|
|
97
|
+
export declare function pairForeignFindings(opened: ProbeProgram | undefined, plans: ProbePlan[], ws: AssembledWorkspace): Map<string, PairForeignFindings>;
|