Skip to content

fix(rizin): preserve trailing whitespace before the completion marker - #4044

Closed
Xander-AJ wants to merge 2 commits into
morluto:mainfrom
Xander-AJ:fix/rizin-marker-preserve-trailing-whitespace
Closed

Xander-AJ wants to merge 2 commits into
morluto:mainfrom
Xander-AJ:fix/rizin-marker-preserve-trailing-whitespace

Conversation

@Xander-AJ

@Xander-AJ Xander-AJ commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #4016. rizin_debug_command removed trailing spaces and a newline from command output when the output and the generated completion marker arrived in one NUL frame, while the same output ending in its own frame was kept. Both results reported complete, untruncated output.

Problem and expected behavior

Trigger: Rizin writes value \n<marker>\n\0 (coalesced) instead of value \n\0<marker>\n\0 (framed). waitForCommandFrames ran trimEnd() over the text before the marker, so the coalesced run returned "value" and the framed run returned "value \n". The same command output should give the same Evidence regardless of how the provider frames it.

Change and scope

Only the text before the marker is no longer trimmed (src/rizin/RizinDebugSessionManager.ts). Nothing else in marker handling, truncation or limits changes. Not included: any change to how frames are joined.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Rizin command frame parsing (waitForCommandFrames).
  • Contribution scope fit and linked maintainer decision: ordinary fix within existing boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: no schema change; rizin_debug_command output may now keep trailing whitespace it previously dropped when coalesced.
  • Provider, bridge, target-format, or platform compatibility: Rizin only.
  • Evidence, artifact, provenance, or reconstruction contract: output is now independent of framing.

Expected effects:

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/providers/RizinDebugSessionCoverage.part4.test.ts runs the same output framed and coalesced and requires identical results.
  • Base reproduction or other evidence: the new test fails on the base revision (expected 'value' to be 'value \n') and passes with the change. Executed against the injected-process fixture; not against a real Rizin.
  • Remaining proof gaps: no real Rizin run; the MCP boundary tests (tests/boundary/mcp) were not run because dist was not built. History check: the trimEnd() was added in the large squashed commit 4aa51bf (fix(reverse): reconcile cleanup ownership and mutation diagnostics #2799) with no stated rationale, and no test or doc I found depends on it. The framed path (output and marker in separate frames) never trimmed, so the old behaviour only applied when frames coalesced. Edge case: a coalesced frame that is only whitespace before the marker (for example a stray \n) now yields that whitespace as output instead of being dropped, matching what a standalone whitespace frame already did.

Validation performed

  • npx vitest run tests/boundary/providers/Rizin src/rizin — 10 files passed, 83 tests passed, 21 skipped (Node 24.18.0)
  • npx oxfmt --check on both changed files — formatted
  • npx oxlint on both changed files — only pre-existing complexity/length warnings in RizinDebugSessionManager.ts

Compatibility, safety, and release

  • Breaking changes or migration steps: none intended; output may retain trailing whitespace.
  • Real Hopper/Ghidra, browser, or OS coverage: none.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: not applicable.

Author readiness

Drafted with AI assistance and then reviewed by the human owner, who made the declarations below.

Human owner: @Xander-AJ

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Command output that shared a NUL frame with the generated completion marker had its trailing whitespace stripped, while the same output in its own frame kept it. Keep the text as received so framing does not change the Evidence.

Fixes morluto#4016
@Xander-AJ
Xander-AJ marked this pull request as ready for review October 15, 2026 10:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T10:07:26.427776Z 8b33c12 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

Preserves trailing whitespace before Rizin’s completion marker instead of trimming it.

  • Rizin command output keeps trailing whitespace before the completion marker.

Reviews (2) · Last reviewed commit: "test(rizin): throw typed errors and reje..." · Reviewed by Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b33c12bf4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

const { manager, started } = await startInjected(injected.spawnProcess, {
frameTimeoutMs: 1000,
});
expect(started.ok).toBe(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Throw typed failures before reading Result values

When startInjected or execute returns Err, these boolean assertions abort with only a generic mismatch, so the typed provider failure is never surfaced and this boundary regression becomes much harder to diagnose. The repository's linked docs/testing.md guidance requires throwing the typed error before reading a successful Result; replace both assertion/fallback pairs with if (!...ok) throw ....error.

AGENTS.md reference: AGENTS.md:L77-L77

Useful? React with 👍 / 👎.

const run = async (framing: "coalesced" | "framed"): Promise<string> => {
const injected = createInjectedProcess({
onWrite: (text, control) => {
const marker = /!echo (.+)\n/u.exec(text)?.[1];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject unmodeled commands in the protocol fixture

If the manager omits or mangles pad but still writes !echo <marker>, this callback still synthesizes value because it only parses the marker, so the regression passes without exercising the requested command exchange. The test guidance linked by the repository rules requires protocol fixtures to reject unmodeled commands; validate the expected pad command and marker request before replying.

AGENTS.md reference: AGENTS.md:L77-L77

Useful? React with 👍 / 👎.

morluto added a commit that referenced this pull request Oct 18, 2026
Adapt #4044 at the shared normal/interrupted frame owner. Preserve the decoded prefix before byte-budget accounting and cover MCP delivery across framing and UTF-8 boundaries. Refs #4016.

Co-authored-by: Xander-AJ <[email protected]>
@morluto

morluto commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Thanks @Xander-AJ. Closing this PR as superseded by d5fc7e6eb on main.

Rizin command framing now preserves trailing whitespace before the correlated completion marker. Main owns frame parsing and the supplied coverage.

This is an unmerged closure: it does not label this PR as merged or remove contributor history/credit. The decision uses the current source diff and existing validation record; no new local test or provider run is claimed.

@morluto morluto closed this Oct 18, 2026
@morluto morluto added bug Something isn't working provider: rizin Analysis provider / engine: rizin labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working provider: rizin Analysis provider / engine: rizin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Rizin completion-marker parsing strips trailing command-output whitespace

2 participants