Skip to content

feat(sources): model Claude Design as a distinct origin, parse memories.json - #3422

Merged
Sinity merged 5 commits into
masterfrom
feature/sources/claude-design-origin
Jul 31, 2026
Merged

Sinity merged 5 commits into
masterfrom
feature/sources/claude-design-origin

Conversation

@Sinity

@Sinity Sinity commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

Claude Design chats get their own Origin.CLAUDE_DESIGN_SESSION /
Provider.CLAUDE_DESIGN instead of being reduced to a
CLAUDE_DESIGN_CHAT_INGEST_FLAG on a plain claude-ai-export session, the
parser now actually reads contentBlocks (tool calls, thinking, errors,
turn-changes, user interjections) instead of a single flat concatenated
string, and the account-level memories.json GDPR sidecar is parsed for
the first time.

Problem

Measured against 11 real design_chats/*.json files (bd polylogue-tbun):
Claude Design is a different product/backend from claude.ai, not a flag on
it — camelCase contentBlocks/authorAccountUuid/turnChanges wire
shape, message.content is a dict, not a list. The pre-existing parser
only ever read content.content (a flat concatenated string) and never
touched contentBlocks at all, so:

  • 751 tool_call, 211 thinking, 175 text, 10 error, and 5
    user_interjection blocks in the sample were entirely unread.
  • 7 of 95 real messages were silently dropped (bd polylogue-je9t): any
    assistant turn made entirely of tool calls (empty flat content, real
    contentBlocks), and any user message carrying only attachments with an
    empty inline content string.

Separately, memories.json (Claude's account-level standing memory
summary, shipped in every claude.ai GDPR export) had no parser at all —
import --explain showed it contributing nothing to every import
(bd polylogue-zng9).

Solution

  • Distinct origin: Origin.CLAUDE_DESIGN_SESSION / Provider.CLAUDE_DESIGN
    admitted 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 the
    general claude.ai check since the shapes are disjoint but the Design
    signature is tighter), sources/revision_backfill.py. Wired through every
    exhaustive Origin-keyed surface this triggers: rendering/ semantic_card_registry.py, ui/theme.py (webui badge tokens),
    agent_integration/spec.py (ORIGIN_MEANINGS), plus their generated
    artifacts (docs/agent-manual.md, webui/src/generated/*).
    CLAUDE_DESIGN_CHAT_INGEST_FLAG is retired outright — hard rename, no
    compat shim, per this repo's "no compat pre-adoption" policy.
  • Real contentBlocks parsing (sources/parsers/claude/ai_parser.py,
    parse_design): tool_call → TOOL_USE/TOOL_RESULT sharing tool_id
    with the Claude API's toolu_* id space; thinking → THINKING; text
    → TEXT; error → TEXT + is_error=True (mirrors the existing
    unrecognized-block-to-text mapping in drive_support_blocks.py; no new
    BlockType needed). Unrecognized block types/message roles are logged
    and dropped, never guessed — the corpus is 11 chats and the product is
    still moving.
  • turnChanges: modeled as a claude_design_turn_changes session_event
    (payload_json), reusing the exact mechanism this module already uses
    for claude_ai_conversation_summary/claude_ai_web_tool_evidence —
    turn-scoped structured evidence is exactly what session_events already
    models. No new construct type, no schema change.
  • user_interjection: NOT flattened. A user message nested inside an
    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
    ParsedMessage segments with incrementing positions — the interjection
    lands as a real role=user message physically between the two
    half-turns (a1#0, then the interjection, then a1#1).
  • authorAccountUuid/authorName: sender_name plus a
    claude_design_message_author session_event (named multi-account
    authorship has no claude.ai equivalent).
  • attachment_kind: gains "skill" and "folder" — an open string
    field (see ParsedAttachment.attachment_kind docstring), so no schema
    change.
  • The 7-message loss is fixed as a side effect of parsing
    contentBlocks properly: a message is now only dropped when it truly has
    no blocks, no attachments, and no text — not merely an empty flat
    content string.
  • memories.json (parse_memories): represented as a synthetic session
    under the existing Provider.CLAUDE_AI/Origin.CLAUDE_AI_EXPORT (same
    backend, no wire-format distinction — unlike Design, this doesn't warrant
    a new origin), dispatched internally from parse_ai on shape (the same
    pattern this module used for Design before it got its own
    origin/provider). One role=system,
    material_origin=GENERATED_CONTEXT_PACK message per memory scope (global
    conversations_memory + one per project_memories entry).
    provider_session_id is deterministic (account-memory:<account_uuid>),
    so re-import is idempotent through the existing content-hash mechanism —
    no new machinery needed for the idempotency requirement.
  • Filed polylogue-6tue (follow-up, deliberately out of scope here): every
    observed Design chat title is literally "Chat"; deriving a real title
    is 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 separate
tracked 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/shows
interjections inline (daemon/webui.py is 1,638 lines and outside this
PR'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; regenerated
    docs/agent-manual.md, docs/agent-integration-reference.md,
    polylogue/agent_integration/data/*, webui/src/generated/* after
    bumping the two hardcoded Origin-count tripwires
    (agent_integration/spec.py's ORIGIN_MEANINGS parity check,
    devtools/render_webui_design_system.py's expected N public Origin tokens) that exist specifically to catch a new Origin member missing
    its label/badge wiring.
  • devtools test across every exhaustiveness-check module an
    Origin/Provider addition can trip (found via grep -rl 'for .* in Origin\|for .* in Provider\|set(Origin)\|set(Provider)' over tests/):
    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, plus
    tests/unit/ui/ and tests/unit/mcp/test_tool_declarations.py — 515
    tests, 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.
  • Not run: a full-repo 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]

Sinity and others added 2 commits July 31, 2026 07:03
…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]>
@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: 23 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: 867f0f2c-c6ab-473f-a6bb-63b750abf4dd

📥 Commits

Reviewing files that changed from the base of the PR and between fb980cb and a5ad630.

⛔ Files ignored due to path filters (3)
  • webui/src/generated/contracts.ts is excluded by !**/generated/**
  • webui/src/generated/contrast-report.json is excluded by !**/generated/**
  • webui/src/generated/tokens.css is excluded by !**/generated/**
📒 Files selected for processing (24)
  • devtools/render_webui_design_system.py
  • docs/agent-integration-reference.md
  • docs/agent-manual.md
  • docs/architecture.md
  • docs/provider-origin-identity.md
  • polylogue/agent_integration/data/deep-reference.md
  • polylogue/agent_integration/data/integration-spec.json
  • polylogue/agent_integration/data/standing-manual.md
  • polylogue/agent_integration/spec.py
  • polylogue/core/enums.py
  • polylogue/core/provider_identity.py
  • polylogue/core/sources.py
  • polylogue/rendering/semantic_card_registry.py
  • polylogue/sources/dispatch.py
  • polylogue/sources/origin_specs.py
  • polylogue/sources/parsers/claude/__init__.py
  • polylogue/sources/parsers/claude/ai_parser.py
  • polylogue/sources/revision_backfill.py
  • polylogue/ui/theme.py
  • tests/unit/agent_integration/test_manual_contract.py
  • tests/unit/rendering/test_semantic_cards.py
  • tests/unit/sources/test_dispatch_payloads.py
  • tests/unit/sources/test_parsers_claude_ai_catalog.py
  • tests/unit/sources/test_parsers_claude_design.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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread polylogue/core/enums.py Resolved
Comment on lines +295 to +299
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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@Sinity
Sinity merged commit 3245eb3 into master Jul 31, 2026
1 of 3 checks passed
@Sinity
Sinity deleted the feature/sources/claude-design-origin branch July 31, 2026 08:23
Sinity added a commit that referenced this pull request Aug 1, 2026
…-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]>
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 62.F010 / P1: refuted at the checked revision: The requested migration concerns the retired source-v15 archive. AGENTS.md:74-77 requires a fresh v1 archive and explicitly excludes migration, import or readback of earlier Polylogue state, so preserving that historical CHECK shape through an upgrade is outside the supported format contract.

Only the rows listed above are dispositioned. Held findings remain open.

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