/** * The W1g facade's pure half (core/README.md, "Readouts", W1g): decoding * `bo_engine_records` buffers into classic's `SimFailure` objects and keys, * the message builders, the PTC set, the thermal readout and the static * warnings with their announce queue. No wasm call happens here: engine.ts * collects the buffers and the device state and hands them over. * * Every string is classic's. The message builders copy classic's template * literals character for character (G10), because classic builds them * inline in its device models; the thermal readout and the static warnings * call classic's own exported functions. */ import type { Net } from "../sim/engine/graph.js"; import { railIcPowerChatterDetail, railIcPowerChatterMessage, type FlybackTopology, type SimCircuit, type SimFailure, type SimFailureKind, type SimWarning, type SimWarningCode, type ThermalRuntimeReadout } from "../sim/engine/sim-engine.js"; import { type ThermalDeviceProfile } from "../sim/thermal-physics.js"; /** f64 values per record: `device, code, pin, since, value, limit, aux` (C ABI, `bo_engine_records`). */ export declare const CORE_RECORD_STRIDE = 7; /** `bo_engine_records` channels. */ export declare const CORE_RECORD_CHANNEL: { readonly failures: 0; readonly warnings: 1; readonly ptcTripped: 2; readonly latchLog: 3; }; /** * The failure kinds the core records. Classic's other kinds stay off this * list: `supply_overvoltage` (0.6.8) latches on an MCU board's supply, and * MCU boards never compile to the core (unsupported-kind), so no core record * names one. Keeping the type narrow keeps `failureFromRecord`'s switch * exhaustive when classic adds a kind. */ export type CoreFailureKind = Extract; /** Failure codes on channels 0 and 3. */ export declare const CORE_FAILURE_KIND_BY_CODE: ReadonlyMap; /** * Warning codes on channel 1. `missing_flyback` is reserved: the facade * derives it (W1g point 11). `rail_ic_power_chatter` is a chip sliding along * its power floor (ruling R92, R53), classic R89's code. */ export declare const CORE_WARNING_CODE_BY_CODE: ReadonlyMap; /** The one PTC code on channel 2. */ export declare const CORE_PTC_TRIPPED_CODE = 1; /** One decoded record. `pin` is `-1` for none; `aux` is the `output_sag` direction (1 HIGH, 0 LOW). */ export interface CoreSlowRecord { device: number; code: number; pin: number; since: number; value: number; limit: number; aux: number; } /** Splits a collected buffer into records. A length off the stride is an ABI drift, so it throws. */ export declare function decodeRecords(buffer: ArrayLike): CoreSlowRecord[]; /** * What a record's `device` and `pin` indices name: per device record, its * component id and its pin ids in pin-record order (for an IC, `vcc` and * `gnd` first). The compiler keeps both. */ export interface RecordNames { readonly devices: ReadonlyArray<{ readonly componentId: string; readonly pinIds?: readonly string[]; }>; } /** Classic's `failureKey` (SE:947): `${kind}\0${componentId}\0${pinId}`, `pinId` `""` when absent. */ export declare function failureKey(kind: SimFailureKind, componentId: string, pinId?: string): string; /** Classic's `warningKey` (SE:975), the same shape as `failureKey`. */ export declare function warningKey(code: SimWarningCode, componentId: string, pinId?: string): string; /** `resistor_overload` for a `resistor` (PA:155; `commitResistiveOverloadStress`, devices/passives.ts). */ export declare function resistorOverloadMessage(componentId: string, value: number, limit: number): string; /** `fuse_tripped` (PA:731; `fuseModel.updateFailures`, devices/passives.ts). */ export declare function fuseTrippedMessage(componentId: string, value: number, limit: number): string; /** `led_failed` (SC:508; `commitLedOvercurrentStress`, devices/semiconductors.ts). */ export declare function ledFailedMessage(componentId: string, value: number, limit: number): string; /** `output_sag` (SE:6333; the failure pass's sag scan, sim-engine.ts). `high` is the commanded direction. */ export declare function outputSagMessage(componentId: string, pinId: string, high: boolean, actual: number): string; export { railIcPowerChatterDetail, railIcPowerChatterMessage }; /** * One failure record as classic's `SimFailure`, in classic's key order: * `componentId, kind, since, value, limit, message`, with `pinId` after * `kind` on `output_sag` only (classic sets it nowhere else, SE:6328). */ export declare function failureFromRecord(record: CoreSlowRecord, names: RecordNames): { key: string; failure: SimFailure; }; /** Channel 0 as classic's `getFailures()`: a fresh object in record (latch) order. */ export declare function failuresFromRecords(records: readonly CoreSlowRecord[], names: RecordNames): Record; /** Channel 3, the latch log, as a list of failures, each with its latch's `since`. */ export declare function failureListFromRecords(records: readonly CoreSlowRecord[], names: RecordNames): SimFailure[]; /** Channel 2 as classic's `getPtcTripped()`: a fresh set of component ids. */ export declare function ptcTrippedFromRecords(records: readonly CoreSlowRecord[], names: RecordNames): Set; /** * One channel 1 record as classic's `SimWarning`, keyed by `warningKey`. Only * `rail_ic_power_chatter` has a Rust producer; a record of a reserved code * means the two halves were built from different contracts, so it throws. * `value` is the chip's floor (V), as classic R89 sets it; the record's * `limit` (A) is a supply's, not the floor's rating, so it is in the detail * line only. */ export declare function warningFromRecord(record: CoreSlowRecord, names: RecordNames): { key: string; warning: SimWarning; }; /** What `getThermalState` reads from `bo_engine_device_state` for a device with a code 91 record. */ export interface ThermalDeviceReading { temperatureC: number; dissipatedPowerW: number; thermalShutdown: boolean; } /** * Classic's `ThermalRuntimeReadout` for one heated device, composed through * classic's own `stepThermalDevice` at `dt = 0` (core/README.md, Readouts, * `getThermalState`): with no elapsed time it returns `T` unchanged and * computes the target, the derating, the per-state warnings and * `withinContinuousLimits` exactly as classic's step does, so every string * is classic's. The key order is classic's stored state (SE:6394-6403) plus * `label` (`getThermalState`, SE:2514). */ export declare function thermalReadout(profile: ThermalDeviceProfile, catalogUid: string, reading: ThermalDeviceReading, ambientC: number): ThermalRuntimeReadout; /** The loaded graph as classic's `_evaluateStaticWarnings` builds it, from `buildNets`'s nets. */ export declare function flybackTopology(circuit: SimCircuit, nets: readonly Net[]): FlybackTopology; /** * The facade's warnings and their announce queue, with classic's semantics * (`_latchWarning`, `_pruneUnannouncedWarnings`, `takeNewWarnings`, * `_evaluateStaticWarnings`; SE:5719-5726, 2488, 5809): a warning is queued * once when it latches, a still-true one keeps its `since` and is not queued * again, and a key that is gone leaves the queue with it. */ export declare class WarningLedger { private readonly warnings; private unannounced; /** `_latchWarning`: a no-op for a key already latched. */ latch(key: string, warning: SimWarning): void; /** * `_evaluateStaticWarnings`: re-derives `missing_flyback` for every * component, latching a new condition with `since`, dropping one that no * longer holds, then pruning the queue to the map. */ evaluateStatic(circuit: SimCircuit, nets: readonly Net[], since: number): void; /** `_pruneUnannouncedWarnings`. */ prune(): void; /** `resetFailures`'s first half: every warning and the queue go. The caller re-derives the static ones. */ clear(): void; /** `getWarnings()`: a fresh object in latch order. */ all(): Record; /** A deep copy, for `CoreEngine.saveState` (W2a): the warnings and the announce queue as they stand. */ copy(): WarningLedger; /** * W2c: the ledger a reload starts from, as classic's load carries * `state.warnings` for each component whose id and kind survive (its * announce queue, pruned to them, goes on; SE:3171). */ carryOnto(keep: (componentId: string) => boolean): WarningLedger; /** `takeNewWarnings()`: the queued warnings in latch order, then an empty queue. */ takeNew(): SimWarning[]; }