API reference
This page is generated from backend/orbit_sdk.py at documentation build time.
Runner context
RunnerContext
dataclass
Per-phase SDK interface supplied to a runner handler.
Do not construct this class in a normal runner. Decorate a function with
@runner.phase(...) and Orbit creates the context when it invokes that
phase. The context is scoped to one process invocation and one iteration.
Attributes:
| Name | Type | Description |
|---|---|---|
phase |
str
|
The lifecycle phase currently being invoked. |
target_repository |
Path
|
Root directory of the evaluated target. |
mode |
str
|
Execution mode, normally |
loop_index |
int
|
One-based evaluation iteration number. |
environment |
dict[str, str]
|
Environment snapshot passed to the runner process. |
resources
property
Return the immutable resource snapshot provided for this invocation.
The snapshot can contain the workflow, build, fixed test cases, model profile, and execution-environment settings. Prefer the typed convenience properties when one is available.
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Immutable resource values supplied for this invocation. |
project_root
property
Evaluation target root; use this instead of a machine-specific path.
Returns:
| Type | Description |
|---|---|
Path
|
Resolved root directory of the evaluated target. |
app_data
property
Orbit's per-user writable data directory.
Returns:
| Type | Description |
|---|---|
Path
|
Writable Orbit AppData directory. |
workflow
property
Return the workflow snapshot supplied by Orbit for this invocation.
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Immutable workflow metadata, or an empty mapping when unavailable. |
build
property
Return the build snapshot supplied by Orbit.
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Immutable build metadata, or an empty mapping when unavailable. |
test_cases
property
Return the fixed target test cases selected for this build.
Returns:
| Type | Description |
|---|---|
list[dict[str, object]]
|
Selected fixed test-case definitions. |
previous_supervisor_feedback
property
Return the latest completed supervisor response for this run.
Runner phases run in separate subprocesses. Reading the retained run record lets the next iteration use the previous iteration's feedback without coupling a runner to a target-specific state file.
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Latest completed supervisor response, or an empty mapping when unavailable. |
function(function_id)
Record one graph-annotated function's outcome within this lifecycle phase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function_id
|
str
|
Stable graph function identifier shown in retained run evidence. |
required |
Yields:
| Type | Description |
|---|---|
None
|
Control to the wrapped function body. |
project_path(*parts)
Resolve a target-repository path without allowing path traversal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*parts
|
str
|
Relative path components inside :attr: |
()
|
Returns:
| Type | Description |
|---|---|
Path
|
An absolute target-repository path. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the path escapes the target repository. |
managed_asset_dir(name)
Return a private, runner-managed AppData directory for a named asset set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Non-empty relative name for the runner-owned asset set. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Writable AppData directory isolated from the target repository. |
load_state(name, default=None, *, scope='runner')
Load mutable runner- or build-scoped state from Orbit AppData.
State is separate from immutable run evidence. Use it only for bounded continuation data required by a later run, such as a persona's last observation or next check. State values must be JSON-safe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Stable state name containing letters, numbers, underscores, or hyphens. |
required |
default
|
object
|
Value returned when no saved state exists. |
None
|
scope
|
str
|
|
'runner'
|
Returns:
| Type | Description |
|---|---|
object
|
The saved JSON value or |
save_state(name, value, *, scope='runner')
Atomically save mutable runner- or build-scoped state in Orbit AppData.
The value is not copied into run evidence. Emit a bounded summary with
:meth:emit_result when a particular state transition needs auditing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Stable state name containing letters, numbers, underscores, or hyphens. |
required |
value
|
object
|
JSON-safe value to retain for a later invocation of this build. |
required |
scope
|
str
|
|
'runner'
|
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
State name, update timestamp, and JSON byte size. |
materialize_assets(name, files)
Atomically materialize runner-owned files outside the target repository.
Use this for temporary scripts, fixtures, or adapter configuration that belongs to the runner rather than the evaluated project. Orbit emits a manifest with content hashes as step evidence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Stable relative name for this runner-managed asset set. |
required |
files
|
dict[str, str | bytes]
|
Relative paths and their UTF-8 text or byte content. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
The asset directory, manifest SHA-256, and hashes by file path. |
write_artifact(relative_path, content, *, content_type='application/octet-stream')
Persist immutable run evidence in AppData and attach its metadata to the step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relative_path
|
str | Path
|
Relative evidence path within the current run and iteration. |
required |
content
|
str | bytes
|
Text or bytes to retain. |
required |
content_type
|
str
|
MIME type used when the artifact is presented. |
'application/octet-stream'
|
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Artifact path, SHA-256, size, content type, and relative path. |
save_data_file(relative_path, content, *, label='', content_type='application/octet-stream')
Save a developer-named data file for the current evaluation iteration.
Call this from any lifecycle phase where the data becomes meaningful. The label is display metadata for the evaluation UI, not a filesystem name; it can describe why this file was retained. The UI exposes both the actual filename and the full AppData path for copying.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relative_path
|
str | Path
|
Relative file path within this run and iteration. |
required |
content
|
str | bytes
|
Text or bytes to retain. |
required |
label
|
str
|
Optional human-readable display name for this data file. |
''
|
content_type
|
str
|
MIME type used when the file is presented. |
'application/octet-stream'
|
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
File metadata, including the label, actual filename, and path. |
git_candidate(paths=None, *, retain_patch=False)
Summarize the current Git candidate without flooding runner output with its diff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
list[str] | None
|
Optional target-relative paths to limit the Git diff. |
None
|
retain_patch
|
bool
|
Store the binary diff as an artifact when it is non-empty. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
A candidate fingerprint, changed paths, and optionally patch metadata. |
git_head()
Return the checked-out commit, or None when the target is not a Git repository.
Returns:
| Type | Description |
|---|---|
str | None
|
Checked-out commit SHA, or |
snapshot_repository(label, *, once=False)
Store the complete target worktree as Git objects without creating a commit.
The snapshot includes tracked, staged, untracked, and ignored files, together with the original index tree and HEAD reference. Git's object database deduplicates unchanged file blobs; Orbit keeps a private ref only so these otherwise-uncommitted objects survive Git garbage collection. The ref is not a branch, tag, or commit-history entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
Stable checkpoint name such as |
required |
once
|
bool
|
Return the existing checkpoint with this label for the run, rather than recording another one. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Immutable snapshot metadata, including its worktree tree hash. |
repository_snapshots()
List retained repository snapshots, newest first.
Returns:
| Type | Description |
|---|---|
list[dict[str, object]]
|
Retained snapshot metadata ordered newest first. |
restore_repository_snapshot(snapshot_id)
Restore a repository snapshot without checking out or creating a commit.
Restoring returns the target worktree, index, and HEAD reference to the recorded state. It also removes files created after the snapshot, including ignored and untracked files inside the target repository. Call this only while Orbit exclusively owns the target repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot_id
|
str
|
Identifier returned by :meth: |
required |
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Restored snapshot metadata and restoration timestamp. |
save_before_each_snapshot()
Save this run's baseline once from a before_each handler.
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Baseline snapshot metadata, reusing an existing baseline for this run. |
save_first_after_each_snapshot()
Save the first completed iteration from an after_each handler.
Returns:
| Type | Description |
|---|---|
dict[str, object] | None
|
First-iteration snapshot metadata, or |
restore_before_each_snapshot()
Restore the baseline saved by :meth:save_before_each_snapshot in after_all.
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Restored baseline metadata. |
record_commit_change(before)
Retain commit-range evidence when a runner phase advances the target HEAD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
before
|
str | None
|
Commit SHA observed before the runner action. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, object] | None
|
Commit-range evidence when HEAD changed, otherwise |
windows_path(value)
Convert a WSL-mounted path to a Windows path for a Windows child process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str | Path
|
Path below a WSL |
required |
Returns:
| Type | Description |
|---|---|
str
|
Equivalent Windows drive path. |
update_file(relative_path, content, *, encoding='utf-8')
Atomically update a project file, retaining its pre-update version.
Snapshots and their metadata live under Orbit AppData rather than the
target repository. Each changed write retains the prior bytes together
with the runner iteration, phase, run ID, timestamp, and SHA-256 hashes.
Use :meth:file_versions to inspect retained versions and
:meth:rollback_file to restore a selected one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relative_path
|
str | Path
|
Target-repository-relative file path to update. |
required |
content
|
str | bytes
|
UTF-8 text or raw bytes to write. |
required |
encoding
|
str
|
Encoding used when |
'utf-8'
|
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Change status, content hash, target path, and retained version metadata. |
file_versions(relative_path)
List retained pre-update versions for a project file, newest first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relative_path
|
str | Path
|
Target-repository-relative file path. |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, object]]
|
Retained version metadata ordered newest first. |
rollback_file(relative_path, version_id)
Restore the pre-update state retained by version_id.
Rolling back first snapshots the current file as a new version. This makes a rollback reversible: call this method again using that newly returned version ID to return to the state before the rollback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relative_path
|
str | Path
|
Target-repository-relative file path to restore. |
required |
version_id
|
str
|
Retained version identifier to restore. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Restored path, selected version ID, and metadata for the new rollback version. |
proposal_decisions()
Return recorded accepted/rejected proposals for this target, newest first.
Returns:
| Type | Description |
|---|---|
list[dict[str, object]]
|
Proposal decision and application events ordered newest first. |
record_proposal_decision(proposal, decision, *, proposal_id=None, rationale='')
Persist an auditable accepted or rejected improvement proposal.
The ledger is stored in Orbit AppData, outside the target repository. Repeating the same decision for unchanged proposal content is idempotent, while a changed decision is appended as a new event. This produces a compact event stream for a future proposal-review UI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proposal
|
dict[str, object]
|
JSON-safe proposal payload being decided. |
required |
decision
|
Literal['accepted', 'rejected']
|
|
required |
proposal_id
|
str | None
|
Optional stable external identifier for the proposal. |
None
|
rationale
|
str
|
Optional human-readable decision reason. |
''
|
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Whether an event was newly recorded and its decision record. |
record_proposal_application(proposal_ids, file_update)
Link accepted proposals to the prompt version they changed.
This is an append-only lifecycle event. It lets a review UI traverse from a decision to an exact prompt snapshot and its rollback version without mutating the original decision record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proposal_ids
|
list[str]
|
Accepted proposal identifiers linked to the file update. |
required |
file_update
|
dict[str, object]
|
Metadata returned by :meth: |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, object]]
|
Newly recorded proposal-application events. |
accept_proposal(proposal, *, proposal_id=None, rationale='')
Record that a proposal was selected for this target's improvement history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proposal
|
dict[str, object]
|
JSON-safe proposal payload to accept. |
required |
proposal_id
|
str | None
|
Optional stable external proposal identifier. |
None
|
rationale
|
str
|
Optional human-readable acceptance reason. |
''
|
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Whether an event was newly recorded and its decision record. |
reject_proposal(proposal, *, proposal_id=None, rationale='')
Record that a proposal was not selected for this target's improvement history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proposal
|
dict[str, object]
|
JSON-safe proposal payload to reject. |
required |
proposal_id
|
str | None
|
Optional stable external proposal identifier. |
None
|
rationale
|
str
|
Optional human-readable rejection reason. |
''
|
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Whether an event was newly recorded and its decision record. |
resource(name, default=None)
Read a named value from Orbit's immutable resource snapshot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Resource name, such as |
required |
default
|
object
|
Value returned when the resource is absent. |
None
|
Returns:
| Type | Description |
|---|---|
object
|
The requested resource value or |
complete_model(prompt)
Run one target-AI turn using the build's configured model profile.
The profile contains provider settings only; its credential remains in the configured environment variable and is never emitted as evidence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Target-AI input to send using the configured model profile. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Profile name, resolved model name, and target-AI response text. |
log(message)
Write an Orbit runner-progress message to the workflow log.
This is for runner lifecycle and adapter progress. It is intentionally
different from :meth:target_log, which records events emitted by the
evaluated target and appears separately in the run's Logs tab.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable lifecycle progress message. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
target_log(message, *, level='info', source='', timestamp=None)
Attach one bounded log line produced by the evaluation target.
Target logs are kept separately from Orbit's runner and workflow output. Call this from an adapter after it has collected a relevant target-side event; it is not intended to mirror the runner's own stdout. Orbit adds the run ID, iteration, and lifecycle phase before retaining the entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Non-empty target event text. It is trimmed to 4,000 characters. |
required |
level
|
str
|
One of |
'info'
|
source
|
str
|
Optional stable target-service name, trimmed to 256 characters. |
''
|
timestamp
|
str | None
|
Optional ISO-8601 timestamp. UTC time is used when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the message is empty, level is unsupported, or timestamp is not a string. |
emit_result(values)
Attach JSON-safe structured evidence to the current Orbit step.
Use this for machine-consumed evidence such as scores, metrics, or
proposal records. Values must be JSON serializable. Repeated result
objects are merged by key, so prefer a single object for related data;
use :meth:target_log for append-only target logging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
dict[str, object]
|
JSON-safe evidence object to attach to the current step. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
playwright_journey(cases=None)
Run bounded, read-only Playwright page checks for the supplied cases.
The browser process is short lived. Scheduling, locking, and any application-server lifecycle remain Orbit's responsibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cases
|
list[dict[str, object]] | None
|
Optional fixed cases to run. The build's selected cases are used when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
Per-case pass/fail evidence, screenshots, page HTML, and artifact directory metadata. |
exec(command, *, cwd=None, timeout=None, env=None, input=None, target_log_source=None, target_log_exclude_prefixes=())
Run one bounded child command and return its captured output.
A runner phase is deliberately not a scheduler. Returning the output lets a phase turn its one-shot result into Orbit-owned structured evidence without starting a persistent child daemon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
list[str]
|
Executable and arguments, passed without a shell. |
required |
cwd
|
Path | None
|
Child working directory; defaults to the target repository. |
None
|
timeout
|
int | None
|
Maximum duration in seconds; no timeout when omitted. |
None
|
env
|
dict[str, str] | None
|
Environment values that supplement the runner environment. |
None
|
input
|
str | None
|
Optional standard input sent to the child before its output is collected. |
None
|
target_log_source
|
str | None
|
When set, forward bounded child-output lines to the target-log stream under this source name. |
None
|
target_log_exclude_prefixes
|
tuple[str, ...]
|
Output prefixes retained for the caller but excluded from target logs, for structured child results. |
()
|
Returns:
| Type | Description |
|---|---|
str
|
Combined standard output and standard error from the child. |
Raises:
| Type | Description |
|---|---|
TimeoutExpired
|
If the child exceeds |
SystemExit
|
If the child exits with a non-zero status. |
Runner registration
Runner
Register lifecycle handlers and dispatch the phase requested by Orbit.
phase(name)
Register a function as a handler for one runner lifecycle phase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Lifecycle phase name, normally one of |
required |
Returns:
| Type | Description |
|---|---|
Callable[[Callable[[RunnerContext], None]], Callable[[RunnerContext], None]]
|
A decorator that leaves the registered handler unchanged. |
main()
Dispatch the phase passed by Orbit and retain any commit-range evidence.
Place runner.main() behind an if __name__ == "__main__" guard
in every runner asset. Orbit supplies the --phase argument and
process environment; callers should not invoke this method directly.
Returns:
| Type | Description |
|---|---|
None
|
|