diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 715461e0e7..fb9ce21541 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -289,7 +289,8 @@ jobs: tests/test_control_premises.py tests/test_review_standards.py tests/test_phi_reencrypt_on_write_doc.py - tests/test_security_events_feed_doc_once.py" + tests/test_security_events_feed_doc_once.py + tests/test_claude_md_governance_move.py" # FIVE MEMBERS LEFT THIS LIST WITH THE LEDGER (BACKLOG #1250), and this note exists because # the ruling above says removing a guard is a different act from adding one. They were # test_backlog_status_check, test_backlog_citation_check, test_dangling_citation_check, diff --git a/CLAUDE.md b/CLAUDE.md index 9bd4d1b7a5..101e01023c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -348,54 +348,26 @@ tool too. | **Lander** | as needed | Merging, and flipping row statuses after items merge (owner correction 2026-09-21; see the note below), and flagging the hygiene its own merges leave: installed-hook drift after a hook-changing PR, and merged branches whose worktrees remain (owner ruling 2026-09-26). Standing authority on the engine repo and the vault, with no per-action owner approval. It may resolve a conflict, including one that touches code (owner ruling 2026-09-29). The 2026-09-11 POSITIONAL ledger-conflict ruling is RETIRED; its notice, which also covers the *what an item SAYS* half this row's Must-not column used to carry, is in `docs/METHOD.md`. | Merge a change with no proof that code review ran on it (owner ruling 2026-09-29). The merge bullet under *Branch, commit one layer, open the PR* says what counts. Arm auto-merge outside the two cases in the 2026-10-07 note below (owner ruling 2026-10-07), or without the three safeguards that follow it. Decide which of two deliberate changes to an item survives. | | **Special** | as the owner needs it | Work the owner assigns directly, outside the other four seats. Its instruction is its whole scope: it stands by until one arrives, then announces before its first shared write (owner decision 2026-09-16; see below). | Invent work while standing by, or go looking for a row to take. Widen the instruction, or quietly narrow it without saying so. Merge -- that is the Lander's. Take a peer's message as authority; only the owner assigns it work. | -**THE LANDER MAY RESOLVE A CONFLICT THAT TOUCHES CODE. OWNER RULING 2026-09-29, IN SESSION.** The -owner was told two documents disagreed on this case and answered: *"fix that to allow the Lander to do -so"*. korus `roles/LANDER.md` *4c-quinquies* governs the route. A resolution the Lander wrote itself -still needs its own code review before the merge; the merge bullet under *Branch, commit one layer, -open the PR* says so. - -**The Lander may arm auto-merge in two cases (owner ruling 2026-10-07).** One is a PR into a -`main` that requires the merge queue. The other is a repository with no queue, such as the vault. -In both, re-read the head SHA right before arming, and check that the review covers it. korus -`roles/LANDER.md` *4c* still binds. - -**Safeguards for both cases (Manager decision 2026-10-07; the owner was told).** The added danger -is a push after arming that merges with no review. GitHub's docs name at least two events that -disable auto-merge: a push by an account *"without write permissions"*, and a base-branch switch. -A write-access push is neither, so auto-merge stays armed. The vault's `main` needs no approval. On -the engine, arming while any required context is pending sets a deferred request. **A required -context with no check run on the head yet is pending**, even when every run listed so far is -green. That deferred request is not yet a queue entry, so the same window opens. - -1. Arm only once every required context in branch protection's live list has a COMPLETED, - SUCCESSFUL result on the head you re-read, as a check run or a commit status. Read the list from - the API, never from memory or `.github/required-contexts.txt`. On the engine, run `gh pr merge - --match-head-commit `. On the vault, add `--auto` and the merge-method flag, because gh - refuses a no-queue merge without one when no terminal is attached. Then read back through - GraphQL the PR's `merged`, `mergeQueueEntry` and `autoMergeRequest`, never - `PullRequest.mergeQueue`, which names the target queue whether or not the PR is in it. Merged, - or on the engine an entry with a null `autoMergeRequest`, is the goal. A non-null - `autoMergeRequest`, on either repository, is a deferred request: disarm it, read it back as - null, then wait for the missing context, or triage that context if it went red. Not merged, no - entry and a null request means nothing is queued, for example because the call silently - no-opped, was refused, or the queue evicted the PR. Read the command's output and the checks - again, and re-run only once this step's condition holds. -2. Pin the full 40-character SHA of the head you re-read, since gh refuses a short one. If you - updated the branch, wait for the new head, and confirm it adds only a clean merge of `main`. - Post the pinned SHA on the PR as a comment. On both paths, gh 2.93.0 sends it as - `expectedHeadOid` to `enablePullRequestAutoMerge`. GitHub's schema describes that field only as - *"The expected head OID of the pull request."* Nothing documented says GitHub checks it again - at merge time. -3. After the merge, compare the PR's `headRefOid` to the latest SHA you posted. If they differ by - more than a clean merge of `main`, read what merged, because a queue may have merged the earlier - head. If unreviewed content landed, revert it and send it to code review. This check is the - binding control, whatever the pin does. Nothing runs it for you, so check every PR you armed at - the start of each Lander session. - -Where *4c* tells an author to push again, disarm first with `gh pr merge --disable-auto`, and -read the state back. Once a PR is queued, that command does not remove the entry (korus -`docs/TIPS-AND-TRICKS.md`), so tell the author to wait. A required status check bound to the reviewed SHA would close this gap at the merge gate. -That is a branch-protection change, and it is unfiled. +The paragraphs whose leads and bold rulings follow moved verbatim to [`docs/roles/GOVERNANCE.md`](docs/roles/GOVERNANCE.md) +on 2026-11-30, under record d20261130T205934217-adcecf, and bind exactly as if they still stood here. + +**These leads are only an index. They leave out conditions and give no permission.** Read all of +`docs/roles/GOVERNANCE.md` before you arm auto-merge, enqueue or merge a PR, resolve a conflict as +the Lander, act on or answer a hold, tell an author to push again, send or work as a repair Builder, +or transfer, take over or cancel the transfer of a held PR. Role cards call these the stub-listed +acts. The Lander reads it at the start of each session, and the Watchdog and every Repair Manager +read it on arrival. Anyone who has read it, or does one of these acts, reads it again after any +compaction. This applies to every seat and every PR author, including Builders, Special and sessions +with no role card. + +- **THE LANDER MAY RESOLVE A CONFLICT THAT TOUCHES CODE. OWNER RULING 2026-09-29, IN SESSION.** +- **The Lander may arm auto-merge in two cases (owner ruling 2026-10-07).** +- **Safeguards for both cases (Manager decision 2026-10-07; the owner was told).** +- **A required context with no check run on the head yet is pending** +- Where *4c* tells an author to push again + +The two auto-merge cases, the safeguards and the full 2026-09-29 conflict ruling that this section +cites are in that file. **ASVS record work is a Manager's, dispatched to vault Builders (owner ruling 2026-09-23).** It covers re-scoring a cell, editing the record's own prose, and reconciling the record against a @@ -443,91 +415,28 @@ nobody checked it. A Manager seat added, the same day, that spawning should be r cannot outlive a mistake, and a spawned session can. The full notices are in [`docs/METHOD.md`](docs/METHOD.md), *CLAUDE.md text moved in wave 2*. -**The Lander may send a repair Builder subagent to a held PR as soon as the hold is posted** (owner -instruction 2026-11-26, in the Lander's chat: *"Change the rules to allow you and future landers to -be more proactive"*). That sentence named no number. The 30-minute windows and the cap of two -repairs here, and the 30-minute transfer and `hold-ack` expiry in the next paragraph, were set in -the Lander's brief written under that instruction, which the owner directed the Manager to follow -exactly (2026-11-26, in the Manager's chat); the not-live guard's question window in the next -paragraph stays at 2 hours. All of these must hold: the hold names one determinate fix, such as a -doc, a comment, a test, or a code change the hold spells out, and not a question of intent, of an -owner ruling or of behaviour; the hold still names the PR's head, and no author answer since the -hold disputes it; the PR is not queued and has no armed auto-merge request; the PR carries no -unminimized repair-owner marker (next paragraph), since its repairs are then the Repair Manager's; -the PR is not ASVS record content, which stays a Manager's (owner ruling 2026-09-23); and the author -has not answered the hold in the last 30 minutes, with a `hold-ack` (next paragraph), a comment or a -commit. If the author has, the Lander reads that answer on its turn and waits for that author until -30 minutes after it. A commit moves the head, so a repair after one needs a fresh hold at the new -head. The Builder fetches before it pushes, never force-pushes, stops if the head moved, stops at -any refusal, and makes only the fixes the hold names. At most two repairs per PR. A further hold -then follows the next paragraph's ordinary transfer rule, with whatever acknowledgement and not-live -tests that rule sets. Every other non-trivial fix still goes to a spawned Manager session, as the -paragraph above says. Before it merges a repair head, the Lander re-reads the PR's comments since -the hold, and an author objection returns the PR to the author (fleet wiki lesson -20261124T012815379Z-wd9e1o). The Lander merges only once a code-review fork at `xhigh` that the -Lander starts itself, on the repair head, covers it, its tag read with `review_tag.py`; the repair -Builder's own QA does not count. That independent review is what keeps authoring apart from landing. -This paragraph's change left it unchanged, along with the review proof the merge bullet below -requires, and did not change what goes to the owner. **Repairing at once, and the shorter windows in -the next paragraph, raise at least this risk:** an author's own Builder may already be mid-fix on a -held PR that looks quiet. Fleet wiki lesson 20261103T145659705Z-kqwvhx found one on 2 of 4 quiet -PRs, measured under the old 2-hour window, so at once is likely worse. The change removed at least -two checks that also guarded against it, the mail to the author and the live-session test. The -collision controls left include at least the head-moved check that binds repair Builders, which are -briefed with it, the test that the hold still names the head, and the 30-minute answer exception. On -a PR that looks quiet, the last two see nothing; what still bears on this risk there includes at -least the head-moved check, which acts only if the author pushes first. An author's in-flight -Builder is not briefed with that check and may have none. - -**A held PR whose author has not acknowledged the hold within 30 minutes transfers to the Repair -Manager.** The owner ruling of 2026-11-03 adopted the transfer, at 2 hours: asked *"Which tiers do -you want to adopt?"* of the Repair Manager proposal, the owner answered *"Tiers 1 and 2"*. The -paragraph above says where the 30-minute window comes from. This covers a hold the paragraph above -does not take, so the Repair Manager is the spawned Manager that paragraph sends a non-trivial fix -or a hold after its second repair to. An acknowledgement is an author comment or commit; the -`hold-ack` marker `scripts/coord/held_pr_turns.py` reads is its unambiguous form, and since every -seat acts as the owner's GitHub identity, only the original author's comment or commit counts, a -commit its own Builders push included; one from the Lander, another seat or a workflow is not one, -the Lander's branch updates included. A `hold-ack` expires 30 minutes after it while it is still the -original author's newest event since the hold and no commit by the original author has landed since -it (2026-11-26, as the paragraph above says; the earlier 2 hours was decided by the Lander under the -owner's delegation of 2026-11-03, record d20261103T190111765-2aa8b6: asked *"should a hold-ack -expire 2h after it"*, the owner answered *"/driver"*). The hold then counts as unacknowledged, which -`scripts/coord/held_pr_turns.py` shows as the Lander's turn, flagged `ack-expired` only while the -head is unchanged; any other head move already reads as the Lander's turn. A transfer on an expired -`hold-ack` also needs the author to read not live: the author's claim and seat record show no live -session, or the author's transcript ENDS on a question unanswered for more than 2 hours, which -counts as no live session whatever its running state. The 2026-11-26 brief set the 30-minute windows -in this paragraph and none for this one, so it was left at 2 hours (decided by the Manager under the -owner's standing instruction of 2026-10-22). The Lander reads this with `list_events` or korus -`scripts/board/seatstate.py`, and confirms the question is the transcript's last turn rather than an -older orphaned ask. The paragraph above's repair takes no such test. An author commit or ordinary -reply hands the turn back to the Lander, and nothing expires then. The author may also hand the PR -over sooner. The explicit form is a comment whose first line is -``, posted only by the original author session, `` -being its own session id; `scripts/coord/held_pr_turns.py` flags it `author-closed` where its -header says it counts. The script cannot tell which session posted the marker, so the Lander -confirms it against the author's seat record; a flagged PR so confirmed is transfer-eligible at -once, without the -30-minute window or the not-live test, and the transfer's other conditions still hold, at least -the next sentence's and the transfer steps in order (owner approval 2026-11-27, in the Manager's -chat). The PR must not be queued or carry an armed auto-merge request. The Lander spawns one -Manager for repairs in its own CCD instance, so `send_message` can wake it, and keeps it alive, -respawning it if it dies. The transfer is, in order: the hold's URL sent to the Repair Manager with -`send_message` as its brief; no transfer unless the send reports delivered, not queued or an error; -the repair-owner marker `` on the PR, `` being the Repair -Manager's CCD `local_` id copied whole; the hold's URL sent to it again; and mail to the original -author's seat-record worktree where it has one, naming the PR URL and that id. A Repair Manager that -does not find the marker stops and waits to be woken. It never briefs a Builder without the marker -naming it. Minimizing the newest marker, and any older one still unminimized, cancels the transfer -and hands the PR back to the original author. At least stacks, landing order, author intent and -anything already waiting on an owner ruling stay with the original author. Like the Lander and the -Watchdog, the Repair Manager never uses `AskUserQuestion`; an owner question its own repair raises -goes in a table. It never opens a PR, enqueues or merges. Its Builders fetch before they push, never -force-push, stop if the head moved, stop at any refusal, and make only the fixes the hold names; the -paragraph above names the collision risk that leaves. Every repair head it pushes takes the Lander's -own independent review the paragraph above requires, before the merge. The procedure is in korus -`roles/LANDER.md` and `roles/MANAGER.md`. +The paragraphs whose leads and bold rulings follow moved verbatim to [`docs/roles/GOVERNANCE.md`](docs/roles/GOVERNANCE.md) +on 2026-11-30, under record d20261130T205934217-adcecf, and bind exactly as if they still stood here. + +**These leads are only an index. They leave out conditions and give no permission.** Read all of +`docs/roles/GOVERNANCE.md` before you arm auto-merge, enqueue or merge a PR, resolve a conflict as +the Lander, act on or answer a hold, tell an author to push again, send or work as a repair Builder, +or transfer, take over or cancel the transfer of a held PR. Role cards call these the stub-listed +acts. The Lander reads it at the start of each session, and the Watchdog and every Repair Manager +read it on arrival. Anyone who has read it, or does one of these acts, reads it again after any +compaction. This applies to every seat and every PR author, including Builders, Special and sessions +with no role card. + +- **The Lander may send a repair Builder subagent to a held PR as soon as the hold is posted** +- **Repairing at once, and the shorter windows in the next paragraph, raise at least this risk:** +- **A held PR whose author has not acknowledged the hold within 30 minutes transfers to the Repair Manager.** + +The owner's instruction of 2026-11-26, which the merge bullet says is quoted in the repair-Builder +paragraph above, is quoted in that file. The paragraph below does not quote it. + +**A repair Builder** fetches before it pushes, never force-pushes, stops if the head moved, stops at +any refusal, and makes only the fixes the hold names. **The author of a held PR** must read the full +`hold-ack`, 30-minute transfer and `author-session-closed` rules there before replying. **Every seat but Special runs the driver and empower rules.** Each seat except Special applies the `driver` and `empower` skills' rules by default, in local and cloud sessions, without the owner @@ -685,7 +594,12 @@ Builder, a subagent included, still never waits and puts its question in its rep so a Manager hands the PR over and leaves the queue to it. **Dequeue before pushing**, because whether a queued entry drops a later push is unmeasured; [`docs/METHOD.md`](docs/METHOD.md), *Auto-merge: the hazard kept*, says why. The full text is in the same file, *CLAUDE.md text moved - in wave 3*. + in wave 3*. **A write-access push leaves auto-merge armed**, so a head pushed after arming can + merge with no review. Where korus `roles/LANDER.md` *4c* tells an author to push again, disarm + first with `gh pr merge --disable-auto` and read the state back; once the PR is queued, that + command does not remove the entry (korus `docs/TIPS-AND-TRICKS.md`), so tell the author to wait. + This is a summary: the stubs above say to read all of `docs/roles/GOVERNANCE.md`, which holds the + full rule, before telling an author to push again. - Work on a feature branch. Which seat opens the PR, and when, is the batching bullet below. Commit at logical stops, **one coherent layer per commit**, with clear messages. Direct pushes to `main` stay blocked by the harness. diff --git a/docs/AUTONOMY-PLAN.md b/docs/AUTONOMY-PLAN.md index 29ee25496e..5d9a99215e 100644 --- a/docs/AUTONOMY-PLAN.md +++ b/docs/AUTONOMY-PLAN.md @@ -68,7 +68,7 @@ It replaces the driver skill's decision process and becomes the default for ever |---|---|---| | **A. Mechanical** | Cleanup of resources **you own**: your session made it, or your claim or seat record names it. Moving into your own worktree. One re-run of a red CI leg, with the failed log linked on the PR; a second red on the same leg is a finding, not a re-run. Reads, research, read-only agents. Force-pushing or deleting **your own unshared** branch. | **Act. Never ask, never hand over a command.** Needs three predicates: the resource is yours, a named undo path exists, and live state was read. A failed predicate makes it Class B. | | **B. Reversible judgment** | Approach and design choices. Briefing and re-briefing. PR cutting. Fixing or filing a finding. A mechanical re-anchor (same content, moved line). A routine Manager plan. **A hook, gate or settings edit that only tightens an existing control** (closing a fail-open or a bypass, with a test that shows the old code letting the case through), **or that follows mechanically from an edit the owner already approved** (a version bump, prose the approved change made false). Owner correction 2026-10-21: asked about a gate version bump and two fail-open fixes, the owner answered *"those two questions are examples of things I don't need to review"*. | **Act on the bar in R4.** Log it. | -| **C. Owner-reserved** | Legal or regulatory acceptance in your name: a register signature or re-signature, a risk acceptance, a deviation. **"Left to the signer" questions.** Money. Credentials, secrets, account settings. Anything git cannot undo, or that touches someone else's work: deleting another session's worktree, force-pushing a shared branch, a real-store migration, a release tag. Branch protection and required contexts. **Weakening a control or a gate.** **Editing the rules that bind the fleet:** CLAUDE.md sections 0, 5, 9 and 11, SAIDS, SDS, the driver and role skills, korus playbooks, `scripts/hooks/*`, `.claude/settings*.json`, account settings, `.pre-commit-config.yaml`, `.github/workflows/*`, except the tightening and follow-on edits that Class B names. An edit that adds an exemption, loosens a check, or adds a new rule stays here. A re-anchor that changes what the register accepts. Spawning outside the CLAUDE.md section 5 ruling. Publishing outside this repo. New product scope. An open ledger row whose banner verdict is build, and the accepted direction of an ADR whose status records the owner's acceptance, are not new product scope (this plan's section 12), so a Manager picking and splitting such work is a routine plan, Class B with its review. Still Class C: a new direction, meaning work beyond the scope of that row or the accepted direction of that ADR; when it is unclear whether work is inside that scope, it is a new direction and stays the owner's. Also still Class C: at least any part the ADR's status holds back (for example as proposed, gated or deferred) or that was since declined, rejected, superseded or withdrawn, in whole or in part; work a row, an ADR or CLAUDE.md reserves to an owner ruling; and work that also falls under any other entry in this cell, a Class C path included. Scope a session wrote counts only where it traces to an owner turn, or, for a row it filed or widened or a verdict it set, to a defect in main's shipped behaviour. An ADR acceptance or amendment a session recorded counts only where it traces to an owner turn that accepts or amends that ADR. A decision recorded under the owner's delegation is the owner's ruling for that question only, answered with /driver or /empower in the asking seat's own chat, where the seat decided after an adversarial review and its record quotes the question and the owner's answer; signing or re-signing the register, money, credentials, and irreversible acts stay the owner's in person (owner ruling 2026-10-22, above). An acceptance recorded "under the driver rule" before 2026-10-22 is not a delegation. Rows and ADRs are read at origin/main. | **Prepare everything, then ask once.** Bundle open Class C items into one AskUserQuestion with confidence-marked recommendations. Lander and Watchdog post them as a table in the digest instead. | +| **C. Owner-reserved** | Legal or regulatory acceptance in your name: a register signature or re-signature, a risk acceptance, a deviation. **"Left to the signer" questions.** Money. Credentials, secrets, account settings. Anything git cannot undo, or that touches someone else's work: deleting another session's worktree, force-pushing a shared branch, a real-store migration, a release tag. Branch protection and required contexts. **Weakening a control or a gate.** **Editing the rules that bind the fleet:** CLAUDE.md sections 0, 5, 9 and 11, `docs/roles/GOVERNANCE.md`, SAIDS, SDS, the driver and role skills, korus playbooks, `scripts/hooks/*`, `.claude/settings*.json`, account settings, `.pre-commit-config.yaml`, `.github/workflows/*`, except the tightening and follow-on edits that Class B names. An edit that adds an exemption, loosens a check, or adds a new rule stays here. A re-anchor that changes what the register accepts. Spawning outside the CLAUDE.md section 5 ruling. Publishing outside this repo. New product scope. An open ledger row whose banner verdict is build, and the accepted direction of an ADR whose status records the owner's acceptance, are not new product scope (this plan's section 12), so a Manager picking and splitting such work is a routine plan, Class B with its review. Still Class C: a new direction, meaning work beyond the scope of that row or the accepted direction of that ADR; when it is unclear whether work is inside that scope, it is a new direction and stays the owner's. Also still Class C: at least any part the ADR's status holds back (for example as proposed, gated or deferred) or that was since declined, rejected, superseded or withdrawn, in whole or in part; work a row, an ADR or CLAUDE.md reserves to an owner ruling; and work that also falls under any other entry in this cell, a Class C path included. Scope a session wrote counts only where it traces to an owner turn, or, for a row it filed or widened or a verdict it set, to a defect in main's shipped behaviour. An ADR acceptance or amendment a session recorded counts only where it traces to an owner turn that accepts or amends that ADR. A decision recorded under the owner's delegation is the owner's ruling for that question only, answered with /driver or /empower in the asking seat's own chat, where the seat decided after an adversarial review and its record quotes the question and the owner's answer; signing or re-signing the register, money, credentials, and irreversible acts stay the owner's in person (owner ruling 2026-10-22, above). An acceptance recorded "under the driver rule" before 2026-10-22 is not a delegation. Rows and ADRs are read at origin/main. | **Prepare everything, then ask once.** Bundle open Class C items into one AskUserQuestion with confidence-marked recommendations. Lander and Watchdog post them as a table in the digest instead. | | **D. Blocked by the harness** | The classifier or sandbox refuses a Class A or B action. | Use a legitimate route: another worktree, the checked script, plumbing. If none exists, put the command once in the daily digest, not every turn. **Never route around a Class C stop.** | **Merging is not a class.** It belongs to the Lander alone, under its proof rules. @@ -260,8 +260,12 @@ The section 3 qualifier on new product scope rests on these five records. Words **Section 3 since the approval.** The approved text is the plan as commit `18fbca9c2a` (2026-10-21, *"the AFK-autonomy plan, approved by the owner 2026-10-21"*) holds it. At least these changes to section 3 came after it: - Commit `1b20affcf0` (2026-10-21, on branch `autonomy-plan`; it reached `main` in engine PR 2498, squashed as `a1e3a4b7dd`). The Class B row gained the clause on a hook, gate or settings edit that only tightens an existing control or follows mechanically from an edit the owner already approved, citing the owner correction of 2026-10-21. The Class C row gained *"except the tightening and follow-on edits that Class B names. An edit that adds an exemption, loosens a check, or adds a new rule stays here."* - Engine PR 2871: the Class C row's qualifier on new product scope, which the five records above source. +- Engine PR 3505 (2026-11-30): the Class C row lists `docs/roles/GOVERNANCE.md` beside `CLAUDE.md` + sections 0, 5, 9 and 11, because rules moved there from section 5 under record + d20261130T205934217-adcecf. A Manager made this change as part of the move; the owner did not + approve it. -**What is live:** only the section 3 qualifier, whose wording and limits are the drafting seat's reading of record 3, with the additions of records 4 and 5, not the owner's words. It rests on the owner's R5 exemption for the minimal T4 empower widening, read by the drafting seat as covering the narrowing clauses that bound it (record 1; R5 is ledger ruling R5). That coverage of the narrowing clauses is the drafting seat's reading, not the owner's words. T1, T2 and T3 are not live, except as far as that qualifier carries T3's pick-and-split clause. +**What is live:** the Class C row's listing of `docs/roles/GOVERNANCE.md`, from engine PR 3505 above, applies. Otherwise only the section 3 qualifier is live, and its wording and limits are the drafting seat's reading of record 3, with the additions of records 4 and 5, not the owner's words. It rests on the owner's R5 exemption for the minimal T4 empower widening, read by the drafting seat as covering the narrowing clauses that bound it (record 1; R5 is ledger ruling R5). That coverage of the narrowing clauses is the drafting seat's reading, not the owner's words. T1, T2 and T3 are not live, except as far as that qualifier carries T3's pick-and-split clause. ## Appendix: review record diff --git a/docs/METHOD.md b/docs/METHOD.md index a9d6697713..489716921a 100644 --- a/docs/METHOD.md +++ b/docs/METHOD.md @@ -326,13 +326,14 @@ nothing, which is honest. The day someone allocates it, your citation quietly st unrelated work. If you must gesture at unfiled work, name the subject rather than a number. Where the number exists but has not merged, say that in the same sentence. -**Never arm auto-merge**, unless you are the Lander acting under its 2026-10-07 exception in the -CLAUDE.md section 5 roster. Enqueuing a PR and merging it are BOTH the Lander's, since the +**Never arm auto-merge**, unless you are the Lander acting under its 2026-10-07 exception in +`docs/roles/GOVERNANCE.md`. Enqueuing a PR and merging it are BOTH the Lander's, since the Console's retirement on 2026-09-10. A Manager talks to the Lander and leaves the queue to it. Arming a PR and then pushing to it is a silent race with two outcomes. If the merge fires first, your push is dropped: the PR reads MERGED and the branch stays alive. If the push lands first, a write-access push leaves auto-merge armed, so the new head can merge with no review. Nothing -reports either one. The safeguards are in the 2026-10-07 note under that roster. +reports either one. The safeguards are in the 2026-10-07 note, which moved from `CLAUDE.md` section 5 +to `docs/roles/GOVERNANCE.md` on 2026-11-30. Never announce a hold, a freeze, or a promise about future state. A 2026-08-01 rehearsal of that shape stayed "in force" for hours after its condition had cleared. `main` moved four times underneath @@ -532,8 +533,9 @@ for the current one. Read each block as `CLAUDE.md` at `ddf350e1d0`. There, *above*, *below*, *this file*, *this section*, *this notice* and a bare section number all mean `CLAUDE.md` and its sections, not this page. The ordinals *eighth* and *ninth* follow that file's count, not the count earlier on this -page. Where a block and `CLAUDE.md` now disagree, `CLAUDE.md` wins. The section *Why four of these -rules changed* above holds older history of the same kind. +page. Where a block disagrees with the current rules in `CLAUDE.md` or `docs/roles/GOVERNANCE.md`, +the current rules win. The section *Why four of these rules changed* above holds older history of +the same kind. ### The Console and the Regulator, retired 2026-09-10 and 2026-09-19 @@ -817,7 +819,8 @@ still states, and points here. Link targets were changed so they resolve from `d Read each block as `CLAUDE.md` at `d62308d8be`. There, *above*, *below*, *this file*, *this section* and a bare section number mean `CLAUDE.md` and its sections, not this page. Where a block -and `CLAUDE.md` now disagree, `CLAUDE.md` wins. +disagrees with the current rules in `CLAUDE.md` or `docs/roles/GOVERNANCE.md`, the current rules +win. ### The Manager's dispatch rules, from section 5 @@ -1050,8 +1053,8 @@ two sections above give. `CLAUDE.md` keeps a short form of each rule and points target was changed so it resolves from `docs/`. Read each block as `CLAUDE.md` at `436cf5c657`. There, *above*, *below*, *this bullet* and a bare -section number mean `CLAUDE.md` and its sections, not this page. Where a block and `CLAUDE.md` now -disagree, `CLAUDE.md` wins. +section number mean `CLAUDE.md` and its sections, not this page. Where a block disagrees with the +current rules in `CLAUDE.md` or `docs/roles/GOVERNANCE.md`, the current rules win. ### Three Lander bullets, from section 5 @@ -1149,13 +1152,14 @@ These blocks moved out of `CLAUDE.md` section 5 on 2026-11-28, word for word, to the same change added for the empower added classes 2 to 4: the owner ruled on 2026-11-25 that section 5 has no net growth (fleet wiki note 20261125T205648099Z-vstih0). Each is at least one of a correction notice, an earlier wording, a list item naming a retired rule, evidence for a rule, or a reading of a ruling that no longer binds; every -rule it sat beside stays in `CLAUDE.md`. +rule it sat beside stayed in `CLAUDE.md` at that time. Some of those rules moved to +`docs/roles/GOVERNANCE.md` on 2026-11-30. Only the line breaks and indent were joined. Read each as `CLAUDE.md` at `7a5b150de6d`. There, *this rule*, *this paragraph*, *this read*, *this line*, *that sentence* and *the bold sentence* mean the passage the heading names, and *the next -paragraph* means the one after it in `CLAUDE.md`. Where a block and `CLAUDE.md` now disagree, -`CLAUDE.md` wins. +paragraph* means the one after it in `CLAUDE.md`. Where a block disagrees with the current rules in +`CLAUDE.md` or `docs/roles/GOVERNANCE.md`, the current rules win. ### After *THE LANDER MAY RESOLVE A CONFLICT THAT TOUCHES CODE*, in *The KORUS roster* diff --git a/docs/roles/GOVERNANCE.md b/docs/roles/GOVERNANCE.md new file mode 100644 index 0000000000..48c6a5db8e --- /dev/null +++ b/docs/roles/GOVERNANCE.md @@ -0,0 +1,171 @@ +# Conflict, auto-merge and held-PR repair governance, moved from CLAUDE.md section 5 + +This file holds the Lander's conflict-resolution and auto-merge rules, the auto-merge safeguards, +and the rules for repairing and transferring a held pull request. Every paragraph between a +`moved-verbatim` begin marker and its end marker moved here verbatim, byte for byte, from root +`CLAUDE.md` section 5 on 2026-11-30, under record d20261130T205934217-adcecf. A Manager made this +class C decision under the Owner's delegation of 2026-11-29 (the `empower` skill, *The standing +delegation*). The Owner did not answer this question, and this note is not authority for any other +change. Record d20261201T031319508-c10934 narrowed the move. The move is narrower than the one the +decision's review recommended: the merge bullet under *Branch, commit one layer, open the PR* stayed +in `CLAUDE.md` section 5. + +**These paragraphs bind exactly as `CLAUDE.md` section 5 does.** `CLAUDE.md` section 5 keeps an +index stub at each place they left, listing every lead. + +The Lander reads this file at the start of each session. The Watchdog and every Repair Manager read +it on arrival. Anyone else reads it before an act listed in `CLAUDE.md` section 5's stubs. Anyone +who has read it, or does one of those acts, reads it again after any compaction. + +The reading instructions here, in the stubs and in the role cards are new, because this text no +longer loads with `CLAUDE.md`. They do not change a moved rule or who decides anything. + +Location note, 2026-11-30: a reference to a neighbouring moved paragraph means that paragraph in +this file. The references below name text that stayed in `CLAUDE.md` section 5. At least these: in +the repair-Builder paragraph, *"as the paragraph above says"* about a non-trivial fix names the +paragraph led *"A MANAGER AND THE LANDER MAY SPAWN A SESSION"*; and *"the merge bullet"*, in that +paragraph and in the conflict paragraph, names the merge bullet under *Branch, commit one layer, +open the PR*. Both stay in `CLAUDE.md` section 5. + +## Conflict resolution and auto-merge + + +**THE LANDER MAY RESOLVE A CONFLICT THAT TOUCHES CODE. OWNER RULING 2026-09-29, IN SESSION.** The +owner was told two documents disagreed on this case and answered: *"fix that to allow the Lander to do +so"*. korus `roles/LANDER.md` *4c-quinquies* governs the route. A resolution the Lander wrote itself +still needs its own code review before the merge; the merge bullet under *Branch, commit one layer, +open the PR* says so. + +**The Lander may arm auto-merge in two cases (owner ruling 2026-10-07).** One is a PR into a +`main` that requires the merge queue. The other is a repository with no queue, such as the vault. +In both, re-read the head SHA right before arming, and check that the review covers it. korus +`roles/LANDER.md` *4c* still binds. + +**Safeguards for both cases (Manager decision 2026-10-07; the owner was told).** The added danger +is a push after arming that merges with no review. GitHub's docs name at least two events that +disable auto-merge: a push by an account *"without write permissions"*, and a base-branch switch. +A write-access push is neither, so auto-merge stays armed. The vault's `main` needs no approval. On +the engine, arming while any required context is pending sets a deferred request. **A required +context with no check run on the head yet is pending**, even when every run listed so far is +green. That deferred request is not yet a queue entry, so the same window opens. + +1. Arm only once every required context in branch protection's live list has a COMPLETED, + SUCCESSFUL result on the head you re-read, as a check run or a commit status. Read the list from + the API, never from memory or `.github/required-contexts.txt`. On the engine, run `gh pr merge + --match-head-commit `. On the vault, add `--auto` and the merge-method flag, because gh + refuses a no-queue merge without one when no terminal is attached. Then read back through + GraphQL the PR's `merged`, `mergeQueueEntry` and `autoMergeRequest`, never + `PullRequest.mergeQueue`, which names the target queue whether or not the PR is in it. Merged, + or on the engine an entry with a null `autoMergeRequest`, is the goal. A non-null + `autoMergeRequest`, on either repository, is a deferred request: disarm it, read it back as + null, then wait for the missing context, or triage that context if it went red. Not merged, no + entry and a null request means nothing is queued, for example because the call silently + no-opped, was refused, or the queue evicted the PR. Read the command's output and the checks + again, and re-run only once this step's condition holds. +2. Pin the full 40-character SHA of the head you re-read, since gh refuses a short one. If you + updated the branch, wait for the new head, and confirm it adds only a clean merge of `main`. + Post the pinned SHA on the PR as a comment. On both paths, gh 2.93.0 sends it as + `expectedHeadOid` to `enablePullRequestAutoMerge`. GitHub's schema describes that field only as + *"The expected head OID of the pull request."* Nothing documented says GitHub checks it again + at merge time. +3. After the merge, compare the PR's `headRefOid` to the latest SHA you posted. If they differ by + more than a clean merge of `main`, read what merged, because a queue may have merged the earlier + head. If unreviewed content landed, revert it and send it to code review. This check is the + binding control, whatever the pin does. Nothing runs it for you, so check every PR you armed at + the start of each Lander session. + +Where *4c* tells an author to push again, disarm first with `gh pr merge --disable-auto`, and +read the state back. Once a PR is queued, that command does not remove the entry (korus +`docs/TIPS-AND-TRICKS.md`), so tell the author to wait. A required status check bound to the reviewed SHA would close this gap at the merge gate. +That is a branch-protection change, and it is unfiled. + + +## Repairing a held pull request + + +**The Lander may send a repair Builder subagent to a held PR as soon as the hold is posted** (owner +instruction 2026-11-26, in the Lander's chat: *"Change the rules to allow you and future landers to +be more proactive"*). That sentence named no number. The 30-minute windows and the cap of two +repairs here, and the 30-minute transfer and `hold-ack` expiry in the next paragraph, were set in +the Lander's brief written under that instruction, which the owner directed the Manager to follow +exactly (2026-11-26, in the Manager's chat); the not-live guard's question window in the next +paragraph stays at 2 hours. All of these must hold: the hold names one determinate fix, such as a +doc, a comment, a test, or a code change the hold spells out, and not a question of intent, of an +owner ruling or of behaviour; the hold still names the PR's head, and no author answer since the +hold disputes it; the PR is not queued and has no armed auto-merge request; the PR carries no +unminimized repair-owner marker (next paragraph), since its repairs are then the Repair Manager's; +the PR is not ASVS record content, which stays a Manager's (owner ruling 2026-09-23); and the author +has not answered the hold in the last 30 minutes, with a `hold-ack` (next paragraph), a comment or a +commit. If the author has, the Lander reads that answer on its turn and waits for that author until +30 minutes after it. A commit moves the head, so a repair after one needs a fresh hold at the new +head. The Builder fetches before it pushes, never force-pushes, stops if the head moved, stops at +any refusal, and makes only the fixes the hold names. At most two repairs per PR. A further hold +then follows the next paragraph's ordinary transfer rule, with whatever acknowledgement and not-live +tests that rule sets. Every other non-trivial fix still goes to a spawned Manager session, as the +paragraph above says. Before it merges a repair head, the Lander re-reads the PR's comments since +the hold, and an author objection returns the PR to the author (fleet wiki lesson +20261124T012815379Z-wd9e1o). The Lander merges only once a code-review fork at `xhigh` that the +Lander starts itself, on the repair head, covers it, its tag read with `review_tag.py`; the repair +Builder's own QA does not count. That independent review is what keeps authoring apart from landing. +This paragraph's change left it unchanged, along with the review proof the merge bullet below +requires, and did not change what goes to the owner. **Repairing at once, and the shorter windows in +the next paragraph, raise at least this risk:** an author's own Builder may already be mid-fix on a +held PR that looks quiet. Fleet wiki lesson 20261103T145659705Z-kqwvhx found one on 2 of 4 quiet +PRs, measured under the old 2-hour window, so at once is likely worse. The change removed at least +two checks that also guarded against it, the mail to the author and the live-session test. The +collision controls left include at least the head-moved check that binds repair Builders, which are +briefed with it, the test that the hold still names the head, and the 30-minute answer exception. On +a PR that looks quiet, the last two see nothing; what still bears on this risk there includes at +least the head-moved check, which acts only if the author pushes first. An author's in-flight +Builder is not briefed with that check and may have none. + +**A held PR whose author has not acknowledged the hold within 30 minutes transfers to the Repair +Manager.** The owner ruling of 2026-11-03 adopted the transfer, at 2 hours: asked *"Which tiers do +you want to adopt?"* of the Repair Manager proposal, the owner answered *"Tiers 1 and 2"*. The +paragraph above says where the 30-minute window comes from. This covers a hold the paragraph above +does not take, so the Repair Manager is the spawned Manager that paragraph sends a non-trivial fix +or a hold after its second repair to. An acknowledgement is an author comment or commit; the +`hold-ack` marker `scripts/coord/held_pr_turns.py` reads is its unambiguous form, and since every +seat acts as the owner's GitHub identity, only the original author's comment or commit counts, a +commit its own Builders push included; one from the Lander, another seat or a workflow is not one, +the Lander's branch updates included. A `hold-ack` expires 30 minutes after it while it is still the +original author's newest event since the hold and no commit by the original author has landed since +it (2026-11-26, as the paragraph above says; the earlier 2 hours was decided by the Lander under the +owner's delegation of 2026-11-03, record d20261103T190111765-2aa8b6: asked *"should a hold-ack +expire 2h after it"*, the owner answered *"/driver"*). The hold then counts as unacknowledged, which +`scripts/coord/held_pr_turns.py` shows as the Lander's turn, flagged `ack-expired` only while the +head is unchanged; any other head move already reads as the Lander's turn. A transfer on an expired +`hold-ack` also needs the author to read not live: the author's claim and seat record show no live +session, or the author's transcript ENDS on a question unanswered for more than 2 hours, which +counts as no live session whatever its running state. The 2026-11-26 brief set the 30-minute windows +in this paragraph and none for this one, so it was left at 2 hours (decided by the Manager under the +owner's standing instruction of 2026-10-22). The Lander reads this with `list_events` or korus +`scripts/board/seatstate.py`, and confirms the question is the transcript's last turn rather than an +older orphaned ask. The paragraph above's repair takes no such test. An author commit or ordinary +reply hands the turn back to the Lander, and nothing expires then. The author may also hand the PR +over sooner. The explicit form is a comment whose first line is +``, posted only by the original author session, `` +being its own session id; `scripts/coord/held_pr_turns.py` flags it `author-closed` where its +header says it counts. The script cannot tell which session posted the marker, so the Lander +confirms it against the author's seat record; a flagged PR so confirmed is transfer-eligible at +once, without the +30-minute window or the not-live test, and the transfer's other conditions still hold, at least +the next sentence's and the transfer steps in order (owner approval 2026-11-27, in the Manager's +chat). The PR must not be queued or carry an armed auto-merge request. The Lander spawns one +Manager for repairs in its own CCD instance, so `send_message` can wake it, and keeps it alive, +respawning it if it dies. The transfer is, in order: the hold's URL sent to the Repair Manager with +`send_message` as its brief; no transfer unless the send reports delivered, not queued or an error; +the repair-owner marker `` on the PR, `` being the Repair +Manager's CCD `local_` id copied whole; the hold's URL sent to it again; and mail to the original +author's seat-record worktree where it has one, naming the PR URL and that id. A Repair Manager that +does not find the marker stops and waits to be woken. It never briefs a Builder without the marker +naming it. Minimizing the newest marker, and any older one still unminimized, cancels the transfer +and hands the PR back to the original author. At least stacks, landing order, author intent and +anything already waiting on an owner ruling stay with the original author. Like the Lander and the +Watchdog, the Repair Manager never uses `AskUserQuestion`; an owner question its own repair raises +goes in a table. It never opens a PR, enqueues or merges. Its Builders fetch before they push, never +force-push, stop if the head moved, stop at any refusal, and make only the fixes the hold names; the +paragraph above names the collision risk that leaves. Every repair head it pushes takes the Lander's +own independent review the paragraph above requires, before the merge. The procedure is in korus +`roles/LANDER.md` and `roles/MANAGER.md`. + diff --git a/docs/roles/builder.card.md b/docs/roles/builder.card.md index b496da3374..4096c69df7 100644 --- a/docs/roles/builder.card.md +++ b/docs/roles/builder.card.md @@ -101,6 +101,8 @@ working tree: Read the korus `roles/COMMON.md` first, whichever seat you hold. CLAUDE.md section 5 governs where the two disagree about this repository. +Before a stub-listed act, read `docs/roles/GOVERNANCE.md`. + Apply the driver and empower rules by default; load both skills at session start. While `MEFOR_AFK_KILL` is not `off`, empower is off and the driver rules still apply. See CLAUDE.md section 5. diff --git a/docs/roles/lander.card.md b/docs/roles/lander.card.md index da287a7abb..05b726a131 100644 --- a/docs/roles/lander.card.md +++ b/docs/roles/lander.card.md @@ -26,7 +26,8 @@ rulings 2026-09-21 and 2026-09-23). The row-status flip stays yours. History: `d every required context with a completed green result on the re-read head, `--match-head-commit` on it, its SHA posted on the PR, a `merged`/`mergeQueueEntry`/`autoMergeRequest` readback, and a `headRefOid` check after the merge. A write-access push keeps it armed. Steps: - CLAUDE.md section 5; korus `4c` still binds. + `docs/roles/GOVERNANCE.md`; korus `4c` still binds. Read `docs/roles/GOVERNANCE.md` again after a + compaction and before any stub-listed act. - **Decide which of two deliberate changes to an item survives.** That belongs to the authors, and korus `4c-quinquies` says the same, so both documents agree here. @@ -59,15 +60,17 @@ A tick is a wakeup, not a message. Do not answer it, acknowledge it, or post a s ## On arrival 1. Read `roles/COMMON.md`, then `roles/LANDER.md`, from korus at `origin/main`. -2. Query the fleet wiki for your subject before you act. Cite any note you act on by id; after, +2. Read `docs/roles/GOVERNANCE.md` at the start of each session; it holds the conflict, auto-merge + and held-PR repair rules moved out of CLAUDE.md section 5. +3. Query the fleet wiki for your subject before you act. Cite any note you act on by id; after, write a lesson, decision, gotcha or correction. A miss never blocks. Run korus's wiki scripts by path with the stores CLAUDE.md section 5 names: the defaults fail here. How: korus `roles/WIKI.md`. -3. **Read the queue ENTRY state, not the pull request's.** They disagree, and the entry is the true +4. **Read the queue ENTRY state, not the pull request's.** They disagree, and the entry is the true one. Measured 2026-09-05: evicted entries read `MERGEABLE`/`CLEAN` at PR level with unmoved heads. -4. A queued entry is not a landed change. Say "queued"; say "landed" only on `merged=true`. -5. `mergeStateStatus` is the starting read, never the verdict. +5. A queued entry is not a landed change. Say "queued"; say "landed" only on `merged=true`. +6. `mergeStateStatus` is the starting read, never the verdict. ## Before you claim it works @@ -104,11 +107,9 @@ working tree: git -C show origin/main:roles/LANDER.md Read the korus `roles/COMMON.md` first, whichever seat you hold. **This card states no precedence -rule over korus, because the table it derives from states none.** Measured 2026-09-21 at engine -`origin/main` (`724e17b02`): the string *"section 5 governs"* returns **0** over `CLAUDE.md`, -against a control of **1** for *"KORUS roster"* on the same read, while returning **2** here and -appearing in five sibling cards. **A rule that lives only in a derived summary is not a rule.** The -one disagreement it carried was resolved by owner ruling 2026-09-29; `docs/METHOD.md` keeps it. +rule over korus, because the table it derives from states none.** **A rule that lives only in a +derived summary is not a rule.** The one disagreement it carried was resolved by owner ruling +2026-09-29; `docs/METHOD.md` keeps it. Apply the driver and empower rules by default; load both skills at session start. While `MEFOR_AFK_KILL` is not `off`, empower is off and the driver rules still apply. See CLAUDE.md diff --git a/docs/roles/manager.card.md b/docs/roles/manager.card.md index 8bc45942e9..a12074fb7c 100644 --- a/docs/roles/manager.card.md +++ b/docs/roles/manager.card.md @@ -7,8 +7,8 @@ Life: long-lived, several -- usually one per account. ## You are not a renamed Console -The Console seat was retired 2026-09-10. **It is not a synonym for this seat, and a Console rule does -not transfer.** The differences are the whole design: +The Console seat was retired 2026-09-10. **It is not a synonym for this seat, and a Console rule +does not transfer.** | | the retired Console | you | |---|---|---| @@ -35,7 +35,6 @@ PR count, the merge queue and the merge rate never limit briefing, and no item c PR. Usage limits bind (`COMMON.md`, *The three usage states*). **ASVS record work is yours** (2026-09-23): re-score, prose, reconcile. Brief vault Builders. -You are not the Tracker renamed. ## What it must not do @@ -59,6 +58,8 @@ commit and you do not batch a session's work into one commit. **The merge is the Lander's.** No label blocks it: what blocks a merge is branch protection and the required contexts, nothing else. +Before a stub-listed act, read `docs/roles/GOVERNANCE.md`. + An authority grant that arrives ADDS to what you already hold; it never narrows it. When one arrives, ask whether you already hold more, not what the message covers. @@ -77,6 +78,7 @@ least-privilege spelling is the broken one, which is why it survives review. korus's wiki scripts by path with the stores CLAUDE.md section 5 names: the defaults fail here. How: korus `roles/WIKI.md`. 3. Read the ledger at the vault's `origin/main` before briefing. Here it is a stub. +4. Repair Manager: read `docs/roles/GOVERNANCE.md` on arrival. ## Before you claim it works @@ -108,9 +110,8 @@ working tree: git -C show origin/main:roles/COMMON.md git -C show origin/main:roles/MANAGER.md -Read the korus `COMMON.md` first, whichever seat you hold. CLAUDE.md section 5 governs where the two -disagree about this repository. Where a korus playbook and `COMMON.md` disagree, CLAUDE.md -section 5 says which wins. +CLAUDE.md section 5 wins where `COMMON.md` and it disagree about this repository. Where a korus +playbook and `COMMON.md` disagree, CLAUDE.md section 5 says which wins. Apply the driver and empower rules by default; load both skills at session start. While `MEFOR_AFK_KILL` is not `off`, empower is off and the driver rules still apply. See CLAUDE.md diff --git a/docs/roles/special.card.md b/docs/roles/special.card.md index 0632b105ad..ab5d659224 100644 --- a/docs/roles/special.card.md +++ b/docs/roles/special.card.md @@ -111,7 +111,7 @@ that is not there yet resolves to nothing rather than to an error: git -C show origin/main:roles/SPECIAL.md Read korus `roles/COMMON.md` first, whichever seat you hold. CLAUDE.md section 5 governs where the -two disagree about this repository, and the push authority above is that divergence. +two disagree about this repository, and the push authority above is that divergence. Before a stub-listed act, read `docs/roles/GOVERNANCE.md`. This card carries only what does not expire. Live state -- the current instruction, what it blocks on, item numbers -- belongs in a dated note, never here. diff --git a/docs/roles/watchdog.card.md b/docs/roles/watchdog.card.md index bc9068c537..b638928479 100644 --- a/docs/roles/watchdog.card.md +++ b/docs/roles/watchdog.card.md @@ -66,16 +66,18 @@ because one arrived. ## On arrival 1. Read the korus `roles/COMMON.md`, then `roles/WATCHDOG.md`, at `origin/main`. -2. Query the fleet wiki for your subject before you act. Cite any note you act on by id; after, +2. Read `docs/roles/GOVERNANCE.md` on arrival; it holds the conflict, auto-merge and held-PR repair + rules moved out of CLAUDE.md section 5. +3. Query the fleet wiki for your subject before you act. Cite any note you act on by id; after, write a lesson, decision, gotcha or correction. A miss never blocks. Run korus's wiki scripts by path with the stores CLAUDE.md section 5 names: the defaults fail here. How: korus `roles/WIKI.md`. -3. **Establish the watched seat is alive from two surfaces.** An agent listing can omit a live seat. -4. **Read the watched seat's own stated gates first.** A seat honouring its own gate is doing its +4. **Establish the watched seat is alive from two surfaces.** An agent listing can omit a live seat. +5. **Read the watched seat's own stated gates first.** A seat honouring its own gate is doing its job, not stalling. -5. **Establish what working looks like as a number.** You cannot call a gap abnormal with no +6. **Establish what working looks like as a number.** You cannot call a gap abnormal with no baseline, and you will be asked for one. -6. Arm one control on every detector you intend to publish from. +7. Arm one control on every detector you intend to publish from. ## Before you publish a reading diff --git a/scripts/coord/held_pr_turns.py b/scripts/coord/held_pr_turns.py index 1a3b242271..84ff24dac0 100644 --- a/scripts/coord/held_pr_turns.py +++ b/scripts/coord/held_pr_turns.py @@ -31,7 +31,7 @@ per-run ``isRequired`` needs a PR number argument, which a paginated PR list cannot pass, so here a same-named run from an app the rule does not count is read as speaking for the context, and a context GitHub requires but the list omits is not surfaced. GREEN is advisory: before arming a -merge the Lander still reads the live list, as CLAUDE.md section 5 requires. The vault's and +merge the Lander still reads the live list, as docs/roles/GOVERNANCE.md requires. The vault's and korus's lists are hard-coded below, by the commissioning brief's choice, so they too can lag the server. A required context whose newest run concluded NEUTRAL or SKIPPED counts as green, as ``_pr_checks.PASSING`` and branch protection both read it. A required context with no result on the @@ -103,8 +103,8 @@ AN UNACKNOWLEDGED HOLD EXPIRES 30 MINUTES AFTER IT. A row that would read AUTHOR with ``held`` and without ``acked`` reads LANDER, flagged ``hold-expired`` after ``held``, when the hold is more than -``HOLD_TTL`` (30 minutes) older than the run's ``now``. Nobody answered it, so CLAUDE.md section 5 -makes it the Lander's move: a repair, or a transfer to the Repair Manager. +``HOLD_TTL`` (30 minutes) older than the run's ``now``. Nobody answered it, so +docs/roles/GOVERNANCE.md makes it the Lander's move: a repair, or a transfer to the Repair Manager. AUTHOR's turn only when ALL of these hold: the newest Lander event is a marker hold (a same-second tie with a non-hold Lander event is no hold); the PR's ``headRefOid`` starts with the marker's SHA, @@ -259,14 +259,14 @@ or ``page-cut``, and the row otherwise reads as it would with the marker counted). The script cannot tell which session posted a marker, since every seat posts under one login; -CLAUDE.md section 5 says only the original author session posts one. The session id is read for +docs/roles/GOVERNANCE.md says only the original author session posts one. The session id is read for the shape only, and is not reported. A counting closed marker is set aside as neither a reply nor a Lander event, as an ack is. The PR then reads LANDER, flagged ``author-closed`` after ``held`` (and ``acked`` when an earlier ack stands): the hold stands and the Lander may transfer the PR to the Repair Manager now, with no 30-minute window and no not-live test. It never substitutes for the hold, and it never makes a -repair-owner marker or a REPAIR turn: the transfer steps in CLAUDE.md section 5 still run. Where +repair-owner marker or a REPAIR turn: the transfer steps in docs/roles/GOVERNANCE.md still run. Where the PR is REPAIR's already (a repair-owner marker after the hold), it stays REPAIR's, and the closed marker is set aside. A marker that does not count in ``classify``, an invalid shape or a minimized one included, is an ordinary event, so one after the hold is a reply, except one that diff --git a/scripts/coord/wait-pr.ps1 b/scripts/coord/wait-pr.ps1 index 131e760f48..dc5b7e6645 100644 --- a/scripts/coord/wait-pr.ps1 +++ b/scripts/coord/wait-pr.ps1 @@ -183,7 +183,7 @@ of it on one line is still allowed, because that line has no loop keyword and no `--watch`. WHAT checks-complete CANNOT SEE. A required context with no check run on the head yet is - invisible to a list of the runs that exist (CLAUDE.md section 5, the Lander's safeguard 1). So + invisible to a list of the runs that exist (docs/roles/GOVERNANCE.md, the Lander's safeguard 1). So the required set is read from classic protection and from rulesets, through the same two endpoints scripts/ci/required_contexts.py reads, and every name in it must have reported, matched ordinally, code unit by code unit, so a near-miss name never satisfies it, not even one that diff --git a/tests/test_claude_md_governance_move.py b/tests/test_claude_md_governance_move.py new file mode 100644 index 0000000000..70a0043444 --- /dev/null +++ b/tests/test_claude_md_governance_move.py @@ -0,0 +1,695 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# Copyright (C) 2026 MessageFoundry Foundation, LLC and contributors +"""Two blocks moved from CLAUDE.md section 5 to docs/roles/GOVERNANCE.md intact; the merge bullet stayed. + +On 2026-11-30 (record d20261130T205934217-adcecf) the Lander's conflict-resolution and auto-merge +paragraphs, and the held-PR repair and transfer paragraphs, moved verbatim out of root +``CLAUDE.md`` section 5. Each place they left keeps an index stub. The merge bullet under *Branch, +commit one layer, open the PR* stayed in ``CLAUDE.md``, because it holds rules that bind every seat +and every session must keep loading. The ways this rots silently, each pinned here, every check +with a control that runs it on a changed copy in memory and shows it fails: + + 1. A stub and the moved text drift apart: a lead is renamed, dropped, truncated or listed at the + wrong place, and a reader following a citation lands on nothing. + 2. The moved text, or the merge bullet that stayed, is edited while claiming to be verbatim. Both + are pinned to SHA-256s of the text at engine ``origin/main`` ``78963cedfe1``. + 3. The move stops telling a seat to read the moved rules: a stub instruction, a reading duty, a + finding aid, the header text, a card pointer or the Lander card's five safeguards go missing. + 4. Banned phrases appear in the header or a stub: text saying the standing delegation governs who + decides, or the refusal section an earlier revision carried. + 5. The always-loaded text stops warning that a write-access push leaves auto-merge armed, or + loses the ``--disable-auto`` step, or the cards, METHOD.md or AUTONOMY-PLAN.md stop naming + ``docs/roles/GOVERNANCE.md`` where the Lander's hold of 2026-12-02 asked. + 6. The manager card gains an arrival step beyond its one line scoped to the Repair Manager. +""" + +from __future__ import annotations + +import hashlib +import re +from pathlib import Path + +_REPO = Path(__file__).resolve().parents[1] +CLAUDE_MD = _REPO / "CLAUDE.md" +GOVERNANCE = _REPO / "docs" / "roles" / "GOVERNANCE.md" +METHOD = _REPO / "docs" / "METHOD.md" +CARDS = _REPO / "docs" / "roles" +CI = _REPO / ".github" / "workflows" / "ci.yml" +_GOV = "docs/roles/GOVERNANCE.md" +_THIS = "tests/test_claude_md_governance_move.py" + +#: SHA-256 of the two moved blocks, concatenated in order, LF line endings, computed from +#: ``git show 78963cedfe1:CLAUDE.md``. 11908 bytes. +MOVED_SHA256 = "02d5811a82f3d01bc74f60236cfb39413a0795325362dbb1df2868e3987f3be9" +#: SHA-256 of the merge bullet, from its "- **The merge is the Lander's" line to the line before +#: "- **A PR's merge state", LF line endings, at ``78963cedfe1``. 9704 bytes. +MERGE_BULLET_SHA256 = "57cd6d8323f584457de2aa9faa86ec9e3f68a13179f91cd54b2c541eebcad9b0" +MOVED_BLOCKS = 2 + +#: Every lead each moved block's stub must list, exactly: each bold span, wherever it sits, and the +#: opening clause of the one paragraph that does not open in bold. The SHA pin freezes the blocks, +#: and ``unlisted_bold_leads`` catches a bold lead this literal misses. +REQUIRED_LEADS: tuple[tuple[str, ...], ...] = ( + ( + "**THE LANDER MAY RESOLVE A CONFLICT THAT TOUCHES CODE. OWNER RULING 2026-09-29, IN SESSION.**", + "**The Lander may arm auto-merge in two cases (owner ruling 2026-10-07).**", + "**Safeguards for both cases (Manager decision 2026-10-07; the owner was told).**", + "**A required context with no check run on the head yet is pending**", + "Where *4c* tells an author to push again", + ), + ( + "**The Lander may send a repair Builder subagent to a held PR as soon as the hold is posted**", + "**Repairing at once, and the shorter windows in the next paragraph, raise at least this risk:**", + "**A held PR whose author has not acknowledged the hold within 30 minutes transfers to the " + "Repair Manager.**", + ), +) + +# ---- text the Lander's holds require, quoted from them + +BIND = "bind exactly as if they still stood here" +#: The acts and reading duties in the stub instruction, each one checked on its own. +STUB_ACTS = ( + "arm auto-merge", + "enqueue or merge a PR", + "resolve a conflict as the Lander", + "act on or answer a hold", + "tell an author to push again", + "send or work as a repair Builder", + "or transfer, take over or cancel the transfer of a held PR", +) +STUB_DUTIES = ( + "Read all of `docs/roles/GOVERNANCE.md` before you", + "The Lander reads it at the start of each session", + "the Watchdog and every Repair Manager read it on arrival", + "Anyone who has read it, or does one of these acts, reads it again after any compaction", + "This applies to every seat and every PR author, including Builders, Special and sessions with " + "no role card", +) +STUB_INSTRUCTION = ( + "**These leads are only an index. They leave out conditions and give no permission.** Read all of " + "`docs/roles/GOVERNANCE.md` before you arm auto-merge, enqueue or merge a PR, resolve a conflict as " + "the Lander, act on or answer a hold, tell an author to push again, send or work as a repair " + "Builder, or transfer, take over or cancel the transfer of a held PR. Role cards call these the " + "stub-listed acts. The Lander reads it at the start of each session, and the Watchdog and every " + "Repair Manager read it on arrival. Anyone who has read it, or does one of these acts, reads it " + "again after any compaction. This applies to every seat and every PR author, including Builders, " + "Special and sessions with no role card." +) +FIRST_STUB_AFTER = ( + "The two auto-merge cases, the safeguards and the full 2026-09-29 conflict ruling that this " + "section cites are in that file." +) +REPAIR_BEFORE = ( + "The owner's instruction of 2026-11-26, which the merge bullet says is quoted in the " + "repair-Builder paragraph above, is quoted in that file. The paragraph below does not quote it." +) +REPAIR_AND_AUTHOR = ( + "**A repair Builder** fetches before it pushes, never force-pushes, stops if the head moved, " + "stops at any refusal, and makes only the fixes the hold names. **The author of a held PR** must " + "read the full `hold-ack`, 30-minute transfer and `author-session-closed` rules there before " + "replying." +) +HEADER_TEXT = ( + "# Conflict, auto-merge and held-PR repair governance, moved from CLAUDE.md section 5", + "under the Owner's delegation of 2026-11-29 (the `empower` skill, *The standing delegation*). The " + "Owner did not answer this question, and this note is not authority for any other change. Record " + "d20261201T031319508-c10934 narrowed the move.", + "**These paragraphs bind exactly as `CLAUDE.md` section 5 does.**", + "The Lander reads this file at the start of each session. The Watchdog and every Repair Manager " + "read it on arrival. Anyone else reads it before an act listed in `CLAUDE.md` section 5's stubs. " + "Anyone who has read it, or does one of those acts, reads it again after any compaction.", + "The reading instructions here, in the stubs and in the role cards are new, because this text no " + "longer loads with `CLAUDE.md`. They do not change a moved rule or who decides anything.", + "Location note, 2026-11-30: a reference to a neighbouring moved paragraph means that paragraph in " + "this file. The references below name text that stayed in `CLAUDE.md` section 5. At least these: in", +) +METHOD_TEXT = ( + "its 2026-10-07 exception in `docs/roles/GOVERNANCE.md`.", + "which moved from `CLAUDE.md` section 5 to `docs/roles/GOVERNANCE.md` on 2026-11-30.", + "every rule it sat beside stayed in `CLAUDE.md` at that time. Some of those rules moved to " + "`docs/roles/GOVERNANCE.md` on 2026-11-30.", + "Where a block disagrees with the current rules in `CLAUDE.md` or `docs/roles/GOVERNANCE.md`, " + "the current rules win.", +) +#: The push warning and disarm step every session must still load, so they stay in CLAUDE.md, +#: outside both stubs, as well as in the moved text. +ALWAYS_LOADED = ( + "**A write-access push leaves auto-merge armed**", + "so a head pushed after arming can merge with no review", + "disarm first with `gh pr merge --disable-auto` and read the state back", + "that command does not remove the entry (korus `docs/TIPS-AND-TRICKS.md`), so tell the author " + "to wait", +) +#: METHOD.md's four "current rules win" lines, each naming GOVERNANCE.md, and the form they replaced. +METHOD_RULES_WIN = ( + "disagrees with the current rules in `CLAUDE.md` or `docs/roles/GOVERNANCE.md`, the current " + "rules win." +) +METHOD_RULES_WIN_COUNT = 4 +METHOD_STALE = "`CLAUDE.md` now disagree, `CLAUDE.md` wins" +AUTONOMY = _REPO / "docs" / "AUTONOMY-PLAN.md" +AUTONOMY_LIVE = ( + "**What is live:** the Class C row's listing of `docs/roles/GOVERNANCE.md`, from engine PR 3505 " + "above, applies." +) +CARD_POINTER = "Before a stub-listed act, read `docs/roles/GOVERNANCE.md`." +ARRIVAL_STEP = { + "lander": "2. Read `docs/roles/GOVERNANCE.md` at the start of each session; it holds the conflict, " + "auto-merge and held-PR repair rules moved out of CLAUDE.md section 5.", + "watchdog": "2. Read `docs/roles/GOVERNANCE.md` on arrival; it holds the conflict, auto-merge and " + "held-PR repair rules moved out of CLAUDE.md section 5.", +} +#: The manager card's one arrival line, scoped to the Repair Manager, in its On arrival section. +#: Apart from it and CARD_POINTER, the manager card may not name the file at all, in any case, so +#: no generic Manager arrival step can be worded past the check. +REPAIR_MANAGER_ARRIVAL = "4. Repair Manager: read `docs/roles/GOVERNANCE.md` on arrival." +_ON_ARRIVAL = "## On arrival" +LANDER_REREAD = ( + "Read `docs/roles/GOVERNANCE.md` again after a compaction and before any stub-listed act." +) +LANDER_SAFEGUARDS = ( + "every required context with a completed green result on the re-read head", + "`--match-head-commit` on it", + "its SHA posted on the PR", + "a `merged`/`mergeQueueEntry`/`autoMergeRequest` readback", + "a `headRefOid` check after the merge", +) +#: Phrases banned from the header and the stubs. +BANNED = ("governs who decides", "standing delegation governs", "Refusal-affected work") + +_MARKER = "moved verbatim to [`docs/roles/GOVERNANCE.md`](docs/roles/GOVERNANCE.md)" +#: Each stub runs from its marker line to the paragraph that follows it in CLAUDE.md. +_STUB_ENDS = ("**ASVS record work is a Manager's", "**Every seat but Special runs") +_BLOCK = re.compile( + r"\n(.*?)", re.DOTALL +) +_LIST_ITEM = re.compile(r"^(\s*)- (.+)$") +# A bold span, which may hold a single-asterisk italic such as *"Sign R1-R9"*. +_BOLD = re.compile(r"\*\*(?:(?!\*\*).)+\*\*") +# How far past the marker a stub's wrapped prose may run before its list must start. +_STUB_SPAN = 16 +# A moved sentence shorter than this may be ordinary prose CLAUDE.md legitimately repeats. +_MIN_LINE = 60 +_MERGE_START = "- **The merge is the Lander's, and NO LABEL BLOCKS IT.**" +_MERGE_END = "- **A PR's merge state is a join over clocks.**" + + +def _read(path: Path) -> str: + # Text mode folds a Windows checkout's CRLF to LF, so the pins are checkout-independent. + return path.read_text(encoding="utf-8") + + +def _fold(text: str) -> str: + """Whitespace folded to single spaces, so wrapping and indent never decide a match.""" + return " ".join(text.split()) + + +def _sha(text: str) -> str: + return hashlib.sha256(text.encode("utf-8")).hexdigest() + + +def stubs(claude: str) -> list[list[str]]: + """The leads each stub in CLAUDE.md lists, one list per stub in file order.""" + lines = claude.splitlines() + found: list[list[str]] = [] + for i, line in enumerate(lines): + if _MARKER not in line: + continue + entries: list[str] = [] + j = i + 1 + while j < min(len(lines), i + _STUB_SPAN) and not _LIST_ITEM.match(lines[j]): + j += 1 + first = _LIST_ITEM.match(lines[j]) if j < len(lines) else None + assert first, f"stub at line {i + 1} lists no leads within {_STUB_SPAN} lines" + # Only the stub's own list: a sibling bullet at another indent ends it. + indent = first.group(1) + while j < len(lines) and (m := _LIST_ITEM.match(lines[j])) and m.group(1) == indent: + entries.append(m.group(2).strip()) + j += 1 + found.append(entries) + return found + + +def stub_entries(claude: str) -> list[str]: + return [entry for stub in stubs(claude) for entry in stub] + + +def stub_texts(claude: str) -> list[str]: + """Each stub's whole folded text, from its marker line up to the paragraph that ends it.""" + out = [] + start = 0 + for end_lead in _STUB_ENDS: + marker = claude.find(_MARKER, start) + para = claude.rfind("\n\n", 0, marker) + 2 if marker >= 0 else -1 + end = claude.find(end_lead, marker) if marker >= 0 else -1 + out.append(_fold(claude[para:end]) if 0 <= para < end else "") + start = max(end, start) + return out + + +def governance_header(governance: str) -> str: + return _fold(governance.split("", 1)[0]) + + +def moved_blocks(governance: str) -> list[str]: + return [m.group(2) for m in _BLOCK.finditer(governance)] + + +def merge_bullet(claude: str) -> str: + """The merge bullet as CLAUDE.md holds it, or "" when it is not there whole.""" + start = claude.find(_MERGE_START) + end = claude.find(_MERGE_END) + return claude[start:end] if 0 <= start < end else "" + + +# ---- checks: each returns its problems, so a control can run it on a changed copy + + +def pin_problems(claude: str, governance: str) -> list[str]: + problems = [] + blocks = moved_blocks(governance) + if len(blocks) != MOVED_BLOCKS: + problems.append(f"{_GOV} holds {len(blocks)} moved blocks, not {MOVED_BLOCKS}") + if claude.count(_MARKER) != MOVED_BLOCKS: + problems.append(f"CLAUDE.md has {claude.count(_MARKER)} stub markers, not {MOVED_BLOCKS}") + if _sha("".join(blocks)) != MOVED_SHA256: + problems.append( + f"the moved text in {_GOV} changed. It moved verbatim, so an edit must change " + "MOVED_SHA256 and REQUIRED_LEADS in the same commit, deliberately, and must also correct " + f"{_GOV}'s header, which says the text moved byte for byte" + ) + bullet = merge_bullet(claude) + if _sha(bullet) != MERGE_BULLET_SHA256: + problems.append( + "the merge bullet in CLAUDE.md changed. Check that change first: it binds every seat and " + "stayed in CLAUDE.md on purpose. Only then update MERGE_BULLET_SHA256" + ) + if bullet and _fold(bullet)[:200] in _fold(governance): + problems.append(f"the merge bullet is repeated in {_GOV}") + return problems + + +def mismatches(claude: str, governance: str) -> list[str]: + """Every way the stubs and the moved text fail to index each other. Empty means they agree. + + Stub N indexes block N, so an entry listed at the wrong place is reported too. + """ + problems = [] + listed = stubs(claude) + blocks = moved_blocks(governance) + if len(listed) != len(blocks): + problems.append(f"CLAUDE.md has {len(listed)} stubs for {len(blocks)} moved blocks") + for n, (entries, block, required) in enumerate( + zip(listed, blocks, REQUIRED_LEADS, strict=False), 1 + ): + folded = _fold(block) + for lead in required: + if folded.count(lead) != 1: + problems.append( + f"lead found {folded.count(lead)} times in block {n}, not once: {lead}" + ) + if entries.count(lead) != 1: + problems.append(f"moved lead has no single CLAUDE.md stub entry: {lead[:80]}") + for entry in entries: + if entry not in required: + problems.append( + f"stub {n} entry is not an exact lead of block {n} in {_GOV}: {entry}" + ) + return problems + + +def unlisted_bold_leads(governance: str) -> list[str]: + """Bold spans in a moved block that REQUIRED_LEADS does not name, so no stub must index them.""" + return [ + span + for block, required in zip(moved_blocks(governance), REQUIRED_LEADS, strict=False) + for span in _BOLD.findall(_fold(block)) + if span not in required + ] + + +def moved_lines_still_in(claude: str, blocks: list[str]) -> list[str]: + """Moved sentences of at least ``_MIN_LINE`` characters that CLAUDE.md still carries. + + Both sides are whitespace-folded, so a re-paste is caught however it is wrapped. A sentence + that is part of a stub entry is the index itself, not a re-paste. + """ + in_claude = _fold(claude) + entries = stub_entries(claude) + found = [] + for block in blocks: + for sentence in _fold(block).split(". "): + if len(sentence) < _MIN_LINE or any(sentence in e for e in entries): + continue + if sentence in in_claude: + found.append(sentence) + return found + + +def telling_problems(claude: str, governance: str, method: str) -> list[str]: + """Every required telling that is absent from the stubs, the header or METHOD.md.""" + return ( + stub_telling_problems(stub_texts(claude)) + + header_telling_problems(governance) + + method_telling_problems(method) + ) + + +def stub_telling_problems(texts: list[str]) -> list[str]: + """What each folded stub text must say: the bind line, the instruction, every act and duty.""" + problems = [] + for n, text in enumerate(texts, 1): + if not text: + problems.append(f"stub {n} not found") + continue + if BIND not in text: + problems.append(f"stub {n} lacks '{BIND}'") + if _fold(STUB_INSTRUCTION) not in text: + problems.append(f"stub {n} lacks the read-the-rules instruction") + problems += [f"stub {n} lacks act: {a}" for a in STUB_ACTS if a not in text] + problems += [f"stub {n} lacks duty: {d}" for d in STUB_DUTIES if d not in text] + if len(texts) == MOVED_BLOCKS: + after_first = _fold(f"- {REQUIRED_LEADS[0][-1]} {FIRST_STUB_AFTER}") + if after_first not in texts[0]: + problems.append("the first stub lacks the finding aid after its list") + after_repair = _fold(f"- {REQUIRED_LEADS[1][-1]} {REPAIR_BEFORE} {REPAIR_AND_AUTHOR}") + if after_repair not in texts[1]: + problems.append( + "the repair stub lacks the 2026-11-26 aid or the repair and author text" + ) + else: + problems.append(f"found {len(texts)} stubs, not {MOVED_BLOCKS}") + return problems + + +def always_loaded_problems(claude: str) -> list[str]: + """The push warning and disarm step, each once in CLAUDE.md and in neither stub.""" + folded = _fold(claude) + texts = stub_texts(claude) + return [ + f"CLAUDE.md lacks, outside the stubs: {a[:60]}" + for a in ALWAYS_LOADED + if folded.count(a) != 1 or any(a in t for t in texts) + ] + + +def header_telling_problems(governance: str) -> list[str]: + header = governance_header(governance) + return [f"{_GOV} header lacks: {h[:60]}" for h in HEADER_TEXT if _fold(h) not in header] + + +def method_telling_problems(method: str) -> list[str]: + folded = _fold(method) + problems = [f"METHOD.md lacks: {m[:60]}" for m in METHOD_TEXT if _fold(m) not in folded] + if folded.count(METHOD_RULES_WIN) != METHOD_RULES_WIN_COUNT: + problems.append( + f"METHOD.md has {folded.count(METHOD_RULES_WIN)} lines naming GOVERNANCE.md as current " + f"rules, not {METHOD_RULES_WIN_COUNT}" + ) + if METHOD_STALE in folded: + problems.append("METHOD.md still says only CLAUDE.md wins") + return problems + + +def autonomy_problems(plan: str) -> list[str]: + if _fold(AUTONOMY_LIVE) in _fold(plan): + return [] + return ["AUTONOMY-PLAN.md 'What is live' does not say the GOVERNANCE.md listing applies"] + + +def card_problems(cards: dict[str, str]) -> list[str]: + problems = [] + folded = {name: _fold(text) for name, text in cards.items()} + for name in ("builder", "manager", "special"): + if CARD_POINTER not in folded[name]: + problems.append(f"{name} card lacks the pointer") + for name, step in ARRIVAL_STEP.items(): + if _fold(step) not in folded[name]: + problems.append(f"{name} card lacks the arrival step") + manager = folded["manager"] + arrival = manager.split(_ON_ARRIVAL, 1)[1].split(" ## ", 1)[0] if _ON_ARRIVAL in manager else "" + if manager.count(REPAIR_MANAGER_ARRIVAL) != 1 or REPAIR_MANAGER_ARRIVAL not in arrival: + problems.append("manager card lacks the one Repair Manager arrival line") + rest = manager.replace(REPAIR_MANAGER_ARRIVAL, "", 1).replace(CARD_POINTER, "", 1) + if "governance.md" in rest.lower(): + problems.append("manager card has an arrival step") + if LANDER_REREAD not in folded["lander"]: + problems.append("lander card lacks the reread line") + problems += [ + f"lander card lacks safeguard: {s}" for s in LANDER_SAFEGUARDS if s not in folded["lander"] + ] + return problems + + +def banned_in(claude: str, governance: str) -> list[str]: + places = {"header": governance_header(governance)} + places.update({f"stub {n}": t for n, t in enumerate(stub_texts(claude), 1)}) + return [f"{where}: {p}" for where, text in places.items() for p in BANNED if p in text] + + +def doc_guards(ci: str) -> list[str]: + m = re.search(r'DOC_GUARDS="([^"]+)"', ci) + return m.group(1).split() if m else [] + + +def _cards() -> dict[str, str]: + names = ("builder", "lander", "manager", "special", "watchdog") + return {n: _read(CARDS / f"{n}.card.md") for n in names} + + +# ---- pins + + +def test_the_pins_hold() -> None: + assert len(REQUIRED_LEADS) == MOVED_BLOCKS + assert pin_problems(_read(CLAUDE_MD), _read(GOVERNANCE)) == [] + + +def test_each_pin_fails_on_a_changed_copy() -> None: + claude, gov = _read(CLAUDE_MD), _read(GOVERNANCE) + changed_block = gov.replace("governs the route.", "governs the route, mostly.", 1) + # A sentence in the bullet's body, well away from its first and last lines. + body = "the holds below are the Lander's own." + assert claude.count(body) == 1 + changed_bullet = claude.replace(body, "the holds below are the Lander's, mostly.", 1) + one_block = re.sub( + r".*?", "", gov, flags=re.S + ) + extra_marker = claude + "\n" + _MARKER + "\n" + with_bullet = gov + "\n" + merge_bullet(claude) + for label, (c, g), expect in ( + ("moved block edited", (claude, changed_block), "MOVED_SHA256"), + ("merge bullet body edited", (changed_bullet, gov), "MERGE_BULLET_SHA256"), + ("a block removed", (claude, one_block), "moved blocks, not"), + ("an extra marker", (extra_marker, gov), "stub markers, not"), + ("merge bullet repeated", (claude, with_bullet), "repeated in"), + ): + assert c != claude or g != gov, label + assert any(expect in p for p in pin_problems(c, g)), label + + +# ---- the index + + +def test_stubs_and_moved_text_index_each_other() -> None: + assert mismatches(_read(CLAUDE_MD), _read(GOVERNANCE)) == [] + assert unlisted_bold_leads(_read(GOVERNANCE)) == [] + + +def test_index_controls() -> None: + claude, gov = _read(CLAUDE_MD), _read(GOVERNANCE) + end = "" + added = gov.replace(end, "**A new ruling binds here.**\n" + end) + assert unlisted_bold_leads(added) == ["**A new ruling binds here.**"] + arm = REQUIRED_LEADS[0][1] + assert mismatches(claude, gov.replace(arm, "**Auto-merge.**")), "lead removed from block" + held = REQUIRED_LEADS[1][2] + assert mismatches(claude.replace(f"- {held}\n", ""), gov), "stub entry removed" + truncated = claude.replace(f"- {held}\n", "- **A held PR whose author\n") + assert any("not an exact lead" in p for p in mismatches(truncated, gov)) + misplaced = claude.replace(f"- {held}\n", "").replace(f"- {arm}\n", f"- {arm}\n- {held}\n") + assert any("not an exact lead of block 1" in p for p in mismatches(misplaced, gov)) + + +def test_the_moved_text_left_claude_md() -> None: + assert moved_lines_still_in(_read(CLAUDE_MD), moved_blocks(_read(GOVERNANCE))) == [] + + +def test_a_re_pasted_paragraph_fails_the_left_check() -> None: + blocks = moved_blocks(_read(GOVERNANCE)) + paragraph = re.split(r"\n\s*\n", blocks[1])[1] + pasted = _read(CLAUDE_MD) + "\n" + _fold(paragraph) + "\n" + assert moved_lines_still_in(pasted, blocks), "a rewrapped re-paste went unreported" + + +# ---- who is told + + +def test_every_seat_is_still_told() -> None: + assert telling_problems(_read(CLAUDE_MD), _read(GOVERNANCE), _read(METHOD)) == [] + assert autonomy_problems(_read(AUTONOMY)) == [] + + +def test_each_telling_fails_when_removed() -> None: + claude, gov, method = _read(CLAUDE_MD), _read(GOVERNANCE), _read(METHOD) + texts = stub_texts(claude) + assert stub_telling_problems(texts) == [] + for n in range(MOVED_BLOCKS): + for phrase in (BIND, *STUB_ACTS, *STUB_DUTIES): + assert phrase in texts[n], (n, phrase) + broken = list(texts) + broken[n] = texts[n].replace(phrase, "") + assert stub_telling_problems(broken), f"stub {n + 1} without: {phrase}" + weakened = claude.replace(BIND, "bind as if they still stood here", 1) + assert any(BIND in p for p in stub_telling_problems(stub_texts(weakened))) + for n, aid in ((0, FIRST_STUB_AFTER), (1, REPAIR_BEFORE), (1, REPAIR_AND_AUTHOR)): + broken = list(texts) + broken[n] = texts[n].replace(_fold(aid), "") + assert broken[n] != texts[n] and stub_telling_problems(broken), aid[:40] + assert stub_telling_problems(texts[:1]), "a missing stub" + for h in HEADER_TEXT: + header = governance_header(gov) + assert _fold(h) in header, h + broken_gov = header.replace(_fold(h), "") + "\n" + assert header_telling_problems(broken_gov), h + for m in METHOD_TEXT: + assert method_telling_problems(_fold(method).replace(_fold(m), "")), m + # Reverting any one of the four lines to the CLAUDE.md-only form fails. + folded = _fold(method) + assert folded.count(METHOD_RULES_WIN) == METHOD_RULES_WIN_COUNT + reverted = folded.replace(f"a block {METHOD_RULES_WIN}", f"a block and {METHOD_STALE}.", 1) + assert reverted != folded and method_telling_problems(reverted) + plan = _read(AUTONOMY) + assert plan.count("from engine PR 3505 above, applies.") == 1 + assert autonomy_problems(plan.replace("from engine PR 3505 above, applies.", "is listed.", 1)) + + +def test_the_push_warning_stays_in_always_loaded_text() -> None: + assert always_loaded_problems(_read(CLAUDE_MD)) == [] + + +def test_the_push_warning_check_fails_when_removed_or_moved_into_a_stub() -> None: + # Mutations run on the raw file, so stub_texts finds the real stub boundaries. + claude = _read(CLAUDE_MD) + start = claude.find(ALWAYS_LOADED[0]) + tail = "before telling an author to push again." + end = claude.find(tail, start) + len(tail) + assert 0 <= start < end - len(tail), "the warning's text was not found" + chunk = claude[start:end] + assert all(a in _fold(chunk) for a in ALWAYS_LOADED) + cut = claude[:start] + claude[end:] + assert always_loaded_problems(cut), "removed" + asvs = "\n\n**ASVS record work" + into_stub_1 = cut.replace(asvs, f"\n{chunk}{asvs}", 1) + every_seat = "\n\n**Every seat but Special runs" + into_stub_2 = cut.replace(every_seat, f"\n{chunk}{every_seat}", 1) + for label, text in (("stub 1", into_stub_1), ("stub 2", into_stub_2)): + assert text != cut, label + assert always_loaded_problems(text), f"moved into {label}" + # Placed outside both stubs, as in the roster's neighbourhood, it passes: the boundary is real. + roster = "\n\n### The KORUS roster" + assert claude.count(roster) == 1 + outside = cut.replace(roster, f"\n\n{chunk}{roster}", 1) + assert always_loaded_problems(outside) == [] + + +def test_every_card_carries_its_pointer_and_the_lander_its_safeguards() -> None: + assert card_problems(_cards()) == [] + + +def test_each_card_check_fails_when_its_text_is_removed() -> None: + cards = {n: _fold(t) for n, t in _cards().items()} + removals = [ + ("builder", CARD_POINTER), + ("manager", CARD_POINTER), + ("special", CARD_POINTER), + ("lander", _fold(ARRIVAL_STEP["lander"])), + ("watchdog", _fold(ARRIVAL_STEP["watchdog"])), + ("lander", LANDER_REREAD), + ("manager", REPAIR_MANAGER_ARRIVAL), + *(("lander", s) for s in LANDER_SAFEGUARDS), + ] + for name, text in removals: + assert text in cards[name], (name, text) + broken = dict(cards, **{name: cards[name].replace(text, "")}) + assert card_problems(broken), f"{name}: {text[:40]}" + with_step = dict( + cards, manager=cards["manager"] + " Read `docs/roles/GOVERNANCE.md` on arrival." + ) + assert "manager card has an arrival step" in card_problems(with_step) + # The allowance is the one scoped line, not the words around it: a lower-case generic step, a + # second copy of the line, and the line with its scope dropped all fail. + for extra in ( + " read `docs/roles/GOVERNANCE.md` on arrival.", + " " + REPAIR_MANAGER_ARRIVAL, + " 5. Every Manager reads `docs/roles/GOVERNANCE.md` on arrival.", + " On arrival, read `docs/roles/GOVERNANCE.md`.", + " Read `docs/roles/GOVERNANCE.md` at the start of each session.", + " Read `docs/roles/GOVERNANCE.md` at session start.", + " Read `docs/roles/GOVERNANCE.md` when you arrive.", + " Read `docs/roles/GOVERNANCE.md` first, before anything else.", + " Read `DOCS/ROLES/GOVERNANCE.MD` too.", + " " + CARD_POINTER, + ): + broken = dict(cards, manager=cards["manager"] + extra) + assert card_problems(broken), extra + # An unscoped step in the On arrival list, with no time word, fails too. + assert cards["manager"].count(REPAIR_MANAGER_ARRIVAL) == 1 + listed = cards["manager"].replace( + REPAIR_MANAGER_ARRIVAL, f"{REPAIR_MANAGER_ARRIVAL} 5. Read `docs/roles/GOVERNANCE.md`.", 1 + ) + assert "manager card has an arrival step" in card_problems(dict(cards, manager=listed)) + unscoped = cards["manager"].replace("Repair Manager: read", "Read", 1) + assert unscoped != cards["manager"] + assert "manager card has an arrival step" in card_problems(dict(cards, manager=unscoped)) + # The scoped line moved out of the On arrival section fails. + moved_out = ( + cards["manager"].replace(REPAIR_MANAGER_ARRIVAL, "", 1) + " " + REPAIR_MANAGER_ARRIVAL + ) + assert "manager card lacks the one Repair Manager arrival line" in card_problems( + dict(cards, manager=moved_out) + ) + # The bare file name the root GOVERNANCE.md shares fails the lander's reread check. + bare = cards["lander"].replace(LANDER_REREAD, LANDER_REREAD.replace("docs/roles/", "", 1)) + assert "lander card lacks the reread line" in card_problems(dict(cards, lander=bare)) + + +# ---- banned phrases in the header and stubs + + +def test_header_and_stubs_carry_no_who_decides_or_refusal_phrase() -> None: + assert banned_in(_read(CLAUDE_MD), _read(GOVERNANCE)) == [] + + +def test_a_banned_phrase_in_the_header_or_any_stub_part_fails_the_check() -> None: + claude, gov = _read(CLAUDE_MD), _read(GOVERNANCE) + planted = "The standing delegation governs who decides. " + header_broken = gov.replace("This file holds", planted + "This file holds", 1) + assert any(p.startswith("header") for p in banned_in(claude, header_broken)) + for n, anchor in ( + (1, "- **THE LANDER MAY RESOLVE"), + (1, "The two auto-merge cases,"), + (2, "- **The Lander may send a repair Builder"), + (2, "**A repair Builder** fetches"), + ): + assert claude.count(anchor) == 1, anchor + broken = claude.replace(anchor, planted + anchor, 1) + assert any(p.startswith(f"stub {n}") for p in banned_in(broken, gov)), anchor + refusal = claude.replace( + "**A repair Builder** fetches", "Refusal-affected work. **A repair Builder** fetches", 1 + ) + assert any("Refusal-affected work" in p for p in banned_in(refusal, gov)) + + +# ---- the doc check stays in the list + + +def test_this_module_runs_on_docs_only_pull_requests() -> None: + assert _THIS in doc_guards(_read(CI)) + + +def test_a_list_without_this_module_fails_the_check() -> None: + ci = _read(CI).replace("\n " + _THIS, "") + assert _THIS not in doc_guards(ci) + assert doc_guards(ci), "the control must still parse the list" diff --git a/tests/tooling_manifest.txt b/tests/tooling_manifest.txt index 45b42daa60..3e9a4f94c8 100644 --- a/tests/tooling_manifest.txt +++ b/tests/tooling_manifest.txt @@ -82,6 +82,7 @@ tests/test_cla_action_patches.py tests/test_cla_action_provenance.py tests/test_claim_check.py tests/test_claim_shared_registry.py +tests/test_claude_md_governance_move.py tests/test_claude_md_review_standards_from_main.py tests/test_claude_md_wiki_state_root.py tests/test_codex_bridge.py