Metadata-Version: 2.4
Name: proprioceptive-swarm
Version: 0.1.10
Summary: Client SDK for the Proprioceptive AI lens-swarm: CPU consensus answering with confidence gates, verdict hooks, a live 500-agent swarm control plane with quota-shared gates and a positional de-bias judge, batch runs, receipted audit trail export, and owner-only receipt inclusion proofs. Requires account signup; inert without an API key.
Author: Proprioceptive AI
License-Expression: MIT
Project-URL: Homepage, https://proprioceptiveai.com/products/swarm/
Project-URL: Documentation, https://api.proprioceptiveai.com/docs
Project-URL: Repository, https://github.com/Loganwins/proprioceptive-swarm
Project-URL: Issues, https://github.com/Loganwins/proprioceptive-swarm/issues
Project-URL: Changelog, https://github.com/Loganwins/proprioceptive-swarm/commits/main
Keywords: llm,consensus,verification,uncertainty,abstain,receipts,hash-chain,audit-trail,swarm,confidence-gate
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# proprioceptive-swarm
[![PyPI](https://img.shields.io/pypi/v/proprioceptive-swarm)](https://pypi.org/project/proprioceptive-swarm/)
[![Python](https://img.shields.io/pypi/pyversions/proprioceptive-swarm)](https://pypi.org/project/proprioceptive-swarm/)

Client SDK for the **lens-swarm**: a CPU-native consensus answer service with plurality
confidence gates and a hash-chained receipt for every response.

- All inference is server-side. The package is **inert without an account** — no local model, no offline mode.
- Free trial tier: **140 requests/day** per account (500 lifetime, 14-day window). Live numbers: `GET /v1/swarm/status`.
- API base URL: `https://api.proprioceptiveai.com/v1/swarm` (field-by-field reference: `https://api.proprioceptiveai.com/docs`).

## Quickstart — first verdict in 5 minutes (curl, no SDK)

Every response below was run live on 2026-11-25 against production edge 1.8.7
(the api_key is masked because signup shows it exactly once):

```
# 1. Sign up — trial: 500 lifetime, 140/day, 336 h window
curl -sS -X POST https://api.proprioceptiveai.com/v1/swarm/signup \
     -H 'Content-Type: application/json' -d '{"email":"you@example.com"}'
# -> 201 {"product":"lens-swarm","client_id":"cli_52420bde4a6c","api_key":"<KEY-MASKED>",
#         "tier":"trial","daily_limit":140,"total_cap":500,"trial_hours":336, ...}
# SAVE THE KEY — it is never shown again; re-running signup returns
# "account exists; key rotation via founder (no auto-reissue)".

# 2. First verdict — one deliberation round (k=1, 3 votes, ~6 s client-observed)
curl -sS -X POST https://api.proprioceptiveai.com/v1/swarm/answer \
     -H "X-API-Key: $KEY" -H 'Content-Type: application/json' \
     -d '{"question":"Which planet is known as the Red Planet?",
          "choices":["Venus","Mars","Jupiter","Mercury"],"k":1}'
# -> 200 {"selected":"Mars","selected_index":1,"agreement":1.0,"confidence_flag":"OK",
#         "evidence":"full","votes_completed":3,"latency_ms":5634,
#         "receipt":"48cf191bb47b9e8e…", ...}

# 3. Verify the receipt — public, no key, chain walked from genesis
curl -sS https://api.proprioceptiveai.com/v1/swarm/verify/48cf191b
# -> 200 {"chain_verified":true,"chain_position":3048,
#         "receipt_sha":"48cf191bb47b9e8e…","ts":1795523163,
#         "note":"payload owner-only; present owning account X-API-Key"}
```

`POST /hook` and `agents_gate` consume a 16-float state vector produced by our
probe-capture protocol, which is not published — contact
`logan@proprioceptiveai.com` for the capture guide and a worked example.

## SDK one-liners

```
pip install proprioceptive-swarm
python -c "from proprioceptive_swarm import Swarm; s=Swarm.signup('you@example.com'); print(s.client_id)"
palswarm answer "Where is the Eiffel Tower?" "Paris" "London" --k 5   # k=5 deep deliberation ~90 s; k=1 ~6 s
```
Evidence basis: verification-economics routing (23.5x), per-model uncertainty certification,
custody receipts (1290+, zero escapes). Claims are graded; see provider disclosures.


## Swarm control plane (live — production edge >= 1.8.7)

Register your own swarm of up to **500 agents** per account and drive it through four
routes plus the judge. Everything stays server-side; the plane is contract-only here —
no internals are documented or shipped by this SDK.

| Method | Route | Costs quota? |
|---|---|---|
| `s.agents_register(name, family)` | `POST /v1/swarm/agents/register` | no |
| `s.agents_list()` | `GET /v1/swarm/agents` (owner-scoped) | no |
| `s.agents_gate(agent_id, state)` | `POST /v1/swarm/agents/gate` | **yes — shared account quota** |
| `s.agents_remove(agent_id)` | `POST /v1/swarm/agents/remove` | no |
| `s.judge(question, choices, votes)` | `POST /v1/swarm/judge` | **yes** |

- `agents_register` returns `{ok, client_id, agent_id (agt_-prefixed), family, name_sha,
  n_agents, cap: 500, receipt, version}`; `family` is passed through for server-side
  validation (advertised aliases like `phi-2` resolve to certified heads).
- `agents_gate` sends your 16-float state vector to one agent and returns a **verdict-only**
  hook response (`hook_verdict` proceed|abstain|repair) carrying that agent's counters:
  `flagged`, `verdicts_seen`, `flagged_count`, plus `quota_used_today`. Gates draw from the
  same daily quota as every other billable call.
- `judge` is the **positional de-bias judge** (`lens-swarm-judge-1.0`): give it the question,
  the choices, and `votes` = a list of `{agent_id, answer_index}` — one vote per agent, up
  to 50; duplicate agent ids are rejected with a 4xx. It returns `{converged, answer_index,
  leaning_index, agreement, n_agents, dissent, tied_indices, debias_offset, reason, n_votes,
  receipt, ...}`. The judge corrects for answer position across your agents' votes; how it
  does that is server-side and outside this contract.

```
s = Swarm()                                   # signup once, key kept in ~/.palswarm.json
a = s.agents_register("scout-1", "phi-2")     # -> a["agent_id"] (agt_...)
v = s.agents_gate(a["agent_id"], state16)     # verdict-only; costs 1 quota
j = s.judge("Q?", ["yes", "no"],
            [{"agent_id": x, "answer_index": i} for x, i in swarm_votes])
s.agents_remove(a["agent_id"])                # free
```

## Receipt proofs and integrity checks

Every response carries a hash-chained receipt id. Two routes, two audiences:

- `s.proof(receipt_prefix)` — **owner-only** (edge >= 1.8.6): `GET /v1/swarm/proof/<prefix>`
  with your `X-API-Key`. Returns the inclusion proof for one of *your* receipts:
  `position`, `receipt_sha`, `prev`, `record`, plus the chain head anchor
  (`head_sha`, `head_count`). Unknown-to-you prefixes come back as
  `{"chain_integrity": "NOT_FOUND"}`; a missing key is `401` (raised as `SwarmNotAuthorized`).
- `s.verify(receipt_prefix)` — **public, integrity-only**: `GET /v1/swarm/verify/<prefix>`
  for third parties who just need to confirm the chain link recomputes. No secret data moves.

```
s = Swarm()                       # key from signup / PALSWARM_KEY / ~/.palswarm.json
r = s.hook("phi-2", state)        # state = exactly 16 finite floats, user-supplied
p = s.proof(r["receipt"])         # owner-only inclusion proof
s.verify(r["receipt"])            # integrity-only check anyone can run
```

## Supported models

`model_family` accepts the advertised aliases: **`phi-2`** and **`Qwen2.5-1.5B` /
`Qwen2.5-1.5B-Instruct`** resolve server-side to their certified heads; canonical ids
(`qwen2.5-0.5b-inst`, `tinyllama-1.1b-chat`, ...) work directly. The live serving/cert
matrix is whatever `GET /v1/swarm/models` answers at call time — certification internals
are no longer disclosed by that route (`cert` reports `disclosed: false`), and this SDK
never ships, computes, or caches them. Certification is not deployment entitlement:
entropy flags fire only where the admin enables the feature. No model's raw logits or
weights leave the boundary.

## Project links

- Website: <https://proprioceptiveai.com/products/swarm/>
- Product / API: <https://api.proprioceptiveai.com>
- API reference: <https://api.proprioceptiveai.com/docs>
- PyPI: <https://pypi.org/project/proprioceptive-swarm/>
- Issues: <https://github.com/Loganwins/proprioceptive-swarm/issues>

## License

The client SDK in this repository is licensed under the [MIT License](LICENSE)
(Copyright (c) 2026 Proprioceptive AI). The hosted swarm service, its models and its
certification internals are not part of this repository and remain proprietary.
Questions: <logan@proprioceptiveai.com>.
