P2 BLOCKING exit green: approval interception chain end-to-end

- tc-tools: Effect declarations -> §15 GatedCategory mapping, deny-by-default
  external reach, taint invariant property-tested (tainted external effects
  are NEVER auto-allowed)
- tc-safety: pending approvals with exact payload+preview, CAS decide with
  audit + single-use grant in one tx, checkpoint suspend/load, exclusive
  resume claim, expiry sweep, decided-unresumed work queue (migration 0004
  adds the outbox the gated email.send tool writes)
- tc-runtime: resumable LoopState checkpointed to agent_runs; gated tool ->
  approval row -> approval_required/run_suspended events -> suspend; resume
  consumes the grant BEFORE executing (spent grant = no execution), rejection
  feeds a structured refusal in-band; durable resume sweeper; continuous
  journal seq across suspension (tested). ContentPart::Text became a struct
  variant — internally-tagged newtype primitives don't serialize
- tc-api: GET/decide approvals endpoints (409 double-decide, tenant
  isolation), decision triggers in-process resume; full chain proven over
  HTTP incl. gateway resumeFrom continuation
- frontend: approval_required/run_suspended events, suspended reply state,
  inline ApprovalCard (§10: summary, category, exact payload preview,
  approve/reject -> decide + stream re-attach), /approvals queue page, nav
- E2E (14 journeys, workers:1 to serialize the shared backend): gated email
  blocks with disabled composer -> approve -> continuation + ✓ step + reload
  replay; reject -> ✗ step, nothing executed; queue page decides pending

106 Rust + 61 frontend tests + 14 Playwright journeys green.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
Omar Sobh
2026-06-10 04:58:47 -05:00
co-authored by Claude Fable 5
parent 9f9f507c15
commit de38449b41
62 changed files with 3576 additions and 203 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ impl AnthropicProvider {
.parts
.iter()
.map(|part| match part {
ContentPart::Text(text) => json!({"type": "text", "text": text}),
ContentPart::Text { text } => json!({"type": "text", "text": text}),
ContentPart::ToolUse { id, name, input } => {
json!({"type": "tool_use", "id": id, "name": name, "input": input})
}
+1 -1
View File
@@ -35,7 +35,7 @@ impl OpenAiCompatProvider {
let mut tool_calls: Vec<Value> = Vec::new();
for part in &message.parts {
match part {
ContentPart::Text(t) => text.push_str(t),
ContentPart::Text { text: t } => text.push_str(t),
ContentPart::ToolUse { id, name, input } => tool_calls.push(json!({
"id": id,
"type": "function",
+13 -1
View File
@@ -15,7 +15,12 @@ pub enum ChatRole {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ContentPart {
Text(String),
// Struct variant (not newtype): internally-tagged enums cannot
// serialize newtype primitives, and this type round-trips through
// `agent_runs.checkpoint`.
Text {
text: String,
},
ToolUse {
id: String,
name: String,
@@ -27,6 +32,13 @@ pub enum ContentPart {
},
}
impl ContentPart {
/// Convenience constructor for plain text parts.
pub fn text(value: impl Into<String>) -> ContentPart {
ContentPart::Text { text: value.into() }
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ChatMessage {
pub role: ChatRole,
+2 -2
View File
@@ -92,7 +92,7 @@ impl LlmProvider for ScriptedProvider {
.iter()
.flat_map(|m| m.parts.iter())
.filter_map(|p| match p {
ContentPart::Text(t) => Some(t.as_str()),
ContentPart::Text { text } => Some(text.as_str()),
_ => None,
})
.collect::<Vec<_>>()
@@ -149,7 +149,7 @@ impl LlmProvider for ScriptedProvider {
.rev()
.flat_map(|m| m.parts.iter())
.find_map(|p| match p {
ContentPart::Text(t) => Some(t.clone()),
ContentPart::Text { text } => Some(text.clone()),
_ => None,
})
.unwrap_or_default();