Skip to content

refactor(auth): split credential state and backends out of lib.rs (ENG-1066) - #347

Merged
lg2m merged 1 commit into
refactor/eng-1066-ap3-audiencesfrom
refactor/eng-1066-ap4-store-module
Oct 18, 2026
Merged

lg2m merged 1 commit into
refactor/eng-1066-ap3-audiencesfrom
refactor/eng-1066-ap4-store-module

Conversation

@lg2m

@lg2m lg2m commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

AP4: split credential state and backends out of lib.rs

Spec: docs/plans/auth-providers.md (AP4) Linear: ENG-1066 Stacked on: #346

A move-only refactor. No user-visible change.

What changed

  • state.rs (new): the on-disk index and plaintext fallback formats (CredentialRecord, IndexState, FallbackState) together with the hardened file operations every write goes through: data-directory checks, lock files, bounded reads, permission checks and atomic writes. The format version constants and the temp-file counter move with them.
  • backend.rs (new): the OS keyring and Windows user-protected secret backends, with WINDOWS_PROTECTED_MAGIC and its sha2 import, which are Windows-only.
  • lib.rs: 2774 lines down to 1904. It keeps the CredentialStore operations, errors, resolution and request-credential loading.
  • Each module now names its own imports explicitly instead of relying on lib.rs's. Items that moved became pub(crate), except KeyringBackend and KeyringError, which are still re-exported publicly. No bodies changed.
  • tests.rs imports fs::File directly. It had been getting File from lib.rs through use super::*.

How verified

  • cargo nextest run -p qq-auth: 79/79, the same count as on the AP3 head. No test or assertion changed.
  • cargo clippy -p qq-auth --all-targets --all-features -D warnings is clean, and so is the minimal qq-provider profile.
  • cargo xtask smoke: 8/8.
  • git patch-id for this PR's own diff is the same before and after the rebase onto origin/main a9bff3ef.
  • The full gate fails on one test that comes from main. qq headless::tests::closing_goal_host_drains_accepted_work_without_admitting_successors (src/headless.rs:4553, added in feat(cli)!: expose durable goals in TUI and headless commands #331) times out after 10s. It also failed 5 out of 5 runs on the plan-only branch, which has no Rust changes relative to origin/main, and it passes intermittently, so this PR didn't introduce it. Main's own CI at a9bff3ef is red too, on goal_model_audit_late_and_stale_confirmation_cannot_achieve (crates/qq-core/src/sessions/tests/goal_model_audit.rs:444). Both are from the goals stack (ENG-1063/ENG-1064).
cargo xtask check

Head 9283a87ff7b8 vs origin/main; 17 changed file(s); scope: qq, qq-auth, qq-client, qq-config, qq-core, qq-harness, qq-mcp, qq-provider, qq-server, qq-tui, xtask.

Gate Result Tests Time Command
fmt pass 1.6s cargo fmt --all -- --check
lint pass 2.1s cargo xtask lint
clippy pass 4.4s cargo clippy ... --all-targets --all-features -- -D warnings
test fail 2709/2710 passed, 15 skipped 378.3s cargo nextest run ...
  • qq headless::tests::closing_goal_host_drains_accepted_work_without_admitting_successors: panicked at src/headless.rs:4553:18 (pre-existing on main; see above).

Compatibility

  • PROTOCOL / DESCRIPTOR / store schema / on-disk formats / public API: unchanged.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 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 ⚠️ Failed 2026-10-18T02:20:44.685144Z 9811e69 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

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 9283a87ff7

ℹ️ 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".

@lg2m
lg2m added this pull request to stack #344 October 17, 2026 09:30
…G-1066)

Slice AP4, move only. The on-disk index and plaintext fallback formats and
the hardened file operations move to state.rs; the OS keyring and Windows
user-protected backends move to backend.rs. Each module imports what it
uses instead of sharing lib.rs's imports; the constants each format owns
move with it. lib.rs keeps the CredentialStore operations, errors and
resolution. No item, value or behaviour changes.
@lg2m
lg2m force-pushed the refactor/eng-1066-ap4-store-module branch from 9283a87 to 9811e69 Compare October 18, 2026 02:20
@lg2m
lg2m merged commit b1c66be into main Oct 18, 2026
6 checks passed
@lg2m
lg2m deleted the refactor/eng-1066-ap4-store-module branch October 18, 2026 02:20
lg2m added a commit that referenced this pull request Oct 18, 2026
…350)

* docs(plans): mark AP0–AP4 shipped and map qq-auth modules (ENG-1066)

The ledger records the merge commits for #341 and #343–#347 with their
receipt; the plan's pre-AP1 shape section says what AP1–AP4 removed; the
architecture source map lists qq-auth's modules (lib, state, backend,
oauth, codex, xai) instead of lib.rs alone.

* docs(plans): state exactly what AP1–AP4 consolidated (ENG-1066)

Review of c183af0: the plan claimed AP1–AP4 removed the per-provider
storage duplication, but token clients, stored formats, request-credential
providers and error mappings remain for AP5/AP8. The architecture map
assigned operation locks to oauth.rs; lib.rs acquires them and state.rs
defines the guard.
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.

1 participant