Repository navigation
feat(generator): switch config surface from TOML to YAML - #454
Merged
Merged
Conversation
Move `.config/tend.toml` → `.config/tend.yaml`. YAML has a native `null` literal, so RFC 7396 Merge Patch's delete-key semantic works directly in `workflow_extra` / `jobs.<name>` overrides — no string sentinel needed. Alternative to the `"__TEND_DELETE__"` sentinel landed in #451. Open for comparison; #439 has both. Changes: - `tend.config.Config.load` reads `.config/tend.yaml` via `yaml.safe_load`. - Hard error when `.config/tend.toml` exists but `.yaml` doesn't — points the user to migrate (no auto-detection or silent fallback). - `docs/tend.example.toml` → `docs/tend.example.yaml`, with a new "delete a generated key with null" example and a YAML quoting tip covering the Norway problem (`yes`/`no`/`on`/`off` → boolean). - `_apply_extras` normalizes a stray `True` key in user-supplied `workflow_extra` back to `"on"` so unquoted `on:` in an override merges into the workflow's existing trigger block — the same YAML 1.1 trap that already bit the generated workflows. - Remove the `__TEND_DELETE__` sentinel and its tests; replaced by three new tests that exercise YAML-native `null` at the top level, inside a nested job override, and on a missing key (no-op per RFC 7396). - Migrate all generator tests, tend's own `.config/tend.yaml`, the install-tend skill, review-reviewers, review-runs, running-tend, DESIGN.md, README.md, CLAUDE.md, and action.yaml. `bot_name` scrapers in cross-repo lookups now match `bot_name:` instead of `bot_name =`. Tradeoffs vs the sentinel approach: - (+) Native `null` instead of a magic string. - (+) Single config format aligned with the generated workflows. - (−) Breaking change for every consumer: `.config/tend.toml` no longer parses; consumers must rename and translate (one-off). - (−) YAML 1.1 footguns surface: unquoted `on:` parses as boolean True, and the Norway problem (`NO`/`yes`/`on`) coerces string values unexpectedly. Mitigated where it bites the generator; documented in `docs/tend.example.yaml` for user-facing values. Co-Authored-By: Claude <[email protected]>
tend-agent
approved these changes
May 13, 2026
Switch the runtime dep from `pyyaml` to `ruamel.yaml>=0.18` so the config surface is YAML 1.2. Drops two PyYAML traps: - Unquoted `on:` parses as the string `"on"`, not boolean True. The `True`-key dance in `_apply_extras` (both for the loaded workflow and for `workflow_extra` overrides) is gone. - Norway problem: `yes`/`no`/`on`/`off` stay strings. The quoting tip in `docs/tend.example.yaml` is no longer needed; replaced with a one-line "parsed under YAML 1.2" note. New test pins the behavior on a prompt/env containing `NO` and `off`. Block-mode dumper uses `typ="rt"` to preserve insertion order; safe mode sorts mapping keys alphabetically, which would churn every regen diff. Flow-mode dumper for inline scalars stays on `typ="safe"`. Tests import `from tests import _yaml as yaml`, a tiny shim that wraps ruamel.yaml with a pyyaml-style `safe_load` / `safe_dump` surface, so the existing `yaml.safe_load(text)` call sites keep working. Co-Authored-By: Claude <[email protected]>
tend-agent
reviewed
May 13, 2026
tend-agent
left a comment
Collaborator
There was a problem hiding this comment.
One stale .config/tend.toml reference outside the diff: generator/src/tend/checks.py:340 is the repo-secret-allowlist failure message that points the user at secrets.allowed in .config/tend.toml — a file that no longer exists after this PR. Happy to push a one-line fix if you want.
One-shot CLI command for adopters bumping past the config format cutover. Reads `.config/tend.toml` via stdlib `tomllib`, writes equivalent YAML, verifies the parsed structures match, then deletes the TOML. Aborts (leaving both files untouched) if `.config/tend.yaml` already exists or if the round-trip parse doesn't compare equal — which would mean the migration lost or changed data. Equivalence check uses dict equality on the parsed structures. Since `Config.load` operates on the parsed dict (not the file format), equal dicts guarantee identical `Config`, and therefore byte-identical generated workflows. The `test_workflows_from_migrated_config_match_ workflows_built_from_toml_dict` test pins that property end-to-end. The nightly skill now invokes `uvx tend@latest migrate` before `uvx tend@latest init` when only `.config/tend.toml` is present, so the upgrade happens automatically on the next scheduled regen. Git status / add scope broadened to include `.config/` so the migration and the regenerated workflows ship in the same PR. `Config.load`'s error when only `.toml` is present now points users at the command. Replaced the brittle bot_name sed scrapers in `running-tend` and `review-reviewers` with `yq '.bot_name // ""'` — handles missing keys via jq's alternative operator and is robust to quoting/whitespace variations. Co-Authored-By: Claude <[email protected]>
tend-agent
approved these changes
May 13, 2026
`tend migrate` was a separate CLI command for the one-shot TOML→YAML upgrade. With auto-migration in `init`, the standalone command is redundant — drop it. `tend init` now checks for a legacy `.config/tend.toml` before loading the config. If only the TOML is present, it runs the verified migration (parsed-TOML dict must equal parsed-back-YAML dict) and continues into workflow regeneration. If both files exist, the YAML is canonical and the TOML is left alone for the operator to review and delete. `tend check` stays read-only — it errors when only `.toml` is present and points the user at `tend init`, which handles the upgrade. The nightly skill drops its explicit `tend migrate` step; `init` does it transparently. `migrate.py` stays as a helper module called from `init` (kept separate because tomllib should not leak into the steady- state config code path). Co-Authored-By: Claude <[email protected]>
# Conflicts: # DESIGN.md
tend-agent
approved these changes
May 13, 2026
Four references to the old config filename survived the YAML migration: - README.md:51 linked to docs/tend.example.toml, which was renamed to .yaml — the link 404'd - generator/src/tend/checks.py:340 emitted a `tend check` error message pointing users at the wrong filename - TODO.md:41,62 referenced .toml in unrelated forward-looking sections Caught by the merge-review pass on #454. Co-Authored-By: Claude <[email protected]>
…erge Three round-trip issues in the override path that produced churny diffs on every regen for consumers using `workflow_extra` or `jobs.<name>`: - `_deep_merge` did `result = dict(base)`, a shallow copy that discards ruamel.yaml's `CommentedMap` style metadata. Switch to `copy.deepcopy` so key order, comments, and sequence indentation survive the merge. - `_YAML_BLOCK` ran on ruamel's default indent (`mapping=2, sequence=2, offset=0`), emitting `- uses:` at the same column as `steps:`. The hand-rendered templates use 6-space list indent. Set `indent(mapping=2, sequence=4, offset=2)` so applied workflows match the no-extras shape. - `_apply_extras` prepended HEADER to the dumped output, but `typ="rt"` loads preserve the HEADER comment block from `wf.content` and emit it again on dump — producing a duplicate header. Drop the manual prepend; let ruamel round-trip the comment block. Also set `preserve_quotes = True` so explicit double-quoted scalars (`cron: "17 6 * * *"`) round-trip with their quotes intact. Add `test_extras_apply_path_regtest` to snapshot the `_apply_extras` path end-to-end — the existing regtests only covered no-extras workflows, so all three drift modes above were invisible to the suite. Caught by the second-pass merge review on #454. Co-Authored-By: Claude <[email protected]>
tend-agent
approved these changes
May 13, 2026
Owner
Author
|
@nedtwigg any thoughts? this solves the null problem, albeit in an obtuse way.... |
|
I don't have any preference between TOML and YAML. I haven't adopted yet, hoping to do so sometime between today and Monday, I'll wait for this to settle first :) |
Owner
Author
|
@tend-agent resolve conflicts |
# Conflicts: # CLAUDE.md
tend-agent
approved these changes
May 14, 2026
4 of 6 tasks
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
Move
.config/tend.toml→.config/tend.yaml. Alternative to the"__TEND_DELETE__"string sentinel landed in #451 — same goal (reach RFC 7396's null-deletes-key branch from user config), different mechanism. #439 has both for comparison.YAML has a native
null, so the delete-key example becomes:The parser is
ruamel.yaml(YAML 1.2), not PyYAML — so the usual YAML 1.1 footguns don't bite the config surface:on:stays the string"on", not boolean True.yes/no/on/offstay strings; onlytrue/falseare booleans.Scope
Config.loadreads.config/tend.yamlvia ruamel.yaml's safe loader.tend initauto-migrates a legacy.config/tend.toml(verifies parsed structures match via dict equality before swapping).tend checkstays read-only and points users attend initif only.tomlis present.docs/tend.example.toml→docs/tend.example.yamlwith a new "delete a generated key with null" example.__TEND_DELETE__sentinel + its three tests; added replacement tests for YAML-nativenull(top-level, nested, missing-key noop), unquotedon:round-trip as string, and Norway-problem strings (NO,off) surviving uncoerced._apply_extrasusesruamel.yamlwithtyp="rt"to preserve insertion-order on regen (safe mode sorts mapping keys, which would churn every diff). Flow-mode scalar dumper stays ontyp="safe"..config/tend.yaml, install-tend, review-reviewers, review-runs, running-tend, CLAUDE.md, README.md, action.yaml, TODO.md.bot_namescrapers in cross-repo lookups now useyq '.bot_name // ""'instead of sed.Tradeoffs vs the sentinel
nullinstead of a magic string.on:→ True trap..config/tend.tomlno longer parses; consumers must rename and translate. Auto-migration intend initsoftens this — nightly regen handles it for free — buttend checkinvocations between bump and nightly hard-error with the migration hint.ruamel.yaml(pure-Python, ~1.3 MB installed) replacingpyyaml(C-extension, ~750 KB installed).The sentinel approach (#451) keeps TOML and avoids both the breaking change and the new dep at the cost of a magic string in config. Pick your poison.
Test plan
cd generator && uv run pytest— 203 passedpre-commit run --all-files— all hooks passuv run python -m tend initround-trips.config/tend.yamlinto the existing.github/workflows/files (no diff outside pre-existing drift in tend-mention.yaml and the v0.0.17 → v0.0.18 header stamp from the release on main)docs/tend.example.yamlproduces the expected merged workflow — covered bytest_null_drops_top_level_keytest_norway_problem_string_not_coercedtest_init_auto_migrates_legacy_toml,test_init_does_not_touch_yaml_when_both_exist,test_workflows_from_migrated_config_match_workflows_built_from_toml_dict🤖 Generated with Claude Code