Skip to content

Fail Closed on a Malformed inheritingAgentTypes in the Tier Guard - #4293

Merged
ptr727 merged 1 commit into
developfrom
feature/tier-guard-fail-closed
Nov 19, 2026
Merged

ptr727 merged 1 commit into
developfrom
feature/tier-guard-fail-closed

Conversation

@ptr727

@ptr727 ptr727 commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

load_tiers in the tier guard lower-cased each inheritingAgentTypes entry outside its try. A non-string entry raised AttributeError. The hook exited non-zero, and Claude Code treats a hook error as allow, so the dispatch went through. A bare string or a mapping never raised, but it iterated silently into a set of characters or keys.

The value must now be a list of strings. Anything else is read as an unreadable mapping. That is the hook's existing fail-closed state: every dispatch naming a model is refused, and one naming none is allowed, as the module docstring states for a missing config. The docstring now names this case too.

No current input reaches this. spec/validate.py checks the key's shape, and the deployed mapping is a copy of the validated file. It takes a hand-edited or partially deployed mapping.

Verification

  • New test test_a_malformed_inheriting_list_is_treated_as_missing covers a non-string entry, a null entry, a bare string, a mapping and a number. Against the previous hook all five subtests fail. With the fix the whole suite passes, 26 tests, and --selftest passes.
  • ruff check, ruff format --check, mypy and the prose gate pass in the pre-commit hook.
  • A local-strict-review pass at the frontier tier is recorded against develop with no findings.

The maintainer reads this diff before it merges, since it changes host-setup/agent-safety/.

Closes #4291

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Malformed model-tier configuration is now rejected, preventing named models from being allowed based on invalid settings.
  • Tests
    • Added coverage for malformed configuration values and their resulting access decisions.

load_tiers lower-cased each inheritingAgentTypes entry outside its try, so a
non-string entry raised and the hook's non-zero exit let the dispatch through.
A string or dict value iterated silently into the wrong set. The value must now
be a list of strings, and anything else reads as an unreadable mapping, which
refuses every dispatch naming a model.

Closes #4291

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings November 19, 2026 20:16
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The tier guard now rejects malformed inheritingAgentTypes values. Tests verify the expected results for requests that name a model and requests that do not.

Changes: Tier guard validation

Layer / File(s) Summary
Validate inheritingAgentTypes
host-setup/agent-safety/claude/model-tier-guard.py, host-setup/agent-safety/claude/test_model_tier_guard.py
load_tiers returns None if inheritingAgentTypes is not a list of strings. Tests cover five malformed values: named-model requests are denied, and requests without a model are allowed.

Estimated code review effort: 2 (Simple) | ~8 minutes

Severity of issue fixed: Medium

Possibly related issues

  • ptr727/ProjectTemplate#2361 — The handoff issue describes the same malformed-value dispatch behavior and a test criterion addressed by this change.
Merge Risk: Minimal · up to 57d57

The tier guard now treats malformed inheritingAgentTypes values as an unreadable mapping and refuses dispatches that name a model. Current inputs are already validated upstream, so this only hardens hand-edited or partially deployed mappings. No merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Fail Closed on a Malformed inheritingAgentTypes in the Tier Guard" matches the main change. The raw summary and objectives say the tier guard now rejects a malformed inheritingAgentTypes fi…
Linked Issues check Passed Issue #4291 requires that load_tiers validate the optional inheritingAgentTypes field as a list of strings and return the fail-closed None when it is not. At the reviewed head, load_tiers in m…
Out of Scope Changes check Passed The PR changes two files in host-setup/agent-safety/claude/: the tier guard hook (validation in load_tiers and the module docstring) and its test file (a new malformed-input test). The validation an…
Full details: Title check

Explanation

The title "Fail Closed on a Malformed inheritingAgentTypes in the Tier Guard" matches the main change. The raw summary and objectives say the tier guard now rejects a malformed inheritingAgentTypes field (non-list or non-string entries) and returns None, so dispatches naming a model are refused. The title names the affected field, the component, and the fail-closed behavior. It is specific and concise, and it does not use vague terms.

Full details: Linked Issues check

Explanation

