Answer stability round 1: 0 🔴, 4 🟡 (0 misread); a chunk window is handed the two XDG variables, rule-hook's checks are tested under them, and three tests stop passing the developer's
CI / tests (pull_request) Successful in 5m16s

This commit is contained in:
2026-12-03 21:30:06 +01:00
parent 173d591986
commit 9b8f9e05e7
7 changed files with 82 additions and 16 deletions
+10 -4
View File
@@ -1,6 +1,6 @@
"""How entry points claim a checkout before they start a chunk in it, so that two never start the same chunk and do-epic never starts one where build-release runs.
An entry point holds `starting` on `project_lock` while it lists the windows of the checkout's chunks and starts new ones. Where the lock cannot be taken, `starting` yields a Failure, and the entry point doesn't start any chunk. It starts each chunk in a tmux window with CHUNK_FLAG, and hands that window the variables named with HANDED.
An entry point holds `starting` on `project_lock` while it lists the windows of the checkout's chunks and starts new ones. Where the lock cannot be taken, `starting` yields a Failure, and the entry point doesn't start any chunk. It starts each chunk in a tmux window with CHUNK_FLAG, and hands that window the variables `handed` picks.
"""
import contextlib
import fcntl
@@ -8,7 +8,7 @@ import pathlib
import typing
from failure import Failure
from loop_state.paths import Paths
from loop_state.paths import Paths, XDG_CONFIG_HOME, XDG_STATE_HOME
from transcript_archive.project_key import project_key
from agent_cycle import tmux
@@ -16,8 +16,14 @@ from agent_cycle import tmux
LOCK = "starting"
# The flag that tells the entry point in a window its chunk, as `--chunk item-372` for build-release and `--chunk ABC-34 ABC-12` for do-epic. Nobody types it, so no panel picked it.
CHUNK_FLAG = "--chunk"
# The prefix of the variables both entry points read. A window gets the tmux server's environment, not the starting terminal's, so they are handed to each window by name.
HANDED = "BUILD_RELEASE_"
# The prefix of the variables both entry points read.
OWN = "BUILD_RELEASE_"
# A window gets the tmux server's environment, not the starting terminal's. Without the two XDG variables, a window would lock and write in other folders than the entry point that started it.
def handed(env: typing.Mapping[str, str]) -> dict[str, str]:
"""The variables of env that an entry point hands each window it starts: those both entry points read, and the two that move the config folder and the state folder."""
return {name: value for name, value in env.items() if name.startswith(OWN) or name in (XDG_CONFIG_HOME, XDG_STATE_HOME)}
@contextlib.contextmanager