Files
beacon-server/db/sqlc/querier.go
T
MrAlders0n 9bbf8efee5 release: v2.0.4 (#217)
* perf(routes): batch cross-IATA and hash route search (#216)

One search fired a /routes/cross request per IATA pair (138k on 2026-10-08). Route search now takes an optional iatas list and runs a fixed number of index-backed queries. /info advertises built-in minimum client versions.

* chore: bump version to 2.0.4
2026-10-09 22:17:23 -04:00

459 lines
33 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
package db
import (
"context"
"encoding/json"
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgtype"
)
type Querier interface {
// An empty region places the channel Beacon-wide.
AddChannelConfigScopes(ctx context.Context, arg AddChannelConfigScopesParams) error
AddChannelMembers(ctx context.Context, arg AddChannelMembersParams) error
AddIATAs(ctx context.Context, iatas []string) error
AddRegionIATAs(ctx context.Context, arg AddRegionIATAsParams) error
// Hop prefixes that match >1 node in an IATA, per width. Computed once per reconfirm run.
AmbiguousPrefixes(ctx context.Context) ([]AmbiguousPrefixesRow, error)
CreateAccount(ctx context.Context, name string) (Account, error)
// Lock the current row before deciding the outcome, including when another
// deactivation commits while this statement is waiting for its row lock.
DeactivateAccount(ctx context.Context, id uuid.UUID) (DeactivateAccountRow, error)
DeleteAllChannelMembers(ctx context.Context) error
DeleteChannelConfigScopes(ctx context.Context) error
DeleteChannelMembersNotIn(ctx context.Context, arg DeleteChannelMembersNotInParams) error
// Keeps the channel IATA filter in step with packet retention.
DeleteOldChannelIATAs(ctx context.Context, lastHeard pgtype.Timestamptz) error
// Deletes nodes not seen since the given cutoff. node_iatas and node_neighbors cascade-
// delete via FK. Excludes nodes referenced by observer_owners.owner_node_id -- that FK has
// no ON DELETE action, so deleting one directly would fail the whole statement anyway, and
// an operator manually recorded ownership for that node, so leave it alone even if stale.
// known_routes.node_ids is a plain UUID[] with no FK; a deleted node's id can be left
// dangling in old routes there, but ReconfirmTask already prunes stale/ambiguous routes
// periodically and will clean those up on its own schedule.
DeleteOldNodes(ctx context.Context, lastSeen pgtype.Timestamptz) error
// Opt-in age-out: preserve retained history and manually recorded ownership.
// Bound deletions per cleanup tick and skip observers being updated by ingest.
DeleteOldObservers(ctx context.Context, lastSeen pgtype.Timestamptz) ([]uuid.UUID, error)
// Deletes one bounded cohort (observations cascade). SKIP LOCKED leaves packets an in-flight
// observation insert holds. raw_deleted_before tells the rollup which hours lost raw rows.
DeleteOldPackets(ctx context.Context, arg DeleteOldPacketsParams) (int64, error)
// Bumps coverage when hours go, so cached responses that included them are not reused.
DeleteOldRollups(ctx context.Context, cutoff pgtype.Timestamptz) error
// One batch of routes past retention, or past grace with too few observations.
// GREATEST keeps the scan on idx_known_routes_last_seen.
DeleteOldRoutes(ctx context.Context, arg DeleteOldRoutesParams) (int64, error)
// Deletes telemetry rows older than the given cutoff. Called by the cleanup goroutine.
DeleteOldTelemetry(ctx context.Context, reportedAt pgtype.Timestamptz) error
// Keeps the trace IATA filter in step with packet retention.
DeleteOldTraceIATAs(ctx context.Context, lastHeard pgtype.Timestamptz) error
DeleteOldTraceTags(ctx context.Context, lastHeardAt pgtype.Timestamptz) error
DeleteRegionIATAsNotIn(ctx context.Context, arg DeleteRegionIATAsNotInParams) error
DeleteRollupHour(ctx context.Context, hour pgtype.Timestamptz) error
// Dirty hours that can no longer be re-rolled.
DeleteStaleDirtyHours(ctx context.Context) error
FillRollupObs(ctx context.Context, dollar_1 pgtype.Timestamptz) error
// Marks the hour complete and bumps the revision only when its content changed.
FinishRollupHour(ctx context.Context, arg FinishRollupHourParams) (bool, error)
GetAccount(ctx context.Context, id uuid.UUID) (Account, error)
// Both counters only grow, so their sum changes whenever rolled content or coverage does.
GetAnalyticsRevision(ctx context.Context) (int64, error)
GetChannelByID(ctx context.Context, id int32) (Channel, error)
GetEarliestCompleteRollupHour(ctx context.Context) (pgtype.Timestamptz, error)
// ============================================================
// STATS
// ============================================================
GetHourlyStats(ctx context.Context, arg GetHourlyStatsParams) ([]GetHourlyStatsRow, error)
GetIATA(ctx context.Context, iata string) (IataCode, error)
// An imported MeshMapper boundary overrides the configured one. border is NULL
// when neither exists; a missing row (unknown IATA) is sql.ErrNoRows, same
// not-found distinction GetIATA already makes.
GetIATABorder(ctx context.Context, iata string) (json.RawMessage, error)
// Routes containing @nodes[i] in IATA @iatas[i] (aligned, one node per IATA). The &&
// drives the node_ids GIN index; the indexed check keeps LIMIT counting real matches.
GetKnownRoutesByNodes(ctx context.Context, arg GetKnownRoutesByNodesParams) ([]GetKnownRoutesByNodesRow, error)
GetLatestCompleteRollupHour(ctx context.Context) (pgtype.Timestamptz, error)
// Neighbor rows between @a_nodes and @b_nodes in either orientation: ingest writes
// adverts as (sender, forwarder) but traces as (receiver, sender). Callers normalise.
GetNeighborLinks(ctx context.Context, arg GetNeighborLinksParams) ([]GetNeighborLinksRow, error)
GetNodeByID(ctx context.Context, id uuid.UUID) (GetNodeByIDRow, error)
GetNodeByPubkey(ctx context.Context, publicKey []byte) (uuid.UUID, error)
// Returns the neighbors of a node with details, ordered by most recently seen.
GetNodeNeighbors(ctx context.Context, nodeID uuid.UUID) ([]GetNodeNeighborsRow, error)
GetNodesByIDs(ctx context.Context, dollar_1 []uuid.UUID) ([]GetNodesByIDsRow, error)
GetNodesByPubkeys(ctx context.Context, pubkeys [][]byte) ([]GetNodesByPubkeysRow, error)
// Hour-or-coarser buckets summed from the hourly rollup; same COALESCE-plus-count shape as the raw query.
// Hours from @tail_start on aren't rolled yet and read raw rows.
GetObserverActivityHourly(ctx context.Context, arg GetObserverActivityHourlyParams) ([]GetObserverActivityHourlyRow, error)
// Same rollup/raw-tail split as GetObserverActivityHourly.
GetObserverActivityHourlyPayloadTypes(ctx context.Context, arg GetObserverActivityHourlyPayloadTypesParams) ([]GetObserverActivityHourlyPayloadTypesRow, error)
// Two indexed ranges, bounded to one observer; no legacy presence counters.
GetObserverActivityLiveSummary(ctx context.Context, arg GetObserverActivityLiveSummaryParams) (GetObserverActivityLiveSummaryRow, error)
// Sub-hour activity buckets straight off idx_observations_observer; no join to packets.
// Aggregates are COALESCEd and paired with a count column: sqlc types a cast expression as
// NOT NULL, so the counts are what tell the store a bucket had no costed or no signal rows.
GetObserverActivityRaw(ctx context.Context, arg GetObserverActivityRawParams) ([]GetObserverActivityRawRow, error)
GetObserverActivityRawPayloadTypes(ctx context.Context, arg GetObserverActivityRawPayloadTypesParams) ([]GetObserverActivityRawPayloadTypesRow, error)
GetObserverBrokers(ctx context.Context, observerID uuid.UUID) ([]GetObserverBrokersRow, error)
GetObserverByID(ctx context.Context, id uuid.UUID) (Observer, error)
GetObserverByPubkey(ctx context.Context, publicKey []byte) (Observer, error)
// Count packet identities, not reception rows: a broker repeat or another
// reception by the same observer must not inflate the comparison.
GetObserverComparison(ctx context.Context, arg GetObserverComparisonParams) (GetObserverComparisonRow, error)
GetObserverLastIATA(ctx context.Context, id uuid.UUID) (string, error)
GetObserverRadio(ctx context.Context, id uuid.UUID) (GetObserverRadioRow, error)
GetObserverScopes(ctx context.Context, observerID uuid.UUID) ([]string, error)
GetObserverTelemetry(ctx context.Context, arg GetObserverTelemetryParams) ([]GetObserverTelemetryRow, error)
GetPacketByHash(ctx context.Context, packetHash []byte) (GetPacketByHashRow, error)
// Return distinct observation IATAs in first-heard order for path resolution,
// without fetching full observations separately for every trace packet.
GetPacketsByTraceTag(ctx context.Context, decode string) ([]GetPacketsByTraceTagRow, error)
// All HTTP aggregates read the hourly rollup, never observations.
GetPathStats(ctx context.Context, arg GetPathStatsParams) ([]GetPathStatsRow, error)
GetRadioPresets(ctx context.Context, arg GetRadioPresetsParams) ([]MvRadioPreset, error)
GetRegion(ctx context.Context, id int32) (GetRegionRow, error)
GetRegionBySlug(ctx context.Context, slug string) (GetRegionBySlugRow, error)
GetRegionIATAs(ctx context.Context, regionID int32) ([]string, error)
GetRouteEvidenceRoute(ctx context.Context, arg GetRouteEvidenceRouteParams) (KnownRoute, error)
// Packets and IATAs cover every retained rollup hour; IATAs are those that heard the
// scope's own packets. Observer and node counts are current memberships.
GetScopeByName(ctx context.Context, name string) (GetScopeByNameRow, error)
GetScopeCatalogue(ctx context.Context, arg GetScopeCatalogueParams) (MeshmapperScopeCatalogue, error)
GetScopeNames(ctx context.Context) ([]string, error)
// Packets since the given hour come from the IATA-set rollup (counted once per hour heard).
// Observer and node counts are current memberships; observers filter by their latest IATA.
GetScopeStats(ctx context.Context, arg GetScopeStatsParams) ([]GetScopeStatsRow, error)
// GetScopeStats packet counts split by hour (same window and IATA-set filter), with the
// distinct observers and advertising nodes active in each scope that hour. Empty hours omitted.
GetScopeStatsHourly(ctx context.Context, arg GetScopeStatsHourlyParams) ([]GetScopeStatsHourlyRow, error)
// Read the hourly rollup, never observations on an HTTP request.
// Weight averages by sample counts instead of averaging regional/hourly means.
GetSignalStats(ctx context.Context, arg GetSignalStatsParams) ([]GetSignalStatsRow, error)
// Repeaters/room servers (node_type 2/3) whose current advert-derived clock drift exceeds
// the given threshold in magnitude, worst first. Not time-windowed -- reflects each node's
// latest measured drift, not an aggregate over a period.
// Select the filtered page before aggregating its IATA memberships.
GetStatsClockDrift(ctx context.Context, arg GetStatsClockDriftParams) ([]GetStatsClockDriftRow, error)
// Returns node counts grouped by type, optionally filtered by IATA.
GetStatsNodeTypes(ctx context.Context, dollar_1 []string) ([]GetStatsNodeTypesRow, error)
// Payload-type observation counts since the given hour, from the hourly rollup.
GetStatsPayloadBreakdown(ctx context.Context, arg GetStatsPayloadBreakdownParams) ([]GetStatsPayloadBreakdownRow, error)
// One row per hour in [since, until) plus a summary row (hour NULL) over its complete hours.
// Counts sum; observers, IATAs and scopes are distinct across the window; packets count
// once per hour heard. Each branch pair keeps "all IATAs" and "these IATAs" plans separate.
GetStatsSeries(ctx context.Context, arg GetStatsSeriesParams) ([]GetStatsSeriesRow, error)
// Top N advertisers since the given hour. Each ADVERT packet counts once per hour heard,
// however many of the requested IATAs heard it (IATA-set rollup). Live names win.
GetStatsTopAdvertisers(ctx context.Context, arg GetStatsTopAdvertisersParams) ([]GetStatsTopAdvertisersRow, error)
// Top N observers since the given hour. Counts sum across matched IATAs; iata is a
// representative one. Live names win over the rolled snapshot.
GetStatsTopObservers(ctx context.Context, arg GetStatsTopObserversParams) ([]GetStatsTopObserversRow, error)
// Top N senders since the given hour. Each message counts once per hour heard, however many
// of the requested IATAs heard it (IATA-set rollup).
GetStatsTopTalkers(ctx context.Context, arg GetStatsTopTalkersParams) ([]GetStatsTopTalkersRow, error)
// Nodes by ADVERT hearings since the given hour. Live names win over the rolled snapshot;
// node_id is NULL once the node row is gone. iata is a representative one.
GetTopNodes(ctx context.Context, arg GetTopNodesParams) ([]GetTopNodesRow, error)
GetTransportScopeByName(ctx context.Context, name string) (int32, error)
GetTransportScopes(ctx context.Context) ([]GetTransportScopesRow, error)
// ============================================================
// CHANNEL MESSAGES
// ============================================================
// Read the immutable first-packet scope in the same statement as insertion.
// A later reception's transport code must not give live and historical messages different tags.
// message_count is a lifetime count, bumped only for a new message. A historical (backfilled)
// message queues its observation hours for a re-roll in the same statement, so the two can't diverge.
InsertChannelMessage(ctx context.Context, arg InsertChannelMessageParams) (InsertChannelMessageRow, error)
// ============================================================
// PACKET OBSERVATIONS
// ============================================================
// Bumps packets.observation_count only for a new row; a duplicate returns the current count.
InsertObservation(ctx context.Context, arg InsertObservationParams) (InsertObservationRow, error)
// Inserts a telemetry snapshot for an observer. The reported_at timestamp should
// be truncated to the configured resolution before calling to ensure deduplication.
InsertObserverTelemetry(ctx context.Context, arg InsertObserverTelemetryParams) error
ListAccounts(ctx context.Context) ([]Account, error)
// Returns all messages across all channels with optional time, IATA, scope and cursor filters.
// Pass empty string for iata or scope to skip those filters.
// Pass cursor=0 to start from the beginning.
ListAllChannelMessages(ctx context.Context, arg ListAllChannelMessagesParams) ([]ListAllChannelMessagesRow, error)
ListChannelCatalogues(ctx context.Context) ([]MeshmapperChannelCatalogue, error)
// Returns messages for a channel identified by integer ID.
// Pass a zero/null timestamp for since to return all messages up to limit.
// Pass empty string for iata to skip IATA filtering.
// Pass cursor=0 to start from the beginning.
ListChannelMessages(ctx context.Context, arg ListChannelMessagesParams) ([]ListChannelMessagesRow, error)
// Returns messages for all channels matching a hash byte.
// May return messages from multiple channels if the hash collides across different keys.
// Pass empty string for iata or scope to skip those filters.
// Pass cursor=0 to start from the beginning.
ListChannelMessagesByHash(ctx context.Context, arg ListChannelMessagesByHashParams) ([]ListChannelMessagesByHashRow, error)
// Channels ordered by last seen, optionally filtered by hash and/or IATAs.
// A channel belongs to an IATA when MeshMapper lists it there or config scopes it
// to a region containing it (or Beacon-wide). NULL hash / empty array / NULL key_known skip those filters.
// Pass cursor=0 to start from the beginning (cursor is last_seen epoch ms).
ListChannels(ctx context.Context, arg ListChannelsParams) ([]Channel, error)
// Keep the non-null tuple boundary separate from the legacy optional cursor so
// generic prepared plans can seek directly into the composite ordered index.
ListChannelsAfter(ctx context.Context, arg ListChannelsAfterParams) ([]Channel, error)
// Only complete hours whose raw rows are still intact can be re-rolled. Queued missing hours
// wait: their first roll consumes the entry only if the entry predates its snapshot.
ListDirtyRollupHours(ctx context.Context, limit int32) ([]pgtype.Timestamptz, error)
ListHeardIATAs(ctx context.Context) ([]string, error)
ListIATAs(ctx context.Context) ([]IataCode, error)
// Only one branch runs. Keep the IATA range ordered by the composite index:
// generic plans can otherwise prefer scanning the global timestamp index.
// The text equality preserves exact input matching, including trailing spaces.
// Pages by (last_seen to the ms, id) so routes sharing the cursor's millisecond
// aren't skipped; cursor id 0 keeps the plain timestamp cursor.
ListKnownRoutes(ctx context.Context, arg ListKnownRoutesParams) ([]ListKnownRoutesRow, error)
// Returns messages after the given message ID, ordered oldest first.
// Used for WS reconnect backfill.
ListMessagesAfterID(ctx context.Context, arg ListMessagesAfterIDParams) ([]ListMessagesAfterIDRow, error)
ListMissingRollupHours(ctx context.Context, limit int32) ([]pgtype.Timestamptz, error)
ListNodeObservations(ctx context.Context, arg ListNodeObservationsParams) ([]ListNodeObservationsRow, error)
// Limit the filtered node page before enriching IATA membership and neighbours.
ListNodes(ctx context.Context, arg ListNodesParams) ([]ListNodesRow, error)
ListObservationsForPacket(ctx context.Context, packetHash []byte) ([]ListObservationsForPacketRow, error)
// Returns advert packets (payload_type=4) heard by a specific observer.
// Pass cursor=0 to start from the beginning, or the last seen id for pagination.
// Keep missing-origin adverts; the generated key field expects a string, not NULL.
ListObserverAdverts(ctx context.Context, arg ListObserverAdvertsParams) ([]ListObserverAdvertsRow, error)
// Copyright 2026 Beacon Contributors
// SPDX-License-Identifier: AGPL-3.0-or-later
ListObserverDirectory(ctx context.Context, arg ListObserverDirectoryParams) (string, error)
// Pass cursor=0 to start from the beginning, or the last seen observer's rownum for pagination.
// Note: observers use UUID PKs so we order by last_seen and use a keyset on last_seen+id.
ListObservers(ctx context.Context, arg ListObserversParams) ([]ListObserversRow, error)
// Returns packets with the latest observation rolled in for display.
// Pass cursor=0 to start from the beginning. IATA-filtered requests are
// served by ListPacketsByIATAs instead.
ListPackets(ctx context.Context, arg ListPacketsParams) ([]ListPacketsRow, error)
// Returns packets with observations after the given observation ID, ordered oldest first.
// Used for WS reconnect backfill. Pass afterObservationId=0 to start from the beginning.
ListPacketsAfterID(ctx context.Context, arg ListPacketsAfterIDParams) ([]ListPacketsAfterIDRow, error)
// IATA-filtered packet list, driven from idx_observations_iata_heard.
// Walking packets newest-first and probing for the site probes ~589k packets
// to fill a page for a quiet site; walking the site's own observation log is
// proportional to the page size instead. Results are ordered by when the
// requested sites heard the packet (site-local recency) and the cursor
// follows that ordering. scan_depth caps how deep each site's observation
// log is walked. A packet repeats once per observer that heard it, so a
// page can collapse to fewer distinct packets than were asked for without
// the site being exhausted. scan_saturated reports whether any site hit
// that cap and scan_floor the oldest heard_at they all cover, so a short
// page can keep paging instead of reading as the end of the data.
// A site that filled scan_depth still has unread history below its floor.
// The newest such floor is the point above which every site is covered.
ListPacketsByIATAs(ctx context.Context, arg ListPacketsByIATAsParams) ([]ListPacketsByIATAsRow, error)
// Every region with its members, for reconciling imported MeshMapper groups.
ListRegionState(ctx context.Context) ([]ListRegionStateRow, error)
// ============================================================
// REGIONS
// ============================================================
ListRegions(ctx context.Context) ([]ListRegionsRow, error)
// Leading index equalities and the time/ID boundary bound both custom and generic plans.
// Full-byte equality is required even when the compact digest matches. TRACE path bytes
// carry readings; unclassified legacy observations cannot be safely called ordinary paths.
ListRouteEvidence(ctx context.Context, arg ListRouteEvidenceParams) ([]ListRouteEvidenceRow, error)
ListScopeCatalogues(ctx context.Context) ([]MeshmapperScopeCatalogue, error)
// ============================================================
// TRACES
// ============================================================
// Tags, most recent first. Filters match the tag summary (see RecordTrace).
ListTraceTags(ctx context.Context, arg ListTraceTagsParams) ([]ListTraceTagsRow, error)
// Returns GRP_TXT packets (payload_type=5) never successfully decrypted. Used at boot to
// retry decryption against the current keystore for packets whose channel key was only added
// to the config after they'd already been ingested -- see
// internal/ingest.BackfillChannelMessages.
ListUndecryptedGroupTextPackets(ctx context.Context) ([]ListUndecryptedGroupTextPacketsRow, error)
// Like ListUndecryptedGroupTextPackets, limited to channels that just gained a key.
ListUndecryptedGroupTextPacketsByHash(ctx context.Context, hashes [][]byte) ([]ListUndecryptedGroupTextPacketsByHashRow, error)
ListZoneBoundaries(ctx context.Context) ([]MeshmapperZoneBoundary, error)
ListZoneLists(ctx context.Context) ([]MeshmapperZoneList, error)
// Returns the hour's status, or 'partial' if raw deletion has reached it since registration.
LockRollupHour(ctx context.Context, hour pgtype.Timestamptz) (string, error)
// Hours whose raw rows cleanup already started deleting can never be rolled completely.
// Readers report the new status, so the revision moves too.
MarkPartialRollupHours(ctx context.Context) error
OldestMissingRollupHour(ctx context.Context) (pgtype.Timestamptz, error)
PruneImportedRegions(ctx context.Context, keep []string) ([]string, error)
// Drops imports for IATAs no longer configured, so their manual border returns.
PruneZoneBoundaries(ctx context.Context, keep []string) ([]string, error)
// Delete node_neighbors where the neighbor has departed from node_short_ids
// for that IATA, or where its prefix_4 is now ambiguous.
ReconfirmNeighbors(ctx context.Context) error
// Checks one batch of least-recently-reconfirmed routes: deletes those with a departed
// hop node or a hop prefix now matching >1 node in that IATA (length-aware:
// 1/2/3/4-byte hop prefixes check prefix_1/2/3/4; ambiguity set supplied by AmbiguousPrefixes),
// and stamps the survivors.
ReconfirmRoutes(ctx context.Context, arg ReconfirmRoutesParams) (int64, error)
// One hearing of a TRACE packet: trace_iatas refreshes at most hourly and the tag's heard
// window widens (the first hearing replaces the packet's provisional times). Packet counts
// and payloads come from UpsertPacket.
RecordTrace(ctx context.Context, arg RecordTraceParams) error
RefreshRadioPresets(ctx context.Context) error
// Adds a 'missing' row for every eligible hour since the earliest retained observation
// (and not before @since), zero-observation hours included.
// No observations yet means nothing to register (GREATEST would ignore the NULL MIN).
RegisterRollupHours(ctx context.Context, since pgtype.Timestamptz) error
// Batch form of ResolveEndpointHashes for a page of packets. Matches the cross
// product of IATAs and hashes; callers pick out the pairs they asked for.
ResolveEndpointHashPairs(ctx context.Context, arg ResolveEndpointHashPairsParams) ([]ResolveEndpointHashPairsRow, error)
// Logical endpoints can be any advertised role, unlike intermediate relay hops.
// Endpoint hashes are always one byte; use the existing (iata, prefix_1) index.
// LIMIT 1 keeps generic plans on a node PK lookup per candidate instead of
// flattening the join into a scan of all nodes. The PK already guarantees one row.
ResolveEndpointHashes(ctx context.Context, arg ResolveEndpointHashesParams) ([]ResolveEndpointHashesRow, error)
// ============================================================
// HELPERS
// ============================================================
// Path hash resolution is split per prefix width so each query gets a
// cacheable generic plan on its (iata, prefix_N) index; a single CASE
// predicate forced a fresh custom plan on every call.
ResolvePathHashesP1(ctx context.Context, arg ResolvePathHashesP1Params) ([]ResolvePathHashesP1Row, error)
ResolvePathHashesP2(ctx context.Context, arg ResolvePathHashesP2Params) ([]ResolvePathHashesP2Row, error)
ResolvePathHashesP3(ctx context.Context, arg ResolvePathHashesP3Params) ([]ResolvePathHashesP3Row, error)
ResolvePathHashesP4(ctx context.Context, arg ResolvePathHashesP4Params) ([]ResolvePathHashesP4Row, error)
// Batch form of ResolvePathHashesP1 across IATAs; callers check uniqueness per IATA.
ResolveRelayHashPairsP1(ctx context.Context, arg ResolveRelayHashPairsP1Params) ([]ResolveRelayHashPairsP1Row, error)
// Batch form of ResolvePathHashesP2 across IATAs; callers check uniqueness per IATA.
ResolveRelayHashPairsP2(ctx context.Context, arg ResolveRelayHashPairsP2Params) ([]ResolveRelayHashPairsP2Row, error)
// Batch form of ResolvePathHashesP3 across IATAs; callers check uniqueness per IATA.
ResolveRelayHashPairsP3(ctx context.Context, arg ResolveRelayHashPairsP3Params) ([]ResolveRelayHashPairsP3Row, error)
// Batch form of ResolvePathHashesP4 across IATAs; callers check uniqueness per IATA.
ResolveRelayHashPairsP4(ctx context.Context, arg ResolveRelayHashPairsP4Params) ([]ResolveRelayHashPairsP4Row, error)
RollAdvertHearings(ctx context.Context, hour pgtype.Timestamptz) error
// Each distinct ADVERT packet counts once, under the exact set of IATAs that heard it this hour.
RollAdvertSets(ctx context.Context, hour pgtype.Timestamptz) error
RollIATAObservations(ctx context.Context, hour pgtype.Timestamptz) error
RollObserverActivity(ctx context.Context, hour pgtype.Timestamptz) error
RollObserverIdentity(ctx context.Context, hour pgtype.Timestamptz) error
RollPacketSets(ctx context.Context, hour pgtype.Timestamptz) error
// category: 0 = routed, 1 = zero-hop, 2 = TRACE, 3 = invalid (meshcore-go IsValidPathLen).
RollPaths(ctx context.Context, hour pgtype.Timestamptz) error
RollPayloadBreakdown(ctx context.Context, hour pgtype.Timestamptz) error
RollScopeNodes(ctx context.Context, hour pgtype.Timestamptz) error
RollScopeObservers(ctx context.Context, hour pgtype.Timestamptz) error
RollScopeSets(ctx context.Context, hour pgtype.Timestamptz) error
// kind = grouping(snr_bin, rssi_bin): 3 = per IATA totals, 1 = per SNR bin, 2 = per RSSI bin.
// rssi=0 AND snr=0 means "not reported".
RollSignal(ctx context.Context, hour pgtype.Timestamptz) error
RollTalkerSets(ctx context.Context, hour pgtype.Timestamptz) error
// Order-independent fingerprint of every family row for the hour.
RollupContentHash(ctx context.Context, hour pgtype.Timestamptz) (string, error)
RollupUnlock(ctx context.Context) error
// NULL payload/etag/checked_at retain the last good list after an error or 304.
SaveChannelCatalogue(ctx context.Context, arg SaveChannelCatalogueParams) error
// One statement commits the validated snapshot and its lookup identities together.
// Empty arrays insert nothing. NULL payload/checked_at retain last-known-good data
// after an error or 304. Imported names never replace existing manual metadata.
SaveScopeCatalogue(ctx context.Context, arg SaveScopeCatalogueParams) error
// NULL feature/etag/checked_at retain the last good boundary after an error or 304.
SaveZoneBoundary(ctx context.Context, arg SaveZoneBoundaryParams) error
// NULL payload/etag/fetched_at retain the last good list after an error or 304.
SaveZoneList(ctx context.Context, arg SaveZoneListParams) error
// Routes holding a source and a destination candidate; callers check order and IATA.
// A route's hops resolve in its own IATA, so candidates from other IATAs can't match.
// Both && predicates use the node_ids GIN index.
SearchKnownRoutesByNodes(ctx context.Context, arg SearchKnownRoutesByNodesParams) ([]SearchKnownRoutesByNodesRow, error)
SetNodeDefaultScope(ctx context.Context, arg SetNodeDefaultScopeParams) error
SetNodeMultibytePaths(ctx context.Context, id uuid.UUID) error
SetNodeMultibyteTraces(ctx context.Context, id uuid.UUID) error
SetPacketDecrypted(ctx context.Context, packetHash []byte) error
SetRollupHourPartial(ctx context.Context, hour pgtype.Timestamptz) error
TouchObserverBrokers(ctx context.Context, arg TouchObserverBrokersParams) error
// Batched flush of coalesced presence bumps. GREATEST keeps a late flush
// from regressing a newer write-through (e.g. a status update).
TouchObservers(ctx context.Context, arg TouchObserversParams) error
TouchPackets(ctx context.Context, arg TouchPacketsParams) error
// ============================================================
// HOURLY ANALYTICS ROLLUPS
// An hour [H, H+1h) is eligible once now() >= H + 95 min (ingest clamps heard_at to ±30 min).
// ============================================================
TryRollupLock(ctx context.Context) (bool, error)
// Records the observer's own OTA-reported region scope, from the "self"
// field of a /neighbors report. Always known (not queried OTA), so this
// unconditionally overwrites, unlike the neighbor-side region_scope.
UpdateObserverRegionScope(ctx context.Context, arg UpdateObserverRegionScopeParams) error
UpdateObserverStatus(ctx context.Context, arg UpdateObserverStatusParams) (uuid.UUID, error)
// ============================================================
// CHANNELS
// ============================================================
// Upsert a channel by (hash, key_fingerprint). Pass NULL fingerprint for
// hash-only records (key unknown). Returns the channel row.
UpsertChannel(ctx context.Context, arg UpsertChannelParams) (Channel, error)
UpsertChannelHashOnly(ctx context.Context, channelHash []byte) (int32, error)
// Refreshes at most hourly so repeat hears don't churn the row.
UpsertChannelIATA(ctx context.Context, arg UpsertChannelIATAParams) error
// Copyright 2026 Beacon Contributors
// SPDX-License-Identifier: agpl
// ============================================================
// IATA CODES
// ============================================================
UpsertIATA(ctx context.Context, iata string) error
// Written by the config-file-driven seeder (internal/config/seed.go), not a
// runtime HTTP path. border is a full, pre-validated GeoJSON Feature with
// bbox already computed -- see internal/config/border.go.
UpsertIATABorder(ctx context.Context, arg UpsertIATABorderParams) error
UpsertIATADetails(ctx context.Context, arg UpsertIATADetailsParams) error
// A hand-written region owns its slug: the WHERE turns a clash into no row.
UpsertImportedRegion(ctx context.Context, arg UpsertImportedRegionParams) (int32, error)
// ============================================================
// ROUTES
// ============================================================
// Route identity is path_key, an md5 of node_ids computed by the caller.
// On conflict, observation_count and last_seen are bumped and hash_prefix follows the
// latest hearing, so evidence matches the hash width the route uses now.
UpsertKnownRoute(ctx context.Context, arg UpsertKnownRouteParams) error
// ============================================================
// NODES
// ============================================================
UpsertNode(ctx context.Context, arg UpsertNodeParams) (Node, error)
// ============================================================
// NODE IATAS
// ============================================================
UpsertNodeIATA(ctx context.Context, arg UpsertNodeIATAParams) error
// ============================================================
// NEIGHBORS
// ============================================================
// Records or updates a neighbor relationship between two nodes observed in the same IATA.
// node_id is the advertising node, neighbor_id is the first-hop forwarder.
// snr is optional; pass NULL when no signal reading is available (the
// common case). regionScope is optional too; pass NULL whenever the OTA
// scope query for this neighbor didn't succeed (status != "responded"),
// so a failed/timed-out query doesn't erase a previously known scope.
// On conflict, snr and region_scope are only overwritten when a new
// non-null value is supplied.
UpsertNodeNeighbor(ctx context.Context, arg UpsertNodeNeighborParams) error
UpsertNodeShortID(ctx context.Context, arg UpsertNodeShortIDParams) error
// ============================================================
// OBSERVERS
// ============================================================
// Empty iata (status/neighbors) leaves last_iata alone; otherwise the newest iata_at wins.
UpsertObserver(ctx context.Context, arg UpsertObserverParams) (Observer, error)
// ============================================================
// OBSERVER BROKERS
// ============================================================
UpsertObserverBroker(ctx context.Context, arg UpsertObserverBrokerParams) error
UpsertObserverScope(ctx context.Context, arg UpsertObserverScopeParams) error
// ============================================================
// PACKETS
// ============================================================
// A new TRACE packet adds itself to its tag summary in the same statement, so the summary
// can't miss a stored packet. 'TRACE' > 'PING'; the longest path keeps the best payload.
UpsertPacket(ctx context.Context, arg UpsertPacketParams) (UpsertPacketRow, error)
UpsertRegion(ctx context.Context, arg UpsertRegionParams) (int32, error)
// ============================================================
// TRANSPORT CODES
// ============================================================
UpsertTransportScope(ctx context.Context, arg UpsertTransportScopeParams) error
}
var _ Querier = (*Queries)(nil)