Repository navigation
feat(inference): measured work holds the core — Background generations defer at the adapter seam (restore-economy 1.a) - #2544
Merged
Conversation
…rations defer at the adapter seam (restore-economy 1.a)
agent/solve quiesces the other citizens' SERVICE LOOPS (verified
quiesced_peers=3) — and the GPU still spent ~half its generations on
dream-belief-review (52 of 109 inference.prefill.complete rows) DURING a
measured solve. Dreams never run in the loops the lease gates; they spawn
their own tasks and walked straight past the quiesce onto the ONE serving
slot, evicting the solve's warm KV every time. At ~32.9s re-prefill vs
~0.1s restore (~330x, measured), the bypass didn't slow the solve — it
halved the machine.
ONE seam, not whack-a-mole: gating each background producer means the
next tokio::spawn forgets. The adapter is where every generation already
crosses with its purpose in hand, so the hold is consulted there and
nowhere else; producers never learn it exists.
THE RTOS SHAPE (Joel: "be careful with await-based code ... we're trying
to be many RTOSes"), audited explicitly:
- Deferral sits AFTER classification and BEFORE the concurrency permit —
a parked request holds NOTHING (no lock, no decode permit, just its own
task on a notify). Parking after the permit would be priority inversion:
a sleeping dream holding the only decode slot while a real turn queues.
- No lock is ever held across an await (the state mutex is sync-scoped).
- Turn and Sidecar never enter the await path at all — a human talking to
a citizen outranks a measurement, and blocking the measured drive's own
traffic would deadlock it. The holder's own Background rides through.
- Release wakes ALL waiters (broadcast, never FIFO) — deferred work
re-races admission instead of draining serially.
- Bounded: a 4h ceiling proceeds LOUDLY (inference.hold.defer_ceiling) —
a lease-leak detector, not a policy. Never a silent forever-park.
RAII with a generation counter: a stale lease's late drop cannot release
a newer hold (the exact silent re-open of the dream-clobber).
TDD: the defer table, the stale-drop hazard, and both ends of the
bounded wait (wake-on-release, ceiling-proceeds) — via the injected-core
pattern (spill.rs precedent) after the process-global singleton made the
first parallel test run race itself.
Probes / VDD receipt: inference.hold.{acquired,released,replaced,
deferred,resumed,defer_ceiling}. The phase receipt is ZERO
Background-class inference.prefill.complete rows during a hold, plus the
solve's own delib.generate.cache hit rate vs tonight's 0.29 baseline.
3 measured_hold + 19 solve + 36 slots/adapter tests green.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… zero polling Joel: "Ideally you operate causally via events triggering actions ... all without stalling, like cbar. Concurrency first ... serial only when you can truly justify it." Audited 1.a against that and it fell short in one place: the defer loop waited on Notify with a 30s re-check tick, because Notify can miss a wakeup that fires before the waiter arms. A tick to paper over a missable event is a poll wearing an event's coat. Now the hold IS the substrate-canonical snapshot shape (watch::Sender, CONCURRENCY-STYLE-GUIDE): - acquire/release are EVENTS (send_replace / send_if_modified — the release event fires exactly when state actually changed, so watchers wake causally, never spuriously); - a deferred waiter awaits changed() and CANNOT miss a transition (watch keeps the latest value) — the tick is deleted; the only clock left is the leak-detector ceiling; - subscribe() is public: a component that would only park at the adapter door can instead REACT — skip assembling work while held, resume on the release event (the dream scheduler's future cheap early-skip); - the Mutex is gone entirely — one fewer lock in the substrate; - serial remains in exactly one justified place: admission to the one physical GPU slot, because the device is serial. Every mind and every deferred task stays concurrent and holds nothing while waiting. Same tests, same contracts (defer table, stale-drop generation guard, wake-on-release, ceiling-proceeds) — the refactor changes the mechanism, not the behavior, and the suite proves it. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ell, and split the act ledger (model_ms vs residue_ms) Three tightenings from CI + the stall audit: 1. THE RATCHET WAS RIGHT. subscribe() shipped with zero callers — unwired public machinery, the #27 shape the hygiene test exists to block. Now wired to the consumer it was designed for: dream_pass parks on the hold's RELEASE EVENT before assembling anything — cluster gathering, budget math and prompt composition are wasted work for a generation the adapter seam would only park at the door. Events trigger actions (CBAR); the adapter gate remains the enforcement and its leak ceiling still bounds the pathological case. Probe: dream.deferred_to_hold. 2. HoldCell demoted to module-private — it was pub only for the injected-core test pattern, and the tests live in this module. A pub type nothing outside constructs is exactly what tripped the ratchet (107 -> 108); the ratchet is back at baseline. 3. THE ACT LEDGER SPLIT (stall-audit finding, Joel: "we're all about latency and limiting locked up minds, or time spent between actions"). persona.act.pace now carries model_ms + residue_ms per act. Measured tonight: acts p50 123s = prefill 40s + decode 52s + ~29s residue — but the residue was only DERIVABLE by subtracting log aggregates; a stall hiding in tools and a stall hiding in the model were the same number. Now every act names where its time went, at the moment it happens, on the probe row that already carries the slow/stuck verdicts. 41 act_observe + 4 reachability + 3 measured_hold tests green. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restore-economy Phase 1.a (plan:
restore-economy-fourteen-personas-one-core.md). Fixes the measured cause of the 0.29 KV hit rate.The defect
agent/solvequiesces the other citizens' service loops (verifiedquiesced_peers=3) — and the GPU still spent ~half its generations ondream-belief-review(52 of 109inference.prefill.completerows) during a measured solve. Dreams never run in the loops the lease gates; they spawn their own tasks and walked straight past the quiesce onto the one serving slot, evicting the solve's warm KV every time. At ~32.9s re-prefill vs ~0.1s restore (~330×, measured), the bypass didn't slow the solve — it halved the machine.One seam, not whack-a-mole
Gating each background producer means the next
tokio::spawnforgets. The adapter is where every generation already crosses with itspurposein hand — the hold is consulted there and nowhere else. Producers never learn it exists.The RTOS audit (the "too-FIFO / blocking cognition" hazard, explicitly)
inference.hold.defer_ceiling) — a lease-leak detector, never a silent forever-park.RAII with a generation counter: a stale lease's late drop cannot release a newer hold (that would silently re-open the dream-clobber).
TDD
The defer table, the stale-drop hazard, and both ends of the bounded wait (wake-on-release + ceiling-proceeds) — written first, via the injected-core pattern (
spill.rsprecedent) after the process-global singleton made the first parallel test run race itself.VDD receipt (at the boundary deploy)
Zero Background-class
inference.prefill.completerows during a hold, and the solve'sdelib.generate.cachehit rate vs tonight's 0.29 baseline. Probes:inference.hold.{acquired,released,replaced,deferred,resumed,defer_ceiling}.3 measured_hold + 19 solve + 36 slots/adapter tests green.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo