test(cli): shared CLI contract schema-golden test (v0.19 Workstream 8)#2668
Merged
Conversation
Adds the schema-golden test that proves the "--json contract" claim instead
of asserting it: a completeness walk recursively classifies every leaf in
(&root.RootCommand{}).SubCommands() into Family A (cecdysis.CommandWithResult,
validated against the one committed envelope.schema.json), Family B
(cecdysis.CommandWithExecuteWithClientResult, raw protojson/go-json
passthrough, asserted to NOT match the envelope), or a named exception
(quickstart --json, a pre-existing log-format toggle, documented not fixed).
An unclassified --json-registering command fails the build.
- cmd/conduit/cecdysis/testdata/envelope.schema.json: the one committed
Family A schema (draft 2020-12, additionalProperties:false).
- cmd/conduit/internal/testutils/envelope.go: ValidateEnvelope/MatchesEnvelope,
shared by every command's own test file (test-only; never linked into the
conduit binary). Promotes github.com/santhosh-tekuri/jsonschema/v6 from an
already-present indirect dependency to direct.
- cmd/conduit/cecdysis/decorators.go: exports MarshalJSON so Family B tests
can assert on the exact --json bytes without re-deriving the marshaling
choice.
- cmd/conduit/cli/schema_golden_test.go: the completeness walk.
- Migrates `conduit init` and `conduit pipelines init` onto
cecdysis.CommandWithResult (previously zero --json support), with
human-mode output text preserved unchanged.
- Extends the 26 existing Family A/B commands' own test files with an
envelope-conformance (or negative) assertion each, plus new lint/dry-run
fixtures where none existed.
- Documents the two-family split and the quickstart exception in
docs/design-documents/20260707-cli-output-conventions.md §6.
Roadmap: v0.19 Workstream 8 (v019-plans/workstreams/cli-contract.md).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015GQFzakPShAYj8CcwajYDD
…ema-golden # Conflicts: # cmd/conduit/root/pipelines/init.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the schema-golden test for v0.19 Workstream 8
(
v019-plans/workstreams/cli-contract.md) — the harmonization guarantee forevery other v0.19 workstream's
--jsonsurface.Corrected premise, verified in the repo (not "one schema," per the plan's
own §4 finding): there are two distinct, both-deliberate
--jsonfamiliesin production today:
cecdysis.CommandWithResult): 15 commands(13 pre-existing +
init+pipelines init, both migrated onto theenvelope in this PR — previously zero
--jsonsupport on either).Validated against one committed schema,
cmd/conduit/cecdysis/testdata/envelope.schema.json.(
cecdysis.CommandWithExecuteWithClientResult): 13 commands, rawprotojson/go-json, intentionally never wrapped in the envelope (confirmed
correct, load-bearing behavior, not a migration backlog item). Asserted to
never accidentally match the envelope schema.
quickstart --jsonmeans "log format," not theenvelope — documented, not silently ignored, not silently fixed.
What's implemented
cmd/conduit/cli/schema_golden_test.go): recursivelywalks
(&root.RootCommand{}).SubCommands()and classifies every leaf.Fails the build if a command registers
--jsonbut implements neitherfamily and isn't a named exception. Verified this predicate actually
fires (temporarily un-exempted
quickstart, confirmed the test failedwith the expected message, restored it).
(
cmd/conduit/internal/testutils/envelope.go):ValidateEnvelope/MatchesEnvelope, test-only (never linked into theconduitbinary —testutilshas zero non-test importers, verified). Promotesgithub.com/santhosh-tekuri/jsonschema/v6from an already-presentindirect dependency to direct — no new dependency, just wiring one that
was already in
go.sum.conduit init/conduit pipelines initmigrated onto Family A(previously zero
--jsonsupport on either), human-mode text preservedbyte-for-byte.
envelope-conformance (or negative) assertion added to its own existing
test file — no production behavior changed, per AC-3. New
lint/dry-runfixtures added where no test file existed before.
docs/design-documents/20260707-cli-output-conventions.md§6 documents the two-family split and the
quickstartexception.Risk tier
Tier 2 (CLI/test infrastructure, per the plan's own assessment — no
data-path invariant touched).
Adversarial self-review
just that it passes) by temporarily removing the
quickstartexceptionentry and confirming the expected failure message, then restoring it.
make generateproduces zero drift beyond this diff's ownfiles (
git status --shortaftermake generateshows only the filesthis PR intentionally touches).
testutils(home of the new schema validator) has zeronon-test importers, so
jsonschema/v6does not enter the shippedconduitbinary despite being promoted to a direct module dependency.connectors bundleandconnector|processor newhave no genuineend-to-end success-path test today (bundling/scaffolding need real
artifacts/network+toolchain) — for these I added a schema-conformance
check against the real result type with realistic synthetic data
(mirroring the pre-existing
TestResultMarshalsToTheDocumentedEnvelopeprecedent in
scaffoldcmd), documented as such rather than silentlypassed off as a full E2E test.
initcommands: a HARD failure(unwritable directory, unknown connector) still returns a non-nil error
from
ExecuteWithResult, correctly routed through the existingconduiterr→ResultErrormapping — no new error-shape code needed.output/test surface only.
Test plan
go build ./...golangci-lint run ./cmd/conduit/...— 0 issuesgo test -race ./cmd/conduit/...— all greenmake generate && git status --short— zero unexpected driftmarkdownlint-cli2(both local and CI-pinned 0.18.1) on the docaddendum — 0 errors
Roadmap: v0.19 Workstream 8.
🤖 Generated with Claude Code
https://claude.ai/code/session_015GQFzakPShAYj8CcwajYDD