Skip to content

Commit 3d35861

Browse files
committed
📝 docs: make the bounded repair workflow an executable branch
The repair example was a fragment: it showed the failure branch and said core had no conditional to select it, pointing at #78 for the missing half. This PR is that half, so the example becomes a whole workflow — <SafeParse> binds the result, <If> reads result.value on success, and <Else> quotes result.input, renders result.errors into one corrective prompt, and validates the reply with <Parse>. The bound is structural rather than a counter: <If> expands one branch and never the other, so only the initial attempt and one corrective attempt can execute, and nothing in the failure branch returns to the start. Verified by running the documented shape end to end — the success branch renders the validated value and never sends the repair prompt; the failure branch renders the input and its issues and validates the correction.
1 parent c6f49ca commit 3d35861

1 file changed

Lines changed: 36 additions & 15 deletions

File tree

‎site/routes/docs/components.tsx‎

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,17 @@ const SAFE_PARSE = `<SafeParse schema={schema} as="result">
9898
<Prompt>Answer with JSON only: did the change pass review?</Prompt>
9999
</SafeParse>`;
100100

101-
const REPAIR = `That first answer was not usable:
101+
const REPAIR = `<SafeParse schema={schema} as="result">
102+
<Prompt>Answer with JSON only: did the change pass review?</Prompt>
103+
</SafeParse>
104+
105+
<If condition={result.ok}>
106+
107+
Review passed: {result.value.passed}
108+
109+
<Else>
110+
111+
That first answer was not usable:
102112
103113
\`\`\`
104114
{result.input}
@@ -110,7 +120,12 @@ const REPAIR = `That first answer was not usable:
110120
111121
<Parse schema={schema} as="verdict">
112122
<Prompt>Correct the JSON above so it satisfies every point.</Prompt>
113-
</Parse>`;
123+
</Parse>
124+
125+
Review passed: {verdict.passed}
126+
127+
</Else>
128+
</If>`;
114129

115130
export default define.page(function Components() {
116131
return (
@@ -335,22 +350,28 @@ export default define.page(function Components() {
335350

336351
<h3>A bounded repair prompt</h3>
337352
<p>
338-
Because the failure is a value, repair is ordinary Markdown rather than
339-
something hidden in the component. The fragment below is the{" "}
340-
<strong>failure branch</strong> — it assumes <code>result</code>{" "}
341-
has already come back failed. It quotes the input, renders every issue
342-
into one corrective prompt, and validates the reply strictly.
353+
Because the failure is a value and <code>&lt;If&gt;</code>{" "}
354+
chooses a branch, the whole retry is ordinary Markdown rather than
355+
something hidden in the component. A successful result is read straight
356+
off <code>result.value</code>. A failed one quotes{" "}
357+
<code>result.input</code>, renders every issue in{" "}
358+
<code>result.errors</code>{" "}
359+
into one corrective prompt, and validates the reply strictly with{" "}
360+
<code>&lt;Parse&gt;</code>.
343361
</p>
344362
<CodeBlock>{REPAIR}</CodeBlock>
345363
<p>
346-
Core ships no conditional component today — the{" "}
347-
<code>&lt;Show&gt;</code>{" "}
348-
in the value-component example above is an author's own component, not a
349-
core one. So this fragment is not yet an executable branch on its own:
350-
choosing it only when <code>result.ok</code>{" "}
351-
is false is what issue #78 adds. Until then, treat it as the shape a
352-
bounded retry takes: inspect, prompt once with the errors, then{" "}
353-
<code>&lt;Parse&gt;</code>.
364+
The retry is <strong>bounded by construction</strong>, not by a counter.
365+
{" "}
366+
<code>&lt;If&gt;</code>{" "}
367+
expands exactly one branch and never the other, so at most two attempts
368+
can execute: the initial{" "}
369+
<code>&lt;SafeParse&gt;</code>, and — only when that one failed — the
370+
single corrective <code>&lt;Parse&gt;</code> inside{" "}
371+
<code>&lt;Else&gt;</code>. When the first answer parses, the failure
372+
branch never expands, so its prompt is never sent. Nothing in the
373+
failure branch reaches back to the beginning, so there is no third
374+
attempt to bound.
354375
</p>
355376

356377
<h2>How it renders</h2>

0 commit comments

Comments
 (0)