Skip to content

feat(auth): publish shared and agent credential authority - #170583

Merged
steipete merged 8 commits into
mainfrom
dbasync/authowner5
Oct 13, 2026
Merged

steipete merged 8 commits into
mainfrom
dbasync/authowner5

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Shared and agent credentials still require a native final read before Codex sends a bearer-authenticated request. The existing personal credential authority cannot yet replace that read because several native and worker writers do not publish their committed facts to the Gateway.

This first slice extends that same authority to shared and agent stores and publishes non-SDK writes. It keeps the final SQL guard until the synchronous SDK custody and generic-key coverage land, followed by the reader cutover.

Design and writer coverage

Credential writes deny authority synchronously before the native effect. Managed transactions install committed postimages before releasing denial; known rollback preserves the old facts, and an unknown outcome remains denied until the owner restarts. Async updates reuse their existing commit grant and receipt transport. Catalog tasks deny the root before dispatch and return committed facts even when the catalog result fails. No new SQL, worker request, or admission handshake is introduced.

Writer family Publication route
Login, import, setup, provider persistence Existing store-update admission and native commit receipt; canonical JSON sinks stage the postimage.
OAuth claim, replace, failure, restore, peer removal; logout and compensation Same update owner; native catalog routes use the catalog settlement receipt.
Native session AuthStorage; external CLI synchronization Prepared native saves enter the canonical sink before mutation and settle with the enclosing transaction.
Secrets apply and exact-owned rollback Canonical write/delete sinks publish both the applied value and committed restoration.
Doctor, import, relocation, schema conversion Existing exclusive offline maintenance; narrowly enumerated migration sinks in the writer ratchet.
Model-catalog refresh and peer writes Host denial before dispatch; native committed-fact capture through work-scope drain and result validation.
Released synchronous SDK saves/upserts Canonical sink publication is shared; explicit custody and released-entry proof follow in slice 2, with signatures preserved.
Generic machine-state writes accepting the credential key Exact transitional sink entries remain in this slice; publication and custody follow in slice 2.

The owner uses admitted database identities. A credential write that first creates an agent database also publishes to authority captured while that path was absent. Metadata-only writes do not revoke credentials. Cold loading uses the existing worker and cannot overwrite a newer committed postimage.

CI repair also separates native JSON writes from read-only imports, preserving the existing lightweight wrapper/worker closure. Preparation may run during pending publication, but the final effect reader still denies authority until settlement.

The writer ratchet rejects new direct/raw credential-table sinks, including dynamic machine-state keys that may select the credential row. Synthetic bypass tests cover direct SQL, aliases, key changes, and extra sinks.

Checks and accepted edges

No final security check is removed in this slice. Fingerprint, selected-profile, pending-refresh, fetch, and response-disclosure guards remain unchanged. A catalog task temporarily denies credentials even when it ultimately makes no credential change; a confirmed result releases that denial. An unknown task outcome stays denied until restart. An external request already started before denial may finish; a new effect cannot start while authority is denied.

T1 and SQL

Metric Base Candidate
Codex final guard primitive sites 2 2 (cutover follows in slice 3)
Static primitive reachability Retained Retained for the released synchronous SDK reader
Warmed causal statements / requests / MAIN (single-run means) 169.1 / 41.3 / 0 172.4 / 41.7 / 0
Changed writer operation SQL / request delta — 0 by construction; existing transports carry additional facts

Static T1 may remain after the final guard cutover because the released synchronous SDK reader reaches the same primitives. That compatibility reachability is separate from the intended SQL-free Codex guard.

SQL measurement and attribution

One completed base/candidate pair uses shared harness 2.1.0: base 592b7e4aea9386e05912e6df2d3ba5493e629aaa, candidate 1d72cc6e48450f594fdb65d54ea49f40fdecf699. Both completed all 13 top-level turns, the native child, RPCs, cron, compaction, and shutdown. Warmed figures are means over ten turns per run, not repeated-run medians. The interrupted repeat has no completed candidate and is excluded. These are the measured revisions; this table does not claim a later integrated head was remeasured.

Metric Base Candidate Delta
Turn-caused all-thread statements/turn 169.1 172.4 +3.3 (+1.95%)
Turn-caused logical requests/turn 41.3 41.7 +0.4 (+0.97%)
Turn-caused MAIN statements/turn 0 0 0
Legacy warmed-window statements/turn 222.0 221.2 -0.8
Legacy warmed-window requests/turn 64.0 57.5 -6.5
Background statements/minute 522.35 537.62 +15.27
Whole-workload statements 7,002 6,961 -41
Whole-workload requests 1,414 1,296 -118
Whole-workload MAIN statements 833 828 -5
First-turn causal statements / requests 393 / 75 416 / 81 +23 / +6

The individual warmed-turn median is 170 statements / 41 requests in both runs. Individual ranges are base 162–173 / 39–44 and candidate 170–192 / 41–46; these are not repeated-run ranges. The 32-CPU host was loaded (base load 68.9→135.0, candidate 80.8→75.4). No latency claim is made. Foreground cache misses and recap work remain counted; lower whole-workload totals do not erase the warmed increase.

Shared family, direct SQL / matching logical requests per warmed turn Base Candidate
Exact-entry facts 4.2 / 4.2 4.2 / 4.2
Actor hydration 1.2 / 1.2 1.2 / 1.2
Entry-cache snapshot loads 0 / 0 0 / 0
Row facts 0 / 0 0 / 0
Watermark reads 0.8 / 0.8 1.0 / 1.0
Rewrite-generation reads 1.0 / 1.0 1.0 / 1.0
Transcript projection snapshots 1.8 / 1.8 2.1 / 2.1
Auth operations 1.3 / 1.3 1.2 / 1.2

Every listed family has zero warmed MAIN SQL. Direct SQL is identified by its native owner stack; matching requests are distinct logical request IDs carrying those statements or naming that owner. Requests may contain multiple families, so these diagnostic rows must not be summed. Entry-cache snapshots specifically mean loadSessionEntrySnapshot; an inline projection is not a whole-cache load. Generic machine-state SQL is not classified as auth from its shape alone.

The complete warmed difference is +33 statements / +4 requests across ten turns. Entry-patch preparation and effect requests contribute +16 / +4; one bounded transcript hydration contributes +12 / +1; activity-summary source contributes +6 / +1; retained exact-entry lookup contributes +1 / +1. These are offset by ordered exact-entry lookup -1 / -1, auth row lookup -1 / -1, and actor requests 0 / -1. This accounting preserves every foreground execution.

Provider traces show 16 ordinary inference calls and two compaction calls on each revision. Activity recap calls differ, 12→15, while both consume the same 26 note strings in the same order (SHA-256 d18a428e96b4290e4d8889e9b3169848c6504f86d9f40703f54d0aed98c4d52e). The base's first recap batches seven notes; the candidate begins with one-note batches. The unchanged recap owner commits activitySummary through an entry patch with a transcript predicate. Whole-workload entry-patch preparation/effect counts rise 53→56 / 71→74, matching the three extra recaps. Native predicate stacks independently identify recap-guard watermark and projection SQL rising 12→15 overall, including 8→10 in warmed causal work. Thus recap batching accounts for both extra warmed watermarks and two of the three extra warmed projections; it does not establish why scheduling differed between revisions.

The remaining warmed projection is one extra bounded transcript hydration at session-transcript-hydration.ts:412, after no usable retained context is found. Its request carries 12 statements. The trace does not record the cache-miss reason. In candidate turn 02, the two hydration requests were sent at +6,520ms and +7,639ms; the recap commit was sent later, at +13,049ms. That later recap cannot explain the preceding hydration miss. Whole-workload watermark reads rise 15→21: recap guards +3, background row-facts reads +2, and a background anchor read +1. Whole-workload projections rise 44→47: recap guards +3, bounded hydration +1, and activity-summary source fallback -1. Background reads stay included in whole-workload totals.

Whole-workload auth is 54→55 statements / 29→30 requests. The only added auth statement is the existing union-row helper, 23→24 reads: first turn +1, warmed turns -1, second session +1, other causal phases unchanged. New authority observation consumes rows already returned by that helper and adds no persistence request. Its trace ends at the generic worker boundary, so the higher-level caller and cache-miss cause of the extra read are unproved. The measured source revisions leave auth persisted-row caching, auth write-token policy, session hydration/cache modules, and writer-queue arbitration unchanged. In-memory authority processing can still affect scheduling. This pair therefore supports operation-level attribution, but does not prove strict per-operation no-growth or a warmed-turn saving.

The shared mock-provider workload does not exercise the Codex bearer-authenticated final guard. Its SQL-free security boundary must be established by the dedicated boundary test and baseline guard probe, not inferred from this whole-workload pair.

Evidence

Validation

Exact annotation-head PR CI is complete and successful: 55 jobs passed, 26 skipped, none failed or cancelled, including openclaw/ci-gate. The raw PR head is 86b94e00719d292e335761e697d441cb99172c9a; CI checked out GitHub merge 703a2998 into main 74c7b3d72589755d14ba630b85e049d671e81a48. All selected test and static jobs passed. The published-driver update job was skipped in this PR workflow and is tracked separately below.

All 22 changed test files (278 tests) passed for PR head 281f6c09c722, with all 21 selected compact/boundary changed-test jobs successful. Every supporting test job checked out GitHub merge 4238a37e (281f6c09c722 into main c6ee92366b56). 86b94e00719d changes only an existing mock-isolation comment. Its complete baseline-ratchet lane now passes, including the marker that failed previously, the T1 no-growth check, and the dialect ratchet. All selected static jobs now pass for the annotation head, including production types, all core/extension lint, architecture, and every test-type stripe. The current core-4 log records GitHub merge 703a2998 (86b94e00719d into main 74c7b3d72589) and every TypeScript leaf exits zero.

Passed static checks at 281f6c09c722: production types; core and extension lint; source contracts; extension/package boundaries; all test-type stripes except the inherited core-4 error below; Madge (zero cycles); Kysely guardrails; T1 no growth; and dialect mechanical 0→0, design 0→0, engine maintenance 2→2. The comment-only head preserves the tested production code.

The credential authority suite covers deny-before-commit and publish-before-observer for shared and agent stores, cold parity, metadata-only writes, deletion/restoration, and unknown outcomes staying denied. Catalog tests cover committed credentials on failed tasks, publication before error release, mismatched worker results, and unknown outcomes. Publication tests cover nested rollback, cross-domain commit publication, stale receipts, and publisher failures. The writer custody guard’s 41 tests passed, including synthetic bypass cases. Every changed test/mock file has completed proof; none is waiting on the long E2E job.

Every changed test file, result, and CI timing

“Test sum” totals printed individual test durations. “Shard wall” is the enclosing Vitest shard, which may contain other files; neither column claims a dedicated per-file run wall time.

File Passed Test sum (s) Shard wall (s) Evidence
src/agents/auth-profiles.sqlite-read-pool.test.ts 10 3.160 48.430 job
src/agents/auth-profiles/credential-authority.test.ts 17 1.571 54.940 job
src/agents/auth-profiles/external-auth.test.ts 8 0.486 20.620 job
src/agents/auth-profiles/oauth-manager.test.ts 18 14.532 44.930 job
src/agents/auth-profiles/oauth.peer-settlement.test.ts 10 10.905 75.380 job
src/agents/auth-profiles/shared-store-bootstrap.async.test.ts 11 4.287 75.380 job
src/agents/auth-profiles/source-check.async.test.ts 6 3.031 44.930 job
src/agents/auth-profiles/store-update.test.ts 20 7.978 44.930 job
src/agents/auth-profiles/store.async-read.test.ts 14 0.147 20.620 job
src/agents/auth-profiles/upsert-with-lock.sqlite.test.ts 21 10.120 43.750 job
src/agents/embedded-agent-runner/model.auth-read-race.test.ts 2 0.169 47.910 job
src/agents/embedded-agent-runner/run/auth-profile-shared-usage.worker.test.ts 9 5.411 56.270 job
src/agents/plugin-model-catalog-auth.test.ts 2 1.711 15.070 job
src/agents/prepared-model-catalog-worker.authority.test.ts 4 2.012 10.660 job
src/agents/prepared-model-catalog-worker.directory.test.ts 4 23.063 42.230 job
src/agents/prepared-model-catalog-worker.oauth-peers.integration.test.ts 3 10.027 94.340 job
src/agents/prepared-model-catalog-worker.secrets.test.ts 7 30.768 65.740 job
src/commands/doctor-auth-flat-profiles.test.ts 37 24.775 38.680 job
src/infra/state-migrations.shared-auth-store.lifecycle.test.ts 2 1.917 58.920 job
src/secrets/apply.test.ts 26 7.515 35.690 job
src/state/state-domain-publication.test.ts 6 0.086 3.340 job
test/scripts/personal-credential-writer-guard.test.ts 41 0.295 0.997 job

The annotation-head long E2E job also completed successfully: 19 tests across six suites, with a total job wall time of 691 seconds. Suite wall times were Doctor auth-profile consumers 156.63s (3 tests), inference authority 10.21s (1), native approval receipt 49.86s (1), quota reset 223.24s (9), isolated quota reset 35.78s (2), and OAuth refresh authority chain 66.32s (3). These are suite durations, not individual-test sums.

Two inherited-from-base static findings were observed at 281f6c09c722:

Check Exact finding and source evidence
Core-4 test types config-preflight-snapshot.test.ts:41 imports unexported readConfigPreflightSnapshot (TS2724). Implementation and test have identical Git blobs on integrated main 17929e42d182d and the candidate.
Knip, full dispatch Sole unused-export finding: ui/src/components/board/board-widget-cell-render.ts: renderBoardWidgetError. The UI tree and Knip configurations are identical to integrated main 17929e42d182d; that symbol has only its declaration. Production/full-tree unused-file scans and the script export scan passed with zero entries.

These are source-identical findings, not matching-main-CI execution claims, and neither failing check is represented as green. Current main 633acc213dae4 has since repaired both: the test no longer references the private function, and the unused Board file/symbol is gone. Annotation-head PR CI already incorporates a newer main merge and passes core-4. The full dispatch’s pinned 281f6c09c722 Knip failure remains historical evidence; Knip was not selected by the annotation-head PR workflow, so no green Knip result is claimed.

The published-driver × candidate update cell passed on production head 281f6c09c722a42094db6951b125078faf7bf589, including the real update to the candidate package. The later annotation head changes only a comment. Current-main integration is complete at ed1123f89241df9212a7fc3e4dcafe5eea0e6685, with parent main e65c0bd16568f168257e2000276aa1b5f07e44c8, and had no conflicts. It includes both static fixes. The earlier candidate Knip scan is reused under the inherited-static exception: its only finding was the identical main-owned UI export, now deleted by main; the intervening lane change is a test annotation. This is not a claim of a fresh-head green Knip run. Per compute conservation, no duplicate local scan or broad dispatch is run for that repaired inherited finding. Integration-head PR CI completed successfully at ed1123f89241df9212a7fc3e4dcafe5eea0e6685: 55 jobs passed, 26 skipped, none failed or cancelled, including the final selected E2E job, all selected static/type/lint/ratchet lanes, and openclaw/ci-gate. Security-sensitive review, dependency review, and Opengrep also passed on this head.

Independent Codex review: two P0/P1 rounds, both scoped clean; the second covers the CI repairs. One SQL harness pair is recorded above. An extra baseline was interrupted under the compute-conservation rule; no second comparison is claimed. No latency claim is made on the loaded host.

LOC against integrated main: 43 files, production/ratchet +920/−343; tests and test helpers +1264/−12. No schema or public SDK signature changes.

@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T05:14:18.053768Z ed1123f 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.

@github-actions

github-actions Bot commented Oct 13, 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: ed1123f89241df9212a7fc3e4dcafe5eea0e6685
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/inline-usage-kernel.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/persisted-store.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/persisted.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/sqlite-json-write.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/sqlite-read.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/sqlite.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/state-normalization.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/state.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/store-update-kernel.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/store-update.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/usage-kernel.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 scripts Repository scripts commands Command implementations agents Agent runtime and tooling size: XL labels Oct 13, 2026
@clawsweeper

clawsweeper Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR publishes shared and agent credential writes to the existing retained authority owner while preserving the final SQL credential guard.

Example: A session pins login-discovery-fixture:owner while its provider catalog refresh is awaiting a response.

  • Before: The model picker returns the previously published account models.
  • After: The added authority capture can reject the passive models.list request with an authority-unavailable error.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The approved architecture is useful, but confirmed runtime, extraction, and test failures prevent readiness.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Shared and agent credential use still requires a synchronous final database read because their writers do not publish authoritative committed facts.
Reason: The maintainer-approved first slice establishes writer coverage while keeping the security guard; subsequent custody and reader cutover are explicitly separate work.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 12 items remain

This maintainer-directed first slice has clear value, but a catalog-read regression, broken wrapper dependencies, and confirmed test defects block merge.

Priority: P2
Reviewed head: 2662c341549503ce71a6d967e309b3cf1a75de0a

Before merge

  • Add real behavior proof - Authority-chain proof required: the shared/agent writer owner now publishes retained credential facts across native and worker settlement, but supplied evidence stops at tests and a queued live comparison; show allowed use and rejection of a revoked or reassigned prepared credential before final upstream HTTP. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Keep pending catalog denial out of passive profile reads (P2) - While a catalog refresh is awaiting its provider response, beginAuthProfileCredentialBatch marks the root pending. This eager capture calls assertCurrent and rejects ordinary selected-profile reads, even when the caller only projects already published model rows. Exact-head CI reproduces the authority-unavailable error in both models-auth-login.catalog.integration.test.ts configurations. Preserve passive selected-account listing while retaining denial at credential effect boundaries; this slice still has the final SQL guard.
  • Preserve the PR wrapper's runtime import closure (P1) - This import makes the extracted sqlite-readonly-location worker require user-model-account-authority and its transitive dependencies, but wrapper-components.txt does not include them. CI confirms an unresolved import and missing closure, so the trusted wrapper extraction cannot execute the affected worker. Update the maintained closure or keep the dependency behind a narrower owner surface.
  • Subscribe to pending facts in the Doctor regression (P2) - subscribe receives committed observer notifications; begin dispatches pending only through subscribeFacts. Consequently this callback never appends to pendingDenied, and the added greater-than-zero assertion always fails. CI confirms the exact failure at line 1151. Use the fact subscription for this pre-commit assertion.
  • Retain the explicit agent owner in the secrets fixture (P2) - The rollback test already opens custom-first-agent under agent ID first. This helper reopens it through directory-derived ownership, requesting custom-4860f669bd67 and throwing before secrets apply runs. CI confirms that owner mismatch. Capture authority from the existing fixture database and explicit owner instead of reopening under a derived ID.
  • Compare OAuth restoration against canonical persisted fields (P2) - The fixture's original credential includes accountId, authFlow, and email properties whose values are undefined. Canonical persistence omits those properties, so toMatchObject(original) rejects the correctly restored credential. CI confirms this mismatch. Compare with the canonical cold read or independently specified persisted fields without weakening the restoration assertion.
  • Update the closed reclamation mock for the new import (P2) - Importing the authority module through sqlite-json now evaluates registerOpenClawStateDatabaseLifecycleListener. session-accessor.sqlite-mutation-worker.runtime.test.ts mocks openclaw-state-db-cache with an empty object, so collection fails before its settlement test runs. CI confirms the missing export at authority-module initialization. Adapt that bounded mock or remove the unnecessary eager dependency.
  • Move added coverage out of over-cap test files (P2) - The new coverage grows apply.test.ts from 1080 to 1110 counted lines and doctor-auth-flat-profiles.test.ts from 1851 to 1891. Exact-head CI rejects both increases under the existing line-cap ratchet. Move coherent authority coverage to sibling test files while preserving the tested production compositions and assertions.
  • Resolve security review attention item - No concrete authorization bypass was found, but retained shared and agent authority needs final-effect revocation and reassignment proof.
  • Resolve merge risk - Before merge, establish that transferred shared and agent credential facts preserve rejection at the final upstream effect after account replacement or revocation.
  • Complete next step - Obtain diagnostics and attribute the remaining production-type, extension-package-boundary, and built-Gateway recovery failures; their available annotations do not establish a repair.
  • Improve patch quality - Add final-effect proof for a prepared shared or agent credential revoked or reassigned before upstream I/O.

Findings

  • [P2] Keep pending catalog denial out of passive profile reads — src/agents/auth-profiles/runtime-read.ts:269-278
  • [P1] Preserve the PR wrapper's runtime import closure — src/agents/auth-profiles/sqlite-json.ts:16
  • [P2] Subscribe to pending facts in the Doctor regression — src/commands/doctor-auth-flat-profiles.test.ts:1131-1132

Tests

  • Missing end-to-end proof: Supply a production-boundary trace covering allowed use and rejection after shared/agent revocation or reassignment before upstream I/O, with credentials and private endpoints redacted.
Agent review details

How this fits together

Credential writers commit shared or agent SQLite rows and publish receipts to Gateway-held authority; canonical reads seed that authority, while Codex inference retains its existing final credential check before upstream HTTP.

flowchart LR
  W[Credential writers] --> D[Shared and agent SQLite]
  D --> P[Commit receipts]
  P --> A[Retained credential authority]
  R[Canonical credential reads] --> A
  R --> G[Existing final SQL guard]
  G --> U[Upstream HTTP]
Loading

Technical review

Best possible solution:

Keep publication in the existing credential owner, preserve passive catalog reads and final-effect guards, and repair the introduced dependency and test failures.

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

Current-main source confirms the retained shared/agent SQL guard, and exact-head CI independently reproduces the introduced catalog, wrapper, and test failures; no target code was executed during this review.

Is this the best way to solve the issue?

Reusing the existing publication owner and preserving the guard is a sound staged approach, but authority seeding must not turn passive canonical reads into denied external effects.

Full review comments:

  • [P2] Keep pending catalog denial out of passive profile reads — src/agents/auth-profiles/runtime-read.ts:269-278
    While a catalog refresh is awaiting its provider response, beginAuthProfileCredentialBatch marks the root pending. This eager capture calls assertCurrent and rejects ordinary selected-profile reads, even when the caller only projects already published model rows. Exact-head CI reproduces the authority-unavailable error in both models-auth-login.catalog.integration.test.ts configurations. Preserve passive selected-account listing while retaining denial at credential effect boundaries; this slice still has the final SQL guard.
    Confidence: 0.96
  • [P1] Preserve the PR wrapper's runtime import closure — src/agents/auth-profiles/sqlite-json.ts:16
    This import makes the extracted sqlite-readonly-location worker require user-model-account-authority and its transitive dependencies, but wrapper-components.txt does not include them. CI confirms an unresolved import and missing closure, so the trusted wrapper extraction cannot execute the affected worker. Update the maintained closure or keep the dependency behind a narrower owner surface.
    Confidence: 1
  • [P2] Subscribe to pending facts in the Doctor regression — src/commands/doctor-auth-flat-profiles.test.ts:1131-1132
    subscribe receives committed observer notifications; begin dispatches pending only through subscribeFacts. Consequently this callback never appends to pendingDenied, and the added greater-than-zero assertion always fails. CI confirms the exact failure at line 1151. Use the fact subscription for this pre-commit assertion.
    Confidence: 1
  • [P2] Retain the explicit agent owner in the secrets fixture — src/secrets/apply.test.ts:72-74
    The rollback test already opens custom-first-agent under agent ID first. This helper reopens it through directory-derived ownership, requesting custom-4860f669bd67 and throwing before secrets apply runs. CI confirms that owner mismatch. Capture authority from the existing fixture database and explicit owner instead of reopening under a derived ID.
    Confidence: 1
  • [P2] Compare OAuth restoration against canonical persisted fields — src/agents/auth-profiles/oauth.peer-settlement.test.ts:391
    The fixture's original credential includes accountId, authFlow, and email properties whose values are undefined. Canonical persistence omits those properties, so toMatchObject(original) rejects the correctly restored credential. CI confirms this mismatch. Compare with the canonical cold read or independently specified persisted fields without weakening the restoration assertion.
    Confidence: 1
  • [P2] Update the closed reclamation mock for the new import — src/agents/auth-profiles/sqlite-json.ts:16
    Importing the authority module through sqlite-json now evaluates registerOpenClawStateDatabaseLifecycleListener. session-accessor.sqlite-mutation-worker.runtime.test.ts mocks openclaw-state-db-cache with an empty object, so collection fails before its settlement test runs. CI confirms the missing export at authority-module initialization. Adapt that bounded mock or remove the unnecessary eager dependency.
    Confidence: 1
  • [P2] Move added coverage out of over-cap test files — src/secrets/apply.test.ts:72-85
    The new coverage grows apply.test.ts from 1080 to 1110 counted lines and doctor-auth-flat-profiles.test.ts from 1851 to 1891. Exact-head CI rejects both increases under the existing line-cap ratchet. Move coherent authority coverage to sibling test files while preserving the tested production compositions and assertions.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Prove authority at final use (recommended)
    Provide an allowed request and a prepared request whose shared or agent credential is revoked or reassigned before upstream I/O, exercising the actual publication owners and final guard.
  2. Hold the first slice
    Keep this PR open until the authority evidence and introduced regressions are resolved.

Provenance checked

  • Retained credential authority keeps the original intent (4b7cf59: Retain personal credential authority before final fetch while denying pending or uncertain mutations.)
  • Async auth updates keeps the original intent (381b1e0: Move locked current-row merge and commit into workers and publish committed snapshots through existing transports.)
  • Persisted credential normalization keeps the original intent (9b0a90e: Doctor owns legacy conversion while canonical credentials and rotation state retain their meaning.)
  • Providerless SecretRef refusal keeps the original intent (2c0278b: Normalize released legacy inputs through Doctor rather than adding runtime compatibility readers.)
  • Catalog generation failure settlement keeps the original intent (d0df645: Discard registration-affected predecessor contexts after failed native ESM refresh.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete authorization bypass was found, but retained shared and agent authority needs final-effect revocation and reassignment proof.

Evidence

What I checked:

  • Pinned scope and approved staging: The full PR body describes a writer-publication slice, explicitly retains the final SQL guard, and defers SDK custody and reader cutover. The security-sensitive comment verifies the author's repository admin role. (2662c3415495)
  • Passive catalog-read regression: The new selected-profile capture checks root denial during ordinary reads. Exact-head CI reports the resulting authority-unavailable error in both configurations of models-auth-login.catalog.integration.test.ts, whose held-refresh scenario requires passive selected-account listing to remain available. (src/agents/auth-profiles/runtime-read.ts:272, 2662c3415495)
  • Doctor assertion confirmed by CI: The added test subscribes to post-commit observers but expects a pending fact; begin() dispatches pending only to fact subscribers. CI confirms expected 0 to be greater than 0 at the new assertion. (src/commands/doctor-auth-flat-profiles.test.ts:1131, 2662c3415495)
  • Wrapper dependency closure broken: The sqlite-json import adds authority and protocol dependencies absent from the trusted wrapper inventory. CI confirms an unresolved authority import in the extracted tree and lists the missing closure. (src/agents/auth-profiles/sqlite-json.ts:16, 2662c3415495)
  • Secrets fixture owner mismatch: The new helper reopens an explicitly owned custom agent path through directory-derived ownership. CI confirms that the existing owner first conflicts with requested owner custom-4860f669bd67 before the rollback scenario runs. (src/secrets/apply.test.ts:73, 2662c3415495)
  • Additional introduced test failures: CI confirms a missing lifecycle-listener export in the session reclamation test's closed mock and an OAuth assertion expecting undefined optional fields that canonical persistence omits. (src/agents/auth-profiles/oauth.peer-settlement.test.ts:391, 2662c3415495)

Likely related people:

  • Peter Steinberger: Raw commit 4b7cf59 adds src/state/user-model-account-authority.ts:22 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4b7cf5946b8e; files: src/state/user-model-account-authority.ts)
  • joshavant: Raw commit 1cb9f70 adds src/agents/prepared-model-catalog-worker.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 1cb9f70cb304; files: src/agents/prepared-model-catalog-worker.ts)
  • Ayaan Zaidi: Raw commit cbaa9ab adds src/agents/prepared-model-catalog-worker.ts:13 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: cbaa9abada32; files: src/agents/prepared-model-catalog-worker.ts)

PR surface

Source +468, Tests +1237, Other +103. Total +1808 across 33 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 14 730 262 +468
Tests 18 1244 7 +1237
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 111 8 +103
Total 33 2085 277 +1808

Review metrics

Metric Value Why it matters
Production versus test growth Production +841/-270; tests and support +1244/-7 The production growth adds publication lifecycle and writer coverage; the parser extractions preserve existing semantics, and this slice claims no final-guard SQL reduction.

Labels

Label changes:

  • add P2: This is a useful internal authority improvement with a bounded catalog-read regression and actionable validation defects.
  • add merge-risk: 🚨 auth-provider: Selected-account model listing can fail while an unrelated catalog task holds root credential denial.
  • add merge-risk: 🚨 security-boundary: Credential authority now crosses worker receipt transport and remains retained; final-effect revocation and reassignment evidence is still required.
  • add merge-risk: 🚨 automation: The new runtime import breaks the trusted PR wrapper's extracted dependency closure.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: This is a useful internal authority improvement with a bounded catalog-read regression and actionable validation defects.
  • merge-risk: 🚨 auth-provider: Selected-account model listing can fail while an unrelated catalog task holds root credential denial.
  • merge-risk: 🚨 automation: The new runtime import breaks the trusted PR wrapper's extracted dependency closure.
  • merge-risk: 🚨 security-boundary: Credential authority now crosses worker receipt transport and remains retained; final-effect revocation and reassignment evidence is still required.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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 October 12, 2026, 11:39 PM ET / October 13, 2026, 03:39 UTC.

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

Copy link
Copy Markdown
Contributor

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: db7a4f62ee

ℹ️ 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 on lines +477 to +478
const writes = node.text.matchAll(
/\b(?:insert\s+(?:or\s+\w+\s+)?into|update|delete\s+from)\s+["`[]?(secret_store_entries|auth_profile_store|config_machine_state|github_(?:(?:personal_|repository_)?publication_requests|publication_session_lifecycles))\b/gi,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Recognize SQLite REPLACE statements in the writer guard

Extend this raw-SQL pattern to cover SQLite's REPLACE INTO and UPDATE OR <action> forms. For example, db.exec("REPLACE INTO auth_profile_store ...") currently produces no violation, allowing a new credential writer to bypass the canonical publication sink and leave retained credential authority stale after the write; the repository's own SQL mutation parser already treats these forms as writes.

AGENTS.md reference: AGENTS.md:L67-L70

Useful? React with 👍 / 👎.

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

Copy link
Copy Markdown
Contributor

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: 281f6c09c7

ℹ️ 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 on lines +459 to +462
const guarded = tables.filter(
(name) =>
guardedTables.has(name) &&
(name !== "config_machine_state" || mayWriteAuthMachineState(node, checker)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Guard Kysely replaceInto credential writes

Extend the Kysely sink detection to recognize replaceInto. A future db.replaceInto("auth_profile_store") or auth-key config_machine_state write never reaches this new guarded-table filter because the earlier call-name check only accepts insertInto, updateTable, and deleteFrom; the writer therefore passes the ratchet while bypassing the canonical credential-publication sink and can leave retained credential authority stale.

AGENTS.md reference: AGENTS.md:L70-L71

Useful? React with 👍 / 👎.

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

Copy link
Copy Markdown
Contributor

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: ed1123f892

ℹ️ 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 on lines +265 to +268
while (ts.isPropertyAccessExpression(query.parent) && ts.isCallExpression(query.parent.parent)) {
const call = query.parent.parent;
const method = query.parent.name.text;
if (method === "values" || method === "set") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Inspect conflict updates for credential-key writes

When a Kysely upsert inserts a non-auth key but its conflict handler calls doUpdateSet({ state_key: "authProfiles.store", value_json: ... }), this ancestor-only scan marks selected false from values() and never visits the nested conflict callback, so the new writer passes the ratchet despite modifying the credential row without publishing authority facts. Inspect onConflict/doUpdateSet assignments before excluding this sink.

AGENTS.md reference: AGENTS.md:L70-L71

Useful? React with 👍 / 👎.

@steipete

Copy link
Copy Markdown
Contributor Author

Reviewed the three writer-ratchet suggestions. They concern syntax a future writer could introduce: raw SQLite REPLACE INTO / UPDATE OR, Kysely replaceInto, and credential-key reassignment in an onConflict().doUpdateSet() callback. No existing credential mutation using those bypasses was identified. These are follow-ups for the source guard, not a currently uncovered production writer; the final native credential check remains in this preparatory PR. Recording them under the two-round review limit and relaxed landing policy rather than adding another review cycle here.

@steipete
steipete merged commit 5822af6 into main Oct 13, 2026
143 of 147 checks passed
@steipete
steipete deleted the dbasync/authowner5 branch October 13, 2026 05:23
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…70583)

Extend the existing credential authority to shared and agent stores. Deny credential writes before commit and publish committed facts before release across native saves, worker updates, catalog tasks, secrets rollback, and offline maintenance. Preserve the final SQL guard while SDK custody and the reader cutover land separately.

Unknown write outcomes remain denied until owner restart; metadata-only changes do not revoke credentials. Boundary tests, two Codex review rounds, PR CI, and the published-driver update cell cover the change.
steipete added a commit that referenced this pull request Oct 14, 2026
…pins (#172374)

Reuse writer-published credential authority for personal OAuth acceptance and remove duplicate account reads, repeated validation, and the personal-accept worker transaction. Prepare provider metadata asynchronously at six native session model-selection callers. Keep live credential checks at physical I/O and retain released synchronous SDK compatibility.

Regression coverage verifies fresh credentials and model pins after in-process writes. No schema, configuration, or public SDK changes.

Release-note context: personal-account authentication avoids redundant database work and session model selection avoids synchronous fallback reads. Follow-up to #171726, #170583, and #170656.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 15, 2026
…pins (openclaw#172374)

Reuse writer-published credential authority for personal OAuth acceptance and remove duplicate account reads, repeated validation, and the personal-accept worker transaction. Prepare provider metadata asynchronously at six native session model-selection callers. Keep live credential checks at physical I/O and retain released synchronous SDK compatibility.

Regression coverage verifies fresh credentials and model pins after in-process writes. No schema, configuration, or public SDK changes.

Release-note context: personal-account authentication avoids redundant database work and session model selection avoids synchronous fallback reads. Follow-up to openclaw#171726, openclaw#170583, and openclaw#170656.
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 scripts Repository scripts security-sensitive-changed size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant