Skip to content

Context Governance

Context governance controls which workflow state each block can read. Blocks receive only the values named in their inputs map. A block with no inputs receives empty inputs.

The same declarations are used for normal execution, isolated subprocess envelopes, audit events, historical API responses, live Server-Sent Events, and the GUI audit panel.

Use inputs to map local input names to context references.

custom/workflows/context-example.yaml
version: "1.0"
kind: workflow
workflow:
name: Context example
entry: draft
blocks:
draft:
type: linear
soul_ref: writer
inputs:
request:
from: workflow.request
safe_to_publish:
from: shared_memory.flags.safe
branch:
from: metadata.runtime.branch
review:
type: linear
soul_ref: reviewer
depends: draft
inputs:
draft_summary:
from: draft.summary
Local inputReferenceMeaning
requestworkflow.requestReads workflow-seeded input named request.
safe_to_publishshared_memory.flags.safeReads safe from shared memory source flags.
branchmetadata.runtime.branchReads branch from metadata source runtime.
draft_summarydraft.summaryReads summary from the upstream draft block result.

Runsight does not backfill legacy state into blocks that do not declare inputs. Code blocks follow the same rule as every other block: their subprocess receives exactly ctx.inputs.

Every block definition supports the inputs field. The effective context mode is always declared.

FieldTypeDefaultDescription
inputsDict[str, InputRef]noneLocal input name to context reference mapping.
inputs.<name>.fromstrrequiredContext reference to resolve for this local input.

Constraints:

RuleBehavior
Block with inputsResolves only the listed inputs.
Block without inputsProvides empty inputs.
Unsupported context mode field valuesInvalid workflow YAML.
Reserved local input namesInvalid workflow YAML.

The following local input names are reserved:

Reserved inputUse
workflowWorkflow-seeded run input reference root.
resultsExplicit block result namespace root.
shared_memoryShared memory namespace root.
metadataRuntime metadata namespace root.
blocksEngine orchestration context.
ctxEngine orchestration context.
call_stackEngine orchestration context.
workflow_registryEngine orchestration context.
observerEngine orchestration context.

The following block IDs are reserved and cannot be used as normal block IDs:

Reserved IDUse
workflowWorkflow-seeded run input reference root.
resultsExplicit block result namespace root.
shared_memoryShared memory namespace root.
metadataRuntime metadata namespace root.

A from reference identifies a namespace, source, and optional field path.

ReferenceNamespaceSourceField pathDescription
draft.summaryresultsdraftsummaryShorthand for an upstream block result.
results.draft.summaryresultsdraftsummaryExplicit upstream block result reference.
workflow.requestresultsworkflowrequestWorkflow-seeded input named request.
shared_memory.flags.safeshared_memoryflagssafeShared memory value.
metadata.runtime.branchmetadataruntimebranchRuntime metadata value.

Workflow-seeded input is represented in audit records as namespace: "results" and source: "workflow". It is not a separate namespace.

Allowed audit namespaces:

NamespaceDescription
resultsWorkflow-seeded input or block output.
shared_memoryShared memory state.
metadataRuntime metadata.

Runsight resolves context in one of two governance modes.

ModeDefaultMissing or denied readData exposure
strictyesFails the block and emits an audit event.Denied or missing values are not exposed.
devnoEmits a warning audit record.Denied or missing values are not exposed.

Dev mode is for development feedback. It does not grant undeclared data, backfill missing values, or create implicit broad state access.

Historical API responses and live context_resolution SSE events use the same event shape.

FieldTypeDescription
schema_versionstrAudit event schema version. Current value: context_audit.v1.
eventstrEvent name for the payload.
run_idstrRun that emitted the event.
workflow_namestrWorkflow name.
node_idstrBlock ID from the workflow YAML.
block_typestrBlock type, such as linear, code, or workflow.
access"declared"Context mode used for the block.
mode"strict" or "dev"Governance mode used for resolution.
sequenceint or nullEvent sequence when available.
recordsContextAuditRecordV1[]Zero or more per-input resolution records.
resolved_countintNumber of resolved records.
denied_countintNumber of denied records.
warning_countintNumber of warning records.
emitted_atstrEvent timestamp.

Example event:

ContextAuditEventV1
{
"schema_version": "context_audit.v1",
"event": "context_resolution",
"run_id": "8f7a23d2-3a2d-4e9a-8a3e-4df9a37c5a91",
"workflow_name": "Context example",
"node_id": "draft",
"block_type": "linear",
"access": "declared",
"mode": "strict",
"sequence": 12,
"records": [
{
"input_name": "request",
"from_ref": "workflow.request",
"namespace": "results",
"source": "workflow",
"field_path": "request",
"status": "resolved",
"severity": "allow",
"value_type": "str",
"preview": "Summarize the launch notes",
"reason": null,
"internal": false
}
],
"resolved_count": 1,
"denied_count": 0,
"warning_count": 0,
"emitted_at": "2026-04-17T09:30:00Z"
}

A declared block with no inputs emits an event with empty records and zero counts.

Declared block with no inputs
{
"schema_version": "context_audit.v1",
"event": "context_resolution",
"run_id": "8f7a23d2-3a2d-4e9a-8a3e-4df9a37c5a91",
"workflow_name": "Context example",
"node_id": "start",
"block_type": "linear",
"access": "declared",
"mode": "strict",
"sequence": 1,
"records": [],
"resolved_count": 0,
"denied_count": 0,
"warning_count": 0,
"emitted_at": "2026-04-17T09:30:00Z"
}

preview is for diagnostics only. It can be redacted or truncated and is not the full payload.

Each event contains zero or more ContextAuditRecordV1 records.

FieldTypeDescription
input_namestr or nullLocal input name.
from_refstr or nullOriginal YAML from reference.
namespace"results", "shared_memory", or "metadata"Context namespace used for the read.
sourcestr or nullSource inside the namespace, such as a block ID, workflow, flags, or runtime.
field_pathstr or nullNested field path inside the source.
statusstrResolution outcome.
severitystrAudit severity.
value_typestr or nullType name for the resolved value when available.
previewstr or nullRedacted or truncated diagnostic preview.
reasonstr or nullExplanation for missing, denied, or warning records.
internalboolWhether the record is internal runtime context.

Status values:

StatusMeaning
resolvedThe declared reference resolved successfully.
missingThe declared reference did not exist.
deniedThe read was not allowed by the declaration or policy.
emptyNo declared reads were needed.

Severity values:

SeverityMeaning
allowResolution succeeded without warning.
warnResolution produced a development warning or non-fatal warning.
errorResolution failed in strict mode or was denied.

Access values:

AccessMeaning
declaredThe block received only declared inputs.
GET /api/runs/{run_id}/context-audit

Response shape:

FieldTypeDescription
itemsContextAuditEventV1[]Audit events for the run.
page_sizeintNumber of events requested.
has_next_pageboolWhether another page is available.
end_cursorstr or nullCursor for the next page.

Live streams use event name context_resolution.

SSE event
event: context_resolution
data: {"schema_version":"context_audit.v1","event":"context_resolution","run_id":"8f7a23d2-3a2d-4e9a-8a3e-4df9a37c5a91","workflow_name":"Context example","node_id":"draft","block_type":"linear","access":"declared","mode":"strict","sequence":12,"records":[],"resolved_count":0,"denied_count":0,"warning_count":0,"emitted_at":"2026-04-17T09:30:00Z"}

Historical replay and live SSE use the same ContextAuditEventV1 payload shape.

The GUI merges historical audit events with live SSE events and deduplicates records for the run.

The audit panel displays:

ColumnMeaning
NodeBlock ID that resolved context.
InputLocal input name.
ReferenceOriginal from reference.
StatusResolution status, such as resolved, missing, denied, or empty.
SeverityResolution severity: allow, warn, or error.

Badges:

BadgeSourceMeaning
Access declaredaccess: "declared"The block received only declared inputs.
Resolveddenied_count: 0, warning_count: 0No denied or warning records.
Denied Ndenied_countOne or more denied records.
Warning Nwarning_countOne or more warning records.
CaseBehavior
No inputsThe block receives empty inputs and emits an audit event with records: [], resolved_count: 0, denied_count: 0, and warning_count: 0.
Missing reference in strict modeThe block fails and an audit event is emitted.
Missing reference in dev modeThe block continues with a warning, but the missing value is not exposed.
Denied read in strict modeThe block fails and an audit event is emitted.
Denied read in dev modeThe block continues with a warning, but the denied value is not exposed.
workflow.requestAudited as namespace: "results", source: "workflow", field_path: "request".
Audit previewRedacted or truncated diagnostic text, not the full value.

Context governance is least-privilege by default. YAML declarations are the source of truth for what a block can read, and the same declarations are used for isolated execution and audit reporting.