Skip to content

Per-unit is_public / is_documented on function_data; reflection stays state_heat_triggers (#2908 Phase 2) - #2935

Merged
squid-protocol merged 4 commits into
mainfrom
feat/2908-p2-per-unit-attributes
Sep 10, 2026
Merged

squid-protocol merged 4 commits into
mainfrom
feat/2908-p2-per-unit-attributes

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #2908 (Phase 2 · per-unit attributes). Additive only: every extracted unit gains is_public (api-header name match ∪ export-list names ∪ healed-orphan credit, per D2) and is_documented (a doc-rule match anchored to the unit's header window: k=5 lines above, +2 into the body for the docstring-position family, per D3); reflection_hits is the existing per-unit state_heat_triggers column, exposed in the audit JSON rather than duplicated. Two new function_data columns (auto-healing migration), three new 5. Function Analysis audit-JSON keys. No count, signal, or score moves.

Score-contract gauntlet (contract_pr_check)

Measured

  • touched languages: none
  • extraction (no touched languages): PASS — skipped: git diff touched no language file

Corpus

  • rosetta_audit: PASS — 46 language(s) checked, 0 regression(s), 0 pre-existing, 0 broken

Golden masters

  • crucible_check (verify): PASS — full_precision PASS; zero_dependency PASS; 0 differences at final state
  • regen scope across the three engine commits: every diff confined to 6. Parsed Files → 5. Function Analysis (the three new keys); bless_scope showed no signal/score leaf key in any round

Tests

  • full suite: 8482 passed, 0 failed (excluding the known local security_auditing ML-dep failures)
  • audit_check: all clear (ruff baseline regenerated for pure line-shifts only, 26 findings unchanged in substance)
  • new contract tests: 4 declaration families + 5 comment families (rust ///, haskell, scheme, perl POD, powershell) + the undelimited-doc-marker case

What the sweep surfaced (fixed here, not ledgered)

  • the positional doc pass initially returned a blank stream for recursive_block/recursive_block_haskell/recursive_block_lisp, perl and powershell — is_documented could structurally never fire for 7 languages (commit 2)
  • doc-rule matches can live in the code stream (undelimited markers like a bare .SYNOPSIS); the anchor now merges comment-stream and code-stream match end-lines (commit 3)

Corpus (engine-first merge order)

squid-protocol/keyword-rosetta rebless/2908-p2-unit-keys (opens as its own PR): verify_language.py aggregates units_public/units_documented from function_data; all 46 manifests gain the keys; 7 main doc plants relocated count-neutrally into the anchor window; exception classes ledgered (units-public-main-outside-api-contract, units-documented-structural-absences). 46/46 PASS.

Pre-existing defects found and filed (not touched here)

🤖 Generated with Claude Code

https://claude.ai/code/session_01XSfBNJvqMah9CsZDN15sEd

squid-protocol and others added 4 commits September 9, 2026 19:59
…ection stays state_heat_triggers (#2908 Phase 2)

- detector.py computes is_public as the union of the api-header name match (A)
  and the export-list name set (B, new _export_declared_names sibling of
  _export_declaration_offsets); galaxyscope.py's Contextual Baseline Fix ORs in
  the healed-orphan credit (C) before the usage_status flip, inside the same
  "credit actually fires" branch, so it lands in the DB (record_mission runs in
  Phase 12, strictly after Phase 3's _calculate_risk_exposures both across
  phases and within the same per-file loop iteration that appends to
  self.parsed_files).
- is_documented is a NEW positional doc-rule pass: prism.py's
  split_positional_comment_stream builds a line-number-aligned, code-blanked/
  comment-preserved counterpart of code_stream (mirroring split_streams'
  construction with roles swapped), and detector.py anchors each doc-rule
  match's end line to a unit's header window (k=5 above, +2 into the body for
  the docstring-position family only). comment_analysis, its counts, def_doc
  and the slicer's docstring field are all untouched.
- Persists two new function_data columns (auto-healing ALTER TABLE migration)
  and three new "5. Function Analysis" audit JSON keys (Is Public / Is
  Documented / Reflection Hits); both golden masters regenerated columns-only
  (2075 diffs, all inside existing Function Analysis entries, zero
  signal/score values moved -- verified via a full structural JSON diff, not
  just the printed sample).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSfBNJvqMah9CsZDN15sEd
…erl and powershell comment families (#2908 Phase 2)

- prism.py: _positional_nested_comments (recursive_block: rust/scala/swift;
  recursive_block_haskell: haskell; recursive_block_lisp: scheme) peels
  nested block comments from a byte-offset-aligned masked view so a found
  delimiter's span can be sliced straight out of the pristine original text,
  instead of _strip_nested_comments' own variable-length placeholder masking
  (fine for line-count-only correspondence, unsafe for this method's
  byte-offset slicing).
- prism.py: _positional_perl_comments makes POD blocks (=pod/=headN/.../=cut)
  visible verbatim at their real lines -- perl.py's own "Known remaining gap,
  not fixed here" note confirms POD was never stripped into comment_stream by
  the production pipeline, so comment_analysis's doc count already reads 0
  for POD-documented perl files; that gap is untouched, this only opens a
  path for the NEW positional pass to see it. `#` line comments now also
  carry perl's own bare-regex/quote-like-operator masking (duplicated from
  the private _mask_perl_line closure), so a `/regex#with-hash/` literal's
  embedded `#` isn't misread as opening a comment. powershell/embedded_syntax
  needed no change -- it was never excluded from the generic REGEX_MATRIX
  positional path; jcl stays blank correctly (no `doc` rule exists for it).
- Golden masters regenerated columns-only again: 962 diffs each leg, every
  one an existing "Is Documented" 0->1 flip inside rust/scala/swift/haskell/
  perl entries (verified via full structural JSON diff), zero other
  keys/values moved. crucible_check both legs PASS; bless_scope leaf-key
  table still shows only 5. Function Analysis.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSfBNJvqMah9CsZDN15sEd
…t blocks (#2908 Phase 2)

- Root cause was NOT in prism.py's embedded_syntax routing (verified correct
  for both `<# ... #>` and `#`-line doc-block shapes). The real gap: the
  file-level `doc` equation `comment_analysis` feeds was already the sum of
  TWO passes -- comment_analysis over comment_stream, AND coding_analysis's
  own generic per-rule loop, which runs every rule (including `doc`) against
  every segment of code_stream too, with no comment-vs-code distinction.
  Confirmed on keyword-rosetta's powershell main.ps1 (expected_signals.json:
  "doc": 1): its `.SYNOPSIS` plant carries no `#`/`<#`/`#>` delimiter at
  all, so comment_stream never contains it, yet the file's own doc equation
  already read 1 -- entirely from the code_stream pass. A positional pass
  that only ever scanned the comment surface (positional_comment_stream)
  structurally could never agree with the file-level count it's the
  per-unit form of.
- detector.py's splice() now also scans code_stream (already line-aligned
  with the original file for the same reason positional_comment_stream is)
  for `doc`-rule matches, merging both streams' match end-lines into one
  window-checked set. No new prism.py stream was needed.
- Strengthened the powershell contract test to mirror the real corpus shape
  (bare, undelimited `.SYNOPSIS` inside code, not a `<# #>` block) plus a
  negative at 6+ lines -- the old block-shaped test is kept alongside it
  (still a real, valid shape) since it wasn't wrong, just incomplete.
- This is a general fix, not powershell-specific: the golden master diff
  also touches shell/assembly/cobol/rust/python entries wherever their own
  `doc` rule already matched code-stream text (the crucible corpus's
  pre-existing `doc` equation counts already included these; is_documented
  now agrees with them). Verified no a/b/c corpus file's public/documented
  invariant moved for any of the 9 languages checked (python/c/cobol/rust/
  haskell/perl/powershell/shell/assembly), and the structural JSON diff
  against both prior golden masters shows every changed leaf is an existing
  "Is Documented" 0->1 flip, nothing else.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSfBNJvqMah9CsZDN15sEd
@squid-protocol squid-protocol added the rosetta:rebless-owed Intentionally moves keyword-rosetta counts; audit warns, corpus re-blesses after merge label Sep 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 44b5667 into main Sep 10, 2026
40 of 41 checks passed
@squid-protocol
squid-protocol deleted the feat/2908-p2-per-unit-attributes branch September 10, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rosetta:rebless-owed Intentionally moves keyword-rosetta counts; audit warns, corpus re-blesses after merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant