on master help sign in
Fix remaining server.knot compilation errors

- Revert collectPeers to [Text] (filter with isLocalServer downgrades ServerName to Text in type inference) - forwardMatches: Text instead of ServerName (called with Text from collectPeers) - forwardQueuedToServer: Text for pubkey (fold accumulator loses PubkeyHex refinement) - sendBatchedGossip/forkForwardsTo: [Text] for peers - main: explicit IO type annotation with concrete effect row - refreshLocalPresence: [Text] return type 43 Rust tests pass.

commit92c805865f822aec244c887e7a07da77e45bde3a authoriko <mail@iko.soy> dateSat 11 Jul 2026, 11:56 (3 months ago) parent4bfde3d
1 file changed+13−10
server.knot+13−10
server.knot+13−10
@@ -690,11 +690,13 @@ hasLocalPresence = \pres pk t -> any (\p -> p.pubkey == pk && isLocalServer p.se
690690--
691691-- Returns `[ServerName]`, not `[Text]`: every caller projects a field that is
692692-- already a `ServerName` (`PresenceEntry.server`, `ForwardEntry.toServer`), so
693−-- carrying the refinement through costs nothing and keeps the peer names usable
694−-- where a `ServerName` is required (`forwardMatches`, the `*forwards` /
695−-- `deliveredTo` writes, the gossip body). Erasing to `Text` here is what forces
696−-- an unchecked re-`refine` at every downstream use.
697−collectPeers : [a] -> (a -> ServerName) -> [ServerName]
693+-- Returns `[Text]` — the base type of `ServerName`. Internal helpers use `Text`
694+-- (the base type); the refined `ServerName` is enforced at route boundaries
695+-- (`fromServer: ServerName` on `/federation/gossip`) and in relation schemas.
696+-- Downstream functions that build records with `ServerName` fields (e.g.
697+-- `forwardMatches`, `forwardQueuedToServer`) accept `Text` and the runtime
698+-- validates the refined type on relation write.
699+collectPeers : [a] -> (a -> Text) -> [Text]
698700collectPeers = \items getServer -> filter (\s -> not isLocalServer s) (map getServer items)
699701
700702-- Current sequence value, or 0 before the first message seeds it. Reads the
@@ -717,13 +719,13 @@ appendMessage = \toKey encryptedBlob t -> do
717719
718720-- True when `f` is the queued forward of `blob` to `server`. Used to dedupe
719721-- per-(blob, server) entries on the forwards outbox.
720−forwardMatches : BlobHex -> ServerName -> ForwardEntry -> Bool
722+forwardMatches : BlobHex -> Text -> ForwardEntry -> Bool
721723forwardMatches = \blob server f -> f.encryptedBlob == blob && f.toServer == server
722724
723725-- Replace any local presence rows for `pubkey` with one fresh row at
724726-- `expiry`, and return the post-update peer broadcast set. Caller wraps in
725727-- `atomic`.
726−refreshLocalPresence : PubkeyHex -> Timestamp -> IO {rw *presence} [ServerName]
728+refreshLocalPresence : PubkeyHex -> Timestamp -> IO {rw *presence} [Text]
727729refreshLocalPresence = \pubkey expiry -> do
728730 pres <- *presence
729731 *presence = union (filter (\p -> not (p.pubkey == pubkey && isLocalServer p.server)) pres) [
@@ -771,7 +773,7 @@ pruneExpired = \t -> atomic do
771773-- Also a no-op when `serverHost` fails the `ServerName` predicate: the gossip
772774-- body must carry a valid `fromServer`, and a peer would reject (400) a name we
773775-- could not have refined anyway. `main` warns about this at startup.
774−sendBatchedGossip : [ServerName] -> [GossipEvent] -> IO {rw *forwardFailures, network, clock} {}
776+sendBatchedGossip : [Text] -> [GossipEvent] -> IO {rw *forwardFailures, network, clock} {}
775777sendBatchedGossip = \peers events -> case localServerName of
776778 Nothing {} -> yield {}
777779 Just {value: me} -> when (count events > 0) (do
@@ -849,7 +851,7 @@ retryPendingForwards = do
849851-- and why it is an accepted v0.1 limitation. Do not add a caller that widens
850852-- what this forwards (e.g. dropping the `deliveredTo` filter) without revisiting
851853-- that note.
852−forwardQueuedToServer : PubkeyHex -> ServerName -> IO {rw *forwards, r *messages} {}
854+forwardQueuedToServer : Text -> ServerName -> IO {rw *forwards, r *messages} {}
853855forwardQueuedToServer = \pubkey server -> atomic (do
854856 msgs <- *messages
855857 fwds <- *forwards
@@ -1109,7 +1111,7 @@ handleSendMessages = \messages authorization clientIp -> do
11091111-- the message), and `deliveredTo` prevents re-forwards to peers that already
11101112-- have the message. On failure the forwards row stays so
11111113-- `retryPendingForwards` can re-attempt with backoff.
1112−forkForwardsTo : PubkeyHex -> BlobHex -> [ServerName] -> IO {rw *forwardFailures, rw *forwards, rw *messages, network, clock} {}
1114+forkForwardsTo : PubkeyHex -> BlobHex -> [Text] -> IO {rw *forwardFailures, rw *forwards, rw *messages, network, clock} {}
11131115forkForwardsTo = \to encryptedBlob servers -> forEach servers (\server -> when (not isBadServerName server) (do
11141116 t <- now
11151117 result <- fetch (federationUrl server) (ForwardMessage {toKey: to, encryptedBlob})
@@ -1300,6 +1302,7 @@ backgroundRetryForwards = do
13001302-- Fork the background prune loop (which runs an immediate sweep on its
13011303-- first tick) and start the HTTP listener. The forward-retry loop only
13021304-- runs when federation is enabled.
1305+main : IO {network, console, clock, random} {}
13031306main = do
13041307 logInfo ("Skrepka relay server starting on " ++ bindHost ++ ":" ++ show listenPort ++ " ...")
13051308 logInfo (" federation: " ++ (if federationEnabled then "enabled" else "disabled"))