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
CI / tests (pull_request) Successful in 5m16s
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -6,7 +6,16 @@ import unittest
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from failure import Failure
|
||||
from chunk_driver.claims import LOCK, starting
|
||||
from chunk_driver.claims import handed, LOCK, starting
|
||||
|
||||
|
||||
class Handed(unittest.TestCase):
|
||||
def test_hands_a_window_the_setups_own_variables_and_the_two_that_move_its_folders(self) -> None:
|
||||
env = {"BUILD_RELEASE_JUDGE_MODEL": "judge", "XDG_CONFIG_HOME": "/configs", "XDG_STATE_HOME": "/state", "XDG_DATA_HOME": "/data", "PATH": "/bin"}
|
||||
self.assertEqual(handed(env), {"BUILD_RELEASE_JUDGE_MODEL": "judge", "XDG_CONFIG_HOME": "/configs", "XDG_STATE_HOME": "/state"})
|
||||
|
||||
def test_hands_no_variable_the_starter_lacks(self) -> None:
|
||||
self.assertEqual(handed({"PATH": "/bin"}), {})
|
||||
|
||||
|
||||
class Starting(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user