From e757979f1a2afdbe7146066345bb9acd19d3b151 Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 17:09:59 +0000 Subject: comments: say why, not what MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every module-level `//!` header is gone, and the comments that remained either re-explained the line below them or had grown into paragraphs. Density went from one comment line per 6.7 lines of code to one per 10. 827 insertions against 2194 deletions across 86 files. What survived: the invariants (I1-I12), the design cross-references into DESIGN.md, and the notes recording a bug that was found and fixed — those are the comments that carry weight, because they answer a question the code cannot answer about itself. What did not: restating a function signature in prose, and narration of the statement underneath. --- tests/remote_agent.rs | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) (limited to 'tests/remote_agent.rs') diff --git a/tests/remote_agent.rs b/tests/remote_agent.rs index 24e259e..af4ac60 100644 --- a/tests/remote_agent.rs +++ b/tests/remote_agent.rs @@ -1,8 +1,3 @@ -//! The remote-builder path, end to end: a real build driven over the real -//! agent protocol against the §16a shims. No root, no network beyond a -//! loopback socket, no container — but the frames, the rendezvous, the log -//! streaming and the blob transfer are the production ones. - mod common; use std::io::Read; @@ -44,8 +39,7 @@ fn a_full_build_runs_over_the_agent_protocol() { .expect("spawn sandbox-agent"); let out = pipeline::run_with(&ctx).unwrap(); - // Kill *and* reap: an unreaped child is a zombie the next test inherits, and - // clippy is right that a spawn nobody waits on is unfinished business. + // Kill *and* reap: an unreaped child is a zombie the next test inherits. let _ = agent.kill(); let _ = agent.wait(); assert!(matches!(out, pipeline::Outcome::Succeeded { .. }), "{out:?}"); @@ -57,8 +51,8 @@ fn a_full_build_runs_over_the_agent_protocol() { "agent-streamed output must reach the build log:\n{log}" ); - // The build really ran as the agent's child, with the shim protocol - // applied from the Run frame's environment. + // The build really ran as the agent's child, with the shim protocol applied + // from the Run frame's environment. let shimlog = env.cfg.hooks.shim_dir.clone().unwrap(); assert_eq!(aur_build::shims::called_with(&shimlog, "makepkg", ""), 1); } @@ -98,14 +92,9 @@ fn blobs_round_trip_over_the_wire_and_a_bad_token_is_refused() { let _ = bad.wait(); } -// --------------------------------------------------------------------------- -// One listener per process. -// -// `Ctx::new` used to construct a backend for every build, and constructing a -// remote backend bound the agent listener. So a second concurrent build on a -// fixed `listen` died of EADDRINUSE — a build failing for a reason that had -// nothing to do with its package. The listener is a property of the process now. -// --------------------------------------------------------------------------- +// One listener per process. Constructing a remote backend bound the agent +// listener, so a second concurrent build on a fixed `listen` died of EADDRINUSE +// for a reason that had nothing to do with its package. fn remote_cfg(listen: &str, token: &str) -> aur_build::config::Config { aur_build::config::Config { @@ -119,7 +108,7 @@ fn remote_cfg(listen: &str, token: &str) -> aur_build::config::Config { } /// A port nothing is holding, so two backends can be asked for the *same* fixed -/// address — which is the only case where double-binding shows up. +/// address — the only case where double-binding shows up. fn free_port() -> u16 { let l = std::net::TcpListener::bind("127.0.0.1:0").unwrap(); let port = l.local_addr().unwrap().port(); @@ -136,19 +125,17 @@ fn two_builds_share_one_agent_listener() { let (sa, sb) = (&a.status().unwrap()[0].id, &b.status().unwrap()[0].id); assert_eq!(sa, sb, "both must report the one listener: {sa} vs {sb}"); assert!(sa.contains(&addr), "and it must be the configured address: {sa}"); - // Why the sharing matters, asserted rather than assumed: a raw second bind - // on a listening address is EADDRINUSE (Rust binds and listens together, so - // SO_REUSEADDR does not rescue it). If this ever passes, the test above is - // vacuous and the regression it guards is back. + // Why the sharing matters, asserted rather than assumed: a raw second bind on a + // listening address is EADDRINUSE. If this ever passes, the test above is + // vacuous. assert!( std::net::TcpListener::bind(&addr).is_err(), "a second bind on {addr} must fail, or nothing here proves anything" ); } -/// Sharing the listener means sharing the queue of dial-ins, which is exactly -/// the semantics `remote` already has: an agent dials in when the operator -/// boots one, and whichever build is waiting takes it. +/// Sharing the listener means sharing the queue of dial-ins: an agent dials in when +/// the operator boots one, and whichever build is waiting takes it. #[test] fn a_dial_in_goes_to_whichever_backend_is_waiting() { let addr = format!("127.0.0.1:{}", free_port()); @@ -179,9 +166,6 @@ fn a_different_token_on_the_same_address_is_refused_not_shared() { } /// The contract in its literal shape: two workers, two builds, one listener. -/// Each worker builds a `Ctx`, and building a `Ctx` used to bind the listener — -/// so the second worker's build died of EADDRINUSE before it looked at its -/// package at all. #[test] fn two_concurrent_builds_do_not_fight_over_the_listener() { let addr = format!("127.0.0.1:{}", free_port()); -- cgit v1.2.3