Import gates run in a fixed order and roll back what they generated
Importing a bundle can create node types before it knows whether the workflow is acceptable. The fixed order, and the rollback, are what keep a refused import from leaving debris behind.
The rule
- A bundle import MUST apply its gates in this order: envelope format, publisher trust, capability manifest, node-type generation, workflow validation, flow-id shape, id collision.
- Any refusal after node-type generation MUST roll the generated node types back, so that a refused import leaves nothing behind.
- An unsupported envelope format MUST be refused with 422 and the code
UNSUPPORTED_BUNDLE_FORMAT. - An untrusted publisher MUST be refused with 403 and the code
UNTRUSTED_PUBLISHER, unless the caller both confirms the publisher and is permitted to do so. - A processor the installation does not have MUST be refused with 422 and the code
MISSING_PROCESSOR. - That refusal MUST be reported ahead of validation, so that a missing processor is actionable rather than surfacing as a structural error.
- A workflow that fails validation MUST be refused with 422, the code
VALIDATION_FAILEDanddetails. - An id that already exists MUST be refused with 409 and the code
WORKFLOW_ID_TAKEN, and the existing workflow MUST NOT be overwritten. - An absent flow id MUST be accepted, and one MUST be minted.
- A flow id that is present MUST match
^[a-z0-9_]+$, so an empty one is refused. - A flow id MUST be at most 64 characters.
- A flow id that breaks either MUST be refused with 422 and the code
INVALID_FLOW_ID. - Every refusal MUST carry at least one
detailsentry identifying the cause. - A flow-id refusal MUST locate itself at
flow.id. - Exposure entries are normalised before validation for every bundle, a trusted one included: an entry keeps only its
name,node_idandport, and only where those are scalar, cast to string; an entry that is not an object, or is wholly malformed, becomes empty but keeps its index, so validation reports it against its own position instead of shifting every later one. - What is stored MUST be the entry as submitted, so an author's additional entry metadata survives the import.
What it means
Generating node types happens before the workflow is known to be acceptable, because a bundle can only be validated once the processors it describes exist to validate against. That ordering choice is what forces the rest of the rule: anything the import creates ahead of validation — a node type, most of all — is rolled back the moment a later gate refuses, or a refused import would leave behind exactly the debris a caller has no way to see or undo.
The exposure-entry coercion runs even for a bundle whose publisher is trusted. Trust decides whether the bundle can be imported at all, not whether the entries inside it are safe to hand to the workflow validator: a malformed entry is normalised to an empty one that keeps its original position, so a validation error still names the entry it belongs to instead of shifting onto whichever entry happened to land at that index next. What is stored, though, is the entry as the bundle submitted it — the coercion protects the validator's reads, not what ends up on record.
A missing processor is reported ahead of workflow validation for the same reason node-type generation runs early: without the processor, the workflow would fail validation with a wall of structural errors that all trace back to one absent capability. Naming the capability first is what makes the refusal actionable.
Example
POST /api/flowdrop/workflows/import
{"format": "flowdrop.bundle/v1", "payload": {"flow": {"id": "imported_flow", "label": "Imported Flow", "nodes": [ … ], "edges": []}}}POST /api/flowdrop/workflows/import
{"format": "flowdrop.bundle/v1", "payload": {"publisher": "acme", "flow": {"id": "imported_flow", "label": "Imported Flow", "nodes": [{"id": "g.1", "data": {"metadata": {"node_type_id": "ghost", "executor_plugin": "ghost_module:ghost"}}}], "edges": []}}}POST /api/flowdrop/workflows/import
{"format": "flowdrop.bundle/v1", "payload": {"publisher": "acme", "flow": {"id": "imported_flow", "label": "Imported Flow", "nodes": [ … ], "edges": []}}}The 409 never overwrites: the workflow already on record under that id is untouched, and nothing from the rejected bundle — including any node type it would have generated — survives the refusal.