Choose what this site may use

This site uses strictly necessary cookies to work and to remember your privacy choices. With your permission it would also load content hosted by other services, such as videos, maps and fonts, which then receive your network address and device data. We do not sell or share your personal information and we run no advertising. Choose Accept all, Reject all or Customise. You can change your mind at any time through Privacy choices at the foot of every page.

  • Always on

    Needed for the site to work and to remember your privacy choices. Always on.

  • Remembers settings you choose, such as the light or dark display, in your browser.

  • Loads videos, maps and other content hosted by other services. Those services receive your address and device data.

Menu Close
In this section: Build
Start
Reference code
Tools
API reference
Public services
Agents
Bindings and crosswalks

Node agent (obsp-node)

REFERENCE Source reference/rust/README.md

FieldValue
StatusReference code; no conformance claim
Version0.0.1
SourceRust reference workspace
 input adapter                 records.rs                          outbox.rs               lib.rs (flush)
 JSON lines  --\                                                                                       POST
                >-- Reading -> QC (RANGE, STEP) -> observation  -> replay batch -> append  -> attempt  -----> gateway
 Sparkplug   --/    (passport    time-quality, provenance,        (batchId =    + fsync     line,       /node-ingest/
 JSON (draft        in force)    quality-flag records;             digest of               settled on  v0.1/replay-
 OIP-0007)                       OIP-0008 envelope on each         the cut)                any answer  batches
                                 observation; key record and
                                 passports published once
cargo run -p obsp-node -- run --config obsp-node/tests/data/node.json --input obsp-node/tests/data/readings-1.jsonl \
    --gateway http://127.0.0.1:8080 --root ../..
cargo run -p obsp-node -- replay --config obsp-node/tests/data/node.json --gateway http://127.0.0.1:8080
cargo run -p obsp-node -- status --config obsp-node/tests/data/node.json
cargo run -p obsp-node -- apply-plan --config <node.json> --plan <plan.json> [--now <rfc3339>]

(The sample configuration writes its outbox next to itself; copy obsp-node/tests/data/ somewhere else to try it.) Exit status: 0 every batch settled and every event acked; 1 an event or a plan was refused; 2 a usage, configuration or input error; 3 batches remain queued because the gateway did not answer.

  • Configuration (src/config.rs): the node manifest and every sensor passport are validated against the live schemas and the passports must name the manifest’s node. The signing key is read from a file (32-byte seed in hexadecimal); obsp-node/tests/data/node-key.hex is a test key whose seed is derived from a public label.
  • Adapters (src/adapters.rs): JSON lines (passportUni, property, resultTime, value, resultState; a null value is MISSING, never zero) and decoded Sparkplug B payloads as JSON per the draft binding of OIP-0007 (native id from the topic, the connector mapping’s fields and quality table, seq modulo 256 per edge node with gaps recorded, NDEATH only for the current birth bdSeq, transient and unmapped metrics never in a result, STATE and commands never converted). Missing-data records and unmapped fields go to the run summary, not into observation records (their connector-output contract is a draft). Protobuf decoding is not done.
  • Records (src/records.rs): observation records of the live schema (3.1.0) with inline quality flags, a time-quality record per batch from the declared clock source, a PROV-O provenance record per batch (raw input lines used by one acquisition activity of the node’s software agent), quality-flag records for every SUSPECT or BAD flag of the node’s own tests, references by UNI and RFC 8785 digest. Each observation carries an OIP-0008 draft envelope (Ed25519, object class observation); the live observation-record schema refuses a signature member today, so the gateway and obsp-verify check signed observations without the member against the live schema and the member against the draft envelope schema. The STEP limit comes from the passport’s extensions."obsp.qc".rateOfChange, a convention of this agent. With the feature obsp-0.2 and "recordVersion": "4.0.0" the observation follows the OIP-0006 shape of the 0.2 series, with origin and subject class (checked against the series’ schema); a gateway refuses those records unless it serves the 0.2 candidate (see “The 0.2 candidate”).
  • Outbox and replay (src/outbox.rs): every batch is appended and flushed to disk before it is sent; each transmission is recorded first (attempt), and any HTTP answer settles the batch (5xx and no answer leave it queued). The batch is a live replay-batch; batchId is the digest of its ordered event ids and payload digests, so a retry keeps it, and attempt never changes an event id or payload digest. Each request carries an Obsp-Request-Context and an Idempotency-Key (rb-<batch>-a<attempt>).
  • Signed plans (src/plans.rs): the node-side decision of the draft OIP-0003 (rollback and replay, expiry, threshold with distinct root-listed keys, mix-and-match, freeze, root chaining, the reserved tasking kind), returning OBS-PLAN-0001 to -0007 before any state change. Beyond the draft’s reference decision, a signature counts only when its COSE_Sign1 signature verifies over the role’s payload. apply-plan refuses without a trusted root (trustedRoot, standing in for the bootstrap bundle member the draft leaves open) or without trusted time, and writes its trusted state only on acceptance. Every node vector of the draft gives its listed codes (obsp-node/tests/vectors/oip-0003/, copied).

Node intake of the gateway (feature ingest)

No operation of the gateway OpenAPI carries observations from a node, so the intake is a reference aid under its own base path, /node-ingest/v0.1, and not a protocol contract:

Route What it does
POST /replay-batches a live replay-batch with the rules of every consequential call (RequestContext, Idempotency-Key, media type, schema, idempotent replay, answer validated, store flushed first); the context’s tenant must be the batch’s. Per event: ACCEPTED; IDEMPOTENT_REPLAY (same id, same payload digest); CONFLICT (same id, other digest; never acked); REJECTED (payload digest not the RFC 8785 digest of the payload, unknown event type, payload failing its schema, a key record naming another controller than the batch’s node, or a signature that does not verify against the node’s key records received so far). Answer: a live replay-batch-result
GET /records the stored events in arrival order (nodeUni, eventType, limit, offset), without payloads
GET /records/{eventId} the payload exactly as received, ETag its digest

Event types: observatory.node.observation.recorded, .timequality.recorded, .provenance.recorded, .qualityflag.recorded, .passport.published, .key.published. Accepted events are written to the gateway’s store (and its file) like every other write. The intake appraises nothing and enrols nothing; the claims stay REPLAY_BATCH_NOT_AUTHORITY and REPLAY_BATCH_RESULT_NOT_READINESS.

Usage policies (feature policy, draft OIP-0014)

Off by default; built with --features policy and switched on with --policy-dir <dir> (policies and consent records, each validated against the copied OIP-0014 schemas; --default-policy <uni> for records that name none). Then every event payload of an intake batch, every record read back (GET /node-ingest/v0.1/records/{eventId}) and every observation served as an exchange item is decided by the obsp-policy enforcement point. The request attributes come from the RequestContext’s extensions["obsp.policy"] (purpose, recipient class, region, aggregation, consent references, community approval; the action defaults to use, the time to the gateway’s clock); without them the request is denied (OBS-GOV-0001, deny by default). A record names its policy at extensions["obsp.policy"] (policyUni or target; an exchange item falls back to its product’s policy) and its sensitivity flags at extensions["obsp.policy"].flags. These are NON-normative reference conventions (see the open questions in obsp-policy/README.md).

A refusal answers 403 with a problem document valid against error-problem: category POLICY_DENIED, errorCode the first OBS-GOV code, one violation per reason naming its rule (field the requirement id, code the reason code) and policyDecisionRef the decision’s UNI. A refused intake batch stores nothing; an observation a flag withholds is left out of an item list and refused when asked for alone (OBS-GOV-0007). Tests: obsp-gateway/tests/policy.rs.