Skip to content

Split cli.py by column behind the subcommand seam (§ 2.4, PR 4 of 4) - #742

Merged
brettheap merged 10 commits into
mainfrom
feat/split-2-4-pr4-cli-split
Sep 7, 2026
Merged

brettheap merged 10 commits into
mainfrom
feat/split-2-4-pr4-cli-split

Conversation

@brettheap

@brettheap brettheap commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

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

This realizes split-opendox-two-layer-product § 2.4 (PR 4 of 4): cli.py's verbs move into the column they belong to, and the openXdox column reaches the parser through PR #736's subcommand extension point instead of a call in build_parser. Zero behaviour change — a byte-identical --help tree for all 31 entry points, every existing test passing unmodified, and (as of the fix round below) both of the invocations cli.py documents proved byte-identical to main on a refusal path and a success path. Refs #656.

#736 landed as a83eb93; this PR was caught up by merging main and now targets main directly.

What moved

cli.py goes 2,487 → 996 lines: the shared spine, the parser, and the entrypoint (996 as of the third fix round's relative-import note; 948 at the branch tip this PR started from, before any fix round's comments grew it).

symbol from to
19 cmd_gate_* verbs (demote … cleanup-abandoned-branch) cli.py:535-1640 cli_gate.py — openXdox, contributed
the gate subparser tree (_add_gate_subcommands + 8 helpers) cli.py:1996-2443 cli_gate.py — openXdox, contributed
GateSubcommands (new) — the SubcommandExtension conformer — cli_gate.py
cmd_generate, cmd_create, cmd_edit cli.py:319-482 cli_project.py — openDox, fixed core
_binding_store … _add_model_binding_parser (10 defs + banner) cli.py:1678-1914 cli_model_binding.py — openDox, fixed core
_add_model_binding_parser(sub) call _add_gate_subcommands's first line build_parser, same ordinal
SUBCOMMAND_EXTENSIONS (new) — the composition point — profile_openxfactory.py

build_parser's tail is now _add_model_binding_parser(sub) → register_all(profile_openxfactory.SUBCOMMAND_EXTENSIONS, sub) → register_all(subcommand_extensions, sub), at exactly the position _add_gate_subcommands(sub) occupied. Eight module imports that only the moved code used were dropped from cli.py.

Note on the cli_gate.py row: it also carries cli.py's one direct doc_health import (from doc_health import derive_possibles as dp, function-local inside cmd_gate_derive_possibles) — moved file, not target, same as every other symbol in the row. See "Decisions for Brett" item 4 for the carve-manifest consequence.

Design decisions taken

  1. The in-tree profile registers inside build_parser, not from main(). Add the route and subcommand extension points behind serve.py and cli.py (split § 2.4, PR 1 of 4: scaffolding, zero behavior change) #736 landed three assertions that pin the default parser: top_level_commands(build_parser()) == (…, "model-binding", "gate"), the same tuple plus a probe verb, and inspect.signature(main).parameters["subcommand_extensions"].default == (). A main()-passed profile contradicts all three, and the 896-line help golden on top of that. The slice spec's own escape applies — "the composition point registers the gate extension at the original point in the sequence" — so gate keeps its ordinal, still goes through SubcommandExtension.register (via register_all, which does the isinstance refusal), both kwarg defaults stay (), and no landed test or golden moves. No golden was regenerated. The line naming the profile is the one line the § 3 carve deletes rather than moves.

  2. _add_model_binding_parser moves up into build_parser. It was the opening line of _add_gate_subcommands — an accident of growth, not a coupling. Leaving it there would drag openDox's provider column into openXdox's contribution; calling it one line earlier keeps model-binding in the core at its exact position in the parser.

  3. The column modules reach the core through _core(), resolved at call time. This is the load-bearing correctness argument, because getting it wrong is green: a moved verb written as from ideation_dashboard.cli import _notebook_port freezes the reference at import and silently stops honouring the thirteen monkeypatch.setattr(cli_mod, …) sites the suite injects fakes through — no test fails and the fakes stop being reached. A mutation check confirms the eager form is now a hard ImportError in either import order (cli.py imports the profile before defining the spine), and test_no_column_module_imports_the_core_eagerly pins the rule so it stays that way. The accessor resolves the core RELATIVELY — from . import cli, not from ideation_dashboard import cli — for the reason the third fix round gives: an absolute name binds ONE package spelling's core no matter which spelling imported the column.

  4. The authentication rail and the session spine stay in cli.py. _gate_actor, _human_gate, _lens_gate, _session_identity_gate, console_presence, cli_provenance, _session_registry, _session_repository_key, _notebook_port, _pull_request_port, _unwind_cli_session, _gate_snapshot. Not tidiness: those are the shared controls every verb passes through, and a contributed verb carrying its own copy could drift into a second, weaker spelling of the same gate. It is the command line's analogue of the route point's "no privileged route" — cli_gate.py cannot reach a gate any other way because it defines none.

  5. cmd_generate_and_open deliberately stays in cli.py. The memo files it under cli_project.py; it is in fact the CLI's assembly point — its body is one serve_mod.build_server(...) call declaring the notebook adapter, the model-provider factory and the retrieval backend, and § 2.4 PR 3 will declare route_extensions at that same call. The repository already treats it that way: three landed tests read the entrypoint's own source to check those declarations (test_session_notebook.py:885, test_doxbench_knowledge_service.py:93 and :168, whose calls >= 2 guard counts build_server call sites across serve.py and cli.py — serve.py has exactly one). Moving it costs three test repoints for no structural gain, and serve.py's own entrypoint stays put for the same reason (memo § 4). See "Decisions for Brett".

  6. New tests instead of edited ones, for six sweeps that would have gone quiet. test_trust_gaps.py's closed-world "every HumanGate construction authenticates first" scan reads cli.py; six of its nine constructions are now in cli_gate.py, so it keeps passing over a smaller world. Same for the five bypass-flag sweeps (test_create_document_cli.py:178, test_session_verbs.py:775, test_session_verbs.py:1255, test_lens_gate_cli.py:126, test_readiness_gate.py:228), whose subject — the gate parser tree, gate propose included — left the file. Rather than touch them, test_cli_column_split.py re-states all six rules over CLI_SURFACE — the core, the three columns and the composition point — with non-vacuity floors, so no module of the CLI is swept by neither reader and the mirror cannot itself go quiet. (The first round mirrored the gate rule over cli_gate.py alone and its BYPASS_FLAGS union missed the two readiness-gate sweeps' --skip-readiness; the second fix round widened both, see below.) Re-export completeness is asserted by walking the parser rather than re-listing names.

  7. The re-export block sits at the bottom of cli.py. build_parser sets func=cmd_create and the suite asserts args.func is cli_mod.cmd_gate_edit_document; a re-export keeps those identities exact — the same function object under both names — so the move is invisible to every caller.

Proof

python3 -m pytest -q tests/ideation-dashboard tests/doc-health
  → 1 failed, 6565 passed, 31 skipped in 781.41s   (at the fix round, 4f333f3e)
    the one failure is the known environmental
    test_snapshot.py::test_find_validator_locates_pinned_checkout
OPENSPEC_TELEMETRY=0 openspec validate --all --strict
  → 96 passed, 1 failed — the known disposition-codexfactory-declared-renames artifact

Counts. 6,565 passed, of which 22 are this PR's new file; the other 6,543 are pre-existing and not one landed test file was edited (git diff --stat touches scripts/ plus one new test file only). Post-rebase onto the base's fix round, the 11 CLI-bearing suites re-ran green (225 passed, 4 skipped).

Goldens: byte-identical, none regenerated. tests/ideation-dashboard/fixtures/cli-help-tree.golden.txt (896 lines, 31 sections) is untouched and test_the_help_text_of_every_entry_point_is_unchanged passes.

The moves are verbatim. A checker reconstructed each moved range from git show HEAD:…/cli.py and confirmed every moved line is present character-for-character in its new module, modulo the _core(). prefix and the continuation-indent it shifts (9 multi-line calls, re-aligned). No function body was rewritten.

Mutation checks run (each reverted).

mutation caught by
register the gate contribution before model-binding 5 tests, incl. the help golden and test_extensions_register_in_declaration_order
drop cmd_gate_edit_document from the re-export block the new walk test and landed test_session_verbs.py
replace _core()._human_gate with an eager top-of-module import hard ImportError at collection (circular)
the same, placed at the bottom of cli_gate.py — the variant that would otherwise be green hard ImportError; the landed CLI suites error at collection too

Fix round (4f333f3)

Three verifier lenses and Copilot; every reproduced finding is fixed here.

HIGH — two core modules under the documented invocations. Run as a script (python3 scripts/ideation_dashboard/cli.py …) or with -m, cli.py loads as __main__, while a moved verb's _core() imports ideation_dashboard.cli — a second module object, with its own RepoRootRefused and GeneratedAtRefused. The except clauses in one copy's main cannot catch the other copy's exception, so both refusals degraded from the deliberate operator-facing message on stderr to an unhandled traceback. No in-process test could see it: main([...]) called from the suite has only ever one module object, which is why the suite was green.

Fixed at the entrypoint, not at the symptom: the __main__ bootstrap now dispatches into the package's own copy of the module (from ideation_dashboard import cli as _package_cli; sys.exit(_package_cli.main())), so exactly one module object ever runs anything, under each of cli.py's two DOCUMENTED invocations (script and -m) — one set of exception classes, one set of patchable names, in both of them. The alternative (a cli_shared.py holding the two exception classes) fixes the classes and leaves the two module objects alive; this leaves one, and it changes no signature, no import graph and no help text.

Residual gap at this round — CLOSED in the third fix round below. scripts/__init__.py exists, so every package under scripts/ is importable both as ideation_dashboard.x and as scripts.ideation_dashboard.x (tests/import_scan.py's header states this in writing, and it is live in-tree for scripts.hermes_runtime_validation and scripts.intent_compliance). The bootstrap above fixes __main__, not that third spelling: a caller who did from scripts.ideation_dashboard import cli; cli.main([...]) would get a module whose verbs are the package copy's (re-export keeps the function objects identical) but whose except RepoRootRefused / except GeneratedAtRefused name its OWN classes, distinct from the package copy's — the same asymmetry the HIGH describes, one spelling over, because _core() always resolves ideation_dashboard.cli regardless of which spelling called into it. Nothing in this repo imported cli.py that way, so the residue fired under neither documented invocation nor any in-tree caller — but it was a reproduced regression from base, and the third fix round below closes it at the root rather than disclosing it again.

Proof, base vs head. Nine invocations — four help paths, the --repo-root refusal, the --generated-at refusal, an unauthenticated-actor refusal, a success (model-binding list), an unknown verb — run in both modes against origin/main and against this head, capturing stdout, stderr and exit code. After normalising worktree paths the two transcripts are byte-identical, and the head transcript contains no traceback. Six subprocess tests now hold that line in CI, and test_the_script_bootstrap_runs_the_packages_copy_of_this_module pins the shape structurally so a tidy-up back to sys.exit(main()) cannot pass.

MEDIUM — the closed-world gate sweep, re-closed. "Every function that builds a HumanGate authenticates its actor first" was closed over the whole CLI because the whole CLI was cli.py. The first round's mirror followed the verbs to cli_gate.py alone, so cli_project.py and cli_model_binding.py were swept by neither reader — no live gap (they build zero gates) but no structural pin either. Both sweeps now read CLI_SURFACE. This is a widening inside this PR's own new file; no landed test is repointed, and test_trust_gaps.py is untouched (its cli.py world is a strict subset of the one now swept).

Mutation checks added (each reverted).

mutation before after
revert the bootstrap to sys.exit(main()) green 5 tests red (both refusals × both modes, plus the structural pin)
unauthenticated HumanGate(...) appended to cli_project.py green (33 passed) red
the same in cli_model_binding.py green (33 passed) red
literal add_argument("--content", …) on the moved edit-document verb green (only the help golden noticed) red in both flag sweeps
computed add_argument("--" + "for" + "ce", …) invisible to any source sweep red in the parser-walk sweep only
from ideation_dashboard import cli at the top of cli_gate.py green (all 13 passed) red
rename gsub → gate_verbs (behaviour-preserving) would have gone red green, as it should be

Copilot, all three taken and resolved. BYPASS_FLAGS now spells --content without the trailing space and matches on a boundary (--content-file still passes); the eager-import scan knows four spellings across both package paths, with a table test putting each to the predicate; the flag sweep's non-vacuity floor is AST-structural (add_parser calls, the Constant("gate") declaration, the add_subparsers call) instead of quote- and variable-name-sensitive.

Also added: test_the_assembled_parser_declares_no_bypass_flag, which reads option strings off the assembled parser rather than the source. It catches what no source sweep can — a flag spelled by computation, or one a contributed extension adds — and the source sweep catches what it cannot (a flag written down anywhere, declared or not). Neither subsumes the other.

Not fixed, and why. The four already-landed #736 commits still listed on this branch, and the catch-up merge message's misattribution of the build_parser docstring reword (it came from this branch's own 3790c50, not from main), both want a branch rewrite — a reserved act. They are merge-time wording: hand-write the squash message rather than accepting GitHub's default concatenation.

Second fix round

Three more verifier lenses, all findings disclosed above where they touch design decision 6 and the HIGH's residual-gap paragraph; the two code changes:

MEDIUM — the bypass-flag mirror missed two of its five landed subjects. Design decision 6 (first fix round) named only test_create_document_cli.py and test_session_verbs.py as the landed sweeps BYPASS_FLAGS mirrors. Two more read cli.py's source the same way and went quiet the same way when the gate parser tree moved: test_lens_gate_cli.py:126 and test_readiness_gate.py:228, both forbidding ("--force", "--override", "--skip-readiness", "--no-gate"). --skip-readiness — the flag naming the very verb, gate propose, that moved — was the one member of that union BYPASS_FLAGS omitted, so nothing on the CLI surface swept it. --skip-readiness is now in BYPASS_FLAGS; design decision 6 above and the new file's own docstring/comments now name all five sweeps. Mutation, reverted: prop.add_argument("--skip-readiness", action="store_true") added to the moved gate propose parser in cli_gate.py was green everywhere at the previous fix round's head (145 passed, 4 skipped) and is now caught by both test_no_verb_on_this_command_line_offers_a_bypass_flag and test_the_assembled_parser_declares_no_bypass_flag.

MEDIUM — the HIGH's fix claim overstated, for a spelling no caller uses. The previous round's fix note said the bootstrap change means "exactly one module object ever runs anything… in every invocation." scripts/__init__.py makes scripts.ideation_dashboard.cli a third importable spelling of this file, and the bootstrap (which only fires for __main__) does not close it: that spelling's own main() would still miss a refusal raised through the package copy's RepoRootRefused/GeneratedAtRefused. Narrowed at this round to what was actually delivered — one module object under cli.py's two documented invocations — under the HIGH section above. The third fix round below closes the gap itself, so the full claim now holds under every importable spelling and the narrowed wording is history rather than a standing exception.

WORDING, no code change (disclosed above). design decision 6's stale sweep count; the "What moved" line count (948 → 966, this round's own bootstrap-comment growth); the "Not in this PR" bullet on NO_IMPLICIT_PUSH_MODULES, whose stated reason (FORBIDDEN_PUSH_TOKENS would fail) does not hold literally — checked, none of the three tokens appears in any of the five CLI modules — though the conclusion (cli.py was never a candidate) is unchanged.

Still open, unfixable without a branch rewrite (re-confirmed, unchanged from the first fix round): the four already-landed #736 commits on this branch's commit list, and 6ab1b6e's missing trailers, and the ca905fa catch-up-merge message's misattribution of the build_parser reword (confirmed again: git diff 2b2d32e3 a83eb93a -- scripts/ideation_dashboard/cli.py is empty; the reword is this branch's own 3790c50). All three: hand-write the squash message at merge time rather than accept GitHub's default concatenation.

python3 -m pytest -q tests/ideation-dashboard tests/doc-health
  → 1 failed, 6565 passed, 31 skipped in 1082.97s   (second fix round; unchanged
    from the first round's count — no test function was added, only
    `BYPASS_FLAGS` and docstrings/comments; the one failure is the known
    environmental test_snapshot.py::test_find_validator_locates_pinned_checkout)

Third fix round

One MEDIUM, closed at the root rather than disclosed a third time.

MEDIUM — the divergence class survived under the second importable spelling. scripts/__init__.py makes scripts.ideation_dashboard.cli a real second name for this file, and a second module object at runtime. The first round's bootstrap closed the __main__ copy; it could not close this one, because the columns named the core absolutely (_core() → from ideation_dashboard import cli) and cli.py re-exported them absolutely in return. A caller who did from scripts.ideation_dashboard import cli; cli.main([…]) therefore ran the OTHER core's verbs, and a refusal raised inside a moved verb was an instance of a RepoRootRefused its own except clause did not name. Reproduced at the previous head as UNCAUGHT ideation_dashboard.cli.RepoRootRefused, where origin/main returns 1 and prints the refusal.

Fixed by making the import graph the split created coherent PER SPELLING, which is the root of it rather than a symptom:

  • _core() in cli_gate.py and cli_project.py is now from . import cli — resolved against the package the column itself was imported under, and still at CALL time, so all thirteen monkeypatch.setattr(cli_mod, …) sites keep reaching the moved bodies (proven by the two live-patch tests, unchanged).
  • cli.py names the four modules the split created relatively (from . import profile_openxfactory; from .cli_gate import …, .cli_model_binding, .cli_project). They are the only relative imports in the file, and the note above them says why; every other import is untouched, because the modules the split did NOT create were spelling-bound before it and are unchanged by it.
  • profile_openxfactory.py contributes from . import cli_gate, so the profile registers the column belonging to the same spelling as the core assembling the parser.
  • The __main__ bootstrap moves to the top of cli.py, above the imports, and hands over before the body runs. Run as a script there is no package at all (__package__ is empty), so that copy cannot name its siblings relatively; handing over first means the body only ever executes as a package module, under whichever spelling imported it. Still ONE __main__ block, still importing the package's copy and calling ITS main — test_the_script_bootstrap_runs_the_packages_copy_of_this_module passes unmodified.

Proven, not asserted. Two new parametrized tests reach the CLI as a LIBRARY caller in a FRESH interpreter per spelling (python3 -c, both roots on PYTHONPATH), because in-process sys.modules already answers for a decision made before the test ran:

  • test_a_library_caller_gets_the_columns_of_its_own_core — cli_gate._core() is core, cli_project._core() is core, profile.cli_gate is gate, every verb the assembled parser dispatches to is the same object on that core, and all 28+ of them come from that spelling's own four modules.
  • test_a_refusal_is_reported_under_every_importable_spelling — core.main([…]) on the --repo-root refusal returns 1, prints the operator-facing message, raises nothing, and leaves no snapshot.
  • test_the_split_modules_name_each_other_relatively — the structural pin: no module the split created may name another absolutely, with the __main__ bootstrap exempted by AST (it has no package to be relative to) and a non-vacuity check that the four relative imports really are there.

Mutation checks (each applied, then reverted).

mutation caught by
_core() in cli_project.py back to from ideation_dashboard import cli 3 red — both scripts.ideation_dashboard probes and the structural pin; the ideation_dashboard probes stay green, which is exactly why the defect hid
cli.py re-exporting cli_gate absolutely 2 — the scripts. library-caller probe and the structural pin (the refusal probe stays green: its path runs through cli_project, which this mutation leaves relative)
profile_openxfactory.py importing cli_gate absolutely the same 2
the bootstrap back to sys.exit(main()) at the foot of the file 6 red (both refusals × both modes, script-mode reachability of a contributed verb, and the structural pin) — one more than the previous round: with relative imports the wrong bootstrap no longer degrades quietly, it refuses to start as a script

Base-vs-head parity, re-run for the new entrypoint. 12 invocations × {script, -m} × {origin/main, this head} — five help paths, no-args, an unknown verb, the --repo-root and --generated-at refusals, an unauthenticated-actor refusal, an area-confinement refusal, model-binding list — 0 differing of 24 transcripts, 0 tracebacks on either side. The library form matches base as well: main([…]) on the refusal returns 1 under BOTH spellings at origin/main and at this head, where the previous head raised under one of them.

Startup cost re-measured (the second round's LOW). That round's bootstrap ran cli.py's body twice in script mode, measured at +0.10s (~32%). Handing over before the body removes the second execution: min-of-12 --help runs, origin/main 0.346s vs this head 0.367s (+0.02s, ~6%; medians 0.371s vs 0.376s).

Re-checked at this head, both previous MEDIUMs still closed. BYPASS_FLAGS carries the union of all five landed bypass sweeps across four files — test_create_document_cli.py:178, test_session_verbs.py:775 and :1255, test_lens_gate_cli.py:126, test_readiness_gate.py:228 — --skip-readiness included, each citation re-read at head; the mirror's docstring, its BYPASS_FLAGS comment, test_no_verb_on_this_command_line_offers_a_bypass_flag's docstring and design decision 6 all name the five. Both surface-wide sweeps read CLI_SURFACE, so no module of the CLI is swept by neither reader.

python3 -m pytest -q tests/ideation-dashboard tests/doc-health
  → 1 failed, 6570 passed, 31 skipped in 953.82s   (third fix round, a54791c8)
    6,570 = 6,565 + the five tests this round adds
    the one failure is the known environmental
    test_snapshot.py::test_find_validator_locates_pinned_checkout
OPENSPEC_TELEMETRY=0 openspec validate --all --strict
  → 96 passed, 1 failed — the known disposition-codexfactory-declared-renames artifact

Fourth fix round

One MEDIUM, one LOW disclosure, and the WORDING corrections below — a Sonnet fix round on the third round's two gating-lens findings.

MEDIUM — the bypass-flag mirror was narrower than the MATCHING the five landed sweeps use, not just narrower than their union. All five landed sweeps (test_create_document_cli.py:181, test_session_verbs.py:778 and :1258, test_lens_gate_cli.py:128, test_readiness_gate.py:230) are a plain substring check (flag not in source). declares_flag's word-boundary match (re.search(re.escape(flag) + r"(?![-\w])", source)), added in the first fix round to keep --content from catching --content-file, was applied to all seventeen flags in both readers — so a prefixed bypass spelling (--force-all, --overwrite-existing, --no-gate-check) written into any column module answered to nothing, while the identical string in the pre-split cli.py would have reddened three landed sweeps.

Fixed by narrowing the word-boundary form back to its one reason for existing: declares_flag now runs for --content only, in both the source sweep (test_no_verb_on_this_command_line_offers_a_bypass_flag) and the parser-walk sweep (test_the_assembled_parser_declares_no_bypass_flag); the other sixteen flags use the landed plain-substring rule, unchanged, in both readers. Verified safe first: a plain-substring sweep over all five CLI modules and over the assembled 312-option parser tree hits only --content-file (via --content) — no other flag's substring collides with a legitimate option anywhere on the surface. BYPASS_FLAGS's comment, declares_flag's docstring, and both sweep functions' docstrings now say the mirror carries the landed sweeps' MATCHING as well as their union, with --content as the one named carve-out.

Mutation, applied then reverted: a single sub.add_argument("--force-all", action="store_true", ...) added to the moved gate parser tree in cli_gate.py — a prefixed bypass spelling no member of the previous BYPASS_FLAGS set matches exactly — reddened both sweeps (the source sweep on --force's substring; the parser-walk sweep on all 19 gate verbs, since --force-all is declared identity-wide via _add_gate_identity_args). Reverted; test_cli_column_split.py is green again (27 passed).

LOW — cli_gate.py:251's doc_health import, disclosed. from doc_health import derive_possibles as dp (function-local, inside cmd_gate_derive_possibles) was cli.py's only direct doc_health import at base; the split moved it into cli_gate.py — the openXdox column, where doc_health will not exist at the carve. No behaviour change, no gating loss, no re-plumbing (out of this PR's scope) — added as a "What moved" row note and a new "Decisions for Brett" item 4 for § 3.1's carve manifest. Searched tests/ for a doc_health-import inventory keyed to specific CLI/serve modules that this move would make stale (grep -rn "from doc_health import\|import doc_health" tests/, ~150 hits); none scans cli.py/cli_gate.py by name or asserts a location-specific count — the closest is output_boundary.py's own docstring ("ideation_dashboard imports doc_health in twenty-three places"), a package-wide total the move does not change. Nothing to widen; the disclosure above is the whole remedy.

WORDING corrections, verified independently and NOT taken on the lens's own suggested numbers where those were themselves imprecise.

  • "What moved" table: _binding_store … _add_model_binding_parser is 10 defs + banner, not 11 (AST count at both base cli.py:1695-1914 and head cli_model_binding.py). The cited range cli.py:1678-1914 was already correct as measured independently (banner starts at line 1678, _add_model_binding_parser ends at line 1914) — a suggested correction to "1695-1907" would itself have been wrong on both ends, so the range is unchanged and only the count is fixed.
  • Third fix round's mutation table: "cli.py re-exporting cli_gate absolutely" and "profile_openxfactory.py importing cli_gate absolutely" each catch 2 tests, not "the same 3" as the cli_project.py row above them — reproduced: test_a_refusal_is_reported_under_every_importable_spelling stays green for both, because the --repo-root refusal path runs through cli_project, which these two mutations leave relative; only the scripts.-spelling library-caller probe and the structural pin go red. (The cli_project.py mutation genuinely catches 3, unchanged — its own refusal path is the one these two leave untouched.)
  • "Decisions for Brett" item 4 (CI): replaced the stale "checks never ran at ca905fae" paragraph — all nine required checks are now green at a54791c8 itself, verified via the commit's check-runs.
python3 -m pytest -q tests/ideation-dashboard tests/doc-health
  → 1 failed, 6570 passed, 31 skipped in 924.76s   (fourth fix round)
    6,570 unchanged from the third round — this round edits test LOGIC, not
    test COUNT, in the one file it touches; the one failure is the known
    environmental test_snapshot.py::test_find_validator_locates_pinned_checkout
OPENSPEC_TELEMETRY=0 openspec validate --all --strict
  → 96 passed, 1 failed — the known disposition-codexfactory-declared-renames artifact

Not in this PR

  • serve.py's split (§ 2.4 PRs 2 and 3) and ROUTE_EXTENSIONS on profile_openxfactory.py — the module is deliberately minimal and additive so PR 3 adds one constant beside SUBCOMMAND_EXTENSIONS.
  • conftest.py's NO_IMPLICIT_PUSH_MODULES is untouched, correctly: the list scopes the implicit-push sweep to modules where a turn, a Save, a compaction or a scheduled task lives (serve.py, the doxbench_* bridge/thread modules, nightly_lane.py); a CLI verb is an explicit human act, so cli.py has never been in that world and the split does not put it there. (An earlier draft of this bullet said adding cli_gate.py to the list would fail test_doxbench_share.py:273 / test_doxbench_thread_wiring.py:948 because those tests self-assert FORBIDDEN_PUSH_TOKENS — checked, and none of .push(, open_or_update(, or git push appears literally in any of the five CLI modules, so that specific claim was wrong; the conclusion above is the real reason cli.py was never a candidate.) The memo's widening requirement belongs to PR 3's serve_* modules.
  • No openspec/, contracts/, docs/, README or tasks.md edit — bookkeeping is the orchestrator's.

Decisions for Brett

  1. cmd_generate_and_open's column (design decision 5). I left the CLI's assembly point in cli.py rather than moving it to cli_project.py as the memo's table says. If you want it moved anyway, the cost is three disclosed one-line test repoints — same assertions, pointed at the file the entrypoint now lives in — not a weakened or regenerated anything. Say the word and I will do it in a fix round.
  2. Scout drift worth recording for § 3.1's manifest: the memo says 17 cmd_gate_* functions; there are 19 (PR Add the route and subcommand extension points behind serve.py and cli.py (split § 2.4, PR 1 of 4: scaffolding, zero behavior change) #736's own test_extension_point_parity.py already says "nineteen").
  3. The core→column import edge, for § 3.1's manifest. build_parser names the in-tree profile, so cli.py → profile_openxfactory → cli_gate — openDox's core acquires an import edge to the openXdox column, the inverse of the direction test_no_column_module_imports_the_core_eagerly pins. It is what keeps the golden byte-identical (design decision 1) and it is the one line the § 3 carve deletes rather than moves; recording it here so it is not discovered at the carve. No test forbids the edge, deliberately — forbidding it would forbid the composition.
  4. cli_gate.py:251 carries the CLI's only doc_health import, for § 3.1's manifest. from doc_health import derive_possibles as dp (function-local, inside cmd_gate_derive_possibles) was cli.py's single direct doc_health import at base; the split moved it into cli_gate.py — the openXdox column, where doc_health will not exist at the carve. Same class as the memo § 5.1 doxbench_packet.py finding (a travelling module depending on an openxFactory-only one). No behaviour change and no gating loss — the import moved file, not target — so this is a carve-manifest fact, not a defect: beside item 3's core→column edge, this is the column→openxFactory-only-package edge.
  5. CI. CI has since dispatched — all nine required checks are green at a54791c8 (pytest-suite included), verified via the commit's check-runs.
    Ready for your word — I have not merged anything and will not.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UyynFBwGMQNeNU8D8qhQBW

brettheap and others added 5 commits September 6, 2026 19:39
….py (split § 2.4, PR 1 of 4: scaffolding, zero behavior change)

tasks.md § 2.4 says serve.py splits BY FUNCTION "behind an app-server route
extension point", and cli.py "behind a subcommand extension point", because
"without the extension point the integration layer forks the server, which is a
fork rather than a profile and breaks the same rule domain-descendant-boundary
applies one level down". This lands the two points and NOTHING ELSE: no route
and no subcommand is extracted here, so the risk surface is one clause in each
dispatch and one keyword-only argument on each builder.

Two neutral modules at the top of scripts/, on the precedent of
output_boundary.py (§ 2.1) and corpus_adapter.py (§ 2.2) and for the same three
reasons: both sides of the carve consume them, they travel with the carve to a
repository where the checker package does not exist, and they therefore import
neither package — stdlib and typing only, asserted by an AST scan over
tests/import_scan.py rather than left as a property of the current body.

  * route_extension.RouteExtension — one member, routes() -> tuple of frozen
    RouteBinding(method, pattern, is_prefix, handler). `handler` is the NAME of
    a method, dispatched getattr(self, name) against the LIVE DashboardHandler.
    That is the whole safety argument and the analogue of corpus-adapter-seam
    requirement 4's "no privileged route": a contributed route reaches the
    request through the same object every core route does, so it meets the same
    central gating by construction. A test asks a contributed write route and a
    core gate verb the same question off-loopback and compares the answers.
  * subcommand_extension.SubcommandExtension — one member, register(subparsers),
    handed the same argparse action every core subcommand is added through, so
    main()'s args.func(args) dispatches a contributed verb by the identical line.

Wiring: build_server gains route_extensions=() (collected once at wiring,
bound to the handler subclass like every other injected attribute, and refused
at BUILD time if a binding names a handler the server does not have);
build_parser and main gain subcommand_extensions=(). Core arms are consulted
FIRST in both dispatches and the fallback LAST, so an empty tuple is today's
behaviour exactly and a contributed route can never shadow a core one.

Golden parity, both derived from origin/main before the wiring was written:
the help text of all 31 entry points at COLUMNS=100, and the ordered core
dispatch arms of _route/do_POST with the handlers each reaches. Both unchanged.
The intent routes land exactly as PR #718 left them — untouched.

Refs #656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MDVAo41VtZqJQpuawwJeYC
…string

Three factual findings against scripts/route_extension.py, verified by V-a
and (for F1) independently confirmed by the Copilot review thread and V-b:

F1 (HIGH): resolve_handlers only checked hasattr(handler_holder, b.handler),
not callability. A binding naming an existing non-callable attribute of
DashboardHandler (e.g. "loopback", "capabilities", "route_bindings") passed
build_server and only crashed the first live request that reached it with
"TypeError: 'bool' object is not callable" — the exact failure the module's
own "a route that cannot be served must not start" guarantee promises never
happens. resolve_handlers now requires callable(getattr(handler_holder,
b.handler, _UNRESOLVED)), with a distinct refusal clause naming the
non-callable attribute separately from a genuinely missing one.

Call-shape decision (the Copilot thread's second question, and V-b's one
finding): resolve_handlers deliberately does NOT validate call shape (exact
vs prefix, read vs write) via inspect.signature. Reliably telling a handler
that is merely flexible about its arguments (*args, a defaulted parameter)
from one that is genuinely the wrong shape needs signature introspection this
module has no cheap way to perform correctly: the same handler name may
resolve through the CLASS (self still explicit) or an INSTANCE (self already
bound) — both accepted by design — and through a plain function, a
staticmethod, a classmethod, or a decorated wrapper, each stripping a
different set of leading parameters. A wrong-shape handler still fails
loudly on its first request with an ordinary Python arity TypeError, rather
than the silent-misroute or "starts but only crashes on this one path" defect
the callability refusal exists to prevent, so the module's neutrality (stdlib
only, no per-arm knowledge of the server it serves) is kept instead of
growing a heavier validation framework for a narrower benefit. Documented in
the docstring and explained on the review thread.

F2 (LOW): collect_bindings's collision key was the literal (method, pattern,
is_prefix), but a "GET" binding also answers a live HEAD request
(RouteBinding.matches). A "GET" and a "HEAD" binding for the same (pattern,
is_prefix) did not collide by key, yet both would answer the same HEAD
request, leaving one silently unreachable. collect_bindings now also checks
each binding against the collision key the OTHER method it overlaps with
would claim, symmetric in either declaration order.

F3 (LOW, wording): the module docstring claimed contributed routes meet
central gating "by CONSTRUCTION". False: a contributed POST handler that
skips its own self.loopback check executes off-loopback, exactly as a core
write route that skipped it would (every core write route self-checks as
its first statement). Softened to a reachability claim: the same primitives
are reachable on the live handler, so a correctly written extension checks
the same way a core route does — not an automatic-enforcement claim.

Zero behaviour change for the default (empty) extension tuples: only
scripts/route_extension.py and its own test file changed; the --help golden
and pinned dispatch-arm tuples in test_extension_point_parity.py are
untouched and still pass byte-identical.

Tests: 58 -> 63 in the three targeted files (test_route_extension.py,
test_subcommand_extension.py, test_extension_point_parity.py), all passing.
Full tests/ideation-dashboard suite: 4956 passed, 31 skipped, 1 failed — the
known environmental test_snapshot.py::test_find_validator_locates_pinned_checkout,
unrelated to this change (it resolves a path against the pinned sibling
checkout, which this detached worktree does not sit beside).

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CHAHvr9zFHRd4kWVnZLK9k
…ssage

Copilot review PRRT_kwDOTAvnrs6fwTVh, scripts/route_extension.py:296:
collect_bindings' collision refusal named the SLOT that matched
(claimed_key[0]) rather than each binding's own declared method, so a
GET/HEAD collision misreported itself as "two route bindings claim GET"
even where the second binding was actually declared HEAD, not GET.

Fix: `seen` now stores the full previous RouteBinding (not just its handler
name), and a new `_collision_message(previous, current)` builds the refusal
from each binding's own `.method`/`.pattern`: a same-method duplicate keeps
the original wording ("two route bindings claim GET '/x' ..."), and a
cross-method GET/HEAD collision now reads "GET '/x' and HEAD '/x' claim the
same GET/HEAD slot ...", naming both bindings correctly regardless of
declaration order.

Adjusted `test_a_get_and_a_head_binding_for_the_same_route_refuse_the_build`
(parametrized both orders) to assert the message names each binding beside
its own declared method, which fails on the old bug (a HEAD binding's own
method never appeared in the old message at all).

No other changes: only scripts/route_extension.py and its test file.

Tests: 63 in the three targeted files (test_route_extension.py,
test_subcommand_extension.py, test_extension_point_parity.py), all passing
(same count as before -- one existing test strengthened, none added). Full
tests/ideation-dashboard suite: 4956 passed, 31 skipped, 1 failed -- the
known environmental test_snapshot.py::test_find_validator_locates_pinned_checkout,
unrelated to this change.

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CHAHvr9zFHRd4kWVnZLK9k
…PR 4 of 4)

`cli.py` was 2,487 lines carrying all three columns at once. It is now 948:
the shared spine, the parser, and the entrypoint. The verbs moved to the
column they belong to, and the openXdox column reaches the parser through
PR #736's subcommand extension point rather than a call in `build_parser`.

  cli_gate.py           openXdox, CONTRIBUTED: 19 cmd_gate_* verbs + the whole
                        `gate` subparser tree, registered through
                        `SubcommandExtension.register`
  cli_project.py        openDox, fixed core: cmd_generate / cmd_create / cmd_edit
  cli_model_binding.py  openDox, fixed core: the model-binding verbs + parser
  profile_openxfactory.py   the composition point: what THIS assembly is
                        built with (the one file the § 3 carve deletes)

Zero behaviour change, and the parser proves it: `cli-help-tree.golden.txt`
is byte-identical for all 31 entry points. `gate` registers at exactly the
ordinal `_add_gate_subcommands(sub)` occupied, so it is still the last
top-level command and `model-binding` still precedes it — that call's own
first line (`_add_model_binding_parser`) moves up into `build_parser`, which
is what lets the openDox column stay put while the openXdox one travels.

The load-bearing risk is late binding, because getting it wrong is GREEN: a
moved verb that reached the spine through `from ideation_dashboard.cli import
_notebook_port` would freeze that reference at import and silently stop
honouring the thirteen `monkeypatch.setattr(cli_mod, ...)` sites the suite
injects fakes through. Every column module resolves the core through
`_core()` at CALL time instead, asserted both structurally and live in the
new tests, which also mirror the three closed-world source sweeps that would
otherwise keep passing over a smaller world.

cmd_generate_and_open deliberately stays in cli.py: it is the CLI's assembly
point (one build_server call declaring the notebook adapter, the model port
factory and the retrieval backend, and PR 3's route_extensions next), the
repository already treats it as the entrypoint in three landed source pins,
and serve.py's own entrypoint stays put for the same reason.

No existing test is modified. 6,556 passed, 1 failed (the known environmental
test_snapshot.py::test_find_validator_locates_pinned_checkout).

Refs #656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CHAHvr9zFHRd4kWVnZLK9k
Copilot AI lite review requested due to automatic review settings September 7, 2026 01:14

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @brettheap! 👋

Your private repo does not have access to Sourcery.

Please upgrade to continue using Sourcery ✨

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

The new regression tests contain gaps/brittle checks that can miss the intended eager-import/forbidden-flag cases or fail on harmless refactors.

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

Pull request overview

This PR completes the §2.4 CLI column split by moving cli.py’s verb implementations into column modules (cli_gate.py, cli_project.py, cli_model_binding.py) while keeping the shared CLI spine in cli.py, and wiring the openXdox “gate” tree through the subcommand extension point introduced in PR #736. It also adds a profile composition module and a dedicated regression test suite to prevent “green but wrong” late-binding regressions.

Changes:

  • Extracted the full gate subcommand tree + cmd_gate_* verbs into cli_gate.py and contributed it via GateSubcommands.register(...) instead of direct wiring in build_parser.
  • Moved generate/create/edit to cli_project.py and model-binding verbs/wiring to cli_model_binding.py, with cli.py re-exporting moved symbols to preserve args.func is cli_mod.<name> identities.
  • Added profile_openxfactory.SUBCOMMAND_EXTENSIONS and a new test module (test_cli_column_split.py) to assert late binding, mirrored scans, and re-export completeness.
File summaries
File Description
tests/ideation-dashboard/test_cli_column_split.py Adds regression tests for late-binding, mirrored sweeps, and re-export completeness (found a few correctness/robustness issues).
scripts/ideation_dashboard/profile_openxfactory.py Declares the in-tree assembly profile (SUBCOMMAND_EXTENSIONS) used by cli.build_parser.
scripts/ideation_dashboard/cli.py Removes moved verbs/wiring, registers profile + injected extensions at the former gate ordinal, and re-exports moved symbols to preserve call identities.
scripts/ideation_dashboard/cli_project.py New module containing generate/create/edit verbs, calling back into the core via _core() for late binding.
scripts/ideation_dashboard/cli_model_binding.py New module containing the model-binding verbs and parser wiring (closed loop; no _core() accessor).
scripts/ideation_dashboard/cli_gate.py New module containing the gate verbs + parser tree and the GateSubcommands subcommand-extension conformer.
Review details
  • 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.

Resolved a merge conflict in scripts/ideation_dashboard/cli.py: main's
squash-merge of #736 independently reworded build_parser()'s docstring
(diverging from this branch's own fix-round wording) while this branch
had already split cmd_model_binding_* and _add_gate_subcommands (and its
helpers) out of cli.py into cli_model_binding.py / cli_gate.py. Verified
byte-for-byte that main brought zero functional change to either region
(the model-binding functions and the gate helper functions matched the
pre-split base exactly), so both conflict hunks resolved by keeping this
branch's side, which already carries #736's docstring content as a strict
superset (the shared "subcommand_extensions"/"registers LAST" paragraphs
plus this branch's own IN-TREE PROFILE paragraph). Confirmed the resolved
file is byte-identical to this branch's pre-merge cli.py.

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_019sa33gYhfLF1F1MkS7Xrd6
Copilot AI review requested due to automatic review settings September 7, 2026 02:24
@brettheap
brettheap changed the base branch from feat/split-2-4-extension-points to main September 7, 2026 02:25

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

A newly added regression test’s bypass-flag scan has a substring mismatch ("--content "), which can fail to detect a forbidden --content flag and undermines the intended safety guarantee.

Review details

Suppressed comments (1)

tests/ideation-dashboard/test_cli_column_split.py:83

  • BYPASS_FLAGS includes the entry "--content " (trailing space), but test_no_moved_verb_offers_a_bypass_flag scans the source text for substrings. A real add_argument("--content", ...) would appear as "--content" (followed by a quote/comma), so this test would not catch the forbidden flag and could go green for the wrong reason.

To keep --content-file allowed while still catching a standalone --content flag, match the quoted token instead (both quote styles).

BYPASS_FLAGS = ("--force", "--override", "--overwrite", "--no-record",
                "--skip-gate", "--no-gate", "--content ", "--delete",
                "--token", "--gh-token", "--github-token", "--merge",
                "--approve", "--admin", "--auto-merge", "--squash")
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

…osed-world sweeps re-closed over the whole CLI

HIGH (gating lens). Run as a script or with `-m`, `cli.py` loads as `__main__`
while a moved verb's `_core()` imports `ideation_dashboard.cli` — a SECOND
module object, with its own `RepoRootRefused` and `GeneratedAtRefused`. The
`except` clauses in one copy's `main` could not catch the other copy's
exception, so both refusals degraded from the deliberate operator-facing
message on stderr to an unhandled traceback. No in-process test could see it:
`main([...])` called from the suite has only ever one module object.

Fixed at the entrypoint rather than at the symptom: the `__main__` bootstrap
now dispatches into the package's own copy of the module, so exactly one
module object runs anything — one set of exception classes, one set of
patchable names — in every invocation. Proof: nine invocations (four help
paths, three refusals, a success, an unknown verb) run in BOTH modes against
origin/main and against this head; the two transcripts are byte-identical
after path normalisation. The alternative (a `cli_shared.py` for the two
exception classes) fixes the classes and leaves the two module objects alive;
this leaves one.

MEDIUM (gating + parity lenses). The closed-world "every function that builds
a HumanGate authenticates its actor first" rule was closed over the whole CLI
because the whole CLI was `cli.py`. The mirror followed the verbs to
`cli_gate.py` alone, leaving `cli_project.py` and `cli_model_binding.py` swept
by neither reader. Both sweeps now read CLI_SURFACE — the core, the three
columns and the composition point — a ruling (a) widening of the mirror inside
this PR's own new file; no landed test is repointed.

LOW / Copilot 1 (`test_cli_column_split.py:83`). `BYPASS_FLAGS` carried
`"--content "` with a trailing space, which cannot match a real
`add_argument("--content", ...)`. Replaced by a boundary match, so a standalone
`--content` is caught and `--content-file` still passes.

LOW / Copilot 2 (`:113`). The eager-import scan missed
`from ideation_dashboard import cli` — an ImportFrom on the PACKAGE. All four
spellings, both package paths, are now recognised, and a table test puts each
one to the scan.

LOW / Copilot 3 (`:266`). The flag sweep's non-vacuity floor depended on double
quotes and on a local named `gsub`. It is structural now: AST `add_parser`
calls, the `gate` declaration, and the verb tree.

Also added: a parser-walk bypass sweep over the assembled tree (it catches a
flag no source sweep can see — one spelled by computation, or contributed by an
extension), and six subprocess tests that run the CLI as an operator does.

Findings NOT fixed here, and why: the four already-landed commits in this
branch's list and the catch-up merge message's misattribution both want a
branch rewrite, which is a reserved act — they are merge-time wording. The
`cmd_generate_and_open` column and the core→column import edge for the § 3.1
manifest are Brett's calls, carried in the PR body.

Findings fixed:
  r5 HIGH   cli.py:947 + cli_project.py:43 — two core modules under script/-m
  r5/r8 MED test_cli_column_split.py:214 — narrowed closed-world gate sweep
  r8 LOW    test_cli_column_split.py:106 — eager-import scan spelling hole
  r8 LOW    test_cli_column_split.py:81  — "--content " trailing space
  r8 LOW    test_cli_column_split.py:263 — formatting-sensitive floor

python3 -m pytest -q tests/ideation-dashboard tests/doc-health
  → 1 failed, 6565 passed, 31 skipped in 781.41s (the tolerated environmental
    test_snapshot.py::test_find_validator_locates_pinned_checkout)
OPENSPEC_TELEMETRY=0 openspec validate --all --strict
  → 96 passed, 1 failed (the tolerated disposition-codexfactory-declared-renames)

Refs #656

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_019sa33gYhfLF1F1MkS7Xrd6
Copilot AI review requested due to automatic review settings September 7, 2026 12:46

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.

🟢 Approval recommended

The changes are primarily a mechanical split with targeted new regression tests, and the only identified issue is a small docstring wording nit.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread scripts/ideation_dashboard/cli.py Resolved
…erstated claims

F1/F9 [MEDIUM]: BYPASS_FLAGS mirrored only test_create_document_cli.py and
test_session_verbs.py's bypass-flag sweeps, missing two more landed sweeps
over cli.py's source that also went quiet when the gate parser tree moved:
test_lens_gate_cli.py:126 and test_readiness_gate.py:228, both forbidding
"--skip-readiness" — the flag naming gate propose, the very verb that moved.
Add "--skip-readiness" to BYPASS_FLAGS (a widening inside this PR's own new
file; no landed test repointed) and correct the file's docstring/comments to
name all five landed sweeps. Verified: adding --skip-readiness to the moved
`gate propose` parser in cli_gate.py was green at the previous head and is
now caught by both test_no_verb_on_this_command_line_offers_a_bypass_flag and
test_the_assembled_parser_declares_no_bypass_flag (mutation reverted).

F4 [MEDIUM]: the previous fix round's bootstrap comment claimed "exactly one
module object ever runs anything ... in every invocation." scripts/__init__.py
makes `scripts.ideation_dashboard.cli` a third importable spelling that the
__main__ bootstrap does not close (_core() always resolves
ideation_dashboard.cli regardless of caller spelling). Narrow the comment to
the two invocations cli.py actually documents and disclose the residual gap
(nil blast radius: no in-repo caller uses that spelling).

F3/F7 [WORDING, PR body only, no further code change]: correct the stale
"948 lines" count (976 after this round's disclosure comment) and the false
claim that adding cli_gate.py to NO_IMPLICIT_PUSH_MODULES would fail
FORBIDDEN_PUSH_TOKENS self-assertions (checked: none of the three tokens
appear literally in any of the five CLI modules); the list's real scope is
implicit server-side/scheduled paths, which a CLI verb has never been part of.

F2, F5, F6, F8, F10-F13: no code change. F2 is informational (measured
startup-cost note, no action needed). F5/F8/F10/F11 remain correctly deferred
(branch rewrite is a reserved act; merge-time hand-written squash message
already named as the remedy). F6/F12/F13 remain Brett's calls, already
disclosed as "Decisions for Brett" items in the PR body.

Targeted: tests/ideation-dashboard/test_cli_column_split.py (22 passed).
Full: python3 -m pytest -q tests/ideation-dashboard tests/doc-health ->
1 failed (known environmental test_snapshot.py::test_find_validator_locates_pinned_checkout),
6565 passed, 31 skipped. OPENSPEC_TELEMETRY=0 openspec validate --all --strict
-> 96 passed, 1 failed (known disposition-codexfactory-declared-renames).

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_019sa33gYhfLF1F1MkS7Xrd6
Copilot AI review requested due to automatic review settings September 7, 2026 14:07

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.

🟢 Approval recommended

The refactor preserves the CLI surface via re-exports and extension wiring, and the added tests directly cover the prior silent-failure modes (late binding and script/-m double-module hazards).

Review details
  • Files reviewed: 5/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

…elling

THE OPEN MEDIUM, closed at the root instead of disclosed a third time. The
§ 2.4 split left one core-to-column divergence alive: the columns named the
core absolutely (`_core()` -> `from ideation_dashboard import cli`) and
`cli.py` re-exported them absolutely in return. `scripts/__init__.py` makes
`scripts.ideation_dashboard.cli` a real second name for this file and a second
module object at runtime, so a caller who imported the CLI that way ran the
OTHER core's verbs: a refusal raised inside a moved verb was an instance of a
`RepoRootRefused` its own `except` clause did not name. Reproduced at dda79b4
as `UNCAUGHT ideation_dashboard.cli.RepoRootRefused`, where origin/main returns
1 and prints the refusal. It is the class of divergence the first round's
bootstrap closed for `__main__`, one spelling over.

Every module the split created now names its siblings RELATIVELY, so each
spelling gets one coherent set and a column always reaches the very core that
is running it:

* `_core()` in cli_gate.py and cli_project.py is `from . import cli` --
  resolved against the package the column itself was imported under, still at
  CALL time, so the thirteen `monkeypatch.setattr(cli_mod, ...)` sites keep
  reaching the moved bodies.
* cli.py names the four modules the split created relatively (the profile and
  the three re-export blocks); every other import is untouched.
* profile_openxfactory.py contributes `from . import cli_gate`, so the profile
  registers the column of the same spelling as the core assembling the parser.
* The `__main__` bootstrap moves ABOVE the imports and hands over before the
  body runs: as a script there is no package at all, so that copy could not
  name its siblings relatively -- handing over first means the body only ever
  executes as a package module. Still one `__main__` block, still importing the
  package copy and calling ITS `main`, so the landed structural pin holds
  unmodified; and it removes the second execution of the module body that the
  previous round's bootstrap cost (+0.10s / 32% measured, now +0.02s / 6%).

PROVEN, not asserted, in this PR's own new test file (no landed test edited):
three tests, two of them parametrized over both importable spellings and run in
a FRESH interpreter, because in-process `sys.modules` answers for a decision
made before the test ran. `test_a_library_caller_gets_the_columns_of_its_own_core`
(both `_core()`s and the profile's column are the caller's, and every verb the
assembled parser dispatches to is the same object on that core, from that
spelling's own modules); `test_a_refusal_is_reported_under_every_importable_spelling`
(`main([...])` returns 1 with the operator-facing message, no traceback, no
snapshot); `test_the_split_modules_name_each_other_relatively` (the structural
pin, exempting only the bootstrap's own import of the core).

Mutations, each applied and reverted: `_core()` back to the absolute form, the
`cli_gate` re-export back to absolute, and the profile's import back to
absolute each red 3 tests (both `scripts.` probes plus the pin) while the
`ideation_dashboard` probes stay green -- which is exactly why the defect hid;
an absolute column import parked inside the `__main__` guard reds the pin; the
bootstrap back to `sys.exit(main())` at the foot reds 6. Base-vs-head: 12
invocations x {script, -m} x {origin/main, head} = 24 transcripts, 0 differing,
0 tracebacks, and `main([...])` on the refusal returns 1 under both spellings
at base and at this head.

Also re-checked at this head and still closed: BYPASS_FLAGS carries the union
of all five landed bypass sweeps across four files (--skip-readiness included),
and both surface-wide sweeps read CLI_SURFACE.

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_017guxvApq5jqB1QXukJUsTQ
Copilot AI review requested due to automatic review settings September 7, 2026 14:54

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

It is a large CLI entrypoint refactor involving cross-module import/dispatch wiring that warrants final human validation of runtime invocation scenarios beyond the static diff review.

Review details

Suppressed comments (1)

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

tests/ideation-dashboard/test_cli_column_split.py:202

  • test_no_column_module_imports_the_core_eagerly treats “module-level” as col_offset == 0, which misses imports that still execute at import time but are nested under a top-level compound statement (e.g., if ...: / try:). That leaves a hole where a column could still bind the core eagerly (and freeze the spine) without being caught by this scan.
  • Files reviewed: 5/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

…he CLI's doc_health import

r6 (gating and security) MEDIUM: `declares_flag`'s word-boundary match was
applied to all seventeen `BYPASS_FLAGS`, not just `--content` (the one flag
that needs it to avoid catching `--content-file`). A prefixed bypass
spelling in any column module (`--force-all`, `--no-gate-check`) answered to
nothing, in both the source sweep and the parser-walk sweep. Narrowed
`declares_flag` to `--content` only; the other sixteen flags use the landed
plain-substring rule the five sweeps this file mirrors all use. Verified
safe (only `--content-file` collides with `--content` anywhere on the
312-option assembled parser) and mutation-proven: a live `--force-all`
declaration on the gate parser reds both sweeps; reverted.

r6 LOW: cli_gate.py:251's `from doc_health import derive_possibles` is now
the CLI's only direct doc_health import, travelling into the openXdox
column undisclosed. No re-plumbing (out of scope) — disclosed in the PR
body's "What moved" table and a new "Decisions for Brett" item for the
§ 3.1 carve manifest. Searched tests/ for a doc_health-import inventory
this move would make stale; none scans cli.py/cli_gate.py by name, so
there is nothing to widen.

r4/r5 WORDING (verified independently, not on the lens's own numbers where
those were themselves imprecise): the cli_model_binding.py "What moved" row
undercounts its defs (10, not 11) — its cited range (cli.py:1678-1914) was
already correct; the third-round mutation table overstates two rows' catch
count (2, not "the same 3" as the row above them — the refusal probe stays
green for both because it runs through the still-relative cli_project.py);
and "Decisions for Brett" item 4 quoted a stale CI paragraph, now replaced
with the fact that all nine required checks are green at a54791c.

No production code changed; test_cli_column_split.py is the only file this
commit touches (27 passed).

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UyynFBwGMQNeNU8D8qhQBW
Copilot AI review requested due to automatic review settings September 7, 2026 16:54

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

A key “structural pin” test intended to prevent future absolute imports between split modules misses the common import ideation_dashboard.cli_gate form, weakening the regression guarantee this PR is explicitly adding.

Review details

Suppressed comments (1)

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

tests/ideation-dashboard/test_cli_column_split.py:857

  • test_the_split_modules_name_each_other_relatively only inspects ast.ImportFrom nodes and will miss the equally common absolute-import form import ideation_dashboard.cli_gate / import scripts.ideation_dashboard.cli_gate. That means the “structural pin” can be bypassed without the test noticing, allowing a future regression where a split module binds a sibling under the wrong package spelling.
  • Files reviewed: 5/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

brettheap added a commit that referenced this pull request Sep 7, 2026
…ce-gap disclosure

Fixes verified findings from the WF24d parity + gating lenses on PR #761
(§ 2.4 PR 3, r7/r8):

* Arm-count claim corrected: "five read arms" -> "four read arms" (matches
  the measured ROUTE_ARMS 10->6 delta) in the PR body and the test comment
  above ROUTE_ARMS in test_extension_point_parity.py.
* "35 in-tree build_server(...) call sites across 27 files" corrected to
  the measured "31 in-tree test call sites across 27 test files" (AST walk,
  not a grep of prose) in serve.py's build_server docstring,
  profile_openxfactory.py's ROUTE_EXTENSIONS comment, and the PR body.
* serve_wire.py's docstring and the PR body's "Plus" bullet both
  over-generalized the reason HOSTED_SESSION_REFUSAL/hosted_ref_refused/
  hosted_index moved to serve_wire.py, claiming all three are read by the
  core and both columns. Corrected per-name: only hosted_ref_refused is
  read by the core; HOSTED_SESSION_REFUSAL is read by both columns only;
  hosted_index has exactly one in-tree reader (serve_projection.py).
* profile_openxfactory.py's relative-import comment spoke in CLI terms
  copied verbatim from #742 (referencing cli.py/cli_gate, neither of which
  exists on this branch) to keep an eventual add/add merge to one hunk.
  Rewritten for the route/server half; the merge cost (a one-paragraph
  resolution instead of a clean add/add on that paragraph) is disclosed in
  the PR body.
* conftest.py's SERVE_SURFACE_MODULES/NO_IMPLICIT_PUSH_MODULES banner said
  "four files" where the tuple now has seven entries; corrected. Added a
  comment explaining why profile_openxfactory.py (also new, also read by
  build_server) is deliberately excluded from both tuples: it is
  relative-import-only by design, so the D12 relative-import guard would
  fail on it for a reason it does not exist to catch.
* Disclosed an undisclosed test addition (test_route_extension.py's
  test_a_caller_s_extensions_are_added_to_the_profile_and_never_replace_it)
  and corrected "No behavioural test was modified" to name the one
  behavioural comparator repoint (row 5) it was asserted alongside.
* Catch-up merge: origin/feat/split-2-4-pr2-opendox-columns advanced to
  ca61cf1 ("Exclude dunders by rule...") after this branch's original
  push, rewriting the same test function this PR also rewrites. Took a
  real merge and resolved the one conflict keeping BOTH the base's
  rule-based _non_dunder exclusion and this PR's five-mixin sweep,
  disclosed in the PR body in place of the stale "base is an ancestor"
  claim.
* Added test_an_exact_caller_binding_under_a_contributed_prefix_wins_the_match
  to test_route_extension.py, pinning (as a disclosed characterization,
  not a fix) that collect_bindings accepts an exact caller binding whose
  pattern sits inside an already-declared contributed PREFIX binding and
  lets it win the match. The structural remedy is in scripts/route_extension.py,
  which this lane must not touch; raised in the PR body's Decisions for
  Brett instead.

python3 -m pytest -q tests/ideation-dashboard tests/doc-health:
1 failed (known environmental test_find_validator_locates_pinned_checkout),
6635 passed, 31 skipped, 783s.
OPENSPEC_TELEMETRY=0 openspec validate --all --strict: 97 passed, 1 failed
(known disposition-codexfactory-declared-renames artifact).

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UyynFBwGMQNeNU8D8qhQBW
@brettheap
brettheap merged commit 421b52d into main Sep 7, 2026
11 checks passed
brettheap added a commit that referenced this pull request Sep 7, 2026
…mber (#757)

Takes origin/main 421b52d, the ideation-dashboard cli.py column split (#742,
PR 4 of 4). No conflict: the six paths it moves are all under
scripts/ideation_dashboard/ and tests/ideation-dashboard/, none of which this
packet edits. Taken AFTER the ratification was encoded, so the records are
re-derived on the merged tree in a separate commit touching review/ files only,
which leaves the ratifying commit — the first commit whose proposal.md declares
Status: ratified — exactly where it is.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JZqmqSDBCmY4cfhPbxN9Xb
brettheap added a commit that referenced this pull request Sep 7, 2026
… origin-retention gate against 05a9db8 (#757)

RECORDS ONLY. This commit touches
openspec/changes/publish-openspec-cli-pin-as-contract-member/review/ and nothing
else, so the RATIFYING commit — 05a9db8, verified to be the FIRST commit on
this branch whose proposal.md declares Status: ratified, which is exactly what
the origin-retention gate resolves at archive time — does not move.

TWO THINGS ARE ADDED. (1) The two `--archive-gate` arms, which take
--ratified-ref and therefore could not be run until 05a9db8 existed: both
RETAINED — "sequenced_after retention gate passed (declaration unchanged since
ratification)" and "scope_globs scope-retention gate passed (scope unchanged
since ratification)". (2) The fourth catch-up merge, a864ef6 taking origin/main
421b52d (the ideation-dashboard cli.py column split, PR #742), named in both
records with its six paths, none of which this packet edits.

EVERY NUMBER RE-DERIVED ON THE MERGED TREE AND NOT ONE MOVED: pinned 1.12 strict
1/1 on the change and 98 passed / 2 dispositioned over 100 corpus items;
membership 283 -> 283 against a 421b52d control worktree OUTSIDE this clone;
188 manifest digests; sequenced_after 40 active / 5 declaring, 181 ledger rows;
scope_globs clean; proposal-support verify ok; release-tag-gate no error and no
warning; doc-health 9/8/58/15 on the branch against 9/8/58/13 on the control,
the branch's reports byte-identical before the encode, after the encode and
after the fourth merge; 1923 passed in the four-suite run on both sides.

Lane: openxfactory-1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JZqmqSDBCmY4cfhPbxN9Xb
brettheap added a commit that referenced this pull request Sep 7, 2026
…3-extension-columns

Six conflicts, all from the squash-merge identity problem (#748/#742 landed
as squash commits, so git treats PR-3's pre-existing work against them as a
fresh collision rather than a fast-forward):

- scripts/ideation_dashboard/profile_openxfactory.py (add/add): the only
  real splice. Kept the shared module docstring (#742's landed header,
  which already anticipated PR 3 adding ROUTE_EXTENSIONS), rewrote the
  "Relative, like the core's own imports..." comment to speak for both
  verbs and routes, and kept BOTH extension tuples: SUBCOMMAND_EXTENSIONS
  (#742/main) alongside ROUTE_EXTENSIONS + `from . import serve_gate,
  serve_openxfactory_lanes, serve_projection` (this branch).

  DISCOVERED WHILE RUNNING THE FULL SUITE, not part of either side's
  original text: a plain top-level `from . import cli_gate` (#742's own
  spelling) turned into a regression the moment ROUTE_EXTENSIONS joined it
  in the same module. `serve.py`'s `build_server` imports
  `profile_openxfactory` on every startup, hosted included, to reach
  ROUTE_EXTENSIONS; `cli_gate` pulls in `authoring` -> `workbench` -> PyYAML,
  which the hosted image deliberately does not carry
  (`test_repo_selector.py::test_hosted_posts_do_not_load_notebook_only_dependencies`,
  green on `main` and on this branch's pre-merge tip, red after a naive
  splice). Fixed by resolving `SUBCOMMAND_EXTENSIONS` and the `cli_gate`
  submodule attribute lazily, via a module-level `__getattr__` (PEP 562) —
  the same pattern `authoring.py` already uses for `REQUIRED_HEADER_FIELDS`
  and for the same reason (a shared module should not carry a dependency
  only one caller needs). `cli.py`'s read of `SUBCOMMAND_EXTENSIONS`, the
  `len(...)==1`/`isinstance(...)` pins in `test_cli_column_split.py`, and
  the `profile.cli_gate is gate` identity check in
  `test_a_library_caller_gets_the_columns_of_its_own_core` (module
  `__getattr__` still answers through `sys.modules`, so identity holds)
  all still pass — verified by re-running the full targeted suite.

- scripts/ideation_dashboard/serve.py (7 hunks): resolved by keeping our
  side throughout, verified hunk by hunk rather than assumed:
  * `import traceback` (main) dropped — the only caller of the module
    (`_log_gate_failure`, T092 defect-3 logging) already lives in
    `serve_gate.py` on this branch, which imports `traceback` itself; the
    name would be dead/unused in `serve.py` after the extraction.
  * the split docstring + import block, the `serve_projection` import +
    widened `serve_wire` import list, the `fresh_ledger_events`/
    `hosted_index`/`hosted_ref_refused` import line, and the
    `DashboardHandler` mixin base list: our side is a strict superset of
    main's (main's text is a subset written before PR 3 added its three
    columns).
  * the `_handle_dtn_seed`/`_handle_staging_seed`/`_handle_apply_register_edits`/
    `_handle_refresh_action`/`_run_refresh` block and the
    `_read_snapshot`/`_serve_snapshot`/`_hosted_entry_refused`/`_serve_index`/
    `_serve_committed_intents`/`_keyed_source`/`_serve_source` block: main
    still carries these as fixed core methods; this branch already moved
    them (byte-diffed to confirm) into `serve_openxfactory_lanes.py` and
    `serve_projection.py` respectively, so keeping our side (empty) is the
    correct resolution, not a loss.

- scripts/ideation_dashboard/serve_wire.py (add/add, 3 hunks): our side
  only — the hosted-plane confinement paragraph, the `HOSTED_SESSION_REFUSAL`/
  `hosted_ref_refused`/`hosted_index` additions and the `snapshot_registry`
  import are PR-3-only content; main's side of every hunk was empty.

- tests/ideation-dashboard/conftest.py (3 hunks), test_extension_point_parity.py
  (3 hunks), test_session_snapshot.py (1 hunk): our side throughout — each
  is the "seven files"/five-mixin widened version of an assertion main still
  states at PR 2's "four files"/two-mixin count; no assertion was dropped,
  every one got strictly broader (NO_IMPLICIT_PUSH_MODULES and
  SERVE_SURFACE_MODULES tuples are the union, in dependency-first order).

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UyynFBwGMQNeNU8D8qhQBW
brettheap added a commit that referenced this pull request Sep 7, 2026
…idence; record the § 2 carried items (#769)

split-opendox-two-layer-product group-2 bookkeeping: tick § 2.1 (#724 e2b8f62), § 2.2/2.2a (#725 ea4e6ff), § 2.3 (#728 1a2ea82), § 2.4 (#736 a83eb93, #741 75467fe, #748 7f7ce75, #742 421b52d, #761 7992b87), § 2.6 (gate re-run on the branch: 6681 passed, the environmental snapshot test and the tolerated disposition artifact identical on main); § 2.5 stays open (Path A D-2). Records the twelve § 2 carried items for the § 3.1 carve manifest; repoints two doc_health sweep-record strings to doxbench_status_exemption. Landed under a Rule 6 window on Brett Heap's word "merge 769 when green" (2026-09-07). Refs #656.

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q8CkMMAdcUZCqAUTgNjsPy
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