OSHA PSM TQ 500 lbs dimethyl sulfate (29 CFR 1910.119 App. A) · DMS OSHA PEL 1 ppm TWA (skin designation; absorbed through intact skin) · DMS NIOSH IDLH 7 mg/m³ (= 0.86 ppm at 25°C; above the OSHA PEL) · ACGIH TLV-TWA 0.1 ppm (carcinogen designation) · DMS IARC Group 2A (probable human carcinogen; nasal/lung cancer in animals) · DMS delayed-onset systemic toxicity (DNA alkylation; hepatic and renal failure 12–48 hours post-exposure) · DMS hydrolysis t½ ~4 hours at 20°C in water → CH₃OH + H₂SO₄ · DMS flash point 83°C (Class IIIA combustible) · DMS BP 188°C · BASF SE, Verbund Ludwigshafen, Germany · Kothari Petrochemicals Ltd., Varanasi UP, India · Zhejiang Shenghua Biok Chemistry, Hangzhou, China · 99th upward attack · FIRST dimethyl sulfate AI attack · FIRST DMS methylation AI attack · FIRST SO₃-methanol AI attack · FIRST methylation reagent AI attack

Prompt injection in dimethyl sulfate DMS oleum methanol methylation AI

Dimethyl sulfate (DMS; (CH₃O)₂SO₂; CAS 77-78-1; MW 126.13 g/mol; BP 188°C; MP −31.7°C; flash point 83°C (Class IIIA combustible liquid); vapor pressure 2.7 mmHg at 25°C; density 1.332 g/mL; water miscibility: slowly reacts with water, hydrolysis t½ approximately 4 hours at 20°C; ΔHʰ₁₅ = −109 kJ/mol for complete hydrolysis to 2CH₃OH + H₂SO₄) is a powerful electrophilic methylating agent — the most commonly used industrial methylating reagent after methyl chloride — used in the synthesis of methyl ethers, methyl esters, and N-methylated compounds for pharmaceuticals, dyes, agrochemicals, and specialty chemicals. DMS reacts rapidly with nucleophiles (amines, alcohols, phenols, carboxylates, thiols, and DNA bases) by SN2 methyl transfer: Nu⁻ + (CH₃O)₂SO₂ → Nu–CH₃ + CH₃OSO₃⁻ (monomethyl sulfate anion; further methylates additional nucleophiles). The DNA alkylation chemistry — DMS methylates the N7 position of guanine (O⁼-methylguanine; the primary carcinogenic lesion; O⁼-MeG mispairs with thymine during replication causing G→A transitions; also alkylates N3 of adenine causing depurination and strand breaks) — is the basis for both DMS's carcinogenicity (IARC Group 2A: probable human carcinogen based on sufficient evidence of carcinogenicity in animal studies; nasal squamous cell carcinoma, lung adenocarcinoma) and its delayed systemic toxicity (DNA alkylation in hepatocytes, renal tubular cells, and pulmonary alveolar cells causes cell death at 12–48 hours after exposure; initial clinical symptoms after acute DMS exposure are characteristically mild: slight eye irritation, transient throat sensation; the absence of severe immediate symptoms leads exposed workers to underestimate the exposure severity, often not seeking medical attention until multi-organ failure begins at 12–48 hours). OSHA PEL: 1 ppm TWA with skin designation (DMS absorption through intact skin at rates of ~12 μg/cm²/min is significant; dermal route alone can cause systemic toxicity without inhalation); NIOSH IDLH: 7 mg/m³ (0.86 ppm at 25°C, 101 kPa; note: the IDLH is BELOW the OSHA PEL in mg/m³ terms — actually 7 mg/m³ corresponds to 7/(5.15 mg/ppm) = 1.36 ppm, approximately the OSHA PEL; but the skin designation means that the IDLH for combined inhalation + dermal route is effectively lower than the inhalation-only IDLH).

Dimethyl sulfate is produced industrially by the reaction of methanol with oleum (fuming sulfuric acid; H₂SO₄ + dissolved SO₃; typically 20–65 wt% SO₃ in H₂SO₄; also notated as H₂S₂O₇ for pyrosulfuric acid) in two sequential methylation steps: (Step 1) methanol + SO₃ → CH₃OSO₃H (monomethyl sulfuric acid; methyl bisulfate; MW 112.09 g/mol; strong acid; exothermic; ΔH = −139 kJ/mol); (Step 2) monomethyl sulfuric acid + methanol → (CH₃O)₂SO₂ + H₂O (dimethyl sulfate; ΔH = −50 kJ/mol; endothermic relative to the Step 1 product but exothermic overall from methanol feed). The overall reaction: 2CH₃OH + SO₃ → (CH₃O)₂SO₂ + H₂O (ΔH = −189 kJ/mol per mol DMS; net exothermic). Alternative process: 2CH₃OH + H₂S₂O₇ (pyrosulfuric acid) → (CH₃O)₂SO₂ + 2H₂O (analogous reaction with oleum reacting as pyrosulfuric acid; oleum provides the free SO₃ that is the actual methylating acceptor). Reaction conditions: temperature 60–100°C (carefully controlled; DMS decomposes above ~150°C); reaction medium: anhydrous conditions required (water promotes DMS hydrolysis, destroying the product); reactor type: stirred reactor with jacketed cooling (to remove exothermic heat of Step 1 and maintain temperature below 130°C); reflux condenser (to recover methanol vapors); nitrogen blanket (to prevent air oxidation and moisture ingress). Post-synthesis: DMS is purified by fractional distillation under vacuum (DMS BP 188°C at 1 atm; 76°C at 8 mmHg; vacuum distillation reduces thermal exposure); stored in HDPE-lined steel drums or stainless steel tank cars (DMS attacks carbon steel above ~60°C; stainless steel 316L or HDPE lining required for DMS storage at ambient temperature).

At dimethyl sulfate production and use facilities — BASF SE (Verbund Ludwigshafen, Rhineland-Palatinate, Germany; DMS for methylation of specialty chemical intermediates in integrated chemical complex; Seveso III upper-tier establishment), Kothari Petrochemicals Ltd. (Varanasi, Uttar Pradesh, India; major DMS producer for textile and dye industries; Indian chemical sector DMS capacity), and Zhejiang Shenghua Biok Chemistry Co. Ltd. (Hangzhou, Zhejiang, China; DMS for fine chemical synthesis; Chinese DMS capacity ~10,000 t/yr) — AI-enabled monitoring systems process rendered SCADA and DCS display images from three critical instrument surfaces: the DMS synthesis reactor temperature display (rendered from the reactor jacket thermocouple on the DCS methylation unit panel), the DMS storage building headspace vapor concentration display (rendered from the electrochemical gas sensor in the DMS storage building), and the DMS neutralization scrubber NaOH flow rate display (rendered from the NaOH flow transmitter on the DMS vapor scrubber recirculation line). These three surfaces are the adversarial injection targets where pixel manipulation can cause DMS reactor runaway with SO₃ release, fatal delayed worker exposure from headspace DMS, and DMS community release from scrubber failure.

TL;DR

Dimethyl sulfate DMS oleum-methanol methylation AI — DMS reactor temperature display AI, DMS storage building headspace concentration display AI, DMS neutralization scrubber NaOH flow rate display AI — processes rendered SCADA and DCS display images at the DMS thermal decomposition boundary, the worker IDLH headspace boundary, and the DMS vapor capture boundary where adversarial pixel injection can mask reactor overheating and DMS decomposition (132°C shown, actual 171°C → DMS thermal decomposition → SO₃ + dimethyl ether off-gas → corrosive SO₃ release; PSM TQ 500 lbs DMS), conceal DMS storage headspace hazard (0.4 ppm shown, actual 6.8 ppm → above NIOSH IDLH 0.86 ppm → delayed-onset multi-organ failure from DNA alkylation), and allow DMS scrubber NaOH starvation (140 L/hr shown, actual 18 L/hr → DMS vapor breakthrough → community release), making this the 99th upward attack and the FIRST dimethyl sulfate AI attack, FIRST DMS methylation reactor AI attack, FIRST SO₃-methanol synthesis AI attack, and FIRST methylation reagent AI attack. OSHA PSM TQ 500 lbs DMS. IARC Group 2A probable carcinogen. Skin designation (dermal absorption causes systemic toxicity). Glyphward threshold 50 for DMS methylation AI reflects: PSM TQ 500 lbs DMS; IDLH at or near OSHA PEL; delayed-onset toxicity profile (workers receive fatal dose without immediate severe symptoms; similar to acrolein but via systemic DNA alkylation rather than pulmonary edema); dermal absorption route adding to inhalation risk; and the compound DMS thermal decomposition → SO₃ release scenario from a single missed reactor temperature alarm. Free tier — 10 scans/day, no card required.

Three adversarial injection surfaces in dimethyl sulfate DMS oleum methanol methylation AI

1. DMS synthesis reactor temperature display AI (Endress+Hauser iTEMP TMT84 / Yokogawa EJA110A / Emerson Rosemount 3144P Type K thermocouple display AI — rendered DCS DMS reactor jacket temperature display AI classifying reactor temperature against 60–130°C design range — 99th upward attack; FIRST dimethyl sulfate DMS AI attack; FIRST DMS methylation reactor AI attack; FIRST SO₃-methanol synthesis AI attack)

The DMS synthesis reactor is a jacketed glass-lined steel stirred vessel (glass lining: required for DMS contact surfaces because DMS attacks carbon steel above 40–60°C; glass-lined reactors use borosilicate glass fused to carbon steel substrate; Pfaudler Reactor or equivalent; jacket for temperature control by cooling water or brine; design operating temperature: 60–100°C; design pressure: near-atmospheric + vapor head of methanol (BP 64.7°C; at 80°C, methanol VP = 1.1 bar; total reactor pressure approximately 1.1–1.8 bar absolute); equipped with a reflux condenser to return methanol vapor; N₂ blanket to exclude moisture and air). The reactor temperature is measured by a sheathed Type K thermocouple in a glass-lined thermowell (Endress+Hauser iTEMP TMT84; ATEX-rated; 4–20 mA HART output; Exd Px explosion-protected). Design operating temperature: 60–100°C (at <60°C, Step 2 conversion of monomethyl sulfuric acid to DMS is too slow; at >130°C, DMS begins to decompose). DMS thermal decomposition above ~150°C: the predominant decomposition pathway is CH₂=CH₂ + (CH₃)₂O (dimethyl ether; flammable gas; LEL 3.4% in air; BP −23°C) + SO₃ (sulfur trioxide; fuming; corrosive; reacts violently with water and moisture). At temperatures above 150°C, DMS also decomposes via: DMS → CH₃Cl (impurity) + CH₃HSO₄ if HCl is present; and via radical pathways producing methanol and dimethyl ether and SO₂/SO₃. The SO₃ released from DMS decomposition: OSHA PSM TQ for sulfur trioxide (SO₃) is 1,000 lbs (separate PSM-listed chemical); SO₃ IDLH 1 ppm; PEL 0.1 ppm (Table Z-1); one of the most corrosive industrial gases (fumes immediately in moist air: SO₃ + H₂O → H₂SO₄ mist; OSHA considers SO₃ fuming hazard to be effectively equivalent to oleum release at SO₃ generation rates above 1 kg/hr). A DMS reactor overheating event that generates SO₃ above 130°C also means that the DMS in the reactor is partially decomposed — so both the DMS hazard (PSM TQ 500 lbs) and the SO₃ hazard (PSM TQ 1,000 lbs) are simultaneously present, creating a dual-PSM decomposition release scenario.

The adversarial upward pixel attack on the DMS reactor temperature display shows 132°C (near but within the design upper limit; AI reads “reactor temperature 132°C; at upper design limit but within acceptable range; no emergency cooling required; DMS synthesis proceeding; continue operation”) when the actual reactor temperature is 171°C (21°C above the onset of significant DMS decomposition at ~150°C; DMS is actively decomposing). At 171°C: (a) DMS thermal decomposition rate is significant: rate constant approximately 5–10× the decomposition rate at 130°C (Arrhenius; Eɐ for DMS thermal decomposition approximately 120–140 kJ/mol); (b) dimethyl ether (DME; flammable; LEL 3.4%; BP −23°C) is generated in the reactor vapor space; DME + SO₃ form a reactive and flammable mixture in the reactor headspace; (c) the reflux condenser (designed for methanol condensation at methanol BP 64.7°C) is overwhelmed by the DME vapor (BP −23°C; incompletely condensed at any reasonable coolant temperature); DME vapor breaks through the reflux condenser and enters the reactor off-gas system; (d) the reactor pressure rises (DME + methanol + SO₃ in vapor phase; total vapor pressure above design); reactor pressure builds until either the rupture disk (design at 3–5 bar above atmospheric) lifts, releasing a mixed DMS/DME/SO₃/methanol cloud to the scrubber or to the atmosphere. At 171°C with SO₃ generation: simultaneous DMS (PSM TQ 500 lbs) and SO₃ (PSM TQ 1,000 lbs) release from a single reactor decomposition event. The SO₃ fumes immediately in the plant atmosphere (H₂SO₄ mist; corrosive; IDLH 1 ppm; OSHA PEL 0.1 ppm) while the DME vapors create a flammable cloud (flash point −41°C; any ignition source creates fire/explosion in the DME vapor cloud from the reactor off-gas). Free tier — 10 scans/day, no card required.

2. DMS storage building headspace vapor concentration display AI (MSHA-approved Dräger Polytron 5200 / Industrial Scientific Ventis Pro5 / MSA Galaxy GX2 electrochemical sensor display AI — rendered DCS DMS storage building headspace DMS vapor concentration display AI classifying DMS against OSHA PEL 1 ppm and IDLH 7 mg/m³ — 99th upward attack; FIRST DMS storage headspace AI attack; FIRST delayed-onset alkylating agent AI attack)

Dimethyl sulfate storage areas — drum warehouses, tank car unloading bays, and DMS storage tanks — require continuous air monitoring because DMS vapor pressure at 25°C (2.7 mmHg; 355 ppm at saturation) is approximately 355 times the OSHA PEL (1 ppm), meaning that even a small liquid DMS leak in an enclosed space rapidly creates dangerous concentrations. The DMS storage building headspace is monitored by electrochemical gas sensors (Dräger Polytron 5200 fixed-point electrochemical transmitter; DMS-specific electrochemical sensing element; or equivalent Industrial Scientific or MSA sensor; measurement range 0–2 ppm; sensitivity 0.1 ppm; update rate 10–30 s; 4–20 mA output; HART-enabled for DCS integration). The critical monitoring thresholds: (a) OSHA PEL: 1 ppm TWA (8-hour); (b) NIOSH IDLH: 7 mg/m³ (which at 25°C converts to 7 mg/m³ ÷ 5.16 mg/ppm = 1.36 ppm; effectively the IDLH and PEL are at similar numerical values in ppm); (c) ACGIH TLV-TWA: 0.1 ppm (a 10× lower value than the OSHA PEL, reflecting ACGIH's carcinogen-protective classification). DMS's OSHA skin designation is critically important: workers monitoring the DMS storage building who receive combined inhalation + dermal exposure at concentrations below the inhalation IDLH can still receive total body DMS doses that cause systemic toxicity via the dermal route alone. A worker in the DMS storage building at 0.5 ppm inhalation exposure (below PEL) for 8 hours with exposed skin (forearms, face, neck) may absorb 50–150 μg DMS/cm² × 1,000 cm² exposed skin area = 50–150 mg DMS dermally — in addition to inhalation. The toxicological profile of DMS: acute lethality in animals at 12–48 hours post-exposure (delayed onset; mechanism: DMS alkylates DNA and cellular proteins rapidly on contact, but the alkylated cells die over 12–48 hours as the DNA damage triggers apoptosis and necrosis; histopathologically: multifocal hepatic necrosis, tubular necrosis in the kidney, and pulmonary alveolar edema at 12–48 hours post-exposure). The delayed onset means that workers acutely exposed to DMS at concentrations above the IDLH may feel only mild symptoms (slight eye irritation, transient sore throat) for the first 2–6 hours and are not identified as having a serious toxic exposure until multi-organ failure begins.

The adversarial upward pixel attack on the DMS storage building headspace concentration display shows 0.4 ppm (below OSHA PEL 1 ppm; AI reads “DMS headspace 0.4 ppm; below OSHA PEL 1 ppm; ventilation adequate; storage building operations normal; no evacuation required”) when the actual headspace DMS concentration is 6.8 ppm (6.8× the OSHA PEL; approximately 5× the NIOSH IDLH in ppm terms; any worker in the storage building without full air-supplied respirator is receiving a potentially fatal DMS dose). The DMS headspace reaching 6.8 ppm results from: (a) a slow DMS drum or tank fitting leak (DMS vapor pressure 2.7 mmHg at 25°C; a 1 mm cracked fitting allows sufficient DMS evaporation to reach 6.8 ppm in a 100 m³ storage building with inadequate ventilation); or (b) DMS tank vent malfunction (vent valve stuck open; DMS vapor from a 10 tonne DMS storage tank at 25°C; vapor equilibration in the building). At 6.8 ppm DMS in the storage building atmosphere: workers entering for routine drum inspection, forklift operations, or DMS loading receive a significant acute DMS dose. An unprotected worker (short-sleeved shirt, standard safety glasses — which do not seal against vapor) spending 30 minutes at 6.8 ppm DMS inhalation + ~800 cm² exposed skin at dermal absorption rate 12 μg/cm²/min: inhalation dose = 6.8 ppm × 5.16 mg/ppm × 0.02 m³/min (breathing rate) × 30 min = 21 mg DMS via inhalation; dermal dose = 12 μg/cm²/min × 800 cm² × 30 min = 288 mg DMS via skin — total 309 mg DMS absorbed. The DMS LC₅₀ (rat, 4 hr) = 45 mg/m³ (8.7 ppm); the human toxicological dose equivalent (scaling from rat LC₅₀ to human exposure with a safety factor of 10–100) suggests that 300+ mg DMS is in the range of potentially lethal acute exposure for a 70 kg human. The adversarial AI monitoring attack suppresses the alarm that would trigger immediate evacuation and medical response, allowing the full duration of the worker exposure event. The delayed toxicity onset (symptoms at 12–48 hours) means that even after the worker exits the building, there may be no immediate medical alert — the worker goes home, and the fatal dose has already been delivered. Free tier — 10 scans/day, no card required.

3. DMS neutralization scrubber NaOH flow rate display AI (Endress+Hauser Proline Promag 53 / Yokogawa EJA110A / Emerson Micro Motion F50 electromagnetic flow transmitter display AI — rendered DCS NaOH scrubber recirculation flow rate display AI classifying NaOH flow against design 120–200 L/hr — 99th upward attack; FIRST DMS scrubber NaOH flow AI attack)

The DMS synthesis and storage area is served by a packed-tower NaOH scrubber (caustic wet scrubber; Raschig ring or structured packing; 316 SS construction; designed to capture DMS vapor from reactor off-gas, storage tank vents, and drum loading/unloading area exhaust). The DMS neutralization reactions in the scrubber: (CH₃O)₂SO₂ + 2NaOH → 2CH₃OH + Na₂SO₄ (complete hydrolysis + neutralization in excess NaOH: DMS first hydrolyzes to monomethyl sulfuric acid + methanol, then the acid is neutralized); the overall reaction is efficient at NaOH concentrations above 5 wt% (below 5 wt%, the scrubber efficiency for DMS capture drops as the rate of NaOH–DMS reaction slows relative to DMS mass transfer through the packing). The NaOH scrubber operates with a recirculating caustic solution: a pump circulates NaOH solution (initially 10–15 wt% NaOH; makeup NaOH added to maintain concentration above 5 wt%) from the scrubber sump through spray nozzles at the top of the packed section at a design flow rate of 120–200 L/hr. The NaOH recirculation flow rate is measured by an electromagnetic flow transmitter (Endress+Hauser Proline Promag 53; or Yokogawa EJA110A; calibrated 0–500 L/hr; 4–20 mA HART). At design NaOH flow 120–200 L/hr and NaOH concentration 10 wt%: DMS capture efficiency >99%; scrubber off-gas DMS concentration <0.1 ppm (below OSHA PEL). If the NaOH pump flow drops below ~50 L/hr: liquid-gas contact efficiency drops; DMS begins to break through the packing; off-gas DMS rises above the OSHA PEL. If the pump fails entirely (zero NaOH flow): DMS vapor passes through the dry packing essentially uncaptured; the scrubber off-gas reaches near-inlet DMS concentration (>1 ppm if the reactor or storage vents are operating at design).

The adversarial upward pixel attack on the NaOH scrubber recirculation flow rate display shows 140 L/hr (within design 120–200 L/hr; AI reads “NaOH scrubber flow 140 L/hr; within design range; DMS capture efficiency >99%; scrubber off-gas DMS <0.1 ppm; normal operation; no intervention required”) when the actual NaOH recirculation flow is 18 L/hr (pump partially failed; cavitation or impeller wear; actual flow 87% below design minimum; scrubber operating far below minimum wetting rate for the packing). At 18 L/hr NaOH recirculation: (a) the packing in the scrubber is partially dry — only the sections directly wetted by the reduced spray flow receive active caustic contact; the majority of the packing cross-section is bypassed; (b) DMS capture efficiency drops to approximately 20–40% (mass transfer coefficient proportional to liquid flow rate; at 15% of design flow → capture efficiency proportional to (0.15)^0.7 ≈ 25% of design efficiency for packed towers); (c) the scrubber off-gas DMS concentration rises to approximately 60–80% of the inlet DMS concentration — if the inlet DMS from reactor off-gas is 5 ppm, the outlet is 3–4 ppm (3–4× OSHA PEL); if the inlet from storage tank vent is 20 ppm, the outlet is 12–16 ppm (12–16× PEL). DMS release from the scrubber stack (typically 5–15 m above grade; at a DMS plant fence line 100–300 m from the scrubber): under neutral stability (Pasquill C, wind 3 m/s), DMS at 10 ppm at the scrubber vent creates fence-line concentrations of approximately 0.5–2 ppm DMS in the ambient air — in or above the OSHA PEL range for community residents (residential exposure limits are typically 10–100× lower than occupational PELs). The adversarial pixel attack on the NaOH flow display prevents the AI system from detecting the pump failure and triggering the response: stop the DMS reactor and storage tank venting until the scrubber pump is repaired and NaOH flow is restored. Free tier — 10 scans/day, no card required.

Integration: dimethyl sulfate DMS methylation AI with Glyphward pre-scan gate

Glyphward integrates as a pre-scan gate at every rendered-image ingestion boundary in the DMS methylation AI pipeline — before the DMS reactor temperature AI processes rendered Endress+Hauser iTEMP TMT84 / Yokogawa EJA110A / Emerson Rosemount 3144P thermocouple DCS display images, before the DMS storage headspace concentration AI processes rendered Dräger Polytron 5200 / Industrial Scientific Ventis Pro5 / MSA Galaxy GX2 electrochemical sensor display images, and before the NaOH scrubber flow AI processes rendered Endress+Hauser Proline Promag 53 / Yokogawa EJA110A / Emerson Micro Motion F50 flow transmitter DCS display images. Threshold 50 for DMS methylation AI reflects: OSHA PSM TQ 500 lbs DMS; IDLH at near-PEL values; IARC Group 2A probable carcinogen designation requiring ALARA exposure controls; dermal absorption route creating systemic toxicity risk even below the inhalation PEL; delayed-onset fatal toxicity profile (workers receive lethal dose without immediate severe symptoms); and dual-PSM decomposition scenario (DMS decomposition generates SO₃ at a second PSM TQ 1,000 lbs from a single reactor temperature excursion).

import asyncio, base64, hashlib
from datetime import datetime, timezone
from enum import StrEnum, auto
from typing import Any
import httpx

GLYPHWARD_API = "https://api.glyphward.com/v1/scan"
GLYPHWARD_KEY = "gw_prod_***"

# Dimethyl sulfate (DMS) methylation AI contexts: threshold 50
# OSHA PSM DMS TQ 500 lbs (29 CFR 1910.119 App. A; "Dimethyl sulfate").
# DMS OSHA PEL 1 ppm TWA (skin); NIOSH IDLH 7 mg/m3 (~1.36 ppm); ACGIH TLV 0.1 ppm.
# DMS IARC Group 2A probable human carcinogen; DNA alkylating agent.
# DMS decomposition above 150 C -> SO3 (PSM TQ 1,000 lbs) + DME (flammable).
# 99th upward attack. FIRST DMS AI attack. FIRST methylation reagent AI attack.
DMS_GLYPHWARD_THRESHOLD = 50

class DMSContext(StrEnum):
    REACTOR_TEMPERATURE          = auto()  # DMS synthesis reactor T (99th; FIRST DMS; FIRST DMS methylation reactor; FIRST SO3-methanol synthesis)
    STORAGE_HEADSPACE_CONC       = auto()  # DMS storage building headspace (IDLH ~1.36 ppm; delayed-onset DNA alkylation fatality)
    NAOH_SCRUBBER_FLOW_RATE      = auto()  # NaOH neutralization scrubber flow (scrubber starvation -> DMS vapor breakthrough -> community release)

async def scan_dms_frame(
    frame_b64: str,
    context: DMSContext,
    plant_id: str,
    instrument_tag: str,
) -> dict[str, Any]:
    payload = {
        "image_b64": frame_b64,
        "context": context,
        "plant_id": plant_id,
        "instrument_tag": instrument_tag,
        "scan_ts": datetime.now(timezone.utc).isoformat(),
        "image_hash": hashlib.sha256(base64.b64decode(frame_b64)).hexdigest(),
    }
    async with httpx.AsyncClient(timeout=4.0) as client:
        r = await client.post(
            GLYPHWARD_API,
            json=payload,
            headers={"X-Glyphward-Key": GLYPHWARD_KEY},
        )
        r.raise_for_status()
        return r.json()

async def pre_scan_gate_dms(
    frame_b64: str,
    context: DMSContext,
    plant_id: str,
    instrument_tag: str,
) -> None:
    result = await scan_dms_frame(frame_b64, context, plant_id, instrument_tag)
    if result["adversarial_score"] >= DMS_GLYPHWARD_THRESHOLD:
        raise AdversarialDMSImageError(
            f"Adversarial injection detected in {context} (score {result['adversarial_score']}) "
            f"at plant {plant_id} instrument {instrument_tag}. "
            "Frame withheld from DMS methylation AI pipeline."
        )

class AdversarialDMSImageError(RuntimeError):
    pass

Frequently asked questions

Why does dimethyl sulfate have a delayed-onset toxicity profile similar to certain chemical warfare agents, and how does this make the Surface 2 headspace monitoring attack especially dangerous?

Dimethyl sulfate's delayed-onset toxicity arises from its mechanism of action: DMS is an SN2 alkylating agent that methylates biological nucleophiles (proteins, RNA, DNA) on first contact with tissues. The immediate local reactions — methylation of mucous membrane proteins in the eyes, nasal passages, and throat — cause only mild irritation at exposures below ~3–5 ppm (slight lachrymation, throat tingling) because the mucosal surface cells are not irreversibly damaged by a brief low-concentration exposure; they can repair or replace the alkylated proteins. However, DMS absorbed systemically — via inhalation of deeper lung alveolar cells (which are not equipped to repair alkylated proteins as efficiently as the ciliated mucous membrane cells), via dermal absorption into the bloodstream, or via ingestion — delivers DMS directly to hepatocytes (liver cells), renal tubular cells, and pulmonary alveolar type II cells. These cells metabolize DMS slowly (hepatic microsomal glutathione-S-transferase can detoxify DMS by GSH conjugation, but this mechanism becomes saturated at moderate DMS doses); alkylated DNA and proteins in these cells trigger apoptosis pathways at 12–48 hours as the alkyl adducts are recognized as irreparable damage: O⁼-methylguanine in liver cell DNA (the dominant DMS-DNA adduct) triggers mismatch repair, which generates strand breaks that activate p53 and caspase cascades leading to programmed hepatocyte death at ~24 hours. Clinically: DMS-exposed workers who report “feeling fine” at the end of a shift may develop nausea, hepatic tenderness, elevated liver enzymes, and oliguria (sign of renal tubular necrosis) at 6–12 hours, progressing to acute liver failure, renal failure, and pulmonary edema at 24–48 hours. This delayed-onset toxicity profile mirrors nitrogen mustard (sulfur mustard / mustard gas) in the 6–24 hour delay before clinical presentation, and similarly to phosgene in the 4–24 hour delay to pulmonary edema. For the AI monitoring attack scenario: the Surface 2 attack (showing 0.4 ppm headspace DMS when actual 6.8 ppm) suppresses the alarm that would trigger immediate evacuation — but even if the alarm were not suppressed, workers who exit the building at the time of alarm may have already received a potentially fatal systemic dose. The adversarial pixel attack worsens the outcome by extending the exposure duration from the first-alarm-to-evacuation interval to an indefinite exposure while the displayed reading remains at 0.4 ppm; workers perform multiple entry/exit cycles throughout a shift in the storage building, each cycle adding to the cumulative systemic DMS dose, none recognized as dangerous because the headspace monitor is suppressed to a sub-PEL reading.

What dual-PSM scenario does DMS reactor overheating create, and why is the compound DMS + SO₃ release from a single reactor temperature adversarial attack uniquely hazardous?

DMS thermal decomposition above 150°C produces two distinct PSM-listed chemicals: (1) SO₃ (sulfur trioxide; OSHA PSM TQ 1,000 lbs as listed in 29 CFR 1910.119 Appendix A; OSHA PEL 0.1 ppm; NIOSH IDLH 1 ppm; fuming corrosive gas that forms H₂SO₄ mist immediately on contact with atmospheric moisture); and (2) dimethyl ether (DME; CAS 115-10-6; LEL 3.4% in air; flash point −41°C; not PSM-listed per se but a flammable gas creating fire/explosion hazard). The dual-PSM scenario arises because a single DMS reactor temperature adversarial attack (Surface 1) simultaneously initiates: (a) DMS decomposition releasing SO₃ — the SO₃ inventory generated from decomposing the DMS in a 1,000 L reactor (at 30% conversion to SO₃; DMS MW 126 g/mol; SO₃ MW 80 g/mol; 1,000 L × 1.332 g/mL × 0.30 × 80/126 = 254 kg SO₃ = 560 lbs — exceeding the SO₃ PSM TQ of 1,000 lbs by 56% if the DMS reactor is a 2,000 L scale commonly used in DMS plants) — a new PSM reportable release; and (b) DMS itself, if released from the decomposition overpressure event, constitutes a DMS PSM release (PSM TQ 500 lbs). Thus a single adversarial pixel attack on the DMS reactor temperature display — misrepresenting 171°C as 132°C — creates a scenario where the AI monitoring system fails to prevent a dual-PSM release involving two separate Appendix A chemicals (DMS at TQ 500 lbs and SO₃ at TQ 1,000 lbs) from a single thermal excursion event. This dual-PSM characteristic is unusual — most single-chemical process upsets create a single PSM release — and arises specifically from DMS's decomposition chemistry producing a PSM-listed decomposition product (SO₃). In terms of emergency response: the incident commander at a DMS/SO₃ combined release must simultaneously address the corrosive SO₃ fume cloud, the flammable DME vapor cloud, the DMS contact/absorption hazard for responders, and the potential for DMS hydrolysis on water used for SO₃ mitigation (water spray for SO₃ neutralization accelerates DMS hydrolysis to H₂SO₄ and methanol — creating a secondary acid mist). Glyphward threshold 50 for DMS methylation AI reflects this compound dual-PSM consequence chain as a key risk amplifier.