Repository navigation
§ 4.1: invert the openDox→openXdox dependency direction (split-opendox, RULED 5626260214) - #7
Conversation
…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>
Reviewer's GuideThis 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 accesssequenceDiagram
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
Flow diagram for dependency-direction validationflowchart 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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
🟡 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_seenconsumer 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_clusterline 396, before that command's existingtryblock at line 407. When the consumer is absent,ConsumerReachUnavailabletherefore escapes the command handler as an unhandled traceback instead of following the establishedlens-add-as-cluster refusedpath. 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.
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>
|
There was a problem hiding this comment.
🔵 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_modis now a lazy proxy, so the first access incmd_gate_lens_add_as_cluster(theHumanSeenSubmissionconstructor) raisesConsumerReachUnavailablewhen openxFactory is absent. That access occurs before the command'stryblock, and the handler does not catch this exception, so the documented absent-consumer case produces an uncaught traceback instead of the normallens-add-as-cluster refusedreturn. Move the construction under thetryand handleConsumerReachUnavailablebefore evaluating the proxy's exception classes.
src/openxdox/consumer_reach.py:55
- The
human_seenbare-name fallback is a separate resolution path, but the runtime tests only cover a qualifiedideation_dashboard.human_seenmodule, 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 samethat this leg does not declarewording 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 dropsast.ExceptHandler(andmatch_case) nodes. An import in a module-levelexcepthandler orcasebody therefore is never censused, even though that code runs during module import, allowing a future forbidden reach to bypass both direction checks. Recurse over allast.ASTchildren 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



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 comment5626260214): "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 ofopensoft/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:opensoft/openDox-code@8e9ffa62)src/opendox/cli.pysrc/opendox/serve.pysrc/opendox/branch_session.pysrc/opendox/serve_workbench.pysrc/opendox/workbench.pysrc/opendox/serve_project.pyByte-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
main59600412by AST, counting an import as import-time when it runs onimport: the walk descends into module-levelif/try/withand 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.)src/opendoxdoc_healthyamljsonschemagate_console.py:563, absent frompyproject.tomlideation_dashboardsrc/openxdox/cli_gate.py:49So the wrong-direction count in this leg's
src/at livemainis 1, not 13.2. The one line, and why the carve left it
human_seenis anot_moved / stays_openxfactory_adapterrow 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 fromopenDox-code/src/opendox/and fromopenXdox-code/src/openxdox/). The carve'simport rewritesclass 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:47importsgate_console, which reachesdoc_healthat its line 63 — soimport openxdox.cli_gatefails ondoc_healthbefore reaching line 49, and the reality check's census attributedcli_gateto thedoc_healthcolumn. Unmasked with adoc_healthstub on the path:Line 49 is inside its row's own declared range. The manifest declares
scripts/ideation_dashboard/cli_gate.pymoved_with_declared_editwith{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 −2againstmain(both commits).src/openxdox/cli_gate.pyfrom openxdox.consumer_reach import human_seen as human_seen_mod. The public namehuman_seen_modis unchanged, so the two call sites (:396,:417— both insidecmd_gate_lens_add_as_cluster, both on undeclared lines) are untouched.src/openxdox/consumer_reach.pyideation_dashboard.human_seen/human_seenon first attribute access, and otherwise raisesConsumerReachUnavailablenaming the layering instead of a bareModuleNotFoundError.tests/test_dependency_direction.py.github/workflows/validate.ymltest_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.pyis 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:
from ideation_dashboard import human_seentosrc/openxdox/register.pyAssertionError: 1 import(s) under src/ still name the PRE-CARVE package 'ideation_dashboard': ['src/openxdox/register.py:33'](2 tests fail)import requests)AssertionError: import-time reach(es) out of src/ that this leg does not declare: ['src/openxdox/register.py:33 -> requests']doc_healthimport to a 9th moduleAssertionError: the doc_health implementation surface (§ 4.1's second clause) moved.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 …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 …workbench.py/ +1 inserve_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 closedWhy 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 resolvesopendoxto the pinned8e9ffa62— the reach § 4.1 needs and not something added to this tree):FLOOR PART 1, the arrival verifier, phase B, on this branch:
Against the line leg 3 landed on, every row figure is identical —
92 / 9 / 81 / 4 unapplied / 6 of 6— and the only movement is97 → 99 file(s)and0 → 2 created, which are exactly the two created files, each named on the command line:4 unappliedis unchanged and correct:unappliedcounts a declared-edit ROW whose arrived bytes equal the carve blob entirely, andcli_gate.pyalready had eleven applied rewrites, so it was in the81 … within their linesbucket 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-atflags 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.openXdox-codeper design § D3: the adapter implementation and projection mechanism, the gate-and-commission loop, anddoxbench_scope"doc_healthimports" — are HERE and are a declared surfacesrc/(25 over 15 files with the carvedtests/), enumerated and pinned; a new reach now failsvalidate. The box's "23" is design § D3's whole-package figure and is not exactly measurable as written — an arithmetic note, not a defectModuleNotFoundError: No module named 'doc_health'. Unchanged by this PR and not its to change:doc_healthis openxFactory's corpus machinery, not vendored, not on PyPI, and this leg's ownpyproject.tomlrecords it as "a BUILD-arc cross-column reach, not a package on PyPI, and not this PR's to resolve"design.md:243, "What must not survive is the direction" — openXdox sidesrc/; three strict tests, each perturbation-provedopensoft/openDox-code8e9ffa62. Not this repository's to writeSo: § 4.1 stays OPEN after this PR, and the two failing clauses are named above. What remains owed, both elsewhere:
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()andserve_projection.routes()returnroute_extension.RouteBindingtuples andcli_gate.GateSubcommands.register()matchessubcommand_extension.MEMBERS. Each slice lowers the ratchet in this file in the same act.doc_healthat 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_openxfactoryexists nowhere in the carved estate, so openDox'sserve.py:1376/cli.py:914composition 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.
cli_gatebinds the seam with both call sites unchanged).except ImportErrorwas too wide — a candidate that EXISTS and raises was swallowed and fell through to the barehuman_seenspelling. Now onlyModuleNotFoundErrorwhosenameis the candidate or a package on its dotted path means "not here"; anything else re-raises.class X: from openxdox import ywould 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.>= 20was an incidental census, not the invariant — replaced by "some module consumesopendox, 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
jsonschemais an undeclared third-party dependency of this leg — reached atsrc/openxdox/gate_console.py:563(deferred), and also atscripts/validate-ideation-dashboard-contracts.py:107andtests/test_doxchat_model_intake.py:1505.pyproject.toml's dependency derivation collected "everyImport/ImportFromin the module body and in module-levelif/try/withblocks", 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.ideation_dashboardreaches survive undertests/, all deferred, none insrc/:tests/test_gate_console.py:870and:1810are declaredimport rewriteslines 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-480sit on a replica row that declares no lines. The carved suites do not run undervalidate(RULED Q-L8 (b′)), so none is reachable from CI. Scoped out of the new suite deliberately, and the suite says so.__pycache__/from a localpytestrun refusesarrival-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-repohistory. 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_mergeall 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