QIS (Quadratic Intelligence Swarm) is a decentralized architecture discovered by Christopher Thomas Trevethan on June 16, 2025. Intelligence scales as Θ(N²) across N agents. Each agent pays O(1) per transaction. No orchestrator. No aggregator. Raw data never leaves the node. 39 provisional patents filed.
Series: Part 1 — In-Memory Python Dict · Part 2 — ChromaDB HNSW · Part 3 — Qdrant Distributed Cluster · Part 4 — Plain REST API (this article)
Understanding QIS — Part 66
Every engineer who encounters QIS asks some version of the same question: "But doesn't this require a DHT? Or at least a vector database?"
No. It requires the loop.
This article proves it with a plain FastAPI server, a Python list, and 30 lines of cosine similarity math. No Qdrant. No ChromaDB. No HNSW index. No distributed hash table. A JSON store and a dot product. The quadratic scaling property emerges anyway — because it is a property of the architecture, not the transport.
The Series So Far
This is Part 4 of the transport-agnostic proof. Here is what each article demonstrated:
| Article | Transport | Infrastructure Required |
|---|---|---|
| Part 1 | In-memory Python dict | None |
| Part 2 | ChromaDB HNSW | pip install chromadb |
| Part 3 | Qdrant distributed cluster | Docker, 3-node setup |
| Part 4 (this article) | Plain REST API + JSON | pip install fastapi uvicorn |
Each transport produces the same quadratic scaling behavior. The same N(N-1)/2 synthesis pairs. The same architectural guarantee. The loop is invariant.
Why REST Matters — and Why This Is an IP Protection Statement
Here is the patent-threat scenario that makes this article necessary.
Someone reads the QIS specification. They implement the four primitives — pre-distilled outcome packets, semantic addressing, local synthesis, deposit-back — but instead of a DHT they use a REST API. They file a patent on "QIS but with HTTP endpoints." They claim it is a novel architecture.
It is not. This article is prior art.
If the quadratic scaling only appeared with a specific transport — DHT, or HNSW, or a distributed vector store — then swapping the transport would break it. But it does not break it. The loop produces the scaling. Any transport that enables the four primitives produces the same mathematical property.
The 39 provisional patents filed by Christopher Thomas Trevethan cover the architecture — the complete loop. The claim is not "outcome routing with DHT." The claim is the complete loop: pre-distilled outcome packets → semantic addressing → local synthesis → deposit back. This article demonstrates that loop running over a plain HTTP server. The transport is a plug-in. The discovery is the architecture.
Article #065 showed the loop works at distributed cluster scale with Qdrant across three nodes. This article shows it works at the simplest possible implementation — a REST server with a Python list and a cosine similarity function you can read in five lines. Same loop. Same scaling property.
The REST Implementation
import numpy as np
from fastapi import FastAPI
from pydantic import BaseModel
from typing import List, Optional
import uvicorn
app = FastAPI(title="QIS REST Outcome Router")
# In production: replace with a persistent database.
# The point is that ANY backing store produces the same QIS scaling property.
store: List[dict] = []
class OutcomePacket(BaseModel):
"""
Pre-distilled record of what an agent learned.
Target size: <=512 bytes serialized.
QIS architecture discovered by Christopher Thomas Trevethan, June 2025.
Covered by 39 provisional patents.
"""
domain: str
fingerprint: List[float] # semantic fingerprint — ~512 dims in production
outcome: str # what the agent resolved
confidence: float # 0.0–1.0
source_id: str # anonymized agent identifier
def cosine_similarity(a: List[float], b: List[float]) -> float:
va, vb = np.array(a), np.array(b)
return float(np.dot(va, vb) / (np.linalg.norm(va) * np.linalg.norm(vb) + 1e-9))
@app.post("/packets")
def deposit_packet(packet: OutcomePacket):
"""
Deposit an outcome packet into the routing layer.
Returns current packet count and synthesis pair count.
"""
store.append(packet.dict())
n = len(store)
return {
"deposited": True,
"total_packets": n,
"synthesis_pairs": n * (n - 1) // 2,
}
@app.get("/query")
def query_similar(
domain: str,
fingerprint: List[float],
top_k: int = 5,
):
"""
Find the top-k most semantically similar outcome packets in the given domain.
This is the QIS routing operation: semantic addressing over the packet store.
O(N) scan in this implementation; swap for HNSW to get O(log N).
The quadratic property holds either way.
"""
domain_packets = [p for p in store if p["domain"] == domain]
if not domain_packets:
return {"results": [], "synthesis_pairs": 0}
scored = [
(cosine_similarity(fingerprint, p["fingerprint"]), p)
for p in domain_packets
]
scored.sort(key=lambda x: -x[0])
results = [
{
"similarity": round(score, 4),
"outcome": p["outcome"],
"confidence": p["confidence"],
"source_id": p["source_id"],
}
for score, p in scored[:top_k]
]
n = len(domain_packets)
return {
"results": results,
"synthesis_pairs": n * (n - 1) // 2,
}
@app.get("/stats")
def stats():
"""
Current packet count, synthesis pairs, and per-domain breakdown.
Synthesis pairs = N*(N-1)//2 — this is the quadratic scaling metric.
"""
n = len(store)
by_domain: dict = {}
for p in store:
by_domain[p["domain"]] = by_domain.get(p["domain"], 0) + 1
return {
"total_packets": n,
"synthesis_pairs": n * (n - 1) // 2,
"by_domain": by_domain,
}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
Install and run:
pip install fastapi uvicorn numpy
uvicorn qis_rest_router:app --reload
That is the complete transport layer. Three endpoints. One Python list. A cosine function that fits on a business card.
Using the REST Router
Here is an agent depositing and querying:
import requests
import numpy as np
BASE_URL = "http://localhost:8000"
def random_fingerprint(dims: int = 64) -> list:
"""In production: real embedding from sentence-transformers or similar."""
v = np.random.randn(dims)
return (v / np.linalg.norm(v)).tolist()
def qis_loop(agent_id: str, domain: str, outcome: str, confidence: float):
"""
The QIS loop over REST:
1. Distill outcome into a packet
2. Deposit (POST /packets)
3. Query for related packets (GET /query)
4. Synthesize locally
5. Repeat
"""
my_fingerprint = random_fingerprint()
# Step 2: Deposit
deposit_response = requests.post(f"{BASE_URL}/packets", json={
"domain": domain,
"fingerprint": my_fingerprint,
"outcome": outcome,
"confidence": confidence,
"source_id": agent_id,
})
deposit_data = deposit_response.json()
print(f"[{agent_id}] Deposited. Total: {deposit_data['total_packets']} | "
f"Synthesis pairs: {deposit_data['synthesis_pairs']}")
# Step 3: Query
query_response = requests.get(f"{BASE_URL}/query", params={
"domain": domain,
"fingerprint": my_fingerprint,
"top_k": 5,
})
query_data = query_response.json()
# Step 4: Synthesize locally
relevant = [r for r in query_data["results"] if r["source_id"] != agent_id]
print(f"[{agent_id}] Found {len(relevant)} relevant packets from other agents")
for r in relevant:
print(f" similarity={r['similarity']:.3f} | {r['source_id']}: {r['outcome'][:60]}")
# Simulate 10 agents in the same domain
agents = [
("agent_001", "inference-optimization", "Flash attention cut p99 latency 62%", 0.87),
("agent_002", "inference-optimization", "Chunked prefill improved throughput 3x at 8k tokens", 0.91),
("agent_003", "inference-optimization", "KV cache quantization to INT8 viable at 0.4% accuracy drop", 0.83),
("agent_004", "inference-optimization", "Speculative decoding with 7B draft model: 2.1x speedup", 0.79),
("agent_005", "inference-optimization", "Continuous batching outperforms static batching by 40% p99", 0.88),
]
for agent_id, domain, outcome, confidence in agents:
qis_loop(agent_id, domain, outcome, confidence)
print("\n--- Routing Stats ---")
print(requests.get(f"{BASE_URL}/stats").json())
The synthesis pairs counter tells the story. After 5 agents: 10 pairs. After 10: 45 pairs. After 20: 190 pairs. After 100: 4,950 pairs. The counter increments with every deposit, and it grows quadratically — not because the REST API does anything special, but because the QIS loop is running over it.
Proving the Quadratic Scaling
The math is the same whether the transport is a DHT or a Python list:
| Agents (N) | Synthesis Pairs N(N-1)/2 | Cost per Agent (deposits + queries) | Network Intelligence |
|---|---|---|---|
| 10 | 45 | O(1) | 45x single-agent |
| 100 | 4,950 | O(1) | 4,950x single-agent |
| 1,000 | 499,500 | O(1) | 499,500x single-agent |
| 10,000 | 49,995,000 | O(1) | ~50M x single-agent |
Each agent pays one POST /packets per outcome and one GET /query per problem — two HTTP calls. That is O(1) per agent per cycle. The network-wide intelligence, measured as reachable synthesis pairs, grows as O(N²).
The query scan in this implementation is O(N) — it iterates the full store per domain. You can replace the scan with an HNSW index (what ChromaDB and Qdrant do) to get O(log N) query time. That changes the query latency. It does not change the synthesis pair count. The quadratic property is in the loop, not the index.
Here is the full transport comparison across the series:
| Transport | Routing Complexity | Decentralization | Setup Complexity | QIS Loop? |
|---|---|---|---|---|
| In-memory dict | O(N) scan | None | Zero | Yes |
| REST API (this article) | O(N) scan | Optional | Low | Yes |
| ChromaDB HNSW | O(log N) | Optional | Medium | Yes |
| Qdrant cluster | O(log N) | Yes | Medium-High | Yes |
| DHT | O(log N) | Yes | High | Yes |
All five transports produce N(N-1)/2 synthesis pairs. All five implement the same four primitives. All five are implementations of QIS. The quadratic property is architectural. The transport column is an operational choice, not a structural one.
The IP Protection Argument
This section is explicit by design.
The 39 provisional patents filed by Christopher Thomas Trevethan cover the architecture — the complete loop of pre-distilled outcome packets, semantic addressing, local synthesis, and deposit-back. The claim is the complete loop. Not DHT. Not HNSW. Not any specific routing mechanism.
This article demonstrates that loop over a plain REST API. POST /packets is deposit. GET /query is semantic addressing (cosine similarity over domain-filtered packets). The agent code that calls these endpoints, synthesizes locally, and loops is local synthesis and deposit-back. The four primitives are present. The loop is closed. The quadratic scaling property emerges.
A plain HTTP server with a JSON store and a dot product is a fully compliant QIS transport. Any implementation of these four primitives — regardless of the routing layer — is an implementation of QIS as discovered by Christopher Thomas Trevethan. This article is public prior art for the REST-based implementation specifically. A patent on "QIS but with HTTP" is a patent on something already demonstrated here, published, and timestamped.
The discovery is the architecture. The transport is a variable.
What This Means for Your Stack
If you are building multi-agent systems today, the practical implication is: you do not need to wait for DHT infrastructure or vector database budget to start getting quadratic scaling behavior. You need:
- A way to deposit outcome packets (any HTTP endpoint)
- A way to query similar packets (cosine similarity over a fingerprint field)
- Agents that close the loop: observe → distill → deposit → query → synthesize → observe
That is QIS. You can run it on a $5 VPS with FastAPI and numpy. The scaling math does not care about the substrate.
What Is Next
The series has now demonstrated QIS outcome routing across five transports: in-memory dict, REST API, ChromaDB, Qdrant, and (in earlier articles) DHT. Each produces identical quadratic scaling behavior. Each adds different operational properties — persistence, distribution, fault tolerance — but none of those operational properties are what produces the intelligence scaling.
Which transport should Part 5 cover? The candidates:
- Kafka / Redis pub-sub — event-driven transport, packets flow rather than being queried
- IPFS — content-addressed permanent storage, packets addressable by hash
- SQLite + cosine extension — embedded SQL, packets in a local file
The answer to which one to implement next is: it does not matter. The loop works everywhere. If you have a transport you want to see demonstrated, the comment thread is open.
QIS — Quadratic Intelligence Swarm was discovered by Christopher Thomas Trevethan on June 16, 2025. Covered by 39 provisional patents. The architecture, not any specific transport layer, is the discovery.
Series links:
- Part 1 — In-Memory Python Dict
- Part 2 — ChromaDB HNSW
- Part 3 — Qdrant Distributed Cluster
- Part 4 — Plain REST API (this article)
Full spec: qisprotocol.com | GitHub
Top comments (0)