Repository navigation
Closed
Labels
area:docsTouches the docs areaarea:serverTouches the server areaenhancementNew feature or requestready-for-agentFully specified, ready for an AFK agent
Description
Part of the launch (#416).
Problem
Most requests leave no trace. Wide events (one structured record per request, sent to stdout for CloudWatch and to PostHog) cover only the runtime routes today. Publish, the portal, sign-in and device login, discovery, connections and the SDK routes emit about fifteen bare Effect.log lines. When a partner says "publish failed", there's nothing to look at.
Do
- One request wide event for every non-runtime route. Use the existing accumulator and sink in
@patchy/analytics/wide-events(theRequestEventshape,WideEvents.enrich), with the runtime path's field rules: ids, principal, route, outcome and refusal code, duration and sizes. Never tokens, request bodies, draft HTML, filenames or SQL. Every event already carriesdeploymentRevision, which is how a request is traced to the build that served it. docs/OPERATIONS.md: how to find a request's event in CloudWatch.
Out
GET /api/version, dropped 2026-10-02./api/releasedescribes the CLI package and doesn't change on a server-only deploy, so it can't stand in. Nothing needs a new public route, though: feat(infra): production infrastructure in AWS CDK and the deploy workflow #415's deploy workflow confirms a rollout through ECS, events carrydeploymentRevision, and feat(infra): production infrastructure in AWS CDK and the deploy workflow #415's deep health check reports the revision for a quick outside check.- Stays on server: wide events for every route, CLI usage and SDK installs #383: the
Patchy-Cliheader, SDK install events, and replacing the bareEffect.loglines.
Done when
Every route emits one event per request, and a test pins that no event carries a token or a request body.
Metadata
Metadata
Assignees
Labels
area:docsTouches the docs areaarea:serverTouches the server areaenhancementNew feature or requestready-for-agentFully specified, ready for an AFK agent
Activity
allisonmahmood commentedon Sep 2, 2026
Grouped with the llms.txt pair (#36, #108): do all three together once staging is up and running, since each only earns its keep with a deployed server to ask. When picked up, the Do list needs refreshing: the server is on Effect now (Fastify is gone, so this is Effect's built-in request logger with
disableLoggerturned off in production), anddocs/SELF_HOSTING.mdno longer exists, so the reading-logs paragraph goes in whatever doc staging produces.[-]feat(server): GET /api/version and production request logging[/-][+]feat(server): a request wide event for every route, and GET /api/version[/+]allisonmahmood commentedon Oct 2, 2026
Rescoped 2026-10-02 for the launch. The old Do list predated Effect (Fastify) and the wide-events decision. This now takes #383's first bullet, a request event for every route on the existing wide-events machinery, so we don't ship a plain request logger that #383 would replace. It no longer waits for staging or for #36/#108.
[-]feat(server): a request wide event for every route, and GET /api/version[/-][+]feat(server): a request wide event for every route[/+]allisonmahmood commentedon Oct 2, 2026
Dropped
GET /api/version(2026-10-02), after the agent picking this up asked whether/api/releasealready covers it. It doesn't:/api/releasedescribes the CLI package, which a server-only deploy leaves unchanged. Neither route is needed, though. ECS confirms rollouts in #415's deploy workflow, every wide event carriesdeploymentRevision, and #415's deep health check now reports the revision for a quick outside check.allisonmahmood commentedon Oct 2, 2026
Agent Brief
Category: enhancement
Summary: Every server request outside the runtime path emits exactly one
RequestEventwide event, following the runtime path's field rules.Current behavior:
Only
/api/runtime/*produces wide events. Each runtime handler wraps its work inWideEvents.withEvent({ type: "request" }, …)and enriches it with ids, outcome, refusal code, limits and sizes. The subscriptions route opens its own request events and the stream emitsstreamevents. Every other route emits nothing:/:company/:name/*,/~content/…,/~shell/…); the SDK tarball;The server runs with Effect's request logger disabled (
disableLogger: true), and nothing replaces it. There are 34 bareEffect.logcall sites; they stay on #383.Desired behavior:
Each request outside
/api/runtime/*produces exactly onetype: "request"event through the existingWideEventsservice and sink (stdout JSON plus PostHog). That includes requests the API guard refuses and requests no route matches./api/runtime/*, or every runtime call gains a second, parent-linked event. The patch dev server mounts the runtime routes without the server's middleware and must keep working as it does today./api/patches/:patchId,/:company/:name/*, or the fallback's own pattern for unmatched requests), plus the method and HTTP status. The raw URL and query string never appear, because they carry company handles, patch names, file paths, codes and return URLs.HttpApiBuilderencodes an endpoint's typed errors into responses inside the route, and the sharedrefusehelper in@patchy/apireturns 4xx responses directly. An outer layer therefore sees a successful exit for a refusal, and the exit alone would recordsuccess. The rules:success;refusedand carries thecodefrom its body when the body has one;failure;interrupted.viewerIdand their company incompanyId. Per the analytics glossary, the viewer is the principal; the machine token is provenance and is not recorded.Authorizationmiddleware and the session helpers the pages use. Individual routes shouldn't each have to add them.patchId, plusversionIdwhere one exists. A publish adds the version it created.durationMscomes fromwithEventas it does now.requestBytescomes from the declared length, without reading the body.responseBytesis the size of the response sent./healthzand the deep check feat(infra): production infrastructure in AWS CDK and the deploy workflow #415 adds from several places. That traffic adds up to tens of thousands of requests a day, would swamp the event stream and the PostHog bill, and tells us nothing. Exclude health-probe routes explicitly.RequestEventgains the fields this needs: route template, method and status. Choose names that read clearly in a CloudWatch query. Make the new fields optional, so runtime events and the patch repo's local runtime keep their shape.Key interfaces:
RequestEventandEventFieldsin@patchy/analytics/wide-events: add the new optional fields.withEventemits only fields declared in the event's schema, so they must be declared there.WideEvents.withEventandWideEvents.enrich: the only way events are built. No second accumulator, logger or sink.docs/OPERATIONS.md: it currently says the server emits one line per runtime call. It now covers every request, and gains a paragraph on finding a request in CloudWatch Logs Insights:type,route,viewerId,outcome,codeand time, and followtraceId;deploymentRevisionnames the build that served the request;Acceptance criteria:
Each of these emits exactly one
type: "request"event with route template, method, status, outcome and duration:A runtime call still emits exactly one request event, unchanged from today.
A refused request has
outcome: "refused"and thecodefrom its response body. Test at least one refusal from an endpoint's typed error (for example, publish with a stale release) and one from the guard (a 429). A 5xx hasoutcome: "failure".An authenticated request carries the user's
viewerIdandcompanyId. A publish carries the resultingpatchIdandversionId./healthzemits no event.A test covers three requests:
It asserts that no emitted event's serialized JSON contains the token, the cookie value, the device code, the HTML, the filename or the raw request path.
docs/OPERATIONS.mddescribes request events for every route and how to find one in CloudWatch.pnpm verifypasses.Out of scope:
GET /api/version, a deployment revision on/api/release, or any other new public route. These were dropped on 2026-10-02: events already carrydeploymentRevision, and feat(infra): production infrastructure in AWS CDK and the deploy workflow #415's health check reports it.Patchy-Cliheader, SDK install events, and replacing the bareEffect.logcall sites (server: wide events for every route, CLI usage and SDK installs #383).feat(server): a request wide event for every route
feat(server): a request wide event for every route
feat(server): a request wide event for every route