Skip to main content

Pra-Effect

Zero-dependency local CLI for parsing, deduplicating, and fingerprinting Python & Node.js error stack traces with low-memory streaming ingestion ($O(1)$ reader, $O(G)$ unique-group memory), ReDoS resilience, SQLite persistence, and standalone HTML reporting.

Python Version License Dependencies


Highlights

  • Zero Third-Party Dependencies: Pure Python standard library (argparse, hashlib, html, re, sqlite3, pathlib).
  • Resilient Fingerprinting (fingerprint_v1): Normalizes dynamic memory addresses (0x7f...), variable line numbers, timestamps, UUIDs, and ephemeral ports so identical incidents aggregate into one canonical hash.
  • Dual Runtime Support: Natively parses Python tracebacks (standard, chained exceptions, multiline messages) and Node.js call stacks (V8 engine).
  • Robust Input Handling:
    • Hard line truncation at 4,096 characters to prevent catastrophic regex backtracking (ReDoS).
    • Interleaving tolerance up to 2 lines of interleaved non-trace log noise.
    • Bounded message collection: log lines (INFO ..., timestamps) never leak into an error message.
    • Chained Python exceptions collapse to a single root incident (causes kept as diagnostic context, never split the fingerprint).
  • Streaming Architecture & Performance:
    • Input parsed line-by-line through state machines — reader memory footprint is $O(1)$ (0.0047 MB tracemalloc for pure stream ingestion).
    • Total memory scales with the number of unique incident groups $O(G)$, not total input byte size ($G$ distinct error patterns retained in memory).
    • Benchmark (Python 3.14 on Windows, synthetic multi-group logs):
      • Typical log stream (28.2 MB, ~72k traces, ~6.8k unique groups): ~6.1 MB Python heap, ~36.5 MB Peak RSS (GATE-MEM-01B PASS).
      • Adversarial high-cardinality stream (21.4 MB, ~54k traces, ~44.7k unique groups): ~39.8 MB Python heap, ~106 MB Peak RSS (characterized in DEC-017).
    • Optional --max-input-mb backstop rejects oversized raw log files (default 100 MB, 0 disables).
  • Local Persistence & Export:
    • WAL-mode SQLite storage for thread-safe concurrent writes and query performance.
    • Self-contained, single-file HTML reports with zero external CDN assets.
  • Semantic Exit Codes: POSIX standard compliance (0 = success/analysis complete, 1 = fatal I/O, 2 = invalid CLI invocation).

Installation

From Source (Editable / Tool Mode)

git clone https://github.com/Genesis410/pra-effect.git
cd pra-effect
pip install -e .

Standalone (Zero Install)

You can directly invoke the script without installation:

python pra_effect.py --help

CLI Usage

Pra-Effect provides three primary commands: ingest, scan, and history.

1. Ingest via STDIN (Pipe Mode)

Pipe stdout or stderr from test runners, logs, or services directly into Pra-Effect:

# Direct pipe from a failing script
python app.py 2>&1 | pra-effect ingest

# Save run to SQLite and export an HTML dashboard
pytest 2>&1 | pra-effect ingest --save --html report.html

# Check installed version (must match pyproject + git tag)
pra-effect --version

2. Scan Existing Log Files

Analyze log dumps or application error logs on disk — a single file or a whole directory:

# Explicit file (must be readable, otherwise exit 1)
pra-effect scan /var/log/application.log --save --html report.html

# Directory scan: default pattern *.log,*.txt, comma-separated globs supported
pra-effect scan /var/log --pattern "*.log,*.txt,*.out"

# Files that cannot be read (binary/unreadable) are skipped with a warning on stderr.
# Exit 1 if zero readable files matched — never a silent "0 errors found".

# Input-size backstop (default 100 MB, streaming already bounds the pipeline; 0 disables)
pra-effect scan /var/log/huge --max-input-mb 250

3. Historical Incident Aggregation

Query grouped incident metrics stored in your local SQLite database:

pra-effect history

Example Output:

=== Pra-Effect Historical Incident Groups ===
Fingerprint:  f9e160e1d88bbca1 (v1)
Runtime:      python
Error Type:   ValueError
Message:      bad <script>alert(1)</script>
Occurrences:  3 total across 2 runs
First Seen:   2026-10-24 16:30:00 UTC
Last Seen:    2026-10-24 16:45:12 UTC

Architecture & Data Flow

Log Stream (STDIN / File)
       │
       ▼
Pre-check Sanitizer (4,096 char cutoff, ReDoS guard)
       │
       ▼
Grammar Parsers (Python Tracebacks / Node.js V8 Stacks)
       │
       ▼
Message Normalizer (UUID / hex / ID collapse — not PII redaction)
       │
       ▼
Fingerprint Engine (SHA-256 top-frame + message -> 16-hex ID)
       │
       ├─────────────────────────┬─────────────────────────┐
       ▼                         ▼                         ▼
Terminal ANSI Output       SQLite Storage (WAL)      HTML Dashboard

Database & Schema

When --save is passed, runs are stored in ./.pra-effect/traces.db (override via --db <path>):

  • runs: Metadata per execution (duration, line counts, unique group count).
  • incidents: Normalized error incidents linked by foreign keys, tracking is_truncated, occurrence counts, and project frames.
  • v_historical_incidents: High-performance view aggregating cross-run recurrence.

Testing

Run the included verification suite (standard unittest discovery, works from any directory):

python -m unittest discover -s . -p "test_*.py"
# or
python test_pra_effect.py

Memory benchmarks for release gates (GATE-MEM-01A streaming pipeline & GATE-MEM-01B realistic workload):

python bench_memory.py            # exit 0 = PASS (<= 50 MB Peak RSS), 1 = gate exceeded, 2 = RSS NOT_RUN

Benchmark & Performance Gates:

  • GATE-MEM-01A (Pipeline Ingestion Stream): Peak RSS $\le$ 35 MB, tracemalloc $<$ 1 MB. Empirically measured 24.36 MB Peak RSS and 0.0047 MB tracemalloc across 54,000+ tracebacks ($O(1)$ streaming ingestion).
  • GATE-MEM-01B (Realistic Workload End-to-End): Peak RSS $\le$ 50 MB on files $\ge$ 25 MB with realistic deduplication ($\le$ 10,000 unique groups). Empirically measured 36.50 MB Peak RSS and 6.12 MB tracemalloc on 28.2 MB / 72,316 tracebacks.
  • High-Cardinality Boundary: In-memory grouping memory scales linearly $O(G)$ with unique error groups (~963 bytes per group with complete representative_trace). Peak RSS 50 MB is not guaranteed for adversarial logs where every single error is unique. --max-input-mb (default 100 MB) provides raw input byte capping.

Tests cover:

  • Python & Node.js grouping and line drift resilience.
  • Message normalization and hex address masking.
  • ReDoS guard and bounded multiline collection.
  • Interleaved non-trace log line tolerance.
  • SQLite WAL mode and concurrent transaction safety.
  • Single-file HTML generation with full XSS escaping on every rendered field, plus a PII notice (normalization is not redaction).
  • Chained exception collapse, bounded message collector, directory scan --pattern with skip/exit semantics.
  • Fingerprint version isolation in history queries (FINGERPRINT_SPEC.md).
  • CLI exit codes (0, 1, 2).
  • Streaming pipeline memory regression ($O(1)$ constant memory ingestion).
  • Raw input file cap backstop (--max-input-mb).
  • Golden CLI output parity (byte-identical across refactors).

License

MIT License. See LICENSE for details.


Release & Changelog

See CHANGELOG.md for the version history. Current release: 1.0.0.

Version consistency across the package (pyproject.toml), the CLI (--version), and the git tag is enforced by test_release_version_consistency.

Metadata

Release files for pra-effect 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pra-effect 1.0.0
File Size Uploaded Provenance Actions
pra_effect-1.0.0.tar.gz 19.3 kB With provenance Details for pra_effect-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pra-effect 1.0.0
File Interpreter ABI Platform Actions
pra_effect-1.0.0-py3-none-any.whl Python 3 none any Details for pra_effect-1.0.0-py3-none-any.whl

Total release size: 38.7 kB

Release files / pra_effect-1.0.0.tar.gz

Download URL pra_effect-1.0.0.tar.gz
Size 19.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3d1d69e50df1e26958e4d965743192606e7fc53e82d372b3f2f5ef9749dbdf01
BLAKE2b-256 checksum
How to use checksums
cea5d4da5a8e2be647020c5b382cc9e3453b6a5185262c3de3c3ccc08edbc202
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / pra_effect-1.0.0-py3-none-any.whl

Download URL pra_effect-1.0.0-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
846d6de36c5d33a489aa36a2f2b0d82dc4a87c35ec05ab54dc05c83d003e9dba
BLAKE2b-256 checksum
How to use checksums
f110ca577b1137cf1a3e3a479d664e8faf708b58a6482929059082787debc3cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for pra-effect 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pra_effect-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page