Automate R-parity check and fix with guardrailed agent - #7
Merged
Conversation
Adds the "fix if required" half of the fidelity chain alongside the existing detection workflow, with hard guardrails and a human-merge policy. - .github/workflows/parity-autofix.yml: sets up Python + live R at the recorded R commit, reproduces the divergence via the live-R parity runner, and only when behavior genuinely drifted hands a structured report to anthropics/claude-code-action. The agent may edit src/nns/** only, must classify the root cause (Python port bug -> fix; R behavior change or native change -> escalate, never touch extern/NNS-core, tools/NNS, or the cache), must verify against live R, and opens a SEPARATE parity-correction PR. If live R cannot be installed, it opens an escalation PR instead of guessing. Never auto-merges. - inspect-r-api-update.yml: chains to parity-autofix via an nns-parity-divergence repository_dispatch (gated on the optional PARITY_DISPATCH_TOKEN secret; prints the manual trigger otherwise). - docs/parity_autofix.md: setup (ANTHROPIC_API_KEY via /install-github-app, optional PARITY_APP_TOKEN so fix PRs trigger CI, optional PARITY_DISPATCH_TOKEN for auto-chaining), guardrails, and human-merge policy. Automation only; no runtime/package behavior changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the "fix if required" half of the fidelity chain. Detection already
exists (
inspect-r-api-update.yml); this adds live-R verification plus aguardrailed, human-reviewed automated fix.
What's added
.github/workflows/parity-autofix.yml— sets up Python + live R at therecorded R commit, reproduces the divergence with the existing
run_live_r_parity_for_changed_api.py, and only when behavior genuinelydrifted invokes
anthropics/claude-code-actionto draft a fix.inspect-r-api-update.yml— chains to the autofix via annns-parity-divergencerepository_dispatch(gated on the optionalPARITY_DISPATCH_TOKEN; prints the manual trigger otherwise).docs/parity_autofix.md— setup + policy.Guardrails (enforced in the gate + agent prompt)
src/nns/**only; neverextern/NNS-core/**,tools/NNS/**,or
tests/_r_cache.json.native change → escalate (native code enters only via NNS-core).
it opens an escalation PR instead of guessing.
must contain the function, args, R output, Python output, first divergent
intermediate, affected files, and proposed fix.
Setup required before it can run (see
docs/parity_autofix.md)ANTHROPIC_API_KEY/install-github-appor Settings → Secrets)PARITY_APP_TOKENnative-backend-ciPARITY_DISPATCH_TOKENinspect → autofix(defaultGITHUB_TOKENcan't emitrepository_dispatch)Model defaults to
claude-sonnet-4-6, overridable via theworkflow_dispatchmodelinput (e.g.claude-opus-4-8for harder divergences).Validation
All four workflow YAMLs parse;
git diff --checkclean;ruff check .passes(no Python/package changes). Note: live-R-in-CI depends on the runner installing
the vendored NNS R dependencies (
r-lib/actions/setup-r-dependenciesagainsttools/NNS, best-effort) — if that fails the workflow escalates rather thanproducing an unverified fix.
This PR is automation only; it does not change runtime/package behavior.
https://claude.ai/code/session_017KnASettwNxUdYJzchRLux
Generated by Claude Code