Skip to content

Remove serve.py's two import-time reaches into openxFactory (plan 034 T011, with T030) - #46

Merged
brettheap merged 5 commits into
mainfrom
build/034-p1a-t011-t030-import-time-reaches
Sep 27, 2026
Merged

brettheap merged 5 commits into
mainfrom
build/034-p1a-t011-t030-import-time-reaches

Conversation

@brettheap

@brettheap brettheap commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Plan 034, tasks T011 and T030 (T030's "Lands with: T011"), slice P1-A (the route seam). The plan is specs/034-opendox-standalone-operation/tasks.md at opensoft/openxFactory main. It has been unchanged since a65230f6 and was re-read at 79a720a2. This PR realizes boxes 2.1, 2.1a, 2.2 (openDox's half) and 2.4 of the ratified add-neutral-product-standalone-operability, and gives 9.2a its instrument (T036 makes a required check run it).

What changes

serve.py:199 imported openxFactory's lanes column, and :206 re-exported its five route names. So import opendox.serve needed a package openDox can never have. So did opendox.cli and opendox.notebook_action, which import it.

  • src/opendox/serve.py:

    • both statements are deleted;
    • serve_openxfactory_lanes.LaneRoutes is off DashboardHandler's bases. A host now declares that column under HANDLER_CONTRIBUTIONS, and build_server composes it (T010);
    • comments at both sites record why.

    The module is not vendored (2.1a). No openDox reader of the five names remains (2.2). The web bundle's repo-selector.js keeps its own ACTIONS_REFRESH_ROUTE spelling, and tests/test_split_route_tails.py reads the bundle, not opendox.serve.

  • tests/test_consumer_reach.py moves opendox.cli and opendox.serve into NEUTRAL_MODULES in this act, as its record test asks, and sets the pre-carve census to zero.

    • The record is empty now, so it is walked inside ONE test.
    • An empty parametrize would be reported as a skip, and validate.yml pins SKIPPED at exactly 3.
  • tests/test_imports_standalone.py (T030, new) imports every module of the package in a fresh interpreter.

    • It first asserts that no sibling (openxdox, ideation_dashboard, doc_health, corpus_adapter_openxfactory) is importable.
    • It imports the package itself, then every module the package's .py files define, in sorted order, so a package precedes its own modules. A package whose __init__ fails, the root included, is imported and reported; pkgutil.walk_packages would skip its children. The test process only finds the package, so its __init__ runs in the sweep alone.
    • It fails naming the FIRST module that did not import, and tells apart a sibling, a failure inside openDox's own package, a missing extra, and a third-party module of the wrong version.
    • Only once every module imports does it hold the sweep complete against pkgutil's own walk.
  • Four passages that said opendox.serve or opendox.cli cannot be imported now say so in the past tense and name T011. They are in docs/profile-registration-runbook.md, docs/runtime.md (twice), tests/test_source_core_arm.py's docstring, and tests/test_consumer_reach.py's STILL_REACHING comment. src/opendox/runtime/cli.py:20-26 makes the same claim and is left to T038, which plan 034 gives that file's comments. The comment at validate.yml:291 is T036's.

  • tests/test_route_handler_contribution.py gains section 6, which drives build_server itself, now that opendox.serve imports. Its cases:

    • the profile's mixin and a caller extension's own, composed after the core and served against the live handler;
    • a binding no class answers, refused at the END of the build by resolve_handlers. It checks the class that will dispatch the route, which is composed last, and the case asserts the snapshot source WAS bootstrapped;
    • a shadowing contribution, an MRO no class can take, and a name the core sets on its instances. Each is refused BEFORE the snapshot source is bootstrapped.

The falsifiers (T011: F2.1's generated sweep, T030's named test, the facet file with its build_server case, and tests/test_consumer_reach.py)

F2.1, run verbatim at a827744 and again at c99b187, the last change to the sweep. Only PATH and TMPDIR were set, so that python resolves to 3.12 and the scratch space stays in this lane's directory. The script's own lines were not changed. It exits 0:

every module of opendox imports with no sibling
.                                                                        [100%]
1 passed in 0.99s

Before the sweep, its sibling loop found none of the four importable. The last line is tests/test_imports_standalone.py::test_every_module_imports_with_no_sibling, with the conftest in play. The install left an untracked build/, which was removed.

The named test bites. In a scratch copy with serve.py:199 restored at its import position, the test fails:

AssertionError: opendox.cli does not import with no sibling installed: it still needs the sibling 'ideation_dashboard'.
  ModuleNotFoundError: No module named 'ideation_dashboard'
  Every other module that failed: opendox.notebook_action, opendox.runtime.app, opendox.runtime.db, opendox.runtime.oidc, opendox.serve

(The runtime.* modules also fail there, because that venv holds .[test] alone, as the next section says.)

The facet file with its build_server cases, with and without the conftest, at 344989a: 91 passed. The build_server cases:

test_build_server_composes_the_class_it_binds_through_the_facet PASSED
test_a_name_the_bound_class_sets_is_refused_before_build_servers_side_effects PASSED
test_build_server_composes_the_declared_mixins_into_the_class_it_binds PASSED
test_a_caller_extensions_own_mixin_is_served PASSED
test_build_server_refuses_a_binding_no_class_answers PASSED
test_build_server_refuses_a_shadowing_contribution_before_its_work PASSED
test_a_profile_that_declares_nothing_binds_the_core_alone PASSED
test_build_server_refuses_what_type_cannot_compose_before_its_work PASSED
test_build_server_refuses_a_name_the_core_sets_on_instances_before_its_work PASSED

tests/test_consumer_reach.py, which the required check runs by name: 31 passed, with and without the conftest, and no skip.

The repository's own check

The three report-producing pytest steps of .github/workflows/validate.yml were run locally. Their file lists were read out of the file itself, and the results were summed the way Pin the triple sums them. The venv was Python 3.12.3 with -c constraints-cpython312-linux.txt -e ".[test]".

  • at 3c637b2: selected=1122 passed=1119 skipped=3 failures=0 errors=0, as at a827744. The pins are >=1114, >=1111 and ==3.
  • One earlier run of the same tree failed one runtime case. It was tests_runtime/test_local_git_adapter.py::test_the_group_is_signalled_from_the_id_saved_at_popen_not_looked_up_later, with ValueError: invalid literal for int() with base 10: ''. The test waits for a pid file to EXIST and then reads it, and the shell's echo $$ > file can create the file before it writes. This PR touches neither that test nor its module. Alone, the case passed 20 runs of 20, and the triple re-run above is clean. It is recorded here as a race that predates this PR.

The whole suite, with the conftest, run in the same .[test] venv: 19 failed, 1418 passed, 13 skipped, 66 errors.

  • The red files are research R3's nine, less test_consumer_reach, which this PR turns green. The counts per file are unchanged: test_doxbench_abstract_pane 28, test_outline_tab 25, test_doxbench_composition 13, test_provider_boundary 12, test_doxbench_memory_gateway 3, test_boundary 1, test_doxbench_mcp 1 and test_outline_model 1.
  • The one addition is T030's own test. In a .[test]-only venv it names opendox.runtime.app, which "needs 'fastapi', which is not a sibling", and it asks for the sweep to run where every extra is installed, as F2.1 does. T036 gives the test extra the runtime packages.

F4.1's scan (scan_deferred_reaches.py from research.md's appendix, sha256 fe11620319b0…, matching the recorded digest) lists 21 deferred reaches at main 0f10b1f and 21 at this head.

  • Only the serve.py entries' line numbers moved, by the comments this PR adds.
  • T011's two reaches are at import time, so F2.1 proves them, not F4.1.
  • _head_of's doc_health.corpus (now serve.py:723) is T012's.

pyflakes, run on serve.py against main's copy, shows no new warning and five fewer: the five unused lane-name re-exports.

Review

Copilot 5328452123 at a827744 opened two threads, and both are answered and resolved.

  • The standalone-import test is not in the required CI. By plan it is not yet. T036 makes a required check run it ("9.2a (a required check now runs T030)"), and validate.yml is T036's. Wiring it in now would also turn the .[test]-only job red, as the thread reply shows.
  • A refusal after bootstrap. A binding no class answers is refused at the end of the build, by design. 344989a narrows the section's claim to say so, and pins it with standalone.source.bootstrapped is True.

Copilot 5328465598 at 344989a reported no findings and raised two items in its overview, both taken, as the PR comment shows:

  • a subpackage whose __init__ fails would have been skipped by the walk. 24fbcb9 imports the file-derived list, which is demonstrated on a scratch copy with a failing subpackage;
  • stale consumer-reach documentation, fixed in 3c637b2 as listed under "What changes".

Copilot 5328489225 at 3c637b2 reported no findings. It asked that internal import failures be classified correctly, and that the root package be included in the diagnosis. Both were taken in c99b187, and each verdict was demonstrated on a scratch copy, as the PR comment shows.

After a827744 no source file changed. The later commits touch tests and docs only, so the F4.1 and pyflakes runs above, made at a827744, stand for this head. F2.1, the triple and the whole suite were re-run. The whole suite at 3c637b2 gives 19 failed, 1418 passed, 13 skipped, 66 errors, with the same 85 red cases, none new and none gone.

Readers outside this repository

Neither of these is an openDox-side reader, so 2.2's openDox half does not move them:

  • openXdox-code tests/test_repo_selector.py reads opendox.serve.ACTIONS_REFRESH_ROUTE. It is in the doc_health-blocked set that T041 excludes.
  • openxFactory tests/ideation-dashboard/test_extension_point_parity.py and test_serve_column_split.py pin LaneRoutes on DashboardHandler. T045 updates them, and declares HANDLER_CONTRIBUTIONS = (LaneRoutes,) in scripts/profile_openxfactory.py.

Two observations, for phase 2 and 3

  • A standalone /capabilities can still advertise refresh where no class answers POST /actions/refresh, because that handler is openxFactory's LaneRoutes.
  • plan.md's "Phase-1 limit" note names the injected snapshot source alone. Measured, a standalone build_server also meets _checkout_real, which imports openxdox.corpus_root, and compute_capabilities' reads of registry_mod.BINDING_*. Section 6's fixture stubs all three, and says so.

Landing

  • It depends on T010, which landed as 0f10b1f.
  • It lands by squash or merge, never rebase. A squash message is built from the commit messages, which carry both trailers. A merge landing must write them into the merge message.
  • serve.py has one writer at a time. T012 follows this PR, then P1-B's T016.

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

🤖 Generated with Claude Code

… T011, with T030)

serve.py:199 imported openxFactory's lanes column, and :206 re-exported
its five route names. So `import opendox.serve` needed a package openDox
can never have (#1144 task 2.1). So did opendox.cli and
opendox.notebook_action, which import it.

- Both statements are gone.
- serve_openxfactory_lanes.LaneRoutes is off DashboardHandler's bases. A
  host now declares that column under HANDLER_CONTRIBUTIONS, and
  build_server composes it (T010, R1Q1 (a)).
- The module is not vendored (2.1a). No openDox reader of the five names
  remains (2.2): the web bundle's repo-selector.js keeps its own
  ACTIONS_REFRESH_ROUTE spelling, and tests/test_split_route_tails.py reads
  the bundle, not opendox.serve.

tests/test_consumer_reach.py moves opendox.cli and opendox.serve into
NEUTRAL_MODULES in the same act, as its record test asks, and sets the
pre-carve census to zero. The record is empty now, so it is walked inside
one test: an empty parametrization would be a skip, and validate.yml pins
SKIPPED exactly.

T030 lands here. tests/test_imports_standalone.py imports every module of
the package in a fresh interpreter with no sibling installed (#1144 task
2.4).

tests/test_route_handler_contribution.py gains section 6, which drives
build_server itself:
- a contributed route served against the live handler;
- a caller extension's own mixin;
- the refusals of a binding no class answers, a shadowing contribution,
  an MRO no class can take, and a name the core sets on its instances.
  The last three are each raised before the snapshot source is
  bootstrapped.

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 27, 2026 01:42
@sourcery-ai

sourcery-ai Bot commented Sep 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR makes opendox.serve independently importable by removing its two import-time reaches into openxFactory, shifting lane-route handler composition to the build-time contribution facet, and adds standalone import coverage plus end-to-end validation of composition and refusal behavior.

Sequence diagram for build-time handler composition

sequenceDiagram
    participant Host
    participant build_server
    participant Facet as HandlerContributionFacet
    participant DashboardHandler
    participant BoundHandler

    Host->>build_server: build_server(...)
    build_server->>Facet: compose_handler(...)
    Facet-->>build_server: composed handler class
    build_server->>DashboardHandler: bind composed class
    DashboardHandler-->>BoundHandler: serve requests with core and contributed routes
    build_server-->>Host: server
Loading

Flow diagram for standalone import validation

flowchart TD
    start[Start fresh interpreter]
    siblings[Assert sibling packages are unavailable]
    walk[Walk every opendox .py module]
    import[Import each module]
    result{Import succeeds without sibling?}
    pass[Pass standalone import test]
    fail[Fail with first module and missing dependency]

    start --> siblings --> walk --> import --> result
    result -->|yes| pass
    result -->|no| fail
Loading

File-Level Changes

Change Details Files
Remove openxFactory dependencies from openDox's import path and move lane-route composition to build time.
  • Delete the lane-column import and five route-constant re-exports from serve.py.
  • Remove LaneRoutes from DashboardHandler and rely on host-declared handler contributions composed by build_server.
  • Document the non-vendored boundary and preserve the core handler's standalone importability.
src/opendox/serve.py
Update consumer-reach accounting so the import-time dependency carve is recorded as complete without introducing a skipped test.
  • Move opendox.cli and opendox.serve into the neutral module set.
  • Set the pre-carve reaching record to empty and replace empty parametrization with one test that walks the record.
  • Update the AST-based reach census to expect zero remaining entries.
tests/test_consumer_reach.py
Add a fresh-interpreter package-wide standalone import sweep with actionable dependency diagnostics.
  • Assert all four sibling packages are absent before importing anything.
  • Walk every package module and verify the generated walk exactly matches on-disk Python files.
  • Report the first failing module and distinguish sibling reaches from missing declared extras or other import failures.
tests/test_imports_standalone.py
Exercise handler-contribution composition through the real server build path and validate preflight refusals.
  • Verify profile and caller-extension mixins are composed after the core and their routes are served by the live handler.
  • Verify empty contributions remain valid and undeclared bindings are rejected.
  • Verify shadowing, unlinearizable MROs, and instance-state name collisions fail before snapshot/bootstrap side effects.
tests/test_route_handler_contribution.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

Required CI does not run the new tests, and one test’s pre-bootstrap ordering claim is not currently enforced.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

Removes openxFactory import-time dependencies from opendox.serve and adds build-time handler composition for standalone operation.

Changes:

  • Removes lane-route imports, re-exports, and inheritance.
  • Adds standalone import-sweep coverage.
  • Adds live handler-composition tests.
  • Updates consumer-reach tracking.
File Description
tests/​test_route_handler_contribution.py Tests build-time composition and dispatch behavior.
tests/​test_imports_standalone.py Adds sibling-free import validation.
tests/​test_consumer_reach.py Records cleared import-time reaches.
src/​opendox/​serve.py Removes host-specific import-time dependencies.

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

Comment thread tests/test_imports_standalone.py Resolved
…ew of #46)

Copilot's review of #46 at a827744 found that section 6's docstring
claimed every refusal is raised before the snapshot source is
bootstrapped. The case of a binding no class answers does not bear that
out. That refusal is resolve_handlers', and it runs at the end of
build_server.

It belongs there. resolve_handlers checks the class that will dispatch
the route, and build_server composes that class last, because its
namespace carries values the build computes. A check against an earlier
class would be a check against a class that never dispatches (T010's
guarantee).

So the claim is narrowed. A contribution that cannot be composed is
refused beside the bindings, before bootstrap, as the shadowing, MRO and
instance-state cases assert. A binding no class answers is refused at the
end. That case now asserts the snapshot source WAS bootstrapped, so the
narrowed claim is enforced rather than stated.

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 27, 2026 01:49

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

🔵 Needs a closer look

The standalone import test has a moderate discovery gap, and stale consumer-reach documentation remains unresolved.

Review effort: Lite
Findings: None

Resolved since last review (2)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Preserve subpackage import failures during module discovery

tests/​test_imports_standalone.py:67

pkgutil.walk_packages(..., onerror=lambda name: None) can hide the import failure of a subpackage while discovering its children. For example, if opendox.foo.__init__ raises ModuleNotFoundError for a sibling, the walk yields opendox.foo, calls onerror, and never yields opendox.foo.child; this test then reports a completeness mismatch instead of recording opendox.foo as the first failing module and naming the missing sibling. Discover module names from the package files (or make the walk callback preserve the package failure) and run the import loop over that complete list.

…before completeness (review of #46)

Copilot's review of #46 at 344989a found, as "previously missed", that
the sweep discovered its modules with pkgutil.walk_packages(onerror=...).
When a subpackage's __init__ fails, the walk yields the package, calls
onerror, and never visits its children. The test then checked
completeness first, so it reported "Never walked: [...]" instead of naming
the subpackage and the sibling it needs.

The sweep now imports every module the package's .py files define, in
sorted order, so a package precedes its own modules. The test reports the
first import failure before anything else. Only once every module imports
does it hold the sweep complete against pkgutil's own walk.

Demonstrated on a scratch copy with a subpackage whose __init__ imports
ideation_dashboard. The new test names "opendox._probe_subpackage ... it
still needs the sibling 'ideation_dashboard'", and lists its child among
the other failures. The test as it was reported only the walk mismatch.
F2.1 still exits 0, and the negative control with serve.py:199 restored
still names opendox.cli first.

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 27, 2026 01:54

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

🔵 Needs a closer look

The standalone import test has two unresolved diagnostic issues, and related dependency-boundary documentation is stale.

Review effort: Lite
Findings: None

…nse (review of #46)

Copilot's review of #46 at 344989a said that stale consumer-reach
documentation remained. Four passages still said that opendox.serve or
opendox.cli cannot be imported at this leg, or that STILL_REACHING
records them. T011 ends both:

- docs/profile-registration-runbook.md, the paragraph before the AST
  lifting. It now says why the lifting was needed, and that T011 moved
  both modules into NEUTRAL_MODULES. The paragraph is apart from the
  runbook hunk that P1-B's #42 adds.
- docs/runtime.md, twice: the note on why the runtime verbs are not in
  build_parser, and the list of what validate's narrowing still holds.
- tests/test_source_core_arm.py's docstring: why that file reads
  serve.py as source.
- tests/test_consumer_reach.py: the tense of STILL_REACHING's comment,
  whose entries T011 moved.

src/opendox/runtime/cli.py's header makes the same claim at :20-26. It is
left to T038, the landing plan 034 gives that file's comments to. The
comment in validate.yml at :291 is T036's.

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

Copy link
Copy Markdown
Contributor Author

Copilot's review of 344989a (review 5328465598, no findings) raised two items in its overview. Both are taken, at 24fbcb9 and 3c637b2:

  1. "Preserve subpackage import failures during module discovery" ("previously missed", tests/test_imports_standalone.py:67). Confirmed and taken in 24fbcb9.

    • The sweep now imports every module the package's .py files define, in sorted order, so a package precedes its own modules.
    • The test reports the first import failure before anything else. Only once every module imports does it hold the sweep complete against pkgutil's own walk.

    This was demonstrated on a scratch copy with a subpackage whose __init__ imports ideation_dashboard. The new test fails like this:

    AssertionError: opendox._probe_subpackage does not import with no sibling installed: it still needs the sibling 'ideation_dashboard'.
      ModuleNotFoundError: No module named 'ideation_dashboard'
      Every other module that failed: opendox._probe_subpackage.child, ...
    

    The test as it was reported only the walk did not visit exactly the package's modules. Never walked: ['opendox._probe_subpackage.child']. F2.1 still exits 0 (1 passed), and the negative control with serve.py:199 restored still names opendox.cli first.

  2. "Stale consumer-reach documentation." Taken in 3c637b2. Four passages still said that opendox.serve or opendox.cli cannot be imported at this leg, or that STILL_REACHING records them. Each now says it in the past tense and names T011:

    • docs/profile-registration-runbook.md, the paragraph before the AST lifting;
    • docs/runtime.md, at the note on the runtime verbs and at the list of what validate's narrowing still holds;
    • tests/test_source_core_arm.py's docstring;
    • tests/test_consumer_reach.py's STILL_REACHING comment.

    Two more carry the same claim and are left to the landings plan 034 gives them. src/opendox/runtime/cli.py:20-26 belongs to T038, which "corrects two comments in src/opendox/runtime/cli.py". The comment at .github/workflows/validate.yml:291 belongs to T036.

At 3c637b2:

  • test_consumer_reach.py and test_source_core_arm.py give 56 passed.
  • tests_runtime/test_deploy_shape.py, which reads docs/runtime.md, gives 86 passed.
  • The validate triple is selected=1122 passed=1119 skipped=3 failures=0 errors=0.

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

Copilot AI review requested due to automatic review settings September 27, 2026 01:59

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

🔵 Needs a closer look

The standalone import test needs to correctly classify internal import failures and include the root package in diagnostic coverage.

Review effort: Lite
Findings: None

…too (review of #46)

Copilot's review of #46 at 3c637b2 asked for two things in the standalone
import test: that it classify internal import failures correctly, and that
it include the root package in its diagnosis.

- Classification. Any ImportError used to be read as "this environment
  lacks a package openDox declares", including a failure inside openDox's
  own package. The verdicts are now told apart:
  - a sibling, the finding this test exists for;
  - a module of openDox's own that does not import, a defect of openDox;
  - a missing third-party package, a missing extra;
  - a third-party module that lacks an imported name, the wrong version;
  - anything else, a defect.
- The root. `opendox` itself was imported outside the recorded loop, and
  this test process imported it too. A failing root __init__ therefore
  surfaced as a collection error, not as a named module. The sweep now
  imports `opendox` first as a recorded module, and this process only
  FINDS the package.

Each verdict was demonstrated on a scratch copy:
- a root __init__ importing ideation_dashboard: "opendox ... still needs
  the sibling 'ideation_dashboard'". The test as it was failed to collect.
- a missing opendox module: "a module of openDox's own that does not
  import, which is a defect in openDox".
- `from json import no_such_name`: "the installed 'json' lacks what openDox
  imports from it".

F2.1 still exits 0. The `.[test]`-only run still names opendox.runtime.app
for fastapi, and the negative control still names opendox.cli.

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 27, 2026 02:05
@brettheap

Copy link
Copy Markdown
Contributor Author

Copilot's review of 3c637b2 (review 5328489225, no findings) asked for two things in the standalone import test. Both are taken in c99b187, and each verdict was demonstrated on a scratch copy.

  1. "Correctly classify internal import failures." Every ImportError used to be read as "this environment lacks a package openDox declares". The verdicts are now told apart:
    • a sibling;
    • a module of openDox's own that does not import, a defect of openDox;
    • a missing third-party package, a missing extra;
    • a third-party module that lacks a name openDox imports, the wrong version;
    • anything else, a defect.
    opendox._probe_internal does not import with no sibling installed: it imports 'opendox._no_such_module', a module of openDox's own that does not import, which is a defect in openDox, not a reach.
    opendox._probe_version does not import with no sibling installed: the installed 'json' lacks what openDox imports from it, so this environment's version is not the one openDox declares.
    
  2. "Include the root package in diagnostic coverage." opendox itself was imported outside the recorded loop, and the test process imported it too. So a failing root __init__ was a collection error: the test as it was gave ImportError while importing test module ... ModuleNotFoundError: No module named 'ideation_dashboard'. The sweep now imports opendox FIRST, as a recorded module, and the test process only finds the package with importlib.util.find_spec:
    opendox does not import with no sibling installed: it still needs the sibling 'ideation_dashboard'.
    

The real checkout still behaves as before:

  • F2.1 exits 0 (1 passed).
  • The .[test]-only run still names opendox.runtime.app for fastapi, with and without the conftest.
  • The negative control with serve.py:199 restored still names opendox.cli and its sibling.

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

@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

🔵 Needs a closer look

The broad import and build-time composition changes warrant final human review, with one documentation nit remaining.

Review effort: Lite
Findings: None

@brettheap
brettheap marked this pull request as ready for review September 27, 2026 02:10

@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 19 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@brettheap

Copy link
Copy Markdown
Contributor Author

READY at c99b187 — Lane: openxfactory-4 (openXfactory-4-openDox_extraction)

@brettheap
brettheap merged commit 0e88454 into main Sep 27, 2026
5 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

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

LANDED — lane openxfactory-4, 2026-09-27T02:16:31Z, PR #46 → 0e88454 (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
…alGit (plan 034 T012) (#47)

Plan 034, task **T012**, slice P1-A (the route seam). The plan is `specs/034-opendox-standalone-operation/tasks.md` at opensoft/openxFactory `main`. It has been unchanged since `a65230f6` and was re-read at `bca4a260`. This PR realizes box **4.3** of the ratified `add-neutral-product-standalone-operability` (openxFactory#1144), for one of its eight reaches into openxFactory.

- **Ruled:** R1Q22 (a), in openxFactory#656 comment `5817152735`. The edit to a carved file needs no declared-edit act.
- **Claim:** openxFactory#656 comment `5850112604`.
- **After:** T011, which landed in #46 as `0e88454a`. This branch is cut from that main.

The task entry, as it reads at `bca4a260`:

> - [ ] T012 [US1] [oDc] **`serve.py:713`** (`doc_health.corpus.RealGit` in `_head_of`). Replace it with openDox's own HEAD reader. It must keep degrading to `None`.
>   - **Realizes**: 4.3 (1 of the 8 reaches into openxFactory).
>   - **Falsifier**: F4.1's scan no longer lists `serve.py:713`.
>   - **Ruled**: R1Q22 (a).
>   - **After**: T011.

`:713` was measured before T011 added its comments. At main `0e88454a` the same reach is at `serve.py:723`.

## What changes

- **`src/opendox/serve.py`**:
  - `_head_of` imported `doc_health.corpus.RealGit` inside its `try`. openDox never has that package, so the import raised first. Standalone, the HEAD was always `None`, and an injected `git=` reader was never consulted.
  - `_CheckoutHead` (new, private) is openDox's own reader. It makes the read `RealGit.head_sha` made, `git -C <checkout> rev-parse HEAD`, with the same 30-second bound. Every failure is `None`.
  - `_head_of` keeps its signature, its `git=` seam and its outer `except Exception: return None`.
  - `import subprocess` joins the standard-library imports.
- **`tests/test_checkout_head.py`** (new) has 8 cases:
  - a real checkout's HEAD is read with `doc_health` made unimportable through `sys.modules`, so the case holds where openxFactory's package is installed too;
  - `None` for a directory that is not a repository (`GIT_CEILING_DIRECTORIES` keeps git from finding one above it), an unborn HEAD, no `git` on the `PATH`, a `git` that does not answer in time, and an injected reader that raises;
  - an injected reader answers instead of git, and is handed the checkout as a `Path`;
  - `serve.py` imports `doc_health` nowhere, function-local imports included.

## Parity with the reader it replaces

openxFactory `main`'s `scripts/doc_health/corpus.py`, at `3c077874`:

```python
_GIT_TIMEOUT_SECONDS = 30                                    # :417

    def _run(self, repo: Path, *args: str) -> str | None:    # :424
        try:
            proc = subprocess.run(["git", "-C", str(repo), *args],
                                  capture_output=True, text=True,
                                  timeout=_GIT_TIMEOUT_SECONDS)
        except (subprocess.TimeoutExpired, OSError):
            return None
        return proc.stdout if proc.returncode == 0 else None

    def head_sha(self, repo: Path) -> str | None:             # :739
        out = self._run(repo, "rev-parse", "HEAD")
        return out.strip() if out else None
```

The argv, the bound and the verdict on a non-zero exit are the same. There are two differences, and both answer `None`:
- `subprocess.SubprocessError` is caught. It is `TimeoutExpired`'s base class.
- An answer that is all whitespace is `None`, where `RealGit` returned `""`.

Where `doc_health` is importable, as in openxFactory, the same `git` command runs as before.

## The falsifier

**F4.1's scan** is `scan_deferred_reaches.py` from research.md's appendix. Its sha256 is `fe11620319b0…`, the digest `evidence/remeasure-2026-09-25.md` records. It was run from the repository root, as research R5 runs it.

At main `0e88454a` it prints `21 deferred reaches`, three of them in `serve.py`:

```
src/opendox/serve.py:639: openxdox.corpus_root  [in _checkout_real]
src/opendox/serve.py:723: doc_health.corpus  [in _head_of]
src/opendox/serve.py:2032: openxdox.corpus_root  [in _refuse_impossible_checkout_root]
```

At this head `05b3b5e` it prints `20 deferred reaches`, two of them in `serve.py`:

```
src/opendox/serve.py:640: openxdox.corpus_root  [in _checkout_real]
src/opendox/serve.py:2055: openxdox.corpus_root  [in _refuse_impossible_checkout_root]
```

With line numbers set aside, the two lists differ by `_head_of`'s entry alone. The two that remain are phase 2's (research R5).

**The new tests:** `8 passed`, with and without the conftest.

**Five mutations** of the reader were each made in a scratch copy and run with `--noconftest`. Each is caught:

| mutation | result | the cases that fail |
|---|---|---|
| T1: back to `doc_health`'s `RealGit` | 4 failed | the HEAD read with `doc_health` unimportable; the timeout; the injected reader that answers; `serve.py` imports `doc_health` nowhere |
| T2: no timeout | 1 failed | the timeout |
| T3: the exit status ignored | 1 failed | the unborn HEAD. There, `git rev-parse HEAD` prints `HEAD` and exits 128 |
| T4: the injected reader ignored | 2 failed | both injected-reader cases |
| T5: no degrade around the reader | 1 failed | the injected reader that raises |

**Standalone, through `build_server`.** A scratch probe builds a server over a fresh one-commit checkout. `doc_health` is made unimportable and no `head=` is passed, so `_head_of` runs. The probe uses section 6's three phase-1 stand-ins, from `tests/test_route_handler_contribution.py`. It reads the bound class's `head`, which `_divergence_headers` sends as `X-Source-Head`:
- at main `0e88454a`: `None`, so the header was empty and the divergence `unknown`;
- at this head: the checkout's own `git rev-parse HEAD`.

## The repository's own check

The three report-producing pytest steps of `.github/workflows/validate.yml` were run locally. Their file lists were read out of the file itself, and the results were summed the way `Pin the triple` sums them. The venv was Python 3.12.3 with `-c constraints-cpython312-linux.txt -e ".[test]"`.

- At `05b3b5e`: `selected=1122 passed=1119 skipped=3 failures=0 errors=0`, as at main. The pins are `>=1114`, `>=1111` and `==3`.
- The new file is not one of the triple's named files. T036 makes the required check run the whole suite, and so this file.

**The whole suite, with the conftest**, in the same venv:
- main `0e88454a`: `19 failed, 1418 passed, 13 skipped, 66 errors`;
- this head: `19 failed, 1426 passed, 13 skipped, 66 errors`.

The 85 red cases are the same at both, none new and none gone. The 8 added cases are this PR's, and all pass. The red files are research R3's nine, less `test_consumer_reach`, which #46 turned green. They also include T030's own test, which in a `.[test]`-only venv names the missing runtime extra, as #46 recorded.

**F2.1**, run verbatim at `e47a482` with only `PATH` and `TMPDIR` set, exits 0: `every module of opendox imports with no sibling`, then `1 passed`. T012 removes no import-time reach, but `serve.py` gains a module-level import, so the sweep was re-run. The install left an untracked `build/`, which was removed. `05b3b5e` changes only `tests/test_checkout_head.py`, which the sweep does not run.

**pyflakes** on `serve.py` reports 92 warnings at main and the same 92 here. The new test file has none.

## Review

Copilot `5328572760` at `e47a482` recommended approval. It reported no findings and opened no thread. Its overview raised one nit: `test_a_checkouts_head_is_read_with_doc_health_unimportable` reads awkwardly. `05b3b5e` renames it `test_the_head_of_a_checkout_is_read_with_doc_health_unimportable`.

SonarCloud's quality gate passed, with two new issues. Both were `python:S9083`, "Remove empty parentheses from this decorator", on the new file's two `@pytest.fixture()` lines. `05b3b5e` makes both bare.

No assertion changed. The new tests, the five mutations, F4.1, the triple and the whole suite were re-run at `05b3b5e`, with the results above.

Copilot `5328584437` at `05b3b5e` recommended approval, with no findings. SonarCloud reports no open issue at `05b3b5e`.

## Landing

- It depends on T011, which landed as `0e88454a`.
- It lands by squash or merge, never rebase. This body carries both trailers, and so does each commit message. A merge landing must write them into the merge message.
- `serve.py` has one writer at a time. This is P1-A's last `serve.py` edit, and P1-B's T016 (#42) follows it. Its entry reads "**After**: T015, T012 (Lane A's last `serve.py` edit)".

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
Brings in T011 (#46, 0e88454: remove serve.py's two import-time
reaches) and T012 (#47, 2768302: read a checkout's HEAD with openDox's
own reader), plus the T010/T025/T026/T027 merges already folded into
main earlier. opendox.cli and opendox.serve now import cleanly, so
T021's named test can run for real (no shim, no importorskip skip).

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

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
brettheap added a commit that referenced this pull request Sep 27, 2026
main is 2768302. It carries P1-A's T010 (#40), T011 (#46) and T012 (#47),
which T016 waits for, and P1-E's T025 (#43) and T027 (#41).

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
…nded)

#44 (T021) squash-landed as 9d13bd1, bringing T011 (#46) and T012 (#47)
in with it (already merged into #44's own branch earlier this session,
now folded in via main's squash instead). T022's own diff (cli.py,
serve.py, corpus_adapter.py, local_git_adapter.py,
tests/test_authoring_seam.py) is layered on top of what main now has.

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

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

# Conflicts:
#	tests/test_authoring_seam.py
brettheap added a commit that referenced this pull request Sep 27, 2026
…ly before a build (T016) (#42)

## Summary

Plan 034's **T016** (openxFactory `specs/034-opendox-standalone-operation/tasks.md`, slice P1-B), which realizes box **3.2** of the ratified `add-neutral-product-standalone-operability` (#1144): registration semantics, on R1Q3 (a) with (i) and (ii), and RN-1 (a).

- **The entry points register openDox's default where nothing is registered.** `cli.build_parser()`, `serve.build_server()`, `cli.main()` and `serve.main()` each open with `domain_profile.register_default(default_profile)`, one line each. Afterwards `is_registered()` answers True. The default is an entry-point registration and never a fallback inside `current()`.
- **A bare process that builds nothing still meets `ProfileNotRegistered`** (R1Q3 (i)). `profile_proxy`'s nothing-registered refusal is kept, never weakened into `()`. `current()`'s refusal now names the default. It says that nothing is registered now, either because nothing was built through an entry point or because `unregister()` has dropped the registration since.
- **A host registration made before anything is built replaces the default** (RN-1 (a)). That covers a host that registered first, which the default then never displaces. It also covers a default an entry point registered that nothing has been built from yet, for example after `serve.main()` has registered it at process start.
- **After a parser or a server was built from the default, a host registration is refused** with today's `AlreadyRegistered` (R1Q3 (ii); RN-1 (a)). The message names the default and the build, and says to register before the first build, or to call `unregister()` first for a deliberate swap.
- **Re-registering the object already registered stays a no-op, the default included.** The registration keeps its kind, a host's or the entry point's default, and a build from the default stays on record.
- **What counts as a build.** Only a composition point's read of the facet it composes from. Those are `SUBCOMMAND_EXTENSIONS` in `cli.build_parser()` and `ROUTE_EXTENSIONS` in `serve.build_server()`, the two facets `profile_proxy._LateProfile.READERS` names. Those reads go through `domain_profile.current_for_build()`, which is `current()` plus the record. Every other read only asks and records nothing: `is_registered()`, `current()`, `repr`, a dunder probe, the proxy's `resolve()`, and the `DISPLAY` and `VIEW_EXTENSIONS` reads. So none of these closes the window in which a host still replaces the default: openXdox's `_upstream()`, `view_extension.host_profile_name()`, `display_profile.host_display()`, `view_extension.host_view_facet()` and `canvas_drafts`. T010's optional `HANDLER_CONTRIBUTIONS` is not one of the two reads either: a server's build is recorded at its `ROUTE_EXTENSIONS` read.

## Authority

- Ratified packet: openxFactory#656 comment [`5815412869`](opensoft/openXfactory#656 (comment)).
- **R1Q3 (a)**, with (i) and (ii): openxFactory#656 comment [`5817152735`](opensoft/openXfactory#656 (comment)). *"The default profile and the default adapter are both entry-point registrations, and F3.1 line 2 is amended. 3.2's 'ambiguous registration' wording is corrected. A late host registration replaces the default until something is built, and is refused after that."*
- **RN-1 (a)**: openxFactory#656 comment [`5850003126`](opensoft/openXfactory#656 (comment)). *"reword requirement 3 so a host registration overrides the default only before anything is built from it, and add the after-build refusal scenario."* The requirement's text was amended by openxFactory#1170 (T007 batch D) → `79a720a2`. Its two scenarios are what this PR's cases assert. "A host registers its own profile" covers a registration before a build, which replaces the default. "A host registers a profile after a build from the default" covers the refusal.
- **T007 batch A**, openxFactory#1171 → `bca4a260`, records the ruled amendments to box 3.2 and to F3.1's line 2 in the packet. T016 carries out both, and the amended line 2 is the one run below.
- **R1Q22 (a)**: `cli.py` and `serve.py` are carved files, and no declared-edit act precedes an arc edit.
- The holder's readings on `DISPLAY` and on U4 (`ProjectSubcommand` stays out of the default) are recorded on openxFactory#656 comment [`5851560764`](opensoft/openXfactory#656 (comment)). `default_profile.py` cites both.
- **After**: T015, #38 → `a435aecf`; T012, #47 → `27683028`, with T010 (#40 → `0f10b1f5`) and T011 (#46 → `0e88454a`) before it. All are on `main`, and `main` @ `9d13bd16` is merged in.
- Claim: openxFactory#656 comment [`5850105728`](opensoft/openXfactory#656 (comment)).

## The falsifier

tasks.md, T016: *"**Falsifier**: F3.1 with line 2 as amended (T007 batch A); `tests/test_profile_registration.py`."* Batch A's amendment, now in the packet at `bca4a260`: *"The line asks after `build_parser()`: `python -c "from opendox.cli import build_parser; from opendox import domain_profile as d; build_parser(); print('OK', d.name_of(d.current()))"`. The prose under it adds that a bare process that builds nothing still meets `ProfileNotRegistered`, which `tests/test_profile_registration.py` asserts."*

F3.1 as #1144 writes it, with line 2 as amended, run from the checkout root. The run uses `python3` for `python`, and `pip install -q` to quiet the install:

```sh
set -euo pipefail
W=$(mktemp -d)
python3 -m venv --clear "$W/v3"
. "$W/v3/bin/activate"
pip install -q ".[test]"
python -c "from opendox.cli import build_parser; build_parser(); print('OK')"
python -c "from opendox.cli import build_parser; from opendox import domain_profile as d; build_parser(); print('OK', d.name_of(d.current()))"
python -m pytest -q tests/test_profile_registration.py
```

At `69fecb9d`, in a fresh venv, with nothing on `PYTHONPATH`. T011 is on `main`, so no shim stands in any more:

```
== F3.1, amended line 2, from the checkout root at 69fecb9, no shim
OK
OK opendox.default_profile
...................................................                      [100%]
51 passed in 1.25s
rc=0
```

Line 3 ran with the root conftest in play, as F3.1 runs it.

`tests/test_profile_registration.py` grows from 30 to 51 cases. Its new section 10 asserts the three cases and the seams between them:

| case (R1Q3, RN-1) | test |
|---|---|
| a bare process that builds nothing refuses (i) | `test_a_bare_process_that_builds_nothing_still_meets_the_refusal`, in a fresh interpreter that imports `opendox.cli`, `opendox.serve` and the default, and builds nothing |
| the entry points register the default (a) | `test_f3_1s_second_line_as_amended_names_the_default` (F3.1 line 2, verbatim, in a fresh process); `test_build_parser_registers_the_default_and_builds_on_it`; `test_cli_main_registers_the_default_and_builds_on_it`; `test_build_server_registers_the_default_before_its_first_read` |
| a host registration before a build replaces it (RN-1 (a)) | `test_a_host_registered_before_any_entry_point_keeps_its_own_tree` (no `runtime` command, so a host keeps its 31-entry tree); `test_a_host_registration_replaces_a_default_nothing_was_built_from`; `test_serve_main_registers_the_default_first_and_a_host_may_still_replace_it` |
| a host registration after a build is refused (ii) | `test_a_host_registration_after_a_build_from_the_default_is_refused`, whose message names the default, the build, `5634195861`, R1Q3 (ii), RN-1 (a) and `unregister()` |
| what is a build | a composition point's read of its facet is, once per `READERS` facet (`test_a_composition_points_read_of_its_facet_is_a_build`). Asking is not (`test_asking_which_profile_is_registered_is_not_a_build`), and nor is a read that only asks: the profile's name, `DISPLAY`, `VIEW_EXTENSIONS`, `canvas_drafts` and `resolve()` (`test_a_read_that_only_asks_is_not_a_build`) |
| the other seams | `unregister()` clears the default and its build. Re-registering the object already registered is a no-op, the default included (three cases). `register_default()` never displaces a registration and refuses `None`. The refusal names the default, and after `unregister()` it claims nothing about what the process built |

`build_server()` and `serve.main()` are held from their own lines, lifted by AST, as this file already holds the server's composition point: a server still reaches `openxdox` to be BUILT in phase 1 (research R7), and `serve.main()`'s `--ref` default reads `openxdox.snapshot_registry` (T055, phase 2). The parser and `cli.main()` are run for real.

**Runs at `69fecb9d`**, in a venv built as `validate` builds one (`pip install -c constraints-cpython312-linux.txt -e ".[test]"`):

| run | result |
|---|---|
| `--noconftest tests/test_profile_registration.py tests/test_default_profile.py` | `68 passed` |
| `validate.yml`'s three pytest steps with its "Pin the triple" arithmetic | `selected=1143 passed=1140 skipped=3 failures=0 errors=0`, OK. `main` @ `9d13bd16` gives `1122 / 1119 / 3`, and the 21 more are this slice's new cases |
| CI at `69fecb9d` | `validate`, `runtime` and SonarCloud all green |
| the whole suite, `python -m pytest -q` with the root conftest in play, `main` @ `9d13bd16` against this branch | `19 failed, 1427 passed, 13 skipped, 66 errors` against `19 failed, 1448 passed, 13 skipped, 66 errors`. The 85 red results are the same set on both, in nine files. Eight are research R3's, and T011 cleared its ninth, `tests/test_consumer_reach.py`. The other is `tests/test_imports_standalone.py` (T011), which asks for every extra and passes on both under `pip install -e ".[runtime,test]"` |

**The tests can fail.** Each mutation below was applied to the checkout at `69fecb9d`, `tests/test_profile_registration.py` re-run without any shim, and the file restored:

| mutation | failed |
|---|---|
| `build_parser()` loses its registration line | 3: F3.1 line 2, the parser test, the after-build refusal |
| a host always replaces the default, even after a build (RN-1 (b)) | 6: the server test, the `cli.main()` test, the after-build refusal, both composition-facet builds, the build kept on record |
| a host never replaces the default | 7: both before-build replacements, the after-build refusal's wording, both not-a-build cases, both re-registrations of the default |
| `current()` falls back to the default (R1Q3 (b)) | 9: every refusal case, the bare process among them |
| `current()` records a build | 4: the `serve.main()` window, both not-a-build cases, re-registering before a build |
| `build_server()` reads `ROUTE_EXTENSIONS` before it registers | 1: the server test |
| `serve.main()` loses its registration line | 1: the `serve.main()` test |
| no read records a build | 6: the server test, the `cli.main()` test, the after-build refusal, both composition-facet builds, the build kept on record |
| every read records a build, `resolve()` included (`46519d61`'s proxy) | 1: the read that only asks |
| re-registering the same object falls through (`c755147b`'s `register()`) | 2: both re-registrations of the default |
| the refusal claims the process built nothing (`aee57d5e`'s text) | 1: the refusal after `unregister()` |

`tests/test_default_profile.py`'s facets test now also asserts that the default declares no `HANDLER_CONTRIBUTIONS`. Declaring `HANDLER_CONTRIBUTIONS = ()` fails it.

## Copilot's review

- **At `c755147b`**, *"Changes recommended"*, one thread. `register()` fell through on the object already registered, so re-registering the default cleared its bookkeeping. Fixed in `1dee448e` (the re-registration row above). The thread was answered with the failing run, and it is resolved.
- **At `46519d61`**, *"Changes recommended"*, one thread. Every proxy read went through `current_for_build()`, so `view_extension.host_profile_name()` and `canvas_drafts._facet()` closed the window with nothing built. I reproduced it read by read in fresh processes: all eight reads were refused before the fix, and after it six let a host replace the default. Fixed in `aee57d5e`, at the proxy (the two read-recording rows above). The thread was answered and is resolved.
- **At `aee57d5e`**, *"Needs a closer look"*, no thread, and one note under "previously missed". `current()`'s refusal claimed "this process has built nothing through one", even after `unregister()` had dropped a default that a parser was built from. Fixed in `16d597b8` (the last row above).
- **At `16d597b8`** and **at `69fecb9d`**, *"Needs a closer look"*, Findings: None. At `69fecb9d`: *"The registration lifecycle and build-boundary changes require final human review."* No thread is open.

## The files, and why each is touched

- `src/opendox/domain_profile.py`: `register_default()` and `current_for_build()` are new. `register()` gains a same-object early return, the before-build replacement and the after-build refusal. The refusal texts and the docstrings say what is now true. `is_registered()` and `current()`, the duck-typed contract openXdox's `_upstream()` reads, answer as before, and only the refusal's words changed.
- `src/opendox/profile_proxy.py`: `__getattr__` records a build for the `READERS` facets only. `resolve()` and every other read go through `current()`. The docstrings say which read is a build, and that the nothing-registered refusal is kept.
- `src/opendox/cli.py` and `src/opendox/serve.py`: the one-line calls, and the one paragraph each that said the unregistered case refuses.
- `src/opendox/default_profile.py`: its registration paragraph now describes what the entry points do. Its facet list names T010's `HANDLER_CONTRIBUTIONS`, which it does not declare, and it cites the holder's readings on `DISPLAY` and U4. `tests/test_default_profile.py` asserts that absence.
- `docs/profile-registration-runbook.md`: `current()`'s refusal cites it as the operational contract, and its body described the contract this PR changes. It is a `Status: record`, so it is not rewritten. It gains a pointer under its introduction and a closing section, "The default profile, since plan 034". That section states the new contract, says what counts as a build, and lists what it supersedes, down to rows of the first refusal table. `README.md`'s index row for it follows, one line.

## Left for the tasks that own them

- `tests/test_consumer_reach.py` (T034), `.github/workflows/validate.yml` (T036) and the root `conftest.py` (T035) are not touched. `opendox.default_profile` is not in `test_consumer_reach.py`'s `NEUTRAL_MODULES`. `tests/test_default_profile.py` asserts its import claim in a fresh interpreter with the siblings blocked, and T034 re-derives the census. `conftest.py`'s comment still says *"openDox ships no profile"*. Its `_SuiteProfile` registration stays correct: it registers before any build, so every suite keeps composing the core surface.
- `build_parser()`'s and `build_server()`'s docstrings still carry the stale pre-carve sentence the runbook lists as owed. This PR adds nothing false there, and it leaves that debt to the act that takes it.
- A suite that registers a stand-in profile should register it before it builds, or call `unregister()` first. Once an entry point has built from the default in a process, the default is that process's registration. The suites that register today are this file, `tests/test_view_registry.py` and `tests/test_route_handler_contribution.py`, and all three unregister around every case that registers. The other two put back what they found through `register()`. So an entry point's default found there would come back as a host's registration. No suite depends on that difference today, and neither file is this slice's.

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>
brettheap added a commit that referenced this pull request Sep 27, 2026
note

One low-severity "previously missed" finding from Copilot's review at
5626a1d (no inline thread): "Update outdated T011 coverage note". The
module docstring's own explanation of which cases needed
--noconftest and why still said T020/T021's cases raise
ModuleNotFoundError "until T011 lands" and T022's named test "SKIPS...
until T011 lands", in the present tense, but T011 landed several
commits ago on this branch (#46 -> 0e88454) -- opendox.cli/
opendox.serve import cleanly now and every case in this file runs for
real. Reworded both paragraphs into past tense, kept as history (why
the file was originally shaped this way) rather than deleted, and
noted plainly that the imports/skip guards that used to matter are now
retained only as harmless defensive guards, not because anything is
still expected to skip.

Documentation only -- no code or test logic changed. 12 passed,
unchanged.

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

Co-Authored-By: Claude Sonnet 5 <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>
brettheap added a commit that referenced this pull request Sep 27, 2026
…into openxFactory at all (#49)

Plan 034, task **T032**, slice P1-F (the sweep and the nine-file repair). The plan is `specs/034-opendox-standalone-operation/tasks.md` at opensoft/openxFactory `main` `468863d1`, where round 2 (#1176) has landed. The T032 through T035 entries there are byte-identical to `0d48231b`'s, which this record was first written against. This PR realizes box **2.3** of the ratified `add-neutral-product-standalone-operability`.

- **Ruled:** R1Q22 (a), openxFactory#656 comment `5817152735`.
- **Claim:** openxFactory#656 comment `5852380744`.
- **After:** T011, T012, T016, T021, T022, T025–T027 ("every lane joins here"). **All have landed.** T022 landed last, as #45 → `255514df`, merged in at `5270acf0`. T038 then landed as #48 → `796838e8`, and `main` at `796838e8` is merged in (`dc8fa87a`, no force-push). Everything below was re-run at this head, `b53b9db2`.

## The sweep (2.3)

The four names in import position under `src/`: import statements, and `importlib.import_module(...)` or `__import__(...)` with a literal name. Every hit is classified by when it runs. It was run at the arc's base, openDox-code `1e4a57fb` (ARC_BASE, `evidence/arc-base.md`), and at `main` `796838e8`. That is where the last lane (T022) joined, plus T038's console script. This PR changes nothing under `src/`, so this head gives the same result.

| | at `1e4a57fb` | at `796838e8` |
|---|---|---|
| import-time reaches | 2 (`ideation_dashboard`) | **0** |
| deferred reaches into openxFactory | 8 | **0** |
| deferred reaches into `openxdox` | 19 | **19** |

**Closed: every reach into openxFactory, and every import-time reach.**

| reach at `1e4a57fb` | target | closed by | landed |
|---|---|---|---|
| `serve.py:199`, `:206` (import time) | `ideation_dashboard.serve_openxfactory_lanes` | T011 (2.1), the handler-contribution facet | #46 → `0e88454a` |
| `serve.py:713`, `_head_of` | `doc_health.corpus` (`RealGit`) | T012, openDox's own HEAD reader | #47 → `27683028` |
| `authoring.py:318`, `_classify_proposal` | `corpus_adapter_openxfactory` | T021, `corpus_adapter.home()` | #44 → `9d13bd16` |
| `workbench.py:746`, `session_documents` | `doc_health.corpus` | T025, the registered adapter's `list_documents` | #43 → `c46430fb` |
| `workbench.py:1407`, `:1408`, `:1409`, `run_scoped_doc_health` | `doc_health`, `.families`, `.runner` | T026, the health-check seam | #39 → `582ed073` |
| `serve_wire.py:1369`, `default_doxbench_validators` | `ideation_dashboard.doxbench_contracts` | T027, the doxBench validator seam | #41 → `8017cd52` |
| `doxbench_packet.py:177`, `_status_exemption` | `ideation_dashboard.doxbench_status_exemption` | T027, the status-exemption seam | #41 → `8017cd52` |

**Deferred: 19 reaches, all into `openxdox`, each inside a function body.** Each is routed no later than the phase whose surface calls it (research R5, the release map). openXdox-code's `OPENDOX_BACK_IMPORTS` ratchet counts them by module: `branch_session` 7, `serve_workbench` 7, `serve` 2, `serve_project` 2, `cli` 1.

| reach at `796838e8` | target | inside | reason it stays, and who routes it |
|---|---|---|---|
| `branch_session.py:1568` | `openxdox.generator` | `_change_rows` | the snapshot generator is openXdox's column; phase 2, T055 (5.4/5.5) |
| `branch_session.py:1587` | `openxdox.register` | `_active_pick_fallbacks` | the cross-reference register; phase 3, T084 |
| `branch_session.py:2005` | `openxdox.kickoff` | `proposal_state_for` | the kickoff column; phase 3, T084 |
| `branch_session.py:2105`, `:2151`, `:2228`, `:3573` | `openxdox.snapshot_registry` | `session_entry`, `register_session_entry`, `refresh_session_snapshot`, `refresh_main_view` | the snapshot registry; phase 2, T055 |
| `cli.py:628` | `openxdox.snapshot_registry` | `_session_registry` | the snapshot registry; phase 2, T055 |
| `serve.py:648` | `openxdox.corpus_root` | `_checkout_real`, called by every `build_server` | the corpus-root predicate; phase 2, T055 (research R7) |
| `serve.py:2118` | `openxdox.corpus_root` | `_refuse_impossible_checkout_root`, called by `serve.main()` | the corpus-root predicate; phase 2, T055 |
| `serve_project.py:246`, `:247` | `openxdox.gate_console`, `openxdox.kickoff` | `_serve_project_register` | the gate console and kickoff; phase 3, T084 |
| `serve_workbench.py:347`, `:544`, `:1665`, `:2607` | `openxdox.doxbench_scope` | `_is_live_session_ref`, `_handle_workbench_thread`, `_handle_workbench_chat_turn`, `_handle_workbench_document_abstract` | doxBench scope; phase 3, T084 |
| `serve_workbench.py:407`, `:408` | `openxdox.gate_console`, `openxdox.gate_routes` | `_thread_gate` | the gate column; phase 3, T084 |
| `serve_workbench.py:1215` | `openxdox.gate_console` | `_handle_workbench_model_approval` | the gate column; phase 3, T084 |

The line numbers moved since research R5 (`cli.py:610` → `:628`, `serve.py:629` → `:648`, `serve.py:1993` → `:2118`), with the code that phase 1, T022 and T038 added. The reaches and their functions did not.

**The late seam, which the scan cannot read.** `consumer_reach.py` holds seven `module(...)` stand-ins (`gate_console`, `snapshot`, `snapshot_registry`, `corpus_root`, `generator`, `serve_projection`, `serve_gate`). Each resolves `openxdox.<name>` at first use. `module()` refuses a prefixed name, so no stand-in can name another package. Research R6's census is unchanged: 65 use sites, in `serve.py` 22, `branch_session.py` 20, `cli.py` 18, `serve_workbench.py` 4 and `workbench.py` 1. They are deferred too, into `openxdox` alone, and T084 retires the module.

**Prose, not import position.** `git grep -w` finds each name in `src/` beyond these: `ideation_dashboard` on 44 lines, `doc_health` on 25, `corpus_adapter_openxfactory` on 2, and the rest of `openxdox`'s 57. Every one of them outside the table above is a comment, a docstring or a string. Several docstrings still describe the pre-carve layout. `serve_project.py:30`, `serve_wire.py:80`, `serve_workbench.py:33` and `doxbench_scope_types.py:40` say *"this module uses ABSOLUTE `ideation_dashboard.*` imports"*. None of them is a reach. They sit in carved files with other writers, so this PR leaves them. A later edit to each file can correct its sentence.

## What changes

**`tests/test_reach_sweep.py`**, a new file, so the sweep's result is held and not only recorded here. It parses `src/` whole, the two top-level extension modules included, as F4.1 parses the package, and it asserts four things:
1. no reach into any of the four runs at import time;
2. no reach of any kind names `ideation_dashboard`, `doc_health` or `corpus_adapter_openxfactory`, in either spelling (the pre-carve `scripts.` one too), the phase-1 cut of 4.3;
3. every reach left is deferred and into `openxdox`, the positive form of F4.1 "lists only `openxdox` targets";
4. no code under `src/` spells an openxFactory package's name at all. That means no string or bytes literal outside documentation, because every import needs the name, however the importer is reached.

**It does not pin the count of 19.** openXdox-code's ratchet already counts those reaches, and each one that T055 or T084 routes simply stops being one. So no later task has to edit this file when a reach closes. A reach may not come back at import time, and none may go into openxFactory. No instrument watched that direction (#1144 task 9.2a), and `tests/test_imports_standalone.py` proves only its import-time half, where no sibling is installed. On this tree, the sweep itself finds exactly F4.1's 19, all `openxdox` and all deferred.

**How it reads a module.** It reads by syntax, not by grep. Prose names the four packages on purpose.
- **Statements.** Import statements, including `from a import b`'s members as the submodules they may be (`from scripts import doc_health`). A star member is named too.
- **Calls.** `import_module` and `__import__` calls with a literal name, by position, as `name=`, or spelled out of a literal `*[...]`/`**{...}`, and under an import alias.
- **Relative names.** They are resolved against a literal `package`. `__import__` resolves against its `globals`: `globals()` is the module's own, and a literal `{"__package__": ...}` resolves. `__import__`'s literal `fromlist` also counts.
- **A module that holds an importer as a value** (assigns, passes, stores it, or looks it up by name) is read strictly. Every call with a literal module name counts there, read as either importer, since it may be bound to either.
- **Refused as UNREADABLE:** a call whose module a spread hides; a relative call whose package or context is unknown; a relative call that leans on `globals()` or `__package__` in a module that rebinds them; a `fromlist` that is not a literal; and a star import, in either form, from a package a sibling lives under (`from scripts import *`). A star from `os` names nothing.
- **Not refused:** a computed name, which is how `consumer_reach`'s seam imports.
- **Timing.** Where position and run time part (`TYPE_CHECKING`, postponed annotations, a generator), it reads position, the stricter reading. PEP 695's lazy positions are read as deferred.
- **What it is not.** It is a regression guard for the code this repository writes, not a sandbox. A name built from pieces at run time is review's to hold, and at import time the runtime sweeps (`test_imports_standalone.py`, `test_consumer_reach.py`) hold it too.

**`tests/import_scan.py`**, the shared reader, which exists so that no direction check keeps its own copy of the extraction. The node reader `names_imported_by` and its helpers live there, and `imported_modules` reads with it. Every new behaviour is opt-in, so `imported_modules`' output, `bound_names`', and `string_literals`' default output are identical to `main`'s reader over every parsed file in this repository: 141 files, 1524 imports, 0 differ. The three callers of `imported_modules` give the same result with and without the edit.

## The falsifier: F4.1's scan, which lists only `openxdox` targets

`scan_deferred_reaches.py`, research.md's appendix, persisted in opensoft/brett-wip. Its sha256 is `fe11620319b02c23dd9a014bc581e1f4867f013f3c26890d43b12dccce5530a0`, which matches the digest `evidence/remeasure-2026-09-25.md` records. Run from this head, `python3 scan_deferred_reaches.py src/opendox`:

```
src/opendox/branch_session.py:1568: openxdox  [in _change_rows]
src/opendox/branch_session.py:1587: openxdox.register  [in _active_pick_fallbacks]
src/opendox/branch_session.py:2005: openxdox  [in proposal_state_for]
src/opendox/branch_session.py:2105: openxdox.snapshot_registry  [in session_entry]
src/opendox/branch_session.py:2151: openxdox.snapshot_registry  [in register_session_entry]
src/opendox/branch_session.py:2228: openxdox.snapshot_registry  [in refresh_session_snapshot]
src/opendox/branch_session.py:3573: openxdox.snapshot_registry  [in refresh_main_view]
src/opendox/cli.py:628: openxdox.snapshot_registry  [in _session_registry]
src/opendox/serve.py:648: openxdox.corpus_root  [in _checkout_real]
src/opendox/serve.py:2118: openxdox.corpus_root  [in _refuse_impossible_checkout_root]
src/opendox/serve_project.py:246: openxdox.gate_console  [in _serve_project_register]
src/opendox/serve_project.py:247: openxdox.kickoff  [in _serve_project_register]
src/opendox/serve_workbench.py:347: openxdox  [in _is_live_session_ref]
src/opendox/serve_workbench.py:407: openxdox  [in _thread_gate]
src/opendox/serve_workbench.py:408: openxdox  [in _thread_gate]
src/opendox/serve_workbench.py:544: openxdox  [in _handle_workbench_thread]
src/opendox/serve_workbench.py:1215: openxdox  [in _handle_workbench_model_approval]
src/opendox/serve_workbench.py:1665: openxdox  [in _handle_workbench_chat_turn]
src/opendox/serve_workbench.py:2607: openxdox  [in _handle_workbench_document_abstract]
19 deferred reaches
```

Every target is `openxdox`. At `1e4a57fb` the same tool printed 27, eight of them into openxFactory. F4.1 WHOLE, *"no deferred reach names the consumer or the publisher"*, is T089's, after T084 routes the last 19 and retires `consumer_reach.py`.

**The new test.** `python -m pytest -q tests/test_reach_sweep.py` at this head gives `35 passed`, with the root conftest and under `--noconftest`. The same file, with this head's `tests/import_scan.py`, run over `1e4a57fb`'s tree fails the three reach assertions:

```
AssertionError: 2 reach(es) into a sibling run at IMPORT time, so the module cannot be imported without it (#1144 task 2.1's defect): src/opendox/serve.py:199: ideation_dashboard (AT IMPORT TIME, in <module>); src/opendox/serve.py:206: ideation_dashboard.serve_openxfactory_lanes (AT IMPORT TIME, in <module>)
AssertionError: 10 reach(es) into openxFactory, which openDox can never install (#1144 task 4.3's phase-1 cut), or imports the source does not spell out (behind a spread, a star, or a context that is not a literal), which could be: src/opendox/authoring.py:318: corpus_adapter_openxfactory (deferred, in _classify_proposal); …
3 failed, 32 passed
```

**83 mutations, and each fails its assertion.** Each is a copy of this tree with one change. Roughly a third plant a reach in `src/`, and the rest weaken the reader or the sweep. The list is in the review record below, and the spec is kept with the slice's tools. Every finding in the review record was also planted at the head it was raised on, where it passed, before its fix.

## The repository's own check

`.github/workflows/validate.yml`'s three report-producing pytest steps, run as the file writes them, and summed as `Pin the triple` sums them. The venv was Python 3.12.3 with `-c constraints-cpython312-linux.txt -e ".[test]"`:

```
triple: selected=1155 passed=1152 skipped=3 failures=0 errors=0
pins:   selected>=1114 (margin 41) passed>=1111 (margin 41) skipped==3
```

This matches `main`. The new file is not on the workflow's list, and neither is any caller of `tests/import_scan.py`. T036 owns `validate.yml` and makes the whole suite the required run.

**The whole suite, with the root conftest**, in the same venv: `main` `796838e8` gives `19 failed, 1454 passed, 13 skipped, 66 errors`, and this head gives `19 failed, 1489 passed, 13 skipped, 66 errors`. A test-by-test JUnit diff shows no changed outcome, nothing gone, and 35 new cases, all this file's and all passing. The 85 red cases are research R3's nine files and T030's `.[test]`-only case. T034 repairs the nine.

## Review record (Copilot)

There were eighteen threads over fifteen rounds, plus four findings raised without a thread. Every thread is answered with its evidence and resolved. Copilot's review at `19b0ecc2` recommends approval, with no findings. Every finding was a way to reach a sibling that the reader did not follow. Each was planted at the head it was raised on, where it passed, and it fails since its fix.

| round, at | finding | fixed in |
|---|---|---|
| 1, `61b308ed` | `import_module(name=...)`; PEP 695 type parameters; one shared reader | `ae82e2b5` |
| 2, `ae82e2b5` | an import alias of `import_module` | `eece371e` |
| 3, `eece371e` | a relative `import_module` against a literal `package` | `9862669f` |
| 4, `9862669f` | "matched by the name it spells" (docstring) | `ab022702` |
| 5, `ab022702` | a destructured alias; a lawful consumer case | `d9d3f3f9` (a module holding an importer as a value is read strictly) |
| 6, `d9d3f3f9` | literal `*[...]` and `**{...}` | `981fce65` |
| 7, `5270acf0` | nested literal spreads | `e6bd5ef5` (UNREADABLE for any other spread) |
| 8, `e6bd5ef5` | an alias looked up by name; a keyword an unreadable entry overwrites | `4b0cb725` |
| 9–10, `4b0cb725`, `aa92f71a` | a bound package; custom `globals` | `aa92f71a` (the spelling check), `6cf729ef`, `c3283e55` |
| 11, `6cf729ef` | the `scripts.` spelling; the full-name match; a concatenated lookup key | `c3283e55` |
| 12, `c3283e55` | a shadowed `globals`; a rebound `__package__` | `1fdd7fbb` |
| 13, `1fdd7fbb` | `from scripts import doc_health` | `a5a7f745` |
| 14, `a5a7f745` | `__import__`'s `fromlist` | `0f7af1a1` |
| 15, `0f7af1a1` | a star import from `scripts`; with it, found in measuring, a strict module's calls read by one importer's rule only | `19b0ecc2`; `b53b9db2` names UNREADABLE for each case it stands for |

## Landing

- T022 (#45) and T038 (#48) have landed, and `main` `796838e8` is merged in. Everything above was re-run at this head.
- T034 comes after it: T034 re-derives `tests/test_consumer_reach.py`'s record against this sweep.
- Squash or merge, never rebase. Each commit message carries both trailers, and so does this body.

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>
brettheap added a commit that referenced this pull request Sep 27, 2026
…16.6's phase-1 repair) (#50)

Plan 034, task **T034**, slice P1-F (the sweep and the nine-file repair). The plan is `specs/034-opendox-standalone-operation/tasks.md` at opensoft/openxFactory `main` `468863d1`, where round 2 (#1176) has landed. The T034 entry there is byte-identical to `0d48231b`'s, which this record was first written against. This PR realizes box **9.1 (part)** and **16.6 (the phase-1 repair)** of the ratified `add-neutral-product-standalone-operability`.

- **Ruled:** R1Q2 (a) and R1Q22 (a), openxFactory#656 comment `5817152735`. Eight of the nine files are carved `moved_with_declared_edit` rows, and `tests/test_consumer_reach.py` has no row. None needs a declared-edit act.
- **Claim:** openxFactory#656 comment `5852380744`.
- **After:** T032, "whose sweep fixes the import inventory that the re-derived censuses must match". **It has landed**, as #49 → `68be484a`, after T022 (#45 → `255514df`) and T038 (#48 → `796838e8`). `main` at `68be484a` is merged in (`7e3dc9ff`, no force-push). Everything below was re-run at this head, `bc6b168d`. The inventory the sweep fixes is the one the re-derived record holds. At `68be484a` the sweep finds no reach at import time, and `STILL_REACHING`, which the record now derives on every run, is empty. The sweep's 19 deferred reaches sit in `branch_session`, `cli`, `serve`, `serve_project` and `serve_workbench`, the five modules openXdox-code's ratchet counts. The sweep's own file passes on this tree (`35 passed`).

## For T007's batch E and T047: what this PR moves to openxFactory

**Four test cases leave openDox-code and become NAMED openxFactory composition tests (R1Q2 (a)).** T007's batch E adds each destination path to F11.1's named set (`COMPOSITION_TESTS`) before T047 lands. T047's openxFactory PR lands the cases there, and T049 checks that they arrived. **`tests/test_session_harness.py` is not moved here.** It is in `collect_ignore`, and it is T035's.

**The holder's decision on the three memory-gateway cases: accepted under R1Q2 (a)** (relayed to this lane's writer, 2026-09-27). T034's text names only the outline case. The memory-gateway cases take the same route because the spec they read exists only in openxFactory.

| moved case | from (openDox-code) | to (openxFactory), proposed | why it cannot stay |
|---|---|---|---|
| `test_the_model_and_the_doc_health_family_agree_on_the_contract` | `tests/test_outline_model.py` | `tests/ideation-dashboard/test_outline_template_agreement.py` | It holds `views/outline-model.js`'s `REQUIRED_SECTIONS` and `QUESTION_SUBFIELDS` equal to openxFactory's `doc_health.families` (`_TEMPLATE_SECTIONS`, `_QUESTION_SUBFIELDS`). It imports `doc_health`, which openDox can never install. openDox has no checker of its own until Group 6 (release 2), so there is no openDox contract to rewrite it against. |
| `test_the_roster_is_exactly_the_promoted_capabilitys_requirements` | `tests/test_doxbench_memory_gateway.py` | `tests/ideation-dashboard/test_memory_gateway_roster.py` | It reads `openspec/specs/memory-gateway/spec.md`, the promoted capability that `doxbench_memory_gateway.CAPABILITY_REQUIREMENTS` is transcribed from. That spec is openxFactory's, and no openDox repository carries a copy (checked in openDox-spec, openDox, openXdox-spec, openXdox and openXdox-code). It failed on `FileNotFoundError`. |
| `test_the_tier_column_is_TRANSCRIBED_not_invented` | same | same | the same spec's tier block |
| `test_the_untiered_requirement_really_is_absent_from_the_tier_block` | same | same | the same spec's tier block |

Both destinations compose openDox at openxFactory's pin, which `scripts/carved_reach.py` already puts on the path for `tests/ideation-dashboard/`. The outline case then reads `openDox/code/src/opendox/web/views/outline-model.js` from the pin, and the memory-gateway cases import `opendox.doxbench_memory_gateway`. **The paths are proposals.** If T047's writer chooses others, batch E records what T047 lands. The cases' own text, verbatim from `main` `19370adc`, is below, so no archaeology is needed.

<details><summary>The outline-template agreement case (from <code>tests/test_outline_model.py</code>)</summary>

```python
def test_the_model_and_the_doc_health_family_agree_on_the_contract():
    """The surface and the checker must mean the same thing by conformance."""
    import sys
    sys.path.insert(0, str(REPO_ROOT / "scripts"))
    from doc_health import families

    js = MODEL_JS.read_text(encoding="utf-8")
    for _needle, label in families._TEMPLATE_SECTIONS:
        assert f'label: "{label}"' in js, f"model omits required section {label}"
    for field in families._QUESTION_SUBFIELDS:
        assert f'"{field}"' in js, f"model omits sub-field {field}"
```

`MODEL_JS` was `REPO_ROOT / "src/opendox/web/views/outline-model.js"`. At openxFactory it is the pinned leg's copy of that file.
</details>

<details><summary>The three memory-gateway roster cases (from <code>tests/test_doxbench_memory_gateway.py</code>)</summary>

```python
SPEC_PATH = REPO_ROOT / "openspec" / "specs" / "memory-gateway" / "spec.md"


# ===========================================================================
# THE ROSTER — transcribed, and asserted against the capability itself
# ===========================================================================


def test_the_roster_is_exactly_the_promoted_capabilitys_requirements():
    """The declaration is only complete if the roster it is complete OVER is
    the capability's own. Read from the promoted spec, so a requirement added
    upstream fails here rather than becoming a silent gap in the declaration."""
    published = {
        line[len("### Requirement: "):].strip()
        for line in SPEC_PATH.read_text(encoding="utf-8").splitlines()
        if line.startswith("### Requirement: ")
    }
    assert published == set(mg.CAPABILITY_REQUIREMENTS)


def _published_tiers() -> dict[str, str]:
    """The spec's OWN tier block, parsed: requirement name -> the tier line it
    is named on."""
    spec = SPEC_PATH.read_text(encoding="utf-8")
    block = spec.split("```text", 1)[1].split("```", 1)[0]
    published: dict[str, str] = {}
    for match in re.finditer(r"(M\d):((?:.|\n)*?)(?=\nM\d:|\Z)", block):
        tier, body = match.group(1), " ".join(match.group(2).split())
        for name in body.split(";"):
            published[name.strip().rstrip(".")] = tier
    return published


def test_the_tier_column_is_TRANSCRIBED_not_invented():
    """RE-PINNED (adversarial review, F7). The roster test checked NAMES only,
    so two wrong tier values sat in the column unchallenged: one requirement
    carried `M0` although the spec's tier block never tiers it at all, and
    `Expert Memory And Knowledge DBs Are Gateway-Governed` was FLATTENED to
    `M4` although the spec says in as many words that it follows the tier of
    the operation it mirrors. Both are now transcribed, and this test reads the
    spec's own block so neither error can recur silently."""
    published = _published_tiers()
    for requirement, declared in mg.CAPABILITY_REQUIREMENTS.items():
        named = [line for line in published
                 if line.lower().startswith(requirement.lower())]
        if not named:
            # Not tiered by the spec at all -- which the column must SAY.
            assert declared == mg.TIER_UNTIERED, requirement
            continue
        line = named[0]
        if line != requirement:
            # The spec qualifies this row rather than tiering it outright.
            assert declared == mg.TIER_MIRRORS_OPERATION, requirement
            assert "follows the tier of the operation it mirrors" in line
            continue
        assert declared == published[line], requirement


def test_the_untiered_requirement_really_is_absent_from_the_tier_block():
    published = _published_tiers()
    untiered = [name for name, tier in mg.CAPABILITY_REQUIREMENTS.items()
                if tier == mg.TIER_UNTIERED]
    # TWO since 2026-08-22: add-doxbench-editing-phase-b's archive promoted
    # `Subject-Free Local Consumers…` into the capability, and the spec's tier
    # block does not tier it either. The list stays EXACT rather than becoming
    # a membership check — an untiered requirement is a fact about the spec, so
    # a third one appearing should fail here and be looked at.
    assert untiered == [
        "Derived memory bindings validate against the neutral schema",
        "Subject-Free Local Consumers Declare Their Inapplicable Rails"]
    for name in untiered:
        assert not any(line.lower().startswith(name.lower())
                       for line in published)
```

`mg` is `opendox.doxbench_memory_gateway`, and the helper needs `import re`. At openxFactory, `REPO_ROOT` is openxFactory's own root, where the spec is (22 requirements at `0d48231b`, and `CAPABILITY_REQUIREMENTS` holds 22).
</details>

## The nine files (research R3), at `main` `68be484a` and at this head

With the root conftest in play, Python 3.12.3, `-c constraints-cpython312-linux.txt -e ".[test]"`. The nine files give the same results on `main` at `68be484a` as at `19370adc`:

| file | `main` | this head | cause | repair |
|---|---|---|---|---|
| `test_doxbench_abstract_pane.py` | 18 passed, 28 errors | 46 passed | § 3.4 slice S5 moved the workbench gate column out of the bundle, so a shell mounted with no column withholds the canvas, and the generate control with it | The harness is the host, so it contributes the column `app.js` resolves. It imports `_CONTRIBUTED_GATE` from `test_doxbench_view.py`, whose S7 note gives the reason, the way it already imports the DOM shim. The column answers `createGateLive` off the same `caps`, so the ungated and hosted mounts still have no gate. |
| `test_outline_tab.py` | 3 passed, 25 errors | 28 passed | the same | the same, and the pre-template sentence reads the SELECTION role's word from `NEUTRAL_DISPLAY`. It spelled openxFactory's "staged" before S7 parameterized it. |
| `test_doxbench_composition.py` | 13 errors | 13 passed | the same | the same |
| `test_provider_boundary.py` | 16 passed, 12 failed | 24 passed | 16.6's three stale reasons | See below. |
| `test_doxbench_memory_gateway.py` | 36 passed, 3 failed | 36 passed | read openxFactory's `openspec/specs/memory-gateway/spec.md` | the three cases move to openxFactory (above) |
| `test_consumer_reach.py` | 31 passed | 36 passed | none left after T011, whose bullet says *"T034 re-derives the rest of the file"* | re-derived: see below |
| `test_boundary.py` | 27 passed, 1 failed | 28 passed | the surface scan kept names whose `__module__` was the literal `"output_boundary"`, so after the carve every class fell out of the census | the guard's home is read off `output_boundary.__name__` |
| `test_doxbench_mcp.py` | 23 passed, 1 failed | 24 passed | the child was started as `-m ideation_dashboard.doxbench_mcp` with `PYTHONPATH=scripts/` | `-m opendox.doxbench_mcp` with `PYTHONPATH=src/` |
| `test_outline_model.py` | 47 passed, 1 failed | 47 passed | imported `doc_health` | the case moves to openxFactory (above) |
| **total** | **201 passed, 18 failed, 66 errors** | **282 passed** | | |

**`test_provider_boundary.py`, for 16.6's three reasons.** None of the twelve failures was a crossing. The file's docstring now records each reason.
1. **It read `snapshot_registry.py`**, its second HTTP-client holder, which the carve sent to openXdox-code. It is no holder in this package now, and the claim about it is not this leg's to make.
2. **It pinned seven per-module scan suites by filename.** The carve manifest sent five to openXdox-code (`test_doxbench_turns.py`, `test_doxbench_packet.py`, `test_doxbench_threads.py`, `test_doxbench_bridge.py` and `test_doxbench_mutation_boundary.py`) and left two in openxFactory (`test_doxbench_model.py` and `test_doxbench_status_exemption.py`, `stays_openxfactory_adapter`). `PRESERVED_SCANS` now pins the three this checkout carries. `PRESERVED_ELSEWHERE` records the seven with their homes, and a case asserts that none of them is here, so the record cannot go stale.
3. **Its sweep reached the runtime (§ 3.5).** `runtime/app.py` spells `Authorization` and `Bearer ` for the identity broker's token, which it checks on the way in. `runtime/oidc.py`, which verifies that token, spells `Authorization` in prose. Both are named as tier-two holders in place of `snapshot_registry.py`, and the provider tier is asserted absent from each, as it was from that module. The named list is an exemption, so it is not its own authority. Since review round 5, `test_the_identity_surface_is_the_runtimes_two_modules` holds it to exactly these two modules, and a third holder has to be argued on its own PR. `runtime/config.py` names `access_token` in `SECRET_PARAMETER_KEYS`, the credential names the runtime refuses and redacts. It gets one permit: that needle, in that module, only while that tuple still names it (read with `ast`), and no other provider-tier spelling there. Since review round 1, the permit covers only the tuple and the module's prose. The sweep asks `_spelled_in_code`, which reads every identifier, attribute name and string literal off the syntax tree outside the declaration and the documentation. A spelling there fails with its line. A case also holds the table to that one entry, not only to its size, so a second permit, or one moved to another module or needle, has to be argued on its own PR.

The boundary is still one module wide for anything that holds a provider credential. 16.6's own measurement agrees: only `doxbench_provider.py` reaches a model provider.

**`test_consumer_reach.py`, re-derived over the whole package.** T011 emptied `STILL_REACHING` by moving its only two entries.
- `test_the_record_is_the_whole_packages_own` now derives the record on every run. It imports every module the package's files define, in one interpreter, with all four siblings blocked. It follows the exception chain, because a stand-in resolved at import time raises `ConsumerReachUnavailable` with the `ModuleNotFoundError` as its cause. The modules that fail on a sibling must be exactly the record. Before this, a module outside `NEUTRAL_MODULES`, which names nine, could start needing `openxdox` at import time and pass the whole file. At this head none fails.
- Every other failure is classified, not dropped. The one read past is a module of `opendox.runtime` missing a package of the runtime extra, where the extra is not installed. In a `.[test]`-only venv, that is `app`, `db` and `oidc`, on `fastapi`, `psycopg` and `httpx`. Anything else fails the test by name: a syntax error, a broken module of openDox's own, an undeclared dependency, or a runtime package needed outside `opendox.runtime`. `RUNTIME_EXTRA` tables the extra's distributions with their import names, and `test_the_runtime_extra_is_the_one_pyproject_declares` holds its keys to `pyproject.toml`'s `runtime` list. `test_the_runtime_extras_modules_are_the_runtimes_own` holds the import names to two independent authorities, the runtime's own imports and the installed metadata. Each tabled name is one that a module of `opendox.runtime` imports. Every third-party package the runtime imports is tabled, or comes from one of the package's required dependencies. Where a tabled distribution is installed, each of its names is installed by it or by a distribution it requires.
- `CONVERTED_SITES` had fallen behind the tree by five names in two files: `branch_session.py`'s `gate_console`, the module whose nine default-argument reads the guard is named for, and `cli.py`'s `corpus_root_refusal`, `generate_snapshot`, `is_rfc3339_datetime` and `SCANNED_ROOTS`. They join the table. `test_every_name_bound_to_the_seam_is_guarded` holds the table equal to the names each module binds to the seam. None of the five is read at import time. The census reads every spelling of the seam:
  - `Y = <seam>.X`, its annotated form, and `Y = <seam>.module(...)`;
  - `<seam>` spelled as an alias of the module, as `opendox.consumer_reach` after `import opendox` or `import opendox.consumer_reach`, or through `from .. import consumer_reach` in a subpackage;
  - each of these wherever the module runs it at import time, a module-level `if` or `try` included.

  A wildcard import from the seam fails with its own message.

**Thirty-seven mutations, each a copy of this tree with one planted change, and each fails the assertion it targets.** One more runs in the `.[runtime,test]` venv. The first thirteen:
- an unlisted module gains a module-level `from openxdox import …`;
- an unlisted module resolves a stand-in at import time, which is caught through the exception chain;
- a new name is bound to the seam;
- `branch_session.py` reads `gate_console` at import time;
- a provider endpoint appears in a non-provider module;
- a `Bearer ` header appears in an unnamed module;
- the identity surface gains `MintedToken`;
- `SECRET_PARAMETER_KEYS` stops naming `access_token`;
- the redaction module gains `client_secret`;
- a carved-away scan suite comes back;
- the guard gains a public class the shim does not re-export;
- the pre-template sentence goes back to "staged topic";
- the abstract-pane harness loses its contributed column.

The twelve added in review round 1:
- an import-time `import doc_health` where a `doc_health` is installed;
- a module importing a missing module of openDox's own;
- a module that raises while importing;
- an undeclared dependency;
- `import fastapi` outside `opendox.runtime`;
- a runtime module importing a package the extra does not declare;
- a distribution added to pyproject's runtime extra and not tabled;
- `Y: T = consumer_reach.X`;
- `Y = consumer_reach.module(...)`;
- `runtime/config.py` spelling `access_token` in a dict key, in an attribute read, and in an f-string.

Eight more came from review rounds 2 and 3:
- `import opendox.consumer_reach` then `opendox.consumer_reach.module(...)`;
- `import opendox` then `opendox.consumer_reach.snapshot`;
- an alias of the seam module;
- a subpackage's `from .. import consumer_reach`;
- the seam imported inside a module-level `try`;
- a stand-in bound inside a module-level `if`;
- a wildcard import from the seam;
- a second redaction permit.

Two came from review round 4, and one more runs in the `.[runtime,test]` venv:
- an invented module in a `RUNTIME_EXTRA` row;
- a runtime module importing a package nothing declares, read statically;
- in `.[runtime,test]`, a module tabled under a distribution that does not install it.

Two came from review round 5:
- a third identity holder listed, with `Authorization` in its code;
- the one redaction permit moved to another needle, with `runtime/config.py` spelling that name instead.

Two controls pass, as they must: a new comment and a new docstring in `runtime/config.py` that name `access_token`.

## The falsifier: `python -m pytest -q` over the nine files

```
$ python -m pytest -q tests/test_doxbench_abstract_pane.py tests/test_outline_tab.py tests/test_doxbench_composition.py tests/test_provider_boundary.py tests/test_doxbench_memory_gateway.py tests/test_consumer_reach.py tests/test_boundary.py tests/test_doxbench_mcp.py tests/test_outline_model.py
282 passed in 22.93s
```

It also passes under `--noconftest`, file by file, and in a `.[runtime,test]` venv.

## The repository's own check

`.github/workflows/validate.yml`'s three report-producing steps, run as the file writes them and summed as `Pin the triple` sums them, in the `.[test]` venv above:

```
triple: selected=1160 passed=1157 skipped=3 failures=0 errors=0
pins:   selected>=1114 (margin 46) passed>=1111 (margin 46) skipped==3
```

`main` at `68be484a` gives `1155/1152/3`. The five new cases are `test_consumer_reach.py`'s, which the required job runs by name. `test_provider_boundary.py`'s new cases are not on the job's list. No skip was added.

**The whole suite, with the root conftest.** A test-by-test JUnit diff against `main` in the same venv:

| venv | `main` | this head |
|---|---|---|
| `.[test]` | 19 failed, 1489 passed, 13 skipped, 66 errors | 1 failed, 1570 passed, 13 skipped |
| `.[runtime,test]` (F2.1's install) | 18 failed, 1490 passed, 13 skipped, 66 errors | **1571 passed, 13 skipped** |

- 69 cases go from red to passed, all in the nine files.
- 15 are gone: the 4 moved cases, and 11 of `test_provider_boundary.py`'s old ids. Nine were `PRESERVED_SCANS` rows for files this checkout does not carry, one was the renamed tier-two case, and one was the `snapshot_registry.py` case.
- 12 are new, all passing: 5 in `test_consumer_reach.py` and 7 in `test_provider_boundary.py`.
- No other outcome changed.
- The `.[test]` venv's one failure is T030's `test_every_module_imports_with_no_sibling`, which needs the `runtime` extra there, as #46 recorded. T036 gives the `test` extra those packages.

## Review round 1 (Copilot, at `6898748a`)

Each finding was planted at `6898748a` first, and every plant passed there. Each is fixed in `86b8f522`, where every plant fails, and each thread is answered with its evidence and resolved.

- **The derivation blocked only `openxdox`.** With a `doc_health` on the path, a module gaining `import doc_health` dropped out of the census. The derivation, and the record entry check that reads the same failure, now block all four.
- **The derivation dropped every failure that named no sibling.** They are classified now (above).
- **The `access_token` permit covered the whole of `runtime/config.py`.** It covers the declaration and the prose now (above).
- The review's overview also named annotated assignments in the seam census, with no thread. That is done too (above).

## Review rounds 2 and 3 (Copilot, at `86b8f522` and `9d52122b`), no threads

- **Round 2: one previously missed finding.** `import opendox.consumer_reach` binds `opendox`, so a stand-in bound through `opendox.consumer_reach` went unseen. Three sibling forms were unseen the same way. All four are read since `9d52122`, and each passed as a plant at `86b8f52`.
- **Round 3: a summary line only, "seam-alias and wildcard-import gaps, and the single provider-boundary permit invariant."** Since `9a9b21a`:
  - the census reads a module-level `if` or `try`, where both plants passed at `9d52122`;
  - a wildcard import fails with its own message;
  - the permit table is held at one entry.
- **At `9a9b21ae` Copilot reports "Needs a closer look", with no finding and no thread.**

## Review round 4 (Copilot, at `7867614c`, the first merge of `main`)

- **`RUNTIME_EXTRA`'s import names were checked only through its keys.** Adding `"planted"` to fastapi's row left the whole of `test_consumer_reach.py` green at `7867614`, and a missing `planted` import in `opendox.runtime` would then have been read past as an absent extra. Fixed in `383b3232` by the new case above, which holds the names to the runtime's imports and to the installed metadata. The thread is answered with that evidence and resolved.
- **At `383b3232` Copilot reports "Needs a closer look", with no finding and no thread.**

## Review round 5 (Copilot, at `7e3dc9ff`, the merge of T032)

- **`IDENTITY_MODULES` was its own authority.** `holders_seen == permitted` proves only that each listed module holds a needle. Planted at `7e3dc9ff`, `runtime/db.py` added to the tuple, with an `Authorization` string in its code, passed the whole file (`24 passed`). The thread also names line 318, the permit table's pin, which held `REDACTION_PERMITS` by its size only. Planted there, the permit moved to `refresh_token`, with `runtime/config.py` spelling that name in place of `access_token`, passed too (`23 passed`). Fixed in `bc6b168d`: each table is held to the surface it names (above), and both plants fail. The thread is answered with that evidence and resolved. All five threads on this PR are resolved.

## Landing

- T032 (#49) and T022 (#45) have landed, and `main` `68be484a` is merged in. Everything above was re-run at this head.
- `tests/test_consumer_reach.py` has one writer at a time (T011 → T034), and this is its second.
- P1-G (T035–T037, T031) follows this PR.
- Squash or merge, never rebase. Each commit message carries both trailers, and so does this body.

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>
brettheap added a commit that referenced this pull request Sep 27, 2026
…(plan 034) (#51)

Plan 034, task **T035**, slice P1-G (the whole suite in CI). The plan is `specs/034-opendox-standalone-operation/tasks.md` at opensoft/openxFactory `main` `133e37d9`. This PR realizes boxes **9.1 (part)** and **9.3 (part)** of the ratified `add-neutral-product-standalone-operability`.

- **Ruled:** R1Q2 (a), R1Q6 (d) and R1Q22 (a), openxFactory#656 comments `5817152735` and `5850003126`. All seven modules are carved rows, and none needs a declared-edit act.
- **Claim:** openxFactory#656 comment `5856501803`.
- **After:** T034, which landed as #50 → `71b631bc`. T032 landed as #49 → `68be484a`, and this branch was cut from it. `main` at `71b631bc` is merged in at `81f93777` (no force-push). Three review rounds followed, each in its own section at the end. Every figure below is re-measured at this head, `b173a970`.

## What changes

The root `conftest.py`'s `collect_ignore` is empty. It held seven modules under RULED Q-L3 (b). Requirement 9 (FR-006) asks this leg for no exclusion, so an entry there now would be an undeclared one, and the block's comment says so.

Each of the seven is rewritten in place as a neutral openDox test that imports no sibling. **No module leaves whole.** Fifteen **cases** test another repository's tree, contract or verb. They leave this suite, and the next section lists each one with its destination. One case is added.

| module | before | after | cause | repair |
|---|---|---|---|---|
| `test_subcommand_extension.py` | 3 failed, 13 passed | 16 passed | `CORE_COMMANDS` still listed `gate`, which the host profile contributes since the carve (research R8) | five core verbs |
| `test_model_provider_broker.py` | 4 failed, 68 passed | 72 passed | Two source paths under `scripts/ideation_dashboard/`. `__import__("ideation_dashboard.doxbench_bridge")`, a string the carve's import rewrite could not see. `from test_doxbench_model import FORBIDDEN_PORT_MEMBERS`, a test module that stayed in openxFactory. | `src/opendox/` paths; `opendox.doxbench_bridge`; the 16-name set carried in verbatim, with its provenance |
| `test_doxbench_entrypoint.py` | 4 passed, 4 errors | 8 passed | fixture setup reached `openxdox.corpus_root` (`ConsumerReachUnavailable`) | `cmd_generate_and_open` runs for real, with the six phase-1 reaches stood in (below) |
| `test_hermeticity.py` | 14 failed, 17 passed | 26 passed | Layer 2 of the guard was off (below). The layout pins described openxFactory's tree. Five cases test other trees. | layer 2 on; the pins rewritten for this layout; five cases move |
| `test_doxbench_chat_view.py` | 1 failed, 123 passed | 124 passed | read `contracts/schemas/xfactory-workbench-chat-turn.schema.yaml`, which the carve sent to openDox-spec | that case moves; a browser/server pair pin is added |
| `test_workbench.py` | 2 failed, 26 passed, 3 skipped | 25 passed | openxFactory's validator (the skips) and its doc-health check (the failures) | six cases move |
| `test_session_harness.py` | 1 collection error | 17 passed | loaded openxFactory's `scripts/sync-notebooklm-books.py` at import time | the load and three cases move |
| **total** | **24 failed, 4 errors, 1 collection error, 251 passed, 3 skipped** | **288 passed** | | |

"Before" is `main` `71b631bc`, each file named on the command line, which pytest collects despite `collect_ignore`. "After" is `81f93777`. Since then the review rounds added one case to `test_hermeticity.py` (27 passed at this head) and one assertion to a `test_doxbench_chat_view.py` case. Python 3.12.3, `.[runtime,test]` under `constraints-cpython312-linux.txt`.

### Three findings fixed on the way

1. **Layer 2 of the hermeticity guard was OFF in this suite.** `tests/hermeticity.py`'s `runner_seams()` probed `find_spec("ideation_dashboard.session_pr")`. This leg has no such package, so the probe returned no seams, and `workbench._default_runner` and `session_pr.SubprocessCommandRunner.run` stayed real in every test. Layer 1 (the `PATH` shim) was still on. But a non-zero exit is the very degradation the notebook adapter swallows, so an escape through the default runner would have passed green. The carve manifest's row for the helper records the probe resolving "to nothing at a destination that lacks them". The seams now name `opendox.workbench` and `opendox.session_pr`, with no probe. With the layer on, the whole `tests/` directory stays green, so no test was escaping.
2. **The `BaseException` handler scan read nothing.** It walked `scripts/ideation_dashboard/`, which does not exist here, and passed on zero files. It now reads `src/opendox/` (58 modules, 9 `BaseException` handlers, all re-raising), and it fails if it reads no module.
3. **The rootdir-anchor case matched a substring.** `rootdir: <repo>` also matches `rootdir: <repo>/tests`. Planted: a `tests/pyproject.toml` with a pytest table makes `tests/` the rootdir, which cuts the root conftest out, and it still prints `configfile: pyproject.toml`. Both of the old checks pass on that. The case now matches the whole value.

**And the P1-E hand-off.** The open-session-notebook case registers a home corpus first. Without one, the worktree listing refuses `ADAPTER_NOT_REGISTERED` before the runner is reached. Whether a registration was present depended on test order, because `cli.build_parser()` registers openDox's default process-wide. The case now registers that default itself, over a one-document scratch worktree instead of this checkout, and `monkeypatch` restores the previous registration.

### The entrypoint's stand-ins

`test_doxbench_entrypoint.py` tests what the entrypoint DECLARES: the model port (`doxbench_install.declared_model_port_factory`), its one process-lifetime adapter, and the session root. It never reads the snapshot. Plan 034's phase-1 limit (plan.md; research R7) is that `generate-and-open` still reaches openXdox for the snapshot and its generator, so exactly these are stood in:
- **`cli`:** `corpus_root_refusal`, `generate_snapshot` and `snapshot_mod.write_snapshot`. `SCANNED_ROOTS` is read only for a snapshot with no document, and the stand-in snapshot has one.
- **`serve`:** T011's three (`tests/test_route_handler_contribution.py`, section 6).
  - The snapshot source goes in through `build_server`'s own `snapshot_source=` seam. The fixture asserts that the entrypoint passes none, so when phase 2 gives it one the fixture fails instead of standing in over it.
  - `_checkout_real` answers **true**, where T011's answers false. The model port is gated on the `session` verdict (loopback, a real checkout, a resolved actor), and the carve's `base-repo` fixture these cases served was a real checkout.

## For T007's batch E, T041 and T047: the fifteen cases this PR moves

Each destination task lands exactly its part of this list, and T049 checks that every case arrived. The links are line ranges at `main` `68be484a`, so the cases' own text needs no archaeology.

**Thirteen become NAMED openxFactory composition tests (T047; R1Q2 (a)).** T007's batch E adds each destination path to F11.1's named set before T047 lands. **The paths are proposals.** If T047's writer chooses others, batch E records what T047 lands. openxFactory's `tests/ideation-dashboard/conftest.py` already reaches each moved file at the pin, through `carved_reach`.

| moved case (`68be484a`) | proposed openxFactory destination | what it needs there |
|---|---|---|
| [`test_saved_manifest_validates_clean_against_the_pinned_validator`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_workbench.py#L119-L126) | `tests/ideation-dashboard/test_workbench_manifest_validation.py` | The validator. The script lives in openXdox-code now, and openxFactory's conftest composes it (`find_openxfactory_validator` → `doxbench_contracts._composed_validator`), so there these cases run instead of skipping. |
| [`test_recipe_seeded_manifest_carries_the_recipe_block_and_validates`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_workbench.py#L129-L140) | same | same |
| [`test_committed_manifest_is_rejected_by_the_pinned_validator`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_workbench.py#L212-L224) | same | same, in `--repo` mode |
| [`test_scoped_doc_health_runs_real_machinery_over_the_fixture`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_workbench.py#L456-L466) | `tests/ideation-dashboard/test_workbench_scoped_doc_health.py` | openxFactory's `doc_health` check registered with T026's seam (T046, in T047's PR), and its `base-repo` fixture |
| [`test_scoped_doc_health_finds_a_real_missing_status`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_workbench.py#L469-L475) | same | same |
| [`test_scoped_doc_health_ignores_out_of_scope_docs`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_workbench.py#L478-L486) | same | same. Here it passed only because an empty findings list satisfies its `all(...)`. |
| [`test_worktree_container_is_gitignored_in_the_aggregation_repo`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_session_harness.py#L248-L260), with [`find_aggregation_root`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_session_harness.py#L229-L238) | `tests/ideation-dashboard/test_session_worktree_book_scan.py` | the aggregation checkout's ignore file, found by the parent walk (it skips where there is none) |
| [`test_session_worktrees_never_reach_a_lifecycle_book`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_session_harness.py#L279-L329) | same | `scripts/sync-notebooklm-books.py`, loaded by spec as the module did ([lines 37–45](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_session_harness.py#L37-L45)) |
| [`test_pinned_factory_paths_never_admits_a_worktree_container`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_session_harness.py#L332-L347) | same | same |
| [`test_the_browser_ceiling_is_pinned_to_the_RELEASED_maxLength`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_doxbench_chat_view.py#L4148-L4166) | `tests/ideation-dashboard/test_doxbench_chat_ceiling.py` | The released `xfactory-workbench-chat-turn.schema.yaml`, which the carve sent to **openDox-spec** (`moved_verbatim` → `opendox_spec`), and `doxbench-chat-model.js`, both through `carved_source(...)` at the pin |
| [`test_a_pytest_run_started_inside_a_conftestless_directory_is_guarded`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_hermeticity.py#L604-L621), with [`_probe_run`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_hermeticity.py#L595-L601) | `tests/ideation-dashboard/test_hermeticity_probe_routes.py` | openxFactory's `tests/notebooklm/test_hermeticity_guard.py` and `pytest.ini`, both `not_moved` and both present at `133e37d9` |
| [`test_the_unittest_fallback_route_installs_the_same_guard`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_hermeticity.py#L640-L660) | same | `tests/hermetic_unittest.py` (`not_moved`, present) |
| [`test_the_bare_unittest_route_is_detected_as_unguarded`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_hermeticity.py#L663-L674) | same | the same probe |

**Two join openXdox-code's declared `doc_health` exclusion (T041; R1Q6 (d)).**

| moved case (`68be484a`) | proposed openXdox-code destination | why the exclusion, not `tests/integration/` |
|---|---|---|
| [`test_an_unguarded_cli_scoped_create_is_refused`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_hermeticity.py#L226-L240) | `tests/test_hermeticity_gate_verbs.py`, listed in T041's exclusion | Both drive `gate create-document`. `gate` is the host profile's verb (openXdox's `cli_gate.GateSubcommands`), so this suite's empty profile has none to parse. `cli_gate` imports `gate_console`, which does `from doc_health import corpus` at module level (`:63`), so F9.2 could not run them in `tests/integration/`. |
| [`test_the_cli_seam_with_a_fake_port_reaches_no_binary`](https://github.com/opensoft/openDox-code/blob/68be484ad8a3cb218b6cd217292c11736aa1c9b4/tests/test_hermeticity.py#L262-L275) | same | same |

The guard itself is still proved here, through the default adapter and through `open_session_notebook`.

### Notes for the destinations (none blocks this PR)

- **The three hermeticity route cases are not compositions.** They test openxFactory's own tree and touch no openDox file. Batch E's admission should say whether they join F11.1's named set or land as plain openxFactory tests.
- **openxFactory's own `tests/hermeticity.py` has the same `find_spec` probe.** When `scripts/ideation_dashboard/` leaves openxFactory, its layer 2 goes off just as silently as it was off here.
- **The serve-side twin of the chat ceiling is broken at its destination too.** openXdox-code's `tests/test_doxbench_knowledge_service.py::test_the_serve_side_ceiling_is_pinned_to_the_RELEASED_maxLength` reads `REPO_ROOT/contracts/schemas/xfactory-workbench-chat-turn.schema.yaml`, which openXdox-code does not carry. It is hidden today because that file is in T041's `doc_health` exclusion. The pair pin added here, `test_the_browser_ceiling_equals_the_servers_ceiling`, holds one side of the triangle whatever happens to that one.
- **Until T047 and T041 land, these fifteen cases run nowhere.** At `133e37d9`, openxFactory's `tests/ideation-dashboard/` has none of the four source files (`test_workbench.py`, `test_session_harness.py`, `test_hermeticity.py`, `test_doxbench_chat_view.py`); they moved at the carve.

## The falsifier: `python -m pytest -q tests/`, with the root conftest in play and `collect_ignore` empty

At this head, `b173a970`, `.[runtime,test]`:

```
$ python -m pytest -q tests/
1860 passed, 13 skipped in 134.84s (0:02:14)
```

`main` `71b631bc` gives `1571 passed, 13 skipped`. A test-by-test JUnit diff at `81f93777` (`1859 passed`): 288 cases go from not collected to passed, all in the seven modules, and no other outcome changes. This head adds the 289th. The 13 skips are `main`'s:
- 2 in `test_binding_stylesheets.py` (T037's pair);
- 8 in `test_doxbench_bridge_live.py` (no `omp`);
- 3 in `test_openprofiler_broker_e2e.py` (no broker).

In a `.[test]`-only venv the same run gives `1 failed, 1859 passed, 13 skipped`. The one failure is `test_imports_standalone.py::test_every_module_imports_with_no_sibling`, T030's. It needs the `runtime` extra and fails in that venv on `main` too (#46 recorded it). T036 cures it by giving the `test` extra those packages. (At `81f93777` there were two failures in that venv. The second was the two-directory case, and Copilot's third round below took it out.)

## Fourteen planted mutations, each caught

Each plant is one change to a scratch copy of this head, and each fails the cases it targets. A control run of all 17 targets passes first.
1. `runner_seams()` returns no seams again: the four layer-2 cases fail.
2. The open-session case loses its home-corpus registration: it fails, because the refusal becomes a notice.
3. The handler scan points back at `scripts/ideation_dashboard/`: it fails, having read no module.
4. A production `except BaseException: pass`: the scan names it.
5. The root conftest claims the slot: `tests/test_hermeticity.py` stops collecting, with `cannot import name 'REPO_ROOT' from 'conftest'` naming the root conftest.
6. `tests/conftest.py` stops claiming: the two-directory case fails, and so does the source pin. `pytest --co tests tests_runtime` gives 34 collection errors, each `cannot import name 'REPO_ROOT' from 'conftest' (tests_runtime/conftest.py)`.
7. `pyproject.toml` loses its pytest table: the anchor case fails.
8. A `tests/pyproject.toml` with a pytest table: the anchor case fails, on the whole-value match alone.
9. The entrypoint declares no model port: the four fixture cases fail.
10. The browser ceiling becomes 501: the new pair pin fails.
11. The brokered port grows `generate`: the forbidden-member case fails.
12. `doxbench_binding.py` imports `yaml` at module scope: the lazy-import case fails.
13. The provider client spells `shell=True`: the shell case fails.
14. `cli` gains a sixth core verb: the core-command case fails.

**One correction the plants forced.** pytest 8.4.2 still falls back to a `pyproject.toml` with no pytest table, when it finds no other config file above it (`_pytest/config/findpaths.locate_config`). The helper's comment and the anchor case's docstring say so, and say why the table is still checked: without it, a `pytest.ini` in any enclosing directory would take the rootdir.

## Copilot's review at `81f93777`: two cases added

The review found nothing and asked for two cases ("Add an independent released-contract assertion and a nested-rootdir regression case"), with no thread. Both are in `4e5c89a9`, and each was planted against first:
- **The released ceiling.** The pair pin holds the browser's constant to the server's, and it cannot see both move together. The case now also holds the server's constant to the released `maxLength`, 500, carried with its source (`xfactory-workbench-chat-turn.schema.yaml` in openDox-spec, read at openDox-spec `main` `8fe8c4c7`). Planted: both constants at 600. The pair still passes, and this line fails.
- **A nested rootdir.** `test_a_nested_rootdir_is_refused_by_the_whole_value_match` is the negative control for the anchor case's match, on a scratch tree. A nested `tests/pyproject.toml` with a pytest table makes `tests/` the rootdir, and the header still prints `configfile: pyproject.toml`. The substring match and the configfile check both accept that header, and the whole-value match refuses it. With the nested file gone, the whole-value match accepts the tree's own root. Planted: the substring match put back, and the control fails.

## Copilot's review at `4e5c89a9`: no leak, measured

The review said the open-session case "leaks the registered home factory because the monkeypatch does not restore the original state". It does not. `monkeypatch.setattr(ca, "_home_factory", ca._home_factory)` records the current value for teardown, and teardown restores it after `register_home` replaces it. Measured with a probe that reads `corpus_adapter._home_factory` before setup and after teardown of that one case:
- It is the same object afterwards, both from nothing registered and from a different registration.
- With that line deleted, it is not, in either state.

The answer is on this PR as a comment. `4100cee8` puts a comment on the line and changes nothing else.

## Copilot's review at `4100cee8`: one finding, fixed

"The cross-suite hermeticity check fails in the declared test-only environment." That is true of a `.[test]`-only venv, where `tests_runtime/test_oidc_verifier.py` cannot import `httpx` until T036. The required workflow at this head does not run the case, so CI was green, but the case did turn a missing package into a slot failure. Since `b173a970` it compares the whole collection outcome of the two orders: the count, and the files that failed to collect.
- A missing package fails the same way in both orders, so the case passes in both venvs.
- With `tests/conftest.py`'s claim removed, it fails in both venvs.
- Any collection error is still refused by the suite itself, and after T036 by the pinned triple.

The thread is answered with this evidence and resolved.

## The repository's own check

`validate.yml` is unchanged. Its steps name none of the seven modules, and they run with `--noconftest`, so the root conftest's list never reached them. The triple is `main`'s. T036 re-pins it for the whole suite.

## Landing

- T034 has landed, and everything above is re-run at the merged head.
- T036 (with T031) follows this PR, then T037.
- Squash or merge, never rebase. The commit carries both trailers, and so does this body.

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>
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