← Back to Pull requests

perf(runtime): advance fuzzy Edit line offsets incrementally #6050

Merged
seekskyworld merged 2 files (45 lines) on Oct 11, 2026 12:29 UTC
View on GitHub
seekskyworld seekskyworld commented on Oct 10, 2026 09:40 UTC
Author

Summary

Edit's line-trimmed fallback rescans every preceding line to locate each matching candidate. Track the source offset once as lines advance, preserving candidate selection, ambiguity errors, newline handling and line ranges. On an admitted 49,000-line repetitive fixture, median helper latency falls from 653.52ms to 4.48ms (10 samples per version; method and reproduction in the issue).

Fixes #6049

Verification

  • 64 Edit / filesystem-worker / tool-entry tests pass; the 22 Edit tests also pass on Node 22.19.0.

  • The new CPU-budget regression fails on the old implementation (2.69 CPU seconds for four edits) and passes with this change. 18,000 seeded before/after cases produce identical results or errors.

  • Repository build, typecheck, lint, format, Desktop/UI knip, ASF headers and diff checks pass.

  • Full Runtime was not entirely green: each of two runs had 3,830 pass / 14 skip / 1 failure, in different unchanged process-lifecycle fixtures (owned-child-process descendant cleanup, then shell-owner-death reading incomplete fixture JSON). The first failing case passes in isolation and its unchanged baseline suite passes 12/12. The second failing file passes 6/6 when rerun alone. These failures are retained in the validation record; no unrelated test was weakened.
  • AI use

  • No generative tool made a substantive contribution

  • Generative tooling made a substantive contribution
  • Tool(s) and scope: OpenAI Codex investigated, implemented and tested this change at @seekskyworld's direction. Final review and merge remain human decisions.

    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
  • Diff: 45 lines (+42 / -3) across 2 files Reviewer: Astro-Han Review duration: 1608m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.27) × (1 − Review Confidence (0.68)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.27 · 45 lines diff across 2 files
    0.27
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.35 · 1 substantive comment(s)
    0.35
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    67%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.229
    Real PR Conversation Timeline
    3 items
    Astro-Han Astro-Han commented on Oct 10, 2026 11:10 UTC
    Reviewer

    Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

    I found no actionable P0–P3 issue at a762ca51f269eb4f83eede95615ec7f414a6fc7b.

    The change in packages/runtime/src/edit-replace.ts:229 maintains the next line's UTF-16 offset while scanning, rather than summing the entire preceding prefix for each candidate. Advancing that offset before rejecting a nonmatch preserves the original locations; CRLF, unequal line lengths, surrogate pairs, EOF handling, uniqueness checks, fuzzy limits, and literal replacement remain unchanged. The helper is used by both the filesystem executor and worker.

    Validation: 46 Edit/filesystem-worker tests passed. An independent seeded comparison of 25,000 inputs produced identical full results or errors on the parent and this head. On the 49,000 repeated-line case, five-call median helper time fell from 9,798.71 ms to 26.51 ms in this environment; four calls consumed 30,862.07 ms versus 80.76 ms of process CPU. The parent's result exceeds the added one-second CPU guard, while this head remains below it. These are helper measurements, not end-to-end latency guarantees.

    No protocol epoch, API, dependency, or persistence change. GitHub reports this head mergeable, with successful CI and Windows packaging checks. I did not run Windows locally or repeat the entire repository test suite.

    Astro-Han Astro-Han approved these changes on Oct 11, 2026 12:29 UTC
    Approved Reviewer

    Approved at @Astro-Han's explicit request: the automated review of this exact head found no blocking (P0–P2) issues, and CI is green.

    Reviewers
    Assignees
    seekskyworld seekskyworld
    Labels
    risk: low confidence: 67.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 27.4% (LOW) · Higher = larger blast radius
    27.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 67.5% · Lower = rushed or shallow review
    67.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 8.9% · Safe to merge
    8.9%
    Repository