Skip to content

Service Card

aryehcitron@gmail.com edited this page Nov 7, 2026 · 4 revisions

Service Card

service.json is a small JSON file that says what a service did in a test run: which parties it talked to, every operation between them, and why each call was made. A service catalogue, a dependency map or an indexer reads it without opening the report. kronikol card writes it from a report that has already been written (5.21.0):

kronikol card ./Reports -o service.json
kronikol card TestRunReport.krkl > service.json
Argument / option Meaning
<report> A TestRunReport.krkl or TestRunReport.json, or the directory holding one, resolved as kronikol query resolves it
-o, --out <file> Write the card to a file instead of stdout; its folder is created
-h, --help Show usage

It reads every report the tool reads, a 4.x TestRunReport.json as well as a 5.x TestRunReport.krkl, in one pass that never holds the report whole: a report of 2,000 scenarios is carded in about 300 ms. Exit 0 when the card is written; 1 when the file cannot be read, is no Kronikol report or is one this build cannot read, or the card cannot be written; 2 for a command it cannot take (--json among them: the card is always JSON).

On BreakfastProvider's lanes a card is 96 to 175 KB, where the report it is made from runs to megabytes.

Every run writes one (5.22.0)

From 5.22.0 a run writes service.json beside its report, with GenerateServiceCard on, its default. It is the card kronikol card writes from the data file the run has just written, byte for byte: written after the run's other outputs, from that file, and before Run.json, which lists it and carries its hash as serviceCard.behaviourHash (Generated Reports › Earlier runs). An indexer that keeps the last hash it read tells from Run.json alone whether the card changed.

  • A run whose data file is off (GenerateTestRunReportData = false) or written as XML writes no card and says nothing of it: the card is made from the JSON data file.
  • A card that cannot be written (the file held open by a reader) is no card of the run's: Run.json names no serviceCard, and the run warns on the console. Its bytes go to service2.json, as any output's do, and Run.json lists that file under files. The run itself does not fail.
  • kronikol ingest writes one, and kronikol merge writes one beside a merged report, from the merged data file.
  • It costs one more pass over the data file at the run's end: about 150 ms on a run of 2,000 scenarios. Set GenerateServiceCard = false to go without it.

Two parts: run and behaviour

The file has three members, formatVersion, run and behaviour, in that order:

  • run holds what moves from one run to the next: the run's id and end (from the Run.json beside the report, when that manifest lists the report and is not older than it, and null otherwise), the repository, commit and branch on CI, the suite, the report's file name, format version, the Kronikol that wrote it and its SHA-256, the environment, the scenario counts by result, behaviourHash, each party's hosts and the calls a test double answered, per operation the calls, errors, statuses and phases counted, one example address for each operation (sN/iM, which kronikol query opens), every operation each scenario reached, and the capture diagnostics the report recorded, counted by kind.
  • behaviour holds what the service does: the rules the card was made under, the party under test, the parties with their kinds, the edges between them, each edge's operations with their statuses, origins, causes and effective phases, the operations the service exposes, the messages it publishes and consumes, each scenario's own operations, the names no party id resolves, and what the capture could not see. Every list is sorted by ordinal comparison, and nothing in it counts anything.

Two runs of the same commit whose scenarios behave the same write the same behaviour bytes. On BreakfastProvider's lanes, ten pairs of runs of one commit gave byte-identical behaviour on all ten.

Operations

An operation is a caller, a callee, a protocol, a method and a target, with graphqlOperation for a GraphQL request. The target and the GraphQL operation are the call's operation key, the one Cross-Run History, the warm-up marks and the component diagram read (5.17.0), with the query string left out:

  • the target is the call's path, templated: /orders/123 and /orders/456 are /orders/{n}. A Service Bus queue, an S3 bucket, an EventBridge bus and a Redis database, which their trackers write where a host would go, are kept as the first segment, so a send to servicebus://orders/ is on /orders;
  • a statement's call adds the statement's first line, its values templated: INSERT INTO orders (id, dish) VALUES (7, 'pancakes') on /orders is /orders INSERT INTO orders (id, dish) VALUES ({n}, '{s}'). That holds for SQL, past the SET statements EF Core sends first, and for a document whose top-level query member is a string, as Cosmos DB's and BigQuery's queries are;
  • graphqlOperation is the operation a GraphQL request names, read from a POST's body or a GET's query string (query Menu, mutation PlaceOrder), or batch for a batch of them.

A run's own templating rules, HistoryShapeTemplates, shape the target as they shape history's, read from the report's shapeTemplates block (5.19.0). behaviour.rules.templateRules says which rules those were: their hash, the one history records as shapeRules; none for a run that had none; null for a report that cannot say, written before 5.19.0 or by Kronikol4J.

An operation's op is the first 16 hex characters of the SHA-256 of those parts, so one operation has one id in every card, and a new one adds an id and moves no other.

Each operation lists:

Member Values
statuses the status codes or labels its calls answered, none for a call with no answer
origins test (the test's own client), subject (the service under test), other (any other party)
causes test (the test made it), request (made while the service served a request: inside a call the service received, or marked by the request's headers), background (made with no request in progress: a hosted service, a timer, the report's background block), unknown (no attribution was recorded and no call encloses it)
effectivePhases setup or action as the call recorded it, else its enclosing call's when it was made inside one, else unknown

Limits, stated so they are not mistaken for behaviour:

  • Seeding through the service's own client (the test resolves the service's repository and writes with it) reads as origin subject and cause background: the call is the service's client's, made with no request in progress.
  • An in-process service with nothing declared reads as the test: with no ServiceId and no parties declared, the inference cannot tell the service's calls from the test's when both run in the test's process and context. Declare the service (ServiceId, or Parties with underTest) and its calls read as subject.
  • A producer that records no attribution (an ingested capture, a proxy tap) gives cause and effectivePhases from nesting alone, which is only as good as the order the producer recorded its calls in.

behaviour.exposes lists the operations the service under test received, deliveries and user actions apart, with basis: "tested": the surface the run tested, not everything the service serves.

Messages

behaviour.messages lists each message call between the service and a broker: publishes for the service's send or publish, consumes for its receive or for the broker's delivery into it, with the broker and the topic or queue. A delivery into the service is never an operation it exposes. Settlement and management calls (completing a message, committing an offset, creating a queue) are operations on their edge and no message, and so is the fault MassTransit records when a consumer throws.

A label the card does not know, from a tracker newer than the card's writer, has no direction rather than a guessed one. At Raw, the SQS, SNS, Storage Queues and EventBridge trackers record the HTTP request itself, whose verb and endpoint name neither the direction nor the queue, so those rows have direction and topic null.

behaviour.capture.emptyTargets lists the message operations whose address names no destination where one belongs (Kafka at Summarised writes kafka:///), or only a tracker's placeholder (servicebus://unknown/), so an indexer does not read them as one queue.

Parties

behaviour.parties comes from the report's parties block when the run declared something (see Report Configuration), else from the inference over the report's calls, with kindSource: "inferred" on the rows it inferred and rules.inference naming the inference's version. A name with no id is listed in behaviour.unresolved.

The card is a function of the report alone, so kronikol card on a kept report writes the card its run wrote. What a run observed of its test clients and did not write reaches the card only through the parties block, which the run writes when it declares something.

behaviour.subject is the party under test: the underTest party whose id is the run's ServiceId, else the one that received the most calls, the first by name on a tie; a declared subject no call reaches is still the subject, and listed. A run with no party under test has no subject, no exposed operations and no messages. The parties, the subject and each call's origin and cause are the ones kronikol query parties and its origin and cause read (5.20.0), so the card and the query never disagree about who a party is or why a call was made.

behaviourHash

run.behaviourHash is the SHA-256 of the behaviour member's bytes exactly as the file holds them. The file is written compact, on one line, with behaviour last, so those bytes run from the { after the last "behaviour": to the byte before the file's closing }. Check it over that range, never over a copy written again by a JSON library (jq -c and Python's json change the escapes):

python3 -c 'import hashlib,json,sys
data = open(sys.argv[1], "rb").read().rstrip(b"\n")
start = data.rindex(b"\"behaviour\":") + len(b"\"behaviour\":")
print(hashlib.sha256(data[start:-1]).hexdigest() == json.loads(data)["run"]["behaviourHash"])' service.json

An indexer compares two runs by the hash and reads the card only when it moved. These move it with no change of behaviour, and each is visible in the card:

  • the card's own rules: the operation key, the templating rules or the inference, which behaviour.rules records;
  • a Kronikol upgrade that records more or names a party anew (5.13.0 named a call to an unmapped host by its host, where it was localhost:443; 5.16.0 marks the calls a stub handler answered as a test double; 5.27.14 keeps a method as the run wrote it, where a merge read Delete as DELETE and a verb built by hand was written in capitals, which moves a call's op once; 5.31.2 follows a call past a handler that hands it on, so a party reached through one can change kind once), which run.report.kronikolVersion tells;
  • the platform: an SDK that makes a call on one OS and not another (the Cosmos DB SDK asks the gateway for a query plan on Linux only), which run.environment tells;
  • the titles Kronikol makes, when an upgrade writes a feature or scenario title differently (5.16.5 keeps the words a method's name writes in capitals).

Schema

The card's JSON Schema is schemas/service-card.v1.schema.json, draft 2020-12. A member a later version adds does not move formatVersion, which names the card's shape, and a reader ignores members it does not know. The schema's objects are closed, so a newer card fails validation against an older copy of it: validate against the copy on main.

Home · 🔍 Search this wiki Full-text search across every page. The “Pages” list above matches page and heading names, not page content.


Demo


Getting Started

Common Tasks

Integration Guides

Uninstrumentable / polyglot backends

Extensions

Configuration

Features

Reference

Clone this wiki locally