test(claude-connector): pin connector_config.v4 tag, parser edges, and README
- Pin ClaudeConnectorConfig::TYPE == gamecult.model_connector.connector_config.v4 and test a full 12-field connector_config.v3 document failing closed with ConfigError::Store. - Cover >6 colon segments rejection and uppercase/mixed-case TUE/SaT weekday parsing in config_init_and_add_model_price_flags. - Update README.md status and backend descriptions to reflect live OpenAiChatBackend, lease run, and RouterBackend as the sole ProviderBackend.
This commit is contained in:
parent
e074b58e4d
commit
f3a660e000
2 changed files with 91 additions and 15 deletions
11
README.md
11
README.md
|
|
@ -7,7 +7,8 @@ credential, so no project wires its own provider calls.
|
|||
The connector gates nothing in dollars. It holds the provider credentials and subscription token, lends leases, derives optional per-call micro-USD visibility on receipts, and publishes communal monthly caller/model spend alongside the plan's usage windows (`usage_readout`, `claude_usage_readout` on the lease socket, and `plan_quota` on every lease grant) for the minds to read and decide their own burn. The one usage-derived refusal is the provider's own (`ProviderRejected`), repeated until its reset.
|
||||
|
||||
Status: the `model-connector` crate and the `claude-connector` backend crate and binary are live
|
||||
(`claude-connector serve|config|ask`); an OpenAI-compatible connector is not written.
|
||||
(`claude-connector serve|config|ask|lease run`), with `RouterBackend` serving `ClaudeCodeBackend`,
|
||||
`MessagesBackend`, and `OpenAiChatBackend`.
|
||||
|
||||
## Entry points
|
||||
|
||||
|
|
@ -42,11 +43,11 @@ Crate `crates/model-connector`:
|
|||
|
||||
Crate `crates/claude-connector` (library and the `claude-connector` binary that wires it to `serve`):
|
||||
|
||||
- `RouterBackend` routes each configured `ModelRow` in the CultCache `gamecult.model_connector.connector_config.v4`
|
||||
- `RouterBackend` is the connector's sole `ProviderBackend` implementation: it routes each configured `ModelRow` in the CultCache `gamecult.model_connector.connector_config.v4`
|
||||
document to its configured `ProviderEntry` (`ProviderWire::AnthropicMessages`, `ProviderWire::OpenAiChat`, or
|
||||
`ProviderWire::ClaudeCodeCli`), enforces per-model `ModelRow` policies (`upstream`, `efforts`, `unset_effort`,
|
||||
`forced_tool_choice`, `output_schema`, `strict_tools`), and isolates `ReasoningState` by provider entry id.
|
||||
- `ClaudeCodeBackend` implements `ProviderBackend` for `ProviderWire::ClaudeCodeCli` by driving the
|
||||
- `ClaudeCodeBackend` serves `ProviderWire::ClaudeCodeCli` (dispatched by `RouterBackend`) by driving the
|
||||
unmodified `claude` binary, one child per call, in print stream-json mode with no tools, no MCP
|
||||
servers, no settings sources and the system prompt replaced. Tool-less turns only: a request
|
||||
with tools or a final tool result is refused before any spawn. A request's output schema goes
|
||||
|
|
@ -54,10 +55,10 @@ Crate `crates/claude-connector` (library and the `claude-connector` binary that
|
|||
- Reasoning state is a session handle (`ClaudeCodeHandle`) authenticated with a connector secret
|
||||
and bound to the caller it was minted for; a handle that cannot be proven to match the request
|
||||
and its caller re-seeds from the caller's transcript, and every resume forks.
|
||||
- `MessagesBackend` implements `ProviderBackend` for `ProviderWire::AnthropicMessages` (one
|
||||
- `MessagesBackend` serves `ProviderWire::AnthropicMessages` (one
|
||||
non-streaming `POST /v1/messages` per call: tools, tool calls and results, thinking blocks,
|
||||
`cache_control`, and cache read/write usage; optional `x-api-key` credential). `OpenAiChatBackend`
|
||||
implements `ProviderBackend` for `ProviderWire::OpenAiChat` (non-streaming chat completions with
|
||||
serves `ProviderWire::OpenAiChat` (non-streaming chat completions with
|
||||
`reasoning_content` replay and `Bearer` credential when configured). Neither HTTP wire has a
|
||||
plan: `plan_quota` comes only from a `ClaudeCodeCli` meter, and only a config with a `ClaudeCodeCli`
|
||||
provider lends token leases.
|
||||
|
|
|
|||
|
|
@ -214,31 +214,91 @@ fn v2_config_is_refused_at_load() {
|
|||
assert!(matches!(load_config(&path), Err(ConfigError::Store)));
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
struct V3ModelRow {
|
||||
id: String,
|
||||
provider: String,
|
||||
upstream: String,
|
||||
efforts: EffortMap,
|
||||
unset_effort: Option<String>,
|
||||
forced_tool_choice: ForcedToolChoice,
|
||||
output_schema: OutputSchemaSupport,
|
||||
strict_tools: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(type = "gamecult.model_connector.connector_config.v3")]
|
||||
struct V3Config {
|
||||
#[cultcache(key = 0)]
|
||||
listen: String,
|
||||
#[cultcache(key = 1)]
|
||||
replay_store: PathBuf,
|
||||
#[cultcache(key = 2)]
|
||||
max_frame_bytes: usize,
|
||||
#[cultcache(key = 3)]
|
||||
max_connections: usize,
|
||||
#[cultcache(key = 4)]
|
||||
socket_timeout_ms: u64,
|
||||
#[cultcache(key = 5)]
|
||||
max_expiry_skew_ms: u64,
|
||||
#[cultcache(key = 6)]
|
||||
providers: Vec<ProviderEntry>,
|
||||
#[cultcache(key = 7)]
|
||||
models: Vec<V3ModelRow>,
|
||||
#[cultcache(key = 8)]
|
||||
callers: Vec<CallerConfig>,
|
||||
#[cultcache(key = 9)]
|
||||
lease_socket: Option<PathBuf>,
|
||||
#[cultcache(key = 10)]
|
||||
lease_holders: Vec<LeaseHolderConfig>,
|
||||
#[cultcache(key = 11)]
|
||||
lease_max_ms: u64,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v3_config_is_refused_at_load() {
|
||||
assert_eq!(
|
||||
ClaudeConnectorConfig::TYPE,
|
||||
"gamecult.model_connector.connector_config.v4"
|
||||
);
|
||||
|
||||
let scratch = Scratch::new();
|
||||
let v3_path = scratch.path("v3.cc");
|
||||
let base = valid();
|
||||
let v3 = V3Config {
|
||||
listen: base.listen,
|
||||
replay_store: base.replay_store,
|
||||
max_frame_bytes: base.max_frame_bytes,
|
||||
max_connections: base.max_connections,
|
||||
socket_timeout_ms: base.socket_timeout_ms,
|
||||
max_expiry_skew_ms: base.max_expiry_skew_ms,
|
||||
providers: base.providers,
|
||||
models: base
|
||||
.models
|
||||
.into_iter()
|
||||
.map(|row| V3ModelRow {
|
||||
id: row.id,
|
||||
provider: row.provider,
|
||||
upstream: row.upstream,
|
||||
efforts: row.efforts,
|
||||
unset_effort: row.unset_effort,
|
||||
forced_tool_choice: row.forced_tool_choice,
|
||||
output_schema: row.output_schema,
|
||||
strict_tools: row.strict_tools,
|
||||
})
|
||||
.collect(),
|
||||
callers: base.callers,
|
||||
lease_socket: base.lease_socket,
|
||||
lease_holders: base.lease_holders,
|
||||
lease_max_ms: base.lease_max_ms,
|
||||
};
|
||||
{
|
||||
let mut cache = CultCache::new();
|
||||
cache.register_entry_type::<V3Config>().unwrap();
|
||||
cache
|
||||
.add_generic_backing_store(SingleFileMessagePackBackingStore::new(&v3_path))
|
||||
.unwrap();
|
||||
cache
|
||||
.put(
|
||||
"runtime".to_string(),
|
||||
&V3Config {
|
||||
listen: "127.0.0.1:7443".to_string(),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
cache.put("runtime".to_string(), &v3).unwrap();
|
||||
}
|
||||
assert!(matches!(load_config(&v3_path), Err(ConfigError::Store)));
|
||||
|
||||
|
|
@ -1278,9 +1338,9 @@ fn config_init_and_add_model_price_flags() {
|
|||
"--price-output",
|
||||
"500000",
|
||||
"--price-band",
|
||||
"MON,tue,Wed:0,1:200000:20000:250000:1000000",
|
||||
"MON,TUE,Wed:0,1:200000:20000:250000:1000000",
|
||||
"--price-band",
|
||||
"Thu,FRI,sat,SuN:22,23:150000:15000:0:750000",
|
||||
"Thu,FRI,SaT,SuN:22,23:150000:15000:0:750000",
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
@ -1476,6 +1536,21 @@ fn config_init_and_add_model_price_flags() {
|
|||
],
|
||||
"canary-only-five",
|
||||
),
|
||||
(
|
||||
&[
|
||||
"--price-input",
|
||||
"1",
|
||||
"--price-cache-read",
|
||||
"1",
|
||||
"--price-cache-write",
|
||||
"1",
|
||||
"--price-output",
|
||||
"1",
|
||||
"--price-band",
|
||||
"mon:1:2:3:4:5:canary-seventh",
|
||||
],
|
||||
"canary-seventh",
|
||||
),
|
||||
(
|
||||
&[
|
||||
"--price-input",
|
||||
|
|
|
|||
Loading…
Reference in a new issue