# OIP-0017: COMMUNITY profile: people and low-cost sensors

| Field | Value |
|---|---|
| Status | DRAFT |
| Functions | `join` (§5.1, light), `describe` (§5.3), `observe` (§5.5), `qualify` (§5.6); no new function (the register keeps exactly twelve) |
| Affects | §7.1 (row `OBSP-COMMUNITY`), new §7.3 with COM-1 to COM-8; new schemas `co-location-record` and `human-report`; `registers/conformance-profiles.yaml` (new profile `OBSP-COMMUNITY`); `conformance/suite.yaml`; the profile enumerations of `conformance-claim`, `conformance-report` and `participant-manifest` (additive); a Makefile target `conformance-community`; `registers/requirements.yaml` regenerated (78 requirements); new cases CT-COMMUNITY-001 to CT-COMMUNITY-006 |
| Protocol version | obsp/0.1 |
| Work packages | WP-PR-09 (frontier profiles: people and low-cost sensors) |
| Requires | Reads OIP-0006 (observer class `PERSON`, subject classes `NONE`, `OBJECTS`, `PERSONS` and their policy rule, observed-property ids `obsp:prop:*`) and OIP-0014 (consent record) by name only. The patches apply to the current tree on their own and do not depend on either draft's files |
| Last call | 30 days (new profile and objects, additive) unless the editors rule otherwise |

## Problem

Low-cost sensors and people who report what they see (a felt earthquake, a flooded street, rain in a home gauge, a
crop stage, a heat symptom) add observations where no other instrument stands. The protocol cannot carry them honestly
today:

1. There is no way to say how good a value is. A low-cost particle counter and a reference monitor produce records of
   the same shape, so an uncorrected reading can travel as if it were a reference measurement.
2. The usual remedy, running the low-cost sensor beside a reference instrument and fitting a correction, has no record:
   nobody can see which reference was used, whether that reference was itself calibrated, over which period, with which
   fit, or how large the residuals were, and so whether a later value still falls inside the period the correction
   covers.
3. A person is not an instrument: there is no sensor passport, the result is often a category on a named scale, and the
   record must protect the person (pseudonymous identity that changes over time, a location that does not single out a
   home, a photo without embedded position, a consent reference, moderation before publication).
4. Reports about people (symptoms, occupancy) need the subject-class rules of OIP-0006 to apply to them as well.

## Change

### Normative text

A new §7.3 "Community profile (`OBSP-COMMUNITY`)" with requirements COM-1 to COM-8 in an id table (full text in
`patches/spec.patch`) and the §7.1 row. The two objects are listed in §7.3 rather than in the §4.2 table of core objects.
In short:

1. **COM-1 (Qualify).** Every value carries a quality tier. `CALIBRATED` only with a CoLocationRecord, referenced by UNI
   and digest, that awarded `CALIBRATED`; `REFERENCE` only with a current calibration record of the instrument, with a
   traceability chain, valid at the observation time; otherwise `INDICATIVE`.
2. **COM-2 (Qualify).** A tier upgrade needs a current record of the same sensor (as candidate) and property whose
   validity window covers the observation time; the window never begins before the co-location period begins.
3. **COM-3 (Describe).** A CoLocationRecord names candidate and reference by sensor passport version, the reference's
   calibration record, site and separation, period, averaging interval, paired samples and data coverage, the fit
   (model, coefficients, covariates; a method record for machine-learning or other fits) and residual statistics (RMSE,
   mean bias, coefficient of determination, evaluation) in the property's unit; the reference calibration is valid over
   the whole period.
4. **COM-4 (Join).** A contributor is a pseudonym the receiving participant issues, never a personal identifier; it
   changes at least once per declared rotation period and is never reused in another period.
5. **COM-5 (Observe).** A HumanReport names observer class `PERSON`, its observed property, a numeric result with its
   UCUM unit or a category of a named vocabulary, phenomenon time, consent record and moderation state (a decided state
   names when and by which role; a rejection or redaction its reason code); it is always `INDICATIVE`.
6. **COM-6 (Observe).** Locations are coarsened by default (stated grid, precision no finer than 100 m; about 1 km
   recommended); an exact location only with the contributor's opt-in; a photo by digest only, location metadata
   removed, with an optional content credentials (C2PA) reference.
7. **COM-7 (Observe).** A report about persons follows OIP-0006 OBS-4 (subject policy by absolute URI) and never carries
   an exact location.
8. **COM-8 (Observe).** Forwarding, export and republication keep tier, co-location reference and moderation state; a
   rejected or redacted report travels only as a tombstone.

The three tiers are written in upper case (`REFERENCE`, `CALIBRATED`, `INDICATIVE`), the repository's convention for
enumerations; the design text names them in lower case. A tier states the evidence behind a value, never its fitness
for a purpose or conformity with a performance scheme.

Until the observation record has a field of its own, an ObservationRecord carries its tier in the extension member
`obsp.community`: `{qualityTier, colocationRef?}` with `colocationRef` `{uni, version?, digest}`. The record schema is not
changed by this proposal (see Open questions).

### Contract: `co-location-record` (schemaVersion `3.1.0`, `$id` `urn:obsp:schema:v3.1:colocationrecord`)

| Property | Required | Shape |
|---|---|---|
| `schemaVersion`, `apiVersion`, `kind`, `protocolVersion` | yes | `3.1.0`, `obsp/co-location-record/v3.1`, `CoLocationRecord`, `obsp/0.1` |
| `colocationUni`, `version` | yes | UNI, record version |
| `candidate` | yes | `{sensorPassportRef (versioned), sensorClass?}`; class `LOW_COST_SENSOR`, `CONSUMER_STATION`, `INDICATIVE_INSTRUMENT`, `OTHER` |
| `reference` | yes | `{sensorPassportRef (versioned), calibrationRef (versioned), tier: REFERENCE}` |
| `observedProperty`, `unit` | yes | `obsp:prop:*` id; UCUM |
| `site` | yes | `{siteUni, separationMetres ≥ 0, inletHeightDifferenceMetres?}` |
| `period` | yes | `{start, end}` RFC 3339 with offset |
| `averagingInterval`, `pairedSamples`, `dataCoverage` | yes | ISO 8601 duration; integer ≥ 1; fraction 0 to 1 |
| `fit` | yes | `{model, coefficients[≥1] {name, value, unit}, covariates?, methodRef?}`; model `LINEAR`, `MULTILINEAR`, `POLYNOMIAL`, `PIECEWISE_LINEAR`, `MACHINE_LEARNING`, `OTHER` (the last two require `methodRef` `{uri, digest}`) |
| `residuals` | yes | `{unit, rmse ≥ 0, meanBias, rSquared 0 to 1, evaluation, meanAbsoluteError?, slope?, intercept?}`; evaluation `IN_SAMPLE`, `HOLD_OUT`, `CROSS_VALIDATION` |
| `tierAwarded` | yes | `CALIBRATED` or `INDICATIVE` (never `REFERENCE`) |
| `acceptanceCriteriaRef` | no | `{uri, digest}` of the criteria the residuals were judged against |
| `validFrom`, `validUntil` | yes | the window in which the correction applies |
| `performedBy`, `correctionState`, `evidenceRefs` (≥ 1: the paired dataset), `recordedAt` | yes | as `calibration-record` |

### Contract: `human-report` (schemaVersion `3.1.0`, `$id` `urn:obsp:schema:v3.1:humanreport`)

