authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-06-20 11:13:27-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-06-20 11:13:27-07:00
log4d790f0064ab99287d3ccb17d2f003f5ed8e8d3e
treeb7d82104a0a9dcc6ca65f903636b9ab682e42e84
parent3ecf3685ba7dbaca04f6a1219a8d42e6094dc526
signature Signed by PGP key B5690EEEBB952194

[codex] Bound relay registration replay diagnostics (#3420)

Co-authored-by: codex <codex@users.noreply.github.com>

2 files changed, 20 insertions(+), 6 deletions(-)

infra/relay/src/agentActivity/MobileRegistrations.test.ts+12-2
...@@ -7,6 +7,7 @@ import * as NodeCryptoLayer from "@effect/platform-node/NodeCrypto";...@@ -7,6 +7,7 @@ import * as NodeCryptoLayer from "@effect/platform-node/NodeCrypto";
7import { describe, expect, it } from "@effect/vitest";7import { describe, expect, it } from "@effect/vitest";
8import * as Effect from "effect/Effect";8import * as Effect from "effect/Effect";
9import * as Layer from "effect/Layer";9import * as Layer from "effect/Layer";
10import * as Logger from "effect/Logger";
10import * as Redacted from "effect/Redacted";11import * as Redacted from "effect/Redacted";
11import { FetchHttpClient } from "effect/unstable/http";12import { FetchHttpClient } from "effect/unstable/http";
1213
...@@ -232,6 +233,11 @@ describe("MobileRegistrations", () => {...@@ -232,6 +233,11 @@ describe("MobileRegistrations", () => {
232 });233 });
233234
234 it.effect("keeps device registration successful when activity replay fails", () => {235 it.effect("keeps device registration successful when activity replay fails", () => {
236 const messages: unknown[] = [];
237 const logger = Logger.make(({ message }) => {
238 messages.push(message);
239 });
240
235 return Effect.gen(function* () {241 return Effect.gen(function* () {
236 const result = yield* Effect.gen(function* () {242 const result = yield* Effect.gen(function* () {
237 const registrations = yield* MobileRegistrations.MobileRegistrations;243 const registrations = yield* MobileRegistrations.MobileRegistrations;
...@@ -250,7 +256,7 @@ describe("MobileRegistrations", () => {...@@ -250,7 +256,7 @@ describe("MobileRegistrations", () => {
250 Effect.fail(256 Effect.fail(
251 new AgentActivityRows.AgentActivityRowListPersistenceError({257 new AgentActivityRows.AgentActivityRowListPersistenceError({
252 userId: "dev:julius",258 userId: "dev:julius",
253 cause: "replay failed",259 cause: "sensitive device replay detail",
254 }),260 }),
255 ),261 ),
256 }),262 }),
...@@ -262,7 +268,11 @@ describe("MobileRegistrations", () => {...@@ -262,7 +268,11 @@ describe("MobileRegistrations", () => {
262 );268 );
263269
264 expect(result).toEqual({ ok: true });270 expect(result).toEqual({ ok: true });
265 });271 expect(messages).toContainEqual([
272 "device registration activity replay failed",
273 { errorTag: "AgentActivityRowListPersistenceError" },
274 ]);
275 }).pipe(Effect.provide(Logger.layer([logger], { mergeWithExisting: false })));
266 });276 });
267277
268 it.effect("unregisters the current user's device", () => {278 it.effect("unregisters the current user's device", () => {
infra/relay/src/agentActivity/MobileRegistrations.ts+8-4
...@@ -51,8 +51,10 @@ export const make = Effect.gen(function* () {...@@ -51,8 +51,10 @@ export const make = Effect.gen(function* () {
51 deviceId: input.payload.deviceId,51 deviceId: input.payload.deviceId,
52 })52 })
53 .pipe(53 .pipe(
54 Effect.tapError((cause) =>54 Effect.tapError((error) =>
55 Effect.logWarning("device registration activity replay failed", { cause }),55 Effect.logWarning("device registration activity replay failed", {
56 errorTag: error._tag,
57 }),
56 ),58 ),
57 Effect.ignore,59 Effect.ignore,
58 );60 );
...@@ -70,8 +72,10 @@ export const make = Effect.gen(function* () {...@@ -70,8 +72,10 @@ export const make = Effect.gen(function* () {
70 deviceId: input.payload.deviceId,72 deviceId: input.payload.deviceId,
71 })73 })
72 .pipe(74 .pipe(
73 Effect.tapError((cause) =>75 Effect.tapError((error) =>
74 Effect.logWarning("live activity registration replay failed", { cause }),76 Effect.logWarning("live activity registration replay failed", {
77 errorTag: error._tag,
78 }),
75 ),79 ),
76 Effect.ignore,80 Effect.ignore,
77 );81 );