Skip to content

fix(automations): honor selected accounts without a credential store - #190956

Merged
vincentkoc merged 6 commits into
mainfrom
fix/cron-configured-account-selection-20261102
Nov 2, 2026
Merged

vincentkoc merged 6 commits into
mainfrom
fix/cron-configured-account-selection-20261102

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

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.ts file. 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.

  • Gateway/CLI boundary proof: all four cases in src/gateway/server.chat-cli-auth.test.ts passed 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.
  • Runner proof: 40/40 auth-profile propagation tests passed on Bun, including carried-session defaults, native adoption, captured-account ownership, non-native runtime rejection and stronger session pins.
  • Shared resolver proof: 22/22 resolver and 14/14 user-link tests passed on Bun. Coverage distinguishes explicit/native/automatic provenance, personal/shared pins and provider compatibility.
  • Baseline reproduction: the missing payload-selected account incorrectly returned ok; the unpinned control passed. Two default/session failures in that run used mismatched fixture keys and are excluded from baseline proof.
  • Signed commit, normal hooks, targeted formatting and diff checks passed. Fresh independent autoreview of production and fixture corrections found no actionable P0-P2 findings.

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 parent 0267ad034a06799d11267dcd21aff5bc63ce76c3 and tested merge 774af19050e8ec733bf69b0b20182ba89eb421d0; 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.

@vincentkoc vincentkoc self-assigned this Nov 2, 2026
@clawsweeper

clawsweeper Bot commented Nov 2, 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.

@vincentkoc
vincentkoc marked this pull request as ready for review November 2, 2026 07:32
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 2, 2026
@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

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

  • Before: The hook can launch Claude using ambient native authentication.
  • After: The hook returns HTTP 502 before CLI launch or provider requests.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused repair with credible final-effect boundary evidence, preserved existing-state behavior, and no actionable findings; no persisted format or migration changes.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): At the exact head, the real Gateway HTTP hook path exercises account resolution, executable launch, FD3 credential transport and loopback provider requests: unavailable payload/default selections and a removed stored pin produce no launch or request, while native and stronger stored-pin controls use the expected credential; the external CLI and provider are synthetic, and raw logs were inaccessible through the review network.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A hook can run under ambient native credentials despite an unavailable explicit account selection, or let a native default outrank a stronger session pin.
Reason: Restores the established account-selection contract; the maintainer-authored direction explicitly accepts rejecting unavailable selected accounts while preserving valid native login.

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
Reviewed head: 149d10a3d853b89879ec70532efc73df5b282fa5

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The default-selection red-on-base replay remains unproven; the baseline payload failure and current-head default rejection are documented separately.
Agent review details

How this fits together

Gateway 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]
Loading

Technical review

Best 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

  • Cron account-selection shortcuts changes intended behavior with a stated reason (fix(automations): allow explicit native CLI account adoption #190904: Native login belongs to the CLI runtime, while ordinary stored-account resolution and session-pin precedence belong to the shared resolver.)
  • Empty-store optimization keeps the original intent (061a9b5: Avoid empty profile-store loads; later auth-reader work preserved source classification and credential precedence.)
  • Session account precedence keeps the original intent (e4e2305: Preserve existing session pins, capture personal defaults at creation, and avoid loading an overridden personal credential.)
  • Session persistence test fixture keeps the original intent (refactor: flip sessions and transcripts to sqlite storage #98236: SQLite accessors own canonical session persistence; the orchestration stand-in must apply their partial-patch and complete-row replacement contracts.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit a24c7aa adds src/agents/auth-profiles/session-override.ts:4 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a24c7aaffeef; files: src/agents/auth-profiles/session-override.ts)
  • Peter Steinberger: Raw commit 061a9b5 adds src/agents/auth-profiles/session-override.ts:75 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 061a9b5c5839; files: src/agents/auth-profiles/session-override.ts)
  • scoootscooob: Raw commit e4e2305 adds src/agents/auth-profiles/session-override.ts:563 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: e4e230510c15; files: src/agents/auth-profiles/session-override.ts)

PR surface

Source -9, Tests +307, Other +2. Total +300 across 9 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 26 35 -9
Tests 6 405 98 +307
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 9 433 133 +300

Review metrics

Metric Value Why it matters
Production versus test/support LOC Production +26/-35; tests/support +405/-98 Production removes duplicate selection policy; test growth exercises process-level credential routing and repairs the existing session-patch fixture contract.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #190951
Summary: This PR addresses the canonical hook account-isolation report; native-account adoption and recovery wording are related but distinct work.

Members:

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: Repairs a concrete hook account-routing defect with a bounded trigger; no widespread current outage is established.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (3 earlier review cycles)
  • reviewed 2026-11-02T07:49:09.634Z sha 61677f4 :: needs changes before merge. :: [P2] Align the persistent fixture's run key with its session target
  • reviewed 2026-11-02T12:06:32.636Z sha 890d10f :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-02T13:07:16.496Z sha 149d10a :: needs maintainer review before merge. :: none

Reviewed November 2, 2026, 8:14 AM ET / 13:14 UTC (Revision 4).

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M and removed size: S labels Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 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: 149d10a3d853b89879ec70532efc73df5b282fa5
  • Maintainer: @vincentkoc
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/session-override.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review head 1975ecffdfc09639a79a68001bd56b760533111c. The persistent fixture now uses matching session target/run keys, and the production repair removes the no-store bypass through the shared account resolver while preserving native-login defaults and stronger session pins. Independent source review is clean. Candidate CI has passed 45 shared-resolver tests, type checks, and the boundary check; the cron runner and remaining jobs are still running. The PR body separates the real baseline failure, fixture failures, executed proof, and remaining gaps.

@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 2, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 2, 2026
@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 2, 2026
@vincentkoc
vincentkoc enabled auto-merge (squash) November 2, 2026 13:11
@vincentkoc
vincentkoc disabled auto-merge November 2, 2026 13:34
@vincentkoc
vincentkoc merged commit f4619fd into main Nov 2, 2026
176 of 179 checks passed
@vincentkoc
vincentkoc deleted the fix/cron-configured-account-selection-20261102 branch November 2, 2026 13:42
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
…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
NEXTAltair added a commit to NEXTAltair/openclaw that referenced this pull request Nov 10, 2026
目的: 会話のアーカイブと自動化ジョブの有効状態を分離し、実行セッションの復元処理と関連説明・テストを更新する。
理由: アーカイブ操作で予定実行が意図せず停止せず、ジョブの有効化を明示操作に限定するため。

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 を足した
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: L 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.

Bug: hook runs can ignore selected accounts without a credential store

1 participant