Repository navigation
perf(distribution): replace grep control-char check with Bash cntrl class - #358
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Claude finished @kyle-sexton's task in 5m 15s —— View job Claude's review of #358Todo list
SummaryThe core change (
One finding posted inline on
Verification noteI read and traced the logic by hand and ran |
|
Claude has reviewed this PR 1 time. The lane skips further automatic reviews after 5; deleting this comment resets the count. |
29154df to
890ff0f
Compare
…l:]] Replace the printf|grep spawn in is_safe_repo_path with a Bash pattern test ([[ $path == *[[:cntrl:]]* ]]), removing ~109 grep process spawns per validate run (issue #316 part 2). Add distribution/fixtures/control-char-equivalence.tsv and control-char-equivalence.test.sh proving grep [[:cntrl:]] regex and Bash glob agree for all 256 single-byte embeddings under LC_ALL=C, except byte 10 (LF): grep line mode misses embedded newlines while Bash correctly rejects them. Part 1 (Git index batching in tracked_regular_mode) remains for a follow-up. Co-authored-by: Kyle Sexton <[email protected]>
890ff0f to
18e3cd4
Compare
- Rename control-char-equivalence.test.sh to control-char-equivalence.sh - Keeps helper out of harness *.test.sh auto-discovery glob Co-authored-by: Kyle Sexton <[email protected]>
|
Resolved Claude nit in 0f4ceb9: renamed Commit signature verified ( |
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary Closes #316 (Part 1). Part 2 (grep → Bash `[[:cntrl:]]` control-char check) already landed in #358. Batches `git ls-files --stage` and `git hash-object` so production `validate` uses one of each instead of per-path spawns. Exact recorded-path attribution is preserved. ## Test plan - [x] `bash distribution/sync-manifest.test.sh` - [x] Nested-prefix fixture + spawn-counting shim - [ ] CI green on merge ## Related Closes #316 <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-e95c74ba-a1a6-4270-b3db-3938d8c4f19e?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-e95c74ba-a1a6-4270-b3db-3938d8c4f19e&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: Kyle Sexton <[email protected]>
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> No related issue: remaining Bash spawn N+1 after #316/#361, ranked by spawn census rather than file size. ## Summary Measurement-first Bash performance pass, following the fleet `performance@melodic-software` plugin (spawn count over wall clock, stable PATH shim, interleaved repeats) and the patterns already landed in #320/#358/#361. `distribution/sync-manifest.sh` is already a Node wrapper; this change does not touch it. Highest-impact remaining subjects on this repo, in order: 1. `check-exec-bit.sh`: **133 → 4** process spawns (**git 131 → 2**) against 65 shebang-looking blobs. 2. `scan-comment-hygiene.sh`: **81 → 3** (**awk 77 → 0**) — one awk per git-grep hit. 3. `check-machine-specific-paths.sh`: **10 → 1** (**git 5 → 1**, **head 5 → 0**). 4. `scan-workflow-files.sh`: **yq 11 → 1** on the success path (CI glob is 11 workflow files). 5. `check-plugin-baseline.sh --compare`: **jq 5 → 3**. 6. cloud-bootstrap warm path: **5 Claude list CLIs → 2**. 7. `setup.sh` plugin stage (fleet+repo, warm): **4 Claude list CLIs + N grep → 2** (same list-once shape as cloud-bootstrap). 8. `check-claude-settings-targets.sh --file`: **jq 3 → 2** on the success path. 9. `check-heading-cites.sh`: drop the identity `cat` when `EXCLUDE` is empty. Host qualification (`bash -c true`, n=20): spread 1.66× (measurable). Headline metric is still the drift-immune spawn counter. ## Fix - **exec-bit**: one `git grep --cached -z -nIE '^#!'` (line 1 ≡ byte-0 shebang) plus one `git ls-files --stage -z` with exact-recorded-path mode lookup. POSIX awk join (bash 3.2: no `declare -A`). Combined `-z -n` emits `path NUL lineno NUL text LF` (git 2.43 byte dump; git-grep(1) only mentions pathname delimiting). The 100644 shebang case fails closed; a contract test pins that record via `tr '\0' '|'`. - **comment-hygiene**: `chp::scan_text` matches the comment-start pattern in-process for newline-free content (the local-lane git-grep hit shape). Multi-line callers still use one awk. - **machine-specific-paths**: one combined `git grep -E` over the five OS/repo bodies; classify hits in-process so per-OS labels and the 20-line cap stay without a second grep or `head`. - **heading-cites**: split the corpus pipeline so an empty `EXCLUDE` does not spawn `cat`. - **check-plugin-baseline `compare_settings`**: one tagged jq pass, matching `compare_catalog` and the #320 yq consolidation. - **cloud-bootstrap**: list marketplaces and plugins once; record installs locally; re-list marketplaces only when this session registered a new one. Materialized `.claude/cloud-bootstrap.sh` stays byte-identical to the component. - **setup.sh plugin stage**: share one `marketplace list` and one `plugin list` across fleet+repo; in-process membership instead of `grep -qxF` per entry; record new installs so the second source does not re-query. Toolchain tracks (apt/dotnet/nvm) are unchanged. - **settings-targets**: one jq policy pass on the success path; `jq empty` on the candidate runs only when that pass fails, so parse errors stay exit 2 and policy misses stay exit 1. - **pin-comment**: one `yq eval --no-doc` over every existing workflow argument on the success path (`filename` operator; without `--no-doc`, `---` document separators are misread as records). Mike Farah yq 4.53.3 multi-file `eval` still stops at the first parse error and has no `try`/`catch`, so a failed batch falls back to per-file `pcc::scan_text` and still reports every file. Left unchanged after census (already at floor, tiny corpus, or I/O-dominated): `sync-manifest` Node engine, setup.sh apt/dotnet/nvm, private-repo-inventory (tiny TOML), `repin::ahead_of` (release-time, small N). ## Verification - `bash harness/shell/run-tests.sh` — previously 19 passed, 0 failed, 16 skipped on the earlier commits; this revision adds spawn-census coverage in `pin-comment-convention.test.sh`. - `comment-hygiene.test.sh`: 8 single-line scans awk=0; multi-line fixture awk=1 - `local-lane-guards.test.sh`: exec-bit 8-file git shim (grep=1, ls-files=1, cat-file=0); 100644 shebang fails closed; `git grep -z -n` layout `bad.sh|1|#!/usr/bin/env bash`; machine-paths git=1 head=0; comment-hygiene driver awk=0; start-of-line Linux home still labeled - `check-plugin-baseline.test.sh`: `--compare` jq=3 - `cloud-bootstrap.test.sh`: warm path marketplace-list=1, plugin-list=1; copies identical - `setup.test.sh`: fleet+repo warm path marketplace-list=1, plugin-list=1, marketplace-add=0, plugin-install=2 (beta+gamma); `bash -n` and stamp-after-wait contracts unchanged - `check-claude-settings-targets.test.sh`: `--file` success-path jq=2; malformed candidate still exits 2 - `pin-comment-convention.test.sh`: 8 conforming files yq=1; parse-error fallback still reports a later missing-comment (batch + per-file yq=4) | subject | before | after | | --- | --- | --- | | `check-exec-bit.sh` | 133 (`git=131`) | **4** (`git=2`) | | `scan-comment-hygiene.sh` | 81 (`awk=77`) | **3** (`awk=0`) | | `check-machine-specific-paths.sh` | 10 (`git=5` `head=5`) | **1** (`git=1`) | | `scan-workflow-files.sh` (CI glob, success) | 11 yq | **1** yq | | `--compare` identical fleet list | 10 (`jq=5`) | **6** (`jq=3`) | | `check-heading-cites.sh` | 8 (incl. `cat=1`) | **7** (`cat=0`) | | `setup.sh` plugin stage (fleet+repo, warm) | 4 Claude list CLIs + N grep | **2** (`grep=0`) | | `check-claude-settings-targets.sh --file` | 3 jq | **2** jq | Grounding: GNU/Git `cat-file --batch` / `ls-files --stage` / `grep` (batch vs per-object); Google Shell Style Guide “builtin vs external” and no UUOC; this repo’s #320/#361 spawn-census method; performance plugin harness-integrity (stable PATH, fail closed, commit before verify); [yq file operators](https://mikefarah.gitbook.io/yq/operators/file-operators). ## Related - Follows #320, #358, #361 and closed #316 (sync-manifest remaining spawns; engine now Node). - Sources: [Git cat-file batch](https://git-scm.com/docs/git-cat-file), [Git ls-files](https://git-scm.com/docs/git-ls-files), [Git grep](https://git-scm.com/docs/git-grep), [Google Shell Style Guide](https://google.github.io/styleguide/shellguide.html), [BashFAQ 001](https://mywiki.wooledge.org/BashFAQ/001), [performance plugin](https://github.com/melodic-software/claude-code-plugins/tree/main/plugins/performance), [yq file operators](https://mikefarah.gitbook.io/yq/operators/file-operators). <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-c3a723a2-54d9-4964-854f-cda78e9fcba6?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-c3a723a2-54d9-4964-854f-cda78e9fcba6&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: ksextonmelodic <[email protected]>
Summary
Replace the
printf | grepcontrol-character probe inis_safe_repo_pathwith an in-shell Bash[[:cntrl:]]pattern test, eliminating ~109grepprocess spawns pervalidaterun.Includes a 256-byte equivalence fixture proving grep and Bash agree for embeddable bytes (documented intentional delta at LF).
This is part 2 of #316. The issue stays open until Part 1 (Git index batching) lands.
Test plan
bash distribution/sync-manifest.test.shRelated
No linked issue