Skip to content

feat(detector): has_header_comment, the non-scored companion to is_documented - #8240

Merged
squid-shepherd[bot] merged 11 commits into
mainfrom
feat/has-header-comment
Nov 11, 2026
Merged

squid-shepherd[bot] merged 11 commits into
mainfrom
feat/has-header-comment

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds has_header_comment, a per-function signal recorded beside is_documented: true when an explanatory comment block sits directly above the unit, Doxygen or plain. It is not a risk_documentation input. The new contract section docs/risk_documentation_contract.md §8 gives the definition and the reason.

Was stacked on #8200, which has merged; this now targets main.

Why

is_documented is anchored on the doc rule (Doxygen /**, ///, @param). Traditional C (curl, nDPI, OpenSSL, the kernel) explains functions in plain /* Curl_foo() does X */ blocks, so on that code nearly every unit reads undocumented. That leaves temporal-crucible's comment experiments with nothing to measure. The owner chose to record the second fact as its own field (option C) rather than loosen is_documented: the score keeps one meaning across languages, and the data can show later whether the two signals behave differently.

Definition (StructuralExtractor._has_header_comment)

  • Walk up from the unit's start line. Up to 2 header-prefix code lines (return type, template<...>, decorator) and 1 blank line may sit between the comment and the unit. A line ending in ; { }, or a preprocessor line, stops the walk.
  • The comment block is the run of comment-only lines, so a trailing comment on a code line never counts.
  • A block is rejected when it is a license header (copyright with (c)/year, SPDX, "licensed under", ...), matches the language's own dead_code rule, has fewer than 2 words, or is under 60% letters and digits once comment markers are removed (dividers).

Where it lands

function_data.has_header_comment (SQLite; healed onto older databases like is_documented), the incremental-scan cache (state_rehydrator.py), and the audit report's per-function Has Header Comment.

Measured

Direct extraction over language-crucible:

functions is_documented has_header_comment
C 1,732 1 452 (26%)
C++ 1,145 5 41

A read of a sample of rejected comment-above cases found mostly correct rejections: DOOM's // P_SpawnMobj banners that only repeat the function name, /* ARGSUSED */. It also found one wrong rejection ("Prints a copyright notice ..." read as a license), which led to the tighter license filter and a test.

Real-repo check: curl (97cef84, 492 C source files, tests/docs excluded)

main before #8200 this PR
C functions 4,390 4,390
is_documented 168 (banner false positives) 49
has_header_comment n/a 1,182 (27%)
docstrings carrying #include / #if / #endif / #define 624 0

The curl scan found two follow-ups, both fixed here:

Known limit, unchanged: C's dead_code rule reads /* return the position after %time{} */ as commented-out code (it ends in {}), so that unit gets no header.

Golden master bless scope

Compared against main in both fixtures, leaf by leaf via golden_store:

  • Has Header Comment is added on all 52,763 units.
  • 3 function docstrings change from the directive stop (c/cpython/dictobject.c, c/cpython/object.c, cobol/gnucobol_internals/numeric.c in the graph snapshot).

Nothing else moves: no score, archetype or file-level value.

Size

7 source/test/doc files plus 2 golden parts. That is over the usual 5-file guideline, but it is one column end to end: detector, recorder, rehydrator, audit recorder, contract, and their tests.

Verification

  • pytest tests/core_engine/test_detector.py tests/tools_recorders/test_record_keeper.py tests/extraction/languages/test_c_strict.py tests/extraction/languages/test_cpp_strict.py tests/core_engine/test_signal_processor.py: 511 passed, plus 11 new header tests.
  • ruff_audit.py --ci, doc_refs_audit.py --ci, dead_key_audit.py --ci: no new findings. ruff format --check: clean.
  • mypy was not run locally (the nyx venv's numpy stubs fail under the 3.11 target); CI's mypy env covers it.
  • Bless: golden-lock.sh python tests/tools/crucible_check.py --update --yes.

Cross-repo

Consumer: temporal-crucible's comment experiments (the curl re-scan on melek). Merge order: #8200 (merged), then this PR, then the 13-language banner-guard PR, then the re-scan.

🤖 Generated with Claude Code

squid-protocol and others added 8 commits November 10, 2026 16:32
…cumented

Traditional C documents functions with plain /* ... */ blocks, which
is_documented (Doxygen-anchored, D3) never sees: on language-crucible's C
files it marks 1 of 1,732 functions. has_header_comment records any
explanatory comment block directly above a unit (license headers,
dividers, one-word banners and commented-out code rejected) as its own
function_data column. It is not a risk_documentation input; contract §8
says why and what it measures.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Only change: the new key in 5. Function Analysis (both fixtures identical
with it removed); true on 10,357 of 52,763 units.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The function-grain comment pass calls re.finditer on the stream outside the
doc pass's try, so a stubbed Prism (test_galaxyscope's worker tests) crashed
the whole splice. Fixes test_worker_amplifies_active_hemorrhage_post_hoc.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Base automatically changed from fix/comment-extraction-pipeline to main November 10, 2026 22:45
squid-protocol and others added 3 commits November 10, 2026 17:47
…comments count

Found on a real curl scan: 93 C docstrings still carried '#endif /* X */'
lines (they end in */, so the #8200 prefix scope let them through); now 0.
A two-word explanation ('/* Compress 512 bits */') is a header comment;
one-word banners still are not. Golden drift: 923 Has Header Comment
flips and 3 C function docstrings (cpython dictobject.c/object.c,
gnucobol numeric.c).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	gitgalaxy/core/detector.py
#	tests/core_engine/test_detector.py
#	tests/golden_master_audit/12_scan_output_snapshots/graph_sqlite.json
#	tests/golden_master_zero_dep_audit/12_scan_output_snapshots/graph_sqlite.json
@squid-protocol
squid-protocol marked this pull request as ready for review November 11, 2026 00:03
@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot enabled auto-merge (squash) November 11, 2026 00:14
squid-shepherd Bot pushed a commit that referenced this pull request Nov 11, 2026
jcl contributed a blank positional stream ('moot: no doc rule'), but the
stream now also feeds the function-grain comment rules (#8200) and header
comments (#8240): every jcl step read as uncommented. Keep each //* comment
statement at its line (JES3 verbs excluded, as _strip_jcl_comments does).

Co-authored-by: Joe Esquibel <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
@squid-shepherd
squid-shepherd Bot merged commit ed79c82 into main Nov 11, 2026
119 checks passed
@squid-shepherd
squid-shepherd Bot deleted the feat/has-header-comment branch November 11, 2026 00:48
squid-protocol added a commit that referenced this pull request Nov 11, 2026
#8240 was blessed before #8245 merged, so main's goldens never had both:
with jcl's positional comments, 119 jcl steps now read Has Header Comment
0 -> 1. Plus this PR's own GLTFLoader.js banner drift.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
squid-protocol added a commit that referenced this pull request Nov 11, 2026
…t of #6454)

Main's #8240 (has_header_comment) and #8245 (jcl positional comment surface)
landed without a joint bless; JCL function rows now report Has Header Comment 1
where a header comment precedes them. No Haskell/Rust golden drift.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
squid-protocol added a commit that referenced this pull request Nov 11, 2026
squid-shepherd Bot pushed a commit that referenced this pull request Nov 11, 2026
…locks (#8244)

* fix(doc): guard 13 languages' doc rule against star-banner and slash-divider false positives

Same /**(?!\*) and (?<!/)///(?!/) guard #8200 put on c/cpp: apex, dart,
groovy, java, javascript, kotlin, objective-c, php, scala, solidity, swift,
typescript, yacc. A /***** box border or //// divider is not a doc block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(doc): narrow the banner guard so /*** + newline docblocks still count

(?!\*) also rejected Magento-style '/***' docblocks (found on the golden:
Mysql.php's doc count went up as their @var tags counted alone). Reject
only banner shapes: /**** (2+ extra stars) and one-line '/*** x ***/'
boxes. Applied to all 15 /** languages, c/cpp included.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(golden): bless the banner guard (threejs GLTFLoader.js: 67 -> 58 doc blocks)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* style: ruff format the widened doc rules (patterns unchanged)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(golden): re-bless after merging main (#8240 + #8245 together)

#8240 was blessed before #8245 merged, so main's goldens never had both:
with jcl's positional comments, 119 jcl steps now read Has Header Comment
0 -> 1. Plus this PR's own GLTFLoader.js banner drift.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Joe Esquibel <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
squid-shepherd Bot pushed a commit that referenced this pull request Nov 11, 2026
…6454) (#8252)

* Haskell calls_out: primed identifiers are not char literals (Part of #6454)

Two names ending in a prime on one line (`Just (_, t') -> case T.unsnoc t' of`)
were paired by the shared literal shield as a char literal, blanking the code
between them. The rule now masks identifier primes before the shield and
restores them after it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* Re-bless golden: JCL has_header_comment after #8245 prism change (Part of #6454)

Main's #8240 (has_header_comment) and #8245 (jcl positional comment surface)
landed without a joint bless; JCL function rows now report Has Header Comment 1
where a header comment precedes them. No Haskell/Rust golden drift.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
squid-shepherd Bot pushed a commit that referenced this pull request Nov 11, 2026
…t of #4108) (#8257)

* Hidden text: U+180E outside Mongolian and lone interlinear marks fire (Part of #4108)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* Re-bless golden masters: Has Header Comment drift from #8240/#8245 (Part of #4108)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

---------

Co-authored-by: Joe Esquibel <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
squid-shepherd Bot pushed a commit that referenced this pull request Nov 11, 2026
…t end in C-family (#8255)

* fix(doc): guard 13 languages' doc rule against star-banner and slash-divider false positives

Same /**(?!\*) and (?<!/)///(?!/) guard #8200 put on c/cpp: apex, dart,
groovy, java, javascript, kotlin, objective-c, php, scala, solidity, swift,
typescript, yacc. A /***** box border or //// divider is not a doc block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(doc): narrow the banner guard so /*** + newline docblocks still count

(?!\*) also rejected Magento-style '/***' docblocks (found on the golden:
Mysql.php's doc count went up as their @var tags counted alone). Reject
only banner shapes: /**** (2+ extra stars) and one-line '/*** x ***/'
boxes. Applied to all 15 /** languages, c/cpp included.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(golden): bless the banner guard (threejs GLTFLoader.js: 67 -> 58 doc blocks)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* style: ruff format the widened doc rules (patterns unchanged)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(golden): re-bless after merging main (#8240 + #8245 together)

#8240 was blessed before #8245 merged, so main's goldens never had both:
with jcl's positional comments, 119 jcl steps now read Has Header Comment
0 -> 1. Plus this PR's own GLTFLoader.js banner drift.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(dead_code): control keywords need '(' and return needs a statement end in C-family

On curl 39 of 48 dead_code hits were prose: '/* for offsetof() */',
'/* if a request ... (on a file) */', '/* return the position after
%time{} */'. In c/cpp/java/javascript/typescript, if/for/while must be
followed by '(' (their conditions always are); in c/cpp/java a commented
return must end in ';' or return a call directly (#7207's
'// return foo(x)'). curl: 48 -> 9 hits, both real commented-out
statements kept, the rest are commented prototypes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(golden): bless the dead_code shape fix (3 corpus files; plus main's stale jcl header drift)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(golden): re-bless after merging #8244 (derived gpu digest only)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Joe Esquibel <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
squid-shepherd Bot pushed a commit that referenced this pull request Nov 11, 2026
…; rejects trailing-comment tails (#8256)

* fix(doc): guard 13 languages' doc rule against star-banner and slash-divider false positives

Same /**(?!\*) and (?<!/)///(?!/) guard #8200 put on c/cpp: apex, dart,
groovy, java, javascript, kotlin, objective-c, php, scala, solidity, swift,
typescript, yacc. A /***** box border or //// divider is not a doc block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(doc): narrow the banner guard so /*** + newline docblocks still count

(?!\*) also rejected Magento-style '/***' docblocks (found on the golden:
Mysql.php's doc count went up as their @var tags counted alone). Reject
only banner shapes: /**** (2+ extra stars) and one-line '/*** x ***/'
boxes. Applied to all 15 /** languages, c/cpp included.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(golden): bless the banner guard (threejs GLTFLoader.js: 67 -> 58 doc blocks)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* style: ruff format the widened doc rules (patterns unchanged)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(golden): re-bless after merging main (#8240 + #8245 together)

#8240 was blessed before #8245 merged, so main's goldens never had both:
with jcl's positional comments, 119 jcl steps now read Has Header Comment
0 -> 1. Plus this PR's own GLTFLoader.js banner drift.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(dead_code): control keywords need '(' and return needs a statement end in C-family

On curl 39 of 48 dead_code hits were prose: '/* for offsetof() */',
'/* if a request ... (on a file) */', '/* return the position after
%time{} */'. In c/cpp/java/javascript/typescript, if/for/while must be
followed by '(' (their conditions always are); in c/cpp/java a commented
return must end in ';' or return a call directly (#7207's
'// return foo(x)'). curl: 48 -> 9 hits, both real commented-out
statements kept, the rest are commented prototypes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(golden): bless the dead_code shape fix (3 corpus files; plus main's stale jcl header drift)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(detector): has_header_comment steps over the unit's own prototype; rejects trailing-comment tails

From the curl hand audit (temporal-crucible#118): curl documents
UNITTEST functions as comment, forward declaration, definition, and the
walk stopped at the prototype's ';'; a blank line inside a /* */ block cut
the block short; and the wrapped tail of a #define's trailing comment read
as a header. curl C: 1,196 -> 1,223 header comments (29 gained, all the
UNITTEST idiom; 2 lost, both trailing-comment tails).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(golden): bless the header-comment fixes (29 corpus units gain a header; plus main's stale jcl drift)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(golden): re-bless after merging #8244 (derived gpu digest only)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Joe Esquibel <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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