You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a5cb2d1
Browse filesBrowse the repository at this point in the historyBrowse files
chore: Replace AGENTS.md rules with lints and tests
Add the `sdk/valid-span-origin` lint rule. It checks span origins
against the trace origin format: string literals written to an origin
attribute, and string literals assigned to a constant whose name ends in
`ORIGIN`. Add `scripts/agent-rules.test.mjs`. It checks that no new
dev-packages test sets `traceLifecycle`, and that every `exports`
subpath with a worker entry puts `workerd` before `browser`.
Cloudflare bundlers set `workerd`, `worker` and `browser`, and the first
matching key wins. The test leaves the place of `worker` to each package:
webpack `target: 'webworker'` builds for browser Web Workers also set
`worker` and `browser`, so `@sentry/react-router` keeps `worker` last on
purpose (#24866).
Remove the AGENTS.md text these checks now enforce, text that restates
code, and the Coding Standards and Testing lines that showed no effect
in an ablation eval. `REVIEW-RULES.md` no longer points the review at
the removed Testing section, and now holds the `stringifyForCodeInjection`
rule itself, so reviews keep checking it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Reach for existing utils before writing a new one. Most shared helpers live in `@sentry/core` (`packages/core/src/utils/`), with browser helpers in `packages/browser-utils/`. Search first (LSP `workspaceSymbol` or grep) for common needs (type guards in `is.ts`, object/array helpers, `normalize`, `dsn`, `merge`, string/url helpers). Reuse or extend the existing util rather than adding a near-duplicate; only introduce a new util when nothing fits.
106
-
- When `JSON.stringify` output goes into generated code (bundler plugins, loaders, virtual modules, `define`), use `stringifyForCodeInjection` from `@sentry/core` instead. It escapes `<`, `>`, U+2028 and U+2029, so the code stays safe when inlined in a `<script>` element.
107
-
- Only use libraries already in the codebase
108
-
- Never expose secrets or keys
109
-
- When modifying files, cover all occurrences (including `src/` and `test/`)
110
87
-**Write few comments; default to none.** Comments explain **why**, never **what** — never add a comment that restates what the code does or narrates the change being made. Only add one when the reasoning isn't clear from the code itself, or to flag a tradeoff or something that would otherwise look surprising to a reader. When in doubt, leave it out.
111
-
- Do not use `expect(someSpy.mock.calls[0]?.[0])` or similar constructs to check what a spy was called with.
112
-
Instead use `expect(someSpy).toHaveBeenCalledWith(...)` or derivatives for a more readable and less brittle test assertion.
113
-
114
-
## Testing
115
-
116
-
-**Do not set `traceLifecycle` in new tests** (node-integration-tests, e2e). Leave it unset so the test exercises the default — span streaming (`stream`). Many existing suites pin `traceLifecycle: 'static'` (or toggle it via `process.env.STREAMED`); do not copy that into new tests.
117
-
- Under span streaming there is no `transaction` envelope with nested `spans`. Assert the transaction via the streamed span container: `.expect({ span: (container) => { ... } })`, finding the root with `container.items.find(i => i.is_segment)` and child spans with `container.items.filter(...)`. Add `.unordered()` so the span container and error events can arrive in any order and unrelated envelopes (client reports, etc.) are ignored. Errors are still separate `event` envelopes (`.expect({ event })`). A streamed span's error status is `'error'`, not the classic transaction's `'internal_error'`.
118
88
119
89
## Lazy Loading Is a Last Resort
120
90
@@ -130,8 +100,3 @@ Before even proposing lazy loading:
Copy file name to clipboardExpand all lines: REVIEW-RULES.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,7 @@ Change a rule when the review gets it wrong two times for the same reason. Add a
6
6
7
7
## Rules in `AGENTS.md`
8
8
9
-
These sections of the root `AGENTS.md` are checks: "Architecture", "Coding Standards", "Testing", and "Lazy Loading Is a Last Resort". The other sections are for authors only.
10
-
11
-
- For the `stringifyForCodeInjection` rule, log messages and boolean `define` values are fine.
9
+
These sections of the root `AGENTS.md` are checks: "Architecture", "Coding Standards", and "Lazy Loading Is a Last Resort". The other sections are for authors only.
12
10
13
11
## SDK source in `packages/`
14
12
@@ -39,6 +37,8 @@ These sections of the root `AGENTS.md` are checks: "Architecture", "Coding Stand
39
37
- Flag a new package, or a new `exports` entry under `packages/`, that can load on a server runtime when its package has no entry in `CASES` or `BUILD_TIME_CASES` in `dev-packages/bundler-tests/tests/runtime-entries.test.ts`. Browser-only packages are fine.
40
38
- Flag a new option on an incoming HTTP request integration (Node `httpIntegration`, Deno `denoHttpIntegration` and `denoServeIntegration`, Bun `bunHttpServerIntegration` and `bunServerIntegration`, Cloudflare `httpServerIntegration`) that applies to more than one runtime and is not in `ServerRequestOptions` (`packages/core/src/integrations/http/server-request-options.ts`).
41
39
40
+
- Flag `JSON.stringify` output that goes into generated code (bundler plugins, loaders, virtual modules, `define` values). Use `stringifyForCodeInjection` from `@sentry/core`: it escapes `<`, `>`, U+2028 and U+2029, so the code stays safe inside a `<script>` element. Log messages and boolean `define` values are fine.
41
+
42
42
**Breaking changes**
43
43
44
44
- A removed public export or a changed default needs an entry in `MIGRATION.md`. A deprecated export needs `@deprecated` in its JSDoc. `CHANGELOG.md` is written at release time, so do not ask for an entry.
description: 'Enforce the trace origin format for literal `sentry.origin` values.',
35
+
},
36
+
schema: [],
37
+
messages: {
38
+
badFormat:
39
+
"Span origin '{{origin}}' must be '<type>.<category>.<integration_name>.<integration_part>': type 'auto' or 'manual', at most four parts, only [a-zA-Z0-9_] in a part. See https://develop.sentry.dev/sdk/telemetry/traces/trace-origin/",
40
+
toolingPart:
41
+
"Span origin '{{origin}}' names tooling ('{{part}}'). The origin identifies the integration, not how it is built.",
0 commit comments