25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
"""The rungs loop-claude hands a worker's claude in its environment, so rule-hook holds each review launch to them: docs/decisions.md → `routing:`.
|
|
|
|
loop-claude sets these variables for its worker and for the claude an interrupt resumes; a human's shell does not, and rule-hook then checks no review launch."""
|
|
import typing
|
|
|
|
from model_routing.ladder import LADDER, Rung
|
|
|
|
PROJECT_RUNG = "LOOP_CLAUDE_PROJECT_RUNG"
|
|
WORKER_RUNG = "LOOP_CLAUDE_WORKER_RUNG"
|
|
|
|
|
|
def environment(project: Rung | None, worker: Rung) -> dict[str, str]:
|
|
"""The variables a worker's claude starts with. A project off the ladder gets an empty rung, so none is inherited from the environment."""
|
|
return {PROJECT_RUNG: str(project) if project else "", WORKER_RUNG: str(worker)}
|
|
|
|
|
|
def handed(environ: typing.Mapping[str, str]) -> tuple[Rung | None, Rung | None]:
|
|
"""The project's and the worker's rungs, each None when unset or not on the ladder."""
|
|
return on_the_ladder(environ.get(PROJECT_RUNG)), on_the_ladder(environ.get(WORKER_RUNG))
|
|
|
|
|
|
def on_the_ladder(value: str | None) -> Rung | None:
|
|
rung = Rung.parse(value or "")
|
|
return rung if rung in LADDER else None
|