Request response policies#2996
Draft
nkaradzhov wants to merge 15 commits into
Draft
Conversation
e74bb9a to
2ea355f
Compare
for now we only extract: - request and response policy -> from tips - is the command keyless -> from key specs
actually fetched from server using the dynamic resolver
Move each switch case body in `_execute` into a typed router/reducer function in `request-response-policies/dispatch.ts`. Switches still dispatch by policy enum; behavior unchanged. Prepares for replacing the switches with a strategy registry in the next commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Define `REQUEST_ROUTERS` and `RESPONSE_REDUCERS` as policy-keyed records of the dispatch helpers introduced in the previous commit. The two switches in `_execute` collapse to a single registry lookup each, with `Unknown policy` errors preserved. `satisfies Record<PolicyName, ...>` keeps the lookup exhaustive at the type level. Adding a new policy now requires only a new entry in the registry — no `_execute` changes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- `CommandIdentifier.subcommand` is now `string | undefined`, mirroring the fact that single-word commands have no second arg. The parser emits `undefined` instead of an implicit empty value. - `StaticPolicyResolver` lowercases the entire policy table at construction time, so lookups are case-insensitive regardless of the casing used in the static data file (which today mixes upper- and lowercase module/command keys). - Subcommand lookups also lowercase the incoming identifier and guard against `undefined`, so `MEMORY USAGE` resolves to the `usage` subcommand policy regardless of caller casing. - Drop the stray `console.log` left in the resolver. - Error messages that referenced `parser.commandIdentifier` now print a `command [subcommand]` label instead of `[object Object]`. - Update `dynamic-policy-resolver.spec.ts` to pass `CommandIdentifier` objects to `resolvePolicy` (previously was passing raw strings). - Add `static-policy-resolver.spec.ts` covering FT.SEARCH, MEMORY USAGE, GET, COMMAND INFO, FT.SUGADD, casing, errors and fallback. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The static policy table had three problems for the Search module: - The `FT` module entries were upper-cased while every other module uses lower-case keys. - A second `search` module held three RediSearch cluster-admin commands (`CLUSTERSET`, `CLUSTERINFO`, `CLUSTERREFRESH`) that are not part of the public FT.* surface. - A `_FT` module held private debug subcommands (`_FT.CONFIG`, `_FT.DEBUG`, etc.) and a long list of deprecated / private FT.* entries (`_LIST`, `_CREATEIFNX`, `_DROPIFX`, `_DROPINDEXIFX`, `_ALIASADDIFNX`, `_ALIASDELIFX`, `_ALTERIFNX`, `ADD`, `DEL`, `GET`, `MGET`, `SYNADD`) which are not user-facing and shouldn't participate in policy resolution. Replace those three modules with a single lower-case `ft` module containing exactly the 25 commands listed in the HLD Command Routing Policy Table, each with the policy the client should apply per the HLD client-interpretation column. `ft.cursor` is left at `default-keyless`/`default-keyless` for now; the HLD specifies `special` (sticky cursor) but that depends on the not-yet-built special-handler registry and cursor binding map. Add `ft-policies.spec.ts`, a parameterised test that asserts every HLD command resolves to the prescribed `request`/`response` pair and that the dropped debug / admin commands no longer resolve. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fd526fa to
e857c1b
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.
Description
Checklist
npm testpass with this change (including linting)?