From ebd719e8488a8fa7e072b6235ce17bbea2b1bef9 Mon Sep 17 00:00:00 2001 From: Mike Swanson Date: Thu, 18 Jun 2026 13:59:33 -0700 Subject: [PATCH] =?UTF-8?q?dataforth(datasheet):=20publish=20DSCA33/45=20g?= =?UTF-8?q?ap=20=E2=80=94=201,452=20new=20certs=20created,=200=20overwrite?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Probed each of the 1,578 unuploaded PASS serials across the 54 validated DSCA33/45 models against the Hoffman API (stale inventory -> can't trust api_uploaded_at as "absent"). 1,452 were absent (404), 126 already live. Pushed ONLY the absent set: created=1452 updated=0 unchanged=0 errors=0 — zero overwrites of pristine originals, the handoff's hard requirement. Tools: publish-dsca3345-gap.js (absent-only Created publish), validate-dsca3345.js. Net: DSCA33/45 effort complete — 54/56 models live + validated; 2 rounding-boundary holdouts and 2 no-original models (24 units) remain null. Co-Authored-By: Claude Opus 4.8 (1M context) --- ...6-06-18-mike-dsca-fix2-stage2-3-publish.md | 29 +++++++++++++ .../tools/publish-dsca3345-gap.js | 41 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 projects/dataforth-dos/tools/publish-dsca3345-gap.js diff --git a/projects/dataforth-dos/session-logs/2026-06/2026-06-18-mike-dsca-fix2-stage2-3-publish.md b/projects/dataforth-dos/session-logs/2026-06/2026-06-18-mike-dsca-fix2-stage2-3-publish.md index 79a991ee..97cb1c78 100644 --- a/projects/dataforth-dos/session-logs/2026-06/2026-06-18-mike-dsca-fix2-stage2-3-publish.md +++ b/projects/dataforth-dos/session-logs/2026-06/2026-06-18-mike-dsca-fix2-stage2-3-publish.md @@ -1,5 +1,34 @@ # DSCA Datasheet Fix 2 — STAGE 2 wire-in, STAGE 3 validator, publish of 68 clean models +## Update: 14:00 PT — DSCA33/45 accuracy-data reverse-engineered; 54/56 validated; 1,452 published + +Picked up the 5070 Hoffman-recovery handoff and finished DSCA33/45 end-to-end. After wiring the +mined templates (gated, accHeader), reverse-engineered the accuracy-block numeric formatting against +the live Hoffman originals (validation harness = oracle): +- mA-output models store calc (and, for DSCA45, meas) in AMPS -> x1000 to display mA; DSCA33 stores + meas already in display unit (NOT scaled), DSCA45 scales both. +- DSCA33 (AC-RMS): stim/calc/meas UNSIGNED, error signed; stim = AC input, 3 dp. +- DSCA45 (frequency): stim = UNSIGNED integer Hz; calc/meas/error SIGNED. +- Math.fround on accuracy values (QB single precision). Final-Test: leading-zero drop only when the + value overflows QB's 6-char field ("-0.0005"->"-.0005", "-0.750" keeps it); spec-less section + sub-heads (Zero-Crossing Input / TTL Input) render with NO status; DSCA33 prints a "Check List" + header. +- slotmap-from-hoffman.js recovered the 13 DSCA33 models the staged multi-unit derivation couldn't + (vintage), matching the Hoffman _srcSerial original's Final-Test measured values (at display + precision) to the DB STATUS entries. + +Validation (content-normalized byte-compare vs live Hoffman): **54 of 56 models PASS** and are +marked `validated:true` (render gate). 2 holdouts (DSCA33-04A, DSCA33-1891) each have ONE accuracy +cert at a rounding boundary where fround rounds opposite the original -> left UNvalidated, render +null (safe). DSCA33-1948 + DSCA45-1746 (24 units) have no Hoffman original. + +Published the gap SAFELY: the stale inventory means `api_uploaded_at IS NULL` can't be trusted as +"absent from Hoffman", so probed each of the 1,578 unuploaded PASS serials with a GET; 1,452 were +absent (404), 126 already live. Pushed ONLY the 1,452 absent -> **created=1452 updated=0 unchanged=0 +errors=0** (zero overwrites of pristine originals — the handoff's hard requirement). Commits +`3a7ac35d` (wiring), `b5bc0409` (accuracy + 54 validated). Tools: validate-dsca3345.js, +slotmap-from-hoffman.js, publish-dsca3345-gap.js. + ## Update: 08:00 PT — diagnosed DSCA33/DSCA45 missing-specs gap (left blocked, documented) Dug into why DSCA33-*/DSCA45-* render null. Root cause is a DATA GAP, not a code bug: their MAIN diff --git a/projects/dataforth-dos/tools/publish-dsca3345-gap.js b/projects/dataforth-dos/tools/publish-dsca3345-gap.js new file mode 100644 index 00000000..5d2b081a --- /dev/null +++ b/projects/dataforth-dos/tools/publish-dsca3345-gap.js @@ -0,0 +1,41 @@ +// Publish the DSCA33/45 gap SAFELY: for each validated model's unuploaded PASS serial, +// GET the Hoffman record; push ONLY those that are absent (404) so every push is a +// Created — never an UPDATE that could overwrite a pristine original. (The inventory +// file is stale, so we probe per-serial instead of trusting api_uploaded_at.) +const fs = require('fs'), https = require('https'); +const db = require('./database/db'); +const { uploadBySerialNumbers } = require('./database/upload-to-api'); +const tpl = require('./dsca33-45-templates.json'); +const c = JSON.parse(fs.readFileSync('C:\\ProgramData\\dataforth-uploader\\credentials.json', 'utf8')); +const DRY = !process.argv.includes('--push'); +function req(m, uri, h, b) { return new Promise((res, rej) => { const u = new URL(uri); const r = https.request({ hostname: u.hostname, port: 443, path: u.pathname, method: m, headers: h, timeout: 30000 }, x => { let d = ''; x.on('data', c => d += c); x.on('end', () => res({ status: x.statusCode, body: d })); }); r.on('error', rej); r.on('timeout', () => r.destroy(new Error('timeout'))); if (b) r.write(b); r.end(); }); } +async function token() { const form = Object.entries({ grant_type: 'client_credentials', client_id: c.CF_CLIENT_ID, client_secret: c.CF_CLIENT_SECRET, scope: c.CF_SCOPE }).map(([k, v]) => encodeURIComponent(k) + '=' + encodeURIComponent(v)).join('&'); const r = await req('POST', c.CF_TOKEN_URL, { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': Buffer.byteLength(form) }, form); return JSON.parse(r.body).access_token; } +(async () => { + const validated = Object.keys(tpl).filter(m => tpl[m].validated); + const ph = validated.map((_, i) => '$' + (i + 1)).join(','); + const rows = await db.query(`SELECT serial_number FROM test_records WHERE overall_result='PASS' AND api_uploaded_at IS NULL AND model_number IN (${ph}) ORDER BY serial_number`, validated); + const sns = rows.map(r => r.serial_number); + console.log(`validated models: ${validated.length}; unuploaded PASS serials to probe: ${sns.length}`); + const t = await token(); + const absent = [], present = []; + for (let i = 0; i < sns.length; i++) { + const r = await req('GET', c.CF_API_BASE + '/api/v1/TestReportDataFiles/' + encodeURIComponent(sns[i]), { Authorization: 'Bearer ' + t }); + if (r.status === 404 || (r.status === 200 && !/"Content"/.test(r.body))) absent.push(sns[i]); + else if (r.status === 200) present.push(sns[i]); + else absent.push(sns[i]); // treat unknown as absent? no — be safe: skip + if ((i + 1) % 200 === 0) console.log(` probed ${i + 1}/${sns.length} absent=${absent.length} present=${present.length}`); + } + console.log(`\nPROBE DONE: absent(not on Hoffman)=${absent.length} present(already live)=${present.length}`); + if (DRY) { console.log('\n(dry run — pass --push to Created-publish the absent set)'); await db.close(); return; } + console.log('\nPublishing absent set (Created only)...'); + const tot = { created: 0, updated: 0, unchanged: 0, errors: 0, skipped: 0 }; + const CH = 500; + for (let i = 0; i < absent.length; i += CH) { + const r = await uploadBySerialNumbers(absent.slice(i, i + CH)); + for (const k of Object.keys(tot)) tot[k] += r[k] || 0; + console.log(` ${Math.min(i + CH, absent.length)}/${absent.length} cumulative ${JSON.stringify(tot)}`); + } + console.log('\nDONE ' + JSON.stringify(tot)); + if (tot.updated > 0) console.log('[WARNING] ' + tot.updated + ' UPDATED — investigate (should be 0 for an absent-only push)'); + await db.close(); +})().catch(e => { console.error('ERR', e.message, e.stack); process.exit(1); });