Repository navigation
docs: add schema inventory classifying universal vs provider metadata (#840) - #874
Conversation
📝 WalkthroughWalkthroughA new schema inventory document is added that systematically classifies database table fields as canonical, trapped in ChangesSchema Inventory Documentation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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 |
There was a problem hiding this comment.
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 winRemove 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
📒 Files selected for processing (1)
docs/plans/schema-inventory.md
| ### 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. |
There was a problem hiding this comment.
🧹 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.
| #### 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. |
There was a problem hiding this comment.
🧹 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.
| #### 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.
There was a problem hiding this comment.
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.mdwith a structured A1–A6 classification of archive tables,provider_metakeys, 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_metausage and theschemas/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. | |
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
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
Summary
Add
docs/plans/schema-inventory.md— a comprehensive classification of every schema field,provider_metakey, 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:
provider_metakeys (A1-A4 + A3 provider-specific)provider_metacolumn — intentional)cwd_pathandbranch_names_jsonalready first-class)source_message_id/raw_idclassified as intentional optional provenance)provider_meta-driven rebuild bootstrapping for cwd/git → refactor(schema): graduate universal semantics out of provider_meta #864)payload_jsonpattern in work_threads/day_summaries (intentional)provider_metain domain modelsschemas/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 syncCloseout
#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