Fault injection and testing core
Project description
Helps you test how your application behaves under realistic network failures without rewriting application code or introducing an in-app proxy layer.
Core value:
- non-intrusive Linux socket interception through
LD_PRELOAD; - Python-first ergonomics (decorators, policy APIs, CLI workflows);
- deterministic and reproducible fault decisions for CI validation;
- broad fault model coverage across connection, transport, DNS, and payload behavior.
Detailed documentation lives in docs/ and is published at:
Package distribution (PyPI):
High-level architecture
Execution model:
- Python decorators/policies write effective configuration to shared memory.
- Linux interceptor hooks socket syscalls (
send,recv,connect,sendto,recvfrom,getaddrinfo). faultcore_networkevaluates a deterministic runtime-stage graph (R0..R8) with operation-specific applicability.- Runtime applies directives (delay, drop, timeout, error, mutate, reorder, duplicate) and then calls original libc functions when needed.
Quick Start
Install from PyPI:
pip install faultcore
Requirements:
- Python 3.10+
- Rust toolchain
- Linux for network interception
Install development dependencies and build native artifacts:
uv sync --group dev
./build.sh
build.sh expects .venv/bin/python to exist, validates version alignment across
pyproject.toml, faultcore_interceptor/Cargo.toml, and faultcore_network/Cargo.toml,
then stages Linux interceptor artifacts into src/faultcore/_native/<platform-tag>/ before building wheels.
Fast validation path:
sh lint.sh
sh build.sh
sh tests.sh
Long stress path (optional):
sh tests_long.sh
CLI-first execution:
uv run faultcore doctor
uv run faultcore run -- python -c "import socket; print('ok')"
uv run faultcore run --run-json artifacts/run.json -- pytest -q
uv run faultcore report --input artifacts/run.json --output artifacts/report.html
uv run faultcore report --input artifacts/run.json --output artifacts/report.latest.html --max-events 200 --reverse-events
Notes:
faultcore rundefaults to strict mode on Linux and exits with code2when interceptor probing fails.- Use
--no-strictonly for debugging environments where preload activation is intentionally unavailable. - With
--run-json, CLI enables record/replay capture mode automatically when mode is unset/off and writes<run-json>.rr.jsonl.gzwhenFAULTCORE_RECORD_REPLAY_PATHis unset. faultcore reportsupports optional event rendering controls:--max-eventsand--reverse-events.
Manual LD_PRELOAD execution is still available for advanced debugging.
Platform behavior:
- Linux:
faultcore runconfiguresLD_PRELOADautomatically and probes interceptor activation in strict mode. - Non-Linux: decorators and policy APIs are still callable, but interceptor-level network effects are not active.
Minimal usage:
import faultcore
@faultcore.timeout(connect="200ms")
def slow_operation():
return "ok"
@faultcore.rate("10mbps")
def network_operation():
return "ok"
What you can test
It supports failure scenarios that commonly cause production-only bugs:
- latency and jitter;
- packet loss and burst loss;
- bandwidth throttling;
- connection and receive timeouts;
- connection error injection;
- DNS delay, timeout, and NXDOMAIN;
- correlated loss (Gilbert-Elliott style state behavior);
- directional profiles (uplink vs downlink);
- packet duplicate and packet reorder;
- session budget limits (bytes, ops, duration);
- payload mutation in stream operations;
- target-aware rules (hostname/SNI/protocol/address/port based scope);
- record/replay for reproducible failure timelines.
These can be combined in one run to validate retries, idempotency, fallbacks, parser robustness, and resilience logic under stress.
Typical CI use cases
- Validate retry/backoff behavior under timeout + packet loss.
- Validate DNS fallback and graceful degradation under resolver faults.
- Validate stream parser robustness under payload mutation and reorder.
- Reproduce flaky integration failures with record/replay evidence.
- Generate run JSON + HTML report artifacts for post-run analysis.
Documentation Index
Primary docs entrypoint:
docs/index.md- Read the Docs: https://faultcore.readthedocs.io/en/latest/
Core documentation paths:
| Document | Scope |
|---|---|
docs/getting_started.md |
Installation, first run, first decorator |
docs/cli_usage.md |
CLI commands (doctor, run, report) and recommended workflows |
docs/api_reference.md |
Feature-by-feature reference (timeout, rate, latency, jitter, loss, DNS, policy APIs) |
docs/examples.md |
Scenario map and recommended testing patterns |
docs/troubleshooting.md |
Symptom-based troubleshooting and quality gate |
Deep-dive references:
| Document | Scope |
|---|---|
docs/architecture.md |
System architecture with runtime-stage graph and module layout |
docs/policies_and_context.md |
Policy lifecycle and application patterns |
docs/interceptor_and_shm.md |
CLI runtime and SHM/interceptor details |
docs/testing_and_examples.md |
Build/test command details and legacy examples |
docs/shm_protocol.md |
SHM binary layout and consistency protocol |
docs/operations_tuning.md |
Baseline/tuning/stress operational guidance |
Build Documentation (Sphinx + MyST)
Generate HTML docs locally:
uv run sphinx-build -M html docs docs/_build
Open generated site entrypoint:
docs/_build/html/index.html
Publish to PyPI
The project includes a release workflow at .github/workflows/publish-pypi.yml that builds:
- Linux
x86_64wheels - Linux
i686wheels - Linux
aarch64wheels - one source distribution (
sdist)
Release options:
- Push a tag like
v2026.3.8to publish directly to PyPI. - Run the workflow manually (
workflow_dispatch) and choose:pypifor production publishtestpypifor dry-run validation
The wheel build uses cibuildwheel and stages architecture-specific native artifacts with
scripts/build_native_artifacts.sh before each wheel build.
Project Status
- Python package metadata:
pyproject.toml - Public API source of truth:
src/faultcore/__init__.py - Decorator behavior source of truth:
src/faultcore/decorator.py - Unit tests:
tests/unit/ - Integration CLI scripts:
tests/integration/
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file faultcore-2026.4.9.tar.gz.
File metadata
- Download URL: faultcore-2026.4.9.tar.gz
- Upload date:
- Size: 50.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6d4dbf6c2be294e22d06bd5c99f06413dec49484a92604eff469b06dd2a12fd
|
|
| MD5 |
cb83dd235002c613847e83bd630fb538
|
|
| BLAKE2b-256 |
0064bd93dc3c045602079a8af32fb2729200e9d5900551dac843587cafbb94cb
|
Provenance
The following attestation bundles were made for faultcore-2026.4.9.tar.gz:
Publisher:
publish-pypi.yml on albertobadia/faultcore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
faultcore-2026.4.9.tar.gz -
Subject digest:
b6d4dbf6c2be294e22d06bd5c99f06413dec49484a92604eff469b06dd2a12fd - Sigstore transparency entry: 1265224887
- Sigstore integration time:
-
Permalink:
albertobadia/faultcore@adef792394f88fb59e06a45419663d809e545b2e -
Branch / Tag:
refs/tags/2026.4.9 - Owner: https://github.com/albertobadia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@adef792394f88fb59e06a45419663d809e545b2e -
Trigger Event:
release
-
Statement type:
File details
Details for the file faultcore-2026.4.9-py3-none-manylinux2014_x86_64.whl.
File metadata
- Download URL: faultcore-2026.4.9-py3-none-manylinux2014_x86_64.whl
- Upload date:
- Size: 478.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbf485d09ba98cf38d922d4e7657ad9d21a3a4b885bd0475d74d4b5071f56c95
|
|
| MD5 |
52e06da2d392b49f620cee2951b0cd05
|
|
| BLAKE2b-256 |
1f489cde06faeda790398deee12444625b1fe57f879c7d6e88178f150cd3859c
|
Provenance
The following attestation bundles were made for faultcore-2026.4.9-py3-none-manylinux2014_x86_64.whl:
Publisher:
publish-pypi.yml on albertobadia/faultcore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
faultcore-2026.4.9-py3-none-manylinux2014_x86_64.whl -
Subject digest:
cbf485d09ba98cf38d922d4e7657ad9d21a3a4b885bd0475d74d4b5071f56c95 - Sigstore transparency entry: 1265225170
- Sigstore integration time:
-
Permalink:
albertobadia/faultcore@adef792394f88fb59e06a45419663d809e545b2e -
Branch / Tag:
refs/tags/2026.4.9 - Owner: https://github.com/albertobadia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@adef792394f88fb59e06a45419663d809e545b2e -
Trigger Event:
release
-
Statement type:
File details
Details for the file faultcore-2026.4.9-py3-none-manylinux2014_i686.whl.
File metadata
- Download URL: faultcore-2026.4.9-py3-none-manylinux2014_i686.whl
- Upload date:
- Size: 516.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6459db894b022173d242dc295be871b5df9cb4276075cfcfa360b15ac4374f60
|
|
| MD5 |
636ff56f56eaed0a44fe9971f584625d
|
|
| BLAKE2b-256 |
567c61b55905e80e0ccad73a17eac9071df525584119e289d05ca90ee75fadf5
|
Provenance
The following attestation bundles were made for faultcore-2026.4.9-py3-none-manylinux2014_i686.whl:
Publisher:
publish-pypi.yml on albertobadia/faultcore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
faultcore-2026.4.9-py3-none-manylinux2014_i686.whl -
Subject digest:
6459db894b022173d242dc295be871b5df9cb4276075cfcfa360b15ac4374f60 - Sigstore transparency entry: 1265225047
- Sigstore integration time:
-
Permalink:
albertobadia/faultcore@adef792394f88fb59e06a45419663d809e545b2e -
Branch / Tag:
refs/tags/2026.4.9 - Owner: https://github.com/albertobadia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@adef792394f88fb59e06a45419663d809e545b2e -
Trigger Event:
release
-
Statement type:
File details
Details for the file faultcore-2026.4.9-py3-none-manylinux2014_aarch64.whl.
File metadata
- Download URL: faultcore-2026.4.9-py3-none-manylinux2014_aarch64.whl
- Upload date:
- Size: 467.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db36244a7dc99ced92c755d7a6617387f0b2ceedc2129ad17212e7341ecb5c40
|
|
| MD5 |
691d8f81f1d473a123e30ab2560923c2
|
|
| BLAKE2b-256 |
08a0a082084753a698a7261717ed7ed467b062206aaf77dcea5c8d1d3b2f862d
|
Provenance
The following attestation bundles were made for faultcore-2026.4.9-py3-none-manylinux2014_aarch64.whl:
Publisher:
publish-pypi.yml on albertobadia/faultcore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
faultcore-2026.4.9-py3-none-manylinux2014_aarch64.whl -
Subject digest:
db36244a7dc99ced92c755d7a6617387f0b2ceedc2129ad17212e7341ecb5c40 - Sigstore transparency entry: 1265225302
- Sigstore integration time:
-
Permalink:
albertobadia/faultcore@adef792394f88fb59e06a45419663d809e545b2e -
Branch / Tag:
refs/tags/2026.4.9 - Owner: https://github.com/albertobadia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@adef792394f88fb59e06a45419663d809e545b2e -
Trigger Event:
release
-
Statement type: