Skip to content

External-system observability: unified PM + queue + quota attribution (webhooks, hot list, session IDs, projections) #2072

Open

Description

@dezren39

Problem (owner direction, 2026-10-28)

Work is steadily moving off the main agent onto other systems that spend their own tokens under direction — the OpenCode fleet, OpenClaw-originated sessions, Codex/ChatGPT, Jules and other external agents. Direction stays centralized (adjust cadences, add/remove scheduled tasks, tell a persistent agent what it is doing right or wrong and let it fix itself), which saves main-agent tokens. The cost: the main agent no longer directly knows what those systems did. Today the record is scattered across GitHub, the queue DB, session stores and quota files, with no single place to answer "what happened, who did it, what did it cost, and was it any good."

This issue is the design + build tracker for closing that gap.

Requirements

1. The PM stack and the queue must be available TO the external systems

Not just readable by the owner: the delegated systems themselves need to read queue state and report outcomes into the PM stack, so their work lands in the shared record as it happens instead of being reconstructed later.

2. Detect what happened OUTSIDE the system

Anything a delegated system does that bypasses the queue/PM record is currently invisible. Close this with webhooks: for every system/repo that can emit them (GitHub first), deliver events into an ingestion point that maintains a hot list of everything created or changed since the last check — issues, PRs, comments, edits, commits. The checking/triage systems then sweep the hot list and flag anything that was not expected (not traceable to a queue item, a schedule, or a directed task).

3. PM stack + queue: one integrated view

Merge or closely integrate the two so the owner can see, in one place:

  • what is queued, and in what order;
  • what has been picked up, and by which system;
  • stats, metrics, graphs and trends over token usage, model selection, plan quotas, and all scheduled jobs.

4. Per-job / per-model outcome attribution

For each job (and model) the system should be able to say: "this job with this model made 2 PRs, closed 1 issue, created 3 issues, commented on these issues" — counting at least: issues/PRs created, commented on, descriptions edited, commits to branches — with every aggregate linking back to the exact issues, PRs and comments behind it.

5. Universal session identity

Every unit of delegated work carries a traceable ID:

  • OpenCode already has session + parent-session IDs — use them as-is (session uploads/digests already preserve child-session lists and model switches).
  • OpenClaw origination of an OpenCode session needs a recorded mapping (which OpenClaw context started which session).
  • Systems whose internals we do not control (ChatGPT/Codex and similar): pull actual IDs from a weekly ChatGPT export; where no native ID exists, workers get an assigned ID when they pick up a queue job and reuse it across subsequent items.
  • The same applies to the main agent itself: when it takes an item from the system it is told its session ID (or presents one it already holds), so its work is attributed the same way.
    Sessions tie to: exact model(s), the system of origin, token usage where measurable (exact where the platform records it, absent where it cannot), and the quota series (item 7) — so a change to a job can be followed to its effects on quotas and outcomes.

6. Quality linkage

  • PRs can be marked reverted or had to be redone, with links to the redo.
  • A bug can be tied to the multiple PRs that contributed to it existing.
    Together with item 4, this is how we find out what is actually causing bugs — which jobs/models/systems produce work that sticks vs work that gets reverted — and the UI should make that analysis easy.

7. Quotas in the same picture, with projections

  • The assistant's own subscription quota joins the PM pool list as a first-class entry: current percentage, total tokens per week, position in the window. (Data source exists: a 5-minute recorder landed 2026-10-28 — ~/tools/quota-recorder.py + the runtime token DB's per-message records; the laptop quota-gatherer already records the other pools every 15 minutes.)
  • For every quota: a few days of percentage history against its reset, and a projection — either "projected to end the window at X%" or "projected to hit quota on at ".
  • Projections are stored, and later compared with what actually happened, so modifiers/rules can be learned over time to make the predictions better.

Persistence principle

Not everything has to land in the database immediately — but everything must be written down somewhere persistent, with a system that gets it into a central location where it can be queried regularly.

Pieces that already exist (build on these)

  • PM aggregator + projector (laptop) with per-source health, comments/actions stores, quota-current and the monthly usage-snapshot JSONL.
  • The queue system (Supabase agent.tasks: packets, dedupe keys, lane claims, completions — completions currently record queue-level worker identity, not per-lane; see the 2026-10-28 token check-in findings).
  • The runtime token DB (agent.agent_message_token_usage + spawn metadata) — exact per-message tokens with cron attribution for everything on this platform.
  • OpenCode session digests (full session/child-session/model-switch records).
  • The 5-minute Muse subscription quota recorder + the laptop's 15-minute pool gatherer.
  • GitHub webhooks are available on all owned repos; the fleet-feed collector pattern is a working ingestion precedent.

Shape of the work (to be refined in design)

  1. Design note first: identity scheme (session/job/system), the attribution event model, webhook ingestion + hot-list store, and the integrated PM/queue/quota views. Record the design on this issue before building.
  2. Then implementation issues, one per piece, linked here: webhook ingestion + hot list; queue↔PM integration views; attribution rollups (per job/model/session); session-ID assignment at queue pickup + OpenClaw/Codex mapping; projection engine + accuracy tracking; Muse pool on the PM list.

Acceptance criteria

  • A design note is recorded on this issue covering: the identity scheme (session/job/system), the attribution event model, webhook ingestion + hot-list store, and the integrated PM/queue/quota views.
  • Implementation issues are filed, one per piece, and linked here (webhook ingestion + hot list; queue↔PM integration views; attribution rollups; session-ID assignment at queue pickup + OpenClaw/Codex mapping; projection engine + accuracy tracking; Muse pool on the PM list).
  • GitHub webhooks (first source) deliver issue/PR/comment/commit events into the ingestion point, and the hot list reflects everything created or changed since the last check.
  • The integrated view can answer, for a given window: what happened, which system/agent did it, what it cost, and its outcome — without hand-reconciling GitHub, the queue DB, and quota files.

Activity

  1. developing-today commented on Oct 29, 2026

    @developing-today
    Contributor
  2. added
    source/humanFiled directly by a human
    priority/highImportant and time-sensitive
    effort/lLarge: multi-day or open-ended; expect staged check-ins
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Oct 29, 2026
  3. dezren39 commented on Oct 29, 2026

    @dezren39
    MemberAuthor

    Intake review

    Related: owner-direction tracker filed 2026-10-29 by dezren39; the fleet's existing queue signal/PM stack and the repo-queue helper are the integration substrate; the stewardship/orchestrator hot-list pattern named in the body is the ingestion precedent.

    Notes: this is a design-first tracker — step 1 in the body (design note recorded here before building) is the gate; the six implementation pieces should be filed as linked issues only after the design lands, per the fleet's nothing-sits-silently rule.

    Risks: scope is fleet-wide (multiple external systems); webhook delivery needs a reachable ingestion endpoint, which may gate the first piece.

    Suggested approach: design note first (identity + event model), then file the six linked implementation issues in the order listed in the body.

    — Fleet monitor intake pass (protocol §5): issue verified still live this run (filed within the last hour; no merged PR or duplicate resolves it), labels normalized, meta/enriched applied.

  4. dezren39 commented on Oct 29, 2026

    @dezren39
    MemberAuthor

    DREW DIRECTION (2026-10-29) — the OpenCode usage exporter: PULL from OpenCode's own history database. We have direct query access to that database and it is backed up on a routine basis; the exporter reads sessions/messages (model, tokens, cost, parentage) out of it on a cadence, the same pull pattern as the Muse runtime-db export — do NOT build push instrumentation into OpenCode/OpenChamber for this. One implementation fact from tonight's lane work: the live session data is in OpenChamber's MANAGED OpenCode instance store — the default-path opencode.db is stale (newest activity ~Oct 6) — so the exporter must target the live instance's database (and ideally notice if the instance's store ever moves). Aster's design (2026-10-29) makes this exporter the precondition for any measured OpenCode baseline: mirror_* tables cover Muse's runtime only.

  5. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    Status — owner order 2026-10-28, stalled, re-queued 2026-10-31.

    This observability direction was given by Drew on 2026-10-28 (issue priority/high), but the issue never got a queue presence — no task row, no queue labels, no execution evidence in 3 days.

    Remediation (2026-10-31, Oct-28 left-on-the-ground audit): enqueued into repo-health-code-pilot as task 4722 (triage/design, priority 70, queued, attempts 0/3), verified by direct queue read; queue signal refreshed.

    The packet scopes the triage to what this issue needs first: sequence the seven requirements into landable slices, fully specify the first slice, and route it — not an attempt at the whole build in one task.

  6. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 2, 2026
  7. 78 remaining items

  8. dezren39 commented on Nov 18, 2026

    @dezren39
    MemberAuthor

    Slice 4 routed (task 19696, OpenChamber scheduled lane). Slice 4 is the live head after slices 1–3 landed. The req-4 design spec is recorded on #10910: #4822/#4828/#5164 already cover spend/token attribution, while this remainder covers outcome counts (issues/PRs created, comments/reviews, description edits, branch commits) with exact GitHub evidence and job/model/session rollups. Its first implementation piece is enqueued as task 20799 in repo-health-code-pilot (dedupe key repo-health:v1:fix:developing-today/code:issue:10910), scoped to an append-only, replay-safe projector over #5204 hot-list events and explicit identity/source gaps. It does not duplicate spend work or add a second webhook receiver. Slices 5–7 remain sequenced behind slice 4. Fresh revalidation: #2072 and #10910 are OPEN; task 20799 is queued.

  9. removed their assignment
    on Nov 20, 2026
  10. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Picked up by felix — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while felix posts progress markers; after 30 minutes of silence any other worker may pick this up.)

  11. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: progress
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    Reconciliation of this tracker against current origin/main and live systems, and slice 4 unblocked.

    Landed and verified: slice 0 design (task 4722); slice 1 OpenCode usage exporter (PR #4680, installed and ticking); slice 2 webhook ingestion + hot list (#5204 closed, PR #5327) with the aggregator consumer live (pm-stack/aggregator/src/github-hot-list.ts, coverage documented in activity.ts); slice 3 queue/PM integration views (#7078 closed, PR #8549); req 4's spend half (#4822 closed, PRs #4828/#5164 — spend-attribution.ts projects usage into per-session/model spend facts).

    Slice 4 (outcome attribution, #10910): the design spec has been recorded on #10910 since 2026-11-18, but its first implementation piece never landed — queue task 20799 was blocked as a packet defect (typed small_fix with a 45-minute lease against an effort/l scope; four lanes picked it up and parked it for exactly that reason). I am landing that first piece now from this seat: the versioned append-only outcome-fact contract + deterministic projector over the #5204 hot-list event kinds, with idempotent event-ID handling, explicit unattributed/source-gap facts, and rebuildable counts, in the aggregator next to spend-attribution.ts.

    Req 5 gap verified live today (2026-11-22): OpenChamber's scheduled-task run history (~/.config/openchamber/scheduled-task-run-history.jsonl on the laptop) carries tokens: null in 5,000 of 5,000 rows. Every row does carry its OpenCode sessionId, so the join key to slice 1's usage export exists — the tokens are recorded in OpenCode's history, just never joined into the run-history row. The fix surface is the OpenChamber fork (run completion) or a later aggregator-side join; recorded here as slice 5 (session identity) input, not silently dropped.

    Still sequenced: slice 5 (session-ID assignment + OpenClaw/Codex mapping — not yet filed as its own issue), slice 6 (quality linkage — not yet filed), slice 7 (projections + accuracy + Muse pool on the PM list — partially advanced elsewhere: the aggregator has quota forecast/analytics today, and the Stage-3 design #1177 / PR #12702 covers forecast promotion; the #2072-specific slice issue is not yet filed). This tracker stays open; slice 4's implementation issue #10910 remains the live head until the projector lands.

  12. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: progress
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    Slice 4's first piece landed as PR #12709 (outcome-fact contract + deterministic projector + append-only fact store, in the aggregator) — details and the remaining slice-4 work (live consumer wiring, outcome view) are recorded on #10910. The reconciliation posted earlier today stands: slices 0–3 and the spend half of req 4 are landed; slices 5–7 remain sequenced behind slice 4's remainder, with the OpenChamber run-history tokens: null finding (verified live today, 5,000/5,000 rows) recorded as slice 5 input.

  13. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Released by felix (outcome: free). Reconciled (slices 0-3 + spend landed; slice 4 design on #10910); landed slice 4 first piece as PR #12709 (outcome attribution projector); OpenChamber run-history tokens:null verified live (5000/5000) and recorded as slice 5 input. Tracker stays open.

  14. added and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 22, 2026
  15. added a commit that references this issue on Nov 22, 2026
  16. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: merged
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    Merged: #12709 — slice 4's first piece: the outcome-fact contract + projector.

    pm-stack/aggregator/src/outcome-attribution.ts implements #10910's spec: hot-list rows project to versioned, append-only outcome facts (issue/PR created, comment/review submitted, description edited, commit pushed, other — nothing silently dropped), each carrying its original event id and canonical source link. Job/session/model identities attach only through caller-supplied authoritative bindings — never inferred from the GitHub actor; everything else is explicitly unattributed. A missing or failed source yields a source-gap fact and null totals, never a zero-activity sweep. Felix re-ran the suite at review: 8/8, 103 expects; the lane's full aggregator run was 3179 pass with only the known pre-existing environmental four failing. Purely additive, no new dependencies.

    This unblocks slice 4's remainder: the live cadence wiring (a consumer on the aggregator's sweep fed by real binding records) and the outcome/rollup view, both named on #10910. Also recorded today on #2072: the OpenChamber run-history tokens:null gap (5,000 of 5,000 rows, verified live) is in scope as slice 5 input — every row carries its OpenCode sessionId, so the join key to the usage export exists.

  17. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: progress
    by: agent archer (lane io, Muse sandbox seat)
    at: 2026-11-23

    Slice 4 (#10910) update: the live cadence wiring remainder landed as PR #13022 (merged 10dfbe9020fe) — a GithubOutcomeConsumer now sweeps the #5204 hot list on the aggregator's cadence under its own projector checkpoint and projects each fixed high-water into the append-only outcome-fact ledger, joining events to jobs/sessions/models only through JSONL binding records (missing file = explicitly unattributed; corrupt file = visible sweep failure). Full record on #10910. Slice 4's one remaining piece is the outcome/rollup view with issue/job drill-through, still tracked on #10910.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    design/executor-expansionDesign: executor-expansion - all issues of this effort carry iteffort/lLarge: multi-day or open-ended; expect staged check-insepic/pm-stackReprioritization program epic (2026-11-12)kind/enhancementmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivequeue/queuedHas a queued queue tasksource/humanFiled directly by a humanstatus:in-reviewtask/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