Skip to content

feat(app): merge and source-list primitives for cross-source search - #2883

Draft
teeohhem wants to merge 1 commit into
tom/n2-select-builderfrom
tom/n3-search-primitives
Draft

feat(app): merge and source-list primitives for cross-source search#2883
teeohhem wants to merge 1 commit into
tom/n2-select-builderfrom
tom/n3-search-primitives

Conversation

@teeohhem

Copy link
Copy Markdown
Contributor

Stacked on #2882.

Two pure, fully-tested pieces the search page needs before it can span sources. ~660 lines, more than half of it tests.

The frontier merge interleaves several already-ordered row streams into one timestamp-ordered list, bounded by the timestamp every stream has covered. Rows past that are held back, so the merged timeline never shows a gap a slower stream could still fill; the caller learns which streams hold the frontier so only those fetch another page. Streams that error or are excluded stop bounding the frontier instead of freezing the list. The subtle cases (a window drained vs. a page cut short at its LIMIT, ascending vs. descending, a stream that hasn't returned yet) are what the tests pin down.

The source-list param resolver extends the existing single-source resolver to a list — dedupes, caps, and reports entries it couldn't resolve so one bad name doesn't sink the selection.

No callers yet; the search page picks them up later in the stack.


Compound Engineering
Claude Code

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview Aug 12, 2026 7:19pm
hyperdx-storybook Ready Ready Preview Aug 12, 2026 7:19pm

Request Review

@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 99dec83

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds reusable primitives for cross-source search before their page-level integration.

  • Adds frontier-aware merging of timestamp-ordered source streams.
  • Adds list-based source parameter resolution with deduplication, limits, and partial-resolution reporting.
  • Adds unit coverage for ascending and descending merge behavior and source-list resolution.

Confidence Score: 4/5

The PR is not yet safe to merge because malformed or numeric Unix-second row timestamps can still produce incorrectly filtered or ordered merged results.

The merge implementation continues to pass unchecked Date conversion results into frontier comparisons and sorting, while the existing timestamp utility explicitly normalizes numeric seconds and rejects invalid dates.

Files Needing Attention: packages/app/src/utils/multiSourceMerge.ts

Important Files Changed

Filename Overview
packages/app/src/utils/multiSourceMerge.ts Adds frontier-based stream merging, but the previously reported timestamp validation and numeric normalization defect remains.
packages/app/src/utils/sourceParams.ts Adds list resolution by composing the existing single-source resolver, deduplicating resolved IDs and applying an optional cap.
packages/app/src/utils/tests/multiSourceMerge.test.ts Covers frontier, lagging-stream, direction, and merge behavior but does not cover invalid or numeric Unix-second timestamps.
packages/app/src/utils/tests/sourceParams.test.ts Covers pending, partial resolution, kind filtering, deduplication, and selection limits.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Ordered source streams] --> B[Compute coverage per active stream]
  B --> C[Choose shared frontier]
  C --> D[Hold rows beyond frontier]
  D --> E[Tag and timestamp-sort eligible rows]
  C --> F[Identify streams tied at frontier]
  G[Source parameter list] --> H[Resolve IDs and names]
  H --> I[Deduplicate and cap]
  I --> J[Resolved and unresolved selections]
Loading

Reviews (2): Last reviewed commit: "feat(app): merge and source-list primiti..." | Re-trigger Greptile

Comment on lines +165 to +170
const parseTs = (row: Record<string, any>): number => {
const raw = row[timestampKey];
let ts = tsCache.get(raw);
if (ts === undefined) {
ts = new Date(raw).getTime();
tsCache.set(raw, ts);

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 Validate merged row timestamps

Missing or invalid values produce NaN, which bypasses frontier comparisons and undermines sorting; numeric Unix-second values are interpreted as milliseconds and placed near 1970. Validate each parsed timestamp and normalize supported numeric values before using them for coverage, filtering, or ordering.

Fix in Claude Code Fix in Conductor Fix in Cursor Fix in Codex

Two pure pieces the search page needs before it can span sources.

The merge interleaves several already-ordered row streams into one
timestamp-ordered list, bounded by a "safe frontier": the timestamp every
stream has covered. Rows older than that are held back, so the timeline
never shows a gap a slower stream could still fill, and the caller is told
which streams are holding the frontier so only those need another page.
Streams that error or are excluded stop bounding the frontier rather than
freezing the list.

The param resolver extends the existing single-source one to a list,
deduping, capping, and reporting entries it could not resolve so one bad
name doesn't sink the whole selection.

Both are unit-tested; nothing calls them yet.
@teeohhem
teeohhem force-pushed the tom/n3-search-primitives branch from 99420f8 to 99dec83 Compare August 12, 2026 19:14
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

E2E Test Results

All tests passed • 140 passed • 1 skipped • 632s

Status Count
✅ Passed 140
❌ Failed 0
⚠️ Flaky 0
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

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