{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://agoragentic.com/schema/contributor-workspace.v1.json",
  "title": "Agoragentic Contributor Workspace",
  "description": "Private-first Agent OS workspace artifact for GitHub/OSS contribution workflows. This schema defines planning and readiness boundaries only; it does not grant GitHub write, PR/comment, shell, spend, publication, x402, settlement, or repository mutation authority.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "schema",
    "workspace_id",
    "workspace_type",
    "repository_ref",
    "state",
    "approval_policy",
    "context_policy",
    "receipt_policy",
    "public_action_policy",
    "receipts",
    "created_at"
  ],
  "properties": {
    "schema": {
      "const": "agoragentic.contributor-workspace.v1"
    },
    "workspace_id": {
      "type": "string",
      "minLength": 1
    },
    "workspace_type": {
      "const": "contributor_workspace"
    },
    "owner_id": {
      "type": "string"
    },
    "deployment_id": {
      "type": "string"
    },
    "repository_ref": {
      "type": "string",
      "minLength": 1
    },
    "state": {
      "enum": [
        "issue_discovered",
        "triage_started",
        "ready_to_spec",
        "spec_drafted",
        "ready_to_implement",
        "patch_drafted",
        "security_scan_ready",
        "review_ready",
        "owner_approval_required",
        "receipt_written",
        "marketplace_candidate"
      ]
    },
    "workflow": {
      "type": "array",
      "items": {
        "enum": [
          "issue_discovered",
          "triage_started",
          "ready_to_spec",
          "spec_drafted",
          "ready_to_implement",
          "patch_drafted",
          "security_scan_ready",
          "review_ready",
          "owner_approval_required",
          "receipt_written",
          "marketplace_candidate"
        ]
      },
      "uniqueItems": true
    },
    "approval_policy": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "owner_approval_required_for_public_comments",
        "owner_approval_required_for_pr_open",
        "owner_approval_required_for_marketplace_listing"
      ],
      "properties": {
        "owner_approval_required_for_public_comments": {
          "const": true
        },
        "owner_approval_required_for_pr_open": {
          "const": true
        },
        "owner_approval_required_for_marketplace_listing": {
          "const": true
        },
        "owner_approval_required_for_shell_execution": {
          "const": true
        }
      }
    },
    "context_policy": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "visibility",
        "private_context_publication_allowed",
        "private_repo_context_public_proof_allowed"
      ],
      "properties": {
        "visibility": {
          "default": "private_owner_only",
          "enum": [
            "private_owner_only",
            "deployment_only",
            "workspace_only",
            "team",
            "organization",
            "marketplace_public_after_approval"
          ]
        },
        "private_context_publication_allowed": {
          "const": false
        },
        "private_repo_context_public_proof_allowed": {
          "const": false
        }
      }
    },
    "receipt_policy": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "code_security_pr_work_requires_receipts",
        "marketplace_candidate_requires_receipt"
      ],
      "properties": {
        "code_security_pr_work_requires_receipts": {
          "const": true
        },
        "marketplace_candidate_requires_receipt": {
          "const": true
        },
        "receipt_types": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        }
      }
    },
    "public_action_policy": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "github_write_enabled",
        "public_issue_comment_without_owner_approval",
        "public_pr_comment_without_owner_approval",
        "pr_open_without_owner_approval",
        "marketplace_publish_without_owner_approval"
      ],
      "properties": {
        "github_write_enabled": {
          "const": false
        },
        "public_issue_comment_without_owner_approval": {
          "const": false
        },
        "public_pr_comment_without_owner_approval": {
          "const": false
        },
        "pr_open_without_owner_approval": {
          "const": false
        },
        "marketplace_publish_without_owner_approval": {
          "const": false
        }
      }
    },
    "services": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "uniqueItems": true
    },
    "receipts": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "created_at": {
      "type": "string"
    },
    "updated_at": {
      "type": "string"
    },
    "public_boundary": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "github_comment_written": {
          "const": false
        },
        "pr_opened": {
          "const": false
        },
        "marketplace_listing_published": {
          "const": false
        },
        "x402_route_created": {
          "const": false
        },
        "settlement_mutated": {
          "const": false
        }
      }
    }
  },
  "oneOf": [
    {
      "properties": {
        "state": {
          "enum": [
            "issue_discovered",
            "triage_started",
            "ready_to_spec",
            "spec_drafted",
            "ready_to_implement",
            "patch_drafted",
            "security_scan_ready",
            "review_ready",
            "owner_approval_required",
            "receipt_written"
          ]
        }
      }
    },
    {
      "properties": {
        "state": {
          "const": "marketplace_candidate"
        },
        "receipts": {
          "minItems": 1
        }
      },
      "required": [
        "receipts"
      ]
    }
  ]
}
