Skip to content

feat: hysteresis condition operator and lookup table support#9

Merged
tbitcs merged 1 commit into
mainfrom
orchestrator/lang
Jun 2, 2026
Merged

feat: hysteresis condition operator and lookup table support#9
tbitcs merged 1 commit into
mainfrom
orchestrator/lang

Conversation

@tbitcs
Copy link
Copy Markdown
Contributor

@tbitcs tbitcs commented Jun 2, 2026

Hysteresis Condition Operator & Lookup Table Support

Hysteresis Operator (ARBITER_OP_HYSTERESIS = 13)

  • Schema: New hysteresis condition op with rising and falling threshold fields
  • C model: aux_value field added to ARBITER_condition_def; static bitmask for per-condition state
  • C eval: Deadband logic — val >= rising → true, val <= falling → false, between → hold previous
  • Python evaluator: Matching implementation with persistent _hyst_state dict
  • Compiler: canonical.py maps risingvalue, fallingaux_value
  • Emitters: emit_c.py and emit_blob.py updated for new op and aux_value

Lookup Tables (ARBITER_EXPR_LOOKUP = 15)

  • Schema: Top-level tables array with id/keys/values; lookup expression op with table field
  • C model: ARBITER_table_def struct; tables/table_count fields in ARBITER_model
  • C eval: Linear interpolation with endpoint clamping via table_lookup()
  • Python evaluator: _table_lookup() helper with matching integer interpolation
  • Compiler: canonical.py flattens and sorts tables, resolves table name references
  • Emitters: emit_c.py emits const key/value arrays and ARBITER_table_def; emit_blob.py updated

Tests

  • 24 new tests in test_hysteresis_lookup.py
  • Hysteresis: rising edge, falling edge, deadband hold true/false, exact thresholds, persistence, PID enable/disable
  • Lookup: exact keys, interpolation, below-min/above-max clamping, conditional execution, multiple tables, NTC curve
  • All 165 tests pass (141 existing + 24 new)

Conversation: https://app.warp.dev/conversation/d8b819b9-1d77-4bd5-9187-ff3c2289793d
Run: https://oz.warp.dev/runs/019e8993-e9a3-7c21-baff-810d0ea0d7c3
This PR was generated with Oz.

- Hysteresis operator (ARBITER_OP_HYSTERESIS = 13):
  - Schema: hysteresis op with rising/falling thresholds
  - C model: aux_value field in condition_def, static bitmask state
  - C eval: deadband logic with persistent per-condition state
  - Python evaluator: matching hysteresis with persistent state dict
  - Compiler: canonical.py maps rising->value, falling->aux_value
  - Emitters: emit_c.py, emit_blob.py updated for new op + aux_value

- Lookup tables (ARBITER_EXPR_LOOKUP = 15):
  - Schema: tables array with id/keys/values, lookup expression op
  - C model: ARBITER_table_def struct, tables/table_count in model
  - C eval: linear interpolation with endpoint clamping
  - Python evaluator: _table_lookup helper with matching interpolation
  - Compiler: canonical.py flattens tables, resolves table references
  - Emitters: emit_c.py emits const arrays + table_def, emit_blob.py

- Tests: 24 new tests covering hysteresis edges/deadband/persistence
  and lookup exact keys/interpolation/clamping/multiple tables

Co-Authored-By: Oz <oz-agent@warp.dev>
@tbitcs tbitcs merged commit fd42dfb into main Jun 2, 2026
2 of 7 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