Skip to content

fix(auth): create a fresh install with canonical shared-auth ownership - #126783

Merged
steipete merged 5 commits into
mainfrom
steipete/fresh-install-shared-auth-owner
Aug 20, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/fresh-install-shared-auth-owner

Conversation

@steipete

@steipete steipete commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A brand-new OpenClaw install is created in the retired shared-auth-store shape, so the operator's very
first openclaw doctor asks them to migrate state that OpenClaw itself created seconds earlier.

Onboard a fresh isolated state dir with the documented non-interactive flow, then run doctor:

Shared auth store
  Shared auth profiles still live in the main agent database. Run `openclaw doctor --fix` to move
  them into shared SQLite state and make the main agent deletable.

Nothing is legacy about this install. Verified on that same state dir:

  • agents/main/agent/openclaw-agent.sqlite -> auth_profile_store holds the primary row;
  • state/openclaw.sqlite -> auth_profile_stores has 0 rows;
  • config_machine_state has no auth.sharedStore row.

doctor --fix then relocates cleanly and prints "The main agent no longer owns shared credentials and
can now be deleted." — a migration with nothing to preserve, on an install minutes old. Until the
operator runs it, the main agent is also not deletable.

Why This Change Was Made

parseSharedAuthStoreOwnership(undefined) in src/agents/auth-profiles/path-resolve.ts returns
{ location: "legacy-main" }. That is the correct compat answer for an existing install: no
ownership row means the profiles really do live in the main agent database, and reading them from
anywhere else would lose them. But a new install also has no row, and no legacy data either, so it is
classified legacy and writes its first credential into the retired location.

6405a59c45a already silenced the empty case in noteSharedAuthStoreStatus. It did not stop new
installs from being created in the legacy shape, so as soon as a real credential exists the nag is
truthful again. This is a producer defect: state is created in the retired shape and repaired
downstream, which Repair Doctrine says to fix at the lifecycle owner.

The fix records auth.sharedStore = {"location":"state-db"} when the shared store is first written
and the legacy source provably holds nothing: no auth_profile_store row, no auth_profile_state
row, and no unfinished cleanup ledger entry. Any legacy row present, or any inspection error, leaves
ownership untouched so doctor keeps owning the relocation. Nothing infers past unreadable or partially
migrated state.

Three deliberate design points:

The check is memoized, not repeated. A naive version re-opens the legacy SQLite on every credential
write for any install that stays legacy — repeated request-time discovery that the root AGENTS.md
forbids on runtime paths. A WeakSet keyed on the process-stable ownership object inspects a legacy
root once per process, and doctor's noteCommittedSharedAuthStoreOwnership replaces that object, so
the flip invalidates the memo without any manual bookkeeping.

Legacy inspection moved to the auth-profiles owner. The bootstrap needs the same row and cleanup
checks the doctor migration uses. Importing them from state-migrations.shared-auth-store.ts would
make runtime depend on migration code, which the architecture rules prohibit, and duplicating them
would create two definitions of "is there anything legacy here". They now live in
shared-store-bootstrap.ts and both consumers share one contract.

Explicit main-agent writes follow the shared target. A main-agent credential is a shared
credential. On legacy roots this is a no-op because both routes already resolve to the same file; on a
fresh root it is what makes the ownership record meaningful. saveAuthProfileStoreInTransaction drops
the agent scope for shared-state rows so shared credentials are never published or cached as
agent-local state. Both invariants are commented at their call sites.

No SQLite schema change — the ownership row is data in an existing table.

User Impact

A new operator's first openclaw doctor no longer opens with a migration request for state that was
just created, and the main agent is deletable from the start. Existing installs are untouched: they
still resolve legacy-main, still see the nag, and doctor --fix still relocates them exactly as
before.

Evidence

Three scenarios, live on a built CLI, verified independently of the change author and re-verified
after the rebase.

Fresh install:

onboard exit=0, stderr empty
agent db: ABSENT
shared rows: shared
ownership: {"location":"state-db"}
doctor "Shared auth store" sections: 0

An install created by a pre-fix binary, then read by this build — untouched:

legacy created: agent rows=primary  ownership=''
new-binary doctor nag count: 1
ownership still: ''   agent rows still: primary

doctor --fix on that legacy install still relocates, and the credential survives:

- Relocated shared auth profiles into shared SQLite state.
- The main agent no longer owns shared credentials and can now be deleted.
after: agent rows=''  shared='shared'  ownership='{"location":"state-db"}'
credential intact: openai:api-key api_key openai keylen 16

Tests. src/agents/auth-profiles — 28 files, 399 tests, passing. Shared-auth migration — 9 tests,
passing. auth-profiles.sqlite-store — 22 tests, passing. The new memo regression spies on
fs.lstatSync, proves two consecutive credential writes cause exactly one legacy inspection, then
runs doctor's migration and proves the ownership flip is observed afterwards. Unreadable and
partially-migrated legacy sources are covered and must not flip.

node scripts/check-changed.mjs clean, including the schema-version and database-first guards.
pnpm build passes. Autoreview clean. The config/assertion-safety-baseline.txt edit is shrink-only
(2 -> 1) because an assertion moved out of that file; no baseline is grown.

Production +267/-153 (net +114), tests +217/-18. The production growth buys a fail-closed
initialization owner, one shared legacy-inspection contract replacing a duplicated one, the memo, and
the write-routing hook; the relocation itself is roughly a wash (+185 in the new module against
-104 removed from the migration module).


Two defects hosted CI caught after the first draft

Both were real, both were fixed here, and both are worth reading before reviewing the diff — they say
where this change's risk actually lives.

1. JSON-era credentials were stranded. The first draft decided a root was "fresh" from the legacy
SQLite rows and the cleanup ledger alone. It ignored the retired file sources that predate the
SQLite store — auth-profiles.json, auth-state.json, auth.json, oauth.json — which
listLegacyAuthProfileSources already enumerates. On an install upgrading from the JSON era the
bootstrap saw no rows, declared the root fresh, recorded state-db, and doctor's later JSON import
failed with unable to open database file / auth profile migration target verification failed.
That is the exact outcome this change exists to prevent. Fixed by consulting the canonical
legacy-source enumeration, memoized like the SQLite probe, fail-closed on any probe error. Verified on
a hand-built JSON-era fixture: read-only doctor leaves ownership absent and the JSON in place, and
doctor --fix imports the credential into the shared store intact. A regression test locks it down by
performing two shared writes on a JSON-era root, asserting the JSON file is probed exactly once, then
proving both the JSON-era credential and the ones written in between survive the import.

2. The explicit-main redirect changed where a relocated agent's credentials persist. Four
onboard-auth tests failed with Expected SQLite auth profile store for <state>/agents/kid/agent.
resolveSharedMainAuthAgentDir honors OPENCLAW_AGENT_DIR, so a process pointed at an agent makes
that agent the shared main dir, and its explicit credential writes route to the shared store.

That one was resolved by evidence rather than by adjusting assertions. Setting
allowExplicitMain: false makes onboard-auth pass 13/13 but breaks three of this PR's own
fresh-install and memo tests, so the requirements genuinely conflict and the contract had to be
decided rather than patched. A probe answered it: after an explicit write, the credential resolves
normally for that agent through ensureAuthProfileStore / resolveApiKeyForProvider
(source: "profile:openai:default"), a sibling agent inherits it through the main store as it always
has, and the sibling's own persisted map stays {}. Only the persistence location moved. The four
tests were coupled to storage layout, so they now read through the ownership-aware path — and the
direct-persistence assertion proving sibling isolation is kept verbatim, plus a new explicit assertion
that the sibling really does resolve the inherited credential. Production delta for that round was
+0/-0.

Updated accounting

Production +371/-230 (net +141), tests +355/-34, baseline +1/-1 shrink-only.

The relocation is the large part and deserves the reviewer's attention: +185 for
shared-store-bootstrap.ts and +80 for legacy-source-files.ts against -104 removed from
state-migrations.shared-auth-store.ts and -87 from legacy-source-diagnostic.ts. Both moves are
forced rather than cosmetic — runtime must not import migration code, and the filename enumeration had
to become dependency-free to break an import cycle — but roughly 70 lines of that is expansion beyond
what was removed, and it is fair to push back on it.

Validation after both fixes

onboard-auth 13/13, auth-profiles.sqlite-store 23/23, doctor-auth-flat-profiles 53/53,
src/agents/auth-profiles 399/399, eight doctor-auth* suites 115/115. Suites were selected by symbol
search rather than by change-based lane selection, which is what missed both of these: 20 related
suites, 991 tests, all passing. All four live scenarios re-verified against a rebuilt dist — fresh
install, legacy SQLite before and after doctor, and the JSON-era path. check-changed clean,
pnpm build passing, autoreview clean.

A brand-new install was born in the retired shape. `parseSharedAuthStoreOwnership(undefined)` returns
`legacy-main`, which is the correct compat answer for an existing install whose profiles really do
live in the main agent database -- but a new install has no ownership row and no legacy data either,
so onboarding wrote its first credential into `agents/main/agent/openclaw-agent.sqlite` and the
operator's very first `openclaw doctor` told them to run a migration for state OpenClaw had created
seconds earlier. The main agent also stayed undeletable until they did.

Record `auth.sharedStore = {"location":"state-db"}` when the shared store is first written and the
legacy source provably holds nothing: no `auth_profile_store` row, no `auth_profile_state` row, and
no unfinished cleanup ledger entry. Any legacy row, or any inspection error, leaves ownership alone
so doctor keeps owning the relocation. The check is memoized per ownership generation with a WeakSet
keyed on the process-stable ownership object, so a legacy root is inspected once per process and
doctor's committed flip naturally invalidates it.

The legacy row inspection moves out of `state-migrations.shared-auth-store.ts` into the auth-profiles
owner so doctor and runtime share one contract instead of runtime importing migration code. Explicit
main-agent credential writes now follow the shared target, which is a no-op on legacy roots where
both routes already resolve to the same file.

No SQLite schema change; the ownership row is data. Existing installs take exactly the path they take
today.
@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 20, 2026 18:23
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Aug 20, 2026
@steipete
steipete requested a review from a team as a code owner August 20, 2026 18:23
@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Aug 20, 2026
@steipete
steipete marked this pull request as draft August 20, 2026 18:26
@steipete

Copy link
Copy Markdown
Contributor Author

Draft again — hosted CI found a real defect that my local proof missed, and it is the exact failure mode this PR is supposed to prevent.

checks-node-compact-small-8 failed with 33 tests in src/commands/doctor-auth-flat-profiles.test.ts. Reproduced both directions: this branch gives 28 failed / 24 passed, current main in a clean worktree gives 52 passed. So it is the change, not drift.

Root cause: initializeFreshSharedAuthStore decides an install is fresh by checking only the legacy SQLite rows plus the cleanup ledger. It ignores the retired file sources that predate the SQLite store — auth-profiles.json, auth-state.json, auth.json, oauth.json — which listLegacyAuthProfileSources in src/agents/auth-profiles/legacy-source-diagnostic.ts already enumerates.

On an install upgrading from the JSON era, credentials sit in auth-profiles.json with nothing yet in the agent SQLite. The bootstrap sees no rows, concludes the root is fresh, and records {"location":"state-db"}. Doctor's JSON import then runs against a root whose ownership has already moved and fails with unable to open database file / auth profile migration target verification failed. Those credentials are stranded — precisely what this change must never do.

Fixing the freshness check to consult the existing legacy-source predicate rather than re-deriving it, keeping it fail-closed on any probe error, and adding a regression test for the JSON-era case specifically. Also auditing the rest of the diff for the same "no SQLite rows means nothing to preserve" assumption.

Worth noting why it slipped: doctor-auth-flat-profiles is in a different lane from src/agents/auth-profiles, and check-changed did not select it from the changed files — the cross-lane hazard the root AGENTS.md warns about.

@clawsweeper

clawsweeper Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 20, 2026, 5:10 PM ET / 21:10 UTC.

ClawSweeper review

What this changes

This PR writes first-run shared credentials to the shared state database only when no legacy SQLite, JSON, or unfinished migration source exists, while preserving Doctor migration for legacy installs.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer review: the prior explicit-main write concern is now covered by effective runtime reads and sibling-isolation assertions, and no new blocking correctness defect was found. The remaining decision is whether fresh installs should canonically store credentials for the configured shared main agent in shared state.

Priority: P1
Reviewed head: 9cf1f7ae814a3de07889dc4b058356288fc39b14
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The repair has substantial focused coverage and credible built-CLI scenario evidence; maintainer confirmation of the durable-location contract remains the material merge question.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body supplies after-fix built-CLI output for fresh, legacy SQLite, and JSON-era migration scenarios, including the observed preserved credential result.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies after-fix built-CLI output for fresh, legacy SQLite, and JSON-era migration scenarios, including the observed preserved credential result.
Evidence reviewed 5 items Current-main failure mechanism: An absent ownership record is interpreted as legacy-main, which is correct for upgrades but caused a new shared write to select the retired main-agent location.
Producer-side ownership repair: The PR inspects legacy JSON, SQLite rows, and pending cleanup before recording state-db ownership; inspection failures retain legacy ownership.
Write and migration boundaries: Shared writes route through the bootstrap before choosing a database, while Doctor explicitly names the legacy main directory during JSON import to avoid flipping ownership mid-migration.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

pnpm openclaw --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-126783-QpOMtZ/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 115.32 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 14.1s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 4298ms (slowest: built plugin control-plane loads 3567ms)

OpenClaw 2026.8.1 (9cf1f7a) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console
… output truncated …

Assertions:

  • PASS expect_output: Usage: openclaw

How this fits together

Auth-profile persistence stores provider credentials for agents and shared runtime use. Onboarding and provider setup write credentials, runtime reads resolve effective shared credentials, and Doctor relocates only legacy state.

flowchart LR
  A[Provider setup or onboarding] --> B[Shared ownership check]
  B --> C{Legacy source exists?}
  C -->|Yes| D[Main agent database]
  C -->|No| E[Shared state database]
  D --> F[Doctor relocation]
  E --> G[Runtime credential resolution]
  F --> G
Loading

Decision needed

Question Recommendation
Should an explicit credential write to the agent selected by OPENCLAW_AGENT_DIR be treated as a shared credential on a fresh root and therefore persist only in shared state? Adopt canonical shared ownership: Accept shared-state persistence for configured shared-main writes on fresh roots while retaining Doctor relocation for every legacy root.

Why: The PR preserves effective credential resolution but deliberately changes the durable location for this supported relocation path; source evidence cannot choose the intended persistence contract.

Before merge

  • Resolve merge risk (P1) - On fresh roots where OPENCLAW_AGENT_DIR names the shared main agent, explicit credential writes now persist in shared state rather than that agent’s database; effective reads remain covered, but the storage contract needs maintainer acceptance.
  • Resolve merge risk (P1) - Production code is net +141 lines in auth persistence and migration ownership; the added bootstrap centralizes a safety-critical decision, so this larger-than-default bug-fix surface merits exact-head CI and owner review.
Agent review details

Security

None.

PR surface

Source +141, Tests +321, Other 0. Total +462 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 9 371 230 +141
Tests 5 355 34 +321
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 15 727 265 +462

Review metrics

Metric Value Why it matters
Production versus tests production +371/-230 (net +141); tests +355/-34 The added runtime bootstrap and extracted migration contract are material auth-persistence changes, with focused regression coverage exceeding the production growth.
Persisted ownership behavior 1 existing machine-state key written on a fresh shared-auth write The existing auth.sharedStore record now determines first-run credential placement and upgrade behavior.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-auth-flat-profiles.test.ts, migration/backfill/repair: src/commands/doctor-auth-flat-profiles.ts, serialized state: src/infra/state-migrations.shared-auth-store.ts, unknown-data-model-change: src/commands/doctor-auth-flat-profiles.test.ts, unknown-data-model-change: src/infra/state-migrations.shared-auth-store.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge-risk options

Maintainer options:

  1. Adopt the shared-target contract (recommended)
    Merge after maintainers explicitly accept that fresh configured-main credentials are shared state while legacy roots remain Doctor-owned.
  2. Retain explicit local persistence
    If the configured agent directory must remain a durable local target, remove the explicit-main redirect and preserve that behavior with focused regression coverage.

Technical review

Best possible solution:

Adopt one explicit contract: fresh shared credentials belong only in shared state, while every detectable legacy source remains legacy until Doctor completes its verified relocation.

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

Yes, from source: current main treats an absent ownership record as legacy-main and selects the main-agent database; the PR’s built-CLI transcript also records the resulting first-Doctor migration prompt.

Is this the best way to solve the issue?

Unclear pending the persistence-contract decision: producer-side initialization is the right layer, but maintainers must confirm that configured-main explicit writes are semantically shared credentials.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4c52d3fe9df3.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies after-fix built-CLI output for fresh, legacy SQLite, and JSON-era migration scenarios, including the observed preserved credential result.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The PR fixes first-run provider credential ownership and the resulting Doctor/deletability workflow.
  • merge-risk: 🚨 compatibility: It intentionally changes durable credential placement for fresh installs and configured shared-main relocations.
  • merge-risk: 🚨 auth-provider: Provider credentials and their shared runtime resolution move to a different SQLite owner on fresh roots.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies after-fix built-CLI output for fresh, legacy SQLite, and JSON-era migration scenarios, including the observed preserved credential result.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix built-CLI output for fresh, legacy SQLite, and JSON-era migration scenarios, including the observed preserved credential result.

Evidence

What I checked:

Likely related people:

  • Dallin Romney: Current-main blame identifies this author on the existing absent-ownership interpretation and shared-auth migration path. (role: recent auth-path contributor; confidence: medium; commits: 28568d0c1278; files: src/agents/auth-profiles/path-resolve.ts, src/infra/state-migrations.shared-auth-store.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm the configured-main persistence contract in review.
  • Wait for exact-head required checks before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-08-20T18:30:04.758Z sha f9f4850 :: found issues before merge. :: [P1] Route external CLI persistence through shared ownership bootstrap
  • reviewed 2026-08-20T19:16:54.831Z sha f9f4850 :: found issues before merge. :: [P1] Preserve JSON-era auth before flipping ownership | [P1] Route external CLI persistence through shared ownership
  • reviewed 2026-08-20T19:44:36.383Z sha 580af0d :: found issues before merge. :: [P1] Route external-CLI persistence through shared ownership
  • reviewed 2026-08-20T20:27:03.824Z sha 580af0d :: found issues before merge. :: [P1] Keep explicit agent-target writes local

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 20, 2026
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Aug 20, 2026
@steipete
steipete marked this pull request as ready for review August 20, 2026 19:39
@steipete steipete closed this Aug 20, 2026
@steipete steipete reopened this Aug 20, 2026
@steipete
steipete marked this pull request as draft August 20, 2026 19:49
@steipete

Copy link
Copy Markdown
Contributor Author

Draft again. The re-fired CI run surfaced a second cross-lane failure, and this one is a design question rather than a bug I can quietly patch.

checks-node-compact-small-26 failed with 4 tests in src/commands/onboard-auth.test.ts, all Expected SQLite auth profile store for <state>/agents/kid/agent. Reproduced locally.

Cause: resolveSharedMainAuthAgentDir honors OPENCLAW_AGENT_DIR, so in those tests — which point that variable at kidAgentDir — kid is the shared main dir for the process. prepareFreshSharedAuthStoreWrite therefore treats an explicit write to kid as a shared write, the fresh root records state-db, and the credential lands in state/openclaw.sqlite rather than the kid agent's own database. The helper reads the agent database directly and finds nothing.

I ran the decisive experiment before concluding anything. With allowExplicitMain: false:

  • onboard-auth → 13/13 pass
  • auth-profiles.sqlite-store → 3 failed / 20 passed
  • doctor-auth-flat-profiles → 53/53 pass

So the redirect is load-bearing for three of this PR's own fresh-install and memo tests, and is simultaneously what breaks the four onboard-auth tests. The requirements are in genuine tension.

The question being settled next, with evidence rather than by editing assertions: after an explicit writeOAuthCredentials(provider, creds, kidAgentDir), is the credential still reachable through the normal runtime read path for that agent, or only through the shared store? If it is still resolvable, only the storage location moved and those four tests are coupled to persistence layout. If it is not, the redirect is a cross-agent regression and must narrow to agentDir === undefined.

Worth flagging either way: OPENCLAW_AGENT_DIR is a supported relocation, not a test-only knob, so whatever contract we land applies to real installs that point it at a specific agent.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 20, 2026
@steipete
steipete marked this pull request as ready for review August 20, 2026 21:03
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 20, 2026
A fresh root records state-db shared ownership, so the model-catalog credential migration persists into the shared store rather than the agent file. The assertion read the agent file directly and saw an empty store while all three credentials were present and correct in state/openclaw.sqlite. Read through the owner for that state root instead of pinning storage layout; the credential contents are still asserted exactly.
@steipete
steipete merged commit a8a9f28 into main Aug 20, 2026
230 checks passed
@steipete
steipete deleted the steipete/fresh-install-shared-auth-owner branch August 20, 2026 21:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 21, 2026
openclaw#126783)

* fix(auth): create a fresh install with canonical shared-auth ownership

A brand-new install was born in the retired shape. `parseSharedAuthStoreOwnership(undefined)` returns
`legacy-main`, which is the correct compat answer for an existing install whose profiles really do
live in the main agent database -- but a new install has no ownership row and no legacy data either,
so onboarding wrote its first credential into `agents/main/agent/openclaw-agent.sqlite` and the
operator's very first `openclaw doctor` told them to run a migration for state OpenClaw had created
seconds earlier. The main agent also stayed undeletable until they did.

Record `auth.sharedStore = {"location":"state-db"}` when the shared store is first written and the
legacy source provably holds nothing: no `auth_profile_store` row, no `auth_profile_state` row, and
no unfinished cleanup ledger entry. Any legacy row, or any inspection error, leaves ownership alone
so doctor keeps owning the relocation. The check is memoized per ownership generation with a WeakSet
keyed on the process-stable ownership object, so a legacy root is inspected once per process and
doctor's committed flip naturally invalidates it.

The legacy row inspection moves out of `state-migrations.shared-auth-store.ts` into the auth-profiles
owner so doctor and runtime share one contract instead of runtime importing migration code. Explicit
main-agent credential writes now follow the shared target, which is a no-op on legacy roots where
both routes already resolve to the same file.

No SQLite schema change; the ownership row is data. Existing installs take exactly the path they take
today.

* fix(auth): preserve JSON-era shared credentials

* docs(auth): explain why doctor names the main agent dir during a shared JSON import

* test(auth): assert shared-owner runtime reads

* test(doctor): read migrated catalog credentials through the shared owner

A fresh root records state-db shared ownership, so the model-catalog credential migration persists into the shared store rather than the agent file. The assertion read the agent file directly and saw an empty store while all three credentials were present and correct in state/openclaw.sqlite. Read through the owner for that state root instead of pinning storage layout; the credential contents are still asserted exactly.
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 maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant