Skip to main content

PyPI Python License

The shared Python substrate for ForkTex services.

One install, no extras: import forktex resolves every module.

pip install forktex

This is not the 0.8.x forktex, which was an agentic CLI — for that, pin forktex==0.8.1. Pre-1.0, minor versions may break; see CHANGELOG.md.

Modules

Primitives

Module What it is
log Structured JSON logging (Loki-ready), trace_id contextvar, setup_logging
error AppError hierarchy, AppErrorCode, ErrorEnvelope, to_envelope
types Base Pydantic models, frozen value objects, camelCase wire shapes
iso Canonical ISO-8601 date/time — every datetime it returns is UTC-aware

Role facades — one per piece of infrastructure:

Module What it is
database Async Postgres/SQLAlchemy: sessions, ORM bases, CRUD, advisory locks, migrations
cache Async Redis: @cached, namespaced keys, invalidation
storage S3/MinIO objects: presigned URLs, bucket lifecycle

Bootstrap — process-level wiring:

Module What it is
api FastAPI app factory: middleware stack, error envelope, health probes

graph, queue, store, vault and vector are set aside in backlog/facades/ until a consumer needs them.

Quick start

from contextlib import asynccontextmanager

from fastapi import Depends, FastAPI
from sqlalchemy.ext.asyncio import AsyncSession

from forktex.database import close_engine, init_engine, yield_transactional_session
from forktex.log import setup_logging

setup_logging(service="my-api")


@asynccontextmanager
async def lifespan(app: FastAPI):
    await init_engine(settings.db_url, pool_pre_ping=True, pool_recycle=1800)
    yield
    await close_engine()


app = FastAPI(lifespan=lifespan)


@app.get("/projects")
async def list_projects(session: AsyncSession = Depends(yield_transactional_session)):
    ...

Transactions

The outermost caller owns the transaction: whoever opens it commits it once, and rolls it back on any exception.

@with_transactional_session
async def place_order(session: AsyncSession, *, reference: str) -> Order:
    return await create(session, Order, reference=reference)


await place_order(reference="A-1")                       # opens a session, commits it

async with transactional_session() as session:
    order = await place_order(session, reference="A-2")   # joins this transaction
    await add_line(session, order=order, sku="X")         # the same one
    raise PaymentFailed                                   # both roll back
transactional_session() async with — the library commits
yield_transactional_session the same unit of work as a generator, for Depends
open_session() no boundary — you commit
savepoint(session) a part allowed to fail without the rest

Inside the first two, commit(), rollback() and begin() raise TransactionBoundaryError. To abort, raise. Full contract in docs/database.md.

init_engine / cache.init / storage.init configure one process-wide default; Database(url), Cache(url) and StorageClient(config) build handles directly, so a process can hold several.

Documentation

One page per module under docs/: wiring, the public surface, the error contract, the gotchas. docs/development.md is the contributor guide.

Development

make install     # poetry install --with dev
make test        # pytest with the coverage floor
make ci          # format-check · lint · license-check · typecheck · audit · test · build · smoke

Integration tests use testcontainers, so Docker must be available.

License

Dual-licensed: AGPL-3.0-or-later, or a commercial license from FORKTEX S.R.L. (info@forktex.com). See LICENSE and NOTICE.

Metadata

Release files for forktex 0.14.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 forktex 0.14.0
File Size Uploaded Provenance Actions
forktex-0.14.0.tar.gz 38.1 kB Without provenance Details for forktex-0.14.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for forktex 0.14.0
File Interpreter ABI Platform Actions
forktex-0.14.0-py3-none-any.whl Python 3 none any Details for forktex-0.14.0-py3-none-any.whl

Total release size: 107.5 kB

Release files / forktex-0.14.0.tar.gz

Download URL forktex-0.14.0.tar.gz
Size 38.1 kB
Tags Source
SHA-256 checksum
How to use checksums
64f8cbfb799df45757cc09e1ef9b382ef8d42c2669adf214556ed2c1cfad021c
BLAKE2b-256 checksum
How to use checksums
997a3124fd23acc3adf155a40b3411f53a0668fa3745f917a892c87a6edc81f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / forktex-0.14.0-py3-none-any.whl

Download URL forktex-0.14.0-py3-none-any.whl
Size 69.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dfe5b078cd77050f2939578e53bc526233a2f9dc57a2dd023d13ea34c2f66b00
BLAKE2b-256 checksum
How to use checksums
79f54b975f4efda27ceee37fb2e993e2102f668da4863134d050200f53a04a72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Security for forktex 0.14.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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