Skip to content

fix(fight): a commented-out signature header silently deletes a scanner - #79

Merged
hyperpolymath merged 1 commit into
fix/restore-workspace-buildfrom
fix/gate-triage-parser-reads-its-own-documentation
Sep 14, 2026
Merged

hyperpolymath merged 1 commit into
fix/restore-workspace-buildfrom
fix/gate-triage-parser-reads-its-own-documentation

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

What is wrong

parse_signatures splits the directive on the bare literal:

for chunk in raw.split(SIGNATURE_TABLE).skip(1) {

SIGNATURE_TABLE is [[gate-triage.detection.signatures]]. The split matches that
text anywhere — in prose, and inside a # comment.

The directive this parser reads documents its own table name in a comment:
.machine_readable/bot_directives/gate_triage.a2ml:174, inside the
[gate-triage.detection] section that opens at line 171 — well above the three real
headers at 258 / 265 / 272.

Two failures, both now covered by tests that are RED against the old parser

Grafting the two new tests onto the current parser, unchanged:

test gate_triage::tests::a_prose_mention_of_the_table_name_does_not_open_a_scanner ... FAILED
  left: 2
 right: 1

test gate_triage::tests::a_commented_out_header_neither_opens_nor_closes_a_table ... FAILED
  left: 0
 right: 1

test result: FAILED. 43 passed; 2 failed
  1. A prose or commented mention opens a phantom scannerleft: 2, right: 1.
  2. A commented-out header deletes a real scannerleft: 0, right: 1. This is the
    serious one. The stray match closes the live table above it and opens a body which
    the section-header scan then discards, so both halves are dropped and the scanner
    vanishes. It does not add noise; it silently removes enforcement.

The fix

Line-oriented. signature_bodies walks split_inclusive('\n'), strips each line's
trailing comment via code_of, and treats a line as a header only when the code
part is exactly the table name. A comment can then neither open nor close a table.

until_next_header is retained — section_of still calls it, so removing it would
trip unused_imports/dead-code under -D warnings.

Two pre-existing assert_eq! calls in this file are reflowed by rustfmt; that is the
only churn outside the new code.

Not fixed here, but adjacent

extract_array in crates/squabble-fight/src/context.rs:152 has the same
comment-blindness: once collecting, it pushes quoted strings from every subsequent
line, comments included, until ]. Out of scope for this PR; worth a follow-up.

Verification

cargo test --workspace --all-features                                 130 passed, 0 failed
cargo clippy --workspace --all-features --all-targets -- -D warnings  rc=0
cargo fmt --all --check                                               gate_triage.rs clean

cargo fmt --all --check still exits 1 for three diffs in
crates/squabble-core/src/polarity.rs — those are pre-existing on main, unrelated
to this change, and deliberately untouched.

Two things a reviewer should know

🤖 Generated with Claude Code

https://claude.ai/code/session_0178nN4Nm3neFRy5K9StZKnB

`parse_signatures` split the directive with

    raw.split(SIGNATURE_TABLE).skip(1)

which matches the literal `[[gate-triage.detection.signatures]]` anywhere in
the file — including inside a `#` comment and inside prose. The directive it
parses documents its own table name in a comment at
`.machine_readable/bot_directives/gate_triage.a2ml:174`, inside the
`[gate-triage.detection]` section that opens at line 171, well above the three
real headers at 258 / 265 / 272.

Two distinct failures, both now covered by tests that fail against the old
parser:

  - a prose or commented mention OPENS a phantom scanner
        left: 2   right: 1
  - a commented-out header CLOSES the live table above it and opens a body
    the section-header scan then discards, so BOTH halves are dropped
        left: 0   right: 1

The second is the serious one: it does not add noise, it removes a real
scanner, and it does so silently.

The fix is line-oriented. `signature_bodies` walks `split_inclusive('\n')`,
strips each line's trailing comment with `code_of`, and only treats a line as
a header when the CODE part is exactly the table name — so a comment can
neither open nor close a table. `until_next_header` is retained because
`section_of` still uses it.

Note that `extract_array` in context.rs has the same comment-blindness once it
is collecting; that is not touched here.

Stacked on #78 because `main` does not currently compile.

  cargo test --workspace --all-features   130 passed, 0 failed
  cargo clippy --workspace --all-features --all-targets -- -D warnings   rc=0
  cargo fmt --all --check   gate_triage.rs clean (3 pre-existing diffs remain
  in crates/squabble-core/src/polarity.rs, unrelated and untouched)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0178nN4Nm3neFRy5K9StZKnB
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: ac593e2d-662e-4c6d-9d4e-e932875d4bfb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath merged commit 3626792 into fix/restore-workspace-build Sep 14, 2026
20 of 21 checks passed
@hyperpolymath
hyperpolymath deleted the fix/gate-triage-parser-reads-its-own-documentation branch September 14, 2026 17:31
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.

1 participant