aKode fase 2b-2: rimosso login ChatGPT e tutti i sottosistemi solo-ChatGPT

- Login: resta solo chiave API (+ header, Bedrock). Rimossi OAuth/browser,
  device code, refresh/revoke su auth.openai.com, PAT, agent/workload identity,
  runtime agent instance, backend-client e openapi-models, workspace routing.
- Rimossi: generazione immagini (ext + skill imagegen), history notes, plugin
  remoti (catalogo, sync, share), cyber access program, daybreak, cloud config
  e requirements (config_server ora fail-closed), attestation, frozen cloud
  skills, EMA MCP auth, Codex Apps/connettori, ricerca ospitata, header/zstd/
  routing/cookie del backend Codex, fallback OPENAI_API_KEY del realtime.
- Messaggi d'errore senza link a chatgpt.com.
- Chiavi di config legacy accettate e ignorate; feature rimosse = Stage::Removed.
- Test: cancellati solo quelli del codice rimosso; test di sicurezza
  (sandbox estensioni, permessi, redazione, auth storage, requirements)
  adattati. Restano solo fallimenti d'ambiente (code-mode-host/V8, ~/.agents).
- Istruzioni di sistema invariate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-10 16:20:15 +01:00
parent 82347a58ed
commit 6089fbde91
1573 changed files with 10289 additions and 177679 deletions

View File

@@ -59,145 +59,6 @@ use wiremock::ResponseTemplate;
use wiremock::matchers::method;
use wiremock::matchers::path;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn thread_creator_survives_resume_and_forks_use_current_auth() -> Result<()> {
use base64::Engine;
let server = start_mock_server().await;
Mock::given(method("POST"))
.respond_with(
ResponseTemplate::new(200)
.insert_header("content-type", "text/event-stream")
.set_body_raw(
responses::sse(vec![ev_response_created("resp"), ev_completed("resp")]),
"text/event-stream",
),
)
.mount(&server)
.await;
let chatgpt_auth = |user_id: &str, account_id: &str| {
let claims = base64::engine::general_purpose::URL_SAFE_NO_PAD.encode(
json!({"https://api.openai.com/auth": {"chatgpt_user_id": user_id}}).to_string(),
);
CodexAuth::from_external_chatgpt_tokens(
&format!("e30.{claims}.sig"),
account_id,
/*chatgpt_plan_type*/ None,
)
};
for auth in [
chatgpt_auth("creator-user", "creator-account")?,
CodexAuth::from_api_key("test"),
] {
let expected_creator = (auth.get_chatgpt_user_id(), auth.get_account_id());
let mut builder = test_codex().with_auth(auth).with_config(|config| {
config
.features
.enable(Feature::Sqlite)
.expect("enable SQLite");
});
let test = builder.build_with_auto_env(&server).await?;
test.submit_turn("persist creator").await?;
let thread_id = test.session_configured.thread_id;
let rollout_path = test.codex.rollout_path().expect("rollout path");
test.codex.shutdown_and_wait().await?;
let meta = codex_rollout::read_session_meta_line(&rollout_path)
.await?
.meta;
let stored = test
.codex
.state_db()
.expect("SQLite")
.get_thread(thread_id)
.await?
.expect("thread");
assert_eq!(
(meta.creator_user_id, meta.creator_account_id),
expected_creator
);
assert_eq!(
(stored.creator_user_id, stored.creator_account_id),
expected_creator
);
let mut resume_builder = test_codex()
.with_auth(chatgpt_auth("resuming-user", "resuming-account")?)
.with_config(|config| {
config
.features
.enable(Feature::Sqlite)
.expect("enable SQLite");
});
let resumed = resume_builder
.resume(&server, test.home.clone(), rollout_path.clone())
.await?;
resumed.submit_turn("resume under another account").await?;
resumed.codex.shutdown_and_wait().await?;
let meta = codex_rollout::read_session_meta_line(&rollout_path)
.await?
.meta;
let stored = resumed
.codex
.state_db()
.expect("SQLite")
.get_thread(thread_id)
.await?
.expect("thread");
assert_eq!(
(meta.creator_user_id, meta.creator_account_id),
expected_creator
);
assert_eq!(
(stored.creator_user_id, stored.creator_account_id),
expected_creator
);
let fork = resumed
.thread_manager
.fork_legacy_thread(
codex_core::ForkSnapshot::Interrupted,
StartThreadOptions::new(resumed.config.clone()),
rollout_path,
)
.await?;
fork.thread
.start_or_steer_turn(TurnInputRequest::user_input(vec![UserInput::Text {
text: "persist fork".to_string(),
text_elements: Vec::new(),
}]))
.await?;
wait_for_event(&fork.thread, |event| {
matches!(event, EventMsg::TurnComplete(_))
})
.await;
let fork_path = fork.thread.rollout_path().expect("fork rollout");
fork.thread.shutdown_and_wait().await?;
let meta = codex_rollout::read_session_meta_line(&fork_path)
.await?
.meta;
let stored = fork
.thread
.state_db()
.expect("SQLite")
.get_thread(fork.thread_id)
.await?
.expect("fork");
let expected_fork = (
Some("resuming-user".to_string()),
Some("resuming-account".to_string()),
);
assert_eq!(
(meta.creator_user_id, meta.creator_account_id),
expected_fork
);
assert_eq!(
(stored.creator_user_id, stored.creator_account_id),
expected_fork
);
}
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn new_thread_is_recorded_in_state_db() -> Result<()> {
let server = start_mock_server().await;