Skip to content

feat(policy): add log-only mode to the policy engine - #617

Merged
akujane merged 3 commits into
strands-agents:mainfrom
akujane:feat/log-only-engine
Nov 23, 2026
Merged

akujane merged 3 commits into
strands-agents:mainfrom
akujane:feat/log-only-engine

Conversation

@akujane

@akujane akujane commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Design 0005 adds a box-wide log-only mode. This PR is the policy-engine half; the Box wiring (the box.toml setting, the stored record, the decision-record fields, and the startup notice) follows in a second PR built on this one.

PolicyEngine::log_only() puts an engine in log-only mode for its whole life. In that mode, a denial from a forbid or from no permit matching comes back as Decision::Allow with would_deny set to the denial's reason, keeping the denial's rule and attribution. It flips only for a request that entered history, so the caller records the action's real outcome and later temporal rules see what actually ran. The flip happens in the authority, before a per-tool MCP call's pending response would be dropped, so a let-through tool call still records its ::response.

Will be handled in a follow up PR, not here

This PR wires nothing into the binary, so no Box code turns the mode on yet. There will be follow-up Box PR, stacked on this branch.

Related Issues

Design: team/designs/0005-log-only-mode.md (#310).

Type of Change

New feature

Testing

  • Unit tests
  • Linux and MacOs run
  • I ran the relevant suites (just check, or cargo test --workspace --all-features)
  • If I touched Rust, I ran cargo fmt --all and cargo clippy --workspace --all-targets --all-features -- -D warnings

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment thread crates/policy/src/policy/authority.rs Resolved
@github-actions

Copy link
Copy Markdown

Assessment: Approve

Re-reviewed at 5c5dfe5. The blocking fail-open I reported earlier (log-only mode with no policy installed) is fixed and pinned by two tests. I left one non-blocking suggestion: the new flag is read and written outside the live lock, so a reload to no policy has a narrow window where one denial can still flip.

Since the last review
  • Step A question answered: The description says the Box PR qualifies the root premise "A policy permit decides whether it runs" for log-only mode. "Absent policy is default-deny" now holds in the engine.
  • would_deny as a field: You decided this with the maintainer, and the three Box sites are named for the stacked PR. Settled for this PR.
  • Checked and held (the fix):
    • An empty source set at open, open_staged and the test constructors holds every denial.
    • A reload to empty stops letting denials through, and a reload from empty to a policy starts doing so. Both directions are covered.
    • The flag change only ever narrows the flip, so it can't make enforce mode allow anything.
    • Box maps a missing policy file to an empty set, so the check covers the case Box actually produces.
  • Verified: tests/log_only_mode.rs 9/9 and the log-only unit tests pass on 5c5dfe5.

Thanks for the quick fix and the tests that pin it.

@github-actions

Copy link
Copy Markdown

Assessment: Approve

Re-reviewed at 0b58f27. The only change since 5c5dfe5 moves the installed-policy flag under the live lock, which resolves my last open suggestion. I found nothing new.

Checked and held
  • The flag is written in reload before drop(live) and set inside each LiveAuthority constructor, so no atomic remains.
  • decide_as_authored and refine_tool_call read the flag under the same guard as the decision.
  • The flip runs only after live.engine.decide. The degraded-tool, pending-tool and poisoned-lock paths return before it.
  • Verified: tests/log_only_mode.rs passes 9/9, and cargo test -p strands-box-policy --lib passes 249/249 (4 ignored).

@strands-agents strands-agents deleted a comment from github-actions Bot Nov 23, 2026
@strands-agents strands-agents deleted a comment from github-actions Bot Nov 23, 2026
@strands-agents strands-agents deleted a comment from github-actions Bot Nov 23, 2026
@strands-agents strands-agents deleted a comment from github-actions Bot Nov 23, 2026
@strands-agents strands-agents deleted a comment from github-actions Bot Nov 23, 2026
@akujane
akujane merged commit 04f6c5c into strands-agents:main Nov 23, 2026
31 checks passed
@akujane akujane mentioned this pull request Nov 23, 2026
8 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants