Skip to content

refactor(auth): keep published store lookup passive - #200185

Merged
vincentkoc merged 4 commits into
mainfrom
refactor/auth-store-passive-owner-20261117
Nov 29, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
refactor/auth-store-passive-owner-20261117

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Reading already-published shared auth ownership currently imports database preparation and inspection code, even when the caller only needs the existing in-memory fact.

User Impact

No intended user-visible behavior change. Auth selection, storage, schema, configuration and permissions stay the same. This change establishes a passive auth lookup boundary; it does not claim an RSS reduction or complete the wider passive catalog-read refactor.

Why This Change Was Made

Keep the existing global ownership map and synchronous readers in their current owner. Move asynchronous preparation/reload into a small active module, and native inspection into the existing native module. Internal callers import the owner they actually use; retired internal exports are removed.

The same map, exact database-path keys, published object identity, and cold-publication limit remain. Admission capture still occurs before the first await; pending reads retain the existing currentness check and committed-owner recheck. Explicit commits and reloads are not newly capped. Filesystem fixtures move unchanged into their existing test-support module to satisfy the test-file line cap.

On the original change, production grew by three net lines and tests/support by 79. Benchmark code had zero net growth.

Evidence

  • Current signed head 66f0126c93ee72c9b8fb4814cf89e84481bdb081 integrates frozen main 8ac87d6697d196fb2a6c8d4bccfcc277caef7e04. Four existing consumers now import the passive, asynchronous or native owner they use. Main’s TUI entry points are preserved.
  • All 334 executed local cases passed on Node 24.22.1, including passive lookup, shared non-isolated reset, real model-auth publication, rotation, reload and agent mutation. Production types, formatting and scoped lint passed. Independent review of the complete integrated range found no actionable issue. The ordinary PR CI run tracks the hosted gates and build coverage for this head.
  • The original base was 6f5d3b399b31855501cc3f38f1221f7165554c59, the initial head 3fdbed9e9ef746fc004f95be1cd7f544809bb799, and the preceding signed head 1086709b6faceb428a1870d2807c174151998fda. Formatting, commit-hook ratchets and git diff --check passed there.
  • Independent complete-source owner/caller review found no blocker. Native autoreview completed five semantic assignments at P0–P3 with no findings and a final scoped-clean result. All 66 changed patches are included. Two import-only files under src/secrets/ use diff context because the native extra-source policy refuses that directory; their full bodies were reviewed independently and are unchanged.
  • The initial-head Node CI selected exact 3fdbed9 on Node 24.22.1. Verified passes include both new auth boundary tests (within 34 boundary cases), 11 direct ownership cases, asynchronous bootstrap, real model-auth publication, 29 agent-creation cases, 92 agent-mutation cases, and 110 reload cases. Production and build inputs were unchanged in the test-only correction 1086709. Its ordinary PR CI is recorded below.
  • Required focused coverage: passive import boundary, direct ownership identity, asynchronous bootstrap, model-auth refresh, real model-auth concurrency/rotation, agent creation/mutation, and shared non-isolated runner fixtures, plus affected caller tests selected by CI. Required gates include relevant type graphs, mock-export/format/lint checks and build.
  • CI artifact build, generated validators, launcher/native-host and built-artifact checks passed on 3fdbed9. The resulting runtime artifact (SHA-256 264a2c4eb9e39c569f675ff4b6d6c4bfa1dbbf72524f8826c3b88b7948a32fec) binds that exact source. The passive owner's complete emitted relative static closure contains 39 chunks and excludes active auth/database loaders; its external fs-safe paths were checked at pinned 0.27.1. This is static compiled-boundary evidence, not an executed compiled-lifetime or RSS claim. The separate Docker seed job ran scripts/build-all.mts on 3fdbed9, including cache-miss unified declaration emission and the complete build. Its later npm pack --ignore-scripts step timed out after 900 seconds, so the packaging/Docker job failed; the timeout cause remains unknown. Declaration proof carries to 1086709 because production and build inputs are unchanged. There is no new dedicated commit-during-read or pre-await-capture race witness.

Node CI on the initial head: https://github.com/openclaw/openclaw/actions/runs/43917795521. Its preflight confirms the exact 3fdbed9 checkout and Node 24.22.1. It found a stale namespace in the real model-auth concurrency test: the captured function and spy still referenced the passive module after the function moved. Commit 1086709 retargets only those test references and keeps the passive path lookup, barrier, rotation assertions and cleanup unchanged. A separate source review of that correction is scoped-clean with no findings.

The ordinary PR CI for 1086709 selected merge 9f97cab1923938a22473e456dab9a0c924010baa, with ordered parents 4a74c61ae7c438587bc272840d180d16f7c5a283 and 1086709b6faceb428a1870d2807c174151998fda. The state-logging type graph passed. The corrected SQLite model-auth worker suite ran and passed all 16 cases on this PR integration. Its test log includes all six cached/publication concurrency combinations, concurrent unrelated-order changes, and both snapshot and native-owner rotation receipt cases. The ordinary CI aggregate remains red on three other jobs. Exact-head ClawSweeper review reports no findings or before-merge items.

Three jobs failed on that earlier integration.

  • UI E2E failed at the pre-ACK scroll in both unadopted-successor cases. Independent timeout-receipt and OK-receipt builds failed at the same line with the same fixture blob. Upstream selected the resolved command row and removed the obsolete screenshot scroll. All four original ACK cases passed on the corrected checkout.
  • Real runtime proof: the admitted-facts refresh/replacement case received SessionMutationAuthorizationChangedError. The log does not identify the originating RPC or failed authority fact. The unchanged case passed in 26.856 seconds on the historical base and 28.932 seconds on the tested integration. Both isolated runs used the same Linux runner class, toolchain and process-local umask of 0022. Neither isolated run reproduced the full-shard failure. The identical test and error also occurred in two independent hosted builds, 005057b6 and 479a4b5a, with the original passive-owner code. The failing RPC is still unidentified.
  • Config RPC hit the 10-second agents.delete deadline in the fresh-revision create/update/delete case. The other 66 cases passed. Scheduled main independently failed at the same RPC in the same Bun shard. Its test, fixture and delete handler match the historical PR base byte for byte. Neither log identifies the stalled phase.

All three historical failure signatures also occurred outside this PR. The new integrated head has completed local qualification and independent source review. Its hosted gates remain pending. No retry, timeout increase or assertion weakening was applied. Initial-head supporting behavior/build results remain distinct from current-head validation; neither full CI run is claimed green. The historical native backend executed no producer and its allocation custody remains UNKNOWN. The 334 local passes above used a separately qualified frozen install on the new head.

@vincentkoc vincentkoc self-assigned this Nov 16, 2026
@clawsweeper

clawsweeper Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@vincentkoc
vincentkoc marked this pull request as ready for review November 16, 2026 17:50
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 16, 2026
@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR separates passive shared-auth ownership lookup from asynchronous database preparation and native inspection.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-consistent, with useful boundary coverage; unresolved current-head CI limits validation confidence.
Proof confidence 🦐 gold shrimp (3/6) This behavior-preserving module refactor requires no shipped-entry-point demonstration; supplied boundary tests and compiled-import evidence address its structural goal.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
Reason: The maintainer-authored direction creates a useful passive import boundary without changing auth selection or adding another state owner.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored refactor preserves the existing ownership contract, with no confirmed patch defect; current-head CI failures remain unattributed.

Priority: P3
Reviewed head: 1086709b6faceb428a1870d2807c174151998fda

Before merge

None.

Findings

None.

Agent review details

How this fits together

Auth lifecycle callers prepare or reload ownership from machine state, publish it into one process-wide map, and synchronous readers consume that fact to select the shared credential database.

flowchart TD
  A[Auth lifecycle callers] --> B[Async preparation]
  B --> C[Shared state worker]
  C --> D[Published ownership map]
  E[Native inspection and preparation] --> D
  D --> F[Passive path readers]
Loading

Technical review

Best possible solution:

Retain the single passive ownership owner and separated preparation modules, then resolve the current-head CI disposition before landing.

Do we have a high-confidence way to reproduce the issue?

The base and fetched-main imports directly establish the coupled dependency boundary; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The module split is a focused solution that preserves the existing state owner, storage contract, synchronous SDK adapters, and lifecycle behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f4fa17a710be.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 63b18e6 adds src/agents/auth-profiles/path-resolve.ts:41 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 63b18e6e5f49; files: src/agents/auth-profiles/path-resolve.ts)
  • Vincent Koc: Raw commit b824b72 adds src/agents/auth-profiles/path-resolve.ts:147 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b824b72ce284; files: src/agents/auth-profiles/path-resolve.ts)

PR surface

Source +3, Tests +79, Other 0. Total +82 across 67 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 35 148 145 +3
Tests 31 149 70 +79
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 67 298 216 +82

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test growth Production +147/-144; tests/support +150/-71. Production growth is limited to the module split; test growth protects passive loading and shared ownership identity.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is an internal dependency-boundary refactor with no intended user-visible behavior change or claimed performance improvement.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 16, 2026, 1:04 PM ET / 18:04 UTC.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 66f0126c93ee72c9b8fb4814cf89e84481bdb081
  • Maintainer: @vincentkoc
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/authorization.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/path-resolve.async.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/path-resolve.native.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/path-resolve.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/paths.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/profiles.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/runtime-read.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/runtime-snapshots.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/shared-store-bootstrap-async.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/shared-store-bootstrap.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/shared-store-bootstrap.worker.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/shared-store-scope.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/source-check.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/sqlite-json.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/store-read.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/upsert-with-lock.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/usage-write.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/plugin-model-catalog-auth.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/gateway/model-auth-refresh.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/state-migrations.shared-auth-store.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/runtime.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts commands Command implementations agents Agent runtime and tooling size: L labels Nov 28, 2026
@vincentkoc
vincentkoc merged commit 7b0b2e3 into main Nov 29, 2026
171 of 174 checks passed
@vincentkoc
vincentkoc deleted the refactor/auth-store-passive-owner-20261117 branch November 29, 2026 13:51
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…hausted (#154631)

Clear a saved usage-limit block when the Codex usage response matches the account and user and reports available purchased credits. Preserve separate quota deadlines, model restrictions, and spending caps.

Co-authored-by: daniel-lxs <[email protected]>
(cherry picked from commit f12c0cf)

Follow-ups: b17f897 fix: stop switching models when a session entry changes during a turn (#208480) [not selected for this narrow backport]; f84b705 fix: preserve lower-token guidance for unaffordable requests (#201392) [not selected for this narrow backport]; 7b0b2e3 refactor(auth): keep published store lookup passive (#200185) [not selected for this narrow backport]; 7771d3e fix: let a fallback model finish after Code Mode reads [not selected for this narrow backport]; 86ca412 fix: show the saved quota reset when chat skips its only model (#207210) [not selected for this narrow backport]

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…#206285)

* test(secrets): cover metadata discovery for plugin config values

* perf(secrets): skip plugin metadata for entries without config values

(cherry picked from commit 5f0743a)

Companion audit: #200185 separates passive credential lookup; no dependency on entry-config scan or origin inventory lifecycle.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…workspaces (#207277)

A chat can require an OpenAI access program that the account offers. When that chat's session is bound to a managed worktree, turns that run in the worktree (for example, a subagent reporting back to its parent) were refused before any model request with "This … program is not advertised for the current account, model, and runtime". The same account in the same chat passed for ordinary messages. Users saw subagent results fail to come back.

Turns that run in a workspace other than the agent's main one (managed worktrees, child sessions, cron jobs with a workspace, compaction with a requested workspace) now see the same account facts as the main workspace. The access check is unchanged: a program is still allowed only when the account's current credential advertises it, and no request reaches a model without it.

The facts an account is offered (`providerOutcomes`) belong to the agent and its credential, not to a directory. They live in the prepared catalog inventory, and every inventory row is already guarded per provider: a source fingerprint (provider config including the resolved key, the providing plugins' versions and install hashes, auth profiles and order, env) plus the credential identity. But the inventory was stored per catalog owner, and owners are keyed by workspace because a workspace can add plugins. So an owner for a second workspace started empty, and in static mode (turns never rediscover) it had no account facts. Only `chat.send` avoided this, because it deliberately prepares its catalog from the main workspace.

Now a non-configured owner is offered the configured owner's inventory for the same agent, and the existing retention guards decide which rows hold for its own config and credentials. The seed is used only when the plugin set matches exactly (a workspace plugin could otherwise provide the same provider id with different code). The owner key, plugins and models stay per workspace. The seed applies at retention time, so a rejected seed does not hide the provider's generated models.

Named edges, not coded:
- If the configured owner has recorded discovery failures, a seeded worktree run owner retries that discovery until its lease ends.
- Before the configured owner's first discovery, or right after a provider config or sign-in change and before rediscovery completes, a worktree turn can still be refused. A main-workspace turn recovers on rediscovery. This is not a regression.

- New `prepared-model-runtime.workspace-inventory.test.ts`. Each case prepares the worktree turn with the dispatch's plugin generation, as report turns are prepared. The entitlement is keyed by account and credential identity:
  - `gives a worktree run with the same direct key only the account facts of its own credential` and `… with the same stored account …` see the main workspace's outcomes. Both fail on the merge base (`[]`).
  - `… with a different direct key …`, `… with a second stored account …` and `… with a signed-out credential …` inherit nothing.
  - `drops the account facts on the next worktree turn after the credential rotates`: after a sign-in change, a turn pinned to the old generation is refused ("superseded"), and the next turn sees no old-account facts.
  - The negative cases pass on the merge base by construction, since it never shares facts. With the retention credential guard disabled, the second-account, signed-out and rotation cases fail. The direct-key case is caught separately by the provider-config fingerprint, which includes the resolved key.
- Real in-process Gateway fixture (synthetic HTTP only; not committed because it clones the repository): `chat.send` and then a requester-settle completion into a parent bound to a real managed worktree. Merge base: the ordinary turn passes and the completion is refused (`OPENAI_ACCESS_PROGRAM_UNAVAILABLE`, not advertised). This branch: both pass. The worktree-bound `chat.send` turn passes on both.
- Prepared model runtime, prepared model catalog and access-program suites plus every direct importer of the changed files: 64 files, all pass, re-run after merging current main.
- `findConfiguredOwnerCandidates` moved unchanged to `prepared-model-runtime.configured-owner.ts` so the owner module stays within its line cap.
- Production (read-only): every refusal of this kind came from a session bound to a managed worktree. Each worktree was created minutes to hours before the first refusal, and none of those sessions ever had a successful report.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 3b899c3)

Follow-ups: 7b0b2e3 refactor(auth): keep published store lookup passive (#200185) [not selected for this narrow backport]

Release adaptation: Use the shared configured-owner resolver and inventory seed while preserving stable publication imports and account/provider fences.

(cherry picked from commit 740a1a4a0ce093185bdcf1b1f024d3d3dbabc16f)

Companion audit: 7b0b2e3 is broader passive auth-store refactoring, not required; focused inventory and retention gates pass on stable publication owners.

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 30, 2026
* refactor(auth): keep published store lookup passive

* test(auth): observe the active shared store owner

* fix(auth): route current consumers to the shared store owners
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts security-sensitive-changed size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant