Skip to content

feat(check): run Vue's compiler over every template in citry check (#207) - #234

Merged
JuroOravec merged 34 commits into
mainfrom
fix/static-checks-207-vue-compile
Oct 21, 2026
Merged

JuroOravec merged 34 commits into
mainfrom
fix/static-checks-207-vue-compile

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Part of #207, stacked on #233; merge that first. It implements proposal 2 from docs/design/issue_207_proposals.md: citry check runs Vue's own compiler over every template, so a structure Vue rejects is reported before the page runs.

What changes

  • A new rule: citry.vue.compile-error (setting rule_vue_compile_error), an error by default. It reports what Vue's compiler rejects, for example:
    • a <div> directly inside a <table>;
    • a button inside a button, or a form inside a form;
    • a v-else with no v-if before it;
    • a mismatched end tag.
  • How check builds the Vue template: citry/_vue/static_template.py writes the same Vue template a render writes, for templates only. It reuses the render's own writer functions, which were moved out of direct_capture.py, capture.py, leaf_program.py and component_render.py without changing their output.
    • Why not one shared function, as the proposal planned: a render builds its Vue template from what it rendered: the chosen <c-if> branch, every <c-for> row and the child components. So a single function for both isn't possible. Instead, a comparison test renders 13 template shapes for real and checks that the check side builds the same Vue template. The design doc records the change.
    • Positions: each error is mapped back to the authored template. An error is reported only where it starts in text the author wrote.
  • No double reports: an invalid Vue expression stays with citry.vue.invalid-expression, and a block inside <p> with citry.template.invalid-nesting, from feat(check): catch twelve more template mistakes before the app runs (#207) #229.
  • Component inside a Vue v-for: only citry check with the app loaded reports it, because transparent and simple components may legitimately sit there.

Evidence

  • Repository templates: 1,009 templates, no findings, at under 1 ms per template. It adds about 0.7 s to the whole-repo static check.
  • Docs examples: of 385 citry-html blocks, 3 findings, all real. Two are deliberate "this fails" examples. The third is in upgrading-to-0-6-0.md, which shows @click="if (ok) save()" as something that fails, and Vue does reject it. The feat(check): catch twelve more template mistakes before the app runs (#207) #229 expression rule doesn't, and should be tightened to match.
  • Tests: 75 new or updated, covering each compiler error and the valid templates that must stay silent: v-pre, <c-if> chains, slots, components, <c-provide> and #c-ignore.
  • Checks: ruff and mypy pass, including --platform linux. Every Python phase of the local gate passes; the Rust phases couldn't run in this worktree because a git submodule wasn't checked out, and no Rust changed.
  • Wheel size: 1,301,978 bytes, under the 1,351,680-byte cap.
  • Reviews: two rounds each of independent code review and a separate prose pass.

Bugs found along the way (not fixed here)

  • The landing page demo docs_site/snippets/landing/editor_invite_panel.py puts <c-MemberChip> inside a Vue v-for, and crashes when it renders.
  • In a component that uses Vue, a component call inside <table> or <tbody> fails when the page renders with a "Foster parenting" error. The cause is the tag Citry writes for the call, not the user's template, so the rule stays silent; the fix belongs in the runtime or the compiler.
  • A NUL character in a template makes the template compiler emit Python that can't run. The rule skips such templates; the fix is in Rust.

🤖 Generated with Claude Code

JuroOravec and others added 30 commits October 21, 2026 12:13
…M event tables

The template lint rules for #207 need more data from the standards than the
attribute index gave: which attributes are boolean, every WAI-ARIA 1.2 and
1.3 state and property, SVG and obsolete HTML element names, and the DOM
event names a listener may use. The generator now reads each from its
published source, with saved copies accepted for an offline refresh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ver (#207)

citry check and the editor now report, from the template alone:
misspelled attributes, elements, and DOM events; unknown aria-* names;
block elements inside <p>; literal ids two elements always render; <img>
without alt (warning); v-model on an element that holds no value; and Vue
expressions that are not valid JavaScript. The misspelled-directive rule
now covers v-* names such as v-iff, the attribute-value rule reports a
boolean attribute with a value other than its own name, and the
component-listener rule reports lowercase names such as @hdie and gets a
rule_undeclared_component_event setting.

Each rule has a rule_* setting on LintSettings and on a component's Lint
class, and the template-only ones also run in citry check --static.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mplate rules

From the independent review of the #207 rules: the Vue-only checks (v-*
directive typos, v-model targets, DOM event names) now skip v-pre content,
which Vue leaves as written; a whitespace-only Vue expression is reported;
obsolete block elements close a paragraph and <noscript> does not; <slot>
bindings are slot props; c-empty counts as a condition for duplicate ids; a
root <img> inside a top-level c-if chain counts as the single root; no
message suggests v-once or v-memo; a bound boolean string gets its own
message. The catalog text now matches the code, and the editor drops a
TypeScript error that repeats an invalid Vue expression.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two separate top-level c-if blocks can both render, so neither image there
is the single root Vue passes a parent's alt to. Also correct the docs and
catalog wording the second review pass found.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A data class field annotated as Literal[...] failed every call with
"Unsupported annotation". It now accepts exactly the listed values, each
read by its own type's rule, and the OpenAPI document lists them as an
enum. The events design also now says what the runtime does with a form:
arguments written in @c-submit replace the form's fields instead of
joining them, and the JSON path checks values strictly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…c-key

The render error for a component that a loop repeats without #c-key, or
with a duplicate key, said only "repeated component call". It now names
the tag as written, its template, and the line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
)

With the application loaded, citry check now reports a component that
<c-for> repeats without #c-key on a page that uses Vue; a component that
assigns to its own Vue prop (the editor reports it too, and a write in
component JavaScript is at most a warning); @c-* arguments the server
would reject: an unknown key, a missing required field, or a literal of
the wrong type; and a var(--name) one typing slip from a css_data() key.
Each has a rule_* setting.

A Boolean Vue prop given a string other than '' or its own name is now
reported, and a condition whose two results are literals is typed as
either result. A js_data() module constant that JSON cannot carry is a
warning in citry check, and a value ty types as a standard non-JSON type,
such as PurePosixPath, is a warning in the editor and citry check
--types. citry check --static notes, and the editor marks, a template it
skips because the base class comes from another module.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From the independent review of the #207 batch 2 rules: a component inside
a keyed component call needs no key of its own, an inner loop's c-empty
repeats with the outer loop, and a js_data() that the source shows always
returns {} does not make the page use Vue. A handler that accepts GET is
checked against its query-string reading too, only the last of two equal
keys is checked, and an Enum member in a Literal field matches its value
of any type. The --types command adds only the js_data() warnings that
need ty, and drops a repeat only at the same place in the same file. A
name js_data() imports or binds itself hides a module constant. The docs,
catalog, and changelogs now say what the code does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a non-JSON type

citry check --types read every component once per file to find these
warnings, which made a large library's check run out of time. It now
searches only the files where ty typed a js_data() value as a type JSON
cannot carry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The new template checks and their generated HTML and ARIA tables took the
wheel to 1,251,430 bytes, past the 1,220 KiB cap set at 1,188,823 bytes.
The cap is now 1,320 KiB, about 100 KB above the measured size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…#207)

A form that calls a server event can keep Django's hidden
csrfmiddlewaretoken input inside it. The dispatcher removes the names in
extensions_defaults["events"]["_csrf_field_names"] (default
csrfmiddlewaretoken) from a call's args before it checks the data class,
on the JavaScript and the no-JavaScript paths alike, unless the class
declares the name. The setting is engine-wide like _max_envelope_bytes
and is checked when the engine is built.

Also commits the #207 proposals and the maintainer's decisions as the
design record for this work.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t JavaScript (#207)

The browser now sends a form's controls as text and marks the call with
argsSource: "form", a new optional field of the citry-events/1 call
record (changed in place, still version 1). The dispatcher builds marked
args as StringArgs, so "3" fills an int field and a checked checkbox a
bool field, exactly as the no-JS form codec does. A call without the mark,
from page code, an API client, or older browser code, stays strict JSON.

The spec, schema, Python and TypeScript protocol code, conformance cases,
and the constraint registry change together; the shipped Python copy and
the browser bundles are regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… once the app loads (#207)

With the application loaded, the editor and citry check --types now read
the component catalog's owner_file and owner_qualname for each inline
template, JavaScript, and CSS, and pass the module-level class names to
static discovery as app_components. Discovery accepts those classes even
though their base class is not traceable from the file, so their
templates get every check. The app worker also says whether each
component renders its template as Citry's own template language, so a
template in another language is never parsed as Citry.

Without the app, or for a class added or renamed since it loaded, the
template-not-checked notice stays, now saying the template is checked
once Citry loads the application and finds the class.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…or too (#207)

The Events handler description (Citry.inspect_components, events.md
9.1) now carries extra_fields, which says whether an argument key the
data class does not declare fails the call, and validated_by, which says
whether Citry's own rules or Pydantic check the values. The editor builds
what each handler accepts from it and runs the same @c-* argument rules
as citry check, skipping a Pydantic model, a description from an older
Citry, and a handler whose method or data class has unsaved edits.

A new rule pair checks a form whose @c-submit sends its fields: a
control whose name the data class does not declare
(citry.browser.unknown-form-field), and, when the template shows every
control, a required field no control sends
(citry.browser.missing-form-field). Disabled controls, controls tied to
another form, buttons, file inputs, and the host CSRF field names the
server removes are skipped. Both rules have rule_* settings and run in
citry check with the app loaded and in the editor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The browser now sends the name and value of the submit button that sent
  a form, as a post without JavaScript does, and the form-field rule
  checks a named submit button; an image input, a #c-ignore region, and a
  bound attribute with a modifier such as :name.prop are handled.
- The editor compares a handler's data class with its file on disk using
  the location the app worker now sends, reads saved files without
  newline translation, so a file with CRLF line endings is checked, and
  caches the saved text and parsed definitions between passes.
- A Pydantic validation_alias counts as declaring a host CSRF field name.
- A class the loaded app lists is read even when it is decorated.
- The spec, design docs, user docs, catalog texts, settings docstrings,
  and changelogs now say what the code does: the form and query adapters
  bind text, a bad argsSource rejects the envelope, text binds at any
  depth, a misspelled control fails only the submits that send it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The editor treats a data class file that no buffer holds as the file
  the app read, so a closed file with CRLF line endings keeps the rules
  on.
- The form-field rule checks the x and y names an image button sends
  instead of its bare name, skips a button whose click is prevented, and
  reads Vue's ^name and .name shorthands as bindings.
- A decorated class the loaded app lists is read even when its base is
  Citry's own Component.
- The docs, spec, and catalog say how image buttons behave.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	CHANGELOG.md
#	docs/design/events.md
#	docs/design/ide_integration.md
#	docs_site/content/ide/template-linting.md
#	packages/protocol/diagnostics/CHANGELOG.md
#	packages/protocol/diagnostics/v1/catalog.json
#	packages/py/citry/citry/_checker.py
#	packages/py/citry/citry/_diagnostic_catalog.py
#	packages/py/citry/citry/_linting.py
#	packages/py/citry/citry/_registry_lint.py
#	packages/py/citry/citry/analysis.py
#	packages/py/citry/citry/ext/events/schemas.py
#	packages/py/citry/citry/settings.py
#	packages/py/citry/tests/test_analysis.py
#	packages/py/citry/tests/test_check_app_rules.py
#	packages/py/citry/tests/test_diagnostics.py
#	packages/py/citry_lsp/CHANGELOG.md
#	packages/py/citry_lsp/citry_lsp/engine.py
#	packages/py/citry_lsp/tests/test_engine.py
…ypes (#207)

Proposals 5 and 7 of docs/design/issue_207_proposals.md, Option 1 each.

A fill's whole-data name, such as `card` in
`<c-fill name="footer" data="card">`, now gets the fields of the slot's
`SlotInput[T]`. The app worker sends each typed slot's fields
(`slot_data_classes`), `TemplatePythonControl.slot_target` records the
component tag and slot, and the ty check file declares the name as a
generated `Mapping[str, Any]` subclass with T's fields, so `card.titel`
and `card.count + " tasks"` are reported (benchmark m36, m37) while
`card["aria-label"]`, `len(card)` and `**card` stay valid, as at runtime.

In the TypeScript check file, a `:prop` value on a child component tag is
passed to a helper typed from the prop's `type` in the child's
`$component` source, with `''` and the hyphenated name added for a
Boolean prop as Vue converts them, and `object` for an Object prop. The
Python prop check now accepts an array for an Object prop too, as Vue
does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…solve

The docs build read `extensions_defaults["events"]["_csrf_field_names"]`
as a cross-reference and failed its crossref guard. Name the setting in
words instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rve (#207)

Proposal 6 of docs/design/issue_207_proposals.md, as decided: a new
`rule_unknown_url` in LintSettings, a warning by default
(`citry.template.unknown-url`, with a did-you-mean one typing slip away).

Citry does not know the host app's routes, so `citry.contrib.flask.mount()`,
`citry.contrib.fastapi.mount()` and `citry.contrib.django.urlpatterns()`
each register a path checker on the Citry instance (a private
registration in `citry/_path_checks.py`). It answers from Flask's URL map
and static folders, Starlette's routes and StaticFiles mounts, or
Django's resolve() and static file finders. `citry check` with the app
loaded asks it about each literal root-relative `href`, `src` and
`action` path, resolved the way the browser requests it. The editor's
app worker asks it once while the app is loaded and sends the answers.

When no integration ran, `citry check` checks no links and adds one note
(`citry.check.url-checker-missing`); a checker that raises skips its
path and adds one note (`citry.check.url-checker-failed`). Flask is a new
test-only dev dependency, so the Flask checker is tested against real
werkzeug routing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to fix/static-checks-207-types

# Conflicts:
#	packages/py/citry/citry/ext/events/dispatcher.py
… config does

The root config targets Python 3.10, which has no tomllib, so ruff groups it
with third-party imports, as the other benchmark tests already do. main has
the same failure; #232 carries the identical fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aved edits

On Windows the file on disk can hold `\r\n` while the editor buffer holds
`\n`. The editor then thought every handler had unsaved edits and turned
the server-event and form-field checks off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec and others added 2 commits October 21, 2026 17:13
…d the editor (#207)

`citry check`, `citry check --static` and the editor now write the Vue
template a render would compile, compile it with the same Rust compiler,
and report what it rejects as `citry.vue.compile-error`
(`rule_vue_compile_error`, an error by default), mapped back to the text
the author wrote: a <div> directly inside a <table>, nested buttons, forms
or links, an orphan v-else, and (with the app loaded) a component inside
a Vue v-for.

The writer (`_vue/static_template.py`) walks the nodes the template
compiler produces and calls the functions a render uses to write each
kind of node, now pulled out of `direct_capture.py`, `capture.py`,
`leaf_program.py` and `component_render.py` without changing their
output. It asks `compile_leaf_program` whether a render would wrap each
<c-if> branch in a <template>, and does the same. A test renders
components and checks that both produce the same Vue template.

Errors the expression and paragraph-nesting rules already explain are
left to them. No compiler output, AST or PyO3 change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	docs/design/ide_integration.md
#	docs/design/issue_207_proposals.md
#	packages/protocol/diagnostics/CHANGELOG.md
#	packages/py/citry/citry/_checker.py
#	packages/py/citry/citry/_registry_lint.py
#	packages/py/citry/tests/test_check_app_rules.py
#	packages/py/citry_lsp/CHANGELOG.md
#	packages/py/citry_lsp/citry_lsp/engine.py
#	packages/py/citry_lsp/citry_lsp/project.py
#	packages/py/citry_lsp/tests/test_project.py
#	packages/py/citry_lsp/tests/test_server_event_payloads.py
Base automatically changed from fix/static-checks-207-types to main October 21, 2026 16:30
@JuroOravec
JuroOravec merged commit cef4cb0 into main Oct 21, 2026
26 checks passed
@JuroOravec
JuroOravec deleted the fix/static-checks-207-vue-compile branch October 22, 2026 08:17
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