Skip to content

perf(read): symmetric 80/80 cap + passthrough allowlist + escape-hatch marker + stdin coverage - #15

Merged
thehoff merged 1 commit into
developfrom
fix/read-unknown-ext-token-cap
May 18, 2026
Merged

thehoff merged 1 commit into
developfrom
fix/read-unknown-ext-token-cap

Conversation

@thehoff

@thehoff thehoff commented May 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

The upstream rebase (#14) implemented the unknown-extension cap and JSON-like routing for .xcstrings/.geojson/.ipynb/.webmanifest/.code-workspace. This PR closes the remaining gaps to fully resolve #12:

  1. Symmetric 80/80 head/tail default (was 80/20). Final assertions, imports-at-bottom, and result lines deserve equal weight to the file's opening.
  2. passthrough_extensions: Vec<String> on ReadConfig — users list source-code extensions contextcrawler doesn't yet filter (e.g. [".svelte", ".astro", ".zig"]) so the cap never truncates an editable source file mid-function. Accepts entries with or without leading dot.
  3. Two-line marker with escape hatch — replaces the single dense info-line. Visually-unmissable divider + info line that tells the reader how to recover full content via contextcrawler proxy cat <path>.
  4. Stdin coverage — run_stdin() now applies the cap with "(stdin)" as display path. cat huge.xcstrings | rtk read - gets the same protection.
  5. .workspace extension added alongside upstream's .code-workspace (JetBrains/Theia workspace files are also JSON).

Reviewed by Codex (earlier draft)

  • P2: stdin path bypassed cap → fixed (item 4 above)
  • P3: .code-workspace extension matching → codex was technically wrong (Path::extension() does return code-workspace for settings.code-workspace), but added .workspace alias for completeness

Test plan

  • cargo test --bin contextcrawler — 1993 passed, 0 failed (+5 new)
  • New tests: symmetric defaults, allowlist with/without dot, stdin cap, workspace extension, two-line marker structure
  • Rewrote upstream's test_render_output_unknown_extension_cap to assert structural properties (head verbatim, divider line, info line with escape hatch, tail verbatim) rather than brittle exact-string match

Closes #12

…h marker + stdin coverage (#12)

The upstream rebase (#14) implemented the unknown-extension cap and the
JSON-like extension routing for `.xcstrings`/`.geojson`/`.ipynb`/etc., so
those parts of #12 are now resolved upstream. This commit closes the
remaining gaps:

1. **Symmetric defaults**: `tail_lines` 20 → 80. Final assertions,
   imports-at-bottom patterns, and result lines deserve the same surface
   area as the file's opening.

2. **Passthrough allowlist**: new `passthrough_extensions: Vec<String>` on
   `ReadConfig`. Users can list source-code extensions that contextcrawler
   doesn't yet filter (e.g. `[".svelte", ".astro", ".zig"]`) so the cap
   never truncates an editable source file mid-function. Accepts entries
   with or without the leading dot.

3. **Two-line marker with escape hatch**: replaces the single dense
   info-line with a visually-unmissable divider plus an info line that
   tells the reader how to recover full content
   (`contextcrawler proxy cat <path>`). An LLM seeing the marker can
   self-recover without needing prior knowledge of the cap. Threaded
   `display_path` through `render_output` and the cap helper.

4. **Stdin coverage**: `run_stdin()` now passes `allow_unknown_cap=true`
   with `"(stdin)"` as the display path. `cat huge.xcstrings | rtk read -`
   gets the same protection as direct reads. (Addresses the codex review
   comment on the earlier draft of this PR.)

5. **`.workspace` extension**: JetBrains/Theia project workspace files are
   also JSON-structured; added to `Language::Data` alongside the upstream
   `.code-workspace` entry.

Tests: 5 new (default values, allowlist with/without dot, stdin cap,
`workspace` extension, two-line marker structure). Existing
`test_render_output_unknown_extension_cap` rewritten to assert structural
properties (head verbatim, divider line, info line with escape hatch,
tail verbatim) rather than a brittle exact-string match. All 1993 binary
tests pass.

Closes #12

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Codex review <[email protected]>
@thehoff
thehoff force-pushed the fix/read-unknown-ext-token-cap branch from 56743b9 to 9a034d0 Compare May 18, 2026 05:35
@thehoff thehoff changed the title perf(read): route JSON-ish extensions to Data + cap unknown-extension files perf(read): symmetric 80/80 cap + passthrough allowlist + escape-hatch marker + stdin coverage May 18, 2026
@thehoff
thehoff merged commit da4ad80 into develop May 18, 2026
3 checks passed
@thehoff
thehoff deleted the fix/read-unknown-ext-token-cap branch May 18, 2026 05:36
thehoff added a commit that referenced this pull request May 18, 2026
…/MD reports (#29)

First tier of the three-tier bench harness scoped in #29. Standalone
test that invokes the built contextcrawler binary as a subprocess with
`RTK_DB_PATH` pointed at a fresh tempfile, so the user's real tracking
DB (`~/Library/Application Support/rtk/history.db`) is never touched.

Verified isolation: live DB row count stayed at 4202 across two harness
runs that internally invoked the binary four times each.

**Cases (against `tests/fixtures/bench/*`):**
- `read_short_passthrough` — small file, exercises the no-cap-fires path
- `read_large_unknownext_cap_fires` — 500-line .unknownext, exercises
  the #15 symmetric 80/80 cap. Empirical: 7000 → 2262 tokens, 67.7%
  savings. Assertion floor 50%.
- `read_xcstrings_json_route` — synthetic Xcode strings file, exercises
  JSON-like extension routing through the JSON compactor (NOT the
  unknown-ext cap). Empirical: 1807 → 389 tokens, 78.5% savings.
  Assertion floor >0%.
- `read_rust_minimal_filter` — code file with comments. Currently
  reports 0% (default FilterLevel doesn't strip on this case); kept as
  a baseline so a future change that enables aggressive filtering can
  measure the lift.

**Aggregate first run on develop tip 5cc6da3: 69.1% weighted savings
across 8912 input tokens.** This is the baseline future runs compare
against.

**Output:**
- `bench/results-<git-sha>.json` — machine-readable, for pre/post diff
- `bench/results-<git-sha>.md` — human-readable, PR-diff-friendly
- Both gitignored under `bench/results-*.{json,md}` so accumulating
  reports don't pollute the tree

**Reproducibility:** same fixtures → same numbers within tolerance.
Bisectable across binary commits.

Hard regression gates:
- Every case must exit 0
- Cap case savings must stay ≥50% (currently 67.7% — 17pp headroom)
- xcstrings case must save tokens (currently 78.5% — far above floor)

Softer gates (delta against `bench/baseline.json`) deferred to a
follow-up so this PR stays focused on the harness scaffolding.

**Tier 2 (Claude Code) + Tier 3 (Codex) deferred** to follow-up PRs
per the #29 build order. Tier 3 will subsume issue #28's
`codex-compliance` measurement.

Tests: 1 new harness + 2 branding-lint + 2027 bin = all pass.

Refs #29
noogalabs pushed a commit to noogalabs/contextcrawler that referenced this pull request Jun 4, 2026
… branding-lint extension

**Version bump 0.39.0 → 0.1.7.** The upstream rebase pulled in rtk's
`0.39.0` version; restoring the downstream `0.1.x` numbering line per
the maintainer's call. `.release-please-manifest.json` updated to
match. Last downstream tag was `v0.1.6` (2026-05-15); this is the
next in the sequence.

**release-please-config.json `package-name: "rtk"` → "contextcrawler".**
Caught by manual audit during release prep. Same regression-family as
thehoff#19 / thehoff#20 / thehoff#22: a rebrand gap the prior branding-lint (src/-scoped)
didn't catch because release-please-config.json lives at repo root.
Without this fix, release-please would have produced `rtk-vX.Y.Z`
tags and release-PR titles.

**Cargo.toml `extended-description` rebrand.** Line 77 still read
"rtk filters and compresses..." — same upstream-leak family. Fixed.

**Extended `tests/branding_lint.rs`** with a third test —
`branding_lint_config_files_pin_canonical_package_name` — that:
- Parses Cargo.toml and asserts `[package].name == "contextcrawler"`
- Parses release-please-config.json and asserts
  `packages["."]["package-name"] == "contextcrawler"`

This closes the gap that let release-please-config.json silently drift
to `"rtk"` post-rebase. Any future rebase that re-introduces an
upstream package-name fails `cargo test --test branding_lint` with an
explicit error pointing at issues thehoff#19/thehoff#20/thehoff#22 history.

**CHANGELOG.md** entry for v0.1.7 added, summarizing all PRs merged
today (thehoff#10 thehoff#15 thehoff#16 thehoff#21 thehoff#24 thehoff#25 thehoff#30) plus the deferred follow-ups
(thehoff#26 thehoff#27 thehoff#28 thehoff#29).

Tests: 2027 bin + 3 branding-lint (1 new) + 1 harness = all pass.
Verified: `contextcrawler --version` now prints `contextcrawler 0.1.7`.

Refs thehoff#19 thehoff#20 thehoff#22 thehoff#29
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.

perf(read): .xcstrings (and similar JSON-ish) files bypass filter; add unknown-extension token cap

1 participant