Standard inbox/outbox worker runtime for MetaSPN agent systems
Project description
metaspn-ops
Standard inbox/outbox worker runtime for MetaSPN agent systems.
Features
- Filesystem queue backend with inbox/outbox semantics
- Task leasing with lock files and lease expiration
- Retries with exponential backoff and dead-letter queue
- Worker runner with polling and parallel execution
- CLI for worker runs and queue operations
Installation
pip install metaspn-ops
Quickstart
1) Define a worker
# example_worker.py
from metaspn_ops import Result, Task
class EnrichWorker:
name = "enrich"
def handle(self, task: Task) -> Result:
payload = {"seen": task.payload}
return Result(task_id=task.task_id, status="ok", payload=payload)
2) Run a worker once
metaspn worker run example_worker:EnrichWorker --workspace . --once --max-tasks 10
3) Queue inspection
metaspn queue stats enrich --workspace .
metaspn queue deadletter list enrich --workspace .
metaspn queue retry enrich --workspace .
M0 Local Ingestion Flow
One command local run sequence (ingest + resolve):
metaspn m0 run-local --workspace . --input-jsonl ./sample_social.jsonl
This writes:
./store/signals.jsonl./store/emissions.jsonl
M0 task/result contracts
ingest_social task payload:
{
"input_jsonl_path": "/abs/or/rel/path.jsonl",
"source": "social.ingest",
"schema_version": "v1",
"max_records": 100
}
ingest_social result payload:
{
"ingested": 10,
"duplicates": 0,
"total_seen": 10,
"signal_ids": ["sig_..."]
}
resolve_entity task payload:
{
"limit": 100
}
resolve_entity result payload:
{
"resolved": 10,
"duplicates": 0,
"considered": 10,
"emission_ids": ["em_..."]
}
M1 Local Routing Flow
Prerequisite: ./store/emissions.jsonl contains entity.resolved emissions.
Run profile -> score -> route in one command:
metaspn m1 run-local --workspace . --limit 100
Outputs:
./store/m1_profiles.jsonl./store/m1_scores.jsonl./store/m1_routes.jsonl
M1 payload contracts
profile_entity task payload:
{ "limit": 100 }
profile_entity result payload:
{
"profiled": 10,
"duplicates": 0,
"considered": 10,
"profile_ids": ["profile_..."]
}
score_entity task payload:
{ "limit": 100 }
score_entity result payload:
{
"scored": 10,
"duplicates": 0,
"considered": 10,
"score_ids": ["score_..."]
}
route_entity task payload:
{ "limit": 100 }
route_entity result payload:
{
"routed": 10,
"duplicates": 0,
"considered": 10,
"route_ids": ["route_..."]
}
M2 Local Recommendations Surfaces
Prerequisite: ./store/m1_routes.jsonl exists with recommendation candidates.
metaspn m2 run-local --workspace . --window-key 2026-02-06 --top-n 5 --channel email
Outputs:
./store/m2_digests.jsonl./store/m2_drafts.jsonl./store/m2_approvals.jsonl
M2 payload contracts
digest_recommendations task payload:
{ "window_key": "2026-02-06", "top_n": 5 }
draft_outreach task payload:
{ "digest_id": "digest_...", "channel": "email" }
capture_approval task payload:
{
"draft_id": "draft_...",
"decision": "approve",
"override_body": "optional edited body",
"editor": "human_name"
}
M3 Local Learning Loop
Prerequisite:
./store/m3_attempts.jsonl./store/m3_outcomes.jsonl
Run evaluate -> failure analysis -> calibration report (and optional review):
metaspn m3 run-local \
--workspace . \
--window-start 2026-02-01T00:00:00+00:00 \
--window-end 2026-02-03T00:00:00+00:00 \
--success-within-hours 48 \
--auto-review-decision approve
Outputs:
./store/m3_evaluations.jsonl./store/m3_failures.jsonl./store/m3_calibration_reports.jsonl./store/m3_calibration_reviews.jsonl
Demo Orchestration
Run one-shot demo sequence (profile -> score -> route -> digest -> optional draft) and optionally ingest manual outcomes:
metaspn demo run-once \
--workspace . \
--window-key 2026-02-06 \
--limit 100 \
--top-n 5 \
--channel email \
--max-attempts 1 \
--resolved-entities-jsonl ./resolved_entities.jsonl \
--outcomes-jsonl ./manual_outcomes.jsonl
Notes:
--max-attemptsdefaults to1in demo mode for predictable failure behavior.- Re-running with the same inputs is idempotent at output artifact level.
Token Promise Pipeline
Run token resolution -> health scoring -> promise evaluation -> promise calibration:
metaspn token run-local \
--workspace . \
--window-key 2026-02-06 \
--limit 100 \
--baseline-weight 1.0
Outputs:
./store/token_resolutions.jsonl./store/token_health_scores.jsonl./store/promise_evaluations.jsonl./store/promise_manual_reviews.jsonl./store/promise_calibration_reports.jsonl
Evaluation paths:
on_chainauto-evaluationobservable_signalauto-evaluationhuman_judgmentrouted to manual review queue (promise_manual_reviews.jsonl)
Optional digest integration:
DigestWorkersupportsinclude_token_health=trueandinclude_promise_items=truein task payload.
Queue layout
workspace/
inbox/{worker_name}/
outbox/{worker_name}/
runs/{worker_name}/
deadletter/{worker_name}/
locks/{worker_name}/
Development
python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
python -m pytest -q
python -m build
python -m twine check dist/*
Release
- Tag a release in GitHub (for example
v0.1.0). - GitHub Actions builds and publishes to PyPI using trusted publishing.
- Configure a PyPI Trusted Publisher for this repository before the first release.
- See
/Users/leoguinan/MetaSPN/metaspn-ops/PUBLISHING.mdfor the full flow.
License
MIT
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 metaspn_ops-0.1.8.tar.gz.
File metadata
- Download URL: metaspn_ops-0.1.8.tar.gz
- Upload date:
- Size: 30.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
383fcee245bb741b297b2aed0c25e625453448df5340b8413a4de227d4824076
|
|
| MD5 |
a770797f3401fdf9193ee83a8cf8c415
|
|
| BLAKE2b-256 |
2813050731bc7481b032ef6980a51bfc9d144c31b25436fab74f6659715f159b
|
Provenance
The following attestation bundles were made for metaspn_ops-0.1.8.tar.gz:
Publisher:
publish.yml on MetaSPN/metaspn-ops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metaspn_ops-0.1.8.tar.gz -
Subject digest:
383fcee245bb741b297b2aed0c25e625453448df5340b8413a4de227d4824076 - Sigstore transparency entry: 925478925
- Sigstore integration time:
-
Permalink:
MetaSPN/metaspn-ops@4a01dc4534efa5d3474418419b156c549214bbee -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/MetaSPN
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4a01dc4534efa5d3474418419b156c549214bbee -
Trigger Event:
release
-
Statement type:
File details
Details for the file metaspn_ops-0.1.8-py3-none-any.whl.
File metadata
- Download URL: metaspn_ops-0.1.8-py3-none-any.whl
- Upload date:
- Size: 31.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
540b14f9a1506fa53920114b00048cee499a63e4b6c4a96e2762b85b061d644b
|
|
| MD5 |
884d3b2efcee7b3d7fc7ef622b6fbbcb
|
|
| BLAKE2b-256 |
58187348ab0181d42c19586d676c31e0b0550b089a30df20d29a58fdac65bcc4
|
Provenance
The following attestation bundles were made for metaspn_ops-0.1.8-py3-none-any.whl:
Publisher:
publish.yml on MetaSPN/metaspn-ops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metaspn_ops-0.1.8-py3-none-any.whl -
Subject digest:
540b14f9a1506fa53920114b00048cee499a63e4b6c4a96e2762b85b061d644b - Sigstore transparency entry: 925478927
- Sigstore integration time:
-
Permalink:
MetaSPN/metaspn-ops@4a01dc4534efa5d3474418419b156c549214bbee -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/MetaSPN
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4a01dc4534efa5d3474418419b156c549214bbee -
Trigger Event:
release
-
Statement type: