Repository navigation
Description
Summary
Found while closing #597 (markdown strict-parsing tests). Markdown's 4 literate-programming
structural signatures (lit_code_blocks, lit_diagrams, lit_headers, lit_links) have
never been counted in a real scan, independent of whether their regexes are correct. All
25 markdown files in tests/golden_master_audit.json report zero across every signature, not
just the ones touched in #597.
Root cause (confirmed via direct execution, not just code reading)
Two separate mechanisms, and markdown's content flows into the one that's dead-ended:
-
gitgalaxy/core/detector.py's "Prose Deflection" gate (~line 435):if confidence < 0.42 or self.primary_lang_id in ( "plaintext", "markdown", "json", "yaml", "csv", ): return {"equations": {}, "functions": [], ...} # early return, nothing scanned
This fires before
comment_analysis()-- the function that scanscomment_stream--
ever runs. -
comment_analysis()'s hardcoded rule whitelist (~line 1066) only checks 6 keys:
dead_code,doc,ownership,planned_debt,fragile_debt,spec_exposure. Markdown's
4lit_*keys aren't on it, so even bypassing (1) wouldn't be enough on its own.
Markdown's entire file content lands in comment_stream via prism.py's "Prose Bypass"
(split_streams, ~line 159) -- code_stream is always empty for markdown, which is why the
normal coding_analysis/code_stream path (the one virtually every other language relies on)
can never see it either.
Why not just make markdown's code_stream non-empty?
Considered and rejected: coding_loc/doc_loc (derived from which stream a file's content
lands in) feed ~10 downstream consumers -- risk-density normalization in
signal_processor.py/security_auditor.py, aggregate stats in record_keeper.py, 3D
visualization mass in gpu_recorder.py, and an anomaly check in statistical_auditor.py
that's specifically if doc_loc > coding_loc * 5. Flipping markdown files from all-doc to
all-code LOC would corrupt all of that for every markdown file in every future scan --
a much bigger blast radius than the signature-counting bug itself.
The fix (verified end-to-end before opening this issue)
Leave prism.py and coding_loc/doc_loc semantics completely untouched. In detector.py:
- Add markdown's 4
lit_*keys tocomment_analysis's whitelist (no-op for every other
language, since none of them define those keys). - For markdown specifically, call
comment_analysis(comment_stream, ...)before returning
from the Prose Deflection gate, instead of bailing with an empty dict (function/
complexity analysis correctly still gets skipped -- markdown has no functions).
Proved this works by running it directly against real Prism output on a sample with
headers/links/fences: coding_loc/doc_loc came back unchanged (0/9, identical to today),
and all 4 signatures came back correctly non-zero.
Scope: markdown only for now
yaml/json/csv are also in the same Prose Deflection tuple and also show all-zero
signatures in the current fixture -- surprising, since yaml's strict-parsing issue (#617/#681)
closed with real, file-traceable golden-master diffs, which doesn't obviously square with this
gate blocking it unconditionally. Worth its own investigation: unlike markdown, yaml's
code_stream is already correctly populated (it doesn't go through the Prose Bypass), so its
fix is likely just "remove yaml from this one gate" -- a different, simpler mechanism than
markdown's, and probably a different root cause than what closed #681 historically. Deferred
rather than folded in here to keep this fix's blast radius scoped and reviewable; will surface
naturally as the strict-parsing epic (#518) works through more languages.
Activity
squid-protocol commentedon Jul 28, 2026
Update: the fix turned out to need a third piece beyond what's described above. Confirmed via direct execution that fixing
detector.pyalone does NOT make markdown's signatures show up in the "Structural Signatures" report section -- that section reads a separatehit_vectorfield, notequationsdirectly.There are actually three independent gates in this pipeline, not two:
detector.py's Prose Deflection gate (described above) -- controls whetherequationsgets populated at all.gitgalaxy/metrics/signal_processor.py's "STATIC LITERATURE OVERRIDE" (~line 412-454) -- a completely separate gate that unconditionally hardcodes"hit_vector": [0] * len(SIGNAL_SCHEMA)for everydoc_languagesentry (markdown/plaintext/rst/text), regardless of whatraw_signals/equationscontains. This is why "Structural Signatures (Net Mitigated Signals)" (which readshit_vectorviaaudit_recorder.py) stayed at zero even after fixing (1).Interestingly, a third, already-existing consumer --
galaxyscope.py's "Instructional Density Multipliers" (~line 1991-2028), which boostsdoc_umbrellabased on a markdown file'slit_diagrams/lit_code_blocks/lit_headers/lit_linkscounts -- readsequationsdirectly, bypassingsignal_processor.pyentirely. That one already showed real diffs from fix (1) alone. It turns out this "instructional density" feature has been silently dead code since it was written, sinceequationswas always empty for markdown before this fix -- worth knowing about for anyone assessingdoc_umbrellascores historically.Fix now also updates
signal_processor.py's override to derivehit_vectorfromraw_signalsthe same way the non-doc path already does, instead of hardcoding zero.risk_vector(the actual 0%-logic-risk-for-docs bypass) is untouched -- onlyhit_vectorchanges. Verified end-to-end against the real crucible corpus: 51 diffs, every one either a.mdfile's ownStructural Signaturesgoing from 0 to a real count, or adoc_umbrellaripple in the same folder via the now-un-dead multiplier -- no off-target files affected.Let markdown's structural signatures reach the detector output (issue #…
Let yaml/json/csv structural signatures reach the detector output (is…
Use line_exclusive's real delimiter list instead of a hardcoded guess…
Strict tests for livecode, fix 7 real bugs (issue #593) (#707)
Fix #587: Strict parsing tests for html structural signatures (#734)
Fix #609: Strict parsing tests for scheme structural signatures (#771)