Skip to content

Carve the Status: exemption out of the packet assembler (§ 2.4 OQ-1) - #741

Merged
brettheap merged 2 commits into
mainfrom
feat/split-2-4-doxbench-packet-split
Sep 7, 2026
Merged

brettheap merged 2 commits into
mainfrom
feat/split-2-4-doxbench-packet-split

Conversation

@brettheap

@brettheap brettheap commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

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

Realizes split-opendox-two-layer-product § 2.4 OQ-1 as ruled: scripts/ideation_dashboard/doxbench_packet.py is split along the line it straddles, so the generic packet assembler can travel to openDox with the chat-turn route that calls it while this corpus's Status:-header read stays in the openxFactory-adapter column. Zero behaviour change to any existing behavioural assertion. The original test-file edit was the conftest.py sweep widening the memo itself mandates; a fix round added three more widenings/repairs to pre-existing negative-space tests, all disclosed in ## Fix round below. Refs #656.

Stack note. § 2.4 PR-1 (#736, scripts/route_extension.py / scripts/subcommand_extension.py) is open in parallel on feat/split-2-4-extension-points. This PR touches neither of those files and shares no other file with it; it branches from main and targets main directly, so the two can land in either order.

What moved

Bodies and the align-status-reader-to-real-lines comment block moved byte for byte (verified by diff against origin/main); only the enclosing file changed.

Symbol From To
_STATUS_RE ideation_dashboard/doxbench_packet.py:134 ideation_dashboard/doxbench_status_exemption.py
STATUS_SCAN_LINES doxbench_packet.py:135 doxbench_status_exemption.py
EXEMPT_STATUSES doxbench_packet.py:152 doxbench_status_exemption.py
_STATUS_DECORATORS doxbench_packet.py:161 doxbench_status_exemption.py
lifecycle_status doxbench_packet.py:164-172 doxbench_status_exemption.py
status_word doxbench_packet.py:175-183 doxbench_status_exemption.py
is_compression_exempt doxbench_packet.py:186-189 doxbench_status_exemption.py
the ruling's comment block doxbench_packet.py:118-162 doxbench_status_exemption.py, verbatim
from doc_health.lines import split_keepends doxbench_packet.py:68 doxbench_status_exemption.py
import re doxbench_packet.py:63 deleted — its only use was _STATUS_RE

Stayed: everything else, exemption_rail included. It is the MARKING mechanism (dataclasses.replace(source, status=…, compression_exempt=…)), and marking a source with whatever status a reader reports is a thing any corpus's assembler does. Its positional signature is unchanged.

Design decisions taken

  1. The generic module keeps the filename, and the rail gets the new one. Three source-scanning tests hard-code doxbench_packet.py (test_doxbench_packet.py:43, :953-958, test_doxbench_blank_reason.py:769-790), and test_provider_boundary.py:243 requires that file's needle scan to survive. Naming the generic half after the file every caller already imports keeps all four pointed at real subjects.
  2. The seven names survive as names, through a module-level __getattr__ — PEP 562, the same shape authoring.__getattr__ uses for REQUIRED_HEADER_FIELDS under § 2.3. That is what let every behavioural test stay unmodified. A top-level from … import was rejected: it would put the adapter-column module back into the generic module's import graph, reading as neutral in the AST scan while being a hard dependency in fact.
  3. __getattr__ serves UNDERSCORE names too. The obvious not name.startswith("_") guard would silently break test_mutation_reverting_lifecycle_status_alone_reproduces_the_divergence, which reads pk._STATUS_RE on purpose to prove the exotic-separator fixture pins the defect the wide ruling closed. It would have errored rather than failed, in a file nobody edited.
  4. One point of dependence. exemption_rail and __getattr__ both resolve through _status_exemption(), so the seam is a single import statement; a test asserts exactly one. exemption_rail resolves once per call, not once per source.
  5. The rail lives beside the package, not inside corpus_adapter_openxfactory/. That package's __all__ is closed to two names and tests/corpus-adapter/test_no_privileged_route.py scan 1 fails any outside importer binding a third; putting the rail there would force widening a ratified closure. A sibling module keeps the column assignment a § 3.1 manifest row.
  6. NO_IMPLICIT_PUSH_MODULES widened, per the memo's rule (§ 3 PR-3, § 6). Splitting a swept module is a way of narrowing that negative which no assertion would catch — both halves keep passing while half the code walks out of it.
  7. The align-status-reader-to-real-lines guards are restated against the carved module directly. The existing ones reach it through the alias and are untouched; the alias is a bridge scheduled for demolition at the carve, and a ratified wide ruling should not be defended only by a bridge.
  8. __getattr__ is left unguarded for the post-carve world (decision 2 below): after the carve the names raise AttributeError, loudly, rather than degrading to a neutral posture. (Fix round: _status_exemption()'s absent-module case actually surfaced as ModuleNotFoundError, not AttributeError, until the fix round below caught and translated it — see ## Fix round item 1.)

Proof

python3 -m pytest -q tests/ideation-dashboard tests/doc-health
  → 1 failed, 6532 passed, 31 skipped in 972.64s (16:12)
    the one failure is the known environmental
    test_snapshot.py::test_find_validator_locates_pinned_checkout

python3 -m pytest -q tests/corpus-adapter        → 89 passed
OPENSPEC_TELEMETRY=0 openspec validate --all --strict
  → 96 passed, 1 failed — the known 'disposition-codexfactory-declared-renames' artifact

Counts before/after, --collect-only over the same two suites, from a detached worktree at origin/main and from this branch:

collected
origin/main 6512
this branch 6564

+52 exactly, all of them the new file. No existing test's count changed, and no existing behavioural test was edited.

Test files touched: 2. tests/ideation-dashboard/test_doxbench_status_exemption.py is new (52 tests). tests/ideation-dashboard/conftest.py gains one tuple entry plus the comment recording why — the widening the memo mandates, which is not an edit of a behavioural assertion.

Goldens: none exist over packet output. The parity the slice asks for therefore has no golden to reconcile, and none was regenerated. It is proved instead by copying the pre-split bodies into the test file verbatim and comparing:

  • the four constants, against their pre-split values;
  • both readers over 14 fixture texts (decorated statuses, CRLF, empty Status:, no header, a header past the window, non-str inputs);
  • both readers over the same 80 real docs/**.md documents the existing drift check reads;
  • a whole assembled packet — assemble_packet(...) through the real path, then every source re-marked from its own text with the pre-split reader: packet.sources tuple equality, packet_sections() byte equality, declaration_text() equality. Non-vacuity is asserted on both sides of the exemption (ratified/True, draft/False), and a negative control shows a divergent reader would move both the tuple and the bytes.

Mutation checks run (6 of 6 caught):

mutation caught by
re-add from doc_health.lines import … to doxbench_packet.py test_the_packet_module_imports_neither_the_checker_nor_the_home_adapter
a SECOND import of the seam test_the_dependence_on_the_carved_rail_sits_at_exactly_one_line
re-define STATUS_SCAN_LINES in doxbench_packet.py test_the_packet_module_no_longer_defines_the_carved_names_itself
add a public name to the rail the alias set does not reach test_the_alias_set_cannot_drift_from_what_the_carved_module_defines
drop standard from EXEMPT_STATUSES 3 parity tests
revert the carved read to str.splitlines() the exotic-separator agreement + its mutation twin

The neutrality scan is AST-parsed, never grepped (tests/import_scan.py), and carries its own negative control over five spellings of the reintroduced dependency including a lazy function-local one.

Not in this PR

  • scripts/route_extension.py / scripts/subcommand_extension.py — those are 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.
  • openspec/, contracts/, docs/, README, tasks.md — bookkeeping is the orchestrator's.
  • The rest of § 2.4's serve.py / cli.py split.
  • A stale prose reference, flagged not fixed: scripts/doc_health/lines.py:46 and scripts/doc_health/corpus.py:193 both name ideation_dashboard.doxbench_packet.lifecycle_status in their sweep records. No test parses them, and doc edits are out of scope — noted for the orchestrator.
  • A cross-column dependency this slice does not fix: the generic module still imports doxbench_scope, which design.md:284-286 files under openXdox rather than openDox. Out of pkt's scope; worth a § 3.1 manifest note.

Fix round

Four independent-verifier findings addressed with a code/test fix; one wording-only PR-body correction folded in above (the import re line-number cite); one Copilot review thread addressed by reply only (see thread).

  1. The post-carve failure mode now actually is what the module already claimed. _status_exemption()'s bare import ideation_dashboard.doxbench_status_exemption raised ModuleNotFoundError when that module is absent — an ImportError, not AttributeError — while three prose sites (the __getattr__ docstring, the rail comment, and decision 2/8 above) said AttributeError. The practical gap: hasattr(pk, "lifecycle_status") and getattr(pk, "lifecycle_status", default) swallow AttributeError but not ModuleNotFoundError, so a caller written to the documented contract would have crashed where it was told it would degrade. __getattr__ now catches ModuleNotFoundError from _status_exemption() and re-raises AttributeError naming the missing attribute (chained via from exc), restoring the documented semantics. New test: test_the_carved_away_case_is_an_ordinary_attribute_error_too (monkeypatches pk._status_exemption to raise ModuleNotFoundError, asserts the re-raised type, the chain, and that hasattr/getattr-default now degrade rather than raise).
  2. test_no_watch_listed_candidate_is_depended_on_anywhere_in_this_slice (test_doxbench_packet.py) widened to add doxbench_status_exemption.py to its scanned-module tuple. The 72 moved lines left the file this negative scanned; without the widening the sweep stayed green while that code walked out of its coverage — a pure widening, no assertion changed.
  3. test_the_alias_set_cannot_drift_from_what_the_carved_module_defines rewritten to parse the carved module's syntax tree instead of filtering vars(rail) by a value's reported __module__. That filter drops any rail-level value whose TYPE supplies __module__ — a compiled re.Pattern (_STATUS_RE itself is one) reports __module__ == "re", so a future regex constant added to the rail and left off the alias set would have passed unnoticed, even though the rail already holds exactly that kind of value. Verified by mutation: appending a second re.compile(...) constant to the rail now fails this test (previously green); reverted after confirming.
  4. PRESERVED_SCANS (test_provider_boundary.py) gained a row for test_doxbench_status_exemption.py::test_the_carved_module_contains_no_forbidden_spelling — the carved module's own forbidden-spelling scan was the only per-module negative-space scan in the package not yet protected by the registry that exists to stop a later change deleting one and staying green.

None of the four is a repoint (no test's assertion target moved to a different file/name); all four are widenings of an existing negative or a new companion test, per RULING (a).

Decisions for Brett

  1. OQ-1's recommended route through classify() does not exist, and this PR ships the task's stated fallback. corpus_adapter.Classification carries kind, required_fields, missing_fields and unclassifiable — never a status VALUE — and corpus_adapter_openxfactory/classify.py:26-33 records RULING OQ-2 (2026-09-06, NO): "Classify answers KIND and REQUIRED FIELDS — nothing else." The rail needs the raw value (PacketSource.status is rendered verbatim into evidence sections) and the leading status word. Independently, classify(corpus, document) answers about a document a corpus holds, while this rail runs over in-memory PacketSource.text once per evidence item per chat turn; the only in-tree way to classify a loose body is authoring._classify_proposal's corpus-of-one, a tempdir round trip. So the rail moved COLUMN keeping its direct doc_health import, and the Protocol was not extended. Either (a) accept that — the task's own fallback, and what is shipped — or (b) overturn OQ-2 and add a status field to Classification, which reopens a closed Protocol (OPERATIONS, tests/corpus-adapter/test_interface_closure.py). test_the_carved_module_still_reaches_doc_health_directly asserts the shipped shape and asserts Classification has no status field, so if (b) is ever ruled, that test is the one line that has to move.
  2. Post-carve default behaviour, left unguarded on purpose. With the adapter-column module gone from openDox's tree, pk.lifecycle_status and friends raise AttributeError at the first assembly — loud, and it breaks openDox's chat turn until openDox supplies its own rail. The alternative is a declared neutral posture (status=None, compression_exempt=False, in the module's own POSTURE_REDUCED idiom), which is a silent-degradation shape this corpus normally refuses. Nothing in § 2.4 forces the choice now; it needs your word rather than an author's judgment, and § 3.1 is where it lands.

Asking for your word on this one before anything further happens to it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CHAHvr9zFHRd4kWVnZLK9k

…OQ-1)

`doxbench_packet.py` did two jobs on opposite sides of the openDox carve. It
ASSEMBLES a bounded context packet — generic, and the primitive openDox's own
chat-turn route calls — and it READ this corpus's `Status:` header against this
corpus's lifecycle vocabulary through `doc_health.lines.split_keepends`, which
is openxFactory's and only openxFactory's. design.md § D3 files the whole file
under the openxFactory-adapter column, so moving it wholesale would leave
openDox's kept-in-tree route depending on an openxFactory-only module: the
fork-vs-profile problem `domain-descendant-boundary` forbids one level down.

OQ-1 was ruled as recommended, so the file splits along the line it straddles.
`_STATUS_RE`, `STATUS_SCAN_LINES`, `EXEMPT_STATUSES`, `_STATUS_DECORATORS`,
`lifecycle_status`, `status_word` and `is_compression_exempt` move verbatim —
bodies and the `align-status-reader-to-real-lines` comment block byte for byte —
into `ideation_dashboard/doxbench_status_exemption.py`, taking the `doc_health`
import with them. Everything else stays, `exemption_rail` included: marking a
source with whatever status a reader reports is generic, and only the READ is
this corpus's. `doxbench_packet.py` now names `doc_health` in no import at all.

The seven names stay ANSWERABLE on `doxbench_packet` through a module-level
`__getattr__` — PEP 562, the same shape `authoring.__getattr__` uses for
`REQUIRED_HEADER_FIELDS` under § 2.3 — so no caller and no existing test needed
an edit. It resolves underscore names too, deliberately: `test_doxbench_packet`'s
mutation check reads `pk._STATUS_RE` to prove the exotic-separator fixture pins
the defect that wide ruling closed. A top-level re-export was rejected because it
would put the adapter-column module back into the generic module's import graph,
which is the fork this carve exists to prevent; lazily, the dependence on the
seam sits at ONE import statement, in `_status_exemption()`.

OQ-1'S RECOMMENDED ROUTE THROUGH `classify()` IS NOT AVAILABLE, and this ships
the task's stated fallback rather than widening a closed Protocol.
`corpus_adapter.Classification` carries kind, required fields, missing fields and
an unclassifiable reason — never a status VALUE — and RULING OQ-2 (2026-09-06,
NO) bounds `classify` to exactly that. The rail needs the value, and it runs over
in-memory strings rather than documents a corpus holds. Both gaps are reported
for Brett's word; a test pins the shipped shape so a later ruling has something
explicit to move.

`NO_IMPLICIT_PUSH_MODULES` is WIDENED to carry the new filename: splitting a
swept module is a way of narrowing that negative which no assertion would have
caught, since both halves keep passing while half the code walks out of it.

Proof: `tests/ideation-dashboard/test_doxbench_status_exemption.py` (52 tests) —
neutrality by AST scan with its own negative control, alias closure in both
directions plus a parse proving the assignments really are gone, and PARITY
against verbatim copies of the pre-split bodies over the fixture corpus, over 80
real documents, and over a whole assembled packet compared as a source tuple and
as rendered section bytes. The `align-status-reader-to-real-lines` guards are
restated against the carved module directly, so they survive the alias's eventual
removal. Six mutations were run and every one was caught.

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:10

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

🟢 Approval recommended

The refactor appears behavior-preserving with extensive parity/neutrality tests, and the remaining feedback is limited to type-annotation accuracy.

Pull request overview

Splits the Status: header lifecycle-exemption reader out of the generic packet assembler so the assembler can “travel” without importing openxFactory-only doc_health, while preserving behavior via a __getattr__ alias bridge and parity tests.

Changes:

  • Added scripts/ideation_dashboard/doxbench_status_exemption.py containing the carved status reader (lifecycle_status, status_word, is_compression_exempt) and related constants.
  • Updated scripts/ideation_dashboard/doxbench_packet.py to resolve the carved reader via a single seam import and to keep backward-compatible attribute access via module-level __getattr__.
  • Added a new test suite proving neutrality/closure/parity and widened NO_IMPLICIT_PUSH_MODULES to include the carved module.
File summaries
File Description
tests/ideation-dashboard/test_doxbench_status_exemption.py New tests asserting neutrality, alias closure, parity with pre-split behavior, and guard agreement against doc_health.
tests/ideation-dashboard/conftest.py Expands the “no implicit push” sweep to include the new carved module.
scripts/ideation_dashboard/doxbench_status_exemption.py New carved module implementing the status header read and compression-exemption decision.
scripts/ideation_dashboard/doxbench_packet.py Removes direct doc_health dependency; routes status reading through the carved module and preserves legacy symbol access via __getattr__.
Review details

Suppressed comments (1)

scripts/ideation_dashboard/doxbench_status_exemption.py:136

  • is_compression_exempt is declared as text: str but is safe for non-strings because lifecycle_status guards with isinstance(text, str). Align the type annotation with the real behavior to avoid incorrect type assumptions at call sites.
def is_compression_exempt(text: str) -> bool:
    """Whether this content is exempt from aggressive compression, read from
    its OWN lifecycle status header."""
    return status_word(lifecycle_status(text)) in EXEMPT_STATUSES
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

Four independent-verifier findings fixed:

F1/F7/F13 - __getattr__ now catches ModuleNotFoundError from
_status_exemption() (raised when the adapter-column module is absent
post-carve) and re-raises AttributeError naming the missing attribute,
chained via `from exc`. Three prose sites already claimed AttributeError
was what happened; it was actually ModuleNotFoundError, which
hasattr()/getattr(default) do not swallow. New test:
test_the_carved_away_case_is_an_ordinary_attribute_error_too.

F2 - test_no_watch_listed_candidate_is_depended_on_anywhere_in_this_slice
(test_doxbench_packet.py) widened to scan doxbench_status_exemption.py:
the 72 moved lines left the file this negative covered, so the sweep
silently narrowed at the carve. Pure widening, no assertion changed.

F3/F8 - test_the_alias_set_cannot_drift_from_what_the_carved_module_defines
rewritten to derive the rail's public surface from its AST rather than
vars(rail) filtered by a value's reported __module__, which drops any
value whose TYPE supplies __module__ (a compiled re.Pattern, e.g. the
rail's own _STATUS_RE, reports __module__ == "re"). Verified by mutation:
a second re.compile(...) constant added to the rail now reds this test.

F4/F9 - PRESERVED_SCANS (test_provider_boundary.py) gained a row for
test_doxbench_status_exemption.py::test_the_carved_module_contains_no_forbidden_spelling,
the one per-module negative-space scan in the package not yet registered.

PR body corrected: "What moved" table's `import re` line cite (65 -> 63),
and a "## Fix round" section disclosing all four fixes.

Copilot review thread (type annotations on lifecycle_status/
is_compression_exempt) answered by reply only: the annotations moved
byte-for-byte from the pre-split code and predate this PR.

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:50

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 carve is well-defended by extensive tests for neutrality and parity, and the only noted issue is a small, non-blocking performance optimization opportunity.

Review details

Suppressed comments (1)

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

scripts/ideation_dashboard/doxbench_packet.py:970

  • exemption_rail scans each source’s text twice: once via rail.lifecycle_status(...) and again inside rail.is_compression_exempt(...) (which re-calls lifecycle_status). Since status is already computed, derive compression_exempt from that value to avoid a redundant header scan per source.
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap
brettheap merged commit 75467fe into main Sep 7, 2026
11 of 12 checks passed
brettheap added a commit that referenced this pull request Sep 7, 2026
…-columns

One real conflict, in tests/ideation-dashboard/conftest.py's
NO_IMPLICIT_PUSH_MODULES tuple: this branch widens it by
serve_workbench.py/serve_project.py/serve_wire.py (§ 2.4 PR 2), main's #741
widens it by doxbench_status_exemption.py (§ 2.4 OQ-1). Resolved by keeping
both sides' additions and both comment blocks. Nothing else conflicted.

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