Answer architecture round 1: 3 🔴, 4 🟡; hand interrupts the rungs, derive the rung rule once, and give each rung one spelling
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
"""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:`."""
|
||||
"""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
|
||||
@@ -9,19 +11,14 @@ 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 has no rung to hand."""
|
||||
return ({PROJECT_RUNG: encoded(project)} if project else {}) | {WORKER_RUNG: encoded(worker)}
|
||||
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 decoded(environ.get(PROJECT_RUNG)), decoded(environ.get(WORKER_RUNG))
|
||||
return on_the_ladder(environ.get(PROJECT_RUNG)), on_the_ladder(environ.get(WORKER_RUNG))
|
||||
|
||||
|
||||
def encoded(rung: Rung) -> str:
|
||||
return f"{rung.model} {rung.effort}"
|
||||
|
||||
|
||||
def decoded(value: str | None) -> Rung | None:
|
||||
model, _, effort = (value or "").partition(" ")
|
||||
rung = Rung(model, effort)
|
||||
def on_the_ladder(value: str | None) -> Rung | None:
|
||||
rung = Rung.parse(value or "")
|
||||
return rung if rung in LADDER else None
|
||||
|
||||
Reference in New Issue
Block a user