Skip to content

feat(check): typed slot data and prop expressions in the editor; check links against the app (#207) - #233

Merged
JuroOravec merged 31 commits into
mainfrom
fix/static-checks-207-types
Oct 21, 2026
Merged

JuroOravec merged 31 commits into
mainfrom
fix/static-checks-207-types

Conversation

@JuroOravec

@JuroOravec JuroOravec commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Also restores a fix #231 lost. GitHub's pull-request delays meant #231 was squash-merged from an older head (689614461), without its last two commits: the editor ignored line-ending differences when deciding whether a handler has unsaved edits. Without that, on Windows every handler looks edited and the server-event and form-field checks switch off; main's Windows tests fail on it. This branch already had those commits, and the merge with main keeps them, so merging #233 puts the fix on main.

Part of #207, stacked on #231; merge that first. It implements proposals 5, 6 and 7 from docs/design/issue_207_proposals.md, as decided there.

What changes

  1. Typed slot data in the editor and --types (proposal 5).
    • The app worker, the process citry-lsp starts to import the app, now sends each typed slot's fields.
    • The Python file Citry generates from a template for ty to check gives a fill's data variable a type with those fields. So card.titel and card.count + " tasks" are reported, while card["aria-label"], len(card) and **card stay valid, as they are at runtime.
    • An editor test covers the whole path, with the child component defined in another module.
  2. Typed prop values written as expressions (proposal 7). In the TypeScript file citry-lsp generates from a template, a :prop value on a child component is checked against the prop's type in the child's $component source. So :open="count" against a Boolean prop is reported. A Boolean prop also accepts '' and its own hyphenated name, as Vue does. type: Object accepts arrays, Date and class instances, here and in the existing Python prop check.
  3. Links to pages and files the app doesn't serve (proposal 6).
    • The rule: rule_unknown_url in LintSettings, a warning by default.
    • Who registers a checker: Flask's and FastAPI's mount() and Django's urlpatterns(), through a private hook. No new public setting.
    • What it checks: literal root-relative href, src and action paths, against the app's routes and static files:
      • Flask: the URL map and the static folder;
      • Starlette: route matching, including StaticFiles mounts;
      • Django: resolve(), plus STATIC_URL and the staticfiles finders.
    • Paths are read the way the browser requests them: entities and percent escapes are decoded and ./.. resolved.
    • Notes: if no checker was registered, the check prints one note and checks no links. If a checker raises, that path is skipped with one note.
    • The editor asks the app worker, with a 3-second limit.
    • Known limits, documented:
      • An app served under a sub-path gets false warnings.
      • A FastAPI parameter typed only in the function signature isn't checked.
      • Paths under Django's MEDIA_URL always count as served.

Evidence

  • Benchmark:
    • m36, m37 and the m27 expression variant are now reported by --types.
    • m45, m48 and m61 stay silent with a "links not checked" note, because the benchmark app serves its pages from hand-written ASGI code that registers no checker. With the same routes behind contrib.fastapi.mount(), all three are reported.
  • Wheel size: 1,284,798 bytes, under the 1,351,680-byte cap.
  • Tests: citry-lsp (885) and citry pass, and ruff and mypy are clean, including mypy with --platform linux.
  • Docs build check: 0 errors.
  • New test-only dev dependency: Flask 3.1, for the Flask checker's tests.
  • Reviews: two independent code reviews and a separate prose pass.
  • Not run locally: the Rust phases of the local gate, because a git submodule isn't checked out in this worktree. No Rust changed.

Open questions

  • Starter --app commands: the starters' citry check --app commands point at a module that never mounts Citry, so each starter now prints the "links not checked" note. It doesn't fail the check. Changing those commands touches the published starter archives, so it's left for a separate decision.
  • citry-lsp release: its citry>=0.6.0 pin must rise at the next release.

🤖 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
JuroOravec added this pull request to stack #237 October 21, 2026 16:05
@JuroOravec
JuroOravec removed this pull request from stack #237 October 21, 2026 16:06
@JuroOravec
JuroOravec changed the base branch from fix/static-checks-207-events to benchmarks/errors-faster-journeys October 21, 2026 16:06
@JuroOravec
JuroOravec added this pull request to stack #219 October 21, 2026 16:07
Base automatically changed from benchmarks/errors-faster-journeys to main October 21, 2026 16:09
# 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
@JuroOravec
JuroOravec merged commit 50a763d into main Oct 21, 2026
27 checks passed
@JuroOravec
JuroOravec deleted the fix/static-checks-207-types branch October 21, 2026 16:30
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