Skip to content

feat(pm-stack): quota watchdog core — entry point, adapters, rung executors, systemd timer (#6032) - #11243

Merged
dezren39 merged 1 commit into
mainfrom
queue/19956-6032-watchdog-core
Nov 17, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/19956-6032-watchdog-core

Conversation

@dezren39

@dezren39 dezren39 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

What this builds (#6032 remainder)

Slice 1 (decision layer, PR #7788) and rung 4 (escalation, PR #8357) already landed. This PR builds the rest of the watchdog core:

  • src/watchdog.ts — the oneshot entry point. Per tick: load adapters, read the state file through coerceHealth, observe each source (producer document + gatherer heartbeat + live CDP liveness probe), classify (including missing-document, stale-read-while-the-browser-lives, and dead-CDP — the classes the producer cannot see itself), decide, execute the rung, run rung-4 escalation/recovery, write state back atomically (tmp+rename), append quota-watchdog-history.jsonl. Nothing decision-relevant lives in process memory (quota: claude read needs cross-tick memory — usage-endpoint 429 (proven) + oneshot gatherer defeats the fetcher's in-process cooldown/cache #5928).
  • Rung executors — rung 2: CDP re-validation (/json/version + /json/list, allowlist origin open, cookies present by name via the CDP websocket — values never enter the process) with one bounded supervised restart of the adapter's browser unit; rung 3: re-login driver that stops dead at a human-only challenge and marks the incident human-blocked. Repairs are gated on QUOTA_WATCHDOG_LIVE_REPAIRS=1, rung-4 production effectors (fleet queue / gh) on QUOTA_WATCHDOG_LIVE=1; the systemd unit sets both, a bare CLI run journals dry-run plans and creates nothing.
  • src/adapters.ts + adapters/fixture.json — the adapter loader: per-provider JSON (origins allowlist, CDP port, data paths, cookie names, login hints, class/rung maps, thresholds), structurally validated, defects reported per file instead of throwing. The core contains zero provider names; the fixture adapter is the one shipped here, real provider adapters are follow-ons per the issue scope.
  • producers/producer-template.mjs — forkable producer scaffold from the retired Meta producer pattern (timeout-bounded CDP, tab ownership, failure-class exit codes + failure documents, atomic latest.json), plus test/fixtures/fixture-producer.mjs, the scenario-driven stub the acceptance tests drive.
  • pm-stack/systemd/pm-quota-watchdog.{service,timer} — oneshot + timer on the gatherer cadence, offset to *:3/15.

Tests (oracles named per the testing doctrine)

bun test ../exporters/test/ — 35 pass, 0 fail (includes the pre-existing state + escalation suites). The new test/watchdog.test.ts drives the entry point end to end against a scratch tree:

  • broken source walks retry → CDP re-validation → re-login → escalation, caps honored (no rung >2× per incident), escalates exactly once and dedupes on later ticks;
  • rate-limited fixture sets cooldownUntil on disk and a fresh tick honors it with no repair action (the quota: claude read needs cross-tick memory — usage-endpoint 429 (proven) + oneshot gatherer defeats the fetcher's in-process cooldown/cache #5928 regression shape);
  • human-only challenge fixture marks the incident human-blocked with the surfacing flag and a same-tick NEEDS DREW line, and the ladder stops dead;
  • healthy source is quiet (state + history only, no output);
  • recovery after escalation comments/closes/completes the hand-off;
  • cross-invocation persistence: every tick re-reads state from disk.

CLI fixture demo also run live: healthy tick quiet; session-expired scenario classified and rung 3 recorded (as skipped with live repairs off).

Live install (units + timer + a laptop-local adapter for the Meta file-export source) and the ≥3-consecutive-tick demonstration follow the merge and are reported on #6032.

Task 19956 · lane any-k


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

…ader, rung 2/3 executors, producer template, systemd timer (#6032)
@dezren39
dezren39 requested a review from a team as a code owner November 17, 2026 10:59
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-17T11:00:01.656475Z
We couldn’t complete this review. Comment @codex review to try again.
da58976 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 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e0c939cf-4cd0-44ab-982f-4329ee61bf11
Commits

Reviewing files that changed from the base of the PR and between 99a6753 and da58976.

Files selected for processing: 9

  • pm-stack/exporters/README.md
  • pm-stack/exporters/adapters/fixture.json
  • pm-stack/exporters/producers/producer-template.mjs
  • pm-stack/exporters/src/adapters.ts
  • pm-stack/exporters/src/watchdog.ts
  • pm-stack/exporters/test/fixtures/fixture-producer.mjs
  • pm-stack/exporters/test/watchdog.test.ts
  • pm-stack/systemd/pm-quota-watchdog.service
  • pm-stack/systemd/pm-quota-watchdog.timer
  • 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@dezren39

Copy link
Copy Markdown
Member Author

Review disposition (lane any-k, task 19956)

  • Codex: the review run itself failed — "You have reached your Codex usage limits for code reviews" — and posted no findings (no inline comments, no review threads). There is nothing substantive to disposition; the failure is a reviewer-capacity limit, not a code finding.
  • CodeRabbit: likewise rate-limited ("Review limit reached"), no findings posted.
  • Merge basis: targeted tests verified in the worktree (bun test ../exporters/test/ — 35 pass, 0 fail, including the pre-existing decision-layer and escalation suites), CLI fixture demo run live, diff matches the impl(pm-stack): browser-dependent quota watchdog core — disk state, failure classes, repair ladder #6032 scope. Merging per standing merge authority; if Codex capacity returns and a later review raises findings on this code, they will be fixed forward.

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