Skip to content

statement: export the closed set of operation shapes - #272

Closed
Kiran01bm wants to merge 1 commit into
mainfrom
kiran01bm/statement-op-kinds
Closed

Kiran01bm wants to merge 1 commit into
mainfrom
kiran01bm/statement-op-kinds

Conversation

@Kiran01bm

Copy link
Copy Markdown
Collaborator

Exports statement.OpKinds(), the closed set of operation shapes, with a test that it matches exactly the OpKind constants ops.go declares.

Why

A registry of the operations pg-sprite can run that cannot be undone is coming next. Its completeness test has to walk every operation shape and fail when a new one is unclassified, the way TestRefusalRegistryIsComplete walks statement.Kinds(). Statement kinds have that accessor; operation shapes do not.

What

  • statement.OpKinds() returns every OpKind, OpUnrecognized first.
  • TestOpKindsIsClosedAndDescribed parses the ops.go iota block and fails if OpKinds() misses or duplicates a constant, or if a shape falls through to the catch-all Describe() label.
  • The test helper declaredIotaValues now takes the file to parse, so the same check reads ops.go as well as statement.go.

No behaviour changes: nothing calls OpKinds() yet.

Before / after

A later PR adds OpDropPolicy to the ops.go iota block and forgets the new list.

Before                                        After

const ( … OpReindex; OpDropPolicy )           const ( … OpReindex; OpDropPolicy )
no list of op kinds exists                    OpKinds() still ends at OpReindex
  → a registry keyed on op kinds cannot         → TestOpKindsIsClosedAndDescribed fails:
    tell that OpDropPolicy is missing             "OpKinds() must enumerate exactly the
                                                   OpKind constants ops.go declares"
                                                → the author adds it, and the registry
                                                  then has to classify it

🤖 Generated with Amp (Claude Opus 4.6)

A registry keyed on the operation shape needs to walk every shape to prove
none is unclassified, as the refusal registry walks Kinds().
@Kiran01bm Kiran01bm closed this Oct 28, 2026
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