Skip to content

fix(search): bound replacement output before publication - #343

Merged
T-Auto merged 3 commits into
mainfrom
work/330-ccch1mneyyy
Oct 21, 2026
Merged

T-Auto merged 3 commits into
mainfrom
work/330-ccch1mneyyy

Conversation

@ccch1mneyyy

@ccch1mneyyy ccch1mneyyy commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #330

What was wrong

ops_replace bounded match counts but not the resulting file size. A 40 KB source containing 40,000 a characters and a 1 KiB replacement produced 40,960,000 bytes, beyond the 32 MiB file-write ceiling. Checking only during publication would also leave earlier directory targets changed before a later oversized target failed.

The change

  • Export and reuse the existing ops-files 32 MiB file-content constant, rather than duplicate the limit.
  • Compute each planned output's UTF-8 byte size with checked multiply/subtract/add operations before constructing replacement content or publishing any file. Overflow and over-limit plans return OUTPUT_LIMIT with no file changes.
  • Apply the same planning bound to previews; exactly 32 MiB remains supported. Keep maxReplacements, existing revision/locking behavior and mutation authority unchanged.
  • Add arithmetic unit coverage and real-worker boundary, multibyte and multi-file regressions. Update paired component docs and changelog; no new dependency or tool-schema change.

Validation

cargo test --workspace --locked --manifest-path native/Cargo.toml
  43 Rust unit tests passed, 0 failed, 0 ignored
  includes replacement boundary, shrink and arithmetic overflow cases

npm run build && npm run build:ptc
  rebuilt/staged the modified worker; passed

DSH_OPS_REQUIRE_RUNTIME=1 node test/run.mjs replace-size linux-args replace-concurrency
  3 suites passed, 0 skipped, 0 failed
  replace-size: all 3 checks passed
  exact 32 MiB accepted; +1 byte rejected
  UTF-8 bytes (not character count) enforced
  later oversized directory target leaves earlier files unchanged
  preview and execution both covered

node scripts/verify-gate.mjs --skip-install
  linux-x64: gate green
  125 suites passed; 2 skipped (optional external tui-host/tui-native)
  manifest: 73 checks (minimum 59)
  packed release and runtime closure: passed

Red/green using the unmodified main worker:
  replace-size: 3 of 3 checks fail
  fixed, rebuilt worker: all 3 checks pass

The full gate uses the real Landlock backend to separate main's unrelated bwrap cache defect (#337/#338); no sandbox permission relaxation is introduced. Input/output schema and model-description byte delta: 0.

PR-triggered CI: https://github.com/T-Auto/dsh-ops/actions/runs/39480498372 — pull_request, aggregate CI required: SUCCESS (Windows x64, Linux x64, macOS arm64 and required supporting jobs passed).

Environment

Arch Linux x64, Node 24.21.0, Rust 1.97.1; source checkout based on main a9ff940.

Combined local validation

The submitted heads of #338, #340, #341, #342, #343, #344 and #345 were applied together in an isolated local verification worktree, including their combined changelog entries. With ordinary PATH selecting real bwrap 0.13.0 and real dsh-TUI 0.16.1 host/worker/renderer suites enabled, node scripts/verify-gate.mjs --skip-install passed all 11 release-gate steps: 129 suites passed, 0 skipped; 46 Rust unit tests passed; manifest 73/59. This Linux combined-tree evidence is separate from each PR's own cross-platform CI; no upstream merge or host installation was performed.

@T-Auto
T-Auto merged commit 656e253 into main Oct 21, 2026
9 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] ops_replace 无产出大小上限:41 KB 请求可写出 39 MB,write_file 有 32 MiB 检查而 replace 没有

2 participants