Skip to content

fix(planner): check double-quoted expansion in linear time - #302

Merged
adityankale190895 merged 1 commit into
DiffCI:mainfrom
FredApps:fix-split-parts-quadratic-quote
Nov 18, 2026
Merged

adityankale190895 merged 1 commit into
DiffCI:mainfrom
FredApps:fix-split-parts-quadratic-quote

Conversation

@FredApps

Copy link
Copy Markdown
Contributor

Fixes #300

splitParts() in src/planner/pipeline-steps.ts used /"[^"]*[$][^"]*"/to decide whether a script part has a$or backtick between double quotes. When a part has a"followed by a long run of backticks and no closing quote, the regex backtracks quadratically: 100,000 backticks took 12.9 s indiscoverGateChecks(). Because of this, tests/fuzz/repository-text.fuzz.test.tsfailed at random, for example on #291 with seed-1959240610`.

Change: expandsBetweenDoubleQuotes() splits the part on " and checks the inner segments for $ or a backtick. It makes one pass and gives exactly the regex's answer: a match needs a $ or backtick with a " on each side and no " in between.

Tests

  • A new fuzz property ("linear rewrites agree with the regexes they replaced") checks the function against the old regex over strings built from ", $, `, ', a and space.
  • tests/planner/pipeline-steps.test.ts times the shrunk counterexample shape (tsc && "" plus 100,000 backticks) against a 1 s budget. It still keeps the script whole.

Local checks:

  • npm run typecheck, npm run build, npm run audit:boundary and npm run agent:check
  • npm test: 1169 pass
  • The fuzz file passes with FC_SEED=-1959240610 and with seeds 1, 2, 3 and 42.

Both changed files are already in release-files.json.

Found while getting CI green on the docs PRs #287, #289 and #291.

splitParts asked /"[^"]*[$`][^"]*"/ whether a script part has a $ or
backtick between double quotes. On a quote followed by a long run of
backticks with no closing quote the regex backtracks quadratically
(100,000 backticks: 12.9 s), so the repository-text fuzz test failed at
random. Split on the quotes instead and look at the inner segments: one
pass, same answers. A fuzz test checks it agrees with the regex, and a
regression test times the counterexample.

Fixes DiffCI#300

Signed-off-by: FredApps <[email protected]>
FredApps added a commit to FredApps/core that referenced this pull request Nov 18, 2026
@FredApps
FredApps marked this pull request as ready for review November 18, 2026 00:55
FredApps added a commit to FredApps/core that referenced this pull request Nov 18, 2026
adityankale190895 pushed a commit that referenced this pull request Nov 18, 2026
* docs: say Rust is supported experimentally in the roadmap

The roadmap listed Rust with Django, PHP and Gradle as not yet
supported, while the Rust (Cargo) adapter is registered and the README,
release boundary and quickstart describe it as experimental. Say so,
with the README's caveat, and keep only Django, PHP and Gradle as next.

Fixes #290

Signed-off-by: FredApps <[email protected]>

* ci: re-run after an unrelated fuzz failure (#300)

Signed-off-by: FredApps <[email protected]>

* ci: re-run after an unrelated Windows Python interpreter flake

Signed-off-by: FredApps <[email protected]>

* ci: re-run checks after the Windows fuzz-timing flake (#300, fixed by #302)

Signed-off-by: FredApps <[email protected]>

---------

Signed-off-by: FredApps <[email protected]>
@adityankale190895
adityankale190895 merged commit 3dca53b into DiffCI:main Nov 18, 2026
13 checks passed
adityankale190895 pushed a commit that referenced this pull request Nov 18, 2026
…rs (#257)

* fix(impact): treat modelled Python files as code when resolving readers

resolveByReference passed isSourceFilePath as isCodeFile, which does not include .py. A pytest test that reads a changed data file was therefore followed as a script; nothing names a test file, so the change selected no tests and did not fall back. Python files the adapter modelled now count as code, so the reading test is selected, and a helper that reads the file selects the tests that import it.

Signed-off-by: FredApps <[email protected]>

* chore: move the release-files.json entry so it merges cleanly with #205, #207 and #209

The manifest is an unordered set, and the PRs listed above add their entries at the same line. Moving this entry one line away lets them merge in either order without a conflict.

Signed-off-by: FredApps <[email protected]>

* ci: re-run checks after the fuzz-timing flake (#300, fixed by #302)

Signed-off-by: FredApps <[email protected]>

---------

Signed-off-by: FredApps <[email protected]>
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.

Planner: splitParts regex is quadratic on a quote followed by many backticks, so the fuzz test fails at random

2 participants