Skip to content

[codex] fix cron announce delivery transcript mirrors - #86140

Closed
VishalJ99 wants to merge 1 commit into
openclaw:mainfrom
VishalJ99:codex/fix-cron-session-transcript-mirror
Closed

VishalJ99 wants to merge 1 commit into
openclaw:mainfrom
VishalJ99:codex/fix-cron-session-transcript-mirror

Conversation

@VishalJ99

@VishalJ99 VishalJ99 commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Mirror cron announce/failure-notification delivery into a session transcript when the cron target is a custom/main session key.
  • Use a stable cron-announce-mirror:v1:* idempotency key so repeated delivery does not duplicate transcript rows.
  • Skip transcript mirrors for routed peer/channel session keys such as agent:<id>:<channel>:direct:<peer>, legacy agent:<id>:<channel>:dm:<peer>, groups, and channels so cron delivery does not race an active embedded chat session lock.
  • Add targeted unit coverage.

Verification

  • Rebased onto origin/main efd88dc00d8da4d5bf8fea1d928fd36169073957; current PR head is 5af6df99e9670edc89bee19ce48bac5470e3f37c.
  • git diff --check origin/main...HEAD
  • pnpm changed:lanes --json (core, coreTests)
  • pnpm test src/cron/delivery.failure-notify.test.ts (1 file, 7 tests passed)
  • pnpm check:changed
  • Reran the unrelated CI-timeout test locally on this head: pnpm test src/agents/model-catalog-visibility.test.ts (1 file, 3 tests passed)

Changelog candidate

  • Cron: mirror session-bound announce and failure alert delivery into the destination transcript so follow-up replies keep the delivered message in context.

Note: the changelog line is intentionally kept out of this PR diff to avoid repeated CHANGELOG.md conflicts while main is moving quickly. It can be added at landing.

Real behavior proof

Behavior addressed: Cron announce/failure-alert delivery that resolves to a safe session-bound target now mirrors the delivered assistant text into that session transcript before the next turn can rely on the transcript. Routed peer/channel session keys, including backward-compatible :dm: direct-message keys, are intentionally not mirrored by this helper to avoid the active-session lock race called out in review.

Real environment tested: Local OpenClaw checkout /Users/dross/openclaw-cron-transcript-mirror, branch codex/fix-cron-session-transcript-mirror, proof head eade497bb55d728612dcb3b87f8390560edde533, based on origin/main 07f500aa562d4f414a6b85d785b2e6c2d776cb8d, with a temporary OPENCLAW_STATE_DIR. The current PR head 5af6df99e9670edc89bee19ce48bac5470e3f37c preserves the same src/cron/** source/test patch, rebased onto current main, with the volatile CHANGELOG.md edit removed. The proof exercises the real runtime path sendCronAnnouncePayloadStrict -> sendDurableMessageBatch -> channel outbound adapter -> transcript append. It uses a local proof LINE outbound adapter so no private external account, phone number, endpoint, or token is needed.

Exact steps or command run after this patch: Ran node --import tsx --input-type=module - from the repo root with an inline harness that registered a local LINE outbound adapter, seeded the session store with a custom session key, a routed direct peer-session key, and a legacy routed dm peer-session key, invoked sendCronAnnouncePayloadStrict for all three targets, then read the resulting transcript files from the temporary state directory.

Evidence after fix:

OPENCLAW_RUNTIME_PROOF cron announce mirror lock-safe dm
state_dir=/var/folders/69/5f9v9rq9045bwk3w75cht7wm0000gn/T/openclaw-cron-mirror-proof.UQzfSF
send_results=[{"channel":"line","to":"proof-recipient","accountId":"proof-account","text":"proof cron announce text"},{"channel":"line","to":"proof-recipient","accountId":"proof-account","text":"proof routed cron announce text"},{"channel":"line","to":"proof-recipient","accountId":"proof-account","text":"proof legacy dm cron announce text"}]
custom_session_key=agent:main:session:proof-cron
custom_session_file=<tmp-state>/agents/main/sessions/proof-session.jsonl
custom_transcript_lines=2
custom_last_role=assistant
custom_last_text=proof cron announce text
custom_idempotency_key=cron-announce-mirror:v1:proof-job:e1006f2c48036c15d4dd13a4
mirror_key_prefix_ok=true
routed_session_key=agent:main:line:direct:<redacted>:thread:99
routed_session_file_exists=false
routed_mirror_skipped=true
legacy_dm_session_key=agent:main:line:dm:<redacted>:thread:99
legacy_dm_session_file_exists=false
legacy_dm_mirror_skipped=true

Observed result after fix: All three cron announce sends reached the outbound adapter. The custom session transcript was created and ended with the mirrored assistant message plus the stable cron mirror idempotency key. The routed direct and legacy dm peer-session sends still delivered, but neither peer-session transcript file was created, confirming the lock-safe mirror gate covers both current and backward-compatible direct-message key shapes.

What was not tested: I did not run a real WhatsApp or Telegram network send from this branch. The original WhatsApp incident evidence was captured separately from a redacted live screenshot and logs: a cron announce was visible in WhatsApp at 17:17, the user replied at 17:18, and the live session transcript did not contain the cron announce before that reply. That before-fix evidence is privacy-redacted and not attached as a PR image.

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels May 24, 2026
@VishalJ99
VishalJ99 force-pushed the codex/fix-cron-session-transcript-mirror branch from 40623a7 to 79a03cd Compare May 24, 2026 17:13
@clawsweeper

clawsweeper Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed May 24, 2026, 3:36 PM ET / 19:36 UTC.

Summary
The branch adds cron announce/failure-alert transcript mirror metadata with stable idempotency keys plus unit coverage for custom sessions and routed direct/dm suppression.

PR surface: Source +67, Tests +81. Total +148 across 2 files.

Reproducibility: yes. A focused source-level repro would call sendCronAnnouncePayloadStrict with agent:main:telegram:group:-100123:topic:77; the PR guard derives topic as the peer kind and passes mirror metadata.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦞 diamond lobster
Patch quality: 🧂 unranked krab
Result: blocked by patch quality or review findings.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Suppress topic-suffixed group/channel session keys and add regression coverage.

Risk before merge

  • Topic-suffixed group/channel session keys such as agent:main:telegram:group:-100123:topic:77 still pass the new guard and can receive mirror transcript writes.
  • A mirror write into an active routed group/topic transcript can reintroduce the same session-state and message-continuity risk the PR is trying to avoid.

Maintainer options:

  1. Cover topic-suffixed routed keys (recommended)
    Extend the guard and regression tests so group/channel routed keys with provider-owned suffixes do not receive transcript mirror metadata.
  2. Pause for the broader route policy
    Wait for the routed-peer mirror policy in fix(cron): skip delivery mirror for routed peer sessions to prevent session lock races #84603, then rebase this helper path onto the same supported classification.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Extend the cron delivery mirror routed-session guard and tests so `agent:main:telegram:group:-100123:topic:77` and another provider-owned group/channel suffix do not pass mirror metadata, while `agent:main:session:daily-digest` still mirrors. Keep the change scoped to `src/cron/delivery.ts` and `src/cron/delivery.failure-notify.test.ts`; do not edit `CHANGELOG.md`.

Next step before merge
A narrow automated repair can extend the routed-session guard and test matrix without a product decision.

Security
Cleared: The diff only changes cron transcript mirror logic and unit tests; it does not alter dependency sources, CI permissions, package resolution, secrets handling, or command execution surfaces.

Review findings

  • [P1] Suppress topic-suffixed routed session mirrors — src/cron/delivery.ts:73-75
Review details

Best possible solution:

Keep the helper mirror for main/custom session keys, but classify routed direct, legacy dm, group, and channel session keys robustly across provider-owned suffixes before merge.

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

Yes. A focused source-level repro would call sendCronAnnouncePayloadStrict with agent:main:telegram:group:-100123:topic:77; the PR guard derives topic as the peer kind and passes mirror metadata.

Is this the best way to solve the issue?

No, not yet. The mirror approach is narrow and maintainable, but the routed-session suppression needs to cover provider-owned group/channel suffixes before it is the best fix.

Full review comments:

  • [P1] Suppress topic-suffixed routed session mirrors — src/cron/delivery.ts:73-75
    The guard only checks the penultimate token after stripping :thread:, so agent:main:telegram:group:-100123:topic:77 is treated as safe because the penultimate token is topic. That still passes mirror metadata and can write into an active routed group/topic transcript; add coverage for topic-suffixed group/channel keys and suppress them before sending mirror metadata.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.9

Codex review notes: model gpt-5.5, reasoning high; reviewed against 43252c809910.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal output from an after-fix local runtime harness that exercised cron announce delivery through outbound delivery into a temporary transcript and verified direct/dm skips with private data redacted.

Label justifications:

  • P1: The PR targets a real cron/channel context bug, and the remaining guard gap can still affect active channel replies for routed group/topic sessions.
  • merge-risk: 🚨 session-state: Merging as-is can still write assistant mirror rows into an active routed group/topic session transcript.
  • merge-risk: 🚨 message-delivery: That transcript mutation can miscontextualize or interrupt follow-up channel replies in the affected routed session.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦞 diamond lobster and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body includes terminal output from an after-fix local runtime harness that exercised cron announce delivery through outbound delivery into a temporary transcript and verified direct/dm skips with private data redacted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal output from an after-fix local runtime harness that exercised cron announce delivery through outbound delivery into a temporary transcript and verified direct/dm skips with private data redacted.
Evidence reviewed

PR surface:

Source +67, Tests +81. Total +148 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 67 0 +67
Tests 1 82 1 +81
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 149 1 +148

Acceptance criteria:

  • node scripts/run-vitest.mjs src/cron/delivery.failure-notify.test.ts
  • git diff --check

What I checked:

  • PR adds mirror metadata after resolving a cron announce target: The PR adds mirrorSessionKey resolution and passes mirror metadata into sendDurableMessageBatch for cron announce/failure delivery. (src/cron/delivery.ts:123, 5af6df99e967)
  • Routed peer detection only checks the penultimate token: isRoutedPeerSessionKey strips only a generic :thread: suffix, then checks parts[parts.length - 2]; a key such as agent:main:telegram:group:-100123:topic:77 yields topic there and is not suppressed. (src/cron/delivery.ts:73, 5af6df99e967)
  • Current routing tests preserve topic suffixes in group keys: Current main explicitly treats agent:main:telegram:group:-100123:topic:77 as a base session key rather than a generic thread suffix, so the PR's parseThreadSessionSuffix call will not remove :topic:77. (src/routing/session-key.test.ts:164, 43252c809910)
  • Current chat-type parsing treats group/channel tokens as routed chat sessions: The shared session chat-type helper classifies any scoped key containing group or channel tokens as group/channel chat, matching the class the PR says must skip transcript mirrors. (src/sessions/session-chat-type-shared.ts:27, 43252c809910)
  • Mirror metadata mutates session transcripts after delivery: Outbound delivery appends params.mirror to the requested session transcript after successful sends, so an incorrectly allowed routed key is a real session-state write. (src/infra/outbound/deliver.ts:1820, 43252c809910)
  • Whitespace diff check is clean: The PR diff has no whitespace errors against current main, so the blocker is behavioral rather than formatting. (5af6df99e967)

Likely related people:

  • steipete: Recent history ties Peter Steinberger to cron notification routing, split notification routing, and the message delivery API that this PR extends. (role: recent area contributor; confidence: high; commits: 332cdd7acaf3, 85148f3b2099, a4b17d65a8ff; files: src/cron/delivery.ts, src/cron/delivery.failure-notify.test.ts, src/channels/message/send.ts)
  • kesor: The failure destination support that this PR now mirrors into transcripts appears in commit 4b4ea5df8bc1. (role: introduced related cron failure destination behavior; confidence: medium; commits: 4b4ea5df8bc1; files: src/cron/delivery.ts, src/cron/delivery-plan.ts)
  • NianJiuZst: The related open PR for routed peer-session mirror suppression covers the same lock-race class around cron delivery transcript mirrors. (role: related fix proposer; confidence: medium; commits: a7196a70950d; files: src/cron/isolated-agent/delivery-dispatch.ts, src/cron/isolated-agent/delivery-dispatch.double-announce.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@VishalJ99
VishalJ99 force-pushed the codex/fix-cron-session-transcript-mirror branch from 79a03cd to eed8122 Compare May 24, 2026 17:16
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels May 24, 2026
@clawsweeper

clawsweeper Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🔥 Warming up: real-behavior proof passed; findings, security review, or rank-up moves are still in progress.

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.
What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@clawsweeper
clawsweeper Bot temporarily deployed to qa-live-shared May 24, 2026 17:25 Inactive
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels May 24, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels May 24, 2026
@VishalJ99
VishalJ99 force-pushed the codex/fix-cron-session-transcript-mirror branch from eed8122 to 375f94f Compare May 24, 2026 17:50
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 24, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@VishalJ99
VishalJ99 force-pushed the codex/fix-cron-session-transcript-mirror branch from 375f94f to b20428f Compare May 24, 2026 18:00

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels May 24, 2026
@clawsweeper clawsweeper Bot added the rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. label May 24, 2026
@VishalJ99
VishalJ99 force-pushed the codex/fix-cron-session-transcript-mirror branch from b20428f to f0f7de6 Compare May 24, 2026 18:29
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 24, 2026
@VishalJ99
VishalJ99 force-pushed the codex/fix-cron-session-transcript-mirror branch 2 times, most recently from 2b8456c to 6d32adc Compare May 24, 2026 18:35

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@VishalJ99
VishalJ99 force-pushed the codex/fix-cron-session-transcript-mirror branch from 6d32adc to eade497 Compare May 24, 2026 18:47

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

VishalJ99 commented May 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Correction: reopened. The goal is to find a cleaner solution to the repeated CHANGELOG.md merge-conflict churn, not abandon the fix. I am preserving this note so the brief close/reopen is explained in the PR history.

@VishalJ99 VishalJ99 closed this May 24, 2026
@VishalJ99 VishalJ99 reopened this May 24, 2026
@VishalJ99
VishalJ99 force-pushed the codex/fix-cron-session-transcript-mirror branch from eade497 to 4102b6c Compare May 24, 2026 19:08
@VishalJ99
VishalJ99 force-pushed the codex/fix-cron-session-transcript-mirror branch from 4102b6c to 5af6df9 Compare May 24, 2026 19:18

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 24, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #86491.

#86491 carries the same cron transcript-mirror fix, folds in the related heartbeat/digest transcript-mirror fix from the live follow-up bug, and keeps CHANGELOG.md out of the diff to avoid the repeated merge-conflict churn. It also addresses this PR's routed group/topic guard finding in the replacement branch.

@VishalJ99 VishalJ99 closed this May 25, 2026
VishalJ99 added a commit to VishalJ99/openclaw that referenced this pull request May 25, 2026
PER-161

Supersedes openclaw#86140 by covering both cron announce/failure delivery and heartbeat/digest delivery in one proactive transcript mirror fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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