Skip to content

Commit 8bef101

Browse files
committed
feat(reasoning): ReasoningEvent.controlFlow + control-flow eventType vocabulary
Adds an optional `controlFlow` object to ReasoningEvent and a reserved control-flow eventType vocabulary (reasoning.tool.called / decision.branched / subrun.spawned|joined / run.completed) so emitters can carry a run's OPERATIONAL control flow — tool calls, branches (with pre/post guard = WHILE/DO_WHILE), delegated sub-runs — for downstream narration-fidelity verification (SP-TRACE-CFR in agentplane). Backward-compatible: eventType stays a free string, controlFlow is optional, additionalProperties already true. Operational structure only (site/branch/guard/ sidechain/arg) — no raw reasoning; traceLevel/trustLevel continue to scope disclosure and provenance. controlFlow.arg carries argument-level trustLevel for IFC/taint. - docs/reasoning-control-flow-events.md (vocabulary + emit->verify flow + privacy note) - examples/reasoning_event_control_flow.json (validated) - schema + both examples validate; make validate passes
1 parent e54336c commit 8bef101

4 files changed

Lines changed: 76 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). Thi
99
## [Unreleased]
1010

1111
### Added
12+
- `ReasoningEvent.controlFlow` (optional) + a reserved control-flow `eventType` vocabulary (`reasoning.tool.called` / `reasoning.decision.branched` / `reasoning.subrun.spawned` / `reasoning.subrun.joined` / `reasoning.run.completed`) so emitters can carry a run's operational control flow for downstream narration-fidelity verification (SP-TRACE-CFR). Backward-compatible; operational structure only (no raw reasoning). See `docs/reasoning-control-flow-events.md` and `examples/reasoning_event_control_flow.json`.
1213
- SourceOS interaction substrate top-level index and README discovery links for `SourceOSInteractionEvent`, generated TypeScript/Python artifacts, and the Noetica → Superconscious → AgentPlane → AgentTerm reference flow.
1314
- Runtime observability and capability governance contracts: `CapabilityLedger`, `BrowserAutomationReceipt`, `GitWorkspaceState`, `OrphanEventReceipt`, and `RuntimeInstallReceipt` with canonical examples, validation wiring (`tools/validate_runtime_observability_examples.py`), a contract catalog, and ADR-0012.
1415
- Reasoning run contracts: `ReasoningRun`, `ReasoningEvent`, `ReasoningReceipt`, `ReasoningReplayPlan`, and `ReasoningBenchmark` with canonical examples and a contract-additions note for the Superconscious reference loop.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Reasoning Control-Flow Events
2+
3+
**Status:** additive extension to `ReasoningEvent` (v2). Backward-compatible: `eventType`
4+
stays a free string and `controlFlow` is optional.
5+
6+
## Purpose
7+
8+
`ReasoningRun` records run lifecycle; it did not carry the *control-flow* of a run
9+
(the sequence of tool calls, branches, and delegated sub-runs). Downstream
10+
narration-fidelity verification (SP-TRACE-CFR) recovers orchestration structure from
11+
this control flow to check that an agent's stated narration matches what it actually
12+
did. This extension lets emitters (Noetica → Superconscious → AgentPlane → AgentTerm,
13+
TurtleTerm, BearBrowser) produce that structure.
14+
15+
**Privacy posture (intentional):** control-flow events carry *operational structure
16+
only* — a site id, a branch label, a guard position, a sub-run id — never raw model
17+
reasoning. `traceLevel` and `trustLevel` continue to scope disclosure and provenance.
18+
This is the "verify what the agent did, not what it thought" guarantee.
19+
20+
## Reserved control-flow eventTypes
21+
22+
| `eventType` | `controlFlow` fields | Recovered structure |
23+
|---|---|---|
24+
| `reasoning.tool.called` | `site` | a tool-call node |
25+
| `reasoning.decision.branched` | `site`, `branchTaken`, `guardPosition?` | branch / loop guard (pre=WHILE, post=DO_WHILE) |
26+
| `reasoning.subrun.spawned` | `site`, `sidechainId` | delegated sub-run entry (SESE) |
27+
| `reasoning.subrun.joined` | `site`, `sidechainId` | delegated sub-run return |
28+
| `reasoning.run.completed` | `site` | terminal |
29+
30+
`site` is a stable orchestration-site identity (the decision-fold key — not a payload
31+
hash). Events are consumed in the run's causal order.
32+
33+
## Argument-level provenance
34+
35+
A `reasoning.tool.called` event MAY set `controlFlow.arg` to name the argument whose
36+
provenance carries this event's `trustLevel`. Consumers map `trustLevel` onto an
37+
integrity lattice for argument-level information-flow control (e.g. an argument derived
38+
from `untrusted-observation` is denied at a trusted sink).
39+
40+
## Consumer
41+
42+
AgentPlane's `sp-run narration-gate` / `sp-run attest-run` project a stream of these
43+
events into a control-flow segment, recover it with two engines, compare it against the
44+
agent's narration claims, and emit a signed run attestation. See
45+
`agentplane/tools/trace_cfr_reasoning_bridge.py`.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"id": "urn:srcos:reasoning-event:demo-dowhile-guard",
3+
"type": "ReasoningEvent",
4+
"specVersion": "2.0.0",
5+
"runRef": "urn:srcos:reasoning-run:superconscious-demo",
6+
"eventType": "reasoning.decision.branched",
7+
"summary": "Loop guard evaluated after the body executed (post-checked).",
8+
"traceLevel": "workspace-safe",
9+
"trustLevel": "trusted-control-input",
10+
"capturedAt": "2026-07-04T00:00:00Z",
11+
"controlFlow": {
12+
"site": "retry-loop-guard",
13+
"branchTaken": "false",
14+
"guardPosition": "post"
15+
}
16+
}

schemas/ReasoningEvent.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@
1515
"summary": { "type": "string" },
1616
"traceLevel": { "enum": ["public-safe", "workspace-safe", "operator-private", "restricted"] },
1717
"trustLevel": { "enum": ["trusted-control-input", "trusted-workspace-source", "semi-trusted-project-source", "untrusted-observation", "restricted-material"] },
18-
"capturedAt": { "type": "string", "format": "date-time" }
18+
"capturedAt": { "type": "string", "format": "date-time" },
19+
"controlFlow": {
20+
"type": "object",
21+
"description": "Optional operational control-flow annotation. Present on the reserved control-flow eventTypes so downstream consumers can recover orchestration structure (e.g. SP-TRACE-CFR narration-fidelity verification) WITHOUT collecting raw reasoning — operational structure only, honoring traceLevel/trustLevel. Reserved eventTypes: 'reasoning.tool.called' (site), 'reasoning.decision.branched' (site, branchTaken, guardPosition), 'reasoning.subrun.spawned' / 'reasoning.subrun.joined' (site, sidechainId), 'reasoning.run.completed' (site).",
22+
"properties": {
23+
"site": { "type": "string", "description": "Stable orchestration-site identity; the decision-fold key (not a payload hash)." },
24+
"branchTaken": { "type": ["string", "null"], "description": "Edge label on a decision successor (e.g. true/false/case:k)." },
25+
"guardPosition": { "enum": ["pre", "post", null], "description": "Loop guard relative to first body execution: pre = pre-checked (WHILE), post = post-checked (DO_WHILE)." },
26+
"sidechainId": { "type": ["string", "null"], "description": "Delegated sub-run id for spawn/join (SESE sidechain)." },
27+
"arg": { "type": ["string", "null"], "description": "Argument name whose provenance carries this event's trustLevel (argument-level taint / IFC)." }
28+
},
29+
"required": ["site"],
30+
"additionalProperties": true
31+
}
1932
}
2033
}

0 commit comments

Comments
 (0)