Skip to content

Test infra: whole-suite pytest collects again and runs on every PR (#292) - #304

Merged
brettheap merged 4 commits into
mainfrom
change/fix-pytest-collection-and-pr-ci
Aug 25, 2026
Merged

brettheap merged 4 commits into
mainfrom
change/fix-pytest-collection-and-pr-ci

Conversation

@brettheap

Copy link
Copy Markdown
Contributor

Fixes #292 — both halves.

1. Collection fix (3f3c75b)

python3 -m pytest tests/ died 6,228 tests in on a duplicate basename: test_header_value_readers.py in both tests/doc-health/ and tests/ideation-dashboard/. Both directories are hyphenated (unpackageable), pytest.ini is the ratified option-free rootdir anchor (no --import-mode), and a per-directory conftest is the forbidden repair — so the doc-health copy is renamed test_doc_health_header_value_readers.py. Nothing live references the old name (only two archived openspec tasks docs, left as records). --collect-only: 6,232 collected, 0 errors.

Bounded honestly: the basename sweep cannot see the conftest flat-slot contention, so multi-directory invocations remain order-dependent (measured, documented in the workflow header). Repairing that needs --import-mode=importlib, which pytest.ini's design forecloses — a separate specced decision.

2. pytest-suite workflow (395f9fd)

Until now no pull_request trigger ran pytest at all. New .github/workflows/pytest-suite.yml: PR→main and push→main, full suite -m "not postgres", installed from the hash-locked requirements/hermes-runtime-contracts.lock (--require-hashes), checkout nested under openxFactory/ (measured: flat checkout false-fails test_find_validator_locates_pinned_checkout), node 22 pinned (41 files skip silently without it), no paths filter (repo-scanning tests read contracts//ideation//docs/; a filter on a required check deadlocks), 35-min timeout vs worst measured 17m21s.

CI-shaped measurement (fresh clone in a dir named openxFactory, no aggregation workspace above, lock-only venv, rebased on current main):

5877 passed, 17 skipped, 338 deselected, 0 failed — 937s (15m37s), exit 0

5877+17+338 = 6232 = collected count.

README gains a ## Python test suite gate section with the ruleset click-path; the check is advisory until you mark pytest-suite required.

Review

Adversarially reviewed pre-push (13 findings: 2 blockers on measurement layout / stale base, 1 on dep source, header factual errors, missing README section — all fixed; rename and workflow mechanics verified correct). The one thing not locally provable is real runner behavior — this PR's own pytest-suite run is that proof; please check it is green before merging.

🤖 Generated with Claude Code

brettheap and others added 2 commits August 24, 2026 17:00
…lifying (#292)

`python3 -m pytest tests/` could not collect at all. It died 6,228 tests in,
and per-directory invocation was the only thing that worked:

    ==================================== ERRORS ====================================
    ____ ERROR collecting tests/ideation-dashboard/test_header_value_readers.py ____
    import file mismatch:
    imported module 'test_header_value_readers' has this __file__ attribute:
      /.../tests/doc-health/test_header_value_readers.py
    which is not the same as the test file we want to collect:
      /.../tests/ideation-dashboard/test_header_value_readers.py
    HINT: remove __pycache__ / .pyc files and/or use a unique basename for your
    test file modules
    =========================== short test summary info ============================
    ERROR tests/ideation-dashboard/test_header_value_readers.py
    !!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
    6228 tests collected, 1 error in 23.78s

The module namespace these two files share is FLAT, and it has to stay flat.
`tests/doc-health/` and `tests/ideation-dashboard/` are hyphenated, so neither
can be a Python package; `pytest.ini` is the deliberately option-free rootdir
anchor for the FR-043 hermeticity guard (PR #49 review finding 17) and may not
grow an `--import-mode`; and a per-directory `conftest.py` is the one repair
that is explicitly forbidden, because `conftest` is an ambient top-level module
name and hijacking it broke `from conftest import FakeGit` for the doc-health
modules once already. So a test file's basename IS its global module name here,
and the fix is to make one of the two carry its suite.

Renamed the doc-health copy. Both files were born in the same commit (42cc321),
so neither has seniority, and nothing live references either path — the only
mentions anywhere are two archived openspec tasks documents, left untouched as
the historical records they are. The tiebreak is convention plus churn risk:
`tests/ideation-dashboard/` already prefixes basenames with the subsystem under
test (`test_doxbench_*`, `test_gate_*`), so its copy reads as conforming, while
`tests/doc-health/` names files after the `doc_health` module they cover
(`test_inventory.py`, `test_organizer_dispatch.py`) and this concern-named file
was already the outlier there. `tests/ideation-dashboard/` is also the far
larger and more actively worked suite, so renaming inside it courts more
collision with in-flight branches.

Swept the rest of the BASENAME class, since collection stops at the first
duplicate and more can hide behind it. `find tests -name 'test_*.py' -printf
'%f\n' | sort | uniq -d` now reports only `test_topology_lifecycle.py`, and
that pair is a false positive of the heuristic: both copies sit inside real
packages (`tests/hermes_runtime_contracts/__init__.py` and its
`postgres/__init__.py`), so their module names already differ. Collection
proves it — there is no second error behind the first.

That sweep is bounded by its own glob, and the bound is worth stating plainly:
it matches only `test_*.py`, so it structurally CANNOT see the other
flat-namespace contention in this repository. `tests/doc-health/`,
`tests/avatar_runtime/`, and `tests/ideation-dashboard/` each carry a
conftest.py with no `__init__.py`, and `conftest` is a single top-level module
slot. The whole-suite run below is unaffected, but multi-directory invocations
are ORDER-DEPENDENT: measured, `pytest tests/doc-health tests/avatar_runtime`
fails with 23 collection errors, while `pytest tests/avatar_runtime
tests/doc-health` collects 841 clean. This commit does not repair that and does
not claim to — the whole-suite green below says nothing about it. The real
repair is `--import-mode=importlib`, which pytest.ini's ratified option-free
design forecloses; changing that is a separate, specced decision.

GREEN: `python3 -m pytest tests/ --collect-only -q` completes clean at 6,232
tests collected, 0 errors.

Co-Authored-By: Claude Fable 5 <[email protected]>
No trigger in this repository ran pytest at all. `wallet-validation.yml` runs
two wallet scripts, `doc-health-reusable.yml` is workflow_call-only, and
`session-open-pr.yml` is workflow_dispatch. Roughly 6,200 tests — the whole
ideation-dashboard suite and every behavioral pin in it — were enforced by
nothing but local discipline. `pytest-suite` is the gate, and it runs the whole
suite rather than a collect-only guard plus a subset, because the whole suite
measurably fits in a PR budget.

MEASURED by simulating this job exactly: a fresh clone into a directory named
`openxFactory` with NO aggregation workspace above it, a clean venv holding only
the hash-pinned lock, node 22 on PATH, Python 3.12 —

  5877 passed, 17 skipped, 338 deselected, 15 subtests passed, 0 failed
  937s (15m37s), exit 0

5,877 + 17 + 338 = 6,232, exactly what `--collect-only` reports, so the run
covers everything collection sees. The 17 skips are self-skipping guards ("no
sibling openxFactory checkout") that stand down when no aggregation workspace
surrounds the repo — true on a runner, and true in this simulation. That
isolation mattered: locally those same doc-health readiness tests resolve the
AGGREGATION submodule instead and run, so a developer's worktree and CI
legitimately differ by two skips.

Dependencies come from `requirements/hermes-runtime-contracts.lock` installed
with `--require-hashes`, not an ad-hoc pip list. That lock is the ratified
validator-input source — `specs/005-customer-subject-runtime/quickstart.md`
provisions the bench from it and `release.py` carries the `.in`/`.lock` pair as
AUXILIARY_MEMBERS — so the gate runs against the same hash-pinned inputs the
contract work was ratified against rather than whatever the index serves that
day. The `.in` pins all five directly (pyyaml, jsonschema, referencing,
rfc3339-validator, pytest) and records why `rfc3339-validator` is not optional:
jsonschema registers its date-time format checker only when that package is
importable, and the canonical validators fail closed without it. Nothing beyond
the lock is needed — the suite is structurally hermetic (tests/hermeticity.py
makes the real `nlm` and `gh` unreachable, FR-043) and every test needing git
builds its own repository with its own identity under tmp_path.

Four choices are measurements, not defaults, and the header records why:

  `-m "not postgres"` — the marked set drives real Docker against digest-pinned
  images and has no docker-detection auto-skip by design: without the images
  those tests FAIL at the session fixture. They belong to their own release-gate
  runner, scripts/run-hermes-runtime-postgres-tests.sh. The repository documents
  the paired deselection scoped to the contracts subtree
  (`pytest tests/hermes_runtime_contracts -m 'not postgres'`); this gate applies
  the same deselection at whole-suite scope for the same reason. Those are the
  338 deselected. The harness's own unmarked test_runner_contract.py still runs
  here, and passes.

  `path: openxFactory` — `find_validator` walks up looking for
  `openxFactory/scripts/validate-ideation-dashboard-contracts.py`, and
  test_snapshot.py::test_find_validator_locates_pinned_checkout asserts it
  resolves. Proven both ways: a flat checkout fails that assert with
  `assert None is not None`; the same tree inside a directory named
  `openxFactory` passes 17/17. The default runner workspace would satisfy this
  only by the coincidence of the repository's name, which a rename or a fork
  would quietly break.

  `actions/setup-node@v4` — 41 test files gate DOM and JS probes on
  `shutil.which("node")` and SKIP when it is absent rather than failing. The
  measured run had node 22, so those probes are inside the numbers above.
  Leaving node to the runner image means a future image could silently drop
  dozens of files' worth of assertions and still report this gate green, which
  is the exact failure this issue exists to end.

  No paths filter — an earlier draft filtered to tests/**, scripts/**, and
  pytest.ini. That was wrong twice. A large group of tests scans real repository
  content rather than fixtures (the trust-anchor validator gate, release
  inventory, workbench guard, derive-possibles, and the ideation readiness and
  dispatch suites read contracts/, ideation/, docs/, openspec/), so a
  content-only change is exactly the kind that can turn this red while matching
  no filtered path. And a filter on a check later marked REQUIRED deadlocks
  every PR it skips — the check never reports and GitHub waits forever. Running
  unconditionally removes both hazards; `push: main` catches content-only merges
  for the same first reason; and concurrency cancels superseded runs per ref so
  a rapid push sequence does not queue duplicate quarter-hour suites.

SCOPE. This pins the `pytest tests/` whole-suite shape only. `conftest` is a
single flat module slot and three test directories carry one without an
`__init__.py`, so multi-directory invocations are order-dependent — measured,
`pytest tests/doc-health tests/avatar_runtime` fails with 23 collection errors
while the reverse order collects 841 clean. A green `pytest-suite` says nothing
about that. The real repair is `--import-mode=importlib`, foreclosed by
pytest.ini's ratified option-free design; changing it is a separate decision.

Timeout is 35 minutes against the worst measurement of 15m37s (an earlier,
contended run took 17m21s) — roughly 2x headroom for a slower runner and a hard
stop for the known hang in test_doxbench_bridge.py, which drives a real child
process over real pipes and can stall under CPU contention.

README documents the gate and the single ruleset click-path to mark it
required, alongside the existing wallet-validation entry.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI lite review requested due to automatic review settings August 24, 2026 21:17

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @brettheap! 👋

Your private repo does not have access to Sourcery.

Please upgrade to continue using Sourcery ✨

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request restores whole-suite pytest tests/ collection by removing a duplicate test module basename, and adds a new GitHub Actions workflow to run the full (non-postgres) Python test suite on every PR targeting main and every push to main, making the suite an enforceable CI signal.

Changes:

  • Add a renamed doc-health test module (test_doc_health_header_value_readers.py) to avoid collection collisions and to pin the real-line header scan behavior for inventory._header_value and organizer_dispatch._header_value.
  • Add .github/workflows/pytest-suite.yml to run python3 -m pytest tests/ -m "not postgres" on PRs/pushes to main, using the hash-locked requirements/hermes-runtime-contracts.lock.
  • Document the new pytest-suite gate in README.md, including how to mark it required via rulesets.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
tests/doc-health/test_doc_health_header_value_readers.py Renames/introduces the doc-health header-value reader tests to avoid duplicate basenames and adds targeted coverage for real-line header scanning.
README.md Documents the new pytest-suite CI gate and how to require it in branch rules.
.github/workflows/pytest-suite.yml Adds a PR/push workflow that runs the full Python test suite (excluding postgres-marked tests) with hash-locked dependencies.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

brettheap and others added 2 commits August 24, 2026 17:36
The first real CI run of `pytest-suite` (PR #304, run 32778659788) failed 23
tests in two classes. Neither is a defect in the workflow — both are places
where the suite quietly depended on something a developer machine has and a
fresh runner does not. Both repairs belong in the tests.

TWENTY-ONE — `git commit failed (rolled back): Author identity unknown`, all in
tests/ideation-dashboard/test_intent_apply_lane.py.

The fixtures build a corpus with `git init` and then commit into it, and they
were careful to pass `-c user.name/-c user.email` on their own git calls. But
the code UNDER test commits too: the apply lane runs its own `git commit`, with
no `-c` flags, so it fell back to an ambient identity. On a developer's machine
`~/.gitconfig` supplies one and the tests pass; on a runner there is none and
the lane rolls back, exactly as it is designed to when a commit fails.

The fix is repo-LOCAL identity set right after `git init`, in both repositories
the file builds — the corpus in `_corpus` and the second clone in the
push-race test. That makes the fixture hermetic with respect to the host's
global git config rather than merely well-behaved on one host.

Deliberately NOT fixed by exporting GIT_AUTHOR_*/GIT_COMMITTER_* in the
workflow. That would have turned CI green while leaving the suite dependent on
ambient configuration, which is the same class of hidden coupling that let this
reach CI in the first place.

RED locally, reproducing the runner by denying the ambient config:

    GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 \
      python3 -m pytest tests/ideation-dashboard/test_intent_apply_lane.py -q
    21 failed, 19 passed

GREEN after the fix, same command: 40 passed.

Swept the rest of the suite for the same latent dependence. Sixteen files build
git repositories; eleven already set repo-local identity, and the five that did
not — test_release_inventory, test_nightly_lane, test_proposal_origin,
test_session_git, test_session_harness — were each run under the same stripped
environment and are clean (38, 21, 29, 66 and 20 passed). This file was the only
one where the RUNTIME, rather than the fixture, was the committer.

TWO — `FileNotFoundError: 'openspec'` in
tests/proposal-support/test_proposal_support.py.

That suite drives the real `openspec` binary; it is a genuine external
dependency, not a mock. Its tests already carried
`@unittest.skipUnless(shutil.which("openspec"), "openspec CLI required")` — but
two of them, added later, did not, so they raised instead of skipping. Both now
carry the same guard as their siblings.

The guard is only half the repair. A guard alone would leave the gate green
while silently testing nothing, so the workflow now installs the CLI as well
(`npm install -g @fission-ai/[email protected]`, pinned to the version this
repository is developed against) and those tests actually run in CI. Measured
both ways: RED with a PATH that excludes the CLI (2 failed, 33 passed); with the
guards and no CLI, 33 passed / 3 skipped; with the CLI present, 36 passed / 0
skipped — the guards skip, they do not mask.

The workflow header is corrected accordingly. It claimed "every test that needs
git builds its own repository with its own identity," which these 21 tests
disproved; it now records what is actually true, why the fix is in the fixture
rather than in the job environment, and why openspec is a CI dependency.

Co-Authored-By: Claude Fable 5 <[email protected]>
The re-simulation after the two fixture repairs, run the way the runner runs —
fresh clone into a directory named openxFactory, hash-pinned lock only, node 22
and the pinned openspec CLI on PATH, and GIT_CONFIG_GLOBAL=/dev/null
GIT_CONFIG_NOSYSTEM=1 so there is no ambient git identity to borrow:

  5877 passed, 17 skipped, 338 deselected, 15 subtests passed, 0 failed
  925s (15m25s), exit 0

Identical to the count before the repairs, which is what makes them repairs
rather than suppressions: nothing was skipped away or lost, the suite simply no
longer depends on the developer's environment to reach it.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings August 24, 2026 21:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Comment on lines +216 to +220
- run: npm install -g @fission-ai/[email protected]

- run: pip install --require-hashes -r requirements/hermes-runtime-contracts.lock

- run: python3 -m pytest tests/ -q -m "not postgres"
@brettheap

Copy link
Copy Markdown
Contributor Author

First CI run record (for the ledger): run 32778659788 failed — 23 failed / 5853 passed in 11m54s. Not workflow defects; two test-hermeticity defects a dev machine hides:

  • 21× tests/ideation-dashboard/test_intent_apply_lane.py — the apply-lane runtime commits with ambient git identity (the fixtures only passed -c user.* on their own calls). Fixed in the fixture with repo-local identity (9c355515); reproducible locally with GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1. Deliberately NOT masked with GIT_AUTHOR_* env in the job. Sweep of the other 15 repo-building test files under the stripped env: clean.
  • 2× tests/proposal-support/test_proposal_support.py — shell the openspec CLI without the skipUnless guard their siblings carry. Guards added, and @fission-ai/[email protected] is installed in the job so the gate runs them (36 passed, 0 skipped) rather than skipping.

Second run 32781781318: 5877 passed, 17 skipped, 338 deselected, 0 failed, 11m47s — identical counts to the local CI-shaped simulation. Ready for merge; pytest-suite stays advisory until marked required (README click-path).

@brettheap
brettheap merged commit 74af6cc into main Aug 25, 2026
3 checks passed
@brettheap
brettheap deleted the change/fix-pytest-collection-and-pr-ci branch September 2, 2026 18:55
brettheap added a commit that referenced this pull request Sep 9, 2026
…1/5.2 ticked on the D-2 evidence) (#832)

Path A PR-5, the last of the 2026-09-06 plan memo's sequence, on Brett Heap's word "merge pr-5 when green" (2026-09-09). Authority: his ruling of 2026-09-05T23:38Z "rule path A, 4.5 is a deferred successor" (#656) and ruling D-2 (the live exercise).

- tasks.md: § 4.4 / § 5.1 / § 5.2 ticked on the D-2 evidence (three `- [ ]` heads removed, every ratified sentence kept byte-identical); § 4.5 untouched as a DEFERRED SUCCESSOR (#714 → 3d1b8cc).
- Archived WITH promotion via `scripts/proposal-support.py . archive --date 2026-09-09` under the pinned @fission-ai/[email protected] (never a bare `openspec archive`); origin retained (declaration unchanged since da1b0e9); six frozen files R100.
- Promoted: `openspec/specs/ideation-intent-plane/spec.md` NEW (7 requirements / 11 scenarios, every block byte-identical to the archived delta) and `openspec/specs/document-lifecycle/spec.md` 18 → 19 requirements ("Gates happen on main"); the new capability's `## Purpose` written by this act (no SHALL; replaces the CLI's TBD stub). openspec/specs 60 → 61; floor regeneration OWED (GRACED covered-pending 1, `created_by_candidate`), `contracts/review-lane-floor-snapshot.yaml` deliberately not edited here.
- README OpenSpec Records row → archived; sweep-ledger row re-seeded with the tool (`--seed-ledger --moved-by '#832'`, one line moved); no thirteenth archive-date disposition.
- Evidence (merged + green): #718 d179cc0, #727 07624d5, #735 6d3237e, xFactory #304 b2db7e47, #313 ddd19650, #345 90435875, #781 450bb60, #808 2ef7d8c, #814 c991c0f, #816 8924230, xFactory #362 119280a8, #830 202c170, xFactory #369 c2313277; D-2 live exercise: act B refusal 36d07ec, act A apply e970dfe, first autonomous merge #176 → 7681e40 (codexfactory[bot] APPROVED 2026-09-09T06:37:22Z).
- Copilot round 1: one factual finding taken (a missing "where" in Purpose); two wording findings answered and resolved.

Refs #656 (stays OPEN). Rule 6 LANDING window observed.

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_012LiNG5Ume1boEfxSNeCmpu
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.

Test infra: no PR workflow runs pytest, and 'pytest tests/' collection is broken by duplicate module names

2 participants