Make registry destruction explicitly reclaim loader state #157

Closed
lost-rob0t wants to merge 2 commits from fix/156-registry-destroy-hooks into fix/154-anonymous-dict-canonicalization
lost-rob0t commented 2026-08-21 22:25:19 +00:00 (Migrated from github.com)

Closes #156 after the runner/dict-normalization stack lands.

Stacked on #155 so the loader lifecycle tests run behind the restored aggregate PlUnit gate and the anonymous-dict normalization repair.

Failure

Merged #133/#67 claimed tool_registry_destroy/1 automatically reclaimed rlm_tool_loader idempotency rows by observing SWI predicate lifecycle events. The restored suite proves that claim false on the actual CI runtime: destroyed registries retain loaded_tool_pack/4 rows and repeated churn accumulates them.

Fix

  • rlm_tool now owns a generic multifile tool_registry_destroy_hook/1 lifecycle seam;
  • registry entries/liveness are removed first, then loaded trusted hooks are invoked best-effort;
  • rlm_tool_loader contributes one hook that calls its existing idempotent rlm_tool_loader_forget_registry/1 cleanup;
  • removes the fragile prolog_listen/3 inference path entirely;
  • core still does not import or depend on rlm_tool_loader.

The late-loader race remains protected by the existing post-loader liveness check: if destruction wins before the loader returns, its finalization sees the dead registry and removes any row it just published.

Existing regressions retained

The existing #67 tests remain the acceptance oracle, including automatic cleanup, cross-registry isolation, repeated churn, no-loader registries, and destroy-vs-loader-return race. No tests are weakened or removed.

Keep draft until exact-head CI proves those tests pass under the real aggregate runner.

Closes #156 after the runner/dict-normalization stack lands. Stacked on #155 so the loader lifecycle tests run behind the restored aggregate PlUnit gate and the anonymous-dict normalization repair. ## Failure Merged #133/#67 claimed `tool_registry_destroy/1` automatically reclaimed `rlm_tool_loader` idempotency rows by observing SWI predicate lifecycle events. The restored suite proves that claim false on the actual CI runtime: destroyed registries retain `loaded_tool_pack/4` rows and repeated churn accumulates them. ## Fix - `rlm_tool` now owns a generic multifile `tool_registry_destroy_hook/1` lifecycle seam; - registry entries/liveness are removed first, then loaded trusted hooks are invoked best-effort; - `rlm_tool_loader` contributes one hook that calls its existing idempotent `rlm_tool_loader_forget_registry/1` cleanup; - removes the fragile `prolog_listen/3` inference path entirely; - core still does not import or depend on `rlm_tool_loader`. The late-loader race remains protected by the existing post-loader liveness check: if destruction wins before the loader returns, its finalization sees the dead registry and removes any row it just published. ## Existing regressions retained The existing #67 tests remain the acceptance oracle, including automatic cleanup, cross-registry isolation, repeated churn, no-loader registries, and destroy-vs-loader-return race. No tests are weakened or removed. Keep draft until exact-head CI proves those tests pass under the real aggregate runner.
lost-rob0t commented 2026-08-24 08:06:40 +00:00 (Migrated from github.com)

Superseded by the explicit registry lifecycle hook now on main via #177. Verified exact current main 7c3561bcc3: rlm_tool owns the multifile destroy hook, does not import rlm_tool_loader, and the loader contributes scoped cleanup. Loader lifecycle/security tests passed 24/24, including automatic reclamation, scoped destroy, churn, unused registries, late-return non-resurrection, conflicts, and capability separation.

Superseded by the explicit registry lifecycle hook now on main via #177. Verified exact current main 7c3561bcc34de55fba875dfd18b773211a3d3420: rlm_tool owns the multifile destroy hook, does not import rlm_tool_loader, and the loader contributes scoped cleanup. Loader lifecycle/security tests passed 24/24, including automatic reclamation, scoped destroy, churn, unused registries, late-return non-resurrection, conflicts, and capability separation.
nsaspy changed title from WIP: Make registry destruction explicitly reclaim loader state to Make registry destruction explicitly reclaim loader state 2026-08-27 20:02:11 +00:00
Some checks failed
CI / Deterministic unit and load checks (push) Has been cancelled
CI / REAL OpenRouter integration (push) Has been cancelled
Nix flake / Flake package and clean runtime load (push) Has been cancelled
Clean SWI pack install / Install and load copied pack (push) Has been cancelled
Runner integrity / runner-integrity (push) Has been cancelled
Tree-sitter FFI / Direct SWI-Prolog Tree-sitter FFI (push) Has been cancelled

Pull request closed

Sign in to join this conversation.
No description provided.