Scan and validate code with configurable logic-lock rules.
Project description
logic-lock
==================================================
L O G I C - L O C K
pip install pylogiclock
import logiclock
==================================================
|
Rules, decorator metadata, and code — stay consistent
pip install pylogiclock — import logiclock (PyPI uses pylogiclock; logic-lock is blocked as too similar to an existing name.)
What it does
logic-lock ties authoritative rule definitions (e.g. JSON: conditions + result) to
what you declare on Python functions with @logic_lock (rule id, optional result /
conditions). It can report mismatches (wrong result string, missing conditions) and
includes helpers for matching, reports, and scenario hints — so teams don’t
silently drift between “what the rule says” and “what the code claims.”
Why use it
- One place for rule IDs and expected outcomes; metadata on callables documents intent.
- Catch inconsistencies early (tests or CI) instead of only in code review.
- Small CLI today (
report-sample, version);scan/validatewill grow — the Python API is the main integration point right now.
TL;DR
pip install pylogiclock
logiclock --version
logiclock --no-color report-sample
In your code
from logiclock.decorators import logic_lock
@logic_lock(
"my_rule",
result="ok",
conditions=["user.is_active"],
)
def handle_request(user):
...
More examples: tests/test_rule_validator.py.
Install
| How | Command |
|---|---|
| PyPI | pip install pylogiclock |
| This repo | pip install . |
CLI: logiclock --help
Troubleshooting
| Issue | Try |
|---|---|
No module named logiclock |
pip install pylogiclock or pip install -e . |
| CLI not found | Same venv; python -m pip show pylogiclock |
scan is a stub |
Use the Python API for now |
| Colors in CI | logiclock --no-color ... |
Development
Python 3.11+.
pip install -r requirements-lock.txt
pip install -e . --no-deps
flake8 src tests
pytest tests
Or pip install -e ".[dev]". Refresh lock:
pip-compile --strip-extras --extra dev -o requirements-lock.txt pyproject.toml
CI in this repo
- lint-and-test:
flake8+pytest - logiclock-scan: composite action,
continue-on-error: truefor now
GitHub Actions (yours)
jobs:
logiclock:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: |
pyproject.toml
requirements-lock.txt
- run: |
pip install -r requirements-lock.txt
pip install . --no-deps
- run: logiclock --strict --no-color scan
This repo (uses: ./):
- uses: ./
with:
python-version: "3.12"
install-command: pip install -r requirements-lock.txt && pip install . --no-deps
scan-command: logiclock --strict --no-color scan
Other repos:
install-command: pip install "pylogiclock @ git+https://github.com/YOUR_ORG/logiclock.git@vX.Y.Z"
On PyPI: use pip install pylogiclock in install-command.
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 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 pylogiclock-0.2.0.tar.gz.
File metadata
- Download URL: pylogiclock-0.2.0.tar.gz
- Upload date:
- Size: 27.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c74131657d48656d100b68ece4f4881235cbe8059f5deb97b39ea7b322e36c1f
|
|
| MD5 |
0dd11a7b4223d9c94659a87e970b328e
|
|
| BLAKE2b-256 |
fdb98dbdda6e76d0cf0518ee1e0829da27c0b403385014b9db1adbb540451801
|
File details
Details for the file pylogiclock-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pylogiclock-0.2.0-py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbfad0825bea857ef1f5ca708243c9f9b93e0b45c987e35fd3c72913502777ac
|
|
| MD5 |
9c19c83631df58737000cd22b14c4ebe
|
|
| BLAKE2b-256 |
83d44a55dd08ab00f34b23079ce57cc3722634c5c060e1efabdc8a9199d09687
|