AI Decision System
Replayable, offline-verifiable records for AI-assisted go/no-go decisions: experiment promotions, typed model answers and human-approved actions.
翻譯準備中
已類型化的 Python 設計與分派模式。使用 Pip 安裝,或自行複製並擁有該檔案。
AI 翻譯
Typed Python design and dispatch patterns. Pip one in, or copy one in and own the file.
取自儲存庫 README
正在載入完整 README。 以下為已儲存的摘錄。
A flock of typed, zero-dependency Python design patterns. Each pattern is a single self-contained pato (a duck you adopt), fully typed, standard library only, and small enough to read in one sitting.
Or copy a single duck. Open its docs page, copy the source from the Source section, and paste it into your own project. No dependency, no version pin, no tool, just one module you own.
The optional PostgreSQL toolkit installs SQLAlchemy, pgvector, and inflection only when a
project asks for them.檢視完整 README ↗A flock of typed, zero-dependency Python design patterns. Each pattern is a single self-contained pato (a duck you adopt), fully typed, standard library only, and small enough to read in one sitting.
pip install patos
Or copy a single duck. Open its docs page, copy the source from the Source section, and paste it into your own project. No dependency, no version pin, no tool, just one module you own.
The optional PostgreSQL toolkit installs SQLAlchemy, pgvector, and inflection only when a project asks for them.
pip install "patos[sql]"
from patos import sql
| pato | description | docs |
|---|---|---|
Singleton | one instance per class, __init__ runs once | docs |
FlyweightMeta | a metaclass that interns instances by constructor args, build-once and immutable | docs |
| pato | description | docs |
|---|---|---|
Registry | self-registering class hierarchies via __init_subclass__, with try-each dispatch, select(predicate) and first_available() | docs |
Strategy | a named family of interchangeable implementations, with first_available() | docs |
value_dispatch | dispatch on a value the way singledispatch dispatches on a type | docs |
type_dispatch | dispatch on the first argument's type, the open-type-ladder dual of value_dispatch | docs |
| pato | description | docs |
|---|---|---|
Decorator | a transparent wrapper that forwards everything to the wrapped object but what it overrides | docs |
Pipeline | a reversible stack of stages, applied forward and unwound in reverse around a core op | docs |
Lifecycle | a typed state machine that permits only the transitions its table declares | docs |
DerivedCache | a load-once cache of a derived value keyed by exactly what it depends on | docs |
| pato | description | docs |
|---|---|---|
StrFlag | an enum Flag whose members carry a literal string, OR-combinable and iterable | docs |
| pato | description | docs |
|---|---|---|
SourceRegistration | binds one research node to the exact source set governing a run and seals it | |
statement_bytes | the sealed statement of a node file, front matter and settlement sections excluded | |
sha256_text_file, sha256_text_sources | checkout-independent digests of registered text |
The seal covers the node's statement and the whole bytes of every other registered source. The
statement starts at the first ## heading after the front matter and ends before the first
## Evidence, ## Ledger or ## Log heading, matched without regard to case. Front matter is
never sealed, so status, date and the registration_sha256 field itself move freely, and a
node that settles and appends to its log still verifies against the claim it was registered under.
Every source is hashed as relative POSIX path \0 LF-normalized bytes \0, ordered by path, which
keeps one seal identical on Windows and POSIX checkouts alike.
| namespace | description | docs |
|---|---|---|
sql | typed SQLModel columns, native PostgreSQL enums, pgvector cosine distance, JSONB reads, and set based SQL helpers | docs |
from patos import Singleton
class Settings(Singleton):
def __init__(self) -> None:
self.debug = False
a = Settings()
a.debug = True
b = Settings() # same object, __init__ did not run again
assert a is b and b.debug
Full documentation lives at phvv.me/patos.
pip install -e ".[dev]"ruff check . && ruff format --check .pyrefly checkpytestpip install -e ".[docs]" && mkdocs buildpython -m build