Skip to content

refactor(github): move personal connection authority to workers - #168948

Merged
steipete merged 14 commits into
mainfrom
dbasync/sw7d-connections
Oct 11, 2026
Merged

steipete merged 14 commits into
mainfrom
dbasync/sw7d-connections

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Personal GitHub sign-in, selection, disconnect, and refresh bookkeeping still perform native database work from the Gateway’s connection owner.

User Impact

Bundled callers now await the shared-state worker, preserving connection ownership checks and settlement of accepted refresh work. RPC shapes, credential storage, and sign-in behavior remain unchanged. This is the connection-authority prerequisite for the GitHub publication migration; publication request and execution paths are not cut over in this PR.

Why This Change Was Made

Typed commands move connection changes and refresh settlement into the existing state writer. OAuth/RPC callers and profile-merge retirement await that owner. Core-only synchronous mutation exports are removed after their bundled callers move.

Role authority reuses the Gateway’s retained canonical profile catalog without another worker request. Standalone callers without that catalog use the existing joined shared-state query. Both paths retain the same profile authority fence and never create absent storage. Connection get/list reads use the owning worker; their duplicate readonly protocol is removed.

Released OAuth cancelAuthorization and disconnect keep their immediate boolean and void results through native adapters. Bundled RPCs use cancelAuthorizationAsync and disconnectAsync; the old methods name those replacements and the next Plugin SDK major removal window through the shared deprecation helper. No schema, stored-data, retention, or update migration is required.

S10 handoff after the complete stack: the parked w6github lane can use host-minted GitHubPublicationRequesterV2 and PersonalGitHubSessionActionV2, with GitHubPublicationTransitionAuthority and typed source/transition operations. This slice is a prerequisite; the complete-stack handoff includes canonical receipt installation before observers and does not claim removal of every final synchronous guard.

Stack dependency: S7 slice 1/7, head 8fd45413281bfb884722a5c89deb8f0c2d1d137a, base main. The original connection implementation base is 951a75d4bf578a0843fb5497d1602b838827b4d6 (dbasync/sw7d-base), including the shared SDK warning helper. This stack reuses that helper; no second helper is introduced.

Evidence

Original complete-stack proof source: f33795fc32205414b436f84f06dcd5e924255704, tree 7e949f3b906ebc5e0f70dfa483b22c018c43c3cb. Its tree matches reviewed repair f33795fc32205414b436f84f06dcd5e924255704. post-runtime-repair-deb8cf38/source-relation.json — workerAwaitCorrection: exact twelve unnecessary awaits removed from one worker test; production and every other file equal b6. Actual proof heads retained. Slice1LandingIntegration records the separate remote-verified integrated successor; complete-stack f337 proof remains historical for that successor. Complete-stack results below do not claim a separate execution of this intermediate head.

Final f337 worker Node/Bun fixtures pass 11/11 each. Lead accepted cumulative check coverage: 31 successful b6 prefix stages plus 11 native f337 suffix stages, retaining actual heads and original failures. All three user-approved cold exceptions now satisfy the same-flow warm ratio <=1.5 condition (repository 1.007232, shared 1.199175, failed preparation 0.572741). Integrated slice 1 static/tests pass at 5e6 and are reused through the one-line baseline-only 8fd successor. The hosted dispatch failure remains unresolved under the lead’s relaxed-v4 focused-pass disposition; targeted baseline and candidate runs both pass.

Landing addendum: current pushed head 8fd45413281bfb884722a5c89deb8f0c2d1d137a (tree bcf921e2c5180abb4cb206507fcab521a396baf4) removes one obsolete mock factory from the generated baseline, 10123 → 10122; isolated review is scoped-clean. Its parent 5e6d6038af0a15178e47e4d52c7cc1168aa2644a contains the five-file test/static repair and conflict-free main integration. The five static gates, Gateway 72/72, SDK surface 6/6 and runtime API guardrail 7/7 ran at that parent; no runtime or test source changes in the successor, so those results remain attributed to 5e6. Seventeen other test files reuse their byte-verified prior 59d6 results. The native mock-ratchet check passes at exact 8fd in 16.482 seconds with 10122 grandfathered factories and stable source. Original owner/common measurements retain their original heads.

Hosted CI failed chat.send deletes a session before its pending dashboard title finishes on CI merge d26228ab (5e6 merged into bdcbb2d887062a9019f64cf516b7c9dff1f0a6bf). One targeted run per head on the same AWS host passed on baseline 50cf629016e248cdea5fac810c8fc6b194155e01 and candidate 5e6d6038af0a15178e47e4d52c7cc1168aa2644a; the test source hashes match. Source audit found no direct S7 path, but neither an inherited failure nor a root cause is proven. The lead accepts the relaxed-v4 focused-pass route with this CI-only uncertainty retained; these reruns do not establish a fix or claim all hosted CI is green.

Original implementation diff at 4c299f5f656f66b565e51e85e3fc8934925e6940 relative to 951a75d4bf578a0843fb5497d1602b838827b4d6: production +1152/−491 (1643 changed lines); tests +100/−18 (118 changed lines); docs +10/−9 (19 changed lines).

The recorded GitHub-style comparison uses observed main revision 50cf629016e248cdea5fac810c8fc6b194155e01 and merge base 50cf629016e248cdea5fac810c8fc6b194155e01: production +1148/−490 (1638 changed lines); tests +149/−59 (208 changed lines); docs +15/−13 (28 changed lines). This is a pinned comparison, not a claim about current main.

