Repository navigation
refactor(console): extract the approvals audience-scope rule from buildApprovalsView - #958
Merged
Merged
Conversation
…ldApprovalsView Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUbxQw6dBGysLA9CtZkFy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017phewNxcFMxpU3ntX2TKek
Contributor
Author
|
Fixed the red Docs & paths job: this branch predated #956, so zizmor's online audit flagged the old Generated by Claude Code |
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.
What changed
buildApprovalsView(Console approvals screen) mixed three jobs in one body with a nestedswitch/ifover the scope rule. It now:all) to(*approvalsView).applyScope, written with guard clauses instead of nested branches;selectRowshelper (used for both the narrowing filters andapprovalRow.mine).Net: the 55-line function with a nested switch becomes a ~20-line orchestrator plus a ~20-line, independently testable rule.
Why behavior is preserved
Pure restructuring inside the Console adapter; no change to Policy, dispatch, auth, wire format, or rendered output. I added
TestApprovals_ScopeRulesbefore refactoring (it passed against the old code), pinning: default keeps mine+own, default never empties a non-empty queue, default on an empty queue, explicitminemay empty, explicitall. It passes unchanged after.Verification
go vetandgofmtclean on the package.go test ./internal/controlplane/...passes before and after.golangci-lint(the installed binary was built with Go 1.25, below the repo's 1.26.9, so it refuses to load config) and fullmake verify(this PR touches only Console view code, no/proto, so proto gates are not in play). CI will run the full gate.Other candidates, ranked (not taken)
approvalFilter: the filter-key list"who","op","risk","quorum","scope"is repeated inparseApprovalFilter,value,queryand chip builders — replace with named key constants.approvals.go(~2000 lines) andactivity.go(~1850) mix view-building with embedded templates; split templates/filters into separate files.activityFilter/accessFilter/approvalFiltereach reimplementhref/query/withXURL-building — a shared small helper could unify them.cmd/relay/main.go(1280 lines) composition root could be split by concern (security-surface, so needs human review).🤖 Generated with Claude Code
https://claude.ai/code/session_01TKUbxQw6dBGysLA9CtZkFy
Generated by Claude Code