Skip to content

fix(scripts): re-apply audit-gap hardening onto sanitized main - #1

Open
opencdlee-dotcom wants to merge 4 commits into
mainfrom
fix/audit-gaps-sanitized
Open

fix(scripts): re-apply audit-gap hardening onto sanitized main#1
opencdlee-dotcom wants to merge 4 commits into
mainfrom
fix/audit-gaps-sanitized

Conversation

@opencdlee-dotcom

@opencdlee-dotcom opencdlee-dotcom commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Re-applies hardening that existed only in the local checkout (pre-history-scrub) onto
the current sanitized main, then repairs the CI pipeline it revealed.

1. fix(scripts) — audit-gap hardening

  • gh_handoff.py — per-subprocess timeout=120s on every gh/git call so a flaky
    uplink can't hang the build; merges stderr+stdout for gh auth status /
    gh repo create / gh repo view so the friendly translator sees the whole message
    regardless of which stream the CLI version uses; TimeoutExpired handled at main().
  • intake_handler.py — upfront 100 KB truncation guard against pathological payloads.
  • narration.py, registry_verify.py — matching timeout + error-path fixes.

Cherry-picked rather than pushed: main was history-scrubbed remotely (personal email
→ noreply, /Users/charlie/Users/user), and the local branch still carried the
pre-scrub history, so pushing it would have re-introduced the scrubbed identifiers into
public history. Re-authored under the noreply address; tree scanned clean.

2. fix(ci) — the test job had never run a single test

Two independent breaks, both pre-existing since 2026-05-06:

  • uv.lock was never committed, so uv sync --frozen died with "Unable to find
    lockfile"
    before any test.
  • With that fixed, uv run pytest died with "Failed to spawn: pytest" — pytest lives
    in [project.optional-dependencies].dev, which plain uv sync doesn't install. Added
    --extra dev.

3. fix(tests) — the first real run exposed a non-hermetic test

_detect_version_managers probes the real home ((Path.home() / ".nvm").exists()), but
nine tests called plan()/detect() without isolating HOME. GitHub's Linux runners
ship nvm at ~/.nvm, so node installs were suppressed as "blocked by VM" and
test_macos_uses_brew asserted on an empty list — while passing on a dev Mac without
~/.nvm. Fixed by adding the repo's existing tmp_install_log fixture (which already
does HOME isolation) to those nine tests. No assertion changed, no test skipped or
weakened, no new abstraction.

Verification

uv sync --frozen --extra dev + uv run pytest224 passed, 2 skipped, 4 deselected,
reproduced locally under three homes: normal, ~/.nvm present (reproduces the CI
failure), and ~/.nvm + ~/.pyenv + ~/.asdf. CI on this branch: both jobs green.

🤖 Generated with Claude Code

opencdlee-dotcom and others added 4 commits August 11, 2026 20:36
…ntake + narration

- gh_handoff: per-call 120s subprocess timeout + top-level TimeoutExpired routed through _friendly; merge auth/repo-create/repo-view stdout into stderr before friendly translation so token redaction covers either stream.
- registry_verify: warn on non-404 HTTP errors (401/403/5xx) instead of silently returning "exists"; still fail-open so transient registry issues do not block installs.
- intake_handler: 100KB upfront cap in _extract_subtools to bound regex/slice work on pathological inputs.
- narration: capture_subprocess timeout path bounds proc.wait(5s), explicitly closes stdout/stderr pipes to unblock _drain_stream readline(), and joins with 10s timeout so a stuck reader can never hang the build.

All 224 tests pass, 2 skipped.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The `test` job has failed on main since 2026-05-06: CI runs `uv sync --frozen`,
which requires a committed lockfile, but uv.lock was never tracked. Every run
died at "Unable to find lockfile at `uv.lock`, but `--frozen` was provided"
before a single test executed.

Generated with `uv lock` (uv 0.11.6, CPython 3.13) and verified against the exact
CI sequence: `uv sync --frozen` then `uv run pytest` -> 224 passed, 2 skipped,
4 deselected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`uv sync --frozen` installs only the main dependency set; pytest and ruff live in
`[project.optional-dependencies].dev`, so the runner reached `uv run pytest` with no
pytest on PATH and died with "Failed to spawn: `pytest`". Combined with the missing
lockfile, the test job has never executed a single test.

Adds `--extra dev` to the sync step. Verified against a clean environment
(UV_PROJECT_ENVIRONMENT set to an empty path, pytest 9.1.1 installed fresh):
`uv sync --frozen --extra dev` then `uv run --frozen pytest`
-> 224 passed, 2 skipped, 4 deselected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ion is hermetic

`_detect_version_managers` probes the real home directory
(`(Path.home() / ".nvm").exists()`, same for .pyenv/.asdf/...), but nine tests in
test_preflight.py called `plan()`/`detect()` without isolating HOME. On any machine
that has a version manager installed the node/python install actions are suppressed
as "blocked by VM", so `test_macos_uses_brew` asserted on an empty action list.

This never surfaced because CI could not run tests at all until the previous two
commits; GitHub's Linux runners ship nvm at ~/.nvm, so the very first real run
failed there while passing on a dev Mac without ~/.nvm.

Fix adds the existing `tmp_install_log` fixture — which already does the HOME
isolation via monkeypatch.setenv + Path.home — to the nine tests that lacked it.
The fixture was already used this way by the tests that passed; no new abstraction,
no assertion changed, no test skipped.

Verified `uv run pytest` -> 224 passed, 2 skipped, 4 deselected under three homes:
a normal home, a home with ~/.nvm (reproduces the CI failure), and a home with
~/.nvm + ~/.pyenv + ~/.asdf.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant