Skip to content

fix(linear): detect dead Linear grants even when no Linear events arrive - #1012

Closed
isadeks wants to merge 4 commits into
mainfrom
feat/1004-linear-grant-refresh-alert
Closed

isadeks wants to merge 4 commits into
mainfrom
feat/1004-linear-grant-refresh-alert

Conversation

@isadeks

@isadeks isadeks commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Closes #1004.

Main already alerts on a dead Linear grant (#812/#831): a rejected refresh is latched as revoked and announced once to the OperationalAlerts SNS topic. But detection only runs when a Linear event needs a token. A workspace with no traffic, or whose webhook has stopped delivering, never re-detects a dead grant, and that's how a dev workspace stayed dead for over two months unnoticed. Separately, an unused refresh token can expire on its own, because nothing refreshes it.

This PR adds a periodic grant health probe.

How it works

  • When: twice a day, on one tick of the concurrency reconciler's existing 15-minute schedule (isProbeTick). The reconciler async-invokes the Linear webhook processor with {grant_health_probe: true}, best-effort.
  • What: the processor pages the workspace registry and resolves each active workspace's token. Latched-revoked workspaces are skipped, and one failure doesn't hide the others.
    • A dead grant reuses the existing latch-and-announce path to OperationalAlerts.
    • Resolving also refreshes tokens that are about to expire, so an idle refresh token no longer expires unused.
  • Footprint: zero new CloudFormation resources. A dedicated EventBridge rule would have pushed MicroVM profiles past the 490 root-resource budget (CRITICAL: escape the CloudFormation 500-resource ceiling — best-practice strategies (8 resources of headroom on main) #852). The reconciler gets lambda:InvokeFunction on the processor only.
  • Docs: a troubleshooting entry in the Linear setup guide (the probe, the alert topic, and bgagent linear setup <slug>).

Tests

  • Tick exactness across offsets, registry pagination and failure isolation.
  • Handler routing: a mutation check fails it when the probe route is removed.
  • The invoke happens only on the probe tick, and invoke errors are swallowed.
  • Zero new resources, with the IAM grant and env present.
  • CDK 5,865 passed, census 112 pass, eslint, drift and the docs build are green. The agent and CLI are untouched.

Limits

  • The probe is sequential over active workspaces. Fine for the expected handful, slow for hundreds.
  • Not yet live-tested on a deployed stack.

…ive (#1004)

Revocation detection (#812) only runs when a Linear event needs a token, so
an idle workspace or a dead webhook never re-detects a dead grant, and an
unused refresh token simply expires: observed live, a workspace sat with an
expired refresh token for months with one ERROR log line.

- The concurrency reconciler (already every 15 min) async-invokes the
  Linear webhook processor with {grant_health_probe: true} on exactly one
  tick per 12 h (isProbeTick). Best-effort: a failed invoke never affects
  reconciliation.
- In probe mode the processor resolves a token for every active registry
  workspace. That refreshes expiring tokens (keeping idle grants alive) and
  sends a rejected grant down the existing latch-and-announce path to
  OperationalAlerts. Its summary logs any workspace without a usable token.
- Zero new CloudFormation resources (an invoke IAM statement and two env
  vars): the root stack is at its 490-resource budget in some census
  profiles, so a rule of its own did not fit.
- LINEAR_SETUP_GUIDE troubleshooting documents the probe, the alert topic
  (which ships without subscribers) and the recovery command.
@isadeks
isadeks requested review from a team and backgroundagents as code owners November 5, 2026 15:22
@isadeks

isadeks commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1067, which carries this change (its commits are kept as they were, followed by one commit that adapts the combined set to current main). Closing to keep one place for review.

@isadeks isadeks closed this Nov 25, 2026
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.

fix(observability): a dead Linear integration fails silently

1 participant