-
Notifications
You must be signed in to change notification settings - Fork 0
stage1: consolidate items 2-4 and fix webhook notification schema gate #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
InfiniteRandomVariable
merged 17 commits into
main
from
stage-1/item-1-fix-pnpm-action-setup
Mar 4, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f8a728a
stage1(item-1): resolve CI pnpm setup version conflict
InfiniteRandomVariable 08379c9
stage1(item-1): fix CI workflow root path assumptions
InfiniteRandomVariable c8f7de5
stage1(item-1): disable broken setup-node pnpm cache path
InfiniteRandomVariable 4eaffe6
stage1(item-1): add execution continuity policy for agents
InfiniteRandomVariable 7120809
stage1(item-2): add webhook observability and error sink integration
InfiniteRandomVariable e9ccd8b
stage1(item-3): add incident runbooks and rehearsal evidence
InfiniteRandomVariable 6238633
stage1(item-3): tighten runbook walkthrough evidence and test require…
InfiniteRandomVariable 6c43d6e
stage1(item-4): add deploy checklist and dry-run evidence
InfiniteRandomVariable e2292a3
stage1(item-4): add deploy checklist verification command and evidence
InfiniteRandomVariable 337269d
stage1(item-4): harden deploy checklist health verification
InfiniteRandomVariable 83a49a4
stage1(item-4): automate deploy rollback rehearsal and record evidence
InfiniteRandomVariable f420e77
stage1(item-4): guard rollback rehearsal artifacts from accidental reuse
InfiniteRandomVariable 5237d8e
stage1(item-4): record deploy checklist validation evidence
InfiniteRandomVariable efd2914
stage1(item-2): accept webhook notification event type in schema
InfiniteRandomVariable ed6e1c1
stage1(item-4): update dry-run evidence with resolved convex schema f…
InfiniteRandomVariable 6b15caf
stage1(item-2): add live stripe observability evidence artifacts
InfiniteRandomVariable 193cf42
stage1(item-4): finalize stage 1 signoff and exit gate state
InfiniteRandomVariable File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| const ERROR_TRACKING_TIMEOUT_MS = 1500; | ||
|
|
||
| type ErrorTrackingArgs = { | ||
| source: string; | ||
| category: string; | ||
| message: string; | ||
| metadata?: Record<string, unknown>; | ||
| }; | ||
|
|
||
| function getWebhookUrl() { | ||
| const url = process.env.ERROR_TRACKING_WEBHOOK_URL; | ||
| if (!url) return undefined; | ||
| return url.trim() || undefined; | ||
| } | ||
|
|
||
| export async function reportErrorTrackingEvent(args: ErrorTrackingArgs) { | ||
| const webhookUrl = getWebhookUrl(); | ||
| if (!webhookUrl) return; | ||
|
|
||
| const payload = { | ||
| source: args.source, | ||
| category: args.category, | ||
| message: args.message.slice(0, 1000), | ||
| metadata: args.metadata ?? {}, | ||
| capturedAt: new Date().toISOString(), | ||
| environment: process.env.NODE_ENV ?? "unknown" | ||
| }; | ||
|
|
||
| const controller = new AbortController(); | ||
| const timeout = setTimeout(() => controller.abort(), ERROR_TRACKING_TIMEOUT_MS); | ||
|
|
||
| try { | ||
| const token = process.env.ERROR_TRACKING_WEBHOOK_TOKEN; | ||
|
|
||
| await fetch(webhookUrl, { | ||
| method: "POST", | ||
| headers: { | ||
| "content-type": "application/json", | ||
| ...(token ? { authorization: `Bearer ${token}` } : {}) | ||
| }, | ||
| body: JSON.stringify(payload), | ||
| signal: controller.signal | ||
| }); | ||
| } catch (error) { | ||
| const err = error instanceof Error ? error.message : `${error}`; | ||
| console.error(`[error-tracking] failed to report event: ${err}`); | ||
| } finally { | ||
| clearTimeout(timeout); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| export type WebhookProvider = "instagram" | "tiktok" | "stripe"; | ||
|
|
||
| export interface WebhookObservabilityContext { | ||
| provider: WebhookProvider; | ||
| route: string; | ||
| method: "GET" | "POST"; | ||
| startedAtMs: number; | ||
| } | ||
|
|
||
| const ALERT_ROUTING = { | ||
| primary: "app-on-call", | ||
| secondary: "infra-platform-owner", | ||
| runbook: "docs/ops/incident-triage-escalation-flow.md" | ||
| } as const; | ||
|
|
||
| function elapsedMs(startedAtMs: number) { | ||
| return Math.max(0, Date.now() - startedAtMs); | ||
| } | ||
|
|
||
| function emit(level: "info" | "warn", payload: Record<string, unknown>) { | ||
| const writer = level === "warn" ? console.warn : console.info; | ||
| writer( | ||
| JSON.stringify({ | ||
| timestamp: new Date().toISOString(), | ||
| ...payload | ||
| }) | ||
| ); | ||
| } | ||
|
|
||
| function toAlertSeverity(statusCode: number) { | ||
| if (statusCode >= 500) { | ||
| return "sev2"; | ||
| } | ||
| return "sev3"; | ||
| } | ||
|
|
||
| export function createWebhookObservabilityContext(args: { | ||
| provider: WebhookProvider; | ||
| route: string; | ||
| method: "GET" | "POST"; | ||
| }): WebhookObservabilityContext { | ||
| return { | ||
| provider: args.provider, | ||
| route: args.route, | ||
| method: args.method, | ||
| startedAtMs: Date.now() | ||
| }; | ||
| } | ||
|
|
||
| export function logWebhookCompleted( | ||
| context: WebhookObservabilityContext, | ||
| details: { | ||
| statusCode?: number; | ||
| accountId?: string; | ||
| eventType?: string; | ||
| workflowStarted?: boolean; | ||
| } = {} | ||
| ) { | ||
| emit("info", { | ||
| event: "webhook_observability.request_completed", | ||
| outcome: "success", | ||
| provider: context.provider, | ||
| route: context.route, | ||
| method: context.method, | ||
| statusCode: details.statusCode ?? 200, | ||
| durationMs: elapsedMs(context.startedAtMs), | ||
| accountId: details.accountId, | ||
| eventType: details.eventType, | ||
| workflowStarted: details.workflowStarted | ||
| }); | ||
| } | ||
|
|
||
| export function logWebhookIgnored( | ||
| context: WebhookObservabilityContext, | ||
| details: { | ||
| statusCode?: number; | ||
| eventType?: string; | ||
| } = {} | ||
| ) { | ||
| emit("info", { | ||
| event: "webhook_observability.request_completed", | ||
| outcome: "ignored", | ||
| provider: context.provider, | ||
| route: context.route, | ||
| method: context.method, | ||
| statusCode: details.statusCode ?? 200, | ||
| durationMs: elapsedMs(context.startedAtMs), | ||
| eventType: details.eventType | ||
| }); | ||
| } | ||
|
|
||
| export function logWebhookFailed( | ||
| context: WebhookObservabilityContext, | ||
| details: { | ||
| statusCode: number; | ||
| errorCode: string; | ||
| errorMessage: string; | ||
| accountId?: string; | ||
| eventType?: string; | ||
| } | ||
| ) { | ||
| emit("warn", { | ||
| event: "webhook_observability.request_completed", | ||
| outcome: "failure", | ||
| provider: context.provider, | ||
| route: context.route, | ||
| method: context.method, | ||
| statusCode: details.statusCode, | ||
| durationMs: elapsedMs(context.startedAtMs), | ||
| errorCode: details.errorCode, | ||
| errorMessage: details.errorMessage, | ||
| accountId: details.accountId, | ||
| eventType: details.eventType, | ||
| alertSeverity: toAlertSeverity(details.statusCode), | ||
| alertRoutePrimary: ALERT_ROUTING.primary, | ||
| alertRouteSecondary: ALERT_ROUTING.secondary, | ||
| alertRunbook: ALERT_ROUTING.runbook | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.