docs/agent-api/ruby-workflow-0.1.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>ruby.workflow//0.1 payload contract — EzAgent agent API</title>
<style>
:root {
color-scheme:dark;
--bg:#0d1319;
--panel:#151d26;
--panel2:#1b2530;
--line:#2b3947;
--text:#e7edf3;
--muted:#9eacba;
--accent:#69d2ff;
--ok:#9ed477
}
* {
box-sizing:border-box
}
body {
max-width:1000px;
margin:auto;
padding:32px 20px 64px;
background:var(--bg);
color:var(--text);
font:16px/1.55 system-ui,-apple-system,Segoe UI,sans-serif
}
h1,h2 {
line-height:1.2
}
h1 {
margin-bottom:.35rem
}
h2 {
margin-top:2.2rem
}
a {
color:var(--accent)
}
code,pre {
font-family:ui-monospace,SFMono-Regular,Menlo,monospace
}
code {
color:#b9e4ff;
overflow-wrap:anywhere
}
pre {
overflow:auto;
padding:14px;
border:1px solid var(--line);
border-radius:8px;
background:#080d12;
color:#dce8f2
}
table {
width:100%;
border-collapse:collapse;
margin:1rem 0
}
th,td {
padding:.65rem;
vertical-align:top;
text-align:left;
border:1px solid var(--line)
}
th {
background:var(--panel2)
}
.lead,.notice {
padding:18px 20px;
border:1px solid var(--line);
border-radius:10px;
background:var(--panel)
}
.lead p:last-child,.notice p:last-child {
margin-bottom:0
}
.notice {
border-left:4px solid var(--accent)
}
.muted {
color:var(--muted)
}
.ok {
color:var(--ok)
}
ul {
padding-left:1.3rem
}
li+li {
margin-top:.35rem
}
footer {
margin-top:3rem;
color:var(--muted);
font-size:.9rem
}
</style>
</head>
<body>
<header class="lead">
<h1><code>ruby.workflow//0.1</code> payload contract</h1>
<p>Descriptor and CSV reply convention for observing Ruby Workflow state. It is a <strong>lossy visualization
contract</strong>, not a JSONL frame set: it rides generic
<a href="jsonl-api.html#report_progress"><code>report_progress</code></a>/<a href="jsonl-api.html#leaf_updated"><code>leaf_updated</code></a> and <a href="jsonl-api.html#macro_call_ipc"><code>macro_call_ipc</code></a>/<a href="jsonl-api.html#macro_result_ipc"><code>macro_result_ipc</code></a> frames. The prepared Ruby Workflow adapts its prepared append-only graph to this existing 0.1 payload; there is no 0.2 payload, new endpoint, frame, schema, or Go decoder.</p>
<p>This page is not for:</p>
<ul>
<li>Frame lifecycle, correlation, and IPC → <a href="jsonl-api.html">JSONL API</a></li>
<li>Comma quoting and parsing → <a href="ez-agent-csv.html">EzAgent CSV</a></li>
<li>Workflow-library lifecycle and callback ordering → <a href="ruby-workflow-lifecycle.html">Workflow
lifecycle for authors</a></li>
<li>Exact Workflow signatures and edge cases → <a href="../ez-agent-ruby/lib/ez_agent/workflow.md">Ruby
Workflow API reference</a></li>
<li>Frontend behavior → <a href="../pkg/tui.md">TUI documentation</a></li>
</ul>
</header>
<h2 id="discovery">How is the visualizer discovered?</h2>
<p>A compatible producer publishes both descriptor fields in <a href="jsonl-api.html#report_progress">generic
progress</a>: <code>visualizer_type=ruby.workflow//0.1</code> and a callable <code>visualizer_macro</code>.
The pair is all-or-nothing. The prepared producer registers that macro only on a Workflow-owned API
connection, where connection close removes the complete advertised capability set. A borrowed API has no
removable-handler lifecycle, so it publishes ordinary progress without a descriptor and retains its
one-Workflow constraint. The service validates live macro ownership, retains transient progress for the
current turn, and publishes the descriptor in
<a href="jsonl-api.html#leaf_updated"><code>leaf_updated</code></a>.</p>
<div class="notice"><strong>Enhancement only.</strong> Ordinary progress title and lines remain the fallback.
A missing, rejected, or unusable descriptor must not prevent useful progress display. The visualizer observes
workflow state; it does not execute work, persist a checkpoint, or carry conversation content.</div>
<h2 id="envelope">What request and envelope are valid?</h2>
<table><thead><tr><th>Part</th><th>Contract</th></tr></thead><tbody>
<tr><td>Macro request</td><td>Exactly <code>info</code> or <code>status</code>; no parameters, commas, or
alternate spelling.</td></tr>
<tr><td>Macro result</td><td>One EzAgent CSV row, beginning <code>info-reply,0.1,<revision></code> or
<code>status-reply,0.1,<revision></code>, then paired <code>path,value</code> fields.</td></tr>
<tr><td>Revision</td><td>Nonempty printable ASCII. The prepared producer increments it for visible
workflow/node structure, state, or count changes; elapsed-clock movement alone does not change it.</td></tr>
</tbody></table>
<pre>info-reply,0.1,42,workflow.name,deploy,workflow.state,running,...
status-reply,0.1,42,workflow.name,deploy,workflow.state,running,...,fanout.total,1,...</pre>
<p>Use the normal correlated macro RPC
(<a href="jsonl-api.html#macro_call_ipc"><code>macro_call_ipc</code></a>/<a href="jsonl-api.html#macro_result_ipc"><code>macro_result_ipc</code></a>); this convention defines only its request text and result text.</p>
<h2 id="reply-schema">What does every reply contain?</h2>
<p>Both reply kinds carry a workflow snapshot. Required recognized paths include:</p>
<ul>
<li><code>workflow.name</code>, <code>workflow.state</code>, and <code>workflow.elapsed_seconds</code>.</li>
<li><code>phase.total</code>, <code>phase.declared_count</code>, and a complete zero-based
<code>phase#N</code> collection in creation order. Declared phases are a complete prefix.</li>
<li><code>status.total</code> and the exclusive buckets <code>provisioning</code>, <code>queued</code>,
<code>running</code>, <code>settling</code>, <code>succeeded</code>, <code>errors</code>, and
<code>cancelled</code>.</li>
<li><code>fanout.current.present</code>. When false, it is the only current-fanout field. When true, the name,
observed count, optional expected count, exact <code>expected_exceeded</code>, enumeration state, elapsed
time, member total, and every member state are required.</li>
</ul>
<p>The seven status buckets must sum to <code>status.total</code>, and <code>phase.declared_count</code> must
equal the declared prefix length. Indexed collections are contiguous, complete, and zero-based; a malformed
known path, duplicate path, missing required path or collection member, odd path/value pairing, inconsistent
totals, or a violated equation invalidates the entire row.</p>
<h2 id="prepared-mapping">How does the prepared graph map to 0.1?</h2>
<p>The mapping is intentionally lossy. Every initial or appended model query and command is one workload node
and contributes exactly once to <code>status.total</code> after declaration/commit. Fanout aggregate handles,
selections, assertions, settled controls, and steer controls are omitted from totals. Query
<code>executed</code>/<code>reused</code> and command <code>volatile</code> success map to
<code>succeeded</code>; <code>skipped</code> maps to <code>cancelled</code>; failures and cancellations map to
<code>error</code>/<code>cancelled</code>. No replay identity, prompt, response, command output, error detail,
callback disposition, or control value is projected.</p>
<p>Every Agent query row uses the Agent display model rather than its query key. The root title is the
Workflow title. An explicit Agent uses its title, falling back to its declared Agent key only when the title
was omitted. A fanout member uses the fanout name as its title and its supplied item tag, or one-based member
index, as its tag. Continuation generation zero and initial try are absent; later generations are
<code>continue-1</code>, <code>continue-2</code>, and so on, while the first retry is <code>try-2</code>. The
complete required <code>name</code> fallback is <code><title> - <tag> continue-N try-N</code>,
with absent parts omitted. For example: <code>ROOT</code>, <code>REVIEWER continue-1</code>, <code>REVIEWER
continue-2 try-2</code>, <code>FANOUT - 1</code>, and <code>FANOUT - Ruby/API</code>. Query keys do not
replace the Agent title.</p>
<p>Prepared phases are the finite complete sequence <code>1..estimated_phases</code>. Fanouts are the finite
initially declared fanouts and their direct query members; append transactions may add workload rows but
cannot add fanouts or phases. This adapter does not synthesize dynamic phases or fanouts. Phases are
presentation groups, never scheduler barriers. While a Workflow is running, an empty declared phase is
<code>not_started</code> because a settled tail may still append workloads to it; appended workloads then
determine phase state normally. After settlement, a phase that remained empty is <code>complete</code> under
the existing vocabulary.</p>
<h2 id="correlation">Where is progress advertised?</h2>
<p>The only eligible target is the external parent selected from <code>EZ_AGENT_LEAF_ID</code>. At
advertisement time it must still exist, be running, have a nonempty tip, and that tip must equal its current
canonical sent-turn summary. Missing, stale, idle, or dropped targets produce no advertisement; there is no
root/group fallback. Descriptor rejection falls back to ordinary progress when possible. Every macro,
progress, projection, stale-target, and clear failure is enhancement-only and never changes Workflow
evaluation success.</p>
<p>Every prepared fallback includes the exact line <code>workflow state: STATE</code>. Immediately after
installing a terminal <code>succeeded</code>, <code>error</code>, or <code>cancelled</code> projection, an
enhanced producer sends one final enabled progress update with the descriptor still attached, followed later
by the ordinary clear on the same connection. A TUI with that descriptor may use the exact terminal line as a
final-page hint before capability teardown; it must ignore unknown or nonterminal values. The hint is lossy
presentation metadata rather than a persisted result or a new CSV field. If it is absent, consumers must not
infer success from descriptor loss alone.</p>
<h2 id="current-fanout">Which fan-out is “current”?</h2>
<p>The producer selects the newest-declared nonterminal fan-out, searching in reverse declaration order.
Consumers must not infer it from status nodes. <code>fanout#N.observed</code> counts direct model-query
members declared by that fan-out.</p>
<h2 id="status-detail">What does <code>status</code> add?</h2>
<p><code>status</code> adds <code>fanout.total</code>, complete indexed <code>fanout#N</code> rows, and
<code>status.node#N</code> rows. Recognized status-only paths are forbidden in <code>info</code>. This keeps
the summary reply small; node-level detail is a separate request.</p>
<p>Every node keeps the required fallback fields <code>kind</code>, <code>name</code>, <code>state</code>,
<code>phase</code>, <code>fanout</code>, and <code>elapsed_seconds</code>. An Agent node may add
<code>title</code>, <code>tag</code>, <code>continuation</code>, and <code>try</code>. If any structured
display field is present, <code>title</code> is required and <code>name</code> must equal the composition
described above. <code>continuation</code> is a positive integer. <code>try</code> is an integer of at least
2. Absent values have no path. Command rows do not need structured Agent fields. These additions retain
payload version 0.1 because unknown syntactically valid paths are ignored; old consumers continue to use
<code>name</code>.</p>
<h2 id="session-presentation">How is the same display stored on leaves?</h2>
<p>The Ruby Workflow writes four application-owned leaf config keys: <code>workflow.display.title</code>,
<code>workflow.display.tag</code>, <code>workflow.display.continuation</code>, and
<code>workflow.display.try</code>. The stable Agent leaf has title and optional tag only. A sibling occurrence
leaf has the same title/tag plus applicable continuation and try values. Absent components are deleted rather
than encoded as zero or empty text. The ordinary leaf name contains the complete composed fallback.</p>
<p>These keys are presentation metadata only. They never enter a prompt, Agent/query identifier, replay
lookup, ancestry decision, or <code>parent_leaf</code> relationship. A session browser requests the keys in
its normal leaf metadata projection and falls back to the complete leaf name if the structured set is absent,
partial, or malformed. It must not parse the fallback name or derive hierarchy from Workflow identifiers.</p>
<h2 id="encoding">How are values encoded and validated?</h2>
<ul>
<li>The row is <a href="ez-agent-csv.html">EzAgent CSV</a>: comma-separated, apostrophe-quoted only when
needed, and doubled apostrophes inside quoted values. It is not RFC 4180.</li>
<li>Booleans are exactly <code>true</code> or <code>false</code>; counts are canonical nonnegative decimal
integers; elapsed values are finite canonical nonnegative decimals. Exponent notation is not accepted.</li>
<li>Known display text is normalized by the producer. Decoders reject invalid UTF-8 and control or
line-breaking characters.</li>
<li>Unknown syntactically valid paths are ignored for forward compatibility, but they still undergo basic
CSV/text validation and cannot duplicate any path.</li>
</ul>
<h2 id="authorities">Where does implementation detail live?</h2>
<table><thead><tr><th>Role</th><th>Authority</th></tr></thead><tbody>
<tr><td>Projector
fixture</td><td><a href="../../pkg/protocol/testdata/workflow_visualization_rows.json"><code>pkg/protocol/testdata/workflow_visualization_rows.json</code></a></td></tr>
<tr><td>Prepared Ruby
producer</td><td><a href="../ez-agent-ruby/lib/ez_agent/workflow.md"><code>EzAgent::Workflow</code> API</a>
and
<a href="../../ez-agent-ruby/lib/ez_agent/workflow/prepared_visualization.rb"><code>prepared_visualization.rb</code></a></td></tr>
<tr><td>Generic progress validation and
delivery</td><td><a href="../../pkg/protocol/progress.go"><code>pkg/protocol/progress.go</code></a> and
<a href="../../pkg/service/progress.go"><code>pkg/service/progress.go</code></a></td></tr>
<tr><td>TUI decoding and contract
tests</td><td><a href="../../pkg/tui/workflow_visualizer.go"><code>workflow_visualizer.go</code></a>,
<a href="../../pkg/tui/workflow_visualizer_test.go"><code>workflow_visualizer_test.go</code></a>, and
<a href="../../pkg/protocol/progress_test.go"><code>progress_test.go</code></a></td></tr>
</tbody></table>
<footer>Payload version 0.1. Generic transport and frame semantics remain owned by the JSONL API.</footer>
</body>
</html>