Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
9a080c8
feat(errors): JavaScript source maps: upload API, symbolicated issue …
Makisuo Nov 24, 2026
a7e5c2b
test(browser): stamp the OTLP goldens with the current SDK version
Makisuo Nov 24, 2026
09a910d
fix(sourcemaps): keep debug-id builds apart, safer grouping keys, val…
Makisuo Nov 24, 2026
f9eb94e
fix(errors): a failed has-maps lookup re-keys nothing
Makisuo Nov 24, 2026
8e836c1
fix(sourcemaps): review round: pending maps keep stored keys, path-fi…
Makisuo Nov 24, 2026
6ca3484
Merge remote-tracking branch 'origin/main' into sourcemaps/backend
Makisuo Nov 24, 2026
4a29621
chore(ios): regenerate the OpenAPI spec for function_from_map
Makisuo Nov 24, 2026
2491e90
fix(sourcemaps): refuse index maps, id-less release maps first, fair …
Makisuo Nov 24, 2026
a1db4e1
fix(sourcemaps): linear stack parsing, throw-site grace, safer re-key…
Makisuo Nov 24, 2026
24445ab
perf(sourcemaps): one map lookup per URL per errors tick, keep an ove…
Makisuo Nov 24, 2026
6352e42
fix(sourcemaps): rules changes re-key raw keys, frame rules pick the …
Makisuo Nov 24, 2026
7d89b4a
fix(sourcemaps): header lines with `@` are not frames, stale keys kee…
Makisuo Nov 24, 2026
a01e559
fix(api): show a too-large source map's size in the 413
Makisuo Nov 24, 2026
e00f071
Merge remote-tracking branch 'origin/main' into sourcemaps/backend
Makisuo Nov 24, 2026
c504cf8
chore(db): regenerate the source maps migration after main's newest
Makisuo Nov 24, 2026
e8f1d29
fix(errors): name the source-mapped type + first function rule apart …
Makisuo Nov 24, 2026
6b5fb2d
feat(cli,browser): maple sourcemaps inject/upload and exception debug…
Makisuo Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/alchemy-sourcemaps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@maple-dev/alchemy": minor
---

Automatic source map uploads. `@maple-dev/alchemy/vite` exports `mapleSourceMaps()`, a Vite plugin that turns on hidden source maps, gives each built JS file a debug id and moves the maps out of the deployed output into `.maple/sourcemaps/<outDir>` with a manifest. The new `Maple.SourceMaps` resource uploads them through `POST /v2/source_maps` after the build, again only when the maps changed; deleting it keeps the uploaded maps, which earlier releases still need. `matchBy: "release"` uploads without debug ids, for telemetry that reports none. `MapleApiContract` gains `upload` for raw request bodies.
5 changes: 5 additions & 0 deletions .changeset/browser-exception-debug-ids.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@maple-dev/browser": minor
---

Exception events now carry `maple.exception.debug_ids`: for each script in the error's stack that registered a debug id (through `maple sourcemaps inject`, or Sentry's debug id tooling), its URL and id, so the matching source map is found by id rather than by file path. Absent when no script in the stack has one.
5 changes: 5 additions & 0 deletions .changeset/cli-sourcemaps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@maple/cli": minor
---

New `maple sourcemaps inject <dir>` and `maple sourcemaps upload <dir>`. `inject` gives every built JS file that has a source map a debug id (derived from the file and its map, so re-running changes nothing), registers it on the file's first line so errors thrown while the file loads still carry it, and writes it into the map; `--dry-run` reports without writing. Maps outside the build directory are never touched. `upload` sends each map to the logged-in workspace, once per JS file that uses it, matched by debug id or by `--service`, `--release` (defaults to the build directory's git commit) and the file path, with `--url-prefix` for the path the files are served under. Maps over 10 MiB (the largest Maple can symbolicate with) and index maps (`sections`) are skipped with a warning, and a run that uploads nothing fails.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@ apps/ios/build/
scripts/seed-demo/.last-seed.json
# isolated screenshot stack env, generated by bun run seed:demo:env
.env.screenshots

# Source maps the Vite plugin moves out of a build (`@maple-dev/alchemy/vite`).
.maple/
13 changes: 13 additions & 0 deletions alchemy.run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { createAwsSecurityBaseline } from "@maple/infra/security-baseline"
import { optionalPlain, plainWithDefault, requiredPlain } from "@maple/infra/env"
import * as Portless from "@maple/alchemy-portless"
import { DEV_PROCESS_APPS, selectedDevApps, type DevApp } from "@maple/infra/dev-urls"
import { selfMapleProviders, uploadWebSourceMaps } from "@maple/infra/self-source-maps"
import MapleAiLive, { MapleAi } from "./apps/ai/src/worker.ts"
import Alerting from "./apps/alerting/src/worker.ts"
import OrgEraser from "./apps/org-eraser/src/worker.ts"
Expand All @@ -62,6 +63,8 @@ import { createMapleScraper } from "./apps/scraper/alchemy.run.ts"
import Landing from "./apps/landing/src/worker.ts"
import LocalUi from "./apps/local-ui/src/worker.ts"
import Web from "./apps/web/src/worker.ts"
import { WEB_SERVICE_NAME } from "./apps/web/src/platform/service-identity.ts"
import { WEB_SOURCE_MAPS_DIR } from "./apps/web/source-maps-dir.ts"
import { Array as Arr } from "effect"

// Infisical defines CLOUDFLARE_DEFAULT_ACCOUNT_ID; alchemy reads CLOUDFLARE_ACCOUNT_ID.
Expand Down Expand Up @@ -324,6 +327,8 @@ const providers =
// Previews only; prd and dev deploys carry no NEON_API_KEY.
Layer.provideMerge(!isDevServer && process.env.NEON_API_KEY ? Neon.providers() : Layer.empty),
Layer.provideMerge(Portless.providers()),
// Uploads web's source maps; inert without the prd-only key.
Layer.provideMerge(selfMapleProviders),
)

export default Alchemy.Stack(
Expand Down Expand Up @@ -429,6 +434,14 @@ export default Alchemy.Stack(
// A vite-source Worker: alchemy owns its build and dev server. Binds api as `API`.
const web = yield* Effect.provideService(Web, ApiWorker, api)
yield* serveWorker("web", web)
// Its source maps, moved out of the deployed assets by the Vite plugin (apps/web/vite.config.ts),
// uploaded after the build under the service and release its telemetry reports.
if (!isDevServer)
yield* uploadWebSourceMaps({
dir: path.resolve(import.meta.dirname, WEB_SOURCE_MAPS_DIR),
service: WEB_SERVICE_NAME,
after: web.hash,
})

// StaticSites run their production build even on `alchemy dev`, so dev uses
// `DEV_PROCESS_APPS` instead. Shared across instances: deployed by `us` alone.
Expand Down
2 changes: 1 addition & 1 deletion apps/ai/src/mcp/tool-descriptors.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const MCP_TOOL_DESCRIPTORS: ReadonlyArray<McpToolDescriptor> = [
{"name":"transition_error_issues","title":"Transition Error Issues","description":"Batch form of transition_error_issue, same rules: up to 200 issues to one state, one note on each. Each issue is checked on its own; a refused move or bad id fails only that issue.","inputSchema":{"type":"object","properties":{"issue_ids":{"type":"array","items":{"type":"string"},"description":"Error issue IDs from list_error_issues, at most 200"},"to_state":{"type":"string","enum":["triage","todo","in_progress","in_review","done","cancelled","wontfix"],"description":"Target state for every issue: triage, todo, in_progress, in_review, done, cancelled, wontfix"},"note":{"type":"string","description":"Reasoning or context, stored on every issue's timeline with the move"},"snooze_until":{"type":"string","description":"For a `wontfix` move: time after which new occurrences reopen each issue as `triage`, UTC (YYYY-MM-DD HH:mm:ss or ISO 8601)"}},"required":["issue_ids","to_state"],"additionalProperties":false},"outputSchema":{"type":"object","properties":{"toState":{"type":"string"},"succeeded":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"failed":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"results":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"ok":{"type":"boolean"},"fromState":{"type":"string"},"workflowState":{"type":"string"},"error":{"type":"string"}},"required":["id","ok"],"additionalProperties":true}},"note":{"type":"string"}},"required":["toState","succeeded","failed","results"],"additionalProperties":true},"annotations":{"title":"Transition Error Issues","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false}},
{"name":"set_issue_severity","title":"Set Issue Severity","description":"Set or clear the triage severity of an issue. Severity drives escalation routing. An agent identity writes with `ai` precedence and never overwrites a severity a human set by hand; the result says whether it applied. A human session writes a sticky manual override.","inputSchema":{"type":"object","properties":{"issue_id":{"type":"string","description":"The error issue ID from list_error_issues (a fingerprint from find_errors is not an issue id): its UUID or its REST id (iss_\u2026)"},"severity":{"type":"string","enum":["critical","high","medium","low","none"],"description":"Target severity; `none` clears it"},"note":{"type":"string","description":"Reasoning or context, stored on the severity event"}},"required":["issue_id","severity"],"additionalProperties":false},"outputSchema":{"type":"object","properties":{"id":{"type":"string"},"severity":{"anyOf":[{"type":"string"},{"type":"null"}]},"severitySource":{"anyOf":[{"type":"string"},{"type":"null"}]},"applied":{"type":"boolean"},"workflowState":{"type":"string"},"serviceName":{"type":"string"},"note":{"type":"string"}},"required":["id","severity","severitySource","applied","workflowState","serviceName"],"additionalProperties":true},"annotations":{"title":"Set Issue Severity","readOnlyHint":false,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false}},
{"name":"merge_error_issues","title":"Merge Error Issues","description":"Fold duplicate error issues into one when they are the same bug split across fingerprints. The kept issue (issue_id) takes their occurrences and every future occurrence of their fingerprints; each merged issue is archived pointing at it. Up to 50 at a time. Only merge issues you have confirmed share a root cause; a merge is undone from the dashboard.","inputSchema":{"type":"object","properties":{"issue_id":{"type":"string","description":"The issue to keep, from list_error_issues: its UUID or its REST id (iss_\u2026)"},"merge_issue_ids":{"type":"array","items":{"type":"string"},"description":"Issue IDs to fold into it, at most 50"}},"required":["issue_id","merge_issue_ids"],"additionalProperties":false},"outputSchema":{"type":"object","properties":{"id":{"type":"string"},"mergedIssueIds":{"type":"array","items":{"type":"string"}},"fingerprintHashes":{"type":"array","items":{"type":"string"}},"occurrenceCount":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"workflowState":{"type":"string"},"serviceName":{"type":"string"}},"required":["id","mergedIssueIds","fingerprintHashes","occurrenceCount","workflowState","serviceName"],"additionalProperties":true},"annotations":{"title":"Merge Error Issues","readOnlyHint":false,"destructiveHint":true,"idempotentHint":false,"openWorldHint":false}},
{"name":"explain_error_grouping","title":"Explain Error Grouping","description":"Explain why an error issue holds the fingerprints it does: for each one, how it got there (the issue's own, a merge, a version re-key, or the grouping key) and which rule keyed it, with the message signature and the stack frames read and skipped. Use it when an issue looks like it mixes unrelated bugs.","inputSchema":{"type":"object","properties":{"issue_id":{"type":"string","description":"The error issue ID from list_error_issues (a fingerprint from find_errors is not an issue id): its UUID or its REST id (iss_\u2026)"}},"required":["issue_id"],"additionalProperties":false},"outputSchema":{"type":"object","properties":{"issueId":{"type":"string"},"fingerprints":{"type":"array","items":{"$ref":"#/$defs/ErrorIssueFingerprintGroupingEncoded"}},"truncated":{"type":"boolean"}},"required":["issueId","fingerprints","truncated"],"additionalProperties":true,"$defs":{"@maple/GroupingRule":{"type":"string","enum":["custom","span","org-rule","chunk-load","type-message","type-function","frames"],"title":"Grouping Rule"},"@maple/IsoDateTimeString":{"type":"string"},"ErrorIssueFingerprintGroupingEncoded":{"type":"object","properties":{"fingerprintHash":{"type":"string"},"source":{"type":"string","enum":["primary","merge","rekey","group"]},"rule":{"anyOf":[{"$ref":"#/$defs/@maple~1GroupingRule"},{"type":"null"}]},"orgRule":{"anyOf":[{"type":"string"},{"type":"null"}]},"pinned":{"type":"boolean"},"exceptionType":{"type":"string"},"messageSignature":{"type":"string"},"frames":{"type":"array","items":{"type":"string"}},"skippedFrames":{"type":"array","items":{"type":"string"}},"customKey":{"anyOf":[{"type":"string"},{"type":"null"}]},"sampledAt":{"anyOf":[{"$ref":"#/$defs/@maple~1IsoDateTimeString"},{"type":"null"}]}},"required":["fingerprintHash","source","rule","orgRule","pinned","exceptionType","messageSignature","frames","skippedFrames","customKey","sampledAt"],"additionalProperties":true}}},"annotations":{"title":"Explain Error Grouping","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false}},
{"name":"explain_error_grouping","title":"Explain Error Grouping","description":"Explain why an error issue holds the fingerprints it does: for each one, how it got there (the issue's own, a merge, a version re-key, or the grouping key) and which rule keyed it, with the message signature and the stack frames read and skipped. Use it when an issue looks like it mixes unrelated bugs.","inputSchema":{"type":"object","properties":{"issue_id":{"type":"string","description":"The error issue ID from list_error_issues (a fingerprint from find_errors is not an issue id): its UUID or its REST id (iss_\u2026)"}},"required":["issue_id"],"additionalProperties":false},"outputSchema":{"type":"object","properties":{"issueId":{"type":"string"},"fingerprints":{"type":"array","items":{"$ref":"#/$defs/ErrorIssueFingerprintGroupingEncoded"}},"truncated":{"type":"boolean"}},"required":["issueId","fingerprints","truncated"],"additionalProperties":true,"$defs":{"@maple/GroupingRule":{"type":"string","enum":["custom","span","org-rule","chunk-load","type-message","type-function","frames","source-mapped","source-mapped-function"],"title":"Grouping Rule"},"@maple/IsoDateTimeString":{"type":"string"},"ErrorIssueFingerprintGroupingEncoded":{"type":"object","properties":{"fingerprintHash":{"type":"string"},"source":{"type":"string","enum":["primary","merge","rekey","group"]},"rule":{"anyOf":[{"$ref":"#/$defs/@maple~1GroupingRule"},{"type":"null"}]},"orgRule":{"anyOf":[{"type":"string"},{"type":"null"}]},"pinned":{"type":"boolean"},"exceptionType":{"type":"string"},"messageSignature":{"type":"string"},"frames":{"type":"array","items":{"type":"string"}},"skippedFrames":{"type":"array","items":{"type":"string"}},"customKey":{"anyOf":[{"type":"string"},{"type":"null"}]},"sampledAt":{"anyOf":[{"$ref":"#/$defs/@maple~1IsoDateTimeString"},{"type":"null"}]}},"required":["fingerprintHash","source","rule","orgRule","pinned","exceptionType","messageSignature","frames","skippedFrames","customKey","sampledAt"],"additionalProperties":true}}},"annotations":{"title":"Explain Error Grouping","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false}},
{"name":"list_similar_error_issues","title":"List Similar Error Issues","description":"List open issues that may be the same bug as this one: same service and error type, with a similar message, most similar first. These are suggestions only; check that each shares the root cause before merging it.","inputSchema":{"type":"object","properties":{"issue_id":{"type":"string","description":"The error issue ID from list_error_issues (a fingerprint from find_errors is not an issue id): its UUID or its REST id (iss_\u2026)"}},"required":["issue_id"],"additionalProperties":false},"outputSchema":{"type":"object","properties":{"issueId":{"type":"string"},"issues":{"type":"array","items":{"$ref":"#/$defs/ErrorIssueSimilarIssueEncoded"}}},"required":["issueId","issues"],"additionalProperties":true,"$defs":{"@maple/ErrorIssueId":{"type":"string","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$","format":"uuid","title":"Error Issue ID"},"@maple/WorkflowState":{"type":"string","enum":["triage","regressed","todo","in_progress","in_review","verifying","done","cancelled","wontfix"],"title":"Workflow State"},"@maple/IsoDateTimeString":{"type":"string"},"ErrorIssueSimilarIssueEncoded":{"type":"object","properties":{"id":{"$ref":"#/$defs/@maple~1ErrorIssueId"},"serviceName":{"type":"string"},"exceptionType":{"type":"string"},"exceptionMessage":{"type":"string"},"errorLabel":{"type":"string"},"workflowState":{"$ref":"#/$defs/@maple~1WorkflowState"},"occurrenceCount":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"lastSeenAt":{"$ref":"#/$defs/@maple~1IsoDateTimeString"},"similarity":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]}},"required":["id","serviceName","exceptionType","exceptionMessage","errorLabel","workflowState","occurrenceCount","lastSeenAt","similarity"],"additionalProperties":true}}},"annotations":{"title":"List Similar Error Issues","readOnlyHint":true,"destructiveHint":false,"idempotentHint":true,"openWorldHint":false}},
{"name":"detach_error_fingerprint","title":"Detach Error Fingerprint","description":"Split one fingerprint off an error issue that the grouping key put there by mistake. Only fingerprints joined by the grouping key detach (source `group` in explain_error_grouping); one folded in by a merge is unmerged from the dashboard instead, and the issue's own fingerprint stays. The detached fingerprint is pinned, so its next occurrence opens an issue of its own.","inputSchema":{"type":"object","properties":{"issue_id":{"type":"string","description":"The issue holding the fingerprint, from list_error_issues: its UUID or its REST id (iss_\u2026)"},"fingerprint":{"type":"string","description":"The fingerprint to split off, from explain_error_grouping"}},"required":["issue_id","fingerprint"],"additionalProperties":false},"outputSchema":{"type":"object","properties":{"id":{"type":"string"},"detachedFingerprintHash":{"type":"string"},"fingerprintHashes":{"type":"array","items":{"type":"string"}},"occurrenceCount":{"anyOf":[{"type":"number"},{"type":"string","enum":["Infinity","-Infinity","NaN"]}]},"workflowState":{"type":"string"},"serviceName":{"type":"string"}},"required":["id","detachedFingerprintHash","fingerprintHashes","occurrenceCount","workflowState","serviceName"],"additionalProperties":true},"annotations":{"title":"Detach Error Fingerprint","readOnlyHint":false,"destructiveHint":false,"idempotentHint":false,"openWorldHint":false}},
{"name":"claim_error_issue","title":"Claim Error Issue","description":"Take a lease on an error issue so other agents do not duplicate the work. Issues in `triage`, `regressed` or `todo` move to `in_progress` on claim. The lease renews whenever you act on the issue (transition it, comment, set its severity, propose a fix) and ends when the issue reaches `done` or `cancelled` or you call release_error_issue. Claiming an issue another agent holds fails.","inputSchema":{"type":"object","properties":{"issue_id":{"type":"string","description":"The error issue ID from list_error_issues (a fingerprint from find_errors is not an issue id): its UUID or its REST id (iss_\u2026)"},"lease_duration_seconds":{"type":"number","description":"How long the lease lasts without activity, 60 to 7200 seconds (default 1800)"}},"required":["issue_id"],"additionalProperties":false},"outputSchema":{"type":"object","properties":{"id":{"type":"string"},"workflowState":{"type":"string"},"leaseHolderActorId":{"type":"string"},"leaseExpiresAt":{"type":"string"},"claimedAt":{"type":"string"},"holder":{"type":"string"}},"required":["id","workflowState","leaseHolderActorId","leaseExpiresAt","claimedAt","holder"],"additionalProperties":true},"annotations":{"title":"Claim Error Issue","readOnlyHint":false,"destructiveHint":false,"idempotentHint":false,"openWorldHint":false}},
Expand Down
4 changes: 4 additions & 0 deletions apps/ai/src/mcp/tools/error-grouping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export const describeRule = (fingerprint: ErrorIssueFingerprintGrouping): string
return `type-function: same type, first named function ${Option.getOrElse(Arr.head(fingerprint.frames), () => "(unknown)")}`
case "frames":
return "frames: generic error type, keyed on these frames and the message"
case "source-mapped":
return "source-mapped: keyed on the original files and functions its source maps name, so a new release keeps the key"
case "source-mapped-function":
return `source-mapped-function: same type, first function its source maps name ${Option.getOrElse(Arr.head(fingerprint.frames), () => "(unknown)")}, so a new release keeps the key`
}
}

Expand Down
Loading
Loading