Repository navigation
Description
From the 2026-09-18 phase profiling (post-#3072 engine, --file-speed --splicing-speed): 5.5_Security_Lens is 253s of node's 752s cumulative worker CPU (34%) and 76.7s of vscode's 268s (29%) — and none of #3063/#3070/#3072 ever touched it. It is the largest remaining lever by a wide margin; halving it is plausibly ~10% end-to-end, more than #3070 and #3072 combined.
What security_lens.scan_content does today (the waste, in order of certainty)
- Double sweep on every hit-bearing signature:
regex.findall(safe_content)for counts, thenregex.finditer(safe_content)AGAIN for snippets/positions (lines ~338–356). Onefinditerpass serves both — trivially identical output, immediate win on threat-dense files. - 13
THREAT_SIGNATURESrun ungated on every file — the pre-perf(detector): required-literal prefilter for the shared coding_analysis rule pass #3070 world. All are(?i)keyword alternations (eval(,XMLHttpRequest,password|secret|token…), i.e. ideal literal-gate material, but only 2/13 currently gate viaderive_literal_gate. First step is diagnosing why the other 11 refuse (likely one weak branch per alternation collapsing the one-of merge — possibly a 1-char literal run trippingmin_literal_len, or an unharvestable branch). Fix the derivation if the cause is general; hand-declare per-signature gates with a one-sided audit only as fallback. - Per-file
splitlines()/joincopy for the 250-char ReDoS shield + the entropystring_extractorpass on every non-autogen file — measure before touching; only act if the profile says they matter after (1)+(2).
Correctness bar
Same one-sided contract as #3069: a gate rejection must equal zero matches. Add a scan_content parity leg (gated vs ungated: identical counts/snippets/positions dicts) over crucible+rosetta, modeled on tests/tools/gate_parity_audit.py. The double-sweep fix needs only the existing security-lens unit tests plus that parity leg.
Efficient workflow (time/token/model)
The expensive derivations are already done — do NOT respend on them:
- Baseline profile is captured (numbers above; commands in this issue). Re-run only the after profile.
- A/B protocol from perf: per-line gating for the line-local heavy rules (state_mutation family) (#3072) #3170: engines via
PYTHONPATH, drivegitgalaxy.galaxyscope.main()by import (never the console script; printgitgalaxy.__file__first),GITGALAXY_LICENSE_KEY=COMMUNITY_FREE_TIER, alternating rounds, and an A-vs-A control before reading anything into artifact diffs (master.db call lists have hash-seed nondeterminism, ~128 rows on curl;audit.json/sarif/llm.mdare the deterministic surface). - Worktree env recipe:
KEYWORD_ROSETTA_PATH/LANGUAGE_CRUCIBLE_PATHset, v6.venvpython withPYTHONPATH=<worktree>; Bash sandbox OFF for mega-repo scans.
Suggested split by cost tier:
- Cheap/mechanical (fleet-able, small model): step 1 (single-pass rewrite — small diff, output-identical by construction); the refusal-diagnosis script (print each signature's
_walk_seqcandidates and which branch kills the merge); the parity-leg audit script (clone gate_parity_audit's skeleton). - Frontier attention (short, focused): reviewing the derivation fix for one-sided soundness (this is the only place a wrong move silently undercounts), and the final measurement read-out.
- Sequencing for wall time: land step 1 alone first (independent, zero-risk, immediately measurable via the 5.5 phase number), then gates. Run corpus audits in the background while writing tests — they're I/O-light and don't fight the editor loop.
Expected effort: one session; most of the token spend should be the two corpus audit runs and one node+vscode A/B, not code generation.
🤖 Generated with Claude Code
Activity
perf(security-lens): single finditer pass in scan_content (#3173) (#3176
perf(security-lens): literal-gate the threat signatures (#3173, step 2)
perf(security-lens): literal-gate the threat signatures (#3173, step 2)
squid-protocol commentedon Sep 18, 2026
Landed as two PRs (split per the sequencing in this issue):
scan_contentswept each threat-bearing file twice (findallfor counts, thenfinditeragain for snippets/positions); collapsed to onefinditerpass, output-identical by construction.derive_literal_gate's_pick_best(fewest-alternatives) grabs a bare(/=/.that a top-level alternation branch is forced through, and themin_literal_lenfloor then drops the whole gate. Fix = aprefer_selectiveflag (default off → coding-rule gates byte-identical) reusing the perf: per-line gating for the line-anchored rules the literal prefilter can't touch #3072_pick_most_selectivepicker → 2/13 → 10/13 gated. The 3 holdouts (reflection_metaprogramming,bitwise_ops,unicode_steganography) carry a genuinely literal-free branch and correctly stay ungated — forcing a gate there would silently undercount.Correctness (the one-sided bar): new
tests/tools/scan_content_gate_parity.pyproves it over 3009 corpus files — zero violations, 47% of signature sweeps eliminated. Plus a gated-vs-ungated differential over 3639 files (692 threat-bearing) with zero divergence, and whole-pipeline artifact identity (SARIF +audit.jsonmod timestamp).Measurement —
5.5_Security_Lensonall_language_repo(2921 files), 3-way interleaved A/B ×3: main 44.63s → #3176 41.12s (−7.9%) → #3177 34.73s (−22.2% cumulative, −15.5% incremental), Optical_Detector control flat. (node/vscode source is no longer on the box;all_language_repois the stand-in.)Step 3 deferred: the
splitlines/join copy + entropystring_extractorpass were left untouched — measure-first, and the profile doesn't justify touching them yet.Recommend closing this once #3177 merges.
perf(security-lens): literal-gate the threat signatures (#3173, step …
tooling(perf): reusable phase A/B harness + perf-ab skill (#3178)
squid-protocol commentedon Sep 18, 2026
Done — both PRs merged:
finditerpass, output-identical)derive_literal_gate(prefer_selective=True); the 3 holdouts have a genuinely literal-free branch and stay ungated)Net on
5.5_Security_Lens(all_language_repo, 3-way interleaved A/B ×3): 44.63s → 34.73s, −22.2% cumulative, with the5_Optical_Detectorcontrol flat and whole-pipeline artifact identity (SARIF +audit.jsonmod timestamp). One-sidedness proven over 3009 corpus files (0 violations) by the newtests/tools/scan_content_gate_parity.py.Step 3 (the
splitlines/join copy + entropystring_extractorpass) deliberately left untouched — the profile doesn't justify it. Closing.