Refactor solver and UI code, add tests, improve configuration - #7
Merged
Conversation
- dilateMask/erodeMask no longer mutate their input mask when run for multiple iterations (previously corrupted surfaceMask in the open-mesh voxelization fallback and any multi-voxel thickness enforcement) - force and load-case ids derive from the max existing id instead of array length, so deleting an entry can no longer mint a duplicate id - constraint region ids are keyed by the group's smallest face index so load-case fixed-region references stay attached to the same physical region when painting adds/removes groups earlier in face order - browser quality profile resolution estimates memory from the requested profile's voxel target instead of a hardcoded high-fidelity count - connector segments and connector mask are computed once per solve instead of once per variant; truss boost reuses the same segments - worker message omits the encoded model base64 (worker solves from the transferred position buffer only) - right-click clear listeners scoped to the canvas instead of window - BFS in minSurfaceHops uses an index cursor instead of Array.shift - remove dead code: unused truss/connection-graph builders, unused exports (lerp, volumeOfOccupancy, gatherPositionsByFaces, etc.), duplicate vite.config.js that shadowed vite.config.ts, orphaned tsconfig.node.json - tests: voxel morphology non-mutation, quality resolution, stable region ids, sequential id minting https://claude.ai/code/session_01EjrufiVyciihwDSSqtjxfd
- replace deprecated on_event startup with a lifespan handler and shut
down the JobManager thread pool on app shutdown
- disable CORS allow_credentials: the API is unauthenticated and
cookie-free, and wildcard origins with credentials is an insecure
combination
- open SQLite in WAL mode with a busy timeout (worker threads update job
progress while request handlers poll) and roll back on errors
- POST /studies/{id}/run accepts an absent body, matching the documented
'optional run options' contract (previously 422)
- replace deprecated trimesh Scene.dump(concatenate=True) with
Scene.to_geometry()
- vectorize world->voxel index mapping (was inverting the 4x4 transform
once per preserved/fixed face center)
- allow OPENTOS_DATA_DIR / OPENTOS_MAX_WORKERS env overrides with
unchanged defaults; gitignore runtime SQLite files
- log job failures via logging instead of traceback.print_exc; remove
never-written baseline/ and reports/ study directories
- remove dead validate_solve_payload shim; deduplicate outcome row
parsing in the repository
- tests: repository job/outcome round-trips, bodyless run request
https://claude.ai/code/session_01EjrufiVyciihwDSSqtjxfd
- GitHub Actions: web typecheck/test/build on Node 22, API pytest on Python 3.11 - document OPENTOS_DATA_DIR / OPENTOS_MAX_WORKERS overrides in the API README and link them from the root README - fix stale /api/solve reference in the web .env.example https://claude.ai/code/session_01EjrufiVyciihwDSSqtjxfd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR consolidates duplicated code across the solver and UI layers, adds comprehensive test coverage, improves configuration handling, and fixes several bugs in mask morphology operations and region ID generation.
Key Changes
Solver & Geometry Refactoring
mesh.tsandsolverWorker.ts, consolidating into a singlebuildConnectorSegments()function insolverWorker.tsvoxel.ts:nearestDomainPoint(),paintTubeSample(),paintTubeSegment(), andrasterizeConnectionGraph()(dead code)mesh.ts:buildOrganicTrussGeometry(),makeNodeSphere(),makeEdgeCylinder(), and related helpersgeometry.ts:toNonIndexedGeometryFromPositions()andgatherPositionsByFaces()estimateSolverMemoryBytes()fromsolverWorker.tstogeometry.tsfor better organizationretainConnectedToAnchors()fromoptimize.tsfor use in testsMask Morphology Bug Fixes
dilateMask()anderodeMask(): These functions now properly avoid mutating the caller's input mask wheniterations >= 2by using a ping-pong buffer strategy that never writes back to the original maskUI & State Management
studyState.ts:faceIndicesMatching()helper to reduce code duplication in face filtering functionsnextSequentialId()function that generates IDs based on the maximum existing ID number rather than array length, preventing ID collisions when regions are deletedbuildConstraintGroups()to use the new ID generation strategyApp.tsxto use the newnextSequentialId()functionViewerCanvas.tsxwith better capture-phase handling for right-click selection clearingConfiguration & Quality Profile
resolveQualityProfile()inconfig.ts:outcomeCountinstead of pre-calculatedestimatedBytesestimateSolverMemoryBytes()functionSettingsclass inconfig.py:OPENTOS_DATA_DIR,OPENTOS_MAX_WORKERS)_int_env()for safe integer environment variable parsingDatabase & API Improvements
database.py:_connect()function with WAL mode and busy timeout configurationrepository.py:_parse_outcome_row()helper to reduce duplication inget_outcomes_by_job_v2()andget_outcomes_by_study_v2()main.py:_lifespan()context manager for proper initialization and shutdown ofJobManagerfusion_solver.py:_world_to_index()to_world_to_indices()and refactored to process multiple points at once using NumPy operationsTest Coverage
voxel.test.ts):https://claude.ai/code/session_01EjrufiVyciihwDSSqtjxfd