{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:ledgermath:api:v1:series-list",
  "title": "LedgerMath data API, version 1: the list of Series",
  "description": "v1/series.json: one row per Series, each with the address of its own file, and each Method's own words for what its numbers mean. A Series is the Runs of one benchmark, parameter set (params), build, instance type and Availability Zone ID. A versioned Method turns a Series' Runs into a Derivation; a row holds a summary of each Method's Derivation of the Series under derivations, keyed <method name>_v<version>, and the Series' file holds them in full. The row's figures are the Derivations' own, at the same paths, nothing rounded, less the bulky parts. The histograms are in the Series' file. The lists of Runs behind each figure are in no file: each is recovered from the points of the Series' month files (the Series' file lists them), in order of start, then Run id: for a percentile of time per repetition, every counted point; for a percentile of bytes per second, every counted point whose bytes_per_repetition is not null; for a group, under either Method, the points with that group's letter, counted or not, and then, for one of the group's percentiles, the same filter as the Series' percentile of that statistic. Each row is written on one line of its own. Each benchmark's rows are also in a file of their own, v1/benchmarks/<benchmark>.json, which the table of contents lists (benchmarks), byte for byte as they are here when both files are of one update, so that a reader need not fetch this whole list to find one Series; the table of contents says when the two can differ and which rows are in no such file (benchmarks.about), and counts them. Version 1 only ever gains fields: a field, once in a v1 file, keeps its name, its type and its meaning, and a reader ignores any field it does not know, which is why no object in this schema forbids members it does not list. A new Method, or a new version of one, is a new key beside the old ones. A change that would break a reader is published as v2, beside v1.",
  "type": "object",
  "required": ["schema", "schema_url", "index", "url", "count", "newest_run_started_at", "methods", "series"],
  "properties": {
    "schema": { "description": "What this file is, and which version of its shape.", "const": "ledgermath.api.series-list/1" },
    "schema_url": { "description": "The address of this schema.", "$ref": "#/$defs/url" },
    "index": { "description": "The address of the table of contents, v1/index.json.", "$ref": "#/$defs/url" },
    "url": { "description": "This file's own address.", "$ref": "#/$defs/url" },
    "count": { "description": "How many Series are listed.", "type": "integer", "minimum": 0 },
    "newest_run_started_at": {
      "description": "When the newest Run of any Series started; null when there is no Series.",
      "anyOf": [{ "$ref": "#/$defs/time" }, { "type": "null" }]
    },
    "methods": {
      "description": "Each Method's own words, as LedgerMath's Method writes them beside its Derivations, keyed <method name>_v<version>: how each number is made, what splits a Series into groups, and the Run files it read and could not read. A Run file that does not validate against the Run schema is in no Series; it is listed here, under unreadable, with why and the address of the file.",
      "type": "object",
      "required": ["series_v1", "requests_v1"],
      "properties": {
        "series_v1": {
          "description": "Method series, version 1: every Series; one number per Run, and the 5th, 50th and 95th percentiles across Runs.",
          "type": "object",
          "required": ["method", "definitions", "split_on", "left_out", "not_split_on", "runs_read", "unreadable", "sections"],
          "properties": {
            "method": { "$ref": "#/$defs/method_series" },
            "definitions": { "$ref": "#/$defs/definitions" },
            "split_on": { "description": "The facts a Series is split into groups on, in order.", "type": "array", "items": { "$ref": "#/$defs/split_fact" } },
            "left_out": { "description": "What is left out of a dump section before it is compared for the split, and why.", "type": "array", "items": { "$ref": "#/$defs/left_out" } },
            "not_split_on": { "description": "Facts the Runs record that do not split a Series, and why.", "type": "array", "items": { "$ref": "#/$defs/split_fact" } },
            "runs_read": { "description": "Run files read.", "type": "integer", "minimum": 0 },
            "unreadable": { "description": "The Run files it could not read, in order of path: each does not validate against the Run schema, so it is in no Series.", "type": "array", "items": { "$ref": "#/$defs/unreadable" } },
            "sections": {
              "description": "How often each dump section's hash changed, over every Run read: the evidence for the split facts. Counts of Runs and of pairs of consecutive Runs.",
              "type": "array",
              "items": {
                "type": "object",
                "required": ["section", "runs", "changed_within_run", "boot_pairs", "changed_within_boot", "series_pairs", "changed_between_runs", "split_on"],
                "properties": {
                  "section": { "description": "The dump section's name.", "type": "string" },
                  "runs": { "description": "Runs whose before-dump or after-dump holds the section.", "type": "integer", "minimum": 0 },
                  "changed_within_run": { "description": "Of those, the Runs whose before-dump and after-dump hold different hashes for it, or only one of which holds it.", "type": "integer", "minimum": 0 },
                  "boot_pairs": { "description": "Pairs of consecutive Runs of one boot, whatever their Series, at least one of whose before-dumps holds the section. A pair neither of whose before-dumps holds it is not counted for it, so the count can differ from section to section.", "type": "integer", "minimum": 0 },
                  "changed_within_boot": { "description": "Of those, the pairs whose before-dumps hold different hashes for it, or only one of which holds it.", "type": "integer", "minimum": 0 },
                  "series_pairs": { "description": "Pairs of consecutive Runs of one Series, summed over every Series, at least one of whose before-dumps holds the section. A pair neither of whose before-dumps holds it is not counted for it: a section the dumps began to hold later is counted only from the pair where it first appears, so the count can differ from section to section.", "type": "integer", "minimum": 0 },
                  "changed_between_runs": { "description": "Of those, the pairs whose before-dumps hold different hashes for it, or only one of which holds it.", "type": "integer", "minimum": 0 },
                  "split_on": { "description": "The split fact read from the section, or null.", "anyOf": [{ "type": "string" }, { "type": "null" }] }
                }
              }
            }
          }
        },
        "requests_v1": {
          "description": "Method requests, version 1: the Series whose samples are requests; each phase of a request, across the requests, within each Run and pooled across Runs.",
          "type": "object",
          "required": ["method", "definitions", "phases", "percentiles", "histogram", "request_facts", "split_on", "left_out", "runs_read", "unreadable"],
          "properties": {
            "method": { "$ref": "#/$defs/method_requests" },
            "definitions": { "$ref": "#/$defs/definitions" },
            "phases": { "description": "The phases of a request, each an interval between two of its events, in nanoseconds of the Run's clock.", "type": "array", "items": { "$ref": "#/$defs/phase_word" } },
            "percentiles": { "description": "The percentiles reported, and the fewest requests that support each.", "type": "array", "items": { "$ref": "#/$defs/percentile_support" } },
            "histogram": { "$ref": "#/$defs/histogram_definition" },
            "request_facts": { "description": "The facts each request records of its connection or of itself.", "type": "array", "items": { "$ref": "#/$defs/request_fact" } },
            "split_on": { "description": "Method series v1's split facts, which give the same groups.", "type": "array", "items": { "$ref": "#/$defs/split_fact" } },
            "left_out": { "description": "Method series v1's: what is left out of a dump section before it is compared for the split, and why.", "type": "array", "items": { "$ref": "#/$defs/left_out" } },
            "runs_read": { "description": "Run files read, of every kind.", "type": "integer", "minimum": 0 },
            "unreadable": { "description": "The Run files it could not read, in order of path: each does not validate against the Run schema, so it is in no Series.", "type": "array", "items": { "$ref": "#/$defs/unreadable" } }
          }
        }
      }
    },
    "series": {
      "description": "One row per Series, in the order benchmark, instance type, zone ID, params, build.",
      "type": "array",
      "items": { "$ref": "#/$defs/row" }
    }
  },
  "$defs": {
    "url": { "description": "An address: an absolute URL starting http:// or https://.", "type": "string", "pattern": "^https?://" },
    "time": { "description": "UTC, to the nanosecond, as the Run records it.", "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?Z$" },
    "method_series": {
      "description": "The Method, by name and version: series, version 1.",
      "type": "object",
      "required": ["name", "version"],
      "properties": { "name": { "description": "The Method's name: series.", "const": "series" }, "version": { "description": "The Method's version: 1.", "const": 1 } }
    },
    "method_requests": {
      "description": "The Method, by name and version: requests, version 1.",
      "type": "object",
      "required": ["name", "version"],
      "properties": { "name": { "description": "The Method's name: requests.", "const": "requests" }, "version": { "description": "The Method's version: 1.", "const": 1 } }
    },
    "definitions": { "description": "How each number is made, in the Method's words, by name.", "type": "object", "additionalProperties": { "description": "One definition, in the Method's words, under the name of what it defines.", "type": "string" } },
    "split_fact": {
      "description": "A fact the Runs record, by name, with the Method's words for it: under split_on, a fact a Series is split into groups on, and where it is read from; under not_split_on, one or more Run fields or dump sections that do not split a Series, and why.",
      "type": "object",
      "required": ["fact", "what"],
      "properties": {
        "fact": { "description": "The fact's name. In split_on, the name under which a group's facts give its value; in not_split_on, the Run fields or dump sections it names, separated by commas when there are more than one.", "type": "string" },
        "what": { "description": "In the Method's words: in split_on, what the fact is and where it is read from; in not_split_on, why it does not split a Series.", "type": "string" },
        "section": { "description": "The dump section it is read from, if it is.", "type": "string" }
      }
    },
    "left_out": {
      "description": "Something the Method leaves out of a dump section before it compares the section for the split: the section, and what is left out and why, in the Method's words.",
      "type": "object",
      "required": ["section", "what", "why"],
      "properties": {
        "section": { "description": "The dump section it is left out of.", "type": "string" },
        "what": { "description": "What is left out of the section, in the Method's words.", "type": "string" },
        "why": { "description": "Why it is left out, in the Method's words.", "type": "string" }
      }
    },
    "unreadable": {
      "description": "A Run file the Method could not read: it does not validate against the Run schema, so it is in no Series.",
      "type": "object",
      "required": ["id", "path", "sha256", "reason", "evidence"],
      "properties": {
        "id": { "description": "The Run file's name without .json, taken from its path whatever the file holds.", "type": "string" },
        "path": { "description": "The Run file's path, runs/<yyyy>/<mm>/<dd>/<id>.json: the name LedgerMath gives it, and its address under the API's base (evidence).", "type": "string" },
        "sha256": { "description": "The sha256 of the Run file's bytes, in hex.", "type": "string", "pattern": "^[0-9a-f]{64}$" },
        "reason": { "description": "Why it does not validate against the Run schema: each error the validator gives, with where in the file it is, joined by \"; \".", "type": "string" },
        "evidence": { "description": "The Run file's address.", "$ref": "#/$defs/url" }
      }
    },
    "phase_word": {
      "description": "One phase of a request: its key, its name in words, and which two of the request's events it is the interval between.",
      "type": "object",
      "required": ["phase", "name", "interval"],
      "properties": {
        "phase": { "description": "The phase's key, as each phase's statistics are keyed: dns, connect, tls, send, first_byte, headers, body or total.", "type": "string" },
        "name": { "description": "The phase in words, such as name lookup.", "type": "string" },
        "interval": { "description": "Which two of the request's event timestamps the phase is the difference of, in words, and over which connections it applies.", "type": "string" }
      }
    },
    "percentile_support": {
      "description": "One percentile the Method reports, by name and per mille, with the fewest requests that support it.",
      "type": "object",
      "required": ["name", "per_mille", "least_requests"],
      "properties": {
        "name": { "description": "The percentile's name, as the statistics are keyed: p50, p90, p95, p99 or p99.9.", "type": "string" },
        "per_mille": { "description": "The percentile as a whole number per mille: 500 for p50, 999 for p99.9.", "type": "integer" },
        "least_requests": { "description": "The fewest requests that support it: at least one request is then expected above it.", "type": "integer" }
      }
    },
    "histogram_definition": {
      "description": "How each phase's times are tallied in fixed bins, the same for every Run, so that the tallies of different Runs add: a pooled percentile is read from the summed bins.",
      "type": "object",
      "required": ["bins_per_doubling", "exact_below_ns", "precision", "definition"],
      "properties": {
        "bins_per_doubling": { "description": "How many bins each doubling of time is cut into, from exact_below_ns on.", "type": "integer" },
        "exact_below_ns": { "description": "Below this many nanoseconds, every nanosecond is a bin of its own.", "type": "integer" },
        "precision": { "description": "A pooled percentile is within this fraction of the exact percentile of the same requests.", "type": "number" },
        "definition": { "description": "How a time's bin is found, in the Method's words.", "type": "string" }
      }
    },
    "request_fact": {
      "description": "One fact the Method records for each counted request that succeeded, by name, with the Method's words for what it is and which event it is read from.",
      "type": "object",
      "required": ["fact", "what"],
      "properties": {
        "fact": { "description": "The request fact's name, as a pool's breakdowns (by) and values (facts) name it.", "type": "string" },
        "what": { "description": "What the request fact is and which event it is read from, in the Method's words.", "type": "string" }
      }
    },
    "params": {
      "description": "The parameter set, as each Run was given it (LM_PARAM_*).",
      "type": "object",
      "additionalProperties": { "description": "One parameter's value, under the parameter's name, as each Run was given it.", "anyOf": [{ "type": "string" }, { "type": "number" }, { "type": "boolean" }] }
    },
    "stat_summary": {
      "description": "Percentiles of time per repetition across the Series' counted Runs. Every counted Run has a time per repetition. A counted Run's time per repetition is infinite, past a double's range, when it is the mean of its two middle samples' ns_per_repetition and their sum overflows (both near the top of a double's range; no real clock comes near): JSON cannot hold it, so its point shows null, and it is counted here all the same; a percentile taken from it, or interpolated towards it, is null. The Runs behind them are the Series' counted points, as its month files hold them.",
      "type": "object",
      "required": ["count", "p5", "p50", "p95"],
      "properties": {
        "count": { "description": "Counted Runs.", "type": "integer", "minimum": 1 },
        "p5": { "description": "The 5th percentile of the counted Runs' times per repetition (count of them), in nanoseconds, by linear interpolation between closest ranks (R type 7). Null when it is infinite or undefined: taken from, or interpolated towards, an infinite time per repetition.", "$ref": "#/$defs/number_or_null" },
        "p50": { "description": "The 50th percentile of the counted Runs' times per repetition (count of them), in nanoseconds, by linear interpolation between closest ranks (R type 7). Null when it is infinite or undefined: taken from, or interpolated towards, an infinite time per repetition.", "$ref": "#/$defs/number_or_null" },
        "p95": { "description": "The 95th percentile of the counted Runs' times per repetition (count of them), in nanoseconds, by linear interpolation between closest ranks (R type 7). Null when it is infinite or undefined: taken from, or interpolated towards, an infinite time per repetition.", "$ref": "#/$defs/number_or_null" }
      }
    },
    "bytes_per_second_summary": {
      "description": "Percentiles of bytes per second across the Series' counted Runs that observed a finite bytes per repetition above 0. A Run among them whose bytes per second is infinite, past a double's range (chiefly one whose time per repetition is 0), cannot have it written in JSON: it is counted here all the same, and a percentile taken from it, or interpolated towards it, is null. The Runs behind them are the Series' counted points whose bytes_per_repetition is not null, as its month files hold them.",
      "type": "object",
      "required": ["count", "p5", "p50", "p95"],
      "properties": {
        "count": { "description": "Counted Runs that observed a finite bytes per repetition above 0, a Run with a bytes per second that is not a finite number included.", "type": "integer", "minimum": 1 },
        "p5": { "description": "The 5th percentile of the bytes per second of the counted Runs that observed a finite bytes per repetition above 0 (count of them), by linear interpolation between closest ranks (R type 7). Null when it is infinite or undefined: taken from, or interpolated towards, a bytes per second that is not a finite number.", "$ref": "#/$defs/number_or_null" },
        "p50": { "description": "The 50th percentile of the bytes per second of the counted Runs that observed a finite bytes per repetition above 0 (count of them), by linear interpolation between closest ranks (R type 7). Null when it is infinite or undefined: taken from, or interpolated towards, a bytes per second that is not a finite number.", "$ref": "#/$defs/number_or_null" },
        "p95": { "description": "The 95th percentile of the bytes per second of the counted Runs that observed a finite bytes per repetition above 0 (count of them), by linear interpolation between closest ranks (R type 7). Null when it is infinite or undefined: taken from, or interpolated towards, a bytes per second that is not a finite number.", "$ref": "#/$defs/number_or_null" }
      }
    },
    "request_stats": {
      "description": "One phase over a set of requests, in nanoseconds: the count of requests, the least and greatest time, and each percentile the count supports (null when it does not), with how many requests are ranked at or above each one reported.",
      "type": "object",
      "required": ["count", "min", "max", "p50", "p90", "p95", "p99", "p99.9", "at_or_above"],
      "properties": {
        "count": { "description": "How many requests the figures are of: those of the set that succeeded and had this phase.", "type": "integer", "minimum": 0 },
        "min": { "description": "The least of their times, in nanoseconds, exactly.", "type": "number" },
        "max": { "description": "The greatest of their times, in nanoseconds, exactly.", "type": "number" },
        "p50": { "description": "The 50th percentile of their times, in nanoseconds, read from the summed histogram: within 1/128 of the exact percentile of the same requests. Null when count is under 2, too few to support it.", "$ref": "#/$defs/number_or_null" },
        "p90": { "description": "The 90th percentile of their times, in nanoseconds, read from the summed histogram: within 1/128 of the exact percentile of the same requests. Null when count is under 10, too few to support it.", "$ref": "#/$defs/number_or_null" },
        "p95": { "description": "The 95th percentile of their times, in nanoseconds, read from the summed histogram: within 1/128 of the exact percentile of the same requests. Null when count is under 20, too few to support it.", "$ref": "#/$defs/number_or_null" },
        "p99": { "description": "The 99th percentile of their times, in nanoseconds, read from the summed histogram: within 1/128 of the exact percentile of the same requests. Null when count is under 100, too few to support it.", "$ref": "#/$defs/number_or_null" },
        "p99.9": { "description": "The 99.9th percentile of their times, in nanoseconds, read from the summed histogram: within 1/128 of the exact percentile of the same requests. Null when count is under 1000, too few to support it.", "$ref": "#/$defs/number_or_null" },
        "at_or_above": {
          "description": "For each percentile reported, how many requests are ranked at or above it (ties counted by rank).",
          "type": "object",
          "properties": {
            "p50": { "description": "How many requests are ranked at or above the 50th percentile; absent when it is not reported.", "type": "integer" },
            "p90": { "description": "How many requests are ranked at or above the 90th percentile; absent when it is not reported.", "type": "integer" },
            "p95": { "description": "How many requests are ranked at or above the 95th percentile; absent when it is not reported.", "type": "integer" },
            "p99": { "description": "How many requests are ranked at or above the 99th percentile; absent when it is not reported.", "type": "integer" },
            "p99.9": { "description": "How many requests are ranked at or above the 99.9th percentile; absent when it is not reported.", "type": "integer" }
          }
        }
      }
    },
    "number_or_null": { "description": "A number, or null.", "anyOf": [{ "type": "number" }, { "type": "null" }] },
    "phase_stats": {
      "description": "Each phase's statistics, by phase; a phase no request had is absent (dns, connect and tls over a kept connection).",
      "type": "object",
      "properties": {
        "dns": { "$ref": "#/$defs/request_stats" },
        "connect": { "$ref": "#/$defs/request_stats" },
        "tls": { "$ref": "#/$defs/request_stats" },
        "send": { "$ref": "#/$defs/request_stats" },
        "first_byte": { "$ref": "#/$defs/request_stats" },
        "headers": { "$ref": "#/$defs/request_stats" },
        "body": { "$ref": "#/$defs/request_stats" },
        "total": { "$ref": "#/$defs/request_stats" }
      }
    },
    "row": {
      "description": "One Series.",
      "type": "object",
      "required": ["id", "url", "benchmark", "params", "build", "instance_type", "availability_zone_id", "runs", "oldest_run_started_at", "newest_run_started_at", "derivations"],
      "properties": {
        "id": { "description": "The Series' id: the first 12 hex digits of the sha256 of its key (benchmark, params, build, instance type, zone ID) as canonical JSON.", "type": "string", "pattern": "^[0-9a-f]{12}$" },
        "url": { "description": "The address of the Series' own file, v1/series/<id>.json.", "$ref": "#/$defs/url" },
        "benchmark": { "description": "The benchmark's name, as its Runs give it.", "type": "string" },
        "params": { "$ref": "#/$defs/params" },
        "build": { "description": "The named build of the benchmark (static, dynamic).", "type": "string" },
        "instance_type": { "description": "The EC2 instance type, as the provider names it.", "anyOf": [{ "type": "string" }, { "type": "null" }] },
        "availability_zone_id": { "description": "The Availability Zone ID, as the provider names it.", "anyOf": [{ "type": "string" }, { "type": "null" }] },
        "runs": { "description": "Runs in the Series, counted or not.", "type": "integer", "minimum": 1 },
        "boots": { "description": "How many boots its Runs were made on: the distinct boots its points name, counted or not. A boot is one fresh machine; each point names its boot (boot) and links its summary (boot_summary). Written since layout 2 (the layout of v1/index.json); a row written before it lacks it.", "type": "integer", "minimum": 1 },
        "oldest_run_started_at": { "description": "When its oldest Run started.", "$ref": "#/$defs/time" },
        "newest_run_started_at": { "description": "When its newest Run started: the moment a citation of the Series as it stands names.", "$ref": "#/$defs/time" },
        "derivations": {
          "description": "A summary of each Method's Derivation of the Series, keyed <method name>_v<version>. Method series v1 derives every Series; Method requests v1 only those whose samples are requests, and its key is absent from the others.",
          "type": "object",
          "required": ["series_v1"],
          "properties": {
            "series_v1": {
              "description": "A summary of Method series v1's Derivation of the Series.",
              "type": "object",
              "required": ["method", "counted_runs", "failed_runs", "groups", "percentiles"],
              "properties": {
                "method": { "$ref": "#/$defs/method_series" },
                "counted_runs": { "description": "Runs this Method counts.", "type": "integer", "minimum": 0 },
                "failed_runs": { "description": "Runs it does not count: shown in their month's file with why, in no percentile.", "type": "integer", "minimum": 0 },
                "groups": { "description": "How many groups its split facts make of the Series' Runs.", "type": "integer", "minimum": 1 },
                "percentiles": {
                  "description": "Across every counted Run of the Series, whatever its group. time_per_repetition_ns is null when no Run counts; bytes_per_second is null when no counted Run observed a finite bytes per repetition above 0.",
                  "type": "object",
                  "required": ["time_per_repetition_ns", "bytes_per_second"],
                  "properties": {
                    "time_per_repetition_ns": { "description": "Nanoseconds per repetition: each Run's median over its counted samples.", "anyOf": [{ "$ref": "#/$defs/stat_summary" }, { "type": "null" }] },
                    "bytes_per_second": { "description": "Bytes per second: each Run's bytes per repetition × 10^9 / its time per repetition in nanoseconds.", "anyOf": [{ "$ref": "#/$defs/bytes_per_second_summary" }, { "type": "null" }] }
                  }
                }
              }
            },
            "requests_v1": {
              "description": "A summary of Method requests v1's Derivation of the Series; absent when that Method does not derive it.",
              "type": "object",
              "required": ["method", "counted_runs", "failed_runs", "groups", "pool"],
              "properties": {
                "method": { "$ref": "#/$defs/method_requests" },
                "counted_runs": { "description": "Runs this Method counts (exit 0, or 4 with failed requests).", "type": "integer", "minimum": 0 },
                "failed_runs": { "description": "Runs it does not count: shown in their month's file with why, left out of its request statistics.", "type": "integer", "minimum": 0 },
                "groups": { "description": "How many groups its split facts, Method series v1's, make of the Series' Runs.", "type": "integer", "minimum": 1 },
                "pool": {
                  "description": "Every succeeded request of the Series' counted Runs, pooled: each phase's statistics, read from the summed histogram (the Series' file holds the histograms, and the breakdowns by request fact).",
                  "type": "object",
                  "required": ["runs", "requests", "failed", "phases"],
                  "properties": {
                    "runs": { "description": "Counted Runs.", "type": "integer", "minimum": 0 },
                    "requests": { "description": "Succeeded requests.", "type": "integer", "minimum": 0 },
                    "failed": { "description": "Failed requests, never timed.", "type": "integer", "minimum": 0 },
                    "phases": { "$ref": "#/$defs/phase_stats" }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
