fix(hn-monitor): guard against cron double-post (interim for cloud#1990)

Merged
KH
6mo ago
+225-21

Why

hn-monitor posted its digest twice for one cron tick. Verified in Daytona (org Agent Relay): a single sandbox ran the runner twice ~3 min apart for one tick — the cloud re-invoked a tick delivery whose 180s processing lease expired before the first run reported delivered. With the handler's old post-before-save ordering, the re-invocation re-read stale seen and re-posted.

Full root-cause analysis and the durable, layered fix (stable per-occurrence key in relaycron → per-occurrence delivery dedup + liveness-gated retry in the delivery layer → atomic ctx.once claim enforced in the runner) are tracked in AgentWorkforce/cloud#1990.

Change

Reorder to claim-then-announce: compute the digest, record the stories as seen, then post. A re-invocation now loads them as already-seen and stays silent.

Trade-off: if the post fails after the save, that digest is dropped rather than risking a duplicate — the right call for a low-stakes twice-daily summary. This is an interim guard; it doesn't cover truly concurrent invocations. The robust fix is cloud#1990.

Typecheck passes.

🤖 Generated with Claude Code


Summary by cubic

Stops duplicate Slack posts from hn-monitor and fixes noisy PR reviewer pings by gating and deduping the “ready for your review” announcement.

  • Bug Fixes
    • hn-monitor: record stories as seen before posting to avoid double-posts from at-least-once cron re-invocation; interim guard pending AgentWorkforce/cloud#1990. If the post fails, the digest is dropped rather than risking a duplicate.
    • PR reviewer: announce “ready” once per head SHA (populate from gh pr view --json headRefOid when missing), and only when the PR is OPEN, mergeable, not DRAFT, no CHANGES_REQUESTED, and checks are complete and passing. An empty check rollup counts as ready only when mergeStateStatus is CLEAN; SKIPPED checks are non-blocking.
    • Review harness: require an “Addressed comments” section with file:line locations for each bot/reviewer comment. Stop committing Relay VFS runtime state and ignore .relay/ and memory/workspace/.relay/.