REPOSITORY CODING · MEDIUM
An old custody screen overwrites a newer sample revision
A transfer succeeds with a stale revision after material was consumed. Restore optimistic concurrency so the operator must review the current sample first.
API Contract DebuggingLaboratory sample custody
Work through a real codebase.
Choose an environment, investigate the existing implementation and use the tests to check your change. Sign in to open a workspace; execution and Ono usage follow your plan’s allowances.
Task requirements and environments
Django · 50 minute session
- receive creates a sample with holder, positive integer quantity and expiresAt. It starts available at revision 1.
- transfer requires the current holder, available status, matching expectedRevision and now strictly before expiresAt. It changes holder and increments revision.
- consume requires the holder, available status and an unexpired sample. Positive amount cannot exceed quantity. It decrements quantity and increments revision.
- quarantine is holder-only and available-only. It increments revision and permanently blocks transfer and consumption.
- inspect returns a sample. available lists the actor’s available, unexpired samples with positive quantity, sorted by ID.
- Every command includes tenant and op. IDs belong to a tenant. Invalid commands return an error without stopping later commands.
- Mutations and their audit records commit together. failAudit rolls back all changes. Read operations do not increment revision.
- An optional request key makes retries idempotent per tenant. Reusing the key with different fields returns request-conflict.
- Use the authenticated workspace API for state across HTTP requests. /run is a disposable fixture. Time and failures are explicit inputs, so tests are repeatable.
Flask · 50 minute session
- receive creates a sample with holder, positive integer quantity and expiresAt. It starts available at revision 1.
- transfer requires the current holder, available status, matching expectedRevision and now strictly before expiresAt. It changes holder and increments revision.
- consume requires the holder, available status and an unexpired sample. Positive amount cannot exceed quantity. It decrements quantity and increments revision.
- quarantine is holder-only and available-only. It increments revision and permanently blocks transfer and consumption.
- inspect returns a sample. available lists the actor’s available, unexpired samples with positive quantity, sorted by ID.
- Every command includes tenant and op. IDs belong to a tenant. Invalid commands return an error without stopping later commands.
- Mutations and their audit records commit together. failAudit rolls back all changes. Read operations do not increment revision.
- An optional request key makes retries idempotent per tenant. Reusing the key with different fields returns request-conflict.
- Use the authenticated workspace API for state across HTTP requests. /run is a disposable fixture. Time and failures are explicit inputs, so tests are repeatable.
Python · 50 minute session
- receive creates a sample with holder, positive integer quantity and expiresAt. It starts available at revision 1.
- transfer requires the current holder, available status, matching expectedRevision and now strictly before expiresAt. It changes holder and increments revision.
- consume requires the holder, available status and an unexpired sample. Positive amount cannot exceed quantity. It decrements quantity and increments revision.
- quarantine is holder-only and available-only. It increments revision and permanently blocks transfer and consumption.
- inspect returns a sample. available lists the actor’s available, unexpired samples with positive quantity, sorted by ID.
- Every command includes tenant and op. IDs belong to a tenant. Invalid commands return an error without stopping later commands.
- Mutations and their audit records commit together. failAudit rolls back all changes. Read operations do not increment revision.
- An optional request key makes retries idempotent per tenant. Reusing the key with different fields returns request-conflict.
- Use the authenticated workspace API for state across HTTP requests. /run is a disposable fixture. Time and failures are explicit inputs, so tests are repeatable.