| Property | Required | Shape |
|---|---|---|
| `schemaVersion`, `apiVersion`, `kind`, `protocolVersion` | yes | `3.1.0`, `obsp/human-report/v3.1`, `HumanReport`, `obsp/0.1` |
| `reportUni` | yes | UNI |
| `observer` | yes | `{class: PERSON, contributor: {pseudonymId, issuerUni, epochStart, epochEnd, rotatesAfter}}`; `pseudonymId` `^pseud:[A-Za-z0-9_-]{16,86}$` |
| `observedProperty`, `phenomenonTime` | yes | `obsp:prop:*` id; RFC 3339 |
| `result` | yes | exactly one of `{value, unit}` or `{category, vocabulary: {uri, version?}}` |
| `location` | yes | `{crs, coordinates [lon, lat], method, precisionMetres, coarsening?, contributorOptIn?}`; method `COARSENED` (default; needs `coarsening` `{scheme: GRID_SNAP, cellDegrees}` and precision ≥ 100 m) or `EXACT` (needs `contributorOptIn: true`) |
| `photo` | no | `{digest, mediaType, locationMetadataRemoved: true, contentCredentialsRef?: {format: C2PA, uri?, digest?}}`; never inline data. The content credentials reference is a placeholder the protocol does not validate yet |
| `consentRef` | yes | `{uni, version?, digest}` of the contributor's consent record (OIP-0014) |
| `subjectClass` | yes | `NONE`, `OBJECTS`, `PERSONS`; `subjectPolicyRef` `{uri, digest?}` required for `PERSONS` |
| `qualityTier` | yes | `INDICATIVE` (constant) |
| `moderation` | yes | `{state, decidedAt?, decidedBy?, reasonCode?}`; state `PENDING`, `ACCEPTED`, `FLAGGED`, `REJECTED`, `REDACTED`; decided states need `decidedAt` and `decidedBy` (role and UNI); `REJECTED` and `REDACTED` need `reasonCode` |
| `evidenceRefs`, `extensions` | no | as elsewhere |
| `recordedAt` | yes | RFC 3339 |

### Profile

`OBSP-COMMUNITY` in `registers/conformance-profiles.yaml`: functions `join`, `describe`, `observe`, `qualify`; it
extends no profile. Join is light: a pseudonymous contributor, no device attestation. `conformance/suite.yaml` lists it.
The Makefile runs its example set (`conformance/examples/OBSP-COMMUNITY/`: a reference particulate monitor and a
low-cost sensor with their passports, the reference's calibration, a co-location record, a reference, a calibrated and
an indicative value, four human reports and the attestation for the manual case) through a target of its own,
`conformance-community`, joined to `conformance` by a prerequisite line, so the shared `PROFILES` and `.PHONY` lines are
not edited. The profile enumerations of `conformance-claim`, `conformance-report` and `participant-manifest` gain the id
(additive, schemas stay `3.1.0`).

### Invariants (suite module `sdk/python/src/obsp/community.py`, merged into the suite's table; unit tests in `sdk/python/tests/test_community.py`)

| Invariant | Rule |
|---|---|
| `community-tier-evidence` | every observation record in the set carries a tier; `CALIBRATED` resolves its `colocationRef` by UNI and RFC 8785 digest to a record that awarded `CALIBRATED`; `REFERENCE` has a current calibration record of its sensor passport with a traceability chain, an in-tolerance outcome and a validity window covering the observation time; an `INDICATIVE` value carries no co-location reference (COM-1) |
| `community-colocation-covers` | for a `CALIBRATED` value the record is `CURRENT`, its candidate is the value's sensor, its property the value's (bare names compare equal to register ids) and its validity window covers the observation time; no record's window begins before its period (COM-2) |
| `community-colocation-consistent` | period and validity ordered; candidate is not the reference; both passports in the set by UNI, version and digest; the reference calibration in the set by UNI and digest, of the reference instrument, in tolerance and valid over the whole period; paired samples fit in the period at the averaging interval; residuals in the property's unit (COM-3) |
| `community-contributor-pseudonymous` | the contributor is a `pseud:` identifier that does not look like an e-mail address, telephone number, hardware address or device serial; its epoch is ordered, no longer than `rotatesAfter` and holds the report; one pseudonym of one issuer is never used in two epochs (COM-4) |
| `community-location-coarsened` | a coarsened location lies on the grid it states and its precision is not finer than half a grid cell (COM-6) |
| `community-subject-policy` | a `PERSONS` report names its subject policy by absolute URI and carries no exact location (COM-7) |

