* fix(ingestion): link an image only to a prompt that provably produced it An LLM fed a PromptManagerPair's prepend_text while its text editor was empty. The node refused to save (an empty positive raised and logged a warning), and the image monitor then linked the image to a stale tracker entry or to the newest prompt in the database. - Nodes: an empty text editor saves and tracks nothing (prepend and append text are never the stored prompt), logs at info, and marks the node's run key empty so no earlier entry can be used for its images. - Tracker entries carry a run key: a digest of the prompt node and its whole upstream graph, the identity ComfyUI's cache uses. The monitor computes the same key from the image's embedded graph and uses a queued or snapshot entry only when the keys match (a snapshot also needs a known run with one entry, so a batch's last item is never applied to every image). - The recency fallback is gone; anything uncertain stays unlinked and is logged at info. - Recorded execution history attributes a file when exactly one run reported it, the file was written during that run, and the run's positive contexts name one stored prompt. The monitor and the output scan use it as their last certain source. - The scan and pair ingestion treat a resolved pair with an empty stored positive as unresolved instead of raising. - tools/review_image_links.py reviews selected links by these rules; dry run by default, --apply changes only named ids after a backup. Closes #342 * test(ingestion): real-host attribution case and the #342 testing contract The managed host disables the image monitor, so the owned fixture pack gains a route that starts and stops the plugin's monitor singleton for the attribution case only. The case runs in both renderers: a typed Pair image links, a Pair image whose positive is only linked prepend text stays unlinked with nothing stored, an unknown node feeding text links through its run key, and its cached re-run links again. * fix(ingestion): take a queued entry only from the run the image appeared in Dropping a key's older queue entries whenever the node ran again let a later queued run, executing during the monitor's processing delay, take the earlier image's entry. The snapshot taken when the image appears now names the key's latest run, and the queue is popped by key and run: same-key entries of earlier runs ahead of it are stale, entries of later runs wait for their own images. Also keeps the attribution case out of the stock real-host suite. * test(ingestion): host lookups degrade to no proof * fix(ingestion): address the #344 review (history re-check, keys, repair) - Images without an embedded API graph: the scan now asks recorded history before skipping a file with no prompt metadata, and the monitor gives a keyless unlinked image one history-only re-check when its run's outputs are recorded (a seal notification from the outputs write; at most 1000 waiting images, each for an hour). - Run keys: an image is unkeyable when any positive node has no key, so a two-pass graph is never linked through the other pass; links follow ComfyUI's is_link exactly. - A failed save marks the node's run key like an empty editor, so an older entry of that key can't stand in for this run. - A placeholder is the latest entry: the image stays unlinked without falling through to history, the same rule as a popped placeholder. - An index on execution_run_outputs(filename, subfolder, root_key, path_style) for the history lookup, added by migration and accepted by the output schema check (any other index is still refused). - Repair tool: unlink removes only the link record and only while the image is still linked to the prompt it was judged on; every run prints what --apply does. - Real-host case proves the re-run's PromptManager node was cached. * test(ingestion): real-host bare-output re-check and the review-round contract A metadata-disabled save, held open behind the fixture gate after SaveImage, waits unlinked while its run is open and links once the run's outputs are recorded. The fixture's monitor route lists the waiting files. TESTING.md covers the history re-check, the read index and what the repair tool's --apply does. * fix(ingestion): batch history lookups instead of adding an index An index on execution_run_outputs would make the library unopenable by older builds, whose schema check refuses any extra index there. The migration and the schema-check allowance are reverted, so the history schema is exactly main's. stored_run_prompts instead looks up a batch of files with one parameterized filename IN (...) query per chunk of at most 500 names and matches in memory; the scan computes it once per scan batch. * fix(ingestion): address the #344 re-review (seal race, linked roots) - A sealed history re-check that can't be scheduled yet (the image's own pass still pending, or the pending set full) is kept due and scheduled when a pending image finishes, instead of being dropped. - History matches a file through ComfyUI's spelling of its output folder first, then with both sides resolved, so a symlinked or junction output folder still attributes the scan's resolved paths; waiting files are keyed by their resolved path. - The scan makes its batch history lookup only when a file needs it. - set_current_prompt pushes to the queue last, so marking a failed execution never adds a second queue slot. - A keyless image outside the output folder doesn't take a waiting slot.
77 lines
5.1 KiB
JavaScript
77 lines
5.1 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { execFileSync } from 'node:child_process';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { readFileSync } from 'node:fs';
|
|
|
|
const root = fileURLToPath(new URL('../../', import.meta.url));
|
|
test('real-ComfyUI suite registers Classic and Nodes 2.0 startup projects', () => {
|
|
const output = execFileSync(process.execPath, ['tools/vendor/node_modules/@playwright/test/cli.js',
|
|
'test', '--config', 'tools/vendor/comfyui.config.mjs', '--list'], {
|
|
cwd: root, encoding: 'utf8', env: { ...process.env,
|
|
PM_COMFY_ROOT: '/unused-pinned-checkout', PM_COMFY_URL: 'http://127.0.0.1:8199/' },
|
|
});
|
|
assert.match(output, /\[classic-start\]/);
|
|
assert.match(output, /\[nodes2-start\]/);
|
|
});
|
|
|
|
test('execution script discovers only the new matrix and preserves all 78 original stock cases plus the native editor and renderer host cases', () => {
|
|
const manifest = JSON.parse(readFileSync(new URL('../../tools/vendor/package.json', import.meta.url), 'utf8'));
|
|
assert.equal(manifest.scripts['test:executions'], 'playwright test --config playwright.execution.config.mjs');
|
|
const list = config => execFileSync(process.execPath, ['tools/vendor/node_modules/@playwright/test/cli.js',
|
|
'test', '--config', config, '--list'], { cwd: root, encoding: 'utf8',
|
|
env: { ...process.env, PM_COMFY_ROOT: '/unused-pinned-checkout' } });
|
|
const stock = list('tools/vendor/comfyui.config.mjs');
|
|
// + local Inspect host case (inspect-sender.spec.mjs, 2 projects), + the S10 renderer case (prompt-bridge.spec.mjs, 2 projects)
|
|
// + #343 linked text: five node types, PromptSearchList, the pre-#343 workflows, legacy Primitive, moved link,
|
|
// paste/clone/undo, wildcard Primitive, subgraph Primitive (text-link.spec.mjs, 2 projects)
|
|
assert.match(stock, /Total: 110 tests in 9 files/);
|
|
assert.doesNotMatch(stock, /execution-history/);
|
|
assert.doesNotMatch(stock, /execution-outputs/);
|
|
assert.doesNotMatch(stock, /library-location/); // it starts its own fresh host (#249 S6b)
|
|
assert.doesNotMatch(stock, /image-attribution/); // needs the owned fixture pack (#342)
|
|
const executions = list('tools/vendor/playwright.execution.config.mjs');
|
|
assert.match(executions, /\[classic-start\]/);
|
|
assert.match(executions, /\[nodes2-start\]/);
|
|
// + the fresh-host library location case, + #342 image attribution, + #343 linked text
|
|
assert.match(executions, /Total: 90 tests in 5 files/);
|
|
for (const project of ['classic-start', 'nodes2-start']) {
|
|
const cases = executions.split('\n').filter(line => line.includes(`[${project}]`));
|
|
assert.equal(cases.filter(line => line.includes('execution-history.spec.mjs')).length, 15);
|
|
assert.equal(cases.filter(line => line.includes('execution-outputs.spec.mjs')).length, 8);
|
|
assert.equal(cases.filter(line => line.includes('library-location.spec.mjs')).length, 1);
|
|
assert.equal(cases.filter(line => line.includes('image-attribution.spec.mjs')).length, 2);
|
|
assert.equal(cases.filter(line => line.includes('execution-text-link.spec.mjs')).length, 19);
|
|
}
|
|
assert.doesNotMatch(executions, /prompt-manager.spec/);
|
|
});
|
|
|
|
test('execution config refuses live-host URLs and binds a managed loopback port', () => {
|
|
for (const url of ['http://127.0.0.1:8188/', 'https://127.0.0.1:8196/', 'http://localhost:8196/', 'http://example.com:8196/']) {
|
|
assert.throws(() => execFileSync(process.execPath, ['--input-type=module', '-e',
|
|
"await import('./tools/vendor/playwright.execution.config.mjs')"], { cwd: root, stdio: 'pipe',
|
|
env: { ...process.env, PM_COMFY_ROOT: '/unused', PM_EXECUTION_URL: url } }), /loopback|8196/);
|
|
}
|
|
});
|
|
|
|
test('CI retains stock, execution and pack suites in order with uploaded execution reports', () => {
|
|
const workflow = readFileSync(new URL('../../.github/workflows/test.yml', import.meta.url), 'utf8');
|
|
const commands = [...workflow.matchAll(/^ run: npm run --prefix tools\/vendor (test:[a-z]+)$/gm)].map(match => match[1]);
|
|
assert.deepEqual(commands, ['test:comfyui', 'test:executions', 'test:compat']);
|
|
assert.match(workflow, /path: tools\/vendor\/test-results\//);
|
|
});
|
|
|
|
test('real-host config waits for its own launcher, never for whichever server holds the port', async t => {
|
|
const previous = process.env.PM_COMFY_ROOT;
|
|
process.env.PM_COMFY_ROOT = '/unused-pinned-checkout';
|
|
t.after(() => { if (previous === undefined) delete process.env.PM_COMFY_ROOT; else process.env.PM_COMFY_ROOT = previous; });
|
|
const { default: config } = await import('../../tools/vendor/comfyui.config.mjs');
|
|
const [server] = config.webServer;
|
|
assert.equal(server.url, undefined);
|
|
assert.equal(server.port, undefined);
|
|
assert.equal(server.reuseExistingServer, false);
|
|
const ready = server.wait.stdout.exec('Starting server\nPM_COMFY_HOST_READY base-directory=/tmp/comfyassets-host-a b\r\nlater');
|
|
assert.equal(ready.groups.pm_comfy_host_base, '/tmp/comfyassets-host-a b');
|
|
assert.equal(server.wait.stdout.exec('To see the GUI go to: http://127.0.0.1:8189'), null);
|
|
});
|