{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aisa.ablera.com/contracts/drafts/branch-set.schema.json",
  "title": "Branch set — DRAFT inter-stage contract (Development)",
  "x-status": "draft",
  "description": "Stage Planning § PL-3 / Development goals DG-2: the code a case is fixing, named before anything is fixed, across every repository plus the model and stored code on that environment's database. The customer lineage forked from master on 18.03.2025 (2a2bdbbca4); divergence is measured on demand, never quoted stale. Required core only (D139).",
  "type": "object", "additionalProperties": true,
  "required": ["case_id", "start_flow", "start_environment", "repositories", "database", "measured_on"],
  "properties": {
    "case_id": { "type": "string" },
    "start_flow": { "type": "string", "enum": ["running-product", "new-product"], "description": "source.start_flows (D63/D123): running products start on bulstrad-staging; new products (the health line) on bulstrad-qa" },
    "start_environment": { "type": "string" },
    "repositories": { "type": "array", "minItems": 1, "items": { "type": "object", "required": ["name", "layout", "branch", "head_sha"], "properties": {
      "name": { "type": "string", "description": "serdica-backend · serdica-ui · intentgpt · serdica-infrastructure" },
      "layout": { "type": "string", "enum": ["old", "new"], "description": "Software Architecture § 9.0: bulstrad-staging/prod = old flat layout; master/bulstrad-qa = new src/Serdica layout" },
      "branch": { "type": "string" }, "head_sha": { "type": "string" },
      "worktree_ref": { "type": "string", "description": "the isolated worktree this case works in" },
      "counterpart": { "type": "object", "properties": { "branch": { "type": "string" }, "head_sha": { "type": "string" }, "divergence_commits": { "type": "integer" }, "fork_point_sha": { "type": "string" }, "exists": { "type": "boolean" } } } } } },
    "database": { "type": "object", "required": ["environment", "stored_code"], "properties": { "environment": { "type": "string" }, "schema_model_ref": { "type": "string" }, "stored_code": { "type": "array", "items": { "type": "object", "required": ["schema", "object", "type", "signature", "snapshot_id"], "properties": { "schema": { "type": "string" }, "object": { "type": "string" }, "type": { "type": "string" }, "signature": { "type": "string", "pattern": "^[a-f0-9]{64}$" }, "signature_algorithm": { "type": "string", "const": "PLSQL-SIG-1" }, "snapshot_id": { "type": "string", "description": "PLSQL_SNAPSHOTS.ID — the precondition of the write grant (Stage Planning § 3b)" } } } } } },
    "deploy_targets": { "type": "array", "items": { "type": "object", "required": ["environment", "customer_facing"], "properties": { "environment": { "type": "string" }, "customer_facing": { "type": "boolean" }, "compose_unit": { "type": "string" }, "pipeline_rule": { "type": "string", "description": "D130: last build job of serdica-infrastructure, then the deployment-phase job naming the service" } } } },
    "measured_on": { "type": "string", "format": "date-time" }
  }
}
