Skip to content

fix(build): fail fast on a non-PascalCase entity id (unenforced contract)#203

Open
agjs wants to merge 2 commits into
mainfrom
fix/validate-entity-id-contract
Open

fix(build): fail fast on a non-PascalCase entity id (unenforced contract)#203
agjs wants to merge 2 commits into
mainfrom
fix/validate-entity-id-contract

Conversation

@agjs

@agjs agjs commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Problem

The approved-plan build path fed slice.entity.id straight into toCamelCase → generated file paths (features/<camel>/…), the <camel>Routes mount identifier, i18n keys, and test ids — with no validation. The planner is only prompted for PascalCase and the plan validator (isEntitySpec) checks merely non-empty, so a malformed id like "Purchase Order" passed validation and then broke generation opaquely deep downstream (worse in headless builds, where no human reviews the plan). The resource-planner path already enforces this exact contract via isResourceId — the approved-plan path just missed it.

Fix

  • invalidEntityIds(slices) in plan-resources.ts — pure, reuses the existing isResourceId (/^[A-Z][a-zA-Z0-9]*$/u), the same contract the sibling path already enforces.
  • A fail-fast throw in runBoringstackBuild right after loadApprovedPlan, before slicesToFeatures/baseline/generation, with an actionable message naming the offending id(s). Surfaced cleanly by headless-build's top-level main().catch (stderr + exit 1) — the only non-test caller.

Enforcing strict PascalCase (not a looser identifier regex) is deliberate: it's the declared contract (plan-types.ts comment + planner prompt) and is already enforced on the resource-planner path, so this is consistency. Worst case is a clear "use PascalCase" message for a one-character fix. No gate or status-contract change.

Tests

  • invalidEntityIds unit tests (space / hyphen / leading-lowercase / leading-digit / symbol flagged, order preserved; empty list).
  • Integration test: runBoringstackBuild rejects on "Purchase Order" and — per panel advisory — spies the generators to assert zero generate/generateUi calls, zero baseline captures, and no model send, pinning the fail-fast-before-side-effects guarantee.

Review

Local 4-model harness-review panel: PASS (4/4). Round-1 raised one advisory (test didn't protect the fail-fast ordering) — incorporated; round-2 clean, zero findings.

agjs added 2 commits July 25, 2026 14:33
…ng generation downstream

The approved-plan build path fed slice.entity.id straight into toCamelCase/wireResource/
reachability/i18n keys with NO validation: the planner is only PROMPTED for PascalCase and
the plan validator (isEntitySpec) checks merely non-empty, so a malformed id like
"Purchase Order" passed and broke generation opaquely deep downstream (worse in headless,
where no human reviews the plan). The resource-planner path already enforces this exact
contract via isResourceId — the approved-plan path just missed it.

Add invalidEntityIds (reuses isResourceId) + a fail-fast throw in runBoringstackBuild before
any generation, surfaced cleanly by headless-build's top-level catch. Pure helper unit-tested;
integration test asserts the throw. No gate/status-contract change; single script caller.
…fect

Panel advisory: the throw test would still pass if generate/generateUi/baseline ran before
validation, so it didn't protect the fail-fast guarantee. Spy the generators + assert zero
calls, zero baseline captures, and no model send on the invalid-id path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant