Skip to main content

Schema Reference

This page documents the complete behavioral contract YAML schema.

Auto-Generated

This page is automatically generated from corpus/schema/contract.schema.json. Do not edit manually. Run npm run docs:generate-schema to regenerate.

Top-Level Properties

PropertyTypeRequiredDescription
packagestringThe npm package name this contract applies to
semverstringSemver range this contract applies to
contract_versionstringSemver version of this contract file itself
maintainerstringGitHub username or team maintaining this contract
last_verifiedstringISO date when this contract was last verified against package documentation
status"production" | "draft" | "in-development" | "deprecated"Quality and validation status of this contract
deprecatedbooleanWhether this contract is deprecated
deprecated_reasonstringReason for deprecation
deprecated_datestringDate when this contract was deprecated
functionsArray<function> (see function)List of functions covered by this contract

Contract Metadata

package

The npm package name this contract applies to.

Type: string

Pattern: Follows npm package naming conventions (supports scoped packages).

Examples:

  • "axios"
  • "@prisma/client"
  • "stripe"

semver

Semantic version range this contract applies to.

Type: string

Examples:

  • ">=1.0.0 <2.0.0" - All 1.x versions
  • "^5.0.0" - 5.x compatible versions
  • "*" - All versions (use sparingly)

contract_version

Version of this contract file itself (not the package version).

Type: string

Format: major.minor.patch (semver)

Increment when:

  • Major: Breaking changes to contract structure
  • Minor: New functions, postconditions, or edge cases added
  • Patch: Fixes to descriptions or sources

status

Quality and validation status of this contract.

Type: enum

Values:

  • "production" - Fully verified and ready for use
  • "draft" - Initial version, not yet verified
  • "in-development" - Work in progress
  • "deprecated" - No longer maintained

Function Definition

Each contract contains an array of functions with their behavioral specifications.

Required Fields

FieldTypeDescription
namestringFunction name
import_pathstringHow this function is imported (e.g., 'axios', 'axios.default', 'axios/lib/core')
descriptionstringHuman-readable description of what this function does

Optional Fields

FieldTypeDescription
preconditionsArray<precondition> (see precondition)Conditions that must be true before calling this function
postconditionsArray<postcondition> (see postcondition)What happens after calling this function (returns/throws)
edge_casesArray<edge_case> (see edge_case)Known sharp edges and gotchas

Precondition Definition

Conditions that must be true before calling a function.

FieldTypeRequiredDescription
idstringUnique identifier for this precondition within the function
descriptionstringWhat must be true before calling the function
sourcestringURL to authoritative documentation supporting this claim
severity"error" | "warning" | "info"How critical is this precondition

Example:

preconditions:
- id: absolute-url-node
description: "URL must be absolute when running in Node.js"
source: "https://axios-http.com/docs/req_config"
severity: warning

Postcondition Definition

Outcomes that occur after calling a function (returns/throws).

FieldTypeRequiredDescription
idstringUnique identifier for this postcondition within the function
conditionstringWhen does this outcome occur
returnsstringWhat value is returned (if applicable)
throwsstringWhat error type is thrown (if applicable)
required_handlingstringWhat the caller MUST do to handle this case
sourcestringURL to authoritative documentation supporting this claim
severity"error" | "warning" | "info"How critical is this postcondition

Important: If severity: error, then required_handling is mandatory.

Example:

postconditions:
- id: network-failure
condition: "network error or timeout"
throws: "AxiosError with error.response === undefined"
required_handling: >
Caller MUST check if error.response exists before accessing it.
source: "https://axios-http.com/docs/handling_errors"
severity: error

Edge Case Definition

Known gotchas, sharp edges, and non-obvious behavior.

FieldTypeRequiredDescription
idstringUnique identifier for this edge case within the function
descriptionstringWhat the edge case is
sourcestringURL to documentation or GitHub issue describing this edge case
severity"warning" | "info"Edge cases cannot have error severity

Note: Edge cases can only have warning or info severity (not error).

Example:

edge_cases:
- id: timeout-default-zero
description: "Default timeout is 0 (no timeout). Production should set explicit timeout."
source: "https://axios-http.com/docs/req_config"
severity: info

Severity Levels

LevelMeaningWhen to Use
errorMust fix - causes crashes, data loss, security issuesUnhandled exceptions, missing required checks
warningShould fix - edge cases, performance issuesNon-critical but important issues
infoNice to know - best practices, gotchasEducational notes, best practices

Complete Example

package: axios
semver: ">=1.0.0 <2.0.0"
contract_version: "1.0.0"
maintainer: "corpus-team"
last_verified: "2026-02-27"
status: production

functions:
- name: get
import_path: "axios"
description: "Makes an HTTP GET request"

preconditions:
- id: absolute-url-node
description: "URL must be absolute in Node.js"
source: "https://axios-http.com/docs/req_config"
severity: warning

postconditions:
- id: network-failure
condition: "network error or timeout"
throws: "AxiosError"
required_handling: "Check error.response exists"
source: "https://axios-http.com/docs/handling_errors"
severity: error

edge_cases:
- id: timeout-default-zero
description: "Default timeout is 0"
source: "https://axios-http.com/docs/req_config"
severity: info

See Also