From 39f6a49939156f2ca56327773f4e830a69797cd0 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Mon, 30 Nov 2026 14:37:59 -0500 Subject: [PATCH 1/9] docs(agents): add fix-at-the-source gate for upstream schema defects Agents patched bad upstream data (e.g. Kibana operationId names) inside this repo instead of fixing it where it originates. Assisted-by: Pi Coding Agent (claude-sonnet-5.5) --- AGENTS.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index c2aa311b..489238fa 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -50,6 +50,14 @@ Commands are defined via shared config structures (see `factory.ts`). Custom log **Read [`ARCHITECTURE.md`](./ARCHITECTURE.md) before proposing structural changes.** It documents performance-critical design decisions (factory core split, per-endpoint API files, lazy loading, manifest format) that must not be refactored unless benchmarks prove the change is neutral. +## Fix at the source + +Before changing command names, flags, descriptions, or input/response shapes that come from `@elastic/schemas`, decide where the defect you're fixing lives. The chain is API spec -> code generator (private `elastic/elastic-client-generator-js` repo) -> `@elastic/schemas` package -> this CLI. + +- Wrong, ugly, or inconsistent data in a schema or spec (names, `operationId`s, descriptions, types, missing `x-` annotations): **stop. Do not patch it here.** Tell the human which upstream repo owns it and draft an issue there. +- CLI-only UX policy (output format, aliases, grouping, safety prompts) is in scope here. +- Never add a per-endpoint or per-namespace override table to work around upstream data. Exception: a maintainer explicitly approves it as a stopgap and a tracking issue is linked in the code comment. + ## Command Authoring Requirements All requirements below are non-negotiable and enforced at review time. From 95bdd25984415c044784e0429bb109e024632a82 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Mon, 30 Nov 2026 14:38:00 -0500 Subject: [PATCH 2/9] docs(agents): add decision test and worked example for upstream fixes Assisted-by: Pi Coding Agent (claude-sonnet-5.5) --- AGENTS.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 489238fa..db8a1d98 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -52,10 +52,12 @@ Commands are defined via shared config structures (see `factory.ts`). Custom log ## Fix at the source -Before changing command names, flags, descriptions, or input/response shapes that come from `@elastic/schemas`, decide where the defect you're fixing lives. The chain is API spec -> code generator (private `elastic/elastic-client-generator-js` repo) -> `@elastic/schemas` package -> this CLI. +Before changing command names, flags, descriptions, or input/response shapes that come from `@elastic/schemas` (`elastic/schemas-js` repo), decide where the defect you're fixing lives. The chain is API spec -> code generator (private `elastic/elastic-client-generator-js` repo) -> `@elastic/schemas` package -> this CLI. - Wrong, ugly, or inconsistent data in a schema or spec (names, `operationId`s, descriptions, types, missing `x-` annotations): **stop. Do not patch it here.** Tell the human which upstream repo owns it and draft an issue there. - CLI-only UX policy (output format, aliases, grouping, safety prompts) is in scope here. +- Decision test. Answer both before writing code: (1) Would other consumers of the schemas, such as Elastic's universal MCP server or Agent Builder tool definitions, benefit from the same fix? (2) Does the change key on upstream identifiers? If either answer is yes, the fix probably belongs upstream. +- Example of what not to do: a table that renames `find-slos-op` to `list` (elastic/cli#833). The `-op` suffixes come from Kibana OAS `operationId`s. Fix them in Kibana OAS or `elastic/schemas-js` (see schemas-js#67 for a name fix made there). - Never add a per-endpoint or per-namespace override table to work around upstream data. Exception: a maintainer explicitly approves it as a stopgap and a tracking issue is linked in the code comment. ## Command Authoring Requirements From 232a47b72932f878b1cfb11775799ba71a4f9f0c Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Mon, 30 Nov 2026 14:38:00 -0500 Subject: [PATCH 3/9] docs(agents): list red-flag patterns for upstream workarounds Assisted-by: Pi Coding Agent (claude-sonnet-5.5) --- AGENTS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AGENTS.md b/AGENTS.md index db8a1d98..7ef7961a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -57,6 +57,7 @@ Before changing command names, flags, descriptions, or input/response shapes tha - Wrong, ugly, or inconsistent data in a schema or spec (names, `operationId`s, descriptions, types, missing `x-` annotations): **stop. Do not patch it here.** Tell the human which upstream repo owns it and draft an issue there. - CLI-only UX policy (output format, aliases, grouping, safety prompts) is in scope here. - Decision test. Answer both before writing code: (1) Would other consumers of the schemas, such as Elastic's universal MCP server or Agent Builder tool definitions, benefit from the same fix? (2) Does the change key on upstream identifiers? If either answer is yes, the fix probably belongs upstream. +- Red flags. If your plan matches one, stop and ask the human: a new map keyed by upstream names; `if (def.name === ...)` special cases; a comment saying "when upstream renames, re-key"; codegen overrides that mirror runtime overrides. - Example of what not to do: a table that renames `find-slos-op` to `list` (elastic/cli#833). The `-op` suffixes come from Kibana OAS `operationId`s. Fix them in Kibana OAS or `elastic/schemas-js` (see schemas-js#67 for a name fix made there). - Never add a per-endpoint or per-namespace override table to work around upstream data. Exception: a maintainer explicitly approves it as a stopgap and a tracking issue is linked in the code comment. From 99daf97fc7db853ded7926d6009e1a5eeef09d2b Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Mon, 30 Nov 2026 14:38:00 -0500 Subject: [PATCH 4/9] docs(architecture): document who owns schema data Assisted-by: Pi Coding Agent (claude-sonnet-5.5) --- ARCHITECTURE.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index dfa1bc35..24074439 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -38,6 +38,17 @@ Properties and roots carry `x-` annotations. Two classes, and the distinction ma **Do not**: strip `x-` keys by prefix. `stripTransportMeta()` in `src/factory-core.ts` removes the routing class by explicit name so user-facing annotations survive into `--help --json`. Routing metadata leaking into schema output violates the transport-abstraction requirement in AGENTS.md. +## Ownership of Schema Data + +| Defect | Owner | +|---|---| +| `operationId`s, summaries, parameter names or types in the spec | Kibana / Elasticsearch / Cloud spec source | +| Name normalization, `x-` annotations, path/body routing, sidecar `_defs.json` / `_types.json` | [`elastic/schemas-js`](https://github.com/elastic/schemas-js) (published as `@elastic/schemas`) | +| Client generation shared with other SDKs | `elastic/elastic-client-generator-js` | +| Output format, grouping, aliases, prompts, policy, config | this repo | + +**Do not**: work around upstream data in this repo with override tables or special cases. File an issue in the owning repo and link it. Precedent: schemas-js#67 fixed a malformed operation name upstream. See "Fix at the source" in AGENTS.md. + ## `cli-schema.ts` — CLI Structure Emitter Module that introspects the registered Commander tree and each command's attached JSON Schema `input` to build the `elastic cli-schema` output consumed by agents. From 55aa731b7dabbc4d68f76ad7da3c3f4a39b3dbed Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Mon, 30 Nov 2026 14:38:00 -0500 Subject: [PATCH 5/9] docs: require upstream-check in PR reviews Assisted-by: Pi Coding Agent (claude-sonnet-5.5) --- .github/skills/code-review/SKILL.md | 1 + AGENTS.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/skills/code-review/SKILL.md b/.github/skills/code-review/SKILL.md index 1e479b30..65d9a139 100644 --- a/.github/skills/code-review/SKILL.md +++ b/.github/skills/code-review/SKILL.md @@ -10,3 +10,4 @@ description: Guidelines to apply when doing a code review on a pull request - Extra attention **SHOULD** be given to *existing unit tests that have changed*, to ensure that the change does not allow regressions, that it actually tests what it states, and that it is still possible for the test to fail under some circumstance (i.e. does not do the functional equivalent of `assert(true)`). - All global CLI options **MUST** be respected by all new changes. For example, if a global `--no-color` flag is supported by the CLI, and `renderText` is updated to emit ANSI, `renderText` must not emit ANSI when that flag is set. - Code should **ALWAYS** reuse provided factories and utilities instead of Node.js globals (`hasGlobalJsonFlag` instead of `process.argv.includes('--json')`, handler return value instead of `process.stdout.write`) unless there is a **VERY** clear reason to circumvent the ideal path. +- Changes that work around upstream data (override tables keyed by `@elastic/schemas` names, special cases on `def.name`, renames of generated commands) **MUST** be flagged unless a maintainer approved a stopgap and an upstream issue is linked. See "Fix at the source" in AGENTS.md. diff --git a/AGENTS.md b/AGENTS.md index 7ef7961a..3a285554 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -10,6 +10,8 @@ Picking an issue at random to generate a contribution is not contributing. PRs o If a human asks you to "find something to work on" or points you at the issue tracker without a specific problem they already understand, stop and tell them to read an issue first. +If any changes in the PR are made to work around upstream data in `@elastic/schemas` or similar, PR description MUST state why the change cannot be fixed upstream (see "Fix at the source"), or that it is not an upstream data issue. + See [CONTRIBUTING.md](./CONTRIBUTING.md) for the full policy. ## Tech Stack From db4c0246c78ede17782e481aa2f5310013f86124 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Mon, 30 Nov 2026 14:38:00 -0500 Subject: [PATCH 6/9] docs(agents): add upstream-check skill Assisted-by: Pi Coding Agent (claude-sonnet-5.5) --- .agents/skills/upstream-check/SKILL.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .agents/skills/upstream-check/SKILL.md diff --git a/.agents/skills/upstream-check/SKILL.md b/.agents/skills/upstream-check/SKILL.md new file mode 100644 index 00000000..67eebd76 --- /dev/null +++ b/.agents/skills/upstream-check/SKILL.md @@ -0,0 +1,19 @@ +--- +name: upstream-check +description: Decide whether a fix belongs in this repo or upstream (Kibana OAS, Elasticsearch spec, elastic/schemas-js). Use before renaming commands, changing generated names, flags, descriptions, or types, or when a schema looks wrong. +--- + +# Upstream check + +Run this before writing code for any change that touches names, flags, descriptions, or shapes derived from `@elastic/schemas`. + +1. Trace the value to its origin: + ```bash + rg -n '' node_modules/@elastic/schemas | head -20 + ``` +2. Classify the owner (see "Ownership of Schema Data" in ARCHITECTURE.md): + - specification content (`operationId`, summary, parameter types): Kibana OAS, Cloud OAS, [Elasticsearch spec](https://github.com/elastic/elasticsearch-specification). + - Normalization, `x-` annotations, routing, sidecars: `elastic/schemas-js`. + - Output, grouping, aliases, prompts, config: this repo. +3. If upstream owns it: **stop**. Do not add an override table or `def.name` special case. Tell the human the owner, and draft the issue (title, current value, proposed value, affected consumers). +4. If a maintainer explicitly approves a stopgap here, link the upstream issue in a code comment. From f6f1222d68ffd50b15ac3a38f7e00f12a53a24f0 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Mon, 30 Nov 2026 14:45:13 -0500 Subject: [PATCH 7/9] docs(github): tell auto-pr not to fix upstream schema data Assisted-by: Pi Coding Agent (claude-sonnet-5.5) --- .github/auto-pr-context.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/auto-pr-context.md b/.github/auto-pr-context.md index 9b58539a..9cf9260e 100644 --- a/.github/auto-pr-context.md +++ b/.github/auto-pr-context.md @@ -17,6 +17,7 @@ Elastic CLI. TypeScript. Commands live under `src/` (`es`, `kb`, `cloud`, `facto - Do not edit `.github/workflows/` - After `package.json` changes, run `node scripts/generate-notice.mjs` - After command or flag changes, run `npm run build:schema` and commit `docs/cli/schema.json` +- Do not fix defects in upstream schema data here (names, `operationId`s, descriptions, types, `x-` annotations). Comment with the owning repo (Kibana OAS, Elasticsearch spec, Cloud spec, `elastic/schemas-js`) and stop. See "Fix at the source" in AGENTS.md ## Search hints From f75194a78a8328540b8d860a3fb1a8d2826496c1 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Mon, 30 Nov 2026 14:45:16 -0500 Subject: [PATCH 8/9] ci(review): flag workarounds for bad upstream schema data Assisted-by: Pi Coding Agent (claude-sonnet-5.5) --- .github/workflows/ai-pr-review-run.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ai-pr-review-run.yml b/.github/workflows/ai-pr-review-run.yml index 4791c7d3..b268e4c0 100644 --- a/.github/workflows/ai-pr-review-run.yml +++ b/.github/workflows/ai-pr-review-run.yml @@ -88,6 +88,13 @@ jobs: credentials must set redirect: 'error' or 'manual', never rely on the default 'follow'. + Flag changes that work around bad upstream schema data + (override tables keyed by @elastic/schemas names, special + cases on def.name, renames of generated commands). Those + fixes belong in Kibana, Cloud or ES specs, or + elastic/schemas-js, unless a maintainer approved a stopgap + and an upstream issue is linked. + Apply ponytail discipline: flag over-engineering, unnecessary abstractions, new dependencies that a few lines would replace, boilerplate added for later, or anything that could be deleted From 04da1ecaa5141ba5ee185f40814f06f21907cabd Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Mon, 30 Nov 2026 14:45:17 -0500 Subject: [PATCH 9/9] docs(contributing): add fix-at-the-source step Assisted-by: Pi Coding Agent (claude-sonnet-5.5) --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd40c45a..d18dd72a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -105,7 +105,8 @@ Adding new third-party dependencies is **strongly discouraged** to minimize supp 2. **Write tests**: All changes should have corresponding unit tests 3. **Test locally**: Run `npm test` and verify everything passes 4. **Check linting**: Fix any lint errors with `npm run test:lint -- --fix` -5. **Review your code**: Would you understand it in 6 months? Can it be simpler? +5. **Fix at the source**: Bad upstream schema data belongs in the spec or [`elastic/schemas-js`](https://github.com/elastic/schemas-js), not here; link the upstream issue in your PR +6. **Review your code**: Would you understand it in 6 months? Can it be simpler? ## Submitting a PR