Skip to main content

Module mpc_commit_controller

Module mpc_commit_controller 

Source
Expand description

Model Predictive Control (MPC) commit pipeline controller (IMPL-26).

Scaffolding-only — this controller is not wired into real commit paths yet. The intent is to pin the API and algebra so downstream beads can replace the heuristic in one place.

The dynamics are a simple linearised single-dimensional queue model:

    x_{k+1} = a * x_k + b * u_k + w_k

where x is observed queue depth (pending commits), u is admission rate (commits per tick we are willing to accept), and w is an unmodelled disturbance. a captures natural drain (e.g. replication, flush), and b is the actuator gain — i.e. how strongly admission rate moves the queue.

For a one-step horizon LQR with cost (x_{k+1} - target)^2 + rho * (u - u_prev)^2 the unconstrained optimum is closed-form:

    u* = (target - a * x) / b

(Derived from requiring a*x + b*u = target; note admission raises the queue so u is positive when the queue is below target and negative when above; the [0, max_rate] clamp handles the “above target → don’t admit, let natural drain a do the work” case.)

After clamping into [0, max_rate] we smooth toward the previous control to avoid chattering:

    u = u_prev + (1 / (1 + rho)) * (u* - u_prev)

This is intentionally 20-ish lines of real logic. Replace with a multi-step horizon QP when we start caring about anticipated disturbance profiles.

Structs§

MpcCommitController
One-step MPC controller for the commit admission pipeline.