Skip to content

fix(web): 3D orphan preflight must return the string error, not the preflight object - #94

Merged
diegokingston merged 1 commit into
mainfrom
fix/3d-disconnected-return
Jul 31, 2026
Merged

fix(web): 3D orphan preflight must return the string error, not the preflight object#94
diegokingston merged 1 commit into
mainfrom
fix/3d-disconnected-return

Conversation

@diegokingston

Copy link
Copy Markdown
Collaborator

Confirma el defecto reportado por QA sobre origin/main (introducido por 85a74c9, el fix de preflight-parity de PR #75):

Defecto

La rama de nodo desconectado de prepareSolve3D (antes cuerpo inline de validateAndSolve3D) retornaba { error, connectedNodes } — el shape del helper preflightModel2D (2D) — donde el contrato declarado es SolverInput3D | string | null.

src/lib/engine/solver-service.ts(1564,16): error TS2353: Object literal may only
specify known properties, and 'error' does not exist in type 'SolverInput3D'.

Impacto en runtime

Los callers detectan falla con typeof result === 'string', así que el objeto pasaba el guard:

Escapó CI porque main no corre typecheck gate (el build de vite no typecheckea).

Fix

La rama retorna el string plano, como todas sus hermanas. El shape { error, connectedNodes } queda interno a preflightModel2D (2D), cuyo contrato es válido. Verificado: TS2353 eliminado de tsc --noEmit.

Regresión

Dos tests nuevos en el control negativo de constraint-connectivity.test.ts: modelo 3D con nodo huérfano asserta el error string correcto tanto en validateAndSolve3D como en validateAndSolve3DAsync (esta última pre-fix tiraba TypeError).

Suite engine+store: 90 files, 2250 passed, 0 failed.

…reflight object

PR #75's preflight-parity commit (85a74c9) left a
{ error, connectedNodes } return inside the 3D disconnected-node branch,
where the declared contract is SolverInput3D | string | null (now
prepareSolve3D). tsc reports TS2353; main's CI has no typecheck gate, so
it slipped through.

Runtime impact: callers detect failure with typeof result === 'string',
so the object sailed past the guard. The sync path then fed the object
into the WASM solver (confusing parse error instead of the orphan
message); the async path (PR #77) crashed inside input3DToWireObject on
input.nodes === undefined.

Fix: return the plain error string, mirroring every sibling branch; the
{ error, connectedNodes } shape stays internal to preflightModel2D (2D),
whose contract is valid.

Regression coverage: orphan 3D model asserts the STRING error on both
validateAndSolve3D and validateAndSolve3DAsync
(constraint-connectivity.test.ts negative control).
@diegokingston
diegokingston merged commit 264f01c into main Jul 31, 2026
6 checks passed
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.

1 participant