Repository navigation
feat(sources): model Claude Design as a distinct origin, parse memories.json - #3422
Conversation
…es.json Problem: Claude Design chats (design_chats/*.json in a Claude AI GDPR export) were reduced to a CLAUDE_DESIGN_CHAT_INGEST_FLAG on a plain claude-ai-export session. Measured against 11 real design_chats (bd polylogue-tbun): Claude Design is a different product/backend, not claude.ai with a flag -- camelCase contentBlocks/authorAccountUuid/ turnChanges wire shape, message.content is a dict not a list. The old parser only ever read content.content (a flat concatenated string), so it silently dropped 7 of 95 real messages (bd polylogue-je9t): any assistant turn made entirely of tool calls, and any user message with attachments but empty inline text. It also never parsed contentBlocks at all -- 751 tool_call, 211 thinking, 175 text, 10 error, and 5 user_interjection blocks across the sample were entirely unread. Separately, memories.json (the claude.ai account-memory GDPR sidecar) had no parser at all and was silently dropped on every import (bd polylogue-zng9). Solution: - Origin.CLAUDE_DESIGN_SESSION / Provider.CLAUDE_DESIGN admitted as a first-class origin (core/enums.py, core/sources.py, core/provider_identity.py, sources/origin_specs.py, sources/dispatch.py, sources/revision_backfill.py), wired through every exhaustive Origin-keyed surface this triggers (semantic card registry, webui theme/design-system contract, agent-integration manual). CLAUDE_DESIGN_CHAT_INGEST_FLAG is retired outright (hard rename, no compat shim) in favor of the distinct origin/provider. - ai_parser.py rewritten: parse_design() walks contentBlocks properly (tool_call -> TOOL_USE/TOOL_RESULT sharing tool_id with the Claude API's toolu_* space, thinking -> THINKING, text -> TEXT, error -> TEXT+is_error). turnChanges (the per-turn create/edit/delete/move file diff -- nothing else in the archive records what a turn changed on disk) becomes a claude_design_turn_changes session_event, reusing the existing session_events/payload_json mechanism this module already uses for claude_ai_conversation_summary rather than adding a new construct type or table. user_interjection (a user message nested inside an assistant turn) is not flattened: the turn's blocks are split at the interjection boundary into separate ParsedMessage segments with incrementing positions, so the interjection lands as a real role=user message physically between the two half-turns. authorAccountUuid/authorName become sender_name plus a claude_design_message_author session_event. attachment_kind (an open string field, no schema change needed) gains "skill" and "folder". The contentBlocks/attachment rewrite also fixes the 7-message loss: a message is only dropped when it truly has no blocks/attachments/ text, not merely an empty flat content string. - parse_memories() represents memories.json as a synthetic session under the existing Provider.CLAUDE_AI/Origin.CLAUDE_AI_EXPORT (no new origin needed -- same backend, no wire-format distinction) with one role=system, material_origin=GENERATED_CONTEXT_PACK message per memory scope (global conversations_memory + one per project). provider_session_id is deterministic (account-memory:<account_uuid>), so re-import is idempotent via the existing content-hash mechanism. - Both looks_like_claude_design/looks_like_claude_memories are strict: unrecognized contentBlocks types and message roles are logged and dropped, never guessed -- the corpus is 11 chats and the product is still moving. - Filed polylogue-6tue (follow-up: every observed title is literally "Chat"; deriving a real title is out of scope here). Verification: devtools verify --quick (format/lint/mypy/render-all/ layering/closure-matrix/schema-roundtrip/manifests/doc-commands/ docs-coverage/clock-hygiene/hash-boundary-census/schema-versioning) green. devtools test across every exhaustive Origin/Provider-keyed test module this change touches (test_origin_specs.py, test_parsers_claude_design.py, test_parsers_claude_ai_catalog.py, test_dispatch_payloads.py, test_dispatch_ordering.py, test_sources.py, test_semantic_cards.py, test_manual_contract.py, test_json.py, test_provider_origin_dedup.py, test_provider_completeness.py, test_browser_capture.py, test_provider_usage_report.py, ui/, mcp tool declarations) -- 515 tests, all green. A full-repo `devtools verify --seed-testmon` was attempted but timed out under this host's concurrent multi-worktree load (unrelated to this change); the targeted sweep above covers every exhaustiveness assertion an Origin/Provider addition can trip, found via `grep -rl 'for .* in Origin\|for .* in Provider\|set(Origin)\|set(Provider)'`. Not run: the full non-testmon suite and integration tests. Ref polylogue-tbun, polylogue-zng9, polylogue-je9t Co-Authored-By: Claude <[email protected]>
polylogue-6tue: derive real Claude Design chat titles instead of the literal "Chat" placeholder, filed while implementing polylogue-tbun. Co-Authored-By: Claude <[email protected]>
|
Warning Review limit reached
Next review available in: 23 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (24)
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 |
Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d91fc74b93
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| messages.append( | ||
| ParsedMessage( | ||
| provider_message_id=interjection_id, | ||
| role=Role.normalize(str(interjection_message.get("role") or "user")), | ||
| text=str(interjection_text) if isinstance(interjection_text, str) and interjection_text else None, |
There was a problem hiding this comment.
Preserve attachments on user interjections
When a user_interjection.message carries attachments, this branch copies only its id, role, content, and timestamp. _design_assistant_messages neither invokes _design_attachment_from_meta nor returns attachments to parse_design, so those files and inline bytes silently disappear from the imported session. Parse the nested user message's attachments and add them to the session attachment accumulator.
Useful? React with 👍 / 👎.
# Conflicts: # .beads/issues.jsonl
…-guard isinstance (#3500) ## Summary Two independent full-suite-red root causes on master, both invisible to per-PR CI's heavy-test skip: the material-protocol origin-vocabulary drift latch (tripped by #3422 adding `claude-design-session`) and the clock guard's `datetime` replacement breaking `isinstance` in guarded test modules. Together they account for ~50 of the 128 failures in a `devtools verify --all` run on master. ## Problem 1. PR #3422 (2026-07-31 10:23) added `claude-design-session` to `core.enums.Origin` without bumping `CURRENT_ORIGIN_VOCABULARY_VERSION` — `resolve_current_origin_vocabulary()`'s deliberate drift latch asserts on every encode, failing all 22 material-protocol tests and downstream encoders. 2. The clock guard installs a raising `datetime` subclass into guarded modules; `isinstance(production_datetime, datetime)` there became an always-false subclass check, failing 20+ tests (test_models timestamp parsing, timestamp guards, null-guard properties). ## Solution - `origin_vocab.py`: version 2→3, frozen digest computed via the module's own documented command, v3 provenance comment; checked-in small-session fixture regenerated via `write_revision` (segment bytes identical, only manifest vocabulary fields changed). - `clock_guard.py`: `GuardedDateTime` gains a metaclass (`_DelegatingInstanceCheck(type)`) whose `__instancecheck__` delegates to real `datetime` — clock reads still raise; type identity restored. ## Verification - `devtools test tests/unit/material_protocol/v1/` — 43 passed (was 22 failed) - `devtools test tests/unit/sources/test_models.py tests/unit/core/test_timestamp_guards.py tests/unit/sources/test_null_guard_properties.py tests/unit/infra/test_clock_guard.py` — 405 passed (test_models was 11 failed) - `mypy --strict` on both changed files — clean - Re-run of a 44-file failed set from a full-suite run: 128 → 78 failures; residual is a third class (Origin-list snapshot pins + a storage-cluster batch), tracked separately. Co-Authored-By: Claude <[email protected]> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added support for the updated origin vocabulary, including distinct `claude-design-session` origins. - Updated session metadata to use the latest vocabulary version and verification information. - **Bug Fixes** - Improved date/time validation behavior while preserving compatibility with standard datetime values. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <[email protected]>
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Claude Design chats get their own
Origin.CLAUDE_DESIGN_SESSION/Provider.CLAUDE_DESIGNinstead of being reduced to aCLAUDE_DESIGN_CHAT_INGEST_FLAGon a plainclaude-ai-exportsession, theparser now actually reads
contentBlocks(tool calls, thinking, errors,turn-changes, user interjections) instead of a single flat concatenated
string, and the account-level
memories.jsonGDPR sidecar is parsed forthe first time.
Problem
Measured against 11 real
design_chats/*.jsonfiles (bd polylogue-tbun):Claude Design is a different product/backend from claude.ai, not a flag on
it — camelCase
contentBlocks/authorAccountUuid/turnChangeswireshape,
message.contentis a dict, not a list. The pre-existing parseronly ever read
content.content(a flat concatenated string) and nevertouched
contentBlocksat all, so:tool_call, 211thinking, 175text, 10error, and 5user_interjectionblocks in the sample were entirely unread.assistant turn made entirely of tool calls (empty flat
content, realcontentBlocks), and any user message carrying only attachments with anempty inline
contentstring.Separately,
memories.json(Claude's account-level standing memorysummary, shipped in every claude.ai GDPR export) had no parser at all —
import --explainshowed it contributing nothing to every import(bd polylogue-zng9).
Solution
Origin.CLAUDE_DESIGN_SESSION/Provider.CLAUDE_DESIGNadmitted in
core/enums.py,core/sources.py,core/provider_identity.py,sources/origin_specs.py(new_claude_design_spec(),"proposed"completeness maturity — no schema-harvest package exists yet for an
11-chat sample),
sources/dispatch.py(new detector branch, ahead of thegeneral claude.ai check since the shapes are disjoint but the Design
signature is tighter),
sources/revision_backfill.py. Wired through everyexhaustive
Origin-keyed surface this triggers:rendering/ semantic_card_registry.py,ui/theme.py(webui badge tokens),agent_integration/spec.py(ORIGIN_MEANINGS), plus their generatedartifacts (
docs/agent-manual.md,webui/src/generated/*).CLAUDE_DESIGN_CHAT_INGEST_FLAGis retired outright — hard rename, nocompat shim, per this repo's "no compat pre-adoption" policy.
sources/parsers/claude/ai_parser.py,parse_design):tool_call→TOOL_USE/TOOL_RESULTsharingtool_idwith the Claude API's
toolu_*id space;thinking→THINKING;text→
TEXT;error→TEXT+is_error=True(mirrors the existingunrecognized-block-to-text mapping in
drive_support_blocks.py; no newBlockTypeneeded). Unrecognized block types/message roles are loggedand dropped, never guessed — the corpus is 11 chats and the product is
still moving.
claude_design_turn_changessession_event(
payload_json), reusing the exact mechanism this module already usesfor
claude_ai_conversation_summary/claude_ai_web_tool_evidence—turn-scoped structured evidence is exactly what
session_eventsalreadymodels. No new construct type, no schema change.
assistant turn would lose its interruption semantics and physical
ordering if collapsed into an ordinary same-position message, so the
turn's blocks are split at the interjection boundary into separate
ParsedMessagesegments with incrementing positions — the interjectionlands as a real
role=usermessage physically between the twohalf-turns (
a1#0, then the interjection, thena1#1).sender_nameplus aclaude_design_message_authorsession_event (named multi-accountauthorship has no claude.ai equivalent).
"skill"and"folder"— an open stringfield (see
ParsedAttachment.attachment_kinddocstring), so no schemachange.
contentBlocksproperly: a message is now only dropped when it truly hasno blocks, no attachments, and no text — not merely an empty flat
contentstring.parse_memories): represented as a synthetic sessionunder the existing
Provider.CLAUDE_AI/Origin.CLAUDE_AI_EXPORT(samebackend, no wire-format distinction — unlike Design, this doesn't warrant
a new origin), dispatched internally from
parse_aion shape (the samepattern this module used for Design before it got its own
origin/provider). One
role=system,material_origin=GENERATED_CONTEXT_PACKmessage per memory scope (globalconversations_memory+ one perproject_memoriesentry).provider_session_idis deterministic (account-memory:<account_uuid>),so re-import is idempotent through the existing content-hash mechanism —
no new machinery needed for the idempotency requirement.
polylogue-6tue(follow-up, deliberately out of scope here): everyobserved Design chat title is literally
"Chat"; deriving a real titleis the same class of gap as the claude-code raw-UUID title problem.
Explicitly out of scope (per the task's own scope note): live
browser-extension capture of Design chats (
bd polylogue-????, a separatetracked bead — Claude Design uses a Connect-RPC/protobuf transport with no
published schema, needing a different capture strategy than the
fetch-hook JSON interception the existing adapters use) and the WebUI
session view that leads with
turnChanges/folds tool calls/showsinterjections inline (
daemon/webui.pyis 1,638 lines and outside thisPR's declared surface — this PR wires the origin through the existing
badge/theme contract so the WebUI doesn't crash on a Design session, but
does not build the bespoke view).
Verification
ruff format --check/ruff check— clean.mypy polylogue— clean (1100 files).devtools render all --check— clean; regenerateddocs/agent-manual.md,docs/agent-integration-reference.md,polylogue/agent_integration/data/*,webui/src/generated/*afterbumping the two hardcoded
Origin-count tripwires(
agent_integration/spec.py'sORIGIN_MEANINGSparity check,devtools/render_webui_design_system.py'sexpected N public Origin tokens) that exist specifically to catch a newOriginmember missingits label/badge wiring.
devtools testacross every exhaustiveness-check module anOrigin/Provideraddition can trip (found viagrep -rl 'for .* in Origin\|for .* in Provider\|set(Origin)\|set(Provider)'overtests/):test_origin_specs.py,test_parsers_claude_design.py(new),test_parsers_claude_ai_catalog.py,test_dispatch_payloads.py,test_dispatch_ordering.py,test_sources.py,test_semantic_cards.py,test_manual_contract.py,test_json.py,test_provider_origin_dedup.py,test_provider_completeness.py,test_browser_capture.py,test_provider_usage_report.py, plustests/unit/ui/andtests/unit/mcp/test_tool_declarations.py— 515tests, all green, both before and after rebasing onto latest
origin/master.devtools verify --quick(format/lint/mypy/render-all/layering/closure-matrix/schema-roundtrip/manifests/ci-workflows/doc-commands/
docs-coverage/test-infra-currency/clock-hygiene/pytest-timeout-overrides/
degrade-loudly/hash-boundary-census/schema-versioning/schema-promotion-
audit) — green, both standalone and via the pre-push hook.
devtools verify --seed-testmon(attempted;timed out after ~13 minutes under this host's concurrent multi-worktree
load — several other sessions were seeding testmon simultaneously — this
is host contention, unrelated to the change) and
tests/integration/.Ref polylogue-tbun, polylogue-zng9, polylogue-je9t
Co-Authored-By: Claude [email protected]