Enforce explicit control-flow modeling across SML machine code#31
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enforces the project’s updated SML policy requiring explicit modeling of runtime control flow by removing runtime if/switch/?: constructs from action/member-method/helper surfaces and updating the accompanying compliance documentation.
Changes:
- Updates SML rules/policy language to explicitly ban runtime branching statements and require modeled control flow (guards/choice states).
- Refactors multiple runtime/helper implementations to replace branching with explicit/branchless control-flow modeling patterns.
- Adds compliance audit artifacts (
docs/compliance-report.md,docs/runtime-conditionals-todo.md) and updates generated architecture docs.
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/emel/token/batcher/guards.hpp | Switches includes to use the new action/detail surface arrangement. |
| src/emel/token/batcher/detail.hpp | Collapses former helper implementation into the actions surface via include indirection. |
| src/emel/token/batcher/actions.hpp | Migrates/rewrites batcher detail helpers into actions.hpp with branch-model constructs. |
| src/emel/text/tokenizer/preprocessor/detail.hpp | Rewrites tokenizer preprocessor helpers to avoid runtime branching statements. |
| src/emel/text/tokenizer/actions.hpp | Replaces ternary-based capacity computation with branchless arithmetic. |
| src/emel/text/renderer/actions.hpp | Introduces branchless optional callback dispatch and replaces conditional error mapping. |
| src/emel/text/detokenizer/detail.hpp | Collapses former helper implementation into the actions surface via include indirection. |
| src/emel/text/detokenizer/actions.hpp | Moves former detail helpers into actions.hpp and rewrites control flow to comply. |
| src/emel/tensor/view/detail.hpp | Replaces ternary pointer selection with array-index selection. |
| src/emel/tensor/detail.hpp | Replaces ternary pointer selection with array-index selection. |
| src/emel/sm.hpp | Normalizes acceptance/error checks and removes runtime if patterns in helper utilities. |
| src/emel/model/weight_loader/sm.hpp | Rewrites wrapper callback dispatch to avoid runtime branching statements. |
| src/emel/kernel/x86_64/guards.hpp | Switches includes to use the new action/detail surface arrangement. |
| src/emel/kernel/x86_64/detail.hpp | Collapses former helper implementation into the actions surface via include indirection. |
| src/emel/kernel/x86_64/context.hpp | Moves runtime feature detection into an inline helper in context.hpp. |
| src/emel/kernel/aarch64/guards.hpp | Switches includes to use the new action/detail surface arrangement. |
| src/emel/kernel/aarch64/detail.hpp | Collapses former helper implementation into the actions surface via include indirection. |
| src/emel/kernel/aarch64/context.hpp | Moves runtime feature detection into an inline helper in context.hpp. |
| src/emel/kernel/aarch64/actions.hpp | Moves former detail helpers into actions.hpp and rewrites SIMD routing/branches to comply. |
| src/emel/gguf/loader/sm.hpp | Removes wrapper if by rewriting the post-process assignment into explicit control flow. |
| src/emel/gbnf/sampler/actions.hpp | Replaces multiple ternaries/ifs with LUT-based mapping and branchless compaction. |
| src/emel/gbnf/rule_parser/lexer/actions.hpp | Rewrites lexer scanning logic to avoid runtime branching statements. |
| src/emel/gbnf/rule_parser/detail.hpp | Rewrites multiple parsing utilities to avoid runtime branching statements. |
| src/emel/gbnf/rule_parser/actions.hpp | Rewrites parser actions’ branching/quantifier logic into modeled/branchless constructs. |
| src/emel/gbnf/detail.hpp | Rewrites grammar::rule() validation/selection into masked/branchless constructs. |
| src/emel/docs/detail.hpp | Rewrites doc helpers to avoid runtime branching statements while preserving behavior. |
| src/emel/batch/planner/modes/simple/actions.hpp | Delegates to a detail helper (presumably compliant) instead of inline branching logic. |
| src/emel/batch/planner/modes/sequential/actions.hpp | Delegates to a detail helper (presumably compliant) instead of inline branching logic. |
| src/emel/batch/planner/modes/equal/actions.hpp | Delegates to detail helpers (including fast path) instead of inline branching logic. |
| src/emel/batch/planner/actions.hpp | Removes ternary in batch normalization by switching to LUT-based selection. |
| docs/runtime-conditionals-todo.md | Adds a TODO tracker for the runtime-conditional removal audit. |
| docs/rules/sml.rules.md | Updates SML rules contract to explicitly ban if/else if/switch/?: at runtime. |
| docs/compliance-report.md | Adds a static-analysis compliance report snapshot and violation inventory. |
| docs/compliance-checklist.md | Updates checklist wording to match the new explicit branching-statement ban. |
| docs/architecture/mermaid/batch_planner_modes_simple.mmd | Updates generated mermaid references after refactors. |
| docs/architecture/mermaid/batch_planner_modes_sequential.mmd | Updates generated mermaid references after refactors. |
| docs/architecture/mermaid/batch_planner_modes_equal.mmd | Updates generated mermaid references after refactors. |
| docs/architecture/batch_planner_modes_simple.md | Updates generated architecture markdown references after refactors. |
| docs/architecture/batch_planner_modes_sequential.md | Updates generated architecture markdown references after refactors. |
| docs/architecture/batch_planner_modes_equal.md | Updates generated architecture markdown references after refactors. |
| README.md | Adds a project re-architecture warning block and minor formatting tweak. |
| AGENTS.md | Updates agent guidance to explicitly ban runtime branching statements and require modeled flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec121b02da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
if/switch/?:) and mirrors that wording in project policy docsdocs/compliance-report.mdanddocs/runtime-conditionals-todo.mdfrom the full compliance auditsrc/emel/**/*{actions,detail,sm}.hppfor runtimeif,switch, and?:offenders and resolves remaining hitsValidation
scripts/quality_gates.shpassesrgcompliance scans for runtimeif (...),switch (...), and ternary operators on machine implementation files passNotes