From d394ccf222f3db200db9ead447b626e4a3c63fba Mon Sep 17 00:00:00 2001 From: Scott Hall Date: Mon, 30 Nov 2026 15:20:35 -0600 Subject: [PATCH 01/13] Move Lander merge and held-PR repair rules from CLAUDE.md s5 to docs/roles/GOVERNANCE.md Moved verbatim under decision record d20261130T205934217-adcecf (vault decision log). No ledger row. GOVERNANCE.md holds three moved blocks, byte-identical but for one link target rewritten to resolve from docs/roles/. CLAUDE.md keeps an index stub of leads at each place. Paragraphs binding other seats stayed. New test pins the bytes and the two-way index. Citations of moved text updated in lander.card.md, METHOD.md, held_pr_turns.py, owed_ledger_acts.py, wait-pr.ps1; watchdog card gets the pointer. Proposed PR title: Move the Lander merge and repair rules into docs/roles/GOVERNANCE.md Verified-by: tests --- CLAUDE.md | 256 ++------------------- docs/METHOD.md | 8 +- docs/roles/GOVERNANCE.md | 286 ++++++++++++++++++++++++ docs/roles/lander.card.md | 4 +- docs/roles/watchdog.card.md | 2 + scripts/coord/held_pr_turns.py | 10 +- scripts/coord/owed_ledger_acts.py | 2 +- scripts/coord/wait-pr.ps1 | 2 +- tests/test_claude_md_governance_move.py | 168 ++++++++++++++ tests/tooling_manifest.txt | 1 + 10 files changed, 490 insertions(+), 249 deletions(-) create mode 100644 docs/roles/GOVERNANCE.md create mode 100644 tests/test_claude_md_governance_move.py diff --git a/CLAUDE.md b/CLAUDE.md index 9bd4d1b7a5..cfdb830d47 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -348,54 +348,13 @@ 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 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: + +- **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).** +- Where *4c* tells an author to push again **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 +402,11 @@ 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 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: + +- **The Lander may send a repair Builder subagent to a held PR as soon as the hold is posted** +- **A held PR whose author has not acknowledged the hold within 30 minutes transfers to the Repair Manager.** **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 @@ -727,109 +606,14 @@ Builder, a subagent included, still never waits and puts its question in its rep Builder in its own session, started from a chip or spawned, opens its own PR. Korus `roles/MANAGER.md` holds the rest, in *When to cut a pull request* and *A Builder in its own session opens its own pull request*. -- **The merge is the Lander's, and NO LABEL BLOCKS IT.** What blocks a merge on GitHub includes - branch protection and the required contexts, and no label; the holds below are the Lander's own. - **The Lander checks for PROOF THAT CODE REVIEW RAN on the change (owner ruling 2026-09-29, in - session).** Proof is a code-review tag on the PR, such as the Builder's QA line under the `qa` - label, or other evidence that code review ran against this change. Without it, the Lander sends - the change to code review. The proof must cover the change being merged, so a conflict resolution - the Lander wrote itself needs its own review. The Lander reads what the review found. **The Lander - may merge when none of the open findings changes behaviour or weakens a control, or the owner has - ruled that each one that does may merge, once it has named each open finding on the PR.** The - owner's ruling of 2026-10-12, in session, approved the condition that none changes behaviour or - weakens a control, as part of the Lander's proposal *"Let me merge when the open findings are - filed as rows and none changes behaviour or weakens a control"*. The naming step, and the order - the ledger ruling R2 paragraph below states, replace the proposal's filing-first step. A finding - that changes behaviour or weakens a control still goes to the owner for a ruling. The 2026-10-12 - ruling does not let the Lander skip the review proof, or choose between two authors' deliberate - changes. Nor does it let the Lander decline a finding that names a defect the merge would ship. - Korus `roles/LANDER.md` *4a-quinquies* holds the rest. Where korus still carries a rule this bullet replaced, this bullet is the newer text. The - full text and the owner's words are in [`docs/METHOD.md`](docs/METHOD.md), *CLAUDE.md text moved - in wave 3*. - **Two kinds of behaviour change are the Lander's own, as class B: empower added classes 2 and 3 - (owner instruction and delegation of 2026-11-28, in the Lander's chat; record - d20261129T014004322-8bc82b).** One is a finding whose only change is a visible - refusal or error, where a measured differential against `origin/main` shows the head never worse - on correctness, with no wrong value written, nothing lost or dropped, and nothing `origin/main` - records or counts left unrecorded, and visible refusals and errors no more frequent than on - `origin/main`. The other is a fail-closed tightening that refuses what - `origin/main` allowed, to protect a control: the refusal names its cause and remedy, the refused - input stays where an operator can retry it, no stored data changes, and the docs a deploying site - reads state the refusal and remedy. Neither covers a finding that weakens a security control, a - gate, an alert, an audit record or a PHI rule, false program output, a false control claim in the - unsafe direction, a false score, a false anchor, or a PR that touches register text. The Lander - decides each after an adversarial review, logs it with `scripts/coord/decision.ps1`, posts the - record id on the PR, names each residual there, merges with it open, and then files it under - ledger ruling R2. A proposal to relax a tightening is filed with an open owner line. A failed - or unclear guard, or a split review, sends the finding to the owner. - **A delegated decision counts as the owner's ruling (owner ruling 2026-10-22).** In the owner's words: - *"when I answer a specific question with /driver or /empower, that delegates that question to the - seat that asked it, including questions the empower rules reserve to me. The seat decides after - an adversarial review and records it as "decided under the owner's delegation of ", - quoting the question and my answer. Treat that record as my ruling, and a merge may rest on it. - Still mine in person: signing or re-signing the register, money, credentials, and irreversible - acts."* It covers only the question answered that way, in the asking seat's own chat: starting a - session with either skill delegates nothing, and a peer relaying such an answer is not a record. - Korus `roles/COMMON.md`, *An Owner answer of /driver or /empower delegates that specific - question*, carries the same ruling. A factual error in prose is a filed row, except a false - statement in a security or assurance record about what a control does, a score or an anchor: - that weakens a control, so it goes to the owner under the 2026-10-12 ruling, and the PR waits - for that ruling; only the statement of what a control does has the exception below. A finding - the Lander cannot classify goes to the owner (decision d20261029T165623191-578690). - Korus `roles/LANDER.md` *4a-quinquies* - sends more to the owner, and governs where the two differ: false program output, and a false - control claim in any comment, docstring or doc (the Lander's reading, decision - d20261110T205706609-38b347). Only a statement of what a control does, what it stores, exposes or - retains included, can be false in the safe direction. One that is false only in the safe - direction, in a record or as a control claim in any text, does not weaken a control. It is filed - under ledger ruling R2 below and does not hold the merge. Safe direction means a reader who acts - on the text does more than the control needs, never less. The usual cases are text that overstates - what is stored, exposed or retained, or understates what a control guarantees, but only where - acting on it passes that test: where storing or retaining something is itself the guarantee, - overstating it is the unsafe direction, and understating a guarantee that leads a reader to drop - or bypass the control is unsafe too. What still goes to the owner includes at least false program - output, which changes behaviour, a false score or a false anchor, always, and a present-tense - claim of a live exposure, which section 0 forbids. This narrows the owner's 2026-10-12 ruling, and - what goes to the owner with it. The owner's instruction of 2026-11-26, quoted in the - repair-Builder paragraph above, named no finding; the rule was set in the Lander's brief written - under it, and the owner directed the Manager to follow that brief exactly (2026-11-26, in the - Manager's chat). Register text the owner signs, signed or drafted for signing, is outside the - safe-direction exception: a finding on it never takes that exception's no-hold route, except the - one case below. Every other route in the merge bullet of engine CLAUDE.md section 5 applies as - written, including the owner routes in that exception's own list. Decided by the Lander under the owner's delegation of - 2026-11-26: asked *"Should the safe-direction carve-out exclude register text the owner signs? - Reply A or B"*, the owner answered *"/driver"* (record d20261127T025715932-3a52ad). The case is - empower added class 4, the Lander's own as class B under the owner's instruction of 2026-11-28 - and record d20261129T014004322-8bc82b. A PR - whose code makes a signed line false only in the safe direction, by the test above, may merge - before the owner re-signs, decided and logged as for the two kinds above, if the PR does not - edit, record or put up for signature any register text, and the falsehood is not a false score - or a false anchor. The Lander names the redraft on the PR and files it under ledger ruling R2. A - Manager drafts the corrected text as record work, with a dated marker beside the signed line until - the owner re-signs in person, and re-anchors any anchor the PR only moved, as a mechanical - re-anchor. No seat signs, re-signs or edits the signed text. - **Ledger ruling R2 (owner-signed 2026-11-04, in session: *"Sign R1-R9"*) changes how the findings - are filed, and the Lander reads it as setting when.** A merged PR files at most one row, holding - its open findings as numbered items. Its deferred scope becomes steps on the row it cites, or is - briefed to that row's next Builder, and goes into a new row only when the PR cites none. A finding - about code the PR did not touch goes instead into the one open row for that module, as an item. - The signed text is cited under R5 above. It says *"The merge still never waits on an open finding, - and no finding goes unrecorded."* Decision d20261111T061703900-432f31 reads R2's signed text as - governing the order of filing and merging. The order is: the Lander names each open finding on the - PR, one line each, with its filed row or "queued for filing", naming its subject and pasting no - row text; it merges; it files the queued ones in the next ledger pass, under the sweep in korus - `roles/LANDER.md`, *An item left in a PR comment is yours to carry*. **Filing an open finding - never holds the merge. A finding that goes to the owner holds the merge until the owner rules.** - That last rule is not R2's text. It is the owner's ruling of 2026-11-15, in the Repair Manager's - chat. Asked *"Under ledger ruling R2's 'the merge never waits on an open finding', does a finding - sent to you for a ruling still hold the merge until you rule?"*, the owner answered *"owner - findings still hold the merge"*. The Lander decided the order under the owner's delegation of - 2026-11-11; the decision's record gives the question as *"does CLAUDE.md s5 file-before-merge or - R2 merge-first govern?"* and the owner's answer as *"/driver"*. The authority for this text is the - owner confirmation in the Repair Manager's chat, 2026-11-15: *"Confirmed: fix all 11 findings on - korus PR 270 and whatever engine PR 2891 leaves open, including the edits to engine CLAUDE.md - section 5 and korus roles/LANDER.md, so both repos state one merge order. R5 does not block this - pair."* +- **The merge is the Lander's, and NO LABEL BLOCKS IT.** This bullet + moved verbatim to [`docs/roles/GOVERNANCE.md`](docs/roles/GOVERNANCE.md) on 2026-11-30, + under record d20261130T205934217-adcecf, and binds exactly as if it still stood here. Its leads: + - **The merge is the Lander's, and NO LABEL BLOCKS IT.** + - **The Lander checks for PROOF THAT CODE REVIEW RAN on the change (owner ruling 2026-09-29, in session).** + - **Two kinds of behaviour change are the Lander's own, as class B: empower added classes 2 and 3 (owner instruction and delegation of 2026-11-28, in the Lander's chat; record d20261129T014004322-8bc82b).** + - **A delegated decision counts as the owner's ruling (owner ruling 2026-10-22).** + - **Ledger ruling R2 (owner-signed 2026-11-04, in session: *"Sign R1-R9"*) changes how the findings are filed, and the Lander reads it as setting when.** - **A PR's merge state is a join over clocks.** `mergeStateStatus` is the starting read, never the verdict, because it hides one blocking reason behind another. Gate on `mergeable == CONFLICTING` first: a PR that conflicts after its checks ran keeps them passing but stale. Korus diff --git a/docs/METHOD.md b/docs/METHOD.md index a9d6697713..ec288deb1a 100644 --- a/docs/METHOD.md +++ b/docs/METHOD.md @@ -1104,7 +1104,7 @@ fleet, so never take them*. verbatim: *"Let me merge when the open findings are filed as rows and none changes behaviour or weakens a control. I would still bring you anything that does."* The owner replied, verbatim: *"approved"*, and then: *"make that persistent for future landers"*. That was at about 17:40 - UTC. `CLAUDE.md` section 5 states the rule once, in its merge bullet, so read it there. + UTC. `docs/roles/GOVERNANCE.md` states the rule once, in its merge bullet, so read it there. The reason, as the Lander seat reported it: the same day, three pull requests passed code review but listed small known defects. Examples were code comments that a dependency bump had @@ -1118,7 +1118,7 @@ fleet, so never take them*. **AMENDED 2026-11-04, added after the move (ledger ruling R2, owner-signed in session: *"Sign R1-R9"*).** R2 amends the rulings of 2026-10-12 and 2026-10-31 ("merge, file rows") in their - filing mechanics only: a merged PR now files at most one row. `CLAUDE.md` section 5 states the new + filing mechanics only: a merged PR now files at most one row. `docs/roles/GOVERNANCE.md` states the new mechanics once, at the end of its merge bullet, so read them there. The 2026-10-31 rulings are not recorded in this repository; the vault ledger's banners quote at least the owner's answers *"Merge, file rows (Recommended)"* on engine PRs 2675 and 2676, and *"Merge both, file rows"* on @@ -1131,8 +1131,8 @@ fleet, so never take them*. delegation of 2026-11-11, reads that text as governing the order of filing and merging too, so filing a row no longer holds the merge. A finding that goes to the owner still does, by the owner's ruling of 2026-11-15. So the Lander's proposal quoted under 2026-10-12, which the owner - approved, stays as the record of that day, but no longer states when a row is filed. `CLAUDE.md` - section 5 states the order once, in its merge bullet, with the authority for the change, so read + approved, stays as the record of that day, but no longer states when a row is filed. + `docs/roles/GOVERNANCE.md` states the order once, in its merge bullet, with the authority for the change, so read it there. - **A PR's merge state is a join over clocks, and the join is the part you must not miss.** diff --git a/docs/roles/GOVERNANCE.md b/docs/roles/GOVERNANCE.md new file mode 100644 index 0000000000..02b3f1fe30 --- /dev/null +++ b/docs/roles/GOVERNANCE.md @@ -0,0 +1,286 @@ +# Merge and repair governance, moved from CLAUDE.md section 5 + +This file holds the Lander's merge rules, its auto-merge safeguards and the repair rules for a held +pull request. Every paragraph between a `moved-verbatim` begin marker and its end marker moved here +verbatim from root `CLAUDE.md` section 5 on 2026-11-30, under record d20261130T205934217-adcecf +(vault decision log; decided by the Manager under the owner's delegation of 2026-11-29, after an +adversarial review). It moved byte for byte, but for the one link target noted below. Nothing in +it was reworded or corrected. + +**These paragraphs bind exactly as `CLAUDE.md` section 5 does.** Moving them changed where they are +read, never what they require or whom they bind. `CLAUDE.md` section 5 keeps an index stub at each +place they left, listing every paragraph's lead, so a citation of section 5 resolves here in one +hop. + +**The Lander, the Watchdog and the Repair Manager read this file on arrival.** So does any Manager +acting on a held pull request. + +Read the moved text with these notes, which are not part of it: + +- The quotations of owner rulings and delegated records below that name `CLAUDE.md` section 5 as a + location, at least the owner confirmation of 2026-11-15 in the Repair Manager's chat, the + delegated record d20261127T025715932-3a52ad and the 2026-11-11 delegated question, name + `CLAUDE.md` section 5 because that is where this text stood when they were given (note added + 2026-11-30). They were not altered, and they now refer to the text in this file. +- Some positional references point at paragraphs that stayed in `CLAUDE.md` section 5. At least: + in the repair-Builder paragraph, *"as the paragraph above says"* about a non-trivial fix going to + a spawned Manager session names `CLAUDE.md`'s paragraph led *"A MANAGER AND THE LANDER MAY SPAWN A + SESSION"*; and in the merge bullet, *"cited under R5 above"* names `CLAUDE.md`'s paragraph on + ledger ruling R5. *"The merge bullet"* and *"the merge bullet under Branch, commit one layer, open + the PR"* now name the merge bullet in this file. +- One link target in the merge bullet was rewritten so it resolves from this directory: the + link shown as `docs/METHOD.md` targets `../METHOD.md` here, where `CLAUDE.md` targeted + `docs/METHOD.md`. Its visible text did not change, and no other byte did (note added 2026-11-30). +- Editing the moved text is a deliberate change: `tests/test_claude_md_governance_move.py` pins its + bytes, and a change to them must change that pin in the same commit. + +## 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`. + + +## The merge bullet + + +- **The merge is the Lander's, and NO LABEL BLOCKS IT.** What blocks a merge on GitHub includes + branch protection and the required contexts, and no label; the holds below are the Lander's own. + **The Lander checks for PROOF THAT CODE REVIEW RAN on the change (owner ruling 2026-09-29, in + session).** Proof is a code-review tag on the PR, such as the Builder's QA line under the `qa` + label, or other evidence that code review ran against this change. Without it, the Lander sends + the change to code review. The proof must cover the change being merged, so a conflict resolution + the Lander wrote itself needs its own review. The Lander reads what the review found. **The Lander + may merge when none of the open findings changes behaviour or weakens a control, or the owner has + ruled that each one that does may merge, once it has named each open finding on the PR.** The + owner's ruling of 2026-10-12, in session, approved the condition that none changes behaviour or + weakens a control, as part of the Lander's proposal *"Let me merge when the open findings are + filed as rows and none changes behaviour or weakens a control"*. The naming step, and the order + the ledger ruling R2 paragraph below states, replace the proposal's filing-first step. A finding + that changes behaviour or weakens a control still goes to the owner for a ruling. The 2026-10-12 + ruling does not let the Lander skip the review proof, or choose between two authors' deliberate + changes. Nor does it let the Lander decline a finding that names a defect the merge would ship. + Korus `roles/LANDER.md` *4a-quinquies* holds the rest. Where korus still carries a rule this bullet replaced, this bullet is the newer text. The + full text and the owner's words are in [`docs/METHOD.md`](../METHOD.md), *CLAUDE.md text moved + in wave 3*. + **Two kinds of behaviour change are the Lander's own, as class B: empower added classes 2 and 3 + (owner instruction and delegation of 2026-11-28, in the Lander's chat; record + d20261129T014004322-8bc82b).** One is a finding whose only change is a visible + refusal or error, where a measured differential against `origin/main` shows the head never worse + on correctness, with no wrong value written, nothing lost or dropped, and nothing `origin/main` + records or counts left unrecorded, and visible refusals and errors no more frequent than on + `origin/main`. The other is a fail-closed tightening that refuses what + `origin/main` allowed, to protect a control: the refusal names its cause and remedy, the refused + input stays where an operator can retry it, no stored data changes, and the docs a deploying site + reads state the refusal and remedy. Neither covers a finding that weakens a security control, a + gate, an alert, an audit record or a PHI rule, false program output, a false control claim in the + unsafe direction, a false score, a false anchor, or a PR that touches register text. The Lander + decides each after an adversarial review, logs it with `scripts/coord/decision.ps1`, posts the + record id on the PR, names each residual there, merges with it open, and then files it under + ledger ruling R2. A proposal to relax a tightening is filed with an open owner line. A failed + or unclear guard, or a split review, sends the finding to the owner. + **A delegated decision counts as the owner's ruling (owner ruling 2026-10-22).** In the owner's words: + *"when I answer a specific question with /driver or /empower, that delegates that question to the + seat that asked it, including questions the empower rules reserve to me. The seat decides after + an adversarial review and records it as "decided under the owner's delegation of ", + quoting the question and my answer. Treat that record as my ruling, and a merge may rest on it. + Still mine in person: signing or re-signing the register, money, credentials, and irreversible + acts."* It covers only the question answered that way, in the asking seat's own chat: starting a + session with either skill delegates nothing, and a peer relaying such an answer is not a record. + Korus `roles/COMMON.md`, *An Owner answer of /driver or /empower delegates that specific + question*, carries the same ruling. A factual error in prose is a filed row, except a false + statement in a security or assurance record about what a control does, a score or an anchor: + that weakens a control, so it goes to the owner under the 2026-10-12 ruling, and the PR waits + for that ruling; only the statement of what a control does has the exception below. A finding + the Lander cannot classify goes to the owner (decision d20261029T165623191-578690). + Korus `roles/LANDER.md` *4a-quinquies* + sends more to the owner, and governs where the two differ: false program output, and a false + control claim in any comment, docstring or doc (the Lander's reading, decision + d20261110T205706609-38b347). Only a statement of what a control does, what it stores, exposes or + retains included, can be false in the safe direction. One that is false only in the safe + direction, in a record or as a control claim in any text, does not weaken a control. It is filed + under ledger ruling R2 below and does not hold the merge. Safe direction means a reader who acts + on the text does more than the control needs, never less. The usual cases are text that overstates + what is stored, exposed or retained, or understates what a control guarantees, but only where + acting on it passes that test: where storing or retaining something is itself the guarantee, + overstating it is the unsafe direction, and understating a guarantee that leads a reader to drop + or bypass the control is unsafe too. What still goes to the owner includes at least false program + output, which changes behaviour, a false score or a false anchor, always, and a present-tense + claim of a live exposure, which section 0 forbids. This narrows the owner's 2026-10-12 ruling, and + what goes to the owner with it. The owner's instruction of 2026-11-26, quoted in the + repair-Builder paragraph above, named no finding; the rule was set in the Lander's brief written + under it, and the owner directed the Manager to follow that brief exactly (2026-11-26, in the + Manager's chat). Register text the owner signs, signed or drafted for signing, is outside the + safe-direction exception: a finding on it never takes that exception's no-hold route, except the + one case below. Every other route in the merge bullet of engine CLAUDE.md section 5 applies as + written, including the owner routes in that exception's own list. Decided by the Lander under the owner's delegation of + 2026-11-26: asked *"Should the safe-direction carve-out exclude register text the owner signs? + Reply A or B"*, the owner answered *"/driver"* (record d20261127T025715932-3a52ad). The case is + empower added class 4, the Lander's own as class B under the owner's instruction of 2026-11-28 + and record d20261129T014004322-8bc82b. A PR + whose code makes a signed line false only in the safe direction, by the test above, may merge + before the owner re-signs, decided and logged as for the two kinds above, if the PR does not + edit, record or put up for signature any register text, and the falsehood is not a false score + or a false anchor. The Lander names the redraft on the PR and files it under ledger ruling R2. A + Manager drafts the corrected text as record work, with a dated marker beside the signed line until + the owner re-signs in person, and re-anchors any anchor the PR only moved, as a mechanical + re-anchor. No seat signs, re-signs or edits the signed text. + **Ledger ruling R2 (owner-signed 2026-11-04, in session: *"Sign R1-R9"*) changes how the findings + are filed, and the Lander reads it as setting when.** A merged PR files at most one row, holding + its open findings as numbered items. Its deferred scope becomes steps on the row it cites, or is + briefed to that row's next Builder, and goes into a new row only when the PR cites none. A finding + about code the PR did not touch goes instead into the one open row for that module, as an item. + The signed text is cited under R5 above. It says *"The merge still never waits on an open finding, + and no finding goes unrecorded."* Decision d20261111T061703900-432f31 reads R2's signed text as + governing the order of filing and merging. The order is: the Lander names each open finding on the + PR, one line each, with its filed row or "queued for filing", naming its subject and pasting no + row text; it merges; it files the queued ones in the next ledger pass, under the sweep in korus + `roles/LANDER.md`, *An item left in a PR comment is yours to carry*. **Filing an open finding + never holds the merge. A finding that goes to the owner holds the merge until the owner rules.** + That last rule is not R2's text. It is the owner's ruling of 2026-11-15, in the Repair Manager's + chat. Asked *"Under ledger ruling R2's 'the merge never waits on an open finding', does a finding + sent to you for a ruling still hold the merge until you rule?"*, the owner answered *"owner + findings still hold the merge"*. The Lander decided the order under the owner's delegation of + 2026-11-11; the decision's record gives the question as *"does CLAUDE.md s5 file-before-merge or + R2 merge-first govern?"* and the owner's answer as *"/driver"*. The authority for this text is the + owner confirmation in the Repair Manager's chat, 2026-11-15: *"Confirmed: fix all 11 findings on + korus PR 270 and whatever engine PR 2891 leaves open, including the edits to engine CLAUDE.md + section 5 and korus roles/LANDER.md, so both repos state one merge order. R5 does not block this + pair."* + diff --git a/docs/roles/lander.card.md b/docs/roles/lander.card.md index da287a7abb..b7b9bc2854 100644 --- a/docs/roles/lander.card.md +++ b/docs/roles/lander.card.md @@ -20,13 +20,13 @@ rulings 2026-09-21 and 2026-09-23). The row-status flip stays yours. History: `d - **Merge with no proof that code review ran** (owner, 2026-09-29). With a QA line or review tag you need not review the diff, but read what it found. None: send it to an `Agent` subagent that - runs the `code-review` skill at `xhigh`. Proof must cover the head you merge (CLAUDE.md section 5). + runs the `code-review` skill at `xhigh`. Proof must cover the head you merge (docs/roles/GOVERNANCE.md). - **Arm auto-merge outside two cases** (owner ruling 2026-10-07): a `main` that requires the queue, or a repo with no queue. **Or arm without the safeguards** (Manager decision, same day): 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. - **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. diff --git a/docs/roles/watchdog.card.md b/docs/roles/watchdog.card.md index bc9068c537..816347d2ea 100644 --- a/docs/roles/watchdog.card.md +++ b/docs/roles/watchdog.card.md @@ -65,6 +65,8 @@ because one arrived. ## On arrival +Read docs/roles/GOVERNANCE.md on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. + 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, write a lesson, decision, gotcha or correction. A miss never blocks. Run korus's wiki scripts by 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/owed_ledger_acts.py b/scripts/coord/owed_ledger_acts.py index 1e339a11ad..0412846ec3 100644 --- a/scripts/coord/owed_ledger_acts.py +++ b/scripts/coord/owed_ledger_acts.py @@ -70,7 +70,7 @@ READ, ERROR (a failed read, or no ledger commit before a baseline: a shallow clone), and DONE with ``--all``. -LEDGER RULING R2 (owner-signed 2026-11-04, in session: "Sign R1-R9"; ``CLAUDE.md`` section 5's +LEDGER RULING R2 (owner-signed 2026-11-04, in session: "Sign R1-R9"; ``docs/roles/GOVERNANCE.md``'s merge bullet states it) changes what ``file`` should say, not how it is read. From that date a merged PR files at most one row, so an ask made since then should read ``file=1`` at most. A larger count, from an earlier ask or a mistaken one, is still read as written, and filing asks on one PR 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..9285fcb450 --- /dev/null +++ b/tests/test_claude_md_governance_move.py @@ -0,0 +1,168 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# Copyright (C) 2026 MessageFoundry Foundation, LLC and contributors +"""The merge and repair paragraphs moved from CLAUDE.md section 5 to docs/roles/GOVERNANCE.md intact. + +On 2026-11-30 (record d20261130T205934217-adcecf) the Lander's merge rules, its auto-merge +safeguards and the held-PR repair rules moved verbatim out of root ``CLAUDE.md`` section 5. Each +place they left keeps an index stub listing every moved paragraph's lead, so an existing citation +of section 5 resolves in one hop. Two ways this rots silently, each pinned here: + + 1. A stub and the moved text drift apart: a lead is renamed or dropped on one side, and a reader + following a citation lands on nothing. Both directions are checked, with a positive control. + 2. The moved text is edited while claiming to be verbatim. Its bytes are pinned to the SHA-256 of + the original paragraphs as they stood at engine ``origin/main`` ``78963cedfe1``, so any edit to + them must change the pin in the same commit, deliberately. The one exception is a relative + link target rewritten to resolve from ``docs/roles/``; the check undoes it before hashing. +""" + +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" + +#: SHA-256 of the three moved blocks, concatenated in order, LF line endings, computed from +#: ``git show 78963cedfe1:CLAUDE.md``. 21612 bytes. +MOVED_SHA256 = "1be0e04f8c46e9fe9c6b5f99bb4ef6662247dd3540deff8aadc2fbd797085115" +MOVED_BLOCKS = 3 +# The one byte change the move made, stated in GOVERNANCE.md's header: CLAUDE.md's relative link to +# docs/METHOD.md would resolve to docs/roles/docs/METHOD.md from the new directory. +_ORIGINAL_LINK = "[`docs/METHOD.md`](docs/METHOD.md)" +_RELINKED = "[`docs/METHOD.md`](../METHOD.md)" + +_MARKER = "moved verbatim to [`docs/roles/GOVERNANCE.md`](docs/roles/GOVERNANCE.md)" +_BLOCK = re.compile( + r"\n(.*?)", re.DOTALL +) +_LIST_ITEM = re.compile(r"^(\s*)- (.+)$") +# A stub's lead sentence may wrap; this many non-list lines may sit between it and its list. +_STUB_GAP = 3 + + +def _read(path: Path) -> str: + # Text mode folds a Windows checkout's CRLF to LF, so the pin is checkout-independent. + return path.read_text(encoding="utf-8") + + +def stub_entries(claude: str) -> list[str]: + """Every lead listed under a stub in CLAUDE.md, in file order.""" + lines = claude.splitlines() + entries: list[str] = [] + for i, line in enumerate(lines): + if _MARKER not in line: + continue + j, gap = i + 1, 0 + while j < len(lines) and not _LIST_ITEM.match(lines[j]) and gap < _STUB_GAP: + j, gap = j + 1, gap + 1 + first = _LIST_ITEM.match(lines[j]) if j < len(lines) else None + assert first, f"stub at line {i + 1} lists no leads" + # 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 + return entries + + +def moved_blocks(governance: str) -> list[str]: + return [m.group(2) for m in _BLOCK.finditer(governance)] + + +def _line_starts(text: str) -> list[str]: + """Each line of ``text`` joined to the next two, list marker and whitespace folded. + + A lead can wrap across lines, so a lead matches at a line where this string starts with it. + """ + lines = text.splitlines() + out = [] + for i in range(len(lines)): + if not lines[i].strip(): + continue + joined = " ".join(lines[i : i + 3]).strip() + if joined.startswith("- "): + joined = joined[2:] + out.append(" ".join(joined.split())) + return out + + +def _paragraph_leads(block: str) -> list[str]: + """The opening text of each paragraph in a moved block, list continuations and code skipped.""" + leads = [] + for para in re.split(r"\n\s*\n", block): + if not para.strip() or re.match(r"\d+\. ", para) or para.startswith(" "): + continue + leads.append(" ".join(" ".join(para.splitlines()[:3]).split()).removeprefix("- ")) + return leads + + +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.""" + problems = [] + entries = stub_entries(claude) + if not entries: + problems.append("CLAUDE.md carries no stub entries") + blocks = moved_blocks(governance) + starts = [s for b in blocks for s in _line_starts(b)] + for entry in entries: + hits = sum(s.startswith(entry) for s in starts) + if hits != 1: + problems.append(f"stub lead found {hits} times in GOVERNANCE.md, not once: {entry}") + for block in blocks: + for lead in _paragraph_leads(block): + if not any(lead.startswith(e) for e in entries): + problems.append(f"moved paragraph has no CLAUDE.md stub entry: {lead[:80]}") + return problems + + +def test_governance_holds_every_moved_block() -> None: + assert len(moved_blocks(_read(GOVERNANCE))) == MOVED_BLOCKS + + +def _as_originally_written(moved: str) -> str: + """Undo the one documented deviation: a link target rewritten to resolve from docs/roles/.""" + assert moved.count(_RELINKED) == 1, "the rewritten METHOD.md link is missing or doubled" + return moved.replace(_RELINKED, _ORIGINAL_LINK) + + +def test_moved_text_is_byte_identical_to_the_original() -> None: + moved = _as_originally_written("".join(moved_blocks(_read(GOVERNANCE)))) + assert hashlib.sha256(moved.encode("utf-8")).hexdigest() == MOVED_SHA256, ( + "the moved text in docs/roles/GOVERNANCE.md changed; it moved verbatim, so an edit must " + "change MOVED_SHA256 in the same commit, deliberately" + ) + + +def test_stubs_and_moved_text_index_each_other() -> None: + claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) + assert mismatches(claude, governance) == [] + + +def test_the_moved_text_left_claude_md() -> None: + claude = _read(CLAUDE_MD) + for block in moved_blocks(_read(GOVERNANCE)): + # The block's longest line: absent means the block is too, and a partial re-paste is caught. + body = max(block.splitlines(), key=len) + assert body not in claude, body + + +def test_a_lead_removed_from_governance_fails_the_check() -> None: + """Positive control: the check above must fire when a moved lead disappears.""" + claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) + entry = "**The Lander may arm auto-merge in two cases (owner ruling 2026-10-07).**" + assert entry in stub_entries(claude) + assert governance.count(entry) == 1 + broken = governance.replace(entry, "**Auto-merge.**") + assert any(entry in p for p in mismatches(claude, broken)) + + +def test_a_moved_paragraph_with_no_stub_fails_the_check() -> None: + """Positive control for the reverse direction: a moved lead with no stub entry is reported.""" + claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) + entry = "**A held PR whose author has not acknowledged the hold within 30 minutes transfers to the Repair Manager.**" + broken = claude.replace(f"- {entry}\n", "") + assert broken != claude + assert any("has no CLAUDE.md stub entry" in p for p in mismatches(broken, governance)) 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 From 929f8fff8608ed0998c81ee4166b80fd8d02deee Mon Sep 17 00:00:00 2001 From: Scott Hall Date: Mon, 30 Nov 2026 15:42:47 -0600 Subject: [PATCH 02/13] GOVERNANCE.md move, review round 1: arrival pointers, citations, stronger left-check Record d20261130T205934217-adcecf. - Lander and Manager cards get the arrival pointer; to fit the 6 KB cap the Lander card now names the safeguards by file, and the Manager card drops two redundant phrases. - Citations of moved text updated in Secure_AI_Development_Standards.md, METHOD.md (incl. the 2026-11-28 precedence sentence), WORKTREES.md, claim_check.py. - GOVERNANCE.md notes: quoted passages left as written; bare section numbers mean CLAUDE.md's. - Test: every long moved line is checked absent from CLAUDE.md, with a re-paste control. Correction to the first commit: the merge bullet moved whole, though its delegated-decision and signing sentences bind every seat. Proposed PR title: Move the Lander merge and repair rules into docs/roles/GOVERNANCE.md Verified-by: tests --- docs/METHOD.md | 9 ++++--- docs/Secure_AI_Development_Standards.md | 4 +-- docs/WORKTREES.md | 2 +- docs/roles/GOVERNANCE.md | 12 +++++---- docs/roles/lander.card.md | 9 +++---- docs/roles/manager.card.md | 8 +++--- scripts/hooks/claim_check.py | 2 +- tests/test_claude_md_governance_move.py | 34 +++++++++++++++++++++---- 8 files changed, 54 insertions(+), 26 deletions(-) diff --git a/docs/METHOD.md b/docs/METHOD.md index ec288deb1a..a7326e917a 100644 --- a/docs/METHOD.md +++ b/docs/METHOD.md @@ -87,7 +87,7 @@ Measured 2026-09-05: that context was already absent from live branch protection owner retired the label and the seat rather than restore the gate. **CORRECTED 2026-09-29:** this paragraph read *"Nothing now requires that anyone read a PR before it merges."* Since an owner ruling that day, the Lander merges only on proof that code review ran, or sends the change to code review. -CLAUDE.md section 5 carries the rule. No machine gate beyond the required check set blocks a merge. +`docs/roles/GOVERNANCE.md`, moved from CLAUDE.md section 5, carries the rule. No machine gate beyond the required check set blocks a merge. Nothing in this system gets pushed to anybody. Everything is polled. @@ -332,7 +332,8 @@ Console's retirement on 2026-09-10. A Manager talks to the Lander and leaves the 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 that roster +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 @@ -1155,7 +1156,9 @@ 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. +`CLAUDE.md` wins. Since 2026-11-30 the rules some of these blocks sat beside, at least the +repair-Builder, Repair Manager transfer, auto-merge safeguard and merge-bullet ones, stand in +`docs/roles/GOVERNANCE.md`, and for those blocks that file wins instead. ### After *THE LANDER MAY RESOLVE A CONFLICT THAT TOUCHES CODE*, in *The KORUS roster* diff --git a/docs/Secure_AI_Development_Standards.md b/docs/Secure_AI_Development_Standards.md index 9431d5ec62..a6af416aab 100644 --- a/docs/Secure_AI_Development_Standards.md +++ b/docs/Secure_AI_Development_Standards.md @@ -373,13 +373,13 @@ python -m messagefoundry check # exit-coded validate + dryrun, reused by git-h > **Dial:** T0 self-review → **T1 the review process below, as one unit: an AI code-review pass run by the session that wrote the change, a proof check by the seat that merges, which also reads what the pass found, and the gates. The reviewer is an AI pass, not a human, and no human reads every diff — the [A.6](#a6-documented-deviations) deviation** → T2 + a human reviewer for consequential changes, when a second maintainer exists (else the T1 posture carries up) → **T3 + [team posture] independent human review before production exposure, escalating when a 2nd maintainer joins; until then the T1 posture carries up.** -**No human reads every diff.** Review before a merge is the process in [`../CLAUDE.md`](../CLAUDE.md) section 5. That section is the source of record, so read it there, under *"A Builder runs the checks before it commits, because nobody downstream can ask it to"*, *"Branch, commit one layer, open the PR"* and *"The Manager plans, dispatches, and holds the owner's attention"*. In outline: +**No human reads every diff.** Review before a merge is the process in [`../CLAUDE.md`](../CLAUDE.md) section 5. That section is the source of record, so read it there, under *"A Builder runs the checks before it commits, because nobody downstream can ask it to"*, *"Branch, commit one layer, open the PR"* and *"The Manager plans, dispatches, and holds the owner's attention"*. Its merge bullet and the Lander's repair rules moved verbatim to [`roles/GOVERNANCE.md`](roles/GOVERNANCE.md) on 2026-11-30 and bind as that section does, so where this list says *that section's merge bullet*, read it there. In outline: - **The Builder**, the session that writes the change, runs the `code-review` **skill** on its own diff, at the effort level that section names. This document calls that the AI code-review pass. *CORRECTED 2026-10-07: this read `code-review` **subagent**. `code-review` is a skill, not an agent type, and that section now names it so.* - **The Lander**, the seat that merges, checks for proof that code review ran on the change being merged. With no proof, it sends the change to code review. - The Lander reads what the review found. It may merge when none of the open findings changes behaviour or weakens a control, or the owner has ruled that each one that does may merge, once it has named each open finding on the pull request; that section's merge bullet states the rule, when the rows are filed, and which findings still hold the merge. A finding that changes behaviour or weakens a control goes to the **owner** for a ruling, except the kinds that section's merge bullet lets the Lander decide as class B. *CORRECTED 2026-11-28: this sentence had no exception; that section's merge bullet now names the empower added classes 2 to 4.* *CORRECTED 2026-10-12: this read "A finding that names a defect the merge would ship goes back to the **owner** for a ruling." An owner ruling that day narrowed it, and that section's merge bullet states the rule.* *CORRECTED 2026-11-15: the second sentence of this item read "It may merge when the open findings are filed as rows and none changes behaviour or weakens a control." Filing a row no longer holds the merge; that section's merge bullet records the order and its authority. This correction did not change which findings reach the owner.* - **Required CI contexts and branch protection** gate the merge (§6.5). -- **The owner** rules on what is routed to them. A seat's record of a question the owner answered with `/driver` or `/empower` counts as that ruling when the seat decided after an adversarial review and the record quotes the question and the owner's answer; signing the register, money, credentials and irreversible acts stay the owner's in person. Nothing ties such a record to the owner's chat: every seat writes as one GitHub identity, so a record a session invents cannot be told from a real one, and the seat that merges cannot check it. [`../CLAUDE.md`](../CLAUDE.md) section 5 states it (owner ruling 2026-10-22). The Manager, the seat the owner talks to, waits for the owner's go only on a plan that holds a class C item (§6.2). *CORRECTED 2026-10-22: this read "waits for the owner's go on a plan for anything past a trivial change".* +- **The owner** rules on what is routed to them. A seat's record of a question the owner answered with `/driver` or `/empower` counts as that ruling when the seat decided after an adversarial review and the record quotes the question and the owner's answer; signing the register, money, credentials and irreversible acts stay the owner's in person. Nothing ties such a record to the owner's chat: every seat writes as one GitHub identity, so a record a session invents cannot be told from a real one, and the seat that merges cannot check it. [`roles/GOVERNANCE.md`](roles/GOVERNANCE.md), moved from [`../CLAUDE.md`](../CLAUDE.md) section 5, states it (owner ruling 2026-10-22). The Manager, the seat the owner talks to, waits for the owner's go only on a plan that holds a class C item (§6.2). *CORRECTED 2026-10-22: this read "waits for the owner's go on a plan for anything past a trivial change".* MEFOR runs this one process for the changes its sessions write, whatever tier a change would resolve to (§4.3). At least one path is outside it: the scoped Dependabot auto-merge (A.2) arms its merge on the required CI contexts, and no code-review pass runs on it. diff --git a/docs/WORKTREES.md b/docs/WORKTREES.md index ab8ef965f4..e1f390fecf 100644 --- a/docs/WORKTREES.md +++ b/docs/WORKTREES.md @@ -1073,7 +1073,7 @@ prose, even when it also sends mail: `rows` names rows whose banner is owed; `file` counts new rows to file. Either may be left out. -Under ledger ruling R2 (`CLAUDE.md` section 5) an ask made since 2026-11-04 should say `file=1` at +Under ledger ruling R2 (`docs/roles/GOVERNANCE.md`) an ask made since 2026-11-04 should say `file=1` at most. The script's docstring says how it reads a larger count, and why two `file=1` asks on one PR stay `OWED`. Without the marker the report falls back to a prose read that can miss an ask; what it reads, and diff --git a/docs/roles/GOVERNANCE.md b/docs/roles/GOVERNANCE.md index 02b3f1fe30..394dd5adbf 100644 --- a/docs/roles/GOVERNANCE.md +++ b/docs/roles/GOVERNANCE.md @@ -17,11 +17,13 @@ acting on a held pull request. Read the moved text with these notes, which are not part of it: -- The quotations of owner rulings and delegated records below that name `CLAUDE.md` section 5 as a - location, at least the owner confirmation of 2026-11-15 in the Repair Manager's chat, the - delegated record d20261127T025715932-3a52ad and the 2026-11-11 delegated question, name - `CLAUDE.md` section 5 because that is where this text stood when they were given (note added - 2026-11-30). They were not altered, and they now refer to the text in this file. +- Some passages below name `CLAUDE.md` section 5 as the place this text stands, at least the + owner confirmation of 2026-11-15 in the Repair Manager's chat, the 2026-11-11 delegated question, + and the text decided under record d20261127T025715932-3a52ad. They were written while this text + stood in `CLAUDE.md` section 5, and they were not altered. The text they named now stands in this + file (note added 2026-11-30). +- A bare section number in the moved text, such as *"which section 0 forbids"*, means that section + of root `CLAUDE.md`. - Some positional references point at paragraphs that stayed in `CLAUDE.md` section 5. At least: in the repair-Builder paragraph, *"as the paragraph above says"* about a non-trivial fix going to a spawned Manager session names `CLAUDE.md`'s paragraph led *"A MANAGER AND THE LANDER MAY SPAWN A diff --git a/docs/roles/lander.card.md b/docs/roles/lander.card.md index b7b9bc2854..e7d9e0752a 100644 --- a/docs/roles/lander.card.md +++ b/docs/roles/lander.card.md @@ -20,13 +20,10 @@ rulings 2026-09-21 and 2026-09-23). The row-status flip stays yours. History: `d - **Merge with no proof that code review ran** (owner, 2026-09-29). With a QA line or review tag you need not review the diff, but read what it found. None: send it to an `Agent` subagent that - runs the `code-review` skill at `xhigh`. Proof must cover the head you merge (docs/roles/GOVERNANCE.md). + runs the `code-review` skill at `xhigh`. Proof must cover the head you merge (GOVERNANCE.md). - **Arm auto-merge outside two cases** (owner ruling 2026-10-07): a `main` that requires the queue, or a repo with no queue. **Or arm without the safeguards** (Manager decision, same day): - 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: - docs/roles/GOVERNANCE.md; korus `4c` still binds. + the three steps in GOVERNANCE.md. A write-access push keeps it armed. korus `4c` still binds. - **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. @@ -58,6 +55,8 @@ A tick is a wakeup, not a message. Do not answer it, acknowledge it, or post a s ## On arrival +Read docs/roles/GOVERNANCE.md on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. + 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, write a lesson, decision, gotcha or correction. A miss never blocks. Run korus's wiki scripts by diff --git a/docs/roles/manager.card.md b/docs/roles/manager.card.md index 8bc45942e9..324011f5a5 100644 --- a/docs/roles/manager.card.md +++ b/docs/roles/manager.card.md @@ -56,8 +56,7 @@ commit and you do not batch a session's work into one commit. **Push your own branch and open your own PR, without asking.** Owner ruling 2026-08-29, anchored at `refs/liaison/owner-ruling-20260829-push` (`987705dfb`), in their words: *"Sessions push their own."* -**The merge is the Lander's.** No label blocks it: what blocks a merge is branch protection and the -required contexts, nothing else. +**The merge is the Lander's.** No label blocks it. 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. @@ -71,6 +70,8 @@ least-privilege spelling is the broken one, which is why it survives review. ## On arrival +Read docs/roles/GOVERNANCE.md on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. + 1. Read `COMMON.md`, then `MANAGER.md`, from korus at `origin/main` -- paths below. 2. Query the fleet wiki for the owner's subject and each item before you brief it. Cite any note you act on by id; after, write a lesson, decision, gotcha or correction. A miss never blocks. Run @@ -116,5 +117,4 @@ Apply the driver and empower rules by default; load both skills at session start `MEFOR_AFK_KILL` is not `off`, empower is off and the driver rules still apply. See CLAUDE.md section 5. -This card carries only what does not expire. Live state -- lane counts, throttles, item numbers -- -belongs in a dated note, never here. +Live state -- lane counts, throttles, item numbers -- belongs in a dated note, never here. diff --git a/scripts/hooks/claim_check.py b/scripts/hooks/claim_check.py index bda0fab04b..8ba3bc1e5b 100644 --- a/scripts/hooks/claim_check.py +++ b/scripts/hooks/claim_check.py @@ -42,7 +42,7 @@ `git interpret-trailers --parse` reads from the message counts. Nothing checks the statement and nothing records the advisory, so the trailer is never proof that a -review ran (CLAUDE.md section 5 says what is). It only makes the convention visible before anything +review ran (docs/roles/GOVERNANCE.md says what is). It only makes the convention visible before anything enforces it. It fires wherever this hook is installed, the vault clone included. At least these never print it: `--no-verify`; a box whose ``.git/hooks`` copy predates it; a message the attribution check refuses, since that check exits first; a merge commit (MERGE_HEAD present); a diff --git a/tests/test_claude_md_governance_move.py b/tests/test_claude_md_governance_move.py index 9285fcb450..015ca48a9e 100644 --- a/tests/test_claude_md_governance_move.py +++ b/tests/test_claude_md_governance_move.py @@ -41,6 +41,8 @@ _LIST_ITEM = re.compile(r"^(\s*)- (.+)$") # A stub's lead sentence may wrap; this many non-list lines may sit between it and its list. _STUB_GAP = 3 +# A moved line shorter than this may be ordinary prose CLAUDE.md legitimately repeats. +_MIN_LINE = 60 def _read(path: Path) -> str: @@ -141,12 +143,34 @@ def test_stubs_and_moved_text_index_each_other() -> None: assert mismatches(claude, governance) == [] +def moved_lines_still_in(claude: str, blocks: list[str]) -> list[str]: + """Moved lines of at least ``_MIN_LINE`` characters that CLAUDE.md still carries. + + Every long line is checked, not one per block, so a re-paste of any one paragraph is caught. + """ + claude_lines = {" ".join(ln.split()) for ln in claude.splitlines()} + found = [] + for block in blocks: + for line in block.splitlines(): + folded = " ".join(line.split()) + if len(folded) >= _MIN_LINE and folded in claude_lines: + found.append(folded) + return found + + def test_the_moved_text_left_claude_md() -> None: - claude = _read(CLAUDE_MD) - for block in moved_blocks(_read(GOVERNANCE)): - # The block's longest line: absent means the block is too, and a partial re-paste is caught. - body = max(block.splitlines(), key=len) - assert body not in claude, body + assert moved_lines_still_in(_read(CLAUDE_MD), moved_blocks(_read(GOVERNANCE))) == [] + + +def test_a_re_pasted_paragraph_fails_the_left_check() -> None: + """Positive control: one moved paragraph pasted back into CLAUDE.md is reported.""" + blocks = moved_blocks(_read(GOVERNANCE)) + paragraph = re.split(r"\n\s*\n", blocks[1])[1] + pasted = _read(CLAUDE_MD) + "\n" + paragraph + "\n" + found = moved_lines_still_in(pasted, blocks) + assert found, "a re-pasted moved paragraph went unreported" + long_lines = [ln for ln in paragraph.splitlines() if len(" ".join(ln.split())) >= _MIN_LINE] + assert len(found) == len(long_lines) def test_a_lead_removed_from_governance_fails_the_check() -> None: From 66bdbe560b58a28f16d2985993f0e8098dff410f Mon Sep 17 00:00:00 2001 From: Scott Hall Date: Mon, 30 Nov 2026 16:01:04 -0600 Subject: [PATCH 03/13] GOVERNANCE.md move, review round 2: full card paths, inner-lead index, rewrap-proof left check Record d20261130T205934217-adcecf. - Lander card names docs/roles/GOVERNANCE.md in full: a bare GOVERNANCE.md resolves to the root project-governance doc. Arrival pointers put the path in backticks. - Merge-bullet stub also lists its two mid-line bold rulings (merge condition; owner findings hold the merge). - Test: stub entries match by folded substring; the reverse check covers every bold span opening a line; the left check is sentence-level and rewrap-proof; new inner-lead control. Pin failure says to fix the header. - METHOD.md precedence sentences name the six moved-rule blocks and the merge-bullet history; Secure_AI claims register row cites GOVERNANCE.md. Proposed PR title: Move the Lander merge and repair rules into docs/roles/GOVERNANCE.md Verified-by: tests --- CLAUDE.md | 2 + docs/METHOD.md | 12 ++-- docs/Secure_AI_Development_Standards.md | 2 +- docs/roles/GOVERNANCE.md | 3 +- docs/roles/lander.card.md | 6 +- docs/roles/manager.card.md | 2 +- docs/roles/watchdog.card.md | 2 +- tests/test_claude_md_governance_move.py | 73 ++++++++++++++----------- 8 files changed, 58 insertions(+), 44 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index cfdb830d47..4a65f36b3f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -611,9 +611,11 @@ Builder, a subagent included, still never waits and puts its question in its rep under record d20261130T205934217-adcecf, and binds exactly as if it still stood here. Its leads: - **The merge is the Lander's, and NO LABEL BLOCKS IT.** - **The Lander checks for PROOF THAT CODE REVIEW RAN on the change (owner ruling 2026-09-29, in session).** + - **The Lander may merge when none of the open findings changes behaviour or weakens a control, or the owner has ruled that each one that does may merge, once it has named each open finding on the PR.** - **Two kinds of behaviour change are the Lander's own, as class B: empower added classes 2 and 3 (owner instruction and delegation of 2026-11-28, in the Lander's chat; record d20261129T014004322-8bc82b).** - **A delegated decision counts as the owner's ruling (owner ruling 2026-10-22).** - **Ledger ruling R2 (owner-signed 2026-11-04, in session: *"Sign R1-R9"*) changes how the findings are filed, and the Lander reads it as setting when.** + - **Filing an open finding never holds the merge. A finding that goes to the owner holds the merge until the owner rules.** - **A PR's merge state is a join over clocks.** `mergeStateStatus` is the starting read, never the verdict, because it hides one blocking reason behind another. Gate on `mergeable == CONFLICTING` first: a PR that conflicts after its checks ran keeps them passing but stale. Korus diff --git a/docs/METHOD.md b/docs/METHOD.md index a7326e917a..bfe532da2c 100644 --- a/docs/METHOD.md +++ b/docs/METHOD.md @@ -1052,7 +1052,8 @@ 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. +disagree, `CLAUDE.md` wins; for a block about the merge bullet, which moved to +`docs/roles/GOVERNANCE.md` on 2026-11-30, that file wins. ### Three Lander bullets, from section 5 @@ -1150,15 +1151,16 @@ 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`, and some have since moved on, as below. 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. Since 2026-11-30 the rules some of these blocks sat beside, at least the -repair-Builder, Repair Manager transfer, auto-merge safeguard and merge-bullet ones, stand in -`docs/roles/GOVERNANCE.md`, and for those blocks that file wins instead. +`CLAUDE.md` wins. Since 2026-11-30 the rules six of these blocks sat beside stand in +`docs/roles/GOVERNANCE.md`, and for those blocks that file wins instead: the blocks headed *After THE LANDER MAY RESOLVE A CONFLICT THAT TOUCHES CODE*, *End of the +repair-Builder paragraph*, *End of the Repair Manager transfer paragraph*, the two merge-bullet +blocks and *The Lander auto-merge safeguards*. ### After *THE LANDER MAY RESOLVE A CONFLICT THAT TOUCHES CODE*, in *The KORUS roster* diff --git a/docs/Secure_AI_Development_Standards.md b/docs/Secure_AI_Development_Standards.md index a6af416aab..f0c21e9c45 100644 --- a/docs/Secure_AI_Development_Standards.md +++ b/docs/Secure_AI_Development_Standards.md @@ -736,7 +736,7 @@ MEFOR is an open-source HL7 v2.x integration engine (Python; FastAPI; SQLite/WAL |---|---| | "Built with AI assistance under the Secure AI-Assisted Development Standards." | This doc; PR/commit history; CI history. *(Previously cited `Co-Authored-By` trailers — struck 2026-07-29: measured count zero, §6.7.)* | | "AI-assisted code review as a compensating control for the solo-maintainer review deviation." | A.6; SDS §A.6; the `code-review` pass and its proof on a pull request, where one was posted (§6.6; the proof rule dates from 2026-09-29); blocking CI. | -| "Review before merge is an AI code-review pass plus deterministic gates; no human reads every diff." | §6.6; [`../CLAUDE.md`](../CLAUDE.md) section 5; A.6. | +| "Review before merge is an AI code-review pass plus deterministic gates; no human reads every diff." | §6.6; [`../CLAUDE.md`](../CLAUDE.md) section 5; [`roles/GOVERNANCE.md`](roles/GOVERNANCE.md); A.6. | | "Gates enforce intent deterministically." | `.claude/settings.json`; PreToolUse hook; `security.yml`; `messagefoundry check`. | | ~~"Provenance recorded at commit granularity by convention."~~ **WITHDRAWN 2026-07-29 — do not use this wording.** | The `Co-Authored-By` trailer this rested on is **not in use** — the project turns it off at source, via `attribution` in [`.claude/settings.json`](../.claude/settings.json) — and the cause once recorded here is withdrawn (A.6). Past adoption is not measurable from a shallow clone (§6.7). The defensible replacement claim is: *"There is no per-commit model/version record, and the PR template has no AI-disclosure field."* *CORRECTED 2026-10-02: the replacement claim read "AI involvement is disclosed per PR via the PR template". The template has no such field (A.6).* | | "AI-surfaced security findings are independently (multi-vote) verified before action; the residual risk is control-asymmetry, which is gated only where a deterministic parity check encodes it." | The 2026-06 audit (44 candidates → 26 confirmed); the listener parity guard and its tests (A.2), which is the one such check listed there. *CORRECTED 2026-10-02: the claim ended "addressed by a parity review gate" — do not use that wording. The review-time parity sweep in §6.6 is not a gate: nothing requires it (A.6).* | diff --git a/docs/roles/GOVERNANCE.md b/docs/roles/GOVERNANCE.md index 394dd5adbf..e8991d3940 100644 --- a/docs/roles/GOVERNANCE.md +++ b/docs/roles/GOVERNANCE.md @@ -34,7 +34,8 @@ Read the moved text with these notes, which are not part of it: link shown as `docs/METHOD.md` targets `../METHOD.md` here, where `CLAUDE.md` targeted `docs/METHOD.md`. Its visible text did not change, and no other byte did (note added 2026-11-30). - Editing the moved text is a deliberate change: `tests/test_claude_md_governance_move.py` pins its - bytes, and a change to them must change that pin in the same commit. + bytes, and a change to them must change that pin in the same commit and correct this header, + which says the text was not reworded. ## Conflict resolution and auto-merge diff --git a/docs/roles/lander.card.md b/docs/roles/lander.card.md index e7d9e0752a..ae13d99cd8 100644 --- a/docs/roles/lander.card.md +++ b/docs/roles/lander.card.md @@ -20,10 +20,10 @@ rulings 2026-09-21 and 2026-09-23). The row-status flip stays yours. History: `d - **Merge with no proof that code review ran** (owner, 2026-09-29). With a QA line or review tag you need not review the diff, but read what it found. None: send it to an `Agent` subagent that - runs the `code-review` skill at `xhigh`. Proof must cover the head you merge (GOVERNANCE.md). + runs the `code-review` skill at `xhigh`. Proof must cover the head you merge (`docs/roles/GOVERNANCE.md`). - **Arm auto-merge outside two cases** (owner ruling 2026-10-07): a `main` that requires the queue, or a repo with no queue. **Or arm without the safeguards** (Manager decision, same day): - the three steps in GOVERNANCE.md. A write-access push keeps it armed. korus `4c` still binds. + the three steps in `docs/roles/GOVERNANCE.md`. A write-access push keeps it armed. korus `4c` still binds. - **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. @@ -55,7 +55,7 @@ A tick is a wakeup, not a message. Do not answer it, acknowledge it, or post a s ## On arrival -Read docs/roles/GOVERNANCE.md on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. +Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. 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, diff --git a/docs/roles/manager.card.md b/docs/roles/manager.card.md index 324011f5a5..26f2f59b2c 100644 --- a/docs/roles/manager.card.md +++ b/docs/roles/manager.card.md @@ -70,7 +70,7 @@ least-privilege spelling is the broken one, which is why it survives review. ## On arrival -Read docs/roles/GOVERNANCE.md on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. +Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. 1. Read `COMMON.md`, then `MANAGER.md`, from korus at `origin/main` -- paths below. 2. Query the fleet wiki for the owner's subject and each item before you brief it. Cite any note you diff --git a/docs/roles/watchdog.card.md b/docs/roles/watchdog.card.md index 816347d2ea..1297be89e0 100644 --- a/docs/roles/watchdog.card.md +++ b/docs/roles/watchdog.card.md @@ -65,7 +65,7 @@ because one arrived. ## On arrival -Read docs/roles/GOVERNANCE.md on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. +Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. 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, diff --git a/tests/test_claude_md_governance_move.py b/tests/test_claude_md_governance_move.py index 015ca48a9e..5090d49b8b 100644 --- a/tests/test_claude_md_governance_move.py +++ b/tests/test_claude_md_governance_move.py @@ -74,30 +74,26 @@ def moved_blocks(governance: str) -> list[str]: return [m.group(2) for m in _BLOCK.finditer(governance)] -def _line_starts(text: str) -> list[str]: - """Each line of ``text`` joined to the next two, list marker and whitespace folded. - - A lead can wrap across lines, so a lead matches at a line where this string starts with it. - """ - lines = text.splitlines() - out = [] - for i in range(len(lines)): - if not lines[i].strip(): - continue - joined = " ".join(lines[i : i + 3]).strip() - if joined.startswith("- "): - joined = joined[2:] - out.append(" ".join(joined.split())) - return out +def _fold(text: str) -> str: + """Whitespace folded to single spaces, so wrapping and indent never decide a match.""" + return " ".join(text.split()) def _paragraph_leads(block: str) -> list[str]: - """The opening text of each paragraph in a moved block, list continuations and code skipped.""" + """Every lead a stub must list: each paragraph's opening, and each bold span opening a line. + + List continuations and indented code are skipped. A bold span opening a line inside a long + paragraph, such as the merge bullet's inner rulings, counts as a lead of its own. + """ leads = [] for para in re.split(r"\n\s*\n", block): if not para.strip() or re.match(r"\d+\. ", para) or para.startswith(" "): continue - leads.append(" ".join(" ".join(para.splitlines()[:3]).split()).removeprefix("- ")) + lines = para.splitlines() + leads.append(_fold(" ".join(lines[:3])).removeprefix("- ")) + for i, line in enumerate(lines[1:], 1): + if line.lstrip().startswith("**"): + leads.append(_fold(" ".join(lines[i : i + 3]))) return leads @@ -108,9 +104,9 @@ def mismatches(claude: str, governance: str) -> list[str]: if not entries: problems.append("CLAUDE.md carries no stub entries") blocks = moved_blocks(governance) - starts = [s for b in blocks for s in _line_starts(b)] + folded = _fold("\n".join(blocks)) for entry in entries: - hits = sum(s.startswith(entry) for s in starts) + hits = folded.count(entry) if hits != 1: problems.append(f"stub lead found {hits} times in GOVERNANCE.md, not once: {entry}") for block in blocks: @@ -133,8 +129,9 @@ def _as_originally_written(moved: str) -> str: def test_moved_text_is_byte_identical_to_the_original() -> None: moved = _as_originally_written("".join(moved_blocks(_read(GOVERNANCE)))) assert hashlib.sha256(moved.encode("utf-8")).hexdigest() == MOVED_SHA256, ( - "the moved text in docs/roles/GOVERNANCE.md changed; it moved verbatim, so an edit must " - "change MOVED_SHA256 in the same commit, deliberately" + "the moved text in docs/roles/GOVERNANCE.md changed. It moved verbatim, so an edit must " + "change MOVED_SHA256 in the same commit, deliberately, and must also correct GOVERNANCE.md's " + "header, which says the text was not reworded" ) @@ -144,17 +141,20 @@ def test_stubs_and_moved_text_index_each_other() -> None: def moved_lines_still_in(claude: str, blocks: list[str]) -> list[str]: - """Moved lines of at least ``_MIN_LINE`` characters that CLAUDE.md still carries. + """Moved sentences of at least ``_MIN_LINE`` characters that CLAUDE.md still carries. - Every long line is checked, not one per block, so a re-paste of any one paragraph is caught. + Both sides are whitespace-folded, so a re-paste of any paragraph is caught however it is + wrapped. A sentence that is part of a stub entry is the index itself, not a re-paste. """ - claude_lines = {" ".join(ln.split()) for ln in claude.splitlines()} + in_claude = _fold(claude) + entries = stub_entries(claude) found = [] for block in blocks: - for line in block.splitlines(): - folded = " ".join(line.split()) - if len(folded) >= _MIN_LINE and folded in claude_lines: - found.append(folded) + 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 @@ -167,10 +167,19 @@ 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" + paragraph + "\n" - found = moved_lines_still_in(pasted, blocks) - assert found, "a re-pasted moved paragraph went unreported" - long_lines = [ln for ln in paragraph.splitlines() if len(" ".join(ln.split())) >= _MIN_LINE] - assert len(found) == len(long_lines) + assert moved_lines_still_in(pasted, blocks), "a re-pasted moved paragraph went unreported" + # Rewrapped to one line: the check must not depend on the original line breaks. + rewrapped = _read(CLAUDE_MD) + "\n" + _fold(paragraph) + "\n" + assert moved_lines_still_in(rewrapped, blocks), "a rewrapped re-paste went unreported" + + +def test_an_inner_lead_dropped_from_a_stub_fails_the_check() -> None: + """Positive control: a bold ruling inside the merge bullet must keep its own stub entry.""" + claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) + entry = "**A delegated decision counts as the owner's ruling (owner ruling 2026-10-22).**" + broken = claude.replace(f" - {entry}\n", "") + assert broken != claude + assert any("has no CLAUDE.md stub entry" in p for p in mismatches(broken, governance)) def test_a_lead_removed_from_governance_fails_the_check() -> None: From 689fc78394bc3a192bfcefbe45038d87366c8be8 Mon Sep 17 00:00:00 2001 From: Scott Hall Date: Mon, 30 Nov 2026 16:45:09 -0600 Subject: [PATCH 04/13] GOVERNANCE.md move: Manager decisions (a)-(d), exact two-way index, SAIDS 0.14 Record d20261130T205934217-adcecf; Manager decisions under /driver. - CLAUDE.md merge stub: pointer to the every-seat delegated-decision and signing rules; outer lead no longer repeated; stubs list every bold ruling, mid-line ones included. - AUTONOMY-PLAN class C row names docs/roles/GOVERNANCE.md. - ci.yml DOC_GUARDS runs the new test (list only). - GOVERNANCE.md header quotes the delegation, question and review; every Manager reads it; pointer to the 2026-11-30 refusal-affected-work ruling (d20261130T212032740-ab4069). - Test: entries must equal a whole lead, both ways; full path in messages; truncation and mid-line controls. - SAIDS 0.14 history row; "at least" wording. Card pointer follows "Read COMMON.md first". Proposed PR title: Move the Lander merge and repair rules into docs/roles/GOVERNANCE.md Verified-by: tests --- .github/workflows/ci.yml | 3 +- CLAUDE.md | 8 ++- docs/AUTONOMY-PLAN.md | 2 +- docs/Secure_AI_Development_Standards.md | 9 +-- docs/roles/GOVERNANCE.md | 18 +++-- docs/roles/lander.card.md | 4 +- docs/roles/manager.card.md | 4 +- docs/roles/watchdog.card.md | 4 +- tests/test_claude_md_governance_move.py | 87 ++++++++++++++++--------- 9 files changed, 91 insertions(+), 48 deletions(-) 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 4a65f36b3f..325ed80040 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -354,6 +354,7 @@ on 2026-11-30, under record d20261130T205934217-adcecf, and bind exactly as if t - **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 **ASVS record work is a Manager's, dispatched to vault Builders (owner ruling 2026-09-23).** It @@ -406,6 +407,7 @@ The paragraphs whose leads follow moved verbatim to [`docs/roles/GOVERNANCE.md`] on 2026-11-30, under record d20261130T205934217-adcecf, and bind exactly as if they still stood here: - **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.** **Every seat but Special runs the driver and empower rules.** Each seat except Special applies the @@ -608,8 +610,10 @@ Builder, a subagent included, still never waits and puts its question in its rep session opens its own pull request*. - **The merge is the Lander's, and NO LABEL BLOCKS IT.** This bullet moved verbatim to [`docs/roles/GOVERNANCE.md`](docs/roles/GOVERNANCE.md) on 2026-11-30, - under record d20261130T205934217-adcecf, and binds exactly as if it still stood here. Its leads: - - **The merge is the Lander's, and NO LABEL BLOCKS IT.** + under record d20261130T205934217-adcecf, and binds exactly as if it still stood here. The + delegated-decision ruling, its in-person limits (signing or re-signing the register, money, + credentials, irreversible acts) and 'No seat signs, re-signs or edits the signed text' bind + every seat; their text is in docs/roles/GOVERNANCE.md. Its inner leads: - **The Lander checks for PROOF THAT CODE REVIEW RAN on the change (owner ruling 2026-09-29, in session).** - **The Lander may merge when none of the open findings changes behaviour or weakens a control, or the owner has ruled that each one that does may merge, once it has named each open finding on the PR.** - **Two kinds of behaviour change are the Lander's own, as class B: empower added classes 2 and 3 (owner instruction and delegation of 2026-11-28, in the Lander's chat; record d20261129T014004322-8bc82b).** diff --git a/docs/AUTONOMY-PLAN.md b/docs/AUTONOMY-PLAN.md index 29ee25496e..24bea6bfd5 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. diff --git a/docs/Secure_AI_Development_Standards.md b/docs/Secure_AI_Development_Standards.md index f0c21e9c45..504f06afcc 100644 --- a/docs/Secure_AI_Development_Standards.md +++ b/docs/Secure_AI_Development_Standards.md @@ -12,8 +12,8 @@ | **Applies to** | Any project developed under the Secure Development Standards using an AI coding assistant. **MessageFoundry (MEFOR)** is the reference implementation (Appendix A); future projects add Appendix B, C, … | | **Maintained by** | Project maintainers (open-source). Each deploying/adopting organization assigns its own local owner. | | **Status** | Draft for review | -| **Version** | 0.13 | -| **Date** | November 15, 2026 | +| **Version** | 0.14 | +| **Date** | November 30, 2026 | | **License** | Publishable under the project's open-source license; intended to be shared with adopters and reused across projects. | | **Review cadence** | At least annually, and on **any material change to the AI toolchain or threat model** (a new agent framework, MCP server, Claude Code version, or a new probed attack class). | | **Aligns to** | NIST SP 800-218 (SSDF) **v1.1**: PO.1 / PO.2 / PO.3 / PO.5 / PS.1 / PW.1 / PW.4 / PW.7 / PW.8 / RV.2 — and deliberately **not SP 800-218A**, which profiles organizations *producing* generative-AI and dual-use foundation models, **not** building software *with* an AI assistant; the name is the trap, and it is the wrong document for this one · OWASP ASVS 5.0 Level 3 (V8, V11, V14, V15, V16) · a **five-principle synthesis** distilled from the AI-assisted-development literature (§3, §11 — *not* an external standard) · the project standing contract [`../CLAUDE.md`](../CLAUDE.md) · companion to Secure Development Standards. **Deliberately omits any certification framework** — see §8. | @@ -22,7 +22,7 @@ ## Executive summary -This is the *Secure AI-Assisted Development Standards* — a companion to the Secure Development Standards (SDS) that governs **how the maintainers use Claude Code to BUILD MessageFoundry** (the engineering workflow), without weakening any SDS guarantee. It is explicitly **NOT** the runtime AI assistant the shipped product offers operators; that policy lives in [AI.md](AI.md) and is out of scope here (the two share only the word "AI"). The standard **owns and expands** the SDS §A.6 deviation — *single-maintainer development, with AI-assisted review as a compensating control* — as the detailed record for the solo-maintainer reality, and it aligns to **NIST SP 800-218 (SSDF)** and **OWASP ASVS 5.0 L3** while deliberately conferring **no certification**. **Status: Draft for review, v0.13.** It serves maintainers (the daily loop), adopters and auditors (build-provenance evidence for their own compliance program), and future projects (their own appendix). +This is the *Secure AI-Assisted Development Standards* — a companion to the Secure Development Standards (SDS) that governs **how the maintainers use Claude Code to BUILD MessageFoundry** (the engineering workflow), without weakening any SDS guarantee. It is explicitly **NOT** the runtime AI assistant the shipped product offers operators; that policy lives in [AI.md](AI.md) and is out of scope here (the two share only the word "AI"). The standard **owns and expands** the SDS §A.6 deviation — *single-maintainer development, with AI-assisted review as a compensating control* — as the detailed record for the solo-maintainer reality, and it aligns to **NIST SP 800-218 (SSDF)** and **OWASP ASVS 5.0 L3** while deliberately conferring **no certification**. **Status: Draft for review, v0.14.** It serves maintainers (the daily loop), adopters and auditors (build-provenance evidence for their own compliance program), and future projects (their own appendix). **Why it exists.** It lets a solo maintainer build a PHI-carrying healthcare engine with an AI assistant without weakening the secure-development baseline, and produces auditable build-provenance evidence. Every control traces to one of **five named failure modes (§3):** (1) intent/requirements drift with no auditable intent→code chain; (2) context loss / "context rot" (the model's working context degrading across a long session); (3) long-trajectory error accumulation; (4) the "fast but flawed" speed–quality paradox; and (5) misplaced trust in output. The calibration anchor is the **METR RCT (2025)**: 16 experienced developers on mature repos were measured **~19% SLOWER** with early-2025 AI tooling while forecasting and still believing they were faster — uncontrolled AI assistance is **not automatically** a speed or quality win. @@ -373,7 +373,7 @@ python -m messagefoundry check # exit-coded validate + dryrun, reused by git-h > **Dial:** T0 self-review → **T1 the review process below, as one unit: an AI code-review pass run by the session that wrote the change, a proof check by the seat that merges, which also reads what the pass found, and the gates. The reviewer is an AI pass, not a human, and no human reads every diff — the [A.6](#a6-documented-deviations) deviation** → T2 + a human reviewer for consequential changes, when a second maintainer exists (else the T1 posture carries up) → **T3 + [team posture] independent human review before production exposure, escalating when a 2nd maintainer joins; until then the T1 posture carries up.** -**No human reads every diff.** Review before a merge is the process in [`../CLAUDE.md`](../CLAUDE.md) section 5. That section is the source of record, so read it there, under *"A Builder runs the checks before it commits, because nobody downstream can ask it to"*, *"Branch, commit one layer, open the PR"* and *"The Manager plans, dispatches, and holds the owner's attention"*. Its merge bullet and the Lander's repair rules moved verbatim to [`roles/GOVERNANCE.md`](roles/GOVERNANCE.md) on 2026-11-30 and bind as that section does, so where this list says *that section's merge bullet*, read it there. In outline: +**No human reads every diff.** Review before a merge is the process in [`../CLAUDE.md`](../CLAUDE.md) section 5. That section is the source of record, so read it there, under *"A Builder runs the checks before it commits, because nobody downstream can ask it to"*, *"Branch, commit one layer, open the PR"* and *"The Manager plans, dispatches, and holds the owner's attention"*. At least its merge bullet, the Lander's conflict-resolution and auto-merge rules with their safeguards, and the held-PR repair and transfer rules moved verbatim to [`roles/GOVERNANCE.md`](roles/GOVERNANCE.md) on 2026-11-30 and bind as that section does, so where this list says *that section's merge bullet*, read it there. In outline: - **The Builder**, the session that writes the change, runs the `code-review` **skill** on its own diff, at the effort level that section names. This document calls that the AI code-review pass. *CORRECTED 2026-10-07: this read `code-review` **subagent**. `code-review` is a skill, not an agent type, and that section now names it so.* - **The Lander**, the seat that merges, checks for proof that code review ran on the change being merged. With no proof, it sends the change to code review. @@ -783,6 +783,7 @@ The standard requires deviations be documented with a compensating control (SDS | Version | Date | Change | |---|---|---| +| 0.14 | November 30, 2026 | **The merge rules moved to their own file.** Under record d20261130T205934217-adcecf, at least the merge bullet, the Lander's conflict-resolution and auto-merge rules with their safeguards, and the held-PR repair and transfer rules moved verbatim from [`../CLAUDE.md`](../CLAUDE.md) section 5 to [`roles/GOVERNANCE.md`](roles/GOVERNANCE.md), and bind as that section does. The §6.6 outline and the A.4 claims-register row were pointed at the new file. No rule changed. The header and the executive summary carry the new version. No change to the §4 spine or the resolver. | | 0.13 | November 15, 2026 | **Filing no longer holds the merge.** The merge bullet in [`../CLAUDE.md`](../CLAUDE.md) section 5 states the new order, the findings that still hold the merge, and the authority: a decision the Lander took under the owner's delegation of 2026-11-11, and an owner confirmation in the Repair Manager's chat, 2026-11-15. A finding that goes to the owner still holds the merge until the owner rules, by an owner ruling in that chat the same day. The §6.6 outline was corrected in place, with a dated note beside the line. What moved is the order, and with it where an open finding is recorded at merge time: on the pull request, until its row is filed. This version did not change the review proof, or which findings reach the owner. The header and the executive summary carry the new version. A.6 was not edited. No change to the §4 spine or the resolver. | | 0.12 | October 22, 2026 | **The AFK-autonomy rule edits.** The owner approved the AFK-autonomy plan on 2026-10-21 and its rule edits on 2026-10-22, both recorded at the head of [AUTONOMY-PLAN.md](AUTONOMY-PLAN.md); the edits are its section 5.3. §6.2: the owner's go is needed only on a plan that holds a class C item, and a routine plan is a logged class B decision that an adversarial review must affirm; the section says which replacement controls are built ([ADR 0211](adr/0211-afk-autonomy-controls-decision-log-kill-switch-tripwires-digest.md)) and which are not, and that the go was retired earlier than plan section 10 placed it. §8 withdraws "the Manager's plan has the owner's go" and approves the plan's autonomy wording verbatim; "autonomously developed" stays banned. §6.6 and A.6 name the owner's delegation ruling of 2026-10-22. §9 lists the built slice, the unbuilt controls, and the owner's planned reviews as designed, not built. A.4 registers the new wording. A.6 widens the PO.1 entry and adds an entry for autonomous class B decisions, so it now holds nine. The §5 *Spec / plan rigor* row and the §7 rows that cited the plan go were aligned. Dated corrections quote the old words. No change to the §4 spine or the resolver. | | 0.11 | October 12, 2026 | **Fewer findings route to the owner.** On 2026-10-12 the owner approved a Lander proposal: the Lander may merge when the open findings are filed as rows and none changes behaviour or weakens a control. A finding that does either still goes to the owner. The §6.6 outline was corrected in place, with a dated note beside the line; [`../CLAUDE.md`](../CLAUDE.md) section 5 states the rule. This changes the review process: it narrows which findings reach the owner. The header and the executive summary carry the new version, and no other passage on the review process was changed. A.6 was not edited, and it does not say which findings reach the owner. No change to the §4 spine or the resolver. | diff --git a/docs/roles/GOVERNANCE.md b/docs/roles/GOVERNANCE.md index e8991d3940..dab707bc26 100644 --- a/docs/roles/GOVERNANCE.md +++ b/docs/roles/GOVERNANCE.md @@ -3,17 +3,19 @@ This file holds the Lander's merge rules, its auto-merge safeguards and the repair rules for a held pull request. Every paragraph between a `moved-verbatim` begin marker and its end marker moved here verbatim from root `CLAUDE.md` section 5 on 2026-11-30, under record d20261130T205934217-adcecf -(vault decision log; decided by the Manager under the owner's delegation of 2026-11-29, after an -adversarial review). It moved byte for byte, but for the one link target noted below. Nothing in -it was reworded or corrected. +(vault decision log). It was decided by the Manager under the owner's delegation of 2026-11-29, +whose message reads *"I want you to decide on everything the classifier will let you decide +using /driver rules"*. The question was *"should CLAUDE.md section 5 seat governance move out of +the always-loaded file to cut Builder context cost?"*. An adversarial review returned +AFFIRM-WITH-CHANGES, and the narrower move it asked for was adopted. The text moved byte for +byte, but for the one link target noted below. Nothing in it was reworded or corrected. **These paragraphs bind exactly as `CLAUDE.md` section 5 does.** Moving them changed where they are read, never what they require or whom they bind. `CLAUDE.md` section 5 keeps an index stub at each place they left, listing every paragraph's lead, so a citation of section 5 resolves here in one hop. -**The Lander, the Watchdog and the Repair Manager read this file on arrival.** So does any Manager -acting on a held pull request. +**The Lander, the Watchdog, the Repair Manager and every Manager read this file on arrival.** Read the moved text with these notes, which are not part of it: @@ -287,3 +289,9 @@ own independent review the paragraph above requires, before the merge. The proce section 5 and korus roles/LANDER.md, so both repos state one merge order. R5 does not block this pair."* + +## Refusal-affected work + +Refusal-affected work: owner ruling 2026-11-30 (AskUserQuestion in a Manager's chat, answer +'Adopt revised rule (Recommended)', record d20261130T212032740-ab4069). Its text is in the empower +skill, section 'Refusal-affected work', and in korus roles/LANDER.md. diff --git a/docs/roles/lander.card.md b/docs/roles/lander.card.md index ae13d99cd8..42954bf0a7 100644 --- a/docs/roles/lander.card.md +++ b/docs/roles/lander.card.md @@ -55,8 +55,6 @@ A tick is a wakeup, not a message. Do not answer it, acknowledge it, or post a s ## On arrival -Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. - 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, write a lesson, decision, gotcha or correction. A miss never blocks. Run korus's wiki scripts by @@ -109,6 +107,8 @@ against a control of **1** for *"KORUS roster"* on the same read, while returnin 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. +Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. + 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/manager.card.md b/docs/roles/manager.card.md index 26f2f59b2c..1681709f82 100644 --- a/docs/roles/manager.card.md +++ b/docs/roles/manager.card.md @@ -70,8 +70,6 @@ least-privilege spelling is the broken one, which is why it survives review. ## On arrival -Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. - 1. Read `COMMON.md`, then `MANAGER.md`, from korus at `origin/main` -- paths below. 2. Query the fleet wiki for the owner's subject and each item before you brief it. Cite any note you act on by id; after, write a lesson, decision, gotcha or correction. A miss never blocks. Run @@ -113,6 +111,8 @@ Read the korus `COMMON.md` first, whichever seat you hold. CLAUDE.md section 5 g disagree about this repository. Where a korus playbook and `COMMON.md` disagree, CLAUDE.md section 5 says which wins. +Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. + 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/watchdog.card.md b/docs/roles/watchdog.card.md index 1297be89e0..03ab60df3d 100644 --- a/docs/roles/watchdog.card.md +++ b/docs/roles/watchdog.card.md @@ -65,8 +65,6 @@ because one arrived. ## On arrival -Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. - 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, write a lesson, decision, gotcha or correction. A miss never blocks. Run korus's wiki scripts by @@ -108,6 +106,8 @@ of a 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. +Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. + 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/tests/test_claude_md_governance_move.py b/tests/test_claude_md_governance_move.py index 5090d49b8b..c06656ddef 100644 --- a/tests/test_claude_md_governance_move.py +++ b/tests/test_claude_md_governance_move.py @@ -39,10 +39,15 @@ r"\n(.*?)", re.DOTALL ) _LIST_ITEM = re.compile(r"^(\s*)- (.+)$") -# A stub's lead sentence may wrap; this many non-list lines may sit between it and its list. -_STUB_GAP = 3 +# A stub that is itself a bullet names its own lead: "- **** This bullet". +_OUTER_LEAD = re.compile(r"^- (\*\*(?:(?!\*\*).)+\*\*) This bullet$") +# A bold span, which may hold a single-asterisk italic such as *"Sign R1-R9"*. +_BOLD = re.compile(r"\*\*(?:(?!\*\*).)+\*\*") +# A stub's lead sentences may wrap; this many non-list lines may sit between the marker and its list. +_STUB_GAP = 6 # A moved line shorter than this may be ordinary prose CLAUDE.md legitimately repeats. _MIN_LINE = 60 +_GOV = "docs/roles/GOVERNANCE.md" def _read(path: Path) -> str: @@ -50,13 +55,20 @@ def _read(path: Path) -> str: 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 stub_entries(claude: str) -> list[str]: - """Every lead listed under a stub in CLAUDE.md, in file order.""" + """Every lead a stub in CLAUDE.md lists, in file order, the bullet stub's own lead included.""" lines = claude.splitlines() entries: list[str] = [] for i, line in enumerate(lines): if _MARKER not in line: continue + if i and (outer := _OUTER_LEAD.match(lines[i - 1])): + entries.append(outer.group(1)) j, gap = i + 1, 0 while j < len(lines) and not _LIST_ITEM.match(lines[j]) and gap < _STUB_GAP: j, gap = j + 1, gap + 1 @@ -74,26 +86,19 @@ def moved_blocks(governance: str) -> list[str]: return [m.group(2) for m in _BLOCK.finditer(governance)] -def _fold(text: str) -> str: - """Whitespace folded to single spaces, so wrapping and indent never decide a match.""" - return " ".join(text.split()) - +def required_leads(block: str) -> list[str]: + """Every lead a stub must list, exactly: each bold span, wherever it sits, and the opening + clause, up to its first comma, of each paragraph that does not open in bold. -def _paragraph_leads(block: str) -> list[str]: - """Every lead a stub must list: each paragraph's opening, and each bold span opening a line. - - List continuations and indented code are skipped. A bold span opening a line inside a long - paragraph, such as the merge bullet's inner rulings, counts as a lead of its own. + Numbered-list continuations and indented code are not paragraphs of their own. """ - leads = [] + leads = _BOLD.findall(_fold(block)) for para in re.split(r"\n\s*\n", block): if not para.strip() or re.match(r"\d+\. ", para) or para.startswith(" "): continue - lines = para.splitlines() - leads.append(_fold(" ".join(lines[:3])).removeprefix("- ")) - for i, line in enumerate(lines[1:], 1): - if line.lstrip().startswith("**"): - leads.append(_fold(" ".join(lines[i : i + 3]))) + opening = _fold(para).removeprefix("- ") + if not opening.startswith("**"): + leads.append(opening.split(",", 1)[0]) return leads @@ -105,14 +110,15 @@ def mismatches(claude: str, governance: str) -> list[str]: problems.append("CLAUDE.md carries no stub entries") blocks = moved_blocks(governance) folded = _fold("\n".join(blocks)) + required = [lead for block in blocks for lead in required_leads(block)] for entry in entries: - hits = folded.count(entry) - if hits != 1: - problems.append(f"stub lead found {hits} times in GOVERNANCE.md, not once: {entry}") - for block in blocks: - for lead in _paragraph_leads(block): - if not any(lead.startswith(e) for e in entries): - problems.append(f"moved paragraph has no CLAUDE.md stub entry: {lead[:80]}") + if entry not in required: + problems.append(f"stub entry is not an exact lead in {_GOV}: {entry}") + elif (hits := folded.count(entry)) != 1: + problems.append(f"stub lead found {hits} times in {_GOV}, not once: {entry}") + for lead in required: + if entries.count(lead) != 1: + problems.append(f"moved lead has no single CLAUDE.md stub entry: {lead[:80]}") return problems @@ -129,8 +135,8 @@ def _as_originally_written(moved: str) -> str: def test_moved_text_is_byte_identical_to_the_original() -> None: moved = _as_originally_written("".join(moved_blocks(_read(GOVERNANCE)))) assert hashlib.sha256(moved.encode("utf-8")).hexdigest() == MOVED_SHA256, ( - "the moved text in docs/roles/GOVERNANCE.md changed. It moved verbatim, so an edit must " - "change MOVED_SHA256 in the same commit, deliberately, and must also correct GOVERNANCE.md's " + f"the moved text in {_GOV} changed. It moved verbatim, so an edit must change " + f"MOVED_SHA256 in the same commit, deliberately, and must also correct {_GOV}'s " "header, which says the text was not reworded" ) @@ -179,7 +185,7 @@ def test_an_inner_lead_dropped_from_a_stub_fails_the_check() -> None: entry = "**A delegated decision counts as the owner's ruling (owner ruling 2026-10-22).**" broken = claude.replace(f" - {entry}\n", "") assert broken != claude - assert any("has no CLAUDE.md stub entry" in p for p in mismatches(broken, governance)) + assert any("has no single CLAUDE.md stub entry" in p for p in mismatches(broken, governance)) def test_a_lead_removed_from_governance_fails_the_check() -> None: @@ -198,4 +204,27 @@ def test_a_moved_paragraph_with_no_stub_fails_the_check() -> None: entry = "**A held PR whose author has not acknowledged the hold within 30 minutes transfers to the Repair Manager.**" broken = claude.replace(f"- {entry}\n", "") assert broken != claude - assert any("has no CLAUDE.md stub entry" in p for p in mismatches(broken, governance)) + assert any("has no single CLAUDE.md stub entry" in p for p in mismatches(broken, governance)) + + +def test_a_truncated_stub_entry_fails_the_check() -> None: + """Positive control: an entry must be a whole lead, not a prefix of one.""" + claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) + entry = "**A held PR whose author has not acknowledged the hold within 30 minutes transfers to the Repair Manager.**" + broken = claude.replace(f"- {entry}\n", "- **A held PR whose author\n") + assert broken != claude + problems = mismatches(broken, governance) + assert any("not an exact lead" in p for p in problems) + assert any("has no single CLAUDE.md stub entry" in p for p in problems) + + +def test_a_mid_line_ruling_dropped_from_a_stub_fails_the_check() -> None: + """Positive control: a bold ruling that opens mid-line still needs its own stub entry.""" + claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) + entry = ( + "**Filing an open finding never holds the merge. A finding that goes to the owner holds the " + "merge until the owner rules.**" + ) + broken = claude.replace(f" - {entry}\n", "") + assert broken != claude + assert any("has no single CLAUDE.md stub entry" in p for p in mismatches(broken, governance)) From 65eff69df3d9ed3946274a5fccf7b0e655ea0d0a Mon Sep 17 00:00:00 2001 From: Scott Hall Date: Mon, 30 Nov 2026 17:08:17 -0600 Subject: [PATCH 05/13] GOVERNANCE.md move: fix review of 689fc78 (arrival step, per-stub index) Record d20261130T205934217-adcecf. - Card pointer is arrival step 2, right after the COMMON.md read, in the lander, manager and watchdog cards. - Test: stub N must index block N; outer bullet lead read however the stub wraps; controls for a misplaced entry and a rewrapped stub. - Stub intros say "leads and bold rulings"; SAIDS 0.14 row says the moved rules' text did not change, not that no rule changed; GOVERNANCE.md header names its closing pointer section. Proposed PR title: Move the Lander merge and repair rules into docs/roles/GOVERNANCE.md Verified-by: tests --- CLAUDE.md | 4 +- docs/Secure_AI_Development_Standards.md | 2 +- docs/roles/GOVERNANCE.md | 17 ++--- docs/roles/lander.card.md | 11 ++-- docs/roles/manager.card.md | 7 +- docs/roles/watchdog.card.md | 13 ++-- tests/test_claude_md_governance_move.py | 88 +++++++++++++++++-------- 7 files changed, 86 insertions(+), 56 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 325ed80040..237cfedd41 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -348,7 +348,7 @@ 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 paragraphs whose leads follow moved verbatim to [`docs/roles/GOVERNANCE.md`](docs/roles/GOVERNANCE.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: - **THE LANDER MAY RESOLVE A CONFLICT THAT TOUCHES CODE. OWNER RULING 2026-09-29, IN SESSION.** @@ -403,7 +403,7 @@ 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 paragraphs whose leads follow moved verbatim to [`docs/roles/GOVERNANCE.md`](docs/roles/GOVERNANCE.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: - **The Lander may send a repair Builder subagent to a held PR as soon as the hold is posted** diff --git a/docs/Secure_AI_Development_Standards.md b/docs/Secure_AI_Development_Standards.md index 504f06afcc..4dffd59b33 100644 --- a/docs/Secure_AI_Development_Standards.md +++ b/docs/Secure_AI_Development_Standards.md @@ -783,7 +783,7 @@ The standard requires deviations be documented with a compensating control (SDS | Version | Date | Change | |---|---|---| -| 0.14 | November 30, 2026 | **The merge rules moved to their own file.** Under record d20261130T205934217-adcecf, at least the merge bullet, the Lander's conflict-resolution and auto-merge rules with their safeguards, and the held-PR repair and transfer rules moved verbatim from [`../CLAUDE.md`](../CLAUDE.md) section 5 to [`roles/GOVERNANCE.md`](roles/GOVERNANCE.md), and bind as that section does. The §6.6 outline and the A.4 claims-register row were pointed at the new file. No rule changed. The header and the executive summary carry the new version. No change to the §4 spine or the resolver. | +| 0.14 | November 30, 2026 | **The merge rules moved to their own file.** Under record d20261130T205934217-adcecf, at least the merge bullet, the Lander's conflict-resolution and auto-merge rules with their safeguards, and the held-PR repair and transfer rules moved verbatim from [`../CLAUDE.md`](../CLAUDE.md) section 5 to [`roles/GOVERNANCE.md`](roles/GOVERNANCE.md), and bind as that section does. The §6.6 outline and the A.4 claims-register row were pointed at the new file. The moved rules' text did not change. The header and the executive summary carry the new version. No change to the §4 spine or the resolver. | | 0.13 | November 15, 2026 | **Filing no longer holds the merge.** The merge bullet in [`../CLAUDE.md`](../CLAUDE.md) section 5 states the new order, the findings that still hold the merge, and the authority: a decision the Lander took under the owner's delegation of 2026-11-11, and an owner confirmation in the Repair Manager's chat, 2026-11-15. A finding that goes to the owner still holds the merge until the owner rules, by an owner ruling in that chat the same day. The §6.6 outline was corrected in place, with a dated note beside the line. What moved is the order, and with it where an open finding is recorded at merge time: on the pull request, until its row is filed. This version did not change the review proof, or which findings reach the owner. The header and the executive summary carry the new version. A.6 was not edited. No change to the §4 spine or the resolver. | | 0.12 | October 22, 2026 | **The AFK-autonomy rule edits.** The owner approved the AFK-autonomy plan on 2026-10-21 and its rule edits on 2026-10-22, both recorded at the head of [AUTONOMY-PLAN.md](AUTONOMY-PLAN.md); the edits are its section 5.3. §6.2: the owner's go is needed only on a plan that holds a class C item, and a routine plan is a logged class B decision that an adversarial review must affirm; the section says which replacement controls are built ([ADR 0211](adr/0211-afk-autonomy-controls-decision-log-kill-switch-tripwires-digest.md)) and which are not, and that the go was retired earlier than plan section 10 placed it. §8 withdraws "the Manager's plan has the owner's go" and approves the plan's autonomy wording verbatim; "autonomously developed" stays banned. §6.6 and A.6 name the owner's delegation ruling of 2026-10-22. §9 lists the built slice, the unbuilt controls, and the owner's planned reviews as designed, not built. A.4 registers the new wording. A.6 widens the PO.1 entry and adds an entry for autonomous class B decisions, so it now holds nine. The §5 *Spec / plan rigor* row and the §7 rows that cited the plan go were aligned. Dated corrections quote the old words. No change to the §4 spine or the resolver. | | 0.11 | October 12, 2026 | **Fewer findings route to the owner.** On 2026-10-12 the owner approved a Lander proposal: the Lander may merge when the open findings are filed as rows and none changes behaviour or weakens a control. A finding that does either still goes to the owner. The §6.6 outline was corrected in place, with a dated note beside the line; [`../CLAUDE.md`](../CLAUDE.md) section 5 states the rule. This changes the review process: it narrows which findings reach the owner. The header and the executive summary carry the new version, and no other passage on the review process was changed. A.6 was not edited, and it does not say which findings reach the owner. No change to the §4 spine or the resolver. | diff --git a/docs/roles/GOVERNANCE.md b/docs/roles/GOVERNANCE.md index dab707bc26..0adc7f7a41 100644 --- a/docs/roles/GOVERNANCE.md +++ b/docs/roles/GOVERNANCE.md @@ -1,14 +1,15 @@ # Merge and repair governance, moved from CLAUDE.md section 5 This file holds the Lander's merge rules, its auto-merge safeguards and the repair rules for a held -pull request. Every paragraph between a `moved-verbatim` begin marker and its end marker moved here -verbatim from root `CLAUDE.md` section 5 on 2026-11-30, under record d20261130T205934217-adcecf -(vault decision log). It was decided by the Manager under the owner's delegation of 2026-11-29, -whose message reads *"I want you to decide on everything the classifier will let you decide -using /driver rules"*. The question was *"should CLAUDE.md section 5 seat governance move out of -the always-loaded file to cut Builder context cost?"*. An adversarial review returned -AFFIRM-WITH-CHANGES, and the narrower move it asked for was adopted. The text moved byte for -byte, but for the one link target noted below. Nothing in it was reworded or corrected. +pull request, and ends with one pointer to a separate owner ruling, which binds by its own record +rather than as moved text. Every paragraph between a `moved-verbatim` begin marker and its end +marker moved here verbatim from root `CLAUDE.md` section 5 on 2026-11-30, under record +d20261130T205934217-adcecf (vault decision log). It was decided by the Manager under the owner's +delegation of 2026-11-29, whose message reads *"I want you to decide on everything the classifier +will let you decide using /driver rules"*. The question was *"should CLAUDE.md section 5 seat +governance move out of the always-loaded file to cut Builder context cost?"*. An adversarial review +returned AFFIRM-WITH-CHANGES, and the narrower move it asked for was adopted. The text moved byte +for byte, but for the one link target noted below. Nothing in it was reworded or corrected. **These paragraphs bind exactly as `CLAUDE.md` section 5 does.** Moving them changed where they are read, never what they require or whom they bind. `CLAUDE.md` section 5 keeps an index stub at each diff --git a/docs/roles/lander.card.md b/docs/roles/lander.card.md index 42954bf0a7..803f0ad480 100644 --- a/docs/roles/lander.card.md +++ b/docs/roles/lander.card.md @@ -56,15 +56,16 @@ 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` on arrival; it holds the merge and 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 @@ -107,8 +108,6 @@ against a control of **1** for *"KORUS roster"* on the same read, while returnin 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. -Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. - 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/manager.card.md b/docs/roles/manager.card.md index 1681709f82..64642ba71c 100644 --- a/docs/roles/manager.card.md +++ b/docs/roles/manager.card.md @@ -71,11 +71,12 @@ least-privilege spelling is the broken one, which is why it survives review. ## On arrival 1. Read `COMMON.md`, then `MANAGER.md`, from korus at `origin/main` -- paths below. -2. Query the fleet wiki for the owner's subject and each item before you brief it. Cite any note you +2. Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. +3. Query the fleet wiki for the owner's subject and each item before you brief it. 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 ledger at the vault's `origin/main` before briefing. Here it is a stub. +4. Read the ledger at the vault's `origin/main` before briefing. Here it is a stub. ## Before you claim it works @@ -111,8 +112,6 @@ Read the korus `COMMON.md` first, whichever seat you hold. CLAUDE.md section 5 g disagree about this repository. Where a korus playbook and `COMMON.md` disagree, CLAUDE.md section 5 says which wins. -Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. - 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/watchdog.card.md b/docs/roles/watchdog.card.md index 03ab60df3d..5e200839da 100644 --- a/docs/roles/watchdog.card.md +++ b/docs/roles/watchdog.card.md @@ -66,16 +66,17 @@ 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 merge and 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 @@ -106,8 +107,6 @@ of a 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. -Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. - 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/tests/test_claude_md_governance_move.py b/tests/test_claude_md_governance_move.py index c06656ddef..4c228ed1a7 100644 --- a/tests/test_claude_md_governance_move.py +++ b/tests/test_claude_md_governance_move.py @@ -39,12 +39,13 @@ r"\n(.*?)", re.DOTALL ) _LIST_ITEM = re.compile(r"^(\s*)- (.+)$") -# A stub that is itself a bullet names its own lead: "- **** This bullet". -_OUTER_LEAD = re.compile(r"^- (\*\*(?:(?!\*\*).)+\*\*) This bullet$") +# A stub that is itself a bullet names its own lead: "- **** This bullet ...", on the +# marker's line or the one before it, however the rest of the sentence wraps. +_OUTER_LEAD = re.compile(r"^- (\*\*(?:(?!\*\*).)+\*\*) This bullet") # A bold span, which may hold a single-asterisk italic such as *"Sign R1-R9"*. _BOLD = re.compile(r"\*\*(?:(?!\*\*).)+\*\*") -# A stub's lead sentences may wrap; this many non-list lines may sit between the marker and its list. -_STUB_GAP = 6 +# How far past the marker a stub's wrapped prose may run before its list must start. +_STUB_SPAN = 12 # A moved line shorter than this may be ordinary prose CLAUDE.md legitimately repeats. _MIN_LINE = 60 _GOV = "docs/roles/GOVERNANCE.md" @@ -60,26 +61,33 @@ def _fold(text: str) -> str: return " ".join(text.split()) -def stub_entries(claude: str) -> list[str]: - """Every lead a stub in CLAUDE.md lists, in file order, the bullet stub's own lead included.""" +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() - entries: list[str] = [] + found: list[list[str]] = [] for i, line in enumerate(lines): if _MARKER not in line: continue - if i and (outer := _OUTER_LEAD.match(lines[i - 1])): - entries.append(outer.group(1)) - j, gap = i + 1, 0 - while j < len(lines) and not _LIST_ITEM.match(lines[j]) and gap < _STUB_GAP: - j, gap = j + 1, gap + 1 + entries: list[str] = [] + for k in (i - 1, i): + if k >= 0 and (outer := _OUTER_LEAD.match(lines[k])): + entries.append(outer.group(1)) + 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" + 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 - return entries + found.append(entries) + return found + + +def stub_entries(claude: str) -> list[str]: + return [entry for stub in stubs(claude) for entry in stub] def moved_blocks(governance: str) -> list[str]: @@ -103,22 +111,28 @@ def required_leads(block: str) -> list[str]: 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.""" + """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 = [] - entries = stub_entries(claude) - if not entries: - problems.append("CLAUDE.md carries no stub entries") + listed = stubs(claude) blocks = moved_blocks(governance) - folded = _fold("\n".join(blocks)) - required = [lead for block in blocks for lead in required_leads(block)] - for entry in entries: - if entry not in required: - problems.append(f"stub entry is not an exact lead in {_GOV}: {entry}") - elif (hits := folded.count(entry)) != 1: - problems.append(f"stub lead found {hits} times in {_GOV}, not once: {entry}") - for lead in required: - if entries.count(lead) != 1: - problems.append(f"moved lead has no single CLAUDE.md stub entry: {lead[:80]}") + if len(listed) != len(blocks): + problems.append(f"CLAUDE.md has {len(listed)} stubs for {len(blocks)} moved blocks") + for n, (entries, block) in enumerate(zip(listed, blocks, strict=False), 1): + required = required_leads(block) + folded = _fold(block) + 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}" + ) + elif (hits := folded.count(entry)) != 1: + problems.append(f"stub {n} lead found {hits} times in block {n}, not once: {entry}") + for lead in required: + if entries.count(lead) != 1: + problems.append(f"moved lead has no single CLAUDE.md stub entry: {lead[:80]}") return problems @@ -228,3 +242,21 @@ def test_a_mid_line_ruling_dropped_from_a_stub_fails_the_check() -> None: broken = claude.replace(f" - {entry}\n", "") assert broken != claude assert any("has no single CLAUDE.md stub entry" in p for p in mismatches(broken, governance)) + + +def test_an_entry_under_the_wrong_stub_fails_the_check() -> None: + """Positive control: each stub indexes the block that left its place, not another one.""" + claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) + held = "**A held PR whose author has not acknowledged the hold within 30 minutes transfers to the Repair Manager.**" + arm = "- **The Lander may arm auto-merge in two cases (owner ruling 2026-10-07).**\n" + broken = claude.replace(f"- {held}\n", "").replace(arm, arm + f"- {held}\n") + assert broken.count(held) == 1 + assert any("not an exact lead of block 1" in p for p in mismatches(broken, governance)) + + +def test_the_bullet_lead_is_read_however_the_stub_wraps() -> None: + """The outer bullet's lead is found with the marker on its own line or on the bullet's.""" + claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) + wrapped = "This bullet\n moved verbatim to" + assert claude.count(wrapped) == 1 + assert mismatches(claude.replace(wrapped, "This bullet moved verbatim to"), governance) == [] From 47ff642949e51d5b869a62f70151b88a70d4155c Mon Sep 17 00:00:00 2001 From: Scott Hall Date: Mon, 30 Nov 2026 17:17:33 -0600 Subject: [PATCH 06/13] GOVERNANCE.md move: final Manager decisions (refusal pointer, authority, every-seat list, literal leads) Record d20261130T205934217-adcecf; Manager decisions under /driver. - Refusal pointer cites korus COMMON.md "A refusal stops the act: Q1 and Q3" and LANDER.md "Work a refusal touched", on a korus branch not yet merged (branch name omitted: the forbidden-content gate refuses it). - Header names the empower skill's standing delegation as the authority and where it states the conflict. - CLAUDE.md every-seat sentence opens "At least", names the register text, adds the held-PR author duties. - Test: required leads are a literal tuple per block; every positive control still fires. Proposed PR title: Move the Lander merge and repair rules into docs/roles/GOVERNANCE.md Verified-by: tests --- CLAUDE.md | 9 ++-- docs/roles/GOVERNANCE.md | 11 ++-- tests/test_claude_md_governance_move.py | 70 ++++++++++++++++--------- 3 files changed, 58 insertions(+), 32 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 237cfedd41..9bbe6cd8a2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -610,10 +610,11 @@ Builder, a subagent included, still never waits and puts its question in its rep session opens its own pull request*. - **The merge is the Lander's, and NO LABEL BLOCKS IT.** This bullet moved verbatim to [`docs/roles/GOVERNANCE.md`](docs/roles/GOVERNANCE.md) on 2026-11-30, - under record d20261130T205934217-adcecf, and binds exactly as if it still stood here. The - delegated-decision ruling, its in-person limits (signing or re-signing the register, money, - credentials, irreversible acts) and 'No seat signs, re-signs or edits the signed text' bind - every seat; their text is in docs/roles/GOVERNANCE.md. Its inner leads: + under record d20261130T205934217-adcecf, and binds exactly as if it still stood here. At least + these bind every seat: the delegated-decision ruling, its in-person limits (signing or + re-signing the register, money, credentials, irreversible acts), 'No seat signs, re-signs or + edits the register text the owner signs', and the held-PR author duties (the hold-ack and + author-closed markers); their text is in docs/roles/GOVERNANCE.md. Its inner leads: - **The Lander checks for PROOF THAT CODE REVIEW RAN on the change (owner ruling 2026-09-29, in session).** - **The Lander may merge when none of the open findings changes behaviour or weakens a control, or the owner has ruled that each one that does may merge, once it has named each open finding on the PR.** - **Two kinds of behaviour change are the Lander's own, as class B: empower added classes 2 and 3 (owner instruction and delegation of 2026-11-28, in the Lander's chat; record d20261129T014004322-8bc82b).** diff --git a/docs/roles/GOVERNANCE.md b/docs/roles/GOVERNANCE.md index 0adc7f7a41..7b848fbe04 100644 --- a/docs/roles/GOVERNANCE.md +++ b/docs/roles/GOVERNANCE.md @@ -8,8 +8,11 @@ d20261130T205934217-adcecf (vault decision log). It was decided by the Manager u delegation of 2026-11-29, whose message reads *"I want you to decide on everything the classifier will let you decide using /driver rules"*. The question was *"should CLAUDE.md section 5 seat governance move out of the always-loaded file to cut Builder context cost?"*. An adversarial review -returned AFFIRM-WITH-CHANGES, and the narrower move it asked for was adopted. The text moved byte -for byte, but for the one link target noted below. Nothing in it was reworded or corrected. +returned AFFIRM-WITH-CHANGES, and the narrower move it asked for was adopted. The empower skill's +standing delegation (Owner instruction 2026-11-29) is the authority; its section 'Where written +rules disagree' names the conflict with the per-question delegation rule in this file and says the +standing delegation governs who decides. The text moved byte for byte, but for the one link target +noted below. Nothing in it was reworded or corrected. **These paragraphs bind exactly as `CLAUDE.md` section 5 does.** Moving them changed where they are read, never what they require or whom they bind. `CLAUDE.md` section 5 keeps an index stub at each @@ -295,4 +298,6 @@ own independent review the paragraph above requires, before the merge. The proce Refusal-affected work: owner ruling 2026-11-30 (AskUserQuestion in a Manager's chat, answer 'Adopt revised rule (Recommended)', record d20261130T212032740-ab4069). Its text is in the empower -skill, section 'Refusal-affected work', and in korus roles/LANDER.md. +skill, section 'Refusal-affected work', and in korus `roles/COMMON.md`, section *A refusal stops +the act: Q1 and Q3*, and `roles/LANDER.md`, section *Work a refusal touched*, on a korus branch +not yet merged to korus main. diff --git a/tests/test_claude_md_governance_move.py b/tests/test_claude_md_governance_move.py index 4c228ed1a7..46845d4b7f 100644 --- a/tests/test_claude_md_governance_move.py +++ b/tests/test_claude_md_governance_move.py @@ -42,14 +42,47 @@ # A stub that is itself a bullet names its own lead: "- **** This bullet ...", on the # marker's line or the one before it, however the rest of the sentence wraps. _OUTER_LEAD = re.compile(r"^- (\*\*(?:(?!\*\*).)+\*\*) This bullet") -# 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 = 12 # A moved line shorter than this may be ordinary prose CLAUDE.md legitimately repeats. _MIN_LINE = 60 _GOV = "docs/roles/GOVERNANCE.md" +#: 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. A literal, not a parse: the SHA +#: pin above freezes the blocks, so these cannot change unless the pin does too. +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.**", + ), + ( + "**The merge is the Lander's, and NO LABEL BLOCKS IT.**", + "**The Lander checks for PROOF THAT CODE REVIEW RAN on the change (owner ruling 2026-09-29, " + "in session).**", + "**The Lander may merge when none of the open findings changes behaviour or weakens a " + "control, or the owner has ruled that each one that does may merge, once it has named each " + "open finding on the PR.**", + "**Two kinds of behaviour change are the Lander's own, as class B: empower added classes 2 " + "and 3 (owner instruction and delegation of 2026-11-28, in the Lander's chat; record " + "d20261129T014004322-8bc82b).**", + "**A delegated decision counts as the owner's ruling (owner ruling 2026-10-22).**", + '**Ledger ruling R2 (owner-signed 2026-11-04, in session: *"Sign R1-R9"*) changes how the ' + "findings are filed, and the Lander reads it as setting when.**", + "**Filing an open finding never holds the merge. A finding that goes to the owner holds the " + "merge until the owner rules.**", + ), +) + def _read(path: Path) -> str: # Text mode folds a Windows checkout's CRLF to LF, so the pin is checkout-independent. @@ -94,22 +127,6 @@ def moved_blocks(governance: str) -> list[str]: return [m.group(2) for m in _BLOCK.finditer(governance)] -def required_leads(block: str) -> list[str]: - """Every lead a stub must list, exactly: each bold span, wherever it sits, and the opening - clause, up to its first comma, of each paragraph that does not open in bold. - - Numbered-list continuations and indented code are not paragraphs of their own. - """ - leads = _BOLD.findall(_fold(block)) - for para in re.split(r"\n\s*\n", block): - if not para.strip() or re.match(r"\d+\. ", para) or para.startswith(" "): - continue - opening = _fold(para).removeprefix("- ") - if not opening.startswith("**"): - leads.append(opening.split(",", 1)[0]) - return leads - - 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. @@ -120,19 +137,22 @@ def mismatches(claude: str, governance: str) -> list[str]: 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) in enumerate(zip(listed, blocks, strict=False), 1): - required = required_leads(block) + 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}" ) - elif (hits := folded.count(entry)) != 1: - problems.append(f"stub {n} lead found {hits} times in block {n}, not once: {entry}") - for lead in required: - if entries.count(lead) != 1: - problems.append(f"moved lead has no single CLAUDE.md stub entry: {lead[:80]}") return problems From 52ede42409edadae19bf5d84a6bea8bb70e58e82 Mon Sep 17 00:00:00 2001 From: Scott Hall Date: Mon, 30 Nov 2026 17:33:28 -0600 Subject: [PATCH 07/13] GOVERNANCE.md move: fix review of 47ff642 (exact quote, marker name, literal completeness) Record d20261130T205934217-adcecf. - CLAUDE.md every-seat sentence quotes "the signed text" exactly, with "the register text the owner signs" as a gloss; names the real author-session-closed marker; points to the header on the standing delegation. - GOVERNANCE.md header: the empower passage is a paragraph that cites CLAUDE.md section 5; edit note names REQUIRED_LEADS. - Test: every bold span must be in REQUIRED_LEADS (with an added-lead control); REQUIRED_LEADS length pinned to MOVED_BLOCKS. Proposed PR title: Move the Lander merge and repair rules into docs/roles/GOVERNANCE.md Verified-by: tests --- CLAUDE.md | 5 +++-- docs/roles/GOVERNANCE.md | 13 ++++++----- tests/test_claude_md_governance_move.py | 29 +++++++++++++++++++++++-- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 9bbe6cd8a2..5732f7b39c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -613,8 +613,9 @@ Builder, a subagent included, still never waits and puts its question in its rep under record d20261130T205934217-adcecf, and binds exactly as if it still stood here. At least these bind every seat: the delegated-decision ruling, its in-person limits (signing or re-signing the register, money, credentials, irreversible acts), 'No seat signs, re-signs or - edits the register text the owner signs', and the held-PR author duties (the hold-ack and - author-closed markers); their text is in docs/roles/GOVERNANCE.md. Its inner leads: + edits the signed text' (the register text the owner signs), and the held-PR author duties (the + `hold-ack` and `author-session-closed` markers); their text is in docs/roles/GOVERNANCE.md, whose + header says where the empower skill's standing delegation governs who decides. Its inner leads: - **The Lander checks for PROOF THAT CODE REVIEW RAN on the change (owner ruling 2026-09-29, in session).** - **The Lander may merge when none of the open findings changes behaviour or weakens a control, or the owner has ruled that each one that does may merge, once it has named each open finding on the PR.** - **Two kinds of behaviour change are the Lander's own, as class B: empower added classes 2 and 3 (owner instruction and delegation of 2026-11-28, in the Lander's chat; record d20261129T014004322-8bc82b).** diff --git a/docs/roles/GOVERNANCE.md b/docs/roles/GOVERNANCE.md index 7b848fbe04..0fed979b0e 100644 --- a/docs/roles/GOVERNANCE.md +++ b/docs/roles/GOVERNANCE.md @@ -9,10 +9,11 @@ delegation of 2026-11-29, whose message reads *"I want you to decide on everythi will let you decide using /driver rules"*. The question was *"should CLAUDE.md section 5 seat governance move out of the always-loaded file to cut Builder context cost?"*. An adversarial review returned AFFIRM-WITH-CHANGES, and the narrower move it asked for was adopted. The empower skill's -standing delegation (Owner instruction 2026-11-29) is the authority; its section 'Where written -rules disagree' names the conflict with the per-question delegation rule in this file and says the -standing delegation governs who decides. The text moved byte for byte, but for the one link target -noted below. Nothing in it was reworded or corrected. +standing delegation (Owner instruction 2026-11-29) is the authority; its paragraph 'Where written +rules disagree' names the conflict with the per-question delegation rule, which it cites as +CLAUDE.md section 5 and which now stands in this file, and says the standing delegation governs who +decides. The text moved byte for byte, but for the one link target noted below. Nothing in it was +reworded or corrected. **These paragraphs bind exactly as `CLAUDE.md` section 5 does.** Moving them changed where they are read, never what they require or whom they bind. `CLAUDE.md` section 5 keeps an index stub at each @@ -40,8 +41,8 @@ Read the moved text with these notes, which are not part of it: link shown as `docs/METHOD.md` targets `../METHOD.md` here, where `CLAUDE.md` targeted `docs/METHOD.md`. Its visible text did not change, and no other byte did (note added 2026-11-30). - Editing the moved text is a deliberate change: `tests/test_claude_md_governance_move.py` pins its - bytes, and a change to them must change that pin in the same commit and correct this header, - which says the text was not reworded. + bytes and their leads, and a change to them must change that pin and `REQUIRED_LEADS` in the + same commit and correct this header, which says the text was not reworded. ## Conflict resolution and auto-merge diff --git a/tests/test_claude_md_governance_move.py b/tests/test_claude_md_governance_move.py index 46845d4b7f..17ddb24ed8 100644 --- a/tests/test_claude_md_governance_move.py +++ b/tests/test_claude_md_governance_move.py @@ -47,6 +47,8 @@ # A moved line shorter than this may be ordinary prose CLAUDE.md legitimately repeats. _MIN_LINE = 60 _GOV = "docs/roles/GOVERNANCE.md" +# A bold span, which may hold a single-asterisk italic such as *"Sign R1-R9"*. +_BOLD = re.compile(r"\*\*(?:(?!\*\*).)+\*\*") #: 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. A literal, not a parse: the SHA @@ -157,7 +159,7 @@ def mismatches(claude: str, governance: str) -> list[str]: def test_governance_holds_every_moved_block() -> None: - assert len(moved_blocks(_read(GOVERNANCE))) == MOVED_BLOCKS + assert len(moved_blocks(_read(GOVERNANCE))) == MOVED_BLOCKS == len(REQUIRED_LEADS) def _as_originally_written(moved: str) -> str: @@ -170,7 +172,7 @@ def test_moved_text_is_byte_identical_to_the_original() -> None: moved = _as_originally_written("".join(moved_blocks(_read(GOVERNANCE)))) assert hashlib.sha256(moved.encode("utf-8")).hexdigest() == MOVED_SHA256, ( f"the moved text in {_GOV} changed. It moved verbatim, so an edit must change " - f"MOVED_SHA256 in the same commit, deliberately, and must also correct {_GOV}'s " + f"MOVED_SHA256 and REQUIRED_LEADS in the same commit, deliberately, and must also correct {_GOV}'s " "header, which says the text was not reworded" ) @@ -280,3 +282,26 @@ def test_the_bullet_lead_is_read_however_the_stub_wraps() -> None: wrapped = "This bullet\n moved verbatim to" assert claude.count(wrapped) == 1 assert mismatches(claude.replace(wrapped, "This bullet moved verbatim to"), governance) == [] + + +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.""" + blocks = moved_blocks(governance) + return [ + span + for block, required in zip(blocks, REQUIRED_LEADS, strict=False) + for span in _BOLD.findall(_fold(block)) + if span not in required + ] + + +def test_every_bold_lead_is_in_the_literal() -> None: + assert unlisted_bold_leads(_read(GOVERNANCE)) == [] + + +def test_a_bold_lead_added_to_a_block_fails_the_literal_check() -> None: + """Positive control: a new bold ruling in moved text must be added to REQUIRED_LEADS.""" + governance = _read(GOVERNANCE) + end = "" + broken = governance.replace(end, "**A new ruling binds here.**\n" + end) + assert unlisted_bold_leads(broken) == ["**A new ruling binds here.**"] From a097e7ae556939cd76dd810e577d292a5edaadd7 Mon Sep 17 00:00:00 2001 From: Scott Hall Date: Mon, 30 Nov 2026 20:55:48 -0600 Subject: [PATCH 08/13] GOVERNANCE.md: refusal pointer cites korus main 8cefd945 Record d20261130T205934217-adcecf. korus PR 293 merged. The pointer now names the sections as titled on korus main (COMMON.md "A refusal stops the act: Q1 and Q3"; LANDER.md "Work a refusal touched: Q1 and Q3 are fixed, and Q2 is decided by the merge seat"), drops "not yet merged", and calls the empower passage a paragraph, as the skill has it. Proposed PR title: Move the Lander merge and repair rules into docs/roles/GOVERNANCE.md Verified-by: tests --- docs/roles/GOVERNANCE.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/roles/GOVERNANCE.md b/docs/roles/GOVERNANCE.md index 0fed979b0e..a690cbeddd 100644 --- a/docs/roles/GOVERNANCE.md +++ b/docs/roles/GOVERNANCE.md @@ -298,7 +298,7 @@ own independent review the paragraph above requires, before the merge. The proce ## Refusal-affected work Refusal-affected work: owner ruling 2026-11-30 (AskUserQuestion in a Manager's chat, answer -'Adopt revised rule (Recommended)', record d20261130T212032740-ab4069). Its text is in the empower -skill, section 'Refusal-affected work', and in korus `roles/COMMON.md`, section *A refusal stops -the act: Q1 and Q3*, and `roles/LANDER.md`, section *Work a refusal touched*, on a korus branch -not yet merged to korus main. +'Adopt revised rule (Recommended)', record d20261130T212032740-ab4069). Its text is in korus +`roles/COMMON.md`, section *A refusal stops the act: Q1 and Q3*, and `roles/LANDER.md`, section +*Work a refusal touched: Q1 and Q3 are fixed, and Q2 is decided by the merge seat*, at korus main +`8cefd945`, and in the empower skill's paragraph 'Refusal-affected work'. From 5ad6caf37e3a08738e643e9e422e4cfae9075792 Mon Sep 17 00:00:00 2001 From: Scott Hall Date: Mon, 30 Nov 2026 21:23:20 -0600 Subject: [PATCH 09/13] Cut PR 3505 back to record adcecf: the merge bullet stays in CLAUDE.md Manager decision d20261201T031319508-c10934 and the Lander's hold of 2026-12-01. Record d20261130T205934217-adcecf. - Merge bullet back in CLAUDE.md byte for byte; block 3, its stub, the every-seat and who-decides sentences and the refusal section removed. - Two remaining stubs say to read the rules; the repair stub keeps the repair-Builder and author limits; header cut to the move and readers. - Lander card: five safeguards back, reread line; measurement sentence trimmed for the cap. Manager card: base text back, two non-rule sentences out, pointer in. Builder and Special cards: pointer. - METHOD, SAIDS, WORKTREES, claim_check, owed_ledger_acts back to base except METHOD's safeguards citation. AUTONOMY-PLAN section 12 line. - Test re-pinned for two blocks plus the merge bullet, with controls. Proposed PR title: Move the Lander conflict, auto-merge and held-PR repair rules into docs/roles/GOVERNANCE.md Verified-by: tests --- CLAUDE.md | 137 +++++++- docs/AUTONOMY-PLAN.md | 4 + docs/METHOD.md | 20 +- docs/Secure_AI_Development_Standards.md | 13 +- docs/WORKTREES.md | 2 +- docs/roles/GOVERNANCE.md | 172 +--------- docs/roles/builder.card.md | 2 + docs/roles/lander.card.md | 16 +- docs/roles/manager.card.md | 18 +- docs/roles/special.card.md | 2 +- scripts/coord/owed_ledger_acts.py | 2 +- scripts/hooks/claim_check.py | 2 +- tests/test_claude_md_governance_move.py | 417 ++++++++++++++++-------- 13 files changed, 454 insertions(+), 353 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 5732f7b39c..3a7ea46c4e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -349,7 +349,13 @@ tool too. | **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 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: +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.** Before you arm +auto-merge, resolve a conflict as the Lander, act on or answer a hold, send or work as a repair +Builder, or transfer or take over a held PR, read all of `docs/roles/GOVERNANCE.md`. Read 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).** @@ -404,12 +410,22 @@ cannot outlive a mistake, and a spawned session can. The full notices are in [`d text moved in wave 2*. 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: +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.** Before you arm +auto-merge, resolve a conflict as the Lander, act on or answer a hold, send or work as a repair +Builder, or transfer or take over a held PR, read all of `docs/roles/GOVERNANCE.md`. Read 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.** +**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 invoking either (plan section 5.1, owner approvals 2026-10-21 and 2026-10-22). The decision @@ -608,20 +624,109 @@ Builder, a subagent included, still never waits and puts its question in its rep Builder in its own session, started from a chip or spawned, opens its own PR. Korus `roles/MANAGER.md` holds the rest, in *When to cut a pull request* and *A Builder in its own session opens its own pull request*. -- **The merge is the Lander's, and NO LABEL BLOCKS IT.** This bullet - moved verbatim to [`docs/roles/GOVERNANCE.md`](docs/roles/GOVERNANCE.md) on 2026-11-30, - under record d20261130T205934217-adcecf, and binds exactly as if it still stood here. At least - these bind every seat: the delegated-decision ruling, its in-person limits (signing or - re-signing the register, money, credentials, irreversible acts), 'No seat signs, re-signs or - edits the signed text' (the register text the owner signs), and the held-PR author duties (the - `hold-ack` and `author-session-closed` markers); their text is in docs/roles/GOVERNANCE.md, whose - header says where the empower skill's standing delegation governs who decides. Its inner leads: - - **The Lander checks for PROOF THAT CODE REVIEW RAN on the change (owner ruling 2026-09-29, in session).** - - **The Lander may merge when none of the open findings changes behaviour or weakens a control, or the owner has ruled that each one that does may merge, once it has named each open finding on the PR.** - - **Two kinds of behaviour change are the Lander's own, as class B: empower added classes 2 and 3 (owner instruction and delegation of 2026-11-28, in the Lander's chat; record d20261129T014004322-8bc82b).** - - **A delegated decision counts as the owner's ruling (owner ruling 2026-10-22).** - - **Ledger ruling R2 (owner-signed 2026-11-04, in session: *"Sign R1-R9"*) changes how the findings are filed, and the Lander reads it as setting when.** - - **Filing an open finding never holds the merge. A finding that goes to the owner holds the merge until the owner rules.** +- **The merge is the Lander's, and NO LABEL BLOCKS IT.** What blocks a merge on GitHub includes + branch protection and the required contexts, and no label; the holds below are the Lander's own. + **The Lander checks for PROOF THAT CODE REVIEW RAN on the change (owner ruling 2026-09-29, in + session).** Proof is a code-review tag on the PR, such as the Builder's QA line under the `qa` + label, or other evidence that code review ran against this change. Without it, the Lander sends + the change to code review. The proof must cover the change being merged, so a conflict resolution + the Lander wrote itself needs its own review. The Lander reads what the review found. **The Lander + may merge when none of the open findings changes behaviour or weakens a control, or the owner has + ruled that each one that does may merge, once it has named each open finding on the PR.** The + owner's ruling of 2026-10-12, in session, approved the condition that none changes behaviour or + weakens a control, as part of the Lander's proposal *"Let me merge when the open findings are + filed as rows and none changes behaviour or weakens a control"*. The naming step, and the order + the ledger ruling R2 paragraph below states, replace the proposal's filing-first step. A finding + that changes behaviour or weakens a control still goes to the owner for a ruling. The 2026-10-12 + ruling does not let the Lander skip the review proof, or choose between two authors' deliberate + changes. Nor does it let the Lander decline a finding that names a defect the merge would ship. + Korus `roles/LANDER.md` *4a-quinquies* holds the rest. Where korus still carries a rule this bullet replaced, this bullet is the newer text. The + full text and the owner's words are in [`docs/METHOD.md`](docs/METHOD.md), *CLAUDE.md text moved + in wave 3*. + **Two kinds of behaviour change are the Lander's own, as class B: empower added classes 2 and 3 + (owner instruction and delegation of 2026-11-28, in the Lander's chat; record + d20261129T014004322-8bc82b).** One is a finding whose only change is a visible + refusal or error, where a measured differential against `origin/main` shows the head never worse + on correctness, with no wrong value written, nothing lost or dropped, and nothing `origin/main` + records or counts left unrecorded, and visible refusals and errors no more frequent than on + `origin/main`. The other is a fail-closed tightening that refuses what + `origin/main` allowed, to protect a control: the refusal names its cause and remedy, the refused + input stays where an operator can retry it, no stored data changes, and the docs a deploying site + reads state the refusal and remedy. Neither covers a finding that weakens a security control, a + gate, an alert, an audit record or a PHI rule, false program output, a false control claim in the + unsafe direction, a false score, a false anchor, or a PR that touches register text. The Lander + decides each after an adversarial review, logs it with `scripts/coord/decision.ps1`, posts the + record id on the PR, names each residual there, merges with it open, and then files it under + ledger ruling R2. A proposal to relax a tightening is filed with an open owner line. A failed + or unclear guard, or a split review, sends the finding to the owner. + **A delegated decision counts as the owner's ruling (owner ruling 2026-10-22).** In the owner's words: + *"when I answer a specific question with /driver or /empower, that delegates that question to the + seat that asked it, including questions the empower rules reserve to me. The seat decides after + an adversarial review and records it as "decided under the owner's delegation of ", + quoting the question and my answer. Treat that record as my ruling, and a merge may rest on it. + Still mine in person: signing or re-signing the register, money, credentials, and irreversible + acts."* It covers only the question answered that way, in the asking seat's own chat: starting a + session with either skill delegates nothing, and a peer relaying such an answer is not a record. + Korus `roles/COMMON.md`, *An Owner answer of /driver or /empower delegates that specific + question*, carries the same ruling. A factual error in prose is a filed row, except a false + statement in a security or assurance record about what a control does, a score or an anchor: + that weakens a control, so it goes to the owner under the 2026-10-12 ruling, and the PR waits + for that ruling; only the statement of what a control does has the exception below. A finding + the Lander cannot classify goes to the owner (decision d20261029T165623191-578690). + Korus `roles/LANDER.md` *4a-quinquies* + sends more to the owner, and governs where the two differ: false program output, and a false + control claim in any comment, docstring or doc (the Lander's reading, decision + d20261110T205706609-38b347). Only a statement of what a control does, what it stores, exposes or + retains included, can be false in the safe direction. One that is false only in the safe + direction, in a record or as a control claim in any text, does not weaken a control. It is filed + under ledger ruling R2 below and does not hold the merge. Safe direction means a reader who acts + on the text does more than the control needs, never less. The usual cases are text that overstates + what is stored, exposed or retained, or understates what a control guarantees, but only where + acting on it passes that test: where storing or retaining something is itself the guarantee, + overstating it is the unsafe direction, and understating a guarantee that leads a reader to drop + or bypass the control is unsafe too. What still goes to the owner includes at least false program + output, which changes behaviour, a false score or a false anchor, always, and a present-tense + claim of a live exposure, which section 0 forbids. This narrows the owner's 2026-10-12 ruling, and + what goes to the owner with it. The owner's instruction of 2026-11-26, quoted in the + repair-Builder paragraph above, named no finding; the rule was set in the Lander's brief written + under it, and the owner directed the Manager to follow that brief exactly (2026-11-26, in the + Manager's chat). Register text the owner signs, signed or drafted for signing, is outside the + safe-direction exception: a finding on it never takes that exception's no-hold route, except the + one case below. Every other route in the merge bullet of engine CLAUDE.md section 5 applies as + written, including the owner routes in that exception's own list. Decided by the Lander under the owner's delegation of + 2026-11-26: asked *"Should the safe-direction carve-out exclude register text the owner signs? + Reply A or B"*, the owner answered *"/driver"* (record d20261127T025715932-3a52ad). The case is + empower added class 4, the Lander's own as class B under the owner's instruction of 2026-11-28 + and record d20261129T014004322-8bc82b. A PR + whose code makes a signed line false only in the safe direction, by the test above, may merge + before the owner re-signs, decided and logged as for the two kinds above, if the PR does not + edit, record or put up for signature any register text, and the falsehood is not a false score + or a false anchor. The Lander names the redraft on the PR and files it under ledger ruling R2. A + Manager drafts the corrected text as record work, with a dated marker beside the signed line until + the owner re-signs in person, and re-anchors any anchor the PR only moved, as a mechanical + re-anchor. No seat signs, re-signs or edits the signed text. + **Ledger ruling R2 (owner-signed 2026-11-04, in session: *"Sign R1-R9"*) changes how the findings + are filed, and the Lander reads it as setting when.** A merged PR files at most one row, holding + its open findings as numbered items. Its deferred scope becomes steps on the row it cites, or is + briefed to that row's next Builder, and goes into a new row only when the PR cites none. A finding + about code the PR did not touch goes instead into the one open row for that module, as an item. + The signed text is cited under R5 above. It says *"The merge still never waits on an open finding, + and no finding goes unrecorded."* Decision d20261111T061703900-432f31 reads R2's signed text as + governing the order of filing and merging. The order is: the Lander names each open finding on the + PR, one line each, with its filed row or "queued for filing", naming its subject and pasting no + row text; it merges; it files the queued ones in the next ledger pass, under the sweep in korus + `roles/LANDER.md`, *An item left in a PR comment is yours to carry*. **Filing an open finding + never holds the merge. A finding that goes to the owner holds the merge until the owner rules.** + That last rule is not R2's text. It is the owner's ruling of 2026-11-15, in the Repair Manager's + chat. Asked *"Under ledger ruling R2's 'the merge never waits on an open finding', does a finding + sent to you for a ruling still hold the merge until you rule?"*, the owner answered *"owner + findings still hold the merge"*. The Lander decided the order under the owner's delegation of + 2026-11-11; the decision's record gives the question as *"does CLAUDE.md s5 file-before-merge or + R2 merge-first govern?"* and the owner's answer as *"/driver"*. The authority for this text is the + owner confirmation in the Repair Manager's chat, 2026-11-15: *"Confirmed: fix all 11 findings on + korus PR 270 and whatever engine PR 2891 leaves open, including the edits to engine CLAUDE.md + section 5 and korus roles/LANDER.md, so both repos state one merge order. R5 does not block this + pair."* - **A PR's merge state is a join over clocks.** `mergeStateStatus` is the starting read, never the verdict, because it hides one blocking reason behind another. Gate on `mergeable == CONFLICTING` first: a PR that conflicts after its checks ran keeps them passing but stale. Korus diff --git a/docs/AUTONOMY-PLAN.md b/docs/AUTONOMY-PLAN.md index 24bea6bfd5..b4e78aefb7 100644 --- a/docs/AUTONOMY-PLAN.md +++ b/docs/AUTONOMY-PLAN.md @@ -260,6 +260,10 @@ 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. diff --git a/docs/METHOD.md b/docs/METHOD.md index bfe532da2c..7f18e9a3ef 100644 --- a/docs/METHOD.md +++ b/docs/METHOD.md @@ -87,7 +87,7 @@ Measured 2026-09-05: that context was already absent from live branch protection owner retired the label and the seat rather than restore the gate. **CORRECTED 2026-09-29:** this paragraph read *"Nothing now requires that anyone read a PR before it merges."* Since an owner ruling that day, the Lander merges only on proof that code review ran, or sends the change to code review. -`docs/roles/GOVERNANCE.md`, moved from CLAUDE.md section 5, carries the rule. No machine gate beyond the required check set blocks a merge. +CLAUDE.md section 5 carries the rule. No machine gate beyond the required check set blocks a merge. Nothing in this system gets pushed to anybody. Everything is polled. @@ -1052,8 +1052,7 @@ 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; for a block about the merge bullet, which moved to -`docs/roles/GOVERNANCE.md` on 2026-11-30, that file wins. +disagree, `CLAUDE.md` wins. ### Three Lander bullets, from section 5 @@ -1106,7 +1105,7 @@ fleet, so never take them*. verbatim: *"Let me merge when the open findings are filed as rows and none changes behaviour or weakens a control. I would still bring you anything that does."* The owner replied, verbatim: *"approved"*, and then: *"make that persistent for future landers"*. That was at about 17:40 - UTC. `docs/roles/GOVERNANCE.md` states the rule once, in its merge bullet, so read it there. + UTC. `CLAUDE.md` section 5 states the rule once, in its merge bullet, so read it there. The reason, as the Lander seat reported it: the same day, three pull requests passed code review but listed small known defects. Examples were code comments that a dependency bump had @@ -1120,7 +1119,7 @@ fleet, so never take them*. **AMENDED 2026-11-04, added after the move (ledger ruling R2, owner-signed in session: *"Sign R1-R9"*).** R2 amends the rulings of 2026-10-12 and 2026-10-31 ("merge, file rows") in their - filing mechanics only: a merged PR now files at most one row. `docs/roles/GOVERNANCE.md` states the new + filing mechanics only: a merged PR now files at most one row. `CLAUDE.md` section 5 states the new mechanics once, at the end of its merge bullet, so read them there. The 2026-10-31 rulings are not recorded in this repository; the vault ledger's banners quote at least the owner's answers *"Merge, file rows (Recommended)"* on engine PRs 2675 and 2676, and *"Merge both, file rows"* on @@ -1133,8 +1132,8 @@ fleet, so never take them*. delegation of 2026-11-11, reads that text as governing the order of filing and merging too, so filing a row no longer holds the merge. A finding that goes to the owner still does, by the owner's ruling of 2026-11-15. So the Lander's proposal quoted under 2026-10-12, which the owner - approved, stays as the record of that day, but no longer states when a row is filed. - `docs/roles/GOVERNANCE.md` states the order once, in its merge bullet, with the authority for the change, so read + approved, stays as the record of that day, but no longer states when a row is filed. `CLAUDE.md` + section 5 states the order once, in its merge bullet, with the authority for the change, so read it there. - **A PR's merge state is a join over clocks, and the join is the part you must not miss.** @@ -1151,16 +1150,13 @@ 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 stayed in `CLAUDE.md`, and some have since moved on, as below. +rule it sat beside stays in `CLAUDE.md`. 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. Since 2026-11-30 the rules six of these blocks sat beside stand in -`docs/roles/GOVERNANCE.md`, and for those blocks that file wins instead: the blocks headed *After THE LANDER MAY RESOLVE A CONFLICT THAT TOUCHES CODE*, *End of the -repair-Builder paragraph*, *End of the Repair Manager transfer paragraph*, the two merge-bullet -blocks and *The Lander auto-merge safeguards*. +`CLAUDE.md` wins. ### After *THE LANDER MAY RESOLVE A CONFLICT THAT TOUCHES CODE*, in *The KORUS roster* diff --git a/docs/Secure_AI_Development_Standards.md b/docs/Secure_AI_Development_Standards.md index 4dffd59b33..9431d5ec62 100644 --- a/docs/Secure_AI_Development_Standards.md +++ b/docs/Secure_AI_Development_Standards.md @@ -12,8 +12,8 @@ | **Applies to** | Any project developed under the Secure Development Standards using an AI coding assistant. **MessageFoundry (MEFOR)** is the reference implementation (Appendix A); future projects add Appendix B, C, … | | **Maintained by** | Project maintainers (open-source). Each deploying/adopting organization assigns its own local owner. | | **Status** | Draft for review | -| **Version** | 0.14 | -| **Date** | November 30, 2026 | +| **Version** | 0.13 | +| **Date** | November 15, 2026 | | **License** | Publishable under the project's open-source license; intended to be shared with adopters and reused across projects. | | **Review cadence** | At least annually, and on **any material change to the AI toolchain or threat model** (a new agent framework, MCP server, Claude Code version, or a new probed attack class). | | **Aligns to** | NIST SP 800-218 (SSDF) **v1.1**: PO.1 / PO.2 / PO.3 / PO.5 / PS.1 / PW.1 / PW.4 / PW.7 / PW.8 / RV.2 — and deliberately **not SP 800-218A**, which profiles organizations *producing* generative-AI and dual-use foundation models, **not** building software *with* an AI assistant; the name is the trap, and it is the wrong document for this one · OWASP ASVS 5.0 Level 3 (V8, V11, V14, V15, V16) · a **five-principle synthesis** distilled from the AI-assisted-development literature (§3, §11 — *not* an external standard) · the project standing contract [`../CLAUDE.md`](../CLAUDE.md) · companion to Secure Development Standards. **Deliberately omits any certification framework** — see §8. | @@ -22,7 +22,7 @@ ## Executive summary -This is the *Secure AI-Assisted Development Standards* — a companion to the Secure Development Standards (SDS) that governs **how the maintainers use Claude Code to BUILD MessageFoundry** (the engineering workflow), without weakening any SDS guarantee. It is explicitly **NOT** the runtime AI assistant the shipped product offers operators; that policy lives in [AI.md](AI.md) and is out of scope here (the two share only the word "AI"). The standard **owns and expands** the SDS §A.6 deviation — *single-maintainer development, with AI-assisted review as a compensating control* — as the detailed record for the solo-maintainer reality, and it aligns to **NIST SP 800-218 (SSDF)** and **OWASP ASVS 5.0 L3** while deliberately conferring **no certification**. **Status: Draft for review, v0.14.** It serves maintainers (the daily loop), adopters and auditors (build-provenance evidence for their own compliance program), and future projects (their own appendix). +This is the *Secure AI-Assisted Development Standards* — a companion to the Secure Development Standards (SDS) that governs **how the maintainers use Claude Code to BUILD MessageFoundry** (the engineering workflow), without weakening any SDS guarantee. It is explicitly **NOT** the runtime AI assistant the shipped product offers operators; that policy lives in [AI.md](AI.md) and is out of scope here (the two share only the word "AI"). The standard **owns and expands** the SDS §A.6 deviation — *single-maintainer development, with AI-assisted review as a compensating control* — as the detailed record for the solo-maintainer reality, and it aligns to **NIST SP 800-218 (SSDF)** and **OWASP ASVS 5.0 L3** while deliberately conferring **no certification**. **Status: Draft for review, v0.13.** It serves maintainers (the daily loop), adopters and auditors (build-provenance evidence for their own compliance program), and future projects (their own appendix). **Why it exists.** It lets a solo maintainer build a PHI-carrying healthcare engine with an AI assistant without weakening the secure-development baseline, and produces auditable build-provenance evidence. Every control traces to one of **five named failure modes (§3):** (1) intent/requirements drift with no auditable intent→code chain; (2) context loss / "context rot" (the model's working context degrading across a long session); (3) long-trajectory error accumulation; (4) the "fast but flawed" speed–quality paradox; and (5) misplaced trust in output. The calibration anchor is the **METR RCT (2025)**: 16 experienced developers on mature repos were measured **~19% SLOWER** with early-2025 AI tooling while forecasting and still believing they were faster — uncontrolled AI assistance is **not automatically** a speed or quality win. @@ -373,13 +373,13 @@ python -m messagefoundry check # exit-coded validate + dryrun, reused by git-h > **Dial:** T0 self-review → **T1 the review process below, as one unit: an AI code-review pass run by the session that wrote the change, a proof check by the seat that merges, which also reads what the pass found, and the gates. The reviewer is an AI pass, not a human, and no human reads every diff — the [A.6](#a6-documented-deviations) deviation** → T2 + a human reviewer for consequential changes, when a second maintainer exists (else the T1 posture carries up) → **T3 + [team posture] independent human review before production exposure, escalating when a 2nd maintainer joins; until then the T1 posture carries up.** -**No human reads every diff.** Review before a merge is the process in [`../CLAUDE.md`](../CLAUDE.md) section 5. That section is the source of record, so read it there, under *"A Builder runs the checks before it commits, because nobody downstream can ask it to"*, *"Branch, commit one layer, open the PR"* and *"The Manager plans, dispatches, and holds the owner's attention"*. At least its merge bullet, the Lander's conflict-resolution and auto-merge rules with their safeguards, and the held-PR repair and transfer rules moved verbatim to [`roles/GOVERNANCE.md`](roles/GOVERNANCE.md) on 2026-11-30 and bind as that section does, so where this list says *that section's merge bullet*, read it there. In outline: +**No human reads every diff.** Review before a merge is the process in [`../CLAUDE.md`](../CLAUDE.md) section 5. That section is the source of record, so read it there, under *"A Builder runs the checks before it commits, because nobody downstream can ask it to"*, *"Branch, commit one layer, open the PR"* and *"The Manager plans, dispatches, and holds the owner's attention"*. In outline: - **The Builder**, the session that writes the change, runs the `code-review` **skill** on its own diff, at the effort level that section names. This document calls that the AI code-review pass. *CORRECTED 2026-10-07: this read `code-review` **subagent**. `code-review` is a skill, not an agent type, and that section now names it so.* - **The Lander**, the seat that merges, checks for proof that code review ran on the change being merged. With no proof, it sends the change to code review. - The Lander reads what the review found. It may merge when none of the open findings changes behaviour or weakens a control, or the owner has ruled that each one that does may merge, once it has named each open finding on the pull request; that section's merge bullet states the rule, when the rows are filed, and which findings still hold the merge. A finding that changes behaviour or weakens a control goes to the **owner** for a ruling, except the kinds that section's merge bullet lets the Lander decide as class B. *CORRECTED 2026-11-28: this sentence had no exception; that section's merge bullet now names the empower added classes 2 to 4.* *CORRECTED 2026-10-12: this read "A finding that names a defect the merge would ship goes back to the **owner** for a ruling." An owner ruling that day narrowed it, and that section's merge bullet states the rule.* *CORRECTED 2026-11-15: the second sentence of this item read "It may merge when the open findings are filed as rows and none changes behaviour or weakens a control." Filing a row no longer holds the merge; that section's merge bullet records the order and its authority. This correction did not change which findings reach the owner.* - **Required CI contexts and branch protection** gate the merge (§6.5). -- **The owner** rules on what is routed to them. A seat's record of a question the owner answered with `/driver` or `/empower` counts as that ruling when the seat decided after an adversarial review and the record quotes the question and the owner's answer; signing the register, money, credentials and irreversible acts stay the owner's in person. Nothing ties such a record to the owner's chat: every seat writes as one GitHub identity, so a record a session invents cannot be told from a real one, and the seat that merges cannot check it. [`roles/GOVERNANCE.md`](roles/GOVERNANCE.md), moved from [`../CLAUDE.md`](../CLAUDE.md) section 5, states it (owner ruling 2026-10-22). The Manager, the seat the owner talks to, waits for the owner's go only on a plan that holds a class C item (§6.2). *CORRECTED 2026-10-22: this read "waits for the owner's go on a plan for anything past a trivial change".* +- **The owner** rules on what is routed to them. A seat's record of a question the owner answered with `/driver` or `/empower` counts as that ruling when the seat decided after an adversarial review and the record quotes the question and the owner's answer; signing the register, money, credentials and irreversible acts stay the owner's in person. Nothing ties such a record to the owner's chat: every seat writes as one GitHub identity, so a record a session invents cannot be told from a real one, and the seat that merges cannot check it. [`../CLAUDE.md`](../CLAUDE.md) section 5 states it (owner ruling 2026-10-22). The Manager, the seat the owner talks to, waits for the owner's go only on a plan that holds a class C item (§6.2). *CORRECTED 2026-10-22: this read "waits for the owner's go on a plan for anything past a trivial change".* MEFOR runs this one process for the changes its sessions write, whatever tier a change would resolve to (§4.3). At least one path is outside it: the scoped Dependabot auto-merge (A.2) arms its merge on the required CI contexts, and no code-review pass runs on it. @@ -736,7 +736,7 @@ MEFOR is an open-source HL7 v2.x integration engine (Python; FastAPI; SQLite/WAL |---|---| | "Built with AI assistance under the Secure AI-Assisted Development Standards." | This doc; PR/commit history; CI history. *(Previously cited `Co-Authored-By` trailers — struck 2026-07-29: measured count zero, §6.7.)* | | "AI-assisted code review as a compensating control for the solo-maintainer review deviation." | A.6; SDS §A.6; the `code-review` pass and its proof on a pull request, where one was posted (§6.6; the proof rule dates from 2026-09-29); blocking CI. | -| "Review before merge is an AI code-review pass plus deterministic gates; no human reads every diff." | §6.6; [`../CLAUDE.md`](../CLAUDE.md) section 5; [`roles/GOVERNANCE.md`](roles/GOVERNANCE.md); A.6. | +| "Review before merge is an AI code-review pass plus deterministic gates; no human reads every diff." | §6.6; [`../CLAUDE.md`](../CLAUDE.md) section 5; A.6. | | "Gates enforce intent deterministically." | `.claude/settings.json`; PreToolUse hook; `security.yml`; `messagefoundry check`. | | ~~"Provenance recorded at commit granularity by convention."~~ **WITHDRAWN 2026-07-29 — do not use this wording.** | The `Co-Authored-By` trailer this rested on is **not in use** — the project turns it off at source, via `attribution` in [`.claude/settings.json`](../.claude/settings.json) — and the cause once recorded here is withdrawn (A.6). Past adoption is not measurable from a shallow clone (§6.7). The defensible replacement claim is: *"There is no per-commit model/version record, and the PR template has no AI-disclosure field."* *CORRECTED 2026-10-02: the replacement claim read "AI involvement is disclosed per PR via the PR template". The template has no such field (A.6).* | | "AI-surfaced security findings are independently (multi-vote) verified before action; the residual risk is control-asymmetry, which is gated only where a deterministic parity check encodes it." | The 2026-06 audit (44 candidates → 26 confirmed); the listener parity guard and its tests (A.2), which is the one such check listed there. *CORRECTED 2026-10-02: the claim ended "addressed by a parity review gate" — do not use that wording. The review-time parity sweep in §6.6 is not a gate: nothing requires it (A.6).* | @@ -783,7 +783,6 @@ The standard requires deviations be documented with a compensating control (SDS | Version | Date | Change | |---|---|---| -| 0.14 | November 30, 2026 | **The merge rules moved to their own file.** Under record d20261130T205934217-adcecf, at least the merge bullet, the Lander's conflict-resolution and auto-merge rules with their safeguards, and the held-PR repair and transfer rules moved verbatim from [`../CLAUDE.md`](../CLAUDE.md) section 5 to [`roles/GOVERNANCE.md`](roles/GOVERNANCE.md), and bind as that section does. The §6.6 outline and the A.4 claims-register row were pointed at the new file. The moved rules' text did not change. The header and the executive summary carry the new version. No change to the §4 spine or the resolver. | | 0.13 | November 15, 2026 | **Filing no longer holds the merge.** The merge bullet in [`../CLAUDE.md`](../CLAUDE.md) section 5 states the new order, the findings that still hold the merge, and the authority: a decision the Lander took under the owner's delegation of 2026-11-11, and an owner confirmation in the Repair Manager's chat, 2026-11-15. A finding that goes to the owner still holds the merge until the owner rules, by an owner ruling in that chat the same day. The §6.6 outline was corrected in place, with a dated note beside the line. What moved is the order, and with it where an open finding is recorded at merge time: on the pull request, until its row is filed. This version did not change the review proof, or which findings reach the owner. The header and the executive summary carry the new version. A.6 was not edited. No change to the §4 spine or the resolver. | | 0.12 | October 22, 2026 | **The AFK-autonomy rule edits.** The owner approved the AFK-autonomy plan on 2026-10-21 and its rule edits on 2026-10-22, both recorded at the head of [AUTONOMY-PLAN.md](AUTONOMY-PLAN.md); the edits are its section 5.3. §6.2: the owner's go is needed only on a plan that holds a class C item, and a routine plan is a logged class B decision that an adversarial review must affirm; the section says which replacement controls are built ([ADR 0211](adr/0211-afk-autonomy-controls-decision-log-kill-switch-tripwires-digest.md)) and which are not, and that the go was retired earlier than plan section 10 placed it. §8 withdraws "the Manager's plan has the owner's go" and approves the plan's autonomy wording verbatim; "autonomously developed" stays banned. §6.6 and A.6 name the owner's delegation ruling of 2026-10-22. §9 lists the built slice, the unbuilt controls, and the owner's planned reviews as designed, not built. A.4 registers the new wording. A.6 widens the PO.1 entry and adds an entry for autonomous class B decisions, so it now holds nine. The §5 *Spec / plan rigor* row and the §7 rows that cited the plan go were aligned. Dated corrections quote the old words. No change to the §4 spine or the resolver. | | 0.11 | October 12, 2026 | **Fewer findings route to the owner.** On 2026-10-12 the owner approved a Lander proposal: the Lander may merge when the open findings are filed as rows and none changes behaviour or weakens a control. A finding that does either still goes to the owner. The §6.6 outline was corrected in place, with a dated note beside the line; [`../CLAUDE.md`](../CLAUDE.md) section 5 states the rule. This changes the review process: it narrows which findings reach the owner. The header and the executive summary carry the new version, and no other passage on the review process was changed. A.6 was not edited, and it does not say which findings reach the owner. No change to the §4 spine or the resolver. | diff --git a/docs/WORKTREES.md b/docs/WORKTREES.md index e1f390fecf..ab8ef965f4 100644 --- a/docs/WORKTREES.md +++ b/docs/WORKTREES.md @@ -1073,7 +1073,7 @@ prose, even when it also sends mail: `rows` names rows whose banner is owed; `file` counts new rows to file. Either may be left out. -Under ledger ruling R2 (`docs/roles/GOVERNANCE.md`) an ask made since 2026-11-04 should say `file=1` at +Under ledger ruling R2 (`CLAUDE.md` section 5) an ask made since 2026-11-04 should say `file=1` at most. The script's docstring says how it reads a larger count, and why two `file=1` asks on one PR stay `OWED`. Without the marker the report falls back to a prose read that can miss an ask; what it reads, and diff --git a/docs/roles/GOVERNANCE.md b/docs/roles/GOVERNANCE.md index a690cbeddd..72afa64550 100644 --- a/docs/roles/GOVERNANCE.md +++ b/docs/roles/GOVERNANCE.md @@ -1,48 +1,26 @@ # Merge and repair governance, moved from CLAUDE.md section 5 -This file holds the Lander's merge rules, its auto-merge safeguards and the repair rules for a held -pull request, and ends with one pointer to a separate owner ruling, which binds by its own record -rather than as moved text. Every paragraph between a `moved-verbatim` begin marker and its end -marker moved here verbatim from root `CLAUDE.md` section 5 on 2026-11-30, under record -d20261130T205934217-adcecf (vault decision log). It was decided by the Manager under the owner's -delegation of 2026-11-29, whose message reads *"I want you to decide on everything the classifier -will let you decide using /driver rules"*. The question was *"should CLAUDE.md section 5 seat -governance move out of the always-loaded file to cut Builder context cost?"*. An adversarial review -returned AFFIRM-WITH-CHANGES, and the narrower move it asked for was adopted. The empower skill's -standing delegation (Owner instruction 2026-11-29) is the authority; its paragraph 'Where written -rules disagree' names the conflict with the per-question delegation rule, which it cites as -CLAUDE.md section 5 and which now stands in this file, and says the standing delegation governs who -decides. The text moved byte for byte, but for the one link target noted below. Nothing in it was -reworded or corrected. +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 Owner did not answer this question. +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.** Moving them changed where they are -read, never what they require or whom they bind. `CLAUDE.md` section 5 keeps an index stub at each -place they left, listing every paragraph's lead, so a citation of section 5 resolves here in one -hop. +**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, the Watchdog, the Repair Manager and every Manager read this file on arrival.** +The Lander, the Watchdog and every Repair Manager read this file on arrival. Anyone else reads it +before doing an act listed in `CLAUDE.md` section 5's stubs. Everyone rereads it after a compaction. -Read the moved text with these notes, which are not part of it: +This header adds no rule and does not change who decides anything. -- Some passages below name `CLAUDE.md` section 5 as the place this text stands, at least the - owner confirmation of 2026-11-15 in the Repair Manager's chat, the 2026-11-11 delegated question, - and the text decided under record d20261127T025715932-3a52ad. They were written while this text - stood in `CLAUDE.md` section 5, and they were not altered. The text they named now stands in this - file (note added 2026-11-30). -- A bare section number in the moved text, such as *"which section 0 forbids"*, means that section - of root `CLAUDE.md`. -- Some positional references point at paragraphs that stayed in `CLAUDE.md` section 5. At least: - in the repair-Builder paragraph, *"as the paragraph above says"* about a non-trivial fix going to - a spawned Manager session names `CLAUDE.md`'s paragraph led *"A MANAGER AND THE LANDER MAY SPAWN A - SESSION"*; and in the merge bullet, *"cited under R5 above"* names `CLAUDE.md`'s paragraph on - ledger ruling R5. *"The merge bullet"* and *"the merge bullet under Branch, commit one layer, open - the PR"* now name the merge bullet in this file. -- One link target in the merge bullet was rewritten so it resolves from this directory: the - link shown as `docs/METHOD.md` targets `../METHOD.md` here, where `CLAUDE.md` targeted - `docs/METHOD.md`. Its visible text did not change, and no other byte did (note added 2026-11-30). -- Editing the moved text is a deliberate change: `tests/test_claude_md_governance_move.py` pins its - bytes and their leads, and a change to them must change that pin and `REQUIRED_LEADS` in the - same commit and correct this header, which says the text was not reworded. +Location note, 2026-11-30: positional references in the moved text name places in `CLAUDE.md` +section 5, where it stood. At least: 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 @@ -186,119 +164,3 @@ paragraph above names the collision risk that leaves. Every repair head it pushe own independent review the paragraph above requires, before the merge. The procedure is in korus `roles/LANDER.md` and `roles/MANAGER.md`. - -## The merge bullet - - -- **The merge is the Lander's, and NO LABEL BLOCKS IT.** What blocks a merge on GitHub includes - branch protection and the required contexts, and no label; the holds below are the Lander's own. - **The Lander checks for PROOF THAT CODE REVIEW RAN on the change (owner ruling 2026-09-29, in - session).** Proof is a code-review tag on the PR, such as the Builder's QA line under the `qa` - label, or other evidence that code review ran against this change. Without it, the Lander sends - the change to code review. The proof must cover the change being merged, so a conflict resolution - the Lander wrote itself needs its own review. The Lander reads what the review found. **The Lander - may merge when none of the open findings changes behaviour or weakens a control, or the owner has - ruled that each one that does may merge, once it has named each open finding on the PR.** The - owner's ruling of 2026-10-12, in session, approved the condition that none changes behaviour or - weakens a control, as part of the Lander's proposal *"Let me merge when the open findings are - filed as rows and none changes behaviour or weakens a control"*. The naming step, and the order - the ledger ruling R2 paragraph below states, replace the proposal's filing-first step. A finding - that changes behaviour or weakens a control still goes to the owner for a ruling. The 2026-10-12 - ruling does not let the Lander skip the review proof, or choose between two authors' deliberate - changes. Nor does it let the Lander decline a finding that names a defect the merge would ship. - Korus `roles/LANDER.md` *4a-quinquies* holds the rest. Where korus still carries a rule this bullet replaced, this bullet is the newer text. The - full text and the owner's words are in [`docs/METHOD.md`](../METHOD.md), *CLAUDE.md text moved - in wave 3*. - **Two kinds of behaviour change are the Lander's own, as class B: empower added classes 2 and 3 - (owner instruction and delegation of 2026-11-28, in the Lander's chat; record - d20261129T014004322-8bc82b).** One is a finding whose only change is a visible - refusal or error, where a measured differential against `origin/main` shows the head never worse - on correctness, with no wrong value written, nothing lost or dropped, and nothing `origin/main` - records or counts left unrecorded, and visible refusals and errors no more frequent than on - `origin/main`. The other is a fail-closed tightening that refuses what - `origin/main` allowed, to protect a control: the refusal names its cause and remedy, the refused - input stays where an operator can retry it, no stored data changes, and the docs a deploying site - reads state the refusal and remedy. Neither covers a finding that weakens a security control, a - gate, an alert, an audit record or a PHI rule, false program output, a false control claim in the - unsafe direction, a false score, a false anchor, or a PR that touches register text. The Lander - decides each after an adversarial review, logs it with `scripts/coord/decision.ps1`, posts the - record id on the PR, names each residual there, merges with it open, and then files it under - ledger ruling R2. A proposal to relax a tightening is filed with an open owner line. A failed - or unclear guard, or a split review, sends the finding to the owner. - **A delegated decision counts as the owner's ruling (owner ruling 2026-10-22).** In the owner's words: - *"when I answer a specific question with /driver or /empower, that delegates that question to the - seat that asked it, including questions the empower rules reserve to me. The seat decides after - an adversarial review and records it as "decided under the owner's delegation of ", - quoting the question and my answer. Treat that record as my ruling, and a merge may rest on it. - Still mine in person: signing or re-signing the register, money, credentials, and irreversible - acts."* It covers only the question answered that way, in the asking seat's own chat: starting a - session with either skill delegates nothing, and a peer relaying such an answer is not a record. - Korus `roles/COMMON.md`, *An Owner answer of /driver or /empower delegates that specific - question*, carries the same ruling. A factual error in prose is a filed row, except a false - statement in a security or assurance record about what a control does, a score or an anchor: - that weakens a control, so it goes to the owner under the 2026-10-12 ruling, and the PR waits - for that ruling; only the statement of what a control does has the exception below. A finding - the Lander cannot classify goes to the owner (decision d20261029T165623191-578690). - Korus `roles/LANDER.md` *4a-quinquies* - sends more to the owner, and governs where the two differ: false program output, and a false - control claim in any comment, docstring or doc (the Lander's reading, decision - d20261110T205706609-38b347). Only a statement of what a control does, what it stores, exposes or - retains included, can be false in the safe direction. One that is false only in the safe - direction, in a record or as a control claim in any text, does not weaken a control. It is filed - under ledger ruling R2 below and does not hold the merge. Safe direction means a reader who acts - on the text does more than the control needs, never less. The usual cases are text that overstates - what is stored, exposed or retained, or understates what a control guarantees, but only where - acting on it passes that test: where storing or retaining something is itself the guarantee, - overstating it is the unsafe direction, and understating a guarantee that leads a reader to drop - or bypass the control is unsafe too. What still goes to the owner includes at least false program - output, which changes behaviour, a false score or a false anchor, always, and a present-tense - claim of a live exposure, which section 0 forbids. This narrows the owner's 2026-10-12 ruling, and - what goes to the owner with it. The owner's instruction of 2026-11-26, quoted in the - repair-Builder paragraph above, named no finding; the rule was set in the Lander's brief written - under it, and the owner directed the Manager to follow that brief exactly (2026-11-26, in the - Manager's chat). Register text the owner signs, signed or drafted for signing, is outside the - safe-direction exception: a finding on it never takes that exception's no-hold route, except the - one case below. Every other route in the merge bullet of engine CLAUDE.md section 5 applies as - written, including the owner routes in that exception's own list. Decided by the Lander under the owner's delegation of - 2026-11-26: asked *"Should the safe-direction carve-out exclude register text the owner signs? - Reply A or B"*, the owner answered *"/driver"* (record d20261127T025715932-3a52ad). The case is - empower added class 4, the Lander's own as class B under the owner's instruction of 2026-11-28 - and record d20261129T014004322-8bc82b. A PR - whose code makes a signed line false only in the safe direction, by the test above, may merge - before the owner re-signs, decided and logged as for the two kinds above, if the PR does not - edit, record or put up for signature any register text, and the falsehood is not a false score - or a false anchor. The Lander names the redraft on the PR and files it under ledger ruling R2. A - Manager drafts the corrected text as record work, with a dated marker beside the signed line until - the owner re-signs in person, and re-anchors any anchor the PR only moved, as a mechanical - re-anchor. No seat signs, re-signs or edits the signed text. - **Ledger ruling R2 (owner-signed 2026-11-04, in session: *"Sign R1-R9"*) changes how the findings - are filed, and the Lander reads it as setting when.** A merged PR files at most one row, holding - its open findings as numbered items. Its deferred scope becomes steps on the row it cites, or is - briefed to that row's next Builder, and goes into a new row only when the PR cites none. A finding - about code the PR did not touch goes instead into the one open row for that module, as an item. - The signed text is cited under R5 above. It says *"The merge still never waits on an open finding, - and no finding goes unrecorded."* Decision d20261111T061703900-432f31 reads R2's signed text as - governing the order of filing and merging. The order is: the Lander names each open finding on the - PR, one line each, with its filed row or "queued for filing", naming its subject and pasting no - row text; it merges; it files the queued ones in the next ledger pass, under the sweep in korus - `roles/LANDER.md`, *An item left in a PR comment is yours to carry*. **Filing an open finding - never holds the merge. A finding that goes to the owner holds the merge until the owner rules.** - That last rule is not R2's text. It is the owner's ruling of 2026-11-15, in the Repair Manager's - chat. Asked *"Under ledger ruling R2's 'the merge never waits on an open finding', does a finding - sent to you for a ruling still hold the merge until you rule?"*, the owner answered *"owner - findings still hold the merge"*. The Lander decided the order under the owner's delegation of - 2026-11-11; the decision's record gives the question as *"does CLAUDE.md s5 file-before-merge or - R2 merge-first govern?"* and the owner's answer as *"/driver"*. The authority for this text is the - owner confirmation in the Repair Manager's chat, 2026-11-15: *"Confirmed: fix all 11 findings on - korus PR 270 and whatever engine PR 2891 leaves open, including the edits to engine CLAUDE.md - section 5 and korus roles/LANDER.md, so both repos state one merge order. R5 does not block this - pair."* - - -## Refusal-affected work - -Refusal-affected work: owner ruling 2026-11-30 (AskUserQuestion in a Manager's chat, answer -'Adopt revised rule (Recommended)', record d20261130T212032740-ab4069). Its text is in korus -`roles/COMMON.md`, section *A refusal stops the act: Q1 and Q3*, and `roles/LANDER.md`, section -*Work a refusal touched: Q1 and Q3 are fixed, and Q2 is decided by the merge seat*, at korus main -`8cefd945`, and in the empower skill's paragraph 'Refusal-affected work'. 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 803f0ad480..08ab42a864 100644 --- a/docs/roles/lander.card.md +++ b/docs/roles/lander.card.md @@ -20,10 +20,14 @@ rulings 2026-09-21 and 2026-09-23). The row-status flip stays yours. History: `d - **Merge with no proof that code review ran** (owner, 2026-09-29). With a QA line or review tag you need not review the diff, but read what it found. None: send it to an `Agent` subagent that - runs the `code-review` skill at `xhigh`. Proof must cover the head you merge (`docs/roles/GOVERNANCE.md`). + runs the `code-review` skill at `xhigh`. Proof must cover the head you merge (CLAUDE.md section 5). - **Arm auto-merge outside two cases** (owner ruling 2026-10-07): a `main` that requires the queue, or a repo with no queue. **Or arm without the safeguards** (Manager decision, same day): - the three steps in `docs/roles/GOVERNANCE.md`. A write-access push keeps it armed. korus `4c` still binds. + 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: + `docs/roles/GOVERNANCE.md`; korus `4c` still binds. Read it again after a compaction, and + before you arm or transfer. - **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. @@ -102,11 +106,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 64642ba71c..1ce362760a 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 @@ -56,7 +55,10 @@ commit and you do not batch a session's work into one commit. **Push your own branch and open your own PR, without asking.** Owner ruling 2026-08-29, anchored at `refs/liaison/owner-ruling-20260829-push` (`987705dfb`), in their words: *"Sessions push their own."* -**The merge is the Lander's.** No label blocks it. +**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. @@ -71,12 +73,11 @@ least-privilege spelling is the broken one, which is why it survives review. ## On arrival 1. Read `COMMON.md`, then `MANAGER.md`, from korus at `origin/main` -- paths below. -2. Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. -3. Query the fleet wiki for the owner's subject and each item before you brief it. Cite any note you +2. Query the fleet wiki for the owner's subject and each item before you brief it. 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`. -4. Read the ledger at the vault's `origin/main` before briefing. Here it is a stub. +3. Read the ledger at the vault's `origin/main` before briefing. Here it is a stub. ## Before you claim it works @@ -116,4 +117,5 @@ Apply the driver and empower rules by default; load both skills at session start `MEFOR_AFK_KILL` is not `off`, empower is off and the driver rules still apply. See CLAUDE.md section 5. -Live state -- lane counts, throttles, item numbers -- belongs in a dated note, never here. +This card carries only what does not expire. Live state -- lane counts, throttles, item numbers -- +belongs in a dated note, never here. 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/scripts/coord/owed_ledger_acts.py b/scripts/coord/owed_ledger_acts.py index 0412846ec3..1e339a11ad 100644 --- a/scripts/coord/owed_ledger_acts.py +++ b/scripts/coord/owed_ledger_acts.py @@ -70,7 +70,7 @@ READ, ERROR (a failed read, or no ledger commit before a baseline: a shallow clone), and DONE with ``--all``. -LEDGER RULING R2 (owner-signed 2026-11-04, in session: "Sign R1-R9"; ``docs/roles/GOVERNANCE.md``'s +LEDGER RULING R2 (owner-signed 2026-11-04, in session: "Sign R1-R9"; ``CLAUDE.md`` section 5's merge bullet states it) changes what ``file`` should say, not how it is read. From that date a merged PR files at most one row, so an ask made since then should read ``file=1`` at most. A larger count, from an earlier ask or a mistaken one, is still read as written, and filing asks on one PR diff --git a/scripts/hooks/claim_check.py b/scripts/hooks/claim_check.py index 8ba3bc1e5b..bda0fab04b 100644 --- a/scripts/hooks/claim_check.py +++ b/scripts/hooks/claim_check.py @@ -42,7 +42,7 @@ `git interpret-trailers --parse` reads from the message counts. Nothing checks the statement and nothing records the advisory, so the trailer is never proof that a -review ran (docs/roles/GOVERNANCE.md says what is). It only makes the convention visible before anything +review ran (CLAUDE.md section 5 says what is). It only makes the convention visible before anything enforces it. It fires wherever this hook is installed, the vault clone included. At least these never print it: `--no-verify`; a box whose ``.git/hooks`` copy predates it; a message the attribution check refuses, since that check exits first; a merge commit (MERGE_HEAD present); a diff --git a/tests/test_claude_md_governance_move.py b/tests/test_claude_md_governance_move.py index 17ddb24ed8..84b747c220 100644 --- a/tests/test_claude_md_governance_move.py +++ b/tests/test_claude_md_governance_move.py @@ -1,18 +1,22 @@ # SPDX-License-Identifier: AGPL-3.0-or-later # Copyright (C) 2026 MessageFoundry Foundation, LLC and contributors -"""The merge and repair paragraphs moved from CLAUDE.md section 5 to docs/roles/GOVERNANCE.md intact. - -On 2026-11-30 (record d20261130T205934217-adcecf) the Lander's merge rules, its auto-merge -safeguards and the held-PR repair rules moved verbatim out of root ``CLAUDE.md`` section 5. Each -place they left keeps an index stub listing every moved paragraph's lead, so an existing citation -of section 5 resolves in one hop. Two ways this rots silently, each pinned here: - - 1. A stub and the moved text drift apart: a lead is renamed or dropped on one side, and a reader - following a citation lands on nothing. Both directions are checked, with a positive control. - 2. The moved text is edited while claiming to be verbatim. Its bytes are pinned to the SHA-256 of - the original paragraphs as they stood at engine ``origin/main`` ``78963cedfe1``, so any edit to - them must change the pin in the same commit, deliberately. The one exception is a relative - link target rewritten to resolve from ``docs/roles/``; the check undoes it before hashing. +"""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 with a control +run on a changed copy in memory: + + 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 its rules: the stub instruction, the repair-Builder and author + text, the reader sentence, the card pointers or the Lander card's five safeguards go missing. + 4. The move adds a rule: text saying who decides, or the refusal section an earlier revision + carried. """ from __future__ import annotations @@ -24,35 +28,21 @@ _REPO = Path(__file__).resolve().parents[1] CLAUDE_MD = _REPO / "CLAUDE.md" GOVERNANCE = _REPO / "docs" / "roles" / "GOVERNANCE.md" - -#: SHA-256 of the three moved blocks, concatenated in order, LF line endings, computed from -#: ``git show 78963cedfe1:CLAUDE.md``. 21612 bytes. -MOVED_SHA256 = "1be0e04f8c46e9fe9c6b5f99bb4ef6662247dd3540deff8aadc2fbd797085115" -MOVED_BLOCKS = 3 -# The one byte change the move made, stated in GOVERNANCE.md's header: CLAUDE.md's relative link to -# docs/METHOD.md would resolve to docs/roles/docs/METHOD.md from the new directory. -_ORIGINAL_LINK = "[`docs/METHOD.md`](docs/METHOD.md)" -_RELINKED = "[`docs/METHOD.md`](../METHOD.md)" - -_MARKER = "moved verbatim to [`docs/roles/GOVERNANCE.md`](docs/roles/GOVERNANCE.md)" -_BLOCK = re.compile( - r"\n(.*?)", re.DOTALL -) -_LIST_ITEM = re.compile(r"^(\s*)- (.+)$") -# A stub that is itself a bullet names its own lead: "- **** This bullet ...", on the -# marker's line or the one before it, however the rest of the sentence wraps. -_OUTER_LEAD = re.compile(r"^- (\*\*(?:(?!\*\*).)+\*\*) This bullet") -# How far past the marker a stub's wrapped prose may run before its list must start. -_STUB_SPAN = 12 -# A moved line shorter than this may be ordinary prose CLAUDE.md legitimately repeats. -_MIN_LINE = 60 +CARDS = _REPO / "docs" / "roles" +CI = _REPO / ".github" / "workflows" / "ci.yml" _GOV = "docs/roles/GOVERNANCE.md" -# A bold span, which may hold a single-asterisk italic such as *"Sign R1-R9"*. -_BOLD = re.compile(r"\*\*(?:(?!\*\*).)+\*\*") + +#: 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. A literal, not a parse: the SHA -#: pin above freezes the blocks, so these cannot change unless the pin does too. +#: opening clause of the one paragraph that does not open in bold. The SHA pin freezes the blocks, +#: and ``test_every_bold_lead_is_in_the_literal`` 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.**", @@ -67,27 +57,56 @@ "**A held PR whose author has not acknowledged the hold within 30 minutes transfers to the " "Repair Manager.**", ), - ( - "**The merge is the Lander's, and NO LABEL BLOCKS IT.**", - "**The Lander checks for PROOF THAT CODE REVIEW RAN on the change (owner ruling 2026-09-29, " - "in session).**", - "**The Lander may merge when none of the open findings changes behaviour or weakens a " - "control, or the owner has ruled that each one that does may merge, once it has named each " - "open finding on the PR.**", - "**Two kinds of behaviour change are the Lander's own, as class B: empower added classes 2 " - "and 3 (owner instruction and delegation of 2026-11-28, in the Lander's chat; record " - "d20261129T014004322-8bc82b).**", - "**A delegated decision counts as the owner's ruling (owner ruling 2026-10-22).**", - '**Ledger ruling R2 (owner-signed 2026-11-04, in session: *"Sign R1-R9"*) changes how the ' - "findings are filed, and the Lander reads it as setting when.**", - "**Filing an open finding never holds the merge. A finding that goes to the owner holds the " - "merge until the owner rules.**", - ), ) +#: Text the Lander's hold of 2026-12-01 requires, quoted from it. +STUB_INSTRUCTION = ( + "**These leads are only an index. They leave out conditions and give no permission.** Before " + "you arm auto-merge, resolve a conflict as the Lander, act on or answer a hold, send or work as " + "a repair Builder, or transfer or take over a held PR, read all of `docs/roles/GOVERNANCE.md`. " + "Read it again after any compaction. This applies to every seat and every PR author, including " + "Builders, Special and sessions with no role card." +) +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." +) +READERS = ( + "The Lander, the Watchdog and every Repair Manager read this file on arrival. Anyone else reads " + "it before doing an act listed in `CLAUDE.md` section 5's stubs. Everyone rereads it after a " + "compaction." +) +CARD_POINTER = "Before a stub-listed act, read `docs/roles/GOVERNANCE.md`." +ARRIVAL_POINTER = "Read `docs/roles/GOVERNANCE.md` on arrival" +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 that would say who decides, or carry the refusal section an earlier revision added. +FORBIDDEN = ("governs who decides", "standing delegation", "Refusal-affected work") + +_MARKER = "moved verbatim to [`docs/roles/GOVERNANCE.md`](docs/roles/GOVERNANCE.md)" +_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 = 12 +# 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 pin is checkout-independent. + # Text mode folds a Windows checkout's CRLF to LF, so the pins are checkout-independent. return path.read_text(encoding="utf-8") @@ -104,9 +123,6 @@ def stubs(claude: str) -> list[list[str]]: if _MARKER not in line: continue entries: list[str] = [] - for k in (i - 1, i): - if k >= 0 and (outer := _OUTER_LEAD.match(lines[k])): - entries.append(outer.group(1)) j = i + 1 while j < min(len(lines), i + _STUB_SPAN) and not _LIST_ITEM.match(lines[j]): j += 1 @@ -125,10 +141,33 @@ 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 folded text, from its marker line to the next blank line after its list.""" + lines = claude.splitlines() + out = [] + for i, line in enumerate(lines): + if _MARKER not in line: + continue + j = i + while j < len(lines) and not _LIST_ITEM.match(lines[j]): + j += 1 + while j < len(lines) and lines[j].strip(): + j += 1 + out.append(_fold("\n".join(lines[i:j]))) + return out + + 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 "" + + 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. @@ -158,35 +197,21 @@ def mismatches(claude: str, governance: str) -> list[str]: return problems -def test_governance_holds_every_moved_block() -> None: - assert len(moved_blocks(_read(GOVERNANCE))) == MOVED_BLOCKS == len(REQUIRED_LEADS) - - -def _as_originally_written(moved: str) -> str: - """Undo the one documented deviation: a link target rewritten to resolve from docs/roles/.""" - assert moved.count(_RELINKED) == 1, "the rewritten METHOD.md link is missing or doubled" - return moved.replace(_RELINKED, _ORIGINAL_LINK) - - -def test_moved_text_is_byte_identical_to_the_original() -> None: - moved = _as_originally_written("".join(moved_blocks(_read(GOVERNANCE)))) - assert hashlib.sha256(moved.encode("utf-8")).hexdigest() == MOVED_SHA256, ( - f"the moved text in {_GOV} changed. It moved verbatim, so an edit must change " - f"MOVED_SHA256 and REQUIRED_LEADS in the same commit, deliberately, and must also correct {_GOV}'s " - "header, which says the text was not reworded" - ) - - -def test_stubs_and_moved_text_index_each_other() -> None: - claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) - assert mismatches(claude, governance) == [] +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 of any paragraph is caught however it is - wrapped. A sentence that is part of a stub entry is the index itself, not a re-paste. + 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) @@ -200,108 +225,212 @@ def moved_lines_still_in(claude: str, blocks: list[str]) -> list[str]: return found -def test_the_moved_text_left_claude_md() -> None: - assert moved_lines_still_in(_read(CLAUDE_MD), moved_blocks(_read(GOVERNANCE))) == [] +def missing_told(claude: str, governance: str) -> list[str]: + """Every required telling that is absent: stub instruction, repair text, readers.""" + problems = [] + texts = stub_texts(claude) + for n, text in enumerate(texts, 1): + if _fold(STUB_INSTRUCTION) not in text: + problems.append(f"stub {n} lacks the read-the-rules instruction") + # Directly after the repair stub's last lead. + after_leads = _fold(f"- {REQUIRED_LEADS[1][-1]} {REPAIR_AND_AUTHOR}") + if after_leads not in _fold(claude): + problems.append("the repair stub lacks the repair-Builder and author text") + if _fold(READERS) not in _fold(governance): + problems.append(f"{_GOV} lacks the reader sentence") + return problems -def test_a_re_pasted_paragraph_fails_the_left_check() -> None: - """Positive control: one moved paragraph pasted back into CLAUDE.md is reported.""" - blocks = moved_blocks(_read(GOVERNANCE)) - paragraph = re.split(r"\n\s*\n", blocks[1])[1] - pasted = _read(CLAUDE_MD) + "\n" + paragraph + "\n" - assert moved_lines_still_in(pasted, blocks), "a re-pasted moved paragraph went unreported" - # Rewrapped to one line: the check must not depend on the original line breaks. - rewrapped = _read(CLAUDE_MD) + "\n" + _fold(paragraph) + "\n" - assert moved_lines_still_in(rewrapped, blocks), "a rewrapped re-paste went unreported" +def card_problems(cards: dict[str, str]) -> list[str]: + problems = [] + for name in ("builder", "manager", "special"): + if CARD_POINTER not in _fold(cards[name]): + problems.append(f"{name} card lacks the pointer") + for name in ("lander", "watchdog"): + if ARRIVAL_POINTER not in cards[name]: + problems.append(f"{name} card lacks the arrival step") + if ARRIVAL_POINTER in cards["manager"]: + problems.append("manager card still has the arrival step") + lander = _fold(cards["lander"]) + problems += [f"lander card lacks safeguard: {s}" for s in LANDER_SAFEGUARDS if s not in lander] + return problems + + +def forbidden_in(claude: str, governance: str) -> list[str]: + header = governance.split("", 1)[0] + places = { + "header": _fold(header), + **{f"stub {n}": t for n, t in enumerate(stub_texts(claude), 1)}, + } + places["GOVERNANCE.md"] = _fold(governance) + return [f"{where}: {p}" for where, text in places.items() for p in FORBIDDEN 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]: + return { + n: _read(CARDS / f"{n}.card.md") + for n in ("builder", "lander", "manager", "special", "watchdog") + } -def test_an_inner_lead_dropped_from_a_stub_fails_the_check() -> None: - """Positive control: a bold ruling inside the merge bullet must keep its own stub entry.""" + +# ---- the pins + + +def test_governance_holds_every_moved_block() -> None: + assert len(moved_blocks(_read(GOVERNANCE))) == MOVED_BLOCKS == len(REQUIRED_LEADS) + + +def test_moved_text_is_byte_identical_to_the_original() -> None: + moved = "".join(moved_blocks(_read(GOVERNANCE))) + assert hashlib.sha256(moved.encode("utf-8")).hexdigest() == MOVED_SHA256, ( + f"the moved text in {_GOV} changed. It moved verbatim, so an edit must change " + f"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" + ) + + +def test_the_merge_bullet_stayed_in_claude_md_verbatim() -> None: claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) - entry = "**A delegated decision counts as the owner's ruling (owner ruling 2026-10-22).**" - broken = claude.replace(f" - {entry}\n", "") - assert broken != claude - assert any("has no single CLAUDE.md stub entry" in p for p in mismatches(broken, governance)) + bullet = merge_bullet(claude) + assert hashlib.sha256(bullet.encode("utf-8")).hexdigest() == MERGE_BULLET_SHA256 + assert _fold(bullet)[:200] not in _fold(governance) + assert "This bullet" not in claude and claude.count(_MARKER) == MOVED_BLOCKS + + +def test_a_changed_merge_bullet_fails_the_pin() -> None: + claude = _read(CLAUDE_MD) + broken = claude.replace("NO LABEL BLOCKS IT.**", "NO LABEL BLOCKS IT, mostly.**", 1) + assert hashlib.sha256(merge_bullet(broken).encode("utf-8")).hexdigest() != MERGE_BULLET_SHA256 + + +# ---- the index + + +def test_stubs_and_moved_text_index_each_other() -> None: + assert mismatches(_read(CLAUDE_MD), _read(GOVERNANCE)) == [] + + +def test_every_bold_lead_is_in_the_literal() -> None: + assert unlisted_bold_leads(_read(GOVERNANCE)) == [] + + +def test_a_bold_lead_added_to_a_block_fails_the_literal_check() -> None: + governance = _read(GOVERNANCE) + end = "" + broken = governance.replace(end, "**A new ruling binds here.**\n" + end) + assert unlisted_bold_leads(broken) == ["**A new ruling binds here.**"] def test_a_lead_removed_from_governance_fails_the_check() -> None: - """Positive control: the check above must fire when a moved lead disappears.""" claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) entry = "**The Lander may arm auto-merge in two cases (owner ruling 2026-10-07).**" - assert entry in stub_entries(claude) assert governance.count(entry) == 1 broken = governance.replace(entry, "**Auto-merge.**") assert any(entry in p for p in mismatches(claude, broken)) def test_a_moved_paragraph_with_no_stub_fails_the_check() -> None: - """Positive control for the reverse direction: a moved lead with no stub entry is reported.""" claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) - entry = "**A held PR whose author has not acknowledged the hold within 30 minutes transfers to the Repair Manager.**" + entry = REQUIRED_LEADS[1][2] broken = claude.replace(f"- {entry}\n", "") assert broken != claude assert any("has no single CLAUDE.md stub entry" in p for p in mismatches(broken, governance)) def test_a_truncated_stub_entry_fails_the_check() -> None: - """Positive control: an entry must be a whole lead, not a prefix of one.""" claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) - entry = "**A held PR whose author has not acknowledged the hold within 30 minutes transfers to the Repair Manager.**" + entry = REQUIRED_LEADS[1][2] broken = claude.replace(f"- {entry}\n", "- **A held PR whose author\n") - assert broken != claude problems = mismatches(broken, governance) assert any("not an exact lead" in p for p in problems) assert any("has no single CLAUDE.md stub entry" in p for p in problems) -def test_a_mid_line_ruling_dropped_from_a_stub_fails_the_check() -> None: - """Positive control: a bold ruling that opens mid-line still needs its own stub entry.""" - claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) - entry = ( - "**Filing an open finding never holds the merge. A finding that goes to the owner holds the " - "merge until the owner rules.**" - ) - broken = claude.replace(f" - {entry}\n", "") - assert broken != claude - assert any("has no single CLAUDE.md stub entry" in p for p in mismatches(broken, governance)) - - def test_an_entry_under_the_wrong_stub_fails_the_check() -> None: - """Positive control: each stub indexes the block that left its place, not another one.""" claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) - held = "**A held PR whose author has not acknowledged the hold within 30 minutes transfers to the Repair Manager.**" - arm = "- **The Lander may arm auto-merge in two cases (owner ruling 2026-10-07).**\n" + held = REQUIRED_LEADS[1][2] + arm = f"- {REQUIRED_LEADS[0][1]}\n" broken = claude.replace(f"- {held}\n", "").replace(arm, arm + f"- {held}\n") assert broken.count(held) == 1 assert any("not an exact lead of block 1" in p for p in mismatches(broken, governance)) -def test_the_bullet_lead_is_read_however_the_stub_wraps() -> None: - """The outer bullet's lead is found with the marker on its own line or on the bullet's.""" +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 missing_told(_read(CLAUDE_MD), _read(GOVERNANCE)) == [] + + +def test_a_missing_telling_fails_the_check() -> None: claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) - wrapped = "This bullet\n moved verbatim to" - assert claude.count(wrapped) == 1 - assert mismatches(claude.replace(wrapped, "This bullet moved verbatim to"), governance) == [] + first = "**These leads are only an index." + assert claude.count(first) == MOVED_BLOCKS + no_instruction = claude.replace(first, "**These leads are an index.", 1) + assert any("read-the-rules instruction" in p for p in missing_told(no_instruction, governance)) + no_repair = claude.replace("**A repair Builder** fetches", "**A repair Builder** may fetch") + assert any("repair-Builder" in p for p in missing_told(no_repair, governance)) + no_readers = governance.replace("every Repair Manager", "the Repair Manager") + assert any("reader sentence" in p for p in missing_told(claude, no_readers)) + + +def test_every_card_carries_its_pointer_and_the_lander_its_safeguards() -> None: + assert card_problems(_cards()) == [] + + +def test_a_missing_pointer_or_safeguard_fails_the_card_check() -> None: + cards = _cards() + for name, old in ( + ("special", CARD_POINTER), + ("lander", "`--match-head-commit`"), + ("watchdog", ARRIVAL_POINTER), + ): + assert old in cards[name] or old in _fold(cards[name]) + broken = dict(cards, **{name: _fold(cards[name]).replace(old, "")}) + assert any(name in p for p in card_problems(broken)), name -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.""" - blocks = moved_blocks(governance) - return [ - span - for block, required in zip(blocks, REQUIRED_LEADS, strict=False) - for span in _BOLD.findall(_fold(block)) - if span not in required - ] +# ---- no rule added -def test_every_bold_lead_is_in_the_literal() -> None: - assert unlisted_bold_leads(_read(GOVERNANCE)) == [] +def test_no_header_or_stub_says_who_decides_and_the_refusal_section_is_gone() -> None: + assert forbidden_in(_read(CLAUDE_MD), _read(GOVERNANCE)) == [] -def test_a_bold_lead_added_to_a_block_fails_the_literal_check() -> None: - """Positive control: a new bold ruling in moved text must be added to REQUIRED_LEADS.""" - governance = _read(GOVERNANCE) - end = "" - broken = governance.replace(end, "**A new ruling binds here.**\n" + end) - assert unlisted_bold_leads(broken) == ["**A new ruling binds here.**"] +def test_a_who_decides_sentence_fails_the_check() -> None: + claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) + broken = governance.replace( + "This header adds no rule", + "The standing delegation governs who decides. This header adds no rule", + ) + assert forbidden_in(claude, broken) + assert forbidden_in(claude, governance + "\n## Refusal-affected work\n") + + +# ---- the doc check stays in the list + + +def test_this_module_runs_on_docs_only_pull_requests() -> None: + assert "tests/test_claude_md_governance_move.py" in doc_guards(_read(CI)) + + +def test_a_list_without_this_module_fails_the_check() -> None: + ci = _read(CI).replace("\n tests/test_claude_md_governance_move.py", "") + assert "tests/test_claude_md_governance_move.py" not in doc_guards(ci) + assert doc_guards(ci), "the control must still parse the list" From d255369ea3fd3b5a1a24545ae6fa5da8f9b505d2 Mon Sep 17 00:00:00 2001 From: Scott Hall Date: Mon, 30 Nov 2026 22:12:56 -0600 Subject: [PATCH 10/13] Apply Lander hold 7300319281: reading duties, finding aids, header, cards, METHOD Record d20261130T205934217-adcecf; hold on PR 3505 at 5ad6caf. - Both stubs: the hold's instruction text (acts and reading duties). - First stub: where the auto-merge cases and 2026-09-29 ruling now are. Repair stub: where the 2026-11-26 instruction is quoted. - GOVERNANCE.md header: title, authority line, reading duties, the new-instructions sentence, location note. - Lander and Watchdog cards: arrival step names the conflict, auto-merge and held-PR repair rules; Lander reads at session start and rereads before any stub-listed act. - METHOD.md: two citations and the 2026-11-28 introduction. - Test: every new text, and every existing check, with an in-memory control; "This bullet" check removed; merge-bullet message says to check the change first. Proposed PR title: Move the Lander conflict, auto-merge and held-PR repair rules into docs/roles/GOVERNANCE.md Verified-by: tests --- CLAUDE.md | 32 +- docs/METHOD.md | 13 +- docs/roles/GOVERNANCE.md | 29 +- docs/roles/lander.card.md | 7 +- docs/roles/watchdog.card.md | 3 +- tests/test_claude_md_governance_move.py | 435 +++++++++++++++--------- 6 files changed, 331 insertions(+), 188 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 3a7ea46c4e..d7cae4660b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -351,11 +351,14 @@ tool too. 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.** Before you arm -auto-merge, resolve a conflict as the Lander, act on or answer a hold, send or work as a repair -Builder, or transfer or take over a held PR, read all of `docs/roles/GOVERNANCE.md`. Read it again -after any compaction. This applies to every seat and every PR author, including Builders, Special -and sessions with no role card. +**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).** @@ -363,6 +366,9 @@ and sessions with no role card. - **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 ledger row when the two disagree. **The Lander keeps the row-status flip** (owner correction @@ -412,16 +418,22 @@ text moved in wave 2*. 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.** Before you arm -auto-merge, resolve a conflict as the Lander, act on or answer a hold, send or work as a repair -Builder, or transfer or take over a held PR, read all of `docs/roles/GOVERNANCE.md`. Read it again -after any compaction. This applies to every seat and every PR author, including Builders, Special -and sessions with no role card. +**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. diff --git a/docs/METHOD.md b/docs/METHOD.md index 7f18e9a3ef..54229a9758 100644 --- a/docs/METHOD.md +++ b/docs/METHOD.md @@ -326,13 +326,13 @@ 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, which moved from 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 @@ -1150,13 +1150,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 index 72afa64550..48c6a5db8e 100644 --- a/docs/roles/GOVERNANCE.md +++ b/docs/roles/GOVERNANCE.md @@ -1,26 +1,31 @@ -# Merge and repair governance, moved from CLAUDE.md section 5 +# 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 Owner did not answer this question. -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. +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, the Watchdog and every Repair Manager read this file on arrival. Anyone else reads it -before doing an act listed in `CLAUDE.md` section 5's stubs. Everyone rereads it after a compaction. +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. -This header adds no rule and does not change who decides anything. +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: positional references in the moved text name places in `CLAUDE.md` -section 5, where it stood. At least: 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. +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 diff --git a/docs/roles/lander.card.md b/docs/roles/lander.card.md index 08ab42a864..c627aef9db 100644 --- a/docs/roles/lander.card.md +++ b/docs/roles/lander.card.md @@ -26,8 +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: - `docs/roles/GOVERNANCE.md`; korus `4c` still binds. Read it again after a compaction, and - before you arm or transfer. + `docs/roles/GOVERNANCE.md`; korus `4c` still binds. Read 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. @@ -60,7 +60,8 @@ 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. Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. +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: diff --git a/docs/roles/watchdog.card.md b/docs/roles/watchdog.card.md index 5e200839da..b638928479 100644 --- a/docs/roles/watchdog.card.md +++ b/docs/roles/watchdog.card.md @@ -66,7 +66,8 @@ because one arrived. ## On arrival 1. Read the korus `roles/COMMON.md`, then `roles/WATCHDOG.md`, at `origin/main`. -2. Read `docs/roles/GOVERNANCE.md` on arrival; it holds the merge and repair rules moved out of CLAUDE.md section 5. +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: diff --git a/tests/test_claude_md_governance_move.py b/tests/test_claude_md_governance_move.py index 84b747c220..6f3b9c19a3 100644 --- a/tests/test_claude_md_governance_move.py +++ b/tests/test_claude_md_governance_move.py @@ -6,17 +6,17 @@ 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 with a control -run on a changed copy in memory: +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 its rules: the stub instruction, the repair-Builder and author - text, the reader sentence, the card pointers or the Lander card's five safeguards go missing. - 4. The move adds a rule: text saying who decides, or the refusal section an earlier revision - carried. + 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. """ from __future__ import annotations @@ -28,9 +28,11 @@ _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. @@ -42,7 +44,7 @@ #: 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 ``test_every_bold_lead_is_in_the_literal`` catches a bold lead this literal misses. +#: 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.**", @@ -59,13 +61,44 @@ ), ) -#: Text the Lander's hold of 2026-12-01 requires, quoted from it. +# ---- 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.** Before " - "you arm auto-merge, resolve a conflict as the Lander, act on or answer a hold, send or work as " - "a repair Builder, or transfer or take over a held PR, read all of `docs/roles/GOVERNANCE.md`. " - "Read it again after any compaction. This applies to every seat and every PR author, including " - "Builders, Special and sessions with no role card." + "**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, " @@ -73,13 +106,36 @@ "read the full `hold-ack`, 30-minute transfer and `author-session-closed` rules there before " "replying." ) -READERS = ( - "The Lander, the Watchdog and every Repair Manager read this file on arrival. Anyone else reads " - "it before doing an act listed in `CLAUDE.md` section 5's stubs. Everyone rereads it after a " - "compaction." +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.", ) CARD_POINTER = "Before a stub-listed act, read `docs/roles/GOVERNANCE.md`." -ARRIVAL_POINTER = "Read `docs/roles/GOVERNANCE.md` on arrival" +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.", +} +LANDER_REREAD = "Read 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", @@ -87,10 +143,12 @@ "a `merged`/`mergeQueueEntry`/`autoMergeRequest` readback", "a `headRefOid` check after the merge", ) -#: Phrases that would say who decides, or carry the refusal section an earlier revision added. -FORBIDDEN = ("governs who decides", "standing delegation", "Refusal-affected work") +#: 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 ) @@ -98,7 +156,7 @@ # 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 = 12 +_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.**" @@ -115,6 +173,10 @@ def _fold(text: str) -> str: 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() @@ -142,21 +204,22 @@ def stub_entries(claude: str) -> list[str]: def stub_texts(claude: str) -> list[str]: - """Each stub's folded text, from its marker line to the next blank line after its list.""" - lines = claude.splitlines() + """Each stub's whole folded text, from its marker line up to the paragraph that ends it.""" out = [] - for i, line in enumerate(lines): - if _MARKER not in line: - continue - j = i - while j < len(lines) and not _LIST_ITEM.match(lines[j]): - j += 1 - while j < len(lines) and lines[j].strip(): - j += 1 - out.append(_fold("\n".join(lines[i:j]))) + 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)] @@ -168,6 +231,33 @@ def merge_bullet(claude: str) -> str: 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. @@ -225,45 +315,75 @@ def moved_lines_still_in(claude: str, blocks: list[str]) -> list[str]: return found -def missing_told(claude: str, governance: str) -> list[str]: - """Every required telling that is absent: stub instruction, repair text, readers.""" +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 = [] - texts = stub_texts(claude) 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") - # Directly after the repair stub's last lead. - after_leads = _fold(f"- {REQUIRED_LEADS[1][-1]} {REPAIR_AND_AUTHOR}") - if after_leads not in _fold(claude): - problems.append("the repair stub lacks the repair-Builder and author text") - if _fold(READERS) not in _fold(governance): - problems.append(f"{_GOV} lacks the reader sentence") + 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 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) + return [f"METHOD.md lacks: {m[:60]}" for m in METHOD_TEXT if _fold(m) not in folded] + + 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 _fold(cards[name]): + if CARD_POINTER not in folded[name]: problems.append(f"{name} card lacks the pointer") - for name in ("lander", "watchdog"): - if ARRIVAL_POINTER not in cards[name]: + for name, step in ARRIVAL_STEP.items(): + if _fold(step) not in folded[name]: problems.append(f"{name} card lacks the arrival step") - if ARRIVAL_POINTER in cards["manager"]: - problems.append("manager card still has the arrival step") - lander = _fold(cards["lander"]) - problems += [f"lander card lacks safeguard: {s}" for s in LANDER_SAFEGUARDS if s not in lander] + if "Read `docs/roles/GOVERNANCE.md` on arrival" in folded["manager"]: + 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 forbidden_in(claude: str, governance: str) -> list[str]: - header = governance.split("", 1)[0] - places = { - "header": _fold(header), - **{f"stub {n}": t for n, t in enumerate(stub_texts(claude), 1)}, - } - places["GOVERNANCE.md"] = _fold(governance) - return [f"{where}: {p}" for where, text in places.items() for p in FORBIDDEN if p in text] +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]: @@ -272,40 +392,39 @@ def doc_guards(ci: str) -> list[str]: def _cards() -> dict[str, str]: - return { - n: _read(CARDS / f"{n}.card.md") - for n in ("builder", "lander", "manager", "special", "watchdog") - } + names = ("builder", "lander", "manager", "special", "watchdog") + return {n: _read(CARDS / f"{n}.card.md") for n in names} -# ---- the pins +# ---- pins -def test_governance_holds_every_moved_block() -> None: - assert len(moved_blocks(_read(GOVERNANCE))) == MOVED_BLOCKS == len(REQUIRED_LEADS) +def test_the_pins_hold() -> None: + assert len(REQUIRED_LEADS) == MOVED_BLOCKS + assert pin_problems(_read(CLAUDE_MD), _read(GOVERNANCE)) == [] -def test_moved_text_is_byte_identical_to_the_original() -> None: - moved = "".join(moved_blocks(_read(GOVERNANCE))) - assert hashlib.sha256(moved.encode("utf-8")).hexdigest() == MOVED_SHA256, ( - f"the moved text in {_GOV} changed. It moved verbatim, so an edit must change " - f"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" +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 ) - - -def test_the_merge_bullet_stayed_in_claude_md_verbatim() -> None: - claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) - bullet = merge_bullet(claude) - assert hashlib.sha256(bullet.encode("utf-8")).hexdigest() == MERGE_BULLET_SHA256 - assert _fold(bullet)[:200] not in _fold(governance) - assert "This bullet" not in claude and claude.count(_MARKER) == MOVED_BLOCKS - - -def test_a_changed_merge_bullet_fails_the_pin() -> None: - claude = _read(CLAUDE_MD) - broken = claude.replace("NO LABEL BLOCKS IT.**", "NO LABEL BLOCKS IT, mostly.**", 1) - assert hashlib.sha256(merge_bullet(broken).encode("utf-8")).hexdigest() != MERGE_BULLET_SHA256 + 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 @@ -313,51 +432,22 @@ def test_a_changed_merge_bullet_fails_the_pin() -> None: def test_stubs_and_moved_text_index_each_other() -> None: assert mismatches(_read(CLAUDE_MD), _read(GOVERNANCE)) == [] - - -def test_every_bold_lead_is_in_the_literal() -> None: assert unlisted_bold_leads(_read(GOVERNANCE)) == [] -def test_a_bold_lead_added_to_a_block_fails_the_literal_check() -> None: - governance = _read(GOVERNANCE) +def test_index_controls() -> None: + claude, gov = _read(CLAUDE_MD), _read(GOVERNANCE) end = "" - broken = governance.replace(end, "**A new ruling binds here.**\n" + end) - assert unlisted_bold_leads(broken) == ["**A new ruling binds here.**"] - - -def test_a_lead_removed_from_governance_fails_the_check() -> None: - claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) - entry = "**The Lander may arm auto-merge in two cases (owner ruling 2026-10-07).**" - assert governance.count(entry) == 1 - broken = governance.replace(entry, "**Auto-merge.**") - assert any(entry in p for p in mismatches(claude, broken)) - - -def test_a_moved_paragraph_with_no_stub_fails_the_check() -> None: - claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) - entry = REQUIRED_LEADS[1][2] - broken = claude.replace(f"- {entry}\n", "") - assert broken != claude - assert any("has no single CLAUDE.md stub entry" in p for p in mismatches(broken, governance)) - - -def test_a_truncated_stub_entry_fails_the_check() -> None: - claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) - entry = REQUIRED_LEADS[1][2] - broken = claude.replace(f"- {entry}\n", "- **A held PR whose author\n") - problems = mismatches(broken, governance) - assert any("not an exact lead" in p for p in problems) - assert any("has no single CLAUDE.md stub entry" in p for p in problems) - - -def test_an_entry_under_the_wrong_stub_fails_the_check() -> None: - claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) + 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] - arm = f"- {REQUIRED_LEADS[0][1]}\n" - broken = claude.replace(f"- {held}\n", "").replace(arm, arm + f"- {held}\n") - assert broken.count(held) == 1 - assert any("not an exact lead of block 1" in p for p in mismatches(broken, governance)) + 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: @@ -375,62 +465,95 @@ def test_a_re_pasted_paragraph_fails_the_left_check() -> None: def test_every_seat_is_still_told() -> None: - assert missing_told(_read(CLAUDE_MD), _read(GOVERNANCE)) == [] + assert telling_problems(_read(CLAUDE_MD), _read(GOVERNANCE), _read(METHOD)) == [] -def test_a_missing_telling_fails_the_check() -> None: - claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) - first = "**These leads are only an index." - assert claude.count(first) == MOVED_BLOCKS - no_instruction = claude.replace(first, "**These leads are an index.", 1) - assert any("read-the-rules instruction" in p for p in missing_told(no_instruction, governance)) - no_repair = claude.replace("**A repair Builder** fetches", "**A repair Builder** may fetch") - assert any("repair-Builder" in p for p in missing_told(no_repair, governance)) - no_readers = governance.replace("every Repair Manager", "the Repair Manager") - assert any("reader sentence" in p for p in missing_told(claude, no_readers)) +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 def test_every_card_carries_its_pointer_and_the_lander_its_safeguards() -> None: assert card_problems(_cards()) == [] -def test_a_missing_pointer_or_safeguard_fails_the_card_check() -> None: - cards = _cards() - for name, old in ( +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", "`--match-head-commit`"), - ("watchdog", ARRIVAL_POINTER), - ): - assert old in cards[name] or old in _fold(cards[name]) - broken = dict(cards, **{name: _fold(cards[name]).replace(old, "")}) - assert any(name in p for p in card_problems(broken)), name + ("lander", _fold(ARRIVAL_STEP["lander"])), + ("watchdog", _fold(ARRIVAL_STEP["watchdog"])), + ("lander", LANDER_REREAD), + *(("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) -# ---- no rule added +# ---- banned phrases in the header and stubs -def test_no_header_or_stub_says_who_decides_and_the_refusal_section_is_gone() -> None: - assert forbidden_in(_read(CLAUDE_MD), _read(GOVERNANCE)) == [] +def test_header_and_stubs_carry_no_who_decides_or_refusal_phrase() -> None: + assert banned_in(_read(CLAUDE_MD), _read(GOVERNANCE)) == [] -def test_a_who_decides_sentence_fails_the_check() -> None: - claude, governance = _read(CLAUDE_MD), _read(GOVERNANCE) - broken = governance.replace( - "This header adds no rule", - "The standing delegation governs who decides. This header adds no rule", +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 forbidden_in(claude, broken) - assert forbidden_in(claude, governance + "\n## Refusal-affected work\n") + 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 "tests/test_claude_md_governance_move.py" in doc_guards(_read(CI)) + assert _THIS in doc_guards(_read(CI)) def test_a_list_without_this_module_fails_the_check() -> None: - ci = _read(CI).replace("\n tests/test_claude_md_governance_move.py", "") - assert "tests/test_claude_md_governance_move.py" not in doc_guards(ci) + ci = _read(CI).replace("\n " + _THIS, "") + assert _THIS not in doc_guards(ci) assert doc_guards(ci), "the control must still parse the list" From 4c54c197e6e208eacf1c1f6a928d391593fb753e Mon Sep 17 00:00:00 2001 From: Scott Hall Date: Wed, 2 Dec 2026 17:31:25 -0600 Subject: [PATCH 11/13] Governance move: restore the push warning and name GOVERNANCE.md where the hold asked Repairs the Lander's hold on PR 3505 at d255369ea3f, its five outcomes: 1. CLAUDE.md section 5, the "Merge when ready" bullet, again tells every session that a write-access push leaves auto-merge armed and to disarm with gh pr merge --disable-auto and read the state back. Reworded, not a re-paste of the moved paragraph, and outside both stubs. 2. The Lander card's reread line names docs/roles/GOVERNANCE.md in full; the test pins the full path. 3. Three METHOD.md "CLAUDE.md wins" lines name docs/roles/GOVERNANCE.md too. 4. AUTONOMY-PLAN.md "What is live" says the Class C GOVERNANCE.md listing applies. 5. The Manager card gets one arrival line scoped to the Repair Manager. The test still refuses any other arrival step, now case-insensitively, with controls. A redundant sentence left the card to stay under its byte cap. The moved blocks and the merge bullet are unchanged; their pins hold. Verified-by: tests --- CLAUDE.md | 6 ++- docs/AUTONOMY-PLAN.md | 2 +- docs/METHOD.md | 12 +++-- docs/roles/lander.card.md | 4 +- docs/roles/manager.card.md | 6 +-- tests/test_claude_md_governance_move.py | 61 ++++++++++++++++++++++++- 6 files changed, 77 insertions(+), 14 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index d7cae4660b..4d395bf455 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -594,7 +594,11 @@ 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, and the author waits instead. The full rule is in + `docs/roles/GOVERNANCE.md`. - 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 b4e78aefb7..f00d1ee7f9 100644 --- a/docs/AUTONOMY-PLAN.md +++ b/docs/AUTONOMY-PLAN.md @@ -265,7 +265,7 @@ The section 3 qualifier on new product scope rests on these five records. Words 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. Of the T items, only the section 3 qualifier is live, 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. ## Appendix: review record diff --git a/docs/METHOD.md b/docs/METHOD.md index 54229a9758..489716921a 100644 --- a/docs/METHOD.md +++ b/docs/METHOD.md @@ -533,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 @@ -818,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 @@ -1051,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 diff --git a/docs/roles/lander.card.md b/docs/roles/lander.card.md index c627aef9db..05b726a131 100644 --- a/docs/roles/lander.card.md +++ b/docs/roles/lander.card.md @@ -26,8 +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: - `docs/roles/GOVERNANCE.md`; korus `4c` still binds. Read GOVERNANCE.md again after a compaction - and before any stub-listed act. + `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. diff --git a/docs/roles/manager.card.md b/docs/roles/manager.card.md index 1ce362760a..eb50953ddd 100644 --- a/docs/roles/manager.card.md +++ b/docs/roles/manager.card.md @@ -78,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. A Repair Manager reads `docs/roles/GOVERNANCE.md` on arrival. ## Before you claim it works @@ -109,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 governs where korus disagrees with it 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/tests/test_claude_md_governance_move.py b/tests/test_claude_md_governance_move.py index 6f3b9c19a3..5daceaa395 100644 --- a/tests/test_claude_md_governance_move.py +++ b/tests/test_claude_md_governance_move.py @@ -128,6 +128,12 @@ "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**", + "disarm first with `gh pr merge --disable-auto` and read the state back", +) 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, " @@ -135,7 +141,14 @@ "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.", } -LANDER_REREAD = "Read GOVERNANCE.md again after a compaction and before any stub-listed act." +#: The manager card's one arrival line, scoped to the Repair Manager. Any other arrival step there +#: is refused. +REPAIR_MANAGER_ARRIVAL = "4. A Repair Manager reads `docs/roles/GOVERNANCE.md` on arrival." +#: Any arrival step naming the file, matched case-insensitively once the one allowed line is removed. +_ARRIVAL_STEP = re.compile(r"governance\.md`? on arrival", re.IGNORECASE) +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", @@ -351,6 +364,17 @@ def stub_telling_problems(texts: list[str]) -> list[str]: 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] @@ -370,7 +394,10 @@ def card_problems(cards: dict[str, str]) -> list[str]: for name, step in ARRIVAL_STEP.items(): if _fold(step) not in folded[name]: problems.append(f"{name} card lacks the arrival step") - if "Read `docs/roles/GOVERNANCE.md` on arrival" in folded["manager"]: + manager = folded["manager"] + if manager.count(REPAIR_MANAGER_ARRIVAL) != 1: + problems.append("manager card lacks the one Repair Manager arrival line") + if _ARRIVAL_STEP.search(manager.replace(REPAIR_MANAGER_ARRIVAL, "", 1)): problems.append("manager card has an arrival step") if LANDER_REREAD not in folded["lander"]: problems.append("lander card lacks the reread line") @@ -494,6 +521,21 @@ def test_each_telling_fails_when_removed() -> None: assert method_telling_problems(_fold(method).replace(_fold(m), "")), m +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: + claude = _read(CLAUDE_MD) + folded = _fold(claude) + for a in ALWAYS_LOADED: + assert folded.count(a) == 1, a + assert always_loaded_problems(folded.replace(a, "")), f"removed: {a[:40]}" + into_stub = folded.replace(a, "").replace(FIRST_STUB_AFTER, f"{FIRST_STUB_AFTER} {a}", 1) + assert into_stub != folded.replace(a, ""), a + assert always_loaded_problems(into_stub), f"moved into a stub: {a[:40]}" + + def test_every_card_carries_its_pointer_and_the_lander_its_safeguards() -> None: assert card_problems(_cards()) == [] @@ -507,6 +549,7 @@ def test_each_card_check_fails_when_its_text_is_removed() -> None: ("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: @@ -517,6 +560,20 @@ def test_each_card_check_fails_when_its_text_is_removed() -> None: 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.", + ): + broken = dict(cards, manager=cards["manager"] + extra) + assert card_problems(broken), extra + unscoped = cards["manager"].replace("A Repair Manager reads", "Read", 1) + assert "manager card has an arrival step" in card_problems(dict(cards, manager=unscoped)) + # 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 From 63e558e0b986eaaf52701cad2d45a63c00c1793b Mon Sep 17 00:00:00 2001 From: Scott Hall Date: Wed, 2 Dec 2026 17:53:38 -0600 Subject: [PATCH 12/13] Governance move repair: review round 1 fixes From the code-review round on the PR 3505 hold repair: - CLAUDE.md: the restored disarm step names the Lander as the one who disarms and tells the author to wait, as the moved text does, keeps the TIPS-AND-TRICKS citation, and says it is a summary of a stub-listed act. - Manager card: the precedence sentence keeps its COMMON.md scope rather than all of korus; the Repair Manager line is shorter to fit the cap. - AUTONOMY-PLAN.md: "What is live" says each listed section 3 change applies, not only the GOVERNANCE.md listing. - Test: the arrival-step ban also catches the file in the On arrival section and with a session-start time; the push-warning control runs on the raw file with a positive outside-stub control; METHOD.md's four lines and the AUTONOMY-PLAN line are pinned with controls; docstring lists the two new pins. Verified-by: tests --- CLAUDE.md | 9 ++- docs/AUTONOMY-PLAN.md | 2 +- docs/roles/manager.card.md | 4 +- tests/test_claude_md_governance_move.py | 98 +++++++++++++++++++++---- 4 files changed, 92 insertions(+), 21 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 4d395bf455..bb922db987 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -595,10 +595,11 @@ Builder, a subagent included, still never waits and puts its question in its rep 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*. **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, and the author waits instead. The full rule is in - `docs/roles/GOVERNANCE.md`. + merge with no review. Where korus `roles/LANDER.md` *4c* tells an author to push again, the + Lander first disarms with `gh pr merge --disable-auto` and reads the state back; once the PR + is queued, that command does not remove the entry (korus `docs/TIPS-AND-TRICKS.md`), so the + Lander tells 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 f00d1ee7f9..be88e831ce 100644 --- a/docs/AUTONOMY-PLAN.md +++ b/docs/AUTONOMY-PLAN.md @@ -265,7 +265,7 @@ The section 3 qualifier on new product scope rests on these five records. Words d20261130T205934217-adcecf. A Manager made this change as part of the move; the owner did not approve it. -**What is live:** the Class C row's listing of `docs/roles/GOVERNANCE.md`, from engine PR 3505 above, applies. Of the T items, only the section 3 qualifier is live, 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:** each section 3 change listed above applies, including the Class C row's listing of `docs/roles/GOVERNANCE.md` from engine PR 3505. Of the T items, only the section 3 qualifier is live, 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. ## Appendix: review record diff --git a/docs/roles/manager.card.md b/docs/roles/manager.card.md index eb50953ddd..a12074fb7c 100644 --- a/docs/roles/manager.card.md +++ b/docs/roles/manager.card.md @@ -78,7 +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. A Repair Manager reads `docs/roles/GOVERNANCE.md` on arrival. +4. Repair Manager: read `docs/roles/GOVERNANCE.md` on arrival. ## Before you claim it works @@ -110,7 +110,7 @@ working tree: git -C show origin/main:roles/COMMON.md git -C show origin/main:roles/MANAGER.md -CLAUDE.md section 5 governs where korus disagrees with it about this repository. Where a korus +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 diff --git a/tests/test_claude_md_governance_move.py b/tests/test_claude_md_governance_move.py index 5daceaa395..2e2996fe4b 100644 --- a/tests/test_claude_md_governance_move.py +++ b/tests/test_claude_md_governance_move.py @@ -17,6 +17,10 @@ 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 @@ -132,7 +136,19 @@ #: outside both stubs, as well as in the moved text. ALWAYS_LOADED = ( "**A write-access push leaves auto-merge armed**", - "disarm first with `gh pr merge --disable-auto` and read the state back", + "the Lander first disarms with `gh pr merge --disable-auto` and reads the state back", +) +#: 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:** each section 3 change listed above applies, including the Class C row's " + "listing of `docs/roles/GOVERNANCE.md` from engine PR 3505." ) CARD_POINTER = "Before a stub-listed act, read `docs/roles/GOVERNANCE.md`." ARRIVAL_STEP = { @@ -143,9 +159,16 @@ } #: The manager card's one arrival line, scoped to the Repair Manager. Any other arrival step there #: is refused. -REPAIR_MANAGER_ARRIVAL = "4. A Repair Manager reads `docs/roles/GOVERNANCE.md` on arrival." -#: Any arrival step naming the file, matched case-insensitively once the one allowed line is removed. -_ARRIVAL_STEP = re.compile(r"governance\.md`? on arrival", re.IGNORECASE) +REPAIR_MANAGER_ARRIVAL = "4. Repair Manager: read `docs/roles/GOVERNANCE.md` on arrival." +#: Once the one allowed line is removed, the file named in one sentence with an arrival or +#: session-start time, either order, case-insensitively. ``card_problems`` also refuses the file +#: anywhere in the manager card's On arrival section. +_ARRIVAL_STEP = re.compile( + r"governance\.md`?[^.]{0,80}?(?:on arrival|start of each session)" + r"|(?:on arrival|start of each session)[^.]{0,80}?governance\.md", + re.IGNORECASE, +) +_ON_ARRIVAL = "## On arrival" LANDER_REREAD = ( "Read `docs/roles/GOVERNANCE.md` again after a compaction and before any stub-listed act." ) @@ -382,7 +405,21 @@ def header_telling_problems(governance: str) -> list[str]: def method_telling_problems(method: str) -> list[str]: folded = _fold(method) - return [f"METHOD.md lacks: {m[:60]}" for m in METHOD_TEXT if _fold(m) not in folded] + 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]: @@ -397,7 +434,9 @@ def card_problems(cards: dict[str, str]) -> list[str]: manager = folded["manager"] if manager.count(REPAIR_MANAGER_ARRIVAL) != 1: problems.append("manager card lacks the one Repair Manager arrival line") - if _ARRIVAL_STEP.search(manager.replace(REPAIR_MANAGER_ARRIVAL, "", 1)): + rest = manager.replace(REPAIR_MANAGER_ARRIVAL, "", 1) + arrival = rest.split(_ON_ARRIVAL, 1)[1].split(" ## ", 1)[0] if _ON_ARRIVAL in rest else "" + if _ARRIVAL_STEP.search(rest) or "governance.md" in arrival.lower(): problems.append("manager card has an arrival step") if LANDER_REREAD not in folded["lander"]: problems.append("lander card lacks the reread line") @@ -493,6 +532,7 @@ def test_a_re_pasted_paragraph_fails_the_left_check() -> None: 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: @@ -519,6 +559,13 @@ def test_each_telling_fails_when_removed() -> None: 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) + assert autonomy_problems(_read(AUTONOMY)) == [] + assert autonomy_problems(_read(AUTONOMY).replace("applies, including", "applies; see", 1)) def test_the_push_warning_stays_in_always_loaded_text() -> None: @@ -526,14 +573,28 @@ def test_the_push_warning_stays_in_always_loaded_text() -> None: 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) - folded = _fold(claude) - for a in ALWAYS_LOADED: - assert folded.count(a) == 1, a - assert always_loaded_problems(folded.replace(a, "")), f"removed: {a[:40]}" - into_stub = folded.replace(a, "").replace(FIRST_STUB_AFTER, f"{FIRST_STUB_AFTER} {a}", 1) - assert into_stub != folded.replace(a, ""), a - assert always_loaded_problems(into_stub), f"moved into a stub: {a[:40]}" + 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: @@ -566,10 +627,19 @@ def test_each_card_check_fails_when_its_text_is_removed() -> None: " 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.", ): broken = dict(cards, manager=cards["manager"] + extra) assert card_problems(broken), extra - unscoped = cards["manager"].replace("A Repair Manager reads", "Read", 1) + # 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 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)) From 79ce2b21dbc5f5ae72ecd3353e7dc6788b029bfa Mon Sep 17 00:00:00 2001 From: Scott Hall Date: Wed, 2 Dec 2026 18:15:05 -0600 Subject: [PATCH 13/13] Governance move repair: review round 2 fixes - CLAUDE.md: the disarm step keeps the moved text's own imperative form ("disarm first ... so tell the author to wait") instead of naming a seat the source does not name; round 1's commit wrongly called that faithful. - AUTONOMY-PLAN.md: back to the narrow outcome, the GOVERNANCE.md listing applies; the qualifier sentence no longer dangles. - Test: the manager card may name docs/roles/GOVERNANCE.md only in its pointer and in the one Repair Manager line, which must sit under On arrival; more controls. ALWAYS_LOADED also pins the consequence and the queued caveat. A duplicate positive assertion is gone. Verified-by: tests --- CLAUDE.md | 10 +++--- docs/AUTONOMY-PLAN.md | 2 +- tests/test_claude_md_governance_move.py | 47 +++++++++++++++---------- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index bb922db987..101e01023c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -595,11 +595,11 @@ Builder, a subagent included, still never waits and puts its question in its rep 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*. **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, the - Lander first disarms with `gh pr merge --disable-auto` and reads the state back; once the PR - is queued, that command does not remove the entry (korus `docs/TIPS-AND-TRICKS.md`), so the - Lander tells 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. + 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 be88e831ce..5d9a99215e 100644 --- a/docs/AUTONOMY-PLAN.md +++ b/docs/AUTONOMY-PLAN.md @@ -265,7 +265,7 @@ The section 3 qualifier on new product scope rests on these five records. Words d20261130T205934217-adcecf. A Manager made this change as part of the move; the owner did not approve it. -**What is live:** each section 3 change listed above applies, including the Class C row's listing of `docs/roles/GOVERNANCE.md` from engine PR 3505. Of the T items, only the section 3 qualifier is live, 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/tests/test_claude_md_governance_move.py b/tests/test_claude_md_governance_move.py index 2e2996fe4b..70a0043444 100644 --- a/tests/test_claude_md_governance_move.py +++ b/tests/test_claude_md_governance_move.py @@ -136,7 +136,10 @@ #: outside both stubs, as well as in the moved text. ALWAYS_LOADED = ( "**A write-access push leaves auto-merge armed**", - "the Lander first disarms with `gh pr merge --disable-auto` and reads the state back", + "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 = ( @@ -147,8 +150,8 @@ METHOD_STALE = "`CLAUDE.md` now disagree, `CLAUDE.md` wins" AUTONOMY = _REPO / "docs" / "AUTONOMY-PLAN.md" AUTONOMY_LIVE = ( - "**What is live:** each section 3 change listed above applies, including the Class C row's " - "listing of `docs/roles/GOVERNANCE.md` from engine PR 3505." + "**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 = { @@ -157,17 +160,10 @@ "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. Any other arrival step there -#: is refused. +#: 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." -#: Once the one allowed line is removed, the file named in one sentence with an arrival or -#: session-start time, either order, case-insensitively. ``card_problems`` also refuses the file -#: anywhere in the manager card's On arrival section. -_ARRIVAL_STEP = re.compile( - r"governance\.md`?[^.]{0,80}?(?:on arrival|start of each session)" - r"|(?:on arrival|start of each session)[^.]{0,80}?governance\.md", - re.IGNORECASE, -) _ON_ARRIVAL = "## On arrival" LANDER_REREAD = ( "Read `docs/roles/GOVERNANCE.md` again after a compaction and before any stub-listed act." @@ -432,11 +428,11 @@ def card_problems(cards: dict[str, str]) -> list[str]: if _fold(step) not in folded[name]: problems.append(f"{name} card lacks the arrival step") manager = folded["manager"] - if manager.count(REPAIR_MANAGER_ARRIVAL) != 1: + 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) - arrival = rest.split(_ON_ARRIVAL, 1)[1].split(" ## ", 1)[0] if _ON_ARRIVAL in rest else "" - if _ARRIVAL_STEP.search(rest) or "governance.md" in arrival.lower(): + 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") @@ -564,8 +560,9 @@ def test_each_telling_fails_when_removed() -> None: 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) - assert autonomy_problems(_read(AUTONOMY)) == [] - assert autonomy_problems(_read(AUTONOMY).replace("applies, including", "applies; see", 1)) + 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: @@ -629,6 +626,11 @@ def test_each_card_check_fails_when_its_text_is_removed() -> None: " 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 @@ -641,6 +643,13 @@ def test_each_card_check_fails_when_its_text_is_removed() -> None: 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))