Skip to content

§ 3.6: openDox creates a repository as a first-class act, with RULING C3's conformant local-git adapter - #26

Merged
brettheap merged 235 commits into
mainfrom
build/3-6-repository-act
Sep 18, 2026
Merged

brettheap merged 235 commits into
mainfrom
build/3-6-repository-act

Conversation

@brettheap

@brettheap brettheap commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

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, 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. 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 rmtreed 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: 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 § 3.5: the openDox runtime — FastAPI + Postgres, identity and coordination, and nothing else (RULED Q1/Q2) #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 (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 past the own-destination check round 21 added. file:// is percent-decoded by git before it opens the path, so file:///…/projects%2Fanother.git opened …/projects/another.git while the comparison saw one component and called it a sibling outside the root (%2e%2e is the same trick). A Windows drive or UNC share is a path, not host:path — C: in the first component matched the scp rule and skipped the check entirely, on the platform this module's pathname fallback exists for. And a relative destination is the repository's: git -C <location> push ../another.git resolves against the mapped repository, while the check resolved against whatever working directory the service had.

This head also carries #25's round twenty-three by merge: neither compose healthcheck puts an operator's .env value into code it runs.

Round 24 — the authorization answer echoed the path it refused

_require_role runs before any act has looked at the identifier — it reads the project id straight off the request path — and the repository routes this PR adds are what made that reachable with arbitrary text. Measured against the previous head:

GET /api/v1/projects/user%3Asecret%40host
  403 {"code":"authz.not_a_member",
       "message":"user … has no membership in project user:secret@host"}

ahead of every redaction the acts apply to their own refusals, and ahead of _refusal_message entirely. An authorization answer needs the subject and the rule, not the object's name: both messages at that boundary say "the project this path names" now, and the session/project mismatch one message over follows the same rule — it still names the stored project, which is a row this runtime wrote, and no longer names the requested one.

This head also carries #25's round twenty-four by merge: a credential in a broker URL's query refused like one in its userinfo, urlsplit's ValueError inside the configuration boundary, and the runtime_pg_role edit the managed-database overlay cannot make stated in both places an operator reads.

Round 25 — four threads: three fixed, one answered by a RULING

  • Round 21's hook guard was sabotage one destination class over. --receive-pack is the command executed on the destination. For a local one that process is ours, which is why the guard belongs there; for a network one the same option runs on the server and disables exactly the pre-receive/update/post-receive a governed factory exists to apply. The guard and the sabotage are one string, and whose process runs the hooks is what decides. A local or file:// destination gets the guarded receiver; every other gets the pinned plain one, which is still round 16's property.
  • The public initialize_repository let ValueError escape. create_repository guards the project id and a direct caller does not come through it — and the preflight cannot catch a NUL either, because a path holding one reads as absent, so the refusal has to be at the mkdir. ValueError joins OSError there, the same pairing the project id and the configured root already have.
  • A legacy row can hold a remote urlsplit refuses. Only new attachments pass the validating path, so file://[bad raised ValueError inside the containment check — before that function's own translation — and /push answered 500. It is a named refusal now, and the stored value is not echoed.
  • basis_revision is RULED, not fixed. The review is right that the compare-and-swap is keyed to corpus.revision and an edit declaring basis B is committed on top of A. RULED openxFactory#656 comment 5701772032 (Brett Heap, 2026-09-16) answers Q-R2: basis_revision is a commit trailer and the compare-and-swap ref move decides staleness. write_back's row in the neutral interface gives it exactly two kinds, neither meaning "stale", and inventing one would be a seventh member of a closed vocabulary under another name — a change to the contract openxFactory pins by commit and digest, which this act may not make.

Answered by measurement, no behaviour taken on trust.

  • The external-diff finding: the mechanism is real and this call site does not reach it. Measured on git 2.43.0 with diff.external set in the repository and GIT_EXTERNAL_DIFF set in the environment — git diff and git diff HEAD run the driver; git diff --name-only and git diff --name-only -z HEAD do not, because an external driver renders a diff BODY and --name-only renders none. --no-ext-diff --no-textconv and the environment strip are kept anyway, because they cost nothing and make the absence a property of the CALL; the case carries the table and is labelled not a regression test.
  • test_the_two_halves_of_the_credential_rule_name_the_same_keys was reported as failing on every run because its input is not credential-shaped. Its input is https://example.invalid/r.git?token=ghp_supersecret — a query-parameter credential, which _ANY_PARAMETER redacts — and the suite is green at every head in the figures block.

Review round 29 (Copilot review at a24aaca8) — nine threads: seven defects

Classified: 7 FIX, 0 REPEAT, 0 out of scope, 2 answered by measurement (one of those with the finding next door taken instead).

  • FIX — no O_DIRECTORY, no act, and the fallback was not a weaker guard but no guard. open_no_follow_chain is called unconditionally and os.O_DIRECTORY is undefined on Windows, so it raised AttributeError before any caller's refusal translation — every read, write, attach and push a traceback rather than an answer. And the creation path's non-dir_fd branch made the parents with location.parent.mkdir(parents=True), which resolves the chain by pathname: an existing <root>/link pointing elsewhere is followed every time on every platform taking that branch — "not just the documented race window", exactly. Both are one answer now: a capability constant and a named PlatformCannotGuardPaths (an OSError, so every caller's translation already handles it). This is a policy change and the case states it: a platform without the primitives is refused, not served with a guarantee that is not one. Both deploy/ shapes and every CI runner are Linux.
  • FIX — a worktree-scoped clean filter was invisible and still ran. With extensions.worktreeConfig set, a linked worktree keeps its own config.worktree. Measured on git 2.43.0: git config --local --get-regexp '^filter\.' exits 1 with nothing while --worktree lists filter.evil.clean, and git diff --name-only runs it. Round 23's override already worked; what did not was finding the name to override. Both scopes are read now, deduplicated — and the case asserts the premise first, so it cannot pass vacuously.
  • FIX — the push names its local destination by the object the guard checked. The containment check resolved a permitted local destination and discarded it; the push re-opened the URL by name, so a symlink could be re-pointed at a sibling under this service's root in between. The push now carries an open directory — /proc/self/fd/<n> for the handle the no-follow walk produced, measured to work — and GitRunner takes a second inheritable descriptor to make that mean anything in the child. This act registered that window as residue twice; it is closed rather than registered a third time.
  • FIX — the containment check fails closed. Its continue said "unreadable: other guards answer", and no other guard answers that question: a local destination whose path could not be resolved — a permission error, a symlink loop, an embedded NUL — went on to git push with nothing having proved it lies outside the root this service owns.
  • FIX — a root-relative Windows path is not absolute and still escapes. Measured on python 3.12: PureWindowsPath(r"\outside") has drive='', root='\\' and is_absolute() == False, and PureWindowsPath("C:/srv/projects") / r"\outside" is C:\outside. root joins the predicate.
  • FIX — the drive/UNC branch runs only where git reads it as a pathname. It ran on every host, so a POSIX runtime classified C:/repo.git as local — and measured on git 2.43.0 on Linux, git reads that as scp/SSH syntax (ssh: Could not resolve hostname c). This act would have sent the local hook-disabling --receive-pack to a remote host, and compared ownership against a filesystem path nothing would ever touch. The classifier takes the platform as a parameter, so the case measures both answers from either host.
  • FIX — signing is pinned off, and the reported half is not the reachable one. Measured with gpg.program pointing at a script: commit.gpgSign does not reach commit-tree, which is the only commit this act makes (git commit does run it — the control). But push.gpgSign=true did reach the push, which this act performs, and failed it with the receiving end does not support --signed push before any receiver had agreed to anything; against a receiver that supports signed push, that is the repository choosing which program this process runs. All three switches are pinned rather than the one reachable today.
  • Answered by measurement — an absolute path containing :// is not a local path, and that is git's own reading. git push /tmp/x/../other://repo.git answers fatal: protocol '/tmp/x/../other' is not supported. git splits on :// first too, so the destination is unusable rather than unchecked: the push fails loudly at git and nothing is bypassed. The classifier agreeing with git is the property that matters.

Review round 30 (Copilot review 5247428831 at 2f33195b) — five threads, two of them about round 29's own answers

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

  • FIX — NO_FOLLOW_WALK_IS_AVAILABLE claimed more than it checked, twice. The walk opens each component with getattr(os, "O_NOFOLLOW", 0), so on a platform holding O_DIRECTORY and dir_fd but not O_NOFOLLOW the flag is silently zero — every component open follows links — and the constant still reported the safe walk as available. And runner_bound_to, which turns the verified handle into the thing git opens, fell back to the pathname where neither /proc/self/fd nor /dev/fd exists, after which the adapter and both acts re-resolve that name for their root checks and their writes: the same-object guarantee this module documents was false there. Both primitives are in the capability now, and the bind raises rather than falling back.
  • FIX — the race moved rather than closing. Round 29 bound the destination through an open descriptor, but _bound_local_destination resolved the name again — so a symlink outside the root during _refuse_a_destination_this_service_owns and repointed into a sibling before the open bound the sibling. The containment question is asked again of the open object (/proc/self/fd/<n> resolves, in this process, to the directory the handle refers to), so the answer cannot be stale by construction and a repoint buys a refusal.
  • FIX — and the test did not exercise it. The first version repointed the link before push_to_remote started, so the ownership check refused immediately and the race was never driven. The swap now happens where it has to — the real check runs against the link pointing outside, and the link is repointed the instant it returns — and the case asserts the guard really did approve the outside destination first, so it cannot pass on a refusal it would have made anyway. Against the pre-fix shape it fails with DID NOT RAISE and the sibling receives the push.
  • FIX — a split remote URL cannot be redacted. get-url --push --all is read by line, so a legacy row holding https://user:secret\n@host/repo arrives as fragments like https://user:secret and @host/repo, and a redactor cannot see userinfo that has been cut in half. The multi-destination refusal no longer echoes them: it names the count, which is the finding, and the map's own value redacted as one value, which is what an operator changes.

Review rounds 31 and 32 (Copilot reviews 5247805877 at cfadd546 and 5247918893 at 19bcb8b7) — three threads and three suppressed comments

Classified: 6 FIX, 0 REPEAT, 0 out of scope, 0 answered by measurement. Each case fails against the previous head; the last one fails against the previous head with its own subject removed, because there the defect was the coverage.

  • FIX — a commit message is a durable record, and two caller-controlled values could forge a line in it. Basis-Revision: and Dispatched-By: are trailers — the write's own account of itself, and the thing a reader of the history is invited to believe. Both were interpolated unencoded, so basis_revision = "A\nWrite-Path: forged" produced a second, fabricated trailer and made the commit's claimed basis and path ambiguous. Refused rather than encoded, which is this module's rule wherever a value cannot be recorded unambiguously — the NUL in a document key is refused one line up in the same function, and an encoded trailer would still be recorded, just recorded wrong and permanently. The refusal does not echo the value, and nothing is written: the branch is where it was.
  • FIX — and the same newline reached the author and committer NAMES. git_identity sanitized only the derived email slug and put the raw actor in GIT_AUTHOR_NAME, which git records verbatim. The name now goes through on_one_line, built from the same per-character rule carries_a_control_character uses — one definition, so a sanitiser and a refusal that disagreed about one character is not a thing that can happen here. That covers every caller the protocol refusal does not, repository_act.initialize_repository's first commit among them. An ordinary name is untouched, which the case asserts, because a sanitiser that renamed people would be its own defect.
  • FIX — a remote helper planted in the repository's own config, which the URL predicate cannot see. remote.<name>.vcs names git-remote-<value>, resolved off PATH, while remote.origin.url stays perfectly ordinary — so there is no :: to find, and -c protocol.ext.allow=never says nothing about it. MEASURED on git 2.43.0 with a planted git-remote-evil and a bare destination: git config remote.origin.vcs evil then git push origin ran git-remote-evil origin <destination>, and ran it with protocol.ext.allow=never passed as well. url.<prefix>.insteadOf reaches the same helper by rewriting the destination before the transport is chosen (the same key pointed at ext:: is refused by git itself — fatal: transport 'ext' not allowed — so the rewrite, not ext, is the hole). --get-all on a fixed key cannot see a key whose middle segment the repository chooses, so the scan asks --get-regexp, and --name-only keeps a credential-shaped insteadOf prefix out of the refusal a caller receives. The case plants the helper, proves git runs it in an unguarded repository first — an environment that could not reproduce the finding would make the refusal untested — and then asserts the refusal, that the marker is absent and that the destination has no ref.
    • remote.<name>.receivepack is deliberately NOT in that list, and that is a decision rather than an oversight: it is executed on a local push, and round 16 closed it by pinning --receive-pack on the command line, where it outranks the config. Refusing the key as well would turn a neutralized stale setting into a failed push, and test_a_push_cannot_be_made_to_run_the_repository_s_own_receive_pack measures the pin both ways.
  • FIX — the scp credential class missed the one form that carries a password (suppressed). ^[^/:@]+@[^/:@]+: required the pre-@ half to hold no colon, so user:secret@host:path slipped past it and git remote add persisted the string in .git/config and in the map row every signed-in caller reads. The user half admits a colon now; widening it cannot make the pattern claim a URL, because [^/@]+ cannot cross the // of a scheme://, and the case asserts that alongside the refusals.
  • FIX — a ValueError out of open() was a traceback rather than this act's refusal (suppressed). A legacy or hand-written map row can hold a location with an embedded NUL, and open() raises before any syscall — which the binding handler did not name, so attach and push answered with a 500 instead of the named RepositoryActRefused every other path failure gets.
  • FIX — the push endpoint's 200 path was covered by nothing (suppressed). The redaction there was right; the case beside it uses an unreachable legacy remote and therefore exercises only the 409, so a regression on the success path — the one place a legacy credential-bearing row is echoed back — would have kept the suite green. MEASURED, git 2.43.0: file://user:token@/abs/path.git pushes (git ignores the authority for a file:// URL), so a reachable legacy row is a real shape and not a contrivance. The case asserts the push actually landed a ref before asserting the body omits the token, because a 200 for a push that did nothing would make the redaction assertion vacuous — and it fails against this same head with redact_remote_url removed, which is the shape it forbids.

Review round 33 (Copilot review 5248164004 at b9051b82) — two threads and two suppressed comments, and a base merge

Classified: 5 FIX, 0 REPEAT, 0 out of scope, 0 answered by measurement. Four are round 32's own rule in the places it was not applied; the fifth is what the merged base found here.

  • FIX — document.corpus is a trailer value and round 32's list left it out. It is caller-controlled through CorpusRef.name and _message writes it as the Corpus: line, so the one unchecked value could still inject the line the other three no longer can. The document KEY goes through the same refusal too: it is the message's SUBJECT, where a newline ends the subject and starts a body nobody wrote.
  • FIX — the create path had the same hole twice (one thread, one previously missed). initialize_repository is public and does not go through repository_location's validation, and the API hands actor an authenticated display name; both are interpolated into the repository's first and permanent commit message. The guard is before git init, because "nothing is created" has to be true — the first placement left the bare repository behind, which the case caught and which is why it is stated here rather than discovered later.
  • FIX — a check that cannot complete is a check that did not pass (suppressed). The bind re-asks containment of the OPEN object with Path(location).parent.resolve(), which raises OSError/RuntimeError for a parent renamed, replaced by a symlink loop or made unreachable after the bind — and push_to_remote translates only GitCommandFailed, so the API answered 500 instead of the act's named refusal. The case enters _bound_local_destination directly, because the destination check one function up asks the same question and already translates it; driving it through push_to_remote would measure that handler and not this one.
  • FIX — and the merged base found a fourth, here. build/3-5-runtime's round-35 answer made the no-credential contract a shape — an AST walk forbidding any use of a bound exception outside _safe_message(exc) / type(exc) anywhere in cli.py — and § 3.6 had since added _settings_and_database, whose ImportError branch emitted str(exc). That is the walk doing exactly what it was written for, on the first branch to add a site after it landed.
  • Base merged. build/3-5-runtime's rounds 34–36 are in (fb53ce8), and the workflow's measurement block keeps both chains: the runtime entries say they are carried by merge and name that PR's head, this branch's own say THE CURRENT FIGURE for this branch.

Independent adversarial review (opus-max, read-only, at cec91c08, three passes) — five findings, all fixed, and one Copilot thread rejected by measurement

Not a Copilot round. A second reviewer with no history on this PR read the head in a fresh clone, reproduced both workflow invocations (322 passed hermetic, 517 passed DB-backed — the figures this branch records), and produced one findings list over three passes; the third was opened specifically on path confinement and TOCTOU. Classified: 5 FIX, 0 REPEAT, 0 out of scope, 1 Copilot thread answered by measurement.

  • BLOCKING ×2 (A26-1, A26-2) — include.path walked through both config guards, and it is ONE git default. git config --includes defaults to OFF when a config FILE is named — --local, --worktree, --global, --file — and ON only when git searches all of them, while git's own config reader always follows an include. So a repository whose .git/config held nothing but [include] path = extra.cfg hid every key from _refuse_repository_local_command_config (both its probes — the fixed-key one and round 32's pattern-key one) and every driver from _emptied_filters, and git ran them anyway. MEASURED on git 2.43.0: the probes exit 1 with no output; the same probes with --includes print !f() { … }; f and filter.evil.clean; and GIT_TRACE=1 git diff --name-only shows run_command: 'sh -c echo PWNED-CLEAN >&2; cat'. That is repository-controlled code executed in this process by the one method whose job is to make check conservative rather than executable, and the push-time execution round 21 added its guard to stop. This guard is the whole attack surface by design — GitRunner deliberately keeps the operator's global and system config — so a hole in it is a hole straight through. Hooks are not in the blast radius, and that is measured too: every invocation carries -c core.hooksPath=<devnull>, the receive side carries it as well, and a command-line -c beats any config file, included or not — which is exactly what bounds this to the keys that are refused rather than -c-overridden.
  • MAJOR (A26-3) — the two halves of the credential rule asked two different questions. names_a_secret_parameter's docstring called itself "THE ONE PLACE THE QUESTION IS ASKED, by both halves of the rule", and it was not: the redactor applies three patterns and the refusal consulted one of them — the positionally anchored one. So host=db password=hunter2 dbname=x and /srv/projects/x.git password=hunter2 were accepted and written verbatim into project_repositories.remote_url — the column whose own refusal text says it is "stored durably with nothing to rotate it" — while every read-back of them was dutifully redacted. A stored credential rather than an echoed one, which is the worse half. carries_a_credential(text) is now redact_credentials(text) != text: the invariant as the implementation, so a fourth pattern cannot reach one half only. And the test that should have caught it, test_the_two_halves_…_share_one_key_list, passed for the wrong reason — it pinned the shared key list, which was shared, and could see neither the predicate set nor the anchoring; the new case is the biconditional over a corpus.
  • MINOR (A26-4) — the scp redaction kept a prefix of the userinfo. The class excluded : and /, so the match began at the last run that fitted: user:secret@host:path/r.git → user:<redacted-url>, and a value with a / or a second @ left more (user:sec/, user:sec@). That is the username, and a prefix of whatever precedes the final @, in map responses, push failures and CLI evidence for a legacy row. [^\s]+ cannot cross whitespace, so every case the narrow class existed for is unchanged and asserted: please tell bob a@b:c still redacts only a@b:c, a bracketed IPv6 scp remote still redacts whole and stops at the following text, a newline is never crossed.
  • MINOR (A26-5) — the store's permissions were whatever umask the process inherited. os.mkdir's default mode is 0o777 & ~umask and neither creation site declared one; nothing in the act, the adapter or the Dockerfile sets a umask, a chmod or core.sharedRepository. Measured: 0755 at umask 022, 0775 at 002, and 0777 with config at 0666 at umask 000 — a world-writable document store. The shipped Kubernetes shape is safe today only because the pod runs as a single uid with a private volume, which makes the answer accidental in a store whose own compose comment says losing it is losing documents. Both sites declare 0o700 and fchmod the descriptor they just opened (an explicit mode= is still masked by the umask, so declaring it is not enough), and git init --shared=0600 pins what git makes under it. Measured after: 0700/0600 throughout, at all three umasks. -c core.sharedRepository=… is not the spelling — GitRunner puts its -c options before the subcommand and git init -c … is unknown switch 'c' on git 2.43.0.
  • Copilot thread on local_git_adapter.py:761 — REJECTED on the landed text, by measurement. It reported the scp branch echoing a password; the password was already redacted (the match began at secret@host:), and git's scp grammar has no password field at all — git splits at the first :, so in user:secret@host:path git reads the host as user and the path as secret@host:path, a remote that cannot authenticate with secret. The redactor is deliberately not changed in the direction that thread asked for; the real residue on that line was the username disclosure above.

Confirmed clean by the same review, and recorded so it is not re-audited: every other git config call site (the three that name a scope were the defect; the rest name none, so includes are on), refuse_credential_bearing_remote's other doors, refuse_command_executing_remote, _destination_as_a_local_path's containment, the scheme branch of the credential pattern — and, from pass 3, path confinement through the project id (every escape spelling refused by name), symlinks at the location (live and dangling, both refused before any other probe), the check-and-use window itself under an attack given a guaranteed win (the verified directory renamed aside and a symlink to a victim planted at its name after the first inode comparison: git wrote through /proc/self/fd/<n> into the real directory, nothing through the link, and the post-init comparison rolled the row back), an ancestor swapped for a symlink after the root was resolved, hooks and signing, PlatformCannotGuardPaths being an OSError, and the configured root's pairing with the volume that backs it.

Base merged, and the merged walk found three more here. build/3-5-runtime's A25-4 answer made the no-credential contract a shape over every module in the package, and it came in with the base: GitRunner.run and _run_bounded composed f"{self.executable}: {exc}" from an OS error and trusted GitCommandFailed to clean it a layer later — the A25-1 shape exactly, and an OS error's text can carry the argv's filename, so it is redacted where it is composed; and _write_back_bound aliased a handler's exception into a local, which never leaked but is a blind spot the walk cannot follow either way. Two corrections went the other way, to the rule itself: a handler catching only this package's own exceptions is free of it entirely (_bound reads CorpusRefused.refusal.kind, a datum this package wrote), and a name anywhere inside one of this package's three redactors is allowed, so redact_credentials(str(exc)) reads as what it is.

Review rounds 34, 35 and 36 (Copilot reviews at cec91c08) — four threads, one batch, all four FACT

Answered as ONE batch and not four rounds, on the holder's ruling. Every premise was MEASURED at 9332bb84 — the head before this batch — rather than argued, and each case fails there and passes here.

  • FIX — a push between two EXTERNAL destinations was unguarded, because containment cannot answer it. Round 30 closed the swap into a path this service OWNS by re-asking the containment question of the OPEN object. For external repository A → external repository B the answer is "outside the root" both times, so the check passed at the name and passed again at the descriptor. Measured at 9332bb84 with the symlink repointed the instant the ownership check returned: the push succeeded and landed in governed-b.git while the map row and the API response both named governed-a.git — a corpus delivered to a destination of nobody's choosing, reported as success. The answer is IDENTITY and not containment: _refuse_a_destination_this_service_owns now returns the (st_dev, st_ino) of each destination it approved, and _bound_local_destination compares that with os.fstat of the descriptor the push will write through. A descriptor refers to an object, not to a name, so it cannot be raced. The containment re-check stays as the backstop for a caller that does not carry the identity. The refusal names neither place, because a value that changed under the act is not one a refusal can honestly quote.
  • FIX — _writable_ref_home walked straight past an existing ref FILE. refs/heads/foo is a perfectly valid ref, and refs/heads/foo/bar can then never exist — but the walk tested is_dir() and carried on up to refs/heads, which is a directory and is writable, so resolution advertised write_path_available=True for a ref git cannot create at all. write_back then hashed the blob, wrote the tree and created the commit before failing: the round-12 finding's own shape, one level down, leaving unreachable objects for a refusal the corpus could have made at resolution. The premise is measured first — git really does refuse update-ref refs/heads/foo/bar while the file is there — and the case asserts count-objects -v is unchanged by the refused write. An existing non-directory is a wall now, judged with os.path.lexists so a dangling symlink counts too; the same nesting with nothing in the way is still writable, so what this refuses is the wall and not the nesting.
  • FIX — the no-follow walk re-moded a directory it did not create. A26-5 gave created components an explicit 0o700 because os.mkdir's default is the ambient umask; the fchmod that settles it sat after except FileExistsError: pass, the branch for "another process got there first", so the loser of that race narrowed a concurrent owner's directory — an operator's own mount point among them. Measured at 9332bb84: 0o700 where the other process had made 0o755, under a comment reading "ONLY WHAT THIS WALK JUST MADE". The window is driven rather than argued: os.mkdir is replaced by one that really creates the directory, as the other process would, and then raises the error the kernel gives the loser.
  • FIX — create_repository adopted a directory that appeared under it. The exclusive mkdir detects that race and the code ignored it: for a location refuse_unusable_location found ABSENT, another process could create an ordinary empty directory in the window, and this act then opened it, passed the emptiness check and initialized a repository in a directory it did not create — the documented exclusive-create guarantee quietly not kept. refuse_unusable_location returns whether the location was there, which is what tells one FileExistsError from the other; the documented case, an empty directory that was already there, is unchanged and the case drives both halves. Measured at 9332bb84 as DID NOT RAISE.

And the base merge that follows it. build/3-5-runtime is this branch's base, and its own second batch made this PR CONFLICTING — which runs no required CI at all, only SonarCloud. bb450614 merges it in, with two conflicts resolved by keeping both: _repository_json redacts on both branches and the merged boundary keeps config.redacted_remote_url (it removes the secret and nothing else, where the general redactor written for git's stderr also replaces the username of an ordinary git@host:path), and the workflow's figure block carries § 3.5's two new entries as this branch's base followed by this branch's own chain. Six cases that wrote a legacy credential-bearing row THROUGH the store now write it with an UPDATE, because § 3.5 refuses that value at identity.CoordinationStore itself — which is § 3.5's own case, and these are about the row that got in before any such rule existed. The idiom is the one this file already used for a legacy location.

The third mini-batch (RULED by Brett Heap on openxFactory#656, ~2026-09-18 17:55Z) — the bound now bounds the whole group

  • FIX — child.kill() bounded git and not the push. A push's real work is in its DESCENDANTS — ssh for a network destination, git-receive-pack for a local one — and they hold the pipes this reader drains. They kept running after the parent died, so a timed-out or overflowing push could go on to complete the remote write after this act had refused, told its caller nothing was sent and rolled the map row back. For a local destination that write lands in a real repository on this machine. Measured at 555a03c8 with a planted slow descendant, and it is worse than the finding said: 30.0 seconds for a 0.6-second bound — the surviving group holds the streams, so the wall clock out_bounded exists to enforce is itself defeated, and with it the promise that a stalled remote cannot hold the request, the repository and the caller's database transaction. Popen takes start_new_session=True, so the child leads a session containing it and everything it spawns and nothing else; _stop_the_whole_group SIGKILLs that group and reaps the child before returning, on both refusal paths. The clean path deliberately does not: a completed push's remaining descendants are git's own business (an opportunistic gc, an ssh control master), and killing them would be a new behaviour rather than a bound on a refused one. Two cases — one drives the finding (the descendant must be dead before the call returns, and its marker must never appear, waited out past its own delay); the other pins the mechanism, so a later edit that drops start_new_session=True cannot pass the first on a stub whose descendant happens to die with its parent.

    And the group was then looked up by an id that can stop existing. _stop_the_whole_group asked os.getpgid(child.pid) at kill time. On the output-overflow path a reader thread reaches it while the main thread may already have returned from child.wait, and measured on CPython 3.12 os.getpgid on a reaped pid raises ProcessLookupError — so exactly the case the group kill exists for would have left the group running behind the refusal. (Popen.kill() is no help there either: after a reap CPython suppresses it, send_signal polling first so a recycled pid is never signalled — bpo-40550.) The pgid is captured immediately after Popen and passed to the stopper. The third case arranges the race rather than racing it: it reaps the child first, asserts that os.getpgid(child.pid) then raises, and still finds the descendant dead and its marker absent.

  • And the base merge that carries § 3.5's own third mini-batch (a86dc3a2): the two-DSN guard now resolves libpq's database default and expands the "$user" search-path token. One workflow conflict, resolved the same way as before — § 3.5's chain as this branch's base, then this branch's own.

That finding is the one the round at ebad9d65 raised, and it is now TAKEN rather than registered — the holder ruled it into this batch as the security-relevant item of the three.

REGISTERED AS A FOLLOW-UP ACT, under the same claim — not built here

The served DATABASE has no non-secret declaration, only the served schema (deploy/kubernetes/base/migration-job.yaml:206, and the same shape in deploy/compose/docker-compose.yaml). OPENDOX_SERVED_SCHEMA is the precedent (A25-3): a name, never a credential, so the workload that must not hold the served DSN can be told it. The same for the database — OPENDOX_SERVED_DATABASE, checked against current_database() before the ledger is bootstrapped — closes it without giving either workload the other's DSN. That is a new setting plus four manifest edits and a guard, ruled a separate act and deliberately not taken here. § 3.5's own batch narrowed the same hole where both DSNs ARE visible: two that name no database no longer compare equal, because libpq defaults the name to the connection user.

The store's own guard does not name a whitespace-bearing scp authority (config._scp_like_userinfo declines a head holding whitespace, so user:pa ss@host:path is None to credential_in_a_remote_url while the URL form of the same value is refused). No writer reachable from the API or the CLI can create such a row — repository_act.refuse_credential_bearing_remote refuses the shape at every one, measured — and the map endpoints now redact it whole, so what remains is a raw-SQL writer against a landed § 3.5. Widening a landed refusal is its own act, and the direction is already written down: the value is one this module cannot parse, and _split_url's reasoning says refuse.

write_back reuses a pathname where the rest of the act holds a descriptor (local_git_adapter.py:2062). rev-parse --absolute-git-dir is converted back into a path for GIT_INDEX_FILE, while the object and ref work stays bound to the inherited directory descriptor — so a rename or replacement between the probe and the index operations puts the temporary index, and its cleanup, in the replacement. Raised at 4156f233. It is § 3.6 code this batch does not touch, it is the TOCTOU family two earlier rounds already worked (_refuse_a_destination_this_service_owns and the O_NOFOLLOW walk), and the repair is the same one they took — keep the index directory tied to a held descriptor. Its own act, with its own case.

SonarCloud S8544 — pin the dependencies this branch's own files pull unpinned: .github/workflows/validate.yml:1195 and deploy/compose/Dockerfile:44. Advisory on this PR (the quality gate is not a required check here) and a supply-chain item rather than a § 3.6 one, so it is registered rather than folded into a security batch whose scope the holder set.

Erratum, recorded here because this act records them: the commit that records this figure (ebad9d6) names the measured commit as 7ed5ee2b; it is 7ed5ee26. The workflow's comment block and this table both name 7ed5ee26, which is the number that matters.

The credential exposure this branch's own merge introduced — fixed, on Brett Heap's word

A regression is not a finding to register. bb450614 pointed app._repository_json at config.redacted_remote_url instead of local_git_adapter.redact_remote_url, for a real reason — the general redactor replaces the userinfo of an ordinary git@github.com:o/r.git, which is a username and not a secret. But config's redactor was written for BROKER URLs and a remote_url is free text, so it knew neither the libpq keyword/value form nor the parameter name pass. Measured through app._repository_json at 555a03c8, all four returned verbatim to every member of the project: host=db password=hunter2 dbname=x, https://github.com/o/r.git?pass=hunter2, https://github.com/o/r.git?sslpassword=hunter2, host=db sslpassword=hunter2.

One declaration and two readings was the first repair, at 2714f6b1: config.SECRET_PARAMETER_KEYS is the list — pass joins it — local_git_adapter.SECRET_PARAMETER_KEYS is built from it ("|".join(...)), and config.LIBPQ_PASSWORD is the one keyword/value pattern the adapter holds by identity. It was not enough, and the case that said it was is the reason it looked enough.

Two implementations reading one list still disagreed three times, and the property case asserting they never did PASSED — its corpus held none of the three. Copilot's review at fe421882 named them; each is measured against a full checkout of that head, not against this tree with a path override (pytest's pythonpath = ["src"] prepends the repo's own src, so a PYTHONPATH "old head" proof silently measures the new code):

shape what fe421882 did where
…?%2574oken=hunter2 config decodes a parameter name once, the adapter to a fixed point GET /api/v1/project-repositories/{id} → 200 with the token in the clear
user:sec⏎ret@host:path config declines to judge a value holding whitespace same endpoint, whole value returned
…?mode=1;token=hunter2 ; is a delimiter to config and not to the adapter — the other direction carries_a_credential answered False, so repository_act.attach_remote accepted a value identity.CoordinationStore refused with a RefusedError the route does not catch: a 500 where a 409 belonged

So there is ONE redactor. config.redacted_remote_url is a call into local_git_adapter.redact_remote_url, and the single nuance this API boundary needs — an ordinary ssh://git@host/… keeps its username, which is not a secret — is an argument to that function rather than a second implementation of it. ; joins both delimiter classes, which is also the 500's fix: the act's pre-check and the store's refusal read the same tail, so that attach is a 409 naming the shape. Agreement is now true by construction; the property case stays as the guard that it remains a call, with the three shapes in its corpus.

And a fourth shape neither reading saw: whitespace INSIDE an authority. user:pa ss@host:path is excluded by the refusal's class (so it cannot start judging prose) and by _CREDENTIAL_SHAPED's (so an unrelated user@host three lines down git's stderr is not joined to the URL above it) — and it came back from the map endpoints entire, measured at fe421882. Closed at the one-URL entry point, where the caller knows it holds one value and not a page of text: redact_remote_url replaces a whitespace-bearing authority whole, exactly as it already does a control-bearing one. redact_credentials is untouched, so the diagnostic reading keeps its lines, and a local path with a space in it has no user:…@ head and is unaffected.

Cases. The DB-backed one drives seven shapes through the real map endpoints — the four of 555a03c8 and the three above — because the defect was in which redactor the boundary called and a case that asked a redactor directly would have passed through both rounds; it asserts the host survives where the value can still be read as one line, that a control-bearing one is replaced whole, that ssh://git@host/… and git@github.com:o/r.git come back exactly as stored, that the ; attach is now a 409, and that the whitespace authority is <redacted-url>. The hermetic one guards the alias, states the property over a corpus of sixteen carriers and six innocent values — now whatever the store's refusal names, the redactor hides (the two readings that actually remain) — and pins the two shapes the redactor hides that the refusal does not name, so the count cannot grow unnoticed.

And the delegation had a cost the first round did not see — this batch's own regression, measured and closed. _decoded_parameter_name decodes a parameter name to a fixed point, which is quadratic in that name by construction, and its docstring named repository_act's length refusal as what keeps it safe. That was true while every path to it came through that refusal; pointing config.redacted_remote_url at redact_remote_url added one that does not, because a legacy remote_url row — a restore, an older build, psql — passed no refusal at any time. Measured against a full checkout of 4156f233, with the decoder instrumented so the call is observed rather than inferred:

a legacy remote_url of CPU per redaction
9 KB of %2525… 0.08 s
60 KB 2.65 s
180 KB 21.31 s

— and _repository_json redacts on every list and every read, once per row, for as long as the row exists. MAX_REMOTE_URL_CHARS therefore moves to config, the module both readers import and where this branch already put the key list and the libpq pattern for the same reason; repository_act keeps the name by alias, so its refusal message and its cases are untouched. The act refuses a new remote longer than it, and redact_remote_url replaces a stored one longer than it whole — so a remote the act accepts is never over-redacted by the boundary that prints it, and the two numbers cannot drift. The case asserts the bound by substitution, not by a clock: it makes the decoder raise, so reaching it at all fails, then removes the substitute and drives a value at the cap through the real decoder, because over-refusing is the other way to get this wrong.

And main is merged (ff926f34). § 3.5 landed squashed (aca94ecb has one parent), so main's copies of every § 3.5 file share no ancestry with this branch's and git reported ten add/add conflicts for files this branch already carried. Each is resolved to this branch's version, and each was checked for anything main had that this branch lacked: the workflow compared structurally (same two jobs, same step names, the only differing run being this branch's hermetic step naming six modules because test_local_git_adapter.py arrives with § 3.6), and every .py file compared by AST over its top-level definitions — the two names that existed only on main are client, which this branch MOVED to tests_runtime/conftest.py, and test_the_verb_set_is_closed_…, which it RENAMED to …_the_runtime_verb_set_… with a sibling for PROJECT_VERBS. Nothing was dropped.

SonarCloud

Green on this PR at every head until the quality gate failed at abc7f634 on S8544 — dependencies pulled without a pinned version or digest, at .github/workflows/validate.yml:1195 and deploy/compose/Dockerfile:44. It is advisory here (SonarCloud is not a required check on this repository) and it is a supply-chain item rather than a § 3.6 one, so it is registered above as a follow-up rather than taken inside a batch whose scope the holder set. The base branch's review answers are described in #25; this branch carries them by merge, never by rebase.

The figures above are this head's, re-measured after those merges.

The lifecycle, run end to end as a process (2026-09-16)

Not a test: the installed opendox-runtime console script, a real Postgres, a real socket. docs/runtime.md § 8a carries the transcript.

step result
runtime init ok — created the project-repository root, reported the pinned canonical digest and ["0001","0002"] on disk
runtime migrate ok — applied 0001 and 0002
runtime status database reachable, both applied, nothing pending, no drift, broker unreachable → ok: false
GET /livez 200 {"status":"live"}
GET /readyz 503 {"database":"ok","schema":"applied","broker_keys":"unavailable: …"}
GET /docs 404 — off unless OPENDOX_PUBLISH_OPENAPI
GET /api/v1/projects 401 — no bearer token
runtime reset --confirm … ok — dropped in the topological order

status and /readyz are deliberately not healthy there: that environment has no Keycloak broker, and both surfaces say so by name rather than reporting green. The database half is green in both, the schema is applied and nothing has drifted — which is the whole of what this act can prove without a broker, and it proves it rather than asserting it.

Four decisions, RULED

RULED openxFactory#656 comment 5701772032 (Brett Heap, 2026-09-16, by interactive multi-choice). All four answers are what these PRs already did, so the ruling cost no re-authoring — it cost a citation, which is 01531a9 on this branch and e9bec39 on #25:

  1. The repository this act creates STAYS BARE, with an empty first commit. Cited at the git init --bare that makes it.
  2. write_back RECORDS basis_revision as a COMMIT TRAILER; the compare-and-swap ref move is what decides staleness. Cited in local_git_adapter's header, in the paragraph explaining why there is no "stale" refusal kind.
  3. The runtime CI job stays ADVISORY now and is made required in a separate declared act. (§ 3.5: the openDox runtime — FastAPI + Postgres, identity and coordination, and nothing else (RULED Q1/Q2) #25's workflow block.)
  4. The verbs are wired into opendox.cli in the BUILD-arc act that repairs opendox.serve; opendox-runtime is the spelling until then. (§ 3.5: the openDox runtime — FastAPI + Postgres, identity and coordination, and nothing else (RULED Q1/Q2) #25's opendox/runtime/cli.py header.)

Review round 5 (Copilot review 5225952155 at cf0b8bac) — every finding fixed, each with an assertion

  • A PERCENT-ENCODED PARAMETER NAME walked past BOTH halves of the credential rule. https://host/x.git?%74oken=ghp_secret contains no literal token, so the refusal accepted it and stored it verbatim in a column the repository endpoints read back to every project member, and the redactor returned it unchanged through a push refusal, a GitCommandFailed message and the CLI's evidence. The name is decoded before it is judged — to a fixed point, so %2574oken is the same trick applied twice — and the two halves now ask ONE predicate, names_a_secret_parameter, instead of each carrying its own regex over raw text. That is the second drift between these halves; the first was the key list, which is why the list was already shared.
  • The push destination check read the FETCH url. git push uses remote.origin.pushurl when one is set, so a stale or hand-added push URL passed the map comparison and sent the corpus elsewhere while the API reported the mapped URL. Both URLs are compared now, the push one through git's own get-url --push, and the refusal says which one disagreed. The test moves only the push URL, leaves the fetch URL matching, and asserts refs/heads/main arrived at NEITHER destination.
  • push_to_remote's branch parameter is gone. Nothing exposed it, but push_to_remote(..., branch="other") would have pushed refs/heads/other while HEAD, LocalGitCorpus and every read served main, and returned success for a history the project is not. The branch is the repository's own, for the same reason remote_name is a constant.

This branch also carries #25's rounds 5 through 8 by merge (0f7d12d, 81b70b2, 080ef29, 893f7eb, 46f1e5b — never a rebase), which is why the figures moved on both sides of the table.

brettheap and others added 8 commits September 16, 2026 13:51
…ment package

RULED Q2 (openxFactory#656 comment 5542792997) puts the openDox runtime on the
`xFactory-Hermes-Install` pattern; RULED Q1 (comment 5542694957) fixes what its
database owns. This commit lands the ordered SQL, the `opendox.runtime`
subpackage and `deploy/{compose,kubernetes}/`, all at the root of this leg.

* `migrations/0001_identity_and_coordination.sql` — RULING Q1's six tables and
  no seventh; pinned by `CANONICAL_MIGRATION_SHA256` and immutable thereafter.
  `migrations/0002_migration_state.sql` — the ledger, additive.
* `src/opendox/runtime/` — `config` (every setting is an env var named in
  `deploy/compose/.env.example`), `migrations` (the fail-closed runner),
  `identity` (the six tables, one store), `db` (the pool), `oidc` (verify
  against the broker; never issue), `app` (six collections behind a bearer
  token), `cli` (`runtime init|migrate|serve|status|reset`).
* `deploy/compose/` + `deploy/kubernetes/` — separate migration and served
  identities, no published host port, no committed credential.
* `pyproject.toml` — a NEW `[project.optional-dependencies] runtime` extra, so
  the leg's existing `pip install -e ".[test]"` is unchanged, and
  `[project.scripts] opendox-runtime`.
* `tests_runtime/` — the hermetic half: 68 assertions over the SQL, the closed
  table set, the package's import weight and the deployment package.

Measured: `python -m pytest -q tests_runtime/test_migration_shape.py
tests_runtime/test_schema_shape.py tests_runtime/test_runtime_surface.py
tests_runtime/test_runtime_cli.py tests_runtime/test_deploy_shape.py
--noconftest` — 68 passed in 5.28s (python 3.12.3, pytest 8.4.2).

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* `docs/runtime.md` — the runbook: the three rulings quoted, the layout, the
  configuration, the five lifecycle verbs, the migration pin, compose and
  Kubernetes, what `reset` does and does not cover, and the residue this act
  records rather than resolves (design § D5's pre-governed scratch space; the
  Q-L5 (b′) narrowing, which this act lifts no part of).
* `tests_runtime/conftest.py` — the DB-backed harness: one throwaway SCHEMA
  per test on a shared server (the Hermes install's shape), an in-fixture RSA
  key pair, a JWKS file and a token minter, so the OIDC suites run the REAL
  verifier and reach no network. No `OPENDOX_TEST_DATABASE_URL` is a SKIP with
  the reason printed, never a silent pass and never a red tree.
* `tests_runtime/test_migrations_apply.py` (7), `test_oidc_verifier.py` (16),
  `test_api_endpoints.py` (20) — the runner against a real Postgres including
  both refusals, token verification against the local key pair including the
  `alg: none` and HS256 downgrades, and the six collections end to end.
* `.github/workflows/validate.yml` — APPEND ONLY (`git diff --stat`: 99
  insertions, 0 deletions, one hunk at `@@ -323,0 +324,99 @@`): a new
  `pytest (runtime, hermetic)` step in the required `validate` job, and a new
  `runtime` job with a `postgres:16` service for everything that needs a
  database, a token or a web framework. Nothing above line 323 is touched, so
  this cannot collide with #24, whose only hunk here is inside the comment
  block at lines 91-147.

Two defects the suites found and this commit fixes, both in code this act
introduces:

* `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. `test_an_empty_key_set_is_a_named_refusal_and_not_a_crash`.
* `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. Now `request: Request`, with the reason recorded at the seam.

Measured (python 3.12.3, pytest 8.4.2, postgres 16.15):
  hermetic, under the required job's own invocation .... 68 passed in 5.12s
  tests_runtime/test_migrations_apply.py ................ 7 passed in 1.94s
  tests_runtime/test_oidc_verifier.py ................... 16 passed in 1.08s
  tests_runtime/test_api_endpoints.py ................... 20 passed in 8.65s

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…tion act

RULED C3 (openxFactory#656 comment 5544381563): "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. …
moving a student or lab-assistant project into a governed factory is a push,
not a migration." Design § D5 names what that makes this code: "the TRIVIAL
CONFORMANT IMPLEMENTATION of the adapter's write-back operation … so the
standalone case is NOT A MODE, it is one adapter implementation."

* `src/opendox/runtime/local_git_adapter.py` — `LocalGitCorpus`, structurally
  conformant with `opendox.corpus_adapter.CorpusAdapter`: six operations, no
  seventh, nothing inherited. THE CORPUS IS THE HISTORY: reads answer from the
  resolved commit and `write_back` builds a blob, a tree and a commit with
  plumbing against a TEMPORARY INDEX, then moves the branch ref with a
  compare-and-swap — so no operation writes a byte on disk, which is what
  `corpus_adapter.write_back`'s "It never touches the corpus tree" demands of
  a corpus whose write path happens to live in the same directory.
  `basis_revision` becomes a commit trailer rather than a refusal, because the
  closed refusal vocabulary has no kind for staleness and `write_back`'s own
  row names only CORPUS_READ_ONLY and WRITE_PATH_UNREACHABLE.
* `src/opendox/runtime/repository_act.py` — the act: the map ROW first, inside
  the caller's transaction, then the repository, so a repository that fails to
  initialize leaves no row pointing at nothing. The remaining window (a process
  killed between the two) is refused by name on the next attempt rather than
  adopted silently. `initialize_repository` is public and database-free, for
  § 3.7's corpus and for this leg's hermetic suites.
* The repository is BARE. A checkout beside the history 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. A repository openDox did NOT create is
  still readable and writable, and `check` is where its divergence is reported.
* The API and the CLI: `POST /api/v1/projects/{id}/repository`, its
  `…/remote` and `…/push` successors, and `opendox-runtime project
  create-repository | attach-remote | push` — plus `ProjectSubcommand`, a
  second conformer to `subcommand_extension.SubcommandExtension`, so the
  eventual `opendox project create-repository` is one line at the assembly
  point and no verb is re-authored. `src/opendox/cli.py` declares no `project`
  command today (measured: its subcommands are generate, generate-and-open,
  create, edit, model-binding and the contributed gate), so the name collides
  with nothing.

THE IMPORT PATH § 3.7 NEEDS: `opendox.runtime.local_git_adapter.LocalGitCorpus`,
stdlib-only to import, and `tests_runtime/test_runtime_surface.py` now holds
both new modules to that contract in a fresh interpreter.

Measured (python 3.12.3, pytest 8.4.2, git 2.43.0): `python -m pytest -q
tests_runtime/test_local_git_adapter.py tests_runtime/test_runtime_surface.py
--noconftest` — 42 passed in 1.97s. The 30 adapter assertions run in the
REQUIRED `validate` job: they need `git` and nothing from the runtime extra.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…e adapter

* `tests_runtime/test_repository_act.py` (15) — the act against a real Postgres
  and a real git: the PAIR (row + repository) written together; a second act on
  a mapped project refused as "already mapped" and not as "there is a directory
  here"; a directory nobody can account for refused BY NAME with the row rolled
  back, proved over two real transactions and a fresh connection; a git that
  fails leaving no row; a write through the adapter being a commit; attaching a
  remote changing no local content (HEAD, tree, refs and the object count all
  measured before and after); and the move being a PUSH — the SAME commit sha
  arrives at a bare "governed factory" and the project is still served from
  where it was. Then the three API verbs, owner-gated.
* `tests_runtime/conftest.py` — the `client` fixture moves here (two suites now
  need it) and gains `client_with_repositories`, which points
  `OPENDOX_PROJECT_REPOSITORY_ROOT` at the test's own directory so a suite can
  never write into a developer's real one.
* `.github/workflows/validate.yml` — `tests_runtime/test_local_git_adapter.py`
  joins the REQUIRED job's hermetic list. That is the strongest placement
  § 3.6's proof can have: the adapter and `opendox.corpus_adapter` are both
  stdlib-only to import, so `isinstance(LocalGitCorpus(), CorpusAdapter)` runs
  in the one check this repository requires. Still append-only against main
  (`git diff -U0`: hunks at `@@ -323,0 +324,99 @@` and, within this act's own
  block, `@@ -356,2 +356,9 @@` / `@@ -365,0 +373 @@`).
* `docs/runtime.md` § 6a — the act, the two decisions it turns on (bare, and an
  empty first commit) and the import path § 3.7 needs.

One defect the suites found and this commit fixes: `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. The row is now checked first (its
`ConflictError` names the project); the orphan check still runs before any
filesystem mutation, so either refusal leaves the disk as it found it.

Measured (python 3.12.3, pytest 8.4.2, postgres 16.15, git 2.43.0):
  hermetic, under the required job's own invocation ... 104 passed in 7.32s
  python -m pytest -q tests_runtime/ ................. 162 passed in 23.82s

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`_head` and `_resolve_revision` still annotated their `git` parameter `_Git`,
the private name the class carried before `repository_act` became a second
caller and it was made public. Under `from __future__ import annotations` an
annotation is a string, so both were inert at runtime and every suite was
green; `pyflakes` reports them as undefined names, which is what they are.

Found by running `python -m pyflakes src/opendox/runtime/*.py
tests_runtime/*.py` over this act's files — clean at this head.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
None of these change behaviour; all six were things a reviewer would have had
to ask about, so they are answered in the source instead.

* `tests_runtime/conftest.py` — two `pytest.importorskip(...)` calls followed by
  a `del` of the name they bound, and an `import jwt` bound only to be deleted.
  The `importorskip` is the guard; the binding was noise.
* `tests_runtime/test_runtime_cli.py` — `open(...).read()` replaced with
  `Path.read_text`, so no file handle is left to the garbage collector; the
  `from pathlib import Path` moves to the module's import block; and the file
  now SAYS why it reads `parser._actions` and `argparse._SubParsersAction`
  (argparse publishes no way to ask a built parser which subcommands it
  declares, and asserting against the help text would pin formatting rather
  than structure and go red on a Python release that rewraps a line).
* `tests_runtime/test_oidc_verifier.py` — the same two `open(...).read()` sites.
* `src/opendox/runtime/app.py` — `del principal` in a read handler now carries
  its reason ONCE, at the first site: the `PrincipalDep` parameter is what makes
  the route authenticated at all (FastAPI resolves it, verifying the token and
  upserting the row, before the body runs), so a handler that does not then use
  the value has authorization "any signed-in principal may read this". `del`
  states that instead of leaving an argument that looks forgotten.

Measured at this head: `python -m pyflakes src/opendox/runtime/*.py
tests_runtime/*.py` clean; the required job's own invocation 104 passed;
`python -m pytest -q tests_runtime/` 162 passed in 21.59s.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
None of these change behaviour; all four were things a reviewer would have had
to ask about, so they are answered in the source instead.

* `tests_runtime/conftest.py` — two `pytest.importorskip(...)` calls followed by
  a `del` of the name they bound, and an `import jwt` bound only to be deleted.
  The `importorskip` is the guard; the binding was noise.
* `tests_runtime/test_oidc_verifier.py`, `tests_runtime/test_runtime_cli.py` —
  three `open(...).read()` sites replaced with `Path.read_text`, so no file
  handle is left to the garbage collector.
* `tests_runtime/test_runtime_cli.py` also now SAYS why it reads
  `parser._actions` and `argparse._SubParsersAction`: argparse publishes no way
  to ask a built parser which subcommands it declares, and asserting against the
  help text would pin formatting rather than structure and go red on a Python
  release that rewraps a line.
* `src/opendox/runtime/app.py` — `del principal` in a read handler now carries
  its reason ONCE, at the first site: the `PrincipalDep` parameter is what makes
  the route authenticated at all (FastAPI resolves it, verifying the token and
  upserting the row, before the body runs), so a handler that does not then use
  the value has authorization "any signed-in principal may read this". `del`
  states that instead of leaving an argument that looks forgotten.

Measured at this head: `python -m pyflakes src/opendox/runtime/*.py
tests_runtime/*.py` clean; `python -m pytest -q tests_runtime/` 111 passed in
15.14s; the required job's own invocation 68 passed.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The same four edits landed on this branch as `dc06f68` before they landed on
its base, so this merge is a no-op on content and a repair of the stack: the
two branches now carry byte-identical copies of `app.py`, `conftest.py`,
`test_oidc_verifier.py` and the cleanup hunks of `test_runtime_cli.py`, and
a reviewer of either PR reads the same files.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

# Conflicts:
#	tests_runtime/test_runtime_cli.py
Copilot AI lite review requested due to automatic review settings September 16, 2026 15:02
@sourcery-ai

sourcery-ai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR makes repository creation a first-class project operation: it atomically coordinates the database map row with a bare, empty local Git repository, supplies a stdlib-only history-backed corpus adapter whose writes are commit-based and CAS-protected, exposes creation/remote/push operations through owner-gated API and CLI surfaces, and validates the behavior through hermetic and database-backed tests.

Sequence diagram for the repository creation act

sequenceDiagram
    participant Owner
    participant API as Repository API
    participant Store as CoordinationStore
    participant Git as Bare Git Repository

    Owner->>API: POST /api/v1/projects/{id}/repository
    API->>Store: create_project_repository(project_id, adapter, location)
    Store-->>API: map row
    API->>Git: initialize_repository(location, project_id, actor)
    Git->>Git: git init --bare
    Git->>Git: commit-tree empty tree
    Git-->>API: initial_commit
    API-->>Owner: 201 repository mapping and initial commit

    alt repository initialization fails
        Git-->>API: RepositoryActRefused
        API-->>Owner: 409 repository.refused
        Store-->>Store: caller transaction rolls back map row
    end
Loading

Sequence diagram for commit-based local corpus writes

sequenceDiagram
    participant Caller
    participant Corpus as LocalGitCorpus
    participant Git as Git History

    Caller->>Corpus: resolve(CorpusRef)
    Corpus->>Git: git rev-parse HEAD
    Git-->>Corpus: basis revision
    Caller->>Corpus: write_back(document, content, actor, basis_revision)
    Corpus->>Git: hash-object -w --stdin
    Corpus->>Git: read-tree and update-index using temporary index
    Corpus->>Git: write-tree
    Corpus->>Git: commit-tree with trailers
    Corpus->>Git: update-ref expected basis revision
    Git-->>Corpus: new commit
    Corpus-->>Caller: WriteReceipt

    alt basis ref changed
        Git-->>Corpus: compare-and-swap failure
        Corpus-->>Caller: WRITE_PATH_UNREACHABLE
    end
Loading

File-Level Changes

Change Details Files
Add a stdlib-only local Git corpus adapter that treats repository history as the corpus and commits as the governed write path.
  • Implement structural conformance to the closed six-operation corpus adapter protocol without inheritance or extra public operations.
  • Read listings and document contents from resolved Git commits, including empty repositories and explicit refusal handling.
  • Write documents with Git plumbing, temporary indexes, commit trailers, and compare-and-swap ref updates without modifying a working tree.
  • Classify supported file shapes without governance requirements and report, rather than omit, unknown documents.
  • Detect checkout divergence where applicable and expose Git availability and shared identity/runner helpers.
src/opendox/runtime/local_git_adapter.py
src/opendox/runtime/__init__.py
tests_runtime/test_local_git_adapter.py
tests_runtime/test_runtime_surface.py
Implement repository creation as an explicit paired coordination-and-filesystem act with bare, empty-initialized repositories.
  • Insert the project-repository map row in the caller transaction before filesystem initialization, allowing initialization failures to roll back the row.
  • Refuse existing mappings and unaccounted non-empty directories rather than adopting or overwriting them.
  • Create a bare repository with an empty first commit and provide helpers to resolve its corpus reference.
  • Attach or replace a remote and push existing Git objects without migrating or changing the local repository.
  • Add runtime dependency checks and owner-facing refusal paths for unavailable Git or failed repository operations.
src/opendox/runtime/repository_act.py
tests_runtime/test_repository_act.py
docs/runtime.md
Expose repository lifecycle operations through owner-gated HTTP routes and standalone CLI commands.
  • Add create, remote-attach, and push API verbs under each project’s repository path with conflict/refusal responses.
  • Add a separate project CLI command with closed create-repository, attach-remote, and push subcommands.
  • Provide a structural ProjectSubcommand extension for eventual assembly into the main CLI without modifying the core CLI command set.
  • Preserve the closed database collection surface while documenting the new verb-oriented interfaces.
src/opendox/runtime/app.py
src/opendox/runtime/cli.py
tests_runtime/test_runtime_cli.py
tests_runtime/test_api_endpoints.py
tests_runtime/conftest.py
docs/runtime.md
Integrate the adapter’s hermetic conformance tests into required CI and document the runtime/deployment boundaries.
  • Run the local Git adapter suite in the required hermetic validation job, skipping with an explicit reason when Git is unavailable.
  • Record the new runtime modules, Git test dependency, repository-act coverage, and one-replica deployment constraint.
  • Extend runtime import-surface checks to ensure the adapter and act remain importable without web or database dependencies.
.github/workflows/validate.yml
docs/runtime.md
src/opendox/runtime/__init__.py
tests_runtime/test_runtime_surface.py

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

brettheap and others added 2 commits September 16, 2026 15:12
…measurement, and eight code smells

SonarCloud's Quality Gate on this PR failed one condition — "E Security Rating
on New Code (required ≥ A)" — over 32 issues. SonarCloud is ADVISORY on this
lane's gate, so nothing here is required; it is done because every one of these
is either a real improvement or a claim worth writing down.

TWO HARDENINGS (`githubactions:S8541`, `docker:S8541`) — `--only-binary :all:`
on both new pip installs, this act's CI job and the image build. Without it pip
may build a dependency from an sdist, which runs that project's `setup.py`
inside the job. MEASURED in a clean venv on 2026-09-16 before it was declared:
`pip install --only-binary :all: -e ".[runtime,test]"` resolves and installs,
and `import fastapi, psycopg, jwt, httpx, uvicorn, opendox.runtime` succeeds —
the local editable project is exempt from the flag, so `-e .` still works, and
`psycopg[binary]` is asked for by name precisely so libpq is never built.
`tests_runtime/test_deploy_shape.py` now asserts the Dockerfile carries it.

ONE SUPPRESSION BY MEASUREMENT (`secrets:S6698`, BLOCKER, the rating's cause) —
the `runtime` job's `POSTGRES_PASSWORD: opendox` is a throwaway credential for a
service container reachable only from that job's own network namespace and torn
down with it. `# NOSONAR`, on the estate's own precedent:
`xFactory-Hermes-Install/.github/workflows/ci.yml` marks its identical
`POSTGRES_PASSWORD: hermes` the same way. The runtime's real DSNs are Secret
references everywhere they appear and `test_deploy_shape.py` refuses a committed
credential value.

ONE MORE BY MEASUREMENT (`python:S5659`, CRITICAL) — "Don't use a JWT token
without verifying its signature" fires on `jwt.get_unverified_header`. Reading
the header first is the only possible order: it carries the `kid` that selects
the signing key and the `alg` the allow-list is applied to, and neither can be
known until it is read. Nothing from it is trusted — `alg` is checked against
the allow-list and the signature is verified in `_decode`, which runs with
`verify_signature: True` and a required-claim list. `# NOSONAR` with that
reason at the line.

EIGHT REAL SMELLS, fixed rather than argued with:
* `python:S5713` — `except (httpx.HTTPError, json.JSONDecodeError, ValueError)`
  named a subclass beside its base: `json.JSONDecodeError` IS a `ValueError`
  (measured), so the pair read as two different failures. Inherited from the
  Hermes source this module was modelled on.
* `python:S3776` — `TokenVerifier.verify` was cognitive complexity 17 (limit
  15). The seven-clause PyJWT-to-`OidcError` mapping is now `_decode`, which is
  also the part a reader wants on its own.
* `python:S8415` — every authenticated router now declares `responses=REFUSALS`,
  so the published OpenAPI schema states the 401/403/404/409 bodies a client
  must handle instead of leaving them to be discovered.
* `python:S7632` — four `# noqa: BLE001 - prose` comments were not valid noqa
  syntax; the prose moves to its own line and the marker is bare.
* `python:S1192` — "project repository" appeared as a literal three times in
  `identity.py`; a module constant now, so a typo cannot make one refusal read
  as a different failure.
* `python:S9083` ×5, `python:S9073` ×4, `python:S5778` ×6 in the suites — bare
  `@pytest.fixture`, composite assertions split so a failure names which half
  failed, and one throwing call per `pytest.raises` block so the block cannot
  pass for the wrong reason.

RECORDED AND NOT DONE: `githubactions:S8544` / `docker:S8544` ("dependencies
without locking resolved versions"). That is the `--require-hashes` lockfile
`pyproject.toml` already names as the obvious successor and as a real act with
a real owner — the Hermes install carries a `uv.lock` for exactly that reason —
and a § 3.5 PR should not invent this leg's supply-chain pin. `S8541` at
`validate.yml:29` is the PRE-EXISTING install step this act must not edit.

Measured at this head: `python -m pyflakes src/opendox/runtime/*.py
tests_runtime/*.py` clean; the required job's own invocation 68 passed;
`python -m pytest -q tests_runtime/` 111 passed in 11.81s.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

# Conflicts:
#	tests_runtime/test_api_endpoints.py
@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

Unresolved critical and moderate issues affect credential exposure, concurrent Git writes, adapter dispatch, and transaction/error handling.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds first-class per-project local Git repositories for openDox, with a history-backed corpus adapter and API/CLI workflows for remotes and pushes.

Changes:

  • Adds LocalGitCorpus with commit-based write-back and CAS protection.
  • Adds repository creation, remote attachment, and push operations.
  • Extends tests, fixtures, documentation, and required CI validation.
File summaries
File Summary
tests_runtime/test_runtime_surface.py Verifies runtime import and structural contracts.
tests_runtime/test_runtime_cli.py Tests project CLI command structure.
tests_runtime/test_repository_act.py Tests repository lifecycle operations.
tests_runtime/test_local_git_adapter.py Tests Git corpus behavior and conformance.
tests_runtime/test_api_endpoints.py Tests repository API integration.
tests_runtime/conftest.py Adds shared runtime fixtures.
src/opendox/runtime/repository_act.py Implements repository creation, mapping, remotes, and pushes.
src/opendox/runtime/local_git_adapter.py Implements the history-backed local Git adapter.
src/opendox/runtime/cli.py Adds project repository CLI commands.
src/opendox/runtime/app.py Adds repository API routes and authorization.
src/opendox/runtime/__init__.py Documents runtime import boundaries.
docs/runtime.md Documents repository behavior and deployment constraints.
.github/workflows/validate.yml Adds adapter tests to required validation.
Review details

Suppressed comments (10)

src/opendox/runtime/cli.py:367

  • The success JSON is emitted before database.transaction() exits and commits. If the commit fails after the filesystem repository was initialized, this prints ok: true (and then the generic error handler may print a second record) even though the map row rolled back, leaving the act split. Emit only after the transaction context has successfully closed.
                CoordinationStore(conn), project_id=args.project_id,
                root=settings.project_repository_root, actor=args.actor)
            return _emit({"verb": "create-repository",
                          "project_id": args.project_id,
                          "adapter": repository_act.ADAPTER_NAME,

src/opendox/runtime/cli.py:394

  • This success record is also emitted while the transaction is still open. A database commit/rollback after the remote configuration has been changed can make the command report success even though the map update did not commit, and the exception path then emits a second JSON object. Move the emit after the with block.
                CoordinationStore(conn), project_id=args.project_id,
                remote_url=args.remote_url)
            return _emit({"verb": "attach-remote",
                          "project_id": args.project_id,
                          "remote_url": row.remote_url,

src/opendox/runtime/cli.py:418

  • The push result is emitted before the surrounding transaction has committed. If closing the database context fails after the remote push, the command reports success and then reports an error, despite the remote already having received the objects. Emit after the transaction block so the command has one final outcome.
            remote_url = repository_act.push_to_remote(
                CoordinationStore(conn), project_id=args.project_id)
            return _emit({"verb": "push", "project_id": args.project_id,
                          "pushed_to": remote_url,

src/opendox/runtime/local_git_adapter.py:177

  • subprocess.run() raises FileNotFoundError/OSError when the executable is missing; it does not return a CompletedProcess for GitRunner.out() to convert into GitCommandFailed. The adapter and the attach/push acts catch only GitCommandFailed, so a missing or invalid Git executable leaks an unhandled OS exception instead of the promised named refusal (an API 500 and a CLI FileNotFoundError result). Normalize this failure in GitRunner or in every caller.
        argv = [self.executable, "-C", str(self.root), "--literal-pathspecs",
                *args]
        merged = {**os.environ, **(env or {})}
        return subprocess.run(argv, input=stdin, capture_output=True,

src/opendox/runtime/repository_act.py:235

  • The project-to-repository map deliberately carries an adapter name, but this act ignores it and always runs local Git against row.location. If the row belongs to a governed/factory adapter, this endpoint will mutate that adapter's repository configuration instead of refusing or dispatching through its implementation. Restrict this operation to ADAPTER_NAME before touching the filesystem.
    row = store.repository_for_project(project_id)
    git = GitRunner(Path(row.location), executable)

src/opendox/runtime/repository_act.py:142

  • git_available() runs before the authoritative map lookup. If Git is missing, a repeated create for an already-mapped project returns the dependency refusal instead of ConflictError, contrary to the documented row-first ordering and making the result depend on the host environment. Check the mapping before probing Git, then rely on the caller's transaction to roll back the row if a new-project initialization cannot run.
    if not git_available(executable):
        raise RepositoryActRefused(
            f"{executable!r} is not on PATH; RULING C3's repository is a plain "
            "local git repository and this act creates it by running git")

src/opendox/runtime/repository_act.py:187

  • Filesystem setup happens outside the try and only GitCommandFailed is normalized below. A permission error or a non-directory parent from location.mkdir() escapes as PermissionError/NotADirectoryError, so the API create route returns an unhandled 500 instead of the act's named RepositoryActRefused failure.
    location = Path(location)
    location.mkdir(parents=True, exist_ok=True)
    git = GitRunner(location, executable)

src/opendox/runtime/repository_act.py:118

  • The default OPENDOX_PROJECT_REPOSITORY_ROOT is the relative path var/projects, but this stores that relative path directly in the durable map. A later API/CLI process with a different working directory will resolve the same row against a different filesystem location, so the repository can appear absent or point at the wrong tree. Persist an absolute canonical root before appending the project id.
    return Path(root).expanduser() / project_id

src/opendox/runtime/repository_act.py:154

  • This call is reached through a check-then-insert implementation with a unique project_id constraint. Two concurrent create requests can both pass the pre-check, after which the loser gets the database's raw unique-violation exception rather than identity.ConflictError; _conflict consequently returns a 500 instead of the documented 409 for a second repository. Make the insert/conflict mapping atomic and normalize the race to the same conflict path.
    row = store.create_project_repository(
        project_id=project_id, adapter=ADAPTER_NAME, location=str(location))

src/opendox/runtime/repository_act.py:226

  • The public helper accepts a custom remote_name, but only the URL is persisted in project_repositories; push_to_remote later defaults to origin. Calling attach_remote(..., remote_name="upstream") therefore succeeds but the normal push cannot find the attached remote. Either remove this override or persist and use the selected name consistently.
def attach_remote(store: Any, *, project_id: str, remote_url: str,
                  remote_name: str = "origin",
                  executable: str = "git") -> Any:
  • Files reviewed: 13/13 changed files
  • Comments generated: 7
  • 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 src/opendox/runtime/app.py Resolved
Comment thread src/opendox/runtime/repository_act.py Resolved
Comment thread src/opendox/runtime/repository_act.py Resolved
Comment thread src/opendox/runtime/repository_act.py Resolved
brettheap and others added 4 commits September 16, 2026 15:17
…it unparseable

THE PREVIOUS HEAD RAN NO JOB AT ALL, and the PR page did not say so. Measured:
`gh api repos/opensoft/openDox-code/commits/4d3ce664.../check-runs` at that head
returns SonarCloud and the Copilot bot and NOTHING ELSE, and
`gh api .../actions/runs?head_sha=4d3ce664...` returns a run named
`.github/workflows/validate.yml` — GitHub's name for a file it could not parse —
with conclusion `failure`. Neither `validate` nor `runtime` started.

THE CAUSE. `run: python -m pip install --only-binary :all: -e ".[runtime,test]"`
as a PLAIN YAML scalar contains `: `, and a colon followed by a space is a
mapping indicator, so the document fails to scan:
`yaml.scanner.ScannerError: mapping values are not allowed here`, line 434
column 54. The flag was added in the previous commit to answer SonarCloud
`githubactions:S8541`; the flag is right and the scalar form was wrong. It is a
folded scalar (`>-`) now, which is the form the two steps above it already use.

AND THE ABSENCE OF A RUN LOOKS LIKE NOTHING, which is why this commit also adds
four suites to `tests_runtime/test_deploy_shape.py` rather than only fixing the
line:
* the workflow parses as YAML at all — the assertion whose failure this class of
  defect is;
* both jobs are declared, this act's hermetic step is APPENDED after the
  existing `pytest` step (reordering is an edit to what the required check
  already ran), and the DB-backed step is the runtime job's last;
* the runtime job supplies a `postgres:` service, installs `.[runtime,test]`
  with `--only-binary :all:`, and passes a `postgresql://` DSN;
* the REQUIRED job installs the test extra ALONE — if it ever installed
  `.[runtime]` every assertion about what imports without the extra would still
  pass and would stop meaning anything.

Two SonarCloud leftovers fixed in the same commit, both the same mistake:
`secrets:S6698` still fired because `xFactory-Hermes-Install`'s precedent marks
BOTH halves — its Postgres password AND its DSN — and this act had marked only
the first; and `python:S7632` fired on a PROSE comment that spelled the
suppression marker, which Sonar reads as a malformed suppression. The marker is
now written only at the end of the line it suppresses, in both files.

Measured at this head (python 3.12.3, pytest 8.4.2, postgres 16.15):
  the required job's own invocation ............ 71 passed
  python -m pytest -q tests_runtime/ ........... 114 passed
  python -c "import yaml; yaml.safe_load(open('.github/workflows/validate.yml'))"
    parses, and reports jobs ['validate', 'runtime']

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: brettheap <1513478+brettheap@users.noreply.github.com>
Co-authored-by: brettheap <1513478+brettheap@users.noreply.github.com>

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

Unresolved findings remain in URL handling, transaction ordering, Git adapter behavior, and repository lifecycle consistency.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (12)

src/opendox/runtime/app.py:74

  • An arbitrary remote URL is stored and returned verbatim by _repository_json, including from the list/read routes available to any authenticated principal. A value such as https://user:token@host/repo.git therefore persists a credential and leaks it to every signed-in user. Reject credential-bearing URLs or keep credentials out of this field and redact them before exposing repository rows.
class RemoteAttach(BaseModel):
    remote_url: str = Field(min_length=1)

src/opendox/runtime/cli.py:369

  • This emits the success JSON before database.transaction() exits and commits. If PostgreSQL commit fails after create_repository has initialized Git, the CLI prints success and then the exception handler prints failure, while the row rolls back and the repository is left in the orphan window this act is meant to report. Build the result inside the transaction but emit it only after the with block has committed.
                root=settings.project_repository_root, actor=args.actor)
        assert created is not None
        return _emit({"verb": "create-repository",
                      "project_id": args.project_id,
                      "adapter": repository_act.ADAPTER_NAME,

src/opendox/runtime/cli.py:396

  • This has the same pre-commit success path as cmd_create_repository: _emit runs while the transaction is still open. If the map update cannot commit after Git config was changed, the CLI prints a success record and then a failure record, even though the authoritative row rolled back. Construct the result inside the with block and emit only after it exits successfully.
            row = repository_act.attach_remote(
                CoordinationStore(conn), project_id=args.project_id,
                remote_url=args.remote_url)
        assert row is not None
        return _emit({"verb": "attach-remote",

src/opendox/runtime/cli.py:420

  • The push is performed and success is emitted before the surrounding database transaction has closed. A connection/commit failure can therefore produce a success record followed by a failure even though the remote already received the push, leaving the caller with the wrong outcome. Emit only after the with block and report the push as indeterminate if the post-push transaction cannot close.
    try:
        remote_url = None
        with database, database.transaction() as conn:
            remote_url = repository_act.push_to_remote(

src/opendox/runtime/local_git_adapter.py:436

  • Using the PID as the temporary index name is not safe for concurrent writes to the same repository. Two requests in one process can share GIT_INDEX_FILE, interleave read-tree/update-index/write-tree, or unlink the other request's index; the ref CAS does not prevent that tree corruption or nondeterministic failure. Use a unique per-call index name and clean it up after the operation.
            return ()
        if bare == "true" or corpus.revision is None:

src/opendox/runtime/local_git_adapter.py:477

  • Every nonzero result from rev-parse --verify HEAD is treated as a legal no-commit repository. That conflates an empty initialized repo with a broken/unreadable HEAD or object database, so resolve can return an empty corpus and list_documents() can return () instead of CORPUS_UNREADABLE, violating the interface's explicit empty-versus-unreadable distinction. Distinguish the expected unborn-HEAD case from other Git failures before returning None.
        if not corpus.write_path_available:
            raise _refuse(WRITE_PATH_UNREACHABLE, corpus.write_path,
                          f"the object database under {corpus.location} is not "
                          "writable; the document remains unsaved rather than "
                          "being written by a fallback")

src/opendox/runtime/repository_act.py:160

  • An existing regular file at the project location makes location.iterdir() raise NotADirectoryError before the act can produce its named refusal; the API then returns a 500 instead of a repository conflict. Check is_dir() and raise RepositoryActRefused for an existing non-directory before iterating.
    return CorpusRef(name=name or row.project_id, location=row.location)

src/opendox/runtime/repository_act.py:246

  • The Git remote configuration is changed before the database UPDATE. If the surrounding transaction later rolls back (for example because the database or a later caller write fails), the repository keeps the new remote while the authoritative map row still has the old/NULL URL. The next push can then use state the map does not describe; add compensation/reconciliation or model this cross-system window explicitly.
                             stdin=b"").decode().strip()
        message = (
            f"Create the repository for project {project_id}\n"
            "\n"
            "openDox creates a repository as a first-class act "

src/opendox/runtime/repository_act.py:154

  • The preflight SELECT in create_project_repository is not atomic with its INSERT. Two concurrent create requests can both pass that check; the losing INSERT then raises a raw database unique-violation that _conflict does not catch, producing a 500 instead of the documented 409 conflict. Make the insert's unique violation map to ConflictError (or handle it at this act boundary).
def corpus_ref_for(row: Any, *, name: str | None = None) -> CorpusRef:
    """The `CorpusRef` a map row addresses, for `LocalGitCorpus.resolve`.

src/opendox/runtime/repository_act.py:268

  • The push target is selected by remote_name, not by the map's row.remote_url, and the map stores no remote name. A caller can attach with remote_name="upstream", or local Git config can drift, while the default push uses origin (or another URL) and reports row.remote_url as the destination. Verify the configured URL against the mapped URL or push directly to the stored URL, and persist the name if it is configurable.
                  executable: str = "git") -> Any:

src/opendox/runtime/repository_act.py:133

  • branch allows this act to create a repository on a non-default branch, but the returned CorpusRef carries no branch and the default LocalGitCorpus/push_to_remote paths target main. Calling create_repository(..., branch="trunk") therefore produces a mapped repository that the advertised write and push successors cannot serve by default. Remove/lock this option or propagate the selected branch through every consumer.

def _current_head_ref(git: GitRunner) -> str:

src/opendox/runtime/repository_act.py:142

  • The map-row check is not actually first: git_available() runs before create_project_repository(). If a project is already mapped but Git is unavailable, this reports the environment failure instead of the authoritative ConflictError, so the second-act refusal depends on whether Git happens to be installed. Move the availability check after the map lookup/insert, still inside the caller's transaction.

def _display_remote_url(remote_url: str) -> str:
    parts = urlsplit(remote_url)
    if parts.scheme and parts.netloc:
  • Files reviewed: 14/14 changed files
  • Comments generated: 3
  • Review effort level: Lite

Comment thread src/opendox/runtime/app.py Resolved
Copilot AI review requested due to automatic review settings September 16, 2026 15:22
Copilot AI and others added 3 commits September 16, 2026 15:23
Co-authored-by: brettheap <1513478+brettheap@users.noreply.github.com>
WHAT HAPPENED, MEASURED. Requesting a review with `gh pr comment --body
'@copilot review'` did not only request a review: on this repository it also
started GitHub's Copilot CODING agent (`gh api .../actions/runs` shows a run
named "Addressing comment on PR #25"), which pushed `86ab5fad` ("Fix repository
adapter review issues", 359 insertions across 7 files) and `1bdedc24`
("Address validation follow-up comments") straight onto this branch.

WHY THEY ARE REVERTED RATHER THAN KEPT. Nothing about them is reviewable as
this act: they carry no `Lane:` trailer and no measurement, nobody ran their
tests before they landed on the branch, and the act they modify is one this
lane claimed (`#656` comment 5699629780) and is answerable for line by line.
An act whose code arrived from an agent nobody asked and nobody measured is not
an act this lane can put its name on, whatever the diff happens to say.

THE FINDINGS THEY WERE ANSWERING ARE NOT DISMISSED. Copilot's review of this PR
(`5224578194`) and of #25 (`5224556194`) are substantial and largely correct —
the missing-executable normalization, the branch assumed to be `main`, the
unborn-versus-unreadable HEAD, the per-process index name, the relative path
persisted in the durable map, the adapter name ignored by `attach_remote` and
`push_to_remote`, the CLI emitting success inside an open transaction, and the
credential-bearing remote URL. Every one of them is answered in this lane's own
commits, with the measurement each needs, in the commits that follow this one.

This is a REVERT and not a force-push: the two commits stay in the history,
which is what makes this note findable next to them. Reviews on this repository
are requested through
`gh api --method POST repos/<owner>/<repo>/pulls/<n>/requested_reviewers
-f 'reviewers[]=Copilot'` from here on, never through an `@copilot` comment.

`git diff a1e7dab` is empty at this commit —
the tree is exactly what this lane last pushed.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: brettheap <1513478+brettheap@users.noreply.github.com>
Copilot stopped work on behalf of brettheap due to an error September 16, 2026 15:25
brettheap and others added 5 commits September 18, 2026 18:00
…"$user"` token

The third mini-batch, RULED by Brett Heap ~17:55Z on openxFactory#656: the two
security-relevant findings of the round at `0968ff8b`, one test each, every
premise measured on postgres 16 and through `PQconninfoParse` rather than
argued.

* TWO DSNs THAT NAME NO DATABASE DID NOT NAME THE SAME ONE.
  `database_named_by` reports what the STRING says, so a pair that both leave
  the database out both answered `None` and the preflight read that as
  agreement. libpq defaults `dbname` to the CONNECTION USER, and this
  deployment's two DSNs carry deliberately different users — the privileged
  migration identity and the least-privileged served one, which is the whole
  point of the split. MEASURED: `postgresql://opendox:…@host:5432/` connects
  and `select current_database()` answers `opendox`.
  `effective_database` resolves `dbname`, else the user; and with NEITHER in
  the string the answer is UNRESOLVED and the pair is refused, because libpq
  then falls back to the operating-system user of whichever process connects
  and the two DSNs are used by two different containers. That is the contract
  the guard already has — it answers before anything connects, so a
  comparison it cannot make is a refusal, exactly as for a broker URL it
  cannot parse. Resolving it AFTER connecting was the alternative and is not
  available to a configuration-time check without a network.
* `"$user"` IS A TOKEN AND WAS COMPARED AS A LITERAL, so two roles' DSNs both
  selecting `"$user",public` agreed on the string while PostgreSQL resolved
  them to two different schemas. `effective_schema` substitutes the DSN's own
  user, as the server does, and the token with no user in the string is
  UNRESOLVED rather than "names no schema" — reading it as the latter would
  have compared equal to a DSN that really names none, which is the same
  false agreement one step along.
  MEASURED on postgres 16, three ways: `search_path = "$user", public` with no
  matching schema gives `current_schema() = public`; WITH A SCHEMA LITERALLY
  NAMED `$user` it is STILL `public`; and with a schema named for the session
  user it is that schema. PostgreSQL never reads `"$user"` as a schema NAME,
  even when one exists — which also measures FALSE the suppressed finding at
  `migrations.py:484` that a real `$user` schema is mistaken for the token.
  (`set search_path = $user` unquoted is a syntax error; the token is always
  written quoted.)

At `68ebea49` the guard ACCEPTED three of the four shapes these cases forbid;
the fourth was refused for the wrong reason.

`user_named_by` is new and reads a NAME, never a credential: the user name is
in every server log line, in `pg_stat_activity` and in a committed ConfigMap,
and nothing here touches the password.

REGISTERED, NOT BUILT — a follow-up act under the same claim: the served
DATABASE has no non-secret declaration, only the served schema
(`deploy/kubernetes/base/migration-job.yaml:206`). `OPENDOX_SERVED_DATABASE`
on A25-3's precedent, checked against `current_database()` before the ledger
is bootstrapped, plus four manifest edits. Ruled a separate act, not this one.

Erratum, carried from the sibling PR: the commit recording openDox-code#26's
`7ed5ee26` figure names it `7ed5ee2b` in its own message. The workflow block
and that PR's description both say `7ed5ee26`, which is the number that
matters.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`3d587ae8` is the commit that was measured: 200 passed 1 skipped on the
required job's own five modules with the runtime extra unimportable, and 324
on `pytest -q tests_runtime/` with a database. The PR description states the
same two numbers at the same commit.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The third mini-batch's #26 half, RULED by Brett Heap ~17:55Z on
openxFactory#656.

`child.kill()` signalled the top-level `git` and nothing else, and a push's
real work is in its DESCENDANTS: `ssh` for a network destination,
`git-receive-pack` for a local one. They hold the pipes this method drains and
they keep running after the parent dies, so a timed-out or overflowing push
could go on to COMPLETE THE REMOTE WRITE after this act had refused, told its
caller nothing was sent and rolled the map row back (Copilot review of
openDox-code#26, at `ebad9d65`). For a local destination that write lands in a
real repository on this machine.

MEASURED AT `555a03c8` WITH A PLANTED SLOW DESCENDANT, and it is worse than the
finding said: the case does not merely leak a process, it takes 30.0 SECONDS
FOR A 0.6-SECOND BOUND. The surviving group holds the pipes, so the wall clock
`out_bounded` exists to enforce is itself defeated — and with it the promise
that a stalled remote cannot hold the request, the repository and the caller's
database transaction.

`Popen` takes `start_new_session=True`, so the child leads a session containing
it and everything it spawns and nothing else, and `_stop_the_whole_group`
SIGKILLs that group and reaps the child before returning. Both refusal paths
use it — the timeout and the output cap. The CLEAN path deliberately does not:
a completed push's remaining descendants are git's own business (an
opportunistic `gc`, an ssh control master), and killing them would be a new
behaviour rather than a bound on a refused one.

Two cases. The first drives the finding: a stub `git` spawns a descendant that
waits and then writes a marker — the stand-in for the remote write — and the
refusal must arrive, the descendant must be dead before the call returns
(`kill(pid, 0)`), and the marker must never appear (waited out past its own
delay, because a merely slow process would pass an assertion made too early).
The second pins the MECHANISM, so a later edit that drops
`start_new_session=True` cannot pass the first on a stub whose descendant
happens to die with its parent: the child's process group is its own and is not
this runner's.

Erratum: the commit recording this branch's `7ed5ee26` figure names it
`7ed5ee2b` in its own message. The workflow block and the PR description both
say `7ed5ee26`, which is the number that matters.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ory-act

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

# Conflicts:
#	.github/workflows/validate.yml
`a86dc3a2` is the merge commit that was measured: 345 passed 1 skipped on the
required job's own six modules with the runtime extra unimportable, and 553 on
`pytest -q tests_runtime/` with a database. The PR description states the same
two numbers at the same commit.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@brettheap

Copy link
Copy Markdown
Contributor Author

Registered — and ONE finding is BLOCKING-class and is HELD for the holder's word

Read the review at 555a03c8 in full (the head before the one push this batch was allowed). Two findings, one of them a credential exposure I introduced in the base merge bb450614, so under the holder's standing instruction it is reported rather than fixed on my own initiative. Nothing further is pushed until that word arrives.

BLOCKING-class — src/opendox/runtime/app.py:1076, and the reviewer is exactly right

The merge resolution swapped this boundary from local_git_adapter.redact_remote_url to config.redacted_remote_url, for a real reason — the general redactor replaces the userinfo of an ordinary git@github.com:o/r.git, which is a username and not a secret. But config's redactor was written for BROKER URLs and does not know the conninfo vocabulary the adapter's does, and remote_url is free text.

Measured at the current head, through app._repository_json itself:

stored value returned by GET /api/v1/project-repositories
host=db password=hunter2 dbname=x host=db password=hunter2 dbname=x
https://github.com/o/r.git?pass=hunter2 https://github.com/o/r.git?pass=hunter2
https://github.com/o/r.git?sslpassword=hunter2 unchanged
host=db sslpassword=hunter2 unchanged

The adapter's redactor handles all four ('host=db <redacted> dbname=x', '…?pass=<redacted>', …). So a legacy row in any of those shapes is handed verbatim to every member of the project — which is the precise failure the docstring on that function claims to close. ?pass= is missing from SECRET_PARAMETER_KEYS as well, so § 3.5's own boundary has the query half of it too.

The repair is to share ONE vocabulary rather than keep two: the conninfo forms and pass belong in the declared key list, and the two redactors should differ only in how much they over-redact, not in what they can SEE. It is a change to a shared predicate on both branches, and it is a credential exposure, so it goes to the holder before it goes to a commit.

Registered, not taken — src/opendox/runtime/local_git_adapter.py:465

FACT: made is false for a component this walk did not create, so a pre-existing OPENDOX_PROJECT_REPOSITORY_ROOT keeps the mode runtime init gave it — Path.mkdir(..., exist_ok=True) under the ambient umask, world-writable at umask 000, while each project directory under it is forced to 0700. Not BLOCKING in the shipped shape (uid 10001, private PVC, no second local user — the boundary A26-5 was decided against), and not one of the three items the holder ruled into this batch. Answered on its own thread.

Taken in this batch

local_git_adapter.py:685 — the bound bounded git and not the push. Measured at 555a03c8 with a planted slow descendant: 30.0 seconds for a 0.6-second bound, plus the descendant finishing the remote write behind the refusal. Fixed at bddb4145; two cases, one for the behaviour and one for the mechanism.

validate and runtime are green at ef8612ad.

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

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

Five unresolved findings remain, including one critical issue and four moderate issues.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

src/opendox/runtime/app.py:1082

  • The API boundary still calls config.redacted_remote_url, but that redactor only covers URL/scp userinfo and query credentials. A legacy row such as host=db password=hunter2 is handled by local_git_adapter.redact_remote_url yet is returned verbatim by the project-repository GET/list responses (and by the attach response through _repository_json), leaking the password to members. Extend the boundary redactor to the full legacy-remote vocabulary, while preserving the deliberate non-redaction of ordinary SSH usernames, and add an API case for this shape.
    `config.redacted_remote_url` AND NOT `local_git_adapter.redact_remote_url`,
    deliberately: the general redactor is written for git's stderr, where
    over-redacting is the safe direction, and its widened scp branch replaces
    the userinfo of an ordinary `git@github.com:o/r.git` — a USERNAME, not a
    secret. The config one is the pair of `credential_in_a_remote_url` and
    changes nothing that predicate calls clean, so an ordinary remote comes
    back exactly as stored and the column stays readable for what it is for.
  • Files reviewed: 36/43 changed files
  • Comments generated: 1
  • Review effort level: Lite

brettheap and others added 3 commits September 18, 2026 18:19
…-repository-act

#25 landed SQUASHED (`aca94ecb` has one parent), so main's copies of every
§ 3.5 file share no ancestry with this branch's — git reported ten ADD/ADD
conflicts for files this branch already carried by merge. Every one is
resolved to THIS branch's version, and that is a measurement rather than a
preference: for each conflicted file the question asked was "does main have
anything this branch lacks", and the answer was no in all ten.

  * `.github/workflows/validate.yml` — compared STRUCTURALLY, not by line:
    both trees parse to the same two jobs with the same step names, and the
    only difference in any step's `run` is the one that must differ — this
    branch's hermetic step names SIX modules because
    `tests_runtime/test_local_git_adapter.py` arrives with § 3.6. The
    remaining textual difference is the figure block's own history, which this
    branch already carries relabelled ("carried by merge").
  * Every `.py` file — compared by AST over its top-level definitions. Two
    names existed only on main and both are accounted for: `client` MOVED to
    `tests_runtime/conftest.py` on this branch (beside
    `client_with_repositories`), and
    `test_the_verb_set_is_closed_and_the_parser_declares_exactly_it` was
    RENAMED to `..._the_runtime_verb_set_...` with a sibling for
    `PROJECT_VERBS`. Nothing is dropped.
  * `identity.repository_for_project` differs only by § 3.6's `for_update`
    row lock, and `docs/runtime.md`'s module list by § 3.6's two modules.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A credential exposure this branch's own merge introduced, fixed on Brett
Heap's word (~18:2xZ): a regression is not a finding to register.

`bb450614` pointed `app._repository_json` at `config.redacted_remote_url`
instead of `local_git_adapter.redact_remote_url`, for a real reason — the
general redactor replaces the userinfo of an ordinary `git@github.com:o/r.git`,
which is a username and not a secret. But `config`'s redactor was written for
BROKER URLs and a `remote_url` is free text, so it knew neither the libpq
keyword/value form nor the parameter name `pass`. MEASURED through
`app._repository_json` at `555a03c8`, all four returned VERBATIM to every
member of the project:

    host=db password=hunter2 dbname=x
    https://github.com/o/r.git?pass=hunter2
    https://github.com/o/r.git?sslpassword=hunter2
    host=db sslpassword=hunter2

ONE DECLARATION AND TWO READINGS NOW. `config.SECRET_PARAMETER_KEYS` is the
list — `pass` joins it — and `local_git_adapter.SECRET_PARAMETER_KEYS` is
BUILT from it (`"|".join(...)`), so the two cannot drift again.
`config.LIBPQ_PASSWORD` is the one keyword/value pattern and the adapter's
`_LIBPQ_PASSWORD` IS that object; it lives in `config` because that is the
module the adapter can import — the API has no business pulling the adapter
into its import graph to redact a string.

The two readings differ ON PURPOSE and only in one direction. The adapter asks
the list as a plain alternation with `.search()`, so it matches every name
`config` matches and more (`monkey` among them): it cleans git's stderr and a
push refusal, where over-redacting costs a word of diagnostic. `config` asks
it whole-word, with a substring rule for the needles too long to collide by
accident (six characters: `password`, `secret`, `token`, `credential`,
`signature`, `apikey`, …) — which is what now answers `sslpassword` — because
it also answers a CONFIGURATION boundary, where over-refusing costs an install
that will not start for a reason that is not true.

Two cases. The DB-backed one drives all four shapes through the REAL map
endpoints, because the defect was in WHICH redactor the boundary called and a
case that asked the redactor directly would have passed throughout; it also
asserts the host survives and that an ordinary `ssh://git@host/…` comes back
exactly as stored. The hermetic one states the property over a corpus of
thirteen carriers and six innocent values: whatever `config` hides, the
adapter hides — the reverse is the defect — plus every declared name hidden by
both, and the two structural identities (`"|".join` and `is`).

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`2714f6b1` is the commit that was measured: 346 passed 1 skipped on the
required job's own six modules with the runtime extra unimportable, and 555 on
`pytest -q tests_runtime/` with a database. The PR description states the same
two numbers at the same commit.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

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

Unresolved critical redaction issues and moderate descriptor-cleanup issues remain.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 11/15 changed files
  • Comments generated: 3
  • Review effort level: Lite

Comment thread src/opendox/runtime/config.py Resolved
Comment thread src/opendox/runtime/config.py Resolved
@brettheap

Copy link
Copy Markdown
Contributor Author

Read at the landed-candidate head fe421882 — FOUR findings, all measured, all HELD

validate and runtime are green at fe421882. The review at that head (18:35:45Z) generated three comments and one from ef8612ad is still open. Three of the four are credential exposure and one is a refusal bypass, all in code this batch wrote — so under the standing instruction they are reported and NOT touched. Nothing is pushed.

Every line below is measured on the current head, not argued.

shape config hides? adapter hides? what the API returns
https://host/r.git?%2574oken=hunter2 no yes verbatim — leaks
user:sec\nret@host:path no yes verbatim — leaks
https://host/x?mode=1;token=hunter2 yes no redacted
https://host/r.git?%74oken=hunter2 yes yes ?%74oken=<redacted>

1. config.py:509 — a DOUBLE-ENCODED parameter name (credential exposure)

CONFIRMED. config's query reading decodes the name ONCE, so %2574oken stays %74oken and is not token; the adapter decodes to a FIXED POINT and catches it. app._repository_json returns the row verbatim. The remedy is the reviewer's: the boundary must use the same fixed-point decode, which is a function the adapter already has.

2. config.py:509 — an scp credential containing a NEWLINE (credential exposure)

CONFIRMED, and it is the direct cost of a decision I made two commits ago: _scp_like_userinfo refuses any candidate containing whitespace, so that widening the scp rule "cannot start eating prose". A legacy row user:sec\nret@host:path is therefore called clean and returned unchanged. New attachments refuse control characters, but legacy rows are exactly what this boundary exists for. The remedy the reviewer names — detect a control-bearing value and redact it WHOLE before the shape-specific rules, as local_git_adapter.redact_remote_url does — keeps both properties.

3. local_git_adapter.py:935 — ; is a parameter delimiter to one reading and not the other

CONFIRMED, and this is the disagreement direction my own new property test asserts cannot happen: config hides ?mode=1;token=hunter2 and the adapter does not. My corpus simply had no ; case, so the test passed while the property was false — worth saying plainly, because a property test that names the property and then under-samples it is the weaker half of this batch. Measured consequence beyond the redaction: the act's pre-check (lga.carries_a_credential) answers False, the store's refusal (built on config) answers True, so an attach of that shape raises RefusedError where the API surfaces a 500 instead of a named refusal. One delimiter class in both, and the corpus grows a ; entry.

4. local_git_adapter.py:668 — the process-group kill can miss the group (refusal bypass)

CONFIRMED in substance, with one correction to the mechanism. On the overflow path a reader thread calls _stop_the_whole_group while the main thread may already have reaped the child; measured on CPython 3.12: os.getpgid(pid) after reaping raises ProcessLookupError, which my except swallows — so the group is never signalled and a descendant survives the refusal. That is the finding and it is right. What is NOT right is the rest of the sentence: Popen.kill() after reaping does not raise — CPython suppresses it deliberately (bpo-40550, and send_signal polls first precisely to avoid signalling a RECYCLED pid). The recycling risk is the sharper form of the same argument and cuts the same way: os.getpgid(child.pid) on a reaped pid could name an unrelated process's group, and killpg would SIGKILL it. Capturing the pgid immediately after Popen and making both terminations best-effort against that saved id closes both.

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

brettheap and others added 2 commits September 18, 2026 20:26
TWO IMPLEMENTATIONS READING ONE LIST STILL DISAGREED. The previous commit gave
`config` and `local_git_adapter` one declared key list and one libpq pattern,
and a property case asserted they never disagreed about what to hide. It passed
while they disagreed three times, because its corpus held none of the three
shapes (Copilot review at `fe421882`; each measured against a full checkout of
that head, not against this tree with a path override):

  * `?%2574oken=…` — `config` decoded a parameter name ONCE and the adapter to
    a fixed point, so `GET /api/v1/project-repositories/{id}` answered 200 with
    the token in the clear;
  * `user:sec<newline>ret@host:path` — `config` declines to judge a value
    holding whitespace, so the same endpoint returned the whole legacy value;
  * `…?mode=1;token=…` — `;` was a delimiter to `config` and NOT to the
    adapter. That one ran the other way and cost more than a leak here:
    `carries_a_credential` is the adapter's redactor asked as a predicate, so
    it answered False, `repository_act.attach_remote` ACCEPTED the value, and
    `identity.CoordinationStore` refused it with a `RefusedError` the route
    does not catch — a 500 where a 409 belonged.

SO THERE IS ONE REDACTOR. `config.redacted_remote_url` is a call into
`local_git_adapter.redact_remote_url`; the one nuance the API boundary needs —
that an ordinary `ssh://git@host/…` keeps its USERNAME, which is not a secret —
is an argument to that function rather than a second implementation of it. `;`
joins both delimiter classes, which is the 500's fix as well: the act's
pre-check and the store's refusal read the same tail, so the attach is a 409
naming the shape. Agreement is true by construction now, and the property case
stays as the guard that it REMAINS a call, with the three shapes in its corpus
and the remaining two readings — the store's refusal and the redaction — held
to the one direction that cannot leak.

AND A FOURTH SHAPE NEITHER READING SAW: whitespace INSIDE an authority.
`user:pa ss@host:path` is excluded by the refusal's class (so it cannot start
judging prose) and by `_CREDENTIAL_SHAPED`'s (so an unrelated `user@host` three
lines down git's stderr is not joined to the URL above it) — and it came back
from the map endpoints entire, measured at `fe421882`. Closed at the ONE-URL
entry point, where the caller knows it holds one value and not a page of text:
`redact_remote_url` replaces a whitespace-bearing authority WHOLE, exactly as
it already does a control-bearing one. `redact_credentials` is untouched, so
the diagnostic reading keeps its lines, and a local path with a space in it has
no `user:…@` head and is unaffected. No writer can make such a row —
`repository_act.refuse_credential_bearing_remote` refuses the shape at every
one, measured — so the value is legacy by construction, which is what this
boundary exists for.

THE GROUP IS KILLED BY THE ID IT WAS BORN WITH. `_stop_the_whole_group` asked
`os.getpgid(child.pid)` at kill time; on the output-overflow path a reader
thread reaches it while the main thread may already have returned from
`child.wait`, and MEASURED on CPython 3.12 `os.getpgid` on a reaped pid raises
`ProcessLookupError` — so the descendants of a reaped child would have outlived
the refusal, which is the whole point of killing the group. The pgid is
captured immediately after `Popen` now and passed to the stopper. The new case
reaps the child FIRST, asserts that the lookup then raises, and still finds the
descendant dead and its marker absent.

REGISTERED, NOT BUILT — follow-ups under the same claim:
  * `identity.CoordinationStore`'s guard does not name a whitespace-bearing scp
    authority either (`config._scp_like_userinfo` declines it), so a raw-SQL
    writer can still create the row this commit redacts. § 3.5 has landed;
    widening a landed refusal is its own act, and the act layer already refuses
    the shape at every writer that goes through it.
  * `OPENDOX_SERVED_DATABASE`: the served DATABASE has no non-secret
    declaration, only the served schema.
  * SonarCloud S8544 on this branch: pin the dependencies at
    `.github/workflows/validate.yml:1195` and `deploy/compose/Dockerfile:44`.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`7977d91e` is the commit that was measured: 347 passed 1 skipped on the
required job's own six modules with the runtime extra unimportable, and 556 on
`pytest -q tests_runtime/` with a database. The PR description states the same
two numbers at the same commit.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@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, your pull request is larger than the review limit of 150,000 diff characters

One is this batch's own (the case that reaps before signalling uses the saved
id and never names a signal itself), and one arrived with the bounded-group
case at `bddb414` and has been flagged since — the PR description's `pyflakes`
row said clean over `src/opendox/runtime/*.py tests_runtime/*.py` while that
invocation reported it, which is a figure stated and not re-measured.

NO CASE IS ADDED OR REMOVED, so the figures the entry above records are
unchanged and re-measured at this head rather than assumed: 347 passed 1
skipped on the required job's six modules, 556 on `pytest -q tests_runtime/`.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

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

Unresolved moderate findings remain in the local Git adapter and repository-act paths, and the workflow’s recorded figure does not match the PR description.

Get a fresh assessment by requesting another Copilot review.

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

Comment thread .github/workflows/validate.yml Resolved

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

Unresolved critical and moderate findings affect write-target integrity and resource usage.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

src/opendox/runtime/config.py:506

  • This delegation sends every legacy remote_url directly through _decoded_parameter_name(), whose fixed-point loop performs a full unquote_plus pass up to len(name)+1 times. Unlike new attachments, rows restored or written through SQL are not subject to MAX_REMOTE_URL_CHARS, so a large nested-percent parameter can make every repository-map response do quadratic CPU work. Bound the legacy redaction before delegation (for example, return the whole-value marker above a safe size) or otherwise cap the decoder.
    if not value:
        return value
    from opendox.runtime.local_git_adapter import redact_remote_url

    return redact_remote_url(value)
  • Files reviewed: 11/15 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +2061 to +2062
git_dir = Path(decoded_path(
git.out("rev-parse", "--absolute-git-dir")))
brettheap and others added 2 commits September 18, 2026 21:06
… no refusal

MY OWN REGRESSION, from the commit two back, and the review at `4156f233`
found it (suppressed there, and correct). `_decoded_parameter_name` decodes a
parameter name to a fixed point — quadratic in that name by construction — and
its docstring named `repository_act`'s length refusal as what keeps it safe.
That was true while every path to it came through that refusal. Pointing
`config.redacted_remote_url` at `redact_remote_url` added one that does not: a
legacy `project_repositories.remote_url` row is a restore, an older build or
`psql`, and it passed no refusal at any time — so the work ran on EVERY read of
the map endpoints, once per row, for as long as the row exists.

MEASURED against a full checkout of `4156f233`, with the decoder instrumented
so the call is observed and not inferred: one call, and

     9 KB of `%2525…`  ->   0.08 s
    60 KB              ->   2.65 s
   180 KB              ->  21.31 s

of CPU per redaction — and `_repository_json` redacts on every list and every
read. `remote_url` is `text`; nothing caps a row written around the store,
which is the row this boundary exists for.

ONE DECLARATION FOR BOTH READINGS. `MAX_REMOTE_URL_CHARS` moves to `config` —
the module both readers import, and where the branch already put the key list
and the libpq pattern for the same reason — and `repository_act` keeps the name
by alias, so its refusal message and its cases are untouched. The act refuses a
NEW remote longer than it; `redact_remote_url` replaces a STORED one longer
than it WHOLE, which is what a value that cannot be read as one URL already
gets. A remote the act ACCEPTS is therefore never over-redacted by the boundary
that prints it, and the two numbers cannot drift apart.

The case asserts the bound BY SUBSTITUTION rather than by a clock: it makes
`_decoded_parameter_name` raise, so reaching it at all fails and
short-circuiting is the only way to pass; then it removes the substitute and
drives a value AT the cap through the real decoder, because over-refusing is
the other way to get this wrong. It also holds the declaration by identity
across `config`, the act and this module.

REGISTERED, NOT TAKEN, from the same review: `write_back` turns
`rev-parse --absolute-git-dir` back into a PATHNAME for `GIT_INDEX_FILE` while
the object and ref work stays bound to a held descriptor, so a rename or
replacement between the probe and the index operations puts the temporary index
in the replacement. It is § 3.6 code this batch does not touch, it is the
TOCTOU family two earlier rounds already worked, and it needs the same
descriptor-held treatment the destination check got — its own act.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`727b4769` is the commit that was measured: 348 passed 1 skipped on the
required job's own six modules with the runtime extra unimportable, and 557 on
`pytest -q tests_runtime/` with a database. The PR description is edited to the
same commit and the same two numbers in this act, which is the ordering the
round at `0a2af8b8` asked for: the description 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 named twice on this PR.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@brettheap

Copy link
Copy Markdown
Contributor Author

Review at 4156f233 — one TAKEN, one REGISTERED

TAKEN — the quadratic decoder's new caller passes no refusal (suppressed comment on config.py:506, and correct). It is this batch's own regression, which is the line the holder drew: a finding about landed code is registered, a fault the branch just introduced is repaired.

_decoded_parameter_name decodes a parameter name to a fixed point — quadratic in that name by construction — and its docstring named repository_act's length refusal as what keeps it safe. True while every path came through that refusal. Pointing config.redacted_remote_url at redact_remote_url added one that does not: a legacy project_repositories.remote_url row is a restore, an older build or psql, and it passed no refusal at any time.

Measured against a full checkout of 4156f233, with the decoder instrumented so the call is observed rather than inferred — one call, on a name of the whole chain's length:

a legacy remote_url of CPU per redaction
9 KB of %2525… 0.08 s
60 KB 2.65 s
180 KB 21.31 s

_repository_json redacts on every list and every read, once per row, for as long as the row exists; remote_url is text and nothing caps a row written around the store.

MAX_REMOTE_URL_CHARS moves to config — the module both readers import, where this branch already put the key list and the libpq pattern for the same reason — and repository_act keeps the name by alias, so its refusal message and its cases are untouched. The act refuses a new remote longer than it; redact_remote_url replaces a stored one longer than it whole. A remote the act accepts is therefore never over-redacted by the boundary that prints it, and the two numbers cannot drift. The case asserts it by substitution rather than by a clock — the decoder is made to raise, so reaching it at all fails — then removes the substitute and drives a value at the cap through the real decoder, because over-refusing is the other way to get this wrong. 727b4769.

REGISTERED — write_back reuses a pathname where the rest of the act holds a descriptor (local_git_adapter.py:2062). rev-parse --absolute-git-dir is turned back into a path for GIT_INDEX_FILE while the object and ref work stays bound to the inherited directory descriptor, so a rename or replacement between the probe and the index operations puts the temporary index — and its cleanup — in the replacement. It is § 3.6 code this batch does not touch, it is the TOCTOU family two earlier rounds already worked (_refuse_a_destination_this_service_owns, the O_NOFOLLOW walk), and the repair is the one they took: keep the index directory tied to a held descriptor. Registered in the PR description as its own act, not folded into a batch whose scope the holder set.

Also registered this round, both in the description's follow-up block: the store's own guard does not name a whitespace-bearing scp authority (config._scp_like_userinfo declines a head holding whitespace) — no writer reachable from the API or the CLI can make such a row, and the map endpoints now redact it whole, so what remains is a raw-SQL writer against a landed § 3.5; and SonarCloud S8544, the unpinned dependencies at .github/workflows/validate.yml:1195 and deploy/compose/Dockerfile:44, which is the advisory quality-gate failure on this PR.

And the figure round is answered by ordering, not by a number. The description is now edited in the same act that records the workflow figure, so the two cannot lag each other again. Both name 727b4769: 348 passed, 1 skipped hermetic and 557 passed on pytest -q tests_runtime/. validate and runtime are green at db5197d0.

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

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.

🔵 Needs a closer look

Three moderate findings remain: two concurrent map-row races can produce 500s, and credential matching can reject valid parameter names.

Review details

Suppressed comments (3)

src/opendox/runtime/app.py:825

  • The _found preflight is not atomic with the act. If the map row is deleted after this read, _local_git_row() inside attach_remote() raises identity.NotFoundError; this handler catches only RepositoryActRefused, so the normal disappeared-row race becomes a 500 instead of the existing 404 translation. Wrap the act call in _found (or catch and translate NotFoundError) rather than relying on the pre-check.
        row = repository_act.attach_remote(store, project_id=project_id,
                                           remote_url=body.remote_url)

src/opendox/runtime/app.py:843

  • As with attach, the earlier _found read can succeed and the map row can disappear before push_to_remote() locks it. That act then raises identity.NotFoundError, which this route does not translate, yielding a 500 for a repository that is simply no longer mapped. Wrap this invocation with _found (or handle NotFoundError) so the route preserves its 404 behavior under concurrent map changes.
        remote_url = repository_act.push_to_remote(store, project_id=project_id)

src/opendox/runtime/config.py:328

  • This substring check reintroduces false refusals for otherwise valid parameter names such as passwordless, secretary, or credentials_version: credential_in_a_remote_url() feeds this predicate into the broker/remote admission path, so those URLs are rejected even though the parameter is not one of the declared credential names. Keep the configuration-side check word-bounded and add only explicitly supported compounds (for example sslpassword) instead of treating every long needle as a substring.
    if any(needle in spaced for needle in _LONG_SECRET_NEEDLES):
        return True
  • Files reviewed: 11/15 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap

Copy link
Copy Markdown
Contributor Author

Review at db5197d0 — three suppressed findings, all REGISTERED, none taken

Zero new inline comments. Three suppressed, and I measured each rather than classifying it from the text. All three are registered, not taken: none is data loss, a credential exposure or a refusal bypass, which is the line the holder set for interrupting a bounded batch.

1 & 2 — app.py:825 and app.py:843: the _found pre-check is not atomic with the act. TRUE, measured by reading the one translation path. There is no app-level handler for identity.NotFoundError; _found is the translation and it is applied per call site. attach_project_remote and push_project_repository both pre-check with _found(lambda: store.repository_for_project(...)) and then call the act outside it, so a map row deleted in that window makes _local_git_row's NotFoundError escape as a 500 where the documented coordination 404 belongs. This is the same class as openDox-code#25's round 10 on the draft-discard path, which was taken there and is quoted in this file at app.py:1031 — so the repair is already written down: wrap the act call in _found, do not lean on the pre-check. Two lines and two cases; a separate act because this batch's scope was set at the redactor and the process group.

3 — config.py:328: the long-needle substring rule refuses valid names. TRUE, measured:

parameter name names_a_secret_parameter what the store does
passwordless True refuses the URL
secretary True refuses the URL
credentials_version True refuses the URL
passage, tokenizer, authority False accepts

The rule exists because sslpassword must be caught and a whole-word reading misses it; the cost is every other compound of a six-character needle. It is fail-closed — an over-refusal, never an acceptance — which is why it is registered rather than repaired mid-batch: a URL is refused with the shape named and the caller can re-send it, where the opposite direction would store a credential. The direction the review recommends (word-bounded plus explicitly supported compounds, sslpassword first) is the right shape and is recorded as its own act, because narrowing a refusal is exactly the change that wants its own corpus and its own review.

Registered on this PR, all now in the description's follow-up block

  1. app.py attach and push: _found around the act, not only the pre-check (this review).
  2. config.names_a_secret_parameter: word-bounded plus declared compounds (this review).
  3. write_back reuses a pathname where the act holds a descriptor (4156f233).
  4. The store's guard does not name a whitespace-bearing scp authority — no reachable writer can make the row, and the map endpoints redact it whole.
  5. OPENDOX_SERVED_DATABASE, the served database's non-secret declaration.
  6. SonarCloud S8544, the unpinned dependencies at .github/workflows/validate.yml:1195 and deploy/compose/Dockerfile:44.

validate and runtime are green at db5197d0. The figure and the description name the same commit, 727b4769: 348 passed, 1 skipped hermetic, 557 passed on pytest -q tests_runtime/.

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

@brettheap

Copy link
Copy Markdown
Contributor Author

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

LANDED — lane openxfactory-4, 2026-09-18T21:20:29Z, PR #26 → 4f8ae01 (opensoft/openDox-code main; plain gate)

§ 3.6 repository act: local git adapter + attach/push boundary; adversarial rounds A26-1..5, batches 1–3 (process-group kill with saved pgid), one shared credential redactor at the boundary (conninfo, pass, ;-delimiter, control/whitespace-bearing authorities), quadratic-decoder bound; follow-ups registered on the PR

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