feat(learning): surface facet provenance (cue_families, evidence_refs) in RPC#5043
feat(learning): surface facet provenance (cue_families, evidence_refs) in RPC#5043mysma-9403 wants to merge 1 commit into
Conversation
…) in RPC facet_to_json is the single serializer feeding every facet-returning learning controller (list_facets, get_facet, and the echoed facet on update/pin/unpin/ forget). ProfileFacet persists and row_to_facet hydrates two provenance columns — evidence_refs (Vec<EvidenceRef>, from evidence_refs_json) and cue_families (Option<HashMap<String,u32>>, from cue_families_json) — but the serializer emitted only 10 keys and silently dropped both, so no RPC consumer could see the evidence behind a facet. Add the two fields to the json! macro. Both types already derive Serialize (EvidenceRef is a #[serde(tag = "type")] enum), None/empty serialize to null/[]. The controller output schemas declare facet/facets as opaque TypeSchema::Json, so the schema contract is unchanged; the addition is purely additive metadata. No store or query change. Scope: evidence_refs are (class, key)-scoped, not value-scoped (the stability detector merges every candidate's evidence for a key before persisting the one value). This only stops the serializer dropping already-persisted state. Test: facet_to_json_includes_cue_families_and_evidence_refs asserts populated provenance round-trips and empty/None serializes to []/null. README get_facet row notes the provenance fields.
📝 WalkthroughWalkthroughThe learning facet JSON serializer now includes ChangesFacet provenance output
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
CI note — the red checks are not from this changeRust Core Coverage is red on a pre-existing flaky test, not this PR. The failing test is Verified against the PR base Rust Feature-Gate Smoke (gates off) is also unrelated: it fails identically on every fresh- Happy to open a small follow-up to de-flake that startup test (give it its own isolated candidate buffer) if a maintainer wants it. |
Summary
evidence_refsandcue_families— through the facet RPC serializer, which was silently dropping them at the boundary.facet_to_json, so every facet-returning controller (list_facets,get_facet,update/pin/unpin/forget) gains them at once.Problem
facet_to_jsonis the single serializer feeding all facet-returninglearning.*controllers.ProfileFacetpersists (androw_to_facethydrates) two provenance columns:evidence_refs: Vec<EvidenceRef>(fromevidence_refs_json) — the citations behind a facet.cue_families: Option<HashMap<String, u32>>(fromcue_families_json) — per-cue-family evidence counts written by the stability detector.Both derive
Serialize(EvidenceRefis a#[serde(tag = "type")]enum), are documented as first-classProfileFacetstate, and exist specifically as provenance — yet the serializer emits only 10 keys and drops both, so no RPC consumer can see the evidence behind a facet.Solution
Add the two fields to the
json!macro infacet_to_json:The controller output schemas declare
facet/facetsas opaqueTypeSchema::Json, so the schema contract is unchanged; the addition is purely additive metadata. No store or query changes.Submission Checklist
facet_to_json_includes_cue_families_and_evidence_refsbuilds a facet with populated and empty provenance and asserts both keys serialize correctly (present-and-populated + null/empty edge).cargo test -p openhuman --lib learning::schemaspasses.N/A: additive read-only field exposure, no new controller/feature row.## Related—N/A.N/A: does not touch a release-cut surface.Closes #NNN— no existing issue; found by inspection.Impact
learning.list_facets/get_facet(and the mutating controllers' echoed facet) now includecue_familiesandevidence_refs, enabling a transparency/provenance UI to cite the evidence behind a learned facet without a second round-trip. Purely additive; no behaviour change for existing consumers.Related
AI Authored PR Metadata
Linear Issue
Commit & Branch
feat/learning-facet-provenance-fieldse4f6889afValidation Run
pnpm --filter openhuman-app format:check— N/A (no frontend change)pnpm typecheck— N/A (no frontend change)cargo test -p openhuman --lib learning::schemascargo fmtBehavior Changes
evidence_refs,cue_families) is now retrievable via the learning facet controllers.Parity Contract
None/empty provenance serializes tonull/[](verified by the test's empty-facet case).