Skip to content

BUILD the corpus-adapter IMPLEMENTATION (design § D4 machinery (1)): openXdox's neutral, profile-parameterized reader answers the conformance corpus 17 of 17 - #23

Merged
brettheap merged 28 commits into
mainfrom
build/corpus-adapter-implementation
Sep 18, 2026
Merged

brettheap merged 28 commits into
mainfrom
build/corpus-adapter-implementation

Conversation

@brettheap

@brettheap brettheap commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

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

Refs #656 (stays OPEN).
CLAIM: 5715212503
RULED Q-X1..Q-X4 (Brett Heap, 2026-09-17, by interactive multi-choice; openxFactory#656 comment 5715212264).

What this is

split-opendox-two-layer-product design.md § D4 machinery (1) — "the corpus-adapter IMPLEMENTATION — chart, firm document store, campaign repository: listed, read, written back and checked" — is the one of the seven machineries that no § 4 box commissioned. § 4.5 built three of them and is ticked; § 4.1 names an "adapter implementation" but is a CARVE box whose own text says what it now waits on is "that reconciliation and not a carve". The obligation is written down live in exactly one place, tasks.md § 3.7: "the missing readers are § 3.6's 'trivial conformant adapter implementation' for openDox and § 4's mapping core for openXdox, and they are build tasks at those destinations".

This PR is openXdox's half of that.

Three NEW modules, flat under src/openxdox/, stdlib plus the PINNED opendox.corpus_adapter (RULED OQ-2 / OQ-Q — the interface is openDox's and is never replicated here):

file lines what it is
src/openxdox/corpus_shape.py 451 the per-corpus construction DATA (Scope, WriteProposal, WritePath, CorpusShape) and from_profile(), which derives scan_roots and one scope per artifact kind from a registered DomainProfile's artifact_kinds[].locations
src/openxdox/domain_corpus_adapter.py 880 DomainCorpusAdapter — the interface's six operations over one CorpusShape
src/openxdox/conformance_corpus.py 94 the DECLARED --adapter factory § 3.7's runner resolves

Two NEW test files, appended LAST to .github/workflows/validate.yml's explicit --noconftest list (a file not on that list is silently never run): tests/test_corpus_shape.py (58) and tests/test_domain_corpus_adapter.py (84).

No existing module is edited. The only non-new file this PR touches is the workflow.

The measurement

$ python3 openxFactory/scripts/verify-carve-conformance.py \
      --destination openxdox_code \
      --dest-root   <this checkout> \
      --adapter     openxdox.conformance_corpus:reader
OK <dest-root>: openxdox_code passed the neutral conformance corpus — 17 of 17 check(s),
   reader openxdox.conformance_corpus:reader, corpus <oxf>/tests/corpus-adapter/fixtures
$ echo $?
0

Measured at openXdox-code 589adee7 / openxFactory 7e074ac9, on the first run, and re-measured unchanged after the one fix below. The control in the same session — --destination openxfactory --dest-root . --adapter home_factory:neutral_reader --sys-path tests/carve_conformance — is also OK — 17 of 17, so the runner and the corpus are behaving.

All seventeen, from --json:

structural-conformance (DomainCorpusAdapter satisfies the six) · resolve-populated · list-population (listed 3; this corpus holds 3) · list-stable (sorted/unique/stable) · read-round-trip (165 bytes, identity round-tripped) · classify-population (complete=1 field-absent=1 unrecognizable=1) · classify-reports-unrecognizable (1 unrecognizable, listing still holds 3) · check-severities (0 findings) · empty-is-an-answer · read-only-declared-at-resolution · absent-refuses · unreadable-refuses · unknown-scope-refuses · unknown-document-refuses · unknown-revision-refuses · write-back-refuses-read-only · write-back-leaves-the-tree.

git status --porcelain in the corpus's own checkout is empty after three runs.

Fourteen review rounds, answered

Twenty findings accepted across fourteen rounds (path traversal through a declared .. or a drive letter, a symlink whose target leaves the corpus, an unreadable directory omitted rather than refused, a declared root present as a FILE, Path.exists() reporting an inaccessible path as ABSENT, an over-wide isolation claim in a docstring, a broken .git symlink read as 'no revision notion', confinement checked only at listing and not at read, a declared root that links out of the corpus, a dangling link dropped by is_file() before confinement, a root probed with is_dir() whose OSError it suppresses, a profile location whose padding made its scan root and its glob disagree, a dangling symlink at a corpus path read as ABSENT rather than unreadable, and one resolved corpus invalidating another one's listing snapshot, and a module comment claiming a per-handle "moment in time" a value-keyed memo does not deliver, globs_of reading a trailing \ differently from every other rule in its own module, write_back acting on a document identity it never listed, a declared root that ARRIVES after resolution widening the listing where one that GOES already refused, a reserved-kind-id refusal the docstring promised unconditionally that sat behind a continue, and a confinement check whose bytes were opened by pathname a second time rather than proved to be the file that passed it) and three proposed changes reverted with the measurement that decides each — a replacement glob matcher that silently dropped 2 of 4 documents below depth one, removing the listing cache (0.07s → 58.85s over 801 documents, quadratic), and write_back raising a refusal kind its row of the interface does not name. A fourth was accepted as a FINDING and narrowed as an IMPLEMENTATION: round nine's WeakKeyDictionary for the listing snapshot buys no isolation a plain dict does not (the pinned ResolvedCorpus is frozen=True, eq=True, so it hashes by value), makes the module depend on that dataclass being weak-referenceable (slots=False today, an undeclared property of an interface this leg does not own), and leaves a hand-built ResolvedCorpus — which the interface explicitly permits — uncached and back on the once-per-document walk at 0.17s against 101.38s over 801 documents. The finding is fixed; the map is an ordinary dict keyed by the handle and entered with setdefault. One further proposal — refusing a corpus whose git work tree is dirty — is REGISTERED as a question for Brett Heap rather than decided here, with the argument for it recorded in full. All threads resolved. The whole round is in this comment.

Which rulings this realizes

  • RULING Q4 (#656 5542823211): "openDox defines a corpus-adapter interface; openXdox implements it." The ruling that puts an implementation here at all.
  • RULING C2 (5544370242): openXdox is the domain-mapping core, PARAMETERIZED. from_profile() is where that lives.
  • RULED OQ-1 FLOOR PART 3 (5547060378, § D6 (3)): every destination passes the neutral corpus; openXdox's adapter implementation is named in terms.
  • RULED Q-X2 (a) (5715212264): this is the NEUTRAL, profile-parameterized reader. RULING Q4's second clause — "over openxFactory's corpus and check families" — is recorded SUPERSEDED by C2 and DQ-1, which put the engineering corpus's reader in openxFactory (§ 2.2a, landed ea4e6ff2). Two readers over one corpus would be DQ-1's collapse risk back.
  • RULED Q-X3 (a) (5715212264): kind_field and required_fields_by_kind are CONSTRUCTION DATA on CorpusShape, exactly as openxFactory's § 2.2a shape carries them. No DomainProfile schema change, no openXdox-spec change, no promoted-spec delta.

No transposition, and that is a property of this reader

RULED Q-F1 (a) (5714365086) has openDox's reader transpose the neutral corpus into git repositories, because its location vocabulary IS git history ("THE CORPUS IS THE HISTORY, NOT THE WORKING TREE", RULING C3) — untransposed it scores 1 of 17.

A profile-parameterized filesystem reader's location vocabulary is a directory tree, which is exactly what the corpus is. So the seventeen checks above ran over tests/corpus-adapter/fixtures/ as it ships — same documents, same keys, same bytes, no intermediate form whose fidelity anyone has to prove. Q-F1's problem does not recur at this destination.

No doc_health reach

tests/test_dependency_direction.py's DOC_HEALTH_SURFACE is unchanged at 8 modules / 13 statements, and that file is not edited by this PR:

$ python -m pytest -q tests/test_dependency_direction.py --noconftest \
      -k "doc_health_implementation_surface or no_module_under_src_reaches_its_consumer or deferred_cross_package"
3 passed, 13 deselected

The five modules that would have been the obvious things to reuse — corpus_root, completeness, round_trip, generator, snapshot_registry — all reach doc_health at import time, which is lawful only where § 4.1's second clause already enumerates it. So none is wired in, and the one rule they carry that this reader genuinely needs is adopted rather than imported: the CR/LF/CRLF line rule (align-status-reader-to-real-lines, 2026-08-19), as an eleven-character regular expression, with both halves asserted — that the three real endings split, and that \x0b \x0c \x1c \x1d \x1e \x85 U+2028 U+2029 do not.

check returning () is likewise deliberate and is the interface's own answer, quoted in the module: "a corpus with no verdict machinery of its own honestly returns (); that is an answer, not a refusal, and a consumer must not read it as 'clean' without asking whether the corpus judges at all." completeness.py is not wired in — it would drag openxFactory's check families into a neutral reader. openXdox ships no verdict provider for the same reason it ships no status words: a check family is a domain's judgement and this package has no domain. A descendant injects one through CorpusShape.verdict, and check-severities passes on the empty answer.

Suite, and every assertion mutation-proved

$ python -m pytest -q <the 16 files validate.yml names> --noconftest
520 passed, 6 skipped         (360 + 6 is the list as this act found it)

$ python -m pytest -q tests/test_corpus_shape.py tests/test_domain_corpus_adapter.py --noconftest
160 passed, 0 skipped, 0 errors

mutate.py (persisted with this lane's evidence, not added to this repository) applies 69 deliberate defects one at a time to corpus_shape.py and domain_corpus_adapter.py and runs the two files against each: the file-location refusal answering corpus-unclassifiable; the declared write path becoming a module constant; read falling back to a revision nobody asked for; an undeclared scope widening silently; write_back writing the tree; a forged reference naming another write path being trusted; the line rule breaking on exotic separators; the reader adopting an enclosing repository; the header window going unbounded; a declared location carrying ..; a symlink escaping the corpus; the listing cache removed; a dangling symlink at a corpus path reading as absent rather than unreadable; one resolved corpus invalidating another one's listing; a declared directory ended with a Windows separator being read as a document pattern; write_back dispatching another corpus's document identity; a declared root that ARRIVES after resolution being walked into the listing; the bytes served not being proved to come from the file that passed confinement; and fifty-one more.

ALL 69 WERE CAUGHT — 0 survivors.

Two survived a first sweep and both are fixed in this PR rather than argued away:

  1. A loose assertion. A profile declaring no locations was refused by the empty-scan-roots guard two lines later, whose message also contains the word "locations", so the test passed on the wrong refusal. It now pins the refusal it means.
  2. A real hole, and the sharper of the two. _git inherited the ambient environment, and GIT_DIR / GIT_WORK_TREE — which git exports to every hook it runs and to git rebase --exec — override -C. Measured directly: a corpus at its own commit 128660da answered dd09f3df, the ambient repository's, purely because the environment said so. AMBIENT_GIT_VARIABLES is now dropped from the subprocess environment, and the work-tree cross-check stays as the fail-closed guard behind it. Both are asserted (test_the_ambient_git_environment_does_not_answer_for_this_corpus, test_a_work_tree_git_does_not_agree_is_this_corpus_refuses).

A third thing, found by reading rather than by the sweep, and it is a fidelity fix and not a bug fix

026b042 corrects real_lines. This module states in terms that the CR/LF/CRLF rule is adopted rather than imported — doc_health.lines is openxFactory's and a neutral reader may not reach for it — and re.split alone does not quite hold that claim up: six of thirteen probed inputs diverged from the shared rule, every one of them a document ending in a newline, which is very nearly all of them ('' came back as one empty line rather than none; 'a\n' as two lines rather than one).

It changes no answer this module gives, and the commit says so rather than claiming a fix it did not make: the spare element is always last, so slicing a window off the front cannot lose a real line to it, and an empty string starts with no header prefix. The conformance run is unchanged, re-measured OK — 17 of 17. It is corrected because real_lines and header_window are PUBLIC and the module's claim is that the rule is adopted — a helper that counts one more line than the rule it names is a trap for the next caller. Measured against doc_health.lines.split_keepends itself, from an openxFactory checkout: identical on all 14 probed inputs, the eight exotic separators included. The rule's own table is now parameterized data in the test file, which is where a future divergence shows.

Three things this reader gets right that a measurement of another got wrong

Actor floor37 measured openDox-code #26 at 6c8f19e7 on 2026-09-17: 11 of 17, six failures, five of them one architectural cause — what openxFactory's adapter takes as per-corpus construction data, that reader holds as module constants. This one was built from that measurement:

  1. A location that is a FILE refuses corpus-unreadable, never corpus-unclassifiable. The interface's own comments are the vocabulary, and the corpus's README holds every reader to it.
  2. The declared write path is construction data. A constant write path makes a read-only corpus unrepresentable, so read-only-declared-at-resolution fails, write_back's own read-only branch becomes unreachable, and a refused write lands in the tree.
  3. The classification vocabulary is construction data too. A reader that classifies by file suffix reports every document in a corpus it does not own as the same kind, obliging nothing — a plausible answer and a false one.

And one more, which is floor37's unasked-for finding: this reader never adopts an enclosing repository. _revision looks for a version marker at the location's OWN root and asks git about that directory only, with the ambient git environment dropped and git's reported work tree cross-checked. Pointed at a plain directory inside somebody's checkout it answers "this corpus carries no revision notion" — the truth — rather than stamping every read with a different corpus's revision.

What this act does NOT do

  • It does not tick § 3.7. That box needs opendox_code too, and openDox's reader is the other half — openDox-code DISPLAY: the xFactory host labels openDox's completion stage "implemented" (RULED openxFactory#656 comment 5784683830) #26, at 11 of 17 as measured on 2026-09-17, three construction data away. § 3.8's and § 4.6's tags wait on the same box.
  • It does not tick § 4.1, which is a carve box whose open half is the 23-import reconciliation.
  • It does not edit tasks.md. RULED Q-X1 (a) books this as a new § 4.5a [oXd] box in the bookkeeper's amendment Carve leg 3: openXdox-code receives its 92 rows at opendox-carve-0 (split-opendox § 3.2) #5, on the packet's own Na precedent (§ 2.2a, § 5.2a, § 5.6a). Its exit sentence, for the bookkeeper to place verbatim: "BUILD the corpus-adapter IMPLEMENTATION — design.md § D4 machinery (1), the one of the seven § 4.5 did not name — parameterized by the § 4.4 domain profile, and prove it on § 3.7's neutral corpus. Measured at openXdox-code <merge sha>, 2026-09-17: verify-carve-conformance.py --destination openxdox_code --adapter openxdox.conformance_corpus:reader → OK — 17 of 17."
  • It does not touch openspec/changes/, so this is the plain gate and not Rule 6.
  • It does not cut xdox-v1.0 (§ 4.6).
  • It does not add a sixth DomainProfile axis. RULED Q-X3 (a) keeps the header vocabulary as construction data; the profile axis is registered as the successor, not done here.
  • It does not consolidate the three readers. After this the estate holds openxFactory's engineering adapter (§ 2.2a), openDox's LocalGitCorpus (§ 3.6, DISPLAY: the xFactory host labels openDox's completion stage "implemented" (RULED openxFactory#656 comment 5784683830) #26) and this one. That is what "every destination passes it" costs, and § 3.7 refuses the alternative in terms: "narrowing the corpus to what the legs pass today would be FLOOR PART 3 deleted to tick FLOOR PART 3." A future consolidation is registered and recommended against for now.

Arrival admissions

The three new src/ files and two new tests/ files are CREATED files under openxdox_code's walked roots, so they need created: rows in openxFactory docs/opendox-carve-admissions.yaml or verify-carve-arrival.py --destination openxdox_code --phase B refuses. That is a companion PR at openxFactory (chore/admit-openxdox-corpus-adapter), whose since: names this branch's commits.

🤖 Generated with Claude Code

Brett Heap and others added 2 commits September 17, 2026 13:36
…nd the neutral conformance corpus answers 17 of 17

`design.md` § D4 machinery (1) — "the corpus-adapter IMPLEMENTATION: chart,
firm document store, campaign repository: listed, read, written back and
checked" — is the one of the seven that no § 4 box commissioned. RULING Q4
(openxFactory#656 `5542823211`) put an implementation here; RULING C2
(`5544370242`) said it is PARAMETERIZED; § 3.7 records the missing reader as
"§ 4's mapping core for openXdox ... a build task at that destination". This
commit is that reader.

Three NEW modules, flat under `src/openxdox/`, stdlib plus the PINNED
`opendox.corpus_adapter` (RULED OQ-2 / OQ-Q — the interface is openDox's and is
never replicated here):

  * `corpus_shape.py` — the per-corpus construction DATA (`Scope`,
    `WriteProposal`, `WritePath`, `CorpusShape`), plus `from_profile()`, which
    derives `scan_roots` and one scope per artifact kind from a registered
    `DomainProfile`'s `artifact_kinds[].locations`. That function is what makes
    this the MAPPING CORE's reader rather than a second copy of openxFactory's.
  * `domain_corpus_adapter.py` — `DomainCorpusAdapter`, the interface's six
    operations over one `CorpusShape`. No base class (the interface is a
    `runtime_checkable` Protocol on purpose), no path literal, no header word,
    no `if home:` branch, and nothing in it writes.
  * `conformance_corpus.py` — the DECLARED `--adapter` factory § 3.7's runner
    resolves, carrying the neutral corpus's own terms as a value.

RULED Q-X1..Q-X4 (Brett Heap, 2026-09-17, by interactive multi-choice;
openxFactory#656 comment 5715212264): Q-X2 (a) this is the NEUTRAL,
profile-parameterized reader and Q4's "over openxFactory's corpus" clause is
superseded by C2 + DQ-1; Q-X3 (a) `kind_field` and `required_fields_by_kind`
are CONSTRUCTION DATA here, so no `DomainProfile` schema change and no promoted-
spec delta.

MEASURED, not asserted (openXdox-code `589adee7`, openxFactory `7e074ac9`):

    python3 scripts/verify-carve-conformance.py \
        --destination openxdox_code --dest-root <this checkout> \
        --adapter openxdox.conformance_corpus:reader
    OK: openxdox_code passed the neutral conformance corpus — 17 of 17 check(s)

exit 0, on the FIRST run. The control in the same session is
`--destination openxfactory --adapter home_factory:neutral_reader` → 17 of 17.
`git status --porcelain` in the corpus's own checkout is EMPTY after three runs:
the reader never touches the tree, and it never adopts the checkout that
encloses the corpus directory.

NO TRANSPOSITION (RULED Q-X2 (a)). openDox's reader addresses git history and
needs the corpus laid down as repositories first (RULED Q-F1 (a), comment
`5714365086`); a profile-parameterized FILESYSTEM reader addresses
`tests/corpus-adapter/fixtures/` as it ships, so the seventeen checks run over
the corpus unchanged.

NO `doc_health` REACH. `tests/test_dependency_direction.py`'s
`DOC_HEALTH_SURFACE` is unchanged at 8 modules / 13 statements; the line rule
these modules need (`corpus_root`, `round_trip` and `completeness` all reach
`doc_health` for it) is ADOPTED as an eleven-character regular expression and
not imported. No existing module is edited by this commit.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…tions, every one caught

`.github/workflows/validate.yml`'s explicit `--noconftest` list grows two
entries, appended LAST: `tests/test_corpus_shape.py` (36) and
`tests/test_domain_corpus_adapter.py` (58). A file not on that list is silently
never run.

They join on exactly the grounds `test_dependency_direction.py` joined under
§ 4.1 and `test_domain_profile.py` under § 4.4, and they do NOT un-narrow RULED
Q-L8 (b'): both cover modules AUTHORED HERE, and both import only `pytest`, the
standard library, the pinned `opendox` interface and this package — no
`doc_health`, no `ideation_dashboard`, no carved suite, and so no skip guard.

MEASURED, with the workflow's own invocation read out of the workflow file:

    python -m pytest -q <the 16 files> --noconftest
    454 passed, 6 skipped        (452 + 6 before this commit)

    python -m pytest -q tests/test_corpus_shape.py \
                        tests/test_domain_corpus_adapter.py --noconftest
    94 passed, 0 skipped, 0 errors

EVERY ASSERTION BITES, and that is measured rather than claimed. `mutate.py`
(in the actor's evidence directory, not in this repository) applies 37
deliberate defects one at a time and runs the two files against each:

  * the file-location refusal answering `corpus-unclassifiable` instead of
    `corpus-unreadable` — the exact defect measured on the other destination's
    reader on 2026-09-17;
  * the declared write path becoming a module constant — which is what makes a
    read-only corpus unrepresentable and lets a refused write reach the tree;
  * `read` falling back to a revision nobody asked for; an undeclared scope
    widening silently to everything; `write_back` writing the corpus tree;
  * the line rule breaking on `\x0b`, `\x0c`, `\x1c`-`\x1e`, `\x85`, U+2028 and
    U+2029 the way `str.splitlines()` does;
  * the reader adopting the git checkout that encloses a corpus directory, and
    the ambient `GIT_DIR`/`GIT_WORK_TREE` answering in the corpus's place;
  * and thirty more.

    ALL 37 WERE CAUGHT — 0 survivors.

TWO OF THOSE MUTATIONS SURVIVED A FIRST SWEEP, and both are fixed here rather
than argued away. One was a LOOSE ASSERTION: a profile declaring no locations
was refused by the empty-scan-roots guard two lines later, whose message also
contains the word "locations", so the test passed on the wrong refusal; it now
pins the refusal it means. The other was a REAL HOLE, and it is the sharper of
the two: `_git` inherited the ambient environment, and `GIT_DIR` /
`GIT_WORK_TREE` — which git exports to every hook it runs and to
`git rebase --exec` — override `-C`. Measured directly: a corpus at its own
commit `128660da` answered `dd09f3df`, the ambient repository's, purely because
the environment said so. `AMBIENT_GIT_VARIABLES` is now dropped from the
subprocess environment, and the work-tree cross-check stays as the fail-closed
guard behind it.

The conformance run is unchanged by all of this — re-measured after the `_git`
fix: `--destination openxdox_code` → `OK — 17 of 17`, exit 0.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 17, 2026 13:53
@sourcery-ai

sourcery-ai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Reviewer's Guide

Builds openXdox’s neutral, profile-parameterized implementation of the pinned openDox corpus-adapter interface, including fail-closed filesystem/Git resolution, scoped listing and reading, construction-data-driven classification and write dispatch, a conformance factory, and comprehensive standalone CI tests.

Sequence diagram for fail-closed corpus resolution and reading

sequenceDiagram
    participant Runner
    participant Adapter as DomainCorpusAdapter
    participant FS as Filesystem
    participant Git

    Runner->>Adapter: resolve(CorpusRef)
    Adapter->>FS: check location and scan_roots
    alt missing path
        Adapter-->>Runner: CorpusRefused(CORPUS_ABSENT)
    else file or unreadable path
        Adapter-->>Runner: CorpusRefused(CORPUS_UNREADABLE)
    else no declared scan root
        Adapter-->>Runner: CorpusRefused(CORPUS_UNCLASSIFIABLE)
    else directory matches shape
        Adapter->>Git: _git(location, rev-parse)
        Git-->>Adapter: revision or no revision
        Adapter-->>Runner: ResolvedCorpus
        Runner->>Adapter: list_documents(corpus, scope)
        Adapter->>FS: glob declared scope patterns
        FS-->>Adapter: sorted unique document keys
        Adapter-->>Runner: DocumentId list
        Runner->>Adapter: read(corpus, document, revision)
        Adapter->>FS: read_bytes(document)
        FS-->>Adapter: document bytes
        Adapter-->>Runner: Document
    end
Loading

Sequence diagram for construction-data-driven classification

sequenceDiagram
    participant Consumer
    participant Adapter as DomainCorpusAdapter
    participant FS as Filesystem
    participant Shape as CorpusShape

    Consumer->>Adapter: classify(corpus, document)
    Adapter->>Adapter: read(corpus, document)
    Adapter->>FS: read_bytes(document)
    FS-->>Adapter: UTF-8 bytes
    Adapter->>Shape: kind_field and required_fields_by_kind
    Adapter->>Adapter: header_window(text, header_scan_lines)
    Adapter->>Adapter: kind_of(text, shape)
    Adapter->>Adapter: obliged_fields(document_key, kind, shape)
    Adapter->>Adapter: absent_fields(text, fields, shape)
    alt kind header absent
        Adapter-->>Consumer: Classification(kind=None, unclassifiable=reason)
    else kind recognized
        Adapter-->>Consumer: Classification(kind, missing_fields)
    end
Loading

File-Level Changes

Change Details Files
Adds a neutral, profile-parameterized corpus shape model and profile-derived scope/location construction data.
  • Introduces immutable shape, scope, write proposal, and governed write-path descriptors.
  • Derives scan roots, per-artifact-kind scopes, and the all-scope union from DomainProfile locations.
  • Keeps header vocabulary, field obligations, verdict providers, and write paths injectable rather than domain-hardcoded.
  • Validates unusable shapes and rejects scope-name collisions or profiles without artifact locations.
src/openxdox/corpus_shape.py
Implements the six-operation corpus-adapter reader with fail-closed resolution, listing, reading, classification, checking, and write dispatch.
  • Provides structural conformance to the pinned openDox protocol and uses its refusal/result types.
  • Resolves filesystem corpora without adopting enclosing repositories; scrubs ambient Git variables and cross-checks Git work trees.
  • Lists sorted, unique documents by declared scopes, reads only listed documents at the resolved revision, and distinguishes corpus refusals from document classification reports.
  • Implements bounded CR/LF/CRLF header parsing, injectable verdict handling, and dispatch-only write-back with read-only and forged-path protections.
src/openxdox/domain_corpus_adapter.py
Adds the declared neutral-corpus adapter factory used by the conformance runner.
  • Defines the neutral corpus shape independently of any domain profile.
  • Exposes a small (name, location) factory returning a DomainCorpusAdapter without transposing or hardcoding a corpus location.
src/openxdox/conformance_corpus.py
Adds standalone tests covering construction data, adapter behavior, refusal semantics, security boundaries, and mutation-sensitive edge cases.
  • Tests profile derivation, scope isolation, glob and placeholder handling, and invalid-shape rejection.
  • Tests all six operations across empty, populated, absent, unreadable, unclassifiable, versioned, read-only, and write-dispatch scenarios.
  • Covers Git environment isolation, enclosing-repository rejection, exact line-ending semantics, classification outcomes, verdict injection, and tree immutability.
tests/test_corpus_shape.py
tests/test_domain_corpus_adapter.py
Registers the new standalone test modules in the explicit no-conftest CI test list.
  • Appends both new test files to the workflow list so they execute in validation despite the repository's conftest isolation requirements.
.github/workflows/validate.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@brettheap

Copy link
Copy Markdown
Contributor Author

@copilot review

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

Address the adapter identity, cache invalidation, and unreadable-path handling findings.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Implements a neutral, profile-parameterized corpus adapter with conformance tests and CI coverage.

Changes:

  • Adds corpus shape construction and profile-derived scopes.
  • Implements resolving, listing, reading, classification, checking, and write dispatch.
  • Registers the conformance reader and new test suites in CI.
File summaries
File Summary
tests/test_domain_corpus_adapter.py Tests adapter behavior and refusal cases.
tests/test_corpus_shape.py Tests shape validation and profile derivation.
src/openxdox/domain_corpus_adapter.py Implements corpus adapter operations.
src/openxdox/corpus_shape.py Defines corpus construction data and profile mapping.
src/openxdox/conformance_corpus.py Provides the neutral conformance reader factory.
.github/workflows/validate.yml Adds the new suites to CI validation.
Review details

Suppressed comments (4)

.github/workflows/validate.yml:409

  • This comment says four tests use the git-availability skip, but only three tests request the git_available fixture; the work-tree guard test does not. Please keep the workflow documentation aligned with the actual suite.
      # imports is unreachable at this leg. Four tests do carry a skip, on a
      # different axis entirely — the git-backed revision assertions skip
      # where `git` is not on PATH, which on this runner it always is.

src/openxdox/domain_corpus_adapter.py:294

  • _listings is keyed only by location, revision, and scope. For an unversioned tree revision is always None, and even a Git working tree can change while HEAD stays the same, so adding/removing/replacing a document after the first listing leaves this adapter serving stale identities and bytes. Either avoid caching listings for mutable trees or bind/invalidate the cache to a snapshot that actually changes when the tree changes.
        self._listings: dict[tuple[str, str | None, str], tuple[str, ...]] = {}

src/openxdox/domain_corpus_adapter.py:319

  • Path.exists()/is_dir() can return False when the path exists but cannot be inspected (for example, a permission-denied parent), so this branch reports CORPUS_ABSENT instead of the documented CORPUS_UNREADABLE; the surrounding except OSError does not catch those suppressed errors. Use an operation such as Path.stat() (and distinguish FileNotFoundError from other OSErrors) before deciding absent versus unreadable.
            if not location.exists():
                raise _refuse(CORPUS_ABSENT, str(location),
                              "the path does not exist")
            if not location.is_dir():
                raise _refuse(CORPUS_UNREADABLE, str(location),

tests/test_domain_corpus_adapter.py:141

  • The test name has a duplicated s in corpuss, which makes the test identifier misleading.
def test_the_factory_is_constructed_from_the_corpuss_terms_alone() -> None:
  • Files reviewed: 6/6 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.

Comment thread src/openxdox/domain_corpus_adapter.py Resolved
…o new one — parity with the shared rule this module says it adopts

`domain_corpus_adapter`'s header states in terms that the CR/LF/CRLF line rule
(`align-status-reader-to-real-lines`, ruled 2026-08-19) is ADOPTED rather than
imported, because its implementation is `doc_health.lines`, which is
openxFactory's own corpus machinery and is exactly what a neutral reader may
not reach for. `re.split` alone does not quite hold that claim up:

    text        the shared rule    re.split alone
    ''          []                 ['']
    'a\n'       ['a']              ['a', '']
    'a\r\nb\r\n' ['a', 'b']        ['a', 'b', '']

Six of thirteen probed inputs diverged, and every one of them is a document
that ends in a newline — which is very nearly all of them.

THIS CHANGES NO ANSWER THIS MODULE GIVES, and the commit says so rather than
claiming a bug fix it did not make: the spare element is always LAST, so
slicing a window off the front cannot lose a real line to it, and an empty
string starts with no header prefix. `kind_of` and `absent_fields` answered
correctly before and answer identically now — the conformance run is unchanged,
re-measured `OK — 17 of 17`.

It is corrected because `real_lines` and `header_window` are PUBLIC and because
the module's own claim is that the rule is adopted. A helper that counts one
more line than the rule it names is a trap for the next caller, and a line
count is exactly what a later writer or a report would reach for.

Measured after the change, against `doc_health.lines.split_keepends` itself
(run from an openxFactory checkout, not from this leg, which cannot import it):
IDENTICAL on all 14 probed inputs, including the eight exotic separators that
must NOT split. The rule's own table is now restated as parameterized data in
`tests/test_domain_corpus_adapter.py`, which is where a future divergence
shows.

    python -m pytest -q tests/test_corpus_shape.py \
                        tests/test_domain_corpus_adapter.py --noconftest
    98 passed        (36 + 62; was 94)

    python -m pytest -q <the 16 files validate.yml names> --noconftest
    458 passed, 6 skipped                             (was 454 + 6)

    mutation sweep: 38 mutations, ALL 38 CAUGHT, 0 survivors
    (M38 is this line: removing the `pop()` is caught by 5 assertions)

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 17, 2026 14:02
@brettheap

Copy link
Copy Markdown
Contributor Author

@copilot review

Co-authored-by: brettheap <1513478+brettheap@users.noreply.github.com>

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

Unresolved identity validation, filesystem error handling, cache invalidation, and write-back membership issues remain.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (3)

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

src/openxdox/domain_corpus_adapter.py:405

  • DocumentId includes the corpus identity, but this path validates only document.key. A caller can pass an ID from another corpus that happens to have the same key; it is then read from this tree and returned unchanged with the foreign corpus value, so the adapter serves an identity that does not belong to the resolved corpus. Reject a mismatched document.corpus before the listing check (and cover the same invariant for write-back).

src/openxdox/domain_corpus_adapter.py:617

  • When a declared scan root or one of its subdirectories is unreadable, Path.glob() can raise OSError during this walk. That exception escapes as a raw filesystem error even though resolve() documents CORPUS_UNREADABLE as the refusal for an unreadable corpus/document; wrap the walk and translate filesystem failures to the adapter's refusal vocabulary (with a regression test).
            completed = subprocess.run(
                ["git", "-C", str(cwd), *args],
                capture_output=True, text=True, timeout=GIT_TIMEOUT_SECONDS,

src/openxdox/domain_corpus_adapter.py:315

  • This cache key cannot distinguish two resolutions of an unversioned corpus: both have the same (location, None, scope) key. If a document is added or removed and the caller resolves again (the documented way to refresh), list_documents, read, and check continue using the old listing, so newly listed documents remain unknown and removed documents can still be read. Invalidate listings when resolving a corpus (or otherwise include a filesystem snapshot in the key) and add a mutation test for unversioned trees.
        # rather than being stamped with `HEAD`.
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/openxdox/domain_corpus_adapter.py Resolved
Copilot AI review requested due to automatic review settings September 17, 2026 14:05
…of the test

`test_the_ambient_git_environment_does_not_answer_for_this_corpus` reached for
`__import__("os")` inline, twice, to build a scrubbed environment for the two
control reads — and it took those reads AFTER `monkeypatch.setenv`, so each one
had to re-scrub what the test had just set. That is the test's own mechanism
tangled into its control.

Both reads now happen BEFORE the variables are set, through one `_head()`
helper with `check=True` and a module-level `os` import, and the
"different commits" control is asserted before the reader is ever invoked. The
test asserts exactly what it asserted; it just no longer has to undo itself to
do it.

No source change. Re-measured: `tests/test_domain_corpus_adapter.py` 62 passed;
the mutation sweep still reports 38 mutations, ALL 38 CAUGHT, 0 survivors.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ion' into build/corpus-adapter-implementation

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

Critical path and symlink containment issues, plus moderate unreadable-path handling, remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (4)

src/openxdox/domain_corpus_adapter.py:347

  • A declared scan root that exists as a file is silently treated as absent. If any other root is present, resolve therefore succeeds and listings omit this malformed/unreadable part of the corpus instead of refusing; for example, a notes file plus a valid papers/ directory resolves as a partial corpus. Reject an existing non-directory root as CORPUS_UNREADABLE before continuing.
                if not declared.exists() or not declared.is_dir():
                    continue

src/openxdox/domain_corpus_adapter.py:595

  • This docstring overstates the isolation provided by _git: the call passes an inherited environment (minus AMBIENT_GIT_VARIABLES) and does not disable Git's system/global/local configuration, so it can still read caller configuration. Either enforce full configuration isolation or document the narrower guarantee so callers do not assume this subprocess is configuration-independent.
        `-C <cwd>` and nothing else: no environment is set, no configuration is
        read from the caller, and no second directory is ever consulted. A

src/openxdox/domain_corpus_adapter.py:338

  • Path.exists() suppresses many OSErrors (including permission-denied errors) and returns False, so an existing but inaccessible corpus path can be reported as CORPUS_ABSENT instead of the required CORPUS_UNREADABLE. Probe the path with an operation that distinguishes FileNotFoundError from other OSErrors, then map the latter to the unreadable refusal before continuing.
            if not location.exists():
                raise _refuse(CORPUS_ABSENT, str(location),

tests/test_domain_corpus_adapter.py:142

  • The test docstring contains the typo corpuss_terms; please correct it to corpus's terms.
def test_the_factory_is_constructed_from_the_corpuss_terms_alone() -> None:
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread src/openxdox/domain_corpus_adapter.py Resolved
Comment thread src/openxdox/domain_corpus_adapter.py Resolved

Copilot AI commented Sep 17, 2026

Copy link
Copy Markdown

@copilot review

Addressed locally in f47794c: the adapter now rejects foreign document identities, clears cached listings on re-resolve, refuses unreadable roots/subtrees and dirty git work trees, and confines listings to regular non-symlink files inside the corpus. Local validation is green (470 passed, 6 skipped), but the provided push path is currently being rejected by branch protection on build/corpus-adapter-implementation.

Co-authored-by: brettheap <1513478+brettheap@users.noreply.github.com>

Copilot AI commented Sep 17, 2026 •

Copy link
Copy Markdown

@copilot review

Addressed in f070e26.

@copilot review

Addressed on this branch in 5f947cd and f070e26.

Copilot AI review requested due to automatic review settings September 17, 2026 14:13

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

Critical and moderate findings leave path traversal and symlink escapes possible and misclassify invalid roots.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (3)

src/openxdox/domain_corpus_adapter.py:337

  • A declared scan root that exists as a regular file is silently skipped here, so a corpus directory containing notes as a file resolves as CORPUS_UNCLASSIFIABLE (or may fall back to another root) instead of the CORPUS_UNREADABLE refusal used for a non-directory corpus location. Treat an existing declared root that is not a directory as unreadable and name that root; otherwise malformed corpus layouts are misclassified.
                if not declared.exists() or not declared.is_dir():
                    continue

src/openxdox/domain_corpus_adapter.py:646

  • The walk yields symlinked files (and can start from a symlinked scan root) without checking where their resolved targets land, so read()/classify() can serve bytes outside the corpus directory. This violates the repository's established confinement invariant (for example, src/openxdox/doxbench_scope.py:127-139 rejects paths whose resolved target escapes the selected root) and lets a corpus expose arbitrary linked files. Resolve each candidate and fail closed (or reject the symlink) unless the target remains under the resolved corpus root; cover both file and directory symlinks.
            for dirpath, _, filenames in os.walk(root, onerror=_onerror):
                directory = Path(dirpath)
                for filename in filenames:
                    yield (directory / filename).relative_to(location)

src/openxdox/domain_corpus_adapter.py:636

  • _scope_keys walks every scan_root for every scope, even when a scope's globs are confined to one root. Consequently a call such as list_documents(corpus, "governance-document") on a profile with several roots scans the entire corpus, and SCOPE_ALL repeats that scan once per kind; large corpora therefore incur avoidable O(number-of-scopes × tree-size) traversal. Restrict traversal to roots implied by the scope globs (or cache a single listing per corpus resolution) before matching patterns.
    def _walk_files(self, location: Path):
        for root_name in self._shape.scan_roots:
            root = location / root_name
            if not root.exists():
                continue
            self._require_traversable(root)
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/openxdox/corpus_shape.py Resolved
…asurement that decides each

`5f947cd` (`copilot-swe-agent[bot]`, pushed to this branch) made seven changes
in one commit. Four are improvements and stay. Three are reverted, and the
sharpest of them is a silent data-loss defect the conformance corpus cannot see.

## KEPT

1. **`_require_own_identity` on `read` / `classify` / `check`.** A `DocumentId`
   whose `corpus` names another corpus is not this corpus's identity, and
   `DOCUMENT_UNKNOWN` is in each of those operations' declared row.
2. **`resolve` clears the listing cache.** An unversioned tree has no revision
   token for the cache key to change with, so a caller that re-resolves after
   editing the tree was being served the listing from before its own edit.
   Re-resolving is the one act that says "the tree may have moved".
3. **An unreadable directory REFUSES instead of being omitted** — kept, and it
   is the best thing in the round. `Path.glob` swallows `OSError` and returns
   what it could reach, so a directory this process cannot open came back as an
   ABSENCE: a corpus that "has no documents there". That is the degradation the
   interface's second requirement forbids in terms, and it was in this reader.
4. **Its two `chmod(0)` tests**, with their `os.access` skip guard — which is
   the right mitigation, and the one the corpus's own README asks for
   ("without `chmod`, which is unreliable as root on CI").

## REVERTED

5. **The listing matcher, and this one is a DEFECT rather than a difference.**
   `Path.glob` was replaced by `os.walk` plus a hand-rolled `_matches_glob`
   built on `PurePath.match`, which has NO recursive `**` — it compensated by
   stripping one `**/` per variant, which covers zero directories and one, and
   nothing deeper. Measured over a tree holding `notes/top.md`,
   `notes/a/one.md`, `notes/a/b/two.md`, `notes/a/b/c/three.md`:

       Path.glob("notes/**/*.md")   -> 4 documents
       the replacement matcher      -> 2 documents

   Two documents disappear, no refusal, no warning, and a projection over the
   result looks exactly like a projection over a smaller corpus. It is the
   ORDINARY case rather than a corner: `corpus_shape.from_profile` emits rooted
   `**` patterns for every directory-shaped location a domain profile declares
   (`docs/**/*.md`, `ideation/staging/*/**/*.md`, ...), so every governed corpus
   this reader exists to serve would have lost its deeper documents.

   **The neutral conformance corpus returns 17 of 17 either way**, because all
   three of its documents are exactly one directory deep. That is worth stating
   plainly: the floor's suite is not a substitute for this leg's own, and this
   is the case that proves it. `test_a_rooted_double_star_lists_every_depth_beneath_it`
   is the regression guard, and mutation M39 reinstates the defect and is caught.

   The refusal from (3) is kept and separated from membership: `_require_readable_tree`
   walks the declared roots with `os.walk`'s `onerror` for DETECTION only, and
   `Path.glob` remains the one membership rule.

6. **`resolve` refusing a dirty git work tree.** The argument for it is real and
   is recorded rather than dismissed: bytes read out of an edited work tree are
   not the bytes at `HEAD`, so stamping them with `HEAD` overstates what was
   read. It is not this reader's call to make. The interface says `revision` is
   "the revision they were read at" and nowhere requires a clean tree;
   openxFactory's own § 2.2a adapter resolves `HEAD` over a dirty checkout and
   serves the working tree; and `--untracked-files=all` means one editor swap
   file makes a whole governed corpus unreadable. Two readers over one corpus
   giving opposite answers is what § 3.7 exists to prevent, so this belongs to a
   RULING and not to a review round. `test_a_dirty_work_tree_still_resolves_at_its_own_head`
   pins today's behaviour and carries the argument; the question is registered
   for Brett Heap in this lane's report.

7. **`write_back` refusing `DOCUMENT_UNKNOWN`.** The interface enumerates the
   kinds each operation may raise and says what an extra one is: "an
   implementation raising a kind outside its row is a defect the conformance
   suite is entitled to catch." `write_back`'s row is `CORPUS_READ_ONLY` and
   `WRITE_PATH_UNREACHABLE`. The question the guard answered — has this key a
   target — is the DECLARED PATH's to answer, through `routes`, whose `None` the
   interface already turns into a refusal naming the path. Pre-empting it with a
   kind the row does not carry is a conformance defect wearing the face of a
   safety check. `test_write_back_raises_only_the_kinds_its_row_of_the_interface_names`
   holds it.

## Measured at this head

    verify-carve-conformance.py --destination openxdox_code
        --adapter openxdox.conformance_corpus:reader        OK — 17 of 17, exit 0

    python -m pytest -q tests/test_corpus_shape.py \
                        tests/test_domain_corpus_adapter.py --noconftest
        107 passed  (36 + 71; was 98)

    python -m pytest -q <the 16 files validate.yml names> --noconftest
        467 passed, 6 skipped                               (was 458 + 6)

    mutation sweep: 42 mutations, ALL 42 CAUGHT, 0 survivors
    (M39-M42 are this round's four: the depth defect, the omitted unreadable
     directory, the uncleared cache, and the foreign document identity)

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

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 critical unresolved TOCTOU vulnerability remains between confinement checks and reading bytes.

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

Comment thread src/openxdox/domain_corpus_adapter.py Resolved
…ng is

Round fourteen, accepted -- and the fix is a real narrowing rather than the
disclaimer that stood here.

THE FINDING IS TRUE. `_require_confined` resolves a PATHNAME and the read
opens a PATHNAME. Those are two operations, so anything that can write the
corpus tree can retarget a link between them and the open lands somewhere
else. The comment at that line already said so -- "the window is narrowed to
the gap between this check and the `open` below, not closed" -- which is
honest and is also all it was.

NEITHER REMEDY THE REVIEW NAMES IS AVAILABLE HERE, and saying why is the
argument for the third one. `O_NOFOLLOW` refuses the final component outright,
so it would also refuse the IN-CORPUS links this reader deliberately allows
and `_require_confined` deliberately admits -- it does not narrow the guard,
it changes what a corpus may contain. A per-component `openat` walk is not
portable and is a great deal of machinery for a stdlib-only neutral reader
whose whole argument is that it is small enough to audit.

SO THE RACE IS NOT PREVENTED, IT IS DETECTED, which is worth more than the
disclaimer it replaces and is cheap. The descriptor is opened FIRST; `fstat`
then names exactly the file whose bytes are about to be read; and that is
compared with the `(st_dev, st_ino)` of the target that passed the boundary,
WHILE THE BYTES ARE STILL UNREAD. The guarantee is therefore neither atomicity
nor the old disclaimer: the bytes this method returns came from the file that
passed confinement, or it refuses. `_require_confined` now hands its target
back so the second half can be asked at all.

Where a filesystem numbers no files (`st_ino` 0, which Windows shares can
report) there is nothing to compare and the guard YIELDS rather than refusing
every read on that filesystem. A guard that cannot see must not pretend it
did -- the same rule this act applied to `_git`'s isolation claim and to the
per-handle "moment in time".

MEASURED BY LETTING THE ATTACKER WIN. The window is microseconds and no test
suite hits it by chance, so the test does not try: it wraps the confinement
check and swaps the link the instant the check has passed, every time. That is
the worst case and not an approximation of it. The last assertion is the one
that matters -- the outside file's bytes never reach the caller.

  M70 the bytes served are not proved to come from the checked file -> caught
  M50 (the pre-existing guard) retargeted: removing the confinement re-check
      now has to keep `target` bound, so it resolves the path directly --
      which is the defect it always meant -- and is caught by 2.

RE-MEASURED:

  the two new files                     160 passed (63 + 97), 0 skipped
  the whole `validate.yml` list         520 passed, 6 skipped
  the list as this act found it         360 passed, 6 skipped
  mutation sweep                        69 mutations, ALL 69 CAUGHT
  conformance, `openxdox_code`          OK -- 17 of 17
  arrival, phase B, 2 replicas          OK -- 129 files, 28 created

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 17, 2026 16:35
@brettheap

Copy link
Copy Markdown
Contributor Author

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

Round fourteen — the TOCTOU disclaimer becomes a measured guarantee

00fe775. The finding is true, and the fix is a real narrowing rather than the sentence that stood at that line.

What was there. _require_confined resolves a pathname and the read opens a pathname. Two operations, so anything that can write the tree can retarget a link between them. The comment said exactly that — "the window is narrowed to the gap between this check and the open below, not closed" — which was honest, and was also all it was.

Why neither proposed remedy applies, which is the argument for the third.

  • O_NOFOLLOW refuses the final component outright, so it would also refuse the in-corpus links this reader deliberately allows and _require_confined deliberately admits. That does not narrow the guard; it changes what a corpus may contain.
  • A per-component openat walk is not portable, and it is a lot of machinery for a stdlib-only neutral reader whose argument is that it is small enough to audit.
  • "Reject concurrently mutable trees" is not decidable here — this reader cannot know whether something else holds a write handle on the operator's checkout.

So the race is not prevented; it is detected, while the bytes are still unread. The descriptor is opened first, fstat names exactly the file about to be served, and that is compared with the (st_dev, st_ino) of the target that passed the boundary. _require_confined now returns its target so the second half can be asked at all. The guarantee is neither atomicity nor the old disclaimer:

the bytes this method returns came from the file that passed confinement, or it refuses.

Where a filesystem numbers no files (st_ino 0, which Windows shares can report) there is nothing to compare and the guard yields rather than refusing every read on it. A guard that cannot see must not pretend it did — the same rule this act applied to _git's isolation claim and to the per-handle "moment in time".

Measured by letting the attacker win. The window is microseconds and no suite hits it by chance, so the test does not try: it wraps the confinement check and swaps the link the instant the check has passed, every time. Worst case, not an approximation — and the closing assertion is that the outside file's bytes never reach the caller.

pinned
M70 the bytes served are not proved to come from the checked file — caught
M50 retargeted: removing the confinement re-check must now keep target bound, so it resolves the path directly, which is the defect it always meant — caught by 2
at 00fe775
the two new files 160 passed (63 + 97), 0 skipped
the whole validate.yml list 520 passed, 6 skipped
the list as this act found it 360 passed, 6 skipped
mutation sweep 69 mutations, ALL 69 CAUGHT
conformance, openxdox_code OK — 17 of 17
arrival, phase B, 2 replicas OK — 129 files, 28 created

Refs #656 (stays OPEN). CLAIM comment 5715212503.

@brettheap

Copy link
Copy Markdown
Contributor Author

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

@copilot review

The TOCTOU finding is accepted and fixed at 00fe775 — the race is not prevented (neither O_NOFOLLOW nor a portable openat walk is available without changing what a corpus may contain), it is detected while the bytes are still unread, and measured by letting the attacker win the race deterministically. Refs #656 (stays OPEN). CLAIM comment 5715212503.

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

Fix write-back membership validation and reconcile the workflow’s recorded test and mutation counts.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (2)

.github/workflows/validate.yml:425

  • The recorded test measurements are inconsistent with the PR description: this workflow comment says the two added files produced 160 passes and the full list 520, while the description reports 159 and 519. Please re-run the exact --noconftest commands at the final head and synchronize the audit trail so the required-check documentation does not advertise an unverified count.
      #   python -m pytest -q tests/test_corpus_shape.py \
      #                       tests/test_domain_corpus_adapter.py --noconftest
      #     160 passed  (63 + 97), 0 skipped, 0 errors
      #
      # AND THE WHOLE LIST, because a count in this file that stops
      # being true is the stale-claim class this leg already sweeps
      # for: the invocation below now reads 520 passed / 6 skipped.

src/openxdox/domain_corpus_adapter.py:631

  • This guard only rejects a DocumentId from a different corpus; it never verifies that a same-corpus key was actually listed. With a reachable path whose routes accepts arbitrary keys (the test helper's lambda key: key is enough), write_back(corpus, DocumentId(corpus=corpus.ref.name, key="notes/never-listed.md"), ...) builds and dispatches a proposal for a document this corpus does not contain. read and classify enforce listing membership, so write_back should fail closed with WRITE_PATH_UNREACHABLE before calling routes/dispatch when the key is not in the resolved listing.
        if document.corpus != corpus.ref.name:
            raise _refuse(
                WRITE_PATH_UNREACHABLE, write_path.name,
                f"{document.corpus!r} does not name {corpus.ref.name!r}, so "
                "this is another corpus's document identity and this reader "
                "will not dispatch it through this corpus's write path; the "
                "document remains unsaved")
        target = write_path.routes(document.key)
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread .github/workflows/validate.yml Resolved
…inst it

Takes openXdox-code `main` `b98e196` -- "Bump opendox pin to openDox-code
5c137a90 (§ 3.4 RULED Q7 landed)" -- into this branch, on the holder's
16:38Z instruction to build and verify against the new pin before pushing.
Merged, never rebased. No conflict: the bump touches `pyproject.toml`,
`view_extensions.py` and three test files, none of which this branch edits,
and its `validate.yml` edit is elsewhere in the file from this branch's.

WHY THIS MERGE NEEDED MEASURING AND NOT JUST MERGING. The pin is the
INTERFACE this whole act is built against:

    -    "opendox @ git+...openDox-code@0b4e8bbf68fabfcd65d4f0d80e619c20a013e888",
    +    "opendox @ git+...openDox-code@5c137a9049600afbcf93b2ac26baf3d229755f95",

So the package was reinstalled at `5c137a90` and everything re-run against
the real new module rather than the one in the environment. What the reader
depends on is unchanged, and that is asserted rather than assumed:

    OPERATIONS        ('resolve','list_documents','read','classify',
                       'check','write_back')            -- six, unchanged
    REFUSAL_KINDS     eight, unchanged
    ResolvedCorpus    same six fields; eq=True, frozen=True, slots=False,
                      weakref_slot=False                -- unchanged

That last line matters beyond bookkeeping: round ten's argument for keying
the listing memo by VALUE in an ordinary dict, and against a
`WeakKeyDictionary`, rests on exactly those dataclass parameters. They still
hold at the new pin.

RE-MEASURED AT THE NEW PIN -- every figure identical to the old one, which is
the property a structurally conformant consumer should have:

  the two new files                     160 passed (63 + 97), 0 skipped
  the whole `validate.yml` list         520 passed, 6 skipped
  the list as this act found it         360 passed, 6 skipped
  mutation sweep                        69 mutations, ALL 69 CAUGHT
  conformance, `openxdox_code`          OK -- 17 of 17
  arrival, phase B, 2 replicas          OK -- 129 files, 28 created

No count in `validate.yml` moved, so no comment in it is edited: the numbers
it carries were true before this merge and are true after it, and re-typing
them would only add a chance to get one wrong.

Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 17, 2026 17:16

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

The broad filesystem and conformance implementation warrants final human review.

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

@brettheap

Copy link
Copy Markdown
Contributor Author

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

Q-A — the dirty-work-tree reader — is RULED: LEAVE AS IS

Brett Heap, 2026-09-18 ~09:55Z, by interactive multi-choice; openxFactory#656 comment 5728368325, item 3:

Q-A, the dirty-work-tree reader (raised by #23): LEAVE AS IS. Both readers — oxF's § 2.2a adapter and openXdox's openxdox.conformance_corpus — keep resolving HEAD over a dirty tree, consistently; the stamp's documented meaning is "the tree at or after this commit". No spec text, no pin move; a refusal would have made an editor's swap file render the corpus unreadable.

That is the question registered in #issuecomment-5716188059 under "Registered, NOT decided — a question for Brett Heap rather than for a review round": round 1 made resolve refuse a corpus whose git work tree is dirty, the refusal was reverted, and the argument for it was recorded rather than dismissed — because two readers over one corpus giving opposite answers is the thing § 3.7 exists to prevent, which makes it a ruling's call and not a review round's.

Nothing follows for this branch, and that is measured rather than asserted

The ruling is what the code at 5b8e527a already does.

This reader's whole revision notion is DomainCorpusAdapter._revision, src/openxdox/domain_corpus_adapter.py:649-702. It takes the ref the caller named or DEFAULT_REF (line 685; DEFAULT_REF = "HEAD", line 127), cross-checks git's own toplevel against the directory it was pointed at (line 686), and returns rev-parse --verify HEAD^{commit} (line 695, returned at line 702). Work-tree cleanliness is consulted nowhere on that path.

It cannot be consulted, because those two lines are the only git this reader ever runs:

$ grep -n 'self._git(' src/openxdox/domain_corpus_adapter.py
686:        toplevel = self._git(location, "rev-parse", "--show-toplevel")
695:        resolved = self._git(location, "rev-parse", "--verify", f"{ref}^{{commit}}")

$ grep -n 'porcelain\|diff-index\|diff --quiet\|"status"\|is_dirty\|untracked' \
      src/openxdox/domain_corpus_adapter.py \
      src/openxdox/corpus_shape.py \
      src/openxdox/conformance_corpus.py
(no match)

Both subcommands are rev-parse. There is no git status --porcelain, no diff-index, no untracked-file probe in the adapter, in corpus_shape, or in the openxdox.conformance_corpus entry point the conformance verifier loads — so a dirty tree here is not merely permitted, it is not observable.

And the working tree is what gets served, stamped with that commit. read takes its bytes from Path(corpus.location) / document.key (line 491) — the tree on disk, not the object database — and returns them as Document(..., revision=corpus.revision) (line 522). Which is the ruling's "the tree at or after this commit", exactly.

The behaviour is pinned rather than incidental. tests/test_domain_corpus_adapter.py:359, test_a_dirty_work_tree_still_resolves_at_its_own_head, commits a corpus, then edits one tracked file and drops one untracked file beside it, and asserts both halves — corpus.revision == committed, and that read returns the EDITED bytes. Re-measured at this head, in a fresh clone, just now:

$ git rev-parse HEAD
5b8e527aa97f7436cdbe2b0901fa48496481422f

$ python -m pytest -q --noconftest \
    tests/test_domain_corpus_adapter.py::test_a_dirty_work_tree_still_resolves_at_its_own_head
1 passed in 0.32s

$ python -m pytest -q tests/test_corpus_shape.py tests/test_domain_corpus_adapter.py --noconftest
160 passed in 1.27s

160 is the figure this PR's body and validate.yml both carry — re-measured independently here, not carried over.

No commit follows from the ruling

No spec text and no pin move, as ruled; and no prose change either, because nothing in these modules or their tests promises the refusal. The test's docstring still closes with "The question is registered in this PR rather than decided in it", and that stays true on its own terms — it was decided on openxFactory#656 by the ratifier, not in this PR. Its reasoning (the interface nowhere requires a clean tree; openxFactory's own § 2.2a adapter resolves HEAD over a dirty checkout and serves the working tree; one editor swap file would otherwise make a whole governed corpus unreadable) is the ruling's own reasoning, so it stands as the record of why.

Q-A is closed. Head unchanged at 5b8e527a.

@brettheap
brettheap marked this pull request as ready for review September 18, 2026 10:08

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

Sorry @brettheap, your pull request is larger than the review limit of 150,000 diff characters

brettheap added a commit to opensoft/openXfactory that referenced this pull request Sep 18, 2026
…§ D4 machinery (1)): 23 created rows become 28, and arrival goes from refusing to OK (#1091)

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

Refs #656 (stays OPEN).
CLAIM: 5715212503
RULED Q-X1..Q-X4 (Brett Heap, 2026-09-17, by interactive multi-choice; #656 comment 5715212264).

## What this is

The arrival admissions for **opensoft/openXdox-code#23** — openXdox's conformant corpus-adapter implementation, `split-opendox-two-layer-product` `design.md` **§ D4 machinery (1)**, the reader `tasks.md` § 3.7 calls "§ 4's mapping core for openXdox".

That PR creates **five** files under `openxdox_code`'s declared roots. A file a destination CREATES has no row in `docs/opendox-carve-manifest.yaml` — the manifest declares what LEAVES openxFactory, never what a destination assembles (RULED OQ-C) — so `scripts/verify-carve-arrival.py` must be TOLD about it or it refuses `arrival-undeclared-file`. This PR is that declaration, in the governed form RULED `#656` comment `5639058687` put it in.

**One file changed; five `created:` entries added, alphabetically, to `openxdox_code`.** 23 → 28.

| path | `since:` |
| --- | --- |
| `src/openxdox/conformance_corpus.py` | `d4282454` |
| `src/openxdox/corpus_shape.py` | `d4282454` |
| `src/openxdox/domain_corpus_adapter.py` | `d4282454` |
| `tests/test_corpus_shape.py` | `5494bb43` |
| `tests/test_domain_corpus_adapter.py` | `5494bb43` |

**Two `since:` values and not one**, because two leg commits introduced them: the three modules at `d4282454c10d2f8891eae94e77d1a7554ebd17ed`, the two test files at `5494bb43350636cf7c3d5a3b6b2d6262ab74dd06`. The file's own header says a `since:` exists so the claim is "falsifiable the same way the manifest's own `carve_commit:` is", so each row names the commit that actually introduced its path rather than one branch head standing in for both.

`src/openxdox/conformance_corpus.py` sorts **before** `consumer_reach.py` (`conf` < `cons`) and `tests/test_corpus_shape.py` **before** `test_dependency_direction.py`, so two of the five are insertions at the head of their runs rather than at the end. Order and uniqueness are the verifier's own refusals, and both are asserted.

## Measured, three ways

The runbook § 5.6 invocation for this destination — the two RULED Q-L7 (a) `--replica-at` placements openXdox-code owes:

```
python3 scripts/verify-carve-arrival.py \
    --destination openxdox_code --dest-root <leg checkout> --phase B \
    --replica-at tests/ideation-dashboard/conftest.py=tests/conftest.py \
    --replica-at tests/ideation-dashboard/session_fixtures.py=tests/session_fixtures.py
```

**[1] Control — leg `main` `589adee7`, admissions AS ON THIS BRANCH (my rows break nothing that was already working):**

```
OK: openxdox_code (opensoft/openXdox-code) at b075fd91dc8f (opendox-carve-0),
    phase B — 96 row(s) arrived, 9 digest(s) verified, 85 declared-edit row(s) within their lines,
    4 unapplied; 2 of 2 declared replica(s) verified; 124 file(s) under scripts, src/openxdox, tests
    with none undeclared (1 scaffold, 2 replica, 23 created); 23 declared admission(s) used
```

**[2] The leg branch `build/corpus-adapter-implementation` `00fe775`, admissions as on oxF `main` `24f7a213` — this is what makes these rows load-bearing:**

```
FAIL: arrival-undeclared-file — src/openxdox/conformance_corpus.py sits under a declared root
      and no row places it, no scaffold file is named that, and its bytes are no replica's at
      the carve commit.
```

**[3] The same leg branch, admissions AS ON THIS BRANCH:**

```
OK: ... 129 file(s) under scripts, src/openxdox, tests with none undeclared
    (1 scaffold, 2 replica, 28 created); 28 declared admission(s) used
```

124 → 129 files, 23 → 28 created, and the refusal is gone. [1] says this branch breaks nothing that was already working; [2] says the five rows are needed; [3] says they are sufficient. Re-measured at oxF `main` `24f7a213` (#1068 merged into this branch) and at leg `00fe775`; the two counts are what the verifier USES at each tree, which is why they did not move when the file itself grew from 23 `created` rows to 27 on main and 32 here.

**[0] NOT THIS BRANCH, and recorded because somebody should look at it.** The same runner, at leg `main` with the admissions AS ON oxF `main` — that is, with no part of this branch in either input — refuses:**

```
FAIL: arrival-undeclared-file — src/openxdox/consumer_reach.py sits under a declared root
      and no row places it ...
```

`consumer_reach.py` IS declared, by a row identical in both files (`since: bfd95063`, an ancestor of leg `main`), so the refusal names a file that is not the problem. The only rows oxF `main` carries whose files leg `main` does not yet hold are the four Q7 `.css` extractions this repository's own #1068 declared — `dispose.css`, `gate-projects.css`, `gate.css`, `swb.css` — which openXdox-code receives when its `opendox` pin advances to `5c137a90`. So this reads as the expected window between the two repositories rather than a defect, and it is reproducible with this branch removed from both sides. It is reported and NOT worked around: the runbook's own remediation says to fix the destination and never the manifest, and neither end of that window is this PR's to move.

```
$ python -m pytest -q tests/carve_arrival
159 passed
```

## The five rows are PINNED, not just shape-checked

A review round on this PR named the gap exactly: `test_the_committed_admissions_file_keeps_the_ruled_seed_and_stays_well_formed`'s generic loop asserts ordering, uniqueness, 40-hex `since` and non-empty `reason` over whatever the file happens to hold, so a future edit could drop, swap or re-provenance any one of these five and still pass. None of them carries a manifest row (RULED OQ-C), so the admission is the only governed record that they may be at the destination at all.

`ecb44968` pins them, as the **ninth** such bump in that test and on the same footing as the eight above it: each of the five is asserted present with its own `since`, the three modules are asserted to share one introducing commit, and the two tests to share the other.

Mutation-proved rather than asserted — renaming ONE of the five rows in the admissions file:

```
FAILED tests/carve_arrival/test_verify_carve_arrival.py::test_the_committed_admissions_file_keeps_the_ruled_seed_and_stays_well_formed
1 failed, 158 deselected
```

## Sequencing

`--allow-created` was **not** used, and neither was `--replica-at` for these five: they are files the destination legitimately assembles (RULED OQ-C), which is exactly what a `created:` row is for. The admissions PR lands FIRST — the same order every `openxdox_code` row annotation in this file has taken (RULED Q-L1) — then openXdox-code#23, then whichever act moves the pin.

Until the leg PR merges, these five rows describe paths the pinned submodule does not yet carry. That is the normal state of a declaration that lands first, and it costs nothing: the verifier reads `created:` as an admission, never as an obligation, so a row for a path not present is inert rather than a refusal.

## What this act does NOT do

- **It does not move any pin.** The `openXdox/code` gitlink is untouched.
- **It does not edit `docs/opendox-carve-manifest.yaml`.** Nothing about what LEAVES openxFactory changes.
- **It does not touch `openspec/changes/`, `tasks.md` or the README OpenSpec Records block**, so this is the plain gate and not Rule 6. RULED Q-X1 (a) books the leg's act as a new § 4.5a `[oXd]` box in the bookkeeper's amendment #5 — a different pull request, not this one.
- **It admits five paths and no others.** The `openxdox_code` block's other 23 rows, and every other destination's block, are byte-identical to this branch's base.

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


Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 18, 2026 21:45
@sonarqubecloud

Copy link
Copy Markdown

@brettheap
brettheap merged commit 3ee8cd3 into main Sep 18, 2026
4 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

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

LANDED — lane openxfactory-4, 2026-09-18T21:46:42Z, PR #23 → 3ee8cd3 (opensoft/openXdox-code main; plain gate)

§ 4.5a: BUILD the corpus-adapter implementation (design § D4 machinery (1)) — neutral profile-parameterized reader, corpus shape, domain corpus adapter with tests; RULED Q-X1..Q-X4 (5715212264); Q-A2 docstring citation registered for the § 5.4 (d) openXdox leg

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.

Copilot review overview

🟡 Changes recommended

Address the critical confinement race and moderate empty-glob validation issue.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)

Comment on lines +511 to +516
target = self._require_confined(Path(corpus.location), path,
Path(document.key))
try:
with open(path, "rb") as handle:
self._require_opened_what_was_checked(
os.fstat(handle.fileno()), target, document.key)
brettheap added a commit that referenced this pull request Sep 18, 2026
Second of two commits. The pin's values are CI's own, from the run the
first commit produced — run 35399041710, PR #25:

  TRIPLE  selected=539  passed=533  skipped=6  failures=0  errors=0

so MIN_SELECTED 539 and MIN_PASSED 533 as FLOORS, EXPECT_SKIPPED 6
EXACTLY, and failures and errors zero.

THE MEASUREMENT AGREES WITH THE FILE'S OWN ACCOUNT OF ITSELF, which is
what makes the exact pin safe to take here rather than merely possible:
the step above already said "The 6 skips that remain are the three seam
suites' `doc_health` pairs, which no pin bump touches", and the report
says six. EXPECT_SKIPPED is pinning a number somebody already understood.

WHAT IS PINNED IS WHAT THIS JOB COLLECTS — the 16-file named list under
`--noconftest`, never a directory, while 85 `test_*.py` exist under
`tests/`. The file states why a directory run is unavailable rather than
merely unused: "`tests/conftest.py` imports the carved session fixtures,
which reach both absent packages." Pinning a number this job does not
produce would pin nothing. So what moves these numbers is editing that
list, and nothing else — no conftest is loaded, so no collection-ignore
mechanism can reach them. (That last point is the correction Copilot
forced on the sibling leg, openDox-code#29; it is written correctly here
the first time.)

PROVED, not assumed — the step's own script extracted from the YAML and
run against fixtures in three states:

  the measured state                     exit 0
  the report absent                      exit 1, names the missing report
  one collected test turns into a skip   exit 1, "skipped 7, pinned exactly 6"

One report and not the sibling's three, because this job runs pytest
once: a single `--junitxml` path cannot be overwritten, and an absent
report is a refusal rather than a zero the floors would read as an empty
suite.

Q-A2, FOLDED AS ONE NON-NORMATIVE LINE (its own REC (a)). The docstring
at tests/test_domain_corpus_adapter.py ends "The question is registered
in this PR rather than decided in it" — true when written on #23, and
reading OPEN now that the question is ruled. It gains the citation
(openxFactory#656 comment 5728368325, 2026-09-18: LEAVE AS IS) and
nothing else: no assertion, no fixture, no test behaviour.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
brettheap added a commit that referenced this pull request Sep 18, 2026
…e on the required check (#25)

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

Second and last sub-act under `split-opendox-two-layer-product` § 5.4's standing claim [`5705086862`](opensoft/openXfactory#656 (comment)); this PR's CLAIMED note is [`5736634701`](opensoft/openXfactory#656 (comment)). The openDox leg landed as `openDox-code` [#29 → `373b05aa`](opensoft/openDox-code#29).

# § 5.4 FLOOR PART 2, clause (d) — the openXdox LEG

The clause, from the ledger at `openspec/changes/split-opendox-two-layer-product/tasks.md:2768-2775`:

> **(d) PINNED BY TEST** at each destination and in `openxFactory` … the way `pytest-suite.yml` already pins this repository's collection triple — **SKIPPED exactly, SELECTED and PASSED as FLOORS, failures and errors zero**. **Per destination, never as one cross-repository equality.**

Unblocked by **#23 → `3ee8cd31`**, which discharged § 4.5a (`tasks.md:1873`) — the blocker the ledger named for this leg at `tasks.md:2843-2846`.

## What the required job actually collects — measured, not assumed

This repository has **one** job, `validate`, and it runs pytest **once**:

| | |
| --- | --- |
| collection | a **NAMED LIST of 16 files**, never a directory |
| conftest | `--noconftest` — no conftest is loaded |
| on disk | **85** `test_*.py` under `tests/` |

A directory run is not merely unused here, it is **unavailable**, and the file says so itself:

> `--noconftest` STAYS, and it is why this list is a list: `tests/conftest.py` imports the carved session fixtures, which reach both absent packages. Every file named here stands on its own under it.

**So the pin covers the 16-file list — what the required check actually collects — and nothing else.** That is the honest object: pinning a number the required job does not produce would pin nothing. It also means what moves these numbers is **editing this list**, exactly as on the openDox leg, and neither `conftest.py` nor any collection-ignore mechanism can move them.

ONE report here, not the sibling's three, because this job runs pytest once: a single `--junitxml=pytest-report.xml` cannot be overwritten, and a missing report exits hard rather than producing a silently smaller sum.

## The pin is measured on CI

Two commits, as on the openDox leg: the first emits the report and PRINTS the triple; the second pins it using the numbers from the first commit's own run, whose URL is below. The reference implementation gives the reason — *"THE PIN IS TAKEN FROM CI'S OWN RUN, NOT FROM A DEVELOPER MACHINE"* — and this leg has the same self-skip shape.

Mirrors `openxFactory/.github/workflows/pytest-suite.yml` — `:599` (the report), `:671-672` (floors), `:782` (`EXPECT_SKIPPED`, exact), `:829` (the XML parse), `:877-881` (the assertions).

**Measuring run:** [35399041710](https://github.com/opensoft/openXdox-code/actions/runs/35399041710) — green, and its `Measure the triple` step printed:

```
TRIPLE selected=539 passed=533 skipped=6 failures=0 errors=0
```

So `MIN_SELECTED: "539"`, `MIN_PASSED: "533"` as floors, `EXPECT_SKIPPED: "6"` exactly, failures and errors zero.

**The measurement agrees with the file's own account of itself**, which is what makes the exact pin safe to take rather than merely possible — the pytest step already said *"The 6 skips that remain are the three seam suites' `doc_health` pairs, which no pin bump touches"*, and the report says six. `EXPECT_SKIPPED` is pinning a number somebody already understood.

**Proved, not assumed** — the step's own script extracted from the YAML and run against fixtures:

| state | result |
| --- | --- |
| the measured state | exit 0 |
| the report absent | exit 1, names the missing report |
| one collected test turns into a skip | exit 1, `skipped 7, pinned exactly 6` |

## Q-A2, folded in as one prose line

The docstring at `tests/test_domain_corpus_adapter.py:373` ends *"The question is registered in this PR rather than decided in it."* That was true on #23 and reads OPEN now that the question is ruled, so it gains a one-line **non-normative** citation of the ruling ([openxFactory#656 comment `5728368325`](opensoft/openXfactory#656 (comment)), 2026-09-18: LEAVE AS IS). Prose only — no assertion, no fixture and no test behaviour is touched. This is Q-A2's own REC (a), folded here because #23 has landed and this is the next act on that file.

## What this does NOT do

It does not tick § 5.4 — the tick rides the packet bookkeeper's amendment now that both legs exist, and no byte of `openspec/changes/split-opendox-two-layer-product/` is touched.

**A correction carried from the sibling leg, so it is not repeated here:** openDox's required job cannot have its numbers moved by this PR landing. All three of its report-producing commands pass `--noconftest` and name their files explicitly (35 named; overlap with its seven `collect_ignore` entries is **empty**). Copilot caught that against my first version of #29's comment and was right. The follow-up registered on openDox-code is `tests/test_triple_pin.py` (~60 lines, the three fixture states the step was proved against by hand), plus — as measurement with no action owed — the **26** `test_*.py` files there collected by no required command.

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


Lane: openxfactory-4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

3 participants