From 2210c934d4a25602318f094e0eca72f42862d44a Mon Sep 17 00:00:00 2001 From: aur-build Date: Fri, 20 Nov 2026 21:03:58 +0000 Subject: db, sandbox: apply the dispositions the table decided MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Six db items are now gated behind `test-support`, each with a comment saying what it is for and why production never calls it: builds::claim production leases a batch; `claim_batch` is what the dispatcher runs settings::set_setting the readers are used, the setter is not Writer::shutdown the server runs until the process ends snapshots::snapshot_by_commit world::world_members production writes world snapshots, never reads one back member by member invariants::unapproved_index_entries gated, not relocated: reading it needs this module's private helpers, and widening those to let a test out would be the wrong trade Gating them exposed three things they were the only user of, and each is gated with them rather than left compiling into a binary that cannot reach it: `Msg::Shutdown` and its loop arm, and `model::json_or`. `arch-census.py --write-budget` also stopped erasing the `test_surface` section — two writers of one file must not delete each other's axis, or the ratchet quietly stops checking it. `steps::touch` is deleted, not narrowed. Nothing called it — not production, not a test. The census had credited it to `tests/shims.rs`, where the word appears inside a string. In sandbox, two tests moved into `src/sandbox/kata.rs`: the container record a lease provisions, and the TTL expiry of a sandbox that never dials in. Neither builds a fixture. `KataBackend::shared_for`, `provision_request`, `sandbox_cr` and `K8sSandboxProvisioner::for_config` are `pub(crate)` as a result. `KataBackend::reclaim` is deleted — same story as `touch`. It forwarded to `self.provisioner.reclaim`, which the reaping site already calls itself, and the TTL test the census credited it for implements the *trait's* `reclaim` on a null provisioner. Same word, different function. Two honest costs, both recorded rather than smoothed over: - `Provisioner` and `ProvisionRequest` are now named by nobody outside `sandbox`, yet cannot be narrowed: `LocalAgentProvisioner` is `pub` because two fixture tests construct it, and Rust forbids a public type implementing a private trait or taking a private parameter type. `sandbox.deadonly` therefore rises 0 → 2, with the reason here as the ratchet demands. - `agent_sandbox_config()` now exists in both `tests/kata.rs` and `src/sandbox/kata.rs`. Three of that file's remaining tests still need it, and a test helper cannot be shared across the crate boundary without making it public again. sandbox: 27 pub / 15 dead -> 22 pub / 10 dead. Suite: 284 passed, 0 failed, 0 ignored. Clippy clean. --- src/db/builds/mod.rs | 10 +++++++++- src/db/builds/steps.rs | 9 --------- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src/db/builds') diff --git a/src/db/builds/mod.rs b/src/db/builds/mod.rs index 2035cfd..fc84335 100644 --- a/src/db/builds/mod.rs +++ b/src/db/builds/mod.rs @@ -127,6 +127,14 @@ pub fn queued(db: &Db, limit: i64) -> Result> { }) } +/// Lease one named build to a worker. +/// +/// Test-tier only. Production leases a *batch* — `claim_batch` is what the +/// dispatcher runs — and nothing in the crate calls this single-build form. +/// It stays because three test files lease one build at a time on purpose, +/// and a test that wants to reason about one lease should not have to +/// arrange for the batch form to hand back exactly one. +#[cfg(feature = "test-support")] pub fn claim(db: &Db, owner: &str, id: &str, lease_secs: i64) -> Result { let (owner, id) = (owner.to_string(), id.to_string()); let exp = time::secs_ahead(lease_secs); @@ -291,5 +299,5 @@ pub use steps::{ begin_step, blocked_builds, cancel_superseded, claim_batch, finish_step, in_flight, queue_depth, requeue_transient, retry, set_blocked_on, set_release_in, set_world, - step_status, steps, touch, + step_status, steps, }; diff --git a/src/db/builds/steps.rs b/src/db/builds/steps.rs index 01d7c40..4ffff36 100644 --- a/src/db/builds/steps.rs +++ b/src/db/builds/steps.rs @@ -149,15 +149,6 @@ pub fn blocked_builds(db: &Db) -> Result)>> { Ok(out) }) } - -pub fn touch(db: &Db, id: &str) -> Result<()> { - let id = id.to_string(); - db.writer.tx(move |tx| { - tx.execute("UPDATE build SET updated_at=?1 WHERE id=?2", params![time::now(), id])?; - Ok(()) - }) -} - pub fn set_release_in(tx: &rusqlite::Transaction<'_>, id: &str, release_id: i64) -> Result<()> { tx.execute("UPDATE build SET release_id=?1 WHERE id=?2", params![release_id, id])?; Ok(()) -- cgit v1.2.3