Skip to content

[DRAFT RDTE] Acquire WineBot writer lease before entrypoint mutations; share FD into API - #184

Draft
mark-e-deyoung wants to merge 6 commits into
rdte/mvp-single-writer-admission-20261121from
rdte/mvp-early-entrypoint-writer-admission-20261122
Draft

mark-e-deyoung wants to merge 6 commits into
rdte/mvp-single-writer-admission-20261121from
rdte/mvp-early-entrypoint-writer-admission-20261122

Conversation

@mark-e-deyoung

Copy link
Copy Markdown
Collaborator

Purpose and source custody

Correct the critical source-bound startup ordering defect in API-only #183: the shell entrypoint writes instance state, config, initializes Wine/desktop, may start recorder/trace/API token before uvicorn lifespan gets its process lock. This candidate acquires one single Linux kernel flock open-file description (OFD) before any 00-setup-user.sh, instance-state, infrastructure, Wine, trace, recorder or API side effects, and passes the same FD across root/user gosu and the API process without release/reacquire.

One atomic 7-path source update to qualified #183 04aa0061a008563d04dda5b4755b8bbe42d9a5c8, new exact head 71d5e93cf048c309c9620cfb08b782ac883caf87. Compare: one ahead, zero behind, exactly seven intended paths, mandatory shell/test runner executable modes preserved.

Implementation

  • api/core/writer_admission.py: new explicit --exec-entrypoint command securely acquires a nonblocking exclusive directory-relative O_NOFOLLOW lock, duplicates FD high (>=200), marks it inheritable, and execves hard-coded /entrypoint.sh. --validate-inherited validates exact root, regular single-link lock inode/device against FD, mode and kernel OFD lock, rejects missing/forged/mismatched FD. API lifespan reuses the inherited lock without LOCK_UN, preventing an unlock gap; standalone API retains existing independent admission. Root may accept an existing lock chowned to the winebot UID by legacy entrypoint setup, otherwise owner/permissions fail closed.
  • docker/entrypoint.sh: first acquisition occurs before root setup. Shell validates FD immediately and after trusted configuration load; refuses a config-modified session root, marker or FD. No reentrant acquisition or untrusted bypass.
  • scripts/init/10-setup-infra.sh: when admitted, failure to create session dirs no longer silently switches to unadmitted /tmp/winebot-sessions; aborts with classified status.
  • tests/test_early_writer_admission.py and mandatory scripts/ci/test.sh: require mock exec on same OFD, real independent Python process inheriting FD across exec/SIGKILL, explicit competing-writer denial, mismatch/spoof rejection and source-level ordering/fallback checks.
  • Formal TLC path filters include shell/admission/infra and new test; formal/SESSION_WRITER_FENCING.md documents design and non-claims.

Qualification/exit

Run exact-head public $0 GHA full lint/unit+frozen v1 conformance+smoke, existing four TLC blue models+three red expected counterexamples, isolation/provenance/security/disposable guards; investigate any first failure and requalify after a minimal corrective commit. Then real two complete entrypoints, root->gosu->child API transfer, Wine11 layered/legacy mount and SIGKILL stages on disposable cloud hosts before owner promotion. Do not treat a unit/model PASS as native/system end-to-end proof.

Boundaries

An admitted single cooperative process family may include entrypoint, one uvicorn API, and Wine subprocesses. High FD may survive with a child and therefore safely delay takeover after parent death; this must be tested, not interpreted as support for untrusted same-UID actors. POSIX flock is not cross-host NFS/distributed fencing, monotonic durable owner epoch/CAS, cross-file commit, orphan-recorder effect retraction, or native WinInspect v0.5 HWND qualification. Existing WineBot #166/WinInspect-private #468/Agent Dispatch #561 native blocker remains. Preserve DRAFT / NOT_READY_FOR_HARDWARE_TEST, no private actions spend, paid cloud, user hardware, private source projection, branch force, merge or release.

Carry one verified kernel OFD from root/user shell into API without
unlock/relock gap; reject root/FD config changes and unadmitted /tmp
fallback; exercise real inherited child vs competing writer and SIGKILL.
Source-bounded Linux single-instance workcell; no distributed CAS claim.
The checkout stores docker/entrypoint.sh, but the test Dockerfile copies
it to /entrypoint.sh and does not materialize /docker/entrypoint.sh.
Verify the same source ordering under both layouts; retain the assertions.
Exact public CI #44981998178: 302 pass, 5 fail when synthetic unit
image runs as root without a winebot account. A freshly root-owned lock
does not require alternate UID lookup; for a legacy chowned lock retain
strict account resolution and fail-closed checks. No lock gate bypass.

Copy link
Copy Markdown
Collaborator Author

2026-11-22 — early-entrypoint first-failure diagnosis and exact correction

Source-authoritative early admission PR #184 first head 71d5e93cf048c309c9620cfb08b782ac883caf87 passed formal TLC, BuildKit, RPC redaction, public evidence/provenance and disposable-layer checks. After source-only path correction 77dfc8c035ed6e1f961584bf5196cf865a5229da, full CI #44981998178 failed at mandatory containerized unit with 302 passed / 5 failed, while real Wine11 composite HIL still in progress. All 5 failures share one source cause: the root-run synthetic unit image does not provide a winebot NSS account; _acquire_writer_fd unconditionally called pwd.getpwnam("winebot") for euid 0, even when the newly created lock was already owned by root 0. First traceback KeyError: getpwnam(): name not found: 'winebot' in api/core/writer_admission.py:73. This is not a test waiver or permission relaxation.

Corrective exact source: de024b17b2b7e2d51a9a746a494c6ab13c5de3a2 changes only the root ownership lookup: accept a strictly root-owned lock with no alternative-account dependency; if an existing lock is non-root, resolve only the actual winebot account and reject unknown owners. Every regular-file, single-link, 0600, real root-path and flock denial remains mandatory. The executable entrypoint/test and previous locked-root checks are unchanged. Need fresh combined exact-head full CI and real Wine11 HIL before any acceptance, plus root->gosu->API FD custody qualification and SIGKILL/mount scope. The product and this draft remain NOT_READY_FOR_HARDWARE_TEST; no main merge/release/paid cloud or private minutes.

Copy link
Copy Markdown
Collaborator Author

2026-11-22 R035 — exact source, first native test result and ongoing gates

de024b17b2b7e2d51a9a746a494c6ab13c5de3a2 is current early-admission head. Initial unit failure at #44981998178 (302 PASS / 5 FAIL) was isolated to root-only synthetic unit image lacking winebot NSS account and corrected without bypass in this exact source. New formal TLC #44982148285 PASS, public evidence #44982148283, BuildKit #44982148252, disposable-layer #44982148250, identity redaction #44982148230, trust provenance #44982148248 and vNext public safety #44982148389 SUCCESS. Full CI #44982148355, startup isolation #44982148356, and Wine 11 layered composite HIL #44982148266 were still RUNNING, not successes, at last readback. Do not accept native owner handoff yet. Layered HIL must prove actual shell/gosu/FD acquisition rather than synthetic model success.

Independent next-release finding: draft #185 branches from preadmission canonical #181 and investigates /tmp/winebot_current_session ephemeral active pointer loss despite durable handover intent. This is an entirely separate source-bound persistence/fencing gap; do not silently fold a production pointer schema migration into this staged entrypoint workcell. Global CAS, orphan marker replay and WinInspect private v0.5 native acceptance remain open. No main merge/release/hardware/paid compute/private GHA minutes.

…fely

After real layered Wine11 HIL first health gate failed with only a
reached-infrastructure marker, emit fixed non-sensitive checkpoints for
session-directory, Xvfb, and WM bootstrap and priority fail-closed root.
Do not expose raw service logs, loosen health or allow unadmitted /tmp.

Copy link
Copy Markdown
Collaborator Author

2026-11-22 — source-exact real layered HIL failure, bounded diagnostic recovery

Real native composite failure on exact de024b17b2b7e2d51a9a746a494c6ab13c5de3a2: public Wine11 layered composite HIL #44982148266 FAILURE, step Build ephemeral candidate and qualify read-only Wine11 replay, job 137084808729 after initial fixed health gate. Safe logs classified STARTUP_DIAGNOSTIC stage=reached_infrastructure; state=running health=starting, token_file=missing, registry=missing, authorized_api=fail; WINE11_LAYER_HIL stage=health_initial. Do NOT count earlier formal/unit success as real Wine11 launch pass or loosen health checks.

Diagnostic-only corrective head: commit edfffa4d4990fab0356b9e6a46bbd3801c46da6c adds only fixed-domain WINEBOT_INFRA_CHECKPOINT markers at begin, session dir ready, Xvfb ready and infra completion and a whitelist-only scripts/ci/classify-startup-logs.py mapping (plus required redaction/unit tests), giving an actionable first-failure stage next public HIL without exposing raw service logs, tokens, paths, identifiers or environment. Failing root fallback remains fatal. New exact HIL #44982906871 and full CI #44982906947 are in progress; formal #44982906945, isolation #44982906883 and focused safeguards success. This has NOT yet fixed actual startup, and must not be promoted.

Parallel durable model #185 exact 56d06dcbd1055fd0fe8c18abe6a85d722cb8aeb3 now full CI #44982261787 SUCCESS in addition to TLC. #187 builds correct one-tree source integration of writer admission + durable pointer models + storage tests on this early-admission head, preserving all blue/red controls; do not assume it proves native health or live persistent pointer migration. No merge/main/release/private GHA spend.

Copy link
Copy Markdown
Collaborator Author

2026-11-22 — additional cross-layer bootstrap boundary (source review, no runtime claim)

The original #183 API-only process lock was corrected to a pre-entrypoint runtime lock in #184, but three-layer Compose has a preceding state-init phase: compose/layered.yml line 19 state-init is a separate short-lived WINEBOT_APP_BUNDLE_IMAGE container with external writable mounts /state/prefix, /state/home, /state/config, /state/userdata, /state/artifacts, /state/shared. winebot-interactive starts after app-seed and state-init complete; it then obtains the new .winebot-active-writer.lock inside its runtime entrypoint. A different Compose project could run its own state-init against the same external persistent state while the first runtime is already admitted. The current parent #184 lock does not, by itself, protect that pre-runtime state initializer. This is a source-rooted cross-deployment concurrency gap, not an observed incident or reason to bypass launch health.
Next sequential gate: bind the same versioned shared-artifacts lock contract to state-init before any persistent mutations, then ensure no release/reacquire gap across state-init→runtime if concurrent deployments are possible, or introduce a validated deployment-controller admission + tested transfer. Keep immutable app-seed separate if its app-store namespace is version-pinned and it never mutates shared user state; prove source boundaries. Do not add an independent incompatible locking method, copy the Python helper to the app bundle without reviewed source custody, or claim POSIX flock gives cross-host consensus. Test two competing full three-layer Compose projects with same volumes and negative admission, crash/SIGKILL at state-init/ready/teardown, and verify existing persisted user files unchanged. Only then can the full three-layer instance claim singleton write ownership.
Current Wine11 HIL first red #44982148266 and new checkpoint #44982906871 (pending) remain separate evidence. #184 and source-combined #187 are DRAFT with protected main untouched.

Real Wine11 layered HIL #44982906871 passed only infra begin, never
session directories or API health. Replace unbounded /dev/urandom shell
pipeline with short secure stdlib generator and add fixed path-free
checkpoints around identity, volatile pointer and mkdir. Fail closed on
entropy, unadmitted root or bounded mkdir failure; no /tmp fallback.
… change

First exact real failure was infrastructure health_initial. Later source
startup diagnostics and CSPRNG fixes did not trigger native HIL because
workflow filters omitted those paths. Enroll writer-admission, API,
infra, setup, diagnostic and synthetic admission test changes so future
source commits cannot pass only model/lint while guest health is stale.

Copy link
Copy Markdown
Collaborator Author

2026-11-22 — real Wine11 first-failure narrowing and missing native CI path corrected

  1. Exact head edfffa4d4990fab0356b9e6a46bbd3801c46da6c real Wine11 layered HIL #44982906871 FAILED, terminal job 137087115509: fixed-safe classification WINE11_LAYER_HEALTH state=running health=starting, STARTUP_DIAGNOSTIC stage=infra_begin, token/registry missing, authorized API fail, WINE11_LAYER_HIL stage=health_initial. Thus early entrypoint lock passed far enough to reach scripts/init/10-setup-infra.sh but never reached session_dirs_ready. Root cause narrowed to session ID generation, ephemeral pointer write, or session mkdir; cannot assert one culprit solely from this marker.
  2. Corrective source 53ef13378ef26549ffd7401602d85d6ce4ebfb7f: replace unbounded cat /dev/urandom | tr | fold | head pipeline with bounded 5-second Python stdlib secrets.token_hex(5), add fixed session identity and pointer-written checkpoints, bound session mkdir at 15s with failure classified as fatal, preserve explicit prohibition on fallback /tmp/winebot-sessions. New source-only tests assert ordering, bounded semantics, redaction and failure priority. Does not claim health solved until real HIL.
  3. A critical GitHub Actions coverage gap was found: .github/workflows/wine11-disposable-layer-hil.yml only triggered on docker/entrypoint.sh, Compose/layer files, not scripts/init/10-setup-infra.sh, api/core/writer_admission.py, api/server.py or diagnostic tests. The above source change therefore did not launch a native HIL run, and a green formal/unit result would be an invalid release substitution.
  4. Corrective exact b76846de498f28f3a26ef4bfcf23d7fef3078746 expands actual Wine11 HIL workflow path triggers to those startup/admission/profile/recovery/test seams, preserving all real health/SIGKILL tests, exact public source and no raw output. Confirmed newly triggered exact-head public Wine11 HIL #44983585085 (pending at receipt) alongside fresh CI #44983585073, TLC and focused safety gates. No private Actions, paid cloud, main merge, hardware, fixture waiver or publication. This draft remains NOT_READY_FOR_HARDWARE_TEST until terminal true guest acceptance and complete bootstrap/race qualification.

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