# Projection: from `cdop.*` tables to CDOP documents

The database is normalised: one table per concept, one row per status change, no parallel arrays, real geometry. CDOP documents are denormalised views of that data. `apps/api/src/domain/projection/cdop.ts` loads a `ProjectAggregate` (batched per-table queries) and produces the Full List document and each per-pod slice with pure functions. Ajv validates every document at seed time and in CI.

This page lists which table feeds which section, the current schema adaptations, and the value projections. Field ids are the schema's `x-cdop-field-id` values.

## Pods and their sections

| Pod (`/v2/projects/{id}/cdop/{pod}`) | Schema file                            | Top-level sections                                                                                                                                                          |
| ------------------------------------ | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `full-list`                          | `Full_List.schema.json`                | agreement, cobenefits, crediting_program, estimations, facility, geolocation_file, issuance, methodology, project, project_stakeholder, registry, unit, validation, vintage |
| `location-details`                   | `Location_Details.schema.json`         | facility, geolocation_file, project, project_stakeholder                                                                                                                    |
| `project-approach-details`           | `Project_Approach_Details.schema.json` | crediting_program, methodology, project, project_stakeholder, registry, validation                                                                                          |
| `disclosures`                        | `Disclosures.schema.json`              | project, project_stakeholder, registry                                                                                                                                      |
| `issuances`                          | `Issuances.schema.json`                | issuance, project                                                                                                                                                           |
| `unit-description` (per unit)        | `Unit_Description.schema.json`         | project, unit, vintage                                                                                                                                                      |
| `crediting-period`                   | `Crediting_Period.schema.json`         | project, validation                                                                                                                                                         |
| `estimations`                        | `Estimations.schema.json`              | estimations, project, validation                                                                                                                                            |
| `co-benefits`                        | `Co_Benefits.schema.json`              | cobenefits                                                                                                                                                                  |
| `durability-permanence`              | `Durability_Permanence.schema.json`    | project                                                                                                                                                                     |
| `project-finance`                    | `Project_Finance.schema.json`          | agreement, project, project_stakeholder, unit                                                                                                                               |
| `labels-certifications`              | `Labels_Certifications.schema.json`    | crediting_program, project, unit                                                                                                                                            |

Each pod document is the subset of the Full List projection that its schema names. A section appears only when there is data for it (see "Absent sections" below).

## Mapping table

| Source table                                                                                                  | CDOP path                                                                                                                                                                                                                                                                                                                                                                                                                                                  | Notes                                                                                                                                                                                                         |
| ------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `project`                                                                                                     | `project.project_name`, `project_description`, `project_id`, `project_id_type`, `project_identifier`, `current_registry_project_id`, `current_registry_project_link`, `project_design_document_link`, `program_type`, `activity_type`, `project_list_date`, `project_registration_date`, `estimated_total_years`, `project_governance_structure`, `community_frameworks`, `public_comment`, `public_comment_summary`, `previous_project_crediting_program` | `project_identifier` is the URN. `project_id` mirrors the native id with `project_id_type` = `current registry project id`. `listed_on` → `project_list_date`, `registered_on` → `project_registration_date`. |
| `project.attestations` (jsonb)                                                                                | `project.attestations[]`, `project.*_attestation`, `project.*_documentation`                                                                                                                                                                                                                                                                                                                                                                               | One bag in the database, several booleans and links in the document.                                                                                                                                          |
| `project.project_risk` (jsonb)                                                                                | `project.project_risk`                                                                                                                                                                                                                                                                                                                                                                                                                                     | Encoded as a JSON string in documents (`CDOP-FB-024`); an object in HAL.                                                                                                                                      |
| `project.native_attributes` (jsonb)                                                                           | none                                                                                                                                                                                                                                                                                                                                                                                                                                                       | WCC `auxiliaries` and Peatland Code `additionalInfoFieldList` are API-only.                                                                                                                                   |
| `project_location` (kind `project`)                                                                           | `project.location[]`                                                                                                                                                                                                                                                                                                                                                                                                                                       | Country, region (UN M49), subdivision, address fields (ids 1 to 31).                                                                                                                                          |
| `project_location` (kind `facility`)                                                                          | `facility.location[]`                                                                                                                                                                                                                                                                                                                                                                                                                                      | Same shape.                                                                                                                                                                                                   |
| `project_mitigation`                                                                                          | `project.mitigation[]`                                                                                                                                                                                                                                                                                                                                                                                                                                     | `mitigation_type` (62), `project_sector` (63), `project_type` (64), `estimated_annual_emissions_mitigation` (167), `estimated_total_emissions_mitigation` (168).                                              |
| `project_status_history`                                                                                      | `project.status[]`                                                                                                                                                                                                                                                                                                                                                                                                                                         | Only `project_status`, `project_status_reason`, `is_current` are emitted (66 to 68). `sequence`, `effective_at`, `recorded_at`, actor and `event_id` stay in the HAL status-history resource (`CDOP-FB-015`). |
| `native_state` via `project.native_state_code`                                                                | `project.status[].project_status`                                                                                                                                                                                                                                                                                                                                                                                                                          | The CDOP value comes from the native state's mapping, not from the lifecycle stage.                                                                                                                           |
| `crediting_period`                                                                                            | `project.crediting_period[]` (158 to 160), `validation.validation[]` (155 to 157)                                                                                                                                                                                                                                                                                                                                                                          | Type, maximum cumulative duration and maximum number of periods on the project; the current period's start, end and number on the validation record.                                                          |
| `geolocation_file`                                                                                            | `geolocation_file.location[]` (34 to 43)                                                                                                                                                                                                                                                                                                                                                                                                                   | Name, format, validity dates, status, created/edited/deleted timestamps, area type, geometry type. The GeoJSON itself is served at `…/geolocation-files/{gid}/content`, not in the document (`CDOP-FB-017`).  |
| `project_finance`                                                                                             | `project.costs_and_revenue[]`, `project.funding[]`, `project.financing_options[]`, `project.community_benefit_mechanism_type[]`, `project.declaring_entity_name`, `project_stakeholder.expected_community_proceeds`, `unit.expected_carbon_credit_price`, `unit.realized_transaction_price`                                                                                                                                                                | The declaring entity name comes from the linked organisation.                                                                                                                                                 |
| `project_sdg`                                                                                                 | `cobenefits.sdgs_the_project_plans_to_contribute_to[]`                                                                                                                                                                                                                                                                                                                                                                                                     | SDG numbers 1 to 17.                                                                                                                                                                                          |
| `cobenefit_method`                                                                                            | `cobenefits.methods_used_to_assess_sdgs_and_other_cobenefits[]`                                                                                                                                                                                                                                                                                                                                                                                            |                                                                                                                                                                                                               |
| `cobenefit_target`                                                                                            | `cobenefits.cobenefit_target[]`                                                                                                                                                                                                                                                                                                                                                                                                                            | Includes the spaced key `overview_of_the_projects_approach_to_ track_and_quantify`, emitted exactly as spelled (`CDOP-FB-002`).                                                                               |
| `cobenefit_impact`                                                                                            | `cobenefits.cobenefit_impact[]`                                                                                                                                                                                                                                                                                                                                                                                                                            |                                                                                                                                                                                                               |
| `project_stakeholder` + `organisation`                                                                        | `project_stakeholder.project_developer_*` (73 to 76), `project_stakeholder.stakeholders[]`, `project_stakeholder.organization[]`, `project_stakeholder.location[]`                                                                                                                                                                                                                                                                                         | The stakeholder flagged `is_primary_developer` fills the `project_developer_*` scalars. Organisation rows fill `organization[]` and `location[]`.                                                             |
| `project_landowner`                                                                                           | `project_stakeholder.list_of_landowners[]`                                                                                                                                                                                                                                                                                                                                                                                                                 |                                                                                                                                                                                                               |
| `agreement_counterparty` + `organisation`                                                                     | `project_stakeholder.counterparty[]`                                                                                                                                                                                                                                                                                                                                                                                                                       |                                                                                                                                                                                                               |
| `project_label` + `label` (kind `accreditation`)                                                              | `project.project_level[]`, `project.other[]`                                                                                                                                                                                                                                                                                                                                                                                                               | Accreditation, start and expiry dates, website (244 to 252).                                                                                                                                                  |
| `project_label` + `label` (kinds `compliance_eligibility`, `compliance_potential`)                            | `project.project_level[].project_level_compliance_*`                                                                                                                                                                                                                                                                                                                                                                                                       |                                                                                                                                                                                                               |
| `unit_label` + `label`                                                                                        | `unit.unit_level[]` (253 to 260)                                                                                                                                                                                                                                                                                                                                                                                                                           |                                                                                                                                                                                                               |
| `label` (level `standard`)                                                                                    | `crediting_program.carbon_standard_level_accreditation` (242)                                                                                                                                                                                                                                                                                                                                                                                              |                                                                                                                                                                                                               |
| `project_registry_history`                                                                                    | `registry.previous[]` (131 to 134)                                                                                                                                                                                                                                                                                                                                                                                                                         | `previous_registration_id` is text in the database and integer in the schema (`CDOP-FB-011`).                                                                                                                 |
| `registry` via `project.registry_id`                                                                          | `registry.current_registry` (83), `registry.origin_registry` (82), `registry.current_project_issuance_registry` (136)                                                                                                                                                                                                                                                                                                                                      | Exact CDOP registry names.                                                                                                                                                                                    |
| `crediting_program`, `standard`, `standard_version`                                                           | `crediting_program.crediting_program[]` (44 to 45), `crediting_program.standard[]` (46 to 47), `crediting_program.initial_standard_version` (48), `crediting_program.current_standard_version` (49)                                                                                                                                                                                                                                                        | `standard.cdop_name` carries the exact published enum string; v2.1.0 corrects `Verified Carbon Standard (VCS)` (FB-006).                                                                                      |
| `methodology`, `methodology_version`                                                                          | `methodology.versions[]` (50 to 53)                                                                                                                                                                                                                                                                                                                                                                                                                        | The 496-value enum string, version, `is_current`, document URL.                                                                                                                                               |
| `validation_event`                                                                                            | `validation.validation_body_name` (84), `validation_date` (85), `validation_report` (86), `validation.event[]` (170 to 171)                                                                                                                                                                                                                                                                                                                                | The latest completed validation fills the scalars. `validation_id` is the per-project `sequence`.                                                                                                             |
| `verification_event`                                                                                          | `project.audits[]` (auditor name, site visit dates, report URL and date); `issuance.issuance[].date_of_verification`, `verification_period_start`, `verification_period_end`                                                                                                                                                                                                                                                                               | The verification record itself (claimed, gross and verified quantities, deductions) has no CDOP section yet; it is served as `cdop:verifications` (M2).                                                       |
| `estimation`                                                                                                  | `estimations.estimation_event[]` (162 to 163), `estimations.status[]` (164 to 166)                                                                                                                                                                                                                                                                                                                                                                         | `estimation_id` is the per-project `sequence`.                                                                                                                                                                |
| `estimation_vintage`                                                                                          | `estimations.vintage_mitigation[]` (172 to 173), `estimations.monitoring[]` (174 to 175), `estimations.estimation_event[].estimated_issuance_date[]`                                                                                                                                                                                                                                                                                                       | Three parallel arrays emitted in the same order from one row per vintage (`CDOP-FB-016`).                                                                                                                     |
| `milestone`                                                                                                   | none                                                                                                                                                                                                                                                                                                                                                                                                                                                       | API-only (`cdop:milestones`).                                                                                                                                                                                 |
| `issuance`                                                                                                    | `issuance.issuance[]` (93 to 101)                                                                                                                                                                                                                                                                                                                                                                                                                          | `batch_identifier` is the URN with batch suffix; `issuance_status` never emits `Verified` (`CDOP-FB-014`).                                                                                                    |
| `unit_block`                                                                                                  | `unit.descriptor[]` (140, 149), `unit.reference[]` (144 to 145), `unit.credit_block[]` (150 to 152), `unit.owner_account_id` (141); `vintage.vintage` (153)                                                                                                                                                                                                                                                                                                | One block is one document. `source_serial_number` comes from `source_block_id`. `vintage.vintage` is `vintage_start_on`.                                                                                      |
| `unit_status_history`                                                                                         | `unit.status[]` (146 to 148)                                                                                                                                                                                                                                                                                                                                                                                                                               | `status` via `cdopUnitStatus(state, state_reason)`; one `is_current`.                                                                                                                                         |
| `retirement`                                                                                                  | `unit.retirement[]` (142 to 143)                                                                                                                                                                                                                                                                                                                                                                                                                           | Beneficiary and detail.                                                                                                                                                                                       |
| `transfer`, `cancellation`                                                                                    | none                                                                                                                                                                                                                                                                                                                                                                                                                                                       | Events and HAL only.                                                                                                                                                                                          |
| `buffer_pool_entry` via `buffer_pool_balance`                                                                 | `project.buffer_pool[]` (196 to 199)                                                                                                                                                                                                                                                                                                                                                                                                                       | One row of four lifetime totals from the ledger (`CDOP-FB-023`).                                                                                                                                              |
| `agreement` (+ `agreement_offtake`, `agreement_insurance`, `agreement_funding`)                               | `agreement.*` (208 to 231), `agreement.offtake[]`, `agreement.insurance[]`, `agreement.funding_details[]`, `agreement.date[]`                                                                                                                                                                                                                                                                                                                              | Effective and expiry dates become the `date[]` array.                                                                                                                                                         |
| `document`                                                                                                    | `project.documents[]` (other documentation type and link), `project.project_design_document_link`, `validation.validation_report`, `project.audits[].verification_report_url`                                                                                                                                                                                                                                                                              | Typed documents are routed to the field that names them; everything else lands in `documents[]`.                                                                                                              |
| `account`, `organisation`                                                                                     | none as entities                                                                                                                                                                                                                                                                                                                                                                                                                                           | `owner_account_id` and stakeholder names only (`CDOP-FB-019`).                                                                                                                                                |
| `event`, `webhook`, `api_key`, `idempotency_key`, `sim_config`, `sim_run`, `cdop_vocabulary`, `document_type` | none                                                                                                                                                                                                                                                                                                                                                                                                                                                       | API infrastructure and reference data.                                                                                                                                                                        |

## Adaptations for CDOP v2.1.0

The projection emits clean `crediting_period` and co-benefit keys, and `credit_block[].block_start`; the old `credit_blockblock_start` workaround is removed. Standard accreditation (field 242) now consistently belongs to `crediting_program`. Empty compliance-market membership is omitted because the field is optional (FB-020).

`unit` and `vintage` appear in per-unit documents. The project-level Full List omits them unless `?unit_id=` is supplied; `/v2/units/{id}/cdop/full-list` and `/v2/units/{id}/cdop/unit-description` carry them. The independent [TWG proposal](./twg-proposal) is built from the same aggregate and never changes these published document shapes.

## Absent sections and strict mode

By default a section with no data is omitted. The document is then honest but may fail the upstream `required` list (`agreement`, `cobenefits`, `estimations` and `geolocation_file` are required by Full List).

`?strict=1` switches on placeholders. Where the schema allows an empty-but-valid value (an empty array, an object with only its required scalars), the API emits it. Each placeholder is listed in the `X-CDOP-Conformance` response header with the register entry that explains it. The API does not invent compliance-market membership or unsupported enum values to force validation.

## Value projections

| Value                                          | Rule                                                                                                                                                                                                                              |
| ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `project.status[].project_status`              | From the native state row (`native_state.cdop_project_status`), which is the registry's own code mapped once.                                                                                                                     |
| `unit.status[].status`                         | `cdopUnitStatus(state, state_reason)`: pending and active → Active; on_hold → Pending Transfer, Accepted Pending Payment or On Hold by reason; buffer → Deposited Released; retired → Retired; cancelled and expired → Cancelled. |
| `unit.descriptor[].type`                       | The registry's unit type verbatim (`PIU`, `VCU`, and also `WCU`/`PCU`, which the enum lacks; `CDOP-FB-025`).                                                                                                                      |
| Integer ids (`validation_id`, `estimation_id`) | The record's per-project `sequence`.                                                                                                                                                                                              |
| `project_risk`                                 | `JSON.stringify` of the stored object.                                                                                                                                                                                            |
| Dates                                          | `*_on` columns as `YYYY-MM-DD`; timestamps as RFC 3339 UTC.                                                                                                                                                                       |
| Enum strings                                   | Exactly the vendored strings, including known typos.                                                                                                                                                                              |

## Round 2 draft pods

Registry Metadata, Validation Metadata and Verification Metadata are Round 2 drafts from the upstream `R2P-FT-Testing` branch (ADR 0013), separately pinned at `39ac535`, not part of the published v2.1.0 release. They are not subsets of Full List, so `apps/api/src/domain/projection/round2.ts` builds each one directly from the aggregate. Field ids are the drafts' own (261 to 330).

| Pod (`/v2/projects/{id}/cdop/{pod}`) | Schema file (`schemas/round2/`)     | Source                                                                                                                                                                                                                                                                                                                                                   |
| ------------------------------------ | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `registry-metadata`                  | `Registry_Metadata.schema.json`     | `registry` and `crediting_program` vocabulary (identifier = 1-based position, CDOP-FB-032), the registry deep link, `registered_on` else `listed_on` (269), `modified_at` as a date (270). `original[]` repeats the current registry (CDOP-FB-033).                                                                                                      |
| `validation-metadata`                | `Validation_Metadata.schema.json`   | `validation_event` rows in sequence order: `validation.validation_event[]`, with `date[]` and `report[]` index-aligned to it (CDOP-FB-034); the current `crediting_period`; stages and stage status derived from the latest validation's status; one `validation_body.details[]` per validation body. Sectoral scope from the methodology (CDOP-FB-038). |
| `verification-metadata`              | `Verification_Metadata.schema.json` | One `verification_event` row: the latest completed, or `?verification_id=`. Verified quantity is gross minus leakage, buffer and uncertainty deductions; the uncertainty margin is sent as a percentage (CDOP-FB-040); audit status from the event's status and opinion. 404 when the project has no verification.                                       |

Required values the dataset does not hold are reported as missing, and `X-CDOP-Conformance` cites `CDOP-FB-035` (validation dates, validator name, body selection, team members; the outcome of a verification in progress), `CDOP-FB-038` (no sectoral scope fits) or `CDOP-FB-039` (the verification credential DID). `?strict=1` fills only the text fields with `Not published`; it never fills a date, a quantity or a scope.

## Verifying the projection

```bash
pnpm seed
pnpm test                                   # conformance: every seeded project × every pod through Ajv
curl -s http://localhost:3000/v2/projects/<id>/cdop/full-list?strict=1 -D - -o /dev/null | grep -i x-cdop
```
