Skip to content
Back to all posts

Architecture Markup in Code: What Did We Actually Observe?

By Maksym Kuzmitskyi
5 min read
Architecture Markup in Code: What Did We Actually Observe?

I could keep the catalog perfectly up to date without knowing whether the application actually followed it.

That isn't a bug in arch check. In my first article about architecture markup, I used it to check declarations against a generated catalog. Comparing the running application with those declarations is a different question.

After publication, Raju Dandigam asked in a DEV comment whether a small set of runtime traces could be compared with the declared typed edges, with observations kept in a separate evidence layer.

That comment inspired the next addition to arch-manifest-prototype. The separation was the part I wanted to preserve.

Three Artifacts, Three Different Claims

The catalog says what developers declare. Evidence records observations from a particular run. A drift report compares the two.

I added a versioned JSON evidence format, an analyzer, and the arch drift command. The first version compares synchronous calls observations with declared call edges, using full Component and API references. It does not compare every relationship the catalog can represent.

I kept the source, run ID, application version, environment and scenario with the observations because I don't want a finding detached from the run that produced it. I also made coveredCallers explicit: which components had their outgoing calls monitored. Restoring a basket on one version isn't coverage of every checkout path.

The Commerce evidence file identifies its environment as synthetic. Its observations are normalized records from a file, not traces automatically collected from a running commerce application. Automatic trace collection and integration with Nivra remain outside this implementation.

A Small Comparison

Here is the relevant declaration from the synthetic Commerce example:

/** * @arch component basket-domain module -- Persistent basket business domain * @arch partOf checkout-page * @arch calls api:cart/cart-api -- Save and restore the basket */

The evidence records a call from component:storefront/basket-domain to api:cart/cart-api. It also records the comparison page calling that API, and another call from the comparison page whose target could not be mapped.

In a checkout with dependencies already installed, run npm run demo from the toolkit root. The generated demo directory contains combined.yaml, arch.evidence.json and arch.drift.json. To repeat the comparison, replace <demo-dir> with the directory printed by the demo:

npm run --silent arch -- drift combined.yaml \ --evidence arch.evidence.json \ --root "<demo-dir>"

These are the three findings, abbreviated for reading rather than copied as raw report JSON:

ObservationStatus
basket-domain to cart-apiconfirmed
comparison-page to cart-apiundeclared
comparison-page to an unmapped APIunresolved

The first observation matches a declared edge. The second has known endpoints but no corresponding declared call. That deserves investigation: perhaps the declaration is missing, perhaps the call is accidental, or perhaps the evidence was mapped incorrectly.

The third is not an undeclared dependency with an invented destination. It remains unresolved. The analyzer needs an identity it can compare, not a plausible service name.

Not Observed Is Not Removed

The fourth status, not_observed, needs more care than the others.

It's tempting to read that as a stale declaration. I don't make that jump. I report it only when the caller was covered, the target API is in the catalog, and no unresolved observation could account for the missing match. Even then, I haven't established that the dependency should be removed.

A scenario may never reach an error handler. A feature flag may keep a branch closed. A trace sample may miss a call. Even monitoring every outgoing call from one component does not exercise every path through that component.

There is a further wrinkle in this demo. The comparison page declares a pricing API call, but its evidence includes a call with no mapped target. That unknown call could be the pricing call. The analyzer therefore does not report the pricing edge as not observed. It keeps the observation unresolved instead of turning incomplete mapping into a second, misleading conclusion.

A missing observation is information about this run, not proof about every possible run.

The Caller Still Matters

The annotation guide includes a CheckoutForm with an onSubmit callback. Its preview supplies a local handler; the working screen supplies a GraphQL handler. I put the API relation on the module that sends the request, not the reusable form. Comparing observations against the wrong declared caller would only give me a more elaborate wrong answer.

A Question, Not an Automatic Rewrite

For a person reviewing a change, these findings narrow the next question. For an agent, the distinction matters just as much: confirmed is not universal correctness, undeclared is not automatic approval to add an annotation, and not observed is not permission to remove one.

I don't want a trace sample to rewrite the architecture. I want it to give me a concrete question to investigate.

Raju's suggestion helped me ask that question without changing who owns the declarations. Which single scenario in your application would you check first?

A note from the author

I’m Maksym Kuzmitskyi, a senior software developer working mainly with React and TypeScript. I build frontend applications and design workflows for working with AI in software delivery. If this article connects with something you’re working on, I’d love to hear from you.

Telegram

More than a blog post

I share frontend news and the reasoning behind it throughout the day. Pick the language that feels natural to you.

Need to discuss your project? Get in touch.