Skip to content

design(pm-stack): browser-dependent quota watchdog — CDP scrape producers that self-repair, escalate to a browser-enabled agent #6031

Open

Description

@dezren39

Directive

Drew, 2026-11-04 ~23:18 CST: for providers whose quota/plan data can only be obtained through a logged-in website (Mistral is the first case), a CDP-driven browser scrape path is accepted — "but we'll need a watchdog agent that knows how to work a browser and can fix it whenever it breaks." If the data relies on a cookie, use the cookie. If self-repair fails, the watchdog triggers a task for a browser-enabled agent to fix it.

Design (landed with this issue)

Full design note: ~/workspace/scratch/mistral-quota-watchdog-2026-11-04/design.md (sandbox workspace). Shape:

  • Three parts, all on the laptop: per-provider producer (oneshot, 15-min timer, writes the code#1301 file-export documents ~/atlas/<provider>-export/latest.json + history.jsonl, classifying its own failures), a generic watchdog core (oneshot offset after the gatherer tick; health state + repair ladder + escalation), and the gatherer, which ingests each source via its existing FILE_EXPORTS machinery (registry currently empty, ingestion code intact) with code#1268 last-known retention.
  • Health model per source: last-success timestamp, consecutive-failure count, failure class — session-expired / cookie-missing / endpoint-changed / browser-down / cdp-unreachable / rate-limited / unknown — each mapped to a repair.
  • Repair ladder, cheapest first, attempt-capped and logged: (0) retain + disk-persisted cooldown (rate-limited only); (1) retry next tick; (2) re-validate/re-extract the session via CDP — primary pattern is the retired Meta producer's in-page fetch, where the cookie never leaves the browser; value extraction is the fallback and lands only in fleet secrets by name; (3) re-login in the browser via the standing Google SSO session ("click in and reset it") — a human-only challenge (2FA / verify-it's-you / passkey) makes the incident human-blocked and surfaces to Drew immediately; (4) escalate to a browser-enabled agent (fleet queue task with the full failure context + one deduplicated GitHub incident issue; auto-close on recovery).
  • State on disk, always: ~/.local/state/pm-aggregator/quota-watchdog-state.json, atomic writes. This is the direct application of code#5928's lesson — the watchdog is a oneshot and must not repeat the in-process cooldown/cache mistake.
  • Cadence: producers *:0/15, watchdog offset on the same 15-min rhythm as the gatherer. Alerting: silent while self-repair works; Drew hears only human-blocked (immediately) or an escalation unresolved >24 h.
  • Generality: per-provider adapter files (origins allowlist, data paths in preference order, cookie names, login hints, class map, thresholds). Mistral is adapter test #1; Claude console / Open Design (code#5060) are named later adopters.
  • History: health observations feed the existing usage snapshot pipeline (code#4889) once its laptop path bug is fixed; interim is the producers' history.jsonl convention — no parallel store.

Position vs existing work

Open questions (named, per #1260's rule)

  1. Escalation-unresolved threshold before a NEEDS DREW line: 24 h proposed. Not blocking.
  2. Recovery of a human-blocked incident: stay silent (closed issue is the record) — proposed.
  3. Producer source home: pm-stack/exporters/ in this repo (proposed) vs beside the quota module in openchamber.

Implementation split (linked issues)

  • Watchdog core: filed as a sibling issue in this repo, linked below.
  • Escalation mechanism: filed as a sibling issue in this repo, linked below.
  • Mistral adapter test #1: filed in developing-today-forks/openchamber, blocked on the sign-in lane's data-path outcome (Vibe token usage API vs console endpoint + cookie), linked below.

Acceptance criteria

  • This design is reviewed and its open questions answered or explicitly deferred.
  • The implementation issues linked from this issue exist and carry their own acceptance criteria (this issue carries no implementation work itself).
  • The design's remediation-catalogue entries are reflected in code#1260's catalogue (comment or sub-issue link there).

Activity

  1. added
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    kind/designA design proposal (design-architect): multi-step, phased, decision-bearing
    on Nov 5, 2026
  2. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    Implementation split filed (this design carries no implementation work itself):

    Design note: ~/workspace/scratch/mistral-quota-watchdog-2026-11-04/design.md. Umbrella: #1260 (noted there). Companion reads: #5928, #4889, openchamber#1619.

  4. added
    queue/queuedHas a queued task in the Supabase agent queue
    task/triageQueue packet kind: verify, reproduce, and route this item
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 5, 2026
  5. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  6. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

    Triage findings (verified fresh this shift)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/pm-stackpm-stack (Pad/Grist) in developing-today/codekind/designA design proposal (design-architect): multi-step, phased, decision-bearingtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions