Skip to content

feat(net)!: per-range priority, order, and judged OLD drops on lite-07 - #9719

Draft
kixelated wants to merge 48 commits into
mainfrom
quest/m2/lite07-subscribe/per-range-policy
Draft

kixelated wants to merge 48 commits into
mainfrom
quest/m2/lite07-subscribe/per-range-policy

Conversation

@kixelated

@kixelated kixelated commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m2/lite07-subscribe/per-range-policy.md, deleting it.

Moves subscription priority and group order onto each track::Range (wire and public API, in every language), schedules each lite-07 group by the ranges still wanting it, names the judged Max Age on OLD drops, answers each lite-07 range from its own state in TrackRun, and adds a TLA+ model of N-to-1 heterogeneous dedup. Fixes audit findings S3, S8 to S11, D3, and D4.

  • Per-range policy on the wire (D4): lite-07 SUBSCRIBE and SUBSCRIBE_UPDATE lose the top-level Subscriber Priority / Group Order. Each Range carries its own, and each Retune carries Priority, Group Order, and Max Age (0 for a range that is not a live join). Older wires keep the one subscription-wide pair, derived from the ranges (Policy::top: highest priority, descending if any range at it asks).
  • Public API: priority and order move from track::Subscription onto track::Range in Rust, JS, moq-ffi, libmoq, and the py, swift, kt, go, and dart wrappers (cpp is generated from moq-ffi). In-tree callers are updated.
  • Per-group scheduling: a lite-07 group goes out at the highest priority among the ranges covering it whose Max Age has not expired it, in that priority's order (descending breaks ties), and falls to a history range's priority and order once it ages past a live join's Max Age, in-flight streams included (Steer::serving, poll_policy, per-priority SendGroups; JS Priority ranks each stream by its own Ranking).
  • Demand folding: demand/ranges.rs counts ranges per policy and drops one only when ranges at covering policies (higher priority, or equal with the same order or descending) cover its span, so a high-priority or finite-Max-Age live join never folds into a lower-priority Range::ALL. With one policy asked it stays O(log n) per change.
  • Retune size: a retune costs no more than the range it names as it now reads, so the fit budget's half message already covers it (an_edit_retuning_every_live_range_fits_one_message).
  • Judged drops (D3): lite-07 SUBSCRIBE_DROP(OLD) carries Max Age (ms + 1, 0 = publisher max age). The relay records exactly that; SubStream::stale_budget and its JS counterpart are deleted.
  • TrackRun (S3, S8 to S11): Start::Unresolved/Resolved, withheld, placed_floor, and taken_back are gone. Lite-07 keeps a RangeState::Waiting | Started per Range ID beside one Delivery enum (Unresolved, Withheld, Answered) that holds the drops a subscriber reads only after the first SUBSCRIBE_START. Groups are served while delivery is unresolved, a finished track answers every waiting range, and an empty track ending at 0 answers them with its END. JS runTrack mirrors it.
  • Model: rs/moq-net/verify/subscribe/SubscribeDedup.tla checks SentOnce, NoPoison, QuietIsSettled, EffectivePolicy, JudgedWidest, and the fold rule. The accounting model's configs take its name as a prefix.
  • Credit admission under mixed policies: behind a group waiting for stream credit it cannot make room for, the cursor hands out the group ranked highest by the policy it would go out at now (Pick::Ranked, Subscriber::poll_recv_group_above), and only if it outranks the waiting one. It ranks each range's first unread group it still wants and takes the best, so nothing ranked lower is consumed or holds a higher group back. A waiting group counts as stuck behind every stream its subscription serves, none included, so it gives way even while another subscription holds the session's credit. A group that gives way goes back to the cursor unread, its record untold (TrackRun::give_way, track::Subscriber::give_back, through every route copy, to the arrivals or the fill it came from). The cursor hands it out again while it is cached and wanted, so the cache and the budgets bound what waits, as for any group never handed out. Once one gave way, the slot refills by rank (Admit::Best) until nothing is left unread. Credit never gives a group up, and the shed and give-up paths are gone. The waiting group is held out of the record's fold until it opens or gives way (Subscriber::hold, Standing::held), so giving way can always take its served mark back. A ranked read that refuses its best group parks on that group's stale deadline, so a group that gave way ages out through the cache driver rather than waiting for another event. SendCredit.tla models mixed policies (SendCreditMixed.cfg, new rule NoHeadOfLine, witness NeverGivesWay). JS needs no change: every JS group stream holds its own place in line, with no single waiting slot.
  • Fix: TrackState::watch_places polls each held group once, at its largest asked time, instead of once per time.
  • Review fixes:
    • A retune keeps a resolved time range where it resolved and only changes its policy and a live join's max; a retune to no max lifts the limit (Rust and JS).
    • A range edit re-reads the Range IDs covering each group in flight (Rust Steer::inflight, JS ranking), so an added range, or a span re-added under a new Range ID, moves a group already streaming. A group stream re-polls the steer until pending, so every update wakes it.
    • poll_step drives the open streams before the group waiting for credit, so a retune never makes a newer group preempt an older one its oldest-first range sends first.
    • A newest-first group that gives way goes back to the cache, not given up as OLD, and a waiting group with no stream of its own serving still gives way to one that outranks it.
    • A lite-07 start resolved when the track ends before any range placed it is never above a group already served (resolve_held), as JS and TrackRun::start do.
    • A group judged stale while it waits for recovery records the budget that judged it.
    • The CARLA control subscription puts its ascending order on a range.
    • verify-resume's coverage names narrowest, and every sync commit is the PR's base.
    • A stale verdict the publisher's max age decided names the reader's budget (0 for history); one a relay's local cache ceiling decided names the ceiling (TrackState::stale_name).
    • Fills and recoveries put their priority and ascending order on the wire range, which lite-07 reads policy from.
    • The compat interop client and the native smoke client subscribe in a shape every released @moq/net takes.
    • A group handed back after the cursor's ranges or cap moved off it is owed nowhere, so the order fallback never hands out a key a retired range asked for (Cursor::give_back).

Impact

  • Wire: breaking for moq-lite-07-wip only, which is unpublished. Older versions and moq-transport are byte-identical. Per-range Priority and Group Order replace the top-level fields; Retune gains Priority and Group Order; SUBSCRIBE_DROP(OLD) gains Max Age. The draft is updated (Prioritization, SUBSCRIBE, SUBSCRIBE_UPDATE, SUBSCRIBE_DROP, changelog), and the shared corpus fixture moves to the new layout.
  • Public API (breaking). Migration note for MIGRATE.md:
    • Rust: track::Subscription no longer has priority, order, with_priority, or with_order. Set them on each track::Range instead: Subscription::default().with_ranges([Range::from(start).with_priority(p).with_order(o)]), or the priority / order fields in a Range { .. } literal (add ..Default::default() where you set neither). To change a subscription's priority, update it with its ranges at the new priority; lite-07 retunes them in place.
    • JS: Track.Subscription.priority and .order move to each Track.Range: subscribe({ ranges: [{ start, priority, order }] }).
    • moq-ffi and wrappers (py, swift, kt, go, dart, cpp): MoqSubscription.priority / .order move to MoqRange.priority / .order. Regenerate bindings and rebuild the matching native library together.
    • libmoq (C): moq_subscription.priority / .order move to moq_range.priority / .order.
    • Before lite-07 the publisher still serves one priority and order per subscription: the highest priority any range asks, descending if any range at it does.
  • Behavior: under stream-credit pressure, on any version, no group is given up for credit. A group ranked below the one waiting for credit waits in the cache, and a waiting group that gives way to one outranking it goes back there unread. Either goes out once credit returns, unless a budget expires it first or the cache evicts it.

Validation

  • quest gate just check and quest gate just ci: pass on 04f1ceb, after merging main twice (the second for fix(net): a read that finds the end settles a waiting live join first #9810's read-loop Walked result, which the ranked pick now returns through).
  • quest gate just test interop --all: all checks passed on d3437fc. The later commits change no wire layout, and the admission fix is publisher scheduling only.
  • Each review fix has a test that fails without it. The admission fix's two tests (lite07_a_backlog_group_history_wants_waits_rather_than_being_shed, lite07_history_below_a_waiting_group_holds_back_no_group_that_outranks_it) fail on 3a49dad (group 1 dropped OLD; group 40 held behind refused history) and pass on the head. lite07_a_waiting_group_gives_way_with_no_stream_of_its_own_serving fails with the old stuck rule (group 10 kept the place) and passes. lite07_a_slot_goes_to_the_best_unread_group_once_one_gave_way fails with a refill in subscription order (slots 9, 1, 5) and passes (9, 5, 1). The give-back path is covered by lite07_a_group_that_gave_way_then_evicted_takes_no_credit, lite07_a_group_that_gave_way_goes_out_from_its_reoffer, and lite07_a_group_that_gave_way_aging_out_is_named. Codex's round-3 fixes each have a test that fails without them: a_held_group_stays_above_the_fold (the waiting key folds and stays told after it gives way), lite07_a_refused_group_aging_out_wakes_the_run (no OLD drop after the cache driver crosses the deadline), and a_group_given_back_outside_the_ranges_is_not_offered_again (the retired key is handed out). Dropping the folded guard in stuck has no test of its own: with the hold the folded case cannot arise, and give_way debug-asserts it on every give-way in the suite. moq-net tests: all pass. CARLA sim tests: 190 passed.
  • /verify-credit, rerun on the round-3 fixes: every send config passes (SendCredit.cfg 88k states 3 s, SendCreditPriority.cfg 102k 4.5 min, SendCreditStreams.cfg 331k 16 s, SendCreditLive.cfg 45k 2 s, SendCreditMixed.cfg 5.1k 8 s, with Guarded), and the receive configs passed earlier on this branch. With the old admission (unaged admit, aged shed, give-way drop, next-in-arrival refusal), SendCreditMixed.cfg breaks NoHeadOfLine. The NeverGivesWay witness fails as expected.
  • widened_max_age::a_tightened_start_leaves_history_fillable_by_an_intermediate_reader passes with relay=false and relay=true.
  • /verify-subscribe, rerun on the round-3 fixes: SubscribeAccounting.tla (78.7M states, 9 min), CutGroupEnd.cfg, PlainReset.cfg (32.2M), and every dedup config (Three 83.0M) pass. The models treat a give-up as a free choice, which deferral only makes rarer, and a deferred group that expires is named as one that never opened.
  • /verify-resume: ResumeReader, StaleRecover, Evict, and ThreeRoutes pass. The credit and subscribe sync commits move to the PR's base, e91efb9653; verify-resume keeps main's.

Models

Size: L
Implementer: Claude Code, claude-opus-5-5, unknown
Implementer: Claude Code, claude-opus-5-5, unknown (arm A)

Decisions

  • An OLD drop with no verdict, such as a priority shed or a group reset, names the narrowest live max age of the publisher's own subscription, not 0 (the publisher's max). With 0, a downstream lite-07 relay settled every reader, including readers whose wider budgets still wanted the group. That hung a lite-06 to lite-07 relay test, and sending no Max Age at all failed it outright. A shed or give-way judges it when the group is given up, so a drop held for the first SUBSCRIBE_START keeps it.
  • Lite-07 TrackRun keeps one subscription-wide Delivery enum beside the per-range states. The wire requires it: drops go out only after the first SUBSCRIBE_START, so drops given up before any range is answered are held per subscription. It replaces the old flags with one enum whose variants carry their data.
  • A group no live range wants anymore goes out at the subscription's policy as a whole. An edit that only refits a span under a new Range ID no longer counts as that, since in-flight groups take their new covering IDs.
  • Credit admission under mixed policies is fixed in this PR, not a follow-up (rejected: landing as is with a follow-up quest).
  • A group that gives way goes back to the cursor unread, so the cache and budgets bound it like any unread group, as both reviewers recommended (rejected: a per-subscription list of deferred group handles, which a peer withholding credit could grow past the cache, and which needed its own eviction, recovery, wake, and ranking machinery; rejected before that: keeping each deferred group's stream machine). Giving back passes through every route copy of a resumed reader and returns a fetched group to its fill's answers.
  • Credit never gives a group up, on any order (rejected: deferring only groups an oldest-first range wants and giving the rest up as OLD, which named a budget expiry no budget decided).
  • In-flight re-ranking when a relay places a provisional live join goes to a follow-up quest (rejected: fixing it in this PR).
  • Codex's four round-3 findings on the give-back path, (a) to (d), are fixed in this PR as recommended, decided while the maintainer was away (rejected: (c) as a follow-up quest, or all four as follow-ups).
  • Priority and order stay per range only (rejected: a request-wide setter). moq-mux, moq-audio, and moq-json keep their loops over ranges; a setter can be added later without a break.

Follow-ups

  • Re-rank in-flight groups when a relay places a provisional live join: placement changes a group's covering ranges without an edit, so a history stream open meanwhile keeps the join's rank until it finishes. No open decisions.
  • While a group waits stuck for credit, the ranked read walks each oldest-first range's owed groups past the ones it no longer wants, linear in the backlog per poll (bounded by the cache). A partition search by age would make it logarithmic if a congested relay shows it hot.
  • TrackRun::hole and the resume reader recompute the narrowest live budget and Policy::of per drop or pick (reviewer note). Track them incrementally if a relay's fitted demand makes this hot.
  • The cursor's own stale write-off (write_off_stale) still names the unclamped budget when a relay's local cache ceiling decided. Name it as TrackState::stale_name does.

Review

Rewritten by quest review after each round.

  • Head: 04f1ceb, named in full once no reviewer reports a finding

  • Base: origin/main at e91efb9

  • Risk: high, The branch changes the unpublished moq-lite-07-wip wire format (the SUBSCRIBE Meta field moves in the lite.json fixture, and the new hasJudgedDrop/has_judged_drop gating is added to version.ts and version.rs), and the JS public API in js/net/api/index.api.md moves order and priority from Track.Subscription to Track.Range, which breaks published consumers and deployed peers when the next cut publishes lite-07; it is hard to undo once released because peers on the new wire format and consumers of the API must migrate.

  • Classified: high by Claude Code, claude-haiku-5-5, low effort, session 64c1e8db-ca21-41c3-b79e-65328cd4fc3f

  • Risk file: bb7b1c0de60b

  • Reviewer: Codex, gpt-6.2-sol, xhigh effort

  • Session: 01a2223f-9e21-7c11-a217-8796ff1fe6b6, round 1

  • Score: 6/10, The patch needs rework because Rust can give scarce stream credit to lower-priority groups and JavaScript placement probes can override the requested priority and order.

  • Rounds: 10; first round 8 (high 2, medium 6); findings 25 (high 3, medium 22): fixed 20, refuted 1, open 4

  • Findings, open until the next round settles them:

    • Medium, rs/moq-net/src/lite/publisher.rs:7072: Rank the first group before spending stream credit
    • Medium, rs/moq-net/src/lite/publisher.rs:6937: Recheck cached contenders when a waiting group loses rank
    • Medium, rs/moq-net/src/model/track.rs:11784: Continue a newest-first scan past an individually stale group
    • Medium, js/net/src/lite/subscriber.ts:3379: Carry the demand policy on JavaScript placement probes
  • Notes, the author's to take or leave:

    • rs/moq-net/verify/credit/SendCredit.tla:132: Model effective group priority across subscriptions
  • Reviewer: Claude Code, claude-opus-5-5, high effort, second

  • Session: a22d06e2-141f-4834-aad8-0ddd61ca380c, round 1

  • Score: 8/10, Nothing in the reviewed areas blocks merging: the wire format, range edits, group ranking, demand fold, answer state machine and bindings all checked clean. The two notes are a stale example in the draft and its doc comments, and a JS/Rust difference in when a held drop's Max Age is captured. Coverage was partial: JS give-way parity, the verify-* models, and some relay-copy files were not reviewed.

  • Rounds: 10; first round 4 (high 2, medium 2); findings 7 (high 3, medium 4): fixed 7, refuted 0, open 0

  • Findings: none

  • Notes, the author's to take or leave:

    • drafts/draft-lcurley-moq-lite.md:897: Draft's OLD-drop example names a removed path
    • js/net/src/lite/publisher.ts:2087: JS builds a held OLD drop's Max Age when it holds the drop, not when it sends it

kixelated and others added 2 commits November 26, 2026 11:28
An OLD drop now carries the Max Age the publisher judged its groups
stale under (ms + 1, 0 = Publisher Max Age), taken from the cursor's
verdict or the group's expiry. Subscribers record that exact budget,
so SubStream::stale_budget (and its JS staleBudget counterpart) and
the narrowest-asked guess are gone: a transient LATEST viewer no longer
settles wider readers on the same upstream subscription.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lite-07 SUBSCRIBE and SUBSCRIBE_UPDATE drop their top-level Subscriber
Priority and Group Order; each Range carries its own, and a Retune
carries a new priority, order, and (for a live join) Max Age. Until the
publisher schedules per group, it serves the subscription at the highest
range priority, descending if any range there is.

Also polls each held group once in TrackState::watch_places, at the
largest time it holds, instead of once per asked time, which spun past
kio's Ready poll limit on a relay with thousands of asks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Per-range priority, order, and judged OLD drops on lite-07 feat(net)!: per-range priority, order, and judged OLD drops on lite-07 Nov 27, 2026
kixelated and others added 18 commits November 26, 2026 21:10
# Conflicts:
#	js/net/src/lite/subscribe.ts
#	js/net/src/lite/subscriber.test.ts
Replace the subscription-wide Start::Unresolved/Resolved, withheld and
placed_floor with one Answer enum: lite-05/06 keep their single held start,
and lite-07 tracks a RangeState per Range ID beside one Delivery lifecycle
(Unresolved, Withheld, Answered) that carries the drops held for the first
SUBSCRIBE_START.

- S8: lite-07 serves groups while delivery is unresolved instead of holding
  the first one and the cursor behind it.
- S3: the lite-07 cursor floor stays put; the window places each range, so an
  unplaced time start no longer cuts off the group holding it.
- S9/S11: a finished track answers every waiting range, with the cache's
  largest when the edge is unknown, which flushes the withheld drops.
- S10: an empty track ending at 0 marks every range answered by its END.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r, and Max Age

SubscribeDedup.tla fans N relay readers, each with its own Priority, Group
Order, and Max Age, into one lite-07 upstream subscription, with joins,
leaves, judged and shed OLD drops, the relay's recorded Max Age, and its own
recovery request racing on the wire. It checks SentOnce, NoPoison,
QuietIsSettled, EffectivePolicy, JudgedWidest, and the fold rule over every
range mix (ASSUME). Each rule was broken once to see TLC catch it.

The subscribe directory now holds two specs, so the accounting model's
configs take its name as a prefix, as sh/tla.sh picks a spec by it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A group goes out at the highest priority among the live ranges covering it
whose max age has not expired it, at that priority's order, and falls to the
next once it ages past them. In-flight streams follow through the steer, a
grouped stream moving to the send group of its new priority.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Track

Mirror the Rust TrackRun refactor: replace the subscription-wide startSent,
startKey, skipped, first and withheld closures with one StartAnswer union
(legacy; waiting/started for lite-05/06; unresolved/withheld/answered for
lite-07), beside the per-range `unstarted` map.

- S8: lite-07 serves groups while delivery is unresolved instead of holding
  the first one, and resolves from the lowest served once the source answers
  or a range is placed.
- S10: a lite-07 track ending before its first group answers every range with
  its SUBSCRIBE_END at 0, and a copy whose source already answered no longer
  parks forever waiting on its upstream.
- S9/S11: a finished track answers a live range with the newest held position
  when the edge is still unknown.
- Lite-03/04 ignore drops rather than holding them forever.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A group goes out at the highest priority among the live ranges covering it whose max age has not aged it out, at that priority's order, and falls to the next once it ages past them. In-flight streams follow: Priority ranks each stream by its own policy, re-ranking as the group ages or an update retunes a range. Mirrors the Rust ranking in d7ca47c.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…6a2cce6e783

# Conflicts:
#	.claude/skills/verify-subscribe/SKILL.md
#	drafts/draft-lcurley-moq-lite.md
#	js/net/src/broadcast.ts
#	js/net/src/lite/subscribe.test.ts
#	js/net/src/lite/subscribe.ts
#	js/net/src/lite/subscriber.test.ts
#	js/net/src/lite/subscriber.ts
#	js/net/src/track.ts
#	rs/moq-gst/src/sink/pad.rs
#	rs/moq-mux/src/container/mkv/import_test.rs
#	rs/moq-net/src/lite/publisher.rs
#	rs/moq-net/src/lite/subscribe.rs
#	rs/moq-net/src/lite/subscriber.rs
#	rs/moq-transcode/src/rung.rs
kixelated added a commit that referenced this pull request Nov 27, 2026
…quest

Follow-up to the two accepted review findings on mid-group route switches,
waiting on per-range-policy (#9719), which rewrites the relay copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated and others added 4 commits November 27, 2026 13:07
…iven up

- A range edit re-reads the Range IDs covering each group in flight (Rust
  `Steer::inflight`, JS ranking reads coverage each time), so an added range
  or a span re-added under a new ID moves a group already streaming.
- A group stream re-polls the steer until pending, so a second update wakes it.
- `shed` and `give_way` name the drop under the narrowest live range when the
  group is given up, not when a drop held for the first START goes out.
- Stale verdicts judged under the publisher's max age name the reader's
  budget, as the cursor does, so a history reader settles instead of asking
  again.
- Fills and recoveries carry their priority and ascending order on the wire
  range, which lite-07 reads policy from.
- Native smoke client subscribes the catalog with defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…own verdict

- `TrackRun::poll_step` drives the open group streams before the group waiting
  for credit, so a retune moves them before the waiting one ranks against
  them and an oldest-first range's newer group never preempts an older one.
- A stale verdict the local cache ceiling decided names the ceiling rather
  than the reader's budget, since upstream may still hold the group; one the
  publisher's max age decided still names the budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated and others added 2 commits November 27, 2026 16:56
…ferred not given up

Behind a group waiting for stream credit it cannot make room for, the cursor
now hands out the group ranked highest by the policy it would go out at now
(`Pick::Ranked`), and only if it outranks the waiting one; nothing ranked
lower is consumed, so blocked history never holds an urgent group back. A
waiting group an oldest-first range still wants is deferred when it gives
way, taking the place back once it empties or outranks the waiting one,
instead of being dropped as OLD. The shed path is gone.

SendCredit.tla models mixed policies (history only, live aging into history),
groups arriving over time, the ranked read, and deferral, with HistoryKept,
NoHeadOfLine, and DeferredWaits; the old admission breaks both new rules on
SendCreditMixed.cfg. The finished per-range-policy quest is deleted, and a
follow-up quest covers re-ranking in-flight groups on placement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n fix

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated and others added 2 commits November 27, 2026 17:40
…6a2cce6e783

# Conflicts:
#	.claude/skills/verify-credit/SKILL.md
#	doc/concept/moq-lite.md
#	js/net/src/lite/publisher.ts
#	js/net/src/lite/subscriber.test.ts
#	js/net/src/lite/subscriber.ts
#	rs/moq-net/src/lite/publisher.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

Design change: credit admission under mixed range policies is now fixed in this PR, as the reviewers recommended and the maintainer picked.

  • Behind a group waiting for stream credit it cannot make room for, the cursor hands out the group ranked highest by the policy it would go out at now (Pick::Ranked, Subscriber::poll_recv_group_above), and only if it outranks the waiting one, so refused history is never consumed and never holds an urgent group back.
  • A waiting group an oldest-first range still wants is deferred when it gives way (TrackRun::deferred) instead of being dropped as OLD; the shed path is gone.
  • SendCredit.tla models mixed policies (SendCreditMixed.cfg, rules HistoryKept, NoHeadOfLine, DeferredWaits); the old admission breaks both new rules there.
  • In-flight re-ranking on a relay's placement moves to the follow-up quest quest/m2/lite07-subscribe/inflight-placement-rank.md, and priority and order stay per range only.

New review sessions follow with quest review --new.

(Written by Claude Opus 5.5)

Credit admission no longer gives a group up: a group that gives way to an
outranking one is deferred as a plain group handle, kept while the cache
holds it and a range wants it, and named stale or dropped only when a
budget expires it or the cache lets it go. A waiting group with no stream
of its own serving, as when another subscription holds the session's
credit, still gives way to a group that outranks it.

Also from review: the CARLA control subscription puts its order on a
range, verify-resume's coverage names `narrowest`, and every sync commit
moves to the PR's base. recover-group-provenance drops its requirement on
this quest, which this PR finishes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated and others added 2 commits November 28, 2026 00:34
… ones

From review:

- A deferred group whose copy lost frames asks the same recovery-aware
  `poll_given_up` a serving group does, so a held re-offer or another
  route still brings it rather than a final drop.
- A finished group the cache evicted before it went out is let go and
  named, so what waits for credit stays bounded by the cache.
  `group::Consumer::poll_lost` parks on the group, so a finished group
  costs no ready poll.
- Deferred groups rank by a retune not yet read when the slot refills.
- A drop a pruned deferred group names goes out before the run parks.

Each has a test that fails without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A deferred group no longer asks a route for frames its copy lost while it
waits: one a route may still bring back (a hold, another copy, a fetching
track, or a resumed read) stays deferred and recovers once it takes the
opening slot, so a credit stall asks upstream for one group at a time.
One no route can bring back is named and let go, as before.

`group::Consumer::poll_lost` now parks on the copy's close alone, so a
frame written to a deferred group wakes no subscription, and a closed
copy is judged once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

Design change: deferred groups now recover lazily. Codex's two unsettled round-3 findings are fixed as it recommended. The maintainer is away, so this follows the standing instruction to take the recommendation.

  • A deferred group no longer asks a route for frames its copy lost while it waits for credit. If a route may still bring them back (a hold, another copy, a track whose handlers fetch, or a resumed read), the group stays deferred. It recovers once it takes the opening slot, as a serving group would, so a stall asks upstream for one group at a time. A group no route can bring back is named and let go, so the cache still bounds what waits at an origin.
  • group::Consumer::poll_lost parks on the copy's close alone, so a frame written to a deferred group wakes no subscription, and a closed copy is judged once.
  • Rejected: recovering every lost deferred group eagerly (round 2), which let a long stall start one upstream refill per evicted group.

New review sessions follow with quest review --new.

(Written by Claude Opus 5.5)

kixelated and others added 9 commits November 28, 2026 02:26
Replace the deferred-group list with the cursor itself: a group waiting
for stream credit that gives way to one outranking it is given back
unread (`track::Subscriber::give_back`, through every route copy), its
record untold, so the cursor hands it out again while it is cached and
wanted. The cache and the budgets bound what waits, as for any group
never handed out, recovery is asked only for the group that takes the
slot, and a reopened group takes the current frame bounds. Once a group
gave way, the slot refills by rank (`Admit::Best`) until nothing is left
unread, so a cached group and one that gave way compete by rank.

Also from review:

- A lite-07 start resolved when the track ends before any range placed
  it is never above a group already served (`resolve_held`), as JS and
  `TrackRun::start` do.
- A group judged stale while it waits for recovery records the budget
  that judged it.

`SendCredit.tla` returns a group that gives way to "cached", drops
`Refill` and `DeferredWaits`, and swaps the `NeverDefers` witness for
`NeverGivesWay`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…from

From review:

- A fetched group a read hands back unread is offered again among the
  fill's answers (`Misses::refill`), not among the arrivals, whose scan
  passes over fetch-only slots.
- A waiting group whose served mark the record folded into its settled
  prefix keeps its place rather than giving way, since the mark can't be
  taken back (`Record::folded`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd returns only where read

- A group waiting for stream credit is held out of the record's fold (`Subscriber::hold`,
  `Standing::held`), so giving way can always take back its served mark. `stuck` drops the
  folded guard, which forced `Admit::None` and let a higher-ranked group stall behind it.
- A ranked read that refuses its best group parks on that group's stale deadline, so it
  ages out through the cache driver rather than waiting on another event.
- `Cursor::give_back` owes a key again only while the cursor's floor, cap, and ranges still
  read it, so a fill answer a narrowing retired is not handed out by the order fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every SendCredit and subscribe config passes on the hold, wake, and range-check fixes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…base

The merged main commit changes no function their tables cover.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rank

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

Design change: Codex's four open round-3 findings on the give-back path are fixed as its reviewer recommended, picked while the maintainer was away (rejected: (c) as a follow-up quest, or all four as follow-ups).

  • (a) and (b): the group waiting for stream credit is held out of the record's fold (track::Subscriber::hold, Standing::held) until it opens or gives way, so giving way can always take its served mark back. The Record::folded guard in TrackRun::stuck is gone, and give_way debug-asserts the held key never folded.
  • (c): a ranked read that refuses its best group parks on that group's stale deadline (Subscriber::watch_stale, through the reserving copy on a resumed reader), so a group that gave way ages out through the cache driver.
  • (d): Cursor::give_back owes a key again only while the cursor's floor, cap, and ranges still read it.

Each has a test that fails without it: a_held_group_stays_above_the_fold, lite07_a_refused_group_aging_out_wakes_the_run, a_group_given_back_outside_the_ranges_is_not_offered_again. Head 04f1ceb also merges main twice. /verify-credit and /verify-subscribe pass on it, and so do just check and just ci.

(Written by Claude Opus 5.5)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant