Skip to content

fix(router): consolidate PM-ack dispatch via manifest registry (Linear coverage)#1223

Merged
zbigniewsobiecki merged 2 commits intodevfrom
fix/pm-ack-coverage
Apr 29, 2026
Merged

fix(router): consolidate PM-ack dispatch via manifest registry (Linear coverage)#1223
zbigniewsobiecki merged 2 commits intodevfrom
fix/pm-ack-coverage

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

  • Plan 017/1 of spec 017 (router-side silent-failure hardening). Closes failure mode A from the 2026-04-29 log audit.
  • 24 silent skips/day on cascade-router (Unknown PM type for PM-focused agent ack, skipping) caused by parallel-path drift between two near-identical PM-ack helpers — one had the linear branch, one didn't. PM-focused agents on Linear-based projects (ucho) never saw the "🔧 On it" comment that Trello/JIRA-based projects got.
  • Three changes: (1) new consolidated helper dispatchPMAck at src/router/pm-ack-dispatch.ts indexes the manifest registry (no per-PM-type literal branching anywhere on the dispatch surface); (2) both legacy call sites (postPMAck in github router adapter, postPMAckComment in shared triggers) delegate; (3) the unknown-PM-type branch escalates from silent WARN to ERROR + Sentry capture under stable tag pm_ack_unknown_pm_type.

Regression nets

  • Per-provider conformance assertion added to the existing PM manifest harness — adding a future provider whose platformClientFactory is misconfigured fails CI with a precise per-provider message.
  • Static guard at tests/unit/router/pm-ack-dispatch.test.ts reads each of the three call sites' source and asserts no pmType === '<literal>' branching ever re-enters the dispatch surface. Modeled on trigger-event-consistency.test.ts.

Test plan

  • +6 tests on dispatchPMAck (Trello/JIRA/Linear happy paths, null-from-postComment, unknown-pmType Sentry path, undefined-pmType same).
  • +4 tests on postPMAckComment delegation contract preservation.
  • +1 per-provider assertion in pm-conformance.test.ts (runs for every registered manifest via describe.each).
  • +1 Linear regression pin on GitHubRouterAdapter.postAck's public surface.
  • Two existing github adapter tests migrated from mocking postTrelloAck (the now-obsolete dependency) to mocking dispatchPMAck.
  • npm test (full unit suite): 472 files / 8668 tests passing (+19 from baseline).
  • npm run typecheck clean.
  • npm run lint clean.
  • Pre-push lefthook (unit + integration) passed.
  • Post-deploy: 24h log volume of Unknown PM type for PM-focused agent ack, skipping on cascade-router drops to 0 under normal operation; new ERROR-tagged Sentry events represent real configuration errors.

🤖 Generated with Claude Code

zbigniewsobiecki and others added 2 commits April 29, 2026 10:34
…re Linear coverage

Plan 017/1 (pm-ack-coverage). Closes failure mode A from spec 017's 24h log
audit on 2026-04-29: PM-focused agents (e.g. backlog-manager) triggered from
a GitHub webhook against Linear-based projects silently skipped their PM-side
ack. The router-adapter's local `postPMAck` helper had `if (pmType === 'trello')`
/ `if (pmType === 'jira')` literal branches but no Linear case, so control fell
through to `WARN: Unknown PM type for PM-focused agent ack, skipping` — 24×
per day on prod cascade-router, all from `ucho`. A near-identical helper at
`src/triggers/shared/pm-ack.ts:postPMAckComment` had the Linear branch, so
this was pure parallel-path drift between two helpers that should have been
one (same shape as PR #1220).

Three changes:

1. New consolidated helper `dispatchPMAck` at `src/router/pm-ack-dispatch.ts`.
   Indexes the manifest registry directly via
   `getPMProvider(pmType).platformClientFactory(projectId).postComment(...)`.
   Zero per-PM-type literal branching anywhere on the dispatch surface.
   Adding a future PM provider lands the dispatch path for free.

2. Both legacy call sites delegate:
   - `src/router/adapters/github.ts:postPMAck` (the buggy one)
   - `src/triggers/shared/pm-ack.ts:postPMAckComment` (had Linear; preserves
     the existing `string | null` return contract via String() normalization)

3. The "Unknown PM type" branch converts from silent WARN+skip to ERROR-level
   log + Sentry capture under stable tag `pm_ack_unknown_pm_type`. Mirrors
   the spec-015 `wedged_lock_canary` precedent. Once the consolidation ships,
   hitting that branch represents a real configuration error (project pinned
   to a deleted provider), not steady-state noise.

Regression nets:

- Per-provider conformance assertion: the existing PM manifest harness gains
  one new `it()` inside its `describe.each` block —
  `dispatchPMAck reaches this provider without throwing`. Adding a future
  provider whose `platformClientFactory` is misconfigured fails CI loudly.

- Static guard against future literal-branching drift:
  `tests/unit/router/pm-ack-dispatch.test.ts` reads each of the three call
  sites' source and asserts no `pmType === 'trello' | 'jira' | 'linear'`
  patterns appear within their bodies. Modeled on
  `trigger-event-consistency.test.ts`. A future maintainer who hand-codes a
  branch fails this guard with a precise file:line citation.

Test coverage: +6 tests on `dispatchPMAck` (Trello/JIRA/Linear happy paths,
null-from-postComment, unknown-pmType Sentry path, undefined-pmType same),
+4 on `postPMAckComment` delegation contract, +1 per-provider assertion in
the conformance harness (4 currently-registered providers including the test
fixture), +1 Linear regression pin on the github router adapter's `postAck`
public surface, plus 2 existing github adapter tests migrated from mocking
`postTrelloAck` to mocking `dispatchPMAck` (the dependency direction
changed). Full suite: 472 files / 8668 tests (+19 from baseline).

Doc updates:
- `src/integrations/README.md` gains a "PM-ack dispatch coverage invariant"
  subsection in the conformance harness section, documenting the no-literal-
  branching rule, the Sentry-tag escalation, and pointing at both regression
  nets.
- `CHANGELOG.md` entry under spec 017.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zbigniewsobiecki zbigniewsobiecki merged commit 71ac7c2 into dev Apr 29, 2026
8 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the fix/pm-ack-coverage branch April 29, 2026 10:48
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/router/adapters/github.ts 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant