upsertPricePoints can synthesize an event id from the wall clock, breaking dedupe
メンテナーはふだん 3 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- postgresql, typescript
調査の方向性
Start with src/db.ts and trace upsertPricePoints into synthesizeEventId; compare the timestamp fallback with the identity invariant in prisma/schema.prisma. Add a regression case in src/__tests__/backfill.test.ts for identical points without timestamp or observedAt, then run the full npm test suite. Done when the no-anchor behavior is explicit and repeated ingests preserve idempotency.
索引モデルが issue の本文から書いたものです。
説明
Background
prisma/schema.prisma states the invariant the price-point identity index depends on:
sources with none — AMM/Soroswap pool snapshots, Aquarius, anything added later — get a key synthesized deterministically from the row's content, never from a clock.
synthesizeEventId honours that by hashing the row's content, including the timestamp:
const content = [ network, p.source, p.pairKey, p.poolId ?? '', String(p.ledger),
p.timestamp.toISOString(), String(p.price), ... ]
#394 introduced a fallback in upsertPricePoints (src/db.ts):
const observedAt = p.observedAt ?? p.timestamp ?? new Date()
const timestamp = p.timestamp ?? observedAt
...
eventId: p.eventId || synthesizeEventId(network, { ...p, timestamp })
When a point arrives with neither timestamp nor observedAt, timestamp becomes new Date() — so the synthesized event id now incorporates the wall clock. Two ingests of byte-identical data produce different event ids, the (network, source, eventId) identity index does not match, and skipDuplicates does not skip. The row is inserted twice.
That is the exact failure the identity work in #237 was built to make impossible, and it inflates volume and skews VWAP — silently, because nothing errors.
How it was found
Lens #385 (historical backfill) has a test that is the clearest statement of the contract:
proves idempotency on re-run: second run inserts 0 points and changes nothing
AssertionError: expected 1 to be +0
It passed on that branch against main as of this morning and fails after merging current main. The branch is not at fault — its test is the thing that noticed.
Why it is subtle
Before #394, a point with no timestamp would have thrown on p.timestamp.toISOString(). #394 turned a loud crash into silent non-determinism, which is the worse of the two.
What to build
- Decide what a point with no
timestampmeans. If every real ingester always sets one, the fallback should be an error rather than a clock read — a crash is recoverable, a duplicated money row is not. - If a clock fallback must stay, it must not reach
synthesizeEventId. The id has to be derived only from fields that are stable across runs, and a row with no stable temporal anchor cannot be given a deterministic identity at all — it should be rejected rather than assigned a random one. - Either way,
observedAtitself may keep thenew Date()default; it is "when Lens saw it" and is not part of the identity.
Acceptance criteria
- A point ingested twice with identical content produces the identical
eventId, with notimestampand noobservedAtsupplied - A test that fails against current
mainand passes after - The behaviour for a point with no temporal anchor is explicit — documented, and either rejected or given a non-clock identity
-
src/__tests__/backfill.test.ts's idempotency case passes in a fullnpm testrun, not only in isolation
Notes
Found while reviewing #385, which is blocked on it. That PR should not be asked to fix this — it is a regression in main.
scripts/migrations/2026-10-17-price-point-identity.sql and the @@unique in prisma/schema.prisma are the surrounding context.
- 主要言語
- TypeScript
- スター
- 4
- フォーク
- 71
- 平均マージ
- 3日 6時間
- マージ済み PR(30日)
- 144
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Divinity-Labs/Lens のほかの issue
-
Webhook retries have no jitter, so failures synchronise対応中かも @Richard-tobi が 9 日前に担当しました。 オープンarea:reliability difficulty:easy help wanted points:100 Stellar Wave
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
Divinity-Labs/Lens#341 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 3 日以内に返信
-
GraphQL queries bypass the per-route scope their REST equivalents require対応中かも @sparkysolutions10-pixel が 2 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
Divinity-Labs/Lens#618 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
area:tests automated live-spec-report
難易度 4/5 3〜5日 初心者へのやさしさ 28/100
Divinity-Labs/Lens#606 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信
-
The key is accepted only as a bearer token, and nothing says so対応中かも @krsnak が 8 日前に担当しました。 オープンarea:docs difficulty:easy help wanted points:100 Stellar Wave
Divinity-Labs/Lens#512 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 3 日以内に返信
-
The admin surface has no tests対応中かも @krsnak が 8 日前に担当しました。 オープンarea:testing difficulty:intermediate help wanted points:150 Stellar Wave
Divinity-Labs/Lens#510 · コメント 5 件 · 担当者 1 名 ·
メンテナーはふだん 3 日以内に返信
Divinity-Labs/Lens の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
outline/outline#14348 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Agent import retains quotes in .env API keys followed by inline comments対応中かも @yxr-2025 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
elie222/rakazo#2322 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
awslabs/visual-asset-management-system#804 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
dsh-market/dsh-market#1027 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信