Skip to content

ci: catch and auto-fix AGENTS.md usage-rules drift - #88

Merged
bougyman merged 3 commits into
mainfrom
issue-79-usage-rules-sync
Aug 12, 2026
Merged

ci: catch and auto-fix AGENTS.md usage-rules drift#88
bougyman merged 3 commits into
mainfrom
issue-79-usage-rules-sync

Conversation

@bougyman

Copy link
Copy Markdown
Member

Summary

Closes #79. Nothing previously ran mix usage_rules.sync automatically, so an ash/oban version bump could silently drift AGENTS.md's generated block with nothing catching it.

  • Adds mix usage_rules.sync --check to ci.yaml's test job (right after mix format --check-formatted) - catches drift introduced within a reviewed PR.
  • Adds a new usage-rules-sync.yaml workflow (push to main + workflow_dispatch) that applies the sync non-interactively and opens a PR via peter-evans/create-pull-request@v8 if anything changed - catches drift from any other source.

Test plan

  • mix usage_rules.sync --check - currently exits 0 (already in sync)
  • Verified --check actually catches drift: deliberately broke a line in AGENTS.md, confirmed it exits non-zero with a diff, restored the original
  • Verified mix usage_rules.sync --yes is a safe no-op (exit 0, no changes) against the current in-sync state
  • actionlint clean on all three workflow files (re-verified after merging in everything that's landed on main since this branch was cut, including the repo rename and the new root-level Mix project)
  • Ran the exact updated CI job sequence locally (mix format --check-formatted && mix usage_rules.sync --check) - passes
  • Verified peter-evans/create-pull-request@v8 is a real current tag via the GitHub API directly

Note

The bot-authored PR (when drift is found) queues ci.yaml's own run via the default GITHUB_TOKEN, but GitHub's anti-loop protection leaves it pending manual approval rather than running automatically - not a blocker, just an extra click.

🤖 Generated with Claude Code

Nothing previously ran `mix usage_rules.sync` automatically, so an
ash/oban bump could silently drift AGENTS.md's generated block with
nothing catching it (verified it's currently in sync, but that's
incidental, not enforced). Adds a `--check` gate to ci.yaml for drift
introduced within a PR, plus a new usage-rules-sync workflow that
applies the sync and opens a PR if anything changed, for drift from
any other source. See #79.
Copilot AI lite review requested due to automatic review settings August 12, 2026 18:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds automated safeguards to prevent AGENTS.md’s generated usage-rules block from drifting silently when dependencies (e.g., ash/oban) change, aligning with the maintenance goals in issue #79.

Changes:

  • Adds a CI gate to fail PRs when AGENTS.md’s generated usage-rules block is out of sync (mix usage_rules.sync --check).
  • Introduces a dedicated workflow that auto-runs the sync on pushes to main (and via manual dispatch) and opens a PR when updates are needed.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
.github/workflows/usage-rules-sync.yaml New workflow to run mix usage_rules.sync --yes and open a PR if it produces changes.
.github/workflows/ci.yaml Adds mix usage_rules.sync --check to the existing test job to catch drift within PRs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bougyman
bougyman force-pushed the issue-79-usage-rules-sync branch from 501d5f4 to 5bb3878 Compare August 12, 2026 18:30
@bougyman
bougyman merged commit ecced63 into main Aug 12, 2026
2 checks passed
@bougyman
bougyman deleted the issue-79-usage-rules-sync branch August 12, 2026 18:34
bougyman added a commit that referenced this pull request Aug 12, 2026
…t hook (#90)

## Summary
- `mix git_hooks` sets `core.hooksPath` to `githooks/` (idempotent).
`mix setup` runs it, and is expected to grow more steps over time as
more repo-management tasks land in this project.
- Adds a new `pre-push` hook alongside the existing `commit-msg` one -
reuses `ci/conventional_commits.sh` as-is (no changes needed: with no
env vars set it already falls back to `main`/`origin/main` as base and
the current branch as head, exactly right for a local push) to catch
anything that slipped past `commit-msg` (a commit made before the hooks
were installed, an amend, etc.), not just the current `HEAD`.
- Removes `app/lib/mix/tasks/githooks.install.ex` - an exact duplicate
of this same idea living in `app/`'s own mix project instead of the new
top-level one.
- Updates `Readme.adoc`/`AGENTS.md`/`app/usage-rules.md`'s references to
the old manual `git config core.hooksPath githooks` / `mix
githooks.install` steps to point at `mix setup` instead.

## Test plan
- [x] `mix setup` run twice - installs cleanly, idempotent (identical
output, no error)
- [x] `githooks/pre-push` run directly - exits 0 against this branch's
own commits
- [x] The underlying validation logic is already proven to catch bad
subjects for real: this exact `ci/conventional_commits.sh` failed CI on
PR #88's badly-worded merge commit earlier today
- [x] `mix test`/`mix format --check-formatted` clean in both projects
(root and `app/`)
- [x] `mix usage_rules.sync --check` still passes after editing
`app/usage-rules.md`
- [x] Confirmed no remaining references anywhere to the removed
`githooks.install` task

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

ci: keep AGENTS.md's usage-rules block from silently drifting

2 participants