Skip to content

Strict parsing tests: yaml structural signatures #617

Closed

Description

@squid-protocol

Update: the lexical-delimiter checklist item originally in this issue (_line_anchor/_inline_comment/_block_start/_block_end) has been removed -- those 4 rule keys are dead config, never read anywhere in gitgalaxy/ (confirmed via grep -rn across the whole package). The real comment-stripping engine (prism.py's _strip_segment_comments) dispatches purely on lexical_family against a separate family-level table in gitgalaxy_config.py. See the epic (#518) for the new issue tracking that real gap instead.


Part of #518.

Language: yaml

  • Lexical family: line_exclusive
  • Extensions: .yml, .yaml, .yamllint
  • 31 of the baseline structural signatures are defined (non-None) for this language in gitgalaxy/standards/language_standards.py.

Reference

gitgalaxy/standards/how_to_add_a_language.md is the canonical doc for what each signature is supposed to capture/exclude, the 5 lexical parsing families, and (recently added) the AI/ML and literate-programming extension packs. Read the INCLUDES/EXCLUDES wording there for any signature before writing its test -- the one-line descriptions below are a quick-reference copy, not the full spec.

A rule being None here is not a gap

Only write tests for the checklist below. If a signature isn't in this language's rules dict, or is explicitly None, that's an intentional "doesn't apply to this language" per the doc's Strict Feature Parity rule (#4) -- don't invent a synthetic match for it just to have a test.

Lexical family note: This language's lexical family is line_exclusive -- there is no native multi-line block syntax; confirm the engine correctly ignores stray closing tokens rather than treating them as real block terminators.

Checklist (this language's non-None structural signatures)

Phase 1: Logic Topology & Structure

  • branch -- Control flow that forces a decision or jump: if, else, switch, for, while, catch, try, &&, ||, ternary.
  • args -- Parameter blocks of functions, methods, and lambdas. Must safely step over type hints and generics without ReDoS.
  • structural_boundaries -- Keywords defining structural boundaries and straight-line execution: var, return, class, import.
  • func_start -- Exact syntax anchoring the start of an executable block of logic: method signatures, constructors.
  • class_start -- The syntax defining an object-oriented class, struct, or record.

Phase 2: Safety & Execution Risk

  • safety -- Defensive programming constructs that prevent crashes at runtime: try/catch, explicit null checks, guard.
  • safety_bypasses -- Syntax that actively bypasses type safety, swallows errors, or relies on unpredictable state: force unwrapping (!), any, raw memory casting, linter bypasses (@ts-ignore).
  • high_risk_execution -- Process-killing commands and catastrophic runtime vulnerabilities: eval, exec, process.exit.
  • io -- Interaction with disk, network, or external systems: file reading/writing, HTTP clients, sockets.
  • api -- Code exposed to the outside world. Captures explicit visibility markers (export, public) AND implicit architectural defaults for implicitly-public languages (Python, Fortran).
  • state_mutation -- Reassignment of variables or modifying collections: let, mut, volatile, .push(), .set().
  • dead_code -- Commented-out structural code and unused logic trails: // if (x), /* var y */.
  • doc -- Structured documentation meant to be parsed by IDEs or generators: JSDoc, docstrings.
  • test -- Assertions and unit testing framework keywords: describe, it, assert, expect.

Phase 3: Architecture & Domain Sensors

  • concurrency -- Asynchronous logic and parallel execution: async, await, Promise, Thread.
  • globals -- Accessing global state, environment variables, or system registries: window., process.env.
  • reflection_metaprogramming -- Metaprogramming, reflection, and dynamic property assignment: Reflection, Proxy, .bind().
  • import -- Dependency resolution and module loading (import, require, using), plus the paired capture-group rule that extracts the exact dependency path string for the dependency graph.

Phase 4: Specialized Sub-systems

  • planned_debt -- Annotated future work: TODO, WIP, STUB.
  • fragile_debt -- Explicit admissions of fragile or dangerous logic: HACK, FIXME, XXX.
  • events -- Event-driven architecture signatures and message brokers: emit, EventEmitter, Kafka.
  • dependency_injection -- Inversion of Control (IoC) injection markers: @Autowired, @Inject.

Phase 5: Resource Management & Stability

  • telemetry -- Structured logging and observability frameworks.
  • debug_prints -- Ad-hoc, temporary debug statements: print(, console.log(.
  • panics_and_aborts -- Forcefully destroying the current execution context: throw, raise, panic!, abort().
  • thread_sleeps -- Thread blocking or forced timeouts: sleep(, delay(.
  • immutability_locks -- Explicitly locking data so it cannot be mutated: const, final, readonly.
  • listeners -- Waiting to receive state from an external broadcast: on(, addEventListener, subscribe(.
  • test_skip -- Bypassed tests or ignored verification specs: @ignore, test.skip(.

Test template

For each checked signature: (1) a positive-match test against its documented includes, capturing exact group text where applicable; (2) a negative-match test against its documented excludes; (3) any cross-rule ambiguity check flagged above; (4) a ReDoS immunity test (reuse assert_redos_immune from tests/core_engine/test_language_standards_strict.py) sized to this rule's actual quantifiers. Group multiple signatures that share the same simple pattern into one parametrized test rather than writing near-duplicates -- don't force one test per key if several are trivially similar for this language.

New tests land in tests/core_engine/test_language_standards_strict.py, the existing home for this style of test.

Activity

  1. added
    testing
    core-engine
    on Jul 26, 2026
  2. squid-protocol commented on Jul 28, 2026

    @squid-protocol
    OwnerAuthor

    Reopening. The closing PR (#681) explicitly skipped the golden crucible verification step:

    [ ] pytest -m golden_crucible -- **not run**, the language-crucible corpus isn't checked out in this environment and LANGUAGE_CRUCIBLE_PATH isn't set.

    This wasn't just a missed checkbox -- it turned out to matter. While investigating a related bug (#691, markdown's structural signatures never being counted in a real scan), I found yaml sits in the exact same detector.py "Prose Deflection" gate that was blocking markdown:

    if confidence < 0.42 or self.primary_lang_id in (
        "plaintext", "json", "yaml", "csv",
    ):
        return {"equations": {}, ...}  # early return, nothing scanned

    This gate discards equations (and therefore every structural signature) before coding_analysis ever runs -- for every yaml file, unconditionally, regardless of code_stream content. Unlike markdown, yaml's code_stream is actually populated correctly (confirmed via direct Prism.split_streams() execution -- yaml doesn't go through prism.py's Prose Bypass), so the 5 real regex bugs #681 fixed (high_risk_execution's rm -rf / boundary bug, test_skip's --passWithNoTests boundary bug, events' schedule: anchor bug, telemetry's ::warning:: anchor bug, and the reflection_metaprogramming ReDoS) are all correct fixes -- they've just never been exercised in a real scan, because this gate has been silently discarding yaml's results the entire time. Confirmed by calling coding_analysis() directly (bypassing only the gate) against a realistic sample containing several of these exact constructs -- it correctly fires high_risk_execution, events, telemetry, etc.

    Since #681's unit-level tests (test_language_standards_strict.py) call the regexes directly against LANGUAGE_DEFINITIONS["yaml"]["rules"], bypassing detector.py entirely, they had no way to catch this -- it's a pipeline-level bug, not a regex-level one, same category as #691.

    What's needed to close this properly:

    1. The pipeline fix itself is being tracked as its own issue (refactoring the gate for yaml/json/csv together, since they share the identical bug shape) -- linking once filed.
    2. Once that lands, this issue should re-run pytest -m golden_crucible in both full-precision and zero-dependency venvs, and the diff should be walked through and explained file-by-file (per how_to_add_a_language.md's Step 5), not just checked for a clean pass/fail -- given the gate fix will likely produce real, previously-invisible diffs on every yaml file in the corpus, similar in shape to what Prose-bypass languages (markdown, plus yaml/json/csv/plaintext) never get their structural signatures counted, regardless of regex correctness #691/Let markdown's structural signatures reach the detector output #692 produced for markdown.

    Leaving open until that verification actually happens.

  3. squid-protocol commented on Jul 28, 2026

    @squid-protocol
    OwnerAuthor

    Verification results: 4 of 5 confirmed working end-to-end, 1 blocked by a newly-found separate bug

    #694/#695 (the pipeline gate fix) is merged. Verified on the merged main:

    pytest -m golden_crucible passes cleanly in both full-precision and zero-dependency venvs. But this is not proof that #681's specific fixes work -- I checked, and none of the 7 yaml files in the crucible corpus (all Ansible playbooks/tasks) happen to contain rm -rf /, schedule:, ::warning::, or --passWithNoTests/--no-audit anywhere. The clean pass reflects absence of those constructs in this corpus sample, not confirmation they're detected -- so I verified directly instead, via a realistic GitHub Actions workflow sample exercising all 5 fixes against the real, merged pipeline:

    Traced the test_skip failure to a new, separate, and more severe bug: filed as #697. prism.py's _strip_single_line_comments() -- the function every line_exclusive-family language (22 of them, including already-closed python/shell/ruby/perl) routes through -- hardcodes #|--|;|// as its comment-marker pattern, completely ignoring the real per-family delimiter config (which for line_exclusive doesn't include -- at all). Any line containing a literal -- anywhere gets everything from that point on silently discarded as a "comment" before it ever reaches a structural-signature regex. run: npm test -- --passWithNoTests becomes run: npm test in code_stream -- the test_skip regex is correct, it just never sees its own target text.

    This is a bigger, separate fix (#697) -- not something to bundle into closing this issue.

    Leaving #617 open until #697 lands and test_skip can be verified the same way as the other 4. Once that's confirmed, this is ready to close for real.

  4. squid-protocol commented on Jul 29, 2026

    @squid-protocol
    OwnerAuthor

    Verification complete: all 5 fixes confirmed working end-to-end, ready to close

    #697/#698 (the prism.py ---truncation fix) merged 2026-07-28. Re-ran the same end-to-end
    verification as before, now against the fully-merged pipeline.

    Real pipeline test (a small standalone repo scanned with galaxyscope, not just the unit
    regexes) against a sample exercising all 5 originally-fixed constructs in one file:

    name: CI
    on:
      schedule:
        - cron: '0 0 * * *'
    jobs:
      build:
        steps:
          - run: rm -rf / --no-preserve-root
          - run: |
              echo "::warning::deprecated step"
          - run: npm test -- --passWithNoTests

    Resulting structural signature counts from the real scan:

    All 5 confirmed, including test_skip, which was the one bug specifically blocked pending #697.

    golden_crucible, both venvs, against unmodified main:

    ✅ full_precision: PASS
    ✅ zero_dependency: PASS
    

    (ran via the new tests/tools/crucible_check.py -- while dogfooding it here, found and fixed
    an unrelated pre-existing bug in the script itself, PR #727, confirming both legs are now
    genuinely clean rather than accidentally green)

    Closing.

  5. added this to the v2.4.6 milestone on Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-enginetesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions