Repository navigation
Conversation
Rename the 15 `elastic kb slo` commands from Kibana's legacy operationId names (`find-slos-op`, `get-slo-op`, ...) to short canonical names that follow one rule: `list*` for paginated results, `get*` for a single element (`list`, `get`, `create`, `list-definitions`, `get-snapshot`, ...). Every legacy `*-op` name stays registered as a Commander alias. - factory: `CommandConfig.aliases`, validated and registered by `defineCommand`; lazy stub leaves carry the same aliases. - policy: `isCommandAllowed` accepts a list of dot-paths; leaves match through their canonical path or any alias path, so an existing `commands.blocked` entry such as `stack.kb.slo.delete-slo-op` still blocks the renamed `stack.kb.slo.delete`. - kb: `src/kb/aliases.ts` naming table keyed by upstream `@elastic/schemas` names; registration, the namespaced argv sniff and stub leaves use it. The flat `kb <token>` sniff keeps matching upstream names only. - codegen: KB functional scripts invoke the canonical names via `cliPath`. - docs: regenerated `docs/cli/schema.json`; alias matching documented in the configuration reference.
🔍 Preview links for changed docs⏳ Building and deploying preview... View progress This comment will be updated with preview links when the build is complete. |
Elastic Docs Style Checker (Vale)Summary: 2 suggestions found 💡 Suggestions (2): Optional style improvements. Apply when helpful.
The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are blocking approval.
No open issues 🎉
What changed in this PR
Gives all 15 elastic kb slo commands shorter canonical names while retaining their legacy names as aliases. The change integrates with the CLI’s shared command factory and lazy-loading architecture.
Changes:
- Adds a Kibana naming registry used by command registration and functional-test generation.
- Supports leaf aliases in command validation, lazy loading, and policy enforcement.
- Updates the generated CLI schema, policy documentation, and tests for naming, completion, and compatibility.
| File | Description |
|---|---|
test/lib/lazy-leaf.test.ts |
Tests stub aliases and alias-triggered loading. |
test/kb/register.test.ts |
Tests canonical registration and lazy invocation through either name. |
test/kb/aliases.test.ts |
Checks mappings, legacy compatibility, uniqueness, and prototype-key safety. |
test/factory.test.ts |
Tests alias validation, invocation, help output, and policies. |
test/completion-cli.test.ts |
Checks completion for canonical names and legacy aliases. |
test/cli-schema.test.ts |
Verifies canonical names and aliases in schema output. |
src/lib/lazy-leaf.ts |
Registers aliases on lightweight command stubs. |
src/kb/register.ts |
Applies resolved names and recognizes aliases during lazy loading. |
src/kb/aliases.ts |
Defines the SLO naming registry and lookup helpers. |
src/factory.ts |
Validates and registers aliases; enforces alias-aware policies. |
src/factory-core.ts |
Adds alias configuration and alias-aware policy matching and visibility. |
docs/cli/schema.json |
Records canonical names and legacy aliases for all 15 SLO commands. |
docs/cli/configuration_reference.md |
Documents policy matching through leaf aliases. |
codegen/functional/test/mapper.test.ts |
Tests mapping upstream actions to canonical CLI paths. |
codegen/functional/kb.ts |
Generates functional-test commands using canonical names. |
Review effort: Balanced
Group aliases (e.g. stack.kibana) are not matched by commands.allowed or commands.blocked; entries must use canonical group names.
The 15 `elastic kb slo` commands are registered under their short names only. Kibana operationId names such as `find-slos-op` are no longer aliases: the CLI is in technical preview, so renames are clean breaks (as in elastic#199 and elastic#201). Generic command alias support and alias-aware policy matching are removed with them. BREAKING CHANGE: `elastic kb slo` commands answer to their short names only (`find-slos-op` → `list`, `get-definitions-op` → `list-definitions`, ...). Update `commands.allowed`/`commands.blocked` entries that name the old paths.
|
PRs that correct or clean up the names of APIs, due to unwanted naming artifacts in the Kibana OAS files or similar such issues, should be handled upstream in The generator is likely the best place for this change. A fix there should be done in such a way that, if/when the OAS definition is cleaned up, the generator continues to work and just skips any cleanup steps that are no longer needed. Closing this so you can contribute there first, then open a new PR here for any follow-up bits that can't be handled by fixing schema definitions. |
Summary
All 15 commands under
elastic kb sloused Kibana's legacy OpenAPIoperationIdnames as-is (find-slos-op,get-slo-op,get-definitions-op, …).slois the only Kibana namespace where every command has an-opsuffix, and most names repeatsloinside theslonamespace.This PR gives them short CLI names that follow one rule:
list*for paginated results,get*for a single element.@elastic/schemasnamefind-slos-oplistcreate-slo-opcreateget-slo-opgetupdate-slo-opupdatedelete-slo-opdeleteenable-slo-openabledisable-slo-opdisablereset-slo-opresetget-definitions-oplist-definitionsget-snapshot-opget-snapshotbulk-snapshot-opbulk-snapshotbulk-delete-opbulk-deletebulk-delete-status-opbulk-delete-statusdelete-rollup-data-opdelete-rollup-datadelete-slo-instances-opdelete-instancesBreaking change
The old
*-opnames are not kept as aliases. The CLI is in technical preview, so this is a clean break, as in #199 and #201. Invoking an old name exits 1 withunknown command.commands.allowed/commands.blockedentries that name an old path (e.g.stack.kb.slo.delete-slo-op) no longer match anything. Ablockedentry like that stops blocking the renamed command, so it needs to be updated to the new path (stack.kb.slo.delete).An earlier revision of this PR kept every old name as a Commander alias, with alias-aware policy matching. That support was removed in 0ddf5b5; nothing in the factory, policy, or lazy-leaf code changes in the final diff.
Changes
src/kb/command-names.ts, new, no imports): a static map keyed bynamespace → upstream name → CLI name, plusresolveKbCommandName(). Onlyslois populated; unmapped commands keep their upstream name.def.namestays the upstream identifier forloadKbApiand request building.src/kb/register.ts): real and stub leaves are registered under the resolved name. The namespaced argv sniff (kb <namespace> <token>) matches CLI names; the flat sniff (kb <token>) keeps matching upstream names only, so short names likelistorgetcannot match across namespaces. Name collisions inside a namespace are rejected by Commander'saddCommand(covered by a test).codegen/functional/kb.ts): each definition getscliPath = [namespace, cliName], so generated scripts callstack kb slo listetc., whiletest/functional/kb/definitions/slo_*.ymlstays client-agnostic.docs/cli/schema.jsonregenerated; the diff is limited to the 15stack kb slocommand names.Testing
npm teston Node 24.22.3 (tsc -bbuild + unit suite + license check): 2464 pass / 0 fail / 2 skipped.eslinton the changed files andscripts/check-spdx.mjs: clean.__completeandcli-schemachecks, an end-to-endstack kb slo find-slos-op→unknown commandcheck, and the codegencliPathmapping.ELASTIC_ENVIRONMENT=stack npm run codegen:functional:kb: generatedslo_*.shcall only CLI names; no-opname in a command position.kb slo --helplists only the CLI names;kb slo find-slos-opandkb slo get-slo-opexit 1 withunknown command;kb slo get --id x --dry-runexits 0.scripts/heap-check, and the startup-time A/B. The final change removes code from the startup path.hyperfineis not available locally, soscripts/perf-checkwas not run; the perf CI job is the authoritative gate.Notes for reviewers
--json, an unknown command (old name or otherwise, e.g.kb spaces not-a-command) prints Commander's plain-text error rather than the{"error": …}shape. This is existing behaviour and is not changed here.🤖 Generated with Claude Code