Repository navigation
feat: a payload schema for three kinds, with presence declared field by field (ADR 0074) - #112
Merged
Merged
Conversation
…by field (ADR 0074)
ADR 0002 promised public `.proto` files and none existed: the corpus of golden
payloads became the contract by default. This writes the schema for the three
kinds that have been read closely — `node_metadata`, `collection_coverage`,
`node_lifecycle` — and leaves the other nineteen alone.
Proto3 singular scalars have no presence, so a measured zero and an unreported
field are the same bytes. Every field whose zero or false is a claim is declared
`optional`; every field whose empty value *is* its absence is not.
Nothing goes on the wire: no payload byte moves and no encoder changes. The
corpus is what keeps the schema honest — each covered golden is parsed into its
generated message with `DiscardUnknown` off, and a second walk fails on any
value that did not survive as a set field.
go test ./... && golangci-lint run # all green
buf lint # clean
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeZECJXTDHL6Nts95eKMJA
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.
ADR 0002 promised public
.protofiles and none existed, so the golden payloadcorpus became the contract by default. This writes the schema for the three
kinds that have been read closely —
node_metadata,collection_coverage,node_lifecycle— and deliberately leaves the other nineteen alone: a.protowritten from a struct freezes a guess for an N-2 window.
Nothing goes on the wire. No payload byte moves, no encoder changes, no
golden file is touched.
The decision that shapes the files
Proto3 singular scalars have no presence: a measured zero and an unreported
field are the same bytes.
"malformed": 0is a claim, and as a plainint64itbecomes indistinguishable from an agent that said nothing.
So presence is declared field by field, asking of each whether silence and
nought mean the same thing.
optionalon every capacity/allocatable number,every coverage counter, every config switch,
SourceHealth.synced/.failing,and
at_observed— wherefalseand absent coincide today only by coincidence.Plain where the empty value is the absence:
kind,source, label strings,window_seconds, and the two knobs whose zero means "the default applies".No enums: canonical JSON renders an enum by its declared name, which is not
"joined"or"NoSchedule". Integer widths are 64-bit throughout, socapacity_cpu_milliandcapacity_memory_bytesrender alike rather than one asa number and one as a string. The goldens do not move to canonical proto JSON.
Full reasoning, including the JSON representation and the compatibility rules,
in ADR 0074.
What keeps it honest
internal/pb/kubernetesv1parses each covered golden withDiscardUnknownoff,then walks the golden JSON beside the parsed message and fails on any key whose
value did not survive as a set field. The check is not vacuous:
A third test logs the nineteen uncovered kinds, so the gap is a number in test
output rather than an assumption.
buf lintandbuf breakingagainstmainrun in CI. Verified against abaseline branch:
The breaking step is guarded on
maincarrying a schema, because on this PR itdoes not yet.
Verification
From a clean
git archive HEADextraction:Notes for review
backend-requirements.mdis untouched, and not by preference.docs/prose_test.gocaps it at 733 lines and it sits at exactly 733, so oneadded line fails the build. The obligation an ingest implementer needs — read
an absent counter as unreported, never as zero — lands with the transport
that carries it. Stating it now is a ceiling raise, which is deliberately a
decision in its own diff.
bufis not a Go tool. It would pull in a large tree; CI installs it viabufbuild/buf-setup-actionandmake protoexpects it on PATH.protoc-gen-gois wired as a Go tool — the module was already a dependency,so
go.modgains one line andgo.sumnothing. Generated Go is committed, sogo buildandgo testneed neither.docs/security.mdis untouched: nothing about what is collected, stored ortransmitted moved.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KeZECJXTDHL6Nts95eKMJA