@nodii/dev 0.6.219 → 0.6.221
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 +12 -5
- package/dist/core.js +1 -1
- package/dist/heavy-slot.sh +6 -2
- package/dist/heavy.js +3 -2
- package/dist/push-hook.sh +23 -3
- package/dist/push-hooks.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -166,10 +166,10 @@ nodii-dev heavy run --size light -- bun test tests/unit/money.test.ts
|
|
|
166
166
|
nodii-dev heavy run -- git push -u origin HEAD
|
|
167
167
|
nodii-dev heavy run --tighten memory=40 -- true # refused (exit 75) unless 40 GB is available
|
|
168
168
|
nodii-dev heavy status
|
|
169
|
-
nodii-dev heavy run --help # prints the usage; takes no slot and runs nothing
|
|
169
|
+
nodii-dev heavy run --help # prints what it does, then the usage; takes no slot and runs nothing
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
-
- **The machine's floor (DEV-PROCESS-2).** Every job reads the floor before it queues and again when a slot is free (`src/machine-floor.js`). Available memory, after what running jobs hold back for their peaks, must be at least 10 GB (5 GB for a light job); swap used at most 24 GB; disk free at least 15 GB. A running job holds back its class's peak (7 GB heavy, 1 GB light) less what its process tree uses now. Under the floor a job exits 75 at once with `MACHINE_UNDER_FLOOR`, naming the reading, the figure and the five largest holders of memory. It is never queued and never let through: there is no exception for a lone job, a landing or a push (hub-490). The readings use the system tools' absolute paths (`/usr/bin/vm_stat`, `/usr/sbin/sysctl vm.swapusage`, `/bin/df -Pk /`), on the install's own node.
|
|
172
|
+
- **The machine's floor (DEV-PROCESS-2).** Every job reads the floor before it queues and again when a slot is free (`src/machine-floor.js`). Available memory, after what running jobs hold back for their peaks, must be at least 10 GB (5 GB for a light job); swap used at most 24 GB; disk free at least 15 GB. A running job holds back its class's peak (7 GB heavy, 1 GB light) less what its process tree uses now. Under the floor a job exits 75 at once with `MACHINE_UNDER_FLOOR`, naming the reading, the figure and the five largest holders of memory. It is never queued and never let through: there is no exception for a lone job, a landing or a push (hub-490). A job that queued for a slot and is then refused when one frees leaves no queue ticket behind. The readings use the system tools' absolute paths (`/usr/bin/vm_stat`, `/usr/sbin/sysctl vm.swapusage`, `/bin/df -Pk /`), on the install's own node.
|
|
173
173
|
- **The floor file.** The floor, the class peaks, the ceilings (3 heavy slots, one of them only for a push forced heavy; 8 light slots) and the 10 s stagger live in `/etc/nodii/floor.env`. It counts only when root owns it and `/etc/nodii`, neither is group- or world-writable, and the lanes' user cannot write it; else the shipped defaults hold, and `heavy status` says why. Only the machine owner installs or changes it, with their password (`sudo install -d -o root -g wheel -m 755 /etc/nodii && sudo install -o root -g wheel -m 644 floor.env /etc/nodii/floor.env`). No variable moves it or the slot directory: `NODII_RESOURCE_LIMITS`, `HEAVY_SLOT_DIR`, `NODII_HEAVY_SLOT`, `NODII_HEAVY_SLOT_HELD` and `HEAVY_LANDING` are gone. `~/.config/nodii-resources/limits.env` keeps only the coordinator's `LANE_CAP`, `STACK_CAP`, `LIGHT_LANE_CAP` and `DEV_SERVER_CAP`.
|
|
174
174
|
- `--tighten memory=GB|swap=GB|disk=GB` (repeatable, or a comma list) makes one call stricter than the floor; a figure that would loosen it exits 2 (`USAGE`). `lane launch` and `lane resume` take it too.
|
|
175
175
|
- **Heavy is end-to-end; light is a short list (MW2-51).** A heavy slot is for end-to-end, real-stack and browser-flow work: Playwright, Cypress and other browser drivers, an `e2e`, `integration`, real-stack or stack script, an image build and a detached stack start. A light slot (under the light floor, 5 GB, with no stagger) is for a typecheck or lint on the diff's files only (`tsc`, `tsgo`, `vue-tsc`, `eslint`, `biome` or `oxlint` naming the files it checks, or a package manager's `typecheck`, `lint` or `tsc` script scoped by its name: `:affected`, `:changed`, `:touched`, `:diff`, `:staged`; a whole-repository typecheck or lint counts heavy), a unit-test run naming at most 20 test files (`bun test`, `vitest`, `jest`, `mocha`, `node --test`; no globs, no compound commands) and `git push`. Anything else counts heavy (`sleep`, `true`, a whole suite, an install), and a command declared light with `--size light` that is none of those counts heavy and says so. `--size heavy` makes any job heavy. Light locks live in `/tmp/nodii-heavy-slots/light`.
|
|
@@ -186,7 +186,7 @@ nodii-dev heavy run --help # prints the usage; takes no s
|
|
|
186
186
|
|
|
187
187
|
It then stops its own job's process tree and logs the reclaim (slot, lane, time held and why) to `/tmp/nodii-heavy-slots/reclaim.log`. `heavy status` shows each slot's lane, marks a reclaim candidate and lists the last reclaims. No session ever signals another session's processes (MW2-49): a waiter only waits. A slot taken outside a lane, or held by a pre-v26 copy, is never reclaimed this way; a check that can't tell (Dev unreachable, no `lsof`) keeps the slot.
|
|
188
188
|
- It can't be skipped. In a lane, the safety hook (`hook safety-pre`) refuses an unqueued heavy command (`SAFETY_HEAVY_UNQUEUED`) and prints the same command with `nodii-dev heavy run --` in front of each heavy part. Only the installed queue queues: a file named `heavy-slot.sh`, run directly or by a shell, is no queue, so its job is judged as if run bare. design-system's surface-gen check (`node infra/code-connect/surface-gen.mjs check`) is heavy.
|
|
189
|
-
- Every-page checks run in CI only (DEV-PROCESS-2, hub-650). In a lane, the hook refuses with `SAFETY_CI_ONLY
|
|
189
|
+
- Every-page checks run in CI only (DEV-PROCESS-2, hub-650). In a lane, the hook refuses with `SAFETY_CI_ONLY`. The refusal opens with "`<check>` runs over every page and runs in CI only; locally run it on the touched pages (`--touched`). Covered by the pull request's `<job>` check (MW1-107)." and names the pull-request check that covers it: `nodii-dev surface generate --all --check` (also through `npx @nodii/dev`, `pnpm dlx` or an env prefix) and any surface-gen check run with `CI=` set, bare or queued, are covered by "Generated pages match their Surfaces" (job `surface-gen-equal`); `pnpm verify:frame-conformance` and `pnpm verify:frame-conformance:gate`, with or without `--touched`, bare or queued, by "Frame conformance for touched pages" (job `frame-conformance`). `surface generate --all --write` and `nodii-dev heavy run -- node infra/code-connect/surface-gen.mjs check` (no `CI=`) stay allowed.
|
|
190
190
|
- `lane check --gate` and `receipt write --run` queue every gate themselves, `lane check` runs each reviewer under a slot (its timeout starts once the slot is granted), and `lane closeout` pushes through the landing reserve.
|
|
191
191
|
- `[TOOL GAP hub-86]` MW5-19 places this helper as the `heavy-slot` util. It ships here until the util pipeline exists.
|
|
192
192
|
|
|
@@ -1956,8 +1956,9 @@ basis until the MW clause it is drafting is uploaded. The hook's shape follows
|
|
|
1956
1956
|
the planner's done-check decisions on that page.
|
|
1957
1957
|
|
|
1958
1958
|
`harness install` and `harness update` (not `--dry-run`) also write a git
|
|
1959
|
-
hook, `push-hook.sh` from this package, as
|
|
1960
|
-
`post-
|
|
1959
|
+
hook, `push-hook.sh` from this package, as `post-commit`, `post-rewrite`
|
|
1960
|
+
and `post-merge` (git runs `post-merge`, not `post-commit`, after `git merge`
|
|
1961
|
+
makes a merge commit) in the directory `git rev-parse --git-path hooks` names, so a
|
|
1961
1962
|
`core.hooksPath` is respected. They do this first, from the CLI's own copy,
|
|
1962
1963
|
so a checkout that cannot reach Dev still gets them. That holds in a lane
|
|
1963
1964
|
session too: when the lane's own checks refuse the command first (no sign-in,
|
|
@@ -1983,6 +1984,12 @@ worker pushes the tip. In the background, the worker:
|
|
|
1983
1984
|
- pushes the current branch's tip to `origin`, never with force and never
|
|
1984
1985
|
`main` or `master`. A commit on a detached HEAD is not pushed: an `INFO`
|
|
1985
1986
|
line logs it.
|
|
1987
|
+
- pushes through `nodii-dev heavy run` (the `nodii-dev` on PATH), so the push
|
|
1988
|
+
and the repository's `pre-push` gates take a slot and read the machine
|
|
1989
|
+
floor like any push (MW2-51, DEV-PROCESS-2; hub-729). Under the
|
|
1990
|
+
floor (exit 75), or with no `nodii-dev` on PATH, nothing is pushed: it logs
|
|
1991
|
+
`not pushed SHA attempt=N: under the machine floor` (or `no nodii-dev on
|
|
1992
|
+
PATH`) and retries on the schedule below. It never pushes around the queue.
|
|
1986
1993
|
- first scans the commits not yet on any origin ref with
|
|
1987
1994
|
`gitleaks git --redact`. A finding means no push, `secret found: RULE FILE
|
|
1988
1995
|
(commit SHORT)` in the log and the state `push blocked: secret`. gitleaks
|
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, lstat, mkdir, readFile, rename, rm, writeFile } from "node:fs/pr
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { basename, dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.221";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/heavy-slot.sh
CHANGED
|
@@ -209,6 +209,8 @@ while [ $# -gt 0 ]; do
|
|
|
209
209
|
--tighten=*) TIGHTEN="${TIGHTEN:+$TIGHTEN,}${1#--tighten=}"; shift;;
|
|
210
210
|
# The drill's red run (o2-red-run.confirm.md): `heavy run --help` once took a slot and ran `--help` as a command.
|
|
211
211
|
-h|--help) cat <<'USAGE'
|
|
212
|
+
Runs a command in a heavy slot (end-to-end only) or a light slot (typecheck, lint, unit tests, push), or refuses it at once below the machine floor (MW2-51).
|
|
213
|
+
|
|
212
214
|
usage: nodii-dev heavy run [--size light|heavy] [--tighten READING=GB] -- <command...>
|
|
213
215
|
nodii-dev heavy status
|
|
214
216
|
|
|
@@ -431,7 +433,9 @@ local frc=0; floor_gate || frc=$?; [ "$frc" -eq 0 ] || return "$frc"
|
|
|
431
433
|
# (limit - held) live tickets may try for a slot. Landings keep their reserve and skip the line.
|
|
432
434
|
local Q="$D/q" TICKET=""; [ "$SIZE" = light ] && Q="$D/lq"; mkdir -p "$Q" 2>/dev/null
|
|
433
435
|
if [ "$IS_LANDING" != 1 ]; then TICKET="$Q/$(date +%s).$(printf '%06d' $$)"; echo $$ > "$TICKET"; fi
|
|
434
|
-
trap '
|
|
436
|
+
# The trap names the ticket's path, not $TICKET: TICKET is local to main, so when a refusal returns from main the EXIT
|
|
437
|
+
# trap ran with it unset ("TICKET: unbound variable" under set -u, O2 green run 28 Nov) and the ticket stayed queued.
|
|
438
|
+
if [ -n "$TICKET" ]; then trap "rm -f '$TICKET'" EXIT; fi
|
|
435
439
|
# v25 (13 Nov, hub-377): a STOPPED waiter (ps state T: ^Z, SIGSTOP, a suspended session) never polls, so it can never
|
|
436
440
|
# take a slot, yet it kept its rank: eight stopped head tickets held 46 live waiters for an hour with 1/6 slots held
|
|
437
441
|
# (05:30Z, reported by rbac-edge-strip). A stopped waiter keeps its ticket, so it gets its place back when it resumes,
|
|
@@ -487,7 +491,7 @@ while :; do
|
|
|
487
491
|
# v30: this read is the one that admits the job, so it is the one logged (--admit), once, admission or
|
|
488
492
|
# refusal, without the job's own slot (--self) and before the job starts.
|
|
489
493
|
frc=0; floor_gate --self "$l" --admit || frc=$?
|
|
490
|
-
if [ "$frc" -ne 0 ]; then rmdir "$D/.admit"; rm -rf "$l"; return "$frc"; fi
|
|
494
|
+
if [ "$frc" -ne 0 ]; then rmdir "$D/.admit"; rm -rf "$l"; [ -n "$TICKET" ] && rm -f "$TICKET"; TICKET=""; return "$frc"; fi
|
|
491
495
|
date +%s > "$SD/last-admit"; rmdir "$D/.admit"; slot="$l"; [ -n "$TICKET" ] && rm -f "$TICKET"; TICKET=""; break 2
|
|
492
496
|
fi
|
|
493
497
|
rmdir "$D/.admit"
|
package/dist/heavy.js
CHANGED
|
@@ -474,8 +474,9 @@ export function ciOnlyViolation(command) {
|
|
|
474
474
|
return {
|
|
475
475
|
code: "SAFETY_CI_ONLY",
|
|
476
476
|
message: [
|
|
477
|
-
|
|
478
|
-
|
|
477
|
+
// The first line is the frozen text in DEV-PROCESS-2's o2-clause-texts.md ("Help and hook text"); done check step 7.
|
|
478
|
+
`\`${found.text}\` runs over every page and runs in CI only; locally run it on the touched pages (\`--touched\`). Covered by the pull request's ${covering.job} check (MW1-107).`,
|
|
479
|
+
`Not run here. That check is "${covering.check}" (design-system CI, job ${covering.job}). DEV-PROCESS-2, hub-650.`,
|
|
479
480
|
covering.local,
|
|
480
481
|
].join("\n"),
|
|
481
482
|
};
|
package/dist/push-hook.sh
CHANGED
|
@@ -8,9 +8,12 @@
|
|
|
8
8
|
# decisions on that page: a git hook installed by harness install, rewrites, 24 h retry, hooks path and
|
|
9
9
|
# chaining, PR whenever none, secret scan before push. One push worker per branch, a short debounce, and the
|
|
10
10
|
# PR opened outside the push lock follow the reviews of #539 and #542.
|
|
11
|
-
# Installed as
|
|
11
|
+
# Installed as post-commit, post-rewrite and post-merge where `git rev-parse --git-path hooks` points: git runs
|
|
12
|
+
# post-merge, not post-commit, after `git merge` makes a merge commit (hub-728).
|
|
12
13
|
#
|
|
13
14
|
# After every commit or rewrite it returns at once and, in the background:
|
|
15
|
+
# - pushes through `nodii-dev heavy run` (hub-729): the push and its pre-push gates take a slot and
|
|
16
|
+
# read the machine floor; under the floor (75) or with no nodii-dev on PATH it is retried, never sent around;
|
|
14
17
|
# - pushes the CURRENT branch only (its tip, refs/heads/<br>), never main or master, never with force;
|
|
15
18
|
# a detached HEAD is not pushed and an INFO line is logged;
|
|
16
19
|
# - before any push, scans the commits not yet on any origin ref with `gitleaks git --redact`. A finding,
|
|
@@ -50,6 +53,8 @@ case $br in main|master) exit 0 ;; esac
|
|
|
50
53
|
git remote get-url origin >/dev/null 2>&1 || exit 0
|
|
51
54
|
|
|
52
55
|
RETRY_S=20 RETRY_MAX_S=300 WINDOW_S=86400
|
|
56
|
+
# The nodii-dev whose `heavy run` queues the push (hub-729); found once, from PATH.
|
|
57
|
+
HEAVY_CLI=$(command -v nodii-dev 2>/dev/null || true)
|
|
53
58
|
API=${GITHUB_API_URL:-https://api.github.com}; API=${API%/}
|
|
54
59
|
STATE_DIR=$GCD/nodii-push
|
|
55
60
|
STATE_FILE=$STATE_DIR/$(printf '%s' "$br" | tr '/' '~').state
|
|
@@ -161,7 +166,7 @@ errline() { printf '%s' "$1" | tr '\n' ' ' | sed -E 's#(://)[^/@ ]+@#\1***@#g' |
|
|
|
161
166
|
transport_error() { printf '%s' "$1" | grep -qiE 'unreachable|could not read from remote|unable to access|could not resolve|connection|timed out|early eof|remote end hung up|failed to lock|cannot lock ref|RPC failed|SSL|proxy'; }
|
|
162
167
|
|
|
163
168
|
work() {
|
|
164
|
-
local i=0 err wait=$RETRY_S start sha rt pp
|
|
169
|
+
local i=0 err wait=$RETRY_S start sha rt pp rc slot_wait
|
|
165
170
|
start=$(now)
|
|
166
171
|
mkdir -p "$STATE_DIR"
|
|
167
172
|
while :; do
|
|
@@ -169,7 +174,14 @@ work() {
|
|
|
169
174
|
# Push the branch's tip as it is now, so a burst of commits lands as one push.
|
|
170
175
|
sha=$(git rev-parse --verify --quiet "refs/heads/$br") || { log "branch $br is gone; nothing pushed"; return 0; }
|
|
171
176
|
scan "$sha" || return 0
|
|
172
|
-
|
|
177
|
+
# hub-729 (DEV-PROCESS-2, MW2-51): the push and the repository's pre-push gates run under a slot and
|
|
178
|
+
# the machine floor, like any push. Under the floor (75) or with no nodii-dev to queue in, nothing is pushed
|
|
179
|
+
# and the push is retried below; it is never sent around the queue.
|
|
180
|
+
rc=0
|
|
181
|
+
if [ -z "$HEAVY_CLI" ]; then rc=127; err="no nodii-dev on PATH, so no heavy slot to push in"
|
|
182
|
+
else err=$("$HEAVY_CLI" heavy run -- git push --quiet origin "$sha:refs/heads/$br" 2>&1) || rc=$?
|
|
183
|
+
fi
|
|
184
|
+
if [ "$rc" -eq 0 ]; then
|
|
173
185
|
# Read the remote branch back in its own call (K03-16): it must hold this commit.
|
|
174
186
|
rt=$(git ls-remote origin "refs/heads/$br" 2>/dev/null | cut -f1)
|
|
175
187
|
if [ "$rt" = "$sha" ] || { [ -n "$rt" ] && git merge-base --is-ancestor "$sha" "$rt" 2>/dev/null; }; then
|
|
@@ -178,6 +190,14 @@ work() {
|
|
|
178
190
|
fi
|
|
179
191
|
err="push read-back: origin at ${rt:-nothing}, not $sha (connection)"
|
|
180
192
|
fi
|
|
193
|
+
if [ "$rc" -eq 75 ] || [ "$rc" -eq 127 ]; then
|
|
194
|
+
[ "$rc" -eq 75 ] && slot_wait="under the machine floor" || slot_wait="no nodii-dev on PATH"
|
|
195
|
+
if [ $(( $(now) - start + wait )) -gt "$WINDOW_S" ]; then log "gave-up $sha after $i attempts ($slot_wait); ahead of remote"; state "ahead of remote: gave up after 24 h"; return 1; fi
|
|
196
|
+
log "not pushed $sha attempt=$i: $slot_wait, retry in ${wait}s: $(errline "$err")"
|
|
197
|
+
state "ahead of remote: $slot_wait, retrying"
|
|
198
|
+
beat; sleep "$wait"; wait=$((wait * 2)); [ "$wait" -gt "$RETRY_MAX_S" ] && wait=$RETRY_MAX_S
|
|
199
|
+
continue
|
|
200
|
+
fi
|
|
181
201
|
if printf '%s' "$err" | grep -qE 'non-fast-forward|fetch first|\[rejected\]|stale info'; then
|
|
182
202
|
rt=$(git ls-remote origin "refs/heads/$br" 2>/dev/null | cut -f1)
|
|
183
203
|
if [ -n "$rt" ] && git merge-base --is-ancestor "$sha" "$rt" 2>/dev/null; then log "superseded $sha (origin at $rt)"; return 0; fi
|
package/dist/push-hooks.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// The git hooks that push a lane's branch after every commit (O22, DEV-PROCESS-13).
|
|
2
2
|
//
|
|
3
3
|
// `nodii-dev harness install|update` writes push-hook.sh (beside this file) as
|
|
4
|
-
//
|
|
4
|
+
// post-commit, post-rewrite and post-merge (git runs post-merge, not post-commit,
|
|
5
|
+
// after a merge commit: hub-728) where `git rev-parse --git-path hooks`
|
|
5
6
|
// points, so a core.hooksPath override is respected. A hook that was already
|
|
6
7
|
// there and is not nodii-dev's is kept as <hook>.nodii-chained and still runs
|
|
7
8
|
// first. Hooks live in the git directory, not the working tree, so they are no
|
|
@@ -13,7 +14,7 @@ import { promisify } from "node:util";
|
|
|
13
14
|
|
|
14
15
|
export const PUSH_HOOK_SCRIPT = new URL("./push-hook.sh", import.meta.url);
|
|
15
16
|
export const PUSH_HOOK_MARKER = "nodii-dev:push-hook";
|
|
16
|
-
export const PUSH_HOOK_NAMES = ["post-commit", "post-rewrite"];
|
|
17
|
+
export const PUSH_HOOK_NAMES = ["post-commit", "post-rewrite", "post-merge"];
|
|
17
18
|
export const CHAINED_SUFFIX = ".nodii-chained";
|
|
18
19
|
|
|
19
20
|
const execFileAsync = promisify(execFile);
|