Skip to content

feat(chart): the agent DaemonSet says which external-harness contract version its chart was packaged with, and a contract bump rolls no pod (#1544) - #1627

Merged
bpalermo merged 2 commits into
mainfrom
feat/harness-contract-version-annotation
Oct 10, 2026
Merged

bpalermo merged 2 commits into
mainfrom
feat/harness-contract-version-annotation

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Closes #1544

A harness outside this repository pins a version of test/harnesscontract/external-harness.yaml. Until now a deployed mesh could not say which one it satisfies.

The external-harness contract changed: one new entry (object.annotation.harness_contract_version) and one new key on an existing object. Both are additions, so version stays 2.

What a harness reads

kubectl -n aether-system get daemonset aether-agent \
  -o jsonpath='{.metadata.annotations.aether\.io/harness-contract-version}'
  • It identifies the contract, not the build. Charts of different versions answer the same while the contract's version stays, and it says nothing about which images run.
  • An empty answer is "not known", never a version: a chart older than 2.4.28, or one rendered from the source tree.

How the value gets there

  1. //test/harnesscontract exports external-harness.yaml to //charts/aether only.
  2. The genrule //charts/aether:harness_contract_version reads the top-level version: line into files/harness-contract-version. It fails the build unless there is exactly one such line and it holds a positive integer.
  3. Both packagings (:aether, :aether_commit) pass that file in files.
  4. The helper aether.harnessContractVersion reads it with .Files.Get, and agent-daemonset.yaml writes it as an annotation on the DaemonSet's own metadata.

There is no literal anywhere. A contract bump edits nothing under charts/.

The annotation is optional in the template. A render of the source tree (helm template charts/aether, which the conformance action and one ci.yaml step run) has no generated file and renders no annotation.

Upgrade

Chart 2.4.28 (main is at 2.4.27). Nothing to set, nothing to do before upgrading.

  • No workload rolls for this change. Every pod template is byte-identical before and after.
  • The agent DaemonSet object's metadata gains one annotation.
  • The helm.sh/chart label on each object's own metadata changes, as with every chart version.

Measured on packages built unstamped on one workstation from the base commit 9359b9f6 and from this branch, rendered with helm template and a kubeconfig that names no cluster:

Render Workloads sha256 of all pod templates, before after
:aether, controller.webhook.spire=true, edge.enabled=true 7 e2cecd325905b8a4 e2cecd325905b8a4
:aether, default values 6 173db91985a6afff 173db91985a6afff
:aether_commit, controller.webhook.spire=true, edge.enabled=true 7 e2cecd325905b8a4 e2cecd325905b8a4

The whole-render diff of the first row is 40 helm.sh/chart: aether-2.4.27 → aether-2.4.28 lines and this, on the agent DaemonSet:

 metadata:
   name: aether-agent
   namespace: aether-system
+  annotations:
+    aether.io/harness-contract-version: "2"
   labels:

The source-tree render of this branch holds no line with the key.

The two jsonpath expressions in the runbook were run over the rendered DaemonSet with kubectl 1.35.1's own printer and no cluster: the first prints 2, the second (the pod template) prints an empty line. Nothing here was run on a cluster. The runbook section "Chart 2.4.28" has the commands to run after a deploy, including reading the agent pods' controller-revision-hash before and after.

A later contract bump changes what both packagings render without a Chart.yaml bump. That is the intent. The bare <X.Y.Z> tag is already rewritten by every commit (#1588); the <X.Y.Z>-<sha> tag stays unique.

Decisions

  • Annotation, on the object. Not a label: nothing selects by a contract version, and an annotation cannot end up in a selector. Not on a pod template: a contract bump must replace no pod.
  • No render failure for a malformed file (the earlier design had one). The build step refuses to produce such a file and the contract test compares the value, so that branch of the template could only be reached, or tested, through a second hand-made package. Left out.
  • The check lives in the contract's chart test, as a new object key contract_version_annotation: <names entry>. The entry has no Go constant (only the chart writes the key), so its checked_by is //test/harnesscontract:aether_chart_test, which holds the object to: that key on its own metadata, the contract's version as a string for its value, and the key nowhere else (not a label, not on a pod template, on no other object of the render). The version it compares with is the one the contract library parses, an independent read from the genrule's.
  • Both packagings are held to the contract. helm_contract_test gains other_packagings; the aether test now renders :aether_commit too. That covers the whole contract for the per-commit package, not only the annotation.
  • A new rule, helm_pod_template_file_test, because no existing rule can render a package with a file changed or removed. It unpacks the package three times (as is, another number in the file, no file) and requires: byte-identical pod templates in all three, exactly changed_lines rendered lines following the file, and a file-less render that only loses lines. It has its own fixture chart and a self-test of six failing cases.
  • Left unchanged on purpose: the contract's version, every existing promise and lock line, every pod template.

Tests

Seen red first, against the unchanged chart:

  • //test/harnesscontract:aether_chart_test: DaemonSet/aether-agent has no annotation aether.io/harness-contract-version ... on its own metadata, for each packaging.
  • //charts/aether:aether_harness_contract_version_rolls_no_pod_test, ..._all_enabled_test, aether_commit_..._test: the render is the same with other content in files/harness-contract-version: no template reads it.
  • //charts/aether:aether_harness_contract_version_annotation_test: the pattern stops at labels:.
  • //test/harnesscontract:harnesscontract_test (TestVersionBump) printed the two lock lines to add.

Mutations, each reverted:

Mutation Fails
The annotation also on the agent pod template the three rolls_no_pod tests (a pod template changes with other content ..., workload DaemonSet/release-aether-agent) and aether_chart_test (also carries ... as an annotation of its pod template)
The build step writes another number aether_chart_test (with the value "20", and ... is at version 2), both packagings
:aether_commit without files aether_commit_..._rolls_no_pod_test and aether_chart_test
version: "2", or a second version: line, in the contract the genrule fails the build with a message naming the file

Run locally on the final tree: bazel test //charts/... //test/harnesscontract/... //test/harnesscontract:checks //bazel/helm/... (280 pass), both packagings built, bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation over the same three trees, make format-check, scripts/check-chart-version-bump.sh, scripts/check-harness-contract-bump.sh origin/main, scripts/check-shell-lint.sh, and --config=race on the two Go tests touched.

Also fixed

  • scripts/check-harness-contract-bump.sh sorted the lock's promise lines by bytes and compared them with comm in the caller's locale. Under a UTF-8 locale comm found them "not in sorted order" and reported promises as gone that were still there, so a lock that only gained lines failed the check. The script now sets LC_ALL=C for everything it runs. //scripts:check_harness_contract_bump_test gained five cases run under a UTF-8 locale over names whose byte order and locale order differ; two were red first (an added line reported as 3 broken promises, under en_US.utf8). The cases are skipped with a note on a host with no UTF-8 locale, and under C.UTF-8 alone they would not have been red.

Docs

  • docs/runbook.md: "The external-harness contract" (which contract a deployed mesh satisfies) and "Chart 2.4.28" (what an upgrade changes, what to run afterwards).
  • test/harnesscontract/README.md: where a harness reads it, the new row of the tie table, the new tie.
  • docs/configuration.md, charts/README.md (the new rule's row).

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

… version its chart was packaged with, and a contract bump rolls no pod (#1544)

A harness outside the repository pins a `version` of
test/harnesscontract/external-harness.yaml and had no way to ask a deployed
mesh which one it satisfies.

- charts/aether (2.4.28): a build step reads `version` from the contract file
  into the package (files/harness-contract-version); both packagings carry it,
  and the agent DaemonSet's own metadata renders it as the annotation
  aether.io/harness-contract-version. No literal anywhere: a contract bump
  edits nothing under charts/. A render of the source tree has no such file
  and renders no annotation.
- The annotation is on the object, never on a pod template. New rule
  helm_pod_template_file_test renders a package as it is, with another number
  in the file and without the file, and requires every pod template to be
  byte-identical.
- The key is a contract entry (object.annotation.harness_contract_version, no
  version bump), tied to the render by a new object key,
  contract_version_annotation: aether_chart_test compares the rendered
  annotation with the version the contract library loads, and now renders the
  per-commit packaging as well.

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 02:54
@bpalermo bpalermo added the chart Helm charts label Oct 10, 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.

🟢 Approval recommended

The package-derived annotation is isolated from pod templates and comprehensively covered across both chart packagings.

0 open findings

What changed in this PR

Adds a package-derived external-harness contract version annotation to the agent DaemonSet without triggering pod rollouts.

Changes:

  • Packages the contract version into both Aether chart variants.
  • Extends contract validation across all chart packagings.
  • Adds reusable no-roll testing for packaged Helm files.
File Description
test/​harnesscontract/​README.md Documents the annotation contract.
test/​harnesscontract/​promises.go Locks the annotation-key promise.
test/​harnesscontract/​promises_test.go Tests promise compatibility rules.
test/​harnesscontract/​external-harness.yaml Adds the annotation contract entry.
test/​harnesscontract/​external-harness.lock.yaml Records new additive promises.
test/​harnesscontract/​defs.bzl Supports testing multiple packagings.
test/​harnesscontract/​contract_test.go Registers the new contract tie.
test/​harnesscontract/​cmd/​chartcheck/​main.go Checks every chart packaging.
test/​harnesscontract/​cmd/​chartcheck/​main_test.go Tests multi-package checking.
test/​harnesscontract/​chart.go Validates annotation placement and value.
test/​harnesscontract/​chart_test.go Covers annotation validation cases.
test/​harnesscontract/​BUILD.bazel Exports the contract and tests both packages.
docs/​runbook.md Adds upgrade and verification guidance.
docs/​configuration.md Documents the deployed annotation.
charts/​README.md Documents the new Helm test rule.
charts/​aether/​templates/​agent-daemonset.yaml Adds the object-level annotation.
charts/​aether/​templates/​_helpers.tpl Reads the packaged contract version.
charts/​aether/​Chart.yaml Bumps chart version to 2.4.28.
charts/​aether/​BUILD.bazel Generates, packages, and tests the version file.
bazel/​helm/​testdata/​filechart/​values.yaml Defines failure-fixture switches.
bazel/​helm/​testdata/​filechart/​templates/​daemonset.yaml Exercises packaged-file behavior.
bazel/​helm/​testdata/​filechart/​files/​unread Provides an unread-file fixture.
bazel/​helm/​testdata/​filechart/​files/​stamp Provides a consumed-file fixture.
bazel/​helm/​testdata/​filechart/​Chart.yaml Defines the fixture chart.
bazel/​helm/​testdata/​filechart/​BUILD.bazel Defines passing and failing fixture targets.
bazel/​helm/​pod_template_file_test.sh Self-tests failure detection.
bazel/​helm/​defs.bzl Implements packaged-file no-roll rules.
bazel/​helm/​BUILD.bazel Registers the rule self-test.

🧠 Review effort: Balanced


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

…llation, whatever the caller's locale

scripts/check-harness-contract-bump.sh sorted the promise lines by bytes and
compared them with comm in the caller's locale. Under a UTF-8 locale comm
found them "not in sorted order" and reported promises as gone that were still
there: a lock that only gained lines failed the check. The script now sets
LC_ALL=C for everything it runs; the test runs it under a UTF-8 locale over
names whose byte order and locale order differ.

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 03:10

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

The version-only marker cannot distinguish additive contract revisions, so older packages may falsely appear compatible with newer harness expectations.

0 open findings

Previously missed (1)

In code that hasn't changed since last review

Medium severity Contract version does not change for additive compatibility changes

charts/​aether/​templates/​agent-daemonset.yaml:21

This value cannot reliably tell a harness that the deployed chart satisfies the contract it was written against. The contract’s own compatibility rules allow new entries, rendered objects, and additional promises without changing version (test/harnesscontract/README.md:55-57). After the next such addition, both an older package and the new package will advertise "2", although a harness written against the newer contract may rely on behavior the older package lacks. Please expose a monotonically changing contract revision/digest in addition to the compatibility version, or bump the advertised identifier for every additive contract change.

🧠 Review effort: Balanced

@bpalermo
bpalermo merged commit b3b4772 into main Oct 10, 2026
31 checks passed
@bpalermo
bpalermo deleted the feat/harness-contract-version-annotation branch October 10, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chart Helm charts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chart: a deployed mesh does not say which external-harness contract version it satisfies

2 participants