Skip to content

fix(cron): deliver final descendant results for threaded jobs - #121180

Closed
steipete wants to merge 1 commit into
mainfrom
codex/qa0809-cron-threaded-child-final
Closed

steipete wants to merge 1 commit into
mainfrom
codex/qa0809-cron-threaded-child-final

Conversation

@steipete

@steipete steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Scheduled jobs that handed work to child agents could publish interim orchestration text, lose the final descendant result, or misroute structured threaded output across channel-specific delivery targets.

Why This Change Was Made

The cron delivery owner now treats completed and awaited child results through one canonical final-output flow, recognizes interim-only spawn handoffs, preserves structured payload classification, and chooses threaded direct versus normal delivery from the prepared target contract.

User Impact

Scheduled Telegram, Discord, Slack, Matrix, and Teams jobs deliver their actual final child response to the intended thread instead of leaking placeholder text, dropping completed work, or emitting duplicate announcements.

Context

Exact final-source trusted remote proof passed 259 tests across seven focused files, including actual channel target normalization and all five channel delivery families. The previously failing core and plugin-boundary type-aware lint gate passed after correcting the implementation; all six changed files pass formatting. Production code decreases by 12 lines.

## What Problem This Solves
Scheduled jobs that handed work to child agents could publish interim orchestration text, lose the final descendant result, or misroute structured threaded output across channel-specific delivery targets.

## Why This Change Was Made
The cron delivery owner now treats completed and awaited child results through one canonical final-output flow, recognizes interim-only spawn handoffs, preserves structured payload classification, and chooses threaded direct versus normal delivery from the prepared target contract.

## User Impact
Scheduled Telegram, Discord, Slack, Matrix, and Teams jobs deliver their actual final child response to the intended thread instead of leaking placeholder text, dropping completed work, or emitting duplicate announcements.

## Context
Exact final-source trusted remote proof passed 259 tests across seven focused files, including actual channel target normalization and all five channel delivery families. The previously failing core and plugin-boundary type-aware lint gate passed after correcting the implementation; all six changed files pass formatting. Production code decreases by 12 lines.
@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 9, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Aug 9, 2026
@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 9, 2026, 1:47 PM ET / 17:47 UTC.

ClawSweeper review

What this changes

The PR routes final results from child agents through the prepared threaded cron-delivery target instead of publishing an interim parent response.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this maintainer PR open: it fixes a real current-main threaded-child delivery gap, but its new text heuristic can suppress a substantive parent result when it contains an interim phrase.

Priority: P1
Reviewed head: 037850c2498cb2faf0d06771957aaa49fdf2ba0e

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The repair has strong owner-boundary intent and broad focused tests, but one P1 message-selection defect remains.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the supplied body reports focused remote tests but links no inspectable runtime artifact.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the supplied body reports focused remote tests but links no inspectable runtime artifact.
Evidence reviewed 5 items Current-main defect: Current main sends threaded work directly before the descendant-finalization path, so an interim parent result can reach the thread before a child’s final result is selected.
Patch-induced false-positive handoff: The new condition treats any short payload containing an interim phrase as child-only, although an accepted child run records no result-ownership fact; a substantive parent result can therefore be cleared or replaced.
Heuristic contract: The phrase recognizer is substring-based, while existing tests only reject text with no hint phrase; they do not cover a substantive short result that contains one.
Findings 1 actionable finding [P1] Do not classify substantive replies as child-only by substring
Security None None.

How this fits together

An isolated cron job can hand work to a child agent, then cron delivery chooses the final response and sends it to a prepared channel target and optional thread. This change governs the handoff between child completion and cross-channel outbound delivery.

flowchart LR
  A[Scheduled cron job] --> B[Parent agent response]
  B --> C[Accepted child agent]
  C --> D[Final-output decision]
  D --> E[Prepared channel target]
  E --> F[Threaded channel delivery]
Loading

Before merge

  • Do not classify substantive replies as child-only by substring (P1) - isLikelyInterimCronMessage accepts any short text containing a hint phrase, while an accepted spawn only proves that a child exists. A real parent result such as a short status containing “working on it” is therefore cleared or replaced by child output; restrict this to an explicit or acknowledgement-only handoff and cover that case.
  • Resolve merge risk (P1) - Merging as written can hide or replace a real short parent result merely because it contains a common interim phrase, causing incorrect threaded message delivery.
  • Complete next step (P2) - The maintainer-labeled PR has a concrete P1 repair, but protected-label handling keeps it on the human review path.

