Skip to main content

rule-engine-core

Shared domain library for the rule-engine platform, published to PyPI as rule-engine-core. The three FastAPI services (metadata_service, position_server, platform_service, rule_engine) all depend on it.

What's in it

  • Expression parser (parser.py) — recursive-descent parser turning an infix rule/filter expression into a Node tree (! & |, comparisons, arithmetic, parentheses; AND/OR/NOT are accepted as aliases).
  • EntitiesRule and Filter (both extend EntityBase) with validate() and evaluate() over metadata fields and nested entities.
  • MetadataStore — loads column metadata from a JSON file or over HTTP.
  • Postgres DAOsEntityDao (rules/filters, persisted as pickled objects) and MetadataDao (the metadata table).
  • DbPool — thread-safe psycopg2 connection pool; one connection per unit of work via with pool.acquire() as conn:.
  • tracing — lightweight X-Trace-Id propagation (contextvars + log stamping
    • thread/pool helpers) shared across services.
  • identityCurrentUser, header parsing, require_admin, and the app_user/user_account_access lookup; framework-neutral identity primitives shared across services.

Install

pip install rule-engine-core

Build & publish (manual)

setup.py reads its dependencies from $BUILD_PATH/requirements.txt, so BUILD_PATH must be set.

python -m pip install --upgrade setuptools wheel twine
cd rule-engine-core
BUILD_PATH="$(pwd)" python setup.py sdist bdist_wheel
twine upload dist/*

Releases are normally cut automatically — see .github/workflows/publish.yml, which publishes to PyPI (then builds the service images) after CI passes on main.

Release order for consumer services

Every service installs this package from PyPI, so a change here is invisible to them until it's published. When a service needs new core API:

  1. Bump version in setup.py.
  2. Build and twine upload.
  3. Then bump the rule-engine-core>=<version> floor in that service's requirements.txt and pyproject.toml.

Until step 2 lands, a service PR carrying a raised floor fails at pip install and its CI goes red. That's the point — it's the reminder to publish, and it beats an ImportError in prod. So publish before merging the consumer.

Note on the pickle serialization contract

Rules and filters are stored in Postgres as pickled Python objects, and entity_dao.py installs sys.modules aliases so older pickles still load. Renaming/moving core modules or changing EntityBase's pickled fields can break unpickling of already-stored entities — treat these as a compatibility contract.

Docker

-> psql --username=$POSTGRES_USER -d $POSTGRES_DB

Release files for rule-engine-core 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rule-engine-core 0.2.0
File Size Uploaded
rule_engine_core-0.2.0.tar.gz 28.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rule-engine-core 0.2.0
File Interpreter ABI Platform
rule_engine_core-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.7 kB

Release files / rule_engine_core-0.2.0.tar.gz

Download URL rule_engine_core-0.2.0.tar.gz
Size 28.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f50521737b159d73f19e4822b3ee4ce9b2b5448312ef30925b7d90114f1558ad
BLAKE2b-256 checksum
How to use checksums
4a373568b1c6a543a1cc58562c59de8ab1f2835b7ed443fc0e002ed92173d789
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / rule_engine_core-0.2.0-py3-none-any.whl

Download URL rule_engine_core-0.2.0-py3-none-any.whl
Size 24.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0a43b4cdd6e9a4de75d69c319688091409456584b40ce5232f7f9baf399fac0
BLAKE2b-256 checksum
How to use checksums
443a1f3580f265892db5d85f52d15df3ff6ed0ef62f12b0b81e97fb8aaac67bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release history Release notifications | RSS feed

0.2.1

2 release files

This release

0.2.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page