Skip to content

Latest commit

 

History

History
358 lines (312 loc) · 22.7 KB

activity.md

File metadata and controls

358 lines (312 loc) · 22.7 KB

Prepared activity reports

tauceti activity reads a prepared summary. It does not query GitHub or the shared state server, open SQLite, scan logs, start a collector, or refresh stale data. tauceti workers status includes the same installation-wide summary.

tauceti activity
tauceti activity --worker reviewer --json
tauceti activity --group FLEET_MACHINE_ID

Finished rounds use their finish receipt in trailing 1-hour, 3-hour, 24-hour, and 7-day windows and an All time column. The type is the final selected work unit, such as roadmap, review, fix, or security-audit; fallback candidates are not additional rounds. All supported round types appear even when their counts are zero; the prepared summary publishes the worker taxonomy for other consumers. No-work surveys have their own row. Admission/GitHub waiting attempts and dry runs are excluded. Failed/interrupted rounds are included, with a failure subset (including timeouts). Running rounds and processes interrupted without a finish receipt are separate. The current "workers working" count is distinct workers with an active work round, excluding workers waiting for capacity or budget; it can lag until the next preparation. Discovery of an interruption never supplies a fabricated finish time. The "Round reporting gaps" line shows 1-hour and 24-hour counts by round start time, and the age of the latest affected start. It is omitted when all gaps have starts older than 24 hours. A gap from the last hour also shows the worker and round ID for finding its log. A missing finish can follow an intentional stop or a crash; it is not pending work, and no exit cause or time is inferred. Historical totals and exact identities remain in JSON. Older prepared summaries show the retained total with recent counts marked unavailable. Fleet recent counts require timing details from every host.

PR authorship comes from successful tracked creation, not the entire GitHub account's history. Authored counts use creation time; landed counts use landing time, including PRs created before the window. Open PRs are the current last-known stock. Unknown states, landing evidence, and historical outcomes are explicit. Closed never means landed. Bors squash-merges can leave GitHub's state as closed; the shared server supplies the recorded promotion to main, bound to the exact approved PR head and constructed batch commit. Titles, reviews, CI success and staging pushes are not landing evidence. Ordinary closed PRs do not produce a missing-landing warning.

Costs and landed PR output

Average API spending has 1h, 3h, 24h, 7d and All time columns in $/hour. It uses accrued conversation costs, including running and interrupted work and reviews. Admission reservations do not enter this rate. Each average divides by elapsed recorded time within that window, so a new installation is not diluted by hours before recording began. Worker-hours recorded adds time across completed and currently running native rounds, clipped to each window. Capacity/budget/quota waiting and interruptions without a known end do not inflate it. Failed rounds with recorded durations still count. The report shows worker-hours first, then API dollars per worker-hour (accrued spending divided by worker-hours) and API dollars per elapsed hour. Both spending rows include the minute-scale live estimate when available, falling back to recorded usage for older snapshots. Active-session cost reservations do not enter either spending rate. Zero recorded worker-hours leave the worker-hour rate unavailable. Fleet averages pool spending over the longest recorded duration covered by their host summaries; parallel machines do not add elapsed wall-clock hours. Missing spending data leaves the fleet rate unavailable. Preparation reuses the existing local budget cache and collector, with no extra tasks or GitHub requests.

Cost estimates have 24h, 7 days and All time columns. They pool every conversation in the reported worker/machine scope, including reviews and fixes on PRs initiated elsewhere. Native final costs correct response-level estimates at their usage timestamps; ongoing sessions use recorded usage, shown separately as running usage. Legacy costs without response timing are spread over their conversation duration. These are API costs, not machine charges or subscription fees. Reading the ledger never changes it. Closed history is indexed once; routine preparation processes only ledger changes, changed/live invocation evidence, and reporting-window expirations. The cost breakdown lists completed sessions, live usage, and the estimated total. Unresolved stopped usage estimates appear only when nonzero or unavailable; an all-zero row is omitted. Settled estimates already belong to completed sessions; recovered estimates are a subset of those. These diagnostic subsets remain in JSON but are omitted from the display to avoid suggesting they should be added again. Healthy accounting adds no diagnostic lines. Unresolved stopped conversations and stale live estimates still produce warnings.

The 24-hour and seven-day denominators contain every fleet-created PR that landed in that window, regardless of when it was opened. All time includes all retained fleet-created PRs with verified landing evidence. Older creation receipts remain eligible, including PRs opened before local activity recording began; an upgrade replays retained PR journals to restore identities previously removed by the history cutoff. PRs opened outside the fleet are excluded. Open, closed unmerged, and unknown-state PRs without landing evidence contribute nothing. Reviews and other assists never add another author's LOC to this denominator. Fleet totals pool costs and landed LOC before dividing; they do not average machine ratios. The display shows landed Lean lines added, estimated API dollars per landed line, and measured-PR coverage when incomplete.

PR state, landing evidence and exact head/base identities come from the shared GitHub state server. LOC uses its cached measurement when available. Otherwise, the existing background refresher fetches the recorded commits into a local bare Git cache and counts .lean additions and deletions in base...head. Renames use the destination filename, and complete diff totals must agree with available PR metadata. Ordinary Git refs preserve downloaded history for later fetches. Failed or missing state observations never trigger Git work; failed Git work leaves the count unknown and normal refresh retries. No Git work runs in status.

File-derived measurements require complete cached file lists and immutable URL and total validation; Git-derived measurements bind the exact head/base pair. The observation route never schedules collection or falls back to GitHub. Missing or stale LOC is extrapolated from measured landed PRs in the same window: measured LOC per measured PR, multiplied by the number of landed PRs. These estimates carry ~ and show measured-PR coverage. With no measured LOC, missing LOC contributes zero; positive spending divided by zero LOC displays $∞ (zero spending displays $0.0000). Missing financial data remains explicitly unavailable. Fleet totals pool measurement counts and costs before estimating and dividing. Older prepared creation-cohort summaries cannot supply landing-window totals; they show unavailable LOC until refreshed, including fleets with mixed collector versions. Status never relabels the old figures or fetches replacement data. Cost preparation runs in the existing background collector; activity and workers status still only read small JSON summaries.

Credit for reviewing and fixing other contributors' PRs

The raw authored-LOC figures remain visible. Attributed landed Lean LOC also credits review and fix work on other contributors' landed PRs, and reduces our credit when other contributors review ours. There is no fixed author/reviewer split. For each landed PR:

outside review cost = outside review passes × our measured cost per review pass
outside production cost = 0 for our PRs
                        = max(0, measured production $/LOC × LOC − our fixes) otherwise
credited LOC = LOC × our PR cost / (our PR cost + outside costs)

Our PR cost includes authoring, reviews and fixes (fix, fix-ci, rebase, lint-repair, overlap-fix, and recovery continuations), accumulated through landing. Only completed rounds enter contribution shares or calibration; failed attempts remain fully charged in the spending numerator. Local paid review passes count once even when they launch several model conversations.

The existing shared-state activity response supplies estimated total review passes from cumulative round counters on cached scoreboard comments. It requires complete cached comment history, current compact fragments, and a scoreboard at the observed PR head. Counter granularity can include reply, carry and publication-control passes; this is a participation proxy, not an exact count of model calls. Every observed pass receives equal weight, with no review-quality or dimension judgments. The collector reads the new scalar in its existing PR observation batch. Already-landed PRs receive a bounded initial observation backfill; incomplete cached histories remain unknown and retry at most hourly for a week after landing, with one initial read for older landed PRs. Existing verified LOC at the same head is retained without re-measurement. No GitHub collection is scheduled by these reads.

Existing full local archive clones and worker outboxes remain a fallback when cached counters are unavailable. This fallback deduplicates execution IDs, excludes model-free/shadow records, and requires a consistent normal archive fetch covering landing plus one minute. It never creates or refreshes a clone.

We use the PR's own measured local cost per review pass where possible. When we did none of its reviews, the fallback is our measured average per paid review pass over the last seven days, falling back to retained history. The production rate likewise uses local authoring plus fixes on measured, locally authored landed PRs from the last seven days, with a retained-history fallback. Other contributors' review costs and production costs are estimates based on these local measurements, not their actual bills. Complete cached counters for the observed PR head are estimates of total participation. Their verification can predate landing: reviews normally finish before staging lands a PR, and reporting does not request a new collection of closed PR comments. Late reviews missing from that snapshot can make our share look too high. The oldest counter/archive observation time is available as review_counts_observed_at in per-host cost-window JSON. The collector reads the cache once after landing before parking the PR. Archive fallback observations may lag until an existing review sync runs; hosts that do not push archives may never refresh that fallback. Neither source schedules collection. Missing or stale evidence remains explicitly incomplete. Settled measurements are parked; new local reviews reopen their PR's measurement.

Estimated $ / attributed LOC divides all accrued spending by summed credited LOC. Unsuccessful work, open/unmerged PRs, unlinked costs, and spending on bump, progress, and other maintenance remain fully charged in this numerator. They are amortized across all credited output; we do not estimate whether other contributors paid their share of this overhead. Costs used to estimate a landed PR's share include earlier windows, but exclude work after landing. The spending numerator retains the displayed time window, so daily rates still fluctuate with landing delays.

Landed PRs with attribution data reports coverage. Missing exact LOC, review records, cost links or calibration samples supply no attributed output. With no covered PRs the attributed rate is unavailable; partial output is shown with its coverage rather than silently assuming there was no outside work. The compact report shows estimates with ~ and the coverage counts, without repeated attribution caveats or partial prefixes. An all-missing rate is unavailable. During historical backfill, adjusted LOC and cost rates are unavailable: full spending divided by partly reconstructed credit is not a fleet estimate. The underlying provisional sums remain in JSON for diagnostics, with attribution_backfilling=true. This is separate from an ordinary pending live refresh, which retains the last prepared estimate. Finishing backfill forces a final report refresh before the backfilling flag clears. Unpriced completed local review passes also make coverage incomplete. Older hosts cannot supply attribution until their collectors are updated. Fleet reporting pools dollars and locally estimated credit before dividing. Worker and group summaries share host-wide measured rates and per-PR denominators, so their credited output adds to the host total. Cross-host production assists may overlap; this report does not reconcile global contribution ownership.

Existing admission receipts now retain the round and selected PR identities. The collector preserves round links from existing PR receipts and can recover historical links from an unambiguous PR receipt inside a worker's recorded round interval. Ambiguous links remain unknown; no transcript parsing is used. Archive reads stay in the existing collector, with at most 32 tracked PRs, 256 small round records and a one-second archive work budget per pass. Session links and PR facts use a separate one-second budget with at most 1,024 changed/backfill sessions and 128 keys per fact stage. Backfill progress is explicit. Live session, receipt and PR updates run before historical backfill. Quiet passes read cached reports and do not scan billing history. Current measured rates are recomputed from compact prepared PR facts when evidence or time-window boundaries change, at most every five minutes for large histories; rates are not frozen per PR. Unchanged archive directories require no enumeration or record reads. The default source is the review runner's existing cache; previously recorded worker cache paths are also reused. TAUCETI_ACTIVITY_REVIEW_ARCHIVES can select already-existing archive checkouts (separated by the platform path separator). No new process, clone, archive sync, GitHub request or shared-server request is introduced.

Local work recovery counts come from each worker's state/<worker>/recovery directory: saved, checkouts moved aside, incomplete and corrupt records, with reasons. The background collector prepares them. Fleet summaries add host counts.

Completed review counts include reviews of other authors' PRs. PRs assisted counts distinct PRs in the reported scope with completed review/fix/rebase work or a branch push, excluding that scope's initiated PRs. Multi-host summaries add review events, while unique assisted-PR counts remain per-host.

Existing local CI receipts are imported read-only and incrementally when a fleet controller is present; this adds no GitHub requests. Non-fleet consumers can set TAUCETI_ACTIVITY_CI_DB to a compatible receipt database or omit this optional source.

Preparation and freshness

Workers write small private receipts into ~/.local/state/tauceti/activity/pending. The existing manager prepares reports in a separate thread every minute, outside its supervision loop. Receipts are consumed idempotently into indexed SQLite. A nonblocking preparation lock prevents duplicate collectors. Atomic publication retains last-known data after a failure and exposes that failure and data age. Summaries older than three minutes are labelled stale. Windows end at each summary's preparation time.

PR evidence is silent during normal operation. Status warns only when an unresolved authored PR's stored observation is more than two hours old, or when a PR has waited more than two hours since creation for its first observation. This allows for hourly shared-server inventory reconciliation and a missed cycle; the preparer's five-minute observation reads do not refresh the underlying facts. Closed PRs and PRs with verified landing evidence are excluded because their historical observations may stop updating permanently. The original all-history observation/check timestamps remain available in JSON. Older summaries without unresolved-PR freshness fields do not produce an age warning. Coverage errors remain visible independently of these age warnings. Repository access warnings identify which open/landed counts may be stale and that background preparation retries. Stored observation errors are discarded once the repository has no remaining refresh work, so removed or fully settled repositories do not leave permanent warnings. Worker and group reports include repository failures only when their own PRs or contributions track that repository; unrelated local history does not warn every fleet group. Installation-wide JSON retains the full set of current errors.

Each worker and fleet group has its own small summary file, so status does not load the entire historical inventory. A separate prepared PR identity inventory supports deduplicated aggregation: tauceti activity --inventory (optionally scoped by worker or group).

# Explicit preparation, using configured shared-server observations and cached Git comparisons.
tauceti activity refresh --config ~/.config/tauceti/workers.toml
# Import PR creation receipts since activity recording began; follow by offset.
tauceti activity refresh --backfill

Activity starts with native round lifecycle recording. Preparation discards previously imported resource-log rounds and PR activity before that starting point. Resource logs are never imported, and the cutoff is retained across journal replays and upgrades. Native rounds already recorded are preserved.

Without a running manager, Linux installations can optionally enable preparation:

tauceti activity install-timer --config ~/.config/tauceti/workers.toml
# To stop recurring preparation:
systemctl --user disable --now tauceti-activity.timer

This installs a user timer with one-minute spacing and a lower-priority oneshot service. It needs a working user service manager, not root. It is unnecessary when the manager already prepares this cache. TAUCETI_ACTIVITY_DIR overrides the activity directory and is exported before worker HOME isolation.

No additional GitHub API requests

The preparer requests up to 100 tracked PR headers and cached LOC counts per call to the shared server's authenticated POST /v1/activity, at most once per five minutes per unlanded PR. It uses worker configuration's github_state_url and github_state_token_file, or the corresponding TAUCETI_GITHUB_STATE_* environment variables.

This route never registers demand, configures repository ingestion, schedules repairs, reactivates closed-PR polling, or falls back to the GitHub facade. Redirects are refused. Failed/missing observations retain last-known facts and are not retried before the next interval. The endpoint returns stored states, original observation timestamps and explicit missing numbers. Existing webhook and reconciliation behavior is unchanged.

Existing webhook merged_at data supplies ordinary GitHub merge evidence. The shared server's existing cron also imports Bors's stored candidate/promotion journal at most once per five minutes for the whole fleet. This reads Bors's database, not GitHub, and neither triggers merges nor changes queue state. The activity endpoint only reads the resulting cache. Promotion receipts require matching construction and main-push (or recovery-read) evidence, preserving the original recorded timestamp and exact approved PR head across squash merges.

Already-present TauCetiCI SQLite data remains an optional Bors landing source; set TAUCETI_ACTIVITY_BORS_DB to its path (the default checks the existing fleet cache). Reporting never downloads or refreshes that database.

Accrued spending

Spending rows use recorded usage from running, completed and interrupted conversations, including the cached live adjustment for usage not yet in the historical baseline. Admission reservations are excluded. The existing rows show one estimated rate in each 1h/3h/24h/7d/All-time window. Worker-hours sum recorded work intervals; elapsed hours measure the covered wall-clock interval. Fleet rates pool dollars and worker-hours before dividing; elapsed time is shared across machines, not summed.

Native final costs take precedence. Timestamped, token-priced usage estimates provide running and interrupted costs; a native final correction is distributed across the recorded responses. Legacy costs without response timing are spread uniformly over their conversation duration and remain estimates. This prevents a long session from appearing entirely in the window in which it happens to finish. Unknown usage remains incomplete and reserved; it is not invented as spending.

The cost/LOC numerator is the same accrued spending, including reviews and other fleet conversations. Its denominator is Lean LOC from every fleet-created PR that landed in the window, regardless of opening date. Missing landed LOC uses the extrapolation/zero fallback described above. Costs have 24h, seven-day and all-time windows; hourly rates retain all five activity windows.

Preparation is local and runs in the existing background collector. Reading status performs no transcript scans, SQL queries or additional GitHub requests.

Incremental historical preparation

Historical cost preparation owns an independent SQLite projection and a durable queue of changed invocations. It never takes the admission projection lock. Indexed provider/message ownership limits corrections to affected invocations; settled journals are not rechecked on each report. Recent final-checkpoint races have a bounded retry period. Per-invocation errors roll back and retry separately without repeatedly preparing successful changes; incomplete costs remain visibly unavailable until the retry succeeds.

Persisted prefix totals advance the 1h/3h/24h/7d boundaries by consuming only crossing events. Completed history is not loaded into Python to rebuild totals. The same totals cover worker time, rounds, PR/LOC output, contributions and CI. A new schema or discarded/replaced cache may require one migration scan. --inventory explicitly reads the prepared PR table; the collector does not serialize the entire inventory every minute.

Confirmed deferred publications retain their original worker, host and round ID. A successful PR creation reconciles an unconfirmed authoring round; a branch push or closure reconciles an unconfirmed repair round. This changes only the outcome, keeping the original finish timestamp and counts. Receipt order and duplicate replays do not change the result. Execution failures and rounds without a recorded finish remain separate; replies alone do not prove a repair that required a push. Legacy intents without a saved round ID never borrow the round draining them.