apply refuses a Role's push to a protected path or a model Lens's input, read from its bundle before any token is minted (#139, record 0188)

Merged
DO
7d ago
+947-99

Closes #139, "Harness: apply refuses a Role's push to a protected path or a Lens's input that no model Lens has reviewed". It is the first story of slice 2.

The edits to config/hooks.json and tools/hooks/protected.py are pre-approved by the Maintainer 2026-11-08, ruled by the Factory Builder.

Record docs/decisions/0188-a-roles-push-is-refused-where-it-touches-a-protected-path-or-a-model-lenss-input-read-from-its-bundle-before-any-token-is-minted.md replaces 0070. The Factory Builder gave it 0188, behind 0186 and 0187.

What changes (the Factory Builder's rulings of 2026-11-10)

  • What a push refuses.
    • Refused: protected paths (records 0004 and 0005, the paths a person must judge) and each model Lens's inputs (record 0052).
    • Pushed: a path that is only a deterministic Lens's input (verify's, the secret scan's). Record 0020 holds it at convergence, until every model Lens has reviewed its head.
    • adapters/rules.py reads which Lenses are model Lenses from config/defaults.json at the base commit, beside config/hooks.json. A commit that names none is push_list_unreadable.
    • Under 0070 the Factory's author could have pushed only docs/ to this repo.
  • Code owners. CODEOWNERS and docs/CODEOWNERS join .github/ among the protected paths.
  • effect/1 gains push_commits. One to a Result, naming the bundle by artifact and digest. The branch and the commit it lands on are apply's. No Role permits it yet.
  • harness/bundle.py.
    • fetch_bundle(artifact, digest) is the one function that #314's choice fills; until then it fetches nothing.
    • names() reads every name a patch writes or reads from the patch itself, as git reads it. It reads the header, rename and copy lines, and sides that must match them. Quoted names are unquoted byte by byte. Anything else makes the bundle unreadable: an unknown line, a miscounted hunk, a NUL, a binary patch, or a marker git does not write.
    • held() reads the base's list first, takes the bundle by its digest, then calls push_refusal.
  • apply.job holds a push after every other check and before minting any token. harness/apply_step.py gives it the hold, at the base commit of a read of the pull request made at the head its facts were read at. A push with no hold is refused. A refusal lists each Effect refused in applied/1 and gives its fault in outcome/1.
  • Faults.
    • The Role's: push_protected, bundle_unreadable, bundle_digest_differs, bundle_not_handed_over.
    • The Factory's: push_list_unreadable, bundle_unfetched, push_not_held.
    • The Result names the bundle, so no item can pause the Factory through it.
  • What waits. The push's write itself, with the fix Intent's push. harness/push.py stays reserved for it, so the eleven rows that wait on that file still wait. Until it lands, config/apps.json grants no need for push_commits.
  • Residuals in the record.
    • The author may change what verify reads. Only model review and the machine user's approval hold such a change at convergence; #198's switch makes that approval required.
    • The names checked are the patch's. The write must land exactly that patch.

Notes for review

  • Records. 0070 is replaced. Its three rows now point at the checks that hold the narrowed rule; the rows themselves are not reworded (the Claude review's minor). 0004's and 0005's push rows are re-pointed. 0020 and 0052 each gain a row. 0020's older row, which waits on harness/push.py and names the issue's original words, is left as it is.
  • The session hook. docs/ now holds a protected path, so the hook asks before commands that may write across docs/ as a whole. Two hook tests moved to a notes/ directory.
  • The token sweep (record 0184). Main's walk of every step's reads now reaches this change's read of config/hooks.json and config/defaults.json at the base, adapters/rules.py's _file_at. tests/test_token_needs.py classes it as contents: read, one request. apply's token already holds contents: read through three of its needs, so nothing more is minted and no App's grant changes.
  • Binary changes. Binary changes are refused, as a binary patch or as text with a NUL. So is a patch whose no-newline marker is in another locale's words. Each fails closed, as a person's to push.

Reads

The Claude review and security pass at 1ac1ceb4:

  • Blocking: a header holding a quote was split otherwise than git splits it, so CODEOWNERS could be touched unread.
  • Major: a hunk count long enough to crash Python; a missing artifact counted as the Factory's fault; no step gave apply the hold.
  • Minor: /dev/null with no mode line; the 0070 rows; 0020's old row.
  • Info: the hook asking about docs/.

All were fixed in b7f396ff, except the two record rows and the hook note, which are described above.

ReviewerHeadUnread partsBlockingMajorMinorInfo
agy1ac1cebnone1100
muse1ac1cebnone0030
astra882f9denone0400
FindingSeverityCriterionWhereWhatDisposition
agy#1blockingPR-2harness/bundle.py:60Unquoted paths with tabs or trailing fields on diff headers bypass held() while git apply writes the target pathfixed in 5f924cb1 (each side names only what its header or rename names; the tab case refused at b7f396ff)
agy#2majorPR-3harness/bundle.py:54_name() double-decodes raw UTF-8 bytes in quoted paths and leaves unknown backslash escapes unrejectedfixed in 5f924cb1 (quoted names unquoted byte by byte, unknown escapes refused)
muse#1minorPR-5harness/apply_step.py:139The apply step never gives apply.job the bundle hold the decision says it givesfixed in b7f396ff (apply_step gives apply.job its hold, at the base of a read at the facts' head)
muse#2minorPR-3harness/bundle.py:91A mutant deleting the spaced-name header reading survives every Bundle testfixed in 5f924cb1 (test and mutant for the spaced-name header)
muse#3minorPR-3harness/bundle.py:139A hunk count past Python's int digit limit raises out of bundle.names instead of reading as unreadablefixed in b7f396ff (counts of nine digits at most)
astra#1majorPR-5harness/bundle.py:29The nine-digit hunk limit has no test at its boundaryfixed in 9ccca631 (nine- and ten-digit counts, mutant)
astra#2majorPR-5harness/bundle.py:94Matching a side to its header does not hold the prefix rulefixed in 9ccca631 (side prefixes on both sides, mutant restored)
astra#3majorPR-3harness/bundle.py:181Binary content passes the hold when represented as text hunksfixed in 9ccca631 (a line with a NUL makes the bundle unreadable)
astra#4majorPR-3harness/bundle.py:186Arbitrary backslash lines are accepted inside a hunkfixed in 9ccca631 (only git's own marker is read)

Astra's second read, after its four majors were fixed:

ReviewerHeadUnread partsBlockingMajorMinorInfo
astra9ccca63none0100
FindingSeverityCriterionWhereWhatDisposition
astra#1majorPR-5harness/bundle.py:128The header-prefix guard has no test that kills its removalfixed in bada18a4 (a mode change under long/ prefixes, mutant)

All three readers ran: Argon (gemini-4-argon-high, 12 parts), Muse (muse-wonder-full-1.0), and Astra (gpt-6-astra, twice). Astra's second read found one test gap, now fixed; no code changed, so it was not read a third time.

Checks

At the numbered head, with main merged in up to record 0187:

  • make checks passes whole.
  • tests.test_token_needs, tests.test_apply, tests.test_adapters, tests.test_steps, tests.test_hooks and tests.test_approve pass, with the two tests.test_tools tests that failed while the record had no number.
  • Every mutant of this change is killed by its named test: 124 run by name on the merge at 6b2fbc32, none stale at the numbered head. The merge group runs every shard in full.
  • The full make verify is CI's, per the Maintainer's rule of 2026-11-09.

šŸ¤– Generated with Claude Code