Skip to content

T010: R2Q17 (a)'s required-check change, the sandbox live in validate (plan 038) - #89

Merged
brettheap merged 1 commit into
mainfrom
r2/t010-validate-sandbox
Oct 6, 2026
Merged

brettheap merged 1 commit into
mainfrom
r2/t010-validate-sandbox

Conversation

@brettheap

@brettheap brettheap commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

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 (ubuntu-24.04 Error during unshare(...): Operation not permitted 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 (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 (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, 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 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 the escape run exited 0, not 42: 0 means the write landed, …
M3: sudo chmod u+s /usr/bin/bwrap after the install 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

… (plan 038)

The required `validate` job, by Brett Heap's word (openxFactory#656
6003486656, R2Q17 (a): "This required-check change is made by this word"):

- pins `runs-on: ubuntu-24.04` (was `ubuntu-latest`, which moves to 26.04
  from 2026-10-19; the move waits for T068's measurement, decision N-18);
- `provision the sandbox`: installs bubblewrap and sets
  `kernel.apparmor_restrict_unprivileged_userns=0`
  (actions/runner-images#10443), recording the image's default first;
- `prove the sandbox live`, before the package install and the suite:
  bwrap at the FIXED path /usr/bin/bwrap, never through PATH, refused if
  setuid (OQ-H15-21); records `bwrap --version`, the package version and
  the kernel; one run that must succeed, passing the floor's three flags
  (--json-status-fd, --disable-userns, --size); and one that must be
  refused a write outside its tmpfs (exit 42 exactly, and nothing on the
  host);
- exports OPENDOX_TEST_SANDBOX_REQUIRED=1 at job level: with CI set, the
  sandbox cases T048's tests/sandbox_required.py gates FAIL rather than
  skip. Named after OPENDOX_TEST_DATABASE_URL, a test-harness switch and
  not a runtime setting.

EXPECT_SKIPPED stays 11; MIN_SELECTED and MIN_PASSED are unchanged. The
acceptance job is untouched, and there is no macOS job.

Lane: openxfactory-4
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 09:54
@sourcery-ai

sourcery-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown

Reviewer's Guide

The validate workflow now provisions and proves a live bubblewrap sandbox on a pinned Ubuntu 24.04 runner before installing and running the suite, and exports a harness flag that turns unavailable sandbox cases into failures rather than skips while preserving the existing suite counts and acceptance job.

Sequence diagram for sandbox validation before the test suite

sequenceDiagram
    participant Runner as GitHub Actions runner
    participant Workflow as validate job
    participant Host as Ubuntu 24.04 host
    participant Bwrap as /usr/bin/bwrap
    participant Suite as Test suite

    Workflow->>Runner: provision the sandbox
    Runner->>Host: apt-get install bubblewrap
    Runner->>Host: sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
    Workflow->>Bwrap: --version
    Workflow->>Bwrap: Run live tmpfs write probe
    Bwrap-->>Workflow: Success and json-status-fd child-pid
    Workflow->>Bwrap: Run read-only host-directory probe
    Bwrap-->>Workflow: Exit 42, host directory unchanged
    Workflow->>Suite: Run with OPENDOX_TEST_SANDBOX_REQUIRED=1
    Suite-->>Workflow: Missing live sandbox cases fail, not skip
Loading

File-Level Changes

Change Details Files
Make the validate job run on a pinned runner and require a live bubblewrap sandbox before tests execute.
  • Pin the job to ubuntu-24.04 and export the sandbox-required test flag for every step.
  • Install bubblewrap and disable the runner's AppArmor user-namespace restriction.
  • Run fixed-path, non-setuid bubblewrap smoke tests covering successful tmpfs writes and rejection of host-directory writes.
  • Record bubblewrap, package, kernel, and JSON status details while failing fast when the sandbox is unavailable or behaves unexpectedly.
.github/workflows/validate.yml
Change sandbox-dependent tests from silently skipping to failing when the required CI capability is absent.
  • Enable OPENDOX_TEST_SANDBOX_REQUIRED in the validate job so the harness enforces sandbox availability under CI.
  • Leave the acceptance job and existing skipped-test expectations unchanged.
.github/workflows/validate.yml

Tips and commands

Interacting with Sourcery

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

Customizing Your Experience

Access your dashboard to:

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

Getting Help

@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 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

The pending validation run must confirm sandbox operation on the actual runner and unchanged selected, passed, and skipped test counts.

Review effort: Balanced
Findings: None

What changed in this PR

Adds live sandbox verification to the required validation job, preparing CI for sandbox-backed Release 2 packs.

Changes:

  • Pins validation to Ubuntu 24.04 and provisions bubblewrap.
  • Verifies sandbox execution and read-only host write protection before tests.
  • Exports the sandbox-required test flag while retaining the expected skip count.
File Description
.github/​workflows/​validate.yml Adds sandbox provisioning and live isolation checks to validation.

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

@brettheap
brettheap marked this pull request as ready for review October 6, 2026 10:23
@sourcery-ai

sourcery-ai Bot commented Oct 6, 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 2 hours and 9 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@brettheap

Copy link
Copy Markdown
Contributor Author

READY at d63e386

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

Holder, at READY (T010, plan 038).

  • After set met: T004 (#1245) landed as 260234b5.
  • Gates at the head:
    • validate, acceptance and SonarCloud pass;
    • Copilot is at the head and does not say "Changes recommended";
    • 0 unresolved threads;
    • no closing keywords.

@brettheap
brettheap merged commit 34c2064 into main Oct 6, 2026
7 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

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

LANDED — lane openxfactory-4, 2026-10-06T14:34:38Z, PR #89 → 34c2064 (opensoft/openDox-code main; plain gate)

Brett: plan 038 RULED incl. lane openxfactory-4 lands every PR (#656 6013547504); Start release 2 (#656 6001702967)

brettheap added a commit that referenced this pull request Oct 6, 2026
…'s posture-note follow-on (plan 038) (#91)

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

Arc: neutral-product-standalone-operability

## T025, U-6: openDox web (SF; DJ (A), W-1 ruled (A)), plan 038

- **Realizes:** 12.5 (part).
- **Falsifier (tasks.md):** openDox-code's whole suite; the 34 nodes, composed, quoted at T029.
- **Ruled:** R2Q8. **Decisions:** W-1, RULED (A) by Brett Heap in his ruling of plan 038 (opensoft/openXfactory#656 comment `6013547504`). The staging model becomes import-free again, which reverses § 3.4 S7's `./display.js` import by his word.
- **After:** T004 (opensoft/openXfactory#1245). **After set met: T004 #1245 → 260234b5.**
- **Files (tasks.md):** `src/opendox/web/views/staging-workbench.js`, `src/opendox/web/views/staging-workbench-model.js`, `tests/fixtures/web_boundary_census.yaml`, `tests/test_web_boundary.py`. This PR is FIRST in the census chain T025 → T015 → T016 → T057.

### What changed

**The model (`views/staging-workbench-model.js`), W-1 (A).**
- It imports nothing again. It now carries its own copy of the nine `views/display.js` tables it read: `STAGE_ROLES`, `STATUS_ROLE`, `SCOPE_KINDS`, `TAB_IDS`, `SESSION_SCOPE_KINDS`, `SESSION_BRANCH_NAMESPACES`, `SNAPSHOT_VALUES`, `NEUTRAL_DISPLAY.stages` (as `NEUTRAL_STAGES`) and `NEUTRAL_DISPLAY.areas` (as `NEUTRAL_AREAS`).
- Its neutral vocabulary is a small reader over three of those tables. It answers the five reads the model makes (`one`, `many`, `short`, `area`, `documentStage`) as `neutralDisplay()` does, and it refuses an unknown role by name, as `Display` does.
- The facet itself still arrives only through `setDisplay`, which the view calls at mount. Nothing a host declares is copied.
- The nine are exported together as `INLINED_DISPLAY_TABLES`, keyed by the `views/display.js` expression each one copies, so T050's inline-parity guard can read both ends.
- `views/display.js` is unchanged. It is T050's file.

**The view (`views/staging-workbench.js`), S1, T102's follow-on.**
- T102's two re-shows (the restored-scope reconcile and an unload) now redraw the plane already stated, through a new `redrawPostureNote`. They no longer call `showPostureNote` again, so the one rule keeps its definition and its two callers. `const stands = !!plane.note && plane.chat !== true;` is kept verbatim.
- One comment names `editingPosture` instead of its capitalised header. That comment was the only place the file carried the substring `POST`, which the no-write-path pin refuses.

**The census and its test.**
- The two rows' `loc` (model 2330 → 2468, view 3621 → 3633) and the class totals (A 18621 → 18759, C 12757 → 12769).
- A new declared class, `inlined_display_tables`, keyed by (path, identifier), with `copies` naming the `views/display.js` expression. The governance-literal sweep skips the string literals inside each declared table's own declaration, and nowhere else in the file. Five of the nine carry watched words: four seam-key tables, plus `STATUS_ROLE`'s role names that are spelled like status words.
- Three new tests:
  - `test_the_staging_model_is_import_free`: no `import`, static or dynamic, and no `from "..."` clause. It reads over the code, with comments and string contents blanked and each template literal's `${...}` substitutions read back as code. A substitution ends at its own code brace, so a brace inside a nested string, comment or regex cannot end it early. Both points come from Copilot's two rounds.
  - `test_every_inlined_display_table_is_real`: each row's table is declared in the file, and each `copies` names something `views/display.js` declares.
  - `test_the_inlined_tables_are_the_registry_the_model_exports`: the census rows and `INLINED_DISPLAY_TABLES` list the same tables. A table the sweep exempts is therefore always one T050's guard reads.
- `test_every_in_scope_file_reads_the_display_facet` accepts a third shape. An import-free file that inlines its tables must declare `setDisplay`, and an in-scope file that imports `./display.js` must import it from that file and call it.

### The falsifier, measured

**Environment.** Python 3.12.3, Node v24.21.0, pytest 8.4.2.
- **Composed run, in R1Q23 (a)'s form:**
  - openXdox-code `56e1c238` (its main), installed with CI's `python -m pip install -e ".[test]"`;
  - openDox-code force-reinstalled (`pip install --force-reinstall --no-deps`) at base `a9ac96f9` or at this head;
  - openxFactory `92010d3e` (its main), with submodules initialized recursively and `PYTHONPATH="$OPENXFACTORY/scripts"`.
  - run off CI (no `CI` variable), as R2-INV-12 measured its 174.
- **openDox-code's own suite:** run as its CI runs it: `CI=true`, a Postgres 16 database in `OPENDOX_TEST_DATABASE_URL`, and `python -m pytest -q --junitxml=pytest-report.xml`.
- **Colour.** Every run quoted below for `40490d4e` and `45f5c55d` unsets `FORCE_COLOR`, `CLICOLOR` and `COLORTERM` and sets `TERM=dumb`, so no colour code reaches a test that matches error text.
- **The final head is `137b75b8`.** It is `45f5c55d` with `origin/main` `34c20641` merged in (T010, #89). That merge brings only `.github/workflows/validate.yml`, where the sandbox is made live and `OPENDOX_TEST_SANDBOX_REQUIRED=1` is set. `src/` and `tests/` are byte-identical to `45f5c55d`.
- **Composed base for the final head:** main `34c20641`, whose `src/` is identical to `a9ac96f9`. openxFactory's `scripts/` and submodule gitlinks are the same at `92010d3e` and at its current main `51456835`.
- **Colour.** Every run quoted below for `40490d4e`, `45f5c55d` and `137b75b8` unsets `FORCE_COLOR`, `CLICOLOR` and `COLORTERM` and sets `TERM=dumb`, so no colour code reaches a test that matches error text.
- **The bundle is the same at every head after `158ab41f`.** `45f5c55d` changes only `tests/test_web_boundary.py` against `40490d4e`, and `40490d4e` changes the model by one line (Sonar's object spread). Each number is quoted at the head it was run on.

**1. The 34 nodes, composed.** Command: `python -m pytest -q tests/test_staging_workbench.py`.

| | result |
|---|---|
| base `a9ac96f9` | `59 failed, 20 passed, 4 errors in 9.61s` |
| head `158ab41f` | `29 failed, 54 passed in 9.09s` |
| head `45f5c55d` | `29 failed, 54 passed in 7.61s` |
| base main `34c20641` (for the final head) | `59 failed, 20 passed, 4 errors in 9.70s` |
| head `137b75b8` (final) | `29 failed, 54 passed in 9.73s` |

At every head, exactly 34 nodes flipped red to green and none flipped green to red. They are the 34 tasks.md names:

| node (R2-INV-P4F bucket) | base | head |
|---|---|---|
| the 28 display-js (DJ) test nodes: `test_workbench_kind_and_signal_vocabularies`, `test_cluster_scope_is_its_document_edges`, `test_cluster_scope_missing_completeness_stays_missing`, `test_possible_scope_separates_cited_from_inherited`, `test_staged_scope_is_folder_docs_plus_declaring_documents`, `test_picked_possible_outline_is_the_picked_topic`, `test_unresolvable_scopes_are_null`, `test_lens_rescope_filters_the_existing_seed_verbatim`, `test_scope_derivation_is_deterministic`, `test_cluster_neighbourhood_is_deduped_and_honours_no_bar`, `test_staged_scope_has_no_neighbourhood_when_no_linked_clusters`, `test_scopes_derive_from_the_real_fixture_snapshot`, `test_a_pasted_descriptor_carries_hostile_values_through_verbatim` ×5, `test_a_hostile_descriptor_stays_one_command` ×5, `test_no_descriptor_leaves_a_shell_metacharacter_unquoted` ×5, `test_the_draft_says_what_you_already_have_on_this_topic` | 28 failed | 28 passed |
| the 4 DJ setup errors: `test_a_stale_token_catalog_failure_gets_its_own_recoverable_rung`, `test_an_unreadable_catalog_gets_its_own_rung_distinct_from_configured_none`, `test_the_editor_only_and_capable_rungs_are_unchanged`, `test_the_catalog_rungs_never_outrank_hidden_or_gate_off` | 4 errors | 4 passed |
| S1 `test_staging_workbench_view_has_no_write_path` (`:798` `POST`, then the `:802` import-free pin) | failed | passed |
| S1 `test_only_the_plane_postures_still_stand_as_an_inline_note` (`showPostureNote(` counted 5, pinned 3) | failed | passed |

**The 29 still red are not this task's.** They are R-1's 23, S2's 4 (allow-list entries) and S3's 2, all of them T026's. Their cause moved:
- The harness nodes now fail on the module-level harness text, not on the import. `does not provide an export named 'BRAINSTORM_AREA'` appears 9 times and `'sessionRoute'` 12 times: these are R-1's 21 harness nodes.
- `display.js` appears in the base log 165 times and in the head log 0 times.

**2. The 16 governed suites, each run alone, composed: base `a9ac96f9` vs head `40490d4e`, and again base `34c20641` vs head `137b75b8`, with the same numbers.**
- base: 668 passed, 170 failed, 4 errors (R2-INV-12's 174 reds).
- head: 702 passed, 140 failed, 0 errors.
- Only `tests/test_staging_workbench.py` moved.

**3. Every openXdox-code test file run alone, composed: 98 files, 3660 cases, base vs `40490d4e`, and again `34c20641` vs `137b75b8`.** Both pairs give the same result: 42 nodes went red to green and 0 went green to red:
- the 34 above;
- 8 outside the governed set, which also copy the model alone and also read `ERR_MODULE_NOT_FOUND ... display.js` at base: `test_doxbench_save.py` 3 (errors), `test_doxbench_transport.py` 4 (errors), and `test_session_document_ownership.py::test_the_rewrite_picker_offers_the_tiles_own_material_and_nothing_else` 1 (failure).
- Totals: base 2933 passed, 638 failed, 83 errors, 6 skipped; head 2975 passed, 607 failed, 72 errors, 6 skipped.
- `test_dependency_direction.py::test_first_attribute_access_refuses_and_names_the_layering` fails at both, which is known and pre-existing at `56e1c238`.

**4. openDox-code's whole suite, as CI runs it.**
- base `a9ac96f9`: `selected=5469 passed=5457 skipped=11 failures=1 errors=0`. The one failure is `tests_runtime/test_migrations_apply.py::test_the_lock_is_released_after_a_run` (`the run left its advisory lock held`). It came from running alongside the head run against one Postgres server, where `pg_locks` is server-wide. Re-run alone at base, that file gives `37 passed`.
- head `158ab41f`, locally: `5461 passed, 11 skipped, 2 warnings in 1975.36s`, which is `selected=5472 passed=5461 skipped=11 failures=0 errors=0`. That is base + the 3 new test cases, with no other node changed, compared node by node. The skip count equals the pinned `EXPECT_SKIPPED` of 11.
- head `40490d4e`, locally with colour off: `5461 passed, 11 skipped, 2 warnings in 2011.25s`. `45f5c55d` changes only `tests/test_web_boundary.py`, which gives `16 passed` there.
- head `45f5c55d`, CI (`validate` run 37452643627): `triple: selected=5472 passed=5461 skipped=11 failures=0 errors=0` and `pins:   selected>=3977 (margin 1495) passed>=3966 (margin 1495) skipped==11`.
- **head `137b75b8` (final), locally, as CI now runs it:** `CI=true`, `OPENDOX_TEST_SANDBOX_REQUIRED=1`, Postgres 16, colour off. Result: `5461 passed, 11 skipped, 2 warnings in 1555.72s`, which is `selected=5472 passed=5461 skipped=11 failures=0 errors=0`.
- **head `137b75b8` (final), CI** (`validate` run 37496783300): `live: the sandbox ran and its tmpfs took a write`, `refused: the write outside its tmpfs failed, and the host directory is unchanged`, `triple: selected=5472 passed=5461 skipped=11 failures=0 errors=0` and `pins:   selected>=3977 (margin 1495) passed>=3966 (margin 1495) skipped==11`.

### Red first

The new import-free test, run against base's model (`a9ac96f9`, with this PR's final test file and census copied in):

```
E           AssertionError: views/staging-workbench-model.js loads another module: an `import` at lines [48]. W-1 (A) makes it import-free, so a table it needs from `views/display.js` is inlined and declared in the census's `inlined_display_tables` instead.
E           assert not [48]
1 failed, 15 deselected in 0.75s
```

At the same base, the whole file gives `4 failed, 12 passed`: the import-free test, the two declaration tests (`does not DECLARE const STAGE_ROLES`, and `exports no INLINED_DISPLAY_TABLES`), and the census `loc` rows. At `45f5c55d` it gives `16 passed`.

### Mutants

Each mutant was applied to a scratch copy of `45f5c55d`, whose `src/` and `tests/` the final head carries unchanged. Each ran against the 11 openDox-code suites that load the model; unmutated, those give `464 passed`. A mutant that adds or removes a line also trips the census `loc` row; the table names the guard that fires besides that.

| mutant | result |
|---|---|
| **M1, re-add the import** (`import { neutralDisplay as _n } from "./display.js";`) | KILLED: `test_the_staging_model_is_import_free`, with `loads another module: an import at lines [62]`. Composed (at `158ab41f`), it is `58 failed, 21 passed, 4 errors`, and all 32 DJ nodes are red again. |
| **M2, alter one inlined entry** (`SCOPE_KINDS.grouping` `"cluster"` → `"group"`) | KILLED: `14 failed, 450 passed`. The failures include `test_display_facet.py::test_the_workbench_model_takes_the_vocabulary_at_the_mount` and `test_workbench_edit_by_scope.py::test_the_browser_set_is_the_servers_set[cluster-g1…g6]`. Composed (at `158ab41f`), it is `34 failed, 49 passed`, with 5 DJ nodes red. |
| M2b, alter an entry the model never reads (`STATUS_ROLE.RETIRED` `"retired"` → `"retire"`) | SURVIVES (`464 passed`), by design. No behaviour reads it, and the equality of the copies is T050's inline-parity guard. |
| M3, a census row names an undeclared table | KILLED by the sweep: `views/staging-workbench-model.js:79 carries 'cluster'`, `:80 'possible'`, `:81 'staged'`. The two declaration tests also fail. |
| M4, a governance literal outside a declared table (`export const STRAY_KIND = "staged";`) | KILLED by the sweep: `views/staging-workbench-model.js:190 carries 'staged'`. The skip is span-limited. |
| M5, a table dropped from `INLINED_DISPLAY_TABLES` | KILLED: `test_the_inlined_tables_are_the_registry_the_model_exports`. |
| M6, `copies: TAB_ID` | KILLED: `views/display.js declares no TAB_ID`. |
| M7, the view stops calling `setDisplay(vocab)` | KILLED: `test_every_in_scope_file_reads_the_display_facet`. |
| M8, a re-export (`export { DRAFT_PATHS } from "./display.js";`) | KILLED: `a from clause at lines [1268]`. |
| M9, a dynamic import (`() => import("./display.js")`) | KILLED: `an import at lines [192]`. |
| M10, Copilot round 1's payload: an import inside a template substitution (`` `${import("./display.js")}` ``) | KILLED: `an import at lines [192]`. At `158ab41f` it SURVIVED: only the census `loc` row fired. |
| M11, Copilot round 2's payload: an import after a `"}}"` string inside a substitution | KILLED: `an import at lines [192]`. |

### Gates

- **CI at `137b75b8` (final):** `validate` pass (the required check, with the sandbox live) and `acceptance` pass. `validate` also passed at `158ab41f`, `40490d4e` and `45f5c55d`.
- **Copilot**, four rounds through the reviewer API:
  - `158ab41f`: "Changes recommended", 1 finding, r4194288989. An `import` inside a template substitution was blanked with the template. Fixed now at `40490d4e`.
  - `40490d4e`: "Changes recommended", 1 finding, r4194349872. A brace inside a nested string ended a substitution early. Fixed now at `45f5c55d`.
  - `45f5c55d`: "Needs a closer look", Findings: None. Its only remark was that the declared T004 prerequisite (#1245) was still pending; #1245 has since landed as `260234b5`.
  - **`137b75b8` (final): "Changes recommended", 1 finding, r4198449977. CLASSIFIED AS AN ACCEPTED LIMIT** under the convergence rule `5988818366`, for the holder's ruling. WRITER-RULES-R2 says "Changes recommended" at the final head blocks the holder's gate until the holder rules.
    - **The finding:** a regex literal after an un-braced `if (...)`, as in `${(() => { if (true) /}}/.test("x"); return import("./x.js"); })()}`, hides a later `import` from the guard. So does the same shape at top level. Reproduced at `137b75b8`.
    - **The cause:** `_js_spans`'s regex-or-division heuristic, written at § 3.4 S7 for the assertion-4 sweep and reused here. After `)`, a `/` is division in `(a) / b` and a regex in `if (a) /re/`, and only a parser can tell which. This leg has no JS parser in its dependency set, and changing the heuristic would also move the S7 sweep.
    - **What the guard still catches:** every form a maintainer writes, as the mutant table shows: static import, `from` re-export, dynamic import, an import in a template substitution, and an import after braces in a nested string, comment or regex. Only the deliberately built statement-level regex form gets past.
    - The reply on the thread says the same; the thread is resolved.
- **Threads:** 3, all answered and resolved, 0 unresolved. Two were fixed now (r4194288989, r4194349872); the third is the accepted limit above (r4198449977).
- **SonarCloud at `137b75b8` (final):** 0 open issues. The two it raised at `158ab41f` (javascript:S6661 object spread, python:S9073 composite assertion) are fixed at `40490d4e`.
  - The quality gate fails on ONE condition: new-code duplication is 3.9% against 3%. It is the 16-line `NEUTRAL_STAGES` table (model `:112-127`), a copy of `views/display.js` `:284-299` (`NEUTRAL_DISPLAY.stages`).
  - That copy is what W-1 (A) rules: the model carries the tables itself, and T050's guard holds them equal. Every other condition is OK (reliability, security, maintainability, hotspots 100% reviewed).
  - SonarCloud is not a required check on this repository (only `validate` is).
  - **HOLDER RULING (opensoft/openXfactory#656 comment `6016356225`): ACCEPTED LIMIT at READY**, under the convergence rule `5988818366`. The holder lands #91 over this one condition and says so in the landing note.

### What is NOT done

- **The equality guard** that the nine copies equal `views/display.js`'s is T050's. That is why M2b survives here.
- **The 29 nodes still red** in `tests/test_staging_workbench.py` are T026's: R-1's 23, S2's 4 and S3's 2.
- **Prose outside this task's files** that this change makes stale. It is left for the files' owners:
  - `views/display.js:203-205` says `SESSION_SCOPE_KINDS` is declared there "rather than in views/staging-workbench-model.js … the model is class C and may carry no literal". T050 owns that file.
  - `tests/test_outline_tab.py:882-890` and `tests/test_doc_wheel.py:135-137` describe the staging model as importing `./display.js`.
  - `tests/test_doxbench_abstract_pane.py:157-161` and `tests/test_doxbench_context_panes.py:118-122` still copy `display.js` beside the model. That is harmless and no longer needed.
- **The CI floors.** This PR adds three test cases, so `selected` rises by 3. `MIN_SELECTED`/`MIN_PASSED` are re-pinned by T017.
- **The pins:** openXdox-code's `opendox` pin, openxFactory's nested `openDox/code` and the root `openDox` gitlink. That is T027 and T028; the 34 nodes are quoted again at T029.

🤖 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 8, 2026
…al lander; feature 007's guard admits the landing's fast-forward (plan 038) (#90)

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

## T012 + T013 (plan 038, P4-D1): the landing seam, governance, confirmation and the neutral lander; feature 007's guard

One PR, as T012's "Lands with: T013" requires.

**Lane 3's review R2-DELTA gave GO at `4527432`** (openxFactory#656 `6068087981`; PR comment `6068087062`). The holder lands it.
- T008 has landed: codeXfactory/codeXfactory#515, merge `f1b019fe` (feature 007's FR-004a and C12).
- T010 (#89, `34c2064`), T025 (#91, `84f8ed8`), T011 (#92, `09b8d44`), T014 (#93, `a7a1c4d`) and T072 (#95, `9922088`) have landed, and this branch has merged all five (never a rebase).
- The two `session_pr` re-exports sit beside T011's names, after its submission-port block.
- Lane 3's R2-DELTA raised one new MINOR (`landing.py:836`), an accepted limit (openxFactory#656 `6069024568` item 1), stated below.
- Copilot's seventh review and Codex's review at `4527432` raised 4 findings. All four are accepted limits by holder ruling openxFactory#656 `6067853207` and are stated below; Copilot's "Changes recommended" at `4527432` stands for them.
- Copilot's sixth review (9 threads) and lane 3's review R2 (`6035652847`) are answered in `ff6f1cb`. R2's findings 1 to 5 are fixed and finding 6 is an accepted limit (holder ruling openxFactory#656 `6035797819`); the point-by-point answer is `6067643141`.

### T012: the landing seam

- **Realizes**: 12.6a (part: the seam, the query, the capability, the lander) and 12.6 (part).
- **Falsifier**:
  - F12.2's thirteen `tests/test_landing_guardrails.py` nodes, including the static issuer check;
  - named nodes beside them for R2Q7 (a)'s two refusals: `test_a_repository_with_no_main_is_unknown_and_refused_naming_it` and `test_no_declaration_refuses_naming_the_file_and_its_content` (lane 3's R2Q7 FIX);
  - ADV-08's named node: `test_a_dirty_served_checkout_on_main_is_refused_before_merging`;
  - the push URL's: `test_the_remote_check_reads_the_push_url_not_the_fetch_url` (a remote whose `pushurl` names a repository ahead of local `main` is refused; one with two push URLs is refused), and `test_the_push_url_never_reaches_git_argv`;
  - lane 3's review R2: `branch.HEAD.mergeOptions` in F12.2's configuration walk, `test_a_driver_named_like_one_of_git_s_own_states_cannot_resolve_a_conflict`, `test_an_ignored_file_the_landing_would_overwrite_is_refused`, `test_only_the_lander_issues_the_served_fast_forward` and `test_a_git_without_attr_source_is_refused_by_name`.
- **Ruled**: R2Q1, R2Q3, R2Q4, R2Q5, R2Q6 and R2Q7 (openxFactory#656 `6003486656`; the plan was ruled at `6013547504`).
- **Decisions**: CF-1, N-1, N-11, N-16, OQ-12-17 and OQ-038-1.

### T013: feature 007's guard, by R2Q6 (a)'s four exceptions

- **Realizes**: 12.6a (part).
- **Falsifier**: `tests/test_session_git.py` whole, quoted below.
- **Ruled**: R2Q6. **Text**: feature 007's FR-004a and SC-002, as T008 landed them (codeXfactory/codeXfactory#515, `f1b019fe`).

### The falsifiers, run at `4527432` with `gh` hidden from PATH (the full local suite in CI form there, with its Postgres and a live sandbox: 5795 passed, 11 skipped, in 39:51)

F12.2's command, verbatim (the thirteen nodes by name):

```text
$ python -m pytest -q "tests/test_landing_guardrails.py::test_land_requires_an_explicit_human_act" … "tests/test_landing_guardrails.py::test_only_the_interactive_layers_call_an_issuer"
.............                                                            [100%]
13 passed in 8.20s
```

T012's five named nodes:

```text
$ python -m pytest -q "tests/test_landing_guardrails.py::test_a_repository_with_no_main_is_unknown_and_refused_naming_it" "tests/test_landing_guardrails.py::test_no_declaration_refuses_naming_the_file_and_its_content" "tests/test_landing_guardrails.py::test_a_dirty_served_checkout_on_main_is_refused_before_merging" "tests/test_landing_guardrails.py::test_the_remote_check_reads_the_push_url_not_the_fetch_url" "tests/test_landing_guardrails.py::test_the_push_url_never_reaches_git_argv"
.....                                                                    [100%]
5 passed in 3.05s
```

`tests/test_session_git.py` whole (105 cases), and the new file whole (113 cases), at `4527432`:

```text
$ python -m pytest -q tests/test_landing_guardrails.py tests/test_session_git.py
218 passed in 80.84s (0:01:20)
```

**Red first.** The same two test files, run against `origin/main`'s code (`a7a1c4d`):
- `tests/test_landing_guardrails.py` does not collect (`ImportError: cannot import name 'landing' from 'opendox'`), so F12.2's command fails, as #1144 says it does today.
- `tests/test_session_git.py` reads `21 failed, 80 passed`. The failures are the moved pin, the admitted fast-forward and its refusals, the eight pinned-settings cases, the ambient-environment case, the NUL-field read, the lookalike `main`, the escaped refusal, and the exact `branch_sha`.
- `("merge", "other-branch")` at `:523` passes on both sides, as T013 requires.

**Mutants: 106 of 106 killed** (on `ff6f1cb`'s code, which `4527432` carries unchanged). There is one mutant per guard, each run against the tests that must catch it, and each was killed by a test failure: pytest exit 1, never an error or a missing node. They cover:
- **the capability** (C1–C12): branch binding, head binding, single use, a non-token, a non-TTY stdin, any answer at the terminal, direct construction, a third issuer, an issuer reached from a product module, any nonce, a non-ASCII nonce reaching `encode()`, and a discarded token's record kept;
- **the governance** (G1–G16): among them, the host never asked, a host without an instrument not outranking, a host that fails to load read as absent, the declaration read from the working tree, standalone without the local install, HEAD's branch read instead of `main`, a duplicate key, a linked declaration, the default profile taken as a host, a lander bound whatever governs, the instrument route skipping the confirmation, and the head not read again before the submission;
- **the lander** (L1–L22): rerere, no `--no-ff`, a dirty `main` checkout, no `ls-remote` check, N-16 reversed, one remote of several, a checkout on another branch fast-forwarded, `main` held elsewhere, a push, no remedy, a conflict reported as a failure, `.gitattributes` reaching the merge, no driver check, the strategy left to configuration, `main` moved by its ref alone, `merge.default` unpinned or pinned to a name a driver can hold, `merge.directoryRenames` unpinned, a named `text` driver taken as git's own, quoted conflict paths, `main` not compared with the merge's tip, and a `main` that did not land reported as landed;
- **the remote check and the messages** (R1–R5, S1, B1–B3, W1–W3): the redaction missing the fragment and spaced forms, the check reading the fetch URL, several push URLs not refused, the push URL riding in the argv, `get-url` without `--push`, a path shown as it is, the prompt, the dirty-checkout refusal and the fast-forward refusal showing raw names, the top's prefix check dropped, and the push URL and the holder's path read stripped;
- **the hooks** (H1–H4): the merge, the landing worktree's checkout, the `switch`, and the fast-forwards running hooks;
- **the byte reads** (N1–N3, X1): NUL-delimited fields read in text mode, the runner ignoring `binary`, text mode decoding strictly, and the served `HEAD` read stripped;
- **the audit** (A1);
- **the guard** (T1–T9, V1): any merge on a clean `main`, a dirty checkout, another branch, below the root, `merge` on the name list, a short id, the fast-forward's settings not pinned or not delivered, the pins back in the argv, the runner passing the ambient environment, and `branch_sha` suffix-matching;
- **Copilot's sixth review** (P1–P12), each of these guards removed:
  - the transport pre-check, and `GIT_ALLOW_PROTOCOL`;
  - scrubbing the URL's values by value, and keeping only git's own stderr lines;
  - the probe's time bound, batch-mode ssh, and the prompt switched off;
  - the escaped branch name in the conflict remedy and the already-landed refusal;
  - the binding's acceptance of a name a strip would change;
  - the bytes reader going through the funnel's pins;
  - the inside-a-work-tree check;
- **lane 3's review R2** (Q1–Q9), each of these broken:
  - `branch.HEAD.mergeOptions` left unpinned;
  - a driver named `set`, `unset` or `unspecified` able to answer (one mutant each);
  - an ignored file overwritten, and the file-where-a-directory-goes case not seen;
  - an older git escaping as a raw `GitError`, and the floor not named at the merge;
  - another module naming the served fast-forward.

### What this changes

**`src/opendox/landing.py` (new).**
- `LandingPort` has one operation, `land(branch, *, confirmation) -> Landed`.
- `Landed` carries `merge_commit` and `previous_main`. Its `served_checkout` is `fast-forwarded` or `left`, and `pushed` is always False.
- `MergeConflict` carries the paths, read NUL-delimited as bytes and so exactly as spelled, and the remedy: bring `main` into the branch and resolve there. Its message shows a path or a branch name that holds a control or format character escaped (`repr`), so neither can write to the terminal or reorder the message. Every refusal that names the branch does the same.
- `LandingRefused` carries a `code` for T016's routes.
- `repository_governance(checkout_root)` answers `standalone`, `governed` or `unknown`, failing closed, in this order:
  1. the checkout must be a working tree's top, with a branch `main` (R2Q7 (a)). The top is asked of git: the checkout must be inside a work tree, with an empty prefix. It is never compared as a path, so a directory name ending in a space or a newline reads;
  2. the install mode must resolve;
  3. a registered host profile decides, whatever any file says (R2Q4 (a));
  4. otherwise `.opendox/governance.yaml` decides, read from the blob at `main`'s tip (N-1). `standalone` needs `OPENDOX_INSTALL_MODE=local` or `--local` (FR-007; ADV-38).
- With no declaration, the refusal names the exact file and its content.
- `bound_lander` binds the neutral lander under `standalone` only.
- `request_landing` routes a landing:
  - under `governed` with an instrument, it submits the confirmed branch through the instrument, and nothing merges. The branch's head is read again immediately before `submit`, and a branch that moved is refused;
  - otherwise it refuses by name: `governed-without-an-instrument`, or why the governance is `unknown`.
- **The neutral lander**, in order:
  1. refuses `main` (R2Q5 (a));
  2. re-reads the governance at the moment of landing;
  3. spends the confirmation;
  4. reads `main` at the remote's PUSH URL first (`git remote get-url --push --all <remote>`; the fetch URL where no `pushurl` is set):
     - a remote with several push URLs is refused (`several-push-urls`). The URLs are read as bytes and no record is dropped, so a URL holding a newline reads as two and is refused, never trimmed;
     - a push URL whose transport is a program git would run is refused before anything runs (`remote-transport`). That covers `<name>::`, and a `<scheme>://` that git does not carry;
     - the URL is probed with `git ls-remote <transient remote> refs/heads/main`, where the transient remote is `remote.opendox-probe-<hex>.url` passed in the command's environment (`GIT_CONFIG_COUNT=1`). So the URL, and any credential in it, never reaches git's argv;
     - the probe admits only git's own transports (`GIT_ALLOW_PROTOCOL`), so a second `insteadOf` rewrite runs no helper;
     - the probe never waits on a human: no prompt, no askpass, and ssh in batch mode, which also outranks a repository's own `core.sshCommand`. It is bounded by `PROBE_TIMEOUT` (60 s);
     - a remote with no `main` passes (N-16);
     - every message is redacted:
       - every value the URL carries is removed BY VALUE (`submission_push._scrubbed`);
       - then the runtime's `redact_credentials` and 12.1a's patterns run, the fragment form (`#token=`) and a value after whitespace included;
       - a failed probe keeps only git's `fatal:` and `error:` lines, so curl's trace headers never reach a message;
  5. refuses a dirty served checkout on `main` before merging (ADV-08), and refuses where another working tree holds `main`;
  6. makes the `--no-ff` merge in its own detached worktree under `<repo>-worktrees/landing/`, with git's own strategy and drivers only:
     - `.gitattributes` and the global attributes file are out of the merge;
     - a driver this machine's attributes still select is refused, a named `text` or `binary` included;
     - `merge.default` is pinned to a fresh driver name, and `merge.directoryRenames` to `conflict`;
     - `branch.HEAD.mergeOptions` is pinned empty. The merge runs on a detached HEAD, where `-X theirs` answered a conflict and `-s ours` dropped the branch (lane 3's review R2);
     - drivers named `set`, `unset` and `unspecified` are pinned to fail. `check-attr` cannot tell those string values from git's own states;
     - a git without `--attr-source` (older than 2.42) is refused by name (`merge-failed`), never with a raw error;
     - rerere is off;
     - no hook runs (`core.hooksPath=/dev/null`) in the landing worktree's checkout, the merge, its `switch`, or either fast-forward. A hooks path inside the tree is the branch author's to write, and a hook that pushed would contradict `pushed=False`;
  7. then moves `main`:
     - where the served checkout holds `main` and is still clean, by `git merge --ff-only <merge commit>` there. First it refuses (`ignored-files-in-the-way`, naming the files and the remedy) when the checkout holds an IGNORED file where the landing writes. That covers the path itself, a file under it, and a file where it needs a directory. A fast-forward overwrites an ignored file with no word;
     - where it holds another branch, the landing worktree takes `main`, checks that it is still the merge's tip, and fast-forwards it there (`left`). git refuses `main` to the landing worktree while another working tree holds it, and refuses `main` to every other working tree while the landing worktree does. So `main` never moves by its ref alone.
- It pushes nothing (R2Q6 (a)), and every git command goes through `session_git.SessionGit`.

**`src/opendox/landing_confirm.py` (new).**
- The confirmation capability: opaque, bound to the branch and its head, and single-use.
- It has exactly two issuers:
  - `confirm_at_terminal`, the `/dev/tty` prompt. It refuses a stdin that is not a terminal, refuses when there is no controlling terminal, and mints only on the typed branch name (N-11);
  - `LandingNonces`, the server's per-branch nonce (OQ-12-13). A nonce that is not an ASCII string is a mismatch, never an exception.
- A token's record is dropped when the token itself is gone (`weakref.finalize`), so a long-running server keeps no record per confirmation. A spent token still held is still refused as spent.
- A token's binding refuses only an empty branch name. git decides what a branch name is, and a legal one may end in a no-break space.
- `INTERACTIVE_LAYERS` names the only modules that may call them: T015's and T016's `cli_branch_actions.py` and `serve_branch_actions.py`.

**`src/opendox/session_pr.py`.** It re-exports `LandingPort` and `repository_governance` (FR-007; ADV-23), beside T011's submission-port names. `PullRequestPort` keeps its three operations.

**`src/opendox/session_git.py` (T013).**
- The name-only allowlist at `:99` is restated, unchanged, and `merge` stays off it.
- An ARGUMENT check admits exactly the three arguments `merge --ff-only <commit>`, with `<commit>` a full object id and never a ref name (FR-004a exception 1). It admits them only at the served ROOT, and only while the served checkout holds `main` and `git status --porcelain` (untracked files included) is empty.
- The guard reads that state from git immediately before the move. `:93`'s stated rule names the exception (exception 2).
- `fast_forward_served(commit)` issues the move, then checks that the served checkout holds `main` at the commit. Otherwise it refuses, and never reports a move it did not make.
- The funnel pins `pull.twohead=ort` and an empty `branch.main.mergeOptions` in that one command's ENVIRONMENT (git's command-scope `GIT_CONFIG_COUNT`), never in its argv. Measured on git 2.43: `-s ours` made a new merge commit, and `--squash` changed the index and moved nothing.
- `SubprocessGitRunner` runs git with `local_git_adapter.sanitized_git_environment()`. So `GIT_DIR`, `GIT_WORK_TREE` and their relatives never redirect a command the guard approved.
- The fast-forward's environment pins `core.hooksPath` to no directory too, so no `post-merge` hook runs.
- `shown()` escapes, for a message, text that holds a control or format character (a bidi override included). The fast-forward refusal, `land`'s refusals and the confirmation prompt all use it.
- `branch_sha` reads the exact ref (`show-ref --verify`), and `checked_out_at` reads a working tree's path as spelled, a trailing space included.
- `git_nul(cwd, *args)` reads a NUL-delimited output as BYTES and decodes each field UTF-8 with `surrogateescape`, with no newline translation, so a carriage return or a non-UTF-8 name reaches a guard as git wrote it (Copilot 4195681954; openxFactory#656 `6026275158`). It runs through the funnel, so the fast-forward's pins apply to it too. Text mode decodes with `surrogateescape` too, so no git output raises.
- The served checkout's `HEAD` ref is read exactly: the legal branch `main\u00a0` is never taken for `main`.
- `ls_remote_url(cwd, url, ref)` probes one ref at a URL through a transient remote in the command's environment, for the landing's remote check. It runs with `PROBE_ENVIRONMENT` (non-interactive, git's own transports only) and `PROBE_TIMEOUT`. The runner takes an `env` overlay and a `timeout`, and a timeout answers exit 124.

**`tests/test_session_git.py` (T013).**
- `:523`'s `("merge", "other-branch")` still refuses, unchanged.
- `:563-564`'s pin moves to the admitted form. `merge` stays absent from the name list, the admitted argv is `("merge", "--ff-only")` plus a full id, and the pure guard admits it on a clean `main` and nothing else.
- New cases:
  - the admitted fast-forward;
  - every pinned setting, through all three entry points (the bytes reader included);
  - refusals: a dirty checkout (tracked and untracked), another branch, a subdirectory, every other merge spelling (the `-c`-pinned spelling included), and a short id;
  - a fast-forward that lands elsewhere;
  - the ambient-environment case.

**`tests/test_landing_guardrails.py` (new).**
- F12.2's thirteen nodes, by their ratified names.
- T012's three named nodes.
- The lander's mechanics, the merge's drivers and settings, the governance reading's edges, and the audit's two nodes.
- The regressions for Copilot's sixth review and lane 3's review R2.
- The host-side nodes run against a registered TEST host profile that declares an instrument (R2Q3 (a)).

### The repository-creation audit (named, as T012 asks)

Every place openDox's product code creates a repository:

| site | before | now |
|---|---|---|
| `src/opendox/conformance_corpus.py:322` (`transpose`, the populated state) | `git init -q`: `init.defaultBranch` decided | `--initial-branch=main` |
| `src/opendox/conformance_corpus.py:431` (`transpose`, the empty state) | `git init -q`: `init.defaultBranch` decided | `--initial-branch=main` |
| `src/opendox/authoring.py:508` | `--initial-branch=main` already | unchanged |
| `src/opendox/runtime/repository_act.py:982-983` (`init --bare`) | `--initial-branch={branch}`, `DEFAULT_BRANCH = "main"` | unchanged, so T011's file is not touched |

Two tests hold it:
- `test_every_repository_opendox_creates_names_its_initial_branch`, a static sweep of every `git init` in the package;
- `test_the_conformance_corpus_is_born_on_main_whatever_git_defaults_to`, run under an ambient `init.defaultBranch = trunk`.

Two places are outside the product and left as they are:
- `acceptance/at_r1_http.py:1774`'s `git init -q` is AT-R1's own fixture, not product code, and AT-R1 asserts nothing about the branch;
- `.github/workflows/release.yml` already uses `-b main`.

### Readings this PR takes, for the holder to rule on (inferred, not ruled)

1. **A registered host profile WITHOUT an instrument also outranks a declaration.** The repository is then `governed`, governed-without-an-instrument, and refused.
   - 12.6a's precedence runs "the host, then main's declaration".
   - T019 asserts "with the real host registered: no lander bound; the host outranks a declaration", and no production host declares an instrument in release 2.
   - So host presence decides, the fail-closed reading. The other reading would bind a lander under a host on the strength of a file.
2. **The instrument's facet is named `SUBMISSION_INSTRUMENT`.** It is a factory `(checkout_root: Path) -> SubmissionPort`. The plan names the instrument ("its contributed `SubmissionPort`, declared in its host profile", R2Q4 (a)) but not the facet. `request_landing` calls the instrument's `submit(branch)`, the operation of T011's `SubmissionPort`, now in `session_pr`.
3. **No `main` is `unknown` even under a host.** A flag/setting disagreement on the install mode is `unknown` in every mode. Both are checked before the host.
4. **"Clean" is git's own sense, untracked files included.**
   - With several remotes and none named `origin`, each remote's `main` is checked.
   - An `ls-remote` that fails is refused: it cannot be verified, so it fails closed.
5. **A confirmation is spent by the first presentation that finds it**, even if the landing then refuses. Under `governed` with an instrument, the routed submission still requires and spends one.
6. **FR-004a's "exactly those three arguments" is read as the argv the guard admits.** CONFIRMED by the holder (openxFactory#656 `6026275158`).
   - The two settings that could turn that fast-forward into a merge (`pull.twohead`, `branch.main.mergeOptions`) are pinned in the command's environment, not its arguments. The command git runs is still `git merge --ff-only <commit>`.
   - Unpinned, a repository's own configuration can make that command create a merge commit, or stage a squash and move nothing.

7. **`--attr-source` needs git 2.42, above the plan's stated floor of 2.31.** On an older git, `land` is refused by name (`merge-failed`, naming 2.42), as data-model.md § Landed says, and nothing is merged. Raised by lane 3's review R2; inferred, not ruled.

### Stated limits (Copilot's reviews and lane 3's R2; for the holder)

- **Neither fast-forward can hold `main` across the check and the move.** The holder WIDENED this limit to both paths (openxFactory#656 `6067853207` item 3, for Codex P1 `4223462529`).
  - The reads (the guard's, and `land`'s check of `main`'s tip) and `git merge --ff-only <commit>` are separate git processes. git has no lock that a separate process can hold across them, and holding the served `index.lock` would also stop the fast-forward.
  - On the served path, a switch of the served checkout by its own user in that window fast-forwards the branch it switched to. The post-check refuses rather than report a landing (`test_a_served_checkout_switched_during_the_fast_forward_is_never_reported`).
  - On BOTH paths, another local git process that rewinds `main` to an ancestor of the merge commit in that window is undone, and the landing reports success.
    - On the `left` path, git refuses `main` to every other working tree while the landing worktree holds it.
    - A ref update made outside any working tree is not refused.
  - `merge --ff-only <commit>`, the one move feature 007 admits, has no compare-and-swap form. `update-ref refs/heads/main <merged> <main>` on the `left` path is not adopted: it would reverse the "`main` never moves by its ref alone" design (Copilot's second review; mutant L15).
  - It is a race between the operator's own local processes, not a payload.
- **A checkout path ending in a newline or a carriage return cannot land** (Copilot `4223441552`, the same defect as Codex P2 `4223462534`). ACCEPTED as a limit by the holder (openxFactory#656 `6067853207` item 1).
  - `checked_out_at` reads `%(worktreepath)` line by line, so the path comes back altered, and `land` refuses as `main-checked-out-elsewhere`.
  - It fails closed, and the served-`HEAD` guard still refuses any move of the wrong branch.
  - The governance reading does take such a path (`test_a_checkout_whose_path_ends_in_a_newline_is_read`).
- **One refusal can print a branch name unescaped** (Copilot `4223441643`). ACCEPTED as a limit by the holder (openxFactory#656 `6067853207` item 2).
  - `fast_forward_served`'s post-check refusal names the branch the served checkout holds, as it is.
  - It is reachable only after a concurrent switch to a branch whose name holds a bidi or format character, and it can only reorder how the message displays.
- **Clean, smudge and process filters run during the landing's checkouts** (Copilot 4199664554). ACCEPTED as a limit by the holder (openxFactory#656 `6026622117` item 1).
  - A filter's command comes from git's configuration, not from the repository's content. Disabling filters would write a different working tree: LFS pointers in place of their content.
  - A filter runs during `land` as it runs during the owner's own `git checkout`. The landing's merge still takes attributes out, so no filter decides a conflict.
- **The static issuer check reads source, so a deliberately dynamic reach can pass it** (lane 3's review R2, finding 6). ACCEPTED as a limit by the holder (openxFactory#656 `6035797819`).
  - `getattr` or `importlib` written to evade the check is a deliberate structural edit of reviewed openDox code. It is the class of `6028383410` and `6028539440`, which 12.6a's in-process limit for deliberate code covers.
  - Implicit string concatenation is caught.
- **A git older than 2.31 with a remote attached is refused as `remote-unreadable`, not by the named 2.42 floor** (lane 3's review R2-DELTA, `landing.py:836`). ACCEPTED as a limit by the holder (openxFactory#656 `6069024568` item 1).
  - Such a git ignores `GIT_CONFIG_COUNT`, so the transient-remote probe fails before the merge's floor refusal is reached, and that refusal tells the user to fix or remove the remote.
  - It fails closed: nothing is merged and `main` is where it was. Without a remote, the same git gets `merge-failed` naming 2.42. Only the message's precision is affected.
- **The instrument receives a branch name.**
  - `SubmissionPort.submit(branch)` is T011's signature (12.1).
  - The head is read again immediately before `submit`, but an adapter that reads the branch later can still see a newer head.
  - Carrying the confirmed object id needs that interface to change, which is T011's or a later task's.

### What is NOT done here

- **T016:**
  - `landing_factory` and `_landing_port`;
  - the `land` verb, its routes and `actions.land`;
  - the confirm control;
  - the surface nodes in this test file;
  - a live session ending by the merge observation (`branch_session.py`).
- **Later tasks:** T017 (the CI floors: this PR raises SELECTED and PASSED, and skips nothing) and T018 (the README).

### Files changed

- `src/opendox/landing.py` (new)
- `src/opendox/landing_confirm.py` (new)
- `src/opendox/session_pr.py` (the re-exports only)
- `src/opendox/session_git.py` (T013)
- `src/opendox/conformance_corpus.py` (the audit's two sites)
- `tests/test_landing_guardrails.py` (new)
- `tests/test_session_git.py` (T013)

🤖 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