Skip to content

T020: the home-corpus seam -- register_home(factory) and home() - #37

Merged
brettheap merged 3 commits into
mainfrom
build/034-p1c-home-corpus-seam
Sep 26, 2026
Merged

brettheap merged 3 commits into
mainfrom
build/034-p1c-home-corpus-seam

Conversation

@brettheap

@brettheap brettheap commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

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

Summary

Plan 034 phase-1 slice P1-C, the home-corpus seam (specs/034-opendox-standalone-operation/tasks.md, task T020; planned at openxFactory main a65230f6, #1167 the phase-1 gate).

opendox.corpus_adapter gains ONE registration for openDox's home corpus, beside domain_profile.register():

  • register_home(factory) stores a home_corpus-shaped factory — adapter, ref = factory(root) — unevaluated. It returns factory, so a registrant can register and hold it in one expression, as domain_profile.register() does for a profile.
  • home() hands the registered factory back. With nothing registered, it raises CorpusRefused (the interface's one exception) carrying the new ADAPTER_NOT_REGISTERED kind, added to REFUSAL_KINDS: subject names the seam (opendox.corpus_adapter) and detail names the remedy (register_home(...)). Never a ModuleNotFoundError raised from inside a function, and never any other exception.

Realizes 4.1 (the seam) and 4.2 of the ratified add-neutral-product-standalone-operability (#1144).

Out of scope, deliberately. authoring.py:318 still imports corpus_adapter_openxfactory.home_corpus by name — routing it through this seam is T021's (single-writer order on tests/test_authoring_seam.py: T020 → T021 → T022), and neither authoring.py nor any other file is touched here.

Files

  • src/opendox/corpus_adapter.py — ADAPTER_NOT_REGISTERED, register_home(), home().
  • tests/test_authoring_seam.py — new. The two seam tests below, plus two supporting cases (a second registration replaces the first; the refusal survives a cleared registration), all reset by an autouse fixture that mirrors test_profile_registration.py's _empty_registry.

Falsifier

Task T020's falsifier: "those two cases, as seam tests in a new tests/test_authoring_seam.py" — nothing registered refuses ADAPTER_NOT_REGISTERED naming the seam and register_home(...); a registered factory is what home() returns.

opendox.serve and opendox.cli do not import until T011 lands (both still raise ModuleNotFoundError: No module named 'ideation_dashboard', measured at 1e4a57fb), and this file needs neither, so it is --noconftest safe:

$ python -m venv --clear /tmp/v20 && . /tmp/v20/bin/activate
$ pip install ".[test]"
$ python -m pytest -q --noconftest tests/test_authoring_seam.py
....                                                                     [100%]
4 passed in 0.06s

The exact F4.1-style check (nothing registered, over the installed distribution):

import opendox.authoring as a  # noqa: F401 -- import alone must not resolve or register anything
from opendox import corpus_adapter as ca
try:
    got = ca.home()
except ModuleNotFoundError as e:
    raise SystemExit(f"FAIL: the deferred reach still imports a publisher module: {e}")
except ca.CorpusRefused as e:
    r = e.refusal
    assert r.kind == ca.ADAPTER_NOT_REGISTERED, f"refused for another reason: {r.kind!r}"
    assert "corpus_adapter" in r.subject, f"the refusal does not name the seam: {r.subject!r}"
    assert "register_home" in r.detail, f"the refusal does not name the remedy: {r.detail!r}"
    print("OK: home() refuses as F4.1 expects")
else:
    raise SystemExit(f"FAIL: nothing is registered, yet home() answered {got!r}")

Output:

OK: home() refuses as F4.1 expects

The repo's own suites, unaffected

corpus_adapter.py has exactly one other consumer in this leg, opendox.runtime.local_git_adapter (named imports only, all additive here — nothing removed or renamed), and one existing test file already exercises it:

$ python -m pytest -q --noconftest tests/test_conformance_corpus.py   # as validate.yml's required job runs it
.....................                                                    [100%]
21 passed in 2.47s

$ pip install ".[runtime]"
$ python -m pytest -q tests_runtime/test_local_git_adapter.py         # the other corpus_adapter.py consumer
........................................................................ [ 52%]
..................................................................      [100%]
138 passed in 19.44s

No slice edits validate.yml before T036 (its required-check file lists are untouched here), so this new file is not yet part of the required validate job — it is proven directly above, as the plan's phase-1 note for tasks that can land before T011 asks.

Test plan

  • python -m pytest -q --noconftest tests/test_authoring_seam.py — 4 passed (the falsifier).
  • The exact F4.1-style nothing-registered check, over a plain pip install ".[test]" into a fresh venv — passes.
  • opendox.serve / opendox.cli still fail to import exactly as before (unchanged baseline).
  • tests/test_conformance_corpus.py (--noconftest) — 21 passed, unaffected.
  • tests_runtime/test_local_git_adapter.py, the module's other consumer — 138 passed, unaffected.
  • This repository's validate required check, green on this PR (polling after open).

🤖 Generated with Claude Code

Summary by Sourcery

Introduce explicit home-corpus registration and retrieval with clear refusal behavior when no adapter is configured.

New Features:

  • Add a registration seam for supplying and retrieving the home-corpus factory.

Bug Fixes:

  • Replace deferred publisher-module import failures with a structured CorpusRefused error when no home adapter is registered.

Enhancements:

  • Extend the refusal vocabulary with an explicit adapter-not-registered kind and preserve factory replacement and validation semantics.

Tests:

  • Add coverage for unregistered refusals, factory retrieval and deferred invocation, replacement registrations, cleared registrations, and invalid factories.

`opendox.corpus_adapter` gains ONE registration for openDox's home corpus,
beside `domain_profile.register()`: `register_home(factory)` stores a
`home_corpus`-shaped factory (`adapter, ref = factory(root)`) unevaluated,
and `home()` hands it back. With nothing registered, `home()` raises
`CorpusRefused` with the new `ADAPTER_NOT_REGISTERED` kind (added to
`REFUSAL_KINDS`), naming the seam (`opendox.corpus_adapter`) as `subject`
and `register_home(...)` as the remedy in `detail`. Realizes 4.1 (the seam)
and 4.2 of #1144 (`add-neutral-product-standalone-operability`).

`authoring.py:318` still imports `corpus_adapter_openxfactory.home_corpus`
by name -- routing it through this seam is T021's, and it is not touched
here (single-writer order on `tests/test_authoring_seam.py`: T020 -> T021 ->
T022).

Falsifier: the two seam tests in the new `tests/test_authoring_seam.py`, run
`--noconftest` (this file, like T015/T025/T026/T027's, needs neither
`opendox.serve` nor `opendox.cli`, which do not import until T011 lands):

    $ python -m pytest -q --noconftest tests/test_authoring_seam.py
    ....                                                                     [100%]
    4 passed in 0.06s

Existing suites that already touch `corpus_adapter.py` are unaffected:
`tests/test_conformance_corpus.py` (--noconftest, as validate.yml runs it):
21 passed; `tests_runtime/test_local_git_adapter.py`, the module's other
consumer: 138 passed.

Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 26, 2026 21:56
@sourcery-ai

sourcery-ai Bot commented Sep 26, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds the phase-1 home-corpus seam: callers can explicitly register a root-to-(adapter, reference) factory and retrieve it through home(), while unconfigured access fails with a structured CorpusRefused instead of a deferred import error; focused seam tests cover the contract and registry lifecycle.

Sequence diagram for home-corpus factory registration and lookup

sequenceDiagram
    participant Host
    participant CorpusAdapter as opendox.corpus_adapter
    participant Caller

    Host->>CorpusAdapter: register_home(factory)
    CorpusAdapter-->>Host: factory
    Caller->>CorpusAdapter: home()
    alt factory registered
        CorpusAdapter-->>Caller: factory
        Caller->>Caller: factory(root)
        Caller-->>Caller: adapter, ref
    else no factory registered
        CorpusAdapter-->>Caller: CorpusRefused(ADAPTER_NOT_REGISTERED)
    end
Loading

File-Level Changes

Change Details Files
Introduces a process-global home-corpus factory registration seam with explicit refusal behavior when unconfigured.
  • Adds the ADAPTER_NOT_REGISTERED refusal kind to the closed refusal vocabulary.
  • Stores and returns the factory without evaluating it, with later registrations replacing earlier ones.
  • Raises CorpusRefused with seam and registration-remedy details when no factory is registered.
src/opendox/corpus_adapter.py
Adds isolated tests covering registration, replacement, deferred evaluation, and unregistered-state refusals.
  • Adds an autouse fixture that clears and restores the process-global registry.
  • Verifies refusal metadata and vocabulary membership.
  • Verifies the exact registered callable is returned and invoked only by the caller.
tests/test_authoring_seam.py

Tips and commands

Interacting with Sourcery

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

Customizing Your Experience

Access your dashboard to:

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

Getting Help

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

register_home() must reject non-callable factories to prevent invalid registry state and raw TypeError failures.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds a lazy home-corpus registration seam with structured refusal handling.

Changes:

  • Adds register_home() and home().
  • Adds ADAPTER_NOT_REGISTERED.
  • Adds focused registration and refusal tests.
File Summary
tests/​test_authoring_seam.py Tests registration, replacement, clearing, and refusal behavior.
src/​opendox/​corpus_adapter.py Implements the home-corpus seam; non-callable factories should be rejected during registration.

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

Comment thread src/opendox/corpus_adapter.py Resolved
`register_home` accepted and published any object, so `register_home(None)`
(or another non-callable) succeeded and `home()` handed back a value that
cannot satisfy its own contract, `adapter, ref = factory(root)`; the
caller's next line then failed with a raw `TypeError` instead of the named
refusal this seam exists to give. Reject a non-callable at registration
time, consistent with `domain_profile.register()` rejecting `None` for the
same reason.

Adds `test_register_home_refuses_a_non_callable_factory`: a rejected
registration raises `TypeError`, leaves `home()` refusing if nothing valid
was ever stored, and does not clobber a good registration already in place.

    $ python -m pytest -q --noconftest tests/test_authoring_seam.py
    .....                                                                    [100%]
    5 passed in 0.07s

Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 26, 2026 22:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

Only minor documentation and PR-metadata nits remain; no blocking issues were identified.

Review effort: Lite
Findings: 1 Low severity

Open (1)
Resolved since last review (1)

Comment thread src/opendox/corpus_adapter.py Resolved
The previous commit made register_home() reject every non-callable,
`None` included, so `_UNSET`'s own comment claiming a registered `None`
"is nothing here forbids" went stale in the same diff. Describe it as the
sentinel for the unregistered state instead.

Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 26, 2026 22:03
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

Functionality is covered by focused tests; the remaining documentation-consistency nit is non-blocking.

Review effort: Lite
Findings: None

Resolved since last review (1)

@brettheap
brettheap marked this pull request as ready for review September 26, 2026 22:06
@brettheap

Copy link
Copy Markdown
Contributor Author

READY at 8e5fc47 -- Lane: openxfactory-4 (openXfactory-4-openDox_extraction)

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

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

@brettheap
brettheap merged commit e295b1a into main Sep 26, 2026
5 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

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

LANDED — lane openxfactory-4, 2026-09-26T22:09:01Z, PR #37 → e295b1a (opensoft/openDox-code main; plain gate)

Brett: land the phase 1 PRs when green

brettheap added a commit that referenced this pull request Sep 27, 2026
…time verbs (T015) (#38)

## Summary

Plan 034's **T015** (openxFactory `specs/034-opendox-standalone-operation/tasks.md`, slice P1-B), which realizes box **3.1** of the ratified `add-neutral-product-standalone-operability` (#1144).

- **`src/opendox/default_profile.py`** (new) is openDox's default profile for its own domain, documents and ideas. It is a MODULE, so refusals and `/capabilities` name it `opendox.default_profile`. It declares the two facets openDox reads strictly:
  - `SUBCOMMAND_EXTENSIONS = (RuntimeSubcommand(),)`, from this first landing (R1Q4 (a), R1Q5 (a)). So no build ever meets an empty default, which RULED ASK-2 and the packet's design § D5 keep refused. `ProjectSubcommand` is not included: R1Q5 (a) names the runtime verbs alone (plan 034, T006's finding U4).
  - `ROUTE_EXTENSIONS = ()`. openDox's own routes are the core server's fixed dispatch, and the facet is declared because `build_server()` reads it strictly.
- It declares **no `DISPLAY` facet**. That is how its vocabulary is `NEUTRAL_DISPLAY` unchanged (requirement 3's third scenario). The reason is under "The one judgement" below.
- **Importing it registers nothing.** T016 wires the entry-point registration (R1Q3 (a)), and it lands after P1-A's T012.
- **`tests/test_default_profile.py`** (new) holds it to requirement 3. Like `test_profile_registration.py`, it imports neither `opendox.cli` nor `opendox.serve`, since neither imports in a lone checkout until T011.

## Authority

- Ratified packet: openxFactory#656 comment [`5815412869`](opensoft/openXfactory#656 (comment)) (*"ratify #1144"*).
- Rulings carried out, openxFactory#656 comment [`5817152735`](opensoft/openXfactory#656 (comment)) (*"(a) on all eleven, (d) on R1Q6"*):
  - **R1Q4 (a)**: the default contributes openDox's own verbs (the runtime verbs now), with `NEUTRAL_DISPLAY`.
  - **R1Q5 (a)**: `RuntimeSubcommand` is in the default's `SUBCOMMAND_EXTENSIONS`, and `opendox-runtime` stays as an alias.
  - **R1Q22 (a)**: no declared-edit act precedes an arc edit. This PR touches no carved file anyway; both files are created ones.
- **After: T006**, which is done: #1167 landed on openxFactory `main` as `a65230f6`.
- Claim: openxFactory#656 comment [`5850105728`](opensoft/openXfactory#656 (comment)).

## The falsifier, and its run

tasks.md, T015: *"**Falsifier**: the new vocabulary test, and a test that `RuntimeSubcommand` is in the default's `SUBCOMMAND_EXTENSIONS`. F3.1 needs T016's registration, so T016 quotes it. That the default imports with no extra installed is shown by T038's plain-install runs."*

Requirement 3's second scenario, which the vocabulary test holds: *"WHEN a neutral product's default profile names the publishing repository's status taxonomy, its change/spec/delta nouns or its act verbs — THEN the profile is refused under RULING C2 and DIRECTION Q5"*.

What the tests sweep:

- **Every name the default declares**: its command tree walked whole, its route patterns, its view ids and its own registered name.
- **Every help string it contributes**, for all three families, `change` and `changes` included. The one measured use in another sense is exempt by its exact string and for that word alone: `runtime migrate --plan` reads "report what would be applied and change nothing", a verb. Any other use of either word fails the sweep until someone reads it and enters it in `_OTHER_SENSES`, and `test_every_exempt_help_string_is_one_the_default_really_carries` fails once the text an entry names is gone, so a stale entry cannot linger.
- **Every word its display renders.**

The three families are copied, with their source, from openxFactory at `42f34ab7`:
- the eight `Status:` words, plus `projection`;
- the OpenSpec nouns;
- the twenty act ids of `contracts/domain-profiles/openxfactory-engineering.yaml`.

`test_the_sweep_catches_a_profile_that_carries_the_vocabulary` shows that the sweep can fail.

Run from the checkout root at `72ba89fe` (`1d98bfe8` with `main` @ `582ed073`, #37 and #39, merged in), in a venv built as `validate` builds one (`pip install -c constraints-cpython312-linux.txt -e ".[test]"`, Python 3.12.3, pytest 8.4.2), under `--noconftest` as tasks.md § Phase 1 requires until T011:

```
$ python -m pytest -v --noconftest tests/test_default_profile.py
test_runtime_subcommand_is_in_the_defaults_subcommand_extensions PASSED [  5%]
test_the_default_is_never_an_empty_profile PASSED [ 11%]
test_the_default_contributes_the_runtime_command_opendox_runtime_builds PASSED [ 17%]
test_the_default_declares_the_two_facets_the_composition_points_read PASSED [ 23%]
test_the_default_is_named_by_its_module_path PASSED [ 29%]
test_the_default_names_none_of_the_publishers_vocabulary PASSED [ 35%]
test_the_defaults_help_carries_none_of_the_publishers_vocabulary PASSED [ 41%]
test_every_exempt_help_string_is_one_the_default_really_carries PASSED [ 47%]
test_the_default_renders_none_of_the_publishers_vocabulary PASSED [ 52%]
test_the_sweep_catches_a_profile_that_carries_the_vocabulary PASSED [ 58%]
test_the_default_renders_neutral_display_unchanged PASSED [ 64%]
test_the_default_claims_no_design_token_so_dark_mode_keeps_its_palette PASSED [ 70%]
test_importing_the_default_registers_nothing_and_needs_no_sibling PASSED [ 76%]
test_the_default_names_no_sibling_package[openxdox] PASSED [ 82%]
test_the_default_names_no_sibling_package[ideation_dashboard] PASSED [ 88%]
test_the_default_names_no_sibling_package[doc_health] PASSED [ 94%]
test_the_default_names_no_sibling_package[corpus_adapter_openxfactory] PASSED [100%]
============================== 17 passed in 0.15s ==============================
```

**The tests can fail.** Each mutation below was applied to a scratch copy of the module at `1d98bfe8`, and the file re-run. The merge of `main` changed none of the files involved (`git diff --stat 1d98bfe 72ba89f` over `default_profile.py`, `tests/test_default_profile.py`, `runtime/cli.py`, `subcommand_extension.py`, `display_profile.py` and `view_extension.py` is empty):

| mutation of `default_profile.py` | result |
|---|---|
| `SUBCOMMAND_EXTENSIONS = ()` | 4 failed: the `RuntimeSubcommand` test, the never-empty test, the runtime-tree test and the name sweep |
| `DISPLAY = NEUTRAL_DISPLAY` added | 3 failed: the facets test, the neutral-display test and the design-token test |
| `ProjectSubcommand()` added to the tuple | 1 failed: the runtime-tree test (U4) |
| a contributed `kickoff` verb added | 2 failed: the runtime-tree test and the name sweep |
| a contributed verb whose help reads "list each open change" | 2 failed: the runtime-tree test and the help sweep |
| the runtime's `--plan` help reworded (in `runtime/cli.py`) | 1 failed: the stale-exemption test |

## The one judgement: why `DISPLAY` is not declared

The task line says the default's *"`DISPLAY` is `NEUTRAL_DISPLAY` unchanged"*. Setting `DISPLAY = NEUTRAL_DISPLAY` literally would render the same words. It would also publish all four design tokens as the HOST's own. `display_manifest` reports a declared facet's tokens in `declared_tokens`, and `views/display.js`'s `applyTokens` writes exactly those onto `:root` inline, where they outrank every per-theme rule in `styles.css`. `tests/test_display_facet.py::test_only_the_tokens_a_host_declared_are_written_onto_root` exists to forbid that.

I measured it with the real `views/display.js` under node, applying each payload the way that test does:

```
payload                               host_facet  declared_tokens                                  written onto :root
default_profile (no DISPLAY facet)    absent      []                                               {}
DISPLAY = NEUTRAL_DISPLAY (literal)   declared    [captured, organized, proposed, completion]      --st-captured #7A5AD0, --st-organized #0D9488, --st-proposed #B96A1B, --st-completion #3B6FD4
```

So the default declares no facet, and `display_profile`'s named absence renders `NEUTRAL_DISPLAY` word for word. `test_the_default_renders_neutral_display_unchanged` asserts the manifest equals the neutral one, with each word table equal to `NEUTRAL_DISPLAY`'s. `test_the_default_claims_no_design_token_so_dark_mode_keeps_its_palette` asserts that `declared_tokens == []`. `VIEW_EXTENSIONS` is undeclared for the same kind of reason: the default contributes no consumer panel, and the absence answers an empty column, named `absent`.

## The repository's own check

The three pytest steps of `validate.yml`'s required `validate` job, with its "Pin the triple" arithmetic, reproduced locally in the same venv:

| | selected | passed | skipped | failures | errors |
|---|---|---|---|---|---|
| `main` @ `582ed073` | 1121 | 1118 | 3 | 0 | 0 |
| this branch @ `72ba89fe` | 1121 | 1118 | 3 | 0 | 0 |

The counts are unchanged, because no file in the job's lists changed. The new test first runs in the required check at T036, which removes those lists (tasks.md § Phase 1: *"No slice edits openDox-code's `validate.yml` before T036"*).

`tests/test_provider_boundary.py` is off the required list and red on `main` for 16.6's reasons, which T034 repairs. It sweeps every package module for provider needles, and it gives `12 failed, 16 passed` both on `main` @ `582ed073` and on this branch @ `72ba89fe`. None of the failures names `default_profile`.

## Copilot's review

Copilot's overview at `cd70eb3e` noted that the vocabulary sweep could miss the nouns `change` and `changes` in contributed help text. It raised no thread. It was right: the help sweep had left both words out. `1d98bfe8` sweeps them, and exempts only the runtime's one measured verb use, by its exact string. The stand-in in `test_the_sweep_catches_a_profile_that_carries_the_vocabulary` now shows `'change' in 'ratify a change'` caught, and the mutation table above shows a noun in new help text failing the sweep. Copilot's overviews at `1d98bfe8` and at `72ba89fe`, the merge of `main`, both read *"Approval recommended"*, with *"Findings: None"*. No review thread is open.

## Left for the tasks that own them

- **`tests/test_consumer_reach.py`'s `NEUTRAL_MODULES`** asks for every new module to be added to its census. That file is single-writer (T011, then T034, in plan.md's table), so `opendox.default_profile` is not added here. T034 re-derives the file. The claim itself is asserted here instead, in `test_importing_the_default_registers_nothing_and_needs_no_sibling`, which imports the module in a fresh interpreter with the four siblings blocked.
- **The root `conftest.py`** still says *"openDox ships no profile"*, in its comment above `_SuiteProfile`. That file is P1-G's (T035). The registration it performs stays right: an empty suite profile keeps pinning the core surface.
- **`domain_profile.py`'s refusal text** (*"ships no profile of its own"*) and the registration runbook describe the contract T016 changes. T016 corrects them together with the entry-point registration that makes them false.

Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)

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


Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
brettheap added a commit that referenced this pull request Sep 27, 2026
Since this branch was cut, main gained T020 (#37), T026 (#39) and T015
(#38). None of them touches src/route_extension.py, src/opendox/serve.py,
the facet's tests or the profile-registration runbook.

Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
brettheap added a commit that referenced this pull request Sep 27, 2026
…check seams

main is a435aec, which carries T015 squashed (#38), T020 (#37) and T026
(#39). The one conflict is src/opendox/default_profile.py, added on both
sides: main holds T015's file byte for byte as its branch left it, and this
branch holds the same file with the one paragraph T016 rewrites (HOW IT IS
REGISTERED). The resolution keeps this branch's file, which is T015's plus
that paragraph and nothing else.

Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
brettheap added a commit that referenced this pull request Sep 27, 2026
…e registered scope (workbench.py:746) (#43)

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

**Plan 034, slice P1-E, task T025.** The plan is `specs/034-opendox-standalone-operation/tasks.md` in opensoft/openxFactory. I read it at #1167's head `42f34ab7`, which landed as `a65230f6`, and it is unchanged on `main` at `79a720a2`. The claim is opensoft/openXfactory#656 comment `5850107036`.

- **Realizes**: 4.3, 1 of its 8 reaches into openxFactory.
- **Ruled**: R1Q9 (a) and R1Q22 (a), comment `5817152735`.
- **After**: both dependencies are on `main`.
  - T020, the home-corpus seam: #37, landed as `e295b1a9`.
  - T026, this slice's earlier `workbench.py` edit: #39, landed as `582ed073`.

  This branch was cut from `main` at `582ed073` and merges `main` at `a435aecf` (T015), so it carries both.

## What it does

`workbench.session_documents` imported openxFactory's `doc_health.corpus` inside its body and applied that corpus's own membership rule, its governed roots plus a declared `Status:` header (`workbench.py:746` at `1e4a57fb`). That was the last of `workbench.py`'s four reaches into the publisher.

- **Membership comes from the registered home corpus.** The function calls the factory that `corpus_adapter.home()` hands back (T020) on the worktree. Its adapter lists that corpus under the scope a host registered, or under `all`, openDox's default, where none is registered.
  - A host registers the scope with `opendox.workbench.register_session_notebook_scope(scope)`, in the same one-registration idiom as T026. The same name again (compared by value) does nothing, a different name is refused, `unregister_session_notebook_scope()` resets it, and `session_notebook_scope()` reads it.
  - openDox's core names no host scope.
  - openxFactory registers its adapter's `documents` scope (T046). At openxFactory `c415c3d1` that scope lists exactly the notebook's 398 documents, where `all` lists 794 (T006).
- **Refusals.** With no home corpus registered, the function refuses as 4.2 does: `CorpusRefused` of kind `ADAPTER_NOT_REGISTERED`, naming the seam and `register_home`. A scope the resolved corpus does not declare refuses `SCOPE_UNKNOWN` before anything is listed, and is never widened to `all`. `branch_session.open_session_notebook` turns either refusal into the FR-042 notice, so a notebook never blocks a session.
- **The bytes are the corpus's.** Each listed document is read through the same adapter (`adapter.read`), never by opening `<worktree>/<key>`, because a `DocumentId.key` is opaque. `corpus_adapter.DocumentId` says a consumer "may compare it, sort it and hand it back, and may not parse it". So the function takes no snapshot of its own, and the notebook carries what the corpus serves at the worktree.
  - Hosted, openxFactory's adapter reads the checkout it is pointed at, file by file, so uncommitted edits and untracked drafts reach the notebook as they did before.
  - `LocalGitCorpus` serves the worktree's `HEAD` instead (see T022 below).

  Copilot's review raised this, and the thread is answered with evidence.
- **The text is unchanged.** Each document is decoded as the reader this replaced read it: `Path.read_text(encoding="utf-8", errors="replace")`, which means UTF-8 with replacement characters and universal newlines. The size bound is measured the same way. So no source's text, and no content hash its re-sync is diffed by, moves.
- **`repository`** is still accepted for the two callers that pass it: `branch_session._session_notebook_documents`, and openxFactory's `sync-notebooklm-books.py`. The registered factory names its own corpus, so the argument no longer selects anything.

Files: `src/opendox/workbench.py`, and a new `tests/test_session_notebook_membership.py`. `validate.yml` is not touched, because no slice edits it before T036.

## Falsifier 1: F4.1's scan

This is #1144's Group 4 `FALSIFIED BY` ast block, run from the checkout as `python3 - src/opendox`. The whole scan stays red until T089. This task's hit is gone, `workbench.py` appears nowhere in the list, and nothing else moved:

    $ diff <(scan at main a435aec) <(scan at this head)
    24d23
    <   src/opendox/workbench.py:746: doc_health

At `main` the scan finds `24 deferred reach(es)`. At this head it finds `23 deferred reach(es)`, listed here:

```text
  src/opendox/authoring.py:318: corpus_adapter_openxfactory
  src/opendox/branch_session.py:1568: openxdox
  src/opendox/branch_session.py:1587: openxdox.register
  src/opendox/branch_session.py:2005: openxdox
  src/opendox/branch_session.py:2105: openxdox.snapshot_registry
  src/opendox/branch_session.py:2151: openxdox.snapshot_registry
  src/opendox/branch_session.py:2228: openxdox.snapshot_registry
  src/opendox/branch_session.py:3573: openxdox.snapshot_registry
  src/opendox/cli.py:610: openxdox.snapshot_registry
  src/opendox/doxbench_packet.py:177: ideation_dashboard.doxbench_status_exemption
  src/opendox/serve.py:1993: openxdox.corpus_root
  src/opendox/serve.py:629: openxdox.corpus_root
  src/opendox/serve.py:713: doc_health.corpus
  src/opendox/serve_project.py:246: openxdox.gate_console
  src/opendox/serve_project.py:247: openxdox.kickoff
  src/opendox/serve_wire.py:1369: ideation_dashboard
  src/opendox/serve_workbench.py:1215: openxdox
  src/opendox/serve_workbench.py:1665: openxdox
  src/opendox/serve_workbench.py:2607: openxdox
  src/opendox/serve_workbench.py:347: openxdox
  src/opendox/serve_workbench.py:407: openxdox
  src/opendox/serve_workbench.py:408: openxdox
  src/opendox/serve_workbench.py:544: openxdox
```

(T027, openDox-code#41, removes `serve_wire.py:1369` and `doxbench_packet.py:177` separately.)

## Falsifier 2: the session-notebook membership test

The test is `tests/test_session_notebook_membership.py`. The two membership cases the plan names:

- `test_with_only_the_default_registered_the_notebook_lists_all`: with only a factory over openDox's `LocalGitCorpus` registered, as T022's entry points will register it, over a real git repository, the notebook lists `all`. That includes a document with no `Status:` header and a non-Markdown file, because openDox's default carries no host rule.
- `test_a_registered_scope_is_the_one_the_notebook_lists`: with `documents` registered over a two-scope stand-in, the notebook lists that scope and nothing else.

Two more cases pin whose bytes the notebook carries:

- `test_the_notebook_carries_what_the_corpus_serves_at_the_worktree` uses a real git worktree holding an uncommitted edit and an untracked draft.
  - A corpus with the host adapter's read semantics serves both.
  - `LocalGitCorpus` serves `HEAD`.
- `test_a_key_is_handed_back_and_never_opened` uses row-id keys over an empty worktree, and they are read in full.

A mutant that opens `<worktree>/<key>` in place of the adapter's read fails 14 of the file's 29 cases, both of these among them.

The run is in a fresh venv with `pip install ".[test]"`. It first asserts that the four siblings are absent:

    the four siblings are absent
    $ python -m pytest -q tests/test_session_notebook_membership.py --noconftest
    29 passed in 0.49s

**Red at `main`.** With the same file copied onto `a435aecf`, the run gives `28 failed, 1 passed`. The decisive failures:

    E       ModuleNotFoundError: No module named 'doc_health'
    E       AssertionError: the notebook reached the publisher's package: ['doc_health.corpus', 'doc_health.corpus', 'doc_health.corpus.load_docs', ...]
    E       AssertionError: a deferred reach into the publisher or the consumer: ...

The first is the 4.2 case: `main` raises a module-not-found error from inside the function, which is the failure requirement 5 retires. The case that passes at `main` is the negative control.

**Why `--noconftest`.** The plan requires it (tasks.md § Phase 1). With the root conftest in play, the file errors 29 times on `ModuleNotFoundError: No module named 'ideation_dashboard'`. The autouse `declared_human_console` fixture raises it when it imports `opendox.cli`, and it stops once T011 lands. With the Group 2 shim on the path, which simulates T011, the whole suite runs with the root conftest, and these 29 cases pass there.

## The repository's own checks

**`validate`, replayed locally.** Its three pytest steps give the same results as `main`:

| step | result |
|---|---|
| `pytest` | `745 passed, 2 skipped` |
| `pytest (S7 residue)` | `13 passed` |
| `pytest (runtime, hermetic)` | `360 passed, 1 skipped` |

The triple is unchanged: selected 1121, passed 1118, skipped 3. The new file is in none of `validate`'s lists, so it moves no floor. The CI `validate` check on this PR is the gate.

**The whole suite, with the Group 2 shim**:

| tree | result |
|---|---|
| `main` `a435aecf` | `20 failed, 1258 passed, 13 skipped, 66 errors` |
| this head | `20 failed, 1287 passed, 13 skipped, 66 errors` |

I compared the two JUnit reports test by test. No outcome changed. The 86 red results are the same 86, and the 29 new cases pass.

## For the tasks downstream

- **T046 (P1-K).** The host makes both registrations once, in its process-start call (`scripts/opendox_host.register_openxfactory()`):

  ```python
  from corpus_adapter_openxfactory import home_corpus
  from corpus_adapter_openxfactory.home import DOCUMENTS   # "documents"
  from opendox import corpus_adapter, workbench
  corpus_adapter.register_home(home_corpus)
  workbench.register_session_notebook_scope(DOCUMENTS)
  ```

  - openxFactory's `scripts/sync-notebooklm-books.py:2091` calls `wb.session_documents(...)` for `--session-ref`, so that script's process needs the same registration.
  - Register `home_corpus` itself, which builds a fresh adapter on every call. `OpenxFactoryCorpusAdapter` caches each listing per `(location, revision, scope)` for as long as the instance lives, and an uncommitted add does not move `HEAD`. So a factory that returned one shared adapter would give a re-sync a stale listing.
  - The `documents` scope has no `Status:` filter of its own; the rule it replaces had one. At `c415c3d1` every governed document carries a `Status:` header, so the two sets are equal (T006: `load_docs` gives 398, and `documents` lists 398). T046's proof that the hosted notebook is unchanged has to hold that equality, or register a scope that carries the filter.
- **T022 (P1-D).** Once an entry point registers the `LocalGitCorpus` factory, the standalone notebook lists `all`: every blob at the worktree's `HEAD`, read at `HEAD`, because `LocalGitCorpus` reads a repository through its history. The host's adapter reads the working tree instead.
  - Copilot's review of this PR raised the difference. The standalone notebook carries the session branch as of its last commit, and not an uncommitted edit.
  - openDox's own flow commits every governed write and creates the notebook right after the first commit, so the two agree when the notebook is created at open.
  - Whether the standalone default should serve the working tree instead is T022's choice of factory, not this task's. I have put it to the lane.
  - Narrowing the standalone set is phase 2's work (T054, R1Q13).
- **T035 (P1-G).** `tests/test_hermeticity.py::test_the_violation_survives_open_session_notebooks_degradation_clause` calls `bs.open_session_notebook(wb.NotebookAdapter(), ...)` directly.
  - After this task, its setup must register a home corpus that lists at least one document. Without one, the create path stops at `ADAPTER_NOT_REGISTERED`, which is swallowed into the FR-042 notice, and never reaches the runner.
  - The module is in the root `conftest.py`'s `collect_ignore` today, so no run shows this. Run by path with the Group 2 shim, the module fails the same 14 cases at `main` `a435aecf` and at this head.
  - Where the registration comes from depends on where T035 sends the module: its own setup here, or the host's registration in openXdox-code's `tests/integration/`. Copilot's overview at `5b4c8774` raised this, and comment `5851370880` answers it.

Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)

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


Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
brettheap added a commit that referenced this pull request Sep 27, 2026
> **READY.** #44 (T021) LANDED (squashed as `9d13bd16`); this PR retargeted to `main` directly. T016 (P1-B, #42) has ALSO LANDED (`19370adc`) and is merged into this branch (`ea83200`). T011/T012 landed earlier still. Every gate this task's own "After:" line named is on `main` and merged into this head. Since the merge, Copilot's review ran to completion across eleven rounds at this head and its predecessors -- every finding fixed, verified red-before/green-after, and either replied-and-resolved (a threaded finding) or explained in the landing commit (an untitled "previously missed" one with no thread to reply to). See "Copilot's review, in full" below for what those eleven rounds actually found and fixed -- several were genuine security/correctness bugs, not nitpicks. Final head `9283278`, all three `validate.yml` steps and the whole authoring-seam suite green, zero unresolved review threads.
>
> **RULING, applied at head `d6abe60`, carried forward unchanged through every merge and fix since: the default reads the working tree, not git HEAD.** Brett, 2026-09-27, via the holder: working tree. Standalone users edit files in their own editor, and the hosted openxFactory adapter already shows worktree bytes — so the standalone default must show the same uncommitted bytes, not the session branch's last commit. Recorded on opensoft/openXfactory#656 by the holder. See "The working-tree ruling" section below.

Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)

**Plan 034, slice P1-D, task T022.** The plan is `specs/034-opendox-standalone-operation/tasks.md` in opensoft/openxFactory, read at #1167's head `42f34ab7` (landed as `a65230f6`, unchanged on `main` at `b5ec3899`). The claim is opensoft/openXfactory#656 comment [`5850371775`](opensoft/openXfactory#656 (comment)) (both T021 and T022).

- **Realizes**: 4.1a.
- **Ruled**: R1Q3 (a), R1Q22 (a), comment `5817152735`.
- **After**: T020 (LANDED, #37 → `e295b1a9`), T021 (LANDED, #44 → `9d13bd16`), T016 (LANDED, #42 → `19370adc`). All landed; all merged into this branch.

## What it does

Where no host has called `corpus_adapter.register_home(...)`, openDox's own entry points now register a `home_corpus`-shaped factory over its own conformant `WorkingTreeCorpus` (`src/opendox/runtime/local_git_adapter.py`, a `LocalGitCorpus` subclass — see the ruling below) — exactly as the default profile stands in for an unregistered host (Group 3, T016). It starts at bare defaults (`required_fields=()`); phase 2's T054 sets the neutral fields R1Q13 decides. A bare process that builds nothing still meets 4.2's `ADAPTER_NOT_REGISTERED` refusal (T020, unchanged). `_default_home_factory` builds a fresh `WorkingTreeCorpus()` on every call — no listing cache keyed on HEAD, so there is nothing to invalidate when the working tree changes under it.

**The seam gains one function, mirroring T016's `domain_profile.register_default()`.** While authoring this task I found T016's own draft PR (#42, not yet landed) already open, and it puts the "register only where nothing is" check *inside* `domain_profile.py` as `register_default(profile)`, so `cli.build_parser()`'s own call is genuinely one line. `corpus_adapter.py` had no such helper (only `register_home()`/`home()`, T020), so this task adds `corpus_adapter.register_default_home(factory)`: it calls `home()` first, and registers `factory` only on the ONE refusal kind that means "nothing is registered yet" (any other `CorpusRefused` is re-raised, never swallowed). Unlike `register_default()`, there is no after-build refusal to track — box 4.1a asks for nothing like RN-1's after-build semantics for the corpus adapter, so this stays as simple as `register_home()` itself.

`LocalGitCorpus`'s own factory (`_default_home_factory`) is duplicated, byte-identical, in `cli.py` and `serve.py` rather than living in `corpus_adapter.py`: that module cannot import `local_git_adapter` without creating the cycle `local_git_adapter.py` already has the other way (`from opendox.corpus_adapter import …`).

**Four call sites**, mirroring T016's four exactly:
- `cli.build_parser()` — the FIRST statement, ahead of the (pre-T016) profile read that can still refuse `ProfileNotRegistered` today.
- `cli.main()` — redundant with `build_parser()`'s own call (which `main()` calls next), kept for the same reason T016 keeps its own match: the outermost entry point states the contract on its own.
- `serve.build_server()` — the FIRST statement, ahead of the profile read two lines below.
- `serve.main()` — redundant with `build_server()`'s own call, same reasoning.

Files: `src/opendox/cli.py`, `src/opendox/serve.py`, `src/opendox/corpus_adapter.py`, `src/opendox/runtime/local_git_adapter.py`, `tests/test_authoring_seam.py`.

## The working-tree ruling: `WorkingTreeCorpus`

`LocalGitCorpus` (the conformant local-git adapter RULING C3 asks for) reads via git plumbing at a resolved revision — `git ls-tree`/`git cat-file blob` at `resolve()`'s revision, defaulting to git HEAD. That is the right read for a *hosted* session bound to a commit, but the wrong one for a standalone default: a standalone user's uncommitted edit would be invisible until they committed it, which is not what "point openDox at my working directory" means to someone editing in their own editor.

`WorkingTreeCorpus(LocalGitCorpus)`, appended to `local_git_adapter.py`, overrides exactly the two methods that decide *where bytes come from*, and nothing else:

- `_list_documents_bound` — `git ls-files -z --cached --others --exclude-standard` (tracked + untracked-but-not-ignored), not `git ls-tree`.
- `_read_bound` — `(Path(corpus.location) / document.key).read_bytes()` when no explicit `revision` is named, falling back to the parent's commit-based read (`super()._read_bound(...)`) when the caller DOES name one. An explicit revision still means what it always meant; only the *default*, no-revision read moved to disk.

`resolve()`, `classify()` (which reads through `read()`, so the override already flows into it), `check()` and `write_back()` are inherited unchanged — `check()`'s existing "uncommitted change" divergence semantics are deliberately untouched by this ruling, which is only about where the DEFAULT corpus's bytes come from.

**The edge case the ruling doesn't mention, and had to be decided anyway:** the repository openDox's own "create a repository" act produces is **bare** (RULING C3, confirmed by `tests_runtime/test_local_git_adapter.py`'s own fixtures) — no working tree at all. `WorkingTreeCorpus` refuses `CorpusRefused(CORPUS_UNREADABLE, ...)` with a detail naming the reason ("this repository is bare … register a host adapter instead, or point this default at an ordinary checkout") rather than silently falling back to git-HEAD reads or crashing on a missing directory.

**Falsifier**, added to `tests/test_authoring_seam.py`:
`test_an_uncommitted_edit_is_visible_through_the_default` builds an ORDINARY (non-bare) checkout by hand, commits one file, resolves it through the registered default, reads the committed bytes, edits the file on disk WITHOUT committing, reads again through the *same resolved corpus object*, and asserts the new bytes are visible; then adds a brand-new untracked file and asserts `list_documents` includes it too.

**Red-checked**: temporarily reverting `cli.py`'s factory back to plain `LocalGitCorpus()` makes this same test fail with `AssertionError: the default served the committed bytes after an uncommitted edit -- it is reading git HEAD, not the working tree` — proving the test actually exercises the ruling, not a vacuous assertion. Restored immediately after confirming the failure; the PR's actual head builds `WorkingTreeCorpus()`.

**A second, unplanned falsifier this class tripped**: `tests_runtime/test_runtime_cli.py`'s anti-leak walk (an AST scan, run over *every* module in the runtime package, that a `except <non-package-exception> as exc` handler may not format `exc`'s text into evidence except through `_safe_message`/`redact_credentials`/`redact_remote_url` — the A25-1 regression class) flagged my first cut of `_read_bound`'s `except OSError as failed:` branch, which passed `str(failed)` straight to `_refuse(...)`. Fixed by routing it through this file's own established idiom for the identical concern (`redact_credentials(str(exc))`, already used for `GitCommandFailed`'s OS-error path, with the exact same rationale recorded there: *"An OS error's text can carry the argv's filename, so it is cleaned where it is composed"* — here it is the working-tree file's own path, read by `Path.read_bytes()`, that could otherwise leak). Confirmed red before the fix (`1 failed, 360 passed`, the one failure being exactly this finding) and green after (`361 passed`) in `tests_runtime`'s full three-file replay of `validate.yml`'s step 3.

## Falsifier: the named test -- now genuinely real, T011 has landed

`tests/test_authoring_seam.py::test_an_entry_point_registers_the_local_git_corpus_when_no_host_has` calls `cli.build_parser()` with nothing registered, then requires `corpus_adapter.home()` to return a factory whose adapter is a `WorkingTreeCorpus` instance (updated for the ruling above; was `LocalGitCorpus` before it).

**T011 (#46 → `0e88454a`), T012 (#47 → `2768302`) and T016 (#42 → `19370adc`) have all landed**, so `opendox.cli`/`opendox.serve` import cleanly, `domain_profile.register_default()` runs at the same entry points this task's own registration does, and this whole file runs for real -- the ordinary way, with the root conftest in play, no `--noconftest`, no shim, no skip:

```
$ python -m pytest -q tests/test_authoring_seam.py
............
12 passed in 0.30s
```

All twelve pass (ten at the T016 merge, plus two more added during the Copilot remediation below: an end-to-end classify-through-the-default falsifier, and the same entry-point coverage for `serve.build_server()`). Every `try: cli.build_parser() except domain_profile.ProfileNotRegistered: pass` tolerance in this file is now genuinely dead code -- T016 landed, so `build_parser()` no longer raises at all -- kept only as a harmless compatibility fallback, and the two stale docstrings/comments that used to describe this as a live "SKIPS today" condition were corrected during the Copilot rounds below.

The remaining two cases (`test_register_default_home_leaves_an_existing_registration_alone`, `test_register_default_home_registers_where_nothing_has`) exercise `corpus_adapter.register_default_home()` directly, over stand-in factories, and always ran unconditionally -- no shim, no `--noconftest`, needed neither before this merge nor after.

(Historical note, preserved for the record: before this merge, the two `importorskip`-gated cases above skipped under both plain and `--noconftest` runs -- `8 passed, 2 skipped` -- and were verified only under the Group 2 simulation shim, `research.md`'s Appendix, giving `10 passed`. That shim is no longer needed for anything in this PR and was never committed.)

## Falsifier: F4.1's scan is unchanged

This task registers a default; it does not remove a deferred reach, and `corpus_adapter`/`local_git_adapter` name neither `openxdox` nor `ideation_dashboard` nor `doc_health` nor `corpus_adapter_openxfactory`. Re-run at the `main`-merged head (`8a3625e`) against `main`'s OWN current tip (`9d13bd16`, carrying T021+T011+T012 -- T011/T030 and T012 each removed a hit of their own, which is why the absolute count dropped from the 23/24 seen in earlier rounds of this PR to **19** here): both `main` at `9d13bd16` and this merged head scan to exactly **19**, identical hits by identity (same file, same imported name, same enclosing function) -- the only per-line differences are the expected line-number shifts in `cli.py` (610→618) and `serve.py` (640→647, 2055→2106) from this task's own registration call and `_default_home_factory` sitting above them. Zero new reaches, zero removed, confirmed by a normalized diff against a fresh worktree at `main`'s exact merged-in commit.

**Not re-run against the full scan tool after the T016 merge or the Copilot remediation rounds below**, since neither touched an import statement: T016's own two files (`domain_profile.py`, `cli.py`/`serve.py`'s registration lines) are unrelated to this scan's targets, and every file the Copilot rounds touched (`local_git_adapter.py`, `tests_runtime/test_local_git_adapter.py`, `tests/test_authoring_seam.py`) was grepped directly for the same four names at the final head -- the only hits are pre-existing prose in `authoring.py`'s comments/docstrings (`doc_health.corpus...`, `doc_health.lines...`, and the `corpus_adapter_openxfactory` name inside a docstring describing what T021 REMOVED), none of them an actual import or attribute reach.

## The repository's own checks, replayed locally

`validate.yml`'s three pytest steps are unaffected (no slice edits `validate.yml` before T036; this task's new/changed tests are not in any of its file lists, except `tests_runtime/test_local_git_adapter.py`, which IS on the `runtime, hermetic` step's list) — replayed at each stage, file lists read directly from the workflow file each time:

| step | at #44's head (`f6f07ae`) | pre-ruling (`d86677c`) | post-ruling (`d6abe60`) | `main`+T016 merged in, final (`9283278`) |
|---|---|---|---|---|
| `pytest` | 745 passed, 2 skipped | 745 passed, 2 skipped | 745 passed, 2 skipped | 767 passed, 2 skipped |
| `pytest (S7 residue)` | 13 passed | 13 passed | 13 passed | 13 passed |
| `pytest (runtime, hermetic)` | 361 passed | 361 passed | 361 passed\* | 372 passed |

(The `pytest` step's `746 → 767` climbs further than the earlier `745 → 746` because several more upstream PRs (T025/T026/T027 and others) merged into `main` between the earlier checkpoints and this final one, all touching files already on that step's list, none of them this task's own doing -- same reasoning as the earlier `745→746`, just a larger number of intervening merges by this point. The `runtime, hermetic` step's `361 → 372` is fully this task's own: 11 new cases added across the Copilot remediation rounds below, all in `tests_runtime/test_local_git_adapter.py`.)

(The `pytest` step's `745 -> 746` is identical to what #44 itself measured post-merge -- not investigated to the single test name, but confirmed NOT this task's doing: this task's own new tests are all in `tests/test_authoring_seam.py`, which is not on this step's file list at all, and the same `+1` appears on #44's branch, which carries none of T022's changes. `tests_runtime`'s total floats by ±1 across repeated runs at the SAME commit -- a pre-existing, environment-timed flake unrelated to this change, recorded once and not re-investigated at every stage.)

**\*One genuine regression surfaced mid-way, caught before commit, not a flake:** `WorkingTreeCorpus`'s first cut of `_read_bound`'s `except OSError as failed:` branch put `str(failed)` straight into a refusal, and `tests_runtime/test_runtime_cli.py`'s anti-leak walk correctly flagged it (`1 failed, 360 passed` — see "The working-tree ruling" section above for the fix and the exact failure text). Fixed by routing the text through `redact_credentials(str(failed))`, matching this file's own established idiom; every `361 passed` in the table above (including at this PR's very first, pre-ruling head, where the bug did not yet exist) is genuinely clean.

**The whole `tests/` directory** (real conftest throughout at and after the `main` merge; the Group 2 shim only for the two earlier, pre-T011 stages):

| tree | result |
|---|---|
| #44's head (`f6f07ae`), with shim | `20 failed, 1242 passed, 13 skipped, 66 errors` |
| #45 pre-ruling (`d86677c`), with shim | `20 failed, 1245 passed, 13 skipped, 66 errors` |
| #45 post-ruling (`d6abe60`), with shim | `20 failed, 1246 passed, 13 skipped, 66 errors` |
| `main` merged in (`8a3625e`), REAL conftest, no shim | `18 failed, 1432 passed, 13 skipped, 66 errors` |

The `20→18` failed and `66` unchanged errors match #44's own post-merge numbers exactly (both branches merged the same `main`). JUnit test-by-test diff (by `classname::name`, exact) between the pre-ruling and post-ruling shimmed heads: zero outcomes changed, one new passing test (the working-tree falsifier). The jump to `1432` passed at the merged head is `main`'s own T010/T011/T012 tests joining the run for the first time (this PR touches none of them) plus this file's own count going from 6 (T021-only, on the old base) to 10 (all of T022's, all genuinely running now).

## T016 merged in

Merged `main` (carrying T016, `19370adc`) into this branch at `ea83200`. One real conflict, in `cli.py`/`serve.py`: both T016's `domain_profile.register_default(default_profile)` and this task's own `corpus_adapter.register_default_home(_default_home_factory)` wanted to be the literal first statement in `build_parser()`/`main()` and `build_server()`/`main()`. Resolved by keeping T016's call first (it has an immediate downstream read in the same function) and this task's second, with a comment explaining the order; also fixed a now-stale comment in `serve.py` left over from before the merge. A second conflict, in `tests/test_authoring_seam.py` (main's squashed T021 and this branch's pre-squash T021 ancestor carrying the same content by different commit objects, the identical class of conflict the earlier `main` merge hit), resolved the same way -- "theirs" contributed nothing, confirmed by an empty post-resolution diff.

## Copilot's review, in full: eleven rounds, every finding fixed

Per the standing instruction to wait for Copilot's review AT THE HEAD before READY -- and to read the review body, not just trust a green check-run conclusion -- eleven successive rounds of Copilot review each found something real after the T016 merge, every one fixed and verified red-before/green-after before moving to the next. In finding order:

1. **Temp-directory classification was broken by the T016 merge's own registration**: once the default registered for real, `authoring._classify_proposal()` staged its input in a plain, non-git `TemporaryDirectory`, and `WorkingTreeCorpus.resolve()` requires a git repository -- every classification call started refusing `CORPUS_UNCLASSIFIABLE`. Fixed with a `_stage_as_a_repository_if_git_is_available()` step, gated by the registered adapter's own MODULE NAME (never `isinstance`, preserving `_classify_proposal`'s "no privileged direct call" principle) so a host's non-git adapter is never affected.
2. **Path-traversal and symlink-escape in `_read_bound`**: a plain `Path(corpus.location) / document.key` open was vulnerable to an absolute-key override, `..` traversal, and a symlinked intermediate component. Fixed with a new `_open_confined()` -- a component-by-component, `O_NOFOLLOW`-at-every-step, descriptor-relative open -- plus name-based rejection of absolute/`..`/`.git`/NUL keys.
3. **The listing could advertise what `read()` could not serve**: gitlinks, untracked nested checkouts, and tracked-but-deleted files. Fixed with mode-based gitlink filtering, trailing-slash nested-repo filtering, and a per-candidate existence check through the same confined open.
4. **A pinned `CorpusRef.revision` was silently ignored** in favor of current disk bytes. Fixed by also checking `corpus.ref.revision`.
5. **`git init`'s ambient environment**: `GIT_TEMPLATE_DIR` was missing from the shared environment sanitizer, so an ambient template directory could plant a repository-local `info/exclude` into a staged tree (demonstrated live: a hostile template really does get copied in unsanitized, and doesn't once filtered); a test helper (`_init_ordinary_checkout`) and this PR's OWN new test for the fix above BOTH separately built their git subprocess environment from a raw `os.environ` copy instead of the shared sanitizer, the identical hazard found and fixed three times in three different places across this remediation, plus once more in this file's own long-standing shared `_GIT_ENV` fixture (exposed, not introduced, by this task's first fixture to call `git init` on a fresh location).
6. **A blocking read of a tracked FIFO could hang forever**, taking `list_documents()`'s own existence check down with it. Fixed with `O_NONBLOCK` on the leaf open plus an `S_ISREG` check.
7. **`read()` exposed files the corpus's own definition excludes**: a directly-constructed `DocumentId` for a `.gitignore`d secret (a `.env`, say) was served, because confinement-to-the-root is not the same guarantee as membership-in-the-corpus. Fixed with a new `_tracked_or_not_ignored()` check ("tracked always wins" over a later ignore rule; a git failure here is `CORPUS_UNREADABLE`, never a false "not tracked" -- the eleventh finding, on this fix's own first cut).
8. **Stale historical documentation**, twice: a module docstring and two individual test docstrings/comments still described `--noconftest`/skip behavior in the present tense after T011 and T016 had already landed on this branch, which would misreport current coverage to a future reader.
9. **Missing runtime test coverage** for `WorkingTreeCorpus` itself (a large new class with zero direct `tests_runtime/` cases before this remediation) and for `serve.build_server()`'s own registration line (AST-lifted, mirroring `test_profile_registration.py`'s established technique for the identical problem).

Every fix above was verified by first reproducing the exact failure against the pre-fix code (a manual repro script, a temporary revert via `sed`/direct text substitution, or a deliberately broken assertion), confirming it failed for the stated reason, fixing it, confirming green, and -- for anything touching a committed file -- confirming the revert-and-restore cycle left the file byte-identical to before. One mistake was caught and fixed within this same remediation, before it shipped: the first cut of finding 7's fix used `:(literal)key` pathspec magic, which `GitRunner`'s own pre-existing `--literal-pathspecs` flag (predating this session) turns from protective into actively wrong -- measured directly, then fixed by passing the bare key.

Every threaded finding got a reply citing the exact fixing commit, then was resolved via GraphQL; two "previously missed" findings (9's `WorkingTreeCorpus` coverage gap, and one instance of 5's `_GIT_ENV` hazard) had no inline thread to reply to at all -- Copilot's overview lists them without a `#discussion_r` link -- so their reasoning lives only in the fixing commit's own message. **Zero unresolved review threads remain as of the final head.**

## Status: READY

Final head `9283278`. Working tree clean, T016/T011/T012 all landed and merged in, all three `validate.yml` steps green (767p/2s, 13p, 372p), `tests/test_authoring_seam.py` at 12 passed, the anti-leak scan and the home-vocabulary scan both green, zero unresolved Copilot review threads.

🤖 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants