<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Uncle Pushui</title>
    <description>The latest articles on DEV Community by Uncle Pushui (@uncle-pushui).</description>
    <link>https://dev.to/uncle-pushui</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1868785%2F82f27483-4416-487e-b0ce-5e6d741637c0.jpg</url>
      <title>DEV Community: Uncle Pushui</title>
      <link>https://dev.to/uncle-pushui</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/uncle-pushui"/>
    <language>en</language>
    <item>
      <title>Frontend Caching in Cabloy/Zova vs Next.js</title>
      <dc:creator>Uncle Pushui</dc:creator>
      <pubDate>Tue, 24 Nov 2026 02:00:31 +0000</pubDate>
      <link>https://dev.to/uncle-pushui/frontend-caching-in-cabloyzova-vs-nextjs-6ce</link>
      <guid>https://dev.to/uncle-pushui/frontend-caching-in-cabloyzova-vs-nextjs-6ce</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Zova caches state; Next.js caches rendered output. They are not two ways of doing the same thing — they are answers to two different problems.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The most common mistake when comparing caches is assuming they solve the same problem.&lt;/p&gt;

&lt;p&gt;Both Zova and Next.js have caches, but they start from opposite ends:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zova's cache is for Vue SPA + SSR&lt;/strong&gt; — the core question is "if the user closes the browser and comes back, do the orders I was looking at still show up?" and "after user A logs out and user B logs in, does the old data get wiped clean?" It is a &lt;strong&gt;client-side state persistence layer&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Next.js's cache is for React full-stack SSR/SSG&lt;/strong&gt; — the core question is "can this route be pre-rendered and returned directly without re-running React on every request?" and "can fetch results be reused across requests?" It is a &lt;strong&gt;rendering performance optimization layer&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So comparing them by API names alone misses the point. You have to see what problem each one is actually trying to answer.&lt;/p&gt;

&lt;p&gt;Let's start with Zova, see exactly what it caches and why, then bring Next.js over for a side-by-side.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Zova's Five-Layer Cache Architecture
&lt;/h2&gt;

&lt;p&gt;Zova's cache lives inside the &lt;code&gt;a-model&lt;/code&gt; module — the Model layer. The entry point is &lt;code&gt;moduleLoaded()&lt;/code&gt; in &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-model/src/service/storage.ts" rel="noopener noreferrer"&gt;storage.ts&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;moduleLoaded&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deepExtend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;queryClientConfig&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;defaultOptions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SERVER&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;queries&lt;/span&gt; &lt;span class="o"&gt;??=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gcTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;Infinity&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// no auto GC during SSR&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;queryCache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;QueryCache&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;queryClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;QueryClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;defaultOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;queryCache&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_persistence&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ModelPersistenceContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;queryClient&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SITE_ID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;VueQueryPlugin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;queryClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The baseline defaults come from &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-model/src/config/config.ts" rel="noopener noreferrer"&gt;config.ts&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;defaultOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;retry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;refetchOnWindowFocus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;refetchOnMount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;refetchOnReconnect&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;gcTime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;// 5 minutes default&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;dehydrate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;shouldDehydrateQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ssr&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dehydrate&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;persister&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'object'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;persister&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sync&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;defaultShouldDehydrateQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nf"&gt;shouldDehydrateMutation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_mutation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The full architecture is five layers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Layer 1: Memory — TanStack Vue Query QueryCache
  In-process query results for the app lifetime
  Default gcTime: 5min, refetchOnWindowFocus: false
  During SSR: gcTime = Infinity

Layer 2: Persistence — Query Persister
  cookie: session-level (session cookie)
  localStorage: permanent (Infinity)
  localforage/IndexedDB: default 24h maxAge
  Plus PersistenceQueue: serialized async writes + generation-based race prevention

Layer 3: Identity Isolation — ModelPersistenceContext
  scope = [instanceId, siteId, userId]
  scope changes → epoch++ → auto-invalidate all DB-persisted queries
  epoch token: stale operations silently dropped via CancelledError

Layer 4: SSR Response Cache — HTTP Cache-Control
  profile 'public': Cache-Control: public, max-age=N
  profile 'session': Cache-Control: private, no-store

Layer 5: Component Cache — Router Tabs + Vue KeepAlive
  tabsOptions.cache: true → tab state persisted to localStorage
  Vue KeepAlive: component instances cached in memory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Layers 2, 3, and 5 are where Zova deviates from Next.js — those three either do not exist in Next.js or work on completely different principles.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Persistence Layer: Not an Optional Plugin
&lt;/h2&gt;

&lt;p&gt;Zova re-implemented persistence rather than directly using &lt;code&gt;@tanstack/query-persist-client&lt;/code&gt;, adding a generation mechanism on top. The core lives in &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-model/src/bean/bean.model/bean.model.persister.ts" rel="noopener noreferrer"&gt;bean.model.persister.ts&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Declaring persistence is a one-liner in a Model bean:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ModelUserInfo&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;BeanModelBase&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nv"&gt;$userInfo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;$useQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;queryKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'userInfo'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;queryFn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUserInfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;persister&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'db'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="c1"&gt;// IndexedDB persistence&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The three storage tiers and their default &lt;code&gt;maxAge&lt;/code&gt; values are configured in &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-model/src/config/config.ts" rel="noopener noreferrer"&gt;config.ts&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="n"&gt;persister&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;maxAge&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;cookie&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="c1"&gt;// undefined = session cookie&lt;/span&gt;
    &lt;span class="n"&gt;local&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;Infinity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;      &lt;span class="c1"&gt;// localStorage = forever&lt;/span&gt;
    &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;// IndexedDB = 24h&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;refetchOnRestore&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The actual storage selection happens in &lt;code&gt;_getPersisterStorage()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nf"&gt;_getPersisterStorage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;storage&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'cookie'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;CookieWrapper&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SERVER&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// SSR never writes to browser storage&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;storage&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'local'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;storage&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'db'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;localforage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That SSR branch is worth noting: during server-side rendering, persistence stays out of browser storage. SSR data instead goes through the &lt;strong&gt;dehydrate / hydrate&lt;/strong&gt; pipeline — the QueryCache is serialized into the HTML, and the client restores it during hydration.&lt;/p&gt;

&lt;h3&gt;
  
  
  PersistenceQueue: Preventing Async Write Races
&lt;/h3&gt;

&lt;p&gt;The most delicate piece of the persistence layer is &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-model/src/lib/persistenceQueue.ts" rel="noopener noreferrer"&gt;persistenceQueue.ts&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;IndexedDB operations are async and queue. Without protection, a "write A → delete A → write B" sequence could finish out of order and corrupt state. Zova uses a generation counter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PersistenceQueue&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="n"&gt;_generation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="n"&gt;_keyGenerations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nf"&gt;generation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sb"&gt;`${this._generation}:${this._keyGenerations.get(key) ?? 0}`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;invalidate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_keyGenerations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_keyGenerations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;invalidateAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_generation&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_keyGenerations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How it works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Before any save/remove on a key, &lt;code&gt;queue.invalidate(key)&lt;/code&gt; increments that key's generation.&lt;/li&gt;
&lt;li&gt;When the async operation actually executes, it checks whether the generation matches what was captured at queue time.&lt;/li&gt;
&lt;li&gt;If a newer write has since invalidated the key, the old operation's generation is stale — it skips itself.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// bean.model.persister.ts _persisterSave()&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;storageKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_getPersisterStorageKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;queue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getPersistenceQueue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invalidate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;storageKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// invalidate old generation first&lt;/span&gt;
&lt;span class="c1"&gt;// then enqueue the write...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This guarantees "the newest write wins" and fixes the IndexedDB async ordering problem. Next.js's Router Cache and Data Cache are both in-process memory, so they never face this class of race.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Identity Isolation: scope + epoch token
&lt;/h2&gt;

&lt;p&gt;This is Zova's unique design — Next.js simply has no concept of multi-tenancy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-model/src/lib/modelPersistence.ts" rel="noopener noreferrer"&gt;modelPersistence.ts&lt;/a&gt; defines the core structures:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;ModelPersistenceScope&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//                                 [instanceId, siteId, userId]&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;ModelPersistenceToken&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="n"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ModelPersistenceScope&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="n"&gt;epoch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The scope is a triple &lt;code&gt;[instanceId, siteId, userId]&lt;/code&gt;. Whenever the user's identity changes — logout, login to another account, switch workspace — the scope changes with it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The full auto-invalidation flow&lt;/strong&gt; lives in &lt;code&gt;update()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;scope&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;freeze&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nf"&gt;normalize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;instanceId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nf"&gt;normalize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;siteId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nf"&gt;normalize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;every&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_scope&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_hydrated&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// Find all queries that need invalidation — those with meta.persister.storage === 'db'&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;affected&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_queryClient&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getQueryCache&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;isModelPersistenceDb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;persister&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;adopt&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_hydrated&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_scope&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_hydrated&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_invalidate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;affected&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// Silently refetch active queries&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;refetchActive&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;current&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_queryClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;refetchQueries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'active'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;predicate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;affected&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What &lt;code&gt;_invalidate()&lt;/code&gt; does:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;_invalidate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_epoch&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// Cancel all in-flight retries first (silent: true to prevent old error publication)&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cancel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;silent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;revert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;notifyManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;batch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setOptions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;initialData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;initialDataUpdatedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;observer&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;observers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setOptions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;initialData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;placeholderData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;emptyQueryState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_version&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;capture&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;listener&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_listeners&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The order matters: &lt;strong&gt;cancel first&lt;/strong&gt;, then &lt;strong&gt;batch-reset all observer initialData/placeholderData&lt;/strong&gt;, then &lt;strong&gt;clear query.state entirely&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  epoch token: stale operations silently die
&lt;/h3&gt;

&lt;p&gt;This is what guarantees "the instant scope changes, all in-flight work is automatically voided". Every persistence read/write/delete captures a token before executing and checks it when done:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// bean.model.persister.ts _createDbPersister()&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;persistence&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;capture&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// ... async work happens ...&lt;/span&gt;
&lt;span class="c1"&gt;// on completion&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;storage&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'db'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;persistence&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;current&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// scope unchanged — result is valid&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// scope changed — silently discard&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;current(token)&lt;/code&gt; checks two things: epoch didn't change, and scope didn't change. Either one being different means false.&lt;/p&gt;

&lt;p&gt;This is far more elegant than Next.js's manual &lt;code&gt;revalidatePath&lt;/code&gt; / &lt;code&gt;revalidateTag&lt;/code&gt;. In Next.js, you must manually trigger invalidation after every logout/login, and it only affects server-side caches. Zova ties &lt;strong&gt;all DB-persisted queries to the current scope&lt;/strong&gt; and invalidates them automatically when scope transitions — plus cancels in-flight operations so stale data never writes back into the new identity's storage.&lt;/p&gt;

&lt;h3&gt;
  
  
  Storage keys are scope-aware too
&lt;/h3&gt;

&lt;p&gt;Inside &lt;code&gt;_getPersisterStorageKey()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;storage&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'db'&lt;/span&gt;
  &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;getModelPersistenceStorageKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;APP_NAME&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;$modelPersistence&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;capture&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;logicalKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;logicalKey&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key format is &lt;code&gt;["zova-model-db", 1, appName, scope, logicalKey]&lt;/code&gt;. The scope is encoded into the key itself, so IndexedDB data for different identities is naturally isolated — even if you manually iterate keys they won't cross.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. SSR Cache: Explicit Profile Declaration
&lt;/h2&gt;

&lt;p&gt;Zova's SSR cache policy lives in &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssr/src/lib/ssrProfile.ts" rel="noopener noreferrer"&gt;ssrProfile.ts&lt;/a&gt; and &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssrserver/src/service/ssrHandler.ts" rel="noopener noreferrer"&gt;ssrHandler.ts&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;resolveSsrProfile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;routeProfile&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;defaultProfile&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ssrProfile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;routeProfile&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="n"&gt;defaultProfile&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;'public'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssrProfile&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'public'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;ssrProfile&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'session'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`invalid SSR profile: ${ssrProfile}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ssrProfile&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only two tiers: &lt;code&gt;public&lt;/code&gt; and &lt;code&gt;session&lt;/code&gt;. The HTTP header setup is straightforward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssrProfile&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'session'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'cache-control'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'private, no-store'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssrProfile&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'public'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;expires&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;resolveSsrResponseCacheExpires&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssrProfileOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;responseCache&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;META_MODE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expires&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'cache-control'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'no-cache, no-store, must-revalidate'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'cache-control'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sb"&gt;`public, max-age=${expires}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Development mode has special handling: &lt;code&gt;metaMode === 'development'&lt;/code&gt; forces &lt;code&gt;expires = 0&lt;/code&gt;, which gives &lt;code&gt;no-cache, no-store, must-revalidate&lt;/code&gt; — preventing browser cache from getting in the way during development.&lt;/p&gt;

&lt;p&gt;Zova's SSR cache is &lt;strong&gt;declarative and manual&lt;/strong&gt; — each route picks &lt;code&gt;ssrProfile: 'public' | 'session'&lt;/code&gt;. It never auto-detects. This is the opposite of Next.js App Router, which automatically excludes routes from the Full Route Cache when it detects dynamic APIs like &lt;code&gt;cookies&lt;/code&gt;, &lt;code&gt;headers&lt;/code&gt;, or &lt;code&gt;searchParams&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Line Up Next.js
&lt;/h2&gt;

&lt;p&gt;Now let's put Next.js App Router's four layers on the table. The docs are clear:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Next.js App Router Caching
Layer 1: Request Memoization (React)
  fetch GET/HEAD auto-deduplication within one React tree render
  Lifetime: single request
  Scope: React Component Tree only

Layer 2: Data Cache (Next.js built-in)
  fetch results persist across requests and deployments
  Default: no-store (not cached)
  Opt-in: cache: 'force-cache' or next.revalidate &amp;gt; 0
  Time-driven: stale-while-revalidate
  Event-driven: revalidateTag / revalidatePath

Layer 3: Full Route Cache (Next.js built-in)
  Pre-rendered HTML + RSC Payload
  Generated at build time or during ISR
  Invalidated by: Data Cache revalidate / redeploy
  Auto-exit: using cookies/headers/searchParams dynamic APIs

Layer 4: Router Cache (browser memory)
  Client-side RSC Payload cache
  Lifetime: session + auto-expiration
  Granularity: layout / loading / page segments
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Side-by-side
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dimension&lt;/th&gt;
&lt;th&gt;Zova (Vue frontend)&lt;/th&gt;
&lt;th&gt;Next.js (React full-stack)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Layers&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;5: memory + persistence + identity + SSR HTTP + KeepAlive&lt;/td&gt;
&lt;td&gt;4: memoization + Data + Full Route + Router&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Persistence storage&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Cookie / localStorage / IndexedDB&lt;/td&gt;
&lt;td&gt;None (browser BFCache + server disk/memory)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Default persistence&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;non-DB queries in memory; DB queries in IndexedDB (24h)&lt;/td&gt;
&lt;td&gt;Memory only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Identity isolation&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ scope=[iid,siteId,userId] epoch token&lt;/td&gt;
&lt;td&gt;❌ not in scope&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SSR data transfer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;QueryCache dehydrate → window.&lt;strong&gt;INITIAL_STATE_DEFER&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;RSC Payload → React reconciliation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SSR cache policy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Explicit profile &lt;code&gt;public&lt;/code&gt; / &lt;code&gt;session&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Auto-inferred from fetch options + Route Segment Config&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Async safety&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;PersistenceQueue generation + CancelledError silent&lt;/td&gt;
&lt;td&gt;SWR background refresh&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Invalidation trigger&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;scope change → auto-invalidate + epoch++&lt;/td&gt;
&lt;td&gt;Manual revalidateTag / revalidatePath&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  TTL semantics are fundamentally different
&lt;/h3&gt;

&lt;p&gt;Zova's TTL is &lt;strong&gt;maxAge&lt;/strong&gt; — when it expires the data is gone. Next.js's &lt;code&gt;revalidate: N&lt;/code&gt; is &lt;strong&gt;stale-while-revalidate&lt;/strong&gt; — after expiry it still returns the stale data and silently refreshes in the background.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Zova&lt;/th&gt;
&lt;th&gt;Next.js&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Time meaning&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Data lifespan&lt;/td&gt;
&lt;td&gt;Maximum time before the server initiates a refresh&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;After expiry&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Discarded; next fetch loads fresh&lt;/td&gt;
&lt;td&gt;Stale data still returned; refresh fires in background&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;User impact&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Loading state on first post-expiry fetch&lt;/td&gt;
&lt;td&gt;Instant response even after expiry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best for&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;User-sensitive data (Auth tokens, captchas)&lt;/td&gt;
&lt;td&gt;Low-sensitivity data (blog posts, product listings)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Default behavior points in opposite directions
&lt;/h3&gt;

&lt;p&gt;Zova's defaults are &lt;code&gt;refetchOnMount: false&lt;/code&gt;, &lt;code&gt;refetchOnWindowFocus: false&lt;/code&gt;, &lt;code&gt;gcTime: 5min&lt;/code&gt; — leaning toward &lt;strong&gt;minimizing requests&lt;/strong&gt; and trusting cache.&lt;/p&gt;

&lt;p&gt;Next.js's default fetch setting is &lt;code&gt;cache: 'no-store'&lt;/code&gt; — leaning toward &lt;strong&gt;freshness by default&lt;/strong&gt;, with cache as an explicit opt-in optimization.&lt;/p&gt;

&lt;p&gt;The defaults answer opposite questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zova&lt;/strong&gt; defaults to "trust the cache" — SPA users expect data to persist across navigations and not flicker. Cache invalidation is a precise, controlled operation (scope change, manual invalidate).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Next.js&lt;/strong&gt; defaults to "don't trust anything" — server-side rendering must guarantee freshness. Caching is an opt-in performance optimization, not the default.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6. Three Zova-Specific Cache Details
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. gcTime is Infinity during SSR
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SERVER&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;queries&lt;/span&gt; &lt;span class="o"&gt;??=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gcTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;Infinity&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means &lt;strong&gt;no auto GC during SSR&lt;/strong&gt;. The reason is straightforward: all queries in the QueryCache during SSR end up dehydrated into the HTML. If one got GC'd before dehydration, the serialized cache would be incomplete.&lt;/p&gt;

&lt;p&gt;Next.js never faces this — each server render is isolated, and the Data Cache is a separate, process-level storage independent of the render lifecycle.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Special staleTime during hydration
&lt;/h3&gt;

&lt;p&gt;Inside &lt;code&gt;$useQuery()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;sync&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;persister&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'object'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;persister&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sync&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sync&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;staleTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;staleTime&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scopeSelf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;staleTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;queryCache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;$queryFind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;queryKey&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;queryCacheExists&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;queryCache&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;staleTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;queryCacheExists&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;resolveStaleTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CLIENT&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;$ssr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isRuntimeSsrPreHydration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;resolveStaleTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scopeSelf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;staleTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ssr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Infinity&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;resolveStaleTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;staleTime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;staleTime.ssr&lt;/code&gt; defaults to &lt;code&gt;Infinity&lt;/code&gt; — during hydration, queries restored from SSR dehydration are considered &lt;strong&gt;permanently fresh&lt;/strong&gt;. The server just rendered them; the client has no reason to disbelieve. Only after hydration completes does normal &lt;code&gt;staleTime.async&lt;/code&gt; (default 0, meaning immediately stale) kick in.&lt;/p&gt;

&lt;p&gt;Next.js doesn't need this — the RSC Payload carries &lt;code&gt;dataUpdatedAt&lt;/code&gt; timestamps and React Query handles freshness on its own.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Router Tabs persistence
&lt;/h3&gt;

&lt;p&gt;This one is very practical. From &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-routertabs/src/model/tabs.ts" rel="noopener noreferrer"&gt;tabs.ts&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Model&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;IModelOptionsTabs&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ModelTabs&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;BeanModelBase&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scene&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="nc"&gt;ModelTabsOptions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tabsOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_tabsState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;$useStateLocalAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;queryOptionsTabs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// localStorage&lt;/span&gt;
      &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_offPersistence&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;persistence&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_tabsDisposed&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;disposed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_startTabsRestore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_getTabsReadiness&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_tabsState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;$useStateMem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;queryOptionsTabs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// in-memory only&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;tabsOptions.cache: true&lt;/code&gt;, the tab list persists to localStorage. But persistence isn't directly consumed — &lt;code&gt;persistence.subscribe()&lt;/code&gt; watches for scope changes and triggers a reload each time, ensuring tab state always aligns with the current identity.&lt;/p&gt;

&lt;p&gt;Next.js Router Cache also caches route-segment state, but never across sessions and with no identity-aware auto-restore. Close and reopen the browser and your previously open tabs are gone.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. The Essential Point
&lt;/h2&gt;

&lt;p&gt;Reduce everything to one sentence:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Zova caches data state; Next.js caches rendered output.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Zova cares about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"If the browser closes and reopens, do my orders still show up?"&lt;/li&gt;
&lt;li&gt;"After logout, does the next account see stale data?"&lt;/li&gt;
&lt;li&gt;"When switching workspaces, should the cache wipe?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next.js cares about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Is this route pre-rendered? Can I skip the server?"&lt;/li&gt;
&lt;li&gt;"Can fetch results be reused across requests?"&lt;/li&gt;
&lt;li&gt;"The CMS updated — which tag do I invalidate?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first is &lt;strong&gt;client-side architecture thinking&lt;/strong&gt; — multi-tenant SPA state lifecycle management. The second is &lt;strong&gt;full-stack rendering framework thinking&lt;/strong&gt; — reducing server work and making first paint faster.&lt;/p&gt;

&lt;p&gt;These two models are not in conflict. In the same application you can have Zova's identity-aware persistence protecting user state on the client, while Next.js's ISR + revalidateTag protects rendered output on the server. They complement rather than compete.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. Summary
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Zova's cache is a five-layer stack: memory → persistence → identity isolation → SSR HTTP → KeepAlive. The two most distinctive layers are persistence and identity isolation.&lt;/li&gt;
&lt;li&gt;The persistence layer implements PersistenceQueue + generation counters to prevent async race conditions. Three storage tiers (cookie / localStorage / IndexedDB) expire by &lt;code&gt;maxAge&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Identity isolation uses a scope triple plus epoch tokens. Any scope change auto-invalidates all DB-persisted queries and silently drops in-flight operations.&lt;/li&gt;
&lt;li&gt;SSR cache is two explicit profile tiers (&lt;code&gt;public&lt;/code&gt; / &lt;code&gt;session&lt;/code&gt;) with no auto-inference.&lt;/li&gt;
&lt;li&gt;Next.js caches are a four-layer stack built around render output reuse. TTL semantics are stale-while-revalidate, and trust in cache must be explicitly opted in.&lt;/li&gt;
&lt;li&gt;Defaults point in opposite directions: Zova trusts cache and minimizes requests; Next.js distrusts cache and requires opt-in.&lt;/li&gt;
&lt;li&gt;The two are not incompatible — they complement each other in a single application.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  References and Source
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Zova / Cabloy
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-model/src/service/storage.ts" rel="noopener noreferrer"&gt;QueryClient initialization and SSR dehydrate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-model/src/lib/modelPersistence.ts" rel="noopener noreferrer"&gt;Identity isolation: ModelPersistenceContext&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-model/src/lib/persistenceQueue.ts" rel="noopener noreferrer"&gt;PersistenceQueue&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-model/src/bean/bean.model/bean.model.persister.ts" rel="noopener noreferrer"&gt;Persister core: three-tier storage + generation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-model/src/bean/bean.model/bean.model.useQuery.ts" rel="noopener noreferrer"&gt;staleTime handling in $useQuery&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-model/src/config/config.ts" rel="noopener noreferrer"&gt;Default configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssr/src/lib/ssrProfile.ts" rel="noopener noreferrer"&gt;SSR Profile resolution&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssrserver/src/service/ssrHandler.ts" rel="noopener noreferrer"&gt;SSR response cache headers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-routertabs/src/model/tabs.ts" rel="noopener noreferrer"&gt;Router Tabs persistence&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Next.js
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://nextjs.org/docs/15/app/guides/caching" rel="noopener noreferrer"&gt;Caching in Next.js 15&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nextjs.org/docs/app/api-reference/functions/fetch" rel="noopener noreferrer"&gt;Fetch API Options&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config" rel="noopener noreferrer"&gt;Route Segment Config&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nextjs.org/docs/app/api-reference/functions/revalidatePath" rel="noopener noreferrer"&gt;revalidatePath / revalidateTag&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>nextjs</category>
      <category>cabloy</category>
      <category>zova</category>
      <category>tanstackquery</category>
    </item>
    <item>
      <title>SSR Hydration in Cabloy/Zova vs Next.js</title>
      <dc:creator>Uncle Pushui</dc:creator>
      <pubDate>Wed, 18 Nov 2026 14:42:52 +0000</pubDate>
      <link>https://dev.to/uncle-pushui/ssr-hydration-in-cabloyzova-vs-nextjs-47jd</link>
      <guid>https://dev.to/uncle-pushui/ssr-hydration-in-cabloyzova-vs-nextjs-47jd</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Next.js has had two generations of SSR. Zova is isomorphic to the first and heteromorphic to the second. Mixing them up makes the comparison meaningless.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When people ask "how does Zova's SSR differ from Next.js", the question is hard to answer directly — because Next.js itself spans two entirely different hydration models:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pages Router&lt;/strong&gt; (the &lt;code&gt;getServerSideProps&lt;/code&gt; era): server calls &lt;code&gt;renderToString&lt;/code&gt;, props are embedded into &lt;code&gt;__NEXT_DATA__&lt;/code&gt;, client calls &lt;code&gt;hydrateRoot&lt;/code&gt;. This is the same paradigm as Vue SSR.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;App Router&lt;/strong&gt; (the RSC era): the server renders React Server Components and emits a Flight-protocol payload; only Client Components participate in hydration. This is something else entirely.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Zova belongs to the former, and it polishes that model further than Pages Router does. So the two comparisons worth making are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Zova vs Pages Router — within one paradigm, where the engineering details differ;&lt;/li&gt;
&lt;li&gt;Zova vs App Router — across paradigms, what each gives up.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's start from a real request.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. One SSR Request in Zova
&lt;/h2&gt;

&lt;p&gt;The entry point is &lt;code&gt;render()&lt;/code&gt; in &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssrserver/src/service/ssrHandler.ts" rel="noopener noreferrer"&gt;ssrHandler.ts&lt;/a&gt;. The whole chain is synchronous and serial:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// 1. Resolve the route and determine the SSR profile&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;route&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;$&lt;span class="nv"&gt;$sysRouter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolveRoute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pagePathFull&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ssrProfile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;resolveSsrProfile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;route&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ssrProfile&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SSR_PROFILE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 2. Create the app; controllers run here and write into ssrContext&lt;/span&gt;
&lt;span class="n"&gt;renderFn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;serverEntry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssrContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 3. Render the whole component tree synchronously&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;runtimePageContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;renderToString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;renderFn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ssrContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 4. Callback chain: dehydrate query cache, inject meta, dispose request-scoped contexts&lt;/span&gt;
&lt;span class="n"&gt;onRenderedList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 5. Assemble the final HTML&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;renderTemplate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssrContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three characteristics stand out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First, &lt;code&gt;renderToString&lt;/code&gt; is synchronous.&lt;/strong&gt; Vue 3's official server-rendering APIs are &lt;code&gt;renderToString&lt;/code&gt; and &lt;code&gt;renderToSimpleStream&lt;/code&gt;; Zova uses the former. That means the server must finish rendering the entire tree before sending the first byte. No Suspense slicing, no progressive transfer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second, data is produced by controllers, not fetched by components.&lt;/strong&gt; In Zova, page data comes from backend controller beans. During SSR, the controller runs in-process (or through &lt;code&gt;performAction&lt;/code&gt; over internal HTTP) and writes into &lt;code&gt;ssrContext.state&lt;/code&gt; and &lt;code&gt;ssrContext.stateDefer&lt;/code&gt;. That is a different data path from &lt;code&gt;await fetch()&lt;/code&gt; inside a Next.js component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Third, request-scoped state must be explicitly destroyed.&lt;/strong&gt; Zova's beans are singletons, and request-scoped things live on &lt;code&gt;ZovaContext&lt;/code&gt;. So &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssr/src/lib/ssr.ts" rel="noopener noreferrer"&gt;ssr.ts&lt;/a&gt; keeps a &lt;code&gt;SymbolServerContexts&lt;/code&gt; set, registers each request, and disposes them all after rendering:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;_serverContextsDispose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;serverContext&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;SymbolServerContexts&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serverContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;disposed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serverContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bean&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;serverContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bean&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="n"&gt;serverContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;serverContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bean&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dispose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;serverContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dispose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;serverContexts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This does not exist in Next.js — every App Router request runs in an isolated execution context, and Pages Router runs a fresh function per request. There is no cross-request singleton state to clean up.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. How State Enters the HTML
&lt;/h2&gt;

&lt;p&gt;Zova uses &lt;strong&gt;two channels&lt;/strong&gt;, injected at different positions in the HTML.&lt;/p&gt;

&lt;p&gt;From &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssr/src/lib/ssrMetaStore.ts" rel="noopener noreferrer"&gt;ssrMetaStore.ts&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Critical state → end of head&lt;/span&gt;
&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;endingHeadTags&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="sb"&gt;`&amp;lt;script id="ssr-state-init"&amp;gt;window.__INITIAL_STATE__=${unevalPatch(ssrContext.state)}&amp;lt;/script&amp;gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Non-critical but bulky state → end of body&lt;/span&gt;
&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;endingBodyTags&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="sb"&gt;`&amp;lt;script id="ssr-state-defer-init"&amp;gt;window.__INITIAL_STATE_DEFER__=${unevalPatch(ssrContext.stateDefer)}&amp;lt;/script&amp;gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The two channels carry different things:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Channel&lt;/th&gt;
&lt;th&gt;Position&lt;/th&gt;
&lt;th&gt;Contents&lt;/th&gt;
&lt;th&gt;Characteristic&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;__INITIAL_STATE__&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;End of head&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;pagePathFull&lt;/code&gt;, &lt;code&gt;ssrProfile&lt;/code&gt;, &lt;code&gt;ssrProfileOptions&lt;/code&gt;, &lt;code&gt;compactHint&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Needed at startup, small&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;__INITIAL_STATE_DEFER__&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;End of body&lt;/td&gt;
&lt;td&gt;TanStack Query &lt;code&gt;dehydrate&lt;/code&gt; output, controller-load error snapshots, meta&lt;/td&gt;
&lt;td&gt;Bulky, can be parsed later&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The reason is straightforward: inline scripts in the head block subsequent parsing. Putting tens of kilobytes of query cache at the end of the body lets the first paint start earlier.&lt;/p&gt;

&lt;p&gt;Conversely, &lt;code&gt;pagePathFull&lt;/code&gt; must arrive early — the client uses it to align the router with the server-rendered page. Otherwise it would render an empty route and then navigate, causing a flash.&lt;/p&gt;

&lt;p&gt;Client-side restoration happens in &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssr/src/bean/sys.ssrState.ts" rel="noopener noreferrer"&gt;sys.ssrState.ts&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CLIENT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;cast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__INITIAL_STATE__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;SymbolSSRState&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;cast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__INITIAL_STATE__&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;delete&lt;/span&gt; &lt;span class="nf"&gt;cast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__INITIAL_STATE__&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'ssr-state-init'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// same for stateDefer&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It immediately deletes the global and removes the script node. Both steps ensure the state is consumed exactly once and memory is released.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. How Hydration Is Detected and Finalized
&lt;/h2&gt;

&lt;p&gt;Zova has no explicit &lt;code&gt;hydrateRoot&lt;/code&gt; call. It relies on a DOM signal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ssr.ts initialize()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CLIENT&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'data-server-rendered'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;SymbolIsRuntimeSsrPreHydration&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;data-server-rendered&lt;/code&gt; attribute is written into &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; by the server through the default &lt;code&gt;bodyAttrs&lt;/code&gt; in &lt;code&gt;_initContext()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="n"&gt;ssrContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_meta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;defu&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssrContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_meta&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;bodyAttrs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'data-server-rendered'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So at client startup Zova immediately knows: am I continuing from server-rendered DOM, or mounting from scratch?&lt;/p&gt;

&lt;p&gt;Vue 3's &lt;code&gt;createSSRApp().mount()&lt;/code&gt; already takes the hydration path, so Zova does not need to choose the API manually. What it does need is to know &lt;strong&gt;when hydration ends&lt;/strong&gt; — many things (initialization that must run once the browser is stable) should wait for that moment.&lt;/p&gt;

&lt;p&gt;The mechanism is a counter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;_hydratingRootInc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CLIENT&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isRuntimeSsrPreHydration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_hydratingInc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;_hydratingRootDec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CLIENT&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isRuntimeSsrPreHydration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_hydratingDec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;_hydratingDec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;SymbolHydratingCounter&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_hydrated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The root mounts (+1) and unmounts (-1); zero means done. &lt;code&gt;_hydrated()&lt;/code&gt; does three things:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;_hydrated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isRuntimeSsrPreHydration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isRuntimeSsrPreHydration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// flip the flag first&lt;/span&gt;

  &lt;span class="c1"&gt;// Let instances suspended during hydration update once&lt;/span&gt;
  &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;SymbolInstanceUpdates&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isUnmounted&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;zova&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"'insertBefore'"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;SymbolOnHydrateds&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That middle section is the key. During hydration, a component's reactive data may already have changed, but Vue defers rendering to match server DOM. After hydration, a single &lt;code&gt;update()&lt;/code&gt; brings the page into its true runtime state. The &lt;code&gt;'insertBefore'&lt;/code&gt; catch exists because the DOM may no longer perfectly match old vnodes after hydration — that error is harmless.&lt;/p&gt;

&lt;p&gt;On top of this, Zova exposes two callback APIs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;onHydrated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                    &lt;span class="c1"&gt;// runs only after the first SSR hydration&lt;/span&gt;
&lt;span class="nf"&gt;handleDirectOrOnHydrated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;// queue during hydration, invoke immediately otherwise&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second is for shared logic. The same code must wait for hydration under SSR and run immediately in a pure SPA; this wrapper adapts automatically.&lt;/p&gt;

&lt;p&gt;After hydration, Zova also marks the document:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'data-zova-hydrated'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SITE_ID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is for external monitoring and end-to-end tests — a way to confirm "this page really finished hydrating".&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Against Pages Router: Same Paradigm
&lt;/h2&gt;

&lt;p&gt;Now bring in Next.js Pages Router. Its chain is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Server&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getServerSideProps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;loadData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Framework output&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;script&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"__NEXT_DATA__"&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"application/json"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;script&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c1"&gt;// Client&lt;/span&gt;
&lt;span class="nf"&gt;hydrateRoot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'__next'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pageProps&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Structurally, it matches Zova:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Zova&lt;/th&gt;
&lt;th&gt;Next.js Pages Router&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Server rendering&lt;/td&gt;
&lt;td&gt;&lt;code&gt;renderToString&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;renderToString&lt;/code&gt; / &lt;code&gt;renderToPipeableStream&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;State injection&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;window.__INITIAL_STATE__&lt;/code&gt; + &lt;code&gt;__INITIAL_STATE_DEFER__&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;script id="__NEXT_DATA__"&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Serialization&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;unevalPatch&lt;/code&gt; → JS literal, direct assignment&lt;/td&gt;
&lt;td&gt;JSON, &lt;code&gt;JSON.parse&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hydration trigger&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;&amp;lt;body data-server-rendered&amp;gt;&lt;/code&gt; auto-detected&lt;/td&gt;
&lt;td&gt;Framework always calls &lt;code&gt;hydrateRoot&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data fetching&lt;/td&gt;
&lt;td&gt;Controller bean&lt;/td&gt;
&lt;td&gt;&lt;code&gt;getServerSideProps&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Component boundary&lt;/td&gt;
&lt;td&gt;None, full-tree hydration&lt;/td&gt;
&lt;td&gt;None, full-tree hydration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The differences are engineering details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zova splits state into two channels&lt;/strong&gt;; Pages Router has a single &lt;code&gt;__NEXT_DATA__&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zova detects hydration via a DOM attribute&lt;/strong&gt;; Pages Router hardcodes it, with no runtime branch for "should this page hydrate".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zova has an &lt;code&gt;onHydrated&lt;/code&gt; lifecycle&lt;/strong&gt;; Pages Router can only approximate it with &lt;code&gt;useEffect&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zova fetches through controllers&lt;/strong&gt;, which carry authentication, authorization, and parameter validation; &lt;code&gt;getServerSideProps&lt;/code&gt; is a bare function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So within this paradigm, Zova is better described as "Pages Router with every weak spot patched" rather than "a different approach".&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Against App Router: Different Paradigm
&lt;/h2&gt;

&lt;p&gt;App Router hydration is a different matter. The key is the &lt;code&gt;'use client'&lt;/code&gt; directive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app/page.tsx — a Server Component by default; no JS is shipped&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'https://api.example.com/data'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Counter&lt;/span&gt; &lt;span class="n"&gt;initial&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// app/counter.tsx — explicitly a Client Component&lt;/span&gt;
&lt;span class="s1"&gt;'use client'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;initial&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;setN&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;initial&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt; &lt;span class="n"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What happens on the server:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Server Component executes; the &lt;code&gt;fetch&lt;/code&gt; result stays on the server.&lt;/li&gt;
&lt;li&gt;The Client Component &lt;strong&gt;does not execute&lt;/strong&gt;; it is serialized into a placeholder plus props plus chunk reference.&lt;/li&gt;
&lt;li&gt;Both are compiled into a Flight-protocol payload (RSC Payload).&lt;/li&gt;
&lt;li&gt;HTML is generated from the RSC output; Client Component positions are empty containers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What the browser does:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Renders the HTML first (Client Component positions are empty or show fallbacks).&lt;/li&gt;
&lt;li&gt;Loads the RSC Payload; React calls &lt;code&gt;hydrateRoot&lt;/code&gt; once on the root container.&lt;/li&gt;
&lt;li&gt;Loads the matching chunk and mounts only when it reaches a Client Component boundary.&lt;/li&gt;
&lt;li&gt;Server Component output stays static and never participates in hydration.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Against Zova:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dimension&lt;/th&gt;
&lt;th&gt;Zova&lt;/th&gt;
&lt;th&gt;Next.js App Router&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Components needing hydration&lt;/td&gt;
&lt;td&gt;All&lt;/td&gt;
&lt;td&gt;Client Components only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JS shipped&lt;/td&gt;
&lt;td&gt;All component code&lt;/td&gt;
&lt;td&gt;Client Components only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data transport&lt;/td&gt;
&lt;td&gt;Custom state object&lt;/td&gt;
&lt;td&gt;Flight payload&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Render API&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;renderToString&lt;/code&gt; (sync)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;renderToReadableStream&lt;/code&gt; (streaming)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First byte&lt;/td&gt;
&lt;td&gt;After full-tree render&lt;/td&gt;
&lt;td&gt;Per Suspense boundary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Error isolation&lt;/td&gt;
&lt;td&gt;One error → whole page 500&lt;/td&gt;
&lt;td&gt;Fallback within the boundary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data fetching&lt;/td&gt;
&lt;td&gt;Controller bean&lt;/td&gt;
&lt;td&gt;Direct &lt;code&gt;fetch&lt;/code&gt; in Server Component&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mismatch surface&lt;/td&gt;
&lt;td&gt;Entire tree&lt;/td&gt;
&lt;td&gt;Client Components only&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The essential difference in one sentence: &lt;strong&gt;App Router cuts hydration demand at the component source; Zova hydrates the entire tree.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The costs differ too. App Router buys a tiny first-load JS bundle and progressive streaming, at the price of requiring developers to understand the Server / Client boundary: &lt;code&gt;useState&lt;/code&gt; only in Client Components, no event handlers in Server Components, serializable values across boundaries, and Server Actions as yet another mental model.&lt;/p&gt;

&lt;p&gt;Zova buys "one component runs on both sides" — any SFC can use &lt;code&gt;ref&lt;/code&gt;, &lt;code&gt;onMounted&lt;/code&gt;, &lt;code&gt;$useState&lt;/code&gt; directly without thinking about boundaries. The price is that first-load JS includes all component code, and the whole tree carries mismatch risk.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Three Zova-Specific Details
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Dual-channel state to start the first paint early
&lt;/h3&gt;

&lt;p&gt;As mentioned, one design judgment deserves emphasis. &lt;code&gt;__INITIAL_STATE__&lt;/code&gt; carries only the fields required at startup; query cache goes through the defer channel. Pages Router has no equivalent — Next.js puts all props into one &lt;code&gt;__NEXT_DATA__&lt;/code&gt;, and large pages slow down head parsing.&lt;/p&gt;

&lt;p&gt;Zova's approach is essentially a manual priority split between the critical rendering path and non-critical data.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Controller-load errors are replayed
&lt;/h3&gt;

&lt;p&gt;This is Zova's most interesting piece. From &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssr/src/lib/ssr.ts" rel="noopener noreferrer"&gt;ssr.ts&lt;/a&gt;, &lt;code&gt;controllerLoad&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;controllerLoad&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;IControllerLoadEvent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;phase&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'prepare'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SERVER&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;controllerLoadKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_allocateControllerLoadKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// Client hydration phase&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_allocateControllerLoadKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stateDefer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;controllerLoad&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;controllerBeanName&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;controllerBeanName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;delete&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stateDefer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;controllerLoad&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replayError&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;_createControllerLoadError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replayControllerRecorded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;controllerRecorded&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// Server: store the error as a snapshot&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;phase&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'fallback'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SERVER&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;controllerLoadKey&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stateDefer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;controllerLoad&lt;/span&gt; &lt;span class="o"&gt;??=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;_createControllerLoadErrorSnapshot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A server-side controller load fails (401, 404, redirect, etc.).&lt;/li&gt;
&lt;li&gt;The error's &lt;code&gt;name / message / code / status / pagePath&lt;/code&gt; is serialized into a snapshot under &lt;code&gt;stateDefer.controllerLoad&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;During client hydration, the same controller is reached and a structurally identical key locates the snapshot.&lt;/li&gt;
&lt;li&gt;The error is &lt;strong&gt;replayed&lt;/strong&gt; instead of re-requested.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Why replay? Because authentication state, cookie availability, and request context may differ between server and client. A re-request could produce a different result — the server redirects to login while the client gets data, and hydration breaks. Replay guarantees &lt;strong&gt;both sides see the same controller result&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The key construction is worth a look; it concatenates the component path from root to current, vnode keys, and occurrence index:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ComponentInternalInstance&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__file&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__name&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;'anonymous'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;unshift&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${name}:${String(current.vnode.key ?? '')}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;structuralKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;occurrence&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_controllerLoadSequence&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;structuralKey&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_controllerLoadSequence&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;structuralKey&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;occurrence&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sb"&gt;`${structuralKey}#${occurrence}:${event.controllerBeanName ?? ''}`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This distinguishes "the same controller appearing multiple times on one page" — each instance gets its own error.&lt;/p&gt;

&lt;p&gt;Next.js has no counterpart. App Router &lt;code&gt;fetch&lt;/code&gt; failures are encoded into the RSC Payload and caught by error boundaries; Pages Router &lt;code&gt;getServerSideProps&lt;/code&gt; throws straight into a 500. Neither needs cross-side replay, because fetching only happens on the server.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Attribute mismatches are tolerated
&lt;/h3&gt;

&lt;p&gt;Vue's hydration reports attribute differences as errors. Zova adds a &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssr/src/lib/ssr.ts" rel="noopener noreferrer"&gt;default tolerance policy&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;_onHydratePropHasMismatchDefault&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;clientValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_vnode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_instance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;ignore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'class'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;ignore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clientValue&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'class'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;normalizeClass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clientValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'style'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// same: overwrite with client value&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'for'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'d'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'aria-labelledby'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'aria-controls'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// overwrite directly&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'value'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// textarea uses .value, others use setAttribute&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;isBooleanAttr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// boolean attributes by presence/absence&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`data-hydrate-ignore-${key}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// developer opt-out&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ignore&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ignore&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;clientValue&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The attribute set is deliberate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;class&lt;/code&gt; / &lt;code&gt;style&lt;/code&gt;: animations, themes, and breakpoints may compute differently on each side; not a bug.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;id&lt;/code&gt; / &lt;code&gt;name&lt;/code&gt; / &lt;code&gt;for&lt;/code&gt; / &lt;code&gt;d&lt;/code&gt; / &lt;code&gt;aria-*&lt;/code&gt;: common in generated IDs, SVG paths, accessibility links; small differences do not matter.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;value&lt;/code&gt;: the user may have already edited the field; hydration should not overwrite it.&lt;/li&gt;
&lt;li&gt;Boolean attributes: &lt;code&gt;disabled&lt;/code&gt;, &lt;code&gt;checked&lt;/code&gt; — presence semantics are more robust.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is also a manual escape hatch: &lt;code&gt;data-hydrate-ignore-${key}&lt;/code&gt;. Add &lt;code&gt;data-hydrate-ignore-title&lt;/code&gt; to an element and that attribute will not error during hydration; the client value wins.&lt;/p&gt;

&lt;p&gt;The value of this policy is &lt;strong&gt;separating legitimate differences from real bugs&lt;/strong&gt; — ignore the former by default so the latter stand out.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Resource Preloading: The Difference Is Not the Manifest
&lt;/h2&gt;

&lt;p&gt;Two things must be separated here, or the conclusion goes wrong:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The module-to-output-file mapping&lt;/strong&gt;, i.e. &lt;code&gt;quasar.manifest.json&lt;/code&gt;. It is a build artifact — the production build generates it, and the development build generates it too. It is read-only at request time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Which modules this specific request actually used.&lt;/strong&gt; That is runtime information; it only exists after the whole component tree has run.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Zova filters by the second and looks up the first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ssrHandler.ts&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;modules&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;cast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssrContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;ssrContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;endingHeadTags&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_renderModulesPreload_zova&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ssrContext&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;ssrContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;endingHeadTags&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_renderModulesPreload&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ssrContext&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And collecting the second is &lt;strong&gt;production-only&lt;/strong&gt;. In &lt;code&gt;moduleLoaded&lt;/code&gt; of &lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssr/src/monkey.ts" rel="noopener noreferrer"&gt;a-ssr/src/monkey.ts&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;moduleLoaded&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;module&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;IModule&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ssrContext.modules&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SERVER&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;PROD&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;$ssr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;$ssr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;$ssr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`@@${module.info.relativeName}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So in development, modulepreload for Zova modules is &lt;strong&gt;not generated at all&lt;/strong&gt; — not "generated after rendering".&lt;/p&gt;

&lt;p&gt;The manifest's shape confirms it is a build artifact: keys are source module paths or hashed output filenames, and values are the dependency file lists. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;".quasar/prod-ssr/client-entry.js"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/assets/index-xxxx.js"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"a-api-DvAtaMhL.js"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/assets/wrapAsyncGenerator-DhsawSOn.js"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Zova turns &lt;code&gt;@@a-api&lt;/code&gt; into a prefix &lt;code&gt;a-api-&lt;/code&gt; and scans for keys ending in &lt;code&gt;.js&lt;/code&gt;, caching the hit in &lt;code&gt;_ssrModulesZovaCache&lt;/code&gt; — a process-level cache that never expires:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;prefix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sb"&gt;`${id.substring(2)}-`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;postfix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'.js'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_clientManifest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prefix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;endsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;postfix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_resolveUrlPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`/assets/${key}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that this is a &lt;strong&gt;linear prefix scan&lt;/strong&gt;, because the manifest is oriented as "file → dependencies", not "module → file", so a reverse lookup is required. Once found, tags are dispatched by extension: js to &lt;code&gt;modulepreload&lt;/code&gt;, css to &lt;code&gt;stylesheet&lt;/code&gt;, fonts and images to &lt;code&gt;preload&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So the real difference is not when the manifest is generated — both are build-time. It is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can "which chunks this page needs" be determined statically before rendering?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;App Router can. The route-segment-to-chunk mapping is static in the build output, so the server knows what to preload before rendering; with chunk references embedded in the RSC Payload, the browser can even fetch on &lt;code&gt;&amp;lt;Link&amp;gt;&lt;/code&gt; hover.&lt;/p&gt;

&lt;p&gt;Zova cannot. Its modules are loaded on demand at runtime — &lt;code&gt;app.meta.module.use(relativeName)&lt;/code&gt; pulls in a module only when routing reaches it. So "which modules this page hits" depends on the controller load path and the actual component tree expansion, and is only known after rendering.&lt;/p&gt;

&lt;p&gt;In one line: &lt;strong&gt;the mapping is static, the hit set is dynamic.&lt;/strong&gt; A static mapping alone cannot move preloading earlier; what actually determines the timing is whether the page-to-chunk binding can be solved before rendering.&lt;/p&gt;

&lt;p&gt;Pages Router sits in between — build artifacts exist, but preloading relies mostly on &lt;code&gt;next/link&lt;/code&gt; and &lt;code&gt;&amp;lt;Head&amp;gt;&lt;/code&gt;, not as deeply integrated as App Router.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. Trade-offs
&lt;/h2&gt;

&lt;p&gt;Putting both sides into one table makes the sacrifices visible:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Zova&lt;/th&gt;
&lt;th&gt;Next.js Pages Router&lt;/th&gt;
&lt;th&gt;Next.js App Router&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Component mental model&lt;/td&gt;
&lt;td&gt;One component, both sides&lt;/td&gt;
&lt;td&gt;Same&lt;/td&gt;
&lt;td&gt;Must distinguish Server / Client&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First-load JS&lt;/td&gt;
&lt;td&gt;Entire tree&lt;/td&gt;
&lt;td&gt;Entire tree&lt;/td&gt;
&lt;td&gt;Client Components only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TTFB&lt;/td&gt;
&lt;td&gt;After full render&lt;/td&gt;
&lt;td&gt;Streamable&lt;/td&gt;
&lt;td&gt;Streamable + sliced&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;State injection&lt;/td&gt;
&lt;td&gt;Dual channel&lt;/td&gt;
&lt;td&gt;Single channel&lt;/td&gt;
&lt;td&gt;Flight payload&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data fetching&lt;/td&gt;
&lt;td&gt;Controller bean (full backend capabilities)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;getServerSideProps&lt;/code&gt; (bare function)&lt;/td&gt;
&lt;td&gt;In-component &lt;code&gt;fetch&lt;/code&gt; (with cache semantics)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hydration lifecycle&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;onHydrated&lt;/code&gt; / &lt;code&gt;handleDirectOrOnHydrated&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;None, &lt;code&gt;useEffect&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;None, &lt;code&gt;useEffect&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pre-hydration consistency&lt;/td&gt;
&lt;td&gt;Error snapshot replay&lt;/td&gt;
&lt;td&gt;Not guaranteed&lt;/td&gt;
&lt;td&gt;Guaranteed by RSC Payload&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cache granularity&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;public&lt;/code&gt; / &lt;code&gt;session&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Page-level&lt;/td&gt;
&lt;td&gt;Segment + fetch + tag&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Migration cost&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;Low (isomorphic)&lt;/td&gt;
&lt;td&gt;High (paradigm shift)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three judgments:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Zova chose "the full app runs on both sides"&lt;/strong&gt;, keeping all complexity inside the framework (dual channel, error replay, attribute tolerance, context lifecycle). It is a "framework thinks more, developer thinks less" choice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pages Router is a different implementation of the same choice&lt;/strong&gt;, with less polish. Its historical value is proving that "embed initial state in HTML + &lt;code&gt;hydrateRoot&lt;/code&gt;" works for many years.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;App Router is a paradigm shift.&lt;/strong&gt; It acknowledges the cost of full hydration and trades component boundaries for first-load performance, pushing complexity onto developers — every component must answer "where does this run?"&lt;/p&gt;

&lt;p&gt;So "who hydrates better" has no universal answer. It depends on whether you would rather put complexity in the framework or in your head.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. Summary
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Next.js has two generations of SSR: Pages Router is isomorphic to Zova (state embedded in HTML + full-tree hydration); App Router is heteromorphic (RSC + selective hydration). The comparison must start by separating these.&lt;/li&gt;
&lt;li&gt;Zova's server chain is &lt;code&gt;resolveRoute → serverEntry → renderToString → onRendered → renderTemplate&lt;/code&gt;, synchronous and serial, with no streaming slices.&lt;/li&gt;
&lt;li&gt;State uses two channels: &lt;code&gt;__INITIAL_STATE__&lt;/code&gt; in head (startup-critical) and &lt;code&gt;__INITIAL_STATE_DEFER__&lt;/code&gt; in body (bulky, deferrable).&lt;/li&gt;
&lt;li&gt;Hydration is detected via &lt;code&gt;data-server-rendered&lt;/code&gt; and finalized when &lt;code&gt;HydratingCounter&lt;/code&gt; reaches zero; at that point instances suspended during hydration get one &lt;code&gt;update()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Three Zova-specific details are worth borrowing: dual-channel priority, cross-side controller error replay, and classified attribute tolerance.&lt;/li&gt;
&lt;li&gt;If Zova evolves further, the two App Router ideas most worth borrowing are streaming rendering and component-level JS pruning — but both require changes to the backend response pipeline and the component model, not small patches.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  References and Source
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Zova / Cabloy
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssr/src/lib/ssr.ts" rel="noopener noreferrer"&gt;SSR context and hydration lifecycle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssr/src/bean/sys.ssrState.ts" rel="noopener noreferrer"&gt;SSR state restoration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssr/src/lib/ssrMetaStore.ts" rel="noopener noreferrer"&gt;State injection and meta management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssrserver/src/service/ssrHandler.ts" rel="noopener noreferrer"&gt;SSR render service&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-model/src/service/storage.ts" rel="noopener noreferrer"&gt;Query cache dehydrate / hydrate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-router/src/monkey.ts" rel="noopener noreferrer"&gt;Router alignment between server and client&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/zova/src/suite-vendor/a-zova/modules/a-ssr/src/monkey.ts" rel="noopener noreferrer"&gt;SSR module assembly and the hydrated hook&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Next.js
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://nextjs.org/docs/pages/building-your-application/data-fetching" rel="noopener noreferrer"&gt;Pages Router: Data Fetching&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nextjs.org/docs/app/building-your-application/rendering/server-components" rel="noopener noreferrer"&gt;App Router: Server Components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nextjs.org/docs/app/building-your-application/rendering/client-components" rel="noopener noreferrer"&gt;App Router: Client Components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://react.dev/reference/react-dom/client/hydrateRoot" rel="noopener noreferrer"&gt;React: hydrateRoot&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ssr</category>
      <category>nextjs</category>
      <category>cabloy</category>
      <category>zova</category>
    </item>
    <item>
      <title>Why Cabloy/Vona Has No NestJS Dynamic Module</title>
      <dc:creator>Uncle Pushui</dc:creator>
      <pubDate>Sat, 14 Nov 2026 12:48:48 +0000</pubDate>
      <link>https://dev.to/uncle-pushui/why-cabloyvona-has-no-nestjs-dynamic-module-2b2b</link>
      <guid>https://dev.to/uncle-pushui/why-cabloyvona-has-no-nestjs-dynamic-module-2b2b</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;NestJS builds a module definition before assembly; Vona never has a module definition to build.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Anyone who has used NestJS knows &lt;code&gt;forRoot()&lt;/code&gt;. When wiring a database, a queue, or a config module, almost every third-party package offers a static method that takes your options:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Module&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;TypeOrmModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forRoot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'mysql'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'localhost'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppModule&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first this looks like "the advanced way to write a module." After a while it becomes clear that it is a patch — a patch over the premise that a module definition must be known in advance.&lt;/p&gt;

&lt;p&gt;Coming to Cabloy/Vona, many people look for the equivalent: components, configuration, and scaffolding are all there, but there is no such thing as a "dynamic module." The reason is not that it has not been built yet. It is that &lt;strong&gt;the problem it solves does not exist in Vona&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. What a Dynamic Module Actually Does
&lt;/h2&gt;

&lt;p&gt;Start with the minimal form. A dynamic module usually looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Module&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PayModule&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;forRoot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PayModuleOptions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;DynamicModule&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;module&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PayModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;provide&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;PAY_OPTIONS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;useValue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nc"&gt;PayService&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;PayService&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;forRootAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PayModuleAsyncOptions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;DynamicModule&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;module&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PayModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imports&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="n"&gt;provide&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;PAY_OPTIONS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="n"&gt;useFactory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;useFactory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="n"&gt;inject&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inject&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nc"&gt;PayService&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;PayService&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three traits matter:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The module class itself is an empty shell; &lt;code&gt;@Module({})&lt;/code&gt; declares no providers.&lt;/li&gt;
&lt;li&gt;The real &lt;code&gt;providers / exports / imports&lt;/code&gt; are returned by a static method.&lt;/li&gt;
&lt;li&gt;The return value is still a &lt;strong&gt;module definition&lt;/strong&gt; — it is simply computed later.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In other words, a Dynamic Module is a deferred constructor for a module definition. It does not change what a module means; it changes &lt;strong&gt;when the module definition is computed&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Why NestJS Must Have This Layer
&lt;/h2&gt;

&lt;p&gt;Because in NestJS a module is not "a directory of code" — it is &lt;strong&gt;input to the container compiler&lt;/strong&gt;. &lt;code&gt;imports / providers / exports&lt;/code&gt; must all be settled before &lt;code&gt;NestFactory.create()&lt;/code&gt;, so the container can build the dependency graph, instantiate providers, and enforce visibility.&lt;/p&gt;

&lt;p&gt;But the following information is unavailable when the &lt;code&gt;@Module&lt;/code&gt; decorator is evaluated:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Need&lt;/th&gt;
&lt;th&gt;Typical case&lt;/th&gt;
&lt;th&gt;Why a static decorator cannot express it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Caller-supplied options&lt;/td&gt;
&lt;td&gt;Database URL, payment keys, tenant config&lt;/td&gt;
&lt;td&gt;The options belong to the consumer, not the library&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Async configuration&lt;/td&gt;
&lt;td&gt;Remote config center, secret manager&lt;/td&gt;
&lt;td&gt;Decorator evaluation is synchronous&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multiple instances of one module&lt;/td&gt;
&lt;td&gt;Several DB connections, several queues&lt;/td&gt;
&lt;td&gt;One class has one set of module metadata&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Conditional provider sets&lt;/td&gt;
&lt;td&gt;An implementation set chosen by environment&lt;/td&gt;
&lt;td&gt;The provider array depends on conditions not yet known&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These four look different, but share one root cause: &lt;strong&gt;the module definition must be fixed before compilation, while the information that determines it is not complete before compilation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So the definition has to be lifted off the class and turned into a function, letting &lt;code&gt;forRoot / forRootAsync / register&lt;/code&gt; fill it in during bootstrap. &lt;code&gt;forRootAsync&lt;/code&gt; goes one step further and wraps "a definition that will be ready later" as an async provider.&lt;/p&gt;

&lt;p&gt;Once you see this, the test for any other framework becomes obvious: &lt;strong&gt;if the module is no longer compiler input, a Dynamic Module loses its ground to stand on.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  3. What a Vona Module Is
&lt;/h2&gt;

&lt;p&gt;A Vona module consists of three things: a directory and package layout, the &lt;code&gt;vonaModule&lt;/code&gt; metadata in &lt;code&gt;package.json&lt;/code&gt;, and the namespace under which config, locales, and resources live.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"vonaModule"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"fileVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"a-core"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"5.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"a-orm"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"5.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"a-user"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"5.0.0"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"onions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"payProvider"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"scopeResource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is no &lt;code&gt;providers&lt;/code&gt;, no &lt;code&gt;exports&lt;/code&gt;, and no &lt;code&gt;imports&lt;/code&gt;. A module does not declare what the container holds, and certainly not who may see it.&lt;/p&gt;

&lt;p&gt;Beans are registered the moment their decorator runs. &lt;code&gt;createBeanDecorator&lt;/code&gt; writes the class straight into the global &lt;code&gt;AppResource&lt;/code&gt;, keyed by &lt;code&gt;{module}.{scene}.{name}&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// excerpt&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createBeanDecorator&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scene&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;optionsPrimitive&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;beanClass&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;unknown&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nc"&gt;Constructable&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="kd"&gt;module&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parseModuleName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;beanClass&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scene&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'scope'&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'module'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;beanOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;appResource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addBean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;module&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scene&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;beanClass&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;beanClass&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The container is a flat two-level structure (app and ctx). Getting a bean is a lookup by name, and instantiation happens only on a miss:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// excerpt&lt;/span&gt;
&lt;span class="n"&gt;_getBeanSelectorInner&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;beanFullName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Constructable&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;beanOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;appResource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;beanFullName&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;any&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;beanOptions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;fullName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;beanOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;beanFullName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;__getSelectorKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fullName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;withSelector&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;SymbolBeanContainerInstances&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_newBeanInner&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fullName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;withSelector&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;SymbolBeanContainerInstances&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="no"&gt;T&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A module provides only two things here: &lt;strong&gt;ownership&lt;/strong&gt; (&lt;code&gt;moduleBelong&lt;/code&gt;, which determines &lt;code&gt;this.scope&lt;/code&gt;, config paths, and log labels) and &lt;strong&gt;load order&lt;/strong&gt; (&lt;code&gt;vonaModule.dependencies&lt;/code&gt;). It provides no visibility boundary, so the question "which providers does this module instance expose?" never arises.&lt;/p&gt;

&lt;p&gt;The contrast in one line:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A NestJS module = compile unit + DI boundary + visibility rules.&lt;/li&gt;
&lt;li&gt;A Vona module = code organization + a namespace for config and resources.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The former's module definition must be constructed ahead of time. The latter's "module definition" was never an object.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Requirement 1: Passing Config — Config Is Data, Not a Constructor Argument
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;forRoot(options)&lt;/code&gt; exists because options participate in provider construction. Vona removes configuration from module construction entirely: a module supplies defaults, and application config overrides them during the load phase.&lt;/p&gt;

&lt;p&gt;A module's default config lives in &lt;code&gt;src/config/config.ts&lt;/code&gt; and exports a function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// a-file/src/config/config.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;VonaApplication&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;defaultProvider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'file-native:native'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;upload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;maxSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During the module load phase (after the &lt;code&gt;moduleLoading&lt;/code&gt; hook), the loader merges it into &lt;code&gt;app.config.modules[relativeName]&lt;/code&gt;, with application config placed after the module defaults:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kd"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;relativeName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deepExtend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;configModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kd"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;relativeName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Application-level customization is written in the project config and overrides data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/backend/config/config/config.ts&lt;/span&gt;
&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'a-file'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;defaultProvider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'file-cloudflare:cloudflare'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Modules that need environment separation go further. The ORM module, for example, layers dev / prod / test defaults inside its own &lt;code&gt;Main.moduleLoading()&lt;/code&gt; and then puts application config on top:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Main&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;BeanSimple&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;IModuleMain&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;moduleLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;_configDefault&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;combineConfigDefault&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ConfigDatabase&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;configDefault&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;configDev&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;configProd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;configTest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;database&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deepExtend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_configDefault&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;database&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;moduleLoaded&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// extend Knex, expose ctx.db, etc.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;configLoaded&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_config&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that &lt;code&gt;Main&lt;/code&gt; is instantiated during the module load phase, while application config has already been loaded by then. So "passing config to a library module" in Vona is a &lt;strong&gt;config merge&lt;/strong&gt;: fixed timing, clear direction (application over module defaults), no module definition regeneration required.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Requirement 2: Async — The Load Phase and Lifecycle Already Absorb It
&lt;/h2&gt;

&lt;p&gt;The root cause of &lt;code&gt;forRootAsync&lt;/code&gt; is that a module definition must be returned synchronously while its dependencies are asynchronous. Vona has no such constraint; the entire startup chain is asynchronous.&lt;/p&gt;

&lt;p&gt;The startup order can be summarized as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;appConfig → appLoad (moduleLoading → config/locale/error/constant → moduleLoaded) → appStart → appReady → appStarted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the source, &lt;code&gt;Start.start()&lt;/code&gt; runs &lt;code&gt;_start_appConfig&lt;/code&gt;, &lt;code&gt;_start_appLoad&lt;/code&gt;, &lt;code&gt;_start_appStart&lt;/code&gt;, &lt;code&gt;_start_appReady&lt;/code&gt;, &lt;code&gt;_start_appStarted&lt;/code&gt; in order. Among them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A config item may return a Promise, and multiple items are evaluated in parallel with &lt;code&gt;Promise.all&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;A module's &lt;code&gt;Main.moduleLoading()&lt;/code&gt; and &lt;code&gt;Main.moduleLoaded()&lt;/code&gt; are async and can read remote config, extend third-party libraries, and attach &lt;code&gt;ctx&lt;/code&gt; properties;&lt;/li&gt;
&lt;li&gt;Application-level async initialization goes into &lt;code&gt;Monkey.appStart()&lt;/code&gt; and &lt;code&gt;Monkey.appReady()&lt;/code&gt;, invoked by the framework in module order.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Monkey&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;BeanSimple&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;IMonkeyAppStart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;IMonkeyAppReady&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;appStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__ThisModule__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;appReady&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__ThisModule__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appReady&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Database connections, queue consumers, and secret fetching — the things that must complete before serving traffic — live in &lt;code&gt;moduleLoaded&lt;/code&gt; or &lt;code&gt;appStart&lt;/code&gt;. They take no part in constructing a module definition, so there is no need for "a module definition that will be ready later."&lt;/p&gt;

&lt;p&gt;NestJS's &lt;code&gt;forRootAsync&lt;/code&gt; pushes asynchrony into the module definition; Vona puts asynchrony back into the startup flow. The latter already has explicit phases and ordering; the former exists to work around "the definition must be synchronous."&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Requirement 3: Multiple Instances — No Module Instance, Only Bean Names
&lt;/h2&gt;

&lt;p&gt;The other major use of Dynamic Modules is registering the same module multiple times: multiple databases, multiple queues, multiple tenants.&lt;/p&gt;

&lt;p&gt;NestJS needs dynamic modules here because a module is a compile unit: one class has one set of metadata, and "one more copy" means generating a second module definition.&lt;/p&gt;

&lt;p&gt;Vona has no "module instance" layer at all. Multiple implementations are simply &lt;strong&gt;multiple beans registered side by side&lt;/strong&gt;, each with a unique fully qualified name:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Domain&lt;/th&gt;
&lt;th&gt;Scene&lt;/th&gt;
&lt;th&gt;Implementations (each its own module)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Payments&lt;/td&gt;
&lt;td&gt;&lt;code&gt;payProvider&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;pay-stripe&lt;/code&gt;, &lt;code&gt;pay-paypal&lt;/code&gt;, &lt;code&gt;pay-mock&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Files&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fileProvider&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;file-native&lt;/code&gt;, &lt;code&gt;file-cloudflare&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auth&lt;/td&gt;
&lt;td&gt;&lt;code&gt;authProvider&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;auth-simple&lt;/code&gt;, &lt;code&gt;auth-oauth&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Captcha&lt;/td&gt;
&lt;td&gt;&lt;code&gt;captchaProvider&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;captcha-simple&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A consumer does not receive a module instance. It receives a name, which is then converted into a bean full name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Bean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BeanPayProvider&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;BeanBase&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;N&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;keyof&lt;/span&gt; &lt;span class="nc"&gt;IPayProviderRecord&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;providerName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;beanFullName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;beanFullNameFromOnionName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;providerName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'payProvider'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bean&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_getBean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;beanFullName&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;never&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even "multiple clients of the same implementation" does not require multiple modules. It is a &lt;code&gt;clients&lt;/code&gt; map in config plus a &lt;code&gt;clientName&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;clientOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clients&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;clientName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;resolvedOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deepExtend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;clientOptions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;payProviderClientOptions&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sb"&gt;`${providerName}/${clientName}`&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As a result, an API like &lt;code&gt;register()&lt;/code&gt; — "register another copy of the module" — has nowhere to stand. There is no module object to instantiate again, only new bean names or new config keys.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Requirement 4: Conditional Providers and Module Customization
&lt;/h2&gt;

&lt;p&gt;The last need is "decide what the container holds based on conditions." Vona handles it in two layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Registration time&lt;/strong&gt;: scene decorators register statically, so every implementation is in the registry;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resolution time&lt;/strong&gt;: onion options &lt;code&gt;enable / match / ignore&lt;/code&gt; decide whether an implementation is currently active, with &lt;code&gt;VonaConfig.onions&lt;/code&gt; and &lt;code&gt;ctx.onionsDynamic&lt;/code&gt; providing application-level and request-level switches.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Differentiated customization goes through &lt;code&gt;config&lt;/code&gt; plus monkey hooks: &lt;code&gt;moduleLoading&lt;/code&gt;, &lt;code&gt;moduleLoaded&lt;/code&gt;, &lt;code&gt;configLoaded&lt;/code&gt;, &lt;code&gt;appStart&lt;/code&gt;, &lt;code&gt;appReady&lt;/code&gt;, &lt;code&gt;appStarted&lt;/code&gt;, &lt;code&gt;appClose&lt;/code&gt;, &lt;code&gt;appClosed&lt;/code&gt;. These hooks run in module order and change metadata, config, and resources — not "return a new module definition."&lt;/p&gt;

&lt;p&gt;One point deserves emphasis: &lt;code&gt;vonaModule.dependencies&lt;/code&gt; is used only for load order and minimum version constraints. It &lt;strong&gt;creates no dependency-injection edges&lt;/strong&gt;. That is why a module can be added later, or referenced before it is assembled, without rearranging an assembly graph.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. Side by Side
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Need&lt;/th&gt;
&lt;th&gt;NestJS&lt;/th&gt;
&lt;th&gt;Vona&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pass options to a library module&lt;/td&gt;
&lt;td&gt;&lt;code&gt;forRoot(options)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Override &lt;code&gt;config.modules[name]&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Async configuration&lt;/td&gt;
&lt;td&gt;&lt;code&gt;forRootAsync&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The config pipeline is async itself&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multiple instances of one module&lt;/td&gt;
&lt;td&gt;Register dynamic modules repeatedly&lt;/td&gt;
&lt;td&gt;Multiple bean names + resolver / selector&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Conditional provider sets&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;register()&lt;/code&gt; returns providers&lt;/td&gt;
&lt;td&gt;Static decorator registration + onion &lt;code&gt;enable/match&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Module visibility isolation&lt;/td&gt;
&lt;td&gt;&lt;code&gt;imports / exports&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;None (single container, lookup by name)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Customize an existing module&lt;/td&gt;
&lt;td&gt;Dynamic module options&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;config&lt;/code&gt; overrides + monkey hooks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dependency ordering&lt;/td&gt;
&lt;td&gt;Module import graph&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;vonaModule.dependencies&lt;/code&gt; (order/version only)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Binding time&lt;/td&gt;
&lt;td&gt;Before container compile&lt;/td&gt;
&lt;td&gt;On every &lt;code&gt;_getBean&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The last row is the summary. Once binding happens at resolution time, everything that "must be computed in advance" simply disappears.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. The Cost
&lt;/h2&gt;

&lt;p&gt;This design is not free. It just moves the cost to the other side.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What NestJS buys&lt;/strong&gt; is an explicit dependency graph and visibility boundary: the provider set is static, module exports are obvious, and compile-time and static analysis can offer stronger guarantees. The price is that module definitions must be constructible in advance, which requires the Dynamic Module layer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Vona buys&lt;/strong&gt; is zero assembly-order constraints and plug-and-play modules: a new implementation is just a new bean, switching implementations is just a config change, and modules create no static dependency edges. The price is that dependencies become a &lt;strong&gt;name contract&lt;/strong&gt; — visibility and assembly correctness are not enforced by the compiler but rely on naming conventions, scope constraints, and tests.&lt;/p&gt;

&lt;p&gt;If one day you genuinely need "multiple isolated DI graphs" (strongly isolated multi-tenancy, for example), Vona's answer is still not "register the module several times." It is to make isolation explicit with namespaces, separate container instances, and selectors. That path still does not pass through the concept of a dynamic module.&lt;/p&gt;




&lt;h2&gt;
  
  
  10. Summary
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;A Dynamic Module is a deferred constructor for a module definition, serving the premise that a module definition must be fixed before compilation;&lt;/li&gt;
&lt;li&gt;Vona modules carry no DI-boundary or visibility responsibility. Beans are registered into a global registry by decorators and resolved by name, so there is no module definition to construct in advance;&lt;/li&gt;
&lt;li&gt;The four needs — passing config, async config, multiple instances, conditional providers — are absorbed by config merging, the startup phases, multiple bean names, and onion filtering respectively;&lt;/li&gt;
&lt;li&gt;This is not "Vona also implements dynamic modules." It is &lt;strong&gt;removing the premise on which dynamic modules depend&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The same reason explains why Vona's Provider Scene can replace NestJS's Dynamic Providers: once binding is deferred to resolution time, multiple implementations cost the dependency structure nothing.&lt;/p&gt;




&lt;h2&gt;
  
  
  References &amp;amp; Source
&lt;/h2&gt;

&lt;h3&gt;
  
  
  NestJS
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.nestjs.com/modules#dynamic-modules" rel="noopener noreferrer"&gt;NestJS Modules / Dynamic Modules&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.nestjs.com/fundamentals/custom-providers" rel="noopener noreferrer"&gt;NestJS Custom Providers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.nestjs.com/fundamentals/circular-dependency" rel="noopener noreferrer"&gt;NestJS Circular Dependency&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  CabloyJS / Vona
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/packages-vona/vona-core/src/lib/decorator/class/createBeanDecorator.ts" rel="noopener noreferrer"&gt;Bean decorator: the registration entry&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/packages-vona/vona-core/src/lib/core/resource.ts" rel="noopener noreferrer"&gt;Global bean registry AppResource&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/packages-vona/vona-core/src/lib/bean/beanContainer.ts" rel="noopener noreferrer"&gt;BeanContainer: lookup by name and lazy instantiation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/packages-vona/vona-core/src/lib/module/config.ts" rel="noopener noreferrer"&gt;Module config loading and merging&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/packages-vona/vona-core/src/lib/module/loader.ts" rel="noopener noreferrer"&gt;Module load pipeline ModuleLoader&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/packages-vona/vona-core/src/lib/framework/start.ts" rel="noopener noreferrer"&gt;Startup phase orchestration Start&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/packages-vona/vona-core/src/lib/core/config.ts" rel="noopener noreferrer"&gt;Config layering combineConfigDefault&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/packages-vona/vona-core/src/types/interface/monkey.ts" rel="noopener noreferrer"&gt;Monkey / ModuleMain lifecycle hook types&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/src/suite-vendor/a-vona/modules/a-orm/src/main.ts" rel="noopener noreferrer"&gt;a-orm: a real example of config layering in Main.moduleLoading&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/src/suite-vendor/a-vona/modules/a-startup/src/monkey.ts" rel="noopener noreferrer"&gt;a-startup: Monkey.appStart / appReady&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/src/suite-vendor/a-file/modules/a-file/src/config/config.ts" rel="noopener noreferrer"&gt;a-file: module default config example&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/src/suite-vendor/a-pay/modules/a-pay/src/bean/bean.payProvider.ts" rel="noopener noreferrer"&gt;a-pay: resolving a provider by name and multi-client config&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>nestjs</category>
      <category>cabloy</category>
      <category>vona</category>
      <category>dependencyinjection</category>
    </item>
    <item>
      <title>AI Vibe Coding in Practice, Part 3: Turning the SMS Plan into a Spec Baseline</title>
      <dc:creator>Uncle Pushui</dc:creator>
      <pubDate>Wed, 04 Nov 2026 08:08:33 +0000</pubDate>
      <link>https://dev.to/uncle-pushui/ai-vibe-coding-in-practice-part-3-turning-the-sms-plan-into-a-spec-baseline-1a29</link>
      <guid>https://dev.to/uncle-pushui/ai-vibe-coding-in-practice-part-3-turning-the-sms-plan-into-a-spec-baseline-1a29</guid>
      <description>&lt;p&gt;The first two articles documented my conversations with Claude Code about the architecture and product decisions for an SMS suite in CabloyJS.&lt;/p&gt;

&lt;p&gt;The first round separated the responsibilities of SMS infrastructure, verification, authentication, and Mock delivery. The second clarified explicit registration, international numbers, real suppliers, and shared Web/Admin identities without automatically granting administrative permissions.&lt;/p&gt;

&lt;p&gt;With a plan in place, should the next instruction be to start coding? In this round, I first asked Claude Code to turn the discussion into spec documents.&lt;/p&gt;

&lt;p&gt;The prompt was short.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/cabloy-spec-generation I agree with your plan. Please organize it into spec documents.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The point was not to produce a few more Markdown files. It was to turn agreement scattered across a conversation into a planning baseline that could later be checked, broken into increments, and verified.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Confirm the document scope before starting implementation
&lt;/h2&gt;

&lt;p&gt;Claude Code did not interpret “I agree” as permission to create business modules. It first checked the repository's planning conventions, existing account planning, Web/Admin sites, and login routes, then stated the scope for this round:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I will create a &lt;strong&gt;complete new-suite baseline for Cabloy Basic&lt;/strong&gt; under &lt;code&gt;repo-specs/cabloy-sms/&lt;/code&gt;, with Chinese body text. The scope is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Six core documents: README, PRD, SRS, PDP/WBS, test plan, and progress.&lt;/li&gt;
&lt;li&gt;A boundary ADR and a runbook for real SMS supplier integration and acceptance.&lt;/li&gt;
&lt;li&gt;A Gantt chart and burndown chart derived from the complete WBS input; these do not represent schedule commitments or completed progress.&lt;/li&gt;
&lt;li&gt;The agreed plan: explicit SMS registration, international numbers, shared existing Web/Admin sites, and initial delivery of Mock + Alibaba Cloud + Tencent Cloud + Twilio, with Vonage deferred.&lt;/li&gt;
&lt;li&gt;A clear distinction between existing source and proposed capabilities. The ADR starts as &lt;code&gt;Proposed&lt;/code&gt;, delivery status starts as &lt;code&gt;not-started&lt;/code&gt;, and this approval does not extend to code execution, real SMS sending, or release authorization.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;It also identified two constraints from the existing system:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The existing &lt;code&gt;home-user&lt;/code&gt; plan excludes usernames and other login identifiers from freely editable profile fields. The new spec will preserve that boundary and state the necessary username-consistency checks, without expanding rename permissions. Supplier accounts, destination enablement, and real test numbers block only acceptance of their respective channels, not independent delivery of the Mock flow.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This was more than a summary of the previous answer. The earlier discussion had examined the relationship between usernames and display names. This round checked existing account planning and confirmed that SMS integration should not quietly broaden profile-editing permissions. Recommendations in a conversation still need to align with boundaries already recorded in the repository.&lt;/p&gt;

&lt;p&gt;In the scope confirmation, I selected:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Generate the complete baseline as recommended, using English body text.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Claude Code acknowledged the adjustment:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Understood. I will generate the complete baseline with &lt;strong&gt;English body text&lt;/strong&gt;, while continuing to report in Chinese. I will write only planning files under &lt;code&gt;repo-specs/cabloy-sms/&lt;/code&gt;, without running scaffolding, database operations, or real SMS sends.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What follows is therefore the generation of an &lt;strong&gt;English spec baseline&lt;/strong&gt;, not a retrospective on completed SMS functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Six core documents, six different questions
&lt;/h2&gt;

&lt;p&gt;“Organize the plan into documents” can easily turn into copying the same architecture description into several files. A more useful approach gives each document a distinct responsibility.&lt;/p&gt;

&lt;p&gt;The core set generated in this round was:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Document&lt;/th&gt;
&lt;th&gt;Main question&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;README&lt;/td&gt;
&lt;td&gt;Where should readers start? What are the current scope, status, and next step?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PRD&lt;/td&gt;
&lt;td&gt;Why build this, and for whom? Which business capabilities belong in the initial release, and which do not?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SRS&lt;/td&gt;
&lt;td&gt;What constrains implementation? What contracts govern modules, APIs, security, identities, concurrency, and frontend integration?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PDP/WBS&lt;/td&gt;
&lt;td&gt;In what order should delivery happen? What are the dependencies and completion conditions?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Test plan&lt;/td&gt;
&lt;td&gt;How will compliance be demonstrated? Which scenarios and evidence are required?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Progress record&lt;/td&gt;
&lt;td&gt;What has not started, what has evidence, and which decisions or external conditions remain open?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For example, “SMS login must not automatically create an account” should not appear only once in a chat. It needs to become a product behavior, a system contract enforced at the existing-identity and authentication boundaries, an implementation task, and an acceptance scenario demonstrating that a missing identity does not silently create a user.&lt;/p&gt;

&lt;p&gt;These are not six parallel versions of the same story. They describe different layers of the same goal.&lt;/p&gt;

&lt;h3&gt;
  
  
  From product requirements to acceptance evidence
&lt;/h3&gt;

&lt;p&gt;The baseline links requirements and delivery through explicit identifiers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PRD → SRS → WBS → ATP
Product requirement → System requirement → Delivery task → Acceptance scenario
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The value of these identifiers is not tidy formatting. They help answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which requirement does this delivery task serve?&lt;/li&gt;
&lt;li&gt;Which task implements a particular security requirement?&lt;/li&gt;
&lt;li&gt;What evidence must support a claim that the task is complete?&lt;/li&gt;
&lt;li&gt;If an acceptance scenario fails, which part of delivery is affected?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not every planning activity needs an invented runtime test, either. A first-slice boundary decision can be completed through documentary review, but that cannot establish that SMS sending has been verified.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Separate architectural decisions from operational procedures
&lt;/h2&gt;

&lt;p&gt;Alongside the six core documents, this round generated a boundary ADR and a supplier operations runbook.&lt;/p&gt;

&lt;h3&gt;
  
  
  The ADR: record the boundaries without implying approval
&lt;/h3&gt;

&lt;p&gt;An ADR is an architecture decision record. ADR 0001 remained &lt;code&gt;Proposed&lt;/code&gt;, recording the proposed responsibility boundaries between SMS transport, verification, identities, and the existing framework.&lt;/p&gt;

&lt;p&gt;“I agree to have the documents generated” is not the same as “I approve every technical detail and authorize implementation.” Explicit status prevents a complete-looking plan from being mistaken for unrestricted execution permission.&lt;/p&gt;

&lt;h3&gt;
  
  
  The supplier runbook: what remains after code integration?
&lt;/h3&gt;

&lt;p&gt;Real SMS integration involves more than SDK calls and parameter mapping:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Secure configuration of supplier accounts and credentials.&lt;/li&gt;
&lt;li&gt;Approved signatures, templates, or sender identities.&lt;/li&gt;
&lt;li&gt;Enabled destination countries and regions.&lt;/li&gt;
&lt;li&gt;Consenting test numbers, allowlists, and spending limits.&lt;/li&gt;
&lt;li&gt;Handling definitive rejection versus an uncertain timeout outcome.&lt;/li&gt;
&lt;li&gt;Channel disablement, cutover, and rollback.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These procedures belong in a runbook. Real credentials, full phone numbers, and verification codes do not belong in the spec.&lt;/p&gt;

&lt;p&gt;The runbook also preserves a key distinction from the previous article: &lt;strong&gt;supplier acceptance of a request does not prove that the handset received the message.&lt;/strong&gt; Adapter mapping can be verified first; live-send and handset-receipt evidence must be obtained separately, once the prerequisites and explicit authorization are in place.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. External prerequisites block their own branches
&lt;/h2&gt;

&lt;p&gt;During generation, Claude Code clarified how delivery would be divided:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The documents will track foundational sending, verification security extensions, explicit registration/login, Web/Admin integration, and real supplier acceptance as separate delivery items. Supplier accounts, signatures, templates, and country permissions constrain acceptance of the corresponding channels; they do not block independent delivery of the Mock flow.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is a practical boundary.&lt;/p&gt;

&lt;p&gt;If a Twilio destination has not been enabled, the international channel cannot be declared accepted. That does not require every development activity to stop. Mock can still independently exercise the sending contract, phone-and-purpose binding, code consumption, and registration/login flow.&lt;/p&gt;

&lt;p&gt;Conversely, a working Mock flow cannot mark Alibaba Cloud, Tencent Cloud, and Twilio as accepted.&lt;/p&gt;

&lt;p&gt;This allows a useful increment to move forward without hiding unfinished live-channel requirements in a progress table.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. One check failed before the final pass
&lt;/h2&gt;

&lt;p&gt;Not every check passed on its first attempt.&lt;/p&gt;

&lt;p&gt;The initial planning check found &lt;strong&gt;45 formal definitions&lt;/strong&gt;, but the documents already referenced two derived charts that had not yet been generated. It reported missing link targets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;complete planning structure failed (45 definitions).
Missing local link target: implementation-gantt.svg.
Missing local link target: implementation-burndown.svg.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The charts were then generated, followed by a fresh planning check and chart-freshness check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run spec:charts &lt;span class="nt"&gt;--&lt;/span&gt; cabloy-sms
npm run spec:check &lt;span class="nt"&gt;--&lt;/span&gt; cabloy-sms
npm run spec:charts:check &lt;span class="nt"&gt;--&lt;/span&gt; cabloy-sms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The final results were:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;complete planning structure passed (45 definitions).
checked implementation-gantt.svg and implementation-burndown.svg
(en; 0/10 verified).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;0/10 verified&lt;/code&gt; matters. Generating charts did not manufacture implementation progress. All ten delivery tasks still had &lt;code&gt;not-started&lt;/code&gt; status.&lt;/p&gt;

&lt;p&gt;The Gantt chart represented task organization and dependencies; the scope-count burndown represented recorded status. Neither was a schedule commitment or a velocity forecast based on actual delivery history.&lt;/p&gt;

&lt;p&gt;The planning checker also explicitly stated its limits: it checks static structure, while approval, semantic sufficiency, implementation, and evidence authenticity still require human review. Connected identifiers do not establish that a design is correct. Rendered charts do not establish that a feature works.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. The recovered completion reply
&lt;/h2&gt;

&lt;p&gt;Below is the final reply from that round, translated into English. Its conclusions and status are preserved; file links have been simplified to document names for readability.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The &lt;strong&gt;complete English spec baseline for Cabloy Basic&lt;/strong&gt; is finished, entirely under &lt;code&gt;repo-specs/cabloy-sms/&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Document entry point
&lt;/h3&gt;

&lt;p&gt;README — planning overview and reading order.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Document&lt;/th&gt;
&lt;th&gt;Content&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;prd.md&lt;/td&gt;
&lt;td&gt;Product goals, user journeys, initial and deferred scope&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;srs.md&lt;/td&gt;
&lt;td&gt;provider/clients/scene, verification security, identities and concurrency, Web/Admin integration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pdp-wbs.md&lt;/td&gt;
&lt;td&gt;Staged delivery, dependencies, and completion conditions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;test-plan.md&lt;/td&gt;
&lt;td&gt;12 acceptance scenarios and evidence requirements&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;progress.md&lt;/td&gt;
&lt;td&gt;Initial status, open decisions, and subsequent entry points&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ADR 0001&lt;/td&gt;
&lt;td&gt;Proposed technical boundaries and decision gates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supplier runbook&lt;/td&gt;
&lt;td&gt;Channel configuration, live-send acceptance, failure handling, and disablement&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two English charts have also been generated: an implementation roadmap and a scope-count burndown.&lt;/p&gt;
&lt;h3&gt;
  
  
  Key points recorded in the baseline
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Explicit registration: &lt;strong&gt;phone number + user-chosen username + registration code&lt;/strong&gt;; SMS login does not automatically register users.&lt;/li&gt;
&lt;li&gt;International numbers normalized to E.164; Web/Admin reuse existing identities, Passport, and shared sites.&lt;/li&gt;
&lt;li&gt;Initial scope includes Mock, Alibaba Cloud, Tencent Cloud, and Twilio; Vonage is deferred.&lt;/li&gt;
&lt;li&gt;Reuse and safely extend &lt;code&gt;a-captcha&lt;/code&gt;, rather than building another OTP system; cover binding, atomic consumption, rate limits, and generic-entry-point bypass risks.&lt;/li&gt;
&lt;li&gt;Mock autofill is allowed only for actual Mock transport, outside production, with explicit enablement; real channels never return codes to the frontend.&lt;/li&gt;
&lt;li&gt;Real-channel accounts, signatures, templates, and country permissions are accepted separately and do not block implementation of the Mock branch.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Check results
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;spec:check&lt;/code&gt;: passed, with &lt;strong&gt;45 formal definitions&lt;/strong&gt; and a complete traceability chain.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;spec:charts&lt;/code&gt; and &lt;code&gt;spec:charts:check&lt;/code&gt;: passed.&lt;/li&gt;
&lt;li&gt;Local-link, whitespace, and machine-local-path privacy checks passed; charts were rendered and inspected.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Only planning generation is complete&lt;/strong&gt;: the ADR remains &lt;code&gt;Proposed&lt;/code&gt;, all 10 delivery tasks are &lt;code&gt;not-started&lt;/code&gt;, and there is no runtime or real-supplier acceptance evidence. No scaffolding, dependency installation, database operations, real sends, or commits were performed.&lt;/p&gt;

&lt;p&gt;The next candidate is &lt;code&gt;WBS-SMS-10-01&lt;/code&gt;: implement scene-driven Mock sending for the verification consumer, proving tenant isolation and production denial. Enter implementation only after the corresponding decisions and execution dossier have been approved through &lt;code&gt;cabloy-spec-execution&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The &lt;strong&gt;45 formal definitions&lt;/strong&gt;, &lt;strong&gt;12 acceptance scenarios&lt;/strong&gt;, and &lt;strong&gt;10 delivery tasks&lt;/strong&gt; are different planning counts—not a set of passing tests. The status above is a snapshot at the end of this generation round, not a statement about later development progress.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. What this step actually left behind
&lt;/h2&gt;

&lt;p&gt;Looking back at the short prompt, what I wanted was a change in working state: from a plan discussed in conversation to a baseline that could be handed over and verified incrementally.&lt;/p&gt;

&lt;p&gt;That transition depends on keeping several boundaries clear:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Product agreement:&lt;/strong&gt; what belongs in the initial release, and what does not.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Technical decisions:&lt;/strong&gt; which details remain Proposed rather than implicitly approved.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delivery tasks:&lt;/strong&gt; the dependencies and exit conditions for each useful increment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Acceptance evidence:&lt;/strong&gt; the difference between a planned scenario and an actual result.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operational authorization:&lt;/strong&gt; document-generation approval is not permission to write code, reset databases, send paid messages, or release software.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This does not require planning every detail until nothing is unknown. It means giving each unknown an owner and defining a bounded next step.&lt;/p&gt;

&lt;p&gt;Once the spec identifies an independently verifiable Mock sending slice, implementation can focus on that slice instead of repeatedly rewriting the entire grand plan. How verification, identities, and frontend flows actually connect is a question for the next stage—answered with code and runtime results.&lt;/p&gt;

</description>
      <category>cabloy</category>
      <category>claudecode</category>
      <category>vibecoding</category>
      <category>specdrivendevelopment</category>
    </item>
    <item>
      <title>Is There a CabloyJS Equivalent in the React/Next.js Ecosystem?</title>
      <dc:creator>Uncle Pushui</dc:creator>
      <pubDate>Mon, 02 Nov 2026 03:32:53 +0000</pubDate>
      <link>https://dev.to/uncle-pushui/is-there-a-cabloyjs-equivalent-in-the-reactnextjs-ecosystem-4db1</link>
      <guid>https://dev.to/uncle-pushui/is-there-a-cabloyjs-equivalent-in-the-reactnextjs-ecosystem-4db1</guid>
      <description>&lt;p&gt;In the Node.js fullstack world, CabloyJS has always occupied a rather specific position. It is not a "frontend framework with some API routes on the side," but an enterprise fullstack architecture with &lt;strong&gt;module boundaries, built-in IoC (inversion of control / dependency injection), native RBAC and Workflow, and a metadata contract shared by frontend and backend&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So a familiar question comes up: if a team's stack is React/Next.js, is there something "close enough"?&lt;/p&gt;

&lt;p&gt;The short answer: &lt;strong&gt;there is no exact equivalent to CabloyJS.&lt;/strong&gt; What the React/Next.js ecosystem offers are four &lt;em&gt;partially overlapping&lt;/em&gt; approaches. Each one hits some of CabloyJS's capabilities; none covers all of them.&lt;/p&gt;

&lt;p&gt;To see this clearly, we first need to break CabloyJS apart.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Split CabloyJS into five comparable capability layers
&lt;/h2&gt;

&lt;p&gt;Calling something a "fullstack framework" makes comparison meaningless. CabloyJS's value actually lives on five independent layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Modularity and scaffolding&lt;/strong&gt; — business capabilities are organized as modules that can be installed, composed, and removed, with a CLI that generates the standard structure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend IoC/DI&lt;/strong&gt; — services, controllers, and beans collaborate through dependency injection instead of layered imports and manual wiring.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Frontend-backend integration&lt;/strong&gt; — one framework constrains both sides, so routing, permissions, validation, and error handling follow the same conventions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RBAC and Workflow&lt;/strong&gt; — the permission model and workflow engine are built into the framework, not "install a library and wire it up."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Metadata-driven design&lt;/strong&gt; — data structures, forms, lists, and permission points are described by metadata, and both sides start from the same definition.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now hold these five layers against the candidates.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Why Next.js itself is not the counterpart
&lt;/h2&gt;

&lt;p&gt;Next.js defines itself as a &lt;strong&gt;React meta-framework&lt;/strong&gt;. It solves rendering modes (SSR/CSR/RSC), routing, builds, deployment, and edge runtimes — extending the frontend all the way into the server.&lt;/p&gt;

&lt;p&gt;Its Route Handlers and Server Actions are enough to write endpoints, but they &lt;strong&gt;do not provide enterprise backend architecture constraints&lt;/strong&gt;: no dependency injection container, no module lifecycle, no built-in permission model, and no workflow engine. In Next.js, all of that belongs to the "choose your own stack and assemble it yourself" category.&lt;/p&gt;

&lt;p&gt;So the question should not be "is there a CabloyJS replacement inside Next.js," but rather: &lt;strong&gt;within the React/Next.js ecosystem, which combination fills in those CabloyJS layers?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Path one: fullstack conventions — RedwoodJS and Blitz.js
&lt;/h2&gt;

&lt;p&gt;If what appeals to you is "one framework owns both sides and tells you, with strong conventions, where business logic belongs," these two frameworks come closest.&lt;/p&gt;

&lt;h3&gt;
  
  
  RedwoodJS
&lt;/h3&gt;

&lt;p&gt;RedwoodJS is one of the most opinionated fullstack frameworks in the React ecosystem. In its classic form, it puts the React frontend, GraphQL API, Prisma data layer, and directory conventions into a single monorepo.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scaffolding&lt;/strong&gt;: &lt;code&gt;generate&lt;/code&gt; commands produce pages, Cells, Services, and GraphQL SDL in one pass, turning "where should this capability live" into a fixed answer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clear boundaries&lt;/strong&gt;: the frontend handles presentation and interaction, data access is confined to the service layer, and server-side validation and tests have a defined home.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One caveat&lt;/strong&gt;: Redwood has spent the past couple of years evolving toward RedwoodSDK, with changes to both its technical foundation and deployment model. When choosing it, confirm which generation you are actually adopting rather than relying on older docs describing the GraphQL + Prisma setup.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Blitz.js
&lt;/h3&gt;

&lt;p&gt;Blitz.js is built directly on top of Next.js, with the explicit goal of erasing the frontend-backend boundary.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zero-API data layer&lt;/strong&gt;: the frontend can &lt;code&gt;import&lt;/code&gt; backend queries and mutations directly; Blitz compiles them into RPC endpoints and client calls at build time. This removes the hand-written API glue layer and is where it most resembles CabloyJS's "one integrated stack."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Built-in auth and sessions&lt;/strong&gt;: authentication and session management work out of the box, with ready-made hooks for authorization checks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Boundary&lt;/strong&gt;: it provides authentication and access-control infrastructure, not a full RBAC permission-point system or workflow engine. Organization-level permission models still need to be modeled by you.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Who it fits&lt;/strong&gt;: teams that want to stay entirely inside the Next.js ecosystem while getting "write the backend, call it from the frontend, with login state included." For that need, Blitz.js is the first choice. If you are not tied to Next.js but want an opinionated fullstack framework in React, look at RedwoodJS.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Path two: admin panels and metadata-driven design — Refine
&lt;/h2&gt;

&lt;p&gt;CabloyJS is often used to build complex enterprise admin systems quickly. If your core need is &lt;strong&gt;permissions, auto-generated CRUD, and direct access to a database or existing API&lt;/strong&gt;, you do not need to replace Next.js — just bring in Refine.&lt;/p&gt;

&lt;p&gt;Refine is an open-source meta-framework for React admin panels that runs seamlessly on Next.js, Remix, or Vite.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Provider-based metadata thinking&lt;/strong&gt;: &lt;code&gt;dataProvider&lt;/code&gt; connects a data source (REST, GraphQL, Supabase, Prisma, etc.), &lt;code&gt;authProvider&lt;/code&gt; handles login state, and &lt;code&gt;accessControlProvider&lt;/code&gt; carries ACL/RBAC decisions. You define &lt;em&gt;how to fetch&lt;/em&gt; and &lt;em&gt;how to authorize&lt;/em&gt;; Refine wires up CRUD pages, forms, lists, and i18n.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UI-agnostic&lt;/strong&gt;: it does not bind to a component library, so you keep Next.js's navigation and rendering modes without being locked in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Boundary&lt;/strong&gt;: Refine is a frontend-side meta-framework and &lt;strong&gt;does not provide a backend runtime&lt;/strong&gt;. Authorization must ultimately be enforced by your API or database, and workflows are out of its scope entirely.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Who it fits&lt;/strong&gt;: teams that already have a backend (or plan to use Supabase or their own API) and whose main pain is repeated admin-panel and permission work.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Path three: backend IoC — NestJS + Next.js
&lt;/h2&gt;

&lt;p&gt;CabloyJS's backend offers Spring-like dependency injection. If your team values backend architectural rigor more than the convenience of a single all-in-one framework, the common answer is a &lt;strong&gt;combo plus a monorepo&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manage the repo with &lt;strong&gt;Nx&lt;/strong&gt; or &lt;strong&gt;Turborepo&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;Let &lt;strong&gt;Next.js&lt;/strong&gt; handle SSR, SEO, and the BFF layer;&lt;/li&gt;
&lt;li&gt;Let &lt;strong&gt;NestJS&lt;/strong&gt; own the real enterprise business backend.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;NestJS is the most mature IoC/DI backend framework in Node.js today: Module, Provider, Guard, Interceptor, and Pipe form a complete set of architectural constraints, with clear module boundaries and test isolation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The cost&lt;/strong&gt;: frontend and backend are no longer governed by one framework, so routing, permissions, DTO validation, and error codes must be explicitly aligned across two systems. In other words, the consistency CabloyJS gets from "one shared metadata contract" has to be recovered here through engineering conventions and shared packages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who it fits&lt;/strong&gt;: large commercial projects that need to evolve for years and cannot compromise on backend architecture. This combination is not weaker than CabloyJS in rigor or modularity — but it is not "batteries included," it is "architecture included."&lt;/p&gt;

&lt;h2&gt;
  
  
  6. How the four options compare
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Requirement&lt;/th&gt;
&lt;th&gt;CabloyJS capability&lt;/th&gt;
&lt;th&gt;React/Next.js option&lt;/th&gt;
&lt;th&gt;Recommendation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Integration and automation&lt;/td&gt;
&lt;td&gt;Modules, CLI generation, unified frontend/backend&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Blitz.js&lt;/strong&gt; / &lt;strong&gt;RedwoodJS&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Choose these to skip auth and API glue work&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fast admin panels and permissions&lt;/td&gt;
&lt;td&gt;Built-in RBAC, Workflow, auto CRUD&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Refine&lt;/strong&gt; (embeddable in Next.js)&lt;/td&gt;
&lt;td&gt;Choose it when the core is admin, forms, and access control&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Top-tier backend architecture (IoC)&lt;/td&gt;
&lt;td&gt;Dependency injection and modularity via Egg/Vona&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;NestJS&lt;/strong&gt; + Turborepo/Nx&lt;/td&gt;
&lt;td&gt;Choose it for large, long-lived systems where backend rigor comes first&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Workflow engine&lt;/td&gt;
&lt;td&gt;Built-in Workflow&lt;/td&gt;
&lt;td&gt;No direct counterpart; build or integrate one&lt;/td&gt;
&lt;td&gt;Evaluate separately for process-heavy systems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shared frontend/backend metadata&lt;/td&gt;
&lt;td&gt;One metadata source drives both sides&lt;/td&gt;
&lt;td&gt;Partial overlap (Refine providers, Redwood conventions)&lt;/td&gt;
&lt;td&gt;No complete equivalent; fill the gap with conventions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  7. Selection advice
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Staying fully inside Next.js&lt;/strong&gt;, valuing "write the backend, use it in the frontend, login included": &lt;strong&gt;Blitz.js&lt;/strong&gt; first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not tied to Next.js but wanting an opinionated React fullstack framework&lt;/strong&gt;: &lt;strong&gt;RedwoodJS&lt;/strong&gt; first — but confirm its current form and deployment model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mainly enterprise admin panels, forms, and permissions&lt;/strong&gt;: &lt;strong&gt;Refine&lt;/strong&gt; has the best return on effort, with no backend replacement required.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend rigor first, system expected to live for many years&lt;/strong&gt;: the &lt;strong&gt;NestJS + Next.js&lt;/strong&gt; monorepo is the safer bet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One honest closing note: all four options can reproduce &lt;strong&gt;most of the day-to-day CabloyJS experience&lt;/strong&gt;, but none fully replicates its five-layer structure of modules + IoC + RBAC + Workflow + metadata. The React/Next.js ecosystem wins on freedom of choice and an enormous supply of components and training material; CabloyJS wins by building enterprise constraints in advance and reducing how much architectural freedom a team has to improvise.&lt;/p&gt;

&lt;p&gt;These are not substitutes for each other. They are a trade-off between &lt;strong&gt;free composition&lt;/strong&gt; and &lt;strong&gt;built-in conventions&lt;/strong&gt;. Decide which cost you fear more, and the answer follows.&lt;/p&gt;

</description>
      <category>react</category>
      <category>nextjs</category>
      <category>cabloyjs</category>
      <category>fullstack</category>
    </item>
    <item>
      <title>AI Vibe Coding in Practice, Part 2: Product Decisions and a Revised SMS Suite Plan</title>
      <dc:creator>Uncle Pushui</dc:creator>
      <pubDate>Mon, 02 Nov 2026 01:41:42 +0000</pubDate>
      <link>https://dev.to/uncle-pushui/ai-vibe-coding-in-practice-part-2-product-decisions-and-a-revised-sms-suite-plan-38ni</link>
      <guid>https://dev.to/uncle-pushui/ai-vibe-coding-in-practice-part-2-product-decisions-and-a-revised-sms-suite-plan-38ni</guid>
      <description>&lt;p&gt;In the previous article, I shared my &lt;code&gt;prompt&lt;/code&gt; and Claude Code's &lt;code&gt;development plan&lt;/code&gt; for an SMS suite—shared infrastructure, verification codes, and authentication—for the CabloyJS fullstack framework. At the end of that plan, Claude Code asked me to confirm three groups of product decisions: registration behavior, phone-number scope, and rollout scope.&lt;/p&gt;

&lt;p&gt;I had a question about “automatically register on SMS login”: if users do not enter a username, how should &lt;code&gt;userName&lt;/code&gt; be determined? I sent that question back to Claude Code along with the other two decisions so it could refine the plan. Here is the next part of the conversation for reference.&lt;/p&gt;

&lt;p&gt;Here is the prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Registration: should SMS login automatically register a new user? I am unsure. If registration is automatic, how is &lt;code&gt;userName&lt;/code&gt; determined?&lt;/li&gt;
&lt;li&gt;Phone-number scope: mainland China only initially, or international numbers too? Support international numbers.&lt;/li&gt;
&lt;li&gt;Rollout:

&lt;ul&gt;
&lt;li&gt;Enable SMS login on both Web/Admin.&lt;/li&gt;
&lt;li&gt;Deliver the complete Mock flow in the initial release and integrate real vendors as well:

&lt;ul&gt;
&lt;li&gt;Mainland China: Alibaba Cloud / Tencent Cloud.&lt;/li&gt;
&lt;li&gt;International numbers: please recommend one or two of the most popular services.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is the development plan returned by Claude Code:&lt;/p&gt;

&lt;p&gt;These clarifications let us narrow the plan further. First, the username question: automatic registration is possible, but explicit registration fits the current account model more naturally. I recommend separating SMS registration from SMS login for the initial release, without automatic registration by default.&lt;/p&gt;

&lt;p&gt;For international SMS, I recommend Twilio and Vonage. Integrate Twilio initially and keep Vonage as the second choice, rather than requiring both in the first release.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Registration: prefer explicit registration with a user-chosen &lt;code&gt;userName&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Why not generate a username automatically?
&lt;/h3&gt;

&lt;p&gt;After checking the source further, the current &lt;code&gt;user.name&lt;/code&gt; is more than an internal technical identifier:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Registration writes it from &lt;code&gt;profile.username&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It is used for user display.&lt;/li&gt;
&lt;li&gt;Existing password login looks up users by this field.&lt;/li&gt;
&lt;li&gt;Profile editing currently allows users to change it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It cannot simply be treated as an automatically generated, immutable internal ID. There is also no separate persisted nickname field for display names.&lt;/p&gt;

&lt;p&gt;Source references:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User profile mapping: &lt;code&gt;vona/src/suite/a-home/modules/home-user/src/service/userAdapter.ts:13&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;User registration: &lt;code&gt;vona/src/suite-vendor/a-vona/modules/a-user/src/bean/bean.user.ts:27&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Password login lookup: &lt;code&gt;vona/src/suite-vendor/a-auth/modules/auth-simple/src/bean/authProvider.simple.ts:58&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Automatic registration could generate a username such as &lt;code&gt;sms_&amp;lt;random identifier&amp;gt;&lt;/code&gt;, but that raises further product questions: can it be changed, what gets displayed, and which name is used if the user later sets a password? Implementing SMS login does not require redesigning the account naming model in the initial release.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Recommended registration and login contracts
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operation&lt;/th&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Behavior&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SMS registration&lt;/td&gt;
&lt;td&gt;International phone number, username, SMS code&lt;/td&gt;
&lt;td&gt;Verify the number, create the user and SMS identity mapping, then sign in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SMS login&lt;/td&gt;
&lt;td&gt;International phone number, SMS code&lt;/td&gt;
&lt;td&gt;Sign in only through an existing SMS identity; never create a new user&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The initial registration flow does not require a password or email, and must not create fake password credentials.&lt;/p&gt;

&lt;p&gt;Recommended username rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reuse and complete the existing username validation.&lt;/li&gt;
&lt;li&gt;Trim surrounding whitespace and apply consistent case-equivalence rules when checking names.&lt;/li&gt;
&lt;li&gt;Require uniqueness within the current instance.&lt;/li&gt;
&lt;li&gt;Reject reserved system names such as admin.&lt;/li&gt;
&lt;li&gt;Return a field error when a name is taken, rather than silently appending a random suffix.&lt;/li&gt;
&lt;li&gt;Preserve uniqueness when the same phone number or username is registered concurrently.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One more detail matters: the current profile editor's “Display name” changes the same &lt;code&gt;user.name&lt;/code&gt;, without the duplicate-name checks used for registration. Registration and renaming should share the necessary username constraints. Otherwise, renaming can introduce conflicts after registration has enforced uniqueness.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Separate phone identity from username
&lt;/h3&gt;

&lt;p&gt;Keep three concepts distinct:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field/concept&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;user.id&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Internal user identifier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;user.name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Account name chosen by the user&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SMS identity mapping&lt;/td&gt;
&lt;td&gt;Association between a verified, normalized phone number and &lt;code&gt;userId&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Consequently:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Renaming a user does not affect phone login.&lt;/li&gt;
&lt;li&gt;A phone number must not become the default username, which could expose the full number wherever the user is displayed.&lt;/li&gt;
&lt;li&gt;A username matching an old account does not trigger automatic association.&lt;/li&gt;
&lt;li&gt;A phone number matching an old account's mobile field does not claim that account either.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The existing authentication chain's automatic registration behavior also needs to be explicitly disabled. The framework can currently create users for both login and register, so passing &lt;code&gt;intention: 'login'&lt;/code&gt; alone does not make an operation login-only.&lt;/p&gt;

&lt;p&gt;For a missing SMS identity, prompt the user to register after verifying ownership of the phone number. The send-code endpoint itself must not disclose whether an account exists.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Phone-number scope: support international numbers and normalize to E.164
&lt;/h2&gt;

&lt;p&gt;Use an explicit international-number contract on both frontend and backend:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Provide a country/region selector on the frontend.&lt;/li&gt;
&lt;li&gt;Use a mature server-side number parser, such as a libphonenumber-based implementation.&lt;/li&gt;
&lt;li&gt;Normalize numbers to E.164 for storage, comparison, and sending, for example +86138… or +447….&lt;/li&gt;
&lt;li&gt;Use the same normalization logic for sending and verification.&lt;/li&gt;
&lt;li&gt;Do not use a simple regular expression to validate numbers from every country.&lt;/li&gt;
&lt;li&gt;Do not infer the recipient's country from the UI language, browser locale, or IP address.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Routing rules
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Destination&lt;/th&gt;
&lt;th&gt;Default sending channel&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Mainland China&lt;/td&gt;
&lt;td&gt;Alibaba Cloud or Tencent Cloud&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hong Kong, Macao, Taiwan, and other international destinations&lt;/td&gt;
&lt;td&gt;Twilio, or Vonage if configured&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Explicit development/test configuration&lt;/td&gt;
&lt;td&gt;sms-mock&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Do not route Hong Kong, Macao, or Taiwan through the mainland China SMS channel, or choose a vendor based on page language.&lt;/p&gt;

&lt;p&gt;Supporting international numbers does not mean enabling worldwide sending by default. Configure allowed countries/regions, quotas, and spending limits. Destinations may have different Sender ID, number registration, template, or use-case requirements, so enable and verify them individually.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. International vendors: Twilio and Vonage
&lt;/h2&gt;

&lt;p&gt;Both are mature, widely used international communications API vendors. This is an engineering recommendation, not a claim that they rank first and second in verifiable global market share.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Vendor&lt;/th&gt;
&lt;th&gt;Recommended role&lt;/th&gt;
&lt;th&gt;Integration&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Twilio&lt;/td&gt;
&lt;td&gt;First choice for international SMS in the initial release&lt;/td&gt;
&lt;td&gt;Programmable Messaging&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vonage, formerly Nexmo&lt;/td&gt;
&lt;td&gt;Second choice or a later alternative channel&lt;/td&gt;
&lt;td&gt;SMS API&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  1. Twilio: recommended for the initial release
&lt;/h3&gt;

&lt;p&gt;It fits the proposed architecture because it provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A general-purpose SMS sending API.&lt;/li&gt;
&lt;li&gt;E.164 recipient numbers.&lt;/li&gt;
&lt;li&gt;A sending number or Messaging Service for sender configuration.&lt;/li&gt;
&lt;li&gt;Extensive documentation on destination permissions and country requirements.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Vonage: a second choice
&lt;/h3&gt;

&lt;p&gt;Vonage SMS API provides general-purpose recipient, sender, and message-body parameters. It can support another SMS Provider following the same contract.&lt;/p&gt;

&lt;p&gt;For specific target countries, the final choice should still consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sending identities that can actually be provisioned.&lt;/li&gt;
&lt;li&gt;Delivery rate and latency tests.&lt;/li&gt;
&lt;li&gt;Unit prices and message-segment billing.&lt;/li&gt;
&lt;li&gt;Account entity and local compliance requirements.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Do not default to managed Verify products for this plan
&lt;/h3&gt;

&lt;p&gt;Both Twilio and Vonage offer managed verification products. For this suite, use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Twilio Programmable Messaging.&lt;/li&gt;
&lt;li&gt;Vonage SMS API.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The plan does not default to their Verify products because sms-captcha is already intended to manage:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code generation.&lt;/li&gt;
&lt;li&gt;Expiry.&lt;/li&gt;
&lt;li&gt;Phone-number and purpose binding.&lt;/li&gt;
&lt;li&gt;Attempt limits.&lt;/li&gt;
&lt;li&gt;Single consumption.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keeping vendors responsible for transport lets Mock, Alibaba Cloud, Tencent Cloud, and international Providers share the same verification semantics.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. The infrastructure must support two vendor sending models
&lt;/h2&gt;

&lt;p&gt;With international vendors included, the unified SMS interface cannot require a vendor template ID for every request. Their APIs differ:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Provider&lt;/th&gt;
&lt;th&gt;Typical sending model&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Alibaba Cloud&lt;/td&gt;
&lt;td&gt;Signature + template ID + named parameters as JSON&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tencent Cloud&lt;/td&gt;
&lt;td&gt;Signature + template ID + ordered parameter array&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Twilio&lt;/td&gt;
&lt;td&gt;Sender/Messaging Service + message body&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vonage&lt;/td&gt;
&lt;td&gt;Sender + message body&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Keep the business call consistent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Proposed interface&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bean&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sms&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;scene&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sms-auth:signup&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;recipient&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;normalizedPhone&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;minutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Server-side Scene configuration and Provider adapters handle the differences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alibaba Cloud: convert &lt;code&gt;{ code, minutes }&lt;/code&gt; to template parameter JSON.&lt;/li&gt;
&lt;li&gt;Tencent Cloud: convert parameters to an array in an explicitly configured order.&lt;/li&gt;
&lt;li&gt;Twilio/Vonage: render the body from localized text templates maintained on the server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Parameter order must not depend on object enumeration. Public requests must not freely supply message bodies, vendor templates, or senders.&lt;/p&gt;

&lt;p&gt;Also distinguish:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Recipient region: determines requirements and available channels.&lt;/li&gt;
&lt;li&gt;Message language: determined by the business language policy.&lt;/li&gt;
&lt;li&gt;Vendor account region: determined by Client configuration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do not combine all three into one region field.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Module structure: retain four core modules and extend real Providers independently
&lt;/h2&gt;

&lt;p&gt;Since the initial scope explicitly includes multiple real vendors, retain the four core modules and create separate vendor modules:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Module&lt;/th&gt;
&lt;th&gt;Initial recommendation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;cabloy-sms&lt;/td&gt;
&lt;td&gt;Required: transport infrastructure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sms-captcha&lt;/td&gt;
&lt;td&gt;Required: verification codes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sms-auth&lt;/td&gt;
&lt;td&gt;Required: registration and login&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sms-mock&lt;/td&gt;
&lt;td&gt;Required: development and testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sms-aliyun&lt;/td&gt;
&lt;td&gt;Required: mainland China Provider&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sms-tencent&lt;/td&gt;
&lt;td&gt;Required: mainland China Provider&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sms-twilio&lt;/td&gt;
&lt;td&gt;Recommended for the initial release: international Provider&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sms-vonage&lt;/td&gt;
&lt;td&gt;Alternative; include when two international channels are needed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;All belong to the cabloy-sms suite. Separate modules isolate SDKs, credential types, and vendor changes, so consumers do not have to load every SDK.&lt;/p&gt;

&lt;p&gt;If retaining exactly four modules is essential, real Providers could live in cabloy-sms. With multiple real vendor consumers now confirmed, separate Provider modules are a better fit.&lt;/p&gt;

&lt;p&gt;Default routing selects one vendor for each send. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mainland China defaults to Alibaba Cloud, with Tencent Cloud selectable through configuration.&lt;/li&gt;
&lt;li&gt;International destinations default to Twilio.&lt;/li&gt;
&lt;li&gt;Never send through multiple Providers simultaneously.&lt;/li&gt;
&lt;li&gt;Do not automatically resend through another vendor when a timeout leaves the result uncertain.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6. What enabling both Web/Admin means
&lt;/h2&gt;

&lt;p&gt;Both can offer SMS registration and login while sharing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users.&lt;/li&gt;
&lt;li&gt;SMS identity mappings.&lt;/li&gt;
&lt;li&gt;The Provider configuration mechanism.&lt;/li&gt;
&lt;li&gt;Passport and session handling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Registering through Web or Admin must not create separate users for the same phone number.&lt;/p&gt;

&lt;p&gt;Opening a login entry point and granting business permissions are separate decisions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SMS registration grants only ordinary registered-user permissions.&lt;/li&gt;
&lt;li&gt;Registering from an Admin page does not grant administrative permissions.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  7. Updated initial delivery recommendation
&lt;/h2&gt;

&lt;p&gt;Set the initial scope to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Infrastructure + Mock: establish a working unified sending contract.&lt;/li&gt;
&lt;li&gt;Alibaba Cloud, Tencent Cloud, and Twilio Providers: integrate with that contract.&lt;/li&gt;
&lt;li&gt;SMS verification: international numbers, purpose binding, rate limits and cooldowns, single consumption, and Mock autofill.&lt;/li&gt;
&lt;li&gt;Explicit SMS registration and login restricted to existing SMS identities.&lt;/li&gt;
&lt;li&gt;Web/Admin entry points and permission regression checks.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For real Providers, distinguish:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code integration complete: request mapping, response parsing, and error handling have been verified.&lt;/li&gt;
&lt;li&gt;Real SMS acceptance complete: accounts, signatures/templates/sending identities have been approved, and authorized test numbers have actually received messages.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The former cannot replace the latter, and a complete Mock flow cannot replace real vendor acceptance.&lt;/p&gt;

&lt;p&gt;My final recommendation is explicit registration to establish &lt;code&gt;userName&lt;/code&gt;, E.164 normalization for international numbers, and initial integration with Alibaba Cloud, Tencent Cloud, and Twilio, with Vonage as the second international option. This covers the requested initial business scope without also taking on account-name redesign, worldwide channel activation, and automatic failover.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.twilio.com/docs/messaging/api/message-resource" rel="noopener noreferrer"&gt;Twilio Messages API: recipient numbers, message body, and sender parameters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.twilio.com/docs/messaging/guides/sms-geo-permissions" rel="noopener noreferrer"&gt;Twilio international SMS destination permissions and restrictions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.vonage.com/en/api/sms" rel="noopener noreferrer"&gt;Vonage SMS API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://help.aliyun.com/zh/sms/developer-reference/api-dysmsapi-2017-05-25-sendsms" rel="noopener noreferrer"&gt;Alibaba Cloud SendSms API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloud.tencent.com/document/product/382/55981" rel="noopener noreferrer"&gt;Tencent Cloud SendSms API&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No code was changed in this round. Vendor information was checked against search results from official documentation; full-page retrieval was restricted by network access. No commitments were made about availability in specific countries, pricing, or actual delivery rates.&lt;/p&gt;




&lt;p&gt;After this exchange, Claude Code had more concrete recommendations for registration, international numbers, and real vendor integration, along with clearer boundaries for shared Web/Admin identities and permissions. I will leave it here for now to keep the article manageable. If you would like to see the implementation that follows, leave a comment and I will continue putting the material together.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>aicoding</category>
      <category>vibecoding</category>
      <category>sms</category>
    </item>
    <item>
      <title>AI Vibe Coding in Practice: An SMS Suite Prompt and Development Plan</title>
      <dc:creator>Uncle Pushui</dc:creator>
      <pubDate>Thu, 29 Oct 2026 02:55:41 +0000</pubDate>
      <link>https://dev.to/uncle-pushui/ai-vibe-coding-in-practice-an-sms-suite-prompt-and-development-plan-20g4</link>
      <guid>https://dev.to/uncle-pushui/ai-vibe-coding-in-practice-an-sms-suite-prompt-and-development-plan-20g4</guid>
      <description>&lt;p&gt;While developing an SMS suite for the CabloyJS fullstack framework—shared infrastructure, verification codes, and authentication—I found both my &lt;code&gt;prompt&lt;/code&gt; and Claude Code's &lt;code&gt;development plan&lt;/code&gt; representative of a real AI coding workflow. I have put them together here for reference.&lt;/p&gt;

&lt;p&gt;Here is the prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Please carefully analyze the following development task and propose a reasonable plan:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Goal: implement shared SMS infrastructure first, then build multiple business capabilities on top of it.

&lt;ul&gt;
&lt;li&gt;Infrastructure: SMS provider / clients / scene.&lt;/li&gt;
&lt;li&gt;Business capabilities:

&lt;ul&gt;
&lt;li&gt;sms captcha: SMS verification codes.&lt;/li&gt;
&lt;li&gt;sms auth: user registration and login.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Suite / module structure:

&lt;ul&gt;
&lt;li&gt;Suite: cabloy-sms.&lt;/li&gt;
&lt;li&gt;Modules:

&lt;ul&gt;
&lt;li&gt;cabloy-sms: shared SMS infrastructure.&lt;/li&gt;
&lt;li&gt;sms-captcha: SMS verification codes.&lt;/li&gt;
&lt;li&gt;sms-auth: user registration and login.&lt;/li&gt;
&lt;li&gt;sms-mock: a Mock SMS Provider that prints verification codes to the console and sends them to the frontend so it can fill the code input automatically.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is the development plan returned by Claude Code:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Overall recommendation
&lt;/h2&gt;

&lt;p&gt;Keep the proposed cabloy-sms suite and its four modules, with these layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cabloy-sms: SMS transport infrastructure, responsible for which provider account and template to use when sending a message.&lt;/li&gt;
&lt;li&gt;sms-captcha: SMS verification, responsible for the recipient, the intended operation, and secure verification.&lt;/li&gt;
&lt;li&gt;sms-auth: phone-based authentication, responsible for which account to sign in to after verification and whether to create a new account.&lt;/li&gt;
&lt;li&gt;sms-mock: an SMS Provider for development and testing. It replaces real transport while retaining the verification and authentication flows.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The most important design principle is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Infrastructure does not depend on verification codes; verification codes do not depend on user authentication; Mock does not change the real business flow.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The current repository is Cabloy Basic. Based on the existing source, reuse Vona's provider/client/scene extension pattern, the a-captcha verification system, and the a-auth authentication chain. There is no need to build another SMS code cache or session system.&lt;/p&gt;

&lt;p&gt;However, a-captcha currently lacks safeguards required for SMS login, including phone-number binding and atomic consumption. It needs a bounded set of backward-compatible extensions.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Suite and module structure
&lt;/h2&gt;

&lt;p&gt;The proposed names follow the current naming rules and can remain unchanged.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Suite&lt;/td&gt;
&lt;td&gt;cabloy-sms&lt;/td&gt;
&lt;td&gt;providerId=cabloy, suiteName=sms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Module&lt;/td&gt;
&lt;td&gt;cabloy-sms&lt;/td&gt;
&lt;td&gt;Shared SMS infrastructure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Module&lt;/td&gt;
&lt;td&gt;sms-captcha&lt;/td&gt;
&lt;td&gt;SMS verification codes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Module&lt;/td&gt;
&lt;td&gt;sms-auth&lt;/td&gt;
&lt;td&gt;SMS registration and login&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Module&lt;/td&gt;
&lt;td&gt;sms-mock&lt;/td&gt;
&lt;td&gt;Mock SMS Provider&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A Suite and one of its Modules can share a name. Their full package names are vona-suite-cabloy-sms and vona-module-cabloy-sms, so they remain distinct.&lt;/p&gt;

&lt;p&gt;Place backend modules under:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vona/src/suite/cabloy-sms/modules/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Place corresponding frontend modules that actually contain frontend code under:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;zova/src/suite/cabloy-sms/modules/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;There is no requirement to create four empty frontend counterparts. The initial frontend work mainly belongs to sms-captcha for verification interactions and sms-auth for login forms. Mock autofill does not require a separate frontend Mock system.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dependency direction
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;sms-captcha depends on the SMS infrastructure and the existing verification system.&lt;/li&gt;
&lt;li&gt;sms-auth depends on SMS verification and the existing authentication system.&lt;/li&gt;
&lt;li&gt;sms-mock only needs the SMS infrastructure.&lt;/li&gt;
&lt;li&gt;The infrastructure, verification, and authentication modules must not have a hard dependency on sms-mock.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Whether Mock participates at runtime should be determined by application composition and server configuration, rather than being enabled unconditionally by business modules.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. cabloy-sms: defining provider / clients / scene
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Provider: implementation of a vendor protocol
&lt;/h3&gt;

&lt;p&gt;A Provider implements a sending protocol, for example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;sms-mock:mock.&lt;/li&gt;
&lt;li&gt;A future Alibaba Cloud SMS Provider.&lt;/li&gt;
&lt;li&gt;A future Tencent Cloud SMS Provider.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Provider is responsible for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Converting a unified send request into the vendor's request.&lt;/li&gt;
&lt;li&gt;Calling the SDK or HTTP API.&lt;/li&gt;
&lt;li&gt;Converting the vendor's response into a unified result.&lt;/li&gt;
&lt;li&gt;Hiding vendor errors and sensitive information.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It does not generate verification codes, decide between registration and login, or look up users.&lt;/p&gt;

&lt;p&gt;Introduce smsProvider and smsScene extension types using the existing decorators, type registration, onion metadata, and CLI templates. There is no need for a separate plugin manager.&lt;/p&gt;

&lt;p&gt;Existing reference:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vona/src/suite-vendor/a-pay/modules/a-pay/src/types/payProvider.ts:6&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Client: named account configuration under a Provider
&lt;/h3&gt;

&lt;p&gt;A Client is named configuration under a Provider. It is not a new business service and does not need its own bean scene.&lt;/p&gt;

&lt;p&gt;For example, one real Provider can have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;default: the default account.&lt;/li&gt;
&lt;li&gt;marketing: another vendor account or dedicated sending configuration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A Client holds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Credentials.&lt;/li&gt;
&lt;li&gt;Region and endpoint.&lt;/li&gt;
&lt;li&gt;Necessary vendor defaults.&lt;/li&gt;
&lt;li&gt;Settings such as whether it is enabled.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use base + clients under each Provider, retaining the type association between Provider and Client.&lt;/p&gt;

&lt;p&gt;The initial release does not need vendor account tables, a credential management console, or a persistent Client registry. Configuration is sufficient for the current consumers.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Scene: a business sending scenario
&lt;/h3&gt;

&lt;p&gt;A Scene represents a stable business intent for sending, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;sms-auth:signin.&lt;/li&gt;
&lt;li&gt;Future order or delivery notifications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A Scene configures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which Provider and Client to use.&lt;/li&gt;
&lt;li&gt;SMS signature and vendor template.&lt;/li&gt;
&lt;li&gt;Template parameter constraints.&lt;/li&gt;
&lt;li&gt;Any necessary server-side routing rules.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The server-side call could look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Proposed interface, not an existing API&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bean&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sms&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;scene&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sms-auth:signin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;recipient&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;normalizedPhone&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;minutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The caller supplies business parameters; the infrastructure resolves transport configuration. Public requests must not directly specify the Provider, Client, template ID, signature, or credentials.&lt;/p&gt;

&lt;p&gt;Also distinguish these concepts:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SMS Scene&lt;/td&gt;
&lt;td&gt;Selects the transport channel, account, and template&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Captcha Scene&lt;/td&gt;
&lt;td&gt;Defines which business operation the verification code can authorize&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The same business module may declare and associate both, but they are not interchangeable. A third registry for “SMS verification scenarios” is unnecessary.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Instance isolation and send results
&lt;/h3&gt;

&lt;p&gt;Providers and Scenes must resolve effective configuration for the current instance. Never cache the first request's credentials, phone number, or scene configuration in shared bean fields.&lt;/p&gt;

&lt;p&gt;The existing onion configuration merge includes instance configuration. Reading static beanOptions.options directly is not equivalent:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vona/src/suite-vendor/a-vona/modules/a-onion/src/service/onion_.ts:252&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Keep sending synchronous for the initial release and distinguish:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Accepted by the vendor.&lt;/li&gt;
&lt;li&gt;Explicitly rejected.&lt;/li&gt;
&lt;li&gt;An uncertain result, such as a timeout.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;“Accepted by the vendor” does not mean “received by the phone.” Defer message queues, delivery receipts, automatic failover, and automatic retries. In particular, do not blindly resend after a timeout.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. sms-captcha: reuse verification infrastructure and add SMS semantics
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Existing capabilities and gaps
&lt;/h3&gt;

&lt;p&gt;a-captcha already provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A challenge ID.&lt;/li&gt;
&lt;li&gt;Provider and Scene.&lt;/li&gt;
&lt;li&gt;Redis storage and TTL.&lt;/li&gt;
&lt;li&gt;Verification DTOs.&lt;/li&gt;
&lt;li&gt;Form validation integration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, its cache currently stores only scene/provider/token/token2, without the recipient phone number. Successful verification uses separate read, compare, and delete operations, allowing multiple concurrent attempts to succeed.&lt;/p&gt;

&lt;p&gt;Reference:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vona/src/suite-vendor/a-captcha/modules/a-captcha/src/bean/bean.captcha.ts:19, :79&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Adding a CaptchaProvider that sends SMS is therefore not enough to complete SMS verification.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Recommended responsibilities
&lt;/h3&gt;

&lt;p&gt;Add generic, optional capabilities to a-captcha:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Accept trusted context at creation time.&lt;/li&gt;
&lt;li&gt;Store verification binding information.&lt;/li&gt;
&lt;li&gt;Compare it with the expected binding computed by the server at consumption time.&lt;/li&gt;
&lt;li&gt;Use atomic state transitions to guarantee single consumption.&lt;/li&gt;
&lt;li&gt;Let Provider/Scene declare policies for controlled issuance, refresh, and token exposure.&lt;/li&gt;
&lt;li&gt;Remove plaintext tokens from generic verification logs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;sms-captcha owns the SMS-specific rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Phone-number normalization and format validation.&lt;/li&gt;
&lt;li&gt;Allowed purposes and scene mapping.&lt;/li&gt;
&lt;li&gt;Cryptographically secure code generation.&lt;/li&gt;
&lt;li&gt;Binding to the phone number, purpose, and any necessary subject.&lt;/li&gt;
&lt;li&gt;Sending cooldowns, quotas, and failed verification attempt limits.&lt;/li&gt;
&lt;li&gt;Calling the SMS infrastructure.&lt;/li&gt;
&lt;li&gt;SMS-specific form interactions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This reuses the OTP system while keeping phone-number rules out of the generic verification module.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Recommended verification rules
&lt;/h3&gt;

&lt;p&gt;For the initial release:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th&gt;Recommendation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Code&lt;/td&gt;
&lt;td&gt;Six digits, handled as a string and generated securely&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Validity&lt;/td&gt;
&lt;td&gt;Five minutes, configurable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resend cooldown&lt;/td&gt;
&lt;td&gt;60 seconds, configurable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Failed attempts&lt;/td&gt;
&lt;td&gt;An explicit limit, such as five&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Expiry&lt;/td&gt;
&lt;td&gt;Lookups and incorrect attempts never extend the original expiry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resend&lt;/td&gt;
&lt;td&gt;A new challenge replaces the old one; the old proof becomes invalid&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Consumption&lt;/td&gt;
&lt;td&gt;A correct code can succeed at most once&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Binding&lt;/td&gt;
&lt;td&gt;Current instance + normalized phone number + purpose; add subject binding as required&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Abuse prevention&lt;/td&gt;
&lt;td&gt;Phone cooldowns/quotas + IP rate limits + verification attempt limits&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The phone number cannot be just a send parameter. A code sent to phone A must never authorize login for phone B, even when the code itself is correct.&lt;/p&gt;

&lt;p&gt;The initial release can continue using the existing Redis storage for short-lived secrets, without building another cache just for hashed storage. It must have a short TTL, access isolation, no plaintext logs, and no persistent verification-code history. If hashed storage becomes a requirement, explicitly separate stored verification material from the value returned for Mock autofill; the current interface does not inherently support that distinction.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Prevent bypasses through generic endpoints
&lt;/h3&gt;

&lt;p&gt;The existing generic captcha creation, refresh, and immediate-verification endpoints are public:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vona/src/suite-vendor/a-captcha/modules/a-captcha/src/controller/captcha.ts:15&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Security rules must therefore live at the shared service boundary, rather than only in a new SMS Controller.&lt;/p&gt;

&lt;p&gt;For the initial release:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generic create(scene) must not create an SMS challenge without trusted context.&lt;/li&gt;
&lt;li&gt;Generic refresh(id, scene) must not resend while bypassing the SMS cooldown.&lt;/li&gt;
&lt;li&gt;Refreshing an expired or missing ID must not fall back to unrestricted sending.&lt;/li&gt;
&lt;li&gt;SMS scenes should initially disable verifyImmediate → token2, avoiding another replayable proof.&lt;/li&gt;
&lt;li&gt;SMS verification must fail when the expected phone/purpose binding is absent.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  5. sms-mock: simulate transport while preserving business validation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Correct runtime behavior
&lt;/h3&gt;

&lt;p&gt;Mock should follow the same chain as real SMS:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;sms-captcha generates a code and establishes its binding.&lt;/li&gt;
&lt;li&gt;The SMS infrastructure resolves the sms-mock Provider.&lt;/li&gt;
&lt;li&gt;Mock makes no external vendor calls.&lt;/li&gt;
&lt;li&gt;It prints the code to the development console with the phone number masked.&lt;/li&gt;
&lt;li&gt;The verification layer returns the code to the frontend only when permitted.&lt;/li&gt;
&lt;li&gt;Submission still enforces expiry, attempt limits, binding, and single consumption.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Never use a fixed universal code or make Mock login return success directly.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Autofill can reuse the existing response field
&lt;/h3&gt;

&lt;p&gt;The captcha response already supports an optional token, and the current form writes it into the input:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;zova/src/suite/cabloy-basic/modules/basic-captcha/src/component/formFieldCaptcha/controller.tsx:96&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;There is no need for a second verification-response protocol.&lt;/p&gt;

&lt;p&gt;However, showToken currently defaults to enabled in all non-production environments. Real SMS must not inherit that behavior:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vona/src/suite-vendor/a-captcha/modules/a-captcha/src/config/config.ts:3&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Returning an SMS code requires all three conditions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The actual Provider used for this request is sms-mock.&lt;/li&gt;
&lt;li&gt;The environment is non-production.&lt;/li&gt;
&lt;li&gt;Development autofill is explicitly enabled.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Real SMS must never return the code because of the global showToken setting, even in dev/test. Selecting Mock in production must fail at startup or sending time, rather than silently falling back.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The frontend needs SMS-specific interactions
&lt;/h3&gt;

&lt;p&gt;The existing image-captcha component automatically creates a challenge on initialization, refreshes it after a failed submission, and renders the payload as an image. It cannot be used unchanged for paid SMS.&lt;/p&gt;

&lt;p&gt;The SMS component should provide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A phone-number input.&lt;/li&gt;
&lt;li&gt;An explicit “Send code” button.&lt;/li&gt;
&lt;li&gt;A cooldown based on server time.&lt;/li&gt;
&lt;li&gt;Autofill after a successful Mock send.&lt;/li&gt;
&lt;li&gt;Clearing the challenge and code when the phone number changes.&lt;/li&gt;
&lt;li&gt;No automatic retry after a send failure.&lt;/li&gt;
&lt;li&gt;No automatic sending on page initialization or ordinary form errors.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keep the code only in the current interaction state. Do not put it in localStorage, SSR HTML, or persistent user state.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. sms-auth: reuse authentication and establish a trusted phone identity
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Recommended product behavior
&lt;/h3&gt;

&lt;p&gt;For the initial release, I recommend:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Sign in after successful phone verification; automatically register if that SMS identity does not exist.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One form can handle both registration and login, matching the basic behavior of the existing generic authentication chain. This remains a product decision requiring confirmation. If registration and login must be strictly separate, define how each operation handles existing and missing identities.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Authentication flow
&lt;/h3&gt;

&lt;p&gt;Add a non-OAuth SMS AuthProvider and reuse this chain:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Verify and consume OTP → obtain or create identity and user → existing Passport signin&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The framework already supports provider.verify → issuePassport → passport.signin:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vona/src/suite-vendor/a-auth/modules/a-auth/src/service/auth.ts:27&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Key requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Consume the OTP at the Provider's verification boundary, rather than only in a new Controller.&lt;/li&gt;
&lt;li&gt;Keep Provider, Client, and intention under server control.&lt;/li&gt;
&lt;li&gt;Do not merge the entire request into authentication configuration.&lt;/li&gt;
&lt;li&gt;Do not create a separate JWT, Cookie, or session storage system.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Never claim an account automatically through an old mobile field
&lt;/h3&gt;

&lt;p&gt;The existing homeUser.mobile is only an optional string. It does not mean “verified phone number”:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vona/src/suite/a-home/modules/home-user/src/entity/user.ts:24&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Use the existing authentication identity mapping:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SMS identity namespace + normalized phone number → auth mapping → userId
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A trusted SMS mapping exists: sign in to its associated user.&lt;/li&gt;
&lt;li&gt;No mapping exists: register or reject according to the confirmed policy.&lt;/li&gt;
&lt;li&gt;An old account has the same mobile value: never automatically associate, merge, or take over that account.&lt;/li&gt;
&lt;li&gt;A mapping exists but its user is missing: return an error; do not silently recreate the account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Defer phone binding, phone changes, recovery, and account merging. Explicitly reject associate/migrate inside the Provider so generic entry points cannot trigger them.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Handle concurrent first registrations separately
&lt;/h3&gt;

&lt;p&gt;Atomic consumption of one code does not guarantee identity uniqueness: a single phone number may have two independent, valid verification requests.&lt;/p&gt;

&lt;p&gt;Serialize by current instance and SMS identity, then recheck and atomically complete these writes within a transaction:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User creation.&lt;/li&gt;
&lt;li&gt;Normal role relationships.&lt;/li&gt;
&lt;li&gt;The auth mapping.&lt;/li&gt;
&lt;li&gt;Any necessary projection into the mobile profile field.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Enter the existing signin flow after commit. A transaction alone, or a lock on a row that does not exist, is insufficient to prevent duplicate creation. Do not add business uniqueness constraints spanning tenants.&lt;/p&gt;

&lt;p&gt;Prefer reusing the existing identity mapping without a new identity table. If a persisted field such as mobileVerifiedAt is necessary, confirm the owning module's fileVersion strategy before implementation.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Frontend login integration
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;sms-auth provides the SMS login form and business wrapper.&lt;/li&gt;
&lt;li&gt;Keep integration with the existing Home Login page minimal.&lt;/li&gt;
&lt;li&gt;Reuse Passport's post-login handling instead of copying token writes and returnTo logic.&lt;/li&gt;
&lt;li&gt;Web/Admin share authentication identities; a different page or vendor Client must not create duplicate users.&lt;/li&gt;
&lt;li&gt;New users follow an explicit ordinary-user role policy. Successful SMS registration does not grant administrative permissions.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  7. Recommended delivery order and acceptance
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;Deliverables&lt;/th&gt;
&lt;th&gt;Exit criteria&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. Infrastructure + Mock&lt;/td&gt;
&lt;td&gt;Provider/Client/Scene, send facade, Mock&lt;/td&gt;
&lt;td&gt;Ordinary template messages can be sent through Mock; instance configuration is isolated; failure semantics are explicit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. SMS verification&lt;/td&gt;
&lt;td&gt;Required captcha extensions, issuance/resend, abuse prevention, SMS component&lt;/td&gt;
&lt;td&gt;Autofill works; phone/purpose binding and atomic consumption are enforced; generic endpoints cannot bypass them&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. SMS registration and login&lt;/td&gt;
&lt;td&gt;SMS AuthProvider, identity creation boundary, login entry&lt;/td&gt;
&lt;td&gt;Registration and subsequent login work; old mobile values are not claimed; concurrent requests do not create duplicate accounts; sessions are reused&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4. First real Provider&lt;/td&gt;
&lt;td&gt;Integration with the selected vendor&lt;/td&gt;
&lt;td&gt;Mock and real transport follow the same contract; real SMS never returns or logs codes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Although Mock is fourth in the module list, implement it with the infrastructure so verification and authentication have a runnable consumer chain from the beginning.&lt;/p&gt;

&lt;p&gt;Acceptance need not become an enormous matrix, but it must cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Verification fails across phone numbers, purposes, and instances, and for expired or replayed codes.&lt;/li&gt;
&lt;li&gt;At most one concurrent consumption of the same challenge succeeds.&lt;/li&gt;
&lt;li&gt;Two independent valid OTPs used concurrently for first login produce exactly one user and identity mapping.&lt;/li&gt;
&lt;li&gt;Generic captcha and authentication entry points cannot bypass security rules.&lt;/li&gt;
&lt;li&gt;Changing the phone number clears the old proof.&lt;/li&gt;
&lt;li&gt;Real SMS never exposes codes in any environment.&lt;/li&gt;
&lt;li&gt;Mock prints and autofills codes only behind explicit development gates.&lt;/li&gt;
&lt;li&gt;Disabled users cannot sign in, and existing password/GitHub login does not regress.&lt;/li&gt;
&lt;li&gt;Sending timeouts never trigger blind retries.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  8. Initial scope and decisions to confirm
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Keep out of the initial release:&lt;/strong&gt; vendor management screens, sending-history screens, bulk marketing, queues, receipts, automatic retries/failover, phone-number changes, recovery, and account merging.&lt;/p&gt;

&lt;p&gt;Only three groups of product decisions need confirmation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Registration: should SMS login automatically register a new user? Recommended.&lt;/li&gt;
&lt;li&gt;Phone-number scope: mainland China only initially, or international numbers too? Either way, require an explicit calling code and normalize consistently. Never prepend +86 to every input by default.&lt;/li&gt;
&lt;li&gt;Rollout: Web first, or Admin at the same time? Should the initial release deliver only the complete Mock flow and defer real vendors?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The names are already reasonable and need no change. Branding or naming preferences can still be accommodated under the same rules.&lt;/p&gt;

&lt;p&gt;After confirmation, create the infrastructure and Mock using the existing CLI rather than building directories manually, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run vona :create:suite cabloy-sms
npm run vona :create:module cabloy-sms &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;--suite&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cabloy-sms
npm run vona :create:module sms-mock &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;--suite&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cabloy-sms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then generate the remaining modules in stages, run focused backend tests, and verify critical E2E flows. Backend contract changes should generate frontend consumers first. For frontend reverse dependencies, build the affected Web/Admin flavors before running npm run deps:vona.&lt;/p&gt;

&lt;p&gt;This round only completed analysis and made no file changes. The CLI command implementations were confirmed in source, but attempts to run npm run vona and npm run zova both failed because @cabloy/cli was missing. Node was v24.8.0, below the repository requirement of &amp;gt;=24.11.0. Prepare the runtime and dependencies before implementation. No dependencies were installed, and no builds or tests were run in this round.&lt;/p&gt;




&lt;h2&gt;
  
  
  Closing note
&lt;/h2&gt;

&lt;p&gt;Claude Code asked me to confirm three groups of product decisions—registration behavior, phone-number scope, and rollout scope—before developing the plan further. I will leave it here for now to keep the article manageable. If you would like to see what comes next, leave a comment and I will continue putting the material together.&lt;/p&gt;

</description>
      <category>cabloy</category>
      <category>claudecode</category>
      <category>aicoding</category>
      <category>vibecoding</category>
    </item>
    <item>
      <title>Functional vs Object-Oriented: Two Cost Curves for Frontend Architecture</title>
      <dc:creator>Uncle Pushui</dc:creator>
      <pubDate>Thu, 22 Oct 2026 11:52:11 +0000</pubDate>
      <link>https://dev.to/uncle-pushui/functional-vs-object-oriented-two-cost-curves-for-frontend-architecture-5ck4</link>
      <guid>https://dev.to/uncle-pushui/functional-vs-object-oriented-two-cost-curves-for-frontend-architecture-5ck4</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Abstract:&lt;/strong&gt; People habitually carve the React/Vue and Zova camps into "functional vs object-oriented." But React's Fiber nodes and Vue's component instances reveal a fact: beneath that so-called functional style, an object system is always hiding. The real dividing line is not syntax — it is who owns state identity, scope, and lifecycle: the closure, or a container-managed bean. This article re-reads the paradigm debate through two cost curves: the functional style pays "architectural entropy" afterwards, the object style pays "ceremony" up front. It then lists three hard requirements only containerization solves cleanly (SSR request scope, interceptable call sites, cross-module contracts), and three costs an object style must honestly face. The final criterion boils down to one sentence: if something needs to be found, replaced, shared, or disposed, make it an object; otherwise, let it be a function.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  1. Tearing down a false dichotomy first
&lt;/h2&gt;

&lt;p&gt;When people discuss the difference between Vue/React and Zova, the most common framing is "functional vs object-oriented." It's a convenient label, but it conflates three distinct things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Syntactic form:&lt;/strong&gt; writing functions or classes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State host:&lt;/strong&gt; closure variables or object properties&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Architectural ownership:&lt;/strong&gt; who manages identity, scope, and lifecycle&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Take one step into the source code, and the classification "React is functional, Vue is functional, Zova is object-oriented" collapses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React's "functions" are merely the expression form of rendering.&lt;/strong&gt; Hooks depend on a fixed call order — which means every function component must have a persistent Fiber node behind it holding the hooks linked list. Pure functions need no identity; React components have identity, scheduling phases, and effect-cleanup queues. React hides an object system beneath function syntax.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vue's &lt;code&gt;setup()&lt;/code&gt; is a function, but every component instance is an object.&lt;/strong&gt; The reactive host is a Proxy object, &lt;code&gt;ref&lt;/code&gt; is a box with getter/setter, &lt;code&gt;reactive&lt;/code&gt; is a proxied object graph. Vue never pretended to be purely functional.&lt;/p&gt;

&lt;p&gt;So the real watershed is not "whether to use functions" — it is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Who owns identity, scope, and lifecycle — the closure, or a container-managed bean?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is the actual boundary between Zova's default mental model and Vue/React's.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Each model's "default answer"
&lt;/h2&gt;

&lt;p&gt;The same counter, written two ways — the difference looks like mere syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Vue 3 default mental model: explicit reactive primitives&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;count2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;computed&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`=== &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; ===`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Zova: a framework-managed reactive object&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Counter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;count2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;$computed&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`=== &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; ===`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count2&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Increment&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference is not that we saved a few &lt;code&gt;.value&lt;/code&gt; keystrokes. In the first snippet, state's host is the &lt;code&gt;setup()&lt;/code&gt; closure, lifecycle hangs off the component instance, and sharing requires hunting for another mechanism. In the second, state's host is a bean instance that &lt;strong&gt;inherently belongs to a container, to a scope&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This single distinction will reveal itself over and over as a system grows.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Cost curves: pre-paid and post-paid
&lt;/h2&gt;

&lt;p&gt;The real divergence between the two models is &lt;strong&gt;where the cost shows up&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Functional style: architectural entropy, paid after
&lt;/h3&gt;

&lt;p&gt;A single component costs almost nothing extra — write a function, declare a few &lt;code&gt;ref&lt;/code&gt;s, done. But Vue officially ships four mutually orthogonal sharing mechanisms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;props / emits&lt;/li&gt;
&lt;li&gt;composables&lt;/li&gt;
&lt;li&gt;&lt;code&gt;provide / inject&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;store layer (Pinia, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When a system grows to dozens of modules and multiple teams, all four mechanisms coexist in one codebase. Which state should use which? There is no enforced answer, only team conventions. Convention density grows linearly with headcount, while execution drift grows exponentially. That is architectural entropy — it never shows up on day one, but it never fails to show up.&lt;/p&gt;

&lt;h3&gt;
  
  
  Object style: ceremony, paid up front
&lt;/h3&gt;

&lt;p&gt;In Zova, every bean must declare its role, scope, and lifecycle. Even a state that only serves a single component's internals has to answer first: "which bean are you, and which container do you live in?" That is the up-front ceremony.&lt;/p&gt;

&lt;p&gt;What it buys in return is the convergence of sharing into one mechanism:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ControllerPage&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="nx"&gt;$$localCounterState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CounterState&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="c1"&gt;// ctx container: component-instance scope&lt;/span&gt;

  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;injectionScope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;host&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="nx"&gt;$$hostCounterState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CounterState&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;           &lt;span class="c1"&gt;// hierarchical lookup: parent–child sharing&lt;/span&gt;

  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;injectionScope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="nx"&gt;$$appCounterState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CounterState&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;            &lt;span class="c1"&gt;// app container: app / request scope&lt;/span&gt;

  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;injectionScope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sys&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="nx"&gt;$$sysCounterState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CounterState&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;            &lt;span class="c1"&gt;// sys container: system scope&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Component-internal, between-components, app-global, system-global — four sharing scopes, one IoC semantics. &lt;code&gt;provide/inject&lt;/code&gt; stops being an independent subsystem and becomes the natural corollary of &lt;code&gt;host&lt;/code&gt; / &lt;code&gt;skipSelf&lt;/code&gt; injection scopes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So "which is better" is a pseudo-question.&lt;/strong&gt; The right question is: where does your system's complexity primarily land? If it lands on "rendering composition," the functional style's flexibility is pure gain. If it lands on "domain ownership, modularity, long-term evolution," the object style's uniformity pays back.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Three things only containerization does cleanly
&lt;/h2&gt;

&lt;p&gt;Some questions are not "style choices" — they are "does this mechanism exist?" questions.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. SSR request scope
&lt;/h3&gt;

&lt;p&gt;SSR has a hard constraint: state must be isolated across requests; module-level singletons leak user data.&lt;/p&gt;

&lt;p&gt;In the functional model, there is no addressable container called "the request." You only have two choices: module-level singletons (leak) or rebuilding the entire module graph per request (expensive and error-prone). Zova's &lt;code&gt;app&lt;/code&gt; container is natively the request boundary, and the &lt;code&gt;sys&lt;/code&gt; container is natively cross-request — this is not syntax sugar; it is a first-class SSR requirement modeled directly into the architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Interceptable call sites
&lt;/h3&gt;

&lt;p&gt;AOP, permission injection, logging, behavior extension — all of these require "call sites" to have stable identity. Pure function calls have no identity; to intercept you have to wrap functions in layers, and the wrapper layers themselves are anonymous and unaddressable. A bean's method call naturally passes through the container, and the container is naturally the interception point.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Cross-module contracts
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ControllerLayout&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a-routertabs.model.tabs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;$$modelTabs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ModelTabs&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bean identifiers let consumers depend on a contract name, not the provider's file path. Modules can be reorganized, relocated, have their implementations replaced — and consumers do not move.&lt;/p&gt;

&lt;p&gt;Functional cross-module sharing eventually converges onto some global store key or context key — essentially a string contract too, except no container is managing its registration, resolution, and lifecycle for you. Anyone can reinvent the mechanism; the difference is whether it is part of the architecture or part of the scaffolding.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Honestly listing three costs of the object style
&lt;/h2&gt;

&lt;p&gt;If you only see the benefits, that is marketing, not architecture. The object style carries three real costs:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Decorators + metadata = runtime magic.&lt;/strong&gt; Behind &lt;code&gt;@Use()&lt;/code&gt; is a conspiracy of build-time transforms and runtime resolution. Static readability drops, call stacks go deeper, and debugging means piercing one extra layer of framework.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Granularity gets forced coarser.&lt;/strong&gt; When "everything should be a bean" becomes a habit, you end up with an input box that still needs a role and a scope — over-modeling. The object style needs discipline to fight its own ceremony.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Structural conflict with React's evolution direction.&lt;/strong&gt; RSC and concurrent rendering push state toward serializable pure data, while a bean is a non-serializable live object graph. Zova can only grow on Vue, not on React — and this is not an aesthetic choice, it is determined by the runtime substrate: Vue's component instance is already an object with a reactive scope, naturally suited to host beans; React's Fiber substrate is heading in the opposite direction.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Convergence: objects own identity, functions own expression
&lt;/h2&gt;

&lt;p&gt;The interesting thing is that both camps are moving into each other's core territory.&lt;/p&gt;

&lt;p&gt;Zova itself is a hybrid: underneath runs Vue reactivity, and &lt;code&gt;$computed&lt;/code&gt; and &lt;code&gt;$watch&lt;/code&gt; are thoroughly functional APIs. Objects only carry identity, scope, and lifecycle — &lt;strong&gt;not computation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The React ecosystem is also moving toward identity: the signals revival, external state containers like &lt;code&gt;QueryClient&lt;/code&gt;, stores like Zustand that "pull state out of the closure" — all essentially admitting that pure closures cannot carry all state, and that an addressable host is needed.&lt;/p&gt;

&lt;p&gt;From this we get an actionable judgment criterion:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;If something needs to be "found, replaced, shared across scopes, disposed with a lifecycle," it is an object; otherwise it should be a function.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Wrapping a pure function in an object is over-design; using a closure to carry something that needs identity is architectural debt.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  7. Conclusion: a debate not on the same abstraction layer
&lt;/h2&gt;

&lt;p&gt;Let us return to the comparison in the title.&lt;/p&gt;

&lt;p&gt;The functional style solves "how to compose rendering." The object style solves "how to organize a long-lived system." The former is a programming paradigm; the latter is an architectural paradigm — &lt;strong&gt;they are not on the same abstraction layer&lt;/strong&gt;. Comparing their elegance directly often leads to "FP is more advanced," but that conclusion is wrong: React's hooks are precisely effectful closures with order constraints, side effects, and Fiber scheduling — they are no closer to pure functions than classes are.&lt;/p&gt;

&lt;p&gt;The questions worth asking are always:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In my system, who does state identity belong to?&lt;/li&gt;
&lt;li&gt;Is the state-sharing mechanism one set or four?&lt;/li&gt;
&lt;li&gt;Is the SSR request boundary modeled?&lt;/li&gt;
&lt;li&gt;When a newcomer takes over an unfamiliar module and needs to change some stateful behavior: do they have to rummage through composables, stores, and provide/inject one by one to find the state's host, or do they just ask "which bean is this?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Zova chooses to pay ceremony up front and reap order later. Whether that choice is right depends not on how elegant the syntax is, but on how long your system plans to live and how big it plans to grow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/cabloy/cabloy" rel="noopener noreferrer"&gt;https://github.com/cabloy/cabloy&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Docs: &lt;a href="https://cabloy.com" rel="noopener noreferrer"&gt;https://cabloy.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Demo: &lt;a href="https://cabloy.com/demo" rel="noopener noreferrer"&gt;https://cabloy.com/demo&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>vue3</category>
      <category>react</category>
      <category>zova</category>
      <category>cabloy</category>
    </item>
    <item>
      <title>CabloyJS’s AI Moment: From a TypeScript Fullstack Framework to AI-Spec-Driven Development</title>
      <dc:creator>Uncle Pushui</dc:creator>
      <pubDate>Fri, 16 Oct 2026 00:52:11 +0000</pubDate>
      <link>https://dev.to/uncle-pushui/cabloyjss-ai-moment-from-a-typescript-fullstack-framework-to-ai-spec-driven-development-5h7o</link>
      <guid>https://dev.to/uncle-pushui/cabloyjss-ai-moment-from-a-typescript-fullstack-framework-to-ai-spec-driven-development-5h7o</guid>
      <description>&lt;p&gt;AI coding assistants have turned "having AI write code" into a mainstream conversation over the past two years. From Cursor's tab completion, to Claude Code's agent mode, to the more radical "Vibe Coding" — describing an idea in natural language and letting AI turn it into a running app.&lt;/p&gt;

&lt;p&gt;But the real difficulty appears when a Vibe Coding project outgrows "hello world" and becomes an actual business system.&lt;/p&gt;

&lt;p&gt;AI "hallucinates." It modifies modules you didn't ask it to touch, assumes interfaces and data structures that don't exist, and turns an entire repository into a mess. This is not about prompts being imprecise enough — it is a deeper problem: &lt;strong&gt;AI lacks explicit, machine-readable global constraints&lt;/strong&gt;. It can only guess from context what the correct boundaries are, and once that guess drifts outside the business scope, the cost of repair grows exponentially.&lt;/p&gt;

&lt;p&gt;The series of pivotal iterations CabloyJS made in the second half of 2026 is a systematic answer to exactly this pain point. No longer satisfied with being a TypeScript fullstack framework that helps developers scaffolding CRUD faster, CabloyJS has been proactively restructuring itself into an &lt;strong&gt;AI Spec-Driven Development (AI-SDD) framework&lt;/strong&gt; purpose-built for AI Vibe Coding.&lt;/p&gt;

&lt;p&gt;This evolution can be organized into three clear threads.&lt;/p&gt;




&lt;h2&gt;
  
  
  Thread One: Turn "having AI write code" into "having AI deliver against a specification"
&lt;/h2&gt;

&lt;p&gt;Most AI coding assistants follow this model: give a description, AI generates a chunk of code based on context. This model works well for local tasks, but inside complex systems that span multiple modules and both frontend and backend, AI faces a fundamental dilemma — it does not know where its boundaries are.&lt;/p&gt;

&lt;p&gt;CabloyJS's answer is a set of built-in Claude Code Skills that splits the development workflow into two strict phases.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase One: Establish "specification authority" inside the repository
&lt;/h3&gt;

&lt;p&gt;The first Skill, &lt;code&gt;cabloy-spec-generation&lt;/code&gt;, does not write code. Its job is to &lt;strong&gt;establish explicit specification files inside the repository so that both AI and humans read the same source of truth&lt;/strong&gt;. A typical output is a set of mutually referencing Spec files covering product requirements, technical contracts, delivery plans, acceptance criteria, and architecture decision records.&lt;/p&gt;

&lt;p&gt;The key is not merely "having a pile of documents on disk." It is &lt;strong&gt;separated authority&lt;/strong&gt;: each file owns one kind of fact, and other files refer to it through stable IDs. Product requirements do not prescribe table names; technical contracts do not redefine business rules; delivery plans do not rewrite upstream authority. AI never has to guess "what is the boundary of this module?" — it goes and reads the Spec that is already there.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase Two: Let AI execute bounded increments
&lt;/h3&gt;

&lt;p&gt;Only after the specification is in place does the second Skill, &lt;code&gt;cabloy-spec-execution&lt;/code&gt;, start touching code. It does not "look at a prompt and change things randomly." It follows a strict execution chain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Read specs → confirm boundaries → generate execution dossier → make source changes → run verification → save evidence → update progress
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every step has a confirmation gate. AI does not automatically expand the task scope, does not skip verification steps, and does not pretend "it's done" when verification fails. The final deliverable is not just a chunk of code — it is &lt;strong&gt;source changes plus an auditable Evidence record plus updated progress state&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Putting these two phases together, CabloyJS is doing something deliberately simple: &lt;strong&gt;it prevents AI from jumping straight from a vague prompt to writing code. Instead, it inserts a Spec-based middle layer that gives AI clear behavioral boundaries within that layer&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;What distinguishes this from traditional "spec-driven development" is that in the traditional model, specs are documents written for humans. In CabloyJS, specs are &lt;strong&gt;machine-readable authority written for both AI and humans&lt;/strong&gt;. AI does not merely "consult" the Spec — its entire execution flow is driven by it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Thread Two: A side effect of AI-SDD — charts are automatically derived from Specs
&lt;/h2&gt;

&lt;p&gt;When every AI operation is constrained by the Specs and updating the same progress file, a natural question emerges: &lt;strong&gt;can we directly derive agile visualization charts from this structured data?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The answer is yes. CabloyJS's Spec system ships with a small toolchain that automatically derives two charts from the WBS (Work Breakdown Structure) and progress files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gantt&lt;/strong&gt;: shows delivery phases, task order, dependencies, and current status&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Burndown&lt;/strong&gt;: shows the approved scope task counts and remaining items&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These charts are not hand-drawn pictures — they are direct visualizations of the Spec data. When AI finishes a WBS task and updates the progress file, running the generation script once more updates the charts automatically.&lt;/p&gt;

&lt;p&gt;On the surface this looks like a "cool small feature," but in the AI-SDD context its significance is completely different. It means: &lt;strong&gt;while AI is writing business code, it is also automatically maintaining the agile progress visualization of the entire project&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You ask AI to build a CRM system. AI is not just helping you write the customer-management CRUD — it is simultaneously updating task dependencies on the Gantt chart and marking completed work items on the Burndown. The entire development pipeline becomes one continuous flow instead of the split state where "AI writes code, humans manually update Trello/Jira."&lt;/p&gt;

&lt;p&gt;One sober expectation is worth keeping: &lt;strong&gt;auto-generated charts are structural views, not calendar schedules or velocity forecasts&lt;/strong&gt;. They tell you what delivery packages exist, their approximate ordering, and which ones have been verified — but they will not tell you whether everything can ship by next Wednesday. That is intentional. AI should not be held responsible for calendar commitments until it truly has business understanding. Until then, treating the charts as "real-time snapshots of structure and state" is the more pragmatic choice.&lt;/p&gt;




&lt;h2&gt;
  
  
  Thread Three: Dual-Engine Architecture — why Cabloy's Vona + Zova is naturally suited for AI-SDD
&lt;/h2&gt;

&lt;p&gt;The foundation of CabloyJS is two independently evolving engines: &lt;strong&gt;Vona&lt;/strong&gt; for the backend and &lt;strong&gt;Zova&lt;/strong&gt; for the frontend. They are not "a backend folder and a frontend folder inside one big project." Each has its own IoC containers, Bean systems, and CLI. They mesh together through &lt;strong&gt;build artifacts&lt;/strong&gt; and a &lt;strong&gt;bidirectional contract loop&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This architecture gives CabloyJS a tremendous natural advantage in AI-SDD: &lt;strong&gt;backend truth and frontend truth are separate, so AI cannot randomly mess with both sides at once&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Backend truth: Vona's OpenAPI contract
&lt;/h3&gt;

&lt;p&gt;Vona's Controllers, DTOs, and Zod schemas automatically produce an OpenAPI document through decorator metadata. That OpenAPI document is the single source of truth for frontend SDK generation. When changing a backend interface, the correct order is always:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Change Vona's DTO/Controller/Zod → emit new OpenAPI → regenerate Zova's $api SDK and $apiSchema helper
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;AI will not "invent" a backend interface on the frontend, because it knows the contract truth lives on the Vona side — the frontend is only a consumer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Frontend truth: Zova's routes, components, and metadata
&lt;/h3&gt;

&lt;p&gt;Conversely, Zova's routes, components, icons, and type definitions are the frontend truth. After building, this metadata flows back into Vona's tooling through a &lt;strong&gt;reverse chain&lt;/strong&gt;, giving the backend tooling perfect IDE type hints. The correct order here is likewise enforced:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Change Zova's routes/components → build Zova (emit rest artifacts) → run deps:vona to sync into Vona
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The repository itself wires a contract-loop-gate into git hooks, which automatically checks whether this chain has been broken at commit time. That means "bidirectional contract" is not a documentation slogan — it is an engineering guardrail.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why this matters for AI
&lt;/h3&gt;

&lt;p&gt;When AI knows that backend truth lives in Vona and frontend truth lives in Zova, and that syncing them has explicit commands and guardrails, it will not freely add fields on both sides, guess interface names, or copy-paste schema definitions. AI only needs to answer three questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is this capability backend or frontend?&lt;/li&gt;
&lt;li&gt;Which side's truth do I need to change?&lt;/li&gt;
&lt;li&gt;Which command do I run to propagate the change to the other side?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three answers are &lt;strong&gt;defined by the framework&lt;/strong&gt;. AI does not have to guess.&lt;/p&gt;




&lt;h2&gt;
  
  
  A new edition split: two MIT baselines
&lt;/h2&gt;

&lt;p&gt;Another important change in 2026 is that CabloyJS's open-source editions have been formally split into two V5+ architecture MIT baselines.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cabloy Basic (reference edition)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;UI layer&lt;/strong&gt;: DaisyUI + Tailwind CSS, a modern lightweight frontend&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Built-in demo&lt;/strong&gt;: A complete e-commerce suite (&lt;code&gt;a-commerce&lt;/code&gt;) including Admin back-office, Web storefront, shopping cart, and payment flows&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Positioning&lt;/strong&gt;: Learn the fullstack pattern, build prototypes, or start projects that need a lightweight UI layer&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;License&lt;/strong&gt;: MIT&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cabloy Start (full-featured edition)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;UI layer&lt;/strong&gt;: Vuetify, a UI component library&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Built-in demo&lt;/strong&gt;: Complete system management, department management, menu authorization, and data-scope-based RBAC&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Positioning&lt;/strong&gt;: Starting point for projects that need enterprise-grade permissions, menus, and department structures&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;License&lt;/strong&gt;: MIT&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This split itself is an extension of the AI-SDD philosophy: &lt;strong&gt;choose a baseline that fits your business starting point first, then let AI deliver bounded increments within that boundary&lt;/strong&gt; — instead of starting from an empty project and asking AI to guess everything from scratch.&lt;/p&gt;




&lt;h2&gt;
  
  
  So what is CabloyJS now?
&lt;/h2&gt;

&lt;p&gt;Putting the 2026 changes together:&lt;/p&gt;

&lt;p&gt;It is no longer just a TypeScript fullstack framework that helps you scaffolding frontend and backend faster. It is a working system that makes AI Vibe Coding &lt;strong&gt;traceable, bounded, and verifiable&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;AI-SDD two-phase workflow&lt;/strong&gt; makes AI work under specification authority instead of guessing under vague prompts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-derived charts&lt;/strong&gt; visualize every step of AI progress, so the development pipeline is no longer split in two&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;dual-engine plus contract loop&lt;/strong&gt; architecture gives frontend and backend each their own source of truth, so AI will not mess with both sides simultaneously&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Two MIT baselines&lt;/strong&gt; let you start from the right point for your business instead of building everything from zero&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Its ambition is clear: be the best fullstack Vibe Coding framework in the AI era — not by "layering prompt engineering on top," but by using &lt;strong&gt;strict typing, repository-internal specification authority, and engineering guardrails&lt;/strong&gt; to turn the previously uncontrolled "blind AI code generation" into an industrial pipeline that is specification-driven, evidence-backed, and automatically reportable.&lt;/p&gt;




&lt;h2&gt;
  
  
  Start with a small increment
&lt;/h2&gt;

&lt;p&gt;If you want to feel this workflow yourself, begin from the public scaffolding:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm create cabloy
npm run dev
npm run dev:zova:admin
npm run dev:zova:web
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then pick a clearly bounded requirement — say, "add a category filter to products" — and run through the full &lt;code&gt;cabloy-spec-generation&lt;/code&gt; → &lt;code&gt;cabloy-spec-execution&lt;/code&gt; flow. You'll notice that when AI no longer has to guess boundaries, contracts, or the definition of done, its behavior quality jumps up visibly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/ai/ai-spec-driven-development" rel="noopener noreferrer"&gt;AI Spec-Driven Development&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/fullstack/vona-zova-integration" rel="noopener noreferrer"&gt;Inside Cabloy's Dual-Engine Architecture&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/fullstack/contract-loop-playbook" rel="noopener noreferrer"&gt;Contract Loop Playbook&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/ai/playbook-spec-generation" rel="noopener noreferrer"&gt;Generate a Cabloy Suite Specification&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/ai/playbook-spec-execution" rel="noopener noreferrer"&gt;Execute an Approved Cabloy Specification Increment&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/fullstack/tutorials-overview" rel="noopener noreferrer"&gt;Cabloy Fullstack Quick Start Tutorials&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aicoding</category>
      <category>vibecoding</category>
      <category>cabloy</category>
      <category>fullstack</category>
    </item>
    <item>
      <title>NestJS Dynamic Providers vs Cabloy/Vona Provider Scene: Two Ways to Bind One Interface to Many Implementations</title>
      <dc:creator>Uncle Pushui</dc:creator>
      <pubDate>Wed, 14 Oct 2026 16:06:31 +0000</pubDate>
      <link>https://dev.to/uncle-pushui/nestjs-dynamic-providers-vs-cabloyvona-provider-scene-two-ways-to-bind-one-interface-to-many-2gkh</link>
      <guid>https://dev.to/uncle-pushui/nestjs-dynamic-providers-vs-cabloyvona-provider-scene-two-ways-to-bind-one-interface-to-many-2gkh</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Both frameworks answer "one interface, many implementations, pick one at runtime". They disagree not on the implementation technique, but on &lt;strong&gt;when the binding happens&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;"One interface, several implementations, choose one by configuration or context" is a question every backend framework has to answer. Payments must switch between Stripe, PayPal, and a mock. File storage must switch between local disk and object storage. Captcha must switch between an image puzzle and an SMS code.&lt;/p&gt;

&lt;p&gt;NestJS answers it with &lt;strong&gt;Dynamic Providers&lt;/strong&gt;; Cabloy/Vona answers it with a &lt;strong&gt;Provider Scene&lt;/strong&gt;. Both work, but the assembly models are fundamentally different — and that difference propagates all the way to runtime switching, module decoupling, and the more fundamental question of what a consumer actually holds a reference to.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Short Conclusion
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dimension&lt;/th&gt;
&lt;th&gt;NestJS Dynamic Providers&lt;/th&gt;
&lt;th&gt;Vona Provider Scene&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Binding timing&lt;/td&gt;
&lt;td&gt;Once, during module initialization&lt;/td&gt;
&lt;td&gt;On every resolution, by name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Expression&lt;/td&gt;
&lt;td&gt;&lt;code&gt;{ provide: TOKEN, useClass: X }&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;@PayProvider()&lt;/code&gt; registers into a scene&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Many implementations per interface&lt;/td&gt;
&lt;td&gt;Aggregated via &lt;code&gt;multi: true&lt;/code&gt;, or one token each&lt;/td&gt;
&lt;td&gt;N registered under one scene, peers by default&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Where implementations live&lt;/td&gt;
&lt;td&gt;Usually in one module's &lt;code&gt;providers&lt;/code&gt; array&lt;/td&gt;
&lt;td&gt;Each implementation is a &lt;strong&gt;separate module&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What the consumer references&lt;/td&gt;
&lt;td&gt;An injected token&lt;/td&gt;
&lt;td&gt;A &lt;strong&gt;name&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Runtime switching&lt;/td&gt;
&lt;td&gt;Effectively fixed after init (&lt;code&gt;overrideProvider&lt;/code&gt; only applies while compiling a test module)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;VonaConfig.onions&lt;/code&gt; + per-request &lt;code&gt;ctx.onionsDynamic&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Contribution to dependency structure&lt;/td&gt;
&lt;td&gt;Participates in the assembly graph&lt;/td&gt;
&lt;td&gt;Produces no static dependency edges&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In one sentence: NestJS binds a token to an implementation in the &lt;strong&gt;single assembly phase&lt;/strong&gt;; Vona defers "which implementation" to &lt;strong&gt;every resolution&lt;/strong&gt;, so it never has an assembly order that could be broken.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem: One Interface, Many Implementations
&lt;/h2&gt;

&lt;p&gt;First, the shared problem. Business code wants to be written like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// The consumer depends only on the abstraction&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;payService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startPayment&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;stripe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;amount&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It should not care how Stripe's SDK, PayPal's OAuth flow, or the mock's fixtures are implemented, and adding a new payment method should not force a change here.&lt;/p&gt;

&lt;p&gt;The divergence appears at one step: how &lt;code&gt;payService&lt;/code&gt; obtains the &lt;code&gt;stripe&lt;/code&gt; implementation object.&lt;/p&gt;




&lt;h2&gt;
  
  
  NestJS's Answer: Bind During Assembly
&lt;/h2&gt;

&lt;p&gt;NestJS expresses this relationship as a provider definition, most commonly &lt;code&gt;useClass&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// pay.module.ts&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Module&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;provide&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PAY_PROVIDER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;useClass&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;StripePayProvider&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;PAY_PROVIDER&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PayModule&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When several implementations must coexist, &lt;code&gt;multi: true&lt;/code&gt; aggregates them into an array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Module&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;provide&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PAY_PROVIDER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;useClass&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;StripePayProvider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;multi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;provide&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PAY_PROVIDER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;useClass&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PaypalPayProvider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;multi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;provide&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PAY_PROVIDER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;useClass&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;MockPayProvider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;multi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PayModule&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The consumer injects the token and receives the bound instance or array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="nd"&gt;Inject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PAY_PROVIDER&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;pay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IPayProvider&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;useFactory&lt;/code&gt; can also express "pick one by configuration":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;provide&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PAY_PROVIDER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;useFactory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ConfigService&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;PAY_DRIVER&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;paypal&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
      &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PaypalPayProvider&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
      &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;StripePayProvider&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
  &lt;span class="nx"&gt;inject&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;ConfigService&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Key Constraint: Binding Happens Once
&lt;/h3&gt;

&lt;p&gt;Whether you use &lt;code&gt;useClass&lt;/code&gt;, &lt;code&gt;useValue&lt;/code&gt;, or &lt;code&gt;useFactory&lt;/code&gt;, that binding logic runs &lt;strong&gt;once, during module assembly&lt;/strong&gt;: when &lt;code&gt;NestFactory.create()&lt;/code&gt; bootstraps the application, the container resolves every module's providers into instances and wires them, and the same instances are reused for the rest of the process lifetime.&lt;/p&gt;

&lt;p&gt;Three practical consequences follow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The set of implementations is fixed at startup.&lt;/strong&gt; You cannot "register" a new payment implementation at runtime — module assembly is not a runtime behaviour, and the length of a &lt;code&gt;multi: true&lt;/code&gt; array is likewise determined during assembly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Changing the selection at runtime requires a detour.&lt;/strong&gt; Reading config inside &lt;code&gt;useFactory&lt;/code&gt; is fine, but it computes its result during assembly; to change it later you must inject &lt;code&gt;ModuleRef&lt;/code&gt;, wrap a mutable factory object, or make the whole provider request-scoped.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Implementation and module boundaries tend to blur.&lt;/strong&gt; Three payment implementations often end up in the same module's &lt;code&gt;providers&lt;/code&gt; array, so "add a payment method" becomes "edit the existing payment module". Separate modules are possible, but that requires deliberate effort rather than being the framework's default shape.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;overrideProvider(TOKEN).useClass(...)&lt;/code&gt; is available only while compiling a testing module with &lt;code&gt;Test.createTestingModule()&lt;/code&gt;. That is an assembly-time behaviour, not a runtime capability.&lt;/p&gt;




&lt;h2&gt;
  
  
  Vona's Answer: Select at Resolution Time
&lt;/h2&gt;

&lt;p&gt;Vona expresses this relationship as a &lt;strong&gt;scene&lt;/strong&gt;: each business area owns a named provider scene and a matching decorator. For payments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// a-pay/src/lib/payProvider.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PayProvider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createBeanDecorator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;payProvider&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Implementations then live in separate modules, siblings of the domain module:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Area&lt;/th&gt;
&lt;th&gt;Scene&lt;/th&gt;
&lt;th&gt;Implementations (each its own module)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Auth&lt;/td&gt;
&lt;td&gt;&lt;code&gt;authProvider&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;auth-simple&lt;/code&gt;, &lt;code&gt;auth-oauth&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Captcha&lt;/td&gt;
&lt;td&gt;&lt;code&gt;captchaProvider&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;captcha-simple&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pay&lt;/td&gt;
&lt;td&gt;&lt;code&gt;payProvider&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;pay-stripe&lt;/code&gt;, &lt;code&gt;pay-paypal&lt;/code&gt;, &lt;code&gt;pay-mock&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image&lt;/td&gt;
&lt;td&gt;&lt;code&gt;imageProvider&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;image-native&lt;/code&gt;, &lt;code&gt;image-cloudflare&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;File&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fileProvider&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;file-native&lt;/code&gt;, &lt;code&gt;file-cloudflare&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each implementation is simply "a bean registered under a scene":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// pay-stripe/src/bean/payProvider.stripe.ts&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;PayProvider&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PayProviderStripe&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;BeanBase&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;IPayProviderExecute&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;startPayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* Stripe SDK */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What the Consumer Holds Is a Name, Not a Reference
&lt;/h3&gt;

&lt;p&gt;The pay facade obtains implementations by &lt;strong&gt;asking the container for a name&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// a-pay/src/bean/bean.payProvider.ts&lt;/span&gt;
&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;N&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="kr"&gt;keyof&lt;/span&gt; &lt;span class="nx"&gt;IPayProviderRecord&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;providerName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;beanFullName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;beanFullNameFromOnionName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;providerName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;payProvider&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bean&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_getBean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;beanFullName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the name translation is a single string replacement:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// onionName = 'pay-stripe:stripe'&lt;/span&gt;
&lt;span class="c1"&gt;// → beanFullName = 'pay-stripe.payProvider.stripe'&lt;/span&gt;
&lt;span class="nx"&gt;onionName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.payProvider.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So &lt;code&gt;pay-stripe:stripe&lt;/code&gt; becomes a container key only at the &lt;strong&gt;moment of the call&lt;/strong&gt;, and the container resolves the instance on demand. The consuming module never imports any concrete implementation — it knows a name.&lt;/p&gt;

&lt;h3&gt;
  
  
  Selection Happens at Resolution Time, Not Assembly Time
&lt;/h3&gt;

&lt;p&gt;Which implementation is active is decided by three layers, all read &lt;strong&gt;at resolution time&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Configuration — &lt;code&gt;VonaConfig.onions&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Each scene keeps its own enabled entries and options in config, and the framework uses them to decide whether an implementation is usable in the current context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Request scope — &lt;code&gt;ctx.onionsDynamic&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A single request can override the selection, for example to disable one aspect in a test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bean&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;executor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;performAction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;post&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;onions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;interceptor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a-ratelimit:rateLimit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;enable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Scene resolver&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For the captcha scene, a scene can select one provider, rotate across several, or vary the choice by user state and business context.&lt;/p&gt;

&lt;p&gt;On top of that, each implementation carries &lt;code&gt;enable&lt;/code&gt; / &lt;code&gt;match&lt;/code&gt; / &lt;code&gt;ignore&lt;/code&gt; metadata, filtered at resolution time by &lt;code&gt;checkOnionOptionsEnabled()&lt;/code&gt; to decide whether it is active in the current runtime.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Unit of Extension Is a Module
&lt;/h3&gt;

&lt;p&gt;Adding a payment method means adding a module (scaffolded for you): one new implementation registered into the &lt;code&gt;payProvider&lt;/code&gt; scene, with no change to existing implementations or to the consumer.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Comparison: How Binding Timing Decides Everything
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Angle&lt;/th&gt;
&lt;th&gt;NestJS assembly-time binding&lt;/th&gt;
&lt;th&gt;Vona resolution-time selection&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;When the token becomes an implementation&lt;/td&gt;
&lt;td&gt;At module initialization&lt;/td&gt;
&lt;td&gt;On every &lt;code&gt;get()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Who changes when adding the Nth implementation&lt;/td&gt;
&lt;td&gt;Usually the existing module's providers&lt;/td&gt;
&lt;td&gt;A new independent module&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Runtime switching&lt;/td&gt;
&lt;td&gt;Needs &lt;code&gt;ModuleRef&lt;/code&gt; / request scope / mutable factory&lt;/td&gt;
&lt;td&gt;A config entry or a request-level override&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What the consumer holds&lt;/td&gt;
&lt;td&gt;An already-resolved instance&lt;/td&gt;
&lt;td&gt;A name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can an implementation form a dependency cycle with its consumer&lt;/td&gt;
&lt;td&gt;Possible (recursive resolution during assembly)&lt;/td&gt;
&lt;td&gt;No (resolved by name at runtime)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The last row deserves attention. In Vona, the only path from consumer to implementation is &lt;strong&gt;"name → container lookup" at runtime&lt;/strong&gt;: registering the Nth implementation adds &lt;strong&gt;zero edges&lt;/strong&gt; to the dependency structure.&lt;/p&gt;

&lt;p&gt;That is exactly why Vona needs no cycle-breaking mechanism at all: there is no recursive resolution during assembly, and no static edge whose number changes with the number of implementations.&lt;/p&gt;




&lt;h2&gt;
  
  
  When to Use Which
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;When N implementations must coexist and rotate within one request path&lt;/strong&gt; (risk-control strategy chains, notification channel rotation): NestJS's &lt;code&gt;multi&lt;/code&gt; aggregation works well; on the Vona side, a scene resolver takes on "rotate / choose by user state" logic of this kind.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When the implementation is long-lived, replaceable infrastructure&lt;/strong&gt; (payment, storage, captcha, auth methods): Vona's Provider Scene fits better, because each implementation is naturally an independent module and switching is a configuration change rather than an edit to an existing module.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When you only need to swap one dependency in a test&lt;/strong&gt;: NestJS's &lt;code&gt;overrideProvider&lt;/code&gt; is more direct; Vona reaches the same end with a per-request &lt;code&gt;onionsDynamic&lt;/code&gt; or a config override.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Neither model is strictly better: NestJS's assembly-time binding makes relationships explicit and statically checkable; Vona's resolution-time selection makes extension and switching looser. What actually matters is whether &lt;strong&gt;your extension point is determined at startup or variable at runtime&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;NestJS Dynamic Providers and Vona Provider Scene both answer "one interface, many implementations", but they land in different places:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;NestJS binds a token to an implementation &lt;strong&gt;during assembly&lt;/strong&gt; — explicit relationships, but the implementation set and binding result are fixed after startup;&lt;/li&gt;
&lt;li&gt;Vona selects an implementation by name &lt;strong&gt;at resolution&lt;/strong&gt; — the consumer holds only a name, and implementations register as peers in independent modules;&lt;/li&gt;
&lt;li&gt;That difference in timing decides runtime switching, module decoupling, and the more fundamental conclusion about whether an implementation can form a dependency cycle with its consumer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Put another way, Vona did not make Dynamic Providers smarter; it moved the binding later. &lt;strong&gt;As long as the binding happens at resolution time, many implementations cost the dependency structure nothing.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  References and Source Code
&lt;/h2&gt;

&lt;h3&gt;
  
  
  NestJS
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.nestjs.com/fundamentals/custom-providers" rel="noopener noreferrer"&gt;NestJS Providers / Custom Providers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.nestjs.com/fundamentals/circular-dependency" rel="noopener noreferrer"&gt;NestJS Circular Dependency Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  CabloyJS / Vona
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/src/suite-vendor/a-vona/modules/a-onion/src/types/onion.ts" rel="noopener noreferrer"&gt;a-onion scene types (VonaConfig.onions / VonaContext.onionsDynamic)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/src/suite-vendor/a-vona/modules/a-onion/src/bean/bean.onion.ts" rel="noopener noreferrer"&gt;a-onion scene checks and execution&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/src/suite-vendor/a-pay/modules/a-pay/src/bean/bean.payProvider.ts" rel="noopener noreferrer"&gt;a-pay facade: resolving a provider by name&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/src/suite-vendor/a-pay/modules/a-pay/src/lib/payProvider.ts" rel="noopener noreferrer"&gt;a-pay scene decorator definition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/packages-vona/vona-core/src/lib/utils/util.ts" rel="noopener noreferrer"&gt;onionName to bean full name utility&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/packages-vona/vona-core/src/lib/bean/beanContainer.ts" rel="noopener noreferrer"&gt;Vona BeanContainer source code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/repo-docs/backend/captcha-guide.md" rel="noopener noreferrer"&gt;Captcha scene documentation (selection, rotation, context variation)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/repo-docs/backend/file-guide.md" rel="noopener noreferrer"&gt;Built-in file providers and their defaults&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/repo-docs/backend/bean-scene-authoring.md" rel="noopener noreferrer"&gt;Bean scene authoring guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>nestjs</category>
      <category>cabloy</category>
      <category>vona</category>
      <category>dependencyinjection</category>
    </item>
    <item>
      <title>How Cabloy/Vona Avoids NestJS Circular Dependencies: A Source-Code Walkthrough of Lazy Property Injection</title>
      <dc:creator>Uncle Pushui</dc:creator>
      <pubDate>Wed, 14 Oct 2026 02:36:05 +0000</pubDate>
      <link>https://dev.to/uncle-pushui/how-cabloyvona-avoids-nestjs-circular-dependencies-a-source-code-walkthrough-of-lazy-property-4jk5</link>
      <guid>https://dev.to/uncle-pushui/how-cabloyvona-avoids-nestjs-circular-dependencies-a-source-code-walkthrough-of-lazy-property-4jk5</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Circular dependency is not about "can it be resolved?" — it is about "when does resolution happen?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;NestJS circular dependencies are a frequently discussed topic: two Services inject each other through their constructors, and the instantiation moment falls into a "chicken-or-egg" deadlock that can only be broken with &lt;code&gt;forwardRef()&lt;/code&gt;. Cabloy/Vona does not have this problem at the architectural level — not because it implements smarter cycle detection, but because it defers dependency resolution to first access.&lt;/p&gt;

&lt;p&gt;This article uses Cabloy/Vona's &lt;code&gt;BeanContainer&lt;/code&gt; and &lt;code&gt;@Use&lt;/code&gt; decorator source code to break down the complete implementation of lazy property injection.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Short Conclusion
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dimension&lt;/th&gt;
&lt;th&gt;NestJS Constructor Injection&lt;/th&gt;
&lt;th&gt;Vona Lazy Property Injection&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Injection timing&lt;/td&gt;
&lt;td&gt;Synchronous during instantiation&lt;/td&gt;
&lt;td&gt;Deferred to first property access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Circular dependency&lt;/td&gt;
&lt;td&gt;Requires &lt;code&gt;forwardRef()&lt;/code&gt; + deferred cycle resolution&lt;/td&gt;
&lt;td&gt;Naturally safe, no special handling&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Constructor parameters&lt;/td&gt;
&lt;td&gt;Dependencies passed as constructor arguments&lt;/td&gt;
&lt;td&gt;Zero constructor dependencies, only getters&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resolution entry&lt;/td&gt;
&lt;td&gt;Container recursively resolves during &lt;code&gt;resolve()&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Getter triggers container cache lookup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Caching strategy&lt;/td&gt;
&lt;td&gt;Stored in container after instantiation&lt;/td&gt;
&lt;td&gt;Entered into container cache before &lt;code&gt;__init__&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In one sentence: NestJS is "inject at construction time, resolve eagerly" — cycles deadlock during instantiation. Vona is "register at declaration time, resolve on access" — the instantiation phase never touches dependencies, and circular dependencies are dissolved by timing.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Root of NestJS Circular Dependencies
&lt;/h2&gt;

&lt;p&gt;First, let us understand where NestJS's problem lies.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Timing Dilemma of Constructor Injection
&lt;/h3&gt;

&lt;p&gt;NestJS dependency injection happens during the constructor phase. When the container resolves &lt;code&gt;A&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Injectable&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ServiceA&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ServiceB&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;  &lt;span class="c1"&gt;// Constructor parameter = dependency&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The container needs to create &lt;code&gt;B&lt;/code&gt; before it can create &lt;code&gt;A&lt;/code&gt;. But if &lt;code&gt;B&lt;/code&gt;'s constructor also depends on &lt;code&gt;A&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Injectable&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ServiceB&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ServiceA&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The resolution chain becomes: &lt;code&gt;new A()&lt;/code&gt; → needs &lt;code&gt;B&lt;/code&gt; → &lt;code&gt;new B()&lt;/code&gt; → needs &lt;code&gt;A&lt;/code&gt; → &lt;code&gt;A&lt;/code&gt; is not yet constructed → deadlock.&lt;/p&gt;

&lt;h3&gt;
  
  
  forwardRef Is a Workaround, Not an Elimination
&lt;/h3&gt;

&lt;p&gt;NestJS uses &lt;code&gt;forwardRef()&lt;/code&gt; and &lt;code&gt;InjectionToken&lt;/code&gt; to defer the resolution order, letting one side complete instantiation first, then injecting the other side afterward. But this is merely a workaround:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Developers must manually identify cycles and annotate with &lt;code&gt;forwardRef&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;Over-long cycle chains may still encounter "instance not ready" problems;&lt;/li&gt;
&lt;li&gt;It adds implicit complexity to the code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Vona's design chose a different path: it does not give circular dependencies any opportunity to arise in the first place.&lt;/p&gt;




&lt;h2&gt;
  
  
  Vona's Three Lines of Defense
&lt;/h2&gt;

&lt;p&gt;Vona structurally does not have an "instantiation-phase" circular dependency problem. The core difference is that dependency resolution is moved from &lt;strong&gt;instantiation time&lt;/strong&gt; to &lt;strong&gt;first access time&lt;/strong&gt;. Three mechanisms ensure this:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. No Constructor Injection
&lt;/h3&gt;

&lt;p&gt;Vona's Service/Bean always extends &lt;code&gt;BeanBase&lt;/code&gt;, and the constructor accepts no dependencies. After instance creation, the container fills in &lt;code&gt;app&lt;/code&gt; / &lt;code&gt;ctx&lt;/code&gt; references, and dependencies are declared on properties via the &lt;code&gt;@Use(...)&lt;/code&gt; decorator.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Lazy Property Injection (the Key Mechanism)
&lt;/h3&gt;

&lt;p&gt;Dependencies declared with &lt;code&gt;@Use&lt;/code&gt; are not injected at Bean creation time. Instead, a getter is installed using &lt;code&gt;Object.defineProperty&lt;/code&gt;. On first property access, the getter resolves the target Bean from the container and caches the result.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Container Itself Is Runtime Lookup
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;BeanContainer.create&lt;/code&gt; returns a lazy Proxy. &lt;code&gt;this.bean.xxxService&lt;/code&gt;, &lt;code&gt;this.scope('module-x')&lt;/code&gt; all resolve from the container by bean full name at access time, producing no static wiring.&lt;/p&gt;




&lt;h2&gt;
  
  
  Source Code Breakdown: Five Stages
&lt;/h2&gt;

&lt;p&gt;Below, we break down the source code across five stages: declaration → storage → mounting → resolution → caching.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage 1: Declaration — &lt;code&gt;@Use&lt;/code&gt; Decorator Does Only Two Things
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// use.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;IDecoratorUseOptions&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;PropertyDecorator&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;MethodDecorator&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;MetadataKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;descriptor&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;PropertyDescriptor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// ① Read property type from TS design:type metadata&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;beanClass&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;appMetadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getDesignType&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;Constructable&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// ② Class → bean full name mapping&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;beanFullName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;beanFullName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;beanFullName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;beanFullName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;appResource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBeanFullName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;beanClass&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// ③ Register metadata — no instantiation happens here&lt;/span&gt;
    &lt;span class="nx"&gt;appResource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addUse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;beanFullName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;descriptor&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;It reads the property type from the &lt;code&gt;design:type&lt;/code&gt; metadata generated by TypeScript's &lt;code&gt;emitDecoratorMetadata&lt;/code&gt;, so &lt;code&gt;@Use()&lt;/code&gt; without arguments can still determine the target Bean;&lt;/li&gt;
&lt;li&gt;The class → bean full name (&lt;code&gt;module-name.scene.name&lt;/code&gt;) mapping must exist, otherwise it throws directly;&lt;/li&gt;
&lt;li&gt;It calls &lt;code&gt;appResource.addUse&lt;/code&gt; to register metadata — &lt;strong&gt;no instantiation occurs&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Stage 2: Storage — Metadata Map Keyed by Property Name, Inherited Along the Prototype Chain
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// resource.ts&lt;/span&gt;
&lt;span class="nf"&gt;addUse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IDecoratorUseOptionsBase&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;registerMappedClassMetadataKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;SymbolDecoratorUse&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;uses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;appMetadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getOwnMetadataMap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;SymbolDecoratorUse&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;getUses&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MetadataKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;IDecoratorUseOptionsBase&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;appMetadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getMetadata&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SymbolDecoratorUse&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// Note: getMetadata&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Writing uses &lt;code&gt;getOwnMetadataMap&lt;/code&gt; (attached to the class prototype, keyed by &lt;code&gt;prop&lt;/code&gt;), reading uses &lt;code&gt;getMetadata&lt;/code&gt; (traverses up the prototype chain) — this means &lt;strong&gt;subclasses automatically inherit all &lt;code&gt;@Use&lt;/code&gt; dependencies declared by the parent class&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage 3: Mounting — Only Install Getter After Instantiation, No Resolution
&lt;/h3&gt;

&lt;p&gt;The strict ordering in the Bean instance creation flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// beanContainer.ts&lt;/span&gt;
&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;_createBeanInstance&lt;/span&gt;&lt;span class="p"&gt;(...)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;beanInstance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_prepareBeanInstance&lt;/span&gt;&lt;span class="p"&gt;(...);&lt;/span&gt;          &lt;span class="c1"&gt;// new + attach app/ctx&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;SymbolBeanContainerInstances&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;beanInstance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c1"&gt;// ① Enter container cache first&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_initBeanInstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;beanFullName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;beanInstance&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;     &lt;span class="c1"&gt;// ② Inject getter → __init__&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ordering ensures: even if a Bean accesses a dependency property during &lt;code&gt;__init__&lt;/code&gt;, triggering reverse resolution, the container can directly hit the cache and return the already-registered instance.&lt;/p&gt;

&lt;p&gt;The core implementation of injection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// beanContainer.ts&lt;/span&gt;
&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;_injectBeanInstancePropLazy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;beanInstance&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;targetBeanFullName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useOptions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;defineProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;beanInstance&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;enumerable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;        &lt;span class="c1"&gt;// Property is enumerable (visible in serialization/spread)&lt;/span&gt;
    &lt;span class="na"&gt;configurable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;      &lt;span class="c1"&gt;// Redefinable for HMR&lt;/span&gt;
    &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;beanInstance&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;SymbolBeanInstancePropsLazy&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="nx"&gt;beanInstance&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;SymbolBeanInstancePropsLazy&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;beanInstance&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;SymbolBeanInstancePropsLazy&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// First access: actually resolve, then cache to instance-private slot&lt;/span&gt;
        &lt;span class="nx"&gt;beanInstance&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;SymbolBeanInstancePropsLazy&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
          &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_injectBeanInstanceProp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;beanInstance&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;targetBeanFullName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useOptions&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="c1"&gt;// App-level container additionally registers this dependency edge to HMR&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;containerType&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
          &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hmr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addBeanInstanceProp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;beanInstance&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;targetBeanFullName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;beanInstance&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;SymbolBeanInstancePropsLazy&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three implementation highlights:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The getter closure captures the container that installed it&lt;/strong&gt; (&lt;code&gt;self&lt;/code&gt;) — properties installed by the app container always go through app resolution, while those installed by the ctx (request-level) container go through ctx resolution;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The cache slot is an instance-level plain object&lt;/strong&gt; &lt;code&gt;SymbolBeanInstancePropsLazy&lt;/code&gt; — after first access, the property degrades to "pseudo-static" with zero lookup cost thereafter;&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;enumerable: true / configurable: true&lt;/code&gt; combination is deliberate: enumerable ensures consistent instance export behavior, configurable lets HMR tear down and reinstall.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Stage 4: Resolution — Three Injection Scopes
&lt;/h3&gt;

&lt;p&gt;First access triggers &lt;code&gt;_injectBeanInstanceProp&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// beanContainer.ts&lt;/span&gt;
&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;_injectBeanInstanceProp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;beanInstance&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;targetBeanFullName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;useOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IDecoratorUseOptionsBase&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;injectionScope&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;injectionScope&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;injectionScope&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;targetInstance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bean&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_getBeanSelectorInner&lt;/span&gt;&lt;span class="p"&gt;(...);&lt;/span&gt;  &lt;span class="c1"&gt;// Application-level singleton&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;injectionScope&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ctx&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;targetInstance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_getBeanSelectorInner&lt;/span&gt;&lt;span class="p"&gt;(...);&lt;/span&gt;           &lt;span class="c1"&gt;// Request-level singleton&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;injectionScope&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;new&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;targetInstance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_newBeanInner&lt;/span&gt;&lt;span class="p"&gt;(...);&lt;/span&gt;                   &lt;span class="c1"&gt;// New instance each time&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;targetInstance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;'app'&lt;/code&gt; / &lt;code&gt;'ctx'&lt;/code&gt; fall into &lt;code&gt;_getBeanSelectorInner&lt;/code&gt;: the container instance cache key is &lt;code&gt;beanFullName&lt;/code&gt; or &lt;code&gt;beanFullName#selector&lt;/code&gt;, creating only if &lt;code&gt;=== undefined&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;'new'&lt;/code&gt; creates a new instance each time, but since the outer getter already caches, &lt;strong&gt;only one resolution happens per property lifecycle&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;The selector parameter is taken from three sources by priority: the decorated property's descriptor getter → &lt;code&gt;useOptions.init&lt;/code&gt; static parameters → &lt;code&gt;useOptions.selector&lt;/code&gt; string expression (evaluation context includes &lt;code&gt;self/app/ctx&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Stage 5: Caching — Container Instance Cache
&lt;/h3&gt;

&lt;p&gt;The caching logic of &lt;code&gt;_getBeanSelectorInner&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// beanContainer.ts&lt;/span&gt;
&lt;span class="nx"&gt;_getBeanSelectorInner&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;beanFullName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Constructable&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;withSelector&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;
&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;beanOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;appResource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;beanFullName&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fullName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;beanOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;beanFullName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;__getSelectorKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fullName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;withSelector&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;SymbolBeanContainerInstances&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_newBeanInner&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fullName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;withSelector&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;SymbolBeanContainerInstances&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cache key generation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;__getSelectorKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;beanFullName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;withSelector&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;withSelector&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;beanFullName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isSelectorValid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;isNilOrEmptyString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;isSelectorValid&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;beanFullName&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;beanFullName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Complete Timing of A↔B Circular Dependency
&lt;/h2&gt;

&lt;p&gt;Using two Services A and B that &lt;code&gt;@Use&lt;/code&gt; each other as an example, here is the complete timing:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Moment&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Declaration&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;@Use&lt;/code&gt; registers A→B, B→A mappings&lt;/td&gt;
&lt;td&gt;No instance interaction&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Business triggers &lt;code&gt;_getBean('A')&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;new A()&lt;/code&gt;, install lazy getter, enter container cache&lt;/td&gt;
&lt;td&gt;A fully exists&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First access &lt;code&gt;a.serviceB&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Getter executes → container creates B (B's construction and getter installation also do not touch A), enters cache&lt;/td&gt;
&lt;td&gt;B fully exists&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B internally accesses &lt;code&gt;b.serviceA&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Getter executes → container cache hit → returns existing A&lt;/td&gt;
&lt;td&gt;Cycle closes, no reentrance&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two invariants guarantee cycle safety:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Getters never execute during the instantiation phase&lt;/strong&gt; (no mutual touching);&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The dependency target is guaranteed to be registered in the container cache at resolution time&lt;/strong&gt; (the "enter cache before init" ordering covers even the aggressive case of accessing dependencies during &lt;code&gt;__init__&lt;/code&gt;).&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Real Code Example
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Vona's &lt;code&gt;@Use&lt;/code&gt; Usage
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;BeanBase&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Use&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zova&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Service&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zova-module-a-bean&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BeanRouter&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;BeanBase&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="nx"&gt;$$sysRouter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SysRouter&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="nx"&gt;$$modelPageData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ModelPageData&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: zero constructor parameters; all dependencies are declared on properties via &lt;code&gt;@Use&lt;/code&gt;. Resolution is triggered only when &lt;code&gt;this.$$sysRouter&lt;/code&gt; is accessed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Equivalent Path in Vona Backend Business Code
&lt;/h3&gt;

&lt;p&gt;In the current repository, backend business code more commonly uses &lt;code&gt;this.scope('module-x').service.yyy&lt;/code&gt; and &lt;code&gt;this.bean.xxx&lt;/code&gt; instead of property-level &lt;code&gt;@Use&lt;/code&gt; — these go through the same container's runtime lookup path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// BeanContainer.create returns a Proxy&lt;/span&gt;
&lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;VonaApplication&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;VonaContext&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;beanContainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BeanContainer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Proxy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;beanContainer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;prop&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;symbol&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_getBean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// Resolves on access&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is essentially the "method-call version" of the same lazy resolution mechanism. The two paths differ only in declaration style (decorator metadata vs string lookup); the resolution and caching mechanisms are fully shared.&lt;/p&gt;




&lt;h2&gt;
  
  
  Failure Boundary and HMR
&lt;/h2&gt;

&lt;p&gt;Lazy property injection is not without boundaries to be aware of:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;_removeBean&lt;/code&gt; only destroys the instance in the container cache and calls its &lt;code&gt;__dispose__&lt;/code&gt;; the cached reference in other Bean instances' &lt;code&gt;SymbolBeanInstancePropsLazy&lt;/code&gt; is not automatically cleared — this is exactly why HMR needs &lt;code&gt;addBeanInstanceProp&lt;/code&gt; to register dependency edges for rewiring.&lt;/p&gt;

&lt;p&gt;So in hot-reload scenarios, the framework can use the registered dependency edges to find all properties that reference the replaced Bean, tear down old getters, install new ones, clear cache slots, and complete dependency rewiring.&lt;/p&gt;




&lt;h2&gt;
  
  
  Module-Level Circular Dependencies
&lt;/h2&gt;

&lt;p&gt;Beyond instance-level circular dependencies, Vona also makes design-level provisions at the module level. Per the documentation:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Using &lt;code&gt;this.$scope.&amp;lt;fixedModule&amp;gt;&lt;/code&gt;, &lt;code&gt;app.scope(...)&lt;/code&gt;, or &lt;code&gt;this.app.scope(...)&lt;/code&gt; does not by itself require adding the target module to the caller's &lt;code&gt;vonaModule.dependencies&lt;/code&gt;. Lookup does not create a module dependency edge, so lookup alone cannot create a circular dependency.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This means module-level circular dependencies are also avoided by design: cross-module lookups do not produce dependency declarations and do not constitute module dependency edges, so modules cannot form circular dependencies merely by "using each other's services."&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The root cause of NestJS's circular dependency problem lies in its design choice of "constructor injection + eager resolution": dependencies must be resolved at instantiation time, circular references inevitably lead to deadlock, and &lt;code&gt;forwardRef&lt;/code&gt; can only defer the resolution order.&lt;/p&gt;

&lt;p&gt;Vona's lazy property injection mechanism dissolves this problem through three design decisions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Zero constructor dependencies&lt;/strong&gt; — the instantiation phase touches no dependencies;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lazy property getter&lt;/strong&gt; — dependency resolution is deferred to first access;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enter cache before init&lt;/strong&gt; — guarantees the dependency target is always ready at resolution time.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Circular dependencies in Vona require no &lt;code&gt;forwardRef&lt;/code&gt;, no special annotation, no developer identification of cycles — they are naturally safe by timing. This is not smarter cycle detection; it is an architectural choice that gives circular dependencies no opportunity to arise.&lt;/p&gt;




&lt;h2&gt;
  
  
  References and Source Code
&lt;/h2&gt;

&lt;h3&gt;
  
  
  NestJS
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.nestjs.com/fundamentals/circular-dependency" rel="noopener noreferrer"&gt;NestJS Circular Dependency Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/nestjs/nest/blob/master/packages/common/index.ts" rel="noopener noreferrer"&gt;NestJS &lt;code&gt;forwardRef&lt;/code&gt; Source Code&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  CabloyJS / Vona
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/packages-vona/vona-core/src/lib/bean/beanContainer.ts" rel="noopener noreferrer"&gt;Vona BeanContainer Source Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/packages-vona/vona-core/src/lib/decorator/class/use.ts" rel="noopener noreferrer"&gt;Vona &lt;code&gt;@Use&lt;/code&gt; Decorator Source Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cabloy/cabloy/blob/main/vona/packages-vona/vona-core/src/lib/core/resource.ts" rel="noopener noreferrer"&gt;Vona AppResource Source Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/backend/foundation" rel="noopener noreferrer"&gt;Vona Foundation Documentation: Module Scope and Dependencies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/backend/module-dependencies" rel="noopener noreferrer"&gt;Vona Module Dependencies Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>nestjs</category>
      <category>dependencyinjection</category>
      <category>circulardependency</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Inside Cabloy's Dual-Engine Architecture: How Vona and Zova Work Together</title>
      <dc:creator>Uncle Pushui</dc:creator>
      <pubDate>Sun, 11 Oct 2026 14:43:33 +0000</pubDate>
      <link>https://dev.to/uncle-pushui/inside-cabloys-dual-engine-architecture-how-vona-and-zova-work-together-fn0</link>
      <guid>https://dev.to/uncle-pushui/inside-cabloys-dual-engine-architecture-how-vona-and-zova-work-together-fn0</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Vona provides the backend framework and runtime; Zova provides the frontend framework and application layer. They are not a "backend folder + frontend folder" inside one big package. They are two engines that evolve independently, meshed together by &lt;strong&gt;generated artifacts&lt;/strong&gt;, &lt;strong&gt;runtime integration&lt;/strong&gt;, and &lt;strong&gt;bidirectional type contracts&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The first thing people notice when opening the Cabloy repository is usually the two large top-level directories: &lt;code&gt;vona/&lt;/code&gt; and &lt;code&gt;zova/&lt;/code&gt;. Each has its own &lt;code&gt;package.json&lt;/code&gt;, CLI, and workspace configuration, and each even carries its own &lt;code&gt;__CABLOY_BASIC__&lt;/code&gt; edition marker. This is not simply a "backend directory plus frontend directory" — it is the core design of Cabloy's fullstack architecture: &lt;strong&gt;one fullstack system, two engines&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This article walks through that dual-engine architecture end to end, using the Cabloy Basic repository (version 5.1.202, MIT licensed) as the baseline.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Big Picture First
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                     ┌──────────────────────────────────────────┐
   Browser  ───────▶ │  Vona (backend runtime, Koa, port 7102)  │
                     │   ├─ SSR Site dispatch (Web/Admin/...)   │
                     │   └─ Renders with Zova-built SSR output  │
                     └───────────▲──────────────────┬───────────┘
       Frontend metadata         │                  │  OpenAPI contracts
       (routes/components/icons) │                  ▼  flow downstream
                     ┌───────────┴──────────────────────────────┐
                     │  Zova (frontend, Vue3 + Vite + TSX)      │
                     │  Standalone SSR dev server (port 9000)   │
                     └──────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key principle: frontend and backend concerns are separated and can evolve independently — but they do not collaborate by hand-copying interfaces or manually copying build files. They collaborate through generated artifacts, runtime integration, and shared conventions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Backend technology base: Koa, Knex, Redis, and multiple database drivers (CI covers MySQL and PostgreSQL)&lt;/li&gt;
&lt;li&gt;Frontend technology base: Vue, Vite, the Quasar toolchain, and TanStack libraries&lt;/li&gt;
&lt;li&gt;Edition UI layer: Cabloy Basic uses DaisyUI + Tailwind CSS; Cabloy Start uses Vuetify. Quasar is part of the engineering toolchain, not the edition's UI component library&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Part 1. Vona: The Backend Engine
&lt;/h2&gt;

&lt;p&gt;Vona is the backend half of Cabloy. Its goal is to support SSR, SPA, Web, and Admin experiences within one system while keeping frontend and backend decoupled enough to evolve independently.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. IoC Containers and the Bean System
&lt;/h3&gt;

&lt;p&gt;Every capability in Vona is organized as a framework-managed &lt;strong&gt;Bean&lt;/strong&gt;. All Beans inherit from &lt;code&gt;BeanBase&lt;/code&gt;, whose working surface already includes &lt;code&gt;app&lt;/code&gt;, &lt;code&gt;ctx&lt;/code&gt;, &lt;code&gt;bean&lt;/code&gt;, &lt;code&gt;scope&lt;/code&gt;, &lt;code&gt;$scope&lt;/code&gt;, &lt;code&gt;$logger&lt;/code&gt;, &lt;code&gt;$loggerChild&lt;/code&gt;, &lt;code&gt;$text&lt;/code&gt;, and more — business code never needs to reassemble these access points by hand.&lt;/p&gt;

&lt;p&gt;There are two container levels:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Container&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;app container&lt;/td&gt;
&lt;td&gt;Global backend Beans (singleton-style)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ctx container&lt;/td&gt;
&lt;td&gt;Request-scoped Beans&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A Bean has three forms of identity, and naming is not a style preference — it directly affects injection, config override paths, and how the CLI organizes generated code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bean identifier&lt;/strong&gt;: &lt;code&gt;{moduleName}.{sceneName}.{beanName}&lt;/code&gt;, e.g. &lt;code&gt;training-student.service.student&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Onion name&lt;/strong&gt;: &lt;code&gt;{moduleName}:{beanName}&lt;/code&gt;, e.g. &lt;code&gt;training-student:student&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bean scene&lt;/strong&gt;: the operational family a Bean belongs to — service, model, entity, dto, controller, startup, queue, broadcast, and so on. The built-in global &lt;code&gt;bean&lt;/code&gt; scene is a deliberate exception with a plain shorthand surface&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are four styles of accessing a Bean:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Access style&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;th&gt;Representative shape&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Dependency injection&lt;/td&gt;
&lt;td&gt;Explicit wiring in a class&lt;/td&gt;
&lt;td&gt;&lt;code&gt;@Use('training-student.service.student') serviceStudent&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dependency lookup (the recommended concise default)&lt;/td&gt;
&lt;td&gt;Ordinary module business code&lt;/td&gt;
&lt;td&gt;&lt;code&gt;this.scope.service.student.findOne()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Direct bean access&lt;/td&gt;
&lt;td&gt;Container-level control&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;this.bean._getBean(...)&lt;/code&gt; / &lt;code&gt;this.ctx.bean._getBean(...)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fresh bean creation&lt;/td&gt;
&lt;td&gt;Flows that must not reuse the default instance&lt;/td&gt;
&lt;td&gt;&lt;code&gt;this.bean._newBean(...)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Note that &lt;code&gt;this.bean._getBean(...)&lt;/code&gt; goes through the app-level container, while &lt;code&gt;this.ctx.bean._getBean(...)&lt;/code&gt; goes through the request-scoped container.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Scope: The Module Resource Facade
&lt;/h3&gt;

&lt;p&gt;The reason Vona backend code stays concise instead of degrading into arbitrary-path imports everywhere is &lt;strong&gt;Scope&lt;/strong&gt;. Each module's service, model, entity, config, constant, locale, and error resources all hang behind one structured facade:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Resources of the current module&lt;/span&gt;
&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stockBalance&lt;/span&gt;

&lt;span class="c1"&gt;// A cross-module resource statically known in source&lt;/span&gt;
&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$scope&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;commerceCatalog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sku&lt;/span&gt;

&lt;span class="c1"&gt;// In tests or standalone scripts, where you hold an app reference&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;commerce-catalog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sku&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One important design decision: &lt;strong&gt;Scope lookup does not create a module dependency edge&lt;/strong&gt;. &lt;code&gt;this.$scope.xxx&lt;/code&gt; merely resolves a resource from the module set already composed into the application; it neither installs nor loads the target module, and it cannot cause circular dependencies. Only when you genuinely need availability guarantees, dependency-first ordering, or a minimum compatible version do you declare &lt;code&gt;vonaModule.dependencies&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. AOP and the Structured Request Pipeline
&lt;/h3&gt;

&lt;p&gt;Vona provides AOP across three aspect families — controller, internal, and external — plus a structured request path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;middleware → guard → interceptor → pipe (Zod validation) → filter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;@Core.transaction(...)&lt;/code&gt; and &lt;code&gt;@Core.retryable(...)&lt;/code&gt; decorators you see in everyday development are both applications of this AOP:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@Core.transaction(...)&lt;/code&gt; defaults to &lt;code&gt;REQUIRED&lt;/code&gt; propagation: start a transaction if none exists, otherwise join the current one; never escalate isolation casually. Use &lt;code&gt;REQUIRES_NEW&lt;/code&gt; only when an independently committed boundary is explicitly required&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Core.retryable(...)&lt;/code&gt; retries only safely replayable transient failures through an explicit &lt;code&gt;errorCodes&lt;/code&gt; allowlist. It retries the downstream AOP suffix and never blindly retries external side effects&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Contracts and the Data Layer: Source of Truth for the Forward Chain
&lt;/h3&gt;

&lt;p&gt;The main backend request-handling chain is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Controller → Service → Model → Entity
             (DTO inference/generation + Zod validation)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Controller, DTO, and Zod schemas — together with decorator metadata such as &lt;code&gt;@Api.field(...)&lt;/code&gt; — ultimately produce the &lt;strong&gt;OpenAPI document&lt;/strong&gt;. That OpenAPI output is the single source of contract truth for frontend SDK generation, which becomes crucial in the contract loop below.&lt;/p&gt;

&lt;p&gt;Vona also ships a broad set of long-term capabilities: CRUD-oriented workflows, multi-tenancy (a tenant is an instance; ordinary resource CRUD is automatically instance-scoped), multi-database/multi-datasource with sharding, two-layer caching (including the cross-Model &lt;code&gt;modelsClear&lt;/code&gt; / &lt;code&gt;modelsClearedBy&lt;/code&gt; dependency graph), transactions, authentication/captcha/RBAC/menus, file and image uploads, mail, queues, workers, schedules, election, broadcast, Redlock, WebSocket, metrics, and telemetry.&lt;/p&gt;

&lt;p&gt;In terms of code organization, the framework core lives in &lt;code&gt;vona/packages-vona/&lt;/code&gt;, the CLI in &lt;code&gt;vona/packages-cli/cli/&lt;/code&gt;, and business code in &lt;code&gt;vona/src/suite/&lt;/code&gt; and &lt;code&gt;vona/src/module/&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 2. Zova: The Frontend Engine
&lt;/h2&gt;

&lt;p&gt;Zova is the frontend half of Cabloy. It combines the strengths of three mature frameworks: &lt;strong&gt;Vue3 reactivity, React-style TSX rendering, and Angular-style IoC&lt;/strong&gt;. When reading Zova code, do not degrade it into "plain Vue plus a pile of utilities" — enter through its controller / bean / IoC architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Three IoC Containers Unify All State Sharing
&lt;/h3&gt;

&lt;p&gt;Many Vue 3 projects mix component-local state, composables, provide/inject, and Pinia depending on where state must be shared. Zova asks a different first question: &lt;strong&gt;which Bean owns this state or behavior, and which container scope should own that Bean?&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Container&lt;/th&gt;
&lt;th&gt;Scope&lt;/th&gt;
&lt;th&gt;Rough Vue-world equivalent&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;sys&lt;/td&gt;
&lt;td&gt;System-wide singleton; survives across SSR requests&lt;/td&gt;
&lt;td&gt;Module-level singletons / global long-lived state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;app&lt;/td&gt;
&lt;td&gt;Application / request level&lt;/td&gt;
&lt;td&gt;App stores, globally provided state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ctx&lt;/td&gt;
&lt;td&gt;Component-instance local&lt;/td&gt;
&lt;td&gt;Component-local state, in-component composables&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The four typical sharing scopes therefore all fold into one model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ControllerPage&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="nx"&gt;$$localCounterState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CounterState&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                          &lt;span class="c1"&gt;// within a component&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;injectionScope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;host&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="nx"&gt;$$hostCounterState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CounterState&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// between components (hierarchical injection)&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;injectionScope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;  &lt;span class="nx"&gt;$$appCounterState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CounterState&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// app-global&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;injectionScope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sys&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;  &lt;span class="nx"&gt;$$sysCounterState&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CounterState&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// system-level&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under SSR, the distinction between &lt;code&gt;app&lt;/code&gt; and &lt;code&gt;sys&lt;/code&gt; is especially critical: app-level behavior can bind to a single application instance or a single request, while sys-level behavior is not request-bound and survives across SSR requests.&lt;/p&gt;

&lt;p&gt;All Beans likewise inherit from &lt;code&gt;BeanBase&lt;/code&gt;, whose core members include &lt;code&gt;sys&lt;/code&gt;, &lt;code&gt;app&lt;/code&gt;, &lt;code&gt;ctx&lt;/code&gt;, &lt;code&gt;bean&lt;/code&gt;, &lt;code&gt;scope&lt;/code&gt;, &lt;code&gt;$el&lt;/code&gt;, and &lt;code&gt;$event&lt;/code&gt;; SSR modules extend it with &lt;code&gt;$ssr&lt;/code&gt; and &lt;code&gt;$useMeta&lt;/code&gt;, page-controller bases provide &lt;code&gt;$params&lt;/code&gt; and &lt;code&gt;$query&lt;/code&gt;, and component-controller bases provide &lt;code&gt;$props&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Controller / Page / Component: TSX Rendering
&lt;/h3&gt;

&lt;p&gt;Every Zova page and component has a &lt;strong&gt;controller bean&lt;/strong&gt; as its logic carrier, with rendering described in TSX. The surrounding frontend engineering capabilities include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a-router routing: routes with dynamic &lt;code&gt;params&lt;/code&gt; must explicitly define &lt;code&gt;route.name&lt;/code&gt;; static routes generate canonical URLs via &lt;code&gt;$router.getPagePath(...)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Page meta code generation&lt;/li&gt;
&lt;li&gt;Two-layer tabs navigation, router stack, routed dialog&lt;/li&gt;
&lt;li&gt;Explicit &lt;code&gt;requiresAuth&lt;/code&gt; and &lt;code&gt;ssrProfile&lt;/code&gt; declarations (Web defaults to &lt;code&gt;public&lt;/code&gt;; cookie-backed or protected first paint uses &lt;code&gt;session&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Unified State Management with Models and ModelResource
&lt;/h3&gt;

&lt;p&gt;Async state that drives rendering is owned by Models, not scattered across fetch/cache variables in individual controllers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Establish query state during render with &lt;code&gt;$useStateData(...)&lt;/code&gt;, and read the reactive surface owned by the current query (&lt;code&gt;query.data&lt;/code&gt; or a model-derived projection)&lt;/li&gt;
&lt;li&gt;Resource-style business data is owned by a &lt;strong&gt;ModelResource&lt;/strong&gt;, which uniformly handles queries, caching, and mutations; &lt;code&gt;$apiSchema&lt;/code&gt; or the owning resource's schema directly drives automatic rendering of ZForm and ZTable&lt;/li&gt;
&lt;li&gt;Only low-reuse, one-off page actions that need no shared state or cache ownership may call the generated &lt;code&gt;$api&lt;/code&gt; directly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The purpose of these rules is clear: there is exactly one copy of schema metadata (on the backend); the frontend neither duplicates schemas nor hand-edits generated code.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Multi-Flavor Output: One Codebase, Many SSR Sites
&lt;/h3&gt;

&lt;p&gt;The same Zova business source code can be built into multiple flavors (i.e., SSR Sites). The actual build artifacts in this repository (&lt;code&gt;zova/dist/&lt;/code&gt;) include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ssr-cabloyBasicWeb&lt;/code&gt; / &lt;code&gt;ssr-cabloyBasicAdmin&lt;/code&gt;: the Web and Admin sites of Cabloy Basic&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ssr-cabloyCommerce&lt;/code&gt; / &lt;code&gt;ssr-cabloyCommerceAdmin&lt;/code&gt;: the e-commerce demo sites&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rest-cabloyBasicWeb&lt;/code&gt; and other rest artifacts: frontend metadata and type packages consumed by Vona&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each flavor has its own env files (&lt;code&gt;zova/env/.env.*&lt;/code&gt;), and at build time the SSR bundle and rest output must be produced as a pair and moved together.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 3. How the Two Engines Mesh: Two Channels
&lt;/h2&gt;

&lt;p&gt;Between Vona and Zova there are two channels of an entirely different nature.&lt;/p&gt;

&lt;h3&gt;
  
  
  Channel 1: Vona Integrated SSR (the Runtime Channel)
&lt;/h3&gt;

&lt;p&gt;The same frontend SSR application has two entry points during development. The difference is not "whether it is SSR" but &lt;strong&gt;who receives the browser request and owns the response&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Vona integrated SSR:   Browser → Vona(7102) → SSR Site matching → Zova build artifacts → browser hydration
Zova standalone SSR:   Browser → Zova dev server(9000) → frontend SSR (APIs still point to Vona)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;npm run dev&lt;/code&gt; starts Vona integrated SSR: Web entry &lt;code&gt;http://localhost:7102/&lt;/code&gt;, Admin entry &lt;code&gt;http://localhost:7102/admin/&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;npm run dev:zova:web&lt;/code&gt; / &lt;code&gt;npm run dev:zova:admin&lt;/code&gt; start Zova standalone SSR (port 9000 by default) for fast hot-reload iteration on pages, routes, and hydration&lt;/li&gt;
&lt;li&gt;Opening port 9000 directly &lt;strong&gt;cannot replace&lt;/strong&gt; integrated acceptance at 7102: it bypasses Vona's SSR Site dispatch and the built-artifact handoff&lt;/li&gt;
&lt;li&gt;The release/acceptance path is: build the SSR and rest artifacts → sync them into Vona with &lt;code&gt;npm run deps:vona&lt;/code&gt; → run full acceptance from the Vona entry&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that "standalone" only means you can open the Zova development server directly; it does not mean it is an independently deployable SSR application. Adding a mountable site requires a matching flavor, a paired set of SSR/rest artifacts, and an &lt;code&gt;@SsrSite&lt;/code&gt; registration on the Vona side.&lt;/p&gt;

&lt;h3&gt;
  
  
  Channel 2: The Bidirectional Contract Loop (the Type and Codegen Channel)
&lt;/h3&gt;

&lt;p&gt;Type information flows in both directions, and each side has its own source of truth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forward chain (backend → frontend)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Controller / DTO / Zod (contract truth)
        │  Vona emits OpenAPI
        ▼
Zova generates SDK ($api) and schema helpers ($apiSchema)
        │  generated code must never be hand-edited
        ▼
Frontend adds only thin semantic wrappers, reusing the same resource owner
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When changing a backend contract, change the backend truth first, then regenerate the frontend consumers — never hand-patch generated files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reverse chain (frontend → backend)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Zova's route, component, and icon metadata is the truth; after building, it flows back into Vona's tooling and type hints. The correct order is to build Zova first, then sync dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run build:zova:admin   &lt;span class="c"&gt;# Admin-side changes&lt;/span&gt;
npm run build:zova:web     &lt;span class="c"&gt;# also required when the Web flavor is affected — SSR bundle and rest must move as a pair&lt;/span&gt;
npm run deps:vona          &lt;span class="c"&gt;# then sync the .zova-rest artifacts into Vona&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The contract loop also has two typical exception branches, handled in entirely different ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Consumer drift&lt;/strong&gt;: fixed by regenerating; do not hand-edit generated output&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local dependency drift&lt;/strong&gt;: the &lt;code&gt;.zova-rest&lt;/code&gt; artifacts already contain the expected changes, but Vona-side types remain stale — delete &lt;code&gt;vona/node_modules&lt;/code&gt; and reinstall dependencies instead of continuing to debug or hand-patching dependency links&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The repository itself also wires a contract-loop-gate into git hooks, which automatically checks whether this chain has been broken at commit time. That means the "bidirectional contract" is not a documentation slogan — it is a workflow enforced by engineering guardrails.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 4. The Shared Organizational Skeleton: Suite / Module / Package
&lt;/h2&gt;

&lt;p&gt;Both engines organize business capability by the same structural boundaries: &lt;strong&gt;suite → module → package&lt;/strong&gt;. This is an architectural boundary, not just directory placement. Frontend and backend suites of the same name correspond one to one:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Suite&lt;/th&gt;
&lt;th&gt;Backend&lt;/th&gt;
&lt;th&gt;Frontend&lt;/th&gt;
&lt;th&gt;What it demonstrates&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;a-commerce&lt;/td&gt;
&lt;td&gt;&lt;code&gt;vona/src/suite/a-commerce&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;zova/src/suite/a-commerce&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A complete e-commerce Admin, Web site, personal center, and payment flows&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a-training&lt;/td&gt;
&lt;td&gt;&lt;code&gt;vona/src/suite/a-training&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;zova/src/suite/a-training&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Master–detail forms, nested detail records, image and file uploads&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a-demo / a-home&lt;/td&gt;
&lt;td&gt;Mirrored&lt;/td&gt;
&lt;td&gt;Mirrored&lt;/td&gt;
&lt;td&gt;Demo and home pages&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Business consumers are also explicitly split into two kinds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Admin Resource&lt;/strong&gt;: back-office management, reusing the generic Resource owner and resource pages&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Web self-service&lt;/strong&gt;: the self-service Web frontend, with its own state, pages, and server-side scope&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When one persisted resource serves both kinds of consumers, the domain and persistence boundary stays single, while the API/DTO contracts, server-side scope, frontend state ownership, and page architecture are separated.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 5. One Diagram to Remember It All
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Zova (frontend truth)                     Vona (backend truth)
──────────────────────                    ──────────────────────
Page/Component/Controller                 Controller → Service → Model → Entity
sys/app/ctx containers + Bean             app/ctx containers + Bean (scene-based)
ModelResource + TanStack Query            DTO + Zod validation + OpenAPI output
flavors: Basic Web/Admin, Commerce        SSR Site registration, multi-tenant instances
route/component/icon metadata  ─reverse──▶  consumed via deps:vona
$api / $apiSchema generated SDK ◀─forward──  OpenAPI contracts
        │                                         │
        └───────── build artifacts: ssr-* / rest-* ┘
               Vona integrated SSR (7102) faces the world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you understand this architecture, many Cabloy working conventions fall into place naturally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why regenerating the frontend SDK — not hand-editing &lt;code&gt;$api&lt;/code&gt; — is the response to backend API changes&lt;/li&gt;
&lt;li&gt;Why frontend route changes must be followed by a Zova build and then &lt;code&gt;deps:vona&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Why debugging fullstack issues requires distinguishing 9000 (frontend iteration) from 7102 (integrated truth)&lt;/li&gt;
&lt;li&gt;Why schema-driven forms (ZForm/ZTable) never need field definitions duplicated on the frontend&lt;/li&gt;
&lt;li&gt;Why business code is organized along suite/module boundaries instead of technical-type directories&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Vona and Zova are each complete, independent, independently evolvable frameworks. Cabloy's value is precisely in assembling them — through the SSR runtime channel and the bidirectional contract loop — into one complete fullstack system built for AI Spec-Driven Development.&lt;/p&gt;




&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/backend/foundation" rel="noopener noreferrer"&gt;Backend Foundation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/frontend/foundation" rel="noopener noreferrer"&gt;Frontend Foundation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/frontend/ioc-and-beans" rel="noopener noreferrer"&gt;IoC and Beans&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/fullstack/ssr-entry-modes" rel="noopener noreferrer"&gt;Vona Integrated SSR and Zova Standalone SSR&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/fullstack/vona-zova-integration" rel="noopener noreferrer"&gt;Vona + Zova Integration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cabloy.com/fullstack/contract-loop-playbook" rel="noopener noreferrer"&gt;Contract Loop Playbook&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>fullstack</category>
      <category>ioc</category>
      <category>ssr</category>
      <category>openapi</category>
    </item>
  </channel>
</rss>
