Give each preview result a scope
An import preview is not a standard guarantee shared by APIs. Define its checks explicitly and obtain the target’s documented error behaviour. This synthetic contract performs no write; a passed preview can become stale before commit.
| Check | Example | What passing proves |
|---|---|---|
| Field shape | quantity is an integer | Submitted representation is acceptable |
| Reference lookup | parent_id=P-5 exists at preview time | Parent existed at that observation |
| Write authority | Role can create this record now | Current permission check passed |
| Capacity at commit | No write/reservation made in preview | Nothing about later availability |
Recheck mutable conditions on commit
Save the preview input revision and check that the committed payload matches it. Revalidate relationships and authority where the target requires them. If the parent disappears or a limit changes, return an actionable row error rather than treating preview success as permission to override.
A parent is deleted after preview but before import. What test belongs in the contract?
Show the worked answer
Commit rejects or safely defers the dependent row under the documented relationship rule, with no orphan record. The preview result remains evidence of an earlier check only.