Skip to content

MagicAST: write CONTRIBUTING.md terminology + AST styling guide; auto-generate GLOSSARY.md #8

Description

@Spelkington

Parent

Follow-up to the MagicAST restructure milestone. Depends on all five restructure phases (#2#6) so the documented conventions describe the post-restructure architecture, not the current one.

What to build

Two related deliverables:

1. CONTRIBUTING.md terminology + AST styling guide

Expand libs/magic-ast/CONTRIBUTING.md to be the canonical reference for contributors and AFK agents working on MagicAST. Two new sections at the bottom of the file:

AST styling conventions:

  • File organization (where new ability/effect/parser files go, how to pick a directory under AST/)
  • Naming conventions (discriminator string format, class name format, record field naming)
  • The attribute-driven registration pattern ([OracleAbility], [OracleEffect], [OracleAbilityParser], [StructuralKeyword]) — examples and gotchas
  • Trait interface conventions (IOptionalEffect, IDurativeEffect, etc.) — when to declare a new trait vs. reuse an existing one
  • Diagnostic conventions: when to emit an UnparsedAbility, how to choose a Diagnostic.Pattern string, when to extend FallbackParser.InferFailurePattern

Terminology (glossary):
The grilling session that produced this milestone resolved a set of terms that should be documented authoritatively. Starting list, not exhaustive:

  • TDD loop — the per-card round-trip cycle (hand-parse JSON → schema-gap red → parser-gap red → green)
  • Schema gap (Red Feat/atlas api web #1)JsonException at deserialization because the AST type system can't represent the hand-parsed JSON (missing node type / missing field / unknown discriminator)
  • Parser gap (Red MagicAST restructure: Phase 1 — Data-driven structural-keyword table #2)OracleParser output doesn't match the hand-parsed expected output even though both are representable
  • Hand-parsed card — a JSON file under HandParsedCards/{set}/{name}.json containing input (CardInputDTO) + output (expected CardOutputAST)
  • Triage — Flowthru pipeline that runs the parser over the full Scryfall oracle corpus, aggregates failure patterns by frequency, and emits a ranked report
  • Triage reportData/_08_Reporting/triage-report.json, the artifact agents read to pick their next assignment
  • Ratchet baselinetest-baseline.json, the snapshot of which tests are currently passing/failing; CI fails on regressions but tolerates stable failures
  • Cleanliness score — per-oracle-line metric ranking how well-isolated a candidate exemplar is for a target pattern (definition TBD — pending decision in the same session)
  • Oracle line — a \n-split chunk of a card's oracle text; the unit used by OracleLineTests
  • Card coverage / line coverage — the two completeness metrics in the triage report (card-level = all abilities parse; line-level = % of lines parsed)

The styling section should reference the auto-generated GLOSSARY.md (deliverable 2 below) as the source of truth for the current set of AST nodes.

2. Auto-generated GLOSSARY.md

A script under libs/magic-ast/scripts/ (suggested: generate-glossary.sh or a small C# tool) that:

  • Walks libs/magic-ast/AST/**/*.cs
  • Extracts <summary> XML doc comments paired with their immediately-following class/record declarations
  • Groups results by directory (e.g., Effects/Damage/* becomes a section)
  • Emits libs/magic-ast/GLOSSARY.md at the root of the library

No Roslyn, no DocFX — straight text/regex parsing is fine. The script runs on demand (during the agent loop, before the agent hand-parses) and as part of CI (to detect undocumented additions).

Acceptance criteria

Part 1 (CONTRIBUTING.md)

Part 2 (GLOSSARY.md script)

  • Script under libs/magic-ast/scripts/ produces libs/magic-ast/GLOSSARY.md from XML doc comments.
  • Output is grouped by AST subdirectory (Abilities, Effects/Damage, Effects/Counter, etc.).
  • Each entry shows: type name, discriminator string (from [OracleAbility] / [OracleEffect] attribute), summary text, and source file link.
  • CI fails if GLOSSARY.md is out of date relative to the source (i.e., script is part of pre-commit or CI; not just on-demand).

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-humanRequires human implementation or HITL checkpointsscope:magic-astAffects libs/magic-ast/

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions