Skip to content

Add typed assertion-kind constants - #107

Merged
korya merged 1 commit into
masterfrom
korya-api-typed-assertion-kinds
Aug 31, 2026
Merged

Add typed assertion-kind constants#107
korya merged 1 commit into
masterfrom
korya-api-typed-assertion-kinds

Conversation

@korya

@korya korya commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Problem

Library consumers must compare assertion families through raw strings, making structured result handling typo-prone and undiscoverable.

FailureCode and EvaluationErrorCode already provide typed discriminators, but Assertion.Kind, Outcome.Kind, Failure.Kind, and EvaluationError.Kind expose plain strings. This inconsistency would become costly once v0.4.0 publishes the package contract.

Solution

Introduce AssertionKind and exported constants across the public result model without changing their string values.

Before:

if outcome.Kind == "jq" {
    // handle jq
}

After:

if outcome.Kind == ha.KindJQ {
    // handle jq
}

Built-in assertions now return the corresponding constant. The type remains an open string type, so external packages can define custom assertion families rather than being restricted to the built-in set. CLI output and machine-visible values remain byte-for-byte compatible.

No visual change: this changes a Go API type without changing CLI rendering.

Other Changes

  • Add an external-package compile-time assertion proving custom implementations remain supported.
  • Record the typed discriminator in the unreleased changelog.

🤖 Generated with Claude Code

Structured consumers previously compared assertion families through undocumented string literals.
Expose AssertionKind constants and use the type throughout outcomes, failures, and evaluation errors
while preserving every serialized value and allowing custom assertion kinds.

Co-Authored-By: OpenAI Codex (GPT-5) <noreply@openai.com>
@korya
korya marked this pull request as ready for review August 31, 2026 00:50
@korya
korya merged commit 60b87fd into master Aug 31, 2026
7 checks passed
@korya
korya deleted the korya-api-typed-assertion-kinds branch August 31, 2026 00:50
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