Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
57 lines
2.5 KiB
Rust
57 lines
2.5 KiB
Rust
//! Request-scoped approval decisions. A review only satisfies the review gate; the host enforces permissions.
|
|
|
|
use std::sync::Arc;
|
|
|
|
use akode_protocol::ThreadId;
|
|
|
|
use crate::ExtensionData;
|
|
|
|
/// Thread-local state installed only after Guardian V2's async classifier initializes.
|
|
pub struct GuardianV2Enabled;
|
|
|
|
/// Guardian's choice for one approval. Synchronous results pass through unchanged.
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
pub enum ApprovalDecision {
|
|
/// Existing async evidence allows this action without synchronous review.
|
|
Allow,
|
|
Reviewed(akode_protocol::protocol::ReviewDecision),
|
|
AskUser,
|
|
}
|
|
|
|
/// Runs an extension-owned review already bound to an action by the host.
|
|
/// `None` requests the host user flow when automatic review exhausts its input budget
|
|
/// and host policy permits it. An optional async approval resolves only when current
|
|
/// cached evidence authorizes the action; it races the complete synchronous review.
|
|
pub trait SynchronousApprovalReviewer: Send + Sync {
|
|
fn review<'a>(
|
|
&'a self,
|
|
reason: akode_protocol::approvals::GuardianReviewReason,
|
|
async_approval: Option<crate::ExtensionFuture<'a, ()>>,
|
|
) -> crate::ExtensionFuture<'a, Option<akode_protocol::protocol::ReviewDecision>>;
|
|
}
|
|
|
|
/// Inputs to Guardian's policy choice. Conversation and scores stay thread-owned.
|
|
pub struct ApprovalDecisionInput<'a> {
|
|
/// Final serving value for this action. The host still requires fresh review when stale.
|
|
pub serving_assessment: Option<bool>,
|
|
pub approval_id: &'a str,
|
|
/// Host tool invocation being approved, absent for approvals without a tool call.
|
|
pub tool_call_id: Option<&'a str>,
|
|
/// Host-resolved permission evidence; unavailable evidence cannot authorize cached approval.
|
|
pub permissions: Option<&'a akode_guardian_context::PermissionContext>,
|
|
pub action: &'a serde_json::Value,
|
|
pub thread_id: ThreadId,
|
|
pub thread_store: &'a ExtensionData,
|
|
/// Captured configuration and evidence owned by the requesting turn.
|
|
pub turn_store: &'a ExtensionData,
|
|
pub category: akode_protocol::openai_models::GuardianScope,
|
|
pub approval_policy: akode_protocol::protocol::AskForApproval,
|
|
pub approvals_reviewer: akode_protocol::config_types::ApprovalsReviewer,
|
|
pub require_guardian: bool,
|
|
/// Existing retry and sensitive-action rules require a synchronous review.
|
|
pub require_fresh_review: bool,
|
|
pub full_access: bool,
|
|
pub metrics: Option<Arc<dyn crate::ExtensionMetrics>>,
|
|
pub synchronous_reviewer: &'a dyn SynchronousApprovalReviewer,
|
|
}
|