fix(engine): keep one repository's failures to itself and key catalog views by registry entries

SW
5h ago
+512-71

Six fixes from the engine/update scan.

Fixes

  1. Maintenance planning errors fail only the repository. Write::maintenance turned a PlanError into the run-level Error::Invalid, so one repository's config (say a 225-character prs.branch with no updates) failed the whole batch: every repository's report row, schedule turn and public record was dropped and the server backed them all off. It now returns StepFailure::Repo, as plans() does. Only the cache error from defer_completed_refresh stays run-level. prs.branch is also capped at load. patchula_config now holds MAX_BRANCH_LEN (240, which branch_name uses), BRANCH_LABEL_ROOM (40) and MAX_BRANCH_PREFIX_LEN (200). A compile-time assert in plan.rs checks that the longest fixed label (lock-file-maintenance) plus a collision suffix fits in that room.
  2. Lockfile warnings no longer turn off cleanup. Obsolete-PR closure read repo.degraded() before lockfile generation, and cleanup read it after, so a lockfile tool's warning skipped cleanup while obsolete PRs still closed, and stale branches piled up. Lifecycle now reads degraded once, when it is prepared. Obsolete closure uses that value, and the engine's cleanup reads Lifecycle::degraded() instead of the repository's warnings at cleanup time.
  3. Catalog views are keyed by the operator registry entries. CatalogScope now carries a digest of every operator entry's scope(), computed once per engine. Adding, removing or rotating an entry misses every view read before, as the HTTP cache key does. I keyed by the whole entry set, not "the matching entry": a catalog can be built from several reads, including mirror redirects, so its matching entry can't be known before the fetch. Keying by all entries is a superset and fails closed. The cost is one catalog refetch whenever any entry changes.
  4. Fewer cache writes. Saved holds a Cow<Catalog>, so saving borrows the fetched catalog instead of deep-cloning it. Views are written through a new Cache::set_states: one writer round trip, one transaction. BranchHint and LookupHint are no longer rewritten when they equal what was read.
  5. The maintenance PR body has no empty table. The update table header is written only when the plan has changes.
  6. Case and punctuation collisions get a stable hash. Labels still shared after the manager prefix (github.com/Sirupsen/logrus and github.com/sirupsen/logrus in two go.mod files, groups Linters and linters) each take -<first 8 hex of sha256(branch identity)>. The identity depends only on the dependency or group, so names stay the same from run to run and in any order. BranchCollision now only covers a hash collision, and its text no longer suggests explicit groups.

State versions: extract/files 12, config/config-files 9, catalog/catalog-controls 10, with their rows updated in tests/state-versions.tsv.

Docs: guide/pull-requests.md (collision hash, the 200-character prefix cap, which warnings skip cleanup and obsolete closure), internals/cache.md (the catalog scope), and a schema doc line on prs.branch.

Tests

  • engine/tests/write.rs an_unnameable_maintenance_branch_fails_only_its_repository: a 225-character prefix with no updates. The run returns Ok and only the repository fails.
  • config/tests/config.rs a_branch_prefix_longer_than_the_cap_is_refused_at_load.
  • update/tests/write.rs warnings_after_preparation_leave_the_lifecycle_undegraded. Also, lookup_warnings_defer_obsolete_pr_closure now asserts degraded().
  • engine/src/catalogs/tests.rs registry_entries_key_the_views_they_may_have_read: same entry reused; a rotated or removed entry misses.
  • update/src/pr/body/tests.rs the_maintenance_body_has_no_empty_update_table.
  • update/src/plan/planning.rs names_that_differ_only_in_case_or_punctuation_take_a_stable_hash: the go.mod and group cases, checked stable across runs and input order.
  • Transcripts recorded for the new tests. actions_lock_maintenance_commits_only_the_lock was re-recorded because its PR body lost the empty table.

Ran on the VM: tests for config, cache, update, engine, cli and server, the manager and lookup corpus tests, and clippy -D warnings on the changed crates.

Follow-ups

  • Item 2 has no engine-level test: producing a real lockfile warning there needs a Cargo or partial actions-relock tool fake. The update-level test pins the invariant. The engine wiring is a single match on Lifecycle::degraded().
  • Auto-merge's policy_allows still reads repo.degraded() after lockfile generation, so a lockfile warning still blocks auto-merge. That is deliberately conservative and unchanged here.