Skip to content

Commit 70f0902

Browse files
mikolalysenkoclaude
andcommitted
Merge fix/gc-report-json-1257 into v5/json-envelope-unify
Takes #1273's LF-normalized contract_doc(); the bun.lockb shared-bundled rollback counts agent failed events (no details.mode) on top of the refused hosted pin. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2 parents 572b4dc + c049dfd commit 70f0902

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

‎crates/socket-patch-cli/src/json_envelope.rs‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,13 +1363,15 @@ mod tests {
13631363
}
13641364

13651365
/// The ```jsonc block under `heading` in CLI_CONTRACT.md.
1366+
/// CLI_CONTRACT.md with LF line endings: a Windows checkout may carry
1367+
/// CRLF, which the `"```jsonc\n"` fence match below would miss.
1368+
fn contract_doc() -> &'static str {
1369+
static DOC: std::sync::OnceLock<String> = std::sync::OnceLock::new();
1370+
DOC.get_or_init(|| include_str!("../CLI_CONTRACT.md").replace("\r\n", "\n"))
1371+
}
1372+
13661373
fn contract_block(heading: &str) -> &'static str {
1367-
// A Windows checkout may carry CRLF line endings.
1368-
let doc: &'static str = Box::leak(
1369-
include_str!("../CLI_CONTRACT.md")
1370-
.replace("\r\n", "\n")
1371-
.into_boxed_str(),
1372-
);
1374+
let doc = contract_doc();
13731375
let at = doc
13741376
.find(heading)
13751377
.unwrap_or_else(|| panic!("{heading} missing"));
@@ -1446,7 +1448,7 @@ mod tests {
14461448
object_keys(value["files"][0].clone()),
14471449
"files[] keys"
14481450
);
1449-
let doc = include_str!("../CLI_CONTRACT.md");
1451+
let doc = contract_doc();
14501452
for action in [
14511453
PatchAction::Discovered,
14521454
PatchAction::Downloaded,

‎crates/socket-patch-cli/tests/e2e_bun_lockb.rs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,16 @@ fn rollback_refuses_binary_hosted_pin_then_checkout(
161161
assert_eq!(env["error"]["code"], "rollback_failed", "{env}");
162162
assert_eq!(rollback_json::already_original(&env), 0, "{env}");
163163
}
164-
assert_eq!(env["summary"]["failed"], 1, "{env}");
164+
// `failed` spans every leg (#1066): the refused hosted pin plus any
165+
// agent copy that could not be restored (a bundled copy the patch never
166+
// touched reports `hash_mismatch`); agent events carry no mode.
167+
let agent_failed = env["events"]
168+
.as_array()
169+
.into_iter()
170+
.flatten()
171+
.filter(|e| e["action"] == "failed" && e["details"]["mode"].is_null())
172+
.count();
173+
assert_eq!(env["summary"]["failed"], 1 + agent_failed, "{env}");
165174
let failed_view = rollback_json::hosted_failed(&env);
166175
let failed = failed_view.as_array().cloned().unwrap_or_default();
167176
assert!(

0 commit comments

Comments
 (0)