Skip to content

refactor(auto-reply): share command body resolution - #130222

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/auto-reply-command-body
Aug 26, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/auto-reply-command-body

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Command-body fallback precedence was implemented twice inside the auto-reply command-turn path. Keeping both copies aligned made future normalization changes easier to miss.

Why This Change Was Made

Exports the existing command-turn context resolver and reuses it from fallback detection. The canonical empty commandText precedence and legacy field order remain unchanged.

User Impact

No user-visible behavior change. This removes duplicate command normalization policy and keeps detection aligned with command-turn context construction.

Evidence

  • node scripts/run-vitest.mjs src/auto-reply/command-turn-context.test.ts src/auto-reply/reply/source-reply-delivery-mode.test.ts — 46 tests passed.
  • node scripts/check-changed.mjs -- src/auto-reply/command-turn-context.ts src/auto-reply/command-turn-detection.ts — all checks passed except the initial core-test typecheck, which resolved root pako@1 because this sparse worktree lacked its UI workspace dependency link.
  • node scripts/run-tsgo-core-test-shards.mjs — passed after linking the existing shared ui/node_modules; hosted exact-head typechecks also use the complete workspace install.
  • Autoreview: clean, no accepted/actionable findings; correctness 0.99.
  • AWS Crabbox run_1016adef13a8 on lease cbx_d27fd6fdfe2a — fresh PR checkout, frozen install, and 46 tests passed; lease stopped after the run.
  • Production delta: +2/-13, net -11. Tests unchanged.

AI-assisted: yes

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc vincentkoc self-assigned this Aug 26, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 26, 2026 16:22
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 26, 2026
@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 Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 1:04 PM ET / 17:04 UTC.

ClawSweeper review

What this changes

The PR exports the auto-reply command-body resolver and reuses it in fallback command detection, deleting the duplicate precedence logic.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open. The refactor is correct: it removes a duplicated command-body precedence implementation and makes fallback detection reuse the command-turn owner; only routine exact-head CI completion remains.

Priority: P3
Reviewed head: af57f0176deabeeedde1a02bec3ab555f09739f5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused net-negative refactor with direct existing-test coverage and reported clean-machine validation.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored, behavior-preserving refactor is exempt from the external-contributor proof gate; the PR body additionally reports focused validation.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored, behavior-preserving refactor is exempt from the external-contributor proof gate; the PR body additionally reports focused validation.
Evidence reviewed 5 items Canonical owner and caller: The context module owns command-body precedence, and fallback detection now imports that resolver rather than retaining a second implementation.
Current-main comparison: The PR differs from current main only by exporting the existing resolver and replacing the byte-equivalent local copy in detection.
Behavior coverage: The context test verifies that empty canonical commandText remains authoritative over stale legacy fields and runs the fallback detector with that input.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/auto-reply/command-turn-context.test.ts src/auto-reply/reply/source-reply-delivery-mode.test.ts

Result: PASS (completed)

[test] starting test/vitest/vitest.unit-fast.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130222-J7pqgy/target

 ✓  unit-fast  src/auto-reply/command-turn-context.test.ts (11 tests) 13ms
 ✓  unit-fast  src/auto-reply/reply/source-reply-delivery-mode.test.ts (35 tests) 19ms

 Test Files  2 passed (2)
      Tests  46 passed (46)
   Start at  17:05:53
   Duration  4.02s (transform 5.41s, setup 226ms, import 7.43s, tests 32ms, environment 0ms)

[test] passed 1 Vitest shard in 16.51s
[test] starting test/vitest/vitest.unit-fast.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130222-J7pqgy/target

 ✓  unit-fast  src/auto-reply/command-turn-context.test.ts (11 tests) 12ms
 ✓  unit-fast  src/auto-reply/reply/source-reply-delivery-mode.test.ts (35 tests) 19ms

 Test Files  2 passed (2)
      Tests  46 passed (46)
   Start at  17:06:10
   Duration  2.24s (transform 1.92s, setup 87ms, import 4.01s, tests 31ms, environment 0ms)

[test] passed 1 Vitest shard in 14.57s

Assertions:

  • PASS expect_output: Test Files

How this fits together

Auto-reply normalizes inbound message fields into a command body, then uses it to classify command turns and select reply behavior. This change consolidates that normalization boundary for context construction and fallback detection.

flowchart LR
  A[Inbound message fields] --> B[Command body resolver]
  B --> C[Command-turn context]
  B --> D[Fallback command detection]
  C --> E[Auto-reply routing]
  D --> E
Loading

Before merge

  • Resolve merge risk (P1) - The supplied check state still has preflight and security runs in progress; merge only after the exact head is green.
  • Complete next step (P2) - No repair lane is needed; wait for the remaining exact-head checks before normal merge handling.
Agent review details

Security

None.

PR surface

Source -11. Total -11 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 2 13 -11
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 2 13 -11

Review metrics

Metric Value Why it matters
Production and test delta production +2/-13; tests 0 The refactor removes duplicated policy without introducing a new behavior or test seam.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep command-body precedence in the command-turn context module and reuse it from every consumer.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep command-body precedence in the command-turn context module and reuse it from every consumer.

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

Not applicable: this is a behavior-preserving refactor, and current tests directly cover the shared precedence invariant.

Is this the best way to solve the issue?

Yes. The command-turn context is the existing normalization owner, so fallback detection should reuse its resolver rather than maintain a parallel copy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8ce8085e8459.

Labels

Label changes:

  • add P3: This is a small behavior-preserving cleanup in auto-reply command normalization.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored, behavior-preserving refactor is exempt from the external-contributor proof gate; the PR body additionally reports focused validation.

Label justifications:

  • P3: This is a small behavior-preserving cleanup in auto-reply command normalization.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored, behavior-preserving refactor is exempt from the external-contributor proof gate; the PR body additionally reports focused validation.

Evidence

What I checked:

Likely related people:

  • steipete: Introduced the command-turn modules and the duplicated resolver now being consolidated. (role: introduced current implementation; confidence: high; commits: 6f0395ec79f9, 64d4f99d2641; files: src/auto-reply/command-turn-context.ts, src/auto-reply/command-turn-detection.ts)
  • vincentkoc: Previously contributed a merged auto-reply command-turn refactor in this same history. (role: recent area contributor; confidence: medium; commits: 963783e3beaf; files: src/auto-reply/command-turn-context.ts)

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.

@vincentkoc
vincentkoc merged commit b5fda03 into main Aug 26, 2026
1077 of 1096 checks passed
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

@vincentkoc
vincentkoc deleted the refactor/auto-reply-command-body branch August 26, 2026 18:00
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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