Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(signals): log a follow-up check's scheduling, expiry and cancellation (#103691)

posthog[bot]b7b0e632b960
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 0a21571a7b87..84fd95434b09 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -10712,6 +10712,14 @@ snapshots:
hash: v1.k794b7964.3362f7e3189434319ec363172447f3fbbe529b2d745ef0ddf7f8e8c494fcd4a2.2bUlzu2lgIJbm8s_5ic3TtAcZ9hHX4_JFAE8hd9fQVk
scenes-app-sidepanels--side-panel-support--light:
hash: v1.k794b7964.deb388fad6d54211a52bf0228e80a62f18903b5a91ed77f47408f1fbb9137480.c8bN-QxTmTOSLWxd37aThlQhlWmlZ9r6N1YUBjhRsU8
+ scenes-app-signals-artefactloglist--check-lifecycle--dark:
+ hash: v1.k794b7964.15b3a8e1bcf9e0ce0d97471ae090a83dde50c6050508c449985c44e44d664a0c.qI_1YM1_36ezR-Q857TKtk3Aj9CCtgj5AUoDTPcOckE
+ scenes-app-signals-artefactloglist--check-lifecycle--light:
+ hash: v1.k794b7964.4a77f1e94db7ebab96b88c0d6ace82c3e2b6384e4185322bae79fb4011b13951.jiUoxtH_nFTRWlp7NljPTBII54Rcq7Gs5XnEsVjU1b4
+ scenes-app-signals-artefactloglist--check-lifecycle-narrow--dark:
+ hash: v1.k794b7964.4d8cc63186f867316fa053a9a1c26a29141d9a8519fc0431f9ee8f246fb87535.nM5FGnojjy0SQYBwxGuPDW_CkV-B77jh96snsiQDHrQ
+ scenes-app-signals-artefactloglist--check-lifecycle-narrow--light:
+ hash: v1.k794b7964.323182dc2e4da1cc3de88a75d4d027f1d9b561a74752a6e9efda62c307252811.Z7e7sMgVVYTvNNOumDp3_1YmGPVrwuL3MtLQZITadIQ
scenes-app-signals-artefactloglist--narrow--dark:
hash: v1.k794b7964.126364946b3e155e64e07b61da407de2075b63f5449d9b64c0c2228daa055a13.QMcKZPlik4titSS_IK7VuTRw0QAxfbl1sKiuFzmechU
scenes-app-signals-artefactloglist--narrow--light:
diff --git a/products/signals/backend/artefact_schemas.py b/products/signals/backend/artefact_schemas.py
index 69edf65c0476..4cfd971e9143 100644
--- a/products/signals/backend/artefact_schemas.py
+++ b/products/signals/backend/artefact_schemas.py
@@ -783,6 +783,63 @@ class CheckResult(BaseModel):
return v
+class CheckLifecycleEntry(BaseModel):
+ """What every entry in a check's life carries, so the three cannot drift apart.
+
+ A check soaks for days before its first run, so its verdict alone leaves the log silent over
+ the window a reader most wants explained. These types fill that silence. All are
+ system-generated: `check_result`'s writer is the executor, and the writers below are in
+ `report_check_artefacts`.
+ """
+
+ check_id: str = Field(description="UUID of the SignalReportCheck this entry describes.")
+ kind: str = Field(description="The check's kind, e.g. `metric_threshold`.")
+ title: str = Field(description="The check's title, copied so the log entry reads on its own.")
+
+
+class CheckScheduled(CheckLifecycleEntry):
+ """A check now watches this report: when it runs, what it watches, and which lane answers it."""
+
+ rationale: str = Field(default="", description="Why the author wrote the check, in their own words.")
+ next_run_at: str = Field(description="ISO 8601 date of the first run. Provisional when `arms_on_resolve`.")
+ arms_on_resolve: bool = Field(
+ description="True when the report has not resolved yet, so the clock starts at the resolve."
+ )
+ soak_minutes: int | None = Field(
+ default=None, description="How long after the resolve the first run waits. Absent on a dated check."
+ )
+ skill_name: str | None = Field(
+ default=None,
+ description="Scout skill that answers an `agent` check. Absent when it runs on the fleet's follow-up scout.",
+ )
+ runs: int = Field(default=1, description="How many runs the check was written for.")
+
+
+class CheckExpired(CheckLifecycleEntry):
+ """A check reached its horizon without deciding, the one transition nobody chose.
+
+ An absent `last_run_at` is what a reader acts on: the claim was never re-measured, so the
+ report's conclusion still stands unverified.
+ """
+
+ expired_at: str = Field(description="ISO 8601 time the sweep retired the check.")
+ last_run_at: str | None = Field(
+ default=None, description="ISO 8601 time of the last run. Absent when the check never ran at all."
+ )
+
+
+class CheckCancelled(CheckLifecycleEntry):
+ """A check was stopped before it could decide.
+
+ Kept apart from `check_scheduled` so each entry records one transition and the renderer reads
+ the type rather than a nullable field.
+ """
+
+ reason: Literal["stopped_by_person", "stopped_by_scout", "replaced_by_research"] = Field(
+ description="Which path stopped the check."
+ )
+
+
# ── Type mapping ─────────────────────────────────────────────────────────────────
# Content models that describe the report's current state (latest row of each type wins) vs
@@ -812,6 +869,9 @@ LogArtefactContent = (
| WorkRelease
| PullRequestLink
| CheckResult
+ | CheckScheduled
+ | CheckExpired
+ | CheckCancelled
| ImplementationReplacement
| ImplementationHandover
)
@@ -842,6 +902,9 @@ ARTEFACT_CONTENT_SCHEMAS: Mapping[str, type[BaseModel]] = {
"work_release": WorkRelease,
"pull_request": PullRequestLink,
"check_result": CheckResult,
+ "check_scheduled": CheckScheduled,
+ "check_expired": CheckExpired,
+ "check_cancelled": CheckCancelled,
"implementation_decision": ImplementationDecision,
"implementation_dispatch": ImplementationDispatch,
"implementation_replacement": ImplementationReplacement,
@@ -859,7 +922,10 @@ _ARTEFACT_TYPE_BY_MODEL: Mapping[type[BaseModel], str] = {model: t for t, model
# that never happened. They stay readable (and so show up in the report's artefact log) but cannot
# be created or edited directly.
# `check_result` is likewise system-generated — the check executor is its only writer; accepting it
-# through the API would let a caller fabricate a verdict for a soak that never ran.
+# through the API would let a caller fabricate a verdict for a soak that never ran. The three
+# lifecycle types around it are closed for the same reason: a fabricated `check_scheduled` claims a
+# watch nobody set up, and a fabricated `check_expired` or `check_cancelled` retires one that is
+# still running.
# `code_review` is likewise system-generated — the ReviewHog workflow is its only writer; accepting
# it through the API would let a caller fabricate review receipts for reviews that never ran.
# Replacement decisions, reservations, and outcomes authorize GitHub closures. Only the server
@@ -875,6 +941,9 @@ NON_WRITABLE_ARTEFACT_TYPES: frozenset[str] = frozenset(
"work_release",
"pull_request",
"check_result",
+ "check_scheduled",
+ "check_expired",
+ "check_cancelled",
"report_link",
"implementation_decision",
"implementation_dispatch",
diff --git a/products/signals/backend/models.py b/products/signals/backend/models.py
index 55a2ec3a6d30..30d11913999c 100644
--- a/products/signals/backend/models.py
+++ b/products/signals/backend/models.py
@@ -1111,6 +1111,9 @@ class SignalReportArtefact(UUIDModel):
WORK_RELEASE = "work_release"
PULL_REQUEST = "pull_request"
CHECK_RESULT = "check_result"
+ CHECK_SCHEDULED = "check_scheduled"
+ CHECK_EXPIRED = "check_expired"
+ CHECK_CANCELLED = "check_cancelled"
IMPLEMENTATION_DECISION = "implementation_decision"
IMPLEMENTATION_DISPATCH = "implementation_dispatch"
IMPLEMENTATION_REPLACEMENT = "implementation_replacement"
@@ -1164,6 +1167,9 @@ class SignalReportArtefact(UUIDModel):
ArtefactType.WORK_RELEASE,
ArtefactType.PULL_REQUEST,
ArtefactType.CHECK_RESULT,
+ ArtefactType.CHECK_SCHEDULED,
+ ArtefactType.CHECK_EXPIRED,
+ ArtefactType.CHECK_CANCELLED,
}
)
diff --git a/products/signals/backend/report_check_artefacts.py b/products/signals/backend/report_check_artefacts.py
new file mode 100644
index 000000000000..5d762cb8caf1
--- /dev/null
+++ b/products/signals/backend/report_check_artefacts.py
@@ -0,0 +1,114 @@
+"""The activity-log entries a `SignalReportCheck` leaves behind, other than its verdict.
+
+Every writer lives here rather than at its call site, because a lifecycle entry is written from
+four places — the shared authoring path, the expiry sweep, and the cancel paths — and they have to
+agree on what an entry says. Each is best-effort: the transition has already happened, and losing
+its log entry must not fail it.
+"""
+
+from __future__ import annotations
+
+from datetime import datetime
+from typing import Literal
+
+import structlog
+
+from products.signals.backend.artefact_attribution import ArtefactAttribution
+from products.signals.backend.artefact_schemas import CheckCancelled, CheckExpired, CheckScheduled
+from products.signals.backend.models import SignalReportArtefact, SignalReportCheck
+
+logger = structlog.get_logger(__name__)
+
+
+def _write(
+ check: SignalReportCheck,
+ content: CheckScheduled | CheckExpired | CheckCancelled,
+ attribution: ArtefactAttribution,
+) -> None:
+ try:
+ SignalReportArtefact.add_log(
+ team_id=check.team_id,
+ report_id=str(check.report_id),
+ content=content,
+ attribution=attribution,
+ )
+ except Exception:
+ logger.exception(
+ "signals.report_check.lifecycle_artefact_failed",
+ check_id=str(check.id),
+ artefact_type=type(content).__name__,
+ )
+
+
+def _skill_name(check: SignalReportCheck) -> str | None:
+ """The scout lane an `agent` check names, or null for the fleet's follow-up scout.
+
+ Read off the stored config rather than parsed, so a config that stopped validating still says
+ which lane its author chose.
+ """
+ if check.kind != SignalReportCheck.Kind.AGENT:
+ return None
+ skill_name = (check.config or {}).get("skill_name")
+ return skill_name if isinstance(skill_name, str) else None
+
+
+def write_check_scheduled(check: SignalReportCheck, attribution: ArtefactAttribution) -> None:
+ """Record that a check now watches this report.
+
+ A pending check gets this entry at creation and not a second one when the resolve arms it: the
+ transition a reader cares about is that the watch exists, and `arms_on_resolve` already says the
+ date is the resolve's to set. The live date belongs to the rail row, which reads the check.
+ """
+ _write(
+ check,
+ CheckScheduled(
+ check_id=str(check.id),
+ kind=check.kind,
+ title=check.title,
+ rationale=check.rationale,
+ next_run_at=check.next_run_at.isoformat(),
+ arms_on_resolve=check.status == SignalReportCheck.Status.PENDING,
+ soak_minutes=check.soak_minutes,
+ skill_name=_skill_name(check),
+ runs=check.runs_remaining,
+ ),
+ attribution,
+ )
+
+
+def write_check_expired(check: SignalReportCheck, expired_at: datetime) -> None:
+ """Record that a check reached its horizon without settling.
+
+ Attributed to the system, because no author chose this: the sweep retires the row when its
+ horizon passes.
+ """
+ _write(
+ check,
+ CheckExpired(
+ check_id=str(check.id),
+ kind=check.kind,
+ title=check.title,
+ expired_at=expired_at.isoformat(),
+ last_run_at=check.last_run_at.isoformat() if check.last_run_at else None,
+ ),
+ ArtefactAttribution.system(),
+ )
+
+
+def write_check_cancelled(
+ check: SignalReportCheck,
+ *,
+ reason: Literal["stopped_by_person", "stopped_by_scout", "replaced_by_research"],
+ attribution: ArtefactAttribution,
+) -> None:
+ """Record that a check was stopped before it could decide.
+
+ `reason` separates the three paths, because they mean different things to a reader: a person
+ stopped watching, a scout run retired its own check, or a re-research pass replaced the check
+ with one written against the report's new prose.
+ """
+ _write(
+ check,
+ CheckCancelled(check_id=str(check.id), kind=check.kind, title=check.title, reason=reason),
+ attribution,
+ )
diff --git a/products/signals/backend/report_check_authoring.py b/products/signals/backend/report_check_authoring.py
index 32909a970472..f1cabeda00d5 100644
--- a/products/signals/backend/report_check_authoring.py
+++ b/products/signals/backend/report_check_authoring.py
@@ -15,8 +15,10 @@ it. That makes the resolve the clock for every kind of fix.
from __future__ import annotations
import uuid
+from collections.abc import Sequence
from datetime import datetime, timedelta
from functools import partial
+from typing import Literal
from django.db import transaction
from django.utils import timezone
@@ -25,6 +27,7 @@ import structlog
from products.signals.backend.artefact_attribution import ArtefactAttribution
from products.signals.backend.models import SignalReport, SignalReportCheck
+from products.signals.backend.report_check_artefacts import write_check_cancelled, write_check_scheduled
from products.signals.backend.report_check_execution import resolve_check_query
from products.signals.backend.report_check_telemetry import capture_report_check_created
from products.signals.backend.report_checks import (
@@ -148,6 +151,9 @@ def create_check(
created_by_id=attribution.user_id,
task_id=attribution.task_id,
)
+ # In the same transaction as the row, so the log can never show a watch the report does not
+ # carry, nor carry one the log never opened.
+ write_check_scheduled(check, attribution)
# Reported from the shared write so every author is counted: the REST endpoint, the scout
# tool and the research pipeline. Post-commit, so a check the cap or a rollback rejected is
# never counted as written.
@@ -175,9 +181,17 @@ def create_checks_from_specs(
"""
if not specs:
return []
- SignalReportCheck.objects.for_team(report.team_id).filter(
+ # Only the pending rows, never a check the resolve already armed: this pass replaces prose that
+ # has not been measured against yet.
+ for replaced in SignalReportCheck.objects.for_team(report.team_id).filter(
report_id=report.id, status=SignalReportCheck.Status.PENDING
- ).update(status=SignalReportCheck.Status.CANCELLED, updated_at=timezone.now())
+ ):
+ cancel_check(
+ replaced,
+ reason="replaced_by_research",
+ attribution=attribution,
+ from_statuses=(SignalReportCheck.Status.PENDING,),
+ )
written: list[SignalReportCheck] = []
for spec in specs:
try:
@@ -203,6 +217,34 @@ def create_checks_from_specs(
return written
+def cancel_check(
+ check: SignalReportCheck,
+ *,
+ reason: Literal["stopped_by_person", "stopped_by_scout", "replaced_by_research"],
+ attribution: ArtefactAttribution,
+ from_statuses: Sequence[str] = SignalReportCheck.OPEN_STATUSES,
+) -> bool:
+ """Stop one check and log it. Returns False when the check had already finished.
+
+ One conditional update rather than a read and then a write: a verdict that lands in between
+ leaves a result artefact, and an unconditional write would overwrite the status that artefact
+ explains. The log entry follows the update rather than the intent, so a cancel that lost that
+ race records nothing, and it is built from the row as it was, so the entry names the check that
+ was stopped rather than the status it now holds.
+
+ `check` is refreshed either way, because both callers report the status back to whoever asked.
+ """
+ cancelled = (
+ SignalReportCheck.objects.for_team(check.team_id)
+ .filter(id=check.id, status__in=from_statuses)
+ .update(status=SignalReportCheck.Status.CANCELLED, updated_at=timezone.now())
+ )
+ if cancelled:
+ write_check_cancelled(check, reason=reason, attribution=attribution)
+ check.refresh_from_db()
+ return bool(cancelled)
+
+
def arm_pending_checks(*, team_id: int, report_id: str | uuid.UUID, resolved_at: datetime) -> int:
"""Start the clock on a resolved report's pending checks. Returns how many were armed.
diff --git a/products/signals/backend/report_check_execution.py b/products/signals/backend/report_check_execution.py
index 5ee00d272faf..dfcfec47cc05 100644
--- a/products/signals/backend/report_check_execution.py
+++ b/products/signals/backend/report_check_execution.py
@@ -16,7 +16,6 @@ a breach the same way and there is one place where "is this value out of bounds?
from __future__ import annotations
import time
-import uuid
from datetime import datetime, timedelta
from functools import partial
@@ -49,6 +48,7 @@ from products.signals.backend.artefact_attribution import ArtefactAttribution
from products.signals.backend.artefact_schemas import CheckResult
from products.signals.backend.enums import SignalSourceProduct, SignalSourceType
from products.signals.backend.models import SignalReport, SignalReportArtefact, SignalReportCheck
+from products.signals.backend.report_check_artefacts import write_check_expired
from products.signals.backend.report_check_telemetry import (
capture_report_check_evaluated,
capture_report_checks_expired,
@@ -422,8 +422,10 @@ def expire_overdue_checks(now: datetime) -> int:
"""
overdue = list(
- SignalReportCheck.all_teams.filter(status__in=SignalReportCheck.OPEN_STATUSES, expires_at__lte=now).values_list(
- "id", "team_id", "last_run_at"
+ # Only the columns the log entry and the telemetry read. A `metric_threshold` config carries
+ # a copied-in query, and a full tick hydrates five hundred rows.
+ SignalReportCheck.all_teams.filter(status__in=SignalReportCheck.OPEN_STATUSES, expires_at__lte=now).only(
+ "id", "team_id", "report_id", "kind", "title", "last_run_at"
)[:MAX_CHECK_EXPIRIES_PER_TICK]
)
if not overdue:
@@ -432,24 +434,49 @@ def expire_overdue_checks(now: datetime) -> int:
# which arms its pending checks and moves `expires_at` forward, and an update filtered on id and
# status alone would retire a check that has just been given a clock.
expired = SignalReportCheck.all_teams.filter(
- id__in=[check_id for check_id, _, _ in overdue],
+ id__in=[check.id for check in overdue],
status__in=SignalReportCheck.OPEN_STATUSES,
expires_at__lte=now,
).update(status=SignalReportCheck.Status.EXPIRED, updated_at=now)
if expired:
+ _log_expired_checks(overdue, now, expired)
_report_expired_checks(overdue)
return expired
-def _report_expired_checks(overdue: list[tuple[uuid.UUID, int, datetime | None]]) -> None:
+def _log_expired_checks(overdue: list[SignalReportCheck], now: datetime, expired: int) -> None:
+ """Write one `check_expired` entry per row this sweep actually retired.
+
+ Which rows those are is re-read when the write took fewer than the selection, because it skips
+ a check whose report resolved in between. Telemetry can live with counting that row; the
+ activity log cannot, because an entry saying a check retired is permanent and a reader acts on
+ it. One transaction rather than one per row, so a full tick is a single commit ahead of the
+ runs it delays.
+ """
+ retired = (
+ {check.id for check in overdue}
+ if expired == len(overdue)
+ else set(
+ SignalReportCheck.all_teams.filter(
+ id__in=[check.id for check in overdue], status=SignalReportCheck.Status.EXPIRED, updated_at=now
+ ).values_list("id", flat=True)
+ )
+ )
+ with transaction.atomic():
+ for check in overdue:
+ if check.id in retired:
+ write_check_expired(check, now)
+
+
+def _report_expired_checks(overdue: list[SignalReportCheck]) -> None:
"""Emit one expiry event per project for the rows a sweep selected.
Counted from the selection rather than the write, so a row armed in between is over-counted by
one. That is acceptable for telemetry and saves a second read of every retired row.
"""
per_team: dict[int, list[datetime | None]] = {}
- for _, team_id, last_run_at in overdue:
- per_team.setdefault(team_id, []).append(last_run_at)
+ for check in overdue:
+ per_team.setdefault(check.team_id, []).append(check.last_run_at)
try:
teams = Team.objects.filter(id__in=per_team.keys()).select_related("organization")
for team in teams:
diff --git a/products/signals/backend/scout_harness/tools/checks.py b/products/signals/backend/scout_harness/tools/checks.py
index a55ecffa0260..78ad242c465d 100644
--- a/products/signals/backend/scout_harness/tools/checks.py
+++ b/products/signals/backend/scout_harness/tools/checks.py
@@ -23,7 +23,6 @@ import uuid
from datetime import datetime
from django.db.models.functions import Coalesce
-from django.utils import timezone
from posthog.dataclasses import frozen
from posthog.models import Team
@@ -31,7 +30,7 @@ from posthog.models import Team
from products.signals.backend.artefact_attribution import ArtefactAttribution
from products.signals.backend.models import SignalReport, SignalReportCheck, SignalScoutRun
from products.signals.backend.report_check_agent import resolve_check_skill_name
-from products.signals.backend.report_check_authoring import CheckCreationError, create_check
+from products.signals.backend.report_check_authoring import CheckCreationError, cancel_check, create_check
from products.signals.backend.report_check_execution import CheckVerdict, record_check_verdict
from products.signals.backend.report_checks import AgentCheckConfig, parse_check_config
from products.signals.backend.scout_harness.tools.emit import _preflight_emit_gates, _resolve_task_id
@@ -115,7 +114,6 @@ def record_check_result(
raise InvalidCheckResultError(f"outcome must be `passed`, `failed`, or `errored`, not `{outcome}`")
check = _resolve_dispatched_check(team, run, check_id)
- task_id = _resolve_task_id(run)
record_check_verdict(
check,
CheckVerdict(
@@ -127,7 +125,7 @@ def record_check_result(
),
# Attributed to the run's task, the way every other artefact an agent writes is, so the
# report's log names what produced the verdict rather than the system that scheduled it.
- attribution=ArtefactAttribution.from_task(task_id) if task_id else ArtefactAttribution.system(),
+ attribution=_run_attribution(run),
run_id=str(run.id),
)
check.refresh_from_db()
@@ -221,7 +219,6 @@ def create_report_check(
"""
_assert_run_may_write_checks(team, run)
report = _resolve_report(team, report_id)
- task_id = _resolve_task_id(run)
try:
check = create_check(
report=report,
@@ -229,7 +226,7 @@ def create_report_check(
rationale=rationale,
kind=kind,
config=config,
- attribution=ArtefactAttribution.from_task(task_id) if task_id else ArtefactAttribution.system(),
+ attribution=_run_attribution(run),
next_run_at=next_run_at,
expires_at=expires_at,
run_interval_minutes=run_interval_minutes,
@@ -248,13 +245,14 @@ def list_report_checks(*, team: Team, report_id: str) -> list[ScoutCheckSummary]
return [_summarize(check) for check in checks[:MAX_CHECKS_LISTED]]
-def cancel_report_check(*, team: Team, run: SignalScoutRun, check_id: str) -> ScoutCheckSummary:
- """Stop a check that is no longer worth running. Its recorded results stay on the report.
+def _run_attribution(run: SignalScoutRun) -> ArtefactAttribution:
+ """Attribute a write to the run's task, the way every other scout write is attributed."""
+ task_id = _resolve_task_id(run)
+ return ArtefactAttribution.from_task(task_id) if task_id else ArtefactAttribution.system()
- One conditional update rather than a read and then a write, as the REST path does: a verdict
- that lands in between leaves a result artefact, and an unconditional write would overwrite the
- status that artefact explains.
- """
+
+def cancel_report_check(*, team: Team, run: SignalScoutRun, check_id: str) -> ScoutCheckSummary:
+ """Stop a check that is no longer worth running. Its recorded results stay on the report."""
_assert_run_may_write_checks(team, run)
try:
uuid.UUID(str(check_id))
@@ -266,12 +264,6 @@ def cancel_report_check(*, team: Team, run: SignalScoutRun, check_id: str) -> Sc
canonical_team_id = team.parent_team_id or team.id
if (check.team.parent_team_id or check.team_id) != canonical_team_id:
raise InvalidCheckWriteError(f"check {check_id} not found")
- cancelled = (
- SignalReportCheck.objects.for_team(check.team_id)
- .filter(id=check.id, status__in=SignalReportCheck.OPEN_STATUSES)
- .update(status=SignalReportCheck.Status.CANCELLED, updated_at=timezone.now())
- )
- check.refresh_from_db()
- if not cancelled:
+ if not cancel_check(check, reason="stopped_by_scout", attribution=_run_attribution(run)):
raise InvalidCheckWriteError(f"check {check_id} already finished as `{check.status}` and cannot be cancelled")
return _summarize(check)
diff --git a/products/signals/backend/test/test_report_checks.py b/products/signals/backend/test/test_report_checks.py
index 20989657c085..22a277149810 100644
--- a/products/signals/backend/test/test_report_checks.py
+++ b/products/signals/backend/test/test_report_checks.py
@@ -1,3 +1,4 @@
+import json
import time
from datetime import timedelta
@@ -34,7 +35,12 @@ from products.signals.backend.report_check_agent import (
build_check_run_note,
resolve_check_skill_name,
)
-from products.signals.backend.report_check_authoring import CheckCreationError, create_check, create_checks_from_specs
+from products.signals.backend.report_check_authoring import (
+ CheckCreationError,
+ arm_pending_checks,
+ create_check,
+ create_checks_from_specs,
+)
from products.signals.backend.report_check_execution import (
CHECK_ERROR_RETRY_AFTER,
CheckVerdict,
@@ -1491,3 +1497,149 @@ class TestResearchAuthoredChecks(APIBaseTest):
else:
with self.assertRaises(PydanticValidationError):
CheckSpec.model_validate(payload)
+
+
+class TestReportCheckLifecycleLog(APIBaseTest):
+ """The activity entries a check leaves other than its verdict.
+
+ Without them the log is silent for the whole soak window, which is the stretch a reader most
+ wants explained: a check that never ran and one that was stopped both read as "nothing
+ happened".
+ """
+
+ def setUp(self) -> None:
+ super().setUp()
+ self.report = SignalReport.objects.create(team=self.team, status=SignalReport.Status.RESOLVED, title="Fix")
+ self.url = f"/api/projects/{self.team.id}/signals/reports/{self.report.id}/checks/"
+
+ def _create(self, **overrides) -> SignalReportCheck:
+ spec: dict = {
+ "title": "Checkout errors stay low",
+ "kind": SignalReportCheck.Kind.METRIC_THRESHOLD,
+ "config": _threshold_config(),
+ "next_run_at": timezone.now() + timedelta(days=7),
+ }
+ spec.update(overrides)
+ return create_check(report=self.report, attribution=ArtefactAttribution.system(), **spec)
+
+ def _entries(self, artefact_type: str, report: SignalReport | None = None) -> list[dict]:
+ return [
+ json.loads(artefact.content)
+ for artefact in SignalReportArtefact.objects.filter(
+ report=report or self.report, type=artefact_type
+ ).order_by("created_at")
+ ]
+
+ def test_writing_a_check_opens_the_log_with_its_date_and_its_lane(self) -> None:
+ check = self._create(
+ kind=SignalReportCheck.Kind.AGENT,
+ config={"instructions": "Read the issue again.", "skill_name": "signals-scout-error-tracking"},
+ )
+
+ entries = self._entries(SignalReportArtefact.ArtefactType.CHECK_SCHEDULED)
+ assert len(entries) == 1
+ assert entries[0]["check_id"] == str(check.id)
+ assert entries[0]["title"] == "Checkout errors stay low"
+ assert entries[0]["skill_name"] == "signals-scout-error-tracking"
+ assert entries[0]["arms_on_resolve"] is False
+ assert entries[0]["next_run_at"] == check.next_run_at.isoformat()
+
+ def test_a_check_waiting_on_the_resolve_says_so_and_is_not_logged_twice_when_armed(self) -> None:
+ open_report = SignalReport.objects.create(team=self.team, status=SignalReport.Status.READY, title="Open")
+ check = create_check(
+ report=open_report,
+ title="Checkout errors stay low",
+ kind=SignalReportCheck.Kind.METRIC_THRESHOLD,
+ config=_threshold_config(),
+ soak_minutes=DEFAULT_CHECK_SOAK_HOURS * 60,
+ attribution=ArtefactAttribution.system(),
+ )
+
+ arm_pending_checks(team_id=self.team.id, report_id=open_report.id, resolved_at=timezone.now())
+
+ entries = self._entries(SignalReportArtefact.ArtefactType.CHECK_SCHEDULED, open_report)
+ check.refresh_from_db()
+ assert check.status == SignalReportCheck.Status.ACTIVE
+ assert len(entries) == 1
+ assert entries[0]["arms_on_resolve"] is True
+ assert entries[0]["soak_minutes"] == DEFAULT_CHECK_SOAK_HOURS * 60
+
+ def test_the_sweep_logs_each_check_it_retires_and_says_it_never_ran(self) -> None:
+ check = self._create()
+ SignalReportCheck.objects.for_team(self.team.id).filter(id=check.id).update(
+ expires_at=timezone.now() - timedelta(days=1)
+ )
+
+ assert expire_overdue_checks(timezone.now()) == 1
+
+ entries = self._entries(SignalReportArtefact.ArtefactType.CHECK_EXPIRED)
+ assert len(entries) == 1
+ assert entries[0]["check_id"] == str(check.id)
+ assert entries[0]["last_run_at"] is None
+
+ def test_the_sweep_logs_nothing_for_a_check_whose_report_resolved_under_it(self) -> None:
+ overdue = self._create()
+ SignalReportCheck.objects.for_team(self.team.id).filter(id=overdue.id).update(
+ expires_at=timezone.now() - timedelta(days=1)
+ )
+ armed = self._create(title="Still watched")
+
+ assert expire_overdue_checks(timezone.now()) == 1
+
+ entries = self._entries(SignalReportArtefact.ArtefactType.CHECK_EXPIRED)
+ armed.refresh_from_db()
+ assert armed.status == SignalReportCheck.Status.ACTIVE
+ assert [entry["check_id"] for entry in entries] == [str(overdue.id)]
+
+ def test_stopping_a_check_from_the_report_logs_who_stopped_it(self) -> None:
+ check = self._create()
+
+ cancelled = self.client.delete(f"{self.url}{check.id}/")
+
+ assert cancelled.status_code == status.HTTP_200_OK
+ entries = self._entries(SignalReportArtefact.ArtefactType.CHECK_CANCELLED)
+ assert len(entries) == 1
+ assert entries[0]["check_id"] == str(check.id)
+ assert entries[0]["reason"] == "stopped_by_person"
+
+ def test_a_refused_cancel_logs_nothing(self) -> None:
+ check = self._create()
+ SignalReportCheck.objects.for_team(self.team.id).filter(id=check.id).update(
+ status=SignalReportCheck.Status.PASSED
+ )
+
+ refused = self.client.delete(f"{self.url}{check.id}/")
+
+ assert refused.status_code == status.HTTP_400_BAD_REQUEST
+ assert self._entries(SignalReportArtefact.ArtefactType.CHECK_CANCELLED) == []
+
+ def test_a_re_research_pass_logs_the_pending_checks_it_replaced(self) -> None:
+ open_report = SignalReport.objects.create(team=self.team, status=SignalReport.Status.READY, title="Open")
+ replaced = create_check(
+ report=open_report,
+ title="Checkout errors stay low",
+ kind=SignalReportCheck.Kind.METRIC_THRESHOLD,
+ config=_threshold_config(),
+ soak_minutes=DEFAULT_CHECK_SOAK_HOURS * 60,
+ attribution=ArtefactAttribution.system(),
+ )
+
+ create_checks_from_specs(
+ report=open_report,
+ specs=[
+ CheckSpec.model_validate(
+ {
+ "title": "Checkout errors stay under 5 a day",
+ "rationale": "The retry fix should hold.",
+ "kind": "metric_threshold",
+ "config": {"query": _PAGEVIEWS, "comparison": {"operator": "lte", "value": 5}},
+ }
+ )
+ ],
+ attribution=ArtefactAttribution.system(),
+ )
+
+ entries = self._entries(SignalReportArtefact.ArtefactType.CHECK_CANCELLED, open_report)
+ assert len(entries) == 1
+ assert entries[0]["check_id"] == str(replaced.id)
+ assert entries[0]["reason"] == "replaced_by_research"
diff --git a/products/signals/backend/views.py b/products/signals/backend/views.py
index 8fecefd9cb98..c11beb76ef52 100644
--- a/products/signals/backend/views.py
+++ b/products/signals/backend/views.py
@@ -123,6 +123,7 @@ from products.signals.backend.pull_requests import import_report_pull_requests
from products.signals.backend.quota import self_driving_quota_enforcement_enabled, self_driving_quota_gate
from products.signals.backend.repo_corrections import sanitized_repository
from products.signals.backend.report_assignments import InvalidPullRequestUrl, ReportClaimConflict, claim_report
+from products.signals.backend.report_check_authoring import cancel_check
from products.signals.backend.report_claims import (
actor_owns_claim,
get_active_claim,
@@ -4343,16 +4344,10 @@ class SignalReportCheckViewSet(
def destroy(self, request: Request, *args, **kwargs) -> Response:
check = cast(SignalReportCheck, self.get_object())
- # One conditional update rather than a read and then a write. A run that commits its verdict
- # between the two leaves a result artefact on the report, and an unconditional write would
- # overwrite the status that artefact explains.
- cancelled = (
- SignalReportCheck.objects.for_team(self.team.id)
- .filter(id=check.id, status__in=SignalReportCheck.OPEN_STATUSES)
- .update(status=SignalReportCheck.Status.CANCELLED, updated_at=timezone.now())
+ stopped = cancel_check(
+ check, reason="stopped_by_person", attribution=resolve_request_attribution(request, self.team.id)
)
- check.refresh_from_db()
- if not cancelled:
+ if not stopped:
return Response(
{"error": f"This check already finished as '{check.status}' and cannot be cancelled."},
status=status.HTTP_400_BAD_REQUEST,
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index 9a60b32dd04c..bb7f3cee6944 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -2132,6 +2132,9 @@ export interface SignalReportStateRequestApi {
* * `work_release` - Work Release
* * `pull_request` - Pull Request
* * `check_result` - Check Result
+ * * `check_scheduled` - Check Scheduled
+ * * `check_expired` - Check Expired
+ * * `check_cancelled` - Check Cancelled
* * `implementation_decision` - Implementation Decision
* * `implementation_dispatch` - Implementation Dispatch
* * `implementation_replacement` - Implementation Replacement
@@ -2163,6 +2166,9 @@ export const SignalReportArtefactArtefactTypeEnumApi = {
WorkRelease: 'work_release',
PullRequest: 'pull_request',
CheckResult: 'check_result',
+ CheckScheduled: 'check_scheduled',
+ CheckExpired: 'check_expired',
+ CheckCancelled: 'check_cancelled',
ImplementationDecision: 'implementation_decision',
ImplementationDispatch: 'implementation_dispatch',
ImplementationReplacement: 'implementation_replacement',
diff --git a/products/signals/frontend/generated/api.ts b/products/signals/frontend/generated/api.ts
index efb63f095327..88e828f380a8 100644
--- a/products/signals/frontend/generated/api.ts
+++ b/products/signals/frontend/generated/api.ts
@@ -798,7 +798,7 @@ export const getSignalsReportArtefactsDestroyUrl = (projectId: string, reportId:
}
/**
- * Delete an artefact, addressed by id. Deleting the latest row of a status type reverts the report's canonical status to the previous version (latest-wins over what remains). `task_run` artefacts are an append-only work log and cannot be deleted. Neither can the types this API cannot write, which the pipeline owns: `check_result`, `code_review`, `implementation_decision`, `implementation_dispatch`, `implementation_handover`, `implementation_replacement`, `pull_request`, `report_link`, `summary_change`, `task_run`, `title_change`, `video_segment`, `work_claim`, `work_release`.
+ * Delete an artefact, addressed by id. Deleting the latest row of a status type reverts the report's canonical status to the previous version (latest-wins over what remains). `task_run` artefacts are an append-only work log and cannot be deleted. Neither can the types this API cannot write, which the pipeline owns: `check_cancelled`, `check_expired`, `check_result`, `check_scheduled`, `code_review`, `implementation_decision`, `implementation_dispatch`, `implementation_handover`, `implementation_replacement`, `pull_request`, `report_link`, `summary_change`, `task_run`, `title_change`, `video_segment`, `work_claim`, `work_release`.
* @summary Delete an artefact
*/
export const signalsReportArtefactsDestroy = async (
diff --git a/products/signals/frontend/inbox/components/detail/ArtefactLogList.stories.tsx b/products/signals/frontend/inbox/components/detail/ArtefactLogList.stories.tsx
index a0c84705bee0..58d8bceaaa2d 100644
--- a/products/signals/frontend/inbox/components/detail/ArtefactLogList.stories.tsx
+++ b/products/signals/frontend/inbox/components/detail/ArtefactLogList.stories.tsx
@@ -103,3 +103,89 @@ export const Narrow: Story = {
),
],
}
+
+/** A check's whole life in the log: scheduled, run, stopped, and retired without a verdict. */
+const checkLifecycleArtefacts = [
+ {
+ id: 'check-expired',
+ type: 'check_expired',
+ created_at: '2026-10-27T09:00:00Z',
+ content: {
+ check_id: 'check-c',
+ kind: 'metric_threshold',
+ title: 'Confirm the export backlog stays clear',
+ expired_at: '2026-10-27T09:00:00Z',
+ last_run_at: null,
+ },
+ },
+ {
+ id: 'check-verdict',
+ type: 'check_result',
+ created_at: '2026-09-27T09:00:00Z',
+ content: {
+ check_id: 'check-a',
+ kind: 'agent',
+ title: 'Checkout errors stay at zero after the retry fix',
+ outcome: 'failed',
+ explanation: 'New events arrive on the same stack frame, with checkout traffic unchanged.',
+ },
+ },
+ {
+ id: 'check-cancelled',
+ type: 'check_cancelled',
+ created_at: '2026-09-21T09:00:00Z',
+ content: {
+ check_id: 'check-b',
+ kind: 'metric_threshold',
+ title: 'No new reports of the export timeout',
+ reason: 'replaced_by_research',
+ },
+ },
+ {
+ id: 'check-scheduled-pending',
+ type: 'check_scheduled',
+ created_at: '2026-09-20T09:05:00Z',
+ content: {
+ check_id: 'check-b',
+ kind: 'metric_threshold',
+ title: 'No new reports of the export timeout',
+ rationale: 'The timeout should stop once the queue drains.',
+ next_run_at: '2026-09-27T09:00:00Z',
+ arms_on_resolve: true,
+ soak_minutes: 4320,
+ runs: 1,
+ },
+ },
+ {
+ id: 'check-scheduled',
+ type: 'check_scheduled',
+ created_at: '2026-09-20T09:00:00Z',
+ content: {
+ check_id: 'check-a',
+ kind: 'agent',
+ title: 'Checkout errors stay at zero after the retry fix',
+ rationale: 'Confirms no new checkout exceptions arrive after the retry fix ships.',
+ next_run_at: '2026-09-27T09:00:00Z',
+ arms_on_resolve: false,
+ skill_name: 'signals-scout-error-tracking',
+ runs: 2,
+ },
+ },
+]
+
+export const CheckLifecycle: Story = {
+ parameters: { mockDate: '2026-10-28T10:00:00Z' },
+ args: { artefacts: checkLifecycleArtefacts },
+}
+export const CheckLifecycleNarrow: Story = {
+ parameters: { mockDate: '2026-10-28T10:00:00Z' },
+ args: { artefacts: checkLifecycleArtefacts },
+ decorators: [
+ (Story) => (
+ // The rail at the width it gets next to an open side panel.
+ <div className="w-[20rem] p-5">
+ <Story />
+ </div>
+ ),
+ ],
+}
diff --git a/products/signals/frontend/inbox/components/detail/ArtefactLogList.tsx b/products/signals/frontend/inbox/components/detail/ArtefactLogList.tsx
index 2ba82a57c341..120ee3828ae1 100644
--- a/products/signals/frontend/inbox/components/detail/ArtefactLogList.tsx
+++ b/products/signals/frontend/inbox/components/detail/ArtefactLogList.tsx
@@ -44,7 +44,9 @@ import { ArtefactTaskRun } from './ArtefactTaskRun'
import {
artefactAttributionLabel,
artefactLocationLabel,
+ CheckLifecycleContent,
CheckResultContent,
+ CheckScheduledContent,
CodeReviewContent,
CodeReferenceContent,
CommitContent,
@@ -65,6 +67,7 @@ import {
TitleChangeContent,
} from './artefactTypes'
import { prActivityTitle } from './prActivityPresentation'
+import { CHECK_LIFECYCLE_ENTRIES } from './reportCheckPresentation'
/** Map a file extension to a CodeSnippet language for syntax highlighting; falls back to plain text. */
function languageFromPath(path: string | undefined): Language {
@@ -143,6 +146,9 @@ const ARTEFACT_MARKER: Record<string, ComponentType<{ className?: string }>> = {
report_link: IconListTreeConnected,
code_review: IconListCheck,
check_result: IconCalendar,
+ check_scheduled: IconCalendar,
+ check_expired: IconCalendar,
+ check_cancelled: IconCalendar,
implementation_decision: IconRefresh,
implementation_replacement: IconRefresh,
implementation_handover: IconRefresh,
@@ -354,6 +360,29 @@ function CheckResultBody({ content }: { content: CheckResultContent }): JSX.Elem
)
}
+/**
+ * The three entries that record a check's life rather than its verdict. They share a shape with
+ * `CheckResultBody`, because a reader scanning the log is following one check through four entries
+ * and a different layout per transition would hide that they are the same thing.
+ */
+function CheckLifecycleBody({
+ title,
+ rationale,
+ detail,
+}: {
+ title?: string
+ rationale?: string
+ detail: string
+}): JSX.Element {
+ return (
+ <div className="flex w-full flex-col items-start gap-1">
+ {title?.trim() ? <span className="text-xs text-default">{title}</span> : null}
+ {rationale?.trim() ? <span className="text-xs text-default">{rationale}</span> : null}
+ {detail ? <span className="text-xs text-tertiary">{detail}</span> : null}
+ </div>
+ )
+}
+
function CodeReviewBody({ content }: { content: CodeReviewContent }): JSX.Element | null {
const counts = content.counts
const reviewUrl = content.review_url || content.pr_url
@@ -475,6 +504,16 @@ function renderArtefactSummary(artefact: SignalReportArtefact): JSX.Element | nu
</LemonTag>
) : null
}
+ case 'check_scheduled':
+ case 'check_expired':
+ case 'check_cancelled': {
+ const { tag } = CHECK_LIFECYCLE_ENTRIES[artefact.type](content as CheckLifecycleContent)
+ return (
+ <LemonTag size="small" type={tag.type}>
+ {tag.label}
+ </LemonTag>
+ )
+ }
case 'implementation_decision': {
const { supersede, blocked_reason } = content as ImplementationDecisionContent
if (typeof supersede !== 'boolean') {
@@ -578,6 +617,18 @@ function renderArtefactBody({
return <CodeReviewBody content={content as CodeReviewContent} />
case 'check_result':
return <CheckResultBody content={content as CheckResultContent} />
+ case 'check_scheduled':
+ case 'check_expired':
+ case 'check_cancelled': {
+ const c = content as CheckScheduledContent
+ return (
+ <CheckLifecycleBody
+ title={c.title}
+ rationale={c.rationale}
+ detail={CHECK_LIFECYCLE_ENTRIES[artefact.type](c).detail}
+ />
+ )
+ }
case 'title_change': {
const c = content as TitleChangeContent
return <ContentChangeBody previous={c.old_title} current={c.new_title ?? ''} />
diff --git a/products/signals/frontend/inbox/components/detail/artefactTypes.ts b/products/signals/frontend/inbox/components/detail/artefactTypes.ts
index 1d6a2ebc6944..f81f66eee25c 100644
--- a/products/signals/frontend/inbox/components/detail/artefactTypes.ts
+++ b/products/signals/frontend/inbox/components/detail/artefactTypes.ts
@@ -107,6 +107,31 @@ export interface CheckResultContent {
run_id?: string | null
}
+/** What every entry in a check's life carries. Mirrors `CheckLifecycleEntry` in `artefact_schemas.py`. */
+export interface CheckLifecycleContent {
+ check_id?: string
+ kind?: string
+ title?: string
+}
+
+export interface CheckScheduledContent extends CheckLifecycleContent {
+ rationale?: string
+ next_run_at?: string
+ arms_on_resolve?: boolean
+ soak_minutes?: number | null
+ skill_name?: string | null
+ runs?: number
+}
+
+export interface CheckExpiredContent extends CheckLifecycleContent {
+ expired_at?: string
+ last_run_at?: string | null
+}
+
+export interface CheckCancelledContent extends CheckLifecycleContent {
+ reason?: 'stopped_by_person' | 'stopped_by_scout' | 'replaced_by_research'
+}
+
export interface TitleChangeContent {
old_title?: string | null
new_title: string
@@ -174,6 +199,9 @@ export const ARTEFACT_TYPE_LABELS: Record<string, string> = {
report_link: 'Report linked',
code_review: 'Code review',
check_result: 'Follow-up check',
+ check_scheduled: 'Follow-up check scheduled',
+ check_expired: 'Follow-up check expired',
+ check_cancelled: 'Follow-up check cancelled',
implementation_decision: 'Open PR assessed',
implementation_replacement: 'Replacement started',
implementation_handover: 'Replacement outcome',
diff --git a/products/signals/frontend/inbox/components/detail/reportCheckPresentation.test.ts b/products/signals/frontend/inbox/components/detail/reportCheckPresentation.test.ts
index c92bdde2d4e4..0c8bb86fbfd2 100644
--- a/products/signals/frontend/inbox/components/detail/reportCheckPresentation.test.ts
+++ b/products/signals/frontend/inbox/components/detail/reportCheckPresentation.test.ts
@@ -5,6 +5,9 @@ import type { SignalReportCheckApi } from 'products/signals/frontend/generated/a
import { SignalReportArtefact } from '../../types'
import {
buildReportCheckRows,
+ checkCancelledEntry,
+ checkExpiredEntry,
+ checkScheduledEntry,
latestCheckExplanations,
reportChecksMeta,
splitReportCheckRows,
@@ -211,4 +214,50 @@ describe('reportCheckPresentation', () => {
expect(latestCheckExplanations(artefacts)).toEqual(new Map([['a', 'newest']]))
})
})
+
+ describe('lifecycle log entries', () => {
+ it('gives a dated check its run date and the scout that answers it', () => {
+ expect(
+ checkScheduledEntry({
+ kind: 'agent',
+ next_run_at: '2026-09-27T09:00:00Z',
+ arms_on_resolve: false,
+ skill_name: 'signals-scout-error-tracking',
+ runs: 2,
+ })
+ ).toEqual({
+ tag: { label: 'Runs Sep 27', type: 'primary' },
+ detail: 'Error tracking scout runs it · 2 runs',
+ })
+ })
+
+ it('says a check on an unresolved report waits for the resolve rather than naming a date it cannot keep', () => {
+ expect(
+ checkScheduledEntry({
+ kind: 'metric_threshold',
+ next_run_at: '2026-09-27T09:00:00Z',
+ arms_on_resolve: true,
+ soak_minutes: 4320,
+ })
+ ).toEqual({
+ tag: { label: 'Waiting for resolve', type: 'muted' },
+ detail: 'Starts 3 days after this report is resolved',
+ })
+ })
+
+ it('separates a check that never ran from one that ran and never settled', () => {
+ expect(checkExpiredEntry({}).tag.label).toEqual('Never ran')
+ expect(checkExpiredEntry({ last_run_at: '2026-09-20T09:00:00Z' })).toEqual({
+ tag: { label: 'Expired', type: 'muted' },
+ detail: 'Last ran Sep 20 · retired at its horizon before it settled',
+ })
+ })
+
+ it('names which path stopped a check, and falls back when the reason is unknown', () => {
+ expect(checkCancelledEntry({ reason: 'replaced_by_research' }).detail).toEqual(
+ 'Replaced when research re-ran on this report and wrote a new check'
+ )
+ expect(checkCancelledEntry({}).detail).toEqual('Stopped before it could settle')
+ })
+ })
})
diff --git a/products/signals/frontend/inbox/components/detail/reportCheckPresentation.ts b/products/signals/frontend/inbox/components/detail/reportCheckPresentation.ts
index a872ef6ab3ac..1c129523d66c 100644
--- a/products/signals/frontend/inbox/components/detail/reportCheckPresentation.ts
+++ b/products/signals/frontend/inbox/components/detail/reportCheckPresentation.ts
@@ -6,7 +6,13 @@ import type { SignalReportCheckApi } from 'products/signals/frontend/generated/a
import { SignalReportArtefact } from '../../types'
import { prettifyScoutSkillName } from '../../utils/scoutRunsWindow'
-import { CheckResultContent } from './artefactTypes'
+import type {
+ CheckCancelledContent,
+ CheckExpiredContent,
+ CheckLifecycleContent,
+ CheckResultContent,
+ CheckScheduledContent,
+} from './artefactTypes'
/** Rows past this many collapse the ones that only record how a check ended. */
const REPORT_CHECK_ROWS_BEFORE_COLLAPSE = 4
@@ -39,14 +45,25 @@ function soakLabel(minutes: number): string {
}
/** Which scout answers an `agent` check. A `metric_threshold` check has no lane: the coordinator measures it. */
-function laneLabel(check: SignalReportCheckApi): string | null {
- if (check.kind !== 'agent') {
+function scoutLaneLabel(kind: string | undefined, skillName: string | null | undefined): string | null {
+ if (kind !== 'agent') {
return null
}
- const skillName = 'skill_name' in check.config ? check.config.skill_name : null
return skillName ? prettifyScoutSkillName(skillName) : FALLBACK_LANE_LABEL
}
+/** The lane as a clause: "Error tracking scout runs it", or "The follow-up scout runs it". */
+function laneRunsIt(kind: string | undefined, skillName: string | null | undefined): string | null {
+ if (kind !== 'agent') {
+ return null
+ }
+ return skillName ? `${prettifyScoutSkillName(skillName)} scout runs it` : `${FALLBACK_LANE_LABEL} runs it`
+}
+
+function laneLabel(check: SignalReportCheckApi): string | null {
+ return scoutLaneLabel(check.kind, 'skill_name' in check.config ? check.config.skill_name : null)
+}
+
function shortDate(value: string): string {
return dayjs(value).format('MMM D')
}
@@ -226,3 +243,73 @@ export function reportChecksMeta(checks: SignalReportCheckApi[]): string {
}
return `${checks.length} · all done`
}
+
+// ── Lifecycle log entries ────────────────────────────────────────────────────────────────────
+
+/** How a check's activity entry reads: the tag beside its header, and the line under its title. */
+export interface CheckLifecycleEntry {
+ tag: { label: string; type: LemonTagType }
+ detail: string
+}
+
+const CHECK_CANCELLED_REASONS: Record<string, string> = {
+ stopped_by_person: 'Stopped from the report before it could settle',
+ stopped_by_scout: 'A scout run stopped it before it could settle',
+ replaced_by_research: 'Replaced when research re-ran on this report and wrote a new check',
+}
+
+/**
+ * The entry written when a check is attached. A check on an open report has no date to give yet,
+ * so it says what starts the clock instead of naming a day it cannot keep.
+ */
+export function checkScheduledEntry(content: CheckScheduledContent): CheckLifecycleEntry {
+ const lane = laneRunsIt(content.kind, content.skill_name)
+ const runs = content.runs && content.runs > 1 ? `${content.runs} runs` : null
+
+ if (content.arms_on_resolve) {
+ const start = content.soak_minutes
+ ? `Starts ${soakLabel(content.soak_minutes)} after this report is resolved`
+ : 'Starts when this report is resolved'
+ return {
+ tag: { label: 'Waiting for resolve', type: 'muted' },
+ detail: joinDetail([start, lane, runs]),
+ }
+ }
+
+ return {
+ tag: {
+ label: content.next_run_at ? `Runs ${shortDate(content.next_run_at)}` : 'Scheduled',
+ type: 'primary',
+ },
+ detail: joinDetail([lane ?? 'The coordinator measures it', runs]),
+ }
+}
+
+/** The entry written when the sweep retires a check at its horizon. */
+export function checkExpiredEntry(content: CheckExpiredContent): CheckLifecycleEntry {
+ if (!content.last_run_at) {
+ return {
+ tag: { label: 'Never ran', type: 'muted' },
+ detail: 'Retired at its horizon without running, so this claim was never re-measured',
+ }
+ }
+ return {
+ tag: { label: 'Expired', type: 'muted' },
+ detail: `Last ran ${shortDate(content.last_run_at)} · retired at its horizon before it settled`,
+ }
+}
+
+/** The entry written when a person, a scout run, or a re-research pass stops a check. */
+export function checkCancelledEntry(content: CheckCancelledContent): CheckLifecycleEntry {
+ return {
+ tag: { label: 'Cancelled', type: 'muted' },
+ detail: CHECK_CANCELLED_REASONS[content.reason ?? ''] ?? 'Stopped before it could settle',
+ }
+}
+
+/** Which builder reads each lifecycle entry, so the renderer needs one arm rather than three. */
+export const CHECK_LIFECYCLE_ENTRIES: Record<string, (content: CheckLifecycleContent) => CheckLifecycleEntry> = {
+ check_scheduled: checkScheduledEntry,
+ check_expired: checkExpiredEntry,
+ check_cancelled: checkCancelledEntry,
+}
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index cf5b8dafa74e..3e60b834d605 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -63194,6 +63194,9 @@ export namespace Schemas {
* * `work_release` - Work Release
* * `pull_request` - Pull Request
* * `check_result` - Check Result
+ * * `check_scheduled` - Check Scheduled
+ * * `check_expired` - Check Expired
+ * * `check_cancelled` - Check Cancelled
* * `implementation_decision` - Implementation Decision
* * `implementation_dispatch` - Implementation Dispatch
* * `implementation_replacement` - Implementation Replacement
@@ -63225,6 +63228,9 @@ export namespace Schemas {
WorkRelease: 'work_release',
PullRequest: 'pull_request',
CheckResult: 'check_result',
+ CheckScheduled: 'check_scheduled',
+ CheckExpired: 'check_expired',
+ CheckCancelled: 'check_cancelled',
ImplementationDecision: 'implementation_decision',
ImplementationDispatch: 'implementation_dispatch',
ImplementationReplacement: 'implementation_replacement',
diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.ts
index 4c00e188c120..c8330b473ccf 100644
--- a/services/mcp/src/generated/signals/api.ts
+++ b/services/mcp/src/generated/signals/api.ts
@@ -435,7 +435,7 @@ export const SignalsReportArtefactsPartialUpdateBody = () => zod
)
/**
- * Delete an artefact, addressed by id. Deleting the latest row of a status type reverts the report's canonical status to the previous version (latest-wins over what remains). `task_run` artefacts are an append-only work log and cannot be deleted. Neither can the types this API cannot write, which the pipeline owns: `check_result`, `code_review`, `implementation_decision`, `implementation_dispatch`, `implementation_handover`, `implementation_replacement`, `pull_request`, `report_link`, `summary_change`, `task_run`, `title_change`, `video_segment`, `work_claim`, `work_release`.
+ * Delete an artefact, addressed by id. Deleting the latest row of a status type reverts the report's canonical status to the previous version (latest-wins over what remains). `task_run` artefacts are an append-only work log and cannot be deleted. Neither can the types this API cannot write, which the pipeline owns: `check_cancelled`, `check_expired`, `check_result`, `check_scheduled`, `code_review`, `implementation_decision`, `implementation_dispatch`, `implementation_handover`, `implementation_replacement`, `pull_request`, `report_link`, `summary_change`, `task_run`, `title_change`, `video_segment`, `work_claim`, `work_release`.
* @summary Delete an artefact
*/
export const SignalsReportArtefactsDestroyParams = () => zod.object({