Repository navigation
v0.1.0
First release of Phargus (@pharn-dev/phargus).
Added
- Release preparation workflow that validates a tarball without publishing, with explicit opt-in for later GitHub Release publishing.
- Installed-package checks for ESM/CJS imports and types, analyzer workers, plugin sandbox, and the agent → collector → dashboard SSE flow.
- Single npm package with subpath exports, built as both ESM and CommonJS.
- Open-source baseline:
README.md,SECURITY.md,CODE_OF_CONDUCT.md,docs/THREAT-MODEL.md,docs/LIMITS.md, issue and pull request templates. - CI: format, lint, typecheck, test, build, action-pin checks, CodeQL and gitleaks.
- Manual release process with npm Trusted Publishing and provenance.
- Agent: event loop delay and memory samplers driven by a sampler controller.
- Agent: NDJSON export stream with bounded, drop-oldest backpressure, to stdout or a file.
- Agent: configuration from
PHARGUS_*environment variables andphargus.config.{js,json}. - Agent: GC sampler (count and pause times by kind) from
PerformanceObserver. - Agent: stream backpressure probe that reports stalled writes by call site.
- Agent:
require('@pharn-dev/phargus/agent')/import '@pharn-dev/phargus/agent'(or--require/--import) starts the agent once per process. - Agent: automatic trace id per incoming
node:http/node:httpsrequest throughAsyncLocalStorage, honouring an incoming W3Ctraceparent;currentTraceId(). - Agent: V8 heap space statistics in every sample and on-demand heap snapshots (
takeHeapSnapshot). - Agent: on-demand allocation sampling through the inspector (
sampleAllocations). - Agent: a parser for
node --trace-deoptoutput (createDeoptParser). It does not capture the output itself. - Agent: runs under the Node permission model; a denied grant disables only that feature with a typed
PhargusPermissionError;isPermissionModelEnabled()andcheckPermission(). - Agent: HTTP spans exported as NDJSON lines next to samples.
- Collector (
@pharn-dev/phargus/collector): fixed time windows with integer math and ring buffers of recent windows, alerts and spans. - Collector: window-based alerts with per-metric thresholds.
- Collector: alert sinks for stdout, a file and a webhook (Node core
fetch). - Collector: opt-in persistence of recent windows to an append-only file, restored on start.
- Dashboard (
@pharn-dev/phargus/dashboard): SSE server with token gating for non-loopback binds. - Dashboard: vanilla-JS live page with event loop, memory, GC, alerts and a trace waterfall of recent requests.
- Analyzer (
@pharn-dev/phargus/analyzer): Worker Thread pool with heap-snapshot summaries and diffs. - Analyzer: source-map stack-trace symbolization on the worker pool.
- Plugin runner (
@pharn-dev/phargus/plugin-runner): user rules in anisolated-vmsandbox in a child process, with a memory limit and a timeout. - Plugin runner: built-in rules (event loop lag, GC pause share, heap growth) and
loadRulesDirectory. - OpenTelemetry (
@pharn-dev/phargus/otel): opt-in OTLP/HTTP JSON export of windows as metrics and spans as traces. - Examples:
examples/express-app(agent in the app, collector and dashboard in a second process) andexamples/worker-pool. - Agent: every sample line carries cumulative
dropped: { samples, spans }loss counters. - Agent:
createDeoptParser({ maxEvents, maxLineLength })anddroppedEvents(). - Agent:
createSamplerController(onSample, { onError }); newPhargusSamplerWarningandPhargusBackpressureWarningprocess warnings. - Dashboard:
allowedHostsoption for names the dashboard is reached by (reverse proxy, container port mapping). - Collector and OpenTelemetry:
closeTimeoutMsoption on the webhook sink and the OTLP exporters;WindowStore.close(). - Analyzer:
maxSnapshotBytesoption (default 256 MiB) andHeapSnapshotTooLargeError(ERR_HEAP_SNAPSHOT_TOO_LARGE);DEFAULT_RESOURCE_LIMITS,DEFAULT_MAX_SNAPSHOT_BYTES. - Analyzer: symbolizer
rootsoption (reads confined byrealpath) andmaxFileBytes(default 64 MiB);DEFAULT_MAX_SOURCE_FILE_BYTES. - Plugin runner:
maxFindings(default 10 000) andmaxResultBytes(default 1 MiB) options. bench/overhead.mjs(agent-on versus agent-off benchmark),bench/soak.mjs(leak checks under load) and a nightly workflow that runs both.- CI:
npm run check:packagein the Build job checks the tarball contents and thatengines.nodematches.nvmrc.
Changed
- Renamed the project and npm package to Phargus (
@pharn-dev/phargus). Imports and preloads now use@pharn-dev/phargus/<subpath>; configuration usesPHARGUS_*environment variables andphargus.config.{js,json}. Existing integrations must update those names. - Renamed public errors and warnings to
Phargus*, error codes toPHARGUS_*, built-in rule IDs and OpenTelemetry metric names tophargus/...andphargus.*, and the dashboard session cookie tophargus_token(existing dashboard sessions must sign in again). engines.nodeis now>=22.18.0, and.nvmrcpins22.18.0; required CI jobs run on that floor.- The package no longer ships declaration maps or the analyzer test fixture;
.js.mapfiles embed their sources. - Agent: an unknown
PHARGUS_*variable prints one warning on stderr and is ignored, instead of disabling the agent. - Agent: samples and spans are queued in separate lanes, each bounded by
queueBound; sample lines are written first. - Agent: the backpressure probe also covers
Duplex,Transform,PassThrough,net.Socket,tls.TLSSocket,http.ServerResponseandhttp.ClientRequest. - Agent: an ESM and a CJS copy of the agent share one set of prototype wrappers.
- Agent:
traceparentwith an all-zero parent id starts a new trace; versions other than00are parsed with the00layout. - Dashboard: requests whose
Hostis not allowed get421; a cross-originOriginon/eventsor a non-GET request gets403. - Dashboard:
?token=is accepted only onGET /and exchanged for anHttpOnly,SameSite=Strictcookie; assets and/eventstake the cookie orAuthorization: Bearer. - Dashboard: malformed-request warnings are rate-limited to one report plus one summary per 10 s; client resets are not reported.
- Collector and OpenTelemetry:
close()waits at mostcloseTimeoutMs, then drops queued batches and aborts in-flight requests, counting both. - Collector:
collector.close()closes the sinks first and latches the window store. - Analyzer: every pool worker runs with
resourceLimits(default 512 MiB old, 64 MiB young generation). - Analyzer: the heap-snapshot worker streams the file; snapshots must list
snapshot,nodesandstringsin V8's order and have at most 262 144 distinct object names. - Analyzer: workers no longer inherit entry-point flags such as
--input-type,-eor--inspect. - Plugin runner: the sandbox child receives the host's
--permission,--experimental-permissionand--allow-*flags.
Fixed
- Agent: requests that arrive while the agent configuration loads are traced.
- Agent: spans no longer evict metric samples from the output queue under load.
- Agent: disabling the backpressure probe or tracing never leaves a throwing
writeoremitbehind and never removes a wrapper another library installed later. - Agent: the stream
writewrappers keep the original arity (write.length === 3). - Agent: a throwing
onSamplecallback no longer becomes an uncaught exception. - Agent: the deopt parser no longer keeps every event forever.
- Analyzer: an oversized heap snapshot can no longer abort the host process with a fatal out-of-memory error.
- Analyzer: a host started with
--input-type=module -ecan start analyzer workers. - Collector:
append()aftercollector.close()no longer reopens the persistence file. - Dashboard: a stalled SSE client no longer retains dropped events.
Security
- Dashboard:
Host/Originallowlist against DNS rebinding. - Dashboard: the token no longer appears in page, asset or SSE URLs; the session cookie holds an HMAC of the token, not the token.
/eventsand error responses sendnosniff, adefault-src 'none'CSP andReferrer-Policy: no-referrer. - Collector and OpenTelemetry: webhook and OTLP requests never follow redirects (a 3xx is a failed delivery) and read at most 64 KiB of a response body.
- Files the agent, the window store and the file alert sink create are mode
0600. - Analyzer: symbolizer parse errors no longer quote file content.
- Plugin runner: rule results are capped in the child and validated on the host; rule error messages are cut to 4 096 characters.