@indigoai-us/hq-cli 5.345.231 → 5.345.232

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +3 -2
  3. package/assets/lanes-reconcile/hq-lanes-reconcile.service +1 -1
  4. package/assets/scaffold/core/scripts/pipeline-conductor.sh +14 -14
  5. package/assets/scaffold/core/scripts/pipeline-driver.sh +7 -7
  6. package/assets/scaffold/core/scripts/session-project.sh +19 -4
  7. package/dist/command-catalog.generated.d.ts +213 -177
  8. package/dist/command-catalog.generated.js +263 -212
  9. package/dist/command-registration-plan.d.ts +6 -24
  10. package/dist/command-registration-plan.js +4 -8
  11. package/dist/commands/auth.js +3 -2
  12. package/dist/commands/core-pipeline-conductor-command.js +1 -1
  13. package/dist/commands/core-pipeline-conductor-native.js +5 -5
  14. package/dist/commands/core-pipeline-driver-native.js +5 -5
  15. package/dist/commands/daemon.js +7 -36
  16. package/dist/commands/deploy-access.js +6 -13
  17. package/dist/commands/deploy-comments.js +5 -13
  18. package/dist/commands/deploy-domains.js +6 -13
  19. package/dist/commands/deploy-list.js +25 -11
  20. package/dist/commands/deploy-mutations.d.ts +3 -0
  21. package/dist/commands/deploy-mutations.js +147 -0
  22. package/dist/commands/link.js +29 -0
  23. package/dist/commands/mesh.js +3 -1
  24. package/dist/commands/report.js +8 -9
  25. package/dist/data/command-states.json +10 -7
  26. package/dist/lib/bot/fleet-bots-update-pass.d.ts +8 -0
  27. package/dist/lib/bot/fleet-bots-update-pass.js +40 -0
  28. package/dist/lib/bot/fleet-bots-update-task.d.ts +12 -0
  29. package/dist/lib/bot/fleet-bots-update-task.js +52 -0
  30. package/dist/lib/bot/fleet-bots-update-worker-v1.d.ts +2 -0
  31. package/dist/lib/bot/fleet-bots-update-worker-v1.js +5 -0
  32. package/dist/lib/daemon/catalog.d.ts +8 -5
  33. package/dist/lib/daemon/catalog.js +15 -8
  34. package/dist/lib/daemon/lock.js +33 -37
  35. package/dist/lib/daemon/ops/skill-command.d.ts +99 -0
  36. package/dist/lib/daemon/ops/skill-command.js +260 -0
  37. package/dist/lib/daemon/protocol.d.ts +1 -1
  38. package/dist/lib/daemon/protocol.js +1 -0
  39. package/dist/lib/daemon/run.js +10 -18
  40. package/dist/lib/daemon/server.js +7 -0
  41. package/dist/lib/daemon/supervisor.d.ts +5 -0
  42. package/dist/lib/daemon/supervisor.js +17 -2
  43. package/dist/lib/db/app-ref.js +10 -15
  44. package/dist/lib/deploy-apps.d.ts +29 -0
  45. package/dist/lib/deploy-apps.js +37 -0
  46. package/dist/lib/doctor/checks/search-index.d.ts +16 -0
  47. package/dist/lib/doctor/checks/search-index.js +61 -0
  48. package/dist/lib/doctor/checks/stranded-lanes.js +1 -1
  49. package/dist/lib/doctor/registry.js +4 -0
  50. package/dist/lib/lanes/accounts.js +3 -3
  51. package/dist/lib/lanes/admission-host.js +1 -1
  52. package/dist/lib/lanes/admission.js +4 -4
  53. package/dist/lib/lanes/autopilot.js +2 -2
  54. package/dist/lib/lanes/blocker-freshness.js +1 -1
  55. package/dist/lib/lanes/compaction.js +5 -5
  56. package/dist/lib/lanes/delivery.js +1 -1
  57. package/dist/lib/lanes/depth-cap.js +1 -1
  58. package/dist/lib/lanes/disk-guard.js +1 -1
  59. package/dist/lib/lanes/dropbox.js +1 -1
  60. package/dist/lib/lanes/hooks-install.js +1 -1
  61. package/dist/lib/lanes/imported-question.js +1 -1
  62. package/dist/lib/lanes/keep-alive.d.ts +2 -2
  63. package/dist/lib/lanes/keep-alive.js +3 -3
  64. package/dist/lib/lanes/kr-freshness.js +1 -1
  65. package/dist/lib/lanes/links.js +4 -4
  66. package/dist/lib/lanes/loop.js +2 -2
  67. package/dist/lib/lanes/machine-identity.js +3 -3
  68. package/dist/lib/lanes/models.js +6 -6
  69. package/dist/lib/lanes/quota.js +1 -1
  70. package/dist/lib/lanes/reconcile-install.js +3 -3
  71. package/dist/lib/lanes/reconcile.js +16 -16
  72. package/dist/lib/lanes/remote-control-lane.js +6 -6
  73. package/dist/lib/lanes/reviews.js +2 -2
  74. package/dist/lib/lanes/spawn.js +24 -24
  75. package/dist/lib/lanes/status-fields.js +4 -4
  76. package/dist/lib/lanes/wait.js +4 -4
  77. package/dist/lib/lanes/watch.js +2 -2
  78. package/dist/lib/lanes/watcher-main.js +1 -1
  79. package/dist/lib/lanes/watcher.js +38 -38
  80. package/dist/lib/lanes/worker-process.js +5 -5
  81. package/dist/lib/mesh/live/daemon/pid-lock.d.ts +2 -4
  82. package/dist/lib/mesh/live/daemon/pid-lock.js +38 -55
  83. package/dist/utils/exclusive-lock.d.ts +60 -0
  84. package/dist/utils/exclusive-lock.js +65 -0
  85. package/package.json +8 -7
  86. package/dist/commands/staff/listings.d.ts +0 -41
  87. package/dist/commands/staff/listings.js +0 -160
  88. package/dist/commands/staff/reset-test-account.d.ts +0 -121
  89. package/dist/commands/staff/reset-test-account.js +0 -285
  90. package/dist/commands/staff/test-account.d.ts +0 -51
  91. package/dist/commands/staff/test-account.js +0 -196
