123 Commits
Author SHA1 Message Date
noah 6e7d10d2cf Merge pull request 'Autodetect, fault tolerance, tuning, API/UI and Stratum V2 for per-family images' (#14) from feature/detect-core into next
next-build / build (push) Successful in 25s
v0.1.0-rc.34
2026-10-22 11:34:17 -06:00
noah f6af71138c Publish the live operating point every control period
source-pr / source (pull_request) Successful in 12s
A client watching the API during a run saw the boot-time snapshot: status was
published at boot and again when the loop exited, so frequency and voltage were
frozen at their starting values for the whole run. The loop now publishes each
period, which is what makes the UI and the API honest while the machine is
actually mining.
2026-10-22 11:10:32 -06:00
noah 8564ced65d Validate profile databases and make the power check meaningful
source-pr / source (pull_request) Successful in 12s
--check-profiles parses a database and reports schema, count and validation,
so envelope work can be checked before an image ever boots with it. An inverted
envelope is rejected with a non-zero exit.

The conformance power check now sets 500 MHz before reading, because a backend
that always reports 0 W passed a range check while being useless to a
power-target loop. It must now report a plausible non-zero draw at a known
operating point.
2026-10-22 11:08:07 -06:00
noah 78baeb8c31 Add a HAL conformance harness for family backends
source-pr / source (pull_request) Successful in 12s
A family backend is only useful if it answers the contract the OS expects, and
until now the only way to know was to boot a board and watch it fail somewhere
downstream. --check-hal walks the contract in order (capabilities, probe,
EEPROM, PSU, frequency and temperature, power, fan) and reports each check
separately, using a fresh connection per check so one desynchronised exchange
cannot invalidate the rest.

It catches the failure modes that matter for autodetect: a backend that does
not advertise chain probing, one that reports an inverted envelope, one that
returns an implausible temperature or power, and one that cannot accept
frequency or fan commands.
2026-10-22 11:06:22 -06:00
noah a16a4385f8 Drive an SV2 session against a socket pool end to end
source-pr / source (pull_request) Successful in 12s
The codec and session had only ever been tested in memory. This runs the real
path over TCP: the client handshakes, opens a channel, receives SetNewPrevHash
and an active NewMiningJob, submits a share and consumes the acknowledgement,
against a mock pool that speaks the same frames.

It also pins the ordering the protocol depends on: the job is interpreted only
after the prev hash, and the submit sequence starts at one.
2026-10-22 11:03:41 -06:00
noah 79f492e5e8 Make the reference server thermal model fan-aware
source-pr / source (pull_request) Successful in 13s
Zones now respond to the fan that actually cools them (round-robin by zone
index), so the active fan sweep can be demonstrated end to end without
hardware: with two fans and three zones the learned map is fan 0 -> zones 0,2
and fan 1 -> zone 1, persisted to the map file.

The settle interval is configurable (ALKANE_FAN_SETTLE_MS) because the real
twenty-second settle makes an interactive sweep last minutes.
2026-10-22 11:02:02 -06:00
noah b0d81b5d0e Add a reference HAL server and power telemetry
source-pr / source (pull_request) Successful in 13s
The reference server answers the real ALKH contract from a fixed machine
description, so the whole OS path can run on a development host and a backend
author has a concrete example of every opcode. It serves detection, frequency,
fan, temperature and power over one socket.

Power was the missing measurement: a power target could not regulate because
the HAL had no way to report watts, so READ_POWER joins the verbs behind
CAP_POWER. With it, --boot against the reference server settles the loop at
623 MHz for a 2400 W target (4 W per MHz in the model) instead of holding at
the boot frequency.

Fan mapping stays opt-in for --boot (ALKANE_FAN_FANS/ALKANE_FAN_ZONES) because
it perturbs the machine and takes minutes.
2026-10-22 10:59:53 -06:00
noah dccbefc8b7 Add the HAL frequency actuator and a --boot command
source-pr / source (pull_request) Successful in 14s
The tuner produced a frequency the hardware contract had no way to apply, so
detection and tuning could not affect a real board. SET_CHAIN_FREQUENCY joins
the HAL verbs behind its own capability bit, and HalClient refuses to use it
when the backend does not advertise it.

--boot HAL_SOCKET PROFILES.json TARGET [PIC|NOPIC] [TICKS] now runs the real
path: detect over the socket, serve the API and UI, read the hottest sensor,
tick the runtime, apply the frequency to each active chain and the fan duty
when the target owns the fan, then print the published document. A missing
socket exits 1 with a backend error instead of a half-booted miner.
2026-10-22 10:56:43 -06:00
noah 894b22277f Boot over the real HAL contract
source-pr / source (pull_request) Successful in 14s
boot_from_hal connects the board backend, detects through the actual HAL
verbs, runs the one-time fan sweep through the same socket, publishes the
snapshot and returns the runtime and the learned map.

The tests drive it against a mock backend that speaks the real wire protocol
(ALKH framing, CAPABILITIES, PROBE_CHAIN, READ_EEPROM, IDENTIFY_PSU), so the
detection path is exercised end to end rather than assumed, and a missing
socket surfaces as a backend error instead of a half-booted miner.
2026-10-22 10:54:35 -06:00
noah 64e1a9ae2b Report one operating point, not two
source-pr / source (pull_request) Successful in 13s
The live frequency and the boot-time operating point were both in the
hardware document, so a client could read 563 MHz in one field and 300 MHz in
another. The document and the cgminer stats now both derive the operating point
from the live frequency and the envelope, which is also what makes the reported
voltage correct.
2026-10-22 10:51:45 -06:00
noah 2b07d27c67 Pair voltage with frequency across the profile envelope
source-pr / source (pull_request) Successful in 12s
Boards do not run at a fixed voltage across their frequency range, so the
reported operating point was describing a machine that does not exist: the
voltage stayed at the boot value while the tuner moved the frequency.

Envelope::voltage_for interpolates linearly between the profile floor and
ceiling and clamps outside it, and MinerRuntime now reports the voltage that
pairs with the applied frequency. A single-frequency envelope reports its
floor without dividing by zero.
2026-10-22 10:50:56 -06:00
noah 42509a6383 Add a runnable self-check for the boot path
source-pr / source (pull_request) Successful in 12s
alkane-os --self-check drives the whole chain without hardware: parse the
example profile database, detect three BM1362 chains with a dead EEPROM,
identify an APW12, boot the runtime, tick toward a power target and print the
published hardware document. It fails loudly if the profile database does not
parse, detection refuses, the tuner does not move, or the chain set is wrong,
which makes it usable as a bench smoke test on a bare control board.

profiles.example.json is a shape example, not validated hardware data: the
envelopes are placeholders until real captures fill the database.
2026-10-22 10:49:04 -06:00
noah 5048156b74 Persist the learned fan map and reuse it until the hardware changes
source-pr / source (pull_request) Successful in 12s
Mapping fans perturbs the machine, so it is done once and stored. ensure_map
reuses a stored map only when the fan and sensor counts match the current
machine; a mismatch is ignored rather than trusted, because applying a map
learned on four fans to a two-fan machine would mis-control thermals.

The store is a small schema-1 document; corrupt or foreign files are ignored
and trigger a fresh sweep instead of failing the boot.
2026-10-22 10:47:19 -06:00
noah 5a1a7948b1 Add the boot sequence from backend and profiles to runtime
source-pr / source (pull_request) Successful in 12s
app::boot is the sequence a family image runs at start-up: validate the
profile database, detect the hardware through the backend, build the runtime
with the operator target and fault policy, and publish the API snapshot in one
step. It returns the runtime or an explicit BootError, so a refusal is visible
to the caller instead of a half-configured miner.

Target labels are defined once (power:3000, hashrate:200, ambient:20000,
fan:100) so the API, UI and logs cannot drift apart.
2026-10-22 10:45:33 -06:00
noah 2c6535f948 Wire the API and UI through one start-up path
source-pr / source (pull_request) Successful in 12s
Add an app layer that binds and starts the management API and the web UI,
publishes the runtime snapshot, and exposes a bound-address result so callers
can discover ephemeral ports. The binary now uses the same function the tests
use, so the wiring CI exercises is the wiring that runs on a board, and it
gained ALKANE_WEB_LISTEN alongside ALKANE_API_LISTEN.

The snapshot is built from the live runtime: active chains, stop reason and
the last applied frequency rather than the boot default.
2026-10-22 10:43:39 -06:00
noah e3e0dab0ec Add the SV2 TCP link and the V1 fallback policy
source-pr / source (pull_request) Successful in 12s
TcpLink turns a TCP stream into framed SV2 messages: it buffers partial reads
and returns one frame at a time, so a frame split across packets is not a
protocol error and two frames in one read are still delivered separately. A
closed stream is an error, never an empty frame.

The fallback policy permits Stratum V1 only when the operator allowed it and
the failure is not transport-level: a dead route or a dropped stream fails
identically on V1, so falling back there would only delay the real error. V1
failures never loop back to V2.
2026-10-22 10:41:23 -06:00
noah 97ea7a4f65 Add the mining runtime state machine
source-pr / source (pull_request) Successful in 13s
Tie the detection plan, the fault ladder and the tuner together, where their
order is decided: a stopped machine is never tuned, a disabled chain is never
dispatched to, and a missing measurement holds the last command instead of
inventing one.

MinerRuntime exposes the active chain set, the stop reason and an operating
point that reflects the last applied command rather than the boot-time
default, which is what the API snapshot reports.
2026-10-22 10:39:43 -06:00
noah b25d6b2a71 Serve an on-box web UI backed by the JSON API
source-pr / source (pull_request) Successful in 12s
The miner now serves a single page that polls /api/hardware and shows profile,
chip, PSU, operating point, chains and EEPROM state, active chains, target and
whether hashing stopped. The page is a convenience; the API routes it uses are
the interface of record, so a JSON-only client loses nothing.

No framework and no new dependency: the request parser is bounded, only GET is
accepted, responses close the connection and are not cached. MiningStatus now
exposes its hardware and summary documents so the UI and the cgminer-style
server build them once, in one place.
2026-10-22 10:38:07 -06:00
noah 914fb8bef7 Add the Stratum V2 session: handshake, jobs and submissions
source-pr / source (pull_request) Successful in 11s
Drive the client half of an SV2 mining connection: send SetupConnection,
verify the success reply, open a standard channel and remember its id, target
and extranonce prefix. Afterwards the session interprets NewMiningJob,
SetNewPrevHash, SetTarget and share acknowledgements, and submits standard
shares with a monotonic sequence number.

State is explicit rather than assumed: a job that arrives before any
SetNewPrevHash reports no previous hash instead of a zero one, a setup or
channel rejection carries the server's error code, and an unknown message is
ignored instead of killing the session.
2026-10-22 10:36:29 -06:00
noah 6ab645e731 Add the Stratum V2 mining-protocol codec
source-pr / source (pull_request) Successful in 12s
Implement the client half of SV2 as framed messages: the 6-byte header
(extension_type U16, msg_type U8, msg_length U24), SetupConnection and its
success reply, OpenStandardMiningChannel and its success reply, NewMiningJob
with both the active and future ntime forms, SetNewPrevHash and
SubmitSharesStandard.

Field layouts and message identifiers come from the published specification
(03-Protocol-Overview 3.2/3.6, 08-Message-Types, 05-Mining-Protocol 5.3) and
were checked against it rather than recalled. Decoding is strict: truncated
payloads, bad option markers, bad UTF-8 and a non-finite or negative hashrate
are protocol errors, never defaults.
2026-10-22 10:34:44 -06:00
noah b62d64adfb Split hashrate across pools with smooth weighted round-robin
source-pr / source (pull_request) Successful in 12s
Each dispatched work slot comes from exactly one pool, and the router hands
out slots in proportion to the configured weights. Smooth weighted
round-robin is used instead of a plain repeating pattern because it keeps the
mix correct at every prefix: a miner with three chains still gets the intended
ratio in the first three slots, not only after a hundred.

Weights parse from a simple list, a zero-weight pool never receives work, and
malformed configurations (empty, all zero, non-numeric, too many pools) are
refused rather than silently normalised.
2026-10-22 10:32:42 -06:00
noah fe0c2d43ce Expose detection, envelope and tuning state on the management API
source-pr / source (pull_request) Successful in 12s
The cgminer-compatible surface only answered summary and version, which hides
everything detection learned. The API now also answers hardware (profile, chip,
PSU, envelope, operating point, per-chain chip count and EEPROM state, fan
zones, active chains, stop reason, target and live frequency) and stats (the
same data in cgminer's flat STATS shape).

MiningStatus carries an optional HardwareSnapshot behind a mutex, so a client
can tell unavailable apart from an empty machine, and unknown commands still
refuse. Chip models gained a stable API name so the wire strings do not drift
from the enum.
2026-10-22 10:30:49 -06:00
noah 96f84dc283 Add the ambient-temperature and max-fan tuning targets
source-pr / source (pull_request) Successful in 12s
Ambient mode holds the hottest sensor a configured margin above the measured
intake temperature, which is the efficiency-at-this-ambient operating point;
missing either sensor is an error rather than a guess. Max-fan mode pins the
fan at its cap, ramps frequency toward the envelope ceiling, and still defers
to the thermal guard.

step() now returns a Command carrying the frequency and, when the target owns
the fan, the duty to apply. The max-fan ramp is explicit rather than a
setpoint loop: a P controller fed its own output settles at half the ceiling,
which the ramp test caught.
2026-10-22 10:28:53 -06:00
noah 5aa6349e27 Add adaptive PID tuning with a thermal derate guard
source-pr / source (pull_request) Successful in 12s
Replace preset tuning with a bounded controller: a PID over chain frequency
that targets a DC power draw or a hashrate, inside the profile envelope. The
controller rate-limits its output, ignores errors inside a deadband, takes the
derivative on the measurement so a setpoint change does not kick it, and uses
conditional integration so a saturated actuator does not wind the integral up.

A thermal guard runs before the target logic: any sensor at or above the
ceiling derates the frequency regardless of what the operator asked for, so a
hashrate target can never cook a board.
2026-10-22 10:26:30 -06:00
noah 724b3da478 Add the fault-tolerance escalation ladder
source-pr / source (pull_request) Successful in 12s
The machine should keep hashing with as many dead chips or chains as
possible, so faults escalate in steps instead of stopping at the first one:
a chain error retries up to a policy limit, then the chain is disabled and the
rest keep running; a chip fault disables only that chip; a chain whose nonce
response stays below the policy floor for consecutive windows is disabled; a
temperature fault stops the machine immediately.

Disabling every chain stops with NoChainsLeft rather than leaving the miner
spinning on an empty active set. The supervisor owns no hardware and no
thermal limits; those come from the profile envelope.
2026-10-22 10:24:38 -06:00
noah ef399d0ca5 Drive fan probing through the HAL client
source-pr / source (pull_request) Successful in 12s
HalClient implements FanProbe, so the measurement sweep runs against a real
board over the same local contract: set_fan maps to SET_FAN_TARGET and
read_zone maps to READ_TEMPERATURE. The wire round-trip test now exercises
both fan verbs through the mock backend.
2026-10-22 10:22:52 -06:00
noah 4139576155 Add the fan-mapping measurement sweep
source-pr / source (pull_request) Successful in 11s
sweep() drives the probing run that map_fans consumes: it moves one fan at a
time between the low and high duty while the others hold their setting, waits
for the settle interval, and records every zone reading. Repeat readings are
emitted so the mapper averages noise.

Safety is enforced in the loop, not by convention: a probe duty below the
minimum, an empty duty range, an inverted range, zero reads and zero fans are
all refused before any fan is touched, and the run always ends with every fan
restored to the high duty so the machine is not left under-cooled.
2026-10-22 10:21:26 -06:00
noah c616429669 Map fans to thermal zones by active probing
source-pr / source (pull_request) Successful in 11s
Fans are not labeled by the hardware: a fan can cool one hashboard heavily
and another barely, and front/back top/bottom is physical. map_fans learns the
map from a stepped run: for every fan compare zone temperatures at the lowest
and highest duty, then give each zone to the fan with the strongest cooling
response.

A response must clear min_drop_mc and beat the runner-up by
min_margin_per_mille, otherwise the zone is reported unresolved rather than
guessed, so a noisy run cannot invent a map. One fan may own several zones,
and a fan with no duty range contributes no evidence.
2026-10-22 10:19:45 -06:00
noah 9ed94bd01f Add the profile database and the end-to-end detection driver
source-pr / source (pull_request) Successful in 12s
Profiles carry the only envelopes detection may use, so a combination absent
from the database is refused rather than guessed. The schema-1 document is
validated on load: unknown chips or sensor wiring, inverted or zero envelopes,
zero chain counts and duplicate names are all rejected.

run_detection now ties the pieces together: probe every declared port, select
a profile by chip, sensor wiring and physical port count, identify the PSU, and
emit a HardwarePlan. A machine with a dead chain still matches its three-chain
profile and runs degraded instead of being reclassified; plan() now tolerates
unidentified chains and refuses only when nothing identified.

The detection backend contract gains identify_psu(), and HalClient answers it
through the new HAL verb.
2026-10-22 10:17:34 -06:00
noah 3028ef29fb Carry detection verbs over the HAL wire contract
source-pr / source (pull_request) Successful in 12s
Add capability negotiation and three detection verbs to the local HAL
contract: CAPABILITIES, PROBE_CHAIN, READ_EEPROM and IDENTIFY_PSU. A backend
that predates them rejects the capability query, which surfaces as a protocol
error instead of a silent zero. HalClient implements ChainProbe, so the OS
detection driver can run against a real board without knowing the family.

The probe contract is now error-aware: a transport failure propagates as an
error and is never reported as a silent port, and probe_chain/detect_chains
are generic over the backend. A wire round-trip test drives a mock backend
over a socket pair and checks the encoding of all three verbs.
2026-10-22 10:15:29 -06:00
noah 99fb12d725 Add chain probing policy to the detection core
source-pr / source (pull_request) Successful in 12s
Define the backend contract for identification (ChainProbe) with a bounded
ProbeBudget and a ProbeOutcome that distinguishes an identified chain from a
silent port and from unframed bytes. probe_chain retries a chain until it
identifies or the budget is spent, and reports an exhausted chain as an
unknown chip instead of dropping it; detect_chains walks every declared port.

Framing and baud switching stay in the per-family SDK backend. Tests cover
retry-until-identified, budget exhaustion, EEPROM state retention and the
refusal path when a chain never identifies.
2026-10-22 10:13:18 -06:00
noah 367f07d956 Add hardware detection plan model
source-pr / source (pull_request) Successful in 14s
Introduce the detection core data model: chain observations, board profile
and PSU envelopes, envelope intersection, and a conservative operating point
when the hardware is not confirmed by an EEPROM. Refusal is explicit for
unknown chips, missing PSUs and empty envelopes, and degraded chains are
reported rather than fatal.
2026-10-22 10:11:52 -06:00
noah 29749fee4a Merge pull request 'Name each Alkane evidence milestone without promoting claims' (#13) from tooling/evidence-levels into next
next-build / build (push) Successful in 26s
v0.1.0-rc.33
2026-10-21 07:50:26 -06:00
noah 1f558ef596 Name each Alkane evidence milestone without promoting claims
source-pr / source (pull_request) Successful in 58s
2026-10-21 07:48:45 -06:00
noah 576f834169 Merge pull request 'Separate research evidence and speed scoped OS PR checks' (#12) from tooling/lab-evidence-ci into next
next-build / build (push) Successful in 38s
v0.1.0-rc.32
2026-10-21 07:40:53 -06:00
noah 093cb62212 Separate research evidence and speed scoped OS PR checks
source-pr / source (pull_request) Successful in 10s
2026-10-21 07:38:30 -06:00
noah 2e42bedb84 Merge pull request 'Route trusted OS next jobs to verifier' (#10) from ci/isolate-fast-runner-next into next
next-build / build (push) Successful in 29s
v0.1.0-rc.31
2026-10-20 18:56:41 -06:00
noah 0b785eebb5 Route trusted OS next jobs to verifier
source-pr / source (pull_request) Successful in 57s
2026-10-20 18:45:04 -06:00
noah 885a71b6fe Merge pull request 'Preserve queued OS merge builds and guard reruns' (#9) from ci/preserve-next-runs into next
next-build / build (push) Successful in 42s
v0.1.0-rc.30
2026-10-19 14:46:44 -06:00
noah 8672507fa4 Preserve queued OS merge builds and guard reruns
source-pr / source (pull_request) Successful in 42s
2026-10-19 14:45:35 -06:00
noah 37f1f8433b Merge pull request 'Route short OS builds to Alkane fast runner' (#8) from ci/route-os-fast-runner into next
next-build / build (push) Successful in 25s
v0.1.0-rc.29
2026-10-19 14:43:50 -06:00
noah b703c757e4 Route short OS builds to Alkane fast runner
source-pr / source (pull_request) Successful in 29s
2026-10-19 14:42:54 -06:00
noah 98d891fc67 Merge pull request 'Expose observed BM1370 work ID correlation' (#7) from feature/bm1370-work-id into next
next-build / build (push) Canceled after 0s
2026-10-19 14:35:26 -06:00
noah d6e043d79f Expose observed BM1370 work ID correlation
source-pr / source (pull_request) Successful in 10s
2026-10-19 13:48:13 -06:00
noah ba286758c7 Merge BM1370 captured wire primitives
next-build / build (push) Successful in 13s
Pure Rust framing; chain, work attribution, and pool acceptance remain open.
v0.1.0-rc.28
2026-10-19 12:17:42 -06:00
noah b65e6bc9f1 Install rustfmt in Alkane OS pull request job
source-pr / source (pull_request) Successful in 12s
2026-10-19 12:15:30 -06:00
noah f7aeeaa2eb Run protected Alkane OS source checks on pull requests
source-pr / source (pull_request) Failing after 5s
2026-10-19 12:12:48 -06:00
noah 1b0607cbd8 Add capture-checked BM1370 wire primitives 2026-10-19 12:11:00 -06:00
noah 7c361aecd9 Invalidate ASIC work when pool version mask changes
next-build / build (push) Successful in 21s
v0.1.0-rc.27
2026-10-17 06:05:03 -06:00
noah 212c9198eb docs: shorten OS entry guide
next-build / build (push) Successful in 19s
v0.1.0-rc.26
2026-10-17 01:42:42 -06:00