Skip to content

Commit d4ba334

Browse files
authored
Merge branch 'main' into chore/rename-repo-to-refactron
2 parents 08a83ee + af843fb commit d4ba334

36 files changed

Lines changed: 3159 additions & 157 deletions

‎.claude/agents/release-manager.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ Follow `RUNBOOK.md` for the mechanics and `dev-docs/release-v0.3.0-checklist.md`
4444
- The `refactron.yaml` schema and the `analyze --json` output shape.
4545
- The PyPI wrapper's behavior, including which Node version it demands and what it does when the CLI is absent.
4646

47+
## Version policy overrides this mapping
48+
49+
**Stay in the current minor. Ship patches (`0.4.1`, `0.4.2`, ...) until the
50+
milestone the next minor stands for is actually delivered.** See the version
51+
policy in `COMMIT_CONVENTIONS.md`.
52+
53+
The mapping below describes what each class of change _would_ be under plain
54+
semver. Use it to reason about **blast radius**, not to pick the number. In
55+
practice that means a change the mapping calls a minor — a new additive
56+
`VerdictReport` field, for instance — still ships as a patch, and the changelog
57+
carries the signal the version number is not carrying. Do not propose a minor
58+
bump on the mapping alone, and do not re-raise it once the founder has called it.
59+
4760
## Semver mapping
4861

4962
- **Patch**: bug fixes that change no public surface. New preconditions from a sidecar are patch (additive observability). Tier reassignments are patch. Internal refactors are patch. **A fix that makes the engine refuse something it used to certify is also a patch**, because the old behavior was a defect, not a contract; say so loudly in the changelog rather than hiding it under a version number.

‎.claude/commands/ship.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Then check the invariants that CI enforces late and cheaply here:
3535
- `node dist/cli/index.js analyze src/ --fail-on high` after a build, since our own self-analysis gate blocks the PR and has caught real style violations in new sidecar code.
3636
- Locked files untouched: `git diff --name-only main...HEAD | grep -E 'src/(contracts|core/models|adapters/interface)\.ts'` must be empty.
3737
- Commit hygiene: Conventional Commits, subjects under 72 characters, no AI names, no co-author trailers.
38+
- Commit granularity: one logical change per commit. Read `git log --oneline main..HEAD` and check no single commit bundles several independent fixes. A commit you could not revert without taking unrelated work with it was too big. Split it before the PR opens, not after.
3839

3940
## 3. Verify the work against its issue
4041

‎.claude/commands/start.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ Two habits that have repeatedly paid off in this repo:
4949
- **Prove the test is red first.** Run it against the pre-fix state and paste the failure. Several "regression tests" here turned out to pass identically on both trees.
5050
- **Surface what you find.** Work that uncovers a second bug is normal. File it with `/issue` and link it; do not silently fold unrelated fixes into this branch.
5151

52-
Commit in logical units with Conventional Commits, subject under 72 characters, no AI names, no co-author trailers. The commit-msg hook enforces this.
52+
Commit in logical units with Conventional Commits, subject under 72 characters, no AI names, no co-author trailers. The commit-msg hook enforces the message shape; the granularity is on you.
53+
54+
**One logical change per commit.** A small fix gets its own commit, even when several came out of the same sitting. The test is whether the commit can be reverted on its own without taking unrelated work with it. Bundling a review's findings into one large commit destroys revert granularity and makes `git bisect` resolve to "one of these ten things". See `COMMIT_CONVENTIONS.md`.
5355

5456
## 5. Hand off to /ship
5557

‎CHANGELOG.md‎

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,127 @@ All notable changes to Refactron are documented here.
55
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
---
9+
10+
## [0.4.1] — 2026-08-19
11+
12+
**Read this one.** Nothing about the report's shape changed, so a version number
13+
alone will not tell you what did: **five false `SAFE` verdicts are fixed, and
14+
what earns a `SAFE` is now narrower.** Every verdict that moves, moves from
15+
`SAFE` toward `UNPROVEN`. Nothing that was `UNSAFE` or `UNPROVEN` can become
16+
`SAFE`, and exit codes are unchanged (`SAFE` and `UNPROVEN` both exit `0`).
17+
18+
Because this is a patch, `^0.4.0` picks it up automatically. That is deliberate:
19+
these are correctness fixes and they should reach you without a manual bump.
20+
21+
### Fixed — five ways a change could earn a `SAFE` it had not earned
22+
23+
Each was reproduced before being fixed. In every case a **passing** suite and
24+
**measured** coverage still produced a `SAFE` that the full suite contradicts.
25+
26+
| The command | Was | Now |
27+
| --- | --- | --- |
28+
| `pytest -q tests/test_scale.py` | `SAFE` on a change that breaks a test | `UNPROVEN` |
29+
| `pytest -q --collect-only` | `SAFE` while running **zero** tests | `UNPROVEN` |
30+
| `PYTEST_ADDOPTS="-k x" pytest -q` | `SAFE` while running one test | `UNPROVEN` |
31+
| `python3 -m unittest tests.test_scale` | `SAFE` on a change the suite catches | `UNPROVEN` |
32+
| 40 statements changed, 1 executed | `SAFE`, "the changed code is covered" | `UNPROVEN` |
33+
34+
If you acted on a `SAFE` from 0.4.0 or earlier for a change verified with a
35+
narrowed test command, or one where `coverage.changedStatements` showed
36+
`covered < total`, that verdict claimed more than it had proven. Re-verify.
37+
38+
### Changed
39+
40+
**What `SAFE` means is narrower.** Two independent rules tightened it. Both move
41+
verdicts in the same direction: `SAFE` becomes `UNPROVEN`. Nothing that was
42+
`UNSAFE` or `UNPROVEN` can become `SAFE`, and exit codes are unchanged.
43+
44+
#### 1. `SAFE` now requires every coverable changed statement to have run
45+
46+
The old rule cleared a whole file as soon as **one** of its changed statements
47+
executed. A diff changing 40 statements in one file, of which 1 ran, returned
48+
`SAFE` with the reason "Tests pass and the changed code is covered."
49+
50+
`SAFE` now requires that every changed statement a test _could_ reach did run.
51+
Partial coverage reports `UNPROVEN` and names the ratio:
52+
53+
```
54+
[UNPROVEN] Tests pass, but only 3 of 14 changed statements were exercised.
55+
```
56+
57+
Statements coverage.py excluded (`# pragma: no cover`, `if TYPE_CHECKING:`) are
58+
subtracted from the count rather than held against you, since no test can reach
59+
them. A change consisting _entirely_ of excluded statements does not reach
60+
`SAFE`: there is nothing a test could have proven about it.
61+
62+
If you are comparing against stored reports, a `SAFE` whose
63+
`coverage.changedStatements` shows `covered < total` was earned under the old
64+
rule. See ADR-11.
65+
66+
#### 2. A narrowed test command can no longer earn `SAFE`
67+
68+
Passing a `testCmd` such as `pytest tests/unit/test_foo.py`, or one using `-k`,
69+
`-m`, `-t` or `--onlyChanged`, scopes the entire verification run. Coverage
70+
could report the changed code as fully exercised while the one test that would
71+
have caught the change was never selected. Reproduced: one repo, one diff, two
72+
test files, only the command differing:
73+
74+
```bash
75+
python3 -m pytest -q # UNSAFE — the change breaks a test
76+
python3 -m pytest -q tests/test_scale.py # was SAFE, now UNPROVEN
77+
```
78+
79+
Refactron now classifies the command as `full`, `narrowed` or `unknown` and
80+
reports it on the new `testScope` field. `narrowed` floors the verdict at
81+
`UNPROVEN`. `unknown` (an unparsed wrapper such as `make test`) does not floor,
82+
and that gap is documented rather than hidden. A `PYTHONPATH=` prefix is not
83+
narrowing, so the remedy for shadow bypass is unaffected.
84+
85+
Exit codes are unchanged: `SAFE` and `UNPROVEN` both exit `0`. Pipelines that
86+
parse the verdict string will see more `UNPROVEN`.
87+
88+
### Added
89+
90+
- `testScope` on `VerdictReport`, carried by `verify-diff --json` and the MCP
91+
`verify_change` tool. Says whether the command was `full`, `narrowed` or
92+
`unknown`, so a stored verdict can be audited for scoping after the fact.
93+
Additive; `reportVersion` stays `1`.
94+
- `engineVersion` on `VerdictReport`: the version that produced the report.
95+
`reportVersion` tells you which **shape** you hold; `engineVersion` tells you
96+
which **rules** produced the verdict. You want both if you keep reports as
97+
history, because this release changed the rules without changing the shape.
98+
- `unittest` is now a recognised runner, alongside `pytest`, `vitest` and `jest`.
99+
- A CLI note naming the filter that cost a run its `SAFE`, and a different note
100+
when the command could not be parsed at all — silence there would let a `SAFE`
101+
resting on an unreadable command look clean.
102+
- The MCP `testCmd` schema now states the narrowing rule, so an agent learns it
103+
before spending a verification run rather than after.
104+
105+
106+
### Security
107+
108+
- Cleared two high and one moderate advisory (`nanoid`, `ip-address`, `hono`),
109+
lockfile-only. No declared dependency range widened. `npm audit` is a release
110+
gate and was failing before this.
111+
112+
### Known limitations, stated rather than implied
113+
114+
- **Coverage is Python-only.** A TypeScript or mixed diff still returns
115+
`UNPROVEN`; it cannot reach `SAFE`, which is the fail-safe direction.
116+
- **`SAFE` means executed, not asserted.** Coverage proves a changed statement
117+
ran, not that any test would fail if its behaviour changed. Tracked in #116.
118+
- **A command we cannot parse is not floored.** `make test`, a wrapper script,
119+
or an unrecognised plugin flag classifies `unknown` and can still reach `SAFE`.
120+
Flooring it would make `SAFE` unreachable for most projects; the CLI says so
121+
out loud instead.
122+
- **Config-file narrowing is not seen.** `pytest.ini` `addopts`/`testpaths`, a
123+
vitest `include`, a jest `testMatch`. The command and the environment are read;
124+
your config files are not. Tracked in #118.
125+
- **Statement-level, not branch-level.** A changed `if` whose true branch never
126+
ran still counts as covered. Tracked in #117.
127+
128+
8129
---
9130

10131
## [0.4.0] — 2026-08-06

‎COMMIT_CONVENTIONS.md‎

Lines changed: 74 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ Conventional Commits, with this repository's specific scope vocabulary and autho
1515
```
1616

1717
- **Subject**: imperative, present tense, no trailing period, ≤ 72 chars.
18-
- **Body**: optional. Wrap at 80. Explains *why*, not *what* the diff shows.
18+
- **Body**: optional. Wrap at 80. Explains _why_, not _what_ the diff shows.
1919
- **Footer**: optional. `Closes #N` / `Refs #N` / `BREAKING CHANGE: …`.
2020

2121
---
2222

2323
## Allowed types
2424

25-
| Type | When to use |
26-
|---|---|
27-
| `feat` | A new user-visible feature. Triggers a minor bump. |
28-
| `fix` | A bug fix. Triggers a patch bump. |
29-
| `perf` | A change that improves performance without changing behavior. Patch. |
25+
| Type | When to use |
26+
| ---------- | ------------------------------------------------------------------------------------------ |
27+
| `feat` | A new user-visible feature. Triggers a minor bump. |
28+
| `fix` | A bug fix. Triggers a patch bump. |
29+
| `perf` | A change that improves performance without changing behavior. Patch. |
3030
| `refactor` | Code change that neither fixes a bug nor adds a feature. Patch (no public surface change). |
31-
| `test` | Adding or correcting tests only. Patch. |
32-
| `docs` | Documentation only. Patch. |
33-
| `chore` | Tooling, CI, build infrastructure, dep bumps. Patch. |
34-
| `ci` | CI workflow changes specifically. Patch. |
35-
| `style` | Formatting, whitespace. Patch. (Rare — should be auto-applied by prettier.) |
36-
| `revert` | Reverts a previous commit. Patch or minor depending on what was reverted. |
31+
| `test` | Adding or correcting tests only. Patch. |
32+
| `docs` | Documentation only. Patch. |
33+
| `chore` | Tooling, CI, build infrastructure, dep bumps. Patch. |
34+
| `ci` | CI workflow changes specifically. Patch. |
35+
| `style` | Formatting, whitespace. Patch. (Rare — should be auto-applied by prettier.) |
36+
| `revert` | Reverts a previous commit. Patch or minor depending on what was reverted. |
3737

3838
If the type field becomes a guess, your commit is doing two things. Split it.
3939

@@ -43,25 +43,25 @@ If the type field becomes a guess, your commit is doing two things. Split it.
4343

4444
Use these scopes; don't invent new ones without adding them here first.
4545

46-
| Scope | Covers |
47-
|---|---|
48-
| `analyze` | `src/analyze/`, detectors, blast-radius |
49-
| `transform` | `src/transform/`, engine, TRANSFORM_ORDER |
50-
| `transform-sidecar` | The Python sidecars under `src/transform/transforms/python/_py/` |
51-
| `verify` | `src/verify/`, 3-gate verification engine |
52-
| `cli` | `src/cli/`, command parsing, format-plan |
53-
| `document` | `src/document/`, docstring + changelog generation |
54-
| `python-adapter` | `src/adapters/python/`, the Python subprocess boundary |
55-
| `ts-adapter` | `src/adapters/typescript/`, ts-morph wrapper |
56-
| `infra` | `src/infrastructure/` — atomic-writer, diff, git |
57-
| `pipeline` | `src/pipeline/` — session, store, queue |
58-
| `contracts` | `src/contracts.ts` (locked — should be rare and always paired with ADR) |
59-
| `core` | `src/core/` (locked — rare) |
60-
| `docs` | `docs/` mdx files |
61-
| `dev-docs` | `dev-docs/` internal docs |
62-
| `ci` | `.github/workflows/` |
63-
| `deps` | `package.json` dep changes |
64-
| `release` | `CHANGELOG.md`, version bumps |
46+
| Scope | Covers |
47+
| ------------------- | ----------------------------------------------------------------------- |
48+
| `analyze` | `src/analyze/`, detectors, blast-radius |
49+
| `transform` | `src/transform/`, engine, TRANSFORM_ORDER |
50+
| `transform-sidecar` | The Python sidecars under `src/transform/transforms/python/_py/` |
51+
| `verify` | `src/verify/`, 3-gate verification engine |
52+
| `cli` | `src/cli/`, command parsing, format-plan |
53+
| `document` | `src/document/`, docstring + changelog generation |
54+
| `python-adapter` | `src/adapters/python/`, the Python subprocess boundary |
55+
| `ts-adapter` | `src/adapters/typescript/`, ts-morph wrapper |
56+
| `infra` | `src/infrastructure/` — atomic-writer, diff, git |
57+
| `pipeline` | `src/pipeline/` — session, store, queue |
58+
| `contracts` | `src/contracts.ts` (locked — should be rare and always paired with ADR) |
59+
| `core` | `src/core/` (locked — rare) |
60+
| `docs` | `docs/` mdx files |
61+
| `dev-docs` | `dev-docs/` internal docs |
62+
| `ci` | `.github/workflows/` |
63+
| `deps` | `package.json` dep changes |
64+
| `release` | `CHANGELOG.md`, version bumps |
6565

6666
Multiple scopes: comma-separated, no spaces: `fix(cli,document): …`.
6767

@@ -74,6 +74,26 @@ Multiple scopes: comma-separated, no spaces: `fix(cli,document): …`.
7474
3. **No `--no-verify`.** If a hook fails, fix the underlying issue. The hook exists to catch a class of bug; bypassing it means shipping that bug.
7575
4. **No `--amend` on a commit that's already been pushed.** Force-push history rewrites are a CR-block.
7676
5. **`BREAKING CHANGE:` footer is mandatory** for any commit that introduces an API/CLI/file-format break. The footer is what tooling reads to bump major.
77+
6. **One logical change per commit.** A small fix gets its own commit. Do not bundle several fixes into one large commit because they were found in the same sitting.
78+
79+
---
80+
81+
## One logical change per commit
82+
83+
**The unit is the change, not the work session.** If you fixed five things, that is five commits, even when they are one-line each and even when they all came out of the same review.
84+
85+
The test: _can this commit be reverted on its own without taking anything unrelated with it?_ If reverting to undo one fix would also undo four others, the commit was too big.
86+
87+
Why this is enforced rather than encouraged:
88+
89+
- **Revert granularity is the whole point.** A false verdict traced to one of five bundled fixes cannot be backed out without losing the other four, so the fix becomes a new forward patch under time pressure — the worst moment to be writing code.
90+
- **`git bisect` resolves to a commit.** A commit containing ten fixes tells you the bug is in one of ten places, which is barely better than not bisecting.
91+
- **Review attention is per-diff, not per-line.** Ten fixes in one diff get one pass of attention spread thin. The reviewer's third question is sharpest on the third commit and absent on the third hunk of a large one.
92+
- **`git log --oneline` is the changelog draft.** One subject covering ten fixes means writing the release notes twice.
93+
94+
Practical shape, for a review that returns several findings: one commit per finding, each with its own test, in an order where every commit leaves the suite green. Related but separable work — the code fix, the doc correction it implies, the ADR amendment — are separate commits in the same PR, not one commit.
95+
96+
The exception is a change that is genuinely atomic: a rename that must move a symbol and every call site together, or a fix whose test cannot pass without it. Those are one commit because splitting them ships a red tree, not because they are convenient together.
7797

7898
---
7999

@@ -127,9 +147,31 @@ Co-Authored-By: Claude <noreply@anthropic.com> # forbidden trailer
127147

128148
---
129149

150+
## Version policy: the minor is earned, not derived
151+
152+
**Stay in the current minor. Ship patch releases (`0.4.1`, `0.4.2`, ...) until
153+
the milestone that the next minor stands for is actually delivered.**
154+
155+
Conventional Commits will suggest a bump, and semver's 0.x rule says a behaviour
156+
change belongs in the minor. Neither decides it here. In this repository the
157+
minor marks the product reaching a goal, so `feat:` commits and behaviour changes
158+
alike land in a patch until that goal is met. Do not propose a minor bump on a
159+
semver mechanic alone, and do not re-raise it once the call is made.
160+
161+
Two consequences to work with rather than argue about:
162+
163+
- `^0.4.0` resolves to `>=0.4.0 <0.5.0`, so a patch **does** reach existing users
164+
automatically where a minor would not. A behaviour change shipped as a patch is
165+
therefore louder, not quieter, in practice.
166+
- Because the version number is not carrying the signal, **the changelog has to.**
167+
Any release that changes what a verdict means leads with that, in plain words,
168+
above the fix list.
169+
170+
---
171+
130172
## Why these rules exist
131173

132-
- **Conventional Commits** lets `release-manager` agents and `release-please` tooling derive semver bumps + changelog sections automatically. Inconsistent commits mean manual triage at release time.
174+
- **Conventional Commits** lets `release-manager` agents and `release-please` tooling derive semver bumps + changelog sections automatically. Inconsistent commits mean manual triage at release time — but the bump they _suggest_ is a suggestion; see the version policy above.
133175
- **No `--no-verify`** is the difference between "we have a working hook" and "we have a hook we work around." Once you bypass once, everyone else does too.
134176
- **No co-author trailers** keeps `git blame` and contributor stats accurate. The reviewer who shipped it owns it.
135177
- **Scope vocabulary** makes `git log --grep="(transform-sidecar)"` useful. Without it, the log is grep-hostile.

0 commit comments

Comments
 (0)