Skip to content

§ 4.1: invert the openDox→openXdox dependency direction (split-opendox, RULED 5626260214) - #7

Merged
brettheap merged 2 commits into
mainfrom
change/section-4-1-inversion
Sep 10, 2026
Merged

brettheap merged 2 commits into
mainfrom
change/section-4-1-inversion

Conversation

@brettheap

@brettheap brettheap commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

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

§ 4.1 of split-opendox-two-layer-product, on Brett Heap's ruling of 2026-09-10 22:4xZ (opensoft/openXfactory#656 comment 5626260214): "START 4.1 NOW — one author on the 13-line openDox→openXdox inversion in opensoft/openXdox-code, its own PR there, verifier, land on green."

Refs opensoft/openXfactory#656


1. What the 13 turned out to be — measured, not carried

The 13 are not in this repository. The census the ruling's phrase comes from is on #656 (5620977531): "13 module-level reaches into openXdox over five core files — cli.py :72 :74 :79 :82 :979, serve.py :138 :170 :173 :175 :191, serve_workbench.py :49, branch_session.py :77, workbench.py :70". Those are lines of opensoft/openDox-**code**. Re-measured live at the commit this leg pins, they reproduce exactly — same five files, same 5/5/1/1/1 distribution — with the line numbers a few apart because the census predates openDox-code's levelling round 4:

module (opensoft/openDox-code @ 8e9ffa62) import-time deferred import-time lines
src/opendox/cli.py 5 1 72, 74, 79, 82, 978
src/opendox/serve.py 5 2 135, 167, 170, 172, 188
src/opendox/branch_session.py 1 7 77
src/opendox/serve_workbench.py 1 7 49
src/opendox/workbench.py 1 0 70
src/opendox/serve_project.py 0 2 —
total 13 19 32 over six modules

Byte-identical at ce53b489, the commit openDox's assembly root pins. A correction for the record: the reality check of 2026-09-10 says "34 back-imports … across six modules"; the live count is 32 (the six modules and the import-time 13 are unchanged, so the ruling's own figure is unaffected).

What IS in this repository — measured at main 59600412 by AST, counting an import as import-time when it runs on import: the walk descends into module-level if/try/with and class bodies, which all execute on import, and stops only at function bodies. (The class half was a review finding; correcting it moved no number — see § 7.)

cross-package root reached from src/ import-time deferred verdict
opendox 17 13 lawful — this IS the direction the pin chain declares (RULED OQ-2)
doc_health 8 5 lawful here by § 4.1's own second clause
yaml 6 2 declared runtime dependency
jsonschema 0 1 finding, not fixed here — gate_console.py:563, absent from pyproject.toml
ideation_dashboard 1 0 the one wrong-direction line: src/openxdox/cli_gate.py:49

So the wrong-direction count in this leg's src/ at live main is 1, not 13.

2. The one line, and why the carve left it

src/openxdox/cli_gate.py:49
    from ideation_dashboard import human_seen as human_seen_mod

human_seen is a not_moved / stays_openxfactory_adapter row under RULING DQ-1 — openxFactory's own cross-reference candidate register (design.md § D3, "the candidate-register row"). It is present at neither carve destination (confirmed: absent from openDox-code/src/opendox/ and from openXdox-code/src/openxdox/). The carve's import rewrites class therefore had nothing lawful to rewrite line 49 to, and left the pre-carve package name standing while rewriting all eleven of its neighbours.

That import is the pin chain running backwards: openxFactory pins the openXdox assembly root (§ 5.1, RULING F), so a module of this package may not import openxFactory's column at import time. design.md:243 states the standard in one sentence — "What must not survive is the direction, not the calls."

It was masked, which is why arrival alone did not surface it. cli_gate.py:47 imports gate_console, which reaches doc_health at its line 63 — so import openxdox.cli_gate fails on doc_health before reaching line 49, and the reality check's census attributed cli_gate to the doc_health column. Unmasked with a doc_health stub on the path:

BEFORE (main 59600412):
  File ".../src/openxdox/cli_gate.py", line 49, in <module>
      from ideation_dashboard import human_seen as human_seen_mod
  ModuleNotFoundError: No module named 'ideation_dashboard'

AFTER (this branch):
  imported ok

Line 49 is inside its row's own declared range. The manifest declares scripts/ideation_dashboard/cli_gate.py moved_with_declared_edit with {class: import rewrites, lines: [44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 74]}. The fix needs no line outside a declared range, so no manifest question arises.

3. The fix — one line, plus its home

Four files, +634 −2 against main (both commits).

file ± what
src/openxdox/cli_gate.py +1 −1 line 49 → from openxdox.consumer_reach import human_seen as human_seen_mod. The public name human_seen_mod is unchanged, so the two call sites (:396, :417 — both inside cmd_gate_lens_add_as_cluster, both on undeclared lines) are untouched.
src/openxdox/consumer_reach.py +155 CREATED (no manifest row — RULED OQ-C). A cached lazy module proxy: resolves ideation_dashboard.human_seen / human_seen on first attribute access, and otherwise raises ConsumerReachUnavailable naming the layering instead of a bare ModuleNotFoundError.
tests/test_dependency_direction.py +466 CREATED. The direction, asserted — by AST over both trees, and at run time over the seam.
.github/workflows/validate.yml +13 −2 runs the new suite beside test_leg_shape.py.

What this deliberately is NOT. It is not the design fix. The right long-run shape is injection — openxFactory hands its submission sink to the verb and openXdox names a protocol rather than a module — and that is BUILD-arc work (§ 3.5/3.6). The proxy is kept narrow on purpose (one name, its reason, its manifest row) so it cannot grow into a facade. No refactor beyond the direction fix; openxdox_surface.py is untouched and still coherent.

4. The direction is now ASSERTED, and every assertion is load-bearing

tests/test_dependency_direction.py, 12 tests: three strict direction checks (they hold today), one enumeration of § 4.1's own surface, one per-module ratchet over the pinned openDox, one self-retirement guard, and five that exercise the new seam at RUN TIME rather than by parsing it.

Each guard was perturbed and observed to fail — a guard nobody has seen fail is a guard nobody has tested:

perturbation result
re-add from ideation_dashboard import human_seen to src/openxdox/register.py AssertionError: 1 import(s) under src/ still name the PRE-CARVE package 'ideation_dashboard': ['src/openxdox/register.py:33'] (2 tests fail)
add an undeclared import-time reach (import requests) AssertionError: import-time reach(es) out of src/ that this leg does not declare: ['src/openxdox/register.py:33 -> requests']
add a doc_health import to a 9th module AssertionError: the doc_health implementation surface (§ 4.1's second clause) moved.
add a back-import to the pinned openDox in site-packages AssertionError: openDox→openXdox back-imports ROSE, per module (import-time, deferred): ['opendox/workbench.py: (1, 0) -> (2, 0)']. The direction may only be removed, never added to …
remove one back-import from the pinned openDox Failed: openDox→openXdox back-imports FELL, per module … — good, and the census in this file is now untrue. Update OPENDOX_BACK_IMPORTS to the observed values in the same act …
compensating −1 in workbench.py / +1 in serve_project.py (both totals unchanged at 13/19) AssertionError: … ROSE, per module (import-time, deferred): ['opendox/serve_project.py: (0, 2) -> (1, 2)'] — the hole the fix round closed

Why the openDox side is a ratchet and not an assertion. The 32 back-imports are in a repository this leg consumes and does not write. A test that asserted they were gone would be red for reasons no commit here can fix. So the census is landed as data and may only fall — and an unrecorded fall also fails, so the number in the tree stays true as the BUILD arc removes them, rather than rotting into a stale comment. When both counts reach zero the suite tells the author to delete the ratchet and assert strictly.

5. Validators

The destination's own gate, exactly as CI runs it (pip install -e ".[test]" in a clean venv, which resolves opendox to the pinned 8e9ffa62 — the reach § 4.1 needs and not something added to this tree):

$ python -m pytest -q tests/test_leg_shape.py tests/test_dependency_direction.py --noconftest
24 passed in 1.46s          (12 at main — 12 new tests, no regression)

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

OK …/openXdox-code: openxdox_code (opensoft/openXdox-code) at opensoft/openxFactory@b075fd91dc8f
(opendox-carve-0), phase B — 92 row(s) arrived, 9 digest(s) verified, 81 declared-edit row(s)
within their lines, 4 unapplied; 6 of 6 declared replica(s) verified (byte-identical, or — where
the row declares lines — differing only on them); 99 file(s) under scripts, src/openxdox, tests
with none undeclared (1 scaffold, 0 replica, 2 created); scaffold admissions checked against
3487e476d782
exit=0

Against the line leg 3 landed on, every row figure is identical — 92 / 9 / 81 / 4 unapplied / 6 of 6 — and the only movement is 97 → 99 file(s) and 0 → 2 created, which are exactly the two created files, each named on the command line:

--allow-created src/openxdox/consumer_reach.py
--allow-created tests/test_dependency_direction.py

4 unapplied is unchanged and correct: unapplied counts a declared-edit ROW whose arrived bytes equal the carve blob entirely, and cli_gate.py already had eleven applied rewrites, so it was in the 81 … within their lines bucket before this change and stays there. No row was edited outside its declared lines, so there is no manifest question for Brett here.

Six --replica-at flags as leg 3 landed them (route_extension, subcommand_extension, conftest, hermeticity, session_fixtures, staging_shapes).

6. § 4.1's box, clause by clause — it cannot tick after this PR

Held to the tick standard of #897 → 021c3d36: a box ticks only where its own text is fully met by cited, landed evidence verified live, and a partly-met box stays open with the failing clause named.

clause of the box state evidence
"Carve openXdox's ~10.9K into openXdox-code per design § D3: the adapter implementation and projection mechanism, the gate-and-commission loop, and doxbench_scope" MET (at leg 3, unchanged here) all 13 § D3 modules row-placed, 11,823 lines; arrival verifier reproduces live above
"The 23 outbound doc_health imports" — are HERE and are a declared surface MET by this PR 13 statements over 8 modules under src/ (25 over 15 files with the carved tests/), enumerated and pinned; a new reach now fails validate. The box's "23" is design § D3's whole-package figure and is not exactly measurable as written — an arithmetic note, not a defect
"… become the adapter's IMPLEMENTATION SURFACE here" — i.e. the surface runs NOT MET 12 of 18 modules still raise ModuleNotFoundError: No module named 'doc_health'. Unchanged by this PR and not its to change: doc_health is openxFactory's corpus machinery, not vendored, not on PyPI, and this leg's own pyproject.toml records it as "a BUILD-arc cross-column reach, not a package on PyPI, and not this PR's to resolve"
the reality check's second, independent ground — design.md:243, "What must not survive is the direction" — openXdox side MET by this PR 1 → 0 wrong-direction lines under src/; three strict tests, each perturbation-proved
the same clause — openDox side NOT MET 13 import-time + 19 deferred back-imports remain at opensoft/openDox-code 8e9ffa62. Not this repository's to write

So: § 4.1 stays OPEN after this PR, and the two failing clauses are named above. What remains owed, both elsewhere:

  1. At opensoft/openDox-code — remove the 13 import-time back-imports (cli.py ×5, serve.py ×5, serve_workbench.py, branch_session.py, workbench.py) through the § 2.4 extension points, then the 19 deferred. This leg already supplies its half of those seams: serve_gate.routes() and serve_projection.routes() return route_extension.RouteBinding tuples and cli_gate.GateSubcommands.register() matches subcommand_extension.MEMBERS. Each slice lowers the ratchet in this file in the same act.
  2. Reachability of doc_health at this leg — BUILD arc § 3.5/3.6, which the ruling itself sequences after § 4.1 ("the conforming readers at openDox-code and openXdox-code (so § 3.7 can tick) after § 4.1").

A third item is a live blocker for both and is named in the reality check rather than here: profile_openxfactory exists nowhere in the carved estate, so openDox's serve.py:1376 / cli.py:914 composition point still dangles. That is § 4.3's box.

7. Fix round 1 — five review findings, all taken (3e8ca604)

All five were valid; the replies on each thread carry the detail and the proof.

  1. The seam had no runtime coverage — five tests added (import without the consumer; first access refuses naming the layering; resolution forwards to the real module object and caches; a broken consumer is re-raised; cli_gate binds the seam with both call sites unchanged).
  2. except ImportError was too wide — a candidate that EXISTS and raises was swallowed and fell through to the bare human_seen spelling. Now only ModuleNotFoundError whose name is the candidate or a package on its dotted path means "not here"; anything else re-raises.
  3. A class body runs at import time and the walker called it deferred, so a top-level class X: from openxdox import y would have bypassed both the strict check and the ratchet. Only function bodies defer now. Re-measured with the corrected definition, every census in this pull request is unchanged (13/19, 8/5, 17/13, 0), so no number above moved.
  4. The per-module ratchet table was dead data — only its keys were read, so a compensating fall-and-rise passed. The whole table is compared now and the totals derive from it; the perturbation in § 4 proves it.
  5. >= 20 was an incidental census, not the invariant — replaced by "some module consumes opendox, and each of the three § 2.4 contribution surfaces still does", which is § 4.3's no-fork rule stated as a test.

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

8. Findings recorded, not fixed

  • jsonschema is an undeclared third-party dependency of this leg — reached at src/openxdox/gate_console.py:563 (deferred), and also at scripts/validate-ideation-dashboard-contracts.py:107 and tests/test_doxchat_model_intake.py:1505. pyproject.toml's dependency derivation collected "every Import/ImportFrom in the module body and in module-level if/try/with blocks", so a reach inside a function body was out of its scope by construction. Declared in the new suite's allowlist with the reason, because adding a dependency is not a direction fix.
  • Four ideation_dashboard reaches survive under tests/, all deferred, none in src/: tests/test_gate_console.py:870 and :1810 are declared import rewrites lines that cannot be applied under the U+2028 line-numbering divergence recorded at leg 3 (RULED Q-L8 (c) is the remedy and openxFactory is not this lane's to write); tests/hermeticity.py:479-480 sit on a replica row that declares no lines. The carved suites do not run under validate (RULED Q-L8 (b′)), so none is reachable from CI. Scoped out of the new suite deliberately, and the suite says so.
  • The arrival verifier walks the filesystem, not the index, so a stray __pycache__/ from a local pytest run refuses arrival-undeclared-file. Clean the tree before running it.

9. Landing

Prior pull requests here landed as merge commits (#5 has three parents, #6 two) — that is the carve-leg convention, which exists to preserve filter-repo history. This is an ordinary post-carve change of four files in one hand-authored commit with no history to preserve, and the repository allows all three merge methods (allow_squash_merge, allow_merge_commit, allow_rebase_merge all true). Either is correct; the lane's gate lands it, and this author does not.

Nothing in openxFactory is touched by this pull request: no manifest, no pin, no gitlink, no openspec/changes/.

🤖 Generated with Claude Code

…ox side

`split-opendox-two-layer-product` § 4.1's second clause is held to
`design.md`:243 — "What must not survive is the direction, not the calls."
Measured at `main` `59600412`, this leg carried exactly ONE wrong-direction
edge, and it was an unapplied declared edit:

    src/openxdox/cli_gate.py:49
      from ideation_dashboard import human_seen as human_seen_mod

`human_seen` is a `not_moved / stays_openxfactory_adapter` row under RULING
DQ-1 — openxFactory's own cross-reference candidate register, present at
NEITHER carve destination — so the carve's `import rewrites` class had nothing
lawful to rewrite line 49 to and left the PRE-CARVE package name standing.
openxFactory is this leg's CONSUMER (§ 5.1, RULING F), so that import is the
pin chain running backwards, and it made `import openxdox.cli_gate` raise
`ModuleNotFoundError` for a second, independent reason.

Line 49 is inside the row's own declared `import rewrites` range (lines 44-54,
74), so the rewrite is lawful at the arrival floor; the fix is one line.

  * `src/openxdox/consumer_reach.py` (CREATED, no manifest row — RULED OQ-C)
    makes the reach LATE, NAMED and REFUSABLE: a lazy module proxy that
    resolves on first attribute access and otherwise raises
    `ConsumerReachUnavailable` naming the layering. Deliberately narrow — it
    is not a facade, and it is not the design fix. Injection is BUILD-arc work
    (§ 3.5/3.6) and is named as owed rather than pretended away.
  * `src/openxdox/cli_gate.py:49` now reads `from openxdox.consumer_reach
    import human_seen as human_seen_mod`. The public name `human_seen_mod` is
    unchanged, so the two call sites (`:396`, `:417`, both inside
    `cmd_gate_lens_add_as_cluster` and both undeclared lines) are untouched.
  * `tests/test_dependency_direction.py` (CREATED) ASSERTS the direction: the
    pre-carve name is gone from `src/`, every cross-package reach out of `src/`
    is declared, the lawful openXdox→openDox edge is exercised, and § 4.1's own
    `doc_health` implementation surface is enumerated (13 statements over 8
    modules; 25 over 15 files counting the carved `tests/`).
  * The openDox→openXdox back-imports are at `opensoft/openDox-code`, which
    this leg consumes and does not write, so they are asserted as a RATCHET
    over a landed census: 13 import-time + 19 deferred over six modules at the
    pinned `8e9ffa62`, identical at the `ce53b489` openDox's assembly root
    pins. The 13 are the census RULED 5626260214 names. The ratchet refuses a
    rise AND an unrecorded fall, so the number in the tree stays true as the
    BUILD arc removes them.
  * `.github/workflows/validate.yml` runs the new suite beside
    `test_leg_shape.py`. It parses trees and imports no carved module, so it
    does NOT un-narrow RULED Q-L8 (b′).

`python -m pytest -q tests/test_leg_shape.py tests/test_dependency_direction.py
--noconftest` → 19 passed (12 before).

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 10, 2026 23:19
@sourcery-ai

sourcery-ai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR removes the remaining import-time openxFactory dependency from openXdox by introducing a late-bound, cached consumer reach, then adds CI-enforced AST shape checks that prevent new reverse dependencies and track existing openDox back-imports until the BUILD arc removes them.

Sequence diagram for late-bound consumer queue access

sequenceDiagram
    participant Caller
    participant cli_gate
    participant consumer_reach
    participant importlib
    participant human_seen

    Caller->>cli_gate: cmd_gate_lens_add_as_cluster()
    cli_gate->>consumer_reach: human_seen.HumanSeenSubmission
    consumer_reach->>consumer_reach: resolve()
    consumer_reach->>importlib: import_module()
    alt consumer module available
        importlib-->>consumer_reach: human_seen
        consumer_reach-->>cli_gate: HumanSeenSubmission
        cli_gate->>human_seen: submit pending_review
    else consumer module unavailable
        importlib-->>consumer_reach: ImportError
        consumer_reach-->>cli_gate: ConsumerReachUnavailable
    end
Loading

Flow diagram for dependency-direction validation

flowchart TD
    source[Source trees]
    ast[tests/test_dependency_direction.py]
    shape[AST dependency-direction assertions]
    pytest[pytest]
    ci[CI validate workflow]

    source --> ast
    ast --> shape
    shape --> pytest
    pytest --> ci
Loading

File-Level Changes

Change Details Files
Invert the openXdox-to-openxFactory dependency by replacing the module-level consumer import with a late-bound adapter seam.
  • Add a cached, attribute-forwarding resolver for the consumer-owned human_seen module.
  • Raise a layering-specific error when the consumer module is unavailable instead of failing during openxdox.cli_gate import.
  • Update the gate command to consume the new seam while preserving the existing call sites.
src/openxdox/cli_gate.py
src/openxdox/consumer_reach.py
Add AST-based dependency-direction validation and wire it into CI.
  • Reject pre-carve ideation_dashboard imports and undeclared import-time or deferred cross-package reaches.
  • Enumerate and lock the doc_health implementation surface and verify lawful openDox imports remain present.
  • Ratchet the pinned openDox→openXdox back-import census so counts cannot increase and future reductions must update the baseline.
  • Run the new shape test alongside the existing leg-shape test without enabling carved-module suites.
tests/test_dependency_direction.py
.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 marked this pull request as ready for review September 10, 2026 23:24

@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 hour and 36 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

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

Several moderate correctness and coverage issues remain unresolved.

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

Pull request overview

This PR inverts the openDox→openXdox dependency using lazy consumer resolution and adds dependency-direction validation.

Changes:

  • Adds lazy human_seen consumer access.
  • Removes the eager CLI consumer import.
  • Adds AST-based import and back-import checks.
  • Runs dependency validation in CI.
File summaries
File Review summary
tests/test_dependency_direction.py Moderate findings on deferred class imports and incomplete back-import comparisons; nit on the magic >= 20 threshold.
src/openxdox/consumer_reach.py Moderate findings on broad ImportError handling, missing runtime coverage, and unavailable-consumer errors escaping the command handler.
src/openxdox/cli_gate.py Uses the lazy consumer reach in place of the eager import.
.github/workflows/validate.yml Runs the new dependency-direction validation.
Review details

Suppressed comments (1)

src/openxdox/consumer_reach.py:102

  • The new lazy binding resolves at cmd_gate_lens_add_as_cluster line 396, before that command's existing try block at line 407. When the consumer is absent, ConsumerReachUnavailable therefore escapes the command handler as an unhandled traceback instead of following the established lens-add-as-cluster refused path. Move submission construction into the guarded block and handle this exception there.
        raise ConsumerReachUnavailable(
  • Files reviewed: 4/4 changed files
  • Comments generated: 5
  • 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/openxdox/consumer_reach.py Resolved
Comment thread src/openxdox/consumer_reach.py Resolved
Comment thread tests/test_dependency_direction.py Resolved
Comment thread tests/test_dependency_direction.py Resolved
Comment thread tests/test_dependency_direction.py Resolved
Five findings from the automated reviewer on PR #7, all valid, all taken.

  1. THE SEAM HAD NO RUNTIME COVERAGE. `test_dependency_direction.py` only
     parsed trees, so the replacement for the removed import could regress
     while CI stayed green. Five tests added: the seam imports with nothing of
     openxFactory present; first attribute access refuses and names the
     layering; given the consumer it forwards to the REAL module object and
     caches it; a broken consumer module is re-raised rather than swallowed;
     and `cli_gate` binds the seam with both call sites unchanged.
  2. `except ImportError` WAS TOO WIDE. A candidate that EXISTS but raises
     while executing — a missing dependency of its own, an internal import bug
     — was swallowed and resolution fell through to the bare `human_seen`
     spelling, which could be an unrelated top-level module, or to a
     `ConsumerReachUnavailable` blaming the layering for a bug inside
     openxFactory. Now only `ModuleNotFoundError` whose `name` IS the candidate
     or a package on its dotted path means "not here"; anything else re-raises.
  3. A CLASS BODY RUNS AT IMPORT TIME and the walker marked its imports
     deferred, so a top-level `class X: from openxdox import y` would have
     bypassed both the strict import-time check and the ratchet. Only a
     FUNCTION body defers now; a class nested in a function stays deferred
     because the flag is already false. Re-measured with the corrected
     definition, every census in this suite is unchanged — 13/19 back-imports
     over six openDox modules, 8/5 `doc_health` over eight, 17/13 `opendox`,
     0 `ideation_dashboard` — so no baseline moves with the fix.
  4. THE PER-MODULE TABLE WAS DEAD DATA. Only its KEYS fed the stray check
     while the two totals were kept by hand beside it, so a fall in one module
     paired with a rise in another passed and left the landed census false.
     The whole table is compared now, the totals DERIVE from it, and the
     refusal names the modules that moved and in which direction. Proved by
     perturbation: −1 import-time in `workbench.py` and +1 in
     `serve_project.py`, total unchanged at 13, now refuses
     `ROSE … ['opendox/serve_project.py: (0, 2) -> (1, 2)']`.
  5. `>= 20` WAS AN INCIDENTAL CENSUS, not the invariant. A lawful
     consolidation of repeated imports would have failed it. Replaced by the
     real statement: some module consumes `opendox`, AND each of the three
     § 2.4 contribution surfaces does — one that stops has forked the server,
     which is § 4.3's own prohibition.

`python -m pytest -q tests/test_leg_shape.py tests/test_dependency_direction.py
--noconftest` → 24 passed (19 before, 12 at main).

Arrival verifier re-run on the amended tree, phase B: OK, exit 0 — 92 rows
arrived, 9 digests verified, 81 declared-edit rows within their lines, 4
unapplied, 6 of 6 replicas, 99 files with none undeclared (2 created). Byte
for byte the line the previous commit produced; no carve row moved.

Refs opensoft/openXfactory#656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 10, 2026 23:29
@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

Unresolved moderate findings remain in error handling, fallback coverage, and AST import census.

Review details

Suppressed comments (5)

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

src/openxdox/cli_gate.py:49

  • human_seen_mod is now a lazy proxy, so the first access in cmd_gate_lens_add_as_cluster (the HumanSeenSubmission constructor) raises ConsumerReachUnavailable when openxFactory is absent. That access occurs before the command's try block, and the handler does not catch this exception, so the documented absent-consumer case produces an uncaught traceback instead of the normal lens-add-as-cluster refused return. Move the construction under the try and handle ConsumerReachUnavailable before evaluating the proxy's exception classes.

src/openxdox/consumer_reach.py:55

  • The human_seen bare-name fallback is a separate resolution path, but the runtime tests only cover a qualified ideation_dashboard.human_seen module, both candidates missing, and a qualified module failure. A regression that removes or breaks this fallback would remain green even though this path is explicitly documented as supported. Add a test with only the bare module available and assert that it resolves and remains cached.
_CANDIDATE_PREFIXES = ("ideation_dashboard.", "")

tests/test_dependency_direction.py:175

  • When this assertion fails, the message reads deferred cross-package reach(es) out of src/ nothing declares, which is grammatically incomplete and less actionable than the import-time diagnostic above. Use the same that this leg does not declare wording here.
        f"deferred cross-package reach(es) out of src/ nothing declares: "

tests/test_dependency_direction.py:1

  • The validation evidence in the PR description is stale relative to this file: it now defines 12 test functions (7 census/ratchet checks plus 5 seam checks), and the workflow combines those with 12 parametrized shape cases, so the command covers 24 tests rather than the documented 19. Please update the landing evidence so the reported green check matches the code being merged.
"""Asserts the DEPENDENCY DIRECTION this leg is held to.

tests/test_dependency_direction.py:104

  • This child-walk filters every list to ast.stmt, so it drops ast.ExceptHandler (and match_case) nodes. An import in a module-level except handler or case body therefore is never censused, even though that code runs during module import, allowing a future forbidden reach to bypass both direction checks. Recurse over all ast.AST children while retaining the function-body timing flag.
            for _field, value in ast.iter_fields(node):
                if isinstance(value, list):
                    walk([n for n in value if isinstance(n, ast.stmt)], deeper)
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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