Skip to content

Commit 736fc71

Browse files
committed
fix(gastown): gate triage header fallback on dev, wire inReview through alarm status
- Gate X-Gastown-Agent-Id header fallback in handleResolveTriage on ENVIRONMENT === 'development' to prevent header spoofing in production - Add inReview to AlarmStatusOutput tRPC schema, router.d.ts types, and TerminalBar UI so the new bead count is visible in the status pane
1 parent 3eed70c commit 736fc71

4 files changed

Lines changed: 20 additions & 3 deletions

File tree

cloudflare-gastown/src/handlers/rig-triage.handler.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ const ResolveTriageBody = z.object({
3131
export async function handleResolveTriage(c: Context<GastownEnv>, _params: { rigId: string }) {
3232
// In production, agentId comes from the verified JWT. In development
3333
// (where authMiddleware is skipped), fall back to the identity header
34-
// the container client sends with every request.
35-
const agentId = getEnforcedAgentId(c) || c.req.header('X-Gastown-Agent-Id');
34+
// the container client sends with every request. The fallback is gated
35+
// on ENVIRONMENT to prevent header spoofing in production.
36+
const agentId =
37+
getEnforcedAgentId(c) ||
38+
(c.env.ENVIRONMENT === 'development' ? c.req.header('X-Gastown-Agent-Id') : null);
3639
if (!agentId) {
3740
return c.json(resError('Agent authentication required'), 401);
3841
}

cloudflare-gastown/src/trpc/schemas.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ const AlarmStatusOutput = z.object({
204204
beads: z.object({
205205
open: z.number(),
206206
inProgress: z.number(),
207+
inReview: z.number(),
207208
failed: z.number(),
208209
triageRequests: z.number(),
209210
}),

src/components/gastown/TerminalBar.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,13 @@ export function TerminalBar({ townId }: TerminalBarProps) {
148148
type AlarmStatus = {
149149
alarm: { nextFireAt: string | null; intervalMs: number; intervalLabel: string };
150150
agents: { working: number; idle: number; stalled: number; dead: number; total: number };
151-
beads: { open: number; inProgress: number; failed: number; triageRequests: number };
151+
beads: {
152+
open: number;
153+
inProgress: number;
154+
inReview: number;
155+
failed: number;
156+
triageRequests: number;
157+
};
152158
patrol: {
153159
guppWarnings: number;
154160
guppEscalations: number;
@@ -372,6 +378,11 @@ function AlarmStatusPane({ townId }: { townId: string }) {
372378
value={data.beads.inProgress}
373379
highlight={data.beads.inProgress > 0}
374380
/>
381+
<StatusRow
382+
label="In Review"
383+
value={data.beads.inReview}
384+
highlight={data.beads.inReview > 0}
385+
/>
375386
<StatusRow label="Failed" value={data.beads.failed} warn={data.beads.failed > 0} />
376387
<StatusRow
377388
label="Triage"

src/lib/gastown/types/router.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ export declare const gastownRouter: import('@trpc/server').TRPCBuiltRouter<
316316
beads: {
317317
open: number;
318318
inProgress: number;
319+
inReview: number;
319320
failed: number;
320321
triageRequests: number;
321322
};
@@ -914,6 +915,7 @@ export declare const wrappedGastownRouter: import('@trpc/server').TRPCBuiltRoute
914915
beads: {
915916
open: number;
916917
inProgress: number;
918+
inReview: number;
917919
failed: number;
918920
triageRequests: number;
919921
};

0 commit comments

Comments
 (0)