Skip to content

feat(logging): call-log correlation ID (safe core subset of #5275) - #5279

Merged
diegosouzapw merged 8 commits into
release/v3.8.40from
extract/correlation-id-oom
Jun 29, 2026
Merged

diegosouzapw merged 8 commits into
release/v3.8.40from
extract/correlation-id-oom

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Summary

Lands the safe, cohesive subset of #5275 (@hartmark) so the genuinely valuable, low-risk work is not blocked by the parts of that PR that need a focused review:

  • Call-Log Correlation ID (end-to-end) — each request gets a unique correlation id, returned in the X-Correlation-Id response header, stored in call_logs (migration 109), filterable via /api/usage/call-logs, and surfaced in the dashboard request logger (with per-chunk stream timestamps + active-requests-first sort).
  • Webpack OOM / lazy-loading fix — narrows the Next build tsconfig include to src/** (the documented **/* → ~70× glob OOM cause), adds "use client" directives for proper code-splitting, and hides the heavy batchProcessor/tsx imports from webpack's static analysis via /* webpackIgnore */.
  • Dev ChunkLoadError fix — no-cache headers on dev HTML + SW unregister.

What was deliberately NOT included (stays in #5275 for a focused review)

  • The combo/resilience semantic changes (targetExhaustion.ts 5xx narrowing, streamPreBuffer, per-model cooldown, validateQuality) — these alter the documented 3-mechanism resilience model and several are currently unwired scaffolding; they deserve their own RFC-level PR.
  • The leftover console.error("[DEBUG-EXPAND]") on the auto-combo hot path.
  • The redundant root @toon-format/toon dependency churn.

Changes vs the original commits

  • Replaced new Function('return import("tsx")')() (Hard Rule deps: bump eslint from 9.39.2 to 10.0.0 in the development group #3 violation) with the sanctioned await import(/* webpackIgnore: true */ "tsx").
  • Renumbered the migration 103 → 109 (103 collided with 103_strip_legacy_combo_config_keys.sql).
  • Declared correlation_id on the CallLogSummaryRow type (typecheck) and rebaselined the 6 frozen files this subset grows (justification in file-size-baseline.json).

Validation

  • npm run typecheck:core — clean
  • npm run check:file-size — OK (baseline updated with justification)
  • npm run check:migration-numbering — OK (no collision)
  • node --import tsx/esm --test tests/unit/save-call-log-persistence.test.ts — 4/4 pass

Original work by @hartmark (commits preserved with author attribution); maintainer co-authored the Rule #3 fix, migration renumber, type fix, and rebaseline.

hartmark and others added 7 commits June 28, 2026 22:42
Narrow tsconfig include to src/**, add "use client" directives for proper
code-splitting, and hide the heavy batchProcessor/tsx imports from webpack's
static analysis via /* webpackIgnore */ (replaces a new Function() eval shim —
Hard Rule #3).

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
- Add correlation_id column to call_logs table (migration + schema)
- Thread correlationId through chat handler, combo handler, and breaker
- Return X-Correlation-Id response header
- Filter call-logs by correlationId in API and dashboard
- Fix call-logs sort: active requests first, then newest
- Add timestamps to request logger detail and list views
- Make getExecutor() async for lazy loading support
- Add correlationId to trackPendingRequest metadata in chatCore.ts
- Add correlationId to PersistAttemptLogsContext and saveCallLog in attemptLogging.ts
- Add correlationId parameter to handleChatCore signature
The CREATE INDEX in SCHEMA_SQL runs before ensureCallLogsColumns adds the
correlation_id column to existing databases, causing 'no such column' error
that silently breaks getDbInstance() — all saveCallLog calls fail.

The index is already created by ensureCallLogsColumns in schemaColumns.ts
after the column is added.
…e test

- Add correlationId to ctx destructuring in attemptLogging.ts so it
  actually reaches saveCallLog (was undefined before — destructured
  variable shadowed the ctx.correlationId reference)
- Add save-call-log-persistence.test.ts: 4 tests verifying saveCallLog
  persists to DB with correlationId, null fallback, getCallLogs roundtrip,
  and column/index existence
Declares the new correlation_id column on the CallLogSummaryRow type (typecheck)
and rebaselines the 6 frozen files the CorrelationId + lazy-loading extraction grows.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Drops the build/lazy-loading changes (tsconfig include narrowing, instrumentation
import shim, "use client" churn) and the call-logs list/detail display rework
(active-first sort, Event Stream split) — those break the CLI build path / existing
request-logger tests in isolation and belong with #5275's focused review. Keeps the
self-contained, green CorrelationId core: migration 109, storage, and the
X-Correlation-Id response header wiring.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
@diegosouzapw diegosouzapw changed the title feat(logging): call-log correlation ID + webpack-OOM/lazy-loading fix (safe subset of #5275) feat(logging): call-log correlation ID (safe core subset of #5275) Jun 29, 2026
@diegosouzapw

Copy link
Copy Markdown
Collaborator Author

Scope reduced: dropped the build/lazy-loading changes (tsconfig include narrowing broke the CLI build path → runtime 500s on the dast-smoke fuzz) and the call-logs list/detail display rework (active-first sort + Event Stream split broke existing request-logger tests in isolation). Both stay with #5275's focused review. This PR is now the self-contained, green CorrelationId core: migration 109 + storage + the X-Correlation-Id response header. Validated: typecheck clean, file-size OK, request-logger-endpoints 34/34, request-log-detail-stream 4/4, save-call-log-persistence 4/4.

@diegosouzapw
diegosouzapw merged commit 9a89158 into release/v3.8.40 Jun 29, 2026
7 checks passed
@diegosouzapw
diegosouzapw deleted the extract/correlation-id-oom branch June 29, 2026 05:49
@diegosouzapw diegosouzapw mentioned this pull request Jun 29, 2026
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
…nference#5275) (cheaper-inference#5279)

Call-log correlation ID core (migration 109 + storage + X-Correlation-Id header) — safe subset of cheaper-inference#5275. Original work by @hartmark. Integrated into release/v3.8.40.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants