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

+32
View File
@@ -5,6 +5,7 @@
app worker [--workers http=8,cpu=1] [--until-idle]
app companies seed|add|set-board|detach|discover|check
app searches add|list|remove
app stages [extract|summarise on|off]
app db init
`app job` queues the work on a queue of its own and drains it here, so a
@@ -109,6 +110,11 @@ def build_parser() -> argparse.ArgumentParser:
"remove", help="stop running a search and close its open roles")
search_remove.add_argument("name")
stages = sub.add_parser(
"stages", help="show whether extract and summarise run, or switch one")
stages.add_argument("name", nargs="?", choices=["extract", "summarise"])
stages.add_argument("state", nargs="?", choices=["on", "off"])
db = sub.add_parser("db", help="database housekeeping")
db.add_argument("action", choices=["init"])
return parser
@@ -129,6 +135,8 @@ def main(argv: list[str] | None = None) -> int:
return run_companies(args)
if args.command == "searches":
return run_searches(args)
if args.command == "stages":
return run_stages(args)
return init_db(args)
except (FileNotFoundError, config_mod.ConfigError) as exc:
print(exc, file=sys.stderr)
@@ -412,6 +420,30 @@ def add_search(config: config_mod.Config, store: Store, args: argparse.Namespace
return 0
def run_stages(args: argparse.Namespace) -> int:
"""`app stages` prints what `GET /api/stages` returns; `app stages extract
on` stores the switch through the function `PUT /api/stages/extract`
calls, and prints the result."""
from app import jobs
from app.storage import Store
if bool(args.name) != bool(args.state):
print("stages: give a stage and on or off, or neither", file=sys.stderr)
return 1
config = config_mod.load(args.config)
store = Store(config.database)
if args.name:
jobs.stages.set_stage(store, args.name, args.state == "on")
found = [jobs.stages.describe_one(config, store, args.name)]
else:
found = jobs.stages.describe(config, store)
for stage in found:
where = "set by the switch" if stage.source == "stored" else "config.yaml's default"
print(f"{stage.name:10} {'on ' if stage.on else 'off'} {where}; "
f"{stage.model}; {stage.answer}")
return 0
def init_db(args: argparse.Namespace) -> int:
"""Create the file, or bring it to the current schema."""
from app.storage import LATEST, Store