Shared foundation for the Argus suite: taxonomy, versioned wire-schema tooling, and the local/remote AI backend contract
Project description
argus-cortex
Shared foundation for the Argus suite: taxonomy, versioned wire-schema tooling, and the local/remote AI backend contract.
Part of the Argus suite (quarry → curator → lens → forge → proof). This is the library the stages import so the code they share — the target taxonomy, the wire-schema versioning discipline, and the way they call local or hosted models — lives in one place instead of being copy-pasted per repo.
What's here
argus_cortex.taxonomy—TargetProfile/TargetStyle/TargetCategory, the "moat" types every stage inherits verbatim.argus_cortex.wire— the versioned wire-schema toolkit:check_version()(major-compatibility gate),make_versioned_base()(a Pydantic base that stamps + checks a version field likeproof_version/manifest_version), andwire_schema()/render_schema()for the committed-schemaschema --checkCLI pattern.argus_cortex.backends— the AI-backend contract generalised from argus-lens:Backend/LocalBackend/RemoteBackend(point at a hosted service bybase_url,host/port, or a knownRemoteProvider), pluswith_retries()andresolve_device(). httpx lives behind the[remote]extra.argus_cortex.server— shared write-guard + env-flag scaffolding for the suite's FastAPI micro-servers:WriteGuard(a pure-ASGI method-gate that never buffers streaming responses), theconstant_refuse()/cross_site_refuse()predicates (read-only/replay mode and cross-site-write protection are two configs of the one guard), theUNSAFE_METHODS/TRUTHY/FALSYconstants, andenv_flag()(warns on a mistyped protection flag rather than silently disabling it). Starlette lives behind the[server]extra.argus_cortex.store— the optional stateful services layer (the suite's persistent "memory"). External and opt-in — every store is configured byCORTEX_*env vars and no-ops when its URL is unset.- Phase 1 — Postgres lineage store. Persists the
source_asset → caption → human_edit → dataset_membership → training_runDAG for LoRA reproducibility, edit capture, and the feedback loop. Backed by a psycopg connection pool (concurrentasyncio.to_threadcalls are safe; a dropped connection is replaced), with atransaction()boundary for atomic multi-step writes.open_lineage_store()returns a no-op store whenCORTEX_PG_URLis unset; psycopg lives behind the[postgres]extra. - Phase 2 — Qdrant vector store. Stores image + tag-set embeddings for retrieval-augmented few-shot and near-duplicate curation; put a
caption_id/asset_idin a point's payload and a search hit joins straight back to the lineage.open_vector_store()no-ops whenCORTEX_QDRANT_URLis unset; qdrant-client lives behind the[qdrant]extra. cortex stores vectors it's handed — computing embeddings is the caller's job. - Phase 3 — MinIO/S3 blob store. Owns image bytes when cortex can't rely on the filesystem/Immich (exported/selected training images). Blobs are content-addressed on sha256 (
content_key()==source_asset.sha256), so storage, dedup, and lineage join share one identity.open_blob_store()no-ops whenCORTEX_S3_ENDPOINT/CORTEX_S3_BUCKETare unset; theminioclient lives behind the[s3]extra.
- Phase 1 — Postgres lineage store. Persists the
from argus_cortex.wire import make_versioned_base, render_schema
from argus_cortex.backends import RemoteBackend, RemoteProvider
# per-package versioned base (readable field name kept local, logic shared)
_Versioned = make_versioned_base("proof_version", "1.0", ("1",))
# reach a hosted scorer by IP/port, or a known provider
scorer = RemoteBackend.from_host("192.168.1.20", 9000, api_key="…")
nim = RemoteBackend.from_provider(RemoteProvider.NVIDIA_NIM, api_key="…")
from argus_cortex.store import open_lineage_store, SourceAsset, Caption, HumanEdit
# no-op if CORTEX_PG_URL is unset; PostgresLineageStore if it's set
store = open_lineage_store() # reads CORTEX_* from the environment
store.ensure_schema() # idempotent bootstrap of the lineage tables
# one atomic unit — the asset + caption + edit commit together or not at all
with store.transaction():
asset_id = store.record_asset(SourceAsset(uri="immich://…", sha256="…"))
# lens emits a CaptionResult; cortex ingests it (cortex never imports lens)
cap_id = store.record_caption(asset_id, Caption.from_caption_result(result, profile={...}))
store.record_edit(cap_id, HumanEdit(edited_caption="…", editor="alice"))
# the (model_caption, edited_caption) pairs the summariser feedback loop trains on
pairs = store.caption_edit_pairs()
from argus_cortex.store import open_vector_store, IMAGE_COLLECTION
# no-op if CORTEX_QDRANT_URL is unset; QdrantVectorStore if it's set
vec = open_vector_store()
vec.ensure_collection(IMAGE_COLLECTION, dim=512) # idempotent
# store an embedding you computed, tagged with its lineage id
vec.upsert(IMAGE_COLLECTION, point_id=cap_id, vector=embedding, payload={"caption_id": cap_id})
# retrieve similar past captions to steer the summariser (few-shot)
hits = vec.search(IMAGE_COLLECTION, vector=query_embedding, top_k=5)
similar_caption_ids = [h.payload["caption_id"] for h in hits] # join back to Postgres
from argus_cortex.store import open_blob_store
# no-op if CORTEX_S3_ENDPOINT / CORTEX_S3_BUCKET are unset; S3BlobStore if set
blobs = open_blob_store()
blobs.ensure_bucket()
# content-addressed: the returned key IS the sha256 (== source_asset.sha256)
sha = blobs.put_content_addressed(image_bytes, content_type="image/jpeg")
data = blobs.get(sha) # bytes, or None if absent
link = blobs.url(sha, expires=3600) # presigned GET URL
Install
uv pip install argus-cortex # core (pydantic only)
uv pip install "argus-cortex[remote]" # + httpx for RemoteBackend
uv pip install "argus-cortex[server]" # + starlette for argus_cortex.server (WriteGuard, env_flag)
uv pip install "argus-cortex[postgres]" # + psycopg for the lineage store
uv pip install "argus-cortex[qdrant]" # + qdrant-client for the vector store
uv pip install "argus-cortex[s3]" # + minio for the blob store
The stateful services are configured via CORTEX_* env vars — see .env.example. Each is optional: leave a URL unset and that feature degrades to a no-op.
Develop
make install # venv + editable install with the "dev" extras
make test
make lint
CI / Release
- CI runs via the shared
argus-cireusable workflow. - Release publishes to PyPI (OIDC trusted publishing) on
v*tags. No container image — this is a library. - Versioning is derived from git tags via
hatch-vcs— tagvX.Y.Zto cut a release.
This repo was scaffolded from argus-pkg-template.
Run copier update to pull template changes (CI, release, tooling).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file argus_cortex-0.2.0.tar.gz.
File metadata
- Download URL: argus_cortex-0.2.0.tar.gz
- Upload date:
- Size: 46.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e814ccd79f4a036899fd7e1cbd6b5065de1bad9c57aa8a927792d0cd520c9f1d
|
|
| MD5 |
292291e774a5a1bb019b0cc714da09c7
|
|
| BLAKE2b-256 |
237ad3e10c87639634125c3b3b575d8f3a5ef19725ea042047d4a8397eca7888
|
Provenance
The following attestation bundles were made for argus_cortex-0.2.0.tar.gz:
Publisher:
release.yml on smk762/argus-cortex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
argus_cortex-0.2.0.tar.gz -
Subject digest:
e814ccd79f4a036899fd7e1cbd6b5065de1bad9c57aa8a927792d0cd520c9f1d - Sigstore transparency entry: 2210546681
- Sigstore integration time:
-
Permalink:
smk762/argus-cortex@db841f902ba0461c7c81e63bf833394c666ed458 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/smk762
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@db841f902ba0461c7c81e63bf833394c666ed458 -
Trigger Event:
push
-
Statement type:
File details
Details for the file argus_cortex-0.2.0-py3-none-any.whl.
File metadata
- Download URL: argus_cortex-0.2.0-py3-none-any.whl
- Upload date:
- Size: 38.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c584c369c8ec6731259322ce5da33d5ce6f02351fb288be01d363197d01faba
|
|
| MD5 |
b6534463bbb93cce5ff51de6a2566c21
|
|
| BLAKE2b-256 |
b4c64d264c29a75c0dd97adb0bb72dec7282c6b5e77c68d552de8d5907367726
|
Provenance
The following attestation bundles were made for argus_cortex-0.2.0-py3-none-any.whl:
Publisher:
release.yml on smk762/argus-cortex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
argus_cortex-0.2.0-py3-none-any.whl -
Subject digest:
0c584c369c8ec6731259322ce5da33d5ce6f02351fb288be01d363197d01faba - Sigstore transparency entry: 2210546719
- Sigstore integration time:
-
Permalink:
smk762/argus-cortex@db841f902ba0461c7c81e63bf833394c666ed458 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/smk762
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@db841f902ba0461c7c81e63bf833394c666ed458 -
Trigger Event:
push
-
Statement type: