Repository navigation
feat(exporters): quota-watchdog decision layer — failure classes + repair ladder (#6032 slice 1) - #7788
Conversation
…pair ladder (#6032) Slice 1 of the generic browser-dependent quota watchdog core (#6032, design #6031): the pure decision layer the oneshot will drive. - Failure-class vocabulary and the single class -> repair-rung mapping. - Repair ladder with per-rung attempt caps (max 2 per incident), a disk-honored rate-limit cooldown, and escalation once rungs are spent. - Persisted per-source health record (attempts, cooldown, bounded repair log, incident identity + surfacing flag) and a non-throwing reader for a state file that cannot be trusted. - Detail sanitization so no credential-shaped text reaches disk or logs. Tests name their oracles per the testing doctrine: PBT invariants over generated tick sequences, an MBT reference ladder model stepped in lockstep, and the four acceptance fixtures. 12 pass, 0 fail. No I/O, no browser, no provider names: the entry point, adapter loader, rung 2/3 executors, escalation hand-off, producer scaffolding and systemd units remain for the follow-up (listed in pm-stack/exporters/README.md).
|
Warning Review limit reachedYou'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 38 minutes. View limit details
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. |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5ce48a5297
ℹ️ 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".
| .replace(/(cookie|authorization|token|bearer|session|password|secret)\s*[:=]\s*\S+/gi, "$1=<redacted>") | ||
| .replace(/[A-Za-z0-9_-]{32,}/g, "<redacted>"); |
There was a problem hiding this comment.
Redact complete authorization and cookie values
When a detail contains a normal authorization header such as Authorization: Bearer abc123, this replacement consumes only Bearer, leaving abc123 intact. Likewise, Cookie: sid=abc123; csrf=def456 retains the second cookie. Values shorter than 32 characters also survive the following replacement, so decide, recordRungOutcome, and coerceHealth can retain credentials in fields explicitly intended to be sanitized before persistence. Handle authorization schemes and complete cookie values rather than redacting only the first whitespace-delimited token.
Useful? React with 👍 / 👎.
| rung: 1, | ||
| outcome: "succeeded", | ||
| detail: "source recovered; incident closed", |
There was a problem hiding this comment.
Record recovery without inventing a rung-1 success
When a source recovers after a rung-0 cooldown, rung-2 browser repair, or rung-3 login, this branch always appends a successful rung-1 repair. For example, a session-expired observation followed by a healthy observation produces a rung-3 attempt followed by a rung-1 success, although rung 1 was never attempted. This makes the persisted repair history misattribute recovery. Represent incident closure separately from a rung outcome, or associate the recovery with the actual repair rather than hard-coding rung 1.
Useful? React with 👍 / 👎.
| // - Example tests: the four fixtures the acceptance criteria name | ||
| // (broken-source walk, rate-limited cooldown, human challenge, quiet | ||
| // when healthy). | ||
| import { describe, expect, test } from "bun:test"; |
There was a problem hiding this comment.
Register and wire the watchdog suite into a CI venue
The new suite is absent from .github/test-suite-registry.json, and repository-wide searches of the reviewed commit found no workflow or flake invocation naming it; the only explicit invocation is the manual README command. Checked .github/workflows/pm-stack-tests.yml: its push/PR path filters exclude pm-stack/exporters/**, and its test steps do not name this suite. The coverage contract in .github/ci-policy.md:195–201 explicitly requires registration and a venue naming the suite files, so these state-machine invariants currently have no automated verification venue. Register the suite and add an explicit CI test step with the required existence check.
AGENTS.md reference: AGENTS.md:L34-L34
Useful? React with 👍 / 👎.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Slice 1 of #6032 (design #6031). This lands the pure decision layer of the generic browser-dependent quota watchdog — the part the issue calls out as the natural fit for PBT/MBT — and leaves the I/O, browser and deployment shell to a follow-up with the boundary written down.
What lands
pm-stack/exporters/src/watchdog-state.tssession-expired,cookie-missing,endpoint-changed,browser-down,cdp-unreachable,rate-limited,unknown, and the single place a class maps to a repair rung.decide()returns the next action (quiet,wait-cooldown,retry,repair rung N,human-blocked,escalate) plus the next persisted record. Per-rung attempts are capped at 2 per incident; a rate-limited source setscooldownUntilon disk and the next tick honors it with no browser action; a rate limit whose cooldown rung is spent escalates rather than climbing to a browser repair.SourceHealthcarrieslastAttemptAt,lastSuccessAt,consecutiveFailures,currentClass, sanitizedlastDetail,cooldownUntil, per-rungrungAttempts, a bounded (20)repairLog, and the incident identity + surfacing flag.coerceHealthreads a file back without trusting it: garbage yields a fresh record, never a throw and never an assumed-healthy.No I/O, no browser, no secrets, no provider names — the core is provider-agnostic by construction, which is what the adapter-loader criterion asks for.
Tests name their oracles
pm-stack/exporters/test/watchdog-state.test.ts— 12 pass, 0 fail:consecutiveFailuresis monotonic while failing and resets on success; a healthy tick always clears the incident and is quiet; no secret-shaped value survives sanitization.human-blockedwith the surfacing flag and not re-hammering, and the healthy source staying quiet.Typecheck of both new files is clean under the repo's strict settings.
What remains for #6032 (listed in
pm-stack/exporters/README.md)The oneshot entry point (state read/write,
latest.json+ heartbeat reads, history append), the adapter loader andadapters/, the rung 2/3 executors, the rung-4 hand-off to #6033, producer scaffolding, and the systemd oneshot + timer. The issue stays open for those.Refs #6032, #6031.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.