Skip to content

test: assert the entity spec table holds together - #3

Merged
skeeeon merged 1 commit into
mainfrom
test/entity-spec-table
Aug 22, 2026
Merged

test: assert the entity spec table holds together#3
skeeeon merged 1 commit into
mainfrom
test/entity-spec-table

Conversation

@skeeeon

@skeeeon skeeeon commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

This repo had no tests at all — CI's go test ./... ran over nothing. The entity table is the right place to start: it's the CLI's entire surface (registerCRUD builds a command tree per spec, pull/apply enumerate the same list), and it's hand-maintained on purpose since it isn't derived from the platform's schema.json.

Every failure mode that table has is silent. Concretely:

  • addFieldFlags and collectFields both switch on Type without a default, so a typo'd type registers no flag and the field quietly cannot be set.
  • A verb spelled "list" makes hasVerb answer false for every verb the spec meant to allow — the command just goes missing.
  • A duplicated alias isn't an error in cobra; one command shadows the other and an entity stops being reachable.
  • A LookupKey naming a field the collection lacks turns every natural-key lookup into an opaque 400.

What's asserted

Types are dispatchable · verbs known and unique · LookupKey names a declared field · select/multiselect carry Values and nothing else does · flags unique within a spec and not colliding with what ls/get/delete/create register themselves (--filter, --sort, --fields, --yes/-y, --random-password) or with root.go's persistent flags · Required only where create exists · no command name or alias claimed twice across the whole table · every entity reachable by at least ls or get.

Plus unit coverage of the helpers behind those checks — aliases, flagName, hasVerb, composeOrgFilter, splitFields — and a short explicit list of the non-org-scoped collections, which is the one place the CLI's model of platform tenancy is written down.

These were verified to fail

A passing test that cannot fail isn't evidence, so I planted each defect, confirmed the failure, and reverted:

planted defect caught by
Type: "strng" on a field addFieldFlags does not dispatch on
locations given Plural: "things" alias "things" is claimed by both
Verbs: ["list", …] unknown verb "list"
LookupKey: "host_name" not a declared field
a field named fields the ls command registers itself
FSelect with Values removed rejects every value passed to it
Values on an FString declares Values, which nothing reads

composeOrgFilter's parenthesisation is pinned for the reason it exists: an OR inside a user's --filter must not escape the org scope.

Two notes for you rather than for the code:

  1. This closes chore test: assert the entity spec table holds together #3. Chore test: guard the entity table against the platform's schema #4 — a guard against the field table drifting behind schema.json — is still open and still needs your call on vendoring vs fetching.
  2. While reading the table I noticed the docs understate it: platform-docs/docs/stone-cli.md §4 lists nats-account and nebula-ca as ls / get, but both specs declare ls, get, update, edit. The server rejects tenant writes either way, so it's a docs inaccuracy rather than a hole — say the word and I'll fix that page.

🤖 Generated with Claude Code

This repo had no tests at all, so CI's `go test ./...` ran over nothing. The
entity table is the right place to start: it is the CLI's entire surface --
registerCRUD turns each spec into a command tree and pull/apply enumerate the
same list -- and it is hand-maintained on purpose, since it is not derived from
the platform's schema.json.

Every failure mode it has is silent. Nothing in the type system objects to a
typo'd field type, and both addFieldFlags and collectFields switch on Type
without a default, so the field registers no flag and quietly cannot be set. A
verb spelled "list" makes hasVerb answer false for every verb the spec meant to
allow, and the command goes missing. A duplicated alias is not an error in
cobra; one command shadows the other and an entity stops being reachable. A
LookupKey naming a field the collection lacks turns every natural-key lookup
into an opaque 400.

So the tests assert: types are dispatchable, verbs are known and unique,
LookupKey names a declared field, select/multiselect carry Values and nothing
else does, flags are unique within a spec and do not collide with the flags ls,
get, delete and create register themselves or with root.go's persistent ones,
required fields only exist where create does, and no command name or alias is
claimed twice across the whole table. Plus unit coverage of the helpers that
back them -- aliases, flagName, hasVerb, composeOrgFilter, splitFields -- and a
short explicit list of the collections that are not org-scoped, which is the one
place the CLI's model of platform tenancy is written down.

Each check was verified by planting the defect it describes and confirming the
failure, then reverting: a passing test that cannot fail is not evidence.
composeOrgFilter's parenthesisation is pinned for the same reason it exists --
an OR inside a user's --filter must not escape the org scope.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@skeeeon
skeeeon merged commit 70631cd into main Aug 22, 2026
1 check passed
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