Repository navigation
Conversation
…nd --ctx The ask comes first: a set --ctx is the total over the slots, planned at its share once, and a share the card cannot hold stops the load by name with the largest share it would hold. With --ctx unset a slot is planned at DEFAULT_TARGET (262,144) or the model's limit, and only this default steps down by halves, only on a plan whose card is short of its resident bytes plus the context's sequence state. Any other refusal stands. Short reads a plan's violations and the card-floor errors as a short card. No seat calls it yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Verdict: MUST_FIX: choose can reject a fitting floor, duplicates shared rules, and documents two nonexistent APIs.
Must fix
1. Try the floor before reporting FloorShort
crates/placement/src/placement/ctx_ask.rs:364 Kind A. Calling choose(Ask::Default, 1, ...) with limit=24576, floor=4096, step=1024 and a plan holding through 4096 probes 24576 → 12288 → 6144, then returns FloorShort without trying the fitting 4096.
Correct the shared ladder so its floor contract holds. Replace lines 363–364:
let next = round_down(rung / 2, steps.step).max(steps.floor.min(target));
if next == rung {Add the 24576 limit to the floor test. Its current power-of-two target reaches 4096 and misses this case.
2. Reuse the split and bisection owners
crates/placement/src/placement/ctx_ask.rs:324 repeats the floor-share and empty-share rule in crates/placement/src/slots.rs:169.
crates/placement/src/placement/ctx_ask.rs:405 repeats the upper-midpoint bisection in crates/placement/src/placement/ctx.rs:115. Kind B, R14: these are the same facts, with error translation and integer width as adapters.
Reusing the owners keeps later boundary fixes in one place. Replace lines 324–327:
let slot_ctx = crate::slots::split_ctx(total, n, std::num::NonZeroU64::MIN)
.map_err(|_| AskError::NoPosition { total, slots })?;The existing zero-slot guard makes NoSlots unreachable here. Change the ctx::largest callback parameter to:
mut ok: impl FnMut(usize) -> Result<bool, E>,Replace lines 403–413 with:
let lo = usize::try_from(lo_k).expect("supported hosts have 64-bit usize");
let hi = usize::try_from(hi_k).expect("supported hosts have 64-bit usize");
let k = super::ctx::largest(lo, hi, |k| holds(k as u64 * steps.step))?;
Ok(Some(k as u64 * steps.step))3. State the actual context-limit caller contract
crates/placement/src/placement/ctx_ask.rs:14 claims ctx::check_slot_ctx already checks the model limit; crates/placement/src/placement/ctx_ask.rs:44 names ctx::CtxLimit::limit. Neither API exists in either tree. Kind B. choose caps defaults and does not validate a set context against the limit.
Correct the contract before seats rely on an absent guard. Replace lines 13–14:
//! seat's error as it stands. Callers validate a set context against the model's
//! limit; here it only caps the default target.
Replace line 44:
/// The name of the model bound, such as `trained`.
Checked
Duplicates: read both existing owners and confirmed the split and bisection copies. Dryer reported zero pairs.
Complexity: diagnostics report choose as new, CC 16; it handles the set search and default ladder.
Silent failure: planner errors propagate through AskError::Plan; only CardShort retries the default.
Tests: the current floor assertion exercises a power-of-two target; the 24576 failure follows the production arithmetic.
Gates: no existing pins, thresholds or tests changed; the PR reports FAIL-first against a stub.
Escape catalog: C1–C4 do not match. No ledger lessons are in force.
Notes
Rust tests were not run during validation. A source-matched arithmetic check reproduced finding 1 and checked the proposed floor fix on boundary inputs. No seat calls this module yet.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
| let next = round_down(rung / 2, steps.step); | ||
| if next < steps.floor { |
There was a problem hiding this comment.
A limit of 24576 skips a fitting floor of 4096; try the floor once before refusing.
| let next = round_down(rung / 2, steps.step); | |
| if next < steps.floor { | |
| let next = round_down(rung / 2, steps.step).max(steps.floor.min(target)); | |
| if next == rung { |
| //! seat's error as it stands. The model's limit is held by | ||
| //! `ctx::check_slot_ctx` before this runs: here it only caps the target. |
There was a problem hiding this comment.
ctx::check_slot_ctx does not exist; state the caller's validation obligation.
| //! seat's error as it stands. The model's limit is held by | |
| //! `ctx::check_slot_ctx` before this runs: here it only caps the target. | |
| //! seat's error as it stands. Callers validate a set context against the model's | |
| //! limit; here it only caps the default target. |
| pub struct Limit { | ||
| /// The positions. | ||
| pub positions: u64, | ||
| /// `trained`, or the bound's own word (`ctx::CtxLimit::limit`). |
There was a problem hiding this comment.
ctx::CtxLimit::limit does not exist in either tree.
| /// `trained`, or the bound's own word (`ctx::CtxLimit::limit`). | |
| /// The name of the model bound, such as `trained`. |
…tx and ctx::largest A target that is no power of two halved past the floor: a limit of 24,576 probed 24,576, 12,288 and 6,144, then refused without trying 4,096. The floor is now a rung of its own. The floor test adds that limit, red on the old ladder (one of nine). A set total's share goes through slots::split_ctx, and the largest share a short card holds through ctx::largest, which now takes an FnMut. The module doc states the caller's limit check instead of naming an API. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Since the last review:
- Floor retry fixed: crates/placement/src/placement/ctx_ask.rs:364 now tries the floor before refusing.
- Shared split and bisection fixed: crates/placement/src/placement/ctx_ask.rs:325 reuses
slots::split_ctx; crates/placement/src/placement/ctx_ask.rs:406 reusesctx::largest. - Caller contract fixed: crates/placement/src/placement/ctx_ask.rs:13 assigns set-context validation to callers; both nonexistent API references are removed.
Verdict: CLEAN: All three earlier findings are fixed, and the new commits introduce no proven defect.
Checked
Duplicates: 0 new functions, types or constants; both earlier copies now reuse existing owners. Dryer reported 0 pairs.
Complexity: crapper reports choose at CC 16 for the set search and default ladder. The new commits replace an existing termination branch.
Silent failure: 2 changed error paths followed. Empty shares return NoPosition; search errors propagate as Plan. The zero-slot guard prevents split_ctx's other error.
Tests: the extended floor test protects line 364. Dropping its floor clamp selects 3072 instead of 4096 and fails the new calls assertion at line 541; the short-floor case also checks refusal after probing 4096.
Gates: no pins, tolerances or existing cases removed or relaxed.
Adversarial checks: the 24576 ladder reaches 4096; a planner error at the floor propagates; shared bisection keeps probes unique and preserves results at u64 boundaries on supported 64-bit hosts.
Escape catalog: C1–C4 do not match. No ledger lessons are in force.
Notes
Rust tests were not run. Source-matched arithmetic checks covered ladder boundaries and maximum-width bisection.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
Part of #155 (ctx-first, 0.3.3).
Adds
placement::ctx_ask, the one owner that turns the user's slots and--ctxinto the context a load serves. No seat calls it yet, so no default moves in this PR. The seat moves come next and change defaults; they need the maintainer's OK before merge.--ctxis the total over the slots, planned once at its share. If the card cannot hold it, the load stops by name and says the largest share that fits.--ctxunset, a slot is planned at 262,144 or the model's limit. Only this default steps down by halves, and only when the card is short of its resident bytes plus that context's state. Any other refusal stands.Shortreads a plan'sCardOverviolations and the card-floor errors as a short card.Evidence (Mac, pool):
cargo test -p bloomery-placement --lib ctx_ask: 9 passed (remote rc 0). FAIL-first: 7 of 8choosetests red against a stubchoose.mac-staticvs33fb317b: ok, lint 41 (remote rc 0).🤖 Generated with Claude Code