Skip to content

Clarify canonical source attribution: thoughts.source_type vs thoughts.metadata.source #240

@thewoolleyman

Description

@thewoolleyman

What's on your mind?

Summary

There appears to be schema drift around how OB1 represents the source of a thought.

Observed patterns include:

  • Stock/core write paths and source filtering guidance use thoughts.metadata.source, queried in SQL as thoughts.metadata->>'source'.
  • Newer dashboard, schema, integration, and stats contributions read or write a dedicated thoughts.source_type column.
  • Some current contributions write both fields, or perform a follow-up update to set source_type after calling stock upsert_thought, because stock upsert_thought only persists p_payload->'metadata'.
  • At least one prior recipe discussion exposed confusion around whether source belongs as a top-level thoughts column versus inside thoughts.metadata.

This makes it unclear which representation new recipes, dashboards, migrations, and user-contributed integrations should target.

(This issue was AI-generated with OpenAI Codex)

Why This Matters

If one component writes only thoughts.metadata.source while another reads only thoughts.source_type, source filtering, dashboard grouping, statistics, and backfill workflows can silently miss records.

If thoughts.source_type is intended to be an enhanced-schema projection or denormalized index-friendly representation of thoughts.metadata.source, that should be documented explicitly. If it is intended to replace thoughts.metadata.source, then recipes and existing source-filtering guidance likely need migration guidance.

This is especially important because the current stock setup guide's upsert_thought(p_content, p_payload) stores only p_payload->'metadata'. A caller that sends sibling top-level keys such as source_type can succeed while silently leaving enhanced columns unset unless it performs a second update or mirrors the value into metadata.

Current Observed Patterns

Related but Not Duplicate

Questions for Maintainers

  1. What is the canonical source attribution field for OB1 going forward: thoughts.metadata.source, thoughts.source_type, or both?
  2. If both are supported, is thoughts.source_type intended to be a denormalized/generated/indexed projection of thoughts.metadata.source, or an independent field?
  3. Should stock upsert_thought populate source_type from p_payload->>'source_type', from p_payload->'metadata'->>'source', or leave enhanced columns to follow-up updates?
  4. Should dashboards and source filters query a compatibility expression such as coalesce(thoughts.source_type, thoughts.metadata->>'source')?
  5. Should recipes write only the canonical representation, or should they write both fields for compatibility?
  6. Would maintainers accept pull requests that document the canonical model, normalize recipes to that model, update dashboard queries, add a compatibility view/RPC/helper, and provide migration/backfill guidance?

Possible Contribution Path

  1. Document the canonical source attribution model.
  2. Clarify whether upsert_thought should populate enhanced columns from payload keys or metadata.
  3. Add a read-side compatibility helper such as effective_source.
  4. Update dashboard queries to use effective_source or an equivalent coalesce(...) expression.
  5. Update recipes to write the canonical field consistently.
  6. Add migration/backfill guidance for installations that already have only one representation.

Reference Links

Repository References

Discord Discussion References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions