Skip to content

claude-code-chat-browser: SessionMetadataDict — tighten all-NotRequired fields for mypy shape enforcement #101

Description

@clean6378-max-it

Calendar Day

Wednesday, July 2, 2026 (PR 1 of 2)

Planned Effort

5 story points (Medium–High) — sprint item #9

Companion PR: Wednesday PR 2 (YAML escape fix #6) — independent; can land in either order.

Problem

SessionMetadataDict declares every field as NotRequired, which means mypy provides no shape enforcement at all — any key can be absent and type-checking passes. This defeats the purpose of using TypedDict. The session metadata has known required fields (session ID, creation timestamp, model info) that should be enforced, while truly optional fields (custom title, tags, etc.) can remain NotRequired.

Goal

One merged PR that splits SessionMetadataDict into required and NotRequired fields based on actual session data contracts, fixes all construction sites flagged by mypy strict, and documents which fields are required and why.

Scope

Touch points

  • SessionMetadataDict definition — promote core identity fields (session ID, timestamps, model info) to required
  • Optional: split into SessionMetadataRequired (base) + SessionMetadataFull (extends with optional fields) if the split is complex
  • All construction sites — supply required fields; minimal test updates if needed
  • Brief docstring on the TypedDict explaining required vs optional fields

Out of scope

  • MessageDict shape splitting (T9 — horizon)
  • ExportStateDict casing alignment (T3 — horizon)
  • file_activity hardcoded strings (deferred)

Acceptance Criteria

  • SessionMetadataDict fields split into required and NotRequired based on actual contracts
  • At least session ID, creation timestamp, and model info are required
  • mypy --strict catches missing required fields at all construction sites
  • Existing tests pass without modification, or are minimally updated
  • Docstring explains which fields are required and why
  • Full pytest, mypy --strict, and ruff pass
  • PR approved by at least 1 reviewer

Verification

cd C:\Users\Jasen\CppAliance\claude-code-chat-browser
.\.venv\Scripts\Activate.ps1
mypy .
pytest -q

Manual: remove a required field at a construction site — confirm mypy error, then fix.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions