Skip to content

feat(state): local client credential cutover (R0 PR1b) - #174599

Merged
steipete merged 23 commits into
mainfrom
pgprep/r10-pr1b-credential-cutover
Oct 19, 2026
Merged

steipete merged 23 commits into
mainfrom
pgprep/r10-pr1b-credential-cutover

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Behavior and ownership

Implements Peter's approved R0 ownership split (2026-10-14), following PR1a #174294 and the landed R14b seam #174360. Swift and TypeScript client identities, token caches, and IPC/socket credentials now belong to the explicitly local <resolved-client-root>/client/credentials.sqlite. Native bootstrap does not open the selected Gateway database. Approval policy and effect-time authority stay unchanged.

App-running callers use authenticated bounded operations; app-absent callers acquire exclusive local custody. Migration captures, copies exact rows, verifies, publishes its receipt, then retires shared credentials under the same custody. Shared schema/cutover is 29; local store and receipt versions stay 1. Receipts bind source identity, generation, and content hash. A stale orphan store is rebuilt from the authoritative source, never merged.

Independent native sources remain byte-identical and genuinely read-only. Same-source imports retain local tokens and consumed-import claims; changed or restored sources trigger a bounded rebuild. Revoked credentials cannot be reimported. Old native readers refuse retired canonical layouts and accept untouched independent sources.

This replaces closed #174485: frozen predecessor artifacts exceeded ClawSweeper's changed-line limit. The replacement uses delta SQL and regenerated current artifacts, with no frozen predecessor runtime/catalog copies.

Update and rollback

Before first cutover the local store does not exist: PR1a enables no production reader or writer. Published SQLite drivers capture the shared credential tables. Automatic rollback restores those tables and socket material; the old version ignores the orphan local store. Credentials issued between upgrade and rollback are lost; affected clients re-pair. The next upgrade rebuilds local state from restored shared state.

PG installations begin with PR1a/R14b-capable drivers that capture shared families and local companions. R14b's capture coordinator attributes the candidate Doctor's writes; no parallel journal or borrow registry was added. Standalone SQLite Doctor takes a fresh same-custody table backup, verifies source row hashes, then retires. Scope is [device_identities, device_auth_tokens, gateway_origin_device_tokens, exec_approvals_config], plus sqlite_stat1/sqlite_stat4 for retired indexes. Native-v0 at a PG anchor refuses with guidance to start once on SQLite, run openclaw doctor --fix, then port; it is not auto-published.

Actual published stable 20→29→20, beta 22→29→22, and installed PR1a PG 25→29→25 capture → candidate Doctor → rollback harnesses pass. They verify restored shared credentials/socket rows, the orphan-store contract, unchanged independent-source bytes/mode/mtime/inode, and old native-reader acceptance.

Rebase and conflict resolutions

Rebased onto c91613518f8076c61f7e598c93388488899426a2, preserving main's schema 28 and assigning this cutover 29. Generated files were regenerated through their owners.

  • Main's identity-custody assertions and command-level cases are retained against the local credential owner or authenticated operation. Main's inlined node-identity command stays inlined.
  • Shared-database fixture cleanup stays, with local credential cleanup where needed; node-pairing and same/different-owner TLS coverage are preserved.
  • State contracts, maintenance, schema repair, and Voice Call Doctor combine main's additions with credential retirement. Existing-version admission keeps its read-only anchor under parent maintenance custody.
  • The latest overlap preserves main's four-mode WAL assertions, narrower Doctor attribution metadata, maintenance-only engine classification, terminal-history wait, and selection-chip readiness comment. No assertion or deadline was weakened. No Swift files changed in the latest reconciliation.

The latest main change inlined the single-caller JSONL transport. This cutover introduces a second production caller, so the reconciliation retains one shared transport plus the exec-host adapter and preserves main's complete real-socket tests. The credential-specific revocation-before-send and bounded-reply tests remain. Generated worker inventory was regenerated, never hand-merged. Independent P0–P2 rebase review is clean. Final local results are recorded below.

Proof

Latest rebase proof: 125 selected tests pass across nine full files (47 transport/credential; 78 updater/admission/onboarding), three type graphs and scoped type-aware lint/format pass, PG generation/check 176 contracts and Kysely four contracts pass. Wrapper inventory/closure, import guard, and ratchets pass except the three inherited UI findings. Mac disconnect 7/7 and test build pass; generated Swift bytes are unchanged from the prior complete native proof. The earlier broad-config lint invocation timed out in declaration preparation before lint ran; the supported core-config lint completed cleanly.

Final source head: a1f95b9c505ca389bb00235312250bcc51e2058e. Current-head CI: 39324475402, actual tested merge 0ee4e16ea617466677ff3a2c25bf7a14d5138119 / main 1099ccc1713bda550cbbf04b97b3f6d4299b0415. All three PG shards actually passed: 934 passed, 37 skipped, zero failed. All CI jobs are now terminal; classification is below. Earlier 83986705 evidence remains retained as historical proof; the classification below uses the current head and attempt.

  • All three PostgreSQL conformance shards actually ran: 934 passed, 37 skipped, zero failed, including public SQLite/PG update and rollback, credential migration, and all three Matrix PG cases. Skips remain skips.
  • Final local PG replay passed 25→29→25 in 194 seconds; all 26 affected PG cases and four WAL capture cases passed. Homebrew PG17 used internal-disk HOME/TMPDIR and the required locale, and was stopped afterward.
  • Store/custody, Gateway startup pairing, refresh/revocation, revoked-import protection, same-inode source changes, exact identity preservation, cross-language receipt/wire fixtures, and old-client refusal are covered by retained input-bound proof.
  • Native proof passes 126 shared/native and eight Mac credential cases; the native rebase additionally passes 116 cases across seven full affected suites. Shared/Mac test builds, Mac product build, and Swift lint pass. No app launch/install or real Keychain mutation occurred.
  • Earlier bound proof covers 11 selected type graphs. The latest rebase passed three targeted type graphs, scoped lint/format, import guard, wrapper inventory/closure, and ratchets except the inherited local findings below. Current CI has the separately reproduced main-side type/lint failure listed below. PostgreSQL generation/checks pass 176 contracts; Kysely checks pass four; worker inventory regenerates unchanged at 625 files/2,304 calls.
  • Current-head CI passed all three restart modes (managed, SIGTERM, SIGKILL), all eight UI E2E shards (3,389 tests) plus the browser-extension job (1 test), and the repaired worker/declaration, catalog, reclamation, completion, and skill-menu cells. Fixture repairs preserve original assertions and deadlines. The declaration fixture no longer follows dependency symlinks and overwrites the installed worker. Completion replay uses the existing current-context decoder; the late-lease fixture closes its seed handle. Native receipt validation matches TypeScript, and the offline candidate retains trusted native assets.

Signed real-Mac proof pending (coordinator-owned post-land verification).

Current-head CI classification

Run 39324475402, attempt 1, head a1f95b9c505ca389bb00235312250bcc51e2058e, actual tested merge 0ee4e16ea617466677ff3a2c25bf7a14d5138119 against main 1099ccc1713bda550cbbf04b97b3f6d4299b0415.

All 205 checks are terminal: 182 successful, 15 skipped, seven inherited failed jobs plus the aggregate gate. No retry was requested for this head. The seven failures are independently reproduced on main or supported by unchanged-input main proof; native admin admission preserves their failed status.

Check Disposition
PostgreSQL conformance All three shards actually ran: 934 passed, 37 skipped, zero failed. Public SQLite/PG capture, Doctor and rollback, migration and all three Matrix PG cases pass.
iOS screenshots and evidence Both passed on the first attempt.
QA Smoke All four profiles passed.
Published-driver update CI Skipped; retained local stable 20→29→20, beta 22→29→22, and PR1a PG 25→29→25 harnesses provide the described proof.
Requester identity shape Inherited: exact main reproduces all five missing-undefined-key assertions; the explicit-fields sixth case passes. Main intentionally omits undefined fields for JSON-stable requester capture, while these expectations still require the keys.
Compaction replay Inherited duplicate-continuation assertion. All 18 relevant recorded inputs unchanged; the ancillary image-cap change is not exercised by this text-only fixture.
Restored requester settlement Inherited common initial request-count/announcement timeout in FINAL and STOP. Twenty-one recorded inputs unchanged per side; runtime-timeout and max-two pass. Outcome-specific branches are not reached; FINAL's yielded fence and platform/timing limits remain explicit.
OTel update setup Inherited retained build-lock refusal after the preceding operator-restart test passes. The two newer main changes affect warning formatting and HTTP asset caching; build prepare/start/stop and internal finalization remain unchanged. No OTel runtime success is claimed.
MCP grant revalidation Inherited view expiry at board.widget.put, before grant-revocation assertions. Sixteen recorded inputs unchanged per side; prior exact-main original-file reproduction and platform/readiness limits are retained.
Gateway-root typecheck and lint Inherited: clean exact main reproduces the missing createDeferredCore and resulting implicit-any errors, plus prefer-promise-reject-errors in the same unchanged test. The original checker and canonical lint rule were run without source edits.