Findings

  • [P1] Do not classify substantive replies as child-only by substring — src/cron/isolated-agent/run-finalize.ts:360-368
Agent review details

Security

None.

PR surface

Source -12, Tests +301. Total +289 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 32 44 -12
Tests 3 322 21 +301
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 354 65 +289

Review metrics

Metric Value Why it matters
Production vs test LOC production +32/-44 (net -12); tests +322/-21 (net +301) The implementation simplifies production flow while adding broad channel-family coverage; the remaining delivery-classification defect needs correction before that coverage supports merge.

Merge-risk options

Maintainer options:

  1. Tighten the child-only classifier (recommended)
    Preserve substantive parent output and defer it only for an explicit or acknowledgement-only child handoff, then add a regression for a short final containing an interim phrase.

Technical review

Best possible solution:

Make child-only delivery depend on an explicit handoff signal or a much stricter acknowledgement-only shape, with a regression covering substantive text that contains an interim phrase.

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

Yes, source-reproducible: an accepted child plus a substantive short parent result containing a recognized interim phrase follows the new spawn-only branch and clears or replaces that result.

Is this the best way to solve the issue?

No; unifying completed and awaited child output is the right owner boundary, but a substring heuristic is not a safe authority signal for discarding parent output.

Full review comments:

  • [P1] Do not classify substantive replies as child-only by substring — src/cron/isolated-agent/run-finalize.ts:360-368
    isLikelyInterimCronMessage accepts any short text containing a hint phrase, while an accepted spawn only proves that a child exists. A real parent result such as a short status containing “working on it” is therefore cleared or replaced by child output; restrict this to an explicit or acknowledgement-only handoff and cover that case.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 34b8a6515d78.

Labels

Label changes:

  • add P1: The patch concerns scheduled job final-result delivery and can suppress or replace a user-visible threaded response.
  • add merge-risk: 🚨 message-delivery: The new handoff decision can select the wrong final response for an existing threaded channel job.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the supplied body reports focused remote tests but links no inspectable runtime artifact.

Label justifications:

  • P1: The patch concerns scheduled job final-result delivery and can suppress or replace a user-visible threaded response.
  • merge-risk: 🚨 message-delivery: The new handoff decision can select the wrong final response for an existing threaded channel job.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the supplied body reports focused remote tests but links no inspectable runtime artifact.

Evidence

What I checked:

Likely related people:

  • steipete: Current cron delivery and finalization lines blame to this recent area commit, and the PR continues work in the same owner boundary. (role: recent area contributor; confidence: medium; commits: e9250be4bbaa, 037850c2498c; files: src/cron/isolated-agent/delivery-dispatch.ts, src/cron/isolated-agent/run-finalize.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Restrict interim-only classification to an explicit or acknowledgement-only handoff.
  • Add a regression where substantive short parent text contains an interim phrase and a child is accepted.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

steipete commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Closing this branch remains correct, but the original “fully superseded” conclusion was too broad. Current main fixes the empty-parent and heartbeat-only parts of the reported cluster, while a narrower descendant-final ownership bug remains.

What current main already fixes:

The remaining root cause is ownership, not thread routing: cron does not yet durably combine explicit yielded-descendant custody, exact accepted child generations, typed terminal reply disposition, sourceReplyFinal progress/final evidence, recipient custody, and terminal task history. Transport shape and fallback paths can still run before that ownership is closed.

This PR must not be merged or mechanically rebased. Its substring-based interim classifier can replace substantive parent output, and its pre-refactor branch conflicts with current ownership boundaries.

Three private root-cause rewrites were evaluated. The final task-ledger design used existing subagent_runs.payload_json and task_runs.detail_json without SQLite DDL, passed 571 focused assertions plus source-blind parent-ownership scenarios, but failed the mandatory final review with three P1 defects:

  1. startup recovery performs outbound network I/O while holding the global cron lock;
  2. retryable known-not-dispatched deliveries are closed instead of retaining prepared custody for redrive;
  3. yielded children can lack a closure when delivery is disabled or target resolution fails.

No private rewrite was pushed. The existing PR remains closed because there is no safe mergeable patch here. A future replacement must use one task-ledger-owned prepared/closed descendant obligation, execute outbound redrive outside the global scheduler lock, retain retryable/ambiguous custody, and close yielded descendants with typed intentional non-delivery when transport is unavailable. Reopen only with that clean implementation and exact-head proof.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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