--- id: STORE-4 family: GR-STORE level: core profiles: [storage-api] posture: normative-target added: "1.0" changed: "1.0" source: https://flowdrop.io/spec/rules/gr-store/store-4 specification: FlowDrop Workflow Specification 1.0 licence: CC BY 4.0 --- # STORE-4 — Absent collections default to empty, and an update touches only what it sends *GR-STORE (Part I) · level: core · profiles: storage-api · added in 1.0* An update is partial. What a caller does not send, it does not change, which is what lets an editor save one part of a workflow without holding the whole of it. ## The rule > **Normative.** This is the rule. > > 1. On create, `nodes` and `edges` MUST default to an empty array when absent, and `metadata` MUST default to empty. > > 2. A workflow that declares no `interface` declares no ports. > > 3. On update, a key the request omits MUST be left as stored. > > 4. A key the request sends as `null` MUST be cleared: the workflow MUST then read as if that key had been omitted on create. > > 5. `name` is the exception to both, and MUST be present and non-null on update as on create (STORE-2). > > 6. An `interface` present on update MUST replace the stored interface as a whole, so a side it omits, or sends as an empty array, MUST be stored with no ports. > > 7. The `metadata` published on read MAY differ from the `metadata` as stored. > > 8. An implementation MAY fold envelope fields such as `format` and `schemaVersion` into it on read. ## What it means An update is partial by default: a key the request does not send is left as stored, which is what lets a caller save one part of a workflow without holding the whole of it in hand. A key sent as `null` is the way to clear it: the workflow then reads as though the key had never been sent on create. That is the same reading JSON Merge Patch gives a partial update. `interface` is replaced as a whole rather than merged: sending it at all rewrites both the inputs and the outputs it describes, even if only one of them is included. A side left out of a present `interface` is not "left as stored", because what is stored is being replaced; it is a side the new interface does not declare, so it has no ports. The `metadata` a caller reads back is not necessarily the `metadata` it would get by reading the stored document directly: an implementation is free to fold housekeeping fields such as a format marker or a schema version into what it publishes on read, without those fields having been part of what was stored. ## Example Four requests to the same endpoint, each reading a different state of a key. ```http title="A create with no nodes, edges or metadata" verdict="201 stored" POST /api/flowdrop/workflows {"id": "bare_wf", "name": "Bare"} ``` ```http title="An update naming only the name and the nodes" verdict="200 preserved" PUT /api/flowdrop/workflows/{workflow} {"name": "Partial renamed", "nodes": [ … ]} ``` ```http title="An update whose interface is present but empty" verdict="200 cleared" PUT /api/flowdrop/workflows/{workflow} {"name": "Clear", "interface": []} ``` ```http title="An update sending metadata as null" verdict="200 cleared" PUT /api/flowdrop/workflows/{workflow} {"name": "Reset", "metadata": null} ``` The first leaves `nodes` and `edges` as empty arrays and `metadata` empty — nothing was sent for them, so there is nothing to default from but empty. The second leaves the edges and metadata a prior request had set untouched, because this request never mentions them. The third is the one that reads like the second but is not: `interface` was sent, so both its sides are rewritten, and an empty array on either side clears it rather than leaving it as it was. The fourth clears `metadata`: it reads back empty, as on a create that never sent it. ## Why Recorded under [OPEN-25](https://flowdrop.io/spec/rulings/open-25), [OPEN-26](https://flowdrop.io/spec/rulings/open-26). ## References **Further reading:** - RFC 7396, JSON Merge Patch (https://www.rfc-editor.org/rfc/rfc7396) — The same reading of a partial update: an absent member leaves the target alone, and a null member removes it. ## Fixtures Test cases whose outcome this rule decides (fixtures/README.md defines each operation): - An update sending an empty list stores the empty list (`update-workflow`): fixtures/presence/store-update-empty-replaces.json - An update keeps what it omits and clears what it sends as null (`update-workflow`): fixtures/presence/store-update-omitted-kept-null-cleared.json ## Related rules - Names: STORE-2, STORE-14 - Referenced by: STORE-14 --- Rule identifiers are permanent and are never renumbered. This specification carries no implementation status: each implementation publishes its own standing against these rules. Licensed CC BY 4.0.