Skip to content

[upstream-sync] Target state ownership transfer between components (upstream PR #1787) #133

@github-actions

Description

@github-actions

Upstream Change Summary

Type: architectural-change
Difficulty: Hard
Recommendation: Adopt

Upstream PR #1787 introduces target state ownership transfer between components — enabling one component to "take over" a target state path from another via an update operation rather than a delete + re-insert. This restructures pre_commit into two phases and adds inverted tracking (TargetStateOwnerInfo) that maps each TargetStatePath to its owning component.

This is a meaningful correctness improvement: without it, transferring target state ownership between components causes a disruptive delete + insert cycle rather than an in-place update, which can break downstream consistency and is unnecessarily expensive.

Upstream References

Relevant Upstream Files / Areas

  • rust/core/src/engine/context.rscrates/recoco-core/src/execution/ (context)
  • rust/core/src/engine/execution.rscrates/recoco-core/src/execution/ (execution engine)
  • rust/core/src/state/db_schema.rscrates/recoco-core/src/execution/ (state tracking)
  • python/tests/core/test_ownership_transfer.py → Rust integration tests to be written

Recoco Considerations

  • Affected modules: crates/recoco-core execution engine and state tracking
  • Key structural changes needed:
    • Add TargetStateOwnerInfo inverted tracking map (maps TargetStatePath → owning component)
    • Restructure pre_commit into two phases:
      • Phase 1: Process inserts/updates; preempt ownership from other components via inverted tracking
      • Phase 2: Handle deletes/contained entries for remaining tracked entries
    • Rename DeclaredEffectDeclaredTargetState and effect_itemstarget_state_items
  • Performance: The inverted tracking adds memory overhead but eliminates unnecessary delete+insert round-trips; net positive for execution efficiency
  • Feature-gating: No new ops — applies to all target types, no new feature gate needed
  • API surface: The DeclaredTargetState rename may surface in the public API if these types are exported

Integration Notes

The rename DeclaredEffect → DeclaredTargetState is a breaking change to any internal API using that type. Check recoco's current naming conventions against upstream before adopting. The two-phase pre_commit restructure is the most complex part — requires careful review of execution.rs to ensure recoco's state management remains consistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    claudeCreated or actioned by Claude AIupstream-syncIssues for syncing updates with our upstream (cocoindex-io/cocoindex)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions