Skip to content

test: lock today's render callback and hook order - #263

Merged
JuroOravec merged 1 commit into
mainfrom
test/render-order-logs
Oct 23, 2026
Merged

JuroOravec merged 1 commit into
mainfrom
test/render-order-logs

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Adds the callback-order tests the native render plan puts first (PR 0),
so each later Rust render level is checked against today's behavior
before it changes any code.

Each case builds a small page with a c-for loop of simple="vue" rows,
renders and serializes it, and records every call into user code and
every extension hook, in order: the id generator, Kwargs and data
schema construction, template_data, js_data, css_data, the parent's
on_render, on_dependencies, the serialize hooks, the execution frame
each data method saw, TRACE lines, the error with its component path and
chain, and any context variable left set. The records observed on main
live in tests/fixtures/call_run_order.json. CASES in the test file
says what each case changes and summarizes its record in one line.

  • 44 cases: the loop edge cases from the plan (row errors, the depth
    limit, on_render boundaries, a row changing state for later rows,
    child calls, slot fills, tracing) and pages serialized as every output
    kind.
  • A thread case checks that two overlapping renders write the same HTML.
  • The ComponentLike.register(dict) case runs in its own process,
    because the registration lasts for the whole process.
  • Hooks are recorded with sys.setprofile instead of by replacing hook
    methods: serialization checks the built-in hooks' identity and stops
    hydrating a page when one is replaced.
  • To regenerate after a deliberate change, run from packages/py/citry:
    uv run --no-sync python -m tests.test_call_run_order --write.
    A changed record is a changed contract, so explain why in the PR.

One case, nested_template_printed_twice, locks today's internal
RuntimeError ("deferred part vanished from its .parts list before
resolution"). If that bug is fixed later, update this case's record
with the fix.

Test-only: no runtime code and no changelog entry. The file runs in about
1 second. Checked locally with the fast profile of scripts/check.py
(passed) and mypy with --platform linux.

🤖 Generated with Claude Code

Add tests/test_call_run_order.py. Each case builds a small page whose
simple="vue" rows come from a c-for loop, renders and serializes it, and
records every call into user code (the id generator, Kwargs and data
schema construction, template_data, js_data, css_data, on_render,
on_dependencies) and every extension hook, with the execution frame each
data method saw, the TRACE lines, the error with its component path and
chain, and any context variable left set. The records observed on main
are stored in tests/fixtures/call_run_order.json, so a later render path
must keep the same calls, counts and order.

Hooks are recorded with sys.setprofile on their code objects instead of
by replacing hook methods, because serialization checks the built-in
hooks' identity and stops hydrating a page when one is replaced.

The 44 cases cover the plan's loop edge cases (row errors, depth limits,
on_render boundaries, state changed by a row, child calls, slot fills,
tracing) and pages serialized as every output kind. A thread case checks
two overlapping renders write the same HTML. The ComponentLike.register
case runs in its own process. The file runs in about 1 second.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec added this pull request to stack #270 October 23, 2026 09:43
@JuroOravec
JuroOravec merged commit 9277d72 into main Oct 23, 2026
27 checks passed
@JuroOravec
JuroOravec deleted the test/render-order-logs branch October 23, 2026 09:47
JuroOravec added a commit that referenced this pull request Oct 23, 2026
…ive render level C1)

A c-for loop over a simple='vue' component now records its rows in one
_DeferredRun, with one _DeferredRunRow at each row's position in the
parts list, instead of building a CitryElement and a DeferredComponent
per row. The render queue gives rows of one run that sit next to each
other one task (_RunTask), which renders them in the order their own
tasks would. A row that calls child components or takes the ordinary
component path stops the task, and the queue renders that row's work
with a task for the remaining rows under it; a row that is too deep or
whose position is gone raises the error its own task raises. Output
bytes and the order of every callback and hook are unchanged; the order
records from #263 pass unchanged on both render paths.

This level is Python only and runs on every interpreter, on both the
Rust and the Python path.

- citry_render.py: _DeferredRun and _DeferredRunRow (one object per row
  position, so the queue finds rows by identity when a hook reorders,
  drops or repeats them; the row's DeferredComponent is built once).
- nodes/__init__.py: ComponentNode.render ends in _finish_render;
  _render_run_row; ForNode._call_run_class and _render_call_run.
- component_render.py: _simple_vue_record, shared by
  _render_simple_vue_leaf and the run task's _run_row; _run_rows,
  _place_run_part, _RunTask and the settle loop's run branch with its
  four exits; place_child shared with the per-row task; the scan groups
  adjacent rows; _contains_deferred and _nesting_depth_error_for.
- _vue/capture.py: a leftover row is an unresolved part.
- Tests: test_call_run_tasks.py (the board spy on both paths, both
  position-gone exits, hook edits and a re-printed list compared with one
  task per row in the same process, rows that change later rows, the
  three public routes that see unplaced rows).
- Docs: native_render.md section 3 and C1's error modes;
  component_rendering.md, component_rendering_defer.md,
  component_on_render.md, vue_optimization_rollout.md, agent INDEX, and a
  ledger row with the timing pending.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 23, 2026
…ive render level C1)

A c-for loop over a simple='vue' component now records its rows in one
_DeferredRun, with one _DeferredRunRow at each row's position in the
parts list, instead of building a CitryElement and a DeferredComponent
per row. The render queue gives rows of one run that sit next to each
other one task (_RunTask), which renders them in the order their own
tasks would. A row that calls child components or takes the ordinary
component path stops the task, and the queue renders that row's work
with a task for the remaining rows under it; a row that is too deep or
whose position is gone raises the error its own task raises. Output
bytes and the order of every callback and hook are unchanged; the order
records from #263 pass unchanged on both render paths.

This level is Python only and runs on every interpreter, on both the
Rust and the Python path.

- citry_render.py: _DeferredRun and _DeferredRunRow (one object per row
  position, so the queue finds rows by identity when a hook reorders,
  drops or repeats them; the row's DeferredComponent is built once).
- nodes/__init__.py: ComponentNode.render ends in _finish_render;
  _render_run_row; ForNode._call_run_class and _render_call_run.
- component_render.py: _simple_vue_record, shared by
  _render_simple_vue_leaf and the run task's _run_row; _run_rows,
  _place_run_part, _RunTask and the settle loop's run branch with its
  four exits; place_child shared with the per-row task; the scan groups
  adjacent rows; _contains_deferred and _nesting_depth_error_for.
- _vue/capture.py: a leftover row is an unresolved part.
- Tests: test_call_run_tasks.py (the board spy on both paths, both
  position-gone exits, hook edits and a re-printed list compared with one
  task per row in the same process, rows that change later rows, the
  three public routes that see unplaced rows).
- Docs: native_render.md section 3 and C1's error modes;
  component_rendering.md, component_rendering_defer.md,
  component_on_render.md, vue_optimization_rollout.md, agent INDEX, and a
  ledger row with the timing pending.

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