Skip to content

Admit the ten openDox runtime files under the walked root src/opendox - #1067

Merged
brettheap merged 3 commits into
mainfrom
chore/admit-opendox-runtime-files
Sep 16, 2026
Merged

brettheap merged 3 commits into
mainfrom
chore/admit-opendox-runtime-files

Conversation

@brettheap

@brettheap brettheap commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openxfactory-4 (openXfactory-4-openDox_extraction)

CLAIM: 5699629780
RULED: Q-R1..Q-R4 — #656 comment 5701772032 (Brett Heap, 2026-09-16, by interactive multi-choice; every RECOMMENDED answer adopted — each is what this PR and openDox-code #25/#26 already do).
Refs #656 (stays OPEN).

Admit the ten openDox runtime files under the walked root src/opendox

docs/opendox-carve-admissions.yaml gains ten created: rows under opendox_code, for the src/opendox/runtime/ subpackage that split-opendox-two-layer-product § 3.5 and § 3.6 add at the leg.

This PR lands FIRST, per RULED Q-L1 and the precedent every existing row in this file follows: the leg PRs it serves are openDox-code build/3-5-runtime and build/3-6-repository-act.

Why exactly ten, and why not more — measured, not assumed

scripts/verify-carve-arrival.py::declared_roots over rows_for(manifest, "opendox_code") — 119 effective rows — returns exactly ['src/opendox', 'tests'].

So everything the two leg PRs add outside those two roots needs no admission and gets none:

  • migrations/ (the ordered SQL, at the root of the leg — § 3.5's own placement sentence);
  • deploy/compose/ and deploy/kubernetes/;
  • docs/runtime.md, pyproject.toml, .gitignore, .github/workflows/validate.yml;
  • and the new tests_runtime/ tree — eight test modules that would each have needed a row had they gone under tests/. under_roots is segment-aware by design ("tests_helpers/x.py is not under tests, and a prefix test that says it is quietly widens the walk"), so a new top-level test directory is outside the walk. That is the single decision that keeps this diff at ten rows.

What remains is one new subpackage, and its ten modules are the ten rows.

The since: shas are BRANCH commits

That is what the rows for src/opendox/web/views/intent-binding.js and src/opendox/display_profile.py already do, and for the same reason: RULED Q-L1 has this admission PR land first, so the leg commit it cites cannot yet be on the leg's main.

sha branch files
9b81cf4dcdfcaba3d51ae1f5505d4a38f086d699 openDox-code build/3-5-runtime the eight § 3.5 modules
a34601a0dfcfef1d8124cbab472bb5e2d6bd114f openDox-code build/3-6-repository-act local_git_adapter.py, repository_act.py

What this PR does NOT do

  • It does not tick a tasks.md box, touch openspec/changes/ or the README's "OpenSpec Records" block — so Rule 6 does not apply to it.
  • It does not move a pin, a manifest row or a digest. docs/opendox-carve-manifest.yaml is untouched: the manifest declares what LEAVES openxFactory and never what a destination assembles (RULED OQ-C), which is why this file exists at all.
  • It admits by name, which is what an admission is — "a name alone … admits whatever is written at it". The files' content is reviewed on the leg PRs.

Measured

  • scripts/verify-carve-arrival.py::read_admissions parses this file at this head and returns 31 opendox_code admissions, in sorted order. That function refuses an out-of-order created: list, a repeated path:, a reason: carrying a newline and a since: that is not 40 lowercase hex; all four gates pass.
  • python -m pytest -q tests/carve_arrival tests/carve_manifest at this head: 277 passed, 4 failed. The same four fail on the unmodified base in this checkout (git stash + rerun, same four names), because this clone is shallow — the carve commit b075fd91 is not in it — and its openDox/openXdox submodules are not materialized. They are a property of the checkout, not of this diff, and they are test_the_real_repository_answers_at_the_ruled_path, test_the_real_manifest_carries_the_q6_form_and_the_four_rows_s5_re_destines, test_carved_reach_resolves_the_four_re_destined_rows_at_their_arrival and test_the_real_manifests_declared_lines_are_the_floors_lines. CI, which checks out fully and materializes both submodules, is the measurement that counts.

Precedent for the shape and the body: openxFactory #1030 § 3, which admitted three slice-S7 files the same way.

Summary by Sourcery

Admit the ten openDox runtime files and enforce their provenance in the carve-arrival checks.

Enhancements:

  • Record admissions for the ten openDox runtime and repository-act files under the walked src/opendox root, preserving their introducing commit provenance.
  • Add regression coverage that pins all ten paths, their two introducing commits, and the required adapter import path.

Tests:

  • Extend carve-arrival validation to ensure the runtime admissions remain complete, ordered by provenance, and correctly grouped by introducing commit.

`docs/opendox-carve-admissions.yaml` gains ten `created:` rows under
`opendox_code`, for the `src/opendox/runtime/` subpackage that
`split-opendox-two-layer-product` § 3.5 and § 3.6 add at the leg.

WHY THESE TEN AND NOT THE WHOLE ACT. Measured, not assumed:
`scripts/verify-carve-arrival.py::declared_roots` over
`rows_for(manifest, "opendox_code")` — 119 effective rows — returns exactly
`['src/opendox', 'tests']`. Everything the two leg PRs add OUTSIDE those two
roots needs no admission and gets none: `migrations/`, `deploy/compose/`,
`deploy/kubernetes/`, `docs/runtime.md`, a new `tests_runtime/` tree,
`pyproject.toml`, `.gitignore` and `.github/workflows/validate.yml`. The new
test tree is deliberately `tests_runtime/` and not `tests/`: `under_roots` is
segment-aware ("`tests_helpers/x.py` is not under `tests`"), so eight test
modules that would each have needed a row need none, and the surface this file
grows by is the ONE new subpackage.

Precedent: openxFactory #1030 § 3, which admitted three slice-S7 files the same
way. Shape and gates: `{path, reason, since}`, alphabetical by `path:` within
the destination, `since:` 40 lowercase hex.

THE TWO `since:` SHAS ARE BRANCH COMMITS, and that is the same thing the rows
for `src/opendox/web/views/intent-binding.js` and
`src/opendox/display_profile.py` already do — RULED Q-L1 has this admission PR
land FIRST, so the leg commit it cites cannot yet be on the leg's `main`:

  9b81cf4dcdfcaba3d51ae1f5505d4a38f086d699  openDox-code `build/3-5-runtime`
      the eight § 3.5 modules
  a34601a0dfcfef1d8124cbab472bb5e2d6bd114f  openDox-code `build/3-6-repository-act`
      `local_git_adapter.py` and `repository_act.py`

MEASURED. `scripts/verify-carve-arrival.py::read_admissions` parses this file
at this head and returns 31 `opendox_code` admissions, sorted (it refuses an
out-of-order list, a repeated `path:` and a `since:` that is not 40 lowercase
hex). `python -m pytest -q tests/carve_arrival tests/carve_manifest` at this
head: 277 passed, 4 failed — and the same four fail on the unmodified base in
this checkout (`git stash` + rerun), because this clone is shallow (the carve
commit `b075fd91` is not in it) and its `openDox`/`openXdox` submodules are not
materialized. They are a property of the checkout, not of this diff.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds ten name-based opendox_code admissions for the new src/opendox/runtime/ subpackage, split between the two downstream branch commits; no manifest, source, task, or OpenSpec changes are included.

File-Level Changes

Change Details Files
Admit the ten runtime modules under the walked src/opendox root, using branch-commit provenance for the downstream leg PRs.
  • Add six core runtime modules from the build/3-5-runtime leg.
  • Add the migrations and OIDC modules from the build/3-5-runtime leg.
  • Add local Git adapter and repository-act modules from the build/3-6-repository-act leg.
  • Keep admission paths sorted and provide 40-character lowercase since SHAs with rationale for each file.
docs/opendox-carve-admissions.yaml

Possibly linked issues

  • #unknown: The PR directly advances the issue’s two-layer openDox extraction by admitting its runtime application, database, identity, and repository modules.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@brettheap

Copy link
Copy Markdown
Contributor Author

@copilot review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Add provenance assertions and revise the misleading atomicity wording.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds ten governed opendox_code admissions for new openDox runtime files.

Changes:

  • Adds eight runtime admissions from §3.5.
  • Adds two repository-act admissions from §3.6.
  • Preserves ordering and branch provenance metadata.
File summaries
File Summary
docs/opendox-carve-admissions.yaml Registers ten runtime files; add exact batch assertions and clarify the rollback/ordering guarantee.
Review details

Suppressed comments (1)

docs/opendox-carve-admissions.yaml:116

  • together or not at all overstates the act's guarantee. The implementation writes the row before filesystem creation and rolls it back on a creation error, but a process killed between git init and transaction commit can leave a repository without a map row; retries refuse that directory. Please describe the ordered/rollback behavior instead of promising cross-system atomicity.
        reason: "added by opensoft/openDox-code `build/3-6-repository-act` (split-opendox-two-layer-product § 3.6, RULED C3 `#656` comment `5544381563`) — the repository-creation act — the map row and the repository together or not at all — plus `attach_remote` and `push_to_remote`, RULING C3's 'a remote can be attached later' and 'a push, not a migration'"
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/opendox-carve-admissions.yaml Resolved
…rstating the act

Both of Copilot's findings at `480fb531`, answered where they were made.

1. THE BATCH WAS NOT PINNED (inline thread, accurate).
   `tests/carve_arrival/test_verify_carve_arrival.py` pins six earlier bumps
   path-by-path and `since`-by-`since`, and then falls back to generic shape
   checks; nothing held these ten. A future edit could drop one, rename it, or
   move a `since` and the suite would stay green. So this commit adds THE
   SEVENTH BUMP on the file's own precedent (the sixth bump, § 3.4 slice S7's
   three DISPLAY-facet files): every one of the ten paths asserted present,
   every `since` asserted exact, plus two group invariants — the eight § 3.5
   modules share one introducing commit and the two § 3.6 modules share
   another, because neither group means anything a module at a time (the same
   argument the sixth bump makes about the facet's two halves) — and one more
   that is specific to this act: `src/opendox/runtime/local_git_adapter.py` is
   the file § 3.7's neutral conformance corpus imports as
   `opendox.runtime.local_git_adapter`, so re-homing it is a change to what
   § 3.7 can import and must not pass as a routine rename.

2. `together or not at all` OVERSTATED THE ACT (suppressed comment, accurate).
   No transaction spans a database and a filesystem and the implementation does
   not claim one does: `repository_act.create_repository` writes the map row
   FIRST inside the caller's transaction, creates the repository second, and a
   failure in the second rolls the first back with the caller's transaction —
   but a process killed between `git init` and that commit leaves a directory
   with no row, and the next act refuses that directory BY NAME rather than
   adopting it. The `reason:` now says exactly that instead of promising
   cross-system atomicity. The module's own header already said it; the
   admission row did not, and the admission row is what a reader of this file
   sees.

Measured at this head: `python -m pytest -q tests/carve_arrival` — 132 passed
in 22.87s (the new pin included).

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 16, 2026 15:09
@brettheap

Copy link
Copy Markdown
Contributor Author

@copilot review

Copilot AI commented Sep 16, 2026

Copy link
Copy Markdown

@copilot review

Addressed in 7fb00ea: the committed admissions test now pins the ten runtime rows to their exact introducing SHAs, and the repository_act.py admission wording no longer overstates atomicity.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Only a minor ordinal-label nit was noted; no blocking issues remain.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

…nd seventh

Copilot's review of #1067 at `7fb00ea`, accurate. `tests/carve_arrival/
test_verify_carve_arrival.py` already labels § 3.4 slice S8's own
`openxdox_code` file THE SEVENTH BUMP (line ~3993), so a second seventh made
the provenance history of that file ambiguous in exactly the place it exists to
be readable. Renamed to THE EIGHTH BUMP, and the block now SAYS what the
ordinals count — amendments to the admissions document across destinations, not
`opendox_code`'s own bumps, of which this is the sixth — so the next author
does not have to re-derive it.

Measured at this head: `python -m pytest -q tests/carve_arrival` — 132 passed
in 25.99s.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 16, 2026 15:19
@brettheap

Copy link
Copy Markdown
Contributor Author

@copilot review

Copilot AI commented Sep 16, 2026

Copy link
Copy Markdown

@copilot review

Addressed in da89c46: the runtime-admission block is now labeled THE EIGHTH BUMP, and python -m pytest -q tests/carve_arrival/test_verify_carve_arrival.py passed (132 passed).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved review comments were identified.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@sonarqubecloud

Copy link
Copy Markdown

@brettheap
brettheap marked this pull request as ready for review September 16, 2026 18:03
@brettheap
brettheap merged commit 00b1e93 into main Sep 16, 2026
15 checks passed

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 7 hours by commenting @sourcery-ai review. Upgrade to get a review now.

brettheap added a commit that referenced this pull request Sep 16, 2026
One commit came in: `00b1e93b` ("Admit the ten openDox runtime files under the
walked root `src/opendox`", #1067). IT AUTO-MERGED CLEAN — no conflict, no hand
resolution. The two incoming files (`docs/opendox-carve-admissions.yaml`,
`tests/carve_arrival/test_verify_carve_arrival.py`) are files this branch never
touches, so they arrive unchanged; this branch's eight files are untouched by
the incoming side.

Taken before the bench round on PR #1069 so every figure the round re-measures
is taken at the tree the pull request would merge.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
brettheap added a commit that referenced this pull request Sep 16, 2026
…a39141)

RULED 2026-09-16 by Brett Heap, in session (multichoice round), on the
governance note that put the register's 7→8 growth to him (PR #1029
issuecomment-5662333218): verbatim **"Keep the eighth entry"** — recorded at
issuecomment-5702650701. The growth is D3's disposition applied at the landing
head and not a count D3's ruling fixed; the baseline is the entries the
register holds WHEN the gate lands. The eighth entry
(`encode-wallet-authority-rulings-r6-r12`, class list-runs-into-prose) STANDS,
and the register lands at EIGHT on Brett Heap's word rather than on this lane's
reading alone. NOTHING THE RULING KEEPS IS EDITED: not `CLOSED_REGISTER`, not
the entry's declaration text, not its sha256 — a byte moved there would move
the digest, which is the one thing the closure pins.

Recorded in the three records the packet keeps this in, in the same words:
the entry's own `why:` in `scripts/code-surface-register.yaml`,
`CLOSED_REGISTER`'s provenance comment in `scripts/code_surface.py`, and
`tasks.md` § 3.4's eighth-carrier paragraph.

TENTH RE-MEASUREMENT, taken WITH the merge of `origin/main` `fa39141c`
(merged at `49007dc4`) rather than left for a later round:

  $ python3 scripts/validate-code-surface.py .     # exit 0
  code_surface: 47 active proposals, 47 declaring — 5 `none`, 34 a repository
  list, 8 named by the register, 0 outside the grammar.
    archive (read, never judged): 169 proposals, 123 declaring, 3 of them
    outside the grammar.
  $ python3 scripts/validate-scope-globs.py .      # exit 0

THE FIRST RE-MEASUREMENT SINCE THE SECOND AT WHICH THE ACTIVE CORPUS GREW, and
a measurement rather than an inference: `git diff --name-status
b1df95e..fa39141 -- 'openspec/changes/*/proposal.md'` is exactly two `A`
lines and nothing else — no `M`, no `D`, no `R`. `adopt-entry-grain-dispositions-form`
(#1050) declares a repository list (33 → 34) and `scope-pinned-arm-root-naming`
(#1052) declares `none` (4 → 5), the archive is UNMOVED at 169/123/3, BOTH
CONFORM and NEITHER is one of the eight — so no carrier arrived, NO ENTRY WENT
STALE (`scan().stale` is `()`) and the register stands at EIGHT untouched
(8 entries, `CLOSED_REGISTER` length 8, equal). Of the 6 commits `main` gained,
not one touches `gate-code-surface-declarations/`, `code_surface.py` or
`code-surface-register.yaml` — the two filings above, an openDox walked-root
admission (#1067), another packet's tasks § 3.4 amendment (#1035), the
openDox/openXdox consumer gate (#1059) and the `retired:` row-form carve
(#1032) — and the merge resolved ZERO conflicts. THE SCENARIO FIRED A NINTH
TIME AND AGAIN COST NOTHING; the ninth's "as this transcript/file stands" is
demoted to "at that re-measurement" in the same edit, since a clause that means
"latest" has to move every time the latest does.

tests/code_surface 153, tests/scope_globs 99, tests/target_release 96, 348 for
the three suites, all unchanged by the merge and by this edit. `OPENSPEC_TELEMETRY=0
openspec validate gate-code-surface-declarations --strict` — valid.

Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap pushed a commit that referenced this pull request Sep 18, 2026
…ing history, and re-measure the leg figures

FOUR findings, all measured FACT before they were taken.

1. THE ORDINALS (Copilot review `5239585507` @ `d3d28269`, suppressed;
   RULED A FACT FINDING by the holder after the previous actor answered it by
   measurement on comment `5719043676`). The previous answer was right that an
   ordinal cannot be read off a block's POSITION — the assertion blocks in
   `tests/carve_arrival/test_verify_carve_arrival.py` are not in ordinal order
   and never were — and wrong that the ordinals therefore stood. Measured
   against the document itself they did not:

     git log --first-parent origin/main -- docs/opendox-carve-admissions.yaml

   diffing each commit's PARSED `created:` sets gives ELEVEN amendments over
   the seed (#979 `972b484a`) — PR #984, #1002, #1001, #1009, #1010, #1023,
   #1030, #1025, #1067, #1068 and this act — of which TEN bump `opendox_code`.
   Slice S5's amendment (#1023 @ `ee251d6c`, eight created files across both
   legs and the first admission-level re-homing) was recorded with NO ordinal,
   so every ordinal after it was ONE LOW: slice S7's three read SIXTH and are
   the SEVENTH, slice S8's one read SEVENTH and is the EIGHTH, the runtime ten
   read EIGHTH and are the NINTH — and that block's "of which this is the
   sixth" is the EIGHTH `opendox_code` bump. RULED Q7's five and this act's one
   carried none at all, and the docstring's narrated history stopped at SEVENTH
   while the code below it named an EIGHTH: a file that cannot be read in one
   direction without contradicting the other.

   Every ordinal now agrees, and the rule is stated with the ONE COMMAND THAT
   DERIVES IT, so the next amendment reads its ordinal off the history instead
   of off a neighbour. The three amendments the docstring never narrated (#1067,
   #1068 and this act) are narrated. The durable-assertions list, which had
   stopped enumerating what the block below actually asserts, gains slice S5's
   eight, slice S8's one and the ten runtime entries.

   THE REUSED RATIONALE IS DISTINGUISHED FROM THE BUMP NUMBER, which is what
   made this drift invisible: this act's block pins to its introducing commit
   "for the reason the DISPLAY-facet block states" and NAMES that block, whose
   ordinal moved with the renumbering while its argument did not. The runtime
   block's ordinal paragraph now records BOTH corrections — it read SEVENTH,
   collided, was moved to EIGHTH, and was still one low — because both are the
   same defect. Its stale "line ~3993" pointer is gone with them.

   Copilot's own arithmetic was wrong in the other direction (it called this
   act's admission the eighth amendment and the seventh `opendox_code` bump;
   measured they are the ELEVENTH and the TENTH). The finding was still right
   that the history had stopped agreeing with itself.

2. THE ADMISSION REASON (Copilot review `5246578877` @ `30a63ebe`, thread on
   `docs/opendox-carve-admissions.yaml:146`). MEASURED in a pristine `0b4e8bbf`
   worktree of openDox-code with the leg's file copied in:

     pytest -q tests/test_display_facet_leaves.py --noconftest
       ->  11 failed, 2 passed in 0.61s        (node v24.21.0 present)

   The reason said `10 failed / 2 passed` and a three-versus-nine split. The
   file carries THIRTEEN tests at the leg's landing head `b51a1ca1`: FIVE
   node-gated, over FOUR modules (`display.js`, `explorer.js`,
   `outline-model.js` and now `docs.js`), and EIGHT reading the source. The old
   "three" named the three MODULES and miscounted the tests even at the
   introducing commit, where it is four and eight over twelve. The reason now
   states the measurement, says it is taken AT THE LANDING HEAD and not at
   `since:` — which stays the introducing commit `338143a3` — and names what
   moved it: openDox-code#28's own Copilot round added the thirteenth test.

   The two that pass at the pristine base are the return-value guard beside
   `applyTokens` and the behavioural probe that only bites once `runAddSection`
   forwards its argument, so all SEVEN leaves are failed by at least one of the
   eleven.

3. THE FOUR MANIFEST ROW NOTES (same review, thread on
   `docs/opendox-carve-manifest.yaml:2498`): `10 of 12` on all four synchronized
   copies -> `11 of 13`. "Each failure its own leaf" is replaced by what is
   true of eleven failures over seven leaves: every leaf failed by at least one
   of them, with the two passers named.

4. THE RUNBOOK'S PROVENANCE PARAGRAPH (same review, suppressed;
   `docs/opendox-cutover-runbook.md:379-383`): it still read "CURRENT TO RULED
   Q7's CSS EXTRACTION" and called Q7 "THIS act" while the tables above it are
   this act's 2717 and its `opendox_code` cell is 1763 — and a second, older
   "THIS ACT CARRIES" in the same paragraph named slice S7. Two acts called
   "this act" in one paragraph, neither of them the act the totals belong to.
   Re-headed to the § 3.4 SLICE-S7 RESIDUE annotation with its own window
   (2710 + 7 = 2717), Q7 restated as the act behind it, and the inner claim
   given slice S7's PR and sha. Swept with it: § 5's `--allow-created` note,
   whose "THIS act adds three more entries" meant PR #1030 and has had seven
   amendments since.

GATE at this head:
  scripts/validate-carve-manifest.py                             OK
    456 rows, 143/175/138, 318 digests, none undeclared, 4 re-destined, 2 retired
  pytest -q tests/carve_arrival tests/carve_manifest             408 passed

No absolute moves: 2717 / 176 / 1745 / 1763 / 2715 stand as measured at the
merge. No assertion changes — every ordinal lives in a comment or a docstring,
grepped repo-wide, and nothing reads them.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap pushed a commit that referenced this pull request Sep 18, 2026
Self-review of `f3fb6e3f` before the review of it. The § 5 `--allow-created`
note, re-anchored in that commit, said PR #1030 "added three more entries to
it, with seven further amendments since". Measured from the same derivation
the same commit installs, PR #1030 is amendment SEVEN and the ones after it
are #1025, #1067, #1068 and this act — FOUR, not seven. Seven is the ORDINAL,
not the remainder, and putting the two in one sentence is precisely the
conflation the renumbering exists to end.

The four are named now rather than counted, so the sentence is checkable
without re-deriving it.

Gate unchanged at this head: scripts/validate-carve-manifest.py OK (456 rows,
143/175/138, 318 digests, none undeclared, 4 re-destined, 2 retired);
pytest -q tests/carve_arrival tests/carve_manifest 408 passed. Also measured
at this head, beyond the brief: tests/carve_conformance + both pin suites
143 passed, and scripts/verify-carve-arrival.py --destination opendox_code
--phase B against openDox-code main 5c137a90 exits 0 — 117 arrived, 35
digests, 82 declared-edit rows within their lines, 1 unapplied, 4/4 replicas,
148 files none undeclared, 2 rows RETIRED and verified absent, 22 admissions
used, 11 stale.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap added a commit to opensoft/openDox-code that referenced this pull request Sep 18, 2026
…ation, and nothing else (RULED Q1/Q2) (#25)

Lane: openxfactory-4 (openXfactory-4-openDox_extraction)

CLAIM: 5699629780
Refs #656 (stays OPEN).

# § 3.5 — the openDox runtime: FastAPI + Postgres, identity and coordination, and nothing else

`openspec/changes/split-opendox-two-layer-product/tasks.md` § 3.5 at openxFactory `main`.

## The two rulings this realizes, in their own words

> **RULING Q2** — #656 comment [`5542792997`](https://github.com/opensoft/openxFactory/issues/656#issuecomment-5542792997), Brett Heap, 2026-09-04T15:31Z: "**reuse the Hermes install pattern** — FastAPI + Postgres, deployed the way `xFactory-Hermes-Install` is (live on AKS since 2026-07-19), OIDC through the Keycloak broker being adopted in QA". Rejected there: "bolting a database onto today's stdlib `serve.py` monolith; a new full-stack platform."

> **RULING Q1** — #656 comment [`5542694957`](https://github.com/opensoft/openxFactory/issues/656#issuecomment-5542694957): "**the database owns identity and coordination; git owns governed artifacts.** Users, memberships, projects, the project-to-repository mapping, sessions and unsaved drafts live in the openDox database. Specs, changes, ideation documents and contracts stay in git, read from repositories and written back only through the apply lane. … the database is disposable relative to the corpus." Rejected: "documents in the database with git as an export; and the hybrid (ideas in the DB until promoted)."

## What this PR does

**`migrations/`, at the root of this leg** — § 3.5's own sentence is "all at the root of `openDox-code`, not of the assembly root", and `tests_runtime/test_migration_shape.py` asserts it.

* `0001_identity_and_coordination.sql` — RULING Q1's six tables, in the ruling's own list, CLOSED: `users`, `memberships`, `projects`, `project_repositories`, `sessions`, `drafts`. It is **byte-pinned**: `opendox.runtime.migrations.CANONICAL_MIGRATION_SHA256` declares its digest, the runner verifies it *before any mutation* and refuses the whole run on a mismatch, and a test hashes the file against the constant on every `validate`. Changing the schema is an additive `0002_…` file; moving the pin is a two-file act somebody has to mean.
* `0002_migration_state.sql` — the ledger, additive, and the reviewable copy of the DDL the runner bootstraps (`create table if not exists`, because the ledger has to exist before 0001 can be recorded). A test asserts the two texts are identical.

**`src/opendox/runtime/` — one new subpackage, eight modules.** `config` (every setting an env var named in `deploy/compose/.env.example`; no credential default; a redacting `__repr__`), `migrations` (the fail-closed runner), `identity` (the six tables, one store, SQL composed only from module-level constants with every runtime value a `%s` parameter), `db` (the psycopg pool and the unit of work), `oidc` (verify against the broker's JWKS; issue nothing), `app` (the six collections), `cli` (the lifecycle verbs).

**The API.** `/api/v1/{users,memberships,projects,project-repositories,sessions,drafts}` — the closed `COLLECTIONS` tuple, read against the routers `build_v1_router` actually mounts. **The unauthenticated surface is `/livez` and `/readyz`, and it is exactly those two** — both orchestrator probes, because a liveness probe that needed a bearer token would need the broker to be up in order to discover that the broker is down, and a readiness probe that needed one could never report an unreachable database. They return no row, no id and no document. FastAPI's defaults would have published `/docs`, `/redoc` and `/openapi.json` as well; those are OFF unless `OPENDOX_PUBLISH_OPENAPI` says otherwise, and `tests_runtime/test_api_endpoints.py` ENUMERATES the running app's unauthenticated routes against that list rather than trusting this sentence. Everything else resolves a bearer token to an `identity.User` **row** and then asks `memberships.role` about that row — and the store is opened LAZILY, so a request refused at the header touches no database connection at all.

**Design § D5's inversion is where the act is largest, and it is executed rather than described.** "Two current requirements say in terms that the dashboard authorizes nothing on the hosted actor and that identity presence changes no capability verdict — write authority today is a property of WHERE the request came from (a loopback console verdict), not WHO sent it. Q1 and Q2 together invert that: an account is a durable row, authentication delegates to the Keycloak broker, and authorization stops being a property of the request's origin. **This is the largest conceptual change in the rulings and the easiest to under-read.**" So: a first login WRITES the user row; there is no loopback exemption and no header that stands in for a token; and `test_every_collection_refuses_an_unauthenticated_request` runs an **in-process** client — the loopback case — and is refused 401 like any other.

**One lifecycle CLI.** `opendox-runtime runtime init | migrate | serve | status | reset`. Every verb prints one redacted JSON evidence object and exits nonzero on a refusal; no DSN, token or password is ever printed. `reset` needs the spelled phrase `--confirm yes-drop-the-coordination-database`, and it can exist at all only because of RULING Q1's last sentence.

**`deploy/compose/` and `deploy/kubernetes/`**, on the Hermes install's shapes. The **migration identity and the served identity are separate** in both, and `config.migration_database_url` refuses to fall back from one to the other, so the separation is enforced in code as well as declared. No service publishes a host port. Every Secret is committed by **name and key** and never by value; `tests_runtime/test_deploy_shape.py` refuses a `kind: Secret` anywhere under `deploy/kubernetes/`.

**`docs/runtime.md`** — the runbook, including a table of which suite runs where and why.

## Why the seam decision is what it is (this is the one choice a reviewer should check)

The verbs are **not** registered in `opendox.cli.build_parser`, and the tree points three ways about that, so `src/opendox/runtime/cli.py`'s header writes it down:

* `src/subcommand_extension.py` is for a layer **above** contributing a subcommand — that is openXdox, and the runtime is not that layer;
* `src/opendox/cli_project.py` states the counter-rule for openDox's own verbs in terms: "FIXED CORE, NOT AN EXTENSION … these verbs are registered by `build_parser` directly";
* and they cannot go there **in this act**, for two measured reasons. `src/opendox/cli.py` is a CARVED file with a row in openxFactory's manifest, so a line added to it is a declared edit that lands at openxFactory first — a different act with a different claim. And `opendox.cli` **cannot be imported at this leg at all**: it reaches `opendox.serve`, whose line 192 `from ideation_dashboard import serve_openxfactory_lanes` exists at neither carve destination, which `tests/test_consumer_reach.py::STILL_REACHING` records by name and RULED Q-L5 (b′) leaves to the BUILD arc.

So this act ships **both spellings and neither is a fork**: `[project.scripts] opendox-runtime` runs the verbs today, and `RuntimeSubcommand` wraps the *same* registration function in an object that structurally conforms to `subcommand_extension.SubcommandExtension` (asserted with `isinstance`). The day `opendox.cli` imports, wiring them into the core parser is one line at the assembly point and no verb is re-authored.

## What this PR does NOT do — residue, by name

* **It lifts no part of RULED Q-L5 (b′).** `opendox.serve` still cannot import at this leg. Nothing in `opendox.runtime` depends on that being repaired: the runtime imports no part of `opendox.serve`, and the two are joined only by the project-to-repository map row.
* **It creates no repository.** That is § 3.6, the PR stacked on this branch. A project with no repository is a visible state here (`GET /project-repositories/{id}` → 404), which is the shape § 3.6's act fills.
* **Design § D5's unresolved residual stands, unresolved:** "The hybrid where ideas live in the database until promoted was REJECTED, so an idea is a governed document in git from its first save — consistent, and heavier than a lab assistant may want. Whether openDox needs a pre-governed scratch space that is NOT 'a draft of a document' is a real residual, it is not one of the open questions." `drafts` is the draft of a document and is **not** that scratch space. Recorded in `docs/runtime.md` § 9 and here.
* **The `runtime` CI job is not a required check.** Making one required is a repository setting (`docs/branch-protection.md`), a separate act with a separate owner; the gap is named in the workflow rather than assumed away.
* **Not taken from `xFactory-Hermes-Install`, each for a reason** (all four recorded at the seam that would have carried them): its three-layer Subject/Tenant/Domain topology and its `layer` token claim — openDox is single-layer, so that would be a shape without a meaning; its worker-readiness surface; its correlated backup job; and its `uv.lock` supply-chain pin, which `pyproject.toml` already records as a real act with a real owner rather than something a § 3.5 PR should invent.

## The arrival floor

Measured: `scripts/verify-carve-arrival.py::declared_roots` over `rows_for(manifest, "opendox_code")` (119 effective rows) returns exactly `['src/opendox', 'tests']`. So `migrations/`, `deploy/`, `docs/runtime.md`, `pyproject.toml`, `.gitignore`, `.github/` and the **new** `tests_runtime/` tree need no admission (`under_roots` is segment-aware — "`tests_helpers/x.py` is not under `tests`"), and the eight files under `src/opendox/runtime/` each need one. Those rows are **openxFactory PR [opensoft/openxFactory#1067](https://github.com/opensoft/openxFactory/pull/1067)**, which lands first per RULED Q-L1.

## CI, and why it is split

`.github/workflows/validate.yml` is **append-only** against `main` — `git diff --stat`: 99 insertions, 0 deletions, one hunk at `@@ -323,0 +324,99 @@`. Nothing above line 323 is touched, so this cannot collide with openDox-code #24, whose only hunk in this file is inside the comment block at lines 91–147.

* A new **step** in the required `validate` job runs the hermetic suites under that job's existing `pip install -e ".[test]"` — no FastAPI, no psycopg, no PyJWT. That is the package's declared import-weight contract, and `tests_runtime/test_runtime_surface.py` measures it two ways: an AST walk for module-level imports, and a **fresh interpreter** that imports the stdlib-only modules and reports any extra distribution that ended up in `sys.modules`.
* A new **job** `runtime` carries a `postgres:16` service (the Hermes install's own CI shape) and `pip install -e ".[runtime,test]"` for everything that needs a database, a token or a web framework. Where `OPENDOX_TEST_DATABASE_URL` is unreachable a **developer's** tree skips with the reason printed — never a silent pass, never a red tree for somebody without Postgres — and **in CI the same absence FAILS**: pytest exits 0 when every collected case is skipped, so a job whose `postgres:16` service failed to start reported green having made no database-backed assertion at all. The job supplies the service, so its absence there is the job's own defect (`conftest._skip_or_fail`, round 5).

## Measured (python 3.12.3, pytest 8.4.2, postgres 16.15)

Every figure below was measured at **`3d587ae8`** — with the `runtime` extra made UNIMPORTABLE, which is the required job's own install — and holds at the current head **`abc7f634`**, which adds only the workflow's record of it and names the command that produced it. A count in this table and a count in the workflow's own comment block must not be two different heads' answers — Copilot's review of #26 was right about that, and both places now say which head they mean.

| run | result |
|---|---|
| the required `validate` job's own invocation (`--noconftest`, the **five** hermetic modules that job names) | **200 passed, 1 skipped** |
| `python -m pytest -q tests_runtime/` with `OPENDOX_TEST_DATABASE_URL` set (the `runtime` job's invocation) | **324 passed** |
| `python -m pyflakes src/opendox/runtime/*.py tests_runtime/*.py` | clean |
| `yaml.safe_load` over `.github/workflows/validate.yml` | parses; jobs `['validate', 'runtime']` |

**The one skip, named rather than left to be found.** It is the live reproducer for round 26's credential leak: it needs `psycopg` to make libpq quote an unparsable DSN back, and the required job installs `.[test]` alone. The property it proves — that the probe never interpolates the exception's text — is measured beside it against a stub driver that raises with the DSN in its message, and **that** case runs in the required job. A suite that skipped a contract silently is the thing this act refuses; a skip that names the driver it wants and points at the case that covers it anyway is not that.

The figures moved with every review round, which is why they are stated with a head. `72 → 93 → 97 → 101 → 102 → 106 → 108 → 109 → 111 → 111 → 118 → 122 → 126 → 128 → 130 → 132 → 132 → 132 → 132 → 135 → 138 → 139 → 141 → 142 → 144 → 145 → 153 → 162 → 167 → 167 → 167 → 171 → 173 → 173 → 174 → 181 → 184 → 196 → 197 → 198 → 200` on the required invocation and `115 → 160 → 173 → 180 → 184 → 189 → 192 → 194 → 196 → 197 → 211 → 216 → 223 → 227 → 230 → 232 → 235 → 236 → 236 → 240 → 245 → 246 → 248 → 249 → 251 → 252 → 262 → 272 → 277 → 279 → 280 → 286 → 288 → 289 → 291 → 298 → 301 → 317 → 320 → 322 → 324` on the full suite: each rise is assertions added to answer a finding, never a suite widened to look busier.

## Review round 4 (Copilot review `5225498056` at `45bb29c5`) — eight findings, all fixed

* **The read routes did not ask the question this module's contract said they did.** `GET /users`, `GET /memberships`, `GET /projects` and both project-repository reads authenticated and then returned the whole install, so any signed-in account could enumerate every user's issuer/subject/email and every project's repository `location` and `remote_url`. The scope is now the MEMBERSHIP ROW, applied in SQL; a row the caller may not see is 404 for a user and 403 `authz.not_a_member` for a project — which is also what an id that exists nowhere gets, so the pair is not an existence oracle.
* **The migration run's advisory lock did not cover the work it named.** `apply()` held `MIGRATION_LOCK_KEY` on one connection and did the bootstrap, the ledger read and every migration through another; a pool of one deadlocked. Every statement now goes through the lock's own connection, measured with `max_size=1`. `runtime reset` had the identical shape.
* **The ledger was narrowed after the migrations, not before**, so a wrong `runtime_role` failed the run only once everything had committed — and `/readyz` asks about schema and drift, never grants.
* `defaultMode: 0o555` is a string in YAML 1.1 and the API server rejects the StatefulSet before Postgres starts.
* The migration Job raced the Postgres StatefulSet on a clean install and could retire itself inside `backoffLimit: 2`.
* `list_drafts` collected the principal's sessions with one capped query, so a user with more than `MAX_PAGE_SIZE` sittings lost the later ones' drafts and was refused its own session by name.
* `POST /memberships` carried `on conflict … do update set role`, so a repeat silently changed a role and still answered 201.
* `init` reported a valid install when the repository root existed as a file; `serve` was the one lifecycle verb that printed no evidence on an ordinary shutdown; `STDLIB_ONLY_MODULES` omitted § 3.6's two modules, so on that branch the import-weight contract skipped exactly the files it exists for.

Each fix carries an assertion; the seven suppressed comments of that round are answered one by one in [this comment](https://github.com/opensoft/openDox-code/pull/25#issuecomment-5701276181).

Two defects the suites found in this act's own code, both fixed here and both recorded at the seam:

1. `oidc.CachingJwks._load_keyset` did not catch `jwt.PyJWKSetError`, which is **not** a subclass of `PyJWKError`. A broker serving `{"keys": []}` — a realm mid-rotation, a misconfigured proxy — would have escaped the typed `IdentityUnavailableError` and surfaced past `app.get_principal`'s 401 mapping as a 500.
2. `app`'s dependency callables annotated `request: Any`. FastAPI reads a dependency's annotations to decide where each argument comes from and takes `Any` for a **query parameter**, so every route answered `422 missing query parameter: request` instead of authenticating — sixteen cases red on the first run.

## Review round 6 (Copilot review `5226506490` at `e9bec395`) — four threads and nine suppressed comments, every one answered

* **ONE NAME FOR THE SERVED ROLE.** `.env.example` declared `OPENDOX_RUNTIME_PG_USER` (which created the role) and `OPENDOX_RUNTIME_PG_ROLE` (which the runtime reads and the migration narrows), and the compose file read only the first — so setting the documented one changed nothing, and setting both differently created one role and narrowed another. One declaration now, and both services interpolate it.
* **AND THE NARROWING IS MEASURED.** `revoke` succeeds and changes nothing for the ledger's owner, a superuser, or a role holding the write through another grant. `_narrow_ledger` asks `has_table_privilege` for each of the four writes and raises `LedgerNarrowingIneffectiveError` when one survives; the narrowing is a precondition of the run, so nothing is applied.
* **`/readyz` verifies the pinned `0001` BEFORE it calculates a plan.** `discover()` returns `[]` for a directory that exists and is empty, so an image that lost the canonical file made `plan()` and `drift()` both empty on a fresh database and readiness reported `schema: applied`.
* **A request body is bounded.** `BodySizeLimit` is a pure ASGI middleware: a declared `Content-Length` over one MiB is refused unread, a chunked body is counted and refused the moment it passes. The cap is declared in the runtime rather than imported, because `opendox.serve*` cannot be imported at this leg (RULED Q-L5 (b′)).
* The nine suppressed comments are answered one by one in [this comment](https://github.com/opensoft/openDox-code/pull/25#issuecomment-5702502815): the compose healthcheck's literal port and the repositories volume's literal path (both now follow their settings), the Kubernetes root held EQUAL to the mountPath it is claimed at, the readiness probe's missing `timeoutSeconds`, a foreign-key race that escaped as a 500 instead of the documented 404, a discovery regex broader than the filename contract, and an `importorskip` that let the `runtime` job pass without exercising a single OIDC or API case.

## Residue this act records rather than resolves (round 6)

* **The served process does not assert its own `current_user`.** The runner now refuses a narrowing that changed nothing, and creation, narrowing and the served DSN derive from one `.env` declaration — but a served container that is handed a DSN for some other role is still only caught by the operator's own care. Asserting it in the process needs the role name configured on the served container too, which is a new setting and a separate declared act.

## Review round 7 (Copilot review `5226856961` at `51cfff71`) — three threads and nine suppressed comments, every one answered

* **Two files claiming one version** made `apply()` run and COMMIT the first and fail on the ledger's key for the second — the partially applied run the runner exists to prevent. `discover_migrations` refuses the directory by name, before anything is mutated, for every caller.
* **The Kubernetes bootstrap created a role the migration did not narrow**: the StatefulSet hard-coded `opendox_runtime` while the Job read `runtime_pg_role`. Both read the same ConfigMap key now — the Kubernetes half of the one-name rule the compose package got in round 6.
* **The narrowing interpolated an UNQUOTED identifier** while the bootstrap creates the role with `%I`, so a configured `MyRole` had its revoke and grant folded to `myrole`: a different role, or none. Quoted here, and measured against a genuinely mixed-case role.
* The nine suppressed comments: two existence oracles (a session and a draft read by id, each answering 404 for an unknown and 403 for another user's — one refusal each now, naming no id), `migrate --plan` skipping the canonical gate `apply()` runs first, `status` reporting pending migrations and staying healthy (and now running that same gate, because an empty directory otherwise reads as "nothing pending"), `status` blaming the database for a failure of the TREE, an `importorskip` that let the API suite skip in CI, and a filename assertion broader than the runner's own regex.

## Review round 8 (Copilot review at `392fd143`) — two threads, both fixed

* **`serve` could not tell "served and stopped" from "never started".** `uvicorn.run` does not propagate a lifespan startup failure — uvicorn logs it and the loop returns — so the verb emitted `ok: true` and exited 0 for a process that never served a request. An explicit `uvicorn.Server(uvicorn.Config(...))` runs, and `server.started` decides which evidence is emitted.
* **Nothing below the canonical version is a migration.** The filename shape accepts `0000_*.sql` and discovery only ordered and de-duplicated, so such a file ran BEFORE the pinned `0001` — mutating the database after the digest gate passed and before the schema that digest pins existed.

**And a rule this round proved twice.** Round 7's preview test passed in a developer's tree and went RED in the required job, because the gate it asserted sat behind the deferred driver import. The gate moved ahead of that import (asking about the TREE needs no driver), and the hermetic figure is now measured with `psycopg`, `psycopg_pool`, `fastapi`, `uvicorn` and `jwt` made unimportable — the required job's own install. A figure measured with the extras present is not that job's figure.

## Review round 9 (Copilot review at `392fd143`) — three threads, all fixed

* **The miss cooldown's clock was read before the lock**, which is the same correction `keyset` took in round 5, in the method beside it. A caller queued behind a forced refresh — which holds the lock for a whole fetch — was refused a refresh the cooldown had already allowed, so a real key rotation went unseen until the next miss.
* `CachingJwks(ttl_seconds=...)` is annotated `float`: the arithmetic is float throughout and the suites cross TTL boundaries on purpose.
* `DROP_ORDER` names the ledger through `migrations.LEDGER_TABLE` rather than spelling it twice — the one moment two spellings differ is a rename, after which `reset` would drop six of seven tables and report all seven.

## Review round 10 (Copilot reviews `5227436293` at `ab7f2110` and `5227525961` at `6e09fbe5`) — twelve findings: eleven fixed, one answered by citation

Classified before anything was touched, as this act now does every round — **FIX** (a real defect here: fix plus a test that fails against the old shape), **REPEAT** (already answered on this PR: cite, resolve, change nothing), **OUT OF SCOPE** (a behaviour no ruling ordered: answer by measurement, register, resolve). This round: **11 FIX, 1 REPEAT, 0 out of scope.**

**Three writes that could lose a race, each a claim the code did not keep:**

* **A draft could be written into a session that had ENDED.** `require_open=True` is a promise about the WRITE, and the route's check and the upsert were two statements — a `DELETE /sessions/{id}` committing between them wrote the draft anyway. The session-open predicate now travels IN the insert (`insert … select … where exists (… ended_at is null)`), so the promise is kept by one atomic act rather than by the interval between two. The ordinary refusal is unchanged (409 `coordination.session_closed` from the pre-check, which still gives the better message); the raced one is 404 `coordination.not_found`.
* **`DELETE /drafts/{id}` called `delete_draft` directly**, so a second discard by the owner — or a row gone between the read and the statement — escaped as a 500 instead of the documented coordination 404. Wrapped in `_found`, like the session-close path beside it.
* **`POST /sessions` inserted outside both translations.** A project deleted between the membership check and the insert made a raw foreign-key violation escape as a 500. `identity.open_session` goes through `_conflict_if_duplicate` now (SQLSTATE → `NotFoundError`) and the route through `_conflict` (→ 404), which is what every other referencing write in this API already did.

**The existence oracle one step out from the one round 7 closed.** Round 7 made "unknown draft" and "another member's draft" one answer — *for a member of the project*. A caller who was NOT a member still got `authz.not_a_member` for a draft that exists and `authz.not_your_session` for an id that does not, so the id space stayed walkable by anyone with an account. Ownership is asked FIRST now, before authorization is consulted at all, and both questions have one refusal. Asserted byte-for-byte, the way the hidden-user pair already is.

**The lifecycle contract's loud half.** Round 8 closed the silent failure `serve` could not report (uvicorn swallows a lifespan error). `Server.run()` also RAISES — `SystemExit` from uvicorn's own `sys.exit(1)` on an occupied port, `OSError` for an address that is not this host's — and that call sat outside every exception-to-evidence handler, so the verb an operator runs longest answered a misconfigured port with a traceback and no JSON. `SystemExit` is named explicitly because `except Exception` does not reach a `BaseException`, and the refusal names the host and port it tried and is redacted like every other message this CLI emits.

**`status` no longer rewrites an answer it already has.** Once `select 1` has succeeded the database IS reachable, and a later failure — a served role without `select` on the ledger, a search path that misses the schema — was reported as `database: unreachable`, pointing an operator at the network for a privilege problem. It is `database: reachable` plus `schema_queries: failed: …` now. Round 7 made exactly this distinction for the runner's own `MigrationError` and left it unmade in the handler one line below.

**The managed-database path had no role provisioning at all.** The bundled Postgres creates and grants the served role on its first start (`deploy/compose/init-runtime-role.sh`); a managed database runs no init script, so the migration owner created the six tables and the served role had no privilege on any of them — the Job succeeded, `/readyz` reported an applied schema, and every request then failed with `permission denied`. Of Copilot's two remedies this took the second, because that role is created out of band with its password anyway and half a provisioning story is worse than a stated one: `docs/runtime.md` states it as an explicit PREREQUISITE with the four statements the bundled script performs, and `tests_runtime/test_deploy_shape.py` DERIVES the required list from that script, so the two paths cannot drift apart silently. The narrowing the migration run then applies to the ledger is named there too, so an operator granting everything knows the one exception.

**Two declared surfaces that were narrower than the code:**

* **`migrations`'s documented connection contract.** The docstring promised `.execute(...)` and the runner also calls `.transaction()`, `.commit()` and `.rollback()` — so a double or an alternative driver written to the documented contract failed with `AttributeError`. The contract is stated in full (four members), and two hermetic tests hold it: one drives a whole `apply()` through a double implementing exactly those four, the other shows the old shorter list raising.
* **`CachingJwks(source=…)` was annotated as a union of the two sources this module ships**, while the cache and the suites only ever ask for `load()` — the rotation and counting sources in `test_oidc_verifier.py` are third implementations already. `JwksSource` is a `runtime_checkable` Protocol now, so the annotation and `isinstance` ask the same question.

**The readiness probe's timeout was EXACTLY the sum of the endpoint's budgets** (10s database checkout + 5s JWKS) while the comment beside it called that "longer than both budgets together". A worst-case-but-valid request had nothing left for scheduling, latency or writing the response. It is 20s now with `periodSeconds` at 30 so a probe still cannot overlap itself, and the test reads BOTH budgets out of the modules that declare them rather than restating them.

**And two prose defects, fixed rather than argued** (both are false statements in landed text, which is the class this act fixes): the deployment's service-account comment was a malformed sentence, and three `tests_runtime` docstrings claimed a narrower import list than their own import block — a hermeticity claim a reader cannot check is the opposite of what those files are for.

**REPEAT:** the JWKS miss cooldown's clock read outside the lock (suppressed at `ab7f2110`) was fixed one head earlier, at `6e09fbe5` — answered on its thread by citation, not re-argued.

**Erratum, recorded here because this act records them:** the commit that recorded the new figure (`cd22da4d`) says "eighteen more hermetic cases"; it is **seven** (111 → 118). The figure itself — 118 at `f9c72341` — is the same in the workflow block and in the table above, which is the number that matters.

## Review round 11 (Copilot review `5228860529` at `cd22da4d`) — nine findings: eight fixed, one answered by measurement

Classified first, as every round is now: **8 FIX, 0 REPEAT, 1 answered by measurement** (a finding whose premise is a description this PR no longer has).

* **The role password was in a process argument.** `psql -v runtime_password=…` puts it in argv, where `ps` and a world-readable `/proc/<pid>/cmdline` can read it for the life of the command — the Secret copied out of the Secret store and into a process table, in both copies of the bootstrap. `\getenv` reads it from psql's own environment now; the role NAME stays an argument, because a name is not a secret. **Measured against psql 16 in a live container before it was written**: `\getenv` sets the variable, `%L` quotes it, and `pg_roles` shows the role created with login.
* **The byte pin did not cover the bytes that ran.** `apply()` read `0001` three times — the gate, `checksum()`, then `read_sql()` to execute — so a migrations directory that can change under the process could pass the pin and run something else, with the ledger recording the digest of bytes that did not run. Each migration is read ONCE into a snapshot now: that is what is hashed, what the canonical pin is re-checked against immediately before execution, and what executes.
* **The streamed half of the body cap answered the wrong refusal**, and Copilot asked for the test that found it. FastAPI's body parser wraps its read in `except Exception` and turns anything it catches into `400 "There was an error parsing the body"` — so a chunked request over the cap stopped reading at the limit (the memory bound held) and then answered 400 instead of the documented `413 request.too_large`, unmeasured because the only cap test sent a declared `Content-Length`. `_BodyTooLarge` is a `BaseException` now, which passes that handler and reaches the middleware — the only frame that can answer for a request whose body it refused.
* **The documented first command could not run on a clean checkout**, in all three places that document it (the runbook, `.env.example`, and the compose file's own inline runbook). `docker compose run` does not build by policy — it is the only one of `run`, `up` and `create` with no `--no-build` flag, because it has nothing to suppress — and the default `OPENDOX_IMAGE` is the local tag `opendox-runtime:local`, which no registry has. `--build` on that one command; `up -d` needs none, and the comment says why.
* **The migration Job could exhaust itself while Postgres was still recovering.** The initContainer proves a LISTENER, and a database replaying a crash recovery listens while answering "the database system is starting up"; the wait carries no credential — deliberately — so it cannot tell that from ready. The honest probe for that case is the migration container itself, which opens a real session, and the Job's retry budget is what makes that a wait rather than a failure: `backoffLimit` 2 → 6, about ten minutes under Kubernetes' exponential backoff.

**Answered by measurement, no change.** The review reports that this description "identifies `6e09fbe5` as the current head and reports `197 passed`" while the workflow says `f9c72341`/`211`. The description said `f9c72341`, `118` and `211` at the time of that review and says `5d86d8b8`, `132` and `236` now; the sentences naming `6e09fbe5` are in the round-10 SECTION, where they name the head the reviews under discussion ran at and the head the JWKS cooldown was fixed at. History and current figure are different claims, and the block that carries the figures says in one line which is which.

## Review round 12 (Copilot review `5229072217` at `3e524f08`) — five findings, all fixed

Classified first, as every round is now: **5 FIX, 0 REPEAT, 0 out of scope** — three threads and two suppressed comments, every one a real defect in this act's own code, each answered with a test that fails against the shape it forbids.

* **The bootstrap's default privileges belonged to whoever ran the script, not to the role that creates the tables.** `alter default privileges` is recorded FOR the current role, the first-start script runs as `$POSTGRES_USER`, and the migration service's DSN is configured separately — so pointing it at another owner (a valid configuration this base documents) meant `0001` created the six tables with no privilege for the served role at all: the Job succeeded, `/readyz` reported a reachable database and an applied schema, and every API request failed `permission denied for table …`. The grant now names the owner — `OPENDOX_MIGRATION_PG_USER` in compose, the `migration_pg_user` ConfigMap key in Kubernetes, both defaulting to `$POSTGRES_USER`, which is today's bundled shape unchanged. **Measured on psql 16.15 in a live container, both ways**: with the fix, a table created by `mig_owner` leaves the served role holding `SELECT|t INSERT|t UPDATE|t DELETE|t`; against the old script, `f f f f`.
* **And the run now MEASURES that**, because a grant that was never made is invisible until a request fails. `MigrationRunner.verify_runtime_access` is the last act of every run: `has_table_privilege` — which counts ownership and group membership, so a role granted through a group passes — for the four rights on every table in the schema but the ledger, and `RuntimeAccessMissingError` naming the missing `table:privilege` pairs otherwise. It is the sibling of the narrowing check beside it (`LedgerNarrowingIneffectiveError`), and it closes the MANAGED path's own version of this finding — an operator who skipped the documented prerequisite — with the same answer. This act does not claim privilege work it did not do.
* **The canonical gate covered the first read, not the run.** `verify_canonical_digest()` hashed `0001`; `bootstrap_ledger()` and `protect_ledger()` then COMMITTED the ledger table and its privilege changes; and only the loop's re-read raised `CanonicalDigestMismatchError`. For a migrations directory that changes under the process — which this runner supports by design, and which is why round 11's per-file snapshot exists — "a tree carrying the wrong `0001` changes nothing at all" was therefore false by two changes. `snapshot_run()` reads every migration's bytes and runs the gate BEFORE the first statement, and the loop drives off that snapshot with nothing left to re-check: round 11's rule ("one read, one digest, one execution") widened from a file to a run.
* **The drafts listing was bounded in rows and not in bytes**, and a row is a document here. Each body is capped at `MAX_REQUEST_BODY_BYTES` (1 MiB) on the way in and `MAX_PAGE_SIZE` is 500, so one authenticated request could force roughly 500 MiB of database fetches, JSON serialization and worker memory, and a few concurrent ones an outage — out of entirely legitimate drafts. `identity.MAX_PAGE_BODY_BYTES` is the SAME NUMBER as the request cap (a page carries no more body bytes than one draft may, and a test asserts the two are one number), and it is applied **in the query** as a running sum over the rows BEFORE each row: the bytes are never fetched, the page is always a prefix so `after` pagination is unchanged, and a draft larger than the whole budget is still returned — the budget bounds what precedes a row, so the first row of a page is never excluded and pagination can always advance. Measured: three 600 KiB drafts were **3 rows / 1,843,200 body bytes** and are now **2 + 1 across two pages**.
* **The managed-database prerequisite typed the password into SQL.** It asked an operator to substitute a value inside a single-quoted literal, where a `'` is a syntax error — or, worse, silently a different password — while the bundled script it is derived from has read it through `\getenv` and quoted it with `%L` since round 11. Same shape now, so the secret never enters the SQL, this runbook, or `~/.psql_history`. **Measured in the same live container**: `pa'ss w0rd` creates the role and logs in.

Every new case was run against the shape it forbids before it was committed — the four hermetic ones fail on the old tree, and the three DB-backed ones fail as *DID NOT RAISE*, *CanonicalDigestMismatchError*, and *the page returned 3 drafts and 1843200 body bytes*. One new case, `test_the_whole_run_is_read_before_the_ledger_is_bootstrapped`, passes against BOTH shapes and its docstring says so: it is not this round's regression (its sibling is), it pins the other half of the promise — that a refusal's whole footprint is the advisory lock — so no later round can satisfy the sibling by moving a mutation earlier instead of moving the reads.

## Review round 13 (Copilot review `5235999257` at `84cbe14e`) — one thread and five suppressed comments

Classified first, as every round is now: **4 FIX, 0 REPEAT, 0 out of scope, 2 answered by measurement** (of which one is the description-versus-workflow figure pair, and one is a behaviour that was measured and found to be the decision).

* **A close in flight raced the draft write.** Round 10 put the session-open predicate INTO the insert, which closed the interval between the route's check and the write; it did not close the one inside the statement. Under READ COMMITTED the `exists` subquery reads the snapshot the statement began with, so a `close_session` committing AFTER that snapshot and BEFORE this transaction commits still left the draft written into a sitting that had ended — which is exactly what `require_open=True` promises cannot happen. `for update` makes the subquery WAIT on a close that is in flight and re-evaluate against the committed row, so the two acts are ordered rather than overlapping. **Measured with two real connections, both ways**: with the close updated and not committed, the new shape's write is still running after three seconds and then raises `NotFoundError` when the close commits; the old shape's had already returned `saved`, with the draft in the database before the session was closed.
* **Two claims the code does not keep, corrected in the text — because in both cases the behaviour is the decision.** `get_store`'s docstring promised that "a request that only reads still gets one consistent snapshot", which READ COMMITTED does not give (every statement takes a new snapshot); the atomicity beside it is real and is what the transaction is for, and asking for the stronger guarantee is a declared act with its own cost — a serialization failure is a retry this API does not have. And `upsert_user`'s said the display fields are "refreshed on every login" while the SQL `coalesce`s: this runtime sees ONE TOKEN PER REQUEST, not a profile event, and whether a token carries `email` depends on the scopes it was issued for, so assigning `excluded.email` directly would make the stored value FLAP between requests made with different tokens by the same person. The docstring now says what the code does and states the consequence the review named — a value removed at the broker is not cleared until a token arrives with a different one — and both halves have a case.
* **The managed-database prerequisite substitutes nothing by hand.** It still carried `'<runtime role>'`, `"<database>"` and `"<migration owner>"`, so an operator who pasted it got a role and a database named after the placeholders and the real served role with no access at all. Every name now arrives through psql's `\getenv` and is quoted by `format`'s `%I`; the password by `%L`. **Measured against postgres 16.15 by running the block verbatim**: it created a role whose name contains a SPACE (`Svc Role`) with a password containing a quote, that role logged in with it, and `pg_default_acl` shows the grantor is the migration owner and the grantee `"Svc Role"`.
* **The compose package's repository root must be absolute, and now says so where it is set.** The application's own default is the relative `var/projects` — right for a developer running `opendox-runtime` directly — and the compose file uses the configured root as the `project_repositories` volume's container mount target. **Measured on Docker Compose v5.5.1**: `docker compose config` ACCEPTS a relative target and the daemon refuses at container creation with `invalid mount path: 'var/projects' mount path must be absolute`. The failure is loud, names the path and happens before anything runs, which is why this stays ONE expression rather than becoming a fixed literal that would make the documented setting mean nothing here again; the new case is labelled a guard rather than a regression, because the value that can be relative lives in an operator's own `.env`.

**Answered by measurement, no change: the description/workflow figure pair.** The review quotes this description at `4bf054ec`/122/216, which is what it said before round twelve's update; both places have named `2052e1e6`/126/223 since, and both name `5d86d8b8`/132/236 now.

## Review round 14 (Copilot review `5236637540` at `f6b7a19c`) — two threads and five suppressed comments

Classified first: **3 FIX** (one of them two call sites, one of them six), **0 REPEAT, 0 out of scope, 0 answered by measurement**. Two threads and five suppressed comments.

* **`current_schema()` IS the search-path fallback this module's qualification was defending against.** Round 5 qualified `runtime reset`'s drops and round 6 qualified the ledger read precisely so that nothing resolves through `search_path` — and the qualification itself resolved through `search_path`, because `current_schema()` answers the first **existing** schema on the path and never the first **configured** one. **Measured on postgres 16.15** with no `tenant` schema: `set search_path = tenant, public` gives `current_schema()` = `public`, `current_schemas(false)` = `{public}`, and `show search_path` = `tenant, public`. So a DSN selecting a schema that was dropped, renamed or never created read and WROTE another one in silence — `MigrationRunner.applied()` reported `public`'s ledger as the selected schema's, after which `plan()` calls a fresh schema migrated and `/readyz` calls it ready, and `runtime reset` qualified every drop as `public.*` and deleted another install's coordination tables under a promise that it would not. `migrations.selected_schema(conn)` asks both questions in one statement and refuses when they disagree, naming both schemas; the same answer replaces `current_schema()` in `_check_runtime_access`'s predicate one method along, where measuring `public`'s tables would have reported on tables the run did not create. **Only the first configured entry is compared, and `"$user"` is not compared at all** — it is not a schema name but the first entry of PostgreSQL's own default `search_path`, where an absent user schema is skipped by design, so a plain install is not refused for having one. Two cases, both failing against the previous head: a hermetic pair through a connection that answers the two columns, and a DB-backed one the way the defect appears — a `users` table in `public`, a schema that is never created, and a DSN that selects it; the reset refuses with nothing dropped and `public.users` intact.

* **The command this service PRINTS was not a command.** `register()` nests every verb under the `runtime` group, so the shortened spelling — the console script followed straight by a verb — exits 2 with argparse's usage error. **Measured through the parser**: `['migrate']` raises `SystemExit(2)` with `invalid choice: 'migrate' (choose from 'runtime')`, and `['runtime', 'migrate']` is the verb. It was what `runtime init`'s evidence emitted as its `next`, what `/readyz` told an operator to run while migrations are pending, what the runbook's transcript showed, and what a case in `test_api_endpoints.py` **pinned** — so an operator who copied the answer the service itself gave them could not make the service ready, and the suite agreed with the broken spelling. Every occurrence in `src/`, `docs/`, `deploy/` and `tests_runtime/` names the group now, and a new hermetic case sweeps all four trees for the console script followed by a verb, so the next one cannot be written silently.
* **The managed-database prerequisite accepted a served role this runtime refuses.** Round 13 made every name in that block arrive through `\getenv` and be quoted by `%I`, and measured it by creating a role named `Svc Role` — which works, in the block. It does not work in the runtime: `config.load_migration_settings` refuses a served role that is not a plain SQL identifier before `migrate` connects, and `MigrationRunner.protect_ledger` refuses it again, because the ledger narrowing interpolates a role name into a `revoke` as **syntax**. A prerequisite an operator can complete and still not start is the same defect as a command they cannot run. The runbook states the grammar now — `[A-Za-z_][A-Za-z0-9_]{0,62}`, with the reason — and says why `%I` is still not redundant under it: the migration owner and the database are under no such constraint, and a served role that IS a plain identifier can still collide with an SQL keyword. The new case pins the statement and both refusals to one spelling.

## Review round 15 (Copilot review `5237498282` at `f86439b1`) — one thread, fixed

Classified: **4 FIX, 0 REPEAT, 0 out of scope, 1 answered by measurement.** One thread and four suppressed comments.

* **The schema guard ran one call too late.** Round 14 made `applied()` and `runtime reset` ask `selected_schema`, and `bootstrap_ledger` runs BEFORE `applied()` in `_apply_locked`. Its `create table` is unqualified — which is right, it must land where the connection's `search_path` selects — so on a connection configured for a schema that no longer exists it created the ledger in `public` and **committed** it, and the refusal arrived one call later: a fail-closed run that had already mutated another schema. The guard is asked before the DDL now, on both of `bootstrap_ledger`'s paths, and the DB-backed case measures the whole run rather than the reader alone — the tables in `public` before and after, with the refused `apply()` in between. Against the previous head it fails with "the refused run created tables in `public`".

* **A concurrent rotation refused a valid token.** The miss-refresh cooldown bounds **fetches**, and it was being used as a bound on **answers**: the thread it denies is precisely the one waiting for another thread's fetch, so a request whose `kid` had already arrived in the new key set raised `InvalidSignatureError` against the old one it was still holding. A denied thread re-reads through `keyset()` now — which takes the same lock the refresh holds, so it waits for the fetch in flight and reads its result, and fetches nothing itself, leaving the amplification bound exactly where it was. The case **forces the order** rather than racing it: the denied thread is held between its read of the old key set and its cooldown question, which is the only window in which the defect exists (an unordered version passes against the previous head, and the docstring says so).
* **The access preflight asked about every table, and not about the schema.** It scanned `relkind = 'r'` across the whole selected schema, so a table that has nothing to do with this runtime — another application sharing the schema, an operator's scratch table — failed the migration run for a privilege the served role was never meant to hold. And `has_table_privilege` alone is not the question: without `usage` on the **schema** a role cannot name those tables at all, so a run could pass the check and every request still fail `permission denied for schema`. The list is RULING Q1's own, imported from `identity` rather than retyped; the schema's `usage` is asked first and named in its own refusal. Both halves measured in one schema against a real role.
* **The page budget bounded what the application received, not what Postgres read.** The inner query selected every `body` and carried it through the window function and the sort before the outer predicate dropped it, so a page of 500 one-megabyte drafts still made the database read and move ~500 MB to return a short prefix. The inner query selects ids and sizes; the bodies are joined back on the ids that survive. Which rows come back — and that at least one always does — is unchanged, and is measured by round 12's own case.

**Answered by measurement, no change: the description/workflow figure pair,** quoted one head apart. Both name `541b0329`/132/235 now, and both say which head they mean.

## Review round 16 (Copilot review `5238724938` at `6c613232`) — two windows left half-closed, both closed

Classified: **2 FIX, 0 REPEAT, 0 out of scope, 0 answered by measurement.** Both are refinements of round 15's own fixes, and both are right.

* **The whole configured `search_path` is walked, not only its first entry.** Round 15 compared the head of the path and exempted `"$user"` — so `search_path = "$user", tenant, public` with neither the role's schema nor `tenant` present stopped the walk at the exempt entry and accepted `public`: the same silent fallback one position along. Every **named** entry ahead of the one PostgreSQL resolved must now exist — "nothing this connection asked for was skipped". `"$user"` stays exempt and only it, because an absent user schema is skipped by design; it is resolved against `current_user`, so a session whose own schema is the answer stops the walk there, which is what that path means. The hermetic fake grew the second question `selected_schema` now asks, because a fake that answered only the first would let the whole walk pass vacuously.
* **The cooldown claim and the refresh are one lock acquisition.** Round 15 made a denied thread re-read, which narrowed the window and did not close it: the claim and the fetch were two acquisitions, so a denied thread could leave the lock and read the cache **before** the claiming thread had taken it to fetch, and reject a valid token carrying the newly rotated `kid`. `keyset_after_miss` holds the lock across the claim **and** the fetch. The cooldown still bounds fetches — one per cooldown, asserted by the load count — which is the property it exists for; what it no longer bounds is answers. The case drives the window itself (the claiming thread paused between its claim and its fetch, the denied thread running during the pause) and hooks whichever method the shape under test claims the cooldown in, so it runs against both heads — and against the previous one the denied thread is refused.

* **And a gap this round itself opened: a dropped coordination table was not reported missing.** The preflight is driven by `pg_class`, so a required table that is not there produces no row and was never added to `missing` — a rerun after `users` was removed reported success and the API failed on the relation later. Restricting the scan to `SERVED_TABLES` (round 15) is what turned "every table in the schema" into a set that can have a hole in it, so the set is compared now and every absent one of RULING Q1's six is named.
* **The JWKS setting promised a discovery this runtime does not make.** "derived from the issuer's discovery document when unset" — nothing reads `.well-known/openid-configuration`; `jwks_url()` appends the fixed Keycloak path. A broker publishing a different `jwks_uri` would have followed the documented configuration and failed readiness. The contract is narrowed to what the code does and says what to set when that is not enough; bounded discovery is a change with its own failure modes and its own tests, and is not smuggled in under a docstring. `0002_migration_state.sql`'s comment also named a test that does not exist, and now names the one that does.

**Registered, not done.** `/readyz` compares ledger versions and migration checksums and does not ask whether the six relations are still there, so an operator who drops `users` while leaving the ledger intact gets a 200. It is the same question the preflight now answers at the END of a run, one surface over, and `verify_runtime_access` is the call readiness would make.

## Review round 19 (Copilot review at `2c56b65`) — three findings, all measured, all real

Classified: **3 FIX, 0 REPEAT, 0 out of scope, 0 answered by measurement.** Each fix carries a case that fails against the previous head.

* **A libpq password holding a space was cut in half by the redactor.** `_DSN_SHAPED`'s `password\s*=\s*\S+` ends at whitespace, and libpq documents that a value containing spaces is written in **single quotes**, with `\'` and `\\` escaped inside. So the *valid* conninfo `password='secret value'` matched only `password='secret`, and this CLI printed `<redacted> value'` — half the password in the evidence, beside the marker that says it was removed. psycopg accepts an arbitrary conninfo and its driver errors quote it back, which is how a real failure arrives here. The pattern reads the quoted forms now; the closing quote is **optional** and neither quoted form crosses a newline, because a truncated message must redact more rather than less and must not swallow the next line of a multi-line error. `sslpassword` is named too — `\b` before `password` does not reach it, and a private key's passphrase is the same secret. The case also pins the non-over-match: `password=simple` still ends at whitespace and `passwordless=fine` is untouched.
* **`search_path` resolution asks whether THIS ROLE may use a schema, not whether it exists.** Round 16 walked the whole configured path and probed the skipped entries against `pg_namespace` — which proves the schema is *there*. PostgreSQL skips an entry the session lacks `usage` on exactly as it skips an absent one, so an existing but unauthorized `tenant` left `missing` empty, the fallback `public` was accepted, and every statement of the run went to `public`. In a multi-tenant install the grant **is** the isolation. **Measured on postgres 16.15** as a role holding no grant on a schema that exists: `pg_namespace` count 1, `has_schema_privilege(current_user, …, 'usage')` false, `current_schema()` `public`. The probe asks `has_schema_privilege` now, and the refusal names which of the two it is because the remedy differs — create the schema, or grant usage. Against the previous head the DB-backed case does not refuse at all: it proceeds into `public` and is stopped only by an accident of that role's grants.
* **The compose build context uploaded a filled-in `.env` to the docker daemon.** `context: ../..` is right — the Dockerfile installs this package from source — and the context is uploaded **before any instruction runs**. `deploy/compose/.env` is git-ignored, which is not a build-context rule, so its DSN and password travelled with every `docker compose … --build` even though the Dockerfile never copies it into the image. `.dockerignore` is an **allowlist**, so the property is structural rather than a list somebody has to extend: everything excluded, the Dockerfile's own `COPY` sources named back in, and the guard derives that list **from the Dockerfile** so the two cannot drift. **Measured with docker server 29.6.2** by copying the context into a `busybox` image — before, `/ctx/deploy/compose/` held `.env`; after, `/ctx` is exactly `README.md`, `migrations`, `pyproject.toml`, `src` — and the real image still builds and runs `opendox-runtime --help`.

**And the figure block says which entries are history.** Round 18 on the sibling PR read a superseded entry as that branch's claim about its own head, and it had every reason to: each entry asserted currency in its own words, so only the note at the top of the block said otherwise. Every superseded entry says SUPERSEDED now, in the entry.


**And its six suppressed comments: four real, two false and measured so.**

* **The readiness probe made three pool checkouts under a budget for one.** `test_deploy_shape.py` derives the probe's `timeoutSeconds` from ONE `DEFAULT_CHECKOUT_TIMEOUT_SECONDS` plus the JWKS timeout and holds it strictly over both — and `/readyz` checked out for `select 1`, again inside `plan()` and again inside `drift()`, each of which calls `applied()`. A contended pool therefore made the probe wait three of those, kubelet cut the probe off mid-flight and the next one overlapped it. `plan()` and `drift()` take the connection `applied()` already accepted, and the probe holds one across every database question. The case counts checkouts, and against the previous head it says **"this probe checked out 3 pooled connections"**.
* **120 attempts is not 240 seconds.** `socket.create_connection(..., timeout=2)` can spend its whole two seconds before the `sleep(2)` that follows, so the migration Job's counted wait ran for up to **480s** while the line it ends with — and the runbook that quotes it — said 240s. **Measured** against a non-routable address with the counts scaled down by 40: three attempts claiming 6s took **12.1s**, exactly twice. It is a `time.monotonic()` deadline now, and the case asserts both the shape and one real bounded run.
* **A documented command carried a password in its own argv.** `--from-literal` puts the value in the shell's history file and in `/proc/<pid>/cmdline` for as long as `kubectl` runs — the same exposure the managed-database block one page down already avoided with `read -rs`, so two paths said different things about one secret. The install block reads into files under `umask 077`, passes `--from-file`, and removes them; **measured** with a `kubectl` on PATH that prints its own argv. The guard greps the runbook for any `--from-literal` whose key is secret-shaped.
* **The managed-database path now ships the overlay it requires.** Pointing both DSNs at a managed database does not remove `postgres-statefulset.yaml` from the base, so that path started a second database nobody uses and failed on the `opendox-postgres` Secret it never creates. An overlay is the only place kustomize can remove a base resource. **Measured with kustomize v5.4.3**: `deploy/kubernetes/overlays/managed-database` renders the Namespace, both ConfigMaps, the runtime Service, the PVC, the Deployment and the Job — and none of `StatefulSet/opendox-postgres`, `Service/opendox-postgres` or `ConfigMap/opendox-postgres-init` — with `migration_wait_host` empty.
* **False against the code.** `STDLIB_ONLY_MODULES` is reported to omit `opendox.runtime.identity`. It is line 43 of that tuple and has been since the module was added.
* **False against PostgreSQL, and this is the second report of it.** `octet_length(d.body)` is held to detoast every candidate body, so that a 500-draft page still makes the database process ~500 MB. `textoctetlen` takes the raw length out of the varlena header — `toast_raw_datum_size` reads a **TOAST pointer**, not the chunks it points at. **Measured on postgres 16.15** over 200 rows of 1 MiB of incompressible ASCII, a 208 MB relation, best of three:

  | query | time |
  | --- | --- |
  | `sum(octet_length(body))` | **0.3 ms** |
  | `count(*)` | **0.3 ms** |
  | this act's windowed inner query | **0.7 ms** |
  | `sum(length(body))` (counts characters) | 463.5 ms |
  | `max(md5(body))` (reads the bytes) | 381.9 ms |

  Sizing costs what counting costs; reading is three orders of magnitude more. A DB-backed case drives the same shapes at a size a test can afford and asserts the ratio, with the measured ratio at that size ~36x against a 4x bar.

## Review round 20 (Copilot review at `2c56b65`) — one finding, and round 19's own fix is what left it

Classified: **1 FIX, 0 REPEAT, 0 out of scope, 0 answered by measurement.**

* **`"$user"` is exempt for being ABSENT, not for being unreachable.** Round 19 made every **named** entry ahead of the answer prove it is usable and left `"$user"` skipped unconditionally — and PostgreSQL skips an existing schema the role lacks `usage` on exactly as it skips an absent one. So a schema named for the role, present and denied, still fell through to `public`: the same silent fallback this function exists to refuse, wearing the default path's name. It goes through the same probe now, under the role's own name, and is forgiven only for **not existing**. The refusal says the entry came from `"$user"`, because that is not a name an operator can grep the DSN for, and the exemption is **positional** rather than by name, so a role whose name also appears as a later named entry does not get that entry forgiven with it. The case covers all four states — denied, absent, answering, and an entry after it judged on its own — and against the previous head the first **DID NOT RAISE**.

## Review round 22 (Copilot review at `a10bd08`) — two findings, one of them reported twice

Classified: **2 FIX, 0 REPEAT, 0 out of scope, 0 answered by measurement.**

* **No broker URL this runtime prints can carry a credential.** `oidc_issuer` and an explicit `oidc_jwks_url` are **public** endpoints — the issuer is what a token's `iss` is compared against, the key set is fetched unauthenticated — and `load_settings` accepted any string. Measured against the previous head with `OPENDOX_OIDC_ISSUER=https://svc:pw@broker/realms/x`: `load_settings` **accepted** it, `repr(settings)` printed it, `status` printed the **derived** `OPENDOX_OIDC_JWKS_URL` with it, and `status` printed `broker_discovery` with it — three printed credentials from a value that had never been a DSN, which is why the DSN-shaped redaction saw nothing. It is **refused at the door**, because redaction alone would make the evidence safe and leave `jwks_url()` — which the verifier actually fetches — pointing at a URL with a credential in it; and **redacted at both printing boundaries anyway**, because a `RuntimeSettings` built by hand does not go through that door. The host survives the redaction, for the same reason a push refusal keeps the host it could not reach.
* **The managed-database overlay supplies the broker.** The base leaves `oidc_issuer` and `oidc_audience` empty on purpose — they are an environment's facts — so an overlay the runbook tells an operator to **build** must supply them or it renders a Deployment that fails `load_settings` before it serves. `overlays/dev` carries a worked example for exactly that reason; round 19's new overlay had none. The guard is derived from the base: every `oidc_*` the base declares empty must be supplied by **every** overlay, and every overlay must be named in the runbook, so one added later is covered by the rule instead of by somebody remembering.

## Review round 23 (Copilot review at `334b9b6`) — two findings, one defect

Classified: **2 FIX, 0 REPEAT, 0 out of scope, 0 answered by measurement.** Compose interpolates `${VAR}` **before** the container sees the string, so both healthchecks turned an operator's `.env` value into code.

* **`CMD-SHELL` made it shell source.** `OPENDOX_PG_USER=x; touch /tmp/pwned` ran in the Postgres container on every probe, and a value with a space silently became two arguments long before anything hostile was needed. It is exec-form `CMD` now — the interpolation stays, because the probe must follow the configured values, but each one is a single argument `exec` passes with no shell between.
* **The application probe made it python source**, evaluated on every probe and before `config.load_settings` had looked at the port. The script is fi…
brettheap pushed a commit that referenced this pull request Sep 18, 2026
…umbering, so this act becomes the TWELFTH bump

main moved to 4401e1a while this PR waited on RULED Q-X4 (a)'s landing order,
and #1085 (`1da7ea6e`, the § 3.4 SLICE-S7 RESIDUE annotation) RENUMBERED the
admissions bumps: § 3.4 SLICE S5's amendment, which had carried no ordinal, was
given one, and that "put every ordinal after it one low". main now runs to the
ELEVENTH.

Two conflicts, both in `tests/carve_arrival/test_verify_carve_arrival.py`, both
resolved by keeping BOTH sides and taking MAIN's numbering:

- The docstring's amendment log. main's NINTH (openxFactory PR #1067, the ten
  `src/opendox/runtime/` files), TENTH (RULED Q7's CSS extraction) and ELEVENTH
  (the S7 RESIDUE) are kept verbatim, and this act's paragraph — which read "A
  NINTH TIME" against the old numbering — becomes "A TWELFTH TIME". Its own
  cross-reference moves with it: "the sixth, seventh and eighth bumps" is now
  "the seventh, eighth and ninth", which is the same three amendments under
  main's numbering (S7, S8, the runtime ten).
- The durable-assertion enumeration. main's fuller list is kept whole — S5's
  eight across both legs, S8's one, the ten runtime entries, RULED Q7's five and
  the S7 RESIDUE one — and this act's five `openxdox_code` entries are appended
  to it rather than replacing anything.

The assertion block's own label follows the docstring: `THE NINTH BUMP` ->
`THE TWELFTH BUMP`. Its measured example is RE-MEASURED rather than assumed, and
is unchanged — `tests/carve_arrival` is still 159 tests, so the comment's
"1 failed, 158 deselected" still reads true.

`docs/opendox-carve-admissions.yaml` merged with no conflict: #1085's
`tests/test_display_facet_leaves.py` row lands at `opendox_code` and this act's
five rows at `openxdox_code`, different destination blocks. Both sides' rows are
present and every destination is still alphabetical by `path` with no repeat
(`opendox_code` 33 rows, `openxdox_code` 32).

MEASURED ON THE MERGE RESULT, not carried over:

    python3 scripts/validate-carve-manifest.py
      OK — phase post-shed, 456 row(s), 318 digest(s) recomputed,
      456 file(s) in the declared surface with none undeclared        exit 0

    python3 -m pytest -q tests/carve_arrival tests/carve_manifest
      408 passed in 156.78s                                          exit 0

    python3 scripts/verify-carve-arrival.py --destination openxdox_code \
        --dest-root <openXdox-code @ 5b8e527a> --phase B \
        --replica-at tests/ideation-dashboard/conftest.py=tests/conftest.py \
        --replica-at tests/ideation-dashboard/session_fixtures.py=tests/session_fixtures.py
      OK — 129 file(s) with none undeclared (1 scaffold, 2 replica,
      28 created); 2 of 2 declared replicas verified                  exit 0

The four STALE admissions that arrival line names (the RULED Q7 `openxdox_code`
sheets) are main's own TENTH bump and predate this merge — declared and not yet
needed at the leg, which the verifier reports and does not refuse.

THIS PR PINS NO openDox-code COMMIT. Its five rows carry two openXdox-code
introducing commits, `d4282454` (the three modules) and `5494bb43` (the two
tests). It waits on openDox-code #26 for RULED Q-X4 (a)'s landing ORDER only.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap added a commit to opensoft/openDox-code that referenced this pull request Sep 18, 2026
… C3's conformant local-git adapter (#26)

Lane: openxfactory-4 (openXfactory-4-openDox_extraction)

CLAIM: 5699629780
Refs #656 (stays OPEN).

**Stacked on `build/3-5-runtime` (§ 3.5). Read that PR first; this one is the diff on top of it.** The holder retargets this to `main` at landing.

# § 3.6 — openDox creates a repository as a first-class act, and RULING C3's local git repository is the conformant adapter

`openspec/changes/split-opendox-two-layer-product/tasks.md` § 3.6.

## The ruling, in its own words

> **RULING C3** — #656 comment [`5544381563`](https://github.com/opensoft/openxFactory/issues/656#issuecomment-5544381563), Brett Heap, 2026-09-04T17:48Z: "**standalone openDox creates and manages a plain local git repository per project.** Documents are always git-backed; commits are the write path; a remote can be attached later. Q1 holds unchanged (the database never holds documents), and **moving a student or lab-assistant project into a governed factory is a push, not a migration.**" Rejected: "a loose-documents mode with the database holding content until a repository is attached; requiring a repository before the first save."

And design § D5 names what that makes the code: "That is the **trivial conformant implementation** of the adapter's write-back operation — a corpus whose declared governed write path is 'commit to this local repository' — so the standalone case is **not a mode, it is one adapter implementation**."

§ 3.6's own reason for existing: "**openDox CREATES A REPOSITORY AS A FIRST-CLASS ACT**, or the origin complaint returns one level down."

## What this PR does

### The adapter — `opendox.runtime.local_git_adapter.LocalGitCorpus`

**§ 3.7's conformance corpus needs exactly this object at exactly this import path, and importing it costs the standard library only.** No FastAPI, no psycopg, no web framework: a conformance suite over three destinations' adapters should not have to install a runtime to check one of them. `tests_runtime/test_runtime_surface.py` holds both new modules to that contract in a fresh interpreter.

Conformance is **structural**: `isinstance(LocalGitCorpus(), corpus_adapter.CorpusAdapter)`, nothing inherited (asserted: `CorpusAdapter not in LocalGitCorpus.__mro__`), and the public callable surface is exactly `corpus_adapter.OPERATIONS` and no seventh. That is the property `corpus_adapter.py`'s own header says the `runtime_checkable` Protocol exists for.

**The corpus is the HISTORY, not a working tree, and that is the decision the file turns on.** `list_documents` and `read` answer from the resolved commit (`git ls-tree`, `git cat-file`); `write_back` writes a blob, reads the resolved tree into a **temporary index**, writes a new tree, makes a `commit-tree` and moves the branch ref with a **compare-and-swap** — so no operation writes a byte on disk. `corpus_adapter.write_back`'s contract is emphatic about this: "It never touches the corpus tree — an implementation that does is refused even where the bytes would be identical, because the gate is the act of passing through the path and not the shape of the result." A `git add` + `git commit` implementation would produce identical bytes and would not be conformant, and `test_a_write_materializes_no_file_on_disk` measures the difference.

**No stale refusal, and that is deliberate.** `write_back`'s declared refusal row is `CORPUS_READ_ONLY` and `WRITE_PATH_UNREACHABLE` and no other kind — "an implementation raising a kind outside its row is a defect the conformance suite is entitled to catch" — and the closed `REFUSAL_KINDS` vocabulary has no kind for staleness. Inventing one would be a seventh member by another name. So `basis_revision` becomes a **commit trailer** and the ref moves by compare-and-swap: a writer working from a superseded revision loses its dispatch rather than overwriting the other one (`test_a_stale_corpus_loses_its_dispatch_rather_than_overwriting`).

`classify` never omits — an unrecognized shape comes back `kind=None` with a reason naming the document, and the document stays in the listing. `required_fields` is empty for every kind, and that is the honest answer rather than an unfinished one: obligations are governance, and a pre-governed repository has none. `check` has exactly one verdict of its own — a tracked file whose checkout differs from the resolved commit, which is RULING C3's "documents are always git-backed" being false — and claims nothing else.

### The act — `opendox.runtime.repository_act`

`create_repository` writes the project-to-repository **map row** and creates the **repository**, and a caller that does one without the other has not performed the act.

* **The row is written first**, inside the caller's transaction: a repository that fails to initialize raises before the commit, so no row survives pointing at nothing. The row is also checked first *within* the act, because it holds the authoritative fact — an already-mapped project is refused as "already mapped", not as "there is a directory here", which is only the symptom.
* **The remaining window is real and is not papered over.** A process killed between `git init` and the commit leaves a directory with no row; the next act **refuses and names it**, with the two remedies, rather than adopting a directory nobody can account for.
* **The repository is BARE**, and its first commit is **empty**. Bare because the corpus is the history and a checkout beside it would be a second answer to "what does this project contain" that the adapter is forbidden to keep up to date — openDox *manages* this repository (RULING C3's own verb), and a human who wants a checkout clones it. Empty because a README this act invented would be content the project's owner did not write, in the one place the product's promise is that the documents are theirs.
* `attach_remote` is RULING C3's "a remote can be attached later" as one UPDATE plus one `git remote add`, writing no object and moving no ref. `push_to_remote` is the last clause: **the move is a push, not a migration** — the same objects go to the remote and the project keeps being served from where it was.

### The surfaces

```
POST /api/v1/projects/{id}/repository           # the act
PUT  /api/v1/projects/{id}/repository/remote    # attach one later
POST /api/v1/projects/{id}/repository/push      # the move

opendox-runtime project create-repository --project-id <id> --actor 'Name <a@b>'
opendox-runtime project attach-remote     --project-id <id> --remote-url <url>
opendox-runtime project push              --project-id <id>
```

All three API verbs are owner-gated by `memberships.role`. The routes hang off `/projects/{id}/repository` rather than off the `project-repositories` collection, so `COLLECTIONS` does not grow: the closed six are what the database owns, and this is a verb over one of them.

`ProjectSubcommand` is a second structural conformer to `subcommand_extension.SubcommandExtension`, on the same argument PR-A's header records. `src/opendox/cli.py` declares **no** `project` command today — measured by parsing it (`generate`, `generate-and-open`, `create`, `edit`, `model-binding`, plus the contributed `gate`), and that measurement is itself a test — so the name collides with nothing and the eventual `opendox project create-repository` is one line at the assembly point.

## What this PR does NOT do — residue, by name

* **It does not write a document.** The first document arrives through `write_back`, the corpus's declared governed write path. The act creates the repository and its first commit.
* **It builds no conformance corpus.** § 3.7 is a separate box; what this PR owes it is the importable adapter, and the import path is `opendox.runtime.local_git_adapter.LocalGitCorpus` (plus `repository_act.initialize_repository`, which builds a corpus to check without a database).
* **It lifts no part of RULED Q-L5 (b′)**, and nothing here reaches `opendox.serve`.
* **It does not scale the runtime.** The Deployment stays one replica with a `Recreate` strategy, because the pod mounts the per-project repositories read-write and git has no cross-writer protocol over a shared filesystem. That is a property of RULING C3's shape, not a capacity decision, and it is recorded in `deploy/kubernetes/base/opendox-deployment.yaml` and in `docs/runtime.md` so a later scale-up is an act somebody takes on purpose.
* **Design § D5's pre-governed scratch space residual stands, unresolved.** Recorded in PR-A and in `docs/runtime.md` § 9.
* **`git` is a runtime dependency of the image**, not of the package. `deploy/compose/Dockerfile` installs it and a test asserts that it does; the act refuses by name where it is absent, and the adapter suites skip with the reason printed.

## The arrival floor

Two more files under the walked root `src/opendox` (`local_git_adapter.py`, `repository_act.py`), admitted with PR-A's eight in **openxFactory PR [opensoft/openxFactory#1067](https://github.com/opensoft/openxFactory/pull/1067)**. Nothing else this PR adds is under a walked root.

## CI

`.github/workflows/validate.yml` stays **append-only** against `main`; this PR's own hunks are inside the block PR-A appended (`@@ -356,2 +356,9 @@`, `@@ -365,0 +373 @@`).

`tests_runtime/test_local_git_adapter.py` joins the **required** job's hermetic list, and that is the strongest placement § 3.6's proof can have: the adapter and `opendox.corpus_adapter` are both stdlib-only to import, so the `isinstance` conformance assertion runs in the one check this repository requires. It shells out to `git` — present on every GitHub runner — and skips with the reason printed where there is none.

## Measured (python 3.12.3, pytest 8.4.2, postgres 16.15, git 2.43.0)

Every figure below was measured at **`727b4769`** — with the `runtime` extra made UNIMPORTABLE, which is the required job's own install, and with **no ambient git configuration** — and holds at the current head **`db5197d0`**, which adds only the workflow's record of it and names the command that produced it. **This description is edited in the same act as that record**, which is what the round at `0a2af8b8` asked for: it lagged the workflow block by one commit there, and one source saying `346`/`555` while the other says `347`/`556` is the defect that review has now named three times on this PR. The table below and the workflow's own comment block name the same commit, which is the same measurement stated twice. **The two per-module rows were stale and are corrected here**: they read `122` and `71`, measured several rounds back and carried forward while the totals were re-measured each round — at `fe421882` they were already **130** and **82**, measured against a full checkout of that head. Only the two bold rows were ever re-measured, which is the same defect as a figure and a workflow block naming different heads, one row down. **A count here and a count in the workflow's comment block must be one head's answer**: Copilot's review was right about that twice (the `108`/`129` pair at round 6, and this table lagging the workflow at round 12), and both places now name the same commit for the current figure.

| run | result |
|---|---|
| the required `validate` job's own invocation (`--noconftest`, the six hermetic modules) | **348 passed, 1 skipped** |
| of which `tests_runtime/test_local_git_adapter.py` | 132 passed |
| `tests_runtime/test_repository_act.py` (DB-backed) | 82 passed |
| `python -m pytest -q tests_runtime/` with `OPENDOX_TEST_DATABASE_URL` set | **557 passed** |
| `python -m pyflakes src/opendox/runtime/*.py tests_runtime/*.py` | clean |
| openxFactory's `verify-carve-conformance.py` over § 3.7's neutral corpus, this class constructed with the corpus's terms | **17 of 17 check(s)**, exit 0 — **last measured at `61973332`, NOT re-run at this head** (see below) |

**THE CONFORMANCE LINE IS THE ONE FIGURE THIS HEAD DOES NOT RE-STATE.** Its harness is openxFactory's `verify-carve-conformance.py` against § 3.7's neutral corpus, and that repository was not in the workspace this round was worked in — so rather than repeat a number nothing here measured, the table says which commit it was measured at. Rounds 31 and 32 change no member of the adapter interface the corpus exercises: the changes are the config scopes `check` reads, the options in `GitRunner`'s common argv, a second inheritable descriptor, and refusals in `repository_act`. The next session with that harness should re-run it before landing.

**THE SKIP IS CARRIED IN FROM `build/3-5-runtime`**, not new here: it is that branch's live `psycopg` reproducer for the DB probe's credential leak, which the required job cannot install a driver for. See #25's round 26.

**AND THE SUITES ARE MEASURED WITHOUT THE DEVELOPER'S GIT CONFIG**, which is how the required job runs. Both git-driving modules point `GIT_CONFIG_GLOBAL`/`GIT_CONFIG_SYSTEM` at nothing and supply an author and committer, because a case that takes its identity from a workstation's global config passes there and exits 128 on a runner — which is exactly what had happened: `validate` and `runtime` were RED on this branch from the head that introduced the gitlink case (round 10) until `a475e71`, on one test, for that reason. It is the third instance on this act of one rule, and the first two are recorded in #25: a result measured under an environment the job does not have is not that job's result.

## Review round 4 (Copilot review `5225429670` at `793c7c56`) — twenty-three findings, all fixed

Ten threads and thirteen suppressed comments, several of them one defect seen from two angles.

* **Credentials — four paths, one rule, written down once.** `refuse_credential_bearing_remote` applied two *anchored* regexes to the raw input while `urlsplit` silently discards leading whitespace, so `" https://user:token@host/x.git"` passed every check and was persisted verbatim into the column the repository endpoints read back. `redact_credentials` matched only the userinfo and SCP forms, so the query/fragment shape that same refusal rejects went through error messages, push refusals and CLI evidence untouched — the two halves of one rule had drifted, and the key vocabulary is now imported rather than retyped. The API returned `remote_url` verbatim from a successful push and from every map read-back. And the three § 3.6 CLI verbs caught their own exceptions before `main()`'s redaction boundary and emitted `str(exc)`, so a driver failure printed the DSN and its password.
* **A corpus failure is refused, never answered.** `check` turned every git failure into `()` — this corpus's "no divergence and no further opinion", a *verdict* — so a repository that became unreadable after it resolved was indistinguishable from a clean one. `_head` had the same shape one level down: `show-ref` exits non-zero both for an unborn branch and for a malformed ref, so a broken repository resolved with `revision=None` and `list_documents` called it empty. `for-each-ref` tells them apart, measured on git 2.43.0. And `refuse_unusable_location`'s emptiness check sat outside every `try`, so a directory the service can stat but not read reached the API as a 500.
* **The push and the map name one place.** `push_to_remote` sent to whatever `origin` happened to be and never looked; it now compares `remote get-url origin` with the row and refuses by name, redacting both. `attach_remote` writes the durable fact first, inside the caller's transaction, so the only surviving window is the one that refusal catches and a repeat of the act repairs. The refspec is the repository's own branch, read from its symbolic HEAD, instead of a hard-coded `main` that made a repository created on `master` servable and unpushable.
* `update-index --cacheinfo 100644,<blob>,<path>` is parsed on the commas and git permits a comma in a path, so a valid `DocumentId.key` such as `notes,2026.md` was rejected or split. `LocalGitCorpus(branch=…)` was stored and never read — removed, not wired up, because wiring it up reintroduces the assumption `_served_ref` exists to refuse. And `test_the_map_records_an_absolute_location` resolved its relative root against pytest's working directory and then `rmtree`d the *checkout's* `var/`.

One defect the suites found in this act's own code, fixed here: `create_repository` checked the **directory** before the **map row**, so a second act on an already-mapped project reported the symptom instead of the fact. Two stale `_Git` annotations left by the rename to `GitRunner` were inert at runtime (PEP 563 strings) and are repaired in their own commit; `pyflakes` is what found them.

## Review round 6 (Copilot review `5226598446` at `f00782fe`) — three threads and fourteen suppressed comments, every one answered

* **The decode had a PASS LIMIT**, which made its own docstring false: `?%2525252574oken=…` was still `%74oken` when the rule looked at it. Unbounded now, and it terminates by construction — every pass that changes the name shortens it, which is an `assert` rather than a claim.
* **`resolve` answered out of the REF STORE.** A commit pruned after it was written still produced a `ResolvedCorpus` nothing could serve, and the refusal arrived later from `list_documents` or `read`. `cat-file -e` asks the object store; the same reasoning closed the unborn-corpus paths and `check`'s bare-repository return.
* **`get-url --push` prints ONE url and git permits several.** Each configured `pushurl` receives the push, so an extra destination hid behind a first one that matched the map. The check asks `--all` and compares the whole list.
* The fourteen suppressed comments are answered one by one in [this comment](https://github.com/opensoft/openDox-code/pull/26#issuecomment-5702674294): the creation route's authorization order (a project that does not exist and one the caller may not act on are now ONE refusal), the owner gate measured on create alone (all three verbs, stranger AND reader, with no git side effect), a HEAD naming a tag, an embedded NUL, an option-shaped document key (`--index-info` on stdin), pathnames that are not UTF-8, a `pushurl` that survived the repair, the check-and-push race (`select … for update` on the map row), and a preflight outside the refusal handler.

## Review round 8 (Copilot review at `f00782fe`) — four threads, all answered

* **A `+` in a parameter name was a 500.** `unquote_plus` turns `+` into a SPACE, which changes the string without shortening it, and the decode loop asserted that every changing pass shortens — so a harmless `?a+b=1` raised out of BOTH halves of the credential rule. The loop is bounded by the name's own length, and termination is argued rather than asserted.
* **An option-shaped revision could become a git OPTION.** `--end-of-options` precedes the caller's value in `_resolve_revision`.
* **The workflow's record carried a literal `%s`** where a commit should be — in the block whose own rule is that every figure names its head. It names `378290d9`.
* **The repository directory's create was not atomic with its check.** A symlink appearing after `refuse_unusable_location` returned was FOLLOWED by `mkdir(exist_ok=True)`, and the project's history would have been written into the link's target — the adoption that refusal exists to prevent. The leaf is created exclusively (an exclusive `mkdir` cannot follow a link), the legal empty-directory case is re-verified through an `O_NOFOLLOW` open, and the directory git is handed is compared by inode with the path.
* **The push/attach race** was already fixed one head earlier (`f204237`): both acts take `select … for update` on the map row, inside the caller's transaction, so the lock is held across the comparisons, the branch resolution and the push.

## Review round 9 (Copilot review at `893f7eb4`) — two new findings, two answered by citation

* **A NUL in a document key is refused before the index protocol sees it.** Round 8 moved the path onto `--index-info -z` to take it out of git's option parsing, and that protocol's record terminator is NUL — so `a.md\0b` would have been truncated, or read as two records, and the receipt would have named a path the write did not make.
* **A corpus failure is not a missing document.** `cat-file` fails the same way for both, so a repository deleted after it resolved, a `.git` that went away and a pruned commit were all `DOCUMENT_UNKNOWN`. `read` asks the corpus first and only a readable one gets to call a document unknown.
* The round's other two — the `+` in a parameter name and the workflow's `%s` — were fixed one head earlier, in round 8, and are answered on their threads by citation.

## Review round 10 (Copilot reviews `5227446610` at `9a9ff25c` and `5227578911` at `1e7c67f8`) — ten distinct findings: eight fixed, one cited, one answered by measurement

Classified before anything was touched: **8 FIX, 1 REPEAT, 1 answered by measurement.**

* **A transport that runs a command.** Git's `ext::<command>` executes its argument in the pushing process — this runtime's own — gated by a config value the host sets. **Measured on git 2.43.0: `protocol.ext.allow=user` in the repository's own config is enough to execute it.** So the shape is refused where it would be stored, and the push carries `-c protocol.ext.allow=never` for rows written before the rule. The test plants a real ext helper that touches a marker file: created against the old shape, never against this one. (Round 12 generalizes this to every `<name>::` helper form — see below.)
* **A space hid a credential from both halves of the rule.** `urlsplit` accepts a raw space inside a URL and the parameter patterns excluded whitespace from a name, so `https://host/x? token=ghp_secret` parsed as a query carrying `token` while the predicate saw no parameter. The patterns step over spaces and tabs around a name now. A CONTROL character (newline, tab, carriage return) is refused outright — a newline in a remote URL forges a second line in `.git/config` — while a plain SPACE is not, because a local path is a destination this act deliberately supports and `/srv/my repos/x.git` is legal.
* **The credential predicate was unbounded work on caller input**: it decodes each parameter name to a fixed point, which is quadratic in the name. `MAX_REMOTE_URL_CHARS` (2048) refuses an over-long URL unread, where the value enters.
* **`attach_remote` could not repair the state it exists to repair.** Measured on git 2.43.0: `git remote set-url` on a remote carrying several `url` entries does not replace the first — it fails — so such a repository was unpushable (the push refuses two destinations) and unrepairable. `config --replace-all` collapses them to the one URL the map records. And the `--unset-all` beside it reads its exit status now: 5 is "nothing to unset", every other non-zero is a config that could not be written.
* **The check and the use were the same NAME, not the same object** — `initialize_repository` verified a descriptor, closed it, and handed git the pathname. Git is given `/proc/self/fd/<n>` for the verified descriptor now (round 12 closes the remaining window, below).
* **A listing and a read have to agree**: `ls-tree -r --name-only` returns gitlink entries for a submodule and `read` asks `cat-file blob`, so the adapter advertised a document it then refused. The listing is filtered to blobs.
* **Five call sites could leak the runner's own failure.** `GitRunner.run` raises when git cannot be started, and `_revalidate`, `_head`, `_served_ref`, `_resolve_revision` and `check`'s bare-repository question all read a returncode. One translated `_probe` helper, plus a NUL guard on a caller-supplied revision.
* **The refusal messages are redacted**, in the CLI and in the API: `RepositoryActRefused` was trusted as secret-free and is not, because `repository_location` echoes a caller-supplied project id.
* **Answered by measurement, no change:** the bracketed-IPv6 SCP form. The review reports that `user@[::1]:repo` bypasses both the userinfo refusal and the redaction; measured on the landed patterns it does neither — the host class matches the `[` and the next character is the `:` the form requires. Two tests pin it, because a property held by luck is one the next edit can lose.
* **Cited, not re-argued:** `read` classifying a corpus failure as `DOCUMENT_UNKNOWN` was fixed at `1e7c67f8` (round 9); the review at `9a9ff25c` predates that head.

## Review rounds 11 and 12 (Copilot reviews `5228881824` at `f93dc26b` and `5228988988` at `1c4727e1`) — six fixed, one answered, one a description this branch had not yet refreshed

* **The helper-transport refusal was the narrow reading of a general mechanism.** Round 10 refused `ext::` and `fd::`; git treats ANY `<name>::<address>` as a remote helper and resolves `git-remote-<name>` from `PATH`, so `evil::anything` reaches an installed helper and `protocol.ext.allow=never` says nothing about it. The whole form is refused now, and `push_to_remote` asks the ROW the same question before pushing — a row written before the rule is exactly the case the rule cannot reach. The test plants a real `git-remote-evil` on `PATH`: against the old shape it runs.
* **One descriptor from the check to the use.** Round 10's handle was opened after a separate emptiness check had closed its own, so a directory removed and replaced between them was described by both `fstat` and `stat` and the comparison compared the replacement with itself. The leaf is created and opened relative to a held PARENT descriptor now, emptiness is asked of that descriptor (`os.listdir` takes a file descriptor), and git is given the same one. The test drives the swap at the only instant it could happen.
* **`_safe_message` was half the credential rule.** The repository verbs route caller-controlled text through it and it applied the DSN pattern alone, so `?token=…` reached the evidence object. One boundary, both halves.
* **Three things `resolve` got wrong about what it was answering**: a PINNED `CorpusRef.revision` does not need HEAD (a repository with an unreadable HEAD was refused for a fact the request does not use); `exists()`/`is_dir()`/`resolve()` raise `PermissionError` for an unsearchable parent and sat outside every translation; and `write_path_available` asked about the git dir while a commit writes an OBJECT and moves a REF, so a read-only `objects/` advertised a usable write path and failed inside the commit.
* **Answered by measurement, no change: the `.git/config` race** between the destination check and the push. This runtime's own acts are serialized — `attach_remote` and `push_to_remote` both take the map row `for_update` — and the remaining actor is one with write access to `.git/config`, which is an actor who can rewrite the corpus itself. Pinning the destination on the command line would put a legacy row's credential into `argv`, the exposure #25's round 11 has just removed for `psql`. Registered as residue with that reason rather than traded for it.
* **And the workflow/description mismatch the second review reports is this section**: the table above now names `2006fb8e` and `198`, which is what the workflow's last entry says at the same commit.

## The ruling of 2026-09-17, and the measurement that produced it

**RULED openxFactory#656 comment [`5714365086`](https://github.com/opensoft/openxFactory/issues/656#issuecomment-5714365086) (Brett Heap, 2026-09-17, by interactive multi-choice): Q-F2 (a) and Q-F3 (a), both applied here, before this PR is ready.**

They were put to him because a **read-only** measurement of this act against `split-opendox-two-layer-product` § 3.7's neutral conformance corpus (helper `floor37`, 2026-09-17; it edited nothing and pushed nothing) put this reader at **11 of 17 checks** and found one live defect.

**Q-F3 — `resolve` adopted the ENCLOSING repository, and `write_back` committed into it.** `rev-parse --git-dir` walks up, so an ordinary directory inside somebody else's checkout resolved as that checkout, at ITS head. Three things then went wrong together, measured end to end on one ordinary repository and one ordinary subdirectory: `list_documents` served keys relative to the prefix; `read` resolved them from the repository ROOT and refused them `DOCUMENT_UNKNOWN` — the listing/read contract this module fixed for gitlinks, broken again by another route; and `write_back` COMMITTED INTO THAT REPOSITORY and moved its branch, writing at the root a path the caller never named. It is reachable inside this product: `OPENDOX_PROJECT_REPOSITORY_ROOT` defaults to the RELATIVE `var/projects`, so a `var/projects/<id>` that exists and is not a repository — a create interrupted, a repository removed, a directory restored from a backup — sits inside whatever checkout the process started in. `refuse_unusable_location` guarded the CREATE path; nothing guarded this one.

`resolve` now asks the repository for its ROOT (`--absolute-git-dir` when bare, `--show-toplevel` otherwise) and refuses unless it IS the location, NAMING the enclosing repository so an operator knows what happened; `write_back` asks again, because that is the call that can put a commit in somebody else's history. Floor37's own reproduction script now refuses at `resolve` instead of moving a branch, and a repository named as itself — including one NESTED inside another, which is a legal thing to have on disk — still resolves and still serves its own history.

**Q-F2 — the reader asserted a corpus's terms instead of being handed them.** Three module constants were doing per-corpus work. `WRITE_PATH`, so no corpus could declare itself read-only: every resolution advertised `local-git-commit`, `write_back`'s own correct `CORPUS_READ_ONLY` branch was unreachable, and a write at a read-only corpus **returned a receipt and moved a ref** — degrading a refusal to a result, which is the one thing a reader over a corpus it does not own must never do. `KINDS_BY_SUFFIX`, so a corpus declaring its kind in a header was classified by file suffix: one complete document, one missing a required field and one with no recognizable shape came back as three `text` documents with nothing missing. And one word: a location that is a FILE refused `corpus-unclassifiable` where the interface's own comments, the corpus's README and openxFactory's adapter all say `corpus-unreadable`.

`__init__` now takes `write_path`, `kind_field` and `required_fields`, **each defaulting to what this class already did** — nothing in this leg passes any of them, and a test pins both the closed parameter set and the defaults. The reader can be HANDED a corpus's terms, which is the pattern `corpus_adapter`'s own header endorses ("a module of plain functions has nowhere to carry per-corpus construction data").

**MEASURED WITH THE REAL READER AND NOT A SUBCLASS.** `LocalGitCorpus(write_path=None, kind_field="Type", required_fields=("Type", "Title"))`, through openxFactory's own `verify-carve-conformance.py`, over the neutral corpus transposed into git by this adapter's own `write_back`:

```
OK …: opendox_code passed the neutral conformance corpus — 17 of 17 check(s)
```

Floor37 measured 11 of 17 at `6c8f19e7`, and 17 of 17 only with a *diagnostic subclass*. This is the class itself. (§ 3.7 remains a separate box and this PR does not claim it: what § 3.7 owes is a declared factory and a corpus, and Q-F1 — how the floor runs a git-history reader against a corpus laid down as a plain directory tree — is a separate act at openxFactory.)

## Review round 12 (Copilot reviews `5229180926` at `7eb9a816` and `5229271198` at `6c8f19e7`) — seven threads and seventeen suppressed comments

Classified first, as every round is now, and the two reviews repeat six findings between them: **13 FIX, 0 REPEAT, 2 answered by measurement, 1 answered and registered as residue.**

* **A redaction that stops at a space is one a secret can be walked past.** The parameter value class ended at the first whitespace, so `?token= ghp_secret` had its EMPTY value replaced and the secret printed beside the marker. A value ends at `&` or `#` and nothing else, and this module deliberately permits whitespace inside a remote string; the newline is the one boundary kept, because this runs over git's multi-line stderr. And the userinfo form did not match AT ALL where the password held a space — while `repository_act._URL_USERINFO` REFUSES that very shape for a new attachment: the two halves of one rule disagreed about one character. The scp branch is deliberately not widened, and the comment says why: it is anchored by nothing but a lookbehind, so admitting a space would let a match start at an earlier word and redact an ordinary sentence whole — and scp form has no password field, which is why its class excludes `:`.
* **The write path is answered where a write would land.** `update-ref` writes `refs/heads/<branch>`, not `refs/`, so a writable `refs/` over an unwritable `refs/heads/` advertised a usable write path and the refusal arrived after the blob, the tree and the commit had been created. And a HEAD that `_served_ref` REFUSES — detached, or naming a tag — was advertised as writable for the same reason, leaving unreachable objects behind for a refusal the corpus could have made at resolution. The predicate also asks for SEARCH as well as WRITE; that case is pinned as a measured table and **labelled as not a regression test**, because git refuses such a repository before the write path is ever computed.
* **Three probes that raised where a refusal is owed**: `_revalidate`'s `Path.exists()`, the temporary index's `unlink` (recorded in the `finally` and raised after it, so an exception already on its way still wins), and the unborn-branch test — which treated an absent ref under `refs/tags` or `refs/remotes` as "the first commit has not been made yet", a statement that is only ever about a branch, so a malformed HEAD resolved as a legal EMPTY corpus.
* **The parent chain is opened without following a link.** The leaf was created relative to a parent opened BY PATHNAME, so a concurrent replacement of the parent — or of any ancestor — made the descriptor, `git init` and the later `stat(location)` all name a directory outside the canonical root, and the inode comparison compared that place with itself and passed. Each component is opened `O_NOFOLLOW` now, and it refuses no legitimate setup: `repository_location` already returns a `resolve()`d path.
* **Three more named refusals in the act**: the root's own `expanduser().resolve()` (the act's FIRST line, so a misconfigured root was an API 500), the preflight's `is_symlink()`/`lexists()`/`exists()`, and the post-create `os.stat(location)` — the one check that decides whether the map row will find the directory again.
* **Writing that first test corrected the handler itself**, and it is this round's sharpest small thing: MEASURED on python 3.12, `Path.resolve()` does not let `ELOOP` through — it raises `RuntimeError("Symlink loop from …")` — so the `except OSError` that named that exact case did not catch it. Corrected in five places across both modules.
* **The helper-transport refusal names the helper it refuses.** The predicate covers every `<name>::<address>` form — round 12's own fix — and the message still named the two spellings git ships, so `evil::anything` got a diagnosis about a transport the owner had not used.

**Answered by measurement, no behaviour taken on trust — each with a case that pins the answer.**

* `remote.origin.pushurl` with no `remote.origin.url` was said to make `get-url` exit non-zero, fall through to `remote add` and be unrepairable. MEASURED on git 2.43.0: `git remote get-url origin` there exits **0** and prints the literal `origin` (`git remote -v` shows an empty fetch URL), so the repair branch was already taken and `--replace-all` created the missing key. The behaviour is version-dependent, so the act now asks the CONFIG SECTION as well and no longer depends on which answer the local git gives; the new case asserts the OUTCOME, which is the same either way.
* `url.<base>.insteadOf` / `pushInsteadOf` were said to let a rewrite make the inspected values equal the map while `git push` sends the corpus elsewhere. MEASURED on git 2.43.0, **the opposite is true**: `get-url` and `get-url --push --all` are THEMSELVES rewritten, so a rewrite makes them DIFFER from the map row and this act refuses — and the value `get-url --push` prints is the one `git push` names in its own failure message. The new case drives a real `pushInsteadOf` at a real bare destination: the push is refused, the refusal names the rewritten destination, and nothing arrives there.

**Answered, and registered as residue.** Binding the served ref at RESOLUTION — so a HEAD switched between `resolve` and `write_back` cannot change which branch the write advances — means carrying it on `ResolvedCorpus`, which belongs to `opendox.corpus_adapter`: the NEUTRAL contract openxFactory pins by commit and digest, and which this act may not widen. An adapter-side memo keyed on a value object would make the guarantee true only when one instance both resolves and writes, which is a claim this act would be making and not keeping. What this corpus resolves is a REVISION, not a branch (`list_documents` and `read` are revision-addressed), and `_served_ref` says in terms that the write path is "the ref HEAD points at". That behaviour now has a case of its own so it cannot change silently, and the guarantee that is unchanged — the commit lands only where the corpus resolved, so no concurrent writer's work is overwritten — keeps its own.

**And one finding that was not in any review: the required job was RED.** `validate` and `runtime` had been failing on this branch since round 10, on one test, because `git commit-tree` needs a committer and that case took one from the developer's global config. See the Measured section.

## Review round 13 (Copilot review `5235886109` at `a475e711`) — eight findings, every one a fix

Classified first: **8 FIX, 0 REPEAT, 0 out of scope, 0 answered by measurement.** Each has a case that fails against the previous head.

* **A `pre-push` hook in a project repository ran in this runtime's process.** `git push` executes the LOCAL `pre-push` hook before it contacts the remote, and the repositories this service manages are writable by it — so `hooks/pre-push` was arbitrary code execution in the runtime, which `protocol.ext.allow=never` says nothing about because a hook is not a transport. Every `git` this package runs carries `-c core.hooksPath=/dev/null` now, set in `GitRunner` rather than on the push so that no later call can forget it. **Measured both ways on git 2.43.0**: a planted hook ran on an ordinary push, did not run with the option, and the push succeeded either way.
* **An ambient `GIT_DIR` outranked `-C`.** Every invocation merged the parent environment, so a runtime started with `GIT_DIR`, `GIT_WORK_TREE`, `GIT_COMMON_DIR` or an object-directory override set — a unit file that inherited one, or a process started from inside a git hook, which is exactly where they are set — resolved, initialized or pushed a DIFFERENT repository than the map row names, silently. The repository-selection and ad-hoc config overrides are stripped from a sanitized copy; `GIT_CONFIG_GLOBAL`/`SYSTEM` are deliberately kept, because they are the operator's own git, which a push may need.
* **The helper-transport predicate is now what git actually does.** The review reported `evil_helper::anything` as a bypass; **measured on git 2.43.0 it is not** — git parses that as SSH to a host named `evil_helper`, because `_` is not a scheme character. What IS a bypass is a name beginning with a DIGIT, and the empty name: `9evil::anything` and `::anything` reach `git-remote-9evil` and `git-remote-`, and the pattern required a leading letter. The table of eight measured spellings is in the module beside the pattern and in the case.
* **Four more, each answered where it was found**: `isspace()` is not "is a control character" (ESC, DEL and the C0/C1 and format sets passed and were written into `.git/config`, where a terminal reading the map's response interprets them — the Unicode CATEGORY is asked now, and a plain space stays legal); `pass` was missing from the shared credential vocabulary, which is a SEARCH, so `password` did not cover it; an explicit-revision read revalidated nothing, so a corpus deleted after `resolve` answered `REVISION_UNKNOWN` about a repository that was no longer there; and two push destinations were refused by a joined string rather than by COUNT.
* **And the map row records a NAME, which is a different question from the one the descriptor answers.** The handle decides where the history goes and held it safely throughout, but `create_repository` commits `location` — so a path re-pointed DURING the initialization left the row naming a directory the history is not in, and the next `resolve(corpus_ref_for(row))` served the decoy. The act asks once more at the last moment it can still refuse, and round 10's own case — which asserted that such an act SUCCEEDS — is folded into this outcome.

## Review round 14 (Copilot review `5236981285` at `2f4f8114`) — one thread and eight suppressed comments

Classified first: **9 FIX, 0 REPEAT, 0 out of scope, 0 answered by measurement.** Every case was run against the shape it forbids before it was run against the fix.

* **`write_back` leaked a kind it does not declare.** The Q-F3 root re-check calls `resolve`'s helper, which refuses `corpus-unreadable`; `corpus_adapter` gives `write_back` exactly two kinds and that is not one of them, so a corpus that went away between `resolve` and the write reached a caller branching on `err.refusal.kind` as a kind this operation never promised. The failure is still refused — as `write-path-unreachable`, with the write path as its subject.
* **The commit trailer spelled the module default.** RULED 5714365086 Q-F2 made `write_path` a per-corpus datum and `WriteReceipt.dispatched_to` already carried the constructed value, so `LocalGitCorpus(write_path="other")` wrote a commit saying `Write-Path: local-git-commit`. The commit is the durable record; it has to be the one that is right.
* **A linked worktree was always read-only.** The write-path probe asked `--absolute-git-dir`, which for a worktree is `<main>/.git/worktrees/<name>` — holding the INDEX and neither `objects/` nor `refs/`. `os.access` on a path that does not exist is `False`, so every writable linked worktree resolved `write_path_available=False`: this adapter's own rule ("a read-only corpus is a fact about the corpus") reporting a fact that was not true. Objects and the served ref are probed against `--path-format=absolute --git-common-dir` now; the git dir stays in the list on its own account, because the temporary index is written there. **Measured on git 2.43.0**, with the table in the module and in the case; for an ordinary checkout and for the bare repository this act creates the two answers are one directory.
* **The bounded header scan allocated the whole document.** `splitlines()[:64]` builds every line before the slice takes sixty-four, under a comment promising it did not. `_leading_lines` yields the same lines and stops; the case holds it to `str.splitlines` over 2,051 inputs, including every boundary that function splits on and a `\n`-only reader would miss.
* **`expanduser()` sat above the translation.** **Measured on python 3.12.3**: `Path("~nosuchuser12345/x").expanduser()` raises `RuntimeError`, and `ref.location` is a caller's string — the last way a location could reach the API as a 500 instead of this interface's refusal.
* **A legacy credential that spans a line is not printed, and the pattern is deliberately NOT widened to do it.** `_CREDENTIAL_SHAPED`'s userinfo class excludes a newline so the redactor applied to git's stderr cannot join a `scheme://` on one line to an unrelated `user@host` on another; the two cases are not distinguishable by pattern, so widening would trade a rare leak for a routine loss of evidence. The distinction is the CALLER's: a stored `remote_url` is one value, and a stored remote may not contain a control character at all because `refuse_credential_bearing_remote` refuses one — so `redact_remote_url` replaces a legacy value carrying one WHOLE, which is what the userinfo form already gets. The control-character question is one predicate now, for the refusing half and the printing half.
* **The acts that reconfigure and push asked only half the question.** `git -C` walks up, and `_local_git_row` verified only the adapter LABEL — so a row whose directory had been removed, or written by hand as `checkout/subdir`, let `attach_remote` set `remote.origin.url` on the ENCLOSING checkout and `push_to_remote` push that checkout's branch to this project's remote. `LocalGitCorpus.resolve` refuses exactly this shape (RULED 5714365086 Q-F3); the acts ask the same question now, before they touch git.
* **A refused act had already created directories.** `mkdir(parents=True)` resolves the chain by pathname, which follows every link in it: for `<root>/link/new/<id>` it created `<outside>/new` and only then did the no-follow walk refuse. `_open_no_follow_chain(..., create=True)` makes each missing component inside the component it has already opened `O_NOFOLLOW`, so the first link fails with `ELOOP` before anything is written.
* **And the identity check compared destinations.** `os.stat(location)` follows the link, so the verified directory moved aside and the name replaced with a SYMLINK BACK TO IT returned the same device and inode and passed — putting a re-pointable name in the durable map. `_directory_by_name` walks the chain with `O_NOFOLLOW`, and states `lstat` as the weaker guarantee where a platform has no `dir_fd`. Round 13's own case follows the stronger refusal rather than being loosened.
* **The map is asked before the path is computed.** `repository_location` refuses an unreadable `OPENDOX_PROJECT_REPOSITORY_ROOT`, so a repeat create for an already-mapped project answered "the configured repository root could not be resolved" on one host and `ConflictError` on another: the same act giving two answers about one durable fact. It is the `git_available` finding one step further up and takes the same fix; the insert still decides, because two concurrent creates both see no row.
* **And the hermetic git environment now reaches the code under test.** `_GIT_ENV` was passed to the suites' own `subprocess.run` and not to `GitRunner`, which inherits `os.environ` — so the claim was true of the assertions and false of the act they assert about. Both suites put the same settings in the process's environment; `GitRunner`'s sanitizer keeps `GIT_CONFIG_GLOBAL`/`SYSTEM`, which are the two that make a workstation and a runner see one git.

## Review rounds 15, 16 and 17 (Copilot reviews `5237132589` at `2f4f8114`, `5237464264` at `90ce2179`, and `5238611815` at `dc8ccb87`) — sixteen findings

Classified across the three: **14 FIX, 0 REPEAT, 0 out of scope, 2 answered by measurement, 1 registered as residue.** Two of the fixes are code execution in this runtime's process.

* **A push ran a program the PUSHED repository chose.** `git push` runs the destination's `receive-pack`, and for a local or `file://` destination it runs it **here** — as a program named by `remote.<name>.receivepack` in the pushing repository's own config. These repositories are writable by the service and by whoever can reach their directory. `--receive-pack=git-receive-pack` on the command line outranks the config value; **measured both ways** with a planted executable, and the case asserts that a plain `git push` from the same repository DOES run it, so the proof is not an assertion.
* **`GIT_CONFIG_PARAMETERS` is the `-c` channel itself,** and round 13's sanitizer left it: a runtime started from inside a git invocation (a hook, an alias, a `filter-branch`) inherited `core.hooksPath` or `protocol.*.allow` from whatever set it. Measured with `core.hooksPath`, because that is the setting this package puts on every invocation.
* **The check and the use are now one object, in the adapter and in both acts.** `write_back`'s root re-check and `_refuse_unless_repository_root` each proved a fact about a pathname, and every git call after them resolved that pathname again. **Measured against the previous head** with the swap driven from inside the re-check and the decoy a CLONE of the corpus (so it holds the resolved commit): `write_back` returned a receipt and the decoy came out with two commits and `a.md` in its tree while the real corpus was untouched. Round 17 extended the binding to `list_documents`, `read` and `check`, which had the same shape.
* **What the binding does not close is registered rather than implied.** An operation binds what `corpus.location` names at its own start, not what `resolve` named, so a repository replaced by another **valid** repository in between is served. Proving otherwise means carrying a resolution-time identity on `ResolvedCorpus` — `opendox.corpus_adapter`'s type, the neutral contract openxFactory pins by commit and digest, which this act may not widen. Same reason and same residue as binding the served ref at resolution (round 12); it is written in `_bound`'s docstring beside the guarantee it does make.
* **A network operation's output is bounded as well as its clock.** `run()` captures both pipes to EOF with no limit, so a remote that answers could stream for the whole 120-second timeout and have every byte held in this process while the request holds the caller's database transaction and the map row's lock. Two reader threads, `MAX_REMOTE_OUTPUT_BYTES` each, and the child is killed when either passes it.
* **A credential holding a space was cut in half.** `_safe_message` ran `_DSN_SHAPED` first, and that pattern ends at whitespace: `postgresql://u:secret value@host` became `<redacted> value@host`. The general credential rule matches the whole authority, so it goes first and the DSN pattern is the fallback. Measured both orders.
* **A ref name is bytes,** in all three places this act decodes one. Two were strict and raised `UnicodeDecodeError` out of `resolve`; `repository_act`'s was `errors="replace"`, which is quieter and wrong in a way a 500 is not — the branch the act then pushed was a different name from the one HEAD points at. All three are `surrogateescape`, and the case pushes the name back into git to prove the round trip.
* **Seven more, each where it was found:** `write_back` leaked `corpus-unreadable`, a kind it does not declare; the commit trailer spelled the module default rather than the corpus's `write_path` (RULED 5714365086 Q-F2); a linked worktree was always read-only (`--absolute-git-dir` holds neither `objects/` nor `refs/` — measured on git 2.43.0); the bounded header scan allocated the whole document; `expanduser()` sat above the translation; a refused act had already created directories through a symlinked parent; and the post-initialization identity check compared destinations, so a symlink back to the verified directory passed.
* **The map pre-check catches the store's `NotFoundError` alone.** `except Exception` was justified by "the next statement raises it again", which is true of this store and is not a property of a collaborator typed `Any`.

* **And two of round 17's suppressed comments were real defects, fixed in `c554006`:** a project id holding a NUL was refused by `ValueError` — which `Path`, `os.open` and `os.mkdir` raise and this act does not catch — so a malformed id reached the API as a 500 instead of the named refusal (the same guard `write_back` puts on `DocumentId.key`, one module over); and git's own stderr could still carry a LEGACY row's multiline credential, which the credential PATTERN cannot match by design, so the push path takes the destination it already KNOWS out of the text instead of widening a pattern that would eat unrelated diagnostic lines.

### Round 18 — three more, two fixed and one measured

* **The bounded push lost its environment, and that was this branch's own regression.** `run()` builds from `_sanitized_git_environment()` and layers the call's own on top; round 17's output cap passed the call's own straight to `Popen`, so a push ran with four variables and no `PATH` — and without `GIT_CONFIG_GLOBAL`/`GIT_CONFIG_SYSTEM`, which this package keeps on purpose because they are the operator's own git. `GitRunner._argv` is one builder for both call paths now, so a policy option cannot be on one and not the other.
* **A read could still be served from an ENCLOSING repository.** The descriptor binding stops a pathname swap; it does not stop git's discovery, which walks up. A location that stops being a repository while sitting inside another checkout was answered from the enclosing one — Q-F3's defect, reachable again through every operation that reopens the location. `_bound` runs `_repository_root` on the bound runner and refuses a mismatch in the operation's own kind.
* **The figure block said "THE CURRENT FIGURE" in eight places.** Round 18 read the `8a69f712` entry as this branch's claim about its own head, and it was: every superseded entry asserted currency in its own words, so only the note at the top of the block told a reader otherwise. Each one says SUPERSEDED now, in the entry, in the past tense. Two entries claim currency: the last `build/3-5-runtime` entry this branch carries by merge and the last entry for this branch.
* **Aliases: answered by measurement, guard kept.** On git 2.43.0 an alias that shadows a **built-in** is ignored (`[alias] remote = !touch …` did not run for `git remote`; an alias under a non-built-in name did), and every command this runner invokes is a built-in. `-c alias.<subcommand>=` is added anyway, so the property belongs to the call rather than to a rule a later git could relax.

### Round 19 — the refusal that echoed an identifier nothing had validated

`repository_location` is the one place in this act reached by whatever the caller sent — every other message naming a project id names one the map already holds — and it put that value straight into a refusal the CLI prints and the API returns.

Round 10 answered the same site by routing the message through the redactors. That was the wrong remedy, and this round says why: those redactors are shaped for URLs and for libpq conninfo, not for arbitrary caller text. **Measured** through `redact_credentials`, the strongest one either surface applies, against the previous head — `'user:secret@host/path'` and `'//user:pw@h/x'` each hold a `/`, so each reaches the branch, and each comes back **whole**. (The report named `https://user:secret\n@host`, which `repr` happens to rescue by escaping the newline into a form the URL pattern then matches; the class is real where that one example is not, which is why the case drives the two shapes that survive.)

A path-component rule has nothing to say that needs the value: it names **which** rule was broken — empty, holds a `/`, holds a NUL, is `.` or `..` — and the caller already holds what it sent. `.` and `..` are their own case, because there the rule's name *is* the value and is not a secret. The round-10 test changed with the remedy: it asserted the marker, and there is no marker now because there is nothing to mark; its claim is the stronger one, that the whole value is absent rather than the part a pattern recognized.

This head also carries **#25's round nineteen** by merge: the libpq quoted-password redaction, `has_schema_privilege` in the search-path walk, and the `.dockerignore` that stops a filled-in `deploy/compose/.env` travelling to the docker daemon. Three of the four new hermetic cases here are its.



**And round nineteen's two suppressed comments, one of which was hiding a second defect.**

* **Two readers of one argument vector disagreed, and both were wrong.** This act pushes with `("-c", "protocol.ext.allow=never", "push", …)`. `GitCommandFailed` took `args[0]`, so a failed push reported itself as `git -c exited 128` — a refusal naming no operation, which is what the review found. Underneath it: `_argv` took the first argument not starting with `-`, which for that vector is the **`-c` value**, and since `protocol.ext.allow=never` is not an identifier the `-c alias.<subcommand>=` guard round 18 added was silently **absent on the one call that reaches a remote**. Measured against the previous head: no `alias.` option at all, and `git -c exited 128: fatal: remote gone`. `subcommand_of` is one rule now, in both places — a `-c` consumes the argument after it.
* **A ref name is bytes minus one newline, and `.strip()` removed more than git wrote.** `git check-ref-format` forbids ASCII control characters — `\n` and `\r`, and nothing else `str.strip()` removes — while `"\xa0".isspace()` is True in python. **Measured**: git 2.43.0 accepts the branch `feature\xa0`, `symbolic-ref HEAD` writes `refs/heads/feature\302\240\n`, and against the previous head `_pushable_branch` answered `'feature'` — a branch that does not exist. The review named the act; the adapter had it twice, on the path that decides which ref a **write** advances. `decoded_ref_name` is the one rule for all three, and the case writes through the adapter and asserts the commit is on `refs/heads/feature\xa0` while `refs/heads/feature` does not exist at all.

This head also carries **#25's round-nineteen suppressed answers** by merge: the readiness probe holding one pool checkout, the migration wait that ends on the clock, the managed-database overlay, and two findings answered by measurement (`STDLIB_ONLY_MODULES` already names `identity`; `octet_length` does not detoast).



### Round 21 — ten threads: eight fixed, one already answered, one registered

* **A destination's own hooks ran in this process.** `--receive-pack=git-receive-pack` pins the receiver's *executable* and says nothing about the destination's `pre-receive`. For a local destination — which this act accepts by design — `git push` forks that receiver here and it reads the **destination's** config. Measured on git 2.43.0 three ways: a plain push **ran** the planted hook; `git -c core.hooksPath=/dev/null push` **ran** it, because the client's `-c` does not reach the receiver; and the option carried on `--receive-pack`, where it becomes the receiving command's own `-c`, **did not** — with the push still landing. The value is still one this act chooses, so round 16's property is unchanged and its case still passes beside the new one.
* **A repository-local `credential.helper` was a program this runtime executed.** `GIT_TERMINAL_PROMPT=0` and an empty `GIT_ASKPASS` refuse a *prompt*, not a helper. Measured against a local endpoint answering 401: a repository-local `!f() { touch MARKER; … }; f` **ran** during the push, and `-c credential.helper=` stopped it. It is **refused rather than overridden** — that option resets the whole list including the operator's global helper, which this package keeps on purpose — so the check is scoped to the file this service writes to, and five other command-naming keys go through the same pass.
* **Nothing tied the destination to the project.** A push to a local destination runs `git-receive-pack` against it with this service's own credentials, and this service owns every repository under the root, so an owner could aim `origin` at a sibling. The root is `location.parent` by construction. This project's own repository, a sibling and the root itself are refused, `file://` included.
* **A refusal raised while BINDING took the wrong kind.** Round 18 put the root re-check inside `_bound`, before the yield, and `_write_back_bound`'s remap is after it, so it is never reached. Measured on a checkout whose `.git` is removed after `resolve`: `corpus-unreadable`, which `write_back` does not declare, where it is now `write-path-unreachable` with the original kind kept in the detail.
* **`GIT_PROXY_COMMAND` names a program** and git runs it for a `git://` remote — `core.gitProxy`'s environment half, which the transport guard does not cover. It joins the two other command-naming variables on the sanitizer's list.
* **A libpq password in a stored remote was returned verbatim.** A remote is an arbitrary string and both existing shapes read URLs, so `host=db password=hunter2` was neither. Only the password field goes; the host stays.
* **A project id is one native path component**, judged by the strictest flavour: this module carries a Windows fallback, and there `PureWindowsPath("C:/srv/projects") / "C:\\outside"` is `C:\\outside` — the root discarded entirely.
* **`ValueError` joins the root's translation**: `Path.resolve()` raises it for an embedded NUL, so a malformed `OPENDOX_PROJECT_REPOSITORY_ROOT` reached the API as a 500.
* **A caller-supplied identifier is removed by identity, not by pattern.** `_safe_message` knows a URL and a conninfo; a project id is neither, and the store echoes the one it was given. The CLI knows what it passed, so it takes that value out before any rule is asked — and a case derives from the source that all six handlers in the three repository verbs do it.
* **Already reconciled**: the workflow/description figure pair. Both name `f5dd586a` / 268 / 439, and since round 18 every superseded entry says so in its own words, so only two entries in that block claim currency at all.

**Registered, not done (new this round).** The inode check ends before the map transaction commits, so a rename in that window can leave the history in the held directory while the row names another valid repository. Closing it needs an identity carried from the filesystem check through the commit — an inode/device pair on the row, or a lock spanning both — which changes what the map stores and the transaction's shape. It is the same shape as the resolution-time identity residue below, and recoverable for the same reason: the row is a name, and the next act on it re-proves the root against the location it opened.

**Registered, not done.** There is no allowlist tying a local destination to a governed factory. RULING C3 makes the move a **push** and a governed factory is a repository, including a local one; an allowlist is a contract with an owner — a register of governed destinations — that does not exist yet, and inventing one inside this act would put the definition in the wrong place. What is closed is the one destination this runtime can write to with no operator credential at all: its own.



### Round 22 — `.strip()` removed more than git wrote, at the sites that read a PATH

Round 19 found this on a **ref** name; the same call was on every `rev-parse` that names a directory. A project id is refused for `/`, a NUL, `.`/`..` and for not being one path component — so `"project "` is a **legal** id and this act creates a location ending in a space, which the root comparison then read back trimmed.

Measured against the previous head, on a repository this act had **just created** at `<tmp>/project `:

```
adapter.resolve        REFUSED corpus-unclassifiable —
                       "this directory is not a git repository; it is INSIDE
                        one, whose root is <tmp>/project"
the act's root check   REFUSED, naming that same trimmed path
```

`<tmp>/project` does not exist; the reader invented it. `decoded_path` is one rule for all five sites and removes exactly the one newline git wrote. It cannot do better — `rev-parse` has no `-z`, so a pathname is terminated by a byte it could itself contain — and the other half of the ambiguity is closed **where the name is chosen**: `repository_location` refuses a project id carrying a control character, the same predicate `refuse_command_executing_remote` uses. A space is not one, and must not become one.

This head also carries **#25's round twenty-two** by merge: no broker URL this runtime prints can carry a credential, and every applyable overlay supplies what the base leaves empty.



### Round 23 — a third door into `check`, and three ways past round 21's own guard

* **`check` ran a program the corpus named.** `--no-ext-diff` and `--no-textconv` are about `diff.external` and `diff.<driver>.textconv`; a tracked file carrying a `filter=` attribute makes `git diff --name-only` run that driver's `clean`, because deciding whether the file **differs** means normalizing it first. **Measured** on git 2.43.0, on exactly this invocation: the planted `clean` **ran**; it did not with `-c filter.evil.clean=`; and it **ran again** with `core.attributesfile` emptied — the attribute is in the repository's own `.gitattributes`, so only the driver can be disowned. Every driver the repository's own config names is emptied for the call; a driver in the operator's global git is the operator's program, the trust boundary that keeps `GIT_CONFIG_GLOBAL`. It **empties rather than refuses**, unlike the push guard: `check` owes an answer about a corpus somebody may legitimately have filtered, so the answer is made conservative (a filtered file reads as changed) rather than executable.
* **Three ways pa…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants