fix(core): validate scan sequence bounds and array dimensions across FTL, latent WM, CBP, and Step 4 - #2039
Conversation
…FTL, latent WM, CBP, and Step 4 Add explicit sequence length bounds checking (1 <= num_steps <= INT32_MAX), exact component/state type verification, trusted array metadata enforcement, rank/shape compatibility checking, and output resource preflight to array scan and learning loop functions in SparseFTLWorldModel, LatentWorldModel, ContinualBackprop, OptionValueDurationLearner, Step 4 SARSA, and core learners.
|
Automated review ran but produced no report; leaving for a maintainer. |
|
Blocking: the new validators do not impose a finite scan ceiling. The affected paths call Please use a documented finite ceiling at every affected scan (the sibling convention is 10,000), validate type/rank/leading length before materialization where applicable, and add regression tests that prove an oversized input is rejected before |
Summary
Hardens array-based transition scanning and learning loop routines against untrusted array types, incompatible array dimensions/ranks, invalid sequence lengths (
num_steps < 1or overflow), and potential signed-int32 scalar/byte allocation overflows across:alberta_framework.core.ftl_world_model.run_sparse_ftl_world_modelalberta_framework.core.latent_world_model.run_latent_world_model_learning_loopalberta_framework.core.continual_backprop.run_cbp_learning_loopalberta_framework.core.option_value_duration.run_option_value_duration_from_arraysalberta_framework.steps.step4.run_step4_scanalberta_framework.core.learners(run_learning_loop,run_learning_loop_batched,run_mlp_learning_loop,run_mlp_learning_loop_batched,run_td_learning_loop,run_true_online_td_loop)Key Changes
np.ndarray,jax.Array, orjax.core.Tracerinstances with conforming shapes.1 <= num_steps <= 2**31 - 1with canonical int index coercion rejecting boolean/float scalar aliases.tests/test_scan_sequence_bounds_validation.pycovering positive evaluation and negative invalid type/shape/length error paths.Validation
pytest tests/test_scan_sequence_bounds_validation.py-> 6/6 passedpytest tests/test_ftl_world_model.py tests/test_latent_world_model.py tests/test_continual_backprop.py tests/test_option_value_duration.py tests/test_step4_production.py tests/test_td_learners.py tests/test_scan_sequence_bounds_validation.py-> 371/371 passedruff check .-> passedmypy-> passed