docs: add agent PR workflow and invariants - #18
Conversation
Adapted from KeyPath's battle-tested agent workflow docs for the kanata fork's Rust/cargo toolchain and two-branch model (main vs keypath/bundled). Defines phase-based invariants, a cherry-pick gate for the shipping branch, and non-negotiable safety rules. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
ReviewThis PR is documentation-only (no Rust code, no API changes), so the standard code-review axes — Rust idioms, hot-path performance, bug surface, backward compatibility — don't really apply here. The relevant question is whether the workflow these docs encode matches the actual repo, and whether the invariants are strict enough to catch what they claim to. Strengths
Issues1. The test invariant is too narrow for a keyboard engine. Both docs assert
2. Pre-push hook is referenced but not in the repo. Both docs lean on "the pre-push hook blocks force-pushes to 3. Diverged-histories claim is load-bearing and unverified. The "never merge in either direction" rule rests on 4. Pre-squashing step is optional, not required. Step 7 ( 5. Minor wording / consistency:
6. Missing: how to recover from a partial state. The invariants define "done," but agents most often get stuck in the middle: PR merged but local branch not pulled, cherry-pick applied but push rejected, worktree exited with uncommitted changes. The "What Can Go Wrong" table touches this; a short "Recovery" section (or a column added to that table for "if you're already in this state, do X") would close the loop and match the invariants-are-self-healing philosophy. Nits
VerdictUseful docs, and the invariants framing is a good fit for agent work. The main thing worth fixing before merge is the test-gate scope (item 1) — as written, an agent that follows this doc to the letter can land a hot-path regression with green local checks. Items 2 and 3 are smaller but worth a sentence each. — Reviewed by Claude (automated code review) |
Summary
docs/agent-pr-invariants.md— phase-based verification gates that define "done" for each stage of agent work (setup, development, PR, babysitting, merge, cleanup)docs/agent-pr-workflow.md— step-by-step reference for the typical path through those phases, including a cherry-pick-to-keypath/bundledphasemain/keypath/bundledtwo-branch modelAlso updates CLAUDE.md (gitignored, local-only) to reference both docs and adds the "never merge main into keypath/bundled" rule explicitly.
Test plan
cargo build,cargo test -p kanata-tcp-protocol)