openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: API specification servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication and account management - name: storyworlds description: Storyworlds and their story paths - name: proposals description: Proposals (pull-request-backed submissions) - name: narrate description: Voice narration and transcription for mobile contributors paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /auth/register: post: operationId: register tags: [auth] summary: Create a new contributor account description: Registers with email and password. No GitHub account required. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RegisterRequest" responses: "201": description: Account created and session started content: application/json: schema: $ref: "#/components/schemas/AuthResponse" "400": $ref: "#/components/responses/BadRequest" "409": description: Email already registered content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/login: post: operationId: login tags: [auth] summary: Log in with email and password requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginRequest" responses: "200": description: Logged in content: application/json: schema: $ref: "#/components/schemas/AuthResponse" "400": $ref: "#/components/responses/BadRequest" "401": description: Invalid credentials content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/logout: post: operationId: logout tags: [auth] summary: End the current session responses: "200": description: Logged out content: application/json: schema: type: object properties: ok: type: boolean required: [ok] /auth/me: get: operationId: getMe tags: [auth] summary: Return the current user's profile description: Requires an active session. responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/MeResponse" "401": $ref: "#/components/responses/Unauthorized" /me/contributions: get: operationId: listMyContributions tags: [narrate] summary: List the current contributor's activity description: > Returns durable narrations submitted by the authenticated contributor and eligible pending or returned PR submissions. A PR submission is included only through its explicit contributor record and the user's linked GitHub identity; ownership is never inferred from a story path. responses: "200": description: Current contributor's activity content: application/json: schema: type: array items: $ref: "#/components/schemas/MyContribution" "401": $ref: "#/components/responses/Unauthorized" /me/notifications: get: operationId: listContributorNotifications tags: [narrate] summary: List the current contributor's notifications description: > Returns calm plain-language updates for the authenticated contributor. Technical failures, raw GitHub events, and maintainer triage are not exposed through this inbox. responses: "200": description: Contributor notifications content: application/json: schema: type: array items: $ref: "#/components/schemas/ContributorNotification" "401": $ref: "#/components/responses/Unauthorized" /me/notifications/{id}/read: post: operationId: markContributorNotificationRead tags: [narrate] summary: Mark one contributor notification as read parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Updated notification content: application/json: schema: $ref: "#/components/schemas/ContributorNotification" "401": $ref: "#/components/responses/Unauthorized" "404": description: Notification not found for this contributor /consents: get: operationId: listConsentRecords tags: [auth] summary: List the current user's active consent choices responses: "200": description: Active consent choices content: application/json: schema: type: array items: $ref: "#/components/schemas/ConsentRecord" "401": $ref: "#/components/responses/Unauthorized" post: operationId: grantConsent tags: [auth] summary: Grant one versioned consent choice requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ConsentInput" responses: "201": description: Recorded consent content: application/json: schema: $ref: "#/components/schemas/ConsentRecord" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "403": description: Reserved derivative consent is unavailable "404": $ref: "#/components/responses/NotFound" /consents/{id}/revoke: post: operationId: revokeConsent tags: [auth] summary: Revoke one active consent prospectively parameters: - name: id in: path required: true schema: type: string format: uuid responses: "200": description: Revocation record content: application/json: schema: $ref: "#/components/schemas/ConsentRecord" "401": $ref: "#/components/responses/Unauthorized" "404": $ref: "#/components/responses/NotFound" /auth/github/authorize: get: operationId: githubAuthorize tags: [auth] summary: Start GitHub account linking description: > Redirects to GitHub's OAuth authorization page. The user must already be logged in. GitHub account linking is optional — contributors do not need a GitHub account to participate. responses: "302": description: Redirect to GitHub "401": $ref: "#/components/responses/Unauthorized" "503": description: GitHub linking not configured on this server /auth/github/callback: get: operationId: githubCallback tags: [auth] summary: GitHub OAuth callback description: > GitHub redirects here after the user authorizes the app. Links the GitHub account to the current platform account and redirects to the frontend. parameters: - name: code in: query schema: type: string - name: state in: query schema: type: string - name: error in: query schema: type: string responses: "302": description: Redirect to frontend with github_link query param (success|denied|error) "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" /storyworlds: get: operationId: listStoryworlds tags: [storyworlds] summary: List all storyworlds responses: "200": description: Storyworld list content: application/json: schema: type: array items: $ref: "#/components/schemas/Storyworld" post: operationId: registerStoryworld tags: [storyworlds] summary: Register an existing GitHub Storyworld Kit repository description: > Requires authentication and an explicit rights confirmation. The repository must already exist on GitHub; this operation never creates or changes repository content. The server reads storyworld.json and the complete Storyworld Kit contract before indexing the repository. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/StoryworldRegistration" responses: "201": description: Storyworld registered content: application/json: schema: $ref: "#/components/schemas/Storyworld" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "403": description: Registration requires steward authority content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "409": description: Repository is already registered content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "422": description: Repository does not satisfy the Storyworld Kit contract content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /storyworlds/{id}: get: operationId: getStoryworld tags: [storyworlds] summary: Get a storyworld by id parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Storyworld content: application/json: schema: $ref: "#/components/schemas/Storyworld" "404": $ref: "#/components/responses/NotFound" patch: operationId: updateStoryworld tags: [storyworlds] summary: Update a storyworld's steward-managed details description: > Updates the short seed sentence surfaced on the Reader discovery page. Requires authentication and steward role for the storyworld. parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/StoryworldUpdate" responses: "200": description: Updated storyworld content: application/json: schema: $ref: "#/components/schemas/Storyworld" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" /storyworlds/{id}/paths: get: operationId: listStoryPaths tags: [storyworlds] summary: List story paths for a storyworld parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Story path list content: application/json: schema: type: array items: $ref: "#/components/schemas/StoryPath" "404": $ref: "#/components/responses/NotFound" /storyworlds/{id}/paths/{pathId}/contributions: get: operationId: listContributions tags: [storyworlds] summary: List contributions for a story path parameters: - name: id in: path required: true schema: type: integer - name: pathId in: path required: true schema: type: integer responses: "200": description: Contribution list content: application/json: schema: type: array items: $ref: "#/components/schemas/Contribution" "404": $ref: "#/components/responses/NotFound" post: operationId: createContribution tags: [storyworlds] summary: Submit a narration to an open story path description: > Creates a contributor record for the authenticated user and commits the narration to the selected open path's branch in the storyworld repository. The Git commit is the durable source of truth; the contribution record indexes it. Requires authentication. parameters: - name: id in: path required: true schema: type: integer - name: pathId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ContributionInput" responses: "201": description: Submitted contribution content: application/json: schema: $ref: "#/components/schemas/Contribution" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "404": $ref: "#/components/responses/NotFound" "409": description: The selected path is not open for contributions content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "502": description: GitHub could not save the submission content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /storyworlds/{id}/provenance: get: operationId: listStoryworldProvenance tags: [storyworlds] summary: Show how contributions entered the canon description: > Reader-facing lineage for accepted story contributions. Uses plain story language rather than source-control terminology. parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Accepted contribution lineage content: application/json: schema: type: array items: $ref: "#/components/schemas/StoryProvenance" "404": $ref: "#/components/responses/NotFound" /storyworlds/{id}/capsules: get: operationId: listCapsules tags: [storyworlds] summary: List concept capsules for a storyworld description: > Returns open capsules (GitHub Issues tagged capsule:*) for the storyworld. Requires authentication. parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Capsule list content: application/json: schema: type: array items: $ref: "#/components/schemas/Capsule" "401": $ref: "#/components/responses/Unauthorized" "404": $ref: "#/components/responses/NotFound" post: operationId: createCapsule tags: [storyworlds] summary: Create a concept capsule description: > Creates a GitHub Issue in the storyworld's repo and returns the mapped capsule. Requires authentication and steward role. parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateCapsuleBody" responses: "201": description: Created capsule content: application/json: schema: $ref: "#/components/schemas/Capsule" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" /storyworlds/{id}/manuscript-ingestion: post: operationId: queueManuscriptIngestion tags: [storyworlds] summary: Queue an owned manuscript for draft capsule extraction description: > Commits an authorized steward's DOCX, EPUB, or PDF to the private intake path and dispatches the pinned repository workflow. The workflow creates only GitHub Issue capsules labeled state:draft; human promotion remains the only path from a capsule to a scene. parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/QueueManuscriptIngestionBody" responses: "202": description: Manuscript committed and workflow queued content: application/json: schema: $ref: "#/components/schemas/QueueManuscriptIngestionResponse" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "502": description: GitHub commit or workflow dispatch failed content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /storyworlds/{id}/capsules/{capsuleId}: patch: operationId: updateCapsule tags: [storyworlds] summary: Update a concept capsule description: > Updates the GitHub Issue backing the capsule. Requires authentication and steward role. parameters: - name: id in: path required: true schema: type: integer - name: capsuleId in: path required: true schema: type: integer description: GitHub Issue number requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateCapsuleBody" responses: "200": description: Updated capsule content: application/json: schema: $ref: "#/components/schemas/Capsule" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" delete: operationId: deleteCapsule tags: [storyworlds] summary: Archive a concept capsule description: > Closes the GitHub Issue backing the capsule (soft delete — issue remains on GitHub). Requires authentication and steward role. parameters: - name: id in: path required: true schema: type: integer - name: capsuleId in: path required: true schema: type: integer description: GitHub Issue number responses: "204": description: Capsule archived "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" /storyworlds/{id}/capsules/{capsuleId}/promote: post: operationId: promoteCapsule tags: [storyworlds] summary: Generate an agent-assisted scene draft from a capsule (streaming SSE) description: > Promotes a capsule to the Scene Writer by streaming an AI-generated opening scene via Server-Sent Events. The response is `text/event-stream`; each event carries `{ content }` chunks and a final `{ done: true }` event. Use native fetch + ReadableStream on the client — Orval does not generate hooks for streaming responses. Requires authentication and steward role. parameters: - name: id in: path required: true schema: type: integer - name: capsuleId in: path required: true schema: type: integer description: GitHub Issue number of the capsule to promote. responses: "200": description: Streaming SSE — text/event-stream "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" /storyworlds/{id}/capsules/{capsuleId}/disrupt: post: operationId: disruptCapsule tags: [storyworlds] summary: Generate a divergent variant capsule from an accepted scene (prose-level inversion) description: > Takes an accepted scene (provided as `sourceText`) and uses the AI layer to produce a deliberately discontinuous raw-material capsule — not a summary, a divergent seed. The returned proposal is not created on the board until the author explicitly accepts it. Requires authentication and steward role. parameters: - name: id in: path required: true schema: type: integer - name: capsuleId in: path required: true schema: type: integer description: GitHub Issue number of the capsule being disrupted. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DisruptCapsuleBody" responses: "200": description: Proposed disruption capsule content: application/json: schema: $ref: "#/components/schemas/CapsuleProposalResponse" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" /storyworlds/{id}/capsules/{capsuleId}/invert: post: operationId: invertCapsule tags: [storyworlds] summary: Generate the symbolic inversion of a capsule (concept-level inversion) description: > Produces a new capsule representing the symbolic shadow of the source capsule — not its antonym, but its structural mirror with reversed purpose or charge. The returned proposal is not created on the board until the author explicitly accepts it. Requires authentication and steward role. parameters: - name: id in: path required: true schema: type: integer - name: capsuleId in: path required: true schema: type: integer description: GitHub Issue number of the capsule to invert. responses: "200": description: Proposed inversion capsule content: application/json: schema: $ref: "#/components/schemas/CapsuleProposalResponse" "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" /storyworlds/{id}/proposals: get: operationId: listStoryworldProposals tags: [proposals] summary: List all proposals for a storyworld (steward dashboard) description: > Returns proposals for a storyworld ordered by submission date descending. Requires authentication and steward role for the storyworld. parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Proposal list content: application/json: schema: type: array items: $ref: "#/components/schemas/StewardProposal" "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" /admin/webhook-deliveries/{id}: get: operationId: listWebhookDeliveryEvidence tags: [storyworlds] summary: Inspect redacted GitHub delivery evidence description: > Returns the storyworld-scoped audit projection of signed GitHub deliveries. Requires authentication and steward role. Raw payloads, signatures, webhook secrets, moderation details, and contributor-private data are never returned. parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Redacted delivery evidence content: application/json: schema: type: array items: $ref: "#/components/schemas/WebhookDeliveryEvidence" "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /proposals: get: operationId: listProposals tags: [proposals] summary: List proposals responses: "200": description: Proposal list content: application/json: schema: type: array items: $ref: "#/components/schemas/Proposal" /transcribe: post: operationId: transcribeAudio tags: [narrate] summary: Transcribe voice narration to text description: > Accepts a base64-encoded audio recording and returns the transcribed text. Uses OpenAI Whisper when OPENAI_API_KEY is configured on the server. Returns 503 when not configured — clients should fall back to manual text entry. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/TranscribeRequest" responses: "200": description: Transcribed text content: application/json: schema: $ref: "#/components/schemas/TranscribeResponse" "503": description: Transcription service not configured content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /proposals/{id}: get: operationId: getProposal tags: [proposals] summary: Get a proposal by id parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Proposal content: application/json: schema: $ref: "#/components/schemas/ProposalDetail" "404": $ref: "#/components/responses/NotFound" /proposals/{id}/versions: post: operationId: createProposalVersion tags: [proposals] summary: Register an immutable proposal version description: > Registers one exact proposed output in a proposal lineage. A predecessor must be a direct version in the same lineage; the mutable proposal record is never used as a substitute for version_ref. Requires authentication. parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateProposalVersionBody" responses: "201": description: Immutable proposal version content: application/json: schema: $ref: "#/components/schemas/CreateProposalVersionResponse" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "404": $ref: "#/components/responses/NotFound" "409": description: Version reference is already registered content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "422": description: Predecessor is missing or crosses proposal lineages content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /proposals/{id}/versions/{versionRef}/review/accept: post: operationId: acceptProposalVersion tags: [proposals] summary: Accept one exact proposal version parameters: - $ref: "#/components/parameters/ProposalId" - $ref: "#/components/parameters/ProposalVersionRef" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AcceptProposalVersionBody" responses: "201": description: Append-only contributor acceptance event content: application/json: schema: $ref: "#/components/schemas/ProposalReviewResponse" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "404": $ref: "#/components/responses/NotFound" "409": description: Version is already frozen or event reference conflicts content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "422": description: Exact version, note, or lineage reference is invalid content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /proposals/{id}/versions/{versionRef}/review/reject: post: operationId: rejectProposalVersion tags: [proposals] summary: Reject one exact proposal version parameters: - $ref: "#/components/parameters/ProposalId" - $ref: "#/components/parameters/ProposalVersionRef" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RejectProposalVersionBody" responses: "201": description: Append-only contributor rejection event content: application/json: schema: $ref: "#/components/schemas/ProposalReviewResponse" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "404": $ref: "#/components/responses/NotFound" "409": description: Version is already frozen or event reference conflicts content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "422": description: Exact version, note, or lineage reference is invalid content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /proposals/{id}/versions/{versionRef}/review/request-revision: post: operationId: requestProposalVersionRevision tags: [proposals] summary: Request a new proposal version description: > Records the request against the reviewed version and creates a child version with a new version_ref and fidelity_note_ref. The child starts with no inherited review outcome. parameters: - $ref: "#/components/parameters/ProposalId" - $ref: "#/components/parameters/ProposalVersionRef" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RequestProposalRevisionBody" responses: "201": description: Append-only revision request and new proposal version content: application/json: schema: $ref: "#/components/schemas/ProposalReviewResponse" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "404": $ref: "#/components/responses/NotFound" "409": description: Successor or event reference conflicts content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "422": description: Predecessor, retained note, or retained event is invalid content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /proposals/{id}/versions/{versionRef}/review/appeal: post: operationId: appealProposalVersion tags: [proposals] summary: Appeal a steward decision for one exact proposal version description: > Appends an appeal event to the affected version. It retains the original steward decision and cannot publish, accept into canon, or change consent. parameters: - $ref: "#/components/parameters/ProposalId" - $ref: "#/components/parameters/ProposalVersionRef" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AppealProposalVersionBody" responses: "201": description: Append-only appeal event content: application/json: schema: $ref: "#/components/schemas/ProposalReviewResponse" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "404": $ref: "#/components/responses/NotFound" "409": description: Event reference conflicts content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "422": description: Exact version, note, or lineage reference is invalid content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /proposals/{id}/review: post: operationId: markProposalUnderReview tags: [proposals] summary: Mark a submission as under steward review description: > Transitions a submitted proposal to the "under-review" state, signalling to the contributor that a steward has begun reading it. Requires authentication and steward role for the proposal's storyworld. parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Updated proposal content: application/json: schema: $ref: "#/components/schemas/Proposal" "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" "409": description: Proposal is not in a state that allows this transition content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /proposals/{id}/accept: post: operationId: acceptProposal tags: [proposals] summary: Accept a submission into canon description: > Merges the backing pull request into the canon branch via Octokit, transitions state to "accepted-into-canon", and writes a provenance record. Requires authentication and steward role for the storyworld. parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Accepted proposal with provenance record id content: application/json: schema: $ref: "#/components/schemas/AcceptProposalResponse" "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" "409": description: Proposal cannot be accepted in its current state content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "502": description: GitHub merge failed content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /proposals/{id}/return: post: operationId: returnProposal tags: [proposals] summary: Return a submission with an editor question description: > Posts a review comment on the backing pull request explaining what needs to change, transitions state to "returned-with-notes", and creates an editor_question row. Requires authentication and steward role. parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ReturnProposalBody" responses: "200": description: Updated proposal content: application/json: schema: $ref: "#/components/schemas/Proposal" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" "409": description: Proposal cannot be returned in its current state content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "502": description: GitHub review comment failed content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /proposals/{id}/editor-questions/{questionId}/address: post: operationId: addressEditorQuestion tags: [proposals] summary: Mark an editor question addressed for the contributor's revision description: > Records or clears the contributor's acknowledgement without changing the original editor question. Only the proposal contributor may change it. parameters: - name: id in: path required: true schema: { type: integer } - name: questionId in: path required: true schema: { type: integer } security: - cookieAuth: [] requestBody: required: true content: application/json: schema: type: object properties: addressed: { type: boolean } required: [addressed] responses: "200": description: Updated editor question content: application/json: schema: $ref: "#/components/schemas/EditorQuestion" "401": { $ref: "#/components/responses/Unauthorized" } "403": description: Not the contributor who owns this proposal content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": { $ref: "#/components/responses/NotFound" } /proposals/{id}/restrict: post: operationId: restrictProposal tags: [proposals] summary: Restrict a submission from further editorial review description: > Transitions an active proposal to "restricted". A steward may include an optional reason for the contributor. Requires authentication and steward role for the proposal's storyworld. parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RestrictProposalBody" responses: "200": description: Restricted proposal content: application/json: schema: $ref: "#/components/schemas/Proposal" "400": $ref: "#/components/responses/BadRequest" "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" "409": description: Proposal cannot be restricted in its current state content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /proposals/{id}/withdraw: post: operationId: withdrawProposal tags: [proposals] summary: Withdraw your own submission description: > Transitions an active proposal to "withdrawn". The server verifies that the signed-in user's linked GitHub identity is the author of the backing pull request before allowing withdrawal. parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Withdrawn proposal content: application/json: schema: $ref: "#/components/schemas/Proposal" "401": $ref: "#/components/responses/Unauthorized" "403": description: Signed-in user is not the proposal author content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" "409": description: Proposal cannot be withdrawn in its current state content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "502": description: Pull request author could not be verified content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /proposals/{id}/archive: post: operationId: archiveProposal tags: [proposals] summary: Archive a terminal submission description: > Transitions an already terminal proposal to "archived". Requires authentication and steward role for the proposal's storyworld. parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Archived proposal content: application/json: schema: $ref: "#/components/schemas/Proposal" "401": $ref: "#/components/responses/Unauthorized" "403": description: Not a steward for this storyworld content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": $ref: "#/components/responses/NotFound" "409": description: Proposal cannot be archived in its current state content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" components: parameters: ProposalId: name: id in: path required: true schema: type: integer ProposalVersionRef: name: versionRef in: path required: true schema: type: string minLength: 1 schemas: HealthStatus: type: object properties: status: type: string required: - status ErrorResponse: type: object properties: error: type: string required: - error RegisterRequest: type: object properties: email: type: string format: email password: type: string minLength: 8 displayName: type: string minLength: 1 required: - email - password - displayName LoginRequest: type: object properties: email: type: string format: email password: type: string required: - email - password PublicUser: type: object properties: id: type: integer email: type: string format: email displayName: type: string createdAt: type: string format: date-time required: - id - email - displayName - createdAt GithubLinkInfo: type: object properties: githubUsername: type: string githubEmail: type: string nullable: true linkedAt: type: string format: date-time required: - githubUsername - linkedAt AuthResponse: type: object properties: user: $ref: "#/components/schemas/PublicUser" required: - user MeResponse: type: object properties: user: $ref: "#/components/schemas/PublicUser" github: oneOf: - $ref: "#/components/schemas/GithubLinkInfo" - type: "null" required: - user - github Storyworld: type: object properties: id: type: integer repoOwner: type: string repoName: type: string title: type: string pathCount: type: integer minimum: 0 description: Number of story paths in this storyworld. savedMomentCount: type: integer minimum: 0 description: Number of distinct saved moments indexed in this storyworld. stewardId: type: integer nullable: true canonBranchRef: type: string seed: type: string nullable: true description: > A short seed sentence surfaced on the Reader discovery page. Null when the world creator has not set one yet. readerTheme: $ref: "#/components/schemas/ReaderTheme" createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - repoOwner - repoName - savedMomentCount - title - pathCount - canonBranchRef - readerTheme - createdAt - updatedAt StoryworldRegistration: type: object required: - repository - rightsConfirmed properties: repository: type: string minLength: 1 description: GitHub repository URL or owner/name reference. rightsConfirmed: type: boolean description: > Confirms that the registering steward has checked the repository's contents and has authority to register them for this storyworld. StoryworldUpdate: type: object required: - seed properties: seed: type: ["string", "null"] maxLength: 120 pattern: '^[^\r\n]*$' description: > One short, single-line invitation for the Reader discovery page. Send null to clear the current seed sentence. ReaderTheme: type: string enum: - editorial - terminal - archive - dispatch - signal default: editorial description: > A finite, per-storyworld Reader theme. Every theme preserves the canonical path markers, attribution, provenance, readable type scale, and reduced-motion behavior. StoryPath: type: object properties: id: type: integer storyworldId: type: integer branchRef: type: string title: type: string originPathId: type: integer nullable: true state: type: string # published-canon: path accepted into canon (mutually exclusive with published-alternate) enum: [personal, open, proposed, published-canon, published-alternate] createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - storyworldId - branchRef - title - state - createdAt - updatedAt Contribution: type: object properties: id: type: integer storyworldId: type: integer pathId: type: integer commitSha: type: string contributorId: type: integer nullable: true title: type: string summary: type: string nullable: true agentAssisted: type: boolean description: > True if this scene was drafted with AI assistance. Always visible in the Reader App — never hover-only. contributorDisplayName: type: string nullable: true description: > Display name of the contributor who authored this scene, resolved from the contributors table. Null when no contributor is recorded or the contributor has no display name. createdAt: type: string format: date-time required: - id - storyworldId - pathId - commitSha - title - agentAssisted - createdAt MyContribution: type: object required: - id - storyworldId - storyworldTitle - pathId - pathTitle - title - submittedAt - source - status properties: id: type: integer storyworldId: type: integer storyworldTitle: type: string pathId: type: integer pathTitle: type: string title: type: string submittedAt: type: string format: date-time source: type: string enum: [narration, proposal] description: Whether this activity record is a saved narration or an imported PR submission. status: type: string enum: [pending, accepted, returned] description: > Current contributor-facing status. Mobile narrations are accepted when their durable Git-backed record is created; submitted and under-review PRs are pending, while returned PRs are returned. ContributorNotification: type: object required: - id - contributorId - proposalId - kind - title - body - eventKey - createdAt properties: id: type: integer contributorId: type: integer proposalId: type: integer kind: type: string enum: [received, being-reviewed, creative-question, official-story, alternate-path] title: type: string body: type: string eventKey: type: string readAt: type: string format: date-time nullable: true createdAt: type: string format: date-time ConsentRecord: type: object required: - id - storyworldId - actionType - scopeKind - status - policyDocumentRef - policyVersion - recordedAt - effectiveAt properties: id: type: string format: uuid storyworldId: type: integer actionType: type: string scopeKind: type: string scopeReference: type: string nullable: true status: type: string enum: [granted, revoked] policyDocumentRef: type: string policyVersion: type: string recordedAt: type: string format: date-time effectiveAt: type: string format: date-time revokedAt: type: string format: date-time nullable: true ConsentInput: type: object required: [actionType, storyworldId] properties: actionType: type: string storyworldId: type: integer scopeKind: type: string default: storyworld scopeReference: type: string nullable: true ContributionInput: type: object description: A narration submitted by the authenticated contributor. properties: title: type: string minLength: 1 description: Human-facing title for the scene. content: type: string minLength: 1 description: The narrated scene text. submissionId: type: string format: uuid description: Client-generated idempotency key retained while retrying this narration. agentAssisted: type: boolean default: false description: > True when the scene was drafted with agent assistance. The disclosure is shown to readers alongside the contribution. consentRecordId: type: string format: uuid description: Active submit-branch consent for this storyworld. aiAssistedConsentRecordId: type: string format: uuid description: Active ai-assisted-draft consent when agentAssisted is true. required: [title, content, submissionId] StoryProvenance: type: object description: Reader-facing record of an accepted contribution. properties: id: type: integer storyworldId: type: integer sourcePathId: type: integer nullable: true sourcePathTitle: type: string contributorNames: type: array items: type: string contributorIdentityFallbacks: type: array items: type: string stewardName: type: string nullable: true decision: type: string example: Accepted into canon acceptedAt: type: string format: date-time required: - id - storyworldId - sourcePathTitle - contributorNames - contributorIdentityFallbacks - decision - acceptedAt TranscribeRequest: type: object properties: audioBase64: type: string description: Base64-encoded audio data mimeType: type: string description: "MIME type of the audio (e.g. audio/m4a, audio/webm)" required: [audioBase64, mimeType] TranscribeResponse: type: object properties: text: type: string description: Transcribed text from the audio required: [text] Capsule: type: object description: > A concept capsule backed by a GitHub Issue. The type preserves the producer's supported vocabulary across the Author App, MCP, and manuscript ingestion. properties: id: type: integer description: GitHub Issue number — the canonical identity of this capsule. storyworldId: type: integer title: type: string description: Capsule name as entered by the author. type: type: string enum: [character, arc, event, arc-beat, planned-event, motif] roleTag: type: string nullable: true description: > Author-defined role label (e.g. protagonist, antagonist, mentor). null if no role has been assigned. epiphanyNote: type: string nullable: true description: Freeform depth note — the GitHub Issue body. createdAt: type: string format: date-time updatedAt: type: string format: date-time maturity: type: integer minimum: 0 maximum: 10 nullable: true description: > Author-set maturity rung (0–10, Rung Ladder). Stored as a `rung:N` GitHub label. Does not gate any action — observation only. required: - id - storyworldId - title - type - createdAt - updatedAt CreateCapsuleBody: type: object properties: title: type: string minLength: 1 description: Capsule name. type: type: string enum: [character, arc, event] roleTag: type: string description: > Author-defined role label (e.g. protagonist, antagonist). Stored as a `role:` GitHub label. epiphanyNote: type: string description: Freeform detail — the GitHub Issue body. required: - title - type QueueManuscriptIngestionBody: type: object description: > Owner-controlled manuscript upload. Base64 is used because this API intentionally accepts only authenticated steward requests. properties: filename: type: string description: Original filename; must end in .docx, .epub, or .pdf. contentBase64: type: string format: byte description: Base64-encoded manuscript, limited to 15 MiB decoded. uploadId: type: string minLength: 8 maxLength: 64 pattern: "^[A-Za-z0-9][A-Za-z0-9_-]{7,63}$" description: Stable client-generated id used for retry-safe intake naming. required: [filename, contentBase64, uploadId] QueueManuscriptIngestionResponse: type: object properties: status: type: string enum: [queued] manuscriptPath: type: string commitSha: type: string capsules: type: string required: [status, manuscriptPath, commitSha, capsules] UpdateCapsuleBody: type: object description: Partial update — only provided fields are changed. properties: title: type: string minLength: 1 roleTag: type: string nullable: true epiphanyNote: type: string nullable: true maturity: type: integer minimum: 0 maximum: 10 nullable: true description: Author-set maturity rung (0–10). Pass null to clear. CapsuleProposalResponse: type: object description: > A proposed new capsule generated by Disrupt or Invert — not yet on the board. The author must explicitly accept it to create it. properties: title: type: string description: Suggested capsule name. type: type: string enum: [character, arc, event] epiphanyNote: type: string description: AI-generated insight note seeding the new capsule. required: [title, type, epiphanyNote] DisruptCapsuleBody: type: object description: > Source material for the Disrupt action — the accepted scene prose to diverge from. properties: sourceText: type: string minLength: 1 description: The accepted scene text to disrupt. Truncated server-side beyond 3 000 chars. required: [sourceText] ReturnProposalBody: type: object properties: editorQuestion: type: string minLength: 1 description: > The question or guidance returned to the contributor. Surfaces as an editor question on the proposal view; posted as a PR review comment on GitHub. required: - editorQuestion ProposalVersion: type: object properties: id: type: integer proposalId: type: integer proposalLineageRef: type: string minLength: 1 versionRef: type: string minLength: 1 predecessorVersionRef: type: string nullable: true fidelityNoteRef: type: string minLength: 1 sourceReference: type: string nullable: true outputReference: type: string nullable: true predecessorFidelityNoteRetainedRef: type: string nullable: true predecessorReviewEventRetainedRef: type: string nullable: true createdAt: type: string format: date-time reviewEventRefs: type: array items: type: string required: - id - proposalId - proposalLineageRef - versionRef - predecessorVersionRef - fidelityNoteRef - createdAt - reviewEventRefs CreateProposalVersionBody: type: object properties: proposalLineageRef: type: string minLength: 1 versionRef: type: string minLength: 1 predecessorVersionRef: type: string nullable: true fidelityNoteRef: type: string minLength: 1 sourceReference: type: string outputReference: type: string required: - proposalLineageRef - versionRef - predecessorVersionRef - fidelityNoteRef CreateProposalVersionResponse: allOf: - $ref: "#/components/schemas/ProposalVersion" ProposalVersionReviewIdentity: type: object properties: proposalLineageRef: type: string minLength: 1 versionRef: type: string minLength: 1 fidelityNoteRef: type: string minLength: 1 eventRef: type: string minLength: 1 safeReason: type: string required: - proposalLineageRef - versionRef - fidelityNoteRef AcceptProposalVersionBody: allOf: - $ref: "#/components/schemas/ProposalVersionReviewIdentity" RejectProposalVersionBody: allOf: - $ref: "#/components/schemas/ProposalVersionReviewIdentity" RequestProposalRevisionBody: allOf: - $ref: "#/components/schemas/ProposalVersionReviewIdentity" - type: object properties: successorVersionRef: type: string minLength: 1 successorFidelityNoteRef: type: string minLength: 1 predecessorFidelityNoteRetainedRef: type: string minLength: 1 predecessorReviewEventRetainedRef: type: string minLength: 1 required: - successorVersionRef - successorFidelityNoteRef - predecessorFidelityNoteRetainedRef - predecessorReviewEventRetainedRef AppealProposalVersionBody: allOf: - $ref: "#/components/schemas/ProposalVersionReviewIdentity" - type: object properties: stewardDecisionRef: type: string minLength: 1 required: - stewardDecisionRef ProposalReviewEvent: type: object properties: id: type: integer eventRef: type: string proposalId: type: integer proposalVersionId: type: integer proposalLineageRef: type: string versionRef: type: string fidelityNoteRef: type: string action: type: string enum: [accept, reject, request-revision, appeal] resultingReviewState: type: string enum: - accepted-by-contributor - rejected-by-contributor - changes-requested - appeal-pending safeReason: type: string nullable: true stewardDecisionRef: type: string nullable: true actorUserId: type: integer nullable: true createdAt: type: string format: date-time required: - id - eventRef - proposalId - proposalVersionId - proposalLineageRef - versionRef - fidelityNoteRef - action - resultingReviewState - createdAt ProposalReviewResponse: type: object properties: proposalId: type: integer proposalLineageRef: type: string versionRef: type: string fidelityNoteRef: type: string proposalVersion: $ref: "#/components/schemas/ProposalVersion" reviewEvent: $ref: "#/components/schemas/ProposalReviewEvent" reviewEventRefs: type: array items: type: string successorVersion: allOf: - $ref: "#/components/schemas/ProposalVersion" nullable: true required: - proposalId - proposalLineageRef - versionRef - fidelityNoteRef - proposalVersion - reviewEvent - reviewEventRefs AcceptProposalResponse: type: object properties: proposal: $ref: "#/components/schemas/Proposal" provenanceRecordId: type: integer description: ID of the provenance_records row created on acceptance. required: - proposal - provenanceRecordId Proposal: type: object properties: id: type: integer storyworldId: type: integer pathId: type: integer prNumber: type: integer state: type: string enum: - draft - submitted - under-review - returned-with-notes - accepted-into-canon - published-alternate - restricted - withdrawn - archived submittedAt: type: string format: date-time decidedAt: type: string format: date-time nullable: true decisionReason: type: string nullable: true required: - id - storyworldId - pathId - prNumber - state - submittedAt ContributionPreview: type: object description: Full narration content shown to a steward while reviewing a proposal. properties: id: type: integer title: type: string content: type: string nullable: true contributorDisplayName: type: string nullable: true createdAt: type: string format: date-time required: - id - title - content - createdAt StewardProposal: allOf: - $ref: "#/components/schemas/Proposal" - type: object properties: contributionPreviews: type: array description: All narration contributions currently associated with the proposal's story path. items: $ref: "#/components/schemas/ContributionPreview" required: - contributionPreviews ProposalDetail: allOf: - $ref: "#/components/schemas/Proposal" - type: object properties: editorQuestions: type: array description: Editor questions returned to the contributor, ordered chronologically. items: $ref: "#/components/schemas/EditorQuestion" required: - editorQuestions EditorQuestion: type: object properties: id: type: integer proposalId: type: integer reviewCommentId: type: integer description: GitHub review comment ID. body: type: string resolved: type: boolean addressedAt: type: string format: date-time nullable: true createdAt: type: string format: date-time required: - id - proposalId - reviewCommentId - body - resolved - createdAt WebhookDeliveryEvidence: type: object description: Redacted, storyworld-scoped evidence for one GitHub delivery. properties: id: type: integer deliveryId: type: string eventType: type: string processingResult: type: string enum: [processed, ignored, failed] replayOutcome: type: string enum: [new, duplicate] proposalId: type: integer nullable: true editorQuestionId: type: integer nullable: true notificationKey: type: string nullable: true provenanceRecordId: type: integer nullable: true receivedAt: type: string format: date-time required: - id - deliveryId - eventType - processingResult - replayOutcome - receivedAt RestrictProposalBody: type: object properties: reason: type: string maxLength: 2000 responses: NotFound: description: Resource not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" BadRequest: description: Missing or invalid fields content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" Unauthorized: description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorResponse"