Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .repository-projection.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"projection": "deixic-code",
"projectionSchemaVersion": 1,
"sourceRepository": "dx-corp/mono",
"sourceSha": "fac55f7217fbc6e14c155ecfc00aed5c8c31adca",
"sourceSha": "e93942ba70f7585b80a55a24065ebbd31e57708d",
"destinationRepository": "dx-corp/code",
"priorProjectedBase": "e9728f9fd83065904e209c56238a89291741bd74",
"priorProjectedBase": "a6d447c5960e7b738a3c3a27fa564f8dcae7f448",
"definitionDigest": "82936441c776e3e8edb5d215a75007ec9714a233f489d460075d79d5ef5ba32f",
"toolDigest": "c244d99199a7ae3eb8ff644a99462163c23b0bb6a83ef50af01efbdca0b81d04",
"contentDigest": "40c32f0bd494617b1e7297f7daf817ddd6861452f132690578f73452179f2900",
"contentDigest": "13746ab7cd6f508ce691afd179ce7d3f11b2bb8d901b5db0ba91153d55c25366",
"publicationEligible": true
}
175 changes: 175 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/dex-host-rs/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ mod tests {
attachments: Vec::new(),
client_tools: Vec::new(),
authorized_tools: Vec::new(),
approval_mode: dex_loop::ApprovalMode::Interactive,
approval_mode: dex_loop::ApprovalMode::Headless,
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/dex-host-rs/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ mod tests {
attachments: Vec::new(),
client_tools: Vec::new(),
authorized_tools: Vec::new(),
approval_mode: dex_loop::ApprovalMode::Interactive,
approval_mode: dex_loop::ApprovalMode::Headless,
},
)],
);
Expand Down
32 changes: 13 additions & 19 deletions packages/dex-host-rs/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//!
//! Two tools, standing in for `local-host-rs`'s much larger registry
//! (`packages/local-host-rs/src/tools/`): one read (`fs.read_file`) and one
//! mutation that needs approval (`fs.write_file`). A real cutover ports the
//! mutation in the `Approval` governance class (`fs.write_file`), which the
//! headless host allows without a prompt. A real cutover ports the
//! rest of that registry the same way — each tool becomes a `ToolSpec` plus
//! a `run` arm, and `NativeHost::requires_approval`'s per-call decision
//! becomes this module's `policy` — not a rewrite of the tools themselves.
Expand All @@ -11,8 +12,8 @@ use std::path::{Path, PathBuf};
use std::sync::Arc;

use dex_loop::{
ApprovalId, CancellationToken, Context, ExecutorKind, GovernanceClass, PrincipalId,
ProposedCall, ThreadId, ToolName, ToolResult, ToolSpec, Tools, Verdict,
CancellationToken, Context, ExecutorKind, GovernanceClass, PrincipalId, ProposedCall, ThreadId,
ToolName, ToolResult, ToolSpec, Tools, Verdict,
};
use serde_json::Value;

Expand Down Expand Up @@ -134,13 +135,6 @@ async fn write_file(root: &Path, args: &Value) -> ToolResult {
}
}

fn approval_summary(call: &ProposedCall) -> String {
match call.args.get("path").and_then(Value::as_str) {
Some(path) => format!("Write to {path}"),
None => "Write to a workspace file".to_owned(),
}
}

/// The `Tools` port over the workspace filesystem at `root`.
#[derive(Clone)]
pub struct LocalTools {
Expand Down Expand Up @@ -175,13 +169,13 @@ impl Tools for LocalTools {
}

async fn policy(&self, _ctx: &Context, call: &ProposedCall) -> Verdict {
match self.spec(&call.tool).map(|spec| spec.governance) {
Some(GovernanceClass::Approval) => Verdict::NeedsApproval {
approval: ApprovalId::new(format!("approve-{}", call.id)),
summary: approval_summary(call),
},
_ => Verdict::Allow,
}
// Maestro turns are headless: no human approves a tool call, so this
// host never returns `NeedsApproval`. An `Approval`-class tool (the
// mutation `fs.write_file`) is allowed outright; its
// `ToolStarted`/`ToolFinished` pair in the log is the audit record.
// A hard deny would be `Verdict::Deny`; no local tool has one today.
let _ = call;
Verdict::Allow
}

async fn run(
Expand Down Expand Up @@ -275,7 +269,7 @@ mod tests {
}

#[tokio::test]
async fn write_file_requires_approval_and_read_file_does_not() {
async fn every_tool_is_allowed_because_turns_are_headless() {
let tools = LocalTools::new(".");
let read_verdict = tools
.policy(
Expand All @@ -290,7 +284,7 @@ mod tests {
&call(WRITE_FILE, serde_json::json!({"path": "a", "content": "x"})),
)
.await;
assert!(matches!(write_verdict, Verdict::NeedsApproval { .. }));
assert_eq!(write_verdict, Verdict::Allow);
}

/// `Tools::policy` here does not read `ctx`, so an empty rehydrated
Expand Down
Loading
Loading