Skip to main content

Module effect

Module effect 

Source
Expand description

COUNTS COME FROM EFFECTS — a change is counted only when a write landed.

★ THE DEFECT. A tick reports how many objects it changed, and every site used to count the same way: propose a command, ? the transport error, add one. The ResourceOp the store sent back was never read, so a write the store answered with “nothing happened” was reported as a change:

  • GC deleting an orphan that bears a finalizer, with no clock to stamp (the store leaves the object untouched: NoOp), counted one change per tick, forever;
  • a delete of an object already gone (NoOp) counted one;
  • write_status_cas read only Conflict, so a status patch the store REFUSED (PatchRejected, ApplyConflict) came back as Written;
  • a datapath removal whose error was discarded (let _ = remove) counted one.

★ THE SHAPE.

  • Effect::of reads the op by an exhaustive match with no wildcard, so a new ResourceOp variant does not compile (E0004) until someone says whether it changed the catalog.
  • Effect::applied is the same answer for a datapath backend (a router, an enforcer, a DNS table): Ok landed, and the error goes back to the caller uncounted.
  • crate::ReconcileReport::record counts an Effect; ObjectOutcome::from(Effect) turns one into a sweep outcome.
  • Landed has no public constructor. ObjectOutcome::Changed holds one, so a sweep cannot report an object as changed without an Effect that said a write landed.

Tier-honest, by path:

  • Sweep (crate::Sweep): reporting an object Changed without a Landed is a compile error. A Landed is minted only by a named constructor that says where the answer came from (Effect::of, Effect::applied, Effect::answered); passing one a made-up answer (answered(true), applied(Ok(()))) compiles and is caught only by review.
  • Legacy counter (ReconcileReport built by hand): objects_changed is still a public field, because the kubelet and the scheduler (outside this crate) still write it directly. A bare write anywhere in the workspace’s src/ is CI-caught, not a type: tests/t1_8_counts_come_from_effects.rs allows only crate::ReconcileReport::record and the sweep conversion, and holds the not-yet-migrated kubelet and scheduler sites to a ceiling. When those reach zero the field goes private and that gate is deleted.

Structs§

Landed
Proof that a write landed. Its field is private: Effect::of, Effect::applied and Effect::answered are the only ways to get one, and each names the answer it read (a store op, a backend result, a table’s reply). Holding a Landed means one of those said so.

Enums§

Effect
What one write did — to the store’s catalog, or to a datapath backend.
Refusal
Why the store refused a write. One arm per refusing ResourceOp.