Add exact-case literal matching without changing folded APIs

perfloop-oss/casei · UNCATALOGUED MECHANISM

https://perfloop.ai/t/oss/case_tn4v1r4hzf

Verdict

VERIFIED · settled 2026-10-11 · merged as tsenart/casei#33

What happened: The assertion is satisfied with this change.

Hypothesis

Enable the requested case-sensitive substring and literal-set searches without changing folded callers. One immutable exact factory can reuse Matcher,Find and Each. This establishes missing library capability,not sensitive field leadership.

The subject is newSearchPlan908–976,the actual shared compiler. Accepted entry_3ztw6q42tx begins its construction path and belongs to wl_rm7b2eq898. Public NewMatcher35 calls this definition. It currently always builds fold tokens and records original IDs. Use byte-identity compilation for an additive NewExactMatcher factory returning the existing Matcher;do not introduce a second public result type or mutable mode.

The required contract is raw byte substring equality for1–64 patterns of1–64 bytes. Find picks earliest byte start then lowest original ID,including prefix/duplicate/empty ties. Each consumes that pattern's byte width,never overlaps,honors stop,and advances one byte after empty results until EOF. Byte-fragment needles may match inside valid UTF8 in exact mode. This is the proposed new edge contract for review,not an old-defect claim. Keep copied patterns and immutable compiled state safe under concurrent/nested reads.

NewMatcher and IndexFold retain Unicode simple folding,opaque semantics and current empty progress. Require their native and exercised portable oracle agreement on width-changing folds,Kelvin,long-s,sigma and malformed inputs. The expected API addition is one documented factory and its compatibility obligations,no new public type/configuration.

The bound is sensitive library capability plus ordering,widths,empty/malformed and portable obligations. All twelve sensitive cells still need real oracle/candidate/entrant mode wiring: current preparation hardcodes folding and skips them. Canonical reporting and broader sensitive population remain separate. IndexFold remains folded;this proposal does not silently reinterpret its name or invent a sensitive board operation. No speedup is claimed.

Raw byte equality is the intended sensitive contract,and an immutable exact factory can share the existing Matcher without changing folded API semantics.

Implement exact construction and independently check public Find/Each against a raw-byte oracle for the required1–64 pattern/byte population and four corpora. Require earliest-byte/lowest-ID prefix,duplicate and empty ties,non-overlap,exact widths,byte fragments,malformed/nil inputs,one-byte empty progress through EOF,callback stop,nested/concurrent safety. Exercise applicable native paths and actual portable fallback. Separately require unchanged NewMatcher/IndexFold simple-fold results. Exact mismatch,mode leakage,changed folded contract or unsafe access rejects this implementation. Passing library proof does not certify sensitive entrants,timings or aggregate targets.

Only the source occurrence changes from the refused arriving hop to the compiler's accepted ordinary entry. No exact implementation or sensitive measurement was run. Raw-byte/empty edge semantics are a frozen proposed contract requiring documentation. The accepted construction workload currently names the folded factory;the operator requests its exact counterpart. Board andfield mode wiring need their real execution owners throughMap/Triage,no inverse library→benchmark edge.

Change to test: Add NewExactMatcher returning the existing Matcher,compiling immutable byte-identity literals rather than fold-token classes. Preserve NewMatcher and IndexFold folding;implement exact Find/Each with original-ID priority,byte widths and byte-progress empty enumeration.

Where it lives

perfloop-oss/casei · plan.go

Evidence

The assertion is satisfied with this change: `On Linux/amd64, NewExactMatcher.Find and Each agree with an independent raw-byte oracle over the generated 1–64 pattern-count and 1–64 byte-width grid on repository prose, code, logs, and Russian corpora, including earliest-byte/lowest-ID prefix, duplicate, and empty ties, exact widths, non-overlap, UTF-8 byte fragments, malformed/nil inputs, byte-by-byte empty progress through EOF, callback stop, copied patterns, and nested/concurrent reads; NewMatcher.Find and Each preserve Unicode simple-fold match offsets and enumeration widths (including width-changing Kelvin and long-s), opaque malformed-byte handling, and empty progress for Kelvin, long-s, sigma, and malformed inputs; IndexFold preserves the corresponding first folded byte offsets for those cases. All folded checks run under default and AVX-disabled dispatch.`

The assertion is satisfied with this change: `When built for Linux/arm64 so root_other.go supplies the portable implementation and run under qemu-aarch64, NewExactMatcher.Find and Each agree with an independent raw-byte oracle over the generated 1–64 pattern-count and 1–64 byte-width grid on repository prose, code, logs, and Russian corpora, including earliest-byte/lowest-ID prefix, duplicate, and empty ties, exact widths, non-overlap, UTF-8 byte fragments, malformed/nil inputs, byte-by-byte empty progress through EOF, callback stop, copied patterns, and nested/concurrent reads; NewMatcher.Find and Each preserve Unicode simple-fold match offsets and enumeration widths (including width-changing Kelvin and long-s), opaque malformed-byte handling, and empty progress for Kelvin, long-s, sigma, and malformed inputs; IndexFold preserves the corresponding first folded byte offsets for those cases.`

Checks: 10 of 10 passed. Verification: no defect found.

Timeline