Skip to content

feat(lattice): add durable schedule authority core - #4323

Open
mgazza wants to merge 2 commits into
feat/lattice-charge-power-dispatcherfrom
feat/lattice-schedule-authority
Open

feat(lattice): add durable schedule authority core#4323
mgazza wants to merge 2 commits into
feat/lattice-charge-power-dispatcherfrom
feat/lattice-schedule-authority

Conversation

@mgazza

@mgazza mgazza commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds the pure BatPred-side v0.4 atomic schedule compiler and durable authority state machine.

  • compiles a complete PredBat plan into an absolute UTC schedule with at most eight slots
  • emits field-10 replacement and digest-guarded cancellation transitions
  • validates retained gateway schedule capabilities and gateway-local coordinates before dispatch
  • persists command identity, installed authority, terminal receipts, and UNKNOWN quarantine time for restart-safe reconciliation
  • distinguishes requested, receiver-applied, and cancelled plan digests
  • keeps writer exclusion after valid_until; only a proven replacement or cancellation ending transition can change/release it
  • requires matching cancellation digest, release flag, and durable/native readback before cancellation APPLIED releases authority
  • reconciles the original command ID without republishing after restart or uncertainty

Safety

This tranche is deliberately disconnected from PredBat.execute_plan, save_plan, and all live transports. It cannot write to a gateway or inverter. Live wiring will be a separate, default-off stacked PR.

The implementation fails closed on:

  • UNKNOWN, malformed/conflicting receipts, corrupt state, stale fencing, and storage/transport uncertainty
  • bare or mismatched cancellation APPLIED
  • wrong provider/access route for an ending transition
  • command collisions, no-active-schedule, plan-digest mismatch, and unconfirmed authority release
  • lease expiry or schedule valid_until without a proven ending transition

UNKNOWN and its first quarantine timestamp are durably paired; a corrupt or half-present pair suppresses the legacy writer.

Verification

  • 47/47 focused schedule-authority tests pass on Python 3.9 and Python 3.14
  • Black, Ruff, cspell, pre-commit, and diff checks pass
  • GitNexus staged audit: LOW risk, two files, zero affected existing execution flows
  • independent review blockers were corrected before publication

Stack

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