Skip to content

Enforce state-first telemetry recording transactions - #341

Open
gmemuriuki wants to merge 2 commits into
telemetry/recording-write-seamfrom
telemetry/recording-transaction
Open

gmemuriuki wants to merge 2 commits into
telemetry/recording-write-seamfrom
telemetry/recording-transaction

Conversation

@gmemuriuki

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR makes private-state persistence the prerequisite for publishing one telemetry recording. It does not connect recording to production callers yet.

The state layer stages the mutated private state and its aggregate snapshot as one unpublished value. Storage finishes metric, event, and private-state preparation before changing any file, then atomically replaces private state to mint the only lock-bound receipt allowed to publish public telemetry.

Publication gives low-volume events first claim on the remaining daily allowance because they cannot be reconstructed, while the cumulative metric snapshot can recover on a later operation. Event and metric writes are attempted independently, and their outcomes retain only bounded failure stages and I/O error kinds.

Dropping a persisted receipt without attempting publication is loud. Tests cover preparation without writes, private-state failure, event and metric partial failures, storage-marker closure, metric suppression, day mismatches, publication ordering, and receipt behavior during panics and unwinding.

Disclosure questions

AI disclosure.

  • The AI tool authored large parts of the code

Questions for reviewers.

Does the staged-value and lock-bound receipt API make publication-before-persistence unrepresentable, and do the partial-failure outcomes preserve the safest recoverable behavior?

@gmemuriuki
gmemuriuki force-pushed the telemetry/recording-transaction branch from ac4f4cb to 9150c22 Compare October 14, 2026 07:14
@gmemuriuki
gmemuriuki added this pull request to stack #331 October 14, 2026 07:16
@gmemuriuki gmemuriuki self-assigned this Oct 14, 2026
@gmemuriuki
gmemuriuki force-pushed the telemetry/recording-transaction branch from 9150c22 to d8539a6 Compare October 14, 2026 07:51
@nikomatsakis
nikomatsakis force-pushed the telemetry/recording-transaction branch from d8539a6 to dc6a328 Compare October 16, 2026 09:02
@gmemuriuki
gmemuriuki force-pushed the telemetry/recording-transaction branch 2 times, most recently from 2a78f34 to da2b2c5 Compare October 20, 2026 13:26
Separate private-state validation and serialization from atomic
replacement. Pass a bounded prepared value to the locked writer so the
recording transaction can finish serialization before changing a file.

Keep replacement failures scoped to the atomic write stages and update
the storage seam tests for the new boundary.
Stage each accepted recording as one private-state and snapshot unit.
Prepare every output before touching storage, then replace private
state to mint the only receipt allowed to publish public telemetry.

Tie that receipt to the held storage lock. Publish low-volume events
before remeasuring and replacing aggregate metrics, while attempting
both public writes independently and retaining only bounded failure
stages and I/O error kinds.

Make skipped publication loud, cover storage-limit and partial-failure
boundaries, and document the state-first transaction contract.
@gmemuriuki
gmemuriuki force-pushed the telemetry/recording-transaction branch from da2b2c5 to 7767374 Compare October 21, 2026 07:23

This branch has not been deployed

No deployments
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