Skip to content

satore: fix contract-violation crash in unification-tree-ref - #739

Open
PratikDhanave wants to merge 1 commit into
google-deepmind:masterfrom
PratikDhanaveFork:fix/satore-unification-tree-ref
Open

satore: fix contract-violation crash in unification-tree-ref#739
PratikDhanave wants to merge 1 commit into
google-deepmind:masterfrom
PratikDhanaveFork:fix/satore-unification-tree-ref

Conversation

@PratikDhanave

@PratikDhanave PratikDhanave commented Jul 25, 2026

Copy link
Copy Markdown

Summary

unification-tree-ref in satore/unification-tree.rkt crashes on any non-empty match due to a swapped map/append*.

trie-ref returns a list of node-values, and each node-value is itself a list of utree-leaf (see add-Clause!, which conses utree-leafs onto the node value). The buggy code mapped the utree-leaf-Clause struct accessor directly over that outer list:

(remove-duplicates (append* (map utree-leaf-Clause (trie-ref utree lit))) eq?)

so the accessor is handed an inner list rather than a utree-leaf, raising utree-leaf-Clause: contract violation, expected: utree-leaf?, given: '(#<utree-leaf>).

Both the function's own inline comment ("hence the append*") and the sibling unification-tree-Clauses ((map utree-leaf-Clause (append* ...))) show the intended order: flatten first, then map. Fix swaps the two:

(remove-duplicates (map utree-leaf-Clause (append* (trie-ref utree lit))) eq?)

The bug was latent because this exported function has no in-repo callers, so no test exercised it.

Testing

Verified by static tracing of trie-ref / make-proc-tree-ref and the utree-leaf node-value shape. Reviewers can validate via raco test satore/tests/.

@google-cla

google-cla Bot commented Jul 25, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@polarbe

polarbe commented Jul 25, 2026 via email

Copy link
Copy Markdown

@polarbe

polarbe commented Jul 25, 2026 via email

Copy link
Copy Markdown

`unification-tree-ref` mapped the `utree-leaf-Clause` accessor directly over
`(trie-ref utree lit)`, but `trie-ref` returns a list of node-values where each
node-value is itself a list of `utree-leaf`. Mapping the struct accessor over
those inner lists raises a contract violation on any non-empty match.

The inline comment ("hence the append*") and the sibling function
`unification-tree-Clauses` both show the intended order: flatten with `append*`
first, then map the accessor. Swap the two operations to match.

The bug was latent because the exported function currently has no in-repo
callers, so no test exercised it.
@PratikDhanave
PratikDhanave force-pushed the fix/satore-unification-tree-ref branch from 2080ecf to 04ef486 Compare July 25, 2026 04:45
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