package/CHANGELOG.md CHANGED
@@ -2,6 +2,37 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [5.345.232] — 2026-11-18
6
+ - `hq-hook` claims `codex-adapter:PostToolUse` on Codex only (`PostToolUse@codex`): the Codex adapter's own PostToolUse work is native. `master-hook:PostToolUse` and each settings command keep their own ids and stay unclaimed, so PostToolUse stays on the old dispatcher.
7
+ - hq-hook can now build and leave a `codex-settings` request note for the HQ daemon: one Codex PostToolUse call's `.claude/settings.json` records, with the payload as the note's body. It refuses a note the daemon would drop. No hook calls it yet, and no hook claim changes.
8
+ - Add authenticated deploy create, archive upload, takedown, password/private gate, and app inspection commands for company and personal scopes. `hq deploy list --personal` lists the personal deploy scope, so the deploy skills can find a personal app without calling the API themselves.
9
+ - Every command that takes a deploy app by id, subdomain or name (`hq deploy comments`, `hq deploy access`, `hq deploy domains --app`, `hq db --app`) now finds it the same way: equal to the app's id, subdomain or name, ignoring case, and refused when more than one app fits. `hq deploy comments` now also accepts a subdomain and ignores case; `hq db --app` now ignores case. `hq report` publishing uses the same lookup but keeps its exact rule: it reuses an app only when the app's subdomain or name equals the report address, case included, never by id; it now refuses an address that fits two apps instead of taking the first.
10
+ - `hq auth status` and the `hq mesh` thread commands (`start`, `progress`, `blocked`, `done`, `note`, and every other `hq mesh` subcommand that fails through the same handler) stop the background flag-registry worker before they exit with an error, so they no longer risk a crash at exit (SIGSEGV on Node 20 and 22) after printing their message.
11
+ - On Grok, a native `list_dir` or `ListDir` call with any target and a `prd.json` or `worker.yaml` pattern is now refused with the message the released adapter gives, instead of being allowed; `Glob` gets the same bytes the adapter writes.
12
+ - The native hook engine's Grok PreToolUse work (not yet switched on) now records, with a test, the calls it refuses that the released Grok adapter allowed without running any hook: a write or edit that names no file, Grok's workflow tool, and a call that names no tool. Calls the adapter skipped and native also allows are checked byte for byte.
13
+ - The seven staff-only commands under `hq staff` (`reset-test-account`, `test-account add`, `remove` and `list`, `listings queue`, `approve` and `reject`) are no longer part of the public CLI. They were marked as being retired in an earlier release; now `hq --help --all` no longer lists them and `hq staff` is an unknown command. The server already refused them to anyone who is not staff. Staff run them from a staff-only tool outside the public CLI.
14
+ - The hq-hook build-identity check now reads Windows paths (backslashes, mixed separators, the `\\?\` prefix `canonicalize` adds, either drive-letter case) the same as slash paths, so test fixtures under `crates/hq-hook/tests` count as fixtures on Windows too and every platform checks the same embedded inputs against the same fingerprinted set.
15
+ - Hooks: the native fleet-local PreToolUse member (not registered yet) now runs the released fleet-local adapter's env dump check on a Bash command and on a Codex exec approval's resolved command, in-process and in the adapter's order, with the adapter's two messages. Where the adapter's verdict depends on the locale, the grep or a Windows carriage return, it blocks whenever any of them would.
16
+ - Hooks: the native fleet-local PreToolUse member now runs the released adapter's sensitive home path check, after the gate and parent scope checks and before the dispatcher and settings checks, as the adapter does. It reads the Bash command, the Read, Grep, Glob, Edit and Write paths, and on the approval path the resolved exec command and each `apply_patch` path. It blocks with the adapter's message. When it cannot decide (for example `HOME` unset or not UTF-8, or an input shape it does not model) it refuses. The member is still not registered. It reads the runtime tool name as the adapter's shell holds it (trailing newlines cut, NUL bytes dropped), and refuses when `HOME` contains a newline or a carriage return.
17
+ - Internal: the `hq-hook` mesh tool-writes parity test's stand-in daemon now runs only the request notes of the hook call whose shim started it, and runs them with its own environment as the HQ daemon does. A stand-in started late by an earlier call on a loaded machine could take a later call's prd-sync note and run it with the wrong stub settings (the Linux CI failure of "f14 same-company switch: prd-sync missing"). Test-only; no behaviour change.
18
+ - `hq-hook` now trusts the `hook-engine-port-*` flags for 15 minutes instead of 24 hours. When the newest flag snapshot (or the daemon's state file) for the scope is older than that, every port flag reads as off and the bridged hooks run in bash, so a hook-engine kill switch reaches a machine without a fresh daemon, including on Windows, within 15 minutes. Every other flag keeps the 24-hour bound. Guards that cannot decide still refuse; only the engine that answers changes.
19
+ - Internal: hq-hook's native Codex SubagentStop `conduct-lanes-link-deliver` note now carries the event's time (`args.at`), so the daemon's `_deliver` run takes only link messages queued at or before the event and leaves later ones queued for the root's next PostToolUse or Stop, as the released adapter's run during the event did. The `us050sas-deliver-note` ledger row loses its second loss.
20
+ - Internal: the manual sign-in tests now bind the registered callback port 8765 instead of 53682. 53682 lies inside the operating system's ephemeral port range, so another test's server could be given it and four sign-in tests failed together with "port 53682 stayed busy". No change to `hq login` itself.
21
+ - `session-project.sh append-event` (and the other locked writes) no longer exits with "could not acquire project write lock" on Windows when the project lock was just released. Windows keeps a removed lock directory delete-pending while another process still holds a handle, and creating it again fails with EPERM, EACCES or EBUSY instead of EEXIST; the shell writer now waits on those codes like the native writer already did, and retries removing its own lock so no ownerless lock directory is left behind. The five-second wait is unchanged, and other platforms still fail fast on those codes.
22
+ - `hq resolve-company --prompt "<text>"` (with optional `--root <dir>`) now resolves the active company for skills and routing (whole-token manifest slug in the text, then the session's company, then the enabled device default) and prints `{"company":"<slug>","source":"prompt|session|device_default|none"}`. It runs the same resolver as `hq core resolve-company --prompt`, so skills can move to the one public command (US-030 c1). `--prompt` cannot be combined with `--path`, and unlike folder mode it does not need HQ Anywhere.
23
+ - hq-hook: `hq-hook bridge inject-policy-on-trigger` takes `--host codex|grok`, the call the released Codex and Grok adapters make when `hook-engine-port-inject-policy-on-trigger` is on, and answers the policy injector natively there, byte for byte as the bash injector the adapter runs today. It keeps bash (exit 75, no output) on a payload that is not one JSON object, a harness that names another host, no HQ root, any other hook id, and on Grok whenever a held-reminder switch is set or a held store exists, and where the Rust state store is off (Windows until US-022), where the native injector would deny every prompt. The native injector now evaluates Grok's PostToolUse for the current injector release, as the bash injector does (US-014).
24
+ - Internal: the host canary (`scripts/host-canary.mjs`) takes `--turns` for Codex and Grok, default 3 (Claude stays at 1). With two or more turns it compares every native policy-injector answer with the bash injector's answer on the same payload, run through the host's released adapter, `hook-adapter-core.sh` and `hook-gate.sh` on a copy of the root cut down to the injector row, after the host exits, in a throwaway HOME, and reports counts only. A parity failure fails the host's canary record.
25
+ - CI: release-tag runs now check, on the Windows "core utility parity" job, that `hq-hook bridge-plan` leaves the state-store ports out where the store is off, and that a Claude Code prompt through master-hook with `hook-engine-port-inject-policy-on-trigger` on is answered by the bash hook instead of the port's store-off deny.
26
+ - User-facing text now names `hq runners` instead of the deprecated `hq lanes` alias: the `hq daemon` remote-control pool `--account-id` help and its HQ-folder error, the `hq doctor` stranded-lane fix command, the `hq-lanes-reconcile.service` ExecStart (bundled asset and the unit `hq runners reconcile install` writes), the bundled `pipeline-conductor.sh` and `pipeline-driver.sh` calls and messages (and the matching native conductor and driver messages), `docs/lanes.md`, `docs/conductor-delivery.md`, and the stderr prefixes and hints in the runners library where no test pins the old text. `hq lanes` still works as an alias with the same routing, and hooks still recognise calls made with the old name.
27
+ - `hq-hook run` has a native `enforce-vault-write-access` in the PreToolUse path rules for Edit, Write, MultiEdit and NotebookEdit, with master-hook's `.hq/vault-access.json` file prefilter, matching the released bash guard; it starts no program. Bash keeps the shell hook and the id is not claimed yet (owner ruling: keep every released block).
28
+ - hq-hook now handles `40-skill-command-script` on UserPromptSubmit itself. It starts no program: when a `/command` prompt resolves to a skill's `command.sh`, it asks the HQ daemon over its socket (new request `skill.command`) and waits up to the daemon's own 2-second request timeout. hqd runs the pinned released hook with the caller's payload and folder, in an environment it builds itself (the hook's own settings, hqd's own PATH, the verified HQ root as HQ_ROOT, and never BASH_ENV, ENV, exported functions, SHELLOPTS, BASHOPTS or CDPATH), and the output is shown to the person only. If the hook, hook-lib.sh, or a session-scope-capability.sh or perl-child-locale.sh present on disk is not the pinned release (hqd checks the same pins), or HQ_ROOT names another checkout, the whole UserPromptSubmit event goes to the released shell hooks instead. With no daemon, a timeout, a daemon refusal or an input the native check cannot decide, the prompt is refused with one message that names hqd and says to start it with `hq daemon start`.
29
+ - hq-hook: `hq-hook run --host codex Stop` now gives the Codex adapter's own Stop answer natively. A hook's block is read as the adapter read it (every block object on stdout, or the last JSON line after words, Windows line ends included), the reason loses its trailing newlines and is not cut, context JSON goes out as its text, and words from a hook that exits 1 are shown. Native stays stricter in four recorded cases: a block with no usable text reason, a block whose JSON holds a bare carriage return, a hook that exits 2, and a payload that names another event all block. `codex-adapter:Stop` is claimed. New parity test against the released adapter (US-050 c1).
30
+ - The native hook engine now does the old dispatcher's Task-agent work on Claude Code's SubagentStart: a new subagent's scope tuple is pinned from the main thread's company lock set (never over an existing tuple), and the subagent's company picks the folder hooks, as before. Under a scope library version the engine does not model, that SubagentStart work is refused natively with the reason on stderr. SubagentStart is not switched over by this change. The parent's multi-company lock is read with the multi-company-session-lock switch, so a subagent is never pinned wider than the old dispatcher pinned it.
31
+ - The native hook engine now claims the old dispatcher's own work on SubagentStart on Claude Code and Grok Build (session bind, duplicate-event check, timeout journal, and on Claude Code the Task-agent scope pin), as it does for Notification, so SubagentStart has no unclaimed hook left in the coverage list. On Grok Build it runs after the adapter's own subagent company bind, as the adapter did. If an HQ has a SubagentStart hook that the engine does not run, the native event does none of that work and prints why on stderr; run `hq reindex` to keep the event on the old dispatcher while such a hook exists. `hq reindex` still keeps SubagentStart on the old dispatcher until the engine reports `lifecycle-dispatch`.
32
+ - Internal: the native Grok PostToolUse port now pins the beta.121 adapter generation (adapter b9075b2f, core 940bb5a0) that current hq-core ships, counting the `HQAD_DISPATCHER_PID` its core exports in the jq byte budget at the widest pid. Before, every Grok tool call on a current root failed closed as an unknown adapter.
33
+ - The daemon's search-index timer no longer falls back to starting `hq index sync` when its in-process worker cannot run (the daemon could not hand its package lease to the worker, or a rollback left an install without the worker). It now schedules nothing, marks the `search-index` unit unavailable with the reason in `hq daemon status`, and a new `hq doctor` check (`search-index.schedule`) warns that the search index is not refreshed on a timer and how to fix it. Running `hq index sync` by hand is unchanged.
34
+ - The daemon's HQ Fleet bot update (`fleet-bots-update`, every 30 minutes) no longer starts a fresh `hq daemon service fleet-bots-update` process. It runs as a daemon internal task on a worker thread, with the same eligibility checks and update steps as before (the command and the task share one function). A failing or crashing pass is recorded as a failed run and stops no other daemon work. `hq daemon service fleet-bots-update` still runs one pass by hand.
35
+
5
36
  ## [5.345.231] — 2026-11-18
6
37
  - The daemon now runs a new `codex-settings` request note: the `.claude/settings.json` PostToolUse commands of one Codex tool call, started one by one with the payload on stdin and the variables the released Codex adapter gave its hooks (`HQ_CHECKPOINT_RUNTIME=codex`, `HQ_HARNESS=codex`, `HQ_WORK_MESH_HARNESS=codex`, `BASH_ENV=/dev/null`, `HQ_ROOT` and `CLAUDE_PROJECT_DIR` set to the root, `HQAD_EVENT_SESSION_ID`; no `HQ_WORK_MESH_DISABLED`). A command the root's settings no longer list is refused. No hook leaves this note yet, and `codex-adapter:PostToolUse` stays unclaimed.
7
38
  - `hq-hook run --host codex PreToolUse` now refuses a Codex `apply_patch`, `Edit` or `Write` into `companies/_template/` natively, with the released Codex adapter's own message (`block_template_edit_if_needed`). It also refuses the readings other machines' adapters refused (a CR in the tool name, other case, backslashes, symlinks) and a path it cannot resolve. `codex-adapter:PreToolUse` stays unclaimed. An edit path holding a NUL byte is refused, a Git Bash `/c/...` or cygwin `/cygdrive/c/...` path is read as `C:/...`, and with no `--hq-root` the edit is refused instead of falling back to `HQ_ROOT`, `CLAUDE_PROJECT_DIR` or the cwd. A template edit in a root with no `.claude/hooks/hook-gate.sh` is refused too, where the adapter exited 0 before any check.
package/README.md CHANGED
@@ -52,10 +52,11 @@ List the hq-deploy apps in your company. Each line shows the app name, public
52
52
  URL, type, access mode and last activity time (updated, last visit or created,
53
53
  whichever the API returns). The optional `query` filters case-insensitively by
54
54
  substring across name, subdomain and title. `--company` defaults to the active
55
- company. Use `--json` for machine-readable output.
55
+ company. `--personal` lists your personal deploy scope instead (it cannot be
56
+ combined with `--company`). Use `--json` for machine-readable output.
56
57
 
57
58
  ```bash
58
- hq deploy list [query] [--company <slug>] [--json]
59
+ hq deploy list [query] [--company <slug> | --personal] [--json]
59
60
  ```
60
61
 
61
62
  An empty unfiltered list prints a hint instead of claiming the org has no apps.
@@ -4,7 +4,7 @@ Documentation=file://personal/projects/hq-cli-lanes/SPEC.md
4
4
 
5
5
  [Service]
6
6
  Type=oneshot
7
- ExecStart=hq lanes reconcile
7
+ ExecStart=hq runners reconcile
8
8
  Nice=10
9
9
 
10
10
  [Install]
@@ -103,7 +103,7 @@
103
103
  #
104
104
  # State dir layout:
105
105
  # stories/<id>.json phases, current index, state, reroutes, worktree
106
- # envelopes/<id>-<phase>.json envelopes queued to hq lanes
106
+ # envelopes/<id>-<phase>.json envelopes queued to hq runners
107
107
  # handoffs/<id>-<phase>.json accepted phase handoffs
108
108
  # decisions/<id>-<worker>.md approval items for the parent session
109
109
  # decisions/<id>-blocked-<phase>.md a worker returned status blocked
@@ -197,7 +197,7 @@
197
197
  #
198
198
  # Exit codes: 0 ok; 1 refused or failed; 2 usage; 3 lane capacity/admission (retry next tick);
199
199
  # 10 held for a parent decision (approval hold, or a blocked handoff on accept);
200
- # 11 lane down: `hq lanes enqueue` returned `loop_not_running` or a terminal
200
+ # 11 lane down: `hq runners enqueue` returned `loop_not_running` or a terminal
201
201
  # lane state. The worker mapping is dropped, the story stays queued, and
202
202
  # route prints LANE_DOWN <id> <phase> <worker> ...; tick stops there.
203
203
  # 12 no lane: the phase's worker has no row in the run's worker table (NO_LANE);
@@ -1692,10 +1692,10 @@ function do_route(p, sid) {
1692
1692
  if (lane) {
1693
1693
  let rows;
1694
1694
  try {
1695
- const listed = JSON.parse(run(E.PC_HQ, ["lanes", "list", "--json"], { timeout: 30000 }).stdout || "{}");
1695
+ const listed = JSON.parse(run(E.PC_HQ, ["runners", "list", "--json"], { timeout: 30000 }).stdout || "{}");
1696
1696
  rows = Array.isArray(listed) ? listed : get(listed, "lanes", null);
1697
- } catch (e) { die("cannot verify mapped pipeline lane ownership: hq lanes list returned invalid JSON"); }
1698
- if (!Array.isArray(rows)) die("cannot verify mapped pipeline lane ownership: hq lanes list omitted lanes");
1697
+ } catch (e) { die("cannot verify mapped pipeline lane ownership: hq runners list returned invalid JSON"); }
1698
+ if (!Array.isArray(rows)) die("cannot verify mapped pipeline lane ownership: hq runners list omitted lanes");
1699
1699
  const row = rows.find(x => isDict(x) && get(x, "lane_id") === lane);
1700
1700
  if (!row) { delete laneMap[ph.worker]; jsave(lanesFile, laneMap); lane = null; }
1701
1701
  else if (get(get(row, "company", {}), "slug") !== company || get(row, "project_id") !== project || get(row, "worker") !== ph.worker) {
@@ -1709,7 +1709,7 @@ function do_route(p, sid) {
1709
1709
  const laneBrief = pjoin(laneBriefDir, ph.worker + ".md");
1710
1710
  writeText(laneBrief, "# Pipeline loop lane: " + project + " / " + ph.worker + "\n\n" +
1711
1711
  "Pipeline phases arrive as queued envelopes. Follow each envelope; this standing brief has no task of its own.\n");
1712
- const createArgs = ["lanes", "create", "--loop", "--company", company, "--project", project,
1712
+ const createArgs = ["runners", "create", "--loop", "--company", company, "--project", project,
1713
1713
  "--story", sid, "--worker", ph.worker, "--brief-file", abspath(laneBrief), "--senior", "session:" + session, "--json"];
1714
1714
  const table = get(or(jload(sp("run.json"), {}), {}), "table", "");
1715
1715
  if (T(table) && exists(table)) {
@@ -1722,10 +1722,10 @@ function do_route(p, sid) {
1722
1722
  const createError = get(answer, "error", null);
1723
1723
  const code = S(isDict(createError) ? get(createError, "code", get(answer, "code", "create_failed")) : (createError || get(answer, "code", "create_failed")));
1724
1724
  if (/admission|capacity|full|limit/i.test(code)) { st.state = "queued"; jsave(sfile(sid), st); print("RETRY " + sid + " " + S(ph.phase) + " lanes-" + code); exit(3); }
1725
- die("hq lanes create refused pipeline phase: " + code + " " + strip(created.stderr));
1725
+ die("hq runners create refused pipeline phase: " + code + " " + strip(created.stderr));
1726
1726
  }
1727
1727
  lane = get(answer, "lane_id", get(answer, "lane"));
1728
- if (!T(lane)) die("hq lanes create returned no lane_id");
1728
+ if (!T(lane)) die("hq runners create returned no lane_id");
1729
1729
  laneMap[ph.worker] = lane;
1730
1730
  jsave(lanesFile, laneMap);
1731
1731
  }
@@ -1733,7 +1733,7 @@ function do_route(p, sid) {
1733
1733
  const suffixes = or(get(st, "envelope_suffixes"), {});
1734
1734
  envData.id = baseEnvelopeId + (suffixes[ph.phase] ? ".r" + suffixes[ph.phase] : "");
1735
1735
  envData.result_path = abspath(sp("handoffs", sid + "-" + ph.phase + ".json")); jsave(ep, envData);
1736
- let r = run(E.PC_HQ, ["lanes", "enqueue", lane, "--envelope", abspath(ep)], { timeout: 30000 });
1736
+ let r = run(E.PC_HQ, ["runners", "enqueue", lane, "--envelope", abspath(ep)], { timeout: 30000 });
1737
1737
  let ans; try { ans = JSON.parse(r.stdout); } catch (e) { ans = {}; }
1738
1738
  let enqueueError = get(ans, "error", null);
1739
1739
  let code = S(isDict(enqueueError) ? get(enqueueError, "code", get(ans, "code", "enqueue_failed")) : (enqueueError || get(ans, "code", "enqueue_failed")));
@@ -1742,7 +1742,7 @@ function do_route(p, sid) {
1742
1742
  const n = Number(suffixes[ph.phase] || 0) + 1;
1743
1743
  suffixes[ph.phase] = n; st.envelope_suffixes = suffixes; envData.id = baseEnvelopeId + ".r" + n;
1744
1744
  jsave(sfile(sid), st); jsave(ep, envData);
1745
- r = run(E.PC_HQ, ["lanes", "enqueue", lane, "--envelope", abspath(ep)], { timeout: 30000 });
1745
+ r = run(E.PC_HQ, ["runners", "enqueue", lane, "--envelope", abspath(ep)], { timeout: 30000 });
1746
1746
  try { ans = JSON.parse(r.stdout); } catch (e) { ans = {}; }
1747
1747
  enqueueError = get(ans, "error", null);
1748
1748
  code = S(isDict(enqueueError) ? get(enqueueError, "code", get(ans, "code", "enqueue_failed")) : (enqueueError || get(ans, "code", "enqueue_failed")));
@@ -1752,7 +1752,7 @@ function do_route(p, sid) {
1752
1752
  delete laneMap[ph.worker]; jsave(lanesFile, laneMap); st.state = "queued"; jsave(sfile(sid), st);
1753
1753
  print("LANE_DOWN " + sid + " " + S(ph.phase) + " " + S(ph.worker) + " lanes-" + code); exit(11);
1754
1754
  }
1755
- die("hq lanes enqueue failed for " + sid + "/" + S(ph.phase) + ": " + code + " " + strip(r.stderr));
1755
+ die("hq runners enqueue failed for " + sid + "/" + S(ph.phase) + ": " + code + " " + strip(r.stderr));
1756
1756
  }
1757
1757
  st.state = "in_flight"; st.started = true; st.routed_at = now(); pop(st, "held_for");
1758
1758
  pop(st, "owner_retry");
@@ -2425,7 +2425,7 @@ function lane_runs() {
2425
2425
 
2426
2426
  function withdraw(lane, sid, ph) {
2427
2427
  if (!T(lane)) return false;
2428
- const r = run(E.PC_HQ, ["lanes", "interrupt", lane, "--story", sid, "--phase", ph, "--json"], { timeout: 30000 });
2428
+ const r = run(E.PC_HQ, ["runners", "interrupt", lane, "--story", sid, "--phase", ph, "--json"], { timeout: 30000 });
2429
2429
  let ans; try { ans = JSON.parse(r.stdout); } catch (e) { return false; }
2430
2430
  const id = sid + "-" + ph;
2431
2431
  if ((get(ans, "withdrawn", []) || []).includes(id)) return true;
@@ -2484,10 +2484,10 @@ function do_stop() {
2484
2484
  }
2485
2485
  do_interrupt("stop: " + (note() || "parent stop command"));
2486
2486
  const lanes = Array.from(lane_runs().values());
2487
- for (const lane of lanes) run(E.PC_HQ, ["lanes", "stop", lane], { timeout: 30000 });
2487
+ for (const lane of lanes) run(E.PC_HQ, ["runners", "stop", lane], { timeout: 30000 });
2488
2488
  let listed = null;
2489
2489
  try {
2490
- const parsed = JSON.parse(run(E.PC_HQ, ["lanes", "list", "--json"], { timeout: 30000 }).stdout || "{}");
2490
+ const parsed = JSON.parse(run(E.PC_HQ, ["runners", "list", "--json"], { timeout: 30000 }).stdout || "{}");
2491
2491
  listed = Array.isArray(parsed) ? parsed : get(parsed, "lanes", null);
2492
2492
  } catch (e) { listed = null; }
2493
2493
  const stopped = Array.isArray(listed) && lanes.every(id => {
@@ -135,7 +135,7 @@
135
135
  # Stall check: --stall-window (default 600 seconds, env PIPELINE_DRIVER_STALL_SECS).
136
136
  # The stall starts at the later of the oldest in-flight phase's route time and
137
137
  # the last lane status change, and is kept in driver/stall.json so a restart
138
- # does not reset it. The lane state comes from `hq lanes list --json`
138
+ # does not reset it. The lane state comes from `hq runners list --json`
139
139
  # (loop state and queue depth). The event fires once per stall;
140
140
  # accepting any phase clears it. No notification hook exists for the driver,
141
141
  # so firing writes the event and exits 28 for the parent's waiter.
@@ -260,14 +260,14 @@ stop_lanes() {
260
260
  lane_file="$STATE/lanes.json"
261
261
  while IFS= read -r lane; do
262
262
  [ -n "$lane" ] || continue
263
- "$PC_HQ" lanes stop "$lane" >/dev/null 2>&1 || true
263
+ "$PC_HQ" runners stop "$lane" >/dev/null 2>&1 || true
264
264
  done <<EOF
265
265
  $(jq -r 'to_entries[] | .value' "$STATE/lanes.json" 2>/dev/null)
266
266
  EOF
267
267
  deadline=$(( $(date +%s) + 60 ))
268
268
  while [ "$(date +%s)" -lt "$deadline" ]; do
269
269
  local rows
270
- rows="$("$PC_HQ" lanes list --json 2>/dev/null)"
270
+ rows="$("$PC_HQ" runners list --json 2>/dev/null)"
271
271
  if printf '%s' "$rows" | jq -e --slurpfile owned "$lane_file" '
272
272
  (if type == "array" then . else .lanes end) as $rows |
273
273
  ($rows | type == "array") and
@@ -363,7 +363,7 @@ function laneRows() {
363
363
  lanes = new Map();
364
364
  try {
365
365
  const owned = load(path.join(S, 'lanes.json')) || {};
366
- const r = cp.spawnSync(HQ, ['lanes', 'list', '--json'], { encoding: 'utf8', timeout: 30000 });
366
+ const r = cp.spawnSync(HQ, ['runners', 'list', '--json'], { encoding: 'utf8', timeout: 30000 });
367
367
  if (!r.error) {
368
368
  const text = String(r.stdout || ''), starts = [text.indexOf('['), text.indexOf('{')].filter((n) => n >= 0);
369
369
  const parsed = JSON.parse(starts.length ? text.slice(Math.min(...starts)) : text);
@@ -575,7 +575,7 @@ function dumps(v) {
575
575
  let rows = [];
576
576
  try {
577
577
  const owned = load(path.join(S, 'lanes.json')) || {};
578
- const r = require('child_process').spawnSync(HQ, ['lanes', 'list', '--json'], { encoding: 'utf8', timeout: 30000 });
578
+ const r = require('child_process').spawnSync(HQ, ['runners', 'list', '--json'], { encoding: 'utf8', timeout: 30000 });
579
579
  const text = String(r.stdout || ''), starts = [text.indexOf('['), text.indexOf('{')].filter((n) => n >= 0);
580
580
  const parsed = JSON.parse(starts.length ? text.slice(Math.min(...starts)) : text);
581
581
  const listed = Array.isArray(parsed) ? parsed : (isObj(parsed) && Array.isArray(parsed.lanes) ? parsed.lanes : []);
@@ -723,9 +723,9 @@ act() {
723
723
  LANE_STALLED)
724
724
  company="$(jq -r '.company_slug // empty' "$STATE/run.json" 2>/dev/null)"
725
725
  lane="$(jq -r --arg w "$d" '.[$w] // empty' "$STATE/lanes.json" 2>/dev/null)"
726
- questions="$("$PC_HQ" lanes questions list --company "$company" --json 2>/dev/null | jq -c --arg lane "$lane" '.questions[]? | select(.lane_id == $lane and .status == "pending")' 2>/dev/null | head -1)"
726
+ questions="$("$PC_HQ" runners questions list --company "$company" --json 2>/dev/null | jq -c --arg lane "$lane" '.questions[]? | select(.lane_id == $lane and .status == "pending")' 2>/dev/null | head -1)"
727
727
  log "LANE_QUESTION story=$b phase=$c lane=$lane question=${questions:-missing}"
728
- finish 28 "loop lane $lane parked after repeated stalls for $b/$c; answer its pending question with hq lanes questions answer, then restart the driver: ${questions:-no pending question returned}" ;;
728
+ finish 28 "loop lane $lane parked after repeated stalls for $b/$c; answer its pending question with hq runners questions answer, then restart the driver: ${questions:-no pending question returned}" ;;
729
729
  INFLIGHT) ;;
730
730
  ACTIVE) ACTIVE="$b" ;;
731
731
  '') ;;
@@ -252,6 +252,14 @@ function processIsAlive(pid) {
252
252
  catch (error) { return error?.code !== "ESRCH"; }
253
253
  }
254
254
 
255
+ // Windows keeps a just-released lock directory or pid file in a delete-pending
256
+ // state while another waiter still holds a handle on it. Creating the same
257
+ // name in that window fails with EPERM, EACCES or EBUSY instead of EEXIST, so
258
+ // it is lock contention and the waiter keeps polling until its deadline.
259
+ function isTransientWindowsLockError(error) {
260
+ return process.platform === "win32" && ["EPERM", "EACCES", "EBUSY"].includes(error?.code);
261
+ }
262
+
255
263
  function acquireProjectWriteLock(prdPath) {
256
264
  const lock = `${prdPath}.write-lock`;
257
265
  const ownerFile = path.join(lock, "pid");
@@ -260,13 +268,19 @@ function acquireProjectWriteLock(prdPath) {
260
268
  try {
261
269
  fs.mkdirSync(lock);
262
270
  try { fs.writeFileSync(ownerFile, `${process.pid}\n`, { flag: "wx" }); }
263
- catch {
264
- fs.rmSync(lock, { recursive: true, force: true });
265
- return undefined;
271
+ catch (error) {
272
+ fs.rmSync(lock, { recursive: true, force: true, maxRetries: 10, retryDelay: 10 });
273
+ if (!isTransientWindowsLockError(error)) return undefined;
274
+ sleepSync(20);
275
+ continue;
266
276
  }
267
277
  process.once("exit", () => releaseProjectWriteLock(lock));
268
278
  return lock;
269
279
  } catch (error) {
280
+ if (isTransientWindowsLockError(error)) {
281
+ sleepSync(20);
282
+ continue;
283
+ }
270
284
  if (error?.code !== "EEXIST") return undefined;
271
285
  let owner = 0;
272
286
  try { owner = Number.parseInt(fs.readFileSync(ownerFile, "utf8"), 10) || 0; } catch { /* new owner has not written its pid yet */ }
@@ -291,7 +305,8 @@ function acquireProjectWriteLock(prdPath) {
291
305
  function releaseProjectWriteLock(lock) {
292
306
  try {
293
307
  const owner = Number.parseInt(fs.readFileSync(path.join(lock, "pid"), "utf8"), 10);
294
- if (owner === process.pid) fs.rmSync(lock, { recursive: true, force: true });
308
+ // Retry so a waiter's open handle on the pid file cannot leave an ownerless lock directory behind.
309
+ if (owner === process.pid) fs.rmSync(lock, { recursive: true, force: true, maxRetries: 10, retryDelay: 10 });
295
310
  } catch { /* lock cleanup is best-effort; stale owners are reclaimed */ }
296
311
  }
297
312