Skip to content

chore: promote staging to main - #722

Merged
izadoesdev merged 15 commits into
mainfrom
staging
Sep 4, 2026
Merged

chore: promote staging to main#722
izadoesdev merged 15 commits into
mainfrom
staging

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Sep 4, 2026

Copy link
Copy Markdown
Member

Summary

  • Promote the current staging release set to main.
  • Includes the custom-events partition migration, profile-query optimization, Vector canary repair, and Bun 1.4.1 upgrade.

Validation

  • bun run lint
  • bun run check-types
  • bun run test

Summary by cubic

Promotes staging's release set to main with monthly analytics.custom_events partitions, the profile-query alias fix, a Vector canary update, and Bun 1.4.1. Custom events no longer store delivery_id; Basket keeps it only for Kafka keys and ClickHouse dedup tokens while stripping it from direct ClickHouse fallback rows, and non-custom Kafka keys are unchanged. Profile queries now include telemetry for aliases established only by custom events.

Migration

  • Run the operator-managed shadow-table migration with ingestion frozen; it swaps in the monthly table, recreates the custom-event identity-map views, and keeps the old table as analytics.custom_events_v2 for verification and rollback.
  • Deploy the Basket fallback change to all writers before migrating; Vector skips the unknown delivery_id, so Kafka payloads need no change.
  • CI canaries now identify custom events through properties.canary_id.

Dependencies

  • Bun 1.4.1 changes localhost resolution and TLS hostname verification; watch the health check and Links/Basket Redpanda producers.

Written for commit 5684a40. Summary will update on new commits.

Review in cubic

Rebuilt analytics.custom_events and swapped it in via EXCHANGE TABLES ON
CLUSTER: 106.01 MiB -> 59.54 MiB (-43.9%), 433 -> 32 parts, 315 -> 12
partitions.

Drops delivery_id entirely. Four days of production query_log show zero
SELECTs against it; nothing in the codebase reads it. Its real uses are
write-path only - an in-memory dedup key in event-service and the Kafka
message key in producer - and the table is ReplicatedMergeTree, not
Replacing, so it was never a storage-level dedup key either. It was 37.6
MiB of incompressible SHA-256 hex, 36% of the table. Basket still generates
it for Kafka keying; Vector has skip_unknown_fields so the now-unknown
field is ignored on insert.

Partitioning moves toDate -> toYYYYMM. Daily partitions held ~8.9k rows,
about one granule each, which set a floor of one granule read per partition
in range: a 31-day scan read 257,516 rows and now reads 16,384 (15.7x).

Codecs measured in isolation on a full copy rather than combined:
properties ZSTD(1) -> ZSTD(6) (-13.3%); LowCardinality on owner_id (-95%)
and website_id. Left timestamp on Delta - DoubleDelta measured 28% worse
because timestamp is third in the sort key and only monotonic within runs.
Left Nullable on anonymous_id/session_id - removing it measured no gain.

The previous table is retained as analytics.custom_events_v2 pending
verification.
Bumps every pin that names a runtime version: the packageManager field
in the root and the three apps that carry their own, bun-version across
ten workflow steps, and the oven/bun base images in all eight
Dockerfiles.

@types/bun stays on 1.4.0 because 1.4.1 is not published; the types
trail the runtime release.

Two changes in 1.4.1 touch this repo and are worth watching on the first
CI run. localhost now bypasses the system resolver, and the health check
talks to services on localhost. TLS verification now reads the URL
hostname rather than the Host header, and the links and basket producers
reach redpanda over TLS.

(cherry picked from commit 375a3b2)
@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
dashboard (staging) Ready Ready Preview Sep 4, 2026 8:44pm UTC
databuddy-status Ready Ready Preview Sep 4, 2026 8:44pm UTC
documentation (staging) Ready Ready Preview Sep 4, 2026 8:44pm UTC

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Team

Run ID: b4e1238e-6ddd-43ee-adb2-f50519640612

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR promotes several staging changes: it upgrades build and runtime environments to Bun 1.4.1, changes the custom_events ClickHouse schema to monthly partitions, repairs the Vector delivery canary, and optimizes profile identity queries.

  • The Bun and Vector-canary changes are internally consistent.
  • The profile-query optimization preserves the prior alias set and adds coverage for custom-event-only identities.
  • The ClickHouse reference schema lacks the required repeatable forward migration for existing environments.
  • The new integration test violates the repository’s explicit-type requirement.

Confidence Score: 4/5

This PR should not merge until the custom-events schema change has a tracked forward migration and the explicit-type repository requirement is satisfied.

Existing ClickHouse tables will ignore the edited bootstrap DDL, leaving environments on the old partition and column shape and causing verification drift; the new test also violates an explicit repository typing rule.

Files Needing Attention: packages/db/src/clickhouse/schema/analytics/core/custom_events.sql; packages/ai/src/query/builder-execution.test.ts

Important Files Changed

Filename Overview
packages/db/src/clickhouse/schema/analytics/core/custom_events.sql Changes codecs, removes delivery_id, and replaces daily partitions with monthly partitions without adding the forward migration required for deployed tables.
packages/db/src/clickhouse/schema/tables.generated.ts Keeps generated custom-event row and insert contracts aligned with the updated reference DDL.
packages/ai/src/query/builders/profiles.ts Reuses target anonymous IDs for visitor-limited profile queries without narrowing the prior identity set.
packages/ai/src/query/builder-execution.test.ts Adds useful custom-event-only alias coverage but types the returned activity arrays as unknown[].
.github/workflows/health-check.yml Moves the canary identifier into JSON properties and queries it using the matching ClickHouse JSON accessor.
package.json Updates the root package-manager declaration consistently to Bun 1.4.1.

Reviews (1): Last reviewed commit: "chore(deps): upgrade bun to 1.4.1" | Re-trigger Greptile

)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/analytics_custom_events', '{replica}')
PARTITION BY toDate(timestamp)
PARTITION BY toYYYYMM(timestamp)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Migration Is Missing

This changes the reference table to monthly partitions and removes delivery_id, but existing installations will not receive those changes. clickhouse:init executes CREATE TABLE IF NOT EXISTS, which is a no-op for a deployed table, and this PR does not include the required forward migration. Environments that were not manually migrated will retain the old schema, fail schema verification, and miss the intended partition optimization. Add a tracked shadow-table migration that can be applied consistently to every environment.

Knowledge Base Used: Data storage and schema

Comment on lines +576 to +578
events: unknown[];
session_id: string;
web_vitals: unknown[];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Explicit Types Are Required

The new test declares events and web_vitals as unknown[]. This violates the repository directive to use proper explicit types instead of any, unknown, or never, and it prevents TypeScript from detecting malformed query output. Define explicit tuple types for the activity and web-vital rows. This repository requirement must be satisfied before merging.

Context Used: Basic guidelines for the project so vibe coders do... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@vercel
vercel Bot temporarily deployed to staging – documentation September 4, 2026 12:52 Inactive
@unkey-deploy

unkey-deploy Bot commented Sep 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Unkey Deploy

Name Status Preview Inspect Updated (UTC)
links (preview) Ready Visit Preview Inspect Sep 4, 2026 8:44pm

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found and verified against the latest diff

Confidence score: 2/5

  • packages/db/src/clickhouse/schema/analytics/core/custom_events.sql omits delivery_id even though fresh-bootstrap delivery sends it, which can break custom-event ingestion; restore the column or coordinate producer and migration changes.
  • The same reference DDL change will not alter the existing analytics.custom_events table, leaving production on the old schema after promotion; add and run a forward shadow-table/backfill/swap migration before updating the reference.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/db/src/clickhouse/schema/analytics/core/custom_events.sql">

<violation number="1" location="packages/db/src/clickhouse/schema/analytics/core/custom_events.sql:13">
P1: On a fresh bootstrap, custom-event delivery sends `delivery_id` but this definition no longer declares it. Restore the column here; removing it would require a coordinated producer and migration change.</violation>

<violation number="2" location="packages/db/src/clickhouse/schema/analytics/core/custom_events.sql:21">
P2: Changing this reference DDL does not repartition the existing `analytics.custom_events` table. Add and run a forward shadow-table/backfill/swap migration before updating the reference, otherwise the promoted production table remains daily-partitioned.</violation>
</file>

Shadow auto-approve: would not auto-approve because issues were found.

Re-trigger cubic

`profile_id` String DEFAULT '',
`delivery_id` String DEFAULT '' CODEC(ZSTD(1)),
`source` LowCardinality(Nullable(String)),
`profile_id` String DEFAULT '' CODEC(ZSTD(1)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: On a fresh bootstrap, custom-event delivery sends delivery_id but this definition no longer declares it. Restore the column here; removing it would require a coordinated producer and migration change.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/db/src/clickhouse/schema/analytics/core/custom_events.sql, line 13:

<comment>On a fresh bootstrap, custom-event delivery sends `delivery_id` but this definition no longer declares it. Restore the column here; removing it would require a coordinated producer and migration change.</comment>

<file context>
@@ -1,24 +1,23 @@
-	`profile_id` String DEFAULT '',
-	`delivery_id` String DEFAULT '' CODEC(ZSTD(1)),
+	`source` LowCardinality(Nullable(String)),
+	`profile_id` String DEFAULT '' CODEC(ZSTD(1)),
 	INDEX idx_event_name event_name TYPE bloom_filter(0.01) GRANULARITY 1,
 	INDEX idx_namespace namespace TYPE bloom_filter(0.01) GRANULARITY 1,
</file context>
Suggested change
`profile_id` String DEFAULT '' CODEC(ZSTD(1)),
`profile_id` String DEFAULT '' CODEC(ZSTD(1)),
`delivery_id` String DEFAULT '' CODEC(ZSTD(1)),

)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/analytics_custom_events', '{replica}')
PARTITION BY toDate(timestamp)
PARTITION BY toYYYYMM(timestamp)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Changing this reference DDL does not repartition the existing analytics.custom_events table. Add and run a forward shadow-table/backfill/swap migration before updating the reference, otherwise the promoted production table remains daily-partitioned.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/db/src/clickhouse/schema/analytics/core/custom_events.sql, line 21:

<comment>Changing this reference DDL does not repartition the existing `analytics.custom_events` table. Add and run a forward shadow-table/backfill/swap migration before updating the reference, otherwise the promoted production table remains daily-partitioned.</comment>

<file context>
@@ -1,24 +1,23 @@
 )
 ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/analytics_custom_events', '{replica}')
-PARTITION BY toDate(timestamp)
+PARTITION BY toYYYYMM(timestamp)
 ORDER BY (owner_id, event_name, timestamp)
 SETTINGS index_granularity = 8192
</file context>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 existing issue remains and no new issues found across 6 files (changes from recent commits).

Confidence score: 3/5

  • packages/db/src/clickhouse/schema/analytics/core/custom_events.sql leaves the old Keeper path on existing clusters, so clickhouse:init can report schema drift and skip the intended repartition migration; add an explicit upgrade path for existing clusters and verify the migration completes.

Shadow auto-approve: would not auto-approve. Auto-approval blocked by 2 unresolved issues from previous reviews.

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 6 files (changes from recent commits).

Shadow auto-approve: would not auto-approve because issues were found.
Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread apps/basket/src/lib/producer.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (changes from recent commits).

Confidence score: 3/5

  • packages/db/src/clickhouse/migrations/20260904_custom_events_repartitioning.md leaves analytics.custom_events_v2 stranded after section-7 recovery while writers resume on the legacy table, so new events can be absent from the final schema; ensure recovery resumes writes to the final schema or explicitly reconciles the cutover before proceeding.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/db/src/clickhouse/migrations/20260904_custom_events_repartitioning.md">

<violation number="1" location="packages/db/src/clickhouse/migrations/20260904_custom_events_repartitioning.md:557">
P2: After a section-7 recovery, writers resume on the recovered legacy `analytics.custom_events`, but `analytics.custom_events_v2` (final schema) is stranded at the recovery cutover and receives no new rows. So by the time you "return to this release," the two tables do not have equal row multisets: every row committed since the recovery exists only in the legacy `custom_events`. The documented forward `EXCHANGE TABLES` cannot merge those rows into the new canonical table — the exchange only swaps names — so either the equal-multiset check fails and the operator is stuck with no given next step, or the operator forces the exchange and the post-recovery writes are dropped when the retained legacy table is deleted. The return procedure must first copy the post-recovery delta into `analytics.custom_events_v2` (the same direction-1 delta copy used in section 7 step 3, with the recovered legacy table as the extra_rows source and `custom_events_v2` as the target) before dropping the views and exchanging forward.</violation>
</file>

Shadow auto-approve: would not auto-approve because issues were found.
Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/db/src/clickhouse/migrations/20260904_custom_events_repartitioning.md Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files (changes from recent commits).

Shadow auto-approve: would not auto-approve because issues were found.
Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/db/src/clickhouse/migrations/20260904_custom_events_repartitioning.md Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 4 files (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Shadow auto-approve: would not auto-approve. Auto-approval blocked by 2 unresolved issues from previous reviews.

Re-trigger cubic

@izadoesdev
izadoesdev merged commit ad6a0cb into main Sep 4, 2026
28 of 29 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