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
2 changes: 1 addition & 1 deletion crates/splash-linux-seccomp/src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn validate_filter(bytes: &[u8]) -> Result<ValidatedFilter, SeccompInstallEr
}

let mut instructions = Vec::with_capacity(instruction_count);
for instruction in bytes.chunks_exact(FILTER_INSTRUCTION_BYTES) {
for instruction in bytes.as_chunks::<FILTER_INSTRUCTION_BYTES>().0 {
instructions.push(ptrace::sock_filter {
code: u16::from_ne_bytes([instruction[0], instruction[1]]),
jt: instruction[2],
Expand Down
57 changes: 35 additions & 22 deletions crates/splash-media-host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,14 @@ fn run() -> Result<bool, String> {
// turned into line-numbered feedback — the "check" half of generate→check→fix.
// See docs/authoring-for-llms.md for the rules this enforces.
if !preflight(&draft_src)? {
println!(
"\nGenerated source failed the syntax gate; nothing was planned or executed."
);
println!("\nGenerated source failed the syntax gate; nothing was planned or executed.");
println!("Feed the diagnostics above back to the model, regenerate, and re-run.");
return Ok(false);
}

// (2b) The untrusted plan is data until the host decides to run it.
let draft = WorkflowDraft::from_json(&draft_src).map_err(|error| {
format!("draft rejected as data (never executed): {error}")
})?;
let draft = WorkflowDraft::from_json(&draft_src)
.map_err(|error| format!("draft rejected as data (never executed): {error}"))?;
let input = WorkflowData::from_input_json(&input_src).map_err(|error| error.to_string())?;

// (1) The host's own reviewed capability catalog.
Expand Down Expand Up @@ -190,12 +187,14 @@ fn build_runtime(dir: PathBuf) -> Result<MobileWorkflowRuntime, String> {
// A data-script that enriches a whole chart parses one JSON payload per
// row; the default 200k instruction budget is spent after ~6 rows, so raise
// it for chart-sized loops.
let mut limits = ExecutionLimits::default();
limits.instruction_limit = 8_000_000;
// The default script deadline assumes no I/O; a chart of sequential network
// calls needs a wall-clock budget that covers real request latency.
limits.soft_timeout = std::time::Duration::from_secs(90);
limits.hard_timeout = std::time::Duration::from_secs(120);
let limits = ExecutionLimits {
instruction_limit: 8_000_000,
// The default script deadline assumes no I/O; a chart of sequential
// network calls needs a wall-clock budget that covers real latency.
soft_timeout: std::time::Duration::from_secs(90),
hard_timeout: std::time::Duration::from_secs(120),
..ExecutionLimits::default()
};
let mut builder =
MobileWorkflowBuilder::with_limits(limits, splash_capabilities::DEFAULT_MAX_PENDING_TOOLS)
.map_err(|error| error.to_string())?;
Expand Down Expand Up @@ -237,8 +236,12 @@ fn build_runtime(dir: PathBuf) -> Result<MobileWorkflowRuntime, String> {
// the movie logic lives in the card's data-script, not in Rust.
let mut imdb = HttpOriginCatalog::default();
imdb.insert(
HttpOrigin::https("imdb", HttpEndpointMethod::Get, "https://v3.sg.media-imdb.com")
.map_err(|error| error.to_string())?,
HttpOrigin::https(
"imdb",
HttpEndpointMethod::Get,
"https://v3.sg.media-imdb.com",
)
.map_err(|error| error.to_string())?,
)
.map_err(|error| error.to_string())?;
let mut imdb_policy = ToolPolicy::json("net.imdb");
Expand Down Expand Up @@ -326,7 +329,8 @@ fn image_generate(
.map_err(|_| ToolError::Denied("OPENAI_API_KEY not set for image.generate".to_owned()))?;

std::fs::create_dir_all(dir).map_err(|error| ToolError::Failed(format!("mkdir: {error}")))?;
let body = json!({"model": "gpt-image-2", "prompt": prompt, "size": size, "quality": quality, "n": 1});
let body =
json!({"model": "gpt-image-2", "prompt": prompt, "size": size, "quality": quality, "n": 1});
let req_path = dir.join("request.json");
let resp_path = dir.join("response.json");
std::fs::write(&req_path, body.to_string())
Expand Down Expand Up @@ -359,7 +363,9 @@ fn image_generate(
let parsed: Value = serde_json::from_str(&text)
.map_err(|error| ToolError::Failed(format!("parse response: {error}")))?;
let b64 = parsed["data"][0]["b64_json"].as_str().ok_or_else(|| {
let api = parsed["error"]["message"].as_str().unwrap_or("no b64_json in response");
let api = parsed["error"]["message"]
.as_str()
.unwrap_or("no b64_json in response");
ToolError::Failed(format!("image API: {api}"))
})?;
let png = b64_decode(b64).ok_or_else(|| ToolError::Failed("bad base64".to_owned()))?;
Expand All @@ -381,9 +387,9 @@ fn media_transcode(
seq: &Seq,
dir: &Path,
) -> Result<Value, ToolError> {
let src = request.input["src"]
.as_str()
.ok_or_else(|| ToolError::Denied("media.transcode requires a string src handle".to_owned()))?;
let src = request.input["src"].as_str().ok_or_else(|| {
ToolError::Denied("media.transcode requires a string src handle".to_owned())
})?;
let vf = request.input["vf"]
.as_str()
.ok_or_else(|| ToolError::Denied("media.transcode requires a string vf".to_owned()))?;
Expand Down Expand Up @@ -442,10 +448,14 @@ fn build_policies(
) -> Result<Vec<WorkflowStepCapabilityPolicy>, String> {
for (step, tool, _) in grants {
if !plan.steps().iter().any(|candidate| &candidate.id == step) {
return Err(format!("grant references a step absent from the draft: {step}"));
return Err(format!(
"grant references a step absent from the draft: {step}"
));
}
if !catalog.iter().any(|descriptor| &descriptor.name == tool) {
return Err(format!("grant names a capability absent from the catalog: {tool}"));
return Err(format!(
"grant names a capability absent from the catalog: {tool}"
));
}
}
Ok(plan
Expand All @@ -464,7 +474,10 @@ fn build_policies(
}

fn capability_names(catalog: &[ToolDescriptor]) -> Vec<String> {
catalog.iter().map(|descriptor| descriptor.name.clone()).collect()
catalog
.iter()
.map(|descriptor| descriptor.name.clone())
.collect()
}

fn parse_grant(value: &str) -> Result<(String, String, usize), String> {
Expand Down
2 changes: 1 addition & 1 deletion crates/splash-sandbox/src/bin/splash-landlock-runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ mod linux {
}

let mut bytes = Vec::with_capacity(value.len() / 2);
for pair in value.as_bytes().chunks_exact(2) {
for pair in value.as_bytes().as_chunks::<2>().0 {
let Some(high) = decode_lower_hex(pair[0]) else {
return Err(RunnerError::InvalidStagedSeccompFilterEncoding);
};
Expand Down
2 changes: 1 addition & 1 deletion crates/splash-storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ fn decode_tag(value: &str) -> Option<[u8; AUTHENTICATED_RECORD_TAG_BYTES]> {
return None;
}
let mut decoded = [0; AUTHENTICATED_RECORD_TAG_BYTES];
for (index, pair) in value.as_bytes().chunks_exact(2).enumerate() {
for (index, pair) in value.as_bytes().as_chunks::<2>().0.iter().enumerate() {
decoded[index] = (hex_value(pair[0])? << 4) | hex_value(pair[1])?;
}
Some(decoded)
Expand Down
6 changes: 5 additions & 1 deletion crates/splash-ui-l0/examples/l0validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ fn main() {
let path = std::env::args().nth(1).expect("usage: l0validate <path>");
let src = std::fs::read_to_string(&path).unwrap_or_default();
let report = realize(&src, &serde_json::json!({}), RealizeLimits::default());
let msgs: Vec<String> = report.diagnostics.iter().map(|d| d.message.clone()).collect();
let msgs: Vec<String> = report
.diagnostics
.iter()
.map(|d| d.message.clone())
.collect();
let ok = report.diagnostics.is_empty() && report.root.is_some();
println!(
"{}",
Expand Down
Loading
Loading