Skip to content

chore: repo-wide hardening and performance improvements#376

Merged
HugoRCD merged 5 commits into
mainfrom
claude/lucid-lamport-eyap8u
Jun 11, 2026
Merged

chore: repo-wide hardening and performance improvements#376
HugoRCD merged 5 commits into
mainfrom
claude/lucid-lamport-eyap8u

Conversation

@HugoRCD

@HugoRCD HugoRCD commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Breaking Changes

    • Raised Node.js engine requirement to version 18 or higher.
  • Improvements

    • Ingest endpoint enforces a 32KB request body limit (returns 413) and stricter JSON validation.
    • Deprecated config fields emit a one-time migration warning and are mapped to replacements.
    • Audit handling tolerates circular references without hanging; signatures remain stable.
    • Background timers no longer keep the process alive.
    • Redaction is faster and more consistent via precompiled matchers and better case-insensitive handling.
    • Vite warns when source location embedding is enabled for production builds.

- CI: scope mutation workflow permissions, SHA-pin third-party actions, pin release Node version
- deps: pin @types/node, declare engines field on published packages
- ingest: cap request body size at 32KB, document the endpoint threat model
- redact: precompile path matchers once per config, O(1) case-insensitive leaf lookup, drop no-op lastIndex resets
- pipeline: unref flush and retry timers so pending batches never hold the process open
- audit: guard stableStringify against circular references
- adapters: share deprecated-alias handling via applyDeprecatedAlias toolkit helper
- vite: warn when sourceLocation is enabled for production builds

https://claude.ai/code/session_01HyRiR2xjNsgoDshB64itH3
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evlog-docs Ready Ready Preview, Comment, Open in v0 Jun 11, 2026 7:26pm
just-use-evlog Ready Ready Preview, Comment Jun 11, 2026 7:26pm

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 62e15036-d6a9-40e0-8841-a9d7f36a4c95

📥 Commits

Reviewing files that changed from the base of the PR and between 98b1af2 and 41bd279.

📒 Files selected for processing (5)
  • .changeset/repo-hardening-perf.md
  • packages/evlog/src/adapters/better-stack.ts
  • packages/evlog/src/pipeline.ts
  • packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts
  • packages/evlog/src/shared/config.ts

📝 Walkthrough

Walkthrough

This PR pins CI/actions and Node engines, adds a shared deprecated-config alias helper (adopted by adapters), enforces 32KB ingest request limits with strict JSON parsing, precompiles redact path matchers and optimizes leaf lookups, adds circular-reference detection to audit stringify, and applies runtime/perf tweaks (timer unref, header Set, Vite warning).

Changes

Dependency hardening and configuration improvements

Layer / File(s) Summary
CI/dependency hardening
.github/workflows/mutation.yml, .github/workflows/release.yml, .github/workflows/semantic-pull-request.yml, package.json, packages/evlog/package.json, packages/nuxthub/package.json
Workflow permissions declared; GitHub Actions pinned to specific commit SHAs; Node.js runtime pinned to version 22 in release workflow; @types/node pinned to ^25.9.1; published packages require Node >=18.0.0.
Deprecated config alias infrastructure
packages/evlog/src/shared/config.ts, packages/evlog/src/adapters/axiom.ts, packages/evlog/src/adapters/better-stack.ts
Added exported applyDeprecatedAlias helper that copies deprecated config fields to replacements with a one-time per-adapter warning; Axiom and Better Stack adapters adopt it to map token/sourceTokenapiKey.
Ingest endpoint request validation
packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts
Introduces readJsonBody enforcing 32KB maximum body size via content-length/raw-length checks, returning 413 for oversized requests and 400 for invalid/empty JSON; handler switched to use readRawBody and updated docs comment.

Redaction and serialization robustness

Layer / File(s) Summary
Redaction path matcher precompilation and caching
packages/evlog/src/types.ts, packages/evlog/src/redact.ts, packages/evlog/test/core/redact.test.ts
Adds internal _pathMatchers to RedactConfig; compiles case-insensitive leaf keys lowercased for Set membership; resolveRedactConfig populates _pathMatchers for more cases; redactEvent reuses compiled matchers; removed regex lastIndex resets; tests cover precompilation correctness and parity with ad-hoc configs.
Circular reference handling in audit serialization
packages/evlog/src/audit.ts, packages/evlog/test/core/audit.test.ts
stableStringify now threads an ancestors WeakSet to detect cycles and emits "[Circular]" for true cycles while preserving deterministic ordering; test ensures signing succeeds on circular inputs.
Performance optimizations and warnings
packages/evlog/src/pipeline.ts, packages/evlog/src/utils.ts, packages/evlog/src/vite/source-location.ts
Introduces unrefTimer() and unrefs scheduled flush timers; replaces linear header includes with precomputed Set for O(1) checks; adds Vite warning when sourceLocation is enabled for production builds.
Changeset documentation
.changeset/repo-hardening-perf.md
Changelog entry documents the hardening and performance updates made across the repository.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • HugoRCD/evlog#371: Related redaction matcher work — both PRs modify path/key matcher compilation and reuse.
  • HugoRCD/evlog#354: Related adapter config aliasing and apiKey convention changes.
  • HugoRCD/evlog#356: Related audit/signing/idempotency finalization and deterministic-field handling.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided; the template requires a description section detailing changes and their rationale. Add a description explaining the purpose of the hardening changes, performance optimizations, and any breaking changes (e.g., Node engine requirement bumps).
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed Title aligns well with the changeset focusing on repo-wide hardening and performance improvements across multiple packages and workflows.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/lucid-lamport-eyap8u

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented Jun 11, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/evlog@376
npm i https://pkg.pr.new/@evlog/nuxthub@376

commit: 41bd279

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Line 62: The package.json dependency "`@types/node`" is set to ^25.9.1 which can
expose Node 25+ typings while CI runs Node 22; update the "`@types/node`" entry in
package.json to a Node-22-compatible major (for example "^22.0.0" or a specific
22.x release), run your package manager to update lockfiles, and re-run CI;
alternatively, if you intend to use Node 25 features, change the CI node-version
to match instead (whichever path you choose, keep the `@types/node` major aligned
with the CI Node runtime).

In `@packages/evlog/src/adapters/better-stack.ts`:
- Line 37: Update the envHint text in the BetterStack adapter so it mentions
both Nuxt-specific and generic environment variable names; locate the envHint
property in packages/evlog/src/adapters/better-stack.ts (the current string
'Env: NUXT_BETTER_STACK_SOURCE_TOKEN → NUXT_BETTER_STACK_API_KEY.') and change
it to include BETTER_STACK_SOURCE_TOKEN and BETTER_STACK_API_KEY alongside the
NUXT_* variants (e.g. mention "NUXT_BETTER_STACK_SOURCE_TOKEN /
NUXT_BETTER_STACK_API_KEY or BETTER_STACK_SOURCE_TOKEN / BETTER_STACK_API_KEY")
so non-Nuxt users are not misled.

In `@packages/evlog/src/pipeline.ts`:
- Line 135: The retry backoff timer in sendWithRetry is being unref'd via
unrefTimer(setTimeout(...)) which can allow Node/Bun to exit even when flush()
is awaiting the retry Promise; modify sendWithRetry so that when it's invoked as
part of an explicit flush (the flush caller or a boolean flag passed into
sendWithRetry), the retry timers are kept ref'd (use setTimeout without
unrefTimer) so the awaited Promise will keep the event loop alive; leave the
unref behavior for non-flush paths to avoid preventing shutdown hang-ups. Ensure
you update the call sites (flush and any other callers) to pass the flag and
change the code around getRetryDelay(attempt) / unrefTimer accordingly.

In `@packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts`:
- Line 52: The check using raw.length mismeasures UTF-8 byte size; update the
ingest POST handler to compute actual UTF-8 byte length (use new
TextEncoder().encode(raw).length) and compare that to MAX_BODY_BYTES instead of
raw.length, replacing the current conditional that references raw and
MAX_BODY_BYTES; ensure the same byte-counting logic is used wherever the body
size is validated in this route so large multi-byte-character payloads are
correctly rejected.

In `@packages/evlog/src/shared/config.ts`:
- Line 60: The guard in applyDeprecatedAlias currently treats falsy values as
unset by using !record[opts.to]; change it to a nullish check so valid falsy
values (0, false, '') are not overwritten—replace the condition with a
null/undefined check such as record[opts.to] == null && record[opts.from] !=
null (or equivalent strict checks) so the alias is only applied when the target
is actually null/undefined and the source exists.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 72370871-86f9-401e-86ce-1f1a48e7ca6c

📥 Commits

Reviewing files that changed from the base of the PR and between 638cdc1 and 98b1af2.

⛔ Files ignored due to path filters (2)
  • packages/evlog/test/toolkit/__snapshots__/api-surface.test.ts.snap is excluded by !**/*.snap
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (19)
  • .changeset/repo-hardening-perf.md
  • .github/workflows/mutation.yml
  • .github/workflows/release.yml
  • .github/workflows/semantic-pull-request.yml
  • package.json
  • packages/evlog/package.json
  • packages/evlog/src/adapters/axiom.ts
  • packages/evlog/src/adapters/better-stack.ts
  • packages/evlog/src/audit.ts
  • packages/evlog/src/pipeline.ts
  • packages/evlog/src/redact.ts
  • packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts
  • packages/evlog/src/shared/config.ts
  • packages/evlog/src/types.ts
  • packages/evlog/src/utils.ts
  • packages/evlog/src/vite/source-location.ts
  • packages/evlog/test/core/audit.test.ts
  • packages/evlog/test/core/redact.test.ts
  • packages/nuxthub/package.json

Comment thread package.json
Comment thread packages/evlog/src/adapters/better-stack.ts Outdated
Comment thread packages/evlog/src/pipeline.ts Outdated
Comment thread packages/evlog/src/runtime/server/routes/_evlog/ingest.post.ts Outdated
Comment thread packages/evlog/src/shared/config.ts Outdated
claude added 2 commits June 11, 2026 19:21
- ingest: measure body size in UTF-8 bytes via TextEncoder
- toolkit: applyDeprecatedAlias only treats null/undefined as unset
- better-stack: include non-Nuxt env vars in deprecation hint
- pipeline: keep retry backoff timers ref'd so flush() can't be
  interrupted by process exit mid-retry; only the idle flush
  scheduling timer is unref'd

https://claude.ai/code/session_01HyRiR2xjNsgoDshB64itH3
@HugoRCD HugoRCD merged commit 4c13bb0 into main Jun 11, 2026
16 of 17 checks passed
@HugoRCD HugoRCD deleted the claude/lucid-lamport-eyap8u branch June 11, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants