Add fi_brief_status resolver for Freedom Intelligence daily briefs.
Mirror binky_rhythm daily due-checks against fi_daily_brief progress events so activity-core can schedule freedom-intelligence research without executing it.
This commit is contained in:
parent
9a4f6a4d75
commit
70a7db500d
2 changed files with 126 additions and 0 deletions
|
|
@ -19,6 +19,8 @@ Supported queries:
|
|||
- legacy_meter_weekly_review: GET {STATE_HUB_URL}/legacy-meter/weekly-review
|
||||
- binky_rhythm_status: due-items for the Binky operating-rhythm definitions,
|
||||
derived from /progress/ events (see _binky_rhythm_status)
|
||||
- fi_brief_status: due-item for Freedom Intelligence daily research brief,
|
||||
derived from fi_daily_brief progress events
|
||||
|
||||
When STATE_HUB_URL points at the state-hub edge relay, allowlisted GET reads may
|
||||
be served from a stale local cache during upstream outages (`X-StateHub-Edge-Cache:
|
||||
|
|
@ -158,6 +160,8 @@ class StateHubContextResolver(ContextResolver):
|
|||
return _legacy_meter_weekly_review(params)
|
||||
if query == "binky_rhythm_status":
|
||||
return _binky_rhythm_status(params)
|
||||
if query == "fi_brief_status":
|
||||
return _fi_brief_status(params)
|
||||
return {}
|
||||
|
||||
|
||||
|
|
@ -470,6 +474,55 @@ def _binky_progress_events(event_type: str, repo: str) -> list[dict[str, Any]]:
|
|||
return matched
|
||||
|
||||
|
||||
_FI_BRIEF_EVENT_TYPE = "fi_daily_brief"
|
||||
_FI_BRIEF_DEFAULT_REPO = "freedom-intelligence"
|
||||
|
||||
|
||||
def _fi_brief_status(params: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Due-item for Freedom Intelligence daily research brief.
|
||||
|
||||
Params: repo (default "freedom-intelligence"), timezone (IANA name,
|
||||
default Europe/Berlin — "today" is evaluated in this zone).
|
||||
|
||||
due is true when no progress event with event_type=fi_daily_brief and
|
||||
detail.repo matching the target repo exists for today. Executing sessions
|
||||
must post that event on completion (see freedom-intelligence
|
||||
docs/daily-brief-playbook.md).
|
||||
"""
|
||||
repo = str(params.get("repo") or _FI_BRIEF_DEFAULT_REPO)
|
||||
kind = str(params.get("kind") or "daily_brief")
|
||||
if kind != "daily_brief":
|
||||
return {"items": [], "repo": repo, "error": f"unknown kind: {kind}"}
|
||||
|
||||
tz = _binky_timezone(params.get("timezone"))
|
||||
now_local = _utc_now().astimezone(tz)
|
||||
today = now_local.date()
|
||||
|
||||
events = _binky_progress_events(_FI_BRIEF_EVENT_TYPE, repo)
|
||||
timestamps = [
|
||||
ts
|
||||
for ts in (
|
||||
_parse_progress_timestamp(item.get("created_at")) for item in events
|
||||
)
|
||||
if ts > datetime.min.replace(tzinfo=timezone.utc)
|
||||
]
|
||||
last_run = max(timestamps, default=None)
|
||||
due = last_run is None or last_run.astimezone(tz).date() != today
|
||||
|
||||
return {
|
||||
"items": [
|
||||
{
|
||||
"kind": kind,
|
||||
"due": due,
|
||||
"date": today.isoformat(),
|
||||
"last_run_at": last_run.isoformat() if last_run else None,
|
||||
}
|
||||
],
|
||||
"repo": repo,
|
||||
"generated_at": _utc_now().isoformat(),
|
||||
}
|
||||
|
||||
|
||||
def _repo_sbom_status(params: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Resolve SBOM staleness against the State Hub.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue