Skip to content

fix(cron): show outcomes for withheld follow-ups - #202997

Merged
steipete merged 1 commit into
mainfrom
codex/cron-followup-visible-outcome
Nov 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/cron-followup-visible-outcome

Conversation

@steipete

@steipete steipete commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two cron-originated follow-ups were withheld with followup queue: input withheld; refusing replay: cron delivery owner retired, with no matching delivery or notice afterward. The reported restart was at 22:44:44 PST; the refusals were at 22:54:55 and 23:01:33 PST. The refusal line contained neither a session key nor a job ID.

User Impact

A withheld cron follow-up now records a failed, not-delivered outcome in the existing cron run history and a bounded failure notice in its targeted session. Removed jobs, cancellations, deleted agents, and retired delivery owners still cannot replay their inputs. No schema, store, queue, restart recovery, or durability policy changes.

Why This Change Was Made

At base f01c0ed4ecde, src/cron/service/delivery-attempt-fence.ts:41-48 combines generation retirement without handover, a stale active-run marker, cancellation, job removal, and a changed default agent into the same error. The metadata cannot identify which production condition fired. A hard process restart cannot retain the in-memory follow-up object or its closures; durable cron recovery is a separate owner. Existing reload handover explicitly preserves delivery authority for live runs. This PR does not claim a false restart fence or change handover.

The regression demonstrates the stale active-run marker condition (!isCronActiveJobMarkerCurrent(activeJobMarker), base line 42). Normal cron finalization clears that marker (src/cron/service/timer-outcome-finalization.ts:231). A detached internal-event Goal continuation retains its cron authority but clears queuedFollowupReplyDisposition (src/auto-reply/reply/goal-continuation.ts:257). Ordinary session-event follow-ups do have a deliver callback, but that callback records a failed completion in its closure and does not render completion.notice (src/auto-reply/reply/session-event-handoff.ts:633).

The vanishing boundary is src/auto-reply/reply/followup-runner.ts:427: the refusal becomes consumed; notification requires sourceDisposition?.kind === "deliver" at line 457, then line 507 completes the queued input's lifecycle. The new diagnostic settlement runs independently of that callback. The captured cron receipt owner writes a separate, idempotently keyed history outcome for the refused continuation, preserving the original occurrence's outcome. The existing session failure-report owner appends the notice without executing the input.

Accepted edges: a removed/reset session can refuse a transcript write through its existing writer guard; cron history remains the outcome owner. Storage failures retain the existing best-effort warning behavior. There is no replay or new retry mechanism. The supplied metadata cannot establish the two production fence conditions; diagnosis and proof stayed local, with no live Gateway or host access.

Simplification: consolidated repeated follow-up delivery/refusal setup while preserving all distinct cases and assertions, and removed a single-use fixture helper with an unused override seam. Production grows by 76 lines across four files; tests change by -1 line across two files versus the base after formatting.

Evidence

The regression drives the production follow-up runner, real cron fence, cron history writer, and session transcript report owner. It retires the active marker before admission; the input remains fenced and its reason is recorded in history and the session.

Red on f01c0ed4ecde, before production edits:

pnpm test src/cron/service.restart-delivery.test.ts --maxWorkers=1
followup queue: input withheld; refusing replay: cron delivery owner retired
AssertionError: expected [] to deep equally contain ObjectContaining{...}
Tests  1 failed | 9 passed (10)

The failed assertion expected a failed, not-delivered history entry with error: "cron delivery owner retired" and the targeted session key. Initial test setup failures were corrected before recording this behavioral red.

Green: all six existing follow-up runner test files passed (46 tests: 2 in the writer-claim shard and 44 in the auto-reply shard). The cron regression, session-run, receipt-finalization, and receipt-store files passed. The delivery-fence consumer run passed: 21 Gateway completion tests (including removed/cancelled occurrence fencing), plus 24 cron delivery/restart tests. Core and targeted messaging/cron test typechecks, touched-file lint, format, and git diff --check passed. Local Codex autoreview of the complete candidate against f01c0ed4ecde, P0–P2: scoped-clean, no accepted/actionable findings. Committed PR head a20cb56a5c070422e8c8dabf9f95dc7cdf6657d8 also passed Codex autoreview against f01c0ed4ecde, P0–P2: scoped-clean, no accepted/actionable findings. Exact-head CI is being watched with the repository watcher.

pnpm test src/auto-reply/reply/followup-runner --maxWorkers=1
Tests  2 passed (2)
Tests  44 passed (44)
pnpm test src/gateway/server-cron-completion.test.ts src/cron/delivery.test.ts src/cron/service.restart-delivery.test.ts --maxWorkers=1
Tests  21 passed (21)
Tests  24 passed (24)
[tsgo:messaging] passed
[tsgo:services-cron] passed

Additional direct consumers passed: src/cron/session-run.test.ts, src/cron/service/timer-outcome-finalization.receipts.test.ts, and src/cron/store/run-receipt-store.test.ts.

Retain the delivery fence while recording refused cron continuations in existing run history and bounded session failure notices. Preserve the original occurrence outcome and never replay revoked input.
@clawsweeper

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T07:52:58.242664Z a20cb56 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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. 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. labels Nov 21, 2026
@clawsweeper

clawsweeper Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR records withheld cron follow-ups in cron history and the targeted session without replaying their inputs.

Example: A cron Goal continuation targets agent:main:withheld-cron after its active-run marker has been cleared.

  • Before: The continuation is refused with “cron delivery owner retired” and leaves no matching history outcome or session notice.
  • After: The continuation remains refused and records a failed, not-delivered history outcome plus a session notice.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful, focused ownership and meaningful regression coverage, but the required product-path proof is absent and the new user-facing notice needs repair.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A refused cron continuation can disappear without an outcome in its automation history or targeted chat.
