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

Do's and Don'ts

These architectural guardrails outline the rules of engagement across specifications, server hooks, Flutter client development, and security boundaries. Following these guidelines ensures your application remains mathematically verified, zero-trust secure, and free of architectural drift.

DO DON’T
DO place all business domain specs inside feature folders: specs/<feature>/*.tsp (e.g. specs/notes/notes.tsp, specs/helpdesk/tickets.tsp). DON’T place domain specs directly in the specs/ root directory. Only app.tsp and platforms.tsp belong at the root; anything else triggers ERR_SPEC_MISPLACED.
DO edit files in Zone 1 (specs/) and Zone 2 (client/lib/**, hooks/**, migrations/**). DON’T ever edit files under .aegil/ (Zone 3). All generated code is hash-locked; modifying it triggers ERR_TAMPERED_GENERATED_FILE.
DO run aegil build whenever you edit TypeSpec specifications or server hooks. DON’T run aegil verify without building first (ERR_STALE_BUILD or ERR_STALE_HOOK_MIRROR).
DO use aegil migrate --name <label> to generate committed database migrations when schema models change. DON’T manually write or edit SQL migrations in .aegil/server/migrations/.

DO DON’T
DO derive caller identity (auth.id) and role (auth.role) strictly from the server-validated session. DON’T ever accept caller identity or role parameters from the client (e.g. actingUserId, callerRole). Doing so creates severe privilege escalation vulnerabilities.
DO enforce row-level access control via declarative CEL policies (@policy), which compile directly into PostgreSQL WHERE clauses. DON’T fetch entire tables into memory to filter access in Dart code. Database-level RLS protects memory and prevents cross-tenant data leaks.
DO designate the primary user ownership field on models with @owner (e.g. @owner reporterId: uuid;). DON’T rely on manual, per-endpoint assignments to track resource ownership.
DO explicitly annotate unauthenticated endpoints with @public if they are intended for guest access. DON’T attempt to read auth.id or auth.role inside a @public operation (ERR_PUBLIC_AUTH_CONFLICT).

DO DON’T
DO import backend models, clients, and BLoCs strictly through the public barrel: package:<app>_flutter/api.dart. DON’T import directly from internal generated paths like .aegil/client/lib/src/.... This is strictly forbidden and triggers ERR_UI_BOUNDARY_VIOLATION.
DO use generated feature BLoCs (<Entity>Bloc) and BlocBuilder to handle queries, mutations, and optimistic updates. DON’T create manual HTTP or WebSocket clients for endpoints that Aegil already generates.
DO wrap protected UI routes in SignInGate(client: client, child: ...) to automatically handle session gates. DON’T write bespoke login-check wrappers on individual widgets.
DO use @permission in specs/platforms.tsp whenever your Flutter app needs native device capabilities (camera, microphone, location). DON’T manually edit native platform manifest files like Info.plist or AndroidManifest.xml in .aegil/client/.

DO DON’T
DO rely on compiler-guaranteed preconditions: when your hook’s execute() runs, authentication, database transactions, entity prefetching, policy permissions, and state machine validation are already guaranteed. DON’T re-check user authentication or duplicate authorization checks inside hook code.
DO apply required state machine transitions and save changes using the provided Transaction tx: await Ticket.db.updateRow(session, updated, transaction: tx);. DON’T open a new, unmanaged database transaction or perform unawaited database writes.
DO run aegil build after editing any hook file to mirror changes into the server. DON’T run aegil verify immediately after editing a hook without building (ERR_STALE_HOOK_MIRROR).

DO DON’T
DO instruct agents to follow the 3-step loop: Edit spec $\rightarrow$ aegil build --agent $\rightarrow$ Implement hooks $\rightarrow$ aegil verify --agent. DON’T allow agents to edit .aegil/ or tamper with generated checksums.
DO use aegil context --feature <name> to provide compact, high-density token context to agents without reading full source files. DON’T pipe entire generated directories into agent context windows.
DO require status "VERIFIED" before considering any agent task complete. DON’T accept "VERIFIED_PARTIAL" (which skipped Docker integration tests) as completed work.