Skip to content

Request response policies#2996

Draft
nkaradzhov wants to merge 15 commits into
redis:masterfrom
nkaradzhov:request-response-policies
Draft

Request response policies#2996
nkaradzhov wants to merge 15 commits into
redis:masterfrom
nkaradzhov:request-response-policies

Conversation

@nkaradzhov

Copy link
Copy Markdown
Collaborator

Description

Describe your pull request here


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

nkaradzhov and others added 15 commits June 8, 2026 10:54
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>
@nkaradzhov nkaradzhov force-pushed the request-response-policies branch from fd526fa to e857c1b Compare June 9, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant