Semantic compilation, architectural reasoning and the limitations of LLMs

BK

BK

—

Nov 24, 2026

Semantic compilation, architectural reasoning and the limitations of LLMs

This is the first part of a boring article that tries to carry out an experiment inspired by the R2ABench research regarding the capabilities of BK (the second part is here).

Rather than read it, I would suggest to give both parts to an LLM and ask what it thinks.

These experiments demonstrate the feasibility of autonomously generating substantial, architecturally coordinated codebases. Controlled comparative experiments will try to quantify the contribution of semantic compilation to engineering quality, cost and model efficiency.

1. What is a semantic compiler?

To understand what is semantic compilation in the context of Artificial Intelligence, it is necessary to distinguish three established disciplines: compiler theory, semantic parsing and program synthesis.

Classical compilation

A conventional compiler translates a program expressed in a source language into a program expressed in a target language while preserving its semantics.

The fundamental correctness objective is:

⟦C(P)⟧T=⟦P⟧S\llbracket C(P)\rrbracket_T=\llbracket P\rrbracket_S

Where (P) is the source program, (C) is the compiler, and the brackets represent the semantics of the program in the respective language.

The important distinction is that compilation is not textual translation. A compiler establishes the meaning of expressions, resolves references, determines types and identifies dependencies before producing the target implementation.

Intermediate representations allow transformations to operate on the meaning and structure of a program rather than its original textual expression.

courses.cs.cornell.edu

Semantic compilation from natural language

Natural language introduces a fundamentally different problem. Unlike a conventional programming language, English does not possess a complete, unambiguous formal execution semantics.

To formally guarantee semantic equivalence, as a mathematical property, we must act “ex post”, over the code that was generated, by independently benchmark if the actual result was made according specs.

Consider the requirement:

A payment must not be executed until it has been approved by an authorized person other than its initiator.

This sentence contains no implementation, but it expresses substantial computational semantics:

  • An identity relationship between the initiator and approver.
  • An authorization constraint.
  • A temporal ordering constraint.
  • A restriction on a permissible state transition.
  • An invariant that must hold across every execution path.

The implementation must preserve these semantics independently of the programming language, framework or deployment topology.

Semantic parsing traditionally addresses the translation of natural language into machine-interpretable meaning. Program synthesis addresses the construction of executable programs satisfying specifications. Both are established research fields.

arXiv

An architecture-first semantic compiler, extends this objective to the engineering of entire software systems: it must account for the meaning of requirements both individually and in their interactions, before or during the production of implementation artifacts.

Conceptually, the objective becomes:

Behavior⁡(P)⊨R\operatorname{Behavior}(P)\models R

Where (R) represents the interpreted requirements and (P) the generated software.

This is a correctness objective, not a claim that arbitrary natural-language requirements admit automatic formal verification.

The significant difference is that the compilation target is no longer merely executable code. It is a collection of coordinated artifacts realizing the requirements of a system.

2. How architectural relationships govern implementation

In 1997, Robert Allen and David Garlan of Carnegie Mellon University published A Formal Basis for Architectural Connection. Their fundamental contribution was to treat architectural connections as semantic entities in their own right, rather than simply links between software components.

A connection defines the protocols, responsibilities and behavioral expectations governing participating components. These can be subjected to compatibility analysis analogous to type checking.

CMU School of Computer Science

This is central to understanding why generating components and engineering systems are fundamentally different computational problems.

Architecture as a system of constraints

At an abstract level, an architecture can be represented as:

A=(V,E,Γ)\mathcal A=(V,E,\Gamma)

Where:

  • (V) represents architectural components.
  • (E) represents their relationships.
  • (Γ) represents the constraints governing their composition and behavior.

Knowing (V) does not establish (E), and knowing (E) does not necessarily establish (Γ).

Two systems can contain identical components while exhibiting entirely different security, consistency, performance and transactional properties because their relationships differ.

Identical components. Different architectural relationships. Different security properties.

Relationships determine implementation obligations

Returning to the payment example, consider the following authorization condition:

Execute⁡(p,t)⇒∃a: Approved⁡(p,a,ta) ∧Authorized⁡(a,p,ta) ∧a≠Initiator⁡(p) ∧ta<t\begin{aligned} \operatorname{Execute}(p,t)\Rightarrow\exists a:\ \operatorname{Approved}(p,a,t_a)\\\ \land\operatorname{Authorized}(a,p,t_a)\\\ \land a\ne\operatorname{Initiator}(p)\\\ \land t_a < t \end{aligned}

This condition imposes obligations across multiple implementation locations.

Implementation location

Derived obligation

Identity management

Establish the identities participating in the transaction.

Persistence

Preserve the relationship between payment, initiator and approval.

Authorization

Evaluate authority over the relevant payment.

Workflow

