From 80212bfb009eaf71a4743310dee6ed08b8f7e1da Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Tue, 2 Jun 2026 20:46:23 +0900 Subject: fix(search_code): fuzzy mid-word matching + Luau/fuzzy live test coverage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address the remaining real defects from the Luau/cs test reports. The wrapper- level findings (dash-leading queries, context flag, no-match message, empty query, path-is-file) were already fixed in earlier commits and verified through the tool; the two genuinely-open items were engine-level, plus a test-coverage gap (the patch-dependent behaviors were only exercised by live tests that skip without a cs binary). - Engine fix (docker/cs/fuzzy-distance.patch): cs's fuzzy `term~N` only scanned same-length windows, so it matched substitutions but never mid-word insertions/deletions — e.g. `computSlipAngle~1` (a dropped 'e') failed to find `computeSlipAngle`, contradicting cs's own "within 1 or 2 distance" docs. Now scan windows of length termLen±maxDist (true Levenshtein) and keep the best per offset. Updates one pre-existing cs test that encoded the buggy substitution-only behaviour and adds mid-word insert/delete cases. Passes cs's pkg/search + pkg/ranker suites; builds clean against the pinned commit. - Provisioning: apply the new patch everywhere the Luau patch is applied — Dockerfile, Dockerfile.dev, packaging/PKGBUILD build() — so every install path (Docker bin/up, native code-search package via bin/service install) ships both patches. - Tests: add skip-gated live tests for Luau declaration detection (function / local function / type / export type), only=usages exclusion, the Luau language tag, and fuzzy mid-word matching. New capability probes (findLuauCapableCs / findFuzzyCapableCs) run these only on a cs that actually has each patch and skip (never fail) on an unpatched/absent binary. Default suite: 600 pass / 12 skip; with a both-patched cs: 612 pass / 0 skip. - Docs: UPSTREAM_CS_FUZZY_BUG.md documents the unreported upstream defect for a potential boyter/cs PR; CS_ARTIX_DEPLOY.md updated to reflect that sync-dispatch.sh now ships the code-search package (carrying both patches). biome + tsc (core/api/frontend) + svelte-check all green. --- Dockerfile.dev | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Dockerfile.dev') diff --git a/Dockerfile.dev b/Dockerfile.dev index 52b1aa2..94d30fb 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,16 +1,19 @@ # --- cs (code spelunker) builder --- # Builds a patched, statically-linked `cs` binary for the search_code tool. # Pinned to the v3.1.0 commit for reproducibility; the patch adds Luau -# declaration support (see docker/cs/luau-declarations.patch). cs vendors its +# declaration support and corrects fuzzy edit-distance matching (see +# docker/cs/luau-declarations.patch and docker/cs/fuzzy-distance.patch). cs vendors its # dependencies, so the `go build` step is offline after the clone. FROM golang:1.25-bookworm AS cs-builder ARG CS_COMMIT=697e0bf194bbc7a4a877e5170c70618989fc92e7 WORKDIR /build COPY docker/cs/luau-declarations.patch /tmp/luau-declarations.patch +COPY docker/cs/fuzzy-distance.patch /tmp/fuzzy-distance.patch RUN git clone https://github.com/boyter/cs.git src \ && cd src \ && git checkout "${CS_COMMIT}" \ && git apply /tmp/luau-declarations.patch \ + && git apply /tmp/fuzzy-distance.patch \ && CGO_ENABLED=0 go build -mod=vendor -ldflags="-s -w" -o /usr/local/bin/cs . \ && /usr/local/bin/cs --version -- cgit v1.2.3