Skip to main content

Tundere Ledger 🧐

A tamper-evident auditing ledger with Tsundere philosophy. "It's not like I'm recording this for you or anything!"

Backed by Rust 🦀 for strictness and performance.

Features

  • 🔒 Tamper-Evident: Uses SHA-256 chaining (Blockchain-like structure).
  • 🚀 High Performance: Core logic runs in native Rust.
  • 🐍 Pythonic: Simple @audit_log decorator for easy integration.

Installation

pip install tundere-ledger

Or build from source:

git clone https://github.com/kuruitinoji-sys/tundere_ledger.git
cd tundere_ledger
pip install .

Usage

Basic Example: The "Tsundere" Decorator

Wrap any function to automatically record inputs, outputs, and errors.

from tundere_ledger import audit_log, verify_log

@audit_log(actor_name="Maid_Chan", importance=2.0)
def delete_database(reason):
    print(f"Deleting DB because: {reason}")
    # If this raises an error, it is also recorded immutably.

# Call the function
delete_database("Master spilled coffee")

# Verify log integrity
if verify_log():
    print("Log is clean.")
else:
    print("Log has been TAMPERED with!")

API Reference

@audit_log(actor_name="Unknown", importance=1.0, log_file="tundere_audit.jsonl")

Decorator that automatically records function calls to an audit log.

Parameters:

  • actor_name (str): Identifier of who performed the action. Default: "Unknown"
  • importance (float): Importance level of the action. Used for weighted audit trails. Default: 1.0
  • log_file (str): Path to the audit log file. Must be within the current directory (path traversal protection). Default: "tundere_audit.jsonl"

Recorded Information:

  • Function name
  • Arguments and keyword arguments (converted to strings)
  • Return value (on success)
  • Exception details (on error)
  • Timestamp (RFC3339 format)
  • SHA-256 chain signature

verify_log(log_path="tundere_audit.jsonl") -> bool

Verifies the integrity of an audit log using SHA-256 chaining.

Parameters:

  • log_path (str): Path to the audit log file to verify. Default: "tundere_audit.jsonl"

Returns:

  • True if the log is intact and unmodified
  • False if the log has been tampered with or is corrupted

get_recorder(log_path="tundere_audit.jsonl") -> TundereRecorder

Returns or creates a recorder instance for the specified log file.

Parameters:

  • log_path (str): Path to the audit log file. Default: "tundere_audit.jsonl"

Returns:

  • A TundereRecorder instance (Rust-backed)

Advanced Usage

Multiple Audit Logs

You can maintain separate audit trails for different components:

from tundere_ledger import audit_log, verify_log

@audit_log(actor_name="system", log_file="payments.jsonl")
def process_payment(amount):
    pass

@audit_log(actor_name="system", log_file="user_access.jsonl")
def access_user_data(user_id):
    pass

# Verify each log independently
if verify_log("payments.jsonl"):
    print("Payment log is clean")

if verify_log("user_access.jsonl"):
    print("Access log is clean")

Custom Recorder Management

from tundere_ledger import get_recorder

# Get or create a recorder
recorder = get_recorder("custom_audit.jsonl")

# Manually record events
recorder.commit_truth("admin", 5.0, '{"action": "user_deleted", "user_id": 42}')

# Verify integrity
if recorder.verify_integrity():
    print("Audit trail is intact")

Security Considerations

  • Path Traversal Protection: All log file paths are validated and must reside within the current working directory.
  • Immutable Chain: Each entry is hashed with the previous hash, making tampering immediately detectable.
  • Actor Identification: Always specify a meaningful actor_name for audit traceability.

License

MIT

Metadata

Release files for tundere-ledger 0.1.1

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

Built distributions (wheels)

Table of built distributions (wheels) for tundere-ledger 0.1.1
File Interpreter ABI Platform
tundere_ledger-0.1.1-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
tundere_ledger-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details
tundere_ledger-0.1.1-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details

Total release size: 829.5 kB

Release files / tundere_ledger-0.1.1-cp38-abi3-win_amd64.whl

Download URL tundere_ledger-0.1.1-cp38-abi3-win_amd64.whl
Size 227.4 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
342e714132ffe41d6be5d4a1de44294073528ca78f002850e4e52cdc504ba5d9
BLAKE2b-256 checksum
How to use checksums
0034d649c25c34ea687b828c0e66e28e99945e00ceac37b812da35fba3476676
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.10.2

Release files / tundere_ledger-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL tundere_ledger-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 322.0 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
56873940ce9789deb2aedbef9ecfb7efcd2af837f455cd1218cd89a3f22954ac
BLAKE2b-256 checksum
How to use checksums
81b2b9c24a58cff86d9ffce3e69bfd74396c4ec76c7950f3f67db369fffe765e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.10.2

Release files / tundere_ledger-0.1.1-cp38-abi3-macosx_11_0_arm64.whl

Download URL tundere_ledger-0.1.1-cp38-abi3-macosx_11_0_arm64.whl
Size 280.1 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a537b22c68d2989835711f65f1a3cd0e310ffd4a43bf60625fe82a97692a8b82
BLAKE2b-256 checksum
How to use checksums
7628bd4b5d2b74271f0e359cb03f72e29e1f1396ef56104a54fae365bd2601f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.10.2

Security for tundere-ledger 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

3 release files No provenance

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