test: prefer SGS hall entrance anchors

This commit is contained in:
lyf
2026-06-30 00:24:08 +08:00
parent c2800bb277
commit e826c92486
2 changed files with 55 additions and 48 deletions

View File

@@ -4,40 +4,41 @@ Status: DONE
Files changed:
- `scripts/check-sgs-hall-poi-adapter.mjs`
- `.superpowers/sdd/task-1-report.md`
Commands run:
- `node scripts/check-sgs-hall-poi-adapter.mjs`
Output summary:
- Smoke script passed. Script now validates:
1. Finding 1: entrance-derived sourceConfidence branch — entrance-backed halls with nodeId must be `backend-sgs-sdk-hall-entrance`
2. Finding 2: enforce entrance/reachable-node semantics — entrances without nodeId that match spaces use space-center sourceConfidence, not hall-entrance
3. Finding 3: avoid hiding duplicate names via Map-by-name only — added assertion that result names are unique, indexed by both name and id for duplicate detection
1. **Finding 1 (FIXED)**: Existing hall POI created from space.center is upgraded when a later entrance has BOTH position and nodeId. Main position, sourceConfidence, and sourceObjectName reflect the real entrance. Upgrade logic added to existing POI handler.
2. **Finding 2 (FIXED)**: Removed over-spec assertion requiring globally unique POI names. Now uses ID-based assertions and maps (byId) to avoid hiding duplicates by name. Assertions reference byId instead of byName for structure validation.
3. **Finding 3 (FIXED)**: Adjusted fixtures so 地球科学展厅 first has a no-coordinate entrance (place 104, fallback to space-center), then a later normalized name entrance (place 109, with nodeId and coordinates) that upgrades to entrance-backed sourceConfidence.
4. Whitelist enforcement prevents unrelated types
5. Unmatched exhibition space with center emits fallback POI
6. Entrance with missing coordinates falls back to matched space.center
7. Entrance still recorded even with undefined positionGltf (no coordinates)
8. **Issue 1 fix**: `backend-sgs-sdk-hall-entrance` sourceConfidence now requires BOTH valid entrance position AND nodeId. Places with coordinates but no nodeId use `backend-sgs-sdk-space-center` instead.
9. **Issue 2 fixture**: Added place 108 (自然科学展厅【主】出入口1) with coordinates but no nodeId, verifying it matches space center [110, 0, 120] and uses `backend-sgs-sdk-space-center` sourceConfidence, not entrance coordinates.
10. **Issue 3 fixture**: Added place 109 (地球 科学 展厅 (主)出入口 1) with spacing and brackets to test name normalization matching — successfully matches space 7 despite formatting differences.
11. **Issue 4 coverage**: Unmatched exhibition space fallback (space 4: 展览坡道) still emits POI with space-center semantics.
8. POI upgrade mechanism: entrance position, sourceConfidence, and sourceObjectName updated on second entrance if it has BOTH nodeId and coordinates
9. Place 108 (自然科学展厅【主】出入口1) with coordinates but no nodeId merges without changing sourceConfidence
10. Place 109 (地球 科学 展厅 (主)出入口 1) with spacing/brackets and nodeId/coordinates successfully upgrades 地球科学展厅 POI
11. ID-based uniqueness validation prevents silent duplicate masking
Commits created:
- `test: refine SGS hall POI source semantics`
- `test: prefer SGS hall entrance anchors`
Self-review notes:
- The semantic gap fix ensures sourceConfidence correctly requires BOTH position and nodeId for hall-entrance classification
- Fixture 108 validates the space-center fallback for entries with coordinates but no routing identity
- Fixture 109 demonstrates that name normalization handles real-world formatting variations (spacing, brackets, punctuation)
- All fixtures consolidate into existing POIs, maintaining clean POI count (7) while improving semantic coverage
- The script is standalone Node coverage for the intended adapter rules because this repository has no configured test runner
- The production adapter implementation is covered by Task 2 in the plan
- Fixtures now include:
- Space 8 (古生物展厅) with entrance 105 that has nodeId n105 for backend-sgs-sdk-hall-entrance assertion
- Place 107 (自然科学展厅 出入口) without nodeId to assert space-center semantics when entrance lacks routing identity
- Place 108 (自然科学展厅【主】出入口1) with coordinates but no nodeId verifying space.center position precedence
- Place 109 (地球 科学 展厅 (主)出入口 1) with spacing/brackets demonstrating name matching robustness
- Name uniqueness validation prevents silent duplicate masking
Implementation details:
- Added upgrade logic in toHallPois: when existing POI is found and later entrance has entrancePosition && place.nodeId, update positionGltf, sourceConfidence, and sourceObjectName
- sourceObjectName field added to POI object to track the entrance that provided/upgraded the position
- Replaced name-based assertions with ID-based assertions for 7 expected halls
- Fixture order: place 104 (no-coord) creates POI with space-center, then place 109 (with nodeId) upgrades it to entrance-backed
Test results:
- All 7 halls correctly identified and merged
- 地球科学展厅 correctly upgraded from space-center to backend-sgs-sdk-hall-entrance on place 109
- Both entrances (104 and 109) recorded in entrances array
- sourceConfidence and positionGltf reflect entrance 109 after upgrade
- ID uniqueness maintained across all POIs
Concerns:
- None.