amos f611da1e57 Batch 24: add 23 calibrated tasks written from Bos seed directions
Batch 24 (20261102-C-bos-seed-24) screened all 3078 Bos seed queries.
Only 23 themes were in scope (pure user-space reliability, at most one
task per theme); the rest were single operations or explanations,
installs and networking, system administration, ROS2, board-only or GUI
requests. Two finished drafts were withdrawn as too close to existing
tasks. Seeds supply direction only: all sources, contracts and tests are
new, and no task shares more than 14 characters with its seed text.

Each task passed the local gate and the trace6 Docker gate (5 runs per
sample class). Claude rebuilt the catalog from the calibration receipts:
23/23 USABLE. 16 of 23 are C/C++.

Only the task directories are taken; the batch worktree's lowered disk
floor in rollout/core.py stays out of main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:21:50 +08:00

125 lines
4.0 KiB
Python

"""Input schema and complete validation before a dispatch run."""
from dataclasses import dataclass
from decimal_units import (InputError, ZERO, parse_quantity, parse_positive,
parse_fraction, parse_identifier, parse_step,
normalize_soc)
CONFIG_KEYS = frozenset(('capacity', 'initial_soc', 'reserve_soc', 'charge_kw', 'discharge_kw', 'grid_kw', 'generator_kw', 'fuel_kwh'))
PERIOD_KEYS = frozenset(('id', 'minute', 'duration_min', 'load_kw', 'pv_kw', 'cloud', 'generator_ready'))
ROOT_KEYS = frozenset(('config', 'periods'))
@dataclass(frozen=True)
class Config:
capacity: object
initial_soc: object
reserve_soc: object
charge_kw: object
discharge_kw: object
grid_kw: object
generator_kw: object
fuel_kwh: object
@dataclass(frozen=True)
class Period:
identifier: str
minute: int
duration: int
load_kw: object
pv_kw: object
cloud: object
generator_ready: bool
@dataclass(frozen=True)
class Scenario:
config: Config
periods: tuple
def require_object(value, label):
if type(value) is not dict:
raise InputError(label + ': object required')
return value
def require_keys(value, expected, label):
actual = frozenset(value)
missing = expected - actual
extra = actual - expected
if missing:
raise InputError(label + ': missing ' + sorted(missing)[0])
if extra:
raise InputError(label + ': unknown ' + sorted(extra)[0])
def parse_config(raw):
raw = require_object(raw, 'config')
require_keys(raw, CONFIG_KEYS, 'config')
capacity = parse_positive(raw['capacity'], 'capacity')
initial_soc = parse_quantity(raw['initial_soc'], 'initial_soc')
reserve_soc = parse_quantity(raw['reserve_soc'], 'reserve_soc')
charge_kw = parse_quantity(raw['charge_kw'], 'charge_kw')
discharge_kw = parse_quantity(raw['discharge_kw'], 'discharge_kw')
grid_kw = parse_quantity(raw['grid_kw'], 'grid_kw')
generator_kw = parse_quantity(raw['generator_kw'], 'generator_kw')
fuel_kwh = parse_quantity(raw['fuel_kwh'], 'fuel_kwh')
normalize_soc(initial_soc, capacity)
normalize_soc(reserve_soc, capacity)
return Config(capacity, initial_soc, reserve_soc, charge_kw, discharge_kw,
grid_kw, generator_kw, fuel_kwh)
def parse_duration(raw):
if type(raw) is not int or raw not in (15, 30, 60):
raise InputError('duration_min: expected 15, 30, or 60')
return raw
def parse_period(raw):
raw = require_object(raw, 'period')
require_keys(raw, PERIOD_KEYS, 'period')
identifier = parse_identifier(raw['id'], 'id')
minute = parse_step(raw['minute'], 'minute')
duration = parse_duration(raw['duration_min'])
load_kw = parse_quantity(raw['load_kw'], 'load_kw')
pv_kw = parse_quantity(raw['pv_kw'], 'pv_kw')
cloud = parse_fraction(raw['cloud'], 'cloud')
ready = raw['generator_ready']
if type(ready) is not bool:
raise InputError('generator_ready: boolean required')
return Period(identifier, minute, duration, load_kw, pv_kw, cloud, ready)
def validate_timeline(periods):
previous_end = None
seen = set()
for period in periods:
if period.identifier in seen:
raise InputError('periods: duplicate id')
if previous_end is not None and period.minute != previous_end:
raise InputError('periods: noncontiguous minute')
previous_end = period.minute + period.duration
if previous_end > 1000000:
raise InputError('periods: minute range exceeded')
seen.add(period.identifier)
def parse_scenario(raw):
raw = require_object(raw, 'scenario')
require_keys(raw, ROOT_KEYS, 'scenario')
config = parse_config(raw['config'])
periods_raw = raw['periods']
if type(periods_raw) is not list:
raise InputError('periods: array required')
if not 1 <= len(periods_raw) <= 64:
raise InputError('periods: count outside 1..64')
periods = tuple(parse_period(item) for item in periods_raw)
validate_timeline(periods)
return Scenario(config, periods)