Repository navigation
fix(matcher): decode the authored operator-map through yaml.v3 - #459
Merged
Merged
Conversation
Matcher carried only json tags, so yaml.v3 decoded its struct field names
`op`/`value` and silently dropped the authored operator-map form
(`expect: {equals: "yes"}`), leaving Op/Value zero with no error. An authored
#Answer.expect (D-FLOW-3) therefore arrived empty and the pipeline lowering's
refusal never fired.
UnmarshalYAML mirrors UnmarshalJSON: the canonical `{op, value}` mapping, an
operator-map, a bare scalar (implicit equality), and null/empty to the zero
matcher. A regression test decodes the authored #Answer shape from YAML and
round-trips the matcher.
Closes #457.
Agent: pr-sweep · Claude Code session 8df24173-9dbe-4357-a454-8faee0703dea
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
Review — PASSHead SHA: Security screen: PASS Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
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
Matchercarried onlyjsontags, soyaml.v3decoded its struct field namesop/valueand silently dropped the authored operator-map form —expect: {equals: "yes"}lowered to a zero matcher, never an error. An authored#Answer.expect(D-FLOW-3) therefore arrived empty and the pipeline lowering's refusal never fired.This adds
Matcher.UnmarshalYAMLmirroring the existingUnmarshalJSON: the canonical{op, value}mapping, an operator-map ({equals: X}), a bare scalar (implicit equality), andnull/empty to the zero matcher. It also adds the regression test that decodes the authored#Answershape from YAML and round-trips the matcher.The diff is
spec/union_types.go(the hand-written#MatcherGo type) and its new test filespec/union_types_matcher_yaml_test.go. No CUE schema, generated type or wire shape changes.Closes #457
How tested
Head
c6967fd5cca92eb0d6373f271eb4fb35e1e69dfd(git rev-parse HEAD).Spike
RCA claim:
Matchercarries onlyjsontags, soyaml.v3decodes the struct'sop/valuefields and silently drops the authored operator-map ({equals: X}), leavingOp/Valuezero.Candidates spiked:
Matcher.UnmarshalYAMLmirroringUnmarshalJSON— WORKS, and it is the candidate the diff implements; the transcripts below are its spike.spectype inside one consumer is the R3 workaround the type exists to prevent, and every other#Matcherdecoded through yaml.v3 would still drop its operator.#Answer.expecta string — rejected: it loses the single-operator matcher vocabulary (#Matcher/#MatchOpMap), and#Answeris not the only matcher-shaped field.Winner: (a) add
Matcher.UnmarshalYAMLmirroringUnmarshalJSON— it gives the type's two read paths one vocabulary (R2) and fixes every YAML consumer rather than one.RCA verdict: confirmed — candidate (a) works; the regression test fails on the unmodified tree and passes with the implementation.
Fails-before — the regression test on a clean worktree of the parent commit
31f96dcwith only the test file added (no implementation):Passes-after — the same test on the head this PR pushes:
Gate
The module gate
spec's CI runs (.github/workflows/ci.yml), on the committed tree:The lint
spec'sAGENTS.mdnames, under the toolchaingo.moddeclares:Consumer proof
The end-to-end lowering proof is the consumer's, not this repo's:
opencharly/plugin-pipeline#69owns the bed that runscharly pipeline run --dry-runthrough the real plugin against the tag this change lands. This repo's boundary — that an authored#Answer.expectreachesspec.Matcherwith its operator and value populated — is the decode, and the regression test above exercises it.Rulebook compliance
git-workflow(with its pre-validator self-audit),strict-policy,root-cause-analyzer,design,go,pluginandinstall-planfrom the live umbrella and spec trees, and spec'sAGENTS.md, before the first edit.MatcherListhas the same missing YAML read path, hard-erroring instead of silently dropping) is filed as MatcherList has no UnmarshalYAML — its scalar/single-map shorthand fails through yaml.v3 #458 and listed under## Filed issues. The gate leaves no warning.UnmarshalYAMLmirrors the existingUnmarshalJSONon the same type, so both read paths accept one vocabulary; candidate (b) was rejected because it would add a second decode of the shared type..worktrees/pr-sweep/spec, branchfix/matcher-unmarshal-yamlofforigin/main); the submodule checkout is untouched; no force-push and no direct push.charlybinary is built or deployed, and the tests run the worktree source.go build,go vet,gofmtandgo testplus thegolangci-lintrun that spec's CI performs, on the committed tree, with zero findings.specdeclares nodisposable:target; the consumer's live bed is plugin-pipeline#69's.Plan conformance
Winning candidate: (a) add
Matcher.UnmarshalYAMLmirroringUnmarshalJSON— the same candidate the### Spikeround names as its winner.Matcher.UnmarshalYAML, the YAML read path of the hand-written#MatcherGo type#StageAskto#Answer): the response contractexpect:is a matcher a response must satisfy to begrantedexpectmatcher arrives populated, so agrantedsettlement can evaluate the response{op, value}mapping, single-operator map, bare scalar, null)DESIGN.cue's#Matcherand#MatcherAlt#Answer: the ask's response contract#Answershape through yaml.v3, assertsOpandValue, and round-tripsschema/*.cueandspec/cue_types_gen.goare untouched;#Matcherstays the hand-written@go(-)type and a clean regeneration stays a no-opChange classification
speccontract module — no authored or wire shape change, no schema or generated-code change.opencharly/plugin-pipeline#69's.Filed issues
MatcherListhas noUnmarshalYAML, so its documented scalar/single-map shorthand fails through yaml.v3 (non-blocking, unclaimed).Agent:
pr-sweep· Claude Code session8df24173-9dbe-4357-a454-8faee0703deaAssisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)