Skip to content

PRD — Fleet activity log

Status: Draft / proposed. Design only; nothing here is implemented yet. Feature: HUB-024 in features/features.yml (status: planned). Requirements: FR7–FR15, NFR4–NFR6 in the root PRD.md, which owns the ids; this document gives the detail. Governing rules: docs/constitution.md and docs/amendments/.

1. Problem

Fleet bots act on many repos, each against the standard it read from that repo's AGENTS.md. Today the only record of what a bot decided is scattered across GitHub (PRs, comments, workflow logs). The operator has to poll GitHub to answer "what did the fleet do, under which rules, and is any bot running against a stale standard?" There is also no record of what bots chose not to do.

2. Goals and non-goals

Goals

  • One append-only log of bot decisions and outcomes, including declines, blocked handoffs and retries.
  • Every decision traceable to the amendment (docs/amendments/NNNN-*.md) whose rule it followed.
  • Logging never blocks, slows or fails a bot's actual work.
  • Standard-version drift visible as rows, not inferred.
  • The Harness Console (tools/console/) as the single reader.

Non-goals

  • Implementing the log, wrapper, store or console page (later PRs).
  • Replacing GitHub as the system of record for PRs, issues or CI.
  • Enforcing the standard or blocking bots on drift: the log reports, it does not gate.
  • Editing or deleting events (corrections are new events).

3. Event schema (append-only) — FR7, FR8

Table fleet_event. Rows are only ever inserted; no update or delete path exists.

Field Type Notes
event_id UUID Generated by the writer; idempotency key on flush
ts timestamp (UTC) When the event happened on the bot, not when it was flushed
bot_id text Stable bot identifier (e.g. lane name from fleet.manifest.yml)
repo text owner/name the bot acted on
task_ref text Task, issue or PR reference (owner/name#123, or a run id)
run_id text Groups the events of one task-handler invocation
event_type enum start, finish, declined, blocked_handoff, retry
standard_version text Stamped from the target repo's AGENTS.md at read time (FR8)
standard_source text Path + commit SHA of the AGENTS.md that was read
decision text What the bot decided (short, structured where possible)
outcome enum success, failure, skipped, pending, unknown
detail JSON Type-specific fields (below)

FR8: the standard version is read once per run from the target repo's AGENTS.md and copied onto every event of that run; if absent, standard_version = 'unknown' (which is itself a drift row).

3.1 What bots did NOT do — FR12, FR13, FR14

Same table, same append-only rules; type-specific fields live in detail.

event_type Required detail fields Req
declined reason (enum: out_of_scope, policy, needs_approval, insufficient_info, other), reason_text, rule_ref (optional amendment) FR12
blocked_handoff blocked_by (bot id or human), handoff_to, why, resolution (resolved, abandoned, open), resolution_text, resolved_ts FR13
retry attempt (1-based), max_attempts, cause, final_outcome (success, gave_up, pending) FR14

A blocked handoff that is later resolved is a new blocked_handoff event with the same run_id and the updated resolution; the latest row wins in reads. A retry sequence logs one retry event per attempt; the last carries the final outcome.

Note: declined, blocked and retry events are expected to be the highest-value learning source in the log. Successes confirm the rules; these events show where the rules, the handoffs or the tooling fall short, and they should be the first thing reviewed when proposing an amendment.

Table fleet_event_amendment (also append-only):

Field Type Notes
event_id UUID FK → fleet_event
amendment text NNNN from docs/amendments/NNNN-*.md
repo text Repo whose amendment log is meant (default bamr87/bamr87)
relation enum followed, cited_for_decline, conflicted

Many-to-many: one decision may follow several amendments. Any decision traces to the rule it followed by joining these tables; an event with no link is reported as "untraced".

5. Write path: fire-and-forget — FR10, NFR4, NFR5

  • Each bot gets a thin wrapper around its task handler: emit start before the handler runs, finish (with outcome) after, in a finally so failures are logged too. Declines, blocked handoffs and retries are emitted by the handler via the same client.
  • emit() appends to a local queue (e.g. JSON-lines spool on the runner) and returns immediately; it never raises into the handler.
  • A background flusher sends batches to the log store; on failure it backs off and keeps the spool. Flush is at-least-once; event_id makes ingestion idempotent.
  • NFR4: a down, slow or misconfigured log never blocks, stalls or fails a bot's work; emit overhead target < 5 ms.
  • NFR5: the spool is bounded; on overflow the oldest events are dropped and a counter event records the loss.
  • No secrets in events: decision, detail and free text are redacted against known token patterns before spooling.

6. Drift query — FR11

Compare each event's standard_version to the current standard version in this monorepo (from AGENTS.md / the published kit version at query time).

SELECT e.ts, e.bot_id, e.repo, e.task_ref, e.standard_version, :current AS current_version
FROM fleet_event e
WHERE e.event_type = 'start' AND e.standard_version IS DISTINCT FROM :current
ORDER BY e.ts DESC;

Each mismatch is a visible row (bot, repo, task, stamped vs current version), never just an aggregate. unknown versions are always shown.

7. Reader: the Harness Console — FR15

The console (tools/console/, see docs/HARNESS.md) is the reader: a page listing recent events filterable by bot, repo, type and outcome; a "did not do" view (declined / blocked / retry); the drift rows from §6; and each event's linked amendments. Decisions and drift appear in one place instead of polling GitHub. The console only reads.

8. Requirements

Id Requirement
FR7 Append-only fleet_event table with the fields in §3
FR8 Standard version stamped from the target repo's AGENTS.md at read time
FR9 fleet_event_amendment link table to docs/amendments/NNNN
FR10 Thin task-handler wrapper emitting start/finish events via a local queue + flusher
FR11 Drift query surfacing every version mismatch as a row
FR12 declined events with reason
FR13 blocked_handoff events: blocking bot, why, resolution
FR14 retry events: attempt count, cause, final outcome
FR15 Harness Console reads and shows events, "did not do" events, amendment links and drift
NFR4 Logging never blocks, stalls or fails bot work
NFR5 Bounded local spool, at-least-once idempotent flush, loss counted
NFR6 Events contain no secrets; free text redacted before spooling

9. Open questions

  • Store: Postgres in the existing tools/dash up stack, a committed JSON-lines file, or both?
  • Exact source of "standard version" in AGENTS.md (a front-matter field, a kit stamp line, or commit SHA)?
  • Retention period and whether old events are compacted into summaries.
  • How bots running in GitHub Actions persist their spool across ephemeral runners.
  • Who records amendment links: the bot (self-reported) or a post-hoc classifier?
  • Should drift ever escalate (issue, notification), or stay report-only?
  • Access control for the console page given the console is published as a static site.