Skip to content

[DRAFT RDTE / API-ONLY] Single-writer admission — entrypoint handoff still blocked - #183

Draft
mark-e-deyoung wants to merge 2 commits into
rdte/mvp-two-writer-fencing-20261121from
rdte/mvp-single-writer-admission-20261121
Draft

mark-e-deyoung wants to merge 2 commits into
rdte/mvp-two-writer-fencing-20261121from
rdte/mvp-single-writer-admission-20261121

Conversation

@mark-e-deyoung

@mark-e-deyoung mark-e-deyoung commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Current safety correction

The first-source implementation only guards the FastAPI lifespan. Do not interpret it as complete single-writer WineBot startup admission. The shell entrypoint and service bootstrap mutate instance state, Wine/profile environment, tracing, recorder and API token files before uvicorn lifespan obtains the lock. See the pinned red-team DLE comment on this PR and the next required entrypoint→API atomic FD handoff. This is a release blocker even if source-bound CI succeeds. No main/hardware/release promotion.


Intent

Implement the first production-facing bounded mitigation identified in formal two-writer DLE #182: no two API processes may concurrently mutate the same Linux session root. A module-local asyncio.Lock is insufficient across processes. This does NOT complete cross-host generation fencing or the multi-file transactional protocol.

Exact-source workcell

Stacked on corrected and formal/TLC-green #182 at 638f3cacd0451009fa39371af4d4451e2cdd5a02. One atomic five-path commit 8e2a8ded024268e2f0907ff0425c3a90c6055ffe, compare ahead one/behind zero. Source:

  • New api/core/writer_admission.py: Linux/POSIX nonblocking exclusive flock retained via one FD for process lifespan, held under config.WINEBOT_SESSION_ROOT/.winebot-active-writer.lock. Requires absolute non-symlink root, secure O_NOFOLLOW/O_CLOEXEC and directory-relative file open, regular single-linked current-UID lock file, 0600 perms. Fails closed on contention/unsupported platform/invalid identity; no permissive fallback.
  • api/server.py: wraps existing lifespan in an admission context before any running-instance write, user profile-link mutation, broker initialization or crash-recovery call. Existing inner startup and shutdown logic unchanged.
  • New tests/test_writer_admission.py: actual competing process and FD denial, lock/root symlink negative, synthetic SIGKILL release/reacquisition, relative-root fail-closed, startup refusal before instance state mutation. No Wine/desktop/network/real user data.
  • Mandatory scripts/ci/test.sh: explicit new regression enrollment, preserved 100755 executable mode (Git tree read-back checked).
  • Formal TLC workflow triggers when production admission module or its tests change, preserving four bounded blue models and all three required red counterexample controls.

Independent local experiment

The lock primitive and four corresponding disposable Linux subprocess tests passed in the ChatGPT execution sandbox (4/4); this is not a release proof. The new server-startup guard and exact combined source MUST pass hosted free public CI before accepting even the bounded Linux process-exclusivity claim.

Acceptance / non-claims

Require new exact-head $0 public GitHub Actions full lint/unit, frozen external conformance, smoke, TLC and red/blue checks, BuildKit/public trust guards; then synthetic and actual multi-worker runtime launch under one shared persistent root and SIGKILL, source/projection/mount review. Preserve DRAFT, no automatic merge, hardware or image promotion. POSIX flock is local advisory admission only; shared filesystem/NFS semantics and multi-host or VM fencing not qualified. Orphan Wine/AHK process effects, atomic multiple-file session state and generation CAS remain separate gates, as does private WinInspect C++ #468 and native HWND #166. No private Actions minutes, paid compute, user hardware, private source or public image publication.

Add fail-closed POSIX flock under shared session root with secure path
flags and FD lifetime ownership, precede all startup state/profile/broker
mutations, and enroll real two-process contention and SIGKILL tests.
This is a bounded single-process guard, NOT distributed epoch fencing.
Source-exact full CI #44913250928 first-failed only at UP035 import
location. Preserve all admission/runtime behavior, tests and formal gates;
require fresh public CI rather than waiving lint.

Copy link
Copy Markdown
Collaborator Author

2026-11-21 — first exact-head CI failure and source-exact fix (R033)

Initial Linux admission PR #183 8e2a8ded024268e2f0907ff0425c3a90c6055ffe passed formal TLC #44913250935 (four blue models / three mandatory counterexample controls), and focused BuildKit, source provenance, disposable contracts, redaction and public evidence all SUCCESS. Full CI #44913250928 FAILURE solely at first Containerized Linting step, Ruff UP035: use collections.abc.Iterator instead of typing.Iterator in new api/core/writer_admission.py:10. Conformance/smoke were skipped, not passed. Exact R033 first-failure evidence is in job 136873333512; no runtime test failure claimed.

Corrective source: commit 04aa0061a008563d04dda5b4755b8bbe42d9a5c8 changes only the location of the Iterator type import to the exact Ruff-requested stdlib module. No mutator admission policy, kernel flock, symlink rejection, lifecycle ordering, test or formal gate changed. Re-run full exact-head CI; retain draft and NOT_READY_FOR_HARDWARE_TEST until source-bound full success and real two-worker/mount/runtime proof. This is still local POSIX exclusivity, not durable generation CAS or cross-host distributed fencing.

Copy link
Copy Markdown
Collaborator Author

2026-11-21 — red-team cross-layer startup ordering gap (explicit release hold)

Static source fact: docker/entrypoint.sh drops to winebot and writes /tmp/winebot_instance_state.json with starting at line 94, writes the pid sentinel and loads config, then sources 10-setup-infra.sh and 20-setup-wine.sh, before calling 30-start-services.sh at line 166. The latter launches optional Windows/native tracing and recorder (lines 7–79), writes an API-token file under /tmp and potentially /winebot-shared (lines 83–105), and only then backgrounds uvicorn api.server:app (line 110). Thus new #183 api/server.py::lifespan process lock fires after these earlier entrypoint and service mutations. It guards a subset of API-worker concurrent writes but does NOT satisfy global invariant SW2 (no persistent/mutating side effect before admission).

Consequence: No false source-to-system promotion even if all #183 CI is green. The entrypoint's existing /tmp/entrypoint.user.pid file is a best-effort PID check, not an atomic cross-process lock/fencing guarantee. The process-lifetime lock now staged is a bounded API lifespan guard only, not full WineBot process/guest ownership, multi-container admission, or generation CAS.

Required next implementation before release: acquire one process-lifetime, shared-root exclusive admission as early as possible after privilege drop but before line 94, then hand the same kernel lock ownership/FD to the API/long-running runtime without a release/reacquire gap; validate ownership (same inode, UID, trusted directory, exact namespace/mount) across shell→service→API and ensure no orphan child holds an unintended lock or carries mutating authority after takeover. A separate trusted volume/root test is required because /artifacts, /wineprefix and /tmp currently have different custody. Run two full entrypoints on one shared persistent root, SIGKILL at each startup stage, and prove the second cannot mutate/start until the old one is fully quiesced. Only then add durable epoch CAS and restart recovery. Prefer one reusable admission primitive with typed invocation, not unrelated PID gates.

DLE classification: BLOCKED_EARLY_STARTUP_ADMISSION, source-rooted negative finding. #183 remains DRAFT / RDTE, despite its local 4/4 POSIX primitive test and native public TLC PASS. No unqualified native release, private source access, paid cloud/hardware or merge.

This branch has not been deployed

No deployments
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.

1 participant