Repository navigation
§ 3.6 follow-up #2: a linked worktree's metadata, and a store refusal that is a refusal - #32
Conversation
Follow-up #2 to openDox-code#30, which registered these four and took none of them: the holder ruled the first, and the other three come from that PR's own review threads. Every measurement is against a full checkout of `5c867137`. 1. A LINKED WORKTREE IS THE THIRD SHAPE, AND THE BINDING DID NOT REACH IT. `-C /proc/self/fd/<n>` binds the working directory, and for the two shapes this act creates that IS the repository — a bare repository is its own git directory, a checkout's is `.git` inside it — so `rev-parse --git-dir` answers a relative name and the index joins onto the held root. A linked worktree is neither: measured on git 2.43.0, `<worktree>/.git` is a FILE naming an absolute path, `--git-dir` answers `<main>/.git/worktrees/<name>` (which holds the INDEX and neither `objects/` nor `refs/`), and those live in the COMMON directory. `resolve` serves that shape WRITABLE, with a case landed since § 3.6, so the pathname branch was live for a supported corpus. RULED: bind both directories by descriptor and keep linked worktrees writable — taking the write away reverses what § 3.6 landed with its own case. `metadata_held_open` opens the two `O_NOFOLLOW` and names them `GIT_DIR` and `GIT_COMMON_DIR` as `/proc/self/fd/<n>`, inherited by every call; MEASURED end to end, the whole write sequence behaves as it does without them, the commit lands on the worktree's own branch and the main branch is untouched. What the case does NOT do is rename the git directory under a running write, and that is recorded rather than left as an absence: git enumerates worktrees through `<common>/worktrees/<name>` to decide whether a branch is checked out elsewhere, so re-pointing that name mid-write makes `update-ref` refuse — git's own bookkeeping, through a name no descriptor of ours binds. The binding property is asserted where it lives: on the descriptors. 2. A STORE REFUSAL IS A REFUSAL, NOT A CRASH. `repository_act` refuses a credential-bearing remote and so does `identity.CoordinationStore` — layering, and the two readings are deliberately not identical. Nothing translated the store's: `app.py` caught `RepositoryActRefused` and nothing else, so a value ONE refuses and the other accepts left the route as an unhandled exception, which FastAPI answers 500. It has happened twice, and both times it was closed one shape at a time — `…?mode=1;token=…` on openDox-code#26, and `/srv/repos/a:b@c.git`, MEASURED a 500 at `5c867137`. `except identity.RefusedError` on the three routes that call an act writing through the store closes the class instead of the instance. 3. A LOCAL PATH IS NOT AN AUTHORITY. The whitespace fallback #30 added — for `user:pa ss@host:path`, which both classes excluded — read the whole head before the last `@`, so `/srv/my repos/a:b@c.git`, a directory whose name holds a colon and an at-sign and a legal `git push` destination, was refused by the store AND replaced with `<redacted-url>` by the printer. GIT'S OWN RULE is the test and it is about the FIRST colon: the `[user@]host:path` form is recognised only when nothing before it is a `/`. That separates the two cases exactly, which is why it is this rule and not "a head holding any slash" — `ci:hun/ter2@github.com:o/r.git` is openDox-code#25's password containing a slash, and `ci` is what precedes its first colon. Both halves of the pair take it, because both made the same misreading. 4. THE DATABASE GUARD'S OTHER TWO ACTS ARE MEASURED. `refuse_a_database_the_ api_will_not_read` is called from `apply()`, from `migrate --plan` and from `reset`, and only `apply()` had a case — "one line each and visible in the diff" is not a measurement. The new case is the schema guard's twin, and it PASSES against `5c867137`: it pins wiring that was untested, and it earns its place by what it catches later, which is exactly how the schema guard came to be missing from two of its three acts. Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…t raised it `f8cb7a90` is the commit that was measured: 359 passed 1 skipped on the required job's own six modules with the runtime extra unimportable, and 572 on `pytest -q tests_runtime/` with a database. The PR description states the same two numbers at the same commit, in this act. AND THE TRIPLE MOVES UP, because this branch adds to it. Measured at `f8cb7a90` across the required job's three reports — `tests/` 714 selected 2 skipped, the S7 residue 13, `tests_runtime/`'s hermetic six 360 selected 1 skipped — the triple is selected 1087, passed 1084, skipped 3. The floors go to 1087 and 1084; `EXPECT_SKIPPED` does not move, because no file turned into skips. Clause (d)'s floors are a RATCHET: an act that adds cases raises them, and an act that merely finds them low leaves them alone, so a number that later goes down is what it was always meant to be — a test that stopped being collected. Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Reviewer's GuideThe PR closes four follow-up findings by descriptor-binding linked worktree metadata during writes, translating store refusals to HTTP 409 responses, distinguishing local paths from credential-bearing authorities using Git’s first-colon rule, and adding migration/reset guard coverage; validation floors and records are updated to reflect the expanded test suite. Sequence diagram for descriptor-bound linked worktree writessequenceDiagram
participant Writer
participant GitRunner
participant Metadata as metadata_held_open
participant Git
participant Worktree
Writer->>Metadata: metadata_held_open(git)
Metadata->>Git: rev-parse --git-dir
Metadata->>Git: rev-parse --path-format=absolute --git-common-dir
Metadata->>Metadata: open_no_follow_chain(git_dir)
Metadata->>Metadata: open_no_follow_chain(common_dir)
Metadata-->>GitRunner: GitRunner with GIT_DIR and GIT_COMMON_DIR
Writer->>Git: hash-object -w
Writer->>Git: read-tree / update-index / write-tree
Writer->>Git: commit-tree
Writer->>Git: update-ref
Git-->>Worktree: Commit worktree branch
Git-->>Worktree: Keep main branch untouched
Sequence diagram for translating store refusals to HTTP 409sequenceDiagram
actor Client
participant API
participant Act as repository_act
participant Store as CoordinationStore
Client->>API: create, attach, or push repository
API->>Act: repository operation
Act->>Store: write through store
Store-->>Act: identity.RefusedError
Act-->>API: identity.RefusedError
API-->>Client: HTTP 409 repository.refused
Sequence diagram for migration and reset database guard coveragesequenceDiagram
participant Operator
participant CLI
participant Guard as refuse_a_database_the_api_will_not_read
participant Database
Operator->>CLI: runtime migrate --plan or runtime reset
CLI->>Guard: refuse_a_database_the_api_will_not_read
Guard->>Database: Check coordination table
alt Database declaration disagrees
Guard-->>CLI: Refusal
CLI-->>Operator: Refuse operation
else Declaration agrees
Guard-->>CLI: Allow operation
CLI->>Database: Execute migration or reset
end
Flow diagram for authority versus local-path detectionflowchart TD
Input[Remote value with whitespace before last @] --> Head[Extract text before last @]
Head --> Colon{Head contains a colon?}
Colon -->|No| Local[Do not classify as authority]
Colon -->|Yes| FirstColon[Inspect text before first colon]
FirstColon --> Slash{Contains /?}
Slash -->|Yes| Local
Slash -->|No| Authority[Classify as credential-bearing authority]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Metadata acquisition errors can escape without the declared refusal translation.
Review effort: Lite
Findings: None
What changed in this PR
Hardens linked-worktree writes, refusal handling, remote URL validation, and migration safety checks.
Changes:
- Binds linked-worktree metadata through descriptors.
- Converts store refusals to HTTP 409 responses.
- Adds regression coverage and updates CI test floors.
| File | Description |
|---|---|
tests_runtime/test_migrations_apply.py |
Migration/reset guard coverage |
tests_runtime/test_local_git_adapter.py |
Worktree and URL regression tests |
tests_runtime/test_api_endpoints.py |
Refusal response coverage |
src/opendox/runtime/local_git_adapter.py |
Descriptor-bound writes and URL classification |
src/opendox/runtime/config.py |
Local-path-aware authority detection |
src/opendox/runtime/app.py |
Store refusal translation |
.github/workflows/validate.yml |
Updated validation floors |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… build/3-7-followup-2-worktree-and-refusals ONE CONFLICT, in the triple's floors, and it is resolved to MAIN'S SIDE: #31 re-pinned them three times as it measured — 1084/1081, then 1090 over the merged #30 (closing a nine-test slack #30 had left), then 1093 for its own hardening cases and the `init.templateDir` one — and those are the true floors at `93ccc3dd`. This branch's own move, which was measured before any of #31's tests existed, is DISCARDED here and re-measured on the merged tree in the next commit. A floor is a measurement, not an arithmetic. Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`d6cb2621` — this branch with openDox-code#31 merged in — is the tree that was
measured, by running the three invocations the required job runs and summing
their JUnit reports:
tests/ (29 files, #31's conformance corpus among them) 725 selected, 2 skipped
the S7 residue 13 selected
the hermetic six 360 selected, 1 skipped
------------------------------------------------------------------------
TRIPLE selected 1098, passed 1095, skipped 3
So `MIN_SELECTED` goes 1096 -> 1098 and `MIN_PASSED` 1093 -> 1095. The two are
this branch's own hermetic cases; its other two are in the DB-backed job, which
this triple does not count. `EXPECT_SKIPPED` does not move: no file turned into
skips, which is the thing that number exists to catch.
1096 + 2 = 1098 is a CHECK on the reading, not its source — the rule #31 wrote
into this block when it moved the floors three times, and the reason the merge
commit discarded this branch's earlier floors rather than adding to them: they
were measured before any of #31's tests existed.
The hermetic figure is re-stated at this head for the same reason. It did not
move — 359 passed, 1 skipped — but the TREE did, and a figure that was not
taken on the tree it is stated for is a figure nobody measured.
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 4 days and 5 hours by commenting @sourcery-ai review. Upgrade to get a review now.
… be held
MY OWN REGRESSION, from the commit that bound a linked worktree's metadata, and
the review at `97a1b37e` found it. `write_back` declares exactly two kinds —
`CORPUS_READ_ONLY` and `WRITE_PATH_UNREACHABLE` — and a caller may branch on
`err.refusal.kind`. Entering `metadata_held_open` at the `with` statement put
its work OUTSIDE `_write_back_bound`'s handler, and one of those calls had been
INSIDE it: the `rev-parse --git-dir` that used to be a single line computing
`named_git_dir`. MEASURED at `97a1b37e` with the real adapter, both raw:
open_no_follow_chain fails on the worktree's gitdir -> FileNotFoundError
rev-parse --git-dir fails -> GitCommandFailed
The second is the wider half and the review did not reach it: that probe runs
for EVERY shape, so an ordinary bare repository or checkout could leak it too —
this branch regressed the promise on the common path, which is the same class
its own item 2 closes at the API boundary.
THE TRANSLATION BELONGS TO THE HELPER, because the helper owns both the probes
and the opens: it catches `GitCommandFailed`, `OSError` and `RuntimeError`
(`Path.resolve`'s symlink loop raises the last, which is why the root probe
catches it too), closes any descriptor it had already taken, and refuses with
`WRITE_PATH_UNREACHABLE` naming the failure CLASS and not git's stderr — a
refusal that quotes a message writes it into whatever reports the refusal. The
subject comes from the caller, so the refusal names the write path the caller
asked about.
One case, both rows, and the probe row is driven on an ORDINARY repository
because that is where the wider half lived. It fails against `97a1b37e` with
the raw `GitCommandFailed` this commit removes.
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`acbb6d46` is the commit that was measured: 360 passed 1 skipped on the required job's own six modules with the runtime extra unimportable, and 573 on `pytest -q tests_runtime/` with a database. The PR description states the same two numbers at the same commit, in this act. The triple was re-run the same way over the same head — `tests/` 723 passed 2 skipped, the S7 residue 13, the hermetic six 360 passed 1 skipped — giving selected 1099, passed 1096, skipped 3, so the floors go to 1099 and 1096. One case added, one floor step; `EXPECT_SKIPPED` does not move. Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Lane: openxfactory-4 (openXfactory-4-openDox_extraction) LANDED — lane openxfactory-4, 2026-09-19T01:30:33Z, PR #32 → d816cf0 (opensoft/openDox-code main; plain gate) § 3.6 follow-up #2: linked-worktree metadata bound by descriptor (own gitdir + --git-common-dir, worktrees writable; RULED 5736683962), identity.RefusedError → 409 on create/attach/push, git's first-colon rule in refusal and printer, migrate --plan/reset mismatched-database cases; the regression item 1 introduced (raw exceptions escaping write_back) closed with WRITE_PATH_UNREACHABLE; triple 1099/1096/3 pinned |



Follow-up #2 to openDox-code#30: the four it registered and did not take
#30 landed with four findings registered, because its head was capped after the second push. This is the act that takes them. Each is measured against a full checkout of
5c867137— never withPYTHONPATH, for the reasondocs/runtime.md§ 8 now records.local_git_adapter.py:2124— ruled by the holderidentity.RefusedErrorwas translated nowhere, so a store refusal the act did not pre-empt was a 500config.py:584cli.py:8291. A linked worktree is the third shape, and the binding did not reach it
-C /proc/self/fd/<n>binds the working directory, and for the two shapes this act creates that is the repository — a bare repository is its own git directory, a checkout's is.gitinside it — sorev-parse --git-diranswers a relative name and the index joins onto the held root. A linked worktree is neither. Measured on git 2.43.0:<worktree>/.gitrev-parse --git-dir(through-C)<main>/.git/worktrees/<name>— absolute, holds the INDEX, holds neitherobjects/norrefs/rev-parse --path-format=absolute --git-common-dirobjects/andrefs/actually areresolveserves that shape writable, with a case landed since § 3.6, so the pathname branch was live for a supported corpus.Ruled by the holder on #30: bind both directories by descriptor and keep linked worktrees writable — making them read-only would reverse what § 3.6 landed with its own case.
metadata_held_openopens the twoO_NOFOLLOWand names themGIT_DIRandGIT_COMMON_DIRas/proc/self/fd/<n>, inherited by every call. Measured end to end before it was written:rev-parse,hash-object -w,read-tree,update-index,write-tree,commit-treeandupdate-refall behave as they do without them, the commit lands on the worktree's own branch, the main branch is untouched, and the temporary index lands inside the held git directory.What the case does not do, and why it says so. It does not rename the git directory under a running write: git enumerates worktrees through
<common>/worktrees/<name>to decide whether a branch is checked out elsewhere, so re-pointing that name mid-write makesupdate-refrefuse withcannot lock ref … unable to resolve reference— git's own bookkeeping, through a name no descriptor of ours binds, and nothing to do with this finding. An absence that is measured and written down is not the same as one nobody noticed.2. A store refusal is a refusal, not a crash — the class, not the instance
repository_actrefuses a credential-bearing remote and so doesidentity.CoordinationStore: layering, not duplication, and the two readings are deliberately not identical. Nothing translated the store's —app.pycaughtRepositoryActRefusedand nothing else — so a value one of them refuses and the other accepts left the route as an unhandled exception, which FastAPI answers 500.It has happened twice, and both times it was closed one shape at a time:
…?mode=1;token=…on #26, where the act accepted what the store refused, and/srv/repos/a:b@c.git, measured a 500 at5c867137(the new case reproduces it there as a rawidentity.RefusedError).except identity.RefusedError→ 409 on the three routes that call an act writing through the store ends the class: a refusal is a refusal, named by shape and never by value.3. A local path is not an authority
The whitespace fallback #30 added — for
user:pa ss@host:path, which both the refusal's class and the redactor's excluded — read the whole head before the last@. So/srv/my repos/a:b@c.git, a directory whose name holds a colon and an at-sign and a perfectly legalgit pushdestination, was refused by the store and replaced with<redacted-url>by the printer.Git's own rule is the test, and it is about the first colon: the
[user@]host:pathform is recognised only when nothing before that colon is a/. It separates the two cases exactly, which is why it is this rule and not "a head holding any slash"::ci:hun/ter2@github.com:o/r.gitci/srv/my repos/a:b@c.gitBoth halves of the pair take it, because both made the same misreading.
4. The database guard's other two acts are measured
refuse_a_database_the_api_will_not_readis called fromapply(), fromruntime migrate --planand fromruntime reset, and onlyapply()had a case — "one line each and visible in the diff" is not a measurement. The new case is the schema guard's twin: a real schema with a coordination table in it, a migration DSN that reaches this database, a declaration naming another, both verbs refusing with the table still there, and both going through once the declaration agrees.It passes against
5c867137, and the docstring says so rather than letting it read as a regression test: it pins wiring that was untested, and it earns its place by what it catches later — which is exactly how the schema guard came to be missing from two of its three acts.5. And the regression this PR's own item 1 introduced, closed here
write_backdeclares exactly two kinds —CORPUS_READ_ONLYandWRITE_PATH_UNREACHABLE— and a caller may branch onerr.refusal.kind; the module has been repaired for this before (round 13's_repository_root, which refused with a kind this operation does not declare). Enteringmetadata_held_openat thewithstatement put its work outside_write_back_bound's handler, and one of those calls had been inside it: therev-parse --git-dirthat used to be a single line computingnamed_git_dir. Measured at97a1b37ewith the real adapter, both raw:write_backopen_no_follow_chainon the worktree's git directoryFileNotFoundErrorrev-parse --git-dir— the probe itselfGitCommandFailedThe second row is the wider half and the review did not reach it: that probe runs for every shape, so an ordinary bare repository or checkout could leak it too — this branch regressed the promise on the common path, which is the same class item 2 above closes at the API boundary.
The translation belongs to the helper, because the helper owns both the probes and the opens: it catches
GitCommandFailed,OSErrorandRuntimeError(a symlink loop raises the last, which is why the root probe catches it), closes any descriptor it had already taken, and refuses withWRITE_PATH_UNREACHABLEnaming the failure class and not git's stderr. One case drives both rows, the probe row on an ordinary repository, and it fails against97a1b37ewith the rawGitCommandFailed.Measured (python 3.12.3, pytest 8.4.2, postgres 16.15, git 2.43.0)
Every figure was measured at
acbb6d46— this branch withorigin/mainmerged in (openDox-code#31, § 3.7's conformance factory; no rebase) — with theruntimeextra made UNIMPORTABLE and no ambient git configuration, and holds at the current headf8678ad, which adds only the workflow's record of it and the triple's floors. This description is edited in the same act as that record.validatejob's own invocation (--noconftest, the six hermetic modules)tests_runtime/test_local_git_adapter.pypython -m pytest -q tests_runtime/withOPENDOX_TEST_DATABASE_URLsetpython -m pyflakes src/opendox/runtime/*.py tests_runtime/*.pytests/725+2 skipped, S7 residue 13, hermetic six 361+1 skipped)The triple's floors move up with the cases that raised them —
MIN_SELECTED1096 → 1098 → 1099,MIN_PASSED1093 → 1095 → 1096,EXPECT_SKIPPEDunchanged at 3 because no file turned into skips. Clause (d)'s floors are a ratchet: an act that adds cases raises them, so a number that later goes down is what they exist to catch.And they were measured on the merged tree, not derived from it. This branch had moved them once already, to 1087/1084, measured before any of #31's tests existed; the merge discarded that side and took main's 1096/1093, and then the floors were moved again from a real run of the three invocations.
1096 + 2 = 1098is a check on the reading — the rule #31 wrote into that block when it moved the floors three times — and not its source.Three of the four new cases fail at
5c867137—'GitRunner' object has no attribute 'held_environment',/srv/my repos/a:b@c.gitrefused as an authority, and the rawidentity.RefusedErrorthat is the 500. The fourth is the coverage case above, which passes there by design.Sequencing
openDox-code#31 (§ 3.7, the conformance factory) landed first (
93ccc3dd), and this branch took it by merge (d6cb2621), never by rebase. The one conflict was the triple's floors and it is resolved to main's side, because #31 had re-pinned them three times as it measured and those are the true floors at93ccc3dd; this branch's own move was then re-made from a run over the merged tree. Nothing else in that file collided: #31 added a line to the first list, and this branch's hunks are the figure block and the floors.Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
🤖 Generated with Claude Code
Summary by Sourcery
Harden repository writes and refusal handling for linked worktrees, local paths, and database command safeguards.
New Features:
Bug Fixes:
Enhancements:
CI:
Tests: