diff --git a/.github/workflows/fleet-converge.yml b/.github/workflows/fleet-converge.yml index 215877f5e03..8203255e088 100644 --- a/.github/workflows/fleet-converge.yml +++ b/.github/workflows/fleet-converge.yml @@ -775,7 +775,7 @@ jobs: WIF_ACCESS_TOKEN: ${{ steps.wif_auth.outputs.access_token }} FLEET_CONVERGE_EXPECTED_HOST: ${{ github.event.inputs.host }} if: github.event.inputs.mode == 'mtcollins1_boot' - timeout-minutes: 38 + timeout-minutes: 52 - name: Upload Mt. Collins unit 1 boot SOL capture and receipts id: mtcollins1_boot_receipt_upload uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f diff --git a/dag/extdeps/bmc/http.dag b/dag/extdeps/bmc/http.dag index 5179edd8abc..dc08069a020 100644 --- a/dag/extdeps/bmc/http.dag +++ b/dag/extdeps/bmc/http.dag @@ -4,7 +4,7 @@ import extdeps.external_authority { ExternalAuthority } import extdeps.uri { Uri, Https } import std.decl_ref { DeclarationRef, WholeDeclaration } import std.disposition { Disposition, RealizationDispatch, Scaffold } -import std.types { Bool, NonEmptyStr, Unit } +import std.types { Bool, Int, NonEmptyStr, Unit } import std.string_type { String } data extdeps_external_authority_anchor: ExternalAuthority = ExternalAuthority { uri: Uri { @@ -80,6 +80,14 @@ data redfish_http_hardwired_transport_note: String = "§3(b) declared debt: ever // on an unreachable host stdout is "\n000" and stderr is the only text naming the cause. A caller // that refuses on this op must refuse with stderr; refusing with the stdout blob refuses with // "\n000", which is typed but locates nothing. +// GetResourceByPath IS THE ONE READ THAT FOLLOWS A LINK THE SERVICE PUBLISHED. DSP0266 makes a +// resource's `@odata.id` and a collection's `Members@odata.nextLink` URIs the client follows as +// given, so the path is an input carried exactly, never assembled from an Id; its consumer +// (gunbc.machine_intake_mtcollins1_boot_diagnostic_bundle) admits only same-origin /redfish/v1/ +// paths before calling it, because the request presents a credential. It binds stderr and +// exit_code beside the body because curl exit 7 (connection refused or unreachable), 28 +// (timeout) and 22 with "error: 401" (authentication refused) are different diagnoses, and it +// takes --max-time as an input so the caller's deadline and the transport's bound are one value. service redfish.Http { operation GetServiceRoot { @@ -315,4 +323,22 @@ service redfish.Http { nonzero => String "redfish system reset POST failed" } } + + operation GetResourceByPath { + input { bmc_host: NonEmptyStr, netrc_file: NonEmptyStr, odata_path: NonEmptyStr, max_seconds: NonEmptyStr } + output { + body: String from "stdout", + transport_stderr: String from "stderr", + exit_code: Int from "exit_code", + success: Bool from "exit_success", + } + readonly + transport shell { + argv: ["curl", "--fail-with-body", "-sS", "-k", "--connect-timeout", "5", "--max-time", "{max_seconds}", "--netrc-file", "{netrc_file}", "https://{bmc_host}{odata_path}"] + } + exit { + 0 => Unit + nonzero => String "redfish resource GET failed" + } + } } diff --git a/dag/extdeps/bmc/ipmi.dag b/dag/extdeps/bmc/ipmi.dag index 431469f838b..04bf8a0564b 100644 --- a/dag/extdeps/bmc/ipmi.dag +++ b/dag/extdeps/bmc/ipmi.dag @@ -3,7 +3,7 @@ module extdeps.bmc.ipmi import extdeps.external_authority { ExternalAuthority } import extdeps.uri { Uri, Https } -import std.types { Bool, NonEmptyStr, Unit } +import std.types { Bool, Int, NonEmptyStr, Unit } import std.string_type { String } data extdeps_external_authority_anchor: ExternalAuthority = ExternalAuthority { uri: Uri { @@ -58,6 +58,14 @@ data extdeps_external_authority_anchor: ExternalAuthority = ExternalAuthority { // THIS PROSE SITS ABOVE THE SERVICE AND NOT BESIDE EACH OPERATION because §4c admits annotations at // module-item grain only; a `//` block inside a declaration body is a hard error, which is how the // first draft of these operations was caught. +// SelListAuthenticated IS SelList WITH A CREDENTIAL, FOR THE SAME REASON SdrTypeList IS SdrList +// WITH ONE: every controller in this fleet refuses an unauthenticated session, and changing what +// SelList means would silently change its existing readers. It binds stderr and exit_code because +// its consumer (gunbc.machine_intake_mtcollins1_boot_diagnostic_bundle) records WHY a read failed, +// and it runs under coreutils `timeout` (extdeps.tools.gnu_coreutils timeout_command's argv shape, +// --kill-after included; exit 124 on expiry) with the caller's bound, so a controller that does not +// answer is a bounded reading, not a hung step, whatever ipmitool's own retry schedule is. +// // SdrTypeList IS THE AUTHENTICATED, TYPE-SELECTED READ, AND IT EXISTS BECAUSE SdrList COULD NOT BE // USED. The three original readonly operations carry no credential, which the asymmetry paragraph // above already records as a real gap; every controller in this fleet now requires one, so a sensor @@ -115,6 +123,22 @@ service diagnostic.ipmi.Tool { } } + operation SelListAuthenticated { + input { bmc_host: NonEmptyStr, username: NonEmptyStr, password_file: NonEmptyStr, deadline: NonEmptyStr, kill_after: NonEmptyStr } + output { + stdout: String from "stdout", + transport_stderr: String from "stderr", + exit_code: Int from "exit_code", + success: Bool from "exit_success", + } + readonly + transport shell { argv: ["timeout", "--kill-after", "{kill_after}", "{deadline}", "ipmitool", "-H", "{bmc_host}", "-I", "lanplus", "-U", "{username}", "-f", "{password_file}", "sel", "elist"] } + exit { + 0 => Unit + nonzero => String "ipmitool authenticated sel elist failed" + } + } + operation ChassisBootDev { input { bmc_host: NonEmptyStr, username: NonEmptyStr, password_file: NonEmptyStr, device: NonEmptyStr } output { stdout: String from "stdout", success: Bool from "exit_success" } diff --git a/dag/extdeps/bmc/redfish_memory_inventory.dag b/dag/extdeps/bmc/redfish_memory_inventory.dag new file mode 100644 index 00000000000..f351e89d77b --- /dev/null +++ b/dag/extdeps/bmc/redfish_memory_inventory.dag @@ -0,0 +1,448 @@ +module extdeps.bmc.redfish_memory_inventory + +import std.types { Int, List, NonEmptyStr, String } +import std.decl_ref { DeclarationRef, WholeDeclaration } +import std.goal_assessment { ObservationAttempt, ObservationEstablished, ObservationRefused } +import extdeps.external_authority { ExternalAuthority, ExternalModelScope, ExternalSubjectRef } +import extdeps.uri { Uri, Https } +import extdeps.languages.json.emit { JsonValue, JsonArray } +import extdeps.languages.json.parse { + parse_json_document, JsonDocumentParsed, JsonDocumentUnreadable, json_document_gap_text, + FieldAbsent, FieldRead, FieldMalformed, + json_field, json_field_string, json_field_int, +} + +// THE PER-SLOT AND PER-SOCKET INVENTORY THAT A REDFISH SERVICE PUBLISHES UNDER A ComputerSystem, +// modeled from DMTF's published schemas: Memory (the `Memory` resource and its `MemoryLocation` +// object), Processor, and the Resource schema's `Status` object (`State`, `Health`). The property +// names are DMTF's, kept verbatim. This module carries what the SCHEMA says a member is. What a +// particular controller was OBSERVED to return is a receipt in the observing layer +// (gunbc.machine_intake_mtcollins1_boot_diagnostic_bundle), never a row here. +// +// WHAT THIS MODULE HAS NOT READ (DESIGN section 4d). No response from mtcollins1's MegaRAC +// Memory or Processors collection exists in this corpus, so nothing here claims which optional +// properties that firmware populates, what its member ids look like, or whether it lists an +// unpopulated slot as a member with State Absent or leaves it out. Every optional property +// therefore parses to an explicit "not reported" value, and a controller that omits unpopulated +// slots produces a shorter member list, which the consumer reports as a count rather than +// reading it as "all present". +// +// WHY THIS IS A MODULE OF ITS OWN AND NOT MORE FIELDS ON extdeps.bmc.types. That module's +// RedfishMemorySummary and RedfishProcessorSummary are the ComputerSystem's AGGREGATE +// properties (MemorySummary, ProcessorSummary). The member resources are different schemas with +// their own citations, and a per-slot fact cannot be derived from a total. +data extdeps_external_authority_anchor: ExternalAuthority = ExternalAuthority { + uri: Uri { + scheme: Https + locator: "redfish.dmtf.org/schemas/v1/Memory.json" + } +} + +data redfish_processor_schema_authority: ExternalAuthority = ExternalAuthority { + uri: Uri { + scheme: Https + locator: "redfish.dmtf.org/schemas/v1/Processor.json" + } +} + +data redfish_resource_schema_authority: ExternalAuthority = ExternalAuthority { + uri: Uri { + scheme: Https + locator: "redfish.dmtf.org/schemas/v1/Resource.json" + } +} + +data extdeps_model_scope: ExternalModelScope = ExternalModelScope { + subject: ExternalSubjectRef { + declaration: DeclarationRef { + module_path: "extdeps.bmc.redfish_memory_inventory", + decl_name: "RedfishMemoryMember", + field: WholeDeclaration + } + }, + first_citation: extdeps_external_authority_anchor, + further_citations: [redfish_processor_schema_authority, redfish_resource_schema_authority] +} + +// Resource.State, as the Resource schema enumerates it. A rendering outside the enumeration is +// carried as StateUnrecognized rather than mapped onto the nearest known value, and an absent or +// null `State` is StateNotReported. Neither is read as Enabled. +type RedfishResourceState + = StateEnabled + | StateDisabled + | StateStandbyOffline + | StateStandbySpare + | StateInTest + | StateStarting + | StateAbsent + | StateUnavailableOffline + | StateDeferring + | StateQuiesced + | StateUpdating + | StateQualified + | StateDegraded + | StateUnrecognized { rendering: NonEmptyStr } + | StateNotReported + +// Resource.Health: OK, Warning, Critical. +type RedfishHealth + = HealthOk + | HealthWarning + | HealthCritical + | HealthUnrecognized { rendering: NonEmptyStr } + | HealthNotReported + +type RedfishResourceStatus { + state: RedfishResourceState + health: RedfishHealth +} + +// Memory.MemoryLocation: Socket, MemoryController, Channel, Slot (all integers in the schema). +type RedfishMemoryLocation { + socket: Int? + memory_controller: Int? + channel: Int? + slot: Int? +} + +// One Memory member. `Id` is required by the schema. `DeviceLocator` is the printed silkscreen +// label and is deprecated in later schema versions in favour of `Location`; it is kept because it +// is what a MegaRAC-era service most plausibly populates, and it is carried as a reading, not +// inferred. +type RedfishMemoryMember { + id: NonEmptyStr + device_locator: String? + memory_location: RedfishMemoryLocation? + capacity_mib: Int? + status: RedfishResourceStatus +} + +// One Processor member. Processor.Socket is a STRING in the schema ("the socket or location of +// the processor"), so it is carried as the controller's rendering and never parsed into an index. +type RedfishProcessorMember { + id: NonEmptyStr + socket: String? + total_cores: Int? + status: RedfishResourceStatus +} + +fn redfish_resource_state_of_wire(s: String) -> RedfishResourceState { + if s == "Enabled" { StateEnabled } + else if s == "Disabled" { StateDisabled } + else if s == "StandbyOffline" { StateStandbyOffline } + else if s == "StandbySpare" { StateStandbySpare } + else if s == "InTest" { StateInTest } + else if s == "Starting" { StateStarting } + else if s == "Absent" { StateAbsent } + else if s == "UnavailableOffline" { StateUnavailableOffline } + else if s == "Deferring" { StateDeferring } + else if s == "Quiesced" { StateQuiesced } + else if s == "Updating" { StateUpdating } + else if s == "Qualified" { StateQualified } + else if s == "Degraded" { StateDegraded } + else if s == "" { StateNotReported } + else { StateUnrecognized { rendering: s as NonEmptyStr } } +} + +fn redfish_resource_state_wire(state: RedfishResourceState) -> String { + match state { + StateEnabled => "Enabled" + StateDisabled => "Disabled" + StateStandbyOffline => "StandbyOffline" + StateStandbySpare => "StandbySpare" + StateInTest => "InTest" + StateStarting => "Starting" + StateAbsent => "Absent" + StateUnavailableOffline => "UnavailableOffline" + StateDeferring => "Deferring" + StateQuiesced => "Quiesced" + StateUpdating => "Updating" + StateQualified => "Qualified" + StateDegraded => "Degraded" + StateUnrecognized { rendering: r } => concat("unrecognized:", r as String) + StateNotReported => "not-reported" + } +} + +fn redfish_health_of_wire(s: String) -> RedfishHealth { + if s == "OK" { HealthOk } + else if s == "Warning" { HealthWarning } + else if s == "Critical" { HealthCritical } + else if s == "" { HealthNotReported } + else { HealthUnrecognized { rendering: s as NonEmptyStr } } +} + +fn redfish_health_wire(health: RedfishHealth) -> String { + match health { + HealthOk => "OK" + HealthWarning => "Warning" + HealthCritical => "Critical" + HealthUnrecognized { rendering: r } => concat("unrecognized:", r as String) + HealthNotReported => "not-reported" + } +} + +type RedfishStringRead = RedfishStringOk { value: String } | RedfishStringBad { cause: NonEmptyStr } + +fn redfish_optional_string(obj: JsonValue, key: String) -> RedfishStringRead { + match json_field_string(obj: obj, key: key) { + FieldAbsent => RedfishStringOk { value: "" } + FieldRead { value: v } => RedfishStringOk { value: v } + FieldMalformed { cause: c } => RedfishStringBad { cause: c as NonEmptyStr } + } +} + +fn redfish_optional_int(obj: JsonValue, key: String) -> ObservationAttempt { + match json_field_int(obj: obj, key: key) { + FieldAbsent => ObservationEstablished { observed: none } + FieldRead { value: n } => ObservationEstablished { observed: Present { value: n } } + FieldMalformed { cause: c } => ObservationRefused { cause: c as NonEmptyStr } + } +} + +fn redfish_status_of(obj: JsonValue) -> ObservationAttempt { + match json_field(obj: obj, key: "Status") { + FieldAbsent => ObservationEstablished { observed: RedfishResourceStatus { state: StateNotReported, health: HealthNotReported } } + FieldMalformed { cause: c } => ObservationRefused { cause: c as NonEmptyStr } + FieldRead { value: status } => + match redfish_optional_string(obj: status, key: "State") { + RedfishStringBad { cause: c } => ObservationRefused { cause: c } + RedfishStringOk { value: state } => + match redfish_optional_string(obj: status, key: "Health") { + RedfishStringBad { cause: c } => ObservationRefused { cause: c } + RedfishStringOk { value: health } => + ObservationEstablished { observed: RedfishResourceStatus { + state: redfish_resource_state_of_wire(s: state), + health: redfish_health_of_wire(s: health), + } } + } + } + } +} + +fn redfish_document(body: String) -> ObservationAttempt { + match parse_json_document(s: body) { + JsonDocumentParsed { value: v } => ObservationEstablished { observed: v } + JsonDocumentUnreadable { gap: g } => ObservationRefused { cause: concat("response is not a JSON document: ", json_document_gap_text(gap: g)) as NonEmptyStr } + } +} + +// A RESOURCE LINK, KEPT EXACTLY AS THE SERVICE PUBLISHED IT. DSP0266 makes `@odata.id` the +// resource's URI and a collection's `Members@odata.nextLink` the URI of its next page; neither is +// reconstructed from an Id or a last segment. It is admitted only when it is a same-origin +// service path -- "/redfish/v1/..." with no scheme, no authority, no dot segment and no fragment -- +// because the request that follows it presents a credential, and a link that could name another +// host would carry that credential there. +type RedfishLinkReading + = RedfishLinkSameOrigin { path: NonEmptyStr } + | RedfishLinkRefused { cause: NonEmptyStr } + +fn redfish_same_origin_link(link: String) -> RedfishLinkReading { + if !starts_with(s: link, prefix: "/redfish/v1/") { + RedfishLinkRefused { cause: concat("link is not a same-origin /redfish/v1/ path: ", link) as NonEmptyStr } + } else if string_contains(s: link, pattern: "//") || string_contains(s: link, pattern: "/../") || ends_with(s: link, suffix: "/..") + || string_contains(s: link, pattern: "#") || string_contains(s: link, pattern: " ") || string_contains(s: link, pattern: "\\") { + RedfishLinkRefused { cause: concat("link carries a segment a same-origin path may not: ", link) as NonEmptyStr } + } else { + RedfishLinkSameOrigin { path: link as NonEmptyStr } + } +} + +// ONE PAGE OF A RESOURCE COLLECTION (DSP0266, "Resource collections"): its `Members` links, +// `Members@odata.count` (the total across every page), and `Members@odata.nextLink` when more +// pages follow. A page without a `Members` array is refused: an absent array is not an empty +// collection. The links are carried as published; whether they are same-origin is decided by the +// consumer that will follow them. +type RedfishCollectionPage { + member_links: List + member_count: Int? + next_link: String? +} + +fn redfish_collection_page_of(body: String) -> ObservationAttempt { + match redfish_document(body: body) { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: doc } => + match redfish_optional_int(obj: doc, key: "Members@odata.count") { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: total } => + match redfish_optional_string(obj: doc, key: "Members@odata.nextLink") { + RedfishStringBad { cause: c } => ObservationRefused { cause: c } + RedfishStringOk { value: next } => + match json_field(obj: doc, key: "Members") { + FieldAbsent => ObservationRefused { cause: "collection page carries no Members array" } + FieldMalformed { cause: c } => ObservationRefused { cause: c as NonEmptyStr } + FieldRead { value: members } => + match members { + JsonArray { elements: elements } => { + let empty: List = [] + let initial: ObservationAttempt, NonEmptyStr> = ObservationEstablished { observed: empty } + let links = fold(elements, init: initial, f: (acc, member) => match acc { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: ls } => + match redfish_optional_string(obj: member, key: "@odata.id") { + RedfishStringBad { cause: c } => ObservationRefused { cause: c } + RedfishStringOk { value: link } => + if link == "" { ObservationRefused { cause: "a collection member carries no @odata.id" } } + else { ObservationEstablished { observed: concat(ls, [link]) } } + } + }) + match links { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: ls } => + ObservationEstablished { observed: RedfishCollectionPage { member_links: ls, member_count: total, next_link: optional_text(s: next) } } + } + } + _ => ObservationRefused { cause: "Members is not an array" } + } + } + } + } + } +} + +// A ComputerSystem's links to its Memory and Processors collections (ComputerSystem schema +// properties `Memory` and `Processors`, each a link object carrying `@odata.id`). A system that +// publishes neither link has published no per-slot inventory. +type RedfishSystemInventoryLinks { + memory: String? + processors: String? +} + +fn redfish_link_property(doc: JsonValue, key: String) -> ObservationAttempt { + match json_field(obj: doc, key: key) { + FieldAbsent => ObservationEstablished { observed: none } + FieldMalformed { cause: c } => ObservationRefused { cause: c as NonEmptyStr } + FieldRead { value: link } => + match redfish_optional_string(obj: link, key: "@odata.id") { + RedfishStringBad { cause: c } => ObservationRefused { cause: c } + RedfishStringOk { value: v } => ObservationEstablished { observed: optional_text(s: v) } + } + } +} + +fn redfish_system_inventory_links_of(body: String) -> ObservationAttempt { + match redfish_document(body: body) { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: doc } => + match redfish_link_property(doc: doc, key: "Memory") { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: memory } => + match redfish_link_property(doc: doc, key: "Processors") { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: processors } => + ObservationEstablished { observed: RedfishSystemInventoryLinks { memory: memory, processors: processors } } + } + } + } +} + +fn redfish_memory_location_of(obj: JsonValue) -> ObservationAttempt { + match json_field(obj: obj, key: "MemoryLocation") { + FieldAbsent => ObservationEstablished { observed: none } + FieldMalformed { cause: c } => ObservationRefused { cause: c as NonEmptyStr } + FieldRead { value: loc } => + match redfish_optional_int(obj: loc, key: "Socket") { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: socket } => + match redfish_optional_int(obj: loc, key: "MemoryController") { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: controller } => + match redfish_optional_int(obj: loc, key: "Channel") { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: channel } => + match redfish_optional_int(obj: loc, key: "Slot") { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: slot } => + ObservationEstablished { observed: Present { value: RedfishMemoryLocation { + socket: socket, memory_controller: controller, channel: channel, slot: slot, + } } } + } + } + } + } + } +} + +fn redfish_member_id(doc: JsonValue) -> ObservationAttempt { + match redfish_optional_string(obj: doc, key: "Id") { + RedfishStringBad { cause: c } => ObservationRefused { cause: c } + RedfishStringOk { value: id } => + if id == "" { ObservationRefused { cause: "member carries no Id, which the schema requires" } } else { ObservationEstablished { observed: id as NonEmptyStr } } + } +} + +fn optional_text(s: String) -> String? { + if s == "" { none } else { Present { value: s } } +} + +fn redfish_memory_member_of(body: String) -> ObservationAttempt { + match redfish_document(body: body) { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: doc } => + match redfish_member_id(doc: doc) { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: id } => + match redfish_optional_string(obj: doc, key: "DeviceLocator") { + RedfishStringBad { cause: c } => ObservationRefused { cause: c } + RedfishStringOk { value: locator } => + match redfish_memory_location_of(obj: doc) { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: location } => + match redfish_optional_int(obj: doc, key: "CapacityMiB") { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: capacity } => + match redfish_status_of(obj: doc) { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: status } => + ObservationEstablished { observed: RedfishMemoryMember { + id: id, device_locator: optional_text(s: locator), memory_location: location, + capacity_mib: capacity, status: status, + } } + } + } + } + } + } + } +} + +fn redfish_processor_member_of(body: String) -> ObservationAttempt { + match redfish_document(body: body) { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: doc } => + match redfish_member_id(doc: doc) { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: id } => + match redfish_optional_string(obj: doc, key: "Socket") { + RedfishStringBad { cause: c } => ObservationRefused { cause: c } + RedfishStringOk { value: socket } => + match redfish_optional_int(obj: doc, key: "TotalCores") { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: cores } => + match redfish_status_of(obj: doc) { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: status } => + ObservationEstablished { observed: RedfishProcessorMember { + id: id, socket: optional_text(s: socket), total_cores: cores, status: status, + } } + } + } + } + } + } +} + +// A RESOURCE'S OWN `@odata.id`, as it returned it. DSP0266 makes this the resource's URI, so a +// consumer that followed a link can check that the resource answering is the one the link named. +fn redfish_resource_odata_id(body: String) -> ObservationAttempt { + match redfish_document(body: body) { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: doc } => + match redfish_optional_string(obj: doc, key: "@odata.id") { + RedfishStringBad { cause: c } => ObservationRefused { cause: c } + RedfishStringOk { value: v } => + if v == "" { ObservationRefused { cause: "resource carries no @odata.id" } } else { ObservationEstablished { observed: v as NonEmptyStr } } + } + } +} diff --git a/dag/extdeps/tools/coreutils_stat.dag b/dag/extdeps/tools/coreutils_stat.dag index 31b822a35de..6bc7566410d 100644 --- a/dag/extdeps/tools/coreutils_stat.dag +++ b/dag/extdeps/tools/coreutils_stat.dag @@ -37,6 +37,11 @@ data extdeps_external_authority_anchor: ExternalAuthority = ExternalAuthority { // make one unreadable half destroy the other. It is also the shape this module's sibling // extdeps.tools.stat already commits to: one token per probe. // +// %s IS THE FILE'S SIZE IN BYTES (st_size), which is the only byte count a caller holding the +// content as a String can get: a String's length counts Unicode scalar values, and a SOL capture is +// not ASCII-only (it carries NUL and whatever the firmware emits), so counting characters and +// calling them bytes would under-read multi-byte content. The digits are parsed by the consumer. +// // %a IS THE ACCESS BITS IN OCTAL WITH NO INTERPRETATION. extdeps.access.posix owns what those digits // MEAN and reads them back through file_mode_of_octal_text; PathMode's whole job is to fetch the // spelling. @@ -55,6 +60,20 @@ service coreutils.Stat { } } + operation PathSize { + input { path: NonEmptyStr } + output { + size_text: String from "stdout" + success: Bool from "exit_success" + } + readonly + transport shell { argv: ["stat", "-c", "%s", "--", "{path}"] } + exit { + 0 => Unit + nonzero => String "stat could not read the path" + } + } + operation PathMode { input { path: NonEmptyStr } output { diff --git a/dag/gunbc/fleet/fleet_converge_workflow.dag b/dag/gunbc/fleet/fleet_converge_workflow.dag index e7ae492c565..bfccaeb5de4 100644 --- a/dag/gunbc/fleet/fleet_converge_workflow.dag +++ b/dag/gunbc/fleet/fleet_converge_workflow.dag @@ -416,6 +416,11 @@ fn fleet_converge_any_mode_step_if(modes: List) -> St // BMC, authorized by that same credential file via -f. THE SOL SESSION IS CARRIED BY IPMI TO THE // BMC, not by an ssh channel to the host, so it presents the BMC credential and never an // identity from the agent; +// - extdeps.bmc.ipmi Tool.SelListAuthenticated and extdeps.bmc.http redfish.Http +// GetSystemsCollection/GetMemoryCollection/GetMemory/GetProcessorCollection/GetProcessor, the +// readonly reads of gunbc.machine_intake_mtcollins1_boot_diagnostic_bundle -- the same BMC +// credential, by -f for ipmitool and through a per-attempt gunbc.auth.netrc_binding netrc, +// shredded on every path, for curl; // - extdeps.tools.env shell.Env.Get, extdeps.tools.sleep Delay.Seconds, extdeps.clock Clock.Now -- // no credential. // - AND, SINCE CENSUS STAGE 0D, gunbc.machine_intake_mtcollins1_census_medium_readback diff --git a/dag/gunbc/machine_intake/ampere_dram_console_observation.dag b/dag/gunbc/machine_intake/ampere_dram_console_observation.dag new file mode 100644 index 00000000000..7be58e6b574 --- /dev/null +++ b/dag/gunbc/machine_intake/ampere_dram_console_observation.dag @@ -0,0 +1,313 @@ +module gunbc.machine_intake_ampere_dram_console_observation + +import std.types { Bool, Int, List, NonEmptyStr, String } +import std.algebra { trim } +import v2.std.optional { Present } + +// WHAT THE AMPERE DRAM FIRMWARE PRINTED ON THE SERIAL CONSOLE DURING ONE BOOT, as an observation +// receipt of this repository. It is not an upstream fact: Ampere publishes no specification of these +// lines that this corpus has read. The grammar is TRANSCRIBED FROM TWO CAPTURES, the mtcollins1 SOL +// captures of fleet-converge runs 35801475989 and 35793279839 (artifact mtcollins1-boot-receipts), +// whose bytes the witness carries verbatim. The block has this shape: +// +// NOTICE: DRAM FW version 210525 starts a block +// CP: 0ff00900 unindented lines between subsections belong to no subsection +// MEMC param: a param subsection, scope MEMC +// mcu_enable_mask = 00000011 [default: 000000ff] +// MCU param: a param subsection, scope MCU +// ecc_en = 00000002 [default: 00000001] +// DRAM populated DIMMs: the trained-DIMM roster +// SK0 MC0 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[b3:80] HMA82GR7AFR4N-VK +// CP: 3ff00100 an unindented line closes the subsection +// +// Lines end in CR (the SOL transport is a serial line) and one capture carries a NUL before the +// first NOTICE; both are removed before a line is read. Indentation (a leading two spaces) is +// what places a line inside a subsection, so it is read before trimming. +// +// WHAT IS NOT CLAIMED (DESIGN section 4d). No param value has a meaning here, mcu_enable_mask +// included: a param is its name, value and printed default, recorded as an observation. That a +// value differs from its default is not an adverse fact (earlier successful sparse boots printed +// mcu_enable_mask 00000001 against default ff), so it is never a finding. "SK", "MC" and "S" are +// read as the socket, memory controller and slot indices their spelling names, which is +// transcribed from the captures, not cited. The text after the slot address is kept verbatim. +// +// AN INDENTED LINE INSIDE A RECOGNISED SUBSECTION THAT DOES NOT PARSE IS KEPT AS MALFORMED, never +// dropped, so a firmware release that changes the row format shows up in the receipt rather than +// as a shorter roster (DESIGN section 5). + +data ampere_dram_fw_version_marker: String = "DRAM FW version " + +data ampere_dram_populated_header: String = "DRAM populated DIMMs:" + +data ampere_dram_param_header_suffix: String = " param:" + +data ampere_dram_indent: String = " " + +type AmpereDramParam { + scope: NonEmptyStr + name: NonEmptyStr + value: NonEmptyStr + default_value: NonEmptyStr +} + +type AmpereDramTrainedDimm { + socket: Int + memory_controller: Int + slot: Int + rendering: String +} + +type AmpereDramMalformedLine { + subsection: NonEmptyStr + line: String +} + +// WHETHER THE ROSTER WAS SEEN WHOLE. In both captures the roster's rows are followed by an +// unindented `CP:` checkpoint line, and a new `DRAM FW version` header also ends it; either closes +// the roster. The end of the capture does NOT: a SOL session lost or cut at a deadline stops +// mid-roster, and reading the rows seen so far as the whole roster would name every socket not yet +// printed as untrained. So only RosterClosed may establish that a socket trained nothing; the rows +// of an open roster are still rendered, as a partial observation. +type AmpereDramRosterStanding + = RosterNotObserved + | RosterOpen + | RosterClosed + +type AmpereDramBlock { + firmware_version: NonEmptyStr + params: List + dimms: List + roster: AmpereDramRosterStanding + malformed: List +} + +// BlockNotPrinted is its own arm because an absent roster is not an empty one: a capture that never +// reached the DRAM firmware says nothing about which sockets trained. blocks_printed counts the +// blocks, and the block read is the LAST one, because a reset loop prints the block once per boot +// and the last is the one that led to whatever followed. +type AmpereDramConsoleObservation + = AmpereDramBlockNotPrinted + | AmpereDramBlockObserved { block: AmpereDramBlock, blocks_printed: Int } + +type AmpereDramSubsection + = OutsideSubsection + | InParams { scope: NonEmptyStr } + | InRoster + +type AmpereDramReadState { + blocks: List + current: AmpereDramBlock? + subsection: AmpereDramSubsection +} + +// A SOL LINE AS THE FIRMWARE WROTE IT: CR and NUL removed, leading spaces kept. +fn ampere_dram_console_line(raw: String) -> String { + join(split(s: join(split(s: raw, delimiter: "\r"), ""), delimiter: "\0"), "") +} + +fn text_after(line: String, marker: String) -> String? { + let parts = split(s: line, delimiter: marker) + if count(parts) < 2 { none } else { + Present { value: join(parts.skip(n: 1), marker) } + } +} + +fn prefixed_int(token: String, prefix: String) -> Int? { + if !starts_with(s: token, prefix: prefix) { none } else { + parse_int(s: join(split(s: join(split(s: token, delimiter: ":"), ""), delimiter: prefix), "")) + } +} + +fn nth_token(tokens: List, n: Int) -> String { + match tokens.skip(n: n).first() { Absent => "" Present { value: t } => t } +} + +// "SK MC S: " +fn ampere_dram_dimm_of(row: String) -> AmpereDramTrainedDimm? { + let tokens = filter(split(s: trim(row), delimiter: " "), t => t != "") + let sl = nth_token(tokens: tokens, n: 2) + if !ends_with(s: sl, suffix: ":") { none } else { + match prefixed_int(token: nth_token(tokens: tokens, n: 0), prefix: "SK") { + Absent => none + Present { value: socket } => match prefixed_int(token: nth_token(tokens: tokens, n: 1), prefix: "MC") { + Absent => none + Present { value: controller } => match prefixed_int(token: sl, prefix: "S") { + Absent => none + Present { value: slot } => Present { value: AmpereDramTrainedDimm { + socket: socket, memory_controller: controller, slot: slot, + rendering: join(tokens.skip(n: 3), " "), + } } + } + } + } + } +} + +// " = [default: ]" under a " param:" header. +fn ampere_dram_param_of(scope: NonEmptyStr, row: String) -> AmpereDramParam? { + let eq = split(s: trim(row), delimiter: " = ") + let name = trim(match eq.first() { Absent => "" Present { value: n } => n }) + let vd = split(s: join(eq.skip(n: 1), " = "), delimiter: " [default: ") + let value = trim(match vd.first() { Absent => "" Present { value: v } => v }) + let def_raw = trim(join(vd.skip(n: 1), " [default: ")) + if count(eq) != 2 || name == "" || value == "" || count(vd) != 2 || !ends_with(s: def_raw, suffix: "]") { none } else { + let default_value = trim(join(split(s: def_raw, delimiter: "]"), "")) + if default_value == "" { none } else { + Present { value: AmpereDramParam { scope: scope, name: name as NonEmptyStr, value: value as NonEmptyStr, default_value: default_value as NonEmptyStr } } + } + } +} + +fn block_with_param(b: AmpereDramBlock, p: AmpereDramParam) -> AmpereDramBlock { + AmpereDramBlock { firmware_version: b.firmware_version, params: concat(b.params, [p]), dimms: b.dimms, roster: b.roster, malformed: b.malformed } +} + +fn block_with_dimm(b: AmpereDramBlock, d: AmpereDramTrainedDimm) -> AmpereDramBlock { + AmpereDramBlock { firmware_version: b.firmware_version, params: b.params, dimms: concat(b.dimms, [d]), roster: b.roster, malformed: b.malformed } +} + +fn block_with_malformed(b: AmpereDramBlock, m: AmpereDramMalformedLine) -> AmpereDramBlock { + AmpereDramBlock { firmware_version: b.firmware_version, params: b.params, dimms: b.dimms, roster: b.roster, malformed: concat(b.malformed, [m]) } +} + +fn block_with_roster(b: AmpereDramBlock, r: AmpereDramRosterStanding) -> AmpereDramBlock { + AmpereDramBlock { firmware_version: b.firmware_version, params: b.params, dimms: b.dimms, roster: r, malformed: b.malformed } +} + +// A LINE THAT ENDS A SUBSECTION closes an open roster; anything else leaves the standing alone. +fn close_roster_if_open(state: AmpereDramReadState, block: AmpereDramBlock) -> AmpereDramBlock { + match state.subsection { + InRoster => block_with_roster(b: block, r: RosterClosed) + _ => block + } +} + +fn subsection_label(s: AmpereDramSubsection) -> NonEmptyStr { + match s { + OutsideSubsection => "outside" + InParams { scope: sc } => concat(sc as String, ampere_dram_param_header_suffix) as NonEmptyStr + InRoster => ampere_dram_populated_header as NonEmptyStr + } +} + +// THE BLOCKS SEEN, with the current one as the capture left it: a roster still open at the end of +// the capture stays RosterOpen. A new block header, by contrast, does close it. +fn blocks_seen(state: AmpereDramReadState) -> List { + match state.current { Absent => state.blocks Present { value: b } => concat(state.blocks, [b]) } +} + +fn blocks_before_new_header(state: AmpereDramReadState) -> List { + match state.current { Absent => state.blocks Present { value: b } => concat(state.blocks, [close_roster_if_open(state: state, block: b)]) } +} + +fn ampere_dram_read_row(state: AmpereDramReadState, block: AmpereDramBlock, line: String) -> AmpereDramBlock { + match state.subsection { + OutsideSubsection => block + InParams { scope: sc } => match ampere_dram_param_of(scope: sc, row: line) { + Present { value: p } => block_with_param(b: block, p: p) + Absent => block_with_malformed(b: block, m: AmpereDramMalformedLine { subsection: subsection_label(s: state.subsection), line: trim(line) }) + } + InRoster => match ampere_dram_dimm_of(row: line) { + Present { value: d } => block_with_dimm(b: block, d: d) + Absent => block_with_malformed(b: block, m: AmpereDramMalformedLine { subsection: subsection_label(s: state.subsection), line: trim(line) }) + } + } +} + +fn ampere_dram_read_step(state: AmpereDramReadState, raw: String) -> AmpereDramReadState { + let line = ampere_dram_console_line(raw: raw) + let stripped = trim(line) + match text_after(line: line, marker: ampere_dram_fw_version_marker) { + Present { value: v } => { + let version = trim(v) + AmpereDramReadState { + blocks: blocks_before_new_header(state: state), + current: Present { value: AmpereDramBlock { firmware_version: (if version == "" { "unrendered" } else { version }) as NonEmptyStr, params: [], dimms: [], roster: RosterNotObserved, malformed: [] } }, + subsection: OutsideSubsection, + } + } + Absent => match state.current { + Absent => state + Present { value: block } => + if starts_with(s: line, prefix: ampere_dram_indent) && stripped != "" { + AmpereDramReadState { blocks: state.blocks, current: Present { value: ampere_dram_read_row(state: state, block: block, line: line) }, subsection: state.subsection } + } else if stripped == ampere_dram_populated_header { + AmpereDramReadState { blocks: state.blocks, current: Present { value: block_with_roster(b: close_roster_if_open(state: state, block: block), r: RosterOpen) }, subsection: InRoster } + } else if ends_with(s: stripped, suffix: ampere_dram_param_header_suffix) && !string_contains(s: stripped, pattern: " = ") { + let scope = trim(join(split(s: stripped, delimiter: ampere_dram_param_header_suffix), "")) + let closed = close_roster_if_open(state: state, block: block) + if scope == "" { + AmpereDramReadState { blocks: state.blocks, current: Present { value: block_with_malformed(b: closed, m: AmpereDramMalformedLine { subsection: "header", line: stripped }) }, subsection: OutsideSubsection } + } else { + AmpereDramReadState { blocks: state.blocks, current: Present { value: closed }, subsection: InParams { scope: scope as NonEmptyStr } } + } + } else if stripped == "" { + state + } else { + AmpereDramReadState { blocks: state.blocks, current: Present { value: close_roster_if_open(state: state, block: block) }, subsection: OutsideSubsection } + } + } + } +} + +fn ampere_dram_console_observation(lines: List) -> AmpereDramConsoleObservation { + let empty: List = [] + let done = fold(lines, init: AmpereDramReadState { blocks: empty, current: none, subsection: OutsideSubsection }, f: (st, raw) => ampere_dram_read_step(state: st, raw: raw)) + let blocks = blocks_seen(state: done) + match reverse(blocks).first() { + Absent => AmpereDramBlockNotPrinted + Present { value: last } => AmpereDramBlockObserved { block: last, blocks_printed: count(blocks) } + } +} + +fn ampere_dram_param_is_non_default(p: AmpereDramParam) -> Bool { + (p.value as String) != (p.default_value as String) +} + +fn ampere_dram_dimms_on_socket(block: AmpereDramBlock, socket: Int) -> Int { + count(filter(block.dimms, d => d.socket == socket)) +} + +fn ampere_dram_socket_untrained(block: AmpereDramBlock, socket: Int) -> Bool { + ampere_dram_dimms_on_socket(block: block, socket: socket) == 0 +} + +// THE DECISIVE FINDINGS THIS RECEIPT ESTABLISHES, given the sockets the caller expects: an expected +// socket with no trained DIMM row in a CLOSED roster, and a row inside a recognised subsection +// that does not parse. Params are never findings (see the note at the top). +fn ampere_dram_findings(observation: AmpereDramConsoleObservation, expected_sockets: List) -> List { + match observation { + AmpereDramBlockNotPrinted => [] + AmpereDramBlockObserved { block: b, blocks_printed: _ } => { + let closed = match b.roster { RosterClosed => true _ => false } + let empty_sockets = map(filter(expected_sockets, k => closed && ampere_dram_socket_untrained(block: b, socket: k)), + k => concat("DRAM firmware ", b.firmware_version as String, " printed no trained DIMM for socket ", to_string(k), " (no SK", to_string(k), " row under 'DRAM populated DIMMs:')")) + let bad = map(b.malformed, m => concat("DRAM firmware row under '", m.subsection as String, "' not in the transcribed grammar: ", m.line)) + concat(empty_sockets, bad) + } + } +} + +fn ampere_dram_console_text(observation: AmpereDramConsoleObservation, expected_sockets: List) -> String { + match observation { + AmpereDramBlockNotPrinted => "ampere dram firmware: NOT PRINTED in this capture (no 'DRAM FW version' line); no roster is observed" + AmpereDramBlockObserved { block: b, blocks_printed: n } => + join([ + concat("ampere dram firmware: version ", b.firmware_version as String, "; block printed ", to_string(n), " time(s), the last read"), + concat("params (observations; a value differing from its printed default is not a finding): ", to_string(count(b.params))), + join(map(b.params, p => concat(" ", p.scope as String, " ", p.name as String, " = ", p.value as String, " [default ", p.default_value as String, "]", if ampere_dram_param_is_non_default(p: p) { " (differs from printed default)" } else { "" })), "\n"), + concat("roster: ", ampere_dram_roster_text(r: b.roster)), + concat("trained dimms by socket: ", join(map(expected_sockets, k => concat("SK", to_string(k), "=", to_string(ampere_dram_dimms_on_socket(block: b, socket: k)))), " ")), + join(map(b.dimms, d => concat(" SK", to_string(d.socket), " MC", to_string(d.memory_controller), " S", to_string(d.slot), ": ", d.rendering)), "\n"), + concat("malformed rows: ", to_string(count(b.malformed))), + ], "\n") + } +} + +fn ampere_dram_roster_text(r: AmpereDramRosterStanding) -> String { + match r { + RosterNotObserved => "NOT OBSERVED (no 'DRAM populated DIMMs:' header in this block); no socket is established untrained" + RosterOpen => "OPEN at the end of the capture (no line closed it); the rows below are partial and no socket is established untrained" + RosterClosed => "closed" + } +} diff --git a/dag/gunbc/machine_intake/mtcollins1_boot_diagnostic_bundle.dag b/dag/gunbc/machine_intake/mtcollins1_boot_diagnostic_bundle.dag new file mode 100644 index 00000000000..dc76df278ea --- /dev/null +++ b/dag/gunbc/machine_intake/mtcollins1_boot_diagnostic_bundle.dag @@ -0,0 +1,1111 @@ +module gunbc.machine_intake_mtcollins1_boot_diagnostic_bundle + +import std.types { Bool, Int, List, NonEmptyStr, Secret, String } +import std.nat { Nat } +import std.algebra { trim } +import std.measure { Second, second, second_count, ByteSize, byte_size, byte_size_count } +import extdeps.tools.gnu_coreutils { coreutils_duration_operand, coreutils_timeout_expired_exit_code } +import extdeps.tools.coreutils_stat +import std.process { ProcessExit, ExitSuccess, ExitFailure } +import std.goal_assessment { ObservationAttempt, ObservationEstablished, ObservationRefused } +import v2.std.optional { Present } +import extdeps.bmc.ipmi +import extdeps.bmc.http +import extdeps.bmc.ipmi_sel { FirmwareError, FirmwareHang, FirmwareProgress } +import extdeps.bmc.redfish_memory_inventory { + RedfishMemoryMember, RedfishProcessorMember, RedfishResourceStatus, RedfishMemoryLocation, + RedfishResourceState, StateAbsent, StateDisabled, StateUnavailableOffline, StateStandbyOffline, + RedfishHealth, HealthWarning, HealthCritical, + redfish_resource_state_wire, redfish_health_wire, + redfish_memory_member_of, redfish_processor_member_of, + RedfishCollectionPage, redfish_collection_page_of, RedfishLinkReading, RedfishLinkSameOrigin, RedfishLinkRefused, redfish_same_origin_link, + RedfishSystemInventoryLinks, redfish_system_inventory_links_of, redfish_resource_odata_id, +} +import extdeps.filesystem.filesystem_io { Filesystem } +import gunbc.auth.netrc_binding { + NetrcBindingPlaced, NetrcBindingRefused, NetrcBindingRefusedResidueRemains, + place_netrc_binding_privately, shred_netrc_binding, +} +import gunbc.clock_read { clock_now_probed_at_or_unknown } +import gunbc.machine_intake_sel_stimulus_listener { SelDelta, sel_read, sel_after, sel_field } +import gunbc.machine_intake_pre_os_bringup_verdict { + SelWindowEvent, BootRestart, FirmwareProgressRecord, OemTimestamped, OtherStandardEvent, + FirmwareConsoleReport, NoTerminalStated, UndecodedErrorCodesOnly, FirmwareErrorStatementUnrecognized, TrainingRefusedByFirmware, + firmware_console_report, +} +import gunbc.machine_intake_ampere_dram_console_observation { + AmpereDramConsoleObservation, ampere_dram_console_observation, ampere_dram_findings, ampere_dram_console_text, +} +import gunbc.machine_intake_host_capture_envelope { HostCaptureLiveStream, host_capture_lines } +import gunbc.machine_intake_mtcollins1_memory_census_observation { mtcollins1_slots } +import gunbc.machine_intake_mtcollins1_access_observation { mtcollins1_endpoint } + +// THE DIAGNOSTIC BUNDLE OF ONE mtcollins1 BOOT ATTEMPT: what the BMC and the pre-OS console +// said about the machine around the attempt, recorded on every terminal arm so that a remote +// operator can diagnose a failed or degraded boot from the run's artifact alone (operator, +// 2026-09-23: run 35793279839 came up with socket 1 absent and nothing in its receipts said why). +// +// DESIGN section 3b, observability row, and the four responsibilities it names. The owning +// domains establish the facts: the SEL record formats are extdeps.bmc.ipmi_sel and their +// before/after reading is gunbc.machine_intake_sel_stimulus_listener; the per-slot and +// per-socket inventory is extdeps.bmc.redfish_memory_inventory; the firmware's pre-OS statement +// is gunbc.machine_intake_pre_os_bringup_verdict firmware_console_report. This module is the +// observation model of ONE attempt (MtCollins1BootDiagnosticBundle), and mtcollins1_boot_bundle_text +// renders it. It does not decode anything those authorities do not. +// +// THE BUNDLE NEVER DECIDES THE VERDICT (brief, and DESIGN section 5's separation of observation +// from judgment). mtcollins1_boot_outcome_with_findings only appends findings to a refusal +// reason. It never turns a success into a failure or a failure into a success, and the witness +// asserts both directions. +// +// A READ THAT FAILS IS A TYPED, LOCATED READING IN THE BUNDLE, NEVER A MISSING SECTION (DESIGN +// section 5). Every section has an arm for "read", one for "the read failed, and why, at which +// endpoint, at what instant", and one for "the attempt ended before this could be read, and +// why". A BMC that does not answer (operator, 2026-09-23: 192.168.1.228 unreachable after a DIMM +// reseat) is itself a diagnosis, so it has its own arm. + +// WHY A BMC READ FAILED. Every arm carries the endpoint it addressed and the instant of the +// attempt. The transport's own exit code and stderr are the evidence: curl 6/7 (name not +// resolved, connection refused or host unreachable), curl 28 (timeout), curl 22 with an HTTP +// 401/403 on stderr (authentication refused). ipmitool's lanplus session setup CANNOT tell an +// unreachable controller from one that refused the credential: both render "Unable to establish +// IPMI v2 / RMCP+ session". So that reading is BmcSessionUnestablished and is not split into +// either, which would be a guess (DESIGN section 4d). +type BmcReadCause + = BmcUnreachable { endpoint: NonEmptyStr, at: NonEmptyStr, detail: String } + | BmcTimeout { endpoint: NonEmptyStr, at: NonEmptyStr, detail: String } + | BmcAuthRefused { endpoint: NonEmptyStr, at: NonEmptyStr, detail: String } + | BmcSessionUnestablished { endpoint: NonEmptyStr, at: NonEmptyStr, detail: String } + | BmcHttpRefused { endpoint: NonEmptyStr, at: NonEmptyStr, detail: String } + | BmcReadFailed { endpoint: NonEmptyStr, at: NonEmptyStr, exit_code: Int, detail: String } + | BmcResponseMalformed { endpoint: NonEmptyStr, at: NonEmptyStr, detail: String } + | BmcCredentialUnavailable { endpoint: NonEmptyStr, at: NonEmptyStr, detail: String } + | BmcCollectionIncomplete { endpoint: NonEmptyStr, at: NonEmptyStr, detail: String } + | BmcDeadlineReached { endpoint: NonEmptyStr, at: NonEmptyStr, not_reached: String } + +fn bmc_read_cause_text(cause: BmcReadCause) -> String { + match cause { + BmcUnreachable { endpoint: e, at: a, detail: d } => concat("BMC unreachable at ", e as String, " (", a as String, "): ", d) + BmcTimeout { endpoint: e, at: a, detail: d } => concat("BMC timed out at ", e as String, " (", a as String, "): ", d) + BmcAuthRefused { endpoint: e, at: a, detail: d } => concat("BMC refused the credential at ", e as String, " (", a as String, "): ", d) + BmcSessionUnestablished { endpoint: e, at: a, detail: d } => concat("no IPMI session at ", e as String, " (", a as String, "; unreachable and credential-refused are indistinguishable on this transport): ", d) + BmcHttpRefused { endpoint: e, at: a, detail: d } => concat("BMC answered with an HTTP error at ", e as String, " (", a as String, "): ", d) + BmcReadFailed { endpoint: e, at: a, exit_code: c, detail: d } => concat("BMC read failed at ", e as String, " (", a as String, ", exit ", to_string(c), "): ", d) + BmcResponseMalformed { endpoint: e, at: a, detail: d } => concat("BMC response unreadable at ", e as String, " (", a as String, "): ", d) + BmcCredentialUnavailable { endpoint: e, at: a, detail: d } => concat("no credential could be presented to ", e as String, " (", a as String, "): ", d) + BmcCollectionIncomplete { endpoint: e, at: a, detail: d } => concat("collection incomplete at ", e as String, " (", a as String, "): ", d) + BmcDeadlineReached { endpoint: e, at: a, not_reached: n } => concat("diagnostics read budget spent before ", e as String, " (", a as String, "); not reached: ", n) + } +} + +// A CAUSE THAT DEFINITIVELY SAYS THE BMC DID NOT ANSWER: the transport established that nothing +// answered at all or in time. BmcSessionUnestablished is NOT one: ipmitool renders an unreachable +// controller and a refused credential identically. Nor is any cause that carries an answer (an +// HTTP status, a malformed body, an incomplete collection) or that no read was made for. +fn bmc_read_cause_is_definitive_no_answer(cause: BmcReadCause) -> Bool { + match cause { + BmcUnreachable { endpoint: _, at: _, detail: _ } => true + BmcTimeout { endpoint: _, at: _, detail: _ } => true + _ => false + } +} + +fn bmc_read_cause_kind(cause: BmcReadCause) -> String { + match cause { + BmcUnreachable { endpoint: _, at: _, detail: _ } => "unreachable" + BmcTimeout { endpoint: _, at: _, detail: _ } => "timed out" + BmcAuthRefused { endpoint: _, at: _, detail: _ } => "credential refused" + BmcSessionUnestablished { endpoint: _, at: _, detail: _ } => "no IPMI session (unreachable and credential-refused are indistinguishable)" + BmcHttpRefused { endpoint: _, at: _, detail: _ } => "answered with an HTTP error" + BmcReadFailed { endpoint: _, at: _, exit_code: _, detail: _ } => "read failed" + BmcResponseMalformed { endpoint: _, at: _, detail: _ } => "answered unreadably" + BmcCredentialUnavailable { endpoint: _, at: _, detail: _ } => "no credential presented" + BmcCollectionIncomplete { endpoint: _, at: _, detail: _ } => "collection incomplete" + BmcDeadlineReached { endpoint: _, at: _, not_reached: _ } => "read budget spent" + } +} + +// THE AGGREGATE OVER BMC READS THAT ALL FAILED. "The BMC did not answer" is said only when EVERY +// cause is a definitive no-answer; otherwise each distinct kind is named, so an ambiguous IPMI +// session failure beside a Redfish timeout reads as exactly that and not as a verdict on the BMC. +fn bmc_all_failed_text(causes: List) -> String { + let empty: List = [] + let kinds = fold(map(causes, c => bmc_read_cause_kind(cause: c)), init: empty, f: (acc, k) => if any(acc, j => j == k) { acc } else { concat(acc, [k]) }) + let first = match causes.first() { Absent => "" Present { value: c } => bmc_read_cause_text(cause: c) } + if all(causes, c => bmc_read_cause_is_definitive_no_answer(cause: c)) { + concat("every BMC read failed and the BMC did not answer; first: ", first) + } else { + concat("every BMC read failed (", join(kinds, "; "), "); first: ", first) + } +} + +fn first_line(s: String) -> String { + match filter(map(split(s: s, delimiter: "\n"), l => trim(l)), l => l != "").first() { + Absent => "" + Present { value: l } => l + } +} + +fn bmc_curl_read_cause(endpoint: NonEmptyStr, at: NonEmptyStr, exit_code: Int, stderr: String) -> BmcReadCause { + let detail = first_line(s: stderr) + if exit_code == 6 || exit_code == 7 { + BmcUnreachable { endpoint: endpoint, at: at, detail: detail } + } else if exit_code == 28 { + BmcTimeout { endpoint: endpoint, at: at, detail: detail } + } else if exit_code == 22 && (string_contains(s: stderr, pattern: "error: 401") || string_contains(s: stderr, pattern: "error: 403")) { + BmcAuthRefused { endpoint: endpoint, at: at, detail: detail } + } else if exit_code == 22 { + BmcHttpRefused { endpoint: endpoint, at: at, detail: detail } + } else { + BmcReadFailed { endpoint: endpoint, at: at, exit_code: exit_code, detail: detail } + } +} + +// ipmitool's lanplus renderings, as its source prints them: "RAKP 2 HMAC is invalid" and +// "Unauthorized name" come from the RAKP exchange rejecting the credential, and "Insufficient +// privilege level" is completion code D4h. Anything that failed to set up a session without one +// of those is BmcSessionUnestablished. +fn bmc_ipmitool_read_cause(endpoint: NonEmptyStr, at: NonEmptyStr, exit_code: Int, stderr: String) -> BmcReadCause { + let detail = first_line(s: stderr) + if exit_code == coreutils_timeout_expired_exit_code { + BmcTimeout { endpoint: endpoint, at: at, detail: concat("no answer within the diagnostics deadline (coreutils timeout exit 124)", if detail == "" { "" } else { concat("; ", detail) }) } + } else if string_contains(s: stderr, pattern: "RAKP 2 HMAC is invalid") || string_contains(s: stderr, pattern: "Unauthorized name") || string_contains(s: stderr, pattern: "Insufficient privilege level") { + BmcAuthRefused { endpoint: endpoint, at: at, detail: detail } + } else if string_contains(s: stderr, pattern: "Unable to establish IPMI v2") { + BmcSessionUnestablished { endpoint: endpoint, at: at, detail: detail } + } else { + BmcReadFailed { endpoint: endpoint, at: at, exit_code: exit_code, detail: detail } + } +} + +// ONE SEL SNAPSHOT: the raw `sel elist` rows as the controller rendered them, or why there are none. +type SelSnapshotReading + = SelSnapshotRead { raw: String, at: NonEmptyStr } + | SelSnapshotUnread { cause: BmcReadCause } + | SelSnapshotNotTaken { reason: NonEmptyStr } + +type MembersReading + = MembersRead { members: List } + | MembersUnread { cause: BmcReadCause } + | MembersNotTaken { reason: NonEmptyStr } + +// THE BMC'S OWN INVENTORY. `credential_removed` is carried because the per-attempt netrc that +// authenticated the reads must be shredded, and a shred that failed is a standing exposure this +// attempt created, which the bundle states rather than hides. +type InventoryReading { + system_id: String + memory: MembersReading + processors: MembersReading + credential_removed: Bool +} + +// THE PRE-OS CONSOLE. The SOL capture is the firmware's training and POST output before any +// kernel, and it is retained by the workflow's upload of mtcollins1_boot_artifact_glob, which +// covers it only if it lives there. The bound is a policy row on artifact size, OBSERVED here: +// the collector itself does not truncate, so a capture over the bound is reported, not clipped. +// THE SIZE IS THE FILE'S BYTE COUNT FROM stat(1) (extdeps.tools.coreutils_stat PathSize), never the +// length of the String read from it: a String's length counts Unicode scalar values, and calling +// those bytes would under-count multi-byte console output. The size is taken before the content is +// read, so a capture over the bound is reported without being loaded. +type ConsoleReading + = ConsoleRetained { path: NonEmptyStr, size: ByteSize, lines: Int, firmware: FirmwareConsoleReport, dram: AmpereDramConsoleObservation } + | ConsoleExceedsBound { path: NonEmptyStr, size: ByteSize, bound: ByteSize } + | ConsoleNotRetained { path: NonEmptyStr } + | ConsoleUnread { path: NonEmptyStr, detail: String } + | ConsoleNotConfigured + +data mtcollins1_boot_console_bound: ByteSize = byte_size(count: 16777216) + +// WHICH ATTEMPT THIS BUNDLE BELONGS TO. The attempt is named by the Actions run id; a run whose id +// could not be read carries that as a typed reading with the variable's own detail, never a blank. +type AttemptIdentityReading + = AttemptRunId { run_id: NonEmptyStr } + | AttemptIdentityUnavailable { variable: NonEmptyStr, detail: String } + +fn attempt_identity_text(a: AttemptIdentityReading) -> String { + match a { + AttemptRunId { run_id: r } => r as String + AttemptIdentityUnavailable { variable: v, detail: d } => concat("UNAVAILABLE: ", v as String, " could not be read: ", d) + } +} + +data mtcollins1_boot_diagnostics_path: String = "artifacts/mtcollins1-boot-diagnostics.txt" + +data mtcollins1_boot_retained_artifact_prefix: String = "artifacts/mtcollins1-boot-" + +type MtCollins1BootDiagnosticBundle { + attempt: AttemptIdentityReading + outcome: String + sel_before: SelSnapshotReading + sel_after: SelSnapshotReading + inventory: InventoryReading + console: ConsoleReading +} + +fn inventory_not_taken(reason: NonEmptyStr) -> InventoryReading { + InventoryReading { system_id: "", memory: MembersNotTaken { reason: reason }, processors: MembersNotTaken { reason: reason }, credential_removed: true } +} + +// ── THE SEL DELTA ──────────────────────────────────────────────────────────────────────────── + +type SelDeltaReading + = SelDeltaDecoded { delta: SelDelta } + | SelDeltaRefused { cause: NonEmptyStr } + | SelDeltaUnavailable { reason: String } + +fn sel_delta_reading(before: SelSnapshotReading, after: SelSnapshotReading) -> SelDeltaReading { + match before { + SelSnapshotRead { raw: b, at: _ } => + match after { + SelSnapshotRead { raw: a, at: _ } => + match sel_read(text: b) { + ObservationRefused { cause: c } => SelDeltaRefused { cause: concat("before snapshot: ", c as String) as NonEmptyStr } + ObservationEstablished { observed: watermark } => + match sel_after(watermark: watermark, text: a) { + ObservationRefused { cause: c } => SelDeltaRefused { cause: c } + ObservationEstablished { observed: delta } => SelDeltaDecoded { delta: delta } + } + } + _ => SelDeltaUnavailable { reason: "no after snapshot" } + } + _ => SelDeltaUnavailable { reason: "no before snapshot" } + } +} + +fn sel_event_kind_text(event: SelWindowEvent) -> String { + match event.kind { + BootRestart { offset: _ } => "system boot initiated (section 42.2 sensor type 1Dh)" + FirmwareProgressRecord { offset: o } => match o { + FirmwareError => "system firmware error (section 42.2 sensor type 0Fh offset 00h, POST error)" + FirmwareHang => "system firmware hang (section 42.2 sensor type 0Fh offset 01h)" + FirmwareProgress { progress_rendering: r } => concat("system firmware progress: ", r as String) + } + OemTimestamped { payload: p } => concat("OEM record, manufacturer ", p.manufacturer_id_rendering as String, ", bytes ", p.oem_bytes_rendering as String, " (OEM-defined; not decoded)") + OtherStandardEvent { rendering: r } => r as String + } +} + +fn sel_event_is_oem(event: SelWindowEvent) -> Bool { + match event.kind { OemTimestamped { payload: _ } => true _ => false } +} + +fn sel_event_text(event: SelWindowEvent) -> String { + concat("record ", to_string(event.record_id), " at ", event.bmc_clock_rendering as String, ": ", sel_event_kind_text(event: event)) +} + +// A STANDARD EVENT WHOSE SENSOR TYPE IS Memory (0Ch) OR Processor (07h). ipmitool renders the +// section 42.2 sensor-type name as the leading word of the sensor column, so the type is read +// from that column. A sensor NAME that merely mentions a CPU ("Voltage CPU0_0V75_PCP") is a +// voltage sensor and is not selected. +fn sel_event_is_memory_or_processor(event: SelWindowEvent) -> Bool { + match event.kind { + OtherStandardEvent { rendering: r } => { + let sensor = sel_field(fields: map(split(s: r as String, delimiter: "|"), f => trim(f)), index: 3) + starts_with(s: sensor, prefix: "Memory") || starts_with(s: sensor, prefix: "Processor") + } + FirmwareProgressRecord { offset: o } => match o { FirmwareProgress { progress_rendering: _ } => false _ => true } + _ => false + } +} + +// ── DECISIVE FINDINGS ──────────────────────────────────────────────────────────────────────── + +// THE SOCKETS THE CENSUS OBSERVED, derived from its slot rows rather than restated. +fn distinct_ints(xs: List) -> List { + let empty: List = [] + fold(xs, init: empty, f: (acc, k) => if any(acc, j => j == k) { acc } else { concat(acc, [k]) }) +} + +fn mtcollins1_census_sockets() -> List { + distinct_ints(xs: map(mtcollins1_slots, s => s.processor_socket as Int)) +} + +fn mtcollins1_census_socket_count() -> Int { + count(mtcollins1_census_sockets()) +} + +fn console_findings(c: ConsoleReading) -> List { + match c { + ConsoleRetained { path: _, size: _, lines: _, firmware: _, dram: d } => ampere_dram_findings(observation: d, expected_sockets: mtcollins1_census_sockets()) + _ => [] + } +} + +fn state_is_down(state: RedfishResourceState) -> Bool { + match state { + StateAbsent => true + StateDisabled => true + StateUnavailableOffline => true + StateStandbyOffline => true + _ => false + } +} + +fn health_is_bad(health: RedfishHealth) -> Bool { + match health { + HealthWarning => true + HealthCritical => true + _ => false + } +} + +fn status_text(status: RedfishResourceStatus) -> String { + concat("State=", redfish_resource_state_wire(state: status.state), " Health=", redfish_health_wire(health: status.health)) +} + +fn memory_socket(m: RedfishMemoryMember) -> Int? { + match m.memory_location { + Absent => none + Present { value: loc } => loc.socket + } +} + +// -1 is never a socket index, so it stands for "the member reports no socket" in the grouping. +fn memory_socket_key(m: RedfishMemoryMember) -> Int { + match memory_socket(m: m) { Absent => -1 Present { value: s } => s } +} + +fn state_is_absent(state: RedfishResourceState) -> Bool { + match state { StateAbsent => true _ => false } +} + +fn socket_absent_finding(ms: List, socket: Int) -> String { + let on = filter(ms, m => memory_socket_key(m: m) == socket) + let absent = count(filter(on, m => state_is_absent(state: m.status.state))) + if absent == 0 || socket < 0 { "" } else { concat("BMC reports ", to_string(absent), " of ", to_string(count(on)), " socket-", to_string(socket), " Memory member(s) State=Absent") } +} + +fn memory_label(m: RedfishMemoryMember) -> String { + match m.device_locator { + Present { value: l } => concat(m.id as String, " (", l, ")") + Absent => m.id as String + } +} + +fn processor_socket_suffix(p: RedfishProcessorMember) -> String { + match p.socket { Present { value: s } => concat(" (Socket ", s, ")") Absent => "" } +} + +fn processor_findings(processors: MembersReading) -> List { + match processors { + MembersRead { members: ps } => { + let expected = mtcollins1_census_socket_count() + let none_short: List = [] + let short = if count(ps) < expected { + [concat("BMC lists ", to_string(count(ps)), " Processor member(s); the 2026-09-10 census observed ", to_string(expected), " sockets")] + } else { none_short } + concat(short, map(filter(ps, p => state_is_down(state: p.status.state) || health_is_bad(health: p.status.health)), + p => concat("BMC Processor ", p.id as String, processor_socket_suffix(p: p), ": ", status_text(status: p.status)))) + } + _ => [] + } +} + +fn memory_findings(memory: MembersReading) -> List { + match memory { + MembersRead { members: ms } => { + let slots = count(mtcollins1_slots) + let none_short: List = [] + let short = if count(ms) < slots { + [concat("BMC lists ", to_string(count(ms)), " Memory member(s); the census board has ", to_string(slots), " slots")] + } else { none_short } + let sockets = distinct_ints(xs: map(ms, m => memory_socket_key(m: m))) + let absent_by_socket = filter(map(sockets, k => socket_absent_finding(ms: ms, socket: k)), line => line != "") + let bad = map(filter(ms, m => (state_is_down(state: m.status.state) && !state_is_absent(state: m.status.state)) || health_is_bad(health: m.status.health)), + m => concat("BMC Memory ", memory_label(m: m), ": ", status_text(status: m.status))) + concat(short, concat(absent_by_socket, bad)) + } + _ => [] + } +} + +fn sel_findings(delta: SelDeltaReading) -> List { + match delta { + SelDeltaDecoded { delta: d } => + map(filter(d.events, e => sel_event_is_memory_or_processor(event: e)), e => concat("SEL ", sel_event_text(event: e))) + _ => [] + } +} + +fn sel_snapshot_cause(s: SelSnapshotReading) -> BmcReadCause? { + match s { + SelSnapshotUnread { cause: c } => Present { value: c } + _ => none + } +} + +fn members_cause(m: MembersReading) -> BmcReadCause? { + match m { + MembersUnread { cause: c } => Present { value: c } + _ => none + } +} + +// EVERY BMC READ WAS ATTEMPTED AND EVERY ONE FAILED. A section that was never attempted does not +// count toward this: an attempt that refused before reading the credential says so separately. +fn bmc_all_reads_failed(bundle: MtCollins1BootDiagnosticBundle) -> List { + let causes = [ + sel_snapshot_cause(s: bundle.sel_before), + sel_snapshot_cause(s: bundle.sel_after), + members_cause(m: bundle.inventory.memory), + members_cause(m: bundle.inventory.processors), + ] + let empty: List = [] + if all(causes, c => match c { Absent => false Present { value: _ } => true }) { + fold(causes, init: empty, f: (acc, c) => match c { Absent => acc Present { value: v } => concat(acc, [v]) }) + } else { empty } +} + +fn mtcollins1_boot_bundle_findings(bundle: MtCollins1BootDiagnosticBundle) -> List { + let nothing: List = [] + let failed = bmc_all_reads_failed(bundle: bundle) + let unreachable = if count(failed) == 0 { nothing } else { [bmc_all_failed_text(causes: failed)] } + let shred = if bundle.inventory.credential_removed { nothing } else { ["the per-attempt Redfish netrc could not be removed; credential material may remain on the runner"] } + concat(unreachable, concat(processor_findings(processors: bundle.inventory.processors), + concat(memory_findings(memory: bundle.inventory.memory), + concat(sel_findings(delta: sel_delta_reading(before: bundle.sel_before, after: bundle.sel_after)), concat(console_findings(c: bundle.console), shred))))) +} + +// THE ONE-LINE CONSEQUENCE ON THE RUN'S OUTCOME: findings are appended to a refusal reason, and a +// success stays a success. This is the whole of the bundle's reach into the verdict. +fn mtcollins1_boot_outcome_with_findings(outcome: ProcessExit, findings: List) -> ProcessExit { + match outcome { + ExitSuccess => ExitSuccess + ExitFailure { code: c, reason: r } => + if count(findings) == 0 { ExitFailure { code: c, reason: r } } + else { ExitFailure { code: c, reason: concat(r, " | bmc diagnostics: ", join(findings, "; ")) } } + } +} + +// ── RENDER ─────────────────────────────────────────────────────────────────────────────────── + +fn sel_snapshot_text(label: String, s: SelSnapshotReading) -> String { + match s { + SelSnapshotRead { raw: r, at: a } => concat(label, ": read at ", a as String, ", ", to_string(count(filter(split(s: r, delimiter: "\n"), l => trim(l) != ""))), " record(s)") + SelSnapshotUnread { cause: c } => concat(label, ": UNREAD: ", bmc_read_cause_text(cause: c)) + SelSnapshotNotTaken { reason: why } => concat(label, ": NOT TAKEN: ", why as String) + } +} + +fn sel_raw_text(label: String, s: SelSnapshotReading) -> String { + match s { + SelSnapshotRead { raw: r, at: _ } => concat("-- raw ", label, " (ipmitool sel elist, verbatim) --\n", r) + _ => concat("-- raw ", label, ": none --") + } +} + +fn sel_delta_text(delta: SelDeltaReading) -> String { + match delta { + SelDeltaDecoded { delta: d } => + concat("delta: ", to_string(count(d.events)), " new record(s) (", to_string(count(filter(d.events, e => sel_event_is_oem(event: e)))), " OEM, kept opaque)\n", + join(map(d.events, e => concat(" ", sel_event_text(event: e))), "\n")) + SelDeltaRefused { cause: c } => concat("delta: REFUSED: ", c as String, " (both raw snapshots below)") + SelDeltaUnavailable { reason: r } => concat("delta: UNAVAILABLE: ", r) + } +} + +fn optional_int_text(n: Int?) -> String { + match n { Present { value: v } => to_string(v) Absent => "not-reported" } +} + +fn memory_location_text(location: RedfishMemoryLocation?) -> String { + match location { + Absent => " location=not-reported" + Present { value: l } => concat(" socket=", optional_int_text(n: l.socket), " controller=", optional_int_text(n: l.memory_controller), " channel=", optional_int_text(n: l.channel), " slot=", optional_int_text(n: l.slot)) + } +} + +fn memory_member_text(m: RedfishMemoryMember) -> String { + concat(" ", memory_label(m: m), memory_location_text(location: m.memory_location), + " capacity_mib=", optional_int_text(n: m.capacity_mib), " ", status_text(status: m.status)) +} + +fn optional_text_or_not_reported(s: String?) -> String { + match s { Present { value: v } => v Absent => "not-reported" } +} + +fn processor_member_text(p: RedfishProcessorMember) -> String { + concat(" ", p.id as String, " socket=", optional_text_or_not_reported(s: p.socket), + " total_cores=", optional_int_text(n: p.total_cores), " ", status_text(status: p.status)) +} + +fn memory_members_text(m: MembersReading) -> String { + match m { + MembersRead { members: ms } => concat("memory: ", to_string(count(ms)), " member(s)\n", join(map(ms, x => memory_member_text(m: x)), "\n")) + MembersUnread { cause: c } => concat("memory: UNREAD: ", bmc_read_cause_text(cause: c)) + MembersNotTaken { reason: why } => concat("memory: NOT TAKEN: ", why as String) + } +} + +fn processor_members_text(m: MembersReading) -> String { + match m { + MembersRead { members: ps } => concat("processors: ", to_string(count(ps)), " member(s)\n", join(map(ps, x => processor_member_text(p: x)), "\n")) + MembersUnread { cause: c } => concat("processors: UNREAD: ", bmc_read_cause_text(cause: c)) + MembersNotTaken { reason: why } => concat("processors: NOT TAKEN: ", why as String) + } +} + +fn bracketed_int(label: String, n: Int?) -> String { + match n { Present { value: k } => concat(" [", label, " ", to_string(k), "]") Absent => "" } +} + +fn firmware_report_text(report: FirmwareConsoleReport) -> String { + match report { + NoTerminalStated => "firmware stated no terminal" + UndecodedErrorCodesOnly { err_lines: n } => concat("firmware printed ", to_string(n), " undecoded ERR code line(s)") + FirmwareErrorStatementUnrecognized { statement: s } => concat("firmware printed an unrecognised statement: ", s as String) + TrainingRefusedByFirmware { statement: s, locus: l } => + concat("firmware refused memory training: ", s as String, bracketed_int(label: "socket", n: l.socket), bracketed_int(label: "memory controller", n: l.memory_controller)) + } +} + +fn console_text(c: ConsoleReading) -> String { + match c { + ConsoleRetained { path: p, size: b, lines: n, firmware: f, dram: d } => + concat("capture ", p as String, " retained in this artifact: ", to_string(byte_size_count(b: b)), " bytes (stat), ", to_string(n), " line(s), within the ", to_string(byte_size_count(b: mtcollins1_boot_console_bound)), "-byte bound; ", firmware_report_text(report: f), "\n", ampere_dram_console_text(observation: d, expected_sockets: mtcollins1_census_sockets())) + ConsoleExceedsBound { path: p, size: b, bound: bound } => + concat("capture ", p as String, " is ", to_string(byte_size_count(b: b)), " bytes (stat), OVER the ", to_string(byte_size_count(b: bound)), "-byte bound; the collector does not truncate, so the artifact carries it whole") + ConsoleNotRetained { path: p } => + concat("capture ", p as String, " is NOT under ", mtcollins1_boot_retained_artifact_prefix, " and is not uploaded with this artifact") + ConsoleUnread { path: p, detail: d } => concat("capture ", p as String, " UNREAD: ", d) + ConsoleNotConfigured => "NOT CONFIGURED: the SOL capture path was unset for this attempt" + } +} + +fn mtcollins1_boot_bundle_text(bundle: MtCollins1BootDiagnosticBundle) -> String { + let findings = mtcollins1_boot_bundle_findings(bundle: bundle) + join([ + "mtcollins1 boot diagnostics", + concat("attempt=", attempt_identity_text(a: bundle.attempt)), + concat("outcome=", bundle.outcome), + "== decisive findings ==", + if count(findings) == 0 { "none" } else { join(findings, "\n") }, + "== bmc system event log ==", + sel_snapshot_text(label: "before", s: bundle.sel_before), + sel_snapshot_text(label: "after", s: bundle.sel_after), + sel_delta_text(delta: sel_delta_reading(before: bundle.sel_before, after: bundle.sel_after)), + sel_raw_text(label: "before", s: bundle.sel_before), + sel_raw_text(label: "after", s: bundle.sel_after), + "== bmc inventory (redfish) ==", + concat("system=", if bundle.inventory.system_id == "" { "not-read" } else { bundle.inventory.system_id }), + processor_members_text(m: bundle.inventory.processors), + memory_members_text(m: bundle.inventory.memory), + "== pre-os console ==", + console_text(c: bundle.console), + "", + ], "\n") +} + +// ── THE DIAGNOSTICS DEADLINE ───────────────────────────────────────────────────────────────── +// +// THE DIAGNOSTIC TRANSACTION HAS A TYPED OUTER BOUND, and the step's time allowance is DERIVED +// from it rather than guessed. Every read is individually bounded by its transport: each SEL +// snapshot runs under coreutils `timeout` (deadline plus --kill-after), and each Redfish GET under +// curl --max-time. The Redfish reads are counted against a READ BUDGET, and a read the budget +// cannot pay for is not made: its section records BmcDeadlineReached naming what was not reached, +// and the attempt still shreds its netrc and writes the bundle. So the worst case is a sum of +// bounds -- mtcollins1_boot_diagnostics_allowance below -- and an unbounded collection cannot push +// the step past its timeout before cleanup and publish run. +// +// The budget is sized for this board's inventory as the census observed it (1 Systems page, the +// system, 1 Processors page and 2 processors, 1 Memory page and 32 slots: 38 reads) with room for +// extra pages; a firmware that pages more finely spends the rest and says so. +data mtcollins1_boot_redfish_read_deadline: Second = second(count: 15) + +data mtcollins1_boot_ipmi_read_deadline: Second = second(count: 20) + +data mtcollins1_boot_ipmi_kill_after: Second = second(count: 5) + +data mtcollins1_boot_sel_snapshot_count: Int = 2 + +data mtcollins1_boot_redfish_read_budget: Int = 48 + +data mtcollins1_boot_collection_page_bound: Int = 8 + +data mtcollins1_boot_collection_member_bound: Int = 40 + +// The netrc shred and the bundle and receipt writes: local file operations. +data mtcollins1_boot_publish_allowance: Second = second(count: 60) + +fn mtcollins1_boot_diagnostics_allowance() -> Second { + let sel = mtcollins1_boot_sel_snapshot_count * ((second_count(s: mtcollins1_boot_ipmi_read_deadline) as Int) + (second_count(s: mtcollins1_boot_ipmi_kill_after) as Int)) + let redfish = mtcollins1_boot_redfish_read_budget * (second_count(s: mtcollins1_boot_redfish_read_deadline) as Int) + second(count: sel + redfish + (second_count(s: mtcollins1_boot_publish_allowance) as Int)) +} + +// ── READS (effects) ────────────────────────────────────────────────────────────────────────── + +fn mtcollins1_ipmi_endpoint() -> NonEmptyStr { + concat("ipmi lanplus ", mtcollins1_endpoint.host as String) as NonEmptyStr +} + +fn mtcollins1_redfish_url(path: String) -> NonEmptyStr { + concat("https://", mtcollins1_endpoint.host as String, path) as NonEmptyStr +} + +fn mtcollins1_boot_sel_snapshot(username: NonEmptyStr, password_file: NonEmptyStr) -> SelSnapshotReading + uses net: std.resources.Network +{ + let at = clock_now_probed_at_or_unknown() + let r = diagnostic.ipmi.Tool.SelListAuthenticated( + bmc_host: mtcollins1_endpoint.host, + username: username, + password_file: password_file, + deadline: coreutils_duration_operand(d: mtcollins1_boot_ipmi_read_deadline) as NonEmptyStr, + kill_after: coreutils_duration_operand(d: mtcollins1_boot_ipmi_kill_after) as NonEmptyStr, + ) + if r.success { + SelSnapshotRead { raw: r.stdout, at: at } + } else { + SelSnapshotUnread { cause: bmc_ipmitool_read_cause(endpoint: mtcollins1_ipmi_endpoint(), at: at, exit_code: r.exit_code, stderr: r.transport_stderr) } + } +} + +// ── COLLECTION COMPLETENESS (pure) ─────────────────────────────────────────────────────────── +// +// A COLLECTION IS COMPLETE ONLY WHEN ITS PAGES ACCOUNT FOR ITS COUNT. The pages are the ones the +// reader followed through Members@odata.nextLink; the first page's Members@odata.count is the +// total DSP0266 says every page reports. No count, a last page that still names a next page, a +// member total different from the count, a count over the member bound, or a member link that is +// not a same-origin path: each refuses as incomplete, and no member is read. A short inventory is +// therefore never inferred from a first page alone. +type CollectionAssembly + = CollectionComplete { links: List } + | CollectionRefused { detail: NonEmptyStr } + +fn redfish_collection_assembly(pages: List, member_bound: Int) -> CollectionAssembly { + match pages.first() { + Absent => CollectionRefused { detail: "no collection page was read" } + Present { value: first } => + match first.member_count { + Absent => CollectionRefused { detail: "the first page carries no Members@odata.count, so completeness cannot be established" } + Present { value: total } => { + let links = fold(pages, init: [], f: (acc, p) => concat(acc, p.member_links)) + let last_has_next = match reverse(pages).first() { Absent => false Present { value: p } => p.next_link != none } + let refused_links = filter(links, l => match redfish_same_origin_link(link: l) { RedfishLinkRefused { cause: _ } => true _ => false }) + let disagreeing = filter(pages, p => p.member_count != Present { value: total }) + let duplicated = first_duplicate(xs: links) + if count(disagreeing) > 0 { + CollectionRefused { detail: concat("a page reports Members@odata.count ", match disagreeing.first() { Absent => "" Present { value: p } => match p.member_count { Present { value: n } => to_string(n) Absent => "none" } }, " where the first page reported ", to_string(total)) as NonEmptyStr } + } else if duplicated != none { + CollectionRefused { detail: concat("member link ", match duplicated { Present { value: d } => d Absent => "" }, " is listed more than once") as NonEmptyStr } + } else if last_has_next { + CollectionRefused { detail: concat("the last page read still carries Members@odata.nextLink; ", to_string(count(links)), " of ", to_string(total), " member(s) read") as NonEmptyStr } + } else if total > member_bound { + CollectionRefused { detail: concat("Members@odata.count ", to_string(total), " exceeds the member bound ", to_string(member_bound)) as NonEmptyStr } + } else if count(links) != total { + CollectionRefused { detail: concat("Members@odata.count ", to_string(total), " but ", to_string(count(links)), " member link(s) across ", to_string(count(pages)), " page(s)") as NonEmptyStr } + } else if count(refused_links) > 0 { + CollectionRefused { detail: concat("member link is not a same-origin path: ", match refused_links.first() { Absent => "" Present { value: l } => l }) as NonEmptyStr } + } else { + CollectionComplete { links: map(links, l => l as NonEmptyStr) } + } + } + } + } +} + +fn first_duplicate(xs: List) -> String? { + let empty: List = [] + let found: String? = none + let done = fold(xs, init: MembersSeen { seen: empty, duplicate: found }, f: (acc, x) => match acc.duplicate { + Present { value: _ } => acc + Absent => if any(acc.seen, y => y == x) { MembersSeen { seen: acc.seen, duplicate: Present { value: x } } } else { MembersSeen { seen: concat(acc.seen, [x]), duplicate: none } } + }) + done.duplicate +} + +type MembersSeen { seen: List, duplicate: String? } + +// ── MEMBER IDENTITY (pure) ─────────────────────────────────────────────────────────────────── +// +// A COLLECTION IS IDENTITY-COMPLETE, NOT ONLY COUNT-COMPLETE: every member answered at the link that +// named it (its returned `@odata.id` is that link) and no two members returned one `Id`. A member +// that answers as another resource, or two links that resolve to one DIMM, would otherwise make a +// full count out of fewer slots. Any mismatch leaves the section unread, so no inventory-count +// finding can be minted from it. +type MemberBody { link: NonEmptyStr, body: String } + +fn member_link_mismatch(m: MemberBody) -> String? { + match redfish_resource_odata_id(body: m.body) { + ObservationRefused { cause: c } => Present { value: concat("member at ", m.link as String, ": ", c as String) } + ObservationEstablished { observed: returned } => + if (returned as String) == (m.link as String) { none } else { Present { value: concat("link ", m.link as String, " returned the resource ", returned as String) } } + } +} + +fn first_member_mismatch(bodies: List) -> String? { + match filter(map(bodies, b => member_link_mismatch(m: b)), r => r != none).first() { + Absent => none + Present { value: r } => r + } +} + +fn memory_member_ids(ms: List) -> List { + map(ms, m => m.id as String) +} + +fn processor_member_ids(ps: List) -> List { + map(ps, p => p.id as String) +} + +fn assemble_memory_members(collection: NonEmptyStr, at: NonEmptyStr, bodies: List) -> MembersReading { + match first_member_mismatch(bodies: bodies) { + Present { value: why } => MembersUnread { cause: BmcResponseMalformed { endpoint: mtcollins1_redfish_url(path: collection as String), at: at, detail: why } } + Absent => { + let empty: List = [] + let parsed = fold(bodies, init: MembersRead { members: empty }, f: (acc, b) => match acc { + MembersRead { members: ms } => match redfish_memory_member_of(body: b.body) { + ObservationRefused { cause: c } => MembersUnread { cause: BmcResponseMalformed { endpoint: mtcollins1_redfish_url(path: b.link as String), at: at, detail: c as String } } + ObservationEstablished { observed: m } => MembersRead { members: concat(ms, [m]) } + } + other => other + }) + match parsed { + MembersRead { members: ms } => match first_duplicate(xs: memory_member_ids(ms: ms)) { + Present { value: d } => MembersUnread { cause: BmcCollectionIncomplete { endpoint: mtcollins1_redfish_url(path: collection as String), at: at, detail: concat("two member links returned the same Id ", d) } } + Absent => parsed + } + other => other + } + } + } +} + +fn assemble_processor_members(collection: NonEmptyStr, at: NonEmptyStr, bodies: List) -> MembersReading { + match first_member_mismatch(bodies: bodies) { + Present { value: why } => MembersUnread { cause: BmcResponseMalformed { endpoint: mtcollins1_redfish_url(path: collection as String), at: at, detail: why } } + Absent => { + let empty: List = [] + let parsed = fold(bodies, init: MembersRead { members: empty }, f: (acc, b) => match acc { + MembersRead { members: ps } => match redfish_processor_member_of(body: b.body) { + ObservationRefused { cause: c } => MembersUnread { cause: BmcResponseMalformed { endpoint: mtcollins1_redfish_url(path: b.link as String), at: at, detail: c as String } } + ObservationEstablished { observed: p } => MembersRead { members: concat(ps, [p]) } + } + other => other + }) + match parsed { + MembersRead { members: ps } => match first_duplicate(xs: processor_member_ids(ps: ps)) { + Present { value: d } => MembersUnread { cause: BmcCollectionIncomplete { endpoint: mtcollins1_redfish_url(path: collection as String), at: at, detail: concat("two member links returned the same Id ", d) } } + Absent => parsed + } + other => other + } + } + } +} + +// ── REDFISH READS UNDER THE BUDGET ─────────────────────────────────────────────────────────── + +// THE BUDGET DECISION IS PURE: a read the budget cannot pay for is refused before any request is +// made, and the refusal names what the transaction did not reach. +fn redfish_budget_refusal(url: NonEmptyStr, at: NonEmptyStr, left: Int, not_reached: String) -> BmcReadCause? { + if left <= 0 { Present { value: BmcDeadlineReached { endpoint: url, at: at, not_reached: not_reached } } } else { none } +} + +type RedfishGet + = RedfishGot { body: String, left: Int } + | RedfishGetFailed { cause: BmcReadCause, left: Int } + +fn redfish_get(netrc: NonEmptyStr, path: NonEmptyStr, left: Int, not_reached: String) -> RedfishGet + uses net: std.resources.Network +{ + let at = clock_now_probed_at_or_unknown() + match redfish_budget_refusal(url: mtcollins1_redfish_url(path: path as String), at: at, left: left, not_reached: not_reached) { + Present { value: c } => return RedfishGetFailed { cause: c, left: left } + Absent => {} + } + let r = redfish.Http.GetResourceByPath( + bmc_host: mtcollins1_endpoint.host, + netrc_file: netrc, + odata_path: path, + max_seconds: to_string(second_count(s: mtcollins1_boot_redfish_read_deadline)) as NonEmptyStr, + ) + if r.success { + RedfishGot { body: r.body, left: left - 1 } + } else { + RedfishGetFailed { cause: bmc_curl_read_cause(endpoint: mtcollins1_redfish_url(path: path as String), at: at, exit_code: r.exit_code, stderr: r.transport_stderr), left: left - 1 } + } +} + +type CollectionFetch + = CollectionFetched { links: List, left: Int } + | CollectionFetchFailed { cause: BmcReadCause, left: Int } + +fn fetch_collection_pages( + netrc: NonEmptyStr, + collection: NonEmptyStr, + page: NonEmptyStr, + pages_left: Int, + left: Int, + read: List, +) -> CollectionFetch + uses net: std.resources.Network +{ + let at = clock_now_probed_at_or_unknown() + if pages_left <= 0 { + return CollectionFetchFailed { cause: BmcCollectionIncomplete { endpoint: mtcollins1_redfish_url(path: collection as String), at: at, detail: concat("page bound ", to_string(mtcollins1_boot_collection_page_bound), " reached with Members@odata.nextLink still pending") }, left: left } + } + match redfish_get(netrc: netrc, path: page, left: left, not_reached: concat("the rest of ", collection as String, " and every member of it")) { + RedfishGetFailed { cause: c, left: l } => CollectionFetchFailed { cause: c, left: l } + RedfishGot { body: body, left: l } => + match redfish_collection_page_of(body: body) { + ObservationRefused { cause: c } => CollectionFetchFailed { cause: BmcResponseMalformed { endpoint: mtcollins1_redfish_url(path: page as String), at: at, detail: c as String }, left: l } + ObservationEstablished { observed: p } => { + let pages = concat(read, [p]) + match p.next_link { + Present { value: next } => + match redfish_same_origin_link(link: next) { + RedfishLinkRefused { cause: why } => CollectionFetchFailed { cause: BmcCollectionIncomplete { endpoint: mtcollins1_redfish_url(path: page as String), at: at, detail: concat("Members@odata.nextLink not followed: ", why as String) }, left: l } + RedfishLinkSameOrigin { path: next_path } => fetch_collection_pages(netrc: netrc, collection: collection, page: next_path, pages_left: pages_left - 1, left: l, read: pages) + } + Absent => + match redfish_collection_assembly(pages: pages, member_bound: mtcollins1_boot_collection_member_bound) { + CollectionRefused { detail: d } => CollectionFetchFailed { cause: BmcCollectionIncomplete { endpoint: mtcollins1_redfish_url(path: collection as String), at: at, detail: d as String }, left: l } + CollectionComplete { links: links } => CollectionFetched { links: links, left: l } + } + } + } + } + } +} + +fn fetch_collection(netrc: NonEmptyStr, collection: NonEmptyStr, left: Int) -> CollectionFetch + uses net: std.resources.Network +{ + fetch_collection_pages(netrc: netrc, collection: collection, page: collection, pages_left: mtcollins1_boot_collection_page_bound, left: left, read: []) +} + +type MemoryFold { reading: MembersReading, left: Int } + +type ProcessorFold { reading: MembersReading, left: Int } + +fn member_not_reached(total: Int, read: Int) -> String { + concat(to_string(total - read), " of ", to_string(total), " member read(s)") +} + +type MemberBodiesFetch + = MemberBodiesFetched { bodies: List, left: Int } + | MemberBodiesFailed { cause: BmcReadCause, left: Int } + +fn fetch_member_bodies(netrc: NonEmptyStr, links: List, left: Int) -> MemberBodiesFetch + uses net: std.resources.Network +{ + let empty: List = [] + fold(links, init: MemberBodiesFetched { bodies: empty, left: left }, f: (acc, link) => match acc { + MemberBodiesFetched { bodies: bs, left: l } => + match redfish_get(netrc: netrc, path: link, left: l, not_reached: member_not_reached(total: count(links), read: count(bs))) { + RedfishGetFailed { cause: c, left: l2 } => MemberBodiesFailed { cause: c, left: l2 } + RedfishGot { body: body, left: l2 } => MemberBodiesFetched { bodies: concat(bs, [MemberBody { link: link, body: body }]), left: l2 } + } + other => other + }) +} + +fn read_memory_members(netrc: NonEmptyStr, collection: NonEmptyStr, links: List, left: Int) -> MemoryFold + uses net: std.resources.Network +{ + match fetch_member_bodies(netrc: netrc, links: links, left: left) { + MemberBodiesFailed { cause: c, left: l } => MemoryFold { reading: MembersUnread { cause: c }, left: l } + MemberBodiesFetched { bodies: bs, left: l } => MemoryFold { reading: assemble_memory_members(collection: collection, at: clock_now_probed_at_or_unknown(), bodies: bs), left: l } + } +} + +fn read_processor_members(netrc: NonEmptyStr, collection: NonEmptyStr, links: List, left: Int) -> ProcessorFold + uses net: std.resources.Network +{ + match fetch_member_bodies(netrc: netrc, links: links, left: left) { + MemberBodiesFailed { cause: c, left: l } => ProcessorFold { reading: MembersUnread { cause: c }, left: l } + MemberBodiesFetched { bodies: bs, left: l } => ProcessorFold { reading: assemble_processor_members(collection: collection, at: clock_now_probed_at_or_unknown(), bodies: bs), left: l } + } +} + +fn link_absent_cause(system: NonEmptyStr, property: String) -> BmcReadCause { + BmcResponseMalformed { endpoint: mtcollins1_redfish_url(path: system as String), at: clock_now_probed_at_or_unknown(), detail: concat("the ComputerSystem publishes no ", property, " link, or a link that is not a same-origin path") } +} + +fn same_origin_or_none(link: String?) -> NonEmptyStr? { + match link { + Absent => none + Present { value: l } => match redfish_same_origin_link(link: l) { + RedfishLinkSameOrigin { path: p } => Present { value: p } + RedfishLinkRefused { cause: _ } => none + } + } +} + +fn read_processors(netrc: NonEmptyStr, system: NonEmptyStr, link: String?, left: Int) -> ProcessorFold + uses net: std.resources.Network +{ + match same_origin_or_none(link: link) { + Absent => ProcessorFold { reading: MembersUnread { cause: link_absent_cause(system: system, property: "Processors") }, left: left } + Present { value: path } => + match fetch_collection(netrc: netrc, collection: path, left: left) { + CollectionFetchFailed { cause: c, left: l } => ProcessorFold { reading: MembersUnread { cause: c }, left: l } + CollectionFetched { links: links, left: l } => read_processor_members(netrc: netrc, collection: path, links: links, left: l) + } + } +} + +fn read_memory(netrc: NonEmptyStr, system: NonEmptyStr, link: String?, left: Int) -> MemoryFold + uses net: std.resources.Network +{ + match same_origin_or_none(link: link) { + Absent => MemoryFold { reading: MembersUnread { cause: link_absent_cause(system: system, property: "Memory") }, left: left } + Present { value: path } => + match fetch_collection(netrc: netrc, collection: path, left: left) { + CollectionFetchFailed { cause: c, left: l } => MemoryFold { reading: MembersUnread { cause: c }, left: l } + CollectionFetched { links: links, left: l } => read_memory_members(netrc: netrc, collection: path, links: links, left: l) + } + } +} + +// THE SELECTED SYSTEM IS IDENTITY-JOINED BEFORE ITS LINKS ARE FOLLOWED: the ComputerSystem that +// answered must return, as its own @odata.id, the link the Systems collection named. A system that +// answers as another resource would otherwise hand this attempt some other system's Memory and +// Processors, and every count finding after it would be about the wrong machine. +fn mtcollins1_system_inventory_links(requested: NonEmptyStr, body: String) -> ObservationAttempt { + match redfish_resource_odata_id(body: body) { + ObservationRefused { cause: c } => ObservationRefused { cause: c } + ObservationEstablished { observed: returned } => + if (returned as String) != (requested as String) { + ObservationRefused { cause: concat("system link ", requested as String, " returned the resource ", returned as String) as NonEmptyStr } + } else { + redfish_system_inventory_links_of(body: body) + } + } +} + +fn inventory_unread(cause: BmcReadCause) -> InventoryReading { + InventoryReading { system_id: "", memory: MembersUnread { cause: cause }, processors: MembersUnread { cause: cause }, credential_removed: true } +} + +data mtcollins1_redfish_systems_path: NonEmptyStr = "/redfish/v1/Systems" + +// THE SYSTEM IS READ, NOT ASSUMED: the Systems collection must name exactly one member, whose own +// Memory and Processors links name the collections read next. Zero or several systems is a typed +// reading, since picking one would be a guess about which system the attempt booted. +fn read_inventory_with_netrc(netrc: NonEmptyStr) -> InventoryReading + uses net: std.resources.Network +{ + let at = clock_now_probed_at_or_unknown() + match fetch_collection(netrc: netrc, collection: mtcollins1_redfish_systems_path, left: mtcollins1_boot_redfish_read_budget) { + CollectionFetchFailed { cause: c, left: _ } => inventory_unread(cause: c) + CollectionFetched { links: systems, left: left } => + if count(systems) != 1 { + inventory_unread(cause: BmcResponseMalformed { endpoint: mtcollins1_redfish_url(path: mtcollins1_redfish_systems_path as String), at: at, detail: concat("Systems collection has ", to_string(count(systems)), " members; exactly one names the booted system") }) + } else { + match systems.first() { + Absent => inventory_not_taken(reason: "Systems collection member vanished between count and read") + Present { value: system } => + match redfish_get(netrc: netrc, path: system, left: left, not_reached: "the system resource and every inventory read after it") { + RedfishGetFailed { cause: c, left: _ } => inventory_unread(cause: c) + RedfishGot { body: body, left: l } => + match mtcollins1_system_inventory_links(requested: system, body: body) { + ObservationRefused { cause: c } => inventory_unread(cause: BmcResponseMalformed { endpoint: mtcollins1_redfish_url(path: system as String), at: at, detail: c as String }) + ObservationEstablished { observed: links } => { + let processors = read_processors(netrc: netrc, system: system, link: links.processors, left: l) + let memory = read_memory(netrc: netrc, system: system, link: links.memory, left: processors.left) + InventoryReading { system_id: system as String, memory: memory.reading, processors: processors.reading, credential_removed: true } + } + } + } + } + } + } +} + +fn mtcollins1_boot_inventory(username: NonEmptyStr, password: String) -> InventoryReading + uses net: std.resources.Network +{ + let at = clock_now_probed_at_or_unknown() + let endpoint = mtcollins1_redfish_url(path: mtcollins1_redfish_systems_path as String) + match place_netrc_binding_privately(machine: mtcollins1_endpoint.host, login: username, password: trim(s: password) as Secret) { + NetrcBindingRefused { cause: c } => inventory_unread(cause: BmcCredentialUnavailable { endpoint: endpoint, at: at, detail: c as String }) + NetrcBindingRefusedResidueRemains { cause: c } => { + let cause = BmcCredentialUnavailable { endpoint: endpoint, at: at, detail: c as String } + InventoryReading { system_id: "", memory: MembersUnread { cause: cause }, processors: MembersUnread { cause: cause }, credential_removed: false } + } + NetrcBindingPlaced { binding: binding } => { + let read = read_inventory_with_netrc(netrc: binding.path as NonEmptyStr) + let removed = shred_netrc_binding(binding: binding) + InventoryReading { system_id: read.system_id, memory: read.memory, processors: read.processors, credential_removed: removed } + } + } +} + +fn console_path_retained(path: String) -> Bool { + starts_with(s: path, prefix: mtcollins1_boot_retained_artifact_prefix) || string_contains(s: path, pattern: concat("/", mtcollins1_boot_retained_artifact_prefix)) +} + +fn console_size_of_stat(size_text: String) -> ByteSize? { + match parse_int(s: trim(size_text)) { + Absent => none + Present { value: n } => if n < 0 { none } else { Present { value: byte_size(count: n as Nat) } } + } +} + +// THE PURE DECISION over the capture's stat size and, when within the bound, its content. +fn mtcollins1_boot_console_reading(path: String, size: ByteSize, capture: String, read_ok: Bool, read_error: String) -> ConsoleReading { + if path == "" { + ConsoleNotConfigured + } else if !console_path_retained(path: path) { + ConsoleNotRetained { path: path as NonEmptyStr } + } else if (byte_size_count(b: size) as Int) > (byte_size_count(b: mtcollins1_boot_console_bound) as Int) { + ConsoleExceedsBound { path: path as NonEmptyStr, size: size, bound: mtcollins1_boot_console_bound } + } else if !read_ok { + ConsoleUnread { path: path as NonEmptyStr, detail: read_error } + } else { + let lines = host_capture_lines(capture: HostCaptureLiveStream { text: capture }) + ConsoleRetained { path: path as NonEmptyStr, size: size, lines: count(lines), firmware: firmware_console_report(lines: lines), dram: ampere_dram_console_observation(lines: lines) } + } +} + +fn mtcollins1_boot_console(path: String) -> ConsoleReading { + if path == "" { + ConsoleNotConfigured + } else if !console_path_retained(path: path) { + ConsoleNotRetained { path: path as NonEmptyStr } + } else { + let st = coreutils.Stat.PathSize(path: path as NonEmptyStr) + match if st.success { console_size_of_stat(size_text: st.size_text) } else { none } { + Absent => ConsoleUnread { path: path as NonEmptyStr, detail: concat("stat -c %s could not size the capture: ", trim(st.size_text)) } + Present { value: size } => + if (byte_size_count(b: size) as Int) > (byte_size_count(b: mtcollins1_boot_console_bound) as Int) { + ConsoleExceedsBound { path: path as NonEmptyStr, size: size, bound: mtcollins1_boot_console_bound } + } else { + let r = Filesystem.Read(path: path) + mtcollins1_boot_console_reading(path: path, size: size, capture: r.content, read_ok: r.success, read_error: r.error) + } + } + } +} + +// THE BUNDLE IS WRITTEN, AND WHETHER IT WAS IS ITSELF A LINE IN THE RECEIPT. A failed write on a +// refused attempt is also appended to the refusal reason. On an accepted attempt the receipt line +// is the only place it can go, because the bundle may not flip the verdict. +type BundleWrite = BundleWritten | BundleWriteFailed { error: String } + +fn bundle_write_receipt_line(w: BundleWrite) -> String { + match w { + BundleWritten => concat("diagnostics=", mtcollins1_boot_diagnostics_path) + BundleWriteFailed { error: e } => concat("diagnostics=write-failed: ", e) + } +} + +fn mtcollins1_boot_write_bundle(bundle: MtCollins1BootDiagnosticBundle) -> BundleWrite { + let written = Filesystem.Write(path: mtcollins1_boot_diagnostics_path, content: mtcollins1_boot_bundle_text(bundle: bundle)) + if written.success { BundleWritten } else { BundleWriteFailed { error: written.error } } +} + +fn mtcollins1_boot_outcome_after_bundle(outcome: ProcessExit, bundle: MtCollins1BootDiagnosticBundle, write: BundleWrite) -> ProcessExit { + let with_findings = mtcollins1_boot_outcome_with_findings(outcome: outcome, findings: mtcollins1_boot_bundle_findings(bundle: bundle)) + match write { + BundleWritten => with_findings + BundleWriteFailed { error: e } => + match with_findings { + ExitSuccess => ExitSuccess + ExitFailure { code: c, reason: r } => ExitFailure { code: c, reason: concat(r, " | diagnostics bundle could not be written: ", e) } + } + } +} diff --git a/dag/gunbc/machine_intake/mtcollins1_boot_run.dag b/dag/gunbc/machine_intake/mtcollins1_boot_run.dag index efab5ffcc6d..1a2d995dc57 100644 --- a/dag/gunbc/machine_intake/mtcollins1_boot_run.dag +++ b/dag/gunbc/machine_intake/mtcollins1_boot_run.dag @@ -56,11 +56,17 @@ import extdeps.bootloader.grub { import gunbc.machine_intake_mtcollins1_access_observation { mtcollins1_endpoint, mtcollins1_capability_row } import gunbc.host_reset_return_run { host_reset_bmc_credential_path_env } import v2.std.optional { Present } -import gunbc.actions_run_binding { actions_variable_read, ActionsVariablePresent, ActionsVariableAbsent, actions_variable_trimmed, fleet_converge_expected_host_env_name } +import gunbc.actions_run_binding { ActionsVariableRead, actions_variable_read, ActionsVariablePresent, ActionsVariableAbsent, actions_variable_trimmed, fleet_converge_expected_host_env_name } import gunbc.fleet_intent_network { operator_host_srv1 } import extdeps.github.actions_environment { github_run_id_variable_name, github_sha_variable_name } import extdeps.bmc.ipmi import gunbc.machine_intake_sol_hold { mtcollins1_sol_hold_shell_emit_dissolution_trigger } +import gunbc.machine_intake_mtcollins1_boot_diagnostic_bundle { + MtCollins1BootDiagnosticBundle, SelSnapshotReading, SelSnapshotNotTaken, inventory_not_taken, + mtcollins1_boot_sel_snapshot, mtcollins1_boot_inventory, mtcollins1_boot_console, + mtcollins1_boot_write_bundle, mtcollins1_boot_outcome_after_bundle, mtcollins1_boot_bundle_findings, bundle_write_receipt_line, + mtcollins1_boot_diagnostics_allowance, AttemptIdentityReading, AttemptRunId, AttemptIdentityUnavailable, attempt_identity_text, +} import std.dissolution { dissolution_description } import extdeps.tools.sleep { sleep_delay_seconds_second_carrier_projection } import extdeps.filesystem.filesystem_io { Filesystem } @@ -90,6 +96,7 @@ data mtcollins1_boot_actuation_allowance: Second = second(count: 480) data mtcollins1_boot_cleanup_allowance: Second = second(count: 180) + data mtcollins1_boot_submit_timeout: Second = second(count: 30) data mtcollins1_boot_submit_body_file_name: String = "mtcollins1-approval-submit.json" @@ -104,6 +111,7 @@ fn mtcollins1_boot_step_timeout_minutes() -> Minute { + second_count(s: mtcollins1_boot_issue_allowance) + second_count(s: mtcollins1_boot_actuation_allowance) + second_count(s: mtcollins1_boot_cleanup_allowance) + + second_count(s: mtcollins1_boot_diagnostics_allowance()) minute(count: (secs + 59) / 60) } @@ -851,30 +859,128 @@ fn mtcollins1_boot_refuses_off_srv1(host: String) -> ProcessExit { } } +// EVERY TERMINAL ARM OF A BOOT ATTEMPT GOES THROUGH mtcollins1_boot_conclude, which writes the +// diagnostic bundle (gunbc.machine_intake_mtcollins1_boot_diagnostic_bundle) and the receipt, and +// appends the bundle's decisive findings to a refusal reason. The attempt below therefore returns a +// RECORD of how far it got with the BMC instead of a bare exit: an attempt that refused before the +// credential was read carries that reason, and the bundle says the BMC sections were NOT TAKEN and +// why, rather than leaving them out (brief, 2026-09-23: accepted, refused, timed out, approval +// expired and pre-OS refusal each upload a bundle). +type MtCollins1BootBmcAccess + = BmcAccessNotReached { reason: NonEmptyStr } + | BmcAccessHeld { username: NonEmptyStr, password_file: NonEmptyStr, password: String, sel_before: SelSnapshotReading } + +type MtCollins1BootAttempt { + outcome: ProcessExit + escalation_id: NonEmptyStr? + bmc: MtCollins1BootBmcAccess +} + +fn mtcollins1_boot_exit_reason(outcome: ProcessExit) -> String { + match outcome { + ExitSuccess => "ok" + ExitFailure { code: _, reason: r } => concat("refused: ", r) + } +} + +fn mtcollins1_boot_ended_before_bmc(outcome: ProcessExit, escalation_id: NonEmptyStr?) -> MtCollins1BootAttempt { + MtCollins1BootAttempt { + outcome: outcome, + escalation_id: escalation_id, + bmc: BmcAccessNotReached { reason: concat("the attempt ended before the BMC credential was read (", mtcollins1_boot_exit_reason(outcome: outcome), ")") as NonEmptyStr }, + } +} + +fn mtcollins1_boot_bundle_of_attempt(attempt: MtCollins1BootAttempt, run: AttemptIdentityReading, capture_path: String) -> MtCollins1BootDiagnosticBundle + uses net: std.resources.Network +{ + match attempt.bmc { + BmcAccessNotReached { reason: why } => + MtCollins1BootDiagnosticBundle { + attempt: run, + outcome: mtcollins1_boot_exit_reason(outcome: attempt.outcome), + sel_before: SelSnapshotNotTaken { reason: why }, + sel_after: SelSnapshotNotTaken { reason: why }, + inventory: inventory_not_taken(reason: why), + console: mtcollins1_boot_console(path: capture_path), + } + BmcAccessHeld { username: user, password_file: pf, password: pw, sel_before: before } => + MtCollins1BootDiagnosticBundle { + attempt: run, + outcome: mtcollins1_boot_exit_reason(outcome: attempt.outcome), + sel_before: before, + sel_after: mtcollins1_boot_sel_snapshot(username: user, password_file: pf), + inventory: mtcollins1_boot_inventory(username: user, password: pw), + console: mtcollins1_boot_console(path: capture_path), + } + } +} + +// THE ATTEMPT'S IDENTITY IS READ, AND A READ THAT FAILED IS CARRIED AS ITS CAUSE, never a blank. +fn mtcollins1_boot_attempt_identity(read: ActionsVariableRead) -> AttemptIdentityReading { + match read { + ActionsVariablePresent { value: v } => + if trim(s: v) == "" { AttemptIdentityUnavailable { variable: github_run_id_variable_name as NonEmptyStr, detail: "present but empty" } } + else { AttemptRunId { run_id: trim(s: v) as NonEmptyStr } } + ActionsVariableAbsent { variable: _, detail: d } => AttemptIdentityUnavailable { variable: github_run_id_variable_name as NonEmptyStr, detail: d } + } +} + +fn mtcollins1_boot_conclude(attempt: MtCollins1BootAttempt) -> ProcessExit + uses net: std.resources.Network +{ + let run = mtcollins1_boot_attempt_identity(read: actions_variable_read(name: github_run_id_variable_name)) + let bundle = mtcollins1_boot_bundle_of_attempt(attempt: attempt, run: run, capture_path: actions_variable_trimmed(name: mtcollins1_boot_sol_capture_path_env)) + let write = mtcollins1_boot_write_bundle(bundle: bundle) + let concluded = mtcollins1_boot_outcome_after_bundle(outcome: attempt.outcome, bundle: bundle, write: write) + let findings = mtcollins1_boot_bundle_findings(bundle: bundle) + let exit_word = match concluded { ExitSuccess => "ok" _ => "refused" } + let receipt_body = join([ + concat("escalation_id=", match attempt.escalation_id { Present { value: e } => e as String Absent => "not-filed (the attempt ended before an approval request was filed)" }), + concat("attempt=", attempt_identity_text(a: run)), + concat("exit=", exit_word), + bundle_write_receipt_line(w: write), + concat("findings=", if count(findings) == 0 { "none" } else { join(findings, "; ") }), + ], "\n") + let kept = Filesystem.Write(path: mtcollins1_boot_receipt_path, content: receipt_body) + if !kept.success { + return match concluded { + ExitSuccess => exit_failure(reason: concat("mtcollins1 boot: could not write receipt: ", kept.error)) + ExitFailure { code: c, reason: r } => ExitFailure { code: c, reason: concat(r, " | could not write receipt: ", kept.error) } + } + } + concluded +} + fn mtcollins1_boot_wet() -> ProcessExit uses net: std.resources.Network { - match actions_variable_read(name: fleet_converge_expected_host_env_name) { + let attempt = match actions_variable_read(name: fleet_converge_expected_host_env_name) { ActionsVariableAbsent { variable: v, detail: d } => - exit_failure(reason: concat("mtcollins1 boot: ", concat(v, concat(" ", concat(d, "; loopback filing is srv1 only"))))) + mtcollins1_boot_ended_before_bmc(outcome: exit_failure(reason: concat("mtcollins1 boot: ", concat(v, concat(" ", concat(d, "; loopback filing is srv1 only"))))), escalation_id: none) ActionsVariablePresent { value: host } => match mtcollins1_boot_refuses_off_srv1(host: host) { ExitSuccess => mtcollins1_boot_wet_on_srv1() - other => other + other => mtcollins1_boot_ended_before_bmc(outcome: other, escalation_id: none) } } + mtcollins1_boot_conclude(attempt: attempt) } -fn mtcollins1_boot_wet_on_srv1() -> ProcessExit +// THE "BEFORE" SEL SNAPSHOT IS TAKEN ONCE THE CREDENTIAL IS READ AND BEFORE THE GATE'S ARM ACTS, so +// that the delta brackets every controller write the attempt makes. It is a readonly read, and +// taking it on a refused gate (approval expired or denied) still records what the BMC logged over +// the approval window. +fn mtcollins1_boot_wet_on_srv1() -> MtCollins1BootAttempt uses net: std.resources.Network { let cred = actions_variable_trimmed(name: host_reset_bmc_credential_path_env) if cred == "" { - return exit_failure(reason: concat("mtcollins1 boot: ", concat(host_reset_bmc_credential_path_env as String, " is unset; controller untouched"))) + return mtcollins1_boot_ended_before_bmc(outcome: exit_failure(reason: concat("mtcollins1 boot: ", concat(host_reset_bmc_credential_path_env as String, " is unset; controller untouched"))), escalation_id: none) } let sub_path = actions_variable_trimmed(name: approval_submission_mac_key_path_env) if sub_path == "" { - return exit_failure(reason: concat("mtcollins1 boot: ", concat(approval_submission_mac_key_path_env as String, " is unset; controller untouched"))) + return mtcollins1_boot_ended_before_bmc(outcome: exit_failure(reason: concat("mtcollins1 boot: ", concat(approval_submission_mac_key_path_env as String, " is unset; controller untouched"))), escalation_id: none) } let sol_pid_path = actions_variable_trimmed(name: mtcollins1_boot_sol_pid_path_env) let sol_capture_path = actions_variable_trimmed(name: mtcollins1_boot_sol_capture_path_env) @@ -883,21 +989,21 @@ fn mtcollins1_boot_wet_on_srv1() -> ProcessExit ActionsVariableAbsent { variable: _, detail: _ } => "" } if run_id == "" { - return exit_failure(reason: "mtcollins1 boot: GITHUB_RUN_ID is unset; refusing rather than reusing a standing escalation id") + return mtcollins1_boot_ended_before_bmc(outcome: exit_failure(reason: "mtcollins1 boot: GITHUB_RUN_ID is unset; refusing rather than reusing a standing escalation id"), escalation_id: none) } let sha = match actions_variable_read(name: github_sha_variable_name) { ActionsVariablePresent { value: v } => v ActionsVariableAbsent { variable: _, detail: _ } => "" } if sha == "" { - return exit_failure(reason: "mtcollins1 boot: GITHUB_SHA is unset; the signed subject binds the execution revision") + return mtcollins1_boot_ended_before_bmc(outcome: exit_failure(reason: "mtcollins1 boot: GITHUB_SHA is unset; the signed subject binds the execution revision"), escalation_id: none) } match mtcollins1_boot_medium_refusal(medium: mtcollins1_boot_medium) { - Present { value: why } => return exit_failure(reason: why) + Present { value: why } => return mtcollins1_boot_ended_before_bmc(outcome: exit_failure(reason: why), escalation_id: none) Absent => {} } match mtcollins1_census_readback_refusal_before_filing(readback: mtcollins1_census_medium_readback(medium: mtcollins1_boot_medium)) { - Present { value: why } => return exit_failure(reason: why) + Present { value: why } => return mtcollins1_boot_ended_before_bmc(outcome: exit_failure(reason: why), escalation_id: none) Absent => {} } let escalation = concat("mtcollins1-boot-", run_id) as NonEmptyStr @@ -908,12 +1014,12 @@ fn mtcollins1_boot_wet_on_srv1() -> ProcessExit ) match approval_instant_now() { Absent => - exit_failure(reason: "mtcollins1 boot: clock unreadable; cannot mint issued_at or an approval window; controller untouched") + mtcollins1_boot_ended_before_bmc(outcome: exit_failure(reason: "mtcollins1 boot: clock unreadable; cannot mint issued_at or an approval window; controller untouched"), escalation_id: Present { value: escalation }) Present { value: issued } => { let expires = approval_expires_at(issued: issued, window: mtcollins1_boot_approval_window()) match approval_file_stored_request(stored: stored_request_from_authorization(request: request, issued_at: issued, expires_at: expires), body_file_name: mtcollins1_boot_submit_body_file_name, submit_timeout: mtcollins1_boot_submit_timeout) { ApprovalFilingRefused { reason: r } => - exit_failure(reason: concat("mtcollins1 boot: ", concat(r, "; controller untouched"))) + mtcollins1_boot_ended_before_bmc(outcome: exit_failure(reason: concat("mtcollins1 boot: ", concat(r, "; controller untouched"))), escalation_id: Present { value: escalation }) ApprovalFiled => { let gate = approval_gate_from_outcome( outcome: approval_poll_ticks( @@ -926,23 +1032,32 @@ fn mtcollins1_boot_wet_on_srv1() -> ProcessExit ) let pw_read = Filesystem.Read(path: cred) if !pw_read.success { - return exit_failure(reason: concat("mtcollins1 boot: BMC credential unreadable after approval: ", pw_read.error)) + return mtcollins1_boot_ended_before_bmc(outcome: exit_failure(reason: concat("mtcollins1 boot: BMC credential unreadable after approval: ", pw_read.error)), escalation_id: Present { value: escalation }) } - let actuated = mtcollins1_boot_after_gate( - gate: gate, - request: request, - password_file: cred, - attempt: run_id, - sol_pid_path: sol_pid_path, - sol_capture_path: sol_capture_path, - ) - let exit_word = match actuated { ExitSuccess => "ok" _ => "refused" } - let receipt_body = concat("escalation_id=", concat(escalation as String, concat("\nexit=", exit_word))) - let kept = Filesystem.Write(path: mtcollins1_boot_receipt_path, content: receipt_body) - if !kept.success { - return exit_failure(reason: concat("mtcollins1 boot: could not write receipt: ", kept.error)) + match mtcollins1_bmc_username { + Absent => + MtCollins1BootAttempt { + outcome: mtcollins1_boot_after_gate(gate: gate, request: request, password_file: cred, attempt: run_id, sol_pid_path: sol_pid_path, sol_capture_path: sol_capture_path), + escalation_id: Present { value: escalation }, + bmc: BmcAccessNotReached { reason: "mtcollins1's BMC is not BmcSecured, so no account is modeled to read it with" }, + } + Present { value: user } => { + let before = mtcollins1_boot_sel_snapshot(username: user, password_file: cred as NonEmptyStr) + let actuated = mtcollins1_boot_after_gate( + gate: gate, + request: request, + password_file: cred, + attempt: run_id, + sol_pid_path: sol_pid_path, + sol_capture_path: sol_capture_path, + ) + MtCollins1BootAttempt { + outcome: actuated, + escalation_id: Present { value: escalation }, + bmc: BmcAccessHeld { username: user, password_file: cred as NonEmptyStr, password: pw_read.content, sel_before: before }, + } + } } - actuated } } } diff --git a/dag/gunbc/machine_intake/sel_stimulus_listener.dag b/dag/gunbc/machine_intake/sel_stimulus_listener.dag index 3cdce0df7b6..4ab74ccd7fe 100644 --- a/dag/gunbc/machine_intake/sel_stimulus_listener.dag +++ b/dag/gunbc/machine_intake/sel_stimulus_listener.dag @@ -36,6 +36,13 @@ fn sel_field(fields: List, index: Int) -> String { match fields.skip(n: index).first() { Absent => "" Present { value: field } => field } } +// A THRESHOLD EVENT CARRIES A SEVENTH FIELD. ipmitool renders a threshold-sensor record with its +// reading appended ("... | Asserted | Reading 0 < Threshold 0.68 Volts"), and mtcollins1's +// controller emits exactly those rows -- gunbc.machine_intake_mtcollins1_32dimm_bringup_observation +// transcribes records 1084..1099 in that shape. A reader that admitted only six fields refused the +// real log from the first threshold row, so a before/after snapshot of this BMC could never be +// taken. The seventh field is admitted only when it is a rendered reading; any other seven-field +// row stays refused. fn sel_rendered_record(line: String) -> ObservationAttempt { let fields = map(split(s: line, delimiter: "|"), field => trim(field)) let id = sel_record_id(text: sel_field(fields: fields, index: 0)) @@ -47,7 +54,7 @@ fn sel_rendered_record(line: String) -> ObservationAttempt ObservationRefused { cause: "SEL record id is not a rendered 16-bit hexadecimal id" } Present { value: record_id } => - if count(fields) != 6 || date == "" || clock == "" || sensor == "" { + if (count(fields) != 6 && !(count(fields) == 7 && starts_with(s: sel_field(fields: fields, index: 6), prefix: "Reading "))) || date == "" || clock == "" || sensor == "" { ObservationRefused { cause: "SEL record is truncated or unrecognized" } } else { ObservationEstablished { observed: SelWindowEvent { diff --git a/dag/test/claim/machine_intake/ampere_dram_console_observation_witness_test.dag b/dag/test/claim/machine_intake/ampere_dram_console_observation_witness_test.dag new file mode 100644 index 00000000000..620fc13cfd6 --- /dev/null +++ b/dag/test/claim/machine_intake/ampere_dram_console_observation_witness_test.dag @@ -0,0 +1,179 @@ +module test.claim.machine_intake.ampere_dram_console_observation_witness_test + +import v2.std.live_tree { LiveTreeDisposition, SubstrateInputsOnly } +import std.types { Bool, List, String } +import gunbc.machine_intake_ampere_dram_console_observation { + AmpereDramBlockNotPrinted, AmpereDramBlockObserved, RosterNotObserved, RosterOpen, RosterClosed, + ampere_dram_console_observation, ampere_dram_findings, ampere_dram_console_text, ampere_dram_dimms_on_socket, +} +import gunbc.machine_intake_host_capture_envelope { HostCaptureLiveStream, host_capture_lines } + +data live_tree_disposition: LiveTreeDisposition = SubstrateInputsOnly + +// SUPPLIED FIXTURES: EXACT BYTES of two real mtcollins1 SOL captures, read with +// `gh run download -n mtcollins1-boot-receipts`. Each excerpt is a contiguous line range +// of the uploaded file, CR and NUL bytes included, escaped only as .dag string syntax requires. +// run 35801475989, artifact mtcollins1-boot-receipts, file mtcollins1-boot-sol.capture (sha256 cd53370a1dc09abf3eea2efd8cefa47327ee03daa5eb2ad69eb059965164b4b5), +// lines 3-13 verbatim including CR and NUL bytes; excerpt sha256 6fb09373894656f891e3d3834d25eff11eb110bd4f51abcc6427ce15bb52036f. +data capture_35801475989_first_block: String = "Checkpoint B4\r\n\0NOTICE: DRAM FW version 210525\r\nCP: 0ff00900\r\nMEMC param:\r\n mcu_enable_mask = 00000011 [default: 000000ff]\r\nMCU param:\r\n ecc_en = 00000002 [default: 00000001]\r\nDRAM populated DIMMs:\r\n SK0 MC0 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[b3:80] HMA82GR7AFR4N-VK \r\n SK0 MC4 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[32:86] HMA82GR7AFR4N-VK \r\nCP: 3ff00100\r\n" + +// run 35801475989, artifact mtcollins1-boot-receipts, file mtcollins1-boot-sol.capture (sha256 cd53370a1dc09abf3eea2efd8cefa47327ee03daa5eb2ad69eb059965164b4b5), +// lines 56-67 verbatim including CR and NUL bytes; excerpt sha256 0f40d0d8a56c1c28c4f900c75f41461a9e623c9e323a4a061a0a8666e599d56a. +data capture_35801475989_last_block: String = "CP: 04001a0a\r\nCP: 00001a0a\r\nNOTICE: DRAM FW version 210525\r\nCP: 0ff00900\r\nMEMC param:\r\n mcu_enable_mask = 00000011 [default: 000000ff]\r\nMCU param:\r\n ecc_en = 00000002 [default: 00000001]\r\nDRAM populated DIMMs:\r\n SK0 MC0 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[b3:80] HMA82GR7AFR4N-VK \r\n SK0 MC4 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[32:86] HMA82GR7AFR4N-VK \r\nCP: 3ff00100\r\n" + +// run 35793279839, artifact mtcollins1-boot-receipts, file mtcollins1-boot-sol.capture (sha256 01b11164fbafddfb4123ca3b49c1dfae731b961d7ef3cfcf6b630996d2a1715b), +// lines 166-182 verbatim including CR and NUL bytes; excerpt sha256 8633cce0b0c66042b4b1f2882e84be58518c4f8fc655077cc1437d08737f91a6. +data capture_35793279839_last_block: String = "CP: 07f01a07\r\nCP: 07001a09\r\nNOTICE: DRAM FW version 210525\r\nCP: 0ff00900\r\nMCU param:\r\n ecc_en = 00000002 [default: 00000001]\r\nDRAM populated DIMMs:\r\n SK0 MC0 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[b3:80] HMA82GR7AFR4N-VK \r\n SK0 MC1 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[b3:80] HMA82GR7AFR4N-VK \r\n SK0 MC2 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[32:86] HMA82GR7AFR4N-VK \r\n SK0 MC3 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[32:86] HMA82GR7AFR4N-VK \r\n SK0 MC4 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[32:86] HMA82GR7AFR4N-VK \r\n SK0 MC5 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[b3:80] HMA82GR7AFR4N-VK \r\n SK0 MC6 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[32:86] HMA82GR7AFR4N-VK \r\n SK0 MC7 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[b3:80] HMA82GR7AFR4N-VK \r\nCP: 3ff00100\r\nCP: 3ff00200\r\n" + +fn lines_of(text: String) -> List { + host_capture_lines(capture: HostCaptureLiveStream { text: text }) +} + +fn any_contains(xs: List, pattern: String) -> Bool { + any(xs, x => contains(x, pattern)) +} + +// ── POSITIVE, OVER THE REAL BYTES ──────────────────────────────────────────────────────────── + +test fn run_35801475989_reads_version_params_and_two_sk0_dimms() -> Bool { + match ampere_dram_console_observation(lines: lines_of(text: capture_35801475989_last_block)) { + AmpereDramBlockObserved { block: b, blocks_printed: n } => + (b.firmware_version as String) == "210525" && n == 1 + && count(b.params) == 2 + && ampere_dram_dimms_on_socket(block: b, socket: 0) == 2 + && ampere_dram_dimms_on_socket(block: b, socket: 1) == 0 + && count(b.malformed) == 0 + AmpereDramBlockNotPrinted => false + } +} + +test fn run_35793279839_reads_eight_sk0_dimms_one_per_controller() -> Bool { + match ampere_dram_console_observation(lines: lines_of(text: capture_35793279839_last_block)) { + AmpereDramBlockObserved { block: b, blocks_printed: _ } => + ampere_dram_dimms_on_socket(block: b, socket: 0) == 8 + && ampere_dram_dimms_on_socket(block: b, socket: 1) == 0 + && count(b.params) == 1 + && count(filter(b.dimms, d => d.memory_controller == 7 && d.slot == 0)) == 1 + && count(b.malformed) == 0 + AmpereDramBlockNotPrinted => false + } +} + +test fn the_nul_before_the_first_notice_does_not_hide_the_block() -> Bool { + match ampere_dram_console_observation(lines: lines_of(text: capture_35801475989_first_block)) { + AmpereDramBlockObserved { block: b, blocks_printed: _ } => ampere_dram_dimms_on_socket(block: b, socket: 0) == 2 + AmpereDramBlockNotPrinted => false + } +} + +test fn only_the_empty_socket_is_a_finding_over_the_real_capture() -> Bool { + let f = ampere_dram_findings(observation: ampere_dram_console_observation(lines: lines_of(text: capture_35801475989_last_block)), expected_sockets: [0, 1]) + count(f) == 1 && any_contains(xs: f, pattern: "DRAM firmware 210525 printed no trained DIMM for socket 1") +} + +// A PARAM DIFFERING FROM ITS PRINTED DEFAULT IS AN OBSERVATION, NEVER A FINDING. +test fn a_non_default_param_is_rendered_but_never_a_finding() -> Bool { + let o = ampere_dram_console_observation(lines: lines_of(text: capture_35801475989_last_block)) + !any_contains(xs: ampere_dram_findings(observation: o, expected_sockets: [0, 1]), pattern: "mcu_enable_mask") + && contains(ampere_dram_console_text(observation: o, expected_sockets: [0, 1]), " MEMC mcu_enable_mask = 00000011 [default 000000ff] (differs from printed default)") +} + +test fn the_render_carries_the_roster_by_socket() -> Bool { + contains(ampere_dram_console_text(observation: ampere_dram_console_observation(lines: lines_of(text: capture_35793279839_last_block)), expected_sockets: [0, 1]), "trained dimms by socket: SK0=8 SK1=0") +} + +// ── REDS: THE REAL BYTES WITH ONE THING CHANGED ────────────────────────────────────────────── + +// MUTATION: the SK0 rows dropped from the real capture make socket 0 empty too. +test fn dropping_the_sk0_rows_makes_socket_0_a_finding() -> Bool { + let kept = filter(lines_of(text: capture_35801475989_last_block), l => !contains(l, " SK0 ")) + any_contains(xs: ampere_dram_findings(observation: ampere_dram_console_observation(lines: kept), expected_sockets: [0, 1]), pattern: "no trained DIMM for socket 0") +} + +// MUTATION: the param rows dropped leave no params, and that changes no finding. +test fn dropping_the_param_rows_leaves_no_params() -> Bool { + let kept = filter(lines_of(text: capture_35801475989_last_block), l => !contains(l, " = ")) + match ampere_dram_console_observation(lines: kept) { + AmpereDramBlockObserved { block: b, blocks_printed: _ } => count(b.params) == 0 && count(b.malformed) == 0 && ampere_dram_dimms_on_socket(block: b, socket: 0) == 2 + AmpereDramBlockNotPrinted => false + } +} + +// THE JOINED SPELLING THE FIRST DRAFT EXPECTED IS NOT THE FIRMWARE'S: it reads as no subsection. +test fn the_joined_spelling_is_not_read_as_a_roster() -> Bool { + match ampere_dram_console_observation(lines: lines_of(text: "NOTICE: DRAM FW version 210525\r\nDRAM populated DIMMs: SK0 MC0 S0: RDIMM\r\n")) { + AmpereDramBlockObserved { block: b, blocks_printed: _ } => count(b.dimms) == 0 + AmpereDramBlockNotPrinted => false + } +} + +test fn an_unparsable_row_inside_the_roster_is_a_typed_malformed_finding() -> Bool { + let text = "NOTICE: DRAM FW version 210525\r\nDRAM populated DIMMs:\r\n socket0/mc0/slot0 RDIMM\r\n SK0 MC1 S0: RDIMM\r\nCP: 3ff00100\r\n" + let f = ampere_dram_findings(observation: ampere_dram_console_observation(lines: lines_of(text: text)), expected_sockets: [0]) + any_contains(xs: f, pattern: "row under 'DRAM populated DIMMs:' not in the transcribed grammar: socket0/mc0/slot0 RDIMM") + && !any_contains(xs: f, pattern: "socket 0") +} + +test fn an_unindented_line_closes_the_roster() -> Bool { + let text = "NOTICE: DRAM FW version 210525\r\nDRAM populated DIMMs:\r\n SK0 MC0 S0: RDIMM\r\nCP: 3ff00100\r\n SK1 MC0 S0: not a roster row\r\n" + match ampere_dram_console_observation(lines: lines_of(text: text)) { + AmpereDramBlockObserved { block: b, blocks_printed: _ } => ampere_dram_dimms_on_socket(block: b, socket: 1) == 0 && count(b.malformed) == 0 + AmpereDramBlockNotPrinted => false + } +} + +test fn a_capture_without_the_block_asserts_no_roster() -> Bool { + let o = ampere_dram_console_observation(lines: lines_of(text: "CP: 3ff00100\r\n SK0 MC0 S0: RDIMM\r\n")) + (match o { AmpereDramBlockNotPrinted => true _ => false }) + && count(ampere_dram_findings(observation: o, expected_sockets: [0, 1])) == 0 +} + +test fn a_reset_loop_reads_the_last_block() -> Bool { + match ampere_dram_console_observation(lines: lines_of(text: concat(capture_35793279839_last_block, capture_35801475989_last_block))) { + AmpereDramBlockObserved { block: b, blocks_printed: n } => n == 2 && ampere_dram_dimms_on_socket(block: b, socket: 0) == 2 + AmpereDramBlockNotPrinted => false + } +} + +// ── ROSTER STANDING: ONLY A CLOSED ROSTER ESTABLISHES AN UNTRAINED SOCKET ──────────────────── + +// The complete real block closes its roster at the `CP: 3ff00100` line. +test fn the_complete_real_block_has_a_closed_roster() -> Bool { + match ampere_dram_console_observation(lines: lines_of(text: capture_35801475989_first_block)) { + AmpereDramBlockObserved { block: b, blocks_printed: _ } => match b.roster { RosterClosed => true _ => false } + AmpereDramBlockNotPrinted => false + } +} + +// The real bytes cut after the SK0 rows (the closing `CP:` line dropped): the roster is open, +// SK0's two rows are kept, and socket 1 is NOT reported untrained. +test fn a_capture_cut_mid_roster_is_open_and_mints_no_empty_socket() -> Bool { + let cut = filter(lines_of(text: capture_35801475989_first_block), l => !contains(l, "CP: 3ff00100")) + let o = ampere_dram_console_observation(lines: cut) + (match o { + AmpereDramBlockObserved { block: b, blocks_printed: _ } => (match b.roster { RosterOpen => true _ => false }) && ampere_dram_dimms_on_socket(block: b, socket: 0) == 2 + AmpereDramBlockNotPrinted => false + }) + && !any_contains(xs: ampere_dram_findings(observation: o, expected_sockets: [0, 1]), pattern: "no trained DIMM") + && contains(ampere_dram_console_text(observation: o, expected_sockets: [0, 1]), "roster: OPEN at the end of the capture") +} + +// A block cut before its roster header has no roster at all, and so no untrained socket. +test fn a_block_without_a_roster_header_mints_no_empty_socket() -> Bool { + let cut = filter(lines_of(text: capture_35801475989_last_block), l => !contains(l, "DRAM populated DIMMs:") && !contains(l, " SK0 ")) + let o = ampere_dram_console_observation(lines: cut) + (match o { + AmpereDramBlockObserved { block: b, blocks_printed: _ } => match b.roster { RosterNotObserved => true _ => false } + AmpereDramBlockNotPrinted => false + }) + && count(ampere_dram_findings(observation: o, expected_sockets: [0, 1])) == 0 +} + +// A new block header closes the previous block's roster; the last block's roster, cut, stays open. +test fn a_new_block_header_closes_the_previous_roster() -> Bool { + let text = "NOTICE: DRAM FW version 210525\r\nDRAM populated DIMMs:\r\n SK0 MC0 S0: RDIMM\r\nNOTICE: DRAM FW version 210525\r\nDRAM populated DIMMs:\r\n SK0 MC0 S0: RDIMM\r\n" + match ampere_dram_console_observation(lines: lines_of(text: text)) { + AmpereDramBlockObserved { block: b, blocks_printed: n } => n == 2 && match b.roster { RosterOpen => true _ => false } + AmpereDramBlockNotPrinted => false + } +} diff --git a/dag/test/claim/machine_intake/mtcollins1_boot_diagnostic_bundle_witness_test.dag b/dag/test/claim/machine_intake/mtcollins1_boot_diagnostic_bundle_witness_test.dag new file mode 100644 index 00000000000..e782192ce2e --- /dev/null +++ b/dag/test/claim/machine_intake/mtcollins1_boot_diagnostic_bundle_witness_test.dag @@ -0,0 +1,528 @@ +module test.claim.machine_intake.mtcollins1_boot_diagnostic_bundle_witness_test + +import v2.std.live_tree { LiveTreeDisposition, SubstrateInputsOnly } +import std.types { Bool, Int, List, NonEmptyStr, String } +import std.goal_assessment { ObservationEstablished, ObservationRefused } +import std.process { ExitSuccess, ExitFailure, exit_failure } +import v2.std.optional { Present } +import extdeps.bmc.redfish_memory_inventory { + RedfishMemoryMember, RedfishProcessorMember, StateAbsent, StateEnabled, StateUnrecognized, HealthOk, HealthCritical, + redfish_memory_member_of, redfish_processor_member_of, + RedfishCollectionPage, redfish_collection_page_of, RedfishLinkSameOrigin, RedfishLinkRefused, redfish_same_origin_link, +} +import gunbc.machine_intake_sel_stimulus_listener { sel_read } +import gunbc.machine_intake_mtcollins1_boot_diagnostic_bundle { + MtCollins1BootDiagnosticBundle, InventoryReading, MembersRead, MembersUnread, MembersNotTaken, + SelSnapshotRead, SelSnapshotUnread, SelSnapshotNotTaken, ConsoleNotConfigured, + BmcUnreachable, BmcTimeout, BmcAuthRefused, BmcHttpRefused, BmcSessionUnestablished, + bmc_curl_read_cause, bmc_ipmitool_read_cause, inventory_not_taken, + mtcollins1_boot_bundle_findings, mtcollins1_boot_bundle_text, mtcollins1_boot_outcome_with_findings, + mtcollins1_boot_console_reading, ConsoleRetained, ConsoleNotRetained, ConsoleExceedsBound, mtcollins1_boot_console_bound, + AttemptRunId, AttemptIdentityUnavailable, BmcDeadlineReached, BmcCollectionIncomplete, + CollectionComplete, CollectionRefused, redfish_collection_assembly, redfish_budget_refusal, member_not_reached, + MemberBody, assemble_memory_members, BmcResponseMalformed, mtcollins1_system_inventory_links, + mtcollins1_boot_diagnostics_allowance, mtcollins1_boot_redfish_read_budget, mtcollins1_boot_collection_member_bound, +} +import gunbc.machine_intake_mtcollins1_boot_run { mtcollins1_boot_ended_before_bmc, BmcAccessNotReached, mtcollins1_boot_attempt_identity } +import gunbc.actions_run_binding { ActionsVariablePresent, ActionsVariableAbsent } +import gunbc.machine_intake_pre_os_bringup_verdict { TrainingRefusedByFirmware } +import std.measure { byte_size, byte_size_count, second_count } + +data live_tree_disposition: LiveTreeDisposition = SubstrateInputsOnly + +// ── SUPPLIED FIXTURES ──────────────────────────────────────────────────────────────────────── +// +// THE SEL ROWS ARE mtcollins1's OWN. gunbc.machine_intake_mtcollins1_32dimm_bringup_observation +// transcribes records 1004 (OEM, manufacturer 00cd3a) and 1084/1085 (threshold events with the +// seventh "Reading" field) from this controller; they are re-rendered here in `ipmitool sel elist` +// form with hexadecimal ids (1004 = 3ec, 1084 = 43c, 1085 = 43d). The boot-restart row follows +// the shape pre_os_observer_witness_test already reads. The Memory-sensor row is SPEC-SHAPED, not +// observed: IPMI v2.0 section 42.2 sensor type 0Ch rendered the way ipmitool renders a sensor-type +// name. No memory-sensor record from this BMC is in the corpus. +data sel_before_fixture: String = "3ec | 09/10/2026 | 09:25:55 PM UTC | OEM record c0 | 00cd3a | 12c805000000\n43c | 09/11/2026 | 06:24:35 PM UTC | Voltage CPU0_0V75_PCP | Lower Non-critical going low | Asserted | Reading 0 < Threshold 0.68 Volts" + +data sel_after_fixture: String = "3ec | 09/10/2026 | 09:25:55 PM UTC | OEM record c0 | 00cd3a | 12c805000000\n43c | 09/11/2026 | 06:24:35 PM UTC | Voltage CPU0_0V75_PCP | Lower Non-critical going low | Asserted | Reading 0 < Threshold 0.68 Volts\n43d | 09/23/2026 | 01:00:00 AM UTC | Voltage CPU1_0V75_PCP | Lower Critical going low | Asserted | Reading 0 < Threshold 0.63 Volts\n43e | 09/23/2026 | 01:00:05 AM UTC | Memory DIMM_S1_A1 | Memory training failure | Asserted\n43f | 09/23/2026 | 01:00:06 AM UTC | OEM record c0 | 00cd3a | 0fde70330102" + +// THE REDFISH BODIES ARE SPEC-SHAPED (DMTF Memory, Processor and Resource schemas), NOT OBSERVED: +// no response from mtcollins1's Memory or Processors collection exists in the corpus. They carry +// the property names the schemas define, and they are the shape a socket-1-absent boot would +// produce if the controller lists unpopulated slots as members with State Absent. +data memory_collection_fixture: String = "{\"@odata.id\": \"/redfish/v1/Systems/Self/Memory\", \"Members\": [{\"@odata.id\": \"/redfish/v1/Systems/Self/Memory/DIMM_S0_A1\"}, {\"@odata.id\": \"/redfish/v1/Systems/Self/Memory/DIMM_S1_A1\"}], \"Members@odata.count\": 2}" + +data memory_member_present_fixture: String = "{\"Id\": \"DIMM_S0_A1\", \"DeviceLocator\": \"DIMM 1\", \"MemoryLocation\": {\"Socket\": 0, \"MemoryController\": 0, \"Channel\": 0, \"Slot\": 1}, \"CapacityMiB\": 16384, \"Status\": {\"State\": \"Enabled\", \"Health\": \"OK\"}}" + +data memory_member_absent_fixture: String = "{\"Id\": \"DIMM_S1_A1\", \"DeviceLocator\": \"Socket 1 DIMM 1\", \"MemoryLocation\": {\"Socket\": 1, \"MemoryController\": 0, \"Channel\": 0, \"Slot\": 1}, \"Status\": {\"State\": \"Absent\"}}" + +data processor_member_fixture: String = "{\"Id\": \"CPU0\", \"Socket\": \"CPU 0\", \"TotalCores\": 80, \"Status\": {\"State\": \"Enabled\", \"Health\": \"OK\"}}" + +fn parsed_memory(body: String) -> List { + match redfish_memory_member_of(body: body) { + ObservationEstablished { observed: m } => [m] + ObservationRefused { cause: _ } => [] + } +} + +fn socket1_absent_members() -> List { + parsed_memory(body: memory_member_absent_fixture) +} + +fn processors_socket0_only() -> List { + match redfish_processor_member_of(body: processor_member_fixture) { + ObservationEstablished { observed: p } => [p] + ObservationRefused { cause: _ } => [] + } +} + +fn bundle_socket1_absent() -> MtCollins1BootDiagnosticBundle { + MtCollins1BootDiagnosticBundle { + attempt: AttemptRunId { run_id: "35793279839" }, + outcome: "refused: mtcollins1 boot: host qualification REFUSED (nproc observed 80, qualification expects 160)", + sel_before: SelSnapshotRead { raw: sel_before_fixture, at: "2026-09-23T00:59:00Z" }, + sel_after: SelSnapshotRead { raw: sel_after_fixture, at: "2026-09-23T01:10:00Z" }, + inventory: InventoryReading { + system_id: "Self", + memory: MembersRead { members: concat(parsed_memory(body: memory_member_present_fixture), socket1_absent_members()) }, + processors: MembersRead { members: processors_socket0_only() }, + credential_removed: true, + }, + console: ConsoleNotConfigured, + } +} + +fn bundle_bmc_silent() -> MtCollins1BootDiagnosticBundle { + let cause = bmc_curl_read_cause(endpoint: "https://192.168.1.228/redfish/v1/Systems", at: "2026-09-23T01:10:00Z", exit_code: 7, stderr: "curl: (7) Failed to connect to 192.168.1.228 port 443: Couldn't connect to server") + let ipmi = bmc_ipmitool_read_cause(endpoint: "ipmi lanplus 192.168.1.228", at: "2026-09-23T00:59:00Z", exit_code: 1, stderr: "Error: Unable to establish IPMI v2 / RMCP+ session") + MtCollins1BootDiagnosticBundle { + attempt: AttemptRunId { run_id: "35800000000" }, + outcome: "refused: mtcollins1 boot: approval window expired; controller untouched", + sel_before: SelSnapshotUnread { cause: ipmi }, + sel_after: SelSnapshotUnread { cause: ipmi }, + inventory: InventoryReading { system_id: "", memory: MembersUnread { cause: cause }, processors: MembersUnread { cause: cause }, credential_removed: true }, + console: ConsoleNotConfigured, + } +} + +fn any_contains(xs: List, pattern: String) -> Bool { + any(xs, x => contains(x, pattern)) +} + +// ── THE REDFISH MODEL ──────────────────────────────────────────────────────────────────────── + +test fn an_absent_slot_parses_to_state_absent_on_its_socket() -> Bool { + match redfish_memory_member_of(body: memory_member_absent_fixture) { + ObservationEstablished { observed: m } => + m.status.state == StateAbsent && (m.id as String) == "DIMM_S1_A1" && match m.memory_location { + Present { value: l } => l.socket == Present { value: 1 } && l.slot == Present { value: 1 } + Absent => false + } && m.capacity_mib == none + ObservationRefused { cause: _ } => false + } +} + +test fn an_unlisted_state_is_carried_not_defaulted() -> Bool { + match redfish_memory_member_of(body: "{\"Id\": \"X\", \"Status\": {\"State\": \"Frobbed\", \"Health\": \"Critical\"}}") { + ObservationEstablished { observed: m } => + (match m.status.state { StateUnrecognized { rendering: r } => (r as String) == "Frobbed" _ => false }) && m.status.health == HealthCritical + ObservationRefused { cause: _ } => false + } +} + +test fn a_member_without_id_refuses() -> Bool { + match redfish_memory_member_of(body: "{\"Status\": {\"State\": \"Enabled\"}}") { + ObservationRefused { cause: c } => contains(c as String, "Id") + ObservationEstablished { observed: _ } => false + } +} + +fn page(links: List, total: Int?, next: String?) -> RedfishCollectionPage { + RedfishCollectionPage { member_links: links, member_count: total, next_link: next } +} + +fn eight_links(page_index: Int) -> List { + map([0, 1, 2, 3, 4, 5, 6, 7], k => concat("/redfish/v1/Systems/Self/Memory/DIMM_", to_string(page_index * 8 + k))) +} + +test fn a_page_keeps_each_members_exact_odata_id() -> Bool { + match redfish_collection_page_of(body: "{\"Members\": [{\"@odata.id\": \"/redfish/v1/Systems/Self/Memory/0x1a%20DIMM/Sub\"}], \"Members@odata.count\": 32, \"Members@odata.nextLink\": \"/redfish/v1/Systems/Self/Memory?$skip=1\"}") { + ObservationEstablished { observed: p } => + p.member_links == ["/redfish/v1/Systems/Self/Memory/0x1a%20DIMM/Sub"] && p.member_count == Present { value: 32 } + && p.next_link == Present { value: "/redfish/v1/Systems/Self/Memory?$skip=1" } + ObservationRefused { cause: _ } => false + } +} + +test fn a_collection_without_members_is_not_an_empty_collection() -> Bool { + match redfish_collection_page_of(body: "{\"@odata.id\": \"/redfish/v1/Systems/Self/Processors\"}") { + ObservationRefused { cause: c } => contains(c as String, "Members") + ObservationEstablished { observed: _ } => false + } +} + +// count=32 served 8 per page through nextLink: complete only when every page is followed. +test fn thirty_two_members_across_four_pages_assemble_complete() -> Bool { + match redfish_collection_assembly(pages: [ + page(links: eight_links(page_index: 0), total: Present { value: 32 }, next: Present { value: "/redfish/v1/Systems/Self/Memory?$skip=8" }), + page(links: eight_links(page_index: 1), total: Present { value: 32 }, next: Present { value: "/redfish/v1/Systems/Self/Memory?$skip=16" }), + page(links: eight_links(page_index: 2), total: Present { value: 32 }, next: Present { value: "/redfish/v1/Systems/Self/Memory?$skip=24" }), + page(links: eight_links(page_index: 3), total: Present { value: 32 }, next: none), + ], member_bound: mtcollins1_boot_collection_member_bound) { + CollectionComplete { links: ls } => count(ls) == 32 + CollectionRefused { detail: _ } => false + } +} + +// The first page alone, still naming a next page, is incomplete -- never "8 members". +test fn a_first_page_with_a_pending_next_link_is_incomplete() -> Bool { + match redfish_collection_assembly(pages: [page(links: eight_links(page_index: 0), total: Present { value: 32 }, next: Present { value: "/redfish/v1/Systems/Self/Memory?$skip=8" })], member_bound: 40) { + CollectionRefused { detail: d } => contains(d as String, "still carries Members@odata.nextLink; 8 of 32") + CollectionComplete { links: _ } => false + } +} + +test fn a_short_page_without_next_link_does_not_reconcile_with_its_count() -> Bool { + match redfish_collection_assembly(pages: [page(links: eight_links(page_index: 0), total: Present { value: 32 }, next: none)], member_bound: 40) { + CollectionRefused { detail: d } => contains(d as String, "Members@odata.count 32 but 8 member link(s)") + CollectionComplete { links: _ } => false + } +} + +test fn a_page_without_a_count_cannot_establish_completeness() -> Bool { + match redfish_collection_assembly(pages: [page(links: eight_links(page_index: 0), total: none, next: none)], member_bound: 40) { + CollectionRefused { detail: d } => contains(d as String, "no Members@odata.count") + CollectionComplete { links: _ } => false + } +} + +test fn a_count_over_the_member_bound_refuses_before_any_member_read() -> Bool { + match redfish_collection_assembly(pages: [page(links: eight_links(page_index: 0), total: Present { value: 4096 }, next: none)], member_bound: 40) { + CollectionRefused { detail: d } => contains(d as String, "exceeds the member bound 40") + CollectionComplete { links: _ } => false + } +} + +test fn a_foreign_member_link_refuses_the_collection() -> Bool { + match redfish_collection_assembly(pages: [page(links: ["https://evil.example/redfish/v1/Systems/Self/Memory/1"], total: Present { value: 1 }, next: none)], member_bound: 40) { + CollectionRefused { detail: d } => contains(d as String, "not a same-origin path") + CollectionComplete { links: _ } => false + } +} + +test fn a_link_is_used_exactly_or_refused_never_rebuilt() -> Bool { + (match redfish_same_origin_link(link: "/redfish/v1/Systems/Self/Memory/0x1a%20DIMM/Sub") { RedfishLinkSameOrigin { path: p } => (p as String) == "/redfish/v1/Systems/Self/Memory/0x1a%20DIMM/Sub" _ => false }) + && (match redfish_same_origin_link(link: "//evil.example/redfish/v1/x") { RedfishLinkRefused { cause: _ } => true _ => false }) + && (match redfish_same_origin_link(link: "/redfish/v1/Systems/../../etc") { RedfishLinkRefused { cause: _ } => true _ => false }) +} + +// An incomplete collection is an unread section, so no short-inventory finding can be minted from it. +test fn an_incomplete_memory_collection_mints_no_short_inventory_finding() -> Bool { + let cause = BmcCollectionIncomplete { endpoint: "https://192.168.1.228/redfish/v1/Systems/Self/Memory", at: "2026-09-23T01:00:00Z", detail: "Members@odata.nextLink not followed" } + let b = bundle_socket1_absent() + let bundle = MtCollins1BootDiagnosticBundle { attempt: b.attempt, outcome: b.outcome, sel_before: b.sel_before, sel_after: b.sel_after, + inventory: InventoryReading { system_id: "/redfish/v1/Systems/Self", memory: MembersUnread { cause: cause }, processors: b.inventory.processors, credential_removed: true }, + console: ConsoleNotConfigured } + !any_contains(xs: mtcollins1_boot_bundle_findings(bundle: bundle), pattern: "Memory member(s); the census board") + && contains(mtcollins1_boot_bundle_text(bundle: bundle), "memory: UNREAD: collection incomplete at https://192.168.1.228/redfish/v1/Systems/Self/Memory") +} + +// ── THE DIAGNOSTICS DEADLINE ───────────────────────────────────────────────────────────────── + +// 2 SEL snapshots x (20 s + 5 s kill-after) + 48 Redfish reads x 15 s + 60 s publish. +test fn the_allowance_is_the_sum_of_the_bounds() -> Bool { + (second_count(s: mtcollins1_boot_diagnostics_allowance()) as Int) == 2 * 25 + mtcollins1_boot_redfish_read_budget * 15 + 60 +} + +test fn a_spent_budget_refuses_the_read_and_names_what_was_not_reached() -> Bool { + (match redfish_budget_refusal(url: "https://192.168.1.228/redfish/v1/Systems/Self/Memory/DIMM_20", at: "t", left: 0, not_reached: member_not_reached(total: 32, read: 20)) { + Present { value: BmcDeadlineReached { endpoint: _, at: _, not_reached: n } } => n == "12 of 32 member read(s)" + _ => false + }) + && redfish_budget_refusal(url: "https://192.168.1.228/x", at: "t", left: 1, not_reached: "") == none +} + +test fn a_partial_bundle_renders_the_reads_not_reached() -> Bool { + let b = bundle_socket1_absent() + let cause = BmcDeadlineReached { endpoint: "https://192.168.1.228/redfish/v1/Systems/Self/Memory/DIMM_20", at: "t", not_reached: member_not_reached(total: 32, read: 20) } + let bundle = MtCollins1BootDiagnosticBundle { attempt: b.attempt, outcome: b.outcome, sel_before: b.sel_before, sel_after: b.sel_after, + inventory: InventoryReading { system_id: "/redfish/v1/Systems/Self", memory: MembersUnread { cause: cause }, processors: b.inventory.processors, credential_removed: true }, + console: ConsoleNotConfigured } + contains(mtcollins1_boot_bundle_text(bundle: bundle), "memory: UNREAD: diagnostics read budget spent before https://192.168.1.228/redfish/v1/Systems/Self/Memory/DIMM_20 (t); not reached: 12 of 32 member read(s)") +} + +// ── READ CAUSES ────────────────────────────────────────────────────────────────────────────── + +test fn curl_exit_codes_type_the_bmc_failure() -> Bool { + let e: NonEmptyStr = "https://192.168.1.228/redfish/v1/Systems" + let t: NonEmptyStr = "2026-09-23T01:00:00Z" + (match bmc_curl_read_cause(endpoint: e, at: t, exit_code: 7, stderr: "") { BmcUnreachable { endpoint: ep, at: at, detail: _ } => (ep as String) == (e as String) && (at as String) == (t as String) _ => false }) + && (match bmc_curl_read_cause(endpoint: e, at: t, exit_code: 28, stderr: "curl: (28) Operation timed out") { BmcTimeout { endpoint: _, at: _, detail: _ } => true _ => false }) + && (match bmc_curl_read_cause(endpoint: e, at: t, exit_code: 22, stderr: "curl: (22) The requested URL returned error: 401") { BmcAuthRefused { endpoint: _, at: _, detail: _ } => true _ => false }) + && (match bmc_curl_read_cause(endpoint: e, at: t, exit_code: 22, stderr: "curl: (22) The requested URL returned error: 404") { BmcHttpRefused { endpoint: _, at: _, detail: _ } => true _ => false }) +} + +test fn an_ipmi_session_failure_is_not_split_into_a_guess() -> Bool { + match bmc_ipmitool_read_cause(endpoint: "ipmi lanplus 192.168.1.228", at: "2026-09-23T01:00:00Z", exit_code: 1, stderr: "Error: Unable to establish IPMI v2 / RMCP+ session") { + BmcSessionUnestablished { endpoint: _, at: _, detail: _ } => true + _ => false + } +} + +// ── THE SEL DELTA OVER THIS BMC'S OWN ROWS ─────────────────────────────────────────────────── + +test fn the_real_threshold_rows_of_this_bmc_are_read_not_refused() -> Bool { + match sel_read(text: sel_before_fixture) { + ObservationEstablished { observed: w } => count(w.events) == 2 + ObservationRefused { cause: _ } => false + } +} + +test fn the_delta_names_the_memory_event_and_not_the_cpu_voltage_sensor() -> Bool { + let findings = mtcollins1_boot_bundle_findings(bundle: bundle_socket1_absent()) + any_contains(xs: findings, pattern: "Memory DIMM_S1_A1 | Memory training failure") + && !any_contains(xs: findings, pattern: "Voltage CPU1_0V75_PCP") +} + +test fn the_render_keeps_raw_records_beside_the_decode_and_counts_oem_opaque() -> Bool { + let text = mtcollins1_boot_bundle_text(bundle: bundle_socket1_absent()) + contains(text, "delta: 3 new record(s) (1 OEM, kept opaque)") + && contains(text, "OEM record, manufacturer 00cd3a, bytes 0fde70330102 (OEM-defined; not decoded)") + && contains(text, "-- raw after (ipmitool sel elist, verbatim) --\n3ec | 09/10/2026") +} + +// ── DECISIVE INVENTORY FINDINGS ────────────────────────────────────────────────────────────── + +test fn a_missing_processor_member_is_a_finding_against_the_census() -> Bool { + any_contains(xs: mtcollins1_boot_bundle_findings(bundle: bundle_socket1_absent()), pattern: "BMC lists 1 Processor member(s); the 2026-09-10 census observed 2 sockets") +} + +test fn socket1_absent_slots_are_named_by_socket() -> Bool { + any_contains(xs: mtcollins1_boot_bundle_findings(bundle: bundle_socket1_absent()), pattern: "BMC reports 1 of 1 socket-1 Memory member(s) State=Absent") +} + +test fn the_findings_reach_the_one_line_refusal() -> Bool { + let findings = mtcollins1_boot_bundle_findings(bundle: bundle_socket1_absent()) + match mtcollins1_boot_outcome_with_findings(outcome: exit_failure(reason: "mtcollins1 boot: host qualification REFUSED"), findings: findings) { + ExitFailure { code: _, reason: r } => contains(r, "mtcollins1 boot: host qualification REFUSED | bmc diagnostics: ") && contains(r, "census observed 2 sockets") + ExitSuccess => false + } +} + +// ── THE BUNDLE NEVER FLIPS THE VERDICT ─────────────────────────────────────────────────────── + +test fn findings_never_turn_a_success_into_a_failure() -> Bool { + let findings = mtcollins1_boot_bundle_findings(bundle: bundle_socket1_absent()) + count(findings) > 0 && match mtcollins1_boot_outcome_with_findings(outcome: ExitSuccess, findings: findings) { ExitSuccess => true _ => false } +} + +test fn no_findings_leave_a_refusal_reason_unchanged() -> Bool { + match mtcollins1_boot_outcome_with_findings(outcome: exit_failure(reason: "r"), findings: []) { + ExitFailure { code: _, reason: r } => r == "r" + ExitSuccess => false + } +} + +// ── A BMC THAT DOES NOT ANSWER ─────────────────────────────────────────────────────────────── + +// IPMI's session failure cannot say "did not answer", so beside a Redfish connect failure the +// aggregate names both kinds instead of a verdict on the BMC. +test fn an_ambiguous_ipmi_failure_is_not_rendered_as_did_not_answer() -> Bool { + let findings = mtcollins1_boot_bundle_findings(bundle: bundle_bmc_silent()) + any_contains(xs: findings, pattern: "every BMC read failed (no IPMI session (unreachable and credential-refused are indistinguishable); unreachable); first: no IPMI session at ipmi lanplus 192.168.1.228 (2026-09-23T00:59:00Z") + && !any_contains(xs: findings, pattern: "did not answer") +} + +// Only an aggregate made wholly of definitive no-answer causes says the BMC did not answer. +test fn only_definitive_no_answers_say_the_bmc_did_not_answer() -> Bool { + let b = bundle_bmc_silent() + let timeout = bmc_ipmitool_read_cause(endpoint: "ipmi lanplus 192.168.1.228", at: "2026-09-23T00:59:00Z", exit_code: 124, stderr: "") + let bundle = MtCollins1BootDiagnosticBundle { attempt: b.attempt, outcome: b.outcome, sel_before: SelSnapshotUnread { cause: timeout }, sel_after: SelSnapshotUnread { cause: timeout }, inventory: b.inventory, console: b.console } + any_contains(xs: mtcollins1_boot_bundle_findings(bundle: bundle), pattern: "every BMC read failed and the BMC did not answer; first: BMC timed out at ipmi lanplus 192.168.1.228") +} + +test fn a_silent_bmc_still_renders_every_section_with_its_cause() -> Bool { + let text = mtcollins1_boot_bundle_text(bundle: bundle_bmc_silent()) + contains(text, "before: UNREAD: no IPMI session") + && contains(text, "processors: UNREAD: BMC unreachable at https://192.168.1.228/redfish/v1/Systems (2026-09-23T01:10:00Z)") + && contains(text, "memory: UNREAD: BMC unreachable") +} + +// ── EVERY SECTION, ON EVERY ARM ────────────────────────────────────────────────────────────── +// +// THE MUTATION CONTROL. Deleting any one section's line from mtcollins1_boot_bundle_text turns +// this claim red, because it asserts each section by its header AND by the reading it carries on +// an arm where nothing was read. +test fn a_bundle_from_an_attempt_that_never_reached_the_bmc_names_why_in_every_section() -> Bool { + let why: NonEmptyStr = "the attempt ended before the BMC credential was read (refused: mtcollins1 boot: approval window expired; controller untouched)" + let bundle = MtCollins1BootDiagnosticBundle { + attempt: AttemptRunId { run_id: "1" }, + outcome: "refused: mtcollins1 boot: approval window expired; controller untouched", + sel_before: SelSnapshotNotTaken { reason: why }, + sel_after: SelSnapshotNotTaken { reason: why }, + inventory: inventory_not_taken(reason: why), + console: ConsoleNotConfigured, + } + let text = mtcollins1_boot_bundle_text(bundle: bundle) + contains(text, "== bmc system event log ==") + && contains(text, concat("before: NOT TAKEN: ", why as String)) + && contains(text, concat("after: NOT TAKEN: ", why as String)) + && contains(text, "== bmc inventory (redfish) ==") + && contains(text, concat("processors: NOT TAKEN: ", why as String)) + && contains(text, concat("memory: NOT TAKEN: ", why as String)) + && contains(text, "== pre-os console ==") + && contains(text, "NOT CONFIGURED: the SOL capture path was unset") +} + +// THE REAL PRODUCER OF AN EARLY TERMINAL: mtcollins1_boot_ended_before_bmc is what every +// pre-credential return in mtcollins1_boot_wet_on_srv1 goes through, and its reason is what the +// bundle's NOT TAKEN sections carry. +test fn an_early_refusal_carries_its_own_reason_into_the_bmc_sections() -> Bool { + match mtcollins1_boot_ended_before_bmc(outcome: exit_failure(reason: "mtcollins1 boot: GITHUB_SHA is unset"), escalation_id: none).bmc { + BmcAccessNotReached { reason: r } => contains(r as String, "GITHUB_SHA is unset") + _ => false + } +} + +// ── THE PRE-OS CONSOLE ─────────────────────────────────────────────────────────────────────── + +test fn a_capture_outside_the_uploaded_glob_is_reported_not_retained() -> Bool { + match mtcollins1_boot_console_reading(path: "/tmp/sol.capture", size: byte_size(count: 1), capture: "x", read_ok: true, read_error: "") { + ConsoleNotRetained { path: _ } => true + _ => false + } +} + +test fn a_retained_capture_reports_its_firmware_statement() -> Bool { + let capture = "ERROR: Non-identical DIMM mixture NOT supported!\n" + match mtcollins1_boot_console_reading(path: "/w/artifacts/mtcollins1-boot-sol.capture", size: byte_size(count: 51), capture: capture, read_ok: true, read_error: "") { + ConsoleRetained { path: _, size: b, lines: _, firmware: f, dram: _ } => (byte_size_count(b: b) as Int) == 51 && match f { TrainingRefusedByFirmware { statement: _, locus: _ } => true _ => false } + _ => false + } +} + +// THE BOUND IS DECIDED ON stat's BYTE COUNT, not on the String: a capture whose stat size exceeds +// the bound is reported over it even when its content is short. +test fn a_capture_over_the_byte_bound_is_reported_whole() -> Bool { + match mtcollins1_boot_console_reading(path: "artifacts/mtcollins1-boot-sol.capture", size: byte_size(count: 16777217), capture: "", read_ok: true, read_error: "") { + ConsoleExceedsBound { path: _, size: s, bound: b } => (byte_size_count(b: s) as Int) == 16777217 && (byte_size_count(b: b) as Int) == 16777216 + _ => false + } +} + +// ── THE ATTEMPT'S IDENTITY ─────────────────────────────────────────────────────────────────── + +test fn a_missing_run_id_is_a_typed_unavailable_identity_not_a_blank() -> Bool { + (match mtcollins1_boot_attempt_identity(read: ActionsVariableAbsent { variable: "GITHUB_RUN_ID", detail: "not set" }) { + AttemptIdentityUnavailable { variable: v, detail: d } => (v as String) == "GITHUB_RUN_ID" && d == "not set" + _ => false + }) + && (match mtcollins1_boot_attempt_identity(read: ActionsVariablePresent { value: "35801475989" }) { AttemptRunId { run_id: r } => (r as String) == "35801475989" _ => false }) +} + +test fn the_unavailable_identity_is_rendered_as_such() -> Bool { + let b = bundle_bmc_silent() + let bundle = MtCollins1BootDiagnosticBundle { attempt: AttemptIdentityUnavailable { variable: "GITHUB_RUN_ID", detail: "not set" }, outcome: b.outcome, sel_before: b.sel_before, sel_after: b.sel_after, inventory: b.inventory, console: b.console } + contains(mtcollins1_boot_bundle_text(bundle: bundle), "attempt=UNAVAILABLE: GITHUB_RUN_ID could not be read: not set") +} + +// THE DRAM FIRMWARE'S EMPTY SOCKET REACHES THE ONE-LINE REFUSAL through the real console route +// (mtcollins1_boot_console_reading -> ampere_dram_console_observation -> bundle findings). +test fn an_empty_dram_socket_in_the_console_reaches_the_refusal() -> Bool { + let capture = "NOTICE: DRAM FW version 210525\r\nMEMC param:\r\n mcu_enable_mask = 00000011 [default: 000000ff]\r\nDRAM populated DIMMs:\r\n SK0 MC0 S0: RDIMM[ad:80] 16GB 2666 ECC 1R x4 RCD[b3:80] HMA82GR7AFR4N-VK \r\nCP: 3ff00100\r\n" + let bundle = MtCollins1BootDiagnosticBundle { + attempt: AttemptRunId { run_id: "35801475989" }, + outcome: "refused: x", + sel_before: SelSnapshotNotTaken { reason: "t" }, + sel_after: SelSnapshotNotTaken { reason: "t" }, + inventory: inventory_not_taken(reason: "t"), + console: mtcollins1_boot_console_reading(path: "artifacts/mtcollins1-boot-sol.capture", size: byte_size(count: 200), capture: capture, read_ok: true, read_error: ""), + } + match mtcollins1_boot_outcome_with_findings(outcome: exit_failure(reason: "mtcollins1 boot: host qualification REFUSED"), findings: mtcollins1_boot_bundle_findings(bundle: bundle)) { + ExitFailure { code: _, reason: r } => contains(r, "printed no trained DIMM for socket 1") && !contains(r, "mcu_enable_mask") + ExitSuccess => false + } +} + +// ── IDENTITY COMPLETENESS ──────────────────────────────────────────────────────────────────── + +fn dimm_body(odata_id: String, id: String, socket: Int) -> String { + concat("{\"@odata.id\": \"", odata_id, "\", \"Id\": \"", id, "\", \"MemoryLocation\": {\"Socket\": ", to_string(socket), "}, \"Status\": {\"State\": \"Enabled\", \"Health\": \"OK\"}}") +} + +data link_a: NonEmptyStr = "/redfish/v1/Systems/Self/Memory/DIMM_A" + +data link_b: NonEmptyStr = "/redfish/v1/Systems/Self/Memory/DIMM_B" + +data memory_collection_path: NonEmptyStr = "/redfish/v1/Systems/Self/Memory" + +test fn duplicate_member_links_refuse_the_collection() -> Bool { + match redfish_collection_assembly(pages: [page(links: [link_a as String, link_a as String], total: Present { value: 2 }, next: none)], member_bound: 40) { + CollectionRefused { detail: d } => contains(d as String, "is listed more than once") + CollectionComplete { links: _ } => false + } +} + +test fn a_later_page_disagreeing_on_the_count_refuses_the_collection() -> Bool { + match redfish_collection_assembly(pages: [ + page(links: [link_a as String], total: Present { value: 2 }, next: Present { value: "/redfish/v1/Systems/Self/Memory?$skip=1" }), + page(links: [link_b as String], total: Present { value: 3 }, next: none), + ], member_bound: 40) { + CollectionRefused { detail: d } => contains(d as String, "reports Members@odata.count 3 where the first page reported 2") + CollectionComplete { links: _ } => false + } +} + +test fn two_links_returning_one_id_leave_the_section_unread() -> Bool { + match assemble_memory_members(collection: memory_collection_path, at: "t", bodies: [ + MemberBody { link: link_a, body: dimm_body(odata_id: link_a as String, id: "DIMM_A", socket: 0) }, + MemberBody { link: link_b, body: dimm_body(odata_id: link_b as String, id: "DIMM_A", socket: 0) }, + ]) { + MembersUnread { cause: BmcCollectionIncomplete { endpoint: _, at: _, detail: d } } => contains(d, "returned the same Id DIMM_A") + _ => false + } +} + +test fn a_member_answering_as_another_resource_leaves_the_section_unread() -> Bool { + match assemble_memory_members(collection: memory_collection_path, at: "t", bodies: [ + MemberBody { link: link_a, body: dimm_body(odata_id: link_a as String, id: "DIMM_A", socket: 0) }, + MemberBody { link: link_b, body: dimm_body(odata_id: link_a as String, id: "DIMM_B", socket: 0) }, + ]) { + MembersUnread { cause: BmcResponseMalformed { endpoint: _, at: _, detail: d } } => contains(d, "link /redfish/v1/Systems/Self/Memory/DIMM_B returned the resource /redfish/v1/Systems/Self/Memory/DIMM_A") + _ => false + } +} + +// CONTROL: two distinct links, a stable total and distinct matching ids are complete and read. +test fn distinct_links_stable_total_and_matching_ids_are_complete() -> Bool { + let links = match redfish_collection_assembly(pages: [ + page(links: [link_a as String], total: Present { value: 2 }, next: Present { value: "/redfish/v1/Systems/Self/Memory?$skip=1" }), + page(links: [link_b as String], total: Present { value: 2 }, next: none), + ], member_bound: 40) { CollectionComplete { links: ls } => count(ls) == 2 CollectionRefused { detail: _ } => false } + links && match assemble_memory_members(collection: memory_collection_path, at: "t", bodies: [ + MemberBody { link: link_a, body: dimm_body(odata_id: link_a as String, id: "DIMM_A", socket: 0) }, + MemberBody { link: link_b, body: dimm_body(odata_id: link_b as String, id: "DIMM_B", socket: 1) }, + ]) { + MembersRead { members: ms } => count(ms) == 2 + _ => false + } +} + +// ── THE SELECTED SYSTEM IS IDENTITY-JOINED ─────────────────────────────────────────────────── + +data system_link_a: NonEmptyStr = "/redfish/v1/Systems/Self" + +fn system_body(odata_id: String) -> String { + concat("{\"@odata.id\": \"", odata_id, "\", \"Id\": \"Self\", \"Memory\": {\"@odata.id\": \"/redfish/v1/Systems/Self/Memory\"}, \"Processors\": {\"@odata.id\": \"/redfish/v1/Systems/Self/Processors\"}}") +} + +test fn a_system_answering_as_another_resource_is_refused() -> Bool { + match mtcollins1_system_inventory_links(requested: system_link_a, body: system_body(odata_id: "/redfish/v1/Systems/Other")) { + ObservationRefused { cause: c } => contains(c as String, "system link /redfish/v1/Systems/Self returned the resource /redfish/v1/Systems/Other") + ObservationEstablished { observed: _ } => false + } +} + +test fn a_system_answering_at_its_own_link_yields_its_inventory_links() -> Bool { + match mtcollins1_system_inventory_links(requested: system_link_a, body: system_body(odata_id: "/redfish/v1/Systems/Self")) { + ObservationEstablished { observed: l } => l.memory == Present { value: "/redfish/v1/Systems/Self/Memory" } && l.processors == Present { value: "/redfish/v1/Systems/Self/Processors" } + ObservationRefused { cause: _ } => false + } +} diff --git a/dag/test/claim/machine_intake/mtcollins1_boot_run_witness_test.dag b/dag/test/claim/machine_intake/mtcollins1_boot_run_witness_test.dag index 083749a112e..fe27a4984d6 100644 --- a/dag/test/claim/machine_intake/mtcollins1_boot_run_witness_test.dag +++ b/dag/test/claim/machine_intake/mtcollins1_boot_run_witness_test.dag @@ -22,6 +22,7 @@ import gunbc.machine_intake_mtcollins1_boot_run { mtcollins1_boot_host_must_be_srv1, mtcollins1_boot_refuses_off_srv1, } import gunbc.auth.approval_gate { approval_status_from_get, approval_instant_from_probe } +import gunbc.machine_intake_mtcollins1_boot_diagnostic_bundle { mtcollins1_boot_diagnostics_allowance } import gunbc.fleet_intent_network { operator_host_srv1, operator_host_srv2 } import gunbc.fleet_converge_workflow { fleet_converge_fleet_ssh_key_step_if } import std.process { ExitSuccess } @@ -60,6 +61,7 @@ test fn the_step_timeout_covers_the_poll_window_and_the_actuation_allowance() -> + (second_count(s: mtcollins1_boot_issue_allowance) as Int) + (second_count(s: mtcollins1_boot_actuation_allowance) as Int) + (second_count(s: mtcollins1_boot_cleanup_allowance) as Int) + + (second_count(s: mtcollins1_boot_diagnostics_allowance()) as Int) (minute_count(m: mtcollins1_boot_step_timeout_minutes()) as Int) * 60 >= covered }