Spaces:
Sleeping
Sleeping
File size: 1,830 Bytes
f88cb09 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | /** engine/decisionKernel.js - The Governance Kernel */
/**
* Analyzes image technical data against user requirements.
* Rules:
* 1. DPI < 150 -> REJECT_LOW_RES
* 2. Dimension mismatch > 10% -> DIMENSION_MISMATCH
* 3. Else -> READY_FOR_PRINT
*
* @param {Object} visionData - Technical data from LLM (dpi, width_mm, height_mm)
* @param {Object} session - Current session with draft order details
*/
function analyzePrintReadyStatus(visionData, session) {
if (!visionData) return { status: 'UNKNOWN' };
const dpi = parseInt(visionData.dpi || 0);
const width = parseFloat(visionData.width_mm || 0);
const height = parseFloat(visionData.height_mm || 0);
// Rule 1: DPI Kill Switch
if (dpi < 150) {
return {
status: 'REJECT_LOW_RES',
details: `DPI detected: ${dpi} (Required: 150+)`,
raw: { dpi, width, height }
};
}
// Rule 2: Dimension Mismatch (if target product has defined dimensions)
// For now, checking against draftAttributes if they exist
const draft = session.draftAttributes || {};
if (draft.width && draft.height) {
const targetW = parseFloat(draft.width);
const targetH = parseFloat(draft.height);
const diffW = Math.abs(width - targetW) / targetW;
const diffH = Math.abs(height - targetH) / targetH;
if (diffW > 0.1 || diffH > 0.1) {
return {
status: 'DIMENSION_MISMATCH',
details: `Detected: ${width}x${height}mm vs Required: ${targetW}x${targetH}mm`,
raw: { dpi, width, height }
};
}
}
return {
status: 'READY_FOR_PRINT',
details: 'File meets technical requirements.',
raw: { dpi, width, height }
};
}
module.exports = { analyzePrintReadyStatus };
|