Repository navigation
Unit-test conventions: the rule in WORKFLOW-LOCAL and the gate check that validates the diff - #335
Merged
Merged
Conversation
Preserve verified final artifact and website provenance, retain the owner production-promotion handoff, and resume maintenance planning from main. Co-authored-by: GPT-6 Codex <noreply@openai.com>
Co-authored-by: GPT-6 Codex <noreply@openai.com>
Co-authored-by: GPT-6 Codex <noreply@openai.com>
Add scripts/test_conventions.py: a unit-test file outside the legacy set lives in tests/unit mirroring its module or carries a heavier suite's marker; every test function in it has a docstring; a legacy file is compared with the merge base of the pull request's base and only loses test functions, with no marker added. The tests and build sessions and the tests.yml job run it, CI against the PR's base SHA. Register the legacy marker and mark all 110 existing test files with it: 1525 legacy tests, 0 breaches. The checker's own tests, 15 in triple form, are the first mirror file. mypy passes over 273 files. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
WORKFLOW-LOCAL gains Unit Tests: mirror placement, the Hoare triple with the precondition established by the test, a docstring stating the contract, a declared public surface, legacy files that only shrink with fix-and-move on touch, the gate's check, and the reviewer's duty in the Pair Review Loop. The humane companion carries the motivation from the 2026-11-03 gate run. The review brief template gains the reviewer's fourth item; the unit-tests guide points at the rule and corrects its fixture list. Maintenance records the diagnosis, the measurements and the queue that follows. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The legacy marker broke test_docker_marker_list_matches_declared_suites in tests/test_isolation.py, which held every registered marker but two to be a Docker marker. Under Unit Tests rule 5 the changed test leaves the legacy file: it is now tests/unit/tests/test_conftest.py, in triple form, with the three non-Docker markers named. 110 legacy files hold 1524 tests, 2 files follow the convention, 0 breaches. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ns.py Owner request on PR #335. The script, its mirror test and every reference in the rule, the gate, the CI step, the marker text and the records follow. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ccozianu
added a commit
that referenced
this pull request
Nov 4, 2026
…escription (#336) Owner order of 2026-11-04, maintenance workstream, following #335. ## What changes `scripts/publish_coverage_numbers_to_pr.py` runs in the pytest job on pull requests, after diff coverage. It reads `coverage.json` and `diff-cover.json`, renders one block bounded by two HTML comment markers with the changed-lines figure and the whole-package figure, and replaces that block in this description through the REST API, appending it when absent. Text outside the block is never touched. The pytest job gains `pull-requests: write` for that one step. `coverage.json` joins the coverage artifact. ## The merge commit half No code. Under Settings, Pull Requests, set the default merge commit message to "Pull request title and description". The block then lands in the merge commit's detail as the description stands at merge time, which is after the green run that wrote it. Until the setting is flipped, the numbers live in the pull request only. ## What the first run taught The first run on this PR spliced the block into the paragraph above, because that paragraph quoted the two markers literally and the upsert matched them mid-sentence. The markers are now matched only when each stands alone on its line, with a test for markers quoted in prose. The same run reported "100% of 0 changed lines", because this PR touches no line of the `devcapsule` package; that case now reads "none measured" instead of a percentage. ## Evidence - Eleven mirror tests in `tests/unit/scripts/test_publish_coverage_numbers_to_pr.py`, triple form: the figures, the block in both cases, the upsert in its four cases, the step with a recorded API, the refusals. - mypy clean; `validate_unittests_follow_conventions.py`: 110 legacy files, 1524 tests, 3 files follow the convention, 0 breaches. - The proof is this pull request: its run appends the block below this line. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- coverage-numbers:begin --> ### Test coverage, from [CI run](https://github.com/ccozianu/devcapsule/actions/runs/41746184938) | | | |---|---| | Changed lines covered | none measured: the change touches no line of `devcapsule` | | Overall `devcapsule` | **88.1%** (17,583 of 19,488 statements) | <!-- coverage-numbers:end -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Owner order of 2026-11-03, maintenance workstream.
ws-maintenance/test-conventionscarries the 0.3.1 preparation records ofws-maintenance/0.3.1-preparationmerged withmainat b3f10b7.Why
nox -s buildin the owner's capsule failed 18 tests, none a product regression. Thirteen read the owner's accepted vendor channel through the launcher's mounted settings; four asserted the repository's own lock down to the release candidate that built the base; one scannedtests/and hit a sample project's virtualenv. The diagnosis, the measurements over the suite and the queue that follows are in the maintenance status.What changes
The rule.
WORKFLOW-LOCAL.mdgains Unit Tests: a unit test file mirrors its module undertests/unit/; a test is a Hoare triple whose precondition the test itself establishes, one call to a public operation, and a promised postcondition; every test has a docstring stating the contract; a unit declares its public surface before it is testable; existing files are markedlegacyand only shrink, a touched test is fixed and moved; the gate checks what a machine can check; the Pair Review Loop brief carries the reviewer's duty. The humane companion carries the motivation. The review brief template and the unit-tests guide are updated.The gate.
scripts/test_conventions.pyruns in thetestsandbuildsessions and as atests.ymlstep against the PR's base SHA. It checks placement and docstrings of non-legacy files, and compares legacy files with the merge base: no test function added or changed, no marker added. Its summary line counts the legacy debt.The marking. All 110 existing test files carry
pytestmark = pytest.mark.legacy, the marker is registered. The first two mirror files are the checker's own tests and the registered-marker law, which the new marker broke and which therefore moved, as rule 5 says.Evidence
scripts/test_conventions.pyagainst this branch: 110 legacy files holding 1524 tests, 2 files follow the convention, 0 breaches.nox -s typecheck: clean over 273 files.nox -s testsin the slice worktree, inside the dogfood capsule: 2730 passed, 14 failed, 41 deselected. The 14 are the 13 trust-record failures the owner's run showed plus the marker law before it moved; the morning's four lock-reading failures and the scan failure do not occur in a clean worktree. The 13 are the isolation gap this PR records and queues, not something it changes.Left for the queue
The isolation fixture should set
DEVCAPSULE_CONFIG_HOME; the sharedproject,configandrecordhelpers move to the unit tree's conftest before legacy tests start moving; a workstream for the measured refactor of the legacy debt; contract and property-based frameworks decided inside its first slice.🤖 Generated with Claude Code