Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions pkgs/id/crates/id-caps/src/agent_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use std::collections::{BTreeMap, BTreeSet, VecDeque};

use ed25519_dalek::{Signature, Signer as _, SigningKey, Verifier as _, VerifyingKey};
use serde::Serialize;
use serde::{Deserialize, Serialize};
use sha2::{Digest as _, Sha256};

use crate::agent_delegation::{AgentId, JoinGrant};
Expand Down Expand Up @@ -244,7 +244,7 @@ impl Ceiling {
/// program invocations. One shape serves as the session budget, the
/// running spend, and the per-event charge recorded in the audit log
/// (§7).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Quota {
/// Frames requested.
pub frames: u64,
Expand Down Expand Up @@ -804,6 +804,29 @@ impl PolicyPoint {
}
}

/// Owner-side ceiling refresh (v2 agents-as-citizens step 1,
/// #8299 §2.1): replace the ceiling in force for this live
/// session. A lowered ceiling takes effect at the next
/// [`Self::admit`] frame check — not the next join — so a
/// citizen's rights track the current role configuration; the
/// role edit itself is audited by the role registry that issued
/// the change. Nothing here widens: it is the same owner-side
/// act as an out-of-band ceiling edit in v1, now reachable
/// through world configuration.
///
/// # Errors
///
/// Returns [`PolicyRefusal::CeilingWorld`] if the new ceiling
/// does not cover the session's world: a session never runs
/// under a ceiling that does not name its world.
pub fn refresh_ceiling(&mut self, ceiling: Ceiling) -> Result<(), PolicyRefusal> {
if !ceiling.worlds().contains(&self.world) {
return Err(PolicyRefusal::CeilingWorld);
}
self.ceiling = ceiling;
Ok(())
}

/// Whether this action's tool is at its §6.3 rate limit at
/// `now`, counting admitted calls inside the trailing window.
fn rate_limited(&mut self, action: &AgentAction, now: u64) -> bool {
Expand Down
1 change: 1 addition & 0 deletions pkgs/id/crates/id-caps/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub mod library_resolution;
pub mod mcp_bridge;
pub mod mcp_policy;
pub mod portal;
pub mod role_config;
pub mod used_caps;
pub mod world_caps;
pub mod world_limits;
Expand Down
Loading