Fix: green Python CI + snake_case wire contract (SotA) + mock runner - #1
Merged
Conversation
Part 1 — CI: ruff errored (exit 2) on every push since Phase 2 because W503 is not a ruff rule (`invalid value 'W503'`). Move ruff config into pyproject.toml, run `ruff check .`, and fix the 7 real violations underneath (E731 lambda in catalog.py + 6 unused imports). Part 2 — Contract alignment: the Swift runner (Codables.swift) emits/expects camelCase for nested input/output/timing/health fields — only model_id and size_mb are snake_case. bridge.py and the nodes used snake_case in several places, so even with the real binary depth/image-gen would get outputPath=None, all timing would read 0, and HealthCheck would show "?". Align the Python side to the real wire format, and add the missing `text_prompt` param to bridge.predict() (the segmentation node previously raised TypeError). Part 3 — tools/mock_runner.py: a zero-dependency (stdlib-only, incl. a tiny pure-Python PNG writer) stand-in for the coreai-runner binary, which can't be compiled here yet (CoreAIKit needs the macOS 27 SDK). It speaks the exact Unix-socket protocol and is swapped in via COREAI_RUNNER_PATH, unblocking end-to-end dogfooding today with placeholder outputs. Part 4 — tests/test_mock_integration.py: pytest that spawns the mock and exercises bridge <-> runner over the real protocol for every capability (depth, detection, VLM, segmentation, instance-seg, CLIP, image-gen). Runs on Linux CI (AF_UNIX, no torch); added as a CI step. Verified locally: ruff clean, all 3 CI steps pass, 9 integration tests pass, and the real CoreAIDepthEstimation node round-trips headless via the mock. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
CI invokes bare `pytest tests/` (not `python -m pytest`), which does not add the repo root to sys.path, so `from comfyui_coreai import ...` failed with ModuleNotFoundError. Add [tool.pytest.ini_options] pythonpath = ["."]. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A cross-source analysis (Apple, HuggingFace, ComfyUI, the .aimodel/Zoo format, and Kevin's own coreai-catalog/coreai-fabric) found the whole ecosystem is snake_case; the runner's camelCase was an un-decided Swift Codable default — the runner's own CatalogClient.swift already maps every snake_case catalog key via explicit CodingKeys, proving the author knew the convention. Standardize the Python bridge, all nodes, the mock runner, and the integration tests on snake_case (imagePath->image_path, outputPath->output_path, totalMs->total_ms, memoryTotalGB->memory_total_gb, maskPaths->mask_paths, ...). This also fixes the pre-existing maskPaths/maskPath camelCase inconsistency in the segmentation node. `kind` enum VALUES (e.g. "depthMap") are left verbatim. The Swift runner gets a matching snake_case CodingKeys change (compile-pending) delivered separately in coreai-runner. Verified: ruff clean, 9/9 integration tests pass, and the real Depth + HealthCheck nodes round-trip headless via the mock (health now shows real values). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
O que e por que
A sessão anterior parou logo após os pushes (nada perdido). Ao continuar, a investigação achou 3 problemas — 1 óbvio (CI vermelho) e 2 latentes (nunca pegos porque nada rodava end-to-end) — e este PR corrige os três + destrava o dogfooding sem o binário Swift (que exige o SDK do macOS 27).
Mudanças
1. CI de Python verde
ruff check ... --ignore E402,W503falhava com exit 2 em todo push desde a Phase 2 (W503não existe no ruff). Config movida parapyproject.toml,ruff check ., 7 violações reais corrigidas.2. Contrato do wire em snake_case (decisão SotA)
Uma análise multi-fonte (Apple, HuggingFace, ComfyUI,
.aimodel/Zoo, e os reposcoreai-catalog/coreai-fabric) concluiu que snake_case é o SotA: todo o ecossistema é snake_case, e o camelCase do runner era só o default do Swift Codable (o próprioCatalogClient.swiftjá mapeia snake_case). Entãobridge.py, os 9 nós, o mock e os testes falam snake_case. Isso também corrige a inconsistência pré-existentemaskPaths/maskPath. O runner recebe as CodingKeys snake_case correspondentes em coreai-runner PR #1 (compile-pending). Também adiciona o parâmetrotext_promptque faltava (nó de segmentação crashava comTypeError).3.
tools/mock_runner.py— stand-in de DEV/TESTERunner-mock zero-dependência (stdlib + encoder PNG puro-Python) que fala o protocolo exato em snake_case. Trocável pelo binário real via
COREAI_RUNNER_PATH. Destrava o dogfooding end-to-end hoje.4.
tests/test_mock_integration.pyPytest que sobe o mock e exercita bridge↔runner no protocolo real para todas as capabilities. Roda no CI Linux (AF_UNIX, sem torch).
Verificação (verde)
ruff check .→ 0 erros · 3 steps do CI + 9/9 testes de integração passamCoreAIDepthEstimation+CoreAIHealthCheckfazem round-trip headless via o mock (health mostra valores reais)Follow-up
Quando o binário Swift compilar (Xcode 26 / macOS 27 beta), aponte
COREAI_RUNNER_PATHpara ele — as CodingKeys snake_case do coreai-runner PR #1 garantem que casa sem retrabalho.🤖 Generated with Claude Code