Skip to content

Codex/merge predbat update - #17

Merged
calvind80 merged 2 commits into
mainfrom
codex/merge-predbat-update
Nov 7, 2026
Merged

calvind80 merged 2 commits into
mainfrom
codex/merge-predbat-update

Conversation

@calvind80

Copy link
Copy Markdown
Owner

Fixed web_security test issue

@calvind80
calvind80 merged commit 70b03d5 into main Nov 7, 2026
5 of 7 checks passed
@calvind80
calvind80 deleted the codex/merge-predbat-update branch November 7, 2026 13:47
calvind80 pushed a commit that referenced this pull request Nov 28, 2026
…pringfall2008#6367)

* feat(boards): add the predbat-memory board for the board runner

A shared-goal board that cuts Predbat's memory use with plans unchanged,
run by the board runner and blackboard skill from agent-memory-supabase.

- board.toml: goal, done-when, rules, intent limit, models and permissions
- measure.py: the runner's measurement, comparing main and a candidate
  branch over three interleaved benchmark runs (medians), exit 0/1/2
- test_measure.py: tests for the verdict, result parsing and harness errors
- README.md: the contract for coverage/memory_benchmark, still to be built

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

* feat(boards): baseline first, and self-describing commits and facts on predbat-memory

The baseline intent runs alone before any saving work. Board commit
messages name their intent, so git log main..<commit> shows what a tree
holds, and every fact gives its commit, what it was built on, what the
tree contains and its medians against main.

Workers can no longer use git -C (it bypassed the push deny), or move,
delete or reset branches.

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

* feat(boards): predbat-memory lead asks a Fable sub-agent when stuck for ideas

Needs the board runner from agent-memory-supabase PR #17, which adds
[lead] ideas_model.

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

* docs(boards): design the predbat-memory benchmark

Design for coverage/memory_benchmark: standalone Predbat with db_primary,
the dummy inverter, a 7-day reference DB exported from the live mirror,
forecast.solar and Octopus served from the live cache with the network cut,
and the wall clock frozen at the extraction time.

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

* docs(boards): implementation plan for the predbat-memory benchmark

Eight tasks: scrub helpers, dummy inverter starting totals, fixture DB and
cache export, export CLI, container wrapper, driver, and acceptance.

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

* feat(boards): scrub helpers for the memory benchmark fixture

collect_sensitive, replace_everywhere and find_leaks keep the Octopus account
number, meter serials and other real identifiers out of the benchmark fixture,
with a pre-commit hook for the tools' tests and ignores for the local fixture.

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

* feat(dummy_inverter): optional starting totals for the lifetime sensors

A totals block in dummy_inverter (load, pv, import, export in kWh) seeds the
lifetime counters so they continue a recorded history instead of starting at
zero. Absent or invalid values keep the old zero start.

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

* feat(boards): fixture database export for the memory benchmark

export_db copies the last N days up to T0 from a live predbat.db opened
read-only: settings and rates stay, Predbat outputs go, and the real
inverter's history is re-keyed onto the dummy inverter's sensors with
daily counters turned into rising lifetime totals.

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

* feat(boards): fixture cache export for the memory benchmark

export_forecast_cache re-keys the live forecast.solar responses under a
neutral postcode and key, scrubbing the location the response echoes;
export_octopus_cache copies the Octopus entries with the account number,
meter serials and Kraken token removed. Every entry is created at T0 so the
components treat it as fresh under the frozen clock.

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

* feat(boards): export_fixture builds the memory benchmark fixture

The CLI snapshots the live predbat.db with SQLite's backup API, exports the
Octopus and forecast cache entries, the 7-day database and a generated
apps.yaml from the committed template, records T0 in a manifest, and deletes
its output if any real identifier survived. Templated inverter settings are
resolved against the live entity names, and the serials they match are
scrubbed. secrets.yaml is never read.

First real export: 242 entities, 75389 history rows, 437 entities dropped,
15 MB, leak check clean.

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

* feat(boards): memory_benchmark wrapper and pinned image

coverage/memory_benchmark <tree> <out dir> checks the tree and the local
fixture, builds a pinned python:3.13-slim-bookworm image once, and runs the
tree in a container with --network none and fixed CPU and memory limits. Inside,
the kernel is built from the tree on the real clock, then the driver runs with
the wall clock frozen at the fixture's T0 by libfaketime. A sitecustomize shim
routes time.sleep through an Event wait, since clock_nanosleep fails under a
frozen clock.

Smoke test (stub driver, two runs): wall time frozen at T0 in both, monotonic
advanced 1.5 s across a sleep, and a connection to 1.1.1.1:53 was refused.

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

* feat(boards): memory benchmark driver and result rules

driver.py starts Predbat as hass.py does, waits for the dummy inverter,
forecast and Octopus components to publish, runs N forced plan cycles and
writes result.json: steady RSS (median after the settle cycles, MiB), peak
(VmHWM), a digest of each cycle's windows and limits, and ok from the log.

Fixes found by the first real runs: the Octopus scrub took the
electricityAgreements key for an account number and wiped the tariffs; it
now scrubs MPAN, MPRN, meter serials, device IDs and A-XXXXXXXX numbers
only. mcp_enable is left out of the template, since the component counts
its presence as on. Predbat's own entities stay in the fixture by default
(it reads their history back; --strip-outputs leaves them out), and
watch_list is dropped.

Octopus still fails offline: a connection error escapes its token refresh
(only TimeoutError is caught), so ok is false until that is handled.

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

* feat(boards): memory benchmark runs clean against the real fixture

The export now reads the Octopus account number off the component's entity
names and scrubs it (the live config holds it as a !secret, so it reached
the fixture unseen), and carries each entity's state at the window start into
the window so a rarely changing sensor still has history. The driver's log
check allows the Octopus offline poll warnings and lists the benign ones with
their reasons.

With the Octopus connection fix (springfall2008#6369) the run is ok: 6 cycles in 28 s,
steady 105.0 MB, peak 136.7 MB.

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

* docs(boards): memory benchmark acceptance results and baseline

The board README now says how to build the fixture and run the benchmark,
what it measures, and what it measured: steady 101.2 to 105.3 MB (median
104.6) and peak 136.3 to 137.9 MB over 12 runs with one plan digest, a
20 MiB control seen as +19.9 MB with the same digest, and a 1% rate change
seen as a new digest. docs/developing.md points at it.

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

* fix(boards): scrub personal data from the memory benchmark fixture by category

The final review found the fixture still held a real address, phone number,
home coordinates and postcode (GE Cloud's account record, zone.home, the
carbon sensor), lower-cased meter serials, and Solax, Wallbox and Octopus
device ids in entity names. The leak check only looked for values it already
knew, so it saw none of them.

- Personal attributes (coordinates, postcodes, names, addresses, emails,
  phones, company) are replaced at any depth in every exported row.
- Device ids in entity names are found by shape and renamed. A colliding
  pair (one serial in two cases) merges into one entity.
- Known values are also scrubbed lower-cased and with underscores, and the
  leak check ignores case.
- The export fails if anything still looks like an email, phone, postcode or
  real coordinates. Every run's log gets the same check.

Also from the review: the Octopus allow-list now permits only the token mint
and the three Intelligent polls, and plan_digest includes the predicted SoC
and cost every half-hour. Re-baselined: 3 runs, one digest, steady 104.3 to
105.5 MB.

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

* fix(boards): address the review of the predbat-memory board

- measure.py: a result.json figure that is NaN, Infinity or negative is a
  harness error. json.loads accepts the non-finite literals json.dump writes,
  and every comparison in verdict is false against NaN, so a broken benchmark
  could report a pass.
- measure.py: a base that disagrees with itself raises HarnessError, so main
  exits 2 rather than 1. An OSError starting the benchmark does the same.
- board.toml: drop Bash(python3 *) and Bash(source *). A deny matches only its
  own tool, so either let a script reach every Edit, Write and Bash deny. The
  baseline's memory map now comes from coverage/memory_benchmark --tracemalloc,
  which the benchmark's own allow entry covers. A test checks that no general
  interpreter is allowed.
- memory_benchmark --tracemalloc writes tracemalloc.txt (the top allocations by
  line and by file after the last cycle) and marks result.json as profiled.
  measure.py refuses profiled runs because tracing inflates RSS. One frame per
  allocation: 25 frames made a run take over ten minutes, one takes about
  2.5 minutes.
- A pre-commit hook runs the board's tests, and every function in the board
  folder has a docstring, also enforced by a test.

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

---------

Co-authored-by: CI <ci@example.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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