Skip to content

Commit bfb9434

Browse files
authored
Merge branch 'main' into idempotency-key-length
2 parents bc0d7f5 + 8ba067d commit bfb9434

148 files changed

Lines changed: 11340 additions & 1808 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/plugin-auth-path.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/plugins": patch
3+
---
4+
5+
The public interfaces for a plugin system. Initially consolidated authentication and authorization interfaces.

.claude/REVIEW.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# REVIEW.md — Trigger.dev OSS
2+
3+
Repo-specific signal for anyone (human or agent) reviewing a PR in this codebase. Calibrates what counts as critical, what to always check, and what to skip.
4+
5+
## What makes a 🔴 Important finding here
6+
7+
Reserve 🔴 for things that would page someone or block a rollback. In this codebase, that means:
8+
9+
- **Rolling-deploy breakage.** Old and new versions of the webapp/supervisor run side-by-side during deploys. A change is broken if:
10+
- A Lua script's behavior changes for a given key set without versioning (rename the script with a behavior-descriptive suffix like `Tracked` rather than `V2` — both versions must coexist safely).
11+
- A Redis data shape used by both versions changes in place. New shapes need a new key namespace.
12+
- A migration is not backward-compatible with the prior image.
13+
- **Schema / migration safety.** Prisma migrations must be backward-compatible with the prior deploy. Adding NOT NULL without a default, dropping a column an old image still reads, renaming a column — all 🔴.
14+
- **Queue / concurrency correctness.** RunQueue, MarQS (V1, legacy), redis-worker — any change to enqueue / dequeue / locking semantics. Re-derive the invariant on paper before flagging or accepting.
15+
- **Missing index on a hot table.** New Prisma queries against `TaskRun`, `TaskRunExecutionSnapshot`, `JobRun`, `Project`, etc. must use an existing index. Check `internal-packages/database/prisma/schema.prisma` for the relevant `@@index` lines — don't guess and don't propose `EXPLAIN`.
16+
- **Recovery-path queries.** Any `TaskRun.findFirst` / `findMany` added to a schedule, run-recovery, or restart loop. Recovery fan-outs (Redis crash, restart storms) turn "rare indexed query" into a DB incident. 🔴 even if indexed.
17+
- **Aggregations on hot tables.** No `COUNT` / `GROUP BY` on `TaskRun` or other multi-million-row tables. Use Redis or ClickHouse for counts.
18+
- **Prod Redis blast-radius.** New code paths that `SCAN` with broad patterns (`*foo*`) on prod-shaped Redis, or `EVAL` Lua with `SCAN` loops inside. Both are 🔴.
19+
- **`@trigger.dev/core` direct import** from anywhere outside the SDK package. Always import from `@trigger.dev/sdk`. Core direct imports are 🔴 — they break the public API contract.
20+
- **Heavy execute-deps imported into request-handler bundles.** Specifically `chat.handover` and similar split-bundle entry points must not transitively import the agent task's execute path. Watch for new imports added at module top-level of route files.
21+
- **V1 engine code modified in a "V2 only" PR.** The `apps/webapp/app/v3/` directory contains both. If the PR description says V2-only but it touches `triggerTaskV1`, `cancelTaskRunV1`, `MarQS`, etc. — 🔴.
22+
23+
## Always check
24+
25+
- **Tests use testcontainers, not mocks.** Vitest with `redisTest` / `postgresTest` / `containerTest` from `@internal/testcontainers`. Any new `vi.mock(...)` on Redis, Postgres, BullMQ, or other infra is wrong here — 🔴 if added in production-path tests, 🟡 if isolated unit test.
26+
- **Public-package changes have a changeset.** `pnpm run changeset:add` produces `.changeset/*.md`. Required for any edit under `packages/*`. Missing → 🟡; missing on a breaking change → 🔴.
27+
- **Server-only changes have `.server-changes/*.md`.** Required for `apps/webapp/`, `apps/supervisor/` edits with no public-package change. Body should be 1-2 sentences (it has to fit as one bullet in a future changelog). Missing → 🟡.
28+
- **Lua script naming.** Coexisting scripts use behavior-descriptive suffixes (`Tracked`), never `V2`. Old name must keep working until the next deploy clears it.
29+
- **RunQueue payload shape.** V2 run-queue payload's `projectId` is consumed by `workerQueueResolver` for override matching. If a PR drops it from the payload, 🔴.
30+
- **`safeSend` scope.** Defensive IPC wrappers belong on loop / interval / handler contexts, not one-shot terminal sends. If the PR adds `safeSend` to a single terminal call for consistency, 🟡 with a "remove this" suggestion.
31+
- **Zod version.** Pinned to `3.25.76` monorepo-wide. New package adding zod with a different version or range — 🔴.
32+
33+
## Skip (do NOT flag)
34+
35+
- Anything Prettier / ESLint catches. CI runs both.
36+
- TypeScript style preferences (`type` vs `interface`) — already covered by repo standards.
37+
- Test coverage exhortations as a generic suggestion. Only flag missing tests when a specific code path is genuinely untested and the path has prior incidents.
38+
- `agentcrumbs` markers (`// @crumbs`, `// #region @crumbs`) and `agentcrumbs` imports — these are temporary debug instrumentation stripped before merge.
39+
- `// removed comments for removed code`, renamed `_unused` vars, re-exported types as "backwards compatibility shims" — also covered by repo standards.
40+
- Suggestions to "add error handling" without naming a specific scenario that breaks.
41+
- Documentation prose nitpicks in `docs/*` MDX files unless factually wrong.
42+
43+
## Things V1/legacy that should NOT block a PR
44+
45+
The `apps/webapp/app/v3/` directory name is misleading — most code there is V2. Only specific files are V1-only legacy: `MarQS` queue, `triggerTaskV1`, `cancelTaskRunV1`, and a handful of others (see `apps/webapp/CLAUDE.md` for the exact list). Don't flag "you should refactor this to use V2" on those — they're frozen.
46+
47+
## Confidence calibration for this repo
48+
49+
The most common false-positive pattern: speculating about race conditions in code paths the agent doesn't have runtime visibility into. If the only evidence is "this *could* race", drop it. If you can point to a specific interleaving with file:line for each step, surface it.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: 🔎 REVIEW.md Drift Audit
2+
3+
on:
4+
pull_request:
5+
types: [opened, ready_for_review, synchronize]
6+
paths-ignore:
7+
- "docs/**"
8+
- ".changeset/**"
9+
- ".server-changes/**"
10+
- "references/**"
11+
12+
concurrency:
13+
group: review-md-drift-${{ github.event.pull_request.number }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
audit:
18+
if: >-
19+
github.event.pull_request.draft == false &&
20+
github.event.pull_request.head.repo.full_name == github.repository
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
pull-requests: write
25+
id-token: write
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29+
with:
30+
fetch-depth: 0
31+
persist-credentials: false
32+
33+
- name: Run Claude Code
34+
id: claude
35+
uses: anthropics/claude-code-action@fefa07e9c665b7320f08c3b525980457f22f58aa # v1.0.111
36+
with:
37+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
38+
use_sticky_comment: true
39+
allowed_bots: "devin-ai-integration[bot]"
40+
41+
claude_args: |
42+
--max-turns 30
43+
--allowedTools "Read,Glob,Grep,Bash(git diff:*)"
44+
45+
prompt: |
46+
You are auditing this PR for drift against `.claude/REVIEW.md`.
47+
48+
## Context
49+
50+
`.claude/REVIEW.md` is the repo's source of truth for what AI / agent code reviewers should treat as critical findings (rolling-deploy safety, hot-table indexes, recovery-path queries, testcontainers usage, Lua versioning, etc.). It is consumed by review agents to calibrate severity. If REVIEW.md goes stale, every future agent review degrades.
51+
52+
## Strategy — read this first
53+
54+
You have a hard turn budget. Spend it on signal, not coverage. The audit is allowed to miss things; it is NOT allowed to time out.
55+
56+
1. Read `.claude/REVIEW.md` once, in full.
57+
2. Run `git diff origin/main...HEAD --name-only` to get the list of changed files. Do NOT read the diff content yet.
58+
3. Scan the file-list for relevance to REVIEW.md scope. Relevance signals: changes to Prisma schema, Redis / queue / Lua code, hot tables, recovery / restart loops, new packages, deletions of paths REVIEW.md cites. Skim everything else.
59+
4. Open at most **5 files** total — only the ones most likely to surface a real signal. If nothing in the file-list looks relevant to any REVIEW.md rule, do NOT read any files; go straight to the verdict.
60+
5. Form a verdict and stop. Do not exhaust the turn budget exploring.
61+
62+
Large PRs (>50 files changed) are a strong signal to be MORE selective, not more thorough. Pick 3-5 files at most.
63+
64+
## What to look for
65+
66+
- **Stale references** — does any REVIEW.md rule cite a file, directory, function, table, Prisma model, or package name that has been removed or renamed in this PR (or is already gone from `main`)?
67+
- **Contradictions** — does code in this PR clearly violate a current REVIEW.md rule? (Don't re-review the PR. Only flag if REVIEW.md and the PR plainly disagree.)
68+
- **Missing rules** — does this PR introduce a new pattern future reviewers should know about? Examples: a new hot table, a new Lua-script versioning convention, a new safety wrapper, a new "must always check" invariant.
69+
- **Obsolete rules** — has the repo moved past a constraint REVIEW.md still asserts? (e.g. a deprecated path is gone, a pattern is now linted, V1 code is deleted.)
70+
71+
## Response format
72+
73+
If nothing needs changing:
74+
75+
✅ REVIEW.md looks current for this PR.
76+
77+
Otherwise:
78+
79+
📝 **REVIEW.md updates suggested:**
80+
81+
- **[stale]** `<rule excerpt>` — <what's stale and why>
82+
- **[contradiction]** `<rule excerpt>` — <what in this PR disagrees>
83+
- **[missing]** under `## <section>` — <one-sentence draft rule>
84+
- **[obsolete]** `<rule excerpt>` — <why this rule no longer applies>
85+
86+
## Rules
87+
88+
- Maximum 3 suggestions per audit. Pick the highest-signal ones.
89+
- Only flag things that would actually mislead a future reviewer. Style and wording do not count.
90+
- Do NOT review the PR itself. Do NOT propose rules outside REVIEW.md's existing sections.
91+
- Do NOT propose rules for one-off PR specifics that don't generalize to future PRs.
92+
- If REVIEW.md does not exist in the repo, respond with `(skip)` and stop.
93+
- When in doubt between "one more file read" and "finish now" — finish now.
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: "🛡️ E2E Tests: Webapp Auth (full)"
2+
3+
# Comprehensive RBAC auth test suite — see TRI-8731. Runs separately from
4+
# the smoke e2e-webapp.yml because it covers every route family with a
5+
# pass/fail matrix and would otherwise dominate per-PR CI time.
6+
#
7+
# Triggered:
8+
# - Manually via workflow_dispatch.
9+
# - Nightly via schedule.
10+
# - On pull requests touching auth-relevant files only (paths filter).
11+
12+
permissions:
13+
contents: read
14+
15+
on:
16+
workflow_dispatch:
17+
schedule:
18+
- cron: "0 4 * * *" # 04:00 UTC daily
19+
pull_request:
20+
paths:
21+
- "apps/webapp/app/services/routeBuilders/**"
22+
- "apps/webapp/app/services/rbac.server.ts"
23+
- "apps/webapp/app/services/apiAuth.server.ts"
24+
- "apps/webapp/app/services/personalAccessToken.server.ts"
25+
- "apps/webapp/app/services/sessionStorage.server.ts"
26+
- "apps/webapp/app/routes/api.v*.**"
27+
- "apps/webapp/app/routes/realtime.v*.**"
28+
- "apps/webapp/test/**/*.e2e.full.test.ts"
29+
- "apps/webapp/test/setup/global-e2e-full-setup.ts"
30+
- "apps/webapp/test/helpers/sharedTestServer.ts"
31+
- "apps/webapp/test/helpers/seedTestSession.ts"
32+
- "apps/webapp/vitest.e2e.full.config.ts"
33+
- "internal-packages/rbac/**"
34+
- "packages/plugins/**"
35+
- ".github/workflows/e2e-webapp-auth-full.yml"
36+
37+
jobs:
38+
e2eAuthFull:
39+
name: "🛡️ E2E Auth Tests (full)"
40+
runs-on: ubuntu-latest
41+
timeout-minutes: 30
42+
env:
43+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
44+
steps:
45+
- name: 🔧 Disable IPv6
46+
run: |
47+
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
48+
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
49+
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
50+
51+
- name: 🔧 Configure docker address pool
52+
run: |
53+
CONFIG='{
54+
"default-address-pools" : [
55+
{
56+
"base" : "172.17.0.0/12",
57+
"size" : 20
58+
},
59+
{
60+
"base" : "192.168.0.0/16",
61+
"size" : 24
62+
}
63+
]
64+
}'
65+
mkdir -p /etc/docker
66+
echo "$CONFIG" | sudo tee /etc/docker/daemon.json
67+
68+
- name: 🔧 Restart docker daemon
69+
run: sudo systemctl restart docker
70+
71+
- name: ⬇️ Checkout repo
72+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
73+
with:
74+
fetch-depth: 0
75+
# Don't leave the GITHUB_TOKEN in .git/config — this job
76+
# doesn't need to push and the persisted creds would be
77+
# readable from any subsequent step (zizmor/artipacked).
78+
persist-credentials: false
79+
80+
- name: ⎔ Setup pnpm
81+
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
82+
with:
83+
version: 10.33.2
84+
85+
- name: ⎔ Setup node
86+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
87+
with:
88+
node-version: 20.20.0
89+
cache: "pnpm"
90+
91+
- name: 🐳 Login to DockerHub
92+
if: ${{ env.DOCKERHUB_USERNAME }}
93+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
94+
with:
95+
username: ${{ secrets.DOCKERHUB_USERNAME }}
96+
password: ${{ secrets.DOCKERHUB_TOKEN }}
97+
- name: 🐳 Skipping DockerHub login (no secrets available)
98+
if: ${{ !env.DOCKERHUB_USERNAME }}
99+
run: echo "DockerHub login skipped because secrets are not available."
100+
101+
- name: 🐳 Pre-pull testcontainer images
102+
if: ${{ env.DOCKERHUB_USERNAME }}
103+
run: |
104+
docker pull postgres:14
105+
docker pull redis:7.2
106+
docker pull testcontainers/ryuk:0.11.0
107+
108+
- name: 📥 Download deps
109+
run: pnpm install --frozen-lockfile
110+
111+
- name: 📀 Generate Prisma Client
112+
run: pnpm run generate
113+
114+
- name: 🏗️ Build Webapp
115+
run: pnpm run build --filter webapp
116+
117+
- name: 🛡️ Run Webapp Full Auth E2E Tests
118+
run: cd apps/webapp && pnpm exec vitest run --config vitest.e2e.full.config.ts --reporter=default
119+
env:
120+
WEBAPP_TEST_VERBOSE: "1"

0 commit comments

Comments
 (0)