@smoothbricks/nx-plugin 0.6.1 → 0.6.2
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 +55 -54
- package/dist/.build-inputs.json +3 -3
- package/dist/cargo-retention-hook.d.ts +8 -1
- package/dist/cargo-retention-hook.d.ts.map +1 -1
- package/dist/cargo-retention-hook.js +12 -1
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +25 -1
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +6 -0
- package/managed/raw/envrc +15 -0
- package/managed/raw/tooling/direnv/developer-links.ts +12 -1
- package/managed/raw/tooling/direnv/devenv.smoo.nix +21 -8
- package/managed/raw/tooling/direnv/linked-snapshots.ts +50 -13
- package/managed/raw/tooling/direnv/setup-environment.ts +23 -11
- package/managed/raw/tooling/git-hooks/pre-push.sh +4 -1
- package/managed/raw/tooling/git-reword-commit +151 -0
- package/package.json +4 -4
- package/src/cargo-retention-hook.ts +12 -1
- package/src/executors/bounded-exec/hang-diagnostics.ts +28 -1
- package/src/managed-files/files.ts +6 -0
- package/test-timings.json +1 -0
package/README.md
CHANGED
|
@@ -231,60 +231,61 @@ The plugin discovers Cargo workspaces beside Nx project manifests at any depth:
|
|
|
231
231
|
only grows. After each Nx run that executed a Cargo producer (an inferred target that builds, checks or tests into the
|
|
232
232
|
target directory, marked by its `cargoProducer` metadata: `cargo-test-archive`, `cargo-test`, `cargo-lint`,
|
|
233
233
|
`cargo-lint-cross`, mutation, bench, and the napi and wasm builds), the plugin's `postTasksExecution` runs its Cargo
|
|
234
|
-
retention hook, which calls `@smoothbricks/cargo-retain` for each Cargo workspace that is due for maintenance.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
target
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
234
|
+
retention hook, which calls `@smoothbricks/cargo-retain` for each Cargo workspace that is due for maintenance. In an
|
|
235
|
+
mbx project, whose canonical environment names `MBX_CACHE_DIR` beside `MBX_TARGET_VIEWS=1`, the targets are mbx's to
|
|
236
|
+
collect and the hook does nothing. Automatic passes run at most once per 24 hours after a successful completed pass,
|
|
237
|
+
one that reclaimed in every root; its existing receipt records completion time and configuration/workspace/target
|
|
238
|
+
identity. A not-due hook reports that scheduling decision without locks, a fingerprint scan, cleanup or receipt
|
|
239
|
+
replacement. It does not claim newer outputs were inspected or the graph is unchanged. Busy, refused, invalid, foreign
|
|
240
|
+
or backward-clock receipt evidence never postpones the next attempt. The first executed producer after the interval
|
|
241
|
+
runs a current pass; cache replays, fetch and noop tasks start none. Manual preview and apply always run fresh. Due
|
|
242
|
+
passes reclaim superseded generations under `<profile>/build/<package>/<META>/`. They keep the newest generation, by
|
|
243
|
+
last use, of each unit identity of a workspace member (identity is every fingerprint field but its edges, source state
|
|
244
|
+
and toolchain, which is `rustc` and the `--sysroot` flag; integers read exactly, so a newer toolchain supersedes an
|
|
245
|
+
older one), every unit used in the last 24 hours (`-Zmtime-on-use` stamps each use; cowshed exports
|
|
246
|
+
`CARGO_UNSTABLE_MTIME_ON_USE=true` to every host shell and job of a Cargo project, and a repository outside cowshed
|
|
247
|
+
sets `[unstable] mtime-on-use = true`), and the transitive dependency closure of those across every profile, host and
|
|
248
|
+
cross alike. A root whose hash files show no stamp (none newer than its compile by more than 24 hours) reports
|
|
249
|
+
`recency-unknown: mtime-on-use off`: its last use is then only its last compile. A profile that holds a legacy layout
|
|
250
|
+
beside the current one is read for the current one, and its legacy entries are retained as `legacy-layout`. A pass
|
|
251
|
+
holds every profile's Cargo locks without waiting: one held lock skips the pass as `busy`, and a profile it cannot
|
|
252
|
+
read (unreadable fingerprint, missing `build/` or lock, or a legacy layout's records alone) refuses the whole pass, as
|
|
253
|
+
does a lock it cannot attempt at all, with the reason named: under Node, macOS takes its `flock(2)`s in-process
|
|
254
|
+
(`open(2)` with `O_EXLOCK | O_NONBLOCK`) and starts no helper, and other platforms hold them in a perl child, so a
|
|
255
|
+
sandbox that refuses to exec perl, like a lock file that cannot be opened, refuses the pass instead of failing the
|
|
256
|
+
run. The compiled CLI opens and locks through a small C wrapper (`native/flock.c`) that captures `errno` immediately.
|
|
257
|
+
Each provider's canonical refusal retains the operation, exact lock path, actual host errno and OS cause: only
|
|
258
|
+
contention is `busy`; any other failure refuses the pass. The hook only reports outcomes and never fails the run it
|
|
259
|
+
follows: whatever escapes a pass is logged as a warning, and the next workspace is still tried. It moves each
|
|
260
|
+
reclaimed generation into the profile's `.smoo-retention-trash/` under that hold, recording its inode first, and
|
|
261
|
+
unlinks it after letting go. Each proven generation gets a synchronous, non-symlink-following inode census and one
|
|
262
|
+
native recursive removal, not an awaited lstat/unlink for every artifact. The census counts internal hardlinks once;
|
|
263
|
+
the pass ledger drops an inode only when its last link is removed, so bytes freed and bytes still linked outside the
|
|
264
|
+
removed generations remain distinct. The manifest's root identity is rechecked immediately before removal. A failed
|
|
265
|
+
removal is an I/O failure, not a successful reclaim or a new completed maintenance receipt. It writes its last report
|
|
266
|
+
to `<target>/.smoo-cargo-retention.json`. Cargo's root-relative fingerprint paths distinguish cross profiles from
|
|
267
|
+
nested target roots under the lock; mixed, foreign or unprovable cross-profile roots refuse the pass rather than
|
|
268
|
+
silently dropping their dependency edges. That scan finds a nested target root (`target/cargo-lint`,
|
|
269
|
+
`target/cargo-lint-cross`) by locking and reading its depth-two profile like the target's own, so a pass held or
|
|
270
|
+
refused there reaches no nested root. Each nested root then gets the same pass over its own profiles, host and cross,
|
|
271
|
+
under only their Cargo locks and the target's one retention lock, one root after another: units never depend across
|
|
272
|
+
roots, so a nested root that is held (a lint running into it) or refused is skipped and reported in the receipt's
|
|
273
|
+
`nestedRoots` without holding up the others, and the receipt schedules the next automatic pass only when every root
|
|
274
|
+
reclaimed. Only generations are reclaimed, never a root or a profile, and a nested root holding no unit of a workspace
|
|
275
|
+
member is retained whole as `foreign-root`. A pre-created target need not carry Cargo's optional backup tag; a present
|
|
276
|
+
but invalid tag still refuses the pass. Every pass still reads the current fingerprint graph. The locked scan reuses
|
|
277
|
+
directory-entry types and reads its small metadata files synchronously, avoiding duplicate stats and one asynchronous
|
|
278
|
+
dispatch per tiny file; it does not walk retained artifact contents or reuse an earlier graph that could miss in-place
|
|
279
|
+
recompiles. `cargo-retention` runs that package's native `smoo-nx-cargo-retain` executable to preview the same
|
|
280
|
+
selection, nested roots included, without changing anything. Each profile's `incremental/<crate>-<id>/` directories go
|
|
281
|
+
in the same pass: rustc keeps one per build variant and never removes the one a feature, profile or flag change
|
|
282
|
+
superseded. One is kept while its newest finished session started inside the compile window (`invoked.timestamp` to
|
|
283
|
+
the hash file's last write) of a kept unit of the same crate, while it started within the recent-use window, or while
|
|
284
|
+
the directory holds an unfinished or unreadable session. The split-debuginfo objects rustc keeps inside current
|
|
285
|
+
generations (rust-lang/rust#161824) are not reclaimed, so a target directory is not bounded by them. Empty fingerprint
|
|
286
|
+
hashes are kept as unfinished compilations. The preservation proof covers Cargo's current unit and dependency records,
|
|
287
|
+
not every debug reference in copied binaries or other checkouts. In particular, a binary copied up before a failed
|
|
288
|
+
link can outlive the generation its debug map names; this pass does not establish that machine-wide debug closure.
|
|
288
289
|
- **Scheduling:** inference never throttles Nx. It sets no `parallelism: false` or `parallel: false`, no cap, and no
|
|
289
290
|
edge whose only purpose is keeping two cargo writers off one `target/`: Cargo owns that lock, and a second process
|
|
290
291
|
waits inside cargo. An edge states a real consumer — fetch before frozen cargo, the archive before the runners,
|
package/dist/.build-inputs.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"packages/nx-plugin/src/cargo-build-script-env.ts": "e5b45ccefc2255cd8a48121eb97132a08e136b4cbbc375d04c940d821a429b23",
|
|
16
16
|
"packages/nx-plugin/src/cargo-closure-input.ts": "6f16430ec0b8949c33337353280372a7258a22d19c79ea3d3dd6bb47acb6fa0d",
|
|
17
17
|
"packages/nx-plugin/src/cargo-dev-profile.ts": "34764ba4fc2aeebe75051c98c2eb64b6baeaa3d8cc0242803081ef935465368d",
|
|
18
|
-
"packages/nx-plugin/src/cargo-retention-hook.ts": "
|
|
18
|
+
"packages/nx-plugin/src/cargo-retention-hook.ts": "8666d49b18227b9793d90f68bd5162d8071ed6b9f004be781852b1c74d5adbe1",
|
|
19
19
|
"packages/nx-plugin/src/cargo-source-hash.ts": "1d72427cb2c7d9038c9452db958d14cbb5017d633f40590093654b474b71cb8e",
|
|
20
20
|
"packages/nx-plugin/src/cargo-toolchain-paths.ts": "3f91da4c07394e47205093874b3d46e888c2e53ab735bbea2b64d660c2611469",
|
|
21
21
|
"packages/nx-plugin/src/cargo-toolchain-policy.ts": "715a743a9922fa1f3be4301bbecee5ed5c1c00c7e9fa6eec0ce9ef9b384fad04",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"packages/nx-plugin/src/executors/bounded-exec/disk-lease.ts": "1a3f6a6fa590d9a2550490bb6906dc91b6c05fbef235b025eaf257eb5310e92d",
|
|
37
37
|
"packages/nx-plugin/src/executors/bounded-exec/executor.ts": "0d1284c1f3e9718a2b2ff5d7139b048cae7d9a7fe3db96d01110bf0937a7ecfc",
|
|
38
38
|
"packages/nx-plugin/src/executors/bounded-exec/gateway-lease.ts": "f3f73bd92db30e4857f98fb8bd2b9a75b2a5a2a318f094e075ed803c1f9a0117",
|
|
39
|
-
"packages/nx-plugin/src/executors/bounded-exec/hang-diagnostics.ts": "
|
|
39
|
+
"packages/nx-plugin/src/executors/bounded-exec/hang-diagnostics.ts": "56a6997611b23eb5f603672e73b58f212558e5255f69b65332734516ad37fe9d",
|
|
40
40
|
"packages/nx-plugin/src/executors/bounded-exec/lease-wait.ts": "59d8ac94d0b8b75858971c5bb28ee421fca4f7685577274fe8bbaf0c01ba462a",
|
|
41
41
|
"packages/nx-plugin/src/executors/bounded-exec/lock-wait.ts": "b14a23b49759a777f4b3338ced003adaf76837c2c38462458f76a7fef1b95d9e",
|
|
42
42
|
"packages/nx-plugin/src/executors/bounded-exec/mbx-pool.ts": "ed35855d8c989358e78a8487b47658319d38efd52f4b1b9a3e95d74dee4002b8",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"packages/nx-plugin/src/managed-assets.ts": "9cea959c09f3163992e666eecc5a65ec1f1b63c81fc56c5e99088507d02c5e3b",
|
|
82
82
|
"packages/nx-plugin/src/managed-files/ci-workflow.ts": "2d64d689e999af20d65cc21b4803659a835a6eb5340e8d3f896cb0c74e6a0878",
|
|
83
83
|
"packages/nx-plugin/src/managed-files/context.ts": "5b83c000322382cb781df4f415f3759388e69686b76779599572a62a5c4dd28c",
|
|
84
|
-
"packages/nx-plugin/src/managed-files/files.ts": "
|
|
84
|
+
"packages/nx-plugin/src/managed-files/files.ts": "468d462da82cf0c3b8bb5db736cb3c06203c2cf8f9bc6cebe70ca52eb6fdac5f",
|
|
85
85
|
"packages/nx-plugin/src/managed-files/generator.ts": "8cf1a1b121645c5ead86c163c9da03f612efb2fff6aabed3ea858d87d6cbd0b3",
|
|
86
86
|
"packages/nx-plugin/src/managed-files/github-runs-on.ts": "a049ca60a79dec57f77e5d18090569a9b8b78818219f236fe352e7705500f531",
|
|
87
87
|
"packages/nx-plugin/src/managed-files/json-edit.ts": "81bc6dd10fffff583cc9f2269f0c2fd2f76b1c5aedbc7d068cf29878371497c2",
|
|
@@ -7,11 +7,18 @@ import type { PostTasksExecutionContext } from 'nx/src/project-graph/plugins/pub
|
|
|
7
7
|
export declare const CARGO_PRODUCER_METADATA: {
|
|
8
8
|
readonly cargoProducer: true;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Whether the run's environment is an mbx project's canonical one, which names the shared store beside mbx-managed
|
|
12
|
+
* target views (specs/cowshed/11_shell.md, "Canonical mbx environment"). Such a project's targets are mbx's to collect,
|
|
13
|
+
* so the plugin retains and purges nothing in them (specs/cowshed/16_build_volumes.md, "Migration" step 4).
|
|
14
|
+
*/
|
|
15
|
+
export declare function mbxManagesTargets(environment: Readonly<NodeJS.ProcessEnv>): boolean;
|
|
10
16
|
/**
|
|
11
17
|
* After a run that executed a Cargo producer task ({@link CARGO_PRODUCER_METADATA}), check whether
|
|
12
18
|
* each Cargo workspace is due for its daily maintenance. A successful receipt schedules only;
|
|
13
19
|
* every due pass reads the current graph under Cargo's locks and is awaited by this Nx process.
|
|
14
|
-
* Maintenance never fails the run it follows: every outcome, a refused or busy pass included, is only reported.
|
|
20
|
+
* Maintenance never fails the run it follows: every outcome, a refused or busy pass included, is only reported. In an
|
|
21
|
+
* mbx project ({@link mbxManagesTargets}) it does nothing.
|
|
15
22
|
*/
|
|
16
23
|
export declare function postTasksExecution(_options: unknown, context: PostTasksExecutionContext): Promise<void>;
|
|
17
24
|
//# sourceMappingURL=cargo-retention-hook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cargo-retention-hook.d.ts","sourceRoot":"","sources":["../src/cargo-retention-hook.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAuB5F;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;aAAK,aAAa;CAAiB,CAAC;AAExE
|
|
1
|
+
{"version":3,"file":"cargo-retention-hook.d.ts","sourceRoot":"","sources":["../src/cargo-retention-hook.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAuB5F;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;aAAK,aAAa;CAAiB,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,OAAO,CAEnF;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8C7G"}
|
|
@@ -25,13 +25,24 @@ function ran(status) {
|
|
|
25
25
|
* another language or a cache-restored replay wrote nothing there.
|
|
26
26
|
*/
|
|
27
27
|
export const CARGO_PRODUCER_METADATA = { cargoProducer: true };
|
|
28
|
+
/**
|
|
29
|
+
* Whether the run's environment is an mbx project's canonical one, which names the shared store beside mbx-managed
|
|
30
|
+
* target views (specs/cowshed/11_shell.md, "Canonical mbx environment"). Such a project's targets are mbx's to collect,
|
|
31
|
+
* so the plugin retains and purges nothing in them (specs/cowshed/16_build_volumes.md, "Migration" step 4).
|
|
32
|
+
*/
|
|
33
|
+
export function mbxManagesTargets(environment) {
|
|
34
|
+
return Boolean(environment.MBX_CACHE_DIR) && environment.MBX_TARGET_VIEWS === '1';
|
|
35
|
+
}
|
|
28
36
|
/**
|
|
29
37
|
* After a run that executed a Cargo producer task ({@link CARGO_PRODUCER_METADATA}), check whether
|
|
30
38
|
* each Cargo workspace is due for its daily maintenance. A successful receipt schedules only;
|
|
31
39
|
* every due pass reads the current graph under Cargo's locks and is awaited by this Nx process.
|
|
32
|
-
* Maintenance never fails the run it follows: every outcome, a refused or busy pass included, is only reported.
|
|
40
|
+
* Maintenance never fails the run it follows: every outcome, a refused or busy pass included, is only reported. In an
|
|
41
|
+
* mbx project ({@link mbxManagesTargets}) it does nothing.
|
|
33
42
|
*/
|
|
34
43
|
export async function postTasksExecution(_options, context) {
|
|
44
|
+
if (mbxManagesTargets(process.env))
|
|
45
|
+
return;
|
|
35
46
|
const executed = Object.values(context.taskResults).filter(({ status }) => ran(status));
|
|
36
47
|
if (executed.length === 0)
|
|
37
48
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hang-diagnostics.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/hang-diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,QAAQ,EAKd,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"hang-diagnostics.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/hang-diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,QAAQ,EAKd,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AAoCtC,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,SAAS,GAAG,MAAM,GAAG,YAAY,CAAC;IAC3C,0HAA0H;IAC1H,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClE;IAAE,MAAM,EAAE,aAAa,GAAG,WAAW,GAAG,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvG,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAChH;AAUD,0FAA0F;AAC1F,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,kBAAkB,EAC3B,MAAM,GAAE,kBAAyB,GAChC,OAAO,CAAC,eAAe,CAAC,CAgR1B;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAM5D"}
|
|
@@ -17,6 +17,8 @@ const PS_FIELDS = 'pid=,ppid=,pgid=,stat=,%cpu=,etime=,lstart=,command=';
|
|
|
17
17
|
*/
|
|
18
18
|
const MAX_SAMPLED_LEAVES = 4;
|
|
19
19
|
const SAMPLE_SECONDS = 1;
|
|
20
|
+
/** How long a process in an uninterruptible kernel wait has its file-system calls traced. */
|
|
21
|
+
const FS_USAGE_SECONDS = 5;
|
|
20
22
|
/**
|
|
21
23
|
* A process census's limit. The stack samples run until the closing census is this far from the window's end.
|
|
22
24
|
*/
|
|
@@ -173,6 +175,28 @@ export function captureHangDiagnostics(request, source = host) {
|
|
|
173
175
|
lines.push(`${name}: no stack; sudo -n sample did not answer, so the call this process waits in is not observed.`);
|
|
174
176
|
}));
|
|
175
177
|
};
|
|
178
|
+
/**
|
|
179
|
+
* A process in an uninterruptible kernel wait (state U) is in a file-system or device call no signal ends, and its
|
|
180
|
+
* stack stops at the system call. Its file-system calls over a few seconds (fs_usage) name the volume and files it
|
|
181
|
+
* waits on, which tells a fixture doing its I/O on a contended shared volume from one serialised behind one APFS
|
|
182
|
+
* operation. Bounded like the stack samples; one fs_usage sudo refuses is named as no trace.
|
|
183
|
+
*/
|
|
184
|
+
const kernelWaits = async (tree) => {
|
|
185
|
+
const waiting = tree.filter((entry) => entry.stat.startsWith('U')).slice(0, MAX_SAMPLED_LEAVES);
|
|
186
|
+
const limitMs = endsAtMs - Date.now() - CENSUS_LIMIT_MS;
|
|
187
|
+
await Promise.all(waiting.map(async ({ pid }) => {
|
|
188
|
+
const name = `fs_usage pid ${pid}`;
|
|
189
|
+
const args = ['-n', 'fs_usage', '-w', '-t', String(FS_USAGE_SECONDS), '-f', 'filesys', String(pid)];
|
|
190
|
+
const result = await probe(name, 'sudo', args, limitMs);
|
|
191
|
+
if (finished)
|
|
192
|
+
return;
|
|
193
|
+
if (result.stdout.trim() !== '') {
|
|
194
|
+
lines.push(`${name} (${FS_USAGE_SECONDS}s of file-system calls):\n${result.stdout.trimEnd()}`);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
lines.push(`${name}: no trace; sudo -n fs_usage gave none, so the files this process waits on are not observed.`);
|
|
198
|
+
}));
|
|
199
|
+
};
|
|
176
200
|
const collect = async () => {
|
|
177
201
|
const before = await census('ps before');
|
|
178
202
|
if (finished)
|
|
@@ -227,7 +251,7 @@ export function captureHangDiagnostics(request, source = host) {
|
|
|
227
251
|
}
|
|
228
252
|
}
|
|
229
253
|
};
|
|
230
|
-
await Promise.all([openFiles(), stackSamples(before)]);
|
|
254
|
+
await Promise.all([openFiles(), stackSamples(before), kernelWaits(before)]);
|
|
231
255
|
if (finished)
|
|
232
256
|
return;
|
|
233
257
|
}
|
|
@@ -1 +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FAAqF;AACrF,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAElF;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,EAAE,CAM7E;AAED,+GAA+G;AAC/G,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,aAAa,GAAG,kBAAkB,GAAG,6BAA6B,GAAG,yBAAyB,EACtG,OAAO,EAAE,kBAAkB,GAC1B,MAAM,CAMR"}
|
|
@@ -147,6 +147,12 @@ const managedFiles = [
|
|
|
147
147
|
target: 'tooling/git-hooks/pre-push.sh',
|
|
148
148
|
executable: true,
|
|
149
149
|
},
|
|
150
|
+
{
|
|
151
|
+
kind: 'raw',
|
|
152
|
+
source: 'tooling/git-reword-commit',
|
|
153
|
+
target: 'tooling/git-reword-commit',
|
|
154
|
+
executable: true,
|
|
155
|
+
},
|
|
150
156
|
{
|
|
151
157
|
kind: 'raw',
|
|
152
158
|
source: 'git-format-staged.yml',
|
package/managed/raw/envrc
CHANGED
|
@@ -13,7 +13,22 @@ if ! has devenv; then
|
|
|
13
13
|
fi
|
|
14
14
|
pushd tooling/direnv >/dev/null
|
|
15
15
|
eval "$(devenv direnvrc)"
|
|
16
|
+
# devenv's use_devenv answers an evaluation that failed with `exit 0`, keeping whatever environment
|
|
17
|
+
# the shell had. Entered by direnv, or activated by cowshed for a workspace's jobs, that shell then
|
|
18
|
+
# has none of this checkout's tools and says nothing (a cancelled evaluation left one recorded as a
|
|
19
|
+
# workspace's shell). Entry fails instead: direnv's exit hook (__dump_at_exit) still dumps the
|
|
20
|
+
# diff, now with this status. An inherited DEVENV_ROOT is another shell's, never this evaluation's.
|
|
21
|
+
unset DEVENV_ROOT
|
|
22
|
+
smoo_require_devenv() {
|
|
23
|
+
local status=$?
|
|
24
|
+
[ -n "${DEVENV_ROOT-}" ] && return "$status"
|
|
25
|
+
log_error "devenv built no environment (see above): this checkout's shell is not entered"
|
|
26
|
+
return 1
|
|
27
|
+
}
|
|
28
|
+
trap 'smoo_require_devenv; __dump_at_exit' EXIT
|
|
16
29
|
use devenv
|
|
30
|
+
trap __dump_at_exit EXIT
|
|
31
|
+
unset -f smoo_require_devenv
|
|
17
32
|
popd >/dev/null
|
|
18
33
|
|
|
19
34
|
# devenv hands direnv only the files its evaluation read; a directory a devenv
|
|
@@ -126,6 +126,7 @@ import path from 'node:path';
|
|
|
126
126
|
import type { BuildInputProducer, KeepDeveloperLinksOptions } from '@smoothbricks/nx-plugin/managed-assets';
|
|
127
127
|
import {
|
|
128
128
|
linkAnchor,
|
|
129
|
+
newestSealedSnapshot,
|
|
129
130
|
type ProducerProbe,
|
|
130
131
|
packedFiles,
|
|
131
132
|
pinnedSnapshot,
|
|
@@ -478,7 +479,17 @@ export async function planDeclaredLinks(root: string): Promise<DeclaredLinksPlan
|
|
|
478
479
|
// own producer provenance instead).
|
|
479
480
|
if (snapshot === undefined) {
|
|
480
481
|
const stale = staleBuilds(name, source);
|
|
481
|
-
if (stale.length > 0)
|
|
482
|
+
if (stale.length > 0) {
|
|
483
|
+
// The live build is older than its sources: serve the newest sealed snapshot of the package instead, named with
|
|
484
|
+
// the revision it holds and why, so shell entry goes on with a build that describes its own sources. With none
|
|
485
|
+
// sealed, the link is refused as before.
|
|
486
|
+
const fallback = newestSealedSnapshot(root, name, source);
|
|
487
|
+
if (fallback === null) throw new Error(staleBuildsRefusal(stale));
|
|
488
|
+
binding = { kind: 'snapshot', target: fallback.directory, id: fallback.id };
|
|
489
|
+
reports.push(
|
|
490
|
+
`! smoo.developerLinks ${name}: serving sealed snapshot ${fallback.id} of ${fallback.head}, the newest this checkout holds, because the live checkout's build is stale: ${staleBuildsRefusal(stale)}`,
|
|
491
|
+
);
|
|
492
|
+
}
|
|
482
493
|
}
|
|
483
494
|
if (snapshot !== undefined) {
|
|
484
495
|
const outcome = await snapshotBinding(root, name, source, snapshot, probe);
|
|
@@ -214,13 +214,12 @@ in {
|
|
|
214
214
|
# wants the cache anyway names it in its own nix.conf.
|
|
215
215
|
cachix.enable = false;
|
|
216
216
|
|
|
217
|
-
#
|
|
217
|
+
# No compiler cache is exported from this shell. One shell once exported
|
|
218
218
|
# RUSTC_WRAPPER=sccache as a BARE NAME, which PATH then resolved per project —
|
|
219
|
-
# which is
|
|
220
|
-
#
|
|
221
|
-
#
|
|
222
|
-
#
|
|
223
|
-
# business deciding which compiler cache a host runs.
|
|
219
|
+
# which is how an unpatched binary from one profile came to serve clients from
|
|
220
|
+
# another. Cargo's cache is mbx: a repository pins it in its own devenv, and
|
|
221
|
+
# cowshed proves that pin against the mbx it installs beside itself
|
|
222
|
+
# (specs/cowshed/05_gateway.md, "Pool selection and revision").
|
|
224
223
|
|
|
225
224
|
# One toolchain for every repository and every workspace, pinned by devenv.lock
|
|
226
225
|
# rather than by a rust-toolchain file. devenv resolves the channel through
|
|
@@ -511,8 +510,15 @@ in {
|
|
|
511
510
|
# A runner links nothing.
|
|
512
511
|
#
|
|
513
512
|
# A failed task does not fail shell entry (devenv reports it and the shell
|
|
514
|
-
# still loads, so the tools to repair it stay available)
|
|
515
|
-
#
|
|
513
|
+
# still loads, so the tools to repair it stay available), with one
|
|
514
|
+
# exception: smoo:developer-links refusing the declared links. A shell on
|
|
515
|
+
# links its declaration does not describe runs another build than it says
|
|
516
|
+
# (a live checkout whose build is stale, with no sealed snapshot to serve
|
|
517
|
+
# instead), and the repair is in the provider checkout, not in this shell.
|
|
518
|
+
# The refused exec leaves node_modules/.smoo-links-refused, which the
|
|
519
|
+
# prologue below says and fails on; the next `--links` run that finds the
|
|
520
|
+
# links current removes it. CI runs both with `devenv tasks run`, which
|
|
521
|
+
# does fail; setup-environment.ts is strict there.
|
|
516
522
|
tasks = let
|
|
517
523
|
setup = ''bun "$DEVENV_ROOT/setup-environment.ts"'';
|
|
518
524
|
in {
|
|
@@ -652,6 +658,13 @@ in {
|
|
|
652
658
|
# they run.
|
|
653
659
|
(lib.mkBefore ''
|
|
654
660
|
cd "$DEVENV_ROOT/../.."
|
|
661
|
+
# smoo:developer-links refused the declared links (tasks above): fail
|
|
662
|
+
# shell entry with its reason rather than run on links it refused.
|
|
663
|
+
if [ -f node_modules/.smoo-links-refused ]; then
|
|
664
|
+
echo "smoo:developer-links refused this checkout's declared links; shell entry fails until they are current:" >&2
|
|
665
|
+
cat node_modules/.smoo-links-refused >&2
|
|
666
|
+
exit 1
|
|
667
|
+
fi
|
|
655
668
|
# A bare assignment: export's status would hide repo-path's refusal of a
|
|
656
669
|
# cowshed workspace it could not serve, and the shell would enter with an
|
|
657
670
|
# empty PATH.
|
|
@@ -925,6 +925,56 @@ function copySealed(from: string, to: string): void {
|
|
|
925
925
|
}
|
|
926
926
|
}
|
|
927
927
|
|
|
928
|
+
/**
|
|
929
|
+
* The newest sealed snapshot of `name` this checkout's store, or else its link anchor's (the main checkout's), holds,
|
|
930
|
+
* newest by the commit time of the HEAD it captured, as `source`'s repository knows it; or null when there is none.
|
|
931
|
+
* What a live developer link serves while the live checkout's build does not describe its sources (developer-links.ts):
|
|
932
|
+
* the last revision that was built and sealed, never the stale build, and never a refusal that stops shell entry.
|
|
933
|
+
*/
|
|
934
|
+
export function newestSealedSnapshot(
|
|
935
|
+
root: string,
|
|
936
|
+
name: string,
|
|
937
|
+
source: string,
|
|
938
|
+
): (SealedSnapshot & { readonly head: string }) | null {
|
|
939
|
+
const stores = [...new Set([path.join(root, SNAPSHOT_STORE), path.join(linkAnchor(root), SNAPSHOT_STORE)])];
|
|
940
|
+
const candidates: { readonly directory: string; readonly receipt: SnapshotReceipt; readonly time: number }[] = [];
|
|
941
|
+
for (const store of stores) {
|
|
942
|
+
let entries: string[];
|
|
943
|
+
try {
|
|
944
|
+
entries = readdirSync(store);
|
|
945
|
+
} catch {
|
|
946
|
+
continue;
|
|
947
|
+
}
|
|
948
|
+
for (const entry of entries) {
|
|
949
|
+
const directory = path.join(store, entry);
|
|
950
|
+
const receipt = readSealed(directory);
|
|
951
|
+
if (receipt === null || receipt.name !== name || !contained(receipt.packagePath)) continue;
|
|
952
|
+
const committed = spawnSync('git', ['-C', source, 'log', '-1', '--format=%ct', receipt.provenance.head], {
|
|
953
|
+
encoding: 'utf8',
|
|
954
|
+
env: { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1' },
|
|
955
|
+
});
|
|
956
|
+
const time = Number.parseInt(committed.stdout.trim(), 10);
|
|
957
|
+
if (committed.status === 0 && Number.isFinite(time)) candidates.push({ directory, receipt, time });
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
candidates.sort((left, right) => right.time - left.time);
|
|
961
|
+
for (const { directory, receipt } of candidates) {
|
|
962
|
+
try {
|
|
963
|
+
verifySnapshot(directory);
|
|
964
|
+
} catch (error) {
|
|
965
|
+
if (error instanceof SnapshotRefusal) continue;
|
|
966
|
+
throw error;
|
|
967
|
+
}
|
|
968
|
+
return {
|
|
969
|
+
kind: 'snapshot',
|
|
970
|
+
id: receipt.id,
|
|
971
|
+
directory: path.join(directory, receipt.packagePath),
|
|
972
|
+
head: receipt.provenance.head,
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
return null;
|
|
976
|
+
}
|
|
977
|
+
|
|
928
978
|
/** A sealed snapshot's receipt, or null when `directory` holds none. Its census is not verified here. */
|
|
929
979
|
export function readSealed(directory: string): SnapshotReceipt | null {
|
|
930
980
|
let input: unknown;
|
|
@@ -941,19 +991,6 @@ export function readSealed(directory: string): SnapshotReceipt | null {
|
|
|
941
991
|
return receipt;
|
|
942
992
|
}
|
|
943
993
|
|
|
944
|
-
/** The sealed snapshot `target` lies in, found by its receipt above it, or null. */
|
|
945
|
-
export function sealedSnapshotOf(
|
|
946
|
-
target: string,
|
|
947
|
-
): { readonly directory: string; readonly receipt: SnapshotReceipt } | null {
|
|
948
|
-
for (let at = path.dirname(target); ; at = path.dirname(at)) {
|
|
949
|
-
if (lstatSync(path.join(at, SNAPSHOT_RECEIPT), { throwIfNoEntry: false }) !== undefined) {
|
|
950
|
-
const receipt = readSealed(at);
|
|
951
|
-
return receipt === null ? null : { directory: at, receipt };
|
|
952
|
-
}
|
|
953
|
-
if (path.dirname(at) === at) return null;
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
|
|
957
994
|
/**
|
|
958
995
|
* The sealed snapshot of `name` in this checkout's store that `linkText`, an alias's recorded link at `entry`, binds,
|
|
959
996
|
* once it verifies; or null when that text names no snapshot left in the store. When no new snapshot can be made the
|
|
@@ -223,6 +223,11 @@ const { values: flags } = parseArgs({
|
|
|
223
223
|
},
|
|
224
224
|
});
|
|
225
225
|
const cargoMode = flags.cargo === true;
|
|
226
|
+
// What a `--links` exec that refused leaves for the enterShell prologue (devenv.smoo.nix), which then fails shell entry
|
|
227
|
+
// with its reason: a shell must not run on links the declaration does not describe (a live checkout whose build is
|
|
228
|
+
// stale with no sealed snapshot to serve, a declaration smoo refuses), and the repair is in the provider checkout, not
|
|
229
|
+
// in this shell. Every `--links` run that finds the links current, or makes them so, removes it.
|
|
230
|
+
const linksRefusal = path.join(projectRoot, 'node_modules', '.smoo-links-refused');
|
|
226
231
|
|
|
227
232
|
// The Nx plugin's test for a Cargo workspace root manifest (CARGO_WORKSPACE_PATTERN), which
|
|
228
233
|
// cargoWorkspaces applies during the bootstrap block; declared above it for the same reason.
|
|
@@ -253,13 +258,12 @@ try {
|
|
|
253
258
|
plan.changes.length === 0 && plan.unavailable.every((unavailable) => unavailable.kind === 'absent');
|
|
254
259
|
// A stale pin is informational, not a stale install: say it even when devenv skips the exec.
|
|
255
260
|
if (current && plan.reports.length > 0) applyDeclaredLinks(projectRoot, plan);
|
|
256
|
-
|
|
261
|
+
const linked =
|
|
257
262
|
current &&
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
);
|
|
263
|
+
!hasStaleDeveloperLinks(projectRoot, ['nx']) &&
|
|
264
|
+
danglingStoreLinks(projectRoot, () => workspaceMemberModules(projectRoot)).length === 0;
|
|
265
|
+
if (linked) rmSync(linksRefusal, { force: true });
|
|
266
|
+
process.exit(linked ? 0 : 1);
|
|
263
267
|
}
|
|
264
268
|
// Planning reads, apart from a snapshot it may capture, which seals by an atomic rename (linked-snapshots.ts),
|
|
265
269
|
// and applying a plan with no changes only says what this machine cannot honour. So an entry with nothing to
|
|
@@ -272,6 +276,7 @@ try {
|
|
|
272
276
|
!hasStaleDeveloperLinks(projectRoot, ['nx'])
|
|
273
277
|
) {
|
|
274
278
|
applyDeclaredLinks(projectRoot, plan);
|
|
279
|
+
rmSync(linksRefusal, { force: true });
|
|
275
280
|
process.exit(0);
|
|
276
281
|
}
|
|
277
282
|
await withInstallLock(async () => {
|
|
@@ -290,6 +295,7 @@ try {
|
|
|
290
295
|
}
|
|
291
296
|
applyDeclaredLinks(projectRoot, await planDeclaredLinks(projectRoot));
|
|
292
297
|
});
|
|
298
|
+
rmSync(linksRefusal, { force: true });
|
|
293
299
|
process.exit(0);
|
|
294
300
|
}
|
|
295
301
|
// Bootstrap only: install deps + wire local git hooks/config.
|
|
@@ -410,6 +416,11 @@ try {
|
|
|
410
416
|
}
|
|
411
417
|
}
|
|
412
418
|
} catch (error) {
|
|
419
|
+
// Thrown out of a `--links` exec, an error is the links refused (an install failure reports itself and exits).
|
|
420
|
+
if (flags.links === true && flags.check !== true) {
|
|
421
|
+
mkdirSync(path.dirname(linksRefusal), { recursive: true });
|
|
422
|
+
writeFileSync(linksRefusal, `${error instanceof Error ? error.message : String(error)}\n`);
|
|
423
|
+
}
|
|
413
424
|
reportSetupFailure(error);
|
|
414
425
|
}
|
|
415
426
|
|
|
@@ -1427,14 +1438,15 @@ async function applyWorkspaceGitConfig(root: string): Promise<void> {
|
|
|
1427
1438
|
|
|
1428
1439
|
const gitDir = path.resolve(root, new TextDecoder().decode(gitDirResult.stdout).trim());
|
|
1429
1440
|
const tooling = path.join(root, 'tooling');
|
|
1430
|
-
linkHook(gitDir, tooling, 'pre-commit');
|
|
1441
|
+
linkHook(gitDir, path.join(tooling, 'git-hooks', 'pre-commit.sh'));
|
|
1431
1442
|
installPostCommitHook(gitDir, tooling);
|
|
1432
|
-
linkHook(gitDir, tooling, 'commit-msg');
|
|
1433
|
-
linkHook(gitDir, tooling, 'pre-push');
|
|
1443
|
+
linkHook(gitDir, path.join(tooling, 'git-hooks', 'commit-msg.sh'));
|
|
1444
|
+
linkHook(gitDir, path.join(tooling, 'git-hooks', 'pre-push.sh'));
|
|
1434
1445
|
}
|
|
1435
1446
|
|
|
1436
|
-
|
|
1437
|
-
|
|
1447
|
+
/** Links `.git/hooks/<name>` to the hook source `<name>.sh`. */
|
|
1448
|
+
function linkHook(gitDir: string, source: string): void {
|
|
1449
|
+
const name = path.basename(source, '.sh');
|
|
1438
1450
|
if (!existsSync(source)) {
|
|
1439
1451
|
throw new Error(`Missing ${name} hook source: ${source}`);
|
|
1440
1452
|
}
|
|
@@ -70,7 +70,10 @@ while read -r _local_ref local_sha _remote_ref _remote_sha; do
|
|
|
70
70
|
esac
|
|
71
71
|
done
|
|
72
72
|
if [ "${#pushed[@]}" -gt 0 ]; then
|
|
73
|
-
smoo monorepo check-public-denylist --remote "$1" "${pushed[@]}" ||
|
|
73
|
+
smoo monorepo check-public-denylist --remote "$1" "${pushed[@]}" || {
|
|
74
|
+
echo 'pre-push: rewrite a refused commit message in place with tooling/git-reword-commit <commit> (the new message on stdin), then push again' >&2
|
|
75
|
+
exit 1
|
|
76
|
+
}
|
|
74
77
|
fi
|
|
75
78
|
|
|
76
79
|
case "$(uname -s)" in
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# git-reword-commit - Rewrite a commit message without affecting worktree
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# echo "new message" | git-reword-commit <commit-hash>
|
|
7
|
+
# echo "prepend this" | git-reword-commit <commit-hash> --prepend
|
|
8
|
+
# echo "append this" | git-reword-commit <commit-hash> --append
|
|
9
|
+
# ... | git-reword-commit <commit-hash> --rewrite-published
|
|
10
|
+
#
|
|
11
|
+
# Examples:
|
|
12
|
+
# # Replace the entire commit message
|
|
13
|
+
# echo "feat: new message here" | git-reword-commit abc123
|
|
14
|
+
#
|
|
15
|
+
# # Prepend to existing message (adds newline between)
|
|
16
|
+
# cat msg.txt | git-reword-commit abc123 --prepend
|
|
17
|
+
#
|
|
18
|
+
# # Append to existing message (adds newline between)
|
|
19
|
+
# echo "Co-authored-by: Someone" | git-reword-commit abc123 --append
|
|
20
|
+
#
|
|
21
|
+
# The commit is rebuilt with `git commit-tree` from its own tree, parents, author and
|
|
22
|
+
# committer, and so is every commit between it and HEAD that descends from it; nothing else
|
|
23
|
+
# changes. HEAD -- a branch, or a detached HEAD -- moves once, with `git update-ref`, and only
|
|
24
|
+
# if it still names the commit it named when the rewrite began. The trees are the same, so the
|
|
25
|
+
# worktree and index are untouched, and no backup ref is left behind.
|
|
26
|
+
#
|
|
27
|
+
# A commit any remote-tracking ref already holds is published: rewriting it forks history
|
|
28
|
+
# others have. That is refused unless --rewrite-published says it is meant.
|
|
29
|
+
#
|
|
30
|
+
|
|
31
|
+
set -euo pipefail
|
|
32
|
+
|
|
33
|
+
usage() {
|
|
34
|
+
echo "Usage: <message> | git-reword-commit <commit-hash> [--prepend|--append] [--rewrite-published]"
|
|
35
|
+
echo ""
|
|
36
|
+
echo "Reads new commit message from stdin."
|
|
37
|
+
echo ""
|
|
38
|
+
echo "Modes:"
|
|
39
|
+
echo " (default) Replace the entire commit message"
|
|
40
|
+
echo " --prepend Prepend to existing message (adds newline between)"
|
|
41
|
+
echo " --append Append to existing message (adds newline between)"
|
|
42
|
+
echo " --rewrite-published Rewrite even though a remote-tracking ref holds the commit"
|
|
43
|
+
exit 1
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if [ $# -lt 1 ]; then
|
|
47
|
+
usage
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
COMMIT_SHORT="$1"
|
|
51
|
+
shift
|
|
52
|
+
|
|
53
|
+
COMMIT_FULL=$(git rev-parse --verify --quiet "$COMMIT_SHORT^{commit}") || {
|
|
54
|
+
echo "Error: Invalid commit reference: $COMMIT_SHORT" >&2
|
|
55
|
+
exit 1
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
MODE="replace"
|
|
59
|
+
REWRITE_PUBLISHED=0
|
|
60
|
+
for option in "$@"; do
|
|
61
|
+
case "$option" in
|
|
62
|
+
--prepend) MODE="prepend" ;;
|
|
63
|
+
--append) MODE="append" ;;
|
|
64
|
+
--rewrite-published) REWRITE_PUBLISHED=1 ;;
|
|
65
|
+
*)
|
|
66
|
+
echo "Error: Unknown option: $option" >&2
|
|
67
|
+
usage
|
|
68
|
+
;;
|
|
69
|
+
esac
|
|
70
|
+
done
|
|
71
|
+
|
|
72
|
+
HEAD_BEFORE=$(git rev-parse --verify HEAD)
|
|
73
|
+
if ! git merge-base --is-ancestor "$COMMIT_FULL" "$HEAD_BEFORE"; then
|
|
74
|
+
echo "Error: $COMMIT_SHORT is not an ancestor of HEAD; there is nothing of it to rewrite here" >&2
|
|
75
|
+
exit 1
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
PUBLISHED=$(git for-each-ref --contains "$COMMIT_FULL" --format='%(refname)' refs/remotes)
|
|
79
|
+
if [ -n "$PUBLISHED" ] && [ "$REWRITE_PUBLISHED" -ne 1 ]; then
|
|
80
|
+
echo "Error: $COMMIT_SHORT is already published; these remote-tracking refs hold it:" >&2
|
|
81
|
+
printf ' %s\n' $PUBLISHED >&2
|
|
82
|
+
echo "Rewriting it forks history others have. Pass --rewrite-published if that is meant." >&2
|
|
83
|
+
exit 1
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
WORK=$(mktemp -d)
|
|
87
|
+
trap 'rm -rf "$WORK"' EXIT
|
|
88
|
+
cat > "$WORK/new"
|
|
89
|
+
if [ ! -s "$WORK/new" ]; then
|
|
90
|
+
echo "Error: Message cannot be empty (nothing on stdin)" >&2
|
|
91
|
+
usage
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
# The message bytes of commit $1: everything after the header's terminating blank line.
|
|
95
|
+
# Continuation lines of a multi-line header (a signature) start with a space, never empty.
|
|
96
|
+
message_of() {
|
|
97
|
+
git cat-file commit "$1" | sed '1,/^$/d'
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
case "$MODE" in
|
|
101
|
+
replace) cp "$WORK/new" "$WORK/message" ;;
|
|
102
|
+
prepend) { cat "$WORK/new"; echo ''; echo ''; message_of "$COMMIT_FULL"; } > "$WORK/message" ;;
|
|
103
|
+
append) { message_of "$COMMIT_FULL"; echo ''; echo ''; cat "$WORK/new"; } > "$WORK/message" ;;
|
|
104
|
+
esac
|
|
105
|
+
|
|
106
|
+
# old -> new for every rebuilt commit, one "old new" pair per line; a parent not listed is kept.
|
|
107
|
+
: > "$WORK/map"
|
|
108
|
+
rebuilt() {
|
|
109
|
+
awk -v old="$1" '$1 == old { print $2; found = 1 } END { if (!found) print old }' "$WORK/map"
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# Rebuild $1 on its rebuilt parents with the message in file $2, keeping tree, author and
|
|
113
|
+
# committer.
|
|
114
|
+
rebuild() {
|
|
115
|
+
local commit="$1" message="$2" parents=() parent listed
|
|
116
|
+
listed=$(git rev-parse "$commit^@")
|
|
117
|
+
for parent in $listed; do
|
|
118
|
+
parents+=(-p "$(rebuilt "$parent")")
|
|
119
|
+
done
|
|
120
|
+
local an ae ad cn ce cd
|
|
121
|
+
{
|
|
122
|
+
IFS= read -r an
|
|
123
|
+
IFS= read -r ae
|
|
124
|
+
IFS= read -r ad
|
|
125
|
+
IFS= read -r cn
|
|
126
|
+
IFS= read -r ce
|
|
127
|
+
IFS= read -r cd
|
|
128
|
+
} < <(git log --no-walk --format='%an%n%ae%n%ad%n%cn%n%ce%n%cd' --date=raw "$commit")
|
|
129
|
+
GIT_AUTHOR_NAME="$an" GIT_AUTHOR_EMAIL="$ae" GIT_AUTHOR_DATE="$ad" \
|
|
130
|
+
GIT_COMMITTER_NAME="$cn" GIT_COMMITTER_EMAIL="$ce" GIT_COMMITTER_DATE="$cd" \
|
|
131
|
+
git commit-tree "$commit^{tree}" ${parents[@]+"${parents[@]}"} < "$message"
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
echo "Rewriting commit $COMMIT_SHORT ($MODE mode)..."
|
|
135
|
+
|
|
136
|
+
NEW_COMMIT=$(rebuild "$COMMIT_FULL" "$WORK/message")
|
|
137
|
+
echo "$COMMIT_FULL $NEW_COMMIT" >> "$WORK/map"
|
|
138
|
+
DESCENDANTS=$(git rev-list --reverse --topo-order --ancestry-path "$COMMIT_FULL..$HEAD_BEFORE")
|
|
139
|
+
for descendant in $DESCENDANTS; do
|
|
140
|
+
message_of "$descendant" > "$WORK/descendant"
|
|
141
|
+
rebuilt_descendant=$(rebuild "$descendant" "$WORK/descendant")
|
|
142
|
+
echo "$descendant $rebuilt_descendant" >> "$WORK/map"
|
|
143
|
+
done
|
|
144
|
+
|
|
145
|
+
HEAD_AFTER=$(rebuilt "$HEAD_BEFORE")
|
|
146
|
+
git update-ref -m "git-reword-commit: reword $COMMIT_FULL" HEAD "$HEAD_AFTER" "$HEAD_BEFORE"
|
|
147
|
+
|
|
148
|
+
echo "Done. Commit message rewritten."
|
|
149
|
+
echo ""
|
|
150
|
+
echo "New commit: $NEW_COMMIT"
|
|
151
|
+
echo "New HEAD: $HEAD_AFTER"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smoothbricks/nx-plugin",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./loader.js",
|
|
@@ -384,9 +384,9 @@
|
|
|
384
384
|
},
|
|
385
385
|
"dependencies": {
|
|
386
386
|
"@nx/js": "23.2.1",
|
|
387
|
-
"@smoothbricks/build-inputs": "0.0.1
|
|
388
|
-
"@smoothbricks/cargo-retain": "0.0.1
|
|
389
|
-
"@smoothbricks/nextest-extract": "0.0.1
|
|
387
|
+
"@smoothbricks/build-inputs": "0.0.1",
|
|
388
|
+
"@smoothbricks/cargo-retain": "0.0.1",
|
|
389
|
+
"@smoothbricks/nextest-extract": "0.0.1",
|
|
390
390
|
"jsonc-parser": "^3.3.1",
|
|
391
391
|
"minimatch": "10.2.5",
|
|
392
392
|
"nx": "latest",
|
|
@@ -40,13 +40,24 @@ function ran(status: TaskStatus): boolean {
|
|
|
40
40
|
*/
|
|
41
41
|
export const CARGO_PRODUCER_METADATA = { cargoProducer: true } as const;
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Whether the run's environment is an mbx project's canonical one, which names the shared store beside mbx-managed
|
|
45
|
+
* target views (specs/cowshed/11_shell.md, "Canonical mbx environment"). Such a project's targets are mbx's to collect,
|
|
46
|
+
* so the plugin retains and purges nothing in them (specs/cowshed/16_build_volumes.md, "Migration" step 4).
|
|
47
|
+
*/
|
|
48
|
+
export function mbxManagesTargets(environment: Readonly<NodeJS.ProcessEnv>): boolean {
|
|
49
|
+
return Boolean(environment.MBX_CACHE_DIR) && environment.MBX_TARGET_VIEWS === '1';
|
|
50
|
+
}
|
|
51
|
+
|
|
43
52
|
/**
|
|
44
53
|
* After a run that executed a Cargo producer task ({@link CARGO_PRODUCER_METADATA}), check whether
|
|
45
54
|
* each Cargo workspace is due for its daily maintenance. A successful receipt schedules only;
|
|
46
55
|
* every due pass reads the current graph under Cargo's locks and is awaited by this Nx process.
|
|
47
|
-
* Maintenance never fails the run it follows: every outcome, a refused or busy pass included, is only reported.
|
|
56
|
+
* Maintenance never fails the run it follows: every outcome, a refused or busy pass included, is only reported. In an
|
|
57
|
+
* mbx project ({@link mbxManagesTargets}) it does nothing.
|
|
48
58
|
*/
|
|
49
59
|
export async function postTasksExecution(_options: unknown, context: PostTasksExecutionContext): Promise<void> {
|
|
60
|
+
if (mbxManagesTargets(process.env)) return;
|
|
50
61
|
const executed = Object.values(context.taskResults).filter(({ status }) => ran(status));
|
|
51
62
|
if (executed.length === 0) return;
|
|
52
63
|
let graph: ProjectGraph;
|
|
@@ -25,6 +25,8 @@ const PS_FIELDS = 'pid=,ppid=,pgid=,stat=,%cpu=,etime=,lstart=,command=';
|
|
|
25
25
|
*/
|
|
26
26
|
const MAX_SAMPLED_LEAVES = 4;
|
|
27
27
|
const SAMPLE_SECONDS = 1;
|
|
28
|
+
/** How long a process in an uninterruptible kernel wait has its file-system calls traced. */
|
|
29
|
+
const FS_USAGE_SECONDS = 5;
|
|
28
30
|
/**
|
|
29
31
|
* A process census's limit. The stack samples run until the closing census is this far from the window's end.
|
|
30
32
|
*/
|
|
@@ -236,6 +238,31 @@ export function captureHangDiagnostics(
|
|
|
236
238
|
}),
|
|
237
239
|
);
|
|
238
240
|
};
|
|
241
|
+
/**
|
|
242
|
+
* A process in an uninterruptible kernel wait (state U) is in a file-system or device call no signal ends, and its
|
|
243
|
+
* stack stops at the system call. Its file-system calls over a few seconds (fs_usage) name the volume and files it
|
|
244
|
+
* waits on, which tells a fixture doing its I/O on a contended shared volume from one serialised behind one APFS
|
|
245
|
+
* operation. Bounded like the stack samples; one fs_usage sudo refuses is named as no trace.
|
|
246
|
+
*/
|
|
247
|
+
const kernelWaits = async (tree: readonly ObservedProcess[]): Promise<void> => {
|
|
248
|
+
const waiting = tree.filter((entry) => entry.stat.startsWith('U')).slice(0, MAX_SAMPLED_LEAVES);
|
|
249
|
+
const limitMs = endsAtMs - Date.now() - CENSUS_LIMIT_MS;
|
|
250
|
+
await Promise.all(
|
|
251
|
+
waiting.map(async ({ pid }) => {
|
|
252
|
+
const name = `fs_usage pid ${pid}`;
|
|
253
|
+
const args = ['-n', 'fs_usage', '-w', '-t', String(FS_USAGE_SECONDS), '-f', 'filesys', String(pid)];
|
|
254
|
+
const result = await probe(name, 'sudo', args, limitMs);
|
|
255
|
+
if (finished) return;
|
|
256
|
+
if (result.stdout.trim() !== '') {
|
|
257
|
+
lines.push(`${name} (${FS_USAGE_SECONDS}s of file-system calls):\n${result.stdout.trimEnd()}`);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
lines.push(
|
|
261
|
+
`${name}: no trace; sudo -n fs_usage gave none, so the files this process waits on are not observed.`,
|
|
262
|
+
);
|
|
263
|
+
}),
|
|
264
|
+
);
|
|
265
|
+
};
|
|
239
266
|
const collect = async (): Promise<void> => {
|
|
240
267
|
const before = await census('ps before');
|
|
241
268
|
if (finished) return;
|
|
@@ -294,7 +321,7 @@ export function captureHangDiagnostics(
|
|
|
294
321
|
}
|
|
295
322
|
}
|
|
296
323
|
};
|
|
297
|
-
await Promise.all([openFiles(), stackSamples(before)]);
|
|
324
|
+
await Promise.all([openFiles(), stackSamples(before), kernelWaits(before)]);
|
|
298
325
|
if (finished) return;
|
|
299
326
|
} else {
|
|
300
327
|
lines.push(`Open-file census not provided on ${source.platform}; observations below name processes only.`);
|
|
@@ -211,6 +211,12 @@ const managedFiles: ManagedFileDescriptor[] = [
|
|
|
211
211
|
target: 'tooling/git-hooks/pre-push.sh',
|
|
212
212
|
executable: true,
|
|
213
213
|
},
|
|
214
|
+
{
|
|
215
|
+
kind: 'raw',
|
|
216
|
+
source: 'tooling/git-reword-commit',
|
|
217
|
+
target: 'tooling/git-reword-commit',
|
|
218
|
+
executable: true,
|
|
219
|
+
},
|
|
214
220
|
{
|
|
215
221
|
kind: 'raw',
|
|
216
222
|
source: 'git-format-staged.yml',
|
package/test-timings.json
CHANGED
|
@@ -126,6 +126,7 @@
|
|
|
126
126
|
"src/executors/bounded-exec/runner-lifecycle.test.ts": 6,
|
|
127
127
|
"src/executors/bounded-exec/runner-sizing.test.ts": 6,
|
|
128
128
|
"src/executors/bounded-exec/mbx-pool.test.ts": 5,
|
|
129
|
+
"src/cargo-retention-hook.test.ts": 5,
|
|
129
130
|
"src/executors/bounded-exec/owned-subtree.test.ts": 5,
|
|
130
131
|
"src/executors/bounded-exec/bounds.test.ts": 3
|
|
131
132
|
}
|