The Manifold
Stardate 55168.0 ยท UES Magnanimous
Briefing
Commander Raghunathan has read the other ship's release notes for version 1.10.3 eleven times and has finally said it out loud: pressure|flow mismatch is the plasma manifold. It is the fault behind the incident nobody talks about, and it is scheduled, according to both logs, for tomorrow. The other Magnanimous did not have the fix in time. It has brought it back.
The fix is a validator. Flow through the manifold should track pressure: the expected flow is four times the square root of the pressure, and a reading whose flow is more than ten percent off that expectation is a mismatch. One mismatch is noise. Two are a warning. Three in a row is the incident, and the core must be told before it happens. This is three functions, eight objectives, and the reason the other ship came. Ensign Tannenbaum has asked to help and, for the first time, been told yes.
Mission objectives
ARCHIE checks all eight every time you run diagnostics.
- โขexpected_flow: four times the square root of pressure, to two places
- โขis_mismatch: a flow more than ten percent off expectation
- โขis_mismatch: exactly ten percent off is not a mismatch
- โขmismatches: the indices of every mismatched reading
- โขmismatches: no readings, no indices
- โขstatus: 'nominal' when nothing is wrong
- โขstatus: 'mismatch at N readings' otherwise
- โขstatus: 'critical' when three or more mismatches are consecutive
Objective
Three functions:
expected_flow(pressure):4 * sqrt(pressure), rounded to two decimal places.is_mismatch(pressure, flow):Trueifflowdiffers from the (unrounded) expected flow by more than ten percent of the expected flow.mismatches(readings):readingsis a list of(pressure, flow)tuples; return the list of indices that mismatch.status(readings):"nominal"if none mismatch;"critical"if three or more mismatched indices are consecutive; otherwise"mismatch at N readings"with N the count.
Press Run Diagnostics and I will tell you which objectives you actually met.
Objective
Four functions:
expected_flow(pressure: f64) -> f64:4 * sqrt(pressure), rounded to two decimal places.is_mismatch(pressure: f64, flow: f64) -> bool: true ifflowdiffers from the (unrounded) expected flow by more than ten percent of it.mismatches(readings: &[(f64, f64)]) -> Vec<usize>: the indices of readings that mismatch.status(readings: &[(f64, f64)]) -> String:"nominal"if none;"critical"if three or more mismatched indices are consecutive; otherwise"mismatch at N readings".
Press Run Diagnostics and I will tell you which objectives you actually met.
Ask Commander Raghunathan for a hint
Build the three functions on top of each other: status uses mismatches, which uses is_mismatch, which uses expected_flow. For 'consecutive', walk the indices and count a run; reset the run whenever the gap is more than one.
Debrief
The validator is in. It flags two mismatches in the last hour of our log, neither consecutive. Commander Raghunathan has looked at the manifold itself, with the torch, and found the seal the notes describe. She has replaced it. It took four minutes. She has been standing next to it since.
Away mission, for your own editor: turn the validator into a real
program. Read readings from a CSV file, one pressure,flow per line, print
the status, and exit with a non-zero code on critical so a shell script can
react. Then add a --tolerance flag with a default of 10 percent. Nothing
here is graded; it is the point at which a browser console should make you want a real
one.