text
stringlengths
185
73.3k
repo
stringlengths
7
100
path
stringlengths
4
146
language
stringclasses
7 values
hash
stringlengths
16
16
score
float64
7
8.5
stars
int64
0
237k
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """Slots and pockets whose ends are cylinders. A slot milled with a round cutter has semi-cylindrical ends, and if it is short enough its two flat walls never pair -- the wall-pairing scan that finds every other slot finds nothing at all. This ...
pzfreo/b123d-recognisers
src/b123d_recognisers/_recess_obround.py
.py
4eb93b93c8d13edd
7.24
2
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """Many candidates into the features they describe. A recess scan proposes the same void more than once -- seen through its other wall pair, split into arms by a channel crossing it, or found again from its end caps. Nothing above this module s...
pzfreo/b123d-recognisers
src/b123d_recognisers/_recess_reduce.py
.py
8459375b8add981c
7.24
2
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """The recognition-record base mixin (package ADR 0002). Every feature-recognition record is a frozen, geometry-only dataclass — no build123d / OCP object leaks out. This mixin gives them the one uniform serialization accessor the contract prom...
pzfreo/b123d-recognisers
src/b123d_recognisers/_record.py
.py
8d70ad985460cef7
7.24
2
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """Closed prismatic rings of planar walls: finding them, measuring them, and asking what caps them. A **ring** is a cycle of planar faces whose spans along one principal axis all agree, each meeting exactly two others -- the walls of a constant...
pzfreo/b123d-recognisers
src/b123d_recognisers/_rings.py
.py
2e7a314884aacb31
7.24
2
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """The state one recognition run shares, in one object instead of several optional arguments. A recogniser called on its own takes a part and works everything out. Called as part of an aggregate it should not: the face-edge derivation, the fac...
pzfreo/b123d-recognisers
src/b123d_recognisers/_run.py
.py
48a392804c784f00
7.24
2
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """Shared types for the public geometry boundary. These aliases describe build123d inputs and the one legacy dictionary substrate exported for downstream compatibility. Recognition records themselves continue to contain only serialisable geomet...
pzfreo/b123d-recognisers
src/b123d_recognisers/_typing.py
.py
c7dfa459ea1fb10f
7.24
2
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """Angled blind step recognition for prismatic parts. An **angled blind step** is a wedge taken out of an edge of the part: one oblique planar wall, stopping part-way along the edge, with a triangular flat closing the blind end. Milled as an a...
pzfreo/b123d-recognisers
src/b123d_recognisers/angled_steps.py
.py
1706e0fb22811caf
7.24
2
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """Chamfer (bevelled-edge) recognition. ``recognise_chamfers`` recovers the manufacturing size of each chamfer so it can be called out (``C12`` / ``12 × 45°``) rather than left as a rendered-but-undimensioned bevel. A chamfer is a small **obliq...
pzfreo/b123d-recognisers
src/b123d_recognisers/chamfers.py
.py
84f6243672d9a0ba
7.24
2
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """Countersink recognition for drilled holes. ``recognise_countersinks`` recovers the countersinks a plain hole recogniser reports as mere openings: an internal **cone** that flares from a drilled bore (the minor circle) out to a larger opening...
pzfreo/b123d-recognisers
src/b123d_recognisers/countersinks.py
.py
60f89f95100e6650
7.24
2
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """Fillet (rounded-edge) radius recognition. ``recognise_fillets`` recovers the radius of each external edge fillet so it can be called out (``R3`` / ``4× R3``) rather than left as a rendered-but-undimensioned round. A fillet is the **arc analo...
pzfreo/b123d-recognisers
src/b123d_recognisers/fillets.py
.py
8462feb8dbec9f57
7.24
2
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """Machined-flat recognition on round stock. ``recognise_flats`` recovers the *across-flats* size of each machined flat — a single planar face truncating round stock (a spanner flat / D-shaft / hex A/F) — so it can be called out rather than lef...
pzfreo/b123d-recognisers
src/b123d_recognisers/flats.py
.py
8e1407c4e110b748
7.24
2
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """Opt-in part-relative recognition with an explicit caller-space frame. Existing recognition entry points remain caller-space and byte compatible. Framed recognition pairs the unchanged local-frame ``RecognitionResult`` with the frame needed t...
pzfreo/b123d-recognisers
src/b123d_recognisers/frames.py
.py
3a02a8edf07a5c69
7.24
2
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """Turned/circlip-groove recognition on round stock. A *groove* is an annular channel turned into round stock — a circlip / retaining-ring groove, an O-ring groove, a run-out relief. It reads as a *narrow* band of the OD whose diameter is a **s...
pzfreo/b123d-recognisers
src/b123d_recognisers/grooves.py
.py
d0367aab46472f96
7.24
2
# SPDX-License-Identifier: Apache-2.0 # Copyright 2024-2026 Paul Fremantle """Recognition of bounded, axis-aligned rectangular raised pads.""" from __future__ import annotations from dataclasses import dataclass from typing import Any from OCP.BRepAdaptor import BRepAdaptor_Surface from OCP.BRepGProp import BRepGPro...
pzfreo/b123d-recognisers
src/b123d_recognisers/pads.py
.py
9951f452f97e4cf2
7.24
2
"""Home Assistant EntityDescription helpers for IDM register metadata.""" from __future__ import annotations from typing import Any from homeassistant.components.binary_sensor import BinarySensorDeviceClass from homeassistant.components.sensor import ( SensorDeviceClass, SensorEntityDescription, SensorSt...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/adapter_descriptions.py
.py
e9fcb02cc38d7659
7.3
3
"""Enum translation helpers for IDM register values.""" from __future__ import annotations import re from .entity_names import translation_key_for_register _SYSTEM_MODE_SLUGS: dict[int, str] = { 0: "standby", 1: "automatic", 2: "absent", 3: "holiday", 4: "hot_water_only", 5: "heating_cooling...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/adapter_enums.py
.py
b8965136cd6305fb
7.3
3
"""GLT measurement classification helpers.""" from __future__ import annotations import re EXTERNAL_POWER_MEASUREMENT_NAMES: tuple[str, ...] = ( "pv_surplus", "pv_production", "house_consumption", "battery_discharge", "battery_soc", "electric_heater_power", ) _GLT_MEASUREMENT_NAMES = frozens...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/adapter_glt.py
.py
93ec1c9d056dfddc
7.3
3
"""Home Assistant metadata overlays for IDM Heatpump registers. SENSOR_METADATA and NUMBER_METADATA add the HA presentation layer (device class, icon, entity category, enabled-by-default) on top of the pure library RegisterDef objects. Extracted from library_adapter to keep the metadata tables separate from the genera...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/adapter_metadata.py
.py
7e7c934ad5e3c421
7.3
3
"""Register-map selection helpers for the HA adapter.""" from __future__ import annotations from typing import Any from idm_heatpump import ( FEATURE_CASCADE, FEATURE_HEATING_CIRCUITS, FEATURE_ISC, FEATURE_PV, FEATURE_SOLAR, FEATURE_ZONE_MODULES, MODEL_NAVIGATOR_10, MODEL_NAVIGATOR_20...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/adapter_registers.py
.py
bf47342f453c762a
7.3
3
"""Binary sensor semantics shared by the IDM integration. The IDM register map contains simple 0/1 states today, but some firmware and future library metadata may use active-low values, bit masks, explicit on/off sets, or negative values for an inactive state. Keeping the conversion in one place prevents platform code...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/binary_semantics.py
.py
d2d61afeef910044
7.3
3
"""Binary sensor platform for IDM Heatpump.""" from __future__ import annotations # IDM Heatpump for Home Assistant # © 2026 Xerolux — Inoffizielle Community-Integration für IDM Navigator 2.0 / 10 Wärmepumpen # Erstellt von Xerolux | https://github.com/Xerolux/idm-heatpump-hass # Lizenz: MIT from homeassistant.compon...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/binary_sensor.py
.py
6977852dda39a6d2
7.3
3
"""Button platform for IDM Heatpump.""" from __future__ import annotations # IDM Heatpump for Home Assistant # © 2026 Xerolux — Inoffizielle Community-Integration für IDM Navigator 2.0 / 10 Wärmepumpen # Erstellt von Xerolux | https://github.com/Xerolux/idm-heatpump-hass # Lizenz: MIT import logging from typing impor...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/button.py
.py
def239f14f47f64e
7.3
3
"""Calculated sensors derived from one IDM coordinator snapshot.""" from __future__ import annotations import math from collections.abc import Callable, Mapping from dataclasses import dataclass from typing import Any from homeassistant.components.sensor import ( SensorDeviceClass, SensorEntity, SensorEn...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/calculated_sensors.py
.py
e193f9c41404b77c
7.3
3
"""Climate platform for IDM Heatpump.""" from __future__ import annotations # IDM Heatpump for Home Assistant # © 2026 Xerolux — Inoffizielle Community-Integration für IDM Navigator 2.0 / 10 Wärmepumpen # Erstellt von Xerolux | https://github.com/Xerolux/idm-heatpump-hass # Lizenz: MIT import logging import re from t...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/climate.py
.py
c47e241404e58b3d
7.3
3
"""Constants for IDM Heatpump integration.""" from __future__ import annotations # IDM Heatpump for Home Assistant # © 2026 Xerolux — Inoffizielle Community-Integration für IDM Navigator 2.0 / 10 Wärmepumpen # Erstellt von Xerolux | https://github.com/Xerolux/idm-heatpump-hass # Lizenz: MIT import enum try: impo...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/const.py
.py
84502202f1bead64
7.3
3
"""Diagnostics support for IDM Heatpump integration.""" from __future__ import annotations # IDM Heatpump for Home Assistant # © 2026 Xerolux — Inoffizielle Community-Integration für IDM Navigator 2.0 / 10 Wärmepumpen # Erstellt von Xerolux | https://github.com/Xerolux/idm-heatpump-hass # Lizenz: MIT from typing impo...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/diagnostics.py
.py
2c32ab8253b4926e
7.3
3
"""Base entity for IDM Heatpump integration.""" from __future__ import annotations # IDM Heatpump for Home Assistant # © 2026 Xerolux — Inoffizielle Community-Integration für IDM Navigator 2.0 / 10 Wärmepumpen # Erstellt von Xerolux | https://github.com/Xerolux/idm-heatpump-hass # Lizenz: MIT import logging from typi...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/entity.py
.py
059f5ad7084b776a
7.3
3
"""Classify low-level errors into actionable user-facing messages.""" from __future__ import annotations import re import socket from idm_heatpump import IdmConnectionError, IdmDeviceError, IdmTransportError # Since idm-heatpump-api 2.0.0 the device's exception code arrives as # ``IdmDeviceError.exception_code``. T...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/error_messages.py
.py
bac1c1351bfe5c83
7.3
3
"""Logging filter for repeated register-failure warnings. ``idm-heatpump-api`` logs a WARNING "Modbus read at address X failed after N attempts: ..." whenever a register read exhausts its retries. For registers the device does not implement (Modbus ``Illegal Data Address`` / exception code 2) this is a perman...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/log_filter.py
.py
4dac2b40d4a9228c
7.3
3
"""Bridge ``idm_heatpump-api`` to the backend-neutral Modbus transport. With API 1.0 the IDM device library accepts an injectable transport via its ``transport=`` constructor parameter. This thin wrapper builds a :class:`ModbusConnectionTransport` (tmodbus-backed) and injects it, so the API owns every public operatio...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/modbus_client.py
.py
5d7057914a4bc090
7.3
3
"""Backend-neutral Modbus transport contract and tmodbus implementation. The IDM device model remains in ``idm-heatpump-api``. This module owns only the physical connection and exposes raw register words so the API continues to handle batching, decoding, model detection and write safety. The transport implements the...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/modbus_transport.py
.py
e2d01c231982e3dc
7.3
3
"""Number platform for IDM Heatpump.""" from __future__ import annotations # IDM Heatpump for Home Assistant # © 2026 Xerolux — Inoffizielle Community-Integration für IDM Navigator 2.0 / 10 Wärmepumpen # Erstellt von Xerolux | https://github.com/Xerolux/idm-heatpump-hass # Lizenz: MIT from homeassistant.components.nu...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/number.py
.py
6211e6df0e808bcd
7.3
3
"""Restart-safe compressor, defrost and operating-mode analysis.""" from __future__ import annotations import logging import math from collections.abc import Callable, Mapping from datetime import UTC, datetime, timedelta from typing import Any, Final from homeassistant.core import HomeAssistant from homeassistant.h...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/operation_analysis.py
.py
ff8ee34d1e7fa5f5
7.3
3
"""Entity-aware Modbus polling plan for IDM Heatpump.""" from __future__ import annotations import asyncio import logging import re from collections.abc import Callable, Iterable from typing import Any from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback from ho...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/polling_plan.py
.py
d453f772bd5108fa
7.3
3
"""Forward Home Assistant sensor values to IDM GLT registers. Two independent forwarder shapes live here: - ``RoomTempForwarder`` — N keyed HA entities into N fixed target registers, looked up via an injectable ``register_for_key`` resolver. Used for per-heating-circuit room temperatures (``hc_{circuit}_ext_room_...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/room_temp_forwarding.py
.py
69d63a3ca3e8d7ab
7.3
3
"""Select platform for IDM Heatpump.""" from __future__ import annotations # IDM Heatpump for Home Assistant # © 2026 Xerolux — Inoffizielle Community-Integration für IDM Navigator 2.0 / 10 Wärmepumpen # Erstellt von Xerolux | https://github.com/Xerolux/idm-heatpump-hass # Lizenz: MIT from typing import Any from hom...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/select.py
.py
e9318dab8c326579
7.3
3
"""Service handlers for IDM Heatpump integration.""" from __future__ import annotations # IDM Heatpump for Home Assistant # © 2026 Xerolux — Inoffizielle Community-Integration für IDM Navigator 2.0 / 10 Wärmepumpen # Erstellt von Xerolux | https://github.com/Xerolux/idm-heatpump-hass # Lizenz: MIT import logging impo...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/services.py
.py
106f1bea3738208e
7.3
3
"""Switch platform for IDM Heatpump.""" from __future__ import annotations # IDM Heatpump for Home Assistant # © 2026 Xerolux — Inoffizielle Community-Integration für IDM Navigator 2.0 / 10 Wärmepumpen # Erstellt von Xerolux | https://github.com/Xerolux/idm-heatpump-hass # Lizenz: MIT from typing import Any from hom...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/switch.py
.py
c352423216c8c490
7.3
3
"""Runtime dependency version helpers for diagnostics and entities.""" from __future__ import annotations import asyncio from dataclasses import dataclass from functools import cache from importlib.metadata import PackageNotFoundError, version @dataclass(frozen=True) class RuntimeVersions: """Versions relevant ...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/versions.py
.py
97f0399c739b42b2
7.3
3
"""Water heater platform for IDM Heatpump.""" from __future__ import annotations # IDM Heatpump for Home Assistant # © 2026 Xerolux — Inoffizielle Community-Integration für IDM Navigator 2.0 / 10 Wärmepumpen # Erstellt von Xerolux | https://github.com/Xerolux/idm-heatpump-hass # Lizenz: MIT import logging from typing...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/water_heater.py
.py
a8dfb02c203fdb69
7.3
3
"""Binary sensors backed by optional IDM Navigator web values.""" from __future__ import annotations import math from dataclasses import dataclass from typing import Any from homeassistant.components.binary_sensor import ( BinarySensorDeviceClass, BinarySensorEntity, BinarySensorEntityDescription, ) from...
Xerolux/idm-heatpump-hass
custom_components/idm_heatpump/web_binary_sensors.py
.py
4a85c4742bb0ad8b
7.3
3
"""Read-only Modbus TCP proxy for the IDM live test environment. Safety contract --------------- - Allows ONLY read function codes: 1, 2, 3, 4 (read coils/discrete inputs/ holding registers/input registers). The idm-heatpump-api uses 0x03 and 0x04 for all reads. - BLOCKS every other function code, in particular th...
Xerolux/idm-heatpump-hass
docker/live-readonly-test/proxies/modbus-readonly/modbus_proxy.py
.py
1571d88fad44bd68
7.8
3
"""ToyDesigner app entry: startup verification + capability matrix. Usage: TOYDESIGNER_LEVEL=V3 python app.py [license.json] Levels V0..V3 select the verification chain (see license_model.verify_license). """ from __future__ import annotations import os import sys import features import license_model as L def run...
zycxfyh/ordivon-security
research/ca-lic/toydesigner/app.py
.py
19622c9a8964ef36
7
0
"""Render pipeline — direct-check gate idiom (idiom #1 of 3 in V3).""" from license_model import NotEntitled from . import _lic FREE_MAX_HEIGHT = 720 def _gate_render_4k(): """Direct boolean check, no helper. One attacker-visible site.""" if not _lic().is_pro(): raise NotEntitled("This feature requi...
zycxfyh/ordivon-security
research/ca-lic/toydesigner/features/render.py
.py
a8128a03268d7c30
7
0
"""Defense baselines for ToyDesigner V4-V8. Every advanced attack script is meaningful only if its corresponding defense first holds. This baseline performs no Windows/KVM work and contacts no network service; V6-V8 use a local stdin/stdout external-authority simulator. """ from __future__ import annotations from pa...
zycxfyh/ordivon-security
research/ca-lic/toydesigner/verify_advanced_baseline.py
.py
ddaba0e2b4dbac67
7
0
"""Home Assistant side of the shading backfill. Everything that needs the recorder or the network lives here; the arithmetic lives in ``core.backfill`` where it can be tested without either. The recorder keeps hourly long-term statistics for every sensor with a measurement state class, and it keeps them forever -- th...
doccodyblue/ha-pvstrings
custom_components/pvstrings/backfill.py
.py
e2e9f3bf0ecb976f
7.15
1
"""Turning an event stream into five-minute aggregates. Home Assistant hands us irregular, event-driven power samples plus a watchdog snapshot every ``watchdog_seconds``. This module integrates those into fixed five-minute buckets and -- just as importantly -- reports honestly how much of each bucket was actually cov...
doccodyblue/ha-pvstrings
custom_components/pvstrings/core/aggregate.py
.py
d20b7f80831330fa
7.15
1
"""Reconstructing shading observations from history nobody kept for us. A fresh install knows nothing about where the shadows fall, and learning it from live five-minute data takes a full turn of the seasons: the sun does not visit the winter part of the sky until winter. Meanwhile Home Assistant has usually been rec...
doccodyblue/ha-pvstrings
custom_components/pvstrings/core/backfill.py
.py
063c2a30b8cedbc8
7.15
1
"""DC -> AC / battery-charge conversion (upgrade.md, tranche 1). Pure functions, strictly downstream of the DC forecast: nothing here may feed back into learning, scoring or censoring. The DC series stays the model's truth; this layer only answers "what arrives behind the inverter" (direct) or "what lands in the batt...
doccodyblue/ha-pvstrings
custom_components/pvstrings/core/conversion.py
.py
604dc5685274e4d1
7.15
1
"""Detecting when a string was actually held back, and what to do about it. Two things this module refuses to conflate: * A **commanded limit** is not curtailment. At a 1796 W limit with 600 W available, the measurement is an exact value, not a lower bound. * Curtailment hits a **group**, shading hits a **string**...
doccodyblue/ha-pvstrings
custom_components/pvstrings/core/curtailment.py
.py
027fcf10fc49d769
7.15
1
"""Stage B: correct the datasheet curve with what the plant actually does. The datasheet curve (stage A) is a prior, never a competitor. Learning moves each support point towards the measured efficiency at that load, bounded on three sides: * a hard cap around the prior, so one bad sensor day cannot rewrite the cu...
doccodyblue/ha-pvstrings
custom_components/pvstrings/core/curve_learning.py
.py
88d1d7d9187d5846
7.15
1
"""Loader for shipped datasheet efficiency curves. Blocking file I/O -- call from the executor. Package-relative paths only: the working directory under HA is not the component directory. A broken file degrades to "model unavailable" with a log line, never to a failed setup -- the conversion then runs neutral, which...
doccodyblue/ha-pvstrings
custom_components/pvstrings/core/inverter_curves.py
.py
d84faadf8686604a
7.15
1
"""Nowcast: die eigene Einstrahlungsmessung in die nächsten Stunden tragen. The weather source only corrects a running day when its next run lands, which cost Andy's plant 1.4 kWh on 2026-08-22 -- the sensor saw the sun break through at 11:00, the forecast followed at 13:02, and the best hour was gone. Calibrated aga...
doccodyblue/ha-pvstrings
custom_components/pvstrings/core/persistence.py
.py
dbab0606f32963f9
7.15
1
"""Is the measured irradiance consistent with what the array actually did? A user's irradiance sensor is one point on a pole; the array is a set of planes spread over a roof. When the two disagree the sensor is usually right -- but not always. A sensor that is slightly off level, soiled, spectrally limited or clippe...
doccodyblue/ha-pvstrings
custom_components/pvstrings/core/plausibility.py
.py
a9a8a901dad983c8
7.15
1
"""Data quality classification. The point of this module is a single rule: a missing measurement is only a zero if the sun is down. Writing ``float(0)`` for an unavailable entity turns a midday inverter dropout into a learned zero, and the learning layer has no way to ever recover from that. """ from __future__ impo...
doccodyblue/ha-pvstrings
custom_components/pvstrings/core/quality.py
.py
1863ed2add05bd6f
7.15
1
"""Irradiance forecast sources. Default source is Open-Meteo: free, no API key, global coverage, and it exposes the **components** (GHI, DNI, DHI). We deliberately do not use its plane-of-array output -- that is computed with an isotropic sky model and a fixed albedo of 0.20, which throws away most of what a proper t...
doccodyblue/ha-pvstrings
custom_components/pvstrings/core/weather.py
.py
f538be1f4eb4afe9
7.15
1
"""Diagnostics download. Deliberately verbose: the geometry history, the model state and the collector counters are exactly what is needed to tell "the forecast is wrong" apart from "the data going in is wrong", and neither is guessable from the entity states. """ from __future__ import annotations from typing impor...
doccodyblue/ha-pvstrings
custom_components/pvstrings/diagnostics.py
.py
0fa472348f51e274
7.15
1
"""Test fixtures. The core package is imported directly, without Home Assistant. That is the whole point of keeping ``core/`` HA-free: the physics and the learning rules can be exercised in milliseconds against a temporary SQLite file. """ from __future__ import annotations import sys from pathlib import Path impo...
doccodyblue/ha-pvstrings
tests/conftest.py
.py
ad14e1d78f9d8da4
7.65
1
"""Five-minute aggregation: the part that decides what "missing" means.""" from __future__ import annotations import pytest from core.aggregate import ( closed_interval, Sample, SampleBuffer, hourly_from_5min, integrate, interval_mid, merge_hourly, interval_start, ) def test_interva...
doccodyblue/ha-pvstrings
tests/test_aggregate.py
.py
21e93fa7fcbd61d9
7.65
1
"""Reconstructing shading observations from hourly history. The failure this module is most exposed to is silence. Every input is a mapping keyed by an epoch hour, and if two of those keys disagree about their unit or their offset the join simply produces nothing -- no exception, no warning, an empty result that look...
doccodyblue/ha-pvstrings
tests/test_backfill.py
.py
4882e8b6e1d97bde
7.65
1
"""Guards for the form schemas. These cannot exercise Home Assistant's selectors directly (no HA in the test environment), so they pin the constraints those selectors impose. The step rule below cost a full deployment cycle to find: a violation raises ``voluptuous.Invalid`` inside the HTTP view, which HA turns into a...
doccodyblue/ha-pvstrings
tests/test_config_flow_schema.py
.py
43304fa20418f702
7.65
1
"""Stage B: the datasheet curve corrected by what the plant actually does. The properties pinned here are the ones that decide whether learning improves the forecast or quietly ruins it: the prior must survive thin evidence, the cap must survive a broken sensor, and the excluded regimes (clipping, standby, censored in...
doccodyblue/ha-pvstrings
tests/test_curve_learning.py
.py
89f01224d9f17d2d
7.65
1
"""The learning rules -- especially the ones that must NOT fire.""" from __future__ import annotations import math import pytest from core.learning import ( MAX_N_EFF, SHRINK_K, Effect, GhiBiasModel, LogRatioModel, Observation, daypart, horizon_bucket, plant_key, weather_clas...
doccodyblue/ha-pvstrings
tests/test_learning.py
.py
9b2b77e81bb9584d
7.65
1
"""Nowcast: the pure core, and the guarantees the engine must not break.""" from __future__ import annotations import numpy as np import pytest from core import persistence class TestSkyState: def test_reads_the_clearness_index_off_the_window(self): measured = np.array([400.0, 420.0, 410.0]) cl...
doccodyblue/ha-pvstrings
tests/test_persistence.py
.py
d8957af69c26be67
7.65
1
"""Quality classification and the commanded-vs-binding distinction.""" from __future__ import annotations import pytest from core import curtailment as curt from core.config import ConfigError, CurtailmentGroup from core.quality import ( QUALITY_EXACT, QUALITY_MISSING, QUALITY_NIGHT, QUALITY_PARTIAL,...
doccodyblue/ha-pvstrings
tests/test_quality_curtailment.py
.py
c632fceb6fa5459b
7.65
1
"""Every entity name must actually resolve. A translation key whose value is a bare string instead of ``{"name": ...}`` does not fail anywhere: Home Assistant simply does not find it and falls back to the device-class name. Two power sensors then both end up called "Power", collide, and one gets a ``_2`` suffix in it...
doccodyblue/ha-pvstrings
tests/test_translations.py
.py
f21189f1aa9d08bb
7.65
1
"""Unit normalisation. Every one of these is a real reading from a real station: feeding km/h into a model that expects m/s is silent and costs a factor of 3.6 in wind cooling. """ from __future__ import annotations import pytest from core import units class TestSpeed: def test_metres_per_second_pass_through(...
doccodyblue/ha-pvstrings
tests/test_units.py
.py
f04df33ef14cfe99
7.65
1
"""Forecast source parsing and the savings calculation.""" from __future__ import annotations from datetime import date import pytest from core.config import Economics from core.economics import ( MODE_FEED_IN, MODE_NET_METERING, MODE_SELF_CONSUMPTION, amortisation, annual_estimate, period_s...
doccodyblue/ha-pvstrings
tests/test_weather_economics.py
.py
102dc8f1540af5d3
7.65
1
"""Fixtures for the Home-Assistant-backed schema tests. These run against a real ``homeassistant`` install (see requirements-ha.txt), which the fast ``tests/`` suite deliberately does not need. Their whole purpose is the class of bug that only HA's own validators can catch: selector configurations that look fine in P...
doccodyblue/ha-pvstrings
tests_ha/conftest.py
.py
bde9a7a7a5e060be
7.65
1
"""Update repository metadata and roadmap markers for v0.4.0-alpha.6.""" from __future__ import annotations from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def update_version() -> None: """Advance package metadata from alpha.5 to alpha.6 when present.""" path = ROOT / "pyproject.toml" ...
Thomas-Heisig/Brain-5D
scripts/apply_alpha6_metadata.py
.py
77c28f4cdb131b58
7
0
"""Apply narrow v0.4.0-alpha.6 type-quality fixes to the current repository.""" from __future__ import annotations from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def replace_once(path: Path, old: str, new: str) -> None: """Replace one known source fragment, remaining idempotent after migra...
Thomas-Heisig/Brain-5D
scripts/apply_alpha6_quality_fixes.py
.py
68c24785af4f896c
7
0
"""Generate tests/test_baseline.json from a completed full-suite run. Usage: python -m pytest tests/ -q python scripts/generate_baseline.py The script reads the pytest output from the last run (or you can pipe it), computes the canonical source digest, and writes tests/test_baseline.json. This is the ONLY ca...
Thomas-Heisig/Brain-5D
scripts/generate_baseline.py
.py
6f4b0c7f447df179
7
0
"""Generate the determinism infrastructure verification artifact. Usage: python scripts/generate_determinism_artifact.py This script runs the determinism-related tests and produces ``research/generated/verification/determinism_infrastructure.json`` which the Gate B status builder uses instead of file-existence ch...
Thomas-Heisig/Brain-5D
scripts/generate_determinism_artifact.py
.py
f27d49311a574f5d
7
0
"""Prepare an alpha.4 working tree for strict quality verification.""" from __future__ import annotations import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def run(*args: str) -> None: """Run one repository preparation command and fail fast.""" subprocess.run(...
Thomas-Heisig/Brain-5D
scripts/prepare_alpha4.py
.py
328b8029be43a865
7
0
"""Fail-fast quality gate for Brain-5D v0.4.0-alpha.7.""" from __future__ import annotations import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def run(*command: str) -> None: """Run one quality command and fail immediately on errors.""" print("+", " ".join(com...
Thomas-Heisig/Brain-5D
scripts/verify_all.py
.py
bfdb7a48d559afbb
7
0
"""Quality verification for the Brain-5D operator dashboard and embodiment bridge.""" from __future__ import annotations import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def run(*command: str) -> None: """Run one command and fail immediately if it fails.""" p...
Thomas-Heisig/Brain-5D
scripts/verify_dashboard.py
.py
cd57d2e6d8043eec
7
0
"""Run the v0.5.0-alpha.1 release verification commands.""" from __future__ import annotations import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def run(*args: str) -> None: """Run one verification command and stop on failure.""" print("+", " ".join(args)) ...
Thomas-Heisig/Brain-5D
scripts/verify_v050a1.py
.py
467054bf68389c09
7
0
"""Verification gate for Brain-5D v0.5.0-alpha.3.""" from __future__ import annotations import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def run(*args: str) -> None: """Run one quality-gate command in the repository root.""" print("+", " ".join(args), flush=T...
Thomas-Heisig/Brain-5D
scripts/verify_v050a3.py
.py
fd80250748827731
7
0
"""Run the Brain-5D operator dashboard with ``python -m src.dashboard``. This module serves as the entry point for the Brain-5D dashboard application. It delegates to the server's main() function with enhanced error handling and user-friendly messages. """ from __future__ import annotations import logging import sys...
Thomas-Heisig/Brain-5D
src/dashboard/__main__.py
.py
1d6089c212156570
7
0
"""Safe read-only access to repository documentation and data files. Supports: .md, .txt, .docx, .xlsx, .csv, .json, .pdf (metadata only) """ from __future__ import annotations import csv import json from dataclasses import dataclass from datetime import datetime from enum import Enum from functools import lru_cache...
Thomas-Heisig/Brain-5D
src/dashboard/docs_source.py
.py
387699c15a453fa4
7
0
# -*- coding: utf-8 -*- """FastAPI 서버 — 심사위원/CLI가 호출하는 API.""" from fastapi import FastAPI, HTTPException from pydantic import BaseModel from src.pipeline import run_pipeline app = FastAPI( title="oss4oss", description="OpenSource for OpenSource - 코어 파이프라인 API", version="0.2.0", ) class ScanRequest(Base...
No4nsw3r/oss4oss
engine/src/api/main.py
.py
293e1b82b1918bcf
7
0
# -*- coding: utf-8 -*- """CLI: python -m src.cli scan <레포>""" import sys import click from src.pipeline import run_pipeline @click.group() def main(): """oss4oss - OpenSource for OpenSource CLI""" @main.command("scan") @click.argument("repo") @click.option("--eco", type=click.Choice(["npm", "pypi"]), default...
No4nsw3r/oss4oss
engine/src/cli/main.py
.py
2ed800f4f35fa825
7
0
# -*- coding: utf-8 -*- """통합 findings → SQLite 적재.""" import csv import json from datetime import datetime, timezone from src.db import get_connection, init_db from .common import SEV_RANK, jload, make_purl, norm_pkg, purl_eco def sbom_components(sbom_path, eco: str): data = jload(sbom_path) comps = {} ...
No4nsw3r/oss4oss
engine/src/pipeline/load.py
.py
5de81b52a4b7e54c
7
0
# -*- coding: utf-8 -*- """원샷 파이프라인: resolve → scan → consolidate → load.""" import os import re import shutil import subprocess from collections import defaultdict from urllib.parse import urlparse from src.paths import DB_PATH, RAW_DIR, WORKSPACE_DIR, ensure_dirs from .common import SEV_RANK from .consolidate impor...
No4nsw3r/oss4oss
engine/src/pipeline/runner.py
.py
f06ab1a62997e277
7
0
# -*- coding: utf-8 -*- """Syft + Grype/Trivy/osv-scanner 실행 (상세가이드: SBOM 입력).""" import os import shutil import subprocess from src.paths import BIN_DIR, ensure_dirs def _tool(name: str, linux_name: str) -> str: """bin/<name>/<exe> → BIN_DIR/<linux> → PATH 순으로 탐색.""" win_exe = f"{linux_name}.exe" candid...
No4nsw3r/oss4oss
engine/src/pipeline/scan.py
.py
96b015df3ed355bb
7
0
# -*- coding: utf-8 -*- """패키지 이름·purl 정규화 헬퍼. 출처: 파트1 `oss4oss/src/pipeline/common.py`. 파트전달파일은 읽기전용이고 경로에 `→` 같은 특수문자가 있어 import 가 불안정하므로 필요한 것만 이식했다. 파트1과 **동일한 규칙**을 써야 purl 이 맞물린다 — 고치지 말 것. """ import re GHSA_RE = re.compile(r"GHSA-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}", re.I) SEV_RANK = { "CRITICAL": 4, "HI...
No4nsw3r/oss4oss
judge/engine/common/pkg.py
.py
f836128a98056781
7
0
# -*- coding: utf-8 -*- """CycloneDX SBOM 로더. 파트1이 Syft 로 만든 SBOM(`raw/<name>/<name>_sbom.json`)을 읽어 **purl → 출처 파일 경로** 맵을 만든다. A3(실행 경로 밖) 판정의 유일한 근거다. DB 에는 이 정보가 없다. `component` 테이블에는 purl·name·version 만 있고 "이 패키지가 어느 파일에 선언돼 있었나"는 SBOM 원본에만 남아 있다. 주의 — Syft 는 두 종류를 함께 넣는다: * `type="library"` + purl 있음 → 진짜 패...
No4nsw3r/oss4oss
judge/engine/common/sbom.py
.py
805423de0663d963
7
0
# -*- coding: utf-8 -*- """OpenVEX 표준 상수와 검증. 철자를 여기 한 곳에만 둔다. 판정 코드는 문자열 리터럴을 쓰지 않고 반드시 이 상수를 참조한다 — 오타 한 글자가 곧 표준 위반이기 때문이다. 참고: https://github.com/openvex/spec """ class Status: """VEX 판정 상태 (4종).""" NOT_AFFECTED = "not_affected" AFFECTED = "affected" FIXED = "fixed" UNDER_INVESTIGATION = "u...
No4nsw3r/oss4oss
judge/engine/common/vex.py
.py
463bd2303c79b31b
7
0
# -*- coding: utf-8 -*- """OpenVEX 1.0 문서 생성 — 파트5 전달용. 우리 판정(`judgment_detail`)을 국제 표준 형식으로 내보낸다. 파트5는 이 파일을 그대로 대시보드·저장소에 올리면 된다. 명세: https://github.com/openvex/spec/blob/main/OPENVEX-SPEC.md """ import json import os from datetime import datetime, timezone from ..common import db from ..common.vex import Status ...
No4nsw3r/oss4oss
judge/engine/export/openvex.py
.py
2ef65b72ec8f19d2
7
0
# -*- coding: utf-8 -*- """악성 패키지 대조 — 버전까지 확인한다. 파트3의 `filter_malicious.py` 를 그대로 쓰지 않는 이유: 그 스크립트는 `osv/malicious/<eco>/<패키지명>/` 의 **폴더 이름만** 긁어서 대조한다. 그래서 `debug` 라는 이름만 같으면 모든 버전을 악성으로 찍는다. 실제로 dvna 를 돌려보면 11건이 걸리는데 **11건 전부 오탐**이었다 (저장소는 `debug@4.4.2` 하나만 악성이라고 명시하는데 dvna 는 2.6.9·3.2.7·4.4.3 을 쓴다). `debug`·`ansi...
No4nsw3r/oss4oss
judge/engine/part2a/malicious.py
.py
bd6044a3b9f85946
7
0
# -*- coding: utf-8 -*- """A5 — 이미 차단됨(inline_mitigations_already_exist) 입력 관리. A5 는 **자동 판정이 불가능한 유일한 사유**다. "앞단에서 입력을 검증한다", "설정으로 그 기능을 껐다", "WAF 가 막는다" 같은 건 코드만 봐서는 알 수 없고 운영 맥락을 아는 사람이 확인해야 한다. 그래서 이 모듈은 **판정하지 않는다.** 사람이 적어 넣은 근거를 읽어서 규칙 엔진에 전달하는 일만 한다. 근거 없는 A5 판정은 만들 수 없다. 파일: `work/mitigations.json` ```json...
No4nsw3r/oss4oss
judge/engine/part2a/mitigations.py
.py
5848ea889b4748fe
7
0
# -*- coding: utf-8 -*- """영향 버전 범위 확보 — 하이브리드. A2(그 버전엔 문제 코드 없음) 판정은 "이 CVE 가 어느 버전부터 어느 버전까지 문제인가"를 알아야 한다. 그런데 파트3가 준 데이터는 lodash·Django 두 패키지만 조회한 것이라 우리 DB 취약점 182건 중 11건밖에 못 덮는다. 그래서 3단 구조로 확보한다: 1. 파트3 `enrichment.json` (팀 산출물 우선) 2. 로컬 캐시 `work/osv_cache.json` 3. OSV API 직접 조회 → 캐시에 저장 파트3가 나중에 실제 SB...
No4nsw3r/oss4oss
judge/engine/part2a/osv.py
.py
28c9d165738077d5
7
0
# -*- coding: utf-8 -*- """CVE → 취약 함수명. 원래는 **파트4(AI 모듈)** 가 CVE 설명을 읽고 함수명을 뽑아 넘겨줘야 한다. 아직 산출물이 없으므로 여기서 부트스트랩한다 — CVE 설명문에서 직접 뽑는다. **인터페이스를 파일 하나로 고정한다.** 파트4 산출물이 오면 그 파일로 교체만 하면 된다: work/vuln_functions.json { "CVE-2024-45230": {"functions": ["urlize", "urlizetrunc"], "source": "part4"} } 주의 — 여기서 뽑은 함...
No4nsw3r/oss4oss
judge/engine/part2b/functions.py
.py
d0ea6c51f4143b22
7
0
# -*- coding: utf-8 -*- """정답셋 대비 정확도·분석시간 측정. 실행: python3 -m tests.test_accuracy 파트 목표에 명시된 요구사항("밝혀진 CVE 몇 개로 정답셋 만들어 정확도·분석시간 측정")을 충족한다. 정답셋은 `tests/fixtures/ground_truth.json` — dvna·pygoat 가 교육용 레포라 레포 안 solution 문서로 정답을 확인할 수 있다. **가장 중요한 지표는 거짓 음성(FN)이다.** "발현되는 것을 발현되지 않는다고 하는 것"이 "발현되지 않는 것을 발현된다고 하는 것"보다 ...
No4nsw3r/oss4oss
judge/tests/test_accuracy.py
.py
134942dc99dbaeea
7.5
0
from __future__ import annotations import re from dataclasses import dataclass from typing import List, Optional, Sequence, Tuple def _norm(s: str) -> str: s = "" if s is None else str(s) s = s.strip() s = re.sub(r"\s+", " ", s) return s def split_steps_answer(segments: Sequence[str]) -> Tuple[List...
zq2r/BaPRM
aca/utils_merge_and_cut.py
.py
01d1f3aa86395015
7
0
import torch from internvl.conversation import get_conv_template def _resolve_optional_bool(value, default): """ Resolve an optional bool override. value: None / "auto": use default True / "true" / "1" / "yes": force True False / "false" / "0" / "no": force False """ if val...
zq2r/BaPRM
eval/prm/bayesian_prm_utils.py
.py
581531a57addf600
7
0
""" EventExecutor 基类 — 事件处理端 执行器负责接收匹配的事件并执行处理逻辑。 用法: from evebus.executors import EventExecutor class MyExecutor(EventExecutor): def __init__(self): super().__init__("my_executor") self.patterns = ["data.*"] async def execute(self, topic: str, payload: dict): ...
openbot-coder/pyevebus
python/evebus/executors/base.py
.py
e23f1629be18fef8
7
0
""" ScriptExecutor — 动态脚本执行器 加载外部 Python 脚本文件,将 on_event 函数作为 handler。 支持运行时重新加载脚本。 用法: from evebus.executors import ScriptExecutor executor = ScriptExecutor( name="my_strategy", script_path="strategies/momentum.py", patterns=["data.quotes.*.ETHUSDT"], ) engine.add_executor(e...
openbot-coder/pyevebus
python/evebus/executors/script.py
.py
be95edf78872e198
7
0
""" Hook 系统 — 中间件模式 每个 hook 接收 HookContext,返回 HookResult。 Hook 链顺序执行,任一 hook 返回非 CONTINUE 则中断。 用法: from evebus import EventEngine, HookStage, HookContext, HookResult engine = EventEngine() async def rate_limit_hook(ctx: HookContext): if is_rate_limited(ctx.source): return HookResult...
openbot-coder/pyevebus
python/evebus/hooks.py
.py
6f32860fc209a0b2
7
0
""" Plugin 基类 — 插件系统 插件通过 on_attach/on_detach 生命周期挂载到 EventEngine。 用法: from evebus import EventEngine, Plugin class MyPlugin(Plugin): def __init__(self): super().__init__("my_plugin") def on_attach(self): @self.on("data.quotes.*") async def on_quote(topic...
openbot-coder/pyevebus
python/evebus/plugin.py
.py
339f22587ece3cb0
7
0