Skip to content

Run every sealed run of the finalize job in a container, as the child does (#1191) - #1192

Merged
brettheap merged 10 commits into
mainfrom
fix/1191-contain-finalize-sealed-runs
Sep 28, 2026
Merged

brettheap merged 10 commits into
mainfrom
fix/1191-contain-finalize-sealed-runs

Conversation

@brettheap

@brettheap brettheap commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openxfactory-5 (openXfactory-5)

Held for

DRAFT. It lands by squash under Brett Heap's word, verbatim "land #1191 and #539 when green" (recorded as RULED against #1191), once every required check is green, Copilot is clean at the head, and 0 review threads are unresolved. This seat does not un-draft it.

Closes #1191. Refs #1161.

Ruling

On 2026-09-27 Brett Heap ruled, verbatim, "(b) for the finalize job too". That is the parent-side twin of opensoft/xFactory#526's ruling (b), landed at db26fdc0, which moved the child worker's sealed render and validator into a container. The finalize job's seal step ran the parent's sealed runs directly on the runner: the sealed validator's probe, the pre-dispatch render, and its --strict validation. That runner holds the App token and runs later steps with it. #1166 closed four Copilot threads (mXq1R, mXs7R, mXs7X, mX2ts) as this class, a sealed process that outlives the lane. This PR contains that class. It delivers each item of #1191's shape list.

What this changes

The lane (scripts/ideation_dashboard/dashboard_refresh_lane.py):

  • Every sealed run is one docker run the lane builds (SealedContainer), in the child worker's shape:
    • the image the build step made, by content id (SEALED_IMAGE), with --pull never;
    • the seal read-only at /seal, a validator run's judged file read-only at /judged, and the render's only writable place a tmpfs of its own at /out;
    • a read-only root with a noexec /tmp, --network none, --ipc none, --cap-drop ALL, no-new-privileges, and this runner's non-root uid;
    • --pids-limit 128, 1 GiB of memory and 1 CPU;
    • four environment literals and nothing of the runner's;
    • --init --rm in the foreground, and this run's label.
  • The docker CLI is called at /usr/bin/docker. Its environment is only PATH, HOME, a fresh DOCKER_CONFIG and LANG.
  • The host reads only what a run prints, bounded. The snapshot leaves by stdout alone, capped at 32 MiB, through the child's own wrapper, which refuses a link, a directory or a fifo at /out with exit 3. Logs and verdicts are capped at 1 MiB.
  • A container of this run's label still running after its run returned is removed and refuses the seal. So does a daemon that cannot list them.
  • Sealed output reaches the log only inside a fence. Strict findings print inside ::stop-commands:: with a 128-bit token drawn at each print. A refusal's reason prints as one line, escaped as workflow-command data (_one_line, _command_data, and RefreshOutcome's log line and annotation).
  • Refused before any sealed run, and before the corpus is archived:
    • an image id the build step did not record;
    • ACTIONS_ALLOW_UNSECURE_COMMANDS, or any of DOCKER_HOST, DOCKER_CONTEXT, DOCKER_TLS, DOCKER_TLS_VERIFY, DOCKER_CERT_PATH, BUILDX_CONFIG, BUILDX_BUILDER, set at all;
    • a root uid or gid;
    • no docker CLI at its path.
  • The exit-3 contract for a seal result the lane could not write is unchanged.

The workflow (.github/workflows/doc-health-reusable.yml, finalize job):

  • The build step dfr-sealed-image runs before the seal. It:

    • first writes SEALED_IMAGE= to GITHUB_ENV, so a build that stops leaves no id behind;
    • refuses the same variables;
    • runs docker build under env -i with the same minimal environment, so no proxy, login or token of the job's reaches it;
    • labels the image with the run;
    • records the checked id at the end.
  • The seal step asks the pinned lane first. This workflow runs at openxFactory main while the lane comes from the aggregation's pin. A lane that does not name SEALED_IMAGE (one from before Contain the finalize job's sealed runs in a container with the seal read-only (ruling (b), parent side) #1191), or cannot be imported, seals nothing. The step records the refusal as the seal's result, writing it rm -f then O_EXCL|O_NOFOLLOW, and no sealed code runs.

  • Every step from the build on runs /bin/bash --noprofile --norc -p and calls each tool by its absolute path. HEAD had 51 bare command names after the seal; now there are 0.

  • The job's last step, always:

    Every docker call in it runs under the same env -i.

Lockstep with the aggregation's pin

The image id crosses by the environment, never by a flag, so an old lane refuses no unknown flag. Between this landing and the aggregation's pin-sync, the pinned lane predates #1191. The seal step's gate refuses it: the nightly records "source not sealed", nothing is dispatched, and no sealed code runs on the runner. The image refresh resumes, contained, once the pin carries #1191.

The invocation, verbatim

The render, as the lane built it in the real-docker proof. The seal's mount source is the real path the lane resolves through its handle on the seal directory. The probe and the strict validation have the same shape, with --mount type=bind,source=<judged dir>,target=/judged,readonly --workdir /tmp and the harness in place of --tmpfs /out:… and the wrapper.

/usr/bin/docker run --rm --init --pull never --read-only --tmpfs /tmp:rw,noexec,nosuid,nodev,size=64m --network none --ipc none --user 1000:1000 --cap-drop ALL --security-opt no-new-privileges --pids-limit 128 --memory 1g --memory-swap 1g --cpus 1 --label openxfactory.dashboard-refresh.sealed-run=91790570388-1 --log-driver none --env PYTHONDONTWRITEBYTECODE=1 --env PYTHONIOENCODING=utf-8 --env HOME=/tmp --env LANG=C.UTF-8 --mount type=bind,source=/workspace/projects/xFactory/lane-tools-openxfactory-5/proof-1191/run-1790570388/workspace/dfr-seal,target=/seal,readonly --tmpfs /out:rw,noexec,nosuid,nodev,size=32m --workdir /seal/openxFactory sha256:627654784e4153caabf2ae36e47e0efad1a81b717120d30061cd0cd8d7d44284 /bin/sh -c 'out=$1; shift; unset PWD OLDPWD
"$@" >&2 || exit
if [ -L "$out" ] || [ ! -f "$out" ]; then
  echo "the sealed render left no regular file at $out" >&2
  exit 3
fi
exec /bin/cat -- "$out"
' render /out/openxFactory-snapshot.json /usr/local/bin/python3 scripts/ideation-dashboard-cli.py generate --repo-root . --repository openxFactory --no-validate --source-revision 7af30fc5f851d82b9617c974039f370f6104e326 --generated-at 2026-09-27T17:54:57-04:00 --output /out/openxFactory-snapshot.json

Image provenance

  • FROM python:3.12-slim@sha256:f77ac9e44ae96ef2c90b8053ea08c31f8be030f824196b0ae4db6d462c84e51f.
  • Nine wheels from requirements/hermes-runtime-contracts.lock, each at the lock's version and hash, installed --no-deps --only-binary=:all: --require-hashes: attrs 26.1.0, jsonschema 4.25.1, jsonschema-specifications 2025.9.1, pyyaml 6.0.3, referencing 0.37.0, rfc3339-validator 0.1.4, rpds-py 2026.6.3, six 1.17.0, typing-extensions 4.16.0.
  • This is the child worker's recipe, byte for byte. test_the_sealed_image_installs_exactly_what_the_lock_pins holds each pin to the lock.
  • A --no-cache build in the proof downloaded all nine and verified their hashes. pip list in the built image shows exactly those nine and pip.

Evidence

Failing first. Each round's tests failed on the code as it was, then passed:

  • Round 1: 34 failed and 1 passed on HEAD's lane and workflow. Quotes: "AssertionError: the probe ran on this runner, not in a sealed container"; "Failed: DID NOT RAISE SealRefused" for the image and variable refusals; assert 0 == 1 for the fence; "AssertionError: no finalize step matching {'id': 'dfr-sealed-image'}"; "ValueError: not enough values to unpack" for the argv shape; "AttributeError … SEALED_SNAPSHOT_LIMIT" for the stdout bound.
  • Scrub sweep: assert 1 == 5, one sweep where five were asserted, and assert 0 == 1 twice.
  • Round 2 (Copilot 5332316826): 8 failed. A second log line ::error::sealed %0A::stop-commands::guessed was printed; the stand-in saw DOCKER_HOST and the other routing variables; IndexError because no SEALED_IMAGE= was cleared; assert 4 == 1 log lines.
  • Round 3 (Copilot 5332433734, 5333273349): 7 failed. The stand-in docker saw the job's HTTP_PROXY, https_proxy and GH_TOKEN, and the scrub exited 0 with an image left.
  • Round 4 (Copilot 5333436182): assert True is False, because a pre-Contain the finalize job's sealed runs in a container with the seal read-only (ruling (b), parent side) #1191 lane's nightly ran.
  • Round 5 (Copilot 5333547364): the planted link's target was overwritten, and a directory raised IsADirectoryError.

Counts.

  • Seal and refresh modules at a37cc97e: 445 passed. tests/carve_manifest at de1ab0e1 and after: 250 passed.
  • CI pytest-suite at cb9e0d35, the head: selected=9256 passed=9250 skipped=6 failures=0. Main at 7af30fc5: 9201/9195/6. That is +55 tests, and skipped stays at 6.
  • The real-docker proof is not collected; it lives in tests/sealed-run-proof/, off the openDox carve surface.
  • A local full-suite run found the carve issue: three tests/carve_manifest tests refused the proof's first location under tests/ideation-dashboard/ as an undeclared carve movement, which is why it moved.

Mutation checks. 80 distinct mutants, each reverting one guard, run against the seal modules in 12 shards.

  • 77 of 79 were killed at 98e64380, and the 2 survivors, W15 and R17, are killed by the tests 35d8c1fc adds.
  • a37cc97e adds R19 (a removal taken on trust), which is killed, and re-checks A26 at its new spelling, also killed. So all 80 are killed at the head's code.
  • Earlier rounds found and killed three more survivors: A23 (a fixed fence token), A40 (the validator bound) and W16 (the build config).
The mutation table
# Mutant Killed by (a failing test)
A01 no --rm test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A02 no --init test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A03 no --pull never test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A04 no --read-only test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A05 /tmp exec test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A06 --network bridge test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A07 no --ipc none test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A08 no --user test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A09 no --cap-drop ALL test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A10 no no-new-privileges test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A11 no --pids-limit test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A12 no --memory test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A13 no --cpus test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A14 no --label test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A15 no --log-driver none test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A16 env passes a name through test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A17 seal mount writable test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A18 judged mount writable test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A19 /out exec test_every_sealed_run_is_one_docker_run_in_the_childs_shape
A20 mount-source field check off test_a_mount_source_that_could_add_a_field_is_refused[a-comma]
A21 docker CLI gets the job's env test_the_docker_cli_runs_with_none_of_the_jobs_environment
A22 strict detail unfenced test_the_strict_findings_reach_the_log_inside_a_fence
A23 fence token fixed test_each_fence_is_opened_with_a_token_of_its_own
A24 stdout bound flag off test_the_snapshot_leaves_the_render_by_stdout_bounded
A25 stderr bound flag off test_a_render_that_prints_past_the_log_bound_is_refused
A26 left-running check off test_a_container_left_running_is_removed_and_refuses_the_seal
A27 timeout leaves containers test_a_render_that_does_not_finish_is_refused
A28 unlistable daemon accepted test_a_daemon_that_cannot_list_the_runs_refuses_the_seal
A29 ACTIONS_ALLOW_UNSECURE_COMMANDS allowed test_a_variable_that_would_take_the_calls_elsewhere_refuses_every_sealed_run[ACTIONS_ALLOW_UNSECURE_COMMANDS]
A30 DOCKER_HOST allowed test_a_variable_that_would_take_the_calls_elsewhere_refuses_every_sealed_run[DOCKER_HOST]
A31 image regex loosened test_no_sealed_code_runs_without_the_image_the_build_step_records[a-short-id]
A32 image fullmatch -> match test_no_sealed_code_runs_without_the_image_the_build_step_records[a-trailing-newline]
A33 root uid/gid allowed test_a_root_uid_runs_no_sealed_code
A34 docker by PATH lookup test_the_real_lane_calls_docker_by_its_absolute_system_path
A35 missing docker CLI accepted test_no_docker_cli_at_its_absolute_path_runs_no_sealed_code
A36 label not this run's test_a_container_left_running_is_removed_and_refuses_the_seal
A37 wrapper takes any output kind test_render_output_that_is_not_a_file_of_its_own_is_refused[a-link-out-of-its-directory]
A38 wrapper keeps PWD test_the_pre_dispatch_render_holds_no_credential_and_no_repository
A39 render stdout bound x64 test_the_snapshot_leaves_the_render_by_stdout_bounded
A40 validator stdout bound x64 test_each_sealed_run_is_read_to_its_own_bound
A41 validator timeout ignored test_a_validator_run_that_reaches_no_verdict_is_refused[hangs]
A42 render log bound ignored test_a_render_that_prints_past_the_log_bound_is_refused
A43 probe back on the runner test_the_confined_locator_never_adopts_the_sealed_validator
A44 strict validation back on the runner test_a_validator_run_that_reaches_no_verdict_is_refused[prints-another-shape]
A45 container resolved after the archive test_no_sealed_code_runs_without_the_image_the_build_step_records[a-trailing-newline]
A46 render timeout ignored test_a_render_that_does_not_finish_is_refused
W01 FROM by tag test_the_sealed_image_installs_exactly_what_the_lock_pins
W02 no --require-hashes test_the_sealed_image_installs_exactly_what_the_lock_pins
W03 no --only-binary test_the_sealed_image_installs_exactly_what_the_lock_pins
W04 no --no-deps test_the_sealed_image_installs_exactly_what_the_lock_pins
W05 bare gh after the seal test_every_step_after_sealed_code_calls_its_tools_by_absolute_path
W06 seal step shell by PATH test_the_seal_steps_failure_is_what_withholds_an_unwritten_result
W07 scrub not always test_the_job_removes_its_sealed_containers_and_image_last
W08 build allows DOCKER_HOST test_the_build_step_refuses_what_would_take_the_calls_elsewhere
W09 build allows ACTIONS_ALLOW_UNSECURE_COMMANDS test_the_build_step_refuses_what_would_take_the_calls_elsewhere
W10 scrub sweeps once test_the_scrub_sweeps_until_no_container_of_this_run_is_left
W11 scrub final container check off test_the_scrub_sweeps_until_no_container_of_this_run_is_left
W12 image unlabelled test_the_finalize_job_builds_the_sealed_image_before_the_seal
W13 SEALED_IMAGE not recorded test_the_build_step_records_no_image_id_but_its_own[a-build-that-ends]
W14 image id unchecked test_the_finalize_job_builds_the_sealed_image_before_the_seal
W15 scrub lists tagged images only test_the_scrub_removes_an_untagged_image_of_this_run (added in 35d8c1fc)
W16 build gets no docker config of its own test_the_build_step_records_no_image_id_but_its_own[a-build-that-stops]
R1 build step leaves SEALED_IMAGE as the job held it test_the_build_step_records_no_image_id_but_its_own[a-build-that-stops]
R3 command data leaves % unescaped test_a_sealed_reason_reaches_the_log_as_one_warning_line[refused]
R4 one line keeps its line breaks test_an_outcome_reason_is_one_line_in_the_log_and_the_annotation[strict_failed]
R5 annotation leaves % unescaped test_an_outcome_reason_is_one_line_in_the_log_and_the_annotation[strict_failed]
R6 NOT SEALED prints the raw reason test_a_sealed_reason_reaches_the_log_as_one_warning_line[refused]
R7 STRICT FAILED prints the raw reason test_a_sealed_reason_reaches_the_log_as_one_warning_line[rejected]
R8 log line keeps the raw reason test_an_outcome_reason_is_one_line_in_the_log_and_the_annotation[strict_failed]
R9 build runs in the job's environment test_the_build_step_records_no_image_id_but_its_own[a-build-that-stops]
R10 a scrub call in the job's environment test_the_scrub_sweeps_until_no_container_of_this_run_is_left
R11 scrub hands the job's token on test_the_scrub_sweeps_until_no_container_of_this_run_is_left
R12 scrub ignores the recorded image left test_an_image_the_scrub_could_not_remove_fails_the_step[the-recorded-image]
R13 scrub ignores a labelled image left test_an_image_the_scrub_could_not_remove_fails_the_step[an-image-with-the-label]
R14 scrub exits clean whatever is left test_a_container_the_scrub_could_not_remove_fails_the_step[a-container-that-never-goes]
R15 seal step runs any pinned lane test_the_seal_step_runs_no_lane_that_would_run_sealed_code_here[a-lane-from-before-1191]
R17 refusal written through a link test_the_refusal_the_seal_step_records_follows_nothing_at_its_path[a-link-the-step-cannot-remove] (added in 35d8c1fc)
R18 refusal path not cleared first test_the_refusal_the_seal_step_records_follows_nothing_at_its_path[a-link-out-of-the-checkout]
R16 seal step runs any lane that imports test_the_seal_step_runs_no_lane_that_would_run_sealed_code_here[a-lane-from-before-1191]

Real-docker proof. tests/sealed-run-proof/sealed_run_containment_proof.py ran on docker 29.8.1 client / 29.6.2 server, at cb9e0d35's content with --fresh-build. All 45 checks pass. Every "nothing left" check counts only a listing that succeeded: with /bin/false for docker, the check records a FAIL.

  • Build step, verbatim: labelled image sha256:62765478….
  • Planted PATH executables: every write aimed at the runner is refused EROFS, and the run's own /tmp and /out refuse exec. No planted gh, git, docker, python3, sh or cat ran. The run is uid 1000 with CapEff 0000000000000000, no network, no docker socket, and none of the canary tokens. The seal and the working directory are unchanged, byte for byte.
  • Detached nohup child and double-forked daemon: the run returned in 1.8 s and nothing was left. The control run on the runner, as sealed code ran before Contain the finalize job's sealed runs in a container with the seal read-only (ruling (b), parent side) #1191, left both children alive 10 s after the render returned.
  • Workflow-command floods: a 3 MiB log flood was kept at 1,048,576 bytes and refused. A 40 MiB flood written past the wrapper through /proc/1/fd/1 was kept at 33,554,432 bytes and refused. A hostile validator's findings printed only inside the fence, guessed fence lines included.
  • Timeout, output kinds and bounds: a render ignoring every signal was refused after 5.5 s and removed. A link, a directory and a fifo at /out were each refused with exit 3. The run stopped at 125 processes, and a render past 1 GiB was killed (exit 137).
  • The real seal phase of this checkout (origin/main 7af30fc5): sealed, with 4133 files. The daemon's own events show three containers of the run's label (the probe, the render, the --strict validation), each with die:0 and destroy. The manifest's precheck is validated, with 400 documents.
  • Last step, verbatim: exit 0, with no image and no container of the run left.
  • About the proof itself: --daemon-path-map rewrites only mount sources, for a dev container that reaches the host's daemon through its socket. The argv above is the lane's.

Copilot. Reviews 5332316826, 5332433734, 5333273349, 5333436182, 5333547364 and 5333919317 opened 10 threads.

  • 9 were fixed test-first, and each reply cites the fix commit.
  • 1 (the wrapper's check-then-cat race) was answered: the race gains sealed code nothing it could not already copy into /out, and no runner path is inside the container.
  • All 10 are resolved. Reviews 5333582652 (at 98e64380), 5334022705 (at a37cc97e) and 5334072030 (at cb9e0d35, the head) found nothing. cb9e0d35 acts on 5334022705's overview note that the proof must fail on a daemon that cannot list.

Gates. Every required check is green at cb9e0d35, the head: former-id-arrival-gate, lane-line, openspec-cli-pin, openxdox-consumer-gate, pytest-suite, release-tag-gate, signed-execution-chain-gate, wallet-validation. SonarCloud is not required.

🤖 Generated with Claude Code

brettheap and others added 2 commits September 27, 2026 21:58
… does

Brett Heap ruled on 2026-09-27, verbatim, "(b) for the finalize job too":
the parent-side twin of the ruling opensoft/xFactory#526 landed at
db26fdc0. The seal step ran the sealed validator's probe, the pre-dispatch
render and its --strict validation as subprocesses on the runner, which
holds the App token and runs later steps with it.

Each now runs as one docker run the lane builds (SealedContainer), in the
child worker's shape: the image the new build step made, by its content
id, with --pull never; the seal mounted read-only at /seal, a validator's
judged file read-only at /judged, and the render's only writable place a
tmpfs of its own at /out; a read-only root with a noexec /tmp, no
network, no IPC, no capabilities, no new privileges, this runner's
non-root uid, and a bound on processes, memory and CPU; four literals of
environment and nothing else; --init and --rm in the foreground, with this
run's label. The docker CLI is called at /usr/bin/docker with a fresh
configuration and none of the job's environment. The host reads only what
a run prints, bounded; the render's snapshot leaves by stdout, capped at
32 MiB, through the child's own wrapper. A container still running after
its run returned is removed and refuses the seal. The strict findings
reach the log inside a ::stop-commands:: fence with a fresh 128-bit
token.

The image id crosses in SEALED_IMAGE, set by a new build step, because
the workflow runs at main while the lane comes from the aggregation's pin:
a lane that predates this ignores it, and this lane without it runs no
sealed code at all. The build step pins python:3.12-slim by digest and
installs the nine wheels requirements/hermes-runtime-contracts.lock pins,
by hash, binary-only. It and the lane refuse ACTIONS_ALLOW_UNSECURE_COMMANDS
and every DOCKER_*/BUILDX_* variable that would move the calls elsewhere.
Every step from the build on runs /bin/bash and calls each tool by its
absolute path. The job's last step removes the run's containers and image
by label. The exit-3 contract for an unwritten seal result is unchanged.

The seal tests run every sealed run through a stand-in docker CLI that
maps the container's paths onto the host, so they drive the lane's own
argv, bounds and leftover check. The host-read render-output checks retire
with the host-side render: nothing a render writes reaches the runner.

Refs #1191
Refs #1161
Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lize-sealed-runs

Takes main 7af30fc (one commit, four files, none of them this pull
request's).

Refs #1191
Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 27, 2026 21:59
@sourcery-ai

sourcery-ai Bot commented Sep 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR hardens the finalize job by making every sealed execution run in a locally built, digest-identified Docker container with strict isolation, bounded host-visible I/O, fail-closed validation, and unconditional cleanup; workflow and extensive tests enforce the integration and security invariants.

Sequence diagram for containerized finalize sealing

sequenceDiagram
    participant Workflow as Finalize workflow
    participant Lane as dashboard_refresh_lane
    participant Docker as Local Docker daemon
    participant Container as SealedContainer
    participant Seal as Read-only seal
    participant Validator as Sealed validator

    Workflow->>Docker: docker build --iidfile
    Docker-->>Workflow: SEALED_IMAGE
    Workflow->>Lane: seal_source()
    Lane->>Lane: resolve_sealed_container()
    Lane->>Docker: run validator probe
    Docker->>Container: Start isolated container
    Container->>Seal: Read sealed validator and product
    Container-->>Lane: Bounded verdict and logs
    Lane->>Docker: run render
    Docker->>Container: Start isolated container
    Container->>Seal: Read sealed corpus
    Container-->>Lane: Bounded snapshot on stdout
    Lane->>Docker: run strict validation
    Docker->>Container: Start isolated container
    Container->>Seal: Read validator and product
    Container-->>Lane: Bounded strict verdict
    Lane-->>Workflow: Seal result
Loading

Flow diagram for fail-closed finalize sealing

flowchart TD
    Start[Finalize seal begins] --> Checks{Required runtime checks pass?}
    Checks -->|No| Refuse[Refuse seal before archiving\nand run no sealed code]
    Checks -->|Yes| Archive[Create and hold seal]
    Archive --> Probe[Containerized validator probe]
    Probe --> Render[Containerized sealed render]
    Render --> Validate[Containerized strict validation]
    Validate --> Result{Runs valid and bounded?}
    Result -->|No| RefuseResult[Record refusal or strict failure]
    Result -->|Yes| Sealed[Write sealed result]
    Sealed --> Fence[Print strict findings inside\nstop-commands fence]
    RefuseResult --> Cleanup[Always remove labeled containers\nand sealed image]
    Sealed --> Cleanup
    Refuse --> Cleanup
Loading

File-Level Changes

Change Details Files
Move all sealed validator, probe, render, and strict-validation execution into a dedicated Docker container with fail-closed runtime checks.
  • Add SealedContainer to construct constrained /usr/bin/docker run invocations using a digest-pinned image, read-only seal mounts, bounded writable tmpfs, non-root execution, no network/IPC/capabilities, resource limits, minimal environment, and cleanup checks.
  • Resolve and validate SEALED_IMAGE, Docker-related environment variables, runner identity, Docker availability, labels, mount paths, bounded output, timeouts, and leftover containers before allowing sealed work.
  • Stream render output through the container wrapper and mount validator inputs read-only, preserving existing verdict/refusal semantics while preventing host filesystem writes and untrusted log commands.
scripts/ideation_dashboard/dashboard_refresh_lane.py
Build and lifecycle-manage the sealed execution image in the finalize workflow.
  • Build a digest-pinned Python image from an inline Dockerfile with the exact locked, hashed runtime wheels and publish its content ID through SEALED_IMAGE.
  • Refuse unsafe Docker-routing variables, use isolated Docker configuration, apply absolute tool paths and privileged-shell settings to post-build steps, and add unconditional container/image cleanup by run label and image ID.
.github/workflows/doc-health-reusable.yml
Expand tests to verify container isolation, workflow wiring, bounded I/O, cleanup, and fail-closed behavior.
  • Add a stand-in Docker CLI and assertions for container command shape, mounts, environment isolation, image identity, labels, timeouts, output bounds, fenced findings, and leftover-container handling.
  • Cover refusal when the image, Docker daemon, runner identity, or mount paths are invalid, and verify exact workflow image-build, absolute-command, shell, and cleanup requirements.
tests/ideation-dashboard/test_dashboard_refresh_lane.py
tests/ideation-dashboard/test_dashboard_source_seal.py

Possibly linked issues


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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved critical security issues remain in image provenance and workflow-command fencing.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)
What changed in this PR

This PR moves finalize-job sealed operations into hardened, digest-pinned Docker containers and strengthens workflow isolation.

Changes:

  • Adds constrained container execution, bounded output, fencing, and cleanup.
  • Builds and records the pinned sealed-run image with absolute tool paths.
  • Expands tests for containment, refusals, output limits, and workflow hardening.
File Review summary
tests/​ideation-dashboard/​test_dashboard_source_seal.py Tests container behavior, isolation, and refusal cases.
tests/​ideation-dashboard/​test_dashboard_refresh_lane.py Tests Docker invocation restrictions and workflow hardening.
scripts/​ideation_dashboard/​dashboard_refresh_lane.py Critical (2 votes): fence or sanitize all sealed-derived warning reasons. Moderate (1 vote): verify docker rm -f succeeds before reporting cleanup.
.github/​workflows/​doc-health-reusable.yml Critical (2 votes): clear stale SEALED_IMAGE after build failure. Moderate (4 votes): isolate cleanup from refused Docker routing variables. Moderate (1 vote): use a minimal build environment to prevent inherited Docker-sensitive variables.

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

…e containment on real docker

The job's last step now sweeps this run's containers until none is
left, for at most 30 seconds, before it removes the sealed image. A
container already going away by its own --rm refuses `docker rm` and
holds the image until it is gone, which opensoft/xFactory#526 found on
real docker. A container still there after the sweep, or a daemon that
cannot say, fails the step. The step is continue-on-error, so the
nightly is never failed by it, and the run shows it. Three behavioural
tests run the step under its own shell against a stand-in docker, and
failed first on the step as it was.

tests/ideation-dashboard/sealed_run_containment_proof.py is the
real-docker proof. It is not a test module, so pytest never collects
it and CI's counts are unchanged. It runs the workflow's own build
step and last step under their own shells, a hostile seal through the
lane's SealedContainer, and the real seal phase of the checkout. On
docker 29.8.1 / 29.6.2 all 45 checks pass. The hostile seal carries a
planted PATH executable and writes aimed at the runner, a detached nohup
child and a double-forked daemon, and a workflow-command flood past
each bound and through the fence. A control run of the same children
on the runner shows them outliving their render.

Four comments that still described sealed code running on the runner
now describe the container.

Refs #1191
Refs #1161
Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 27, 2026 22:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved moderate issues affect cleanup, image provenance, and workflow-command output safety.

Review effort: Lite
Findings: 2 High severity · 2 Medium severity

Open (4)

…and print a reason as one line

From Copilot review 5332316826 on PR #1192:
- The build step writes SEALED_IMAGE= to GITHUB_ENV as its first
  command. A build that stops therefore leaves no image id for a later
  step, whatever the job held before. The built id is recorded only at
  the end, once checked, and GITHUB_ENV takes the last value written.
- Before its first docker call, the last step unsets the variables the
  build and the lane refuse: DOCKER_HOST, DOCKER_CONTEXT, DOCKER_TLS,
  DOCKER_TLS_VERIFY, DOCKER_CERT_PATH, BUILDX_CONFIG and BUILDX_BUILDER.
  It then removes what the local daemon holds.
- A refusal's reason reaches the log as one line. The seal phase's
  STRICT FAILED and NOT SEALED warnings escape it as workflow-command
  data. RefreshOutcome's log line and annotation make it one line, and
  the annotation escapes % as well.

Three more tests cover guards that round 1's mutation checks found
untested: every fence opens with a token of its own, every sealed run
is read to its own bound, and the build step's docker configuration is
made fresh in the job's temporary directory.

Every new test failed first on the code as it was, except those three,
which each kill their mutant. The round-2 mutation checks killed 11 of
11 mutants: the three round-1 survivors and one for each new guard.

Refs #1191
Refs #1161
Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 28, 2026 02:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved workflow isolation and cleanup issues, plus inconsistent Docker refusal handling, remain.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity

Open (2)
Resolved since last review (3)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Convert Docker command timeouts and launch errors to SealRefused

scripts/​ideation_dashboard/​dashboard_refresh_lane.py:2974

If docker ps hangs, subprocess.run(..., timeout=60) raises TimeoutExpired here instead of the documented SealRefused. Direct callers of seal_source therefore get an uncaught exception, and the daemon-listing refusal is not handled consistently; convert timeout (and launch OSError) into the same fail-closed refusal before returning.

…hind, and move the proof off the carve surface

From Copilot reviews 5332433734 and 5333273349 on PR #1192:
- The build step's `docker build` now runs under `env -i` and sees only
  PATH, HOME, DOCKER_CONFIG and LANG, the environment the lane's own
  docker calls have. The CLI honors proxy variables from its environment,
  not only from its configuration, so a fresh DOCKER_CONFIG alone was not
  enough.
- Every docker call in the last step runs the same way. That supersedes
  the unset of the refused variables: no proxy, routing variable or token
  of the job's reaches any call.
- The last step also fails when the recorded image, or any image
  carrying the run's label, is still there after the removals, or when
  the daemon cannot say. A container left behind already failed it.

The real-docker proof moves from tests/ideation-dashboard/ to
tests/sealed-run-proof/. tests/ideation-dashboard/ is the openDox carve
surface (docs/opendox-carve-manifest.yaml): a file that appears there
needs a re-cut of the manifest, and three tests in tests/carve_manifest
refused the proof as an undeclared movement.

The tests failed first on the steps as they were. The stand-in docker
saw the job's proxies and token on every call, and the step exited 0
with an image left.

Refs #1191
Refs #1161
Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 28, 2026 02:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical containment and rollout-gating issues remain, along with cleanup and proof correctness issues.

Review effort: Lite
Findings: 2 High severity · 1 Low severity

Open (3)
Resolved since last review (2)

From Copilot review 5333436182 on PR #1192. This workflow runs at
openxFactory main, while the lane comes from the aggregation's pin. A
lane from before #1191 ignores SEALED_IMAGE and runs the probe, the
render and its --strict validation on the runner. Until the pin-sync,
the job would therefore have built the image and still run sealed code
on the host.

The seal step now asks the pinned lane first, and runs it only when it
names SEALED_IMAGE. A lane that does not, or that cannot be imported,
seals nothing. The refusal is written as the seal's result, so the
record step reports it, nothing is uploaded or dispatched, and no
sealed code runs. The image refresh pauses until the pin-sync carries
#1191. That is the fail-closed side of the ruling.

The tests run the seal step under its own shell, in a stand-in workspace
with each kind of pinned lane. On the step as it was, the lane from
before #1191 and the one that cannot be imported both failed first:
their nightly ran. A test comment also named the proof at a path it
never had; it now names tests/sealed-run-proof/.

Refs #1191
Refs #1161
Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 28, 2026 02:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

An unresolved critical result-path safeguard issue remains, along with proof validation gaps.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (3)

From Copilot review 5333547364 on PR #1192. The seal step writes the
refusal for a pinned lane that predates #1191 itself, because that lane
cannot be trusted to. It wrote with open(..., "w"), which follows a link
planted at dfr-seal-result.json, so it could overwrite the link's
target outside the checkout.

It now writes as the lane writes its own result. Whatever sits at the
path is removed without being followed, and the result is created
O_EXCL|O_NOFOLLOW. A path that cannot be cleared, such as a directory,
gets no result, and still nothing is sealed.

The test plants a link to a file outside the workspace, and then a
directory. Both failed first on the step as it was. The link's target
was overwritten with the refusal, and the directory raised
IsADirectoryError and failed the step.

Refs #1191
Refs #1161
Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 28, 2026 03:04

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

Address retry resource cleanup, document launch-failure behavior, and remove the host-specific absolute path.

Review effort: Lite
Findings: None

Resolved since last review (1)

The final mutation run at 98e6438 killed 77 of 79 mutants. The two
survivors are killed by the tests added here, and no code changes:
- W15 made the scrub's removal list images without -a. Docker's
  containerd image store lists an untagged image only with --all, which
  opensoft/xFactory#526 found on real docker. The stand-in docker now
  lists an untagged image of the run only to -a, and
  test_the_scrub_removes_an_untagged_image_of_this_run asserts the image
  is removed and the step ends clean.
- R17 wrote the seal step's refusal with open(..., "w"). The rm before
  it removed the planted link, so no test reached the O_NOFOLLOW. The new
  case plants a link the step cannot remove (a read-only workspace), and
  the link's target stays untouched.

Refs #1191
Refs #1161
Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 28, 2026 04:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved cleanup and container-accountability failures can permit unsafe image deletion or leave sealed processes running.

Review effort: Lite
Findings: 1 High severity

Open (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Guard recorded-image cleanup when the build step is skipped

.github/​workflows/​doc-health-reusable.yml:4348

This cleanup is always(), while dfr-sealed-image is conditional (3766), so when that build step is skipped it never clears SEALED_IMAGE. A digest supplied by the job/workflow environment can therefore reach this image rm and delete an unrelated image even though no image was recorded by this run. Gate the recorded-image removal/inspection on steps.dfr-sealed-image.outcome == 'success' (while retaining the label sweep for images actually built by this run), or clear the variable in an unconditional step first.

From Copilot review 5333919317 on PR #1192. When a container of the
run's label was still running after its run returned, the lane removed
it and refused the seal, saying it was removed. It said so even when the
daemon had rejected the removal.

After the removal the lane now lists the run's running containers again.
If one is still there, the refusal names it and says the daemon could
not remove it, and that the job's last step removes what the run left.
The seal is refused either way. _remove now returns whether the daemon
removed what it was asked to.

Both tests failed first on the lane as it was. The stand-in docker now
removes what `rm -f` names unless it is told to reject the removal. The
test for a container left running asserts the listing that follows the
removal, and hit IndexError where no second listing existed. The new test
for a rejected removal got the "it is removed" message. The mutation
checks kill R19 (the removal taken on trust) and A26 at its new spelling.

Refs #1191
Refs #1161
Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 28, 2026 04:33

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 containment proof must fail when Docker cannot list containers instead of treating empty output as successful cleanup.

Review effort: Lite
Findings: None

Resolved since last review (1)

From the overview of Copilot review 5334022705 on PR #1192. The proof
read an empty `docker ps` listing as "no container left" even when the
listing itself failed. Its last check read "image gone" from an
`image inspect` that fails for a daemon that cannot answer.

containers_of now returns None when the daemon cannot list, and
nothing_left fails on it. The final check fails unless both image
listings succeed and neither shows the run's image. With /usr/bin/docker
replaced by /bin/false, nothing_left now records a FAIL ("the daemon
could not list them"). At this head, with a fresh build, all 45 checks
still pass on docker 29.8.1 / 29.6.2.

Refs #1191
Refs #1161
Lane: openxfactory-5 (openXfactory-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 28, 2026 04:41

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

Workflow cleanup and refusal-result handling can act on unrelated or stale resources when prerequisite operations fail.

Review effort: Lite
Findings: None

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
D Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@brettheap
brettheap marked this pull request as ready for review September 28, 2026 05:08

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-5 (openXfactory-5)

LANDING — lane openXfactory-5, session b254fdd5-0bdf-44e0-bb45-5a780234009f@Eagle, 2026-09-28T05:10:22Z, PR #1192 into opensoft/openxFactory main

@brettheap
brettheap merged commit b422b30 into main Sep 28, 2026
14 of 15 checks passed
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openxfactory-5 (openXfactory-5)

LANDED — lane openXfactory-5, session b254fdd5-0bdf-44e0-bb45-5a780234009f@Eagle, 2026-09-28T05:10:40Z, PR #1192 into opensoft/openxFactory main → merge b422b30; Run every sealed run of the finalize job in a container, as the child does (#1191)

@brettheap
brettheap deleted the fix/1191-contain-finalize-sealed-runs branch September 28, 2026 05:11
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.

Contain the finalize job's sealed runs in a container with the seal read-only (ruling (b), parent side)

2 participants