For a person or a model about to write an app; a model gets the same text from oad guide.

Contents

Changing an app#

An app is changed by editing its definition, in small steps that a person can review. People may already use it: their data stays, and what they agreed to is asked again only when it changed.

Small edits as patches#

Everything named in a definition lives in an object keyed by its name, so each thing has a stable JSON Pointer: /actions/drink, /state/goal, /surfaces/visual/views/home. An edit is a JSON Patch (RFC 6902): a list of operations, each with op (add, replace, remove, and also move, copy, test), a path and, for add and replace, a value. Adding to the end of a list uses - as the last segment of the path.

This patch gives the water app a button that starts the day's count again:

JSON

[
  { "op": "replace", "path": "/version", "value": "1.1.0" },
  { "op": "add", "path": "/actions/reset", "value": { "description": "Start today's count again from zero.", "confirm": true, "steps": [ { "set": "state.glasses", "to": 0 }, { "set": "state.countedOn", "to": "=env.today" } ] } },
  { "op": "add", "path": "/surfaces/visual/views/home/body/children/-", "value": { "control": "core:button", "props": { "label": "Start again", "emphasis": "low" }, "on": { "press": { "run": "reset" } } } }
]

Apply it with oad patch. The result is checked first; if it has errors, nothing is written. It prints, in plain words, what changed:

oad patch water.oad.json --patch edit.json --in-place

--dry-run checks and describes without writing; without --in-place or --out the patched definition is printed. oad diff describes the difference between two files, and with --patch prints it as a patch.

With the chat tools, a new app that fails its checks is kept unfinished under its name. Mend it with change_app, a small patch of the places the diagnostics name, never the whole definition again: each patch that applies is kept, and the app is made once the checks pass.

Changes that widen what the app may do#

Some changes need a person's yes before they are made: a new or wider permission, a new capability call or web address, a removed or loosened guard (allow, require, confirm), more given to agents, a value that is no longer sensitive. This patch makes the water app send a notification, so it needs one:

JSON

[
  { "op": "replace", "path": "/version", "value": "1.2.0" },
  { "op": "add", "path": "/capabilities", "value": { "notify": { "contract": "core:notify", "description": "Tells you when you reach the day's goal." } } },
  { "op": "add", "path": "/grants", "value": { "goalNotice": { "capability": "notify", "scopes": ["notify.self"], "reason": "Tell you once a day when you reach your goal.", "required": false } } },
  { "op": "add", "path": "/rules", "value": { "goalReached": { "description": "When today's count reaches the goal, say so.", "when": { "becomes": "state.goal > 0 && state.today >= state.goal" }, "do": [ { "call": "notify.send", "once": "=`goal:${user.person.id}:${env.today}`", "with": { "title": "Goal reached" }, "onError": [] } ] } } }
]

oad patch writes such a change only with --allow-wider, and otherwise exits with status 3 and lists what needs consent. Show the person that list and ask before you add the flag. Never add it on your own.

Keeping a history#

With --history, oad patch records each change in a file beside the definition (water.oad.history.json): the version, the time, who made it, the request in the requester's words, and the patch. --by says who made the change and --intent gives the request; a widening change also needs --approved-by with the person who agreed:

oad patch water.oad.json --patch edit.json --in-place --history --by agent:editor --intent "Add a button to start the day again"

oad undo water.oad.json --in-place takes back the last recorded change.

Before you change an app the person has used, call the tool read_use_report: it says which actions failed for them, with the host's code, and which permissions they declined.

Versions#

  • Raise version with every change. oad patch --history refuses a change that leaves it as it was.
  • Removing or renaming an action, an action's input field, a state entry an agent can read, or anything in exports breaks the people and agents that use it: raise the first number (2.0.0). Adding is a smaller change (1.1.0); fixing a description or a label, the last (1.0.1).
  • Never change id: a new id is a different app, which starts with no data.

What happens to people's data#

When the owner runs the new version, the host keeps the stored values. A state entry the new version adds starts at its initial. A stored value that no longer fits its entry's new type is replaced by the initial, so change a type with care, or add a new entry and leave the old one. A record of a collection flow in a stage the new version no longer has goes back to the flow's initial. A grant request that changed is asked again; one that did not keeps its answer.

Next#