Skip to content

fix(agent): annotated Blueprint Cedar rules fail task start - #1005

Merged
krokoko merged 6 commits into
mainfrom
fix/995-blueprint-annotated-cedar-rules
Nov 21, 2026
Merged

krokoko merged 6 commits into
mainfrom
fix/995-blueprint-annotated-cedar-rules

Conversation

@isadeks

@isadeks isadeks commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #995.

The agent used to reject annotated rules from a Blueprint at task startup. That meant copying the example from the Cedar policy guide could stop every task on a repository.

The runner now reads each rule’s tier from Cedar’s parsed annotations. Hard rules deny the action, soft rules ask for approval, and a legacy rule keeps its generated legacy_extra_<n> ID. The same handling applies to registry rules loaded at task startup. An entry that mixes tiers or supplies a rule ID without a tier fails at startup and identifies the invalid entry.

bgagent policies list uses Cedar’s parser for inline rules too. It shows the built-ins and inline Blueprint rules. The guide explains where to find the registry modules that the agent also enforces.

The guide now uses the Blueprint construct’s cedarPolicies array. Its production-write example covers relative and absolute paths. Its approval example explains how the task’s window and the rule’s 900-second cap interact. It also identifies the proposed disable and maxPreApprovalScope settings as unimplemented.

Tests

  • Runner bootstrap tests cover spaces in annotations, a comment mentioning another tier, legacy IDs, and invalid entries.
  • Tests load the rules directly from the guide. They exercise Write and Edit on the same production file through both path forms, allow similarly named directories, and check approval windows of 300, 600, and 900 seconds.
  • Policy listing tests cover formatted annotations, legacy rule numbering, and invalid entries.

@isadeks
isadeks requested review from a team and backgroundagents as code owners November 5, 2026 14:30
Every repo cedar_policies entry went to PolicyEngine's legacy
extra_policies path, which rejects @tier/@rule_id. Following the Cedar
policy guide (annotated hard/soft rules) therefore failed every task on
that repo at start; blueprint_soft_policies/blueprint_hard_policies were
only ever used in unit tests. Registry Cedar modules share the field.

- split_blueprint_policies routes @tier("hard") entries to the hard input,
  @tier("soft") to the soft input, and leaves unannotated entries on the
  legacy path. An entry declaring both tiers, or @rule_id without a tier,
  fails with a clear error instead of being guessed.
- Tests: the guide's verbatim example rules build an engine through the
  runner's bootstrap and enforce as documented (hard deny, soft gate with
  min-wins timeout); fails with the original ValueError on the old wiring.
- CEDAR_POLICY_GUIDE described a blueprint.yaml {hard, soft, disable}
  format and maxPreApprovalScope that do not exist; it now documents the
  Blueprint construct's array form and says which options are not
  implemented yet.
@isadeks
isadeks force-pushed the fix/995-blueprint-annotated-cedar-rules branch from 6b83896 to 544c64e Compare November 5, 2026 14:37

@krokoko krokoko 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.

I’d hold this for two fixes. A valid Cedar rule can still stop every task on a repository, and the production-write example covers only one of the two path forms the agent receives. Both need a regression test. The full build passed locally with this branch merged with main.

Comment thread agent/src/runner.py Resolved
Comment thread docs/guides/CEDAR_POLICY_GUIDE.md Resolved
Comment thread docs/guides/CEDAR_POLICY_GUIDE.md Resolved
Comment thread docs/guides/CEDAR_POLICY_GUIDE.md Resolved
@krokoko
krokoko dismissed their stale review November 20, 2026 23:11

7e78a50 addresses all four findings. I pushed the fixes and verified the full build. The updated code is ready for an independent review.

@krokoko
krokoko self-requested a review November 20, 2026 23:26
@krokoko
krokoko enabled auto-merge November 20, 2026 23:27
@krokoko
krokoko added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 3a76b67 Nov 21, 2026
10 of 11 checks passed
@krokoko
krokoko deleted the fix/995-blueprint-annotated-cedar-rules branch November 21, 2026 00:21
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.

fix(agent): annotated Blueprint Cedar rules fail task start

3 participants