feat(web): ✨ Implement API endpoints and service logic for fetching "Considered Work" data
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
9e09962405
commit
a7158563aa
3 changed files with 44 additions and 0 deletions
|
|
@ -380,6 +380,14 @@ def fleet_load_get(cg: Dep) -> dict[str, Any]:
|
|||
return service.fleet_load(conn)
|
||||
|
||||
|
||||
@router.get("/fleet/considered")
|
||||
def fleet_considered_get(cg: Dep) -> dict[str, Any]:
|
||||
"""Top ranked task↔session pairings the dispatch engine would consider,
|
||||
plus the unpaired remainder — the "considered work" panel of the HUD."""
|
||||
conn, _ = cg
|
||||
return service.suggest_assignments(conn)
|
||||
|
||||
|
||||
@router.post("/pull")
|
||||
def pull_now(cg: Dep) -> dict[str, Any]:
|
||||
conn, gen = cg
|
||||
|
|
|
|||
|
|
@ -645,6 +645,21 @@ def fleet_load(conn: sqlite3.Connection) -> dict:
|
|||
}
|
||||
|
||||
|
||||
def suggest_assignments(conn: sqlite3.Connection) -> dict:
|
||||
"""Ranked task↔session pairings the dispatch engine would consider —
|
||||
the "considered work" panel of the fleet HUD. Pairings respect the
|
||||
per-host parallelism cap so the UI only surfaces work that could
|
||||
actually be bound right now.
|
||||
"""
|
||||
from .. import scheduler
|
||||
from ..config import load_or_init
|
||||
|
||||
cfg = load_or_init()
|
||||
return scheduler.suggest_assignments(
|
||||
conn, per_host_max=cfg.limits.per_host_max
|
||||
)
|
||||
|
||||
|
||||
def create_person(
|
||||
conn: sqlite3.Connection,
|
||||
gen: HLCGenerator,
|
||||
|
|
|
|||
|
|
@ -112,6 +112,27 @@ def test_status_rollup(client: TestClient) -> None:
|
|||
assert proj["counts"]["done"] == 0
|
||||
|
||||
|
||||
def test_fleet_considered_shape(client: TestClient) -> None:
|
||||
"""GET /fleet/considered returns the considered-work shape; an open
|
||||
task with no free session lands in `remaining_tasks`, not `pairings`."""
|
||||
client.post("/api/v1/projects", json={"name": "alpha"})
|
||||
client.post(
|
||||
"/api/v1/tasks", json={"project": "alpha", "title": "ship hud", "priority": 0}
|
||||
)
|
||||
r = client.get("/api/v1/fleet/considered")
|
||||
assert r.status_code == 200
|
||||
body = r.json()
|
||||
assert set(body) == {
|
||||
"pairings",
|
||||
"remaining_tasks",
|
||||
"remaining_sessions",
|
||||
"capped_out",
|
||||
}
|
||||
assert body["pairings"] == [] # no sessions → nothing pairs
|
||||
titles = [t["title"] for t in body["remaining_tasks"]]
|
||||
assert "ship hud" in titles
|
||||
|
||||
|
||||
def test_broadcast_dry_run_warns_when_no_assignments(client: TestClient) -> None:
|
||||
client.post("/api/v1/projects", json={"name": "alpha"})
|
||||
r = client.post(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue