TETHESIS
DOCUMENTATION · SDK

Python and Node SDKs

Python and Node clients over the same HTTP API — Cypher, streaming reads, atomic writes, schema, search and the graph lifecycle. The module is invariantdb in both languages. .NET and Go also expose typed governance operations; confirm version and package details in the engine reference.

INSTALL

From a pinned, hash-checked URL

Neither client is published to PyPI or the public npm registry. Install from the InvariantDB URL — pip and npm verify the file against its hash and refuse a mismatch. Don’t run a bare pip install invariantdb or npm install invariantdb against the public registries.

# Python pip install "https://sdk.invariantdb.com/python/invariantdb-0.10.1-py3-none-any.whl#sha256=<SHA-256 from the release notes>"
# Node npm install https://sdk.invariantdb.com/node/invariantdb-0.10.1.tgz

pip checks the wheel against the #sha256= in the URL; npm records the integrity hash in package-lock.json.

CONNECT

Create a client

# Python from invariantdb import Client c = Client(url="https://invariantdb.com", api_key="gq_...")
// Node import { Client } from "invariantdb"; const c = new Client({ url: "https://invariantdb.com", apiKey: "gq_..." });

The key is a gq_-prefixed API key. Both clients also accept a bearer token if you’d rather not use a managed key.

CYPHER

Run a query

# Python result = c.cypher( "my_graph", "MATCH (n:Person {name: $name}) RETURN n.email", parameters={"name": "Alice"}, ) for row in result.as_dicts(): print(row["n.email"]) # Stats and warnings come back with every result print(result.stats.rows_returned, result.warnings)
// Node const result = await c.cypher( "my_graph", "MATCH (n:Person {name: $name}) RETURN n.email", { parameters: { name: "Alice" } }, ); for (const row of result.asDicts()) console.log(row["n.email"]);

Node and edge values arrive with their envelopes flattened — plain objects and dicts, not nested {node: {…}} wrappers.

STREAMING READS

Cursors for large results

Stream a big result set instead of materializing it. Cursors are read-only — mutations on the cursor route are refused.

# Python with c.cursor.stream("my_graph", "MATCH (n:Event) RETURN n", batch_size=1000) as it: for row in it: process(row)
// Node for await (const row of c.cursor.stream("my_graph", "MATCH (n:Event) RETURN n", { batchSize: 1000 })) { process(row); }
ATOMIC WRITES

Pre-resolved batches

Write operations bypass the Cypher parser and apply a pre-resolved batch — cheaper at high throughput than CREATE/MERGE in Cypher. Values are wrapped to the engine’s tagged format for you.

# Python c.write("my_graph", [ {"createNode": {"strId": "n1", "labels": ["Person"], "properties": {"name": "Ada"}}}, {"createEdge": {"strId": "e1", "type": "KNOWS", "source": "n1", "target": "n2"}}, ])

Operation shapes: createNode, createEdge, updateNodeProperties, updateEdgeProperties, deleteNode, detachDeleteNode, deleteEdge.

GRAPHS & SCHEMA

Lifecycle and declarations

# Graphs c.graphs.list() c.graphs.create("new_graph") c.graphs.info("new_graph") # snapshot seq, labels, edge types c.graphs.clone(source="prod", destination="prod_snapshot")
# Schema — versioned; ACL, encryption and vector index all come from here c.schema.put("my_graph", { "properties": { "ssn": { "type": "string", "encryption": {"subject_id_property": "userId"}, "acl": {"read": ["admin", "compliance"]} }, "embedding": { "type": "vector", "dim": 1536, "metric": "cosine", "index": "hnsw" }, }, })

Every schema.put appends a new version; c.schema.history(graph) lists them. Field-level access, cryptographic erasure and vector-index selection all read from these declarations.

SEARCH

Full-text and vector

# Python hits = c.search.fulltext("my_graph", label="Document", property="body", query="invoice") hits = c.search.vector("my_graph", label="Document", property="embedding", vector=[0.1, 0.4, ...], k=10)

Hits are ranked best-first. The engine picks flat or HNSW automatically from the schema declaration and label size.

GOVERNED AGENT RUNTIME

Use the run harness for bounded agent execution.

Python and Node provide a client-side harness for scoped agent runs. The harness manages delegated credentials, trace lifecycle, budgets, tool policies and revocation. The .NET and Go SDKs also provide typed calls for leases, budgets, receipts and authority. Check the SDK version and API reference for exact signatures and feature availability.

CONTROLCONTRACT
Run lifecycleThe Python and Node SDK harness creates a delegated run credential, starts the agent trace, applies its operation budget and revokes the credential on completion.
Tool policyClassify tools as read, propose or act. Reject unknown arguments and command-like parameters under the configured policy; strip model-supplied consent arguments. Tool availability depends on prior reads.
Information-flow controlsFence model-visible context by trust tier, strip hidden fields and gate tools by the lowest tier of content seen. These are runtime controls, not a guarantee against every prompt-injection technique.
Delegation chainCaller → agent → task → read/propose credentials. Each child is no wider than its parent; credentials remain outside model-visible context.

Consult the installed SDK documentation for invocation signatures and configuration. Tracked read validation applies to supported read-session shapes. Future-dated single-label reads are covered by the reported fix; transaction-integrated tracking and relationship-read tracking require separate version verification. Use explicit revision conditions where tracking coverage is unavailable.

Build on the foundation