Skip to content

Extract shared project compilation orchestration from the CLI #671

Description

@cssbruno

Priority

High

Context

cmd/gowdk/build.go currently coordinates configuration loading, source discovery, parsing, IR assembly, Go binding, compiler validation, contract scanning, security auditing, static generation, AsyncAPI generation, generated-app output, binary/WASM compilation, Docker output, and deployment recipes.

A separate orchestration path in internal/lang.CheckFilesWithOptions performs parsing, assembly, enrichment, validation, accessibility checks, and contract scanning for check and tooling flows.

Problem

Compiler behavior is duplicated across command paths. check, build, dev, LSP, inspect, manifest, sitemap, and audit can gain different validation coverage or ordering as features are added. The CLI also carries application-service responsibilities that are difficult to test independently of flag and process handling.

Proposed direction

Introduce shared workspace/application services, for example:

internal/workspace
  LoadProject
  CompileSnapshot
  ValidateSnapshot
  PlanApplication

internal/publish
  PublishStatic
  PublishGeneratedApp
  BuildBinary

The CLI should parse flags, invoke these services, stream structured diagnostics/events, and format results. LSP and other tooling should reuse the same snapshot and validation pipeline.

Acceptance criteria

  • There is one canonical project compilation pipeline from loaded config and source set through validated snapshot.
  • build, check, dev, LSP, inspect, manifest, sitemap, routes/endpoints, and audit reuse that pipeline or an explicitly documented subset.
  • Contract scanning, Go binding, accessibility checks, security validation, and feature validation have a single owning stage.
  • CLI packages no longer directly coordinate individual parser/compiler/generator subsystems.
  • Compiler services return structured diagnostics and events without writing directly to stdout/stderr.
  • The compiled snapshot can be cached and reused by multiple outputs in one command.
  • Unit tests exercise orchestration without invoking the CLI process.
  • Integration tests prove gowdk check and gowdk build agree on source validity.

Related

#667 should define the phase-typed snapshot and plan consumed by this service. #669 should own transactional publication.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions