@smoothbricks/nx-plugin 0.5.6 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1095 -360
- package/dist/.build-inputs.json +138 -0
- package/dist/bin/smoo-nx-cargo-toolchain.d.ts +3 -0
- package/dist/bin/smoo-nx-cargo-toolchain.d.ts.map +1 -0
- package/dist/bin/smoo-nx-cargo-toolchain.js +8 -0
- package/dist/bin/smoo-nx-forbidden-spellings.d.ts +3 -0
- package/dist/bin/smoo-nx-forbidden-spellings.d.ts.map +1 -0
- package/dist/bin/smoo-nx-forbidden-spellings.js +32 -0
- package/dist/bin/smoo-nx-nextest-timings.d.ts +3 -0
- package/dist/bin/smoo-nx-nextest-timings.d.ts.map +1 -0
- package/dist/bin/smoo-nx-nextest-timings.js +28 -0
- package/dist/bounded-test-policy.d.ts +1 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +14 -15
- package/dist/build-state-output-policy.d.ts +95 -1
- package/dist/build-state-output-policy.d.ts.map +1 -1
- package/dist/build-state-output-policy.js +368 -30
- package/dist/bun-lock-scope.d.ts +44 -0
- package/dist/bun-lock-scope.d.ts.map +1 -0
- package/dist/bun-lock-scope.js +97 -0
- package/dist/cargo-build-script-env.d.ts +49 -0
- package/dist/cargo-build-script-env.d.ts.map +1 -0
- package/dist/cargo-build-script-env.js +324 -0
- package/dist/cargo-closure-input.d.ts +31 -4
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +66 -6
- package/dist/cargo-retention-hook.d.ts +17 -0
- package/dist/cargo-retention-hook.d.ts.map +1 -0
- package/dist/cargo-retention-hook.js +85 -0
- package/dist/cargo-source-hash.d.ts +25 -7
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +108 -43
- package/dist/cargo-toolchain-paths.d.ts +40 -0
- package/dist/cargo-toolchain-paths.d.ts.map +1 -0
- package/dist/cargo-toolchain-paths.js +84 -0
- package/dist/cargo-toolchain-policy.d.ts +25 -8
- package/dist/cargo-toolchain-policy.d.ts.map +1 -1
- package/dist/cargo-toolchain-policy.js +39 -5
- package/dist/cargo-workspace.d.ts +10 -4
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +65 -95
- package/dist/cross-check-policy.d.ts +9 -9
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +11 -11
- package/dist/disk-command-policy.d.ts.map +1 -1
- package/dist/disk-command-policy.js +1 -0
- package/dist/ensure-built-receipt.d.ts +13 -5
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +126 -47
- package/dist/ensure-built-witness.d.ts +27 -8
- package/dist/ensure-built-witness.d.ts.map +1 -1
- package/dist/ensure-built-witness.js +45 -15
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +9 -1
- package/dist/eslint-config-closure.d.ts +7 -0
- package/dist/eslint-config-closure.d.ts.map +1 -0
- package/dist/eslint-config-closure.js +346 -0
- package/dist/executors/all-verdicts/executor.d.ts +35 -0
- package/dist/executors/all-verdicts/executor.d.ts.map +1 -0
- package/dist/executors/all-verdicts/executor.js +133 -0
- package/dist/executors/all-verdicts/schema.d.ts +10 -0
- package/dist/executors/all-verdicts/schema.d.ts.map +1 -0
- package/dist/executors/all-verdicts/schema.js +2 -0
- package/dist/executors/bounded-exec/bounds.d.ts +56 -0
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
- package/dist/executors/bounded-exec/bounds.js +43 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts +33 -36
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +54 -119
- package/dist/executors/bounded-exec/executor.d.ts +19 -12
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +371 -239
- package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
- package/dist/executors/bounded-exec/gateway-lease.js +81 -28
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
- package/dist/executors/bounded-exec/lease-wait.d.ts +43 -0
- package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
- package/dist/executors/bounded-exec/lease-wait.js +68 -0
- package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
- package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
- package/dist/executors/bounded-exec/lock-wait.js +108 -0
- package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
- package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
- package/dist/executors/bounded-exec/owned-subtree.js +178 -0
- package/dist/executors/bounded-exec/progress.d.ts +4 -1
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +5 -2
- package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
- package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-attach.js +207 -0
- package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
- package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-detach.js +207 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp.js +1213 -399
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts +4 -4
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/run-cpu-pool.js +20 -30
- package/dist/executors/bounded-exec/runner-hook.js +14 -5
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
- package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
- package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
- package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
- package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
- package/dist/executors/bounded-exec/runtime-pin.js +167 -0
- package/dist/executors/bounded-exec/schema.d.ts +18 -1
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +40 -11
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +88 -19
- package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
- package/dist/executors/cargo-zigbuild/executor.js +67 -12
- package/dist/executors/clean-outputs/executor.js +1 -0
- package/dist/executors/scriptc-native/executor.d.ts +79 -0
- package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
- package/dist/executors/scriptc-native/executor.js +367 -0
- package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
- package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
- package/dist/executors/scriptc-native/ffi-paths.js +25 -0
- package/dist/executors/scriptc-native/schema.d.ts +34 -0
- package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
- package/dist/executors/scriptc-native/schema.js +1 -0
- package/dist/executors/typescript-emit/executor.d.ts +3 -1
- package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
- package/dist/executors/typescript-emit/executor.js +164 -33
- package/dist/forbidden-spelling-policy.d.ts +56 -0
- package/dist/forbidden-spelling-policy.d.ts.map +1 -0
- package/dist/forbidden-spelling-policy.js +176 -0
- package/dist/generators/create-package/generator.d.ts.map +1 -1
- package/dist/generators/create-package/generator.js +3 -4
- package/dist/graph-input-contract.d.ts +14 -0
- package/dist/graph-input-contract.d.ts.map +1 -1
- package/dist/graph-input-contract.js +67 -2
- package/dist/index.d.ts +23 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +676 -215
- package/dist/managed-assets.d.ts +2 -0
- package/dist/managed-assets.d.ts.map +1 -1
- package/dist/managed-files/files.d.ts +3 -3
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +28 -3
- package/dist/managed-files/managed-format.d.ts.map +1 -1
- package/dist/managed-files/managed-format.js +1 -0
- package/dist/nextest-code-bound.js +1 -0
- package/dist/nextest-timings.d.ts +35 -0
- package/dist/nextest-timings.d.ts.map +1 -0
- package/dist/nextest-timings.js +168 -0
- package/dist/owned-installation.d.ts +6 -5
- package/dist/owned-installation.d.ts.map +1 -1
- package/dist/owned-installation.js +150 -26
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +2 -3
- package/dist/process-children.d.ts +7 -0
- package/dist/process-children.d.ts.map +1 -0
- package/dist/process-children.darwin.d.ts +7 -0
- package/dist/process-children.darwin.d.ts.map +1 -0
- package/dist/process-children.darwin.js +13 -0
- package/dist/process-children.js +14 -0
- package/dist/process-children.linux.d.ts +8 -0
- package/dist/process-children.linux.d.ts.map +1 -0
- package/dist/process-children.linux.js +25 -0
- package/dist/process-group.d.ts +108 -0
- package/dist/process-group.d.ts.map +1 -0
- package/dist/process-group.js +171 -0
- package/dist/process-listing.d.ts +7 -0
- package/dist/process-listing.d.ts.map +1 -0
- package/dist/process-listing.js +51 -0
- package/dist/producer-receipts.d.ts +8 -2
- package/dist/producer-receipts.d.ts.map +1 -1
- package/dist/producer-receipts.js +75 -48
- package/dist/task-graph-policy.d.ts +21 -0
- package/dist/task-graph-policy.d.ts.map +1 -0
- package/dist/task-graph-policy.js +91 -0
- package/dist/test-timings.js +4 -4
- package/dist/test-walk-policy.d.ts +14 -5
- package/dist/test-walk-policy.d.ts.map +1 -1
- package/dist/test-walk-policy.js +8 -2
- package/dist/testing.d.ts +73 -28
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +217 -223
- package/dist/tool-bins.d.ts +33 -0
- package/dist/tool-bins.d.ts.map +1 -0
- package/dist/tool-bins.js +72 -0
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +3 -4
- package/dist/wait-why-policy.d.ts +28 -0
- package/dist/wait-why-policy.d.ts.map +1 -0
- package/dist/wait-why-policy.js +223 -0
- package/dist/workspace-config-policy.d.ts +14 -8
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +60 -16
- package/dist/workspace-manifest.d.ts +41 -6
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/dist/workspace-manifest.js +57 -0
- package/executors.json +21 -1
- package/loader.js +2 -0
- package/managed/raw/envrc +11 -0
- package/managed/raw/patches/nx@23.2.1.patch +2840 -199
- package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
- package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
- package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
- package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
- package/managed/raw/tooling/direnv/developer-links.ts +464 -25
- package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
- package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
- package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
- package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
- package/managed/raw/tooling/direnv/repo-path +68 -6
- package/managed/raw/tooling/direnv/secret-references.ts +13 -4
- package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
- package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
- package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
- package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
- package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
- package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
- package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
- package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
- package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
- package/package.json +77 -13
- package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
- package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
- package/src/bin/smoo-nx-nextest-timings.ts +31 -0
- package/src/bounded-test-policy.ts +12 -14
- package/src/build-state-output-policy.ts +458 -34
- package/src/bun-lock-scope.ts +108 -0
- package/src/cargo-build-script-env.ts +265 -0
- package/src/cargo-closure-input.ts +74 -7
- package/src/cargo-retention-hook.ts +94 -0
- package/src/cargo-source-hash.ts +138 -41
- package/src/cargo-toolchain-paths.ts +95 -0
- package/src/cargo-toolchain-policy.ts +49 -5
- package/src/cargo-workspace.ts +72 -123
- package/src/cross-check-policy.ts +12 -10
- package/src/disk-command-policy.ts +1 -0
- package/src/ensure-built-receipt.ts +132 -39
- package/src/ensure-built-witness.ts +62 -10
- package/src/ensure-built.ts +11 -1
- package/src/eslint-config-closure.ts +357 -0
- package/src/executors/all-verdicts/executor.ts +164 -0
- package/src/executors/all-verdicts/schema.json +22 -0
- package/src/executors/all-verdicts/schema.ts +10 -0
- package/src/executors/bounded-exec/bounds.ts +76 -0
- package/src/executors/bounded-exec/cpu-pool.ts +51 -117
- package/src/executors/bounded-exec/executor.ts +423 -259
- package/src/executors/bounded-exec/gateway-lease.ts +82 -33
- package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
- package/src/executors/bounded-exec/lease-wait.ts +89 -0
- package/src/executors/bounded-exec/lock-wait.ts +141 -0
- package/src/executors/bounded-exec/owned-subtree.ts +235 -0
- package/src/executors/bounded-exec/progress.ts +9 -3
- package/src/executors/bounded-exec/ram-attach.ts +238 -0
- package/src/executors/bounded-exec/ram-detach.ts +226 -0
- package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
- package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
- package/src/executors/bounded-exec/ram-temp.ts +1497 -460
- package/src/executors/bounded-exec/run-cpu-pool.ts +22 -30
- package/src/executors/bounded-exec/runner-hook.ts +14 -6
- package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
- package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
- package/src/executors/bounded-exec/runtime-pin.ts +232 -0
- package/src/executors/bounded-exec/schema.json +11 -2
- package/src/executors/bounded-exec/schema.ts +19 -1
- package/src/executors/bounded-exec/verdict.ts +137 -34
- package/src/executors/cargo-zigbuild/executor.ts +82 -8
- package/src/executors/clean-outputs/executor.ts +1 -0
- package/src/executors/scriptc-native/executor.ts +394 -0
- package/src/executors/scriptc-native/ffi-paths.ts +29 -0
- package/src/executors/scriptc-native/schema.json +60 -0
- package/src/executors/scriptc-native/schema.ts +34 -0
- package/src/executors/typescript-emit/executor.ts +205 -38
- package/src/forbidden-spelling-policy.ts +226 -0
- package/src/generators/create-package/generator.ts +7 -7
- package/src/graph-input-contract.ts +61 -2
- package/src/index.ts +792 -225
- package/src/managed-assets.ts +3 -0
- package/src/managed-files/files.ts +28 -3
- package/src/managed-files/managed-format.ts +1 -0
- package/src/nextest-code-bound.ts +1 -0
- package/src/nextest-timings.ts +106 -0
- package/src/owned-installation.ts +150 -23
- package/src/package-target-policy.ts +2 -3
- package/src/process-children.darwin.ts +14 -0
- package/src/process-children.linux.ts +33 -0
- package/src/process-children.ts +22 -0
- package/src/process-group.ts +209 -0
- package/src/process-listing.ts +54 -0
- package/src/producer-receipts.ts +68 -45
- package/src/task-graph-policy.ts +98 -0
- package/src/test-walk-policy.ts +23 -8
- package/src/testing.ts +240 -232
- package/src/tool-bins.ts +108 -0
- package/src/typecheck-test-policy.ts +2 -3
- package/src/wait-why-policy.ts +226 -0
- package/src/workspace-config-policy.ts +63 -15
- package/src/workspace-manifest.ts +89 -6
- package/test-timings.json +123 -98
- package/dist/bin/smoo-nx-failures.d.ts +0 -3
- package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
- package/dist/bin/smoo-nx-failures.js +0 -3
- package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
- package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
- package/dist/bin/smoo-nx-nextest-extract.js +0 -42
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
- package/dist/failure-summary.d.ts +0 -5
- package/dist/failure-summary.d.ts.map +0 -1
- package/dist/failure-summary.js +0 -118
- package/dist/nextest-extraction.d.ts +0 -117
- package/dist/nextest-extraction.d.ts.map +0 -1
- package/dist/nextest-extraction.js +0 -303
- package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
- package/src/__tests__/cargo-closure-filesets.ts +0 -94
- package/src/__tests__/cargo-closure-fixture.ts +0 -113
- package/src/__tests__/counted-cargo-process.ts +0 -286
- package/src/__tests__/counted-cargo.ts +0 -713
- package/src/__tests__/directory-change.ts +0 -27
- package/src/__tests__/fixture-cargo-home.ts +0 -36
- package/src/__tests__/fixture-nx-env.ts +0 -193
- package/src/__tests__/owned-installation.ts +0 -13
- package/src/__tests__/past-tick.ts +0 -12
- package/src/__tests__/progress-clock.ts +0 -43
- package/src/__tests__/runtime-input.ts +0 -23
- package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
- package/src/bin/smoo-nx-failures.ts +0 -4
- package/src/bin/smoo-nx-nextest-extract.ts +0 -44
- package/src/bounded-test-policy.test.ts +0 -1029
- package/src/build-state-output-policy.test.ts +0 -115
- package/src/bun-bootstrap.test.ts +0 -102
- package/src/bun-file-packages.test.ts +0 -47
- package/src/cargo-closure-filesets.test.ts +0 -63
- package/src/cargo-closure-input.property.test.ts +0 -50
- package/src/cargo-closure-input.test.ts +0 -506
- package/src/cargo-closure-key.test.ts +0 -240
- package/src/cargo-resolve-cache.test.ts +0 -1181
- package/src/cargo-source-hash.test.ts +0 -707
- package/src/cargo-workspace.test.ts +0 -615
- package/src/cross-check-policy.test.ts +0 -316
- package/src/disk-command-policy.test.ts +0 -61
- package/src/ensure-built-receipt.test.ts +0 -279
- package/src/ensure-built-witness.test.ts +0 -688
- package/src/ensure-built.test.ts +0 -1462
- package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
- package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
- package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
- package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
- package/src/executors/bounded-exec/executor-host.test.ts +0 -800
- package/src/executors/bounded-exec/executor.test.ts +0 -1819
- package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
- package/src/executors/bounded-exec/progress.test.ts +0 -139
- package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
- package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
- package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
- package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
- package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
- package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
- package/src/executors/bounded-exec/verdict.test.ts +0 -545
- package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
- package/src/executors/clean-outputs/executor.test.ts +0 -20
- package/src/executors/typescript-emit/executor.test.ts +0 -83
- package/src/failure-summary.ts +0 -119
- package/src/generators/bounded-test-targets/generator.test.ts +0 -138
- package/src/generators/bun-test-tracing/generator.test.ts +0 -250
- package/src/generators/create-package/generator.test.ts +0 -190
- package/src/generators/make-public/generator.test.ts +0 -137
- package/src/graph-input-contract.test.ts +0 -379
- package/src/host-controller-wiring.test.ts +0 -31
- package/src/index.test.ts +0 -3319
- package/src/linked-snapshots.nx.test.ts +0 -254
- package/src/managed-files/forgejo-artifact.test.ts +0 -395
- package/src/managed-files/generator.test.ts +0 -243
- package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
- package/src/managed-files/json-edit.test.ts +0 -216
- package/src/managed-files/managed-content.test.ts +0 -166
- package/src/managed-files/managed-format-json.test.ts +0 -308
- package/src/managed-files/repo-path.test.ts +0 -172
- package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
- package/src/managed-files/trace-db-artifact.test.ts +0 -7
- package/src/managed-files/tree-permissions.test.ts +0 -109
- package/src/managed-files/tree.test.ts +0 -123
- package/src/manifest-hash.test.ts +0 -219
- package/src/nextest-code-bound.test.ts +0 -161
- package/src/nextest-extraction.test.ts +0 -216
- package/src/nextest-extraction.ts +0 -371
- package/src/nextest-partitions.test.ts +0 -501
- package/src/nx-cache-bound.test.ts +0 -109
- package/src/nx-cache-restore-mtime.test.ts +0 -170
- package/src/nx-daemon-claim.test.ts +0 -279
- package/src/nx-daemon-idle-cpu.test.ts +0 -80
- package/src/nx-daemon-idle-policy.test.ts +0 -111
- package/src/nx-daemon-ignore-files.test.ts +0 -210
- package/src/nx-daemon-root-normalization.test.ts +0 -105
- package/src/nx-daemon-start-never.test.ts +0 -292
- package/src/nx-daemon-validity.test.ts +0 -1055
- package/src/nx-dot-input-policy.test.ts +0 -353
- package/src/nx-failure-life-cycles.test.ts +0 -207
- package/src/nx-files-archive-racy.test.ts +0 -97
- package/src/nx-foreign-workspace-env.test.ts +0 -329
- package/src/nx-incomplete-run-summary.test.ts +0 -70
- package/src/nx-plugin-load-errors.test.ts +0 -120
- package/src/nx-project-graph-errors.test.ts +0 -70
- package/src/nx-project-resolution-cache.test.ts +0 -176
- package/src/nx-raw-inputs.test.ts +0 -166
- package/src/nx-resident-graph-workers.test.ts +0 -112
- package/src/nx-run-information.test.ts +0 -118
- package/src/nx-skipped-task-exit.test.ts +0 -180
- package/src/nx-state-location.test.ts +0 -63
- package/src/nx-store-resolution.test.ts +0 -81
- package/src/nx-task-graph-cycles.test.ts +0 -148
- package/src/nx-task-output-lease.test.ts +0 -550
- package/src/nx-use-local.test.ts +0 -105
- package/src/owned-installation.test.ts +0 -105
- package/src/package-target-policy.test.ts +0 -1014
- package/src/producer-receipts.test.ts +0 -285
- package/src/release-config-policy.test.ts +0 -311
- package/src/runtime-input.test.ts +0 -393
- package/src/serial-group-wiring.test.ts +0 -326
- package/src/task-history-namespace.test.ts +0 -181
- package/src/task-results.test.ts +0 -228
- package/src/test-clock-policy.test.ts +0 -338
- package/src/test-program.test.ts +0 -303
- package/src/test-timings.test.ts +0 -240
- package/src/test-walk-policy.test.ts +0 -620
- package/src/testing.test.ts +0 -509
- package/src/typecheck-test-policy.test.ts +0 -1468
- package/src/typescript-resolution.test.ts +0 -76
- package/src/version-actions.test.ts +0 -80
- package/src/workspace-config-policy.test.ts +0 -737
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { connect } from 'node:net';
|
|
2
|
+
import typia from 'typia';
|
|
3
|
+
import { type CpuLeaseProgress, CpuLeaseWait } from './lease-wait.js';
|
|
4
|
+
|
|
5
|
+
const isCpuProgress = typia.createEquals<CpuLeaseProgress>();
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
|
-
* The client half of a lease held on the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
8
|
+
* The client half of a lease held on a unix socket: the gateway's host disk-lifecycle lease
|
|
9
|
+
* (`disk-lease.ts`) and a parent's CPU pool (`cpu-pool.ts`) speak the same protocol
|
|
10
|
+
* (specs/cowshed/05_gateway.md, "Disk-lifecycle lease").
|
|
7
11
|
*
|
|
8
12
|
* The client writes one request line and keeps the connection open without half-closing it. The
|
|
9
13
|
* gateway answers `queued` at once and `granted` when the lease is the client's, and the lease
|
|
10
14
|
* lasts until the client closes the connection, so a client that dies holding one releases it with
|
|
11
|
-
* its socket.
|
|
12
|
-
*
|
|
15
|
+
* its socket. The caller decides what a refusal means: disk work may run unleased, while CPU
|
|
16
|
+
* admission fails rather than running outside its parent's count.
|
|
13
17
|
*/
|
|
14
18
|
|
|
15
19
|
/** The cowshed gateway's control socket, at the store root every peer agrees on. */
|
|
@@ -25,12 +29,15 @@ export interface LeaseBounds {
|
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
|
-
* Why a
|
|
29
|
-
*
|
|
30
|
-
*
|
|
32
|
+
* Why a lease is not held: no gateway listens, the gateway predates this kind of lease, the gateway
|
|
33
|
+
* knows the lease but predates a field the request names (it refuses the field at once), or any
|
|
34
|
+
* other refusal, silence or breakage.
|
|
31
35
|
*/
|
|
32
36
|
export type UnleasedCause = 'absent' | 'predates' | 'predates-field' | 'other';
|
|
33
37
|
|
|
38
|
+
/** A refusal: the lease is not held, and why. */
|
|
39
|
+
export type Unleased = { granted: false; cause: UnleasedCause; reason: string; code?: string };
|
|
40
|
+
|
|
34
41
|
/**
|
|
35
42
|
* A granted lease with its `granted` answer, held until released, or why there is none. `closed`
|
|
36
43
|
* resolves when the connection really closes: after `release`, when the gateway ends it, or when
|
|
@@ -38,20 +45,20 @@ export type UnleasedCause = 'absent' | 'predates' | 'predates-field' | 'other';
|
|
|
38
45
|
*/
|
|
39
46
|
export type HeldLease =
|
|
40
47
|
| { granted: true; answer: Readonly<Record<string, unknown>>; release: () => void; closed: Promise<void> }
|
|
41
|
-
|
|
|
48
|
+
| Unleased;
|
|
42
49
|
|
|
43
50
|
/**
|
|
44
51
|
* Ask the gateway at `socket` for the lease `request` names, `what` in its messages ("disk
|
|
45
|
-
* leases", "the CPU
|
|
46
|
-
* EOF, so a request not queued within
|
|
47
|
-
*
|
|
48
|
-
*
|
|
52
|
+
* leases", "the parent CPU pool"). A gateway from before one-line requests says nothing until it reads
|
|
53
|
+
* EOF, so a disk request not queued within its ack bound is half-closed to read that gateway's
|
|
54
|
+
* refusal. CPU admission instead uses its own control/silence policy: no compatibility half-close,
|
|
55
|
+
* and no total queue bound (specs/cowshed/05_gateway.md, "Deadlines").
|
|
49
56
|
*/
|
|
50
57
|
export function holdLease(
|
|
51
58
|
socket: string,
|
|
52
59
|
request: Readonly<Record<string, unknown>>,
|
|
53
60
|
what: string,
|
|
54
|
-
bounds: LeaseBounds,
|
|
61
|
+
bounds: LeaseBounds | CpuLeaseWait,
|
|
55
62
|
onQueued?: () => void,
|
|
56
63
|
): Promise<HeldLease> {
|
|
57
64
|
// `Promise.withResolvers` would read better but needs lib es2024; this package inherits lib
|
|
@@ -60,6 +67,8 @@ export function holdLease(
|
|
|
60
67
|
const promise = new Promise<HeldLease>((settled) => {
|
|
61
68
|
resolve = settled;
|
|
62
69
|
});
|
|
70
|
+
const cpu = bounds instanceof CpuLeaseWait ? bounds : null;
|
|
71
|
+
// eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: CPU connect/send is control-bounded and its answer heartbeat-silence-bounded by armCpu(); disk acknowledgement and half-close are bounded below, and a queued disk lease lasts until its holder releases it
|
|
63
72
|
const connection = connect(socket);
|
|
64
73
|
// `closed` is made when a consumer reads it, so a lease nobody watches allocates no promise. The
|
|
65
74
|
// flag, not `connection.destroyed`, says the socket really closed: `destroy()` sets that flag before
|
|
@@ -86,47 +95,79 @@ export function holdLease(
|
|
|
86
95
|
clearTimeout(timer);
|
|
87
96
|
timer = setTimeout(onExpiry, ms);
|
|
88
97
|
};
|
|
98
|
+
const armCpu = (): void => {
|
|
99
|
+
if (cpu === null || state === 'settled') return;
|
|
100
|
+
wait(cpu.remainingMs(), () => {
|
|
101
|
+
cpu.look();
|
|
102
|
+
const failure = cpu.expired();
|
|
103
|
+
if (failure === null) {
|
|
104
|
+
armCpu();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
unleased(
|
|
108
|
+
`${failure.code}: cpu-pool: the lease endpoint ${socket} exceeded ${failure.boundMs} ms (waited ${failure.elapsedMs} ms; last progress: ${failure.last})`,
|
|
109
|
+
'other',
|
|
110
|
+
failure.code,
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
armCpu();
|
|
89
115
|
const answer = (line: string) => {
|
|
116
|
+
if (state === 'settled') return;
|
|
90
117
|
let parsed: unknown;
|
|
91
118
|
try {
|
|
92
119
|
parsed = JSON.parse(line);
|
|
93
120
|
} catch {
|
|
94
|
-
unleased(`the
|
|
121
|
+
unleased(`the lease endpoint ${socket} answered something that is not an answer: ${line}`);
|
|
95
122
|
return;
|
|
96
123
|
}
|
|
97
124
|
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
98
|
-
unleased(`the
|
|
125
|
+
unleased(`the lease endpoint ${socket} answered something that is not an answer: ${line}`);
|
|
99
126
|
return;
|
|
100
127
|
}
|
|
101
128
|
const fields: Readonly<Record<string, unknown>> = Object.fromEntries(Object.entries(parsed));
|
|
129
|
+
if (cpu !== null && isCpuProgress(parsed)) {
|
|
130
|
+
if (!cpu.heartbeat(parsed.progress)) {
|
|
131
|
+
unleased(`the lease endpoint ${socket} sent non-advancing CPU progress: ${line}`);
|
|
132
|
+
} else {
|
|
133
|
+
armCpu();
|
|
134
|
+
}
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
102
137
|
const lease = fields.lease;
|
|
103
138
|
if (fields.ok !== true) {
|
|
104
139
|
const error = String(fields.error ?? '');
|
|
105
140
|
const why = `${String(fields.code ?? 'refused')}: ${error}`;
|
|
106
141
|
if (state === 'half-closed' || error.endsWith('unknown gateway control operation')) {
|
|
107
|
-
unleased(
|
|
142
|
+
unleased(
|
|
143
|
+
`the lease endpoint ${socket} predates ${what} (${why}); restart it with \`cowshed setup\``,
|
|
144
|
+
'predates',
|
|
145
|
+
);
|
|
108
146
|
} else if (error.endsWith('contains an unknown field')) {
|
|
109
147
|
unleased(
|
|
110
|
-
`the
|
|
148
|
+
`the lease endpoint ${socket} predates a field of ${what} (${why}); restart it with \`cowshed setup\``,
|
|
111
149
|
'predates-field',
|
|
112
150
|
);
|
|
113
151
|
} else {
|
|
114
152
|
unleased(
|
|
115
|
-
`the
|
|
153
|
+
`the lease endpoint ${socket} refused the lease (${why})`,
|
|
116
154
|
'other',
|
|
117
155
|
typeof fields.code === 'string' ? fields.code : undefined,
|
|
118
156
|
);
|
|
119
157
|
}
|
|
120
158
|
} else if (state === 'half-closed') {
|
|
121
|
-
unleased(
|
|
159
|
+
unleased(`the lease endpoint ${socket} did not queue the request in time; it is alive but overloaded`);
|
|
122
160
|
} else if (state === 'asked' && lease === 'queued') {
|
|
123
161
|
state = 'queued';
|
|
124
162
|
onQueued?.();
|
|
125
|
-
|
|
126
|
-
|
|
163
|
+
if (bounds instanceof CpuLeaseWait) {
|
|
164
|
+
bounds.queued();
|
|
165
|
+
armCpu();
|
|
166
|
+
} else if (bounds.grantMs === null) {
|
|
127
167
|
clearTimeout(timer);
|
|
128
168
|
} else {
|
|
129
|
-
|
|
169
|
+
const grantMs = bounds.grantMs;
|
|
170
|
+
wait(grantMs, () => unleased(`the lease endpoint ${socket} granted nothing within ${grantMs} ms`));
|
|
130
171
|
}
|
|
131
172
|
} else if (state === 'queued' && lease === 'granted') {
|
|
132
173
|
settle({
|
|
@@ -136,22 +177,30 @@ export function holdLease(
|
|
|
136
177
|
get closed() {
|
|
137
178
|
closed ??= socketClosed
|
|
138
179
|
? Promise.resolve()
|
|
139
|
-
:
|
|
180
|
+
: // eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a held lease's connection lasts as long as its holder keeps it; release() destroys it on this side, and the gateway's own end closes it too
|
|
181
|
+
new Promise<void>((done) => connection.once('close', () => done()));
|
|
140
182
|
return closed;
|
|
141
183
|
},
|
|
142
184
|
});
|
|
143
185
|
} else {
|
|
144
|
-
unleased(`the
|
|
186
|
+
unleased(`the lease endpoint ${socket} answered out of turn: ${line}`);
|
|
145
187
|
}
|
|
146
188
|
};
|
|
147
189
|
connection.on('connect', () => {
|
|
148
190
|
state = 'asked';
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
191
|
+
if (bounds instanceof CpuLeaseWait) {
|
|
192
|
+
connection.write(`${JSON.stringify(request)}\n`, () => {
|
|
193
|
+
bounds.sent();
|
|
194
|
+
armCpu();
|
|
195
|
+
});
|
|
196
|
+
} else {
|
|
197
|
+
connection.write(`${JSON.stringify(request)}\n`);
|
|
198
|
+
wait(bounds.ackMs, () => {
|
|
199
|
+
state = 'half-closed';
|
|
200
|
+
connection.end();
|
|
201
|
+
wait(bounds.afterCloseMs, () => unleased(`the lease endpoint ${socket} answered nothing`));
|
|
202
|
+
});
|
|
203
|
+
}
|
|
155
204
|
});
|
|
156
205
|
connection.on('data', (chunk: Buffer) => {
|
|
157
206
|
buffered += chunk.toString('utf8');
|
|
@@ -163,14 +212,14 @@ export function holdLease(
|
|
|
163
212
|
});
|
|
164
213
|
connection.on('error', (error) => {
|
|
165
214
|
if (state === 'connecting') {
|
|
166
|
-
unleased(`
|
|
215
|
+
unleased(`nothing answers for ${what} at ${socket} (${error.message})`, 'absent');
|
|
167
216
|
} else {
|
|
168
217
|
unleased(error.message);
|
|
169
218
|
}
|
|
170
219
|
});
|
|
171
220
|
connection.on('close', () => {
|
|
172
221
|
socketClosed = true;
|
|
173
|
-
unleased(
|
|
222
|
+
unleased(`the lease connection for ${what} at ${socket} closed`);
|
|
174
223
|
});
|
|
175
224
|
return promise;
|
|
176
225
|
}
|
|
@@ -1,9 +1,52 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import { describeTeardown, killProcessGroupNow, TEARDOWN_PATIENCE } from '../../process-group.js';
|
|
2
3
|
import { type ProcessEntry, withDescendants } from '../../testing.js';
|
|
4
|
+
import {
|
|
5
|
+
describeHolders,
|
|
6
|
+
type LockWait,
|
|
7
|
+
lockCandidates,
|
|
8
|
+
lockWaits,
|
|
9
|
+
parseLsofFields,
|
|
10
|
+
parseLsofTable,
|
|
11
|
+
} from './lock-wait.js';
|
|
3
12
|
|
|
4
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The pre-expiry capture window. Stack samples set it: under load averages of 27-52 on 18 cores one `sudo -n sample`
|
|
15
|
+
* took 1.1-4.6 s, and in a five-second window two of eight real captures lost their sample at its limit.
|
|
16
|
+
*/
|
|
17
|
+
export const HANG_CAPTURE_MS = 10_000;
|
|
5
18
|
const MAX_PROBE_BYTES = 4 * 1024 * 1024;
|
|
6
19
|
const PS_FIELDS = 'pid=,ppid=,pgid=,stat=,%cpu=,etime=,lstart=,command=';
|
|
20
|
+
/**
|
|
21
|
+
* Stack samples: `sample` suspends a process every millisecond for one second and reports its threads' call graph. The
|
|
22
|
+
* runner and at most this many leaf processes are sampled, all at once. `-mayDie` is not passed: it reads symbols
|
|
23
|
+
* before sampling and measured about a second slower under load, and a process that exits mid-sample is a raced
|
|
24
|
+
* capture all the same.
|
|
25
|
+
*/
|
|
26
|
+
const MAX_SAMPLED_LEAVES = 4;
|
|
27
|
+
const SAMPLE_SECONDS = 1;
|
|
28
|
+
/**
|
|
29
|
+
* A process census's limit. The stack samples run until the closing census is this far from the window's end.
|
|
30
|
+
*/
|
|
31
|
+
const CENSUS_LIMIT_MS = 1_000;
|
|
32
|
+
/**
|
|
33
|
+
* lsof's mount-table fallback (darwin libproc dmnt.c, readmnt()): a mount it cannot stat(), such as one detaching under a
|
|
34
|
+
* concurrent shed, is kept with its mount-table device. Descriptors come per process from libproc, so this warning omits
|
|
35
|
+
* none of the selected processes' rows.
|
|
36
|
+
*/
|
|
37
|
+
const LSOF_MOUNT_FALLBACK =
|
|
38
|
+
/^lsof: WARNING: can't stat\(\) \S+ file system .*\n {6}Output information may be incomplete\.\n {6}assuming "dev=[0-9a-f]+" from mount table\n/gm;
|
|
39
|
+
|
|
40
|
+
/** The lsof stderr that makes its census incomplete: everything except its mount-table fallback. */
|
|
41
|
+
function lsofFaults(stderr: string): string {
|
|
42
|
+
return stderr.replace(LSOF_MOUNT_FALLBACK, '').trim();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A `sample` report up to its binary-image list: its header and call graph name the stacks; the load map is bulk. */
|
|
46
|
+
function callGraph(report: string): string {
|
|
47
|
+
const end = report.indexOf('\nBinary Images:');
|
|
48
|
+
return (end === -1 ? report : report.slice(0, end)).trim();
|
|
49
|
+
}
|
|
7
50
|
|
|
8
51
|
export interface HangDiagnostics {
|
|
9
52
|
startedAtMs: number;
|
|
@@ -11,6 +54,8 @@ export interface HangDiagnostics {
|
|
|
11
54
|
/** Positive when the observation completed before the idle expiry. */
|
|
12
55
|
offsetFromExpiryMs: number;
|
|
13
56
|
outcome: 'holders' | 'none' | 'incomplete';
|
|
57
|
+
/** Lock waits the snapshot names: empty unless the capture is complete, and always empty without the open-file census. */
|
|
58
|
+
lockWaits: readonly LockWait[];
|
|
14
59
|
text: string;
|
|
15
60
|
}
|
|
16
61
|
|
|
@@ -53,8 +98,10 @@ export function captureHangDiagnostics(
|
|
|
53
98
|
`Hang snapshot: pid=${request.pid} pgid=${request.pgid ?? 'unknown'} startedAtMs=${startedAtMs}`,
|
|
54
99
|
'Open files and process observations are evidence, not proof of a contested lock or its owner.',
|
|
55
100
|
];
|
|
56
|
-
|
|
101
|
+
const active = new Set<string>();
|
|
102
|
+
const during = (): string => (active.size === 0 ? 'process census' : [...active].join(', '));
|
|
57
103
|
let finished = false;
|
|
104
|
+
let waits: readonly LockWait[] = [];
|
|
58
105
|
// This package targets lib es2022, which does not declare Promise.withResolvers.
|
|
59
106
|
return new Promise((resolve) => {
|
|
60
107
|
const finish = (outcome: HangDiagnostics['outcome']): void => {
|
|
@@ -70,16 +117,17 @@ export function captureHangDiagnostics(
|
|
|
70
117
|
capturedAtMs,
|
|
71
118
|
offsetFromExpiryMs,
|
|
72
119
|
outcome,
|
|
120
|
+
lockWaits: outcome === 'incomplete' ? [] : waits,
|
|
73
121
|
text: `${lines.join('\n')}\nHang snapshot outcome=${outcome} capturedAtMs=${capturedAtMs} offsetFromExpiryMs=${offsetFromExpiryMs}\n`,
|
|
74
122
|
});
|
|
75
123
|
};
|
|
76
124
|
const timer = setTimeout(() => {
|
|
77
|
-
lines.push(`Capture incomplete: ${budgetMs}ms deadline reached during ${
|
|
125
|
+
lines.push(`Capture incomplete: ${budgetMs}ms deadline reached during ${during()}; no empty-holder conclusion.`);
|
|
78
126
|
finish('incomplete');
|
|
79
127
|
}, budgetMs);
|
|
80
128
|
const cancelled = (): void => {
|
|
81
129
|
if (finished) return;
|
|
82
|
-
lines.push(`Capture cancelled during ${
|
|
130
|
+
lines.push(`Capture cancelled during ${during()}; its progress generation is no longer current.`);
|
|
83
131
|
finish('incomplete');
|
|
84
132
|
};
|
|
85
133
|
request.signal?.addEventListener('abort', cancelled, { once: true });
|
|
@@ -93,7 +141,7 @@ export function captureHangDiagnostics(
|
|
|
93
141
|
return;
|
|
94
142
|
}
|
|
95
143
|
const probe = async (name: string, file: string, args: readonly string[], limitMs: number) => {
|
|
96
|
-
active
|
|
144
|
+
active.add(name);
|
|
97
145
|
lines.push(`${name}: ${file} ${args.join(' ')}`);
|
|
98
146
|
const result = await source.probe(
|
|
99
147
|
file,
|
|
@@ -101,6 +149,7 @@ export function captureHangDiagnostics(
|
|
|
101
149
|
Math.max(0, Math.min(limitMs, endsAtMs - Date.now())),
|
|
102
150
|
controller.signal,
|
|
103
151
|
);
|
|
152
|
+
active.delete(name);
|
|
104
153
|
if (!finished) {
|
|
105
154
|
lines.push(
|
|
106
155
|
`${name}: ${result.status}${result.status === 'exited' ? ` code=${result.code}` : ` ${result.detail}`}`,
|
|
@@ -110,8 +159,8 @@ export function captureHangDiagnostics(
|
|
|
110
159
|
return result;
|
|
111
160
|
};
|
|
112
161
|
const census = async (name: string): Promise<ObservedProcess[] | null> => {
|
|
113
|
-
// Bare `ps`, resolved through PATH like testing.ts's
|
|
114
|
-
const result = await probe(name, 'ps', ['-A', '-o', PS_FIELDS],
|
|
162
|
+
// Bare `ps`, resolved through PATH like testing.ts's processesOf: NixOS has no /bin/ps.
|
|
163
|
+
const result = await probe(name, 'ps', ['-A', '-o', PS_FIELDS], CENSUS_LIMIT_MS);
|
|
115
164
|
if (finished) return null;
|
|
116
165
|
if (result.status !== 'exited' || result.code !== 0) {
|
|
117
166
|
lines.push(`${name}: could not inspect the process table; not an empty process tree.`);
|
|
@@ -152,6 +201,41 @@ export function captureHangDiagnostics(
|
|
|
152
201
|
}
|
|
153
202
|
return tree;
|
|
154
203
|
};
|
|
204
|
+
/**
|
|
205
|
+
* One-second call stacks of the runner and of its tree's leaf processes, taken at once: a stack names the call a
|
|
206
|
+
* process waits in, which the open-file census cannot. A sample sudo refuses, or one that does not answer, is named
|
|
207
|
+
* as no stack for that process; stacks never change the holder outcome.
|
|
208
|
+
*/
|
|
209
|
+
const stackSamples = async (tree: readonly ObservedProcess[]): Promise<void> => {
|
|
210
|
+
const live = tree.filter((entry) => !entry.stat.startsWith('Z'));
|
|
211
|
+
const parents = new Set(live.map((entry) => entry.ppid));
|
|
212
|
+
const leaves = live.filter((entry) => entry.pid !== request.pid && !parents.has(entry.pid));
|
|
213
|
+
const omitted = leaves.slice(MAX_SAMPLED_LEAVES).map((entry) => entry.pid);
|
|
214
|
+
if (omitted.length > 0)
|
|
215
|
+
lines.push(
|
|
216
|
+
`Stack samples bounded to the runner and ${MAX_SAMPLED_LEAVES} leaf processes; not sampled: pid ${omitted.join(', ')}`,
|
|
217
|
+
);
|
|
218
|
+
const limitMs = endsAtMs - Date.now() - CENSUS_LIMIT_MS;
|
|
219
|
+
const sampled = [request.pid, ...leaves.slice(0, MAX_SAMPLED_LEAVES).map((entry) => entry.pid)];
|
|
220
|
+
await Promise.all(
|
|
221
|
+
sampled.map(async (pid) => {
|
|
222
|
+
const name = `stack sample pid ${pid}`;
|
|
223
|
+
// `-file /dev/stdout` writes the report to the probe's pipe alone, not also to a root-owned file in /tmp.
|
|
224
|
+
const args = ['-n', 'sample', String(pid), String(SAMPLE_SECONDS), '-file', '/dev/stdout'];
|
|
225
|
+
const result = await probe(name, 'sudo', args, limitMs);
|
|
226
|
+
if (finished) return;
|
|
227
|
+
const report = callGraph(result.stdout);
|
|
228
|
+
if (result.status === 'exited' && result.code === 0 && report !== '') {
|
|
229
|
+
lines.push(`${name} (${SAMPLE_SECONDS}s; binary image list omitted):\n${report}`);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (report !== '') lines.push(`Partial ${name} output:\n${report}`);
|
|
233
|
+
lines.push(
|
|
234
|
+
`${name}: no stack; sudo -n sample did not answer, so the call this process waits in is not observed.`,
|
|
235
|
+
);
|
|
236
|
+
}),
|
|
237
|
+
);
|
|
238
|
+
};
|
|
155
239
|
const collect = async (): Promise<void> => {
|
|
156
240
|
const before = await census('ps before');
|
|
157
241
|
if (finished) return;
|
|
@@ -159,30 +243,62 @@ export function captureHangDiagnostics(
|
|
|
159
243
|
let incomplete = false;
|
|
160
244
|
let observed = before.length > 0;
|
|
161
245
|
if (source.platform === 'darwin') {
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const answered = (result: HangProbeResult): boolean =>
|
|
167
|
-
result.status === 'exited' && (result.code === 0 || (result.code === 1 && result.stderr.trim() === ''));
|
|
168
|
-
if (!answered(resources)) {
|
|
169
|
-
incomplete = true;
|
|
170
|
-
if (resources.stdout.trim() !== '')
|
|
171
|
-
lines.push(`Partial privileged lsof output:\n${resources.stdout.trimEnd()}`);
|
|
172
|
-
lines.push(
|
|
173
|
-
'Privileged resource census unavailable; fallback is ordinary-user visibility only, not proof of no holders.',
|
|
174
|
-
);
|
|
175
|
-
resources = await probe('lsof user-scoped fallback', 'lsof', args, 1_000);
|
|
246
|
+
const openFiles = async (): Promise<void> => {
|
|
247
|
+
const args = ['-nP', '-p', before.map((entry) => entry.pid).join(',')];
|
|
248
|
+
// Bare `sudo`/`lsof` through PATH, like `ps` above: NixOS provides neither /usr/bin/sudo nor /usr/sbin/lsof.
|
|
249
|
+
let resources = await probe('lsof privileged', 'sudo', ['-n', 'lsof', ...args], 1_500);
|
|
176
250
|
if (finished) return;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
251
|
+
const answered = (result: HangProbeResult): boolean =>
|
|
252
|
+
result.status === 'exited' &&
|
|
253
|
+
(result.code === 0 || (result.code === 1 && lsofFaults(result.stderr) === ''));
|
|
254
|
+
if (!answered(resources)) {
|
|
255
|
+
incomplete = true;
|
|
256
|
+
if (resources.stdout.trim() !== '')
|
|
257
|
+
lines.push(`Partial privileged lsof output:\n${resources.stdout.trimEnd()}`);
|
|
258
|
+
lines.push(
|
|
259
|
+
'Privileged resource census unavailable; fallback is ordinary-user visibility only, not proof of no holders.',
|
|
260
|
+
);
|
|
261
|
+
resources = await probe('lsof user-scoped fallback', 'lsof', args, 1_000);
|
|
262
|
+
if (finished) return;
|
|
263
|
+
}
|
|
264
|
+
if (resources.stdout.trim() !== '')
|
|
265
|
+
lines.push(`lsof open files/sockets (not contested-lock proof):\n${resources.stdout.trimEnd()}`);
|
|
266
|
+
if (!answered(resources) || lsofFaults(resources.stderr) !== '') incomplete = true;
|
|
267
|
+
else if (resources.stderr.trim() !== '')
|
|
268
|
+
lines.push(
|
|
269
|
+
'lsof warned only that it could not stat() the named mounts and kept their mount-table devices; that omits no descriptor of the selected processes.',
|
|
270
|
+
);
|
|
271
|
+
observed = resources.stdout.trim() !== '';
|
|
272
|
+
if (!observed && answered(resources))
|
|
273
|
+
lines.push('lsof reported no open-file matches within its stated visibility.');
|
|
274
|
+
// A lock wait needs a complete census of the run's files: a regular file the run holds on a numbered descriptor
|
|
275
|
+
// that another process also holds open. One privileged lsof names those holders; a probe that did not answer
|
|
276
|
+
// makes the capture incomplete, never an empty holder set.
|
|
277
|
+
const rows = incomplete ? [] : parseLsofTable(resources.stdout);
|
|
278
|
+
const candidates = lockCandidates(rows);
|
|
279
|
+
if (candidates.length > 0) {
|
|
280
|
+
const holders = await probe(
|
|
281
|
+
'lsof lock holders',
|
|
282
|
+
'sudo',
|
|
283
|
+
['-n', 'lsof', '-nP', '-F', 'pcn', '--', ...candidates],
|
|
284
|
+
1_500,
|
|
285
|
+
);
|
|
286
|
+
if (finished) return;
|
|
287
|
+
const openers =
|
|
288
|
+
answered(holders) && lsofFaults(holders.stderr) === '' ? parseLsofFields(holders.stdout) : null;
|
|
289
|
+
if (openers === null) {
|
|
290
|
+
incomplete = true;
|
|
291
|
+
lines.push('Lock holder census incomplete; no lock wait is named.');
|
|
292
|
+
} else {
|
|
293
|
+
waits = lockWaits(rows, new Set(before.map((entry) => entry.pid)), openers);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
await Promise.all([openFiles(), stackSamples(before)]);
|
|
298
|
+
if (finished) return;
|
|
184
299
|
} else {
|
|
185
300
|
lines.push(`Open-file census not provided on ${source.platform}; observations below name processes only.`);
|
|
301
|
+
lines.push(`Stack samples not provided on ${source.platform}; no blocking call is observed.`);
|
|
186
302
|
}
|
|
187
303
|
const after = await census('ps after');
|
|
188
304
|
if (finished) return;
|
|
@@ -205,16 +321,40 @@ export function captureHangDiagnostics(
|
|
|
205
321
|
incomplete = true;
|
|
206
322
|
lines.push('Process identities or membership changed during capture; open-file census raced.');
|
|
207
323
|
}
|
|
324
|
+
if (!incomplete) {
|
|
325
|
+
for (const wait of waits) {
|
|
326
|
+
lines.push(
|
|
327
|
+
`Lock wait (open-handle evidence, not a kernel lock owner): ${wait.path} open in the run by pid ${wait.waiters.join(', ')} and outside it by ${describeHolders(wait.holders)}`,
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
208
331
|
finish(incomplete ? 'incomplete' : observed ? 'holders' : 'none');
|
|
209
332
|
};
|
|
210
333
|
void collect().catch((error: unknown) => {
|
|
211
334
|
if (finished) return;
|
|
212
|
-
lines.push(`Capture incomplete during ${
|
|
335
|
+
lines.push(`Capture incomplete during ${during()}: ${error instanceof Error ? error.message : String(error)}`);
|
|
213
336
|
finish('incomplete');
|
|
214
337
|
});
|
|
215
338
|
});
|
|
216
339
|
}
|
|
217
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Ends a probe at its limit without waiting for it, and says whether its group still lists members. An ordinary probe
|
|
343
|
+
* runs as this user, so SIGKILL to its process group ends it and anything it started, and the kill is repeated while
|
|
344
|
+
* the group lists members, since one forked as the signal goes out survives it. `sudo` keeps this user's real uid but
|
|
345
|
+
* runs its command as root, which no signal from this user reaches: a group SIGKILL would end sudo alone and orphan
|
|
346
|
+
* the command. Signalled itself, sudo relays SIGTERM to its command and exits only after it. While sudo starts it
|
|
347
|
+
* holds root's real uid, and this throws EPERM. A probe is its caller's child and stays unreaped while the caller
|
|
348
|
+
* waits here, and the kernel lists it as a member of its own group until then, so a group left listed is expected.
|
|
349
|
+
*/
|
|
350
|
+
export function stopProbe(file: string, pid: number): boolean {
|
|
351
|
+
if (file === 'sudo') {
|
|
352
|
+
process.kill(pid, 'SIGTERM');
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
return killProcessGroupNow(pid, TEARDOWN_PATIENCE);
|
|
356
|
+
}
|
|
357
|
+
|
|
218
358
|
/** A probe owns its group and output pipes; its deadline never waits for an unresponsive child to reap. */
|
|
219
359
|
function runProbe(
|
|
220
360
|
file: string,
|
|
@@ -248,9 +388,11 @@ function runProbe(
|
|
|
248
388
|
let killFailure = '';
|
|
249
389
|
if (child.pid !== undefined) {
|
|
250
390
|
try {
|
|
251
|
-
|
|
391
|
+
if (stopProbe(file, child.pid)) {
|
|
392
|
+
killFailure = `; probe group cleanup: ${describeTeardown({ command: file, group: child.pid })}`;
|
|
393
|
+
}
|
|
252
394
|
} catch (error) {
|
|
253
|
-
killFailure = `; probe group cleanup: ${error instanceof Error ? error.message : String(error)}`;
|
|
395
|
+
killFailure = `; probe ${file === 'sudo' ? 'stop through sudo' : 'group cleanup'}: ${error instanceof Error ? error.message : String(error)}`;
|
|
254
396
|
}
|
|
255
397
|
}
|
|
256
398
|
finish({ status, detail: detail + killFailure, stdout, stderr });
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** Peer wait classes from specs/cowshed/05_gateway.md, "Deadlines". */
|
|
2
|
+
export const CONTROL_MS = 5_000;
|
|
3
|
+
export const HEARTBEAT_MS = 5_000;
|
|
4
|
+
export const HEARTBEAT_SILENCE_MS = 15_000;
|
|
5
|
+
|
|
6
|
+
/** The CPU pool's actor-authored progress, shared by its server and lease client. */
|
|
7
|
+
export interface CpuLeaseProgress {
|
|
8
|
+
ok: true;
|
|
9
|
+
progress: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type CpuWaitState = { kind: 'sending' } | { kind: 'waiting'; at: number; last: string; sequence: number };
|
|
13
|
+
|
|
14
|
+
/** A failed wait, not a failed command: expiry ends this client's admission only. */
|
|
15
|
+
export interface CpuWaitFailure {
|
|
16
|
+
code: 'TIMEOUT' | 'SILENT';
|
|
17
|
+
boundMs: number;
|
|
18
|
+
elapsedMs: number;
|
|
19
|
+
last: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Pure CPU admission policy; its injected monotonic clock performs no I/O or scheduling. */
|
|
23
|
+
export class CpuLeaseWait {
|
|
24
|
+
private readonly started: number;
|
|
25
|
+
private state: CpuWaitState = { kind: 'sending' };
|
|
26
|
+
/** When the client last looked at its wait or read a frame of it. */
|
|
27
|
+
private looked: number;
|
|
28
|
+
|
|
29
|
+
constructor(private readonly now: () => number = () => performance.now()) {
|
|
30
|
+
this.started = now();
|
|
31
|
+
this.looked = this.started;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The kernel took the complete request; only peer silence bounds the answer from here. */
|
|
35
|
+
sent(): void {
|
|
36
|
+
this.looked = this.now();
|
|
37
|
+
if (this.state.kind === 'sending') {
|
|
38
|
+
this.state = { kind: 'waiting', at: this.now(), last: 'request sent', sequence: 0 };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A queue entry proves actor progress, not a deadline for returning a token. */
|
|
43
|
+
queued(): void {
|
|
44
|
+
this.sent();
|
|
45
|
+
if (this.state.kind === 'waiting') {
|
|
46
|
+
this.state = { ...this.state, at: this.now(), last: 'queued' };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Only an advancing actor sequence renews silence; duplicate or invalid progress proves nothing. */
|
|
51
|
+
heartbeat(sequence: number): boolean {
|
|
52
|
+
this.sent();
|
|
53
|
+
if (this.state.kind !== 'waiting' || !Number.isSafeInteger(sequence) || sequence <= this.state.sequence)
|
|
54
|
+
return false;
|
|
55
|
+
this.state = { kind: 'waiting', at: this.now(), last: `heartbeat ${sequence}`, sequence };
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The client looks at its wait before judging it. A look later than the silence bound plus a heartbeat
|
|
61
|
+
* after its previous look or frame means the client's own event loop did not run (a loaded host), so
|
|
62
|
+
* what the pool sent meanwhile is unread: the pool gets one heartbeat more from now (05_gateway.md
|
|
63
|
+
* "Deadlines"). A client that looks in time judges the pool at the bound.
|
|
64
|
+
*/
|
|
65
|
+
look(): void {
|
|
66
|
+
const now = this.now();
|
|
67
|
+
if (this.state.kind === 'waiting' && now - this.looked > HEARTBEAT_SILENCE_MS + HEARTBEAT_MS) {
|
|
68
|
+
this.state = { ...this.state, at: Math.max(this.state.at, now - HEARTBEAT_SILENCE_MS + HEARTBEAT_MS) };
|
|
69
|
+
}
|
|
70
|
+
this.looked = now;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Milliseconds until the current phase's bound, clipped at zero. */
|
|
74
|
+
remainingMs(): number {
|
|
75
|
+
const due = this.state.kind === 'sending' ? this.started + CONTROL_MS : this.state.at + HEARTBEAT_SILENCE_MS;
|
|
76
|
+
return Math.max(0, due - this.now());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** No total queue age exists: an advancing heartbeat keeps the wait alive indefinitely. */
|
|
80
|
+
expired(): CpuWaitFailure | null {
|
|
81
|
+
if (this.remainingMs() > 0) return null;
|
|
82
|
+
return {
|
|
83
|
+
code: this.state.kind === 'sending' ? 'TIMEOUT' : 'SILENT',
|
|
84
|
+
boundMs: this.state.kind === 'sending' ? CONTROL_MS : HEARTBEAT_SILENCE_MS,
|
|
85
|
+
elapsedMs: this.now() - this.started,
|
|
86
|
+
last: this.state.kind === 'sending' ? 'connecting or sending request' : this.state.last,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|