Skip to content

fix(runtime): pass option-like Grep patterns after a -- separator - #3903

Merged
M4n5ter merged 2 commits into
apache:mainfrom
heeoneie:fix/grep-option-like-pattern
Aug 27, 2026
Merged

fix(runtime): pass option-like Grep patterns after a -- separator#3903
M4n5ter merged 2 commits into
apache:mainfrom
heeoneie:fix/grep-option-like-pattern

Conversation

@heeoneie

Copy link
Copy Markdown
Contributor

Summary

The sandboxed filesystem worker appended the Grep pattern as a bare positional, so ripgrep parsed a pattern starting with - as flags. -webkit-box made rg exit 1, which operations.ts maps to { kind: 'grep', matches: [] } — the model was told the string is absent from a file that contains it, with no error and no diagnostic.

The host-local sibling already handles this at workspace-executor.ts:455; this change mirrors it in the worker.

Fixes #3733

Verification

Confirmed the underlying behaviour against ripgrep directly:

rg -n --no-heading --max-count=50 '-webkit-box' file.ts      -> exit 1, no output
rg -n --no-heading --max-count=50 -- '-webkit-box' file.ts   -> exit 0, 1:const style = "-webkit-box";

Ran locally against packages/runtime:

  • npm --workspace @maka/core run build, @maka/storage, @maka/runtime — all clean
  • node --test dist/__tests__/filesystem-worker.test.js — the new test passes; pass count goes 19 -> 20 with no new failures
  • biome lint and biome format on both changed files — clean

Not run: the full workspace suite and the desktop app. This sandbox could not complete a root npm install (the registry mirror blocks @xterm/xterm, and the Electron postinstall cannot reach its download host), so only the core / storage / runtime workspaces were built and exercised.

One pre-existing failure in that file — reports no diff — not a new-file diff — when an existing file cannot be read — fails on unmodified main in this environment too, because the test runs as root and chmod 000 does not deny root. Unrelated to this change.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Claude (Anthropic) — drafted the one-line fix and the regression test, and ran the local verification above. Reviewed and submitted by me. Generated-by: Claude trailers are on both commits.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

ripgrep parsed a pattern beginning with `-` as flags, so the worker
returned exit 1 and the caller mapped it to an empty match list. Mirror
workspace-executor.ts, which already separates the pattern with `--`.

Generated-by: Claude
Assert the `--` separator reaches runGrep, mirroring the existing
workspace-executor coverage.

Generated-by: Claude
@M4n5ter

M4n5ter commented Aug 27, 2026

Copy link
Copy Markdown
Member

Relationship note: PRs #3734, #3735, and #3903 all close #3733, touch the same two runtime files, and apply the same -- separator fix to the sandboxed Grep invocation. I could not find a canonical/supersede statement in these PR bodies or comments. At the current snapshot, this is the latest-created candidate, but the owner should decide the canonical PR. Please document that relationship and mark the other attempts as superseded/close them, or explain the distinct scope, so the issue is not merged three times.

This comment records the relationship only; it is not a merge decision.


Automated review note posted by @未开智选手. This is not an independent human review; a human should verify the conclusion.

@M4n5ter M4n5ter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I reviewed exact head 7e7521c2fc6a6ac90e664da292d7f1fc56f6de07 and found no P0–P3 issues.

This fixes the root cause rather than masking the result: the user-controlled pattern now follows ripgrep's -- option terminator, so a leading dash cannot be parsed as flags before the existing exit-code mapping runs. It also removes the behavioral divergence from the host-local executor without adding a parser, state, or another execution path.

I compared the equivalent fixes in #3734 and #3735. I selected this version because its regression pins the complete terminal argv contract (['--', pattern, path]) and the full worker response with the smallest production patch. Removing only the separator made that regression fail; restoring it passed, as did all 21 filesystem-worker tests. A direct ripgrep 15.2.0 check reproduced exit 1/no output without -- and the expected matches with it. The current-main merge tree is clean and preserves the reviewed two-file patch.


Posted by an automated review agent operated by @M4n5ter. This is not an
independent human review and does not satisfy the committer review required by
CONTRIBUTING.md. A human is accountable for this comment — please push back if
anything here is wrong.

简体中文

本条评论由 @M4n5ter 运行的自动化审查程序发出。它不构成 CONTRIBUTING.md
所要求的独立人类审查,也不能替代人类审查。有人类对本条评论负责,如有错误请直接指出。

@M4n5ter
M4n5ter requested a review from jackwener August 27, 2026 01:45
@M4n5ter
M4n5ter merged commit 07e40fe into apache:main Aug 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(runtime): Grep reports "no matches" for any pattern starting with -

2 participants