Skip to content

About

Typed, dependency-light Python libraries, one package per concern, each versioned and released on its own.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

groundwork

CI License: MIT Python 3.12 | 3.13 | 3.14

Small, typed Python libraries for building data services: shared contracts, a service platform, ports for market data and content sources, and statistics for evaluating models honestly. Each package does one job, keeps its required dependencies short, and is versioned and released on its own, so a fix to one package moves only the projects that pin it.

Packages

Package Purpose Version Python Builds on
primitives-kit Shared contracts with no behaviour of their own: a rate-budget protocol, its error tree, a vendor quota reading. 0.1.0 3.12+ none
pack-contracts What a plugin pack is written against: a manifest read without importing the pack, pluggy hookspecs, a ledger that enforces the versioning rule. 0.2.1 3.12+ none
platform-kit A service platform: typed config, one notification path, a watchdog plane, a strict plugin loader, a FastAPI composition root, a Postgres rate budget, ingest lanes with a freshness verdict, a daemon run-loop kit, a job-engine port with a Windmill adapter, OpenTelemetry tracing with a per-trace span budget, a counted outbound HTTP client and a guarded fetch of an untrusted image URL, gauge and counter readings for a store many processes write (its statements over a caller's sync or async executor, the per-process publisher and the text exposition), an ntfy push transport with its spool file contract, an identity and permission model with route-declared policy, a shadow-to-enforce readiness check and user administration, and the async daemon loops (a cadence loop, a wake-coalescing loop, reconnecting LISTEN and NATS wake wires, a thread-backed side publisher that never blocks its sync caller and counts every dropped copy, a compute-once shared producer cache), an event-loop lag sampler that names what held the loop, a Postgres job queue with a claim gate, an off-loop heartbeat, a stall reaper and a step journal, a migration ledger held to account (sha256 per applied file, a transactional rollback, live catalog vs replay fingerprint, background policies declared vs running), pgmq message operations with every queue's health from pgmq's own metrics, a column watch (a value column that has never been non-NULL is a producer nobody wrote), and the runtime side of typed config (an append-only override ledger with its attribution watch, the live value-and-source view, and a config fingerprint stamped on graded rows with the watch for an unstamped one). 0.31.0 3.11+ primitives-kit (sql), pack-contracts (packs)
market-ports Typed market-data ports: frozen rows, capability-mapped providers, fallback chains that report which tier answered, retries and rate budgets, public-vendor adapters, and stdlib bar analytics (forward outcome labels, a read's kill rule, VWAP and its sigma) and calendar flags. 0.21.0 3.12+ primitives-kit
content-data A content-source registry declared as data and validated against built-in and pack-contributed kinds, with a versioned content contract, prompt-pack pins and a conformance kit. 1.1.0 3.12+ platform-kit, pack-contracts (through platform-kit's packs)
honesty-stats Statistics that keep an evaluation honest: deflated Sharpe ratios, the probability of overfitting, purged cross-validation, conformal intervals, proper forecast scores, false-discovery control, effective counts under dependence, SPA, StepM and the Model Confidence Set, sequential tests, two-proportion lifts, group separation, hit rates over a luck baseline, an alpha-investing error budget and fixed verdict ladders. 0.5.0 3.12+ none
learn-kit The fit side of evaluation: a gate, a run ledger and a loop runner for learning loops, earned weights, lifecycle rules (health, retirement, rotation), a test fingerprint, a discrete-time hazard, hierarchical shrinkage, probability calibrators, forecast combiners, and the ledger and registry on MLflow. 0.4.1 3.12+ honesty-stats
mcp-catalog One declarative catalog for the MCP servers and tools a Claude session loads: a JSON schema, a renderer to each client's config (Claude Code, Claude Desktop, an agentgateway profile), checks holding charters, hooks, live configs and a gateway to the catalog, a shrink-only baseline, a usage meter and a ToolSearch hit-rate meter. 0.3.0 3.12+ none

Version is the version on base. A version is released when its tag is pushed; the released versions are on the Releases page. Builds on lists the packages from this repository that a package depends on, with the extra that brings each in where it is optional. Each package's README covers its modules, extras and third-party dependencies.

Installation

The packages are not published to PyPI. Install one from its release tag and its subdirectory of this repository:

pip install "honesty-stats @ git+https://github.com/mjdevaccount/groundwork@honesty-stats-v0.5.0#subdirectory=packages/honesty-stats"

With uv, in pyproject.toml:

[project]
dependencies = ["honesty-stats"]

[tool.uv.sources]
honesty-stats = { git = "https://github.com/mjdevaccount/groundwork", tag = "honesty-stats-v0.5.0", subdirectory = "packages/honesty-stats" }

Extras go after the name as usual: platform-kit[service,sql] @ git+....

Quickstart

from honesty_stats import basic, multitest

# 18 hits in 30 trials looks like a 60% hit rate. The 95% Wilson interval still includes 50%.
basic.wilson(18, 30)
# (0.4232005249827382, 0.7540960567391661)

# Five hypotheses tested at once: which survive false-discovery control at 5%?
# The default is Benjamini-Yekutieli, valid under any dependence between the tests.
multitest.bh_fdr([0.001, 0.008, 0.039, 0.041, 0.27], alpha=0.05)
# [True, True, False, False, False]

# A flat series has no Sharpe ratio. Unknown is None, never 0.
basic.sharpe([0.01, 0.01, 0.01])
# None

Each package README opens with an example of its own.

Design principles

  • One package per concern. Each package has its own pyproject.toml, CHANGELOG.md and release tag. Depending on one package pulls in only the packages listed under Builds on.
  • Imports point down. The layering between packages is a set of import-linter contracts in the root pyproject.toml, checked in CI. primitives-kit and honesty-stats import no other package from this repository, so anything can depend on them without a cycle.
  • Small cores, optional extras. Heavier integrations (SQLAlchemy, FastAPI, dlt, scikit-learn, Optuna and others) sit behind extras, and tests fail if importing a package's core loads an extra's library.
  • Typed. Every package ships py.typed. CI runs mypy --strict and pyright --verifytypes on every package's public surface.
  • Extensible through ports, one plugin engine. Code from another distribution arrives as a pack, loaded by platform-kit's plugins/packs (pluggy); a library takes its contributions as built-ins its host hands over (market-ports' provider roster). A plugin that fails to load raises; it is never skipped silently.
  • Unknown is None, never 0. Datetimes carry a timezone. Value types are frozen.
  • No consumer knowledge. No package names an application, host, schema or environment variable of the code that uses it; configuration is passed in. tests/test_no_consumer_knowledge.py scans every package for it.

Versioning

Each package follows Semantic Versioning and keeps a changelog in the Keep a Changelog format. Every package is pre-1.0, so a minor release may change the public API; read the package's CHANGELOG.md before moving a pin.

A release is the tag <package>-vX.Y.Z, for example platform-kit-v0.5.2. Pushing it runs release.yml: the full CI gate runs again, the tag is checked against the package's version, and that package's sdist and wheel are attested (SLSA build provenance, signed through Sigstore) and attached to an immutable GitHub release. Check a downloaded file with gh attestation verify <file> --repo mjdevaccount/groundwork --signer-workflow mjdevaccount/groundwork/.github/workflows/release.yml; a file whose bytes changed fails it. A package that depends on another from this repository names it by a direct reference to that package's release tag, so a published wheel never asks an index for a sibling.

Using a package

Pin the package's release tag and its subdirectory, as in Installation.

Consuming several packages

uv builds a package from this repository as a member of its workspace, so it resolves that package's siblings from the same commit, whatever tag their direct references name, and refuses any other source for a workspace member. Pinning platform-kit at platform-kit-v0.5.2 and pack-contracts at pack-contracts-v0.2.1 therefore names two URLs for one package, and uv fails with "conflicting URLs".

Pin every package you name directly at one tag: the release tag of the package that names the others. That tag holds the sibling code its release was checked against.

[tool.uv.sources]
platform-kit = { git = "https://github.com/mjdevaccount/groundwork", tag = "platform-kit-v0.5.2", subdirectory = "packages/platform-kit" }
pack-contracts = { git = "https://github.com/mjdevaccount/groundwork", tag = "platform-kit-v0.5.2", subdirectory = "packages/pack-contracts" }

A tag of a package that names none of the others (say pack-contracts-v0.2.1) can hold an older platform-kit, and an untagged commit can hold unreleased code. If you need a sibling newer than the one a package names, there is no consistent set until that package is released naming it. A dependency of yours that names a sibling at its own tag, such as a pack built against pack-contracts-v0.1.0, is the same conflict: resolve it once with [tool.uv] override-dependencies.

pip installs the tag each direct reference names, and uv installs the member's commit. Both give the same code because every release is checked: at each <package>-vX.Y.Z tag, every sibling the package names, and every sibling those tags name in turn, must have the same src/ and pyproject.toml as at its named tag (tests/test_internal_deps.py). The check runs on every pull request, with HEAD standing in for a package whose new version has no tag yet, and again in the release workflow before it builds.

Compatibility

  • Python: 3.12, 3.13 and 3.14, each tested in CI. platform-kit also supports 3.11, tested in CI, except its sql and packs extras, which bring in packages that require 3.12.
  • Dependencies: every package is also tested at the lowest versions its pyproject.toml allows (uv pip install --resolution lowest-direct), so a declared lower bound is one that works.
  • Platforms: pure Python, no compiled extensions. CI runs on Linux.

Development

The repository is a uv workspace: one lockfile and one toolchain for every package.

uv sync --all-groups

# tests (the Postgres-backed tests start a postgres:18 testcontainer, or skip without Docker)
uv run pytest -q

# lint
uv run ruff check .
uv run ruff format --check .
uv run lint-imports
uv run vulture
uv run actionlint
uv run zizmor .

# types: mypy, then pyright for each package's public surface
uv run mypy
uv run pyright --verifytypes platform_kit --ignoreexternal

# build every package and check its metadata
uv build --all-packages --no-sources
uv run twine check --strict dist/*

.github/workflows/ci.yml runs all of the above, plus the lowest-bounds matrix, the 3.11 leg, secret scanning, a duplicate-code check and a documentation-reference check. Its test job is the one required check and passes only when every other job does.

The tests for platform-kit's SQL stores and rate budget use a real Postgres. Set PLATFORM_KIT_TEST_PG=postgresql://user:pw@host:port/db to use your own database; with it unset, a throwaway postgres:18 container is started. In CI those tests cannot skip (PLATFORM_KIT_TEST_PG_REQUIRED=1).

uv run pytest -q --cov reports coverage. The floor in the root pyproject.toml (fail_under) is only ever raised. It holds every package except market-ports, content-data and learn-kit, which CI holds to floors of their own until they reach it, so a whole-workspace run locally reports below it.

Contributing

Open a pull request against base. Pull requests are squash-merged once CI passes. To release a package: bump its version and its row in the table above, move the Unreleased section of its CHANGELOG.md under the new version, merge, then push the tag <package>-vX.Y.Z.

License

MIT.

About

Typed, dependency-light Python libraries, one package per concern, each versioned and released on its own.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages