Skip to main content

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:

  • protect
  • create_protector
  • logicfp.user_mode.ErrorCode
  • logicfp.user_mode.NormalizationError
  • logicfp.user_mode.LogicExecutionError
  • logicfp.user_mode.ProtectRuntimeError
  • logicfp.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=True success returns your result directly, failure raises ProtectRuntimeError
  • simple=False success returns ok/result/context, failure returns ok/error/context

Example:

from logicfp import protect


@protect(simple=False)
def review_text(request):
    return {"summary": request.payload["text"][:20]}

Learn More

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

logicfp-3.3.0.tar.gz (32.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logicfp-3.3.0-py3-none-any.whl (45.1 kB view details)

Uploaded Python 3

File details

Details for the file logicfp-3.3.0.tar.gz.

File metadata

  • Download URL: logicfp-3.3.0.tar.gz
  • Upload date:
  • Size: 32.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for logicfp-3.3.0.tar.gz
Algorithm Hash digest
SHA256 540a2c11d2ffb551df9ddb6a9d2932d042ffefe3ab712c06e2dd715bb2ece094
MD5 d6373efbed63e90bd1ce0369cf1a6472
BLAKE2b-256 f08eee2f9ce6cf14d073ff642b9f2bd3491856dd4122c24a971cf5f05fac336a

See more details on using hashes here.

File details

Details for the file logicfp-3.3.0-py3-none-any.whl.

File metadata

  • Download URL: logicfp-3.3.0-py3-none-any.whl
  • Upload date:
  • Size: 45.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for logicfp-3.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2dbf75fc699ce181817b2ec09eec6cab7d94354245e331e21d19a101ae202e5f
MD5 881892f2557b797e01d7a060a47baeb7
BLAKE2b-256 b4ee7ce1d9665da992814267c4d822214fdef477b1fcae6eb4f200aaedce0da4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page