Repository navigation
fix(import): ingest decimal-bearing ChatGPT exports - #1871
Conversation
Problem: ChatGPT account-export ZIP members decoded through ijson carry Decimal values for numeric fields. The acquisition JSON contract rejected those records, replaced them with empty objects, classified the ZIP as unknown-export, and left the daemon retrying/excluding valid ChatGPT exports. The same session also exposed an FTS readiness false negative: exact readiness counted blocks.text while the FTS writer indexes blocks.search_text.\n\nWhat changed: normalize Decimal values before acquisition/provider detection and before direct parser dispatch record lowering, so ChatGPT conversation records keep their mapping/title/timestamps. Align the exact messages_fts invariant with the writer/trigger predicate by counting blocks.search_text. Add focused regressions for Decimal-bearing ChatGPT records.\n\nVerification: devtools test tests/unit/sources/test_dispatch_payloads.py tests/unit/sources/test_source_laws.py -k 'streaming_decimals or decimal_bearing_chatgpt or locks_provider_after_first_detected_payload' passed. devtools test tests/unit/daemon/test_fts_readiness_fallback.py -k 'exact_coverage_counts_tool_blocks_as_indexable or falls_back_to_exact' passed. Local exact readiness against /realm/db/polylogue/index.db reports messages_ready=True with 3,632,991/3,632,991 rows and 0 missing/excess/duplicate rows.\n\nRef #1870
📝 WalkthroughWalkthroughTwo independent fixes: ChangesDecimal Normalization in Payload Handling
FTS Invariant SQL Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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: 1
🤖 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 `@polylogue/sources/source_acquisition_components.py`:
- Around line 133-140: Extract the `_normalize_json_decimal` function to
eliminate duplication across files. Create a shared module at
polylogue/core/json.py (or polylogue/core/normalization.py) and move the
function implementation there as a public function. In
polylogue/sources/source_acquisition_components.py (lines 133-140), delete the
local implementation and import the shared function from the new module,
ensuring it is called from `_artifact_payload`. In polylogue/sources/dispatch.py
(lines 74-81), delete the duplicate implementation and import the shared
function from the new module, ensuring it is called from `_payload_record` and
`_payload_sequence`.
🪄 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: bc7e4e73-321e-4ed0-9a26-183edceb4e97
📒 Files selected for processing (5)
polylogue/sources/dispatch.pypolylogue/sources/source_acquisition_components.pypolylogue/storage/fts/fts_lifecycle.pytests/unit/sources/test_dispatch_payloads.pytests/unit/sources/test_source_laws.py
Problem: the ChatGPT import fix needed Decimal normalization in both ZIP acquisition and provider dispatch, and the initial implementation duplicated the helper across those boundaries. What changed: move the recursive Decimal-to-JSON-number lowering into polylogue.core.json and import it from both callers so Decimal-bearing streamed payloads keep one JSON contract. Verification: - devtools test tests/unit/sources/test_dispatch_payloads.py tests/unit/sources/test_source_laws.py -k 'streaming_decimals or decimal_bearing_chatgpt or locks_provider_after_first_detected_payload' - devtools test tests/unit/daemon/test_fts_readiness_fallback.py -k 'exact_coverage_counts_tool_blocks_as_indexable or falls_back_to_exact' - devtools verify --quick
Summary
Fixes ChatGPT account-export ZIP ingestion when streamed JSON records contain
Decimalvalues fromijson, and fixes the FTS readiness invariant that made a correctly rebuilt search index look stale.Closes #1870
Problem
The dogfood archive had ChatGPT export ZIPs available but no
chatgpt-exportsessions in the archive. The daemon had excluded staged inbox copies asunknown-exportafter repeated failures. Proper investigation showed the 2026 export was not HTML-only: it containsconversations-000.jsonthroughconversations-024.jsonwith 2,403 session-bearing ChatGPT records.The root cause was at the ZIP acquisition boundary.
ijsonemits numeric values asDecimal; acquisition rejected those records as non-JSONValue, replaced them with{}, and provider detection could only classify them asunknown. A related operational failure surfaced after import: exact FTS readiness countedblocks.text, while the FTS writer and triggers indexblocks.search_text.Solution
polylogue.core.json.Decimalvalues before ZIP acquisition/provider detection.Decimalvalues before direct parser dispatch record lowering.messages_ftsreadiness with the writer/trigger predicate,blocks.search_text != ''.Live repair/import evidence from
/realm/db/polylogueafter applying the fix locally:chatgpt-export: 2,491 indexed sessions.conversations.json/conversations-*.json.shared_conversations.jsonsessions.message_feedback.json/user.jsoncreated by the earlier broad live-batch attempt.messages_ready=True,3,633,598/3,633,598,missing=0,excess=0,duplicate=0.Verification
devtools test tests/unit/sources/test_dispatch_payloads.py tests/unit/sources/test_source_laws.py -k 'streaming_decimals or decimal_bearing_chatgpt or locks_provider_after_first_detected_payload'4 passeddevtools test tests/unit/daemon/test_fts_readiness_fallback.py -k 'exact_coverage_counts_tool_blocks_as_indexable or falls_back_to_exact'2 passeddevtools verify --quickgit pushpre-push quick gate8c013f249980208471969acdc568f7da378dec6cOperational note
The installed
polylogued.servicestill uses the previous Nix-store build until this change is merged/deployed/rebuilt. The active archive data is repaired/imported; readiness from the old service can still report the pre-fix falsefts_not_freshresult.