Check Result Tested source and scope Wall / CI seconds Evidence
Migration closure REUSED 7a695a0f91db5de010a402c9452527b3623a17cc — 12-query census;14 committed-file hash matches. No escaped legacy caller, runtime alias, mutating read or retired route. Source proof only. not measured / not measured post-runtime-repair-deb8cf38/source-relation.json — latestMigrationSourceAudit; reuse: Two reviewed test-only corrections leave production unchanged: b6 personal teardown and f337 worker read awaits. Actual executed head retained; affected worker tests/types rerun separately.
Final-head native mock ratchet PASS 8fd45413281bfb884722a5c89deb8f0c2d1d137a — check:test-mock-exports against 50cf; 10122 grandfathered factories. Stable source; exact one-row baseline deletion from tested 5e6, no runtime/test source changes. 16.482242829999905 / not measured ratchet-8fd45413/launch.log — RATCHET_RESULT and native ratchet output
Integrated5e6 static gates PASS 5e6d6038af0a15178e47e4d52c7cc1168aa2644a — Type-aware core/scripts lint, source contracts/export collisions, Knip export scan and SDK surface pass with native environment and stable source. core30.707; scripts2.365; contracts91.575; Knip106.697; SDK7.156 / not measured landing-5e6d6038/results/static-results.json; source-receipt.json; completion.json
Integrated5e6 repaired tests PASS 5e6d6038af0a15178e47e4d52c7cc1168aa2644a — Gateway72/72 across authorization/users-GitHub/device-pairing; surface-report6/6; runtime-api guardrail7/7. Native reports show no failures, pending or todo. Gateway148.617; surface14.706; guardrail25.635 / not measured landing-5e6d6038/results/test-results.json; focused-gateway-vitest.json; focused-other-vitest.json; sdk-guardrail-vitest.json
Unchanged integration tests REUSED 59d6ed2de0852030d3e532225f37d3a0b3b0e700 — 17 prior test files reused, including connection/publication/authority siblings; every test blob hash independently matches5e6. This is prior-head evidence, not17 new executions. prior execution retained / not measured landing-5e6d6038/results/completion.json reusedTests; historical landing-59d6ed2d/gateway-vitest.json and focused.log; reuse: All17 test source blobs are byte-identical at59d6 and5e6; current repaired files and SDK guardrail ran separately. Lead/proof owner accepts this scoped reuse.
Dispatch CI case — baseline targeted run PASS 50cf629016e248cdea5fac810c8fc6b194155e01 — One filtered run of the exact failing case on the same AWS host as the candidate; identical test source. Does not reproduce the hosted CI failure. 67.166904479 / not measured dispatch-case-comparison.json; baseline-dispatch-50cf6290/
Dispatch CI case — candidate targeted run PASS 5e6d6038af0a15178e47e4d52c7cc1168aa2644a — One filtered run; test source identical to baseline. The actual hosted job used a CI merge commit; this pass does not prove an inherited failure or a fix. 66.925617602 / not measured dispatch-case-comparison.json; candidate-dispatch-5e6d6038/
Slice 1 integration — authorization fixture PASS 59d6ed2de0852030d3e532225f37d3a0b3b0e700 — Reviewed one-line mock export rename after conflict-only main integration; 6/6 authorization tests. Historical result; later integrated proof and explicit 17-file reuse are recorded above. 89.32 Vitest / 113.09 pnpm / not measured landing-mock-test.log; landing-mock-review-status.json
Gateway-ready connection owner RPC proof PASS 4c299f5f656f66b565e51e85e3fc8934925e6940 — Three alternating pairs against 951a75d; connected status, missing-pending cancel and disconnect, 18/18 tests across six runs. Existing profile catalog retained before measurement on both sides; accepted by lead. Synthetic transport, not live GitHub proof. Vitest suites: base [57.88, 56.57, 55.55]; candidate [56.14, 56.3, 55.79] (RPC timing separate) / not measured renewal-7914382e/evidence/results/owner1/comparison.json; completion.json; 01–03 main/candidate test.log and manifest.json
Worker fixture — Node and Bun PASS f33795fc32205414b436f84f06dcd5e924255704 — Node 11/11 and Bun 11/11; zero failed/pending/skipped/todo. Exact final source remained stable. Validates the twelve synchronous-read await removals. Node 30.823; Bun 28.180561 / not measured renewal-f33795fc/evidence/results/runtime/runtime-results.json; bun/runtime-results.json; both worker-fixture-vitest.json reports
Shared-publication tests REUSED 7a695a0f91db5de010a402c9452527b3623a17cc — Shared 23/23 and boundary 36/36 passed; includes unbranded legacy writer/callback paths. Both suites and production are unchanged through f337. 86.953 / not measured renewal-7a695a0f/evidence/results/runtime/runtime-results.json; bun/runtime-results.json; reuse: Shared/boundary inputs are unchanged through both test-only corrections; actual7a head retained.
Repository/requester aliases PASS a7c683b6829e50b595848a8357a6521557cd1e94 — 58/58: repository 43 and requester aliases 15 at a7. The repository suite includes the legacy callback that observes the publishing transaction. Later 7a bookkeeping tests are separate. 211.293 / not measured renewal-a7c683b6/evidence/results/runtime/runtime-results.json; focused-gateway.log
Identity/profile focused tests PASS f0b9308c8af2f3211f1c2fe357baed96bc596f0d — 14/14 tests across user-channel-identities and user-profiles-multi-account; native single invocation. Historical exact-f0 result. 46.381 / not measured renewal-f0b9308c/evidence/results/runtime/runtime-results.json; state-focused.log
Personal publication — full suite REUSED b6e39b6b5f2c4769ee6ec8d232e02c581eed1ff9 — 50/50, zero failed/pending/skipped/todo. Includes executed legacy personal-writer cases; validates the teardown correction. Source remained exact throughout. 141.705 / not measured renewal-b6e39b6b/evidence/results/runtime/runtime-results.json; focused-gateway-vitest.json; reuse: F337 changes only the separate worker test. Personal suite and all production files are byte-identical to b6; actual executed head retained.
Dedicated SDK type fixture REUSED 22b70997d7b0a5f7c85229b51f5a938f48739a32 — Bun wrapper 1/1 is type-only; f0 SDK test typecheck 54.002s validates its assertions. Legacy runtime coverage is listed separately; no universal parity or inherited-reader claim. 2.703 / not measured renewal-22b70997/evidence/results/bun/runtime-results.json; renewal-f0b9308c/evidence/results/runtime/sdk-test-types.log; reuse: Lead accepted the unchanged SDK fixture through the later source corrections; its actual executed head remains 22b7.
Types, declarations, cycles and dead code REUSED 7a695a0f91db5de010a402c9452527b3623a17cc — Core types, SDK declarations, Madge, configured Knip files/dependencies and canonical all-exports passed. SDK declarations match all 298 original f0 path/hash entries without normalization. git diff --check also passed. core 63.085; dts 105.468; Madge 19.095; Knip 69.662; exports 84.721; diff 0.048 / not measured renewal-7a695a0f/evidence/results/runtime/runtime-results.json; sdk-declaration-comparison.json; exports/runtime-results.json; reuse: Two reviewed test-only corrections leave production unchanged: b6 personal teardown and f337 worker read awaits. Actual executed head retained; affected worker tests/types rerun separately.
SDK API comparison REUSED f0b9308c8af2f3211f1c2fe357baed96bc596f0d — Original 951a→f0 comparison: no entrypoint additions/removals, 7 added exports, 182 reachable changes. Exact 7a declarations equal original f0; b6 is test-only. No new API-diff run. 547.025 / not measured renewal-f0b9308c/evidence/results/runtime/sdk-api.json; sdk-api-evidence.json; renewal-7a695a0f/evidence/results/runtime/sdk-declaration-comparison.json; f0-sdk-declarations-baseline.json; reuse: Lead and metadata verification independently matched all 298 path/hash entries to original f0, including original source-receipt/runtime-results and baseline snapshot hashes. Original API comparison remains applicable to 7a.
Common workload and failure behavior REUSED 7a695a0f91db5de010a402c9452527b3623a17cc — Common:a0→7a, 3 pairs, accepted under attributed turn noise floor/non-turn tolerance. Failure:2c32→7a, 5 pairs, 40/40 tests; cold worker-turn preparation has a user-approved exception after same-flow warm ratio 0.572741; original cold ratio retained. Actual bases, counts and all timings below. Per-phase/per-flow durations below; no total-suite timing claim / not measured renewal-7a695a0f/evidence/results/common7/comparison.json; failure/comparison.json; failure/*/vitest.json; reuse: Two reviewed test-only corrections leave production unchanged: b6 personal teardown and f337 worker read awaits. Actual executed head retained; affected worker tests/types rerun separately.
Earlier Gateway failure FAIL (resolved) deb8cf386e59daf7c84825a0a1b3fe57d7380842 — Original deb8: 131 passed/1 failed. Personal observation failure resolved by 22b7 selected cases (6 passed/44 skipped, 67.978s); full personal suite now passes 50/50 at b6. Original four-file run remains failed. 521.34 / not measured renewal-deb8cf38/evidence/results/runtime/runtime-results.json; focused-gateway.log; renewal-22b70997/evidence/results/runtime/runtime-results.json
Full check:changed — earlier failure FAIL 7a695a0f91db5de010a402c9452527b3623a17cc — Original7a run stopped at counted-line cap1002>1000; later steps did not run. The b6 correction passed the line cap, but this original run remains failed. 6.623 / not measured renewal-7a695a0f/evidence/results/changed/runtime-results.json; changed.log
Full check:changed — lint failure FAIL b6e39b6b5f2c4769ee6ec8d232e02c581eed1ff9 — Original b6 run:31 stages passed, then exactly12 worker-test await-thenable errors stopped lint; later stages did not run in that invocation. Reviewed f337 removed those awaits; the accepted cumulative row records the successful continuation without relabeling this failure. 2623.708 / not measured renewal-b6e39b6b/evidence/results/changed/changed.log; runtime-results.json; lint-diagnostics.json
Check:changed — cumulative completion PASS f33795fc32205414b436f84f06dcd5e924255704 — Lead accepted 31 successful prefix stages at b6 plus all11 native suffix stages at f337. Native command environments preserved; core0 errors/19 warnings, extension/script0 errors, cycles0. Production unchanged; neither original failed run is relabeled as passing. suffix elapsed982.658; command sum979.211; b6 prefix stages timed in original log / not measured renewal-b6e39b6b/evidence/results/changed/changed.log; renewal-f33795fc/evidence/results/changed-native/runtime-results.json; runtime-completion.json; native-plan.json
Remaining gates PENDING Not executed — No slice 1 native gate remains pending. Hosted dispatch failure remains unresolved under the lead’s relaxed-v4 focused-pass disposition; both targeted runs pass. Later slices retain their integration gates; slice 7 MUST add named +7/+2 SDK budgets. Update cells apply only to slices 3/7. not measured / not measured working-evidence-deb8cf38/remaining-gates.json; dispatch-case-comparison.json; ratchet-8fd45413/launch.log

CI seconds were not measured. Earlier f0 Gateway verification failed (383 passed/10 failed; 991.429s), leading to requester-abort, pending-recovery and fixture repairs. The deb8 failure and selected 22b7 resolution above retain that history. Executed legacy coverage includes unbranded shared/boundary writer paths at 7a and the repository callback at a7 and the personal writer at b6. The full b6 personal suite executes legacy writer cases with V2 fields stripped; synchronous connection cancel/disconnect fixture shapes were source-inspected. Branded V2 requesters called through old method names are not evidence of legacy behavior. The dedicated SDK fixture is type-only; this evidence does not claim universal writer/callback parity or inherited status-reader compatibility. Full b6 check:changed stopped at twelve await-thenable errors after its preceding type/dead-export stages passed; later checks are now covered by the corrected f337 suffix; the b6 invocation remains failed. Prior7a worker fixture results were Node11/11 in30.596s and Bun11/11 in28.199s; current f337 Node/Bun reruns now pass as listed above. The suffix attempt at f33795fc32205414b436f84f06dcd5e924255704 failed as tooling after 397.502812829s: the external runner dropped native command.env, promoting 19 untouched max-lines warnings to errors. Zero await-thenable errors remained. The corrected runner preserved native plan/environment and all11 suffix steps passed; that tooling failure remains recorded, with no source change. Evidence: renewal-f33795fc/evidence/results/changed/changed.log.

Current Gateway-ready owner proof accepted. Three alternating pairs measured 951a75d4bf578a0843fb5497d1602b838827b4d6 → 4c299f5f656f66b565e51e85e3fc8934925e6940 using approved fixture github-connections-gateway-ready.template.ts (SHA256 062429ca922ac2186fb3caa00ed10bbc5e3b04763db9f8ca6b84e93c56a6b742). All six runs passed 3/3 tests (18/18 total); every native execution succeeded, every SQL median fell, and no duration ratio exceeded 1.5.

Gateway-ready owner RPC All-thread SQL Main-thread SQL Worker requests Median milliseconds Duration ratio
status 45 → 20 45 → 16 0 → 1 305.028559 → 286.777319 0.940165
cancel 10 → 4 10 → 0 0 → 1 7.401827 → 10.478736 1.415696
disconnect 28 → 16 28 → 2 0 → 2 18.850947 → 24.786272 1.314856

Both sides retain the existing profile catalog before fixture creation and outside the measured RPC, matching the real Gateway lifetime. Coverage is connected status, missing-pending cancellation and disconnect through synthetic RPC fixtures; OAuth start/poll/install/refresh/expiry and live GitHub transport are not measured. Earlier standalone/no-catalog latency remains historical evidence for that different fixture. No user duration waiver was approved or is needed for this accepted Gateway-path result.

renewal-7914382e/evidence/results/owner1/comparison.json and completion.json retain every sample and exact measured source. Vitest suite-duration samples are base [57.88, 56.57, 55.55] seconds and candidate [56.14, 56.3, 55.79] seconds; these include fixture/build overhead and differ from the measured RPC milliseconds above. GitHub CI seconds were not measured.

Common-workload applicability accepted. Current edge 951a75d4bf578a0843fb5497d1602b838827b4d6 → 4c299f5f656f66b565e51e85e3fc8934925e6940 adds resident-catalog reuse. The lead accepted resident-role-sql-source-bridge-7914382e.md: the common driver does not invoke the role change, all six retained ledgers/stacks exclude it, and all 45 attribution-source blobs remain unchanged. This is source-based reuse of the accepted historical workload, not a new common execution.

Historical common workload accepted. Three alternating pairs measured 951a75d4bf578a0843fb5497d1602b838827b4d6 → fd8535cdb4dd35d8a82402bf0a5cdf3f345887ab. All common duration windows are valid. Original measured identities, increases and correlation limits remain unchanged.

Common phase Base → candidate SQL median Delta Requests Duration ratio
01.boot 2319 → 2318 -1 59 → 60 1.026321
01.connect 1174 → 1220 +46 50 → 57 1.021577
02.first-turn 2633 → 2577 -56 363 → 353 0.987451
03.warmed-mean 1007.2 → 1011.2 +4 195.6 → 196.1 0.997662
04.second-session 3830 → 3836 +6 660 → 659 1.031979
05.control-plane 33 → 33 0 5 → 5 0.996380
06.cron 1392 → 1369 -23 213 → 209 1.008277
07.compaction 402 → 402 0 83 → 83 0.995662
08.shutdown 195 → 195 0 15 → 15 0.978292

First-turn falls by 56. Warmed mean rises by 4 (+0.3971%) under the noise floor. Its exact median-defining decomposition is (candidate run 1 − base run 1) / 10; raw warmed samples are base [1007.2, 1008.1, 1005.5], candidate [1011.2, 1023.6, 1006.9].

Unchanged operation owner Contribution to warmed +4
Auth profile reads +0.3
Memory database domains +3.5
Native memory lease cleanup +0.2
Plugin compare/delete and entry reads +0.9
Session and pending-input reads −0.7
Other task-worker reads −0.2

All 45 inspected owner/caller files are unchanged. Positive SQL signatures occur in baseline. Native memory lease ROLLBACK totals are 17 in every full workload; the largest positive warmed operation families also retain equal full-workload totals. userGitHubConnections does not execute in warmed samples; userProfiles.githubAttribution.resolve stays at 70 SQL / 10 requests. Operation and independent SQL-multiset accounting both reconcile exactly.

Connect +46 is unchanged device bootstrap +4, cron +11, cleanup/images +22, plugin sweep +6, HTML provenance +3. Adjacent boot+connect sums are base [3469, 3493, 3500], candidate [3508, 3540, 3539]; median 3493 → 3539, +46 (+1.3169%), duration ratio 1.026517. Second-session +6 (+0.1567%) is auth +6, memory −5, session writes −9, session reads +19, other −5. Both pass the lead’s non-turn disposition; other non-turn medians are flat/lower.

Whole-workload SQL samples are base [22030, 22047, 22011], candidate [22012, 22028, 22049]: median 22030 → 22028 (−2). Requests [3404, 3401, 3402] → [3398, 3398, 3401]: median 3402 → 3398 (−4). These are context, not a substitute for phase gates.

Attribution uses source-based operation/caller accounting plus independent SQL multisets. Individual worker-ID/timestamp/stack-to-SQL correlation was not retained; this is not a fully reconstructed event trace. common1-fd8535cd-owner-audit.md and its JSON retain samples, source hashes, conservation and limits.

The compatibility claim covers released writer/callback forms. Inherited status-reader limitations are recorded in the final stack PR; this slice does not establish whole-family reader compatibility.

Published-driver × candidate update cell: not required (v4). Connection/OAuth RPC authority, profile ownership and receipt changes; no update, Doctor, migration/schema DDL, plugin loading, or Gateway service startup/shutdown change. Moved connection table-existence reads preserve the original read behavior. The inherited shared SDK warning helper adds runtime diagnostics, not plugin loading.

@clawsweeper

clawsweeper Bot commented Oct 11, 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.

@github-actions

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

These security sensitive changes were made:

  • src/gateway/github-personal-oauth.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/github-personal-authorization.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: XL labels Oct 11, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR moves personal GitHub connection operations into shared-state workers while retaining released synchronous service adapters.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The migration has clear value, but two unresolved correctness findings and insufficient authority-chain evidence prevent merge readiness.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Personal GitHub connection bookkeeping performs native database work on the Gateway thread.
Reason: The established feature owner chose this internal worker migration, which reuses existing storage and preserves the released service contract.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep this maintainer-owned PR open: the worker migration is useful, but both previously reported correctness findings remain unresolved.

Priority: P2
Reviewed head: 8fd45413281bfb884722a5c89deb8f0c2d1d137a

Before merge

  • Add real behavior proof - Authority-chain proof required: the inspected historical screenshots and synthetic connection comparisons do not show allowed and foreign-profile rejection at OAuth effects, revocation before refresh I/O, or credential preservation after a lost connect result. Provide redacted terminal output or logs through the real production owners covering those cases; redact API keys, IPs, phone numbers, and non-public endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve credentials when the connection commit outcome is unknown (P2) - If the worker commits the connect mutation and then its result is lost or rejected, this awaited commitConfig throws despite the durable selection already pointing at candidate.profileId. installManagedGitHubProfile then removes the published credential directory because this caller does not set retainProfileOnCommitFailure. The connection is left selected but unusable, and pending authorization has already been cleared. Retain the profile through uncertain outcomes and reconcile the committed selection before cleanup; the shared OAuth caller already uses the installer's retention option. This previously reported finding remains unresolved.
  • Revalidate the selected connection before sending the refresh request (P2) - A disconnect or account replacement can commit after beginRefresh commits while its worker response is still returning. After the new await, assertOwned checks only the profile lease, which disconnect does not revoke; refreshGitHubOAuthToken then sends the captured selection.refreshToken for the revoked connection. The later operation-ID check prevents persistence from resurrecting the selection, but cannot undo remote credential rotation. Reread and validate the live owner, generation, selected profile, and refresh operation immediately before the network call. This previously reported finding remains unresolved.
  • Resolve security concern: Connection revocation does not fence refresh I/O - The profile lease protects local credential materialization, while the selected connection authorizes remote rotation; retaining that lease does not establish that the connection remains authorized.

Findings

  • [P2] Preserve credentials when the connection commit outcome is unknown — src/gateway/github-personal-oauth.ts:308-309
  • [P2] Revalidate the selected connection before sending the refresh request — src/gateway/github-personal-oauth.ts:490-495
  • [medium] Connection revocation does not fence refresh I/O — src/gateway/github-personal-oauth.ts:495

Tests

  • Missing end-to-end proof: Provide final-effect evidence for allowed and foreign-profile OAuth operations, revocation during the refresh handoff, and recovery after a committed connect loses its result; the supplied cases do not exercise these failures.
Agent review details

How this fits together

Authenticated Gateway RPCs prepare profile authority, workers read or update private connection records, and the OAuth lifecycle manages GitHub requests and local CLI credentials.

flowchart TD
A[Authenticated Gateway client] --> B[Personal GitHub RPC]
B --> C[Profile authority]
B --> D[OAuth lifecycle]
D --> E[Shared state worker]
E --> F[Private connection records]
D --> G[GitHub and managed credentials]
Loading

Technical review

Best possible solution:

Keep the worker migration, preserve credentials through uncertain connect outcomes, and revalidate the live selection immediately before refresh I/O.

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

Source inspection establishes both introduced failure paths; no target code or tests were executed during this read-only review.

Is this the best way to solve the issue?

Moving these operations to the existing worker owner is appropriate, provided asynchronous failure handling preserves selected credentials and current authority at external effects.

Full review comments:

  • [P2] Preserve credentials when the connection commit outcome is unknown — src/gateway/github-personal-oauth.ts:308-309
    If the worker commits the connect mutation and then its result is lost or rejected, this awaited commitConfig throws despite the durable selection already pointing at candidate.profileId. installManagedGitHubProfile then removes the published credential directory because this caller does not set retainProfileOnCommitFailure. The connection is left selected but unusable, and pending authorization has already been cleared. Retain the profile through uncertain outcomes and reconcile the committed selection before cleanup; the shared OAuth caller already uses the installer's retention option. This previously reported finding remains unresolved.
    Confidence: 0.97
  • [P2] Revalidate the selected connection before sending the refresh request — src/gateway/github-personal-oauth.ts:490-495
    A disconnect or account replacement can commit after beginRefresh commits while its worker response is still returning. After the new await, assertOwned checks only the profile lease, which disconnect does not revoke; refreshGitHubOAuthToken then sends the captured selection.refreshToken for the revoked connection. The later operation-ID check prevents persistence from resurrecting the selection, but cannot undo remote credential rotation. Reread and validate the live owner, generation, selected profile, and refresh operation immediately before the network call. This previously reported finding remains unresolved.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Personal connection ownership and OAuth lifecycle keeps the original intent (4c0588d: The original feature separates personal credentials from shared execution and binds their use to the authenticated durable profile.)
  • Role authority preparation keeps the original intent (c69b8b9: Verified profile roles determine current authority; later profile-reader work retains canonical catalog facts for Gateway consumers.)
  • Released synchronous OAuth methods keeps the original intent (4c0588d: The personal OAuth service exposes immediate cancellation and disconnect results; this PR retains those methods and adds explicitly named async replacements.)

Testing

Proof path: in-process harness.

Security

Needs attention: The refresh handoff can perform credential-bearing I/O after connection revocation.

Evidence

Security concerns:

  • [medium] Connection revocation does not fence refresh I/O — src/gateway/github-personal-oauth.ts:495
    The profile lease protects local credential materialization, while the selected connection authorizes remote rotation; retaining that lease does not establish that the connection remains authorized.
    Confidence: 0.96

What I checked:

PR surface

Source +658, Tests +90, Docs +2, Other 0. Total +750 across 31 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 18 1146 488 +658
Tests 10 149 59 +90
Docs 1 15 13 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 2 2 2 0
Total 31 1312 562 +750

Labels

Label changes:

  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Label justifications:

  • P2: This focused internal migration has two actionable failure-path defects without evidence of an urgent deployed regression.
  • merge-risk: 🚨 compatibility: The service gains async cancel and disconnect methods; the maintainer-authored direction preserves the released synchronous results and documents their deprecation window.
  • merge-risk: 🚨 auth-provider: An uncertain connect result can leave a selected GitHub connection without its managed credentials.
  • merge-risk: 🚨 security-boundary: The new refresh await permits connection revocation before a credential-bearing network request without a final selection check.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-11T06:57:02.630Z sha 59d6ed2 :: needs real behavior proof before merge. :: [P2] Preserve credentials when the connection commit outcome is unknown | [P2] Revalidate the selected connection before sending the refresh request
  • reviewed 2026-10-11T08:01:24.076Z sha 5e6d603 :: needs real behavior proof before merge. :: [P2] Preserve credentials when the connection commit outcome is unknown | [P2] Revalidate the selected connection before sending the refresh request

Reviewed October 11, 2026, 4:33 AM ET / 08:33 UTC (Revision 3).

@clawsweeper clawsweeper Bot added the proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. label Oct 11, 2026
@steipete
steipete merged commit bc1d2b9 into main Oct 11, 2026
141 of 144 checks passed
@steipete
steipete deleted the dbasync/sw7d-connections branch October 11, 2026 08:38
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…claw#168948)

* refactor(plugin-sdk): share legacy persistence warning budgets

* refactor(github): move personal connection authority to workers

* fix(github): propagate reviewed connection authority repairs

Preserve existing branch history while carrying reviewed S7 repairs.

* fix(github): propagate reviewed connections compatibility and gate repairs

Preserve existing branch history and stage-specific ownership contracts.

* fix(github): propagate reviewed connections gate repairs

Preserve branch history and carry reviewed API, fixture, and static-gate repairs at their owning slice.

* perf(github): reuse the state worker for role authority

* perf(github): reuse state worker for connection reads

* perf(github): reuse resident role authority

* test(github): align authorization mock with worker policy

* test(github): repair integrated connection fixtures

* chore(test): prune explained GitHub mock baseline
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 18, 2026
First-parent upstream c96fac1..d9eba8a (10 PRs: openclaw#168948 GitHub
connection authority to workers, openclaw#168975, openclaw#168772 cron receipt custody
removal, openclaw#169012, openclaw#169006, openclaw#169009, openclaw#168283 test batch d042, openclaw#168994,
openclaw#168964, openclaw#168855 approval/placement state in workers).

Conflicts:
- docs/reference/database-schemas/worker-access-inventory.md: took
  upstream, then regenerated (db:worker-inventory:gen, 633 files / 2449
  calls) instead of hand-merging.
- src/agents/embedded-agent-runner/compact-reasons.test.ts: upstream
  openclaw#168283 deleted low-value cases; kept upstream's file plus our own
  additions only (unknown_model, empty reason, closed-union check and the
  isCompactionSkipCode block).

session-reset-service.ts auto-merged: upstream's awaited placement
retirement (assertCurrent) is disjoint from our continuation-cancellation
cleanup reason.

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime 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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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