Skip to content

Write podbench's own comments once, not once per run - #201

Merged
gilesknap merged 1 commit into
mainfrom
fix/comments-duplicate-on-a-second-merge
Aug 23, 2026
Merged

gilesknap merged 1 commit into
mainfrom
fix/comments-duplicate-on-a-second-merge

Conversation

@gilesknap

Copy link
Copy Markdown
Member

Found by running the Phase 4 command by hand against p47 the day after Phase 5 —
over a values file that had already been through it once, which is the ordinary
case after a chart bump or when you just want to see what is deployed.

The values were idempotent. The comments were not:

      # Declared and deliberately *not mounted* by the application. ...
      # Declared and deliberately *not mounted* by the application. ...
    - name: podbench-home

test_running_the_merge_twice_changes_nothing compared
yaml.safe_load(once) == yaml.safe_load(twice) and passed the whole time,
because parsed values cannot see a comment. It now compares the text, and
runs a third pass as well.

Why the obvious fix is wrong

Neither end of the round trip can be asked whether a comment is already present:

  • ruamel attaches a comment it parsed to the node before it, so the key a
    comment sits above has nothing on it to find — ca.items is empty there.
  • replacing a key's value drops a comment that had been parsed onto that
    value, so a comment present in the input can be absent from the output.

That second half is not hypothetical. Checking the input document alone fixed
the duplication and silently lost the fsGroup comment instead — it had been
parsed onto the supervisor args, which are replaced on every run.

So the comments are deferred, the tree is rendered once, and each is written
only where that render did not already carry it. Converges by construction: a
comment that survived is left alone, one that was destroyed is rewritten, and
either way it appears exactly once.

Verified

Three passes deep over the real services/bl47p-ea-fastcs-01/values.yaml on
p47-beamline, reading the live pod each time: byte-identical.

1647 tests pass, pyright clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_015LEmzFsLaoa5zWeQvdN1Xe

Found by running `--print-values --values` by hand against p47 the day after
Phase 5, over a values file that had already been through it. The values were
idempotent; the comments were not. Each of podbench's own grew another copy of
itself on every run:

      # Declared and deliberately *not mounted* by the application. ...
      # Declared and deliberately *not mounted* by the application. ...
    - name: podbench-home

`test_running_the_merge_twice_changes_nothing` compared `yaml.safe_load(once)`
with `yaml.safe_load(twice)` and passed throughout, because parsed values cannot
see a comment. It now compares the text, and a third pass as well.

Neither end of the round trip can be asked whether a comment is already there.
ruamel attaches a comment it parsed to the node *before* it, so the key a
comment sits above has nothing on it to find - and replacing a key's value drops
a comment parsed onto that value, so a comment in the input can be missing from
the output. That second half is not hypothetical: checking the input alone fixed
the duplication and silently lost the fsGroup comment instead, because the
supervisor `args` it had been parsed onto are replaced on every run.

So the comments are deferred, the tree is rendered once, and each is written
only where the render did not already carry it. Verified three passes deep
against the real services/bl47p-ea-fastcs-01/values.yaml: byte-identical.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015LEmzFsLaoa5zWeQvdN1Xe
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 16d1d46c-0c22-4fbb-a688-44c88a32d511

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gilesknap
gilesknap merged commit 9f8abdb into main Aug 23, 2026
30 checks passed
@gilesknap
gilesknap deleted the fix/comments-duplicate-on-a-second-merge branch August 23, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant