Skip to content

feat(language): a file says what it reads under one given key - #520

Closed
FBumann wants to merge 1 commit into
claude/mathspec-fragment-wordfrom
claude/mathspec-given-block
Closed

FBumann wants to merge 1 commit into
claude/mathspec-fragment-wordfrom
claude/mathspec-given-block

Conversation

@FBumann

@FBumann FBumann commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Prompt: "Decided with @FabianHofmann: Move all about given into a top level key."

Note

The following content was generated by AI.

What this changes

Two top-level keys become one, closed at two kinds:

given:
  variables:
    Port_p: { dims: [snapshot, port] }
  constraints:
    Bus_nodal_balance: { dims: [snapshot, bus] }

The loaded objects follow the file, so the schema is the shape a reader sees: Spec.given.variables, Spec.given.constraints, and Program.given.variables / .constraints on a GivenTargets. The declaration keys go from twelve back to eleven, which is one fewer than the count #507 asks you to accept.

Both types keep their own blocks (GivenVariableBlock, GivenConstraintBlock) — only where they sit moved. given: itself takes those two keys and nothing else:

given: unknown key 'parameters' in a given block. Valid keys: constraints, variables.
Everything that moved
Where What
model.py GivenBlock holds both mappings; Spec.given replaces the two fields; the collision walk and the frame walk read through it
program.py GivenTargets holds both, sealed as every other group is; Program.given replaces the two fields
composition.py GIVEN_SECTIONS becomes GIVEN_KINDS, which maps the key inside given: to what one entry is called. The key is the owning section's name too, so section.removeprefix('given_') is gone
lowering.py, resolution.py, dimensions.py, advice.py, typesetting/ every read is schema.given.variables or schema.given.constraints
examples/library/ generator.yaml and load.yaml declare given: variables:
docs declarations.md is one ## given section with two subsections, and the anchor #given is what the other pages link

_agreed now takes the label for what one entry is called, because the same helper folds the coordinate space and the given kinds, and only the caller knows which. _lay_over gained a given branch: a patch is laid over one kind at a time, so patching the columns a file reads cannot drop the row families beside them.

Verified

Same environment as the rest of the stack: python 3.13, dependencies by pip, not the pinned solve.

  • pytest -q — 1367 passed, 6 skipped (1365 on fix(language): a composition refusal calls a library file a fragment rather than a template #511's head, so 2 new; every other test moved with the rename rather than being added).
  • python -m tools.schema regenerated; the diff is GivenBlock added, the two top-level properties replaced by one $ref. python -m tools.gallery regenerated the four library pages. The golden typesetter output does not move — the golden model reads nothing.
  • mkdocs build --strict builds, after the usual local drop of the CPython inventory this proxy 403s. The built page carries id="given", id="given-variables" and id="given-constraints", and both inbound links resolve to #given.
  • ruff format --check ., ruff check, typos, prettier clean. render_tex renders 34 models.
  • Sentence length on the pages this touched, median and count over 25 words: declarations 13/10, file 11/2, limits 17/26, howto/compose 14/4. This diff changed four sentences on those pages.

Not run: reuse, zizmor, taplo, and compile-tex's tectonic half.

Mutation table

Two guards are new here, and each is caught by the test written for it.

Mutation Result
_lay_over replaces given: whole rather than a kind at a time 1 failed — test_a_patch_over_one_kind_of_given_leaves_the_other_alone
GivenBlock is open rather than closed 2 failed — test_given_holds_two_kinds_and_refuses_a_third, and the schema drift test
restored 1367 passed

Deliberately not done

Stack: on #511 → #510 → #508 → #507 → #505.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CA5v9XJvgYViUHP7hSiKPU


Generated by Claude Code

`given_variables:` and `given_constraints:` become `given: variables:` and
`given: constraints:`, and the block is closed at those two kinds. `Spec.given`
and `Program.given` follow the file, so the schema is the shape a reader sees.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CA5v9XJvgYViUHP7hSiKPU
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.

2 participants