Skip to content

Derive the dashboard's required header fields from the adapter's classify (split § 2.3) - #728

Merged
brettheap merged 1 commit into
mainfrom
feat/split-2-3-classify-response
Sep 6, 2026
Merged

brettheap merged 1 commit into
mainfrom
feat/split-2-3-classify-response

Conversation

@brettheap

@brettheap brettheap commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

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

What

split-opendox-two-layer-product § 2.3: "authoring.py's REQUIRED_HEADER_FIELDS — today co-authoritative with doc_health.corpus.STATUS_SCAN_LINES — becomes a CLASSIFY response rather than a constant", the operation design.md § D2 names ("what KIND is this document, and which fields does its kind require").

The dashboard's create gate now asks openxFactory's own corpus adapter:

  • authoring.missing_required_headers(text) returns the missing_fields of a classify response, and authoring.required_header_fields() returns its required_fields — both reached through home_corpus() and the interface's six operations, no other route.
  • The field block itself moves to the corpus's shape (corpus_adapter_openxfactory/home.py, the one module permitted to name this repository's own layout). The direction has to invert for the consumer to derive rather than restate: before this PR home.py imported the block from authoring.py, so leaving it there would make the dashboard's answer its own answer, laundered through the adapter.
  • authoring.py consequently stops importing doc_health altogether and stops being one of the readers doc_health/lines.py enumerates as "readers of a lifecycle header that must agree". It cannot drift from the corpus's reader because it no longer reads.

Why this shape (design decisions taken)

1. A proposal is classified as a corpus of one. classify answers about documents a corpus holds — it reads through read, so an unlisted identity refuses. A create gate's whole question is about a body that is not in the corpus yet. So _classify_proposal stages the body in a throwaway tree, under the same prefix the create path writes into, and resolves it through home_corpus(location) like any other location. The alternative — importing the package's classify_text and calling it on a string — is precisely the private door corpus-adapter-seam requirement 4 forbids, and test_no_privileged_route.py fails the build for it. The gate binds exactly one name out of the package (home_corpus), asserted in the new test file as well as by the estate-wide scan.

2. REQUIRED_HEADER_FIELDS is KEPT, as a lazily resolved alias (PEP 562 module __getattr__), not as a constant. Every in-tree production consumer is migrated — after this PR nothing under scripts/ reads the name at all. It is kept because completeness.GOVERNANCE_HEADER_FIELDS deliberately RESTATES the block to keep completeness.py's import graph free of anything that touches the filesystem, and test_completeness.py cross-checks the two so they cannot drift. Keeping the name turns that existing cross-check into a check against the CORPUS's answer — strictly stronger than what it checked before; deleting it would either delete the cross-check or force into completeness.py the import it was written not to have. It is lazy rather than a module-level assignment because an eager REQUIRED_HEADER_FIELDS = required_header_fields() would ask the corpus at import time — a filesystem read during an import, and an ordering hazard between the two packages.

Two tests pin that the alias is derived, not authored: authoring.py is parsed for an assignment (and for the six-name literal under any name) that must not exist, and a different required table — the real adapter class and the real classifier over a mutated shape, substituted through home_corpus — must change both the alias and the gate's answer. A constant left in place passes every parity trivially; these are what make that impossible.

3. obliged_prefixes is now authored in home.py too, and pinned equal to authoring.IDEATION_PREFIX. They answer two different questions over one tree — which tree the header block obliges, and which tree a create may write into (a gate that exists whether or not any header is obliged there). Importing one from the other would put back the edge § 2.3 removes. The existing parity assertion holds them equal and is no longer vacuous, the same treatment scan_roots gets against corpus_root.SCANNED_ROOTS under RULING OQ-4.

4. The parities measure against a frozen oracle, never against the migrated caller. tests/header_contract_oracle.py holds the pre-§ 2.3 algorithm verbatim, with its own copy of the field block and its own window — deliberately not derived, since a derived oracle follows the change it exists to detect. test_openxfactory_adapter.py::test_classify_agrees_with_the_corpus_own_header_readers used to compare classify with authoring.missing_required_headers; since that function is this call now, it was about to become a function compared with itself, so it measures against the oracle instead. One oracle, read by both suites, because hand-copying it would reintroduce inside the tests the pattern this change removes from the code.

Behaviour is byte-for-byte. The signature of missing_required_headers is unchanged (no new parameter): the gate is path-agnostic exactly as before, which is why the proposal is staged under the obliged tree rather than at the caller's own key. render_scaffold is untouched; its rendered skeleton is still asserted header-complete through the migrated gate.

Validation

  • python3 -m pytest -q tests/corpus-adapter tests/ideation-dashboard/test_authoring_classify_derivation.py tests/ideation-dashboard/test_authoring_agent.py tests/ideation-dashboard/test_completeness.py tests/ideation-dashboard/test_header_value_readers.py → 153 passed; tests/corpus-adapter + the new file alone → 29 passed. The full python3 -m pytest -q tests/corpus-adapter tests/ideation-dashboard tests/doc-health → 6557 passed, 31 skipped, 1 failed in 868s, the one failure being the pre-existing environmental test_snapshot.py::test_find_validator_locates_pinned_checkout (it looks for a sibling openxFactory checkout, which a scratch worktree has no parent for). The direction test (tests/doc-health/test_import_direction.py) and all four no-privileged-route scans are green.
  • Parity over the real corpus: whole tree, zero divergence. test_the_migrated_gate_answers_identically_over_the_whole_governed_corpus compares the migrated gate with the frozen oracle over 679 governed documents (both scopes: iter_doc_paths ∪ iter_lifecycle_paths), with a floor assertion so a walk that lost its subject cannot pass, and a companion test asserting the population exercises both the complete and the incomplete answer.
  • Mutation check, run by hand and also permanent in the suite. Adding one field to HOME_SHAPE's table turned 7 tests red across both suites — including the whole-corpus parity, the order test, and the adapter's own header parity — and restoring it returned them to green. The in-suite control (test_a_different_classify_answer_changes_the_gate) does the same thing through monkeypatch, so it runs on every CI run rather than having been true on the day it was checked.
  • OPENSPEC_TELEMETRY=0 openspec validate --all --strict → 97 passed, 1 failed; the one failure is change/disposition-codexfactory-declared-renames, a local untracked artifact that fails identically in a clean origin/main worktree (verified side by side).
  • doc-health --single-repo delta vs a fresh origin/main worktree: ZERO. Both runs exit 0 with byte-identical output once the checkout directory name is normalised.
  • No new skips, so pytest-suite.yml's exact EXPECT_SKIPPED: "21" is unaffected; MIN_SELECTED/MIN_PASSED are floors and only rise.

Scope

Touched: scripts/corpus_adapter_openxfactory/home.py, scripts/ideation_dashboard/authoring.py, one comment in scripts/ideation_dashboard/completeness.py, tests/corpus-adapter/test_openxfactory_adapter.py, and two new test files. Not touched, deliberately: serve.py/cli.py (§ 2.4), doc_health internals, openspec/**, contracts/**, docs/**, README. doc_health/lines.py's reader enumeration is left as it stands — its closing claim ("every one of the readers named above now scans through THIS module") stays true, since the gate's answer is still computed by split_keepends inside classify; the enumeration is historical, and editing doc-health prose is out of this PR's scope.

Offered for Brett Heap's word — nothing here is merged, ratified or landed on my own initiative.

Refs #656

🤖 Generated with Claude Code

https://claude.ai/code/session_01MDVAo41VtZqJQpuawwJeYC

…sify

`split-opendox-two-layer-product` § 2.3: `authoring.py`'s
`REQUIRED_HEADER_FIELDS` — a constant co-authoritative with
`doc_health.corpus.STATUS_SCAN_LINES` — becomes a CLASSIFY response
(design § D2).

The create gate no longer authors the field block and no longer scans for
it: `missing_required_headers` returns the `missing_fields` of the home
adapter's `classify` response, asked through `home_corpus()` and the
interface's own operations. The block itself moves to the corpus's shape
(`corpus_adapter_openxfactory/home.py`), because the direction has to
invert for the consumer to derive rather than restate; `authoring.py`
therefore stops importing `doc_health` altogether, and stops being one of
the readers `doc_health.lines` enumerates as having to agree about a
header window.

`REQUIRED_HEADER_FIELDS` survives as a lazily resolved alias (PEP 562) so
`completeness.GOVERNANCE_HEADER_FIELDS`'s existing cross-check keeps
working — and now measures that deliberate restatement against the
corpus's own answer. Tests pin that the alias is derived and not authored:
authoring.py is parsed for an assignment that must not exist, and a
different table answered through the same interface must change the gate.

Parity: the migrated gate's answer is identical to the frozen
pre-migration one over all 679 governed documents; the adapter's own
header parity now measures against that frozen oracle rather than against
the caller it fed.

Refs #656

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

@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 migration is coherent end-to-end (shape → classify → gate), preserves behavior via an external oracle, and the tests prevent regressions and reintroduction of co-authoritative constants.

Pull request overview

This PR completes §2.3 of split-opendox-two-layer-product by making the ideation-dashboard “required header fields” come from the corpus adapter’s classify response (and therefore from the adapter’s declared corpus shape) rather than from a dashboard-owned constant, while keeping a lazy compatibility alias for REQUIRED_HEADER_FIELDS.

Changes:

  • Move the authoritative required header field tuple into scripts/corpus_adapter_openxfactory/home.py (HEADER_FIELDS) and wire HOME_SHAPE.required_fields_by_kind to it.
  • Update scripts/ideation_dashboard/authoring.py so missing_required_headers(text) and required_header_fields() derive from classify by staging a “corpus of one” under ideation/ and querying via home_corpus().
  • Add a frozen pre-migration oracle plus strong parity/mutation tests to ensure behavior is byte-for-byte unchanged and the value is truly derived (not re-authored).
File summaries
File Description
tests/ideation-dashboard/test_authoring_classify_derivation.py New end-to-end parity + mutation-control tests proving the gate’s answer is derived from classify and unchanged over the governed corpus.
tests/header_contract_oracle.py New frozen pre-§2.3 oracle for header completeness to avoid tautological comparisons post-migration.
tests/corpus-adapter/test_openxfactory_adapter.py Update adapter parities to measure required fields against the oracle and assert the authoring alias reflects the adapter table.
scripts/ideation_dashboard/completeness.py Comment update clarifying the cross-check now measures the restatement against the corpus answer.
scripts/ideation_dashboard/authoring.py Replace local header-scan logic with classify-derived answers; add lazy REQUIRED_HEADER_FIELDS alias via PEP 562 __getattr__.
scripts/corpus_adapter_openxfactory/home.py Author HEADER_FIELDS and OBLIGED_PREFIX in the adapter home shape and remove imports from the dashboard package.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

@brettheap

Copy link
Copy Markdown
Contributor Author

RULING — WORDS — Brett Heap, 2026-09-06T23:03Z, in session (lane openxfactory-4-opendox-extraction, session 01MDVAo41VtZqJQpuawwJeYC), verbatim: "merge 727 and 728 when green" — Path A PR-4 #727 (boundary suite) and § 2.3 #728 (classify-derived header fields) land once green with no unresolved threads and their verifiers passed; landing notes (no openspec/changes/ path); admin squash because brettheap-authored PRs cannot self-clear the code-owner review.

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

@brettheap

Copy link
Copy Markdown
Contributor Author

LANDING (record only — no openspec/changes/ path) — lane openxfactory-4-opendox-extraction, session 01MDVAo41VtZqJQpuawwJeYC, 2026-09-06T23:09Z, PR #728 into openxFactory main on Brett Heap's words "merge 727 and 728 when green"; head 87c2c10, all nine checks SUCCESS, 0 unresolved threads, 0 closing refs, MERGEABLE, no file overlap with main.

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

@brettheap
brettheap merged commit 1a2ea82 into main Sep 6, 2026
11 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

LANDED — lane openxfactory-4-opendox-extraction, 2026-09-06T23:10Z, PR #728 → 1a2ea821 (admin squash at head 87c2c10, 23:09:51Z). § 2.3 realized.

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

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