upsertPricePoints can synthesize an event id from the wall clock, breaking dedupe
Los mantenedores suelen responder en 3 días
@sparkysolutions10-pixel ya está trabajando en esto.
Desde el 25/10/2026.
- #621 de @sparkysolutions10-pixel — fusionado
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- postgresql, typescript
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 4
- Forks
- 71
- Merge medio
- 3 d 14 h
- PR fusionados (30 d)
- 157
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Divinity-Labs/Lens
-
Webhook retries have no jitter, so failures synchronisePosiblemente ocupada @Richard-tobi la tomó hace 11 días. Abiertoarea:reliability difficulty:easy help wanted points:100 Stellar Wave
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
Divinity-Labs/Lens#341 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 3 días
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Divinity-Labs/Lens#626 ·
Los mantenedores suelen responder en 3 días
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Divinity-Labs/Lens#625 ·
Los mantenedores suelen responder en 3 días
-
Live Service Spec Drift ReportAbiertoarea:tests automated live-spec-report
Dificultad 4/5 3-5 días Aptitud para principiantes 28/100
Divinity-Labs/Lens#606 · 4 comentarios ·
Los mantenedores suelen responder en 3 días
-
The key is accepted only as a bearer token, and nothing says soPosiblemente ocupada @krsnak la tomó hace 9 días. Abiertoarea:docs difficulty:easy help wanted points:100 Stellar Wave
Divinity-Labs/Lens#512 · 4 comentarios · 1 asignado ·
Los mantenedores suelen responder en 3 días
Todos los issues de Divinity-Labs/Lens
Issues similares
-
New icon: `filter-clear`Abiertocalcite-ui-icons enhancement impact - p3 - not time sensitive needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
Esri/calcite-design-system#15467 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
diegosouzapw/OmniRoute#18390 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 86/100
guilhermerodz/input-otp#157 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
davidjerleke/embla-carousel#1414 ·
Los mantenedores suelen responder en 4 días