Skip to content

perf(security): scan one line per distinct shape of a repetitive directive table (Part of #3188) - #5441

Merged
squid-protocol merged 2 commits into
mainfrom
perf/3188-directive-table-lens
Oct 18, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
perf/3188-directive-table-lens

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #3188

What

A generated-file fast lane for the Security Lens. A large (>= 256 KB), ASCII, C/C++/Objective-C file whose non-blank lines are >= 95% bare preprocessor directives and which has few distinct line shapes (digit runs collapsed; <= 25% of lines) gets the REAL lens run once per distinct shape instead of over the whole text. The result is used only if it is clean (all counts zero); any finding keeps the file on the full lane. The gate is bounded and linear (possessive regex), so it is ReDoS-proof.

Wired in _process_file_worker (about 23 lines in galaxyscope.py); logic lives in the new gitgalaxy/core/generated_fastlane.py. The payload gains fast_lane: "directive_table" only when the lane was taken.

Class table

Member Covered Note
darwin-xnu AvailabilityInternal.h-style version tables yes the telemetry outlier
Availability*.h, winerror-style #define tables, errno / enum tables yes, by construction same gate
Hand-written macro headers with bodies no (stay on full lane) quote/brace/semicolon/continuation lines are not bare directives
Detector (Optical) cost on such files, ~1.5 s no see Sibling gaps

No burned mainframe estate contains such a file, so none was needed for evidence.

Plan change

The plan skipped the detector as well. That dropped the file: statistical_auditor removes an ambiguous-extension (.h) file with zero structure ("Unresolved Ambiguity (No Retainable Structure)"), and the detector's signals feed risk scores. So the lane is Security-Lens-only. No config key was added (avoids the #5438 overlap and the dead-key audit), and the architecture brief was not touched.

Evidence

Synthetic 1.95 MB table (/tmp, outside the repo): wall time 3.93 s -> 2.92 s (~1 s of lens saved), file_data byte-identical on and off.

Gates

  • pr_gates --fast 6/6, --ratchets 8 pass
  • golden-lock.sh crucible_check.py (language-crucible v1.7.0): full_precision PASS, zero_dependency PASS, no bless needed
  • audit_check.py: ruff, mypy, dead-key, ast-accuracy all clear
  • 18 new tests in tests/core_engine/test_generated_fastlane_3188.py

Cross-repo

None. Companion PRs: none. Textual overlap only with #5435 (galaxyscope.py) and #5438; this change is small there and branch is 0 behind main.

Sibling gaps / remaining slices

  • Detector (Optical) cost, ~1.5 s on these files. A cheap equivalent needs per-shape signal extrapolation, a different mechanism.

Lessons for agents

  • A fast lane that skips the detector on an ambiguous-extension .h file gets the file banished by statistical_auditor (zero structure), and changes risk signals. Skip only the Security Lens, with the real lens on a sample.
  • tests/tools/audit_check.py needs ~/.cache/gitgalaxy/mypy-2.4.0/bin on PATH, and golden-lock.sh needs python3, not python. LANGUAGE_CRUCIBLE_PATH is set to /srv/storage_16tb/projects/gitgalaxy/language-crucible on the owner's box.

🤖 Generated with Claude Code

@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Oct 18, 2026
@squid-protocol

Copy link
Copy Markdown
Owner Author

No description provided.

@squid-protocol
squid-protocol marked this pull request as ready for review October 18, 2026 09:05
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol

Copy link
Copy Markdown
Owner Author

No description provided.

@squid-protocol
squid-protocol enabled auto-merge (squash) October 18, 2026 09:17
@squid-protocol
squid-protocol merged commit 21cbcb3 into main Oct 18, 2026
67 checks passed
@squid-protocol
squid-protocol deleted the perf/3188-directive-table-lens branch October 18, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant