Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bdf2819
Her prompt is fitted to a working window sized from the measured pref…
joelteply Oct 28, 2026
694a726
context_budget: the working-window step is an associated constant
joelteply Oct 28, 2026
d682844
The working window is the dyno's measured knee (48k), not a rate: sta…
joelteply Oct 28, 2026
b1acb40
An epoch starts her growing sources at a quarter of what grounding le…
joelteply Oct 28, 2026
f7ebc79
The working window's rule is a pure function the test runs at the kne…
joelteply Oct 28, 2026
4b5cf9e
WORKING_WINDOW_TOKENS and working_window_when are associated items: c…
joelteply Oct 28, 2026
29ae09a
source-hygiene: prompt_self_sizing ratchet counts every prompt-conten…
joelteply Oct 28, 2026
f883c28
Flexbox compliance step 0: the unused tool catalog (authorized_tool_c…
joelteply Oct 28, 2026
f972581
refactor(focus): preserve dispatch completions for view allocation
joelteply Oct 28, 2026
db36673
continuum_context: an item's whole may be stored, not resident (resid…
joelteply Oct 28, 2026
f3fc3bc
feat(focus): expose grant-based tool levels and invariant demand
joelteply Oct 28, 2026
68f28d5
feat(focus): pass epoch tools grant into learned-head selection
joelteply Oct 28, 2026
8e7b38d
Focus, conversation step: airc delivers every turn whole; her cursor …
joelteply Oct 28, 2026
09ec9f3
Merge branch 'codex/focus-tools' of https://github.com/CambrianTech/c…
joelteply Oct 28, 2026
3c5d9e1
Merge commit '8e7b38d41' into codex/focus-tools
joelteply Oct 28, 2026
d4a0b11
Focus, tools step: her hands are one claim in the one allocation, the…
joelteply Oct 28, 2026
c44b539
Merge remote-tracking branch 'origin/fable/working-window' into codex…
joelteply Oct 28, 2026
7998517
Remove independent tool-window budget after shared focus integration
joelteply Oct 28, 2026
d3dfdff
Focus, grounding and recall step: sources deliver every item at its l…
joelteply Oct 28, 2026
4b9e1e8
Focus: compile fixes from the 20:19Z window; delete what the migratio…
joelteply Oct 28, 2026
a8fdbc6
Focus: room updates are conversation turns in her view; the inert rep…
joelteply Oct 28, 2026
13ba365
Merge branch 'codex/focus-tools' of https://github.com/CambrianTech/c…
joelteply Oct 28, 2026
ceca62f
Use shared allocation receipts instead of rereading tool affordability
joelteply Oct 28, 2026
c8904ca
Describe tool receipt against shared allocation
joelteply Oct 28, 2026
e687458
Focus: an unread room update keeps a handle in her view, so one large…
joelteply Oct 28, 2026
2dcd5de
Focus: room updates get one index line that never collapses, not a ha…
joelteply Oct 28, 2026
1dc5a2a
Card ids in the board, active-work and wall sources use airc_core's s…
joelteply Oct 28, 2026
1978076
Merge branch 'codex/focus-tools' of https://github.com/CambrianTech/c…
joelteply Oct 28, 2026
58a5968
Focus, act_observe: her echoed args fold at a fixed rule; a settled r…
joelteply Oct 28, 2026
eef1460
Merge remote-tracking branch 'origin/fable/working-window' into codex…
joelteply Oct 28, 2026
a81ef42
Separate saved-output transport pages from prompt allocation
joelteply Oct 28, 2026
55f18e4
Align output-page binding documentation with transport bound
joelteply Oct 28, 2026
7551953
Merge remote-tracking branch 'origin/fable/working-window' into codex…
joelteply Oct 28, 2026
c4a585a
fix(ipc): remove unused server-loop import left by split
joelteply Oct 28, 2026
8bbebc9
style(ipc): remove trailing blank line after obsolete section
joelteply Oct 28, 2026
332f102
test(focus): retain calibrated claims when checking withheld tools
joelteply Oct 28, 2026
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
4 changes: 3 additions & 1 deletion core/continuum-academy/src/cognition/eval/eval_settle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ pub(super) async fn eval_settle(
let delivery = crate::cognition::rag_budget::RagDelivery {
source_id: "airc".to_string(),
items: vec![crate::cognition::rag_budget::RagItem {
key: String::new(),
summary: None,
pointer: None,
content: prompt.to_string(),
tokens: 0,
metadata: serde_json::json!({ "peer_id": "peer", "occurred_at_ms": EVAL_EPOCH_MS }),
}],
tokens_used: 0,
truncated: false,
resolution_used: crate::cognition::rag_budget::ResolutionPreference::Raw,
};
let burst = crate::cognition::workspace::Burst::from_turns(
room,
Expand Down
12 changes: 9 additions & 3 deletions core/continuum-academy/src/cognition/eval/run_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ pub(super) async fn run_pass(
let task_delivery = crate::cognition::rag_budget::RagDelivery {
source_id: "airc".to_string(),
items: vec![crate::cognition::rag_budget::RagItem {
key: String::new(),
summary: None,
pointer: None,
content: framed_prompt,
tokens: 0,
metadata: serde_json::json!({
Expand All @@ -214,7 +217,6 @@ pub(super) async fn run_pass(
}],
tokens_used: 0,
truncated: false,
resolution_used: crate::cognition::rag_budget::ResolutionPreference::Raw,
};
// own_peer/agent_name attribute the persona's OWN past posts; a single-task
// exam has none, so they're inert here (the item's peer_id "peer" ≠ "").
Expand Down Expand Up @@ -400,6 +402,9 @@ pub(super) async fn run_pass(
let nudge_delivery = crate::cognition::rag_budget::RagDelivery {
source_id: "airc".to_string(),
items: vec![crate::cognition::rag_budget::RagItem {
key: String::new(),
summary: None,
pointer: None,
content: format!(
"You did not answer. This is a GRADED exam question and you must answer it \
now — do NOT reply PASS or stay silent. Provide your complete solution:\n\n{}",
Expand All @@ -410,7 +415,6 @@ pub(super) async fn run_pass(
}],
tokens_used: 0,
truncated: false,
resolution_used: crate::cognition::rag_budget::ResolutionPreference::Raw,
};
let nudge_burst = crate::cognition::workspace::Burst::from_turns(
room,
Expand Down Expand Up @@ -519,6 +523,9 @@ pub(super) async fn run_pass(
let red_delivery = crate::cognition::rag_budget::RagDelivery {
source_id: "airc".to_string(),
items: vec![crate::cognition::rag_budget::RagItem {
key: String::new(),
summary: None,
pointer: None,
content: format!(
"You settled, but the task's definition-of-done currently FAILS. Its output ends:

Expand All @@ -531,7 +538,6 @@ Fix the workspace and finish — the grade reads th
}],
tokens_used: 0,
truncated: false,
resolution_used: crate::cognition::rag_budget::ResolutionPreference::Raw,
};
let red_burst = crate::cognition::workspace::Burst::from_turns(
room,
Expand Down
4 changes: 3 additions & 1 deletion core/continuum-academy/src/cognition/eval/warm_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ pub(super) async fn warm_gate(cycle: &crate::cognition::workspace::WorkspaceCycl
let probe_delivery = crate::cognition::rag_budget::RagDelivery {
source_id: "airc".to_string(),
items: vec![crate::cognition::rag_budget::RagItem {
key: String::new(),
summary: None,
pointer: None,
content: "ready check".to_string(),
tokens: 0,
metadata: serde_json::json!({ "peer_id": "peer", "occurred_at_ms": EVAL_EPOCH_MS }),
}],
tokens_used: 0,
truncated: false,
resolution_used: crate::cognition::rag_budget::ResolutionPreference::Raw,
};
let mut warm = false;
for _ in 0..15u32 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ pub async fn apply_act(
},
status: ActStatus::Executed,
};
observation.push_str(&obs.render_recency(intent, &budget));
observation.push_str(&obs.render_recency(intent));
recall_observation.push_str(&obs.render_recall(intent));
// (The canvas feed publishes at the tool-executor seam, PRE-fold — a
// flood-sized ObserveResult here is already a spilled preview that no
Expand Down
18 changes: 6 additions & 12 deletions core/continuum-cognition/src/cognition/act_observe/observation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use serde::{Deserialize, Serialize};
use ts_rs::TS;

use crate::ai::types::{ToolCall, ToolResult};
use crate::cognition::context_budget::ContextBudget;

use super::recency::{
humanize_result_content, render_act_for_recall,
Expand Down Expand Up @@ -264,23 +263,18 @@ impl Observation {
/// #205 KV-stability invariant. `intent` is batch-level (one per `apply_act`
/// call, shared by every act in the batch), so it is passed rather than
/// stored per-`Observation`.
pub fn render_recency(&self, intent: &str, budget: &ContextBudget) -> String {
Self::render_recency_impl(self, intent, budget)
}

fn render_recency_impl(&self, intent: &str, budget: &ContextBudget) -> String {
let fold = Some(budget.echoed_arg_chars());
let args = summarize_args_for_recency(&self.call.input, fold);
pub fn render_recency(&self, intent: &str) -> String {
let args = summarize_args_for_recency(&self.call.input);
// The intent rides the result as a ONE-LINE reason, clipped to the same
// window-relative echo budget the args get — never the whole monologue.
// fixed echo bound the args get (ECHOED_ARG_CHARS) — never the whole monologue.
// Measured 2026-09-04: one result header carried 2,902 chars of intent
// ("Let me get oriented…") ahead of 790 chars of actual output; across a
// turn, 6.1k of 20.6k result chars were intent echo. The output is what
// she must read; the reason is a label.
let because = if intent.trim().is_empty() {
String::new()
} else {
format!(" because {}", clip_intent(intent, budget.echoed_arg_chars()))
format!(" because {}", clip_intent(intent, super::recency::ECHOED_ARG_CHARS))
};
format!(
"{}({}){}\nResult:\n{}\n\n",
Expand All @@ -295,8 +289,8 @@ impl Observation {
/// args, the same fold) over its HUMANIZED body at `level` (its summary, else whole), so a
/// summary reads what the receipt shows her, never the executor's serialized JSON, where a
/// read's numbered lines are escaped and no code level is found (Codex on #5424).
pub(crate) fn render_summary_part(&self, budget: &ContextBudget, level: impl Fn(&str) -> Option<String>) -> String {
let args = summarize_args_for_recency(&self.call.input, Some(budget.echoed_arg_chars()));
pub(crate) fn render_summary_part(&self, level: impl Fn(&str) -> Option<String>) -> String {
let args = summarize_args_for_recency(&self.call.input);
let body = self.body_text();
let body = body.trim();
let shown = level(body).unwrap_or_else(|| body.to_owned()); // unwrap_or: a body with no smaller level is its own summary
Expand Down
35 changes: 14 additions & 21 deletions core/continuum-cognition/src/cognition/act_observe/recency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ pub(super) fn humanize_result_content(raw: &str) -> String {
}
}

/// How much of one argument she wrote is echoed back in its result's header, and of the
/// intent line beside it. A rule for showing her own words, which her tool call already
/// carries whole, never a share of the window: the recall sibling below is a constant for
/// the same reason. It was a fixed 600 before it became `ContextBudget::echoed_arg_chars`
/// (a 64th of the window, a second budget her view's allocation never saw).
pub(super) const ECHOED_ARG_CHARS: usize = 600;

/// Collapse tool ARGS for the RECENCY channel (working memory).
///
/// The recall path has collapsed big args since it was written — `summarize_args_for_recall`
Expand All @@ -90,18 +97,11 @@ pub(super) fn humanize_result_content(raw: &str) -> String {
/// into working memory as ARGS, ahead of the `EDIT REFUSED` result carrying the diagnostic she
/// needed. On a 16k-token lane there is no room left for the diagnosis to survive.
///
/// Deliberately MUCH more generous than the recall bound (600 vs 80 chars): recency is shown
/// once and she may genuinely need to see the edit she just issued. Only a pathological
/// whole-file paste collapses.
///
/// `budget` is `None` when the live window is UNKNOWN (no model binding). Then nothing folds.
/// An unknown window must never become an invented one — that is how a guess turns into a
/// clamp that outlives the guess.
pub(super) fn summarize_args_for_recency(
args: &serde_json::Value,
budget: Option<usize>,
) -> String {
let fold_at = budget.unwrap_or(usize::MAX);
/// Deliberately MUCH more generous than the recall bound ([`ECHOED_ARG_CHARS`] vs 80 chars):
/// recency is shown once and she may genuinely need to see the edit she just issued. Only a
/// pathological whole-file paste collapses.
pub(super) fn summarize_args_for_recency(args: &serde_json::Value) -> String {
let fold_at = ECHOED_ARG_CHARS;
match args {
serde_json::Value::Object(map) => map
.iter()
Expand Down Expand Up @@ -211,7 +211,6 @@ pub(super) fn render_act_for_recall(

#[cfg(test)]
mod tests {
use crate::cognition::context_budget::ContextBudget;
use crate::sdk_codegen::{ActVerdict, ToolVerdict};
/// The two pre-#4352 states this file used to take as a bare bool.
const OK_V: ActVerdict = ActVerdict::Declared(ToolVerdict::Succeeded);
Expand Down Expand Up @@ -372,10 +371,7 @@ mod tests {
fn a_whole_file_arg_is_not_echoed_back_ahead_of_the_result() {
let whole_file = "x = 1\n".repeat(4000); // ~24k chars, a real source file
let args = serde_json::json!({ "file_path": "sympy/core/basic.py", "content": whole_file });
let rendered = summarize_args_for_recency(
&args,
Some(ContextBudget::from_window(16_384).echoed_arg_chars()),
);
let rendered = summarize_args_for_recency(&args);
assert!(
rendered.chars().count() < 400,
"a whole-file arg must collapse, not flood: {} chars",
Expand All @@ -396,10 +392,7 @@ mod tests {
"file_path": "a.py",
"new_content": "def f():\n return refine_arg(x)\n"
});
let kept = summarize_args_for_recency(
&small,
Some(ContextBudget::from_window(16_384).echoed_arg_chars()),
);
let kept = summarize_args_for_recency(&small);
assert!(
kept.contains("refine_arg"),
"an ordinary edit stays visible verbatim: {kept}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,9 @@ pub async fn settle_step(
// read the typed acts (verb + paths) off these entries, not receipt prose,
// so they survive the seam-5 live-drift the `I ran …` scans died on.
let pre_settle = body.working_memory.recent_entries();
let head: String = text
.chars()
.take(body.working_memory.budget().trail_head_chars())
.collect();
body.working_memory.record_settlement(&head, Some(ws.activity_room_id));
// Whole: what of it her trail shows is the trail's levels in her view's one
// allocation, never a head cut at a window share here (FLOW §2d).
body.working_memory.record_settlement(&text, Some(ws.activity_room_id));
// Unfulfilled-promise backstop (#122): a Speak that NARRATES action
// (first-person intent + fence) which nothing lifted/executed —
// reaching this arm means no format recognized it — leaves her
Expand Down
74 changes: 23 additions & 51 deletions core/continuum-cognition/src/cognition/cached_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
//! event, workspace-map until one of the persona's own write receipts. The owner
//! who constructs the wrap holds a [`DirtyHandle`] and connects it to that event;
//! `deliver` never re-fetches on the compose path unless dirty (or the cache
//! genuinely cannot answer: different room, or a bigger budget could yield more
//! from a source that truncated). No benchmark/drive mode — an exam composes fast
//! genuinely cannot answer: a different room). No benchmark/drive mode — an exam composes fast
//! because nothing it depends on changes, a live room gets the same win because
//! rosters and doctrine barely change there either.
//!
Expand All @@ -31,9 +30,7 @@ use std::sync::Arc;

use async_trait::async_trait;

use crate::cognition::rag_budget::{
RagContext, RagDelivery, RagSource, ResolutionPreference,
};
use crate::cognition::rag_budget::{RagContext, RagDelivery, RagSource};

/// The invalidation lever the OWNER wires to the source's change event.
/// Cloneable and cheap; `mark()` from any thread/task.
Expand Down Expand Up @@ -107,14 +104,12 @@ impl CachedRagSource {
/// Can `cached` answer THIS call without a fetch?
///
/// - Same room (a projection is room-scoped state).
/// - It fits the budget (`tokens_used <= budget`).
/// - It is COMPLETE (`!truncated`) **or** the budget hasn't grown past what
/// it was able to spend — a truncated delivery under a bigger budget
/// could legitimately yield more, so it re-fetches.
fn answers(cached: &CachedDelivery, room: Option<uuid::Uuid>, budget: u32) -> bool {
/// - Not invalidated (the caller checks `dirty` before asking).
///
/// A source is never handed a size, so a delivery is not budget-shaped and
/// `truncated` is the source's own fetch limit: neither changes the answer.
fn answers(cached: &CachedDelivery, room: Option<uuid::Uuid>) -> bool {
cached.room == room
&& cached.delivery.tokens_used <= budget
&& (!cached.delivery.truncated || budget <= cached.delivery.tokens_used)
}
}

Expand All @@ -132,25 +127,12 @@ impl RagSource for CachedRagSource {
self.inner.expand_command()
}

fn floor_tokens(&self) -> u32 {
self.inner.floor_tokens()
}

fn budget_claim(&self, window: u32, headroom: u32) -> crate::cognition::rag_budget::RagSourceBudget {
self.inner.budget_claim(window, headroom)
}

async fn deliver(
&self,
ctx: &RagContext,
budget: u32,
resolution: ResolutionPreference,
) -> RagDelivery {
async fn deliver(&self, ctx: &RagContext) -> RagDelivery {
let room = ctx.airc_room.as_ref().map(|r| r.as_uuid());
let mut guard = self.last_good.lock().await;
if !self.dirty.load(Ordering::SeqCst) {
if let Some(cached) = guard.as_ref() {
if Self::answers(cached, room, budget) {
if Self::answers(cached, room) {
return cached.delivery.clone();
}
}
Expand All @@ -159,7 +141,7 @@ impl RagSource for CachedRagSource {
// an event landing mid-fetch must not be lost (swap-then-check would
// serve a projection already known stale).
self.dirty.store(false, Ordering::SeqCst);
let delivery = self.inner.deliver(ctx, budget, resolution).await;
let delivery = self.inner.deliver(ctx).await;
*guard = Some(CachedDelivery {
delivery: delivery.clone(),
room,
Expand Down Expand Up @@ -187,27 +169,17 @@ mod tests {
fn expand_command(&self) -> Option<&'static str> {
None
}
fn floor_tokens(&self) -> u32 {
1
}
async fn deliver(
&self,
_ctx: &RagContext,
_budget: u32,
_resolution: ResolutionPreference,
) -> RagDelivery {
async fn deliver(&self, _ctx: &RagContext) -> RagDelivery {
let n = self.fetches.fetch_add(1, Ordering::SeqCst) + 1;
RagDelivery {
source_id: "counting".to_string(),
items: vec![crate::cognition::rag_budget::RagItem {
content: format!("fetch #{n}"),
tokens: 4,
metadata: serde_json::json!({}),
}],
tokens_used: 4,
truncated: false,
resolution_used: ResolutionPreference::Raw,
}
RagDelivery::of(
"counting",
vec![crate::cognition::rag_budget::RagItem::whole(
"counting",
format!("fetch #{n}"),
serde_json::json!({}),
)],
false,
)
}
}

Expand All @@ -225,7 +197,7 @@ mod tests {
let ctx = RagContext::for_persona(me, 0);

for _ in 0..5 {
let d = cached.deliver(&ctx, 100, ResolutionPreference::Raw).await;
let d = cached.deliver(&ctx).await;
assert_eq!(
d.items[0].content, "fetch #1",
"unchanged world → cached projection"
Expand All @@ -238,7 +210,7 @@ mod tests {
);

dirty.mark();
let d = cached.deliver(&ctx, 100, ResolutionPreference::Raw).await;
let d = cached.deliver(&ctx).await;
assert_eq!(
d.items[0].content, "fetch #2",
"dirty → exactly one refetch"
Expand All @@ -247,7 +219,7 @@ mod tests {

// A DIFFERENT room must not see this room's projection (exam-bleed class).
let other = RagContext::for_persona_in_room(me, 0, uuid::Uuid::new_v4());
let d = cached.deliver(&other, 100, ResolutionPreference::Raw).await;
let d = cached.deliver(&other).await;
assert_eq!(
d.items[0].content, "fetch #3",
"room switch → fresh fetch, never bleed"
Expand Down
4 changes: 2 additions & 2 deletions core/continuum-cognition/src/cognition/channel_digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ mod tests {
"first sight splits one page back — the seed the caller then persists"
);

// Now the DELIVERY step marks what she was shown as read — what
// `AircRagSource::deliver` does with the packed read-through lamport. The
// Now her read receipt marks what a sent prompt showed her as read — what
// `AircRagSource::mark_read` does after the deliberation faculty sends. The
// seed bounds the page; the advance consumes it. Both halves are needed,
// and together the room goes QUIET with nothing new. Before the fix, the
// whole transcript came back as unread on every single turn forever.
Expand Down
Loading
Loading