Merge origin/main (cut 0 connector v4, cut 1a vault snapshots) into the seeded-Begin branch; the dungeon crate moves to model-connector types and drops codex-connector

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-12-02 20:04:35 +01:00
commit 47b174844a
19 changed files with 2378 additions and 645 deletions

275
Cargo.lock generated
View file

@ -61,6 +61,15 @@ version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
[[package]]
name = "ar_archive_writer"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "523e5e187fff36fcb8d1d19ccf0ca4ca43ec3d158316057f66dc6f72716bc5ec"
dependencies = [
"object",
]
[[package]]
name = "async-stream"
version = "0.3.6"
@ -176,12 +185,6 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "base64"
version = "0.23.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
[[package]]
name = "base64ct"
version = "1.8.3"
@ -272,22 +275,6 @@ dependencies = [
"inout",
]
[[package]]
name = "codex-connector"
version = "0.1.0"
source = "git+https://github.com/GameCult/CodexConnector.git?rev=68fe94b9475823de92ed766a97ea962d48723708#68fe94b9475823de92ed766a97ea962d48723708"
dependencies = [
"aes-gcm",
"base64 0.23.1",
"rand_core 0.6.4",
"rmp-serde",
"serde",
"serde_json",
"sha2",
"thiserror",
"zeroize",
]
[[package]]
name = "const-oid"
version = "0.9.6"
@ -345,7 +332,7 @@ source = "git+https://github.com/GameCult/CultLib.git?rev=85f7024a35ea42cf9f0a01
dependencies = [
"anyhow",
"chrono",
"cultcache-rs-derive",
"cultcache-rs-derive 0.1.0",
"fs2",
"redb",
"rmp-serde",
@ -356,6 +343,26 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "cultcache-rs"
version = "0.3.1"
source = "git+https://github.com/GameCult/CultLib.git?rev=a4eae9056152335662f1115f97bf35fb00ab6d23#a4eae9056152335662f1115f97bf35fb00ab6d23"
dependencies = [
"anyhow",
"chrono",
"cultcache-rs-derive 0.2.0",
"fs2",
"redb",
"rmp-serde",
"serde",
"serde_bytes",
"serde_json",
"serde_stacker",
"stacker",
"uuid",
"windows-sys 0.59.0",
]
[[package]]
name = "cultcache-rs-derive"
version = "0.1.0"
@ -366,14 +373,24 @@ dependencies = [
"syn 2.0.119",
]
[[package]]
name = "cultcache-rs-derive"
version = "0.2.0"
source = "git+https://github.com/GameCult/CultLib.git?rev=a4eae9056152335662f1115f97bf35fb00ab6d23#a4eae9056152335662f1115f97bf35fb00ab6d23"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "cultmesh-rs"
version = "0.1.0"
source = "git+https://github.com/GameCult/CultLib.git?rev=85f7024a35ea42cf9f0a0199a064526427150191#85f7024a35ea42cf9f0a0199a064526427150191"
dependencies = [
"anyhow",
"cultcache-rs",
"cultnet-rs",
"cultcache-rs 0.1.0",
"cultnet-rs 0.1.0",
"serde",
]
@ -384,9 +401,34 @@ source = "git+https://github.com/GameCult/CultLib.git?rev=85f7024a35ea42cf9f0a01
dependencies = [
"aes-gcm",
"anyhow",
"base64 0.22.1",
"base64",
"chrono",
"cultcache-rs",
"cultcache-rs 0.1.0",
"ed25519-dalek",
"hmac",
"rand 0.9.5",
"rmp-serde",
"rmpv",
"serde",
"serde_bytes",
"serde_json",
"sha2",
"socket2 0.5.10",
"uuid",
"windows-sys 0.61.2",
"zeroize",
]
[[package]]
name = "cultnet-rs"
version = "0.2.0"
source = "git+https://github.com/GameCult/CultLib.git?rev=a4eae9056152335662f1115f97bf35fb00ab6d23#a4eae9056152335662f1115f97bf35fb00ab6d23"
dependencies = [
"aes-gcm",
"anyhow",
"base64",
"chrono",
"cultcache-rs 0.3.1",
"ed25519-dalek",
"hmac",
"rand 0.9.5",
@ -441,9 +483,9 @@ dependencies = [
[[package]]
name = "deranged"
version = "0.5.8"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e"
[[package]]
name = "digest"
@ -467,6 +509,12 @@ dependencies = [
"syn 3.0.3",
]
[[package]]
name = "dyn-clone"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555"
[[package]]
name = "ed25519"
version = "2.2.3"
@ -663,9 +711,9 @@ version = "0.1.0"
dependencies = [
"async-trait",
"chrono",
"codex-connector",
"cultcache-rs",
"cultcache-rs 0.1.0",
"ghostlight-persona-projection",
"model-connector",
"reqwest",
"rmp-serde",
"rmpv",
@ -692,17 +740,17 @@ dependencies = [
"async-stream",
"async-trait",
"axum",
"base64 0.22.1",
"base64",
"chrono",
"codex-connector",
"cultcache-rs",
"cultcache-rs 0.1.0",
"cultmesh-rs",
"cultnet-rs",
"cultnet-rs 0.1.0",
"ghostlight",
"ghostlight-persona-projection",
"hmac",
"jsonwebtoken",
"libc",
"model-connector",
"rand 0.9.5",
"reqwest",
"rmp-serde",
@ -837,7 +885,7 @@ version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0"
dependencies = [
"base64 0.22.1",
"base64",
"bytes",
"futures-channel",
"futures-util",
@ -1020,7 +1068,7 @@ version = "9.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a87cc7a48537badeae96744432de36f4be2b4a34a05a5ef32e9dd8a1c169dde"
dependencies = [
"base64 0.22.1",
"base64",
"js-sys",
"pem",
"ring",
@ -1031,9 +1079,9 @@ dependencies = [
[[package]]
name = "lazy_static"
version = "1.5.0"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
[[package]]
name = "libc"
@ -1097,9 +1145,9 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
[[package]]
name = "mime"
version = "0.3.17"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
checksum = "d5848f5a9e8117cf94f2f90faac24a87ff81600ff8628c1e3deaab572e76bfa1"
[[package]]
name = "mio"
@ -1112,6 +1160,26 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "model-connector"
version = "0.1.0"
source = "git+https://eureka.gamecult.org/forge/GameCult/ModelConnector.git?rev=edf2f8e03cbb61df385b9b145b46f676ce3b70d5#edf2f8e03cbb61df385b9b145b46f676ce3b70d5"
dependencies = [
"aes-gcm",
"base64",
"cultnet-rs 0.2.0",
"rand_core 0.6.4",
"rmp-serde",
"rmpv",
"schemars",
"serde",
"serde_bytes",
"serde_json",
"sha2",
"thiserror",
"zeroize",
]
[[package]]
name = "nu-ansi-term"
version = "0.50.3"
@ -1155,6 +1223,15 @@ dependencies = [
"autocfg",
]
[[package]]
name = "object"
version = "0.39.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e5a6c098c7a3b6547378093f5cc30bc54fd361ce711e05293a5cc589562739b"
dependencies = [
"memchr",
]
[[package]]
name = "once_cell"
version = "1.21.4"
@ -1196,7 +1273,7 @@ version = "3.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be"
dependencies = [
"base64 0.22.1",
"base64",
"serde_core",
]
@ -1245,9 +1322,9 @@ dependencies = [
[[package]]
name = "powerfmt"
version = "0.2.0"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958"
[[package]]
name = "ppv-lite86"
@ -1267,6 +1344,16 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "psm"
version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dcd034599e63b970727f70d79e02d62390a4a84f7c6b827c27c46d5ac3fa622"
dependencies = [
"ar_archive_writer",
"cc",
]
[[package]]
name = "quinn"
version = "0.11.11"
@ -1427,10 +1514,30 @@ dependencies = [
]
[[package]]
name = "regex-automata"
version = "0.4.18"
name = "ref-cast"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3"
dependencies = [
"ref-cast-impl",
]
[[package]]
name = "ref-cast-impl"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.3",
]
[[package]]
name = "regex-automata"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158"
dependencies = [
"aho-corasick",
"memchr",
@ -1439,9 +1546,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.8.11"
version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6"
[[package]]
name = "reqwest"
@ -1449,7 +1556,7 @@ version = "0.12.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147"
dependencies = [
"base64 0.22.1",
"base64",
"bytes",
"futures-core",
"futures-util",
@ -1603,6 +1710,31 @@ version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
[[package]]
name = "schemars"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab508826f74a77ca9d5aba6ff19b522583ee3eaf28a19384ff3d0e5835fadf6e"
dependencies = [
"dyn-clone",
"ref-cast",
"schemars_derive",
"serde",
"serde_json",
]
[[package]]
name = "schemars_derive"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1c3a92094fa7d61aa124645844facb6b554dfc797136d0f5fd1f890e2bffc69"
dependencies = [
"proc-macro2",
"quote",
"serde_derive_internals",
"syn 3.0.3",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
@ -1655,6 +1787,17 @@ dependencies = [
"syn 3.0.3",
]
[[package]]
name = "serde_derive_internals"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f852137cce035d6a4df67ccce505ff6b3e9fd3a10e3e52b24dc71e650bb1a9bd"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.3",
]
[[package]]
name = "serde_json"
version = "1.0.151"
@ -1679,6 +1822,17 @@ dependencies = [
"serde_core",
]
[[package]]
name = "serde_stacker"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4936375d50c4be7eff22293a9344f8e46f323ed2b3c243e52f89138d9bb0f4a"
dependencies = [
"serde",
"serde_core",
"stacker",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@ -1796,6 +1950,19 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
[[package]]
name = "stacker"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "707f49d46706bacf8a2b00d51dace3f9de527c13eec3778f570c411f89e69967"
dependencies = [
"cc",
"cfg-if",
"libc",
"psm",
"windows-sys 0.61.2",
]
[[package]]
name = "subtle"
version = "2.6.1"
@ -2527,18 +2694,18 @@ dependencies = [
[[package]]
name = "zerocopy"
version = "0.8.56"
version = "0.8.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "556764e583adb45a9f8d413c2a147fa7e8d821e48e12b14fd560b607998b75eb"
checksum = "cba8a86aee14fc8cc6c208af60854b3d4ab7185a9a369a12c648faa2716ff42a"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.56"
version = "0.8.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2ab42fc20575779bd240faa45f94a74256f755c0fa9e89f0ede20d91d0cdfc1"
checksum = "f89bca3b96ceb3cfcb4572790402f977442270d252b9a8504ebc258760c55f94"
dependencies = [
"proc-macro2",
"quote",

View file

@ -20,7 +20,7 @@ async-stream = "0.3"
axum = { version = "0.8", features = ["macros"] }
chrono = { version = "0.4", features = ["serde"] }
base64 = "0.22"
codex-connector = { git = "https://github.com/GameCult/CodexConnector.git", rev = "68fe94b9475823de92ed766a97ea962d48723708" }
model-connector = { git = "https://eureka.gamecult.org/forge/GameCult/ModelConnector.git", rev = "edf2f8e03cbb61df385b9b145b46f676ce3b70d5" }
cultcache-rs = { git = "https://github.com/GameCult/CultLib.git", rev = "85f7024a35ea42cf9f0a0199a064526427150191", package = "cultcache-rs" }
cultnet-rs = { git = "https://github.com/GameCult/CultLib.git", rev = "85f7024a35ea42cf9f0a0199a064526427150191", package = "cultnet-rs" }
cultmesh-rs = { git = "https://github.com/GameCult/CultLib.git", rev = "85f7024a35ea42cf9f0a0199a064526427150191", package = "cultmesh-rs" }

View file

@ -17,8 +17,8 @@ async-stream.workspace = true
axum.workspace = true
chrono.workspace = true
base64.workspace = true
codex-connector.workspace = true
cultcache-rs.workspace = true
model-connector.workspace = true
cultnet-rs.workspace = true
cultmesh-rs.workspace = true
jsonwebtoken.workspace = true

View file

@ -53,7 +53,7 @@ impl From<String> for TurnFault {
Self { detail, class: InferenceFaultClass::Unclassified }
}
}
use codex_connector::{CodexInputItem, CodexToolDefinition};
use model_connector::{InputItem, ToolDefinition};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use sha2::{Digest, Sha256};
@ -1940,7 +1940,7 @@ impl PlayTable {
snapshot: &WorldSnapshot,
dispatched: &[SubjectId],
principal: &VerifiedPrincipalEvidence,
) -> Result<Vec<CodexToolDefinition>, String> {
) -> Result<Vec<ToolDefinition>, String> {
let mut tools = authoring_tools(PLAY_TOOLS).map_err(|error| error.to_string())?;
tools.extend(control_tools());
let Some(player) = player_subject(snapshot, principal) else {
@ -2815,7 +2815,7 @@ fn handle_for(id: SubjectId) -> String {
/// vocabulary a Dungeon-only presentation concern. The id itself comes from
/// the library's own `id_text` (PA.f113) — Dungeon no longer keeps its own
/// copy of the debug-paren strip `table_view` uses to print it.
fn annotate_actor_tools(tools: &mut [CodexToolDefinition], snapshot: &WorldSnapshot, subject: SubjectId) {
fn annotate_actor_tools(tools: &mut [ToolDefinition], snapshot: &WorldSnapshot, subject: SubjectId) {
let label = subject_label(snapshot, subject);
let id = id_text(subject);
for tool in tools {
@ -2867,9 +2867,9 @@ fn actor_prefix(subject: SubjectId) -> String {
format!("{}{HANDLE_SEPARATOR}", handle_for(subject))
}
fn control_tools() -> Vec<CodexToolDefinition> {
fn control_tools() -> Vec<ToolDefinition> {
vec![
CodexToolDefinition {
ToolDefinition {
name: DISPATCH_TOOL.into(),
description: "Dispatch one or more subjects to act this round, each named by its full id \
exactly as table_view prints it in brackets — never the short <handle>__ prefix an actor tool's own \
@ -2877,17 +2877,17 @@ name carries. An id naming no dispatchable subject is refused, quoting the text
.into(),
parameters_json: r#"{"type":"object","properties":{"subjects":{"type":"array","items":{"type":"string"}}},"required":["subjects"]}"#.into(),
},
CodexToolDefinition {
ToolDefinition {
name: ADVANCE_TIME_TOOL.into(),
description: "Advance the world clock by a whole number of fictional minutes.".into(),
parameters_json: r#"{"type":"object","properties":{"minutes":{"type":"integer","minimum":1}},"required":["minutes"]}"#.into(),
},
CodexToolDefinition {
ToolDefinition {
name: ASK_PLAYER_TOOL.into(),
description: "Stop the turn and ask the player a question.".into(),
parameters_json: r#"{"type":"object","properties":{"question":{"type":"string"}},"required":["question"]}"#.into(),
},
CodexToolDefinition {
ToolDefinition {
name: END_TURN_TOOL.into(),
description: "End the turn: its consequences are settled.".into(),
parameters_json: r#"{"type":"object","properties":{},"required":[]}"#.into(),
@ -3083,8 +3083,8 @@ fn record_call(
/// fully-resolved round before `round` as `AssistantText`/`ToolCall`/`ToolResult`
/// items, exactly as `controllers.rs`'s own multi-round lanes rebuild their
/// conversation from `completed` outputs.
fn rebuild_conversation(turn: &PlayTurn, round: usize) -> Vec<CodexInputItem> {
let mut conversation = vec![CodexInputItem::UserText {
fn rebuild_conversation(turn: &PlayTurn, round: usize) -> Vec<InputItem> {
let mut conversation = vec![InputItem::UserText {
text: turn.opening_prompt.clone(),
}];
for (index, output) in turn.rounds.iter().enumerate() {
@ -3096,7 +3096,7 @@ fn rebuild_conversation(turn: &PlayTurn, round: usize) -> Vec<CodexInputItem> {
match event {
InferenceEvent::Text(text) => {
if !text.is_empty() {
conversation.push(CodexInputItem::AssistantText { text: text.clone() });
conversation.push(InputItem::AssistantText { text: text.clone() });
}
}
InferenceEvent::ToolCall {
@ -3106,7 +3106,7 @@ fn rebuild_conversation(turn: &PlayTurn, round: usize) -> Vec<CodexInputItem> {
} => {
let this_slot = slot;
slot += 1;
conversation.push(CodexInputItem::ToolCall {
conversation.push(InputItem::ToolCall {
call_id: call_id.clone(),
name: name.clone(),
arguments: arguments.clone(),
@ -3115,7 +3115,7 @@ fn rebuild_conversation(turn: &PlayTurn, round: usize) -> Vec<CodexInputItem> {
.call_record(index, this_slot)
.and_then(|call| call.result.clone())
.unwrap_or_default();
conversation.push(CodexInputItem::ToolResult {
conversation.push(InputItem::ToolResult {
call_id: call_id.clone(),
output: output_text,
});

View file

@ -341,6 +341,9 @@ fn lane_fault(error: &ControllerOpenError) -> &'static str {
"--key-file is unreadable, empty, or not one run of visible ASCII"
}
ControllerOpenError::SharedModelPrefix { .. } => "two inference lanes claim one model prefix",
ControllerOpenError::SidecarClaimsConnectorModel { .. } => {
"the SDK sidecar prefix claims a connector model"
}
ControllerOpenError::EmptyModelPrefix { .. } => "an inference lane's model prefix is empty",
}
}

View file

@ -7,7 +7,7 @@ license.workspace = true
[dependencies]
async-trait.workspace = true
chrono.workspace = true
codex-connector.workspace = true
model-connector.workspace = true
cultcache-rs.workspace = true
ghostlight-persona-projection = { path = "../ghostlight-persona-projection" }
reqwest.workspace = true

File diff suppressed because it is too large Load diff

View file

@ -33,7 +33,7 @@ use super::{
SubjectId, SubjectKind, WorldId, WorldPatch, WorldPhase, WorldSnapshot,
};
use async_trait::async_trait;
use codex_connector::CodexInputItem;
use model_connector::InputItem;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use sha2::{Digest, Sha256};
@ -349,7 +349,7 @@ pub(super) struct ElaborationCapture {
}
pub(super) enum ElaborationLoopEvaluation {
Continue { conversation: Vec<CodexInputItem> },
Continue { conversation: Vec<InputItem> },
Complete { capture: ElaborationCapture },
}
@ -1135,7 +1135,7 @@ pub(super) fn evaluate_elaboration_loop(
budget: usize,
) -> Result<ElaborationLoopEvaluation, ControllerError> {
check_refusals(refusals, completed.len())?;
let mut conversation = vec![CodexInputItem::UserText {
let mut conversation = vec![InputItem::UserText {
text: prompt.to_owned(),
}];
let mut fold = DraftFold::default();
@ -1155,7 +1155,7 @@ pub(super) fn evaluate_elaboration_loop(
match event {
InferenceEvent::Text(text) => {
if !text.is_empty() {
conversation.push(CodexInputItem::AssistantText { text: text.clone() });
conversation.push(InputItem::AssistantText { text: text.clone() });
}
}
InferenceEvent::ToolCall {
@ -1164,13 +1164,13 @@ pub(super) fn evaluate_elaboration_loop(
arguments,
} => {
called_tool = true;
conversation.push(CodexInputItem::ToolCall {
conversation.push(InputItem::ToolCall {
call_id: call_id.clone(),
name: name.clone(),
arguments: arguments.clone(),
});
let result = fold.apply(name, arguments);
conversation.push(CodexInputItem::ToolResult {
conversation.push(InputItem::ToolResult {
call_id: call_id.clone(),
output: result,
});
@ -1187,7 +1187,7 @@ pub(super) fn evaluate_elaboration_loop(
"a refusal follows a round that submitted nothing".into(),
));
}
conversation.push(CodexInputItem::UserText {
conversation.push(InputItem::UserText {
text: render_refusal(&refusal.mismatches),
});
fold = DraftFold::default();
@ -1439,7 +1439,7 @@ pub(super) fn elaboration_request(
round: usize,
model: &str,
instructions: &str,
input: Vec<CodexInputItem>,
input: Vec<InputItem>,
) -> Result<InferenceRequest, ControllerError> {
tool_request(
command_id,
@ -2035,7 +2035,7 @@ fn seed_request(
command_id: CommandId,
round: usize,
model: &str,
input: Vec<CodexInputItem>,
input: Vec<InputItem>,
) -> Result<InferenceRequest, ControllerError> {
tool_request(
command_id,
@ -2213,7 +2213,7 @@ mod tests {
let recomputed: Vec<String> = conversation
.iter()
.filter_map(|item| match item {
CodexInputItem::ToolResult { output, .. } => Some(output.clone()),
InputItem::ToolResult { output, .. } => Some(output.clone()),
_ => None,
})
.collect();
@ -2389,13 +2389,13 @@ mod tests {
.unwrap() else {
panic!("a refused round finalized instead of reopening");
};
let CodexInputItem::UserText { text } = conversation.last().unwrap() else {
let InputItem::UserText { text } = conversation.last().unwrap() else {
panic!("the refusal is not the next user turn");
};
assert!(text.contains("The world refused the patch you submitted"));
assert!(text.contains(&render_mismatch(&Mismatch::NoCanonicalChange)));
assert!(
matches!(&conversation[1], CodexInputItem::ToolCall { name, .. } if name == "declare_place"),
matches!(&conversation[1], InputItem::ToolCall { name, .. } if name == "declare_place"),
"the refused round's calls left the conversation"
);
assert_eq!(

View file

@ -143,7 +143,10 @@ pub use table::{
decode_authoring_call, decode_authoring_calls, describe_refusal, describe_refusal_to_actor,
id_text, id_text_matches, table_view,
};
pub use vault::{VaultError, VaultEvidenceSource};
pub use vault::{
ImportOutcome, SnapshotId, VAULT_PROFILE_SCHEMA, VAULT_SNAPSHOT_SCHEMA, VaultError,
VaultEvidenceSource, VaultProfile, VaultSnapshot,
};
pub use verse::{
CALL_RECORD_SCHEMA, CallRecordError, CallRecordStore, CreateVerseWorldIntent, ProviderCallRecord,
RUN_RECORD_SCHEMA, RecordedCoverBudget, RecordingInferencePort, Refusal, RefusalReason, RunClaim,

View file

@ -17,7 +17,7 @@ use super::controllers::{
call_id_is_valid, tool_name_is_valid, unix_ms,
};
use async_trait::async_trait;
use codex_connector::CodexInputItem;
use model_connector::InputItem;
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use sha2::{Digest, Sha256};
@ -334,9 +334,9 @@ fn lower_request(prepared: &PreparedInference, prefix: &str) -> Result<Value, In
let mut messages = vec![json!({"role": "system", "content": request.instructions})];
for item in &request.input {
messages.push(match item {
CodexInputItem::UserText { text } => json!({"role": "user", "content": text}),
CodexInputItem::AssistantText { text } => json!({"role": "assistant", "content": text}),
CodexInputItem::ToolCall {
InputItem::UserText { text } => json!({"role": "user", "content": text}),
InputItem::AssistantText { text } => json!({"role": "assistant", "content": text}),
InputItem::ToolCall {
call_id,
name,
arguments,
@ -349,11 +349,18 @@ fn lower_request(prepared: &PreparedInference, prefix: &str) -> Result<Value, In
"function": {"name": name, "arguments": arguments},
}],
}),
CodexInputItem::ToolResult { call_id, output } => json!({
InputItem::ToolResult { call_id, output } => json!({
"role": "tool",
"tool_call_id": call_id,
"content": output,
}),
// Ghostlight replays no provider state, and an OpenAI-compatible
// server has no place for one.
InputItem::ReasoningState { .. } => {
return Err(InferenceFault::integrity_violation(
"a local request carried provider reasoning state",
));
}
});
}
let mut tools = Vec::with_capacity(request.tools.len());
@ -379,9 +386,7 @@ fn lower_request(prepared: &PreparedInference, prefix: &str) -> Result<Value, In
body["tools"] = json!(tools);
body["parallel_tool_calls"] = json!(request.parallel_tool_calls);
}
if let Some(max_tokens) = request.max_output_tokens {
body["max_tokens"] = json!(max_tokens);
}
body["max_tokens"] = json!(request.max_output_tokens);
Ok(body)
}
@ -570,7 +575,7 @@ mod tests {
use crate::patch::{RECORD_GAP_PATCH_TOOL, SUBMIT_PATCH_TOOL, patch_tools};
use crate::sdk_inference::{DEFAULT_SDK_MODEL_PREFIX, RoutedInferencePort, SdkBinding};
use crate::CommandId;
use codex_connector::CodexToolDefinition;
use model_connector::ToolDefinition;
use std::collections::VecDeque;
use std::sync::{Mutex, OnceLock};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
@ -822,7 +827,7 @@ mod tests {
InferencePurpose::Elaboration,
TEST_MODEL,
"Author the shortfall.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: prompt.into(),
}],
patch_tools(),
@ -889,18 +894,18 @@ mod tests {
TEST_MODEL,
"Only reply once every item is accounted for.",
vec![
CodexInputItem::UserText {
InputItem::UserText {
text: "Open the gate.".into(),
},
CodexInputItem::AssistantText {
InputItem::AssistantText {
text: "Checking the ledger.".into(),
},
CodexInputItem::ToolCall {
InputItem::ToolCall {
call_id: "call-9".into(),
name: RECORD_GAP_PATCH_TOOL.into(),
arguments: r#"{"detail":"no ledger entry"}"#.into(),
},
CodexInputItem::ToolResult {
InputItem::ToolResult {
call_id: "call-9".into(),
output: "gap recorded".into(),
},
@ -1005,7 +1010,7 @@ mod tests {
InferencePurpose::Elaboration,
TEST_MODEL,
"Author the shortfall.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Author the shortfall.".into(),
}],
patch_tools(),
@ -1083,10 +1088,10 @@ mod tests {
InferencePurpose::Persona,
TEST_MODEL,
"Respond only in natural prose.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Say something true.".into(),
}],
Vec::<CodexToolDefinition>::new(),
Vec::<ToolDefinition>::new(),
RequestShape {
max_output_tokens: 1_200,
parallel_tool_calls: false,
@ -1119,10 +1124,10 @@ mod tests {
InferencePurpose::Persona,
TEST_MODEL,
"Respond only in natural prose.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Say something true.".into(),
}],
Vec::<CodexToolDefinition>::new(),
Vec::<ToolDefinition>::new(),
RequestShape {
max_output_tokens: 1_200,
parallel_tool_calls: false,
@ -1194,10 +1199,10 @@ mod tests {
InferencePurpose::Persona,
TEST_MODEL,
"Respond only in natural prose.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Say something true.".into(),
}],
Vec::<CodexToolDefinition>::new(),
Vec::<ToolDefinition>::new(),
RequestShape {
max_output_tokens: 1_200,
parallel_tool_calls: false,
@ -1232,10 +1237,10 @@ mod tests {
InferencePurpose::Persona,
TEST_MODEL,
"Respond only in natural prose.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Say something true.".into(),
}],
Vec::<CodexToolDefinition>::new(),
Vec::<ToolDefinition>::new(),
RequestShape {
max_output_tokens: 1_200,
parallel_tool_calls: false,
@ -1400,7 +1405,7 @@ mod tests {
InferencePurpose::Elaboration,
TEST_MODEL,
"Author the shortfall.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Author the shortfall.".into(),
}],
patch_tools(),
@ -1428,10 +1433,10 @@ mod tests {
InferencePurpose::Persona,
TEST_MODEL,
"Respond only in natural prose.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Say something true.".into(),
}],
Vec::<CodexToolDefinition>::new(),
Vec::<ToolDefinition>::new(),
RequestShape {
max_output_tokens: 1_200,
parallel_tool_calls: false,
@ -1460,7 +1465,7 @@ mod tests {
InferencePurpose::Elaboration,
TEST_MODEL,
"Author the shortfall.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Author the shortfall.".into(),
}],
patch_tools(),
@ -1493,10 +1498,10 @@ mod tests {
InferencePurpose::Persona,
TEST_MODEL,
"Respond only in natural prose.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Say something true.".into(),
}],
Vec::<CodexToolDefinition>::new(),
Vec::<ToolDefinition>::new(),
RequestShape {
max_output_tokens: 1_200,
parallel_tool_calls: false,
@ -1526,10 +1531,10 @@ mod tests {
InferencePurpose::Persona,
TEST_MODEL,
"Respond only in natural prose.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Say something true.".into(),
}],
Vec::<CodexToolDefinition>::new(),
Vec::<ToolDefinition>::new(),
RequestShape {
max_output_tokens: 1_200,
parallel_tool_calls: false,
@ -1558,10 +1563,10 @@ mod tests {
InferencePurpose::Persona,
TEST_MODEL,
"Respond only in natural prose.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Say something true.".into(),
}],
Vec::<CodexToolDefinition>::new(),
Vec::<ToolDefinition>::new(),
RequestShape {
max_output_tokens: 1_200,
parallel_tool_calls: false,
@ -1588,10 +1593,10 @@ mod tests {
InferencePurpose::Persona,
TEST_MODEL,
"Respond only in natural prose.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Say something true.".into(),
}],
Vec::<CodexToolDefinition>::new(),
Vec::<ToolDefinition>::new(),
RequestShape {
max_output_tokens: 1_200,
parallel_tool_calls: false,
@ -1624,10 +1629,10 @@ mod tests {
InferencePurpose::Persona,
TEST_MODEL,
"Respond only in natural prose.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Say something true.".into(),
}],
Vec::<CodexToolDefinition>::new(),
Vec::<ToolDefinition>::new(),
RequestShape {
max_output_tokens: 1_200,
parallel_tool_calls: false,
@ -2054,8 +2059,8 @@ mod tests {
InferencePurpose::Persona,
"hosted/deepseek-chat",
"Respond only in natural prose.",
vec![CodexInputItem::UserText { text: "Say something true.".into() }],
Vec::<CodexToolDefinition>::new(),
vec![InputItem::UserText { text: "Say something true.".into() }],
Vec::<ToolDefinition>::new(),
RequestShape { max_output_tokens: 1_200, parallel_tool_calls: false },
)
.expect("the request builds");

View file

@ -18,7 +18,7 @@ use super::{
AffordanceId, CommandId, ControllerAssignment, ControllerId, EdgeId, EntityId, LensWeights,
NewController, SubjectId, SubjectKind, SubjectState, WorldId,
};
use codex_connector::CodexToolDefinition;
use model_connector::ToolDefinition;
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use sha2::{Digest, Sha256};
@ -6726,7 +6726,7 @@ pub(crate) const PATCH_TOOLS: &[PatchTool] = &[
/// The catalog. Fixed per build: it reads `PATCH_TOOLS` and nothing else — not
/// world state, not a snapshot, not a config.
pub(crate) fn patch_tools() -> Vec<CodexToolDefinition> {
pub(crate) fn patch_tools() -> Vec<ToolDefinition> {
PATCH_TOOLS
.iter()
.map(|entry| {

View file

@ -12,7 +12,7 @@ use super::controllers::{
tool_name_is_valid, unix_ms,
};
use async_trait::async_trait;
use codex_connector::CodexInputItem;
use model_connector::{InputItem, ReasoningEffort};
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use std::collections::BTreeMap;
@ -29,10 +29,6 @@ use tokio::sync::Mutex as AsyncMutex;
/// largest request either transport carries is the same grouped cell.
pub(super) const MAX_SIDECAR_FRAME_BYTES: usize = 1_052_672;
/// The reasoning-effort values the SDK's own `EffortLevel` admits. A request
/// carrying anything else is refused rather than silently mis-mapped.
const SDK_EFFORT_LEVELS: [&str; 5] = ["low", "medium", "high", "xhigh", "max"];
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub(super) enum SidecarFrame {
@ -379,9 +375,9 @@ struct SdkInferenceReceipt {
const SDK_RECEIPT_SCHEMA: &str = "ghostlight.sdk_inference_receipt.v1";
/// The model-name prefix that names the SDK transport when nothing configures
/// one. It holds even with no SDK port built, so a `claude-`prefixed lane on a
/// connector-only deployment is refused at open instead of quietly reaching the
/// wrong backend.
/// one. It claims a model only when the sidecar is configured; the connector
/// serves `claude-` models on its own, and `open_inference` refuses a sidecar
/// whose prefix would take a connector model.
pub const DEFAULT_SDK_MODEL_PREFIX: &str = "claude";
/// Everything the SDK sidecar needs to open, gathered so `open_inference` takes
@ -551,15 +547,8 @@ pub(super) fn lower_query(
turn_cap: u32,
) -> Result<SidecarFrame, InferenceFault> {
let request = &prepared.invocation.request;
if let Some(effort) = request.reasoning_effort.as_deref()
&& !SDK_EFFORT_LEVELS.contains(&effort)
{
return Err(InferenceFault::integrity_violation(
"the requested reasoning effort has no SDK counterpart",
));
}
let mut items = request.input.iter();
let Some(CodexInputItem::UserText { text: prompt }) = items.next() else {
let Some(InputItem::UserText { text: prompt }) = items.next() else {
return Err(InferenceFault::integrity_violation(
"an SDK request must open with exactly one user text item",
));
@ -567,17 +556,22 @@ pub(super) fn lower_query(
let mut transcript = Vec::new();
for item in items {
match item {
CodexInputItem::AssistantText { text } => transcript.push(format!("assistant: {text}")),
CodexInputItem::ToolCall {
InputItem::AssistantText { text } => transcript.push(format!("assistant: {text}")),
InputItem::ToolCall {
name, arguments, ..
} => transcript.push(format!("tool call {name}: {arguments}")),
CodexInputItem::ToolResult { output, .. } => {
InputItem::ToolResult { output, .. } => {
transcript.push(format!("tool result: {output}"))
}
// A later user turn is a kernel refusal reopening the session; the
// transcript is already a textual replay of the conversation, so
// it rides there like every other turn.
CodexInputItem::UserText { text } => transcript.push(format!("user: {text}")),
InputItem::UserText { text } => transcript.push(format!("user: {text}")),
InputItem::ReasoningState { .. } => {
return Err(InferenceFault::integrity_violation(
"an SDK request carried provider reasoning state",
));
}
}
}
Ok(SidecarFrame::Query {
@ -595,8 +589,16 @@ pub(super) fn lower_query(
parameters_json: tool.parameters_json.clone(),
})
.collect(),
effort: request.reasoning_effort.clone(),
max_output_tokens: request.max_output_tokens,
effort: request.reasoning_effort.map(|effort| {
match effort {
ReasoningEffort::Low => "low",
ReasoningEffort::Medium => "medium",
ReasoningEffort::High => "high",
ReasoningEffort::Max => "max",
}
.to_owned()
}),
max_output_tokens: Some(request.max_output_tokens),
turn_cap,
})
}
@ -769,8 +771,10 @@ impl RoutedInferencePort {
.filter(|(prefix, _)| model.starts_with(prefix.as_str()))
.max_by_key(|(prefix, _)| prefix.len())
.map(|(prefix, port)| (prefix.len(), port));
let sdk_claim = model
.starts_with(&self.sdk_model_prefix)
// The SDK prefix claims only when the sidecar is configured: the
// connector serves `claude-` models too, so an unconfigured sidecar
// must leave them to it.
let sdk_claim = (self.sdk.is_some() && model.starts_with(&self.sdk_model_prefix))
.then_some(self.sdk_model_prefix.len());
match (local_claim, sdk_claim) {
(Some((local_len, local_port)), Some(sdk_len)) => {
@ -831,7 +835,7 @@ mod tests {
RECORD_GAP_PATCH_TOOL, SUBMIT_PATCH_TOOL, kernel_speak_entry, patch_tools,
};
use crate::{AffordanceId, AffordanceSnapshot};
use codex_connector::CodexToolDefinition;
use model_connector::ToolDefinition;
use std::collections::VecDeque;
const TEST_RUNTIME: &str = "ghostlight-sdk-test";
@ -912,7 +916,7 @@ mod tests {
InferencePurpose::Elaboration,
TEST_MODEL,
"Author the shortfall.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: prompt.into(),
}],
patch_tools(),
@ -932,10 +936,10 @@ mod tests {
InferencePurpose::Persona,
TEST_MODEL,
"Respond only in natural prose.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: prompt.into(),
}],
Vec::<CodexToolDefinition>::new(),
Vec::<ToolDefinition>::new(),
RequestShape {
max_output_tokens: 1_200,
parallel_tool_calls: false,
@ -1346,7 +1350,7 @@ mod tests {
InferencePurpose::OperationalAgent,
TEST_MODEL,
"Use only the supplied tools.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: "Hold the bridge.".into(),
}],
catalog_tools("", &granted),
@ -1442,10 +1446,21 @@ mod tests {
open_inference(None, Some(sdk()), None, None, &models("gpt-5.6-terra").each()),
Err(ControllerOpenError::UnroutableModel { .. })
));
// The connector alone serves `claude-` models.
assert!(
open_inference(Some(connector()), None, None, None, &models("claude-haiku-5-5").each()).is_ok()
);
// A sidecar whose prefix would take a model the connector serves is
// refused at open, not left to steal the route.
assert!(matches!(
open_inference(Some(connector()), None, None, None, &models("claude-opus-5").each()),
Err(ControllerOpenError::UnroutableModel { .. })
open_inference(Some(connector()), Some(sdk()), None, None, &models("claude-haiku-5-5").each()),
Err(ControllerOpenError::SidecarClaimsConnectorModel { .. })
));
// The same sidecar beside the connector is fine for a model the
// connector does not serve.
assert!(
open_inference(Some(connector()), Some(sdk()), None, None, &models("claude-opus-5").each()).is_ok()
);
assert!(matches!(
open_inference(
None,
@ -1795,13 +1810,6 @@ mod tests {
assert_names_no(&fault, CANARY);
}
// An effort the SDK has no counterpart for.
let port = SdkInferencePort::new(ScriptedLink::new(Vec::new()), TEST_RUNTIME);
let mut prepared = prose_prepared(&port, "Say something true.");
prepared.invocation.request.reasoning_effort = Some(CANARY.into());
let fault = lower_query(1, &prepared, 1).expect_err("an unmapped effort lowered");
assert_names_no(&fault, CANARY);
// A model no backend claims, prepared and inferred through the router.
let directory = tempfile::tempdir().unwrap();
let entry = directory.path().join("main.js");
@ -1824,8 +1832,8 @@ mod tests {
InferencePurpose::Persona,
CANARY,
"Respond only in natural prose.",
vec![CodexInputItem::UserText { text: "Say something true.".into() }],
Vec::<CodexToolDefinition>::new(),
vec![InputItem::UserText { text: "Say something true.".into() }],
Vec::<ToolDefinition>::new(),
RequestShape { max_output_tokens: 1_200, parallel_tool_calls: false },
)
.expect("the request builds");
@ -1840,25 +1848,27 @@ mod tests {
// `lower_query` reads the provider request off the prepared value, so
// the shapes it must refuse are written there directly. Nothing here
// asserts a digest; the identity tests own that.
let build = |input: Vec<CodexInputItem>, effort: Option<&str>| {
let build = |input: Vec<InputItem>, effort: Option<ReasoningEffort>| {
let mut prepared = prose_prepared(&port, "Say something true.");
prepared.invocation.request.input = input;
prepared.invocation.request.reasoning_effort = effort.map(str::to_owned);
prepared.invocation.request.reasoning_effort = effort;
prepared
};
let user = |text: &str| CodexInputItem::UserText { text: text.into() };
let user = |text: &str| InputItem::UserText { text: text.into() };
// Every effort the SDK admits passes; anything else is refused.
for effort in SDK_EFFORT_LEVELS {
// Every typed effort lowers.
for effort in [
ReasoningEffort::Low,
ReasoningEffort::Medium,
ReasoningEffort::High,
ReasoningEffort::Max,
] {
assert!(lower_query(1, &build(vec![user("go")], Some(effort)), 1).is_ok());
}
let fault = lower_query(1, &build(vec![user("go")], Some("blistering")), 1)
.expect_err("an unmapped effort lowered");
assert!(fault.integrity_was_violated(), "{fault:?}");
// The first item must be user text.
for input in [
vec![CodexInputItem::AssistantText { text: "no".into() }],
vec![InputItem::AssistantText { text: "no".into() }],
Vec::new(),
] {
let fault = lower_query(1, &build(input, None), 1)
@ -1881,20 +1891,20 @@ mod tests {
&build(
vec![
user("go"),
CodexInputItem::AssistantText {
InputItem::AssistantText {
text: "thinking".into(),
},
CodexInputItem::ToolCall {
InputItem::ToolCall {
call_id: "call-0".into(),
name: "record_gap".into(),
arguments: "{}".into(),
},
CodexInputItem::ToolResult {
InputItem::ToolResult {
call_id: "call-0".into(),
output: "gap recorded".into(),
},
],
Some("medium"),
Some(ReasoningEffort::Medium),
),
4,
)
@ -1930,15 +1940,27 @@ mod tests {
#[tokio::test]
async fn soul_routing_refuses_rather_than_falling_back() {
assert_eq!(DEFAULT_SDK_MODEL_PREFIX, "claude");
let connector_only = RoutedInferencePort::new(
Some(Arc::new(SdkInferencePort::new(
let stand_in = || {
Arc::new(SdkInferencePort::new(
ScriptedLink::new(Vec::new()),
TEST_RUNTIME,
)) as Arc<dyn InferencePort>),
)) as Arc<dyn InferencePort>
};
// A connector with no sidecar serves `claude-` models itself.
let connector = stand_in();
let connector_only = RoutedInferencePort::new(
Some(Arc::clone(&connector)),
None,
DEFAULT_SDK_MODEL_PREFIX,
Vec::new(),
);
assert!(Arc::ptr_eq(
connector_only.route(TEST_MODEL).unwrap(),
&connector
));
// A sidecar on a prefix that does not match, and no connector: the
// model has no owner and routes nowhere.
let connector_only = RoutedInferencePort::new(None, Some(stand_in()), "sdk/", Vec::new());
assert!(connector_only.route(TEST_MODEL).is_none());
let prepared =
PreparedInference::prepare(TEST_RUNTIME, 4_102_444_800_000, prose_request("Say it.")).unwrap();

View file

@ -26,7 +26,7 @@ use super::{
DecisionOpportunity, EntityId, KernelError, Mismatch, RefKind, Statement, SubjectId,
SubjectKind, Target, WorldPatch, WorldSnapshot,
};
use codex_connector::{CodexInputItem, CodexToolDefinition};
use model_connector::{InputItem, ToolDefinition};
use serde_json::Value;
use thiserror::Error;
@ -44,7 +44,7 @@ pub enum TableError {
/// `PATCH_TOOLS`; which names a particular agent gets is policy, and policy
/// belongs to the caller — `PLAY_TOOLS` is Dungeon's, pinned in Cut 8, not
/// this module's.
pub fn authoring_tools(names: &[&str]) -> Result<Vec<CodexToolDefinition>, TableError> {
pub fn authoring_tools(names: &[&str]) -> Result<Vec<ToolDefinition>, TableError> {
let catalog = patch::patch_tools();
names
.iter()
@ -220,7 +220,7 @@ fn subject_opportunity<'a>(
/// turn; that is the controller lane's own vocabulary, and
/// `decode_actor_call` has no arm for either, so offering them here would
/// hand the play agent a tool `decode_actor_call` always refuses (PA.f55).
pub fn actor_tools(prefix: &str, snapshot: &WorldSnapshot, subject: SubjectId) -> Vec<CodexToolDefinition> {
pub fn actor_tools(prefix: &str, snapshot: &WorldSnapshot, subject: SubjectId) -> Vec<ToolDefinition> {
match subject_opportunity(snapshot, subject) {
Some((_, granted)) => controllers::affordance_tools(prefix, &granted),
None => Vec::new(),
@ -1038,8 +1038,8 @@ impl InferenceRequest {
round: usize,
model: &str,
instructions: &str,
input: Vec<CodexInputItem>,
tools: Vec<CodexToolDefinition>,
input: Vec<InputItem>,
tools: Vec<ToolDefinition>,
max_output_tokens: u32,
) -> Result<InferenceRequest, ControllerError> {
tool_request(

View file

@ -6,11 +6,11 @@
//! own vocabulary. Both spell a property the same way because both spell it
//! here. Nothing in this module reads world state, a snapshot, or a config.
use codex_connector::CodexToolDefinition;
use model_connector::ToolDefinition;
use serde_json::{Value, json};
pub(super) fn tool(name: &str, description: &str, schema: Value) -> CodexToolDefinition {
CodexToolDefinition {
pub(super) fn tool(name: &str, description: &str, schema: Value) -> ToolDefinition {
ToolDefinition {
name: name.into(),
description: description.into(),
parameters_json: serde_json::to_string(&schema)

File diff suppressed because it is too large Load diff

View file

@ -26,7 +26,7 @@ use crate::controllers::{
};
use async_trait::async_trait;
use chrono::Utc;
use codex_connector::CodexProviderRequest;
use model_connector::ProviderRequest;
use cultcache_rs::{CacheBackingStore, CultCacheEnvelope, OwnedRedbMessagePackBackingStore};
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
@ -197,10 +197,10 @@ fn hex(digest: &[u8]) -> String {
/// id from the world it ran in, so keying on them would tie a recorded run to
/// one world's random identity. Everything else the provider is sent
/// (model, instructions, input, tools, shape) is in the digest.
fn content_digest(request: &CodexProviderRequest) -> Result<String, InferenceFault> {
fn content_digest(request: &ProviderRequest) -> Result<String, InferenceFault> {
// Exhaustive on purpose: a field added upstream must be placed in the key
// or left out here by name before this compiles.
let CodexProviderRequest {
let ProviderRequest {
schema_id,
request_id: _request_id, // names the call, not what it asks
conversation_id: _conversation_id, // names the call, not what it asks
@ -208,16 +208,12 @@ fn content_digest(request: &CodexProviderRequest) -> Result<String, InferenceFau
instructions,
input,
reasoning_effort,
reasoning_summary,
service_tier,
output_format_name,
previous_response_id,
cache_retention,
tools,
tool_choice,
parallel_tool_calls,
output_schema_json,
max_output_tokens,
prompt_cache_key,
} = request;
let bytes = rmp_serde::to_vec(&(
schema_id,
@ -225,16 +221,12 @@ fn content_digest(request: &CodexProviderRequest) -> Result<String, InferenceFau
instructions,
input,
reasoning_effort,
reasoning_summary,
service_tier,
output_format_name,
previous_response_id,
cache_retention,
tools,
tool_choice,
parallel_tool_calls,
output_schema_json,
max_output_tokens,
prompt_cache_key,
))
.map_err(|_| InferenceFault::new("a provider request could not be measured"))?;
Ok(hex(&Sha256::digest(bytes)))
@ -601,14 +593,10 @@ impl RecordingInferencePort {
}
/// The most this request can cost: its serialized bytes plus its output
/// allowance. A request with no output allowance has no bound, so it
/// cannot be held under a cap.
/// allowance. The v4 request type cannot omit the allowance, so every
/// request has a bound.
fn bound(request: &PreparedInference) -> Result<u64, InferenceFault> {
let allowance = request
.invocation
.request
.max_output_tokens
.ok_or_else(InferenceFault::budget_exhausted)?;
let allowance = request.invocation.request.max_output_tokens;
let payload = serde_json::to_vec(&request.invocation.request)
.map_err(|_| InferenceFault::new("a provider request could not be measured"))?;
Ok((payload.len() as u64).saturating_add(u64::from(allowance)))

View file

@ -3,7 +3,7 @@ use crate::CommandId;
use crate::controllers::{
InferenceFaultClass, InferenceFaultDisposition, RequestShape, tool_request,
};
use codex_connector::{CodexInputItem, CodexToolDefinition};
use model_connector::{InputItem, ToolDefinition};
use std::sync::atomic::{AtomicUsize, Ordering};
const MODEL: &str = "hosted/test-model";
@ -73,10 +73,10 @@ fn request_for(command: CommandId, prompt: &str, max_output_tokens: u32) -> Infe
InferencePurpose::Persona,
MODEL,
"Respond only in prose.",
vec![CodexInputItem::UserText {
vec![InputItem::UserText {
text: prompt.into(),
}],
Vec::<CodexToolDefinition>::new(),
Vec::<ToolDefinition>::new(),
RequestShape {
max_output_tokens,
parallel_tool_calls: false,
@ -100,13 +100,7 @@ fn bound_of(prepared: &PreparedInference) -> u64 {
.expect("a provider request serializes")
.len() as u64;
payload
+ u64::from(
prepared
.invocation
.request
.max_output_tokens
.expect("an allowance"),
)
+ u64::from(prepared.invocation.request.max_output_tokens)
}
fn reply(text: &str, receipt: &str) -> InferenceOutput {
@ -276,17 +270,6 @@ async fn cap_refuses_before_the_provider_is_called() {
.await
.expect("a call that fits the cap is made");
assert_eq!(inner.calls(), 1);
// A request with no output allowance has no bound and is refused.
let mut open_ended = prepared_for("open ended", 1_200);
open_ended.invocation.request.max_output_tokens = None;
let unbounded = recording(&inner, &store, "run-open", u64::MAX);
let fault = unbounded
.infer(open_ended)
.await
.expect_err("no allowance, no bound");
assert_eq!(fault.class(), InferenceFaultClass::BudgetExhausted);
assert_eq!(inner.calls(), 1);
}
#[tokio::test]
@ -969,20 +952,20 @@ async fn usage_one_token_over_the_bound_faults_and_stores_no_record() {
#[test]
fn the_replay_key_covers_what_the_request_asks_and_not_what_names_it() {
let base = prepared_for("key", 1_200).invocation.request.clone();
let digest = |edit: &dyn Fn(&mut CodexProviderRequest)| {
let digest = |edit: &dyn Fn(&mut ProviderRequest)| {
let mut request = base.clone();
edit(&mut request);
content_digest(&request).unwrap()
};
let same = digest(&|_| {});
assert_eq!(same, content_digest(&base).unwrap());
let changes: Vec<(&str, Box<dyn Fn(&mut CodexProviderRequest)>)> = vec![
let changes: Vec<(&str, Box<dyn Fn(&mut ProviderRequest)>)> = vec![
("model", Box::new(|r| r.model.push('x'))),
("instructions", Box::new(|r| r.instructions.push('x'))),
(
"tools",
Box::new(|r| {
r.tools.push(CodexToolDefinition {
r.tools.push(ToolDefinition {
name: "t".into(),
description: "d".into(),
parameters_json: "{}".into(),
@ -991,57 +974,41 @@ fn the_replay_key_covers_what_the_request_asks_and_not_what_names_it() {
),
(
"input",
Box::new(|r| r.input.push(CodexInputItem::UserText { text: "x".into() })),
Box::new(|r| r.input.push(InputItem::UserText { text: "x".into() })),
),
(
"max_output_tokens",
Box::new(|r| r.max_output_tokens = Some(1)),
Box::new(|r| r.max_output_tokens = 1),
),
(
"reasoning_effort",
Box::new(|r| r.reasoning_effort = Some("low".into())),
),
(
"service_tier",
Box::new(|r| r.service_tier = Some("flex".into())),
Box::new(|r| r.reasoning_effort = Some(model_connector::ReasoningEffort::High)),
),
(
"output_schema_json",
Box::new(|r| r.output_schema_json = Some("{}".into())),
),
(
"previous_response_id",
Box::new(|r| r.previous_response_id = Some("p".into())),
),
(
"parallel_tool_calls",
Box::new(|r| r.parallel_tool_calls = !r.parallel_tool_calls),
),
("schema_id", Box::new(|r| r.schema_id.push_str(".v2"))),
(
"reasoning_summary",
Box::new(|r| r.reasoning_summary = Some("auto".into())),
),
(
"output_format_name",
Box::new(|r| r.output_format_name = Some("persona_reply".into())),
),
(
"tool_choice",
Box::new(|r| {
r.tool_choice = match r.tool_choice {
codex_connector::CodexToolChoice::Auto => {
codex_connector::CodexToolChoice::Required
model_connector::ToolChoice::Auto => {
model_connector::ToolChoice::Required
}
codex_connector::CodexToolChoice::Required => {
codex_connector::CodexToolChoice::Auto
model_connector::ToolChoice::Required => {
model_connector::ToolChoice::Auto
}
}
}),
),
(
"prompt_cache_key",
Box::new(|r| r.prompt_cache_key = Some("ghostlight-persona-1".into())),
"cache_retention",
Box::new(|r| r.cache_retention = Some(model_connector::CacheRetention::Short)),
),
];
for (field, change) in changes {

View file

@ -141,7 +141,7 @@ impl InferencePort for ScriptedPort {
let sequence = self.calls.fetch_add(1, Ordering::SeqCst);
let wire = &request.invocation.request;
let bound = serde_json::to_vec(wire).unwrap().len() as u64
+ u64::from(wire.max_output_tokens.unwrap());
+ u64::from(wire.max_output_tokens);
self.bounds.lock().unwrap().push(bound);
if let Some(fault) = self.faults.lock().unwrap().pop_front() {
return Err(fault);

View file

@ -1,69 +1,50 @@
# Connector And Claude SDK Sidecar Bring-Up
No live smoke exists in this tree. The ignored test this file once documented,
`runtime::tests::live_smoke_seeds_then_ticks_a_world_against_the_connector`,
ran the production tick driver and the Active elaboration sweep against a real
CodexConnector; the play agent's Cut 1 (`d69e9d4`) deleted both, and the test
with them. A command that names it now matches nothing and exits 0. No
replacement exists. The recipe that once gated a deploy on a real model is
gone from main, and so is its `accept-real-persona-membrane` step. The one real-model test
left is the ignored `controllers::tests::real_local_model_cognition_modes_commit_speech`
(`crates/ghostlight/src/controllers.rs`). It has no automated run: it needs a model server
on `GHOSTLIGHT_LOCAL_ENDPOINT` plus the `GHOSTLIGHT_CONTROLLER_*_MODEL`,
No automated live smoke exists in this tree. The one real-model test left is the
ignored `controllers::tests::real_local_model_cognition_modes_commit_speech`
(`crates/ghostlight/src/controllers.rs`), and a person runs it by hand with
`cargo test -p ghostlight -- --ignored real_local_model_cognition_modes_commit_speech`.
It needs either a local model server (`GHOSTLIGHT_LOCAL_ENDPOINT`) or the
connector (`GHOSTLIGHT_ACCEPTANCE_CONNECTOR=<host:port>` plus the systemd
credential below), and the `GHOSTLIGHT_CONTROLLER_*_MODEL`,
`GHOSTLIGHT_ACCEPTANCE_RUNTIME_ID` and `GHOSTLIGHT_ACCEPTANCE_PERSONA_PROSE_LOG`
variables, and a person runs it by hand with `cargo test -p ghostlight -- --ignored
real_local_model_cognition_modes_commit_speech`.
variables. The release gate passes if one of three attempts commits; every
failed attempt's prose is kept.
What remains true and stays here: bringing up a real CodexConnector and a
built Claude SDK sidecar. The seed lane (`world.seed`) still runs real
inference through `ControllerRunner`, and both transports below are how a
session gets real model responses instead of a fixture inference port.
## The connector
## Substrate
Ghostlight's connector lane speaks model-connector v4 to claude-connector, which
Eureka owns and runs on Yggdrasil at `127.0.0.1:4110`. Ghostlight is one of its
callers, identified as `ghostlight`. Connector models are `claude-haiku-5-5`,
`claude-sonnet-5-5` and `claude-opus-5-5`; any other name is refused
`ModelNotAllowed`. A required tool choice on `claude-sonnet-5-5` is refused as
an invalid request, and Ghostlight sends only `Auto`.
Machine-local, outside the repo: `F:\Projects\Ghostlight-smoke\`.
The connection key is never copied, printed or put in an environment variable.
`ConnectorBinding::key_path` names a file, read once when the port opens. Under
systemd that file is the credential the unit mounts:
- `codex-home\auth.json`: a copy of `~/.codex/auth.json`. The connector spawns
the official `codex app-server` child against this home and may refresh it.
- `connector\ghostlight.key`: 64 hex characters, no trailing newline; the
shared connection secret. Both sides read the same file.
- `connector\connector.cc`: the daemon's single-caller config.
- `logs\`: connector stdout/stderr and pid.
The connector binary is `F:\Projects\CodexConnector\target\debug\codex-connector.exe`
built from the repo head with the `daemon` feature. Ghostlight's `Cargo.lock`
pins the connector library at an older revision whose daemon does not build
against its own lockfile; the head daemon speaks the same wire law.
## Bring-up
Initialize the config once (the codex executable path and SHA-256 are the
newest `codex.exe` under `%LOCALAPPDATA%\OpenAI\Codex\bin\`):
```powershell
F:\Projects\CodexConnector\target\debug\codex-connector.exe --initialize-single-caller-config F:\Projects\Ghostlight-smoke\connector\connector.cc 127.0.0.1:4103 <codex.exe> <sha256> F:\Projects\Ghostlight-smoke\codex-home F:\Projects\Ghostlight-smoke\connector\replay.cc ghostlight-smoke F:\Projects\Ghostlight-smoke\connector\ghostlight.key 1 gpt-5.6-luna,gpt-5.6-sol,gpt-5.6-terra 4 1052672 16000
```bash
sudo systemd-run --wait --pipe \
-p LoadCredential=connector-key:/etc/gamecult/claude-connector/connection-ghostlight.key \
-E GHOSTLIGHT_ACCEPTANCE_CONNECTOR=127.0.0.1:4110 ... <test binary> --ignored
```
Start the daemon detached; it prints one ready line to stderr:
The ignored `live_connector_v4_completes_plain_tool_and_schema_requests` runs the
same way (it needs only `CREDENTIALS_DIRECTORY`) and checks a plain, a tool and
an output-schema request on haiku and a plain request on sonnet.
```powershell
$R='F:\Projects\Ghostlight-smoke'; $p = Start-Process -FilePath 'F:\Projects\CodexConnector\target\debug\codex-connector.exe' -ArgumentList @('--config', "$R\connector\connector.cc") -RedirectStandardOutput "$R\logs\connector.stdout.log" -RedirectStandardError "$R\logs\connector.stderr.log" -PassThru -WindowStyle Hidden; $p.Id | Out-File "$R\logs\connector.pid"
```
Stop it with `Stop-Process -Id (Get-Content F:\Projects\Ghostlight-smoke\logs\connector.pid)`.
A session that wants the connector reads
`GHOSTLIGHT_CONTROLLER_CONNECTOR=127.0.0.1:4103` and
`GHOSTLIGHT_CONTROLLER_CREDENTIAL='F:\Projects\Ghostlight-smoke\connector\ghostlight.key'`,
the same variables the deleted harness read.
Ghostlight's port is one shot
and returns a typed fault (`InferenceFaultClass`) whose disposition says whether
the owning flow may try again.
## Claude SDK route
`crates/ghostlight/src/sdk_inference.rs`'s `SdkInferencePort` gives any lane whose configured
model is `claude`-prefixed (matching `GHOSTLIGHT_SDK_MODEL_PREFIX`, default
`claude`) a second transport: a Node sidecar on the Claude Agent SDK instead of
the CodexConnector, so a session can run on the Claude subscription with no
Codex budget.
the connector, so a session can run on the Claude subscription with no
connector budget.
**Operator prerequisites, none of which Ghostlight performs:**
@ -92,10 +73,10 @@ GHOSTLIGHT_SDK_SIDECAR='F:\Projects\Ghostlight\sidecar\claude-sdk\dist\main.js'
GHOSTLIGHT_SDK_MODEL_PREFIX=claude # optional; this is already the default
```
`GHOSTLIGHT_SDK_SIDECAR`'s absence means no SDK binding at all — a
`claude`-prefixed lane model then fails at open with `UnroutableModel` rather
than silently reaching the connector. Any of the five
`GHOSTLIGHT_CONTROLLER_*_MODEL` variables can be set to a `claude`-prefixed
model (for example `claude-opus-5`) to route that lane through the sidecar;
the connector variables are only required for lanes that still route to the
connector, and an all-`claude` configuration needs neither.
`GHOSTLIGHT_SDK_SIDECAR`'s absence means no SDK binding at all: a
`claude`-prefixed lane model then routes to the connector, which serves the
`claude-*-5-5` models itself. With both bound, a model the connector serves
(`claude-<tier>-5-5`) under the sidecar's prefix is refused at open
(`SidecarClaimsConnectorModel`) rather than stolen by the sidecar; a model
such as `claude-opus-5` still reaches the sidecar.