Repository navigation
feat(repo-ops): renumber-migration tool, gated on commands.migrationGraph - #88
Conversation
|
Deferred item (open-PR id reservation) is tracked in #89. |
|
Rebased onto main after #83 (merge-guard) merged; it was conflicting. Two text-only conflicts: the README layout tree now lists merge-guard alongside renumber-migration.sh, and in the repo-ops README the merge-guard section stays under Hooks, followed by the Tools section. No code conflicts. All validate.yml steps pass locally (hooks 190/0, renumber-migration 67/0). |
0bac55f to
e206869
Compare
…raph Re-parents a branch's migrations onto the live base head after a collision: git mv to head+1.., rewrite revision/down_revision, re-run the repo's graph check, report one verdict. Idempotent; inert when commands.migrationGraph is unset. Adds commands.migrationGraph and paths.migrations to the config schema. Claude-Session: https://claude.ai/code/session_01T7j4GUt15DJp7G9UK4tMNE
…tions, ignores comment quotes Claude-Session: https://claude.ai/code/session_01T7j4GUt15DJp7G9UK4tMNE
…res a revision Base head is read from the flat files only; a branch-added nested file is refused only when it declares a revision. Claude-Session: https://claude.ai/code/session_01T7j4GUt15DJp7G9UK4tMNE
…name or any revision assignment Claude-Session: https://claude.ai/code/session_01T7j4GUt15DJp7G9UK4tMNE
…de the merged Wait tools Claude-Session: https://claude.ai/code/session_01T7j4GUt15DJp7G9UK4tMNE
e206869 to
344a06b
Compare
|
Rebased again, onto main after #80 and #86 merged. The conflicts were text only. validate.yml now runs both the wait-tools and renumber-migration test steps. The README layout tree lists both test scripts and the scripts {wait-for-review,wait-for-checks,renumber-migration}.sh. In the repo-ops README, this PR's section follows the new Wait tools section. One extra commit renames it from "Tools" to "Migration tools" so the two H2s don't read as duplicates. All validate.yml steps pass locally (hooks 190/0, wait tools 73/0, renumber-migration 67/0). |
Human overview
Adds
renumber-migration.shto repo-ops: after a migration collision it re-parents the branch's migrations onto the live base head, re-runs the repo's graph check, and reports one verdict. It is inert in any repo that does not setcommands.migrationGraph, and it never commits or pushes. Part of P2 in the tech-lead-loop design (Q4 decided: maintainerd, gated on that key). Refs Vycari/vycari#102.Human required (optional)
.claude/maintainerd.jsonwill needcommands.migrationGraphandpaths.migrationsbefore the tool does anything there (pepper also has its ownscripts/renumber_migration.py); not part of this PR.AI reviewer
What the diff does.
plugins/repo-ops/scripts/renumber-migration.sh(new, bash 3.2, jq/git/sed only): readscommands.migrationGraph(unset/null ->not-configured, exit 0, before touching git) andpaths.migrations(no default; a set graph command without it is exit 3). Requires the base (origin/<defaultBranch>, fetched unless--no-fetch) to be an ancestor of HEAD, elserefused:behind-base: the graph check can only judge a tree that holds the base's migrations. Base head = the one revision no other names as parent (not exactly one -> refused). Branch migrations = index files absent from the base, ordered into one linear chain; renamed to head+1.. in two phases via.renumber.Nscratch names so 0172->0173 cannot clobber a not-yet-moved 0173.revision/down_revisionand the docstringRevision ID:/Revises:lines are rewritten withsed -Eto a temp file (BSD/GNU parity), then read back; a mismatch is exit 3 rather than a half-renumbered file. Changes aregit added, not committed. Then the graph check runs from the repo root.Contract mirrors wait-for-review/wait-for-checks style: verdict on line 1, exit mirrors it (0 ok, 1
graph-failed, 2refused:<reason>, 3 tool could not run, never a verdict). Verdicts are listed in the script header and the README table.Idempotence. The plan compares each file's current name and
down_revisionto the target; no difference ->up-to-date(graph check still runs). Files are read from the index, so a re-run after a staged but uncommitted renumber is alsoup-to-date. Tests cover re-run before commit, after commit, and a second renumber after main moves again.Schema.
commands.migrationGraphandpaths.migrationsadded to the canonicalconfig-schema.md(example + tables + prose) and re-vendored withsync-references.sh. No version bump:version-bump.ymldoes it on merge.Alternatives rejected. A
lib/shared with the wait tools: this branch is off main, not #86, andwait-common.shis wait-specific; the script is self-contained. Python (pepper's ownrenumber_migration.pyis): the maintainerd scripts are bash and a stranger's repo may have no Python. Auto-rebasing the branch: it would rewrite history; the tool refuses and prints the command instead. Defaultingpaths.migrationsto an Alembic path: the brief and Q4 keep layout in config.Known limits, stated plainly. (1) It only sees the base head; an id claimed by another still-open PR is invisible, so a graph check that names such a collision needs a re-run after that PR lands (pepper's tool can feed open PRs; not replicated here). (2) Numeric sequential ids and
<id>_<slug>names only; hash ids, merge migrations, multi-parent or non-linear branch chains arerefused:. (3) Stale prose references to an old id are reported, never edited. (4) A crash between the twogit mvphases leaves.renumber.Nfiles; the error text says how to recover.Where to look hardest. The chain-order loop and the two-phase rename; the
sedexpressions (anchored to line start, matching only the exact old id);refusevsdie(verdict vs tool error).Verification.
./scripts/test-renumber-migration.sh: 59 passed, 0 failed, on bash 5 and on macOS/bin/bash3.2 (real throwaway git repos, bare origin, no network).shellcheck -S warningclean on both scripts../scripts/sync-references.sh --check,python3 scripts/check-links.py,check-merge-arming.py, and the other fourtest-*.shsuites pass. Not run: against pepper's real migrations or a real Alembic.Deferred. Open-PR id reservation (limit 1), tracked under Vycari/vycari#102's tool follow-ups; no separate issue filed yet, will file one if the maintainer wants it.
Checklist (repo-specific)
./scripts/test-coverage.shand./scripts/test-profile.shpass locally./scripts/sync-references.sh --checkpasses (vendored reference docs still match canonical)python3 scripts/check-links.pypasseshttps://claude.ai/code/session_01T7j4GUt15DJp7G9UK4tMNE
The PR appears safe to merge; no new findings or outstanding previous findings remain.
Summary
Adds a config-gated migration renumbering tool that re-parents a branch’s linear migrations onto the base head, stages the result, and runs the repository’s graph check. It also documents the configuration and adds a throwaway-repository test suite to CI.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Read migrationGraph configuration] --> B{Configured?} B -- No --> C[not-configured] B -- Yes --> D[Check base ancestry and migration chain] D --> E{Safe to renumber?} E -- No --> F[refused] E -- Yes --> G[Plan new IDs and parent revisions] G --> H{Changes needed?} H -- Yes --> I[Rename and rewrite; stage changes] H -- No --> J[Run graph check] I --> J J --> K[Report verdict]Reviews (7) · Last reviewed commit: "renumber-migration: retitle its README s..."