Repository navigation
Surface schema field/relationship/schema-level descriptions in schema_metadata - #2706
Conversation
…_metadata (closes #2653) EntityFieldDescriptor now carries each field's description, and a new EntityRelationshipDescriptor carries each relationship's description plus enough shape (target_type, direction, cardinality, reverse_name, reverse_cardinality) to identify it — EntityTypeDescriptor previously represented no relationship data at all. Both flow through EntityTypeDescriptor::from_schema/to_json/from_json, so schema_metadata (the find_skills sidecar) stops dropping them. find_skills also fetches each candidate schema's own description subtree (reusing flatten_subtree_content, the shared ADR-057 subtree-render utility already used for skill instructions) and attaches it as a sibling description key on the schema_metadata entry, cached per call since the same schema can appear in metadata for multiple matched skills. The compact EXISTING SCHEMAS prompt line (render_line) is deliberately unchanged — descriptions reach the model only via schema_metadata JSON, not the deterministic prompt-injection block. EntityFieldDescriptor/EntityTypeDescriptor gained new struct fields, which broke exhaustive struct literals in packages/agent's own test fixtures (tools.rs, routing.rs) — updated those literals with the new fields' inert defaults (None/empty vec) to keep the workspace compiling; no agent behavior changed. Added an integration test with a fixture schema carrying rich field, relationship, and schema-level descriptions, verifying all three reach a live find_skills() call's schema_metadata end to end. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Independent scoped review (dispatched per issue #2653's process note) — verdict: APPROVE Reviewed structurally and by running the tests directly (not just reading the diff): 1. 2. Subtree-render reuse — confirmed genuine reuse, not a reimplementation: the new 3. Fixture test — exercises the real Mechanical agent-crate diff ( No blocking findings. One non-blocking note: if a future recipe needs the agent to set an edge-field value when creating a relationship (e.g. a |
mstomar125
left a comment
There was a problem hiding this comment.
Automated independent review: APPROVE (posted as a comment — GitHub blocks self-approval on this self-authored PR). Full findings in the review comment above.
Summary
EntityFieldDescriptornow carries each field'sdescription(was read fromSchemaFieldand silently dropped before serialization).EntityRelationshipDescriptor(on a newEntityTypeDescriptor.relationshipsfield) carries each relationship'sdescriptionplus its shape (target_type,direction,cardinality,reverse_name,reverse_cardinality) —SchemaRelationshipwasn't represented inEntityTypeDescriptorat all before this.find_skillsnow fetches each candidate schema's own description subtree (markdown children under the schema node) and attaches it as a siblingdescriptionkey on that schema'sschema_metadataentry, reusing the existing shared subtree-render utility (flatten_subtree_content, ADR-057) rather than a third independent implementation. Fetches are cached per call since the same schema can appear in metadata for multiple matched skills.Deliberately unchanged
EXISTING SCHEMASprompt line (EntityTypeDescriptor::render_line) is untouched — none of the new description content is rendered into it. It still shows only type id / display name / field shape /title_template, exactly as before. Description content reaches the model only throughschema_metadata's JSON (to_json/from_json), delivered alongside a matchedfind_skillsskill result.find_skills's"skill"-only search scope and the "EXISTING SCHEMAS" prompt-injection mechanism itself (packages/agent/src/local_agent/tools.rs/agent_loop.rs) are untouched — out of scope for this issue.Incidental fix required
EntityFieldDescriptor/EntityTypeDescriptorgained new struct fields.packages/agent's own test fixtures (local_agent/tools.rs,local_agent/routing.rs) construct these structs via exhaustive literals, which no longer compiled. Updated those literals with the new fields' inert defaults (None/vec![]) — no agent behavior, logic, or test assertions changed, purely mechanical to keep the workspace compiling.Testing
entity_types_block.rs: field/relationship descriptions survive theto_json/from_jsonround trip, and are confirmed absent fromrender_line()'s output.packages/core/tests/find_skills_schema_metadata_test.rs: a fixture schema authored with a field description, a relationship description, and a markdown schema-level description, associated with a skill scoped to it vianode_types, embedded with the real embedding model, and retrieved through a livefind_skills()call — asserts all three description sources are present in the returnedschema_metadata, not dropped.bun run test:alland the full pre-push gate (includingcargo test -p nodespace-app --test "*"andbun run test:e2e) pass clean.bun run quality:fix(cargo fmt+cargo clippy --all-targets -- -D warnings -D clippy::unused-async) clean across the whole workspace.Test plan
bun run test:allpassesbun run quality:fixcleanfind_skills'sschema_metadatacarries field, relationship, and schema-level descriptionsentity_types_block.rs/skill_ops.rstest suites pass unchanged in shapecloses #2653
🤖 Generated with Claude Code