Skip to content

Read time_us from the record envelope, where it actually lives - #12

Merged
DGaffney merged 1 commit into
mainfrom
feat/arrived-at-network-arrival-field
Sep 4, 2026
Merged

DGaffney merged 1 commit into
mainfrom
feat/arrived-at-network-arrival-field

Conversation

@DGaffney

@DGaffney DGaffney commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

hydrate_bulk took time_us from commit.record. It has never been there. Jetstream stamps it on the record envelope, next to did and commit, because it is the firehose consumer's receipt time and not something the posting client writes — commit.record holds only what the client wrote.

So the enriched envelope's time_us has been None on every record this pipeline has ever produced. The visible symptom was the mega archives' time_us column being uniformly NULL, which read as an egress problem.

Why it matters beyond the archives

This is the only faithful "when did the post reach the network" signal Graze has, and it is what the new arrived_at field resolves to (rust-smasher#85, feed-processor#121). createdAt is author-supplied and validated by nothing upstream: 40.9% of *.brid.gy posts sit more than ten minutes from their arrival, p95 4.2h, against 0.70% of everything else.

This fix is not what the consumers depend on

They read message.time_us first — the raw record is passed through whole as message, which is the only reason the value survived at all — so they already work on the backlog. This makes the envelope's own copy agree with them going forward. The test pins that agreement, because a copy that disagreed would make arrived_at mean different things by record age.

Tests

There is no tests/ directory here yet; pyproject.toml already configures pytest with pythonpath = ["src/"], so this is the first thing to use it.

Three of the four tests fail on the pre-fix tree — verified by restoring the old line, not assumed. The fourth (absent stays None) passes either way, which is correct: it pins that absent must not become 0.

Note the single module-level event loop. Hydration._cache_lock is an aiorwlock created at class-definition time and binds to the first loop that takes it, so a fresh asyncio.run per test makes every test after the first raise. That is a property of the production singleton, not of the tests.

🤖 Generated with Claude Code

`hydrate_bulk` took `time_us` from `commit.record`. It has never been there.
Jetstream stamps it on the record envelope, next to `did` and `commit`, because
it is the firehose consumer's receipt time and not something the posting client
writes -- `commit.record` holds only what the client wrote.

So the enriched envelope's `time_us` has been `None` on every record this
pipeline has ever produced. The visible symptom was the mega archives' `time_us`
column being uniformly NULL, which read as an egress problem.

It matters more than the archives. This is the only faithful "when did the post
reach the network" signal Graze has, and it is what the new `arrived_at` field
resolves to (rust-smasher and feed-processor, same branch name). `createdAt` is
author-supplied and validated by nothing upstream: 40.9% of `*.brid.gy` posts
sit more than ten minutes from their arrival, p95 4.2h, against 0.70% of
everything else.

This fix does not make the field work on its own, and is not what the consumers
depend on. They read `message.time_us` first -- the raw record is passed through
whole as `message`, which is the only reason the value survived at all -- so they
already work on the backlog. This makes the envelope's own copy agree with it
going forward. The test pins that agreement, because a copy that disagreed would
make `arrived_at` mean different things by record age.

Three of the four tests fail on the pre-fix tree, verified by restoring the old
line rather than assumed. The fourth (absent stays None) passes either way,
which is correct: it pins that absent must not become 0.

There is no `tests/` directory here yet; `pyproject.toml` already configures
pytest with `pythonpath = ["src/"]`, so this is the first thing to use it. Note
the single module-level event loop -- `Hydration._cache_lock` is an `aiorwlock`
created at class-definition time and binds to the first loop that takes it, so a
fresh `asyncio.run` per test makes every test after the first raise. That is a
property of the production singleton, not of the tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@DGaffney
DGaffney merged commit b1d0226 into main Sep 4, 2026
1 of 3 checks passed
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