Repository navigation
Description
Filed as promised in #3138, and the diagnosis turned out to be quite different from how that PR described it. This is an extraction gap, not a detection one, and it has a single identifiable trigger.
Measured
language-crucible/data/tcl/sqlite/testrunner.tcl (1,939 lines, 56,482 bytes) declares 40 procs at line start. GitGalaxy's 5. Function Analysis reports 22. The 18 missing ones are contiguous:
L943 dirs_nHelper L1127 job_matches_any_pattern
L947 dirs_freeDir L1160 add_tcl_jobs
L958 dirs_allocDir L1220 add_build_job
L972 create_or_clear_dir L1245 add_shell_build_job
L980 build_to_dirname L1261 add_make_job
L987 r_write_db L1280 add_fuzztest_jobs
L998 r_get_next_job L1361 add_zipvfs_jobs
L1052 add_job L1380 add_devtest_jobs
L1411 must_be_testfixture
L1426 add_jobs_from_cmdline
This accounts for the tcl baseline sitting at found_functions: 349 against real_functions: 367 in tests/tree_sitter_accuracy_baseline_tcl.json — 95.1% recall.
Not a syntax problem, and not truncation
The missed declarations are the same shape as extracted ones — proc dirs_nHelper {} { (missed) versus proc find_interpreter {} { (extracted, L31). And extraction resumes at L1544, so nothing is being cut off; a bounded region is being skipped and then recovered.
At L943, the first missed declaration:
| signal | value |
|---|---|
{ / } before that point |
316 / 316, balanced |
" before that point |
337, odd |
So the brace slicer is in sync. The quote state is not.
Trigger
Walking double-quote parity line by line, the flip that matters is L823:
puts "unknown option: \"$a0\"". Use --help for more info."Five double-quotes. The string opens, \"$a0\" is correctly escaped, the 4th quote closes it — and then . Use --help for more info. sits outside any string, with a 5th quote opening one that never closes. This is malformed TCL in sqlite's own source; a real interpreter rejects it with extra characters after close-quote. It is presumably a typo for ... \"$a0\". Use --help for more info.".
The parity stays odd from there through the missed region. (Parity alone doesn't predict the resume point at L1544 exactly, which suggests the quote handling is already bounded/recovering somewhere rather than purely global — worth confirming as part of the fix.)
Why this is ours to fix
The input is bad, but a regex-based structural-signature engine shouldn't lose 45% of a file's declarations to one stray quote in a puts on line 823. tree-sitter recovers and finds them. A proc at column 0 is about as unambiguous a structural anchor as tcl offers, and it should survive an unterminated string earlier in the file.
Two candidate directions, not a prescription:
- treat an unterminated double-quoted string as line-bounded for tcl, the way
_strip_nested_commentsalready does for REXX's quote morphology incore/prism.py - resync quote state at a line-start
procanchor, so a desync can't span declarations
Whichever way, rule 5/9/11/13/14 ReDoS discipline from how_to_add_a_language.md applies.
Reproducing
Note the trap: galaxyscope on PATH is an editable install of the v6 checkout, which is not necessarily on main. Run from a worktree with PYTHONPATH pointed at it, or this file reads as Unsupported Format (.undeterminable) from before #3133's trampoline fix and you will chase the wrong bug (I did — see #3140 note below).
cd <worktree>
GITGALAXY_LICENSE_KEY=COMMUNITY_FREE_TIER PYTHONPATH=. python -c "
import sys; sys.argv=['galaxyscope','<crucible>/data/tcl','--output','/tmp/out/']
from gitgalaxy.galaxyscope import main; main()"Then compare 5. Function Analysis for sqlite/testrunner.tcl against grep -cE '^[[:space:]]*proc ' testrunner.tcl.
Fixing this moves a pinned baseline
tree_sitter_accuracy_baseline_tcl.json will need regenerating, and recall should rise toward 367/367. It also has extra_functions: 13, which is a separate question this issue does not address.
Activity
Bless golden masters: testrunner.tcl recovers 18 procs (#3142)
Fix tcl proc loss after an unterminated double-quote (#3142)
Bless golden masters: testrunner.tcl recovers 18 procs (#3142)
Fix tcl proc loss after an unterminated double-quote (#3142) (#3149)