Reclaim loader state when registries are destroyed #133
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nsaspy/prolog-rlm!133
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/67-loader-registry-cleanup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #67.
Runtime invariant
Destroying a tool registry reclaims the
rlm_tool_loaderidempotency bookkeeping owned by that registry when the loader module is present. Registry ownership remains inrlm_tool; core does not import the loader, and capability/authority/MCP semantics do not change.The invariant also holds when registry destruction races with a loader that already registered its tool but has not yet returned. A late successful loader return cannot resurrect bookkeeping for a dead registry.
Implementation
rlm_tool_loaderto SWI-Prolog's built-in predicate lifecycle events for the core registry-liveness predicate;retractalllifecycle event for the affected registry ID;registry_destroyedrather than preserving stale state;rlm_tool_loader_forget_registry/1as an explicit idempotent host operation;docs/external-tool-libraries.mdwith the automatic cleanup contract.Compatibility audit
The repository CI runtime is SWI-Prolog 9.0.4. The exact upstream V9.0.4 source was checked before retaining this design:
prolog_listen/3supports the named listener option and predicateretractalllifecycle events carry the module-qualifiedend(Head)form handled here.Non-goals
Verification
Tests for the base lifecycle invariant were added before the implementation, and the later race test was added before the race hardening. No sleeps are used for correctness synchronization.
The exact PR-head GitHub Actions gates are authoritative because local SWI-Prolog is unavailable in this environment. Merge only after deterministic and required live gates are green; do not weaken or skip provider gates to force a merge.