Skip to content

refactor(text): reuse quote state for XML tag scanning - #149105

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/xml-tag-quote-scanner-20260915
Sep 16, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/xml-tag-quote-scanner-20260915

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

XML tag-close handling now reuses the existing private quote-state scanner, removing a second quote/backslash state machine. Escaped quotes, unquoted < rejection, tag boundaries, malformed markup, code-region protection, and UTF-16 offsets retain their existing behavior.

Production: −25 lines (3 added / 28 removed). Tests: +48 lines, adding 13 XML quote-boundary cases. No public API, parser-policy, or dependency change.

Validation for 37a7779851597b585bf84180eadc367bff04171f:

  • 155 target and sibling cases passed: 130 primary, 13 XML, and 12 MiniMax. Actual CI checkout 16a36abadf775ec4689f6b31e98676b629090677 binds the tested source postimages to this head.
  • Original CI attempt 1 passed, including its aggregate gate: 122 successful jobs and 17 skipped jobs.
  • Complete owner/caller/test review, targeted formatting, diff checks, and fresh full-context branch autoreview passed. The static review found no actionable P0–P2 defect; it did not execute tests.
  • The exact-head ClawSweeper review has no actionable findings or remaining rank-up moves.

Fixed-scope sloppiness score: 35.172430150309815 → 35.91470735595805. The score rises because high-complexity mass stays fixed while total mass falls; raw cyclomatic complexity drops 281 → 277. This is a structural measurement, with no runtime-speed or performance claim.

@vincentkoc vincentkoc self-assigned this Sep 15, 2026
@clawsweeper

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

@vincentkoc
vincentkoc marked this pull request as ready for review September 15, 2026 12:49
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 15, 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 Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 6:48 PM ET / 22:48 UTC (Revision 2).

ClawSweeper review

What this changes

Reuses the existing quote scanner when locating XML tag boundaries in assistant text and adds coverage for quoted attributes and malformed markup.

Merge readiness

✅ Ready for maintainer review

Keep open: this remains a useful, behavior-preserving cleanup absent from current main. No actionable defects were found, consistent with the previous review of the same head.

Priority: P3
Reviewed head: 37a7779851597b585bf84180eadc367bff04171f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable consolidation with behavioral coverage and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored internal refactor is exempt from external-contributor runtime proof; sanitizer output tests and successful exact-head CI provide supplemental validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored internal refactor is exempt from external-contributor runtime proof; sanitizer output tests and successful exact-head CI provide supplemental validation.
Evidence reviewed 7 items Introduced change and behavioral equivalence: The pinned introduced diff replaces only the tag-close quote state machine. The reused scanner processes every preceding UTF-16 position monotonically, preserving single/double quotes, backslash escapes, unquoted '<' rejection, and '>' termination.
Current main still has separate scanners: Current main retains both the private payload quote scanner and the separate tag-close state machine; the proposed consolidation is not already present.
Latest release comparison: The v2026.9.4 source also retains the separate tag-close scanner. GitHub contents inspection succeeded after local historical blob retrieval failed.
Findings None None.
Security None None.

How this fits together

OpenClaw’s shared text sanitizer removes tool-call scaffolding from model output before chat delivery and history display. XML boundary detection helps distinguish hidden payloads from ordinary prose and code examples.

flowchart LR
  A[Model output] --> B[Shared text sanitizer]
  B --> C[Protect code examples]
  C --> D[Scan XML boundaries]
  E[Quote and escape state] --> D
  D --> F[Remove payloads or preserve prose]
  F --> G[Chat delivery and history]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -25, Tests +48. Total +23 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 28 -25
Tests 1 48 0 +48
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 51 28 +23

Review metrics

None.

Technical review

Best possible solution:

Keep one private quote-state implementation for payload and tag scanning while preserving existing sanitizer output.

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

Not applicable: this refactor claims no existing user-facing defect; source comparison supports equivalent scanner behavior.

Is this the best way to solve the issue?

Yes: reusing the existing private scanner removes duplicate logic without expanding APIs, changing parser policy, or introducing another owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 14b8ad1d1871.

Labels

Label justifications:

  • P3: This is a bounded internal cleanup with no intended user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored internal refactor is exempt from external-contributor runtime proof; sanitizer output tests and successful exact-head CI provide supplemental validation.

Evidence

What I checked:

  • Introduced change and behavioral equivalence: The pinned introduced diff replaces only the tag-close quote state machine. The reused scanner processes every preceding UTF-16 position monotonically, preserving single/double quotes, backslash escapes, unquoted '<' rejection, and '>' termination. (src/shared/text/assistant-visible-text.ts:118, 37a777985159)
  • Current main still has separate scanners: Current main retains both the private payload quote scanner and the separate tag-close state machine; the proposed consolidation is not already present. (src/shared/text/assistant-visible-text.ts:118, 14b8ad1d1871)
  • Latest release comparison: The v2026.9.4 source also retains the separate tag-close scanner. GitHub contents inspection succeeded after local historical blob retrieval failed. (src/shared/text/assistant-visible-text.ts:118, 3a9d69db306c)
  • Focused behavioral coverage: The added cases exercise the exported sanitizer with escaped quotes, consecutive delimiters, malformed attributes, self-closing tags, UTF-16 text, and protected code examples. They assert output behavior without adding production test seams. (src/shared/text/assistant-visible-text.xml-quotes.test.ts:4, 37a777985159)
  • Exact-head CI: GitHub confirms the cited original CI attempt completed successfully for the pinned PR head. The supplied body reports 155 focused and sibling cases; this review did not execute tests. (37a777985159)
  • Review continuity and distinct related work: The previous completed review covers this same head and retains no findings. The open fix: serialized tool-call XML leaks into chat replies #138204 adds GLM payload recognition and streaming behavior, whereas this PR preserves parser policy; its proof does not establish supersession or transfer to this PR. (37a777985159)

Likely related people:

  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: 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-15T13:06:13.634Z sha 37a7779 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc merged commit b09af22 into main Sep 16, 2026
263 checks passed
@vincentkoc
vincentkoc deleted the refactor/xml-tag-quote-scanner-20260915 branch September 16, 2026 02:55
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

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: S 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