Skip to content

Say why the live feed keys records, and stop citing an upsert - #75

Open
jerome-queck wants to merge 1 commit into
mainfrom
live-feed-says-upsert-and-upstream-does-not
Open

Say why the live feed keys records, and stop citing an upsert#75
jerome-queck wants to merge 1 commit into
mainfrom
live-feed-says-upsert-and-upstream-does-not

Conversation

@jerome-queck

Copy link
Copy Markdown
Member

Two comments in server/openf1/live-feed.ts explained the in-memory keying by an upsert that does
not exist. Upstream's real-time ingestor writes InsertOne per emission
(real_time/processing.py:104util/db.py:348-357), it never calls the upsert_data_sync that
sits next to it, and it creates no index on _key for MongoDB to key on. One record per _key is
what the query API answers with, by grouping on _key and taking the highest _id
(util/db.py:66-75).

The keying itself is correct and stays. Only the reason changes, and the true one is the more
useful: this feed reads the revision stream off MQTT with no query API in front of it, so it must
collapse the revisions itself for the live path to agree with what rest-feed.ts receives for the
same Session.

Comments only — no executable change, test/run green.

The measured mechanism is in #74, which this does not close: what remains there is whether to record
the rule as an ADR, and that is the author's call.

Assisted-by: Claude Opus 5 (reasoning: high)
Co-authored-by: Claude noreply@anthropic.com

The two comments in live-feed.ts justified keying records in memory by an
upsert MongoDB is doing upstream. It is not: upstream's real-time ingestor
appends a row per revision (InsertOne, never ReplaceOne) and there is no index
on the key it would upsert on. The collapsing to one record per key happens in
the query API, on read.

The behaviour the comments defend is right, and its real reason is better —
this feed is handed the revision stream with no query API in front of it, so it
has to collapse the revisions itself in order to agree with what rest-feed.ts
is given for the same Session. Comments only; nothing executable changes.

Investigated in #74.

Assisted-by: Claude Opus 5 (reasoning: high)
Co-authored-by: Claude <noreply@anthropic.com>
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