Repository navigation
fix(automations): honor selected accounts without a credential store - #190956
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR routes automation account selection through the shared resolver while preserving native login and stronger session pins. Example: A hook selects anthropic/claude-sonnet-4-6@anthropic:missing with no credential store and an available native Claude login.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR repairs account-selection enforcement still missing on main, with no actionable findings; broader CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway hooks enter the isolated automation runner, which resolves model and account preferences before CLI preparation forwards a stored credential or uses native login. flowchart LR
A[HTTP agent hook] --> B[Automation preparation]
B --> C[Shared account resolver]
D[Session pins and agent defaults] --> C
E[Runtime native login policy] --> C
C --> F[CLI credential preparation]
F --> G[Provider request]
Technical reviewBest possible solution: Use the shared resolver as the sole account-precedence owner, with native identities supplied by the prepared runtime. Do we have a high-confidence way to reproduce the issue? Current main visibly skips account resolution when no store or configured auth metadata exists; supplied baseline evidence shows an unavailable payload-selected account incorrectly succeeding. Is this the best way to solve the issue? The patch repairs the owning decision by removing both caller shortcuts and preserving native identities inside shared precedence, without adding runtime state or configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 75be4d0f9332. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -9, Tests +307, Other +2. Total +300 across 9 files. Added test files: 1. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed November 2, 2026, 8:14 AM ET / 13:14 UTC (Revision 4). |
|
|
@clawsweeper re-review Please review head |
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…penclaw#190956) * test(automations): reproduce skipped hook account selection * fix(automations): validate selected accounts without a credential store * test(automations): assert preparation account rejection * fix(automations): preserve session account precedence through CLI admission * test(automations): preserve canonical session patch semantics in fixtures * test(automations): exercise hook defaults through native session creation
目的: 会話のアーカイブと自動化ジョブの有効状態を分離し、実行セッションの復元処理と関連説明・テストを更新する。 理由: アーカイブ操作で予定実行が意図せず停止せず、ジョブの有効化を明示操作に限定するため。 rebase 時のコンフリクト解決 (onto 57fd13e, 元コミット 4e34d417156): - cron/isolated-agent/session.ts: 上流 7f4cbc1 (openclaw#180563) が canRollArchivedHeartbeat (アーカイブ済み heartbeat 行の差し替え) を削除し、 上流 f31b33f が hasSessionAutoModelFallbackProvenance の import を外した。 上流の形を基に、restoreArchived 時だけアーカイブ由来の block を通す分岐を再適用 - cron/isolated-agent/session.test.ts: 上流が追加した inferenceCaptured と 本コミットの restoreArchived を併記。上流が削除したテストのコメントは破棄 - cron/job-session-bindings.test.ts: 上流が describe を外して書き直した版を基に、 本コミットで削除した disableCronJobsBoundToSessions のテストとヘルパーを除外 - sessions-mutations.perf.test.ts / sessions-patch-diagnostics.test.ts: 本コミットが書き換えていた cron 無効化と cronEffects の検証は、上流の low-value テスト整理で削除済みのため上流版を採用 - cron / sessions 関連テスト 5 ファイルの通過を確認 rebase 時のコンフリクト解決 (onto 258d034, 元コミット 994faecc5f8): - cron/job-session-bindings.ts: 上流 f9135d2 が binding を物理会話キーと agent の Map (resolveCronJobSessionBindings) に作り替え、disableCronJobsBoundToSessions も 複数セッション対応へ書き直していた。本コミットの方針どおり無効化関数は削除し、 上流の binding 解決は残した。上流側に他の呼び出し元は無い - cron/job-session-bindings.test.ts: 上流のリネーム後の import を使い、 無効化関数のテストとヘルパーは除外。上流が追加した global scope の binding テストは残した - docs/automation/cron-jobs/managing-jobs.md: 上流が追加した global scope の段落と 「main session はアーカイブできない」一文を残し、アーカイブ段落は本コミットの文言 - cron/isolated-agent.auth-profile-propagation.test.ts: 上流 f4619fd (openclaw#190956) が追加した cronSession fixture に、本コミットで必須にした restoresArchivedSession が無く型チェックが失敗したため false を足した
Fixes #190951
What Problem This Solves
Hook-triggered agent runs could ignore an explicitly selected account when no credential-store source existed and continue with ambient native CLI authentication. A separate native-account shortcut could also override a stronger session account pin.
User Impact
Unavailable selected accounts stop before CLI launch. Native login remains supported, explicit session pins win over agent defaults, and removing a pinned stored account does not silently switch that session to native login. Provider identities, global defaults, configuration keys, and public APIs are unchanged.
Why This Change Was Made
Cron now always uses the shared account resolver. The prepared runtime supplies its core-owned native-login identities; the resolver applies session-pin/configured/automatic precedence and recognizes valid native pins before stored-credential lookup. This removes both cron shortcuts and avoids false missing-account warnings for valid native pins. Callers without the trusted native identity list retain their existing behavior.
Production net -9 lines. Tests/support net +307 lines. The test-line allocation is 348 because the ratchet counts the extracted session-store helper but excludes the shrinking
.test-harness.tsfile. The shared baseline is unchanged. The in-memory accessor now applies the production partial-patch contract and preserves intentional field removal when committing a projected row.Evidence
Current head:
149d10a3d853b89879ec70532efc73df5b282fa5.src/gateway/server.chat-cli-auth.test.tspassed on Bun, including the new hook account-isolation case. The encompassing group passed 10/10 tests. The fixture uses real HTTP hook ingress, account selection, executable launch, FD3 credential transport, persistence and removal. Only the external Claude executable and provider are synthetic.ok; the unpinned control passed. Two default/session failures in that run used mismatched fixture keys and are excluded from baseline proof.CI-derived boundary verdict (the individual effects are asserted in the passing hook case):
{ "head": "149d10a3d853b89879ec70532efc73df5b282fa5", "runId": 41448063924, "jobId": 125287641170, "result": "pass", "unavailablePayload": { "httpStatus": 502, "cliLaunches": 0, "providerRequests": 0 }, "unavailableFreshSessionDefault": { "httpStatus": 502, "cliLaunches": 0, "providerRequests": 0 }, "unpinnedAndNativeDefault": "native credential observed at loopback provider", "explicitNativeSessionPin": "native credential observed despite stored credential availability", "strongerStoredSessionPin": "stored credential observed over native default and unavailable payload selection", "removedStoredPin": { "httpStatus": 502, "cliLaunches": 0, "providerRequests": 0 } }This addresses the previous review's final-effect proof, security attention and Rank-up move. Removal is verified after deleting the account from both exact owner stores and confirming its absence; no new mid-flight revocation guarantee is claimed. Existing Anthropic CLI tests separately cover authority revalidation after initialization.
Remaining Proof and Limits
The broader current-head CI run completed with the unrelated PostgreSQL failure described below. The default-selection red-on-base replay remains unproven; current-head payload/default behavior and the baseline payload failure are established. Local dependencies are unqualified. Two Blacksmith Testbox attempts queued and were stopped without payload execution; their native cleanup is reconciled. PR CI supplies the execution evidence above.
The loopback fixture proves credential routing and side effects, not live Claude cloud authentication or production Telegram delivery. Cold-import performance parity has not been measured. The existing runner/Gateway files exceed the 30-second guideline because they exercise persistence and process lifecycle; this change reuses their fixtures.
Related: #190904
Separate follow-up: #191110 tracks misleading native-login advice for an unavailable selected stored account.
Completed CI and unrelated failure attribution
Run 41448063924 completed with the 80 focused account tests passing. The full run remains failed: PostgreSQL conformance 3/3 failed the global namespace comparison at
update-cohort-restore.postgres.test.ts:278; the aggregate gate follows it. The automatic table calls this new because the matching scheduled-main job passed, without comparing selected scope.Independent source/log inspection attributes this to the existing test-isolation defect: the test compares every
restore_%schema while parallel test processes share that database. A third, unowned namespace disappeared during the awaited refusal. The restore owner drops only its newly allocated failed-attempt namespace. The exact process that owned the vanished UUID is not logged. All 15 inspected failure inputs/manifests are byte-identical between CI main parent0267ad034a06799d11267dcd21aff5bc63ce76c3and tested merge774af19050e8ec733bf69b0b20182ba89eb421d0; the merge tree was independently reconstructed from that parent and this exact head.The separate owner already repairs and records deterministic reproduction of this defect in #191075. No duplicate repair, CI rerun, timeout increase, or assertion weakening is included here. Landing uses the supported attributed-unrelated-failure route and preserves the failed CI result.