codex: use app-shaped metadata batch contract

This commit is contained in:
Steven Lee
2026-07-07 21:29:00 +00:00
parent b9bbf5be87
commit a47c96f887
4 changed files with 26 additions and 26 deletions
+2 -2
View File
@@ -1870,7 +1870,7 @@ instead of failing the whole request.
{
"id": "demo-app",
"name": "Demo App",
"description": "Example connector for documentation.",
"description": "Example app for documentation.",
"distributionChannel": null,
"branding": null,
"appMetadata": null,
@@ -1883,7 +1883,7 @@ instead of failing the whole request.
```
`app/read` reads fresh metadata records from a cache partitioned by backend URL and ChatGPT
account/workspace identity, then makes at most one `POST /ps/connectors/batch` for missing or
account/workspace identity, then makes at most one `POST /ps/apps/batch` for missing or
expired ids with `include_actions=false` and `include_model_descriptions=false`. Backend or
transport failures return an RPC error without replacing existing cache records. Its metadata
shape intentionally excludes runtime state, MCP tools, actions, model descriptions, and icon
@@ -39,9 +39,9 @@ const DEFAULT_TIMEOUT: Duration = Duration::from_secs(30);
#[tokio::test]
async fn app_read_deduplicates_orders_partial_misses_and_reuses_cached_metadata() -> Result<()> {
let state = BatchServerState::new(json!({
"connectors": [
connector_response("alpha", "Alpha", Some("https://chatgpt.com/apps/alpha/alpha")),
connector_response("beta", "Beta", Some("https://chatgpt.com/apps/beta/beta")),
"apps": [
app_response("alpha", "Alpha", Some("https://chatgpt.com/apps/alpha/alpha")),
app_response("beta", "Beta", Some("https://chatgpt.com/apps/beta/beta")),
]
}));
let (server_url, server_handle) = start_batch_server(state.clone()).await?;
@@ -73,7 +73,7 @@ async fn app_read_deduplicates_orders_partial_misses_and_reuses_cached_metadata(
assert_eq!(
state.requests(),
vec![json!({
"connector_ids": ["beta", "missing", "alpha", "forbidden"],
"app_ids": ["beta", "missing", "alpha", "forbidden"],
"include_actions": false,
"include_model_descriptions": false,
})]
@@ -104,7 +104,7 @@ async fn app_read_deduplicates_orders_partial_misses_and_reuses_cached_metadata(
#[tokio::test]
async fn app_read_backend_failure_preserves_fresh_cached_records() -> Result<()> {
let state = BatchServerState::new(json!({
"connectors": [connector_response("cached", "Cached", /*install_url*/ None)]
"apps": [app_response("cached", "Cached", /*install_url*/ None)]
}));
let (server_url, server_handle) = start_batch_server(state.clone()).await?;
let codex_home = TempDir::new()?;
@@ -225,7 +225,7 @@ fn metadata(id: &str, name: &str, install_url: Option<&str>) -> ConnectorMetadat
}
}
fn connector_response(id: &str, name: &str, install_url: Option<&str>) -> Value {
fn app_response(id: &str, name: &str, install_url: Option<&str>) -> Value {
let mut response = json!({
"id": id,
"name": name,
@@ -331,7 +331,7 @@ async fn start_batch_server(state: BatchServerState) -> Result<(String, JoinHand
let listener = TcpListener::bind("127.0.0.1:0").await?;
let addr = listener.local_addr()?;
let router = Router::new()
.route("/ps/connectors/batch", post(batch_connectors))
.route("/ps/apps/batch", post(batch_apps))
.with_state(state);
let handle = tokio::spawn(async move {
let _ = axum::serve(listener, router).await;
@@ -339,7 +339,7 @@ async fn start_batch_server(state: BatchServerState) -> Result<(String, JoinHand
Ok((format!("http://{addr}"), handle))
}
async fn batch_connectors(
async fn batch_apps(
State(state): State<BatchServerState>,
headers: HeaderMap,
Json(body): Json<Value>,
+15 -15
View File
@@ -154,12 +154,12 @@ pub async fn read_connector_metadata(
.collect::<Vec<_>>();
if !missing_ids.is_empty() {
let response: GetConnectorsResponse = chatgpt_post_request_with_timeout(
let response: GetAppsResponse = chatgpt_post_request_with_timeout(
config,
&auth,
"/ps/connectors/batch",
&GetConnectorsRequest {
connector_ids: &missing_ids,
"/ps/apps/batch",
&GetAppsRequest {
app_ids: &missing_ids,
include_actions: false,
include_model_descriptions: false,
},
@@ -168,9 +168,9 @@ pub async fn read_connector_metadata(
.await?;
let mut requested_ids = missing_ids.iter().cloned().collect::<HashSet<_>>();
let fetched = response
.connectors
.apps
.into_iter()
.map(batch_connector_to_metadata)
.map(batch_app_to_metadata)
.filter(|metadata| requested_ids.remove(&metadata.id))
.collect::<Vec<_>>();
store.commit(&fetched);
@@ -198,23 +198,23 @@ pub async fn read_connector_metadata(
}
#[derive(Serialize)]
struct GetConnectorsRequest<'a> {
connector_ids: &'a [String],
struct GetAppsRequest<'a> {
app_ids: &'a [String],
include_actions: bool,
include_model_descriptions: bool,
}
#[derive(Deserialize)]
struct GetConnectorsResponse {
connectors: Vec<BatchConnector>,
struct GetAppsResponse {
apps: Vec<BatchApp>,
}
/// The explicit metadata-only projection of plugin-service's broader Connector response.
/// The explicit metadata-only projection of Plugin Service's public app response.
///
/// Serde ignores all other backend fields, including actions, model descriptions, runtime state,
/// and icons.
#[derive(Deserialize)]
struct BatchConnector {
struct BatchApp {
id: String,
name: String,
description: Option<String>,
@@ -225,8 +225,8 @@ struct BatchConnector {
install_url: Option<String>,
}
fn batch_connector_to_metadata(connector: BatchConnector) -> ConnectorMetadata {
let BatchConnector {
fn batch_app_to_metadata(app: BatchApp) -> ConnectorMetadata {
let BatchApp {
id,
name,
description,
@@ -235,7 +235,7 @@ fn batch_connector_to_metadata(connector: BatchConnector) -> ConnectorMetadata {
app_metadata,
labels,
install_url,
} = connector;
} = app;
ConnectorMetadata {
id,
name,
+1 -1
View File
@@ -7,7 +7,7 @@ use crate::AppBranding;
use crate::AppMetadata;
use crate::CONNECTORS_CACHE_TTL;
/// Metadata returned by the connector batch-read API.
/// Metadata returned by the app batch-read API.
///
/// This intentionally excludes connector runtime state, tools, actions, model descriptions, and
/// icon fields. Consumers that need those concepts must use their owning APIs instead of growing