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.13.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.13.0
File Size Uploaded Provenance Actions
forktex-0.13.0.tar.gz 37.4 kB Without provenance Details for forktex-0.13.0.tar.gz

Built distribution (wheel)

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

Total release size: 106.0 kB

Release files / forktex-0.13.0.tar.gz

Download URL forktex-0.13.0.tar.gz
Size 37.4 kB
Tags Source
SHA-256 checksum
How to use checksums
58aa0ac5bea5b74af88f23493d273ac18ae10290df0d83742e5d861fc765df1f
BLAKE2b-256 checksum
How to use checksums
f996029bc9a9d8c63e0cbcfb76f98bc661a6f93fa4427cefb54bf921065af005
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.13.0-py3-none-any.whl

Download URL forktex-0.13.0-py3-none-any.whl
Size 68.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
361c64c74babf1b5f91fefd9153373853c7a31ffa6cd016e494bdcb493df438f
BLAKE2b-256 checksum
How to use checksums
4fe471b507b3b56ecd575df401c6efb7e4c5d09604c7b1ada829b3e321847273
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.13.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