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.4.0.tar.gz (34.0 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.4.0-py3-none-any.whl (47.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for logicfp-3.4.0.tar.gz
Algorithm Hash digest
SHA256 6b187e3689477545bbce04181bd50ac122e6c956b774a12b0624b967af04257f
MD5 af3bf26dde6e988306681e22054e796b
BLAKE2b-256 5e565c0e39917b7b2f3f61318a11f2f61b440fb1fe975dd773a3dce2f5732779

See more details on using hashes here.

File details

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

File metadata

  • Download URL: logicfp-3.4.0-py3-none-any.whl
  • Upload date:
  • Size: 47.8 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70aa1b964315910b9e8e2db501a1d16d58b3c9887c7e344f33a8e69fa1efa79e
MD5 68a5cd5ed5a3f89d37824df4a0198a65
BLAKE2b-256 c386338c2631a3fc3b5cb7a7cf35c3e55cddd5119ab8984944335d55aa37d329

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