Skip to content

fix(agent-os): close three fail-open gaps from issue #3520 - #3524

Merged
MohammadHaroonAbuomar merged 2 commits into
microsoft:mainfrom
Jainil-Gosalia:fix/fail-open-gaps-3520
Aug 4, 2026
Merged

MohammadHaroonAbuomar merged 2 commits into
microsoft:mainfrom
Jainil-Gosalia:fix/fail-open-gaps-3520

Conversation

@Jainil-Gosalia

@Jainil-Gosalia Jainil Gosalia (Jainil-Gosalia) commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3520

Two fail-open security gaps where the Python reference was laxer than the sibling SDK ports:

1. Geography default fail-open (\data_classification.py)
Absent geography (empty string) no longer bypasses
equired_geography. Changed from \policy.required_geography and data_label.geography and ...\ to \policy.required_geography is not None and data_label.geography != ....

2. Empty \�ll_labels\ matches everything (\context_aggregation.py)
\AggregationRule.post_init\ raises \ValueError\ when \�ll_labels\ is empty, preventing a rule from matching every envelope and suppressing the escalation backstop.

The restriction-gating gap from #3520 (the \decide_next\ gate reading pre-existing \�nv.restrictions\ instead of the aggregation-effective set) is covered by #3523 and is intentionally not included here to avoid overlapping changes.

Both fixes ship with regression tests that fail without the change, plus a security audit doc (\docs/security/audits/2026-07-31-fail-open-closure-python-reference.md) to clear the Security Audit Required gate.

Copilot AI review requested due to automatic review settings July 30, 2026 10:46
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions github-actions Bot added the tests label Jul 30, 2026
@github-actions

Copy link
Copy Markdown

Welcome to the Agent Governance Toolkit! Thanks for your first pull request.
Please ensure tests pass, code follows style (ruff check), and you have signed the CLA.
See our Contributing Guide.

@github-actions

Copy link
Copy Markdown
🤖 AI Agent: docs-sync-checker — Docs Sync

AI-generated review output. Treat it as untrusted analysis and verify before acting.

Docs Sync

  • decide_next() in context_accumulation.py -- missing docstring
  • README.md -- no updates found for the described changes
  • CHANGELOG -- missing entry for behavioral changes

@github-actions

Copy link
Copy Markdown
🤖 AI Agent: security-scanner — View details

AI-generated review output. Treat it as untrusted analysis and verify before acting.

No security issues found.

@github-actions

Copy link
Copy Markdown
🤖 AI Agent: contributor-guide — View details

AI-generated review output. Treat it as untrusted analysis and verify before acting.

Welcome, and thank you for contributing! Great job addressing multiple security gaps and including thorough regression tests.

Before merging:

  1. Ensure all new tests pass in CI and cover edge cases for the updated logic.
  2. Confirm that the ValueError handling aligns with project error conventions.

For guidance, please review CONTRIBUTING.md.

@github-actions github-actions Bot added the size/M Medium PR (< 200 lines) label Jul 30, 2026
@github-actions

Copy link
Copy Markdown
🤖 AI Agent: test-generator — `agent-os/src/agent_os/policies/context_accumulation.py`

AI-generated review output. Treat it as untrusted analysis and verify before acting.

agent-os/src/agent_os/policies/context_accumulation.py

  • test_rule_implied_restriction_gates_immediately -- Validates that rule-implied restrictions are checked against the aggregation-effective set, not pre-existing restrictions.

agent-os/src/agent_os/policies/context_aggregation.py

  • test_empty_all_labels_rejected -- Ensures AggregationRule raises a ValueError when all_labels is empty.

agent-os/src/agent_os/policies/data_classification.py

  • test_missing_geography_denied_when_required -- Confirms that missing geography in DataLabel results in denial when required_geography is specified in the policy.

Test coverage looks good. No additional gaps identified.

@github-actions

Copy link
Copy Markdown

PR Review Summary

Check Status Details
🔍 Code Review ⚠️ Missing No current-run comment
🛡️ Security Scan ⚠️ Missing No current-run comment
🔄 Breaking Changes ⚠️ Missing No current-run comment
📝 Docs Sync ⚠️ Missing No current-run comment
🧪 Test Coverage ⚠️ Missing No current-run comment

Verdict: ⚠️ AI review incomplete; ready for human review

AI review comments are untrusted advisory output. The summary reports workflow-generated completion status only, not model-authored pass/fail claims.

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.

Pull request overview

TL;DR: 0 blockers, 0 warnings. No issues found. Clean change.

Changes:

  • Tightened ABAC geography enforcement to deny when a geography is required but missing/mismatched.
  • Fixed context-action gating to consult aggregation-effective restrictions (including rule-implied restrictions) immediately.
  • Prevented fail-open aggregation rules by rejecting empty all_labels, with regression tests covering all three cases.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
agent-governance-python/agent-os/src/agent_os/policies/data_classification.py Fail-closed geography requirement when a required geography is configured.
agent-governance-python/agent-os/src/agent_os/policies/context_accumulation.py Gate actions based on aggregation-effective restrictions and emit obligations from that same set.
agent-governance-python/agent-os/src/agent_os/policies/context_aggregation.py Reject empty all_labels in AggregationRule to avoid match-all behavior defeating the backstop.
agent-governance-python/agent-os/tests/test_data_classification.py Regression test for missing geography denial when geography is required.
agent-governance-python/agent-os/tests/policies/test_context_accumulation.py Regression test ensuring rule-implied restrictions gate immediately.
agent-governance-python/agent-os/tests/policies/test_context_aggregation.py Regression test ensuring empty all_labels is rejected.

@Jainil-Gosalia

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@liamcrumm

Copy link
Copy Markdown
Contributor

The Security Audit Required gate is failing because this touches agent_os/policies/, which scripts/ci/security-audit-required.sh treats as a capability path.

To clear it, add docs/security/audits/YYYY-MM-DD-<short-description>.md covering what changed and why, threat model impact, and test coverage. The format is in docs/security/audits/README.md, and 2026-06-25-falsy-default-thresholds.md is a close analog for a fail-open fix.

@liamcrumm

Copy link
Copy Markdown
Contributor

#3523 fixes the same decide_next restriction-set bug as gap #2 here, and also handles the case where floor_triggered fires with an empty agg.restrictions, which currently yields a CONSTRAIN carrying no obligations.

Could you drop gap #2 and keep gaps #1 (geography default) and #3 (empty all_labels)? Those are unique to this PR. That leaves the two changes non-overlapping.

Separately, the Security Audit Required gate needs a docs/security/audits/ entry, as noted above.

- Geography default fail-open: require explicit geography match when
  policy.required_geography is set; absent geography no longer bypasses.
- Empty all_labels rejected: AggregationRule.__post_init__ raises
  ValueError when all_labels is empty, preventing silent backstop defeat.

The restriction-gating gap (decide_next reading env.restrictions) is
covered by microsoft#3523 and intentionally left out of this PR.

Each fix ships with a regression test that would fail without the change,
plus a security audit doc under docs/security/audits/.

Signed-off-by: Jainil Gosalia <jainil.gosalia@gmail.com>
Copilot AI review requested due to automatic review settings July 31, 2026 09:12
@github-actions github-actions Bot added documentation Improvements or additions to documentation security Security-related issues labels Jul 31, 2026

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 1, 2026 02:46
@MohammadHaroonAbuomar
MohammadHaroonAbuomar enabled auto-merge (squash) August 1, 2026 02:46

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.

Review details

  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@imran-siddique

Copy link
Copy Markdown
Collaborator

Status check: this is now approved with every check green, including the Security Audit gate that was blocking it on July 30. It is the only PR in the open queue in that state, so it just needs someone with merge rights to take it. MohammadHaroonAbuomar liamcrumm

@MohammadHaroonAbuomar
MohammadHaroonAbuomar merged commit 628b274 into microsoft:main Aug 4, 2026
124 of 126 checks passed
liamcrumm pushed a commit that referenced this pull request Aug 12, 2026
)

The 2026-07-31 fail-open closure audit doc merged in #3524 without a
frontmatter block, but the strict frontmatter gate added in #3352 scans
the whole tree (--root .). main therefore fails its own gate, and every
open PR rebased onto main inherits the failure.

Add the title/last_reviewed/owner block matching the sibling audit docs
so `check_frontmatter.py --root . --strict` reports 0 findings.

Signed-off-by: AlgoVoi <chopmob@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation security Security-related issues size/M Medium PR (< 200 lines) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

accumulated-context Python reference: two fail-open gaps the SDK ports have fixed (geography default; env-vs-aggregation restriction gating)

5 participants