Repository navigation
chore(function): send hits to the r2 data lake - #8550
Merged
Merged
Conversation
This was referenced Oct 1, 2026
The opencode S3 data lake is retired. Send the models.dev hit event to the platform lake's event stream instead, using the source/type/timestamp/payload envelope that the platform's models.hit table projects, and add a script that backfills the hits recorded in the S3 lake. The worker now needs the LakeEndpoint and LakeToken secrets in place of LakeUrl and LakeSecret.
adamdotdevin
force-pushed
the
remove-lake-ingest
branch
from
October 1, 2026 18:51
ac55282 to
00b35bc
Compare
Contributor
|
No actionable findings. |
Contributor
|
No actionable findings. |
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.
Summary
Moves
models.hitingestion from the retained legacy S3 Tables lake (anomalyco/opencode#52514) into the platform R2 lake. S3 data and Athena access remain available to the internal dashboards; anomalyco/opencode#52515 stays on hold.{source: "models", type: "hit", timestamp, payload}, withmethod,path,useragent,ip, andcf_countryin the payload. anomalyco/anomaly#674 projects these into amodels.hittable. PostHog tracking is unchanged.packages/core/src/hit.ts, so live hits and the backfill produce the same rows.packages/core/script/backfill-hits.ts, which exports the hits already recorded in the S3 lake and replays them into the stream with their original timestamps.Rollout
models.hittable exists before hits arrive.devstage, which serves models.dev. The endpoint is in thelakeoutput of theanomalyco/platform/productionstack, and the token needs the Workers Pipelines Send permission. Missing secrets fail deployment; follow-up fix(function): reject empty lake secrets #8579 also rejects empty token values and invalid stream endpoints.bunx sst secret remove LakeUrl --stage dev --fallbackandbunx sst secret remove LakeSecret --stage dev --fallback(these legacy values were fallback secrets).Backfill
Run this after the deploy and before the S3 lake is ever deleted. Wait for the old Worker to stop and Firehose to drain, then export every S3 hit. Do not use the first R2 hit as a cutoff: old and new Worker versions can overlap.
For small exports:
The HTTP replay measures UTF-8 bytes, rejects invalid timestamps, validates the checkpoint against the endpoint and export hashes, and resumes accepted batches. Retries or a crash before checkpointing can duplicate submissions; reconcile counts before declaring completion.
The production source has approximately 2.6 billion hits. For that volume,
packages/core/script/backfill-hits-glue.pyreuses the existing Console generation-backfill Glue job with an overridden script location and separate checkpoint prefix. It reads a pinned S3 Tables snapshot, applies the same field mapping, and appends to bothmodels.hitanddefault.eventthrough the R2 Iceberg catalog. Each table append is atomic; daily destination counts recover a committed append after interruption and verify every historical day. A mismatched partial destination fails. Start with a bounded dev sample, then useDRY_RUN=trueagainst production before the complete migration. Historical methods are null; path is null when absent in the S3 schema. Keep live producers running.Validation
models.hitanddefault.event. S3 models.hit ingestion remains frozen; old fallback secrets were removed. fix(function): reject empty lake secrets #8579 merged and its worker deployment succeeded.