Repository navigation
Description
Overview
Found while reviewing the PR for core#2899 (making check_node_completeness extends-chain aware).
Problem Statement
NodeService::check_node_completeness (packages/core/src/services/node_service/schema.rs, ~line 1243) iterates a node type's required: true relationships and, for each one, calls self.store.check_relationship_exists(node_id, &relationship.name) to decide whether it is satisfied.
check_relationship_exists (packages/core/src/db/sqlite_store/relationships.rs, ~line 1555) queries WHERE in_node = ?1 AND relationship_type = ?2, and edges are always inserted with in_node set to the source (Out-direction) side. Nothing in check_node_completeness inspects relationship.direction before calling it.
A schema may legally declare a relationship with direction: "in" and required: true — nothing in create_schema/update_schema rejects that combination. For such a relationship, check_relationship_exists(node_id, name) can never find a match from node_id's own perspective (the edge, if any, is inserted with a different node as in_node), so a required in-direction relationship can never be reported satisfied — the node is permanently reported incomplete regardless of actual data.
NodeService::remove_relationship_in_tx (packages/core/src/services/node_service/relationship.rs, ~line 1165) already guards against this exact case by checking r.direction == RelationshipDirection::Out before treating a declared relationship as removable via this lookup direction; check_node_completeness has no equivalent guard.
This is a pre-existing gap (not introduced by core#2899's extends-chain fix), but that fix widens where it is reachable: check_node_completeness now also runs the same direction-blind check against relationships declared only on an ancestor schema and inherited by a subtype, not just a type's own direct declarations.
Proposed Solution
check_node_completeness should only treat a required relationship as checkable via check_relationship_exists(node_id, name) when relationship.direction is Out (matching the guard already used in remove_relationship_in_tx). An in-direction required relationship needs the reverse-direction existence check (or an explicit decision on how completeness applies to inbound-only relationships) instead.
Acceptance Criteria
-
check_node_completenessdoes not misreport a requiredin-direction relationship as permanently missing - Regression test: a required
in-direction relationship with a real edge attached from the other side is correctly reported satisfied - Code passes
bun run quality:fix - Tests pass (
bun run test:all)
Non-Goals
No change to check_node_completeness's extends-chain resolution (core#2899) or to how required is enforced on the write path.
Activity
malibio commentedon Sep 25, 2026
Frontend baseline: 262 files / 5269 tests passed