Skip to content

Land the corpus-adapter seam: the interface and openxFactory's own adapter package (split § 2.2, § 2.2a) - #725

Merged
brettheap merged 7 commits into
mainfrom
feat/split-2-2-corpus-adapter-seam
Sep 6, 2026
Merged

brettheap merged 7 commits into
mainfrom
feat/split-2-2-corpus-adapter-seam

Conversation

@brettheap

Copy link
Copy Markdown
Contributor

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

What and why

split-opendox-two-layer-product § 2.2 — name the corpus adapter's operations and land them as an interface in-tree ("a repository created before the interface exists has its boundary drawn by whatever git filter-repo happened to move") — and § 2.2a, RULING DQ-1's own task: stand up openxFactory's conformant adapter package beside scripts/doc_health/, "reached by no route the interface does not define".

Design basis: § D2 (the four-operation table, the two derived operations, and the neutral-module placement rule PR #724 already realized once for the write guard), § D3's third column (the fifteen requirements that stay here as openxFactory's own adapter; the apply lane a permanent fixture of it under Q1), § D6 parts 1–4 (in particular part 3, the neutral conformance corpus "every destination passes").

The seam capability's four requirements, and where each is discharged:

requirement discharged by
1 — the dependency points ONE WAY scripts/corpus_adapter.py imports neither reader package nor any implementation (stdlib + typing), asserted by parsing. A closed-member @runtime_checkable Protocol rather than an ABC, so an implementation authored in another repository conforms without importing anything from openxFactory — which is the property the seam exists for.
2 — fail closed on an unresolvable corpus CorpusRefused carrying a structured Refusal that always NAMES its subject; absent / not-a-directory / unclassifiable-shape / unknown-revision each refuse, and an empty corpus returns (). The conformance suite runs its own fail-closed check against a deliberately forgiving adapter and requires it to FAIL.
3 — the governed write path is the only write path write_back DISPATCHES and returns a receipt; nothing in the package opens a file for writing. The home corpus declares the apply lane and reports it unavailable (the lane cannot yet carry edit-apply), so the write refuses by name and the bytes on disk are asserted unchanged. A TreeWritingAdapter is run through the same check and required to FAIL.
4 — one implementation, no privileged path The class carries no path literal and no home branch; four parsed scans police the routes; the same class serves a neutral corpus with no openspec/, no contracts/, no lifecycle headers.

The interface as landed

scripts/corpus_adapter.py — six methods, no properties, closed against OPERATIONS:

def resolve(self, ref: CorpusRef) -> ResolvedCorpus
def list_documents(self, corpus: ResolvedCorpus, scope: str = SCOPE_ALL) -> tuple[DocumentId, ...]
def read(self, corpus: ResolvedCorpus, document: DocumentId, revision: str | None = None) -> Document
def classify(self, corpus: ResolvedCorpus, document: DocumentId) -> Classification
def check(self, corpus: ResolvedCorpus, subjects: tuple[DocumentId, ...] | None = None) -> tuple[Finding, ...]
def write_back(self, corpus: ResolvedCorpus, document: DocumentId, content: bytes, *,
               actor: str, basis_revision: str, reason: str = "") -> WriteReceipt

Plain frozen dataclasses only (CorpusRef, ResolvedCorpus, DocumentId, Document, Classification, Finding, WriteReceipt, Refusal), eight stable refusal kinds, and no home vocabulary anywhere in the file — prose included.

Adapter package layout

scripts/corpus_adapter_openxfactory/
  __init__.py    exports exactly ("OpenxFactoryCorpusAdapter", "home_corpus")
  shape.py       CorpusShape / Scope / WritePath / WriteProposal — construction DATA, no literals
  home.py        HOME_SHAPE + home_corpus(); the ONLY module that names this repo's layout
  adapter.py     OpenxFactoryCorpusAdapter — exactly six public methods
  classify.py    kind detection + the required-field answer, driven by shape
  check.py       doc-health delegation and the Finding mapping
  write_path.py  the apply-lane descriptor, its request artifact and its dispatcher seam

home_corpus() is a FUNCTION, and __init__ imports home.py on the call: importing the package never imports the home layout, so it can be exercised against a corpus it does not own. Nothing in the package's neutral core imports home.py at all — the class has no name for the home corpus, so it cannot branch on it.

Design decisions taken

Everything the implementation memo left open, with its basis.

Shape

  1. A Scope per name, each with its OWN exclusion set (memo sketched one shared excluded_parts). corpus.py states that the evidence filter "belongs to this set alone"; a shared set would have re-merged what govern-openspec-corpus-membership OQ-2 deliberately kept apart. Parity-tested: each scope equals what its owning function returns.
  2. obliged_prefixes — a field the memo did not sketch. The six-field header block is the ideation header contract; it governs documents under that tree, not the whole governed corpus. Applying it corpus-wide would report docs/ documents as missing Topics: — a false finding, the failure class this repository has already paid for. Derived from authoring.IDEATION_PREFIX, the constant the create path already enforces it with.
  3. required_fields_by_kind[None] is the DEFAULT, covering both an unlisted kind and an unclassifiable document. That second half is what makes the parity exact: a document missing Kind: is a document missing a required field, so one answer covers both, and classify(...).missing_fields == tuple(authoring.missing_required_headers(text)) holds over real documents.
  4. Unclassifiable ⟺ no value for the shape's kind field. Mechanical and honest; 61 of 420 governed home documents are unclassifiable on this rule, and each is REPORTED by name and still listed.
  5. The verdict is construction DATA (a callable), with a groups narrowing. Two reasons: a corpus with no verdict machinery must be expressible (the neutral corpus returns ()), and a full home verdict is a two-minute run while the conformance suite is a per-PR gate. Narrowing is a construction argument any implementation may offer over its own corpus — it adds no operation and opens no route — and the full mapping is pinned separately, 1:1 against run_suite's own output.

Behaviour
6. Subject normalization in check. doc-health legitimately reports findings against paths that are not governed documents. The interface says a subject is a document key or the corpus name, so an unlisted path becomes a corpus-wide finding with its original path carried into the message — nothing is lost and the interface's rule stays literally true.
7. Guard ORDER in write_back: read-only → unreachable → routing → build → correlate → dispatch. A refusal therefore cannot have produced a side effect on its way to being raised.
8. WritePath.routes. The lane's edit-apply targets a change_id, so a document outside a packet has no target on the path; answering None rather than inventing an id keeps the refusal honest. Archived packets resolve to the dated id; anything that is not one safe segment refuses before a request is built.
9. The request artifact carries the body — as text, or base64 when it does not decode, with sha256 always — and is shape-checked against the lane's own shape_error before it is returned. A request this repository builds can never be one the lane would reject on arrival; a self-built request that fails raises, because that is a defect here and not a refusal of the caller.
10. The correlation identifier is intent_apply_lane.request_digest, not a second identity function.
11. Versioned ⟺ a version marker at the corpus ROOT. A plain tree of documents has no revision notion (which the interface declares legal) and a caller naming one is refused. Without this, a fixture directory inside a checkout would answer with the enclosing repository's revision — a different corpus's answer.
12. A per-instance listing cache keyed by (location, revision, scope). read decides membership by asking the listing — one definition, so no second membership rule can disagree with the first — and re-walking per read would make classifying a corpus quadratic in its own size. Stability is asserted against a fresh adapter, so an implementation that merely remembers its last answer cannot pass.
13. A scope may be NAMED all (the neutral corpus declares exactly that and nothing else — the smallest conformant shape), so resolve de-duplicates the scope names it announces.
14. Listing order is the sorted posix keys, which differs from iter_doc_paths' Path-parts sort (docs/a-b.md vs docs/a/b.md). The parity tests therefore compare SETS and assert sortedness separately.
15. home_corpus() returns (adapter, ref) as a NamedTuple, so the two-name public surface is genuinely usable without reaching into the package.

Tests
16. The vocabulary scan is two scans of different strictness — the interface over its WHOLE SOURCE (literals, comments, docstrings), the package over its string LITERALS only, with docstrings and bare string statements excluded from the latter. The interface is what every implementer of the standard reads; the package's docstrings must stay free to name what they delegate to, or the test becomes an argument for deleting true documentation.
17. A fourth scan in test_no_privileged_route.py: nothing in the package's neutral core may import home.py. This is the structural half of requirement 4 — the class cannot branch on a corpus it cannot see.
18. The six signatures are pinned as text. An implementation outside this repository conforms to that text and to nothing else, so it may change (the interface is provisional) but not quietly.
19. bound_names and string_literals join the two lifted scanners in tests/import_scan.py — a package must be importable while reaching past its declared names is not, and a vocabulary scan must not read the docstring that explains it.
20. The fixture README lives OUTSIDE neutral/. A document explaining which words the neutral corpus omits would contain every one of them.
21. OQ-2 is enforced structurally as well as by scope: the package imports neither doc_health.pin_class nor doc_health.inventory.
22. INTERFACE_PROVENANCE says "openDox's own governance instance" rather than the ruling's literal "openDox's OpenSpec". The tool's own name is home vocabulary the whole-source scan bans from that file, and the file is the one that travels. The substance of OQ-1 is unchanged; flagged here because it is the ruling's wording that moved.

The four rulings of 2026-09-06 (openxFactory #656), applied

  • OQ-1 — YES, a PROVISIONAL marker. INTERFACE_PROVENANCE is a module constant and the same sentence opens the docstring; test_conformance.py::test_the_interface_declares_itself_provisional asserts it names both who ratifies (openDox) and what openxFactory authors instead (the terms of consumption). This forecloses a later "openxFactory wrote openDox's standard" objection.
  • OQ-2 — NO. classify returns kind + required/missing fields only. pin_class and inventory.artifact_type_for stay doc-health internals, and test_ruling_oq2_holds_the_other_classification_vocabularies_out asserts the package does not even import them — so no home-only operation is created.
  • OQ-3 — SEED HERE. tests/corpus-adapter/fixtures/neutral/ is the neutral conformance corpus (two roots of its own, three documents, a Type:/Title: vocabulary belonging to no governed repository, one document deliberately unclassifiable). tests/corpus-adapter/fixtures/README.md documents it as the seed handed upstream at § 3.7, and test_conformance.py is implementation-agnostic and adapter-factory-parameterized with ONE fenced implementation-aware block, so handing the pair over is a move rather than a rewrite.
  • OQ-4 — ADAPTER'S OWN. resolve uses the adapter's own shape data; corpus_root.py is untouched; test_the_scan_roots_are_the_roots_a_projection_is_built_from pins HOME_SHAPE.scan_roots == corpus_root.SCANNED_ROOTS so the duplication fails closed instead of drifting. The collapse is filed to § 2.4, where the entrypoint repoint reaches cli.py's --repo-root and serve.py's --checkout-root.

Validator outputs

Run in a detached scratch worktree at origin/main = 310fd64f, each against a fresh origin/main worktree as baseline.

1. The new suite

$ python3 -m pytest tests/corpus-adapter -q
......................................................................   [100%]
70 passed in 3.05s

2. tasks.md § 2.6's own gate

$ python3 -m pytest tests/ideation-dashboard tests/doc-health -q
FAILED tests/ideation-dashboard/test_snapshot.py::test_find_validator_locates_pinned_checkout
1 failed, 6327 passed, 31 skipped, 7 warnings in 846.07s (0:14:06)

That one failure is pre-existing and environmental, confirmed by running it alone on a clean origin/main worktree: find_validator looks for a sibling openxFactory checkout, which a scratch worktree does not have (assert None is not None). It is not reachable from anything in this PR.

3. The required check's own command

baseline (clean origin/main):  96 failed, 9487 passed, 110 skipped, 338 deselected, 50 errors, 72 subtests passed in 1470.38s
this branch:                   96 failed, 9557 passed, 110 skipped, 338 deselected, 50 errors, 72 subtests passed in 1389.80s

Delta: passed +70 (exactly the new tests), failed +0, skipped +0, errors +0. The FAILED/ERROR node-id sets were diffed after normalizing the worktree name and are identical (146 = 146, empty diff).

A scratch worktree cannot reproduce CI's environment — it has no aggregation layout, no pinned decision core and no submodules — so skipped reads 110 here rather than the pinned 21, on the baseline as much as on the branch. What the pin is protecting against is a NEW skip, and this change adds none: the skipped count is unmoved and no skipif is introduced anywhere. SELECTED/PASSED rise by 70. No floor needs to move.

4. OpenSpec

$ OPENSPEC_TELEMETRY=0 openspec validate --all --strict
✗ change/disposition-codexfactory-declared-renames
Totals: 95 passed, 1 failed (96 items)

The identical single failure appears on a clean origin/main worktree (Totals: 95 passed, 1 failed (96 items)) — the known local artifact, reported only. Delta zero. This PR makes no openspec/ edit of any kind.

5. doc-health self-gate

$ python3 scripts/doc-health.py --single-repo .    # branch vs fresh origin/main worktree
ZERO DELTA   (297 lines each, byte-identical after normalizing the checkout directory's name)

Mutation checks on the new guards — each run once, then restored:

mutation result
adapter.py imports .home test_the_adapters_neutral_core_cannot_see_the_home_layout FAILED
a module under scripts/ does from corpus_adapter_openxfactory.home import HOME_SHAPE test_nothing_under_scripts_reaches_past_the_two_public_names FAILED
HOME_ROOT = "openspec" added to scripts/corpus_adapter.py test_the_interface_carries_no_home_vocabulary_anywhere_in_its_source FAILED

After restoring all three: 70 passed, and git status back to the committed tree.

Explicitly out

  1. § 2.3 — authoring.py is untouched; REQUIRED_HEADER_FIELDS stays a constant and the adapter MIRRORS it under a parity pin, which is what makes § 2.3 a deletion rather than a re-derivation.
  2. § 2.4 — no serve.py/cli.py split, no route or subcommand extension point. The corpus_root collapse is filed there.
  3. No consumer migration. The adapter lands with zero in-tree consumers, by design; its exercise is the conformance suite, which runs it against the real home corpus on every CI run, so it cannot rot silently.
  4. No reading of arbitrary history. read serves the resolved revision and refuses others; doc_health.corpus.RealGit is unchanged.
  5. Nothing moves out of openxFactory. No git filter-repo, no openDox/openXdox repository, no carve manifest, no pin declarations.
  6. § 2.5 — the apply lane is not hardened, and no intent-apply.yml dispatch, real or dry-run, is performed by this PR or its tests. The flip test injects a recording callable that invokes nothing.
  7. No openspec/ edit of any kind — including ticking the 2.2 / 2.2a boxes and the README OpenSpec Records block. That bookkeeping is a separate PR, and that is the PR which takes the Rule 6 landing window, not this one. No landing window is owed here.
  8. No contracts/ edit — the request artifact is built to the existing gate-intent.schema.yaml.
  9. No README / doc-index edit and no new docs/ document, so doc-health's corpus census does not move (measured: zero delta).
  10. No new pytest marker and no new skip.

Notes for review

  • The one permitted existing-file edit is tests/doc-health/test_import_direction.py: two imports replacing two local helper definitions. Its three tests and every assertion in them are unchanged, and it passes.
  • Every co-authoritative constant the adapter needs is DERIVED from the module that owns it, not restated; the two that cannot be derived (the kind header's name, and that this corpus is versioned) are pinned by parity tests against the readers that own them.

Refs #656

This PR does not merge itself. It is offered for Brett Heap's word.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WoVQPAyEUXZf9S779gRVbo

brettheap and others added 4 commits September 6, 2026 10:41
Six operations as one closed-member `@runtime_checkable` Protocol at the top of
`scripts/`, in neither reader package and importing neither — the placement rule
design D2 states and PR #724 realized once for the write guard, applied to the
module both readers will consume (§ 2.3, § 2.4) and that travels to openDox with
the carve.

Design D2 names four operations plus two derived ones; `DESIGN_NAMES` declares
the one rename (`list` is a builtin). All six members are methods, so
`isinstance` and `issubclass` both work and `__protocol_attrs__` is readable as
the closure a companion test compares against.

Structural rather than nominal conformance is the choice, and the reason is in
the docstring: an implementation authored in another repository must conform
without importing anything from openxFactory, which is what requirement 1 is
about. An ABC would make the seam the dependency it was drawn to remove.

RULING OQ-1 (#656, 2026-09-06, YES): `INTERFACE_PROVENANCE` marks the in-tree
signatures PROVISIONAL — openDox ratifies them, openxFactory authors the terms
of consumption — and the conformance suite asserts the marker.

RULING C2: no home vocabulary anywhere in this file, prose included.
Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WoVQPAyEUXZf9S779gRVbo
… RULING DQ-1)

Beside `scripts/doc_health/`, one implementation of the § 2.2 interface over
this repository's corpus, reached by no route the interface does not define.

SHAPE AS DATA IS WHAT MAKES REQUIREMENT 4 TESTABLE. The class carries no path
literal and no home branch: everything it knows arrives as a `CorpusShape`, and
`home.py` is one value among others. That is what lets design D6 part 3's
neutral conformance corpus be served by the SAME class with the same code path
— the design's own "only mechanical proof" that the no-privileged-route rule
holds for the home corpus. Nothing in the package's neutral core imports
`home.py`, so the class cannot branch on the home corpus: it has no name for it.

Delegation: `resolve` is the adapter's own shape-driven structural test (RULING
OQ-4: adapter's own; parity-pinned against `corpus_root.SCANNED_ROOTS`, collapse
filed to § 2.4) with `RealGit.resolve_ref` for the revision half; the two scopes
resolve `iter_doc_paths`' and `iter_lifecycle_paths`' ruled globs SEPARATELY,
never merged; `classify` mirrors `corpus.parse_kind` and
`authoring.missing_required_headers` through the shared real-line rule; `check`
builds a `doc_health` Context directly and maps findings onto the neutral shape
with the grouping and rule inside the OPAQUE code.

WRITE-BACK NEVER WRITES. This corpus DECLARES the apply lane (RULING Q1) and
that lane cannot yet carry `edit-apply` (LANE_DEFERRED_VERBS), so `resolve`
reports the path unavailable and `write_back` refuses WRITE_PATH_UNREACHABLE
naming it — requirement 3's own third scenario rather than a gap. § 2.5 flips
one construction argument and the refusal becomes a receipt; no dispatch, real
or dry-run, is performed here.

RULING OQ-2 (NO): classify answers kind + required fields only. `pin_class` and
`inventory.artifact_type_for` stay checker internals and the package does not
import them.
Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WoVQPAyEUXZf9S779gRVbo
`test_import_direction.py` defined `_imported_modules` and
`_names_a_forbidden_package` for § 2.1's direction; § 2.2/2.2a needs the
identical pair for a different one. Hand-copying an AST scanner is the
co-authoritative-constant pattern this repository repairs elsewhere, and the
copy that drifts is the one that silently stops catching things.

Two more scanners join them: `bound_names`, which answers what an import BINDS
so a package can be importable while reaching past its declared public names is
not, and `string_literals`, which excludes docstrings and bare string statements
so a module that may not USE a word is still free to explain why.

`tests/hermeticity.py` is the precedent for a helper at the `tests/` root. The
edit to `test_import_direction.py` is two imports; its three tests and every
assertion in them are unchanged.
Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WoVQPAyEUXZf9S779gRVbo
…formance

Five modules under `tests/corpus-adapter/` and the neutral corpus they run over.
No new conftest — `pytest.ini` anchors rootdir and says at length why a new
per-directory conftest is the wrong answer to a rootdir problem.

  * closure — the Protocol's members ARE `OPERATIONS`, the class declares no
    seventh public method (parsed, so a method that fails to import still
    counts), the package exports exactly two names, and the six signatures are
    pinned as text because an implementation outside this repository has nothing
    else to conform to. Negative control on a synthetic seventh operation.
  * no privileged route — four scans: nothing under `scripts/` binds past the
    two public names; the interface imports neither reader package nor any
    implementation; the package's neutral core cannot even import `home.py`.
    Negative control on four spellings of the same door, asserted on the count.
  * no home vocabulary (RULING C2) — two scans of deliberately different
    strictness: the interface over its WHOLE SOURCE, the package over its string
    LITERALS, with `home.py` and `write_path.py` exempt because naming the home
    layout is their job — and a test that the exemption still covers something.
  * conformance (RULING OQ-3: SEED HERE) — written against `corpus_adapter`
    alone, parameterized by an adapter FACTORY, with ONE fenced
    implementation-aware block, so handing it and `fixtures/neutral/` upstream at
    § 3.7 is a move rather than a rewrite. It has TEETH: two deliberately
    non-conformant adapters (one that forgives an absent corpus, one whose
    write-back writes the tree) are run through the suite's own fail-closed
    checks and required to FAIL, so requirements 2 and 3 are enforced by the
    suite rather than by the implementation's goodwill.
  * home parities — every co-authoritative constant pinned against the module
    that owns it: scan roots against `corpus_root.SCANNED_ROOTS`, both scopes
    against `iter_doc_paths`/`iter_lifecycle_paths`, the field table against
    `authoring.REQUIRED_HEADER_FIELDS`, classify against `parse_kind` and
    `missing_required_headers` over forty real documents, and a fixture whose
    header sits on the LAST real line of the window behind a U+2028 — the
    `align-status-reader-to-real-lines` invariant. Plus the verdict mapping 1:1
    against `run_suite`'s own output, and the § 2.5 flip proven with a recording
    dispatcher that invokes no workflow.
Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WoVQPAyEUXZf9S779gRVbo
Copilot AI lite review requested due to automatic review settings September 6, 2026 14:44

@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

There are confirmed correctness issues in the new shared scanner (string_literals docstring exclusion bug) and in the adapter’s write-back/revision guards that can lead to incorrect behavior or runtime crashes.

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

Pull request overview

This PR introduces an in-repo “corpus adapter” seam: a neutral CorpusAdapter interface (scripts/corpus_adapter.py), plus openxFactory’s own conformant implementation (scripts/corpus_adapter_openxfactory/) and a new conformance test suite (tests/corpus-adapter/) with fixture corpora.

Changes:

  • Add scripts/corpus_adapter.py defining the sealed six-operation CorpusAdapter Protocol plus refusal/data types.
  • Add scripts/corpus_adapter_openxfactory/ implementing the interface via shape-driven construction, verdict mapping, and a declared (currently unreachable) governed write-path descriptor.
  • Add a new conformance suite + fixture corpora under tests/corpus-adapter/, and factor shared AST import scanners into tests/import_scan.py (used by direction/privileged-route tests).
File summaries
File Description
tests/import_scan.py New shared AST scanners for import-direction / vocabulary policing tests.
tests/doc-health/test_import_direction.py Switches to shared scanners from tests/import_scan.py; assertions unchanged.
tests/corpus-adapter/test_openxfactory_adapter.py Parity tests pin the home adapter against existing doc-health / dashboard readers and lane helpers.
tests/corpus-adapter/test_no_privileged_route.py Scans for forbidden import routes and ensures interface/package neutrality constraints hold structurally.
tests/corpus-adapter/test_no_home_vocabulary.py Vocabulary scans enforcing that home-only nouns/paths don’t leak into the interface / neutral core values.
tests/corpus-adapter/test_interface_closure.py Pins the interface’s closed six-method surface and the implementation’s lack of a 7th operation.
tests/corpus-adapter/test_conformance.py Implementation-agnostic conformance suite run over neutral/empty/home corpora, plus negative controls (“teeth”).
tests/corpus-adapter/fixtures/README.md Documentation for the conformance fixtures and their intent.
tests/corpus-adapter/fixtures/not-a-directory Fixture file used to assert resolve refuses “not a directory”.
tests/corpus-adapter/fixtures/neutral/papers/gamma.md Neutral fixture doc deliberately missing kind/type header.
tests/corpus-adapter/fixtures/neutral/notes/beta.md Neutral fixture doc missing a required field for findings.
tests/corpus-adapter/fixtures/neutral/notes/alpha.md Neutral fixture “complete” document.
tests/corpus-adapter/fixtures/empty/papers/.gitkeep Keeps empty fixture directories in git.
tests/corpus-adapter/fixtures/empty/notes/.gitkeep Keeps empty fixture directories in git.
scripts/corpus_adapter.py New neutral interface module: types, refusal model, and six-operation Protocol.
scripts/corpus_adapter_openxfactory/init.py Public surface: exports only OpenxFactoryCorpusAdapter and home_corpus() (lazy import of home layout).
scripts/corpus_adapter_openxfactory/write_path.py Declared write-path descriptor + request artifact builder and correlation-id computation.
scripts/corpus_adapter_openxfactory/shape.py Shape/Scope/WritePath/WriteProposal data used to parameterize the adapter without embedding home literals.
scripts/corpus_adapter_openxfactory/home.py Home-corpus-specific shape construction, derived from existing owning modules, plus home_corpus().
scripts/corpus_adapter_openxfactory/classify.py Shape-driven kind detection and required/missing field computation (mirrors existing readers).
scripts/corpus_adapter_openxfactory/check.py Verdict adapter mapping doc-health findings into neutral Finding values and normalizing subjects.
scripts/corpus_adapter_openxfactory/adapter.py The concrete six-method adapter implementation (resolve/list/read/classify/check/write_back).
Review details
  • Files reviewed: 20/22 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.

Comment thread tests/import_scan.py Resolved
brettheap and others added 2 commits September 6, 2026 11:21
…r's reference

Two defects found by review, each an instance of the same mistake: an answer the
adapter is supposed to GIVE was being read back in as an answer it could TRUST.

WRITE-BACK GATED ON THE CALLER'S FLAG (adapter.py). `ResolvedCorpus` is plain
data, so a caller can hand-build one and never pass through `resolve` at all —
and `write_back` decided whether the governed write path was reachable by
reading `corpus.write_path_available` off that reference. A forged
`write_path_available=True` therefore walked past the guard and into
`write_path.dispatch`: a TypeError today, because nothing is injected, and a
REAL DISPATCH the moment § 2.5 injects one. That makes the gate advisory, which
is the opposite of requirement 3 — 'the gate is the act of passing through the
path'. Reachability now comes from `write_path.available`, the adapter's own
descriptor, and the reference is checked for AGREEMENT instead: a reference
naming a path this adapter does not declare is a refusal, never a dispatch
through whichever path the adapter happens to hold, and a reference that
disagrees the other way fails closed rather than having the disagreement settled
inside a write.

REVISION DEGRADED INSTEAD OF REFUSING (adapter.py). `_revision` returned None —
'this corpus has no revision notion', which the interface declares legal — for a
tree that plainly DID have one and whose ref would not resolve. The concrete
case is an unborn HEAD: initialized, nothing committed. The marker is there,
`HEAD` resolves to nothing, and every read would then stamp its bytes with a
revision of None, indistinguishable from the plain directory tree beside it.
That is the exact shape requirement 2 forbids — 'SHALL NOT degrade to an empty
result, to a partial listing, or to a skip'. None now means ONE thing (no
version marker at the root); a versioned corpus whose ref will not resolve
refuses REVISION_UNKNOWN, naming the ref, and the DEFAULT ref is named for the
same reason a requested one is.

Both are proven by mutation, not by inspection. Reverting the first reproduces
the reviewer's own demonstration verbatim — `TypeError: 'NoneType' object is not
callable` on `openspec/changes/add-identity-brokering/proposal.md`; reverting
the second reds the unborn-HEAD test.

The forgery check is a conformance case, factory-parameterized and naming no
implementation, and it samples a SPREAD across the listing rather than its head:
the first draft took `listed[0]`, which for this corpus has no target on the
declared path, so every forgery met the routing refusal instead and the check
passed over the defect it was written for. A test that cannot fail is worse than
no test, so the sample now reaches documents that really do route.
Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToeHpuM688VACctz1iN4dN
Copilot AI review requested due to automatic review settings September 6, 2026 15:39

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 introduces a new cross-repository interface boundary and enforcement suite whose long-term contract implications warrant final human review despite strong test coverage.

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

TEST-ONLY. No adapter behaviour changes; what changes is whether the suite can
see it.

Re-verification found that the forged-reference check never reached the guard it
was written for. All three fixtures resolved against a write path that was
either absent (neutral, empty) or declared-and-unavailable (home), so the
availability guard behind the name check caught every forgery first — and
DELETING the name-mismatch guard left all 75 tests green. A suite that cannot
tell two guards apart is testing neither.

So there is a fourth fixture: the home shape with a recording dispatcher
injected, which is the one construction argument § 2.5 will flip. Its path is
genuinely reachable, and it proves BOTH sides in order, because each is the
other's control — first a legitimate resolve() + write_back must actually
dispatch (otherwise "it refused" proves nothing, since a corpus that refuses
everything passes every assertion about refusing), then the SAME document under
a reference naming a path this adapter does not serve must refuse AND leave the
dispatch count unmoved. A refusal raised after the path was already entered is
worse than no refusal, so the count, not the exception, is what settles it. The
dispatcher records and does nothing: no workflow is invoked.

Two consequences for the generic checks, both of which make them more honest
rather than more permissive:

  * Forging AVAILABILITY is only a forgery on a corpus that reported itself
    unavailable. Where the path is already open there is nothing to forge and a
    successful write is correct. Which case applies is read from the adapter's
    own report, so the check stays a statement about any implementation.
  * An AVAILABLE path may still refuse a particular document that has no target
    on it, so `check_write_back_honours_what_resolve_declared` no longer asserts
    that a WRITE_PATH_UNREACHABLE refusal implies the path was unavailable. The
    direction that IS implied — a receipt means the path was open — is asserted
    instead.

The suite stays implementation-agnostic: the new fixture, its recorder and the
count-reader live in the one fenced block, and every assertion outside it names
no implementation and reads only a number.

Mutation-checked. Deleting the name-mismatch guard now reds two cases:
`test_a_forged_reference_cannot_open_the_write_path[dispatchable]` ("the renamed
forgery over openspec/changes/add-identity-brokering/proposal.md was accepted")
and `test_a_reachable_write_path_dispatches_once_and_only_for_its_own_name`
("DID NOT RAISE CorpusRefused").

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

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 correctness gap in the new tests/import_scan.py::bound_names() helper (alias handling) undermines the “bind only these names” enforcement described by its callers.

Review details

Suppressed comments (1)

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

tests/import_scan.py:84

  • bound_names() claims to report the bound name for from pkg import ... statements, but it currently yields alias.name and ignores as aliases. That means from corpus_adapter_openxfactory import OpenxFactoryCorpusAdapter as Adapter would be treated as binding the public name even though the actual bound identifier differs, which undermines the “bind only these names” policy described by this helper and its callers.
  • Files reviewed: 20/22 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap

Copy link
Copy Markdown
Contributor Author

RULING — WORDS — Brett Heap, 2026-09-06T17:42Z, in session (lane openxfactory-4-opendox-extraction, session 01ToeHpuM688VACctz1iN4dN), verbatim: "merge 725 and 304 when green" — openxFactory PR #725 (§ 2.2 + 2.2a corpus-adapter seam) and xFactory PR #304 (Path A PR-3 custody wiring) land once green with no unresolved threads; neither touches openspec/changes/, so landing notes rather than Rule 6 windows; admin merges because brettheap-authored PRs cannot self-clear the review rules.

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 01ToeHpuM688VACctz1iN4dN, 2026-09-06T17:42Z, PR #725 into openxFactory main on Brett Heap's word "merge 725 and 304 when green"; head 482a231, all nine checks SUCCESS, 0 unresolved threads, 0 closing refs, MERGEABLE.

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

@brettheap
brettheap merged commit ea4e6ff into main Sep 6, 2026
10 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

LANDED — lane openxfactory-4-opendox-extraction, 2026-09-06T17:46Z (merge at 17:43:00Z), PR #725 → ea4e6ff2 (admin squash at head 482a231, on Brett Heap's words "merge 725 and 304 when green"). § 2.2 + § 2.2a realized; ticks come with the group-2 bookkeeping PR.

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
brettheap added a commit that referenced this pull request Sep 17, 2026
…ty, and the fifteen carried into it (#1071)

Lane: openxfactory-4 (openXfactory-4-openDox_extraction)

Refs #656 (stays OPEN).
CLAIM: [`5703096449`](#656 (comment))

**`split-opendox-two-layer-product` § 5.2a, realized: the FIFTEEN engineering-vocabulary requirements are RE-PROMOTED under the successor capability this packet authors, `openxfactory-engineering-adapter`.** Filing only — `Status: draft` on all three lifecycle documents, no ratification, no archive, no tick.

## Why now

The box says the successor capability's *"id this task authors"* and says nothing else about it, and **three pieces of live work were waiting on that id**: § 5.6's de-floor, § 8.4's both-directions floor accounting, and two § 6 closures already open — #1060 (§ 6.1's seven `doc-health` requirements) and #1065 (§ 6.5's narrowing) — each of which carried its delta WHOLE rather than re-author it against *"the successor capability id … § 5.2a, unbuilt and assigned to another actor"*. This declares it.

## The id, derived rather than chosen (`design.md` § D1)

| measured at `fa39141c` | what it names the adapter |
|---|---|
| the ratified per-requirement map, **15 of 15** openxFactory rows, identical phrasing | *"openxFactory's OWN ENGINEERING ADAPTER, the small package beside `scripts/doc_health/` that implements openDox's corpus-adapter seam (RULING DQ-1)"* |
| `design.md` § D3 column head · § D1 topology · `proposal.md` (9) | *"the engineering mapping"* · *"its OWN engineering adapter"* · *"a small ENGINEERING ADAPTER PACKAGE"* |
| bigram count over the whole packet | **"engineering adapter" 22** · "corpus adapter" used as ITS name **0** |
| landed § 2.2a package (#725 → `ea4e6ff2`) | `scripts/corpus_adapter_openxfactory/`, sole public class `OpenxFactoryCorpusAdapter` |
| landed § 4.4 profile (#984 → `a1ef886f`) | `contracts/domain-profiles/openxfactory-engineering.yaml`, `mapping_id: openxfactory-engineering` |

Head noun = the packet's own name for it. The `openxfactory-` qualifier stays because `corpus-adapter-seam` requirement 4 (*"one implementation and carries no privileged path"*) is made load-bearing by DQ-1 — an unqualified `engineering-adapter` would read as the NEUTRAL capability, which is openDox's under RULING Q4. Spelling is fixed by the two landed machine names. Rejected with reasons: `corpus-adapter-seam`, `engineering-adapter`, `corpus-adapter-openxfactory`, `openxfactory-engineering` (taken). **A different id is a one-command rebuild** — the delta is generated, not typed.

## Measured

* **The fifteen come out fifteen.** All 102 `## REMOVED` rows of the packet's map classified by the destination each **Reason** names: **openDox 71 / openXdox 16 / openxFactory 15** — RULING DQ-1's map exactly.
* **Carried, not authored.** Lifted from `openspec/specs/ideation-dashboard/spec.md` BY TITLE by script: 102 promoted requirements, **0 of 15 missing**, titles character-for-character identical (which is what makes the successor a distinct `promotion_fidelity` key), **49,829 source bytes, 84 scenarios**, all fifteen carrying `SHALL` on the FIRST body line.
* **TWO edits, and the count is itself a finding** (NARROWED from six after Copilot rounds 1 and 3 — dispositions in the comments below). Six path-literal occurrences sit in the fifteen; only two name a question the six-wide seam answers as its requirement states it, and both are `resolve`, both in *doxBench resolves its released contract from the checkout it runs in* — the literal the governing `design.md` § D2 names `resolve` for in terms (*"the operation `corpus_root.py` performs today with a path literal"*).
* **The other four are RECORDED NON-EDITS**, each with the operation it would have needed (`design.md` § D2): a topic's EXISTENCE under `ideation/staging/` — `list_documents` lists under DECLARED scopes, the home adapter declares `documents`/`lifecycle` and no staging scope, and the interface's own docstring insists an empty corpus stays distinguishable from an unreadable one, so listing-emptiness cannot carry that refusal; the DESTINATION of authoring the console must not perform; and twice the workspace returned documents land in. **What would unblock them** — a declared staging scope, or an answer that keeps *absent* and *empty* apart — is openDox's to declare under RULING Q4, and `tasks.md` § 4.5 carries it as a BLOCKED box in the shape § 6.1 and § 6.5 used for named-not-performed work.
* **Two further non-edits, for a complete census**: `proposal.md` ×4 (a document's identity — `DocumentId.key` is declared opaque at `scripts/corpus_adapter.py:213-224`), `OPENXFACTORY_ROOT` ×3 (a rung of requirement 10's own ladder). `main` ×1 is a git ref.
* **The carry is proved, and the proof verifies the COMMITTED artifact.** `review/build-delta.py` is committed inside the packet: it aborts unless each declared edit matches EXACTLY ONCE, REVERSES them and asserts byte equality against the promoted text, and — run without `--write` — READS the committed delta and compares, so a hand-edited delta cannot pass. Mutation-proved: clean tree `CHECK PASSED` exit **0**; one word changed in the committed delta `CHECK FAILED` with the diff, exit **1**; the file deleted `CHECK FAILED`, exit **1**.

## Gates on this branch

| gate | result |
|---|---|
| `openspec validate repromote-engineering-vocabulary --strict` (CLI **1.12.0**, the pinned version) | `Change 'repromote-engineering-vocabulary' is valid` |
| `review/build-delta.py .` — the packet's own verifier, in CHECK mode | `CHECK PASSED … byte-identical … 53118 bytes, sha256 c3b985ae…`. Every gate RAISES (no `assert`), proved under `python3 -O`: mutated committed delta exit **1**, broken edit-match exit **1** (`REFUSED: edit matched 0x`), clean exit **0**; a CRLF-edited delta exits **1**; a duplicate promoted title exits **1** |
| `scripts/proposal-support.py . verify` | `proposal support verification ok` |
| `openspec validate --all --strict` | **108 passed, 2 failed (110 items)** — the two are PRE-EXISTING and named: `add-chain-attestation` and `add-composed-view-authoring`, both a MODIFIED block omitting a scenario canon still carries. Neither is this packet's and neither touches the fifteen. |
| `validate-sequenced-after.py . --ledger-diff` | `per-change sweep ledger consistent with the corpus (217 rows)`; the plain run passes (48 active changes, 17 declaring; both archive-date arms pass) |
| `validate-code-surface.py .` (the gate #1029 landed) | passed — 48 active proposals, 48 declaring, 6 `none`, **0 outside the grammar** |
| doc-health `--single-repo . --family promotion-fidelity` | **No findings** — this packet promotes nothing |
| `pytest tests/code_surface tests/sequenced_after` | **439 passed** |
| ARCHIVE DRY RUN (throwaway copy of `openspec/`, pinned CLI) | `openxfactory-engineering-adapter: create` · `+ 15 added` · `Totals: + 15, ~ 0, - 0, → 0`; **0** placeholder occurrences, 15 requirements / 84 scenarios, all fifteen byte-identical delta→promoted, and `openspec/specs/ideation-dashboard/spec.md` sha256 **UNCHANGED** by the run — § D3's "removes nothing", measured |
| **`pytest-suite`** | **RED ON `main` ITSELF and not this branch's** — see comment [`5703461771`](#1071 (comment)). `main` at `4cef77af` runs `1 failed, 7715 passed`, the one failure being `test_modified_block_currency_self_gate.py::test_the_resolution_ordering_and_marker_classes_read_zero_over_the_real_tree` over two OTHER changes' MODIFIED blocks (#1052 and #1050). This packet carries no `## MODIFIED` block at all. |

## What this does NOT do

* **It authors NO second `## REMOVED` block on `ideation-dashboard` — a declared judgment, not an omission** (`design.md` § D3). The packet's ratified map is that removal's single writer; a sixth live writer would be an undeclared sibling collision this box has no authority to declare (that delta's own `## THE SIBLING COLLISION` section enumerates five and handles each); and in one archive order it becomes *"a removal of nothing … applied against a document that never held the title"*, the defect the packet's block (b) refuses. The box's fidelity sentence holds without it — `promotion_fidelity.py` keys `(capability, norm(title))`, so the successor is a distinct key and the packet's REMOVED delta stays visible. **Mechanical corroboration: this packet's own sweep row seeds `class: sole`** — the corpus's machinery agreeing no other change writes any key it writes. **If the ruling goes the other way the block is one file and this lane will author it on the word.**
* No byte of `openspec/changes/split-opendox-two-layer-product/` — no tick, no map row, no design line. No code: nothing under `scripts/`, nothing under `tests/` but the GENERATED sweep-ledger row. Nothing under `contracts/`: no schema, pin, digest, bundle version or release tag. No gitlink, no submodule, no row of `docs/opendox-carve-manifest.yaml`. Nothing under `openspec/specs/` — this delta reaches canon only at an archive.
* It does not ratify and does not archive. `tasks.md` § 1 holds the ratification questions (the id, the six edits, the two non-edits, the § D3 judgment, the § D4 archive order); § 3 holds the archive, which is **sequenced BEFORE the split packet's own** so the fifteen are never in no capability at all (`design.md` § D4).

## Sibling search (three reads, all clear)

No #656 CLAIM names § 5.2a or the successor capability. Of the open openxFactory PRs, exactly one touches `openspec/specs/ideation-dashboard/spec.md` — **#1066**, whose hunks are at `:2249`, `:2267` and an append after `:2590` and which touches **none of the fifteen**; extraction here is title-keyed, so its landing shifts line numbers and changes nothing, and the carry is re-proved mechanically after any merge from `main`. `LANES.md` holds no row on this box.

**Rule 6 applies** (this pull request touches `openspec/changes/` and the README OpenSpec Records block). Brought to READY, **not landed** — the landing window is the holder's.

**Review state.** Seven Copilot rounds, every live finding taken and every thread answered and resolved (**10 threads, 0 unresolved**); the dispositions are in the comments below, including the ONE finding refused with a reason (pytest coverage for a packet-local one-shot helper would make `code_surface: none` false and flip the archive class). `114a9c63` is the final head — later rounds are answered in comments, not by moving it.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>

🤖 Generated with [Claude Code](https://claude.com/claude-code)


Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <[email protected]>
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