Blog
Saved0

Compile on publish: faster AI workflows without losing traceability

The runtime got faster. It was no longer the same application. How to validate and optimize a visual workflow once, at publish, without letting the compiled output drift from what was reviewed.

LinkedIn
On this page
  1. The runtime got faster. It was no longer the same application.
  2. Does a visual workflow have to run slowly?
  3. What does compile on publish actually do?
  4. What can a compiler safely optimize?
  5. Check that the application stayed the same
  6. Keep a map from runtime back to source
  7. Will compiling make an AI application faster?
  8. Agents and long-running cases still fit
  9. Common anti-patterns
  10. Ten rules for compile on publish
  11. The result: inspectable and fast, without a second source of truth
  12. Frequently asked questions
  13. How Frozion governs what goes live
  14. Sources
The short answer

Compile on publish means validating and optimizing a visual workflow definition once, when it's published, instead of interpreting it on every request. It removes repeated parsing, mapping and dispatch work. It's safe only when every dependency that affects behavior is declared, controls are never moved or skipped, and every compiled step traces back to its source.

The runtime got faster. It was no longer the same application.

A lender runs a multi-tenant credit-release workflow. It loads a tenant-scoped account, calculates exposure, checks policy, asks a person to approve when required, and releases credit through an enterprise API.

The first version interprets the workflow on every request: read the step definitions, resolve mappings, build validators, bind policy and API clients. It's easy to inspect, but at high volume the per-step overhead adds up.

So the team adds a compile step at publish. It precomputes branch conditions, fuses deterministic calculations, generates serializers and caches policy results it considers pure. Throughput improves.

Then a hidden assumption bites. Tenant and legal entity reach the policy service through ambient runtime context. They were never declared as inputs to the policy step. The optimizer sees a function of amount and risk tier, and caches the result on those two values.

Tenant A allows automatic release for a given amount and risk tier. Tenant B requires review for the same values. The fast path reuses Tenant A's cached decision for Tenant B. The API request is valid, the policy step is still on the diagram, and the runtime logs a cache hit, not an error.

No optimizer bug was needed. The optimizer preserved exactly the meaning it was given. The definition failed to declare a dependency that controlled the outcome.

Two tenants send the same amount and risk tier to a policy step; a cache keyed only on amount and risk tier returns tenant A's auto-approve decision to tenant B, bypassing the review tenant B requires.
A cache key missing tenant scope turns a performance gain into a governance failure.

Does a visual workflow have to run slowly?

No. People review a visual definition; the runtime can execute a prepared plan derived from it. The two can differ in form as long as each runtime step traces back to its source.

Visual architecture is often framed as a trade-off: keep the application inspectable and pay for interpretation on every request, or generate fast code and let the diagram go stale. That's a false choice. It mixes up two questions:

  • What should people use to design, review and govern the application?
  • What should the runtime use to execute it efficiently?

A visual view is built for people. The stored definition is built for completeness and versioning. A compiled plan is built for dispatch. Execution evidence is built for investigation. These don't have to be the same artifact. They have to stay linked. (For why the visual definition must stay in charge, see visual architecture vs no-code.)

ArtifactPurposeAuthority
Visual viewDesign, review, simulation, inspection per roleOnly as a faithful view of the definition
Workflow definitionFull meaning: steps, contracts, policy, identity, state, side effects, evidenceThe editable source before publish
Published versionApproved, immutable definitionThe release contract for new cases
Compiled planPre-bound handlers, compiled mappings, validators, evidence hooksHow that version runs, as a verified output
Execution evidencePath taken, policy results, state, costs, errors, effectsWhat a given case actually did

What does compile on publish actually do?

It validates the workflow, pins its dependencies, prepares everything that doesn't change per request, adds evidence hooks and packages the result, once, at publish time, so requests run a prepared plan.

The publish pipeline has six stages:

  1. Normalize. Put expressions, schemas, mappings, policy references and dependency IDs into one standard form, so equivalent definitions produce the same result and can be fingerprinted.
  2. Validate. Type-check inputs, outputs and mappings. Find unreachable branches, illegal loops, ambiguous joins and missing failure routes. Check that policy covers every consequential step, authority carries through, approvals bind to proposals and side effects are classified. Schema validation is one input, not the whole check.
  3. Resolve. Pin schemas, mappings, policies, sub-workflows, integrations, model routes and environments. Produce a dependency manifest for the release.
  4. Optimize. Precompile expressions, mappings, validators, serializers and query plans. Fuse safe adjacent steps. Pre-bind dispatch. Remove repeated reflection, conversion and parsing, but only where it can't change meaning.
  5. Instrument. Bind correlation, policy, lineage, cost, latency, state, approval and side-effect evidence into the plan itself, not onto whatever code happened to come out.
  6. Package. Produce the plan, a traceability map, a build manifest, fingerprints and signatures, the same release-integrity disciplines secure-development guidance asks of any software build.

This is also where hidden assumptions turn into errors. If a policy result depends on tenant and purpose, those must be declared inputs. If a mapping drops classification or scope, the edge is rejected. If an approval binds to a proposal fingerprint, a later payload can't be swapped in without re-approval.

What can a compiler safely optimize?

Anything that can't change authority, state, ordering, side effects, policy, evidence or visible values. Everything else needs declared dependencies, or stays exactly where the workflow put it.

Enterprise rules make locally equivalent steps globally different. A policy check before tenant scoping isn't the same as one after. Approval before a material mapping change isn't the same as approval after. A retry before reconciliation isn't the same as one after.

ClassExamplesCondition
Generally safePre-parsed schemas, compiled expressions, generated serializers, constant folding, pre-bound handlersCan't change authority, state, order, effects, policy, evidence or output
Safe with declared dependenciesStep fusion, caching, query reuse, batching, parallelism, prefetchTenant, authority, freshness, ordering and evidence are all in the proof or cache key
Implement, never removePolicy checks, approvals, identity propagation, validation, side-effect gates, durable waits, evidenceMay be made efficient; never skipped, broadened or reordered
Never by assumptionReusing decisions across tenants, hoisting authorization out of resource scope, retrying uncertain effectsNeeds a reviewed design change and a new publish, not an optimization pass

Check that the application stayed the same

A normal compiler proves the output preserves the language's semantics. An enterprise workflow carries more obligations than that. Before release, check the compiled plan still preserves:

  • input, output, mapping and failure contracts;
  • identity, delegation, tenant, purpose and resource scope;
  • where policy runs, its obligations and their enforcement;
  • waits, events, timers and resume rules;
  • approval binding to the exact proposal, its conditions and expiry;
  • side-effect class, operation ID, retry and reconciliation (see retries and idempotency);
  • required lineage, cost and audit evidence.

Some of this can be checked statically. The rest needs generated tests, simulation on representative cases or runtime assertions. "It compiled" and "the application is unchanged" are different release claims.

Fail closed. If the pipeline can't prove or test a consequential transformation, don't apply it. A slower correct plan beats a faster one whose controls you can't defend.

Keep a map from runtime back to source

Source maps let developer tools relate generated code back to the original file. A compiled workflow needs the same thing at the level of meaning, not line numbers.

For any error, latency spike, policy denial, unexpected branch or external effect, you should be able to name the published version and compiler version; the step, edge, mapping, policy check or approval it came from; the optimization passes that touched it; and the inputs, state, authority, cost and evidence of that step.

That gives operators source-level inspection: click a step in the visual workflow and see its latency, errors, retries, cost and policy outcomes, even if it was fused into a compiled segment. An incident record navigates back to the exact definition that allowed the behavior.

A visual workflow step linked by two-way arrows to its compiled handler and to a runtime event, showing that an incident can be traced back to the source step and version.
A traceability map links each visual step to its compiled form and to every runtime event it produces, in both directions.

Will compiling make an AI application faster?

Only the coordination around the slow parts. Most AI workflows spend their time waiting on models, data, networks, people or external systems, and compiling doesn't shorten any of those.

Don't sell compilation as a universal latency cure. The real gain is narrower: removing repeated work in workflows with many small deterministic steps, high volumes, frequent mappings and validations, or deterministic-first paths that skip model calls entirely.

Measure before and after, rather than assuming parsing is the bottleneck:

Where to measureQuestion
DispatchHow long goes on picking handlers and moving between steps?
Contracts and mappingsHow much is parsing, reflection, conversion and serialization?
Policy and identityWhich checks can be pre-planned, and which must use current facts?
Data accessWhat can be prepared at publish or startup?
State and evidenceWhich writes can be batched without weakening guarantees?
End to endDid errors, policy behavior, side effects or explainability change?

The best optimization is usually not "make every step faster." It's taking repeated work out of the hot path while keeping every check whose answer depends on the current person, record, policy and state.

Agents and long-running cases still fit

A compiled plan doesn't need the whole path known in advance. A model may propose a classification, tool request or short plan. Events arrive whenever. People pause the work. What compilation fixes in advance is the boundary: which proposal shapes are allowed, which actions are open under which authority, and which validation, budget, approval and evidence rules apply whatever path is taken. A model-generated plan stays data until it passes those checks.

Each case records the published version and plan fingerprint it started under. A later publish creates a new plan for new cases. Cases already waiting don't silently pick it up; moving them is a deliberate, validated migration. Replaying a past case uses the plan that actually ran. Recompiling today against newer dependencies is a what-if, not a reproduction. (See versioning AI workflows.)

Common anti-patterns

Anti-patternWhy it failsWhat to do instead
Interpret everything foreverEvery request repeats parsing, binding and mappingPrepare stable mechanics at publish; keep current-state checks live
Generate and forgetGenerated code becomes the real applicationTreat compiled output as read-only and traceable
Hand-edit generated codeBehavior no longer has a source or a reproducible buildExtend through declared steps or published compiler plug-ins
Optimize hidden contextAmbient tenant, identity or freshness drops out of cache keysDeclare every dependency that affects behavior
Compile only the happy pathTimeouts, retries, approvals and uncertain effects behave differentlyCompile and validate the full lifecycle, failures included
Telemetry without source mappingOperators see handlers, not application stepsReport metrics, errors and policy results per source step

Ten rules for compile on publish

  1. Keep one authority: the published version. The compiled plan is its output.
  2. Compile only from declared dependencies, never ambient context.
  3. Validate types, mappings, policy coverage and approvals before optimizing.
  4. Put fences around every consequential control.
  5. Check that application obligations survive, not just language semantics.
  6. Fail closed when a transformation can't be proven or tested.
  7. Build evidence hooks into the plan.
  8. Map every runtime event back to its source step and version.
  9. Fingerprint and sign the release, with its dependencies.
  10. Keep running cases on the plan they started with.

The result: inspectable and fast, without a second source of truth

The case for visual architecture isn't that people can draw boxes. It's that one definition can be reviewed visually, validated formally, compiled efficiently, executed durably and investigated through evidence.

A compiler only helps if it treats contracts, identity, policy, state, approvals, side effects and evidence as part of the program, not annotations around it. The goal is a verifiable path from the reviewed workflow to what runs, and an equally strong path back from any runtime event to the definition that allowed it.


Frequently asked questions

What does compile on publish mean for an AI workflow?

The workflow definition is validated, type-checked, bound to pinned dependencies and turned into an optimized runtime plan once, at publish time. Requests then run that prepared plan instead of re-reading and re-interpreting the definition every time.

Will compiling a workflow make model calls faster?

Model calls stay as slow as the model. Compilation removes coordination overhead (parsing, mapping, validation setup, dispatch), which matters for high-volume, many-step or deterministic-first workflows, not for steps dominated by inference, networks or human waits.

Can a cached policy decision be reused across tenants?

Only if tenant and every other fact the decision depends on are part of the cache key. A decision cached on amount alone and reused for another tenant is a governance failure, even though no component reports an error.

How does this work for agents we already run?

Route the agent's tool calls through a governed runtime over MCP or HTTPS. Each routed call then runs inside a published, versioned workflow, so its checks, approvals and evidence are validated before release and traceable afterwards.

With Frozion

How Frozion governs what goes live

In Frozion, publishing is a governed step, not a file copy. Before a workflow change goes live, you see every workflow that uses the changed part, compare versions, run a batch simulation on recorded cases and approve the publish, with rollback ready. Deploys don't interrupt running cases. Policy is enforced before and after every step, whatever the release. Behavior Intelligence & Replay inspects and replays past cases without live side effects, and Provenance & Evidence keeps one tamper-evident record per decision, so any outcome traces back to the published version behind it.


Sources

  1. OMG, Business Process Model and Notation (BPMN) 2.0.2Visual process notation, separate from the implementation environment.
  2. JSON Schema, Draft 2020-12Machine-readable validation for typed boundaries at publish time.
  3. NIST SP 800-53 Rev. 5Configuration baselines, change control and system integrity.
  4. NIST SP 800-218, Secure Software Development FrameworkProtected builds, release integrity and provenance.
  5. NIST SP 800-218A, SSDF Community Profile for Generative AISecure development practices extended to AI systems.
  6. NIST SP 800-204D, Software Supply Chain Security in CI/CD PipelinesBuild, package and deploy stages with supply-chain assurance.
  7. RFC 8785, JSON Canonicalization SchemeStable content identity for definitions and manifests.
  8. ECMA-426, Source Map FormatMapping generated artifacts back to their source.
  9. W3C PROV-ODerivation chains from source to runtime artifact.
More in Platform architecture

Platform architecture

Why a governed runtime 4
Building AI applications 4
Semantic integration 1

Other topics

Pick up where you left off: