Skip to content

refactor(query): share search and Git decoding, reduce test fixture duplication - #1238

Merged
yyjeqhc merged 2 commits into
mainfrom
refactor/reduce-query-and-test-duplication
Oct 21, 2026
Merged

yyjeqhc merged 2 commits into
mainfrom
refactor/reduce-query-and-test-duplication

Conversation

@yyjeqhc

@yyjeqhc yyjeqhc commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Why

Search option construction and Git result framing were maintained twice, while common Runner and handoff test setup repeated large capability and registration literals. This makes small policy or fixture changes require synchronized edits without adding coverage.

Changes

  • Share ripgrep mode, context and glob-option construction between the server command renderer and Windows native argv builder. Keep POSIX escaping, literal Windows argv, mandatory exclusions, timeout/cancellation and backend error mapping in their existing boundaries.
  • Share the bounded trailing-frame decoder used by workspace-change and diff-hunk results. Preserve each protocol's magic, expected block sequence, metadata interpretation, byte limits and complete-prefix checks.
  • Replace repeated all-None SearchRequest test setup with a test-only Default implementation.
  • Use typed Runner capability updates and a common ordinary registration fixture. All 100 capability values in the three previously expanded fixtures remain identical; ownership, policy, generation and negative registration cases remain explicit.
  • Share nine clean-repository handoff setups and consolidate four App capability tests into a case matrix. Preserve the original assertions and all twelve capability/policy calls.

No public result/schema shape, production authorization boundary or future Agent Loop primitive is removed.

Measured reduction

Measured against 66dc9703c5714901b083f000a1b6b8d40ef7785c, after cargo fmt, including new helpers:

Scope Added Deleted Net reduction
Production Rust 113 147 34
Rust tests and support 268 1,093 825
Total physical lines 381 1,240 859

The same MSI cloc 0.6.2 used for the repository reports changed-file Rust code 22,695 -> 21,961, a 734-line reduction. Its code counter differs from physical diff lines. Most of this PR's reduction is reusable test setup, rather than removed production features.

Validation

On MSI Windows, reusing E:\git\webcodex\target:

  • Search inline/consumer tests: 64 passed.
  • Workspace-change and Git diff-hunk consumers: 107 passed, including malformed-tail, header and oversized-length cases.
  • WebSocket/QUIC fixture suites: 30 passed.
  • Runtime metadata: 51 passed.
  • Handoff: 59 passed.
  • Work-result App: 10 passed.
  • Runner native-search unit/preflight tests: 5 passed.
  • Explicit runner-real-process-tests cases for search modes/fallback and directory globs/bounds: 2 passed.
  • Total: 328 passed; no self-skip messages in the selected test logs.
  • cargo fmt --all -- --check and git diff --check.

The POSIX shell-metacharacter test and Unix producer-cleanup tests are platform gated and were not executed on MSI. They remain available to Linux CI. This PR does not claim full-workspace or cross-platform process validation.

@yyjeqhc
yyjeqhc merged commit 7b35aaf into main Oct 21, 2026
18 checks passed
@yyjeqhc
yyjeqhc deleted the refactor/reduce-query-and-test-duplication branch October 21, 2026 07:17
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.

1 participant