Repository navigation
refactor(parsers): dedupe timestamp wrappers; drop claude __init__ shadow - #1382
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 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 |
531c4a5 to
5ed84c1
Compare
…#1384) ## Summary PR #1370 (typed ranked-result envelope) changed `polylogue list --format json` for search-mode queries to emit `{"hits": [...], "limit": N, "next_cursor": ...}` rather than a bare JSON array. The CLI parity adapter at `tests/infra/surfaces.py:307` still expected a bare array and asserted `not isinstance(parsed, list)`, causing both `test_search_unique_token_parity` and `test_search_shared_token_parity` to fail on every search-mode case on master. ## Solution When the parsed CLI output is a dict carrying a `hits` array (the typed envelope shape), peel the `hits` and continue with the existing per-row id extraction. The list-mode and search-hit-mode shapes still work unchanged — they hit the same row loop directly. Updated the inline doc to enumerate all three shapes the adapter now handles. ## Verification - `nix develop --command pytest tests/unit/storage/test_surface_parity_adapters.py -q` → **10 passed** (was 2 failures on master). - No production code touched; test-infra only. ## Scope Single-file, test-infra-only change. Should land before #1379 / #1380 / #1382 (or alongside) so those PRs' CI runs are unmasked by this pre-existing failure. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
`polylogue/sources/parsers/claude/__init__.py` re-defined
`extract_text_from_segments`, `extract_messages_from_chat_messages`,
`normalize_timestamp`, `parse_sessions_index`, `find_sessions_index`,
and `enrich_conversation_from_index` as pure passthrough functions
around the canonical implementations in `common.py` / `index.py`.
The shadows add no behavior — they only force every caller of the
package-level `claude.X` name to traverse an extra frame and obscure
the real definition.
Re-export the real symbols directly so `from polylogue.sources.parsers.claude import normalize_timestamp` (used by the fuzz target and the
hypothesis property tests) and `claude.normalize_timestamp` (used by
`test_parsers_props.py`) resolve to `common.py`'s implementation without
the wrapper layer.
Verification:
pytest tests/unit/sources/test_parsers_base.py \
tests/unit/sources/test_parsers_props.py \
tests/unit/sources/test_tool_result_role_reclassification.py \
--deselect tests/unit/sources/test_parsers_props.py::test_extract_messages_from_list_never_invents_messages \
-n 0
# 132 passed
Co-Authored-By: Claude <[email protected]>
Returns (datetime, iso_string) in one call. Preserves the original string verbatim when the input is already a string so on-disk representations round-trip unchanged; for numeric inputs the canonical format_timestamp string is used. Lifts the (datetime, string) duplication out of the Codex parser.
Removes the local _timestamp_pair wrapper (it just rewrapped parse_timestamp + format_timestamp with string-preservation) in favour of the shared helper. Replaces _normalize_timestamp with a small _iso_or_none alias over parse_timestamp_pair so the four message/event sites keep a one-liner ISO accessor. No behaviour change.
5ed84c1 to
6fd371f
Compare
Summary
Two parser-layer cleanups bundled because both target the same surface (per-provider parser wrappers around shared core helpers).
claude/__init__.pyshadow wrappers (extract_text_from_segments,normalize_timestamp) — 33 LoC of dead code that duplicatedclaude/common.py's richer implementations.codex._timestamp_pairtocore/timestamps.pyasparse_timestamp_pair(value) -> tuple[datetime, str] | None— returns canonical (datetime, iso_string) pair; preserves the original verbatim string when input is a string, else canonicalformat_timestampoutput.Problem
claude/__init__.pyre-definedextract_text_from_segments(11 LoC) andnormalize_timestamp(~22 LoC) thatclaude/common.pyalready defined with richer bodies. Imports across the codebase landed at one site or the other depending on author memory; the shadow versions weren't reached by any current caller.polylogue/sources/parsers/codex.py::_timestamp_pairwas a tiny per-parser wrapper aroundcore/timestamps.py::parse_timestamp, returning both datetime and ISO-string in one call. It belonged incore/so other parsers could use it instead of inventing their own paired conversion.Solution
claude/__init__.py; thecommon.pyversions are the canonical ones, already in use everywhere it matters.parse_timestamp_pair(value)incore/timestamps.py. Returns(datetime, str) | None. When input is a string, the returned ISO string is the original string verbatim (preserves whatever format the source used) rather than re-formatting viaformat_timestamp— matches the original codex behavior.codex.py::_timestamp_pair(8 LoC) is gone; callers useparse_timestamp_pairdirectly.codex.py::_normalize_timestamp(3 LoC) shrinks to a 2-line_iso_or_nonealias that derives the ISO string fromparse_timestamp_pair(value)[1](kept rather than inlined at 4 call sites — inlining at the call would net positive LoC).Wrappers intentionally preserved
polylogue/sources/parsers/claude/common.py::normalize_timestampis NOT a passthrough. It produces an epoch-second float-string (e.g."1700000000.0") with millisecond-epoch detection (> 1e11 → / 1000). Different semantics from bothparse_timestamp(returns datetime) andparse_timestamp_pair(returns ISO string). Used by 2 sibling parsers plus a fuzz harness plus tests. Real added concern; left as-is.polylogue/sources/parsers/codex.py::_newer_timestamp{,_pair}are not parsing wrappers — they're latest-timestamp comparison utilities. Out of scope.polylogue/sources/parsers/chatgpt.pyalready callsparse_timestampdirectly inside_coerce_float; no wrapper to remove.Verification
nix develop --command pytest tests/unit/sources -q→ 1177 passed in 47.80s.nix develop --command ruff format polylogue/→ 802 files unchanged on commit.devtools verify-topologyclean (LoC counts updated).Files
polylogue/sources/parsers/claude/__init__.py(-33 LoC, 33-line shadow block removed)polylogue/core/timestamps.py(+19 LoC,parse_timestamp_pairhelper)polylogue/sources/parsers/codex.py(-10 net, two wrappers removed)docs/plans/topology-target.yaml(LoC counts updated)