Cross-Cutting Concerns Analysis

Purpose: Identifies architectural concerns that span multiple layers and must be designed cohesively upfront.

Document Type: Architecture Risk Assessment & Design Priority Matrix

Last Updated: 2025-11-06


Ranked Concerns

Cross-cutting concerns ranked by Correctness Impact, Complexity, Cross-Layer Penetration, Performance Impact, and Developer Experience.

See Guidelines.md for criteria definitions and scoring legend.


1. Event Ordering Contract ⭐⭐⭐⭐⭐ (Priority: Critical)

Scores: Correctness (10/10) · Complexity (9/10) · Cross-Layer (10/10) · Performance (7/10) · DevEx (8/10)

Affected Layers: Luny abstractions, LunyScript runtime, all engine adapters

Risk Profile:

Requirements:

Design Now: Must be designed before implementation begins. Cannot be changed without breaking all user code.


2. Object/Node/Actor Registration System ⭐⭐⭐⭐⭐ (Priority: Critical)

Scores: Correctness (9/10) · Complexity (10/10) · Cross-Layer (9/10) · Performance (9/10) · DevEx (7/10)

Affected Layers: LunyScript core, all engine adapters

Risk Profile:

Requirements:

Dependencies: Required by event dispatch, lifecycle management, queries, serialization

Design Now: Core contracts must be established upfront. Poor design creates permanent performance bottlenecks.


3. Memory Management Strategy ⭐⭐⭐⭐ (Priority: High)

Scores: Correctness (8/10) · Complexity (7/10) · Cross-Layer (7/10) · Performance (10/10) · DevEx (6/10)

Affected Layers: LunyScript core, engine-specific pooling strategies

Risk Profile:

Requirements:

Dependencies: Ties into registration, object lifecycle, serialization

Design Now: Pooling architecture and ownership rules must be defined before implementation. Retrofitting is expensive.


4. Execution Tracing & Profiling Hooks ⭐⭐⭐⭐ (Priority: High)

Scores: Correctness (5/10) · Complexity (8/10) · Cross-Layer (8/10) · Performance (8/10) · DevEx (10/10)

Affected Layers: Every execution path in LunyScript, optional adapter hooks

Risk Profile:

Requirements:

Data to Expose:

Design Now: Hook points must be designed into architecture from the start.


5. Error Handling & Recovery ⭐⭐⭐⭐ (Priority: High)

Scores: Correctness (8/10) · Complexity (6/10) · Cross-Layer (8/10) · Performance (5/10) · DevEx (9/10)

Affected Layers: Luny error contracts, LunyScript handling, engine-specific reporting

Risk Profile:

Requirements:

Dependencies: Interacts with event ordering, execution model, registration

Design Now: Error boundaries and propagation rules must be established before writing core logic.


6. Concurrency Model ⭐⭐⭐ (Priority: Medium - Future-Proof)

Scores: Correctness (9/10) · Complexity (9/10) · Cross-Layer (6/10) · Performance (7/10) · DevEx (6/10)

Affected Layers: Luny async abstractions, LunyScript threading rules, adapter implementations

Risk Profile:

Requirements:

Design Later: Can start single-threaded. Design async hooks into abstractions for future expansion.


7. Serialization & Hot Reload ⭐⭐⭐ (Priority: Medium - Developer Quality)

Scores: Correctness (6/10) · Complexity (7/10) · Cross-Layer (6/10) · Performance (4/10) · DevEx (8/10)

Affected Layers: LunyScript runtime state, engine-specific serializers

Risk Profile:

Requirements:

Design Later: Nice-to-have. Can be bolted on after core runtime is stable.


8. API Versioning & Compatibility ⭐⭐ (Priority: Low - Deferred)

Scores: Correctness (7/10) · Complexity (6/10) · Cross-Layer (10/10) · Performance (1/10) · DevEx (7/10)

Affected Layers: All public APIs across all layers

Risk Profile:

Requirements:

Design Later: Establish versioning scheme early but don’t constrain initial design. Implement migration tools after API stabilizes.


Design Priority Matrix

Must Design Now (Before Implementation)

Reason: Changing these later requires major refactoring or breaks existing code.

  1. Event Ordering Contract - Correctness foundation
  2. Object Registration System - Performance foundation
  3. Memory Management Strategy - Prevents permanent bottlenecks
  4. Execution Tracing Hooks - Cannot retrofit without invasive changes
  5. Error Handling & Recovery - Required for usable MVP

Can Design Later (Incremental Addition)

Reason: Can be added without breaking existing architecture.

  1. Concurrency Model - Start single-threaded, add async later
  2. Serialization & Hot Reload - Quality-of-life feature
  3. API Versioning - Implement after API stabilizes

Cross-Layer Dependency Graph

Event Ordering Contract
    ├── Object Registration (requires ordered lifecycle)
    ├── Error Handling (requires atomic phases)
    └── Memory Management (requires cleanup phases)

Object Registration System
    ├── Event Dispatch (requires object lookup)
    ├── Serialization (requires stable IDs)
    └── Profiling Hooks (requires object identity)

Memory Management
    ├── Object Registration (requires pooling integration)
    └── Serialization (requires ownership clarity)

Execution Tracing
    └── (observes all other systems)

Key Insight: Event Ordering + Object Registration + Memory Management form tightly coupled core. Must be designed together.


Risk Levels