## Compatibility

Additive: two new objects, a new profile and three enumerations that gain a value. No existing record changes. The tier
of an observation record travels in its extension bag, which every record already allows, so obsp/0.1 records and the
OIP-0006 record shape both carry it unchanged.

Draft interplay: the invariants and their tests are new files joined to the suite by three lines placed between the
`Case` and `Suite` classes of `conformance.py`, where no other draft has context; the Makefile gains its own target
next to `openapi` instead of a word on the `PROFILES` line. With these patches applied, the patches of OIP-0001 to
OIP-0008 still apply. What still meets other drafts:

- `registers/requirements.yaml` (generated by `python3 tools/requirements.py`; the proposal accepted second regenerates
  it): OIP-0009, OIP-0010, OIP-0011, OIP-0012, OIP-0013, OIP-0014, OIP-0015 and OIP-0019 touch the same entries;
- the profile lines every new-profile draft adds at the same place (OIP-0010, OIP-0011, OIP-0012, OIP-0013): the
  `OBSP-CONSUMER` row of §7.1 and the new §7.3 after §7.2, `registers/conformance-profiles.yaml`, `conformance/suite.yaml`
  and the three profile enumerations. Whichever is accepted second is rebased on the first and renumbers its section.

## Tests

| Requirement | Case | Kind | Evidence and invariants |
|---|---|---|---|
| COM-4 | CT-COMMUNITY-001 | invariant | `human-report`; `community-contributor-pseudonymous` (function `join`) |
| COM-3 | CT-COMMUNITY-002 | invariant | `co-location-record`, `calibration-record`, `sensor-passport`; `community-colocation-consistent` (function `describe`) |
| COM-1, COM-2 | CT-COMMUNITY-003 | invariant | `co-location-record`, `observation-record`; `community-tier-evidence`, `community-colocation-covers` (function `qualify`) |
| COM-5 | CT-COMMUNITY-004 | schema | `human-report` (function `observe`) |
| COM-6, COM-7 | CT-COMMUNITY-005 | invariant | `human-report`; `community-location-coarsened`, `community-subject-policy` (function `observe`) |
| COM-8 | CT-COMMUNITY-006 | manual | procedure: forward calibrated and indicative values and accepted, pending and rejected reports through every path; tier, co-location reference and moderation state survive; the rejected report travels as a tombstone |

Positive fixtures: `co-location-record.valid` (PM2.5 low-cost sensor, multilinear fit with a humidity covariate,
hold-out residuals, `CALIBRATED`), `.no2-machine-learning` (machine-learning fit with its method record, cross-validated),
`.fit-failed-stays-indicative` (residuals miss the criteria, `INDICATIVE`); `human-report.valid` (felt earthquake,
categorical intensity on a named macroseismic scale), `.rain-gauge` (numeric, mm), `.persons-with-policy` (self-reported
body temperature, `PERSONS` with a subject policy, moderation pending), `.exact-location-opt-in-photo` (flood depth,
exact location with opt-in, photo by digest with a content credentials reference), `.rejected` (moderation `REJECTED`
with a reason code).

Negative fixtures, one broken rule each. `co-location-record.`: `reference-without-calibration`,
`reference-tier-indicative`, `tier-awarded-reference`, `missing-period`, `period-end-not-rfc3339`, `missing-residuals`,
`residuals-without-rmse`, `r-squared-above-one`, `residuals-without-evaluation`, `data-coverage-above-one`,
`zero-paired-samples`, `ml-fit-without-method`, `fit-without-coefficients`, `bad-averaging-interval`,
`negative-separation`, `property-not-a-register-id`, `missing-candidate-passport`, `candidate-passport-without-version`,
`missing-valid-until`, `performed-by-not-a-role`, `missing-evidence`. `human-report.`: `observer-not-person`,
`pseudonym-is-email`, `pseudonym-is-phone-number`, `contributor-without-rotation`, `contributor-without-epoch-end`,
`missing-consent-ref`, `persons-without-policy`, `missing-subject-class`, `tier-calibrated`, `numeric-without-unit`,
`category-without-vocabulary`, `result-value-and-category`, `exact-without-opt-in`, `coarsened-without-coarsening`,
`coarsened-precision-too-fine`, `missing-location-method`, `latitude-out-of-range`, `photo-inline-data`,
`photo-location-metadata-kept`, `photo-without-digest`, `content-credentials-not-c2pa`, `missing-moderation`,
`unknown-moderation-state`, `moderation-decided-without-time`, `moderation-rejected-without-reason`,
`phenomenon-time-not-rfc3339`.

Rules the schemas cannot express (digests against documents in the set, validity windows against observation times,
calibration coverage of the co-location period, sample counts, pseudonym shapes and reuse, grid snapping, policy URIs)
are proved by 47 unit tests, including one that runs the profile on the example set (PASS, report valid against
`conformance-report`) and one that runs it on a copy with one indicative value relabelled `CALIBRATED` and sees only
CT-COMMUNITY-003 fail.

## References

| Source | Used for | Checked |
|---|---|---|
| CEN/TS 17660-1 (air quality, performance evaluation of air quality sensor systems, part 1: gaseous pollutants) | the practice of co-location against a reference method and of residual-based performance classes that `co-location-record` records (by reference to `acceptanceCriteriaRef`, never by copying criteria) | not checked |
| PPSR Core (public participation in scientific research data and metadata standard) | the project, dataset and observation layers of participatory science, for a later crosswalk of `human-report` | not checked |
| OIP-0006 (draft): observer class `PERSON`, subject classes and OBS-4 | `human-report` observer and subject class | draft in this repository |
| OIP-0014 (draft): consent record | `consentRef` | draft in this repository |
| ISO 8601 durations, RFC 3339 date-times, UCUM | `averagingInterval`, `rotatesAfter`, times, units | as elsewhere in the protocol |
| C2PA content credentials | the placeholder `contentCredentialsRef` | not checked |

No text, table or figure of these sources is reproduced.

## Open questions

1. Should OIP-0006 give the observation record a `qualityTier` field and a `colocationRef` (or a general
   `calibrationRef` covering both calibration records and co-location records), so the tier leaves the extension bag?
   This draft keeps the record schema untouched so that it stays independent of OIP-0006's files.
2. Should `relations.yaml` gain external rows for CEN/TS 17660-1 and PPSR Core (and a crosswalk `crosswalks/ppsr-core.yaml`)?
   They were left out so that `implements-edges.json` is not touched before either source has been opened. The part
   number for particulate matter, the edition year and the performance classes of CEN/TS 17660 were not checked.
3. Acceptance criteria are referenced, not encoded: should the protocol carry machine-readable thresholds per property
   (for example maximum RMSE and minimum coefficient of determination per class), or leave them to the scheme the
   operator names?
4. Should co-location separation, inlet height difference and maximum extrapolation of a correction beyond its period
   (sensor drift) be bounded by the protocol? Today the validity window is the operator's statement.
5. The coarsening floor (100 m, about 1 km recommended) and the single `GRID_SNAP` scheme are this draft's choice.
   Should named discrete global grids or administrative areas be allowed, and should the floor depend on the subject
   class or on population density?
6. Pseudonym rotation: should the protocol fix a longest rotation period, and say how a contributor can link their own
   reports across epochs (for reputation or withdrawal of consent) without the receiving participant being able to?
7. Content credentials: the C2PA reference is a placeholder. Which edition, which assertions, and should a photo
   without credentials be allowed at all?
8. COM-8 is tested by a manual case. Once the exchange APIs of OIP-0001 are accepted, should it become an invariant on
   exported documents?
9. Should a person reading a calibrated instrument (a standard rain gauge) be able to report `CALIBRATED` values, with
   the instrument's passport and co-location record named in the report? Today every human report is `INDICATIVE`.

Acceptance needs appointed editors and a last-call window. Until then this proposal stays at DRAFT.
