mirror of
https://github.com/MeshCore-Beacon/beacon-server.git
synced 2026-12-06 13:16:36 +00:00
Two bounded ranges instead of an OR across first and last hearing: migration 086 adds idx_packets_origin_last_heard. Planguard entries guard both ranges, and the node activity test holds the clock still and runs in CI again.
1007 lines
84 KiB
Go
1007 lines
84 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 {
|
|
// Completes a sign-up: the username and password hash of the verified sign-up replace the row's, the address counts
|
|
// as verified, and every verify token and session of the account goes, in one statement. No row when the user is
|
|
// already verified, disabled or gone.
|
|
ActivateUser(ctx context.Context, arg ActivateUserParams) (uuid.UUID, error)
|
|
// An empty region places the channel Beacon-wide.
|
|
AddChannelConfigScopes(ctx context.Context, arg AddChannelConfigScopesParams) error
|
|
AddChannelMembers(ctx context.Context, arg AddChannelMembersParams) error
|
|
// Copyright 2026 Beacon Contributors
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
// A stored observation's site for a message another statement created. A no-op when the packet has no message;
|
|
// found says whether the packet has a committed message (then the site is recorded, now or before).
|
|
AddChannelMessageIATA(ctx context.Context, arg AddChannelMessageIATAParams) (bool, error)
|
|
AddIATAs(ctx context.Context, iatas []string) error
|
|
AddRegionIATAs(ctx context.Context, arg AddRegionIATAsParams) error
|
|
// What each of the nodes is and what a polled one reports, over the readings since the cutoff.
|
|
AlertNodeCaps(ctx context.Context, arg AlertNodeCapsParams) ([]AlertNodeCapsRow, error)
|
|
// For each repeater, the battery reading closest to 24 hours before its newest one, within 3 hours of that mark.
|
|
AlertNodeDayAgo(ctx context.Context, arg AlertNodeDayAgoParams) ([]AlertNodeDayAgoRow, error)
|
|
// For each repeater and the oldest cursor of its clock rule: the advert drift at or before the cursor (the pair's
|
|
// first half), then every kept advert after it, oldest first. The table keeps at most 16 per node.
|
|
AlertNodeDrifts(ctx context.Context, arg AlertNodeDriftsParams) ([]AlertNodeDriftsRow, error)
|
|
// The newest trusted readings of each repeater within the window, at most 12 each.
|
|
AlertNodeReadings(ctx context.Context, arg AlertNodeReadingsParams) ([]AlertNodeReadingsRow, error)
|
|
// For each repeater and the cursor of its reboot rule: the newest trusted uptime reading at or before the cursor (the
|
|
// baseline), then the oldest page_size readings after it, so every reading since the cursor is reached page by page.
|
|
AlertNodeUptimes(ctx context.Context, arg AlertNodeUptimesParams) ([]AlertNodeUptimesRow, error)
|
|
// polled is the same test as the overview's (AlertNodeCaps): a current polling assignment while polling is on.
|
|
AlertNodesData(ctx context.Context, arg AlertNodesDataParams) ([]AlertNodesDataRow, error)
|
|
AlertObserverCaps(ctx context.Context, arg AlertObserverCapsParams) ([]AlertObserverCapsRow, error)
|
|
AlertObserverDayAgo(ctx context.Context, arg AlertObserverDayAgoParams) ([]AlertObserverDayAgoRow, error)
|
|
AlertObserverTelemetry(ctx context.Context, arg AlertObserverTelemetryParams) ([]AlertObserverTelemetryRow, error)
|
|
// The same for an observer's status telemetry.
|
|
AlertObserverUptimes(ctx context.Context, arg AlertObserverUptimesParams) ([]AlertObserverUptimesRow, error)
|
|
// polled is the same test as the overview's (AlertObserverCaps): status telemetry within fresh_since.
|
|
AlertObserversData(ctx context.Context, arg AlertObserversDataParams) ([]AlertObserversDataRow, error)
|
|
// The next enabled rules of live users after the id, with the name the user gave the pin and, for a back_online
|
|
// rule, when the radio's gone_quiet rule last recovered and whether that rule is on.
|
|
AlertRuleBatch(ctx context.Context, arg AlertRuleBatchParams) ([]AlertRuleBatchRow, error)
|
|
AlertsEvalUnlock(ctx context.Context) error
|
|
AlertsSendUnlock(ctx context.Context) error
|
|
// Stores what the evaluation decided, only for rules not edited since they were read (same version). Returns the ids
|
|
// that were stored.
|
|
ApplyAlertUpdates(ctx context.Context, arg ApplyAlertUpdatesParams) ([]uuid.UUID, error)
|
|
// Applies only the address the link was issued for ($2, lower case), so a later change of the pending address cannot ride on an old link.
|
|
// The pending address was verified by the link that got us here, so the account counts as verified too.
|
|
ApplyPendingEmail(ctx context.Context, arg ApplyPendingEmailParams) (int64, error)
|
|
// Copies the packet's payload type onto the first @max_rows observations in [@from_id, @to_id),
|
|
// in id order, that lack one. Rows that already carry a type are never touched. Returns how many
|
|
// untyped rows it picked, how many it typed, and the last picked id (0 when it picked none).
|
|
BackfillObservationPayloadTypes(ctx context.Context, arg BackfillObservationPayloadTypesParams) (BackfillObservationPayloadTypesRow, error)
|
|
BeginAlertPass(ctx context.Context, passID uuid.UUID) error
|
|
// Counts a failed mail and holds it back for a minute, doubling with each earlier failure; the last allowed failure
|
|
// ends the channel.
|
|
BumpAlertEmailAttempts(ctx context.Context, arg BumpAlertEmailAttemptsParams) error
|
|
// As for mail, or held until hold_until when the push server asked for longer.
|
|
BumpAlertPushAttempts(ctx context.Context, arg BumpAlertPushAttemptsParams) error
|
|
BumpUserAtlas(ctx context.Context, arg BumpUserAtlasParams) (int64, error)
|
|
// Exact check of messages in (after_id, through_id]: pairs the definition has and the table lacks (counting
|
|
// observations up to obs_through only), and table pairs no stored observation backs.
|
|
CheckChannelMessageIATAs(ctx context.Context, arg CheckChannelMessageIATAsParams) (CheckChannelMessageIATAsRow, error)
|
|
// Exact check of every packet with an observation in (after_id, through_id]: site rows the observations imply
|
|
// and the table lacks, rows whose hearing time or packet columns differ, and rows no observation backs.
|
|
CheckPacketSitesSlice(ctx context.Context, arg CheckPacketSitesSliceParams) (CheckPacketSitesSliceRow, error)
|
|
// Run under LockPollingTarget.
|
|
ClearNoPasswordBlocked(ctx context.Context, targetPublicKey []byte) (int64, error)
|
|
// Keeps fetch timing so re-enabling still respects backoff; the ETag goes with the rows.
|
|
ClearRepeaters(ctx context.Context) (int64, error)
|
|
// Renumbers the target's ranks 0..n-1 in their current order, so after a delete the best survivor polls. Only the
|
|
// lowest rank can become 0, so the one-poller index holds row by row. Run under LockPollingTarget.
|
|
CompactTargetAssignments(ctx context.Context, targetPublicKey []byte) error
|
|
// One statement, so a state is used once; an expired one is deleted and reported as missing by the caller.
|
|
ConsumePortalState(ctx context.Context, cookieHash []byte) (ConsumePortalStateRow, error)
|
|
// Spends a live reset token only while the address it was mailed to is still the account's address, in one statement.
|
|
ConsumeResetToken(ctx context.Context, arg ConsumeResetTokenParams) (uuid.UUID, error)
|
|
// One statement, so two concurrent uses cannot both match used_at IS NULL.
|
|
ConsumeUserToken(ctx context.Context, arg ConsumeUserTokenParams) (ConsumeUserTokenRow, error)
|
|
// Recomputed each pass. Counts other observers that heard a RESPONSE (1) or PATH (8) packet with the reading's
|
|
// 8-byte hash within 10 minutes of sampled_at. packets and packet_observations keep no source hash, so the
|
|
// sender is not checked; packet_observations.payload_type is not always filled, so the type comes from packets.
|
|
// A reading whose observer row was deleted counts every observer. Never-counted readings go first, oldest first,
|
|
// then counted ones newest first, so every reading is reached however many arrive.
|
|
CorroborateReadings(ctx context.Context, arg CorroborateReadingsParams) (int64, error)
|
|
// How many messages were sent at or after since, counted to at most row_limit: idx_channel_messages_sent alone.
|
|
CountChannelMessagesSentSince(ctx context.Context, arg CountChannelMessagesSentSinceParams) (int64, error)
|
|
CountTargetAssignments(ctx context.Context, targetPublicKey []byte) (int32, error)
|
|
CountUntrustedNodeReadings(ctx context.Context, arg CountUntrustedNodeReadingsParams) (int32, error)
|
|
CountUserRequests(ctx context.Context, userID uuid.UUID) (int32, error)
|
|
CreateAccount(ctx context.Context, name string) (Account, error)
|
|
CreatePortalState(ctx context.Context, arg CreatePortalStateParams) error
|
|
CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
|
|
CreateUserSession(ctx context.Context, arg CreateUserSessionParams) (CreateUserSessionRow, error)
|
|
CreateUserToken(ctx context.Context, arg CreateUserTokenParams) error
|
|
CurrentPollingPoller(ctx context.Context, targetPublicKey []byte) ([]byte, 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)
|
|
DeleteAlertRule(ctx context.Context, arg DeleteAlertRuleParams) (int64, error)
|
|
DeleteAllChannelMembers(ctx context.Context) error
|
|
DeleteChannelConfigScopes(ctx context.Context) error
|
|
DeleteChannelMembersNotIn(ctx context.Context, arg DeleteChannelMembersNotInParams) error
|
|
DeleteDevicesByToken(ctx context.Context, pushToken string) error
|
|
// A finished notice that ran out of attempts on a channel is dropped.
|
|
DeleteExhaustedAlerts(ctx context.Context, arg DeleteExhaustedAlertsParams) (int64, error)
|
|
DeleteExpiredPollingClaims(ctx context.Context, receivedAt pgtype.Timestamptz) error
|
|
DeleteExpiredPortalStates(ctx context.Context, cutoff pgtype.Timestamptz) error
|
|
DeleteExpiredRepeaterReadings(ctx context.Context, receivedAt pgtype.Timestamptz) error
|
|
// One batch past retention, keyset after the per-run cursor (the first call passes -infinity, 0).
|
|
// The truncated bound (ms ceiling of the cutoff) drives idx_known_routes_keyset; the exact
|
|
// residual decides membership. + interval 0 keeps the exact cutoff a Filter, so the planner
|
|
// cannot switch to a last_seen index on deployments that still have one.
|
|
DeleteExpiredRoutes(ctx context.Context, arg DeleteExpiredRoutesParams) (DeleteExpiredRoutesRow, error)
|
|
DeleteExpiredUserSessions(ctx context.Context, cutoff pgtype.Timestamptz) error
|
|
DeleteExpiredUserTokens(ctx context.Context, cutoff pgtype.Timestamptz) error
|
|
// One batch of rarely-seen routes after the cursor, inside a window of at most 6 h below the grace
|
|
// cutoff: candidates without locks, then lock SKIP LOCKED through the pkey (re-checked on the newest
|
|
// version) and delete. unresolved_ts is the earliest candidate left behind; window_end is the bound used.
|
|
DeleteGraceRoutesSlice(ctx context.Context, arg DeleteGraceRoutesSliceParams) (DeleteGraceRoutesSliceRow, error)
|
|
// Run under LockPollingTarget, then CompactTargetAssignments.
|
|
DeleteObserverTargetAssignment(ctx context.Context, arg DeleteObserverTargetAssignmentParams) (int64, error)
|
|
DeleteOldAlertPasses(ctx context.Context, startedAt pgtype.Timestamptz) 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
|
|
DeleteOldServedVersions(ctx context.Context, servedAt pgtype.Timestamptz) 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
|
|
// Run under LockPollingTarget, so it cannot interleave with an election of the target.
|
|
DeleteOrphanPollingAssignments(ctx context.Context, targetPublicKey []byte) error
|
|
DeletePollingAdminStop(ctx context.Context, arg DeletePollingAdminStopParams) (int64, error)
|
|
DeletePollingAssignments(ctx context.Context, targetPublicKey []byte) error
|
|
DeletePollingCandidates(ctx context.Context, observerPublicKey []byte) error
|
|
DeleteRegionIATAsNotIn(ctx context.Context, arg DeleteRegionIATAsNotInParams) error
|
|
DeleteRepeaterSource(ctx context.Context, source string) error
|
|
DeleteRollupHour(ctx context.Context, hour pgtype.Timestamptz) error
|
|
// A session has one device: registering a new token replaces the old one.
|
|
DeleteSessionDeviceOtherToken(ctx context.Context, arg DeleteSessionDeviceOtherTokenParams) error
|
|
// Dirty hours that can no longer be re-rolled.
|
|
DeleteStaleDirtyHours(ctx context.Context) error
|
|
// A sign-up nobody confirmed holds its username and address; once it is old and has no live verify link left it
|
|
// is removed so both can be used again. A disabled account is never removed here.
|
|
DeleteStaleUnverifiedUsers(ctx context.Context, arg DeleteStaleUnverifiedUsersParams) error
|
|
DeleteTelemetryRequest(ctx context.Context, id uuid.UUID) error
|
|
// Run in the Atlas write's transaction: a radio taken off the Atlas takes its rules with it.
|
|
DeleteUnpinnedAlertRules(ctx context.Context, userID uuid.UUID) error
|
|
DeleteUser(ctx context.Context, id uuid.UUID) (int64, error)
|
|
DeleteUserAtlasPins(ctx context.Context, userID uuid.UUID) error
|
|
DeleteUserDevice(ctx context.Context, arg DeleteUserDeviceParams) error
|
|
DeleteUserIfHash(ctx context.Context, arg DeleteUserIfHashParams) (int64, error)
|
|
DeleteUserTokens(ctx context.Context, arg DeleteUserTokensParams) error
|
|
DeliveredAlertDevices(ctx context.Context, ids []int64) ([]DeliveredAlertDevicesRow, error)
|
|
// Telemetry requests that need attention and were not announced at this status, locked until the transaction ends.
|
|
DueRequestAttention(ctx context.Context) ([]DueRequestAttentionRow, error)
|
|
EndAllUserSessions(ctx context.Context, userID uuid.UUID) error
|
|
// Ends the live app sessions beyond the newest keep.
|
|
EndOldestAppSessions(ctx context.Context, arg EndOldestAppSessionsParams) error
|
|
EndOtherUserSessions(ctx context.Context, arg EndOtherUserSessionsParams) error
|
|
EndUserSession(ctx context.Context, arg EndUserSessionParams) error
|
|
EnsurePollingTarget(ctx context.Context, targetPublicKey []byte) error
|
|
// Creates the empty Atlas row (revision 0) so a first write has a row to lock.
|
|
EnsureUserAtlas(ctx context.Context, userID uuid.UUID) error
|
|
// Drops what was not delivered within its window, and what was delivered long ago.
|
|
ExpireAlertOutbox(ctx context.Context, arg ExpireAlertOutboxParams) (int64, error)
|
|
// Every site of every message in (after_id, through_id]: the backfill and the reconcile's message part.
|
|
FillChannelMessageIATAsByMessages(ctx context.Context, arg FillChannelMessageIATAsByMessagesParams) (int64, error)
|
|
// The site of every group-text observation in (after_id, through_id] whose packet has a message.
|
|
// An untyped observation is checked too: older rows may have no payload type.
|
|
FillChannelMessageIATAsByObservations(ctx context.Context, arg FillChannelMessageIATAsByObservationsParams) (int64, error)
|
|
// The audit's fill: each (packet, site) of the observations in (after_id, through_id], at its latest hearing there
|
|
// among all of the packet's observations, so a pair heard again in a later slice comes back at that hearing.
|
|
FillPacketSitesAudit(ctx context.Context, arg FillPacketSitesAuditParams) (int64, error)
|
|
// Copyright 2026 Beacon Contributors
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
// Each (packet, site) of the observations in (after_id, through_id], at its latest hearing there.
|
|
// Pairs already at or past that hearing are skipped before the insert, so a clean slice writes nothing.
|
|
FillPacketSitesSlice(ctx context.Context, arg FillPacketSitesSliceParams) (int64, error)
|
|
// Hop prefixes that match >1 node in an IATA, per width, into the sweep's temp table.
|
|
FillReconfirmAmb(ctx context.Context) error
|
|
FillRollupObs(ctx context.Context, dollar_1 pgtype.Timestamptz) error
|
|
// The requested sites that have at least one row: a site with none adds no row to any site page.
|
|
FilterKnownSites(ctx context.Context, iatas []string) ([]string, error)
|
|
FinishAlertPass(ctx context.Context, passID uuid.UUID) 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)
|
|
GetBackgroundState(ctx context.Context, key string) (json.RawMessage, error)
|
|
// A state with its age on the database clock: how long since its writer last saved it.
|
|
GetBackgroundStateAge(ctx context.Context, key string) (GetBackgroundStateAgeRow, 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.
|
|
// hop_count + 0: no hop_count-led index may supply this order (a LIMIT walk would check the GIN conditions row by row).
|
|
GetKnownRoutesByNodes(ctx context.Context, arg GetKnownRoutesByNodesParams) ([]GetKnownRoutesByNodesRow, error)
|
|
// The statistics the planner holds for known_routes.hop_count, read so the store can tell a small hop group from a
|
|
// large one (see ListKnownRoutesGlobalHop). The columns are NULL before the table is first analyzed.
|
|
GetKnownRoutesHopStats(ctx context.Context) (GetKnownRoutesHopStatsRow, 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)
|
|
// Hours before @tail_start come from the rollup; later ones aren't rolled yet and read raw rows, found through
|
|
// the node's packets first heard in [@packet_from, @packet_until) and through its older packets heard again
|
|
// since @late_from. Each branch reads one range of an (origin_pubkey, time) index, and no packet is in both.
|
|
GetNodeActivityHourly(ctx context.Context, arg GetNodeActivityHourlyParams) ([]GetNodeActivityHourlyRow, error)
|
|
GetNodeByID(ctx context.Context, id uuid.UUID) (GetNodeByIDRow, error)
|
|
GetNodeByPubkey(ctx context.Context, publicKey []byte) (uuid.UUID, error)
|
|
// The node's most recently first-heard packet, one probe of idx_packets_origin.
|
|
GetNodeLatestPacket(ctx context.Context, originPubkey []byte) (GetNodeLatestPacketRow, error)
|
|
// Returns the neighbors of a node with details, ordered by most recently seen.
|
|
GetNodeNeighbors(ctx context.Context, nodeID uuid.UUID) ([]GetNodeNeighborsRow, error)
|
|
GetNodePublicKey(ctx context.Context, id uuid.UUID) ([]byte, error)
|
|
GetNodesByIDs(ctx context.Context, dollar_1 []uuid.UUID) ([]GetNodesByIDsRow, error)
|
|
GetNodesByPubkeys(ctx context.Context, pubkeys [][]byte) ([]GetNodesByPubkeysRow, error)
|
|
GetObservationIDRange(ctx context.Context) (GetObservationIDRangeRow, 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 in one pass over idx_observations_observer: per bucket and payload type, the sums the store
|
|
// turns into the buckets and the type mix. Two ranges: [since, head_until) and [tail_from, until); the store
|
|
// fills the middle from its in-memory counts when it has them. Signal aggregates skip rows whose RSSI and SNR
|
|
// are both zero or missing.
|
|
GetObserverActivityRaw(ctx context.Context, arg GetObserverActivityRawParams) ([]GetObserverActivityRawRow, 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.
|
|
//
|
|
// Each observer's receptions are read on their own from idx_observations_observer
|
|
// (observer_id, heard_at): (packet_hash, observer_id) is unique, so each side
|
|
// holds a packet at most once, and the full join yields each heard packet once.
|
|
// The route type is checked once per packet after the join.
|
|
// The observer ids are scalar subqueries so the planner costs every observer
|
|
// alike: given a busy observer's own row count, a custom plan may instead walk
|
|
// every reception in the window through idx_observations_heard, which reads
|
|
// several times the buffers.
|
|
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)
|
|
// The API's only telemetry shape (a start, no end): reported_at >= @since without the NULL branch.
|
|
GetObserverTelemetrySince(ctx context.Context, arg GetObserverTelemetrySinceParams) ([]GetObserverTelemetrySinceRow, 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)
|
|
// GetPathStats for at most 32 distinct IATAs: one rollup probe per (hour, IATA). @since and @until are UTC hours.
|
|
// The hours walked stay inside the table's own [min(hour), max(hour)]; an empty table walks none
|
|
// (a NULL start makes generate_series return no rows).
|
|
GetPathStatsProbe(ctx context.Context, arg GetPathStatsProbeParams) ([]GetPathStatsProbeRow, error)
|
|
GetPollingState(ctx context.Context) (GetPollingStateRow, error)
|
|
GetPollingTarget(ctx context.Context, targetPublicKey []byte) (GetPollingTargetRow, error)
|
|
GetRadioPresets(ctx context.Context, arg GetRadioPresetsParams) ([]MvRadioPreset, error)
|
|
// The newest packet time retention has deleted; observations heard after it plus 30 minutes are all still stored.
|
|
GetRawDeletedBefore(ctx context.Context) (pgtype.Timestamptz, 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)
|
|
// Unfiltered node counts by type; never reads node_iatas.
|
|
GetStatsNodeTypesAll(ctx context.Context) ([]GetStatsNodeTypesAllRow, error)
|
|
// Node counts by type for nodes heard in any of @iatas.
|
|
GetStatsNodeTypesByIATAs(ctx context.Context, iatas []string) ([]GetStatsNodeTypesByIATAsRow, 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, ranked by flood or direct adverts (@sort). Each ADVERT
|
|
// packet counts once per hour heard, however many of the requested IATAs heard it. Live names win.
|
|
GetStatsTopAdvertisers(ctx context.Context, arg GetStatsTopAdvertisersParams) ([]GetStatsTopAdvertisersRow, error)
|
|
// GetStatsTopAdvertisers for at most 32 distinct IATAs: the hearings part probes per (hour, IATA),
|
|
// walking only hours inside the hearings table's [min(hour), max(hour)].
|
|
GetStatsTopAdvertisersProbe(ctx context.Context, arg GetStatsTopAdvertisersProbeParams) ([]GetStatsTopAdvertisersProbeRow, 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)
|
|
// GetTopNodes for every IATA: one pass over the hours since @since. The plan router lets it use parallel
|
|
// workers (planpolicy.ParallelWorkers).
|
|
GetTopNodesAll(ctx context.Context, arg GetTopNodesAllParams) ([]GetTopNodesAllRow, error)
|
|
// GetTopNodes for 1 to 32 distinct IATAs: one rollup probe per (hour, IATA). @since is a UTC hour. An empty
|
|
// @iatas matches nothing (every IATA is GetTopNodesAll).
|
|
// The hours walked stay inside the table's own [min(hour), max(hour)]; an empty table walks none
|
|
// (a NULL start makes generate_series return no rows).
|
|
GetTopNodesProbe(ctx context.Context, arg GetTopNodesProbeParams) ([]GetTopNodesProbeRow, error)
|
|
GetTransportScopeByName(ctx context.Context, name string) (int32, error)
|
|
GetTransportScopes(ctx context.Context) ([]GetTransportScopesRow, error)
|
|
HasLivePollingCandidate(ctx context.Context, arg HasLivePollingCandidateParams) (bool, error)
|
|
// Whether any observation up to @max_id lacks a payload type. A full scan, run at most once per
|
|
// process by the payload-type backfill.
|
|
HasUntypedObservations(ctx context.Context, maxID int64) (bool, error)
|
|
// A rate-limited push waits until hold_until; no attempt is counted.
|
|
HoldAlertPush(ctx context.Context, arg HoldAlertPushParams) error
|
|
InsertAlertNotices(ctx context.Context, arg InsertAlertNoticesParams) 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)
|
|
// The seeded insert's fallback: the same statement without the site seed. The read-model
|
|
// reconcile adds the message's sites within one interval.
|
|
InsertChannelMessageUnseeded(ctx context.Context, arg InsertChannelMessageUnseededParams) (InsertChannelMessageUnseededRow, error)
|
|
// ============================================================
|
|
// PACKET OBSERVATIONS
|
|
// ============================================================
|
|
// Bumps packets.observation_count and moves the packet's site row forward only for a new row; a duplicate
|
|
// returns the current count and writes nothing.
|
|
InsertObservation(ctx context.Context, arg InsertObservationParams) (InsertObservationRow, error)
|
|
// InsertObservation without the site row: the fallback when that statement fails. The caller marks the site
|
|
// read model untrusted; its reconcile adds the row.
|
|
InsertObservationUnsited(ctx context.Context, arg InsertObservationUnsitedParams) (InsertObservationUnsitedRow, 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
|
|
InsertPollingAdminStop(ctx context.Context, arg InsertPollingAdminStopParams) (int64, error)
|
|
InsertPollingAssignment(ctx context.Context, arg InsertPollingAssignmentParams) error
|
|
InsertPollingCandidate(ctx context.Context, arg InsertPollingCandidateParams) error
|
|
// Run under LockPollingObserver. Inserts nothing when this observer stored a reading of the target by the same
|
|
// method received after recent_after, or budget readings of any target received after budget_after.
|
|
InsertRepeaterReading(ctx context.Context, arg InsertRepeaterReadingParams) (int64, error)
|
|
InsertTelemetryRequest(ctx context.Context, arg InsertTelemetryRequestParams) error
|
|
InsertUserAtlasPin(ctx context.Context, arg InsertUserAtlasPinParams) error
|
|
// Newest trusted battery and temperature per polled node since a time, driven by polled targets, not all nodes.
|
|
// The received_at bound lets the BRIN index prune the history scan for readings of unassigned targets.
|
|
LatestNodeReadings(ctx context.Context, arg LatestNodeReadingsParams) ([]LatestNodeReadingsRow, error)
|
|
// The newest status reading before since: the baseline for the first counter increments in range.
|
|
LatestNodeStatusReadingBefore(ctx context.Context, arg LatestNodeStatusReadingBeforeParams) ([]LatestNodeStatusReadingBeforeRow, error)
|
|
// The data of the user's newest unused token of a kind, even if it has expired (cleanup keeps it for a week), for
|
|
// repeating a mail without minting from anything else.
|
|
LatestUserToken(ctx context.Context, arg LatestUserTokenParams) ([]byte, error)
|
|
ListAccounts(ctx context.Context) ([]Account, error)
|
|
// The original all-channel message statement, before the channel read model: no page runs it
|
|
// (planpolicy.VerificationOnly); tests compare message pages with it.
|
|
// 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)
|
|
// Every channel filtered by sites: each site's newest message ids from the read model, merged.
|
|
ListAllChannelMessagesByIATAs(ctx context.Context, arg ListAllChannelMessagesByIATAsParams) ([]ListAllChannelMessagesByIATAsRow, error)
|
|
// Every channel filtered by sites and a scope: each (site, scope) range's newest message ids, merged.
|
|
ListAllChannelMessagesByIATAsScoped(ctx context.Context, arg ListAllChannelMessagesByIATAsScopedParams) ([]ListAllChannelMessagesByIATAsScopedRow, error)
|
|
// Every channel filtered by sites with since, optionally by scope: the messages sent since then (idx_channel_messages_sent),
|
|
// each kept when it has a row at one of the sites, newest first. It reads every message sent since then, so it costs
|
|
// what the request asked for: the caller first tries the newest ids when many were sent.
|
|
ListAllChannelMessagesByIATAsSince(ctx context.Context, arg ListAllChannelMessagesByIATAsSinceParams) ([]ListAllChannelMessagesByIATAsSinceRow, error)
|
|
// ListAllChannelMessagesByIATAsSince when many messages were sent since then: the newest scan_rows message ids below
|
|
// the cursor, keeping those sent since then with a row at one of the sites. Exact when it fills the page (every newer
|
|
// id was read); otherwise the caller reads the messages sent since then instead.
|
|
ListAllChannelMessagesByIATAsSinceWalk(ctx context.Context, arg ListAllChannelMessagesByIATAsSinceWalkParams) ([]ListAllChannelMessagesByIATAsSinceWalkRow, error)
|
|
// Every channel, unfiltered: a walk by id; a message counts once it has a stored observation.
|
|
ListAllChannelMessagesPlain(ctx context.Context, arg ListAllChannelMessagesPlainParams) ([]ListAllChannelMessagesPlainRow, error)
|
|
// Every channel filtered by scope alone: the scope's newest message ids from the read model.
|
|
ListAllChannelMessagesPlainScoped(ctx context.Context, arg ListAllChannelMessagesPlainScopedParams) ([]ListAllChannelMessagesPlainScopedRow, error)
|
|
// Every channel with since, optionally by scope (no sites): a walk by id.
|
|
ListAllChannelMessagesSince(ctx context.Context, arg ListAllChannelMessagesSinceParams) ([]ListAllChannelMessagesSinceRow, error)
|
|
ListChannelCatalogues(ctx context.Context) ([]MeshmapperChannelCatalogue, error)
|
|
// Every channel key and its id, preloaded at boot for the ingest write-through.
|
|
ListChannelIDs(ctx context.Context) ([]ListChannelIDsRow, error)
|
|
// The busiest (channel, site) pairs among recent messages; the first-time verification compares their pages.
|
|
ListChannelMessageIATASamples(ctx context.Context, arg ListChannelMessageIATASamplesParams) ([]ListChannelMessageIATASamplesRow, error)
|
|
// The busiest (channel, scope) pairs among recent messages, with the scope name today's statement filters on.
|
|
ListChannelMessageScopeSamples(ctx context.Context, arg ListChannelMessageScopeSamplesParams) ([]ListChannelMessageScopeSamplesRow, 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)
|
|
// One channel filtered by sites: each site's newest message ids from the read model, merged.
|
|
ListChannelMessagesByIATAs(ctx context.Context, arg ListChannelMessagesByIATAsParams) ([]ListChannelMessagesByIATAsRow, error)
|
|
// One channel filtered by sites and scope.
|
|
ListChannelMessagesByIATAsScoped(ctx context.Context, arg ListChannelMessagesByIATAsScopedParams) ([]ListChannelMessagesByIATAsScopedRow, error)
|
|
// One channel, unfiltered: a walk of the channel by id; a message counts once it has a stored observation.
|
|
ListChannelMessagesPlain(ctx context.Context, arg ListChannelMessagesPlainParams) ([]ListChannelMessagesPlainRow, error)
|
|
// One channel and scope: the read model has a row exactly when the message has a stored observation.
|
|
ListChannelMessagesPlainScoped(ctx context.Context, arg ListChannelMessagesPlainScopedParams) ([]ListChannelMessagesPlainScopedRow, error)
|
|
// One channel with since (no client sends it): a channel walk; sites filter through the read model.
|
|
ListChannelMessagesSinceWalk(ctx context.Context, arg ListChannelMessagesSinceWalkParams) ([]ListChannelMessagesSinceWalkRow, 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 see a plain row comparison on (last_seen, id).
|
|
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)
|
|
// iata as a range keeps it in the pathkeys, so only idx_known_routes_iata_keyset returns rows in
|
|
// order; with = a generic plan may walk the global keyset. No cursor: NULL ts and id 0.
|
|
ListKnownRoutesByIATA(ctx context.Context, arg ListKnownRoutesByIATAParams) ([]ListKnownRoutesByIATARow, error)
|
|
// Custom plans only (class C: PlanRouter runs it unnamed): a generic plan walks the whole region for a rare hop.
|
|
// The = form prices the Sort correctly; the range form under-costs it when a hop index exists.
|
|
ListKnownRoutesByIATAHop(ctx context.Context, arg ListKnownRoutesByIATAHopParams) ([]ListKnownRoutesByIATAHopRow, error)
|
|
// Several IATAs' page: each IATA's own page from idx_known_routes_iata_keyset, merged. A list costs at most its
|
|
// length times the page however sparse its IATAs are, where filtering the global keyset walks past every other IATA.
|
|
ListKnownRoutesByIATAs(ctx context.Context, arg ListKnownRoutesByIATAsParams) ([]ListKnownRoutesByIATAsRow, error)
|
|
// ListKnownRoutesByIATAs with a hop filter; each IATA's page is ListKnownRoutesByIATAHop's.
|
|
ListKnownRoutesByIATAsHop(ctx context.Context, arg ListKnownRoutesByIATAsHopParams) ([]ListKnownRoutesByIATAsHopRow, error)
|
|
ListKnownRoutesGlobal(ctx context.Context, arg ListKnownRoutesGlobalParams) ([]ListKnownRoutesGlobalRow, error)
|
|
// Custom plans only (class C: PlanRouter runs it unnamed), so the planner drops the branch @read_group turns off.
|
|
// The planner's own break-even between reading the whole hop group from the hop index and walking the keyset index
|
|
// sits far below the real one, so a mid-size group could flip, by ANALYZE sample, to a walk ten times dearer. The
|
|
// store sets @read_group for a group whose estimate is under the real break-even (see hopGroupIsSmall): that branch
|
|
// (kh) reads the group and sorts it. Otherwise today's statement runs (kk). Each branch returns rows in keyset order.
|
|
ListKnownRoutesGlobalHop(ctx context.Context, arg ListKnownRoutesGlobalHopParams) ([]ListKnownRoutesGlobalHopRow, 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)
|
|
ListNoPasswordBlocked(ctx context.Context) ([][]byte, error)
|
|
// Newest packet first (first_heard_at, then hash), then its newest observation: walks idx_packets_origin and
|
|
// probes each packet's observations, so a page costs its own rows, not the node's history.
|
|
// @cursor is the previous page's last observation id (0 starts at the top); its packet gives its place in this
|
|
// order. A cursor whose observation is gone matches nothing, which ends the list.
|
|
ListNodeObservations(ctx context.Context, arg ListNodeObservationsParams) ([]ListNodeObservationsRow, error)
|
|
// Readings of one target in [since, until) ascending; until is open when NULL. Untrusted ones only when asked for.
|
|
ListNodeReadings(ctx context.Context, arg ListNodeReadingsParams) ([]ListNodeReadingsRow, error)
|
|
// Limit the filtered node page before enriching IATA membership and neighbours.
|
|
ListNodes(ctx context.Context, arg ListNodesParams) ([]ListNodesRow, error)
|
|
// ListNodes by name, type, neighbour count or last seen, keyset-paged, in the web table's order: unnamed
|
|
// nodes last, unknown types after sensor, ties newest first (last seen ties by id).
|
|
ListNodesSorted(ctx context.Context, arg ListNodesSortedParams) ([]ListNodesSortedRow, error)
|
|
ListObservationsForPacket(ctx context.Context, packetHash []byte) ([]ListObservationsForPacketRow, error)
|
|
// Advert observations (payload_type 4) heard by one observer, oldest id first, after @cursor_id
|
|
// (0 starts at the beginning). Reads idx_observations_adverts; needs payload_type on every observation.
|
|
// 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
|
|
// $13..$18 are the ingest process's live counts (obscount): for an hour from $13 on, the whole
|
|
// minutes before $14 come from the counts and only [$14, slice end) is read raw.
|
|
ListObserverDirectory(ctx context.Context, arg ListObserverDirectoryParams) (string, error)
|
|
// The observer's requested assignments to other targets that are still requested, with the age of each target's
|
|
// oldest request, oldest first. A withdrawn target's assignment waits for its own election and holds no seat.
|
|
ListObserverRequestedSeats(ctx context.Context, arg ListObserverRequestedSeatsParams) ([]ListObserverRequestedSeatsRow, error)
|
|
// Observers newest last_seen first; the cursor is the (last_seen, id) of the last row.
|
|
ListObservers(ctx context.Context, arg ListObserversParams) ([]ListObserversRow, error)
|
|
// Targets with an assignment whose candidate is gone. A requested assignment is kept while its observer's claim
|
|
// accepts requests: it is made before the device lists the target, and the claim rows of an expired claim are gone.
|
|
ListOrphanPollingTargets(ctx context.Context) ([][]byte, error)
|
|
// The sites with the most packets among observations above after_id; the first-time verification pages them.
|
|
ListPacketSiteSamples(ctx context.Context, arg ListPacketSiteSamplesParams) ([]ListPacketSiteSamplesRow, 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)
|
|
// The original region page statement, before the site read model: no page runs it (planpolicy.VerificationOnly);
|
|
// tests compare region pages with it. 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)
|
|
// One range per named scope; a zero-hit scope costs a single index probe.
|
|
ListPacketsByScopes(ctx context.Context, arg ListPacketsByScopesParams) ([]ListPacketsByScopesRow, error)
|
|
// ListPacketsByScopes with the type tests inside each scope range (index-only through the included columns).
|
|
ListPacketsByScopesTypes(ctx context.Context, arg ListPacketsByScopesTypesParams) ([]ListPacketsByScopesTypesRow, error)
|
|
// One site: one range of its (site_heard_at, packet_hash) index.
|
|
ListPacketsBySite(ctx context.Context, arg ListPacketsBySiteParams) ([]ListPacketsBySiteRow, error)
|
|
// The page rows for keys from ListPacketsBySitesSince and the window statements, in the given order.
|
|
ListPacketsBySiteKeys(ctx context.Context, arg ListPacketsBySiteKeysParams) ([]ListPacketsBySiteKeysRow, error)
|
|
// Two or more sites with a cursor: one range per site; a packet whose newest requested-site row is at or above
|
|
// the cursor was already returned, so the in-range re-check drops it.
|
|
ListPacketsBySites(ctx context.Context, arg ListPacketsBySitesParams) ([]ListPacketsBySitesRow, error)
|
|
// ListPacketsBySites for the first page or one site, where the re-check cannot match.
|
|
ListPacketsBySitesFirst(ctx context.Context, arg ListPacketsBySitesFirstParams) ([]ListPacketsBySitesFirstRow, error)
|
|
// ListPacketsBySitesScopedWindow with a type filter: one range per (site, scope, payload type, route type).
|
|
ListPacketsBySitesScopedTypedWindow(ctx context.Context, arg ListPacketsBySitesScopedTypedWindowParams) ([]ListPacketsBySitesScopedTypedWindowRow, error)
|
|
// ListPacketsBySitesWindow with one range per (site, named scope).
|
|
ListPacketsBySitesScopedWindow(ctx context.Context, arg ListPacketsBySitesScopedWindowParams) ([]ListPacketsBySitesScopedWindowRow, error)
|
|
// Page keys for many type pairs (Go sends no window: since and until are -infinity and infinity; the window tests
|
|
// stay so the statement keeps its meaning for any window). Each site range is read to at most scan_depth entries, as deep as the observation statement reads, and the
|
|
// window and type tests filter what was read; the last row (is_floor) is the floor below which this page is
|
|
// incomplete, when a range filled scan_depth. Rows below the floor are left to the next page.
|
|
ListPacketsBySitesSince(ctx context.Context, arg ListPacketsBySitesSinceParams) ([]ListPacketsBySitesSinceRow, error)
|
|
// One range per (site, payload type, route type); Go passes each type list deduplicated and sends only a few
|
|
// type pairs here.
|
|
ListPacketsBySitesTyped(ctx context.Context, arg ListPacketsBySitesTypedParams) ([]ListPacketsBySitesTypedRow, error)
|
|
// ListPacketsBySitesTyped for the first page or one site.
|
|
ListPacketsBySitesTypedFirst(ctx context.Context, arg ListPacketsBySitesTypedFirstParams) ([]ListPacketsBySitesTypedFirstRow, error)
|
|
// ListPacketsBySitesWindow with a type filter: one range per (site, payload type, route type) instead of each site's
|
|
// range, so a rare type reads at most page_limit entries per pair. Go sends only lists below the 64 pairs that mean
|
|
// every type.
|
|
ListPacketsBySitesTypedWindow(ctx context.Context, arg ListPacketsBySitesTypedWindowParams) ([]ListPacketsBySitesTypedWindowRow, error)
|
|
// Page keys for a first_heard_at window (absent sides are -infinity and infinity), filtered by types. The caller
|
|
// passes lo_ts = since - 30 minutes and hi_ts = until + 30 minutes (-infinity / infinity without that side), and
|
|
// main_ts/main_hash = the cursor, lowered to (hi_ts, a hash above every stored one) when the cursor is above hi_ts.
|
|
// An entry first heard in the window and heard at the site within 30 minutes of that lies in [lo_ts, hi_ts], so
|
|
// each site is read only from the page start down to lo_ts; the two partial indexes add the entries heard there
|
|
// more than 30 minutes later or earlier. Each part stops at page_limit matching entries. Go passes each type list
|
|
// deduplicated within its domain, so 64 pairs is every type: then the type test folds away and cannot steer a part
|
|
// to the type index.
|
|
ListPacketsBySitesWindow(ctx context.Context, arg ListPacketsBySitesWindowParams) ([]ListPacketsBySitesWindowRow, error)
|
|
// One range per (payload type, route type) pair; DISTINCT keeps a repeated type from returning rows twice.
|
|
ListPacketsByTypes(ctx context.Context, arg ListPacketsByTypesParams) ([]ListPacketsByTypesRow, error)
|
|
// Unfiltered packet page: newest (last_heard_at, packet_hash) first.
|
|
ListPacketsPage(ctx context.Context, arg ListPacketsPageParams) ([]ListPacketsPageRow, error)
|
|
// first_heard_at window. Branch 1 walks last_heard_at down to since; branch 2 adds the rows a concurrent
|
|
// upsert left with last_heard_at below first_heard_at, which that bound cannot see.
|
|
ListPacketsWindow(ctx context.Context, arg ListPacketsWindowParams) ([]ListPacketsWindowRow, error)
|
|
// ListPacketsWindow with branch 1 run once per named scope and branch 2 limited to those scopes.
|
|
ListPacketsWindowScoped(ctx context.Context, arg ListPacketsWindowScopedParams) ([]ListPacketsWindowScopedRow, error)
|
|
ListPollingAdminStops(ctx context.Context) ([]PollingAdminStop, error)
|
|
// Evidence: zero-hop adverts of the target this observer heard since $3, with missing signal (0/0) left out. mean_snr is 0 when n is 0.
|
|
ListPollingCandidates(ctx context.Context, arg ListPollingCandidatesParams) ([]ListPollingCandidatesRow, error)
|
|
ListPollingObservers(ctx context.Context) ([]PollingObserver, error)
|
|
// A target with only expired claims is still listed while it has assignment rows, so the caller can clear them. A
|
|
// requested target is always listed, so its requests move between waiting and active.
|
|
ListPollingTargets(ctx context.Context, receivedAt pgtype.Timestamptz) ([][]byte, error)
|
|
// Every region with its members, for reconciling imported MeshMapper groups.
|
|
ListRegionState(ctx context.Context) ([]ListRegionStateRow, error)
|
|
// ============================================================
|
|
// REGIONS
|
|
// ============================================================
|
|
// Each region with its detail and member IATAs, so clients resolve every region in one call.
|
|
ListRegions(ctx context.Context) ([]ListRegionsRow, error)
|
|
ListRepeaterSources(ctx context.Context) ([]MeshmapperRepeaterSource, error)
|
|
// Observers that could take a requested target: a live claim that accepts requests and zero-hop advert evidence for
|
|
// the target since first_heard_at (missing signal 0/0 left out). They need not name the target in their claim: a
|
|
// device learns of a requested target from the owners answer. held counts the requested targets the claim names;
|
|
// seats_elsewhere counts this observer's requested assignments to other still-requested targets whose oldest request
|
|
// is older than this target's, so seats go to the oldest requests first.
|
|
ListRequestCandidates(ctx context.Context, arg ListRequestCandidatesParams) ([]ListRequestCandidatesRow, error)
|
|
// The observers whose claim accepts requests, in key order, which is the order their seat locks are taken in.
|
|
ListRequestObserverKeys(ctx context.Context, receivedAt pgtype.Timestamptz) ([][]byte, error)
|
|
// The targets that hold a requested assignment of any of the observers: the ones a seat decision may take a seat
|
|
// from, locked with the election in key order.
|
|
ListRequestedAssignedTargets(ctx context.Context, observers [][]byte) ([][]byte, error)
|
|
// When each observer handed this target as a requested one stored its newest trusted reading of it.
|
|
ListRequestedAssigneeReadings(ctx context.Context, targetPublicKey []byte) ([]ListRequestedAssigneeReadingsRow, error)
|
|
// The observers handed this target as a requested one, with their rank (0 polls).
|
|
ListRequestedAssignees(ctx context.Context, targetPublicKey []byte) ([]ListRequestedAssigneesRow, 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)
|
|
ListTargetAdminStops(ctx context.Context, targetPublicKey []byte) ([][]byte, error)
|
|
ListTargetOtherStates(ctx context.Context, targetPublicKey []byte) ([]ListTargetOtherStatesRow, error)
|
|
ListTargetRequests(ctx context.Context, targetPublicKey []byte) ([]ListTargetRequestsRow, error)
|
|
ListTargetServedVersions(ctx context.Context, targetPublicKey []byte) ([]ListTargetServedVersionsRow, 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 after 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.DecryptBackfill.
|
|
ListUndecryptedGroupTextPackets(ctx context.Context) ([]ListUndecryptedGroupTextPacketsRow, error)
|
|
// Like ListUndecryptedGroupTextPackets, limited to channels that just gained a key.
|
|
ListUndecryptedGroupTextPacketsByHash(ctx context.Context, hashes [][]byte) ([]ListUndecryptedGroupTextPacketsByHashRow, error)
|
|
ListUserAlertRules(ctx context.Context, userID uuid.UUID) ([]ListUserAlertRulesRow, error)
|
|
ListUserAtlasPins(ctx context.Context, userID uuid.UUID) ([]ListUserAtlasPinsRow, error)
|
|
ListUserSessions(ctx context.Context, arg ListUserSessionsParams) ([]ListUserSessionsRow, error)
|
|
// A user's requests, oldest first, with the node's current id and name, the observer that polls the repeater and
|
|
// the newest trusted reading. No password column is read; poller_id is the nil uuid when nobody polls it. The
|
|
// poller's own claim is live when received after received_after: poller_claim_at is null without one, and
|
|
// poller_claimed says whether that claim lists the repeater (poller_state is its state then).
|
|
ListUserTelemetryRequests(ctx context.Context, arg ListUserTelemetryRequestsParams) ([]ListUserTelemetryRequestsRow, error)
|
|
// search is a LIKE pattern with its wildcards already escaped, or empty for everyone. The cursor is the last row of
|
|
// the previous page; the first page passes a far-future time and the max uuid.
|
|
ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)
|
|
ListZoneBoundaries(ctx context.Context) ([]MeshmapperZoneBoundary, error)
|
|
ListZoneLists(ctx context.Context) ([]MeshmapperZoneList, error)
|
|
LiveUserDevices(ctx context.Context, userIds []uuid.UUID) ([]LiveUserDevicesRow, error)
|
|
// Serializes one observer's reading inserts until the transaction ends, so its rate and budget checks see each
|
|
// other. Class 25191, beside the target class and the (25189, n) job locks.
|
|
LockPollingObserver(ctx context.Context, observerPublicKey []byte) error
|
|
// Serializes the seat decisions of one observer until the transaction ends. Class 25192, beside the target class
|
|
// (25190) and the reading-insert class (25191). Taken before the target lock, in key order, so two elections
|
|
// cannot wait on each other.
|
|
LockPollingSeats(ctx context.Context, observerPublicKey []byte) error
|
|
// Serializes elections of one target until the transaction ends. Class 25190 in the two-key space, which never
|
|
// meets the one-key migration lock; the schema keeps instances in other schemas apart.
|
|
LockPollingTarget(ctx context.Context, targetPublicKey []byte) 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)
|
|
LockUserAtlas(ctx context.Context, userID uuid.UUID) (LockUserAtlasRow, error)
|
|
// Serializes session issuance and credential changes of one user until the transaction ends. NO KEY UPDATE keeps
|
|
// the foreign-key checks of unrelated inserts (Atlas, requests) from waiting on it.
|
|
LockUserCredentials(ctx context.Context, id uuid.UUID) (LockUserCredentialsRow, error)
|
|
// Serializes one user's request creation (the limit) without blocking the foreign-key checks on their rows.
|
|
LockUserForRequests(ctx context.Context, id uuid.UUID) (uuid.UUID, error)
|
|
MarkAlertDeviceDelivered(ctx context.Context, arg MarkAlertDeviceDeliveredParams) error
|
|
// A notice is delivered once both channels are done.
|
|
MarkAlertsDelivered(ctx context.Context, arg MarkAlertsDeliveredParams) error
|
|
// The mail went out (sent_at set) or none was needed.
|
|
MarkAlertsEmailDone(ctx context.Context, arg MarkAlertsEmailDoneParams) error
|
|
MarkAlertsPushDone(ctx context.Context, arg MarkAlertsPushDoneParams) 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
|
|
MarkRequestAttention(ctx context.Context, arg MarkRequestAttentionParams) error
|
|
MaxChannelMessageID(ctx context.Context) (int64, error)
|
|
MaxObservationID(ctx context.Context) (int64, error)
|
|
MinObservationID(ctx context.Context) (int64, error)
|
|
// The first message id above after_id, or 0 when there is none.
|
|
NextChannelMessageID(ctx context.Context, afterID int64) (int64, error)
|
|
NodeHasReadings(ctx context.Context, targetPublicKey []byte) (bool, error)
|
|
NodeIDsByKeys(ctx context.Context, dollar_1 [][]byte) ([]NodeIDsByKeysRow, error)
|
|
NodeLatestTrustedReadingAt(ctx context.Context, targetPublicKey []byte) (pgtype.Timestamptz, error)
|
|
// Assigned observers of one target by rank. An assignment whose observer has no row is left out.
|
|
NodePollingAssignments(ctx context.Context, targetPublicKey []byte) ([]NodePollingAssignmentsRow, error)
|
|
NodePublicKey(ctx context.Context, id uuid.UUID) ([]byte, error)
|
|
// The id skip + 1 observations above after_id: (after_id, id] holds exactly skip + 1 of them. 0 when fewer remain.
|
|
ObservationIDAbove(ctx context.Context, arg ObservationIDAboveParams) (int64, error)
|
|
// The id that bounds the newest n observations at or below through_id from below: (id, through_id] holds exactly n
|
|
// of them. 0 when fewer than n + 1 remain.
|
|
ObservationIDBelow(ctx context.Context, arg ObservationIDBelowParams) (int64, error)
|
|
ObserverIDsByKeys(ctx context.Context, dollar_1 [][]byte) ([]ObserverIDsByKeysRow, error)
|
|
ObserverKeysByIDs(ctx context.Context, dollar_1 []uuid.UUID) ([]ObserverKeysByIDsRow, error)
|
|
// Targets with a waiting or active request whose node no observer has heard since cutoff and whose newest such
|
|
// request was enabled before it. Requests with no node row count from the enabling alone.
|
|
OfflineRequestTargets(ctx context.Context, cutoff pgtype.Timestamptz) ([][]byte, error)
|
|
OldestMissingRollupHour(ctx context.Context) (pgtype.Timestamptz, error)
|
|
OldestTargetRequest(ctx context.Context, targetPublicKey []byte) (pgtype.Timestamptz, error)
|
|
PacketSitesTotalBytes(ctx context.Context) (int64, error)
|
|
// Who a live token belongs to, without using it.
|
|
PeekUserToken(ctx context.Context, arg PeekUserTokenParams) (uuid.UUID, error)
|
|
// Notices of a finished pass (or one that started before pass_timeout_before and never finished) only, with a channel
|
|
// that is not done and is due, and whole user and pass groups only, so one pass's notices for a user stay in one mail:
|
|
// groups are taken in order while the running total stays within row_limit, and the first group is taken whatever
|
|
// its size. email_due and push_due say which channels to try.
|
|
PendingAlerts(ctx context.Context, arg PendingAlertsParams) ([]PendingAlertsRow, error)
|
|
PollingAdminRequestCounts(ctx context.Context, targets [][]byte) ([]PollingAdminRequestCountsRow, error)
|
|
// Each live candidate and each assigned observer of the given targets. rank is -1 for an unassigned candidate.
|
|
// Claim fields come only from a live claim, so an assignment left over from an expired one shows them empty.
|
|
PollingAdminTargetRows(ctx context.Context, arg PollingAdminTargetRowsParams) ([]PollingAdminTargetRowsRow, error)
|
|
// Targets with a live candidate or any assignment row, newest claim first. latest_trusted uses the owners rule.
|
|
PollingAdminTargets(ctx context.Context, arg PollingAdminTargetsParams) ([]PollingAdminTargetsRow, error)
|
|
PollingClaimReceivedAt(ctx context.Context, observerPublicKey []byte) (pgtype.Timestamptz, error)
|
|
PollingElectionUnlock(ctx context.Context) error
|
|
PollingObserverFlags(ctx context.Context, observerPublicKey []byte) (PollingObserverFlagsRow, error)
|
|
// assigned counts the target's assignment rows. latest_ts only trusts readings from an assigned observer with
|
|
// advert evidence (the newest per assignee, then the newest of those), so an observer Beacon has never heard the repeater through cannot stand others down. A target the
|
|
// observer was handed as a requested one is listed even before its claim names it (that is how it learns of it);
|
|
// claimed_requested is true when the claim names it as requested; target_requested when a request is in use for it.
|
|
// accepts_requests and request_slots are the claim's, for polling.OfferSeats. The observer's flags and the password
|
|
// in use come from the same statement, so an answer never pairs a password with an approval it did not exist under.
|
|
// The password is only read for a requested assignment of an unblocked observer whose claim accepts requests.
|
|
PollingOwnerRows(ctx context.Context, arg PollingOwnerRowsParams) ([]PollingOwnerRowsRow, error)
|
|
PollingTargetExists(ctx context.Context, targetPublicKey []byte) (bool, 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)
|
|
// The header and the pins in one statement, so they come from one snapshot. A user with no Atlas gets no rows.
|
|
ReadUserAtlas(ctx context.Context, userID uuid.UUID) ([]ReadUserAtlasRow, error)
|
|
// Delete node_neighbors where the neighbor has departed from node_short_ids
|
|
// for that IATA, or where its prefix_4 is now ambiguous.
|
|
// Check each distinct regional neighbor once. Keep the one-row lookup correlated:
|
|
// a flattened anti-join can rescan the whole identity catalogue for each edge.
|
|
ReconfirmNeighbors(ctx context.Context) error
|
|
// The next batch_size routes after the cursor in pkey order: deletes those with a departed hop
|
|
// node or a hop prefix matching >1 node in that IATA (length-aware, reconfirm_amb). Writes no stamp.
|
|
// The DELETE re-checks the newest row version. An empty last_iata means the walk passed the end.
|
|
ReconfirmRoutesBatch(ctx context.Context, arg ReconfirmRoutesBatchParams) (ReconfirmRoutesBatchRow, error)
|
|
// Count the bounded slice and return its last key. A short slice ends the cycle.
|
|
ReconfirmSliceEnd(ctx context.Context, arg ReconfirmSliceEndParams) (ReconfirmSliceEndRow, error)
|
|
// Keep 16 adverts, including the INSERT's row. Sibling CTEs share a snapshot:
|
|
// the table scan alone cannot see the new row. A conflict returns no extra row.
|
|
RecordClockDrift(ctx context.Context, arg RecordClockDriftParams) error
|
|
// Written on every owners answer that lists the target, so it only touches the row when the version changed or the
|
|
// last write is an hour old.
|
|
RecordServedVersion(ctx context.Context, arg RecordServedVersionParams) 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
|
|
RefreshPortalUser(ctx context.Context, arg RefreshPortalUserParams) (User, 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
|
|
// Stores the same password under a newer hash, only while the hash is still the one that was verified.
|
|
RehashUserPassword(ctx context.Context, arg RehashUserPasswordParams) (int64, error)
|
|
// rows is a JSON array of {"key": hex, "data": {...}}; unchanged rows are not rewritten.
|
|
// fetchedAt comes from the source's checked_at when read.
|
|
ReplaceRepeaters(ctx context.Context, arg ReplaceRepeatersParams) error
|
|
RequestNode(ctx context.Context, id uuid.UUID) (RequestNodeRow, error)
|
|
// A request that is fine again can be announced again the next time it needs attention.
|
|
ResetRequestAttention(ctx context.Context) 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
|
|
// Every Roll statement inserts in its table's primary-key order, so an hour's rows for one IATA share a few
|
|
// adjacent heap pages; the per-(hour, IATA) stats probes then read those pages instead of one page per row.
|
|
RollIATAObservations(ctx context.Context, hour pgtype.Timestamptz) error
|
|
RollNodeActivity(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
|
|
// NULL etag/checked_at retain the last good list's state after an error or 304;
|
|
// a new URL drops the old site's ETag.
|
|
SaveRepeaterSource(ctx context.Context, arg SaveRepeaterSourceParams) 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.
|
|
// hop_count + 0: no hop_count-led index may supply this order (a LIMIT walk would check the GIN conditions row by row).
|
|
SearchKnownRoutesByNodes(ctx context.Context, arg SearchKnownRoutesByNodesParams) ([]SearchKnownRoutesByNodesRow, error)
|
|
// Packets whose hash falls in [lo, hi). The materialized CTE pins the primary key
|
|
// range scan; otherwise generic plans walk idx_packets_last_heard across the table.
|
|
// IATA filtering is a membership probe, so ordering and the cursor stay on global
|
|
// last_heard_at.
|
|
SearchPacketsByHashPrefix(ctx context.Context, arg SearchPacketsByHashPrefixParams) ([]SearchPacketsByHashPrefixRow, 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
|
|
SetPollingObserver(ctx context.Context, arg SetPollingObserverParams) error
|
|
SetPollingState(ctx context.Context, arg SetPollingStateParams) error
|
|
SetRollupHourPartial(ctx context.Context, hour pgtype.Timestamptz) error
|
|
SetUserAlertChannels(ctx context.Context, arg SetUserAlertChannelsParams) (int64, error)
|
|
SetUserDisabled(ctx context.Context, arg SetUserDisabledParams) (int64, error)
|
|
SetUserEmailVerified(ctx context.Context, arg SetUserEmailVerifiedParams) (int64, error)
|
|
SetUserPassword(ctx context.Context, arg SetUserPasswordParams) (int64, error)
|
|
SetUserPendingEmail(ctx context.Context, arg SetUserPendingEmailParams) (int64, error)
|
|
// Read-only. Visits, through each time-ordered packet_sites index, every entry whose key was written in the last
|
|
// lookback (2 minutes). An index scan that reaches an entry whose heap tuple is dead to every snapshot sets the
|
|
// entry's LP_DEAD hint; when that leaf later fills, the inserting backend deletes hinted entries instead of splitting
|
|
// (nbtree simple deletion). Keeps the three indexes at about 2x a fresh build instead of 4-9x. Changes no row.
|
|
// The ORDER BY ... LIMIT keeps every lateral a per-front index range scan (never flattened into a join).
|
|
// The cap is far above any front's 2-minute volume (the busiest site: about 150 entries) and only bounds the gauge.
|
|
SweepPacketSitesFronts(ctx context.Context, lookback pgtype.Interval) (SweepPacketSitesFrontsRow, error)
|
|
// OfflineRequestTargets for one target, asked again under the target's lock before its requests are disabled.
|
|
TargetStillOffline(ctx context.Context, arg TargetStillOfflineParams) (bool, error)
|
|
TelemetryRequestTarget(ctx context.Context, arg TelemetryRequestTargetParams) ([]byte, error)
|
|
// Write-through for a cached keyed channel: the UpsertChannel conflict update, by id.
|
|
// No row (deleted or re-keyed since cached) sends the caller back to UpsertChannel.
|
|
TouchChannel(ctx context.Context, arg TouchChannelParams) (int32, error)
|
|
// Write-through for a cached hash-only channel: the UpsertChannelHashOnly conflict update, by id.
|
|
TouchChannelHashOnly(ctx context.Context, arg TouchChannelHashOnlyParams) (int32, 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
|
|
TouchPollingOtherState(ctx context.Context, arg TouchPollingOtherStateParams) error
|
|
TouchUserLogin(ctx context.Context, arg TouchUserLoginParams) (int64, error)
|
|
TouchUserSession(ctx context.Context, arg TouchUserSessionParams) (int64, error)
|
|
// Page keys straight from the observations, independent of packet_sites. floor_ts bounds the read: keys at or
|
|
// above it are exact, because a packet's newest requested-site hearing is unchanged by dropping older ones.
|
|
TruthPacketsBySitesPage(ctx context.Context, arg TruthPacketsBySitesPageParams) ([]TruthPacketsBySitesPageRow, error)
|
|
TryAlertsEvalLock(ctx context.Context) (bool, error)
|
|
TryAlertsSendLock(ctx context.Context) (bool, error)
|
|
TryPollingElectionLock(ctx context.Context) (bool, 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)
|
|
TurnOnAlertPush(ctx context.Context, id uuid.UUID) 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)
|
|
UpdatePollingTarget(ctx context.Context, arg UpdatePollingTargetParams) error
|
|
UpdateTelemetryRequest(ctx context.Context, arg UpdateTelemetryRequestParams) error
|
|
UpdateUserDisplayName(ctx context.Context, arg UpdateUserDisplayNameParams) (int64, error)
|
|
// A change of thresholds, or turning a rule on, starts its state again: no stale notification, and the data the
|
|
// evaluator looks at starts now.
|
|
UpsertAlertRule(ctx context.Context, arg UpsertAlertRuleParams) (UpsertAlertRuleRow, error)
|
|
UpsertBackgroundState(ctx context.Context, arg UpsertBackgroundStateParams) error
|
|
// ============================================================
|
|
// CHANNELS
|
|
// ============================================================
|
|
// Upsert a keyed channel by (hash, key_fingerprint). Returns the channel row. A NULL fingerprint never matches that key,
|
|
// so the store sends hash-only records (key unknown) to UpsertChannelHashOnly or UpsertChannelHashOnlyNamed.
|
|
UpsertChannel(ctx context.Context, arg UpsertChannelParams) (Channel, error)
|
|
UpsertChannelHashOnly(ctx context.Context, channelHash []byte) (int32, error)
|
|
// UpsertChannel for a hash-only channel heard with a name or hashtag: the hash-only conflict target, and
|
|
// UpsertChannel's insert and conflict update.
|
|
UpsertChannelHashOnlyNamed(ctx context.Context, arg UpsertChannelHashOnlyNamedParams) (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)
|
|
// Applies only a claim newer than the stored one and received at least the claim interval after it, checked in
|
|
// this statement so concurrent claims cannot both pass. Zero rows means it was ignored.
|
|
UpsertPollingClaim(ctx context.Context, arg UpsertPollingClaimParams) (int64, error)
|
|
UpsertRegion(ctx context.Context, arg UpsertRegionParams) (int32, error)
|
|
// ============================================================
|
|
// TRANSPORT CODES
|
|
// ============================================================
|
|
UpsertTransportScope(ctx context.Context, arg UpsertTransportScopeParams) error
|
|
// The handle is unique, so a registration for a handle another session holds moves that row (crossing users on
|
|
// purpose: a phone belongs to one account, so the previous user's alerts never reach its next user).
|
|
UpsertUserDevice(ctx context.Context, arg UpsertUserDeviceParams) error
|
|
UserAlertChannels(ctx context.Context, id uuid.UUID) (UserAlertChannelsRow, error)
|
|
// Only enabled rules: back_online needs a gone_quiet rule that is on.
|
|
UserAlertRuleKinds(ctx context.Context, arg UserAlertRuleKindsParams) ([]string, error)
|
|
UserByEmail(ctx context.Context, email string) (User, error)
|
|
UserByID(ctx context.Context, id uuid.UUID) (User, error)
|
|
UserByProviderSubject(ctx context.Context, arg UserByProviderSubjectParams) (User, error)
|
|
UserByUsername(ctx context.Context, lower string) (User, error)
|
|
UserHasAtlasPin(ctx context.Context, arg UserHasAtlasPinParams) (bool, error)
|
|
UserHasLiveDevice(ctx context.Context, userID uuid.UUID) (bool, error)
|
|
UserRequestTargets(ctx context.Context, userID uuid.UUID) ([][]byte, error)
|
|
// A session is live when it is not ended, not past either expiry, and its user is not disabled.
|
|
UserSessionByTokenHash(ctx context.Context, arg UserSessionByTokenHashParams) (UserSessionByTokenHashRow, error)
|
|
UserSessionLive(ctx context.Context, arg UserSessionLiveParams) (bool, error)
|
|
}
|
|
|
|
var _ Querier = (*Queries)(nil)
|