Architecture: How to resolve the fundamental BOTH semantic overload where ...

Documentation for Sessions

πŸ—οΈ Architecture: How to resolve the fundamental BOTH semantic overload where ...

Date: 2026-03-26
Time: 18:06:41 UTC
Session: gspace1-274.4
Agent: backend
Confidence: 93%
Status: βœ… Documented


πŸ“‹ Decision Context

Question:

How to resolve the fundamental BOTH semantic overload where BOTH means both 'run both visual+code paths' AND 'auto-detect for me', causing PE generation to never trigger?

Task: S274: Add AUTO to ModuleGenOutputMode, fix BOTH semantic overload


🎯 Decision Made

Chosen:

Added AUTO='auto' to ModuleGenOutputMode enum. Replaced all 8+ default values from BOTHβ†’AUTO. Added deterministic format resolver (entities ≀10 + no complex features β†’ PE, otherwise β†’ CODE) with LLM fallback only for ambiguous cases. AUTO always resolves to exactly one concrete mode (CODE or PLATFORM_ELEMENTS) before EXECUTE phase runs.

Options Considered:

  1. Add AUTO enum and deterministic resolver (chosen)
  2. Keep BOTH overload but improve LLM decision confidence threshold
  3. Remove BOTH entirely and force explicit mode selection from frontend
  4. Add separate autoDetect boolean flag alongside outputMode

πŸ’­ Reasoning

This implements the exact design from S270 decision dev_1774534783563_v2360k6. The key insight is that BOTH has two legitimate but incompatible meanings: (1) 'generate visual metadata AND Angular code' for the execute phase, and (2) 'decide the best format for me' for the user. Adding AUTO as an explicit intent separates these. The deterministic resolver eliminates the LLM round-trip (~200 tokens, ~2-3s) for 80%+ of cases where the answer is obvious from ANALYZE output (simple CRUDs with ≀10 entities β†’ PE, complex apps β†’ CODE). LLM is only invoked for genuinely ambiguous cases. Crucially, AUTO always resolves to exactly one mode before EXECUTE, so the three-way branch in execute.phase.ts (PE vs VISUAL/BOTH vs CODE/BOTH) now receives a clean signal. This prevents the previous failure where 'both' fell into the Angular code path by default. The deterministic resolver can become wrong if: (1) entity count is a poor proxy for complexity, or (2) PE framework gains support for complex features. Early warning: track override rates from the frontend Module panel toggle.


πŸ“ Files Involved


πŸ”— Related


Auto-generated by MCP Smart Consolidation