Skip to content

fix(restriction_policies): drop stale principals instead of skipping the whole policy (2/4)#630

Draft
michael-richey wants to merge 1 commit into
drop-unresolvable-principals-scaffoldingfrom
drop-unresolvable-principals-restriction-policies
Draft

fix(restriction_policies): drop stale principals instead of skipping the whole policy (2/4)#630
michael-richey wants to merge 1 commit into
drop-unresolvable-principals-scaffoldingfrom
drop-unresolvable-principals-restriction-policies

Conversation

@michael-richey

Copy link
Copy Markdown
Collaborator

Context

Stacked PR 2 of 4. Base: drop-unresolvable-principals-scaffolding (PR #629). This is the confirmed incident fix.

This PR

Overrides connect_resources on RestrictionPolicies so that, under --drop-unresolvable-principals, a principal absent from both destination and source (permanently gone — e.g. a role deleted before the org's first-ever import) is dropped from its binding and the policy still syncs, instead of the whole restriction policy being skipped on a single dead reference.

  • Principals present in source but not destination keep today's hard-fail/retry behavior.
  • If dropping empties a binding whose source list was non-empty, the resource is still skipped and flagged as an access-elevation risk (ERROR + risk:empty_restriction_policy metric), governed by --skip-failed-resource-connections like any other connection failure.
  • The "id" (dashboard/slo/notebook) connections keep the generic path unchanged.
  • extract_source_ids intentionally left unaffected (documented) so --minimize-reads lazy-loading can still resolve which principals to check.

Testing

New TestRestrictionPoliciesConnectResources suite: flag off (unchanged), drop-and-continue, source-present hard-fail, empty-binding risk, multi-binding partial-empty, skip_failed_resource_connections interaction, middle-element index-shift regression, extract_source_ids unaffected, org/non-composite pass-through, and a dangling-id guard. Green; ruff clean.

🤖 Generated with Claude Code

…the whole policy

Overrides `connect_resources` so that, under `--drop-unresolvable-principals`, a principal
absent from both destination and source state (permanently gone — e.g. a role deleted
before the org's first-ever import) is dropped from its binding and the policy still syncs,
instead of the entire restriction policy being skipped on a single dead reference.

- Principals present in source but not destination keep today's hard-fail/retry behavior.
- If dropping empties a binding whose source list was non-empty, the resource is still
  skipped and flagged as an access-elevation risk (ERROR + metric), governed by
  `--skip-failed-resource-connections` like any other connection failure.
- The "id" (dashboard/slo/notebook) connections keep the generic path unchanged.
- `extract_source_ids` is intentionally left unaffected (documented) so minimize-reads
  lazy-loading can still resolve which principals to check.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@michael-richey michael-richey force-pushed the drop-unresolvable-principals-scaffolding branch from 7db6366 to a7514ad Compare July 14, 2026 21:32
@michael-richey michael-richey force-pushed the drop-unresolvable-principals-restriction-policies branch from c0fbb7e to 76bcbff Compare July 14, 2026 21:32
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