INNER CODE UNIT · JavaScript
open
Manavarya09/design-extract · src/fidelity/index.js:64
const open = counts.high + counts.medium + counts.low;
parts.push(open ? `${open} correction(s): ${counts.high} high, ${counts.medium} med, ${counts.low} low` : 'no corrections outstanding');
return parts.join(' · ');
}
/**
* Drive the closed correction loop.
* @param {object} args
* @param {() => Promise<{verify,motion}>|{verify,motion}} args.measure re-measure fidelity
* @param {(plan:object, round:number) => Promise<void>|void} [args.rebuild] apply corrections
* @param {number} [args.threshold] stop once overall >= this (default 90)
* @param {number} [args.maxRounds] hard cap on iterations (default 4)
* @returns {Promise<{rounds:Array, final:object, converged:boolean}>}
*/
export async function runFidelityLoop({ measure, rebuild, threshold = 90, maxRounds = 4 } = {}) {
if (typeof measure !== 'function') throw new TypeError('runFidelityLoop requires a measure() function');
const rounds = [];