Skip to content

id-caps: reconcile the two #7916 policy points into mcp_policy - #13220

Merged
dezren39 merged 1 commit into
mainfrom
lane-ry-13202
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
lane-ry-13202

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Reconciles the duplicate spike step-4 policy points (#7916 landed twice) to one, per #13202.

Survivor: id_caps::mcp_policy::PolicySession — the bridge-integrated shape spike step 5 (#7917) drives. Deleted: agent_policy.rs (standalone PolicyPoint) and its acceptance test file.

Ported from the deleted module so the survivor carries the union:

  • Per-tool rate limits (§6.3) — RoleGrant.rate_limits, sliding admitted-call window per tool, RefusedRateLimit audit outcome, RefusalKind::RateLimited. act() now takes host time (now, unix seconds) to drive the windows and stamp the park event.
  • Structured park event (§6.2) — PolicyRefusal.park_event is now a serializable ParkEvent (kind / reason / message / agent / world / at / quota spent / budget) instead of the bare message string.
  • Owner-summary refusal breakdown — OwnerSummary.refusals_by_code, keyed by the new AuditOutcome::refusal_code().

Not ported, deliberately: delegation expiry (not in #13202's union; RoleGrant carries no expiry) and the join-granted opening audit event (here the bridge session's world.join call is the audited join).

New unit tests cover the ported behaviors: rate limit refuses past the cap, is audited, charges nothing, and the window slides open again; park-event fields on quota refusal; summary breakdown by code.

Verification: cargo test -p id-caps in the pkgs/id dev shell on the laptop (results in the closing comment on #13202). The remote dispatch route cannot run nix develop today (#13159 family), so the laptop run is the verifying route; main-branch CI is the remaining gate per repo policy.

Closes #13202.

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-23T11:10:58Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": null,
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": null,
    "auth_subject": "archer",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Prove it works
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Spike step 4 landed twice: mcp_policy (PR #13192, bridge-integrated
PolicySession) and agent_policy (PR #13182, standalone PolicyPoint).
Keep mcp_policy as the one policy point — it is the shape spike
step 5 drives through the bridge — and port the standalone point's
remaining pieces into it:

- per-tool rate limits (design 6.3): RoleGrant.rate_limits, a
  sliding admitted-call window per tool, RefusedRateLimit audit
  outcome and RefusalKind::RateLimited; act() now takes the host
  time that drives the windows
- the structured park event: PolicyRefusal.park_event is now a
  serializable ParkEvent (kind/reason/message/agent/world/at/spend/
  budget) instead of the bare message string
- owner summary refusals broken down by stable refusal code
  (AuditOutcome::refusal_code)

Delete agent_policy.rs and its acceptance test file; the ported
behaviors are covered by new mcp_policy unit tests (rate-limit
window slide, park-event fields, summary breakdown). Deliberately
not ported: delegation expiry (the #13202 union does not list it
and RoleGrant carries no expiry) and the join-granted opening
event (the bridge session's world.join call is the audited join
here).
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8a3682ee-00f4-462f-9d40-83d569ae4f87
Commits

Reviewing files that changed from the base of the PR and between 15b2ac8 and 576950c.

Files selected for processing: 4

  • pkgs/id/crates/id-caps/src/agent_policy.rs
  • pkgs/id/crates/id-caps/src/lib.rs
  • pkgs/id/crates/id-caps/src/mcp_policy.rs
  • pkgs/id/crates/id-caps/tests/agent_policy_point.rs
  • 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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T11:14:39.727204Z 576950c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 576950cd81

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1362 to +1363
#[test]
fn rate_limit_refuses_beyond_the_role_limit_and_the_window_slides() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add invariant-driven coverage for the ported rate limiter

The ported stateful rate limiter is covered only by a fixed two-call/60-second example, despite the repository testing doctrine requiring property tests for invariants and model-based tests where a specification exists. Add generated action/time sequences checked against a trailing-window reference model, covering expiration boundaries, independent tools, and the invariant that refused calls neither execute nor spend quota; name the model as the test oracle.

AGENTS.md reference: AGENTS.md:L37-L39

Useful? React with 👍 / 👎.

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.

dedup(id-caps): two policy-point implementations landed for #7916 (mcp_policy + agent_policy) — reconcile to one before step 5

1 participant