fix(router): remove persisted route_config key on SemanticRouter.delete()#635
Open
vishal-bala wants to merge 1 commit into
Open
fix(router): remove persisted route_config key on SemanticRouter.delete()#635vishal-bala wants to merge 1 commit into
vishal-bala wants to merge 1 commit into
Conversation
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
SemanticRouter.delete() dropped the search index but left the standalone
{name}:route_config JSON key in Redis, since that key is not tracked by
the index. Delete it explicitly so deletion fully removes router state.
Closes #634
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
24b0fbb to
23805cf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
A
SemanticRouterpersists its configuration as a standalone JSON key,{name}:route_config, written when the router is constructed and rewritten on every route change.delete(), however, only drops the router's search index — it never removes that key. The index is built over hash documents, andFT.DROPINDEX ... DDdeletes only the documents the index actually tracks, so the JSON config key falls outside its reach and survives every call todelete().The immediate consequence is orphaned
:route_configkeys accumulating in Redis. The subtler one is a correctness gap:from_existing()loads a router straight from that key, so a router that was supposedly deleted can be silently resurrected from stale config. It also leaves residue behind in the test suite, where it contributed to the broader Redis-backed isolation problems tracked in #546.Fix
delete()now removes{name}:route_configexplicitly after dropping the index, so deleting a router fully clears its state. The change is confined toSemanticRouter.delete(); there is no async router variant to mirror.A regression test constructs a router, confirms the config key exists, calls
delete(), and then asserts both that the key is gone and thatfrom_existing()on the same name raises rather than reloading stale config — locking in the behaviour described above.Closes #634.
Note
Low Risk
Small lifecycle fix in router teardown with a focused regression test; no changes to routing, auth, or data semantics beyond complete cleanup on delete.
Overview
SemanticRouter.delete()now drops the search index and explicitly deletes the standalone Redis JSON key{name}:route_config, which is not removed byFT.DROPINDEXbecause it sits outside the index.This prevents orphaned config keys and stops
from_existing()from reloading a router that was supposed to be deleted.An integration test asserts the config key is gone after
delete()and thatfrom_existing()raises when no valid config remains.Reviewed by Cursor Bugbot for commit 23805cf. Bugbot is set up for automated code reviews on this repo. Configure here.