Skip to content

feat(generator): expose __TEND_DELETE__ sentinel for RFC 7396 deletes - #451

Merged
max-sixty merged 1 commit into
mainfrom
toml
May 13, 2026
Merged

max-sixty merged 1 commit into
mainfrom
toml

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Adds "__TEND_DELETE__" as a sentinel for RFC 7396's null-deletes-key semantic, which was unreachable from TOML before. A pre-pass in _apply_extras walks workflow_extra and per-job overrides, swapping the sentinel for None before the existing _deep_merge runs — the delete branch then does the work.

Motivating case: a scheduled workflow that should be workflow_dispatch-only. The user can now drop just on.schedule instead of replacing the whole on: block:

[workflows.nightly.workflow_extra.on]
schedule = "__TEND_DELETE__"

Same shape covers the issue author's case (narrowing on.issues on tend-mention) and any other generator-injected key.

Lists are passed through unchanged — JSON Merge Patch doesn't define array element deletion, and the sentinel inherits that limitation.

A parallel PR exploring the alternative (switch the config format to YAML so null is native) will appear as a separate PR; #439 has both for comparison.

Closes #439

Thanks to @jrdncstr for reporting in #439.

TOML has no `null` literal, so the delete branch in `_deep_merge` (None
pops the key) was unreachable from `.config/tend.toml`. A pre-pass swaps
the sentinel string for None before the existing merge runs.

Closes #439

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit a34338b into main May 13, 2026
6 checks passed
@max-sixty
max-sixty deleted the toml branch May 13, 2026 17:31
max-sixty added a commit that referenced this pull request May 14, 2026
## 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:

```yaml
workflows:
  nightly:
    workflow_extra:
      on:
        schedule: null   # drop the cron, keep workflow_dispatch
```

The parser is `ruamel.yaml` (YAML 1.2), not PyYAML — so the usual YAML
1.1 footguns don't bite the config surface:

- Unquoted `on:` stays the string `"on"`, not boolean True.
- Norway problem doesn't apply: `yes`/`no`/`on`/`off` stay strings; only
`true`/`false` are booleans.

## Scope

- `Config.load` reads `.config/tend.yaml` via ruamel.yaml's safe loader.
- `tend init` auto-migrates a legacy `.config/tend.toml` (verifies
parsed structures match via dict equality before swapping). `tend check`
stays read-only and points users at `tend init` if only `.toml` is
present.
- Migrated `docs/tend.example.toml` → `docs/tend.example.yaml` with a
new "delete a generated key with null" example.
- Removed the `__TEND_DELETE__` sentinel + its three tests; added
replacement tests for YAML-native `null` (top-level, nested, missing-key
noop), unquoted `on:` round-trip as string, and Norway-problem strings
(`NO`, `off`) surviving uncoerced.
- `_apply_extras` uses `ruamel.yaml` with `typ="rt"` to preserve
insertion-order on regen (safe mode sorts mapping keys, which would
churn every diff). Flow-mode scalar dumper stays on `typ="safe"`.
- Migrated every test, tend's own `.config/tend.yaml`, install-tend,
review-reviewers, review-runs, running-tend, CLAUDE.md, README.md,
action.yaml, TODO.md. `bot_name` scrapers in cross-repo lookups now use
`yq '.bot_name // ""'` instead of sed.

## Tradeoffs vs the sentinel

- (+) Native `null` instead of a magic string.
- (+) Single config format aligned with the generated workflows.
- (+) YAML 1.2 via ruamel.yaml — no Norway problem, no `on:` → True
trap.
- (−) Breaking change for every consumer: `.config/tend.toml` no longer
parses; consumers must rename and translate. Auto-migration in `tend
init` softens this — nightly regen handles it for free — but `tend
check` invocations between bump and nightly hard-error with the
migration hint.
- (−) Extra runtime dep: `ruamel.yaml` (pure-Python, ~1.3 MB installed)
replacing `pyyaml` (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

- [x] `cd generator && uv run pytest` — 203 passed
- [x] `pre-commit run --all-files` — all hooks pass
- [x] `uv run python -m tend init` round-trips `.config/tend.yaml` into
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)
- [x] Delete-key example in `docs/tend.example.yaml` produces the
expected merged workflow — covered by `test_null_drops_top_level_key`
- [x] Norway-problem strings survive — covered by
`test_norway_problem_string_not_coerced`
- [x] Auto-migration verifies parsed structures match before swapping —
covered by `test_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](https://claude.com/claude-code)

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: tend-agent <[email protected]>
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.

feat(generator): expose TOML-expressible delete-key sentinel for workflow_extra / _deep_merge

2 participants