Issue #4291 requires that load_tiers validate the optional inheritingAgentTypes field as a list of strings and return the fail-closed None when it is not. At the reviewed head, load_tiers in model-tier-guard.py does this. It returns None when inheriting is not a list or any entry is not a str. Only then does it lower-case the entries. A non-string entry, a null entry, a bare string, a mapping, or a number now returns None instead of raising. The validation runs after the try block, not inside it as the issue suggests. The checks are isinstance and all(isinstance(...)) calls, which cannot raise, and the try still guards the file read and key lookups. So the requested behavior holds. The module docstring also documents the new case. The absent-key case still defaults to an empty list, so existing mappings without the key keep working. The test file change was not readable through the tool, so the test result is taken from the PR description and is not independently verified. The behavior itself was verified from the source.

Full details: Out of Scope Changes check

Explanation

The PR changes two files in host-setup/agent-safety/claude/: the tier guard hook (validation in load_tiers and the module docstring) and its test file (a new malformed-input test). The validation and docstring changes implement #4291 directly. The new test supports that change. No unrelated behavior was found in the hook source. The test file diff could not be read, so its contents are inferred from the PR description and the raw summary, which both describe only the malformed-input test.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8a1441e and 57d57fa.

Files selected for processing: 2

  • host-setup/agent-safety/claude/model-tier-guard.py
  • host-setup/agent-safety/claude/test_model_tier_guard.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@ptr727

ptr727 commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 57d57facccec1145b86e6521e5162bf95bbd5ca7, the content this pull request carries at that commit against develop, and it recorded 0 findings.

Copilot AI 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.

🔵 Needs a closer look

Maintainer review is needed because the change alters a host safety hook’s fail-closed handling of malformed deployment data, despite passing automated tests.

No open issues 🎉

What changed in this PR

This PR hardens the Claude Code tier guard against malformed inheritingAgentTypes configuration by treating invalid values as unreadable and preserving fail-closed behavior for model-bearing dispatches.

Changes:

  • Validate that inheritingAgentTypes is a list containing only strings.
  • Document malformed configuration as an unreadable state.
  • Add tests covering malformed lists, nulls, strings, mappings, and numbers.
File Description
host-setup/​agent-safety/​claude/​test_model_tier_guard.py Adds coverage verifying fail-closed behavior for malformed inheritingAgentTypes values.
host-setup/​agent-safety/​claude/​model-tier-guard.py Validates inheritingAgentTypes configuration and documents the resulting fail-closed behavior.

Review effort: Lite

@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.95%. Comparing base (8a1441e) to head (57d57fa).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4293   +/-   ##
========================================
  Coverage    78.95%   78.95%           
========================================
  Files           42       42           
  Lines        15625    15625           
========================================
  Hits         12337    12337           
  Misses        3288     3288           
Flag Coverage Δ
python-3.13 78.95% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727

ptr727 commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ptr727

ptr727 commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

Copilot round on 57d57fa, headline "Needs a closer look: Maintainer review is needed because the change alters a host safety hook's fail-closed handling of malformed deployment data" (0 open findings, "No open issues"). No change needed: the headline names no defect. It restates that the diff touches host-setup/agent-safety/, which this PR already routes to the maintainer for a read before merge, and merge stays held for that go-ahead. Tests pass in CI (26 tests plus --selftest).

@ptr727
ptr727 merged commit b352fb9 into develop Nov 19, 2026
14 checks passed
@ptr727
ptr727 deleted the feature/tier-guard-fail-closed branch November 19, 2026 20:53
ptr727 added a commit that referenced this pull request Nov 19, 2026
…pes and Close Further Retired-Path Edges (#4296)

## Summary

Promotes `develop` to `main`. It carries these changes:

- [#4293](#4293) makes the
tier guard fail closed on a malformed `inheritingAgentTypes`.
- **Declined points.** A list-valued `models` raises a `TypeError` the
existing `try` catches, and a deep-nesting `RecursionError` is outside
the hook's stated scope. The hook runs standalone and cannot import
`is_str_list`. Empty or duplicate names do no harm in the hook.
- [#4295](#4295) closes
further latent edges in the retired-path checks. Its body lists 7
declined edges with evidence under "Declined edges", and #4294 tracks
the two leftover edges.

Closes #4291
Closes #4285

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

2 participants