Skip to content

§ 3.6 follow-ups: the seven findings #26 registered, each with its case - #30

Merged
brettheap merged 5 commits into
mainfrom
build/3-7-registered-follow-ups
Sep 18, 2026
Merged

brettheap merged 5 commits into
mainfrom
build/3-7-registered-follow-ups

Conversation

@brettheap

@brettheap brettheap commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

The seven follow-ups openDox-code#26 registered rather than took

§ 3.6 landed with seven findings registered, because each of its batches had a scope the holder set. This is the act that takes them, one commit, one case each.

Every measurement here was made against a full checkout of 4f8ae01e — never by pointing PYTHONPATH at an old tree. pyproject.toml sets [tool.pytest.ini_options] pythonpath = ["src"] and pytest prepends it, so a PYTHONPATH "old head" proof silently measures the new code and the case passes for nothing. That trap is now written down in docs/runtime.md § 8, "Proving a regression case against an older head", because it is the one that leaves a regression test in the suite that never saw the regression.

The seven, with where each came from

# finding origin
1 the served DATABASE has no non-secret declaration, only the served schema A25-3's half-closed finding, registered on #26 as ruled item 4
2 S8544 — installs resolve whatever the index offers on the day they run SonarCloud on #26 (advisory gate)
3 _found wraps the pre-check and not the act: a deleted row is a 500 Copilot on #26 at db5197d0, suppressed
4 the long-needle substring rule refuses passwordless, secretary Copilot on #26 at db5197d0, suppressed
5 write_back reuses a pathname where the act holds a descriptor Copilot on #26 at 4156f233
6 the store's guard cannot see a whitespace-bearing scp authority measured on #26 while closing the printing half; registered there
7 the repository root keeps runtime init's umask-derived mode registered on #26 as local_git_adapter.py:465; ruled "measure first"

1. OPENDOX_SERVED_DATABASE, and four manifest edits

A25-3's finding was that config._refuse_two_dsns_that_select_different_schemas can never fire in a shipped deployment: the Deployment holds the served DSN, the migration Job holds the migration one, and no workload holds both — so the migration container has to be told where the API reads. It was told the schema. It was not told the database, and that is the wider question: a schema comparison made in the wrong database compares two names that happen to agree, and dbname may be omitted from a DSN entirely, in which case libpq defaults it to the connection USER (measured for #25's two-DSN guard) — so two DSNs that look alike can select two databases without either one saying so.

The consequence is A25-3's, one level up: DDL and a ledger applied to a database nothing serves, or runtime reset dropping the six coordination tables of a database that was never this install's. That verb cannot be undone.

refuse_a_database_the_api_will_not_read compares the declaration with current_database() before the ledger is bootstrapped and before the schema guard — the wider question first, so the refusal names the database when both declarations are wrong — in all three acts: apply(), migrate --plan, reset. A name and never a credential, which is the whole reason a workload that must not hold the served DSN can be given it. Four manifest edits carry it: the configmap literal (pg_database=), the Job's env, compose's migrate service (from the same .env value the Postgres service creates), and .env.example.

2. S8544 — one measured dependency lock, read by all three installs

pyproject.toml declares what this package needs and deliberately does not pin it; a library that pins its dependents' versions cannot be installed beside anything. The other half was missing: the required job, the DB-backed job and the runtime image each resolved whatever the index offered on the day they ran, so the same commit tested twice is two different programs.

constraints-cpython312-linux.txt is the resolved set — generated in a clean venv on cpython 3.12 / linux, not written by hand, with the command to regenerate it in its own header — and it is passed with -c in all three places. A constraints file and not a requirements one: it pins what is installed and installs nothing, so the required job still installs .[test] alone and the FastAPI and psycopg entries simply do not apply there.

It sits at the repository root, and that is load-bearing: deploy/ holds the git-ignored .env that .dockerignore exists to keep out of the build context, so a lock living there would have meant a !deploy… re-inclusion — and the guard that no such rule exists is what keeps the filled-in .env at home.

3. _found around the act, not only the pre-check

Both repository routes read the map row with _found(...) and then call the act, which takes the row FOR UPDATE inside itself. A row deleted between those two statements raised identity.NotFoundError past a handler that catches only RepositoryActRefused — measured at 4f8ae01e as an uncaught exception, which is a 500 where this API documents 404. The same class as #25's round 10 on the draft-discard path, and the same repair: the translation belongs on the call that can raise it, not on a read taken beforehand.

4. A parameter name is judged by its words, plus one declared compound

Whole-word matching answered sslpassword — libpq's own keyword — as innocent, so the first repair made every declared needle of six characters or more a substring. That bought one true name at the price of every other compound of those words: measured, passwordless and secretary were refused as credential-bearing. A false refusal at a configuration boundary is not the safe direction — this predicate decides whether an install starts.

So the compound is declared, and there is exactly one this runtime meets. credentials_version stays refused on purpose: credentials is one of its words, and that same reading is what catches access_token, X-Api-Key and sessionToken — narrowing past it would mean comparing the whole name, which those three walk straight through.

5. The temporary index is written through the held descriptor

Every other call in write_back goes through -C /proc/self/fd/<n>, which is what makes "the check and the use are one object" true. GIT_INDEX_FILE was built from rev-parse --absolute-git-dir — a pathname. Measured on git 2.43.0, with the directory renamed away and a symlink to a second repository put in its place after the probe:

form where opendox-index-… landed
the absolute pathname the decoy
joined onto the held descriptor the real repository

--git-dir asked through -C answers relative — . for the bare repository this act creates, .git for a checkout, both measured — so joining it onto the runner's own root keeps the whole path, and the unlink that cleans it up, inside the descriptor. The case drives the swap from the probe itself and asserts both the mechanism (the index path is inside /proc/self/fd/) and the consequence (the decoy holds nothing, the real repository holds the commit); against 4f8ae01e it reports the absolute path.

6. The store names an authority it cannot read

_scp_like_userinfo declines a head holding whitespace so this rule cannot start judging prose, and the redactor's _CREDENTIAL_SHAPED excludes it so an unrelated user@host three lines down git's stderr is not joined to the URL above it — and user:pa ss@host:path sat between them: refused in its URL form, accepted in its scp form. #26 closed the printing half at the one-URL entry point; this closes the store's own guard, by shape and never by value, on _split_url's reasoning that a value this module cannot parse can still carry a credential. Nothing ordinary is caught: a head without : is a username, a value without @ has no authority, and /srv/a@b/my repos/x.git is neither.

7. The repository root is created 0700 — measured first, as ruled

The holder ruled "measure first, fix only if a reachable path leaves it wider than 0700". runtime init is that path: every repository under the root is created REPOSITORY_DIRECTORY_MODE, and the root above them took Path.mkdir's default, 0o777 & ~umask. Measured: 0755 under the container's own umask (0o022) and 0777 under umask 0 — every project id listable, and traversable, by any local account. 0o700 is umask-safe, because a umask can only remove bits, and Path.mkdir applies mode to the leaf only, which is right: the parents are the operator's own path components.

An existing root is reported and not re-moded, on the walk's own rule that it narrows only what it made itself — an operator's mount point is not this act's to change — and the mode is in init's evidence, so an operator upgrading from a build that created it 0755 sees the number and decides.

Three existing cases moved with the code, and say why in place

  • the required job's install guard reads the .[…] extras now, rather than searching the whole command line for the word runtime — the lock's filename contains it, and what the job must not do is install the runtime extra;
  • the Dockerfile's install assertions read the parts rather than one exact line, because the install now carries -c and wraps;
  • the redactor/refusal corpus records that one of its two "hidden but not refused" shapes is now refused, leaving one — the double-encoded parameter name, which stays a deliberate difference because a server decodes a name once, so ?%74oken= is the one that arrives as token and is refused.

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

Every figure below was measured at 4767ceb7, with the runtime extra made UNIMPORTABLE (the required job's own install) and with no ambient git configuration, and holds at the current head 58852e1, which adds only the workflow's record of it. This description is edited in the same act as that record, which is what the round at 0a2af8b8 asked for on the sibling PR. The branch carries origin/main by merge (#29's "Pin the triple" step on the required job), never by rebase; both of this PR's hunks in that file — the two -c installs and the figure block — stayed where they were.

run result
the required validate job's own invocation (--noconftest, the six hermetic modules) 357 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 568 passed
python -m pyflakes src/opendox/runtime/*.py tests_runtime/*.py clean
the constrained install itself (pip install -c … -e ".[test]" in a clean venv) 6 packages, and the hermetic six green under it

Ten new cases, each run against 4f8ae01e first, and each failed there for its own reason: the uncaught NotFoundError, MigrationRunner.__init__() got an unexpected keyword argument 'served_database', 0o777, the absolute index path, the three refusals and the missing lock.

The review at 4df3701c, and what it moved

Four findings, all measured true, all taken in one push — three of them defects in this act's own output, which is the line the holder drew: a finding about landed code is registered, work that does not do what it says is repaired.

  • The same defect in both deployments: a declaration that defaults to EMPTY beside a server that CREATES a named database. Compose declared ${OPENDOX_PG_DB:-} next to POSTGRES_DB: ${OPENDOX_PG_DB:-opendox}; the Kubernetes base left pg_database= empty and neither overlay set it (measured: dev merges only opendox-oidc, managed-database merges migration_wait_host and a commented runtime_pg_role). So the guard item 1 exists to add was a no-op in every shape that ships. One expression for compose's two services now; the base declares opendox, which its own StatefulSet hardcodes; the managed-database overlay — which deletes that StatefulSet — carries the commented edit beside the one it already carries. Leaving it wrong there is a refusal, not a silent wrong-database migration. pg_schema stays empty for the opposite reason: public is PostgreSQL's default, not a name this repository chose.
  • The image's repository root bypassed item 7. runtime init narrows the root it creates, and in the shipped image it creates nothing — the Dockerfile makes /var/lib/opendox/projects in its own layer with mkdir -p, which takes 0o777 & ~umask (0755 for a RUN), and this runtime does not re-mode a directory it did not make. install -d -m 0700 states the mode itself, in the layer that owns the directory.
  • The runbook's old-head procedure now runs as written — tar -x -C does not create its destination.
  • The comment at local_git_adapter.py:2104 said something false, and now says the truth. See follow-up Bootstrap posture: LICENSE, SECURITY, CODEOWNERS, validate check, pytest suite #1 below. No behaviour changed there in this act.

Registered as follow-up #1 — a separate PR, ruled

write_back's index is still pathname-bound for a LINKED WORKTREE, and the comment that denied it was wrong. Measured on git 2.43.0: git -C <worktree> rev-parse --git-dir answers the absolute <main>/.git/worktrees/<name> — not . or .git — and test_a_linked_worktree_can_reach_its_write_path, landed with § 3.6, serves exactly that shape writable and drives write_back through it. So the fallback branch is live for a supported corpus, and for it GIT_INDEX_FILE stays outside the held descriptor: the race this PR closes for a bare repository and a checkout remains open there.

Ruled by the holder: bind the worktree's metadata by descriptor — its own gitdir and --git-common-dir, which is where objects/ and refs/ live, so two more held directories threaded through the method — and keep linked worktrees writable. Making them read-only instead is rejected, because it reverses a decision § 3.6 landed with its own case. A separate act, size M, not folded in here.

Not in this act

  • local_git_adapter.py:465 is the one item that came back "measure, then decide" and the decision is recorded above: runtime init is the reachable path and it is fixed; the walk's own fchmod was already correct, and a pre-existing root is reported rather than re-moded — with the image's own layer now making that root 0700, since it is the one place that owns it.
  • Follow-up Bootstrap posture: LICENSE, SECURITY, CODEOWNERS, validate check, pytest suite #1 above — the linked worktree's index, ruled a separate act.
  • The SonarCloud findings that are not S8544 (cognitive complexity, duplicated literals, the secrets:S8136 false positives on this repository's own redaction fixtures) are untouched; the gate is advisory here and they are not this act's list.

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

🤖 Generated with Claude Code

Summary by Sourcery

Harden runtime migrations, repository operations, credential handling, dependency installation, and deployment configuration against the seven registered follow-up findings.

New Features:

  • Add served-database declarations and safeguards so migrations and resets cannot target a database the API does not read.
  • Introduce a shared pinned dependency constraints file for CI, container, and runtime installations.
  • Add secure repository-root initialization with explicit 0700 permissions and mode reporting.
  • Extend credential detection to declared compound parameter names and whitespace-bearing scp authorities.

Bug Fixes:

  • Translate repository rows deleted during attach or push actions into documented 404 responses.
  • Bind temporary Git indexes to the held repository descriptor for bare repositories and checkouts, preventing pathname replacement races.

Enhancements:

  • Apply database validation before schema validation and before migration ledger changes across migration, planning, and reset operations.
  • Document and test reliable regression measurements against older source revisions.
  • Correct deployment defaults and managed-database guidance so served-database protection is active in shipped configurations.

Build:

  • Add the resolved Python 3.12/Linux dependency constraints file and use it for package installations.
  • Set repository storage directories to private permissions in the runtime image.

CI:

  • Use the shared dependency constraints in validation workflow installs and update deployment-shape assertions for locked, wrapped install commands.

Deployment:

  • Propagate served-database configuration through Compose and Kubernetes migration deployments.
  • Ensure container-created repository roots are owned with 0700 permissions.

Documentation:

  • Document the correct procedure for running regression cases against an older checkout.

Tests:

  • Add regression coverage for database mismatches, deletion races, descriptor-bound Git indexes, credential-name handling, scp authorities, dependency locks, deployment declarations, and repository permissions.

Chores:

  • Update recorded validation results and correct an inaccurate linked-worktree comment while leaving its separate follow-up unresolved.

brettheap and others added 2 commits September 18, 2026 21:43
… its case

openDox-code#26 landed with seven findings REGISTERED rather than taken, because
its batches had a scope somebody set. This is the act that takes them. Each is
measured against a full checkout of `4f8ae01e` — never by pointing `PYTHONPATH`
at an old tree, which pytest's `pythonpath = ["src"]` silently defeats (that
trap is now written down in `docs/runtime.md` § 8).

1. THE SERVED DATABASE HAS A NON-SECRET DECLARATION (ruled item 4, from A25-3's
   half-closed finding). A25-3 established that the configuration-time
   comparison of the two DSNs can never fire in a shipped deployment, because
   the Deployment holds the served DSN and the migration Job holds the
   migration one and no workload holds both — so the migration container must
   be TOLD where the API reads. It was told the SCHEMA and not the DATABASE,
   which is the wider question: a schema comparison made in the wrong database
   compares two names that happen to agree, and `dbname` may be omitted
   entirely, in which case libpq defaults it to the connection USER. So a
   mispointed migration DSN applied DDL — and `runtime reset` DROPPED the six
   coordination tables — in a database the API never reads, with nothing in the
   shipped shape able to notice. `OPENDOX_SERVED_DATABASE` is a NAME and never
   a credential; `refuse_a_database_the_api_will_not_read` compares it with
   `current_database()` BEFORE the ledger is bootstrapped, and before the
   schema guard, in all three acts (`apply`, `migrate --plan`, `reset`). Four
   manifest edits carry it: the configmap literal, the Job's env, compose's
   migrate service and `.env.example`.

2. S8544 — EVERY INSTALL OF THIS PACKAGE READS ONE DEPENDENCY LOCK.
   `pyproject.toml` declares what this package needs and deliberately does not
   pin it; the other half was missing, so the required job, the DB-backed job
   and the image resolved whatever the index offered on the day they ran — the
   same commit tested twice is two different programs. `constraints-cpython312-
   linux.txt` is the resolved set, MEASURED in a clean venv rather than written
   by hand, and passed with `-c` in all three places. A constraints file, so the
   required job still installs `.[test]` ALONE. At the repository ROOT
   deliberately: `deploy/` holds the git-ignored `.env` that `.dockerignore`
   exists to keep out of the build context, and a lock living there would have
   meant a `!deploy…` re-inclusion.

3. `_found` AROUND THE ACT, NOT ONLY THE PRE-CHECK. Both repository routes read
   the map row through `_found` and then called the act, which takes the row FOR
   UPDATE inside itself; a row deleted between those two statements raised
   `identity.NotFoundError` past a handler that catches only
   `RepositoryActRefused` — measured at `4f8ae01e` as an uncaught exception,
   which is a 500 where this API documents 404. Same class as #25's round 10 on
   the draft-discard path, same repair.

4. A PARAMETER NAME IS JUDGED BY ITS WORDS AND ITS DECLARED COMPOUNDS. Making
   every needle of six characters or more a SUBSTRING bought `sslpassword` at
   the price of every other compound of those words: `passwordless` and
   `secretary` were refused as credential-bearing (measured). A false refusal at
   a CONFIGURATION boundary is not a safe direction — it is an install that will
   not start for a reason that is not true — so the one compound this runtime
   meets is DECLARED. `credentials_version` stays refused on purpose:
   `credentials` is one of its words, and that same reading is what catches
   `access_token`, `X-Api-Key` and `sessionToken`.

5. THE TEMPORARY INDEX IS WRITTEN THROUGH THE HELD DESCRIPTOR. Every other call
   in `write_back` goes through `-C /proc/self/fd/<n>`, which is what makes "the
   check and the use are one object" true; `GIT_INDEX_FILE` was built from
   `rev-parse --absolute-git-dir`, a PATHNAME. MEASURED on git 2.43.0 with the
   directory renamed away and a symlink to a second repository put in its place
   after the probe: the absolute form wrote `opendox-index-…` into the DECOY and
   the descriptor-relative form wrote it into the real repository. `--git-dir`
   asked through `-C` answers RELATIVE (`.` bare, `.git` checkout, measured), so
   joining it onto the runner's root keeps the whole path inside the descriptor.

6. THE STORE NAMES AN AUTHORITY IT CANNOT READ. `_scp_like_userinfo` declines a
   head holding whitespace so the rule cannot start judging prose, and the
   redactor's class excludes it so an unrelated `user@host` down git's stderr is
   not joined to the URL above it — and `user:pa ss@host:path` fell between
   them, refused in its URL form and accepted in its scp form. #26 closed the
   printing half; this closes the store's own guard, by SHAPE and never by
   value. Nothing ordinary is caught: a head without `:` is a username, a value
   without `@` has no authority, and `/srv/a@b/my repos/x.git` is neither.

7. THE REPOSITORY ROOT IS CREATED 0700 — measured first, as ruled. Every
   repository under it is `REPOSITORY_DIRECTORY_MODE`; the root above them took
   `Path.mkdir`'s default, `0o777 & ~umask`, so MEASURED under the container's
   umask (0o022) `runtime init` left it 0755 and under umask 0 it left it 0777 —
   every project id listable and traversable by any local account. 0700 is
   umask-safe, because a umask can only remove bits. An EXISTING root is
   reported and not re-moded, on the walk's own rule that it narrows only what
   it made itself; the mode is in `init`'s evidence so an operator upgrading
   sees it.

Three existing cases moved with the code and say why in place: the required
job's install guard reads the `.[…]` EXTRAS now rather than searching the whole
command line for the word `runtime` (the lock's filename contains it); the
Dockerfile's install assertions read the parts rather than one exact line; and
the redactor/refusal corpus records that one of its two "hidden but not refused"
shapes is now refused, leaving only the double-encoded parameter name — which
stays a deliberate difference, because a server decodes a name once.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`6d2b0861` is the commit that was measured: 355 passed 1 skipped on the
required job's own six modules with the runtime extra unimportable, and 566 on
`pytest -q tests_runtime/` with a database. The PR description is written with
the same two numbers at the same commit, in this act — the ordering the review
at `0a2af8b8` asked for on the sibling PR, where the description lagged the
workflow block by one commit.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 18, 2026 21:44
@brettheap
brettheap marked this pull request as ready for review September 18, 2026 21:45

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

You can request another review in 4 days and 8 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR implements the seven registered §3.6 follow-ups: it adds served-database refusal checks, locks all dependency installs, fixes repository-action race/error handling, narrows credential detection while covering unreadable authorities, hardens repository-root permissions, and documents reliable older-head regression measurements. It also adds or updates focused deployment, migration, API, Git, redaction, and CLI tests for each behavior.

Sequence diagram for served-database migration refusal

sequenceDiagram
    participant CLI
    participant MigrationRunner
    participant PostgreSQL

    CLI->>MigrationRunner: apply()
    MigrationRunner->>PostgreSQL: selected_database()
    PostgreSQL-->>MigrationRunner: current_database()
    alt database differs from served_database
        MigrationRunner-->>CLI: MigrationError
    else database matches
        MigrationRunner->>MigrationRunner: refuse_a_schema_the_api_will_not_read()
        MigrationRunner->>PostgreSQL: bootstrap_ledger()
        MigrationRunner-->>CLI: migrations applied
    end
Loading

Sequence diagram for descriptor-bound repository write-back

sequenceDiagram
    participant WriteBack
    participant Git
    participant Repository
    participant Decoy

    WriteBack->>Git: rev-parse --git-dir
    Git-->>WriteBack: relative git directory
    WriteBack->>WriteBack: build path under git.root
    WriteBack->>Repository: read-tree and update-index via held descriptor
    WriteBack->>Repository: write-tree
    Repository-->>WriteBack: commit created
    Decoy-->>WriteBack: no temporary index written
Loading

Flow diagram for credential-name and authority refusal

flowchart TD
    A[Remote URL or parameter name] --> B{Parameter contains a secret word?}
    B -->|yes| C[Refuse credential-bearing parameter]
    B -->|no| D{Declared compound sslpassword?}
    D -->|yes| C
    D -->|no| E{Authority has whitespace-bearing userinfo?}
    E -->|yes| C
    E -->|no| F[Accept value]
Loading

File-Level Changes

Change Details Files
Added an explicit served-database safety boundary to migration, planning, reset, configuration, and deployment wiring.
  • Introduced OPENDOX_SERVED_DATABASE as a non-secret setting and status field.
  • Compared current_database() before schema checks and any ledger/DDL/reset work.
  • Propagated the declaration through Kubernetes, Compose, and migration settings.
  • Added coverage for mismatch refusal, ordering, and unchanged database state.
src/opendox/runtime/config.py
src/opendox/runtime/migrations.py
src/opendox/runtime/cli.py
deploy/compose/docker-compose.yaml
deploy/kubernetes/base/kustomization.yaml
deploy/kubernetes/base/migration-job.yaml
tests_runtime/test_migrations_apply.py
tests_runtime/test_runtime_cli.py
tests_runtime/test_deploy_shape.py
Locked dependency resolution consistently across CI and the runtime image with one generated constraints file.
  • Added the root-level CPython 3.12/Linux resolved constraints file.
  • Applied -c constraints-cpython312-linux.txt to both validation installs and the Docker build.
  • Copied the lock into the image before installation.
  • Updated install-shape tests to inspect extras and lock usage rather than exact command text.
constraints-cpython312-linux.txt
.github/workflows/validate.yml
deploy/compose/Dockerfile
tests_runtime/test_deploy_shape.py
.dockerignore
Closed race and error-translation gaps in repository actions.
  • Wrapped attach and push acts with _found so deletion during the act maps to the documented 404.
  • Built temporary Git index paths from the held descriptor and relative --git-dir output instead of a replaceable pathname.
  • Added an arranged descriptor-swap regression case asserting both path mechanism and repository outcome.
src/opendox/runtime/app.py
src/opendox/runtime/local_git_adapter.py
tests_runtime/test_api_endpoints.py
tests_runtime/test_local_git_adapter.py
Refined credential-name and remote-authority detection to reduce false negatives without broad substring false positives.
  • Replaced long-needle substring matching with whole-word matching plus the explicitly declared sslpassword compound.
  • Refused whitespace-bearing scp-like authorities by shape while preserving ordinary usernames and local paths.
  • Updated redaction/refusal corpus expectations and added focused cases.
src/opendox/runtime/config.py
tests_runtime/test_local_git_adapter.py
Made the repository root private on creation and observable when already present.
  • Created a new root with REPOSITORY_DIRECTORY_MODE (0700), independent of umask.
  • Reported the existing root's mode without changing operator-owned directories.
  • Added tests for umask-zero creation and existing-root preservation.
src/opendox/runtime/cli.py
tests_runtime/test_runtime_cli.py
Documented the correct method for proving regressions against an older checkout.
  • Explained why pytest's configured src path overrides an old-tree PYTHONPATH.
  • Provided whole-checkout and direct-script procedures for running cases against the old head.
docs/runtime.md

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

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.

Copilot review overview

🟡 Changes recommended

Critical database declaration gaps and the linked-worktree index fallback remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 3 High severity · 1 Low severity

Open (4)
What changed in this PR

This PR addresses seven runtime, deployment, dependency, credential-handling, and repository-safety follow-ups.

Changes:

  • Adds served-database guards and deployment configuration.
  • Adds shared dependency constraints for CI and Docker.
  • Hardens repository writes, initialization, credential handling, and regression coverage.
File Reviewed changes
tests_runtime/​test_runtime_cli.py Tests database wiring and repository-root permissions.
tests_runtime/​test_migrations_apply.py Tests served-database validation.
tests_runtime/​test_local_git_adapter.py Tests Git index handling and credential cases.
tests_runtime/​test_deploy_shape.py Tests constrained installs and deployment configuration.
tests_runtime/​test_api_endpoints.py Tests disappearing repository rows returning 404.
src/​opendox/​runtime/​migrations.py Adds database-target validation; nit (1 vote): reset wording should identify the selected database.
src/​opendox/​runtime/​local_git_adapter.py Uses descriptor-relative indexes; critical (3 votes): the linked-worktree absolute-path fallback remains unsafe.
src/​opendox/​runtime/​config.py Adds database and credential rules; moderate (1 vote): whitespace-bearing scp authorities can produce a 500.
src/​opendox/​runtime/​cli.py Adds root-permission handling; moderate (1 vote): the pre-created image root can bypass the 0700 invariant.
src/​opendox/​runtime/​app.py Translates act-time missing rows to 404 responses.
docs/​runtime.md Documents older-head regression testing; nit (2 votes): create the extraction directory first.
deploy/​kubernetes/​base/​migration-job.yaml Passes the served database to the migration job.
deploy/​kubernetes/​base/​kustomization.yaml Adds database configuration; critical (1 vote): empty defaults leave the guard disabled.
deploy/​compose/​Dockerfile Applies constrained dependency installation and creates the project directory.
deploy/​compose/​docker-compose.yaml Propagates the served database; critical (2 votes): its default does not match the bundled database.
deploy/​compose/​.env.example Documents the served-database setting.
constraints-cpython312-linux.txt Records resolved dependency constraints.
.github/​workflows/​validate.yml Applies dependency constraints; nit (1 vote): an install-contract comment is stale.
.dockerignore Includes the constraints file in Docker builds.

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

Comment thread deploy/compose/docker-compose.yaml Resolved
Comment thread docs/runtime.md Resolved
@brettheap

Copy link
Copy Markdown
Contributor Author

Review at 4df3701c — four findings, all MEASURED, all REGISTERED here

Nothing is taken in this batch: the holder's word after the sibling PR's overrun is one push, and a fault found afterwards gets a message first. Three of these are defects in this act's own output — the follow-ups it builds do not reach the shipped shapes, and one in-code claim is simply false — so they are written down precisely rather than softened, and the repair waits on the word.

1. local_git_adapter.py:2104 — the linked-worktree fallback is REACHABLE, and my comment says it is not. TRUE.

The comment reads "it cannot arise for a repository this act writes to". Measured on git 2.43.0: for a linked worktree git -C <wt> rev-parse --git-dir answers an absolute path (<main>/.git/worktrees/wt) — not . or .git — and test_a_linked_worktree_can_reach_its_write_path (landed on #26) asserts write_path_available for exactly that shape and drives write_back through it. So the fallback branch is live for a supported, writable corpus, and for it GIT_INDEX_FILE stays pathname-bound outside the held descriptor: the very race this act closes is still open there.

It is not a one-line repair, which is the other reason it is registered. The two answers are (a) bind the worktree's git metadata to descriptors too — the common directory and the worktree's own are two places, and --git-common-dir is where objects/ and refs/ live — or (b) serve linked worktrees read-only, which reverses a landed #26 decision and its case. That is a ruling, not a fix.

2. deploy/compose/docker-compose.yaml:247 — the bundled default disables the guard. TRUE.

Measured in the same file: the server is POSTGRES_DB: ${OPENDOX_PG_DB:-opendox} (line 27) and the declaration I added is ${OPENDOX_PG_DB:-}. An operator who sets nothing therefore gets a server holding opendox and a migration container told nothing, so _served_database() is None and the guard this act exists to add is a no-op in the shape everybody runs first. ${OPENDOX_PG_DB:-opendox} is the whole repair.

3. deploy/kubernetes/base/kustomization.yaml:128 — same, for every shipped Kubernetes shape. TRUE.

pg_database= is empty in the base and neither overlay sets it (measured: dev merges only opendox-oidc; managed-database merges migration_wait_host and a commented runtime_pg_role). The bundled StatefulSet hardcodes POSTGRES_DB: opendox, so the base can name it truthfully; the managed-database overlay then has to set its own, exactly as it already must for runtime_pg_role, and that is a numbered step in its runbook rather than a silent inheritance.

The one thing worth saying against the finding: pg_schema= ships empty too, and "empty declares nothing" is the existing convention this item followed. The convention is right for the schema (public is a default, not a fact) and wrong for the database, because the bundled server creates a named one.

4. docs/runtime.md:678 — the documented procedure does not run as written. TRUE.

tar -x -C /tmp/oldhead needs the directory to exist; my own runs created it with mkdir and the paragraph dropped that line. A runbook step that fails on the first command is worse than none, because it teaches that the section is decorative.

Also in the review's file table, measured here

  • The image's project root bypasses item 7. deploy/compose/Dockerfile does mkdir -p /var/lib/opendox/projects before runtime init ever runs, so the root EXISTS and this act's "report an existing root, do not re-mode it" rule leaves it at the image build's umask (0755 for a default RUN). Item 7's guarantee therefore does not reach the shipped image. Real, and registered: the fix is install -d -m 0700 (or a chmod 0700) in that layer, which is the one place the runtime does own the directory.
  • "Whitespace-bearing scp authorities can produce a 500" — MEASURED FALSE. That 500 shape is real history on § 3.6: openDox creates a repository as a first-class act, with RULING C3's conformant local-git adapter #26 (;token=), where the ACT accepted what the STORE refused and identity.RefusedError escaped a handler that catches RepositoryActRefused. It cannot happen here: for every value the new store rule refuses, repository_act.refuse_credential_bearing_remote refuses first — checked across five whitespace-bearing authorities, RepositoryActRefused each time. The act is strictly the wider of the two, which is the direction that cannot 500.
  • The two wording nits (the reset refusal naming the selected database; the stale install-contract comment) are noted and not taken in this batch.

validate and runtime are green at 4df3701c. The figure and this description name the same commit, 6d2b0861: 355 passed, 1 skipped hermetic and 566 passed on pytest -q tests_runtime/.

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

brettheap and others added 3 commits September 18, 2026 21:57
…th at 2104

Four of the review's findings at `4df3701c`, each measured in the file it names.
The first two are the same defect in two deployments: a declaration that
defaults to EMPTY beside a server that CREATES a named database.

COMPOSE. `postgres` is `POSTGRES_DB: ${OPENDOX_PG_DB:-opendox}` and the
migration container was told `${OPENDOX_PG_DB:-}`, so an operator who sets
nothing — the first run everybody makes — got a server holding `opendox` and a
container told nothing at all. `_served_database()` turns that into `None` and
the guard is a no-op in exactly the shape it was added for. One expression for
both now, defaults included, so they cannot come apart.

KUBERNETES. `pg_database=` was empty in the base and set by NEITHER overlay
(measured: `dev` merges only `opendox-oidc`; `managed-database` merges
`migration_wait_host` and a commented `runtime_pg_role`) — so the guard was off
in every shipped shape. The base declares `opendox`, which is what its own
`postgres-statefulset` hardcodes, and the managed-database overlay — which
DELETES that StatefulSet — now carries the commented edit beside the one it
already carries for `runtime_pg_role`. Leaving it wrong there is a REFUSAL and
not a silent wrong-database migration, which is the direction this declaration
exists to choose. `pg_schema` stays empty for the opposite reason: `public` is
PostgreSQL's default rather than a name this repository chose.

THE IMAGE'S REPOSITORY ROOT. `runtime init` narrows the root it CREATES, and in
the shipped image it creates nothing: the Dockerfile makes
`/var/lib/opendox/projects` in its own layer, so by the time `init` runs the
root is already there and this runtime does not re-mode a directory it did not
make. `mkdir -p` takes `0o777 & ~umask` — 0755 for a `RUN` layer — so the
directory holding every project's bare repository shipped world-readable and
traversable while each repository under it is 0700. `install -d -m 0700` states
the mode itself, so no umask applies, and the layer that OWNS the directory is
the one that makes it.

THE RUNBOOK STEP RUNS AS WRITTEN. `tar -x -C /tmp/oldhead` does not create its
destination, and the paragraph dropped the `mkdir` my own runs used. A step that
fails on its first command teaches that the section is decorative.

AND THE COMMENT AT `local_git_adapter.py:2104` SAID SOMETHING FALSE. It claimed
an absolute `--git-dir` "cannot arise for a repository this act writes to".
MEASURED false on git 2.43.0: `git -C <worktree> rev-parse --git-dir` answers
the absolute `<main>/.git/worktrees/<name>`, and
`test_a_linked_worktree_can_reach_its_write_path` — landed with § 3.6 — serves
exactly that shape WRITABLE and drives `write_back` through it. So the fallback
branch is live for a supported corpus and its index is still bound to a
pathname. NO BEHAVIOUR CHANGES HERE: the repair is two more held descriptors
(the worktree's own gitdir and `--git-common-dir`, which is where `objects/` and
`refs/` live) and it is RULED a separate act, with read-only linked worktrees
rejected because that reverses what § 3.6 landed with its own case. What this
commit changes is the comment, which now says what is true and what is
scheduled — the one thing a comment owes.

Two cases carry it: the shipped shapes' declarations (compose's two services
compared as one expression, the base's literal against its own StatefulSet, and
the overlay's commented edit) and the image's root mode.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`4767ceb7` is the commit that was measured: 357 passed 1 skipped on the
required job's own six modules with the runtime extra unimportable, and 568 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.

This branch also carries `origin/main` by merge (openDox-code#29's "Pin the
triple" step on the required job), never by rebase, and both of this act's
hunks in that file stayed where they were: the two `-c` installs and this
comment block.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 18, 2026 22:02
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C 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

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.

Copilot review overview

🟡 Changes recommended

Four unresolved moderate findings remain in dependency locking, service wiring, migration-path coverage, and credential-shape handling.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 2 Medium severity

Open (3)
Resolved since last review (3)

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

Copy link
Copy Markdown
Contributor Author

Review at 58852e1f — two new findings, both MEASURED, both REGISTERED (round cap)

The holder set a round cap on this PR, so nothing here moves the head. Both are measured rather than relayed, and the first one is bigger than the review says.

1. config.py:584 — a local path with : … @ reaches the store and escapes as a 500. TRUE, and only PARTLY this act's.

Measured on this head and on origin/main (373b05a):

value credential_in_a_remote_url refuse_credential_bearing_remote where
/srv/repos/a:b@c.git "a password in the URL's authority" ACCEPTED origin/main already
/srv/my repos/a:b@c.git (main) None → (here) "an authority this runtime cannot read as one word" ACCEPTED widened by this act

So the shape the review names is real, and the plain one — no whitespace at all — has been on main since § 3.5: the store refuses a value the act accepts, and app.py translates identity.RefusedError nowhere (grep: not one occurrence), so it leaves the route as an unhandled exception. That is a 500 for a legal local-path remote, and it is the same class as #26's ;token= 500, which was closed by making the two readings agree on that one shape rather than by closing the escape.

The repair that ends the class rather than this instance is the boundary one, and it is the shape this PR already used for NotFoundError: except identity.RefusedError → 409 on the three routes that call an act which writes through the store (create, attach, push), so a store refusal can never again arrive as a crash. Restricting the fallback to a genuine scp authority — a head with no / in it — is the narrower half and closes the two rows above; it does not close the class.

Registered, with the boundary repair named, because the cap is on this PR and not on the finding.

2. cli.py:829 — no DB-backed case drives migrate --plan or reset with a mismatched served DATABASE. TRUE.

The wiring is there for all three acts and the case covers apply() — including that the DATABASE is asked before the SCHEMA when both declarations are wrong — but the schema guard has test_reset_and_plan_ask_the_served_schema_declaration_the_run_asks and the database guard has no twin. It is a coverage gap rather than a defect: the two call sites are one line each and are visible in the diff. It goes on the same follow-up as the boundary repair, because a case that drives reset wants the same harness that one built.

Still open from the previous round

Follow-up #1 — write_back's index is still pathname-bound for a linked worktree, measured (--git-dir through -C answers the absolute <main>/.git/worktrees/<name>, and § 3.6's landed case serves that shape writable). Ruled a separate act: bind the worktree's own gitdir and --git-common-dir by descriptor, keep linked worktrees writable. The comment at local_git_adapter.py:2104 no longer claims otherwise.

Closed in this round, per the review's own list

Default OPENDOX_PG_DB to the served database, Enable database guard for all Kubernetes deployment shapes and Create extraction directory before untarring — all three resolved at 4767ceb7, with two cases carrying them.

validate and runtime are green at 58852e1f. The figure block and this description name the same commit, 4767ceb7: 357 passed, 1 skipped hermetic and 568 passed on pytest -q tests_runtime/.

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

@brettheap
brettheap merged commit 5c86713 into main Sep 18, 2026
4 of 5 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

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

LANDED — lane openxfactory-4, 2026-09-18T22:12:55Z, PR #30 → 5c86713 (opensoft/openDox-code main; plain gate)

§ 3.6 follow-ups: the seven findings #26 registered (OPENDOX_SERVED_DATABASE + current_database() guard with manifests incl. compose/k8s defaults, S8544 dependency lock, _found around attach/push, whole-token secret matching, descriptor-bound GIT_INDEX_FILE, whitespace scp authority named, 0700 root incl. the image), each with its case; follow-up #1 linked-worktree descriptor binding (ruled) and follow-up #2 RefusedError→409 boundary + mismatched-database cases registered

brettheap added a commit that referenced this pull request Sep 18, 2026
…lack

The floors moved twice in this pull request and the second measurement is
the one that governs.

First: eight tests joined the list with
`tests/test_conformance_corpus.py` — run 35400706354, 1076 -> 1084 and
1073 -> 1081.

Then #30 landed (merge `5c867137`, 22:12:50Z), this branch merged
`origin/main`, and the number moved again — run 35400771494 over the
merged head: selected 1093, passed 1090, skipped 3.

NINE OF THOSE ARE #30'S, AND IT LEFT THE FLOORS WHERE IT FOUND THEM.
Its tests went into files ALREADY in the required job's lists —
`tests_runtime/test_deploy_shape.py`, `test_local_git_adapter.py`,
`test_runtime_cli.py` — which is the one way to add tests here without
touching the list, and therefore the one way to grow the pin's slack
without noticing. Main was left with `selected>=1076 (margin 9)`: green,
and blind to any regression smaller than nine tests. That is not a
criticism of the landing so much as evidence that the procedure needs to
be attached to "adding tests" rather than to "editing the list", and the
pin's comment now says so where the next reader will be standing.

Closed here because this act was re-measuring anyway. A floor with slack
in it is a floor that has stopped catching the regression it was set to
catch.

Neither figure is derived: 1084 + 9 = 1093 is a check on the reading, not
its source. EXPECT_SKIPPED stays 3 across all three runs.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
brettheap added a commit that referenced this pull request Sep 19, 2026
…d Q-F1's transposition (#31)

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

CLAIM [`5736795055`](opensoft/openXfactory#656 (comment)) — `split-opendox-two-layer-product` § 3.7 FLOOR PART 3, the **openDox side**. The other two sides are landed: openxFactory's half of RULED Q-F1 (a) (`#1086` → `049d54a9`) and openXdox's reader (`openXdox-code` #23 → `3ee8cd31`).

# § 3.7 FLOOR PART 3 — openDox's conformance reader

The box asks for one thing and names two parts of it. Its own words:

> **§ 3.7 also owes a DECLARED factory and Q-F1's transposition** — `tasks.md:1392-1394`

> a reader that exists **is not a pass recorded**. The exit line — the three-argument command returning `OK — 17 of 17` … is owed — `tasks.md:1489-1493`

> **Q-F1 (a)** — how FLOOR PART 3 runs against a GIT-HISTORY reader: **the DESTINATION transposes the corpus into git and says so** (`conformance_corpus.transpose()`, run with `--corpus <transposition>`), documents, keys and bytes unchanged — `tasks.md:1357-1361`

So this PR is a factory, a transposition, and a recorded pass — **not a CI step**. openDox's implementation already existed (`LocalGitCorpus`, landed by #26 with Q-F2's three construction data on `__init__`); what was missing was the module that points it at somebody else's corpus. The ledger's reading of this side was blunt and correct: *"openDox — NOT EVIDENCED, and unlike openXdox this one has NOT moved: `openDox-code` carries no conformance reader at all"* (`:1516-1519`).

## The pass, measured

openxFactory's runner at `eb1880cb`, against this tree and a transposition built by this module:

```
$ python3 scripts/verify-carve-conformance.py \
    --destination opendox_code \
    --dest-root   <this checkout> \
    --adapter     opendox.conformance_corpus:reader \
    --corpus      <the transposition>

OK …: opendox_code passed the neutral conformance corpus — 17 of 17 check(s),
reader opendox.conformance_corpus:reader, corpus …,
TRANSPOSED and FAITHFUL to …/tests/corpus-adapter/fixtures — 3 document(s) at
revision 91c6319e…, key/sha256 table 744c9183…, unmoved across the run
EXIT=0
```

`TRANSPOSED and FAITHFUL` is the half that cannot be faked: the runner computes `{key: sha256(bytes)}` off openxFactory's **files** and compares it against what **this reader serves**, so a transposition that dropped, added, renamed or re-encoded a document refuses `conformance-corpus-unfaithful` instead of passing.

## What the module is

152 lines, two functions.

| | |
| --- | --- |
| `reader(name, location)` | the declared factory. **Neither argument is used**, and that is the property being measured rather than an oversight: one reader built from the corpus's terms alone is pointed at all four of the corpus's states in a single run, which the three resolution-time negative confirmations require. |
| `transpose(shipped, dst)` | Q-F1 (a)'s permission, taken with its proof — the same documents laid into git, bytes and keys unchanged. |

**`write_path=None` is load-bearing**, and is the one place this could have quietly failed. `LocalGitCorpus` declares *openDox's* governed write path; the corpus's `read-only-declared-at-resolution` check asserts that resolution reports **none**, and has a name for a reader that brings one anyway: *"a reader is inventing one"*. `kind_field` / `required_fields` are the corpus's own two-field header (`Type`, `Title`) — a corpus that "has never heard of a factory", in the words of its own first document — so they are values here, never defaults inherited from openDox.

**All four states are built**, because the seventeen checks resolve four locations and three of them are negative confirmations:

- `neutral` — a git repository holding **exactly** the shipped files
- `empty` — a repository committed with `--allow-empty` and **no tracked path**; a `.gitkeep` would be listed by `ls-tree -r` and the empty corpus would hold a document
- `not-a-directory` — a file
- the absent state — built by **not creating it**, which is the only honest way to build it

## The tests, and what they deliberately do not do

8 tests, added to the required job's named list. **They prove the property the runner checks, not the run**: the runner needs openxFactory's checkout and its fixtures, which this leg does not have and must not acquire to satisfy a test. So they reproduce the runner's own asymmetric comparison — a `{key: sha256}` table off the **files** against what the **reader** serves — over a corpus built in a tmpdir with the shipped one's shape, plus: the transposition adds no key of its own; the empty state answers rather than refuses; both refusal states refuse with the right kind.

Bytes are compared as `Document.content` **bytes**, never decoded — a transposition that re-encoded a document would round-trip through `str` and compare equal while the bytes on disk had changed.

## Honest size: M

The factory is small (openXdox's analogue is 94 lines) because the adapter already exists here. `transpose()` is the part openXdox never needed, and the faithfulness proof is unforgiving about keys, so it is a medium change rather than a small one.

## The pin

The required job's collection triple is pinned by this lane's #29 → `373b05aa`. Adding a test file moves it, so the floors are **re-measured from this PR's own CI run and raised with the reason in the same commit** — `pytest-suite.yml`'s own procedure, and the mechanism its comment names: what moves these numbers here is editing the explicit list, and nothing else.

## Coordination

**#30 @`58852e1f`** is open on this repository and overlaps two files (`validate.yml`, `local_git_adapter.py`). Different subject, different claim; named before authoring rather than discovered at a conflict. If it lands first this branch takes `git merge origin/main` — never a rebase — and **re-measures the pin afterwards**, because #30's own test additions move the same three numbers.

**This does not tick § 3.7**, which needs both destinations; openXdox's pass is evidenced ([`5736681367`](opensoft/openXfactory#656 (comment))) and this supplies openDox's. It is also **§ 8.2 part 3**, whose other three parts are already on record.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
brettheap added a commit that referenced this pull request Sep 19, 2026
… 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>
brettheap added a commit that referenced this pull request Sep 19, 2026
… that is a refusal (#32)

# 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 with `PYTHONPATH`, for the reason `docs/runtime.md` § 8 now records.

| # | what | origin |
|---|---|---|
| 1 | a **linked worktree**'s metadata was not bound by descriptor, so its index stayed pathname-bound | [#30 thread on `local_git_adapter.py:2124`](#30 (comment)) — **ruled by the holder** |
| 2 | `identity.RefusedError` was translated **nowhere**, so a store refusal the act did not pre-empt was a **500** | [#30 thread on `config.py:584`](#30 (comment)) |
| 3 | the whitespace fallback read a **local path** as an authority | same thread |
| 4 | the served-database guard's other two acts had **no case** | [#30 thread on `cli.py:829`](#30 (comment)) |

## 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:**

| | linked worktree |
|---|---|
| `<worktree>/.git` | a **file** naming an absolute path |
| `rev-parse --git-dir` (through `-C`) | `<main>/.git/worktrees/<name>` — **absolute**, holds the INDEX, holds neither `objects/` nor `refs/` |
| `rev-parse --path-format=absolute --git-common-dir` | where `objects/` and `refs/` actually are |

`resolve` serves 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_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** before it was written: `rev-parse`, `hash-object -w`, `read-tree`, `update-index`, `write-tree`, `commit-tree` and `update-ref` all 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 makes `update-ref` refuse with `cannot 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_act` refuses a credential-bearing remote and so does `identity.CoordinationStore`: layering, not duplication, and the two readings are deliberately not identical. Nothing translated the store's — `app.py` caught `RepositoryActRefused` and **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 at `5c867137`** (the new case reproduces it there as a raw `identity.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 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 that colon is a `/`. It separates the two cases exactly, which is why it is this rule and not "a head holding any slash":

| value | before the first `:` | verdict |
|---|---|---|
| `ci:hun/ter2@github.com:o/r.git` | `ci` | an authority — #25's password-containing-a-slash hole **stays closed** |
| `/srv/my repos/a:b@c.git` | a path | a local path, not judged |

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 `runtime migrate --plan` and from `runtime 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: 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_back` declares exactly two kinds — `CORPUS_READ_ONLY` and `WRITE_PATH_UNREACHABLE` — and a caller may branch on `err.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). 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:**

| what fails | what escaped `write_back` |
|---|---|
| `open_no_follow_chain` on the worktree's git directory | `FileNotFoundError` |
| `rev-parse --git-dir` — the probe itself | `GitCommandFailed` |

The 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`, `OSError` and `RuntimeError` (a symlink loop raises the last, which is why the root probe catches it), closes any descriptor it had already taken, and refuses with `WRITE_PATH_UNREACHABLE` naming the failure **class** and not git's stderr. One case drives both rows, the probe row on an **ordinary** repository, and it fails against `97a1b37e` with the raw `GitCommandFailed`.

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

Every figure was measured at **`acbb6d46`** — this branch with `origin/main` **merged** in (openDox-code#31, § 3.7's conformance factory; no rebase) — with the `runtime` extra made UNIMPORTABLE and no ambient git configuration, and holds at the current head **`f8678ad`**, 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.**

| run | result |
|---|---|
| the required `validate` job's own invocation (`--noconftest`, the six hermetic modules) | **360 passed, 1 skipped** |
| of which `tests_runtime/test_local_git_adapter.py` | 138 passed |
| `python -m pytest -q tests_runtime/` with `OPENDOX_TEST_DATABASE_URL` set | **573 passed** |
| `python -m pyflakes src/opendox/runtime/*.py tests_runtime/*.py` | clean |
| the required job's **triple** (`tests/` 725+2 skipped, S7 residue 13, hermetic six 361+1 skipped) | selected **1099**, passed **1096**, skipped **3** |

**The triple's floors move up with the cases that raised them** — `MIN_SELECTED` 1096 → 1098 → **1099**, `MIN_PASSED` 1093 → 1095 → **1096**, `EXPECT_SKIPPED` unchanged 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 = 1098` is 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.git` refused as an authority, and the raw `identity.RefusedError` that 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 at `93ccc3dd`; 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](https://claude.com/claude-code)


Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

2 participants