Skip to main content

SPOC

title-image

License: MIT Language GitHub PyPI Downloads

SPOC is a registry-first runtime kernel for modular monolithic Python applications. It sits below your HTTP framework — FastAPI, Robyn, anything — managing internal resources and application objects, and registering every declared object in one flat registry under a canonical identifier:

kind:namespace.object_name        e.g.  models:blog.post

Surfaces are built on top by enumerating the registry. The kernel describes; it never executes.

Features

  • App discovery — Django-style apps declared by dotted module path and imported through the normal import system; the kernel never touches sys.path and never writes to disk
  • Dependency-ordered loading — modules initialize in topological order, tear down in reverse; sync and async lifecycles (start/astart), with coroutine hooks awaited and refused loudly by the sync path
  • Declarable modes — the developmentstagingproduction cascade is the default, and [spoc.modes] extends it (test = ["test", "production"]) without restating the triple
  • One flat registry — typed records with kind / namespace / name facets; grouped views are derived, never stored
  • Conventional identity — PEP 8 class names derive their snake_case identifier automatically; stated names are verbatim and validated against ^[a-z][a-z0-9_]*$, lookups are always exact, and re-registering an object under a different identity raises instead of substituting
  • A stated concurrency contract — registration is atomic, transitions are serialized with one winner, post-boot reads need no coordination
  • Precise resolution — failures name the failing segment and the valid candidates; a typo never falls through to None
  • Zero runtime dependenciesdependencies = [] is an invariant
  • A shipped test harnessspoc.testing gives every project an isolated framework scope, a declarative app-tree builder, and a mode override; with pytest installed the same pieces arrive as fixtures automatically, and the kernel never imports any of it
  • Pre-runtime diagnosticsspoc check dry-boots the project and reports config problems, unresolvable apps, cycles, collisions, and sync/async lifecycle mismatches before they reach runtime; spoc list and spoc explain read the registry from the command line

Structured-data loading ships in the box as the contained subpackage spoc.formats (from spoc import formats) — the kernel never imports it, importing spoc never loads it, and its optional codecs live behind extras (pip install "spoc[full]").

Installation

Requires Python 3.12+

pip install spoc

Scaffolding a project needs no install at all — spoc init ships as a console script, and SPOC has no dependencies to resolve:

uvx spoc init myproject      # generate; installs nothing

The generated project imports spoc at runtime, so install it in the environment you run the project from. Full detail in the installation guide.

Quick Start

from pathlib import Path
import spoc

framework = spoc.Framework("models")       # the closed kind set, declared once
model = framework.kind("models")           # a ready-made decorator

@model
class Post:                                # apps/blog/models.py → models:blog.post
    ...

framework.start(Path(__file__).parent)     # construction is inert; start boots
# async surfaces: await framework.astart(...) awaits coroutine hooks

record = framework.resolve("models:blog.post")
print(record.identifier, record.object)

# Project a surface — routes from registry records, nothing else:
routes = [
    (f"/{c.namespace}/{c.object_name}", c.object)
    for c in framework.registry.by_kind("models")
]

Documentation

For detailed documentation, tutorials, and examples:

Read the Docs

Stability

SPOC is pre-1.0. Every name, command, and extra carries one of three tiers — public, provisional, or internal. For an importable name the tier follows from how it is exposed: exported from a package is public, saying so in its own docstring makes it provisional, and reachable only through a submodule is internal. Both the tiers and every change to them since the last release are checked on every CI run. Until 1.0 a public element may still change in a minor release, so pin a minor if that matters: spoc>=0.5,<0.6.

Stability & Versioning — the tiers, what they exclude, the deprecation lifecycle, and what has to be true before 1.0 is cut.

Links

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spoc-0.7.0.tar.gz (161.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spoc-0.7.0-py3-none-any.whl (104.5 kB view details)

Uploaded Python 3

File details

Details for the file spoc-0.7.0.tar.gz.

File metadata

  • Download URL: spoc-0.7.0.tar.gz
  • Upload date:
  • Size: 161.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for spoc-0.7.0.tar.gz
Algorithm Hash digest
SHA256 b06ff3d4ddfac23a8882831223fd062de8d6c8884bac61be8c89dcae33b30797
MD5 5f3deb043d98f5384f56d7d8805b5e3f
BLAKE2b-256 ff52f00c891097fec784886512bbfad8ff883079d5251edf147cec62a15a3639

See more details on using hashes here.

File details

Details for the file spoc-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: spoc-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 104.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for spoc-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afe97cc2ad1c383364fc41ac0bf1ee313ccd8455f40596a33dd0b19170867cb6
MD5 e39e2003043885324769a6db2b164662
BLAKE2b-256 20abd7040022643fbc548155250b5e1da4da41ad8ba482c1be9a086a08058f2c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.9.0

2 files

0.8.0

2 files

This release

0.7.0 This release

2 files

0.6.0

2 files

0.5.0

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.3

2 files

0.2.2

2 files

0.1.35

2 files

0.1.34

2 files

0.1.33

2 files

0.1.32

2 files

0.1.31

2 files

0.1.21

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 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