Config-driven gate and state machine evaluator for MetaSPN entity pipelines
Project description
metaspn-gates
metaspn-gates is a config-driven gate + state-machine evaluator for MetaSPN entity pipelines.
Current implementation (v0.1 seed)
- Deterministic gate evaluation from config
- Hard requirements and soft thresholds
- Per-gate per-entity cooldown checks
- Transition attempt snapshots
- Transition application + task emissions
- Config parsing and validation from mapping
metaspn-schemasintegration hooks (currently used for typed emission shaping)- Optional
metaspn-schemasemission shaping (Task+EmissionEnvelope)
Public API
evaluate_gates(config, entity_state, features, now)apply_decisions(entity_state, decisions, caused_by=None)parse_state_machine_config(payload)load_state_machine_config(path)
Notes
load_state_machine_configcan usemetaspn_schemasparsing/validation hooks when exposed by that package version.- Canonical schema hooks:
- parser:
parse_state_machine_config(mapping payload) - validator:
validate_state_machine_config
- parser:
- If
metaspn_schemasis unavailable, it falls back to JSON parsing only. - Current dependency target:
metaspn-schemas>=0.1.0,<0.2.0. apply_decisions(..., use_schema_envelopes=True)attaches schema-shaped payloads whenentity_state.entity_idis present.
M0 Minimum Keys
For the sample M0 progression (SEEN -> OBSERVED -> PROFILED) the minimum keys are:
entity_state.state:SEENorOBSERVEDentity_state.track:M0features.ingestion.resolved_entity_id: required forSEEN -> OBSERVEDfeatures.profile.handle: required forOBSERVED -> PROFILEDfeatures.profile.confidence: numeric threshold forOBSERVED -> PROFILED(sample gate uses>= 0.7)
Reference fixture:
/Users/leoguinan/MetaSPN/metaspn-gates/tests/fixtures/m0_state_machine_config.json
M1 Required Keys
For the M1 routing progression (SEEN -> OBSERVED -> PROFILED -> QUALIFIED -> ROUTED) the minimum keys are:
entity_state.state: one ofSEEN,OBSERVED,PROFILED,QUALIFIEDentity_state.track:M1entity_state.entity_id: required for emitted task metadatafeatures.ingestion.resolved_entity_id: required forSEEN -> OBSERVEDfeatures.profile.handle: required forOBSERVED -> PROFILEDfeatures.profile.confidence: thresholded forOBSERVED -> PROFILEDfeatures.social.followers: required floor forPROFILED -> QUALIFIEDfeatures.scores.routing_readiness: required forPROFILED -> QUALIFIEDandQUALIFIED -> ROUTEDfeatures.scores.profile_quality: thresholded forPROFILED -> QUALIFIED
M1 reference fixture:
/Users/leoguinan/MetaSPN/metaspn-gates/tests/fixtures/m1_routing_state_machine_config.json
M2 Required Keys
For recommendation gating (QUALIFIED -> RECOMMENDABLE -> DRAFT_READY) the minimum keys are:
entity_state.state:QUALIFIEDorRECOMMENDABLEentity_state.track:M2entity_state.entity_id: required for downstream task metadatafeatures.profile.handle: required recommendation eligibility hard requirementfeatures.scores.recommendation_score: recommendation and draft thresholdsfeatures.scores.intent_score: recommendation eligibility thresholdfeatures.context.channel: channel-scoped cooldown keyfeatures.context.playbook: playbook-scoped cooldown keyfeatures.context.suppress_recommendations: suppression flag for recommendation gatefeatures.context.suppress_drafts: suppression flag for draft gate
M2 reference fixture:
/Users/leoguinan/MetaSPN/metaspn-gates/tests/fixtures/m2_recommendation_state_machine_config.json
M3 Learning Outputs
Learning helpers are exposed for reviewable gate analytics artifacts:
evaluate_attempt_outcomes(...)classify_failure_reason(...)generate_calibration_proposals(...)
These produce deterministic outputs for:
- moved-too-early detection
- false-negative/false-positive classification
- calibration recommendations (threshold/cooldown direction hints)
Calibration Safety Constraints
- Calibration outputs are proposal-only artifacts.
- No threshold or cooldown values are auto-applied silently.
- Every proposal has
auto_apply=Falseand must be explicitly approved by a human/operator workflow.
Demo Support
Demo fixture:
/Users/leoguinan/MetaSPN/metaspn-gates/tests/fixtures/demo_state_machine_config.json
Demo progression:
SEEN -> OBSERVEDenqueuesenrich_profileOBSERVED -> SHORTLISTEDenqueuesscore_entitySHORTLISTED -> READYoptionally enqueuesdraft_messagewhenfeatures.demo.draft_enabled=true
Digest explainability helper:
format_decision_trace(decisions)returns rows withpassed,blocked, andreason.
Token Health Support
Token fixture:
/Users/leoguinan/MetaSPN/metaspn-gates/tests/fixtures/token_health_state_machine_config.json
Token minimum keys:
entity_state.state:CANDIDATEorWATCHLISTEDentity_state.track:TOKENfeatures.token.holder_count: hard requirement floorfeatures.token.creator_behavior_risk: hard requirement ceilingfeatures.scores.credibility: threshold for both gatesfeatures.scores.organic_volume: soft thresholdfeatures.scores.concentration: soft thresholdfeatures.token.address,features.token.chain,features.token.symbol: copied into task emission metadata for token workers
Release
- GitHub Actions workflow:
/Users/leoguinan/MetaSPN/metaspn-gates/.github/workflows/publish.yml - Publish trigger: GitHub Release published (or manual
workflow_dispatch) - Publishing method: PyPI Trusted Publishing via
pypa/gh-action-pypi-publish
One-time setup
- In PyPI, create project
metaspn-gatesand configure Trusted Publisher for this GitHub repo/workflow. - In GitHub, create environment
pypi(optional protection rules supported).
Release flow
- Bump
/Users/leoguinan/MetaSPN/metaspn-gates/pyproject.tomlversion. - Tag and push a release commit.
- Publish a GitHub Release for that tag.
publish.ymlbuilds and uploads to PyPI.
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_gates-0.1.8.tar.gz.
File metadata
- Download URL: metaspn_gates-0.1.8.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41c76c1afb1b507e09ec1384d6857fa29ef11d212221788f0ee5c67163324899
|
|
| MD5 |
82c1a7cb0be2152204166f00c29c1140
|
|
| BLAKE2b-256 |
7777fc34559c95354cca19c8ac010cf9ef4d37c9c87dc2b432e51cebf7239499
|
Provenance
The following attestation bundles were made for metaspn_gates-0.1.8.tar.gz:
Publisher:
publish.yml on MetaSPN/metaspn-gates
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metaspn_gates-0.1.8.tar.gz -
Subject digest:
41c76c1afb1b507e09ec1384d6857fa29ef11d212221788f0ee5c67163324899 - Sigstore transparency entry: 925494446
- Sigstore integration time:
-
Permalink:
MetaSPN/metaspn-gates@19326497cbad62eb0aad8b8982cf3951b2825b73 -
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@19326497cbad62eb0aad8b8982cf3951b2825b73 -
Trigger Event:
release
-
Statement type:
File details
Details for the file metaspn_gates-0.1.8-py3-none-any.whl.
File metadata
- Download URL: metaspn_gates-0.1.8-py3-none-any.whl
- Upload date:
- Size: 14.1 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 |
efeff24c0a203e9a90601085a36fef179c5b28f9f322a96f322ca144a3966d79
|
|
| MD5 |
c8cdb412db2f8c8bf88385a8e3d080df
|
|
| BLAKE2b-256 |
f4f3ad2472466d99398906da7d1994c362fef27a52eeb1e2e8f17af88a7ec5fe
|
Provenance
The following attestation bundles were made for metaspn_gates-0.1.8-py3-none-any.whl:
Publisher:
publish.yml on MetaSPN/metaspn-gates
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metaspn_gates-0.1.8-py3-none-any.whl -
Subject digest:
efeff24c0a203e9a90601085a36fef179c5b28f9f322a96f322ca144a3966d79 - Sigstore transparency entry: 925494461
- Sigstore integration time:
-
Permalink:
MetaSPN/metaspn-gates@19326497cbad62eb0aad8b8982cf3951b2825b73 -
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@19326497cbad62eb0aad8b8982cf3951b2825b73 -
Trigger Event:
release
-
Statement type: