Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"source":"M5 (Apple M5 Pro) prompt captures, completed generations that landed (finish != length), 24 h to 2026-10-26, usage.outputTokens (reasoning included), in capture order per mind","minds":{"Aiko":[98,119,196,576,170,1136,126,313,814,164,385,822,271,486,756,186,75,75,81,149,184,110,301,427,410,92,102,164,97,453,99,95,119,326,107,205,1095,98,99,98,223,76,78,203,84,204,679,188,493,104,105,299,612,549,369,306,99,347,180,355,248,110,159,235,337,69,118,83,170,646,60,272,110,298,609,208,347,148,458,102,621,232,224,94,397,123,296,293,81,1095,300,121,604,150,871,191,246,239,289,813,117,113,594,226,102,400,281,142,174,317,244,386,840,568,380,436,662,270,580,78,299,226,430,264,154,433,101,101,99,123,124,390,121,80,106,412,109,68,225,158,451,182,1184,323,469,141,176,476,182,1063,303,100,316,122,1102,322,166,614,165,77,105,92,92,103,244,271,81,486,531,99,125,74,410,1120,52,238,298,129,408,601,383,336,580,560,291,222,514,74,175,116,259,116,118,83,225,343,119,218,137,540,204,284,75,434,239,160,357,122,105,137,162,82,1133,187,807,250,391,194,340,689,351,75,1337,75,1118,742,120,1120,1212,673,88,432,1045,51,343,1159,566,83,124,121,1030,259,1055,51,425,1094,72,1098,1057,910,140,113,961,235,200,610,528,1097,482,92,230,665,504,111,1426,116,357,40],"Atlas":[129,255,251,267,295,126,761,231,128,134,231,420,97,346,271,830,1202,250,976,172,232,141,190,471,216,460,179,184,243,138,328,391,334,225,192,168,164,122,288,277,186,742,207,626,233,165,233,175,166,190,201,221,164,228,464,185,196,166,232,127,796,184,172,195,82,134,186,342,194,242,180,337,175,284,168,165,209,220,305,176,188,150,181,191,270,194,225,249,302,563,425,735,233,275,191,242,633,222,185,82,1040,172,166,228,138,543,112,380,168,58,264,210,392,150,384,114,538,167,522,618,615,334,176,223,392,233,264,239,375,243,358,216,841,171,201,328,883,135,165,830,332,371,458,270,482,155,1164,168,183,273,182,625,132,273,543,450,83,817,243,344,1153,527,98,389,67,133,648,100,522,621,934,252,517,172,987,77,600,168,134,828,500,383,135,573,496,494,55,646,161,1093,376,202,149,87,529,589,767,176,523,208,1076,243,518,369,1147,541,504,594,183,758,127,330,700,98,725,1234,191,330,694,489,283,353,365,554,181,776,866,383,60,97,706,63,222,318,73,310,854,351,1092,297,475,339,479,145,421,550,225,463,846,129,713,115,384,421,141,1436,385,362,565,158,951,212,195,197,243,352,151,285,285,329,370,144,723,1049,121,193,977,140,336,220,181,290,306,332,248,175,120,979,145,839,206,684,227,1135,201,174,493,333,197,108,102,171,50,173,43,150,166,140,107,212,150,141,160,294,251,204,213,498,462,278,276,77,98,356,120,205,247,188,184,196,255,288,770,79,370,1228,425,625,738,933,907,433,112,1070],"Benchy":[276,228,107,193,113,250,237,119,104,744,435,595,595,151,318,171,388,322,100,798,294,166,463,531,335,219,361,379,525,280,309,1112,541,78,637,666,806,439,222,303,473,730,316,715,160,422,716,98,458,335,387,461,197,477,235,257,451,264,76,788,323,663,65,462,269,293,89,85,428,83,222,345,219,261,146,414,1526,74,68,148,375,100,248,432,772,429,71,576,552,61,752,141,59,185,174,258,234,131,145,193,391,118,180,129,122,932,163,249,1055,224,479,679,410,628,158,303,488,247,650,173,129,1073,390,351,517,1172,760,98,685,213,498,78,541,89,416,152,802,792,356,191,125,84,433,211,439,100,207,516,252,141,160,140,239,276,61,661,151,547,252,353,684,1069,369,706,268,159,391,660,342,684,336,255,365,748,654,191,592,1114,80,907,96,477,1065],"Cyrus":[169,138,363,207,115,120,356,118,104,372,154,799,391,683,616,483,461,179,86,651,248,435,304,371,116,405,154,811],"Demetri":[110,116,247,205,91,216,75,277,211,163,139,407,98,334,188,336,268,194,282,509,154,66,381,196,92,766],"Esme":[590,620,206,238,90,227,413,569,154,390,110,104,111,382,165,1020,971,703,282,174,172,233],"Freya":[496,221,117,257,151,128,997,359,238,297,1177,739,1074,966,1087,104,364,1077,382,137,92,689,245,83,201,194],"Idris":[1291,107,525,283,370,479,757,286,215,198,351,435,337,173,285,584,328,227,751,332,280,286,251,416,141],"Joaquin":[418,356,190,1126,157,378,226,433,984,90,497,198,143,229,374,413,102,170,320,356,287,275,110,60,298],"Kira":[299,76,118,1071,81,1208,1026,316,111,97,1078,1120,69,61,305,151,125,122,81,142,221,169,348,1071,1075,123,746,151,904,96,556,106,517,1278,53],"Lorcan":[62,275,183,124,225,327,273,377,382,486,410,324,534],"Mara":[188,397,489,580,170,222,215,280,297,62,57,57,175,338],"Mathis":[285,447,358,187,376,240,179,594,415,248,418,234,741,156,79,142,147,530,404,151,132],"Rania":[178,211,596,547,475,315,284,997,595,149],"Solomon":[398,378,587,456,750,210,389,625,239,1127,769,250,472]}}
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,12 @@ pub struct DeliberationPromptView {
pub input_identity: [u8; 32],
/// Cached pre-calibration cost, including selected schemas and framing.
pub estimated_prompt_tokens: usize,
/// The reply's allowance this plan granted (its flex grant plus what no other claim
/// took, under its runaway bound) — charged against the window here, and carried
/// verbatim as the wire request's `max_tokens`.
/// The room this plan leaves for the reply: its flex grant, sized by her measured
/// reply tail (`ReplyTail::reserve`). Charged against the window here; the floor of
/// the request's `max_tokens`, never its ceiling ([`Self::reply_allowance`]).
pub completion_reserve: u32,
/// The turn's runaway bound: a loop guard on the request, reserved by no claim.
pub reply_bound: u32,
pub capacity_error: Option<PromptCapacityError>,
/// The assembled prompt broke the one budget (`prompt/budget.rs`): the act fails and
/// this prompt is never sent.
Expand Down Expand Up @@ -400,4 +402,19 @@ impl DeliberationPromptView {
.collect::<Vec<_>>()
.join("\n")
}

/// The request's `max_tokens`: the window's PHYSICAL room after this prompt, under the
/// runaway bound, never below the reserve. The reserve sizes her view; it never cuts
/// her reply: a reply longer than her measured tail writes into whatever the window
/// still has (mid-epoch, the room her view has not grown into yet), and joins the
/// tail. One token stays free: local admission requires prompt + reply < window.
pub fn reply_allowance(&self, window: u32, calibration: PromptCalibration) -> u32 {
let prompt = calibration.charge(self.estimated_prompt_tokens).min(u32::MAX as usize) as u32;
window
.saturating_sub(prompt)
.saturating_sub(1)
.min(self.reply_bound)
.max(self.completion_reserve)
.max(1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ impl LlmDeliberationFaculty {
let (reply, reply_runaway) = reply_claim(
self.turn_kind(ws),
self.working_set.as_ref().and_then(|reg| reg.need_of(self.persona_id)),
self.working_set.as_ref().and_then(|reg| reg.reply_reserve_of(self.persona_id)),
pending_peak,
Self::holds_live_work(ws),
ws.directed_at_self(),
Expand Down Expand Up @@ -314,13 +315,13 @@ impl LlmDeliberationFaculty {
// The reply never takes from required content: its floor is what the window leaves
// after framing, tools and the required input. Its UNCLIPPED floor is her need.
let reply_need = reply.floor_tokens;
// An act's reply wants its whole runaway bound, at its priority above her context's:
// what no claim took used to top it up to that bound, and her view, a claim on the
// whole window, leaves nothing untaken. Aris's act was cut at the output limit with
// 5,316 granted and 0 unallocated (the M5, 2026-10-22 00:14Z), a whole turn lost.
if matches!(self.turn_kind(ws), TurnKind::Act) {
reply.max_tokens = reply.max_tokens.max(reply_runaway);
}
// The reply claims her measured RESERVE (`reply_claim`), never the runaway bound:
// reserving 12,288 for replies measured at p99 1,202 left her view and history a
// median 30.3k of a 58,880 window (the M5, 2026-10-26, 30 `delib.window.flex` rows;
// framing 13,463 there already includes the tool schemas). A reply past the reserve is not cut by it (Aris's act
// cut at 5,316 granted, 2026-10-22, was the reserve bounding the request): the
// request carries the window's physical room after the prompt
// (`DeliberationPromptView::reply_allowance`).
reply.floor_tokens = reply_need.min(context_window.saturating_sub(fixed_cost.saturating_add(required_cost)));
reply.min_tokens = reply.floor_tokens;
let fixed_claim = |id: &str, tokens: u32| crate::cognition::rag_budget::RagSourceBudget {
Expand Down Expand Up @@ -372,12 +373,10 @@ impl LlmDeliberationFaculty {
}));
let plan = crate::cognition::rag_budget::flex_allocate(context_window, &claims);
let budget_floor = crate::cognition::rag_budget::turn_need(&claims).saturating_sub(claims.iter().find(|c| c.source_id == FLEX_REPLY).map_or(0, |c| c.floor_tokens)).saturating_add(reply_need);
// Whatever no claim took is hers to write with, up to the runaway bound.
// The room the view leaves for the reply is the reply's grant. What no claim took
// is her view's to grow into; the reply may still write into it (`reply_allowance`).
let reply_grant = plan.granted(FLEX_REPLY);
let completion_reserve = reply_grant
.saturating_add(plan.unallocated)
.min(reply_runaway)
.max(1) as usize;
let completion_reserve = reply_grant.max(1) as usize;
continuum_base::probe!(
class = "delib.window.flex",
persona = %self.persona_name,
Expand All @@ -392,11 +391,12 @@ impl LlmDeliberationFaculty {
reply_granted = reply_grant,
unallocated = plan.unallocated,
reply_runaway,
allowance = completion_reserve,
reserve = completion_reserve,
escalation = plan.escalation_needed,
"the served window's one allocation — framing, required input, grounding, \
history and the reply by priority; the allowance is the reply's grant plus \
what no claim took, under its runaway bound"
history and the reply by priority; the reserve is the reply's grant (her \
measured tail), what no claim took is her view's, and the runaway bound only \
guards the request"
);
// Grounding is optional: when its floor did not fit, it holds no room the
// required input then has to do without.
Expand All @@ -413,10 +413,9 @@ impl LlmDeliberationFaculty {
.filter(|a| claims.iter().skip(5).any(|c| c.source_id == a.source_id))
.map(|a| a.allocated_tokens)
.sum();
// What no claim took goes to the reply up to its runaway bound; only the rest is room
// her view may grow into by appends (`fit_view`), and the fit's budget holds that same
// room, or it would drop what the epoch was allowed to keep.
let view_room = plan.unallocated.saturating_sub(reply_runaway.saturating_sub(reply_grant));
// What no claim took is room her view may grow into by appends (`fit_view`), and the
// fit's budget holds that same room, or it would drop what the epoch was allowed to keep.
let view_room = plan.unallocated;
let msg_budget = window_msg_budget.min(required_tokens.saturating_add(calibration.prompt_budget(
plan.granted(FLEX_HISTORY).saturating_add(view_granted).saturating_add(view_room) as usize,
)));
Expand Down Expand Up @@ -690,6 +689,7 @@ impl LlmDeliberationFaculty {
input_identity,
estimated_prompt_tokens,
completion_reserve: completion_reserve as u32,
reply_bound: reply_runaway,
capacity_error,
budget_fault,
protocol_error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ const PASS_RUNAWAY_MULTIPLE: u32 = 2;
/// ([`LlmDeliberationFaculty::COMPLETION_FLOOR_TOKENS`]); an ACT floors at her measured
/// answer channel (the tool call itself). The caller caps it so required input always
/// fits — the reply never takes from required content.
/// - max: what she is expected to write — her measured need, or the reply-sized cold
/// prior when unmeasured; at least twice a pending cut's peak (the cut write gets its
/// room back on the retry). Never past the runaway bound.
/// - max: her REPLY RESERVE — the max of her last measured outputs × 5/4
/// ([`crate::cognition::working_set::ReplyTail`]), or the reply-sized cold prior when
/// unmeasured; at least twice a pending cut's peak (the cut write gets its room back on
/// the retry). Never past the runaway bound. The reserve sizes the room her view leaves;
/// it never bounds the reply: the request carries the window's physical room after the
/// prompt (`DeliberationPromptView::reply_allowance`).
/// - priority: an ambient pass 4, a directed pass 6, an act 8, an act on live held work
/// or after a pending cut 10 — the weight the reply grows by against history (5) and
/// grounding (6).
Expand All @@ -34,10 +37,12 @@ const PASS_RUNAWAY_MULTIPLE: u32 = 2;
/// priority, so priority is what decides.
///
/// The runaway bound: [`LlmDeliberationFaculty::ACT_OUTPUT_CAP`] for an act; for a pass,
/// twice her measured turn, never below the act's cap.
/// twice her measured turn, never below the act's cap. A loop guard on the request only:
/// no claim reserves it.
pub fn reply_claim(
kind: TurnKind,
need: Option<super::super::working_set::OutputNeed>,
reserve: Option<u32>,
pending_peak: u32,
live_work: bool,
directed: bool,
Expand All @@ -52,8 +57,8 @@ pub fn reply_claim(
_ => LlmDeliberationFaculty::COMPLETION_FLOOR_TOKENS,
}
.min(runaway);
let wanted = need
.map_or(LlmDeliberationFaculty::COMPLETION_COLD_PRIOR_TOKENS, |n| n.total()) // map_or: unmeasured = a REPLY-sized prior, never a window fraction
let wanted = reserve
.unwrap_or(LlmDeliberationFaculty::COMPLETION_COLD_PRIOR_TOKENS) // unwrap_or: unmeasured = a REPLY-sized prior, never a window fraction
.max(pending_peak.saturating_mul(2))
.max(floor)
.min(runaway);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ fn catalog_fits_the_minimum_serving_window() {
let framing = estimate_guard_tokens(&collapsed);
// The reply's floor — what the window always holds for it — derived from the
// claim itself, never re-spelled. Above it the reply grows by priority.
let reserve = reply_claim(TurnKind::Pass, None, 0, false, false).0.floor_tokens as usize;
let reserve = reply_claim(TurnKind::Pass, None, None, 0, false, false).0.floor_tokens as usize;
assert!(
framing + reserve < window as usize,
"framing+menu ({framing}) + reserve ({reserve}) must leave burst room in {window}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ fn prompt_plus_completion_cap_never_exceeds_the_served_window() {
// Same atomic snapshot the production `contribute` path uses — the model
// binding carries the served window the request is bounded to.
let binding = faculty.binding.load_full();
let allowance = view.reply_allowance(window, PromptCalibration::default());
let request = faculty.build_request_within(
&binding,
view.completion_reserve,
allowance,
view.messages.clone(),
None,
view.system.clone(),
Expand All @@ -51,10 +52,8 @@ fn prompt_plus_completion_cap_never_exceeds_the_served_window() {
let cap = request
.max_tokens
.expect("deliberation must bound generation to the reserved room");
assert_eq!(
cap, view.completion_reserve,
"the generation cap IS the reserved room — one source of truth"
);
assert_eq!(cap, allowance, "the generation cap IS the reply's physical room — one source of truth");
assert!(cap >= view.completion_reserve, "never below the room the plan reserved");
// The closed invariant: prompt-at-ceiling + the generation cap fits n_ctx.
let prompt_tokens = estimate_guard_tokens(&view.system) + estimate_guard_tokens(&view.user_text());
assert!(
Expand Down Expand Up @@ -161,7 +160,7 @@ fn measured_emissions_size_the_reserve_and_capped_turns_grow_it_back() {
.with_context_window(window)
.with_working_set(reg.clone());
let wanted = |who: Uuid, pending: u32| {
reply_claim(TurnKind::Pass, reg.need_of(who), pending, false, false).0.max_tokens
reply_claim(TurnKind::Pass, reg.need_of(who), reg.reply_reserve_of(who), pending, false, false).0.max_tokens
};

let cold = wanted(persona, 0);
Expand Down Expand Up @@ -266,6 +265,46 @@ fn measured_reserve_recovers_past_a_censored_large_reply() {
}
}

// what this catches: an act reserving its runaway bound. On the M5 (2026-10-26) every
// act reserved 12,288 of a 58,880 window for replies measured at p99 1,202 and max
// 1,526, leaving her view and history a median 30.3k of it. The reserve is her
// measured tail (max × 5/4); the request still carries the window's physical room, so a
// reply past the tail is never cut by it.
#[test]
fn an_act_reserves_her_measured_tail_and_may_write_past_it() {
use crate::cognition::working_set::{EmissionStop, WorkingSetRegistry};
let window = 58_880u32;
let persona = Uuid::new_v4();
let reg = WorkingSetRegistry::new();
for (tick, output) in [252u32, 792, 1_202, 300].into_iter().enumerate() {
reg.record_emission_in_memory(persona, output, output / 2, EmissionStop::Landed, tick as u64);
}
assert_eq!(reg.reply_reserve_of(persona), Some(1_503), "max 1,202 × 5/4");
let faculty = LlmDeliberationFaculty::new(
persona,
"Aiko",
"You are Aiko.",
Arc::new(HeuristicInferenceAdapter::new()),
)
.with_context_window(window)
.with_tools(vec![read_tool()])
.with_working_set(reg);
let ws = writing_workspace(crate::identity::ActivityRoom::mint(), 40, true);
assert_eq!(faculty.turn_kind(&ws), TurnKind::Act);
let view = faculty.prompt_view_within(&ws, window);
assert!(view.capacity_error.is_none(), "{:?}", view.capacity_error);
assert!(view.budget_fault.is_none(), "{:?}", view.budget_fault);
assert!(
(LlmDeliberationFaculty::COMPLETION_FLOOR_TOKENS..=1_503).contains(&view.completion_reserve),
"the act reserves her tail, never the runaway bound: {}",
view.completion_reserve
);
let allowance = view.reply_allowance(window, PromptCalibration::default());
assert!(allowance > view.completion_reserve, "a reply past her tail writes into the window's room");
assert!(allowance <= LlmDeliberationFaculty::ACT_OUTPUT_CAP, "the runaway bound still guards");
assert!(view.estimated_prompt_tokens + (allowance as usize) < window as usize, "inside the window");
}

// what this catches: KV-prefix cache locality — session-stable standing framing
// (roster/doctrine/map) must serialize BEFORE volatile grounding (recall) even
// when the volatile bid scores HIGHER salience, so the stable sections sit in the
Expand Down
Loading
Loading