Overview
Thecheck-upstream-status worker finds the most recent digest page for a given agent, reads its machine-readable status line and run timestamp, and returns a structured status object. It’s used by dependent agents (like Client Health Scorecard) to check upstream data freshness and completeness.
Key features:
- Searches for most recent digest matching agent patterns
- Parses machine-readable status lines from page content
- Detects stale data based on configurable age thresholds
- Identifies degraded states (partial, failed, ERROR-titled, stale)
- Returns pre-formatted data completeness notices
Input Parameters
Name of the agent to check. Must be one of the valid agent names:
"Inbox Manager""Personal Ops Manager""GitHub Insyncerator""Client Repo Auditor""Docs Librarian""VEP Weekly Reporter""Home & Life Watcher""Template Freshness Watcher""Time Log Auditor""Client Health Scorecard""Morning Briefing"
Maximum age in hours before digest is considered stale. Default:
48If true, enforces MAX_AGE_DEFAULT (48h) regardless of max_age_hours. Default:
falseOutput Format
All outputs include these fields:Whether a digest page was found for the agent
Echo of input agent_name
Overall status. One of:
"complete"— ✅ Complete run, fresh data"partial"— ⚠️ Partial run"failed"— ❌ Failed run"full_report"— 📊 Full Report"stub"— 📝 Stub"not_found"— No digest found"stale"— Found but older than max_age_hours"unknown"— Could not parse status
Type of run from status line, or null if not found/parsed
ISO 8601 timestamp of run from digest content, or null if not found
Hours since run_time, or null if run_time not found
Whether digest is older than max_age_hours or requires current cycle
Whether digest content contains “Heartbeat: no actionable items”
Whether page title includes “ERROR”
Notion URL of found digest, or null
Notion page ID of found digest, or null
Whether upstream data is degraded. True if:
- status is “not_found”, “stale”, “partial”, or “failed”
- OR is_error_titled is true
Pre-formatted notice for inclusion in dependent digest. Empty string if not degraded.Examples:
"⚠️ Data Completeness Notice: Time Log Auditor digest not found for current cycle. Dimensions relying on this data marked 🔘 Unavailable.""⚠️ Data Completeness Notice: Docs Librarian last ran 52h ago (expected within 48h). Treating as stale.""⚠️ Data Completeness Notice: VEP Weekly Reporter last run was ⚠️ Partial / ❌ Failed. Upstream data may be incomplete.""⚠️ Data Completeness Notice: GitHub Insyncerator last digest was an ERROR run. Treating upstream data as degraded."
Usage Examples
- Check Multiple Upstreams
- Healthy Upstream
- Stale Upstream
- Not Found
Agent Digest Patterns
The worker searches for digests matching agent-specific title patterns:| Agent | Digest Title Patterns |
|---|---|
| Inbox Manager | ”Email Triage” |
| Personal Ops Manager | ”Personal Triage” |
| GitHub Insyncerator | ”GitHub Sync” |
| Client Repo Auditor | ”Client Repo Audit” |
| Docs Librarian | ”Docs Quick Scan”, “Docs Cleanup Report” |
| VEP Weekly Reporter | ”VEP Weekly Activity Report” |
| Home & Life Watcher | ”Home & Life Weekly Digest” |
| Template Freshness Watcher | ”Setup Template Freshness Report” |
| Time Log Auditor | ”Time Log Audit” |
| Client Health Scorecard | ”Client Health Scorecard” |
| Morning Briefing | ”Morning Briefing” |
Patterns are defined in
src/shared/agent-config.ts:6-18. The worker queries the target database (docs or home_docs) with OR filters for all patterns.Status Line Parsing
The worker reads the first paragraph block from the digest page and parses the machine-readable status line:[emoji] [status_type]:[status_value]
If parsing fails, status_type is null and status is "unknown".
Staleness Detection
A digest is marked stale if:require_current_cycle: trueANDrun_time_age_hours > 48, ORpage_created_age_hours > max_age_hours
status changes from parsed value to "stale".
Data Completeness Notices
The worker generates notices for four degraded states:Error Handling
The worker returns structured output even on Notion API errors:The worker NEVER throws. Always returns a structured output with
degraded: true on errors.Implementation Details
Source Files
- Worker implementation:
src/workers/check-upstream-status.ts:33-197 - Schema definition:
src/index.ts:48-63 - Type definitions:
src/shared/types.ts:69-99 - Agent patterns:
src/shared/agent-config.ts:6-32
Database Targeting
The worker automatically determines target database from agent name:home_docs: Personal Ops Manager, Home & Life Watcherdocs: All other agents
AGENT_TARGET_DB (src/shared/agent-config.ts:20-32).
Query Strategy
The worker:- Builds OR filter with all agent digest patterns
- Sorts by
created_timedescending - Fetches top 5 results
- Returns first result (most recent)
- Reads first 50 blocks to parse status line and run time
If an agent has multiple digest patterns (like Docs Librarian with “Docs Quick Scan” and “Docs Cleanup Report”), the worker returns the most recent match across all patterns.