Skip to content

Ada: a nested subprogram ends at its own end Name; the parent keeps its tail (#8913) - #9061

Closed
squid-protocol wants to merge 4 commits into
mainfrom
churn/8913-20261122T2053Z
Closed

squid-protocol wants to merge 4 commits into
mainfrom
churn/8913-20261122T2053Z

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #8913 (the Ada nested-subprogram case; the two unreproduced shapes are listed as sibling gaps). Part of #8863.

What changed

Ada is sliced by Mode A (_slice_by_labels): every unit ran greedily to the next func_start match. For C4 holding Inner, C4 ended at Inner's header (losing its begin ... end C4; tail and its if), and Inner ran to EOF and took that tail.

  • gitgalaxy/core/detector.py: new _ada_unit_end finds the end Name; that closes a subprogram (searched in the whole file, since a parent's end lies past its nested headers; case-insensitive, end Pkg.Name; accepted). In _slice_by_labels, an Ada unit with a labelled end now ends there; every nested subprogram inside it is blanked out of its block (newlines kept, so lines and LOC hold) and its span is excluded from the parent's hit vector via a new optional exclude_spans on _calculate_block_metrics. A unit with no labelled end keeps the old greedy body.
  • tests/extraction/languages/test_ada_nested_subprogram_8913.py: the issue's C4/Inner case (C4 branch 1, Inner 0, end lines), two sibling nested subprograms, two levels of nesting, end-label spellings, unlabelled end; fallback, flat subprograms unchanged.

Class / Sibling gaps

Class: Mode A greedy slicing gives a nested unit with an explicit closing label the wrong body (parent truncated at the nested header, nested unit extended to the parent's tail). Member fixed here: Ada.

  • PL/I (same mechanism, nested PROC): its child already ends at END name; (_structural_unit_end), but the parent is still truncated at the nested header. Not changed here to keep the golden drift attributable to Ada; same exclude_spans hook would serve it. No burned-estate program needs it (core/sweep).
  • Ada extended return (return R : T do ... end return;) truncating the enclosing function: not reproduced on a minimal file, not verified here.
  • Ada exception-handler when counted as a branch (branch contract corollary 1): different mechanism (the branch rule in languages/ada.py matches every when, case arms included); not changed here.
  • Ada nested subprogram with no end Name; label keeps the greedy body (stated fallback).

Golden drift

Re-blessed with golden-lock.sh crucible_check.py --update --yes (both legs), then re-checked: both PASS. The Ada drift is the intended change (function boundaries, per-function families, Ada directory rollups). Other languages move only through repo-wide graph rollups (PageRank at the 1e-5 level, topological coordinates, composition z-scores, archetype distribution counts) because Ada's function set and import/call edges changed. scope_check.py --expect ada also listed shell/powershell/cpp function-level Calls Out To / Fan Out entries that do not appear in the blessed golden diff; I did not chase them further. Merged main once for a sibling's golden conflict (took main's generated files, re-blessed).

Facts checked: ada tests 133 passed (new file 7); pr_gates --fast 9/9; pr_gates --ratchets 9 pass, 0 skipped; crucible_check PASS both legs.

Lessons for agents

  • _calculate_block_metrics counts branch/etc. by bisecting the spatial map on start_idx/end_idx, not from block text: blanking text inside a block does not remove its hits; pass exclude_spans.

🤖 Generated with Claude Code

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

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot marked this pull request as ready for review November 22, 2026 21:46
@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

PR #9061 @ feb7a6c: 1 failed check(s)

== rosetta-audit (failure) -- real
https://github.com/squid-protocol/gitgalaxy/actions/runs/45073987381/job/137367004894
repro: no local equivalent; read the check page
errors:
pre powershell FAIL powershell: 1 mismatch(es)
pre tcl FAIL tcl: 1 mismatch(es)
##[error]Process completed with exit code 1.
log tail:
Removing SSH command configuration
[command]/usr/bin/git config --local --name-only --get-regexp core.sshCommand
[command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
Removing HTTP extra header
[command]/usr/bin/git config --local --name-only --get-regexp http.https://github.com/.extraheader
[command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http.https://github.com/.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
Removing includeIf entries pointing to credentials config files
[command]/usr/bin/git config --local --name-only --get-regexp ^includeIf.gitdir:
[command]/usr/bin/git submodule foreach --recursive git config --local --show-origin --name-only --get-regexp remote.origin.url
Post job cleanup.
[command]/usr/bin/git version
git version 2.56.1
Temporarily overriding HOME='/home/runner/work/_temp/ad091125-a2b8-4656-84e5-8f6625061483' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
[command]/usr/bin/git config --global --add safe.directory /home/runner/work/gitgalaxy/gitgalaxy/gitgalaxy-baseline
Removing SSH command configuration
[command]/usr/bin/git config --local --name-only --get-regexp core.sshCommand
[command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
Removing HTTP extra header
[command]/usr/bin/git config --local --name-only --get-regexp http.https://github.com/.extraheader
[command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http.https://github.com/.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
Removing includeIf entries pointing to credentials config files
[command]/usr/bin/git config --local --name-only --get-regexp ^includeIf.gitdir:
[command]/usr/bin/git submodule foreach --recursive git config --local --show-origin --name-only --get-regexp remote.origin.url
Post job cleanup.
[command]/usr/bin/git version
git version 2.56.1
Temporarily overriding HOME='/home/runner/work/_temp/0b1e1865-e1a1-4029-b13d-86c63995a4db' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
[command]/usr/bin/git config --global --add safe.directory /home/runner/work/gitgalaxy/gitgalaxy/gitgalaxy
Removing SSH command configuration
[command]/usr/bin/git config --local --name-only --get-regexp core.sshCommand
[command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
Removing HTTP extra header
[command]/usr/bin/git config --local --name-only --get-regexp http.https://github.com/.extraheader
[command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http.https://github.com/.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
Removing includeIf entries pointing to credentials config files
[command]/usr/bin/git config --local --name-only --get-regexp ^includeIf.gitdir:
[command]/usr/bin/git submodule foreach --recursive git config --local --show-origin --name-only --get-regexp remote.origin.url
Cleaning up orphan processes

@squid-shepherd squid-shepherd Bot added the shepherd:needs-fix Bot: a real failure on this head; see the digest comment. Guide: docs/ci.md label Nov 22, 2026
@squid-protocol

Copy link
Copy Markdown
Owner Author

Waiting on an owner decision (asked privately, 2026-11-22). Nothing is needed from contributors; work resumes once it is answered.

squid-protocol added a commit that referenced this pull request Nov 23, 2026
 #9056 #9057 #9058 #9059 #9061 #9067) (#9111)

* apply #9053 (non-snapshot changes)

* apply #9054 (non-snapshot changes)

* apply #9057 (non-snapshot changes)

* apply #9059 (non-snapshot changes)

* apply #9061 (non-snapshot changes)

* apply #9067 (non-snapshot changes)

* apply #9055 (non-snapshot changes)

* golden: re-bless once for the seven stacked engine fixes (#9053 #9054 #9055 #9057 #9059 #9061 #9067)

Each of the seven PRs conflicted with the others in the golden-master snapshots, so merging them
one at a time would have re-conflicted the rest each time. One combined branch, one bless
(crucible_check.py --update --yes through golden-lock.sh, both legs) plus the dartdoom DOOM golden.

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

* apply #9056 #9058 (non-snapshot changes)

* golden: re-bless with #9056 and #9058 folded in (powershell, perl) plus odamex and prboom-plus DOOM goldens

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

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
@squid-protocol

Copy link
Copy Markdown
Owner Author

Superseded by #9111 (merged as fcc440b), which carries this PR's hand-written change with the golden snapshots re-blessed once for all nine.

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 shepherd:needs-fix Bot: a real failure on this head; see the digest comment. Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ada: a nested subprogram takes its parent's body (the parent's branch goes to the nested function)

1 participant