Skip to content

Implement repo-fleet-monitor snapshot/SQL-first fetch (digest-judged runs, ≤3M input/run) #2154

Open

Description

@dezren39

Implementation follow-on from the #2134 triage (queue task 3164, 2026-10-29). Parent: #2134 (design recorded there); fleet epic: #2055.

The 2h cadence half of #2134 is already live. This issue is the remaining half: rebuild repo-fleet-monitor's state fetch to be snapshot/SQL-first so a run costs ≤3M input (from 7.2M at check-in #5) with no duty dropped.

Design (full text on #2134):

  1. Deterministic precompute, run-start fresh. A script (extend the existing hidden_files/monitor-fetch.py / monitor-query.py prototypes in the goal workspace) runs at the start of every monitor run and emits ONE compact digest: live queue tasks across all four pilot queues (PostgREST, one query per queue, live statuses only) joined against a bounded GitHub pull (only issues carrying queue/* or work/* labels and PRs bound to live tasks). The digest pre-flags divergences mechanically: claimed-but-unlabelled, labelled-but-no-live-task, expired leases still claimed, expired parks, PR merged/closed but task open, issue closed but task open, dead-in-queue (max_attempts reached, still queued).
  2. The agent judges only the digest. Full task/issue lists never enter the agent's context; a flagged divergence is investigated with a targeted single-item fetch. Intake enrichment stays bounded (newest-first sample, as today) but draws its candidate list from the digest.
  3. Freshness is binding: the digest is generated in-run; judging from a snapshot older than the run is forbidden (the stale 2026-10-28 prototype snapshot JSONs in hidden_files are the anti-pattern — delete or overwrite them in-run, never read them as evidence).
  4. No duty dropped — each protocol duty maps to digest fields: reconciliation + auto-repair (divergence flags), dead-in-queue alerts (attempts flag), intake enrichment (unenriched-issue list), in-progress tracker (claimed tasks + label join), protocol checks (work/* without a fresh agent note = flag).

Acceptance:

Activity

  1. developing-today commented on Oct 29, 2026

    @developing-today
    Contributor
  2. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Oct 30, 2026
  3. dezren39 commented on Oct 30, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

    Triage verdict — scope CONFIRMED, with one correction that changes the acceptance

    Premise holds. The remaining half of #2134 is real and untouched: no branch matching 2154 or fleet-monitor exists, and gh pr list --state all --search '2154 in:body,title' returns nothing, so no parallel attempt is in flight.

    Live state verified fresh (2026-10-30T04:45Z)

    Check Result
    repo-fleet-monitor enabled yes
    Cadence every: 2h, anchor 2026-10-29T03:12:10, timeout 3600s — the #2134 cadence half is live, so this issue must not touch it
    Prototypes wired into the job body no — grep -c 'monitor-fetch|monitor-query' over the definition returns 0
    Prototype capability partial: monitor-fetch.py is tasks?select=* across the four queues (no GitHub join, no flags); monitor-query.py is the compact task projection usable as the digest's task half
    Stale snapshots still present monitor-tasks-snapshot.json (975 KB, 2026-10-28 10:35), monitor-gh-snapshot.json (95 KB, 10:45)

    The correction: seven duty blocks, not five. The issue body maps four design points onto five duties. The live definition — which is the thing being rewritten — now carries seven blocks:

    Live duty block Digest field that must replace it
    DUTY 1 safety net (queue↔GitHub, code) live tasks + labelled-but-no-live-task, issue-closed-but-task-open
    DUTY 1 ADDENDUM (claim/label divergence auto-repair + dead-in-queue) claimed-but-unlabelled, expired-lease-still-claimed, expired-park, dead-in-queue
    DUTY 1B (PR↔queue reconciliation + out-of-band pickup catch, all four queues; added 2026-10-28) bounded PR set joined to live-task issues + pr-merged-but-task-open
    DUTY 2 intake enrichment unenriched candidate list (newest-first, meta/enriched absent)
    DUTY 3 in-progress tracker claimed/assigned tasks + label join + last-activity
    DUTY 4 protocol checks work/* with no fresh agent-note:v1
    DUTY 5 expedite/next-up labels (added 2026-10-29) expedite/next-up issues with live task id + priority

    Duty 1B is the one that ended the duplicate-PR failure class on 2026-10-28, and Duty 5 is the newest Drew-ordered duty. A digest that only serves the five duties named in this issue's body would silently stop both. "No duty dropped" therefore means all seven, and that is what the implementation packet requires.

    What actually costs the 7.2M/run (named so the rewrite has a target, not a guess): the in-run snapshot.py pulls every live task row for 4 queues × 4 statuses plus gh issue list --limit 1000 and gh pr list --limit 500 for all four repos, writing issues-developing-today-code.json (4.86 MB), tasks.json (2.85 MB), prs-developing-today-code.json (332 KB), then printing 62 KB of analysis. The digest replaces that whole shape: bounded pull (queue/* + work/* labelled issues only, PRs bound to live tasks), everything else derived by join.

    One implementation gotcha worth recording: the job body addresses the goal workspace as ~/workspace/goals/... (the agent sandbox mount), while the versioned copy on the execution host is ~/hatch-personal/workspace/goals/... (a git repo — crons/ and GOAL.md are tracked). The digest script has to be committed in the versioned copy and invoked by a path the job actually resolves at run time. That has to be decided and proved inside the one full run, not assumed.

    Routing

    Implementation packet enqueued: task 3809, repo-health-code-pilot, priority 90 (Batch 3 top priority per Drew's #2134 directive), dedupe repo-health:v1:fix:developing-today/code:issue:2154, timebox 45 min, max 2 attempts. It carries this issue's acceptance criteria verbatim plus the seven-duty mapping above. The ≤3M target stays as written: measured over the three check-ins after the rewrite lands, with divergence-repair counts not below the pre-rewrite average.

  4. added
    queue/queuedHas a queued task in the Supabase agent queue
    and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    queue/queuedHas a queued task in the Supabase agent queue
    on Oct 30, 2026
  5. 36 remaining items

  6. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: parked (task 3809)

  7. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · blocked

    The run-start digest (monitor-digest.py) FAILED this run: exit 4, repo-queue: curl failed: curl: (28) Operation timed out after 60001 milliseconds with 0 bytes received — the PostgREST read path is hanging again (tracked as the queue outage on issue #4875). No digest was written; the on-disk digest remains the 2026-11-04T07:27Z one from the previous run and was NOT used as evidence (stale-digest rule).

    Fallback used this run, per the monitor body: per-duty commands only — gh for the GitHub side (works, ~5s/call) and supabase-exec.py (Management API) for queue reads, which is itself degraded: aggregate count queries succeed after ~1–2 min, row-level queries mostly return HTTP 544 "Connection terminated due to connection timeout", and the few that succeed take ~2 min for a single row. Queue mutations via repo-queue.py (enqueue/cancel/signal/claim) are therefore effectively unavailable this run; any queue-side repairs that could not be verified are reported as pending in the run summary, not silently dropped.

  8. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · blocked

    Failure: monitor-digest.py exited 4 on two attempts (04:12 and 04:13 CST). Error: repo-queue: HTTP 503 from PostgREST: {"code":"PGRST002","message":"Could not query the database for the schema cache. Retrying."} — project keihfchslgjetkmnmzra.supabase.co. repo-queue.py health fails identically, so the queue control plane is unreachable this run; all queue-side duties (reconciliation, dead-in-queue repair, PR binding, expedite raises) are blocked on the DB, and the monitor is falling back to GitHub-side per-duty checks only. No digest JSON was produced; no stale digest was used as evidence.

  9. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · blocked

    • Agent: fleet monitor
    • Session / ID: repo-fleet-monitor run 2026-11-04 06:12 CST
    • Found via: monitor reconciliation
    • Task: Run-start digest failure report (per the Implement repo-fleet-monitor snapshot/SQL-first fetch (digest-judged runs, ≤3M input/run) #2154 duty): monitor-digest.py fails immediately with FileNotFoundError: /home/hatch/tools/repo-queue.py — the Python helper was removed in the 2026-11-04 binary-direct migration (code#5362), and the digest script still imports it via importlib. shift-certifier.py (full mode) fails the same way; only its --summary-only path (jsonl-only) works. This is the same missed-consumer class as code#5422 / code#5414.
    • Expectation: digest + certifier migrated to the repo-queue binary (or a stable library surface) so the monitor's run-start digest works again; until then the monitor falls back to per-duty SQL (supabase-exec) + gh reads, as it did this run.
  10. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    Update on the digest breakage noted here: monitor-digest.py imported the removed ~/tools/repo-queue.py module for its queue reads, so every monitor run since the binary-direct migration (#5362) lost its run-start digest and Duty 6 certifier input. Repaired 2026-11-04: the import is replaced with a self-contained read of muse-dev2 — the tasks query runs through the Management API SQL endpoint (the supabase-exec path) via curl with a slim projection of the fields the digest actually consumes, paged at 200 rows, because direct PostgREST reads from the sandbox truncate mid-chunk unpredictably. Verified with a full run today: digest written (165,948 bytes) with per-repo flag counts for all four repos. The next scheduled monitor run picks it up unchanged.

  11. added
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 4, 2026
  12. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked

    • Agent: queue worker lane code-d (repo-queue-worker-shift-d)
    • Session / ID: cron shift 2026-11-04 07:28 CST · queue task 3809
    • Found via: queue claim (direct execution lane)
    • Transition: picked up → verified → parked
    • State: Acceptance 1 verified live (RUN-START DIGEST section present in the live repo-fleet-monitor job body, duties intact). Acceptance 2 evidenced by full digest-flow monitor runs on 2026-11-03 (14:12/16:12/20:12/22:12 CST, all duties in output). Today's 06:12 CST run lost its digest to the design: repo-queue + secrets brokers on the laptop behind the session proxy #5362 binary migration (FileNotFoundError: ~/tools/repo-queue.py); the script repair posted above is confirmed structurally (no remaining import of the removed module; direct PostgREST reads) but is unproven until a scheduled monitor run executes it.
    • Resume condition: (a) a scheduled repo-fleet-monitor run completes with an in-run digest (proves the repair live), then (b) collect the three daily token check-ins for the ≤3M input measurement, then update Slim repo-fleet-monitor: snapshot/SQL-first state fetch + 2h cadence (target ≤3M/run) #2134 with the measurement, link epic epic: fleet expansion & placement program (2026-10-28 directive, LIST 1–5) #2055, and complete task 3809 / close this issue.
  13. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 4, 2026
  14. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    Monitor repair status — 2026-11-04 (fleet-binary exception close-out, code#5412)

    What broke: the 2026-11-04 06:12 CST run's digest step failed with FileNotFoundError: [Errno 2] No such file or directory: '/home/hatch/tools/repo-queue.py' — the digest builder (monitor-digest.py, deployed 2026-11-03, rollout record: ~/workspace/goals/keep-the-four-repos-healthy/hidden_files/monitor-digest-rollout.md) still spawned the deleted Python helper for its queue-wide pull. The run proceeded on the filed-failure fallback path.

    Repair (done 2026-11-04, earlier today): monitor-digest.py now reads PostgREST directly — Management API SQL endpoint for the queue-wide pull (plain urllib reads truncate mid-body on this host), slim projection, credentials fetched from Bitwarden by name only. No repo-queue.py dependency remains in the digest path. The related Duty-6 helper shift-certifier.py had the same break and was repaired the same day (code#5505): self-contained PostgREST reads via curl (key passed in curl's stdin config, never argv/disk); judging logic untouched; verified CERTIFIED output for all lanes.

    Verification — four consecutive judged runs on the repaired digest:

    • 08:12, 10:12, 12:12, 14:12 CST runs all completed ok, each generating a fresh in-run digest (latest: 2026-11-04T20:12:31Z, 152,179 bytes) and evidencing all duties (per-issue checks across all four repos, seven worker bindings incl. shift-certifier CERTIFIED x6, fleet + supervisor + watchdog duties).

    What of this issue's spec remains:

    • The ≤3M input-tokens/run measurement: three daily token check-ins (the parked follow-on task 3809), then close/update Slim repo-fleet-monitor: snapshot/SQL-first state fetch + 2h cadence (target ≤3M/run) #2134 and link the fleet epic epic: fleet expansion & placement program (2026-10-28 directive, LIST 1–5) #2055.
    • Digest size is running 78–159 KB vs the <100 KB design target — worth a projection trim when the measurement pass happens.
    • The monitor job body itself still invokes the queue CLI under its repo-queue alias name (works via the ~/tools/bin/repo-queue symlink to the fleet binary); migrating the body's invocations to fleet queue is tracked in the migration ledger (~/workspace/goals/keep-the-four-repos-healthy/hidden_files/repo-queue-to-fleet-migration-2026-11-04.md) — deferred in this pass because the live body could not be safely re-based from the copy available to the migration agent; it needs a follow-up edit from a verified copy.

    agent-note:v1 — monitor repair verification + remaining spec, 2026-11-04.

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

Metadata

Metadata

Assignees

Labels

queue/parkedQueue task is parked (waiting on CI, time, or an event)source/creatorFiled by the new-issue-creator jobstatus/parkedDeliberately paused with a recorded resume conditiontask/triageQueue packet kind: verify, reproduce, and route this itemwork/assignedQueue worker lifecycle state

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions