aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / docs / REPOSITORY_EXECUTION_RULES.md
| 1 | # AIEN Repository Execution Rules |
| 2 | |
| 3 | ## Adoption |
| 4 | |
| 5 | Adopted 2026-10-10 from Drake's revised rules for the six-issue campaign (interplane#97 and #98, aien-sovereign-core#397 and #398, aegis-runtime#38 and #39). Tooling: `scripts/pr-gate.sh` and `scripts/rebase-crumb.sh`. |
| 6 | |
| 7 | ## Recorded facts (2026-10-10) |
| 8 | |
| 9 | - (a) Branch protection read from GitHub: interplane requires the checks schemas-and-fixtures, rust, python, cross-language, adapter-aien and adapter-odysseus, in strict mode, with no review count. aien-sovereign-core requires the check "Workspace Verification & Invariant Audit", 0 reviews, enforce_admins on. aegis-runtime requires the check "Test & Invariant Verification", 0 reviews, enforce_admins on. Therefore `--admin` is never needed for a green PR. |
| 10 | - (b) interplane has no .crumb files, so the crumb step is skipped there with a notice. aegis-runtime and aien-sovereign-core use crumbs. |
| 11 | - (c) INTERPLANE carries a Python SDK by Drake's 2026-10-04 direction (approved exception). The Motus adapter for interplane#97 lives only under interplane adapters/motus. No Python enters any AIEN-owned repository. |
| 12 | |
| 13 | |
| 14 | These rules apply to Claude Code, all delegated workers, and all repositories involved in this implementation campaign. |
| 15 | |
| 16 | The objective is to ship verified code without corrupting shared branches, bypassing security requirements, or creating unnecessary integration conflicts. |
| 17 | |
| 18 | ## 1. Source of Truth |
| 19 | |
| 20 | GitHub main is authoritative. Inspect current code, tests, active PRs, and repository instructions before editing. |
| 21 | |
| 22 | Never implement an issue solely from its description. Check whether the functionality already exists or has been superseded. |
| 23 | |
| 24 | Use separate branches and worktrees for concurrent development. |
| 25 | |
| 26 | One worker owns each writable worktree. Never allow two workers to modify the same worktree concurrently. |
| 27 | |
| 28 | ## 2. Crumb Compilation |
| 29 | |
| 30 | Retired (DRA-97, 2026-11-07: "Retire Crumbs from the active workflow while preserving live ownership"). A PR needs no `crumb compile`, no `crumb verify` and no separate crumb commit; existing `.crumb` files stay as history. The rule as it stood: |
| 31 | |
| 32 | Every applicable PR must have `.crumb` compilation and verification completed after its final source change. |
| 33 | |
| 34 | Required commands: `crumb compile .` then `crumb verify .` |
| 35 | |
| 36 | Commit generated `.crumb` changes separately as the final commit. |
| 37 | |
| 38 | Do not modify source files after that commit without rerunning compilation and verification. |
| 39 | |
| 40 | If a repository does not support these commands, report the discrepancy and follow its explicit repository policy. Never silently skip a required check. |
| 41 | |
| 42 | ## 2a. Local verification |
| 43 | |
| 44 | `scripts/pr-gate.sh` reads GitHub's CLEAN state. It does not prove the commit was verified. The local admission check that complements CLEAN is `aien-test verify COMMIT` (sovereign-core `tools/aien-test`, ADR 0033 amendment 2026-10-11): it prints READY when every gate required at the base ref has a PASS receipt for that exact commit, and BLOCKED otherwise, with the reason (a missing or NOT_RUN gate, an UNMAPPED changed path, or a BLOCKED_OPERATOR head). Run it on the final SHA. Since the retirement (DRA-97, 2026-11-07) the final SHA is the last source commit: there is no crumb commit, and READY no longer depends on crumbs being CURRENT (sovereign-core `tools/aien-test/docs/LOCAL_VERIFICATION.md`). Before the retirement it was the commit that included the crumb commit, and a pre-crumb SHA was never READY (`docs/crumbs/LOCAL_PIPELINE.md` section 2, history). |
| 45 | |
| 46 | Trust anchors come from the base ref, never from the head under test (ADR 0033 amendment, A1): the required gate set, `.aien/verify.pub`, `.aien/always` and `.aien/unmapped-ok` are read from `origin/main`. A head that changes the pipeline's own configuration (`.aien/`, `tests/gates/`, `.github/workflows/`, `.forgejo/`, `tools/aien-test/`) is BLOCKED_OPERATOR: the operator runs its verification by hand and says so in the PR. Acceptance proofs for the crumb side of this rule (determinism, fixed point, staleness, claims) are `scripts/pipeline-proofs/13-*.sh` to `18-*.sh`; measured numbers in `scripts/pipeline-proofs/RESULTS-2026-10-11.md`. Since the retirement (DRA-97, 2026-11-07) proofs `19-*.sh` to `21-*.sh` prove the opposite: `pr-gate.sh` admits stale, missing or mixed crumbs with `GATE crumb: SKIP retired`, `rebase-crumb.sh` runs no crumb tool and adds no crumb commit, and the final SHA is the last source commit. |
| 47 | |
| 48 | ## 3. Rebase and Crumb Conflicts |
| 49 | |
| 50 | Every sovereign-core merge to main can invalidate `.crumb` files in other open PRs. |
| 51 | |
| 52 | After each sovereign-core merge, evaluate remaining PRs for drift. |
| 53 | |
| 54 | Approved recovery script: `scripts/rebase-crumb.sh <worktree> <branch>` (this repository). |
| 55 | |
| 56 | Before running it: |
| 57 | |
| 58 | - Confirm the worktree has no uncommitted changes. |
| 59 | - Confirm the intended branch and remote. |
| 60 | - Inspect the script before first use. |
| 61 | - Preserve the expected remote head for force-with-lease protection. |
| 62 | - Ensure no other worker is writing to that branch. |
| 63 | |
| 64 | The script takes main's `.crumb` when a conflict is only in `.crumb` files, and pushes with lease. Since the crumb retirement (DRA-97, 2026-11-07) it no longer runs `crumb compile` or `crumb verify` and adds no crumb commit. |
| 65 | |
| 66 | If it reports CODE CONFLICT, stop automated rebasing for that branch. Resolve the source conflict by hand. |
| 67 | |
| 68 | Never discard source changes to manufacture a clean rebase. |
| 69 | |
| 70 | Do not rewrite another worker's branch without coordination. |
| 71 | |
| 72 | ## 4. Definition of CLEAN |
| 73 | |
| 74 | A PR may merge only when all of the following hold: |
| 75 | |
| 76 | - Working tree is clean. |
| 77 | - Changes are based on the intended current main. |
| 78 | - No unresolved merge conflicts. |
| 79 | - Required compilation passes (crumb verification is retired, DRA-97). |
| 80 | - Required tests and CI checks pass. |
| 81 | - Required approvals are present and valid. |
| 82 | - GitHub reports a mergeable state. |
| 83 | - No outstanding blocking security findings. |
| 84 | - The final diff contains no unintended changes. |
| 85 | - The implementation satisfies the linked issue's acceptance criteria. |
| 86 | |
| 87 | Do not equate GitHub's CLEAN merge-state label with complete verification. |
| 88 | |
| 89 | ## 5. Merge Procedure |
| 90 | |
| 91 | Serialize merges into each repository's main branch. |
| 92 | |
| 93 | Default command: `gh pr merge N -R aien-dev/<repo> --squash --delete-branch` |
| 94 | |
| 95 | Only use `--admin` when explicitly authorized for that specific PR and when the required project governance permits it. |
| 96 | |
| 97 | Never use administrative privileges to hide failing tests, missing approvals, security findings, or unresolved conflicts. |
| 98 | |
| 99 | After every merge, refresh main and revalidate dependent or competing PRs. |
| 100 | |
| 101 | ## 6. GitHub PR Editing |
| 102 | |
| 103 | The normal `gh pr edit` workflow is currently unreliable in this environment. |
| 104 | |
| 105 | Use the API fallback: `gh api -X PATCH repos/aien-dev/<repo>/pulls/N -F body=@file` |
| 106 | |
| 107 | Verify the returned response and fetch the PR afterward to confirm the update. |
| 108 | |
| 109 | Do not assume an API operation succeeded merely because the command exited. |
| 110 | |
| 111 | ## 7. Language and Runtime Constraints |
| 112 | |
| 113 | No Python or systemd may be introduced as part of this campaign. |
| 114 | |
| 115 | Use Rust for AIEN-owned runtime, orchestration, adapters, and execution control. |
| 116 | |
| 117 | Motus may run externally using its own dependencies, but the AIEN integration must communicate over an explicitly verified protocol boundary. |
| 118 | |
| 119 | If a task requires Python inside an AIEN-owned repository, treat it as an architectural conflict. Redesign it or report the blocker before proceeding. |
| 120 | |
| 121 | Existing Python files do not authorize adding more Python. Flag any conflict with the strict repository policy rather than silently ignoring it. |
| 122 | |
| 123 | ## 8. Command Hooks |
| 124 | |
| 125 | A local Bash hook rejects certain command text containing accelerator or kernel-module related terms. |
| 126 | |
| 127 | Do not embed source-file contents containing these terms into Bash commands or heredocs. Use the approved Write tool for file creation and editing. |
| 128 | |
| 129 | Do not attempt to bypass restrictions on executing prohibited operations. |
| 130 | |
| 131 | If an approved development command is incorrectly blocked, report the exact failure and use an authorized alternative. |
| 132 | |
| 133 | ## 9. Commits and Attribution |
| 134 | |
| 135 | Use small, logically isolated commits. |
| 136 | |
| 137 | Required commit trailers, when attribution accurately reflects the contributors: |
| 138 | |
| 139 | `Co-authored-by: Drake Stapleton <drake@aienos.com>` |
| 140 | `Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>` |
| 141 | |
| 142 | Do not invent contributors or misrepresent authorship. |
| 143 | |
| 144 | Required PR footer: 🤖 Generated with [Claude Code](https://claude.com/claude-code) |
| 145 | |
| 146 | Every PR must reference its issue, describe its implementation, identify verification performed, and disclose limitations. |
| 147 | |
| 148 | ## 10. Worker Models and Verification |
| 149 | |
| 150 | Use Sonnet for delegated implementation workers unless instructed otherwise. |
| 151 | |
| 152 | Workers may inspect, implement, test, and propose solutions within their assigned ownership boundaries. |
| 153 | |
| 154 | A worker's claim of completion is not verification. |
| 155 | |
| 156 | The coordinating agent must independently inspect every worker's changes and verify relevant tests, security invariants, and actual GitHub state. |
| 157 | |
| 158 | Do not accept unsupported claims about test passes, hardware performance, successful merges, or completed integrations. |
| 159 | |
| 160 | Use an independent reviewer for security-sensitive changes. |
| 161 | |
| 162 | ## 11. Failure Handling |
| 163 | |
| 164 | Do not repeatedly retry the same failing operation without identifying the cause. |
| 165 | |
| 166 | On failure: |
| 167 | |
| 168 | 1. Capture the exact failure and affected commit. |
| 169 | 2. Determine whether it is source-related, environmental, or caused by concurrent changes. |
| 170 | 3. Apply the smallest justified correction. |
| 171 | 4. Rerun the affected verification. |
| 172 | 5. Escalate or isolate persistent blockers without destroying valid work. |
| 173 | |
| 174 | Never force-push another worker's changes away. |
| 175 | |
| 176 | Never turn off tests, security checks, or authorization rules merely to make a PR merge. |
| 177 | |
| 178 | ## 12. Communication |
| 179 | |
| 180 | Use plain English when reporting to Drake. Do not use em dashes or en dashes. |
| 181 | |
| 182 | Provide concise updates that identify completed work, active work, blockers, and next actions. |
| 183 | |
| 184 | Do not confuse attempted operations with completed operations. |
| 185 | |
| 186 | ## 13. Final Delivery |
| 187 | |
| 188 | Before declaring the campaign complete: |
| 189 | |
| 190 | - Verify every merged PR against its issue. |
| 191 | - Check relevant cross-repository interfaces. |
| 192 | - Run integration tests. |
| 193 | - Confirm no unintended dependency or architecture changes. |
| 194 | - Report remaining failed, skipped, or unavailable verification. |
| 195 | - Confirm final GitHub issue and PR status. |
| 196 | |
| 197 | A task is complete only when the implementation, verification, and required integration are finished. |
| 198 | |
| 199 | ## 14. Worker Instructions |
| 200 | |
| 201 | Worker briefs live with each campaign; this document wins when they conflict. |
| 202 | |
| 203 | Stable rules and validated scripts live in aien-architecture (`docs/REPOSITORY_EXECUTION_RULES.md`, `scripts/pr-gate.sh`, `scripts/rebase-crumb.sh`). |
| 204 | |
| 205 | **Operating principle: Ship correct, verified code. Preserve other workers' changes. Protect main. Never trade correctness for apparent progress.** |