diff --git a/.claude/skills/pr-push/SKILL.md b/.claude/skills/pr-push/SKILL.md index 846e3b6da..b64f9d7d0 100644 --- a/.claude/skills/pr-push/SKILL.md +++ b/.claude/skills/pr-push/SKILL.md @@ -26,6 +26,20 @@ current branch — never touches main. ## Workflow +### 0. Dry-run mode check + +If the user invokes `/pr-push --dry-run`: +- Print: "Dry-run mode — inspecting state, nothing will be pushed or committed." +- Run steps 1 through 4a in **inspect-only** mode: + - Step 4: run `make check-systems-db` to check current stamp freshness (no merge) + - Step 4a: report which watched files changed vs origin/main; show whether `make regen-db` + would be triggered; do NOT run the regen, stage, or commit +- Print a summary: watched files changed (list), regen needed (yes/no), DB stamp fresh (yes/no) +- Print "Dry run complete — use /pr-push to apply." +- Stop. Do not push or create a PR. + +--- + ### 1. Validate branch ```bash @@ -201,6 +215,67 @@ git merge origin/main --no-edit If merge conflicts, **stop and report** — let the user resolve. If clean, continue. +### 4a. Regen systems.db if generator sources or data changed (#858) + +Check whether any file in the **source-file watch list** was modified on this branch +versus `origin/main`. This list covers generator code AND the data files that feed them: + +```bash +git diff --name-only origin/main...HEAD -- \ + tooling/economy-db/import_economics.py \ + tooling/planet-gen/generate_atlas.py \ + server/src/bin/generate_brands/main.rs \ + tooling/generate-brands \ + server/data/systems-schema.sql \ + wiki/star-systems/ \ + wiki/economics/ \ + content/economics/ +``` + +**If output is empty:** skip this step entirely. + +**If any files appear in the output:** the DB must be regenerated on top of the +current main. Perform the following: + +1. **Integrate main.** Step 4 merged main into the branch. If you find yourself + on a branch that was NOT yet merged with main in step 4, do it now: + ```bash + git fetch origin + git merge origin/main --no-edit + ``` + If there are merge conflicts in source files, **stop and report which files + conflict**. Ask the user to resolve manually — do not attempt to auto-resolve + generator source conflicts. + +2. **Regenerate the DB:** + ```bash + make regen-db + ``` + `make regen-db` runs all three generators and stamps the meta table. It tolerates + coverage gate failures (exit 2 = data quality warning, not an error). If it exits + with any other non-zero code, stop and report the stderr output — do not push. + +3. **Stage the updated DB:** + ```bash + git add server/data/systems.db + ``` + +4. **Commit only if the DB actually changed:** + ```bash + git diff --cached --stat -- server/data/systems.db + ``` + - If the diff shows changes: commit with `/git-commit`, message: + `chore(db): regen systems.db against rebased sources` + - If no diff (regen produced identical output — sources were self-consistent): + unstage the file (`git restore --staged server/data/systems.db`) and skip the + commit. The source changes alone are the PR content. + +**In dry-run mode** (from step 0): report which watch-list files changed and +whether regen would be triggered. Do NOT run the regen or modify any files. + +This step prevents the pre-push hook from rejecting a push where the branch modifies +a generator source or data file but did not regenerate the DB. + ### 5. Push ```bash