Repository navigation
Keep historical foreign-advert flags when archived nodes return - #2498
Conversation
|
Kent Beck Gate: PASS (test quality) on |
|
Could a maintainer rerun the failed jobs on The required Go build and tests and the ingestor race check passed. GitHub requires repository-admin rights for the retry I requested. The first-frame overlap also reproduced on current master and is tracked separately in #2499. |
4296502 to
0e02b50
Compare
|
Kent Beck Gate: PASS (test quality) at |
|
The retry on the old revision stayed at attempt 1. I rebased the two archive commits onto master after #2500 landed. Both patches compare equal to their previously reviewed versions. An existing database now restores the historical flag when an archived node returns. The map and mobile navigation checks passed locally, and all three browser shards passed on |
zfouts
left a comment
There was a problem hiding this comment.
Reviewed at eec8b815. Approving.
- The flag was already sticky for active nodes (
MarkNodeForeignonly sets it, and nothing clears it). This carries the same rule across archive and return, which matchesnode_visibility.go's "the ingestor only ever sets it". UpsertNodeis the only insert path intonodesandMoveStaleNodesthe only one intoinactive_nodes, so no write path is missed.- Mixing
?1with plain?is valid in SQLite: the plain?after it continue from 8. - The
UPDATEbefore the REPLACE inMoveStaleNodesrepairs rows an older ingestor reactivated with the flag at 0. - Tests cover flagged, unflagged, legacy NULL, active flagged and brand-new keys, reopen a database from the old ingestor and run retention before return. The ingestor foreign, stale, upsert and retention tests pass locally.
Nits:
- Every advert upsert now looks up
inactive_nodes(cmd/ingestor/db.go:1046-1048). TheEXISTSsits inVALUES, so it runs before conflict detection for every advert, not just returning nodes. It's a primary-key lookup, and the PR's 1.89 to 2.07 ms measurement for active adverts makes it acceptable on the ingest path. - A foreign flag can't be cleared now. The
inactive_nodesrow isn't deleted when a node returns (that predates this PR), so after an operator widens the geofilter, a node flagged once stays foreign. That was already true for active nodes; a sentence in the PR body would make it explicit.
FYI for merge order: #2396 (Postgres) rewrites the same node upsert and archive insert, so whichever lands second needs a manual port, and the EXISTS … ?1 form needs a Postgres translation. I'll handle that on the #2396 side if this lands first.
… and the advert reception changes to Postgres Brings in 10 master commits: Kpa-clawbot#2366 (catalogue key tier), Kpa-clawbot#2497 (regions count only received adverts), Kpa-clawbot#2498 (archived foreign-advert flags), Kpa-clawbot#2492 (observer comparison), Kpa-clawbot#2511, Kpa-clawbot#2513, Kpa-clawbot#2514, Kpa-clawbot#2517, Kpa-clawbot#2518, Kpa-clawbot#2519. Conflicts: - cmd/ingestor/approved_channels.go: both sides added a mutex to channelKeySet. One mu now serialises refresh, master's setCatalog and the branch's Close, and guards the users.db/Postgres accounts readers as well as master's approvedNames and catalogue tier. - cmd/ingestor/db.go, nodes upsert: master's foreign_advert carry-over on top of the branch's qualified columns and lastSeenClampSQL. Master looked up the archived flag with ?1, which dbx.Rebind turns into $11 on Postgres; it is now a plain ? bound to the public key again, and the EXISTS is wrapped in CASE so Postgres stores 0/1 in the BIGINT column. - cmd/ingestor/db.go, MoveStaleNodes: master's UPDATE that restores an archived foreign flag runs before the branch's portable moveStaleNodesSQL (not master's INSERT OR REPLACE ... SELECT *), with IS DISTINCT FROM 1 instead of the SQLite-only IS NOT 1. Ported to Postgres: - catalog_keys (Kpa-clawbot#2366): pgschema migration 0004_catalog_keys.sql (same columns, CHECKs, defaults and key; LatestVersion 4), the table in sqlite_endstate.sql, and the worker's upsert sets updated_at from excluded.updated_at instead of strftime('%s','now'). - corescope-migrate copies catalog_keys and verify never prints catalog_keys.key_hex (channel secrets), for any store. - GetNodes region filter (Kpa-clawbot#2497) and the observer comparison (Kpa-clawbot#2492) used IS NOT 'tx'; both use IS DISTINCT FROM 'tx'. The comparison's ORDER BY label COLLATE NOCASE is lower(<label expression>) on Postgres, which folds ASCII only under COLLATE "C", as NOCASE does. - docs/catalogue-keys.md: the revert SQL on PostgreSQL. Tests on both backends: - The catalogue key tests that use a store and the Kpa-clawbot#2498 foreign-advert tests run on SQLite and Postgres (onBothStores; insertTx uses RETURNING). - New dual tests for the observer comparison and the GetNodes region filter. - pgschema: an upgrade from version 3 with data; the control migration tests no longer assume 3 is the latest version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SQLite-only forms master brought in this round (Kpa-clawbot#2492, Kpa-clawbot#2497, Kpa-clawbot#2498, Kpa-clawbot#2366) and in the last one (Kpa-clawbot#2486) were only caught by Postgres test runs. The ingestor's portable-SQL guard now also rejects IS NOT with a number, numbered placeholders (dbx.Rebind turns ?1 into $11) and strftime; the server gets a guard for IS NOT with a literal and numbered placeholders. Both scanners have self-tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #2496. Related to #730.
When an archived node returns with an ordinary advert, the upsert restores the foreign flag retained for that public key. A previously returned node recovers on its next advert. If it ages out first, retention preserves that evidence before replacing its archive row.
Rebased onto
1c5ec2fad, which includes the mobile first-frame correction in #2500. The two archive patches match the previously reviewed patches. In a database made by the old ingestor, the historical map filter showed only the returning flagged node after upgrade. Clearing it showed both ordinary controls too. The map suite passed 77/77 and both motion preferences cleared the bar by 20.5 px in the 40/40 navigation suite.Each advert adds an indexed archive-key lookup. The earlier benchmark used 4,000 active and 30,000 archived nodes on these same SQL changes.
WAL/FULL includes variable disk-commit time. Rebased regression