Skip to content

Complete redesign: modern PiProject computation and verification system - #8

Merged
zomop merged 2 commits into
mainfrom
arena/372cb4fc-piproject
Nov 22, 2026
Merged

zomop merged 2 commits into
mainfrom
arena/372cb4fc-piproject

Conversation

@zomop

@zomop zomop commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Summary

Complete redesign and rebuild of PiProject — replacing the legacy single-file
scripts with a modern, modular, high-performance π computation and
independent verification system. Project name remains PiProject.

All work is on feature branch arena/372cb4fc-piproject targeting main.
No commits were made directly to main. Original Git history is preserved.

What was done

Replaced legacy source code

Removed pi_project_v4.py, pi_v3.py, pie.py, and the root-level
verify.py. Replaced with a structured Python package under src/piproject/:

  • compute.py — Chudnovsky + binary splitting computation engine using
    gmpy2 arbitrary-precision integers. Streaming output, guard-digit handling,
    no global gmpy2 state mutation on import.
  • verify.py — Independent verification engine with explicit statuses:
    CALCULATED, STRUCTURE_VALID, PREFIX_VERIFIED, FULLY_VERIFIED,
    INDEPENDENTLY_VERIFIED, VERIFICATION_FAILED. Never reports full
    verification from a prefix check alone.
  • bbp.py — BBP hexadecimal spot checks (algorithmically independent of
    Chudnovsky) for arbitrary-position verification.
  • cli.py — Professional CLI: calculate, verify, benchmark,
    inspect, hash commands with SHA-256 fingerprints and progress reporting.

Tests

77 passing tests covering unit, integration, regression, CLI, and corrupted-
output detection. Tests verify that errors beyond the first 1,000 digits are
detected.

Documentation

  • docs/architecture.md, docs/algorithms.md, docs/verification.md,
    docs/reproducibility.md
  • Updated README with new architecture, badges, verification coverage table,
    and verified SHA-256 fingerprints

CI

  • .github/workflows/ci.yml — runs tests and benchmarks on every push/PR

Benchmarks (best of 3, Linux x86_64, Python 3.11.2, gmpy2 2.3.2)

Digits Time Throughput
1,000 0.1 ms ~8.7M digits/sec
10,000 1.7 ms ~5.7M digits/sec
100,000 34.8 ms ~2.9M digits/sec
1,000,000 627.5 ms ~1.6M digits/sec

Independent verification results

Cross-checked against two independent methods:

  1. Decimal/Machin computation (algorithmically independent) — exact match
    at 1,000, 10,000, and 100,000 digits (SHA-256 verified)
  2. IonicaBizau/pi-decimals reference (GitHub) — exact match at
    1,000,000 digits (SHA-256: 7806ee47…bbf7069)

BBP spot checks at hex positions 1, 10, 100, 120 all match published values.

Blocker: PiProject-Archive backup repository

I attempted to create a private GitHub repository named "PiProject-Archive"
as a permanent mirror of the original repository, but the GitHub integration
returned 403 Resource not accessible by integration (createRepository) —
the integration does not have repository creation permission.

As a fallback, I created a verified local git bundle at
/tmp/PiProject-Archive.bundle containing the complete original history
(5 refs, sha1 algorithm, bundle verified OK). This can be pushed to
PiProject-Archive once the repository is created.

Files changed

24 files changed: 2,327 insertions, 1,605 deletions.
Deleted: 5 legacy files (4 source + 1 test).
Added: 19 new files (source, tests, docs, CI, packaging).

Known limitations

  • No Rust/C++ core: the Rust toolchain is not available in this environment
    and crates.io is not in the allowed outbound hosts, so a Rust/GMP core
    could not be built. The computation engine remains Python + gmpy2.
  • 10,000,000-digit verification: not independently verified in this audit
    (reference host pilookup.com is not accessible from this environment).
    The 1M-digit result IS verified against an external reference.

Requested actions

  1. Create the private "PiProject-Archive" repository and push the bundle
    from /tmp/PiProject-Archive.bundle (or I can do this once permissions
    are available).
  2. Review and approve the redesign before merging to main.
  3. Decide on a LICENSE file (none was added pending owner authorization).

zomop and others added 2 commits November 22, 2026 21:14
Replace legacy single-file scripts with a modular Python package:

- src/piproject/compute.py: Chudnovsky + binary splitting computation engine
  with gmpy2, streaming output, guard-digit handling, no global state mutation
- src/piproject/verify.py: Independent verification engine with explicit
  statuses (CALCULATED, STRUCTURE_VALID, PREFIX_VERIFIED, FULLY_VERIFIED,
  INDEPENDENTLY_VERIFIED, VERIFICATION_FAILED). Never reports full
  verification from a prefix check alone.
- src/piproject/bbp.py: BBP hexadecimal spot checks (algorithmically
  independent of Chudnovsky) for arbitrary-position verification
- src/piproject/cli.py: Professional CLI with calculate/verify/benchmark/
  inspect/hash commands, SHA-256 fingerprints, progress reporting
- tests/: 77 passing unit, integration, and CLI tests
- docs/: architecture, algorithms, verification, reproducibility
- .github/workflows/ci.yml: CI pipeline with tests and benchmarks
- pyproject.toml: package configuration with piproject console script
- Removed legacy: pi_project_v4.py, pi_v3.py, pie.py, root verify.py
- Updated README with new architecture, badges, verification coverage table

Benchmark results (best of 3):
- 1,000 digits: 0.1 ms (~8.7M digits/sec)
- 10,000 digits: 1.7 ms (~5.7M digits/sec)
- 100,000 digits: 34.8 ms (~2.9M digits/sec)
- 1,000,000 digits: 627.5 ms (~1.6M digits/sec)

Independently verified against decimal/Machin computation (1K-100K digits)
and IonicaBizau/pi-decimals reference (1M digits) with matching SHA-256.

NOTE: Could not create the private GitHub 'PiProject-Archive' backup
repository due to integration permission limitations (403 on
createRepository). A local mirror bundle was created at
/tmp/PiProject-Archive.bundle and verified intact.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
- CI: Replace tautological self-verification with committed reference
  fixture (tests/fixtures/pi_1000_reference.txt) verified by SHA-256
  before use. CI fails if the fixture hash does not match.
- BBP: Add decimal-to-hex conversion (decimal_to_hex_at) and
  bbp_vs_decimal() to validate the real relationship between calculated
  decimal output and independent BBP computation at the same positions.
  BBP is now reported as two checks: pure BBP vs published reference,
  and BBP vs decimal-to-hex of the calculated output.
- Verification status semantics: is_fully_verified() returns True ONLY
  for FULLY_VERIFIED. INDEPENDENTLY_VERIFIED (BBP spot checks) confirms
  the algorithm at sampled positions only and is NOT full verification.
  BBP never changes the main verification status.
- Corruption detection tests: corrupted digits near beginning, around
  position 1,001, near end; missing digits; extra digits; truncated
  files; invalid characters; whitespace; incorrect decimal point;
  incorrect precision metadata.
- compute.py: Rename calculate_pi_streaming -> calculate_pi_to_file with
  accurate documentation (compute in memory, write in chunks; not true
  streaming during computation since Chudnovsky/binary splitting
  produces a single result). Keep old name as deprecated alias.
- Benchmarks: 1M digits in 640ms, 10M digits in 11.5s at 149 MB peak RSS.
  First 1M digits of 10M result verified against IonicaBizau reference.

89 tests passing.
Rust investigation: Rust toolchain cannot be installed (SSL blocked for
sh.rustup.rs and static.rust-lang.org; apt network blocked; no dev
headers). Python + GMPY2 is the only viable option (evidence-based).
GMP/MPFR dev headers missing and cannot be installed.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@zomop
zomop merged commit a26d8f5 into main Nov 22, 2026
1 check passed
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.

1 participant