Reason: The maintainer-authored direction restores visible terminal accounting without changing replay, cancellation, reload, or durability policy.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: it addresses a source-confirmed gap in withheld cron follow-up reporting, but the new notice needs actionable wording before merge.

Priority: P2
Reviewed head: a20cb56a5c070422e8c8dabf9f95dc7cdf6657d8

Before merge

  • Explain the withheld automation and give the user a next action (P2) - When the active cron marker has retired, this new visible report contains only “withheld: cron delivery owner retired”. That exposes an internal lifecycle term without explaining that the automation follow-up did not run or how the user can proceed. Root AGENTS.md requires errors to name the next step. Keep the diagnostic reason in the recorded details, and make the notice explain the skipped follow-up and direct the user to review the automation's run history before deciding whether to run it again.

Findings

  • [P2] Explain the withheld automation and give the user a next action — src/auto-reply/reply/followup-runner.ts:488

Tests

  • Missing end-to-end proof: Provide a redacted isolated-Gateway capture of a cron continuation being withheld, its failed history outcome and visible session notice, and no input replay; redact credentials, IPs, phone numbers, and non-public endpoints.
Agent review details

How this fits together

The follow-up runner admits queued agent work; cron supplies occurrence authority, while existing cron-history and session-transcript writers persist terminal outcomes.

flowchart TD
  A[Cron occurrence] --> B[Queued follow-up]
  B --> C[Admission fence]
  C --> D[Refused continuation]
  D --> E[Cron history writer]
  D --> F[Session failure writer]
Loading

Technical review

Best possible solution:

Keep the existing refusal and persistence owners, and give the session notice a plain explanation and a safe next action.

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

Source confirms that recorded authority loss consumes the queued continuation while notification depends on a callback detached Goal continuations lack; the supplied regression exercises that path, but this review ran no target code.

Is this the best way to solve the issue?

The patch uses the smallest existing ownership path for recording refusal outcomes and preserves delivery authority, with one actionable-copy defect.

Full review comments:

  • [P2] Explain the withheld automation and give the user a next action — src/auto-reply/reply/followup-runner.ts:488
    When the active cron marker has retired, this new visible report contains only “withheld: cron delivery owner retired”. That exposes an internal lifecycle term without explaining that the automation follow-up did not run or how the user can proceed. Root AGENTS.md requires errors to name the next step. Keep the diagnostic reason in the recorded details, and make the notice explain the skipped follow-up and direct the user to review the automation's run history before deciding whether to run it again.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 76cbbdf70d30.

Provenance checked

  • Queued follow-up refusal and source settlement keeps the original intent (d981eaa: Revoked queued input must settle as a visible failure rather than silently cancelling; subsequent custody work preserves retry for unrecorded authority failures.)
  • Cron completion delivery fence keeps the original intent (187594c: Prevent duplicate delivery after uncertain acceptance and restart; later reload handover work intentionally retains delivery for live runs.)
  • Follow-up test consolidation keeps the original intent (d979dba: Distinguish recorded revocation from temporary authority refusal and preserve the accepted input's custody; the consolidated cases retain those distinctions.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/cron/service.restart-delivery.test.ts --maxWorkers=1
  • pnpm test src/auto-reply/reply/followup-runner --maxWorkers=1
  • git diff --check

What I checked:

PR surface

Source +76, Tests -1. Total +75 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 76 0 +76
Tests 2 213 214 -1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 289 214 +75

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test LOC Production +76/-0; tests +213/-214 Production growth connects existing diagnostic owners; test consolidation offsets the focused regression.

Labels

Label changes:

  • add P2: Missing outcomes for refused automation continuations are a bounded observability defect; this PR deliberately preserves execution and delivery behavior.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Missing outcomes for refused automation continuations are a bounded observability defect; this PR deliberately preserves execution and delivery behavior.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

Reviewed November 21, 2026, 3:07 AM ET / 08:07 UTC.

@steipete
steipete merged commit e43daaa into main Nov 21, 2026
143 checks passed
@steipete
steipete deleted the codex/cron-followup-visible-outcome branch November 21, 2026 08:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Nov 22, 2026
- status-message: the fork moved formatVoiceModeLine out (line cap) and
  upstream openclaw#203043 moved formatEstimatedContextBudgetTokens out; together
  they took the last reader of the SessionEntry type import (TS6133).
- followup-runner.test: upstream openclaw#202997/openclaw#203029 replaced the
  createSettledExecution fixture with createExecution("settled" default);
  the fork's suppressed-delivery ordering case follows (TS2552).

No behavior change.

Refs openclaw#129388

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 22, 2026
…202997)

Retain the delivery fence while recording refused cron continuations in existing run history and bounded session failure notices. Preserve the original occurrence outcome and never replay revoked input.
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
)

(cherry picked from commit f02d9dc)

Release adaptation: Place the captured cron receipt/error contract and troubleshooting text first. Its producer and consumer follow in the paired source commit.

Companion audit: #203029 is required by #202997 to cover authority-only refusal without replay.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
Retain the delivery fence while recording refused cron continuations in existing run history and bounded session failure notices. Preserve the original occurrence outcome and never replay revoked input.

(cherry picked from commit e43daaa)

Release adaptation: Integrate the companion against the stable pre-source queue/cron owners; keep their activated behavior in this source commit after the companion contract. No change to authority or replay policy.

Companion audit: #203029 included as the preceding contract and paired activation; later account/restart lifecycle rows are independent.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant