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. --- CS_ARTIX_DEPLOY.md | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'CS_ARTIX_DEPLOY.md') diff --git a/CS_ARTIX_DEPLOY.md b/CS_ARTIX_DEPLOY.md index 7296f8d..a942ef8 100644 --- a/CS_ARTIX_DEPLOY.md +++ b/CS_ARTIX_DEPLOY.md @@ -12,13 +12,14 @@ feature provisions that binary on **two** deployment paths automatically: There is a **third** path — the Artix cyberdeck box — that is deployed by a personal script living **outside this repo** -(`~/projects/cyberdeck/sync-dispatch.sh`). That script is not updated by this -feature and **must be edited once** (4 small additions) so the Artix box also -gets `cs`. Until then, `search_code` on the cyberdeck will return its graceful +(`~/projects/cyberdeck/sync-dispatch.sh`). That script has now been edited (the +5 small additions below) so the Artix box also gets the patched `cs`. Before the +edit, `search_code` on the cyberdeck returned its graceful `Error: search_code requires the 'cs' binary ...` message on every call. -This file documents that required follow-up. It is committed so the change isn't -forgotten; the actual edit happens in the cyberdeck repo, not here. +This file documents that follow-up (now applied). It is committed so the change +isn't forgotten and can be re-derived if the cyberdeck script is ever reset; the +actual edit lives in the cyberdeck repo, not here. --- @@ -26,8 +27,9 @@ forgotten; the actual edit happens in the cyberdeck repo, not here. `packaging/PKGBUILD` now builds a `code-search` split package (a patched, statically-linked `cs` pinned to upstream commit -`697e0bf194bbc7a4a877e5170c70618989fc92e7`, tag `v3.1.0`, plus -`docker/cs/luau-declarations.patch` for Roblox `.luau` declaration support). It +`697e0bf194bbc7a4a877e5170c70618989fc92e7`, tag `v3.1.0`, plus two patches: +`docker/cs/luau-declarations.patch` for Roblox `.luau` declaration support and +`docker/cs/fuzzy-distance.patch` for correct fuzzy edit-distance matching). It installs `cs` to `/usr/bin/cs`. `code-search` is a plain static binary with **no init-system coupling**, so it @@ -43,11 +45,13 @@ and does not yet include `code-search`. --- -## The required edit to `~/projects/cyberdeck/sync-dispatch.sh` +## The edit applied to `~/projects/cyberdeck/sync-dispatch.sh` -Four small additions. After applying them, run `sync-dispatch.sh --build` (the -`--build` flag rebuilds the packages first, producing the new -`code-search-*.pkg.tar.zst`). +Five small additions (the four below plus mirroring `PKG_CS` into the generated +remote-script preamble alongside `PKG_DISPATCH` / `PKG_S6`). This edit has been +applied. To deploy, run `sync-dispatch.sh --build` (the `--build` flag rebuilds +the packages first, producing the new `code-search-*.pkg.tar.zst` that now +carries both the Luau and fuzzy patches). ### 1. Declare the package name (next to `PKG_DISPATCH` / `PKG_S6`) @@ -111,6 +115,10 @@ For a `.luau` sanity check (confirms the Luau patch is present), search a Roblox project with `only: "declarations"` — `function` / `type` / `export type` lines should be detected. +For a fuzzy sanity check (confirms the fuzzy patch is present), a mid-word +deletion should match, e.g. `cs -- 'computSlipAngle~1'` finds `computeSlipAngle` +(returns empty on an unpatched cs). + --- ## If you ever decouple `cs` from this repo -- cgit v1.2.3