Skip to content

Commit be56361

Browse files
committed
cli: report sandbox confinement for plugin-routed comparisons
Surface the active sandbox confinement (active_sandbox_status) wherever a plugin helper runs a comparison: archive --unpacker / auto-route prints sandbox=<label> (and a sandbox{label,confined} object in --json), and compare --prediffer appends the confinement to its info line. A degraded run (LINSYNC_SANDBOX_SKIP / no backend) is therefore visible at the point of use, not just via plugin run-diagnostic. Advances Phase 6's 'surface sandbox-policy decisions/degradation'; threading the confinement into the FolderCompareResult/TextCompareResult types themselves remains. Test asserts the archive --unpacker JSON carries sandbox.confined.
1 parent b5472bf commit be56361

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

crates/linsync-cli/src/main.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,9 @@ fn run_text_compare(
474474
}
475475
let chain_ids: Vec<&str> = chain.iter().map(|p| p.manifest.id.as_str()).collect();
476476
eprintln!(
477-
"info: applying prediffer chain before diffing: {}",
478-
chain_ids.join(" -> ")
477+
"info: applying prediffer chain before diffing: {} (sandbox: {})",
478+
chain_ids.join(" -> "),
479+
active_sandbox_status().label
479480
);
480481
compare_text_files_with_prediffer_chain(
481482
left,
@@ -1431,12 +1432,16 @@ fn archive_compare_via_plugin(
14311432
let right_tree = unpack(right_archive, "right")?;
14321433
let result = compare_virtual_trees(&left_tree, &right_tree);
14331434
let summary = &result.summary;
1435+
// The unpacker helper ran under the sandbox; surface its confinement so a
1436+
// degraded run is visible rather than silent.
1437+
let sandbox = active_sandbox_status();
14341438

14351439
if json {
14361440
let body = serde_json::json!({
14371441
"left": { "archive": left_archive, "unpacker": id, "entries": left_tree.len() },
14381442
"right": { "archive": right_archive, "unpacker": id, "entries": right_tree.len() },
14391443
"equal": result.is_equal(),
1444+
"sandbox": { "label": sandbox.label, "confined": sandbox.confined },
14401445
"summary": {
14411446
"compared": summary.compared_count,
14421447
"identical": summary.identical_count,
@@ -1449,7 +1454,8 @@ fn archive_compare_via_plugin(
14491454
println!("{body}");
14501455
} else {
14511456
println!(
1452-
"unpacker={id} compared={} identical={} different={} one_sided={} left_only={} right_only={}",
1457+
"unpacker={id} sandbox={} compared={} identical={} different={} one_sided={} left_only={} right_only={}",
1458+
sandbox.label,
14531459
summary.compared_count,
14541460
summary.identical_count,
14551461
summary.different_count,

crates/linsync-cli/tests/plugin_cli.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,9 @@ fn archive_unpacker_compares_virtual_trees() {
535535
let json: serde_json::Value = serde_json::from_str(&stdout(&diff)).unwrap();
536536
assert_eq!(json["equal"], serde_json::json!(false));
537537
assert_eq!(json["summary"]["different"], serde_json::json!(1));
538+
// The unpacker ran under the sandbox; its confinement is surfaced (here
539+
// unconfined, since the test degrades the sandbox).
540+
assert_eq!(json["sandbox"]["confined"], serde_json::json!(false));
538541

539542
// Unknown plugin id → error exit 2.
540543
let unknown = run_isolated_unsandboxed(&home, &["archive", "--unpacker", "nope", a, b]);

0 commit comments

Comments
 (0)