hive-c0re: scrub host-integration cookies (#715 batch 8)

This commit is contained in:
damocles 2026-05-31 17:48:54 +02:00 committed by mara
commit dd07ca946e
3 changed files with 57 additions and 60 deletions

View file

@ -194,8 +194,8 @@ pub struct QueueEntry {
/// the wire that way too.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub approval_id: Option<i64>,
/// Current sub-step inside the running entry (#437, option A from
/// the issue). Worker mutates this as the kind-specific pipeline
/// Current sub-step inside the running entry. Worker mutates this
/// as the kind-specific pipeline
/// advances through phases (e.g. `"plant tags"` →
/// `"nixos-container update"` → `"finalize deploy"`). `None` while
/// `Queued` and after terminal — only meaningful with
@ -255,9 +255,9 @@ impl RebuildQueue {
/// `(kind, agent)` swallows the new request.
/// - `MetaUpdate`: dedup ALSO requires the `inputs` field to match —
/// two meta-updates with different input lists are distinct work
/// and must queue separately (closes #365: previously the second
/// meta-update collapsed into the first whenever it was still
/// `Queued`, losing the second's input set).
/// and must queue separately, otherwise the second meta-update
/// would silently collapse into the first whenever it was still
/// `Queued`, losing the second's input set.
///
/// Running and terminal entries never dedup — operators are free
/// to re-queue a rebuild that's currently running (something
@ -277,7 +277,7 @@ impl RebuildQueue {
/// `MetaUpdate` enqueues to tell the worker which meta-flake
/// inputs to bump. For `MetaUpdate` the `inputs` value is part of
/// the dedup key (two meta-updates with different inputs are
/// distinct operations, see #365).
/// distinct operations).
pub fn enqueue_with_inputs(
&self,
kind: QueueKind,
@ -293,8 +293,8 @@ impl RebuildQueue {
/// Full-shape enqueue — every `QueueEntry` field that's settable
/// at submit time. Existing `enqueue` / `enqueue_with_inputs`
/// delegate to this with `approval_id: None`; the approval-driven
/// POST handlers (#436) call it directly with the source row's id
/// so the worker can re-fetch the kind-specific payload.
/// POST handlers call it directly with the source row's id so the
/// worker can re-fetch the kind-specific payload.
// 8/7 args: the queue entry has 6 independent submit-time fields plus
// the inputs/approval_id pair specific to MetaUpdate and approval
// entries. A builder struct would obscure the call sites; the
@ -314,9 +314,9 @@ impl RebuildQueue {
let mut inner = self.inner.lock().expect("rebuild_queue mutex poisoned");
// Dedup against a pending entry with the same (kind, agent) —
// and, for MetaUpdate, the same `inputs` list (see method
// docstring + #365 for why). Approval-driven entries also
// require the approval_id to match so two distinct approvals
// for the same agent never collapse into one queue slot.
// docstring for why). Approval-driven entries also require the
// approval_id to match so two distinct approvals for the same
// agent never collapse into one queue slot.
for entry in &mut inner.entries {
if entry.state == QueueState::Queued
&& entry.kind == kind
@ -392,7 +392,7 @@ impl RebuildQueue {
Self::trim_history(&mut inner);
}
/// Set the current sub-step label on a `Running` entry (#437).
/// Set the current sub-step label on a `Running` entry.
/// Returns `true` when the row was found AND the label changed
/// (caller should emit a `RebuildQueueChanged` snapshot only on
/// `true` to avoid noisy duplicate frames). No-op for entries not
@ -583,9 +583,9 @@ async fn dispatch(
// approval (HostRequest::RequestSpawn → submit_kind →
// approve → enqueue with approval_id). The manager-side
// `RequestSpawn` surface that used to bypass approvals
// was removed in #442; if a future direct-spawn admin
// path needs to skip the approval ride it should wire
// its own action call rather than route through here.
// was removed; if a future direct-spawn admin path needs
// to skip the approval ride it should wire its own action
// call rather than route through here.
anyhow::bail!(
"rebuild_queue: Spawn entry id={} agent={} arrived without an approval_id — \
nothing should enqueue this shape today",
@ -648,9 +648,9 @@ async fn run_meta_update(
/// Compute which agents a `nix flake update <inputs>` on the meta
/// flake would affect. Used by callers that pre-enqueue cascade
/// `Rebuild` entries at `MetaUpdate` submission time (issue #347) so the
/// dashboard can render the dependent work alongside its parent before
/// the lock bump actually runs.
/// `Rebuild` entries at `MetaUpdate` submission time so the dashboard
/// can render the dependent work alongside its parent before the lock
/// bump actually runs.
///
/// Mirrors `run_meta_update`'s post-bump fan-out logic. Empty `inputs`
/// or any input under `hyperhive` → every container; otherwise just
@ -749,7 +749,7 @@ mod tests {
#[test]
fn meta_update_dedup_matches_inputs() {
// Two MetaUpdate enqueues with identical inputs → dedup (#365).
// Two MetaUpdate enqueues with identical inputs → dedup.
let q = RebuildQueue::new();
let a = q.enqueue_with_inputs(
QueueKind::MetaUpdate,
@ -774,7 +774,7 @@ mod tests {
#[test]
fn meta_update_dedup_separates_distinct_inputs() {
// Two MetaUpdate enqueues with DIFFERENT inputs → distinct
// entries, not deduped (the actual #365 bug).
// entries, not deduped.
let q = RebuildQueue::new();
let a = q.enqueue_with_inputs(
QueueKind::MetaUpdate,