Skip to content

build: make the unused-state rules precise enough to gate - #1307

Merged
kvlonge merged 3 commits into
mainfrom
feat/fensu-unused-state-precision
Nov 5, 2026
Merged

kvlonge merged 3 commits into
mainfrom
feat/fensu-unused-state-precision

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Why

XSB076 (unread control-store state) and XSB077 (unconstructed enum variants) shipped in warn mode. Before they can gate, each needs a way to record intentional cases with a written reason, and XSB077 must not count a variant as used just because a lookup table or comparison names it. The new-duplicate check from fensu 0.29.0 also needs wiring, in warn mode until it becomes a gate.

Changes

  • XSB076 reads allowed = ["table.column=reason", ...]. It covers audit-history columns that people query directly and the typed mirror columns the UI will filter on, marked "reader comes with the UI epic". XSB077 excepts the evidence-view permission for the same reason.
  • XSB077 reads exceptions = ["Enum" or "Enum::Variant=reason", ...] for serde wire enums and variants written as SQL text. It also reads construction_required = ["Enum=reason"] for enums whose variants count only when a value is constructed; const tables, use, patterns, matches! and ==/!= do not count. Action (permissions) uses this.
  • Malformed entries, and entries naming a table or enum the tree no longer defines, are reported as faults.
  • Require fensu 0.29.0. make check-ci runs fensu dupes --since <base> --fail-on-new; a new cluster prints a warning and does not fail. CI fetches the pull request base for the diff.

Verification

  • pytest tests/unit/scripts/fensu_policy: passes; mutations of each new matcher fail a test.
  • fensu check --warn on main: 0 faults, 3 XSB077 warnings, all likely-real unused variants.
  • On the pre-simplification scheduler baseline: 45 warnings (XSB076 36, XSB077 9), no false positives in XSB077.
  • make check-dupes-new with a copied function reports the cluster and exits 0; with a missing base it skips with a warning.
  • make check-ci passes.

- XSB076 takes an allowlist of table.column=reason entries: audit history
  people read through audit exports, and mirror columns whose reader comes
  with the UI epic.
- XSB077 takes Enum or Enum::Variant exceptions with reasons for serde wire
  enums and variants written as SQL text, and construction_required enums
  whose variants count only where code builds them as a value, so a
  permission named only in role tables and classifiers is reported.
- An entry without a reason, or one that no longer hides anything in a
  tree that defines its table or enum, is reported too.
Require fensu 0.29.0 and run `fensu dupes --since <base> --fail-on-new`
from check-ci. A new cluster prints a warning and does not fail the
build until it becomes a gate. CI fetches the pull request base so the
shallow checkout can diff against it.
@kvlonge
kvlonge enabled auto-merge (squash) November 5, 2026 05:45
The UI's sample-row reads will require view.evidence, so XSB077 excepts
Action::ViewEvidence with that reason instead of reporting it.
@kvlonge
kvlonge merged commit 9ed91ad into main Nov 5, 2026
45 checks passed
@kvlonge
kvlonge deleted the feat/fensu-unused-state-precision branch November 5, 2026 06:24
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.

1 participant