<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <id>https://docs.synapsys.jmzworks.it/blog</id>
    <title>Synapsys Blog</title>
    <updated>2026-08-25T00:00:00.000Z</updated>
    <generator>https://github.com/jpmonette/feed</generator>
    <link rel="alternate" href="https://docs.synapsys.jmzworks.it/blog"/>
    <subtitle>Synapsys Blog</subtitle>
    <icon>https://docs.synapsys.jmzworks.it/img/favicon.svg</icon>
    <entry>
        <title type="html"><![CDATA[Why commands are matched by token, not by state]]></title>
        <id>https://docs.synapsys.jmzworks.it/blog/2026/08/25/why-tokens</id>
        <link href="https://docs.synapsys.jmzworks.it/blog/2026/08/25/why-tokens"/>
        <updated>2026-08-25T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[The obvious design replays every command. Here is what Synapsys does instead.]]></summary>
        <content type="html"><![CDATA[<p>Synapsys workers do not accept inbound connections. Everything — every report and
every command — rides a single outbound POST the worker makes every few seconds.</p>
<p>That leaves one question: how does the Core tell a worker to do something exactly
once?</p>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-obvious-design-is-wrong">The obvious design is wrong<a href="https://docs.synapsys.jmzworks.it/blog/2026/08/25/why-tokens#the-obvious-design-is-wrong" class="hash-link" aria-label="Direct link to The obvious design is wrong" title="Direct link to The obvious design is wrong" translate="no">​</a></h2>
<p>Send the desired state, let the worker compare it against what it is doing, and
act on the difference.</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#bfc7d5"><span class="token plain">if (desiredState != currentState) apply(desiredState);</span><br></div></code></pre></div></div>
<p>This replays. A process that takes thirty seconds to stop reports <code>stopping</code> for
six consecutive beats, and on each one the desired state still differs from the
current state, so the command fires again. With a start command it is worse: you
get six starts.</p>
<p>You can patch around it — suppress commands while a transition is in flight, add a
grace period — but every patch is a guess about timing, and timing is exactly what
an unreliable network takes away from you.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="what-synapsys-does">What Synapsys does<a href="https://docs.synapsys.jmzworks.it/blog/2026/08/25/why-tokens#what-synapsys-does" class="hash-link" aria-label="Direct link to What Synapsys does" title="Direct link to What Synapsys does" translate="no">​</a></h2>
<p>The Core keeps a <strong><code>desiredToken</code></strong> per process and increments it on every user
command. The worker keeps the last token it actually applied, as <strong><code>ackToken</code></strong>,
and reports it on every heartbeat.</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#bfc7d5"><span class="token plain">if (desiredToken &gt; ackToken) {</span><br></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">    apply(desiredState);</span><br></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">    ackToken = desiredToken;</span><br></div><div class="token-line" style="color:#bfc7d5"><span class="token plain">}</span><br></div></code></pre></div></div>
<p>Duplicates are now arithmetic rather than judgement. The same response delivered
six times applies once, because after the first the tokens are equal.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-consequences-worth-knowing">The consequences worth knowing<a href="https://docs.synapsys.jmzworks.it/blog/2026/08/25/why-tokens#the-consequences-worth-knowing" class="hash-link" aria-label="Direct link to The consequences worth knowing" title="Direct link to The consequences worth knowing" translate="no">​</a></h2>
<p><strong><code>idle</code> had to stop meaning "stop".</strong> Once a command completes, the Core resets
<code>desiredState</code> to <code>idle</code> to mean "nothing outstanding". Any client that reads that
as an instruction shuts down everything it owns. So <code>idle</code> means <em>no command</em>, and
stop is <code>stopping</code>.</p>
<p><strong><code>failed</code> cannot be commanded.</strong> A state you can be in is not necessarily a state
you can be told to enter. Nothing can be instructed to fail, so validity is
checked twice — once for what a worker may report, once for what the Core may
ask for.</p>
<p><strong>Order matters at the edges.</strong> Update <code>ackToken</code> after applying, never before. A
client that acknowledges first and crashes has lost the command, because the Core
will consider it done.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="why-this-is-in-the-docs-not-just-the-code">Why this is in the docs, not just the code<a href="https://docs.synapsys.jmzworks.it/blog/2026/08/25/why-tokens#why-this-is-in-the-docs-not-just-the-code" class="hash-link" aria-label="Direct link to Why this is in the docs, not just the code" title="Direct link to Why this is in the docs, not just the code" translate="no">​</a></h2>
<p>Every future starter — Go, Python, whatever comes after — reimplements this loop.
It is the one piece of Synapsys that cannot be encapsulated in a library, because
it <em>is</em> the thing each library independently has to get right.</p>
<p>That is also why Raw API is a first-class connection method rather than a
fallback: the protocol is the product.</p>]]></content>
    </entry>
</feed>