Example 06

Manufacturing lot recall traceability

A recall must find every work order and finished good built from an affected lot.

Status
illustrative
Industry
Manufacturing
Language
C#
Framework
NUnit
CI
any
Fulfilment
BUILD_DATASET
Profile
manufacturing-traceability

About this example

All data is synthetic. DataNivra provisions approved test data into a customer-controlled target; it does not run these tests. Credentials for the target are never returned by DataNivra — your runner holds its own.

Why test data matters

A recall must find every work order and finished good built from an affected lot.

What is requested

manufacturing-traceability@1 with MFG_EVERYDAY_PRODUCTION × 200, MFG_LOT_RECALL × 50.

Policy gates

Within the profile maximums; synthetic-only.

What is provisioned

A certified synthetic dataset in the profile's approved target.

Expected output

AUTO_APPROVED for a developer; the test polls until READY.

Cleanup

The finally/teardown block calls POST /v1/test-data/requests/{id}/release.

Files

  • request.yaml
  • LotRecallTests.cs

Run

  1. A tenant administrator defines and a second person approves the profile (datanivra test-data define ../../profiles/manufacturing-traceability.yaml --submit, then datanivra policies approve).
  2. datanivra test-data validate request.yaml && datanivra test-data plan request.yaml
  3. Run the example with DATANIVRA_BASE_URL and a session or workload token.

Files

Exactly as they are in the examples repository. Every value is a synthetic placeholder; nothing here is a credential.

request.yaml

# yaml-language-server: $schema=../../../../packages/contracts/schemas/v1/manifests/test-data-request.schema.json
# DataNivra test-data-request manifest (apiVersion datanivra.io/v1alpha1). Validate: datanivra test-data validate <file>
apiVersion: datanivra.io/v1alpha1
kind: TestDataRequest
metadata:
  name: manufacturing-lot-recall
spec:
  profile: { name: manufacturing-traceability, version: 1 }
  scenarios:
    - { scenario_code: MFG_EVERYDAY_PRODUCTION, count: 200 }
    - { scenario_code: MFG_LOT_RECALL, count: 50 }

examples/test-data-api/scenarios/06-manufacturing-lot-recall/request.yaml

LotRecallTests.cs

// Manufacturing lot recall — NUnit with the REST API (no .NET SDK exists; HttpClient only).
// DataNivra provisions approved data; the test runs against your service with its own DB access.
using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
using NUnit.Framework;

public record TestDataRequest(string id, string state);

[TestFixture]
public class LotRecallTests
{
    static readonly HttpClient Http = new();
    static readonly string Api = Environment.GetEnvironmentVariable("DATANIVRA_BASE_URL") + "/v1/test-data/requests";
    string? requestId;

    [OneTimeSetUp]
    public async Task Acquire()
    {
        Http.DefaultRequestHeaders.Authorization =
            new("Bearer", Environment.GetEnvironmentVariable("DATANIVRA_TOKEN"));
        var body = new
        {
            profile = new { name = "manufacturing-traceability", version = 1 },
            scenarios = new[]
            {
                new { scenario_code = "MFG_EVERYDAY_PRODUCTION", count = 200 },
                new { scenario_code = "MFG_LOT_RECALL", count = 50 },
            },
        };
        var created = await (await Http.PostAsJsonAsync(Api, body)).Content.ReadFromJsonAsync<TestDataRequest>();
        requestId = created!.id;
        for (var i = 0; i < 120; i++)
        {
            var current = await Http.GetFromJsonAsync<TestDataRequest>(
quot;{Api}/{requestId}"); if (current!.state == "READY") return; await Task.Delay(TimeSpan.FromSeconds(5)); } Assert.Fail("test data not READY"); } [OneTimeTearDown] public async Task Release() { if (requestId is not null) await Http.PostAsJsonAsync(
quot;{Api}/{requestId}/release", new { reason_code = "TEST_RUN_FINISHED" }); } [Test] public void EveryAffectedWorkOrderIsFound() => Assert.That(requestId, Is.Not.Null); }

examples/test-data-api/scenarios/06-manufacturing-lot-recall/LotRecallTests.cs

The profile it uses: manufacturing-traceability

A tenant administrator defines this profile and a second person approves it; requests can only ask for what it allows. All profiles

manufacturing-traceability.yaml

# yaml-language-server: $schema=../../../packages/contracts/schemas/v1/manifests/test-data-profile.schema.json
# DataNivra test-data-profile manifest (apiVersion datanivra.io/v1alpha1). Validate: datanivra test-data validate <file>
# Placeholder ids (00000000-0000-4000-8000-0000000000NN): replace with your ids.
# 01 = approved target environment, 11 = certified dataset, 21 = customer agent,
# 99 = workload identity trust (datanivra workload-identities list).
apiVersion: datanivra.io/v1alpha1
kind: TestDataProfile
metadata:
  name: manufacturing-traceability
  description: Synthetic lots, work orders and quality records
spec:
  fulfilment: BUILD_DATASET
  build:
    business_domain: lots and work orders
    pack_id: manufacturing
    dataset_kind: SYNTHETIC_ONLY
    target_environment_id: 00000000-0000-4000-8000-000000000001
    retention_days: 1
    max_total_records: 1300
    scenarios:
      - {
          pack_id: manufacturing,
          scenario_code: MFG_EVERYDAY_PRODUCTION,
          kind: NORMAL,
          default_count: 300,
          max_count: 1000,
        }
      - {
          pack_id: manufacturing,
          scenario_code: MFG_LOT_RECALL,
          kind: RARE,
          default_count: 20,
          max_count: 100,
        }
      - {
          pack_id: manufacturing,
          scenario_code: MFG_TOLERANCE_LIMITS,
          kind: BOUNDARY,
          default_count: 50,
          max_count: 200,
          included_by_default: false,
        }

examples/test-data-api/profiles/manufacturing-traceability.yaml