Skip to content

feat: implement Spatial Integrity Filter for zero-overlap layouts - #27

Open
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
jules/spatial-integrity-filter-js1-32af5416-bb74-43bb-b355-9816dd59a00c
Open

google-labs-jules[bot] wants to merge 1 commit into
mainfrom
jules/spatial-integrity-filter-js1-32af5416-bb74-43bb-b355-9816dd59a00c

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

Context & Rationale

Currently, our design simulator uses an additive scoring model where high-value features can mask fatal layout errors, such as component overlaps. This allows technically broken or unusable layouts to pass audits with mediocre scores instead of being outright rejected.

To improve the technical feasibility of generated layouts, we are introducing a Spatial Integrity Filter. By applying a strict zero-score penalty to any design with detected spatial collisions, we guarantee that only physically valid layouts pass the audit process, without requiring complex and high-risk MCTS refactoring.


Key Changes

1. Broadened Collision Detection

  • Removed the hasInteractive constraint inside the layout auditor. The collision detection engine now evaluates bounding box coordinates for all mapped DOM elements to ensure comprehensive spatial integrity.

2. Repaired Bounding Box Calculus

  • Modified estimateElementCoordinates to track a global maxY cursor, preventing sequentially processed wrapper elements (such as <main> and <section>) from incorrectly registering overlaps.
  • Fixed an issue with bento cell cardIndex assignments that forced identical tags into identical coordinates.
  • Removed artificial coordinate clamping (y = Math.min(y, 800)), which was causing components located outside the viewport to mathematically stack up and trigger false-positive collisions.

3. Score Override & Audit Integrity

  • Integrated a post-simulation check into the MCTS parser (design-mcts.js). When a spatial violation is flagged, the parser intercepts the pipeline to force an aggregate design score of exactly 0.
  • Updated the CLI audit output to explicitly report [SPATIAL_VIOLATION] along with the exact element IDs involved in the collision for easier debugging and developer auditing.

Acceptance Criteria Verified

  • Any design output with bounding box collisions receives a final aggregate score of 0.
  • Non-overlapping layouts continue to use standard additive scoring without interference.
  • CLI logs clearly output the specific element IDs that caused the spatial violation.
  • Validation is executed post-simulation to ensure no increase in simulation run times.

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.

0 participants