vibrante-node-runtime 2.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- src/__init__.py +1 -0
- src/runtime/__init__.py +187 -0
- src/runtime/agent_runtime.py +315 -0
- src/runtime/ai_planner.py +371 -0
- src/runtime/approval_pipeline.py +237 -0
- src/runtime/architectural_features/__init__.py +68 -0
- src/runtime/architectural_features/architectural_feature_realizer.py +279 -0
- src/runtime/architectural_features/architectural_plan.py +421 -0
- src/runtime/architectural_features/architectural_plan_builder.py +428 -0
- src/runtime/architectural_features/environment_architecture_review.py +398 -0
- src/runtime/asset_identity/__init__.py +103 -0
- src/runtime/asset_identity/asset_identity_auditor.py +532 -0
- src/runtime/asset_identity/identity_review.py +248 -0
- src/runtime/asset_identity/identity_serializer.py +76 -0
- src/runtime/asset_identity/identity_statistics.py +132 -0
- src/runtime/asset_identity/opaque_id_detector.py +167 -0
- src/runtime/asset_identity/role_engine_validator.py +134 -0
- src/runtime/asset_identity/role_geometry_validator.py +161 -0
- src/runtime/asset_knowledge_graph.py +505 -0
- src/runtime/asset_staging_manager.py +350 -0
- src/runtime/assets/__init__.py +310 -0
- src/runtime/assets/acquisition/__init__.py +109 -0
- src/runtime/assets/acquisition/acquisition_manager.py +431 -0
- src/runtime/assets/acquisition/download_registry.py +324 -0
- src/runtime/assets/acquisition/fab_library_scanner.py +384 -0
- src/runtime/assets/acquisition/library_index.py +379 -0
- src/runtime/assets/acquisition/library_watcher.py +362 -0
- src/runtime/assets/acquisition/megascans_scanner.py +551 -0
- src/runtime/assets/acquisition_online/__init__.py +211 -0
- src/runtime/assets/acquisition_online/acquisition_pipeline.py +279 -0
- src/runtime/assets/acquisition_online/asset_cache_manager.py +265 -0
- src/runtime/assets/acquisition_online/asset_fetcher.py +361 -0
- src/runtime/assets/acquisition_online/asset_provenance_tracker.py +231 -0
- src/runtime/assets/acquisition_online/download_queue.py +297 -0
- src/runtime/assets/acquisition_online/download_review.py +253 -0
- src/runtime/assets/acquisition_online/download_scheduler.py +188 -0
- src/runtime/assets/acquisition_online/download_serializer.py +116 -0
- src/runtime/assets/acquisition_online/download_statistics.py +145 -0
- src/runtime/assets/acquisition_online/fab_socket_receiver.py +449 -0
- src/runtime/assets/acquisition_online/megascans_auth.py +408 -0
- src/runtime/assets/acquisition_online/megascans_download.py +391 -0
- src/runtime/assets/acquisition_online/megascans_search.py +313 -0
- src/runtime/assets/acquisition_online/project_asset_staging.py +221 -0
- src/runtime/assets/acquisition_online/provider_session_manager.py +182 -0
- src/runtime/assets/acquisition_online/quixel_bridge_client.py +380 -0
- src/runtime/assets/assembly/__init__.py +288 -0
- src/runtime/assets/assembly/anchor_asset_engine.py +387 -0
- src/runtime/assets/assembly/architectural_templates.py +493 -0
- src/runtime/assets/assembly/asset_clustering_engine.py +343 -0
- src/runtime/assets/assembly/asset_placement_engine.py +553 -0
- src/runtime/assets/assembly/asset_scale_analyzer.py +278 -0
- src/runtime/assets/assembly/bounding_box_extractor.py +227 -0
- src/runtime/assets/assembly/clearance_validator.py +204 -0
- src/runtime/assets/assembly/collision_detector.py +208 -0
- src/runtime/assets/assembly/composition_constraints.py +291 -0
- src/runtime/assets/assembly/decorative_population_engine.py +419 -0
- src/runtime/assets/assembly/environment_blueprint.py +92 -0
- src/runtime/assets/assembly/environment_builder.py +401 -0
- src/runtime/assets/assembly/environment_completeness_review.py +500 -0
- src/runtime/assets/assembly/environment_review.py +454 -0
- src/runtime/assets/assembly/environment_scale_review.py +490 -0
- src/runtime/assets/assembly/environment_structure_builder.py +344 -0
- src/runtime/assets/assembly/environment_zones.py +332 -0
- src/runtime/assets/assembly/footprint_calculator.py +181 -0
- src/runtime/assets/assembly/layout_spacing_engine.py +350 -0
- src/runtime/assets/assembly/placement_optimizer.py +272 -0
- src/runtime/assets/assembly/placement_relationships.py +380 -0
- src/runtime/assets/assembly/placement_templates.py +1024 -0
- src/runtime/assets/assembly/scene_population_engine.py +351 -0
- src/runtime/assets/assembly/semantic_placement_rules.py +323 -0
- src/runtime/assets/assembly/spatial_metadata.py +118 -0
- src/runtime/assets/assembly/spatial_review.py +304 -0
- src/runtime/assets/assembly/storytelling_layout_engine.py +768 -0
- src/runtime/assets/assembly/unit_normalizer.py +192 -0
- src/runtime/assets/cache/__init__.py +39 -0
- src/runtime/assets/cache/asset_cache.py +330 -0
- src/runtime/assets/cache/asset_storage.py +234 -0
- src/runtime/assets/cache/asset_sync.py +280 -0
- src/runtime/assets/discovery/__init__.py +17 -0
- src/runtime/assets/discovery/asset_discovery_engine.py +223 -0
- src/runtime/assets/download/__init__.py +24 -0
- src/runtime/assets/download/asset_download_manager.py +275 -0
- src/runtime/assets/geometry/__init__.py +149 -0
- src/runtime/assets/geometry/asset_metrics.py +476 -0
- src/runtime/assets/geometry/bounding_box_extractor.py +478 -0
- src/runtime/assets/geometry/geometry_analyzer.py +251 -0
- src/runtime/assets/geometry/geometry_review.py +463 -0
- src/runtime/assets/geometry/geometry_serializer.py +121 -0
- src/runtime/assets/geometry/geometry_statistics.py +206 -0
- src/runtime/assets/geometry/ground_contact_detector.py +277 -0
- src/runtime/assets/geometry/pivot_detector.py +248 -0
- src/runtime/assets/geometry/support_surface_detector.py +299 -0
- src/runtime/assets/logging/__init__.py +17 -0
- src/runtime/assets/logging/asset_logger.py +153 -0
- src/runtime/assets/metadata/__init__.py +65 -0
- src/runtime/assets/metadata/asset_metadata_enricher.py +215 -0
- src/runtime/assets/metadata/asset_provenance.py +273 -0
- src/runtime/assets/metadata/asset_semantic_mapper.py +265 -0
- src/runtime/assets/metadata/provider_normalizer.py +364 -0
- src/runtime/assets/providers/__init__.py +38 -0
- src/runtime/assets/providers/base.py +218 -0
- src/runtime/assets/providers/local_library_provider.py +209 -0
- src/runtime/assets/providers/polyhaven_provider.py +268 -0
- src/runtime/assets/providers/provider_manager.py +229 -0
- src/runtime/assets/providers/quixel_provider.py +277 -0
- src/runtime/assets/providers/sketchfab_live_provider.py +515 -0
- src/runtime/assets/providers/sketchfab_provider.py +327 -0
- src/runtime/assets/providers/studio_library_provider.py +323 -0
- src/runtime/assets/providers/usd_library_provider.py +310 -0
- src/runtime/assets/ranking/__init__.py +17 -0
- src/runtime/assets/ranking/asset_ranking_engine.py +365 -0
- src/runtime/assets/real_world_scale.py +189 -0
- src/runtime/assets/realization/__init__.py +162 -0
- src/runtime/assets/realization/asset_converter.py +282 -0
- src/runtime/assets/realization/asset_dependency_resolver.py +285 -0
- src/runtime/assets/realization/asset_importer.py +298 -0
- src/runtime/assets/realization/asset_instancer.py +269 -0
- src/runtime/assets/realization/asset_material_mapper.py +337 -0
- src/runtime/assets/realization/asset_normalizer.py +319 -0
- src/runtime/assets/realization/asset_realization_review.py +416 -0
- src/runtime/assets/realization/asset_validation_pipeline.py +316 -0
- src/runtime/assets/realization/realization_serializer.py +172 -0
- src/runtime/assets/realization/realization_statistics.py +265 -0
- src/runtime/assets/realization/scene_asset_realizer.py +405 -0
- src/runtime/assets/realization/usd_builder.py +272 -0
- src/runtime/assets/recommendations/__init__.py +17 -0
- src/runtime/assets/recommendations/asset_recommendation_engine.py +260 -0
- src/runtime/assets/schema/__init__.py +38 -0
- src/runtime/assets/schema/asset_descriptor.py +484 -0
- src/runtime/assets/semantic/__init__.py +234 -0
- src/runtime/assets/semantic/asset_catalog.py +368 -0
- src/runtime/assets/semantic/asset_catalog_review.py +266 -0
- src/runtime/assets/semantic/asset_catalog_serializer.py +103 -0
- src/runtime/assets/semantic/asset_catalog_statistics.py +130 -0
- src/runtime/assets/semantic/asset_catalog_sync.py +248 -0
- src/runtime/assets/semantic/asset_cinematic_mapper.py +156 -0
- src/runtime/assets/semantic/asset_environment_mapper.py +459 -0
- src/runtime/assets/semantic/asset_knowledge_graph.py +257 -0
- src/runtime/assets/semantic/asset_lookdev_mapper.py +180 -0
- src/runtime/assets/semantic/asset_manifest_reader.py +236 -0
- src/runtime/assets/semantic/asset_metadata_extractor.py +167 -0
- src/runtime/assets/semantic/asset_metadata_provider.py +231 -0
- src/runtime/assets/semantic/asset_query_engine.py +240 -0
- src/runtime/assets/semantic/asset_role_classifier.py +193 -0
- src/runtime/assets/semantic/asset_storytelling_mapper.py +163 -0
- src/runtime/assets/semantic/megascans_metadata_client.py +345 -0
- src/runtime/assets/semantic/semantic_asset_enricher.py +232 -0
- src/runtime/assets/serialization/__init__.py +15 -0
- src/runtime/assets/serialization/asset_serializer.py +201 -0
- src/runtime/assets/suitability/__init__.py +115 -0
- src/runtime/assets/suitability/asset_suitability_engine.py +345 -0
- src/runtime/assets/suitability/asset_suitability_review.py +193 -0
- src/runtime/assets/suitability/asset_suitability_serializer.py +67 -0
- src/runtime/assets/suitability/asset_suitability_statistics.py +141 -0
- src/runtime/assets/suitability/environment_affinity.py +290 -0
- src/runtime/assets/suitability/material_affinity.py +247 -0
- src/runtime/assets/suitability/placement_affinity.py +153 -0
- src/runtime/assets/suitability/role_affinity.py +205 -0
- src/runtime/assets/suitability/scale_affinity.py +150 -0
- src/runtime/assets/suitability/story_affinity.py +235 -0
- src/runtime/assets/suitability/style_affinity.py +252 -0
- src/runtime/assets/validation/__init__.py +17 -0
- src/runtime/assets/validation/asset_validation_engine.py +281 -0
- src/runtime/assets/vector_search/__init__.py +193 -0
- src/runtime/assets/vector_search/asset_embedding_builder.py +132 -0
- src/runtime/assets/vector_search/asset_vector_store.py +264 -0
- src/runtime/assets/vector_search/catalog_vector_index_builder.py +155 -0
- src/runtime/assets/vector_search/embedding_provider.py +294 -0
- src/runtime/assets/vector_search/hybrid_ranking_engine.py +241 -0
- src/runtime/assets/vector_search/intent_embedding_engine.py +99 -0
- src/runtime/assets/vector_search/intent_parser.py +462 -0
- src/runtime/assets/vector_search/retrieval_pipeline.py +275 -0
- src/runtime/assets/vector_search/retrieval_review.py +281 -0
- src/runtime/assets/vector_search/retrieval_serializer.py +91 -0
- src/runtime/assets/vector_search/retrieval_statistics.py +133 -0
- src/runtime/assets/vector_search/semantic_similarity.py +116 -0
- src/runtime/assets/vector_search/vector_search_engine.py +246 -0
- src/runtime/atmosphere_orchestrator.py +412 -0
- src/runtime/audit_store.py +230 -0
- src/runtime/capability_catalog.py +2324 -0
- src/runtime/capability_registry.py +225 -0
- src/runtime/cinematic_camera_engine.py +497 -0
- src/runtime/cinematic_composition.py +399 -0
- src/runtime/cinematic_scene_review.py +539 -0
- src/runtime/contextual_reasoning.py +286 -0
- src/runtime/dependency_graph.py +205 -0
- src/runtime/distributed_runtime.py +348 -0
- src/runtime/environment/__init__.py +189 -0
- src/runtime/environment/anchor_asset_builder.py +389 -0
- src/runtime/environment/atmosphere_builder.py +307 -0
- src/runtime/environment/decorative_population.py +320 -0
- src/runtime/environment/environment_blueprint.py +107 -0
- src/runtime/environment/environment_completeness.py +234 -0
- src/runtime/environment/environment_requirements.py +224 -0
- src/runtime/environment/environment_review.py +320 -0
- src/runtime/environment/environment_serializer.py +100 -0
- src/runtime/environment/environment_statistics.py +149 -0
- src/runtime/environment/environment_structure_builder.py +391 -0
- src/runtime/environment/environment_template_library.py +388 -0
- src/runtime/environment/environment_zone_builder.py +334 -0
- src/runtime/environment/support_asset_builder.py +243 -0
- src/runtime/environment_realization/__init__.py +177 -0
- src/runtime/environment_realization/architectural_constraint_solver.py +230 -0
- src/runtime/environment_realization/beam_builder.py +221 -0
- src/runtime/environment_realization/ceiling_builder.py +186 -0
- src/runtime/environment_realization/environment_execution_engine.py +228 -0
- src/runtime/environment_realization/environment_realization_engine.py +119 -0
- src/runtime/environment_realization/environment_review.py +250 -0
- src/runtime/environment_realization/environment_serializer.py +77 -0
- src/runtime/environment_realization/environment_statistics.py +134 -0
- src/runtime/environment_realization/floor_builder.py +198 -0
- src/runtime/environment_realization/opening_builder.py +224 -0
- src/runtime/environment_realization/room_shell_builder.py +215 -0
- src/runtime/environment_realization/room_shell_completeness_validator.py +303 -0
- src/runtime/environment_realization/structural_attachment_enforcer.py +386 -0
- src/runtime/environment_realization/structural_builder.py +314 -0
- src/runtime/environment_realization/structural_elements.py +258 -0
- src/runtime/environment_realization/structural_routing_engine.py +390 -0
- src/runtime/environment_realization/wall_builder.py +199 -0
- src/runtime/environment_rules.py +239 -0
- src/runtime/environment_shell/__init__.py +187 -0
- src/runtime/environment_shell/environment_readiness_gate.py +187 -0
- src/runtime/environment_shell/environment_shell_audit.py +184 -0
- src/runtime/environment_shell/environment_shell_blueprint.py +267 -0
- src/runtime/environment_shell/environment_shell_builder.py +265 -0
- src/runtime/environment_shell/environment_shell_state.py +133 -0
- src/runtime/environment_shell/shell_ceiling_builder.py +114 -0
- src/runtime/environment_shell/shell_floor_builder.py +96 -0
- src/runtime/environment_shell/shell_phase_result.py +66 -0
- src/runtime/environment_shell/shell_review.py +241 -0
- src/runtime/environment_shell/shell_serializer.py +67 -0
- src/runtime/environment_shell/shell_statistics.py +141 -0
- src/runtime/environment_shell/shell_validator.py +138 -0
- src/runtime/environment_shell/shell_wall_builder.py +156 -0
- src/runtime/environment_shell/structural_anchor_generator.py +200 -0
- src/runtime/environment_shell/structural_element_placer.py +193 -0
- src/runtime/environments/__init__.py +67 -0
- src/runtime/environments/environment_registry.py +1139 -0
- src/runtime/environments/environment_statistics.py +219 -0
- src/runtime/execution_explainer.py +399 -0
- src/runtime/execution_quality.py +258 -0
- src/runtime/execution_review.py +221 -0
- src/runtime/execution_scheduler.py +263 -0
- src/runtime/failure_intelligence.py +341 -0
- src/runtime/goal_decomposer.py +532 -0
- src/runtime/houdini_asset_realizer.py +329 -0
- src/runtime/houdini_runtime.py +992 -0
- src/runtime/intent_parser.py +275 -0
- src/runtime/knowledge_graph.py +310 -0
- src/runtime/layout/__init__.py +172 -0
- src/runtime/layout/affordance_engine.py +384 -0
- src/runtime/layout/anchor_layout_engine.py +244 -0
- src/runtime/layout/decoration_layout_engine.py +325 -0
- src/runtime/layout/furniture_cluster_builder.py +381 -0
- src/runtime/layout/layout_review.py +265 -0
- src/runtime/layout/layout_serializer.py +77 -0
- src/runtime/layout/layout_statistics.py +123 -0
- src/runtime/layout/relationship_graph.py +165 -0
- src/runtime/layout/relationship_graph_builder.py +699 -0
- src/runtime/layout/relationship_layout_engine.py +1101 -0
- src/runtime/layout/relationship_realization_auditor.py +849 -0
- src/runtime/layout/semantic_layout_engine.py +327 -0
- src/runtime/layout/surface_placement_engine.py +270 -0
- src/runtime/layout/wall_attachment_engine.py +243 -0
- src/runtime/layout_realization/__init__.py +183 -0
- src/runtime/layout_realization/cluster_realizer.py +212 -0
- src/runtime/layout_realization/collision_solver.py +359 -0
- src/runtime/layout_realization/identity_metadata_writer.py +257 -0
- src/runtime/layout_realization/layout_application_engine.py +242 -0
- src/runtime/layout_realization/layout_realization_engine.py +293 -0
- src/runtime/layout_realization/layout_validator.py +315 -0
- src/runtime/layout_realization/metadata_application_engine.py +187 -0
- src/runtime/layout_realization/realization_review.py +268 -0
- src/runtime/layout_realization/realization_serializer.py +77 -0
- src/runtime/layout_realization/realization_statistics.py +151 -0
- src/runtime/layout_realization/relationship_metadata_writer.py +305 -0
- src/runtime/layout_realization/relationship_persistence_auditor.py +426 -0
- src/runtime/layout_realization/relationship_realizer.py +294 -0
- src/runtime/layout_realization/scene_constraint_solver.py +317 -0
- src/runtime/layout_realization/surface_realizer.py +195 -0
- src/runtime/layout_realization/transform_resolver.py +268 -0
- src/runtime/layout_realization/wall_attachment_realizer.py +182 -0
- src/runtime/layout_transform_engine.py +341 -0
- src/runtime/lighting/__init__.py +215 -0
- src/runtime/lighting/lighting_color_engine.py +252 -0
- src/runtime/lighting/lighting_environment_mapper.py +792 -0
- src/runtime/lighting/lighting_exposure_engine.py +213 -0
- src/runtime/lighting/lighting_hierarchy_engine.py +248 -0
- src/runtime/lighting/lighting_knowledge.py +342 -0
- src/runtime/lighting/lighting_language.py +239 -0
- src/runtime/lighting/lighting_mood_engine.py +230 -0
- src/runtime/lighting/lighting_patterns.py +522 -0
- src/runtime/lighting/lighting_plan_builder.py +320 -0
- src/runtime/lighting/lighting_readability_engine.py +273 -0
- src/runtime/lighting/lighting_recommendation_engine.py +205 -0
- src/runtime/lighting/lighting_review.py +370 -0
- src/runtime/lighting/lighting_serializer.py +71 -0
- src/runtime/lighting/lighting_statistics.py +142 -0
- src/runtime/lighting/lighting_strategy_engine.py +239 -0
- src/runtime/lighting/lighting_validation.py +183 -0
- src/runtime/llm_provider.py +340 -0
- src/runtime/lookdev/__init__.py +137 -0
- src/runtime/lookdev/lookdev_patterns.py +216 -0
- src/runtime/lookdev/lookdev_review.py +389 -0
- src/runtime/lookdev/lookdev_serializer.py +71 -0
- src/runtime/lookdev/lookdev_statistics.py +133 -0
- src/runtime/lookdev/lookdev_validation.py +203 -0
- src/runtime/lookdev/material_assignment_engine.py +331 -0
- src/runtime/lookdev/material_knowledge.py +244 -0
- src/runtime/lookdev/material_library.py +311 -0
- src/runtime/lookdev/material_recommendation.py +394 -0
- src/runtime/lookdev/renderer_profiles.py +281 -0
- src/runtime/mcp_runtime.py +357 -0
- src/runtime/mcp_server_runtime.py +386 -0
- src/runtime/mcp_session.py +261 -0
- src/runtime/mcp_tool_registry.py +2169 -0
- src/runtime/mcp_transport.py +206 -0
- src/runtime/multi_dcc_runtime.py +316 -0
- src/runtime/orchestration_heuristics.py +360 -0
- src/runtime/pattern_library.py +344 -0
- src/runtime/plan_validator.py +314 -0
- src/runtime/planning/__init__.py +103 -0
- src/runtime/planning/camera/__init__.py +1 -0
- src/runtime/planning/camera/camera_planner.py +179 -0
- src/runtime/planning/composition/__init__.py +1 -0
- src/runtime/planning/composition/composition_planner.py +223 -0
- src/runtime/planning/logging/__init__.py +1 -0
- src/runtime/planning/logging/planning_logger.py +109 -0
- src/runtime/planning/planners/__init__.py +1 -0
- src/runtime/planning/planners/asset_query_generator.py +265 -0
- src/runtime/planning/planners/scene_planner.py +199 -0
- src/runtime/planning/planners/zone_planner.py +271 -0
- src/runtime/planning/recommendations/__init__.py +1 -0
- src/runtime/planning/recommendations/scene_plan_recommendation_engine.py +228 -0
- src/runtime/planning/schema/__init__.py +23 -0
- src/runtime/planning/schema/scene_plan.py +569 -0
- src/runtime/planning/serialization/__init__.py +1 -0
- src/runtime/planning/serialization/plan_serializer.py +147 -0
- src/runtime/planning/validators/__init__.py +1 -0
- src/runtime/planning/validators/scene_plan_validator.py +210 -0
- src/runtime/planning_memory.py +242 -0
- src/runtime/predictive_execution.py +393 -0
- src/runtime/procedural_scene_assembler.py +415 -0
- src/runtime/production_memory.py +309 -0
- src/runtime/production_scoring.py +422 -0
- src/runtime/reality/__init__.py +197 -0
- src/runtime/reality/architectural_integrity_validator.py +220 -0
- src/runtime/reality/beam_connection_validator.py +205 -0
- src/runtime/reality/composition_engine.py +206 -0
- src/runtime/reality/correction_applier.py +159 -0
- src/runtime/reality/correction_pass_engine.py +253 -0
- src/runtime/reality/density_engine.py +145 -0
- src/runtime/reality/floating_object_detector.py +206 -0
- src/runtime/reality/functional_zone_builder.py +260 -0
- src/runtime/reality/geometry_inspector.py +229 -0
- src/runtime/reality/human_reasoning_engine.py +284 -0
- src/runtime/reality/reality_intelligence_engine.py +182 -0
- src/runtime/reality/reality_scene_model.py +351 -0
- src/runtime/reality/reality_serializer.py +75 -0
- src/runtime/reality/reality_statistics.py +145 -0
- src/runtime/reality/support_rule_engine.py +248 -0
- src/runtime/reality/visual_review_engine.py +217 -0
- src/runtime/recommendation_engine.py +358 -0
- src/runtime/render_preparation_engine.py +463 -0
- src/runtime/resource_estimator.py +256 -0
- src/runtime/resource_optimizer.py +343 -0
- src/runtime/review_engine.py +768 -0
- src/runtime/review_feedback.py +325 -0
- src/runtime/runtime_analytics.py +330 -0
- src/runtime/runtime_bootstrap.py +137 -0
- src/runtime/runtime_constraints.py +317 -0
- src/runtime/runtime_federation_api.py +297 -0
- src/runtime/runtime_identity.py +70 -0
- src/runtime/runtime_narration.py +493 -0
- src/runtime/runtime_prompt_context.py +682 -0
- src/runtime/scene_awareness.py +559 -0
- src/runtime/scene_cache.py +277 -0
- src/runtime/scene_hierarchy_builder.py +258 -0
- src/runtime/scene_layout_planner.py +292 -0
- src/runtime/scene_realization_review.py +452 -0
- src/runtime/scene_recommendation_engine.py +398 -0
- src/runtime/scene_validation/__init__.py +118 -0
- src/runtime/scene_validation/occupancy_validator.py +176 -0
- src/runtime/scene_validation/orphan_detector.py +205 -0
- src/runtime/scene_validation/plausibility_engine.py +236 -0
- src/runtime/scene_validation/relationship_validator.py +238 -0
- src/runtime/scene_validation/routing_audit.py +556 -0
- src/runtime/scene_validation/scene_reality_validator.py +229 -0
- src/runtime/scene_validation/support_surface_validator.py +155 -0
- src/runtime/scene_validation/validation_review.py +207 -0
- src/runtime/scene_validation/validation_serializer.py +74 -0
- src/runtime/scene_validation/validation_statistics.py +142 -0
- src/runtime/semantic/__init__.py +113 -0
- src/runtime/semantic/enrichers/__init__.py +12 -0
- src/runtime/semantic/enrichers/scene_intent_enricher.py +305 -0
- src/runtime/semantic/logging/__init__.py +18 -0
- src/runtime/semantic/logging/semantic_logger.py +298 -0
- src/runtime/semantic/prompts/__init__.py +12 -0
- src/runtime/semantic/prompts/intent_prompt_builder.py +317 -0
- src/runtime/semantic/recommendations/__init__.py +17 -0
- src/runtime/semantic/recommendations/intent_recommendation_engine.py +434 -0
- src/runtime/semantic/scene_intent_extractor.py +455 -0
- src/runtime/semantic/schema/__init__.py +40 -0
- src/runtime/semantic/schema/scene_intent_schema.py +349 -0
- src/runtime/semantic/serialization/__init__.py +16 -0
- src/runtime/semantic/serialization/intent_serializer.py +248 -0
- src/runtime/semantic/validators/__init__.py +14 -0
- src/runtime/semantic/validators/scene_intent_validator.py +284 -0
- src/runtime/semantic_execution.py +348 -0
- src/runtime/semantic_import_controller.py +408 -0
- src/runtime/semantic_lighting_engine.py +566 -0
- src/runtime/semantic_memory.py +257 -0
- src/runtime/semantic_registry.py +386 -0
- src/runtime/semantic_scene_templates.py +387 -0
- src/runtime/storage/__init__.py +18 -0
- src/runtime/storage/memory_backend.py +294 -0
- src/runtime/storage/serialization.py +211 -0
- src/runtime/storage/sqlite_backend.py +365 -0
- src/runtime/structure/__init__.py +135 -0
- src/runtime/structure/environment_structural_affinity.py +254 -0
- src/runtime/structure/geometry_role_detector.py +182 -0
- src/runtime/structure/metadata_role_classifier.py +279 -0
- src/runtime/structure/structural_asset_classifier.py +331 -0
- src/runtime/structure/structural_placement_rules.py +326 -0
- src/runtime/structure/structural_review.py +682 -0
- src/runtime/structure/structural_serializer.py +113 -0
- src/runtime/structure/structural_statistics.py +209 -0
- src/runtime/studio/__init__.py +71 -0
- src/runtime/studio/cross_project_learning.py +263 -0
- src/runtime/studio/knowledge_recommendation.py +324 -0
- src/runtime/studio/knowledge_serializer.py +154 -0
- src/runtime/studio/knowledge_statistics.py +107 -0
- src/runtime/studio/production_benchmark.py +240 -0
- src/runtime/studio/project_memory.py +250 -0
- src/runtime/studio/review_analytics.py +166 -0
- src/runtime/studio/studio_knowledge.py +284 -0
- src/runtime/studio/studio_metrics.py +155 -0
- src/runtime/studio/studio_standards.py +262 -0
- src/runtime/studio_knowledge.py +328 -0
- src/runtime/transaction_manager.py +367 -0
- src/runtime/validation_engine.py +234 -0
- src/runtime/visual_hierarchy_engine.py +452 -0
- src/runtime/worker_runtime.py +236 -0
- src/runtime/workflow_federation.py +316 -0
- src/runtime/workflow_optimizer.py +407 -0
- src/runtime/workflow_templates.py +421 -0
- src/runtime/workflows/__init__.py +129 -0
- src/runtime/workflows/workflow_blueprint.py +394 -0
- src/runtime/workflows/workflow_executor.py +344 -0
- src/runtime/workflows/workflow_pack.py +403 -0
- src/runtime/workflows/workflow_recommendation.py +353 -0
- src/runtime/workflows/workflow_registry.py +165 -0
- src/runtime/workflows/workflow_review.py +336 -0
- src/runtime/workflows/workflow_serializer.py +149 -0
- src/runtime/workflows/workflow_statistics.py +205 -0
- src/runtime/workflows/workflow_validator.py +272 -0
- src/utils/__init__.py +0 -0
- src/utils/hou_bridge.py +262 -0
- src/utils/vibrante_config.py +272 -0
- vibrante_node_runtime-2.5.1.dist-info/METADATA +47 -0
- vibrante_node_runtime-2.5.1.dist-info/RECORD +472 -0
- vibrante_node_runtime-2.5.1.dist-info/WHEEL +5 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/CLA.md +96 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/COMMERCIAL_LICENSE.md +170 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSE +178 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSES/AGPL-3.0.txt +661 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSES/CC-BY-4.0-SCOPE.md +53 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSES/CC-BY-4.0.txt +396 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSES/GPL-3.0.txt +674 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSES/LGPL-3.0.txt +165 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSES/README.md +65 -0
- vibrante_node_runtime-2.5.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,992 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Houdini Runtime
|
|
3
|
+
===============
|
|
4
|
+
Semantic layer on top of `src.utils.hou_bridge`. Provides:
|
|
5
|
+
|
|
6
|
+
• scene_context(...) — single structured snapshot of scene + selection +
|
|
7
|
+
networks + assets + render nodes, cached for fast repeated reads.
|
|
8
|
+
• build_node_chain(spec) — declarative creation of a Houdini network from
|
|
9
|
+
a JSON spec: validate → create → param → connect → layout → cook.
|
|
10
|
+
|
|
11
|
+
Both functions are async to fit Vibrante's node `execute()` contract. The
|
|
12
|
+
runtime is the seam between graph nodes and the raw RPC bridge — nodes
|
|
13
|
+
should never call `get_bridge()` directly for context aggregation or
|
|
14
|
+
multi-step composition, because the runtime layer:
|
|
15
|
+
|
|
16
|
+
1. caches reads (avoids duplicate bridge round-trips per execution)
|
|
17
|
+
2. validates inputs before mutating Houdini
|
|
18
|
+
3. returns shape-stable JSON-serialisable data (LLM-friendly)
|
|
19
|
+
4. is the future hook point for transactions / rollback (Tier 3)
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import asyncio
|
|
25
|
+
import json
|
|
26
|
+
from typing import Any, Callable, Dict, List, Optional
|
|
27
|
+
|
|
28
|
+
from src.runtime.scene_cache import get_scene_cache
|
|
29
|
+
|
|
30
|
+
# Bridge imports kept lazy so unit tests can monkey-patch without a live
|
|
31
|
+
# Houdini process. We import the module, not the names, so attribute access
|
|
32
|
+
# (`_bridge_module.get_bridge()`) resolves through any test patch.
|
|
33
|
+
from src.utils import hou_bridge as _bridge_module
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# ---------------------------------------------------------------------------
|
|
37
|
+
# Bridge helpers
|
|
38
|
+
# ---------------------------------------------------------------------------
|
|
39
|
+
|
|
40
|
+
def _bridge():
|
|
41
|
+
return _bridge_module.get_bridge()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
async def _to_thread(fn, *args, **kwargs):
|
|
45
|
+
"""Run a blocking bridge call off the event loop without leaking exceptions."""
|
|
46
|
+
return await asyncio.to_thread(fn, *args, **kwargs)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# ---------------------------------------------------------------------------
|
|
50
|
+
# Scene context
|
|
51
|
+
# ---------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
_NETWORKS = ("obj", "mat", "out", "stage", "tasks", "shop", "vex", "ch")
|
|
54
|
+
_CORE_NETWORKS = ("obj", "mat", "out")
|
|
55
|
+
_OPTIONAL_NETWORKS = ("stage", "tasks", "shop", "vex", "ch")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
async def scene_context(
|
|
59
|
+
include_selection: bool = True,
|
|
60
|
+
include_assets: bool = True,
|
|
61
|
+
include_render: bool = True,
|
|
62
|
+
force_refresh: bool = False,
|
|
63
|
+
) -> Dict[str, Any]:
|
|
64
|
+
"""Return a structured snapshot of the current Houdini scene state.
|
|
65
|
+
|
|
66
|
+
Shape is stable across calls — empty sections appear as empty lists/dicts
|
|
67
|
+
instead of being omitted, so downstream LLM prompts can rely on the keys.
|
|
68
|
+
"""
|
|
69
|
+
cache = get_scene_cache()
|
|
70
|
+
|
|
71
|
+
if force_refresh:
|
|
72
|
+
cache.invalidate("scene_context::")
|
|
73
|
+
|
|
74
|
+
# Each section cached independently so a partial refresh is possible later.
|
|
75
|
+
scene = await _section(cache, "scene_context::scene", _fetch_scene_info)
|
|
76
|
+
networks = await _section(cache, "scene_context::networks", _fetch_networks)
|
|
77
|
+
selection = (
|
|
78
|
+
await _section(cache, "scene_context::selection", _fetch_selection)
|
|
79
|
+
if include_selection else []
|
|
80
|
+
)
|
|
81
|
+
assets = (
|
|
82
|
+
await _section(cache, "scene_context::assets", _fetch_assets)
|
|
83
|
+
if include_assets else {"hda_files": [], "definitions": []}
|
|
84
|
+
)
|
|
85
|
+
render = (
|
|
86
|
+
await _section(cache, "scene_context::render", _fetch_render, networks)
|
|
87
|
+
if include_render else {"render_nodes": []}
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
"scene": scene,
|
|
92
|
+
"selection": selection,
|
|
93
|
+
"networks": networks,
|
|
94
|
+
"assets": assets,
|
|
95
|
+
"render": render,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
async def _section(cache, key: str, fetcher, *fetcher_args) -> Any:
|
|
100
|
+
cached = cache.get(key)
|
|
101
|
+
if cached is not None:
|
|
102
|
+
return cached
|
|
103
|
+
value = await fetcher(*fetcher_args)
|
|
104
|
+
cache.set(key, value, ttl_sec=5.0)
|
|
105
|
+
return value
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
async def _fetch_scene_info() -> Dict[str, Any]:
|
|
109
|
+
try:
|
|
110
|
+
info = await _to_thread(_bridge().scene_info) or {}
|
|
111
|
+
except Exception as exc:
|
|
112
|
+
return {"error": str(exc)}
|
|
113
|
+
return {
|
|
114
|
+
"hip_file": info.get("hip_file", ""),
|
|
115
|
+
"hip_name": info.get("hip_name", ""),
|
|
116
|
+
"houdini_version": info.get("houdini_version", ""),
|
|
117
|
+
"fps": info.get("fps", 24),
|
|
118
|
+
"frame": info.get("frame", 1),
|
|
119
|
+
"frame_range": list(info.get("frame_range") or [1, 240]),
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
async def _fetch_networks() -> Dict[str, List[Dict[str, Any]]]:
|
|
124
|
+
out: Dict[str, List[Dict[str, Any]]] = {}
|
|
125
|
+
bridge = _bridge()
|
|
126
|
+
|
|
127
|
+
for net in _CORE_NETWORKS:
|
|
128
|
+
out[net] = await _safe_network_summary(bridge, f"/{net}")
|
|
129
|
+
|
|
130
|
+
for net in _OPTIONAL_NETWORKS:
|
|
131
|
+
path = f"/{net}"
|
|
132
|
+
try:
|
|
133
|
+
exists = await _to_thread(bridge.node_exists, path)
|
|
134
|
+
if not (isinstance(exists, dict) and exists.get("exists")):
|
|
135
|
+
continue
|
|
136
|
+
except Exception:
|
|
137
|
+
continue
|
|
138
|
+
out[net] = await _safe_network_summary(bridge, path)
|
|
139
|
+
return out
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
async def _safe_network_summary(bridge, path: str) -> List[Dict[str, Any]]:
|
|
143
|
+
summarizer = getattr(bridge, "network_summary", None)
|
|
144
|
+
try:
|
|
145
|
+
if summarizer is not None:
|
|
146
|
+
data = await _to_thread(summarizer, path)
|
|
147
|
+
else:
|
|
148
|
+
data = await _to_thread(bridge.children, path)
|
|
149
|
+
except Exception:
|
|
150
|
+
return []
|
|
151
|
+
return list(data or [])
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
async def _fetch_selection() -> List[Dict[str, Any]]:
|
|
155
|
+
bridge = _bridge()
|
|
156
|
+
selection_fn = getattr(bridge, "get_selection", None)
|
|
157
|
+
if selection_fn is None:
|
|
158
|
+
return []
|
|
159
|
+
try:
|
|
160
|
+
paths = await _to_thread(selection_fn) or []
|
|
161
|
+
except Exception:
|
|
162
|
+
return []
|
|
163
|
+
out: List[Dict[str, Any]] = []
|
|
164
|
+
for entry in paths:
|
|
165
|
+
if isinstance(entry, dict):
|
|
166
|
+
out.append({
|
|
167
|
+
"path": entry.get("path", ""),
|
|
168
|
+
"type": entry.get("type", ""),
|
|
169
|
+
"category": entry.get("category", ""),
|
|
170
|
+
})
|
|
171
|
+
else:
|
|
172
|
+
path_str = str(entry)
|
|
173
|
+
info = await _safe_node_info(bridge, path_str)
|
|
174
|
+
out.append({
|
|
175
|
+
"path": path_str,
|
|
176
|
+
"type": info.get("type", ""),
|
|
177
|
+
"category": info.get("category", ""),
|
|
178
|
+
})
|
|
179
|
+
return out
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
async def _safe_node_info(bridge, path: str) -> Dict[str, Any]:
|
|
183
|
+
try:
|
|
184
|
+
return await _to_thread(bridge.node_info, path) or {}
|
|
185
|
+
except Exception:
|
|
186
|
+
return {}
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
async def _fetch_assets() -> Dict[str, Any]:
|
|
190
|
+
bridge = _bridge()
|
|
191
|
+
try:
|
|
192
|
+
result = await _to_thread(
|
|
193
|
+
bridge.run_code,
|
|
194
|
+
(
|
|
195
|
+
"import hou\n"
|
|
196
|
+
"result = {\n"
|
|
197
|
+
" 'files': list(hou.hda.loadedFiles()),\n"
|
|
198
|
+
" 'defs': [\n"
|
|
199
|
+
" {\n"
|
|
200
|
+
" 'name': d.nodeTypeName(),\n"
|
|
201
|
+
" 'label': d.description(),\n"
|
|
202
|
+
" 'file': d.libraryFilePath(),\n"
|
|
203
|
+
" 'category': d.nodeTypeCategory().name(),\n"
|
|
204
|
+
" }\n"
|
|
205
|
+
" for f in hou.hda.loadedFiles() for d in hou.hda.definitionsInFile(f)\n"
|
|
206
|
+
" ]\n"
|
|
207
|
+
"}\n"
|
|
208
|
+
),
|
|
209
|
+
)
|
|
210
|
+
except Exception:
|
|
211
|
+
return {"hda_files": [], "definitions": []}
|
|
212
|
+
payload = (result or {}).get("result") or {}
|
|
213
|
+
return {
|
|
214
|
+
"hda_files": list(payload.get("files") or []),
|
|
215
|
+
"definitions": list(payload.get("defs") or []),
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
async def _fetch_render(networks: Dict[str, List[Dict[str, Any]]]) -> Dict[str, Any]:
|
|
220
|
+
out_nodes = networks.get("out") or []
|
|
221
|
+
render_types = {
|
|
222
|
+
"karma", "ifd", "mantra", "opengl", "ris", "arnold", "redshift_rop",
|
|
223
|
+
"vray_renderer", "usdrender_rop", "lop_render"
|
|
224
|
+
}
|
|
225
|
+
render_nodes = [
|
|
226
|
+
{"path": n.get("path", ""), "type": n.get("type", "")}
|
|
227
|
+
for n in out_nodes
|
|
228
|
+
if n.get("type", "") in render_types
|
|
229
|
+
]
|
|
230
|
+
return {"render_nodes": render_nodes}
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
# ---------------------------------------------------------------------------
|
|
234
|
+
# Build node chain
|
|
235
|
+
# ---------------------------------------------------------------------------
|
|
236
|
+
|
|
237
|
+
def _expected_path(n: dict) -> str:
|
|
238
|
+
"""Return the path we expect Houdini to create for spec node `n`.
|
|
239
|
+
|
|
240
|
+
Returns an empty string when `n` has no explicit name (Houdini will pick
|
|
241
|
+
one, so we can't predict the path before the create call).
|
|
242
|
+
"""
|
|
243
|
+
name = n.get("name") or ""
|
|
244
|
+
if not name:
|
|
245
|
+
return ""
|
|
246
|
+
return n["parent"].rstrip("/") + "/" + name
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def _topo_sort_nodes(nodes_spec: List[dict]) -> List[dict]:
|
|
250
|
+
"""Return nodes in creation order: parent-creators before their children.
|
|
251
|
+
|
|
252
|
+
If node A's expected created path matches node B's `parent`, B must come
|
|
253
|
+
after A. Uses Kahn's algorithm; falls back to the original order if a
|
|
254
|
+
cycle is detected (which the spec validator should have rejected already).
|
|
255
|
+
"""
|
|
256
|
+
# expected_path → index for nodes that have an explicit name
|
|
257
|
+
by_expected: Dict[str, int] = {}
|
|
258
|
+
for i, n in enumerate(nodes_spec):
|
|
259
|
+
ep = _expected_path(n)
|
|
260
|
+
if ep:
|
|
261
|
+
by_expected[ep] = i
|
|
262
|
+
|
|
263
|
+
# deps[i] = indices that i depends on (i must come after them)
|
|
264
|
+
dependents: Dict[int, List[int]] = {i: [] for i in range(len(nodes_spec))}
|
|
265
|
+
in_degree = [0] * len(nodes_spec)
|
|
266
|
+
for i, n in enumerate(nodes_spec):
|
|
267
|
+
parent = n["parent"]
|
|
268
|
+
if parent in by_expected and by_expected[parent] != i:
|
|
269
|
+
dep = by_expected[parent]
|
|
270
|
+
dependents[dep].append(i)
|
|
271
|
+
in_degree[i] += 1
|
|
272
|
+
|
|
273
|
+
from collections import deque
|
|
274
|
+
queue: deque[int] = deque(i for i in range(len(nodes_spec)) if in_degree[i] == 0)
|
|
275
|
+
ordered: List[int] = []
|
|
276
|
+
while queue:
|
|
277
|
+
idx = queue.popleft()
|
|
278
|
+
ordered.append(idx)
|
|
279
|
+
for child in dependents[idx]:
|
|
280
|
+
in_degree[child] -= 1
|
|
281
|
+
if in_degree[child] == 0:
|
|
282
|
+
queue.append(child)
|
|
283
|
+
|
|
284
|
+
if len(ordered) != len(nodes_spec):
|
|
285
|
+
return nodes_spec # cycle — fall back to original order
|
|
286
|
+
return [nodes_spec[i] for i in ordered]
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
async def build_node_chain(spec: Dict[str, Any]) -> Dict[str, Any]:
|
|
290
|
+
"""Build a Houdini node network from a structured spec.
|
|
291
|
+
|
|
292
|
+
Spec shape:
|
|
293
|
+
{
|
|
294
|
+
"intent": "string (free-form label for logs)",
|
|
295
|
+
"nodes": [
|
|
296
|
+
{"id": "n1", "parent": "/obj/geo1", "type": "sphere",
|
|
297
|
+
"name": "src", "params": {"radx": 2.0}},
|
|
298
|
+
...
|
|
299
|
+
],
|
|
300
|
+
"connections": [
|
|
301
|
+
{"from": "n1", "to": "n2", "out": 0, "in": 0},
|
|
302
|
+
...
|
|
303
|
+
],
|
|
304
|
+
"layout": true,
|
|
305
|
+
"cook": false
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
Returns:
|
|
309
|
+
{"ok": bool, "intent": str, "created_paths": [...],
|
|
310
|
+
"id_to_path": {...}, "error": "..." (only if ok=false)}
|
|
311
|
+
"""
|
|
312
|
+
intent = str(spec.get("intent") or "")
|
|
313
|
+
nodes_spec = list(spec.get("nodes") or [])
|
|
314
|
+
connections_spec = list(spec.get("connections") or [])
|
|
315
|
+
do_layout = bool(spec.get("layout", True))
|
|
316
|
+
do_cook = bool(spec.get("cook", False))
|
|
317
|
+
|
|
318
|
+
error = _validate_spec(nodes_spec, connections_spec)
|
|
319
|
+
if error:
|
|
320
|
+
return {
|
|
321
|
+
"ok": False,
|
|
322
|
+
"intent": intent,
|
|
323
|
+
"created_paths": [],
|
|
324
|
+
"id_to_path": {},
|
|
325
|
+
"error": error,
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
# Sort so parent-creating nodes always precede their children.
|
|
329
|
+
sorted_nodes = _topo_sort_nodes(nodes_spec)
|
|
330
|
+
|
|
331
|
+
# Paths that will be created by nodes in this spec — skip the pre-flight
|
|
332
|
+
# node_exists check for these (they don't exist yet, by design).
|
|
333
|
+
will_create: set[str] = {_expected_path(n) for n in sorted_nodes if _expected_path(n)}
|
|
334
|
+
|
|
335
|
+
bridge = _bridge()
|
|
336
|
+
|
|
337
|
+
# Pre-flight: verify that external parents (not created in this spec) exist.
|
|
338
|
+
for n in sorted_nodes:
|
|
339
|
+
parent = n["parent"]
|
|
340
|
+
if parent in will_create:
|
|
341
|
+
continue # will be satisfied by a preceding node in sorted_nodes
|
|
342
|
+
try:
|
|
343
|
+
exists = await _to_thread(bridge.node_exists, parent)
|
|
344
|
+
except Exception as exc:
|
|
345
|
+
return _failure(intent, [], {}, f"node_exists check failed for {parent}: {exc}")
|
|
346
|
+
if not (isinstance(exists, dict) and exists.get("exists")):
|
|
347
|
+
return _failure(intent, [], {}, f"parent node does not exist: {parent}")
|
|
348
|
+
|
|
349
|
+
id_to_path: Dict[str, str] = {}
|
|
350
|
+
created_paths: List[str] = []
|
|
351
|
+
parents_seen: List[str] = []
|
|
352
|
+
# Maps expected_path → actual_path so we can fix parent refs when Houdini
|
|
353
|
+
# assigns a numbered suffix (e.g. pyro_src_geo1 instead of pyro_src_geo).
|
|
354
|
+
actual_by_expected: Dict[str, str] = {}
|
|
355
|
+
|
|
356
|
+
for n in sorted_nodes:
|
|
357
|
+
node_id = n["id"]
|
|
358
|
+
# Patch parent if a preceding node in this spec was created with a
|
|
359
|
+
# different actual path than we predicted (Houdini name collision).
|
|
360
|
+
parent = actual_by_expected.get(n["parent"], n["parent"])
|
|
361
|
+
try:
|
|
362
|
+
result = await _to_thread(
|
|
363
|
+
bridge.create_node,
|
|
364
|
+
parent, n["type"], n.get("name", ""),
|
|
365
|
+
)
|
|
366
|
+
except Exception as exc:
|
|
367
|
+
return _failure(intent, created_paths, id_to_path, f"create_node failed for '{node_id}': {exc}")
|
|
368
|
+
path = (result or {}).get("path") or ""
|
|
369
|
+
if not path:
|
|
370
|
+
return _failure(intent, created_paths, id_to_path, f"create_node returned no path for '{node_id}'")
|
|
371
|
+
id_to_path[node_id] = path
|
|
372
|
+
created_paths.append(path)
|
|
373
|
+
if parent not in parents_seen:
|
|
374
|
+
parents_seen.append(parent)
|
|
375
|
+
|
|
376
|
+
# Record mapping so children of this node use the real path.
|
|
377
|
+
ep = _expected_path(n)
|
|
378
|
+
if ep and ep != path:
|
|
379
|
+
actual_by_expected[ep] = path
|
|
380
|
+
|
|
381
|
+
params = n.get("params") or {}
|
|
382
|
+
if params:
|
|
383
|
+
try:
|
|
384
|
+
await _to_thread(bridge.set_parms, path, params)
|
|
385
|
+
except Exception as exc:
|
|
386
|
+
return _failure(intent, created_paths, id_to_path, f"set_parms failed for '{node_id}' ({path}): {exc}")
|
|
387
|
+
|
|
388
|
+
for c in connections_spec:
|
|
389
|
+
from_path = id_to_path[c["from"]]
|
|
390
|
+
to_path = id_to_path[c["to"]]
|
|
391
|
+
try:
|
|
392
|
+
await _to_thread(
|
|
393
|
+
bridge.connect_nodes,
|
|
394
|
+
from_path, to_path,
|
|
395
|
+
int(c.get("out", 0)), int(c.get("in", 0)),
|
|
396
|
+
)
|
|
397
|
+
except Exception as exc:
|
|
398
|
+
return _failure(intent, created_paths, id_to_path, f"connect_nodes failed for {c['from']}→{c['to']}: {exc}")
|
|
399
|
+
|
|
400
|
+
if do_layout:
|
|
401
|
+
for parent in parents_seen:
|
|
402
|
+
try:
|
|
403
|
+
await _to_thread(bridge.layout_children, parent)
|
|
404
|
+
except Exception:
|
|
405
|
+
pass # layout is decorative — never fail the build for this
|
|
406
|
+
|
|
407
|
+
if do_cook and created_paths:
|
|
408
|
+
last = created_paths[-1]
|
|
409
|
+
try:
|
|
410
|
+
await _to_thread(bridge.cook_node, last, False)
|
|
411
|
+
except Exception as exc:
|
|
412
|
+
return _failure(intent, created_paths, id_to_path, f"cook_node failed for {last}: {exc}")
|
|
413
|
+
|
|
414
|
+
# Mutating op — bump cache so subsequent scene_context() reflects reality.
|
|
415
|
+
get_scene_cache().invalidate("scene_context::")
|
|
416
|
+
|
|
417
|
+
return {
|
|
418
|
+
"ok": True,
|
|
419
|
+
"intent": intent,
|
|
420
|
+
"created_paths": created_paths,
|
|
421
|
+
"id_to_path": dict(id_to_path),
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
def _validate_spec(nodes_spec: List[dict], connections_spec: List[dict]) -> Optional[str]:
|
|
426
|
+
if not nodes_spec:
|
|
427
|
+
return "spec.nodes must contain at least one node"
|
|
428
|
+
|
|
429
|
+
seen_ids: set[str] = set()
|
|
430
|
+
for i, n in enumerate(nodes_spec):
|
|
431
|
+
if not isinstance(n, dict):
|
|
432
|
+
return f"spec.nodes[{i}] must be a dict, got {type(n).__name__}"
|
|
433
|
+
for key in ("id", "parent", "type"):
|
|
434
|
+
if not n.get(key):
|
|
435
|
+
return f"spec.nodes[{i}] missing required field '{key}'"
|
|
436
|
+
nid = n["id"]
|
|
437
|
+
if nid in seen_ids:
|
|
438
|
+
return f"duplicate node id: '{nid}'"
|
|
439
|
+
seen_ids.add(nid)
|
|
440
|
+
|
|
441
|
+
for i, c in enumerate(connections_spec):
|
|
442
|
+
if not isinstance(c, dict):
|
|
443
|
+
return f"spec.connections[{i}] must be a dict, got {type(c).__name__}"
|
|
444
|
+
for key in ("from", "to"):
|
|
445
|
+
if not c.get(key):
|
|
446
|
+
return f"spec.connections[{i}] missing required field '{key}'"
|
|
447
|
+
if c["from"] not in seen_ids:
|
|
448
|
+
return f"connection {i} references unknown node id '{c['from']}'"
|
|
449
|
+
if c["to"] not in seen_ids:
|
|
450
|
+
return f"connection {i} references unknown node id '{c['to']}'"
|
|
451
|
+
return None
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
def _failure(intent: str, created: List[str], id_to_path: Dict[str, str], message: str) -> Dict[str, Any]:
|
|
455
|
+
return {
|
|
456
|
+
"ok": False,
|
|
457
|
+
"intent": intent,
|
|
458
|
+
"created_paths": list(created),
|
|
459
|
+
"id_to_path": dict(id_to_path),
|
|
460
|
+
"error": message,
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
# ---------------------------------------------------------------------------
|
|
465
|
+
# Convenience: scene_context serialised for LLM prompts
|
|
466
|
+
# ---------------------------------------------------------------------------
|
|
467
|
+
|
|
468
|
+
def context_to_prompt(context: Dict[str, Any]) -> str:
|
|
469
|
+
"""Pre-serialise a scene_context dict to a compact JSON string."""
|
|
470
|
+
return json.dumps(context, indent=2, sort_keys=True, default=str)
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
# ---------------------------------------------------------------------------
|
|
474
|
+
# Semantic operation execution (Tier 2)
|
|
475
|
+
# ---------------------------------------------------------------------------
|
|
476
|
+
#
|
|
477
|
+
# Each supported operation is a structured dict with an "op" discriminator
|
|
478
|
+
# plus type-specific params. The transaction system feeds these in one at a
|
|
479
|
+
# time; this module is responsible for:
|
|
480
|
+
# 1. validating each op shape
|
|
481
|
+
# 2. capturing a rollback snapshot BEFORE mutating
|
|
482
|
+
# 3. executing via the bridge
|
|
483
|
+
# 4. marking the appropriate dirty-state entries
|
|
484
|
+
# 5. exposing a paired rollback handler for the transaction manager
|
|
485
|
+
#
|
|
486
|
+
# The same op vocabulary is also used by `build_node_chain` internally.
|
|
487
|
+
# Adding a new op type means:
|
|
488
|
+
# • add an entry to _OP_EXECUTORS
|
|
489
|
+
# • add a paired entry to _OP_ROLLBACKERS
|
|
490
|
+
# • register the rollback in `_register_rollback_handlers()` (called at
|
|
491
|
+
# module import time)
|
|
492
|
+
#
|
|
493
|
+
# We DELIBERATELY do not expose a "run_python" or "execute_code" op.
|
|
494
|
+
# Arbitrary Python execution would break the AI-Plan → Transaction guarantee
|
|
495
|
+
# that operations are structured, validated, and deterministic.
|
|
496
|
+
|
|
497
|
+
SUPPORTED_OPS = (
|
|
498
|
+
"create_node",
|
|
499
|
+
"set_parms",
|
|
500
|
+
"connect_nodes",
|
|
501
|
+
"delete_node",
|
|
502
|
+
"set_display_flag",
|
|
503
|
+
"set_render_flag",
|
|
504
|
+
"set_keyframe",
|
|
505
|
+
"cook_node",
|
|
506
|
+
"layout_children",
|
|
507
|
+
"build_node_chain",
|
|
508
|
+
)
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
def _validate_operation(op: Dict[str, Any]) -> Optional[str]:
|
|
512
|
+
"""Return None if the op is well-formed, else an error string."""
|
|
513
|
+
if not isinstance(op, dict):
|
|
514
|
+
return f"operation must be a dict, got {type(op).__name__}"
|
|
515
|
+
op_type = op.get("op")
|
|
516
|
+
if op_type not in SUPPORTED_OPS:
|
|
517
|
+
return f"unsupported op '{op_type}'. Supported: {sorted(SUPPORTED_OPS)}"
|
|
518
|
+
|
|
519
|
+
required: Dict[str, tuple] = {
|
|
520
|
+
"create_node": ("parent", "type"),
|
|
521
|
+
"set_parms": ("node", "parms"),
|
|
522
|
+
"connect_nodes": ("from", "to"),
|
|
523
|
+
"delete_node": ("path",),
|
|
524
|
+
"set_display_flag": ("path",),
|
|
525
|
+
"set_render_flag": ("path",),
|
|
526
|
+
"set_keyframe": ("node", "parm", "frame", "value"),
|
|
527
|
+
"cook_node": ("path",),
|
|
528
|
+
"layout_children": ("path",),
|
|
529
|
+
"build_node_chain": ("spec",),
|
|
530
|
+
}
|
|
531
|
+
for field in required.get(op_type, ()):
|
|
532
|
+
if op.get(field) is None or op.get(field) == "":
|
|
533
|
+
return f"op '{op_type}' missing required field '{field}'"
|
|
534
|
+
|
|
535
|
+
if op_type == "set_parms" and not isinstance(op.get("parms"), dict):
|
|
536
|
+
return "op 'set_parms' requires 'parms' to be a dict"
|
|
537
|
+
if op_type == "build_node_chain" and not isinstance(op.get("spec"), dict):
|
|
538
|
+
return "op 'build_node_chain' requires 'spec' to be a dict"
|
|
539
|
+
return None
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
async def execute_operation(op: Dict[str, Any]) -> Dict[str, Any]:
|
|
543
|
+
"""Execute a single structured operation against Houdini.
|
|
544
|
+
|
|
545
|
+
Returns a dict suitable for `TransactionManager.record_operation`:
|
|
546
|
+
{"op", "params", "result", "snapshot", "status", "dirty", "error"?}
|
|
547
|
+
|
|
548
|
+
Never raises — failures are returned with status="failed" and an "error".
|
|
549
|
+
"""
|
|
550
|
+
error = _validate_operation(op)
|
|
551
|
+
if error is not None:
|
|
552
|
+
return {
|
|
553
|
+
"op": op.get("op", "<invalid>"),
|
|
554
|
+
"params": dict(op),
|
|
555
|
+
"result": None,
|
|
556
|
+
"snapshot": {},
|
|
557
|
+
"status": "failed",
|
|
558
|
+
"error": error,
|
|
559
|
+
"dirty": [],
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
op_type = op["op"]
|
|
563
|
+
executor = _OP_EXECUTORS[op_type]
|
|
564
|
+
try:
|
|
565
|
+
return await executor(op)
|
|
566
|
+
except Exception as exc: # noqa: BLE001
|
|
567
|
+
return {
|
|
568
|
+
"op": op_type,
|
|
569
|
+
"params": dict(op),
|
|
570
|
+
"result": None,
|
|
571
|
+
"snapshot": {},
|
|
572
|
+
"status": "failed",
|
|
573
|
+
"error": f"{type(exc).__name__}: {exc}",
|
|
574
|
+
"dirty": [],
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
# ----- Executors -----------------------------------------------------------
|
|
579
|
+
|
|
580
|
+
async def _exec_create_node(op: Dict[str, Any]) -> Dict[str, Any]:
|
|
581
|
+
bridge = _bridge()
|
|
582
|
+
parent = op["parent"]
|
|
583
|
+
node_type = op["type"]
|
|
584
|
+
name = op.get("name", "")
|
|
585
|
+
result = await _to_thread(bridge.create_node, parent, node_type, name) or {}
|
|
586
|
+
path = result.get("path") or ""
|
|
587
|
+
cache = get_scene_cache()
|
|
588
|
+
if path:
|
|
589
|
+
cache.mark_node_created(path)
|
|
590
|
+
cache.invalidate("scene_context::")
|
|
591
|
+
return {
|
|
592
|
+
"op": "create_node",
|
|
593
|
+
"params": {"parent": parent, "type": node_type, "name": name},
|
|
594
|
+
"result": {"path": path, "name": result.get("name", name), "type": result.get("type", node_type)},
|
|
595
|
+
"snapshot": {"created_path": path},
|
|
596
|
+
"status": "ok" if path else "failed",
|
|
597
|
+
"dirty": [path] if path else [],
|
|
598
|
+
"error": "" if path else "create_node returned empty path",
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
async def _exec_set_parms(op: Dict[str, Any]) -> Dict[str, Any]:
|
|
603
|
+
bridge = _bridge()
|
|
604
|
+
node = op["node"]
|
|
605
|
+
new_parms = dict(op["parms"])
|
|
606
|
+
prev: Dict[str, Any] = {}
|
|
607
|
+
for key in new_parms:
|
|
608
|
+
try:
|
|
609
|
+
r = await _to_thread(bridge.get_parm, node, key)
|
|
610
|
+
prev[key] = r.get("value") if isinstance(r, dict) else r
|
|
611
|
+
except Exception:
|
|
612
|
+
prev[key] = None
|
|
613
|
+
await _to_thread(bridge.set_parms, node, new_parms)
|
|
614
|
+
cache = get_scene_cache()
|
|
615
|
+
cache.mark_node_dirty(node)
|
|
616
|
+
cache.invalidate("scene_context::")
|
|
617
|
+
return {
|
|
618
|
+
"op": "set_parms",
|
|
619
|
+
"params": {"node": node, "parms": new_parms},
|
|
620
|
+
"result": {"node": node, "parm_count": len(new_parms)},
|
|
621
|
+
"snapshot": {"node": node, "prev": prev},
|
|
622
|
+
"status": "ok",
|
|
623
|
+
"dirty": [node],
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
async def _exec_connect_nodes(op: Dict[str, Any]) -> Dict[str, Any]:
|
|
628
|
+
bridge = _bridge()
|
|
629
|
+
from_path = op["from"]
|
|
630
|
+
to_path = op["to"]
|
|
631
|
+
out_idx = int(op.get("out", 0))
|
|
632
|
+
in_idx = int(op.get("in", 0))
|
|
633
|
+
|
|
634
|
+
# Snapshot previous input on the target so we can restore it on rollback.
|
|
635
|
+
prev_from = await _read_input_source(bridge, to_path, in_idx)
|
|
636
|
+
|
|
637
|
+
await _to_thread(bridge.connect_nodes, from_path, to_path, out_idx, in_idx)
|
|
638
|
+
cache = get_scene_cache()
|
|
639
|
+
cache.mark_connection_changed(from_path, to_path, in_idx)
|
|
640
|
+
cache.invalidate("scene_context::")
|
|
641
|
+
return {
|
|
642
|
+
"op": "connect_nodes",
|
|
643
|
+
"params": {"from": from_path, "to": to_path, "out": out_idx, "in": in_idx},
|
|
644
|
+
"result": {"from": from_path, "to": to_path, "in": in_idx},
|
|
645
|
+
"snapshot": {"to": to_path, "in": in_idx, "prev_from": prev_from},
|
|
646
|
+
"status": "ok",
|
|
647
|
+
"dirty": [to_path],
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
async def _exec_delete_node(op: Dict[str, Any]) -> Dict[str, Any]:
|
|
652
|
+
bridge = _bridge()
|
|
653
|
+
path = op["path"]
|
|
654
|
+
# Capture a thin snapshot for diagnostics (rollback cannot reconstruct
|
|
655
|
+
# the node — see docs in _rollback_delete_node).
|
|
656
|
+
try:
|
|
657
|
+
info = await _to_thread(bridge.node_info, path)
|
|
658
|
+
except Exception:
|
|
659
|
+
info = {}
|
|
660
|
+
await _to_thread(bridge.delete_node, path)
|
|
661
|
+
cache = get_scene_cache()
|
|
662
|
+
cache.mark_node_deleted(path)
|
|
663
|
+
cache.invalidate("scene_context::")
|
|
664
|
+
return {
|
|
665
|
+
"op": "delete_node",
|
|
666
|
+
"params": {"path": path},
|
|
667
|
+
"result": {"path": path},
|
|
668
|
+
"snapshot": {"path": path, "info": info, "restorable": False},
|
|
669
|
+
"status": "ok",
|
|
670
|
+
"dirty": [path],
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
async def _exec_set_display_flag(op: Dict[str, Any]) -> Dict[str, Any]:
|
|
675
|
+
return await _exec_set_flag(op, kind="display")
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
async def _exec_set_render_flag(op: Dict[str, Any]) -> Dict[str, Any]:
|
|
679
|
+
return await _exec_set_flag(op, kind="render")
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
async def _exec_set_keyframe(op: Dict[str, Any]) -> Dict[str, Any]:
|
|
683
|
+
bridge = _bridge()
|
|
684
|
+
node = op["node"]
|
|
685
|
+
parm = op["parm"]
|
|
686
|
+
frame = float(op["frame"])
|
|
687
|
+
value = op["value"]
|
|
688
|
+
try:
|
|
689
|
+
r = await _to_thread(bridge.get_parm, node, parm)
|
|
690
|
+
prev = r.get("value") if isinstance(r, dict) else r
|
|
691
|
+
except Exception:
|
|
692
|
+
prev = None
|
|
693
|
+
await _to_thread(bridge.set_keyframe, node, parm, frame, value)
|
|
694
|
+
cache = get_scene_cache()
|
|
695
|
+
cache.mark_node_dirty(node)
|
|
696
|
+
cache.invalidate("scene_context::")
|
|
697
|
+
return {
|
|
698
|
+
"op": "set_keyframe",
|
|
699
|
+
"params": {"node": node, "parm": parm, "frame": frame, "value": value},
|
|
700
|
+
"result": {"node": node, "parm": parm, "frame": frame, "value": value},
|
|
701
|
+
"snapshot": {"node": node, "parm": parm, "prev": prev},
|
|
702
|
+
"status": "ok",
|
|
703
|
+
"dirty": [node],
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
async def _exec_set_flag(op: Dict[str, Any], kind: str) -> Dict[str, Any]:
|
|
708
|
+
bridge = _bridge()
|
|
709
|
+
path = op["path"]
|
|
710
|
+
on = bool(op.get("on", True))
|
|
711
|
+
prev = await _read_flag(bridge, path, kind)
|
|
712
|
+
setter = bridge.set_display_flag if kind == "display" else bridge.set_render_flag
|
|
713
|
+
await _to_thread(setter, path, on)
|
|
714
|
+
cache = get_scene_cache()
|
|
715
|
+
cache.mark_flag_changed(path)
|
|
716
|
+
cache.invalidate("scene_context::")
|
|
717
|
+
return {
|
|
718
|
+
"op": f"set_{kind}_flag",
|
|
719
|
+
"params": {"path": path, "on": on},
|
|
720
|
+
"result": {"path": path, "on": on},
|
|
721
|
+
"snapshot": {"path": path, "kind": kind, "prev": prev},
|
|
722
|
+
"status": "ok",
|
|
723
|
+
"dirty": [path],
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
async def _exec_cook_node(op: Dict[str, Any]) -> Dict[str, Any]:
|
|
728
|
+
bridge = _bridge()
|
|
729
|
+
path = op["path"]
|
|
730
|
+
force = bool(op.get("force", False))
|
|
731
|
+
await _to_thread(bridge.cook_node, path, force)
|
|
732
|
+
get_scene_cache().mark_node_cooked(path)
|
|
733
|
+
return {
|
|
734
|
+
"op": "cook_node",
|
|
735
|
+
"params": {"path": path, "force": force},
|
|
736
|
+
"result": {"path": path, "cooked": True},
|
|
737
|
+
"snapshot": {"path": path}, # cook has no inverse
|
|
738
|
+
"status": "ok",
|
|
739
|
+
"dirty": [path],
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
async def _exec_layout_children(op: Dict[str, Any]) -> Dict[str, Any]:
|
|
744
|
+
bridge = _bridge()
|
|
745
|
+
path = op["path"]
|
|
746
|
+
await _to_thread(bridge.layout_children, path)
|
|
747
|
+
return {
|
|
748
|
+
"op": "layout_children",
|
|
749
|
+
"params": {"path": path},
|
|
750
|
+
"result": {"path": path},
|
|
751
|
+
"snapshot": {"path": path}, # layout has no meaningful inverse
|
|
752
|
+
"status": "ok",
|
|
753
|
+
"dirty": [],
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
async def _exec_build_node_chain(op: Dict[str, Any]) -> Dict[str, Any]:
|
|
758
|
+
spec = op["spec"]
|
|
759
|
+
result = await build_node_chain(spec)
|
|
760
|
+
created = list(result.get("created_paths") or [])
|
|
761
|
+
return {
|
|
762
|
+
"op": "build_node_chain",
|
|
763
|
+
"params": {"spec": spec},
|
|
764
|
+
"result": result,
|
|
765
|
+
"snapshot": {"created_paths": created},
|
|
766
|
+
"status": "ok" if result.get("ok") else "failed",
|
|
767
|
+
"dirty": list(created),
|
|
768
|
+
"error": result.get("error", "") or "",
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
_OP_EXECUTORS: Dict[str, Callable[[Dict[str, Any]], Any]] = {
|
|
773
|
+
"create_node": _exec_create_node,
|
|
774
|
+
"set_parms": _exec_set_parms,
|
|
775
|
+
"connect_nodes": _exec_connect_nodes,
|
|
776
|
+
"delete_node": _exec_delete_node,
|
|
777
|
+
"set_display_flag": _exec_set_display_flag,
|
|
778
|
+
"set_render_flag": _exec_set_render_flag,
|
|
779
|
+
"set_keyframe": _exec_set_keyframe,
|
|
780
|
+
"cook_node": _exec_cook_node,
|
|
781
|
+
"layout_children": _exec_layout_children,
|
|
782
|
+
"build_node_chain": _exec_build_node_chain,
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
# ----- Rollback handlers ---------------------------------------------------
|
|
787
|
+
#
|
|
788
|
+
# Each handler receives the FULL recorded operation dict (params + result +
|
|
789
|
+
# snapshot). MUST NOT raise; returns {"ok": bool, "error"?: str, ...}.
|
|
790
|
+
|
|
791
|
+
async def _rollback_create_node(recorded: Dict[str, Any]) -> Dict[str, Any]:
|
|
792
|
+
path = (recorded.get("snapshot") or {}).get("created_path", "")
|
|
793
|
+
if not path:
|
|
794
|
+
return {"ok": True, "note": "nothing to undo (no path captured)"}
|
|
795
|
+
try:
|
|
796
|
+
await _to_thread(_bridge().delete_node, path)
|
|
797
|
+
get_scene_cache().mark_node_deleted(path)
|
|
798
|
+
return {"ok": True, "undone": path}
|
|
799
|
+
except Exception as exc: # noqa: BLE001
|
|
800
|
+
return {"ok": False, "error": f"delete failed: {type(exc).__name__}: {exc}"}
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
async def _rollback_set_parms(recorded: Dict[str, Any]) -> Dict[str, Any]:
|
|
804
|
+
snap = recorded.get("snapshot") or {}
|
|
805
|
+
node = snap.get("node", "")
|
|
806
|
+
prev = snap.get("prev") or {}
|
|
807
|
+
if not node:
|
|
808
|
+
return {"ok": True, "note": "nothing to undo"}
|
|
809
|
+
restored: Dict[str, Any] = {}
|
|
810
|
+
errors: List[str] = []
|
|
811
|
+
bridge = _bridge()
|
|
812
|
+
for key, value in prev.items():
|
|
813
|
+
if value is None:
|
|
814
|
+
errors.append(f"no prev for '{key}' — skipped")
|
|
815
|
+
continue
|
|
816
|
+
try:
|
|
817
|
+
await _to_thread(bridge.set_parm, node, key, value)
|
|
818
|
+
restored[key] = value
|
|
819
|
+
except Exception as exc: # noqa: BLE001
|
|
820
|
+
errors.append(f"{key}: {type(exc).__name__}: {exc}")
|
|
821
|
+
get_scene_cache().mark_node_dirty(node)
|
|
822
|
+
return {"ok": not errors, "restored": restored, "error": "; ".join(errors) if errors else ""}
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
async def _rollback_set_keyframe(recorded: Dict[str, Any]) -> Dict[str, Any]:
|
|
826
|
+
snap = recorded.get("snapshot") or {}
|
|
827
|
+
node = snap.get("node", "")
|
|
828
|
+
parm = snap.get("parm", "")
|
|
829
|
+
prev = snap.get("prev")
|
|
830
|
+
if not node or not parm:
|
|
831
|
+
return {"ok": True, "note": "nothing to undo"}
|
|
832
|
+
if prev is None:
|
|
833
|
+
return {"ok": True, "note": f"no previous value captured for '{node}.{parm}'"}
|
|
834
|
+
try:
|
|
835
|
+
await _to_thread(_bridge().set_parm, node, parm, prev)
|
|
836
|
+
get_scene_cache().mark_node_dirty(node)
|
|
837
|
+
return {"ok": True, "restored": {parm: prev}}
|
|
838
|
+
except Exception as exc: # noqa: BLE001
|
|
839
|
+
return {"ok": False, "error": f"{type(exc).__name__}: {exc}"}
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
async def _rollback_connect_nodes(recorded: Dict[str, Any]) -> Dict[str, Any]:
|
|
843
|
+
snap = recorded.get("snapshot") or {}
|
|
844
|
+
to_path = snap.get("to", "")
|
|
845
|
+
in_idx = int(snap.get("in", 0))
|
|
846
|
+
prev_from = snap.get("prev_from")
|
|
847
|
+
if not to_path:
|
|
848
|
+
return {"ok": True, "note": "nothing to undo"}
|
|
849
|
+
try:
|
|
850
|
+
if prev_from:
|
|
851
|
+
# Restore prior connection
|
|
852
|
+
await _to_thread(_bridge().connect_nodes, prev_from, to_path, 0, in_idx)
|
|
853
|
+
return {"ok": True, "restored_from": prev_from}
|
|
854
|
+
else:
|
|
855
|
+
await _disconnect_input(_bridge(), to_path, in_idx)
|
|
856
|
+
return {"ok": True, "disconnected": to_path}
|
|
857
|
+
except Exception as exc: # noqa: BLE001
|
|
858
|
+
return {"ok": False, "error": f"{type(exc).__name__}: {exc}"}
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
async def _rollback_delete_node(recorded: Dict[str, Any]) -> Dict[str, Any]:
|
|
862
|
+
# Tier 2 limitation — deleting a node is unrecoverable without a full
|
|
863
|
+
# HIP snapshot. Report the limitation explicitly so audit logs are honest.
|
|
864
|
+
path = (recorded.get("snapshot") or {}).get("path", "")
|
|
865
|
+
return {
|
|
866
|
+
"ok": False,
|
|
867
|
+
"error": (
|
|
868
|
+
f"cannot restore deleted node '{path}' in Tier 2 "
|
|
869
|
+
"(no HIP snapshot system yet)."
|
|
870
|
+
),
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
async def _rollback_set_flag(recorded: Dict[str, Any]) -> Dict[str, Any]:
|
|
875
|
+
snap = recorded.get("snapshot") or {}
|
|
876
|
+
path = snap.get("path", "")
|
|
877
|
+
kind = snap.get("kind", "")
|
|
878
|
+
prev = snap.get("prev")
|
|
879
|
+
if not path or kind not in ("display", "render"):
|
|
880
|
+
return {"ok": True, "note": "nothing to undo"}
|
|
881
|
+
if prev is None:
|
|
882
|
+
return {
|
|
883
|
+
"ok": False,
|
|
884
|
+
"error": f"no prev {kind} flag state captured for '{path}'",
|
|
885
|
+
}
|
|
886
|
+
try:
|
|
887
|
+
setter = _bridge().set_display_flag if kind == "display" else _bridge().set_render_flag
|
|
888
|
+
await _to_thread(setter, path, bool(prev))
|
|
889
|
+
get_scene_cache().mark_flag_changed(path)
|
|
890
|
+
return {"ok": True, "restored": bool(prev)}
|
|
891
|
+
except Exception as exc: # noqa: BLE001
|
|
892
|
+
return {"ok": False, "error": f"{type(exc).__name__}: {exc}"}
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
async def _rollback_noop(recorded: Dict[str, Any]) -> Dict[str, Any]:
|
|
896
|
+
return {"ok": True, "note": f"op '{recorded.get('op')}' has no inverse"}
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
async def _rollback_build_node_chain(recorded: Dict[str, Any]) -> Dict[str, Any]:
|
|
900
|
+
created = list((recorded.get("snapshot") or {}).get("created_paths") or [])
|
|
901
|
+
if not created:
|
|
902
|
+
return {"ok": True, "note": "no nodes created"}
|
|
903
|
+
bridge = _bridge()
|
|
904
|
+
errors: List[str] = []
|
|
905
|
+
deleted: List[str] = []
|
|
906
|
+
for path in reversed(created):
|
|
907
|
+
try:
|
|
908
|
+
await _to_thread(bridge.delete_node, path)
|
|
909
|
+
deleted.append(path)
|
|
910
|
+
get_scene_cache().mark_node_deleted(path)
|
|
911
|
+
except Exception as exc: # noqa: BLE001
|
|
912
|
+
errors.append(f"{path}: {type(exc).__name__}: {exc}")
|
|
913
|
+
return {"ok": not errors, "deleted": deleted, "error": "; ".join(errors) if errors else ""}
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
_OP_ROLLBACKERS: Dict[str, Any] = {
|
|
917
|
+
"create_node": _rollback_create_node,
|
|
918
|
+
"set_parms": _rollback_set_parms,
|
|
919
|
+
"connect_nodes": _rollback_connect_nodes,
|
|
920
|
+
"delete_node": _rollback_delete_node,
|
|
921
|
+
"set_display_flag": _rollback_set_flag,
|
|
922
|
+
"set_render_flag": _rollback_set_flag,
|
|
923
|
+
"set_keyframe": _rollback_set_keyframe,
|
|
924
|
+
"cook_node": _rollback_noop,
|
|
925
|
+
"layout_children": _rollback_noop,
|
|
926
|
+
"build_node_chain": _rollback_build_node_chain,
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
# ----- Bridge helpers used by execute / rollback ---------------------------
|
|
931
|
+
|
|
932
|
+
async def _read_flag(bridge, path: str, kind: str) -> Optional[bool]:
|
|
933
|
+
"""Read display or render flag via run_code (no dedicated bridge method)."""
|
|
934
|
+
attr = "isDisplayFlagSet" if kind == "display" else "isRenderFlagSet"
|
|
935
|
+
code = (
|
|
936
|
+
f"_n = hou.node('{path}')\n"
|
|
937
|
+
f"if _n is not None and hasattr(_n, '{attr}'):\n"
|
|
938
|
+
f" result = bool(_n.{attr}())\n"
|
|
939
|
+
f"else:\n"
|
|
940
|
+
f" result = None\n"
|
|
941
|
+
)
|
|
942
|
+
try:
|
|
943
|
+
r = await _to_thread(bridge.run_code, code)
|
|
944
|
+
return r.get("result") if isinstance(r, dict) else None
|
|
945
|
+
except Exception:
|
|
946
|
+
return None
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
async def _read_input_source(bridge, target_path: str, in_idx: int) -> Optional[str]:
|
|
950
|
+
"""Return the path of the node currently feeding input `in_idx` of target."""
|
|
951
|
+
code = (
|
|
952
|
+
f"_n = hou.node('{target_path}')\n"
|
|
953
|
+
f"if _n is None:\n"
|
|
954
|
+
f" result = None\n"
|
|
955
|
+
f"else:\n"
|
|
956
|
+
f" _inputs = list(_n.inputs())\n"
|
|
957
|
+
f" if {in_idx} < len(_inputs) and _inputs[{in_idx}] is not None:\n"
|
|
958
|
+
f" result = _inputs[{in_idx}].path()\n"
|
|
959
|
+
f" else:\n"
|
|
960
|
+
f" result = None\n"
|
|
961
|
+
)
|
|
962
|
+
try:
|
|
963
|
+
r = await _to_thread(bridge.run_code, code)
|
|
964
|
+
return r.get("result") if isinstance(r, dict) else None
|
|
965
|
+
except Exception:
|
|
966
|
+
return None
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
async def _disconnect_input(bridge, target_path: str, in_idx: int) -> None:
|
|
970
|
+
code = (
|
|
971
|
+
f"_n = hou.node('{target_path}')\n"
|
|
972
|
+
f"if _n is not None and {in_idx} < len(_n.inputs()):\n"
|
|
973
|
+
f" _n.setInput({in_idx}, None)\n"
|
|
974
|
+
)
|
|
975
|
+
await _to_thread(bridge.run_code, code)
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
# ----- Handler registration ------------------------------------------------
|
|
979
|
+
|
|
980
|
+
def _register_rollback_handlers() -> None:
|
|
981
|
+
"""Register Houdini rollback handlers with the transaction manager.
|
|
982
|
+
|
|
983
|
+
Called at module import time so any code path that imports
|
|
984
|
+
`src.runtime.houdini_runtime` (which is everything that mutates Houdini)
|
|
985
|
+
transparently gets the rollback contract.
|
|
986
|
+
"""
|
|
987
|
+
from src.runtime import transaction_manager as _tm
|
|
988
|
+
for op_type, handler in _OP_ROLLBACKERS.items():
|
|
989
|
+
_tm.register_rollback_handler(op_type, handler)
|
|
990
|
+
|
|
991
|
+
|
|
992
|
+
_register_rollback_handlers()
|