Reintroduces the host-ops lock-status endpoint dropped from PR #13276
(NET-4074 / NET-6815) with all four Greptile findings addressed:
1. P1 — gate the route on requireBoard(req). Default-deny:
non-board actors receive 403 {error: 'board_only'} before any
disk I/O. The host-ops.ts module imports requireBoard from
server/src/middleware/auth.ts.
2. P2 — trim the response shape to {host, canonicalHost, status,
age_seconds, ttl_seconds}. Internal lock metadata (agent, issue,
intent, pid, started, heartbeat) is no longer exposed over the
network; the bash helper and JSON-on-disk lock files retain full
provenance for netquirk_acquire / netquirk_heartbeat callers.
3. P2 — parseNetquirkLockTtlSec now rejects empty, non-numeric,
fractional, negative, zero, and out-of-range values with
InvalidLockTtlError. The accepted range is 30 <= n <= 3600
seconds. Validated TTL is captured once at module load via
resolvedLockTtl() and surfaced through /healthz's
'host-ops.lock_ttl_sec' block (status: ok | invalid | default)
so an operator sees a broken env without reading server logs.
4. P2 — this PR's title names the lock-status endpoint explicitly;
the prior bundled commit was buried in a 'narrow null-environment
retry' PR scope.
Test coverage in server/src/__tests__/host-ops-route.test.ts:
- parseNetquirkLockTtlSec boundary (30, 3600), invalid inputs
(NaN, fractional, empty, undefined, negative, above max)
- resolvedLockTtlFromEnv default vs env source paths
- GET /api/host-ops/lock-status returns 403 board_only for
missing / non-board actors, 200 trimmed shape for board actors,
stale status when the admin-supplied TTL crosses the heartbeat,
absent when no lock is present, and 400 missing_host when the
host query param is absent.
- Alias canonicalisation (apps-arm1.* fold to apps-arm1).
/healthz surfaces 'host-ops.lock_ttl_sec' with ttl_seconds, source,
env_key, env_value, min, max, default, and status. The field is
included in both the redacted (no auth) and full responses; the
config carries no host / agent / intent metadata so it is safe to
expose without a board session.
No host mutation. No data export. No secrets. No auth bypass.
Co-Authored-By: Claude <noreply@anthropic.com>