Skip to content

fix(auth): publish synchronous SDK credential mutations - #170632

Merged
steipete merged 14 commits into
mainfrom
dbasync/authowner5-sdk
Oct 13, 2026
Merged

steipete merged 14 commits into
mainfrom
dbasync/authowner5-sdk

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Shared and agent credential authority cannot safely replace the final SQL read while released synchronous SDK writers and generic machine-state writes can change credentials outside the Gateway's publication lifecycle. This change closes those writer paths through the existing credential owner introduced in #170583. This PR builds on that owner change. The final bearer-fetch guard remains in place for the subsequent reader cutover.

Writer coverage

Writer family Entry and custody Credential publication
Released synchronous SDK save/upsert and provider-auth helpers agent-runtime.saveAuthProfileStore, provider-auth.upsertAuthProfile, and native provider helpers reach runAuthProfileWriteTransaction; supplied connections enter custody before loading or saving rows. Standalone callers acquire the existing exclusive offline lease; a live foreign Gateway refuses the write. Shared/agent JSON cell sinks enter withAuthProfileCredentialWrite synchronously before SQL.
Native AuthStorage SqliteAuthStorageBackend.withLock uses the same managed transaction and prepared save; updateAsync uses the existing auth-store worker operation. Native saves use the canonical cell publication; async saves use the existing host admission and commit receipt.
Login, import, provider setup, logout, OAuth claim/replace/fail/restore, and peer updates Profile/upsert APIs, store-update, and candidate-store updates retain their existing owner routes. store-update-kernel supplies credential facts before the host grants COMMIT; committed receipts install before denial is released.
External CLI synchronization, exact snapshot restore, secrets apply and rollback Native store save/restore paths enter the same transaction custody and canonical cell sinks. The existing credential publication sees the exact replacement or deletion; metadata-only changes remain outside credential revocation.
Model-catalog native/plugin writes The existing request work scope binds synchronous writes to its captured shared root and rejects calls after closure. The host starts its credential batch before dispatch; the worker collects committed receipts, drains admitted work, and returns facts before host release.
Generic machine-state write/update/delete/import Only normalized authProfiles.store enters credential custody/publication. Other keys retain their existing behavior. Native writes publish through the canonical owner; async machineState.write starts host denial and delivers the existing native receipt before release.
TUI and onboarding recommendation commands Workers construct fixed namespaces from scopeKey or workspaceKey, rather than accepting an arbitrary machine-state key. These commands cannot reach authProfiles.store; direct worker regressions cover the former escape routes.
Doctor and relocation/import maintenance Existing exact-path maintenance admission or exclusive offline ownership remains required. Runtime writes use the same sinks; stopped-owner relocation is the explicit maintenance exception.

The empty agent-store anchor created by inline usage remains an audited absence-to-empty mutation. It contains no credentials and cannot replace existing credential bytes. Other generic callers use fixed keys or owner-generated namespaces. The writer-entry ratchet rejects new credential sink callers and alternate generic worker dispatches without an owner audit.

Custody and settlement

This reuses Gateway ownership, offline schema leases, managed transaction settlement, and the existing credential authority. Agent open records its shared owner root once, including agents stored outside the state directory. An ordinary worker must have active operation admission for the captured physical root; an unrelated worker admission is insufficient. Already-admitted path aliases use the existing in-memory identity registry, so symlinked state directories remain supported without another filesystem or SQL lookup. Catalog writes reuse their request's existing work scope. There is no new owner, durable generation, polling read, or cross-thread handshake.

Credential changes deny synchronously before native mutation. Known COMMIT installs all committed facts before releasing denial; confirmed rollback restores the committed view. A supplied SDK connection retains its offline lease through its outer managed transaction. Unknown native outcomes discard release observers, leave credential authority denied, and retain exclusive custody until owner restart. A caught native write error cannot silently certify a later outer commit. Order, cooldown, and usage-only changes do not revoke credentials.

Supplied-connection and ordinary SDK saves can share a managed outer transaction; shared-state transactions enter through runOpenClawStateWriteTransaction, and nested supplied-connection saves continue to use the released SDK transaction helper. A later ordinary save recovers that transaction's retained custody from the existing connection cache before normal preparation and admission. This lookup reads connection identity only; it performs no SQL and adds no authority registry. Only the actual mutation connection is enrolled for settlement, so a cold ownership lookup cannot attach an unrelated database transaction to the lease.

Released SDK exports, signatures, immediate return values, and synchronous completion timing remain unchanged. Standalone SDK writes remain supported under exclusive offline custody. Writes against a live foreign Gateway must use the Gateway owner; raw unmanaged transactions remain refused because their settlement cannot publish safely. No public signature, schema, or config change is introduced.

Scope and accepted edges

No final security check is removed here. The duplicate raw-transaction check moves into the shared custody entry; arbitrary TUI/onboarding key dispatch is deleted. The existing SQL final read remains until the covered writer graph and the subsequent memory-only guard are proved together. An external request already initiated before credential denial may finish; new effects remain denied during pending or unknown changes.

Evidence

Candidate: c9bd14ae4174ffca46b31f041bf5cafebfadea3a, including landed parent #170583 (5822af67c6da) and the shared-transaction fixture correction. The squash-parent integration preserves the tested SDK changes; the five conflicted files were identical between the reviewed PR1 head and its squash commit, so their PR2 versions were retained exactly. Final-head PR CI completed with 101 successful and 25 skipped jobs. Two test jobs and the aggregate CI gate failed only for the evidenced inherited failures below. Build, production/test types, lint, ratchets, architecture, source contracts, additional/package boundaries and security checks passed. The inherited-failure landing exception is used; the aggregate gate is not described as green.

Two Codex P0/P1 review rounds are complete. The second found an uncertain-commit bug in standalone SDK custody: the outer cleanup could release its offline lease after an unknown COMMIT. The fix attaches that lease to the existing managed transaction settlement. A negative control reproduced the four shared/agent × save/upsert failures while eight confirmed-settlement controls passed. The local candidate run was stopped under the compute-conservation rule and is not claimed as a pass. No third review is requested.

The initial PR CI, at 5ec9a5e04da2f2c693929b740b17806485ee0874, passed production types, lint, source contracts, package boundaries, and 133 changed-boundary tests. It also exposed native-writer fixtures in thread pools, raw handles missing captured identity, a fixture accidentally claiming maintenance rather than Gateway ownership, an omitted writer edge, and the wrapper import inventory. These were repaired in subsequent commits; those passes are prior-head evidence.

The next PR CI, at 2b474bb5292ce760795c9d2ac5b0c69f039966a5, exposed a real SDK composition regression introduced by retaining the offline lease: supplied and ordinary saves in one outer transaction could reject their own custody. The candidate fixes connection-bound reentry as described above and extends the existing commit, rollback, and unknown-settlement regressions through the released SDK transaction export. It also gives the catalog-worker fixture the production owner's admitted work scope and drain-before-receipt ordering, updates a stale test-routing probe to a genuinely isolated fixture, and integrates main's fix for a removed test import. The final-head run completed after these repairs; its remaining failures are identified below. The next CI run caught a fixture error in the new shared-state cases: they placed an ordinary shared save inside a raw SDK outer transaction, which the shared-state owner has always rejected. The fixture now enters the existing shared-state transaction owner while preserving the nested released SDK call, ordinary save, and every commit/rollback/custody assertion; no production behavior or SDK contract changes for this correction.

The account-only Codex route QA failure is inherited. The PR failure matches an executed clean main checkout at 43584d99e8a15c9cbb1280e19be098ba9ca7e6b7: the account-only model is refused because its Codex route compatibility is not declared. That main run recorded 1 failed / 2 passed, 107.57 seconds wall time (101.61 seconds Vitest); its content-pinned receipt is retained with the campaign evidence. The main SHA predates this lane's original base, and this PR does not change the implicated route policy.

The auth-email QA failure is also inherited. The PR failure was reproduced on the actual lane base 592b7e4aea9386e05912e6df2d3ba5493e629aaa: Doctor and the selected-account turn completed, but successful status output omitted the expected synthetic email and reported OpenAI windows: [], error: "Token expired", and collection.source: "gateway". To reach the unchanged assertion under host load, the diagnostic fixture used the verified Codex version constant 0.160.0 instead of the broad version-lookup import, raised that test's limit from 180 to 900 seconds, and raised Doctor/status fixture command limits from 120 to 600 seconds. All assertions and product source stayed unchanged, including status's --timeout 60000; the temporary fixture edits were restored afterward. The test took 196.211 seconds (286.33 seconds total Vitest), exited 1, and matched the CI failure. The relevant status, usage, Codex request, and fixture files have no base-to-candidate changes.

The final-head consent-test failure is inherited: candidate job and scheduled main job, at main 4e3b11bf, both fail chat.native-runtime-consent.test.ts at line 372 with an unexpected retained session row after database replacement. The later consent/rejection assertion is not reached; this is not evidence that a consent grant was accepted. The central main-repair lane already owns the exact failure. The final-head auth-email failure also matches the base reproduction above.

Metric Base Candidate
Retained final-guard T1 sites in this lane 2 2; reader cutover is a separate PR
Warmed-path SQL / request claim No reduction claimed in this writer-custody slice No harness pair under compute conservation
Auth subsystem SQL / request delta Existing native statements and worker operations No added SQL or worker requests by source inspection; not a measured per-turn result

Regressions cover actual released SDK save/upsert, foreign-Gateway refusal, deny-before-COMMIT, publish-before-release, nested supplied/ordinary connection commit and rollback, unknown settlement, metadata-only writes, cold parity, wrong/missing worker-root facts, admitted state-directory aliases, generic machine-state mutation, and TUI/onboarding namespace confinement. Prior-head ratchet proof passed 43 synthetic cases and the actual-source snapshot; renaming a covered SDK writer entry produced one violation. Final-head CI passed its selected behavioral shards and T1/dialect/custody ratchets. Exact-head job 115147795276 explicitly passed all 49 credential-authority cases and all 10 config-machine-state-write cases, including the repaired outer-transaction SDK cases, unknown-outcome custody and async generic-worker publication. Its generic changed-boundary job passed 11 files / 133 tests in 50.40 seconds; those are not counted as credential-specific tests. Dependency/Knip and SDK evidence are detailed below. No local broad suite was run after the compute-conservation notice.

The SDK API report completed and its JSON artifact was inspected. It compares parent ed1123f89241df9212a7fc3e4dcafe5eea0e6685 against PR merge ref 61731af17d439904f9b222224a27b684ad6b7b7a, from workflow head cbb3812a9ee0c54bd833ebfdc4423f66d424d022. There are zero added/removed entrypoints or exports and zero direct signature changes. All 157 entries are reachable-type changes; the six internal declaration changes cover narrowed worker inputs, optional custody context, and the no-I/O cache lookup. The released credential save/upsert and provider-auth signatures are unchanged. This is prior-head evidence reused after the test-only correction and parent integration; it is not a new-head execution claim. Report digest: b982b8d24d12b95b4c30624f0d3edf9befdda217f73a488badcc424e40af9422.

The earlier static/API run passed its runtime topology/architecture check and reported inherited Knip findings in unchanged UI, memory and session exports. Exact source/config identities matched main; the central cleanup landed as #170660 (bda83ac9f1688ba1eb91a75afbaaaa44291c9792) and is included by the parent integration. Final-head architecture job 115147794245 explicitly ran Madge and reported zero import cycles; runtime import cycles were also zero and Kysely guardrails passed. No local broad scan was repeated.

The older qualification run also reported two agents.delete RPC timeouts. A focused main attempt exceeded the fixture startup deadline and did not reach that RPC; it is inconclusive, not inherited-failure evidence or a repair claim. The final-head CI has no such failed job; the exact file outcome remains unlocated in its compressed shards. The original diagnostics remain recorded for the central deletion owner.

Review follow-up: shorthand worker-command discriminants can evade this intermediate ratchet, although no production bypass was found. The expanded ratchet in the subsequent reader-cutover PR handles shorthand properties before the native guard is retired.

The released synchronous SDK reader still reaches the same native primitives, so static T1 may remain after the subsequent Codex guard cutover. This writer PR claims no warmed-turn reduction. No update/Doctor/schema/plugin-loading/service-lifecycle behavior is changed; the published-driver update cell is not triggered by this custody-only change.

LOC versus the integrated parent PR: 29 files, +1222/−135. Production is +436/−119 (net +317); writer-custody ratchet tooling is +47/−1, making production including the ratchet +483/−120 (net +363). Tests, test helpers, and test routing account for +693/−15; the wrapper inventory accounts for +46/−0.

@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.

@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:42:49.058017Z c9bd14a 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.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts agents Agent runtime and tooling size: XL labels Oct 13, 2026

@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: 5ec9a5e04d

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

return;
}
if (
ts.isPropertyAssignment(node) &&

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 Handle shorthand machine-state discriminants

When a direct caller uses const type = "machineState.write" as const; scope.execute({ type, input }), type is a ShorthandPropertyAssignment, so this PropertyAssignment-only check never inspects it. The semantically equivalent dispatch therefore passes the new credential-writer guard while bypassing writeConfigMachineStateAsync and its host credential-publication admission, leaving the ratchet unable to prevent an authProfiles.store mutation without host denial/publication. Include shorthand discriminants in the check.

AGENTS.md reference: AGENTS.md:L75-L75

Useful? React with 👍 / 👎.

Base automatically changed from dbasync/authowner5 to main October 13, 2026 05:23
@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: c9bd14ae4174ffca46b31f041bf5cafebfadea3a
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/credential-write-custody.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/runtime-scope.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/store.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 the commands Command implementations label Oct 13, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the commands Command implementations label Oct 13, 2026
@steipete
steipete merged commit 5041419 into main Oct 13, 2026
208 of 213 checks passed
@steipete
steipete deleted the dbasync/authowner5-sdk branch October 13, 2026 05:56
steipete added a commit that referenced this pull request Oct 13, 2026
## What Problem This Solves

The five configured-model endpoint tests fail during auth fixture setup with `Auth profile credential writes require an admitted worker`, before endpoint selection runs. Commit `50414196f1912053abee1ddcab595fca3c7e7889` (#170632) introduced credential custody and moved native credential fixtures to the existing forked database-worker lane, but missed this file.

Route `session-override.model-endpoint.test.ts` through that existing owner, preserve its former unit-fast watch classification, and extend the existing routing regression table. The helper, product credential boundary, and all five endpoint/session assertions are unchanged. No schema, SDK, update, runtime SQL, or T1 behavior changes; no checks removed.

## Evidence

Observed failure: CI run 38355813699, job 115158713394, tested merge `8068e6e8be4e24c011b20fb25d584025e347aedd` into main `95b3b97a4c38457f1c615ec34c7947d35e2a191f`; all five cases fail at `credential-write-custody.ts:72` through `openclaw-test-state.ts:354`. [Focused baseline CI 38357566269](https://github.com/openclaw/openclaw/actions/runs/38357566269/job/115163898247) reproduced all five matching custody errors on main base `95b3b97a4c38457f1c615ec34c7947d35e2a191f` in 52.94 seconds, with unchanged source verified.

Validation: changed-file formatting, changed-file oxlint, diff checks, native commit hooks, and one isolated Codex review passed with no findings. Local tests/types were intentionally deferred to hosted execution. [Focused candidate CI](https://github.com/openclaw/openclaw/actions/runs/38357566269/job/115163897957) passed all five endpoint cases under the existing infra owner (Vitest 27.71 seconds, wrapper 56.81 seconds). The changed routing regression passed in 4 ms (one passed, 16 filtered; Vitest 5.24 seconds, wrapper 7.33 seconds). The workflow verified candidate `6bc2d13d88e13c9b1309a393476e3af83a80e568` and unchanged source after execution.

LOC: two test-routing files, +3/-0; production +0/-0.
steipete added a commit that referenced this pull request Oct 13, 2026
## What Problem This Solves

Model-fallback fixtures did not follow two updated runtime contracts. After #169714 made `getRuntimeConfig` a prepared-snapshot reader, all 32 cases in [the original failing CI job](https://github.com/openclaw/openclaw/actions/runs/38353294225/job/115150698389) failed at session admission. Publish each fixture's actual configuration before admission, including the two direct embedded-runner cases, and clear it in the workspace helper's existing `finally` cleanup.

The sibling overflow-recovery fixture also seeded a credential store even though it skips auth-profile runtime and already has synthetic provider keys. Since #170632 requires credential writes from admitted workers, that unused write fails in the threaded test lane before all three cases reach their assertions. Remove only the obsolete import and setup write. Every fallback, compaction, profile-health, suspension, replay-safety, result, and execution-receipt assertion remains intact. Production code and credential security checks are unchanged.

## Evidence

- The original 32 cases pass in [PR CI](https://github.com/openclaw/openclaw/actions/runs/38358233170/job/115166408820): 48.51 seconds Vitest / 50.04 seconds wrapper. That run exposed the three overflow-recovery fixture failures described above.
- [Exact-file overflow baseline](https://github.com/openclaw/openclaw/actions/runs/38359573397/job/115170321081) on main `605065ce7461177e9b438c8d8917641a8e8380e0` reproduces all three credential-custody failures (56.82 seconds Vitest / 60.52 seconds wrapper), with unchanged sources verified. The current head also passes all three overflow cases in [PR CI 38360757838](https://github.com/openclaw/openclaw/actions/runs/38360757838/job/115174590776): 42.20 seconds Vitest / 43.77 seconds wrapper. The original 32 cases also pass on this head (59.65 seconds / 61.78 seconds).
- Changed-file oxfmt, repository-config oxlint, and `git diff --check` pass. The initial repair and overflow-only repair each received a Codex review scoped-clean through P2. The overflow review required one retry after the first attempt exited without a report.
- No local test suites, builds, or SQL harness ran. This fixture-only repair makes no warmed SQL/request or T1 claim; production LOC is zero.

Scope: three test files, +9/-3 lines. Source culprits were verified from parent-relative patches: `7e48efba10479f90496438e3edf3e0d0121e34c7` (#169714) changed the runtime-config reader, and `50414196f1912053abee1ddcab595fca3c7e7889` (#170632) added the credential-write worker guard. The overflow main-branch behavioral baseline confirms the source attribution; the independent 32-case baseline did not complete and is inconclusive; it was cancelled to conserve compute. No baseline pass or failure is claimed for that attempt.

Current-head ratchets: T1 454 → 454, compatibility calls 9 → 9, dialect groups 0 → 0. The required dependency review and aggregate CI gate passed on this head; the earlier transient status was not a dependency finding.
steipete added a commit that referenced this pull request Oct 13, 2026
…170770)

## What Problem This Solves

Scheduled main CI fails `image-generate-tool.auth.test.ts` when the retained image tool test saves real credentials. It runs in the `agents-tools` thread pool, where the credential owner correctly rejects an unadmitted writer before the test can verify refreshed availability.

Commit `90c4d9a6edebdb2b256fd2129d461227b9d1df42` (#164992) added this real-write regression. Commit `50414196f1912053abee1ddcab595fca3c7e7889` (#170632) later introduced credential custody and moved other native credential fixtures into the forked database-worker owner, but missed this file.

Add the image-auth file to that existing owner and extend the existing routing contract to require inclusion in infra and exclusion from agents-tools. All six behavioral cases, the fixture helper, and the production credential guard remain unchanged. No checks are removed; no schema, SDK, runtime SQL, T1, or update behavior changes. Two test-routing files: +4/-0; production: +0/-0.

## Evidence

The actual scheduled-main baseline is run [38359584345](https://github.com/openclaw/openclaw/actions/runs/38359584345), job [115170479640](https://github.com/openclaw/openclaw/actions/runs/38359584345/job/115170479640), head `0348a2526c561d8ccce61bfd23931024a6b8f13e`. The failure is `Auth profile credential writes require an admitted worker` at `credential-write-custody.ts:72`, through `writeAuthProfiles` to `image-generate-tool.auth.test.ts:57`. The containing agents-tools shard reports 1 failed / 1933 passed / 1 skipped tests (47.73 seconds Vitest; 49.77 seconds wrapper). This is observed main execution, not a source-parity inference.

Changed-file formatting, direct changed-file oxlint, and `git diff --check` passed. One isolated Codex review completed with no actionable findings; native commit hooks passed. No local tests or type scans ran under compute conservation. Candidate proof:

```sh
pnpm test src/agents/tools/image-generate-tool.auth.test.ts --maxWorkers=1
pnpm test test/vitest-scoped-config.test.ts --maxWorkers=1 -t "keeps infra and database worker consumers rooted at the repository"
```

The exact original file passed all six cases on candidate `30edf5f4bed3e34b3aab06d39c8a914b976ff76d` in [focused CI 38362624127/job115180185169](https://github.com/openclaw/openclaw/actions/runs/38362624127/job/115180185169): 26.08 seconds Vitest, 64.20 seconds wrapper; unchanged-source verification passed. The routing contract passed in ordinary CI 38361217277/job115176092361 (2.501-second case, 24/24 file cases). Ordinary CI omitted the original file, so the supplement ran only its six cases. No duplicate baseline was run.

Final ordinary CI: 49 successful checks, 39 skipped, no failures or pending checks. Static, type, architecture, security, and required CI gates passed. Database ratchets remained T1 454 to 454, compatibility calls 9 to 9, and all dialect groups 0 to 0. This is a test-only owner-routing correction; no SQL savings are claimed.
obviyus added a commit that referenced this pull request Oct 13, 2026
## What Problem This Solves

Fixes three approval-intent resource tests failing before inference because their credential fixture runs in an unhosted worker thread.

## User Impact

No production behavior change, migration, or operator action. Approval overlap, cancellation-drain, and credential-rotation coverage runs again with its existing assertions.

## Why This Change Was Made

Route the resource test through the existing database-worker project, alongside other native credential fixtures that require host-owned offline writer custody. The test, shared fixture, production custody checks, timeouts, and concurrency assertions are unchanged.

The stale test routing was exposed by `50414196f1912053abee1ddcab595fca3c7e7889` (#170632), which introduced `src/agents/auth-profiles/credential-write-custody.ts:71-72`. The direct fixture write at `src/test-utils/openclaw-test-state.ts:355`, called from `src/system-agent/approval-intent.resources.test.ts:120`, cannot acquire that custody in an ordinary Vitest thread. This adds the missing routing entry rather than weakening the credential boundary.

Memory background reload is intentionally not changed: #170612 already contains its maintainer-owned fixture repair.

## Evidence

On main `0348a2526c561d8ccce61bfd23931024a6b8f13e`:

- `node scripts/run-vitest.mjs src/system-agent/approval-intent.resources.test.ts src/plugins/memory-background-reload.test.ts` stopped in the first shard: all 3 approval resource cases failed with `Auth profile credential writes require an admitted worker` (23.86 s wrapper).

After the routing repair and rebasing onto main `c1f504ab456`:

- `node scripts/run-vitest.mjs src/system-agent/approval-intent.resources.test.ts src/system-agent/approval-intent.test.ts src/system-agent/verified-inference.test.ts test/vitest-scoped-config.test.ts test/vitest-cli-ownership.test.ts`: **68 passed across 5 files** (68.03 s wrapper). This includes all 3 resource cases, 31 approval/verified-inference sibling cases, and 34 routing cases.
- `pnpm exec oxfmt --check test/vitest/vitest.database-worker-core-paths.mjs`: passed.
- `node scripts/run-oxlint.mjs test/vitest/vitest.database-worker-core-paths.mjs`: passed.

No assertions, retries, or timeouts changed. No production code changed.

Co-authored-by: Ayaan Zaidi <[email protected]>
steipete added a commit that referenced this pull request Oct 13, 2026
Run the quota provider, XAI retirement, and auth state fixtures in the
existing forked database-worker project. Preserve XAI's previous unitFast
watch admission.

The credential custody change in 5041419 (#170632) missed these
consumers, which fail before their intended assertions in scheduled runs
38359584345 and 38365062007. Keep the production custody guard and all
assertions intact.
steipete added a commit that referenced this pull request Oct 13, 2026
… tests

Breaking commit 5041419 (#170632) requires admitted credential
writers. The provider fixtures still used synchronous saves from
unadmitted Vitest threads, so setup failed before exercising auth.

Pull the fixtures and worker routing forward verbatim from #169868
(head 9c6a892). Await the existing auth
writer and database cleanup, and route only these two files through
the existing database-worker project. Production code is unchanged.

Default-runner proof: OpenAI embedding 30/30, Alibaba video 7/7, and
Ollama 51/51. Targeted Oxlint, Oxfmt, and git diff --check passed.
Independent P0-P2 review found no actionable issues.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
)

Route released synchronous credential writers and generic credential-key mutations through the existing credential authority. Preserve SDK signatures and synchronous completion; deny before mutation, publish committed facts before release, and retain denial and custody after unknown outcomes.

Keep supplied and ordinary saves composable in managed transactions, and confine unrelated worker commands to their own namespaces. CI security/static checks and SDK surface evidence recorded in the PR; inherited consent-session and auth-email failures use the authorized landing exception.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…70735)

## What Problem This Solves

The five configured-model endpoint tests fail during auth fixture setup with `Auth profile credential writes require an admitted worker`, before endpoint selection runs. Commit `c3b5d0c7bc15f2f497247c3127cfa844d34c6e74` (openclaw#170632) introduced credential custody and moved native credential fixtures to the existing forked database-worker lane, but missed this file.

Route `session-override.model-endpoint.test.ts` through that existing owner, preserve its former unit-fast watch classification, and extend the existing routing regression table. The helper, product credential boundary, and all five endpoint/session assertions are unchanged. No schema, SDK, update, runtime SQL, or T1 behavior changes; no checks removed.

## Evidence

Observed failure: CI run 38355813699, job 115158713394, tested merge `8068e6e8be4e24c011b20fb25d584025e347aedd` into main `2d12e5db290affaa2538fd6c9c879924c939486e`; all five cases fail at `credential-write-custody.ts:72` through `openclaw-test-state.ts:354`. [Focused baseline CI 38357566269](https://github.com/openclaw/openclaw/actions/runs/38357566269/job/115163898247) reproduced all five matching custody errors on main base `2d12e5db290affaa2538fd6c9c879924c939486e` in 52.94 seconds, with unchanged source verified.

Validation: changed-file formatting, changed-file oxlint, diff checks, native commit hooks, and one isolated Codex review passed with no findings. Local tests/types were intentionally deferred to hosted execution. [Focused candidate CI](https://github.com/openclaw/openclaw/actions/runs/38357566269/job/115163897957) passed all five endpoint cases under the existing infra owner (Vitest 27.71 seconds, wrapper 56.81 seconds). The changed routing regression passed in 4 ms (one passed, 16 filtered; Vitest 5.24 seconds, wrapper 7.33 seconds). The workflow verified candidate `6bc2d13d88e13c9b1309a393476e3af83a80e568` and unchanged source after execution.

LOC: two test-routing files, +3/-0; production +0/-0.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
## What Problem This Solves

Model-fallback fixtures did not follow two updated runtime contracts. After openclaw#169714 made `getRuntimeConfig` a prepared-snapshot reader, all 32 cases in [the original failing CI job](https://github.com/openclaw/openclaw/actions/runs/38353294225/job/115150698389) failed at session admission. Publish each fixture's actual configuration before admission, including the two direct embedded-runner cases, and clear it in the workspace helper's existing `finally` cleanup.

The sibling overflow-recovery fixture also seeded a credential store even though it skips auth-profile runtime and already has synthetic provider keys. Since openclaw#170632 requires credential writes from admitted workers, that unused write fails in the threaded test lane before all three cases reach their assertions. Remove only the obsolete import and setup write. Every fallback, compaction, profile-health, suspension, replay-safety, result, and execution-receipt assertion remains intact. Production code and credential security checks are unchanged.

## Evidence

- The original 32 cases pass in [PR CI](https://github.com/openclaw/openclaw/actions/runs/38358233170/job/115166408820): 48.51 seconds Vitest / 50.04 seconds wrapper. That run exposed the three overflow-recovery fixture failures described above.
- [Exact-file overflow baseline](https://github.com/openclaw/openclaw/actions/runs/38359573397/job/115170321081) on main `b47aa9f98f13dedf545cd84747a19c9b3096e13c` reproduces all three credential-custody failures (56.82 seconds Vitest / 60.52 seconds wrapper), with unchanged sources verified. The current head also passes all three overflow cases in [PR CI 38360757838](https://github.com/openclaw/openclaw/actions/runs/38360757838/job/115174590776): 42.20 seconds Vitest / 43.77 seconds wrapper. The original 32 cases also pass on this head (59.65 seconds / 61.78 seconds).
- Changed-file oxfmt, repository-config oxlint, and `git diff --check` pass. The initial repair and overflow-only repair each received a Codex review scoped-clean through P2. The overflow review required one retry after the first attempt exited without a report.
- No local test suites, builds, or SQL harness ran. This fixture-only repair makes no warmed SQL/request or T1 claim; production LOC is zero.

Scope: three test files, +9/-3 lines. Source culprits were verified from parent-relative patches: `5dbf2157dc8325fff25f79abddd7a2d2bc11e798` (openclaw#169714) changed the runtime-config reader, and `c3b5d0c7bc15f2f497247c3127cfa844d34c6e74` (openclaw#170632) added the credential-write worker guard. The overflow main-branch behavioral baseline confirms the source attribution; the independent 32-case baseline did not complete and is inconclusive; it was cancelled to conserve compute. No baseline pass or failure is claimed for that attempt.

Current-head ratchets: T1 454 → 454, compatibility calls 9 → 9, dialect groups 0 → 0. The required dependency review and aggregate CI gate passed on this head; the earlier transient status was not a dependency finding.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…penclaw#170770)

## What Problem This Solves

Scheduled main CI fails `image-generate-tool.auth.test.ts` when the retained image tool test saves real credentials. It runs in the `agents-tools` thread pool, where the credential owner correctly rejects an unadmitted writer before the test can verify refreshed availability.

Commit `24fc8a49a8c1c4f106d92c833b440cec6e6d55f6` (openclaw#164992) added this real-write regression. Commit `c3b5d0c7bc15f2f497247c3127cfa844d34c6e74` (openclaw#170632) later introduced credential custody and moved other native credential fixtures into the forked database-worker owner, but missed this file.

Add the image-auth file to that existing owner and extend the existing routing contract to require inclusion in infra and exclusion from agents-tools. All six behavioral cases, the fixture helper, and the production credential guard remain unchanged. No checks are removed; no schema, SDK, runtime SQL, T1, or update behavior changes. Two test-routing files: +4/-0; production: +0/-0.

## Evidence

The actual scheduled-main baseline is run [38359584345](https://github.com/openclaw/openclaw/actions/runs/38359584345), job [115170479640](https://github.com/openclaw/openclaw/actions/runs/38359584345/job/115170479640), head `116f0502239e7f1cd4a85f57331f986f616e8939`. The failure is `Auth profile credential writes require an admitted worker` at `credential-write-custody.ts:72`, through `writeAuthProfiles` to `image-generate-tool.auth.test.ts:57`. The containing agents-tools shard reports 1 failed / 1933 passed / 1 skipped tests (47.73 seconds Vitest; 49.77 seconds wrapper). This is observed main execution, not a source-parity inference.

Changed-file formatting, direct changed-file oxlint, and `git diff --check` passed. One isolated Codex review completed with no actionable findings; native commit hooks passed. No local tests or type scans ran under compute conservation. Candidate proof:

```sh
pnpm test src/agents/tools/image-generate-tool.auth.test.ts --maxWorkers=1
pnpm test test/vitest-scoped-config.test.ts --maxWorkers=1 -t "keeps infra and database worker consumers rooted at the repository"
```

The exact original file passed all six cases on candidate `30edf5f4bed3e34b3aab06d39c8a914b976ff76d` in [focused CI 38362624127/job115180185169](https://github.com/openclaw/openclaw/actions/runs/38362624127/job/115180185169): 26.08 seconds Vitest, 64.20 seconds wrapper; unchanged-source verification passed. The routing contract passed in ordinary CI 38361217277/job115176092361 (2.501-second case, 24/24 file cases). Ordinary CI omitted the original file, so the supplement ran only its six cases. No duplicate baseline was run.

Final ordinary CI: 49 successful checks, 39 skipped, no failures or pending checks. Static, type, architecture, security, and required CI gates passed. Database ratchets remained T1 454 to 454, compatibility calls 9 to 9, and all dialect groups 0 to 0. This is a test-only owner-routing correction; no SQL savings are claimed.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
## What Problem This Solves

Fixes three approval-intent resource tests failing before inference because their credential fixture runs in an unhosted worker thread.

## User Impact

No production behavior change, migration, or operator action. Approval overlap, cancellation-drain, and credential-rotation coverage runs again with its existing assertions.

## Why This Change Was Made

Route the resource test through the existing database-worker project, alongside other native credential fixtures that require host-owned offline writer custody. The test, shared fixture, production custody checks, timeouts, and concurrency assertions are unchanged.

The stale test routing was exposed by `c3b5d0c7bc15f2f497247c3127cfa844d34c6e74` (openclaw#170632), which introduced `src/agents/auth-profiles/credential-write-custody.ts:71-72`. The direct fixture write at `src/test-utils/openclaw-test-state.ts:355`, called from `src/system-agent/approval-intent.resources.test.ts:120`, cannot acquire that custody in an ordinary Vitest thread. This adds the missing routing entry rather than weakening the credential boundary.

Memory background reload is intentionally not changed: openclaw#170612 already contains its maintainer-owned fixture repair.

## Evidence

On main `116f0502239e7f1cd4a85f57331f986f616e8939`:

- `node scripts/run-vitest.mjs src/system-agent/approval-intent.resources.test.ts src/plugins/memory-background-reload.test.ts` stopped in the first shard: all 3 approval resource cases failed with `Auth profile credential writes require an admitted worker` (23.86 s wrapper).

After the routing repair and rebasing onto main `7f29537f79a`:

- `node scripts/run-vitest.mjs src/system-agent/approval-intent.resources.test.ts src/system-agent/approval-intent.test.ts src/system-agent/verified-inference.test.ts test/vitest-scoped-config.test.ts test/vitest-cli-ownership.test.ts`: **68 passed across 5 files** (68.03 s wrapper). This includes all 3 resource cases, 31 approval/verified-inference sibling cases, and 34 routing cases.
- `pnpm exec oxfmt --check test/vitest/vitest.database-worker-core-paths.mjs`: passed.
- `node scripts/run-oxlint.mjs test/vitest/vitest.database-worker-core-paths.mjs`: passed.

No assertions, retries, or timeouts changed. No production code changed.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
Run the quota provider, XAI retirement, and auth state fixtures in the
existing forked database-worker project. Preserve XAI's previous unitFast
watch admission.

The credential custody change in c3b5d0c (openclaw#170632) missed these
consumers, which fail before their intended assertions in scheduled runs
38359584345 and 38365062007. Keep the production custody guard and all
assertions intact.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
… tests

Breaking commit c3b5d0c (openclaw#170632) requires admitted credential
writers. The provider fixtures still used synchronous saves from
unadmitted Vitest threads, so setup failed before exercising auth.

Pull the fixtures and worker routing forward verbatim from openclaw#169868
(head 9c6a892). Await the existing auth
writer and database cleanup, and route only these two files through
the existing database-worker project. Production code is unchanged.

Default-runner proof: OpenAI embedding 30/30, Alibaba video 7/7, and
Ollama 51/51. Targeted Oxlint, Oxfmt, and git diff --check passed.
Independent P0-P2 review found no actionable issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling scripts Repository scripts security-sensitive-changed size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant