Skip to content

T100 follow-on 2: #86's deferred trust-store items D1-D4 and D6 (plan 034) - #88

Merged
brettheap merged 2 commits into
mainfrom
followon/t100-deferred-d1-d6
Oct 5, 2026
Merged

brettheap merged 2 commits into
mainfrom
followon/t100-deferred-d1-d6

Conversation

@brettheap

@brettheap brettheap commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Arc: neutral-product-standalone-operability

What this is

Slice A of release 1's follow-ons. It covers the deferred items in openDox-code#86's "Deferred to a follow-on (not release 1)" section that sit in the trust and binding modules: D1 to D4 and D6. Each gets the remedy that section names. The holder ruled on Copilot's eighth review in openxFactory#656 comment 5992038800. Brett Heap's word is comment 6000582654 ("openDox-code follow-ons first"), and the claim is comment 6000611731.

  • Release. This lands after opendox 0.1.0, which was built from dede32b4. It reaches users only in a later release, and that release needs Brett's publish word. It moves no release-1 pin.
  • Scope. Only src/opendox/doxbench_trust.py, src/opendox/doxbench_binding.py and two new test files change.
  • Not here. D5 (the declarations document's broker member ceiling), F1 and F2 are slice B, lane openXfactory-3's. Slice B imports MAX_JUDGED_MEMBERS by name, and this change keeps that name.

Each item, its remedy and its test

Every case is in a new file:

  • tests/test_doxbench_trust_followon.py holds D1 and D6.
  • tests/test_doxbench_binding_followon.py holds D2, D3 and D4.

"Red" means the case fails at 389e5a4a (main) for its item's own reason. "Pin" means the case holds a rule that a mutant of the remedy would break.

# Remedy Tests
D1 (r4182645599) _bytecode_caches treats only absence as "no cache": FileNotFoundError, NotADirectoryError, or a path holding a NUL, which no file system holds (judged as written, as before, r4179077018). A listing that fails for any other reason is reported, and the command is refused as unreadable, FAIL-CLOSED (_Unlistable); in_repository_argv returns the member. The refusal is asked only once no member names a file inside the repository, as xargs's is (5988818366), so a cache named inside keeps its name. _Unlistable and _TooManyLinks share a base, _Unjudgeable, which both catch sites now catch. REASON_UNREADABLE_COMMAND names the new cause. Red: test_D1_a_cache_directory_that_cannot_be_listed_is_refused_as_unreadable (Copilot's case: another interpreter's tag linked into the repository; and an empty directory; each by -m broker and -mbroker), test_D1_a_packages_cache_directory_that_cannot_be_listed_is_refused, test_D1_a_listing_that_fails_part_way_is_refused_as_unreadable. Pins: test_D1_a_cache_named_inside_keeps_its_name, test_D1_a_cache_directory_that_is_not_there_is_no_refusal[no-directory, a-file-in-its-place, a-name-holding-a-nul]. The existing test_R6_a_cache_is_judged_by_name_where_its_directory_cannot_be_listed still holds.
D6 (r4182645836) The directory is streamed with os.scandir(). A step of the budget is spent for the listing and one before each entry is kept, and nothing is sorted. A directory of any size costs no more than the command's budget. Red: test_D6_a_cache_directory_is_charged_as_it_is_listed: a directory of a million entries is refused as unreadable in under a second, having drawn no more entries than the budget holds, and is never listed whole. Pin: test_D6_the_listing_and_each_entry_are_a_step_each, which checks the exact steps and what is kept. At 389e5a4a it fails only on the new unlisted keyword.
D2 (r4182645661) write_settings_document's staging cleanup is best-effort (contextlib.suppress(OSError)) for both kinds of new file: a new document's staging name, and the temporary file an existing document is replaced from. A removal that fails never reports a published document as unwritten, and never hides the error that failed a write. The new file is then left beside the document. Red: test_D2_a_staging_name_left_behind_never_fails_a_published_write (the function itself, and add through the CLI, which declares and trusts), test_D2_an_earlier_error_is_never_masked_by_the_cleanup[new, existing]. Pin: test_D2_a_staging_name_is_removed_where_it_can_be
D3 (r4182645700) The ceiling's refusal names the document by shown_path(self.path), on read and on write. Red: test_D3_the_ceilings_refusal_prints_the_documents_path_escaped (a checkout path holding a newline and an ESC sequence)
D4 (r4182645752) BindingStore._save() counts the members across the bindings it would write and refuses past MAX_JUDGED_MEMBERS before anything is published (_held_to_the_ceiling, the same rule that is applied on read). The old document survives and still reads. The refusal says "so it was not written and nothing in it changed". The CLI's existing _undone then takes back the provisional trust. cli_model_binding.py is unchanged. Red: test_D4_a_write_past_the_ceiling_is_refused_before_it_publishes[add, edit], test_D4_a_new_document_past_the_ceiling_is_never_made, test_D4_an_add_past_the_ceiling_trusts_nothing (CLI: rc 1, document byte-identical, no trust held), test_D4_an_edit_past_the_ceiling_keeps_what_was_trusted[trusted, untrusted] (CLI: the earlier form trusted again where it was trusted, and the new form's trust withdrawn where it was not). Pins: test_D4_a_write_at_the_ceiling_is_written[add, edit], test_D4_an_add_and_an_edit_at_the_ceiling_are_trusted, test_the_ceiling_is_the_one_ruled

Behavior changes an operator sees

  • A broker command run by -m is now refused as unreadable when a __pycache__ it could import from cannot be listed. That covers a directory on the start directory or the effective PYTHONPATH that this user may search but not list, or one whose listing fails part way. A missing directory, or a file in its place, is no refusal.
  • add or edit of a binding that would take the bindings document past 256 broker command members is refused, and nothing is written. Before, it was written, and the document was then refused on every later read.
  • A staging name that cannot be removed after a publish no longer fails the write. A second name of the published file may be left beside it.

Evidence

  • Red at 389e5a4a: 18 failed, 9 passed with these two files placed on main. 17 fail for their item's own reason. The 18th is the D6 step pin, which fails on the new keyword.
  • Mutants: 30 mutants (13 for D1, 6 for D6, 4 for D2, 1 for D3, 6 for D4), and all 30 are killed. Each runs against the two new files under its -k, and the whole of the two files plus tests/test_model_binding_trust.py where those pass.
  • Full suite in CI's install shape (pip install --only-binary :all: -c constraints-cpython312-linux.txt -e ".[runtime,test]", python -m pytest -q, no database locally): at e02e7554, 5229 passed and 177 skipped locally, where the Postgres cases skip without a database; CI's validate at the same head, with its database, 5395 passed and 11 skipped.

Notes for review

  • No closing keywords. This pull request names T100 follow-on: the trust store's review findings (plan 034) #86 only as the record of the deferred items.
  • Copilot's review threads are answered under the holder's convergence rule (openxFactory#656 comment 5988818366): each is fixed now, or recorded as an accepted limit with its reason, then resolved.

🤖 Generated with Claude Code

brettheap and others added 2 commits October 5, 2026 18:49
…D6 (plan 034)

Two new test files hold openDox-code#86's deferred trust-store items, each
as #86's "Deferred to a follow-on (not release 1)" names its remedy (the
holder's ruling, openxFactory#656 comment 5992038800; Brett Heap's word,
comment 6000582654). 17 cases fail at 389e5a4, each for its item's own
reason. The other 10 pin a rule that a mutant of the remedy would break.

- tests/test_doxbench_trust_followon.py: D1 (r4182645599), D6 (r4182645836)
- tests/test_doxbench_binding_followon.py: D2 (r4182645661), D3
  (r4182645700), D4 (r4182645752)

Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… 034)

Each item is remedied as openDox-code#86's "Deferred to a follow-on (not
release 1)" names it (the holder's ruling, openxFactory#656 comment
5992038800; Brett Heap's word, comment 6000582654).

- D1 (r4182645599): in `_bytecode_caches`, a cache directory whose
  listing fails for any reason but its absence (`FileNotFoundError`,
  `NotADirectoryError`) refuses the command as unreadable, FAIL-CLOSED
  (`_Unlistable`). It is asked once no member names a file inside the
  repository, as xargs is (5988818366), so a cache named inside keeps
  its name. A path holding a NUL lists nothing, as before.
- D6 (r4182645836): the directory is read with `os.scandir()`. A step
  of the budget is spent for the listing, and one before each entry is
  kept. Nothing is sorted.
- D2 (r4182645661): `write_settings_document`'s staging cleanup is
  best-effort (`contextlib.suppress(OSError)`), for a new document's
  staging name and an existing one's temporary, so it never masks a
  completed publish or an earlier error.
- D3 (r4182645700): the ceiling's refusal names the document by
  `shown_path(self.path)`.
- D4 (r4182645752): `BindingStore._save()` counts the members and refuses
  a write past `MAX_JUDGED_MEMBERS` before publishing, so the old document
  survives and the CLI's `_undone` takes back the provisional trust.

Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 5, 2026 19:09
@sourcery-ai

sourcery-ai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Reviewer's Guide

This follow-on implements trust and binding remedies D1-D4 and D6: trust inspection now streams and fails closed on unlistable bytecode caches within the work budget, binding writes enforce the 256-member ceiling before publication with escaped diagnostics, and staging cleanup no longer masks write outcomes.

Sequence diagram for fail-closed module trust inspection

sequenceDiagram
    participant Broker
    participant Trust as doxbench_trust
    participant FS as Filesystem

    Broker->>Trust: _command_refused(members, root)
    Trust->>Trust: _in_repository_member(members, root)
    Trust->>Trust: _module_paths(name, roots, unlisted)
    Trust->>FS: os.scandir(__pycache__)
    loop Within work budget
        FS-->>Trust: directory entry
        Trust->>Trust: _spend()
    end
    alt Listing is absent, not a directory, or contains NUL
        Trust-->>Broker: continue without cache refusal
    else Listing fails with another OSError
        Trust-->>Broker: REASON_UNREADABLE_COMMAND
    end
Loading

Sequence diagram for bounded binding document writes

sequenceDiagram
    participant CLI
    participant Store as BindingStore
    participant FS as Filesystem

    CLI->>Store: _save(bindings)
    Store->>Store: _refuse_a_link()
    Store->>Store: _held_to_the_ceiling(bindings, writing=true)
    alt More than MAX_JUDGED_MEMBERS
        Store-->>CLI: BindingRefused
        CLI->>CLI: _undone()
        Note over Store,FS: No document is published
    else At or below MAX_JUDGED_MEMBERS
        Store->>FS: write_settings_document(path, text)
        FS-->>Store: published document
        Store-->>CLI: success
    end
Loading

Flow diagram for best-effort staging cleanup

flowchart TD
    A[write_settings_document] --> B{Document exists?}
    B -- No --> C[Write staged file]
    C --> D[Publish with hardlink]
    D --> E[Suppress OSError from staged.unlink]
    B -- Yes --> F[Write temporary replacement]
    F --> G[Replace document]
    G --> H[Suppress OSError from temporary.unlink on failure]
    E --> I[Return publish result]
    H --> J[Reraise original write error]
Loading

File-Level Changes

Change Details Files
Make broker trust evaluation fail closed when Python bytecode-cache directories cannot be completely inspected, while preserving bounded judgment cost.
  • Replace whole-directory sorting with budgeted streaming via os.scandir().
  • Treat missing, non-directory, and NUL-containing paths as cache absence, but record other listing failures as unreadable.
  • Propagate unjudgeable module members through repository checks and unreadable-command reporting, with repository matches taking precedence.
src/opendox/doxbench_trust.py
tests/test_doxbench_trust_followon.py
Make binding-document writes enforce the broker-member ceiling before publication and improve refusal diagnostics.
  • Materialize pending bindings and reject totals above MAX_JUDGED_MEMBERS before serialization or replacement.
  • Use shown_path() for escaped document paths in both read and write ceiling errors.
  • Preserve existing documents and allow the CLI to withdraw provisional trust after a refused write.
src/opendox/doxbench_binding.py
tests/test_doxbench_binding_followon.py
Make staging-file cleanup best effort without masking publication or write errors.
  • Suppress OSError while removing staging files for both new-document and replacement flows.
  • Leave an unremovable staging alias or temporary file in place while retaining the original write outcome.
  • Cover successful publication, cleanup failure, and earlier write-error precedence.
src/opendox/doxbench_binding.py
tests/test_doxbench_binding_followon.py

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

@sonarqubecloud

sonarqubecloud Bot commented Oct 5, 2026

Copy link
Copy Markdown

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

🔵 Needs a closer look

Security-sensitive filesystem trust decisions and atomic persistence behavior warrant final human review.

Review effort: Balanced
Findings: None

What changed in this PR

Adds fail-closed trust checks and safer binding persistence for deferred D1–D4 and D6 items.

Changes:

  • Stream and budget bytecode-cache inspection, refusing unlistable caches.
  • Make staging cleanup best-effort and enforce binding-member limits before writes.
  • Add regression, boundary, rollback, and diagnostic tests.
File Description
src/​opendox/​doxbench_trust.py Handles unlistable caches within bounded trust evaluation.
src/​opendox/​doxbench_binding.py Improves cleanup and pre-write ceiling enforcement.
tests/​test_doxbench_trust_followon.py Covers cache failures and work budgeting.
tests/​test_doxbench_binding_followon.py Covers cleanup, limits, escaping, and rollback.

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

@brettheap

Copy link
Copy Markdown
Contributor Author

READY at e02e755 — Lane: openxfactory-4 (openXfactory-4-openDox_extraction)

Holder: release-1 follow-on slice A, T100 follow-on 2: #86's deferred trust-store items D1, D2, D3, D4 and D6. Copilot's eighth review on #86 named them and 5992038800 ruled on them. The authority is Brett Heap's word 6000582654, and the claim is 6000611731. It is an arc follow-on, with Arc: neutral-product-standalone-operability. It lands after 0.1.0, reaches users only in a later release, and moves no release-1 pin.

  • The fixes, each as T100 follow-on: the trust store's review findings (plan 034) #86's body names it:
    • D1: a cache directory that cannot be listed refuses as unreadable;
    • D2: the staging cleanup is best-effort;
    • D3: the ceiling refusal names shown_path(...);
    • D4: _save() refuses a write past MAX_JUDGED_MEMBERS before it publishes;
    • D6: os.scandir() streaming, with a step charged per entry and no sorted().
  • The writer's six calls, all upheld by the holder:
    1. D2 also makes the existing-document branch's temporary.unlink best-effort. It could mask an earlier error the same way, and it is pinned by a test.
    2. D1 refuses only after the in-repository judgment, following the xargs ordering in 5988818366, so a cache named inside the repository is still refused as in-repository.
    3. Absence means a missing directory, a file in its place, or a NUL path, as r4179077018 rules.
    4. _Unjudgeable is a shared base.
    5. REASON_UNREADABLE_COMMAND names the unlistable cache.
    6. A -m broker whose import cache cannot be listed is now refused. That is fail-closed, as ruled.
  • Gates.
    • validate (5395 passed, 0 failures), acceptance and SonarCloud pass.
    • Copilot raises no findings at the head, and there are 0 threads.
    • 30 of 30 mutants are killed.
    • Red-first: 17 cases fail on 389e5a4a for their own item's reason.
    • No closing keyword.
    • Only doxbench_trust.py, doxbench_binding.py and two new test files change. Slice B's files are untouched.
  • Noted for later, not in this slice: five other refusals in BindingStore._load still print the raw path, the same class as D3.

@sourcery-ai

sourcery-ai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 22 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@brettheap
brettheap merged commit 8197bb4 into main Oct 5, 2026
5 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

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

LANDED — lane openxfactory-4, 2026-10-05T19:32:57Z, PR #88 → 8197bb4 (opensoft/openDox-code main; plain gate)

Brett: land phase 1 / phase 2 PRs when green

brettheap added a commit that referenced this pull request Oct 5, 2026
…red broker's ceiling, and the trust line under a host (plan 034) (#87)

Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Authored by lane openXfactory-3, delegated by lane openxfactory-4 (#656 6000630835)

Release 1's follow-on slice B, plan 034: the declarations side and the CLI trust line. Brett Heap's word after release 1 was *"openDox-code follow-ons first (Recommended)"* (openxFactory#656 comment 6000582654). Lane openxfactory-4 delegated this slice to lane openXfactory-3 in its follow-ons brief. The claim is openxFactory#656 comment 6000630835. Like openDox-code#86, this is a realization follow-on of #1144's 16.3a, so it carries the arc's trailer. Slice A, run by lane openxfactory-4's own writer, owns `doxbench_binding.py` and `doxbench_trust.py`. This PR edits neither; it imports `MAX_JUDGED_MEMBERS` from the first.

**Release note.** This lands on openDox-code `main` after 0.1.0. It reaches users only in a later release, which needs Brett's publish word, so release 1's pins do not move.

**Sources and rulings:**
- **F1**: Copilot r4184739661 on openxFactory#1236, rated High. At T094's landing the holder recorded it as a release-1 accepted limit (READY 5996119122) and left it for this follow-on.
- **D5**: openDox-code#86's deferred r4182645796 (the holder's ruling 5992038800, "Deferred to a follow-on").
- **F2**: lane openxfactory-4's pre-review of openxFactory#1236. That PR's body lists it among its accepted limits and leaves it for an openDox-code follow-on.
- **Copilot and SonarCloud on this PR**: each finding is classed fix-now or accepted limit under the convergence rule, openxFactory#656 comment 5988818366.

## Each finding, its fix and its tests

"Red" means the case fails at `389e5a4a` (main), run against main's own source. The pins and controls pass there too.

| # | Fix | Tests |
|---|---|---|
| F1 | `DeclarationStore._open` replaces the store's `document_present` look. Only "no such file", or a file where a directory belongs on the way, is absence. Anything else in the document's place is refused by name, as `IntakeRefused`, in the refusal an unreadable document gets (`doxbench_binding.cannot_read`), naming what the path is: `the declarations document at "<path>" cannot be read (a directory, not a regular file)`. The same goes for a FIFO, a socket, a symbolic link, or a character or block device. The look is `os.lstat`, so a FIFO is refused without being opened. The open is `O_RDONLY \| O_NONBLOCK \| O_NOFOLLOW \| O_CLOEXEC`, and `os.fstat` on the descriptor decides, so whatever replaced the file after the look is refused for what it is, and nothing is ever read from it or waited on. The bytes are read through that descriptor and parsed in `read_settings_document`'s words (`_parsed`). A document that vanishes between the look and the open is refused, as main refused one that vanished between its look and its read. A platform without `O_NOFOLLOW` or `O_NONBLOCK` opens no document (Copilot r4187659916, below). `doxbench_binding.document_present` is unchanged. | `tests/test_doxbench_intake_store_kinds.py`. **Red:** `test_F1_a_non_regular_path_is_refused_by_every_read` (15: `pending_binding_ids`, `get`, `list`, `broker` and `read_back`, each over a directory, a FIFO and a socket); `test_F1_the_governed_hosts_policy_admits_nothing_over_it` (3, with a stand-in of openxFactory's `GovernedBindingTrust` as T094 landed it at `36908480`, asked through `verdict_for` and `intake_verdict_for`); `test_F1_no_write_lands_over_it` (6: `propose` and `declare_broker` × 3); `test_F1_a_fifo_in_the_documents_place_is_never_opened`; `test_F1_a_link_that_appears_after_the_link_rule_looked_is_never_read[dangling, a-file-outside]`; `test_F1_a_file_replaced_after_the_look_is_judged_by_its_descriptor[directory, fifo]`; `test_F1_a_file_replaced_by_a_link_after_the_look_is_never_read_through`; `test_F1_a_document_removed_after_the_look_is_not_read_as_none`; `test_F1_a_platform_without_the_opens_guards_opens_no_document[no-nofollow, no-nonblock, neither]`. **Pins and controls:** `test_F1_a_link_in_the_documents_place_is_unreadable_not_absent[dangling, a-directory, a-fifo]` (#86's N1 already refuses these); `test_F1_no_document_is_still_no_document`; `test_F1_a_look_that_fails_is_never_absence`; `test_F1_a_regular_document_still_reads`; `test_F1_the_port_factorys_pending_set_still_reads_a_refusal_as_empty` (3); `test_F1_the_declarations_parse_refuses_in_the_bindings_stores_words` (4). |
| D5 | `BrokerDeclaration` refuses more members than `doxbench_binding.MAX_JUDGED_MEMBERS` (256), which it reads from that module when a broker is declared and never restates. The refusal reads `a broker declaration declares 257 broker command members, more than the 256 judged in one document; name the broker program and its fixed leading arguments only`. It is held at construction, so `from_record` (every read of the store) and `declare_broker` (the write) both refuse, and no write can cross it. So the shape of the bindings store's r4182645752 (slice A's) cannot arise here. The console intake's surface reads the broker through `read_back` and offers nothing over a refused document, so `broker_command_refused` never scans more than 256 declared members. | `tests/test_doxbench_intake_broker_ceiling.py`. **Red:** `test_D5_a_broker_past_the_ceiling_is_refused_by_name` (ceiling + 1); `test_D5_the_ceiling_is_imported_never_restated` (with the ceiling patched to 3: 3 read, 4 refused); `test_D5_a_document_whose_broker_passes_the_ceiling_is_refused[broker, get, pending_binding_ids, read_back]`; `test_D5_no_write_crosses_the_ceiling`. **Control:** `test_D5_a_broker_at_the_ceiling_is_read` (exactly 256). |
| F2 | `_trusted_line(binding, recording)` takes the `TrustRecording`. Where the policy recorded nothing (`recorded` is false: a host's policy whose `record()` answers nothing, as openxFactory's governed one does), the line is `  trusted "<id>" by the host's trust policy for "<root>"` (`TRUSTED_BY_THE_HOSTS_POLICY`). Where a record was written, it is byte for byte `  trusted "<id>" on this machine for "<root>"`. `add`, `edit`, `set-credential` and `trust` each pass their own recording. | `tests/test_cli_model_binding_trusted_line.py`. **Red:** `test_F2_a_host_that_recorded_nothing_is_named_as_what_trusts_it[add, edit, set-credential, trust]` (the exact line, no "on this machine", and nothing written to the state directory). **Byte-identity pins**, exact-string: `test_F2_a_record_written_on_this_machine_keeps_its_exact_line[add, edit, set-credential, trust]`. |

## F1's dangling link: unreadable, not absent

The brief asked whether a dangling symbolic link at the declarations path counts as absent or unreadable. This PR reads it as **unreadable**, which fails closed, for three reasons.

1. **F1's purpose.** A path that exists (`lstat` succeeds) but names nothing that can be read is not "no document". Read as absent, it declares nothing pending, and the governed host trusts every binding: the hole F1 closes.
2. **It is already the store's rule for a link a clone carries.** The link rule (#86's N1) refuses a link at the document's name, or at `ideation/` or `ideation/dashboard/`, before anything is read, whatever the link names, a missing target included. `test_F1_a_link_in_the_documents_place_is_unreadable_not_absent[dangling]` pins that, and it passes at main too.
3. **The read path now judges a link as itself, so the decision does not rest on N1's look alone.** A dangling link that appears after that look is refused as `a symbolic link, not a regular file`. That is `test_F1_a_link_that_appears_after_the_link_rule_looked_is_never_read[dangling]`, red at main, where the link read as no document and the binding was trusted.

No concrete reason for the other reading was found: a dangling link is no more an operator's "nothing declared" than a directory is.

## Behavior changes an operator sees

- A directory, a FIFO, a socket or a device at the declarations path is refused by name: `the declarations document at "<path>" cannot be read (a directory, not a regular file)`. So is a link that appears there after the link rule looked. Under openxFactory's governed host, every binding then reads untrusted with that reason ("its declarations document cannot be read (…)"), until the path holds the document again or nothing.
- The console intake's surface is not offered over such a path, as before. Its writes (`propose`, `declare_broker`) are refused by name. At main, a directory there raised a raw `IsADirectoryError` from the write, a socket a raw `OSError`, and a FIFO hung the write, which opens the path for append and waits for a reader.
- `doxbench_intake.pending_binding_ids`, the port factory's own question, which passes over pending bindings, still reads any refusal as nothing pending, for the reason its docstring gives, so a hosted console is not taken down.
- A declared broker of more than 256 members is refused by name, both when it is read and when it is declared.
- Under a host whose policy records nothing, `add`, `edit`, `set-credential` and `trust` end with `trusted "<id>" by the host's trust policy for "<root>"`. Standalone, the line is unchanged.
- On a platform without `O_NOFOLLOW` or `O_NONBLOCK`, a declarations document that is there is refused by name. No CI runner and no deployment is such a platform.

## Evidence

- **Full suite, locally, at the final head `bc610409`:** **5265 passed, 177 skipped, 0 failed** (1176.96 s). It ran in a venv installed as `validate` installs it (`pip install --only-binary :all: -c constraints-cpython312-linux.txt -e ".[runtime,test]"`), with `LANG=C.UTF-8` and a short `TMPDIR`, as `python -m pytest -q --junitxml=… --basetemp=… -p no:cacheprovider`. **Main `389e5a4a`, the same way: 5202 passed, 177 skipped.** The 177 skips are the database-backed cases on a machine with no `OPENDOX_TEST_DATABASE_URL`; CI runs them against its `postgres:16` service. The difference is the 63 new cases.
- **CI at the final head:** `validate` succeeded (run 37361225935, job 111936023214) with `5431 passed, 11 skipped` and `triple: selected=5442 passed=5431 skipped=11 failures=0 errors=0`, a margin of 1465 on both floors. `acceptance` succeeded (job 111936023743), and so did SonarCloud Code Analysis. At `e50cc3ff`, with 60 of the 63 cases, the same job read `selected=5439 passed=5428 skipped=11`, so every new case runs on the runner and passes, and none skips.
- **Red at main:** the three new files run against `389e5a4a`'s own source give **45 failed, 18 passed**. Every behavior case fails there. The 18 that pass are the pins and controls named in the table.
- **Mutants: 22, every one killed, on the final source (`bc610409`).** Each edits the source at the final head, and runs against the new file for its fix, and against `tests/test_model_binding_trust.py` if it survived that. None did.

| Mutant | Killed by |
|---|---|
| F1-a: the look's kind guard dropped, so a socket or a FIFO is opened | `test_F1_a_non_regular_path_is_refused_by_every_read[broker-socket]` |
| F1-b: the descriptor's kind guard dropped | `test_F1_a_file_replaced_after_the_look_is_judged_by_its_descriptor[directory]` |
| F1-c: `O_NONBLOCK` dropped from the open | `test_F1_a_file_replaced_after_the_look_is_judged_by_its_descriptor[fifo]` (the open waits, and the case's 20-second limit fails it) |
| F1-d: `O_NOFOLLOW` dropped from the open | `test_F1_a_file_replaced_by_a_link_after_the_look_is_never_read_through` |
| F1-e: the look follows links (`stat` for `lstat`) | `test_F1_a_link_that_appears_after_the_link_rule_looked_is_never_read[dangling]` |
| F1-f: the guard negated to the old reading, a non-regular path is absent | `test_F1_a_non_regular_path_is_refused_by_every_read[broker-directory]` |
| F1-g: every failed look is absence | `test_F1_a_look_that_fails_is_never_absence` |
| F1-h: a document removed after the look is absence | `test_F1_a_document_removed_after_the_look_is_not_read_as_none` |
| F1-i: a kind misnamed (a FIFO called a directory) | `test_F1_a_non_regular_path_is_refused_by_every_read[broker-fifo]` |
| F1-j: the parse's refusal words drift from the bindings store's | `test_F1_the_declarations_parse_refuses_in_the_bindings_stores_words[not-utf-8]` |
| F1-k: the refusal not in an unreadable document's form | 29 cases, the 15 of `test_F1_a_non_regular_path_is_refused_by_every_read` among them |
| F1-l: a platform without the open's guards opens unguarded | `test_F1_a_platform_without_the_opens_guards_opens_no_document[no-nofollow]` |
| D5-a: the ceiling dropped | `test_D5_a_broker_past_the_ceiling_is_refused_by_name` |
| D5-b: the ceiling off by one (`>=`) | `test_D5_a_broker_at_the_ceiling_is_read` |
| D5-c: the ceiling restated as 256, not imported | `test_D5_the_ceiling_is_imported_never_restated` |
| F2-a: reverted, always "on this machine" | `test_F2_a_host_that_recorded_nothing_is_named_as_what_trusts_it[add]` |
| F2-b: the guard negated | `test_F2_a_host_that_recorded_nothing_is_named_as_what_trusts_it[add]` |
| F2-c: always the host's wording | `test_F2_a_record_written_on_this_machine_keeps_its_exact_line[add]` |
| F2-d to F2-g: one verb's line ignores its recording (`add`, `edit`, `set-credential`, `trust`) | `test_F2_a_host_that_recorded_nothing_is_named_as_what_trusts_it[add]`, `[edit]`, `[set-credential]` and `[trust]` in turn; `trust`'s mutant also fails `[set-credential]`, which runs `trust` first |

- **Beside slice A:** this branch merged locally with #88's head `e02e755` (slice A, still a DRAFT), with no textual conflict (`git merge-tree`). On that merged tree the 63 new cases and #88's 27 pass: `90 passed`. #88 changes none of the helpers this PR calls (`cannot_read`, `shown_path`, `linked_component`, `read_settings_document`'s words, `MAX_JUDGED_MEMBERS`).
- **Downstream:** two other repositories' tests use `DeclarationStore`. openxFactory's `tests/domain_profile/test_host_registers_binding_trust.py` and openXdox-code's `tests/test_doxchat_model_intake.py` were read at their mains, and neither pins a behavior this changes: a non-regular path read as absent, a broker past the ceiling, or the "on this machine" line under a host.

## Copilot

- **Round 1, review 5419251779 at `e50cc3ff`, "Changes recommended", one finding.** r4187659916 (High): `O_NOFOLLOW` and `O_NONBLOCK` fell back to 0 on a platform without them. **Fix now** in `ecbe72f0`. Such a platform opens no declarations document; one that is there is refused by name. This matches `runtime.local_git_adapter.NO_FOLLOW_WALK_IS_AVAILABLE`'s own rule. Answered (4187698785) and resolved. The review's overview also names parent-directory link races, with no thread of its own. That one is proposed below as an accepted limit.
- **Round 2, review 5419325120 at `ecbe72f0`, "Needs a closer look", no findings.**
- **Round 3, review 5419371864 at `bc610409` (the final head), "Needs a closer look", no findings.** Copilot reviewed each pushed head on its own, under the repository's Copilot review rule. A reviewer-API request at `bc610409` (19:12:21Z) registered none, since that head was already reviewed. 0 of 1 threads are unresolved.

## SonarCloud

- At `e50cc3ff` and `ecbe72f0`, the quality gate passed with 11 new issues, each classed as a Copilot finding would be, and each **fixed now** in `bc610409`. One was python:S1192: "declarations document" was written three times, and is now one constant, `_DOCUMENT`, with the words unchanged. Ten were python:S5778: exception tests holding more than one call that could raise. Each store, record and argv is now built before its `pytest.raises` block.
- At `bc610409` (analysis 19:09:54Z), the quality gate passed with **0 open issues**.

## Accepted limits (proposed; the holder rules at READY)

- **A link swapped in for `ideation/` or `ideation/dashboard/` while the store reads** (Copilot round 1's overview). The look and the open follow links in directories on the way, and `O_NOFOLLOW` guards only the document's own name. A clone cannot deliver this: the link rule refuses any link on the way within the checkout's own path before the read, so only a process racing the read could put one there. Whatever is opened through such a link is still judged by its descriptor's type. Reading through it yields nothing the repository could not have written in its own declarations document. The write path's equivalent race belongs to #86's N1 and `write_settings_document` (slice A's file), and is unchanged here. The follow-on would be a walk of `ideation/dashboard/` component by component, with `dir_fd` and `O_NOFOLLOW`, for both the read and the write.

## For the holder

- **`list`'s trust line** (`_trust_lines`) still reads "trusted on this machine" for a binding a host's verdict trusts. F2's finding named the line the acts print (`_trusted_line`), so `list` is unchanged here. It is the same class, and could be a follow-on.
- **The bindings document** still reads a non-regular path as absent (`doxbench_binding.document_present`, slice A's file). There, absent means no binding is used, which is the safe direction, so F1's hazard does not arise.
- **`_parsed` repeats `read_settings_document`'s four refusal sentences** rather than calling it, because that function reads by path and this store reads only through the descriptor it judged. `test_F1_the_declarations_parse_refuses_in_the_bindings_stores_words` holds the two stores to the same words. A shared helper that takes text would need a change to `doxbench_binding.py`, which is slice A's file.
- **The triple pin's floors are not moved**, as #86 left them. The 63 cases raise selected and passed by 63 and skip nothing on the runner, so `EXPECT_SKIPPED` stays 11.
- `Path.resolve()` raises `RuntimeError` on a checkout root that is itself a looping link, before any policy is asked (`resolved_root`). That is pre-existing and outside this slice.

## Commits

- `6ca46e8a`: F1, D5 and F2, with their tests.
- `e50cc3ff`: a document removed after the look is refused, not read as none.
- `ecbe72f0`: Copilot r4187659916, a platform without the open's guards opens no declarations document.
- `bc610409`: SonarCloud's new issues.

Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Arc: neutral-product-standalone-operability

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


Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
brettheap added a commit that referenced this pull request Oct 6, 2026
… (plan 038) (#89)

Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Arc: neutral-product-standalone-operability

## T010 [oDc]: R2Q17 (a)'s required-check change

Plan 038 (`038-opendox-document-tool-self-maintenance`). This is the CI owner's first of five ordered edits to `.github/workflows/validate.yml`: T010, then T017, T051, T067 and T080 (decision N-4).

- **Realizes**: 15.1b (part), 15.5 (part, the platform).
- **Falsifier**: the job's own run on the PR, quoted: the live proof step green, the suite's selected/passed/skipped counts unchanged.
- **Ruled**: R2Q17. The answer is (a), openxFactory#656 `6003486656`: *"This required-check change is made by this word"*. The plan was ruled at #656 `6013547504`. **Decisions**: N-4, OQ-H15-21.

## What changes in the required `validate` job

- **`runs-on: ubuntu-24.04`**, pinned. It was `ubuntu-latest`, which moves to 26.04 in a window that opens 2026-10-19. The move waits for T068's measurement (decision N-18).
- **`provision the sandbox`** (new step). It installs `bubblewrap` with apt and sets `kernel.apparmor_restrict_unprivileged_userns=0` (actions/runner-images#10443). It prints the image's default value before changing it.
- **`prove the sandbox live`** (new step). It runs before the package install, so it runs before the suite.
  - bwrap is run at the FIXED path `/usr/bin/bwrap`, never through PATH (OQ-H15-21). The step refuses a missing or setuid binary. A setuid bwrap would pass without unprivileged user namespaces.
  - It records `bwrap --version`, the package version and the kernel.
  - **Run 1 must succeed.** It writes to its tmpfs and reads the write back. It passes all three flags that set OQ-H15-21's version floor (`--json-status-fd`, `--disable-userns`, `--size`), so a bwrap below the floor stops at "Unknown option".
  - **Run 2 must be refused a write outside its tmpfs.** It runs over a host directory the runner can write, bound read-only. It must see the directory, write to its own tmpfs, and fail the write into the directory: exit 42 exactly. The step then checks on the host that nothing landed.
- **The switch: `OPENDOX_TEST_SANDBOX_REQUIRED: "1"`**, exported at job level, so every step of `validate` sees it.
  - Under it, with `CI` set, a sandbox case that finds no live sandbox FAILS rather than skips. This mirrors `tests_runtime/conftest.py`'s `_skip_or_fail`.
  - T048's `tests/sandbox_required.py` is the helper that reads it. T067's shell step can read the same switch.
  - **Why this name.** `plan.md`, `tasks.md` and `data-model.md` declare no variable. `grep -nE 'OPENDOX_[A-Z_]*(SANDBOX|REQUIRED)|SANDBOX_REQUIRED|sandbox_required'` finds only the helper module's name, at `tasks.md:914` and `:922`. The name follows this repository's test-harness switches (`OPENDOX_TEST_DATABASE_URL`, `OPENDOX_TEST_HOME`), which sit apart from the runtime's closed `SETTING_NAMES`. So no guard mistakes it for an operator setting, and `tests_runtime/conftest.py`'s per-case clearing leaves it alone.
- `EXPECT_SKIPPED` stays `"11"`, and `MIN_SELECTED` and `MIN_PASSED` are unchanged. No step script names the test runner or `pip install`, so the one-run and one-install guards in `tests_runtime/test_deploy_shape.py` still hold. The new step names do not start with "install".

## The falsifier: this PR's own run

The run is [37446196804](https://github.com/opensoft/openDox-code/actions/runs/37446196804) (`pull_request`, head `d63e3860`), validate job `112211500317`, conclusion **success**. `acceptance` also passed.

The runner image:
```
Image: ubuntu-24.04
Version: 20260927.320.1
```

The `provision the sandbox` step:
```
image default: kernel.apparmor_restrict_unprivileged_userns=1
Unpacking bubblewrap (0.9.0-1ubuntu0.3) ...
Setting up bubblewrap (0.9.0-1ubuntu0.3) ...
kernel.apparmor_restrict_unprivileged_userns = 0
```

The `prove the sandbox live` step, **green**:
```
bwrap: /usr/bin/bwrap, bubblewrap 0.9.0, package 0.9.0-1ubuntu0.3, kernel 6.17.0-1022-azure
kernel.apparmor_restrict_unprivileged_userns=0
json-status: { "child-pid": 3248, "cgroup-namespace": 4026532339, "ipc-namespace": 4026532337, "mnt-namespace": 4026532268, "net-namespace": 4026532340, "pid-namespace": 4026532338, "uts-namespace": 4026532336 } { "exit-code": 0 }
live: the sandbox ran and its tmpfs took a write
sh: 4: cannot create /home/runner/work/_temp/sandbox-escape-probe/escaped: Read-only file system
refused: the write outside its tmpfs failed, and the host directory is unchanged
```

The suite, then `Pin the triple`:
```
5458 passed, 11 skipped, 2 warnings in 814.24s (0:13:34)
triple: selected=5469 passed=5458 skipped=11 failures=0 errors=0
pins:   selected>=3977 (margin 1492) passed>=3966 (margin 1492) skipped==11
```

**The counts are unchanged against `main`.** No `validate` run had ever covered `main`'s tip `a9ac96f9`: #87's tested head `bc610409` did not contain #88. So `validate` was dispatched on `main` for this comparison: [37445317621](https://github.com/opensoft/openDox-code/actions/runs/37445317621) (`workflow_dispatch`, `a9ac96f9`, success, same runner image).
```
5458 passed, 11 skipped, 2 warnings in 813.22s (0:13:33)
triple: selected=5469 passed=5458 skipped=11 failures=0 errors=0
```
Both read selected 5469, passed 5458 and skipped 11. A second run of this head, dispatched on the branch, read the same: [37446067746](https://github.com/opensoft/openDox-code/actions/runs/37446067746), `selected=5469 passed=5458 skipped=11 failures=0 errors=0`, with the proof green.

## Mutants: each new guard, killed on a real runner

Each mutant was a one-line edit on a throwaway branch, dispatched once. The branches were deleted afterwards and none was ever proposed. Each went red at `prove the sandbox live`, so the suite never ran.

| mutant | run | the step's refusal |
|---|---|---|
| M1: drop the sysctl | [37446262428](https://github.com/opensoft/openDox-code/actions/runs/37446262428) | `kernel.apparmor_restrict_unprivileged_userns=1`, `bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted`, `the sandbox did not run (bwrap exited 1), so this runner has no live sandbox` |
| M2: bind the probe directory read-write (`--bind`) | [37446266135](https://github.com/opensoft/openDox-code/actions/runs/37446266135) | `the escape run exited 0, not 42: 0 means the write landed, …` |
| M3: `sudo chmod u+s /usr/bin/bwrap` after the install | [37446269880](https://github.com/opensoft/openDox-code/actions/runs/37446269880) | `/usr/bin/bwrap is setuid, so this proof would not exercise unprivileged user namespaces` |

M1 also measures what R2Q17 assumed. The pinned image ships the AppArmor restriction on, and without the sysctl bwrap cannot set up its namespaces.

## Local checks (checks, not the falsifier)

- `actionlint` 1.7.12 with shellcheck: clean. One SC2016 is disabled at its line with the reason: `$1` belongs to the inner `sh -c`.
- The proof step's own script, extracted from the workflow and run against stub bwraps:
  - a working stub passes (rc 0);
  - a stub that lets the write land, exiting 0, is refused (rc 1);
  - a stub that lets the write land but exits 42 is refused by the host check (rc 1);
  - a stub that cannot create namespaces is refused (rc 1).
- `tests/test_triple_pin.py`, `tests_runtime/test_deploy_shape.py` and `tests/test_release_workflow.py`: 246 passed.
- The full suite, in a venv built with this job's install command, with no PostgreSQL and `CI` unset: `5292 passed, 177 skipped` (5469 selected). The skips are the database-backed cases, which skip without a database outside CI.

## Files changed

- `.github/workflows/validate.yml`: the `validate` job's comment block, `runs-on`, job-level `env`, and the two new steps. No other file.

## What is NOT done here

- **No test reads `OPENDOX_TEST_SANDBOX_REQUIRED` yet.** T048 (lane openXfactory-3) adds `tests/sandbox_required.py` and the sandbox cases that it gates. Until then the switch changes no outcome, which is why the counts are identical.
- The product's own fixed bwrap path and version-floor enforcement is T048's `check_pack_sandbox.py`. This PR only records the runner's version and uses the floor's flags in CI.
- The floors `MIN_SELECTED` and `MIN_PASSED` are T017's and T051's. F15.1's shell block in this job is T067's. AT-R2's `acceptance` job is T080's. The `acceptance` job is untouched and still runs on `ubuntu-latest`.
- The 26.04 measurement is T068's, and the move off 24.04 is a separate required-check change (N-18).
- There is no macOS job, as ruled.
- The ruleset is unchanged. The required context is still `validate`, and this PR changes what that job does.

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


Arc: neutral-product-standalone-operability
Lane: openxfactory-4 (openXfactory-4-openDox_extraction)
Co-Authored-By: Claude Opus 5.5 (1M context) <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.

2 participants