Skip to content

docs(effect-otel): design the flush-shape counters and batch-size histogram (RIG-3694) - #1224

Draft
rigel-mintaka wants to merge 1 commit into
mainfrom
compass-obs/rig-3694-flush-shape
Draft

rigel-mintaka wants to merge 1 commit into
mainfrom
compass-obs/rig-3694-flush-shape

Conversation

@rigel-mintaka

Copy link
Copy Markdown
Contributor

Design only; the implementation follows against this frozen record.

RIG-3694 asks whether turn coalescing produces many tiny batches or
saturates the cap. No existing instrument answers it: the twelve metrics in
Decision 2 count losses, retries, and depths, and a raw batch rate is
uninterpretable without knowing WHY each batch flushed.

The filed size/timer/shutdown taxonomy does not survive contact with the
code. The spine has no timed flush: pumpLoop's only idle wait is the wake
latch, the sole Effect.sleep is the priority-retry backoff, and takeBatch
never waits for a fuller batch. A reason="timer" label could never be
incremented, and an inert label is forbidden, so it is excluded.

The code-true taxonomy is four reasons, not three: full (the cap closed the
batch), drain (teardown residue), short (1..255 queued, the coalescing signal),
and empty. The empty case is reachable and was missed in drafting: a stale
coalesced wake exits the idle loop with both lanes empty, and the terminal
guard returns only when ended, so takeBatch produces a zero-frame batch and
the spine opens a stream carrying nothing. takeBatch has no empty guard.
Counting it separately keeps the other three honest -- folded into short it
would inflate the tiny-batch rate that is precisely the signal this issue
wants, making a wasted round trip look like aggressive coalescing.

Adds a batch-size histogram, the first in this module. Effect requires an
explicit boundary spec; MetricBoundaries.exponential({start:1,factor:2,
count:10}) gives [1,2,4,8,16,32,64,128,256] plus +Inf, verified by executing
it rather than reading the types. Power-of-two buckets hold constant relative
resolution where the variation is, the top boundary lands exactly on
PUBLISH_BATCH_MAX so saturation is one bucket delta, and +Inf stays
structurally empty as an invariant check.

Purely additive: Decision 2's rows and prose are untouched, following the
Decision 3a precedent in compass-agent-loop-otel. The freeze protects decision
content, and this rewrites none.

Ledger-impact: none

Co-authored-by: Matt Wilkinson matt@rigel.build

…togram (RIG-3694)

Design only; the implementation follows against this frozen record.

RIG-3694 asks whether turn coalescing produces many tiny batches or
saturates the cap. No existing instrument answers it: the twelve metrics in
Decision 2 count losses, retries, and depths, and a raw batch rate is
uninterpretable without knowing WHY each batch flushed.

The filed size/timer/shutdown taxonomy does not survive contact with the
code. The spine has no timed flush: pumpLoop's only idle wait is the wake
latch, the sole Effect.sleep is the priority-retry backoff, and takeBatch
never waits for a fuller batch. A reason="timer" label could never be
incremented, and an inert label is forbidden, so it is excluded.

The code-true taxonomy is four reasons, not three: full (the cap closed the
batch), drain (teardown residue), short (1..255 queued, the coalescing signal),
and empty. The empty case is reachable and was missed in drafting: a stale
coalesced wake exits the idle loop with both lanes empty, and the terminal
guard returns only when `ended`, so takeBatch produces a zero-frame batch and
the spine opens a stream carrying nothing. takeBatch has no empty guard.
Counting it separately keeps the other three honest -- folded into short it
would inflate the tiny-batch rate that is precisely the signal this issue
wants, making a wasted round trip look like aggressive coalescing.

Adds a batch-size histogram, the first in this module. Effect requires an
explicit boundary spec; MetricBoundaries.exponential({start:1,factor:2,
count:10}) gives [1,2,4,8,16,32,64,128,256] plus +Inf, verified by executing
it rather than reading the types. Power-of-two buckets hold constant relative
resolution where the variation is, the top boundary lands exactly on
PUBLISH_BATCH_MAX so saturation is one bucket delta, and +Inf stays
structurally empty as an invariant check.

Purely additive: Decision 2's rows and prose are untouched, following the
Decision 3a precedent in compass-agent-loop-otel. The freeze protects decision
content, and this rewrites none.

Ledger-impact: none

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@linear-code

linear-code Bot commented Sep 14, 2026

Copy link
Copy Markdown

RIG-3694

@trunk-io

trunk-io Bot commented Sep 14, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

Copy link
Copy Markdown

Compass engineering docs preview: https://compass-obs-rig-3694-flush-s.compass-eng-docs.pages.dev

Deployed from compass-obs/rig-3694-flush-shape at 8b9f190.

Changed pages:

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant