Skip to content

Reload only plugins whose builds changed - #251

Closed
JustKira wants to merge 8 commits into
feat/tkm-163-index-backfillfrom
feat/tkm-162-reload-per-plugin
Closed

JustKira wants to merge 8 commits into
feat/tkm-163-index-backfillfrom
feat/tkm-162-reload-per-plugin

Conversation

@JustKira

@JustKira JustKira commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #250, which is stacked on #249.

Summary

An ACP action can finish while another plugin reloads. Reload compares plugin build ids and keeps unchanged workers and asset URLs. The window remounts changed views and their actual importers.

reload
  inspect the candidate; verify each changed worker in a temporary working directory
  commit grants and schemas only after all checks pass
  cancel actions from retired builds and replace their workers
  publish current routing and re-run subscriptions on the open connection
  remount changed views and their window importers

A retired action drops its wait on an unchanged worker without stopping it. Surviving actions resolve new calls and provider lookups against the published catalog. A window load that encounters a retired asset keeps its import edges so the next catalog can remount the importer.

Linear: TKM-162

Evidence

  • Before: The two-worker and browser regressions showed that even unrelated reloads cancelled actions or cleared drafts. The follow-up probes reproduced a nested cancellation killing a second worker, stale action and provider routing, a broken worker slipping through validation, and a window importer stranded after a retired asset returned 404.
  • After: The regressions verify worker process continuity, visible cancellation, current routing, atomic rejection of an invalid worker bundle, and importer recovery. A removed subscription query reports an error and resumes on the same id when restored.
  • Updated the existing cancellation test to publish a changed build, and the worker removal test to assert the reload error while preserving the worker and child death checks. The asset test now checks that the plugin build id serves declared assets while a catalog revision and a private backend asset are both rejected.
Local command Result
cargo test -p server --no-fail-fast -- --test-threads=2 183 passed. Two real-adapter tests remain ignored because they require installed adapters and CLI login.
cargo test -p tokamak-app 5 passed.
bash .ci/check.sh rust Passed.
bash .ci/check.sh ts Passed.
bash .ci/check.sh lint Passed with TypeScript lint warnings.
proto run bun -- e2e/run.ts Passed.
proto run bun -- run e2e:browser Passed all 20 Chromium and WebKit tests.
proto run bun -- packages/build/tests/browser-assets.mjs Passed all three origin modes.

Stack interaction tests

In packages/server/tests/reload.rs:

  • a. changed_worker_swaps_while_skipped_index_is_retried — publishes the changed build, reports the new duplicate found on retry, and lets the unchanged worker finish its action.
  • b. repaired_index_restores_only_skipped_plugin_and_required_dependent — restores both builds after a row repair with no rebuild; unrelated worker PIDs stay the same.
  • c. failed_backfill_or_readiness_keeps_live_builds_and_indexes — either failure leaves the old catalog, build ids, worker PIDs and indexes in place.
  • d. index_only_build_changes_revision_and_restarts_only_its_worker — the manifest hashes the backend bundle containing the schema, so an index edit changes the build id even when the worker code and version are unchanged.
  • e. no_op_reload_preserves_running_actions_and_worker_pids — proves both actions finish on the same worker PIDs and no change event is emitted.

Reload regression tests

Each test failed before its fix and passed afterward.

  • active_dependent_keeps_old_build_when_required_plugin_is_skipped — a new required dependency cannot evict an active plugin; the error names both plugins and the running action and workers survive.
  • invalid_artifact_is_isolated_only_for_an_identified_skipped_plugin — a hash mismatch in a known skipped build is reported while another build reloads. Active corruption and invalid manifest identity still refuse the reload.
  • skipped_only_edit_preserves_active_catalog_and_provider_order — changing a skipped build leaves the active order and revision stable. An active build change publishes the new revision.

Known limits

  • The readiness check starts each changed worker in a temporary working folder
    and checks that the bundle imports and answers. It catches syntax errors,
    missing imports, and code that throws during import. A worker can still fail
    on its first real call if its import sees different files or settings in its
    real working folder.
  • The readiness check runs the plugin's top-level code. Plugins are trusted,
    so that code runs without a sandbox. Writes to files or calls to outside
    services during import can happen even if the reload is refused. Keep side
    effects out of import time.

Merge Danger

Door: Two-way. No storage migration.

Blast Radius: Reloads. Existing sessions stay connected; asset addresses from before the upgrade may need a fresh catalog.

…o t3/stack-251

# Conflicts:
#	packages/runtime/PLUGINS.md
#	packages/server/src/plugins/catalog.rs
#	packages/server/src/plugins/loading.rs
#	packages/server/src/service/plugin_control.rs
@JustKira
JustKira changed the base branch from dev to feat/tkm-163-index-backfill November 20, 2026 12:52
Protect active dependents during skip propagation, report verification errors for known skipped builds, and derive catalog order from active plugins. Notify windows when the catalog revision changes.
@JustKira
JustKira marked this pull request as draft November 20, 2026 14:08
@JustKira

Copy link
Copy Markdown
Contributor Author

Closing without merging. The plugin shape, the server engine and sign-in are being decided again (Linear TKM-194 and TKM-195), and this work sits on top of them. Nothing is lost: the head commit is a3978ea, and git fetch origin pull/251/head brings it back.

@JustKira JustKira closed this Nov 21, 2026
@JustKira
JustKira deleted the feat/tkm-162-reload-per-plugin branch November 21, 2026 18:08
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