fix(db,clients): declare the undeclared indexes, type the untyped kwargs (CHOO-1436) - #367
Draft
amaudruz wants to merge 3 commits into
Draft
fix(db,clients): declare the undeclared indexes, type the untyped kwargs (CHOO-1436)#367amaudruz wants to merge 3 commits into
amaudruz wants to merge 3 commits into
Conversation
…O-1436) `ix_agent_sessions_agent_room`, `ix_agent_sessions_transport_session_id`, `ix_agents_parent_agent_id` and `ix_external_user_claims_user_id` were created by migrations and never declared on the models. Autogenerate would have emitted `DROP INDEX` for all four, so the next person to add a column had a one-keystroke path to quietly dropping four indexes off live tables. The parity test listed them by name rather than filtering by kind, precisely so this stayed visible. The list goes with them, and the test is back to allowing no drift at all. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…CHOO-1436) Four `ClientBase` subclasses took their own arguments and forwarded the rest as `**kwargs: Any` (`**kwargs: object` with a `type: ignore` on `AgentClient`). That makes the pass-through invisible to the type checker on both sides: the subclass cannot be told it is missing something, and a caller cannot be told it is passing something that no longer exists. Which is how a stale `device_id=` type-checked clean and took all four collaboration bridges down at startup. The credential had moved into `session_state`, and nothing said so until the process refused to start. `ClientBaseKwargs` declares the shape once and the subclasses unpack it, so both checks come back without eleven parameters restated four times. Verified by putting the original mistake back: mypy now reports "Unexpected keyword argument "device_id" for "ClientBase"" at the call site. `matrix_transport_for` widens to `ClientBase[Any]`, which is what it always was in fact — it reads five base attributes and never the config. `ClientBase` is invariant in its config type, so the previous annotation only type-checked while nobody was checking. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`list_after_seq` was added for the delivery cursor without noticing that `list_for_room` already was that query, character for character. Two names for one behaviour is how they drift. `list_for_room` keeps the name and gains the paragraph that justified the second one, including the part worth writing down: a cursor starting at 0 also skips reconstructed history, which is numbered below zero, because a backfill is not something to deliver. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Two outstanding items from the Tuwunel-replacement work, neither of them part of a plan step. Stacked on #366.
The four undeclared indexes —
afa45e2dix_agent_sessions_agent_room,ix_agent_sessions_transport_session_id,ix_agents_parent_agent_idandix_external_user_claims_user_idwere created by migrations and never declared on the models. Autogenerate would have emittedDROP INDEXfor all four — so the next person to add a column had a one-keystroke path to quietly dropping four indexes off live tables.The parity test listed them by name rather than filtering by kind, precisely so this stayed visible rather than becoming permanent. The list goes with them, and the test is back to allowing no drift at all.
The constructor pass-through —
443cfb97Four
ClientBasesubclasses forwarded their remaining arguments as**kwargs: Any(**kwargs: objectplus atype: ignoreonAgentClient). That makes the pass-through invisible to the type checker in both directions: the subclass cannot be told it is missing something, and a caller cannot be told it is passing something that no longer exists.Which is how a stale
device_id=type-checked clean and took all four collaboration bridges down at startup. The credential had moved intosession_state, and nothing said so until the process refused to start.ClientBaseKwargsdeclares the shape once and the subclassesUnpackit, so both checks come back without eleven parameters restated four times.Verified by putting the original mistake back. With
device_id=record.device_idre-added at the factory call site, mypy reports:matrix_transport_forwidens toClientBase[Any], which is what it always was in fact — it reads five base attributes and never the config.ClientBaseis invariant in its config type, so the previous annotation only type-checked while nobody was checking.Testing
2355 pass, ruff and mypy clean.
🤖 Generated with Claude Code