Skip to content

docs: add schema inventory classifying universal vs provider metadata (#840) - #874

Merged
Sinity merged 1 commit into
masterfrom
feature/chore/schema-inventory-840
May 7, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/chore/schema-inventory-840

Conversation

@Sinity

@Sinity Sinity commented May 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

Add docs/plans/schema-inventory.md — a comprehensive classification of every schema field, provider_meta key, insight projection, and storage mapper across six axes (A1-A6). Each item includes rationale and the owning follow-up issue or explicit "intentional" label.

Problem

Polylogue has accumulated semantic fields across archive tables, provider_meta, raw blobs, provider events, action events, content blocks, and insight projections. Some are clearly provider-specific, others are universal-ish archive semantics trapped in provider-shaped blobs or ad hoc projection fallbacks. No single document classified which is which.

Solution

A 13-section inventory document covering:

  • Conversation table fields and provider_meta keys (A1-A4 + A3 provider-specific)
  • Messages table (clean, no provider_meta column — intentional)
  • Content blocks (clean)
  • Action events (clean — cwd_path and branch_names_json already first-class)
  • Provider events (source_message_id/raw_id classified as intentional optional provenance)
  • Attachments (native identity trapped in JSON expression indexes → refactor(schema): graduate universal semantics out of provider_meta #864)
  • Conversation stats (clean)
  • Session insight tables (legacy provider_meta-driven rebuild bootstrapping for cwd/git → refactor(schema): graduate universal semantics out of provider_meta #864)
  • Legacy payload_json pattern in work_threads/day_summaries (intentional)
  • Raw/provenance tables (clean)
  • Mapper repetition audit (5 locations per table, decision deferred on table descriptor)
  • Cross-cutting provider_meta in domain models
  • Cross-cutting schemas/unified/provider_meta_* layer (should shrink after canonical fields exist)

Verification

  • devtools verify --quick — pre-push hook passed all gates (ruff format, ruff check, mypy, render-all, topology, layering, file-budgets, test-ownership, schema-roundtrip, cross-cuts, suppressions, manifests, witness-lifecycle, proof-pack)
  • devtools render-all --check — all generated surfaces in sync

Closeout

#840 remains open until every classified gap is linked to a focused issue or explicitly marked intentional. The closeout matrix is Section 13 of the document.

Ref #840 #842 #839 #803 #800 #841 #864 #852

Summary by CodeRabbit

  • Documentation
    • Added comprehensive schema inventory documentation covering data structure organization and current storage patterns.

Classify every schema field, provider_meta key, insight projection, and storage
mapper across six axes (A1-A6). Each item includes rationale and the owning
follow-up issue or explicit "intentional" label.

Ref #840 #842 #839 #803 #800 #841 #864

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@coderabbitai

coderabbitai Bot commented May 7, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

A new schema inventory document is added that systematically classifies database table fields as canonical, trapped in provider_meta, or raw-only; enumerates provider-specific metadata allowlists; and audits repetitive column-list duplication across DDL, record models, mappers, and SQL statements, with deferred decisions on descriptor layers.

Changes

Schema Inventory Documentation

Layer / File(s) Summary
Classification Framework
docs/plans/schema-inventory.md (lines 1–18)
Document introduces six classification axes (A1–A6) defining the spectrum from canonical universal columns to provider-specific metadata, raw-only data, and mapper duplication patterns.
Core Table Inventories
docs/plans/schema-inventory.md (lines 21–248)
Per-table field classifications for conversations, messages, content_blocks, action_events, provider_events, attachments, conversation_stats, session insight tables, and raw/provenance tables; enumerates trapped universal semantics in provider_meta and provider-specific allowlists.
Mapper & Schema Audit
docs/plans/schema-inventory.md (lines 250–288)
Documents the five-point column-list repetition pattern across DDL, record models, row mappers, tuple builders, and SQL statements; records the decision to defer descriptor layer implementation.
Model Guidance & Summary
docs/plans/schema-inventory.md (lines 290–360)
Cross-cutting guidance on provider_meta treatment as fallback/compatibility layer and a closeout matrix summarizing semantic bucket statuses linked to owning issues or "Intentional" labels.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Poem

🐰 A schema so clear, a map made with care,
Fields filed away in their rightful layer,
Provider and canon in orderly rows,
Where each datum's true home and intention now shows!
The mapper's long dance finally found their rhythm—
Inventory complete, we've got the big picture! 📋✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and accurately summarizes the main change: adding schema inventory documentation that classifies universal vs provider metadata.
Description check ✅ Passed The description comprehensively covers all required template sections: Summary, Problem, Solution, Verification, and includes Closeout notes addressing follow-ups and remaining work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/chore/schema-inventory-840

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/plans/schema-inventory.md (1)

361-361: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove stray line number.

Line 361 contains just "361" without any content or context. This appears to be a formatting error or leftover line number that should be removed.

🧹 Proposed fix
 | Mapper/tuple/DDL repetition (table descriptor) | Decision deferred | This issue (`#840`) |
 | Full ORM adoption | Rejected | This issue (`#840`) |
-361
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/plans/schema-inventory.md` at line 361, Remove the stray standalone
"361" line from the markdown document to fix the formatting error; open the
schema-inventory.md content, locate the orphan line containing only "361" and
delete that line so the document flows correctly with no leftover line-number
artifacts.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/plans/schema-inventory.md`:
- Around line 222-230: The A4 axis label is misused: change the classification
for the legacy single-payload entries (work_threads -> payload_json and
day_session_summaries -> payload_json) so they are not marked as "A4 (legacy
payload pattern)" which implies accidental provider leakage; instead update
those headings to a new label (e.g., "Intentional legacy payload pattern" or
"L1: intentional legacy") or add a dedicated note/section "intentional legacy
patterns" and move the work_threads and day_session_summaries descriptions
there, keeping the current text but replacing the A4 marker to reflect
intentional design.
- Around line 154-161: The header "A4 — Columns that may not be consistently
populated" conflicts with the A4 axis meaning "Accidental provider leakage"
while the text concludes `source_message_id` and `raw_id` are intentional
optional provenance; update the section to resolve this mismatch by either (a)
renaming the header to something like "Intentional optional provenance" and
explicitly stating `source_message_id` and `raw_id` are intentionally nullable,
or (b) keeping the A4 header but adding a clarifying sentence that this use of
A4 is non-standard and these two columns are intentionally optional; ensure the
fields `source_message_id` and `raw_id` are mentioned by name and the decision
line ("Decision: ... Classified as intentional optional provenance") is adjusted
to match the chosen classification.

---

Outside diff comments:
In `@docs/plans/schema-inventory.md`:
- Line 361: Remove the stray standalone "361" line from the markdown document to
fix the formatting error; open the schema-inventory.md content, locate the
orphan line containing only "361" and delete that line so the document flows
correctly with no leftover line-number artifacts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9f2f6915-22ee-49be-bdef-a9be0f1af580

📥 Commits

Reviewing files that changed from the base of the PR and between 09b5e90 and 59d82bc.

📒 Files selected for processing (1)
  • docs/plans/schema-inventory.md

Comment on lines +154 to +161
### A4 — Columns that may not be consistently populated

| Column | Issue |
|--------|-------|
| `source_message_id` | Not all parsers set this. Should be required or removed. |
| `raw_id` | Set by batch ingest but not universally available. Should document coverage. |

Decision: These columns are useful provenance when available but their nullable status is correct. Classified as intentional optional provenance. No follow-up issue needed unless a parser should set them and doesn't.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Inconsistent axis classification for provider_events fields.

The section header uses A4 — "Columns that may not be consistently populated", but A4 is defined at line 15 as "Accidental provider leakage". However, the conclusion at line 161 states these are "intentional optional provenance" with no follow-up issue needed.

This creates a contradiction: if source_message_id and raw_id are intentional design choices, they should not be classified under an "Accidental" axis.

Recommendation: Either create a separate note/classification for "intentional optional fields" or clarify in the text that this A4 usage is non-standard. The current labeling will confuse readers about whether these fields need remediation.

📝 Suggested clarification

Replace the A4 header with a note:

-### A4 — Columns that may not be consistently populated
+### Note: Optional provenance columns

 | Column | Issue |
 |--------|-------|
 | `source_message_id` | Not all parsers set this. Should be required or removed. |
 | `raw_id` | Set by batch ingest but not universally available. Should document coverage. |

-Decision: These columns are useful provenance when available but their nullable status is correct. Classified as intentional optional provenance. No follow-up issue needed unless a parser should set them and doesn't.
+**Decision:** These columns are useful provenance when available but their nullable status is correct. Classified as **intentional optional provenance**. No follow-up issue needed unless a parser should set them and doesn't.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/plans/schema-inventory.md` around lines 154 - 161, The header "A4 —
Columns that may not be consistently populated" conflicts with the A4 axis
meaning "Accidental provider leakage" while the text concludes
`source_message_id` and `raw_id` are intentional optional provenance; update the
section to resolve this mismatch by either (a) renaming the header to something
like "Intentional optional provenance" and explicitly stating
`source_message_id` and `raw_id` are intentionally nullable, or (b) keeping the
A4 header but adding a clarifying sentence that this use of A4 is non-standard
and these two columns are intentionally optional; ensure the fields
`source_message_id` and `raw_id` are mentioned by name and the decision line
("Decision: ... Classified as intentional optional provenance") is adjusted to
match the chosen classification.

Comment on lines +222 to +230
#### A4 (legacy payload pattern)

The `payload_json TEXT NOT NULL` field holds a `WorkThreadPayload` — this is a typed Pydantic model serialized to JSON, consistent with the `*_payload_json` pattern used by profiles. However, unlike profiles which split into `evidence_payload_json`/`inference_payload_json`/`enrichment_payload_json`, work_threads uses a single undifferentiated `payload_json`. This is a **legacy pattern**, not a bug. Classified as intentional for now; could be split in a follow-up if thread evidence/inference/enrichment needs separate search indexes.

### 8.4 `day_session_summaries`

#### A4 (same legacy payload pattern)

`payload_json TEXT NOT NULL` — same single-payload pattern as work_threads. Intentional for now.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Inconsistent axis classification for legacy payload patterns.

Both sections 8.3 (work_threads) and 8.4 (day_session_summaries) use the A4 axis label with descriptors like "legacy payload pattern", but then explicitly state these are "intentional for now" (lines 224, 230).

This contradicts the A4 definition at line 15: "Accidental provider leakage". If these single-payload patterns are intentional design choices (even if legacy), they should not be classified as accidental leakage.

Recommendation: Use a different label or create a note section for "intentional legacy patterns" to distinguish them from accidental technical debt that requires remediation.

📝 Suggested fix
 ### 8.3 `work_threads`

-#### A4 (legacy payload pattern)
+#### Note: Intentional legacy payload pattern

 The `payload_json TEXT NOT NULL` field holds a `WorkThreadPayload` — this is a typed Pydantic model serialized to JSON, consistent with the `*_payload_json` pattern used by profiles. However, unlike profiles which split into `evidence_payload_json`/`inference_payload_json`/`enrichment_payload_json`, work_threads uses a single undifferentiated `payload_json`. This is a **legacy pattern**, not a bug. Classified as intentional for now; could be split in a follow-up if thread evidence/inference/enrichment needs separate search indexes.

 ### 8.4 `day_session_summaries`

-#### A4 (same legacy payload pattern)
+#### Note: Same intentional legacy payload pattern

 `payload_json TEXT NOT NULL` — same single-payload pattern as work_threads. Intentional for now.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#### A4 (legacy payload pattern)
The `payload_json TEXT NOT NULL` field holds a `WorkThreadPayload` — this is a typed Pydantic model serialized to JSON, consistent with the `*_payload_json` pattern used by profiles. However, unlike profiles which split into `evidence_payload_json`/`inference_payload_json`/`enrichment_payload_json`, work_threads uses a single undifferentiated `payload_json`. This is a **legacy pattern**, not a bug. Classified as intentional for now; could be split in a follow-up if thread evidence/inference/enrichment needs separate search indexes.
### 8.4 `day_session_summaries`
#### A4 (same legacy payload pattern)
`payload_json TEXT NOT NULL` — same single-payload pattern as work_threads. Intentional for now.
#### Note: Intentional legacy payload pattern
The `payload_json TEXT NOT NULL` field holds a `WorkThreadPayload` — this is a typed Pydantic model serialized to JSON, consistent with the `*_payload_json` pattern used by profiles. However, unlike profiles which split into `evidence_payload_json`/`inference_payload_json`/`enrichment_payload_json`, work_threads uses a single undifferentiated `payload_json`. This is a **legacy pattern**, not a bug. Classified as intentional for now; could be split in a follow-up if thread evidence/inference/enrichment needs separate search indexes.
### 8.4 `day_session_summaries`
#### Note: Same intentional legacy payload pattern
`payload_json TEXT NOT NULL` — same single-payload pattern as work_threads. Intentional for now.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/plans/schema-inventory.md` around lines 222 - 230, The A4 axis label is
misused: change the classification for the legacy single-payload entries
(work_threads -> payload_json and day_session_summaries -> payload_json) so they
are not marked as "A4 (legacy payload pattern)" which implies accidental
provider leakage; instead update those headings to a new label (e.g.,
"Intentional legacy payload pattern" or "L1: intentional legacy") or add a
dedicated note/section "intentional legacy patterns" and move the work_threads
and day_session_summaries descriptions there, keeping the current text but
replacing the A4 marker to reflect intentional design.

@Sinity
Sinity merged commit 4367c71 into master May 7, 2026
2 checks passed
@Sinity
Sinity deleted the feature/chore/schema-inventory-840 branch May 7, 2026 06:01
Copilot AI review requested due to automatic review settings May 7, 2026 06:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new planning document that inventories Polylogue’s archive/schema semantics vs. provider-specific metadata, to support #840/#864 by clearly classifying fields/keys across the A1–A6 axes.

Changes:

  • Introduces docs/plans/schema-inventory.md with a structured A1–A6 classification of archive tables, provider_meta keys, insight rebuild paths, and mapper repetition points.
  • Links “trapped universal”/“leakage” items to follow-up issues (notably #864, plus #803/#839/#842/#841/#800) and records “intentional” decisions.
  • Captures cross-cutting notes about domain model provider_meta usage and the schemas/unified/provider_meta_* harmonization layer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

| `provider_name` | Denormalized for query performance. |
| `word_count` | Precomputed word count. |
| `has_tool_use`, `has_thinking`, `has_paste` | Precomputed boolean flags for filter pushdown. |
| `message_type` | Enum: message, tool_use, tool_result, thinking. |
Sinity added a commit that referenced this pull request May 7, 2026
Closes the inventory acceptance criterion of #840 (without
closing #840 itself, which stays open until each classified
gap is linked to a follow-up). Polylogue had accumulated
semantic fields across archive tables, `provider_meta`, raw
blobs, provider events, action events, content blocks, and
insight projections; some are provider-specific, others are
universal-ish semantics trapped in provider-shaped blobs.

Adds `docs/plans/schema-inventory.md` — a 13-section
classification across six axes (A1: already canonical, A2:
trapped universal, A3: provider-specific, A4: accidental
leakage, A5: raw-only, A6: mapper repetition):

- conversation table fields and `provider_meta` keys;
- messages (clean — no `provider_meta` column);
- content blocks (clean);
- action events (clean — `cwd_path`, `branch_names_json`
  already first-class);
- provider events (`source_message_id` / `raw_id` classified
  as intentional optional provenance);
- attachments (native identity trapped in JSON expression
  indexes → #864);
- conversation stats (clean);
- session insights (legacy `provider_meta`-driven rebuild
  bootstrap for cwd/git → #864);
- legacy `payload_json` in work_threads / day_summaries
  (intentional);
- raw / provenance tables (clean);
- mapper repetition audit (5 locations per table);
- cross-cutting `provider_meta` in domain models;
- cross-cutting `schemas/unified/provider_meta_*` layer.

Each entry carries rationale and either an owning follow-up
issue or an explicit "intentional" label.

Refs #800, #803, #839, #840, #841, #842, #864
Sinity added a commit that referenced this pull request May 7, 2026
Closes the inventory acceptance criterion of #840 (without
closing #840 itself, which stays open until each classified
gap is linked to a follow-up). Polylogue had accumulated
semantic fields across archive tables, `provider_meta`, raw
blobs, provider events, action events, content blocks, and
insight projections; some are provider-specific, others are
universal-ish semantics trapped in provider-shaped blobs.

Adds `docs/plans/schema-inventory.md` — a 13-section
classification across six axes (A1: already canonical, A2:
trapped universal, A3: provider-specific, A4: accidental
leakage, A5: raw-only, A6: mapper repetition):

- conversation table fields and `provider_meta` keys;
- messages (clean — no `provider_meta` column);
- content blocks (clean);
- action events (clean — `cwd_path`, `branch_names_json`
  already first-class);
- provider events (`source_message_id` / `raw_id` classified
  as intentional optional provenance);
- attachments (native identity trapped in JSON expression
  indexes → #864);
- conversation stats (clean);
- session insights (legacy `provider_meta`-driven rebuild
  bootstrap for cwd/git → #864);
- legacy `payload_json` in work_threads / day_summaries
  (intentional);
- raw / provenance tables (clean);
- mapper repetition audit (5 locations per table);
- cross-cutting `provider_meta` in domain models;
- cross-cutting `schemas/unified/provider_meta_*` layer.

Each entry carries rationale and either an owning follow-up
issue or an explicit "intentional" label.

Refs #800, #803, #839, #840, #841, #842, #864
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants