Data Model: Annoying Bugs Sweep

Existing Entities

LegacyWPRuntime

The pre-event-source witness read from WP frontmatter and tasks.md.

FieldRole in this mission
wp_idPer-WP ordering and verification key
shell_pidClaim-borne value that must survive
shell_pid_created_atClaim-borne value that must survive
agentClaim-borne value that must survive
assignee, tracker_refs, subtasks, reviewAnnotation values that must not overwrite later legitimate annotations

EventStream

Two independently ordered collections:

  • transitions: folded by (at, event_id) to derive lane and claim-borne slots.
  • annotations: folded after transitions, also by (at, event_id), to derive off-axis slots.

Planning Value Objects

WPSeedOrder

FieldTypeInvariant
wp_idstrSafe WP identifier
existing_transition_keyssequence of (at, event_id)Read from the canonical status stream
existing_annotation_keyssequence of (at, event_id)Read from the same stream
seed_key(at, event_id)Strictly less than every existing key for this WP when history exists
anchor_sourceenumexisting_history_floor, claim_event, frontmatter, or mission_created_at

The implementation may use a helper rather than a persisted dataclass. The value-object model exists to make the invariant testable.

ClaimSlotWitness

FieldTypeRule
wp_idstrMatches the legacy row
slotenumshell_pid, shell_pid_created_at, or agent
legacy_valuescalarDerived directly from read_legacy_runtime
raw_seed_valuescalarValue persisted in the migration seed evidence
snapshot_valuescalarReduced after seed append
later_legitimate_writerboolWhether non-migration history owns the final slot
matchesboolRaw seed equals legacy; snapshot equals legacy only without a later writer

Every non-null legacy claim slot requires a matching raw seed witness. Snapshot equality is required only when no later legitimate writer exists; otherwise verification proves that later value wins.

SeedCompatibilityRepair

FieldTypeRule
repair_idULIDDeterministic namespace distinct from the original seed id
corrupting_seed_idULIDIdentifies the persisted pre-fix seed
restored_valuescalarValue reduced from legitimate history with migration seeds excluded
slotlane or annotation fieldRepairs only a value the old seed currently corrupts

Compatibility repairs are append-only and idempotent. They are not emitted for correctly ordered seeds or where a later legitimate writer already wins.

DeadCodeVerdict

FieldTypeMeaning
stateenumclean, findings, undeterminable
diagnostic_codestring or nullStable code for non-clean structured results
examined_filesintegerNon-negative denominator
symbolslistDiscovered public symbols
findingslistUnreferenced symbols or diagnostic finding
reasonstring or nullRequired for undeterminable

State rules:

  • clean requires successful discovery and examined_files > 0 for a supported source change set.
  • findings requires at least one unreferenced symbol.
  • undeterminable requires a stable diagnostic code and remediation; it is never rendered as clean.

State Transitions

Birth cutover

legacy read -> seed/compatibility plan -> append missing deterministic seeds or repairs
            -> reduce -> independent raw + snapshot verify -> flip status_phase

Any append or verification error leaves status_phase unchanged.

Dead-code gate

baseline present -> diff discovery
  -> failed/unsupported -> undeterminable finding
  -> supported -> symbol extraction -> reference scan
       -> unreferenced symbols -> findings
       -> none -> clean