{
  "openapi": "3.0.3",
  "info": {
    "title": "PitchStation Issues API",
    "version": "2026-11-21",
    "description": "Space-owned issue tracking with manual/AI capture, protected uploads, independently authorized versioned artifact references, progress, comments, assignment and human-reviewed agent resolution. Team-wide Issue reading (2026-11-06). With ISSUES_ENABLED=1, an active human who is currently a member of the exact active Team associated through active spaces.team_id may list/search/read Issue details, activity and bound-upload attachments across all that Team’s active issue-associated Spaces without a Space role. Paused intake preserves browsing and otherwise-authorized comments. Read and write access helpers are separate: creation, upload staging and AI drafting retain the former explicit Space membership/ownership plus current exact Team membership gate; existing operation-specific intake/routing requirements remain. Comments retain the former explicit Space member/owner plus current exact Team membership gate; issue.permissions.comment is authoritative. Team-only reading grants no write, manager or eligible-owner authority. Editing, progress, status, approval and resolution requirements remain unchanged. Team membership grants neither underlying Space documents nor artifact access; artifact references retain independent authorization and exact-version semantics. Public links, platform-admin status alone, service accounts, inactive humans/Teams/Spaces and another Team’s membership grant no Issue-read bypass. Revocation and changed Team association fail closed immediately. Sharing an Issue URL grants no access; each recipient needs their own authorization. The separate Team admin progress action retains its existing admin-only operational projection. Authorized Team/Space routing settings and destination metadata remain available while reporting is off; issue reads, filing, attachments, drafting and Team progress still require the server flag. Every mutation requires an Idempotency-Key retained for 30 days; issue mutations also require expected_revision and expected_ownership_epoch. Draft generation has no durable mutation. Uploads: 15 MB/file, 10 references and 50 MB/issue, 500 MB/uploader; unbound staging expires in 24 hours. Current account state and applicable Team/Space roles are checked on every call. Owner lifecycle hooks and a 30-second maintenance pass reconcile routing. Human resolution approvals are session-only, single-use and expire after 15 minutes. Fixed status (2026-11-21): Fixed sits between In Progress and Resolved and means a fix exists and its automated tests passed; it waits for review. Only the current eligible owner sets Fixed (from Open, In Progress or Fixed), in a session or with an issues:write personal token, and only with a passing verification record (IssueVerificationInput), which is stored and shown literally and never fetched. Resolution stays the owner's human review by default; a per-Space setting agent_auto_resolve, off by default and turned on only by a Team owner or admin who manages the Space in a web session, lets the owner's token resolve with a passing record instead of an approval_id. Restoring a backup turns it off. No route or scope changed."
  },
  "servers": [
    {
      "url": "https://pitchstation.ai"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/issues/notification-preferences": {
      "get": {
        "summary": "Read the current human's opt-in Issue notification preferences",
        "description": "Optional email follow-up, switched off by default. Both ISSUES_ENABLED and ISSUES_NOTIFICATIONS_ENABLED must be exactly 1, read per request; otherwise returns 404 FEATURE_DISABLED before authentication and stores/sends nothing. Only active human accounts have preferences; personal tokens retain their declared scope and current authorization checks. No MCP tool exposes these routes. Preferences are all false for existing and new accounts. Per-Issue mute overrides every preference and watch. Provider acceptance is not delivery or proof of reading. No notification centre is created. An optional issue_id additionally returns this human's default/watch/mute state after current Issue read authorization; global preferences require no Issue membership. Reads do not opt the account in.",
        "operationId": "get_api_issues_notification_preferences",
        "x-required-scope": "issues:read",
        "parameters": [
          {
            "name": "issue_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional protected Issue identifier for its saved watch state."
          }
        ],
        "responses": {
          "200": {
            "description": "Saved values, with false defaults and optional per-Issue watch state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "preferences"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "preferences": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "assigned",
                        "reported",
                        "digest"
                      ],
                      "properties": {
                        "assigned": {
                          "type": "boolean",
                          "description": "Assignment and reassignment to the current human."
                        },
                        "reported": {
                          "type": "boolean",
                          "description": "Progress and resolution of Issues reported by the current human."
                        },
                        "digest": {
                          "type": "boolean",
                          "description": "Daily reminders for assigned Issues without recent progress."
                        }
                      }
                    },
                    "watch": {
                      "type": "string",
                      "enum": [
                        "default",
                        "watch",
                        "mute"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or missing Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Active human account and the required personal token scope are required; service accounts have no preferences.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "FEATURE_DISABLED unless both ISSUES_ENABLED and ISSUES_NOTIFICATIONS_ENABLED are exactly 1, checked before authentication. For an issue_id, inaccessible Issues fail closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Save the current human's opt-in Issue notification preferences",
        "description": "Optional email follow-up, switched off by default. Both ISSUES_ENABLED and ISSUES_NOTIFICATIONS_ENABLED must be exactly 1, read per request; otherwise returns 404 FEATURE_DISABLED before authentication and stores/sends nothing. Only active human accounts have preferences; personal tokens retain their declared scope and current authorization checks. No MCP tool exposes these routes. Preferences are all false for existing and new accounts. Per-Issue mute overrides every preference and watch. Provider acceptance is not delivery or proof of reading. No notification centre is created. Requires all three boolean fields and no other body keys. Every exact retry uses the same Idempotency-Key and body; idempotency records last 30 days. Saving preferences sends no notification.",
        "operationId": "put_api_issues_notification_preferences",
        "x-required-scope": "issues:write",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "assigned",
                  "reported",
                  "digest"
                ],
                "properties": {
                  "assigned": {
                    "type": "boolean",
                    "description": "Assignment and reassignment to the current human."
                  },
                  "reported": {
                    "type": "boolean",
                    "description": "Progress and resolution of Issues reported by the current human."
                  },
                  "digest": {
                    "type": "boolean",
                    "description": "Daily reminders for assigned Issues without recent progress."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Preferences confirmed saved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "preferences"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "preferences": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "assigned",
                        "reported",
                        "digest"
                      ],
                      "properties": {
                        "assigned": {
                          "type": "boolean",
                          "description": "Assignment and reassignment to the current human."
                        },
                        "reported": {
                          "type": "boolean",
                          "description": "Progress and resolution of Issues reported by the current human."
                        },
                        "digest": {
                          "type": "boolean",
                          "description": "Daily reminders for assigned Issues without recent progress."
                        }
                      }
                    },
                    "watch": {
                      "type": "string",
                      "enum": [
                        "default",
                        "watch",
                        "mute"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or missing Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Active human account and the required personal token scope are required; service accounts have no preferences.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "FEATURE_DISABLED unless both ISSUES_ENABLED and ISSUES_NOTIFICATIONS_ENABLED are exactly 1, checked before authentication. For an issue_id, inaccessible Issues fail closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "IDEMPOTENCY_CONFLICT when a key is reused with a different body. Watch changes also reject stale revision or ownership epoch; refresh and review instead of automatically replaying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "JSON body exceeds 4 KiB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/issues/{id}/watch": {
      "put": {
        "summary": "Set the current human's watch or mute state for an authorized Issue",
        "description": "Optional email follow-up, switched off by default. Both ISSUES_ENABLED and ISSUES_NOTIFICATIONS_ENABLED must be exactly 1, read per request; otherwise returns 404 FEATURE_DISABLED before authentication and stores/sends nothing. Only active human accounts have preferences; personal tokens retain their declared scope and current authorization checks. No MCP tool exposes these routes. Preferences are all false for existing and new accounts. Per-Issue mute overrides every preference and watch. Provider acceptance is not delivery or proof of reading. No notification centre is created. Current exact-Team Issue read permission is rechecked before saving. The request requires the displayed Issue's expected_revision and expected_ownership_epoch, and an Idempotency-Key. An exact retry reuses the unchanged key and body; stale state or changed ownership requires a fresh read and deliberate action. Mute always wins; default follows the account's preferences. Watch does not grant Issue access or underlying artifact access.",
        "operationId": "put_api_issues_id_watch",
        "x-required-scope": "issues:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "watch",
                  "expected_revision",
                  "expected_ownership_epoch"
                ],
                "properties": {
                  "watch": {
                    "type": "string",
                    "enum": [
                      "default",
                      "watch",
                      "mute"
                    ]
                  },
                  "expected_revision": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "expected_ownership_epoch": {
                    "type": "integer",
                    "minimum": 1
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-Issue watch state confirmed saved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "watch"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "watch": {
                      "type": "string",
                      "enum": [
                        "default",
                        "watch",
                        "mute"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or missing Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Active human account and the required personal token scope are required; service accounts have no preferences.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "FEATURE_DISABLED unless both ISSUES_ENABLED and ISSUES_NOTIFICATIONS_ENABLED are exactly 1, checked before authentication. For an issue_id, inaccessible Issues fail closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "IDEMPOTENCY_CONFLICT when a key is reused with a different body. Watch changes also reject stale revision or ownership epoch; refresh and review instead of automatically replaying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "JSON body exceeds 4 KiB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/issues/events": {
      "post": {
        "summary": "Record bounded, identifier-free Issue adoption events",
        "description": "Optional pilot telemetry, disabled by default. ISSUES_METRICS_ENABLED is read for every request and enables this route only when exactly 1. Otherwise the route returns 404 FEATURE_DISABLED before authentication, including for anonymous callers, and stores nothing. When enabled, accepts an active human session (current user JWT or same-origin session cookie) or a personal API token with issues:write; service accounts and disabled accounts are refused. Membership and product-operation authorization remain separate from telemetry. Accepts 1–20 events per batch and at most 16 KiB of JSON; all event names, attribute keys and enum values are allowlisted. attrs may be omitted and defaults to an empty object except issues_create_outcome, which requires a non-created outcome. Durable creation, progress, comment, assignment, transition, approval and notification outcomes are server-only and cannot be claimed through this route. Stores only daily counters and bounded enum dimensions, never text, actor/Team/Space/Issue identifiers, URLs, filenames, draft-session identifiers or approval values. Exports suppress slices with fewer than five distinct contributing actors; only bounded, transient actor sets are held in process memory to determine suppression, and aggregates retain 90 UTC days. Rate limit: 60 requests per minute per human account, shared across that account’s sessions and personal tokens; with full batches, at most 1,200 accepted events per minute. Each accepted event increments exactly one aggregate counter. This telemetry route has no Idempotency-Key requirement or deduplication: do not automatically retry a request whose outcome is uncertain, as a retry can increment counters again. The browser sends fire-and-forget batches and stops for the page after FEATURE_DISABLED. No MCP tool exposes this endpoint.",
        "operationId": "post_api_issues_events",
        "x-required-scope": "issues:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "events"
                ],
                "properties": {
                  "events": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "items": {
                      "oneOf": [
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_entry_opened"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "global",
                                    "team",
                                    "space",
                                    "artifact",
                                    "review",
                                    "direct",
                                    "agent"
                                  ]
                                },
                                "width": {
                                  "type": "string",
                                  "enum": [
                                    "phone",
                                    "tablet",
                                    "desktop"
                                  ]
                                },
                                "language": {
                                  "type": "string",
                                  "enum": [
                                    "en",
                                    "zh",
                                    "other"
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_list_loaded"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "global",
                                    "team",
                                    "space",
                                    "artifact",
                                    "review",
                                    "direct",
                                    "agent"
                                  ]
                                },
                                "width": {
                                  "type": "string",
                                  "enum": [
                                    "phone",
                                    "tablet",
                                    "desktop"
                                  ]
                                },
                                "language": {
                                  "type": "string",
                                  "enum": [
                                    "en",
                                    "zh",
                                    "other"
                                  ]
                                },
                                "view": {
                                  "type": "string",
                                  "enum": [
                                    "all",
                                    "reported",
                                    "assigned",
                                    "team",
                                    "space"
                                  ]
                                },
                                "duration": {
                                  "type": "string",
                                  "enum": [
                                    "under_1s",
                                    "1_to_5s",
                                    "5_to_25s",
                                    "over_25s"
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_composer_opened"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "global",
                                    "team",
                                    "space",
                                    "artifact",
                                    "review",
                                    "direct",
                                    "agent"
                                  ]
                                },
                                "capability": {
                                  "type": "string",
                                  "enum": [
                                    "reporter",
                                    "owner",
                                    "manager",
                                    "reader"
                                  ]
                                },
                                "eligible": {
                                  "type": "boolean",
                                  "enum": [
                                    false,
                                    true
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_destination_blocked"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "global",
                                    "team",
                                    "space",
                                    "artifact",
                                    "review",
                                    "direct",
                                    "agent"
                                  ]
                                },
                                "capability": {
                                  "type": "string",
                                  "enum": [
                                    "reporter",
                                    "owner",
                                    "manager",
                                    "reader"
                                  ]
                                },
                                "reason": {
                                  "type": "string",
                                  "enum": [
                                    "no_team",
                                    "no_route",
                                    "no_space_role",
                                    "paused_intake",
                                    "no_owner",
                                    "server_off"
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_destination_selected"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "global",
                                    "team",
                                    "space",
                                    "artifact",
                                    "review",
                                    "direct",
                                    "agent"
                                  ]
                                },
                                "capability": {
                                  "type": "string",
                                  "enum": [
                                    "reporter",
                                    "owner",
                                    "manager",
                                    "reader"
                                  ]
                                },
                                "eligible": {
                                  "type": "boolean",
                                  "enum": [
                                    false,
                                    true
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_setup_started"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "global",
                                    "team",
                                    "space",
                                    "artifact",
                                    "review",
                                    "direct",
                                    "agent"
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_routing_saved"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "selected_space_count": {
                                  "type": "string",
                                  "enum": [
                                    "0",
                                    "1",
                                    "2_to_5",
                                    "6_plus"
                                  ]
                                },
                                "default_coverage": {
                                  "type": "string",
                                  "enum": [
                                    "none",
                                    "partial",
                                    "all"
                                  ]
                                },
                                "fallback_coverage": {
                                  "type": "string",
                                  "enum": [
                                    "none",
                                    "partial",
                                    "all"
                                  ]
                                },
                                "enabled": {
                                  "type": "boolean",
                                  "enum": [
                                    false,
                                    true
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_route_ready"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "selected_space_count": {
                                  "type": "string",
                                  "enum": [
                                    "0",
                                    "1",
                                    "2_to_5",
                                    "6_plus"
                                  ]
                                },
                                "default_coverage": {
                                  "type": "string",
                                  "enum": [
                                    "none",
                                    "partial",
                                    "all"
                                  ]
                                },
                                "fallback_coverage": {
                                  "type": "string",
                                  "enum": [
                                    "none",
                                    "partial",
                                    "all"
                                  ]
                                },
                                "enabled": {
                                  "type": "boolean",
                                  "enum": [
                                    false,
                                    true
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_template_selected"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "starter": {
                                  "type": "string",
                                  "enum": [
                                    "none",
                                    "software",
                                    "design",
                                    "contract",
                                    "manual"
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_draft_requested"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "starter": {
                                  "type": "string",
                                  "enum": [
                                    "none",
                                    "software",
                                    "design",
                                    "contract",
                                    "manual"
                                  ]
                                },
                                "mode": {
                                  "type": "string",
                                  "enum": [
                                    "manual",
                                    "ai"
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_draft_outcome"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "outcome": {
                                  "type": "string",
                                  "enum": [
                                    "manual",
                                    "generated",
                                    "disabled",
                                    "fallback",
                                    "discarded_after_edit"
                                  ]
                                },
                                "duration": {
                                  "type": "string",
                                  "enum": [
                                    "under_1s",
                                    "1_to_5s",
                                    "5_to_25s",
                                    "over_25s"
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_draft_applied"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "outcome": {
                                  "type": "string",
                                  "enum": [
                                    "manual",
                                    "generated",
                                    "disabled",
                                    "fallback",
                                    "discarded_after_edit"
                                  ]
                                },
                                "fields_edited": {
                                  "type": "boolean",
                                  "enum": [
                                    false,
                                    true
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_evidence_stage_outcome"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "upload",
                                    "artifact",
                                    "external_link"
                                  ]
                                },
                                "size": {
                                  "type": "string",
                                  "enum": [
                                    "under_1mb",
                                    "1_to_5mb",
                                    "5_to_15mb"
                                  ]
                                },
                                "outcome": {
                                  "type": "string",
                                  "enum": [
                                    "success",
                                    "failed",
                                    "intent"
                                  ]
                                },
                                "reason": {
                                  "type": "string",
                                  "enum": [
                                    "count",
                                    "size",
                                    "quota",
                                    "expired",
                                    "authorization",
                                    "unavailable",
                                    "transport"
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_evidence_open_outcome"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "upload",
                                    "artifact",
                                    "external_link"
                                  ]
                                },
                                "size": {
                                  "type": "string",
                                  "enum": [
                                    "under_1mb",
                                    "1_to_5mb",
                                    "5_to_15mb"
                                  ]
                                },
                                "outcome": {
                                  "type": "string",
                                  "enum": [
                                    "success",
                                    "failed",
                                    "intent"
                                  ]
                                },
                                "reason": {
                                  "type": "string",
                                  "enum": [
                                    "count",
                                    "size",
                                    "quota",
                                    "expired",
                                    "authorization",
                                    "unavailable",
                                    "transport"
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_submit_attempted"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "global",
                                    "team",
                                    "space",
                                    "artifact",
                                    "review",
                                    "direct",
                                    "agent"
                                  ]
                                },
                                "eligible": {
                                  "type": "boolean",
                                  "enum": [
                                    false,
                                    true
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name",
                            "attrs"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_create_outcome"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "channel": {
                                  "type": "string",
                                  "enum": [
                                    "ui",
                                    "pat",
                                    "system"
                                  ]
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "Open",
                                    "In Progress",
                                    "Fixed",
                                    "Resolved"
                                  ]
                                },
                                "has_evidence": {
                                  "type": "boolean",
                                  "enum": [
                                    false,
                                    true
                                  ]
                                },
                                "outcome": {
                                  "type": "string",
                                  "enum": [
                                    "replayed",
                                    "conflict",
                                    "validation",
                                    "permission",
                                    "transport"
                                  ]
                                }
                              },
                              "required": [
                                "outcome"
                              ]
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_draft_recovered"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "draft_kind": {
                                  "type": "string",
                                  "enum": [
                                    "new_issue",
                                    "progress",
                                    "comment"
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_detail_opened"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "channel": {
                                  "type": "string",
                                  "enum": [
                                    "ui",
                                    "pat",
                                    "system"
                                  ]
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "Open",
                                    "In Progress",
                                    "Fixed",
                                    "Resolved"
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_notification_opened"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "assigned",
                                    "progress",
                                    "fixed",
                                    "resolved",
                                    "digest"
                                  ]
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "name"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "enum": [
                                "issues_watch_changed"
                              ]
                            },
                            "attrs": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "watch": {
                                  "type": "string",
                                  "enum": [
                                    "watch",
                                    "mute",
                                    "unwatch"
                                  ]
                                }
                              }
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted: all events were added once to their daily aggregate counters. This confirms persistence of this batch, without proving any product operation succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "accepted"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "accepted": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 20
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_EVENT: malformed or oversized JSON, an empty or over-20 batch, unknown request/event/attribute keys, unknown event names, invalid enum values or a client attempt to claim a server-only durable outcome. Invalid batches write no counters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or invalid/expired credential while metrics are enabled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED for a scoped personal token lacking issues:write; PERSON_REQUIRED for a service or inactive account. Cookie-authenticated mutations also require the trusted application origin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "FEATURE_DISABLED: ISSUES_METRICS_ENABLED is not exactly 1. Returned before authentication, including for anonymous callers; no event is stored.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "METRICS_RATE_LIMITED: more than 60 requests per minute from the same human account across sessions and personal tokens.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "METRICS_CAPACITY: the bounded store would exceed 10,000 live daily event/attribute slices; the entire batch is rejected. ACCOUNTS_UNAVAILABLE: current account state cannot be checked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/issues/destinations": {
      "get": {
        "summary": "List readable active Team-associated issue Spaces",
        "description": "Enumerates active Spaces associated with the caller’s exact active Teams, including paused intake, using current active human Team membership without requiring a Space role. Each Space includes can_read:true, can_report (the preserved user/Space submit permission) and can_comment (the preserved comment gate), alongside unchanged can_manage, intake_enabled and accepting_issues. Use numeric id/space_id for Issue navigation; slug, space_slug, default_owner_id and owner details are omitted unless the caller independently owns or is an explicit member of the Space. can_report does not include intake, routing readiness or the server-wide flag. accepting_issues is enabled intake plus an eligible default or fallback owner, independently of can_report and ISSUES_ENABLED. The frontend enables filing only when can_report AND accepting_issues AND enabled (ISSUES_ENABLED=1) are true; show all readable Spaces for the selected team_id in the Space filter and composer, including those where filing is unavailable; disable submission unless all three conditions hold. Preserve the draft when explaining a blocked destination. Paused intake does not remove Issue read or otherwise-authorized comment access. Available while reporting is off; enabled reports the server-wide switch. The additional teams list contains only current active Teams visible through the caller’s current membership. Each Team carries ref, the owner-qualified @owner/handle reference already visible on the Teams page, so same-titled Teams can be distinguished without changing unique titles. Each Team carries readiness_reasons; empty means at least one route is ready for this caller, subject to enabled. Codes are NO_SPACE_CONFIGURED, NO_SPACE_ROLE, INTAKE_PAUSED, NO_ELIGIBLE_ROUTE and SERVER_OFF, and independent blockers may appear together. Each explicitly accessible Space adds readiness_reasons and default_owner (the effective eligible default, then backup). Team-only readers receive Team-level reasons without private per-Space reasons or owner details. Restricted routing Spaces remain id/title only. ai_enabled reflects ISSUES_AI_ENABLED (false only for 0), independently of the reporting switch, without provider details. Intentional AI disablement retains manual drafting; unavailable AI returns the original text for manual editing.",
        "operationId": "get_api_issues_destinations",
        "x-required-scope": "issues:read",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Readable destination metadata, preserved write capabilities and reporting availability. No issue contents are returned. Each Space carries its agent_auto_resolve setting, read-only here.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "enabled": {
                      "type": "boolean",
                      "description": "Server-wide ISSUES_ENABLED=1 switch, independent of per-Space permission, intake and routing. False does not suppress authorized destination metadata; actual Issue reads and filing still require the feature to be enabled."
                    },
                    "spaces": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "team_id": {
                            "type": "integer"
                          },
                          "title": {
                            "type": "string"
                          },
                          "intake_enabled": {
                            "type": "boolean",
                            "description": "Space intake selection. False pauses new filing while preserving Team-wide Issue reading and otherwise-authorized comments when the feature is enabled."
                          },
                          "accepting_issues": {
                            "type": "boolean",
                            "description": "True when intake is enabled and a default or fallback owner is eligible. Independent of can_report and the server-wide enabled flag; not a complete authorization or feature-readiness result."
                          },
                          "agent_auto_resolve": {
                            "type": "boolean",
                            "description": "The Space's agent auto-resolve setting (2026-11-21), read-only here: while true, the issue owner's token may resolve with a passing verification record instead of an approval_id."
                          },
                          "can_read": {
                            "type": "boolean",
                            "enum": [
                              true
                            ],
                            "description": "Current active human membership of the exact associated active Team permits Issue reads in this active Space without a Space role. Does not authorize underlying Space documents or artifact content."
                          },
                          "can_report": {
                            "type": "boolean",
                            "description": "Preserved user/Space submit permission: current exact Team membership plus explicit Space membership or ownership. Does not imply intake, eligible routing or ISSUES_ENABLED readiness; those gates still apply to actual filing."
                          },
                          "can_comment": {
                            "type": "boolean",
                            "description": "Preserved explicit Space member/owner plus current exact Team membership comment gate. Independent of intake; Team-only readers are false. Read latest issue.permissions.comment for the authoritative per-Issue comment capability."
                          },
                          "can_manage": {
                            "type": "boolean",
                            "description": "Unchanged manager permission: current exact Team membership and explicit Space membership/ownership, plus personal Space ownership or Team owner/admin authority. Team-only reading does not grant management."
                          },
                          "readiness_reasons": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "enum": [
                                "NO_SPACE_CONFIGURED",
                                "NO_SPACE_ROLE",
                                "INTAKE_PAUSED",
                                "NO_ELIGIBLE_ROUTE",
                                "SERVER_OFF"
                              ]
                            },
                            "description": "Independent, permission-safe filing blockers. An empty array means no listed blocker. No Space-specific reasons are returned without explicit Space access."
                          },
                          "default_owner": {
                            "type": "object",
                            "nullable": true,
                            "description": "Effective eligible configured default or Team backup, exposed only with independent explicit Space access. Null means neither is currently eligible.",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "username": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "required": [
                          "can_read",
                          "can_report",
                          "can_comment"
                        ]
                      }
                    },
                    "ai_enabled": {
                      "type": "boolean",
                      "description": "AI drafting switch only: false when ISSUES_AI_ENABLED=0. Does not imply a provider is configured or available, and exposes no provider details. Reporting, Space authorization and manual drafting remain separate."
                    },
                    "teams": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "title": {
                            "type": "string"
                          },
                          "ref": {
                            "type": "string",
                            "description": "Owner-qualified @owner/handle reference, identical to the current member-visible Teams reference; distinguish duplicate titles with this value."
                          },
                          "can_manage": {
                            "type": "boolean",
                            "description": "Current Team owner/admin authority; does not grant access to restricted Space routing."
                          },
                          "readiness_reasons": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "enum": [
                                "NO_SPACE_CONFIGURED",
                                "NO_SPACE_ROLE",
                                "INTAKE_PAUSED",
                                "NO_ELIGIBLE_ROUTE",
                                "SERVER_OFF"
                              ]
                            },
                            "description": "Independent, permission-safe filing blockers. An empty array means no listed blocker. No Space-specific reasons are returned without explicit Space access."
                          }
                        },
                        "required": [
                          "id",
                          "title",
                          "ref",
                          "can_manage",
                          "readiness_reasons"
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "team_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ]
      }
    },
    "/api/issues/spaces/{slug}/settings": {
      "get": {
        "summary": "Read Space routing settings",
        "description": "Available before server-wide issue tracking is enabled. Existing scope, account and Team/Space authority checks apply.",
        "operationId": "get_api_issues_spaces_slug_settings",
        "x-required-scope": "issues:read",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "{success:true, settings:{space_id,space_slug,team_id,default_owner_id,intake_enabled,agent_auto_resolve,agent_auto_resolve_changed:{by:{id,username}|null,at|null}}}."
          }
        },
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "summary": "Associate Team and configure issue intake",
        "description": "Available before server-wide issue tracking is enabled. Team association requires personal Space ownership and target Team admin authority. Existing issues prevent Team reassociation. No membership is copied. An eligible default or fallback is required to enable intake. agent_auto_resolve (boolean, off by default) lets the issue owner's token resolve with a passing verification record instead of an approval_id. Only a Team owner or admin who manages the Space may change it (otherwise 403 ISSUE_MANAGE_REQUIRED); turning it on needs that person's web session (a token, even a full-access one, gets 403 HUMAN_SESSION_REQUIRED); a qualifying admin's issues:manage token may turn it off. Every change is an issue_config_events entry with before and after, and the Space remembers agent_auto_resolve_changed {by:{id,username}|null, at|null}; by null with an at means a backup restore turned it off.",
        "operationId": "patch_api_issues_spaces_slug_settings",
        "x-required-scope": "issues:manage",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED, PERSON_REQUIRED or ISSUE_MANAGE_REQUIRED; HUMAN_SESSION_REQUIRED when a token turns agent_auto_resolve on",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "{success:true, settings:{space_id,space_slug,team_id,default_owner_id,intake_enabled,agent_auto_resolve,agent_auto_resolve_changed:{by:{id,username}|null,at|null}}}."
          }
        },
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "team_id": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "default_owner_id": {
                    "type": "string",
                    "nullable": true
                  },
                  "intake_enabled": {
                    "type": "boolean"
                  },
                  "agent_auto_resolve": {
                    "type": "boolean",
                    "description": "Agents may resolve issues with passing-test evidence. See the operation description."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/issues/spaces/{slug}/owners": {
      "get": {
        "summary": "List eligible human Space owners/editors",
        "description": "",
        "operationId": "get_api_issues_spaces_slug_owners",
        "x-required-scope": "issues:read",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after."
          }
        },
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/issues/teams/{teamId}/settings": {
      "get": {
        "summary": "Read Team fallback as Team admin",
        "description": "Available before server-wide issue tracking is enabled. Existing scope, account and Team/Space authority checks apply.",
        "operationId": "get_api_issues_teams_teamId_settings",
        "x-required-scope": "issues:read",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after."
          }
        },
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "summary": "Configure Team fallback as Team admin",
        "description": "Available before server-wide issue tracking is enabled. Existing scope, account and Team/Space authority checks apply.",
        "operationId": "patch_api_issues_teams_teamId_settings",
        "x-required-scope": "issues:manage",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after."
          }
        },
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "fallback_owner_id": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "fallback_owner_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/issues/teams/{teamId}/progress": {
      "get": {
        "summary": "Read Team operational summary as Team admin",
        "description": "Always an operational projection, including restricted Spaces. Fields: id,space_id,space_name,owner_id,assignment_state,status,last_progress_at. Never titles, reporter, snippets, notes or attachments. Counts apply the same filters. counts has one entry per status, in the order Open, In Progress, Fixed, Resolved.",
        "operationId": "get_api_issues_teams_teamId_progress",
        "x-required-scope": "issues:read",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after."
          }
        },
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "space_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "owner_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact human account ID. UI owner selection displays account names."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ]
      }
    },
    "/api/issues": {
      "get": {
        "summary": "Search current authorized issues or My Issues",
        "description": "mine=assigned|reported. Search is a literal case-insensitive substring of title/description. attention=needs_reassignment filters current assignment state. no_progress_days is a chosen positive safe-integer elapsed-day check against last_progress_at, or created_at when progress has never been posted; updated_at, comments and metadata changes never reset it. Attention checks may be combined and do not promise an overdue date. Default limit 50, max 100, offset max 100000. Entitlements apply before search, counts and pagination. The owners response field contains distinct {id,username} values across every authorized matching issue before pagination and the owner_id filter; Team, Space, status, type, mine, attention, no_progress_days and q restrictions still apply. It never includes owners inferred from inaccessible issue details. An active human who is currently a member of the exact active Team associated with the active Issue Space may read without a Space role. Paused intake does not block reads. Current revocation and association changes fail closed immediately. The server feature flag and token scopes still apply. Team-wide Issue reading does not grant underlying Space documents or independently authorized artifact content. The separate admin progress projection remains unchanged.",
        "operationId": "get_api_issues",
        "x-required-scope": "issues:read",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "issues",
                    "total",
                    "limit",
                    "offset"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "issues": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Issue"
                      }
                    },
                    "total": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "limit": {
                      "type": "integer",
                      "minimum": 1
                    },
                    "offset": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "space_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "priority",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "Low",
                "Medium",
                "High",
                "none"
              ]
            },
            "description": "Exact priority match; none selects Issues without a priority. Applied within authorized filtering before search, totals and pagination; existing order is unchanged. Omission means no priority filter. Empty and unknown values return 400 INVALID_INPUT, like the existing type and status filters."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "Open",
                "In Progress",
                "Fixed",
                "Resolved"
              ]
            },
            "description": "Exact status: Open, In Progress, Fixed or Resolved. Applied within authorized filtering before owner choices, totals and pagination."
          },
          {
            "name": "owner_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact human account ID. UI owner selection displays account names."
          },
          {
            "name": "mine",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "attention",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["needs_reassignment"]
            },
            "description": "Choose Issues whose current assignment_state needs reassignment."
          },
          {
            "name": "no_progress_days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "description": "Choose Issues with at least N elapsed 24-hour days since last_progress_at, or created_at when progress has never been posted. Comments do not reset the age. Invalid values return 400 INVALID_INPUT."
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "team_id",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ]
      },
      "post": {
        "summary": "Manually create an issue",
        "description": "Explicit Space membership/ownership AND current exact Team membership, enabled intake and the global feature (ISSUES_ENABLED=1) remain required; Team-only reading is insufficient. can_report is authority only, independent of intake/routing/global readiness. The normal composer checks can_report AND accepting_issues AND enabled. Existing API/MCP creation with an explicit owner_id requires manager permission and, for scoped tokens, issues:manage in addition to issues:write. The explicitly selected human owner must be eligible; configured default/fallback readiness is not required on this path, even when accepting_issues is false. With owner_id omitted, default routing tries an eligible Space default, then an eligible Team fallback. Original text is preserved verbatim. Unknown fields are rejected. attachment_ids binds staged evidence atomically. Optional source additionally requires shares:read for scoped personal PATs and accepts IssueSource only when ISSUES_CAPTURE_ENABLED=1 (exactly, per request); otherwise 404 FEATURE_DISABLED with no storage. Independent active-human access to the account-audience share, exact version and thread is rechecked on retries. Evidence binds atomically and grants no document rights to Issue readers. Explicit reporter submission is always required.",
        "operationId": "post_api_issues",
        "x-required-scope": "issues:write",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED; DESTINATION_CHANGED when the Space does not belong to the selected Team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "issue"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "issue": {
                      "$ref": "#/components/schemas/Issue"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "space_id": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "Bug",
                      "Enhancement"
                    ]
                  },
                  "priority": {
                    "type": "string",
                    "nullable": true,
                    "enum": [
                      "Low",
                      "Medium",
                      "High",
                      null
                    ],
                    "description": "Optional reporter-selected priority. Omit or send null for no priority. Any other value returns 400 INVALID_INPUT without creating an Issue or links. AI drafting never chooses it."
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "description": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 20000,
                    "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/IssueText"
                      }
                    ]
                  },
                  "source": {
                    "$ref": "#/components/schemas/IssueSource"
                  },
                  "original_text": {
                    "type": "string",
                    "maxLength": 30000,
                    "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/IssueText"
                      }
                    ]
                  },
                  "owner_id": {
                    "type": "string"
                  },
                  "attachment_ids": {
                    "type": "array",
                    "maxItems": 10,
                    "uniqueItems": true,
                    "items": {
                      "type": "string"
                    }
                  },
                  "details": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "reproduction_steps": {
                        "type": "string",
                        "maxLength": 10000,
                        "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/IssueText"
                          }
                        ]
                      },
                      "expected_behavior": {
                        "type": "string",
                        "maxLength": 10000,
                        "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/IssueText"
                          }
                        ]
                      },
                      "actual_behavior": {
                        "type": "string",
                        "maxLength": 10000,
                        "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/IssueText"
                          }
                        ]
                      },
                      "requested_change": {
                        "type": "string",
                        "maxLength": 10000,
                        "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/IssueText"
                          }
                        ]
                      },
                      "intended_outcome": {
                        "type": "string",
                        "maxLength": 10000,
                        "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/IssueText"
                          }
                        ]
                      }
                    }
                  },
                  "team_id": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "Optional Team context. The Space must still belong to this Team when the report is filed; otherwise DESTINATION_CHANGED is returned."
                  }
                },
                "required": [
                  "space_id",
                  "type",
                  "title",
                  "description"
                ]
              }
            }
          }
        }
      }
    },
    "/api/issues/{id}": {
      "get": {
        "summary": "Read issue details and current revision",
        "description": "An active human who is currently a member of the exact active Team associated with the active Issue Space may read without a Space role. Paused intake does not block reads. Current revocation and association changes fail closed immediately. The server feature flag and token scopes still apply. Returns issue.permissions.comment as the authoritative comment capability; reading alone grants no writing or underlying Space document/artifact access. Members may open/copy an Issue URL, but each recipient needs independent authorization.",
        "operationId": "get_api_issues_id",
        "x-required-scope": "issues:read",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Current authorized Issue detail, including existing revision/ownership epoch, evidence and permissions, plus authoritative permissions.comment. latest_owner_progress is the newest saved owner update (summary, blockers, next_step, created_at and event_id), or null before any update. It is independent of activity pagination; comments never replace it or advance last_progress_at. The existing latest_progress summary string remains compatible. evidence_usage reports all bound references and upload bytes, including unavailable artifact references; combine it with current staging before uploading. Limits remain authoritative at transactional binding, and the separate 500 MB uploader quota is not an Issue budget. Space navigation uses space.id; space.slug is omitted unless the caller independently owns or is an explicit member of the Space. The same Space and evidence_usage projection applies to Issue lists and successful Issue mutations; latest_owner_progress is additionally returned in detail and successful Issue mutations.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "issue": {
                      "type": "object",
                      "properties": {
                        "latest_owner_progress": {
                          "$ref": "#/components/schemas/LatestOwnerProgress"
                        },
                        "evidence_usage": {
                          "$ref": "#/components/schemas/IssueEvidenceUsage"
                        },
                        "permissions": {
                          "$ref": "#/components/schemas/IssuePermissions"
                        },
                        "description": {
                          "type": "string",
                          "allOf": [
                            {
                              "$ref": "#/components/schemas/IssueText"
                            }
                          ],
                          "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example."
                        },
                        "original_text": {
                          "type": "string",
                          "allOf": [
                            {
                              "$ref": "#/components/schemas/IssueText"
                            }
                          ],
                          "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example."
                        },
                        "details": {
                          "$ref": "#/components/schemas/IssueReportDetails"
                        },
                        "priority": {
                          "type": "string",
                          "nullable": true,
                          "enum": [
                            "Low",
                            "Medium",
                            "High",
                            null
                          ],
                          "description": "Optional reporter-selected priority; null means no priority. AI drafting never chooses it."
                        },
                        "team": {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "id",
                            "title"
                          ],
                          "properties": {
                            "id": {
                              "type": "integer"
                            },
                            "title": {
                              "type": "string"
                            }
                          }
                        },
                        "verification": {
                          "nullable": true,
                          "allOf": [
                            {
                              "$ref": "#/components/schemas/IssueVerification"
                            }
                          ],
                          "description": "The current verification record, or null. Set by Fixed and by an agent auto-resolve; cleared when the issue goes back to In Progress or Open; kept by a reviewed resolution. Activity keeps every record."
                        },
                        "agent_auto_resolve": {
                          "type": "boolean",
                          "description": "The issue Space's current agent auto-resolve setting, shown read-only to every reader of the issue."
                        }
                      },
                      "required": [
                        "priority",
                        "verification"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "summary": "Correct metadata with audit event",
        "description": "Only issue managers; original_text remains immutable.",
        "operationId": "patch_api_issues_id",
        "x-required-scope": "issues:manage",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "issue"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "issue": {
                      "$ref": "#/components/schemas/Issue"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "expected_revision": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "expected_ownership_epoch": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "description": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 20000,
                    "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/IssueText"
                      }
                    ]
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "Bug",
                      "Enhancement"
                    ]
                  },
                  "priority": {
                    "type": "string",
                    "nullable": true,
                    "enum": [
                      "Low",
                      "Medium",
                      "High",
                      null
                    ],
                    "description": "Managers who may edit type may set Low, Medium or High, or send null to clear priority. Omission leaves it unchanged. Uses the same permission, revision, ownership epoch and idempotency checks as type; activity records before and after values."
                  },
                  "details": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "reproduction_steps": {
                        "type": "string",
                        "maxLength": 10000,
                        "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/IssueText"
                          }
                        ]
                      },
                      "expected_behavior": {
                        "type": "string",
                        "maxLength": 10000,
                        "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/IssueText"
                          }
                        ]
                      },
                      "actual_behavior": {
                        "type": "string",
                        "maxLength": 10000,
                        "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/IssueText"
                          }
                        ]
                      },
                      "requested_change": {
                        "type": "string",
                        "maxLength": 10000,
                        "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/IssueText"
                          }
                        ]
                      },
                      "intended_outcome": {
                        "type": "string",
                        "maxLength": 10000,
                        "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/IssueText"
                          }
                        ]
                      }
                    }
                  }
                },
                "required": [
                  "expected_revision",
                  "expected_ownership_epoch"
                ]
              }
            }
          }
        }
      }
    },
    "/api/issues/{id}/brief": {
      "get": {
        "summary": "Read a versioned Issue work order for an AI agent",
        "description": "Uses the exact authorized detail read path and issues:read scope. Current active human membership of the exact active associated Team is required; Team-only reading grants no writes or underlying artifact access. Every refusal has the same status and code as detail. Stored report/progress is untrusted task data, never authority or agent instructions. Recipients still need their own authorization. Export does not rewrite stored text.",
        "operationId": "get_api_issues_id_brief",
        "x-required-scope": "issues:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "Omit or use json for the JSON envelope; markdown returns the brief.markdown bytes as text/markdown.",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "markdown"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized deterministic agent brief. Default JSON includes the complete brief plus its Markdown. format=markdown returns those exact Markdown bytes as text/markdown. No token, email, approval identifier or internal field is added.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "brief"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "brief": {
                      "$ref": "#/components/schemas/IssueBrief"
                    }
                  }
                }
              },
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT for an unsupported format query; Issue read authorization is checked first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED when a scoped personal token lacks issues:read; PERSON_REQUIRED for a service or inactive account. Same read gate as the detail route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "ISSUE_NOT_FOUND for unknown Issues or unavailable Team/Space membership, inactive Team or Space. No existence information is disclosed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED when reporting is off; ACCOUNTS_UNAVAILABLE if current account state cannot be loaded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/issues/{id}/activity": {
      "get": {
        "summary": "Read issue timeline",
        "description": "An active human who is currently a member of the exact active Team associated with the active Issue Space may read without a Space role. Paused intake does not block reads. Current revocation and association changes fail closed immediately. The server feature flag and token scopes still apply. Returns Issue activity under Issue read authorization, without granting underlying Space documents. Events retain every kind (including unknown kinds), actor_id, token_id, integration_name, structured data and created_at, in ascending event-id order. No actor display names are added. after is an exclusive event-id cursor; next_after is the last returned id, or the supplied after when empty. Approval identifiers are excluded, including from legacy event payloads; resolution_reviewed records only the reviewed revision and owner epoch. Comment text and owner progress summary, blockers and next_step use Issue text format 1 (issue-text/1); see IssueText for the complete rules and progress example.",
        "operationId": "get_api_issues_id_activity",
        "x-required-scope": "issues:read",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after."
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ]
      }
    },
    "/api/issues/{id}/assignment": {
      "post": {
        "summary": "Reassign as issue manager",
        "description": "New owner must be eligible. Changes owner epoch.",
        "operationId": "post_api_issues_id_assignment",
        "x-required-scope": "issues:manage",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after."
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "expected_revision": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "expected_ownership_epoch": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "owner_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "expected_revision",
                  "expected_ownership_epoch",
                  "owner_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/issues/{id}/updates": {
      "post": {
        "summary": "Post owner progress and optional status",
        "description": "Current owner only. A token must post progress before human review; it cannot combine new progress with approved resolution. When ISSUES_METRICS_ENABLED=1 or ISSUES_NOTIFICATIONS_ENABLED=1, an otherwise-authorized approval rejection records a content-free durable resolution_rejected activity entry containing only a fixed reason, with no approval identifier/value. The audit and exact-retry error response commit together under the existing idempotency key; an exact replay returns the same error without adding another activity or event. Rejection does not advance the Issue revision or ownership epoch, and the existing status/error codes remain unchanged. With both switches off, the legacy rejection behavior records no rejection audit. A successful response includes latest_owner_progress with the saved summary, blockers, next_step and event timestamp. Omitted blockers/next_step are empty strings for this update, rather than inherited from an older update. Progress may carry status In Progress, Fixed (with a verification record; staged attachment_ids bind as usual) or Resolved; a move to Open stays the manager transition. A token's agent auto-resolve is accepted here too. Fixed (2026-11-21): the current eligible owner sets Fixed from Open, In Progress or Fixed (a refresh replaces the record), in a session or with an issues:write personal token, only with a passing verification record (missing: VERIFICATION_REQUIRED; malformed: VERIFICATION_INVALID with field; failed above 0 or passed 0: 422 VERIFICATION_FAILED). A record anywhere else is VERIFICATION_NOT_ACCEPTED. The owner may move Fixed back to In Progress; a manager may move Fixed or Resolved to Open (scoped tokens also need issues:manage); both clear the current record. A session resolves directly; a token resolves with the owner's approval_id (the reviewed record is kept) or, only where the Space's agent_auto_resolve is on, with a passing verification record and no approval_id: the record is stored with status Resolved and the activity event records the token and auto_resolve {enabled, changed_by, changed_at}. Without either, a token gets 403 HUMAN_REVIEW_REQUIRED, also when the setting is on. Still refused with INVALID_TRANSITION: In Progress to Open, leaving Resolved other than to Open, Open to Open and In Progress to In Progress. Revision, owner epoch and Idempotency-Key rules are unchanged.",
        "operationId": "post_api_issues_id_updates",
        "x-required-scope": "issues:write",
        "responses": {
          "400": {
            "description": "INVALID_INPUT, IDEMPOTENCY_REQUIRED, VERIFICATION_REQUIRED, VERIFICATION_INVALID (with field) or VERIFICATION_NOT_ACCEPTED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED, TEAM_REQUIRED or VERIFICATION_FAILED (with field)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after."
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "expected_revision": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "expected_ownership_epoch": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "summary": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 10000,
                    "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/IssueText"
                      }
                    ]
                  },
                  "blockers": {
                    "type": "string",
                    "maxLength": 10000,
                    "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/IssueText"
                      }
                    ]
                  },
                  "next_step": {
                    "type": "string",
                    "maxLength": 10000,
                    "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/IssueText"
                      }
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "Open",
                      "In Progress",
                      "Fixed",
                      "Resolved"
                    ]
                  },
                  "approval_id": {
                    "type": "string"
                  },
                  "verification": {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/IssueVerificationInput"
                      }
                    ],
                    "description": "Required with status Fixed. With status Resolved it is accepted only from a token that sends no approval_id: the agent auto-resolve path, which answers 403 HUMAN_REVIEW_REQUIRED where the Space does not allow it. Anywhere else it is 400 VERIFICATION_NOT_ACCEPTED."
                  },
                  "attachment_ids": {
                    "type": "array",
                    "maxItems": 10,
                    "uniqueItems": true,
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "expected_revision",
                  "expected_ownership_epoch",
                  "summary"
                ]
              }
            }
          }
        }
      }
    },
    "/api/issues/{id}/comments": {
      "post": {
        "summary": "Comment with explicit Space and current exact Team membership",
        "description": "Preserves the former comment gate: explicit Space membership/ownership AND current membership of the exact active associated Team. Team-only readers cannot comment. Use the latest issue.permissions.comment as the authoritative comment capability; token write scope is also required for scoped tokens. Paused intake does not block otherwise-authorized comments. Comment increments revision but does not update last_progress_at. Existing revision, owner epoch, idempotency and feature-availability requirements remain.",
        "operationId": "post_api_issues_id_comments",
        "x-required-scope": "issues:write",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after."
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "expected_revision": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "expected_ownership_epoch": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 10000,
                    "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/IssueText"
                      }
                    ]
                  }
                },
                "required": [
                  "expected_revision",
                  "expected_ownership_epoch",
                  "text"
                ]
              }
            }
          }
        }
      }
    },
    "/api/issues/{id}/transitions": {
      "post": {
        "summary": "Transition issue status",
        "description": "Current owner: Open to In Progress, Fixed or Resolved; In Progress to Fixed or Resolved; Fixed to Fixed, In Progress or Resolved. Manager: Fixed or Resolved to Open, additionally requiring issues:manage for scoped tokens. A PAT resolving requires a human-reviewed approval for exactly this revision/ownership epoch. When ISSUES_METRICS_ENABLED=1 or ISSUES_NOTIFICATIONS_ENABLED=1, an otherwise-authorized approval rejection records a content-free durable resolution_rejected activity entry containing only a fixed reason, with no approval identifier/value. The audit and exact-retry error response commit together under the existing idempotency key; an exact replay returns the same error without adding another activity or event. Rejection does not advance the Issue revision or ownership epoch, and the existing status/error codes remain unchanged. With both switches off, the legacy rejection behavior records no rejection audit. Missing, expired, consumed or changed-state approvals fail closed; reload and obtain a new human review. An exact successful retry reuses the identical payload and Idempotency-Key and returns its saved outcome without consuming the approval again or appending another event. Approval identifiers are never written to activity events or exposed by activity reads. Fixed (2026-11-21): the current eligible owner sets Fixed from Open, In Progress or Fixed (a refresh replaces the record), in a session or with an issues:write personal token, only with a passing verification record (missing: VERIFICATION_REQUIRED; malformed: VERIFICATION_INVALID with field; failed above 0 or passed 0: 422 VERIFICATION_FAILED). A record anywhere else is VERIFICATION_NOT_ACCEPTED. The owner may move Fixed back to In Progress; a manager may move Fixed or Resolved to Open (scoped tokens also need issues:manage); both clear the current record. A session resolves directly; a token resolves with the owner's approval_id (the reviewed record is kept) or, only where the Space's agent_auto_resolve is on, with a passing verification record and no approval_id: the record is stored with status Resolved and the activity event records the token and auto_resolve {enabled, changed_by, changed_at}. Without either, a token gets 403 HUMAN_REVIEW_REQUIRED, also when the setting is on. Still refused with INVALID_TRANSITION: In Progress to Open, leaving Resolved other than to Open, Open to Open and In Progress to In Progress. Revision, owner epoch and Idempotency-Key rules are unchanged.",
        "operationId": "post_api_issues_id_transitions",
        "x-required-scope": "issues:write",
        "responses": {
          "400": {
            "description": "INVALID_INPUT, IDEMPOTENCY_REQUIRED, VERIFICATION_REQUIRED, VERIFICATION_INVALID (with field) or VERIFICATION_NOT_ACCEPTED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED, TEAM_REQUIRED or VERIFICATION_FAILED (with field)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after."
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "expected_revision": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "expected_ownership_epoch": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "Open",
                      "In Progress",
                      "Fixed",
                      "Resolved"
                    ]
                  },
                  "approval_id": {
                    "type": "string"
                  },
                  "verification": {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/IssueVerificationInput"
                      }
                    ],
                    "description": "Required with status Fixed. With status Resolved it is accepted only from a token that sends no approval_id: the agent auto-resolve path, which answers 403 HUMAN_REVIEW_REQUIRED where the Space does not allow it. Anywhere else it is 400 VERIFICATION_NOT_ACCEPTED."
                  }
                },
                "required": [
                  "expected_revision",
                  "expected_ownership_epoch",
                  "status"
                ]
              }
            }
          }
        }
      }
    },
    "/api/issues/{id}/resolution-approvals": {
      "post": {
        "summary": "Review and approve resolution as the human owner",
        "description": "Rejects ALL PATs including legacy full-access; no MCP approval tool exists. The current eligible owner's human session approves the existing saved revision; the Review result panel shows saved progress, evidence, owner and reviewed revision. Returns approval {id,issue_id,owner_id,revision,ownership_epoch,expires_at}; id is single-use and expires in 15 minutes. No caller-supplied approved boolean. Records resolution_reviewed in the timeline without advancing issue revision or recording the identifier. The hand-off contains Issue identity, reviewed revision, owner epoch and approval identifier, never a token. Keep approval identifiers out of browser storage, URLs, logs, analytics and email. Any revision or owner-epoch change, reassignment or account security change invalidates approval; server time enforces absolute expiry. After expiry, consumption or a relevant change, reload and review the saved result again. Exact retries reuse the same payload and Idempotency-Key; the server does not mint another approval.",
        "operationId": "post_api_issues_id_resolution_approvals",
        "x-required-scope": "session",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after."
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "expected_revision": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "expected_ownership_epoch": {
                    "type": "integer",
                    "minimum": 1
                  }
                },
                "required": [
                  "expected_revision",
                  "expected_ownership_epoch"
                ]
              }
            }
          }
        }
      }
    },
    "/api/issues/attachments": {
      "post": {
        "summary": "Stage exactly one upload, artifact reference or evidence URL",
        "operationId": "post__api_issues_attachments",
        "x-required-scope": "issues:write",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "{success:true,attachment:{id,kind,available,...,expires_at}}. Ready staged uploads, external links and available artifacts expose their absolute 24-hour staging expiry. External links expose the supplied label as filename (default: Evidence link). Artifact metadata is independently authorized; bound artifacts retain their exact version."
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "space_id": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "filename": {
                    "type": "string",
                    "maxLength": 180
                  },
                  "content_base64": {
                    "type": "string",
                    "description": "Canonical base64, at most 15 MB decoded."
                  },
                  "artifact_slug": {
                    "type": "string"
                  },
                  "version_no": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "url": {
                    "type": "string",
                    "description": "HTTP(S) evidence URL without credentials; PitchStation documents must use artifact_slug."
                  },
                  "label": {
                    "type": "string",
                    "maxLength": 180,
                    "description": "Optional human-readable external evidence link label, returned as filename; defaults to Evidence link."
                  }
                },
                "required": [
                  "space_id"
                ]
              }
            }
          }
        },
        "description": "Preserves the explicit Space membership/ownership AND current exact Team membership write gate and existing staging requirements. Team-only Issue reading does not authorize upload staging, even when can_read is true. Unsubmitted staging stays private to its uploader and expires after 24 hours; expired evidence must be reselected/restaged or removed. Issue detail evidence_usage plus current staging supports pre-upload checks for 10 references and 50 MB; transactional binding remains authoritative after concurrent changes. The 15 MB/file and separate 500 MB/uploader quota remain enforced. Artifact references retain independent authorization and bind the exact version; Issue readers are not promised document access. After a lost mutation response, an explicit unchanged retry keeps the original payload and idempotency key even if local staging metadata has aged; the server confirms an already-bound result or rejects expired unbound staging."
      }
    },
    "/api/issues/attachments/{attachmentId}": {
      "get": {
        "summary": "Read permitted evidence or staged upload",
        "operationId": "get__api_issues_attachments__attachmentId_",
        "x-required-scope": "issues:read",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after."
          },
          "200": {
            "description": "Authorized attachment metadata or raw upload bytes by default; encoding=base64 returns content_base64, encoding=metadata omits bytes. Artifact references return permitted metadata only. Upload byte responses use private cache and sandbox/nosniff headers."
          }
        },
        "parameters": [
          {
            "name": "attachmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "encoding",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "base64",
                "metadata"
              ]
            }
          }
        ],
        "description": "Bound uploaded bytes use current Issue read authorization: active human membership of the exact active Team associated with the active Issue Space, without a Space role. Paused intake preserves these reads. Unsubmitted staged bytes remain private to their uploader under the existing destination write gate. Artifact references keep independent authorization and exact-version identity, and never fall through to a newer version. Team-wide Issue reading grants no underlying Space documents."
      },
      "delete": {
        "summary": "Remove your unsubmitted attachment",
        "operationId": "delete__api_issues_attachments__attachmentId_",
        "x-required-scope": "issues:write",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Staged attachment removed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "result"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "result": {
                      "type": "object",
                      "required": [
                        "removed"
                      ],
                      "properties": {
                        "removed": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "attachmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/api/issues/drafts": {
      "post": {
        "summary": "Generate an editable draft with manual fallback",
        "operationId": "post__api_issues_drafts",
        "x-required-scope": "issues:write",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope, owner or manager permission; HUMAN_REVIEW_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "Success. Responses use {success:true, issue|approval|settings|spaces|owners:...}; list/progress responses expose issues,total,limit,offset and progress additionally exposes counts. Activity exposes events,next_after."
          }
        },
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "space_id": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "original_text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 20000,
                    "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/IssueText"
                      }
                    ]
                  },
                  "attachment_ids": {
                    "type": "array",
                    "maxItems": 10,
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "space_id",
                  "original_text"
                ]
              }
            }
          }
        },
        "description": "Preserves the explicit Space membership/ownership AND current exact Team membership write gate and existing draft requirements. Team-only Issue reading does not authorize AI drafting. The server feature flag and separate AI availability still apply."
      }
    },
    "/api/issues/teams/{teamId}/routing": {
      "get": {
        "summary": "List configurable issue Spaces for a Team admin",
        "description": "Team owners/admins may configure existing Team Spaces where they have explicit Space access and their own unassociated Spaces. Spaces belonging to another Team are excluded. Restricted Team Spaces expose only operational id/title metadata, without slugs, routing or membership details. Available while reporting is off.",
        "operationId": "get_api_issues_teams_teamId_routing",
        "x-required-scope": "issues:read",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED, PERSON_REQUIRED or ISSUE_MANAGE_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "{success:true, routing:{team_id,team_name,fallback_owner_id,fallback_owners,spaces,restricted_spaces}}. Configurable spaces include id,slug,title,associated,intake_enabled,default_owner_id and eligible owners. Each editable Space also includes default_owner_eligible, fallback_owner_eligible (for the currently saved selections), and effective_default_owner:{id,username}|null, choosing an eligible configured default before an eligible backup. Unsaved eligibility can be checked against the existing owners list. These are per-Space results, never a universal Team-ready claim. restricted_spaces contains only id,title. Each configurable Space also includes agent_auto_resolve and agent_auto_resolve_changed {by:{id,username}|null, at|null}. Every configurable Space is one this Team owner or admin manages, so each may change the setting; restricted_spaces carry no setting."
          }
        },
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "summary": "Atomically select Team issue Spaces and routing owners",
        "description": "Team owners/admins submit only changed Spaces. Associating an unassociated Space also requires personal Space ownership. Other Team Spaces cannot be moved. A selected Space requires an eligible default or fallback owner; every row, fallback, audit and retry record commits together or rolls back together. Intake may be paused without deleting existing issues. Retried writes recheck current authority and return current authorized metadata. Available while reporting is off. Pausing intake preserves Team-wide Issue browsing and otherwise-authorized comments; it does not grant Space membership or alter write roles. agent_auto_resolve (boolean, off by default) lets the issue owner's token resolve with a passing verification record instead of an approval_id. Only a Team owner or admin who manages the Space may change it (otherwise 403 ISSUE_MANAGE_REQUIRED); turning it on needs that person's web session (a token, even a full-access one, gets 403 HUMAN_SESSION_REQUIRED); a qualifying admin's issues:manage token may turn it off. Every change is an issue_config_events entry with before and after, and the Space remembers agent_auto_resolve_changed {by:{id,username}|null, at|null}; by null with an at means a backup restore turned it off.",
        "operationId": "patch_api_issues_teams_teamId_routing",
        "x-required-scope": "issues:manage",
        "responses": {
          "400": {
            "description": "INVALID_INPUT or IDEMPOTENCY_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required or token expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED, PERSON_REQUIRED or ISSUE_MANAGE_REQUIRED; HUMAN_SESSION_REQUIRED when a token turns agent_auto_resolve on",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Issue, Space or Team unavailable to this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "ISSUE_STALE, IDEMPOTENCY_CONFLICT, APPROVAL_STALE or INVALID_TRANSITION",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ASSIGNMENT_REQUIRED, OWNER_INELIGIBLE, INTAKE_DISABLED or TEAM_REQUIRED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "ACCOUNTS_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "200": {
            "description": "{success:true, routing:{team_id,team_name,fallback_owner_id,fallback_owners,spaces,restricted_spaces}}. Configurable spaces include id,slug,title,associated,intake_enabled,default_owner_id and eligible owners. Each editable Space also includes default_owner_eligible, fallback_owner_eligible (for the currently saved selections), and effective_default_owner:{id,username}|null, choosing an eligible configured default before an eligible backup. Unsaved eligibility can be checked against the existing owners list. These are per-Space results, never a universal Team-ready claim. restricted_spaces contains only id,title. Each configurable Space also includes agent_auto_resolve and agent_auto_resolve_changed {by:{id,username}|null, at|null}. Every configurable Space is one this Team owner or admin manages, so each may change the setting; restricted_spaces carry no setting."
          }
        },
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "spaces"
                ],
                "properties": {
                  "fallback_owner_id": {
                    "type": "string",
                    "nullable": true
                  },
                  "spaces": {
                    "type": "array",
                    "maxItems": 200,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "space_id",
                        "intake_enabled"
                      ],
                      "properties": {
                        "space_id": {
                          "type": "integer",
                          "minimum": 1
                        },
                        "intake_enabled": {
                          "type": "boolean"
                        },
                        "default_owner_id": {
                          "type": "string",
                          "nullable": true
                        },
                        "agent_auto_resolve": {
                          "type": "boolean",
                          "description": "Optional; send it only to change the setting. Same rules as the Space settings PATCH."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/issues/sources/config": {
      "get": {
        "summary": "Check optional contextual Issue capture availability",
        "description": "App-origin personal-account capability probe. Default off: 404 FEATURE_DISABLED unless ISSUES_CAPTURE_ENABLED=1. Requires ISSUES_ENABLED=1. No source content is returned or stored.",
        "operationId": "get_api_issues_sources_config",
        "x-required-scope": "issues:read",
        "responses": {
          "200": {
            "description": "Capture enabled for this active personal account. Response: {success:true,enabled:true}."
          },
          "400": {
            "description": "INVALID_INPUT"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "PERSON_REQUIRED or SCOPE_REQUIRED"
          },
          "404": {
            "description": "FEATURE_DISABLED unless ISSUES_CAPTURE_ENABLED=1 (exactly, read per request), or SOURCE_UNAVAILABLE if independent access to the exact source fails."
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE"
          }
        }
      }
    },
    "/api/issues/sources/resolve": {
      "get": {
        "summary": "Resolve an authorized exact-version source before filing",
        "description": "App-origin read-only endpoint; scoped personal PATs additionally require shares:read. For an active personal account with independent current account-audience access to this share, effective content version and thread. Public-link/recipient capabilities never authorize capture. Only the source owner may reference an available archived version under the existing artifact policy; retired or mismatched versions never fall through to current content. The thread must belong to this share and exact version. Returns excerpt, source, version and only same-thread Issues the caller can already read. Does not create or stage an Issue. Default off: 404 FEATURE_DISABLED unless ISSUES_CAPTURE_ENABLED=1 (exactly, read per request); ISSUES_ENABLED=1 also required.",
        "operationId": "get_api_issues_sources_resolve",
        "x-required-scope": "issues:read",
        "parameters": [
          {
            "name": "kind",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "review_thread",
                "artifact"
              ]
            }
          },
          {
            "name": "share",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            }
          },
          {
            "name": "version",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "thread",
            "in": "query",
            "required": false,
            "description": "Required for review_thread; belongs to this exact share/version.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized source, version, excerpt and independently readable existing Issues.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "source": {
                      "$ref": "#/components/schemas/IssueSource"
                    },
                    "version": {
                      "type": "integer"
                    },
                    "excerpt": {
                      "type": "string"
                    },
                    "issues": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_INPUT"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "PERSON_REQUIRED or SCOPE_REQUIRED"
          },
          "404": {
            "description": "FEATURE_DISABLED unless ISSUES_CAPTURE_ENABLED=1 (exactly, read per request), or SOURCE_UNAVAILABLE if independent access to the exact source fails."
          },
          "503": {
            "description": "ISSUES_DISABLED or ACCOUNTS_UNAVAILABLE"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Personal API token or current user JWT. GET /api/auth/scopes lists scopes. Session-only approval rejects all API tokens, including legacy tokens."
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._:-]{8,128}$"
        },
        "description": "Stable key for retries of the same payload and operation for 30 days. A deliberate edit needs a new key. Ownership changes invalidate old owner write outcomes."
      }
    },
    "schemas": {
      "IssueSource": {
        "type": "object",
        "additionalProperties": false,
        "description": "Optional exact-version source, off by default. Requires ISSUES_CAPTURE_ENABLED=1. Consumes one of the 10 evidence references, bound atomically on explicit create with source kind and thread metadata. Keeps independent artifact authorization.",
        "oneOf": [
          {
            "properties": {
              "kind": {
                "enum": [
                  "review_thread"
                ]
              }
            },
            "required": [
              "thread"
            ]
          },
          {
            "properties": {
              "kind": {
                "enum": [
                  "artifact"
                ]
              }
            },
            "not": {
              "required": [
                "thread"
              ]
            }
          }
        ],
        "required": [
          "kind",
          "share",
          "version"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "review_thread",
              "artifact"
            ]
          },
          "share": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "thread": {
            "type": "integer",
            "minimum": 1,
            "description": "Required for review_thread; root thread on this exact share and version."
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "code": {
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "field": {
            "type": "string",
            "description": "The refused field for VERIFICATION_INVALID and VERIFICATION_FAILED, for example verification.change.commit."
          }
        }
      },
      "LatestOwnerProgress": {
        "type": "object",
        "nullable": true,
        "description": "Latest saved owner update independent of the paged activity timeline. Null before the first owner update. Comments and other event kinds never replace it.",
        "required": [
          "event_id",
          "summary",
          "blockers",
          "next_step",
          "created_at"
        ],
        "properties": {
          "event_id": {
            "type": "integer"
          },
          "summary": {
            "type": "string",
            "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
            "allOf": [
              {
                "$ref": "#/components/schemas/IssueText"
              }
            ]
          },
          "blockers": {
            "type": "string",
            "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
            "allOf": [
              {
                "$ref": "#/components/schemas/IssueText"
              }
            ]
          },
          "next_step": {
            "type": "string",
            "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example.",
            "allOf": [
              {
                "$ref": "#/components/schemas/IssueText"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "IssueEvidenceUsage": {
        "type": "object",
        "description": "Current bound evidence usage for an authorized Issue reader, independent of per-uploader staging/quota. All reference kinds count, even when an artifact's protected metadata is unavailable. Only uploads consume bytes. Add current staging locally; the server rechecks the limits when binding.",
        "required": [
          "references",
          "bytes",
          "max_references",
          "max_bytes"
        ],
        "properties": {
          "references": {
            "type": "integer",
            "minimum": 0
          },
          "bytes": {
            "type": "integer",
            "minimum": 0
          },
          "max_references": {
            "type": "integer",
            "enum": [
              10
            ]
          },
          "max_bytes": {
            "type": "integer",
            "enum": [
              52428800
            ]
          }
        }
      },
      "IssuePermissions": {
        "type": "object",
        "required": [
          "manage",
          "owner",
          "comment"
        ],
        "properties": {
          "manage": {
            "type": "boolean",
            "description": "Existing manager capability, still subject to explicit Space plus current exact Team membership and manager authority."
          },
          "owner": {
            "type": "boolean",
            "description": "Existing current-owner indicator; existing eligible-owner requirements govern owner writes and are not widened by Team-only reading."
          },
          "comment": {
            "type": "boolean",
            "description": "Authoritative per-Issue comment capability under the preserved explicit Space member/owner AND current exact Team membership gate. Team-only readers are false. Paused intake does not itself disable comments; existing token scope, feature, revision and retry requirements still apply."
          },
          "set_fixed": {
            "type": "boolean",
            "description": "The reader is the issue's owner and the status is Open, In Progress or Fixed (a refresh). The write still checks eligibility and needs a passing verification record."
          },
          "back_to_in_progress": {
            "type": "boolean",
            "description": "The reader is the owner and the status is Fixed."
          },
          "reopen": {
            "type": "boolean",
            "description": "The reader is an issue manager and the status is Fixed or Resolved. A scoped token additionally needs issues:manage."
          },
          "resolve": {
            "type": "string",
            "nullable": true,
            "enum": [
              "direct",
              "agent_auto_resolve",
              "owner_review",
              null
            ],
            "description": "null: this reader cannot resolve. direct: the owner in a web session (who may also approve the saved result for an agent). agent_auto_resolve: the owner's token where the Space allows agent auto-resolve; send status Resolved with a passing verification record and no approval_id. owner_review: the owner's token otherwise; ask the owner to review at /issues.html?id=ISSUE_ID and resolve with the approval_id."
          }
        }
      },
      "IssueText": {
        "type": "string",
        "description": "Issue text format 1 (issue-text/1) is a display reading of plain text; stored text is never rewritten. A blank line separates paragraphs; a single line break inside a paragraph is kept. Lines starting with \"- \" or \"* \" form a bullet list. Lines starting with a number and \". \" or \") \" form a numbered list that keeps its numbers; a list item may continue on following lines indented by two or more spaces. A line starting with \"# \", \"## \" or \"### \" is a heading displayed below the page’s own headings. Text between single backticks is inline code; lines between two lines of three backticks are a code block. Bare http:// or https:// addresses and [label](https://address) become links with rel=\"noopener noreferrer\"; no other schemes are links. Everything else is literal: no emphasis, no tables, no images, no HTML. Characters such as * _ # < > & and raw HTML inside a paragraph are shown as typed. The renderer builds DOM nodes and never assigns reporter or agent text to innerHTML.",
        "example": "已定位示例预览的换行问题。The demo preview now keeps its paragraphs.\n\n- Checked `frontend/demo/preview.js` in the local fixture.\n- 阻碍：等待示例截图复核。\n\n1. Review the fixture at https://example.test/demo.\n2) Ask the human owner to review the saved result."
      },
      "IssueReportDetails": {
        "type": "object",
        "additionalProperties": false,
        "description": "Optional detail fields in Issue text format 1; the brief includes only filled fields.",
        "properties": {
          "reproduction_steps": {
            "type": "string",
            "allOf": [
              {
                "$ref": "#/components/schemas/IssueText"
              }
            ],
            "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example."
          },
          "expected_behavior": {
            "type": "string",
            "allOf": [
              {
                "$ref": "#/components/schemas/IssueText"
              }
            ],
            "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example."
          },
          "actual_behavior": {
            "type": "string",
            "allOf": [
              {
                "$ref": "#/components/schemas/IssueText"
              }
            ],
            "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example."
          },
          "requested_change": {
            "type": "string",
            "allOf": [
              {
                "$ref": "#/components/schemas/IssueText"
              }
            ],
            "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example."
          },
          "intended_outcome": {
            "type": "string",
            "allOf": [
              {
                "$ref": "#/components/schemas/IssueText"
              }
            ],
            "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example."
          }
        }
      },
      "IssueVerificationInput": {
        "type": "object",
        "additionalProperties": false,
        "description": "A verification record of an automated test run that really happened: never invent, round or reuse another run's results. Unknown fields are refused at every level; the whole record, as canonical JSON, is at most 4096 bytes. Shape errors are 400 VERIFICATION_INVALID with field naming the first refused field; failed above 0 or passed 0 is 422 VERIFICATION_FAILED. Count cancelled tests as failed and to-do tests as skipped. The server checks shape, not truth: it records who sent the record and how, and stores it literally.",
        "required": [
          "subject",
          "passed",
          "failed",
          "skipped",
          "tested_at",
          "change"
        ],
        "properties": {
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300,
            "description": "What was tested: a command, suite or run name. One line: trimmed; control characters and bidirectional controls (U+202A–U+202E, U+2066–U+2069) are refused."
          },
          "passed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000000,
            "description": "Passing tests. Must be at least 1 (0 is 422 VERIFICATION_FAILED)."
          },
          "failed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000000,
            "description": "Failing tests, cancelled ones included. Must be 0 (above 0 is 422 VERIFICATION_FAILED)."
          },
          "skipped": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000000,
            "description": "Skipped tests, to-do ones included."
          },
          "tested_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339 with Z or an offset; not before 2020-01-01 and not more than 5 minutes after the server clock. Stored in UTC."
          },
          "change": {
            "type": "object",
            "additionalProperties": false,
            "description": "The change that was tested: a commit with its repository, a pull request or a branch (at least one).",
            "anyOf": [
              {
                "required": [
                  "commit",
                  "repository"
                ]
              },
              {
                "required": [
                  "pull_request"
                ]
              },
              {
                "required": [
                  "branch"
                ]
              }
            ],
            "properties": {
              "repository": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200,
                "description": "OWNER/REPO, HOST/OWNER/REPO or an https address."
              },
              "commit": {
                "type": "string",
                "pattern": "^[0-9A-Fa-f]{7,64}$",
                "description": "7–64 hexadecimal characters; stored in lower case. Needs repository."
              },
              "pull_request": {
                "type": "string",
                "format": "uri",
                "maxLength": 500,
                "description": "An https address with a host and no user name or password, without white space or control characters; stored as sent and never fetched."
              },
              "branch": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200,
                "pattern": "^(?!-)(?!.*\\.\\.)[A-Za-z0-9._/-]{1,200}$",
                "description": "Letters, digits, \".\", \"_\", \"/\" and \"-\"; no leading \"-\" and no \"..\"."
              }
            }
          },
          "release": {
            "type": "object",
            "additionalProperties": false,
            "minProperties": 1,
            "description": "Optional release of the change: at least one of version, environment and url.",
            "properties": {
              "version": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "description": "Version or tag. One line: trimmed; control characters and bidirectional controls (U+202A–U+202E, U+2066–U+2069) are refused."
              },
              "environment": {
                "type": "string",
                "minLength": 1,
                "maxLength": 50,
                "description": "For example production. One line: trimmed; control characters and bidirectional controls (U+202A–U+202E, U+2066–U+2069) are refused."
              },
              "url": {
                "type": "string",
                "format": "uri",
                "maxLength": 500,
                "description": "An https address with a host and no user name or password, without white space or control characters; stored as sent and never fetched."
              }
            }
          },
          "run_url": {
            "type": "string",
            "format": "uri",
            "maxLength": 500,
            "description": "A run or status-page address. An https address with a host and no user name or password, without white space or control characters; stored as sent and never fetched."
          },
          "summary": {
            "type": "string",
            "maxLength": 1000,
            "description": "Optional short test summary; trimmed; line breaks and tabs allowed, other control characters refused. Shown literally."
          }
        }
      },
      "IssueVerification": {
        "type": "object",
        "additionalProperties": false,
        "description": "A stored verification record as returned: the sent fields, normalized (trimmed text, lower-case commit, tested_at in UTC), plus the fields the server adds. digest is the SHA-256 of the stored record as canonical JSON (sorted keys; recorded_by as the user id) and names the record in review, hand-off and brief.",
        "required": [
          "subject",
          "passed",
          "failed",
          "skipped",
          "tested_at",
          "change",
          "status",
          "recorded_at",
          "recorded_by",
          "via",
          "integration_name",
          "digest"
        ],
        "properties": {
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300,
            "description": "What was tested: a command, suite or run name. One line: trimmed; control characters and bidirectional controls (U+202A–U+202E, U+2066–U+2069) are refused."
          },
          "passed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000000,
            "description": "Passing tests. Must be at least 1 (0 is 422 VERIFICATION_FAILED)."
          },
          "failed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000000,
            "description": "Failing tests, cancelled ones included. Must be 0 (above 0 is 422 VERIFICATION_FAILED)."
          },
          "skipped": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000000,
            "description": "Skipped tests, to-do ones included."
          },
          "tested_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339 with Z or an offset; not before 2020-01-01 and not more than 5 minutes after the server clock. Stored in UTC."
          },
          "change": {
            "type": "object",
            "additionalProperties": false,
            "description": "The change that was tested: a commit with its repository, a pull request or a branch (at least one).",
            "properties": {
              "repository": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200,
                "description": "OWNER/REPO, HOST/OWNER/REPO or an https address."
              },
              "commit": {
                "type": "string",
                "pattern": "^[0-9A-Fa-f]{7,64}$",
                "description": "7–64 hexadecimal characters; stored in lower case. Needs repository."
              },
              "pull_request": {
                "type": "string",
                "format": "uri",
                "maxLength": 500,
                "description": "An https address with a host and no user name or password, without white space or control characters; stored as sent and never fetched."
              },
              "branch": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200,
                "pattern": "^(?!-)(?!.*\\.\\.)[A-Za-z0-9._/-]{1,200}$",
                "description": "Letters, digits, \".\", \"_\", \"/\" and \"-\"; no leading \"-\" and no \"..\"."
              }
            }
          },
          "release": {
            "type": "object",
            "additionalProperties": false,
            "minProperties": 1,
            "description": "Optional release of the change: at least one of version, environment and url.",
            "properties": {
              "version": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "description": "Version or tag. One line: trimmed; control characters and bidirectional controls (U+202A–U+202E, U+2066–U+2069) are refused."
              },
              "environment": {
                "type": "string",
                "minLength": 1,
                "maxLength": 50,
                "description": "For example production. One line: trimmed; control characters and bidirectional controls (U+202A–U+202E, U+2066–U+2069) are refused."
              },
              "url": {
                "type": "string",
                "format": "uri",
                "maxLength": 500,
                "description": "An https address with a host and no user name or password, without white space or control characters; stored as sent and never fetched."
              }
            }
          },
          "run_url": {
            "type": "string",
            "format": "uri",
            "maxLength": 500,
            "description": "A run or status-page address. An https address with a host and no user name or password, without white space or control characters; stored as sent and never fetched."
          },
          "summary": {
            "type": "string",
            "maxLength": 1000,
            "description": "Optional short test summary; trimmed; line breaks and tabs allowed, other control characters refused. Shown literally."
          },
          "status": {
            "type": "string",
            "enum": [
              "Fixed",
              "Resolved"
            ],
            "description": "Fixed, or Resolved when the owner's agent resolved with this record where the Space allows agent auto-resolve."
          },
          "recorded_at": {
            "type": "string",
            "format": "date-time"
          },
          "recorded_by": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "username"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "username": {
                "type": "string"
              }
            }
          },
          "via": {
            "type": "string",
            "enum": [
              "session",
              "token"
            ]
          },
          "integration_name": {
            "type": "string",
            "nullable": true,
            "description": "The token's name for a token write, otherwise null."
          },
          "digest": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        }
      },
      "IssueBrief": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "format",
          "version",
          "text_format",
          "id",
          "url",
          "title",
          "type",
          "priority",
          "space",
          "team",
          "report",
          "status",
          "owner",
          "reporter",
          "created_at",
          "updated_at",
          "last_progress_at",
          "latest_owner_progress",
          "verification",
          "evidence",
          "artifact_references",
          "permissions",
          "write",
          "next_actions",
          "markdown"
        ],
        "properties": {
          "format": {
            "type": "string",
            "enum": [
              "pitchstation-issue-brief"
            ]
          },
          "version": {
            "type": "integer",
            "enum": [
              1
            ]
          },
          "text_format": {
            "type": "string",
            "enum": [
              "issue-text/1"
            ]
          },
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Canonical Issue URL; sharing it grants no access."
          },
          "title": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "Bug",
              "Enhancement"
            ]
          },
          "priority": {
            "type": "string",
            "nullable": true,
            "enum": [
              "Low",
              "Medium",
              "High",
              null
            ],
            "description": "Optional reporter-selected priority; null means no priority. AI drafting never chooses it."
          },
          "space": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "title"
            ],
            "properties": {
              "id": {
                "type": "integer"
              },
              "title": {
                "type": "string"
              }
            }
          },
          "team": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "title"
            ],
            "properties": {
              "id": {
                "type": "integer"
              },
              "title": {
                "type": "string"
              }
            },
            "nullable": true
          },
          "report": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "description",
              "original_text_same_as_description",
              "details"
            ],
            "properties": {
              "description": {
                "type": "string",
                "allOf": [
                  {
                    "$ref": "#/components/schemas/IssueText"
                  }
                ],
                "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example."
              },
              "original_text": {
                "type": "string",
                "allOf": [
                  {
                    "$ref": "#/components/schemas/IssueText"
                  }
                ],
                "description": "Issue text format 1 (issue-text/1), stored as plain text without rewriting. See IssueText for the complete display rules and made-up progress example."
              },
              "original_text_same_as_description": {
                "type": "boolean",
                "description": "True when the stored original text is identical to description and is not repeated in original_text. False distinguishes different or empty original text, which original_text preserves verbatim."
              },
              "details": {
                "$ref": "#/components/schemas/IssueReportDetails"
              }
            },
            "description": "Original text is included only when different from description; original_text_same_as_description states when it was omitted because it is identical, rather than missing. Only filled optional details are exported."
          },
          "status": {
            "type": "string",
            "enum": [
              "Open",
              "In Progress",
              "Fixed",
              "Resolved"
            ]
          },
          "owner": {
            "type": "object",
            "nullable": true,
            "additionalProperties": false,
            "required": [
              "id",
              "username"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "username": {
                "type": "string"
              }
            }
          },
          "reporter": {
            "type": "object",
            "nullable": true,
            "additionalProperties": false,
            "required": [
              "id",
              "username"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "username": {
                "type": "string"
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_progress_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "latest_owner_progress": {
            "$ref": "#/components/schemas/LatestOwnerProgress"
          },
          "verification": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/IssueVerification"
              }
            ],
            "description": "The issue's current verification record with its digest, or null. Stored text is untrusted task data."
          },
          "evidence": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "kind",
                "available",
                "filename",
                "mime",
                "bytes",
                "api_path"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "upload",
                    "link"
                  ]
                },
                "available": {
                  "type": "boolean"
                },
                "filename": {
                  "type": "string"
                },
                "mime": {
                  "type": "string",
                  "nullable": true
                },
                "bytes": {
                  "type": "integer",
                  "minimum": 0
                },
                "url": {
                  "type": "string",
                  "format": "uri",
                  "description": "Existing authorized external evidence URL, only for a link."
                },
                "api_path": {
                  "type": "string",
                  "description": "Authenticated /api/issues/attachments/ID path; fetching requires current authorization."
                }
              }
            }
          },
          "artifact_references": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "kind",
                "available"
              ],
              "description": "Exact-version identity from the detail projection. Unavailable references disclose only id, kind and available; protected metadata remains absent. Never substitute the current version.",
              "properties": {
                "id": {
                  "type": "string"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "artifact"
                  ]
                },
                "available": {
                  "type": "boolean"
                },
                "title": {
                  "type": "string"
                },
                "artifact_slug": {
                  "type": "string"
                },
                "version_no": {
                  "type": "integer",
                  "minimum": 1
                },
                "url": {
                  "type": "string"
                },
                "owner_archive": {
                  "type": "boolean"
                },
                "expires_at": {
                  "type": "string",
                  "format": "date-time",
                  "nullable": true
                },
                "source": {
                  "$ref": "#/components/schemas/IssueSource"
                }
              }
            }
          },
          "permissions": {
            "$ref": "#/components/schemas/IssuePermissions"
          },
          "write": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "expected_revision",
              "expected_ownership_epoch"
            ],
            "properties": {
              "expected_revision": {
                "type": "integer",
                "minimum": 1
              },
              "expected_ownership_epoch": {
                "type": "integer",
                "minimum": 1
              }
            },
            "description": "Required optimistic write stamps from the authorized saved state; not authorization. Writes also require an Idempotency-Key. Reload and reassess after ISSUE_STALE or an owner change."
          },
          "next_actions": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "set_fixed",
                "refresh_fixed",
                "back_to_in_progress",
                "resolve",
                "resolve_with_verification",
                "request_owner_review",
                "reopen"
              ]
            },
            "description": "What this reader may do next, in this order: set_fixed (Open or In Progress) or refresh_fixed (Fixed), back_to_in_progress, then one resolve action (resolve in a web session; resolve_with_verification where the Space allows agent auto-resolve; request_owner_review otherwise), then reopen for a manager. Empty when the reader may do none of these. It sits beside write, never inside it: write holds exactly the stamps a client sends back. It grants nothing; every write is checked again."
          },
          "markdown": {
            "type": "string",
            "description": "Same content under fixed headings in this order: Identity; Report; Original text; Reproduction steps; Expected behaviour; Actual behaviour; Requested change; Intended outcome; Status and people; Times; Latest owner progress; Summary; Blockers; Next step; Verification (only when a record exists); Evidence; Artifact references; Permissions; Write requirements; Next actions. The first line is pitchstation-issue-brief version 1. Empty headings contain Not provided. When original_text_same_as_description is true, Original text contains the fixed sentence: The original text is identical to the report above and is not repeated. That sentence is brief prose; stored text is placed in indented code blocks so hostile headings, HTML or code fences cannot become brief structure. Same saved Issue state and caller projection produce the same bytes. Identity includes one Priority line only when set; an unset priority produces no priority line or placeholder."
          }
        }
      },
      "Issue": {
        "type": "object",
        "description": "Common Issue response projection. Existing fields retain their authorization and semantics; priority is always present, including null when unset. Detail and successful mutations additionally include latest_owner_progress. verification is always present, null when the issue has no current record; agent_auto_resolve is the Space's setting.",
        "required": [
          "priority",
          "verification"
        ],
        "properties": {
          "priority": {
            "type": "string",
            "nullable": true,
            "enum": [
              "Low",
              "Medium",
              "High",
              null
            ],
            "description": "Optional reporter-selected priority; null means no priority. AI drafting never chooses it."
          },
          "verification": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/IssueVerification"
              }
            ],
            "description": "The current verification record, or null. Set by Fixed and by an agent auto-resolve; cleared when the issue goes back to In Progress or Open; kept by a reviewed resolution. Activity keeps every record."
          },
          "agent_auto_resolve": {
            "type": "boolean",
            "description": "The issue Space's current agent auto-resolve setting, shown read-only to every reader of the issue."
          }
        }
      }
    }
  }
}
