Commit Graph
45 Commits
Author SHA1 Message Date
Thomas DurieuxandClaude Opus 5.5 24534823a3 perf(db): fix the slowest MongoDB queries from the last 24 hours
MongoDB's slow-query log (24 h, >100 ms) showed four shapes:

- Admin repository search: a case-insensitive substring regex over four
  fields scanned all ~300k repositories, three times per page (up to 5.2 s
  each). Searches that are a repository ID or owner/name now match
  through the indexes first and only fall back to the regex otherwise.
- Admin errors page owner lookup: repoId $in without the repoId index's
  collation was a full collection scan. It now uses the collation.
- Status breakdown and home stats aggregates (~0.4 s over every
  repository, ~100 runs a day from admin polling): cached for a minute,
  and the admin overview uses the existing hourly home-stats cache.
- Folder counts for large repositories (0.7-1.5 s, 400-550k index keys)
  are cached per tree generation, which never changes; legacy trees are
  keyed by commit for 5 minutes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 13:36:17 +00:00
Thomas DurieuxandClaude Opus 5.5 fc14b2c3ae fix(preview): anonymize form previews on a worker, trace slow ones to their project
A user's backtracking term made each anonymize-form preview block the API's
event loop for ~1.2 s and fail with a 500. One per keystroke, 45 of them
froze every request for about a minute (12:59 UTC, 2026-11-30).

- Previews run on their own worker pool (1 worker by default). A preview
  that runs past its deadline (3 s) terminates its worker and answers
  422 anonymization_timeout; the form explains the term is too slow.
- One preview per user: a newer edit, or the client leaving, stops the
  older preview (409 preview_superseded, logged at info).
- Slow (>=500 ms) or failed previews log an anonymization_preview record
  with the project's repoId, input bytes and term count.
- Heartbeats carry the interval's worst event-loop delay (loopMaxMs,
  loopP99Ms); a delay of 1 s or more logs event_loop_blocked at warn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 13:17:35 +00:00
Thomas DurieuxandClaude Opus 5.5 3f8812c99e fix(logging): give raw GitHub failures an error code, log missing branches as warnings
Overnight, GitHub refusals reached the logs as bare HTTPError/UnknownError
with no code: a ZIP whose archive request was refused became a cut
connection and a 502 zip_not_available, a 401 while checking a file
became an uncoded 401, and an Octokit 403 on /options answered
internal_error.

- codeUpstreamError maps got/Octokit replies to repo_not_accessible,
  github_rate_limit_exceeded, github_unavailable or upstream_error;
  handleError applies it, the streamer file route uses the file-level
  mapping, and programming errors pass through unchanged.
- A ZIP that fails before any byte answers with the code, so the API
  relays it; 4xx archive refusals log at warn.
- branch_not_found (owner deleted the branch) logs at warn.
- Octokit's HttpError is an allowlisted error type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 07:52:23 +00:00
Thomas Durieux cc5e06022f Merge remote-tracking branch 'origin/feat/external-request-logs' into HEAD
# Conflicts:
#	deploy/logging/sanitize.vrl
#	public/asset-manifest.json
#	public/script/vendor.min.js
#	src/core/log-record.ts
2026-11-29 13:11:41 +00:00
Thomas DurieuxandClaude Opus 5.5 d8a777cd35 fix(logging): keep reviewers unlinkable, look admin users up by explicit id
- Requests carry userId on warn and error records only. The app calls
  /api/user on every page load, so a userId on routine info records sat
  next to the repoId a signed-in reviewer opened, and timestamps linked
  them. Jobs keep it at every level. Logger, collector and the admin
  projection apply the same rule.
- Admin user routes take an _id only as id:<_id>; a 24-hex GitHub login
  can no longer match another account's _id for ban or promote.
- The download-job expectation includes the owner id the PR adds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 13:08:19 +00:00
Thomas Durieux 7c9e803fbd Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	deploy/logging/sanitize.vrl
2026-11-29 13:03:03 +00:00
Thomas DurieuxandClaude Opus 5.5 86a35d62f1 feat(logging): record repository, user and viewer on log records
Handlers that resolve an anonymized repository, pull request or gist now
put its public ID on the log context, so request, job and error records
carry repoId, pullRequestId or gistId. The signed-in user's internal _id
(userId) is recorded on account routes. On routes that serve anonymized
content, userId is kept only when the user owns, co-authors or
administers the project; otherwise the record carries viewer "visitor"
or "anonymous" and no userId. The collector, the Redis mirror and the
admin log APIs apply the same rule. Jobs carry repoId and the owner's
userId stamped at enqueue time.

The admin Errors page links repoId to the admin repository search and
userId to the admin user page, which now accepts a user _id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 12:36:09 +00:00
Thomas Durieux 0233d1ad0b Merge remote-tracking branch 'origin/main' into fix/expected-errors-info
# Conflicts:
#	deploy/logging/sanitize.vrl
#	public/asset-manifest.json
#	public/script/vendor.min.js
#	src/core/log-diagnostic-schema.ts
2026-11-29 12:03:42 +00:00
Thomas DurieuxandClaude Opus 5.5 e571268e56 feat(logging): record each outbound call to GitHub and other external services
One info record per HTTP request to an external host (fetch and node:http),
with method, host, a fixed endpoint label, status or error code, duration and
the caller's requestId. Internal hops are skipped. Labels keep only literal
segments, so no owner, repository, path or identifier is logged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 11:57:28 +00:00
Thomas Durieux 07bdae9252 Merge remote-tracking branch 'origin/main' into feat/repo-list-sync
# Conflicts:
#	deploy/logging/sanitize.vrl
#	public/asset-manifest.json
#	public/script/vendor.min.js
2026-11-29 11:52:53 +00:00
Thomas DurieuxandClaude Opus 5.5 0a0b579c13 fix(logging): keep uncoded streamer 4xx replies on the Errors page
An uncoded 4xx comes from something in front of the streamer (body-size
limit, ingress, wrong entrypoint), so it is now streamer_unexpected_response
(502, error) rather than an info-level file_not_found. The streamer's
catch-all route gets its own code so a misrouted call logs at warn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 11:47:06 +00:00
Thomas DurieuxandClaude Opus 5.5 63343c871c fix: keep every thrown error code in the logs
The logger keeps errorCode only for allowlisted codes, and so does the
collector (sanitize.vrl). Both lists are maintained by hand, so codes
added since then were dropped and logged as a bare 400. Among them:
invalid_billing_expiration (billingError), invalid_auth_state
(appError), streamer_unreachable, github_unavailable, user_banned and
most billing and GitHub App codes, 41 in all.

scripts/generate-log-diagnostics.js now collects the codes passed to
AnonymousError, billingError and appError, plus codes assigned to an
errCode/code variable. It writes them to LOG_THROWN_ERROR_CODES, which
the logger accepts, and appends them to the collector's errorCode
allowlist. A test fails when a thrown code is missing from either list.

Regenerating also refreshes source function names that had gone stale
(jsDelivrFileUrl, ownerGitHubAccessRequired, ...), whose stack frames
the collector was dropping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 09:16:35 +00:00
Thomas DurieuxandClaude Opus 5.5 c73e992b7c feat: store the repository picker list and update it by webhook
The anonymize page's "Your repositories" picker now pages and searches a
per-user list stored in MongoDB instead of calling GitHub on every page and
search. GitHub is read only when the list is empty, when the user presses
the new refresh button, or after an installation change marks it stale.

- One sync per list (Mongo lock with a renewed lease); full pagination in
  the background after the first page is returned; rate limits pause syncs.
- GitHub App installation, installation_repositories and repository
  webhooks update the stored lists idempotently. The App must subscribe to
  the Repository event (documented in docs/github-app-setup.md).
- Legacy OAuth lists change only on refresh.
- Picker header shows "Updated 3 min ago" and a refresh button.
- dev-mock: stored list, simulated refresh and webhook endpoint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 08:06:30 +00:00
Thomas DurieuxandClaude Opus 5.5 4099953d8a feat(logging): label billing routes and checkout outcomes
Billing API calls and Stripe return pages were logged as route "other", so
the purchase funnel could only be read from Stripe. Give them fixed labels in
the app, Nginx and the collector allowlist, and record the ?billing= outcome
(success, cancelled, portal) on edge requests. Only fixed values are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 18:30:40 +00:00
Thomas Durieux b284bfb4f9 fix(logging): retain safe ZIP and worker failure reasons 2026-11-19 15:04:03 +00:00
Thomas DurieuxandClaude Opus 5.5 1e99cda5e0 fix: make the admin billing tab count sales consistently and show amounts
- The subscriptions list shows one row per sale, grouped with the same
  stages as the summary: a paper pack is one "Paper pack" row with its
  parts on a second line. Filters, state tabs, sort and pagination count
  sales. A new "Started" filter matches the summary periods.
- N days now draw N buckets ending today (12 months: 52 weeks), and the
  tiles count from the same start.
- One family vocabulary: Subscriptions, Repository add-ons, Conferences in
  the legend, the By-plan grouping and the list.
- Cancelling folds into "Renews / ends", revocation into "Status"; rows
  have one height. Names and repository ids use proportional figures,
  since Inter's tabular figures widen hyphens.
- New Amount column (cached Stripe list price, per period for
  subscriptions, once per pack). Chart tooltips show count and revenue
  per family and the total per currency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 15:28:19 +00:00
Thomas Durieux 9a20ad1cf8 fix: distinguish quota limits and increase author storage 2026-11-15 18:47:47 +00:00
Thomas Durieux 128a7366b7 Merge pull request #972 from tdurieux/feat/operational-alerts-incidents
feat: add operational incident evidence and recovering alerts
2026-11-15 16:28:02 +01:00
Thomas Durieux 11f2bb31d8 Merge pull request #971 from tdurieux/fix/grafana-operations-clarity
fix: make Grafana operations understandable and query-correct
2026-11-15 16:27:51 +01:00
Thomas Durieux d99a9587f7 fix: retain loss evidence and fail interrupted deployments 2026-11-15 13:52:05 +00:00
Thomas Durieux ba159878b4 feat: show latency by API endpoint and method 2026-11-15 13:50:03 +00:00
Thomas Durieux 0f9d8c657a feat: add operational incident evidence and recovering alerts 2026-11-15 13:45:38 +00:00
Thomas Durieux a4f441f097 fix: record cached reader failures before pipeline teardown 2026-11-15 13:39:17 +00:00
Thomas Durieux 87882c5a4b fix: use datasource-native regex variable interpolation 2026-11-15 13:36:09 +00:00
Thomas Durieux 7f3cf71bc3 fix: make Grafana operations understandable and query-correct 2026-11-15 13:34:03 +00:00
Thomas Durieux d2e3954d21 fix: explain interrupted requests and account for overlapping latency 2026-11-15 13:31:16 +00:00
Thomas Durieux 1723f5e927 fix: require anonymous endpoint methods for logged paths 2026-11-15 00:14:01 +00:00
Thomas Durieux 7d044525ce fix: exclude source repository lookups from captured paths 2026-11-15 00:08:12 +00:00
Thomas Durieux 953767b2cd fix: retain actual anonymous request paths across outcomes 2026-11-15 00:01:21 +00:00
Thomas Durieux 8eb5097070 Merge remote-tracking branch 'origin/main' into integrate/diagnostics 2026-11-14 23:19:23 +00:00
Thomas Durieux 6035c01956 Merge remote-tracking branch 'origin/main' into integrate/diagnostics
# Conflicts:
#	deploy/logging/README.md
#	public/asset-manifest.json
#	public/css/all.min.css
#	public/css/style.css
#	public/script/vendor.min.js
2026-11-14 23:19:22 +00:00
Thomas Durieux fbb9c5fac0 Merge pull request #967 from tdurieux/fix/deployment-and-repository-errors
fix: guard GitHub App deployments and distinguish removed repositories
2026-11-15 00:18:37 +01:00
Thomas Durieux 65914c743e fix: validate GitHub App mounts before deployment and distinguish removed repositories 2026-11-14 22:57:01 +00:00
Thomas Durieux 5dbf3e7829 feat: retain bounded failed-request reproduction context 2026-11-14 21:44:48 +00:00
Thomas Durieux 0f7b798cae test: trace a real synthetic exception through logging 2026-11-14 21:25:09 +00:00
Thomas Durieux f6574069da feat: preserve safe request and exception diagnostics 2026-11-14 21:22:28 +00:00
Thomas Durieux 2647794d39 fix: let Vector read restricted Nginx access logs 2026-11-14 21:09:29 +00:00
Thomas Durieux 8ec205612c fix: preserve log event fields during VictoriaLogs ingestion 2026-11-14 17:37:34 +00:00
Codex 20621c0660 fix(admin): include unknown releases and edge failures in investigations 2026-11-14 16:53:13 +00:00
Codex 88d696ca7c fix(admin): reserve Redis capacity for complete stats transactions 2026-11-14 16:44:31 +00:00
Codex 8b928a4c82 feat(admin): investigate correlated logs from the Errors page 2026-11-14 16:33:37 +00:00
Codex f084f5cbfc fix: make buffer losses observable and preserve admin error codes 2026-11-14 14:01:50 +00:00
Codex 7e2a6e9d75 feat: add private structured logging and investigation dashboards 2026-11-14 13:40:40 +00:00
Codex b51e5afa4a ops: limit bulk file fetching and repeated directory polling 2026-11-10 11:31:55 +00:00
Codex 905b8ad781 ops: attribute edge traffic and correlate upstream failures 2026-11-10 08:46:57 +00:00