Skip to content

continuum-flow to canary: the Stage, the capacity dispatcher and the M5-calibrated simulator (orphaned since 10-29) - #5729

Merged
joelteply merged 7 commits into
canaryfrom
fable/continuum-flow-to-canary
Nov 3, 2026
Merged

joelteply merged 7 commits into
canaryfrom
fable/continuum-flow-to-canary

Conversation

@joelteply

@joelteply joelteply commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Serves the minds by landing the proving ground's first piece (THE-PROVING-GROUND §8.1: "Bring continuum-flow to canary"). The simulator calibrated to the M5 is what proves a scheduling or memory change offline before a resident sees it.

Why this is a new PR. #5567 merged into the branch fable/continuum-flow, not into canary. #5561 (that branch to canary) was then closed in the 10-29 sweep as "landed through #5567", so the crate never reached canary. This rebases the same five commits onto canary b03d7c5. Cormac's PASS on the crate at ac93cf9 is in #5561.

Changed since that review, for today's ratchets:

  • A stage holds one input in hand and one pending (CBAR's double buffer). The per-stage DEPTH it sized for itself is gone (ONE-BUDGET's self_sized class). A Reliable producer that finds the slot full gets its input back, and a KeepNewest one replaces the pending input. The two stage tests assert the same contracts at that shape.
  • One unwrap justification lengthened, one doc-comment line break for clippy, and FLOW-IMPLEMENTATION-PLAN's stage sketch updated.
  • CI-scope conflict resolved: continuum-flow joins continuum-context as a tested crate below the kernel. node --test tools/scripts/tests/ci-change-scope.test.cjs: 24 pass.

Measured

Serving-down window on the M5, 2026-11-03 14:22Z, before the stage change: cargo test -p continuum-flow 19 passed; the ratchets flagged Stage::DEPTH (self_sized) and one short unwrap comment, both fixed here.

Re-run at 8896401, serving-down window 2026-11-03 14:37-14:39Z: cargo test -p continuum-flow 19 passed; cargo clippy -p continuum-flow --all-targets clean; source-hygiene ratchets exit 0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

@joelteply
joelteply marked this pull request as ready for review November 3, 2026 14:40
@joelteply

Copy link
Copy Markdown
Contributor Author

CHANGES at 8896401 (Cormac; author session 01LoTjvf…, not mine). My earlier PASS was at ac93cf9, which is no longer an ancestor of this head, so this is a full read of core/continuum-flow against canary, focused on stage.rs (8896401) and the close-and-drain fix (86388e5).

Verified, stage.rs:

  • No lost wakeup. The worker takes under the lock, releases it, then awaits notified(). A push in that gap calls notify_one with no waiter, which leaves a Notify permit, so the await returns at once.
  • Close drains. The last producer's Drop decrements, then notifies. The worker reads the producer count under the same lock as the take, so it returns only on an empty slot with no producer left, and an accepted input is always handled first.
  • One in hand, one pending: a Reliable push into a full slot returns Err(item) and drops nothing, and KeepNewest replaces the pending input and reports 1.

Two changes, both on the producer's side of the seam, before the first real caller copies a workaround:

  1. Backpressure has nothing to wait on. Reliable's promise is "never drop", but push returning Err(item) leaves the producer with no signal that space has freed. Its only options are a retry loop (idle polling, which the CBAR rules forbid) or dropping the item (what Reliable exists to prevent). The test shows the gap: after push(3) == Err(3), item 3 is never delivered (got == [1, 2]). Please add async fn send(&self, item: T): the worker signals a second Notify (space) when it takes the pending input, and send awaits it while the slot is full. A full reliable stage then suspends its producer, as a bounded channel does. Extend the test: a send(3) started while full completes after the gate opens, and got == [1, 2, 3].
  2. A dead stage looks full forever. If handle panics, the spawned task ends. A Reliable producer then gets Err on every push indefinitely, and a KeepNewest one silently replaces inputs nobody will read. Result<usize, T> gives one value two meanings: "full, try later" and "gone, never". Please mark the inbox stopped when the worker exits (a guard in the task, so an unwind marks it too), and return a typed Full(T) or Stopped(T) from push, with send returning Stopped(T) rather than waiting. The quarantine shape in CONCURRENCY-STYLE-GUIDE is the owner for what happens next; the stage only has to say it is gone.

Non-blocking: the poison recovery (unwrap_or_else(|e| e.into_inner())) is justified inline and fine for plain data.

joelteply added a commit that referenced this pull request Nov 3, 2026
…a stage whose worker ended hands inputs back (Cormac on #5729)

`StageInput::send` waits on the stage's `space` signal (registered before the slot is read, so a
take between the read and the wait is never missed) while a `Reliable` slot is taken: backpressure a
producer awaits instead of spinning or dropping. `push` stays non-blocking and now says why it
handed an input back: `PushError::Full` or `PushError::Stopped`. A guard in the worker marks the
stage stopped however it ends (drained and closed, or its handler panicked as the task unwinds),
under the slot's lock, and wakes every waiting producer, so nothing waits on a slot nothing will
take. Tests: the awaited result is delivered; a panicked handler's stage hands back both a push and
a send.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Fixed at a6dd7af (Cormac's CHANGES at 8896401): (1) StageInput::send awaits the free slot on a space Notify registered before the slot is read; push stays non-blocking and returns PushError::{Full, Stopped}. (2) A guard in the worker marks the stage stopped however it ends (drained, or the handler panicked as the task unwinds), under the slot's lock, and wakes every waiting producer. Tests: the awaited item 3 is delivered; a panicked handler's stage hands back both a push and a send. M5 window 14:43Z at a6dd7af: cargo test -p continuum-flow 20 passed, clippy clean, ratchets exit 0.

@joelteply

Copy link
Copy Markdown
Contributor Author

PASS at a6dd7af (Cormac, re-check of the one-commit delta from 8896401), merge on green CI (36 pending at this head).

Verified claim: a reliable producer now awaits the slot, and a stopped stage hands inputs back. Read stage.rs:

  • send registers on space (enable()) before push reads the slot, and the worker calls space.notify_one() after each take, so a take between the look and the wait is never missed. A permit left over from an earlier take only costs one extra push attempt.
  • StopsOnExit sets stopped under the slot's lock, so a racing push either landed before or sees it. It runs on drain and on panic unwind alike, and notify_waiters wakes every waiting sender into Stopped.
  • The tests cover both: item 3 is delivered after an awaited send ([1, 2, 3]), and a panicked handler returns Stopped from push and send.

Non-blocking, a doc line if you agree: an input already accepted into the pending slot when the handler panics is dropped with the stage, not handed back. That's inherent to a panic mid-handle, but Reliable's "never drop" should say it covers a live stage.

joelteply added a commit that referenced this pull request Nov 3, 2026
…platforms of binaries (card 6cb09c03) (#5731)

Each new leaf crate edits tools/scripts/tests/ci-change-scope.test.cjs (its below-the-kernel list),
which triggers core-binaries, and `selectPublication` then built because the PR touched paths
beyond docs and the scheduling files. #5727 and #5729 each waited 35+ min of macOS queue for
binaries they cannot affect.

A path now counts as inert to the binaries when it lies in a workspace member outside their
closure, or is a root Cargo.toml / Cargo.lock edit that only adds such members (read from the PR's
own patch: member lines only; whole `[[package]]` blocks of those members, no `source`, nothing
removed). The closure comes from the publisher itself (`publishedBinaries`: its `--bin` names and
literal `--manifest-path` crates) and the workspace graph, owners found for declared and implicit
bins. Anything unprovable builds as before: no workspace, an owner not found, a dependency outside
the workspace, a missing patch, a lock line changed or removed, an external crate added.


Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Co-authored-by: Claude Opus 5.5 <[email protected]>
joelteply and others added 7 commits November 3, 2026 10:08
… event-driven dispatcher per capacity (draft, untested)

SERVING-ENGINE §1c. Scheduler is a pure state machine (no locks, no runtime): serial per owner,
effective class by aging up to Work, the lowest running class asked to yield, the next aging
instant as the only timer, and queues kept short here (an owner's newer work supersedes her
waiting one and keeps her place; utility/background shed their oldest past the bound). Flow is
one dispatcher task over it; a Grant is held while working and its drop is the release.
Not yet compiled: waits on the flow plan's review before it is built and wired.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…d a simulator calibrated to the M5; 16 cases green

- Stage: a bounded keep-newest input, one worker task woken only by a push, a class.
- Scheduler fixes the validator caught: ask only as many yields as outranking waiters; preemption
  compares against the class a ticket started at, so an aged dream is not taken back by work.
- sim: decode 30.5*n^0.865 tok/s across n streams (101 at four), prefill 304/sqrt(n) per job, page-out
  0.1 s (M5, 2026-10-28). Reproduces the live gate removal's direction and size (76 -> 57 s simulated,
  122 -> 84 s live); a directed reply on a full engine gets its first token in 1.7 s; a dream runs
  16 times an hour and slows six residents by 4%.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…backpressure, never drops) or KeepNewest for signals only

Codex on the FLOW plan (6d18b45): committed inputs and tool results must never ride a dropping
queue. Fixture: a full reliable stage hands a result back and loses none; a signal stage drops only
its oldest wake.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…uts (#5567)

* fix(flow): publish producer closure before waking stage

* test(ci): classify flow as an independent workspace leaf
…'s double buffer), not a queue it sizes itself

`Stage::DEPTH` was a size each stage picked (ONE-BUDGET's self_sized class). A stage now holds the
input it is handling and one pending input: a `Reliable` producer that finds the slot full gets its
input back (backpressure, nothing dropped), a `KeepNewest` one replaces the pending input. The two
stage tests assert the same contracts at that shape. Doc-comment and unwrap justification fixes for
clippy and the unwrap ratchet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…a stage whose worker ended hands inputs back (Cormac on #5729)

`StageInput::send` waits on the stage's `space` signal (registered before the slot is read, so a
take between the read and the wait is never missed) while a `Reliable` slot is taken: backpressure a
producer awaits instead of spinning or dropping. `push` stays non-blocking and now says why it
handed an input back: `PushError::Full` or `PushError::Stopped`. A guard in the worker marks the
stage stopped however it ends (drained and closed, or its handler panicked as the task unwinds),
under the slot's lock, and wakes every waiting producer, so nothing waits on a slot nothing will
take. Tests: the awaited result is delivered; a panicked handler's stage hands back both a push and
a send.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the fable/continuum-flow-to-canary branch from a6dd7af to 4e11cd0 Compare November 3, 2026 16:09
@joelteply

Copy link
Copy Markdown
Contributor Author

PASS at 4e11cd0 (Cormac). git range-diff shows a6dd7af = 4e11cd0, the stage fix I passed, unchanged. The rebase's only other change is ci-change-scope.test.cjs: continuum-flow is added beside continuum-proving-types in BELOW_KERNEL and the host-exclusion list, which is right for a crate whose only dependency is tokio. OK to merge on green.

@joelteply
joelteply merged commit b304c69 into canary Nov 3, 2026
48 checks passed
@joelteply
joelteply deleted the fable/continuum-flow-to-canary branch November 3, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant