Support keyring OpenAI auth natively
This commit is contained in:
parent
3c3b5008db
commit
963c454c0c
8 changed files with 1188 additions and 74 deletions
975
epiphany-openai-auth-spine/Cargo.lock
generated
975
epiphany-openai-auth-spine/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -12,8 +12,10 @@ anyhow = "1"
|
|||
base64 = "0.22"
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
codex-client = { path = "../vendor/codex/codex-rs/codex-client" }
|
||||
codex-keyring-store = { path = "../vendor/codex/codex-rs/keyring-store" }
|
||||
reqwest = { version = "0.12", features = ["blocking", "json"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
sha2 = "0.10"
|
||||
thiserror = "2"
|
||||
tracing = "0.1"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
use std::fs::OpenOptions;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::RwLock;
|
||||
|
|
@ -7,6 +10,8 @@ use chrono::DateTime;
|
|||
use chrono::Utc;
|
||||
use codex_client::build_reqwest_client_with_custom_ca;
|
||||
use codex_client::with_chatgpt_cloudflare_cookie_store;
|
||||
use codex_keyring_store::DefaultKeyringStore;
|
||||
use codex_keyring_store::KeyringStore;
|
||||
use reqwest::StatusCode;
|
||||
use reqwest::header::HeaderMap;
|
||||
use reqwest::header::HeaderValue;
|
||||
|
|
@ -14,7 +19,10 @@ use serde::Deserialize;
|
|||
use serde::Serialize;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde_json::Value;
|
||||
use sha2::Digest;
|
||||
use sha2::Sha256;
|
||||
use thiserror::Error;
|
||||
use tracing::warn;
|
||||
|
||||
pub const OPENAI_API_KEY_ENV_VAR: &str = "OPENAI_API_KEY";
|
||||
pub const CODEX_API_KEY_ENV_VAR: &str = "CODEX_API_KEY";
|
||||
|
|
@ -22,12 +30,16 @@ pub const REFRESH_TOKEN_URL_OVERRIDE_ENV_VAR: &str = "CODEX_REFRESH_TOKEN_URL_OV
|
|||
const REFRESH_TOKEN_URL: &str = "https://auth.openai.com/oauth/token";
|
||||
const CLIENT_ID: &str = "app_EMoamEEZ73f0CkXaXp7hrann";
|
||||
const TOKEN_REFRESH_INTERVAL_MINUTES: i64 = 8;
|
||||
const KEYRING_SERVICE: &str = "Codex Auth";
|
||||
|
||||
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum AuthCredentialsStoreMode {
|
||||
#[default]
|
||||
File,
|
||||
Keyring,
|
||||
Auto,
|
||||
Ephemeral,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
|
|
@ -141,6 +153,7 @@ pub struct ApiKeyAuth {
|
|||
pub struct ChatgptAuth {
|
||||
auth: AuthDotJson,
|
||||
codex_home: PathBuf,
|
||||
store_mode: AuthCredentialsStoreMode,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -239,6 +252,7 @@ impl ChatgptAuth {
|
|||
let previous_access_token = tokens.access_token.clone();
|
||||
return refresh_and_persist_tokens(
|
||||
self.codex_home.clone(),
|
||||
self.store_mode,
|
||||
tokens.refresh_token.clone(),
|
||||
)
|
||||
.map(|auth| {
|
||||
|
|
@ -296,6 +310,7 @@ impl ChatgptAuthTokens {
|
|||
pub struct AuthManager {
|
||||
codex_home: PathBuf,
|
||||
enable_codex_api_key_env: bool,
|
||||
store_mode: AuthCredentialsStoreMode,
|
||||
cached_auth: RwLock<Option<CodexAuth>>,
|
||||
}
|
||||
|
||||
|
|
@ -303,19 +318,28 @@ impl AuthManager {
|
|||
pub fn shared(
|
||||
codex_home: PathBuf,
|
||||
enable_codex_api_key_env: bool,
|
||||
_auth_credentials_store_mode: AuthCredentialsStoreMode,
|
||||
auth_credentials_store_mode: AuthCredentialsStoreMode,
|
||||
_chatgpt_base_url: Option<String>,
|
||||
) -> Arc<Self> {
|
||||
Arc::new(Self::new(codex_home, enable_codex_api_key_env))
|
||||
Arc::new(Self::new(
|
||||
codex_home,
|
||||
enable_codex_api_key_env,
|
||||
auth_credentials_store_mode,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn new(codex_home: PathBuf, enable_codex_api_key_env: bool) -> Self {
|
||||
let cached_auth = load_auth(&codex_home, enable_codex_api_key_env)
|
||||
pub fn new(
|
||||
codex_home: PathBuf,
|
||||
enable_codex_api_key_env: bool,
|
||||
store_mode: AuthCredentialsStoreMode,
|
||||
) -> Self {
|
||||
let cached_auth = load_auth(&codex_home, enable_codex_api_key_env, store_mode)
|
||||
.ok()
|
||||
.flatten();
|
||||
Self {
|
||||
codex_home,
|
||||
enable_codex_api_key_env,
|
||||
store_mode,
|
||||
cached_auth: RwLock::new(cached_auth),
|
||||
}
|
||||
}
|
||||
|
|
@ -331,9 +355,13 @@ impl AuthManager {
|
|||
{
|
||||
return Some(auth);
|
||||
}
|
||||
let auth = load_auth(&self.codex_home, self.enable_codex_api_key_env)
|
||||
.ok()
|
||||
.flatten();
|
||||
let auth = load_auth(
|
||||
&self.codex_home,
|
||||
self.enable_codex_api_key_env,
|
||||
self.store_mode,
|
||||
)
|
||||
.ok()
|
||||
.flatten();
|
||||
if let Ok(mut guard) = self.cached_auth.write() {
|
||||
*guard = auth.clone();
|
||||
}
|
||||
|
|
@ -373,6 +401,7 @@ fn read_trimmed_env(key: &str) -> Option<String> {
|
|||
fn load_auth(
|
||||
codex_home: &PathBuf,
|
||||
enable_codex_api_key_env: bool,
|
||||
store_mode: AuthCredentialsStoreMode,
|
||||
) -> std::io::Result<Option<CodexAuth>> {
|
||||
if enable_codex_api_key_env && let Some(api_key) = read_codex_api_key_from_env() {
|
||||
return Ok(Some(CodexAuth::from_api_key(api_key)));
|
||||
|
|
@ -380,17 +409,17 @@ fn load_auth(
|
|||
if let Some(api_key) = read_openai_api_key_from_env() {
|
||||
return Ok(Some(CodexAuth::from_api_key(api_key)));
|
||||
}
|
||||
let auth_path = codex_home.join("auth.json");
|
||||
let contents = match std::fs::read_to_string(&auth_path) {
|
||||
Ok(contents) => contents,
|
||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(None),
|
||||
Err(err) => return Err(err),
|
||||
let Some(auth_dot_json) = load_auth_dot_json(codex_home, store_mode)? else {
|
||||
return Ok(None);
|
||||
};
|
||||
let auth_dot_json: AuthDotJson = serde_json::from_str(&contents)?;
|
||||
build_auth(codex_home.clone(), auth_dot_json).map(Some)
|
||||
build_auth(codex_home.clone(), store_mode, auth_dot_json).map(Some)
|
||||
}
|
||||
|
||||
fn build_auth(codex_home: PathBuf, auth_dot_json: AuthDotJson) -> std::io::Result<CodexAuth> {
|
||||
fn build_auth(
|
||||
codex_home: PathBuf,
|
||||
store_mode: AuthCredentialsStoreMode,
|
||||
auth_dot_json: AuthDotJson,
|
||||
) -> std::io::Result<CodexAuth> {
|
||||
if let Some(api_key) = auth_dot_json.openai_api_key.as_ref() {
|
||||
return Ok(CodexAuth::from_api_key(api_key.clone()));
|
||||
}
|
||||
|
|
@ -402,6 +431,7 @@ fn build_auth(codex_home: PathBuf, auth_dot_json: AuthDotJson) -> std::io::Resul
|
|||
AuthMode::Chatgpt => Ok(CodexAuth::Chatgpt(ChatgptAuth {
|
||||
auth: auth_dot_json,
|
||||
codex_home,
|
||||
store_mode,
|
||||
})),
|
||||
AuthMode::ChatgptAuthTokens => Ok(CodexAuth::ChatgptAuthTokens(ChatgptAuthTokens {
|
||||
auth: auth_dot_json,
|
||||
|
|
@ -414,6 +444,129 @@ fn build_auth(codex_home: PathBuf, auth_dot_json: AuthDotJson) -> std::io::Resul
|
|||
}
|
||||
}
|
||||
|
||||
fn auth_file(codex_home: &Path) -> PathBuf {
|
||||
codex_home.join("auth.json")
|
||||
}
|
||||
|
||||
fn load_file_auth_dot_json(codex_home: &Path) -> std::io::Result<Option<AuthDotJson>> {
|
||||
let auth_path = auth_file(codex_home);
|
||||
let contents = match std::fs::read_to_string(&auth_path) {
|
||||
Ok(contents) => contents,
|
||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(None),
|
||||
Err(err) => return Err(err),
|
||||
};
|
||||
serde_json::from_str(&contents)
|
||||
.map(Some)
|
||||
.map_err(std::io::Error::other)
|
||||
}
|
||||
|
||||
fn save_file_auth_dot_json(codex_home: &Path, auth: &AuthDotJson) -> std::io::Result<()> {
|
||||
let auth_path = auth_file(codex_home);
|
||||
if let Some(parent) = auth_path.parent() {
|
||||
std::fs::create_dir_all(parent)?;
|
||||
}
|
||||
let json_data = serde_json::to_string_pretty(auth).map_err(std::io::Error::other)?;
|
||||
let mut options = OpenOptions::new();
|
||||
options.truncate(true).write(true).create(true);
|
||||
let mut file = options.open(auth_path)?;
|
||||
file.write_all(json_data.as_bytes())?;
|
||||
file.flush()
|
||||
}
|
||||
|
||||
fn delete_file_if_exists(codex_home: &Path) -> std::io::Result<bool> {
|
||||
match std::fs::remove_file(auth_file(codex_home)) {
|
||||
Ok(()) => Ok(true),
|
||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(false),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
fn compute_store_key(codex_home: &Path) -> String {
|
||||
let canonical = codex_home
|
||||
.canonicalize()
|
||||
.unwrap_or_else(|_| codex_home.to_path_buf());
|
||||
let path_str = canonical.to_string_lossy();
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(path_str.as_bytes());
|
||||
let digest = hasher.finalize();
|
||||
let hex = format!("{digest:x}");
|
||||
let truncated = hex.get(..16).unwrap_or(&hex);
|
||||
format!("cli|{truncated}")
|
||||
}
|
||||
|
||||
fn load_keyring_auth_dot_json(codex_home: &Path) -> std::io::Result<Option<AuthDotJson>> {
|
||||
let store = DefaultKeyringStore;
|
||||
let key = compute_store_key(codex_home);
|
||||
match store.load(KEYRING_SERVICE, &key) {
|
||||
Ok(Some(serialized)) => serde_json::from_str(&serialized).map(Some).map_err(|err| {
|
||||
std::io::Error::other(format!(
|
||||
"failed to deserialize CLI auth from keyring: {err}"
|
||||
))
|
||||
}),
|
||||
Ok(None) => Ok(None),
|
||||
Err(error) => Err(std::io::Error::other(format!(
|
||||
"failed to load CLI auth from keyring: {}",
|
||||
error.message()
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
fn save_keyring_auth_dot_json(codex_home: &Path, auth: &AuthDotJson) -> std::io::Result<()> {
|
||||
let store = DefaultKeyringStore;
|
||||
let key = compute_store_key(codex_home);
|
||||
let serialized = serde_json::to_string(auth).map_err(std::io::Error::other)?;
|
||||
store
|
||||
.save(KEYRING_SERVICE, &key, &serialized)
|
||||
.map_err(|error| {
|
||||
std::io::Error::other(format!(
|
||||
"failed to write OAuth tokens to keyring: {}",
|
||||
error.message()
|
||||
))
|
||||
})?;
|
||||
if let Err(err) = delete_file_if_exists(codex_home) {
|
||||
warn!("failed to remove CLI auth fallback file: {err}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn load_auth_dot_json(
|
||||
codex_home: &Path,
|
||||
store_mode: AuthCredentialsStoreMode,
|
||||
) -> std::io::Result<Option<AuthDotJson>> {
|
||||
match store_mode {
|
||||
AuthCredentialsStoreMode::File => load_file_auth_dot_json(codex_home),
|
||||
AuthCredentialsStoreMode::Keyring => load_keyring_auth_dot_json(codex_home),
|
||||
AuthCredentialsStoreMode::Auto => match load_keyring_auth_dot_json(codex_home) {
|
||||
Ok(Some(auth)) => Ok(Some(auth)),
|
||||
Ok(None) => load_file_auth_dot_json(codex_home),
|
||||
Err(err) => {
|
||||
warn!("failed to load CLI auth from keyring, falling back to file storage: {err}");
|
||||
load_file_auth_dot_json(codex_home)
|
||||
}
|
||||
},
|
||||
AuthCredentialsStoreMode::Ephemeral => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
fn save_auth_dot_json(
|
||||
codex_home: &Path,
|
||||
store_mode: AuthCredentialsStoreMode,
|
||||
auth: &AuthDotJson,
|
||||
) -> std::io::Result<()> {
|
||||
match store_mode {
|
||||
AuthCredentialsStoreMode::File => save_file_auth_dot_json(codex_home, auth),
|
||||
AuthCredentialsStoreMode::Keyring => save_keyring_auth_dot_json(codex_home, auth),
|
||||
AuthCredentialsStoreMode::Auto => match save_keyring_auth_dot_json(codex_home, auth) {
|
||||
Ok(()) => Ok(()),
|
||||
Err(err) => {
|
||||
warn!("failed to save auth to keyring, falling back to file storage: {err}");
|
||||
save_file_auth_dot_json(codex_home, auth)
|
||||
}
|
||||
},
|
||||
AuthCredentialsStoreMode::Ephemeral => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
fn token_account_id(tokens: Option<&TokenData>) -> Option<String> {
|
||||
tokens.and_then(|tokens| {
|
||||
tokens
|
||||
|
|
@ -453,12 +606,12 @@ fn token_is_fedramp(tokens: Option<&TokenData>) -> bool {
|
|||
|
||||
fn refresh_and_persist_tokens(
|
||||
codex_home: PathBuf,
|
||||
store_mode: AuthCredentialsStoreMode,
|
||||
refresh_token: String,
|
||||
) -> std::io::Result<AuthDotJson> {
|
||||
let response = request_chatgpt_token_refresh_blocking(refresh_token)?;
|
||||
let auth_path = codex_home.join("auth.json");
|
||||
let contents = std::fs::read_to_string(&auth_path)?;
|
||||
let mut auth_dot_json: AuthDotJson = serde_json::from_str(&contents)?;
|
||||
let mut auth_dot_json = load_auth_dot_json(&codex_home, store_mode)?
|
||||
.ok_or_else(|| std::io::Error::other("ChatGPT auth record is not available"))?;
|
||||
let tokens = auth_dot_json.tokens.get_or_insert_with(TokenData::default);
|
||||
if let Some(id_token) = response.id_token {
|
||||
tokens.id_token = parse_chatgpt_jwt_claims(&id_token).map_err(std::io::Error::other)?;
|
||||
|
|
@ -470,7 +623,7 @@ fn refresh_and_persist_tokens(
|
|||
tokens.refresh_token = refresh_token;
|
||||
}
|
||||
auth_dot_json.last_refresh = Some(Utc::now());
|
||||
std::fs::write(&auth_path, serde_json::to_string_pretty(&auth_dot_json)?)?;
|
||||
save_auth_dot_json(&codex_home, store_mode, &auth_dot_json)?;
|
||||
Ok(auth_dot_json)
|
||||
}
|
||||
|
||||
|
|
@ -726,7 +879,19 @@ mod tests {
|
|||
fn parses_minimal_api_key_auth_json() {
|
||||
let auth: AuthDotJson =
|
||||
serde_json::from_str(r#"{"auth_mode":"apikey","OPENAI_API_KEY":"sk-test"}"#).unwrap();
|
||||
let built = build_auth(PathBuf::from("."), auth).unwrap();
|
||||
let built = build_auth(PathBuf::from("."), AuthCredentialsStoreMode::File, auth).unwrap();
|
||||
assert_eq!(built.auth_mode(), AuthMode::ApiKey);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_codex_auth_store_modes() {
|
||||
assert_eq!(
|
||||
serde_json::from_str::<AuthCredentialsStoreMode>(r#""auto""#).unwrap(),
|
||||
AuthCredentialsStoreMode::Auto
|
||||
);
|
||||
assert_eq!(
|
||||
serde_json::from_str::<AuthCredentialsStoreMode>(r#""keyring""#).unwrap(),
|
||||
AuthCredentialsStoreMode::Keyring
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ pub fn auth_manager(codex_home: std::path::PathBuf) -> Arc<AuthManager> {
|
|||
AuthManager::shared(
|
||||
codex_home,
|
||||
/*enable_codex_api_key_env*/ true,
|
||||
AuthCredentialsStoreMode::File,
|
||||
AuthCredentialsStoreMode::Auto,
|
||||
/*chatgpt_base_url*/ None,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ here is suspect until proven otherwise.
|
|||
|
||||
### Transformations
|
||||
|
||||
- `epiphany-openai-auth-spine` loads file/env auth, refreshes ChatGPT access
|
||||
tokens, preserves account metadata, and exposes the auth subset needed by the
|
||||
Epiphany OpenAI transport.
|
||||
- `epiphany-openai-auth-spine` loads env, file, keyring, and auto-fallback
|
||||
Codex auth, refreshes ChatGPT access tokens, preserves account metadata, and
|
||||
exposes the auth subset needed by the Epiphany OpenAI transport.
|
||||
- `epiphany-openai-codex-spine` converts `CodexAuth` directly into
|
||||
authorization/account headers, chooses the ChatGPT Codex backend or OpenAI API
|
||||
base URL from auth mode, builds a local serializable Responses request body,
|
||||
|
|
@ -52,8 +52,9 @@ here is suspect until proven otherwise.
|
|||
|
||||
- `epiphany-openai-auth-spine`: keep as the native credential compatibility
|
||||
organ. It knows the path Epiphany actually uses now: `CODEX_API_KEY` /
|
||||
`OPENAI_API_KEY`, `$CODEX_HOME/auth.json`, ChatGPT token refresh, account id,
|
||||
plan metadata, FedRAMP flag, and the standard HTTP client edge.
|
||||
`OPENAI_API_KEY`, `$CODEX_HOME/auth.json`, Codex keyring entries, auto
|
||||
keyring/file fallback, ChatGPT token refresh, account id, plan metadata,
|
||||
FedRAMP flag, and the standard HTTP client edge.
|
||||
- `codex-client`: keep only as a plain HTTP/SSE transport helper for now. It
|
||||
does not own Epiphany request shape, model policy, stream semantics, or durable
|
||||
state.
|
||||
|
|
@ -74,9 +75,9 @@ here is suspect until proven otherwise.
|
|||
of the native OpenAI spine graph. If a later model catalog is needed, it
|
||||
should be a typed Epiphany catalog document, not a revival of the old Codex
|
||||
provider stack.
|
||||
- Native auth does not yet preserve every Codex auth mode. Keyring storage,
|
||||
external bearer command auth, and agent identity are legacy/reference gaps
|
||||
unless a concrete user path proves they are needed.
|
||||
- Native auth does not yet preserve every Codex auth mode. External bearer
|
||||
command auth and agent identity are legacy/reference gaps unless a concrete
|
||||
user path proves they are needed.
|
||||
|
||||
## Extract Target
|
||||
|
||||
|
|
@ -176,13 +177,15 @@ application. `codex-core` re-exports the contract only as a compatibility
|
|||
alias, and `CodexThread` now calls native state-update functions around its
|
||||
remaining revision check, persistence validation, and rollout/session writeback.
|
||||
|
||||
The first credential extraction is now landed: `epiphany-openai-auth-spine`
|
||||
replaces `codex-login` in the native OpenAI path for file/env auth, ChatGPT
|
||||
token refresh, account metadata, and header material. `cargo tree` for
|
||||
`epiphany-openai-codex-spine` now finds no `codex-login`, `codex-api`,
|
||||
`codex-protocol`, `codex-app-server-protocol`, or model-provider crates. The
|
||||
remaining question is whether keyring/external bearer/agent-identity support
|
||||
deserves native implementation or should remain a sealed legacy Codex path.
|
||||
The credential extraction now covers Codex file/keyring/auto auth plus env API
|
||||
keys, ChatGPT token refresh, account metadata, and header material.
|
||||
`epiphany-openai-codex-spine` uses `AuthCredentialsStoreMode::Auto` by default,
|
||||
so native runtime calls preserve normal Codex keyring storage without importing
|
||||
`codex-login`. `cargo tree` for `epiphany-openai-codex-spine` now finds no
|
||||
`codex-login`, `codex-api`, `codex-protocol`, `codex-app-server-protocol`, or
|
||||
model-provider crates. The remaining question is whether external
|
||||
bearer-command auth or agent identity deserves native implementation or should
|
||||
remain a sealed legacy Codex path.
|
||||
|
||||
The point is ownership: Epiphany calls a model adapter; it does not live inside
|
||||
the Codex host brain.
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ remembers doctrine; the branch remembers the blade.
|
|||
|
||||
- Do not copy exact branch or HEAD from this note. Run `git status --short --branch` and `git log --oneline -5`.
|
||||
- The active foundation directive is now `notes/codex-starvation-and-cultnet-liberation-plan.md`. The previous Codex app-server control-plane rebuild made Epiphany less rotten inside Codex, but that is not the destination. Epiphany must become a native CultCache/CultNet runtime. Codex is a compatibility reliquary for OpenAI subscription auth and model transport, not the host brain.
|
||||
- `notes/codex-auth-spine-inventory.md` is the source-grounded keeper list for that reliquary: `epiphany-openai-auth-spine` is now the native credential organ for file/env auth, ChatGPT token refresh, account metadata, and header material; `codex-client` remains only as a plain HTTP/SSE helper. `codex-login`, `codex-api`, `codex-model-provider`, `codex-model-provider-info`, `codex-core::client`, and `models-manager` are no longer keeper request-path organs; if model catalog/routing grows back, it should be an Epiphany typed document surface.
|
||||
- `notes/codex-auth-spine-inventory.md` is the source-grounded keeper list for that reliquary: `epiphany-openai-auth-spine` is now the native credential organ for env/file/keyring/auto auth, ChatGPT token refresh, account metadata, and header material; `codex-client` remains only as a plain HTTP/SSE helper. `codex-login`, `codex-api`, `codex-model-provider`, `codex-model-provider-info`, `codex-core::client`, and `models-manager` are no longer keeper request-path organs; if model catalog/routing grows back, it should be an Epiphany typed document surface.
|
||||
- Edge JSON is allowed for schema description, hostile ingress before immediate typed parsing, sealed forensic artifacts, or named quarantine experiments. When both subsystems are ours, runtime data must remain typed CultCache documents and move over CultNet typed contracts. Generic `serde_json::Value` in worker launch/result/selfPatch/runtime flow is contamination until classified and replaced.
|
||||
- `epiphany-openai-runtime` worker result ingress now parses assistant output directly into typed role/reorient ingress structs selected from the durable launch document, stores nested `statePatch` and `selfPatch` as typed MessagePack in `EpiphanyRuntimeRoleWorkerResult`, and no longer passes worker result data through generic `serde_json::Value`. JSON survives there only as the OpenAI text-output edge before typed deserialization.
|
||||
- Agent self-memory review/application now has typed `AgentSelfPatch` core APIs. JSON-value selfPatch functions are compatibility wrappers for CLI/artifact ingress; native callers should parse once at the edge and then call `review_agent_self_patch_document` / `apply_agent_self_patch_document`.
|
||||
- `epiphany-openai-codex-spine` no longer uses Codex's Responses client, model-provider layer, `codex-api`, `codex-model-provider`, `codex-model-provider-info`, `codex-protocol`, or `codex-login` for outbound model requests. It uses `epiphany-openai-auth-spine` for file/env credentials and ChatGPT token refresh, builds a local serializable OpenAI Responses body, opens the HTTP/SSE stream through `codex-client`, and parses Responses SSE frames into typed Epiphany stream events. `cargo tree` for the spine now finds no `codex-login`, `codex-api`, `codex-protocol`, `codex-app-server-protocol`, or model-provider crates. Caveat: keyring storage, external bearer command auth, and agent identity are not native yet.
|
||||
- `epiphany-openai-codex-spine` no longer uses Codex's Responses client, model-provider layer, `codex-api`, `codex-model-provider`, `codex-model-provider-info`, `codex-protocol`, or `codex-login` for outbound model requests. It uses `epiphany-openai-auth-spine` for env/file/keyring/auto credentials and ChatGPT token refresh, builds a local serializable OpenAI Responses body, opens the HTTP/SSE stream through `codex-client`, and parses Responses SSE frames into typed Epiphany stream events. `cargo tree` for the spine now finds no `codex-login`, `codex-api`, `codex-protocol`, `codex-app-server-protocol`, or model-provider crates. Caveat: external bearer command auth and agent identity are not native yet.
|
||||
- Durable Epiphany state types now live in root crate `epiphany-state-model`. `codex-protocol` re-exports them only so old rollout/API callers keep compiling; do not add new durable `Epiphany*` state structs under `vendor/codex`. `epiphany-core` imports the native model directly and no longer depends on `codex-protocol`. Pressure derives from native `EpiphanyTokenUsageSnapshot`; Codex token telemetry is mapped at the bridge. Codex rollout/event reconstruction now lives in `codex-core::epiphany_rollout`, where the Codex `RolloutItem` / `EventMsg` types belong. Exact retrieval path matching is native to `epiphany-core`, so `epiphany-core` has no direct vendored Codex crate dependency.
|
||||
- The May 2026 foundation migration in `notes/epiphany-ideal-architecture-rebuild-plan.md` is complete enough to defend. Read `notes/epiphany-architectural-teardown.md` before touching Epiphany control-plane code, but do not treat it as an open-ended excuse to keep shaving the altar. The rebuild moved scene projection, freshness derivation, pressure policy, targeted context shards, bounded graph traversal, job/progress view derivation, planning view derivation, reorientation resume/regather verdict policy, pure CRRC recommendation policy, fixed-lane coordinator decision policy, role-board projection policy, role/reorient result interpretation, role self-persistence review policy, and role/reorient acceptance bundle policy into `epiphany-core`; typed acceptance receipts replaced summary-string identity for live accept paths, runtime links are dual-written on launch, and result read-back now prefers runtime links.
|
||||
- Read `notes/epiphany-ideal-architecture-rebuild-plan.md` immediately after the teardown. It defines the smallest coherent replacement architecture: durable `EpiphanyState`, runtime-spine-owned `RuntimeState`, separate role memory/heartbeat state, `epiphany-core` as policy owner, app-server as adapter, Aquarium as reflector, typed acceptance receipts, and derived view lenses instead of a protocol verb zoo.
|
||||
|
|
@ -375,11 +375,11 @@ The next real move remains Codex starvation, not outward bridge work. The
|
|||
inventory and ledger now exist:
|
||||
|
||||
- `notes/codex-auth-spine-inventory.md` maps the shrinking Codex
|
||||
auth/model-call reliquary: `login` auth/token refresh is still kept for
|
||||
subscription compatibility, `codex-client` is a plain HTTP/SSE edge, and
|
||||
`codex-login` / `codex-api` / `codex-protocol` are no longer used by the
|
||||
native OpenAI request path. The remaining Codex auth gaps are keyring storage,
|
||||
external bearer command auth, and agent identity.
|
||||
auth/model-call reliquary: native auth now covers env/file/keyring/auto
|
||||
storage plus ChatGPT token refresh for subscription compatibility,
|
||||
`codex-client` is a plain HTTP/SSE edge, and `codex-login` / `codex-api` /
|
||||
`codex-protocol` are no longer used by the native OpenAI request path. The
|
||||
remaining Codex auth gaps are external bearer command auth and agent identity.
|
||||
- `notes/json-contamination-ledger.md` classifies the major Epiphany JSON
|
||||
contamination. Edge JSON is allowed only for schema/wire boundaries,
|
||||
hostile ingress before typed parse, sealed forensic artifacts, or named
|
||||
|
|
@ -576,18 +576,17 @@ transitively depends on `codex-login`, `codex-app-server-protocol`,
|
|||
`codex-model-provider-info`. The CultNet schema
|
||||
catalog advertises OpenAI adapter status, model request, stream event, and
|
||||
receipt document types plus the coordinator-owned model request contract. The
|
||||
remaining auth caveat is functional, not architectural: keyring storage,
|
||||
external bearer command auth, and agent identity are not implemented natively
|
||||
yet.
|
||||
remaining auth caveat is functional, not architectural: external bearer command
|
||||
auth and agent identity are not implemented natively yet.
|
||||
|
||||
The `epiphany-openai-spine` binary is now the first native edge for that
|
||||
wrapper. It can print typed adapter status and consume a serialized
|
||||
`EpiphanyOpenAiModelRequest` document for a model turn outside Codex
|
||||
app-server. Treat its JSON as CLI/file-edge serialization of typed documents,
|
||||
not internal data cargo. The native request path no longer pulls `codex-login`
|
||||
or `codex-api`; the next real cut is deciding whether keyring/external
|
||||
bearer/agent-identity auth deserves native implementation or remains sealed
|
||||
legacy Codex compatibility.
|
||||
or `codex-api`; the next real cut is deciding whether external bearer or
|
||||
agent-identity auth deserves native implementation or remains sealed legacy
|
||||
Codex compatibility.
|
||||
|
||||
The native runtime no longer imports `codex-login` directly. The Codex spine now
|
||||
exports the `default_codex_home` and `auth_manager` helpers, and those helpers
|
||||
|
|
@ -611,9 +610,9 @@ documents, and completes the original heartbeat/specialist runtime job without
|
|||
Codex worker execution. `roleResult` and `reorientResult` now require those
|
||||
typed worker result documents; generic runtime job summaries are lifecycle
|
||||
receipts, not reviewable findings.
|
||||
The next cut is no longer `codex-login` weight in this spine; it is either
|
||||
native keyring/external bearer/agent-identity auth support or the next
|
||||
Epiphany-in-vendor evacuation surface.
|
||||
The next cut is no longer `codex-login` weight or keyring support in this
|
||||
spine; it is either native external bearer/agent-identity auth support or the
|
||||
next Epiphany-in-vendor evacuation surface.
|
||||
|
||||
That coordinator cut is now landed for the MVP runner. `epiphany-mvp-coordinator`
|
||||
accepts `--openai-runtime-bin`, resolves the local `epiphany-openai-runtime`
|
||||
|
|
|
|||
Binary file not shown.
File diff suppressed because one or more lines are too long
Reference in a new issue