Repository navigation
BUILD the corpus-adapter IMPLEMENTATION (design § D4 machinery (1)): openXdox's neutral, profile-parameterized reader answers the conformance corpus 17 of 17 - #23
Conversation
…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>
Reviewer's GuideBuilds 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 readingsequenceDiagram
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
Sequence diagram for construction-data-driven classificationsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@copilot review |
There was a problem hiding this comment.
🟡 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_availablefixture; 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
_listingsis keyed only by location, revision, and scope. For an unversioned treerevisionis alwaysNone, and even a Git working tree can change whileHEADstays 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 returnFalsewhen the path exists but cannot be inspected (for example, a permission-denied parent), so this branch reportsCORPUS_ABSENTinstead of the documentedCORPUS_UNREADABLE; the surroundingexcept OSErrordoes not catch those suppressed errors. Use an operation such asPath.stat()(and distinguishFileNotFoundErrorfrom otherOSErrors) 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
sincorpuss, 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.
…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 review |
Co-authored-by: brettheap <1513478+brettheap@users.noreply.github.com>
There was a problem hiding this comment.
🟡 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
DocumentIdincludes the corpus identity, but this path validates onlydocument.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 foreigncorpusvalue, so the adapter serves an identity that does not belong to the resolved corpus. Reject a mismatcheddocument.corpusbefore 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 raiseOSErrorduring this walk. That exception escapes as a raw filesystem error even thoughresolve()documentsCORPUS_UNREADABLEas 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, andcheckcontinue 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
…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
There was a problem hiding this comment.
🟡 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,
resolvetherefore succeeds and listings omit this malformed/unreadable part of the corpus instead of refusing; for example, anotesfile plus a validpapers/directory resolves as a partial corpus. Reject an existing non-directory root asCORPUS_UNREADABLEbefore 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 (minusAMBIENT_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 manyOSErrors (including permission-denied errors) and returnsFalse, so an existing but inaccessible corpus path can be reported asCORPUS_ABSENTinstead of the requiredCORPUS_UNREADABLE. Probe the path with an operation that distinguishesFileNotFoundErrorfrom otherOSErrors, 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 tocorpus'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
Addressed locally in |
Co-authored-by: brettheap <1513478+brettheap@users.noreply.github.com>
There was a problem hiding this comment.
🟡 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
notesas a file resolves asCORPUS_UNCLASSIFIABLE(or may fall back to another root) instead of theCORPUS_UNREADABLErefusal 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-139rejects 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_keyswalks everyscan_rootfor every scope, even when a scope's globs are confined to one root. Consequently a call such aslist_documents(corpus, "governance-document")on a profile with several roots scans the entire corpus, andSCOPE_ALLrepeats 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
…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>
…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>
|
Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Round fourteen — the TOCTOU disclaimer becomes a measured guarantee
What was there. Why neither proposed remedy applies, which is the argument for the third.
So the race is not prevented; it is detected, while the bytes are still unread. The descriptor is opened first,
Where a filesystem numbers no files ( 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.
Refs #656 (stays OPEN). CLAIM comment |
|
Lane: openxfactory-4 (openXfactory-4-openDox_extraction) @copilot review The TOCTOU finding is accepted and fixed at |
There was a problem hiding this comment.
🟡 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
--noconftestcommands 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
DocumentIdfrom a different corpus; it never verifies that a same-corpus key was actually listed. With a reachable path whoseroutesaccepts arbitrary keys (the test helper'slambda key: keyis 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.readandclassifyenforce listing membership, sowrite_backshould fail closed withWRITE_PATH_UNREACHABLEbefore callingroutes/dispatchwhen 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
…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>
|
Lane: openxfactory-4 (openXfactory-4-openDox_extraction) Q-A — the dirty-work-tree reader — is RULED: LEAVE AS ISBrett Heap, 2026-09-18 ~09:55Z, by interactive multi-choice; openxFactory#656 comment 5728368325, item 3:
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 Nothing follows for this branch, and that is measured rather than assertedThe ruling is what the code at This reader's whole revision notion is It cannot be consulted, because those two lines are the only git this reader ever runs: Both subcommands are And the working tree is what gets served, stamped with that commit. The behaviour is pinned rather than incidental. 160 is the figure this PR's body and No commit follows from the rulingNo 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 Q-A is closed. Head unchanged at |
There was a problem hiding this comment.
Sorry @brettheap, your pull request is larger than the review limit of 150,000 diff characters
…§ 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>
|
|
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 |
| 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) |
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>
…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>




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-productdesign.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 PINNEDopendox.corpus_adapter(RULED OQ-2 / OQ-Q — the interface is openDox's and is never replicated here):src/openxdox/corpus_shape.pyScope,WriteProposal,WritePath,CorpusShape) andfrom_profile(), which derivesscan_rootsand one scope per artifact kind from a registeredDomainProfile'sartifact_kinds[].locationssrc/openxdox/domain_corpus_adapter.pyDomainCorpusAdapter— the interface's six operations over oneCorpusShapesrc/openxdox/conformance_corpus.py--adapterfactory § 3.7's runner resolvesTwo NEW test files, appended LAST to
.github/workflows/validate.yml's explicit--noconftestlist (a file not on that list is silently never run):tests/test_corpus_shape.py(58) andtests/test_domain_corpus_adapter.py(84).No existing module is edited. The only non-new file this PR touches is the workflow.
The measurement
Measured at openXdox-code
589adee7/ openxFactory7e074ac9, 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 alsoOK — 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 --porcelainin 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.gitsymlink 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 byis_file()before confinement, a root probed withis_dir()whoseOSErrorit 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_ofreading a trailing\differently from every other rule in its own module,write_backacting 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 acontinue, 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), andwrite_backraising 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'sWeakKeyDictionaryfor the listing snapshot buys no isolation a plain dict does not (the pinnedResolvedCorpusisfrozen=True, eq=True, so it hashes by value), makes the module depend on that dataclass being weak-referenceable (slots=Falsetoday, an undeclared property of an interface this leg does not own), and leaves a hand-builtResolvedCorpus— 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 withsetdefault. 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
5542823211): "openDox defines a corpus-adapter interface; openXdox implements it." The ruling that puts an implementation here at all.5544370242): openXdox is the domain-mapping core, PARAMETERIZED.from_profile()is where that lives.5547060378, § D6 (3)): every destination passes the neutral corpus; openXdox's adapter implementation is named in terms.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, landedea4e6ff2). Two readers over one corpus would be DQ-1's collapse risk back.5715212264):kind_fieldandrequired_fields_by_kindare CONSTRUCTION DATA onCorpusShape, exactly as openxFactory's § 2.2a shape carries them. NoDomainProfileschema 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_healthreachtests/test_dependency_direction.py'sDOC_HEALTH_SURFACEis unchanged at 8 modules / 13 statements, and that file is not edited by this PR:The five modules that would have been the obvious things to reuse —
corpus_root,completeness,round_trip,generator,snapshot_registry— all reachdoc_healthat 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+2029do not.checkreturning()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.pyis 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 throughCorpusShape.verdict, andcheck-severitiespasses on the empty answer.Suite, and every assertion mutation-proved
mutate.py(persisted with this lane's evidence, not added to this repository) applies 69 deliberate defects one at a time tocorpus_shape.pyanddomain_corpus_adapter.pyand runs the two files against each: the file-location refusal answeringcorpus-unclassifiable; the declared write path becoming a module constant;readfalling back to a revision nobody asked for; an undeclared scope widening silently;write_backwriting 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_backdispatching 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:
_gitinherited the ambient environment, andGIT_DIR/GIT_WORK_TREE— which git exports to every hook it runs and togit rebase --exec— override-C. Measured directly: a corpus at its own commit128660daanswereddd09f3df, the ambient repository's, purely because the environment said so.AMBIENT_GIT_VARIABLESis 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
026b042correctsreal_lines. This module states in terms that the CR/LF/CRLF rule is adopted rather than imported —doc_health.linesis openxFactory's and a neutral reader may not reach for it — andre.splitalone 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 becausereal_linesandheader_windoware 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 againstdoc_health.lines.split_keependsitself, 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
floor37measured openDox-code #26 at6c8f19e7on 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:corpus-unreadable, nevercorpus-unclassifiable. The interface's own comments are the vocabulary, and the corpus's README holds every reader to it.read-only-declared-at-resolutionfails,write_back's own read-only branch becomes unreachable, and a refused write lands in the tree.And one more, which is floor37's unasked-for finding: this reader never adopts an enclosing repository.
_revisionlooks 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
opendox_codetoo, 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.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 ownNaprecedent (§ 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."openspec/changes/, so this is the plain gate and not Rule 6.xdox-v1.0(§ 4.6).DomainProfileaxis. RULED Q-X3 (a) keeps the header vocabulary as construction data; the profile axis is registered as the successor, not done here.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 newtests/files are CREATED files underopenxdox_code's walked roots, so they needcreated:rows in openxFactorydocs/opendox-carve-admissions.yamlorverify-carve-arrival.py --destination openxdox_code --phase Brefuses. That is a companion PR at openxFactory (chore/admit-openxdox-corpus-adapter), whosesince:names this branch's commits.🤖 Generated with Claude Code