Skip to content

[upstream-sync] Fix component context plumbing for state/memo functions (upstream PR #1777) #135

@github-actions

Description

@github-actions

Upstream Change Summary

Type: bug-fix
Difficulty: Medium
Recommendation: Adopt

Upstream PR #1777 fixes a bug where use_context() calls inside __coco_memo_state__() (memoized state functions) didn't receive the correct component context. The fix plumbs the component context through to state functions so that context-dependent operations within memoized state work correctly.

The core Rust change is in rust/core/src/engine/component.rs — the PyO3 binding in rust/py/src/component.rs is irrelevant to recoco.

Upstream References

Relevant Upstream Files / Areas

  • rust/core/src/engine/component.rscrates/recoco-core/src/execution/ or equivalent component module
  • rust/py/src/component.rsskip (PyO3 bindings, not applicable)

Recoco Considerations

  • Affected modules: crates/recoco-core component execution / memoization logic
  • No Python to port: The Python binding changes (rust/py/src/component.rs) are irrelevant
  • Correctness impact: Without this fix, any recoco user relying on use_context() within state/memo functions gets silently wrong behavior — context is missing or stale
  • Feature-gating: No new feature gate needed; this is a core engine fix
  • API surface: Likely internal — component context threading is an implementation detail

Integration Notes

Review rust/core/src/engine/component.rs diff to understand exactly where context was not being threaded through. Recoco's equivalent component execution code should receive the same fix. The companion test PR (#1782) is Python-only but the test cases describe the scenarios to validate: direct function call with use_context() in a state function, and mount() component scenario with memoization skip behavior. Write equivalent Rust integration tests when adopting this fix.

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