Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/wine11-experiment-source-retry-rdte.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Wine11 inherited trace-path startup recovery controls
on:
push:
branches:
- rdte/wine11-experiment-source-retry-r1-20261123
paths:
- docker/entrypoint.sh
- scripts/init/30-start-services.sh
- scripts/init/winepath-with-retry.sh
- tests/test_winepath_startup_retry.py
- .github/workflows/wine11-experiment-source-retry-rdte.yml
workflow_dispatch:
permissions:
contents: read
concurrency:
group: wine11-experiment-source-retry-r1
cancel-in-progress: false
jobs:
offline-accepted-main-retry-contract:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
- name: Validate shell syntax and known-stage retry wiring
run: |
set -euo pipefail
bash -n docker/entrypoint.sh scripts/init/30-start-services.sh scripts/init/winepath-with-retry.sh
grep -Fq 'WINEBOT_STARTUP_ERROR stage=' docker/entrypoint.sh
grep -Fq 'WINEBOT_STARTUP_STAGE="services/trace-log-path"' scripts/init/30-start-services.sh
grep -Fq 'WINEBOT_STARTUP_STAGE="services/trace-script-path"' scripts/init/30-start-services.sh
grep -Fq '/scripts/init/winepath-with-retry.sh' scripts/init/30-start-services.sh
echo 'PASS: wine11_experiment_startup_wiring'
- name: Execute original fail-closed bounded retry suite
run: |
set -euo pipefail
python3 -m venv "$RUNNER_TEMP/wine11-venv"
"$RUNNER_TEMP/wine11-venv/bin/pip" install --disable-pip-version-check 'pytest==9.0.3'
"$RUNNER_TEMP/wine11-venv/bin/python" -m pytest -q tests/test_winepath_startup_retry.py
echo 'PASS: synthetic_trace_path_retry_controls'
- name: Scope
if: always()
run: echo 'Accepted-main source retry borrowed byte-exact; isolated fixture, no private artifacts, raw logs, policy bypass, production release or private Actions spend.'
3 changes: 3 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ if [ "$(id -u)" = "0" ]; then
fi

# --- USER CONTEXT (winebot) ---
# Accepted-main-style fixed-code startup failure classification; no values/secrets.
WINEBOT_STARTUP_STAGE="configuration"
trap 'startup_rc=$?; if [ "$startup_rc" -ne 0 ]; then printf "WINEBOT_STARTUP_ERROR stage=%s rc=%s\\n" "$WINEBOT_STARTUP_STAGE" "$startup_rc" >&2; fi' EXIT
write_instance_state() {
local state="$1"
local reason="${2:-}"
Expand Down
8 changes: 6 additions & 2 deletions scripts/init/30-start-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@

echo "--> Pass 4: Service Startup (WINEBOT_INPUT_TRACE_WINDOWS=${WINEBOT_INPUT_TRACE_WINDOWS:-unset})"

WINEBOT_STARTUP_STAGE="services/input-trace"
# Post-Init Tracing (Ensures wineserver is stable)
if [ "${WINEBOT_INPUT_TRACE_WINDOWS:-0}" = "1" ]; then
echo "--> Post-Init Tracing: AHK hook enabled."
sleep 2
WIN_TRACE_MS="${WINEBOT_INPUT_TRACE_WINDOWS_SAMPLE_MS:-5}"
mkdir -p "$SESSION_DIR/logs"
WINE_LOG_PATH=$(winepath -w "$SESSION_DIR/logs/input_events_windows.jsonl")
WINE_SCRIPT_PATH=$(winepath -w /automation/core/input_trace_windows.ahk)
WINEBOT_STARTUP_STAGE="services/trace-log-path"
WINE_LOG_PATH="$(/scripts/init/winepath-with-retry.sh "$SESSION_DIR/logs/input_events_windows.jsonl")"
WINEBOT_STARTUP_STAGE="services/trace-script-path"
WINE_SCRIPT_PATH="$(/scripts/init/winepath-with-retry.sh /automation/core/input_trace_windows.ahk)"
WINEBOT_STARTUP_STAGE="services/trace-launch"
echo "--> Starting Windows Input Trace..."
(
TRACE_RESTART_WINDOW="${WINEBOT_TRACE_RESTART_WINDOW_SECONDS:-120}"
Expand Down
19 changes: 19 additions & 0 deletions scripts/init/winepath-with-retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Convert one Linux path for Wine input tracing, retrying transient Wine startup.
# No fallback path and no sensitive Wine stderr are admitted to caller logs.
set -euo pipefail
if [ "$#" -ne 1 ] || [ -z "$1" ]; then
exit 2
fi
for attempt in 1 2 3 4; do
translated=""
if translated="$(timeout 8s winepath -w "$1" 2>/dev/null)" &&
[ -n "$translated" ] &&
[[ "$translated" != *$'\n'* ]] &&
[[ "$translated" != *$'\r'* ]]; then
printf '%s\n' "$translated"
exit 0
fi
if [ "$attempt" -lt 4 ]; then sleep 1; fi
done
exit 1
75 changes: 75 additions & 0 deletions tests/test_winepath_startup_retry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""Fail-closed Wine trace-path retries without native Wine or private fixtures."""

import os
import subprocess
from pathlib import Path

import pytest

SCRIPT = Path("scripts/init/winepath-with-retry.sh")


@pytest.mark.parametrize(
("mode", "expected_rc", "expected_count"),
[("recover", 0, 3), ("fail", 1, 4), ("multiline", 1, 4)],
)
def test_bounded_trace_path_retry(
tmp_path: Path, mode: str, expected_rc: int, expected_count: int
) -> None:
tool = tmp_path / "winepath"
tool.write_text(
"#!/bin/sh\n"
"set -eu\n"
'count="$(cat "$WINEPATH_COUNTER" 2>/dev/null || printf 0)"\n'
'count=$((count + 1))\n'
'printf "%s" "$count" > "$WINEPATH_COUNTER"\n'
'if [ "$WINEPATH_MODE" = recover ] && [ "$count" -ge 3 ]; then\n'
" printf 'Z:\\\\trace.jsonl\\n'\n"
" exit 0\n"
"fi\n"
'if [ "$WINEPATH_MODE" = multiline ]; then\n'
" printf 'Z:\\\\trace.jsonl\\nSYNTHETIC_PRIVATE_MARKER\\n'\n"
" exit 0\n"
"fi\n"
"echo SYNTHETIC_PRIVATE_MARKER >&2\n"
"exit 1\n",
encoding="utf-8",
)
tool.chmod(0o755)
sleep = tmp_path / "sleep"
sleep.write_text("#!/bin/sh\nexit 0\n", encoding="utf-8")
sleep.chmod(0o755)
counter = tmp_path / "counter"
env = os.environ.copy()
env.update(
PATH=f"{tmp_path}:{env['PATH']}",
WINEPATH_COUNTER=str(counter),
WINEPATH_MODE=mode,
)
result = subprocess.run(
["bash", str(SCRIPT), "/synthetic/trace.jsonl"],
env=env,
capture_output=True,
text=True,
timeout=45,
check=False,
)
assert result.returncode == expected_rc
assert int(counter.read_text(encoding="utf-8")) == expected_count
assert "SYNTHETIC_PRIVATE_MARKER" not in result.stdout + result.stderr
if expected_rc == 0:
assert result.stdout == "Z:\\trace.jsonl\n"
else:
assert not result.stdout


def test_no_input_rejected_without_wine_process() -> None:
result = subprocess.run(
["bash", str(SCRIPT)],
capture_output=True,
text=True,
timeout=5,
check=False,
)
assert result.returncode == 2
assert result.stdout == ""
Loading