Skip to main content
Install from source while the PyPI release is pending:
When PyPI is live, use uv add noesis or pip install noesis. Import as import noesis as ns.

Core functions

ns.run()

Execute a baseline episode using the current session.
string
required
Task or goal for the episode.
int
default:"0"
Seed for reproducibility.
bool | Intuition | None
default:"True"
True enables the default intuition policy, False disables it, or pass an Intuition implementation.
dict
Metadata tags attached to the episode.
RuntimeContext
default:"None"
Optional runtime context. If provided, execution bypasses the default session.
str | Path | None
default:"None"
Workspace root to snapshot for verification.
VerifySpec | Sequence[VerifySpec] | None
default:"None"
Verification assertions to evaluate against the workspace.
Returns: Episode ID (e.g., "ep_01JH6Z2V9Q2K6Y6N0QZ7K2QW8C") Example:
Runtime context example:
context is a RuntimeContext (a ports container). For metadata, prefer tags={...}.

ns.solve()

Execute an episode through a specific adapter/graph.
GraphSource
required
Adapter name/import path or callable to execute the task.
Example:

Run lifecycle APIs

Use these APIs for approval gates and same-run continuation. Simple mental model:
  • interrupt and checkpoint pause a run with audit evidence.
  • resume emits lifecycle evidence only (run.resume).
  • resume_run emits run.resume and continues execution.

Lifecycle flow (easy)

Determinism scope:
  • Noēsis enforces immutable, append-only artifacts and replay discipline.
  • External tool/LLM outputs may still vary unless your environment captures/freezes them.
Continuation contract:
  • Same run ID.
  • Append-only artifacts preserved.
  • Resume continues post-plan by default (no replan) with anchor validation.
Adapter continuity:
  • resume_run(..., using=...) must match the persisted adapter from checkpoint/state.
  • For minimal runs (ns.run(...)), omitting using is allowed.

Common failure modes

  • RunSealedError: lifecycle writes and resume attempts are rejected once final.json seals the run.
  • CheckpointNotFoundError: resume/resume_run reference a checkpoint that does not exist.
  • MissingCausalParentError: checkpoint/interrupt cannot anchor to a causal parent event.
  • CheckpointConsistencyError: checkpoint anchor (event_offset, last_event_id, state_hash) no longer matches artifacts.
  • RunLifecycleTransitionError: lifecycle mutation violates the run state-machine contract.
  • ResumeAdapterRequiredError: resume_run requires explicit using for non-minimal checkpoints.
  • ResumeAdapterMismatchError: resume_run adapter does not match checkpoint adapter contract.
All errors above are defined in noesis.domain.run_lifecycle.

Verification helpers

Use these helpers to build verification specs for verify=....

ns.summary.read()

Load the summary for an episode.
Returns: Summary dictionary (task, metrics, flags, manifest, etc.).

ns.events.read()

Load the event timeline for an episode.
Set stream=True to iterate lazily. Integrity behavior:
  • Raises noesis.trace.events.EventLogIntegrityError when events.jsonl contains invalid UTF-8, malformed JSON, or a non-object record.
  • Uses fail-closed semantics: corrupted lines are not skipped.

noesis.io.list_runs()

List recent episodes (newest first).
Each row includes episode_id, task, started_at, flags, success, manifest, and manifest_status (when strict_manifest=True).
In v1.0.0, ns.list_runs() exists as a deprecated legacy alias. Prefer noesis.io.list_runs().

noesis.io.last()

Get the most recent episode ID.

ns.set() / ns.get()

Update or read the current configuration snapshot.
runs_dir points to the episodes root directory (for example, .noesis/episodes). Common keys: runs_dir, planner_mode (meta/minimal), direction_min_confidence, governance_mode (off/audit/enforce), governance_failure_policy, governance_timeout_ms (reserved/unused), governance_pause_on_veto, policy_aliases, learn_home, learn_mode, learn_auto_apply_min_confidence, learn_auto_apply_min_successes, intuition_mode, timeout_sec, prompt_provenance_enabled, prompt_provenance_mode, agents (reserved/unused), tasks (reserved/unused).

Intuition and policies

DirectedIntuition

Base class for policies that can emit hints, interventions, or vetoes.
Helper methods:
  • hint(advice, confidence=0.5, rationale=None, evidence_ids=None, target="input", scope="episode")
  • intervene(advice, patch, confidence=0.6, rationale=None, evidence_ids=None, target="input", scope="episode")
  • veto(advice, confidence=0.8, rationale=None, evidence_ids=None, target="plan", scope="episode")

IntuitionEvent (schema)

Fields include kind, advice, confidence, policy_id, policy_version, policy_kind, applied, rationale, evidence_ids, patch, target, scope, and blocking (plus schema_version).

NoesisVeto

Raised when a policy vetoes an episode.

Governance

Pre-act governance evaluates proposed actions before execution. Configure via ns.set(governance_mode=...).

GovernanceMode

GovernanceFailurePolicy

Default depends on mode: auditfail_open, enforcefail_closed.

GovernanceDecision

GovernanceResult

Immutable result from governance evaluation.

Custom governors

Custom governor injection is not part of the v1.0.0 runtime/CLI execution surface. Governance is configured via ns.set(governance_mode=..., governance_failure_policy=...) and uses the built-in pre-act governor.

Governed side effects (pre-act gating)

ns.governed_act(...) is the operating-system boundary for side effects. It executes through the same canonical runtime boundary used by ns.run(...) and ns.solve(...) (same finalization and sealing rules). Event paths:
  • allow/audit: action_candidate → governance → act
  • enforce veto (governance_pause_on_veto=False): action_candidate → governance → terminate (no act)
  • enforce veto with pause enabled (governance_pause_on_veto=True): action_candidate → governance → run.interrupt → run.checkpoint (no act, no terminate)
Artifact constraints:
  • terminal outcomes (allow/audit/veto terminate): run seals with final.json and manifest.json
  • paused-on-veto outcomes: run stays unsealed (no final.json / manifest.json yet) until continuation/termination
Supported kind values:
  • shell: requires ns.set(shell_executor=...)
  • adapter: requires ns.set(adapter_executor=...)
If the matching executor is not configured, ns.governed_act(...) raises ValueError before actuation.

Troubleshooting ns.governed_act(...)

Internal tool invocation use cases (adapter implementers)

Noesis also exposes an internal application contract for protocol adapters:
Use this contract when you need explicit prepare/approve/execute boundaries for side-effecting tools. The canonical identity key is run_id + draft_id. Execution-time failures are surfaced as typed errors from noesis.domain.tool_contract:
  • PreparedToolInvocationNotFoundError
  • ApprovalDecisionRequiredError
  • ApprovalDecisionBindingError
For full workflow, event ordering, and troubleshooting guidance, see Integrate adapters.

Session management

Use sessions when you need isolated configuration, explicit lifecycle control, or registered ports.
SessionBuilder reads config from env/TOML; you can also inject ports before building. Within a session, run/solve behave like the module-level helpers but share the session’s config and runtime context.

Module facades

  • ns.summary.read(episode_id, context=None): read summary.json.
  • ns.events.read(episode_id, stream=False, context=None): iterate events; pass stream=True to lazily consume.
  • ns.context: helpers for building runtime contexts and attaching ports (advanced use — see the “Add a memory port” guide).
  • ns.learn: learning signal emission and proposal management (see Learning section below).

Learning

The learning subsystem records proposals from episode outcomes for policy improvement.

LearnMode

Configure via ns.set(learn_mode="record").

LearnStatus

LearnProposal

Dataclass for learning signals. Contains kind, payload, confidence, status, and metadata.
In v1.0.0, learning proposals are emitted automatically during summary finalization when learn_mode is enabled. When proposals are generated, they are written to learn.jsonl for the episode and tracked under learn_home.

Helper functions

Episode index

EpisodeIndex

Manage an on-disk episode manifest (and optional FAISS similarity index).
Core methods:
  • append(episode_id, summary_path, state_path, status, task, using, provenance=None, embedding=None)
  • iter(include_expired=False) → iterator of EpisodeRecord
  • search(embedding, k=5) → similarity matches (empty if FAISS disabled)
  • vacuum() → prune expired records

Type definitions

IntuitionEvent

Returned by policy methods. See schema above for fields.

Determinism utilities

For reproducible testing and replay, Noesis exports deterministic clock and RNG utilities:
These are used internally by the replay gate to ensure artifact determinism. Exposed for custom test harnesses and advanced integrations.

Environment variables

Next steps

CLI reference

Command-line interface documentation.

Write policies

Create intuition policies.