Skip to content

BUILD § 3.5/3.6: openDox stops requiring its consumer at import time — 4 of the 13 through a late seam, 9 owed a declared-edit ruling - #9

Merged
brettheap merged 2 commits into
mainfrom
build/remove-openxdox-back-imports
Sep 11, 2026
Merged

brettheap merged 2 commits into
mainfrom
build/remove-openxdox-back-imports

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openxfactory-4-opendox-extraction (formerly openxfactory-opendox)

BUILD slice 2 of split-opendox-two-layer-product, on Brett Heap's rulings of 2026-09-10 22:4xZ (opensoft/openXfactory#656 comment 5626260214): "BUILD arc: START NOW, land each slice when green" and "§ 4.1 … land on green; 4.2–4.5 follow". It takes the openDox half of § 4.1's second failing clause, named on the § 4.1 LANDED note (5627156620).

Refs opensoft/openXfactory#656


1. The claim, in one line

Four of the thirteen import-time openxdox reaches are gone, and two modules of this package now import with no openxdox installed. The other nine are each blocked on a line the carve manifest does not declare, and are named below rather than patched.

before (8e9ffa62) after
import-time openxdox reaches under src/ 13 9
deferred 19 19
modules that import with no openxdox installed 0 of 6 2 of 6

Per module, which is the grain openXdox-code's ratchet reads:

module before after
opendox/branch_session.py (1, 7) (1, 7)
opendox/cli.py (5, 1) (3, 1)
opendox/serve.py (5, 2) (5, 2)
opendox/serve_project.py (0, 2) (0, 2)
opendox/serve_workbench.py (1, 7) (0, 7)
opendox/workbench.py (1, 0) removed from the table — (0, 0)

The companion pull request at openXdox-code lowers OPENDOX_BACK_IMPORTS to exactly that, in the same act, because the ratchet refuses an unrecorded fall.

2. The mechanism, and why it is two mechanisms and not one

design.md:243 states the standard in a sentence: "What must not survive is the direction, not the calls." The thirteen split cleanly into two classes, and the packet gives each its own answer.

(a) CONTRIBUTIONS — the § 2.4 extension points. A route or a subcommand openXdox contributes travels through route_extension.RouteBinding and subcommand_extension.SubcommandExtension. This repository already declares both seams (serve.build_server(route_extensions=…), cli.build_parser(subcommand_extensions=…), tasks.md § 2.4) and openXdox-code already supplies its half (serve_gate.routes(), serve_projection.routes(), cli_gate.GateSubcommands.register()). No new discovery machinery is needed or added: build_parser's own docstring already names the act — "It is also the one line the § 3 carve deletes rather than moves: afterwards the core names no profile and openXdox declares its own." That line is profile_openxfactory.SUBCOMMAND_EXTENSIONS / .ROUTE_EXTENSIONS, and deleting it is blocked on undeclared lines — see § 4. So no entry-point group, no registration hook and no extensions= parameter is invented here: the smallest mechanism is the one already in the tree, and what it is waiting on is a ruling, not a design.

(b) LIBRARY REACHES — a late-bound stand-in. A neutral verb of openDox that CALLS a function living in openXdox's column is the class design.md:243 permits to survive. src/opendox/consumer_reach.py (CREATED, no manifest row, RULED OQ-C) makes those reaches late: a cached stand-in that resolves on first ATTRIBUTE access and otherwise raises ConsumerReachUnavailable naming the layering. This is not a new invention either — it is the shape openXdox-code landed for the mirror-image case eight hours ago in § 4.1 (src/openxdox/consumer_reach.py, bfd95063), reviewed and fix-rounded there, including the narrow ModuleNotFoundError-by-name handling that keeps a broken consumer from being reported as a layering fault.

Four sites, each a one-line-for-one-line conversion inside its row's declared lines, every call site unchanged:

site was now
cli.py:72 from openxdox import gate_console as gate_mod gate_mod = consumer_reach.gate_console
cli.py:74 from openxdox import snapshot as snapshot_mod snapshot_mod = consumer_reach.snapshot
serve_workbench.py:49 from openxdox import snapshot_registry as registry_mod registry_mod = consumer_reach.snapshot_registry
workbench.py:70 from openxdox.snapshot import find_validator find_validator = consumer_reach.find_validator

The last one is a from … import <function> site, so the seam also carries a late CALLABLE (consumer_reach.function) — the call site still spells a bare find_validator(...).

3. THE FINDING — two conversions were made, measured, and REVERTED

serve.py:135 and branch_session.py:77 are single declared lines and convert cleanly. They are deliberately not in this pull request.

def _demotion_retention_candidates(
    checkout_root, tile, *,
    records_dir: str = gate_console.DEFAULT_RECORDS_DIR,   # branch_session.py:1741
):

A default argument is evaluated when the def executes, which is at import time. branch_session.py has 7 such sites and serve.py has 2 (registry_mod.DEFAULT_INDEX_NAME, registry_mod.PEEK_TTL_SECONDS, lines 1280/1284). Converting the import alone leaves the module resolving openxdox at import time through the stand-in — proved on this branch before the revert:

opendox.branch_session  ConsumerReachUnavailable: 'openxdox.gate_console' belongs to openXdox …
                        File ".../branch_session.py", line 1741, in <module>

openXdox-code's ratchet cannot see this. OPENDOX_BACK_IMPORTS is an AST census over ast.Import / ast.ImportFrom nodes; a default-argument reach is neither. So the conversion would have lowered the recorded census by two — branch_session all the way to (0, 7), the reading "this module no longer imports openXdox at all" — while import opendox.branch_session still failed without it. A census that reads better than the tree is worse than no census, so the edits were reverted and the sites are listed in § 4 with the others.

Two consequences, both acted on:

  1. This repository asserts the property the census is a proxy for, not the census: tests/test_consumer_reach.py imports each module in a subprocess with openxdox blocked at the finder and requires exit 0.
  2. An AST guard here (test_a_converted_name_is_never_used_at_import_time) walks defaults, annotations, decorators and class bodies for reads of a converted name — the guard that would have caught both reverts before they were made. It is not offered as a fix to the openXdox-side ratchet, which is correct for what it measures; it is the gap named so § 4.1's owner can decide.

4. The nine that remain — every one blocked on an UNDECLARED LINE

docs/opendox-carve-manifest.yaml gives each of these files a moved_with_declared_edit row bounding edits to named CARVE-COMMIT lines, and scripts/verify-carve-arrival.py --phase B enforces it. A replace opcode touching an undeclared carve line refuses; an insertion is lawful only beside a declared one. Every one of the thirteen import-time reaches sits ON a declared line — but nine of them cannot be removed without also touching a line that is not.

reach what the fix needs carve line(s) needed declared?
cli.py:79 from openxdox.corpus_root import ( delete or replace the 3-line statement 80, 81 no (79 is)
cli.py:82 from openxdox.generator import ( same 83, 84 no (82 is)
cli.py:978 the 19-verb gate re-export delete the block; the verbs are a CONTRIBUTION, not a core name 980–989 no (979 is)
serve.py:167 serve_gate, :170 serve_projection stop naming them as MIXIN BASES of DashboardHandler 626–630 no
serve.py:172, :188 the two name re-export blocks delete them 176–177, 192–198 no
the composition point profile_openxfactory.ROUTE_EXTENSIONS hand extensions in instead of naming a profile 1380–1381 no
serve.py:135, branch_session.py:77 defer the DEFAULT-ARGUMENT reaches (§ 3) branch_session 1740, 1859, 1878, 4179, 4217, 4254, 4287, 4504, 4991; serve 1283, 1287 no

So this lane owes Brett Heap a declared-edit ruling, not a patch. The question is narrow and it is the same question for all nine: may a post-carve BUILD-arc change edit a moved_with_declared_edit row outside its declared lines, and if so under what record? The § 4.1 pull request framed it the other way round — "The fix needs no line outside a declared range, so no manifest question arises" — which is the first half of the same rule. Nothing here presumes the answer.

Two smaller things fall out of the same table, recorded for whoever words that ruling:

  • serve.py also reaches the PRE-CARVE package twice at import time — from ideation_dashboard import serve_openxfactory_lanes (:168) and its name block (:175). serve_openxfactory_lanes is a stays_openxfactory_adapter row under RULING DQ-1, present at NEITHER destination, so the carve's import rewrites class had nothing lawful to rewrite it to. It is the identical defect class § 4.1 fixed on the openXdox side (cli_gate.py:49 → human_seen), and it is blocked by the identical undeclared lines. Recorded as a census in test_no_module_under_src_names_the_pre_carve_package_at_import_time, which refuses a rise.
  • cli.py:914 and serve.py:1376 still name profile_openxfactory, which exists nowhere in the carved estate — so build_parser() and build_server() raise NameError today, independent of anything here. That is § 4.3's box and the § 4.1 note already flags it.

5. Proof

openDox imports with NO openxdox installed — fresh venv, pip install -e ".[test]", nothing else (importlib.util.find_spec('openxdox') → None):

opendox.workbench            IMPORTS OK
opendox.serve_workbench      IMPORTS OK
opendox.branch_session       FAILS: ModuleNotFoundError: No module named 'openxdox'
opendox.serve                FAILS: ModuleNotFoundError: No module named 'openxdox'
opendox.cli                  FAILS: ModuleNotFoundError: No module named 'openxdox'

The three failures are the nine reaches of § 4, and they fail on the ORIGINAL import statements — nothing here converted a hard failure into a quiet one.

The seams pick up openXdox when it IS installed — second venv carrying both legs; see the comment thread on this pull request for the transcript.

This repository's own gate, exactly as CI runs it:

$ python -m pytest -q tests/test_leg_shape.py tests/test_consumer_reach.py --noconftest
28 passed          (12 at main — 16 new tests, no regression)

FLOOR PART 1, the arrival verifier, phase B, on this branch:

OK …/dox: opendox_code (opensoft/openDox-code) at opensoft/openxFactory@b075fd91dc8f
(opendox-carve-0), phase B — 123 row(s) arrived, 61 digest(s) verified, 61 declared-edit
row(s) within their lines, 1 unapplied; 0 of 0 declared replica(s) verified (byte-identical,
or — where the row declares lines — differing only on them); 134 file(s) under src/opendox,
tests with none undeclared (1 scaffold, 8 replica, 2 created); scaffold admissions checked
against 8e9ffa628e96
exit=0

Against the line leg 1 landed on, every row figure is identical — 123 / 61 / 61 / 1 unapplied — and the only movement is 132 → 134 file(s) and 0 → 2 created, which are exactly the two created files, each named on the command line:

--allow-created src/opendox/consumer_reach.py
--allow-created tests/test_consumer_reach.py

No row was edited outside its declared lines, which is what § 4 is about: the edits that WOULD have been are not in this branch.

7. Fix round 1 — five review findings over three defects, all taken (551ad4d5)

Two reviewers found the same two test defects independently; all five threads are answered and resolved.

  1. The refusal named a remedy that is not one. ConsumerReachUnavailable told the caller to use the § 2.4 extension points; they contribute route bindings and subcommands and cannot inject a MODULE, so a caller who followed the message arrived back at the same refusal. It now says the remedy is to install openXdox and only that today, says why the extension points are not an alternative, and names the injection that would remove the reach as work that does not exist yet. No capability-injection API was invented here — that is the design fix, § 3.5/3.6 / § 4.3, and not this slice's to choose.
  2. A nonzero exit was being read as "still reaches the consumer". STILL_REACHING would have stayed green on a syntax error or an unrelated missing dependency, masking a defect in the half of the file nobody looks at. The failure must now be an ImportError/ModuleNotFoundError whose LAST line names openxdox — two clauses, because a SyntaxError carries no module name to match on. Perturbation-proved on a module made to fail with import no_such_dependency.
  3. The fake openxdox parent leaked into the rest of the process. Tracked and removed now. Reproduced first — import openxdox SUCCEEDED after the test without the cleanup and raises ModuleNotFoundError with it. Disclosed: removing the cleanup again still passes 16/16, because every later reach in this file is to a SUBMODULE and an empty parent refuses those as an absent one does; this is hygiene for what is collected next, not a bug the suite was hiding.

The arrival verifier was re-run on the amended tree and reproduces the same OK line byte for byte.

8. What this pull request does not touch

No manifest, no pin, no gitlink, no openspec/changes/, nothing in openxFactory. No moved_verbatim row. conftest.py's collect_ignore list is unchanged: the two suites it names for workbench (tests/test_workbench.py) reach openXdox at RUN time as well as import time, so un-ignoring them is a slice of its own.

🤖 Generated with Claude Code

…(4 of the 13, RULED 5626260214)

openDox is the NEUTRAL product. openXdox pins it (split-opendox § 4.2, RULED
OQ-2) and openDox pins nothing back, so a neutral openDox with no `openxdox`
installed is the normal case. Thirteen module-level reaches into `openxdox`
survived the carve, measured at 8e9ffa6 and ratcheted from openXdox-code.

Four are removed here through a late-bound seam, `src/opendox/consumer_reach.py`
— the shape openXdox-code landed for the mirror-image case in § 4.1
(bfd95063): a cached stand-in that resolves on first ATTRIBUTE access and
otherwise refuses naming the layering rather than raising ModuleNotFoundError
from an import line far from the call. cli.py :72 :74, serve_workbench.py :49
and workbench.py :70. Every call site is unchanged.

  src/opendox/workbench.py        IMPORTS with no openxdox installed
  src/opendox/serve_workbench.py  IMPORTS with no openxdox installed

Nine remain, and NONE of them is blocked on judgement — each needs a line the
carve manifest's row does not declare, so each is owed a declared-edit ruling
and is named on the pull request rather than patched:

  cli.py  :79 :82   multi-line `from openxdox.X import (...)`; the
                    continuation lines (carve 80-81, 83-84) are undeclared
  cli.py  :978      the 19-verb gate re-export; carve 980-989 undeclared
  serve.py :167 :170 :172 :188  serve_gate / serve_projection are MIXIN BASES
                    of DashboardHandler (carve 626-630) and are re-exported in
                    multi-line blocks (carve 176-177, 192-198); the
                    composition point is carve 1380-1381. All undeclared
  serve.py :135, branch_session.py :77   DELIBERATELY NOT CONVERTED

The last two are the finding of this slice. Both modules evaluate
`<consumer module>.<CONSTANT>` as a DEFAULT ARGUMENT — branch_session at 7
sites, serve at 2 — which runs when the `def` executes, i.e. at import time.
Rewriting the import alone would lower openXdox-code's AST census by one while
the module still could not be imported without openXdox: the reach would stop
being an Import node without stopping being a reach. Both edits were made,
measured, and reverted.

tests/test_consumer_reach.py (16 tests) therefore asserts the property the
census is a proxy for — the module IMPORTS, in a subprocess with `openxdox`
blocked at the finder — plus the seam's run-time behaviour and an AST guard
over defaults/annotations/decorators that would have caught the two reverts
before they were made. .github/workflows/validate.yml runs it.

Arrival verifier, phase B, on this branch: OK — every row figure identical to
the landed baseline (123 rows / 61 digests / 61 declared-edit rows within
their lines / 1 unapplied), the only movement being 132 -> 134 files and
0 -> 2 created, which are exactly the two files named with --allow-created.

Refs opensoft/openXfactory#656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 11, 2026 00:58
@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This slice removes four import-time openXdox dependencies by routing selected module and function references through a lazy consumer-reach seam, allowing two openDox modules to import without openXdox while preserving runtime behavior when the consumer is installed. New subprocess, AST, and seam tests enforce the actual importability property, document the nine intentionally unresolved reaches, and run in CI.

Sequence diagram for lazy openXdox consumer reach resolution

sequenceDiagram
    participant OpenDox as OpenDox module
    participant Reach as consumer_reach
    participant Importer as Python importer
    participant Consumer as openXdox module

    OpenDox->>Reach: access gate_console, snapshot_registry, or find_validator
    Reach->>Importer: import_module(openxdox.module)
    alt consumer installed
        Importer->>Consumer: load module
        Consumer-->>Reach: module
        Reach-->>OpenDox: cached module or callable
        OpenDox->>Consumer: invoke existing operation
    else consumer unavailable
        Importer-->>Reach: ModuleNotFoundError
        Reach-->>OpenDox: ConsumerReachUnavailable
    end
Loading

File-Level Changes

Change Details Files
Introduces a lazy, cached seam for consumer-module and consumer-function access, converting four import-time openDox-to-openXdox dependencies without changing downstream call sites.
  • Adds module and callable proxies that resolve only on first use.
  • Converts CLI gate/snapshot access, workbench validator access, and workbench-serving registry access.
  • Raises a descriptive layering error only when openXdox is absent, while propagating failures originating inside an installed consumer.
src/opendox/consumer_reach.py
src/opendox/cli.py
src/opendox/serve_workbench.py
src/opendox/workbench.py
Adds executable safeguards proving import-time dependency direction and documenting the remaining reaches.
  • Tests neutral modules in subprocesses with openXdox blocked.
  • Exercises deferred resolution, caching, callable forwarding, error discrimination, and dunder behavior.
  • Adds AST checks for converted-name use in defaults, annotations, decorators, and module/class import-time code.
  • Records the nine remaining reaches and pre-carve package references as expected until a declared-edit ruling.
tests/test_consumer_reach.py
Integrates the new consumer-reach suite into the dependency-free validation workflow.
  • Runs consumer-reach tests alongside leg-shape validation under --noconftest.
.github/workflows/validate.yml

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

@brettheap brettheap changed the title BUILD § 3.5/3.6: openDox stops importing its consumer — the 13 import-time openxdox reaches go through the § 2.4 seams BUILD § 3.5/3.6: openDox stops requiring its consumer at import time — 4 of the 13 through a late seam, 9 owed a declared-edit ruling Sep 11, 2026
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-4-opendox-extraction (formerly openxfactory-opendox)

The both-legs transcript — the seams pick up openXdox when it IS installed

Second venv: pip install -e <openDox-code@this branch> then pip install --no-deps -e <openXdox-code@main bfd95063>. A doc_health meta-path stub is on the path for § 3 onward, exactly as § 4.1's pull request did to unmask cli_gate — 12 of 18 openXdox-code modules still raise ModuleNotFoundError: doc_health, which is § 4.1's FIRST open clause and not this slice's.

openxdox installed at: …/xdox/src/openxdox

--- (1) the late seam resolves to the REAL consumer module ---
  consumer_reach.snapshot.resolve()          is openxdox.snapshot          -> True
  consumer_reach.snapshot_registry.resolve() is openxdox.snapshot_registry -> True

--- (2) the CONVERTED call sites see the real module ---
  serve_workbench.registry_mod.DEFAULT_INDEX_NAME -> 'index.json'
  serve_workbench.registry_mod is openxdox.snapshot_registry -> True
  workbench.find_validator(Path('/nonexistent')) -> None
  workbench.find_validator forwards to openxdox.snapshot.find_validator -> True

--- (3) the § 2.4 SEAMS, openXdox's half, live ---
  serve_gate.GateRoutesExtension: conforms to RouteExtension -> True; routes() -> 1 binding(s); all RouteBinding -> True
  serve_projection.ProjectionRoutesExtension: conforms to RouteExtension -> True; routes() -> 3 binding(s); all RouteBinding -> True
  cli_gate.GateSubcommands() conforms to SubcommandExtension -> True | MEMBERS = ('register',)

--- (4) collect_bindings over BOTH contributed columns, the way build_server does ---
  collect_bindings((GateRoutesExtension(), ProjectionRoutesExtension())) -> 4 binding(s)
     GET   /snapshot-index.json         exact  -> _serve_index
     GET   /source                      exact  -> _refuse_bare_source
     POST  /actions/gate/               prefix -> _handle_gate_action
     GET   /source/                     prefix -> _serve_source

--- (5) register_all onto a REAL argparse parser, the way build_parser does ---
  contributed subcommands -> ['gate']

So no new discovery mechanism is needed: openXdox's half of both § 2.4 seams already conforms structurally and already produces RouteBindings and a register, and openDox's collect_bindings / register_all already accept them. What is missing is only the composition point — profile_openxfactory, which exists nowhere in the carved estate (§ 4.3's box) — and the ability to delete the lines that name it (§ 4 of the description).

One more finding, from the same transcript

Before the doc_health stub was added, the first access through the seam produced this:

  cli.gate_mod.GateConsole -> ModuleNotFoundError: No module named 'doc_health'
  is ConsumerReachUnavailable? False

False is the correct answer and it is load-bearing: openXdox IS installed, so this is not a layering failure, and consumer_reach re-raises it untouched rather than converting it into ConsumerReachUnavailable. That is § 4.1 fix-round finding 2 ("except ImportError was too wide") holding on this side of the seam, observed live rather than asserted.

A CYCLE the transcript exposes, for whoever words the declared-edit ruling

openxdox.cli_gate:46 imports opendox.branch_session, which at :77 imports openxdox.gate_console. So the subcommand seam cannot be exercised end to end — from openxdox import cli_gate re-enters openXdox through openDox — until branch_session.py:77 is gone. It is one of the nine, and it is the one blocked by the seven DEFAULT-ARGUMENT lines in § 3 of the description. The cycle is not new (it is the direction the BUILD arc removes) but it does mean branch_session.py is the highest-value of the nine, not the smallest.

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.

🟡 Changes recommended

Four unresolved moderate findings affect the consumer seam and test reliability.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds late-bound openxdox access so selected opendox modules can import independently, with new tests and CI coverage.

Changes:

  • Adds cached module and callable consumer proxies.
  • Defers selected CLI, workbench, and serving dependencies.
  • Adds import-isolation and dependency-census tests.
  • Runs the new tests in CI.
File summaries
File Summary and review notes
tests/test_consumer_reach.py Adds isolation and census tests. Three moderate findings remain: validate blocked-import failures specifically (3 votes), clean up fake parent packages (2 votes), and traverse nested import-time statements (1 vote).
src/opendox/workbench.py Defers validator resolution through the consumer seam.
src/opendox/serve_workbench.py Defers snapshot registry resolution.
src/opendox/consumer_reach.py Adds late-bound consumer access. One moderate finding (2 votes): the documented extension-point alternative does not inject the required capabilities.
src/opendox/cli.py Defers gate and snapshot module resolution.
.github/workflows/validate.yml Runs the consumer-reach validation suite.
Review details

Suppressed comments (1)

tests/test_consumer_reach.py:335

  • ast.iter_child_nodes(tree) visits only direct Module children, so an ideation_dashboard import inside a module-level if, try, with, or class body is not counted even though it executes during module import. This guard can therefore report the expected census while a new pre-carve import still breaks neutrality; traverse import-time statement bodies while excluding function bodies.
        for node in ast.iter_child_nodes(tree):
            if isinstance(node, ast.ImportFrom) and not node.level and \
                    (node.module or "").split(".")[0] == "ideation_dashboard":
                seen[rel] = seen.get(rel, 0) + 1
            elif isinstance(node, ast.Import) and any(
                    a.name.split(".")[0] == "ideation_dashboard" for a in node.names):
                seen[rel] = seen.get(rel, 0) + 1
  • Files reviewed: 6/6 changed files
  • Comments generated: 3
  • Review effort level: Lite

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

Comment thread src/opendox/consumer_reach.py Resolved
Comment thread tests/test_consumer_reach.py Resolved
Comment thread tests/test_consumer_reach.py Resolved
@brettheap
brettheap marked this pull request as ready for review September 11, 2026 01:05

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/test_consumer_reach.py" line_range="127" />
<code_context>
+    is what stops the list above from silently becoming a list of two.
+    """
+    done = _import_in_subprocess(module, consumer_blocked=True)
+    assert done.returncode != 0, (
+        f"`import {module}` now SUCCEEDS with no `openxdox` — good, and the "
+        f"record in this file is out of date. Move {module!r} from "
</code_context>
<issue_to_address>
**issue (testing):** `test_the_reaching_modules_are_recorded_as_reaching` passes for any import failure, not specifically a failure caused by the recorded `openxdox` reach. A later regression such as a syntax error, missing unrelated dependency, or broken local import therefore leaves this test green while the census claim is no longer true.

**Triggers:** When one of the modules in `STILL_REACHING` becomes broken for a reason unrelated to the consumer dependency.

**Suggested fix:** Assert that stderr contains the expected `openxdox` failure or inspect the traceback/module name instead of checking only that the return code is nonzero.

```suggestion
    assert done.returncode != 0 and "openxdox" in done.stderr, (
```
</issue_to_address>

### Comment 2
<location path="tests/test_consumer_reach.py" line_range="201-209" />
<code_context>
+
+    original = consumer_reach.importlib.import_module
+    consumer_reach.importlib.import_module = _raise
+    try:
+        with pytest.raises(ModuleNotFoundError) as caught:
+            reach.anything
+    finally:
+        consumer_reach.importlib.import_module = original
+    assert caught.value is broken
+    assert not isinstance(caught.value, consumer_reach.ConsumerReachUnavailable)
+
+
+def test_resolution_forwards_to_the_real_module_and_caches(tmp_path: Path) -> None:
</code_context>
<issue_to_address>
**issue (bug_risk):** `test_resolution_forwards_to_the_real_module_and_caches` installs a synthetic `sys.modules["openxdox"]` parent but removes only `openxdox.pretend`; when the real consumer is absent, the fake parent remains in the pytest process and can mask a subsequently installed or injected `openxdox` package for later tests.

**Triggers:** When `openxdox` is absent during this test and a later test imports or simulates the consumer package in the same process.

**Suggested fix:** Save the prior `openxdox` and `openxdox.pretend` entries and restore both in `finally`, deleting the synthetic parent when the test created it.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: tests/test_consumer_reach.py:127, tests/test_consumer_reach.py:209


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread tests/test_consumer_reach.py Resolved
Comment thread tests/test_consumer_reach.py Resolved
Copilot AI review requested due to automatic review settings September 11, 2026 01:08
1. THE REFUSAL POINTED AT A REMEDY THAT IS NOT ONE. `ConsumerReachUnavailable`
   told a caller to "assemble a server that contributes this capability
   through the § 2.4 extension points". It cannot:
   `build_server(route_extensions=)` contributes route bindings and
   `build_parser(subcommand_extensions=)` contributes subcommands, and neither
   injects a MODULE — so a caller who followed the message arrived back at the
   same refusal. The message now says the remedy is to install openXdox AND
   ONLY THAT today, says why the extension points are not an alternative, and
   names the injection that would remove the reach as work that does not exist
   yet (§ 3.5/3.6, § 4.3).

2. A NONZERO EXIT WAS BEING READ AS "STILL REACHES THE CONSUMER".
   test_the_reaching_modules_are_recorded_as_reaching accepted any failing
   subprocess, so a syntax error or an unrelated missing dependency would have
   sat in STILL_REACHING forever, green, while masking a real defect. The
   failure must now be an ImportError/ModuleNotFoundError whose last line
   names `openxdox`. Perturbation-proved by recording a module made to fail on
   `import no_such_dependency`:

     AssertionError: `import opendox.doxbench_bridge` raised an import error
     naming something other than the blocked consumer — a real missing
     dependency, not a layering edge

3. THE FAKE `openxdox` PARENT LEAKED INTO THE REST OF THE PROCESS.
   test_resolution_forwards_to_the_real_module_and_caches created it with
   `sys.modules.setdefault` and removed only the submodule, so every later
   test saw an importable empty package. Tracked and removed now. The
   observable difference, reproduced:

     baseline                     ModuleNotFoundError: No module named 'openxdox'
     after the test, no cleanup   `import openxdox` SUCCEEDED -> <module 'openxdox'>
     after the cleanup            ModuleNotFoundError: No module named 'openxdox'

   Disclosed: this leak did NOT turn any test in this file red, because the
   only later reaches are to SUBMODULES and an empty parent refuses those the
   same way an absent one does. It is hygiene for whatever is collected next
   — `tests/test_workbench.py` when its collect_ignore entry comes out — not a
   bug this file was hiding.

  python -m pytest -q tests/test_leg_shape.py tests/test_consumer_reach.py --noconftest
  28 passed

Arrival verifier, phase B, re-run on the amended tree: OK, reproducing the
same line byte for byte.

Refs opensoft/openXfactory#656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <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.

🔵 Needs a closer look

Moderate findings remain around runtime coverage, census traversal, and exact package-name validation.

Review details

Suppressed comments (4)

Previously missed (1) — in code that hasn't changed since the last review.

tests/test_consumer_reach.py:353

  • This census only examines direct children of the module. An import nested in a module-level if, try, with, or class body also executes during import but is skipped here, so a new ideation_dashboard reach could be introduced without failing this guard. Traverse module-level statement bodies recursively while excluding function bodies, as _import_time_uses does, instead of using only ast.iter_child_nodes(tree).

src/opendox/cli.py:75

  • Neither late binding in this hunk is exercised after import: test_consumer_reach.py tests the generic stand-in, but no selected test calls cli.gate_mod or cli.snapshot_mod. Since cli remains blocked by other imports, a typo in either alias or a broken attribute forward can leave the new import checks green. Add a focused fake-consumer test that exercises the converted CLI path.
from opendox import consumer_reach  # noqa: E402
gate_mod = consumer_reach.gate_console  # noqa: E402
from opendox import serve as serve_mod  # noqa: E402
snapshot_mod = consumer_reach.snapshot  # noqa: E402

src/opendox/consumer_reach.py:191

  • module() promises that callers pass a name without the package prefix, but this condition rejects only dotted forms. module("openxdox", ...) is accepted and resolves to openxdox.openxdox instead of failing, so the exact package name is silently misinterpreted. Reject the exact package name as well.
    if name.startswith(f"{CONSUMER_PACKAGE}."):

src/opendox/workbench.py:71

  • This changes the module-level find_validator binding used by validate_manifest, but the new tests only prove that workbench imports and never invoke this rebound alias. The existing workbench suite is in the root conftest's ignored set, and the new --noconftest CI command omits it, so a wrong target or forwarding regression would pass. Add a focused fake-consumer test that calls workbench.find_validator (or validate_manifest) after import.
find_validator = consumer_reach.find_validator
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap
brettheap merged commit da8aae9 into main Sep 11, 2026
4 checks passed
brettheap added a commit that referenced this pull request Sep 11, 2026
…sole at import time

`from openxdox import gate_console` (:77, declared) becomes
`from .consumer_reach import gate_console` — the same NAME, bound to the late
stand-in step 1 added, so all thirty-odd `gate_console.X` call sites below are
unchanged and only the DIRECTION at import time goes (`design.md`:243).

The nine `records_dir: str = gate_console.DEFAULT_RECORDS_DIR` DEFAULT
ARGUMENTS (:1740, :1859, :1878, :4179, :4217, :4254, :4287, :4504, :4991 — the
nine lines the Q-L1 row annotation declares) become `DEFAULT_RECORDS_DIR` from
`opendox.defaults`. No stand-in can serve them: a default argument is evaluated
where the `def` sits, at import time, which is what openDox-code #9 § 3
measured and reverted.

`import opendox.branch_session` now succeeds with `openxdox` unimportable.
Every edited line is one the row declares — carve 77 (replaced by the import
plus its reason) and the nine annotated default lines; the arrival verifier
reports no undeclared line.

Refs opensoft/openXfactory#656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
brettheap added a commit that referenced this pull request Sep 11, 2026
…f1f2e5

This PR was STACKED on `build/remove-back-imports-2b`; that branch landed as
openDox-code #10, squashed onto `main` as `0f1f2e59`. The stack therefore had to
be brought onto `main` before the ruled serve.py half (ASK-6 -> 1) could be
authored against the file main actually carries.

A REBASE was the intended act and IS what fixes this tree: `git rebase --onto
origin/main cc1d806 build/section-4-3-profile-lazy-proxy` replayed all seven
§ 4.3 commits with ZERO conflicts and produced a diff against `main` that is
BYTE-IDENTICAL to the pre-rebase diff against `cc1d806b` — proof that main's
squash of 2b and this branch's 2b ancestry are the same content, and that
§ 4.3 touches nothing 2b left unsettled.

It could not be PUSHED as a rebase. The `opensoft` org-level ruleset 8981805
applies `non_fast_forward` to EVERY branch of this repository, not just `main`,
so history replacement is refused for this branch by policy
(`GH013 ... Cannot force-push to this branch`). The lane's permitted single
force is unavailable, and bypassing an org ruleset is not this author's act.

So the same result arrives append-only: this is `main` merged INTO the branch,
with the merge resolved to EXACTLY the verified rebase's tree
(`16cf0c43` = `ef67c83`^{tree}, the rebase head's tree). The two conflicted
files — `src/opendox/cli.py` and `tests/test_consumer_reach.py`, the two the
§ 4.3 commits edit on top of 2b — take the rebase's resolution, which is
main's 2b shape with the § 4.3 intent re-applied on top, because that is what
the conflict-free rebase computed. `git diff origin/main...HEAD` is unchanged
by this commit.

Landing is unaffected: #9 and #10 both landed as SQUASHES (`da8aae96`,
`0f1f2e59`), so the merge commit and the duplicated 2b ancestry do not reach
`main` — the squash carries this tree and nothing else.

Lane: openxfactory-4-opendox-extraction
Refs opensoft/openXfactory#656

Co-Authored-By: Claude Opus 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