Skip to content

Register openDox's default at the entry points; a host replaces it only before a build (T016) - #42

Merged
brettheap merged 11 commits into
mainfrom
build/034-t016-registration-semantics
Sep 27, 2026
Merged

brettheap merged 11 commits into
mainfrom
build/034-t016-registration-semantics

Conversation

@brettheap

@brettheap brettheap commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

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

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:

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 69fecb9d, 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

Summary by Sourcery

Register openDox’s default profile at entry points while preserving explicit registration failures and allowing host profiles to replace it only before composition begins.

New Features:

  • Register openDox’s default profile at CLI and server entry points when no host profile is registered.
  • Allow a host profile to replace the entry-point default before the first composition build, while rejecting replacements afterward.

Bug Fixes:

  • Preserve the existing refusal when a process reads the profile without any registration, rather than silently falling back to an empty profile.
  • Ensure re-registering the same profile preserves registration type and build state.

Enhancements:

  • Track builds only when composition points read the facets they compose from, leaving diagnostic and non-composing reads replaceable.
  • Clarify the profile registration contract and default-profile behavior in the runbook and README.

Documentation:

  • Document the default profile, registration timing, build boundary, replacement rules, and refusal behavior.

Tests:

  • Expand profile registration coverage for entry-point defaults, pre- and post-build host registration, build tracking, unregister behavior, and non-building reads.

brettheap and others added 4 commits September 26, 2026 22:01
…time verbs (T015)

Plan 034's T015 (openxFactory specs/034-opendox-standalone-operation), which
realizes box 3.1 of the ratified add-neutral-product-standalone-operability.

src/opendox/default_profile.py is openDox's default profile for its own
domain. It declares the two facets openDox reads strictly:

- SUBCOMMAND_EXTENSIONS carries RuntimeSubcommand from this first landing
  (R1Q4 (a), R1Q5 (a), openxFactory#656 comment 5817152735), so no build
  meets an empty default.
- ROUTE_EXTENSIONS is empty, because openDox's own routes are the core
  server's fixed dispatch.

It declares no DISPLAY facet, so the display it yields is NEUTRAL_DISPLAY
unchanged, through display_profile's named absence. Declaring the table
itself would claim its four design tokens as the host's, and the shell would
then pin the light palette over the dark theme. Importing the module
registers nothing; T016 wires the entry-point registration.

tests/test_default_profile.py holds it to requirement 3:

- the RuntimeSubcommand test;
- the vocabulary test, over every name, help string and rendered word the
  default declares, with a stand-in that shows the sweep can fail;
- the display, which is NEUTRAL_DISPLAY with no token claimed;
- a subprocess import with the four siblings blocked, which registers
  nothing and loads nothing outside the standard library.

Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ly before a build (T016)

Plan 034's T016 (openxFactory specs/034-opendox-standalone-operation), which
realizes box 3.2 of the ratified add-neutral-product-standalone-operability.
It carries out R1Q3 (a), with (i) and (ii) (openxFactory#656 comment
5817152735), and RN-1 (a) (comment 5850003126).

- cli.build_parser(), serve.build_server(), cli.main() and serve.main() call
  domain_profile.register_default(default_profile) first. It registers
  openDox's own default only where nothing is registered, so is_registered()
  then answers True. The default is an entry-point registration and never a
  fallback inside current().
- A process that builds nothing still meets ProfileNotRegistered, and
  profile_proxy keeps its nothing-registered refusal (R1Q3 (i)).
- A host registration made before anything is built from the default
  replaces it. After a parser or a server was built from it, register() is
  refused as AlreadyRegistered, naming the default and the build (R1Q3 (ii),
  RN-1 (a)). The proxy resolves through current_for_build(), which records
  the build; current() and is_registered() record nothing.
- The refusal text, the default profile's docstring and the proxy's
  docstrings now say so. The runbook is a record, so it gains a section at
  its end rather than a rewrite, and README's index row for it follows.

tests/test_profile_registration.py asserts all three cases: the
bare-process refusal; the replacement before a build, both with the host
registered first and over a default nothing was built from; and the refusal
after a build. It runs build_parser() and main() for real, and build_server()
and serve.main() from their own lines, since a server cannot be built in a
lone checkout until phase 2.

Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…rb use (T015)

Copilot's review of cd70eb3: the vocabulary sweep could miss the OpenSpec
nouns change and changes in contributed help text. The sweep had left both
words out of help text entirely, because the runtime's own help uses one as
an English verb.

Both words are swept in help text now. The one measured verb use,
`runtime migrate --plan`'s "report what would be applied and change nothing",
is exempt by its exact string and for that word alone. Any other use fails the
sweep until someone reads it and enters it in _OTHER_SENSES, and a new test
removes an entry once the text it names is gone. The stand-in profile shows
the noun is caught.

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

sourcery-ai Bot commented Sep 26, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR introduces openDox's standalone default profile and wires it into CLI and server entry points as an explicit registration, while preserving refusal for unregistered library reads and enforcing a build-aware window in which hosts may replace the default. It adds registry/proxy state tracking, comprehensive default-profile and registration tests, and updates the operational documentation.

Sequence diagram for entry-point default registration and build

sequenceDiagram
    participant Caller
    participant EntryPoint
    participant Registry as domain_profile
    participant Proxy as profile_proxy
    participant Default as default_profile

    Caller->>EntryPoint: build_parser()
    EntryPoint->>Registry: register_default(default_profile)
    Registry->>Default: register when nothing is registered
    EntryPoint->>Proxy: read SUBCOMMAND_EXTENSIONS
    Proxy->>Registry: current_for_build()
    Registry-->>Proxy: default_profile and record build
    Proxy-->>EntryPoint: RuntimeSubcommand
    EntryPoint-->>Caller: built parser
Loading

State diagram for host replacement of the default profile

stateDiagram-v2
    [*] --> Unregistered
    Unregistered --> DefaultRegistered: register_default(default_profile)
    Unregistered --> HostRegistered: register(host_profile)
    DefaultRegistered --> HostRegistered: register(host_profile) before build
    DefaultRegistered --> DefaultBuilt: current_for_build()
    DefaultBuilt --> DefaultBuilt: register(host_profile) / AlreadyRegistered
    HostRegistered --> HostRegistered: register(other_profile) / AlreadyRegistered
    DefaultBuilt --> Unregistered: unregister()
    HostRegistered --> Unregistered: unregister()
    DefaultRegistered --> Unregistered: unregister()
Loading

Flow diagram for unregistered reads versus entry-point builds

flowchart TD
    A[Profile access] --> B{Entry point building?}
    B -->|No| C["current()"]
    C --> D{Profile registered?}
    D -->|No| E[ProfileNotRegistered]
    D -->|Yes| F[Return registered profile]
    B -->|Yes| G["register_default(default_profile)"]
    G --> H["profile_proxy.resolve()"]
    H --> I["current_for_build()"]
    I --> J[Record build when using default]
    J --> K[Build parser or server]
Loading

File-Level Changes

Change Details Files
Add an import-safe default profile for standalone openDox operation.
  • Define runtime subcommand and empty route facets for the openDox-owned default.
  • Keep display and view facets absent so neutral vocabulary and theme behavior remain unchanged.
  • Verify runtime composition, vocabulary isolation, display behavior, and sibling-independent imports.
src/opendox/default_profile.py
tests/test_default_profile.py
Implement entry-point registration and build-aware profile replacement semantics.
  • Add default registration, build tracking, and reset behavior to the single-profile registry.
  • Allow a host to replace an entry-point default before the first build, but reject replacement afterward with diagnostic guidance.
  • Keep unregistered reads refusing instead of falling back to an empty or implicit default.
  • Route proxy facet resolution through the build-recording accessor.
src/opendox/domain_profile.py
src/opendox/profile_proxy.py
Register the default before profile reads at all CLI and server entry points.
  • Register the default in parser and server builders before facet access.
  • Register the default in both process-level main functions while preserving the pre-build host replacement window.
  • Update composition comments and entry-point behavior documentation.
src/opendox/cli.py
src/opendox/serve.py
Document and test the revised profile-registration contract.
  • Extend the runbook and README index with default registration, refusal, replacement, and build-boundary rules.
  • Add tests for bare-process refusal, entry-point registration, host replacement timing, post-build refusal, and non-build reads.
  • Update test isolation to preserve the registry's expanded internal state and retain AST-based server coverage.
docs/profile-registration-runbook.md
README.md
tests/test_profile_registration.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

Default-registration bookkeeping and related public contract documentation remain unresolved.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Registers openDox’s standalone default profile at CLI/server entry points while preserving explicit refusal and safe host-profile replacement timing.

Changes:

  • Adds default registration and build-state tracking.
  • Updates proxy resolution and entry-point behavior.
  • Adds registration tests and documentation.
File Summary
tests/​test_profile_registration.py Tests registration timing and refusal cases.
tests/​test_default_profile.py Validates default profile contents.
src/​opendox/​serve.py Registers the default before server composition.
src/​opendox/​profile_proxy.py Records default-backed builds.
src/​opendox/​domain_profile.py Implements default registration and build-state semantics.
src/​opendox/​default_profile.py Defines the standalone profile.
src/​opendox/​cli.py Registers the default before parser construction.
README.md Updates the runbook index description.
docs/​profile-registration-runbook.md Documents the updated registration contract.

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

Comment thread src/opendox/domain_profile.py Resolved
brettheap and others added 2 commits September 27, 2026 00:17
Copilot's review of openDox-code#42 at c755147: register() fell through to
its bookkeeping when handed the object already registered. So
register(opendox.default_profile) over an entry point's default cleared
_is_default and _built_from_default. A host's profile could then no longer
replace a default nothing was built from, and a refusal after a build lost
the message that names the default.

register() now returns at once for the same object, before any bookkeeping
is touched. Three cases hold it. Re-registering the default before a build
leaves it replaceable. After a build it neither raises nor forgets the build.
A host that registers the default itself, before any entry point has, holds
a host's registration. The first two fail on c755147's register(). The
docstring and the runbook say so, and the runbook now counts forty-eight
cases.

Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…check seams

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

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

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

Profile inspection can incorrectly mark a build complete, and the runbook contains contradictory and inaccurate documentation.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread src/opendox/profile_proxy.py Resolved
Copilot's review of openDox-code#42 at 46519d6: every read through the
proxy went through current_for_build(), so a read that only asks was taken
for a build. view_extension.host_profile_name() resolves the proxy for a
diagnostic. canvas_drafts._facet() reads the DISPLAY facet whenever a draft
names a stage. After register_default(default_profile), either one made a
later host register() raise AlreadyRegistered with no parser or server
built. The runbook said otherwise.

The proxy now records a build only at the reads its READERS table names.
Those are SUBCOMMAND_EXTENSIONS as cli.build_parser() reads it and
ROUTE_EXTENSIONS as serve.build_server() reads it. Every other read goes
through current(): resolve(), the DISPLAY and VIEW_EXTENSIONS facets, and
the profile's name. test_a_read_that_only_asks_is_not_a_build fails on
46519d6's proxy. The read-is-a-build test now runs once per READERS facet,
and all six after-build cases fail if no read records anything. The
docstrings and the runbook say which read is a build. The runbook also says
which rows of its first refusal table the plan-034 table replaces. It now
counts fifty cases.

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 00:30

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

Two moderate findings remain regarding build tracking and refusal diagnostics.

Review effort: Lite
Findings: None

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

In code that hasn't changed since last review

Medium severity Avoid misleading build-history claim after unregister

src/​opendox/​domain_profile.py:370

After a default-backed parser/server has been built, unregister() deliberately clears _registered and _built_from_default, so a later current() can enter this branch even though the process did build through an entry point. The message's unconditional “this process has built nothing through one” is then false and makes the refusal diagnostic misleading; describe the current absence of a registration instead of asserting that history.

Copilot's review of openDox-code#42 at aee57d5, under "previously missed":
current()'s refusal said "this process has built nothing through one" of
the entry points unconditionally. After a build from the default,
unregister() leaves nothing registered in a process that did build, and
the refusal then made a false claim about that process.

The refusal now says that nothing is registered now. It names both ways to
get there: nothing was built through an entry point, or unregister() has
dropped the registration since. The new
test_the_refusal_after_unregister_claims_nothing_about_what_was_built
builds from the default, unregisters and reads the refusal. It fails on
aee57d5's text. ProfileNotRegistered's and current()'s docstrings, the
proxy's refusal bullet and the runbook's refusal row say the same. The
runbook now counts fifty-one cases.

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 00:36

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 changes require final human review because they are too complex or risky for automated approval.

Review effort: Lite
Findings: None

brettheap added a commit that referenced this pull request Sep 27, 2026
…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 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 and others added 2 commits September 27, 2026 02:52
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>
T010 (#40) added a fifth facet, HANDLER_CONTRIBUTIONS, and build_server()
reads it by presence. The default does not declare it: it contributes no
route, so it has no method to supply, and
route_extension.declared_handler_contributions() answers () for it.
default_profile.py's docstring now counts five facets, and
test_default_profile.py asserts the absence through that same reader.
Declaring HANDLER_CONTRIBUTIONS = () fails the facets test.

The proxy's docstring and the runbook's "What counts as a build" say where
that read stands. It is optional and not in READERS, so the server's build
is recorded at its ROUTE_EXTENSIONS read. The docstring also cites the
holder's recorded readings on U4 and DISPLAY (openxFactory#656 comment
5851560764).

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 03:04
main is 9d13bd1, which adds P1-D's T021 (#44) to what the last merge took.
It touches no file of T016'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>
@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 registration lifecycle and build-boundary changes require final human review.

Review effort: Lite
Findings: None

@brettheap
brettheap marked this pull request as ready for review September 27, 2026 03:14

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

@brettheap

Copy link
Copy Markdown
Contributor Author

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

@brettheap
brettheap merged commit 19370ad into main Sep 27, 2026
4 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

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

LANDED — lane openxfactory-4, 2026-09-27T03:20:53Z, PR #42 → 19370ad (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
T016 (#42 -> 19370ad) landed: cli.build_parser()/cli.main()/
serve.build_server()/serve.main() each now open with
domain_profile.register_default(default_profile). This branch's own
corpus_adapter.register_default_home(_default_home_factory) call sat at
the same 'first statement' position in the same four functions, so this
merge resolves that positional conflict by keeping T016's already-landed
call first (it has an immediate downstream read in the same function
body -- the SUBCOMMAND_EXTENSIONS/ROUTE_EXTENSIONS reads a few lines
below) and this task's own call second, immediately after. R1Q3 (a)
(openxFactory#656 comment 5817152735) names both as independent
entry-point registrations with no specified order between them.

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

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

# Conflicts:
#	src/opendox/cli.py
#	src/opendox/serve.py
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
…48)

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

## What this is

Plan 034's task **T038**, slice **P1-H, the console script**
(`specs/034-opendox-standalone-operation/tasks.md` § "Phase 1 writer
slices", read at openxFactory `main` `bca4a2600299535271761ac24d8adf492a8875fe`;
unchanged since #1167's head `42f34ab7`, which landed as `a65230f6`, and
re-checked against #1176's round-2 re-plan diff, which touches no T038 line).
This PR realizes box **10.1** of the ratified `add-neutral-product-standalone-operability`.

- **Ruled:** R1Q4 (a), R1Q5 (a), R1Q22 (a) — openxFactory#656 comment
  `5817152735`.
- **Claim:** openxFactory#656 comment `5852235792`.
- **After:** T016 (#42), T022 (#45) — `cli.py`'s single-writer order. Opened
  as a DRAFT on Brett's "draft ahead of dependencies," while both were still
  open. **T016 has since landed** (`19370ad`); `main` merged in at `41dfb75`
  and the falsifier re-verified for real (below). **T022 (#45) is still
  OPEN**, so this PR stays draft until it lands too.

## What changes

- **`pyproject.toml`**: adds `opendox = "opendox.cli:main"` under
  `[project.scripts]`, alongside the existing `opendox-runtime =
  "opendox.runtime.cli:main"`. This is the one documented entry point
  requirement 10 asks for: `opendox.cli:main` already builds and dispatches
  the whole command tree (`generate`, `generate-and-open` — which serves the
  browser surface — `create`, `edit`, `model-binding`, plus whatever a host
  or the default profile contributes), where `opendox-runtime` only ever
  started the lifecycle subsystem.
- **`src/opendox/runtime/cli.py`**: corrects two stale comments (R1Q22 (a);
  plan 034 T011), each to the past tense:
  - the "two measured reasons" bullet, which said a line added to
    `src/opendox/cli.py` needed a declared-edit act at openxFactory first
    (retired by R1Q22 (a)) and that `opendox.cli` could not be imported at
    all (fixed by T011, which removed the `ideation_dashboard` reach);
  - the "AND THAT IS THE RULED SHAPE" paragraph, which described Q-R4's
    answer in the future tense and named a mechanism ("wired into
    `opendox.cli` in the BUILD-arc act that repairs `opendox.serve`") that
    is not quite how it turned out. It now names where the verbs actually
    reach `opendox`: through the default profile (T015/T016), not by
    editing `cli.py`.
- **`src/opendox/cli.py`** (added at the holder's word, see below): corrects
  its own matching stale comment and the `build_parser()` docstring
  (R1Q22 (a)), comment-only.

**`src/opendox/cli.py`: two comments, added after a holder ruling.** The
first authoring pass made no edit here — I'd read PR #42 (T016) and #45
(T022)'s diffs against `cli.py` beforehand, and neither touches the stale
composition-point comment at `cli.py`:92-111 or the `build_parser()`
docstring, and `src/opendox/default_profile.py`'s own header (T015, already
on `main`) states this task's job as the console-script addition alone. I
flagged the ambiguity in this PR rather than guess. The holder ruled: fold
it in, comment-only, since R1Q22 (a) covers `cli.py` the same way it covers
`runtime/cli.py`, and T038 is phase 1's last task in `cli.py`'s
single-writer order (`After: T016, T022`; nothing later in phase 1 touches
this file). `f9dfc2a` does that:
- the note above the `profile_openxfactory` import said the `build_parser()`
  docstring "is NOT corrected here … until an act that declares them lands"
  (RULED OQ-1); it now says R1Q22 (a) retired that gate and names T038 as
  the act that makes the correction;
- `build_parser()`'s own docstring said the composition point is "the one
  line the § 3 carve deletes rather than moves: afterwards the core names
  no profile and openXdox declares its own" — superseded by ratified
  requirement 3, which has the core carry its OWN default profile
  permanently (T015/T016), not become profile-less. It now says whichever
  profile is current gets composed (a host's, or openDox's own default),
  and names the default's `RuntimeSubcommand` as how `opendox` reaches the
  runtime verbs with no separate wiring in this file.

No behavior change: `build_parser()` already read
`profile_openxfactory.SUBCOMMAND_EXTENSIONS` unconditionally before this
commit, and still does. Re-verified after `f9dfc2a` in a fresh venv:
`opendox --help`, `opendox runtime --help` and `opendox-runtime --help` all
exit 0; `tests/test_consumer_reach.py`, `test_route_handler_contribution.py`
and `test_profile_registration.py` (173 tests) unaffected.

## The falsifier (F10.1's first assertion, and `opendox runtime --help`)

Run in a fresh venv, `pip install .` (no extra, matching F10.1's method):

```
$ opendox-runtime --help
usage: opendox-runtime [-h] {runtime,project} ...
exit=0
```

`opendox --help` and `opendox runtime --help` do **not** exit 0 yet, and
this is expected, not a defect in this PR: `build_parser()` reads
`profile_openxfactory.SUBCOMMAND_EXTENSIONS` unconditionally, and until
P1-B's T016 lands, nothing registers a default profile, so the lazy proxy
raises:

```
opendox.domain_profile.ProfileNotRegistered: no host profile is registered,
so openDox has no contributed subcommands and no contributed routes to
compose from. ...
```

identically for both invocations (both go through `opendox.cli.main` →
`build_parser()`). `opendox-runtime --help` above is unaffected: it never
reaches `opendox.cli`.

`pyproject.toml` parses (`tomllib.load`); `src/opendox/runtime/cli.py`
compiles and `tests_runtime/test_runtime_cli.py` (83 passed, 1 skipped, no
change from the pre-existing skip) is unaffected by the docstring-only edit.

## Landing

- **READY at `ceab6489`.** Both #42 (T016) and #45 (T022) have landed;
  `main` merged in twice (once per dependency), auto-merging cleanly both
  times. Re-ran `opendox --help`, `opendox runtime --help` and
  `opendox-runtime --help` for real in a fresh venv (editable install,
  matching CI's `pip install -e ".[test]"`): all three exit 0.
  Copilot's review at the merge head (`2c75ce0`) found three findings (two
  medium, one low); two are fixed (an entry-point metadata test, and the
  one remaining internally-contradictory paragraph in `runtime/cli.py`) and
  the third (the standalone `--help`'s hard-coded `prog="ideation-dashboard"`)
  is answered with evidence rather than fixed, since `prog` is unconditional
  and changing it would also change the HOSTED case's byte-identical
  `--help` text that `build_parser()`'s own docstring says a golden
  snapshot asserts — raised as a follow-up, not silently dropped. Copilot's
  next review, at this exact head, reports 0 new findings and all three
  resolved. All three checks (`validate`, `runtime`, `SonarCloud Code
  Analysis`) SUCCESS.
- `cli.py` has one writer at a time; this PR is last in that chain for
  phase 1 (`After: T016, T022`).
- 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.

Arc: neutral-product-standalone-operability

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


Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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