Repository navigation
Invent tree aniket - #4
Merged
Merged
Conversation
Two faults found while working out how to set limits on the remaining parameters, both of which would have undermined the limits themselves. The page and the detector disagreed about the boundary. classify() uses strict inequalities - warn_max is the last acceptable reading, not the first unacceptable one, and the winding figure of 125 degC is "the highest reading the machine is designed to produce" - while the page used >=. A sensor sitting exactly on its setpoint was drawn as over a limit while the detector called it normal, which is a disagreement an operator cannot resolve from the screen. The page now matches the server on all six bounds, and two checks pin it there. And there was no supported way to set a limit at all: no writable endpoint, no admin registration, nothing but a devtool script that does not ship in the production image. Worse, activation clears every bound on a binding whose dictionary point changes meaning, so limits are not set once - they have to be re-appliable after every re-review. So they are a reviewed file now, like the dictionary packs, with a command that applies it. A bound needs a citation and a reason, the same way an approval needs a note. A figure derived in one unit is refused on a signal measured in another rather than coerced. And a family may name channels to leave disarmed, each with its own reason, because a limit armed on a channel whose own history breaches it raises a permanent alarm about a machine that is standing still. The file carries the one decision already made, and reproduces it exactly: 318 winding channels matched, 307 limited, 11 left disarmed. Getting that right took two corrections the dry run caught - the first draft would have armed the 11 Millbrook channels the original review deliberately excluded, and the second would have disarmed the same bay numbers at the other two stations, because bay numbering repeats and an exclusion naming only a tag hits all three. 826 backend tests, 8 component checks, tsc and biome green.
The 307 stator-winding points have carried warn 125 / critical 145 since they were applied, and could never have raised anything. evaluate_thresholds had one caller - the webhook ingest view - and that view is unreachable for a Cosmos source, because ingest_readings refuses a Cosmos batch without an explicit station. A reading could have landed above 145 degC every minute for a year and MachineAnomaly would still have held nothing. The live poll path now evaluates the machines whose state it wrote, after the ingest verdict is taken and inside a helper that cannot raise: the sweep's own handler feeds _classify, which has no branch for a detector error and would file one as NETWORK while suppressing last_success_at, telling an operator a poll that succeeded could not reach Cosmos. The whole body is guarded, not just the per-machine call, because the queryset's SELECT runs when the loop first iterates. The machine set comes from IngestResult.machine_ids, returned out of _apply_snapshot rather than accumulated on the connector: that method is atomic, so a set mutated inside it would keep entries describing rows the rollback discarded, and the poller would then judge a machine nothing was written for. Two more paths, because the poller alone is inert here. Every station is parked at the end of a fully consumed recorded window, so no poll will ever apply another document: - apply_signal_limits evaluates every binding a family matched, not only the ones whose bounds moved, so a re-run on an already-armed estate still answers "does anything breach this". It runs inside the transaction, so --dry-run reports the number worth having before arming anything - how many alarms the file raises as the estate stands - and then discards it. For the committed file: 28 machines, 0 breaching. - import_pumphouse_dump does the same. It is the path that really loads a station from a recorded window, so wiring only the poller would have closed the gap on the path that reads nothing and left it open on the one an operator uses. Auto-resolution stopped lying. It is the only code in the backend that writes RESOLVED, and it closed everything it stopped matching with "Signal returned inside its configured limits" - including the case where activation had wiped all six bounds because a point's meaning changed, asserting a recovery on a channel still reading 191 degC. There are now two notes, and the honest one says the condition was not observed to end. A bad-quality reading still holds its condition open: a sensor going bad is not evidence either way. Anomaly observation times are served in the clock the rest of the blade uses. Nothing had needed this because no anomaly had ever existed; the first one the estate raised would have been dated 442 days before the signal row that produced it, on the same screen. The stored instant stays on the plant's clock, so the migration is still checkable against the source, and acknowledgement and resolution times are left alone - a person acted at a real moment. Verified on the live local estate: 30 machines evaluated, 0 anomalies; forcing one winding to 191 raises CRITICAL with the right bounds in its metrics and a card dated 442.7 days forward; recovery writes the affirmative note. THRESHOLDS.md and BLOCKERS.md record the second research pass over the remaining four families - 852 points, no new row, and why - along with the two changes that were designed and then deliberately not built.
The production image copies contrib/cosmos/review and not contrib/cosmos/limits, so apply_signal_limits fails there on a missing file. A deployment could therefore complete every step of section 14, draw every tile correctly, and be unable to raise a single alarm - with no limits, classify() returns unknown for all 1,452 bindings. That is the same failure the review packs already had recorded against them, and the hardest kind to notice, because nothing is broken on screen. The sequence had no step for arming limits at all, which is why the gap survived being written down twice. It is now 14.3.6, dry run first: the preview reports how many alarms the file raises on the estate as it stands and then discards them, which is the number worth seeing before arming anything. Two stale cells in the bootstrap table said "no shipped path creates them" for dictionary points and cached current values, contradicting 14.5, which records both as closed - the dictionary comes from each station's snapshot and the cache is written by the poller once a station is activated. Limits were missing from the table entirely. And 14.6 treated a 14.3.6 as one-way that did not exist: the review is applied inside 14.3.5, so that is the one-way step.
Coverage goes from 307 of 1,452 bindings to 412. The new row carries the stator winding's 125/145 onto the 106 motor and stator core detectors, because no standard publishes a core temperature at all: IS/IEC 60034-1 has no core row in Table 7 and cl. 8.10.4 is qualitative. That is defensible only as an upper bound and the entry says so in its own citation - it cites the winding figures and claims nothing about cores. The assumption field states the cost rather than burying it: a core runs cooler than the winding around it, so 125/145 warns late rather than early. Safe in direction, insensitive in practice. It will not catch a core drifting warm, and it is not a substitute for a measured core rise at rated load. Screened per (station, path) over the recorded span with the same sampler and the same rules the winding row was held to - PLAUSIBLE (0, 125), MIN_SAMPLES 20, densifying while any channel is short - rather than trusting the single cached instant. 75 samples per channel, 105 clean, none too sparse to judge. One channel failed, and it closes a question this repo has carried open: PUMP4_MOTOR_CORE_RTD2_PROCESS_VALUE at Cedar Creek reads exactly -242.1 in 75 of 75 samples while its five sibling detectors on the same bay read 36.6-43.4 degC throughout. A constant impossible value is a dead channel, so it is excluded by name with that reason. It also identifies the -242.1 that BLOCKERS.md and THRESHOLDS.md both listed as an unexplained deep negative: one channel, not on the converter rail lattice, not a sign fault. 853.3 is now the only one left. Nothing fires. Hottest core reading on the estate is 67.7 degC against a 125 degC warning, and the command reports `evaluated : 29 machines, 0 breaching` on application and `applied : 0, unchanged : 412` on a re-run. Five tests pin what keeps the row honest, including that the two families' patterns cannot both match a tag - overlap would make a point's limit depend on the order of entries in the file. Two corrections to what this branch committed earlier, both from adversarial review and both reproduced before being written down: - "PUMP5_SPEED = 474.06 rpm is a rail, not a speed" was too strong. It sits exactly on 32767 counts at scalar 80, with a relative error identical to the confirmed vibration rail - but 474.06 rpm is also a plausible instrument range, so "the converter saturated" and "the machine is at the top of its range" are not distinguishable from the value. Provable: it is on the boundary. Not provable: which that means. - "Pump 05's DCS instrumentation is fine, only its monitoring rack is dead" was wrong. Measured against the emulator over 539 consecutive snapshots, all 66 of its tags are distinct=1, including active power, discharge pressure and every winding RTD. The control settles it: stopped Pump 04, same station, same snapshots, varies on 45 of 66. The bay is frozen and its monitoring channels are additionally railed. The earlier note called the other readings "plausible and varied"; they vary across channels and not in time, which is not the same thing, and the error was not checking the time axis.
Four independent source classes - the OEM, project and regulatory documents, technical literature, and the standards themselves - each searched and then re-checked by a pass that re-downloaded every cited document and confirmed every quote in place. No angle produced a figure. The decisive negative is CAG's Kaleshwaram audit, which was the best candidate because it is public, detailed and quotes contract terms verbatim. It contains zero occurrences of insulation, temperature rise, class F, class B, CACW, CACA, IS 325, 60034, IS 5120, winding, stator, or even the bare word temperature. Twelve greps, 0/0 across both chapters. 125/145 stays derived rather than read. What the search did change: The assumption now has a statutory citation. CEA Construction Regulations r.37(2) (2010) and r.40(2)(a)(ii) (2022) require class F insulation with rise limited to class B for large vertical machines in a water powerhouse, and Maharashtra WRD and BHEL's own HT-motor specification say the same. That is three organisations quoting one long-standing Indian convention rather than three independent derivations, and the CEA applicability clause reaches generating and licensee companies rather than irrigation pumping stations - so it raises the assumption from a guess to the documented norm for this duty, and no further. The dangerous branch is weakened, not closed. BHEL's literature gives "Insulation System Class F/ H" and never mentions class B, but that is an argument from silence in a four-page flyer whose own range excludes both the 40 MW and 134 MW machines and which post-dates the supply. Class B - the case where 125/145 warns late - is unlikely by convention and not ruled out by evidence. Two questions retired by arithmetic. Table 9 item 1c reduces the permitted rise by any excess above 40 degC, so the design ambient does not move the ceiling and the ambient half of question 8 is withdrawn. Item 1d does the same for the water coolant datum. One trap worth more than a citation: BHEL states rise BY RESISTANCE (70 K, and 80 K over inlet cooling water), while the 125 here rests on the 85 K EMBEDDED DETECTOR column of Table 7. Different quantities. A plate figure read without its measurement method could move the band in the wrong direction. IS 12802 cl. 5.3 makes ETD mandatory by default for AC stator windings, which is what licenses the ETD column. And a correction to the ask itself. "One photograph answers four questions" was wrong: CAG places BHEL as supplier for Packages 6, 8, 10 and 11, while Medigadda, Annaram and Sundilla were let as separate contracts, so the OEM for Parvathi and Saraswati is unestablished in either direction - and those two carry 275 of the 307 armed winding points. The ask is now one plate per pump house, three in total, each covering only its own station. Useful consequence: the plate is required to carry the answer. IS/IEC 60034-1 cl. 10.2 item 8 obliges it to state the thermal class and, printed separately, the rise limit where that is lower. Dead ends are recorded so nobody repeats them, including that every apparently independent "43 machines / 40 MW" report traces to one MEIL press release.
users.tests.RuleSetModelTest.test_model_names has been failing on this branch: every database model must appear either in a ruleset or in the ignore list, and assets_ingestioncheckpoint appears in neither. It was added by migration 0012 and never registered. It goes in the ignore list, with the rest of the connector plumbing - assets_healthsource, assets_machinesignalbinding, assets_machinesignalstate, assets_machineanomaly and assets_healthevidencesnapshot are all there already. A checkpoint is a cursor position, a lease and a last error code; it has no user-facing CRUD and no role should grant it separately. Found because a reviewer needed the test to be green before proposing a new model, and ran a suite this branch's own work had not been running: assets, machine_health, repair and approvals were green throughout, and users was never in that set. The other two failures in users (OwnerModelTest display names) reproduce with this change reverted and are not related; users.test_migrations fails on a missing django_test_migrations dev dependency.
…thing The winding and core screens each read whole documents and threw away every tag but one family. Each document carries all ~900 tags, so surveying every bound channel costs the same reads already being paid for: 1,386 of 1,452 channels, 78/77/17 documents across the three stations at a 3-hour stride over 238 hours. THE PROTECTION GAP. PH_2 /dex/PUMP2_PUMP_MOTOR_WINDING_TEMPERATURED9 reports the 3276.7 over-range marker in 63 of 75 samples - 84% of the time it is not measuring - and it carried a live 125/145. Now excluded. That is a defect in the screening rule, not one bad channel. apply_winding_thresholds skips pegged samples before counting and then asks only whether MIN_SAMPLES usable readings remain; it never asks what fraction of the total they are. A channel pegged five readings in six therefore passes as clean, and any family screened the same way inherits it. AN EXCLUSION DID NOT DISARM. Adding a channel to an exclude list skipped it and left whatever bounds it already carried, so the file could say a channel was disarmed while the database still held 125/145 - the one artefact that is supposed to be the authority on limits was authoritative in only one direction. Excluding now clears all six bounds and reports a disarmed count. Armed goes 412 to 411. Four tests pin it, including that a dry run reports the disarm without performing it, and that disarming one channel does not disarm the family. TWO BAYS DO NOT BEHAVE LIKE THEIR NEIGHBOURS. Constant-channel fraction over the same 75 samples in the same hall: Millbrook Pump 05 35/37 = 95% (the known frozen block, confirmed from a second angle), Cedar Creek Pump 02 29/56 = 52% (new), against a healthy sibling at 4/56 = 7%. Pump 02 is not a whole-bay freeze: MOTOR_CORE_RTD1 through RTD4 move across 7-8 distinct values while RTD5 and RTD6 sit dead still, same bay, same family. Individual stuck detectors. Nineteen armed channels are among the frozen and are deliberately left armed. A frozen detector under-reports, so it risks a missed alarm rather than a nuisance one, and excluding it would not restore protection - it would only record that there is none. The hall drifts less than a kelvin in ten days, so stuck and genuinely stable cannot be separated at this stride. Flagged, not settled. Also recorded: ten channels reporting impossible temperatures (-242.1, -188.9, -161.6, -140.2 ...) and seventeen pegged outright, none armed yet, all of them exclusions the day a cooling family is armed. And a correction to my own first reading of the survey. The naive classifier called 174 channels dead and 57 signed; both were wrong. 58 of the "dead" are MOTOR_ON_STATUS and MOTOR_OFF_STATUS and 28 more are ACTIVE_POWER at 0.0, all correctly reporting a stopped bay, and 85 of the "signed" read between -5 and 0, which is transducer offset near zero rather than a fault. Counting either as broken would have overstated the problem threefold.
The range survey left nineteen armed channels frozen across the recorded window and could not say whether they were stuck detectors or genuinely stable ones in a hall that drifts less than a kelvin in ten days. A 3-hour stride cannot separate those. So the bay was walked densely: 232 hourly documents across the whole span plus 2,149 snapshots at the 5-second cadence inside three buckets, with Pump 01 read from the same documents as a control. It settles, and the pattern is worth more than the verdict. Core RTD 1-4 move across seven to eight distinct values and 5-6 do not; winding detectors 1-6 move across seven to nine and 7-11 do not. One distinct value across 2,381 readings while siblings on the same bay move in the same documents is not a stable detector. The control bay has 0 of 17 frozen in these two families. The frozen set is a contiguous high-index block, which points at one acquisition module rather than seven independent failures - a much cheaper thing for the plant to go and find. All seven are now excluded and disarmed. The bay keeps six working winding detectors, still at the six cl. 8.6.2 requires, so nothing real was lost. Armed goes 411 to 404. Millbrook Pump 05's twelve stay armed deliberately. That bay reads 95% constant including MOTOR_ON_STATUS, ACTIVE_POWER and its flow, so the evidence says one stale acquisition rather than twelve dead detectors, and excluding them would record twelve instrument faults that have not been shown to exist. THE SCREENER CAN NO LONGER ARM A CHANNEL THAT IS NOT REPORTING. It counts what a channel offered alongside what was usable and requires the ratio to clear MIN_REPORTING_FRACTION. The floor is 0.5 and it is not fitted: across all 424 winding and core channels the distribution is bimodal with an empty middle - 416 report on every sample, one on 73 of 74, seven on 16% or less - so any floor between 0.2 and 0.95 separates them identically, and the one chosen is the one that can be said in words. Applied to this estate it reproduces the committed exclusion list exactly, which is the check that it neither over- nor under-fires. Two test corrections. The dead-channel test unpacked a single-element exclusion list, so it failed on the next discovery rather than on a defect; it now looks the entry up by key. And a new test requires every exclusion reason to contain a number from the channel's own history - "looks wrong" is an opinion, "-242.1 in 75 of 75 samples" is evidence, and the next person deciding whether to re-arm has only that sentence to work from. A near-miss worth recording: the two PUMP2_..._TEMPERATURED9 exclusions are not a duplicate. One is PH_2, pegged five readings in six; the other is PH_3, frozen. Same tag name, different station, different fault. That is what station-scoped exclusions are for, and this is the first time the scoping has caught anything.
The request said "any machine will do - they are identical". They are not, and the public procurement record is why: CAG places BHEL as the pump and motor supplier for Packages 6, 8, 10 and 11, while the Medigadda, Annaram and Sundilla lifts were let as separate contracts. So the OEM for Parvathi and Saraswati is unestablished in either direction, and those two carry 301 of the 404 armed points. A plate from one house tells us nothing reliable about another. The message now asks for one plate per pump house and says plainly not to substitute. It also asks for something the earlier version missed: the MEASUREMENT METHOD alongside the rise. BHEL's published specifications state rise by resistance, and the 125 degC here rests on the embedded-detector column of Table 7 - a mean winding temperature and a hot-spot reading are different quantities, and a plate figure adopted without its method would move the band in an unknown direction. It tells the plant the information is required to be on the plate by IS/IEC 60034-1's marking clause, so the request cannot come back empty, and it offers the O&M data sheet as a fallback where a plate is unreachable or weathered. Two questions are deliberately NOT in the message. Whether the rise is referred to the primary or secondary coolant does not move the ceiling (Table 9 item 2), and neither does the design ambient (Table 9 item 1c). Both were on the ask list until the arithmetic retired them, and asking anyway would spend the plant's goodwill on numbers we have proved we do not need. The Ranganayaka note stopped arguing for a second photograph, which the new request already covers, and now records what is actually useful about that station: it is the only one of the three the record does place with BHEL, so it is where the house practice has the best claim - and simultaneously the machine running on the most borrowed reasoning, since its 32 winding points carry a band derived from an assumption about a different machine at a different rating.
Twenty cached readings sat at a signed-16-bit converter rail and were displayed as good measurements: a valve position of -118.5%, three field voltages at -592.6 V, fifteen vibration channels at the two-complement floor or ceiling. _coerce now marks them BAD exactly as it marks 3276.7 - which is the same converter saturating at 0.1 scaling - keeping the value, because "saturated" and "zero" are different facts about a plant. Migration 0018 applies the rule to what was already cached, mirroring 0017. That is not optional here: all three checkpoints sit at the end of a fully consumed recorded window, which is also what read_ceiling returns, so every poll reads zero documents and nothing is ever re-ingested. Without the migration the rule would have changed nothing at all. It marked 20 rows. None of the affected bindings carries a transform, so the cached value is the same number _coerce sees and the two predicates test the same thing. THE JUSTIFICATION IS NOT THE ONE OVER_RANGE USES, and getting that wrong is what sank two previous designs. 3276.7 argues that no real channel reaches it. Here that argument is unavailable: this repo's own recorded decision of 2026-09-26 approved the vibration channels as "raw, unitless source values ... may be signed", precisely because 10-34% of their readings are negative. Negative is documented normal for that family. What is defended instead is arithmetic, and it was measured rather than assumed. Across all 1,305 numeric cached readings exactly 20 sit within 6.9e-8 relative of a rail, and the nearest reading that does not is 9.7e-4 away - a margin of about 14,000x. The tolerance sits two orders of magnitude above the worst true hit and two below the nearest miss. The scalar list is closed on purpose. With a free scalar the predicate is satisfiable by almost anything: the negative anchor is within 1.7e-8 of 1600/27, so an open rule with a generous cap matches every multiple of 1600 and marks real readings bad. A short enumerated list is the only form a human can agree to, and each entry is there because a reading was found on it. x8 is deliberately excluded and the comment says so. PUMP5_SPEED sits at exactly +32767 counts on that scaling with a residual as small as any confirmed rail, but 474 rpm is also a plausible instrument range, so saturation and a machine at the top of its range cannot be told apart from the value - and it is the only speed reading on the estate's only running bay. That needs better evidence than this. Cost, measured rather than estimated: 0 armed bindings lose a reading, so no limit is affected and no protection is lost. Exactly one group empties - Millbrook Pump 05's five vibration channels, on the bay whose entire block is frozen anyway. That consequence is why this change was declined once; it is now paid knowingly, against 20 readings that were being presented as measurements. Six tests pin it, including the one-count gap between the anchors - the signature that identifies a rail pair rather than two unrelated constants - and a near-miss winding temperature of 59.2 degC staying GOOD against a rule aimed at 59.2593.
…ot one
Two standards say a single detector is not an alarm. IEEE Std 3004.8-2016
cl. 8.5.2.2 recommends RTD voting so damaged and open-circuit inputs are
ignored, and API Std 670 cl. 5.4.6.4 makes dual voting standard where two
sensors share a bearing's load zone - while explicitly keeping single-violation
logic for every other configuration, which is why a null vote_minimum means no
voting rather than a default of two. THRESHOLDS.md has recorded this as a free
mitigation since the winding row landed. With 11-12 winding detectors per bay on
one band, a single failed input would otherwise open a critical alarm about a
healthy machine.
IT DE-ESCALATES; IT DOES NOT SUPPRESS, and that distinction is the design. A
stator hot spot in one slot is real and is exactly what an eleven-detector array
exists to catch, so silencing a lone detector to avoid nuisance trips would
discard the signal the standards are protecting. Two or more detectors past
critical raise the critical. One raises a warning whose evidence names the count
and the minimum and says to treat it as a possible sensor fault until a second
detector agrees.
That also corrects THRESHOLDS.md, which said a lone detector should be
"annunciated as a sensor fault". That is one reading too confident: asserting it
IS a sensor fault is as wrong as suppressing it. The message says it may be one.
A confirmed condition cannot be downgraded when a corroborating detector later
fails - record_anomaly never silently de-escalates - and a test pins it, because
a sensor dropping out is not a machine getting better.
THE GROUPING NEEDED A NEW FIELD, and the obvious candidates were checked first.
Every detector carries its own ParameterTemplate ("Motor Winding RTD 7"), so
templates give 404 groups of one. signal_kind is blank on all 404 bindings. And a
component pools winding with core detectors on 16 of 29 machines, so voting by
component would corroborate a winding breach with a core reading - two different
measurements. The group is therefore written onto the binding from the reviewed
limits file, which already names exactly these families, and is cleared both when
a channel is disarmed and when activation changes a point's meaning.
One hazard closed on the way: a minimum larger than the group makes CRITICAL
unreachable, which is a limit that looks armed and can never fire.
apply_signal_limits now warns per machine. This estate is clean - every group
holds at least four detectors - but that was luck rather than design, and the
next family armed may not be so lucky.
Seven tests, including that detectors in different groups do not vote for each
other, that a warning-level breach is untouched, and that with no minimum set the
single-violation behaviour is exactly what it was before this field existed.
The mimic collapsed every non-good reading into one bad_quality label. A channel pegged at the source's over-range marker, one sitting on a converter rail and one whose reading will not parse are three different things to go and look at, and the screen gave an operator the same word for all three. That cost most on the readings this branch had just spent a day identifying: the twenty rails coerced yesterday became twenty rows saying "Unusable quality". Millbrook Pump 09 is the case that shows it. Two railed vibration channels and one over-range winding detector now read as a railed pair and a pegged detector rather than as three identical labels. Verified on live data: PH_2 P5 shows six railed, P9 two railed and one over-range, PH_3 P2 two over-range. DERIVED AT PROJECTION, NOT STORED, and the choice matters. A reason written onto the state row at ingest records whichever version of the rule was running then; a derived one is always the current rule's answer. That is the same argument that made migration 0018 necessary in the first place - a verdict cached under an old rule is a verdict nobody can trust. ONE PREDICATE, NOT TWO. _pegged and _railed are private, and importing private names across modules is how a projection drifts from the coercion it is supposed to agree with. So pumphouse_payload gains a public unusable_reason(), _coerce asks it too, and a test pins that the mimic's answer is the same function's - not merely the same today. The frontend needed the matching labels. reasonLabel falls back to "Unavailable" for an unknown code, so shipping the backend half alone would have made the screen LESS informative than the single bad_quality it replaced: over_range, railed and not_finite are now named. One behaviour corrected on the way: a non-finite number reached the same bad_quality label as everything else, and now says not_finite. It is the one case in this set that is a parsing fact rather than a plant fact, and worth telling apart.
Raising and clearing are not symmetric and the detector treated them as if they were. A breach that turns out to be transient costs somebody a look; a clear that turns out to be transient closes a real condition and nobody looks again. The clear side now has hysteresis: a signal must read inside its limits for five minutes before the condition closes. MEASURED ON THE PLANT'S CLOCK, AND THAT IS THE WHOLE OF THE FIX. MachineSignalState holds one row per binding, so a poll applying up to MAX_DOCUMENTS_PER_STATION = 200 snapshots five seconds apart - about seventeen minutes of plant time - evaluates exactly once, against the last of them. A winding above its critical limit for 199 of those 200 samples that dips below on the last one would close a standing critical, while the poller still held the 199 contrary samples in memory. A delay on the server clock would not help: one evaluation is one evaluation however long the poll took. Measured on observed_at the clearing reading is five seconds newer than the last breach, the gate holds, and the condition survives its own catch-up. A test pins exactly that - an hour passes on the server, the plant moves five seconds, the anomaly stays open. Five minutes because it is already this estate's validity window, the same figure assets.activation._initial_cursor enters a live source at. A condition with no clearing reading still closes immediately - binding gone, threshold removed, signal stopped. The gate needs a reading to measure from, and holding those open would make them unclosable, which is the failure the two resolution notes exist to avoid. THREE EXISTING TESTS CHANGED, and they are named here rather than quietly edited. Each asserted that a recovery resolves its anomaly while writing the breach and the clear at the SAME plant instant - a zero-second recovery, which is precisely what this gate refuses. They now carry a clearing timestamp past the window, which is what a recovery actually looks like: always later than the breach it ends. The fixtures got more realistic, but the behaviour they pinned did change. Not fixed here, and not claimed: evaluate_thresholds still has no freshness gate, so a station whose poller dies keeps its last cached verdict indefinitely. That is a separate failure with a separate shape.
Freshness cannot see a frozen acquisition. Timestamps advance on every poll whether or not the value moves, so a channel reporting punctually and saying the same thing for ever reads as perfectly current. Millbrook Pump 05 holds one value on 35 of its 37 channels across the whole recorded window - including its run status and its 24.5 MW - and nothing on the blade said so. MachineSignalState.value_changed_at now records when a signal last reported a different number, maintained at ingest for free off the payload_hash that was already being computed. The mimic shows it as "Unchanged for: 10 days" beside the reading. A MEASUREMENT, NOT A VERDICT, and the distinction is the whole design. "Constant" is correct for a great many channels: a stopped bay reports MOTOR_ON_STATUS 0 for ever and is right to. A per-channel rule calling every unchanging channel faulty would have fired on 58 status bits on its first run, which is the same error the range survey's first classifier made and I had to catch. The evidence that a bay is frozen is aggregate, and choosing that aggregate rule is what two rack-sentinel designs were refuted for. So the field reports the span and leaves the reading of it to somebody who knows the machine. Which turns out to be enough. Backfilled across the estate the field separates the bays on its own, with no threshold from anybody: Millbrook Pump 05, Cedar Creek Pump 02 and Maple Grove Pump 02 all sit at a median 9.92 days unchanged, against 0.04 days for every healthy bay - a 250x separation. It also surfaced a third bay, Maple Grove Pump 02, which the range survey recorded at 4 of 8 constant but never singled out because that bay carries so few channels. NO BACKFILL IN THE MIGRATION, deliberately. The honest value for a row cached before the field existed is unknown: the cache holds one reading, so nothing in the database says when it last differed. Writing observed_at would assert it changed on the most recent poll, which is false for precisely the frozen channels this exists to expose. backfill_value_changed --source <pk> walks the recorded window and sets it from the source instead - a command rather than a data migration because it needs the network, and a migration that cannot run offline blocks a deployment. It wrote 1,386 rows here. One correction to my own tests, recorded because the failure was instructive: the first version advanced the plant clock six hours past the present, and ingestion rejected every second reading as future-skewed (MAX_CLOCK_SKEW_SECONDS = 300). It looked exactly like the field not updating. The fixtures now run the clock backwards from the present, which is what a recorded window actually is.
…missing The bootstrap section never stated the thing an operator most needs to know before starting: every input the commands read is tracked in the repository and copied into the production image, so nothing is carried across by hand. It now lists each input, its path, and how it reaches production - and separately lists the four things that are NOT in the repository and must be supplied: the HealthSource row, the managed identity's Cosmos access, the enable setting, and a new image build. That last one is the trap. The files being in git is not the same as their being in the running container; an image built before the two COPY lines has neither directory. backfill_value_changed was missing from the sequence. It is now 14.3.7. Activation enters a recorded window five minutes before its end, so without the backfill the "Unchanged for" figure covers only that last slice, and a bay frozen for ten days would read as frozen for five minutes.
A rollout that carries migrations had no way to apply them. The server refuses to start with migrations pending (INVE-W8), and gunicorn preloads the app, so that refusal is the master's exit and ends the container: measured, exit code 1 after eight to ten seconds, three runs of three, no worker booted and the port never opened. There is no running container to exec into, so "deploy, then migrate" cannot be done in that order. init.sh now applies them itself when AIMMS_MIGRATE_ON_START is set, before the server is started: the lineage check, then migrate. Opt-in, for the web app, for the rollout that needs it. INVENTREE_AUTO_UPDATE would also migrate at start, but it does not ask whose database it is, it sets maintenance mode in that database before it migrates, and it starts the server even when a migration has failed. The lineage check is new. Two lines of this fork share migration numbers without sharing migrations - assets 0011 to 0016, part 0155 - and Django will apply one line's history beside the other's without complaint. The check refuses when this code has migrations to apply and the database already holds migrations it has no file for. Either half alone is ordinary: migrations to apply is this line's own rollout, and a database ahead of its image is what a rollback looks like, which has to be able to start. Rehearsed through the real start script on a throwaway copy of the local database: two pending migrations applied and the server answered; a copy rolled back to before the split took all eleven; a copy carrying the other line's 91 migration names was refused with exit 1 and no row written; and a copy one release ahead of the image started.
Section 13 is rewritten around what the image does rather than what it was assumed to do, and pinned to 11cec10. It could not migrate. The September text said to update the app and run migrate through exec once the revision was ready. With migrations pending the server exits at load, gunicorn preloads, and the container goes with it: five runs of five, development tree and built image. The rollout now sets AIMMS_MIGRATE_ON_START and reads the outcome from the log. It did not fit. The built image's server holds 546 MiB idle; the July export gives aimms-dev 512. Held to that, one showmigrations beside the server had not finished after five minutes and six workers were killed for memory, so the nine bootstrap commands of section 14 could not have run. The rollout raises the size first and settles at 1 GiB. It could not be rolled back as described. "Additive" is not enough: seven columns are NOT NULL with no database default, so an older image starts and reads but cannot create a machine or a binding. The seven defaults that close that are given, tried both ways on a copy. The pre-flight reads django_migrations instead of showmigrations, which only lists what the running image has files for. The divergence table says what the other line's 91 files are: 78 new, 13 squashes. Still not run against Azure. What was rehearsed, and on what, is listed.
Two ways a wrong alarm could be raised or a real one missed. A channel that stops reporting leaves its last number in the cache, and every poll judged that number again. Now a reading older than its source's freshness window - measured against the machine's newest good reading, on the plant's clock - is handled as an unusable one: it neither opens a condition nor closes one. A channel reporting the same number past that window is a different doubt and is not suppressed, since a stopped bay's status is rightly constant; the alarm says it instead, with the span. A reading arriving by webhook took whatever quality the sender claimed, "good" by default, so the 3276.7 over-range marker from that route would have been classified as a temperature. It is now judged by the rule the Cosmos path uses, from the same function, and can only be marked worse.
The station drawing was a sketch with three boxes over it and a row of yellow buttons underneath, P1 beside P10. It is now the station: forebay and level, suction and discharge headers, and every registered bay drawn between them in number order, in the colour of its state, and chosen by clicking it. Status codes are given in words; the layout says what each code means and an unknown one is shown as it came. The pump drawing is a vertical unit - motor, bearings, stool, shaft, casing, discharge valves - with shaft speed and discharge pressure added beside status, power and flow. Each of its thirteen physical parts is a numbered region keyed on the part's catalogue code, which is the one thing the three stations share, and a numbered entry summarising that part's readings with a bar per sensor. A part this pump has no readings for stays on the drawing and says so. Each pump page shows the same view under its own tab. The run of tables that followed is one line per system that opens into its table. The drawings are set into the page rather than shown as images, so they take the theme and a running pump can be green. The response serializer never listed unchanged_for_seconds, so the figure computed a week ago reached nobody. It does now, with the part code.
A pump page's trail was "Machines"; it is now Machines, then the station, each crumb keeping the open tab, so leaving a pump's Performance tab lands on the station's. The machine endpoint names a pump's station and its bay for that, read-only. The Installed Parts tab was empty for every pump and station: it read the hand-recorded parts table, which holds nothing for registered equipment, while the registry held 451 components for it. The tab now lists those, read-only and marked draft, with parts recorded by hand underneath only when there are any. Plain equipment is unchanged. Also wires the pump mimic tab into the machine page.
… takes it The mimic blanked any reading whose observation time was ahead of the server's at all, as "Source clock is ahead". Ingestion accepts the same reading as normal up to five minutes ahead, on the understanding that plant clocks run a little fast or slow of ours. On a plant whose PLC clock is a few seconds fast, every point on the mimic would have read as unknown while ingestion took them all without comment. Both sides now draw the line at the same place, MAX_CLOCK_SKEW_SECONDS. The page shows a small lead as no age rather than a negative one.
…e record An acknowledged anomaly was never resolved: the resolver declined to close a condition "on the operator's behalf", and nothing else writes RESOLVED. So it stayed in the machine's one active slot for that signal for ever, and the next real breach refreshed the old acknowledged row instead of raising an open alarm - a second event nobody was shown. The acknowledgement is a record that somebody saw the condition, not a claim that it is still there; the detector is the only thing that knows that. An acknowledged condition now closes by the same recovery rule as an open one, with who acknowledged it, when, and what they wrote left on the row, and a later breach is a new alarm.
… work The alarm chain - limit, vote, anomaly, page, acknowledgement - had never been seen end to end on this estate, because nothing in the recorded data breaches a limit, and the mimic's alarm table was a list of readings with nothing to do about them. Each alarm row now carries the anomaly the detector holds for it, in one query for the station and its pumps. On both mimics an alarm shows its state - open, acknowledged, or not raised yet while its vote group has not agreed - with an Acknowledge button that asks for a note, and a link to the Health tab where it lives. A refused acknowledgement says why, inline, and keeps the note. A new management command raises a real one on a chosen machine: a reading at the critical limit plus ten per cent, through the ordinary ingestion, on as many detectors as the vote needs, and the detector raises what it raises. --clear lets the detector close it by its own recovery rule and then puts the displaced rows back exactly as found; on a station shown on a shifted clock the recovery reading would otherwise sit five minutes in the future for ever. It refuses without --yes; the anomaly it leaves is marked as a test.
…the list An alarm was visible only to whoever happened to be looking at the page it was on. A critical condition on a pump at three in the morning was recorded, evaluated and drawn, and nobody was told. When a critical opens, or a warning is confirmed up to one, it now goes through the ordinary notification framework - the bell in the web app, and email where a mail host is configured - to every active user who holds the work_order role and a scope grant on the machine's client: the same two gates the Health tab enforces, and no others. Once per condition; warnings are not sent, since with provisional limits they would be a stream. The machine list carries each machine's open alarm count, criticals apart, and a station's count includes its pumps': the morning check is which stations have something to look at, and a station's own alarms are few.
… alarms on the index Every resolved anomaly was kept - how it ended, who acknowledged it, what they wrote - and nothing listed them. The Health tab now has a Past alarms table under the active ones: the maintenance record an audit asks for. The mimic's alarm row offers Create repair beside Acknowledge, the same intake the Health tab has, prefilled from the reading and raised against the anomaly so the two stay linked. The Machines index gets an Alarms column; a station reads "2 critical" when two of its pumps do.
…hour at most A false alarm had no way out: suppressed existed as a status and nothing set it. An alarm can now be dismissed with a required reason - for the limit set too tight rather than the machine. It leaves the active list, counts nowhere, lights nothing and tells nobody, and while the reading goes on breaching no second alarm is opened about it. It closes like any other when the reading recovers, so a dismissal is never a permanent silence. The next reader of the history can tell a wrong limit from an ignored one. A refresh used to replace an anomaly's metrics whole, which dropped the dismissal record and the readings a test alarm displaced; those marks are now carried over. A signal sitting on its limit re-opens as a new condition every few minutes; it is now announced at most once an hour. A user can switch the notifications off (NOTIFY_MACHINE_ALARMS). The email path is covered by a test that sends through the mail backend. The mimic reports the worst active alarm on each bay and on the station, so the drawing can carry it. The machine list's alarm counts can be sorted and filtered (has_alarms). test_alarm --clear also clears an alarm that was dismissed during the test.
…history on one clock A pump with a critical alarm sat on the station drawing as a calm grey idle bay. The bay now keeps the colour of what the pump is doing and gains a ring and a marker in the colour of its alarm, counted in the legend beside the states. An alarm row offers Dismiss beside Acknowledge and Create repair, through one note dialog for both: a note is optional to acknowledge and a reason is required to dismiss. The Health tab's anomaly cards offer it too, and lead to the mimic where the reading is drawn. Past alarms showed First observed on the presented clock beside Resolved on the server's, so an alarm on replayed history read as ending before it began. Both columns are now when the condition was observed, on one clock. The history can be searched and filtered by severity, says who acknowledged or dismissed each alarm, and links to the repair raised for it. A Machine Alarms widget can be added to the dashboard, the Machines list's Alarms column sorts and filters, and the alarm notifications switch sits under Settings > Notifications.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Redesigned the pump-station and pump mimics, and added end-to-end alarm handling: operators can acknowledge, dismiss with a reason, or raise a repair straight from an alarm, and critical alarms now send bell/email notifications. Alarms also show on the station drawing, the Machines list, a dashboard widget and a searchable past-alarm history. Everything is tested and pushed; next is deploying to the Azure dev app and getting alarm limits from the plant.