Prevent execution before valid approval.

Execution service

Enforce the invariant on every execution path.

Testing

Verify the combined behavior of these mechanisms.

The implementation of each component is therefore partially determined by relationships that extend beyond the component itself.

This is the foundation of compositional engineering and assume-guarantee reasoning: a component's correctness depends on what it guarantees and what it assumes about its surrounding system.

sciencedirect

System correctness is not generally the sum of independently correct component implementations. It depends on whether their composition satisfies the intended system properties.

This is also why architectural knowledge must inform code generation, rather than merely document the resulting code.

3. Why LLMs struggle to isolate architectural relationships

There are three distinguishable problems: relational binding, compositional reasoning and global constraint satisfaction.

3.1 Entity recognition is not relational reasoning

An LLM can readily associate terms such as payment, authentication, authorization, database and audit log with familiar software patterns.

However, identifying those entities does not determine:

  • Which relationships are required.
  • Under which conditions they apply.
  • Which other relationships constrain them.
  • How those relationships propagate throughout the system.

The R2ABench study measures precisely this distinction across 68 projects with human-validated architectural references.

arXiv

3.2 Higher-arity relational binding

The REL study, published at ICML 2026, provides a deeper explanation of the difficulty observed in architectural generation.

The authors distinguish operand complexity from relational complexity:

  • Operand complexity: difficulty associated with identifying or representing individual entities.
  • Relational complexity: the number of independent variables that must be bound simultaneously to perform an inference.

For example:

R(a,b)\R(a,b)

is a binary relationship, whereas:

R(a,b,c,d)\R(a,b,c,d)

requires the joint consideration of four arguments.

Knowing all pairwise relationships does not necessarily establish the higher-order relationship.

A simple mathematical demonstration is the constraint:

a⊕b⊕c=0a\oplus b\oplus c=0

For binary variables, every possible pairwise assignment can occur in a valid solution. Nevertheless, only half of the possible three-variable assignments satisfy the constraint.

Examining the variables individually or pairwise is therefore insufficient to recover the complete rule.

This matters directly to software architecture, where correctness frequently depends on the simultaneous interaction of identities, permissions, resources, state, timing and operational context.

The REL researchers experimentally isolated relational complexity from input size.

Their findings are particularly significant:

  • Low-complexity relational tasks remained solvable even with large inputs.
  • Performance deteriorated as relational arity increased.
  • Certain high-complexity tasks remained near chance-level performance regardless of input size.
  • Increasing inference-time computation and providing examples did not eliminate the degradation.

arXiv

Having access to more information is not equivalent to being able to integrate that information relationally.

This is why expanding an LLM's context window does not, by itself, solve architectural reasoning.

3.3 Compositional reasoning and error propagation

The problem becomes more severe when relationships depend on previously inferred relationships.

Suppose:

r1=f(a,b)r_1=f(a,b)
r2=g(r1,c)r_2=g(r_1,c)
r3=h(r1,r2,d)r_3=h(r_1,r_2,d)

An incorrect inference at (r1) can invalidate both subsequent relationships, even when the later inference operations are individually correct.

Dziri et al., in Faith and Fate: Limits of Transformers on Compositionality (NeurIPS 2023), investigated this phenomenon using computation graphs. Their experiments and theoretical analysis examined how errors propagate through compositional tasks and how learned pattern matching can substitute for systematic computation.

arXiv

Software architecture contains precisely these dependency structures: architectural decisions constrain subsystem decisions, which constrain interfaces, which constrain implementation.

An incorrect architectural inference may consequently produce hundreds of individually plausible but collectively incorrect implementation decisions.

3.4 Runtime semantics are another manifestation of the same difficulty

SWE-Flux investigates whether LLMs can reconstruct actual program execution across repository boundaries.

Unlike architecture-generation benchmarks, its reference answers are obtained from instrumented executions.

arXiv

Understanding what an individual function does is substantially easier for the evaluated models than determining how values, control and state propagate across interconnected functions.

The paper documents instances where models confuse static source-code associations with actual runtime dependencies.

This distinction is essential: recognizing an apparent relationship in source code is not equivalent to understanding its operational semantics.

4. Semantic compilation in practice: the Jext experiment

In the article presenting our demonstrator, Jext, we published several quantitative results that deserve further examination in light of the research discussed above.

The most interesting result is arguably not the generation of approximately 100,000 lines of code, but the production of an extensive network of relationships between requirements, architectural components and implementation methods.

An examination of the generated ReqIF document reveals the following:

Traceability relationship

Count

Use case → Requirement atom

283

Requirement atom → Component

6,772

Requirement atom → Method

25,195

Component → Method

974

Total

33,224

Of the 283 identified requirement atoms, 275 have implementation mappings (97.2%, but this part is covered better in part 2)

Figure: Actual traceability matrix extracted from the generated ReqIF document contained in the repo. Each dark cell represents a recorded relationship between a requirement atom and an implementation method. Methods are grouped by their owning components.

4.1 The significance of these relationships

In R2ABench, we saw how the identification of architectural entities does not necessarily translate into the ability to identify their relationships.

Furthermore, requirements coverage and traceability emerge as significant deficiencies even at the architectural representation level, before any implementation takes place.

In Jext, we are examining relationships that extend considerably further: from requirements to architectural components and down to individual software methods.

Formally, the requirements-to-method mapping can be expressed as:

T⊆R×MT\subseteq R\times M

Where (R) represents the requirements and (M) the implementation methods.

However, the interesting property is not simply the cardinality of this relation.

For every mapped requirement (r), method (m) and owning component (c), the generated traceability graph satisfies:

T(r,m)∧O(m,c)⇒T(r,c)T(r,m)\land O(m,c)\Rightarrow T(r,c)

All 25,195 requirements-to-method relationships satisfy this condition. Additionally, no dangling references or duplicate relationship triples can be identified among the 33,224 relationships.

This, per se, establishes a measurable property of structural consistency across different levels of engineering abstraction.

Although these results do not establish the semantic correctness of each relationship, they demonstrate that the generated engineering artifacts constitute a genuinely structurally coordinated deliverable.

4.2 Relational complexity and software engineering

The task-handoff example is also particularly relevant to the Harvard REL study.

The researchers demonstrate that relational complexity constitutes a distinct dimension of reasoning difficulty, independent of the number of entities presented to a model.

The authorization of a task handoff illustrates why this matters in software engineering. The validity of the operation depends on the joint interpretation of multiple entities, relationships, policies and contextual conditions.

The resulting decision then has consequences extending across several implementation locations.

There are therefore two distinct relational problems involved in the engineering of such a system:

  1. Establishing the relationships that determine the semantics of an operation.
  2. Preserving the implications of those relationships throughout its implementation.

The Jext experiment is particularly interesting because it provides inspectable artifacts of the second problem at considerable scale.

The generated traceability relationships, together with the observable implementation, provide a basis for examining how architectural obligations are distributed across the software system.

4.3 An engineering artifact in its own right

There is another important aspect of the generated traceability network.

The 25,195 requirements-to-method relationships represent engineering information that would ordinarily need to be established and maintained as a separate activity.

The Requirements Interchange Format (ReqIF) provides a standardized representation through which such information can be exchanged between requirements-management and engineering systems.

In regulated software engineering, the ability to establish correspondence between requirements and implementation artifacts is particularly relevant to verification, impact analysis and certification-supporting processes.

Producing this information alongside the implementation is therefore a significant result independently of code-generation performance.

4.4 When a single requirement governs an entire architectural relationship

A particularly interesting example emerges from examining the requirement ATOM-A-234-1080043EE3.This single requirement is associated with 20 architectural components and 93 implementation methods. What makes these numbers significant is the nature of the relationships involved. Authorizing a task handoff requires the coordinated interpretation of user identities, organizational memberships, role assignments, resource relationships, recipient eligibility, security policies and the current state of the task. The implications of this decision extend across multiple components and execution environments.

Figure — Selected architectural obligations associated with a single requirement, reconstructed from the generated TypeScript and Python implementation.

Inspection of the generated code reveals that browser-side permission checks do not substitute for server-side authorization, that identity admission remains distinct from resource authorization, and that recipient eligibility and resource revision are revalidated before execution. Furthermore, the ownership change, activity record and invalidation notification are coordinated within a transactional operation. Dedicated tests address recipient eligibility, authorization failures and transactional rollback.

This example is particularly relevant to both R2ABench and Harvard REL. The former identifies the difficulty of reconstructing architectural relationships; the latter investigates the difficulty of integrating multiple interdependent operands within a reasoning operation. Here, we observe not merely the identification of such relationships, but concrete manifestations of their semantics throughout the generated implementation.

The interesting result is that the semantic implications of a single requirement can be carried across multiple architectural boundaries while remaining explicitly traceable to the originating requirement. This provides a concrete illustration of semantic compilation as distinct from conventional code generation.

5. Conclusion

The research examined in this article identifies relational reasoning, compositional reasoning and the preservation of architectural constraints as substantial challenges in AI-driven software engineering.

The Jext experiment demonstrates that semantic compilation can produce a substantial software implementation accompanied by an extensive, structurally consistent network of relationships connecting requirements, components and methods.

These results do not constitute a direct evaluation against R2ABench or REL, and structural traceability should not be confused with verified functional correctness. Nevertheless, they provide concrete empirical material for investigating semantic compilation as an engineering methodology.

This extends the application of LLMs from code generation toward the coordinated engineering of complex software systems.