Skip to content

fix(governance): fold a lower tier's channels.posture as an intersection - #18776

Merged
cruisercohen merged 1 commit into
mainfrom
fix/9798-posture-tier-fold
Oct 10, 2026
Merged

cruisercohen merged 1 commit into
mainfrom
fix/9798-posture-tier-fold

Conversation

@cruisercohen

@cruisercohen cruisercohen commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: When one policy tier is composed over another, the lower tier's channels.posture takes effect as a narrowing instead of being dropped.

ScopedMap.compose returned the higher tier's posture and ignored the lower tier's. So a home or env policy that narrows channels.posture (for example slack.allowed_enterprise_ids) beneath a central policy that also sets channels had 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

  • Changing policy-over-profile composition. A profile still cannot carry posture.
  • Changing the updates.source rule, where the higher tier's glob still stands.
  • Validating a lower-tier posture entry against the composed members; a member the higher tier refuses is refused whatever its posture says.

What changed (motivation → approach → change)

Leaf in posture Result of the fold
Set by both tiers Intersection: an id must be allowed by both
Set only by the lower tier Added as a further restriction
Set only by the higher tier Kept

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.compose in src/kiro_crew/platform/governance.py now builds the posture with a new _compose_posture helper, reusing ScopedRuleset.compose (allow∩allow, deny∪deny) for leaves both sides set.

A profile never carries posture, because ScopedMap.from_dict rejects 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.posture that 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 set channels:

  • 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 controls field the per-scope compose left to the higher tier.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision c8b73d190568fdcf341750b5c529c6baeff33b34 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of c8b73d190568fdcf341750b5c529c6baeff33b34 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

After upgrade, a home or env channels.posture that used to be ignored starts refusing Slack ids. Check that existing two-tier deployments expect this.

What this change ships

Inventory (4 items) — 4 justified

Intent: when policy tiers are stacked, an operator's lower-tier channel posture narrowing actually applies instead of being silently dropped. FIX (#9798).

  1. A lower tier's posture leaf that the higher tier also sets now intersects with it, so an id must be allowed by both — justified
  2. A posture leaf or member set only by the lower tier now adds a restriction — justified
  3. The governance guide and spec no longer say "a subordinate posture is not yet folded" — justified
  4. Three tier-ladder tests cover intersect, cannot-widen and no-repeal-by-omission — justified

[FIRST-PRINCIPLES-REVIEWED] c8b73d1

Description read

[DESCRIPTION-READ] cff853630d7fe33749da52eb035f21d4347528a576129c2a56877a0424e7bc19

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of c8b73d190568fdcf341750b5c529c6baeff33b34 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check before merge: a posture denial from the lower tier is labelled profile: (layer profile) by _AndRuleset. The members fold already labels its denials the same way.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed c8b73d190568fdcf341750b5c529c6baeff33b34 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] c8b73d1

Verdict parsed from the review's SHA-scoped output markers for commit c8b73d190568fdcf341750b5c529c6baeff33b34.

False positive or not applicable? A repository writer can comment:
/ai-review override fable c8b73d190568fdcf341750b5c529c6baeff33b34: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of c8b73d190568fdcf341750b5c529c6baeff33b34 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c8b73d1

False positive or not applicable? A repository writer can comment:
/ai-review override gpt c8b73d190568fdcf341750b5c529c6baeff33b34: <one-sentence reason>

@cruisercohen
cruisercohen force-pushed the fix/9798-posture-tier-fold branch from 3d638cd to 659265a Compare October 10, 2026 08:02
@cruisercohen
cruisercohen marked this pull request as ready for review October 10, 2026 08:22
@cruisercohen

Copy link
Copy Markdown
Contributor Author

The five red build/frontend checks (Build Wheel, Build Desktop x2, E2E stub, Frontend Tests 1) all fail on gen-ui-index: src/kiro_crew/docs/ui-index.generated.json is stale. That file is stale on main itself and this PR does not touch the frontend; #18753 regenerates it. This branch will be rebased once that lands.

@cruisercohen
cruisercohen requested review from a team and KiroCrewCaptain as code owners October 10, 2026 08:22
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 10, 2026
@cruisercohen
cruisercohen enabled auto-merge (squash) October 10, 2026 08:34
@cruisercohen
cruisercohen force-pushed the fix/9798-posture-tier-fold branch from 659265a to 39801ff Compare October 10, 2026 08:45
@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention labels Oct 10, 2026
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.
@cruisercohen
cruisercohen force-pushed the fix/9798-posture-tier-fold branch from 39801ff to c8b73d1 Compare October 10, 2026 09:24
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 10, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

This PR fixes ScopedMap.compose, which silently dropped a lower policy tier's channels.posture. The cause was that it returned only the ceiling's posture. The fix is at the root cause. A new _compose_posture in src/kiro_crew/platform/governance.py:1244 intersects leaf by leaf. When both tiers set a leaf it uses ScopedRuleset.compose (allow∩allow, deny∪deny), or an _AndRuleset when the side being narrowed is already an AND. A leaf only the lower tier sets is added, and a leaf only the ceiling sets is kept. I tried to break it in three ways: a lower tier listing an extra id to widen the allowlist, a lower tier omitting posture to repeal the ceiling's, and a third tier stacked on an already-AND'd leaf. None of them widen. The helper copies the ceiling's inner dicts before writing, so composing never changes the ceiling's own posture. The three new tests cover the intersection, the attempt to widen and the omitted posture. Base is main, every check is green, both lanes PASS, and I found no defect. I am holding only because this is a change to security and governance policy, which the brief reserves for a maintainer. — crew-pr-reviewer

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@cruisercohen
cruisercohen merged commit 97aee9c into main Oct 10, 2026
102 checks passed
@cruisercohen
cruisercohen deleted the fix/9798-posture-tier-fold branch October 10, 2026 19:58
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 10, 2026
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.

governance: fold a subordinate tier's channels.posture in the tier ladder (currently discarded by ScopedMap.compose)

2 participants