DEV Community

CrabPascal
CrabPascal

Posted on

Audit Deep Dive: Backend Run/Build | Auditoria: backend run/build

Bilingual post · Post bilíngue

Jump to: English · Português


English {#english}

Audit Deep Dive: Backend Run/Build

Mintlify docs tour — after the technical debt backlog overview, we open Lucas's backend audit with file-level evidence.

Post-v2.16.0, the CrabPascal squad ran a structured technical audit. Lucas owned backend, runtime, codegen, and run/build parity. His findings live in Mintlify at Audit (Lucas) — Backend and feed IDs in the audit overview.

This post translates that audit into actionable context for developers choosing between run and build-exe.

What was audited

Scope included:

  • C codegen: src/codegen/mod.rs, src/project/mod.rs
  • Runtime fallbacks: src/complete_runtime.rs
  • String stubs: src/stubs.c
  • CLI build behavior without a C toolchain
  • Fixture matrix: string_conformance, class_property, dict_trygetvalue_var

Commands run during audit:

cargo test
crab-pascal run tests/fixtures/string_conformance.pas
crab-pascal build tests/fixtures/string_conformance.pas --output ...
Enter fullscreen mode Exit fullscreen mode

P0 finding: TD-RUNTIME-001 (false build success)

Evidence: src/project/mod.rs lines 192–246 — when self.compiler.is_none(), build falls back to "Runtime Interno… Executando diretamente da AST."

Impact: crab-pascal build could appear to succeed without compiling real C, masking regressions.

Sprint 10 fix: exit non-zero with clear message when no gcc/clang; parity tests with skip reason when toolchain absent.

This was the single highest-risk item in the audit's Top 10.

P0 finding: TD-CODEGEN-006 (strings ignore pascal_*)

Evidence: Generated string_conformance.c called Length("año") directly while stubs.c defines pascal_Length.

Impact: Native build either failed to link or produced wrong string semantics vs run.

Sprint 10 fix: codegen maps builtins to pascal_*; run_build_parity compares stdout when gcc exists.

P0 findings: OO codegen gaps (Sprint 13 era)

ID Evidence Impact
TD-CODEGEN-001 Properties → backing field + comment only Properties broken in C
TD-CODEGEN-002 Method body → comment + default return Methods silently wrong
TD-CODEGEN-003 try/except → "simulated" comments Exceptions fake in C

Sprint 13 addressed TD-CODEGEN-003 with honest refusal — codegen errors instead of emitting stubs. Properties and methods remain on the backlog for future sprints.

P1: runtime masking

TD-RUNTIME-002evaluate_record_access returns Integer(0) on unexpected types instead of erroring.

TD-RUNTIME-003 — method dispatch fallback returns cloned object placeholder.

Both make debugging harder. Fixtures should assert failure on invalid field access and unknown methods.

P1: TD-TEST-001 (no build parity suite)

Pre-Sprint 10, tests focused on run. Audit recommended dedicated tests/parity_* calling build and comparing stdout — implemented in Sprint 10 with graceful skip.

Developer checklist after audit

  1. Default to run for OOP, exceptions, and Horse APIs.
  2. Run parity tests locally if you have gcc/clang:
   cargo test run_build_parity
Enter fullscreen mode Exit fullscreen mode
  1. Treat build success without toolchain as failure — if you see "Runtime Interno" in output on an old binary, upgrade to v2.18.0+.
  2. Report parity bugs with both run and build-exe output attached.

Status since audit

Many P0 items partially or fully closed in Sprints 10–13. P1 runtime masking and full OO codegen remain. The audit document stays as historical evidence — do not delete; link from PRs when closing IDs.

Next in series: Bruno's parser/AST/semantic audit — Delphi surface gaps in the front-end.


Português {#portugus}

Auditoria: backend run/build

Tour Mintlify — depois da visão geral do backlog de débito, abrimos a auditoria backend de Lucas com evidência em nível de arquivo.

Pós-v2.16.0, a squad CrabPascal rodou auditoria técnica estruturada. Lucas ficou com backend, runtime, codegen e paridade run/build. Achados vivem no Mintlify em Auditoria (Lucas) — Backend e alimentam IDs na visão geral da auditoria.

Este post traduz a auditoria em contexto acionável para desenvolvedores escolhendo entre run e build-exe.

O que foi auditado

Escopo incluiu:

  • Codegen C: src/codegen/mod.rs, src/project/mod.rs
  • Fallbacks de runtime: src/complete_runtime.rs
  • Stubs de string: src/stubs.c
  • Comportamento CLI build sem toolchain C
  • Matriz de fixtures: string_conformance, class_property, dict_trygetvalue_var

Comandos rodados na auditoria:

cargo test
crab-pascal run tests/fixtures/string_conformance.pas
crab-pascal build tests/fixtures/string_conformance.pas --output ...
Enter fullscreen mode Exit fullscreen mode

Achado P0: TD-RUNTIME-001 (falso sucesso de build)

Evidência: src/project/mod.rs linhas 192–246 — quando self.compiler.is_none(), build cai em "Runtime Interno… Executando diretamente da AST."

Impacto: crab-pascal build podia parecer sucesso sem compilar C real, mascarando regressões.

Fix Sprint 10: exit ≠ 0 com mensagem clara sem gcc/clang; testes de paridade com skip quando toolchain ausente.

Foi o item de maior risco no Top 10 da auditoria.

Achado P0: TD-CODEGEN-006 (strings ignoram pascal_*)

Evidência: string_conformance.c gerado chamava Length("año") diretamente enquanto stubs.c define pascal_Length.

Impacto: Build nativo falhava no link ou produzia semântica de string errada vs run.

Fix Sprint 10: codegen mapeia builtins para pascal_*; run_build_parity compara stdout quando gcc existe.

Achados P0: gaps de codegen OO (era Sprint 13)

ID Evidência Impacto
TD-CODEGEN-001 Properties → só backing field + comentário Properties quebradas no C
TD-CODEGEN-002 Corpo de método → comentário + return default Métodos errados silenciosamente
TD-CODEGEN-003 try/except → comentários "simulated" Exceções falsas no C

Sprint 13 endereçou TD-CODEGEN-003 com recusa honesta — codegen erra em vez de emitir stubs. Properties e métodos permanecem no backlog para sprints futuros.

P1: mascaramento no runtime

TD-RUNTIME-002evaluate_record_access retorna Integer(0) em tipos inesperados em vez de erro.

TD-RUNTIME-003 — fallback de dispatch de método retorna placeholder clonado do objeto.

Ambos dificultam debug. Fixtures devem assertar falha em acesso a field inválido e métodos desconhecidos.

P1: TD-TEST-001 (sem suite de paridade build)

Pré-Sprint 10, testes focavam run. Auditoria recomendou tests/parity_* dedicados chamando build e comparando stdout — implementado no Sprint 10 com skip gracioso.

Checklist do desenvolvedor pós-auditoria

  1. Prefira run para OOP, exceções e APIs Horse.
  2. Rode testes de paridade localmente se tiver gcc/clang:
   cargo test run_build_parity
Enter fullscreen mode Exit fullscreen mode
  1. Trate sucesso de build sem toolchain como falha — se vir "Runtime Interno" em binário antigo, atualize para v2.18.0+.
  2. Reporte bugs de paridade com output de run e build-exe anexados.

Status desde a auditoria

Vários P0 parcial ou totalmente fechados nos Sprints 10–13. Mascaramento P1 no runtime e codegen OO completo permanecem. O doc de auditoria fica como evidência histórica — não apague; linke de PRs ao fechar IDs.

Próximo na série: auditoria parser/AST/semântica de Bruno — gaps de superfície Delphi no front-end.


Published on dev.to/@crabpascal · Código em CrabPascal

Top comments (0)