feat: add coding-agent least-privilege flagship policy and demo - #273
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a least-privilege “coding agent” policy surface to weaver-kernel, plus a deterministic flagship demo and supporting match helpers/tests/docs, as the concrete adoption story for #253.
Changes:
- Introduces
CodingAgentPolicyEngine+enforce_coding_agent_constraints()to bind grant-time scope into signed token constraints and fail closed on execution-time scope substitution. - Adds deterministic glob-based scope matching helpers (
policy_matching.py) with unit tests. - Adds a CI-run, hermetic flagship demo (
examples/coding_agent_least_privilege.py) with a drift-checked receipt and accompanying security documentation.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_policy_matching.py | Adds unit coverage for new glob/scope matching helpers. |
| tests/test_coding_agent.py | Adds unit coverage for the coding-agent policy engine and constraint enforcement helper. |
| src/weaver_kernel/policy_matching.py | Introduces deterministic scope glob matching utilities. |
| src/weaver_kernel/coding_agent.py | Implements the coding-agent least-privilege policy engine and driver-side constraint enforcement helper. |
| Makefile | Runs the new flagship demo as part of the example target. |
| examples/coding_agent_least_privilege.py | Adds a hermetic flagship demo exercising ALLOW/DENY/escalation/scope anti-swap with an ActionTrace receipt. |
| examples/coding_agent_expected.txt | Adds the maintained expected semantic receipt for drift checking. |
| docs/coding-agent-security.md | Documents the coding-agent capability vocabulary, signed scope binding, and non-claims. |
Suppressed comments (5)
tests/test_coding_agent.py:79
- Per AGENTS.md / the review checklist, tests should assert both exception type and message. Add a
match=here so the denial message is covered.
with pytest.raises(PolicyDenied) as exc:
tests/test_coding_agent.py:103
- Per AGENTS.md / the review checklist, tests should assert both exception type and message. Add a
match=here to cover the missing-role error message.
with pytest.raises(PolicyDenied) as exc:
tests/test_coding_agent.py:119
- Per AGENTS.md / the review checklist, tests should assert both exception type and message. Add a
match=here to cover the task-approval denial message.
with pytest.raises(PolicyDenied) as exc:
tests/test_coding_agent.py:131
- Per AGENTS.md / the review checklist, tests should assert both exception type and message. Add a
match=here to cover the missing-role error message.
with pytest.raises(PolicyDenied) as merge_exc:
tests/test_coding_agent.py:146
- Per AGENTS.md / the review checklist, tests should assert both exception type and message. Add a
match=here to cover the missing-role error message for secrets access.
with pytest.raises(PolicyDenied):
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Advances #253 with a real embedded least-privilege boundary and maintained flagship demo.
What this adds
CodingAgentPolicyEnginewith a deliberately small capability vocabulary for repository reads/writes, test commands, networked shell commands, secrets, PR creation, and PR merge.enforce_coding_agent_constraints()for drivers to fail closed if invocation arguments are swapped after a valid grant.That last point is the core security property: a token approved for
src/demo.pycannot later be reused to mutate.github/workflows/release.yml.Flagship proof
python examples/coding_agent_least_privilege.pyis hermetic and makes no real repo/GitHub/network side effects. It demonstrates:kernel.explain()The script drift-checks its semantic output against
examples/coding_agent_expected.txt, andmake cinow executes it.docs/coding-agent-security.mdexplains the three practical authority profiles (review, edit+test, publish-for-review), the driver-side constraint requirement, and explicit non-claims.Scope
This does not pretend to solve arbitrary host sandboxing or prompt injection. The boundary only applies to actions routed through the embedded kernel and to drivers that enforce the signed constraints before the side effect.
This PR intentionally does not auto-close #253 yet; the issue can remain the canonical place for any richer action-envelope/budget/organizational-authority follow-up after this concrete beachhead is validated.
Merge only after the exact final head passes the repository's full CI.