Wire the app like the boilerplate: door, queue, schedules, eight tabs

app/main.py assembles it in the boilerplate's order, auth.connect first,
then the queue with the scheduler and the pages. TABS is Roles,
Applications, Agents, Companies, Jobs, Schedules, Messages and Account:
the alpha page's three views become templates on the boilerplate's
base.html, driven by static/roles.js (the old app.js) through api() and
toasts.js, over the unchanged JSON routes. Companies lists every board with
its open roles and the affinity control. A 422 is one sentence, so a toast
never reads [object Object].

Config takes the boilerplate's shape: APP_CONFIG or config.yaml, a missing
file is the defaults, an unknown key is an error. roles.yaml is gone;
config.yaml is the committed default and carries the starter agents.

pull is now a job that asks for the pull cascade, because a schedule
enqueues a job kind; its default schedule, every 6h, is declared beside it
in app/jobs/cascade.py. pull_batch's targets are keyword-only so the Jobs
tab offers no batch button. `app worker` is the boilerplate's; `app job`
still drains a queue of its own and fires no schedules.

test_coupling holds pipeline, auth and desk apart (desk may import
pipeline) and plugins to desk; test_architecture keeps app's layers, now
with main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-23 12:48:12 +02:00
1 parent 24508dd6fc
commit 59a301c351
42 files changed
+2407 -998

No files matched your search

+22 -7
View File
@@ -17,7 +17,7 @@ if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from desk.models import Item # noqa: E402
from pipeline import FINAL, TASKS, JobQueue, Jobs, RunContext # noqa: E402
from pipeline import FINAL, SCHEDULES, TASKS, JobQueue, Jobs, RunContext # noqa: E402
from plugins.ats import ATSSource # noqa: E402
from app.config import AgentSeed, Config # noqa: E402
from app.jobs import cascade, embed, score # noqa: E402
@@ -266,13 +266,13 @@ def test_starter_agents_are_imported_once(store: Store, tmp_path: Path) -> None:
def test_the_shipped_starter_agents_validate() -> None:
from app import config as config_mod
names = [a.name for a in config_mod.load(ROOT / "roles.yaml").agents]
names = [a.name for a in config_mod.load(ROOT / "config.yaml").agents]
assert names == ["Berlin backend", "Remote EU stretch"]
# ---------------------------------------------------------------- cascade
def test_the_pull_cascade_runs_extract_embed_then_score(
def test_the_pull_job_runs_pull_extract_embed_then_score(
store: Store, config: Config, fake: FakeEmbedder, tmp_path: Path,
monkeypatch: pytest.MonkeyPatch) -> None:
store.add_subscription("ats", "greenhouse:acme", label="Acme", company="Acme",
@@ -292,19 +292,34 @@ def test_the_pull_cascade_runs_extract_embed_then_score(
queue = JobQueue(Jobs(tmp_path / "roledesk.db"), config, store,
workers={"cpu": 1, "http": 1, "llm": 1})
task_id = queue.start_task(TASKS["pull"]())
# The `pull` job, which is what the schedule fires: its own work is to ask
# for the chain, which then runs to its end in the same drain.
started = queue.enqueue("pull")
queue.drain(timeout=60)
cascade_id = queue.jobs.of_task(task_id)[0].cascade_id
jobs = sorted(queue.jobs.of_cascade(cascade_id), key=lambda j: j.id)
assert started is not None and queue.jobs.get(started.id).state == "done" # type: ignore[union-attr]
batch = queue.jobs.last("pull_batch")
assert batch is not None
jobs = sorted(queue.jobs.of_cascade(batch.cascade_id), key=lambda j: j.id)
stages = [j.result.get("task") for j in jobs if j.kind == FINAL]
assert stages == list(cascade.CASCADES["pull"])
work = [j.kind for j in jobs if j.kind != FINAL]
assert work == ["pull_batch", "embed", "score"], "extract is off, so it finds nothing"
# The `pull` job and the chain it asked for are one cascade, so the Jobs
# tab shows a scheduled pull as one run. Extract is off and finds nothing.
assert work == ["pull", "pull_batch", "embed", "score"]
assert all(j.state == "done" for j in jobs)
assert len(store.scores(agent.id)) == 1
def test_pull_is_a_job_on_a_six_hour_schedule_and_the_stages_are_tasks() -> None:
"""A schedule enqueues a job kind, so `pull` is a job; were it a task too,
the Jobs tab would draw two `pull` buttons."""
assert "pull" not in TASKS
assert {"extract", "embed", "score"} <= set(TASKS)
assert SCHEDULES["pull"].kind == "pull"
assert SCHEDULES["pull"].cadence == "every 6h"
def test_follows_walks_the_cascade_and_stops_at_its_end() -> None:
assert cascade.follows("pull", "pull") == "extract"
assert cascade.follows("pull", "extract") == "embed"