# OIP-0010: CONSTELLATION profile: orbits, tasking, onboard processing and downlink

| Field | Value |
|---|---|
| Status | DRAFT |
| Functions | `describe` (§5.3), `time` (§5.4), `observe` (§5.5), `orchestrate` (§5.8), `exchange` (§5.10), `prove` (§5.11); no new function (the register keeps exactly twelve) |
| Requires | OIP-0006 (universal observation: origin, processing of observations, store-and-forward times) and OIP-0008 (signature envelope). The new objects are defined standalone: the shared definitions (`Geometry`, `Timestamp`, `SignatureEnvelope`) are copied unchanged into each schema, so the patches apply to the current tree on their own |
| Relates to | OIP-0012 (model runs, a parallel draft): an onboard-processed product names its model run by UNI only, never by schema reference |
| Affects | §4.2 (two rows), §7.1 (row `OBSP-CONSTELLATION`), new §7.3 with CST-1 to CST-7; new schemas `orbit-record`, `conjunction-record`, `tasking-order`, `downlink-record`; the profile id added to the `conformance-claim`, `conformance-report` and `participant-manifest` enumerations; `registers/conformance-profiles.yaml`, `registers/functions.yaml`, `conformance/suite.yaml`, Makefile `PROFILES`; `registers/requirements.yaml` regenerated; cases CT-CONSTELLATION-001 to CT-CONSTELLATION-006 |
| Protocol version | obsp/0.1 |
| Last call | 90 days (new profile and four new objects) unless the editors rule otherwise |

## Problem

Satellites are observers like any other, but nothing in OBSP 0.1 can say where a spacecraft was, whether it was at
risk, who asked it to look, what happened to the request and how the data reached the ground:

1. There is no orbit object. A product made from a satellite pass cannot name the orbit it was geolocated with, its
   epoch, frame or the message it came from, so a later orbit correction cannot be traced to the products it touches.
2. Conjunction assessments are exchanged as messages that are replaced, not versioned. A receiver cannot tell an
   update from a silent overwrite, and §5.9 (correction without erasure) is not applied to them.
3. Tasking has no protocol object. A request, its acceptance, its execution and its outcome live in each provider's
   interface; nothing proves which party moved the order to which state, or links a delivered product to the order.
4. The path from acquisition to the ground (onboard storage, relays, ground station, file transfer) is not recorded,
   so latency claims and replay order cannot be checked, and a product processed onboard cannot say so.

## Change

### Normative text (new §7.3, summarised; the exact text is in `patches/spec.patch`)

The profile `OBSP-CONSTELLATION` lists Describe, Time, Observe, Orchestrate, Exchange and Prove. It records CCSDS
messages by reference and digest and never copies them.

| Id | Requirement (short form) | Case |
|---|---|---|
| CST-1 | An OrbitRecord names the spacecraft by COSPAR id or catalogue number, the epoch, reference frame and time system; references its ODM (`OEM`, `OPM`, `OMM`, CCSDS 502.0-B-3) by format and digest; states whether covariance is present; names the source system by role and UNI | CT-CONSTELLATION-001 |
| CST-2 | A ConjunctionRecord references its CDM (CCSDS 508.0-B-1) by digest and states TCA, miss distance (m) and collision probability. An update is a new version naming the version it supersedes, recorded by a CorrectionNotice (§5.9); a version is never overwritten | CT-CONSTELLATION-005 |
| CST-3 | A TaskingOrder keeps every transition, in order, numbered from 1, each to an allowed next state; nothing follows a terminal state; entries are never removed or rewritten; the state is the last transition's target | CT-CONSTELLATION-003 |
| CST-4 | Every transition is signed by its actor with the signature envelope (`COSE_Sign1`) over the entry without its signature, and chained to the previous entry by digest | CT-CONSTELLATION-006 |
| CST-5 | A `FULFILLED` order references its DownlinkRecords and products by UNI and digest; every listed product is in a referenced DownlinkRecord that names the order, acquired inside the order window; `FAILED` and `CANCELLED` carry a reason | CT-CONSTELLATION-004 |
| CST-6 | A DownlinkRecord states `acquiredAt` ≤ `onboardStoredAt` ≤ `downlinkStart` ≤ `downlinkEnd` (as instants) and its ground station; relay hops are in order inside that span; a CFDP transfer carries its transaction id | CT-CONSTELLATION-002 |
| CST-7 | Every delivered product states its processing level (`L0` to `L4`, optional sub-level letter); an onboard-processed product names its model run by UNI and is never `L0` | CT-CONSTELLATION-004 |

Tasking lifecycle (one object, state history, every transition signed):

| From | Allowed next states |
|---|---|
| (start) | `FEASIBILITY`, `ORDERED` |
| `FEASIBILITY` | `ORDERED`, `CANCELLED` (a feasibility with no opportunity ends `CANCELLED` with reason `NOT_FEASIBLE`) |
| `ORDERED` | `ACCEPTED`, `CANCELLED` (a provider refusal is `CANCELLED` with reason `REJECTED_BY_PROVIDER`) |
| `ACCEPTED` | `EXECUTING`, `CANCELLED` |
| `EXECUTING` | `FULFILLED`, `FAILED`, `CANCELLED` |
| `FULFILLED`, `FAILED`, `CANCELLED` | none (terminal) |

Binding note (informative, not a requirement): the community STAC API extension for tasking ("STAPI") is a community
specification, not a standard. Its order states are expected to map onto the states above, and an implementation
records the external order id in `externalRefs` (scheme `stapi-order`). The mapping has not been checked against a
release of that specification (checked: not checked).

### Contracts (schemaVersion `3.1.0`, `$id` `urn:obsp:schema:v3.1:<name>`)

`orbit-record`: `orbitUni`, `version`, `spacecraft` (`spacecraftUni?`, `cosparId` `^[0-9]{4}-[0-9]{3}[A-Z]{1,3}$`,
`noradCatalogNumber`, at least one of the two, `objectType?`), `epoch`, `referenceFrame` (`EME2000`, `GCRF`, `ICRF`,
`ITRF`, `TEME`, `TOD`, `MOD`, `OTHER` with `referenceFrameOther`), `centreName?`, `timeSystem` (`UTC`, `TAI`, `TT`,
`GPS`, `TDB`, `UT1`), `odm` (`format` `OEM`/`OPM`/`OMM`, `standard` `CCSDS 502.0-B-3`, `encoding` `KVN`/`XML`, `uri`,
`digest`, `messageId?`), `covariancePresent`, `source` (`kind`, `sourceUni`), `validTime?`, `signature?`, `recordedAt`.

`conjunction-record`: `conjunctionUni`, `version`, `cdm` (`standard` `CCSDS 508.0-B-1`, `messageId`, `encoding`, `uri`,
`digest`, `creationDate`), `primary`, `secondary` (space objects as above), `tca`, `missDistance` (`value` ≥ 0, `unit`
`m`), `collisionProbability` (`value` 0 to 1, `method?`), `relativeSpeed?` (m/s), `orbitRefs?`, `supersedes` (required
for every version after the first, refused on the first), `signature?`, `recordedAt`.

`tasking-order`: `orderUni`, `constellationUni?`, `spacecraft?`, `requester` and `provider` (role and UNI), `request`
(`productKind`, `area` as a Geometry with CRS, `window`, `constraints?`: cloud cover, off-nadir, minimum processing
level, priority), `state`, `history` (entries: `seq`, `from` (absent on the first), `to`, `at`, `actor`, `reason`
(required for `FAILED` and `CANCELLED`), `previousDigest`, `evidenceRefs?`, `signature` (required envelope)),
`feasibility?`, `fulfilment` (required exactly when `FULFILLED`: `downlinkRefs`, `products`), `externalRefs?`,
`recordedAt`. The allowed transitions are encoded in the schema; the order of the history is a suite invariant.

`downlink-record`: `downlinkUni`, `spacecraft`, `orderUnis?`, `acquiredAt`, `onboardStoredAt`, `downlinkStart`,
`downlinkEnd`, `groundStation` (`stationUni`, `geometry?`), `relayHops?` (`kind`, `nodeUni`, `receivedAt`,
`forwardedAt`), `transfer` (`protocol` `CFDP` with `cfdp` = source entity id and transaction sequence number, or
`OTHER`), `products` (UNI, digest, `processingLevel`, `onboardProcessing?` = `modelRunUni`, `processedAt?`),
`timeQualityRef?`, `signature?`, `recordedAt`.

Onboard processing is carried on the product references of the DownlinkRecord and the order's fulfilment, so
`product-manifest` is not changed by this proposal. A product's processing level and model run travel with every
reference to it.

### Invariants (suite, `sdk/python/src/obsp/constellation.py`, merged into the runner's table)

| Invariant | Rule |
|---|---|
| `downlink-times-ordered` | acquisition ≤ storage ≤ downlink start ≤ end, as instants with offsets; relay hops after storage, each forwarding after receiving and before the downlink ends (CST-6) |
| `tasking-transitions-monotonic` | `seq` 1..n, `from` equals the previous `to`, allowed transitions only, nothing after a terminal state, times non-decreasing, `state` equals the last `to` (CST-3) |
| `tasking-transitions-signed` | each entry carries a `COSE_Sign1` envelope whose `payloadDigest` is the digest of the entry without `signature`; `previousDigest` of entry n is the digest of entry n−1, absent on the first (CST-4) |
| `tasking-fulfilment-linked` | for a `FULFILLED` order, every downlink reference resolves by UNI and digest in the evidence set, the downlink names the order and acquired inside the window, every listed product is a product of a referenced downlink with the same digest (CST-5) |
| `conjunction-update-supersedes` | no two conjunction documents with the same UNI and version and different digests; every `supersedes` names the same conjunction, a lower version and the digest of that version when present; a CorrectionNotice in the set supersedes that version by this one, digests included (CST-2) |

The signature check is structural (the envelope binds the entry it signs); verifying signature bytes and resolving
keys is OIP-0008's (`signature-verifies`, `signature-key-resolvable`) once both are accepted.

## Compatibility

Not breaking: four new objects, one new profile, no change to an existing object (§10). Existing profiles and their
example sets are untouched.

Draft interplay. The patches apply to the current tree on their own. With them applied, every patch of the other
drafts still applies except three hunks of `registers/requirements.yaml`, which is generated: OIP-0002
`registers.patch`, OIP-0003 `cases-invariants.patch` and OIP-0009 `registers.patch` change the case lists of
§5.8, §5.10 and §5.11 requirements, to which this proposal's cases add their own ids. Whichever proposal is accepted
second regenerates the index (`python3 tools/requirements.py`). The objects are inserted at the start of each
function's `objects` list and the invariant table is merged between `run_case` and `run` in `conformance.py`, where
no other draft edits. OIP-0011 and OIP-0012 add a profile at the same lines (profile register, suite, Makefile,
enumerations, §4.2, §7.1, §7.3), so whichever is accepted second is rebased on the first and renumbers its §7.x.
When OIP-0008 is accepted, the CorrectionNotice of the example set moves to the signature envelope with the rest of
`correction-notice`.

Relation rows to add at acceptance (left out of the patches, because `registers/implements-edges.json` is generated
from them and every draft that adds a row conflicts on its `count` line):

| Id | Standard | Kind | Schemas | Profile |
|---|---|---|---|---|
| `EXT-CCSDS-ODM` | CCSDS 502.0-B-3 Orbit Data Messages | aligns-with | `orbit-record` | `OBSP-CONSTELLATION` |
| `EXT-CCSDS-CDM` | CCSDS 508.0-B-1 Conjunction Data Message | aligns-with | `conjunction-record` | `OBSP-CONSTELLATION` |
| `EXT-CCSDS-CFDP` | CCSDS 727.0-B-5 CCSDS File Delivery Protocol | aligns-with | `downlink-record` | `OBSP-CONSTELLATION` |

STAPI gets no relation row: it is a community specification and the binding is a note.

## Tests

| Requirement | Case | Function | Kind | Evidence and invariants |
|---|---|---|---|---|
| CST-1 | CT-CONSTELLATION-001 | describe | schema | `orbit-record` |
| CST-6 | CT-CONSTELLATION-002 | time | invariant | `downlink-record`; `downlink-times-ordered` |
| CST-3 | CT-CONSTELLATION-003 | orchestrate | invariant | `tasking-order`; `tasking-transitions-monotonic` |
| CST-5, CST-7 | CT-CONSTELLATION-004 | observe | invariant | `tasking-order`, `downlink-record`; `tasking-fulfilment-linked` |
| CST-2 | CT-CONSTELLATION-005 | exchange | invariant | `conjunction-record`, `correction-notice`; `conjunction-update-supersedes` |
| CST-4 | CT-CONSTELLATION-006 | prove | invariant | `tasking-order`; `tasking-transitions-signed` |

Example set `conformance/examples/OBSP-CONSTELLATION/` (passes the profile, 6 of 6 requirements): an EO smallsat
tasking from feasibility to a delivered product (order with five signed transitions, the downlink over CFDP with an
L1C scene and an L2 flood mask processed onboard), and a conjunction update (version 1, version 2 and the
CorrectionNotice that supersedes version 1).

Example signatures. Every transition of every example and fixture order carries a real Ed25519 `COSE_Sign1` signature
(OIP-0008 envelope) made with example-only keys (`uni:key:requester-eo-desk-01`, `uni:key:provider-eo-ops-01`; seeds
derived from public labels, `testOnly`), and `previousDigest` chains the entries. The signatures are made by the
generator in `reference/python/obsp-space` (`python3 -m obsp_space resign-tasking`), which keeps each entry's content,
re-signs in order and rebuilds the chain; the entries of the two negative fixtures that break the signature rule
(`transition-without-signature`, `transition-legacy-signature`) are left as they are. The suite's invariant stays
structural, as above; the package's `verify_signatures` also checks the signature bytes, that the key's controller is the
actor and that the key was valid at the transition time.

Positive fixtures: `orbit-record` (`valid`, `omm-catalogue`), `conjunction-record` (`valid`, `update`),
`tasking-order` (`valid`, `executing`, `not-feasible`), `downlink-record` (`valid`, `relay`).

Negative fixtures, one broken rule each (the file name says which): `orbit-record.` `missing-epoch`,
`missing-reference-frame`, `missing-time-system`, `no-spacecraft-id`, `bad-cospar-id`, `odm-without-digest`,
`unknown-odm-format`, `missing-covariance-flag`, `missing-source`, `frame-other-without-name`, `epoch-not-rfc3339`;
`conjunction-record.` `cdm-without-digest`, `missing-tca`, `probability-above-one`, `negative-miss-distance`,
`miss-distance-not-metres`, `update-without-supersedes`, `first-version-supersedes`; `tasking-order.`
`unknown-state`, `skipped-transition`, `transition-from-terminal`, `first-transition-to-accepted`,
`transition-without-signature`, `transition-legacy-signature`, `cancelled-without-reason`,
`fulfilled-without-fulfilment`, `fulfilment-before-fulfilled`, `fulfilment-product-without-digest`, `empty-history`;
`downlink-record.` `missing-onboard-stored-at`, `missing-ground-station`, `cfdp-without-transaction`,
`onboard-product-at-l0`, `bad-processing-level`, `product-without-processing-level`, `onboard-without-model-run`,
`no-products`.

Unit tests (`sdk/python/tests/test_constellation.py`, 29 tests): every invariant passes on the example set and fails
on a targeted change (storage before acquisition, relay hop out of order or after the downlink, removed or reordered
transition, transition after a terminal state, edited entry, broken chain, DSSE envelope on a transition, downlink
missing or with another digest, product not downlinked, acquisition outside the window, downlink not naming the
order, overwritten conjunction version, update without its notice, wrong supersedes digest or version), and the
example set passes `conformance run --profile OBSP-CONSTELLATION`.

## External references

| Reference | Used for | Checked |
|---|---|---|
| CCSDS 502.0-B-3, Orbit Data Messages (OEM, OPM, OMM; reference-frame and time-system keywords) | `orbit-record.odm`, `referenceFrame`, `timeSystem` | partly: the April 2023 edition's OEM and OMM keyword tables and its `REF_FRAME` and `TIME_SYSTEM` value sets were read from the public document; other clauses not checked |
| CCSDS 508.0-B-1, Conjunction Data Message | `conjunction-record.cdm`, TCA, miss distance, probability | partly: the keyword tables of the June 2013 issue with corrigenda to Cor. 2 were read from the public document; other clauses not checked |
| CCSDS 727.0-B-5, CCSDS File Delivery Protocol (transaction id = source entity id and transaction sequence number) | `downlink-record.transfer.cfdp` | not checked |
| COSPAR international designator format; satellite catalogue number | `spacecraft.cosparId`, `noradCatalogNumber` | not checked |
| Processing levels L0 to L4 (earth-observation data processing level convention) | `processingLevel` | not checked |
| STAC API tasking extension ("STAPI"), community specification, not a standard | `externalRefs` (informative note) | not checked |

## Open questions

1. Is CCSDS 502.0-B-3 the current edition, and does it add the Orbit Comprehensive Message (OCM)? If so, should
   `odm.format` accept `OCM`? The enumeration follows the three messages the profile was asked to cover. Partly
   answered: the April 2023 edition of 502.0-B-3 defines the OCM (its section 6); whether it is the latest issue was not
   checked. The question of accepting `OCM` stays open.
2. The reference-frame and time-system enumerations are a subset of the ODM keyword values; should the schema take
   the full SANA register values instead (`OTHER` covers the rest today)? Reading the April 2023 value sets shows the
   draft enumerations are not a subset: the frame list there has no plain `ITRF` or `MOD` (it has ITRF2000, ITRF-93,
   ITRF-97) and the time-system list has GMST, MET, MRT, SCLK, TCB and TCG, which the draft's `timeSystem` lacks (the
   draft's `UT1` is in it). The reference tooling maps the ITRF values to `ITRF` and refuses the time systems.
3. Catalogue numbers beyond five digits and alphanumeric forms: is an integer up to 999999999 enough, or should a
   string form be allowed?
4. `correction-notice` has no reason code for a routine update with new data; the example uses `VALUE_ERROR`. Add
   `NEW_DATA` to the correction reasons (a change to §5.9's object)?
5. Should the signing key of each transition be constrained by role (requester signs `FEASIBILITY`, `ORDERED` and
   requester cancellations; provider signs the rest)? Today the actor is recorded and the signature binds it, but the
   role-to-transition table is not normative.
6. Should orbit records be signed (CST-1 makes `signature` optional today)?
