logicfp user-mode protection library
Project description
Logic Fingerprint (logicfp)
logicfp is an AI-era call protection layer.
Developer documentation lives in README.developer.md.
Install
pip install logicfp
Quick Start
from logicfp import protect
@protect()
def call_model(request):
return {"answer": request.payload["text"].upper()}
result = call_model(payload={"text": "hello"})
Use @protect() when you want the default entrypoint.
Use create_protector() when you need more than one protector instance.
Use logicfp.user_mode when you want explicit user-mode types like ErrorCode, NormalizationError, LogicExecutionError, and ProtectRuntimeError.
User Mode Contract
The current public contract centers on:
protectcreate_protectorlogicfp.user_mode.ErrorCodelogicfp.user_mode.NormalizationErrorlogicfp.user_mode.LogicExecutionErrorlogicfp.user_mode.ProtectRuntimeErrorlogicfp.config.describe_effective_config
logicfp now recommends user mode as the only public entry model.
Minimal Config
Put your project config at:
your_project/config/config.yaml
logicfp:
instance_id: decorator-node
default_source: user_function
backend_type: memory
Use logicfp: as the main YAML section name. Older logic_fingerprint: configs are still accepted for compatibility.
For user mode, backend_type: memory is still the recommended default.
Failure Styles
logicfp supports two user-mode failure styles:
simple=Truesuccess returns your result directly, failure raisesProtectRuntimeErrorsimple=Falsesuccess returnsok/result/context, failure returnsok/error/context
Example:
from logicfp import protect
@protect(simple=False)
def review_text(request):
return {"summary": request.payload["text"][:20]}
Learn More
- User-mode cheatsheet: documents/Tutorial/user-mode-cheatsheet.md
- Quick user-mode guide: documents/Tutorial/user-mode-quickstart.md
- User-mode examples: documents/Tutorial/user-mode-examples.md
- User-mode error codes: documents/Tutorial/user-mode-error-codes.md
- User-mode envelope contract: documents/Tutorial/user-mode-envelope.md
- User mode vs engineering mode: documents/Tutorial/user-mode-vs-engineering.md
- Config reference: documents/Tutorial/config-reference.md
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 logicfp-3.4.10.tar.gz.
File metadata
- Download URL: logicfp-3.4.10.tar.gz
- Upload date:
- Size: 40.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faab5a9c9e852427aefd2fab3e4deb374e4be4ca681409fc5cb0b7bff3331c13
|
|
| MD5 |
45b04e93b126a912b668ee53491f1a95
|
|
| BLAKE2b-256 |
eae3e6480b1e407c7e490996e07b2b39135153480bac46995c2a5fcd85842989
|
Provenance
The following attestation bundles were made for logicfp-3.4.10.tar.gz:
Publisher:
publish.yml on dymzz/logic_fingerprint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logicfp-3.4.10.tar.gz -
Subject digest:
faab5a9c9e852427aefd2fab3e4deb374e4be4ca681409fc5cb0b7bff3331c13 - Sigstore transparency entry: 1205067077
- Sigstore integration time:
-
Permalink:
dymzz/logic_fingerprint@058efbd7c253e0687d59a254ee44983ed64f3ed7 -
Branch / Tag:
refs/tags/v3.4.10 - Owner: https://github.com/dymzz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@058efbd7c253e0687d59a254ee44983ed64f3ed7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file logicfp-3.4.10-py3-none-any.whl.
File metadata
- Download URL: logicfp-3.4.10-py3-none-any.whl
- Upload date:
- Size: 59.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de51bf8c5f48ae0b9f1389a1bd63fd7dea9ef5f34228d86374f289e76a987d61
|
|
| MD5 |
8de570e0c4c2775af6da6d8fd8a4f808
|
|
| BLAKE2b-256 |
438792dbed4de5d5a6b601af8e7708c1dd64da1afe1ff7b88671e787b5571642
|
Provenance
The following attestation bundles were made for logicfp-3.4.10-py3-none-any.whl:
Publisher:
publish.yml on dymzz/logic_fingerprint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logicfp-3.4.10-py3-none-any.whl -
Subject digest:
de51bf8c5f48ae0b9f1389a1bd63fd7dea9ef5f34228d86374f289e76a987d61 - Sigstore transparency entry: 1205067134
- Sigstore integration time:
-
Permalink:
dymzz/logic_fingerprint@058efbd7c253e0687d59a254ee44983ed64f3ed7 -
Branch / Tag:
refs/tags/v3.4.10 - Owner: https://github.com/dymzz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@058efbd7c253e0687d59a254ee44983ed64f3ed7 -
Trigger Event:
push
-
Statement type: