feat(auto-derive): open reconciliation PR on diff (write + PR mode)#138
Conversation
Replaces dry-run-only with active reconciliation: daily 07:00 UTC run executes derive.sh --write, and on any diff in ip_map_branch.txt or docker/scripts/demoLibrary.source vs master, force-pushes the stable branch auto-derive/reconciliation and opens (or updates) a PR. On no-diff with an existing open reconciliation PR, the PR is closed and the remote branch is deleted -- upstream drift reverted. Diff detection is scoped to those two output files so unrelated edits to tools/auto-derive/ or other paths can't trigger a bot PR for changes the bot didn't make. workflow_dispatch defaults to reconcile; choose `dry-run` from the input dropdown for a manual preview with artifact upload and no side effects. Fixture test suite job is unchanged from PR openemr#135. Caveat: PRs are created via GITHUB_TOKEN, so downstream workflows (rabbit, CI) don't auto-run on bot PRs -- the in-workflow fixture suite is the authoritative algorithm validator. Empty commit forces CI if needed.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe Reconcile Workflow and Documentation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/derive-ip-map.yml:
- Around line 35-43: Gate the reconcile job’s side effects behind the fixture
suite by making `reconcile` depend on the `test` job in this workflow, rather
than running as an անկախ parallel sibling. Update the `jobs.reconcile`
definition in `derive-ip-map.yml` so it only executes when `test` succeeds,
preventing force-push/PR actions from `reconcile` when
`./tools/auto-derive/fixtures-and-tests/test.sh` fails.
- Around line 39-55: The Checkout step in the derive-ip-map workflow is using
the workflow-triggering HEAD, which can pull in unrelated commits when run
manually. Update the actions/checkout configuration in the Checkout step to
explicitly check out master by setting the ref on that step, so the
auto-derive/reconciliation branch and PR diff are always based on the correct
baseline.
- Around line 151-167: The `git diff` summary in the reconciliation workflow is
being built incorrectly because `--stat` is placed after the pathspec separator,
so the `stat` variable captures a full patch instead of the summary. Update the
diff command in the reconciliation script to use `git diff` with `--stat` before
`--` while keeping the same paths, so `stat` and `full_diff` remain distinct in
the PR body.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: aefdd18d-b7ca-47ab-8fb7-3455c5ecc99c
📒 Files selected for processing (2)
.github/workflows/derive-ip-map.ymltools/auto-derive/README.md
… --stat, add PR trigger - reconcile job now needs: test and requires test success, so a broken algorithm can't force-push or open a PR (rabbit #3487382063). - reconcile checkout pinned to ref: master so workflow_dispatch from a topic branch can't carry unrelated commits into the bot branch (rabbit #3487382069). - Move --stat before -- in PR-body git diff so it's parsed as a flag rather than a pathspec; the stat output was previously the full patch (rabbit #3487382072). - Add pull_request: trigger with path filter so PRs touching bot files re-run the fixture suite (restores PR openemr#1's CI coverage). Reconcile guard restructured to positive-list schedule + dispatch-reconcile so PR events can't accidentally satisfy it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… PHP toolchain (#141) The auto-derive bot (PRs #135, #138) is now the canonical writer of ip_map_branch.txt + docker/scripts/demoLibrary.source. The legacy PHP-based per-tag bumper is fully redundant; remove it. Changes: - Delete .github/workflows/bump-tag.yml (repository_dispatch openemr-tag consumer). - Delete tools/release/ (composer/PHPUnit/IpMapBumper.php toolchain). - Add `repository_dispatch types=release-targets-changed` listener to derive-ip-map.yml so the bot reconciles immediately when upstream pushes release-targets.yml instead of waiting for the next 07:00 UTC tick. - Update reconcile job's if-guard to allow repository_dispatch while preserving the existing schedule + workflow_dispatch-reconcile paths and the repo-owner/test-success gates. pull_request is still excluded from reconcile by the explicit allowlist. - README + workflow header comments updated to reflect retired-state. Cross-repo follow-up (tracked separately): openemr/openemr companion PR to (a) dispatch `release-targets-changed` from a workflow that watches .github/release-targets.yml on master and (b) stop dispatching the now unlistened-for `openemr-tag` event from release-prep.yml:328-337. During the transition the openemr-tag dispatches land here with no listener — harmless no-op. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
What
Promotes the
derive-ip-mapworkflow from dry-run-only (PR #135) to active reconciliation:derive.sh --writeand, on any diff inip_map_branch.txtordocker/scripts/demoLibrary.sourcevsmaster, force-pushes the stable branchauto-derive/reconciliationand opens (or updates) a PR titled[auto-derive] reconcile demo_farm against upstream openemr master.workflow_dispatchnow takes amodeinput (reconciledefault,dry-runoptional).dry-runmode keeps the artifact-upload preview behavior from PR feat(auto-derive): scaffold ip_map + demoLibrary derivation bot (dry-run) #135 with no branch/PR side effects.Why
PR #135 set up the algorithm + dry-run scaffolding. PR #2 (this) is the "live" rung -- the bot now actually reconciles. PR #3 will retire the legacy
bump-tag.yml+tools/release/PHP toolchain.Behavior details
--force-with-leaseis safe even if the branch was just deleted (lease against missing ref).git diff --quiet -- ip_map_branch.txt docker/scripts/demoLibrary.source. An unrelated edit totools/auto-derive/(or anywhere else) on master won't trip the bot into PR-ing changes it didn't make.git addonly the two output files. No accidental sweep of other working-tree noise.if:pins toopenemr/demo_farm_openemrso forks don't accidentally try to open PRs against themselves.Caveats
GITHUB_TOKENdo NOT trigger downstream workflows (rabbit, CI). The in-workflow fixture suite job is the authoritative algorithm validator. To manually run CI on a bot PR, push an empty commit (git commit --allow-empty -m 'trigger ci' && git push).gh pr createstep will fail.Out of scope
tools/auto-derive/derive.sh(algorithm is stable from PR feat(auto-derive): scaffold ip_map + demoLibrary derivation bot (dry-run) #135)tools/auto-derive/fixtures-and-tests/**(fixtures are stable from PR feat(auto-derive): scaffold ip_map + demoLibrary derivation bot (dry-run) #135)tools/release/**,demo_build.sh,ip_map_branch.txt,docker/scripts/demoLibrary.source(untouched here; the daily bot run will pick up any drift)Test plan
openemr/demo_farm_openemrworkflow_dispatchwithmode=dry-run-- verify artifact uploads, no branch created, no PR openedworkflow_dispatchwithmode=reconcile-- verify either (a) no-diff path logs cleanly with no PR, or (b) diff path creates branchauto-derive/reconciliation+ opens PR with expected title/body/stat/full-diffreconcilewith no underlying drift change -- verify existing PR is updated (gh pr edit) rather than duplicatedreconcilewith no further drift -- verify clean no-diff exit with no zombie PRSummary by CodeRabbit