Skip to content
This repository was archived by the owner on May 14, 2026. It is now read-only.
This repository was archived by the owner on May 14, 2026. It is now read-only.

feat(reporter): implement the reporting engine (NDJSON + Reporter trait) #345

@zkochan

Description

@zkochan

Summary

Implement the reporter described in #344: a typed LogEvent enum mirroring
@pnpm/core-loggers, a trait Reporter per the #339 capability shape, an
NdjsonReporter that writes pnpm's wire format to stderr, a
SilentReporter for --reporter=silent, generic threading through the
install entry point, and the spawn-and-pipe wiring that feeds pacquet's
NDJSON into @pnpm/cli.default-reporter for default rendering.

This is the engine only. Backfilling missing log events in existing crates
and documenting the porting convention land in separate issues (linked
below).

Scope

  • New crate (likely crates/reporter, or extend an existing one if a
    clearer home emerges):
    • LogEvent enum with one variant per pnpm log channel from
      @pnpm/core-loggers.
      Serde attributes produce the bunyan envelope (level, time, name)
      plus channel-specific payload, matching what pnpm emits under
      --reporter=ndjson.
    • trait Reporter { fn emit(event: &LogEvent); } per Refactor and document the dependency injection pattern for tests #339 (associated
      function, no &self).
    • NdjsonReporter unit struct:
      • Module-level static OnceLock<Sender<Vec<u8>>> for the writer-task
        MPSC sender.
      • Module-level static throttle map for pnpm:fetching-progress
        (200ms per package, matching pnpm's reporter-side throttle).
      • Thread-local Vec<u8> serialization buffer per emit.
      • One dedicated writer task draining the channel and write_all-ing to
        stderr in batches.
    • SilentReporter unit struct: no-op emit.
  • --reporter=default|ndjson|silent CLI flag in pacquet-cli. The entry
    point dispatches to install::<NdjsonReporter> or
    install::<SilentReporter>; default and ndjson share the same sink,
    default additionally spawns the JS reporter and pipes stderr into it.
  • Spawn-and-pipe wiring for --reporter=default: spawn
    @pnpm/cli.default-reporter (or pnpm --reporter=default in consumer
    mode — TBD) as a child process and pipe pacquet's stderr to its stdin.
    The PR picks one of the three delivery options from Use pnpm's @pnpm/cli.default-reporter for terminal output (via NDJSON) #344 and documents
    the choice.
  • Identifier interning: Arc<str> (or lasso / ustr) for package
    names/versions threaded through events. Hooked at the resolver boundary
    so call sites already hold cheap clones.
  • One real channel wired end-to-end as a smoke test (e.g. pnpm:stage for
    "importing"), verified to render identically to pnpm.
  • Schema pinning: pacquet's Cargo.toml records the pnpm version it
    targets; add a CI check that emitted JSON parses against the
    corresponding upstream @pnpm/core-loggers shapes (TS-side script or a
    serde round-trip into our own duplicate of those types).

Out of scope (tracked separately)

Acceptance criteria

  • pacquet install --reporter=ndjson emits NDJSON whose lines parse cleanly
    when piped into pnpm --reporter=default (or
    npx @pnpm/cli.default-reporter), with at least one channel rendering
    identically to pnpm.
  • pacquet install --reporter=silent produces no output beyond what
    --reporter=silent produces in pnpm.
  • pacquet install --reporter=default spawns the JS reporter and renders
    pnpm-shaped output for the wired channel.
  • just ready is green; the recording-fake pattern from Refactor and document the dependency injection pattern for tests #339 is used at
    least once.

Parent

Design: #344. Roadmap line item: pnpm/pnpm#11633.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions