Skip to content

fix: generic parent ref resolution for clarification workflow#85

Merged
MaxLinCode merged 4 commits intomainfrom
claude/generic-parent-ref-fix
Apr 15, 2026
Merged

fix: generic parent ref resolution for clarification workflow#85
MaxLinCode merged 4 commits intomainfrom
claude/generic-parent-ref-fix

Conversation

@MaxLinCode
Copy link
Copy Markdown
Owner

Summary

  • Adds parentTargetRef field to clarification entity schema — back-pointer from clarification to the original write target entity
  • Implements generic parent ref resolution in resolveWriteTarget: when focus_entity_id points at an entity with parentTargetRef, follows the ref to the actual write target (turn-type agnostic)
  • Populates parentTargetRef from resolvedOperation.targetRef when creating clarifications, and closes prior open clarifications (one-open-per-workflow invariant)

Supersedes PR #84 — uses entity-registry-based generic approach instead of the clarification-specific pending_clarifications lookup.

Bug fixed

When focus_entity_id points at a clarification entity, applyWriteCommit detects a "target change" and wipes accumulated fields like day: "tomorrow". Multi-turn planning breaks: "schedule gym tomorrow" → "what time?" → "10am" loses the day.

Test plan

  • Schema tests: parentTargetRef null, object, and rejection when omitted (3 tests)
  • resolveWriteTarget tests: follows parentTargetRef, works regardless of turn type, no-op for entities without parentTargetRef, handles null parentTargetRef (4 new tests)
  • deriveConversationReplyState tests: populates parentTargetRef from resolvedOperation, null for new plans, closes prior open clarifications (3 new tests)
  • Full typecheck clean across all packages
  • Full test suite green (279 tests)

🤖 Generated with Claude Code

MaxLinCode and others added 3 commits April 14, 2026 03:16
Back-pointer from clarification entity to original write target.
Uses .optional().default(null) for backward compatibility with stored entities.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When focus_entity_id points at an entity with parentTargetRef (e.g. a
clarification), follow the ref to the actual write target. Turn-type
agnostic — works for any entity kind with a parent back-pointer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Derive from resolvedOperation.targetRef when creating clarifications.
Close prior open clarifications (one-open-per-workflow invariant).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
atlas-web Ignored Ignored Preview Apr 15, 2026 6:43am

@MaxLinCode MaxLinCode force-pushed the claude/generic-parent-ref-fix branch from f07cd82 to 68a7ac2 Compare April 15, 2026 06:25
ZodDefault/ZodOptional wrappers create input vs output type
mismatches that surface as "two different types" errors when
ConversationEntity is resolved through multiple package paths.

Use plain targetRefSchema (no wrappers) and require the field
explicitly. Runtime code uses `"parentTargetRef" in entity.data`
to handle pre-migration entities gracefully.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MaxLinCode MaxLinCode force-pushed the claude/generic-parent-ref-fix branch from 68a7ac2 to 942c2e3 Compare April 15, 2026 06:43
@MaxLinCode MaxLinCode merged commit ad128bf into main Apr 15, 2026
2 checks passed
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