Skip to content

feat(pm-stack): section-risk notification class (#8882) - #8889

Merged
dezren39 merged 1 commit into
mainfrom
queue/15095-8882-section-risk
Nov 12, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/15095-8882-section-risk

Conversation

@dezren39

@dezren39 dezren39 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Implements #8882 (task 15095): a seventh notification class section-risk for pm-stack/aggregator.

What changed

  • notifications.ts: class section-risk ("Section failure / severe risk") in NOTIFICATION_CLASS_DEFAULTS (default ON for new subscriptions) + NOTIFICATION_CLASSES, so the preferences page renders the toggle and per-class test sends accept it; test-send landing is /quota like the other quota classes. buildNotificationCandidates derives one candidate per major section (workhorse, speed, specialist, summit, small) from snapshot.sectionPools: FAILED when every serving pool is walled (breakthrough, title Section failed: <section>), SEVERE RISK when every non-walled serving pool is pending wall (any measured window >=85%, not a breakthrough). Pools in error/stale/lapsed state never count as serving. Compact body, soonest reset first: walled: <pool> (resets Fri 14:28Z), ... · pending: <pool> 97% (resets Mon 11:04Z). Fingerprint state carries walled/pending membership + soonest reset, so dedupe/cooldown/recovery ride the existing engine unchanged.
  • aa.ts: routeLeafSets exported; new sectionPoolIdsFromConfig(configText, poolIds) + poolServesDoor join, pinned by tests: (1) exact via the gatherer service-id spelling (serviceIdFor: _claude -> anthropic:claude-pro, _muse -> meta); (2) split pools under a door (_antigravity.gemini serves _antigravity); (3) *-plan(s) pseudo-providers map to their base provider pools (opencode-go-plans -> opencode-go.*, openai-plan -> _openai.main/.alt, mistral-plan -> mistral).
  • small-100k choice (recorded per the issue): small already reaches small-100k's leaves through its nested opencode-route/small-100k target, and live leaf analysis (2026-11-12) shows small-100k's door set identical to small's, so it rolls up under small with no extra mapping.
  • config.ts/server.ts: new opencodeConfigFile config (env PM_AGG_OPENCODE_CONFIG_FILE, default ~/git/code/.opencode/opencode.jsonc); the alert-engine snapshot reads it fail-soft each tick and supplies sectionPools.
  • test/alerts.test.ts: the two exact default-class-map assertions gain section-risk.

Tests

  • New test/section-risk-8882.test.ts (8 tests): class registration/landing; the three acceptance fixture scenarios (all-walled -> one FAILED with compact body; only-non-walled >=85% -> one SEVERE RISK; one healthy pool <85% -> no candidate); stale pools excluded; absent membership -> nothing; the config join incl. plan doors and small-100k nesting; unparseable config -> {}.
  • Suite: worktree 2146 pass / 17 fail vs clean main 2138 pass / 17 fail (same 17 pre-existing failures; +8 new passing, zero new failures). Typecheck error count identical to main (78 lines, none in touched files).

Remaining after merge (same task): deploy the aggregator on the laptop, verify the running server exposes the class, live derivation proof against the real quota snapshot, and Drew's phone subscription flip (section-risk on, quota-wall/quota-near-wall off) recorded on #8882.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • New Features
    • Added section-risk alerts for major service sections when their serving quota pools are exhausted or reach 85% of a measured quota window.
    • Alerts show affected and pending pools, reset times, and whether a section is at severe risk or has failed.
    • Section-to-pool matching now uses the route configuration.

…hole route section fails or is at severe risk (#8882)
@dezren39
dezren39 requested a review from a team as a code owner November 12, 2026 08:23
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T08:26:57.335522Z 16c71c1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The aggregator now maps configured route sections to quota pools and includes that membership in notification snapshots. The notification engine derives section-risk candidates for failed sections and sections where all eligible non-walled pools meet the 85% threshold.

Changes: Section-risk notifications

Layer / File(s) Summary
Route configuration and pool mapping
pm-stack/aggregator/src/config.ts, pm-stack/aggregator/src/aa.ts, pm-stack/aggregator/test/section-risk-8882.test.ts
The config adds an OpenCode configuration path. Route helpers expand configured route leaves and map the five watched sections to matching quota pool IDs. Tests cover matching rules and invalid configuration.
Section membership in notification snapshots
pm-stack/aggregator/src/server.ts
The server reads the configured OpenCode file and adds computed section-to-pool membership to the notification snapshot.
Section-risk candidate derivation
pm-stack/aggregator/src/notifications.ts, pm-stack/aggregator/test/alerts.test.ts, pm-stack/aggregator/test/section-risk-8882.test.ts
The notification class is default-enabled and uses /quota as its test landing. Derivation emits candidates when all serving pools are walled or all eligible non-walled pools have measured windows at or above 85%. Tests cover candidate contents and absence conditions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant AggregatorServer
  participant OpenCodeConfig
  participant sectionPoolIdsFromConfig
  participant NotificationEngine
  AggregatorServer->>OpenCodeConfig: Read configured JSONC
  AggregatorServer->>sectionPoolIdsFromConfig: Pass config text and quota pool IDs
  sectionPoolIdsFromConfig-->>AggregatorServer: Return section-to-pool membership
  AggregatorServer->>NotificationEngine: Provide notification snapshot
  NotificationEngine->>NotificationEngine: Derive section-risk candidates
Loading

Possibly related issues

Possibly related PRs

  • developing-today/code#1023 — This PR changes route targets in the OpenCode config that this change reads to derive section membership.
Merge Risk: Moderate · up to 16c71

The new section-risk notification can send repeated alerts when usage percentages drift, and it can miss or misreport section failures when the route-to-pool matching includes pools that cannot serve a route. Fingerprint churn and membership matching should be fixed before merge. Reset-time reporting and a transient config-read failure are smaller correctness gaps.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 16c71c15f5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +847 to +848
const doors = new Set([...leaves].map((leaf) => leaf.split("/")[0]));
out[section] = [...new Set(poolIds.filter((poolId) => [...doors].some((door) => poolServesDoor(poolId, door))))].sort();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the leaf model when joining split quota pools

For the configured speed section, the only Antigravity leaf is gemini-flash-plan → _antigravity/gemini-3.8-flash (.opencode/opencode.jsonc:2463,3337-3341), but dropping the model here causes poolServesDoor to include both Antigravity pools. The gatherer's antigravityPoolForModel explicitly attributes Gemini models only to _antigravity.gemini. Consequently, a healthy _antigravity.claude-gpt pool suppresses the failure/risk notification even when every pool actually serving speed is walled or pending wall. Preserve the model identity and apply the gatherer's split-pool attribution when deriving membership.

Useful? React with 👍 / 👎.

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