Historical local failures remain recorded in native review; passing replays do not erase them. The main/PR identity and fixture differences are retained in the evidence. Native admin admission is used for the verified inherited failures; failed CI is not represented as green.

The three inherited local UI max-lines findings are ui/src/pages/chat/components/chat-message.test.tsx, ui/src/pages/config/config-page-state.ts, and ui/src/pages/sessions/sessions-page-state.ts. Clean main also reproduces six generated Mermaid Knip assets: assets/mermaid.min-DhdZyIsV.js, frame.js, and native.js under both apps/shared/OpenClawKit/Sources/OpenClawChatUI/Resources/Mermaid/ and apps/shared/mermaid/assets/mermaid/.

Size

+3,896 net production lines, or +3,870 excluding the generator (+26), against the rebase base above. Full diff: 29,532 changed lines across 518 files, below ClawSweeper's 50,000-line limit. Complete Swift/TS cutover, custody, receipt/source binding, old-client fencing, and rollback support account for growth beyond the +1,500–2,200 estimate.

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: ios App: ios app: macos App: macos gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations size: XL labels Oct 16, 2026
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR moves client identities, cached tokens, and native socket secrets into a separately versioned local SQLite store.

Example: A CLI installation uses PostgreSQL for Gateway state.

  • Before: Client identity and token access depends on the selected shared-state database.
  • After: Private client credentials use <resolved-client-root>/client/credentials.sqlite at local schema version 1.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The inspected repairs are coherent with no new confirmed defect; final native authority evidence remains absent, and review coverage does not certify every changed fixture.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Private client credential access remains coupled to the Gateway's selected shared-state database.
Reason: The maintainer-authored direction and merged prerequisite approve separating local secrets while preserving identity bytes, pairing authority, and rollback behavior.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: this maintainer-approved cutover remains necessary, the two latest findings are addressed, and the explicit landing pause still applies.

Priority: P2
Reviewed head: 01695d5df1dc12530bbaf4d9a32af5569ad2ec98

Before merge

  • Add real behavior proof - Authority-chain proof required: provide the scheduled signed real-Mac client.credentials trace showing allowed access and rejection of foreign UID, unowned-root, and closed or replaced owner requests before credential I/O or disclosure, including closure while work waits. Recorded PostgreSQL, updater, and native harness results support their declared scenarios but explicitly exclude this app run; redact secrets, IPs, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security review attention item - No concrete bypass was established, but the new credential-disclosure boundary still needs its scheduled authority proof.
  • Resolve merge risk - Final-effect authorization for native credential disclosure after owner closure or replacement remains unverified.
  • Complete next step - Resolve the conflicts GitHub reports for the reviewed head and validate the affected integration changes.

Findings

None.

Tests

  • Missing end-to-end proof: The scheduled signed-app credential authority scenario remains unshown, and the archive regression has no recorded failing base run.
Agent review details

How this fits together

CLI and Apple clients submit bounded credential operations to the active app or an exclusive offline owner; migration and restore owners preserve the shared/local binding.

flowchart TD
  A[CLI and Apple clients] --> B[Credential routing]
  B --> C[Authenticated app control]
  B --> D[Exclusive offline custody]
  C --> E[Local credential SQLite]
  D --> E
  F[Doctor and updater] --> E
  F --> G[Shared state migration]
Loading

Technical review

Best possible solution:

Complete the approved single-owner cutover with exact migration and restore binding, preserving the documented rollback contract.

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

This is an approved architectural cutover; current-main source confirms the shared-storage coupling, and no runtime reproduction was attempted during this read-only review.

Is this the best way to solve the issue?

The inspected implementation uses one local credential owner and existing migration, backup, and capture coordinators; the two requested repairs fit those owners without introducing competing state.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Complete the scheduled native verification (recommended)
    Establish allowed and forbidden final credential effects through the signed app before lifting the landing pause.
  2. Retain the landing pause
    Keep this PR open while the native proof coordinator completes the scheduled verification.

Provenance checked

  • Cross-runtime identity persistence changes intended behavior with a stated reason (98410d9: The earlier migration established one SQLite identity owner and preserved key material across Node and Apple clients.)
  • Native adoption of CLI-written identities keeps the original intent (3740070: Native startup needed to adopt valid canonical identities during shared-state migration without rotating trust or accepting corrupt rows.)
  • Legacy import and rollback keeps the original intent (feat: prepare local client credential storage and recovery #174294: The approved cutover requires copy-only independent sources, durable consumed-import claims, and rebuilding stale local state from authoritative rollback images.)
  • Migration publication attribution keeps the original intent (fix(update): PostgreSQL schema migrations keep exact rollback #174360: The existing capture coordinator attributes committed migration changes while preserving exact rollback and rejecting foreign writes.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete bypass was established, but the new credential-disclosure boundary still needs its scheduled authority proof.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 98410d9 adds apps/shared/OpenClawKit/Sources/OpenClawKit/DeviceIdentitySQLiteStore.swift:6 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 98410d986eee; files: apps/shared/OpenClawKit/Sources/OpenClawKit/DeviceIdentitySQLiteStore.swift)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Root-cause cluster

Relationship: canonical
Canonical: #174599
Summary: This PR replaces the closed predecessor and completes the production cutover after the merged preparation work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • remove merge-risk: 🚨 automation: Current PR review merge-risk labels are merge-risk: 🚨 compatibility, merge-risk: 🚨 security-boundary.

Label justifications:

  • P2: This is an approved storage and ownership improvement without an established urgent production incident.
  • merge-risk: 🚨 compatibility: Shared credential tables are retired and client versions must coordinate; the rollback re-pairing tradeoff is explicitly recorded in the merged prerequisite.
  • merge-risk: 🚨 security-boundary: The app-control endpoint now returns private credential material and depends on current UID, root, and owner-lifetime authority.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Add final-effect proof for foreign UID, foreign root, and closed or replaced native owners, including closure while credential work waits.

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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-16T20:05:12.183Z sha a27ee92f9d4d9d183e381d5fbe7f2238e8c0a525 :: needs real behavior proof before merge. :: [P2] Keep predecessor identity repair reachable before cutover validation
  • reviewed 2026-10-17T18:37:45.479Z sha c24a2b7257f68e1ecf46a42950f99d92358ca11f :: needs real behavior proof before merge. :: [P1] Preserve explicit identity database paths | [P2] Validate the persisted winner before serving app identities
  • reviewed 2026-10-17T20:06:55.732Z sha 2af27ceb28dda236990e1e1b9ed5a51874a998ba :: needs real behavior proof before merge. :: [P2] Accept the exact raw observation when clearing normalized tokens | [P2] Fall back offline after a definite pre-send socket refusal | [P2] Migrate the remaining preauth test identity paths | [P2] Apply migration custody to the untouched-index recovery cases
  • reviewed 2026-10-17T21:09:21.031Z sha 574d96bd000422acd1ee2278a258c8a773fa1d75 :: needs real behavior proof before merge. :: [P2] Match archived receipts using captured canonical source identity | [P2] Update the retained planner expectation for first-sign-in routing

Reviewed October 17, 2026, 6:29 PM ET / 22:29 UTC (Revision 5).

@steipete
steipete force-pushed the pgprep/r10-pr1b-credential-cutover branch 5 times, most recently from f30c956 to d09b09a Compare October 17, 2026 03:33
@openclaw-barnacle openclaw-barnacle Bot added channel: voice-call Channel integration: voice-call agents Agent runtime and tooling channel: matrix Channel integration: matrix extensions: codex labels Oct 17, 2026
@steipete
steipete force-pushed the pgprep/r10-pr1b-credential-cutover branch from f9e8e76 to 62e3976 Compare October 17, 2026 06:24
@steipete
steipete force-pushed the pgprep/r10-pr1b-credential-cutover branch 6 times, most recently from 3f78fee to a1095b1 Compare October 17, 2026 17:14
@steipete
steipete marked this pull request as ready for review October 17, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: ios App: ios app: macos App: macos channel: matrix Channel integration: matrix channel: voice-call Channel integration: voice-call clawsweeper:intake:feature Preliminary submission classification; full source review pending. cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: codex extensions: qa-lab gateway Gateway runtime merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts security-sensitive-changed size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant