Skip to content

perf(runtime): keep credential reads out of plan compilation - #208

Merged
lg2m merged 5 commits into
fix/eng-815-harbor-testsfrom
perf/eng-791-credential-plan-compile
Sep 28, 2026
Merged

lg2m merged 5 commits into
fix/eng-815-harbor-testsfrom
perf/eng-791-credential-plan-compile

Conversation

@lg2m

@lg2m lg2m commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Stack #209, 2 of 3: #207 → #208 (this) → #189. Diff shown is this layer only.

What changes for users

Faster time to first token on machines with several configured providers and a secure keyring, especially macOS.

RuntimeFactory::load built the spawn_agent route list through configured_model_options, which calls provider_authenticated (a keyring read) for every configured provider on every plan compile; ModelDiscovery::cached additionally resolved a credential just to derive a cache key. Each compile cost N+1 secure-store reads; on macOS each is a securityd round trip.

Now:

  • The spawn_agent route list and Jev routing candidates admit a provider when its credential is present (a name in the credential index from one index load, a set environment variable, an inline value, NoAuth, an AWS source) without reading the secret. A present-but-unusable credential fails at the child's own load, where the router already falls back to the configured model. Isolated TUI QA offers only its fixture route. Model catalogs shown to a client (/models) still resolve each credential.
  • The discovery cache probe is skipped whenever its scope would need secure-store I/O (Codex, XAI, stored secret references, built-in API-key fallback without an explicit non-stored value); the configured reasoning ladder applies.
  • One read remains: the selected provider's own credential, which its compiled recipe needs.

Measured

cargo test -p qq --release -- --ignored plan_compile_with_slow_keyring --nocapture, 5 ms per keyring read, cold compile median over 50 iterations:

stored-credential providers main this PR reads/compile
1 10.5 ms 5.2 ms 2 → 1
4 25.6 ms 5.4 ms 5 → 1
16 86.2 ms 5.7 ms 17 → 1

Review round

Codex found a real regression in the first cut: dropping the check entirely advertised every built-in catalog (64 routes against 17 on a default config), bypassed the isolated QA single-route guard, and left routing candidates probing every provider. Fixed in fix(runtime): admit plan spawn routes on credential presence with regression tests; the MCP doc qualification was also taken. Timings unchanged (5.2 / 5.3 / 5.5 ms).

Design

Extracted from #189 (927ab0b, b0ae622, 2415d79, kept with -x and rebased onto main without that stack's admission/--state-root machinery). No protocol, schema, config, or Jev change; no new dependency.

Verification

  • New regression tests plan_compilation_reads_only_the_selected_providers_credential (12 providers, exactly 1 keyring read; main: 13) and plan_spawn_routes_offer_only_providers_with_a_credential_present; isolated-QA single-route assertion.
  • Contributor's PanicOnReadKeyring tests (codex_plan_compilation_keeps_credentials_request_time, codex_plan_with_no_live_cache_uses_configured_effort_ladder) and the cache_only_discovery read-count test.
  • cargo fmt --check, cargo clippy --workspace --all-targets --all-features -D warnings, cargo test -p qq green.
  • docs/design/architecture.md credential paragraph and docs/plans/progress/speed-first.md ledger entry updated.

Linear: ENG-791.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T19:32:29.698884Z e068779 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5a7013ebd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/runtime.rs Resolved
Comment thread src/runtime.rs Resolved
Adds a regression test that a compile with twelve stored-credential
providers reads the secure store once (main read it thirteen times) and an
ignored benchmark that times cold compiles behind a 5 ms-per-read keyring
for 1/4/16 providers. Records the before/after in the speed-first ledger and
corrects the architecture text: one read remains, the selected provider's
own credential.

Linear: ENG-791
@lg2m
lg2m force-pushed the perf/eng-791-credential-plan-compile branch from e5a7013 to 994d5d0 Compare September 28, 2026 18:53
@lg2m
lg2m changed the base branch from main to fix/eng-815-harbor-tests September 28, 2026 18:53
@lg2m
lg2m added this pull request to stack #209 September 28, 2026 18:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 994d5d067a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/runtime.rs Resolved
Comment thread docs/design/architecture.md Resolved
…ndly

The first cut stopped probing credentials by admitting every configured
provider, which advertised every built-in catalog to spawn_agent (64 routes
on a default config against 17), let unauthenticated providers crowd the
bounded list, bypassed the isolated QA profile's single-route guard, and
left Jev routing candidates probing every provider through
configured_model_options.

model_options_for_plan now admits a provider when its credential is present
(index name from one index load, environment variable, inline value, NoAuth,
AWS source) without reading the secret, returns the fixture route alone in
isolated QA, and is used for routing candidates too. configured_model_options
remains for tests only. Architecture text narrowed to the provider path and
names the MCP bearer resolution on a registry-cache miss.

Tests: plan_spawn_routes_offer_only_providers_with_a_credential_present;
isolated_tui_qa_policy_survives_runtime_callbacks_and_reconnect now asserts
the plan's single spawn route.

Linear: ENG-791

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0687796f9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/runtime.rs Resolved
@lg2m
lg2m merged commit 8ef6f78 into main Sep 28, 2026
4 checks passed
@lg2m
lg2m deleted the perf/eng-791-credential-plan-compile branch September 28, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants