Repository navigation
fix(governance): fold a lower tier's channels.posture as an intersection - #18776
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS After upgrade, a home or env What this change shipsInventory (4 items) — 4 justifiedIntent: when policy tiers are stacked, an operator's lower-tier channel posture narrowing actually applies instead of being silently dropped. FIX (#9798).
[FIRST-PRINCIPLES-REVIEWED] c8b73d1 Description read[DESCRIPTION-READ] cff853630d7fe33749da52eb035f21d4347528a576129c2a56877a0424e7bc19 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check before merge: a posture denial from the lower tier is labelled [DESIGN-REVIEWED] c8b73d1 Description read[DESCRIPTION-READ] abed7d68e625ee9e1572760437cf7b8169b26b94f0d7344b0c885146f19d0000 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
3d638cd to
659265a
Compare
|
The five red build/frontend checks (Build Wheel, Build Desktop x2, E2E stub, Frontend Tests 1) all fail on |
659265a to
39801ff
Compare
ScopedMap.compose kept only the higher tier's posture, so a lower policy tier's narrower channels.posture had no effect. Posture now folds leaf by leaf: a leaf both tiers set is the intersection, a leaf only the lower tier sets is added, and the higher tier's leaves are kept. A profile never carries posture, so policy-over-profile composition is unchanged.
39801ff to
c8b73d1
Compare
|
This PR fixes |
iamwhatever
left a comment
There was a problem hiding this comment.
This fixes ScopedMap.compose, which kept only the ceiling's channels.posture and dropped a lower policy tier's. The fix is at the root: _compose_posture in src/kiro_crew/platform/governance.py intersects leaf by leaf. A leaf both tiers set goes through ScopedRuleset.compose (deny∪deny flattens, and every other mode or matcher pair becomes an _AndRuleset that requires both to permit). A leaf only one tier sets carries through as a restriction. The ceiling's inner dicts are copied before any write, so the ceiling is never mutated. I tried five ways to widen the ceiling: a subordinate listing an extra id, a subordinate omitting posture, a third tier over an already-AND'd leaf, mismatched allow/deny modes, and a profile tier (from_dict rejects posture, so that path is a no-op). Every one only narrows or keeps the ceiling, so the change can only refuse more. The one user-visible effect is that a home or env posture that used to be ignored now applies. That is the documented intent, and the guide and spec are updated. Three new tier-ladder tests cover intersect, cannot-widen and no-repeal-by-omission, and the intersect test fails on base, where the subordinate leaf was dropped. Base is main, checks are green and all lanes PASS. — crew-pr-reviewer (deep re-check)
Problem / Motivation
Goal: When one policy tier is composed over another, the lower tier's
channels.posturetakes effect as a narrowing instead of being dropped.ScopedMap.composereturned the higher tier's posture and ignored the lower tier's. So a home or env policy that narrowschannels.posture(for exampleslack.allowed_enterprise_ids) beneath a central policy that also setschannelshad no effect, and nothing reported it.Why it matters
The tier ladder's rule is that a lower tier may only narrow the higher one. A narrowing that is silently discarded breaks that rule in the quiet direction: the operator believes a restriction applies when it does not.
Not a goal
updates.sourcerule, where the higher tier's glob still stands.members; a member the higher tier refuses is refused whatever its posture says.What changed (motivation → approach → change)
Posture is a map of member → leaf → ruleset, and an absent leaf permits everything. So the fold that can only narrow is an intersection per leaf.
ScopedMap.composeinsrc/kiro_crew/platform/governance.pynow builds the posture with a new_compose_posturehelper, reusingScopedRuleset.compose(allow∩allow, deny∪deny) for leaves both sides set.A profile never carries posture, because
ScopedMap.from_dictrejects it there. So over a profile the helper returns the ceiling's posture unchanged, and policy-over-profile behaviour is the same as before.Alternatives not taken: last-writer-wins, because a lower tier could then widen the higher tier's allowlist; and keeping the discard, because the lower tier's setting is silently dropped. The governance guide (
docs/guides/enterprise-mcp-governance.md) and the governance spec (docs/system-specs/modules/governance.md) describe the fold.Backwards compatibility
Compatible: no document that loads today is rejected. A lower-tier
channels.posturethat was ignored now narrows the composed ceiling, which is the documented tighten-only rule.Removes nothing: no key, path or public function is removed; the only behaviour change is that a narrowing that was discarded now applies.
Tests
In
test/test_governance_tier_ladder.py,TestASubordinateMayOnlyTighten, with a central policy and a home policy that both setchannels:test_a_subordinate_posture_folds_as_an_intersection: a shared leaf intersects, and a leaf only the lower tier sets restricts. Fails on main.test_a_subordinate_posture_cannot_widen_the_authority: a lower tier listing an extra id does not admit it.test_a_subordinate_cannot_repeal_the_authority_posture_by_omission: a lower tier with no posture keeps the higher tier's.Manual verification
N/A — unit coverage sufficient: the change is a pure composition function exercised end to end through
load_security_policy.Related Issues
Fixes #9798
Pattern harvest
Not generalizable: the fold of each governed field is chosen per field shape, and this was the one
controlsfield the per-scope compose left to the higher tier.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)