* fix(rename): bind apply to reviewed plans (U7) Retain exact semantic edits behind single-use preview tokens and reject source, target, inventory and graph drift before application. Preserve explicit partial-write accounting and keep large unedited sources covered with hashes instead of retained text. Refs #2973 * fix(rename): cover unindexed sources (U7) Address PR #3617 review by binding every supported source to streamed byte hashes and canonical targets, including tracked and untracked files absent from the graph. Keep the exact reviewed edits and bound evidence memory. Use conventional even-sample medians and extend the existing CI benchmark to capture and validate unindexed sources without relaxing timing gates. Note: pre-existing packed Tree-sitter GLIBCXX_3.4.31 host failure in parse-cache-identity-package.test.ts is not addressed by this PR. * fix(rename): preserve lazy startup (U7) Keep language providers off the MCP startup path; load their existing classification only when rename inventory is requested. The existing 12 startup closure checks now pass. Address PR #3617 review by including token validation in reviewed apply timing and growing indexed evidence before preview, preserving the 20MiB controls under a 256MiB native pool. Migrate dispatch and retention tests to the preview token contract, keeping write-failure oracles. Note: pre-existing auto-sync /tmp fixture security and installed ARM64 grammar-header failures remain outside this PR; the packed Tree-sitter GLIBCXX_3.4.31 host failure also reproduces on unchanged main. * test(rename): always remove apply fixture (U7) Own the temporary directory from creation in an outer finally so setup and preview assertions cannot bypass cleanup. Keep spy restoration in its inner finally and preserve all write-failure assertions. Address PR #3617 cleanup feedback. * fix(rename): retain targets and config evidence * test(rename): verify approved physical output * test(rename): cover native filesystem matrix * test(rename): align preview contract fixtures --------- Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com> |
||
|---|---|---|
| .. | ||
| measure.mjs | ||
| README.md | ||
Semantic rename benchmarks
Run from gitnexus/:
node --import tsx bench/rename/measure.mjs
node --import tsx bench/rename/measure.mjs --check
The harness executes prepared semantic plans against real temporary files. It checks exact output, edit counts, line numbers, UTF-16 offsets and CRLF reports; previews must preserve the source. Native parsing and graph resolution are covered by the per-language persisted integration suites, rather than included in the construction timings below.
A second workload runs the whole semantic planner (planGraphRename: parsing,
scope resolution, provider receiver proofs, rewrite validation and before/after
binding verification) over one generated TypeScript module. It renames a method
called 2,000 and then 8,000 times from receivers constructed in 20-call
functions, and checks that the produced edits rewrite exactly the declaration and
every call. The normalized planning ratio must stay below 2. This catches
per-occurrence rescans of a file's occurrences, syntax tree or edit list, which
make planning quadratic in file size while leaving small fixtures untouched.
The preview workload grows from 1,000 to 4,000 edits. The normalized scaling ratio must stay below 2, and the large preview must remain below a generous one-second ceiling. These gates catch a return to repeated whole-string copying or repeated prefix line counting. The 100-source, eight-edited-file apply case reports median time without a filesystem timing gate.
A local Node 22.18.0 comparison on PR #3557 measured:
| Workload | Before | After |
|---|---|---|
| 1,000-edit preview | 175 ms | 4.3 ms |
| 4,000-edit preview | 2,823 ms | 13.8 ms |
| Normalized preview scaling | 4.03 | 0.80 |
| Apply: 100 sources, eight edited files | 278 ms | 101 ms |
These are local prepared-plan measurements, not end-to-end indexing timings.
Reviewed previews retain source text only for edited files. Other supported sources, including existing files absent from the index, retain SHA-256 hashes and canonical targets. Validation streams those files in 64 KiB chunks and batches at most eight concurrent reads before each atomic replacement. I/O remains proportional to source count times edited-file count; retained text is proportional to edited source bytes. The shared package contains no filesystem or native-parser adapter.
The harness reports conventional medians (the mean of the two middle samples
for even sample counts), retained text bytes, and preview retention/validation
with 100 and 400 sources. An additional pair leaves half the sources unindexed
to measure their evidence capture. Both 400-source validation cases must stay
below one second and a normalized scaling ratio of 2.5. Reviewed application
also has a one-second ceiling. The existing rename step in ci-tests.yml runs
all these checks with --check.
Reviewed application includes capability consumption and its configuration validation, approved-target checks, staging and installation. It uses the real provider configuration loader and asserts exactly two apply-time refreshes: at capability validation and before the first installation. Configuration discovery therefore stays independent of edited-file count. Source bytes and targets still receive per-replacement checks; these filesystem operations are not a transaction.