Skip to content

M5 Router, compat and funnel, part A - #37

Merged
Bre77 merged 4 commits into
milestone/m4b-energyfrom
milestone/m5a-router
Nov 2, 2026
Merged

Bre77 merged 4 commits into
milestone/m4b-energyfrom
milestone/m5a-router

Conversation

@Bre77

@Bre77 Bre77 commented Nov 2, 2026

Copy link
Copy Markdown
Member

Stacked on milestone/m4a-cloud-clients. One commit per issue.

Issues

Issue State
ENG-19 RTR-1 typed facade router All acceptance met
ENG-30 RTR-2 EnergySiteRouter and merge helpers All acceptance met
ENG-20 FNL-1 observation funnel All acceptance met

ENG-19

  • Each row of document 02 section 2 has a test.
  • test/router.types.ts compiles through tsconfig.test.json. Removing one @ts-expect-error made tsc exit 2.
  • await router returns the router, and Object.keys(router) shows only backends.
  • A plain object with failover_safe: true fails over, and a plain object rethrown from the last backend is the same value.

ENG-30

  • 0 and false overlay, and null keeps the cloud value.
  • A null local returns a copy, and unowned keys never overlay.
  • Each row of the failover table has a test. src/powerwall is not on this base, so the Powerwall classes are stand-ins with the same markers.
  • A method absent on the local backend goes straight to the cloud.

ENG-20

  • Older observations drop, and unchanged values skip.
  • A listener error does not stop other listeners.
  • A test asserts no module-level timer or fetch, against the module's syntax tree and at run time.

The rule that must not fail

BluetoothUnconfirmedCommand is checked first, by instanceof and the unconfirmed field. test/consumers/esm.mjs proves this with both real copies of the package: a CJS-loaded error thrown into the ESM router. Removing the field check fails 11 tests and that consumer.

For review

  • Differs from Python: is_failover_safe(unconfirmed) is false. Python answers true and relies on the router checking first. The router's behaviour is the same, and the predicate is now safe to use alone.
  • Additions to the design: at least two backends are required at run time, as Python's signature requires. backends is frozen. then is never routed, so a backend cannot make the router thenable. A subclass that shadows a method with a getter stops it routing.
  • Port kept as is: in ObservationFunnel.publish, a listener that republishes the same value at a newer time stops the outer loop, so later listeners miss that value. Python does the same.
  • Not verified: no real Bluetooth or Powerwall backend exists on this base. LostAck in test/router.test.ts fills the _send seam of a real VehicleSigned instead. test_ble_write_timeout_router.py's GATT cases belong with the Bluetooth layer.

🤖 Generated with Claude Code

Bre77 and others added 3 commits November 2, 2026 13:43
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…R-2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 56 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 89 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML; Path: .coderabbit.yaml
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 20d12cfa-7e37-4c1f-8a80-1628a0adb9c0
Commits

Reviewing files that changed from the base of the PR and between 609cba6 and 0e57cb8.

Files selected for processing: 16
  • .changeset/energy-site-router.md
  • .changeset/observation-funnel.md
  • .changeset/typed-router.md
  • AGENTS.md
  • src/funnel.ts
  • src/index.ts
  • src/log.ts
  • src/router/base.ts
  • src/router/energysite.ts
  • src/router/index.ts
  • test/consumers/cjs.cjs
  • test/consumers/esm.mjs
  • test/energysite-router.test.ts
  • test/funnel.test.ts
  • test/router.test.ts
  • test/router.types.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@Bre77
Bre77 added this pull request to stack #42 November 2, 2026 04:23
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Bre77
Bre77 removed this pull request from stack #42 November 2, 2026 04:29
@Bre77
Bre77 changed the base branch from milestone/m4a-cloud-clients to milestone/m4b-energy November 2, 2026 04:29
@Bre77
Bre77 added this pull request to stack #43 November 2, 2026 04:29
@Bre77
Bre77 merged commit a8b9352 into main Nov 2, 2026
4 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