Proposal: API Contract for Close Experiment with Mandatory Fields
| Field | Value |
|---|---|
| Type | Proposal |
| Status | Draft |
| Author | xRED Dev Team |
| Created | 2026-04-08 |
| Tracking | AAB-1919 , RETINA-7223345 |
1. Problem Statement
The DataRiver Facade endpoint POST /experiments/{eid}/close allows closing an
experiment without signing. However, closing fails due to two blockers:
Blocker 1: Mandatory template fields
The template used by AutoLab includes required fields that must be populated before an experiment can be closed:
- pRED Experiment Start & End Dates → Start Date
- pRED Experiment Start & End Dates → End Date
- pRED Experiment Purpose
The Facade supports closing but does not expose the property update endpoint
(PUT /entities/{eid}/properties) needed to populate these fields first.
The AutoLab AAB (signals_close_experiment) has no way to set them.
Blocker 2: Race condition with async metadata job
The signals-legal-metadata job (operated by ORCA/LEM) runs in the background every
15 seconds. It scans newly created experiments to check the Cost Center field — if
empty, it populates it with the appropriate value. This creates a race condition: the
experiment cannot be closed until this metadata update completes. If the close is
attempted before the job runs, it fails because Cost Center is still empty.
Current vs required flow
Current: AAB calls close → Signals rejects (mandatory fields missing) → failureRequired: Wait for metadata job → populate mandatory fields → close → success2. User Story
As a scientist using AutoLab to run automated workflows, I want to close my Signals experiment automatically when my workflow completes, so that the experiment is properly finalised with all required metadata without me having to manually go into Signals to fill in fields and click close.
Acceptance Criteria
- The integration can read the current experiment state (including which fields are mandatory and which are already populated)
- The integration can populate any missing mandatory fields with values provided by the workflow (or sensible defaults)
- The integration can close the experiment after all mandatory fields are satisfied
- If a mandatory field cannot be populated (no value available), the integration returns a clear error indicating which fields are missing (which)
- The experiment’s audit trail correctly attributes the field updates and close action to the authenticated user
3. Proposed Flow
Key Points
- The flow runs entirely at the AutoLab consumer (AAB), not through an xRED proxy
- Phase 1 uses the DataRiver Facade (
GET /experiments/{eid}/details) to read the experiment including its fields anddigest - Phase 2 handles the race condition with the
signals-legal-metadatajob — polls until Cost Center is populated (the job runs every ~15 seconds) - Phase 3 uses the LEM API Proxy (Route 2 in ADR-005) because the property update endpoint is not in the DataRiver Facade. Populates Start Date, End Date, and Experiment Purpose.
- Phase 4 uses the DataRiver Facade (
POST /experiments/{eid}/close) - The
digestfrom Phase 1/2 is passed to Phase 3 to handle concurrent editing (see the Signals REST API digest mechanism) (see the Signals REST API digest mechanism)
4. API Contract (OpenAPI)
4.1 Existing endpoints used
DataRiver Facade (Route 1):
| Method | Path | Purpose |
|---|---|---|
| GET | /experiments/{eid}/details | Read experiment with fields, relationships, digest |
| POST | /experiments/{eid}/close | Close experiment without signing |
LEM API Proxy (Route 2) — not in facade, requires LEM approval:
| Method | Path | Purpose |
|---|---|---|
| PUT | /entities/{eid}/properties?digest={digest} | Update experiment metadata fields |
4.2 Property update request format
The native Signals PUT /entities/{eid}/properties endpoint expects:
{
"data": [
{
"attributes": {
"name": "Description",
"value": "Automated experiment from AutoLab workflow XYZ"
}
},
{
"attributes": {
"name": "Group",
"value": "Research Team A"
}
}
]
}The digest is passed as a query parameter: ?digest=60367023
4.3 Close experiment request format
The DataRiver Facade POST /experiments/{eid}/close expects:
{
"data": {
"attributes": {
"reason": "Workflow completed successfully"
}
}
}The reason field can be an empty string.
4.4 Error responses
| Phase | Error | HTTP Code | Meaning |
|---|---|---|---|
| Read | Experiment not found | 404 | Invalid eid |
| Read | Unauthorized | 401 | Invalid/expired token |
| Update | Digest mismatch | 428 | Experiment modified since read |
| Update | Validation error | 400 | Invalid field name or value |
| Close | Mandatory fields missing | 400/403 | Fields still not populated |
| Close | Experiment already closed | 403 | Cannot close again |
5. Mandatory Fields
The pRED templates have mandatory fields at two different lifecycle stages. Both must be satisfied for the auto-close flow to succeed.
Fields required at experiment creation
Per the template analysis (AAB-1919 ), the pRED templates require these fields when creating the experiment:
| Field | Required at | Notes |
|---|---|---|
| Description | Creation | Set by create_experiment |
| Group | Creation | Set by create_experiment |
| Limited Access | Creation | Set by create_experiment |
| Limited Access Reason | Creation | Set by create_experiment |
| Portfolio Projects | Creation | Set by create_experiment |
These are handled by the AAB’s signals_create_experiment action. If the experiment
was created correctly, these should already be populated at close time.
Fields required before closing
These fields are not set at creation and must be populated before the experiment can be closed:
| Field | Required at | Source |
|---|---|---|
| pRED Experiment Start Date | Close | Must be set by the integration |
| pRED Experiment End Date | Close | Must be set by the integration |
| pRED Experiment Purpose | Close | Must be set by the integration |
Fields populated by background job (race condition)
| Field | Required at | Source |
|---|---|---|
| Cost Center | Close | Populated by signals-legal-metadata job (runs every ~15s) |
The Cost Center field is populated asynchronously by ORCA’s legal metadata injection job. The integration must either wait for the job to complete or check that the field is populated before attempting to close. If the close is attempted within the first ~15 seconds of experiment creation, it may fail.
Summary: what must be true before close
All of the following must be satisfied:
- Creation fields (Description, Group, etc.) — should already be set if created via SDK
- Start Date, End Date, Experiment Purpose — must be explicitly set by the integration
- Cost Center — must wait for async job to populate it
- Digest — must be current (no concurrent modifications since last read)
6. What Needs to Happen
| Action | Who | Dependency |
|---|---|---|
Confirm PUT /entities/{eid}/properties is accessible via LEM API Proxy | LEM team | LEM approval for Route 2 access |
| Document which fields are mandatory per template on DIA tenant | xRED Dev | Templates must exist on DIA tenant first |
| Implement the 3-phase flow (read → update → close) | xRED Dev / LabEx | LEM Proxy access granted |
| Propose adding property updates to the DataRiver Facade | DataRiver team | Long-term — removes Route 2 dependency |
Update AAB signals_close_experiment to call the new flow | LabEx | New service or SDK method available |
7. Enablement through Facade
Instead of using the LEM API Proxy for property updates, propose to DataRiver that they add either:
Option A: A new endpoint PUT /experiments/{eid}/properties to the
facade (wrapping the native endpoint).
Option B: An enhanced close endpoint that accepts field values in the request body and populates them before closing — a single atomic operation:
{
"data": {
"attributes": {
"reason": "Workflow completed",
"fields": {
"Description": "Automated experiment",
"Group": "Research Team A",
"Limited Access": false,
"Limited Access Reason": "",
"Portfolio Projects": "Project XYZ"
}
}
}
}Option B would be ideal as it avoids the digest race condition between update and close.