Skip to content

fix(storage): restore literal_check deleted out from under live call sites - #3464

Merged
Sinity merged 1 commit into
masterfrom
hotfix/restore-literal-check
Jul 31, 2026
Merged

Sinity merged 1 commit into
masterfrom
hotfix/restore-literal-check

Conversation

@Sinity

@Sinity Sinity commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

Restores literal_check in polylogue/storage/sqlite/archive_tiers/common.py, deleted by #3458 as a supposed zero-call-site dead shim. It has real call sites and master's HEAD currently fails to import archive_tiers/index.py at all.

Problem

#3458 (5798b3d, "collapse duplicate implementations, dead shims, and split vocabularies") deleted literal_check from common.py on the strength of a "zero call sites" grep (bead polylogue-u6tl). But #3451 (42bafb0, "wire literal_check into DDL, fix a drift CHECK gap") had already landed earlier the same day and wired it into archive_tiers/index.py's delegation_facts DDL for DelegationMappingState/DelegationResultStatus CHECK constraints. #3458's grep predated #3451's merge and was never re-run against the merged tree.

Net effect on current master: every module that imports archive_tiers/index.py (i.e. essentially the whole storage substrate, and by extension most of tests/) fails at collection with ImportError: cannot import name 'literal_check' from 'polylogue.storage.sqlite.archive_tiers.common'. Discovered while running devtools test for unrelated work on polylogue-cgfy — a fresh devtools test on any file failed at conftest import.

Solution

Restore literal_check verbatim (matching #3451's usage and CLAUDE.md's still-accurate description of it as real machinery for the ~20 enum-backed columns "and the handful of literal_check call sites wired so far"), rather than migrating the two real call sites to check()/nullable_check() — those only accept PolylogueStrEnum, not the typing.Literal aliases DelegationMappingState/DelegationResultStatus actually are. No other part of #3458 touched.

Verification

  • devtools test tests/unit/sources/test_parsers_claude_code_artifacts.py tests/unit/storage/test_archive_tiers_common.py — 38 passed (previously failed at collection with ImportError)
  • devtools verify --quick — exit 0 (format, lint, mypy, render all --check, schema-versioning policy) — ran automatically via the pre-push hook

…sites

Problem: PR #3458 (5798b3d) deleted `literal_check` from
`storage/sqlite/archive_tiers/common.py` as "zero call sites"
(polylogue-u6tl), but PR #3451 (42bafb0, merged earlier the same day) had
already wired it into `archive_tiers/index.py`'s `delegation_facts` DDL for
`DelegationMappingState`/`DelegationResultStatus` CHECK constraints. #3458's
grep predated #3451's landing and was never re-run against the merged tree,
so master's HEAD import-fails on every module that touches
`archive_tiers/index.py` (`ImportError: cannot import name 'literal_check'`)
-- this broke test collection repo-wide, discovered while running
`devtools test` for unrelated work on polylogue-cgfy.

Solution: restore `literal_check` verbatim (matching #3451's usage and
CLAUDE.md's still-accurate description of it), rather than migrating the two
real call sites to `check()`/`nullable_check()` -- those only accept
`PolylogueStrEnum`, not the `typing.Literal` aliases `DelegationMappingState`/
`DelegationResultStatus` actually are.

Verification: devtools test tests/unit/sources/test_parsers_claude_code_artifacts.py
tests/unit/storage/test_archive_tiers_common.py -> 38 passed (previously
failed at collection with ImportError).
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4ee3c53c-cda1-4178-8013-8188da584329

📥 Commits

Reviewing files that changed from the base of the PR and between 7a0d381 and 2cca1e5.

📒 Files selected for processing (1)
  • polylogue/storage/sqlite/archive_tiers/common.py

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.

@Sinity
Sinity merged commit aeea9c4 into master Jul 31, 2026
3 checks passed
@Sinity
Sinity deleted the hotfix/restore-literal-check branch July 31, 2026 14:33
Sinity added a commit that referenced this pull request Jul 31, 2026
…#3465)

## Summary

Closes out the remainder of polylogue-cgfy's disposition work now that
PR #3442 landed the flagship consumption gap
(structuredPatch/originalFile/oldString -> file_edits, reachable via API
+ MCP + CLI `read --view file-edits`). Adds the two remaining
genuinely-unread, real-value wire keys (`requestId`,
`thinkingMetadata.maxThinkingTokens`) and records the full disposition
(read / measured-negative / deliberately-dropped-duplicate) for the rest
of the bead's "other unread keys of substance" list in the Claude Code
OriginSpec's `fidelity_notes`, satisfying AC1.

## Problem

polylogue-cgfy's 2026-07-29 corpus enumeration found 34 of the 70 most
common Claude Code wire keys with zero references in
`polylogue/sources/`. The structuredPatch/originalFile/oldString cluster
(105K/92K/86K rows) and most of the "other keys of substance" list
(`stop_reason`, `stop_sequence`, `cache_creation`, `ttftMs`, `todos`,
`toolUseResult.sandbox`/`filenames`/`numFiles`, `slug`) were captured by
prior sessions on this bead and PR #3442, but two items remained
genuinely unread with no recorded disposition either way: `requestId`
(1,171 sampled occurrences -- the Anthropic API's per-call request id)
and `thinkingMetadata.maxThinkingTokens` (34 occurrences -- the
extended-thinking token budget). The bead's remaining lower-value items
(`userType`, `sourceToolAssistantUUID`, `hookCount`/`hookInfos`,
`toolUseID`) also had no recorded disposition, so AC1 ("every key...
classified... recorded in the Claude Code OriginSpec fidelity
declaration") was incomplete.

Verified each of those lower-value items directly against a real
~/.claude/projects corpus before classifying:
- `userType` is the literal string `"external"` on every sampled record
(measured negative, same class as the bead's own `usage.service_tier`
finding).
- `sourceToolAssistantUUID` equals that same record's own `parentUuid`,
already captured as `ParsedMessage.parent_message_provider_id` -- a
duplicate spelling, not new evidence.
- `hookCount`/`hookInfos` describe hook firings already tracked durably
(with outcome, which `hookInfos` lacks) in `source.db`'s
`raw_hook_events`.
- `toolUseID` is already consumed for its real signal (the
`progress`/`agent_progress` delegation-edge disposition documented in
`code_parser.py`'s module docstring).

Also discovered en route: `master` HEAD (5798b3d) failed to import at
all (`ImportError: cannot import name 'literal_check'`) -- #3458 deleted
it as a supposed zero-call-site dead shim, but #3451 had wired real call
sites into it earlier the same day. Fixed and merged separately as #3464
so this branch could even run tests; this branch is rebased on top of
that fix.

## Solution

- `polylogue/sources/parsers/claude/code_parser.py`:
`_message_usage_event_payload` gains a `record` parameter (the top-level
record `item`, since `requestId`/`thinkingMetadata` live there, not
inside `message`); the sole call site now passes `record=item`. Both new
keys ride the existing `message_usage` session-event payload as
`request_id`/`max_thinking_tokens`.
- **Production callers exercising the new fields**:
`Session.session_events` -> CLI `read --view events`
(`polylogue/cli/read_views/events.py` -> `run_session_events`,
`polylogue/cli/messages.py`) and MCP `get(ref, projection="events")`
(`polylogue/mcp/server_cutover.py:905`) already render every
`session_events` row generically regardless of `event_type` -- no new
consumer code needed, verified by reading both call chains before
writing this PR (the generic `events` projection was wired by prior
work, not this PR).
- `polylogue/sources/origin_specs.py`: new `fidelity_notes` entry on the
Claude Code `OriginSpec` recording the full disposition table above.

## Verification

- `devtools test
tests/unit/sources/test_claude_code_unread_wire_fields.py
tests/unit/sources/test_parsers_claude_code_artifacts.py
tests/unit/sources/test_origin_specs.py` -> 57 passed
- `devtools verify --quick` -> exit 0 (format, lint, mypy, render all
--check, schema-versioning policy)
- Anti-vacuity: each new field has a paired "field absent" test
asserting the key is omitted from the payload, not fabricated

Ref polylogue-cgfy

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Enhancements**
- Claude Code usage events now capture available request identifiers and
maximum thinking-token settings.
- Missing metadata continues to be omitted, keeping usage records clean
and accurate.

- **Quality Improvements**
- Added coverage to verify that these Claude Code fields are preserved
and handled consistently.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sinity added a commit that referenced this pull request Jul 31, 2026
Resolves the common.py conflict by taking master's literal_check restoration
(#3464), which superseded this branch's own prerequisite fix for the same
breakage.
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.

1 participant