Switch the extract and summarise stages on the page, over config.yaml

A stored `stage:extract` / `stage:summarise` in the state table overrides
extract.enabled / summarise.enabled; with none, the file applies. One
function, stages.stage_on, decides, and both tasks' finders ask it.
GET/PUT /api/stages and `app stages` show and set it with who would answer;
Runs has a "What the model reads" block, and a search agent's card says when
a stage is off and links to the switch.

Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Sonnet committed 2026-09-29 15:54:53 +02:00
1 parent a629eda8de
commit 471ace703c
15 files changed
+593 -23

No files matched your search

+19 -4
View File
@@ -19,7 +19,8 @@ fills columns that are still empty: a board's structured field wins over what
a model read out of the prose. See `Store.set_extracted`.
Off by default (`extract.enabled: false`), because on the API backend every
batch is a paid call.
batch is a paid call. Whether it runs is `stages.stage_on`: the switch under
Runs, else the config file.
"""
from __future__ import annotations
@@ -35,6 +36,7 @@ from desk import modeltask
from desk.modeltask import ModelTask
from pipeline import NULL, RunContext, Task, job
from app.config import Config
from app.jobs import stages
from app.models import PERMITS, REMOTE, SENIORITIES, ExtractResult, Role
from app.storage import Store
@@ -234,7 +236,20 @@ def run_batch(config: Config, store: Store, *, context: RunContext = NULL,
return modeltask.one(TASK, config, store, uids or [], context=context).model_dump()
def _always(config: Config) -> Any:
"""The settings with the file's flag out of the way: `batches` reads
`enabled` off them, and the switch is `stages.stage_on`, which needs the
store that `settings` is not given."""
return config.extract.model_copy(update={"enabled": True})
def extract_task() -> Task:
"""Finds nothing while `extract.enabled` is false, so the task, the
button and the cascade stage are all no-ops with the switch off."""
return replace(modeltask.of(TASK), label=TASK.label)
"""Finds nothing while the stage is off (`stages.stage_on`), so the task,
the button and the cascade stage are all no-ops with the switch off."""
stage = modeltask.of(replace(TASK, settings=_always))
find = stage.finder
def when_on(config: Config, store: Store) -> Any:
return find(config, store) if stages.stage_on(config, store, "extract") else []
return replace(stage, finder=when_on)