Skip to content

Conversation

@BioPhoton
Copy link
Collaborator

@BioPhoton BioPhoton commented Jan 9, 2026

Related: #1197

This PR includes:

  • types for source sink flows
  • wal.ts - general WriteAheadLog and sharded WAL inc format and filenames
  • wal-trace-json.ts traceEvent specific login for a WAL
  • profiler constants to control WAL leader
  • moved trace utils into profiler

Note

This PR addresses a comment related to logging.
It could also be used as file output for the logger

Warning

All filesystem operations in WAL—and indirectly in the profiler—are synchronous by design.
The eslint rules are disables over file name pattern

Why synchronous fs is used for WAL code?

  • Profilers are side-channels, not business logic
  • Data must never be lost, reordered, or partially written
  • process.on('exit') cannot safely run async I/O
  • Sync writes guarantee ordering + durability
  • Profiler I/O volume is small → overhead is negligible
  • Crash-safety > throughput

@nx-cloud
Copy link

nx-cloud bot commented Jan 9, 2026

View your CI Pipeline Execution ↗ for commit f34ef73

Command Status Duration Result
nx run ci:code-pushup -- merge-diffs --files=/h... ✅ Succeeded 5s View ↗
nx run-many --targets=code-pushup --parallel=fa... ✅ Succeeded 1m 39s View ↗
nx run-many --targets=code-pushup --parallel=fa... ✅ Succeeded 13m 23s View ↗
nx run-many -t unit-test,int-test ✅ Succeeded 52s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-19 21:06:30 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 9, 2026

Open in StackBlitz

@code-pushup/ci

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/ci@1210

@code-pushup/cli

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/cli@1210

@code-pushup/core

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/core@1210

@code-pushup/create-cli

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/create-cli@1210

@code-pushup/nx-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/nx-plugin@1210

@code-pushup/axe-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/axe-plugin@1210

@code-pushup/models

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/models@1210

@code-pushup/coverage-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/coverage-plugin@1210

@code-pushup/eslint-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/eslint-plugin@1210

@code-pushup/js-packages-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/js-packages-plugin@1210

@code-pushup/jsdocs-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/jsdocs-plugin@1210

@code-pushup/lighthouse-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/lighthouse-plugin@1210

@code-pushup/typescript-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/typescript-plugin@1210

@code-pushup/utils

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/utils@1210

commit: f34ef73

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Code PushUp

🤨 Code PushUp report has both improvements and regressions – compared current commit d5f2a33 with previous commit 270b474.

🕵️ See full comparison in Code PushUp portal 🔍

🏷️ Categories

🏷️ Category ⭐ Previous score ⭐ Current score 🔄 Score change
Documentation 🔴 42 🔴 46 ↑ +3.5
Performance 🔴 37 🔴 36 ↓ −1
Code style 🟢 99 🟢 100 ↑ +0.4
Code coverage 🟢 93 🟢 93 ↑ +0.2
Bug prevention 🟡 75 🟡 75 ↓ −0.1
Axe Accessibility 🟡 88 🟡 88 ↓ −0.1
Security 🟡 51 🟡 51
Updates 🟡 78 🟡 78
Type Safety 🟡 67 🟡 67
Miscellaneous 🟡 67 🟡 67
Accessibility 🟢 92 🟢 92
Best Practices 🟢 100 🟢 100
SEO 🟢 92 🟢 92
👍 4 groups improved, 👎 1 group regressed, 👍 11 audits improved, 👎 2 audits regressed, 23 audits changed without impacting score

🗃️ Groups

🔌 Plugin 🗃️ Group ⭐ Previous score ⭐ Current score 🔄 Score change
ESLint Style guide (import) 🟡 80 🟢 100 ↑ +20
JSDocs coverage Documentation coverage 🔴 42 🔴 46 ↑ +3.5
Lighthouse Performance 🔴 37 🔴 36 ↓ −1
ESLint Suggestions 🟢 99 🟢 100 ↑ +0.4
Code coverage Code coverage metrics 🟢 93 🟢 93 ↑ +0.2

29 other groups are unchanged.

🛡️ Audits

🔌 Plugin 🛡️ Audit 📏 Previous value 📏 Current value 🔄 Value change
ESLint Forbid unassigned imports 🟥 1 warning 🟩 passed ↓ −100 %
JSDocs coverage Classes coverage 🟥 6 undocumented classes 🟨 6 undocumented classes  +0 %
JSDocs coverage Properties coverage 🟥 30 undocumented properties 🟥 40 undocumented properties ↑ +33.3 %
Lighthouse Total Blocking Time 🟥 1,890 ms 🟥 2,280 ms ↑ +21.1 %
Lighthouse Speed Index 🟥 6.0 s 🟥 5.9 s ↓ −2.7 %
JSDocs coverage Functions coverage 🟥 577 undocumented functions 🟥 580 undocumented functions ↑ +0.5 %
JSDocs coverage Types coverage 🟥 268 undocumented types 🟥 258 undocumented types ↓ −3.7 %
JSDocs coverage Variables coverage 🟥 268 undocumented variables 🟥 276 undocumented variables ↑ +3 %
Lighthouse Time to Interactive 🟥 13.0 s 🟥 12.9 s ↓ −0.9 %
JSDocs coverage Methods coverage 🟨 13 undocumented methods 🟨 15 undocumented methods ↑ +15.4 %
Code coverage Branch coverage 🟨 89 % 🟨 89.2 % ↑ +0.2 %
Code coverage Function coverage 🟩 94.4 % 🟩 94.5 % ↑ +0.2 %
Code coverage Line coverage 🟩 92.7 % 🟩 92.6 % ↓ −0.1 %
Lighthouse Uses efficient cache policy on static assets 🟨 31 resources found 🟨 31 resources found ↑ +0.3 %
Lighthouse Avoids enormous network payloads 🟩 Total size was 2,104 KiB 🟩 Total size was 2,103 KiB ↓ −0.1 %
Lighthouse Minimizes main-thread work 🟥 9.2 s 🟥 10.1 s ↑ +9.8 %
Lighthouse JavaScript execution time 🟥 4.3 s 🟥 5.1 s ↑ +19.4 %
Lighthouse Server Backend Latencies 🟩 1,200 ms 🟩 510 ms ↓ −57.3 %
Lighthouse Largest Contentful Paint 🟥 11.5 s 🟥 10.9 s ↓ −4.7 %
Lighthouse Reduce unused JavaScript 🟥 Potential savings of 224 KiB 🟥 Potential savings of 226 KiB ↓ −21.2 %
Lighthouse Max Potential First Input Delay 🟥 980 ms 🟥 1,200 ms ↑ +22 %
Lighthouse Reduce unused CSS 🟥 Potential savings of 95 KiB 🟥 Potential savings of 95 KiB ↓ −24.6 %
Lighthouse Remove duplicate modules in JavaScript bundles 🟥 Potential savings of 93 KiB 🟥 Potential savings of 93 KiB ↓ −32.6 %
Lighthouse Initial server response time was short 🟩 Root document took 540 ms 🟩 Root document took 410 ms ↓ −24.1 %
Lighthouse Metrics 🟩 100% 🟩 100% ↓ −0.9 %
Lighthouse First Contentful Paint 🟥 3.1 s 🟥 3.1 s ↑ +0.3 %
Lighthouse Avoids an excessive DOM size 🟥 2,403 elements 🟥 2,405 elements ↑ +0.1 %
Axe Elements must only use supported ARIA attributes 🟩 100 elements 🟩 102 elements ↑ +2 %
Axe ARIA attributes must be used as specified for the element's role 🟩 100 elements 🟩 102 elements ↑ +2 %
Axe Elements must only use permitted ARIA attributes 🟩 100 elements 🟩 102 elements ↑ +2 %
Axe ARIA attributes must conform to valid names 🟩 100 elements 🟩 102 elements ↑ +2 %
Lighthouse Network Round Trip Times 🟩 10 ms 🟩 10 ms ↑ +15.5 %
JS packages Outdated npm prod dependencies. 🟨 16 outdated package versions (5 major, 8 minor, 3 patch) 🟨 15 outdated package versions (5 major, 8 minor, 2 patch) ↓ −6.2 %
TypeScript Semantic errors 🟥 25 errors 🟥 26 errors ↑ +4 %
Axe Inline text spacing must be adjustable with custom stylesheets 🟩 43 elements 🟩 42 elements ↓ −2.3 %
Axe Interactive controls must not be nested 🟩 61 elements 🟩 60 elements ↓ −1.6 %

643 other audits are unchanged.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 16, 2026

Code PushUp

🥳 Code PushUp report has improved – compared current commit f523c36 with previous commit 270b474.

💼 Project utils

🥳 Code PushUp report has improved.

🕵️ See full comparison in Code PushUp portal 🔍

🏷️ Category ⭐ Previous score ⭐ Current score 🔄 Score change
Documentation 🔴 45 🟡 51 ↑ +5.4
Code coverage 🟢 95 🟢 95 ↑ +0.4

4 other categories are unchanged.

👍 2 groups improved, 👍 9 audits improved

🗃️ Groups

🔌 Plugin 🗃️ Group ⭐ Previous score ⭐ Current score 🔄 Score change
JSDocs coverage Documentation coverage 🔴 45 🟡 51 ↑ +5.4
Code coverage Code coverage metrics 🟢 95 🟢 95 ↑ +0.4

13 other groups are unchanged.

🛡️ Audits

🔌 Plugin 🛡️ Audit 📏 Previous value 📏 Current value 🔄 Value change
JSDocs coverage Classes coverage 🟨 3 undocumented classes 🟨 3 undocumented classes  +0 %
JSDocs coverage Properties coverage 🟥 27 undocumented properties 🟥 37 undocumented properties ↑ +37 %
JSDocs coverage Types coverage 🟥 66 undocumented types 🟨 56 undocumented types ↓ −15.2 %
JSDocs coverage Functions coverage 🟥 239 undocumented functions 🟥 242 undocumented functions ↑ +1.3 %
JSDocs coverage Variables coverage 🟥 49 undocumented variables 🟥 57 undocumented variables ↑ +16.3 %
JSDocs coverage Methods coverage 🟨 13 undocumented methods 🟨 15 undocumented methods ↑ +15.4 %
Code coverage Function coverage 🟩 96.2 % 🟩 96.6 % ↑ +0.5 %
Code coverage Branch coverage 🟩 91.8 % 🟩 92.2 % ↑ +0.4 %
Code coverage Line coverage 🟩 97.8 % 🟩 98 % ↑ +0.2 %

435 other audits are unchanged.


13 other projects are unchanged.

@BioPhoton BioPhoton marked this pull request as ready for review January 17, 2026 21:44
@BioPhoton BioPhoton requested a review from hanna-skryl January 17, 2026 21:44
@BioPhoton BioPhoton requested a review from matejchalk January 17, 2026 22:34
@BioPhoton BioPhoton changed the title feat(utils): add file sink classes feat(utils): add WriteAheadLog classes Jan 18, 2026
Copy link
Collaborator

@hanna-skryl hanna-skryl left a comment

Choose a reason for hiding this comment

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

The justification for sync file operations is well-reasoned 👍 I've added a few minor suggestions and comments.

SHARD_ID: /^\d{8}-\d{6}-\d{3}(?:\.\d+){3}$/,
} as const;

export function soratebleReadableDateString(timestampMs: string): string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
export function soratebleReadableDateString(timestampMs: string): string {
export function sortableReadableDateString(timestampMs: string): string {

Comment on lines +188 to +190
* @throws Error if recovery encounters decode errors
*/
repack(out = this.#file) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The JSDoc says that repack() throws if recovery encounters decode errors, but the implementation logs to the console and continues without throwing. Am I missing something?

import type { Codec } from '../src/lib/wal.js';

export class MockSink implements Sink<string, string> {
export class MockFileSink implements WriteAheadLogFile<string> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The TypeScript plugin reports an error here. Maybe MockFileSink should implement AppendableSink<string> instead?

Comment on lines +234 to +248
it('should create WAL format with custom directory', () => {
const format = traceEventWalFormat({ dir: '/custom/path' });

expect(format.baseName).toBe('trace');
expect(format.walExtension).toBe('.jsonl');
expect(format.finalExtension).toBe('.json');
});

it('should create WAL format with groupId', () => {
const format = traceEventWalFormat({ groupId: 'session-123' });

expect(format.baseName).toBe('trace');
expect(format.walExtension).toBe('.jsonl');
expect(format.finalExtension).toBe('.json');
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

traceEventWalFormat doesn't take any parameters 🤔

const recordsToWrite = hasInvalidEntries
? (r.records as T[])
: filterValidRecords(r.records);
fs.mkdirSync(path.dirname(out), { recursive: true });
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's an existing ensureDirectoryExists utility, but it's async. Maybe worth adding a sync variant (ensureDirectoryExistsSync) since this pattern repeats multiple times?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes also thought about it. For me I'm pretty soled on going sync in only this edge case of WAL and profiling. Let's wait on @matejchalk opinion here.

Comment on lines +455 to +457
* @throws Error if any shard contains decode errors
*/
finalize(opt?: Record<string, unknown>) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question as in repack() - the JSDoc says it throws on decode errors, but there is no explicit Error.

format: Partial<WalFormat<T>>,
): WalFormat<T> {
const {
baseName = 'trace',
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a mismatch between the JSDoc and the actual implementation - should baseName default to 'trace' or Date.now().toString()?

BioPhoton and others added 3 commits January 19, 2026 21:48
Co-authored-by: Hanna Skryl <80118140+hanna-skryl@users.noreply.github.com>
Co-authored-by: Hanna Skryl <80118140+hanna-skryl@users.noreply.github.com>
Co-authored-by: Hanna Skryl <80118140+hanna-skryl@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants