Skip to content

Commit 82bf47b

Browse files
hotlongclaude
andauthored
feat(devx): read-seam invention rule gains an identity-pass-through criterion (#6451) (#6471)
The #5186 read-seam rule reddens on a `catch` around a storage read that logs nothing and returns an invented answer. Its EMPTY value table (`[]` / `false` / `null` / `undefined` / `{}` / `''` / `0` / `1`) could not see the shape #6116 turned out to be: `catch { return records; }`, where `records` is the enclosing function's own parameter. That seam was counted in the census the whole time while the gate printed a green line, so the defect survived under a gate that had surveyed it — found by a human reading code, like the three before it. Measured first, per the maintainer's 2026-08-06 收窄先行 ruling, before any criterion was written. Across the three scan roots (78 production files, 292 catch clauses, 63 read seams) exactly 2 catches return one of their own parameters; only 1 guards a read at all, and BOTH already log, so both are absorbed by the existing "any log at all" exemption. The true new red set is zero: this reddens nothing on `main` and adds no baseline entry. The criterion is separate from the empty-value table on purpose — `inventedEmptyValue` judges an expression alone, this one needs the enclosing function's parameter list, and merging them would give the table a silent context dependency. Both existing exemptions still apply unchanged, which is why #6116's fixed seam stays green: it keeps passing the input through on both branches and says so once. - new `identityPassThrough` + `enclosingFunctionParameters`; findings carry a `kind` so the violation message names which criterion fired and offers the pass-through-specific fix (add one log; never "change the value") - the census line now names the seam it used to render as "no invented answer" - self-test: 8 new cases pinning #6116 before and after its fix, the type-discriminated branch, both-branch pass-through, a caller-supplied fallback, destructured/`as`/`!` spellings, a callback's own parameter, and the measured majority shape (an accumulated local is NOT a pass-through) - new `expectInvents` assertion on the exact reported set: `expectViolation: false` is vacuous for cases that pass BECAUSE an exemption fired — deleting the criterion left them green, testing nothing. Reverse-verified: neutering the criterion turns 8 cases red, 2 of them solely through `expectInvents` - limitation 4 records what the rule deliberately cannot do: separate "pass-through as declared contract" from "pass-through swallowing a fault" Claude-Session: https://claude.ai/code/session_01BDmDsu2575gDxeMCxXhDE3 Co-authored-by: Claude <noreply@anthropic.com>
1 parent f996495 commit 82bf47b

2 files changed

Lines changed: 427 additions & 18 deletions

File tree

0 commit comments

Comments
 (0)