Repository navigation
Read time_us from the record envelope, where it actually lives - #12
Merged
Merged
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
hydrate_bulktooktime_usfromcommit.record. It has never been there. Jetstream stamps it on the record envelope, next todidandcommit, because it is the firehose consumer's receipt time and not something the posting client writes —commit.recordholds only what the client wrote.So the enriched envelope's
time_ushas beenNoneon every record this pipeline has ever produced. The visible symptom was the mega archives'time_uscolumn 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_atfield resolves to (rust-smasher#85, feed-processor#121).createdAtis author-supplied and validated by nothing upstream: 40.9% of*.brid.gyposts 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_usfirst — the raw record is passed through whole asmessage, 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 makearrived_atmean different things by record age.Tests
There is no
tests/directory here yet;pyproject.tomlalready configures pytest withpythonpath = ["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 become0.Note the single module-level event loop.
Hydration._cache_lockis anaiorwlockcreated at class-definition time and binds to the first loop that takes it, so a freshasyncio.runper test makes every test after the first raise. That is a property of the production singleton, not of the tests.🤖 Generated with Claude Code