SDK reference #
Generated from tensorchain.workspace.Workspace (local) and tensorchain.client.RemoteWorkspace (the same names over HTTP). Refusals raise Refused(code, message) locally and ClientRefused(code, message, http_status) remotely.
| method | local | over HTTP |
|---|---|---|
branch | yes | - |
capabilities | yes | yes |
close | yes | - |
common_ancestors | yes | yes |
compare | yes | - |
descendants | yes | - |
describe | yes | yes |
digest | yes | yes |
evaluate | yes | yes |
fork | yes | yes |
freeze_source | yes | - |
full_digest | yes | yes |
get | yes | yes |
get_run | yes | yes |
get_step | yes | yes |
get_verified | yes | yes |
info | yes | yes |
log_step | yes | yes |
merge | yes | yes |
merged_tags | yes | yes |
promote | yes | - |
put | yes | yes |
refs | yes | yes |
register_program | yes | - |
repair | yes | - |
revision | yes | yes |
rewards | yes | yes |
rollback | yes | - |
search | yes | yes |
set_capability | yes | yes |
snapshot | yes | - |
submit | yes | - |
tag | yes | yes |
tags | yes | yes |
trace | yes | yes |
verify | yes | yes |
branch #
Workspace.branch(self, decision, options, agent, paths, parent=None, caps=None, registry=None)
One child workspace per option of a decision; nothing is chosen or deleted: the option not taken stays as a road not taken.
capabilities #
Workspace.capabilities(self)
Every program's capability state (Off, Shadow, Advisory), its bound digest and whether it is stale.
close #
Workspace.close(self)
Release the workspace file (the context manager calls this).
common_ancestors #
Workspace.common_ancestors(self, step_ids)
Every ancestor of the given steps, with how many of them sit beneath it.
compare #
Workspace.compare(self, candidates, workdir, agent='admin', caps=None, registry=None)
Run heads against candidate versions in two forked workspaces (a crossroad); one receipt per program: identical or differs. Moves nothing.
descendants #
Workspace.descendants(self, content_id, max_visit=100000)
Every step forward of a content id or step: steps that read it or produced it, their children, and steps that read their outputs (tc-sql addendum N); refused visit_cap past max_visit.
describe #
Workspace.describe(self)
Schema, base pins (core file digests), revision, programs and their digests, limits; api = tensorchain.v1.
digest #
Workspace.digest(self, heads=None)
The layer-0 digest of the workspace (its retained objects and heads); equal digests = equal state.
evaluate #
Workspace.evaluate(self, step_id)
Judge a step from exact evidence (a verified object, a run's recorded status): rewards to the agent and to whoever gave the instruction. No evidence, no reward; idempotent.
fork #
Workspace.fork(self, path, request_id, caps=None, registry=None)
A verified child workspace (depth + 1) that inherits capabilities and lineage; refused cap_exceeded past the caps.
freeze_source #
Workspace.freeze_source(self, source)
Freeze a source (anything with heads() and export()) into an input reference for submit.
full_digest #
Workspace.full_digest(self)
The digest of everything, including merged heads and lineage.
get #
Workspace.get(self, root)
The bytes of a root, re-hashed before they are returned; refused corrupt or not_found.
get_run #
Workspace.get_run(self, run_id)
A run's retained request, outcome and receipt.
get_step #
Workspace.get_step(self, step_id)
One recorded step.
get_verified #
Workspace.get_verified(self, root)
The bytes only if the object's whole closure is present and re-hashes, else refused unverified.
info #
Workspace.info(self)
This workspace's node: id, parent, parent revision, base, depth (a fork has a parent and depth + 1).
log_step #
Workspace.log_step(self, *, agent, cause, cause_kind, kind, parent=None, reads=(), output=None, output_kind=None)
Record one step of an agent's work: who, the digest of the instruction that caused it, its kind, its parent step, what it read, what it produced. Returns the step id.
merge #
Workspace.merge(self, child_path)
Bring a child home: its new objects, tags (as name@child) and lineage, re-judged from this workspace's own evidence.
merged_tags #
Workspace.merged_tags(self)
Tags that arrived by merge from a child, named name@child.
promote #
Workspace.promote(self, program, candidate, approved_by, receipt=None)
Move a program's head to a candidate, with its compare receipt and a named approver; the admin may promote only an identical result, anything else needs the owner (owner_approval_required).
put #
Workspace.put(self, raw)
Store bytes; returns their root (sha256 of the bytes). Idempotent; refused missing_dependency if a declared dep is absent.
refs #
Workspace.refs(self, prefix='')
Every retained root whose name starts with prefix.
register_program #
Workspace.register_program(self, name)
A program's reference: the digest of its own code (what a run is bound to).
repair #
Workspace.repair(self, peer)
Quarantine and refetch bad objects, heads and lineage from peer, an open Workspace (a parent or sibling); the audit chain is reported, never rewritten.
revision #
Workspace.revision(self)
The revision counter that expected_revision is checked against (one writer at a time).
rewards #
Workspace.rewards(self, lineage=None, via=None)
Reward rows, optionally for one lineage or via one step.
rollback #
Workspace.rollback(self, program, to, approved_by)
Move a program's head back to one of its previous heads.
search #
Workspace.search(self, kind, q_tokens, limit=8, source=None, before=None, window=None, max_visit=500000)
Nearest neighbours of a token query, answered by the store's owner (visit_cap bounds the work).
set_capability #
Workspace.set_capability(self, program, state, approved_by=None)
Change a program's capability state; Advisory needs a named approver; every change is logged.
snapshot #
Workspace.snapshot(self, source=None, commit=None)
Store every code byte of the engine package (or source, a package directory) and one version per program; nothing is overwritten.
submit #
Workspace.submit(self, request, source)
Run a request synchronously: completed only if the output equals the supplied expectation; an identical retry returns the stored outcome; the same request_id with a changed field is refused identity_reused.
tag #
Workspace.tag(self, name, root)
Retain a root under a name (an own head); tagged objects are part of the workspace's state and digest.
tags #
Workspace.tags(self)
This workspace's own tags: {name: root}.
trace #
Workspace.trace(self, step_id)
A step's chain back to the root instruction, nearest first (blame).
verify #
Workspace.verify(self)
Check everything: objects re-hash, dependencies, closures, the hash-linked audit chain, lineage. ok + per check.