Assess and publish a water-level observation#

What this demonstrates#

This example exact-reads compatible historical measures, assesses a new finite measurement with the offline deterministic script, prepares an immutable observation, and submits it only with an explicit write grant and stable idempotency key. Synthetic IDs and hashes make the publication flow reproducible without writing to production.

Example input#

The exact-read current measurement and compatible history are reduced to the script’s bounded input contract:

{
  "current": {
    "water_level": {
      "value": 1.8,
      "unit": "m",
      "method": "gauge"
    }
  },
  "history": [
    {
      "artifact_id": "hist-1",
      "subject": "harbor-a",
      "measures": {
        "water_level": {
          "value": 1.0,
          "unit": "m",
          "method": "gauge"
        }
      }
    },
    {
      "artifact_id": "hist-2",
      "subject": "harbor-a",
      "measures": {
        "water_level": {
          "value": 1.1,
          "unit": "m",
          "method": "gauge"
        }
      }
    },
    {
      "artifact_id": "hist-3",
      "subject": "harbor-a",
      "measures": {
        "water_level": {
          "value": 1.2,
          "unit": "m",
          "method": "gauge"
        }
      }
    }
  ],
  "subject": "harbor-a",
  "history_complete": true,
  "minimum_samples": 3,
  "deviation_sigma": 2.0
}

Workflow#

  1. The host exact-reads the current source and historical artifacts in trusted project scope. It owns service authentication, response bounds, and canonical artifact retrieval.

  2. The skill workflow selects only finite measures with the same subject, unit, and compatible method, and records whether history is complete.

  3. The offline script scripts/assess_measurements.py assess computes the mean, sample standard deviation, z-score, status, and included artifact IDs. It performs no service access.

  4. The skill workflow prepares a typed observation draft preserving source lineage, evidence, limitations, units, method, valid time, geometry, and opaque extensions.

  5. The host accepts gkb_publish only when trusted run context grants gkb.write; it validates and renders the draft, derives identity, and performs the immutable commit with the unchanged idempotency key.

  6. The skill workflow reports persistence only from the host’s successful commit result.

Example output#

Running the command below produces this exact structured output:

{
  "data": {
    "assessments": {
      "water_level": {
        "deviation_sigma": 2.0,
        "direction": "above",
        "mean": 1.0999999999999999,
        "method": "gauge",
        "sample_artifact_ids": [
          "hist-1",
          "hist-2",
          "hist-3"
        ],
        "sample_standard_deviation": 0.09999999999999998,
        "samples": 3,
        "status": "deviates",
        "unit": "m",
        "value": 1.8,
        "z_score": 7.0000000000000036
      }
    },
    "history_complete": true,
    "method": "scaled_arithmetic_mean_sample_standard_deviation_z_score",
    "subject": "harbor-a"
  },
  "ok": true,
  "provenance": {
    "implementation": "assess_measurements.py/2.0.0"
  },
  "status": "complete",
  "truncated": false,
  "warnings": []
}

Draft publication request#

Assessment does not publish anything. Authorization is a trusted host-run precondition and is not accepted from this JSON. If the run already has gkb.write, the host can accept this synthetic typed draft, justified relations, and stable key:

{
  "idempotency_key": "delta-harbor-a-water-level-20260801-v1",
  "artifact": {
    "kind": "observation",
    "subject": "harbor-a",
    "valid_time": "2026-08-01T12:00:00Z",
    "geometry": {
      "type": "Point",
      "coordinates": [
        -89.15,
        29.22
      ]
    },
    "measures": {
      "water_level": {
        "value": 1.8,
        "unit": "m",
        "method": "gauge"
      }
    },
    "derived_from": [
      "survey-delta-104",
      "hist-1",
      "hist-2",
      "hist-3"
    ],
    "evidence": [
      {
        "sha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
        "role": "calibrated_gauge_reading"
      }
    ],
    "limitations": [
      "single gauge location"
    ],
    "extensions": {
      "urn:example:assessment:v1": {
        "status": "deviates",
        "z_score": 7.0000000000000036
      }
    }
  },
  "relations": [
    {"type": "derived_from", "target_artifact_id": "survey-delta-104"},
    {"type": "derived_from", "target_artifact_id": "hist-1"},
    {"type": "derived_from", "target_artifact_id": "hist-2"},
    {"type": "derived_from", "target_artifact_id": "hist-3"}
  ]
}

The request remains uncommitted input: there is no durable artifact ID or persistence claim. The host derives authorization, project, and execution identity from trusted context, validates and renders the draft, and must return commit success. For demonstration, this synthetic fixture stands in for a host-supplied result; it is not evidence of a production write:

{
  "publication_state": "committed",
  "artifact_id": "gkb:observation:delta-harbor-a-water-level-20260801-v1",
  "content_hash": "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
  "idempotency": {
    "key": "delta-harbor-a-water-level-20260801-v1",
    "disposition": "created"
  },
  "relations_created": [
    {
      "type": "derived_from",
      "target_artifact_id": "survey-delta-104"
    },
    {
      "type": "derived_from",
      "target_artifact_id": "hist-1"
    },
    {
      "type": "derived_from",
      "target_artifact_id": "hist-2"
    },
    {
      "type": "derived_from",
      "target_artifact_id": "hist-3"
    }
  ],
  "indexing_warnings": []
}

Corrections, assertions, and inferences#

A correction exact-reads its target and appends a new immutable artifact; it never edits the old one. A compact correction request is:

{
  "idempotency_key": "delta-harbor-a-water-level-20260801-correction-v1",
  "artifact": {
    "kind": "observation",
    "subject": "harbor-a",
    "valid_time": "2026-08-01T12:00:00Z",
    "measures": {
      "water_level": {"value": 1.75, "unit": "m", "method": "calibrated_gauge"}
    },
    "supersedes": ["gkb:observation:delta-harbor-a-water-level-20260801-v1"],
    "derived_from": ["gauge-calibration-20260802"],
    "limitations": ["post-event calibration correction"]
  },
  "relations": [
    {
      "type": "supersedes",
      "target_artifact_id": "gkb:observation:delta-harbor-a-water-level-20260801-v1"
    },
    {"type": "derived_from", "target_artifact_id": "gauge-calibration-20260802"}
  ]
}

Reusing either idempotency key with changed canonical content is a conflict and fails closed. Assertions must identify the claimed proposition and supporting evidence. Inferences must identify their method/model revision, inputs, uncertainty, and limitations; neither may be mislabeled as a direct observation.

Human-readable result#

The 1.8 m gauge reading is 7 sample standard deviations above the complete three-observation baseline (mean 1.1 m, sample standard deviation 0.1 m), so the deterministic assessment marks it deviates. The draft preserves the gauge method, unit, exact lineage, evidence hash, limitation, and assessment extension. It becomes durable only after an authorized host commit returns a stable artifact ID and content hash. An identical retry reuses the same idempotency key.

Limitations#

  • Top-level complete means the assessment computation succeeded. History completeness is the separate host-asserted history_complete field; when it is false, each compatible measure uses incomplete_baseline rather than inferential statistics.

  • incomplete_baseline suppresses inferential statistics. insufficient_baseline means complete history did not meet the minimum compatible sample count.

  • deviates is a deterministic threshold result, not a domain conclusion or publication grant.

  • A draft has not been committed and carries no durable-write status. Only a host result can establish a committed artifact, its durable ID, content hash, idempotency disposition, relations, and warnings.

  • Reusing a key with changed canonical content is a conflict. Fail closed; never choose a new key to hide the change. Corrections append a new artifact with supersedes.

Reproduce#

From the repository root, run the same assessment with inline JSON:

printf '%s\n' '{"current":{"water_level":{"value":1.8,"unit":"m","method":"gauge"}},"history":[{"artifact_id":"hist-1","subject":"harbor-a","measures":{"water_level":{"value":1.0,"unit":"m","method":"gauge"}}},{"artifact_id":"hist-2","subject":"harbor-a","measures":{"water_level":{"value":1.1,"unit":"m","method":"gauge"}}},{"artifact_id":"hist-3","subject":"harbor-a","measures":{"water_level":{"value":1.2,"unit":"m","method":"gauge"}}}],"subject":"harbor-a","history_complete":true,"minimum_samples":3,"deviation_sigma":2.0}' | python3 skills/geonemo-gkb-publish/scripts/assess_measurements.py assess | python3 -m json.tool

The command ends at assessment. An authorized publication requires the host’s gkb_publish capability; no skill-local command can commit the synthetic draft.