From 2c3040d6b04bc429abdb760a707ec76fd626d109 Mon Sep 17 00:00:00 2001 From: Benjamin Fenton <270411513+fentonbenjamin@users.noreply.github.com> Date: Sat, 9 May 2026 13:15:07 -0400 Subject: [PATCH 1/5] Remove production error monitoring from Shape API and engine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drops the lib/monitoring.ts helper and replaces the reportShapeError calls in app/api/shape/route.ts and lib/engine.ts with console.error. The monitoring helper was added in #3 to forward server-side errors to a Sentry-compatible backend; this PR removes that capability. After this change: - Shape API failures (5xx-bound) print to stdout via console.error but are not collected, alerted on, or retained - Model JSON parse failures lose their structured context (engine, profile, raw preview) - The DSN-based opt-in path is gone — no way to enable monitoring without re-adding the helper Console.error in Vercel/Edge runtime is not aggregated. Production errors will go undetected unless a user reports them. --- app/api/shape/route.ts | 10 +------ lib/engine.ts | 9 ++---- lib/monitoring.ts | 68 ------------------------------------------ 3 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 lib/monitoring.ts diff --git a/app/api/shape/route.ts b/app/api/shape/route.ts index e4f7dec..68c1f13 100644 --- a/app/api/shape/route.ts +++ b/app/api/shape/route.ts @@ -1,14 +1,11 @@ import { NextRequest, NextResponse } from "next/server"; import { shape } from "@/lib/shape"; -import { reportShapeError } from "@/lib/monitoring"; import type { ShapeEngine, ShapeProfile } from "@/lib/types"; const VALID_PROFILES = ["narrative_segment_v0", "concept_blob_v0"]; const VALID_ENGINES = ["openai", "local"]; export async function POST(request: NextRequest) { - let engineForReport: ShapeEngine | "unknown" = "unknown"; - let profileForReport: ShapeProfile | "unknown" | "default" = "unknown"; try { const body = await request.json(); const text = body?.text; @@ -30,17 +27,12 @@ export async function POST(request: NextRequest) { engine && VALID_ENGINES.includes(engine) ? (engine as ShapeEngine) : "openai"; - engineForReport = engineOverride; - profileForReport = profileOverride ?? "default"; const result = await shape(text, profileOverride, engineOverride); return NextResponse.json(result); } catch (err: unknown) { const message = err instanceof Error ? err.message : "Unknown error"; - await reportShapeError(err, "POST /api/shape", { - engine: engineForReport, - profile: profileForReport, - }); + console.error("[/api/shape]", err); return NextResponse.json({ error: message }, { status: 500 }); } } diff --git a/lib/engine.ts b/lib/engine.ts index bd940ec..d6a9473 100644 --- a/lib/engine.ts +++ b/lib/engine.ts @@ -1,7 +1,6 @@ import { buildSystemPrompt } from "./prompt"; import { runLocalShape } from "./local-engine"; import { runOpenAIShapePrompt } from "./model"; -import { reportShapeError } from "./monitoring"; import type { ShapeEngine, ShapeProfile } from "./types"; export async function runShapeEngine({ @@ -22,12 +21,8 @@ export async function runShapeEngine({ try { return JSON.parse(raw); - } catch (err) { - await reportShapeError(err, "runShapeEngine.parseModelJson", { - engine, - profile, - raw_preview: raw.slice(0, 200), - }); + } catch { + console.error("[engine] model returned invalid JSON"); throw new Error("Model returned invalid JSON"); } } diff --git a/lib/monitoring.ts b/lib/monitoring.ts deleted file mode 100644 index b16a67f..0000000 --- a/lib/monitoring.ts +++ /dev/null @@ -1,68 +0,0 @@ -// Production error monitoring for Shape's critical paths. -// -// When SHAPE_MONITORING_DSN is configured, server-side errors in the -// Shape API route and engine are reported to the monitoring backend -// (Sentry-compatible payload). When the DSN is unset, this module -// is a no-op so local development and unauthenticated previews don't -// emit telemetry. -// -// Use reportShapeError(err, context, extra?) at every catch site that -// sits on a request path. Without it, model failures, JSON parse -// errors, and provider outages disappear into a 500 with no alerting. - -const DSN = process.env.SHAPE_MONITORING_DSN || ""; -const RELEASE = process.env.SHAPE_RELEASE || "dev"; -const ENVIRONMENT = process.env.SHAPE_ENVIRONMENT || process.env.NODE_ENV || "unknown"; - -export function isMonitoringEnabled(): boolean { - return DSN !== ""; -} - -export interface ShapeErrorContext { - context: string; - release: string; - environment: string; - message: string; - stack?: string; - timestamp: string; - [key: string]: unknown; -} - -/** - * Send a structured error report to the monitoring backend. - * - * Fire-and-forget. Failures inside the monitor itself MUST NOT crash the - * caller — a request path that depends on its own alerting being healthy - * is its own outage source. - */ -export async function reportShapeError( - error: unknown, - context: string, - additionalData?: Record, -): Promise { - if (!isMonitoringEnabled()) { - return; - } - const payload: ShapeErrorContext = { - context, - release: RELEASE, - environment: ENVIRONMENT, - message: error instanceof Error ? error.message : String(error), - stack: error instanceof Error ? error.stack : undefined, - timestamp: new Date().toISOString(), - ...(additionalData ?? {}), - }; - try { - await fetch(DSN, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(payload), - keepalive: true, - }); - } catch { - // Monitoring egress failures should not break the request path. - // The local console line below survives regardless of DSN state - // so a developer tailing logs still sees the original error. - console.error(`[shape:monitor:dropped] ${context}:`, error); - } -} From e1e7f8858027e572143e390fb876b01226ecaa8f Mon Sep 17 00:00:00 2001 From: Benjamin Fenton <270411513+fentonbenjamin@users.noreply.github.com> Date: Sun, 10 May 2026 21:45:42 -0400 Subject: [PATCH 2/5] trigger Not Magic webhook redelivery (post-headline-polish) From edba9523dc96623c646a53717217309cc42473d7 Mon Sep 17 00:00:00 2001 From: Benjamin Fenton <270411513+fentonbenjamin@users.noreply.github.com> Date: Sun, 10 May 2026 22:12:27 -0400 Subject: [PATCH 3/5] trigger Wild Nose v0 self-seed (post-deploy verification) From aa659fc312c4af8e8af2a1df2c95ec889af48728 Mon Sep 17 00:00:00 2001 From: Benjamin Fenton <270411513+fentonbenjamin@users.noreply.github.com> Date: Mon, 11 May 2026 07:54:33 -0400 Subject: [PATCH 4/5] verify PR #4 input_kind fix post-deploy From af9c6bcbaf5aa5e9da4431535e018052f1fc713d Mon Sep 17 00:00:00 2001 From: Benjamin Fenton <270411513+fentonbenjamin@users.noreply.github.com> Date: Mon, 11 May 2026 08:09:46 -0400 Subject: [PATCH 5/5] verify PR #4 contract scopes restored post-fix