{% attribute id:'{{ attributeValue.AttributeId }}' %}
{% assign public = attribute.IsPublic %}
{% endattribute %}
The attribute entity command isn't guaranteed to return a value. If no value is returned public will not be reassigned. Lava doesn't support scoped variables so the previous value is retained.
I suspect that the entity command is ignoring these values because the are marked IsPublic:false. Adding securityenabled:'false' to the entity command bypasses this check and fixes the issue.
{% attribute id:'{{ attributeValue.AttributeId }}' securityenabled:'false' %}
{% assign public = attribute.IsPublic %}
{% endattribute %}