feat: support ao.unset sentinel for patch field removal#829
Merged
Conversation
When AOS processes use patch@1.0 to cache state, Lua nil removes keys from tables before serialization, making it impossible to express "remove this field" in a patch. This adds convert_unset_values/1 to dev_json_iface which converts the "__ao-unset__" sentinel string to the unset atom during JSON result deserialization. dev_message:set/3 already handles the unset atom by removing those keys.
Usage from Lua: `Send({device="patch@1.0", prices={cherry=ao.unset}})`
Requires ao.unset = "__ao-unset__" defined in ao.lua (AOS repo).
jfrain99
approved these changes
Apr 9, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
convert_unset_values/1todev_json_ifacethat recursively converts<<"__ao-unset__">>sentinel strings to theunsetatom during JSON result deserializationpreprocess_results(outbox messages) andjson_to_message(patches path)dev_message:set/3already handles theunsetatom by removing those keys -- no changes needed thereProblem
When AOS processes use
patch@1.0to cache state for frontend HTTP access, removing a field from a nested map is impossible. Luanildeletes the key from the table before serialization, so the patch system never learns the field should be removed. The deep merge indev_message:setpreserves old keys that are absent from the new patch.Solution
A sentinel value
"__ao-unset__"that survives Lua table serialization and JSON encoding. At the HB boundary (dev_json_iface), it is converted to theunsetatom thatdev_message:setalready handles.Requires a companion change in the AOS repo:
ao.unset = "__ao-unset__"inao.lua.Usage