carrick 0.3.136 → 0.3.138
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/scripts/install-scanned-deps.sh +142 -2
- package/sidecar/dist/src/capture/api.d.ts +7 -0
- package/sidecar/dist/src/capture/check.d.ts +33 -0
- package/sidecar/dist/src/capture/check.js +102 -10
- package/sidecar/dist/src/index.js +1 -1
- package/sidecar/dist/src/library-claims.d.ts +25 -1
- package/sidecar/dist/src/library-claims.js +1348 -94
- package/sidecar/dist/src/result-candidates.d.ts +7 -0
- package/sidecar/dist/src/result-candidates.js +12 -5
- package/sidecar/dist/src/runtime-emitter.d.ts +39 -0
- package/sidecar/dist/src/runtime-emitter.js +65 -0
- package/sidecar/dist/src/server-labels.js +2 -2
- package/sidecar/dist/src/stated-params.d.ts +73 -3
- package/sidecar/dist/src/stated-params.js +292 -9
- package/sidecar/dist/src/type-inferrer.d.ts +17 -35
- package/sidecar/dist/src/type-inferrer.js +81 -82
- package/sidecar/dist/src/types.d.ts +125 -13
- package/sidecar/dist/src/validators.d.ts +1422 -162
- package/sidecar/dist/src/validators.js +39 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carrick",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.138",
|
|
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.138",
|
|
118
|
+
"@carrick-tools/cli-darwin-x64": "0.3.138",
|
|
119
|
+
"@carrick-tools/cli-linux-arm64": "0.3.138",
|
|
120
|
+
"@carrick-tools/cli-linux-x64": "0.3.138",
|
|
121
|
+
"@carrick-tools/cli-win32-x64": "0.3.138"
|
|
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.138",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Carrick",
|
|
7
7
|
"email": "hello@carrick.tools"
|
|
@@ -75,6 +75,21 @@
|
|
|
75
75
|
# Unset, the script behaves as it always has: on a developer's own CI the
|
|
76
76
|
# tree is theirs. `action.yml` leaves it unset.
|
|
77
77
|
#
|
|
78
|
+
# CARRICK_INSTALL_LOCKFILE_RETRY=1 is the hosted runner's lane policy (carrick#3069),
|
|
79
|
+
# separate from the posture above. Unset, nothing here changes. Set, a strict
|
|
80
|
+
# install that fails with anything but a timeout (124, 137) is retried once, with
|
|
81
|
+
# lifecycle scripts still disabled, the same time limit and every untrusted guard:
|
|
82
|
+
# npm npm ci -> npm install --ignore-scripts --no-audit --no-fund --no-save
|
|
83
|
+
# pnpm install --frozen-lockfile -> install --no-frozen-lockfile --ignore-scripts [--ignore-pnpmfile]
|
|
84
|
+
# yarn classic as above -> yarn install --pure-lockfile --ignore-scripts
|
|
85
|
+
# bun as above -> bun install --ignore-scripts --no-save
|
|
86
|
+
# Not retried: Yarn Berry (no install mode that reads the lockfile without writing
|
|
87
|
+
# it; zero-install repos commit what a mutable install writes) and Deno (the
|
|
88
|
+
# pre-flight asks only when `nodeModulesDir` is set, and no failing frozen
|
|
89
|
+
# install has been seen). The tree stays the commit: the lockfile, package.json
|
|
90
|
+
# and pnpm-workspace.yaml are restored byte for byte after the retry, and a root
|
|
91
|
+
# that ends uninstalled keeps no node_modules directory the attempts created.
|
|
92
|
+
#
|
|
78
93
|
# CARRICK_CLI names the Carrick to ask for the services. `action.yml` writes a
|
|
79
94
|
# wrapper for whichever copy the run resolved, npm package or release asset.
|
|
80
95
|
# Deliberately NOT `CARRICK_BIN`: that variable names a scanner BINARY to the
|
|
@@ -88,6 +103,9 @@ INSTALL_TIMEOUT_SECONDS="${CARRICK_INSTALL_TIMEOUT:-300}"
|
|
|
88
103
|
# Set by a machine that scans repositories it does not own; see the header.
|
|
89
104
|
UNTRUSTED="${CARRICK_INSTALL_UNTRUSTED:-}"
|
|
90
105
|
|
|
106
|
+
# Set by the hosted runner; see the header. A lane policy, separate from UNTRUSTED.
|
|
107
|
+
LOCKFILE_RETRY="${CARRICK_INSTALL_LOCKFILE_RETRY:-}"
|
|
108
|
+
|
|
91
109
|
# The delimiter for the one multi-line step output this script writes. A
|
|
92
110
|
# workflow reads `cache_dirs` as the `path:` of actions/cache, which takes one
|
|
93
111
|
# directory per line, and a plain `key=value` line cannot carry that.
|
|
@@ -393,13 +411,70 @@ yarn_untrusted_refusal() {
|
|
|
393
411
|
echo "$answer"
|
|
394
412
|
}
|
|
395
413
|
|
|
414
|
+
# A failed attempt's log: the first 30 lines (npm puts the cause of a refusal
|
|
415
|
+
# there and follows it with usage text), a marker only when lines were cut,
|
|
416
|
+
# then the last 20. A log of 50 lines or fewer prints whole.
|
|
417
|
+
print_failed_log() {
|
|
418
|
+
local log="$1" total
|
|
419
|
+
[ -f "$log" ] || return 0
|
|
420
|
+
total=$(wc -l <"$log" | tr -d ' ')
|
|
421
|
+
if [ "$total" -le 50 ]; then
|
|
422
|
+
cat "$log"
|
|
423
|
+
else
|
|
424
|
+
head -n 30 "$log"
|
|
425
|
+
echo "... ($((total - 50)) lines omitted) ..."
|
|
426
|
+
tail -n 20 "$log"
|
|
427
|
+
fi
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
# The files a lockfile-tolerant retry may rewrite, per manager.
|
|
431
|
+
retry_guarded_files() {
|
|
432
|
+
case "$1" in
|
|
433
|
+
npm) echo "package-lock.json package.json" ;;
|
|
434
|
+
pnpm) echo "pnpm-lock.yaml package.json pnpm-workspace.yaml" ;;
|
|
435
|
+
yarn) echo "yarn.lock package.json" ;;
|
|
436
|
+
bun) echo "bun.lock bun.lockb package.json" ;;
|
|
437
|
+
esac
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
# Every `node_modules` directory under a root, one per line, sorted; `.git` and
|
|
441
|
+
# the `node_modules` found are not descended into.
|
|
442
|
+
node_modules_dirs() {
|
|
443
|
+
find "$1" -name .git -prune -o -name node_modules -type d -prune -print 2>/dev/null | sort
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
# The retry command for a manager, run through `run_install` like the strict
|
|
447
|
+
# one, with every untrusted-mode guard the strict install has.
|
|
448
|
+
run_retry_install() {
|
|
449
|
+
local root="$1" log="$2" manager="$3"
|
|
450
|
+
case "$manager" in
|
|
451
|
+
npm)
|
|
452
|
+
if [ -n "$UNTRUSTED" ]; then
|
|
453
|
+
npm_trusted_tools
|
|
454
|
+
run_install "$root" "$log" env "${NPM_TRUSTED_TOOLS[@]}" npm install --ignore-scripts --no-audit --no-fund --no-save
|
|
455
|
+
else
|
|
456
|
+
run_install "$root" "$log" npm install --ignore-scripts --no-audit --no-fund --no-save
|
|
457
|
+
fi
|
|
458
|
+
;;
|
|
459
|
+
pnpm)
|
|
460
|
+
if [ -n "$UNTRUSTED" ]; then
|
|
461
|
+
run_install "$root" "$log" corepack pnpm install --no-frozen-lockfile --ignore-scripts --ignore-pnpmfile
|
|
462
|
+
else
|
|
463
|
+
run_install "$root" "$log" corepack pnpm install --no-frozen-lockfile --ignore-scripts
|
|
464
|
+
fi
|
|
465
|
+
;;
|
|
466
|
+
yarn) run_install "$root" "$log" yarn install --pure-lockfile --ignore-scripts ;;
|
|
467
|
+
bun) run_install "$root" "$log" bun install --ignore-scripts --no-save ;;
|
|
468
|
+
esac
|
|
469
|
+
}
|
|
470
|
+
|
|
396
471
|
# Yarn Berry's lockfile opens with a `__metadata` block; classic's does not.
|
|
397
472
|
yarn_is_berry() {
|
|
398
473
|
[ -f "$1/.yarnrc.yml" ] || grep -q '^__metadata:' "$1/yarn.lock" 2>/dev/null
|
|
399
474
|
}
|
|
400
475
|
|
|
401
476
|
cmd_install_one() {
|
|
402
|
-
local root="$1" manager="$2" log status refusal
|
|
477
|
+
local root="$1" manager="$2" log status refusal strict_cmd="" no_retry="" snap="" before=""
|
|
403
478
|
if [ "$manager" != "deno" ] && { [ -f "$root/deno.json" ] || [ -f "$root/deno.jsonc" ]; }; then
|
|
404
479
|
# Mixed roots need the global Deno cache AND the Node compiler's local
|
|
405
480
|
# install. Neither preparation executes authorized project lifecycle code.
|
|
@@ -411,8 +486,19 @@ cmd_install_one() {
|
|
|
411
486
|
# reach the version the repo pins in `packageManager`.
|
|
412
487
|
corepack enable >/dev/null 2>&1 || true
|
|
413
488
|
|
|
489
|
+
# Taken before the first attempt, so a retry that fails can remove what the
|
|
490
|
+
# attempts created and nothing else.
|
|
491
|
+
if [ -n "$LOCKFILE_RETRY" ]; then
|
|
492
|
+
before=$(mktemp "${RUNNER_TEMP:-${TMPDIR:-/tmp}}/carrick-node-modules.XXXXXX") || before=""
|
|
493
|
+
[ -n "$before" ] && node_modules_dirs "$root" >"$before"
|
|
494
|
+
fi
|
|
495
|
+
|
|
414
496
|
case "$manager" in
|
|
415
497
|
deno)
|
|
498
|
+
# No retry: the pre-flight asks about a Deno service only when its config
|
|
499
|
+
# sets `nodeModulesDir`, and no failing `deno install --frozen` has been seen.
|
|
500
|
+
no_retry=1
|
|
501
|
+
strict_cmd="deno install --frozen"
|
|
416
502
|
# A project can authorize lifecycle scripts through allowScripts in its
|
|
417
503
|
# config. Deno has no --ignore-scripts: disabling node_modules is what
|
|
418
504
|
# prevents those scripts from running, even for an authorizing config.
|
|
@@ -421,6 +507,7 @@ cmd_install_one() {
|
|
|
421
507
|
status=$?
|
|
422
508
|
;;
|
|
423
509
|
npm)
|
|
510
|
+
strict_cmd="npm ci"
|
|
424
511
|
if [ -n "$UNTRUSTED" ]; then
|
|
425
512
|
npm_trusted_tools
|
|
426
513
|
run_install "$root" "$log" env "${NPM_TRUSTED_TOOLS[@]}" npm ci --ignore-scripts
|
|
@@ -430,6 +517,7 @@ cmd_install_one() {
|
|
|
430
517
|
status=$?
|
|
431
518
|
;;
|
|
432
519
|
pnpm)
|
|
520
|
+
strict_cmd="pnpm install --frozen-lockfile"
|
|
433
521
|
if [ -n "$UNTRUSTED" ]; then
|
|
434
522
|
# pnpm loads the tree's `.pnpmfile.cjs` on install unless told not to.
|
|
435
523
|
run_install "$root" "$log" corepack pnpm install --frozen-lockfile --ignore-scripts --ignore-pnpmfile
|
|
@@ -448,11 +536,19 @@ cmd_install_one() {
|
|
|
448
536
|
# so the two lines are told apart by what the tree says they are,
|
|
449
537
|
# never by which command happens to exit 0.
|
|
450
538
|
if yarn_is_berry "$root"; then
|
|
539
|
+
# No retry: Berry has no install mode that reads the lockfile without
|
|
540
|
+
# writing it, a mutable install can write `.pnp.cjs` and `.yarn/cache`
|
|
541
|
+
# that zero-install repos commit, and lifting
|
|
542
|
+
# YARN_ENABLE_IMMUTABLE_INSTALLS undoes the guard from #2246/#2251.
|
|
543
|
+
no_retry=1
|
|
544
|
+
strict_cmd="yarn install --mode=skip-build"
|
|
451
545
|
run_install "$root" "$log" yarn install --mode=skip-build
|
|
452
546
|
elif [ -n "$UNTRUSTED" ]; then
|
|
453
547
|
# Frozen, or classic rewrites yarn.lock.
|
|
548
|
+
strict_cmd="yarn install --frozen-lockfile"
|
|
454
549
|
run_install "$root" "$log" yarn install --frozen-lockfile --ignore-scripts
|
|
455
550
|
else
|
|
551
|
+
strict_cmd="yarn install"
|
|
456
552
|
run_install "$root" "$log" yarn install --ignore-scripts
|
|
457
553
|
fi
|
|
458
554
|
status=$?
|
|
@@ -463,8 +559,10 @@ cmd_install_one() {
|
|
|
463
559
|
return 0
|
|
464
560
|
fi
|
|
465
561
|
if [ -n "$UNTRUSTED" ]; then
|
|
562
|
+
strict_cmd="bun install --frozen-lockfile"
|
|
466
563
|
run_install "$root" "$log" bun install --ignore-scripts --frozen-lockfile
|
|
467
564
|
else
|
|
565
|
+
strict_cmd="bun install"
|
|
468
566
|
run_install "$root" "$log" bun install --ignore-scripts
|
|
469
567
|
fi
|
|
470
568
|
status=$?
|
|
@@ -478,10 +576,52 @@ cmd_install_one() {
|
|
|
478
576
|
if [ $status -eq 0 ]; then
|
|
479
577
|
echo "Installed $root dependencies with $manager (lifecycle scripts disabled)."
|
|
480
578
|
[ -f "$log" ] && tail -n 3 "$log"
|
|
579
|
+
[ -n "$before" ] && rm -f "$before"
|
|
481
580
|
return 0
|
|
482
581
|
fi
|
|
483
582
|
|
|
484
|
-
|
|
583
|
+
print_failed_log "$log"
|
|
584
|
+
|
|
585
|
+
# One lockfile-tolerant retry (CARRICK_INSTALL_LOCKFILE_RETRY=1). A timeout
|
|
586
|
+
# is not retried: a second attempt would only spend the limit again.
|
|
587
|
+
if [ -n "$LOCKFILE_RETRY" ] && [ -z "$no_retry" ] && [ $status -ne 124 ] && [ $status -ne 137 ]; then
|
|
588
|
+
echo "Carrick's lockfile install ($strict_cmd) in $root failed (exit $status); retrying once without the frozen lockfile, lifecycle scripts still disabled."
|
|
589
|
+
snap=$(mktemp -d "${RUNNER_TEMP:-${TMPDIR:-/tmp}}/carrick-retry-snapshot.XXXXXX") || snap=""
|
|
590
|
+
if [ -z "$snap" ]; then
|
|
591
|
+
warn "Carrick could not snapshot $root before retrying its install; the scan will refuse that service rather than index \`any\` through its packages."
|
|
592
|
+
[ -n "$before" ] && rm -f "$before"
|
|
593
|
+
return 0
|
|
594
|
+
fi
|
|
595
|
+
# The tree stays the commit: put the lockfile and manifests back byte for
|
|
596
|
+
# byte afterwards, whatever the retry did (pnpm rewrites its lockfile).
|
|
597
|
+
local file
|
|
598
|
+
for file in $(retry_guarded_files "$manager"); do
|
|
599
|
+
if [ -e "$root/$file" ]; then cp -p "$root/$file" "$snap/$file"; else : >"$snap/absent.$file"; fi
|
|
600
|
+
done
|
|
601
|
+
run_retry_install "$root" "$log" "$manager"
|
|
602
|
+
status=$?
|
|
603
|
+
for file in $(retry_guarded_files "$manager"); do
|
|
604
|
+
if [ -e "$snap/$file" ]; then cp -p "$snap/$file" "$root/$file"; else rm -f "$root/$file"; fi
|
|
605
|
+
done
|
|
606
|
+
rm -rf "$snap"
|
|
607
|
+
if [ $status -eq 0 ]; then
|
|
608
|
+
echo "Installed $root dependencies with $manager after its lockfile install failed; the lockfile and package.json in the tree are unchanged (lifecycle scripts disabled)."
|
|
609
|
+
[ -f "$log" ] && tail -n 3 "$log"
|
|
610
|
+
[ -n "$before" ] && rm -f "$before"
|
|
611
|
+
return 0
|
|
612
|
+
fi
|
|
613
|
+
print_failed_log "$log"
|
|
614
|
+
fi
|
|
615
|
+
|
|
616
|
+
# A root that ends uninstalled keeps no node_modules the attempts created:
|
|
617
|
+
# the pre-flight reads one as prepared, and the scan would read `any` silently.
|
|
618
|
+
if [ -n "$before" ]; then
|
|
619
|
+
local created
|
|
620
|
+
while IFS= read -r created; do
|
|
621
|
+
[ -n "$created" ] && rm -rf "$created"
|
|
622
|
+
done < <(node_modules_dirs "$root" | comm -13 "$before" -)
|
|
623
|
+
rm -f "$before"
|
|
624
|
+
fi
|
|
485
625
|
if [ $status -eq 124 ] || [ $status -eq 137 ]; then
|
|
486
626
|
warn "Carrick's dependency install ($manager) in $root hit the ${INSTALL_TIMEOUT_SECONDS}s limit; the scan will refuse that service rather than index \`any\` through its packages."
|
|
487
627
|
else
|
|
@@ -610,6 +610,13 @@ export interface CheckOptions {
|
|
|
610
610
|
* 7's native tsc (`judgeTscPath`). Tests inject a stand-in to pin the
|
|
611
611
|
* abnormal-termination path. */
|
|
612
612
|
tscPath?: string;
|
|
613
|
+
/** Total time cap for the workspace install, in ms (default 1800000, or
|
|
614
|
+
* `CARRICK_CHECK_INSTALL_TIMEOUT_MS`). Past it the install is killed and
|
|
615
|
+
* every pair reads unverifiable with gate `install:timeout` (carrick#3021). */
|
|
616
|
+
installTimeoutMs?: number;
|
|
617
|
+
/** Silence limit for the workspace install, in ms (default 120000): an
|
|
618
|
+
* install that prints nothing for this long is killed the same way. */
|
|
619
|
+
installIdleTimeoutMs?: number;
|
|
613
620
|
/** Delete the scratch workspace before returning (default true). Tests that
|
|
614
621
|
* inspect the assembled tree pass false. */
|
|
615
622
|
cleanup?: boolean;
|
|
@@ -17,6 +17,38 @@
|
|
|
17
17
|
import type { CheckOptions, CheckProgressPhase, CheckResult } from './api.js';
|
|
18
18
|
import { type RawDiagnostic } from './check-classify.js';
|
|
19
19
|
export type CheckProgress = (phase: CheckProgressPhase, message: string) => void;
|
|
20
|
+
interface SpawnResult {
|
|
21
|
+
code: number | null;
|
|
22
|
+
/** The signal that ended the process, when one did. */
|
|
23
|
+
signal: NodeJS.Signals | null;
|
|
24
|
+
stdout: string;
|
|
25
|
+
stderr: string;
|
|
26
|
+
/** Which time limit killed the process, when one did. */
|
|
27
|
+
timedOut: false | 'total' | 'idle';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The check install's limits (carrick#3021). A healthy install prints
|
|
31
|
+
* progress about once a second (longest gap measured: 1 s), so silence is the
|
|
32
|
+
* sign of a hang: the install is killed after `DEFAULT_INSTALL_IDLE_MS` with
|
|
33
|
+
* no output, and a total cap bounds one that keeps printing. Both are far
|
|
34
|
+
* above the slowest healthy run measured (54 s, install plus judge).
|
|
35
|
+
* `CARRICK_CHECK_INSTALL_TIMEOUT_MS` replaces the total cap.
|
|
36
|
+
*/
|
|
37
|
+
export declare const DEFAULT_INSTALL_IDLE_MS = 120000;
|
|
38
|
+
export declare const DEFAULT_INSTALL_TIMEOUT_MS = 1800000;
|
|
39
|
+
/** The total cap: the option, else the environment, else the default. */
|
|
40
|
+
export declare function installTotalLimitMs(opt: number | undefined, env?: NodeJS.ProcessEnv): number;
|
|
41
|
+
/**
|
|
42
|
+
* Why the check install did not finish, as a gate and a sentence the verdicts
|
|
43
|
+
* carry. A hang and a refused connection are named apart from a plain failure.
|
|
44
|
+
*/
|
|
45
|
+
export declare function installFailure(install: Pick<SpawnResult, 'timedOut' | 'stderr' | 'stdout'>, limits: {
|
|
46
|
+
idleMs: number;
|
|
47
|
+
totalMs: number;
|
|
48
|
+
}): {
|
|
49
|
+
gate: string;
|
|
50
|
+
reason: string;
|
|
51
|
+
};
|
|
20
52
|
/**
|
|
21
53
|
* Whether a process's stderr carries V8's fatal heap-exhaustion line
|
|
22
54
|
* (`Reached heap limit`, `Ineffective mark-compacts near heap limit`, and the
|
|
@@ -113,3 +145,4 @@ export declare function judgeLabel(tscPath: string): string;
|
|
|
113
145
|
/** Run the deterministic check phase. Async: install + tsc run off the event
|
|
114
146
|
* loop so the sidecar stays responsive and can emit keepalive frames. */
|
|
115
147
|
export declare function runCheck(opts: CheckOptions, onProgress?: CheckProgress): Promise<CheckResult>;
|
|
148
|
+
export {};
|
|
@@ -28,17 +28,104 @@ import { openProbeProgram, probeDeepFindings } from './check-deep.js';
|
|
|
28
28
|
import { onlyDeclaredOpenAny } from './deep-walk.js';
|
|
29
29
|
import { pairFieldReports } from './check-fields.js';
|
|
30
30
|
import { pairDispatchUnions } from './check-union.js';
|
|
31
|
-
function runProcess(command, args, cwd, env) {
|
|
31
|
+
function runProcess(command, args, cwd, env, limits) {
|
|
32
32
|
return new Promise((resolve, reject) => {
|
|
33
|
-
const
|
|
33
|
+
const limited = limits?.totalMs !== undefined || limits?.idleMs !== undefined;
|
|
34
|
+
// With a limit the child leads its own process group, so the kill takes
|
|
35
|
+
// the package manager's workers with it and `close` can fire.
|
|
36
|
+
const child = spawn(command, args, {
|
|
37
|
+
cwd,
|
|
38
|
+
env,
|
|
39
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
40
|
+
detached: limited,
|
|
41
|
+
});
|
|
34
42
|
let stdout = '';
|
|
35
43
|
let stderr = '';
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
let timedOut = false;
|
|
45
|
+
const kill = (kind) => {
|
|
46
|
+
timedOut = kind;
|
|
47
|
+
try {
|
|
48
|
+
process.kill(-child.pid, 'SIGKILL');
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
child.kill('SIGKILL');
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const totalTimer = limits?.totalMs === undefined ? undefined : setTimeout(() => kill('total'), limits.totalMs);
|
|
55
|
+
let idleTimer;
|
|
56
|
+
const armIdle = () => {
|
|
57
|
+
if (limits?.idleMs === undefined)
|
|
58
|
+
return;
|
|
59
|
+
if (idleTimer)
|
|
60
|
+
clearTimeout(idleTimer);
|
|
61
|
+
idleTimer = setTimeout(() => kill('idle'), limits.idleMs);
|
|
62
|
+
};
|
|
63
|
+
const clearTimers = () => {
|
|
64
|
+
if (totalTimer)
|
|
65
|
+
clearTimeout(totalTimer);
|
|
66
|
+
if (idleTimer)
|
|
67
|
+
clearTimeout(idleTimer);
|
|
68
|
+
};
|
|
69
|
+
armIdle();
|
|
70
|
+
child.stdout.on('data', (d) => {
|
|
71
|
+
stdout += d.toString();
|
|
72
|
+
armIdle();
|
|
73
|
+
});
|
|
74
|
+
child.stderr.on('data', (d) => {
|
|
75
|
+
stderr += d.toString();
|
|
76
|
+
armIdle();
|
|
77
|
+
});
|
|
78
|
+
child.on('error', (e) => {
|
|
79
|
+
clearTimers();
|
|
80
|
+
reject(e);
|
|
81
|
+
});
|
|
82
|
+
child.on('close', (code, signal) => {
|
|
83
|
+
clearTimers();
|
|
84
|
+
resolve({ code, signal, stdout, stderr, timedOut });
|
|
85
|
+
});
|
|
40
86
|
});
|
|
41
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* The check install's limits (carrick#3021). A healthy install prints
|
|
90
|
+
* progress about once a second (longest gap measured: 1 s), so silence is the
|
|
91
|
+
* sign of a hang: the install is killed after `DEFAULT_INSTALL_IDLE_MS` with
|
|
92
|
+
* no output, and a total cap bounds one that keeps printing. Both are far
|
|
93
|
+
* above the slowest healthy run measured (54 s, install plus judge).
|
|
94
|
+
* `CARRICK_CHECK_INSTALL_TIMEOUT_MS` replaces the total cap.
|
|
95
|
+
*/
|
|
96
|
+
export const DEFAULT_INSTALL_IDLE_MS = 120_000;
|
|
97
|
+
export const DEFAULT_INSTALL_TIMEOUT_MS = 1_800_000;
|
|
98
|
+
/** The total cap: the option, else the environment, else the default. */
|
|
99
|
+
export function installTotalLimitMs(opt, env = process.env) {
|
|
100
|
+
if (opt !== undefined)
|
|
101
|
+
return opt;
|
|
102
|
+
const fromEnv = Number(env.CARRICK_CHECK_INSTALL_TIMEOUT_MS);
|
|
103
|
+
return Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : DEFAULT_INSTALL_TIMEOUT_MS;
|
|
104
|
+
}
|
|
105
|
+
/** What the package manager prints when it cannot reach the registry. */
|
|
106
|
+
const REGISTRY_UNREACHABLE = /ERR_PNPM_META_FETCH_FAIL|ERR_PNPM_FETCH_|ENOTFOUND|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENETUNREACH/;
|
|
107
|
+
/**
|
|
108
|
+
* Why the check install did not finish, as a gate and a sentence the verdicts
|
|
109
|
+
* carry. A hang and a refused connection are named apart from a plain failure.
|
|
110
|
+
*/
|
|
111
|
+
export function installFailure(install, limits) {
|
|
112
|
+
if (install.timedOut) {
|
|
113
|
+
const idle = install.timedOut === 'idle';
|
|
114
|
+
return {
|
|
115
|
+
gate: 'install:timeout',
|
|
116
|
+
reason: idle
|
|
117
|
+
? `workspace dependency install printed nothing for ${Math.round(limits.idleMs / 1000)}s and was stopped (registry unreachable or stuck)`
|
|
118
|
+
: `workspace dependency install did not finish within ${Math.round(limits.totalMs / 1000)}s (registry unreachable or too slow)`,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (REGISTRY_UNREACHABLE.test(`${install.stderr}\n${install.stdout}`)) {
|
|
122
|
+
return {
|
|
123
|
+
gate: 'install:registry-unreachable',
|
|
124
|
+
reason: 'workspace dependency install failed: the package registry could not be reached',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return { gate: 'install:failed', reason: 'workspace dependency install failed' };
|
|
128
|
+
}
|
|
42
129
|
/** The tail V8 prints on every fatal heap-exhaustion line. */
|
|
43
130
|
const HEAP_OUT_OF_MEMORY = 'JavaScript heap out of memory';
|
|
44
131
|
/**
|
|
@@ -309,18 +396,23 @@ export async function runCheck(opts, onProgress) {
|
|
|
309
396
|
const degraded = [];
|
|
310
397
|
// ---- Install (async, off the event loop) --------------------------------
|
|
311
398
|
progress('installing', 'installing pinned dependencies');
|
|
312
|
-
const
|
|
313
|
-
|
|
399
|
+
const installLimits = {
|
|
400
|
+
idleMs: opts.installIdleTimeoutMs ?? DEFAULT_INSTALL_IDLE_MS,
|
|
401
|
+
totalMs: installTotalLimitMs(opts.installTimeoutMs),
|
|
402
|
+
};
|
|
403
|
+
const install = await runProcess(pnpmPath, ['install'], ws.workspaceDir, undefined, installLimits);
|
|
404
|
+
if (install.code !== 0 || install.timedOut) {
|
|
405
|
+
const failure = installFailure(install, installLimits);
|
|
314
406
|
const installError = scrubPaths((install.stderr || install.stdout).trim().slice(0, 2000), scrubCtx);
|
|
315
407
|
// `errors` says why the run failed (carrick#1821); each pair the install
|
|
316
408
|
// stopped says it too, because the client reads every pair's own verdict
|
|
317
409
|
// on a failed check (carrick#1833).
|
|
318
|
-
errors.push(
|
|
410
|
+
errors.push(`${failure.reason}${installError && failure.gate !== 'install:timeout' ? `: ${installError}` : ''}`);
|
|
319
411
|
for (const s of opts.stubs) {
|
|
320
412
|
degraded.push({ service_name: s.service_name, reason: 'workspace install failed' });
|
|
321
413
|
}
|
|
322
414
|
const verdicts = sortVerdicts([
|
|
323
|
-
...unverifiableAll(probing,
|
|
415
|
+
...unverifiableAll(probing, failure.gate, `${failure.reason}; compatibility cannot be verified.` +
|
|
324
416
|
(installError ? ` Installer output: ${installError}` : '')),
|
|
325
417
|
// Capture-decay verdicts stand regardless of the install outcome.
|
|
326
418
|
...preGated,
|
|
@@ -643,7 +643,7 @@ function handleListLibrarySurface(request) {
|
|
|
643
643
|
const { claimsVerifier } = projectComponents();
|
|
644
644
|
const fromDir = path.resolve(projectLoader.getRepoRoot(), request.from_dir);
|
|
645
645
|
log(`Listing the declared surface of ${request.packages.length} specifier(s) from ${fromDir}`);
|
|
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 });
|
|
646
|
+
const { surfaces, surface_sha256 } = claimsVerifier.listSurface(fromDir, request.packages, request.max_entries ?? SURFACE_MAX_ENTRIES, request.exports ?? {}, { handlers: request.handlers, types: request.types, resultCandidates: request.result_candidates, maxHandlerMembers: request.max_handler_members });
|
|
647
647
|
return { request_id: request.request_id, status: 'success', surfaces, surface_sha256 };
|
|
648
648
|
}
|
|
649
649
|
catch (err) {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
*/
|
|
38
38
|
import { ts, type Project } from 'ts-morph';
|
|
39
39
|
import { type PackageDirectoryOf } from './position-rows.js';
|
|
40
|
-
import type { ClaimSlot, LibraryCheck, LibrarySurface, SemanticsCheck, SemanticsModule, SemanticsDeclaration, SemanticsResult } from './types.js';
|
|
40
|
+
import type { ClaimSlot, LibraryCheck, LibrarySurface, ResultShape, SemanticsCheck, SemanticsModule, SemanticsDeclaration, SemanticsResult } from './types.js';
|
|
41
41
|
/** How one check came out, before it is stamped with its claim and receiver. */
|
|
42
42
|
type Outcome = {
|
|
43
43
|
verdict: 'verified';
|
|
@@ -55,6 +55,12 @@ type Outcome = {
|
|
|
55
55
|
* itself verified (carrick#2968). Only `request_member_missing`.
|
|
56
56
|
*/
|
|
57
57
|
requestDropped?: string;
|
|
58
|
+
/**
|
|
59
|
+
* In-process only: on a type receiver, the declarations its type stands
|
|
60
|
+
* on (`declaredSymbols`), the key a reader joins a receiver by
|
|
61
|
+
* (carrick#3046).
|
|
62
|
+
*/
|
|
63
|
+
receiverTypes?: readonly ts.Declaration[];
|
|
58
64
|
} | {
|
|
59
65
|
verdict: 'failed' | 'unchecked';
|
|
60
66
|
reason: string;
|
|
@@ -198,6 +204,22 @@ export declare function declarationKey(declaration: ts.Node): string;
|
|
|
198
204
|
*/
|
|
199
205
|
export interface LabelledMembers {
|
|
200
206
|
sends: ReadonlyMap<string, ClaimSlot>;
|
|
207
|
+
/**
|
|
208
|
+
* The properties a service assigns to reply (`form: set`, carrick#3047),
|
|
209
|
+
* by {@link declarationKey} of the property, with the slot the assigned
|
|
210
|
+
* value sits in (always argument 0). Never in `sends`.
|
|
211
|
+
*/
|
|
212
|
+
sets: ReadonlyMap<string, ClaimSlot>;
|
|
213
|
+
/**
|
|
214
|
+
* The route members whose handler's return is the reply (`returns` on a
|
|
215
|
+
* receive op, carrick#3054), by {@link declarationKey} of the route member,
|
|
216
|
+
* with the slot the handler sits in and the part of the return that holds
|
|
217
|
+
* the body. Never in `sends`.
|
|
218
|
+
*/
|
|
219
|
+
returns: ReadonlyMap<string, {
|
|
220
|
+
handler: ClaimSlot;
|
|
221
|
+
result?: ResultShape;
|
|
222
|
+
}>;
|
|
201
223
|
bodies: ReadonlySet<string>;
|
|
202
224
|
/** How each label read came out (`verified`, or the reason it was not), for the log. */
|
|
203
225
|
outcomes?: Readonly<Record<string, number>>;
|
|
@@ -206,6 +228,8 @@ export interface LabelledMembers {
|
|
|
206
228
|
export interface SurfaceOptions {
|
|
207
229
|
/** Each member's `handlers` (carrick#2674 S3). */
|
|
208
230
|
handlers?: boolean;
|
|
231
|
+
/** `types[]` widened, `settable`, `types_left_out` (carrick#3050). */
|
|
232
|
+
types?: boolean;
|
|
209
233
|
/** Each signature's `result_candidates` (carrick#2817). */
|
|
210
234
|
resultCandidates?: boolean;
|
|
211
235
|
/** Handler-parameter members the whole call may list (default `HANDLER_LISTING_BUDGET`, carrick#3016). */
|