Repository navigation
T055 follow-up: confine to the resolved entry, no second lookup (default_registry.resolve_source) - #70
Conversation
…ult_registry.resolve_source) Copilot at openDox-code#59 0c946f4 ("previously missed", medium, default_registry.py:444): resolve_source() performs a second lookup by (repository, ref) after the caller has already resolved an entry, so a concurrent refresh can put another entry's source_root behind the path. serve_project._resolved_listed_edit_entry, the only production caller of that two-step path, resolved an entry and then asked the registry for the path by the entry's pair. It now resolves once and confines the path to THAT entry's own root through the registry seam's declared resolve_within, as serve.py's /source arm does since #59. The listed-path check and the editor launch already used the entry in hand, so lookup, validation and confinement are one entry. The route no longer needs a method the seam does not declare, so a contributed registry without resolve_source serves it. SnapshotRegistry.resolve_source keeps its behaviour (one lookup, confined to that entry) and its docstring now says it is for a caller that holds only a pair. tests/test_edit_action_one_entry.py holds the rule: one lookup, both directions of the race at the route, confinement kept, a host registry, and no module asking a registry for a path by a pair. Arc: neutral-product-standalone-operability Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Reviewer's GuideThe PR removes the remaining unstable second registry lookup from the project edit route by confining paths through the entry returned by its single resolution, while retaining existing listing and containment rules. It documents the intended scope of Sequence diagram for single-entry project edit path resolutionsequenceDiagram
participant Client
participant EditRoute as serve_project
participant Registry
participant Seam as projection_seams.registry
participant Entry
participant Editor
Client->>EditRoute: POST /actions/edit
EditRoute->>Registry: resolve(repository, ref)
Registry-->>EditRoute: Entry
EditRoute->>Entry: read listed source paths
EditRoute->>Seam: resolve_within(Path(Entry.source_root), path)
Seam-->>EditRoute: confined target
alt target is a listed file
EditRoute->>Editor: launch editor over Entry.source_root
EditRoute-->>Client: 200
else target unavailable or unlisted
EditRoute-->>Client: 404 document_unavailable
end
Sequence diagram for refresh-safe source confinementsequenceDiagram
participant EditRoute as serve_project
participant Registry
participant Seam as projection_seams.registry
participant FirstEntry as resolved entry
participant Replacement as refreshed entry
EditRoute->>Registry: resolve(repository, ref)
Registry-->>EditRoute: FirstEntry
Note over Registry,Replacement: A refresh may replace the key after resolution
EditRoute->>Seam: resolve_within(Path(FirstEntry.source_root), path)
Seam-->>EditRoute: target confined to FirstEntry
EditRoute->>FirstEntry: read listed source paths
EditRoute-->>Replacement: no lookup by repository and ref
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
🟢 Approval recommended
The focused change correctly removes the second lookup and is comprehensively covered.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes a registry-refresh race by confining edit paths to the already-resolved snapshot entry.
Changes:
- Uses one stable registry entry throughout edit validation.
- Documents
resolve_source’s pair-only contract. - Adds focused confinement and race coverage.
| File | Description |
|---|---|
src/opendox/serve_project.py |
Confines edits to the resolved entry’s root. |
src/opendox/default_registry.py |
Clarifies lookup semantics. |
tests/test_edit_action_one_entry.py |
Tests single lookup, confinement, host seams, and refresh races. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…r, do not copy them SonarCloud's quality gate on this PR read 4.9% duplication on new code (required at most 3%): the new test module carried a copy of test_projection_seams.py's autouse registry-isolation fixture and its git helper. Import both instead, as tests/test_doxbench_*.py import their shared helpers from test_doxbench_view. The autouse fixture applies to the new module's cases (eight SETUPs under --setup-show), the eight cases pass, and all five mutants of the fix are still killed. Arc: neutral-product-standalone-operability Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
|
READY at 5666505 — Lane: openxfactory-4 (openXfactory-4-openDox_extraction) |
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 1 day and 20 hours by commenting @sourcery-ai review. Upgrade to get a review now.
main now carries #70 (75bd8705, resolve_source confined to the resolved entry) and #66's squash (a23e422). This branch already held #66's final head, a7bda06, at 923f30d9. So main brings only #70's three files (default_registry.py, serve_project.py and tests/test_edit_action_one_entry.py), and T058 touches none of them. The merge is clean. Proof that the merge carries exactly T058's delta: the stable patch-id of `git diff a7bda06 923f30d9` equals the patch-id of `git diff origin/main` against this merge. That delta is seven files. Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…n 034) (#68) Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Plan 034 **T058** [US2] [oDc], **the post-render validator in the generate verbs** (#1144's 7.2, in part), from `specs/034-opendox-standalone-operation/tasks.md` at openxFactory `main` `91e4685f`: > It validates the neutral snapshot against T053's schema, read from T057's packaged copy. `--strict` makes a validator that cannot run fatal, and `--no-validate` skips validation. > - **Realizes**: 7.2 (part). > - **Falsifier**: F7.2. The good fixture exits 0; the malformed one exits non-zero, naming `EXPECTED_RULE`, with no `No such file or directory`. > - **Ruled**: R1Q22 (a), `5817152735`; R1Q11 (a), R1Q12 (a), `5850003126`. > - **After**: T051, T056, T057. Claimed on openxFactory#656 in comment `5901343950`, with T056. ## Was stacked on #66, and is now on `main`, with its predecessors landed - **It was stacked on T056's branch** (#66), which was itself stacked on #59 (T055). Each new #66 head was merged in here, the last being `a7bda066` at `923f30d8`. - **#66 has landed** as `a23e4224`, after #70 (`75bd8703`, the `resolve_source` follow-up to #59). `main` is merged in at `5322efee`. It brought only #70's three files, `default_registry.py`, `serve_project.py` and `tests/test_edit_action_one_entry.py`, and T058 touches none of them. - **The merge carries exactly T058's delta.** The stable patch-id of `git diff a7bda06 923f30d` equals the patch-id of `git diff main 5322efe`: `f302a8aa` both times. The same id held at `cd6b33cb` against `38761c76`. - **#58 (T057) was merged in**, at `e94ab323`, `3351f6a7` and `753ffa19`, because T058 wires the `opendox.validator` that #58 ships. **#58 has since landed** as `8ec08e91`, which reaches this branch through #59 and #66 (`03825eb5`, no content change: T057's files here equal `main`'s byte for byte). - So this PR's diff is now **T058's own seven files**. Until #58 landed, it also showed #58's delta. - **T058's own changes are six commits**: `3d0b6d66` (six files, listed below), and `28241a4b`, `69ca0e2e`, `1ec7d2c9`, `c7768ed5` and `cd6b33cb` (Copilot's findings, below). - #58 and #59 fork from #57 at the same commit, `8e7da4a2`, so the merge was clean and brought only #58's own 55 files. - **Gated on nothing but its own review.** #57 (`a691e4e4`), #58 (`8ec08e91`), #59 (`fa140875`) and #66 (`a23e4224`) have all landed. - **The base is `main`.** It was retargeted before #66 landed, since a `--delete-branch` landing of #66 would have closed it. The diff against `main` is T058's own seven files again. ## What T058 changes **`src/opendox/default_projection.py`: openDox's own validator takes the stand-in's place.** The stand-in, `OwnValidatorNotBuilt`, answered every validation "unavailable, T057 is not here". - **One adapter per own kind.** `OwnValidator(kind)` keeps the lookup's protocol, `validate(path, *, strict, search_from)` → `projection_seams.ValidationResult`. - The seam registers one validator per kind and hands it only a path. So the adapter knows its kind from where it is registered. - `VALIDATORS` holds one for each of `OWN_KINDS`: `opendox-snapshot` and `ideation-workbench`. - `projection_seams.register_defaults()` registers each under its kind (a one-line change). - `OWN_KINDS` is not widened. The doxBench wire kinds reach `opendox.validator` through their own seam (T085). - **It reads the document as its kind is written.** - The snapshot is read as JSON, strictly: NaN, the infinities and a key given twice are refused. - The manifest is read as YAML with `safe_load`, as `workbench.py` reads it. - Then `opendox.validator.validator_for(kind)` judges the document against the packaged copy, which `opendox.contracts` proves against its recorded digest on every call. - **Three outcomes**, which `cli._validate` already turns into consequences: | the adapter meets | outcome | what the verb does | |---|---|---| | no violation | `validated` | prints `validation: opendox-snapshot: 0 violations, by opendox.validator, over its packaged copy opendox-snapshot (sha256 f9e3e111af1d)`, exit 0 | | any violation | `not-conformant`, rc 1; stdout is one `[<rule>] <where>: <detail>` line per violation, then a count | "validation FAILED … This is the SNAPSHOT", relays the lines on **stderr**, exit 1 (with or without `--strict`) | | a document that cannot be read as JSON (or YAML) | `not-conformant`, rule `document-syntax` | as above | | a readable document holding a number that cannot be read as written (an infinity, a NaN, one binary64 would round, or an unprovable spelling) | `not-conformant`, rule `document-number` | as above | | `ValidatorUnavailable` (a copy failing its identity check, or not evaluable), `UnknownKind`, or a document that cannot be read | `validator-unavailable`, with the reason | "validation SKIPPED … could not run: <reason>", exit 0; **exit 1 under `--strict`** | - **`strict` and `search_from` change nothing** in the adapter. openDox's validator has no warnings to harden, and it searches for nothing, since its schemas are package data. `dependency_remedy` is `None`: no subprocess runs. - So F7.2's "no `No such file or directory`" holds by construction. - `--strict` still means what the verb's help says, through `cli._validate`. **The workbench manifest's two validator rules, carried (for the holder).** - The manifest schema says of two rules that it cannot state them, and leaves them to the validator: - every `recipe.pinned` keyword is also in `recipe.checked`; - no `recipe.new_candidates` document is already a member or excluded. - The consumer's script (`validate-ideation-dashboard-contracts.py`, `check_workbench_rules`) checked both. `opendox.validator` checks the schema only, as #58's body says. - The holder decided (2026-09-28, "To T055: carry two workbench rules") that routing `validate_manifest` to openDox's validator must not drop them. T055 routed it to the stand-in, so they fall due here. - The adapter carries them for `ideation-workbench`, under the script's identifiers, `workbench-pinned-not-checked` and `workbench-candidate-overlap`. They are judged beside the schema, and are total over any shape. - If the holder prefers them in `opendox.validator` itself, that is a move within #58's module, and the ids stay. **The schema copy.** - `tests/test_neutral_projection.py` reads the neutral contract from the packaged copy, through `opendox.contracts.verified_bytes("opendox-snapshot")`. - T054's `tests/fixtures/opendox-snapshot.schema.yaml` and its `SCHEMA_SHA256` are removed. The bytes were identical (`f9e3e111…584a` both), so no case's verdict moved. - The digest case now asserts that the bytes read are the recorded ones, that a strict JSON read equals `contracts.load()`'s YAML read, and that the tree carries one copy. **The stand-in's cases in `tests/test_projection_seams.py`**, as T055's hand-off listed them: | before | after | |---|---| | `test_the_validator_stand_in_concludes_nothing_and_names_T057` | `test_openDoxs_own_validator_is_bound_to_each_own_kind` | | `test_openDoxs_own_kind_meets_the_stand_in_and_strict_makes_it_fatal` | `test_openDoxs_own_kind_meets_openDoxs_own_validator` (a bare snapshot is now REJECTED, naming `[envelope-keys]`), and `test_openDoxs_own_validator_unavailable_is_skipped_and_strict_makes_it_fatal` (a copy refused by `opendox.contracts`: skipped, then fatal under `--strict`) | | the stand-in half of `test_a_manifest_is_validated_by_the_validator_for_its_kind` | a bare manifest is now judged, naming `[required]` | Two identity asserts also move from `default_projection.VALIDATOR` to `VALIDATORS[kind]`. **`tests/test_post_render_validator.py` (new, 29 cases):** - F7.2 through `python -m opendox.cli generate --strict`, with the siblings refused by T056's `tests/standalone_child.py`; - `generate-and-open --no-open --no-serve --strict` over both fixtures; - `--no-validate`; - the three outcomes, including five not-JSON documents, an unreadable path, `ValidatorUnavailable`/`SchemaNotEvaluable`, and a copy tampered below `opendox.contracts`; - `strict`/`search_from` inert; - each validator reading as its own kind; - the two workbench rules, their bounded detail, and `workbench.save(validate=True)` keeping a valid manifest and unwinding a broken one. ## F7.2, failing before and passing after **#1144's F7.2, verbatim**: a fresh venv, `pip install .` (package data on disk, a non-editable install), both fixtures as fresh repositories, `generate --strict` twice, the rule grep, and the negative grep asserted as exit status 1. - **Before**, at this branch's base (`3b13f141`: #59 + #66 + #58, with the stand-in), it exits **1** on the good fixture's `--strict` run: ``` validation SKIPPED — this snapshot was NOT checked against the pinned schema the validator registered for kind 'opendox-snapshot' reached no verdict. … openDox's own validator is plan 034's T057, and this build does not carry it yet, so nothing of openDox's own kinds is checked --strict was given and it means what it says: a run that COULD NOT be validated FAILS rather than continuing unchecked ``` - **After**, at `cd6b33cb`, and again at `5322efee`, after `main` was merged in, it exits **0**. The malformed run's stderr: ``` validation FAILED — the pinned validator REJECTED …/bad.json. This is the SNAPSHOT, not the environment: the validator ran fine and found the data non-conformant. [title-and-summary-are-text] /documents/1/title: '' is shorter than 1 1 violation(s) of the opendox-snapshot contract, by opendox.validator, over its packaged copy opendox-snapshot (sha256 f9e3e111af1d) ``` `EXPECTED_RULE` is `title-and-summary-are-text`, and no `No such file or directory` appears. **`tests/test_post_render_validator.py`**: at the base, with the stand-in, **26 failed and 2 passed**. The two that pass hold what T058 does not change: `--no-validate`, and `EXPECTED_RULE` being one of the contract's rules. At `3d0b6d66`, **29 passed**. At this head `1678ccd0`, with Copilot's later rounds, **50 passed**, and also 50 under `--noconftest`. ## Mutation check: 29 of 29 killed, re-run at this head Each mutant was applied, the named cases were run, and the sources were restored and checked by sha256. | mutant | killed by | |---|---| | M1 violations answer `validated` | 17 cases | | M2 violations answer `unavailable` | 12 | | M3 the rule lines are dropped from stdout | 17 | | M4 `ValidatorUnavailable` read as a pass | 4, including the `--strict` case | | M5 NaN admitted as JSON | 1 | | M6 a repeated key admitted | 1 | | M7 the pinned rule dropped | 4 | | M8 the overlap rule dropped | 1 | | M9 the overlap ignores `excluded` | 1 | | M10 the validator reads the document's `kind`, not its own | 1 | | M11 the entry points register only the snapshot's validator | 2 | | M12 the rules compare unhashable entries | 1 | | M13 an unreadable document reads as valid | 1 | | M14 `--strict` does not make an unavailable validator fatal (`cli.py`) | 1 | | M15 `--no-validate` does not skip (`cli.py`) | 4 | | M16 T054's fixture copy of the schema comes back (a tree mutant) | 1 | | M17 a rule's detail quotes every name | 1 | | M18 name membership tested against the list again (quadratic) | the linear-time case, at 17.0 s | | M19 an `OSError` from the lookup escapes | the unreadable-file case | | M20 a quoted name is not cut | the long-name case | | M21 a key given twice picks the last `kind` again (`cli.py`) | the doubled-kind case | | M22 a non-finite number is read as JSON | the `1e999` and YAML `.inf`/`.nan` cases | | M23 a rounded number is read as written | the `1.0000000000000001` and `1.5e-400` cases | | M24 every inexact binary fraction refused (over-strict) | the controls (`0.1`, `2.50`, …) | | M25 the manifest's floats are read unproved | the four manifest-number cases | | M26 the JSON read proves no float | the snapshot number cases | | M27 an unprovable number spelling keeps its float | the two base-60 manifest cases | | M28 a refused number is reported as a syntax error | the number-rule cases | | M29 the syntax message names the kind as an adjective again ("a 'opendox-snapshot' document") | the two exact-message syntax cases (6 failed) | ## The repository's own checks The whole suite ran locally as CI runs it: `CI=true`, `LANG=C.UTF-8`, PostgreSQL 16, `-e ".[runtime,test]"` with the constraints file, at the committed head, with a clean tree. | tree | passed | skipped | |---|---|---| | base `3b13f141` | 2948 | 11 | | `3d0b6d66` (T058's commit) | 2978 | 11 | | `09cd1e8a` (#66's `42a08a31` merged in) | 2979 | 11 | | `28241a4b` (Copilot's two findings) | 2981 | 11 | | `21e4723f` (#66's `5a26532e` and #58's `3351f6a7` merged in) | 3010 | 11 | | `69ca0e2e` (#66's `e939c31f` merged in, and Copilot's second round) | 3014 | 11 | | `80153754` (Copilot's third round, and #58's `753ffa19` merged in) | 3031 | 11 | | `c7768ed5` (#66's `e3574774` merged in, and Copilot's fourth round) | 3033 | 11 | | `cd6b33cb` (#66's `38761c76` merged in, and Copilot's fifth round) | 3034 | 11 | | `923f30d8` (#66's final head `a7bda066` merged in), run under `nohup … &` | 3036 | 11 | | `5322efee` (`main` merged in, with #66 and #70 landed), run under `nohup … &` | 3044 | 11 | | this head `1678ccd0` (Copilot's sixth round: the syntax message's wording), run under `nohup … &` | **3044** | **11** | - The junit diff at `3d0b6d66` shows **+32 added** (29 in the new file, 3 in `test_projection_seams.py`) and **2 removed** (the two stand-in cases above, replaced). At `09cd1e8a` it shows +33: the extra case is #66's own. - At `923f30d8`, against `cd6b33cb`, it shows **+2**: #66's `test_a_child_stops_on_the_interrupt_even_when_the_runner_ignores_it` and #59's `test_a_regenerate_promotes_no_session_and_moves_no_active_key`. At `5322efee`, against `923f30d8`, it shows **+8**, all from #70's `tests/test_edit_action_one_entry.py`. At this head, against `5322efee`, it shows 0 added, 0 removed and 0 changed. - **0 changed** outcomes, and the same 11 skips. - The mutation check was re-run at `923f30d8` and `5322efee` (28 of 28 killed both times), and at this head, where it is **29 of 29**. - **F4.1's deferred-reach scan**: 11 at the base and 11 here, the same list. The adapter imports `opendox.validator` and PyYAML when a validation runs, and names no sibling. - No floor, workflow, `conftest.py`, `pyproject.toml` or pin is touched. ## Files (T058's own commits) - `src/opendox/default_projection.py`: `OwnValidator`, `VALIDATORS`, `SYNTAX_RULE`, `NUMBER_RULE`, `WORKBENCH_RULES`. The stand-in is removed and the docstring rewritten. - `src/opendox/projection_seams.py`: `register_defaults()` registers `VALIDATORS[kind]`. - `src/opendox/cli.py` (`69ca0e2e`): `_written_kind` refuses a key given twice, and `_validate` fails on it. These seven files are the whole of the PR's diff now that #58 has landed. - `tests/test_projection_seams.py`: the stand-in cases above. - `tests/test_neutral_projection.py`: it reads the packaged copy. - `tests/fixtures/opendox-snapshot.schema.yaml`: removed. - `tests/test_post_render_validator.py`: new. It is a created file, with no carve-manifest row (RULED OQ-C). ## Copilot - At `3d0b6d66`, "Needs a closer look", with two findings. Both are fixed in `28241a4b`, answered with evidence, and resolved: - **r4139734412**: an unreadable packaged record or copy escaped `validator_for()` as a `PermissionError` traceback. `opendox.contracts` converts only a missing file. - Measured with `copies.yaml` at mode 000: `generate --strict` exited 1 with the traceback. - The adapter now reports an `OSError` from the lookup as validator-unavailable, and the verb warns, or fails under `--strict`, in its own words. - The root conversion is #58's file, and it has been relayed to #58's owner. - New case: `test_a_packaged_file_that_cannot_be_read_is_unavailable_not_a_traceback`. - **r4139734444**: `_names()` was quadratic, and the schema bounds none of the three lists. Membership is now a set's. New case: `test_the_rules_read_a_long_list_in_linear_time`, which took 17.5 s before the fix and 0.01 s after. - At `21e4723f`, "Needs a closer look", with four findings, each answered with evidence and resolved: - **r4139769819**: the verb chose a validator by `kind` with plain `json.loads`, which keeps the last of two keys. So `"kind": "opendox-snapshot", "kind": "unknown"` found no validator, and an ordinary run exited 0. - Fixed in `69ca0e2e`: `cli._written_kind` refuses a key given twice, and the verb fails whatever `--strict` says. New case: `test_a_kind_given_twice_chooses_no_validator_and_fails`. - NaN and the infinities are left to the chosen validator, since they do not make the kind ambiguous. - **r4139840593**: `1e999` reads as `inf` without `parse_constant`. Fixed in `69ca0e2e` (`parse_float=_finite`), with two new not-JSON cases. - **r4139769791**: a quoted name was not cut. Fixed in `69ca0e2e`: each is cut at 80 characters. New case: `test_a_rules_detail_cuts_a_long_name`. - **r4139769759** (`validator.py`, #58's file): `_close` consuming earlier siblings' canons at `count == 0`. **Not reproduced**: the slice is `done[len(done) - count:]`, which is empty at 0, and `_canon([1, []])` and `_canon([[], 1])` are distinct (`a2:n1:1a0:`, `a2:a0:n1:1`). No change here; the note went to #58's owner. - (r4139734412's root, `opendox.contracts` refusing an unreadable file, has since landed in #58 as `2b8ad24`, merged in here. With it, a record at mode 000 gives `could not run: opendox.contracts has copies.yaml, and it cannot be read (PermissionError: Permission denied)` and no traceback. The adapter's own `OSError` guard stays as defense in depth.) - At `69ca0e2e`, one finding, answered with evidence and resolved: - **r4139937566**: `float()` rounds `1.0000000000000001` to `1.0`, which meets `const: 1`. A manifest so written read as "0 violations", and jsonschema 4.26 reads the snapshot case the same way. - The contract has no `number` type, so rather than carry decimals through #58's validator, `1ec7d2c9` refuses a float literal that is not finite, or not equal to the shortest spelling of the float read from it, under `document-syntax`. The same proof applies to the manifest's YAML floats. - `0.1`, `2.50`, `1E2` and every float openDox's writer writes read as written. - Six new cases fail without the fix, and seven controls pass either way. - At `80153754`, one finding, answered with evidence and resolved: - **r4146201125**: a YAML base-60 float (`0:1.0000000000000001`) is read and rounded by PyYAML, but `Decimal` cannot parse it, so the proof let it through, and the manifest read as "0 violations". - Fixed in `c7768ed5`: a spelling the proof cannot compare is refused, under `document-syntax`. - Two new cases fail without the fix, and mutant M27 is killed. - At `c7768ed5`, one finding, answered with evidence and resolved: - **r4146428769**: a valid document refused for a number was reported as "cannot be read as YAML/JSON". - Fixed in `cd6b33cb`: such a number breaks a rule of its own, `document-number`. `document-syntax` stays for a document that cannot be read at all. - Ten cases fail without the change, and mutant M28 is killed. - At `cd6b33cb`, "Needs a closer look", with nothing open. - At `5322efee`, "Needs a closer look", with one finding, answered with evidence and resolved: - **r4148179148**: `document-syntax`'s message read "a 'opendox-snapshot' document", which takes the wrong article. - Fixed in `1678ccd0`: it now reads "a document of kind 'opendox-snapshot'". - The two exact-message cases, updated first, failed against the old wording (6 of 6 runs), and mutant M29 is killed. - At this head `1678ccd0`, a review is re-requested through the reviewer API. ## For the holder 1. **The two workbench rules** (above): carried in the adapter, under the consumer script's ids. Tell me if they belong in `opendox.validator` instead. 2. **The verb relays at most the last 20 lines** of a rejection (`cli._report_non_conformance`, T055's, unchanged). A snapshot breaking more than 19 rules shows the count line and the last 19. That is enough for F7.2's single rule, and not changed here. Arc: neutral-product-standalone-operability Lane: openxfactory-4 (openXfactory-4-openDox_extraction) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Arc: neutral-product-standalone-operability Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Main now carries T054 to T058, T055's follow-up (#70) and T056's standalone test. This PR edits src/opendox/runtime/config.py and tests_runtime/test_runtime_cli.py, and main touches neither, so the merge is clean. Full suite on the merged tree: 3061 selected, 3050 passed, 11 skipped, 0 failed. EXPECT_SKIPPED=11 holds exactly, and the floors are met. Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Arc: neutral-product-standalone-operability Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
T071 (#60) now carries main 047bb4f: phase 2, with T054 to T058, T055's follow-up #70 and T056's standalone test. Git auto-merges cli.py and test_doxbench_entrypoint.py without a conflict: main's _refuse_empty_source_options sits after the install shape is resolved, and --local still precedes --host. Four callers on main relied on generate-and-open's old default, and since this PR an unflagged run is HOSTED and refuses without its broker's issuer. They get --local in the next commit, which T070 owes now that T056 has landed. Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Arc: neutral-product-standalone-operability Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
T070 (#67) now carries T071's merge of main 047bb4f: phase 2, with T054 to T058, T055's follow-up #70 and T056's standalone test. It also carries the four generate-and-open callers that now say --local. Git auto-merges pyproject.toml (main's validator package data beside this PR's local extra and data files), src/opendox/cli.py and tests/test_doxbench_entrypoint.py without a conflict. On their own, the merged callers run --local, and here that starts the bundled server. Three of them would do so under the user's own state directory. The stand-in driver no longer stands in for anything, so three bundled cases fail on this merge alone. The next commit takes both in hand. Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Arc: neutral-product-standalone-operability Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… collapsed DSN pair (plan 034) (#60) Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Plan 034 (`specs/034-opendox-standalone-operation/tasks.md`, read at openxFactory `main` `e369cb25`), phase-3 slice **P3-I, install mode and the bundle**, its first task only: - **T071** (#1144's 13.2 and 13.3). `load_settings` refuses a non-PostgreSQL DSN, naming the one dialect kept. It refuses the same credential in both settings, naming `OPENDOX_MIGRATION_DATABASE_URL`. **`OPENDOX_MIGRATION_DATABASE_URL` is required only for the `migrate` path** (RULED, see below) — `load_settings` (served/status/init/project-verb) keeps it optional; `load_migration_settings` (migrate/reset) already required it, independently of this PR. Falsifier: F13.1's `load_settings` block. After: T063, T069 (both done: T063 landed as openxFactory#1218 → `a883bbf6`). Claimed on openxFactory#656 in [`5876416600`](opensoft/openXfactory#656 (comment)). **Authored ahead under the phase-3 draft-ahead rule** (Brett, 2026-09-28 ~18:00Z: *"Only the independent ones (Recommended)"*). Only T071 and T078–T080 (P3-B, a separate stacked PR) are drafted before T063. This PR stayed DRAFT until T063 had landed and the holder said so. **T063 has landed** (openxFactory#1218 → `a883bbf6`, 2026-10-02 23:37:43Z), which closes phase 2, so phase 3 is open and this PR is the first of its stack to go READY. **Not T070.** 13.4–13.6 (`OPENDOX_INSTALL_MODE`, and the `--local` flag) are untouched — T071's own `After:` line names T063 and T069 only, and nothing here reads or names `OPENDOX_INSTALL_MODE`. 13.2/13.3 build cleanly without it. ## What it does - **13.2 — the dialect.** `_refuse_non_postgresql_dsn` (new) refuses either DSN whose URI scheme is not `postgresql://` or `postgres://`, naming the setting and the dialect found. The keyword/value conninfo form (`host=h dbname=d …`) names no dialect at all and is unaffected — that syntax is libpq's own grammar, and no other driver reads it. A DSN `urlsplit` itself cannot parse (an unbracketed IPv6 host, measured) is a named `ConfigurationError`, never a bare exception — the same shape `_split_url` already covers for the broker settings. This check is a no-op on an ABSENT migration DSN — see 13.3. - **13.3 — the collapse is refused; the migration DSN is required only for `migrate`.** - `OPENDOX_MIGRATION_DATABASE_URL` stays **optional** in `load_settings` (`Setting`'s `required` flag is `False`, `_optional` reads it, `RuntimeSettings.migration_database_url` keeps `str | None`) — RULED "Required only for migrate" (Brett, openxFactory#656, on the claim thread for plan 034's T071, 2026-09-28; see "Resolved by ruling" below). It is never defaulted from `OPENDOX_DATABASE_URL`. `load_migration_settings` (the `migrate`/`reset` loader) is unaffected either way: it already independently required one. - `_refuse_the_same_dsn_in_both_settings` (new) refuses the two DSNs being the exact same STRING, naming `OPENDOX_MIGRATION_DATABASE_URL` — asked only once the two are already known to **agree** on where they land (the existing `_refuse_two_dsns_that_select_different_schemas`, unchanged, now runs first): two DIFFERENT secrets for one role still pass, exactly as the existing "single-role install" case (`test_a_dsn_that_names_no_database_still_reaches_one`) documents. - Both `_refuse_non_postgresql_dsn` and `_refuse_the_same_dsn_in_both_settings` are **no-ops when the migration DSN is absent** (the same shape `_refuse_two_dsns_that_select_different_schemas` already used for "nothing to compare"), and run exactly as before — dialect → schema-mismatch → collapse — whenever both DSNs are actually given. Optional does not mean unchecked. ## The ripple (opened, then reverted, by the ruling) An earlier version of this PR (`91f7973`) made the migration DSN required, which broke 27 existing call sites across five test files. The ruling above keeps it optional, so that ripple has been **reverted in full**, back to `main`: - `tests_runtime/conftest.py`, `test_api_endpoints.py`, `test_migrations_apply.py` and `test_runtime_surface.py` are byte-for-byte `main` again — no `migration_dsn` fixture, no threading, nothing. - `test_runtime_cli.py`'s 20 touched call sites (individual `monkeypatch.setenv` blocks, `base`/`env` dicts, the shared `_stub_uvicorn` helper) are reverted the same way. - `test_two_dsns_that_select_different_schemas_are_refused`'s "AND A MIGRATION DSN THAT IS SIMPLY ABSENT" case is back to **accepted** (`assert load_settings(...)`), which is what the setting being optional again means for that test — with a one-line note on why it was briefly the opposite. - **Six tests now cover 13.2/13.3 directly**, three unchanged from before plus three new ones: `test_a_non_postgresql_dsn_is_refused_naming_the_dialect_kept`, `test_an_unparseable_dsn_is_refused_and_never_raises_a_bare_valueerror`, `test_the_same_dsn_in_both_settings_is_refused_naming_the_migration_one` (all three test `load_settings` directly, both DSNs always given), plus `test_serve_and_status_load_with_no_migration_dsn_configured` and `test_the_collapse_is_refused_through_the_served_workload_too` (both at the CLI dispatch level — `status`/`serve` — rather than only through `load_settings` called directly), plus `test_migrate_refuses_a_non_postgresql_migration_dsn_at_configuration` (`f097fd8`, a follow-up Copilot review round — see below). `test_migrate_refuses_rather_than_borrowing_the_served_identity` (pre-existing, untouched) already covered "migrate refuses without it." ## Fix round: `load_migration_settings` gets the same dialect gate (`f097fd8`) Copilot's re-review of `b5296f9` found that 13.2's dialect gate was wired into `load_settings` only. `load_migration_settings` — the loader `runtime migrate`/`reset` actually use — checked only that the migration DSN was non-empty and handed it straight to `Database`, so a non-PostgreSQL migration DSN reached the driver instead of being refused by name at configuration: the same un-named failure 13.2 exists to prevent for the served loader, reachable through the one path F13.1's own falsifier does not call. Fixed with one more call to the existing `_refuse_non_postgresql_dsn`; `test_migrate_refuses_a_non_postgresql_migration_dsn_at_configuration` is the dialect-refused twin of the existing `test_migrate_and_reset_need_no_served_identity_and_no_broker` (which shows an unreachable-but-valid-dialect migration DSN getting PAST configuration). [Finding](#60 (comment)) and [reply](#60 (comment)), thread resolved. A second finding from the same round ([here](#60 (comment))) read a stale, pre-ruling snapshot of this body ("required" language) — by the time it posted, the body already said "optional… required only for migrate" throughout. [Replied](#60 (comment)) noting the race and inviting a quote of any sentence still reading that way; thread resolved. ## The falsifier (F13.1's `load_settings` block) Quoted from `openspec/changes/add-neutral-product-standalone-operability/tasks.md`, run against this branch: ``` from opendox.runtime.config import ConfigurationError, load_settings OK = {"OPENDOX_OIDC_ISSUER": "https://issuer.example.invalid/realms/fixture", "OPENDOX_OIDC_AUDIENCE": "fixture"} def refusal(**dsns): try: load_settings({**OK, **dsns}) except ConfigurationError as e: return str(e) raise AssertionError(f"accepted: {dsns}") m = refusal(OPENDOX_DATABASE_URL="sqlite:///x.db", OPENDOX_MIGRATION_DATABASE_URL="sqlite:///x.db") assert "postgres" in m.lower(), f"a second dialect was refused for the wrong reason: {m}" one = "postgresql://one@127.0.0.1/opendox" m = refusal(OPENDOX_DATABASE_URL=one, OPENDOX_MIGRATION_DATABASE_URL=one) assert "OPENDOX_MIGRATION_DATABASE_URL" in m, f"a collapsed pair was refused for the wrong reason: {m}" ``` Both assertions pass on this branch (verified interactively; both calls give both DSNs, so the ruling above does not change either outcome; T074 is the task that runs F13.1 whole, later in Group 13, after T072/T073 exist). ## The repo's own suite Measured locally against this branch: this sandbox's host-mapped loopback ports are unreachable (a local environment quirk, not this change — even a fresh container's freshly-published port refuses a host-side connection here), so Postgres is reached at the container's own bridge IP instead of `127.0.0.1`, which is otherwise identical to `validate.yml`'s own DSN shape. ``` python -m pytest -q 2473 passed, 11 skipped, 1 failed in ~195s ``` The one failure, `tests/test_model_provider_broker.py::test_the_broker_child_inherits_no_credential_shaped_environment`, is **pre-existing**: it is red the same way against unmodified `main` (`2d116415`) in this same sandbox (an ambient `LC_CTYPE` this environment sets and the check's allowlist does not name) — unrelated to `runtime/config.py`, and not touched by this PR. It does not reproduce in this PR's own CI (below), confirming the sandbox-only attribution. Against `main`'s own last recorded CI triple (2479 selected / 11 skipped, `validate.yml`'s own comment history) this change is **+6 / +6 / +0** — six tests (three carried over, three new: two for the ruling, one for the follow-up fix round below), nothing lost, the original ripple fully reverted. `validate.yml`'s `Pin the triple` floors (`MIN_SELECTED=2476`, `MIN_PASSED=2465`, `EXPECT_SKIPPED=11`) permit the rise unchanged; I have not touched them. **This PR's own CI (`f097fd8`): `validate` and `SonarCloud Code Analysis` both green.** ## Merge-from-main round (`adeb6fed`, 2026-10-02) Phase 2 has landed, so this branch merges main `047bb4fa`: T054 to T058, T055's follow-up #70 and T056's standalone test. - **The merge is clean.** This PR edits `src/opendox/runtime/config.py` and `tests_runtime/test_runtime_cli.py`, and main touches neither. - **Full suite on the merged tree**, run with `LANG=C.UTF-8` and `CI=true` against a `postgres:16`: `3061 selected, 3050 passed, 11 skipped, 0 failed`. `EXPECT_SKIPPED=11` holds exactly, and the floors are met. - **The sandbox-only `LC_CTYPE` failure above does not reproduce in this run.** It runs with `LANG=C.UTF-8`. - **#67 (T070) and #69 (T072) stack on this branch** and take this head in their own merge rounds. ## Fix round: a PostgreSQL scheme libpq would not read as a URI is refused (`c39d960e`) Copilot's review at `adeb6fed` noted that `postgresql:foo` was still accepted. [Answered on the PR](#60 (comment)). - `urlsplit` reads `postgresql:` without `//`, and any capitalized `PostgreSQL://` or `POSTGRES://`, as the PostgreSQL scheme. libpq reads none of them as a URI, and its refusal **repeats the whole value**, password included (measured). - The dialect gate now refuses a PostgreSQL scheme in any spelling but libpq's two (`postgresql://`, `postgres://`), naming the setting and never the value. - The new case covers 8 inputs. All fail against `adeb6fed` and pass here, and 5 mutants are killed. - Full suite: `3069 selected, 3058 passed, 11 skipped, 0 failed`. ## Resolved by ruling Brett ruled on the conflict Copilot's review found (openxFactory#656, on the claim thread for plan 034's T071, 2026-09-28), choosing **"Required only for migrate (Recommended)"**: - Keep both refusals: the non-PostgreSQL DSN, and one credential given in both settings. - Require `OPENDOX_MIGRATION_DATABASE_URL` only on the `migrate` path. - `serve` and `status` keep it OPTIONAL, and it is never defaulted from `OPENDOX_DATABASE_URL`. - When both are given, the collapse refusal still applies. This matches #1144 13.3's own text and `deploy/compose/docker-compose.yaml`'s separation (the `opendox` service never gets a migration DSN; `docs/runtime.md` § 3 never lists it as required) — **neither file needed a change**; both already documented the now-ruled behavior. The plan's "stops being optional" line is a holder-side correction, not part of this PR, and #1144's own wording is unchanged. Reworked in `b5296f9` per the ruling: the required→optional flip is reverted, the 27-site ripple it forced is reverted with it, and two new CLI-level tests (`test_serve_and_status_load_with_no_migration_dsn_configured`, `test_the_collapse_is_refused_through_the_served_workload_too`) prove the ruled shape end to end. [The original finding](#60 (comment)) and [my first reply](#60 (comment)) (flagging it for a ruling) are in the review thread, [now closed out citing the ruling](#60 (comment)) and marked resolved. ## Scope Touches: `src/opendox/runtime/config.py`, `tests_runtime/conftest.py`, `tests_runtime/test_api_endpoints.py`, `tests_runtime/test_migrations_apply.py`, `tests_runtime/test_runtime_cli.py`, `tests_runtime/test_runtime_surface.py`. Nothing else — no `conftest.py` at the repo root, no `pyproject.toml`, no workflow file, no `README.md`, no pin, no `deploy/`, no `docs/`. No `openspec/changes/` path, so no Rule 6 window applies. The holder's lander merges. T063 has landed (openxFactory#1218 → `a883bbf6`), so the holder un-drafts it. Arc: neutral-product-standalone-operability 🤖 Generated with [Claude Code](https://claude.com/claude-code) Arc: neutral-product-standalone-operability Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ild (plan 034) (#69) Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Arc: neutral-product-standalone-operability Plan 034 (`specs/034-opendox-standalone-operation/tasks.md`, read at openxFactory `main` `91e4685f`), phase-3 slice **P3-I, install mode and the bundle**: - **T072** (#1144's 13.1): the bundled PostgreSQL server, as T007 batch H's 13.1 addendum reads (openxFactory#1206 → `f99a2097`). - **Falsifier:** F13.1's TCP-listener block, which reads the kernel's socket table at run time, and its `runtime status` block. - **After:** T070 (openDox-code#67, landed as `66ff7257`). It was stacked on #67's branch; the holder has retargeted it to `main`, and `57b7ed8f` merges main `66ff7257`, so this diff is T072 alone. **Ruled:** - R1Q22 (a), `5817152735`; - R1Q16 (i)–(iv), `5850003126`; - the phase-3 draft-ahead widening, `5901112350`. Claimed on openxFactory#656 in [`5901575394`](opensoft/openXfactory#656 (comment)). **Authored ahead as a DRAFT**, which did not go READY before T063 landed and the holder said so. **T063 has landed** (openxFactory#1218 → `a883bbf6`, 2026-10-02 23:37:43Z), which closes phase 2, so phase 3 is open. #60 (`7ff434d9`) and #67 (`66ff7257`) ahead of it have landed. ## What it does, by R1Q16's four parts - **(i) The document server starts it as its own child, and reports it.** - `opendox generate-and-open --local` (or `OPENDOX_INSTALL_MODE=local`) starts `postgres` as a **direct child** of the process serving the document surface. It uses `subprocess.Popen` and never `pg_ctl`, which would re-parent it. - It prints the socket, the pid and what it migrated. - `runtime status` reports `database_bundle` (`data_dir`, `socket_dir`, `pid`). It reads the pid from the server's own `postmaster.pid` and believes it only while a postgres runs there. - **(ii) Started and migrated, and nothing more.** - `initdb` runs once per data directory. - An idempotent bootstrap makes the database and the SERVED role. Its grants are the compose stack's (`init-runtime-role.sh`): CONNECT, USAGE on `public`, and DML on what the owner creates, by default privileges. - Then `migrations.MigrationRunner` runs as the owner, with the served role and database declared. The run narrows the ledger to SELECT for the served role and verifies its access, exactly as a hosted `runtime migrate` does. - `runtime migrate` under `local` migrates the bundle too. - **(iii) It ships as the `opendox[local]` extra**, which is `opendox[runtime]` plus `pixeltable-pgserver>=0.6.0` (RULED, openxFactory#656 `5916000030` item 2). **The `test` extra joins it**, so F9.1's `.[test]` install still runs every case. - **(iv) It stops with the entry point.** - SIGTERM is read as the Ctrl-C the serve loop already stops on, followed by a PostgreSQL fast shutdown (then an immediate one, then SIGKILL, each bounded). - The backstop is `PR_SET_PDEATHSIG` on Linux, so a SIGKILLed entry point still takes its server with it. - The server runs in its own session, so a terminal's Ctrl-C reaches the entry point, and the stop happens in order. ### 13.1's fixed identity - **The data and socket directories live under `OPENDOX_STATE_DIR`**, at `<state>/postgres/data` and `<state>/postgres/run`. - The setting is new. It defaults to `$XDG_STATE_HOME/opendox`, else `~/.local/state/opendox`, and must be absolute, because the server's process and a `runtime status` run from elsewhere must derive the same socket. - A state directory too long for the kernel's `sun_path` is refused, naming the setting. - **No TCP listener:** `listen_addresses` is empty, and the socket directory is narrowed to 0700. - **Peer authentication** (RULED, openxFactory#656 `5916000030` item 3, *"Peer auth + accept (Recommended)"*): - `initdb` runs with `--auth-local=peer --auth-host=reject`. - Before every launch the bundle rewrites `pg_hba.conf` and `pg_ident.conf` (atomically, mode 0600). `pg_hba.conf` holds one rule, `local all all peer map=opendox`, plus `host … reject` for IPv4 and IPv6. `pg_ident.conf` maps the running OS user, and nobody else, to `opendox` and `opendox_runtime`. - The kernel reports the connecting uid, so the DSNs carry no password because there is none. A cluster an older build left as `trust` is put back to peer on its next start. - **Both DSNs are supplied:** two users (owner `opendox` for migrations, `opendox_runtime` for serving) over the one socket, with `port` spelled so a stray `PGPORT` cannot redirect libpq. They pass T071's three checks for the reason those exist: one dialect, one database, and never one credential in both settings. - **An operator DSN given beside `local` is refused by name.** It is added to T070's `HOSTED_ONLY_SETTINGS`, a holder reading on openxFactory#656 that Brett may overrule. - **A second entry point on the same state directory is refused**, naming the running pid. One install's database belongs to one entry point at a time. ### The migrations gap (assigned to T072 by the holder) - The migrations were not package data. `migrations/` sits at the repository root, and only the image copies it (`WORKDIR /app`), so `pip install "opendox[local]"` run outside a checkout had nothing to apply. - Now `pyproject.toml`'s `[tool.setuptools.data-files]` maps `migrations/*.sql` into the wheel's data directory (`share/opendox/migrations`). **The root `migrations/` does not move.** - `config.migrations_dir` resolves an unset `OPENDOX_MIGRATIONS_DIR` in this order: 1. `migrations` wherever the working directory has one (a checkout, or the image's `/app`), which is **today's default, unchanged**; 2. otherwise the copy the installed distribution's `RECORD` lists (`packaged_migrations_dir`); 3. for an editable install, which installs no data files, the source tree's own `migrations/`. - The canonical digest gate is what proves any copy found is the pinned one. - `test_a_wheel_install_migrates_its_bundled_server_outside_a_checkout`: - builds this package's wheel offline (`--no-build-isolation`, `--no-index`); - installs it under a `--prefix` outside the checkout; - runs from a directory with **no** `migrations/`, asserting that `opendox` is the wheel's copy and that the migrations dir is under the prefix's `share/opendox`; - migrates the bundled server there (`applied == ["0001", "0002"]`). ### The server package (RULED, openxFactory#656 `5916000030` item 2: *"pixeltable-pgserver (Recommended)"*) - **`pixeltable-pgserver` 0.6.0**, the maintained fork of `pgserver`, uploaded 2026-07-14. Apache-2.0, as its dist-info `LICENSE` and OSI classifier say. It carries **PostgreSQL 16.14** under the PostgreSQL License (`initdb --version` and `postgres --version` from `pixeltable_pgserver/pginstall/bin`). It also carries an 18.4 under `pginstall18/`, which this package does not use. - **Only its binaries are used**, found with `importlib.util.find_spec("pixeltable_pgserver")` without importing it. Its own manager is not used, because: - it daemonizes through `pg_ctl`, against (i); - it stops from `atexit`, which SIGTERM never runs, against (iv); - it may put the socket under the user's runtime directory, opened to 0777, against 13.1. - **Linkage, re-verified on the installed wheel** (`readelf -d`, `ldd`): - `postgres` needs `libz`, `libpthread`, `librt`, `libdl`, `libm`, `libc`; - `initdb` needs those less `libz` and `libdl`, plus the wheel's own vendored `libpq`. That libpq resolves through `RPATH $ORIGIN/../../../pixeltable_pgserver.libs` and itself needs only `libc`, `libm` and `libpthread`; - the server's loadable modules need `libc`, and one needs the vendored libpq. So the system libraries are the C library and libz only: no system PostgreSQL, no ICU. - **Its floor and its size:** - Wheels exist for **cp310 to cp314**, on Linux x86_64 and aarch64, macOS and Windows. - The Linux wheels are tagged `manylinux_2_27` and `manylinux_2_28`, so they need **glibc 2.27 or later**. That is the tag's floor. The highest GLIBC symbol any binary or module needs is 2.25, by `objdump -T`. - Each wheel is about **24.7 MB** (the cp312 x86_64 wheel is 24,704,230 bytes), because it carries two server majors. - It pulls in `fasteners`, `platformdirs`, `psutil` and `typing-extensions`, which nothing here imports. All four were already pinned. - **Superseded:** `pgserver` 0.1.4 carried PostgreSQL 16.2 and had no wheel after cp312 (Copilot r4139811507 and r4139811528, both now resolved with this ruling cited). Also rejected: `postgresql-binaries`, which links the system's ICU and untars at first use, and `pgembed`, which is PostgreSQL 17. ### Outside `src/` and `tests/` - **`pyproject.toml`:** the `local` extra, the `test` extra joining it, `setuptools>=70.1` in `test` (the wheel test's offline build; 70.1 is the first release that builds a wheel with no `wheel` package), and the data-files map. It is a single-writer file (T057 → T072). #58 (T057) adds package data there, and the merge-from-main round takes it. - **`constraints-cpython312-linux.txt`,** in its own commit as its header asks. It was extended under its own pins in a clean 3.12.3 venv (`psutil==7.2.2`, `platformdirs==4.12.2`, `fasteners==0.20` and `setuptools==84.0.0` new). At `84a6c041` it was re-resolved in a clean environment under the pins less `pgserver`. The one line that moved is `pgserver==0.1.4` → `pixeltable-pgserver==0.6.0`. - **`deploy/` — one line, and the task requires it.** `deploy/compose/.env.example` gains `OPENDOX_STATE_DIR=`, because `test_every_runtime_setting_is_documented_in_env_example` requires every `SETTINGS` entry there. The compose stack is hosted and never reads it. **`docs/`: untouched.** - **Not touched:** `serve.py` (T073 adds the `install` block) and `validate.yml`. It already installs `.[runtime,test]`, and `test` now carries `local`. - **Existing tests changed:** - `tests/test_doxbench_entrypoint.py` stands the bundle in, with a tripwire. Its cases test the model port, which reads nothing from the store (R1Q16 (ii)). - T070's `test_install_mode.py` and `test_install_mode_entrypoint.py` stop passing DSNs beside `local`. - `test_runtime_surface.py` declares `opendox.runtime.bundle` stdlib-only at import, because `opendox.cli` imports it and `opendox --help` runs with no extra installed. ## The falsifier F13.1's `runtime status` block and its TCP-listener block, verbatim in their assertions (`f13-1-local.sh`), against a server `generate-and-open --local` started **in the background**, with no broker and no operator database, under `set -euo pipefail`. **Since the merge round (`19e32f0c`), the start is the REAL entry point.** It is `python -m opendox.cli generate-and-open --local`, with the validator on, over T050's `tests/fixtures/plain-documents` copied into a fresh repository, as F13.1's preamble does. The stand-in driver is deleted. One deviation remains, and it does not weaken a check: - ~~**Generation is stood in.**~~ Retired at `19e32f0c`. Until then the start went through `tests_runtime/local_entrypoint_driver.py`, because this stack's base predated T055/T056's standalone generate. - **The pid comes from `runtime status`.** The TCP-listener block reads the server's pid from `runtime status`'s `database_bundle`, not from `caps.json`. `/capabilities`' `install` block is T073's, so F13.1's `caps.json` block is T073's to run. - ~~**The corpus is a one-file stand-in.**~~ Retired at `19e32f0c`: it is T050's fixture now. BEFORE is #67's head `b50e3b1`; AFTER is this branch: ``` === BEFORE (b50e3b1) ready=1 runtime status rc=1 AssertionError: no bundled database answered: None OPENDOX_DATABASE_URL is required and is not set: … FAIL status-block AssertionError: the bundle reports no server pid: None FAIL tcp-listener-block === AFTER (this branch, set -euo pipefail, exit 0) ready=1 runtime status rc=0 PASS status-block server pid 638810, sockets ['3692911'], TCP LISTEN rows: none PASS tcp-listener-block PASS stops-with-entry-point (pid 638810 gone) --- server stdout: database /tmp/tmp.v0wydKm5Zm/postgres/run (bundled, pid 638810, migrations applied now: ['0001', '0002']) ``` T070's F13.1 refusal probes and F13.1's `load_settings` block still pass on this branch (`F13.1 REFUSALS + T070 PAIR: ALL PASSED`). In the suite, `tests_runtime/test_bundled_postgres.py` runs the same two blocks on the same background launch, and adds three checks: the server's `PPid` is the entry point's pid (i), the socket directory is 0700, and SIGTERM ends the entry point with exit 0 and the server gone (iv). Beside that it has a SIGKILL case (the parent-death backstop), the second-server refusal, `runtime migrate` under `local`, the wheel case above, and the layout and refusal cases. **Under `CI` it fails rather than skips** if the server is missing, because `validate.yml` pins `EXPECT_SKIPPED=11` exactly. ## A mutant of each new refusal and guarantee, killed Each mutant was applied alone, and `test_bundled_postgres.py` plus `test_install_mode.py` were run with `-x`, with a 240 s bound so a hang could not pass for a kill: | mutant | killed by | |---|---| | M1 an operator DSN accepted beside local | `test_migrate_under_the_local_mode_uses_the_bundle_and_refuses_a_dsn` | | M2 a socket path too long accepted | `test_a_state_dir_too_long_for_a_unix_socket_is_refused_naming_it` | | M3 a relative state dir accepted | `test_a_relative_state_dir_is_refused_naming_it` | | M4 the server opens a TCP listener (`listen_addresses=127.0.0.1`) | `test_the_entry_point_owns_a_migrated_server_with_no_tcp_listener` | | M5 the server is not the entry point's child (`setsid -f`) | same | | M6 `stop()` a no-op | `test_a_second_entry_point_on_the_same_state_dir_is_refused` | | M7 no parent-death signal | `test_the_server_stops_even_when_the_entry_point_is_killed_outright` | | M8 SIGTERM not read as an interrupt | `test_the_entry_point_owns_a_migrated_server_with_no_tcp_listener` | | M9 started but not migrated | same | | M10 the served DSN is the owner's (a collapse) | `test_the_two_dsns_are_two_users_over_the_one_socket` | | M11 no packaged migrations found | `test_a_wheel_install_migrates_its_bundled_server_outside_a_checkout` | | M12 the socket directory left 0755 | `test_the_entry_point_owns_a_migrated_server_with_no_tcp_listener` | | M13 a second server on one state dir not refused | `test_a_second_entry_point_on_the_same_state_dir_is_refused` | **A defect this PR's own test found in itself.** The first cut of the wheel case ran `pip install --prefix` without `--ignore-installed`. pip then read the suite's own editable `opendox` as the installed copy of the same project and **uninstalled it**, emptying the environment the suite runs in (measured: `pip list` lost `opendox` and both console scripts). The flag is now there, with a comment, and the case asserts afterwards that the suite's own `opendox` still resolves. ## The repo's own suite Full `python -m pytest -q`, `LANG=C.UTF-8`, `CI=true`, against a `postgres:16` like `validate.yml`'s: | | selected | passed | skipped | failed | errors | |---|---|---|---|---|---| | #60's head `f097fd8` | 2485 | 2474 | 11 | 0 | 0 | | #67 (T070) `b50e3b1` | 2531 | 2520 | 11 | 0 | 0 | | #67 (T070) `525f61c`, its fix round 2 | 2538 | 2527 | 11 | 0 | 0 | | this branch before the merge, `c3a70a2` | 2545 | 2534 | 11 | 0 | 0 | | `32db5d8` (merges `525f61c`) | 2552 | 2541 | 11 | 0 | 0 | | `ac61596` (merges `02dadc5`) | 2554 | 2543 | 11 | 0 | 0 | | `28bdccd` (fix round 4, and merges `859b37b6`) | 2580 | 2569 | 11 | 0 | 0 | | `96b2699f` (fix round 5) | 2584 | 2573 | 11 | 0 | 0 | | `a0fb7c8d` (merges `026f00ea`; fix round 6) | 2584 | 2573 | 11 | 0 | 0 | | `0f77d5c1` (fix round 7) | 2595 | 2584 | 11 | 0 | 0 | | `379fbb14` (fix round 8) | 2601 | 2590 | 11 | 0 | 0 | | `84a6c041` (the carrier and peer authentication, as ruled) | 2613 | 2602 | 11 | 0 | 0 | | `f8e6e9e9` (fix round 10) | 2619 | 2608 | 11 | 0 | 0 | | `fe232fe` (merges #67's `c8fac05e`, carrying main `047bb4fa`), before its edits | — | — | — | 3 (the bundled background cases) | — | | `19e32f0c` (the merge round's edits) | 3195 | 3184 | 11 | 0 | 0 | | `6eb0bbdb` (merges #67's `cdf7382b`; the env probe expects the child's own state dir) | 3204 | 3193 | 11 | 0 | 0 | | `fedfa75d` (fix round 11, `0488f5bd`, then merges #67's `d1de1fd9` with no file change) | 3210 | 3199 | 11 | 0 | 0 | | `f66e5f82` (fix round 12, `3426c753`, then merges #67's `105f2f12`) | 3215 | 3204 | 11 | 0 | 0 | | `a9854078` (in-process local cases get their own state dir), with local and broker settings, a runner `OPENDOX_STATE_DIR` and a 90-character `XDG_STATE_HOME` exported | 3215 | 3204 | 11 | 0 | 0 | | `21bde1af` (the adversarial review's M1, L1, L2, L3 and replication note) | 3236 | 3225 | 11 | 0 | 0 | | `28e195b9` (fix round 13: the carrier is found as the installed distribution's own files) | 3240 | 3229 | 11 | 0 | 0 | | `57b7ed8f` (fix round 14, `bf9bcb08`, then merges main `66ff7257`) | 3327 | 3316 | 11 | 0 | 0 | | `058d96ef` (fix round 15) | 3328 | 3317 | 11 | 0 | 0 | | `085ba0b0` (merges main `2fc714d2`, #62 T079) | 3346 | 3335 | 11 | 0 | 0 | | `3ebccb3c` (fix round 16) | 3350 | 3339 | 11 | 0 | 0 | | `52a2b8dc` (merges main `9a490405`, #74 T081) | 3399 | 3388 | 11 | 0 | 0 | | `4a9dbe95` (fix round 17) | 3402 | 3391 | 11 | 0 | 0 | | this branch, `c04690f8` (fix round 18, `8986158e` and `c04690f8`) | 3404 | 3393 | 11 | 0 | 0 | `EXPECT_SKIPPED=11` holds exactly, and the floors allow the rise unchanged. The new module adds about 32 s to the run (ten cases, each server start about 1.5 s). **Merging #67's fix rounds.** `95fe16f` merges `32683e8`, and `32db5d8` merges `525f61c`: `runtime migrate` and `reset` refuse what a local install cannot be. - `525f61c` and this PR both rewrite `load_migration_settings`. The conflict resolves to this PR's structure: under `local`, the refusal is asked first, and only then is the bundle's migration DSN read. T070's reason is carried into the comment. - The two merged cases set the local shape as this PR defines it, with the mode and the state dir and no operator DSN. Beside `local` a DSN is itself refused here, so a case that set one would have tested the DSN refusal instead of the broker or bind refusal it names. - A mutant that drops the refusal from the migration loader fails all 7 merged cases. - `ac61596` merges `02dadc5`, cleanly. With the runtime extra absent, `status`'s early return now reports a local install's broker as not configured. The merged case uses this PR's local shape and also asserts that `database_bundle` is reported on that return: present for local, `null` for hosted. ## Fix rounds 4 and 5: Copilot's twelve threads (`5e52872`, `96b2699f`) Copilot reviewed `95fe16f`, `32db5d8` and `ac61596a` and opened twelve threads. **Ten are fixed, answered and resolved.** The new cases are in `tests_runtime/test_local_lifecycle.py` (new, hermetic), plus two in `test_bundled_postgres.py`. - **Migrations** (r4139811473, r4139880241). - An explicit `OPENDOX_MIGRATIONS_DIR` is used as given. - Unset, a **local** install uses only its own installation's copy, never the working directory's. That copy is the source tree `__file__` came from first, then the `RECORD` of the distribution that holds the running module. Where there is none, it is refused. - A **hosted** install's default is unchanged (13.6). - **The pid** (r4139811555, r4139938402). - A pid is believed only when `/proc` proves it is an executable named `postgres` running in this data directory. A proven-stale lock is removed before the launch. - Where there is no `/proc`, nothing is believed, and PostgreSQL's own interlocks stand. The price is a `status` with no pid on macOS and the BSDs, recorded in the thread. - **initdb** (r4139880213): it runs into an attempt directory that is renamed into place only on success. Abandoned attempts are removed. A non-cluster `data/` is refused and left alone. - **start()** (r4139880279): every phase is one guarded operation, and every failure is the one named refusal, with its phase and class. - **Interrupts** (r4139880267): SIGTERM or Ctrl-C anywhere in the local lifecycle is a clean stop, exiting 128 + the signal number. A served run still exits 0. - **Refusal wording** (r4139880298): broker settings and DSNs are two classes, each with its own reason. - **State dir** (r4139938444): an unknown `~user`, or no home, refuses naming `OPENDOX_STATE_DIR`. - **Test helper** (r4139811584): bounded by a selector. With a silent 8 s child and a 1 s deadline, it returned after 1.0 s where the old loop took 8.0 s. Evidence: - Against `ac61596`'s source, 17 of round 4's first 18 cases fail; the one that passes is the unchanged hosted default. Round 5's cases fail against `28bdccd`. - Mutants: 23 of round 4 and 5 of round 5, all killed (`runs/mutants-t072-r4.txt`, `-r5.txt` in the writer's workdir). **Round 6** (`a0fb7c8d`): Copilot's review at `28bdccd9` opened two more threads. - The unknown-`_serves` point was already fixed at `96b2699f`; it is answered and resolved. - The pyproject note named a function that no longer exists. It now names `installation_migrations_dir`, and the packaging case checks every `opendox.runtime.config.<name>` pyproject names. - `4aed6278` merges T070's `026f00ea`, a docstring change. **Round 7** (`0f77d5c1`): Copilot's review at `a0fb7c8d` opened three threads, all fixed and resolved. SonarCloud raised one reliability finding. - **libpq's environment.** Every `PG*` variable is lifted out of `os.environ` for the duration and put back afterwards, around `generate-and-open --local`'s lifecycle and the runtime verbs under `local`. `PGHOSTADDR`, `PGSERVICE` and `PGOPTIONS` can no longer redirect the bundle's connections. The real entry point and `status` are proven with all three set. - **The socket's path.** The resolved state tree must be this user's own and writable by no one else. Every ancestor must be owned by the user or root, and sticky where others can write it; a group-writable ancestor of the user's own group is allowed. Symlinks inside the tree are refused before any chmod. - **A relative HOME** is refused for the default state directory. - **SonarCloud S6466** (reliability): `server_binaries` no longer indexes a list. - Evidence: 8 new cases fail against `a0fb7c8d`, and 11 mutants are killed. **Round 8** (`379fbb14`): Copilot's review at `0f77d5c1` opened two threads, both fixed and resolved. - A group-writable ancestor is refused whatever its group, because a primary group can have other members. - The configured path is checked as configured, as well as resolved: both chains' ancestors, every link's owner, and no `..` anywhere. - Evidence: 5 new cases fail against `0f77d5c1`, and 5 mutants are killed. **Round 9** (`84a6c041`) applies Brett's two rulings, openxFactory#656 [`5916000030`](opensoft/openXfactory#656 (comment)) items 2 and 3: the carrier and peer authentication, as described above. - **The server confirms it**, in its own views: - `pg_hba_file_rules` has exactly the one peer rule (with `map=opendox`) and the two rejects; - `pg_ident_file_mappings` has exactly the two mappings, for this OS user; - `system_user` is `peer:<os user>` for both roles. - **The map decides.** The same OS user asking for a role outside the map is refused (`peer authentication failed`). A non-root suite cannot connect as a second OS user, so for that case the map, read back from the server, stands: it names no other user. - **Evidence:** 13 new cases fail against `379fbb14`. 9 mutants are killed: - initdb trust; - no map; - a trust rule; - a wildcard system user; - a third role; - no re-assertion; - any name admitted; - files 0644; - the old carrier. The auth mutants are also killed by the real-server cases alone. **Round 10** (`f8e6e9e9`): Copilot's review at `84a6c041` raised three points, all fixed. - An existing `postgres/data` joins the tree check, a broken link included (r4147680113, resolved). - Missing parent directories are created exactly 0700 whatever the umask. `mkdir(parents=True)` under umask 0002 made them group-writable. - Readiness requires the data directory's lock file to name the launched child, so a racing loser cannot adopt the winner's socket. - Evidence: 6 new cases fail against `84a6c041`, and 4 mutants are killed. **SonarCloud S2115, ACCEPTED, as ruled.** - **Issue:** `AaDvyyOCiqwq-gAw53M3`, python:S2115, "Add password protection to this database", on `src/opendox/runtime/config.py` `DatabaseBundle.dsn`. - **New status:** `accept` (SonarCloud now reports it `RESOLVED`). Set with the SonarQube tool on openxFactory#656 `5916000030` item 3's authority. - **Rationale:** the DSN has no password because the server authenticates Unix-socket connections by PEER. The kernel verifies the connecting uid (`SO_PEERCRED`), and `pg_ident.conf` maps only this install's OS user to the two roles. The socket directory is 0700, the server has no TCP listener (`listen_addresses` is empty), and every host connection is rejected. The same rationale is in the DSN's docstring. - **Gate:** after the change, SonarCloud reports the PR's quality gate `OK` on every condition. ## Merge-from-main round (`fe232fe`, `19e32f0c`; 2026-10-02) Phase 2 has landed. This branch now carries #67's `c8fac05e`, which carries #60's `adeb6fed` and main `047bb4fa` (T054 to T058, T055's follow-up #70 and T056's standalone test). Git auto-merges `pyproject.toml` (main's validator package data beside this PR's local extra and data files), `src/opendox/cli.py` and `tests/test_doxbench_entrypoint.py` without a conflict. Four edits followed, all in `19e32f0c`: 1. **The stand-ins in `tests_runtime/local_entrypoint_driver.py` go.** The driver is deleted. Its stand-ins patched names T055 has since replaced, so on the merged tree they stood in for nothing, and all three background cases failed: the real corpus-root check refused the stand-in corpus. `test_bundled_postgres.py` now runs the real entry point over T050's fixture, with the validator on. 2. **Every cheap refusal comes before the database start.** Main's T055 added `_refuse_empty_source_options`, so the local path asks it before it builds the bundled server. `tests/test_projection_seams.py`'s empty-option case carries a tripwire bundle, so a regression neither starts a server nor passes. 3. **No child touches the user's state directory.** T070 gave four phase-2 callers `--local`, and here `--local` starts the bundled server, whose `OPENDOX_STATE_DIR` defaults to the user's `~/.local/state/opendox`. `tests/standalone_child.py` now gives every child a fresh, short, private state directory under `/tmp` and removes it when the child stops. Measured before: three children of T056 and T058 initialized a cluster in the (sandboxed) default state home. 4. **T056's case 3 asserts it:** while serving, its bundled server's data directory is under the child's own state directory, and the directory is gone after the stop. - **Mutants**, all four killed: the refusal dropped; no private state dir; the dir not removed; the fixture not a repository. - **Full suite:** `3195 selected, 3184 passed, 11 skipped, 0 failed`. Nothing is left under `~/.local/state/opendox` or `/tmp/odx-child-*`. ## Merge of #67's fix rounds (`94254b18`, `6eb0bbdb`; 2026-10-02) `94254b18` merges #67's `cdf7382b`, which carries #60's `c39d960e` (a PostgreSQL scheme libpq would not read as a URI is refused). `cdf7382b` itself means a `--local` caller inherits none of the runner's runtime settings. There were two docstring and setup conflicts, and both were resolved by keeping both sides: - **`tests/standalone_child.py`:** the code merged cleanly in the needed order. The child's environment first drops every `SETTING_NAMES` entry, and only then is `OPENDOX_STATE_DIR` set to the child's own directory. - **`tests/test_projection_seams.py`:** the empty-option case scrubs the settings and keeps this PR's bundled-server tripwire. `6eb0bbdb` changes #67's harness probe. On #67 it asserted that a child sees no runtime setting. Here every child is given exactly one, its private state directory. The probe now also exports a runner state directory, and asserts three things: - the child sees exactly `OPENDOX_STATE_DIR` among the runtime settings; - its value is the child's own `Child.state_dir`, not the runner's; - the directory is gone once the child has exited. Evidence: - **Mutants**, all four killed, under an exported hosted install's settings: - the child keeps the runner's settings; - the scrub runs after the state dir is set; - the runner's own state dir is passed through; - the in-process case does not scrub. - **Exported settings:** the child-driven modules (`tests/test_standalone_generate_path.py`, `tests/test_post_render_validator.py`) pass whole with a hosted install's settings and a runner `OPENDOX_STATE_DIR` exported. - **Full suite:** `3204 selected, 3193 passed, 11 skipped, 0 failed`. Nothing is left under `~/.local/state/opendox` or `/tmp/odx-child-*`. ## Fix round 11: nothing is made through a path the tree check would refuse (`0488f5bd`, then `fedfa75d`) Copilot's review at `19e32f0c` opened one thread, which is real (reproduced) and is now answered and resolved. `_prepare_directories` made the missing `postgres/run` before the tree check judged the path, so a component it refuses had already been written through: another user's link, or a 0777 directory. In a sticky parent such as `/tmp`, another user could also plant the state directory's name between the check and the `mkdir`. The fix: - **What exists is judged before any write.** `_refuse_an_unsafe_tree(existing_only=True)` runs the link-ownership loop first, so even a broken foreign link is named. The whole tree is judged again afterwards, before the socket directory's `chmod`. - **Missing components are made by descriptor.** `_make_private_directories` makes each one relative to its parent's descriptor and opens it with `O_NOFOLLOW`. `fstat` must show it is this user's alone before anything is made beneath it. A planted link, non-directory or foreign directory is the named refusal: never followed, never re-moded. - **No `mkdir`/`chmod` window.** Each component is born 0700 under a umask of 077, and the umask is put back afterwards. Evidence: - **New cases:** six, in `tests_runtime/test_local_lifecycle.py`. All fail against `19e32f0c`'s `bundle.py` and pass here. - **Mutants:** seven, all killed. - **Full suite:** `3210 selected, 3199 passed, 11 skipped, 0 failed`. `fedfa75d` merges #67's `d1de1fd9` (its healthy-local status case reads either DSN form). On this branch that case uses the bundled server, so the conflict resolves to this side and changes no file. ## Fix round 12: the auth files are exactly 0600, and the cluster runs on its own files (`3426c753`, then `f66e5f82`) Copilot's reviews at `6eb0bbdb` and `fedfa75d` opened two threads, both real and now answered and resolved. - **`write_authentication`'s 0600 was only a creation request.** The umask filtered it, and a stale temporary from an interrupted start kept its own mode or was written through as a link. Now the stale temporary is unlinked, the new one is opened `O_CREAT | O_EXCL | O_NOFOLLOW`, and its descriptor is `fchmod`-ed to exactly 0600 before anything is written. A link raced in after the unlink is a refusal, never followed. - **A reused cluster's `postgresql.conf` could redirect `data_directory`, `hba_file` and `ident_file`**, for example to an outside `trust` file. The launch now pins all three on the command line, which outranks every configuration file. Evidence: - **New cases:** four in `tests_runtime/test_local_lifecycle.py` (umask, stale 0644, stale link, raced link) and one real-cluster case in `tests_runtime/test_bundled_postgres.py`. All but the raced-link case fail against `fedfa75d`. - **Mutants:** six, all killed. - **Full suite:** `3215 selected, 3204 passed, 11 skipped, 0 failed`. `f66e5f82` merges #67's `105f2f12` cleanly. It adds an autouse fixture in `tests_runtime/conftest.py` that clears every runtime setting before each case, so a case wanting `OPENDOX_STATE_DIR` sets its own, as every one here already does. ## The adversarial review of `f66e5f82` (`a9854078` to `21bde1af`; 2026-10-02) An adversarial review of `f66e5f82` found nothing high. It found one medium, three lows and a note. Each is fixed in its own commit, each with a new case that fails without it and mutants that are killed. One more hermeticity fix came first. - **`a9854078`: the in-process local cases give themselves a short state directory.** The doxBench entrypoint fixture and the empty-option case in `test_projection_seams.py` scrubbed the settings, and so fell back to the runner's default state directory. When that is too long for a Unix socket, configuration refuses it before the case is reached. Measured with a 90-character `XDG_STATE_HOME`: 4 errors and 1 failure. Each now sets its own short `OPENDOX_STATE_DIR` and removes it afterwards. Nothing is made in it, because the database is stood in. Both mutants are killed. - **M1, medium (`e214477d`): a comma in the state directory is refused.** PostgreSQL splits `-k` on commas, and libpq splits a decoded `host` on them. The review reproduced sockets in two unchecked directories, one of them 0777, while the checked 0700 directory stayed empty. `config.database_bundle` (every bundle's one derivation) now refuses a `,` from `OPENDOX_STATE_DIR`, `XDG_STATE_HOME` or `HOME`, without repeating the value. - **L1 (`c4f5df3c`): the carrier is pinned to `pixeltable-pgserver>=0.6.0,<0.7`, and another major is refused by name.** Before an existing cluster is used, the server's own `postgres --version` is asked against its `PG_VERSION`. Another major, or a server that does not say, is a named refusal, before anything is written. 4 mutants are killed. - **L3 (`b2d80e94`): the directory creation starts from is judged by its descriptor.** `_make_private_directories` now `fstat`-judges the base it opens with `_unsafe_because` before the first `mkdir`. That is the install's own rule for the state directory and below, and the ancestors' rule above it. This makes round 11's rule hold inside the function itself. 2 mutants are killed. - **L2 (`9e2f3030`): the local verbs judge their socket before connecting to it.** `runtime status`, `migrate` and `reset` connected to whatever answered at the bundle's socket path. Reproduced here: `status` on a 0777 tree whose `run` linked to another bundle's socket reported that bundle's applied migrations and exited 0. The fix: - `bundle.refusal_before_connecting` asks the start's tree check (now `bundle.refuse_an_unsafe_tree`) of what exists. It then asks for a live server of THIS data directory: its own `postmaster.pid` must name a live `postgres` whose working directory is this data directory, listening at this socket directory. - **Status's `database` reads `"not probed: <reason>"`** for a local install that fails this check, including one with no server running. It used to read `"unreachable: …"`, found by connecting. - **`migrate` and `reset` refuse as `local-bundle-unverified`.** Hosted is unchanged. - The status database block is re-indented under the new branch; `git diff -w` shows only the branch. - 7 mutants are killed. - **The note (`21bde1af`): no replication connection, logical or physical. Fixed, not only reworded.** `authentication_files`' docstring said a replication connection is refused. A physical one was refused, but a logical one (`replication=database`) was accepted as `peer:<user>`, and `IDENTIFY_SYSTEM` answered (measured). No `pg_hba.conf` rule can tell it from an ordinary connection. So the launch sets `max_wal_senders=0`, and the docstring now says both kinds are refused by the server. The mutant is killed. **Full suite:** `3236 selected, 3225 passed, 11 skipped, 0 failed`. Nothing is left under `~/.local/state/opendox` or `/tmp/odx-*`. ## Fix round 13: the server is found as the installed distribution's own files (`28e195b9`) Copilot's review at `f66e5f82` opened one thread, which is real and is now answered and resolved. `server_binaries` used `importlib.util.find_spec`, which follows `sys.path`. Under `python -m opendox.cli` that starts with the working directory, and a corpus checkout is where it runs. So a checkout holding an executable `pixeltable_pgserver/pginstall/bin/postgres` was run as the database server. The carrier is now looked up by distribution name (`importlib.metadata`), on `sys.path` without the working directory. Both binaries must be files its RECORD lists, inside it and executable. Evidence: - **New case:** the working directory holds an importable package and a forged `.dist-info`, and the server is not taken from it. - **Reworked lookup case:** four refusal shapes. - **Before:** 6 of the 8 fail against `find_spec`. - **Mutants:** 4 killed, 1 equivalent. - **Full suite:** `3240 selected, 3229 passed, 11 skipped, 0 failed`. ## Fix round 14: a named platform gate, resolution failures as reasons, no pid behind a refused tree (`bf9bcb08`) Copilot's review at `21bde1af` opened three threads, all real and now answered and resolved. - **A named platform gate.** The bundle is a POSIX design, but the carrier ships Windows wheels, where a start failed as an `AttributeError`. `bundle.unsupported_platform()` names the missing primitives (`os.getuid`, `O_DIRECTORY`, `O_NOFOLLOW`, `os.fchmod`, `mkdir` with `dir_fd`, `socket.AF_UNIX`). A start and the local verbs' socket check ask it first. - **Resolution failures are reasons.** `refusal_before_connecting()` names a symlink loop (`RuntimeError`) and an embedded NUL (`ValueError`) as reasons, beside `OSError`. - **No pid behind a refused tree.** `bundle.report()` reports a pid only behind a verified tree. A `postgres/data` linked to another live bundle had reported that server's pid. Evidence: - **New cases:** three hermetic ones, and a `linked-data` shape with null-pid assertions in the real verbs case. - **Mutants:** eight, all killed. ## Merge of main after #67 landed (`57b7ed8f`; 2026-10-03) #67 (T070) landed as a squash, `66ff7257`, after #61 (T078, `8a98e317`). Main thus holds T070's content as one commit this branch's history never saw, and a plain merge against the old base `047bb4fa` conflicted in ten files where both sides carry the same T070 text. So the merge is computed against the T070 state this branch already held, #67's `105f2f12`: `git merge-tree --write-tree --merge-base=105f2f12 HEAD origin/main`. It is recorded with both parents. The base is sound because `git diff 2526245 66ff725` (#67's last branch head against its squash) names only #61's three files. Against it the merge is clean: - **18 files** take main's changes since `105f2f12`: #65 T088, #71 T085, #61 T078, and #67's `--local` in #71's test. - **17 of them are byte-identical to main's.** `src/opendox/cli.py` is the one merged file: main's two `doxbench_defaults` registrations sit beside this branch's local path. - **No standalone `generate-and-open` child main brought in lacks `--local`.** #71's case gained it in #67's merge. #65's lens test runs `generate` and `serve.build_server`. #61 runs no entry point. Under T072, #71's `--local` child starts a bundled server in `tests/standalone_child.py`'s private state directory. - **Full suite:** `3327 selected, 3316 passed, 11 skipped, 0 failed`. ## Fix round 15: on Linux the parent-death signal is armed, or the server is not started (`058d96ef`) Copilot's review at `57b7ed8f` opened one thread, which is real and is now answered and resolved. `ctypes` reports a failed `prctl()` by returning `-1`, never by raising (a seccomp denial, say), and the child ignored it. A killed entry point could then orphan the server, against R1Q16 (iv). The fix: - **A failed `prctl` is a refusal.** The child now raises on a nonzero return. `subprocess` re-raises that as `SubprocessError`, which `_launch` names as the refusal "could not be given its parent-death signal", with no server process left. - **A Linux C library with no `prctl` is the same refusal**, where it used to fall back silently. Other platforms are unchanged. Evidence: - **New case (Linux):** a stand-in `prctl` that returns `-1`. The start refuses by name, and the stand-in server never runs. - **Mutants:** both killed. - **Full suite:** `3328 selected, 3317 passed, 11 skipped, 0 failed`. ## Merge of main after #62 landed (`085ba0b0`; 2026-10-03) `085ba0b0` merges main `2fc714d2` (#62, T079). #62 changes only `doxbench_binding.py`, `doxbench_intake.py`, `doxbench_provider.py` and `test_model_provider_broker.py`, none of which this branch touches, so the merge is clean. It runs no `generate-and-open` child, so it needs no `--local`. Full suite: `3346 selected, 3335 passed, 11 skipped, 0 failed`. ## Fix round 16: a local install's served role and database are the bundle's own (`3ebccb3c`) Copilot's review at `085ba0b0` opened one thread, which is real and is now answered and resolved. Under `local`, `OPENDOX_RUNTIME_PG_ROLE` could replace the bundle's served role in the settings. The migration run narrows the ledger privileges of exactly that configured role, while the bundle bootstraps `opendox_runtime` with the default DML and its served DSN connects as `opendox_runtime`. So `OPENDOX_RUNTIME_PG_ROLE=pg_read_all_data` left `opendox_runtime` able to rewrite `opendox_schema_migrations`. `refuse_what_a_local_install_cannot_be` (asked by both loaders and by `generate-and-open --local`) now accepts two settings only unset or naming the bundle's own: - `OPENDOX_RUNTIME_PG_ROLE` must be `opendox_runtime`; - `OPENDOX_SERVED_DATABASE` must be `opendox`, since it declares the same identity. Hosted is unchanged. Evidence: - **New case:** both settings, through both loaders. - **Mutants:** both killed. - **Full suite:** `3350 selected, 3339 passed, 11 skipped, 0 failed`. ## Merge of main after #74 landed (`52a2b8dc`; 2026-10-03) `52a2b8dc` merges main `9a490405` (#74, T081), with no overlap. #74's standalone `generate-and-open` fixture already passes `--local`, since it landed after #67. Under T072 that child now starts a bundled server in the harness's private state directory. - **`tests/test_chat_model_configuration.py`:** 49 passed. - **Full suite:** `3399 selected, 3388 passed, 11 skipped, 0 failed`. ## Fix round 17: the `/proc` falsifier is gated, and a backslash in the map is pinned literal (`4a9dbe95`) Copilot's review at `52a2b8dc` opened two threads, both now answered and resolved. - **The `/proc` falsifier is gated.** `test_the_entry_point_owns_a_migrated_server_with_no_tcp_listener` reads Linux's `/proc`, so it now skips where `/proc` is absent, as the other `/proc` and PDEATHSIG cases do. On Linux, and in CI, nothing changes. - **Backslashes are pinned literal, not escaped.** The thread suggested escaping backslashes in `pg_ident.conf`. Measured against the bundled PostgreSQL 16.14, `pg_ident_file_mappings` reads `"DOMAIN\alice"`, `"alice\"` and `"a\\b"` back as exactly those names, without error. The tokenizer treats a backslash specially only at the end of a line, never inside quotes, so escaping would map a different name. - The code is unchanged. - A real-server read-back case and a hermetic verbatim assertion pin the behaviour. - The escaping mutant is killed. **Full suite:** `3402 selected, 3391 passed, 11 skipped, 0 failed`. main has since taken #63 (T080, `1130e996`), whose five files (the doxbench model-provider family) do not overlap this branch. The PR stays MERGEABLE, and CI's merge ref includes it. ## Fix round 18: one schema for both DSNs, and an uninspectable live pid fails closed (`8986158e`, `c04690f8`) Copilot's review at `4a9dbe95` opened two threads. The holder accepted both, and both are now answered and resolved. - **`8986158e`: both bundle DSNs name `search_path=public`.** Left implicit, PostgreSQL's `"$user", public` let a reused cluster with a schema named `opendox` or `opendox_runtime` split the owner's ledger from the served role's reads. - **New real-server case:** both role-named schemas are created, then the bundle restarts. Both roles' `current_schema()` is `public`, they read one ledger, nothing is re-applied, and `status` is reachable with nothing pending. - **Before:** without the pin, the restart fails with `RuntimeAccessMissingError`. - **Mutants:** 2 killed. - **`c04690f8`: a live pid `/proc` will not describe is unknown, not "not ours".** `_identity` raises `_Withheld` for anything but a vanished entry, and `_remove_a_proven_stale_lock` keeps the lock and refuses the start by name rather than unlinking a possibly live server's lock. With no `/proc` at all, PostgreSQL still judges. - **New case:** a live pid whose `/proc` links are withheld. It fails against `4a9dbe95`. - **Mutants:** 2 killed. **Full suite:** `3404 selected, 3393 passed, 11 skipped, 0 failed`, run with `LANG=C.UTF-8` and no `GIT_*`/`XF_*`. ## Downstream, for the holder - **Out of scope, and not T072's: `serve.py` cannot bind `::1`.** This is pre-existing, measured at #60's head `f097fd8`: `gaierror [Errno -9] Address family for hostname not supported`. `serve.LOOPBACK_HOSTS` lists `::1`, but `ThreadingHTTPServer` is IPv4. Recorded on #67 (T070) for a `serve.py` follow-up in that file's single-writer order. This PR does not touch `serve.py`. - **Done at the merge round:** the driver's stand-ins are gone, and the probe runs the real entry point on `tests/fixtures/plain-documents`. - **For T073 and T075, which stack on this PR:** a `--local` child built with `tests/standalone_child.py` gets its own state directory automatically. Any other `--local` caller must set `OPENDOX_STATE_DIR` itself. - **T073** reads `database_bundle` from the server object the entry point keeps (`args.database_bundle`) for `/capabilities`' `install` block. - **T074** runs F13.1 whole, `caps.json` block included. - **Overlap** (`gh pr diff -R opensoft/openDox-code`): `pyproject.toml` (#58) and `cli.py` (#59, and the T058 writer after it). They have landed, and this stack took its merge-from-main round after them. `serve.py` is not touched here. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Arc: neutral-product-standalone-operability Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>



What this is
A small follow-up to T055 (#59, landed as
fa140875). It takes the one finding Copilot's review of #59 at0c946f4eraised as "previously missed", after the last push that could take it.The finding, quoted
Copilot review overview on #59 at
0c946f4e(review5368674478), medium, "Avoid unstable second lookup during source path confinement",src/opendox/default_registry.py:444:It is real. #59 already closed the same pattern in
serve.py's/sourcearm (Copilot r4136585695 and r4136863569): that arm resolves the entry once and confines to that entry's own root withresolve_source_path(Path(root), rest).serve_project._resolved_listed_edit_entrywas the one caller left.What changed
src/opendox/serve_project.py:_resolved_listed_edit_entryresolves the entry ONCE and confines the path to THAT entry's own root through the registry seam's declaredresolve_within(read asprojection_seams.registry.current()inside the function). The listed-path check already read the entry in hand, and the editor is launched overentry.source_root, so the lookup, the validation and the confinement are now one entry. An entry with no root serves nothing, as before.resolve_sourceis on no seam's list (REGISTRY_CALLABLES), so a contributed registry is never asked for one. That is why the fix confines the entry in hand rather than adding an entry-based method to openDox's own registry: a host's registry would not carry it.src/opendox/default_registry.py:SnapshotRegistry.resolve_sourcekeeps its behaviour (one lookup, confined to that entry). Its docstring now says it is for a caller that holds only a pair, and why a caller that already holds an entry must not ask again by its pair.tests/test_edit_action_one_entry.py(new, 8 cases).No module-level proxy is bound in
serve_project.py:tests/test_projection_seams.py::test_no_proxy_over_a_seam_is_read_at_import_timepins the exact set of modules that bind one (serve.py,serve_workbench.py), and this PR does not edit that file.Every caller of the two-step path
git grep resolve_source -- srcatfa140875finds the definition and exactly one production caller,serve_project.py:111. The other registry lookups insrc/are one resolution each:serve.py_serve_snapshotand_serve_source(already one entry),serve_workbench.py(resolvethenresolve_within(entry.source_root, ...), three sites), andbranch_session.py(stamping an entry after a register, no confinement)._keyed_source'sregistry.get(*parsed)is a parse-time existence check whose result is a key, and_serve_sourcethen resolves that key once.The new test
test_no_module_asks_a_registry_for_a_path_by_a_pairholds that set empty, so a future caller has to be argued for.Evidence
Red at main, green after. The new module against
fa140875's sources (serve_project.pyanddefault_registry.pyas on main):With this PR:
8 passed. The three that pass at main are the control (a listed file opens with no refresh), confinement kept, and "no root serves nothing", which pin what must NOT change.The race is tested at the ROUTE, both ways, with a real server, a real
POST /actions/editand the console token. A registry whose key is replaced right after the route's firstresolve(as a refresh on another thread would) lands the replacement between the resolution and the confinement (asserted):200and an editor over a file that is not there. Now:404 document_unavailable, no editor.404). Now:200, and the editor is started over that entry's root.Mutants of the fix, all killed (the new module only,
serve_project.pyrestored after each):registry.resolve_source(repository, ref, path), i.e. main)Path(root) / path, no containment ruletest_the_entrys_own_root_still_confines_what_the_route_acceptsT056's module against this fix. Fetched #66's head
38761c76read-only into a scratch worktree, merged main (fa140875; the two add/add conflicts,default_registry.pyandtests/test_projection_seams.py, resolved to main's blobs, as T056's own diff does not touch either), cherry-picked this commit on top, and rantests/test_standalone_generate_path.py(its children run from that worktree'ssrcviaPYTHONPATH):That module's requests are
GET /source/notes-toolshed-inventory.md(200, byte-equal) andGET /source/.git/config(404). They go throughserve.py's/sourcearm (resolve_source_path), which #59 already moved offresolve_source, not throughserve_project, so this PR leaves them as they were. The module passes identically with and without this commit.Whole suite at
5666505b,LANG=C.UTF-8, run in the foreground with a throwawaypostgres:16andOPENDOX_TEST_DATABASE_URLset as CI sets it:#59's CI at
0c946f4ewasselected=2989 passed=2978 skipped=11. This PR adds 8 cases: 2997 selected, 2986 passed, 11 skipped.Overlap with open PRs
None.
gh pr diff --name-onlyon #60 to #69, read against each PR's own merge-base (#66 and #68 carry #59's commits, which listsdefault_registry.pyspuriously): their own diffs touch neitherserve_project.pynordefault_registry.py. #66's ownserve.pychange is one flushedprintnear line 2216, outside the/sourcearm.Review rounds
0471f8c7: "Approval recommended", no findings, 0 threads. The SonarCloud quality gate failed there on 4.9% duplication on new code (required at most 3%): the new test module carried a copy oftest_projection_seams.py's autouse isolation fixture andgithelper.5666505b: imports both instead of copying them (thetests/test_doxbench_*.pyprecedent), a test-only change. The autouse fixture still applies to all eight cases (eight SETUPs under--setup-show), the eight cases pass, and M1 to M5 are still killed.5666505b: "Approval recommended", no findings, 0 threads.validateand SonarCloud ("Quality Gate passed") green at5666505b.Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
🤖 Generated with Claude Code