Skip to content

Fix: green Python CI + snake_case wire contract (SotA) + mock runner - #1

Merged
kevinqz merged 3 commits into
mainfrom
claude/relaxed-mcclintock-1e124d
Jul 4, 2026
Merged

Fix: green Python CI + snake_case wire contract (SotA) + mock runner#1
kevinqz merged 3 commits into
mainfrom
claude/relaxed-mcclintock-1e124d

Conversation

@kevinqz

@kevinqz kevinqz commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

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,W503 falhava com exit 2 em todo push desde a Phase 2 (W503 não existe no ruff). Config movida para pyproject.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 repos coreai-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óprio CatalogClient.swift já mapeia snake_case). Então bridge.py, os 9 nós, o mock e os testes falam snake_case. Isso também corrige a inconsistência pré-existente maskPaths/maskPath. O runner recebe as CodingKeys snake_case correspondentes em coreai-runner PR #1 (compile-pending). Também adiciona o parâmetro text_prompt que faltava (nó de segmentação crashava com TypeError).

3. tools/mock_runner.py — stand-in de DEV/TESTE

Runner-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.py

Pytest 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 passam
  • Nós reais CoreAIDepthEstimation + CoreAIHealthCheck fazem 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_PATH para ele — as CodingKeys snake_case do coreai-runner PR #1 garantem que casa sem retrabalho.

🤖 Generated with Claude Code

kevinqz and others added 3 commits July 4, 2026 15:48
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>
@kevinqz kevinqz changed the title Fix: green Python CI + align runner contract (camelCase) + mock runner Fix: green Python CI + snake_case wire contract (SotA) + mock runner Jul 4, 2026
@kevinqz
kevinqz merged commit 5400a5f into main Jul 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant