Skip to content
Merged
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
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = [".", "crates/ironclaw_common", "crates/ironclaw_host_api", "crates/ironclaw_filesystem", "crates/ironclaw_memory", "crates/ironclaw_events", "crates/ironclaw_event_projections", "crates/ironclaw_event_streams", "crates/ironclaw_reborn_event_store", "crates/ironclaw_extensions", "crates/ironclaw_processes", "crates/ironclaw_dispatcher", "crates/ironclaw_scripts", "crates/ironclaw_process_sandbox", "crates/ironclaw_mcp", "crates/ironclaw_wasm", "crates/ironclaw_wasm_sandbox_core", "crates/ironclaw_wasm_limiter", "crates/ironclaw_capabilities", "crates/ironclaw_secrets", "crates/ironclaw_network", "crates/ironclaw_host_runtime", "crates/ironclaw_runtime_policy", "crates/ironclaw_authorization", "crates/ironclaw_run_state", "crates/ironclaw_approvals", "crates/ironclaw_resources", "crates/ironclaw_auth", "crates/ironclaw_trust", "crates/ironclaw_turns", "crates/ironclaw_agent_loop", "crates/ironclaw_threads", "crates/ironclaw_prompt_envelope", "crates/ironclaw_hooks", "crates/ironclaw_hooks_postgres", "crates/ironclaw_hooks_libsql", "crates/ironclaw_hooks_parity", "crates/ironclaw_loop_support", "crates/ironclaw_reborn", "crates/ironclaw_reborn_config", "crates/ironclaw_reborn_composition", "crates/ironclaw_reborn_identity", "crates/ironclaw_first_party_extensions", "crates/ironclaw_reborn_cli", "crates/ironclaw_reborn_traces", "crates/ironclaw_reborn_webui_ingress", "crates/ironclaw_reborn_openai_compat", "crates/ironclaw_conversations", "crates/ironclaw_product_adapters", "crates/ironclaw_product_workflow", "crates/ironclaw_product_workflow_storage", "crates/ironclaw_product_adapter_registry", "crates/ironclaw_wasm_product_adapters", "crates/ironclaw_telegram_v2_adapter", "crates/ironclaw_slack_v2_adapter", "crates/ironclaw_outbound", "crates/ironclaw_triggers", "crates/ironclaw_architecture", "crates/ironclaw_safety", "crates/ironclaw_skills", "crates/ironclaw_oauth", "crates/ironclaw_llm", "crates/ironclaw_embeddings", "crates/ironclaw_engine", "crates/ironclaw_gateway", "crates/ironclaw_tui", "crates/ironclaw_webui_v2", "crates/ironclaw_webui_v2_static"]
members = [".", "crates/ironclaw_common", "crates/ironclaw_host_api", "crates/ironclaw_filesystem", "crates/ironclaw_memory", "crates/ironclaw_events", "crates/ironclaw_event_projections", "crates/ironclaw_event_streams", "crates/ironclaw_reborn_event_store", "crates/ironclaw_extensions", "crates/ironclaw_processes", "crates/ironclaw_dispatcher", "crates/ironclaw_scripts", "crates/ironclaw_process_sandbox", "crates/ironclaw_mcp", "crates/ironclaw_wasm", "crates/ironclaw_wasm_sandbox_core", "crates/ironclaw_wasm_limiter", "crates/ironclaw_capabilities", "crates/ironclaw_secrets", "crates/ironclaw_network", "crates/ironclaw_host_runtime", "crates/ironclaw_runtime_policy", "crates/ironclaw_authorization", "crates/ironclaw_run_state", "crates/ironclaw_approvals", "crates/ironclaw_resources", "crates/ironclaw_auth", "crates/ironclaw_trust", "crates/ironclaw_turns", "crates/ironclaw_agent_loop", "crates/ironclaw_threads", "crates/ironclaw_prompt_envelope", "crates/ironclaw_hooks", "crates/ironclaw_hooks_postgres", "crates/ironclaw_hooks_libsql", "crates/ironclaw_hooks_parity", "crates/ironclaw_loop_support", "crates/ironclaw_reborn", "crates/ironclaw_reborn_config", "crates/ironclaw_reborn_composition", "crates/ironclaw_reborn_identity", "crates/ironclaw_first_party_extensions", "crates/ironclaw_reborn_cli", "crates/ironclaw_reborn_traces", "crates/ironclaw_reborn_webui_ingress", "crates/ironclaw_reborn_openai_compat", "crates/ironclaw_reborn_openai_compat_storage", "crates/ironclaw_conversations", "crates/ironclaw_product_adapters", "crates/ironclaw_product_workflow", "crates/ironclaw_product_workflow_storage", "crates/ironclaw_product_adapter_registry", "crates/ironclaw_wasm_product_adapters", "crates/ironclaw_telegram_v2_adapter", "crates/ironclaw_slack_v2_adapter", "crates/ironclaw_outbound", "crates/ironclaw_triggers", "crates/ironclaw_architecture", "crates/ironclaw_safety", "crates/ironclaw_skills", "crates/ironclaw_oauth", "crates/ironclaw_llm", "crates/ironclaw_embeddings", "crates/ironclaw_engine", "crates/ironclaw_gateway", "crates/ironclaw_tui", "crates/ironclaw_webui_v2", "crates/ironclaw_webui_v2_static"]
exclude = [
"channels-src/discord",
"channels-src/feishu",
Expand Down
1 change: 1 addition & 0 deletions crates/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Boundary rule: if you need an upstream crate in a low-level crate, stop and chec
| `ironclaw_reborn_config` | `ironclaw_reborn_config/AGENTS.md`, `Cargo.toml`, `src/lib.rs` | Boot configuration contracts for standalone Reborn binary. | Runtime execution or product adapter behavior. |
| `ironclaw_reborn_composition` | `ironclaw_reborn_composition/AGENTS.md`, `ironclaw_reborn_composition/CLAUDE.md` | Facade-shaped production composition root for Reborn. | Low-level policy internals that belong to service crates. |
| `ironclaw_reborn_openai_compat` | `ironclaw_reborn_openai_compat/AGENTS.md`, `ironclaw_reborn_openai_compat/CLAUDE.md` | Reborn-native OpenAI-compatible API route descriptors, Chat/Responses DTOs, sanitized error envelope, and fail-closed route fragment. | V1 gateway handlers, direct LLM proxying, listener binding, ProductWorkflow internals/direct runtime wiring. |
| `ironclaw_reborn_openai_compat_storage` | `ironclaw_reborn_openai_compat_storage/AGENTS.md`, `ironclaw_reborn_openai_compat_storage/CLAUDE.md` | Durable storage adapters for Reborn OpenAI-compatible public refs and idempotency mappings. | HTTP route handlers, ProductWorkflow orchestration, v1 gateway handlers, direct LLM proxying. |
| `ironclaw_first_party_extensions` | `ironclaw_first_party_extensions/AGENTS.md`, `Cargo.toml` | Concrete first-party userland extension implementations and deterministic tool behavior behind scoped handles. | Host runtime composition, loop-facing ports, ambient runtime authority, dispatcher/network/secrets handles. |
| `ironclaw_first_party_extension_ports` | `ironclaw_first_party_extension_ports/AGENTS.md`, `Cargo.toml` | Loop-facing adapters for first-party extensions: skill activation/context/execution ports over loop-support and turn-run contracts. | Concrete tool behavior, host runtime composition, product workflow, raw host authority. |
| `ironclaw_reborn_cli` | `ironclaw_reborn_cli/AGENTS.md` | Standalone Reborn CLI, command files, CLI context, shell completions, doctor/home/profile commands. | V1 runtime imports, root `ironclaw` deps, side effects in pure commands. |
Expand Down
1 change: 1 addition & 0 deletions crates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ A good rule of thumb: if a change adds new authority or persistence, put it in t
| `ironclaw_reborn_config` | `ironclaw_reborn_config` | Reborn boot-config boundary: typed configuration, profiles, and validation consumed before services start. |
| `ironclaw_reborn_cli` | `ironclaw_reborn_cli` | Reborn-first CLI surface (command modules, completion, shell entry points). Calls into composition; does not own host policy. |
| `ironclaw_reborn_webui_ingress` | `ironclaw_reborn_webui_ingress` | Host-owned listener binding, authenticator implementations, and serve loop for the Reborn WebChat v2 HTTP gateway. |
| `ironclaw_reborn_openai_compat_storage` | `ironclaw_reborn_openai_compat_storage` | Durable filesystem-backed storage adapters for Reborn OpenAI-compatible public refs and idempotency mappings. |
| `ironclaw_llm` | `ironclaw_llm` | LLM provider routing and abstraction used by Reborn product surfaces and the agent loop. |
| `ironclaw_agent_loop` | `ironclaw_agent_loop` | Agent-loop framework state, planner/executor, strategy/family contracts, and test support. |
| `ironclaw_loop_support` | `ironclaw_loop_support` | Adapts durable Reborn support boundaries into the narrow agent-loop host port. It should not own provider clients or runtime dispatchers. |
Expand Down
51 changes: 51 additions & 0 deletions crates/ironclaw_architecture/tests/reborn_dependency_boundaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,57 @@ fn boundary_rules() -> Vec<BoundaryRule> {
"ironclaw_webui_v2",
],
},
BoundaryRule {
// Durable storage for OpenAI-compatible public refs sits behind
// the OpenAiCompatRefStore port. It may use the universal
// filesystem backend and the OpenAI-compatible contract crate, but
// must not grow route handling, ProductWorkflow orchestration, or
// runtime/composition reach-through.
crate_name: "ironclaw_reborn_openai_compat_storage",
forbidden: vec![
"ironclaw",
"ironclaw_capabilities",
"ironclaw_conversations",
"ironclaw_dispatcher",
"ironclaw_engine",
"ironclaw_event_projections",
"ironclaw_event_streams",
"ironclaw_events",
"ironclaw_extensions",
"ironclaw_gateway",
"ironclaw_host_runtime",
"ironclaw_llm",
"ironclaw_loop_support",
"ironclaw_mcp",
"ironclaw_memory",
"ironclaw_network",
"ironclaw_outbound",
"ironclaw_processes",
"ironclaw_product_workflow",
"ironclaw_reborn",
"ironclaw_reborn_cli",
"ironclaw_reborn_composition",
"ironclaw_reborn_config",
"ironclaw_reborn_event_store",
"ironclaw_first_party_extensions",
"ironclaw_first_party_extension_ports",
"ironclaw_resources",
"ironclaw_run_state",
"ironclaw_runtime_policy",
"ironclaw_safety",
"ironclaw_scripts",
"ironclaw_secrets",
"ironclaw_skills",
"ironclaw_storage",
"ironclaw_threads",
"ironclaw_trust",
"ironclaw_tui",
"ironclaw_turns",
"ironclaw_wasm",
"ironclaw_wasm_product_adapters",
"ironclaw_webui_v2",
],
},
BoundaryRule {
// Registry projects ProductAdapter host-api sections from the single
// Extension Manifest v2 over extension-owned installation and activation
Expand Down
24 changes: 23 additions & 1 deletion crates/ironclaw_reborn_openai_compat/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ironclaw_reborn_openai_compat

Reborn-native OpenAI-compatible API contract surface for #3283 / #4442.
Reborn-native OpenAI-compatible API contract surface for #3283 / #4442 /
#4443.

## Boundary

Expand All @@ -15,6 +16,27 @@ This crate is a product/API route surface, not a host runtime:
- Later slices should route through the channel-neutral `ProductWorkflow`
surface rather than recreating v1 `/v1/chat/completions` LLM proxy behavior.

## Opaque Refs and Idempotency

The `refs` module owns the OpenAI-compatible identity contract used before
routes are wired to ProductWorkflow:

- Public ids are typed opaque refs: `chatcmpl-*` for Chat Completions and
`resp_*` for Responses.
- Generated ids use host entropy and must not encode tenant, user, thread, run,
product-action, projection, cursor, or host-path values.
- Client idempotency keys are scoped by actor scope + route surface +
request-body fingerprint. Same key and same fingerprint replays the same
mapping; same key with a different fingerprint returns a sanitized conflict.
- Missing idempotency keys create a new mapping on every POST.
- Lookup/cancel/stream-resume authorization checks use actor scope. Unauthorized
and nonexistent refs are intentionally indistinguishable to API callers.
- Mappings start as pending and are later bound to internal product-action /
turn-run / projection refs by ProductWorkflow wiring slices.
- Durable storage adapters live in `ironclaw_reborn_openai_compat_storage`;
this crate defines only the side-effect-free `OpenAiCompatRefStore` port and
ref vocabulary.

## Route Surface

The descriptor table covers:
Expand Down
5 changes: 5 additions & 0 deletions crates/ironclaw_reborn_openai_compat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ default = []
openai-compat-beta = ["dep:axum"]

[dependencies]
async-trait = "0.1"
hex = "0.4"
ironclaw_host_api = { path = "../ironclaw_host_api", version = "0.1.0" }
Comment thread
hanakannzashi marked this conversation as resolved.
Resolved
ironclaw_product_adapters = { path = "../ironclaw_product_adapters", version = "0.1.0" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sha2 = "0.10"
thiserror = "2"
tracing = "0.1"
uuid = { version = "1", features = ["v4", "serde"] }

axum = { version = "0.8", optional = true }

Expand Down
6 changes: 4 additions & 2 deletions crates/ironclaw_reborn_openai_compat/src/chat.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use serde::{Deserialize, Serialize};

use crate::OpenAiChatCompletionId;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct OpenAiChatCompletionRequest {
pub model: String,
Expand Down Expand Up @@ -91,7 +93,7 @@ pub struct OpenAiChatToolCallFunction {

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct OpenAiChatCompletionResponse {
pub id: String,
pub id: OpenAiChatCompletionId,
pub object: String,
pub created: u64,
pub model: String,
Expand All @@ -110,7 +112,7 @@ pub struct OpenAiChatChoice {

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct OpenAiChatCompletionChunk {
pub id: String,
pub id: OpenAiChatCompletionId,
pub object: String,
pub created: u64,
pub model: String,
Expand Down
22 changes: 22 additions & 0 deletions crates/ironclaw_reborn_openai_compat/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use ironclaw_product_adapters::{ProductAdapterError, ProductWorkflowRejectionKind};
use serde::{Deserialize, Serialize};

use crate::OpenAiCompatRefError;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum OpenAiCompatErrorKind {
Expand Down Expand Up @@ -132,6 +134,14 @@ impl OpenAiCompatHttpError {
Self::from_kind(400, false, OpenAiCompatErrorKind::Validation, param)
}

pub fn not_found(param: Option<String>) -> Self {
Self::from_kind(404, false, OpenAiCompatErrorKind::NotFound, param)
}

pub fn conflict(param: Option<String>) -> Self {
Self::from_kind(409, false, OpenAiCompatErrorKind::Conflict, param)
}

pub fn not_wired() -> Self {
Self::from_kind(501, false, OpenAiCompatErrorKind::Unsupported, None)
}
Expand Down Expand Up @@ -202,6 +212,18 @@ impl From<ProductAdapterError> for OpenAiCompatHttpError {
}
}

impl From<OpenAiCompatRefError> for OpenAiCompatHttpError {
fn from(error: OpenAiCompatRefError) -> Self {
match error {
OpenAiCompatRefError::InvalidIdentifier { .. } => Self::invalid_request(None),
OpenAiCompatRefError::StoreUnavailable => {
Self::from_kind(503, true, OpenAiCompatErrorKind::ServiceUnavailable, None)
}
OpenAiCompatRefError::CorruptMapping => Self::internal(),
}
}
}

#[cfg(feature = "openai-compat-beta")]
impl axum::response::IntoResponse for OpenAiCompatHttpError {
fn into_response(self) -> axum::response::Response {
Expand Down
11 changes: 11 additions & 0 deletions crates/ironclaw_reborn_openai_compat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod descriptors;
mod error;
#[cfg(feature = "openai-compat-beta")]
mod handlers;
mod refs;
mod responses;
#[cfg(feature = "openai-compat-beta")]
mod router;
Expand Down Expand Up @@ -43,6 +44,16 @@ pub use handlers::{
chat_completions, responses_api_cancel, responses_api_create, responses_api_retrieve,
responses_v1_cancel, responses_v1_create, responses_v1_retrieve,
};
pub use refs::{
InMemoryOpenAiCompatRefStore, OpenAiChatCompletionId, OpenAiCompatActorScope,
OpenAiCompatBindInternalRefs, OpenAiCompatIdempotencyConflict, OpenAiCompatIdempotencyKey,
OpenAiCompatInternalRefs, OpenAiCompatProductActionRef, OpenAiCompatProjectionRef,
OpenAiCompatPublicId, OpenAiCompatRefError, OpenAiCompatRefLookup, OpenAiCompatRefOperation,
OpenAiCompatRefReservation, OpenAiCompatRefReservationOutcome, OpenAiCompatRefStore,
OpenAiCompatRequestFingerprint, OpenAiCompatResourceBinding, OpenAiCompatResourceKind,
OpenAiCompatResourceMapping, OpenAiCompatRouteSurface, OpenAiCompatTurnRunRef,
OpenAiResponseId,
};
pub use responses::{
OpenAiResponseErrorObject, OpenAiResponseObject, OpenAiResponseOutputItem,
OpenAiResponseOutputItemStatus, OpenAiResponseStatus, OpenAiResponseUsage,
Expand Down
Loading
Loading