Skip to content

Keeps the upgrade host's step handler map - #229

Merged
johnnyt merged 1 commit into
mainfrom
se-1px6-upgrade-host-handler-lookup-cache
Oct 11, 2026
Merged

johnnyt merged 1 commit into
mainfrom
se-1px6-upgrade-host-handler-lookup-cache

Conversation

@johnnyt

@johnnyt johnnyt commented Oct 11, 2026

Copy link
Copy Markdown
Member

Summary

On every cancel, the upgrade host's UpgradeHost.Loans.handler_for_invocation/1 found an invocation's handler by authoring the loan document again (the palette and every gated edit, through LoanDocument.document/0) and reading the palette, although the compile it maps the invocation's state through was already kept per node.

The block-to-handler map (a step block's id to the handler serving its invoke type) is now built once per node from the document and the palette, kept under :persistent_term beside the compile through the module's existing cached/2, and the lookup maps the provenance's block id through it. The build loads each palette module before asking it for invoke_type/0, because the map is kept and a miss would be kept with it.

Every answer is unchanged: a state with no owner in the provenance, a block that is not an invoke step, and an invoke type no handler serves each still answer :error.

Tests

A new loan test, "the handler lookup reads each step's handler from a map kept once per node, not from the document", pins that the map is kept after a lookup and that the lookup answers from the kept map (a swapped map changes its answer; the test restores the kept map on exit). The existing loan test's two lookups and its unknown-state :error stay as they were.

Sabotage, both red on an assertion and restored byte-equal: the map built on every call with nothing kept (the kept-map assertion read nothing); the lookup dropping and rebuilding the map on every call (the swapped-map assertion answered the fine's real handler).

Gate

The root mix quality and, from upgrade_host/, the CI job's mix deps.get --check-locked, mix compile --warnings-as-errors (test env) and mix test all green on the rebased head. The upgrade host's exact pins in upgrade_host/mix.exs and its mix.lock do not move.

Review

The pre-request review round (a diff critic and a test critic) found nothing blocking. No record text in this change.

On every cancel, the upgrade host looked up an invocation's handler by
authoring the loan document again and reading the palette, though the
compile was already kept. The block-to-handler map is now built once
per node from the document and the palette and kept beside the compile,
and the lookup maps the provenance's block id through it. Every answer
is the same as before.

A new loan test pins that the lookup reads the kept map. No pin moves.
@johnnyt
johnnyt merged commit 81c9e0a into main Oct 11, 2026
4 checks passed
@johnnyt
johnnyt deleted the se-1px6-upgrade-host-handler-lookup-cache branch October 11, 2026 09:45
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