Production provenance

Provenance records how a representation was produced. PostProject stores the operation as an activity between its inputs and outputs:

        flowchart LR
    camera["camera original"] -- "input" --> transcode{{"transcode activity<br/>tool, agent, parameters"}}
    audio["external audio"] -- "input" --> transcode
    transcode -- "output" --> proxy["editing proxy"]
    

This keeps the operation itself available. A consumer can inspect the kind of work, optional input/output roles, timestamps, tool and version, responsible agent, and metadata parameters instead of seeing only an unexplained derived-from link.

Activity kinds and edge roles are namespaced strings. Applications and studios can add their own vocabulary without waiting for a closed PostProject enum. Unknown valid identifiers remain ordinary provenance data.

When an activity commits, storage captures the current representation fingerprints on every input and output edge. Those snapshots let callers evaluate artifact knowledge and reproducibility without reading media files.

Graph behavior

Activities support fan-in, fan-out, and processing across assets. An activity may have no inputs—for example, capture or generation—but a completed activity must have at least one output. The same representation cannot be both an input and output of one activity, and a new activity cannot introduce a generation cycle.

Ancestry and descendants are derived by traversing activities. PostProject does not infer that an output is a revision, variant, alternative, or proxy unless a consumer records that separate semantic fact.

Scope and trust

Activity provenance is portable production knowledge, not proof of authenticity and not a job-execution system. Parameters are typed metadata assertions on the activity. Cryptographic claims and verification remain the responsibility of a trust layer such as C2PA, and actually running a transcode or render remains the responsibility of the host application or workflow system.

See standards boundaries for the conceptual mapping to W3C PROV and MovieLabs OMC.

Across public surfaces

The example records one activity and queries the graph from its input and output sides:

static pp_error_code_t record_render(pp_production_t *production,
                                     const pp_representation_id_t *source_id,
                                     const pp_representation_id_t *render_id,
                                     pp_error_t **error) {
  const pp_activity_edge_t inputs[] = {{*source_id, "org.postproject:primary"}};
  const pp_activity_edge_t outputs[] = {{*render_id, NULL}};
  pp_transaction_t *transaction = NULL;
  pp_activity_set_t *producers = NULL;
  pp_object_ref_set_t *ancestors = NULL;
  pp_activity_id_t activity_id;

  pp_error_code_t status =
      pp_production_begin_edit(production, NULL, NULL, &transaction, error);
  if (status == PP_OK) {
    status = pp_transaction_create_activity(transaction,
        &(pp_activity_recipe_t){"org.postproject:render", inputs, 1, NULL, NULL, "Example Renderer", "2.1", "https://example.com/renderer", NULL, NULL, NULL, NULL, NULL, 0},
        outputs, 1, &activity_id, error);
  }
  if (status == PP_OK) {
    pp_commit_receipt_t commit_receipt;
    status = pp_transaction_commit(transaction, &commit_receipt, error);
  }
  if (status == PP_OK) {
    status = pp_production_activities_producing(production, *render_id,
                                                &producers, error);
  }
  if (status == PP_OK) {
    status = pp_production_provenance_ancestors(production, *render_id,
                                                &ancestors, error);
  }
  if (status == PP_OK) {
    printf("producers: %llu, ancestors: %llu\n",
           (unsigned long long)pp_activity_set_count(producers),
           (unsigned long long)pp_object_ref_set_count(ancestors));
  }

  pp_object_ref_set_release(ancestors);
  pp_activity_set_release(producers);
  pp_transaction_release(transaction);
  return status;
}
void record_render(postproject::Production &production,
                   const postproject::RepresentationId &source_id,
                   const postproject::RepresentationId &render_id) {
  postproject::ActivitySpec activity{};
  activity.kind = "org.postproject:render";
  activity.inputs = {std::make_pair(source_id, std::string("org.postproject:primary"))};
  activity.outputs = {render_id};
  activity.tool = postproject::ToolIdentity{
      "Example Renderer", "2.1", "https://example.com/renderer"};

  auto transaction = production.edit().value();
  const auto activity_id = transaction.createActivity(activity).value();
  transaction.commit().value();

  const auto producers = production.activitiesProducing(render_id).value();
  require(producers.size() == 1 && producers.front().id == activity_id,
          "producing activity");
  require(production.ancestors(render_id).value() == std::vector{source_id},
          "provenance ancestors");
  require(production.descendants(source_id).value() == std::vector{render_id},
          "provenance descendants");
}
def record_render(
    production: Production,
    source_id: RepresentationId,
    render_id: RepresentationId,
) -> None:
    with production.edit() as transaction:
        activity_id = transaction.create_activity(
            ActivitySpec(
                "org.postproject:render",
                inputs=((source_id, "org.postproject:primary"),),
                outputs=(render_id,),
                tool=ToolIdentity(
                    "Example Renderer", "2.1", "https://example.com/renderer"
                ),
            )
        )
        transaction.commit()

    (producer,) = production.activities_producing[render_id]
    assert producer.id == activity_id
    assert production.activities_consuming[source_id] == (producer,)
    assert production.provenance_ancestors[render_id] == (source_id,)
    assert production.provenance_descendants[source_id] == (render_id,)
fn record_render(
    production: &mut SqliteProduction,
    source_id: RepresentationId,
    render_id: RepresentationId,
) -> Result<()> {
    let activity = Activity::new(
        ActivityId::new(),
        ActivityKind::new("org.postproject:render")?,
        vec![ActivityInput::new(
            source_id,
            Some(ActivityRole::new("org.postproject:primary")?),
        )],
        vec![ActivityOutput::new(render_id, None)],
    )?
    .with_tool(ToolIdentity::new(
        "Example Renderer",
        Some("2.1".to_owned()),
        Some("https://example.com/renderer".to_owned()),
    )?);
    {
        let mut transaction = production.begin_transaction()?;
        transaction.create_activity(&activity)?;
        transaction.commit()?;
    }

    let consuming = production.activities_consuming(source_id)?;
    let producing = production.activities_producing(render_id)?;
    assert_eq!(consuming[0].id(), activity.id());
    assert_eq!(producing[0].id(), activity.id());
    assert!(producing[0].inputs()[0].snapshot().is_some());
    assert_eq!(production.ancestors(render_id)?, vec![source_id]);
    assert_eq!(production.descendants(source_id)?, vec![render_id]);
    Ok(())
}
postproject activity add production.pproj org.postproject:render \
  --input "$ORIGINAL_ID=org.postproject:primary" \
  --output "$SEQUENCE_ID" \
  --tool-name "Example Renderer" --tool-version 2.1 \
  --tool-uri https://example.com/renderer
postproject activity producing production.pproj "$SEQUENCE_ID"
postproject activity ancestors production.pproj "$SEQUENCE_ID"

Storage snapshots each input’s and output’s fingerprints when the activity is recorded; reading an activity returns those snapshots with its tool and agent attribution:

static pp_error_code_t print_edge_snapshot(const pp_activity_set_t *set,
                                           uint64_t a, uint64_t e, int input,
                                           pp_error_t **error) {
  uint8_t has_snapshot = 0;
  uint64_t revision = 0;
  uint64_t count = 0;
  /* Snapshots are captured at commit; a migrated edge may have none. */
  pp_error_code_t status =
      input ? pp_activity_set_get_input_snapshot(set, a, e, &has_snapshot,
                                                 &revision, &count, error)
            : pp_activity_set_get_output_snapshot(set, a, e, &has_snapshot,
                                                  &revision, &count, error);
  if (status == PP_OK && has_snapshot) {
    printf("    snapshot at revision %llu\n", (unsigned long long)revision);
  }
  for (uint64_t f = 0; status == PP_OK && has_snapshot && f < count; ++f) {
    const char *algorithm;
    uint16_t version = 0;
    const uint8_t *value;
    uint64_t length = 0;
    uint8_t has_observed = 0;
    uint64_t observed = 0;
    status = input ? pp_activity_set_get_input_snapshot_fingerprint(
                         set, a, e, f, &algorithm, &version, &value, &length,
                         &has_observed, &observed, error)
                   : pp_activity_set_get_output_snapshot_fingerprint(
                         set, a, e, f, &algorithm, &version, &value, &length,
                         &has_observed, &observed, error);
    if (status == PP_OK) {
      printf("      %s v%u (%llu bytes)\n", algorithm, version,
             (unsigned long long)length);
    }
  }
  return status;
}

static pp_error_code_t print_activity(const pp_activity_set_t *set, uint64_t a,
                                      pp_error_t **error) {
  pp_activity_id_t id;
  const char *kind;
  uint8_t has_started = 0, has_finished = 0;
  int64_t started = 0, finished = 0;
  uint64_t input_count = 0, output_count = 0;
  const char *tool = NULL, *tool_version = NULL, *tool_uri = NULL;
  const char *agent = NULL, *agent_scheme = NULL, *agent_value = NULL;
  const char *agent_qualifier = NULL;
  pp_error_code_t status = pp_activity_set_get(
      set, a, &id, &kind, &has_started, &started, &has_finished, &finished,
      &input_count, &output_count, error);
  if (status == PP_OK) {
    status = pp_activity_set_get_tool(set, a, &tool, &tool_version, &tool_uri,
                                      error);
  }
  if (status == PP_OK) {
    status = pp_activity_set_get_agent(set, a, &agent, &agent_scheme,
                                       &agent_value, &agent_qualifier, error);
  }
  if (status == PP_OK) {
    printf("%s by %s %s, run by %s (%s:%s)\n", kind, tool != NULL ? tool : "-",
           tool_version != NULL ? tool_version : "",
           agent != NULL ? agent : "-",
           agent_scheme != NULL ? agent_scheme : "",
           agent_value != NULL ? agent_value : "");
  }
  for (uint64_t e = 0; status == PP_OK && e < input_count; ++e) {
    pp_representation_id_t representation_id;
    const char *role;
    status =
        pp_activity_set_get_input(set, a, e, &representation_id, &role, error);
    if (status == PP_OK) {
      printf("  input role %s\n", role != NULL ? role : "-");
      status = print_edge_snapshot(set, a, e, 1, error);
    }
  }
  for (uint64_t e = 0; status == PP_OK && e < output_count; ++e) {
    pp_representation_id_t representation_id;
    const char *role;
    status =
        pp_activity_set_get_output(set, a, e, &representation_id, &role, error);
    if (status == PP_OK) {
      printf("  output role %s\n", role != NULL ? role : "-");
      status = print_edge_snapshot(set, a, e, 0, error);
    }
  }
  return status;
}

static pp_error_code_t record_transcode(pp_production_t *production,
                                        const pp_representation_id_t *original_id,
                                        const pp_representation_id_t *proxy_id,
                                        uint64_t counts[4],
                                        pp_error_t **error) {
  const pp_activity_edge_t inputs[] = {
      {*original_id, "org.postproject:input.primary-video"}};
  const pp_activity_edge_t outputs[] = {
      {*proxy_id, "org.postproject:output.proxy"}};
  const int64_t started = INT64_C(1767225600000000);
  const int64_t finished = INT64_C(1767225660000000);
  pp_transaction_t *transaction = NULL;
  pp_activity_set_t *activities = NULL;
  pp_activity_set_t *consuming = NULL;
  pp_object_ref_set_t *descendants = NULL;
  pp_object_query_set_t *descendant_page = NULL;
  pp_activity_id_t activity_id = {0};

  pp_error_code_t status =
      pp_production_begin_edit(production, NULL, NULL, &transaction, error);
  if (status == PP_OK) {
    /* Tool and agent identity are independent, optional attributions. */
    status = pp_transaction_create_activity(transaction,
        &(pp_activity_recipe_t){"org.postproject:transcode", inputs, 1, &started, &finished, "Example Transcoder", "3.2", "https://example.com/transcoder", "Assistant editor", "com.example.staff", "ae-17", NULL, NULL, 0},
        outputs, 1, &activity_id, error);
  }
  if (status == PP_OK) {
    char *saved = NULL;
    pp_activity_id_t parsed = {0};
    pp_object_ref_t target;
    status = pp_activity_id_format(activity_id, &saved, error);
    if (status == PP_OK) status = pp_activity_id_parse(saved, &parsed, error);
    pp_string_release(saved);
    if (status == PP_OK) status = pp_object_ref_from_activity(parsed, &target, error);
    if (status == PP_OK) status = pp_object_ref_get_activity(&target, &parsed, error);
    if (status == PP_OK && memcmp(parsed.bytes, activity_id.bytes, 16))
      status = PP_ERROR_INTERNAL;
  }
  if (status == PP_OK) {
    char *saved = NULL;
    pp_representation_id_t parsed = {0};
    pp_object_ref_t target;
    status = pp_representation_id_format(*original_id, &saved, error);
    if (status == PP_OK) status = pp_representation_id_parse(saved, &parsed, error);
    pp_string_release(saved);
    if (status == PP_OK) status = pp_object_ref_from_representation(parsed, &target, error);
    if (status == PP_OK) status = pp_object_ref_get_representation(&target, &parsed, error);
    if (status == PP_OK && memcmp(parsed.bytes, original_id->bytes, 16))
      status = PP_ERROR_INTERNAL;
  }
  if (status == PP_OK) {
    pp_commit_receipt_t commit_receipt;
    status = pp_transaction_commit(transaction, &commit_receipt, error);
  }
  if (status == PP_OK) {
    status = pp_production_activities(production, &activities, error);
  }
  for (uint64_t a = 0; status == PP_OK && a < pp_activity_set_count(activities);
       ++a) {
    status = print_activity(activities, a, error);
  }
  if (status == PP_OK) {
    status = pp_production_activities_consuming(production, *original_id,
                                                &consuming, error);
  }
  if (status == PP_OK) {
    status = pp_production_provenance_descendants(production, *original_id,
                                                  &descendants, error);
  }
  if (status == PP_OK) {
    /* The page form bounds depth and visited representations. */
    status = pp_production_provenance_descendants_page(
        production, *original_id, UINT32_C(8), UINT32_C(1000), UINT32_C(100),
        NULL, &descendant_page, error);
  }
  for (uint64_t i = 0;
       status == PP_OK && i < pp_object_query_set_count(descendant_page); ++i) {
    pp_object_ref_t descendant;
    uint32_t depth = 0;
    status =
        pp_object_query_set_get(descendant_page, i, &descendant, &depth, error);
    if (status == PP_OK) {
      printf("descendant at depth %u%s\n", depth,
             pp_object_query_set_next_cursor(descendant_page) != NULL
                 ? " (more pages follow)"
                 : "");
    }
  }
  if (status == PP_OK) {
    counts[0] = pp_activity_set_count(activities);
    counts[1] = pp_activity_set_count(consuming);
    counts[2] = pp_object_ref_set_count(descendants);
    counts[3] = pp_object_query_set_count(descendant_page);
  }

  pp_object_query_set_release(descendant_page);
  pp_object_ref_set_release(descendants);
  pp_activity_set_release(consuming);
  pp_activity_set_release(activities);
  pp_transaction_release(transaction);
  return status;
}

static pp_error_code_t
count_consumers_by_page(const pp_production_t *production,
                        const pp_representation_id_t *original_id, uint64_t *out_count,
                        pp_error_t **error) {
  char cursor_storage[2049] = {0};
  const char *cursor = NULL;
  pp_error_code_t status = PP_OK;
  *out_count = 0;
  while (status == PP_OK) {
    pp_activity_set_t *page = NULL;
    status = pp_production_activities_consuming_page(
        production, *original_id, UINT32_C(1), cursor, &page, error);
    *out_count += status == PP_OK ? pp_activity_set_count(page) : 0;
    /* The cursor borrows the page; copy it before releasing the page. */
    const char *next =
        status == PP_OK ? pp_activity_set_next_cursor(page) : NULL;
    const int copied =
        next != NULL
            ? snprintf(cursor_storage, sizeof cursor_storage, "%s", next)
            : 0;
    pp_activity_set_release(page);
    if (status != PP_OK || copied == 0) {
      break;
    }
    if (copied < 0 || (size_t)copied >= sizeof cursor_storage) {
      status = PP_ERROR_INTERNAL;
    }
    cursor = cursor_storage;
  }
  return status;
}
postproject::ActivityId record_transcode(postproject::Production &production,
                                   const postproject::RepresentationId &original_id,
                                   const postproject::RepresentationId &proxy_id) {
  postproject::ActivitySpec spec{};
  spec.kind = "org.postproject:transcode";
  spec.started_at_unix_micros = 1'700'000'000'000'000;
  spec.finished_at_unix_micros = 1'700'000'060'000'000;
  spec.inputs = {std::make_pair(original_id, std::string("org.postproject:essence"))};
  spec.outputs = {proxy_id};
  spec.tool = postproject::ToolIdentity{"Example Encoder", "5.1", std::nullopt};
  spec.agent = postproject::AgentIdentity{
      "render-node-04", postproject::ExternalIdentifier{"com.example.farm.node",
                                                        "04", std::nullopt}};

  auto transaction = production.edit().value();
  const auto activity_id = transaction.createActivity(spec).value();
  require(postproject::ActivityId::fromString(activity_id.toString().value()).value()
              == activity_id, "saved activity identity");
  require(postproject::ObjectRef::activity(activity_id).activityId().value()
              == activity_id, "typed activity target");
  transaction.commit().value();

  // Every edge carries the fingerprints its representation had at creation.
  for (const auto &activity : production.activities().value()) {
    std::cout << activity.kind << " by "
              << (activity.tool ? activity.tool->name : "unknown tool")
              << " on "
              << (activity.agent ? activity.agent->name.value_or("?") : "?")
              << '\n';
    for (const auto &input : activity.inputs) {
      print_snapshot("input", input.snapshot);
    }
    for (const auto &output : activity.outputs) {
      print_snapshot("output", output.snapshot);
    }
  }

  const auto consumers = production.activitiesConsuming(original_id).value();
  std::cout << "activities reading the original: " << consumers.size() << '\n';
  // Whole-set traversal, then the bounded paged form of the same query.
  const auto derived = production.descendants(original_id).value();
  const auto page = production.descendants(original_id, 8, 1000, 100).value();
  std::cout << derived.size() << " descendant(s), first page "
            << page.items.size() << '\n';
  return activity_id;
}
def record_proxy_generation(
    production: Production,
    original_id: RepresentationId,
    proxy_id: RepresentationId,
) -> ActivityId:
    with production.edit() as transaction:
        activity_id = transaction.create_activity(
            ActivitySpec(
                "org.postproject:transcode",
                inputs=((original_id, "org.postproject:primary"),),
                outputs=((proxy_id, "org.postproject:proxy"),),
                tool=ToolIdentity("Example Transcoder", "3.2"),
                agent=AgentIdentity(
                    "Render node 4", ExternalIdentifier("com.example.host", "node-4")
                ),
            )
        )
        transaction.commit()
    return activity_id


def print_fingerprint_snapshots(edge: ActivityEdge) -> None:
    # Commit captured the fingerprints each edge representation had then.
    if edge.snapshot is None:
        return
    for fingerprint in edge.snapshot.fingerprints:
        print(
            f"  {edge.representation_id} {fingerprint.algorithm}: "
            f"{fingerprint.value.hex()[:16]}..."
        )


def print_activities(production: Production) -> tuple[Activity, ...]:
    activities = production.activities
    for activity in activities:
        tool = activity.tool.name if activity.tool else "-"
        agent = activity.agent.name if activity.agent else "-"
        print(f"{activity.kind} by {tool} on {agent}")
        for edge in activity.inputs + activity.outputs:
            print(f" {edge.role or '-'}")
            print_fingerprint_snapshots(edge)
    return activities


def print_lineage(production: Production, original_id: RepresentationId) -> None:
    for activity in production.activities_consuming[original_id]:
        print(f"consumed by {activity.id}")
    for descendant_id in production.provenance_descendants[original_id]:
        print(f"descendant {descendant_id}")

    cursor = None
    while True:
        page = production.provenance_descendants_page(
            original_id, max_depth=8, max_representations=1000, limit=100, cursor=cursor
        )
        for match in page.items:
            print(f"descendant {match.representation_id} at depth {match.depth}")
        cursor = page.next_cursor
        if cursor is None:
            break
fn record_proxy_generation(
    production: &mut SqliteProduction,
    original_id: RepresentationId,
    proxy_id: RepresentationId,
) -> Result<ActivityId> {
    let activity = Activity::new(
        ActivityId::new(),
        ActivityKind::new("org.postproject:generate-proxy")?,
        vec![ActivityInput::new(
            original_id,
            Some(ActivityRole::new("org.postproject:primary")?),
        )],
        vec![ActivityOutput::new(proxy_id, None)],
    )?
    .with_tool(ToolIdentity::new(
        "Example Encoder",
        Some("3.2".to_owned()),
        None,
    )?)
    .with_agent(AgentIdentity::new(
        Some("Render node 4".to_owned()),
        Some(ExternalIdentifier::new(
            IdentifierScheme::new("com.example.render-node")?,
            "node-4",
            None,
        )?),
    )?);
    {
        let mut transaction = production.begin_transaction()?;
        // Storage captures the current input and output fingerprints on each edge.
        transaction.create_activity(&activity)?;
        transaction.commit()?;
    }

    for recorded in production.activities()? {
        println!("activity {} ({})", recorded.id(), recorded.kind().as_str());
        if let Some(tool) = recorded.tool() {
            println!("  tool: {} {:?}", tool.name(), tool.version());
        }
        if let Some(agent) = recorded.agent() {
            println!("  agent: {:?}", agent.name());
        }
        for input in recorded.inputs() {
            println!(
                "  input {} as {:?}",
                input.representation_id(),
                input.role()
            );
            for fingerprint in input
                .snapshot()
                .map_or(&[][..], |snapshot| snapshot.fingerprints())
            {
                println!("    {} v{}", fingerprint.algorithm(), fingerprint.version());
            }
        }
        for output in recorded.outputs() {
            let snapshot = output.snapshot().expect("storage records output snapshots");
            println!(
                "  output {} at revision {}",
                output.representation_id(),
                snapshot.revision_sequence()
            );
        }
    }

    let consuming = production.activities_consuming(original_id)?;
    println!("activities consuming the original: {}", consuming.len());

    let descendants = production.descendants(original_id)?;
    let page = production.descendants_page(
        original_id,
        ProvenanceQueryLimits::new(8, 1_000)?,
        &QueryPageRequest::new(100, None)?,
    )?;
    for item in page.items() {
        println!(
            "descendant {} at depth {}",
            item.representation_id(),
            item.depth()
        );
    }
    assert_eq!(descendants.len(), page.items().len());
    Ok(activity.id())
}
postproject activity add provenance.pproj org.postproject:transcode \
  --input "$ORIGINAL_ID=org.postproject:source" --output "$PROXY_ID" \
  --tool-name ffmpeg --tool-version 7.1 --tool-uri https://ffmpeg.org \
  --agent-name "Proxy farm" \
  --agent-identifier-scheme com.example.host --agent-identifier-value render-07
# Each edge keeps a snapshot of the fingerprints current when it was recorded.
postproject --json activity list provenance.pproj |
  jq '.[] | {kind, tool, agent,
    inputs: [.inputs[] | {representation_id, role, fingerprints: .snapshot.fingerprints}],
    outputs: [.outputs[] | {representation_id, fingerprints: .snapshot.fingerprints}]}'
postproject activity consuming provenance.pproj "$ORIGINAL_ID"
# Descendant queries are paged; follow next_cursor until it is null.
CURSOR=
while :; do
  ARGS=(--json activity descendants provenance.pproj "$ORIGINAL_ID" --limit 1)
  [[ -n "$CURSOR" ]] && ARGS+=(--cursor "$CURSOR")
  PAGE=$(postproject "${ARGS[@]}")
  jq -r '.items[] | "\(.representation_id) depth \(.depth)"' <<<"$PAGE"
  CURSOR=$(jq -r '.next_cursor // empty' <<<"$PAGE")
  [[ -z "$CURSOR" ]] && break
done