Skip to content

feat(standards): implement Ada & SPARK structural signatures (#76) - #1140

Merged
squid-protocol merged 2 commits into
mainfrom
feature/ada-spark-structural-signatures-76
Aug 7, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
feature/ada-spark-structural-signatures-76

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Implements #76 (epic #75, "Aerospace Compliance & Enterprise Integration",
Phase 1) -- adds native Ada/SPARK structural-signature support to
gitgalaxy/standards/language_standards.py, following
gitgalaxy/standards/how_to_add_a_language.md's generation and
strict-testing protocol.

  • Full 54-key baseline rules dict for ada (extensions .adb/.ads/.ada).
    5 keys are explicit None where Ada genuinely has no equivalent
    (ui_framework, closures, tabs_vs_spaces, ssr_boundaries,
    dependency_injection) -- Strict Feature Parity, not an oversight.
  • safety covers Implement Ada & SPARK Structural Signatures #76's explicit ask: strict-typing range constraints
    (type ... is range, and the equally common subtype X is Base range Lo .. Hi form) plus a scoped safety-pragma vocabulary (pragma Assert,
    Precondition, Postcondition, Invariant) -- deliberately not bare
    pragma, since most pragmas (Pack, Import, ...) have nothing to do
    with safety.
  • api covers package specs (package ... is), correctly excluding
    package body ... and generic-instantiation package X is new ...
    via negative lookaheads (not optional groups, per Rule 15).
  • class_start covers Ada's real OOP entity -- tagged types, both root
    declarations (type Foo is tagged record) and derived/extended ones
    (type Dog is new Animal with record, where the literal word tagged
    is never repeated, so the derived form needs its own alternative or an
    entire inheritance chain becomes invisible).
  • func_start requires a real subprogram body (Rule 7: strict execution
    anchoring), excluding spec-only declarations, abstract/null
    procedures, and generic-subprogram instantiations -- while still
    matching SPARK's common with Pre => ..., Post => ... aspect clause
    between the profile and is.

A real pipeline bug caught before it shipped

Both the issue and epic label Ada's lexical_family "hybrid_dash". That
name doesn't exist anywhere in the engine. Using it verbatim would have
silently broken comment stripping for every Ada file: prism.py's generic
stripper falls through with an empty compiled pattern for any family name
it doesn't recognize, so -- comments would never be removed from the code
stream, contaminating every downstream signature count with comment noise.

Root cause: Ada genuinely has no block-comment form ("no native block
comments historically" is in #76's own checklist, directly contradicting
the "hybrid_dash" name it also asks for). Reusing the existing
"line_exclusive" family was also rejected -- its shared delimiter list is
consumed by several other languages (Perl, Assembly) that use -- as a
real operator/decrement; widening it would silently truncate their real
code, the exact failure mode #621 already fixed once by narrowing
"standard_block".

Fix: registered a new, properly-wired "line_exclusive_dash" family
(single -- delimiter, no block form) in gitgalaxy_config.py's
LEXICAL_FAMILY_HEURISTICS, and added the matching branch in prism.py's
_compile_regex_matrix(). Verified end-to-end with a real
Prism.split_streams() call (see test_ada_lexical_family_is_correctly_ wired_not_just_labeled), not just that the config key exists.

Test plan

  • tests/extraction/languages/test_ada.py -- extraction gauntlet
    (func_start/args/class_start/_dependency_capture: valid/invalid/
    pathological/ReDoS-immunity cases)
  • tests/extraction/languages/test_ada_strict.py -- per-signature
    positive/negative coverage for all 49 non-None keys, schema
    completeness audit, symbolic-boundary audit (Ada attributes like
    'Class/'Access), nested-delimiter audit, re.M completeness
    audit, ambiguity sweep (documents intentional double-classifications
    like protected/delay firing both concurrency and their more
    specific sibling, mirroring COBOL's existing EXEC CICS ENQ
    precedent), and a geometric ReDoS scaling sweep
  • python tests/tools/audit_check.py -- ruff/mypy/dead-key baselines
    all clean, ruff format . clean
  • python tests/tools/crucible_check.py -- both full-precision and
    zero-dependency modes pass with zero diff (the language-crucible
    corpus has no Ada files yet, confirmed via find, so this proves no
    off-target blast radius on the other ~80 languages rather than
    Ada-specific regression coverage)
  • python -m pytest tests/ -- full suite green (6700 passed)

Closes #76.

Adds the full 54-key baseline signature dict for Ada/SPARK to
LANGUAGE_DEFINITIONS, following how_to_add_a_language.md's generation and
strict-testing protocol.

The epic/issue's suggested lexical_family ("hybrid_dash") doesn't exist
anywhere in the engine and doesn't match Ada's real comment grammar (no
native block-comment form). Using it verbatim would have silently disabled
comment stripping for every Ada file: Prism's generic stripper falls
through with an empty compiled pattern for any family name it doesn't
recognize. Registered a new, properly-wired "line_exclusive_dash" family
instead (gitgalaxy_config.py's LEXICAL_FAMILY_HEURISTICS + a new branch in
prism.py's _compile_regex_matrix) scoped to Ada's actual single-token `--`
comment grammar, rather than widening the existing shared "line_exclusive"
family (which would have silently truncated real code in Perl/Assembly,
both of which use `--` as a real operator -- the same failure mode #621
already fixed once by narrowing "standard_block").

Verified via tests/extraction/languages/test_ada.py (extraction gauntlet:
func_start/args/class_start/_dependency_capture) and test_ada_strict.py
(per-signature coverage, schema completeness, symbolic-boundary/nested-
delimiter/ReDoS/ambiguity audits, and an end-to-end Prism.split_streams()
proof that -- comments are actually stripped). Full test suite, ruff/mypy/
dead-key baseline audits, and crucible_check.py (both full-precision and
zero-dependency modes) all pass with zero diff -- the language-crucible
corpus has no Ada files yet, confirmed via find, so the zero diff proves no
off-target blast radius on the other ~80 languages rather than Ada-specific
coverage.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

The shared aspect-mark vocabulary (decorators/import/_dependency_capture)
only covered the foundational SPARK contract aspects (Pre/Post/Global/
Depends/SPARK_Mode), missing the data-flow refinement aspects
(Abstract_State/Initializes/Refined_Global/Refined_Post/Refined_State/
Refined_Depends) used to formally model a package's private state for the
prover -- common in real SPARK code. They didn't misfire as false imports
(the `=>` already breaks import's required trailing-`;` grammar shape
either way), they were just invisible to every signature. Also adds the
`pragma SPARK_Mode (On);` form, structurally distinct from the `with
SPARK_Mode => On` aspect form already covered -- both are real and common.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@squid-protocol
squid-protocol merged commit e55ab3f into main Aug 7, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the feature/ada-spark-structural-signatures-76 branch August 7, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Ada & SPARK Structural Signatures

1 participant