fix(inspect): never fill a setting the file does not record
The legacy parser can take a FaceDetailer as the generation sampler and report its CFG for a workflow whose guider records none. Fill a setting from the legacy parse only when the server left it unresolved or ambiguous; a known value or a definite "not recorded" stays. The corpus and parity Node tools again measure extractGenerationFacts on its own, the contract their fixture vectors describe.
This commit is contained in:
@@ -11,7 +11,7 @@ import path from 'node:path';
|
||||
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||
const web = path.join(here, '..', '..', '..', 'web', 'js');
|
||||
const require = createRequire(import.meta.url);
|
||||
const parser = require(path.join(web, 'comfy-metadata.js')), { extractGenerationFacts } = parser;
|
||||
const { extractGenerationFacts } = require(path.join(web, 'comfy-metadata.js'));
|
||||
const { projectInspectionPayload } = await import(pathToFileURL(path.join(web, 'workspace', 'inspection-state.mjs')).href);
|
||||
|
||||
const chunks = [];
|
||||
@@ -19,7 +19,7 @@ for await (const chunk of process.stdin) chunks.push(chunk);
|
||||
const output = {};
|
||||
for (const { name, body } of JSON.parse(Buffer.concat(chunks).toString('utf8'))) {
|
||||
const identity = { kind: 'rooted-file', key: `0:${name}.png`, root_index: 0, path: `${name}.png`, root_scope: null };
|
||||
const record = projectInspectionPayload(JSON.parse(body), identity, null, extractGenerationFacts, false, parser);
|
||||
const record = projectInspectionPayload(JSON.parse(body), identity, null, extractGenerationFacts);
|
||||
output[name] = Object.fromEntries(Object.entries(record.generation).map(([field, fact]) => [field, { status: fact.status, value: fact.value }]));
|
||||
}
|
||||
process.stdout.write(JSON.stringify(output));
|
||||
|
||||
@@ -544,3 +544,14 @@ test('callers without the browser global pass the legacy parser explicitly', ()
|
||||
assert.equal(record.prompts.positive.text, 'a lighthouse at dusk, oil painting');
|
||||
assert.equal(record.prompts.negative.text, 'blurry, watermark');
|
||||
});
|
||||
|
||||
test('a setting the file does not record is never filled from the legacy parse', t => {
|
||||
globalThis.ComfyMetadata = require('../../web/js/comfy-metadata.js');
|
||||
t.after(() => { delete globalThis.ComfyMetadata; });
|
||||
const entry = image(), data = envelope(entry);
|
||||
data.metadata.prompt_graph = { status: 'parsed', value: detailerPipelineGraph() };
|
||||
const extract = input => ({ ...extractGenerationFacts(input), cfg: { status: 'not-recorded', value: null, source: null, evidence: null, reason: null, sampler_id: null } });
|
||||
const record = contract('toInspectionRecord')(data, entry, extract);
|
||||
assert.equal(record.generation.cfg.status, 'not-recorded');
|
||||
assert.equal(record.generation.cfg.value, null);
|
||||
});
|
||||
|
||||
@@ -10,13 +10,13 @@ import readline from 'node:readline';
|
||||
|
||||
const web = path.join(path.resolve(process.argv[2]), 'web', 'js');
|
||||
const require = createRequire(import.meta.url);
|
||||
const parser = require(path.join(web, 'comfy-metadata.js')), { extractGenerationFacts } = parser;
|
||||
const { extractGenerationFacts } = require(path.join(web, 'comfy-metadata.js'));
|
||||
const { projectInspectionPayload } = await import(pathToFileURL(path.join(web, 'workspace', 'inspection-state.mjs')).href);
|
||||
const identity = { kind: 'rooted-file', key: '0:corpus.png', root_index: 0, path: 'corpus.png', root_scope: null };
|
||||
|
||||
function facts(line) {
|
||||
try {
|
||||
const record = projectInspectionPayload(JSON.parse(line), identity, null, extractGenerationFacts, false, parser);
|
||||
const record = projectInspectionPayload(JSON.parse(line), identity, null, extractGenerationFacts);
|
||||
return Object.fromEntries(Object.entries(record.generation).map(([field, fact]) => [field, { status: fact.status, reason: fact.reason ?? null }]));
|
||||
} catch (error) {
|
||||
return { error: error?.name || 'Error' };
|
||||
|
||||
@@ -187,7 +187,8 @@ function withWorkflowParams(record, parser = comfyMetadata()) {
|
||||
}
|
||||
record.prompts = prompts;
|
||||
for (const [field, key] of LEGACY_FACTS) {
|
||||
if (!found(key) || record.generation[field]?.status === 'known') continue;
|
||||
// Only open answers are filled: a known value or a definite "not recorded" stays.
|
||||
if (!found(key) || !['unresolved', 'ambiguous'].includes(record.generation[field]?.status)) continue;
|
||||
record.generation[field] = { status: 'known', value: String(params[key]), source: graph ? 'api-graph' : 'workflow', evidence: 'configuration', reason: null, sampler_id: null };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user