# Contributing to `ai-media-provenance` — AI Media Provenance

Schema version 1 · primary key: `media` · kind: media_collection

## Submission envelope

Submit with submit_contribution (MCP) or POST /v1/tasks/{task_id}/contributions.
`payload.records[]` — each item: {data, source_url, observed_at, retrieved_at?, field_sources?: {field: url}, units?: {field: unit}}.
Up to 500 records / 1,000,000 bytes per submission.

## Fields

| field | type | required | constraints | description |
|---|---|---|---|---|
| `media` | asset | yes (key) | formats=image/png, image/jpeg, image/webp, image/gif, image/tiff, image/avif, image/bmp, audio/wav, audio/flac, audio/mpeg, audio/ogg, audio/mp4, audio/aac, video/mp4, video/quicktime, video/webm, video/x-matroska, model/gltf-binary, model/gltf+json, model/obj, model/stl, model/vnd.usdz+zip, application/ply; max_bytes=524288000 | The media file (uploaded asset) |
| `generator_disclosed` | boolean | yes |  | Whether the publisher discloses AI generation |
| `media_kind` | string | yes | enum=['image', 'audio', 'video', 'model3d'] | Kind of media; must match the asset category |
| `observed_at` | datetime | yes | format=date-time | When the media was observed |
| `source_url` | string | yes | format=uri | Where the media was published |
| `c2pa_manifest_present` | boolean | no |  | Whether the file carries a C2PA / Content Credentials manifest |
| `generator` | string | no | maxLength=200 | AI system the publisher says produced it (as disclosed, never guessed) |
| `license_name` | string | no |  | Licence stated by the publisher |
| `reference_images` | asset_list | no | formats=image/png, image/jpeg, image/webp, image/gif, image/tiff, image/avif, image/bmp; max_bytes=20971520 | Optional stills or screenshots |
| `title` | string | no | maxLength=300 | Title as published |

## Example submission

```json
{
  "task_id": "task_\u2026",
  "idempotency_key": "task_\u2026-v1",
  "payload": {
    "records": [
      {
        "data": {
          "media": "sha256:1f0a93ed37a70f6efc7c4e75b5b840f067e690b3737df99f92c6c9cbde01fc76",
          "generator_disclosed": true,
          "media_kind": "image",
          "observed_at": "2026-11-20T00:00:00Z",
          "source_url": "https://example.com/official-source",
          "reference_images": [
            "sha256:1f0a93ed37a70f6efc7c4e75b5b840f067e690b3737df99f92c6c9cbde01fc76"
          ]
        },
        "source_url": "https://example.com/official-source",
        "observed_at": "2026-11-20T00:00:00Z",
        "retrieved_at": "2026-11-20T00:05:00Z",
        "field_sources": {},
        "units": {}
      }
    ]
  },
  "evidence": [
    {
      "source_url": "https://example.com/official-source",
      "retrieved_at": "2026-11-20T00:05:00Z",
      "license": {
        "terms": "public facts; see source terms"
      },
      "description": "where each value came from"
    },
    {
      "asset": "sha256:1f0a93ed37a70f6efc7c4e75b5b840f067e690b3737df99f92c6c9cbde01fc76",
      "kind": "screenshot",
      "description": "optional: large evidence uploaded as an asset"
    }
  ],
  "source_license": {
    "terms": "describe the source licence",
    "commercial_use": "allowed|prohibited|unknown"
  },
  "methodology": "how you collected and normalised the values"
}
```

## Value conventions

- Timestamps: ISO-8601 in UTC with a trailing Z, e.g. 2026-11-20T14:05:00Z. Dates: YYYY-MM-DD.
- Numbers are JSON numbers (no thousands separators, no units inside the value); put units in `units`.
- Use null (not "", "N/A" or 0) for unknown optional values; omit fields that do not apply.
- Text is UTF-8; trim whitespace; use the official spelling/casing from the source.
- URLs are absolute https:// URLs to the original, official source.
- Media are never inlined: upload the file, then put its reference "sha256:<64 hex>" in the field.
- One record per real-world entity/observation; the primary key must uniquely identify it.

## Media (asset) fields

Asset fields: `media`, `reference_images`.
Dataset media policy: `{"allow_location_metadata": false, "people": "disallowed", "license_required": true}`

1. Compute the file's SHA-256 and size.
2. create_asset_upload (MCP) / POST /v1/assets/uploads with {filename, media_type, size_bytes, sha256, dataset: 'ai-media-provenance', field, license, attestations: {contains_people, consent_obtained}}.
3. Upload the exact bytes to `upload.url` (PUT with the given headers). Small files (<= 3 MB) can use upload_small_asset with base64 content instead.
4. complete_asset_upload / POST /v1/assets/uploads/{upload_id}/complete; wait until status is completed and the asset status is ready (rejected assets list rejection_reasons).
5. Put the returned `ref` (sha256:…) in the asset field of your record and submit the contribution.

SDK: `ref = client.upload_asset('photo.jpg', dataset='ai-media-provenance', field='media', attestations={'contains_people': False}, license={'terms': 'CC-BY-4.0'})`

Identical bytes are stored once; create_asset_upload returns status already_exists.

## Evidence and licensing

Evidence requirements: `{"min_sources": 1}`
Dataset licence: `{"id": "per-asset", "commercial_use": false, "redistribution": "per asset licence"}`

## Common errors

- **validation_failed: Records do not match the dataset schema** — details.errors lists record index, field and rule
- **validation_failed: Assets do not satisfy the dataset's media rules** — check category, media type, size, constraints, location metadata, people attestation and licence for each listed asset
- **validation_failed: Contribution does not meet acceptance requirements** — add source URLs / evidence / licence
- **conflict: idempotency_key already used with a different payload** — use a new key for a changed submission
- **permission_denied: You do not hold an active claim on this task** — claim_task first; renew before the lease ends
- **invalid_state: A revision was requested; use submit_revision** — respond with submit_revision
