Skip to content

feat(tooling): add SDK coverage tool and manifest - #110

Merged
LanusseMorais merged 2 commits into
LSH-3445-ci-and-rootfrom
LSH-3445-sdk-coverage-tool
Nov 25, 2026
Merged

LanusseMorais merged 2 commits into
LSH-3445-ci-and-rootfrom
LSH-3445-sdk-coverage-tool

Conversation

@LanusseMorais

@LanusseMorais LanusseMorais commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #111 (CI workflow and cmd.Root()), split out of this PR at review; merge #111 first.

Summary

  • Adds cmd/sdkcoverage and internal/sdkcoverage, an offline tool that reads the pinned latitudesh-go-sdk surface from the module cache, walks the cobra command tree built by cmd.Root() and reconciles both against sdk-coverage.yaml. Subcommands: report (markdown, text, json), check, groups, commands. No API token involved.
  • Adds sdk-coverage.yaml, which maps SDK methods to the commands that call them: 116 of 216 methods covered at v1.21.4, 29 excluded with a reason, 71 pending. Besides commands and excluded, a group can name a pending command (suggested) or record that an existing command is to call a pending method (extends, e.g. BGP sessions in elastic-ips get).
  • The JSON report is the input for the sdk-watch scaffold (LSH-3442): pending commands grouped by top-level command, with "extends": true when the scaffold should grow an existing command instead of adding one.
  • TestCLISDKCoverage runs with go test ./... and fails only on contradictions: a mapped path the CLI does not register, a method or group the SDK no longer exposes, a command no method claims, an exclusion without a reason, or a pending method whose automatic name is a command that already exists (it must go under extends or get a new name under suggested). New SDK methods show up as pending, not as failures.
  • Adds make coverage-report and make coverage-check, and a CONTRIBUTING guide.

Known limitations

  • The gate checks that every mapped path exists, not that the command actually calls the method, so a wrong mapping is caught in review. That is why a planned extension goes under extends and only moves to commands once the command calls the method.
  • A few commands hit an endpoint by hand (plans list/stock, s3 access-keys list/get/import); they are mapped to the SDK method for the same endpoint, with a comment.
  • Bucket resolution (ObjectStorage.GetStorageBucket) runs before almost every s3 command; it is mapped only where it is the command's only API call.
  • Managed Databases and KubernetesClusters.UpdateKubernetesCluster are excluded as deprecated, so they are not scaffolded.
  • Greptile also reports two issues in code already on main (the servers actions reboot --wait transition check and the ssh_keys alias); they are out of scope here.

Testing

No credentials are needed: everything runs offline against the module cache, except the last block, which downloads the latest SDK.

Clone & checkout

git clone https://github.com/latitudesh/cli.git lsh-cli
cd lsh-cli
git checkout LSH-3445-sdk-coverage-tool

Build & unit tests

go build -o lsh .
go vet ./...
go test ./...

Try the commands

Gate and reports. make coverage-check should print ok: v1.21.4 — 116/216 methods covered, 29 excluded, 71 pending; 5 new top-level command groups; the extends query returns the elastic-ips get extension, and s3 configure shows up as a command next to its export child:

make coverage-check
make coverage-report
go run ./cmd/sdkcoverage report -format markdown
go run ./cmd/sdkcoverage report -format json | jq '.counts'
go run ./cmd/sdkcoverage report -format json | jq -c '.pending[].commands[] | select(.extends)'
go run ./cmd/sdkcoverage commands | grep '^s3 configure'

The gate must reject each broken manifest below with exactly one violation: an extends to a command that does not exist, an extends for a method already mapped, a suggested name that already exists, and a command no method claims:

sed 's/ListElasticIPBgpSessions: elastic-ips get/ListElasticIPBgpSessions: elastic-ips show/' sdk-coverage.yaml > /tmp/sdkcov-extends-missing.yaml
go run ./cmd/sdkcoverage check -manifest /tmp/sdkcov-extends-missing.yaml
sed 's/      GetElasticIPBgpSession: elastic-ips get/      GetElasticIP: elastic-ips get/' sdk-coverage.yaml > /tmp/sdkcov-extends-done.yaml
go run ./cmd/sdkcoverage check -manifest /tmp/sdkcov-extends-done.yaml
sed 's/CreateElasticIPBgpSession: elastic-ips attach/CreateElasticIPBgpSession: elastic-ips get/' sdk-coverage.yaml > /tmp/sdkcov-suggested-existing.yaml
go run ./cmd/sdkcoverage check -manifest /tmp/sdkcov-suggested-existing.yaml
sed 's/, s3 configure\]/]/' sdk-coverage.yaml > /tmp/sdkcov-no-configure.yaml
go run ./cmd/sdkcoverage check -manifest /tmp/sdkcov-no-configure.yaml
rm -f /tmp/sdkcov-*.yaml

Check the manifest against the latest SDK release without touching go.mod (v1.21.5 today, same counts):

dir=$(go mod download -json github.com/latitudesh/latitudesh-go-sdk@latest | jq -r '.Dir')
go run ./cmd/sdkcoverage report -sdk-dir "$dir" -format text

🤖 Generated with Claude Code

Comment thread internal/sdkcoverage/reconcile.go Resolved
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 24, 2026
@leandroh

Copy link
Copy Markdown
Member

Thanks for this, the coverage numbers are useful. 116 of 216 SDK methods have a command and 71 are still open, which is a gap we should close. I'd like to split the PR and make the coverage part smaller before we merge it.

Happy to merge now, as a separate PR

  • .github/workflows/test.yml. We have no build/vet/test check on PRs today, so this helps right away.
  • cmd.Root(). Building the tree once and sharing it is a clean change.

Concerns with the coverage tool as it is

  1. More work on every CLI PR. TestCLISDKCoverage fails when a command isn't claimed in sdk-coverage.yaml. So every new command also needs a YAML entry, for good.
  2. The check is weak. As the description says, the test checks that a mapped command exists, not that it calls the method. A wrong mapping passes CI. We'd be keeping a manual list without getting a guarantee.
  3. The list could come from the code. We can find which SDK methods cmd/ calls by scanning it with go/packages and looking for calls on the SDK client. That removes the commands: section and the wrong-mapping case. The YAML would then only list exceptions: excluded with a reason, and maybe extends.
  4. naming.go (473 lines) guesses command names only to feed the sdk-watch scaffold. If the scaffold uses an LLM, it can choose the names itself. Could we leave this out until the scaffold exists?

Suggestion

  • PR 1: the CI workflow and Root().
  • PR 2: coverage found from code, a report of uncalled SDK methods, and a short exclusions file. Leave suggested, extends and the naming logic until the scaffold work starts.

Is the sdk-watch scaffold planned work? If it is, more of this design makes sense, but I'd still want the test to check "the method is called" rather than "the command exists".

@LanusseMorais
LanusseMorais force-pushed the LSH-3445-sdk-coverage-tool branch from 6602da0 to 5789479 Compare November 25, 2026 19:51
@LanusseMorais LanusseMorais changed the title feat(tooling): add SDK coverage tool, manifest and CI test workflow feat(tooling): add SDK coverage tool and manifest Nov 25, 2026
@LanusseMorais
LanusseMorais changed the base branch from main to LSH-3445-ci-and-root November 25, 2026 19:51
@greptile-apps
greptile-apps Bot dismissed their stale review November 25, 2026 19:51

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@LanusseMorais
LanusseMorais added this pull request to stack #112 November 25, 2026 19:57
@LanusseMorais
LanusseMorais merged commit e191981 into main Nov 25, 2026
1 check passed
@LanusseMorais
LanusseMorais deleted the LSH-3445-sdk-coverage-tool branch November 25, 2026 20:07
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.

2 participants