Skip to content

refactor(auto-reply): deslop auto-reply - #157000

Merged
steipete merged 1 commit into
mainfrom
deslop/l27-autoreply-cleanup
Sep 24, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/l27-autoreply-cleanup

Conversation

@steipete

@steipete steipete commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Auto-reply repeats parsing, event adaptation, delivery projection, and queue bookkeeping across forwarding layers, increasing the amount of code that must stay consistent. This is a maintainer-requested second-pass cleanup of the auto-reply subsystem.

User Impact

No user-visible behavior change is intended. Reply ordering, channel text, prompt/transcript bytes, command and approval distinctions, public SDK exports, configuration, protocol, and persisted schemas stay unchanged.

Compatibility audit: no config schema, option, default, database schema, serialized-state shape, or migration is changed. In reply-media-paths.ts, the existing persistLocalReplyMedia owner and its arguments are unchanged; the extracted helper only shares its result projection. Empty and non-empty payloads retain the same mediaUrl, mediaUrls, attachments, trust metadata, MIME/name fields, and failure metadata. Existing media-path, media-ownership, final-media, and plugin-consumer tests cover these boundaries. The earlier automated compatibility flags did not identify a concrete changed contract and noted an incomplete file list.

Why This Change Was Made

Existing owners now handle the repeated work directly:

  • CLI events use the shared event bridge and lifecycle envelope; follow-up progress callbacks use the existing visibility wrapper.
  • Slash command parsing uses the typed set/unset parser directly, removing the cast-based intermediate adapter. Command mutation, private-route deduplication, model selection, and aliases reuse their existing owners.
  • Queue cleanup and refresh share source iteration. Unreachable drain fallback and unused summary-preparation branches are removed without changing FIFO or custody. The latest-run reference remains because lazy transcript recorders retain it after queue admission and need session-rotation updates.
  • Media result preparation, history recording, image ordering, and markdown-section collection have one implementation each.
  • Invariant-free forwarding helpers, duplicated type declarations, redundant state, and subsumed branches are removed. The assertion baseline shrinks only for the deleted parser module.

Evidence

All pre-commit checks passed on the initial candidate afbdb9a76d28e1b6f04b5aae73cc0454c2a58683 in Blacksmith Testbox (tbx_01m38kyvkhdh3vbbrhwhzn8vx4; 4 CPUs, 15 GB). The tracked-source fingerprint matched before and after the full run.

  • node scripts/check-changed.mjs --base origin/main: passed, including all 25 test-type shards, core/scripts lint, formatting, dead-export scans, and zero runtime import cycles.
  • node scripts/run-vitest.mjs <explicit focused and cross-shard paths>: all 20 batches passed, covering 392 selected files: 344 core/cross-subsystem files and 48 plugin consumers. This includes test/scripts/plugin-sdk-surface-report.test.ts and consumers in Discord, Feishu, LINE, Matrix, Mattermost, memory-lancedb, Teams, Signal, Slack, Telegram, and WhatsApp. Batches took 43m52s including initial QA runtime preparation.
  • pnpm plugin-sdk:surface:check and pnpm plugin-sdk:check-exports: passed. This revision has no plugin-sdk:api:check command; these are the current package-owned surface/export checks.
  • pnpm build: passed in 4m48s. It emitted a non-enforcing isolated Mermaid gzip advisory (1555.8 KiB versus 960.0 KiB); UI inputs are unchanged, and no bundle budget or bundle baseline was altered.
  • Codex autoreview through P2: scoped-clean, with no accepted/actionable findings.
  • git diff --check: passed.

Changed-test wall costs on the Testbox runner, each measured with pnpm test <file> --maxWorkers=1:

File under src/auto-reply/reply/ Wall time Result
commands-setunset.test.ts 1.41s pass
queue.collect.test.ts 18.41s pass
queue.collect-transcript.test.ts 17.45s pass

The collected-transcript regression itself took 3ms in the focused batch; most standalone wall cost is runtime preparation/imports. After publication, the branch was rebased onto 86c2919245f. The range-diff only drops one superseded one-line cleanup from agent-runner-failure-reply.ts: main moved that helper to its canonical failover owner. Every remaining cleanup hunk is unchanged. Codex autoreview of that rebased candidate also passed through P2. Its plugin contract job then failed because the typed-hook inventory omitted extensions/qa-lab/index.ts. The exact assertion reproduces on both the PR head and a clean merge-base checkout (86c2919245f); both inputs are unchanged by this PR. Main fixed the inventory in 3e53db714d2. The branch is now rebased onto bce21484fa7, with an identical range-diff, and the formerly failing assertion now passes on 2c5ca7696bd93421cac48045075312f4a48c6a5e. The final transcript/failover check passed (22 cases across two files). Exact-head PR CI completed successfully for 2c5ca7696bd93421cac48045075312f4a48c6a5e (pull_request, matching head SHA). node scripts/watch-pr-ci.mjs 157000 2c5ca7696bd93421cac48045075312f4a48c6a5e --timeout 3600 --interval 120 returned GREEN, excluding 15 superseded check contexts. The initial full proof remains the evidence for the unchanged cleanup patch.

Production-only reduction: 1,219 lines. The required campaign command also counts the one-line assertion-baseline removal:

79 files changed, 721 insertions(+), 1941 deletions(-)

Measured with:

git diff --shortstat $(git merge-base origin/main HEAD) -- . ':(exclude)**/*.test.*' ':(exclude)**/test/**' ':(exclude)docs/**'

Only tests exclusive to the deleted parser adapter were removed; surviving parser behavior remains covered. The existing collected-transcript test now admits the aggregate and rotates the session before resolving the recorder, preserving content/media/mention/settlement assertions while checking the resulting transcript identity. The complete case moved to queue.collect-transcript.test.ts because the line-growth ratchet rejects growth of the existing oversized collection suite; no baseline exception or coverage reduction was used. The regression fails when the retained latest-run reference is removed and passes with the original bookkeeping intact.

@clawsweeper

clawsweeper Bot commented Sep 24, 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.

@steipete
steipete force-pushed the deslop/l27-autoreply-cleanup branch from afbdb9a to 17b148b Compare September 24, 2026 04:13
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 24, 2026, 12:58 AM ET / 04:58 UTC (Revision 2).

ClawSweeper review

What this changes

The branch consolidates automatic reply command parsing, agent event delivery, follow-up queue bookkeeping, media preparation, and related tests without intending to change user-visible replies.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep this PR open. Current main still has the pre-cleanup auto-reply paths, so the branch has distinct value. The inspected changes and reported exact-head CI reveal no concrete regression; this broad refactor was not independently exercised through a live reply in this read-only review.

Priority: P3
Reviewed head: 2c5ca7696bd93421cac48045075312f4a48c6a5e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent production-code reduction has broad reported validation and no concrete finding in the inspected diff.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: Repository State identifies the author as a member, so the external-contributor proof gate does not apply. Testbox and exact-head CI support the changed auto-reply paths, but this review did not observe a live reply; no stored-data contract changes were identified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies the author as a member, so the external-contributor proof gate does not apply. Testbox and exact-head CI support the changed auto-reply paths, but this review did not observe a live reply; no stored-data contract changes were identified.
Evidence reviewed 9 items Introduced queue cleanup: The PR consolidates iteration over queued items and retained summary sources; queue settings are still applied after a new queue is created.
Introduced media consolidation: Local reply media still passes through the existing persistence owner; the new helper shares projection of its result.
Startup limit comparison: The removed second limit check followed a call that already fits each block within the remaining character budget.
Findings None None.
Security None None.

How this fits together

Auto-reply receives channel messages, interprets commands, and starts agent turns. It passes progress and final output through follow-up queues and media preparation to channel delivery.

flowchart LR
 A[Inbound channel message] --> B[Command and route selection]
 B --> C[Agent turn]
 C --> D[Follow-up queue]
 C --> E[Media preparation]
 D --> F[Outbound reply]
 E --> F
Loading

Before merge

  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production and test LOC production −1,219; tests +10 The stated cleanup reduces production code while retaining and extending collected-transcript coverage.

Stored data model

Persistent data-model change detected: serialized state: src/auto-reply/reply/reply-media-paths.ts, unknown-data-model-change: src/auto-reply/reply/reply-media-paths.ts, unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep one owner for each reply transformation while preserving command authorization, queue ordering, transcript identity, and media delivery through the existing runtime boundaries.

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

Not applicable: this PR targets duplicated implementation rather than a reported runtime failure. The inspected current-main files retain the older paths.

Is this the best way to solve the issue?

Yes: the inspected changes consolidate existing owners and remove forwarding code without establishing a competing capability or storage contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6a6f8a6ecec2.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is an internal cleanup with no intended user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies the author as a member, so the external-contributor proof gate does not apply. Testbox and exact-head CI support the changed auto-reply paths, but this review did not observe a live reply; no stored-data contract changes were identified.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vito Cappello: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-24T04:22:35.699Z sha 17b148b :: blocked before merge. :: none

@steipete
steipete force-pushed the deslop/l27-autoreply-cleanup branch from 17b148b to 2c5ca76 Compare September 24, 2026 04:33
@steipete
steipete merged commit 187f5c5 into main Sep 24, 2026
241 of 242 checks passed
@steipete
steipete deleted the deslop/l27-autoreply-cleanup branch September 24, 2026 05:48
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
amittell added a commit to amittell/openclaw that referenced this pull request Oct 9, 2026
Brings the branch onto current main; GitHub reported it CONFLICTING.

inbound-meta.ts conflicted because main rewrote the helpers this branch had
moved out of it: openclaw#157000, openclaw#161129, openclaw#164547 and openclaw#166085 trimmed the file,
openclaw#158028 dropped its max-lines suppression, and openclaw#167236 merged the transcript
sanitizers into sanitizeTranscriptText. The split is re-applied on main's
code rather than on the branch's older copies:

- inbound-meta.text.ts holds main's normalizePromptMetadataString,
  normalizePromptMetadataStringArray, sanitizePromptBody,
  truncateBodyHeadTail and sanitizeTranscriptText, moved verbatim.
- inbound-meta.current-message.ts builds both projections with
  sanitizeTranscriptText(..., "body") in place of the branch's
  sanitizeTranscriptBody; the inline projection keeps main's bare header.
- inbound-meta.ts is main's file minus the moved helpers.
- config/max-lines-baseline.txt takes main's side, which already dropped the
  inbound-meta.ts entry.

The carrier projection stays in its own module: get-reply-run.media-only.test.ts
and followup-turn-admission.test.ts mock ./inbound-meta.js with closed
factories, and prompt-prelude.ts must not import the projection through them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant