Skip to content

test(contract): a promise that leaves or changes without a version bump fails a test, checked_by lists every test that holds an entry, and the names a chart passes are held to its render (#1541, #1547, #1548) - #1566

Merged
bpalermo merged 28 commits into
mainfrom
ci/harness-contract-followups
Oct 10, 2026

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Three follow-ups to the external-harness contract (#1535). Base: 26a90582.

This pull request does not bump the contract's version. It adds checks; no promise changes. main moved the contract to version 2 while this was open (#1508), so the lock here is the one for version 2: on merging main, TestVersionBump failed and printed it, as the README prescribes. Only its version line differs from the lock for version 1, because that bump was a change of meaning written in notes, which the lock cannot see; the README now says so plainly and the "Versions" table is the one place a bump is recorded. The contract file changes in three ways, none of them a change of meaning: checked_by becomes a list where several tests hold an entry, the CSIDriver object takes its name from the csi.driver entry instead of repeating the string, and a few things more are held (the prober container's arguments and environment, the uds-csi plugin directory, the selectors of the controller's pod webhooks): new promises, which need no bump.

#1541: a promise that leaves or changes without a version bump fails a test

test/harnesscontract/external-harness.lock.yaml holds one line per promise of the current version: "<entry id> <key> [<member>]" and a digest of what is promised there. TestVersionBump (in //test/harnesscontract:harnesscontract_test) compares it with the contract.

The rule it encodes (README, "The rule", which now states the cases it was silent on):

Change Result
An entry removed or renamed; a value changed; a value added to or removed from a closed set; a label added to or removed from a metric; a log field removed, renamed or changed to or from a time; another roll strategy; a render made with other set pairs, release or namespace fails, names the entry and the key, asks for the bump. It prints no digest, so there is nothing to paste that passes without the bump
version bumped by one fails once more and prints the whole lock for the new version, to replace the file with
version bumped by more than one, or lowered fails
A new entry, a new object of a render, a new field of a log line, a key an entry did not have, one more pod label, container, or thing a container is held to fails and prints the line to add to the lock; no bump
notes, a comment, checked_by, the order of a list passes

How the unit is chosen: every key of an entry is one promise, so adding to its value changes it (a closed set, a metric's labels, the set pairs). Where the contract itself says a set is open (log fields, pod labels, containers, what a container is held to), each member is its own promise, so a new member is an addition. A key added to an entry type in the future is a promise unless it is added to notPromised; TestEveryKeyIsAPromise fails otherwise.

The base comparison. That test reads both files from one checkout, so it cannot see a change made to both: an entry removed together with its lock lines, or a promise changed with its digest recomputed. scripts/check-harness-contract-bump.sh covers that. A new step of the chart-version-bump job runs it with the pull request's base sha: every promise line of the lock at the base is still there, unchanged, or version is higher than at the base. //scripts:check_harness_contract_bump_test tests it with a fake git show and fails if ci.yaml stops running it against the base. This is the one workflow edit, a step added to an existing job.

What it does not do. A promise made only in prose (notes, a comment) has no line. And on this pull request the base comparison has nothing to compare, because the base has no lock yet: its first real run is the next pull request that touches the contract.

The lock's form, and ties. TestVersionBump also requires the lock to be byte for byte the file the test prints (header, one promise to a line, sorted), because the base comparison reads it line by line: the same promises as an inline map would read there as none. A promise made through a tie to another entry (name_from, args, resource_attributes, code_resource_attributes, host_paths, webhooks) is named and digested in the lock by what the tie comes to, never by the entry's id, so moving a tie to another entry that says the same is no bump. Which entry a tie names is held separately: TestTies compares the contract's ties with a list in contract_test.go, in both directions, so name_from: csi.driver cannot become the literal unnoticed (nothing else failed when it did).

#1547: checked_by lists every test that holds an entry

  • checked_by is one label or a list. review-only cannot be combined with a test, and a test cannot be named twice.
  • Each test an entry names must list it: Contract.Owns for a Go test, ids for a chart test. helm_contract_test now passes the checker its own label, and the checker fails when a render of its chart does not name it, or an entry names it that its chart's renders give it nothing to compare.
  • The contract does not load unless the two views agree: an entry a render refers to names that render's chart test, and an entry that names a chart test is referred to by one of that test's renders.
  • resource.node now lists its three tests; mesh.default_domain, csi.driver, port.outbound_http and resource.service_name.prober list the chart test that compares them with a render beside the test that compares them with the code.

#1548: audit of the entries compared with a Go constant only

"Tied" means the entry is compared with helm template of the packaged chart at the chart's defaults, in both directions (seen red for the chart edited alone and for the contract edited alone). No file under charts/ changes.

Entry Can a chart change what is deployed? Result
port.outbound_http (18081) Not the port a proxy listens on: a constant in the agent, the CNI plugin and the registrar, with no flag. The prober chart's probe.egress (default 127.0.0.1:18081) decides which port a deployed prober dials Tied now: the prober's rendered --egress is 127.0.0.1:<port.outbound_http>
port.outbound_l4 (18082) No. No flag, and no chart value or template of a mesh component spells it Not applicable
mesh.default_domain Yes. meshDomain of the aether chart is --mesh-domain of the agent and the mesh-DNS daemon (tied by #1535), and of the controller, the registrar and the edge agent. probe.meshDomain of the prober chart is --mesh-domain of the prober Tied now for the prober. The controller, registrar and edge agent take the same template expression but are not containers the contract lists: not tied (item 2 under "Not done")
csi.driver No value. The node plugin takes it from the constant (no flag). The aether chart writes it again as the name of the CSIDriver object Tied now: the object has name_from: csi.driver, and the uds-csi DaemonSet must have a hostPath volume of the path <its --kubelet-root>/plugins/<csi.driver> (the kubelet plugin directory, a literal in the template) that the uds-csi container mounts at that same path. Not tied: the volume of the udsecho pods (below)
resource.service_name.prober No chart value today, but the environment a chart renders can replace what the code sets. OTEL_SERVICE_NAME is an explicit override. service.name= in OTEL_RESOURCE_ATTRIBUTES also renamed the prober when this audit was made (measured in newResource); #1562 has since stopped that, so that half of the rule is now belt and braces Tied now: the rendered prober container is given neither (code_resource_attributes)
pod.label.managed No value. A literal in the selectors of the controller's two pod webhooks, which ignore failures, and on the pods of the prober and udsecho charts Tied now for the webhooks: the namespace selector of the one and the object selector of the other must be exactly the entry's value with "true", and nothing else, in the aether chart's render. The pods' own labels: below
pod.annotation.upstreams, pod.annotation.endpoint_port, pod.annotation.endpoint_uds_socket No value changes the key. Literals on the pods of the prober and udsecho charts, which use the annotations as any workload does Not applicable to what the mesh does with them; the copies are item 1 under "Not done"
pod.annotation.endpoint_ports, pod.annotation.endpoint_protocol, pod.annotation.capture_exclude_outbound_ports, service.label.mesh_service No. No chart template renders them Not applicable
log_lines cap_per_window, window_seconds No. Constants of the prober, no flag Not applicable
envoy_stats stat prefix No. A literal of the listener generator Not applicable
metrics Compared with the real instruments, not with a constant. The names and labels are literals in code and the charts pass the exporter only an endpoint (read from the templates, not compared with a render) Not applicable

Evidence

bazel test //test/harnesscontract/... //scripts/... //e2e/... //bazel/actionlint:all, the lint build over //test/harnesscontract/... and //scripts/... with --@aspect_rules_lint//lint:fail_on_violation, make actionlint, scripts/check-shell-lint.sh and make format-check pass.

Seen red on the real files, each change made alone and reverted:

Mutation check: 132 single-line mutations of the new code (118 in Go, 14 in the script), plus the digest redaction seen red before its fix, each run alone and reverted; each fails a named test. Two of them first failed to compile, which is no kill; they were rewritten and then failed a test.

Not done

  1. Not tied by the contract: the names the prober and udsecho charts put on their own pods (the mesh label, the annotations, the CSI driver of a volume). Since fix(chart): the node proxy's Envoy stats name their service, and the prober and udsecho charts' mesh names are held to the Go constants (#1561, #1589, #1582, #1588) #1595 the charts' own helm_mesh_names_test targets hold them to the Go constants, so nothing is left to do here.
  2. Not tied: --mesh-domain of the controller, the registrar and the edge agent. Tying them means listing those containers in the contract, which is a new promise about names no harness addresses.

Closes #1541
Closes #1547
Closes #1548

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…mp fails a test, checked_by lists every test that holds an entry, and the names a chart passes are held to its render (#1541, #1547, #1548)

Three follow-ups to the external-harness contract (#1535). The contract's
version stays 1: checks are added, no promise changes.

#1541. external-harness.lock.yaml holds one line per promise of the current
version: "<entry id> <key> [<member>]" and a digest. TestVersionBump compares
it with the contract. A line that is gone or whose digest differs fails and
asks for the bump, without printing a digest; with the version bumped by one
the test prints the whole new lock; a promise the contract gains needs a line
and no bump, and the test prints the line. Prose (notes, comments), checked_by
and the order of a list are not promises. A key added to an entry type later
is a promise by default.

#1547. checked_by is one label or a list. Every test it names lists the entry
among the ids it holds: Contract.Owns for a Go test, `ids` for a chart test,
which is now told its own label. The contract does not load unless an entry a
render refers to names that render's chart test, and an entry that names a
chart test is referred to by one of its renders.

#1548. Audit of the entries compared with a Go constant only. Tied to the
render: the CSIDriver object's name (name_from: csi.driver), the prober
chart's default --mesh-domain and --egress (the outbound port, through a
pattern), and the prober's service.name, which the OpenTelemetry SDK lets the
environment override: the rendered container must be given neither
service.name in OTEL_RESOURCE_ATTRIBUTES nor OTEL_SERVICE_NAME. No chart file
changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 9, 2026 18:16
@bpalermo bpalermo added the ci CI workflows, test selection and build tooling label Oct 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Base-aware deletion enforcement and several chart-drift paths remain unresolved.

5 open findings
What changed in this PR

Adds stronger test-only enforcement for the external-harness contract.

Changes:

  • Adds a promise lock and version-bump checks.
  • Supports multiple checked_by tests per entry.
  • Extends chart checks for referenced names, arguments, and resource attributes.
File Description
AGENTS.md Documents contract-lock workflow.
docs/​runbook.md Updates contract guidance.
test/​harnesscontract/​BUILD.bazel Registers lock tests and chart ties.
test/​harnesscontract/​README.md Documents promise and chart rules.
test/​harnesscontract/​chart.go Extends rendered-chart validation.
test/​harnesscontract/​chart_test.go Tests new chart ties.
test/​harnesscontract/​contract.go Adds multi-test ownership.
test/​harnesscontract/​contract_test.go Tests ownership validation.
test/​harnesscontract/​defs.bzl Passes chart-test labels to checker.
test/​harnesscontract/​external-harness.lock.yaml Records version-one promises.
test/​harnesscontract/​external-harness.yaml Adds chart-backed contract ties.
test/​harnesscontract/​promises.go Implements promise locking.
test/​harnesscontract/​promises_test.go Tests lock semantics.
test/​harnesscontract/​testing.go Handles shared ownership.
test/​harnesscontract/​cmd/​chartcheck/​main.go Validates chart-test ownership.
test/​harnesscontract/​cmd/​chartcheck/​main_test.go Tests checker ownership behavior.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/harnesscontract/README.md Resolved
Comment thread test/harnesscontract/promises.go Resolved
Comment thread test/harnesscontract/chart.go Resolved
Comment thread test/harnesscontract/README.md Resolved
…d the webhook selectors, the plugin directory and an unreadable environment are held too

Review round 1.

- scripts/check-harness-contract-bump.sh compares the lock with the one at
  the pull request's base (a step of the chart-version-bump job): a promise
  removed together with its lock line, or changed with its digest recomputed,
  passes the hermetic test and fails here unless the version is higher than
  at the base. Hermetic test with a fake `git show`; it also holds ci.yaml to
  running the script with the base sha.
- pod.label.managed is held to the label the controller's two pod webhooks
  select by in the aether chart's render. The configuration has no name in
  the contract: it is the render's one object of its kind.
- csi.driver is held to the kubelet plugin directory the uds-csi DaemonSet
  mounts from the host as well as to the CSIDriver object's name.
- A container whose code sets a resource attribute fails closed when its
  environment cannot be read: OTEL_RESOURCE_ATTRIBUTES from valueFrom, or
  any envFrom.
- README: which changes the hermetic test cannot see, said exactly.

No chart file changes; the contract's version stays 1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 9, 2026 19:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread test/harnesscontract/chart.go Resolved
Comment thread scripts/check-harness-contract-bump.sh Resolved
… key, and the base comparison refuses a bump by more than one

Review round 2.

- A webhook selector on the mesh label with a value other than "true"
  matches nothing the mesh manages: the check compares key and value.
- With the contract and the lock moved together, only the base can tell a
  bump by two from a bump by one: check-harness-contract-bump.sh refuses it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 9, 2026 19:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Webhook validation does not preserve the required distinction between namespace and object selectors.

3 open findings

🧠 Review effort: Balanced

Comment thread test/harnesscontract/chart.go Resolved
…t to either

Review round 3. The namespace selector and the object selector of a webhook
are not interchangeable: one selects the namespaces whose pods the webhook
sees, the other the pods. `webhooks` now says which of the two selects by the
entry, and the check reads that one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 9, 2026 19:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The chart checker still permits restrictive webhook selectors and disconnected CSI socket mounts to pass.

2 open findings
3 resolved since last review

🧠 Review effort: Balanced

Comment thread test/harnesscontract/chart.go Resolved
Comment thread test/harnesscontract/chart.go Resolved
…e plugin directory is held to its mount as well as its host path

Review round 4.

- Kubernetes requires everything a selector lists. A second matchLabels pair
  or any matchExpressions beside the mesh label narrows what a fail-open
  webhook sees, down to nothing: the selector the contract names must be the
  one pair and nothing else.
- The uds-csi plugin writes its socket under the directory named after the
  driver, in its own filesystem. The hostPath volume that ends with that
  directory must be mounted by a container (not an init container) at a path
  that ends the same way.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 9, 2026 20:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The base comparison currently passes when git show fails for reasons other than a genuinely absent lock.

2 open findings
2 resolved since last review

🧠 Review effort: Balanced

Comment thread scripts/check-harness-contract-bump.sh Resolved
Comment thread test/harnesscontract/README.md Resolved
…se cannot be read

Review round 5. `git show` failing for any reason read as "the base has no
lock" and passed, so a base the checkout lacks (a shallow clone) switched the
check off. The base must be a commit that is here; only a base that is here
and has no lock at that path has nothing to compare; a lock that is there and
cannot be read fails. README: one sentence completed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 9, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Chart validation can still miss webhook narrowing and CSI mounts moved away from the plugin container.

2 open findings
2 resolved since last review

🧠 Review effort: Balanced

Comment thread test/harnesscontract/chart.go Resolved
Comment thread test/harnesscontract/chart.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The base-lock shell parser can ignore valid YAML formatting and leave future promise removals unenforced.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread scripts/check-harness-contract-bump.sh Resolved
…s the form the base comparison reads

Review round 12. The base comparison reads the lock one line at a time; the
hermetic test parsed it as YAML. The same promises as an inline map, or
indented otherwise, passed the test and would have read at a later pull
request's base as no promise at all. TestVersionBump now also requires the
file to be byte for byte the one Contract.Lock writes, and prints it when it
is not.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 9, 2026 23:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The contract, lock, chart checks, CI enforcement, and regression coverage are consistent with the stated requirements.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 9, 2026 23:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Promise-name construction is ambiguous, allowing some semantic changes to bypass version-bump enforcement.

0 open findings

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 9, 2026 23:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Host-path promise keys currently treat a tie-only change as a breaking contract change.

1 open finding

🧠 Review effort: Balanced

Comment thread test/harnesscontract/promises.go Resolved
…what the tie comes to, not by the entry it names

Review round 13. The lock line of a host path was named by its pattern, and
those of a container's resource attributes by the id of the entry: moving the
tie to another entry that says the same removed a line and asked for a
version bump, though nothing a harness reads had changed and TestTies already
holds which entry a tie names. A host path is now named by the path it comes
to and an attribute by its key, as names, arguments and webhook labels
already were. The same tie coming to something else is still a bump. The
lock is regenerated: four lines renamed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 10, 2026 01:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The contract, chart, lock, CI, and regression-test changes are internally consistent with no unresolved defects found.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

bpalermo and others added 2 commits October 9, 2026 22:43
…E says who holds the charts' own mesh names

main added `agent.xds_acked_tls_clusters_unknown` to the contract. A new
entry needs no version bump and a line in the lock per promise: TestVersionBump
failed on the merge and printed the four lines, which are added. That failure
was also the first on a pull request's merge ref: `test` went red on the
previous head for exactly this reason.

main also holds the prober and udsecho charts' mesh names to the Go constants
(helm_mesh_names_test, #1595), so the README no longer lists them as
compared with nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 10, 2026 01:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The test-only contract enforcement is internally consistent, extensively covered, and introduces no unresolved correctness issues.

0 open findings

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 10, 2026 02:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The contract, lock, chart checks, CI gate, and comprehensive tests are consistent with the stated requirements.

0 open findings

🧠 Review effort: Balanced

@bpalermo
bpalermo merged commit 9359b9f into main Oct 10, 2026
31 checks passed
@bpalermo
bpalermo deleted the ci/harness-contract-followups branch October 10, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI workflows, test selection and build tooling

Projects

None yet

2 participants