Repository navigation
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. |
|
Thanks for the contribution. ClawSweeper is trimming this lowest-signal PR because the author is over the repository's open-PR budget. @LiuwqGit currently has 17 open PRs in this repository, above the budget of 15. ClawSweeper is closing this PR as one of the author's lowest-signal submissions under that budget: its overall rating is C and its real behavior proof is insufficient. Closing or finishing other PRs frees review budget, and this PR can be reopened once the author is under budget or when real proof is added. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Closing or finishing other open PRs frees review budget. This PR can be reopened once the author is under budget, or sooner when real behavior proof is added. Review detailsBest possible solution: Close this lowest-signal PR for now. Finish or close other open PRs to free review budget, then reopen this PR once the author is under budget; adding real behavior proof also makes it eligible for reconsideration. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the missing sessionTarget binding, and supplied before/after Gateway logs demonstrate admission failure and successful target-specific execution; this review ran no reproduction. Is this the best way to solve the issue? The single Gateway binding is the smallest coherent inference fix and avoids reinterpreting stored jobs, while explicit-agent rejection remains a valid owner-selected alternative. Security review: Security review needs attention: No concrete authorization bypass was found, but the supplied abort trace does not establish revocation after cron authority capture. AGENTS.md: found and applied where relevant. What I checked:
Codex review notes: model internal, reasoning medium; reviewed against 70e2761fccfc. |
46588c2 to
176dc7e
Compare
|
Reworked the patch and replaced the in-process probe with a real Gateway run. Head is now 1. Real behavior proof (create → due turn). A real Not covered by the live run, stated plainly in the body: the provider is synthetic, so two agents with separate stored credentials were not exercised against a live provider, and creator-grant revocation mid-create was not replayed against the live gateway. 2. P1 — resolve the agent before declaration scope matching. Fixed at the root: the binding moved out of 3. P1 — select the execution agent before capturing inference. 4. P2 — unsupported management-create exception. Removed, together with the 5. Cross-agent authority at the final effect. The unauthorized-caller leg now runs through the supported admission boundary instead of a fabricated capability: 6. Merge risk (credential / stale creator authority carried into the provider call). The mechanism that could carry it is gone: inference capture no longer resolves a different agent from the one that executes, because both read the same value bound once at admission. 7. Maintainer decision. This PR implements the review's recommended option 1 — infer the execution agent from a qualified session target at Gateway admission, before all execution preparation, while retaining existing agent-runtime creation restrictions. If the owner prefers option 2 (reject a contradictory agent/session combination and keep today's defaults), that is a small change to the same single call site: replace the binding with a refusal naming both agents and 8. Data-model compatibility. Added: a row written by an older build (no Test-quality items. The fabricated RED/GREEN on the final base. Against Diff is now 8 files, +369/−6; the four source files account for +57/−3 ( @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
A cron job created without --agent but with sessionTarget "session:agent:<other>:..." was bound to the creating caller's agent (or left to the configured default), while the due run resolves its session from sessionTarget. With per-agent SQLite session stores the run then failed in ~0.1s with "SQLite session store path belongs to agent main; requested agent worker." and a one-shot job was disabled as a permanent error. Name the execution agent once at cron.add admission, before caller scope matching, creator session and inference capture, declaration matching, and persistence each read it, so a job is never prepared for one agent and stored for another. An explicit --agent still wins, detached targets still fall back to the caller or configured default, and an agent turn still cannot create a job that another agent would execute. The CLI warning stops promising the configured default agent when the job's own session names one. Fixes openclaw#190123
- keep the `// SAFETY:` comment on the line directly above the `candidate as CronJobCreate` assertion in cron.add; the ratchet only recognises a standalone SAFETY comment on the preceding line, and the explanatory comment inserted between them made the existing exemption invisible (checks-fast-baseline-ratchets). - pin the malformed-session-target loop in cron-caller-scope.test.ts to a const tuple so the literals keep their `CronSessionTarget` types instead of widening to `string` (check-test-types-core-2, TS2322). No behaviour change.
176dc7e to
c9b5ca8
Compare
|
Two follow-ups on this head: the two CI failures were mine and are fixed, and the account leg the security note asked for is now proven against a real gateway. 1. CI — both failures were introduced by this PR, both fixed in
|
|
🦞👀 Re-review progress:
|
`automations add` now names the execution agent from the job's own agent-qualified session reference before falling back to the configured default, but the CLI guide still documented explicit `--agent`, then `--session-key`, then default. Users scheduling into another agent's conversation were given the wrong account-selection contract. Spell out the create-time precedence, the warning it produces, and that detached targets still fall through to the default — separately from stored-job ownership, which resolves as before and is never reinterpreted.
The declaration-matcher case asserted a pure-function outcome that cannot detect admission forgetting to call the binder, and the caller-restriction case re-asserted both scope outcomes that the admission-boundary regression already drives through `handleGatewayRequest` + a real `CronService`. Repeated-declaration convergence and the foreign-agent refusal are covered there. Kept, narrowed to what nothing else pins: the creating caller stays the recorded `owner` while execution routing follows the session's agent. The explicit-agent, legacy-session-key and malformed-target contracts are unchanged — a malformed `session:` target is rejected by normalization before it can reach admission, so that catch is only reachable here.
|
Follow-up round on P3 documentation finding — create-time ownership precedence.
The Low-value test note — removed the two duplicated helper cases, kept the one contract nothing else pins.
Verification on this head: Still open, and not mine to close: the owner decision on target-derived creation binding (this PR implements the review's recommended option 1; option 2 is a small change at the same single call site), the revoked/reassigned-authority final-effect leg (needs a live model turn holding cron management authority — not reachable from the shipped CLI, so it stays on the admission-boundary regressions and is stated in the body), and a v2026.10.9 upgrade against a store with real schedules and run history (this environment has no npm-installed gateway I can safely upgrade; the legacy-row fixture proves read-without-rewrite only for that fixture, as the body says). @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Third round on Upgrade leg — store seeded by the pre-change build, carried over to this oneA gateway running Settings, schedules, ownership and run history all survived the swap, and the upgraded build kept executing the stored schedules under each job's own account. Nothing was restamped: both jobs were created with an explicit Limits of this leg, stated plainly: the store was seeded minutes before the swap by a gateway built from CI on this headBoth failures this revision started from are green, and so is the aggregate: What is still open, and why it is not mine to close
Body updated with the upgrade leg, its limits, and the current CI state. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Round four on Upgrade from the npm-released
|
|
🦞👀 Re-review progress:
|
|
Round five on SetupReal gateway from this branch's source, isolated state dir, two agents owning separate provider credentials ( Case A — allowed: the turn creates a job for its own agent's sessionThe due run fired after the creating turn had completed normally — a normally completed creator turn keeps its legitimately captured persistent authority, and that authority reaches the provider. That is the exact distinction the review drew ("normal creator-turn completion must not be treated as revocation"), shown positively. Case B — nearest-forbidden: the same turn targets worker's sessionThe create reached the production Case C — revoked mid-create: the identical allowed create, aborted while in flightThe same create shape that persisted in Case A, with the creator authority revoked while the create was in flight (tool call recorded at :32.791, abort processed at :32.985, no tool result ever recorded): nothing persisted and no provider request was issued for the job. The transcript shows the tool call was dispatched and never returned — the revocation landed inside the create, before commit. Still not replayed live, stated plainly
The PR body's Evidence section now carries this round (three cases, one gateway run, timestamps and log lines as above), and the "What was not tested" / "Proof limitations" entries were updated to say the agent-turn create leg, the foreign-agent rejection at provider I/O, and mid-create revocation are now replayed live — reassigned and queued-execution revocation are the honest remainder. The maintainer decision on target-derived creation binding is unchanged and still the owner's call; this PR implements the review's recommended option 1. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Closes #190123
What Problem This Solves
conversation with
openclaw cron add --session session:agent:<other>:…and no--agentgot a jobthat could never run. The create was admitted for one agent while the job's own session belonged
to another, so the due run failed in milliseconds (
cron job agent is unavailable: worker, or onthe reporter's install
SQLite session store path belongs to agent main; requested agent worker.)and the one-shot (
at) job was then auto-disabled as a permanent error: the payload never ran andnothing told the creator why. On today's
mainthe same command in a two-agent roster does noteven reach that point — it is refused with
invalid cron.add params: Multiple agents are configured, but this operation has no explicit owner.Either way the scheduled work is silentlylost.
No --agent specified; the job will run with the configured default agent.for a job whose session already named one.fix(cron): bind a caller-less job to its session target's agent #190156 (earlier attempt at this report, withdrawn by its author before merge — it changed the
global owner-resolution precedence and left the due-run leg on
job.agentIduntouched). This PRtakes the narrower route: name the execution agent once at
cron.addadmission, and leave globalattribution precedence alone. Fix signal labels:
clawsweeper:queueable-fix,clawsweeper:fix-shape-clear,clawsweeper:source-repro.Why This Change Was Made
cron.addadmission step reads it,so caller-scope matching, creator-session and inference capture, declaration matching, and the
persisted row all agree on the same owner.
bindCronCreateExecutionAgent(
src/gateway/server-methods/cron-caller-scope.ts) resolves it — an explicitagentIdwins,otherwise the job's own session reference decides (
sessionTargetsession:<key>first, the sameprecedence the run uses through
resolveCronSessionTargetSessionKey, then the legacy scopedsessionKey) — andcronAddHandlerapplies it to the request before it builds anything else.That one resolved
jobCreatethen flows unchanged intocronCreateMatchesCallerScope,captureCronCreatorSession, thematchesExistingdeclaration matcher, andcontext.cron.add.CronService.add.That happened after two gateway consumers had already read the unresolved input, leaving two
real inconsistencies (both raised in review):
cronAddHandlerhandedmatchesExistingthe unresolvedjobCreate, socronJobMatchesDeclarationScopecompared the configured default (main) against the storedowner (
worker) and excluded the row it should have converged onto — repeating a declarationwould have created a second job instead of preserving the first one's id and history;
captureCronCreatorSessionran before that binding, so it loaded the execution session andcaptured inference for the configured default agent while the job was stored for another.
src/cron/service/ops-mutations.tsis therefore back tomain: the service no longer re-resolvesownership, and there is exactly one binding point.
manageAllexception incronCreateMatchesCallerScope. Itwas unreachable —
CRON_MANAGEMENT_METHODS(src/gateway/cron-creator-authority-grant.ts) listscron.list/get/update/run/remove/bindand excludescron.add,mintCronCreatorAuthorityGrantthrows for a management method outside that list,
getCronManagementAuthorityonly returns insidea redeemed method-bound management context, and the one other caller (
cron.update) passes acreatorScopebuilt withmanageAll: undefined. Its test fabricated the capability withvi.fn()instead of reaching it through admission. Creation authority is unchanged frommain:an agent turn still cannot create a job that another agent would execute, and a scoped caller
targeting a foreign session is refused exactly as before (
cronPatchSessionRefsMatchCalleralreadyrefused it on
main).tryResolveCronJobEffectiveAgentId's precedence (explicit id →scoped
sessionKey→ configured default), so visibility, scheduling, run receipts, and the Doctorheartbeat cutover keep their existing attribution semantics; already-stored jobs are never
reinterpreted or migrated. Detached targets (
isolated/current/main) name no agent andstill fall back to the caller scope or configured default, and a malformed
session:target namesno owner instead of throwing out of a pure resolver.
the SQLite scope check, or existing stored jobs; no config surface added; no other create path
(plugin
service-cron,templates-add) is re-pointed; no refactor of the caller-scope module.cron.addadmission — a job that used to be stored without anagentIdnowstores the session's agent, which is visible to declaration convergence, agent-filtered listings,
and inference capture.
agentIdandits own session reference names one, and every consumer downstream reads that same value.
Regression tests run through the real admission boundary (
handleGatewayRequest+cronHandlers["cron.add"]+ a realCronServiceon an on-disk store) and cover the persistedowner, repeated-declaration convergence, agent-filtered listing, both caller-scope outcomes, an
ownerless row stored by an older build, the declaration matcher's input contract, and the CLI
warning.
User Impact
openclaw cron add --name probe --at <t> --session session:agent:worker:dashboard:<uuid> --message ping(no--agent) warnsNo --agent specified; the job will run with agent worker, named by its session., stores the jobwith
agentId: "worker", reportsworkerincron list, and the due run really executes a turnin
agent:worker:dashboard:<uuid>underagentId=workerinstead of dying againstmain. Anidentical repeated
--declaration-keyconverges onto the same job id. An agent turn still cannotcreate a job for another agent, and a job stored by an older build still loads and lists unchanged.
src/gateway/server-methods/cron-caller-scope.ts(
bindCronCreateExecutionAgent, plus the revertedcronCreateMatchesCallerScope/applyCronCreateCallerScopeDefault),src/gateway/server-methods/cron-add.ts(the single bindingpoint),
src/cron/agent-id.ts(resolveCronJobSessionRefAgentId),src/cli/cron-cli/register.cron-add.ts(warning text), and the regressions insrc/gateway/server-methods/cron.gateway-policy.integration.test.ts(Gateway automation execution agent),src/gateway/server-cron.session-target.test.ts,src/gateway/server-methods/cron-caller-scope.test.ts(create-time execution agent), andsrc/cli/cron-cli.test.ts. Alsodocs/cli/cron.md: the create-time precedence this introduces(explicit
--agent→ the job's own agent-qualified session reference → configured default) is nowdocumented separately from stored-job ownership, which is unchanged.
Evidence
openclaw gatewayprocess and the realopenclawCLI,both run from this branch's source (
node --import ./scripts/tsx.mjs src/entry.ts …, self-reportedOpenClaw 2026.10.9), against an isolated state dir with per-agent SQLite session stores(
session.store: "<state>/sessions/{agentId}.sqlite"), token auth, and a localOpenAI-compatible endpoint on
127.0.0.1standing in for the model provider so a due turn cancomplete offline. Worktree
aispace/worktrees/issue-190123, headc9b5ca8e25d, baseorigin/main36ddf502c84, Node v26.12.1. The before legs restoreorigin/maincopies of thefour touched source files and re-run the identical commands against an identically configured
gateway.
second isolated state dir whose two agents own separate provider credentials —
mainresolveslocalmain/proof-model-main(key tail1111),workerresolveslocalworker/proof-model-worker(key tail
2222), both served by one local endpoint that logs theAuthorizationheader itreceives. This is the leg that shows target-derived agent selection picking the account, at the
last observable effect (the provider HTTP call), rather than only in the stored row.
(head
acd435275ff): the same two-account gateway was reconfigured withtools.gatewayPolicy.automations.scope: "caller"so a model turn — not the operator CLI — isthe automation caller, and the drives below replay the authority chain end to end through a real
openclaw agentturn (real gateway process, real signed agent-runtime identity, productioncron.addadmission), with the synthetic endpoint logging which account served every request.Three cases, one gateway run, head
acd435275ff(this head; the touched source files areunchanged since the traces above):
A — an agent-turn create for the turn's own session persists with
agentId: mainand its duerun (after the creating turn completed normally) is served by
main's credentials — a normallycompleted creator turn keeps its captured persistent authority, and that authority reaches the
provider. B — the same agent-turn caller naming another agent's session is rejected at the
production
cron.addadmission (job agentId outside caller scope), nothing persists, andworker's provider account is never touched (zerokeyTail=2222requests for the whole run; theonly session store ever opened is
main.sqlite). C — the identical allowed create with thecreator authority revoked mid-flight (turn aborted while the create was in progress: the tool
call is recorded at :32.791, the abort lands at :32.985, no tool result is ever recorded)
persists nothing and issues no provider request for the job.
redacted):
--agentis stored withagentId: "worker"; the CLI namesworkerinstead of promising the configured default; anidentical repeated declaration converges onto the same job id (
created: false, updated: true)rather than adding a second job; and the due run completes a real agent turn under
agentId=workerinagent:worker:dashboard:<uuid>— it reaches the model provider, and the onlysession store created is
worker.sqlite, so neither the store-scope guard nor theagent-availability guard that killed the run on
mainfires. An agent-turn caller is stillrefused a job another agent would execute (
job agentId outside caller scope), and a job storedby an older build with no owner still loads, is served by
cron.get/cron.list, and is notrewritten.
--agent, one per agent'ssession, on the two-account gateway (head
c9b5ca8e25d; token redacted):worker-session job created with no
--agentreached the provider underworker-account/proof-model-worker, the main-session job undermain-account/proof-model-main. Selection isper target, not sticky — two jobs created seconds apart in the same gateway bound two different
accounts, both runs completed, both one-shots were deleted after running, and neither the
agent-availability guard nor the session-store scope guard fired.
origin/mainsources with the same two-account config:origin/main, same config shape,same state layout.
Two-agent roster — the create never lands, so the work is lost at admission:
mainonly, so a default resolves and the create is admitted) — thereporter's failure leg, including the auto-disable:
effectiveAgentId: "main") contradicts the job's own session(
agent:worker:…), the run dies in 17 ms, and the one-shot is disabled — the reported outcome.The new regression tests fail on those same
origin/mainsources:acd435275ff, real store seeded by the pre-change build): agateway running
origin/maincopies of the four touched files created two recurring jobs on thetwo-account config and ran them for real; the gateway was then stopped and restarted on this
branch's sources against the same state dir — no migration step, no store edit, no re-create:
executing the stored schedules under each job's own account. No job was restamped: both were
created with an explicit
--agent, and both kept exactly thatagentId.acd435275ff): the store above was seededby a source build, so the leg was repeated against the npm-released package —
[email protected]fetched from the registry tarball (
openclaw-2026.10.9.tgz, 103 MB,dist/+ production depsinstalled), self-reporting
OpenClaw 2026.10.9 (8b18b55). Its gateway created and ran tworecurring jobs on the two-account config; the gateway was then stopped and this branch's sources
were started against the same state dir — no migration, no store edit, no re-create:
entry survived the released→branch handover, and the branch build kept executing those stored
schedules under each job's own provider account. The per-run
provider/modelfields above arethe gateway's own recorded attribution for this leg (the endpoint-side log for this run was lost to
a port conflict with a leftover process from an aborted first attempt, so it is not cited).
source was run directly), and no real model provider was called — a local OpenAI-compatible
endpoint returned a canned streaming completion. Provider-side behaviour that only a live
commercial provider has (profile availability, authorization identity, recorded-route checks, real
credential validation) was not exercised. The agent-turn create leg, the foreign-agent-caller
rejection at provider I/O, and creator-authority revocation mid-create are now replayed live
against a real gateway (the three cases above, head
acd435275ff); what stays un-replayed isreassigned authority (rotated lifecycle generation — an in-process gateway restart, which
trivially kills in-flight work) and queued-execution revocation (an occurrence waiting for exec
approval whose creator authority is revoked), both of which remain covered by the admission-boundary
and creator-revocation commit-guard tests. Shared-store (
session.storewithout{agentId})multi-agent setups were not exercised. Jobs created before this change were verified to load,
list, stay unrewritten, and keep running: a store seeded by the npm-released
[email protected]package (
8b18b55) — two recurring jobs, real run history, both agent accounts, plus thegateway's own heartbeat job — was carried over to this branch's build unchanged, and a second leg
did the same from a store seeded by
origin/mainsources (both above). Neither store waslong-lived (both were seeded minutes before the handover), and the released package was run from an
extracted tarball with its production deps installed rather than through a system-wide install with
systemd units, so an in-place
npm i -gupgrade path was not exercised.turn, two agents on distinct provider credentials; synthetic model provider. The agent-turn
authority-chain leg is the same tier: real gateway, real
openclaw agentturns, real signedagent-runtime identity, real
cron.addadmission, synthetic provider endpoint.proven at the provider HTTP boundary but not against a live provider's credential validation. The
negative paths (a foreign agent request, or authority revoked mid-create, producing no provider
HTTP request) are replayed live above at the synthetic endpoint — what they show is that no request
reaches the account at all, which a synthetic endpoint observes exactly as a live one would, but a
live provider's own-side records were not consulted. Both upgrade legs reused stores seeded minutes
earlier rather than long-lived production stores.
acd435275ff, after the runs above):docs/cli/cron.mdnow states the create-time precedence and the warning it produces, separately from stored-job
ownership (ClawSweeper's P3 documentation finding). The two helper cases it flagged as duplicated
by the admission regressions are gone — the declaration-matcher case (a pure-function outcome that
cannot detect admission forgetting to call the binder) and the caller-restriction case (both scope
outcomes are driven through
handleGatewayRequest+ a realCronServiceincron.gateway-policy.integration.test.ts). Retained, narrowed to what nothing else in the repopins: the creating caller stays the recorded
ownerwhile execution routing follows the session'sagent. The explicit-agent, legacy-session-key and malformed-target contracts are unchanged, and
those commits are docs/test-only — no runtime behaviour moved, so the traces above still describe
this head.
the execution agent from a qualified session target vs. reject the combination). CI green on
acd435275ff—check-test-types-core-2andchecks-fast-baseline-ratchets, the two failuresthis revision started from, both report SUCCESS, and the full check suite passes on this head. The
agent-turn authority-chain leg above was added after the last review: no runtime files changed
(evidence only), so the CI result and every earlier trace still describe this head.