Skip to content

Enforce no-LLM widgets; job_runs records interrupted runs and downtime misfires - #39

Merged
ggapp1 merged 2 commits into
mainfrom
fix/widget-llm-guard-and-job-runs
Oct 29, 2026
Merged

ggapp1 merged 2 commits into
mainfrom
fix/widget-llm-guard-and-job-runs

Conversation

@ggapp1

@ggapp1 ggapp1 commented Oct 29, 2026

Copy link
Copy Markdown
Owner

The last two open items from the whole-project review.

Widgets cannot reach the model (enforced, not just claimed). Runtime bound app._llm on every app, so a widget could call app.llm() despite the positioning that the dashboard works with every tier dead. run_widget now sets the IN_WIDGET ContextVar around widget.fn() (reset via its token in a finally); App.llm() raises LLMNotAllowedInWidgetError, which names the rule and the alternative (compute in a job/tool, have the widget read the result). The error becomes the widget's error card and the provider is never called. Tasks and app.to_thread work spawned by the widget inherit the block. No suite app or example widget called the model.

job_runs no longer has gaps.

  • A run inserts a running row at start and updates it in place to its outcome (one run, one row). A job killed mid-run therefore leaves evidence.
  • At start(), before anything is scheduled, leftover running rows become interrupted. Only serve() starts the scheduler, and it does so under the exclusive data_dir/.dudamel.lock.
  • Fires missed while the process was down are recorded as one misfired row per job with the count (capped at "1000+"). The window runs from the job's latest recorded run to startup. The in-memory job store recomputes next fires from "now", so APScheduler's own EVENT_JOB_MISSED could never see these fires, and the two windows don't overlap. Cron jobs count with the zone-carrying trigger; interval jobs count whole intervals.
  • No migration: status is a free String(32), and finished_at is nullable.

Full suite: 1162 passed locally; the new scheduler/widget tests are stable across 15 consecutive runs. Known unrelated flake: test_mcp_reconnect.py fails when several pytest processes run concurrently (reported by the test-health review; tracked separately).

…s rows become interrupted, and downtime fires are recorded as misfired
@ggapp1
ggapp1 merged commit 9e8d831 into main Oct 29, 2026
6 checks passed
@ggapp1
ggapp1 deleted the fix/widget-llm-guard-and-job-runs branch October 29, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant