Skip to content

T025: the session notebook lists the registered home corpus, under the registered scope (workbench.py:746) - #43

Merged
brettheap merged 3 commits into
mainfrom
build/034-p1e-session-documents-seam
Sep 27, 2026
Merged

brettheap merged 3 commits into
mainfrom
build/034-p1e-session-documents-seam

Conversation

@brettheap

@brettheap brettheap commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

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

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

What it does

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

  • Membership comes from the registered home corpus. The function calls the factory that corpus_adapter.home() hands back (T020) on the worktree. Its adapter lists that corpus under the scope a host registered, or under all, openDox's default, where none is registered.

    • A host registers the scope with opendox.workbench.register_session_notebook_scope(scope), in the same one-registration idiom as T026. The same name again (compared by value) does nothing, a different name is refused, unregister_session_notebook_scope() resets it, and session_notebook_scope() reads it.
    • openDox's core names no host scope.
    • openxFactory registers its adapter's documents scope (T046). At openxFactory c415c3d1 that scope lists exactly the notebook's 398 documents, where all lists 794 (T006).
  • Refusals. With no home corpus registered, the function refuses as 4.2 does: CorpusRefused of kind ADAPTER_NOT_REGISTERED, naming the seam and register_home. A scope the resolved corpus does not declare refuses SCOPE_UNKNOWN before anything is listed, and is never widened to all. branch_session.open_session_notebook turns either refusal into the FR-042 notice, so a notebook never blocks a session.

  • The bytes are the corpus's. Each listed document is read through the same adapter (adapter.read), never by opening <worktree>/<key>, because a DocumentId.key is opaque. corpus_adapter.DocumentId says a consumer "may compare it, sort it and hand it back, and may not parse it". So the function takes no snapshot of its own, and the notebook carries what the corpus serves at the worktree.

    • Hosted, openxFactory's adapter reads the checkout it is pointed at, file by file, so uncommitted edits and untracked drafts reach the notebook as they did before.
    • LocalGitCorpus serves the worktree's HEAD instead (see T022 below).

    Copilot's review raised this, and the thread is answered with evidence.

  • The text is unchanged. Each document is decoded as the reader this replaced read it: Path.read_text(encoding="utf-8", errors="replace"), which means UTF-8 with replacement characters and universal newlines. The size bound is measured the same way. So no source's text, and no content hash its re-sync is diffed by, moves.

  • repository is still accepted for the two callers that pass it: branch_session._session_notebook_documents, and openxFactory's sync-notebooklm-books.py. The registered factory names its own corpus, so the argument no longer selects anything.

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

Falsifier 1: F4.1's scan

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

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

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

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

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

Falsifier 2: the session-notebook membership test

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

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

Two more cases pin whose bytes the notebook carries:

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

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

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

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

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

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

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

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

The repository's own checks

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

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

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

The whole suite, with the Group 2 shim:

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

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

For the tasks downstream

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

    from corpus_adapter_openxfactory import home_corpus
    from corpus_adapter_openxfactory.home import DOCUMENTS   # "documents"
    from opendox import corpus_adapter, workbench
    corpus_adapter.register_home(home_corpus)
    workbench.register_session_notebook_scope(DOCUMENTS)
    • openxFactory's scripts/sync-notebooklm-books.py:2091 calls wb.session_documents(...) for --session-ref, so that script's process needs the same registration.
    • Register home_corpus itself, which builds a fresh adapter on every call. OpenxFactoryCorpusAdapter caches each listing per (location, revision, scope) for as long as the instance lives, and an uncommitted add does not move HEAD. So a factory that returned one shared adapter would give a re-sync a stale listing.
    • The documents scope has no Status: filter of its own; the rule it replaces had one. At c415c3d1 every governed document carries a Status: header, so the two sets are equal (T006: load_docs gives 398, and documents lists 398). T046's proof that the hosted notebook is unchanged has to hold that equality, or register a scope that carries the filter.
  • T022 (P1-D). Once an entry point registers the LocalGitCorpus factory, the standalone notebook lists all: every blob at the worktree's HEAD, read at HEAD, because LocalGitCorpus reads a repository through its history. The host's adapter reads the working tree instead.

    • Copilot's review of this PR raised the difference. The standalone notebook carries the session branch as of its last commit, and not an uncommitted edit.
    • openDox's own flow commits every governed write and creates the notebook right after the first commit, so the two agree when the notebook is created at open.
    • Whether the standalone default should serve the working tree instead is T022's choice of factory, not this task's. I have put it to the lane.
    • Narrowing the standalone set is phase 2's work (T054, R1Q13).
  • T035 (P1-G). tests/test_hermeticity.py::test_the_violation_survives_open_session_notebooks_degradation_clause calls bs.open_session_notebook(wb.NotebookAdapter(), ...) directly.

    • After this task, its setup must register a home corpus that lists at least one document. Without one, the create path stops at ADAPTER_NOT_REGISTERED, which is swallowed into the FR-042 notice, and never reaches the runner.
    • The module is in the root conftest.py's collect_ignore today, so no run shows this. Run by path with the Group 2 shim, the module fails the same 14 cases at main a435aecf and at this head.
    • Where the registration comes from depends on where T035 sends the module: its own setup here, or the host's registration in openXdox-code's tests/integration/. Copilot's overview at 5b4c8774 raised this, and comment 5851370880 answers it.

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

🤖 Generated with Claude Code

Summary by Sourcery

Decouple session notebook document membership from openxFactory by resolving documents through the registered home corpus and scope.

New Features:

  • Route session notebook membership through the registered home corpus, using a registered scope or the default all scope.
  • Add host APIs for registering, unregistering, and inspecting the session notebook scope.

Bug Fixes:

  • Remove the session notebook's deferred dependency on openxFactory's doc_health package.
  • Refuse unregistered home corpora and unknown scopes without widening membership or blocking session creation.

Enhancements:

  • Preserve adapter-provided document content and existing decoding and size-limit behavior while supporting worktree-specific corpus semantics.

Tests:

  • Add comprehensive tests covering corpus and scope registration, membership selection, refusal behavior, content handling, registration discipline, and removal of deferred foreign-package reaches.

…4 T025)

workbench.session_documents imported openxFactory's doc_health.corpus inside
its body and applied that corpus's own membership rule (workbench.py:746 at
1e4a57f): the last of workbench.py's four deferred reaches into the
publisher, which opensoft/openXfactory#1144's task 4.3 routes in phase 1
(plan 034, tasks.md T025; R1Q9 (a)).

It now calls the factory corpus_adapter.home() hands back (T020) on the
worktree, and lists that corpus under the scope a host registered with
opendox.workbench.register_session_notebook_scope(scope), or under `all`,
openDox's default, where none is. openDox's core names no host scope;
openxFactory registers its adapter's `documents` scope (T046), which lists
exactly the notebook's 398 documents at openxFactory c415c3d1 (T006).

With no home corpus registered it refuses as 4.2 does (CorpusRefused,
ADAPTER_NOT_REGISTERED), and a scope the corpus does not declare refuses
SCOPE_UNKNOWN rather than widening. open_session_notebook turns either into
the FR-042 notice, so a notebook never blocks a session. Each document is
decoded as the replaced reader read it (Path.read_text with errors=replace,
so UTF-8 with replacement and universal newlines), and the size bound is
measured as before, so no source's text or content hash moves.

tests/test_session_notebook_membership.py holds that: the 4.2 refusal and
the session's notice, `all` with only openDox's LocalGitCorpus default
registered, the registered scope when there is one, the undeclared-scope
refusal, the decoding held to Path.read_text itself, the size bound, the
scope's one-registration discipline, a booby-trapped doc_health that is
never reached, and an ast check that workbench.py now makes no deferred
reach at all.

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:31
@sourcery-ai

sourcery-ai Bot commented Sep 26, 2026

Copy link
Copy Markdown

Reviewer's Guide

Session notebook document discovery is decoupled from openxFactory-specific doc_health logic and now uses the registered home corpus under an explicitly registered scope, defaulting to all; structured refusals, legacy caller compatibility, text semantics, and the eliminated deferred reach are covered by focused tests.

Sequence diagram for registered session notebook membership

sequenceDiagram
    participant Host
    participant Workbench
    participant CorpusAdapter
    participant CorpusFactory
    participant Corpus

    Host->>Workbench: register_session_notebook_scope(scope)
    Workbench-->>Host: scope
    Host->>Workbench: session_documents(worktree, repository, max_bytes)
    Workbench->>CorpusAdapter: home()
    CorpusAdapter-->>Workbench: factory
    Workbench->>CorpusFactory: factory(worktree)
    CorpusFactory-->>Workbench: adapter, ref
    Workbench->>Corpus: adapter.resolve(ref)
    Corpus-->>Workbench: resolved
    Workbench->>Workbench: session_notebook_scope()
    alt scope is not declared
        Workbench-->>Host: CorpusRefused(SCOPE_UNKNOWN)
    else scope is declared
        Workbench->>Corpus: adapter.list_documents(resolved, scope)
        Corpus-->>Workbench: document IDs
        loop each document
            Workbench->>Corpus: adapter.read(resolved, document_id)
            Corpus-->>Workbench: content
        end
        Workbench-->>Host: document keys and decoded text
    end
Loading

File-Level Changes

Change Details Files
Route session-notebook membership through the registered home corpus and registered scope instead of importing publisher-specific logic.
  • Import and use the home-corpus adapter seam to resolve and list documents from the worktree.
  • Add process-global scope registration with all as the default, idempotent same-value registration, conflict refusal, and reset support.
  • Refuse missing home adapters and undeclared scopes with structured corpus errors rather than falling back or widening scope.
  • Preserve UTF-8 replacement decoding, universal newline behavior, size filtering, document keys, and the compatibility repository parameter.
src/opendox/workbench.py
Add focused coverage for membership behavior, refusal handling, compatibility, and removal of deferred publisher/consumer reaches.
  • Test default all membership, host-registered narrow scopes, worktree factory invocation, and no unintended listing on scope refusal.
  • Test adapter and scope registration lifecycle, FR-042 session-notebook refusal handling, text decoding, and size bounds.
  • Verify doc_health is never imported or touched and reproduce the static deferred-reach check with a negative control.
tests/test_session_notebook_membership.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

The default home factory can read stale or incomplete HEAD content instead of current worktree files.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Routes session notebook membership through the registered home corpus and removes the direct doc_health dependency.

Changes:

  • Adds scope registration, validation, and refusal handling.
  • Preserves document decoding and size limits.
  • Adds membership and hermeticity tests.
File Summary
tests/​test_session_notebook_membership.py Tests membership, refusals, decoding, limits, and dependency removal.
src/​opendox/​workbench.py Implements corpus-based notebook membership; default snapshot behavior may omit uncommitted worktree edits and conflicts with existing contract semantics.

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

Comment thread src/opendox/workbench.py Resolved
brettheap and others added 2 commits September 27, 2026 00:28
…napshot

session_documents reads every listed document through the registered home
corpus's adapter, never by opening <worktree>/<key>: a DocumentId.key is
opaque, and a consumer may not parse it. So what the notebook carries is what
that corpus serves at the worktree. The docstring still said it read the
worktree's files itself, which is true of the host's adapter (it reads the
checkout it is pointed at, file by file, uncommitted edits included) and not
of a corpus that serves a revision, such as LocalGitCorpus, which serves the
worktree's HEAD. It now says both, and where openDox's own flow makes them
agree: every governed write is one commit on the session branch, and the
notebook is created right after the first one.

Two tests pin it. Over a git worktree holding an uncommitted edit and an
untracked draft, a checkout-reading corpus serves both, and LocalGitCorpus
serves HEAD. And row-id keys over an empty worktree are read in full, so no
byte comes from a path built out of a key. A mutant that opens the key as a
path fails 14 of the file's 29 tests, both new ones among them.

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 review requested due to automatic review settings September 27, 2026 00:33
@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

An existing hermeticity regression test no longer reaches its intended runner path and needs updated setup and coverage.

Review effort: Lite
Findings: None

Resolved since last review (1)

@brettheap

Copy link
Copy Markdown
Contributor Author

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

On Copilot's overview at 5b4c8774: "An existing hermeticity regression test no longer reaches its intended runner path and needs updated setup and coverage." Copilot names no file. The one test that reaches the create path through session_documents is tests/test_hermeticity.py::test_the_violation_survives_open_session_notebooks_degradation_clause, which calls bs.open_session_notebook(wb.NotebookAdapter(), ..., worktree=REPO_ROOT).

The observation is right about what the test now needs. With nothing registered at the home seam, session_documents refuses ADAPTER_NOT_REGISTERED, open_session_notebook turns the refusal into its FR-042 notice, and the create path never reaches the runner. So the test's setup must register a home corpus first.

It is not a regression this PR can observe or repair, for three reasons:

  1. Neither main nor this branch runs the module. tests/test_hermeticity.py is in the root conftest.py's disclosed collect_ignore, under "awaits openXdox-code leg (imports openxdox.)"*. That is why it is absent from both whole-suite JUnit reports compared in the body.

  2. Run explicitly, it fails the same way before and after. I ran it by path with the Group 2 shim:

    • at main a435aecf: 14 failed, 17 passed;
    • at 5b4c8774: 14 failed, 17 passed;
    • the failing sets are identical.

    This case is DID NOT RAISE at both heads. At main, session_documents died on from doc_health import corpus, and the module-not-found error was swallowed the same way. Wider than that, the in-process runner layer is not hooked up in this tree at all. test_the_default_notebook_runner_refuses_instead_of_running_nlm fails too, and the PATH shim's refusal of the real nlm shows up as a RuntimeError. No real nlm ran.

  3. The module's return is T035's. Plan 034's T035 empties that collect_ignore, and it either rewrites each of the six modules in place or moves it to openXdox-code's tests/integration/ (T042). How this test gets its home corpus depends on where T035 sends it: from its own setup here, or from the host's registration there. That makes it T035's call, not this slice's. This slice's files are workbench.py, serve_wire.py and doxbench_packet.py, with their seam tests.

I have added this to the body's downstream notes for T035: before calling open_session_notebook, the test must register a home corpus that lists at least one document, or it stops at ADAPTER_NOT_REGISTERED and never reaches the runner.

@brettheap
brettheap marked this pull request as ready for review September 27, 2026 00:46

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

@brettheap

Copy link
Copy Markdown
Contributor Author

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

@brettheap
brettheap merged commit c46430f 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-27T00:48:06Z, PR #43 → c46430f (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
Since the last merge, main gained T025 (#43) and T027 (#41). Neither
touches src/route_extension.py, src/opendox/serve.py, the facet's tests or
the profile-registration runbook.

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

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