Orchestrata Ultimate › Plans › briefs › kimi-c2-result
Kimi task C2 — twin-bug sweep results
Source: plans/briefs/kimi-c2-result.md at 8a2cb42ad · last changed 2026-07-27 · first committed 2026-07-22 · 220 lines.
Prose pending.
Plan text
Kimi task C2 — twin-bug sweep results
Generated from a repo-wide sweep of tests/ + src/orchestrata_ultimate/ for
bind/listen/serve sites and a cross-check of every MERGE (:<Label> {…})
against knowledge_graph/canonical_schema.py.
Part 1 — fixed ports bound by tests across parallel batches
Method
- Searched for
add_insecure_port,socket.bind,websockets.serve,uvicorn.run/uvicorn.Server,asyncio.start_server,HTTPServer,TCPServer, and bareserve()calls. - Traced each port back to its source: dynamic (
bind((host, 0))/_free_port()), environment variable, or literal default. - Classified "worker-slot-scoped" as: value varies by
ORCHESTRATA_WORKER_SLOTvia the remap intests/conftest.py(currentlyNEO4J_URIandKG_GRPC_PORT). - Excluded shared infra ports a test merely connects to, per the brief (Redis 6379, Neo4j 7687, gateway 8765, kernel/CXP_GRPC_PORT 50053), unless the test itself binds one.
Findings
- ~80 test-side bind/listen/serve sites use dynamic port allocation
(
socket.bind((..., 0))or a local_free_port()helper). These are safe and are summarized in the note below rather than tabulated individually. - 1 test-side site reads an env var:
tests/knowledge_graph/test_server.pybindsKG_GRPC_PORT. This is the known Workstream A issue;tests/conftest.pynow remaps it per worker slot (gwN→ base+N), so it is worker-slot-scoped. - 5 source-side bind sites are reachable from tests; their port sources are shown in the table.
Port-source table (non-dynamic / env-driven sites only)
| file:line | bind/serve call | port source | worker-slot-scoped? | collision candidate? | notes |
|---|---|---|---|---|---|
src/orchestrata_ultimate/cxp/grpc_server.py:436 |
add_insecure_port |
CXP_GRPC_PORT env (→ kernel 50053) |
no | no | shared infra by design (kernel gRPC) |
src/orchestrata_ultimate/cxp/ws_server.py:200 |
websockets.serve |
literal default 8765 (WSServerConfig.port) |
no | yes | no env var; every default-constructed WSServer() binds the same port |
src/orchestrata_ultimate/gateway/server.py:657 |
websockets.serve |
GATEWAY_PORT env (→ 8765) |
no | no | shared infra by design (gateway WS) |
src/orchestrata_ultimate/gateway/http_surface.py:89 |
uvicorn.Server |
GATEWAY_HTTP_PORT env (→ 8766) |
no | yes | gateway HTTP health/metrics surface; not in the explicit shared-infra list but gateway-owned |
src/orchestrata_ultimate/semantic_graph/ha_controller_cli.py:177 |
uvicorn.Server |
MEMGRAPH_HA_PORT env (→ 8080) |
no | yes | tests currently pass MEMGRAPH_HA_PORT=0, so no live collision today; latent fixed-port risk |
tests/knowledge_graph/test_server.py (server bind) |
CXPServer via server._serve() |
KG_GRPC_PORT env (→ 50052) |
yes | no | known / in-flight (Workstream A); per-slot remap in tests/conftest.py:81-90 |
Dynamic-port sites (safe — not collision candidates)
The following patterns were found repeatedly and all bind port 0 or a
_free_port() / _find_free_port() value:
tests/agents/test_kernel_handler.py:35,test_kernel_handler_memory.py:118,test_runtime_main.py:60,test_web_tools.py:133tests/cxp/test_grpc.py:63,test_grpc_client.py:62,test_grpc_fields.py:65,test_grpc_kernel_endpoint.py:101,test_proto_grpc.py:54(bind) and:67/:89/:114/:137/:158/:203/:231/:263(add_insecure_portwith f-string built from_free_port()),test_websocket.py,test_ws_client.pytests/gateway/conftest.py:18/:54,test_cli_behavioral.py,test_server_behavioral.py,test_server_coverage_wave.py,test_server_integration.py, handlers (test_cxp.py,test_cxp_kernel_dispatch.py,test_orchestrator_kernel_dispatch.py,test_state.py,test_volk.py),test_audit_behavioral.py,test_kernel_reply_consumer.py,test_cli_coverage_wave.pytests/generated_recovery/test_gateway_auth_handler.pytests/governance/e2e/test_policy_evaluator_dispatcher_enforcement_proof.py,test_escalation_handler.pytests/harness/test_cxp_live.py:58tests/infrastructure/kernel.py:23,test_kernel_infra.py:37tests/kernel/test_cli_main.py,test_cli_main_extended.py,test_cli_main_kernel_boot.py,test_dispatcher.py,test_dispatcher_expanded.py,test_dispatcher_policy_audit.py,test_kernel_defect_regressions.py,test_pipeline_expanded.py,test_pipeline_kg.pytests/llm/test_client_extended.py:69tests/postman/test_sync_router.py:280tests/scripts/conftest.py:103/:109,test_start_test_services.py:106/:176/:227tests/semantic_graph/conftest.py:238/:244,test_memgraph_adapter.pytests/tools/test_remote_trigger_tool.py:99/:533/:684tests/verification/integrations/test_redis_manager.py:56
These are not tabulated individually because every one uses dynamic allocation.
Part 1 summary line
Part 1: 3 candidate ports (3 new).
- New candidates:
src/orchestrata_ultimate/cxp/ws_server.py:200(default 8765),src/orchestrata_ultimate/gateway/http_surface.py:89(GATEWAY_HTTP_PORT8766),src/orchestrata_ultimate/semantic_graph/ha_controller_cli.py:177(MEMGRAPH_HA_PORT8080). - Known / in-flight (now worker-slot-scoped, not a current candidate):
tests/knowledge_graph/test_server.py(KG_GRPC_PORT50052).
Part 2 — uniqueness-constraint labels vs MERGE keys
Canonical constraints source
Uniqueness constraints are taken from
src/orchestrata_ultimate/knowledge_graph/canonical_schema.py
(CANONICAL_MERGE_KEYS), rendered by _constraint_ddl() and exposed through
get_all_ddl(). There are 70 canonical (label, key) pairs; the full list is:
| label | canonical key |
|---|---|
| Action | id |
| Alert | id |
| ApiContract | id |
| Architecture | id |
| ArchitectureDecision | id |
| Artifact | id |
| AuditEntry | entry_id |
| CapacityModel | id |
| Change | id |
| Class | id |
| CloudService | name |
| Component | id |
| Constraint | id |
| Conversation | id |
| ConversationTurn | id |
| CostLineItem | id |
| CostModel | id |
| DataEntity | id |
| Decision | id |
| Deployment | id |
| DesignClass | id |
| DesignModule | id |
| Directory | id |
| Environment | id |
| Escalation | id |
| Event | id |
| Fact | id |
| FailureMode | id |
| File | id |
| Function | id |
| GatewayEvent | entry_id |
| Intent | id |
| Memory | id |
| Message | message_id |
| Module | id |
| Package | id |
| Parameter | id |
| Pattern | name |
| PipelineRun | id |
| PolicyDecision | id |
| Portfolio | name |
| Predicate | id |
| Project | slug |
| QualityAttribute | id |
| Region | code |
| Requirement | id |
| RequirementItem | id |
| Resolution | resolution_id |
| Risk | id |
| Rule | id |
| Scenario | id |
| SemanticChunk | id |
| ServiceLevelObjective | id |
| Session | session_id |
| SessionEnd | id |
| SessionStart | id |
| Spec | id |
| Task | id |
| TechnologyChoice | id |
| Test | id |
| TestResult | id |
| TestRun | id |
| Timeout | id |
| Tool | name |
| ToolCall | id |
| TradeOff | id |
| UserStory | id |
| Violation | id |
| Volk | alias |
| WAFPillar | name |
(Constraints are also applied by scripts/migrate_neo4j_canonical.py and the
kg_schema.py apply step invoked from scripts/bootstrap_graphs.py.)
MERGE / constraint mismatches found
Swept src/orchestrata_ultimate/ and scripts/ for MERGE (:<Label> {<key>: …})
on canonical labels and compared the MERGE key to the canonical constraint key.
| constraint (label.key) | MERGE site file:line | MERGE key | notes |
|---|---|---|---|
Volk.alias |
src/orchestrata_ultimate/kernel/audit/writers.py:288 |
volk_id |
audit writer creates (v:Volk {volk_id: …}) |
Class.id |
src/orchestrata_ultimate/knowledge_graph/kg_context.py:779 |
name |
regex-driven class sync MERGEs on name + file_path |
Function.id |
src/orchestrata_ultimate/knowledge_graph/kg_context.py:803 |
name |
regex-driven function sync MERGEs on name + file_path |
Message.message_id |
src/orchestrata_ultimate/knowledge_graph/runtime_writer.py:91 |
id |
runtime signal writer MERGEs (m:Message {id: …}) |
GatewayEvent.entry_id |
src/orchestrata_ultimate/knowledge_graph/runtime_writer.py:135 |
id |
runtime signal writer MERGEs (e:GatewayEvent {id: …}) |
Project.slug |
src/orchestrata_ultimate/knowledge_graph/sync.py:205 |
id |
AST sync MERGEs (p:Project {id: …}) |
TestRun.id |
src/orchestrata_ultimate/knowledge_graph/test_results_store.py:130 |
run_id |
test-results store MERGEs (r:TestRun {run_id: …}) |
Function.id |
src/orchestrata_ultimate/knowledge_graph/test_results_store.py:200 |
name |
COVERS relationship writer MERGEs (f:Function {name: …}) |
Memory.id |
src/orchestrata_ultimate/memory/cold_store.py:132 |
key |
cold store MERGEs (m:Memory {key: …}) |
Module.id |
src/orchestrata_ultimate/semantic_graph/adapters/memgraph.py:576 |
name |
Memgraph chunk linker MERGEs (m:Module {name: c.module}) |
Known File/Directory self-check
The brief's known instances are the historical File/Directory mismatch
(File/Directory MERGEd on id while the constraint was on path). The
canonical_schema.py ruling has since been updated: File and Directory now
have canonical keys id (file_id / directory_id constraints), and the old
file_path / directory_path constraints were removed from
knowledge_graph/schema.py.
| historical site | MERGE key | current canonical constraint | status |
|---|---|---|---|
src/orchestrata_ultimate/session/kg_sync/_stage_folders.py:112 |
id |
Directory.id |
known — now aligned |
src/orchestrata_ultimate/session/kg_sync/_stage_folders.py:125 |
id |
File.id |
known — now aligned |
src/orchestrata_ultimate/knowledge_graph/synchronizer.py:321 |
id |
File.id |
known — now aligned |
src/orchestrata_ultimate/knowledge_graph/kg_context.py:718 |
id |
File.id |
known — now aligned |
Part 2 summary line
Part 2: 10 mismatches (10 new).
The 3 known File/Directory sites are included as a self-check; they are now
aligned with the canonical id constraint and no longer constitute mismatches.