fix(audit): declare the partial flag on discord.role_changed - #216
Merged
Conversation
Both writers stamp `partial` on every row they write (jobs/discord-roles.ts:143 on the deprovision path, :369 on the main sweep), but the PARTS entry declared only added/removed/tier/cause. Undeclared keys count toward the hidden-key total, so EVERY role-change row rendered a `+1 more` with nothing behind it -- and a row that was genuinely partial said so only as that same opaque count. Declared with `flag` rather than `scalar`: the interesting state is the true one, and "partial false" on the overwhelming majority of rows would be noise.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe ChangesRole change audit summaries
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
Comment |
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.
Found while auditing the Details column for #215, fixed separately because it is
a different action and a different mechanism.
The bug
discord.role_changedhas two writers, and both stamp apartialkey on everyrow:
src/jobs/discord-roles.ts:143— the deprovision path, writing{ removed, cause, partial }src/jobs/discord-roles.ts:369— the main sweep, writing{ added, removed, tier, partial }The
PARTSentry declaredadded,removed,tier, andcause— notpartial.summarizeDetailscounts undeclared keys toward the hidden-keytotal, so every role-change row rendered a
+1 morewith nothing behind it.Two costs. The
+1 morewas pure noise on rows where nothing was hidden, whichtrains an admin to ignore the marker. And a row that was genuinely partial —
some roles failed to apply — announced that fact only as the same opaque count
it showed on every complete row, so the one case worth noticing was
indistinguishable from the noise.
The fix
One
flag("partial", "partial")added to the declaration.flagrather thanscalar: it renders the word only when the value is truthywhile declaring the key either way, so complete rows say nothing instead of
carrying a
partial falsethat would be noise on the overwhelming majority.Placed last because it qualifies the whole change rather than naming a part of
it, and declared parts are never truncated (
summarize.ts:405-407), so trailingcosts it no visibility.
Verification
Written test-first — the three new cases fail against the unfixed code:
That last one is the bug stated precisely:
partialinflating the hidden countpast the one key that was genuinely undeclared. All three pass after the change.
npm run typecheck,npm run lint,npm run format:checkclean.npm test→ 92 files, 1490 tests passing.npm run buildsucceeds.Scope
This fixes the one action. I did not systematically audit the other ~50
logAuditpayload sites for the same declared-vs-written drift — that is abroader sweep worth doing on its own, and the same class of bug would be
invisible in exactly the same way anywhere else it exists.
Touches
summarize.tsalongside #215, but in a different region ofPARTS(the
discord.*entries rather than the character-id ones). Either ordermerges.
Summary by CodeRabbit
Bug Fixes
partialindicator only when applicable.partialfield from being incorrectly counted as an undisclosed change when false.Tests