Skip to content

Evaluate retained Single relations exactly once - #392

Open
yoohaemin wants to merge 3 commits into
masterfrom
fix/single-keep-coherence
Open

yoohaemin wants to merge 3 commits into
masterfrom
fix/single-keep-coherence

Conversation

@yoohaemin

Copy link
Copy Markdown
Owner

Single <>: placed the left relation in both branches of a zip, so an uncached effect could execute it twice and retain a different value from the one passed downstream. Compose the left relation once, then zip Self with the downstream relation, matching Optional and Many.

Tests in both interpreter models use a deferred counter to verify single and bulk coherence and repeated execution. Existing relation-shape tests retain their public output-type assertions without depending on the old duplicated AST.

Validation: core/test, core3/test, coreJS/test, coreJS3/test, fmt. All passed.

Copilot AI balanced review requested due to automatic review settings October 17, 2026 03:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new inner zip conflicts with interpreter proof bounds when the downstream relation accepts a strict supertype of the retained value.

1 open issue
What changed in this PR

Fixes retained Single composition so the left relation runs once and retains the value passed downstream.

Changes:

  • Composes the left relation before zipping Self with the downstream relation.
  • Adds coherence tests for both interpreter models.
  • Preserves public output-type assertions without fixing the internal composition shape.
File Description
core/​src/​test/​scala/​decrel/​RelationSpec.scala Removes old composition-shape assertions.
core/​src/​test/​scala/​decrel/​reify/​monofunctor/​KeepCoherenceSpec.scala Tests single, repeated, and bulk execution coherence.
core/​src/​test/​scala/​decrel/​reify/​bifunctor/​KeepCoherenceSpec.scala Adds equivalent bifunctor coherence tests.
core/​src/​main/​scala/​decrel/​syntax.scala Evaluates retained Single relations once.

Review effort: Balanced

Comment on lines +42 to 46
Relation.Self[LeftOut],
LeftOut,
LeftOut,
RightTree & Relation[RightIn, RightOut],
RightIn,

This branch has not been deployed

No deployments
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.

2 participants