VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

Vocabulary Coding and Engineering | Semantic Contract Testing: Can Two Systems Prove They Use the Same Definition?

Educational illustration of a laptop, programming diagrams, notebook and network model

Two software systems can exchange perfectly valid data and still misunderstand the meaning of the values they exchange. One system sends approved: true after an editor reviews a document’s spelling. Another treats the same Boolean as permission to publish or release payment. The JSON is valid; the field exists; the API call succeeds. Yet the real handover has failed. Vocabulary Coding and Engineering proposes semantic contract testing: checking not only whether an interface sends the right fields, but whether both parties use the same source-defined states, eligibility boundaries, units, time conventions and authorised actions.

This proposal builds on established consumer-driven contract testing. Pact’s official documentationOpenAPIJSON Schema

Why a valid JSON message can still be wrong

A provider sends {"complete":true}. Its documentation defines complete as “the customer’s form was received”. The consumer interprets complete as “an authorised reviewer has accepted all supporting documents”. No parser error appears and both systems agree on the Boolean type.

The mismatch can cause payments, account access or customer notices to occur prematurely. The remedy is an interface contract that identifies the event and evidence behind complete, along with examples of received-but-not-reviewed cases.

What consumer-driven contract testing does

Pact lets a consumer express the specific interactions it relies upon and lets the provider verify those expectations. Its contracts describe example requests and responses rather than every conceivable use of a service. This can detect interface breakages before two components are deployed together.

A semantic extension would add task-specific meaning tests. The provider may guarantee a valid response with the right field while the consumer’s business assumption is still mistaken. Both levels must be evaluated independently rather than conflated.

Consumer and provider are roles, not always client and server

The consumer is the system using information and the provider is the system supplying it. They may communicate over HTTP, through a queue or via files. A human reader can also consume a statement from an institutional provider without using any software.

The same dependency problem exists in every case: what exactly was promised about the information? A reliable contract specifies the scope of what the provider guarantees and what the recipient must not infer.

A shared field name is not a shared concept

Two departments may both use active to describe accounts. One counts any login in 30 days; another requires a completed purchase. The label is identical, but the inclusion criteria differ.

A semantic contract maps each field to a scoped definition and source, rather than copying a familiar label into a common schema. The exchange can use distinct field names or an explicit conversion, but should not silently pretend the measures are interchangeable.

Structure and semantics need separate tests

JSON Schema can require properties, constrain types and restrict enumerated values. These checks catch malformed input and unsupported shapes. It cannot determine whether a Boolean approval refers to an editorial review or a payment authorisation.

A strong test suite reports structural pass and semantic pass separately. It can explain that the message is parseable but does not satisfy the consumer’s declared interpretation. A green schema check should never imply the entire business process is safe.

A proposed semantic-contract envelope

The exchange record can include a source definition ID, version, issuer, applicable domain, field name, data type, allowed states, effective interval and relevant examples. It also identifies who can approve changes to that definition.

This envelope is a proposed Vocabulary Coding and Engineering artifact, not an official Pact or OpenAPI feature. It should remain small enough to maintain and secure, while adding the details whose omission would change consequential decisions.

Not all approvals are authorisations

An editor approves a draft for spelling accuracy. A compliance officer approves a technical check. A director authorises publication. These events need separate status types even though a team may colloquially call all of them approval.

The contract can expose distinct fields or states and prohibit implicit promotion of one into another. A source message saying editorial_checked must not be used as permission to transfer money or publish without a separate valid authorisation.

The boundary example is part of the contract

Suppose an account qualifies at age 65 or older. A test exactly at age 65 reveals whether the provider and consumer mean the same threshold. Additional tests cover age 64 and 66 to confirm the boundary’s direction.

These examples make the meaning more concrete than a short prose definition. A contract consumer can test that the provider does not silently replace “at least” with “over” when translating the condition into SQL or a user-facing explanation.

Null, absent and false states

A provider sends an omitted verification field. The consumer sets its default to true. This creates an authorisation claim the provider never made. If the field is explicitly false, that may mean the verification failed; if null, it may mean the check was not performed.

The contract should define how unknown, not assessed, failed, passed and not applicable are represented. It must test missing-field behaviour, not only happy-path true and false values.

Dates need event types and conventions

A shipment status has a recorded timestamp. The provider means the scan was uploaded Thursday; the consumer assumes the parcel reached the recipient Thursday. A delivery-based refund clock begins on the wrong event.

The contract should distinguish event time, recording time and effective policy time, and specify timezone and duration units where they matter. A syntactically valid ISO timestamp cannot repair a wrongly chosen event.

Units must never be guessed

A temperature field contains 40. One system records Celsius, the other displays Fahrenheit. Both use numbers, but the interpreted physical quantities differ.

An operational contract attaches unit and quantity type to measurements, preserves conversion rules and includes representative tests. The same discipline applies to currencies, percentages, percentages points, population counts and durations.

The consumer may need fewer fields but stricter meaning

Consumer-driven contracts often test only the interactions the consumer relies upon. A reporting dashboard may require counts and stable definitions, while a payment system also needs explicit authorisation and exceptions. The two consumers do not necessarily need identical requirements.

The provider should publish clear guarantees per field and action. It may safely change unused data while preserving what one consumer needs, but should not treat a field’s changed meaning as backward-compatible solely because the data shape stayed the same.

Breaking changes can be invisible to schemas

A policy provider changes complete from form received to all evidence reviewed while keeping complete as a Boolean field. An OpenAPI or JSON Schema validation might still pass every message.

A semantic regression test should compare old and new outcomes on stored included and excluded examples. The release should document which consumers depend on the former meaning, what migrations are needed and how historical data remain interpretable.

Semantic versioning is task-dependent

A change that is compatible for a search interface can be breaking for a regulatory submission or payment. A broad search result might tolerate a close concept match; a direct eligibility rule may require exact source-defined criteria.

Version categories should be supported by concrete consumer tests and a separate human-impact note. A new version label cannot establish legal effect or turn a draft source into an operative rule.

Test the whole chain, not one API call

A provider’s source rule becomes a data field, then a mobile notice, then an AI summary and finally an automated decision. The original condition may survive the first interface while disappearing in the summary.

End-to-end checks should compare the final decision with the authoritative source, not just each adjacent pair of messages. Passing local contracts is useful but does not by itself guarantee a global semantic result.

Contract testing can expose incompatible local definitions

One organisation says verified when an email link was clicked. Another uses verified after an identity-document process. If the consumer assumes the latter, no amount of matching Boolean structure will make the two sources equivalent.

An honest contract may refuse the mapping and require an additional proof from the right authority. The objective is reliable interoperability, not forcing every similar word to denote one universal concept.

The test oracle needs source authority

Who decides whether the response has the right meaning? The source policy owner can specify its intended operational criteria. A technical reviewer can test implementation. A relevant legal authority may be needed for a disputed statutory definition.

These are different roles. An annotation team can establish a research reference for its benchmark without acquiring the power to change a law or approve a real person for a benefit.

A contract failure should be diagnosable

A test can fail because a field is absent, a value falls outside a type, the provider changed its business rule or an AI lost an exception. Reporting only “contract failed” leaves engineers guessing at the remedy.

A useful failure report identifies the violated source rule, counterexample, affected consumer and severity. It should also say whether the conclusion is certain or requires source clarification.

Privacy is part of the interface agreement

Adding full personal histories to every semantic envelope might improve traceability while introducing unjustified exposure. Most interoperability tests can use synthetic records and source definitions without distributing sensitive identity data.

A real implementation should limit shared evidence to what the task requires, apply access controls and respect retention and correction obligations. A successful contract test is not an authorisation to move personal information across organisations.

Worked example: a three-stage application

Fictional workflow: A service receives an application, checks its documents and decides eligibility. The first provider says documents_received; a second says verification_completed; a third says decision_approved. The statuses are related but not equivalent.

Construct cases with received-but-unreviewed documents, failed verification and accepted-but-not-yet-issued decisions. Test every consumer against its actual source contract so a later AI summary cannot turn the first stage into a final award.

What a good pilot would measure

A prototype can select ten public, non-sensitive status fields and build two consumer programs with deliberately different assumptions. Compare ordinary JSON validation with an extended semantic test suite on held-out boundary cases.

Report false alarms, caught differences, unresolved mappings and the time needed to maintain the contract. The proposed method earns value only if it improves practical correctness enough to justify its complexity. No empirical result is claimed in this article.

A semantic contract checklist

  • Provider: Source system and responsible owner.
  • Consumer: Actual application and decision that relies on the field.
  • Concept: Exact field sense and source reference.
  • Type: JSON or other structural representation.
  • States: Meaning of accepted, rejected, missing and exception values.
  • Boundaries: Positive, negative and threshold cases.
  • Time: Event timestamps, effective version and timezone.
  • Permissions: Which actions the value can and cannot authorise.
  • Compatibility: Previous consumers and release consequences.
  • Correction: Failures, migration owner and audit history.

Seven steps to build a semantic contract

  1. Identify the source definitions used by the provider.
  2. Ask each consumer which decisions it makes from the received values.
  3. Define the data structure and business meaning separately.
  4. Write counterexamples at thresholds, exceptions and unknown states.
  5. Run ordinary structural tests and source-based decision tests.
  6. Review changes under versioned compatibility and authority rules.
  7. Preserve failures, corrections and limits before real-world release.

A single successful payload is not a complete semantic contract

An example response {"approved":true} does not reveal who approved what or why. A consumer may incorrectly assume payment authorisation when the provider means an editor checked grammar. Both systems can pass ordinary JSON tests while interpreting the status differently.

Build an explicit state table for received, reviewed, authorised, denied, pending and disputed. Specify the evidence and actor behind each state, and prepare cases where a record has been received but no decision has occurred. This distinguishes business meaning from the shape of an API message.

Contract tests must deliberately include invalid interpretations

A provider should supply test cases containing missing authorisation, expired status and a revoked approval. A consumer that treats any nonempty status as permission to release funds should fail, even if every value satisfies the declared JSON data type.

Include appropriate negative controls so the test does not reject every unfamiliar value. Unknown and not applicable can be valid states under a documented contract. A good semantic test identifies whether the downstream action is supported, not merely whether the field is present.

Who may approve an altered contract?

Developers can author and verify test interactions, but a change to a legal eligibility rule or institutional payment policy may require the actual competent authority. A code review and a policy approval are different events, even if both are called approval.

Version the source definition and record which consumers use it. Where changes affect historical cases or live decisions, document the transition and a correction route. The test result demonstrates behaviour under stipulated criteria; it does not give a software team permission to rewrite obligations.

Frequently asked questions

Is semantic contract testing already a Pact feature?

Pact provides established consumer-driven integration contract testing. The additional business-meaning layer proposed here is an extension in the Vocabulary Coding and Engineering framework, not a Pact product feature or formal standard.

Can JSON Schema establish that a definition is correct?

No. It checks structural constraints on data. The correctness, applicability and authority of a definition require domain evidence and appropriate review.

What is the hardest semantic change to detect?

A meaning change that leaves field names, data types and ordinary example values unchanged can evade structural checks until a boundary or exception case appears.

Can two systems communicate without sharing every definition?

Yes. They need reliable agreement about the concepts and consequences relevant to the actual exchange. Other local terminology can remain different.

Conclusion: the interface contract must include what the data means

Computer systems do not share understanding merely because their messages parse. A semantic contract makes a narrower, testable claim: these fields mean these things, under these sources and dates, and produce these outcomes for these cases. Such a record can expose mismatches before they affect users, while maintaining clear limits between formatting, evidence and authority. The next stage for Z and MTP is not to abolish local vocabularies, but to make every consequential handover capable of saying exactly what was—and was not—agreed.

Sources and related reading

Editorial scope: Semantic contract testing is a proposed application of existing software contract-testing methods to operational meaning. Fictional examples do not establish a formal industry standard or permission to take real actions.