---
id: PLN-0007
ticket: world-stage-editor-sync
title: World Stage Sync Validation
status: open
created: 2026-06-21
completed:
tags:
  - validation
  - world-editor
  - stage-editor
---

## Objective

Add validation for missing, mismatched, and outdated `StageDefinition` sync state.

## Background

`DEC-0002` requires warnings for missing `StageDefinition`, errors for assets synced to another world stage id, and warnings for outdated contract hash.

## Decisions of Origin

- `DEC-0002`: World Editor / Stage Editor Sync V1.

## Scope

### Included

- World Editor validation for missing `StageDefinition`.
- World Editor validation for mismatched `worldStageId`.
- World Editor validation for stale `contractHash`.
- Stage Editor display of passive sync state if the sync data is present.

### Excluded

- Endpoint implementation marker validation.
- Runtime Journey validation changes.
- Migration of temporary prototype assets.

## Execution Steps

### Step 1 - Add hash recomputation entry point

**What:** Make contract hash recomputation reusable by validation.

**How:** Expose a method on `StageDefinitionSyncer` or a related helper that computes the expected hash for a world stage without mutating the `StageDefinition`.

**File(s):**

- `Assets/Scripts/Editor/GON/WorldEditor/StageDefinitionSyncer.cs`

### Step 2 - Extend WorldLayoutValidator

**What:** Validate StageDefinition sync state from the World Editor.

**How:** In `WorldLayoutValidator.ValidateStages`, check each world stage:

- if `stageDefinition` is null, emit warning;
- if assigned sync data has a non-empty `worldStageId` different from the world stage id, emit error;
- if assigned sync data hash differs from recomputed hash, emit warning.

**File(s):**

- `Assets/Scripts/Editor/GON/WorldEditor/WorldLayoutValidator.cs`

### Step 3 - Improve validation messages

**What:** Make validation messages actionable.

**How:** Include the world stage id as `objectId` and message text that says whether the fix is create, sync, or reassign the `StageDefinition`.

**File(s):**

- `Assets/Scripts/Editor/GON/WorldEditor/WorldValidation.cs`
- `Assets/Scripts/Editor/GON/WorldEditor/WorldLayoutValidator.cs`

### Step 4 - Show sync state in Stage Editor inspector

**What:** Show passive sync state on `StageDefinition`.

**How:** In `StageInspectorPanel.BuildStageInspector`, add a read-only `World Sync` section showing:

- not synced;
- synced world stage id and display name;
- world stage kind;
- sync timestamp;
- contract hash or short hash.

**File(s):**

- `Assets/Scripts/Editor/GON/StageEditor/StageInspectorPanel.cs`

## Test Requirements

### Unit Tests

- None required unless editor tests are available.

### Integration Tests

- Compile `Assembly-CSharp-Editor`.

### Manual Verification

- Validate a world stage with no `StageDefinition`; confirm warning.
- Assign a `StageDefinition` synced to a different stage id; confirm error.
- Modify a world stage after sync; confirm stale hash warning.
- Re-sync; confirm stale warning disappears.
- Open Stage Editor and confirm sync state is visible.

## Acceptance Criteria

- [ ] Missing `StageDefinition` emits warning.
- [ ] Mismatched `worldStageId` emits error.
- [ ] Outdated hash emits warning.
- [ ] Stage Editor inspector shows passive sync state.
- [ ] No marker implementation validation is introduced.
- [ ] `Assembly-CSharp-Editor` compiles.

## Dependencies

- `PLN-0005` must be implemented first.
- `PLN-0006` should be implemented before full manual validation.

## Risks

- If hash computation is not deterministic, stale warnings will be noisy.
- Existing prototype assets may warn or error; DEC-0002 allows discarding or recreating temporary assets.
