fix(cron): clean up deleteAfterRun direct deliveries#67807
fix(cron): clean up deleteAfterRun direct deliveries#67807hxy91819 merged 4 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR fixes a gap where Confidence Score: 5/5Safe to merge; the cleanup logic is correct and well-tested, with only a minor test mock path issue that does not affect current test outcomes. All findings are P2. The core fix (finally-guarded cleanup wrapper + dedup flag) is logically sound, covers all direct-delivery branches, and the new tests assert both cleanup and single-delete behavior correctly. The only concern is a mock targeting the wrong sessions module path, which currently has no impact on test results. src/cron/isolated-agent/delivery-dispatch.double-announce.test.ts — the vi.mock for the sessions module path should be verified/corrected, though it does not affect current test correctness.
|
|
@hxy91819 PTAL |
08e27fa to
8e35809
Compare
|
Merged via squash.
Thanks @MonkeyLeeT! |
|
Thanks @MonkeyLeeT for the clean fix and thorough regression tests — the double-delete guard via
No rush on any of these — the current PR is solid and ready to land as-is. |
Two related gaps in the CHANGELOG write path both caused PRs to land in the wrong place: 1) `resolve_merge_changelog_section` only consulted the environment override and PR labels. If a PR was only tagged with something like `size: S` (no `bug`/`fix`/`feature` label), the default fell through to Changes even when the PR title made the category obvious (e.g. `fix(cron): clean up deleteAfterRun direct deliveries` on PR openclaw#67807). That Conventional-Commits prefix is the repo's actual classification signal for most PRs and was being ignored. Add a title-prefix fallback after the label check: a title starting with `fix`, `bugfix`, or `hotfix` (followed by `(`, `:`, `!`, or whitespace) routes to Fixes; `feat`, `feature`, `enhance` route to Changes. Labels still win when present. Deliberately strict so `fixup!`, `fixing ...`, `fixture updates`, `featured posts` are not misread as `fix:`/`feat:`. 2) `appendUnreleasedChangelogEntry` deduped only on full-text equivalence. When a PR had a detailed entry written during prepare and then the merge step called `ensure_pr_changelog_entry` again with the short PR-title form, the two text bodies differed and the same PR got a duplicate line — that is what happened to PR openclaw#67679, which ended up with lines under both `### Changes` and `### Fixes`. Add a stronger precheck: scan the `## Unreleased` block for any existing bullet whose first PR reference matches the new entry's PR number. If one exists anywhere in the block (any sub-section), skip insertion. Dedup is scoped to Unreleased so the same PR number in a released block does not suppress a new Unreleased entry, and uses integer-equality on the PR number so `openclaw#67` is not shadowed by `openclaw#6767`. Together these two changes cover both of the recently observed failure modes: - Missing section signal from labels (PR openclaw#67807) is now picked up from the title. - Second ensure at merge time (PR openclaw#67679) no longer plants a duplicate in a different sub-section. Covered by shell smoke (27 resolver scenarios) and vitest (12 cases incl. the openclaw#67679 cross-section regression, released-block false positive, and PR-number prefix collision).
* changelog: move openclaw#67807 entry to Fixes section * changelog: move openclaw#67807 entry to Fixes section with correct PR-number ordering
* changelog: move openclaw#67807 entry to Fixes section * changelog: move openclaw#67807 entry to Fixes section with correct PR-number ordering
* changelog: move openclaw#67807 entry to Fixes section * changelog: move openclaw#67807 entry to Fixes section with correct PR-number ordering
* changelog: move openclaw#67807 entry to Fixes section * changelog: move openclaw#67807 entry to Fixes section with correct PR-number ordering
* changelog: move openclaw#67807 entry to Fixes section * changelog: move openclaw#67807 entry to Fixes section with correct PR-number ordering
Summary
deleteAfterRunsessions on the text-finalization path; structured payloads and threaded direct deliveries could leave isolated cron sessions behind.deleteAfterRunjobs could accumulate transcript state and hit the context-overflow behavior reported in Cron sessions with deleteAfterRun: true not being deleted — causes context overflow #67718.sessions.deletecall.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
deleteAfterRundirect cron sessions was attached to the text finalization path, but the structured direct-delivery and threaded direct-delivery branches calleddeliverViaDirectwithout that cleanup.useDirectDeliverybranches, and no guard against duplicate deletion after refactoring cleanup into a shared wrapper.Regression Test Plan (if applicable)
src/cron/isolated-agent/delivery-dispatch.double-announce.test.tsdeleteAfterRuncleans up after threaded direct deliveries, structured direct deliveries, and structured silent replies without double-deleting the session.dispatchCronDeliverybranch selection and cleanup behavior, so the isolated dispatch test file exercises the exact control flow without extra cron runtime noise.User-visible / Behavior Changes
Cron jobs using
deleteAfterRun: truenow reliably delete isolated direct-delivery sessions after structured payload sends and threaded direct sends. Silent direct deliveries still clean up the session, but only issue one delete call.Diagram (if applicable)
Security Impact (required)
Yes, explain risk + mitigation:Repro + Verification
Environment
deleteAfterRun: true, isolated cron sessionSteps
deleteAfterRun: trueon the job.Expected
Actual
Evidence
Human Verification (required)
pnpm test/ repo-wide gate in this shell, because the local environment lacks apnpmbinary onPATH; verification used the underlying Vitest cron config directly.Review Conversations
Compatibility / Migration
Risks and Mitigations
sessions.deletecall for the structured silent path.