fix: remove design-debt shims — falsy ID bug, selector normalization, concurrency, exception swallowing
pipeline.ts: || undefined → ?? undefined (9 occurrences) - || converts valid subject ID 0 to undefined because 0 is falsy in JS. This broke clause witnesses and topology references for the first subject. domain-index.ts: remove .toLowerCase() on CSS selectors - CSS selectors are case-sensitive (IDs, class names, attribute values). Lowercasing on lookup but not on storage (selectorIndex) meant case- sensitive selectors never matched — returning empty arrays silently. canonical.ts: add warning when visualBoxes falls back to layout boxes - visualBoxes ?? boxes silently substituted layout coordinates for visual space, producing incorrect results for transform-dependent assertions. Now emits console.warn so silent data corruption is visible. extraction.ts: serialize materializeSemanticSelector calls (3 sites) - Changed Promise.all over page.evaluate() to sequential for..of. While Playwright serializes CDP calls internally, concurrent DOM-modifying evaluate() calls create undefined execution order. Sequential resolution eliminates theoretical race conditions for semantic selector injection. engine.ts: include stack trace in evaluator exception diagnostics - Catch-all converted ALL exceptions (including TypeError from programming bugs) to IMH_EVALUATOR_EXCEPTION with just err.message. Now includes stack trace and logs to console.warn for visibility. Distinguishes TypeError (programming bug) from other evaluation errors. 648 SDK tests + 57 E2E hard tests pass, zero regressions.
This commit is contained in:
@@ -778,7 +778,9 @@ export function adaptSolverWorldToCanonical(
|
||||
matrices: solverWorld.matrices ?? { values: [] },
|
||||
rects: solverWorld.rects,
|
||||
boxes: solverWorld.boxes,
|
||||
visualBoxes: solverWorld.visualBoxes ?? solverWorld.boxes,
|
||||
visualBoxes: solverWorld.visualBoxes && solverWorld.visualBoxes.boxId.length > 0
|
||||
? solverWorld.visualBoxes
|
||||
: (console.warn('[imhotep-core] adaptSolverWorldToCanonical: visualBoxes missing, falling back to layout boxes. Visual-space assertions may produce incorrect results.'), solverWorld.boxes),
|
||||
fragments: {
|
||||
fragmentId: [],
|
||||
subjectId: [],
|
||||
|
||||
@@ -802,8 +802,8 @@ export function executionIrToClauseDescriptors(context: ExecutionContext): Claus
|
||||
clauseKind: 'unknown',
|
||||
version: 1,
|
||||
subjectRef: executionIr.clauseSubject[i],
|
||||
referenceRef: executionIr.clauseReference[i] || undefined,
|
||||
frameRef: executionIr.clauseFrame[i] || undefined,
|
||||
referenceRef: executionIr.clauseReference[i] ?? undefined,
|
||||
frameRef: executionIr.clauseFrame[i] ?? undefined,
|
||||
options: { unsupported: true, rawType: clauseType },
|
||||
})
|
||||
continue
|
||||
@@ -837,13 +837,13 @@ export function executionIrToClauseDescriptors(context: ExecutionContext): Claus
|
||||
clauseId: `clause_${i}`,
|
||||
clauseKind,
|
||||
version: 1,
|
||||
subjectRef: subjectRef || undefined,
|
||||
referenceRef: referenceRef || undefined,
|
||||
frameRef: executionIr.clauseFrame[i] || undefined,
|
||||
stateRef: context.stateIds[executionIr.clauseState[i]] || undefined,
|
||||
timelineRef: context.timelineIds[executionIr.clauseTimeline[i]] || undefined,
|
||||
envGuardRef: context.envGuardIds[executionIr.clauseEnvGuard[i]] || undefined,
|
||||
toleranceRef: context.toleranceIds[executionIr.clauseTolerance[i]] || undefined,
|
||||
subjectRef: subjectRef ?? undefined,
|
||||
referenceRef: referenceRef ?? undefined,
|
||||
frameRef: executionIr.clauseFrame[i] ?? undefined,
|
||||
stateRef: context.stateIds[executionIr.clauseState[i]] ?? undefined,
|
||||
timelineRef: context.timelineIds[executionIr.clauseTimeline[i]] ?? undefined,
|
||||
envGuardRef: context.envGuardIds[executionIr.clauseEnvGuard[i]] ?? undefined,
|
||||
toleranceRef: context.toleranceIds[executionIr.clauseTolerance[i]] ?? undefined,
|
||||
bounds: Object.keys(bounds).length > 0 ? bounds : undefined,
|
||||
options: Object.keys(options).length > 0 ? options : undefined,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user