Skip to content

chore(tests): drop tests/__init__.py so build_tests cannot depend on import order - #72

Draft
openvoiceos-bot wants to merge 1 commit into
devfrom
fix/t6298-tests-init-defeats-build-tests
Draft

openvoiceos-bot wants to merge 1 commit into
devfrom
fix/t6298-tests-init-defeats-build-tests

Conversation

@openvoiceos-bot

@openvoiceos-bot openvoiceos-bot commented Sep 28, 2026 •

Copy link
Copy Markdown

What this changes

One deleted file: tests/__init__.py.

Correction to the first version of this description

The first version of this description said the flat-layout package at the
repository root SHADOWED the installed wheel in this repository, and that the
suite tested the working tree. THAT IS WRONG FOR THIS REPOSITORY, and it was
measured wrong by the author, not by a reviewer's guess. Reviewer-c measured the
base and found the suite green; this lane then re-ran the same instrument and got
the same result. The correction is to the description. The code change is
unchanged and still worth merging, for the smaller reason below.

Why, corrected

The tests directory was a package. Under pytest's default prepend import mode
that puts the repository root back on sys.path. On this repository the root IS
put back, and nothing resolves through it:
tests/e2e/test_hivescope_client_db_e2e.py sorts first, imports the package from
site-packages before any other module asks for it, and sys.modules then wins
every later lookup.

So the deletion does not remove a shadow here. It converts an ORDERING guarantee
into a STRUCTURAL one: today the suite imports the wheel because of collection
order, and after this change the root is never on sys.path at all.

That is worth having, and not only as tidiness. The ordering guarantee fails in
the exact case build_tests exists to catch. When the WHEEL is broken, the
pre-empting import is the one that raises, the package never lands in
sys.modules, and every module collected after it falls back to sys.path. With
the root present, one file reports the broken wheel and the rest can silently
read the working tree; with the root gone, every file reports it. Measured on
this repository: under a poisoned wheel the base reports 1 collection error and
the head reports 2.

How it was measured, corrected

The author's original probe was one cell asserting "site-packages" in pkg.__file__. It reports where ONE cell's first import landed and cannot carry
this claim. The instrument that decides is the prescribed control, run in both
directions in a venv holding the wheel this repository builds, installed
non-editable, on Python 3.11:

  • SOURCE-POISON, a raise in the repository-root copy, suite required to stay
    GREEN. Base 50e952b with tests/__init__.py present: 68 passed, 3 skipped,
    zero marker hits
    . The source tree is never imported. The head: the same.
  • WHEEL-POISON, a raise in the installed copy, suite required to go RED. The
    base ALREADY reds, which is the same finding from the other side.

Node ids are identical across the change, 69 each, and the baseline counts are
identical, so the deletion costs nothing.

The shape this description originally claimed IS present in sibling repositories,
and there source-poison reds the base. This repository is the one member of the
batch where it does not, and the sweep's row for it has been corrected in the same
words as this description:
knowledge/wiki/audits/gate-ledger/t6298-org-sweep-tests-init-measured.md.

The option not taken

pytest_args: --import-mode=importlib also works, and was rejected. It is per
workflow: every caller must carry it, and this repository has more than one
workflow that runs pytest. Deleting the file fixes them all at once and the next
caller cannot forget it.

This repository has NO tests/e2e/__init__.py. The first version of this
description said it had one and that the file was left in place; that sentence
was wrong and is removed.


This pull request was prepared by an AI agent (Claude Opus 5) under human
supervision. The measurement above was executed, not reasoned.

🤖 Generated with Claude Code

The tests directory was a package, so pytest's default prepend import mode put
the repository root back on sys.path and the flat-layout package at the root
shadowed the wheel the build_tests job had just built and installed. The suite
tested the working tree, and a packaging defect passed: a module left out of the
wheel, a missing dependency or missing package data.

Measured: a probe cell collected out of tests/ resolved the package to the
working tree with this file in place, and to site-packages with it gone. The unit
suite keeps the same counts.

tests/e2e/__init__.py, where it exists, stays. With this parent gone the basedir
for an e2e file is tests/, so the repository root still stays off sys.path.

Evidence: knowledge/wiki/audits/gate-ledger/t6298-org-sweep-tests-init-measured.md

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the fix label Sep 28, 2026
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

I've finished my rounds! Here's the state of the PR. 🏥

I've aggregated the results of the automated checks for this PR below.

📋 Repo Health

Is the codebase feeling fit today? Let's check. 🏃‍♂️

✅ All required files present.

Latest Version: 0.4.3a9

✅ hivemind_sqlite_database/version.py — Version file
✅ README.md — README
✅ LICENSE.md — License file (consider renaming to LICENSE)
✅ pyproject.toml — pyproject.toml
⚠️ setup.py — setup.py
✅ CHANGELOG.md — Changelog
✅ hivemind_sqlite_database/version.py has valid version block markers

🏷️ Release Preview

The release train is fueling up! 🚂

Current: 0.4.3a9 → Next: 0.4.3a10

Signal Value
Label (none)
PR title fix(tests): drop tests/__init__.py so build_tests imports the wheel
Bump alpha

⚠️ No conventional commit prefix — alpha-only bump.
Suggested: fix: update the thing or feat: update the thing


🚀 Release Channel Compatibility

Predicted next version: 0.4.3a10

Channel Status Note Current Constraint
Stable ⚪ Not in channel -
Testing ⚪ Not in channel -
Alpha ✅ Compatible hivemind-sqlite-database>=0.4.3a9

📊 Coverage

Checking the weather: is it raining tests? ☔

✅ 85.6% total coverage

Per-file coverage (2 files)
File Coverage Missing lines
hivemind_sqlite_database/version.py 0.0% 5
hivemind_sqlite_database/__init__.py 87.8% 24

Full report: download the coverage-report artifact.

⚖️ License Check

Ensuring our project is well-protected legally. 🛡️

✅ No license violations found.

Policy: Apache 2.0 (universal donor). StrongCopyleft / NetworkCopyleft / WeakCopyleft / Other / Error categories fail. MPL allowed.

🔍 Lint

The results are fresh out of the pipeline. 🏗️

❌ ruff: issues found in 6 file(s) — see job log
✅ actionlint: 12 workflow file(s), no finding

🔨 Build Tests

A thorough inspection of the build process. 🔍

✅ All versions pass

Python Build Install Tests pytest
3.10 ✅ ✅ ✅ 68 passed, 3 skipped, 18 warnings in 5.10s
3.11 ✅ ✅ ✅ 68 passed, 3 skipped, 18 warnings in 3.81s
3.12 ✅ ✅ ✅ 68 passed, 3 skipped, 18 warnings in 4.91s
3.13 ✅ ✅ ✅ 68 passed, 3 skipped, 18 warnings in 6.06s
3.14 ✅ ✅ ✅ 68 passed, 3 skipped, 18 warnings in 4.69s

May the tests be ever in your favor! 🏹

@openvoiceos-bot openvoiceos-bot changed the title fix(tests): drop tests/__init__.py so build_tests imports the wheel chore(tests): drop tests/__init__.py so build_tests cannot depend on import order Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants