Skip to main content

Module delegation

Module delegation 

Source
Expand description

CADMAS-CTX delegation posteriors (arXiv:2604.17950).

§Role

Static per-agent skill scores are provably lossy when capability is context-conditional (linear regret Ω(ε · P(z₀) · T)). CADMAS-CTX replaces them with a hierarchy of per-(agent, skill, bucket) Beta posteriors scored under a risk-aware LCB, achieving O(log T) regret. This module is the Phase C scaffolding for that replacement on codetether’s internal routing surfaces (choose_router_target, swarm / ralph dispatch, RLM model selection, autochat persona pick).

§Scope in Phase C step 16

Types + math + sidecar-compatible serialisation, with no live consumers yet. The go/no-go experiment in choose_router_target lands in a follow-up commit (Phase C step 17) once these primitives are stable.

§Invariants

  • State lives only in the sidecar — never in DerivedContext. Capability history is not chat context either.
  • Updates are Beta-Bernoulli conjugate; no ML-style training.
  • Cold-start shrinkage is bounded by m_z ≤ 2 per the paper.

§Examples

use codetether_agent::session::delegation::{
    BetaPosterior, DelegationConfig, DelegationState,
};
use codetether_agent::session::relevance::{Bucket, Dependency, Difficulty, ToolUse};

let bucket = Bucket {
    difficulty: Difficulty::Easy,
    dependency: Dependency::Isolated,
    tool_use: ToolUse::No,
};

let mut state = DelegationState::with_config(DelegationConfig::default());
state.update("openai", "model_call", bucket, true);
state.update("openai", "model_call", bucket, true);
state.update("openai", "model_call", bucket, false);

let score = state.score("openai", "model_call", bucket);
assert!(score.is_some());

Structs§

BetaPosterior
Per-(agent, skill, bucket) Beta-Bernoulli posterior.
DelegationConfig
Tunable knobs for DelegationState.
DelegationState
Per-session CADMAS-CTX sidecar.

Constants§

DEFAULT_DELTA
Default delegation margin δ.
DEFAULT_GAMMA
Default uncertainty penalty γ for LCB scoring.
DEFAULT_KAPPA
Default weak-prior strength κ used to seed posteriors from self-declared confidence.
DEFAULT_LAMBDA
Default forgetting factor λ applied on each update.

Type Aliases§

BeliefKey
Key for DelegationState::beliefs. Stored as owned strings so the map serialises cleanly and survives across process boundaries.