Skip to content

Contract Loop Playbook ​

This page is the canonical playbook for Cabloy’s bidirectional fullstack contract loop.

AI Spec-Driven Development defines what an approved increment should build and how it is proven. Contract Loop is its complementary synchronization mechanism: it aligns Vona↔Zova contract sources, generated handoffs, and consumers, but does not create suite authority or establish ATP evidence.

Use it when you need to decide:

  • where source truth lives for a change
  • which generated handoff should be refreshed
  • which side is actually stale
  • whether the problem is source drift, generated-output drift, consumer drift, or local dependency drift

Why this playbook exists ​

Cabloy’s fullstack collaboration is not only backend-to-frontend.

The same monorepo supports two symmetric chains:

  • forward chain — backend contract emission and frontend consumption
  • reverse chain — frontend metadata or resource handoff and backend consumption

The core model applies to both Cabloy Basic and Cabloy Start.

What changes by edition is not the model itself, but the operational branch:

  • flavor names
  • UI-resource examples
  • generated-output paths
  • build commands

So the first question is always:

  1. which chain am I in?
  2. which edition is active?

Shared vocabulary ​

Use these terms consistently:

  • contract loop — the full bidirectional Vona↔Zova collaboration model
  • forward chain — backend contract truth flows into generated frontend consumers
  • reverse chain — frontend-owned metadata or resources flow into backend consumers
  • contract source — the authored layer that currently owns truth
  • generated handoff — the generated output that carries truth to the other side
  • consumer drift — downstream consumers no longer match current truth
  • local dependency drift — generated artifacts are already correct, but installed local file dependencies are still stale

The two chains ​

Forward chain ​

Use the forward chain when backend-authored contract surfaces changed.

Typical contract sources:

  • controller request or response signatures
  • DTOs
  • entity field metadata
  • validation rules
  • OpenAPI metadata

Typical handoff:

  • Swagger or OpenAPI output
  • generated Zova SDK or schema-aware helpers
  • flavor-built REST output when the workflow depends on it

Typical consumers:

  • generated frontend API files
  • thin frontend model facades
  • schema-driven UI
  • custom row or page actions

If your issue becomes one mixed Student row-action chain rather than a pure direction question, first continue with Backend Metadata to Frontend Table Actions, then Backend Metadata to Frontend Table Actions Source Reading Map.

If the family root and source-reading map already match your case and the visible result is still wrong, continue with Backend Metadata to Frontend Table Actions Debug Checklist.

If you have already changed that mixed chain and now want to prove it layer by layer rather than diagnose a failure, continue with Backend Metadata to Frontend Table Actions Verify Playbook.

Reverse chain ​

Use the reverse chain when frontend-owned metadata or resources changed and backend-side tooling or metadata will consume them.

Typical contract sources:

  • frontend routes
  • frontend components
  • frontend icons
  • custom form-field or table-cell resources
  • module metadata consumed by backend ZovaRender.*(...) references

Typical handoff:

  • generated metadata
  • flavor build output
  • local file dependency sync into Vona

Typical consumers:

  • backend metadata that references frontend resources
  • backend-side tooling and type hints
  • SSR or integration paths that depend on refreshed frontend output

Decision tree ​

Use this decision tree before editing or regenerating anything.

1. Did backend contract truth change? ​

Examples:

  • DTO shape changed
  • controller request or response changed
  • validation changed
  • OpenAPI metadata changed
  • an existing resource field changed

For an existing resource-field change, first use Existing Resource Field Update to make the persistence, DTO, locale, renderer, and migration decision explicit. Then continue with the applicable contract-loop branch.

Then use the forward chain:

  1. change backend truth first
  2. prove emitted contract output is correct
  3. regenerate frontend consumers
  4. keep frontend follow-up thin
  5. verify consumer alignment

See Backend OpenAPI to Frontend SDK for the end-to-end forward-chain bridge from backend-authored contract truth to generated frontend consumers.

2. Did frontend-owned metadata or resource truth change? ​

Examples:

  • a custom table cell was added
  • a custom form field was added
  • routes, components, or icons changed
  • backend metadata now references new frontend resources

Then use the reverse chain:

  1. change frontend source truth
  2. regenerate metadata when applicable
  3. build the relevant frontend flavor output
  4. run npm run deps:vona
  5. verify backend consumers can see the refreshed handoff

See Frontend Metadata Back to Backend for the end-to-end reverse-chain bridge from frontend-owned truth to backend-visible shared handoff.

When the frontend change creates a new independently mounted SSR site rather than refreshing an existing consumer, use Independent SSR Site and Flavor Setup. The new Vona consumer needs a matched flavor, paired SSR/REST build wrapper, site registration, and dispatch/hydration proof.

3. Do generated artifacts look stale? ​

Examples:

  • generated SDK still reflects an old endpoint shape
  • generated metadata is missing a new resource
  • rest output did not pick up the latest source change

Then diagnose generated-output drift:

  1. confirm the source layer was changed in the right place
  2. confirm the correct generation path was used
  3. regenerate instead of hand-patching
  4. verify the generated output itself before debugging downstream code

4. Do generated artifacts already look correct, but consumers still behave stale? ​

Examples:

  • the generated .zova-rest artifacts already contain the new keys or types
  • the generated SDK already contains the new method
  • backend or frontend still sees stale consumers after the normal sync flow

Then suspect local dependency drift:

  1. stop editing source files
  2. if the relevant generated handoff is not already known to be correct, make a quick confirmation; do not repeat evidence already available
  3. rerun the normal sync flow if it has not already run
  4. if an affected Vona/TypeScript process is running, restart it when consumers still look stale
  5. if generated output is wrong, return to the build chain; only repair the local install state when the output and sync are correct and stale behavior remains

Forward chain playbook ​

Stage 1: Backend contract source ​

Author the truth in Vona first.

Typical layers:

  • controllers
  • DTOs
  • entities
  • validation helpers
  • OpenAPI annotations

Rule:

  • do not patch generated frontend consumers first when the backend owns truth

Stage 2: Emitted contract proof ​

Before regeneration, verify the backend output is actually correct.

Typical checks:

  • controller contract matches intent
  • DTO and validation align
  • OpenAPI output reflects the intended shape

If the emitted contract is wrong, regeneration will only spread the mistake.

Stage 3: Module ownership and generation ​

Regenerate the frontend consumer path deliberately.

Configure module ownership when needed:

bash
npm run zova :openapi:config <module-name>

For AI development, both Cabloy Basic and Cabloy Start should default to managed isolated generation, even when a development Swagger service is currently available:

bash
npm run contract:generate:isolated -- <module-name>

This isolated path reuses the existing Zova generator and module ownership checks, but starts Vona in an isolated test run without Playwright. Its claim-backed test resources are cleaned after success and retained on failure; generated SDK files remain shared workspace output, so serialize concurrent generation and do not assume rollback.

Use the direct command only as a deliberate exception when a specific development or external Swagger source is required:

bash
npm run zova :openapi:generate <module-name>

When the target is a module-local SDK, keep ownership constrained with operations.match so the module only generates the API surface it actually owns.

Stage 4: Thin frontend follow-up ​

After regeneration, keep frontend follow-up thin.

That means:

  • prefer generated contract consumers over hand-written duplicates
  • use thin model facades as semantic wrappers over generated APIs
  • reuse the existing resource-owner when the custom API still belongs to an existing resource

For resource-bound custom endpoints, prefer rest-resource.model.resource as the state owner. A module-local model may still exist, but it should remain a semantic facade instead of becoming a second cache owner. When Admin Resource consumption and Web self-service consumption have genuinely different API, scope, projection, or SSR semantics, see Admin Resource and Web Self-Service for the boundary between Admin owner reuse and a dedicated Web model.

See the canonical downstream pattern in repo-agent-governance/skills/cabloy-contract-loop/references/resource-custom-state-pattern.md.

Stage 5: Consumer verification ​

Verify that generated output and frontend consumers agree.

Typical checks:

  • generated API contains the intended methods
  • model or schema consumers still typecheck
  • UI behavior now matches the regenerated contract

Reverse chain playbook ​

Stage 1: Frontend-owned source truth ​

Start from the frontend resource or metadata that actually changed.

Typical layers:

  • bean resources
  • components
  • metadata wrappers
  • routes
  • icons

Rule:

  • do not treat a frontend-owned resource handoff as frontend-only cleanup if backend consumers depend on it

Stage 2: Generated handoff ​

Refresh the generated metadata or build output that carries the change across the boundary.

Typical commands may include:

bash
npm run zova :tools:metadata <module-name>

and then the relevant build path for the active edition and flavor.

Stage 3: Vona sync handoff ​

After the frontend-generated handoff is ready, detect the active edition and version, resolve every affected Zova flavor/site, identity, and output path from the active manifests, then use the affected ordinary build:zova* wrapper when convenient or the universal paired command npm run build:zova:isolated -- <affected-flavor> [<affected-flavor> ...]. Complete all affected paired SSR/REST outputs before running npm run deps:vona as the default Vona dependency synchronization step. deps:vona consumes the existing .zova-rest output; it does not generate that output. Resolve ordinary wrapper mappings and independently named site values from source rather than inferring Admin/Web identities. With healthy local dependency state, this normal flow is usually sufficient, and deleting vona/node_modules is not a routine prerequisite.

For this Cabloy Basic checkout, the representative Admin sequence is:

bash
npm run build:zova:admin
npm run deps:vona

If the same resource path must also be available to Web, complete both affected pairs before the final dependency synchronization:

bash
npm run build:zova:admin
npm run build:zova:web
npm run deps:vona

In a multi-flavor change, complete all affected paired builds before the final dependency synchronization. Do not treat build:rest:* alone as sufficient. The SSR bundle and the generated REST output should move together.

deps:vona is the normal synchronization step, not an absolute guarantee against local dependency drift. If consumers still look stale, restart an affected running Vona/TypeScript process if one is present. Make a quick confirmation of the relevant generated artifacts only when they are not already known to be correct; if they are wrong, return to the build chain rather than reinstalling. Never hand-edit generated manifests, lockfiles, dependency links, .zova-rest packages, or copied build artifacts.

For Cabloy Start, use the same reverse-chain logic, but resolve the Start-specific flavor names and output paths from the active Start repo before recommending commands.

Stage 4: Consumer verification ​

Verify that backend consumers can now resolve the refreshed frontend-generated handoff.

Typical checks:

  • backend metadata resolves the new frontend resource names
  • generated shared types now appear in backend-side consumers
  • SSR or integration behavior sees the refreshed output

Recovery path for local dependency drift ​

Use this branch only when the paired builds and npm run deps:vona completed, the relevant generated output is known to be correct, and consumers still behave stale after restarting an affected running Vona/TypeScript process if one is present. If the output is not already known to be correct, make a quick confirmation; if it is wrong, return to the build chain rather than reinstalling.

Then treat the problem as local dependency drift, not as a reason to hand-patch source or generated output.

Representative recovery path:

bash
cd vona && rm -rf node_modules && pnpm install

This is an exceptional recovery step, not the first response or a routine prerequisite for npm run deps:vona. Re-run the relevant consumer verification after reinstalling.

Verification by branch ​

Forward chain ​

  • backend source truth is correct
  • emitted OpenAPI or contract output is correct
  • module ownership is constrained
  • generated frontend consumer output is refreshed
  • frontend consumers and UI behavior align

Reverse chain ​

  • frontend source truth is correct
  • metadata or build output is refreshed
  • Vona dependency sync completed
  • backend consumers resolve the updated frontend-generated handoff

Local dependency drift ​

  • generated artifacts already prove the change exists
  • sync flow already ran
  • reinstall is justified only because consumers still behave stale

Tutorial map ​

Use the tutorial series as examples of the two chains:

Released under the MIT License.