Skip to content

feat(core): exact Vue syntax errors, parser-marked prop writes, declared directives and inheritAttrs; citry-core 1.9.0 (#207) - #244

Merged
JuroOravec merged 9 commits into
mainfrom
feat/core-analysis-records
Oct 22, 2026
Merged

JuroOravec merged 9 commits into
mainfrom
feat/core-analysis-records

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Exact Vue syntax errors, parser-marked prop writes, declared directives, and inheritAttrs (#207 items 9 and 10)

This implements items 9 and 10 of docs/design/issue_207_proposals.md (Option 1 for both) and the inheritAttrs extension for benchmark case m53 (an <img> without alt). It changes citry-core's Python surface, so it releases citry-core 1.9.0 together with the citry that pins it.

What a developer sees

  • A broken Vue expression shows the parser's message where it stops. v-if="open &&" now reads "The Vue expression in 'v-if' is not valid JavaScript (Unexpected token), so Vue cannot compile this template." The editor underlines the last & instead of the whole value. A broken function () {...} listener is blamed for its own mistake, not for a missing function name. An expression that contains a character reference such as &amp; keeps the whole range and the message without a parser error, because positions in the decoded text do not match the template.
  • Prop writes come from the parser, not from the text after a name. open /* note */ = false and [open] = pair are now reported; open followed by --count on the next line is not. A write in component JavaScript, such as this.open = false, now follows rule_prop_assignment like a template write. Before, it was capped at a warning; the tests that encoded that cap are updated on purpose.
  • A custom directive the component registers is not a misspelling. With the application loaded, v-iff passes when every component that renders the template registers iff in $component({ directives }), under Vue's lookup (my-dir, myDir, MyDir). A shared template is still reported for each component that does not register the name, with that component's severity, and so is an option Citry cannot read. citry check --static and an editor without the application still report it.
  • inheritAttrs: false makes a root <img> without alt reportable (with the application loaded). Vue then never passes a parent's alt to it. An inheritAttrs value Citry cannot read counts as passing alt on, so the rule stays quiet.

How it works

  • analyze_browser_source parses the authored text inside a generated async function to find free names, as before. When that fails, or when the text closes the generated function (a); (b, now invalid), the error comes from a second parse of the authored text alone. Each free name carries the write flag of OXC, the Rust JavaScript parser the analysis uses. An error the top-level parse raises only because it runs outside a function, such as new.target, gives way to the wrapped parse's error, unless it sits on a stray ), ] or } that closes the generated function.
  • analyze_component_source marks member writes, reads directives the same way it reads emits, and reports each call's inheritAttrs.
  • Both functions return the Rust structs as frozen Python records (BrowserAnalysis, BrowserComponentAnalysis, and nine more) that compare and hash by value. The tuple shapes are gone, so a later field will not break callers again. A test keeps the hand-written _rust.pyi stub equal to the fields Python reads.
  • The editor reads each owner's JavaScript for the directive and inheritAttrs facts, cached by the JavaScript text. A narrowed syntax diagnostic carries the whole expression in Diagnostic.data (expressionRange), and the TypeScript duplicate filter uses it. That is needed: for @click="startDrag('a');;let x = 1; let x = 2", TypeScript reports the type error at 'a', away from Citry's finding on the second x; an integration test shows TypeScript reporting it alone and nothing once Citry's diagnostic is passed.

Checks run before merging

  1. Standalone parse versus wrapped parse: 0 disagreements over 1,740 expressions from the repository's templates and docs examples.
  2. Messages for the common mistakes: observed and locked in Rust and Python tests; none names the generated function.
  3. Parser write flag versus the old text guess: 1 difference in 3,694 references (return ++this.value), where the old guess was wrong.
  4. Duplicates: one finding with Vue's compiler rule on, and in the editor one Citry diagnostic and no TypeScript error, on an expression where TypeScript alone does report.
  5. Browser: a component that registers iff and myDir renders v-iff and v-my-dir without the unregistered-directive error.
  6. Browser: with inheritAttrs: false, a parent's bound alt reaches the root <img> neither in the server HTML nor after Vue mounts or hydrates; a control component does receive it.
  7. Cost of the records (debug builds, same corpus, best of five): calling costs the same; reading the fields the wrappers read is about 6 to 8% slower per analyze_browser_source call (about one microsecond) and 2% per analyze_component_source call. That is under the 10% slowdown the design allowed, so the records stay.
  8. The editor caches the component JavaScript analysis per JavaScript text.

Release

  • citry-core moves to 1.9.0 and citry pins citry-core==1.9.0, in this change. This is a breaking change in a minor release, following the 1.8.0 precedent.
  • citry-lsp's code now uses fields only citry 0.6.1 has (declared_directives, context_start_index), so citry-lsp must require citry>=0.6.1 before it is released. Its floor stays citry>=0.6.0 here, because the editor refuses a Citry older than MINIMUM_CITRY_VERSION, and this workspace's citry is still 0.6.0. The release pull request must set citry's version to 0.6.1 and, in the same change, raise citry-lsp's citry>= requirement, MINIMUM_CITRY_VERSION in citry_lsp/protocol.py, and the expected entry in scripts/verify_citry_lsp_distribution.py (see the new note in packages/py/citry_lsp/AGENTS.md). The raised floor also makes the release plan publish citry before citry-lsp.
  • Release order: citry-core 1.9.0, then citry 0.6.1, then citry-lsp. Run Prepare release candidate with the selection citry-core,citry,citry-lsp; qualification uses the citry-core wheel built from the same commit. Then run gh workflow run repo--release.yml -f candidate_run_id=<run-id>.
  • After citry-core 1.9.0 is on PyPI, refresh benchmarks/errors/frameworks/citry/baseline/uv.lock. Its override already says 1.9.0, as its test requires, and the benchmark runner refuses the stale lock until then.

Rebuild after pulling

The extension's Python interface changed. After pulling, rebuild it before running anything:

uv sync --all-packages
# or, for a faster debug build
cd packages/py/citry_core && uv run maturin develop

Running .venv/bin/pytest or uv run --no-sync against an extension built before this change fails with AttributeError on a tuple, at app startup when vue_variables or component_js_globals is set, and in renders and lint.

🤖 Generated with Claude Code

JuroOravec and others added 9 commits October 22, 2026 09:36
The OXC browser analysis now reports what the Vue rules guessed before:

- `analyze_browser_source` returns the parser's first syntax error
  (message and UTF-8 byte range in the authored text), taken from a
  second parse of the authored text alone, and marks each free name as
  written or read using OXC's own reference flags.
- Text that closes the generated wrapper function, such as `a); (b`,
  is now invalid in both modes.
- `analyze_component_source` marks member writes (`this.open = false`),
  reads the `directives` option like `emits`, and reports each call's
  `inheritAttrs` when the source proves it.

The result structs become `#[pyclass(frozen, eq)]` records with a
Python-style `__repr__`, so the PyO3 glue can return them directly.
`oxc_diagnostics` (already in the lock graph at 0.143.0) is now a
pinned workspace dependency so the error mapping can name its type.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`template_parser.analyze_browser_source()` and
`analyze_component_source()` now return `BrowserAnalysis` and
`BrowserComponentAnalysis` records instead of tuples. The eleven record
classes are registered in the `template_parser` submodule, re-exported
from `citry_core.template_parser`, and stubbed in `_rust.pyi` from the
Rust structs; a test keeps the stub's fields equal to what Python reads.

citry's wrappers, the render-time instance check, and the
`vue_variables` validation read the records. The wrappers gain the
syntax error, write flags, declared directives, and `inheritAttrs`,
with defaults, so their callers keep working.

citry-core moves to 1.9.0 and citry pins `citry-core==1.9.0` in the
same change, as docs/codebase.md requires. The distribution test reads
the version from the manifest instead of a copied literal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ared directives, inheritAttrs (#207)

- `citry.vue.invalid-expression` names the JavaScript parser's message
  (new catalog variant `parser`, parameter `detail`) and spans the token
  it points to. An error at the end moves back to the last character
  written; an expression with a character reference keeps the whole
  range and the generic message. Findings carry the whole expression as
  `context_start_index`/`context_end_index`, which the Vue compiler
  rule's duplicate filter compares against.
- `citry.browser.prop-assignment` uses the parser's write flags instead
  of reading the text after a name, so a write in component JavaScript
  now follows the rule's severity. This changes the earlier
  "at most a warning" contract on purpose; the tests are updated.
- `citry.template.misspelled-directive` skips a `v-*` name that every
  rendering component registers in `directives`, under Vue's lookup.
- `citry.template.missing-image-alt` reports a component's single root
  `<img>` when its JavaScript proves `inheritAttrs: false`.

Catalog, generated bindings, docs, and changelogs move with the rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t quiet on narrowed expression errors

- The engine fills `declared_directives` and the image rule's
  `root_may_receive_attributes` from each owner's current JavaScript once
  the application is loaded. The analysis is cached by JavaScript text,
  so a lint pass over unchanged text reuses it.
- A narrowed `citry.vue.invalid-expression` diagnostic carries the whole
  expression in `Diagnostic.data` (`expressionRange`), and
  `map_type_check_findings` uses it to drop a TypeScript error elsewhere
  in the same expression. Malformed data falls back to the range.
- citry-lsp now requires citry>=0.6.1, the release that carries these
  fields, so the release plan publishes citry first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Folds #239's unreleased citry-core fix (NUL escaping) into the 1.9.0
release notes, and moves the error benchmark's citry-core override to
1.9.0 with citry's pin, as its test requires. That baseline's uv.lock
can only be refreshed once citry-core 1.9.0 is on PyPI.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…se keeps a parent's alt off the root image

Browser evidence for the two skips the checks now make: a component that
registers `iff` and `myDir` renders `v-iff` and `v-my-dir` without the
unregistered-directive error, and a root `<img>` in a component with
`inheritAttrs: false` never receives a parent's bound `alt`, server-side
or after Vue mounts or hydrates, while a control component does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The directive skip is decided per component: a `v-*` name is reported
  for the components that do not register it and do not ignore the rule,
  with their severity, so an ignoring component no longer blocks the skip.
- A broken listener reports the error from whichever parse got further,
  so `function () { a +* b }` is not blamed for a missing name. A parser
  error at the end of the text moves back over spaces and comments to the
  last token.
- An error the standalone parse raises only because it runs at the top
  level, such as `new.target`, no longer hides the author's mistake.
- The records hash by value, and `__repr__` quotes strings as Python does.
- `BrowserSyntaxError` and `BrowserDirectiveName` are exported from
  `citry.analysis`.
- The editor test now uses an expression TypeScript reports on its own,
  so it proves the `Diagnostic.data` filter is needed.
- citry-lsp's `citry>=` floor stays 0.6.0 until the release pull request
  sets citry to 0.6.1: the editor refuses a Citry below
  `MINIMUM_CITRY_VERSION`, including this workspace's. citry-lsp's
  AGENTS.md now says what moves together.
- Prose: app-only skips stated, the catalog lists all three directive
  lookups, design doc and docstrings updated, wording fixes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pes the wrapper

The rule that prefers the wrapped parse's error over an earlier
standalone one made `a))`, `a) b` and `a } b c` report a statement
message from the generated code. The standalone error now stays when it
sits on a closing `)`, `]` or `}`, the only way the wrapped parse gets
past it; otherwise an earlier standalone error, such as `new.target`
(now also at the end of the text), gives way to the wrapped one. These
inputs are locked in the tests.

Also: an end-of-text range falls back to the last character when a
quote inside a regular expression looks like an unterminated string, and
the record `__repr__` comment states where it differs from Python.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec changed the base branch from main to fix/static-checks-207-inject October 22, 2026 10:20
@JuroOravec
JuroOravec added this pull request to stack #219 October 22, 2026 10:20
Base automatically changed from fix/static-checks-207-inject to main October 22, 2026 10:25
@JuroOravec
JuroOravec merged commit d305c36 into main Oct 22, 2026
34 checks passed
@JuroOravec
JuroOravec deleted the feat/core-analysis-records branch October 22, 2026 10:31
JuroOravec added a commit that referenced this pull request Oct 22, 2026
#244 raised citry's pin to citry-core==1.9.0 but left the distribution
verifier expecting 1.8.0, so every citry wheel check failed with
"unexpected runtime dependencies". The verifier now reads citry-core's
own [project] version, and a test checks that citry pins that release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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