Skip to content
VerificationWould you notice if your agent drifted in production?Explore the 5-stage harness›
Architecture Internals

Compiler architecture and path ownership

This section documents the internal engineering design of the Aegil compiler itself (bin/, lib/compiler/, lib/templates/, and tool/). Emitters operate as pure in-memory planning functions, OwnershipPolicy validates every path before ProjectWriter commits bytes to disk, and .aegil/manifest.json locks generated artifacts with deterministic 64-bit FNV-1a checksums.

Layer Path Responsibility
Config lib/compiler/config/project_config.dart Parses aegil.yaml without third-party dependencies, validating name, namespace, layout, exact toolchain pins, and paths.
Frontend lib/compiler/frontend/ SpecLoader merges specs/**/*.tsp in sorted order; SpecPodParser, AppParser, and PlatformParser compile entities, CEL policies, state machines, @app, and @platform into SpecPodIr.
Layout lib/compiler/layout/project_layout.dart Single source of truth for directory paths (server/, generated/, client/, hooks/) versus Dart package names (<name>_server, <name>_client, <name>_flutter, <name>_hooks).
Platforms lib/compiler/platforms/permission_registry.dart Maps abstract @permission declarations to Android manifest entries, iOS and macOS Info.plist usage keys, and macOS entitlements across the four @platform targets.
Emitters lib/compiler/emitters/ Pure generators (ServerpodShellEmitter, ServerpodMonorepoEmitter, FlutterShellEmitter, PlatformShellEmitter, IntegrationTestEmitter, GitignoreEmitter, SecretsEmitter) that take ProjectConfig + SpecPodIr and return PlannedFile lists.
Harness lib/compiler/harness/ OutputPlan, OwnershipPolicy, ProjectWriter, AegilManifestManager, ToolchainResolver, IntegrationRunner, ProjectInitializer.

Generated files must be byte-identical across machines and years:

  • Emitters never emit timestamps, current years, random values, or absolute paths into FileOwner.generated or FileOwner.toolManaged files.
  • User-supplied strings (displayName, permission reason) are escaped for the file format they enter:
    • .tsp decorator strings: ProjectInitializer.escapeSpecString (\ and ")
    • YAML double-quoted strings: _yamlQuote (\ and ")
    • Dart single-quoted literals: _dartString (\, ', and $)
    • XML / Info.plist / AndroidManifest.xml / HTML: _xml (&, <, >, ", ')
    • .xcconfig: replaceAll('//', '/ /') so // cannot start a comment
    • JSON: jsonEncode