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: dojo description: Git Dojo lesson and repository state operations - name: progress description: Course progress persistence across both tracks - name: capstone description: Go Live capstone against the learner's real GitHub account - name: crisis description: Crisis Room disaster-recovery scenarios - name: drills description: Warm-up recall drills with spaced-repetition scheduling 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" /dojo/overview: get: operationId: getDojoOverview tags: [dojo] summary: Course overview description: High-level progress across all Git Dojo lessons responses: "200": description: Overview content: application/json: schema: $ref: "#/components/schemas/DojoOverview" /dojo/lessons: get: operationId: listLessons tags: [dojo] summary: List lessons description: All Git Dojo lessons with playground status responses: "200": description: Lessons content: application/json: schema: type: array items: $ref: "#/components/schemas/Lesson" /dojo/lessons/{lessonId}/state: get: operationId: getRepoState tags: [dojo] summary: Repository state for a lesson playground description: Full git state of the lesson's practice repository parameters: - name: lessonId in: path required: true schema: type: string responses: "200": description: Repository state content: application/json: schema: $ref: "#/components/schemas/RepoState" "404": description: Lesson not found content: application/json: schema: $ref: "#/components/schemas/ApiMessage" /dojo/lessons/{lessonId}/check: post: operationId: runLessonCheck tags: [dojo] summary: Run the lesson's check script description: Executes the lesson's check.sh grader and returns its output parameters: - name: lessonId in: path required: true schema: type: string responses: "200": description: Check results content: application/json: schema: $ref: "#/components/schemas/CheckResult" "404": description: Lesson not found content: application/json: schema: $ref: "#/components/schemas/ApiMessage" /dojo/lessons/{lessonId}/bot: post: operationId: runBotAction tags: [dojo] summary: Let time pass — the simulated teammate acts description: Runs the lesson's scripted teammate beat (bot.sh), which may push commits to the lesson's shared remote parameters: - name: lessonId in: path required: true schema: type: string responses: "200": description: Teammate action results content: application/json: schema: $ref: "#/components/schemas/BotActionResult" "404": description: Lesson not found content: application/json: schema: $ref: "#/components/schemas/ApiMessage" /dojo/lessons/{lessonId}/commits/{commitHash}/diff: get: operationId: getCommitDiff tags: [dojo] summary: What a commit actually changed description: Changed files and readable line-by-line diff for one sealed snapshot (merges are compared against their first parent) parameters: - name: lessonId in: path required: true schema: type: string - name: commitHash in: path required: true schema: type: string description: Full or abbreviated hex commit hash responses: "200": description: Commit diff content: application/json: schema: $ref: "#/components/schemas/CommitDiff" "404": description: Lesson or commit not found content: application/json: schema: $ref: "#/components/schemas/ApiMessage" "400": description: Invalid commit hash content: application/json: schema: $ref: "#/components/schemas/ApiMessage" /dojo/lessons/{lessonId}/file-diff: get: operationId: getWorkingFileDiff tags: [dojo] summary: Working-copy changes for one file description: How a file differs from the last snapshot, split into what is already staged (Loading Dock) and what is still unstaged (Workbench) parameters: - name: lessonId in: path required: true schema: type: string - name: filePath in: query required: true schema: type: string description: Repo-relative path of the file, as reported by the repo state responses: "200": description: Working file diff content: application/json: schema: $ref: "#/components/schemas/WorkingFileDiff" "404": description: Lesson not found or file has no changes content: application/json: schema: $ref: "#/components/schemas/ApiMessage" /crisis/scenarios: get: operationId: listCrisisScenarios tags: [crisis] summary: List crisis scenarios description: All Crisis Room scenarios with playground and badge status responses: "200": description: Scenarios content: application/json: schema: type: array items: $ref: "#/components/schemas/CrisisScenario" /crisis/scenarios/{crisisId}/setup: post: operationId: setupCrisisScenario tags: [crisis] summary: Initialize the scenario's broken repository description: Idempotently rebuilds the scenario's practice repo in its broken state parameters: - name: crisisId in: path required: true schema: type: string responses: "200": description: Setup result content: application/json: schema: $ref: "#/components/schemas/CrisisSetupResult" "404": description: Scenario not found content: application/json: schema: $ref: "#/components/schemas/ApiMessage" /crisis/scenarios/{crisisId}/state: get: operationId: getCrisisRepoState tags: [crisis] summary: Repository state for a crisis scenario playground description: Full git state of the scenario's practice repository parameters: - name: crisisId in: path required: true schema: type: string responses: "200": description: Repository state content: application/json: schema: $ref: "#/components/schemas/RepoState" "404": description: Scenario not found content: application/json: schema: $ref: "#/components/schemas/ApiMessage" /crisis/scenarios/{crisisId}/check: post: operationId: runCrisisCheck tags: [crisis] summary: Grade the scenario's recovery description: Runs the scenario's server-side grader against the practice repo parameters: - name: crisisId in: path required: true schema: type: string responses: "200": description: Check results content: application/json: schema: $ref: "#/components/schemas/CheckResult" "404": description: Scenario not found content: application/json: schema: $ref: "#/components/schemas/ApiMessage" /crisis/scenarios/{crisisId}/file-diff: get: operationId: getCrisisFileDiff tags: [crisis] summary: Working-copy changes for one file in a crisis scenario description: How a file differs from the last snapshot, split into what is already staged (Loading Dock) and what is still unstaged (Workbench) parameters: - name: crisisId in: path required: true schema: type: string - name: filePath in: query required: true schema: type: string description: Repo-relative path of the file, as reported by the repo state responses: "200": description: Working file diff content: application/json: schema: $ref: "#/components/schemas/WorkingFileDiff" "404": description: Scenario not found or file has no changes content: application/json: schema: $ref: "#/components/schemas/ApiMessage" /crisis/scenarios/{crisisId}/commits/{commitHash}/diff: get: operationId: getCrisisCommitDiff tags: [crisis] summary: What a crisis commit actually changed description: Changed files and readable line-by-line diff for one sealed snapshot in a crisis scenario's playground (merges are compared against their first parent) parameters: - name: crisisId in: path required: true schema: type: string - name: commitHash in: path required: true schema: type: string description: Full or abbreviated hex commit hash responses: "200": description: Commit diff content: application/json: schema: $ref: "#/components/schemas/CommitDiff" "404": description: Scenario or commit not found content: application/json: schema: $ref: "#/components/schemas/ApiMessage" "400": description: Invalid commit hash content: application/json: schema: $ref: "#/components/schemas/ApiMessage" /progress: get: operationId: getProgress tags: [progress] summary: Get saved course progress description: All completed modules across both tracks responses: "200": description: Progress content: application/json: schema: $ref: "#/components/schemas/Progress" /progress/complete: post: operationId: completeModule tags: [progress] summary: Record a module completion description: Marks a module as passed and persists it server-side requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CompleteModuleRequest" responses: "200": description: Updated progress content: application/json: schema: $ref: "#/components/schemas/Progress" /drills/due: post: operationId: getDueDrills tags: [drills] summary: Which drill items are due for review description: Given the drill items the learner has unlocked, returns per-item practice stats and a schedule-ordered due list. POST because the eligible candidate set lives client-side. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DrillCandidateSet" responses: "200": description: Due items and stats content: application/json: schema: $ref: "#/components/schemas/DrillDueResult" /drills/attempt: post: operationId: recordDrillAttempt tags: [drills] summary: Record a drill answer description: Persists one attempt and reschedules the item (correct -> longer interval, wrong -> soon) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DrillAttemptInput" responses: "200": description: Updated item stats content: application/json: schema: $ref: "#/components/schemas/DrillItemStats" /capstone/status: get: operationId: getCapstoneStatus tags: [capstone] summary: Go Live capstone status description: GitHub connection state, practice repo, and mission verification results responses: "200": description: Capstone status content: application/json: schema: $ref: "#/components/schemas/CapstoneStatus" /capstone/repo: post: operationId: createCapstoneRepo tags: [capstone] summary: Create the real practice repository description: Idempotently creates a dojo-prefixed repo on the learner's GitHub account and seeds the practice pull request responses: "200": description: Repo ready (created now or already existed) content: application/json: schema: $ref: "#/components/schemas/CapstoneStatus" "409": description: GitHub not connected or repo creation failed content: application/json: schema: $ref: "#/components/schemas/ApiMessage" delete: operationId: deleteCapstoneRepo tags: [capstone] summary: Reset the capstone and attempt repo deletion description: Attempts to delete the dojo practice repo via GitHub. Connected GitHub tokens typically lack the delete_repo scope; in that case capstone state is still reset and a 409 explains where to delete the repo manually. responses: "200": description: Repo deleted on GitHub and state cleared content: application/json: schema: $ref: "#/components/schemas/CapstoneStatus" "409": description: GitHub refused deletion (state was still reset when the repo remains) — error text includes the manual-deletion URL content: application/json: schema: $ref: "#/components/schemas/ApiMessage" /capstone/verify/{missionId}: post: operationId: verifyCapstoneMission tags: [capstone] summary: Verify a capstone mission against live GitHub description: Checks the real repository state via the GitHub API; badges are recorded only on verified truth parameters: - name: missionId in: path required: true schema: type: string responses: "200": description: Verification result content: application/json: schema: $ref: "#/components/schemas/CapstoneVerifyResult" "404": description: Unknown mission content: application/json: schema: $ref: "#/components/schemas/ApiMessage" "409": description: GitHub not connected or repo missing content: application/json: schema: $ref: "#/components/schemas/ApiMessage" components: schemas: HealthStatus: type: object properties: status: type: string enum: [ok, degraded] smokeStatus: type: string enum: [passed, failed, unknown] description: Result of the last startup smoke check passed: type: boolean description: Raw pass/fail result from the last completed smoke check smokeCheckedAt: type: string description: ISO 8601 timestamp of when the last smoke check completed required: - status - smokeStatus ApiMessage: type: object properties: error: type: string required: - error DojoOverview: type: object properties: totalLessons: type: number startedLessons: type: number totalCommits: type: number dojoFound: type: boolean description: Whether the git-dojo folder exists at the expected location required: [totalLessons, startedLessons, totalCommits, dojoFound] Lesson: type: object properties: id: type: string description: Short lesson id such as lesson-01 number: type: number title: type: string folderName: type: string description: Lesson folder name such as lesson-01-first-snapshot hasPlayground: type: boolean description: setup.sh has been run for this lesson initialized: type: boolean description: The playground contains a git repository commitCount: type: number hasBot: type: boolean description: The lesson has a scripted teammate (bot.sh) that can act when time passes required: [id, number, title, folderName, hasPlayground, initialized, commitCount, hasBot] RepoFile: type: object properties: path: type: string status: type: string enum: [staged, modified, staged_and_modified, untracked, deleted, conflicted] required: [path, status] RepoCommit: type: object properties: hash: type: string shortHash: type: string subject: type: string authorName: type: string date: type: string description: ISO 8601 author date refs: type: array items: type: string description: Branch or tag names pointing at this commit branch: type: ["string", "null"] description: Branch this commit was listed under, when walking per-branch history parents: type: array items: type: string description: Full hashes of this commit's parent commits (2+ for merges) required: [hash, shortHash, subject, authorName, date, refs, parents] RemoteBranch: type: object properties: name: type: string description: Remote-tracking ref short name, e.g. origin/main headHash: type: string required: [name, headHash] SyncStatus: type: object properties: remoteBranch: type: string description: The remote-tracking branch compared against, e.g. origin/main ahead: type: number description: Local commits the remote doesn't have yet (not pushed) behind: type: number description: Remote commits the local branch doesn't have yet (not pulled) required: [remoteBranch, ahead, behind] RepoBranch: type: object properties: name: type: string isCurrent: type: boolean headHash: type: string required: [name, isCurrent, headHash] RepoState: type: object properties: lessonId: type: string hasPlayground: type: boolean initialized: type: boolean currentBranch: type: ["string", "null"] detachedHead: type: boolean mergeInProgress: type: boolean files: type: array items: $ref: "#/components/schemas/RepoFile" commits: type: array items: $ref: "#/components/schemas/RepoCommit" branches: type: array items: $ref: "#/components/schemas/RepoBranch" remotes: type: array items: type: string remoteBranches: type: array items: $ref: "#/components/schemas/RemoteBranch" description: Remote-tracking branch heads (where GitHub's copy sits, as last seen) syncStatus: oneOf: - $ref: "#/components/schemas/SyncStatus" - type: "null" description: Ahead/behind counts for the current branch vs its remote counterpart, when one exists repoFolder: type: ["string", "null"] description: Subfolder of the playground the state was read from (e.g. laptop), when the working copy isn't the playground root summary: type: string description: Plain-English explanation of the current repository state hasBot: type: boolean description: The lesson has a scripted teammate (bot.sh) that can act when time passes required: [ lessonId, hasBot, hasPlayground, initialized, currentBranch, detachedHead, mergeInProgress, files, commits, branches, remotes, remoteBranches, syncStatus, repoFolder, summary, ] DiffLine: type: object properties: kind: type: string enum: [added, removed, context, hunk] description: hunk marks a "skip ahead" separator between change regions text: type: string required: [kind, text] FileDiff: type: object properties: path: type: string changeKind: type: string enum: [added, modified, deleted, renamed, binary] renamedFrom: type: ["string", "null"] description: Previous path when the file was renamed added: type: number description: Count of added lines removed: type: number description: Count of removed lines truncated: type: boolean description: True when the diff was cut off for size lines: type: array items: $ref: "#/components/schemas/DiffLine" required: [path, changeKind, renamedFrom, added, removed, truncated, lines] CommitDiff: type: object properties: hash: type: string shortHash: type: string subject: type: string authorName: type: string date: type: string description: ISO 8601 author date isMerge: type: boolean description: True when the snapshot joined two timelines; the diff is against its first parent summary: type: string description: Plain-English explanation of what this snapshot changed files: type: array items: $ref: "#/components/schemas/FileDiff" required: [hash, shortHash, subject, authorName, date, isMerge, summary, files] WorkingFileDiff: type: object properties: path: type: string status: type: string enum: [staged, modified, staged_and_modified, untracked, deleted, conflicted] summary: type: string description: Plain-English explanation of where this file's changes sit staged: anyOf: - $ref: "#/components/schemas/FileDiff" - type: "null" description: Changes already boxed on the Loading Dock (staged), if any unstaged: anyOf: - $ref: "#/components/schemas/FileDiff" - type: "null" description: Changes still on the Workbench (unstaged), if any required: [path, status, summary, staged, unstaged] ProgressEntry: type: object properties: moduleId: type: string description: Module id such as 1.1 (Track A) or lesson-01 (Track B) track: type: string enum: [visual, cli, live] completedAt: type: string description: ISO 8601 timestamp of when the module first passed required: [moduleId, track, completedAt] Progress: type: object properties: entries: type: array items: $ref: "#/components/schemas/ProgressEntry" required: [entries] CompleteModuleRequest: type: object properties: moduleId: type: string track: type: string enum: [visual, cli, live] required: [moduleId, track] BotActionResult: type: object properties: ran: type: boolean description: Whether the teammate script ran output: type: string description: What the teammate did, in plain English required: [ran, output] CapstoneRepo: type: object properties: name: type: string fullName: type: string description: owner/name htmlUrl: type: string cloneUrl: type: string defaultBranch: type: string required: [name, fullName, htmlUrl, cloneUrl, defaultBranch] CapstoneMission: type: object properties: id: type: string description: Mission id (push-commit, create-branch, merge-pr) title: type: string verified: type: boolean description: True only after the live GitHub API confirmed this step verifiedAt: type: ["string", "null"] description: ISO 8601 timestamp of first verified pass required: [id, title, verified, verifiedAt] DrillCandidate: type: object properties: id: type: string description: Drill item id from the client-side drill bank sourceId: type: ["string", "null"] description: Lesson/crisis id whose grader friction should boost this item's priority required: [id] DrillCandidateSet: type: object properties: candidates: type: array items: $ref: "#/components/schemas/DrillCandidate" required: [candidates] DrillItemStats: type: object properties: id: type: string seenCount: type: number description: How many times this item has been attempted correctCount: type: number lastCorrect: type: ["boolean", "null"] description: Whether the most recent attempt was correct (null if never attempted) lastSeenAt: type: ["string", "null"] description: ISO 8601 timestamp of the most recent attempt dueAt: type: ["string", "null"] description: When this item comes due again (null means due now / never attempted) dueNow: type: boolean priority: type: number description: Scheduling priority; grader friction on the item's source raises it required: [id, seenCount, correctCount, lastCorrect, lastSeenAt, dueAt, dueNow, priority] DrillFrictionEntry: type: object description: Grader friction for one lesson or crisis source properties: sourceId: type: string description: Lesson or crisis id (e.g. "lesson-01", "crisis-03") failures: type: number description: Number of failed grader runs on this source passes: type: number description: Number of passed grader runs on this source effectiveFailures: type: number description: > Recency-weighted failure score (0–10 range). Failures decay exponentially with a 14-day half-life so old misses stop dominating the ranking once the learner has improved. recentPasses: type: number description: Passes in the newer half of the last 10 grader runs recentFailures: type: number description: Failures in the newer half of the last 10 grader runs olderPasses: type: number description: Passes in the older half of the last 10 grader runs olderFailures: type: number description: Failures in the older half of the last 10 grader runs windowFailures: type: number description: > Number of failed runs within the rolling window (last 30 grader runs). Use this for display instead of the raw cumulative `failures` counter so the subtitle stays consistent with current struggle level. windowPasses: type: number description: > Number of passed runs within the rolling window (last 30 grader runs). Pair with windowFailures to compute a self-consistent pass ratio (windowPasses / (windowFailures + windowPasses)). recovered: type: boolean description: > True when the learner has fully recovered: recentFailures === 0 and recentPasses > 0. Recovered entries are included in the friction list so the UI can celebrate the improvement before hiding the row. required: [sourceId, failures, passes, effectiveFailures, recentPasses, recentFailures, olderPasses, olderFailures, windowFailures, windowPasses, recovered] DrillDueResult: type: object properties: items: type: array description: All candidates with stats, due items first in priority order items: $ref: "#/components/schemas/DrillItemStats" dueCount: type: number friction: type: array description: Per-source grader friction for sources referenced by the candidates, sorted by failures descending. Only sources with at least one failure are included. items: $ref: "#/components/schemas/DrillFrictionEntry" required: [items, dueCount, friction] DrillAttemptInput: type: object properties: itemId: type: string correct: type: boolean sourceId: type: ["string", "null"] required: [itemId, correct] CapstoneStatus: type: object properties: githubConnected: type: boolean githubLogin: type: ["string", "null"] description: The connected GitHub username, when available repo: anyOf: - $ref: "#/components/schemas/CapstoneRepo" - type: "null" prNumber: type: ["number", "null"] prUrl: type: ["string", "null"] prBranch: type: ["string", "null"] description: Head branch of the Dojo-generated pull request missions: type: array items: $ref: "#/components/schemas/CapstoneMission" badgeEarnedAt: type: ["string", "null"] description: Set only when every mission has been verified against GitHub required: [githubConnected, githubLogin, repo, prNumber, prUrl, prBranch, missions, badgeEarnedAt] CapstoneVerifyResult: type: object properties: missionId: type: string verified: type: boolean githubUnavailable: type: boolean description: True when GitHub could not be reached to perform this verification; retry the check later detail: type: string description: Honest explanation of what the live check saw status: $ref: "#/components/schemas/CapstoneStatus" required: [missionId, verified, githubUnavailable, detail, status] CheckResult: type: object properties: ran: type: boolean passed: type: ["boolean", "null"] description: True when every check passed, null when it could not be determined output: type: string description: Raw output of check.sh required: [ran, passed, output] CrisisScenario: type: object properties: id: type: string description: Scenario id such as crisis-01 number: type: number hasPlayground: type: boolean description: The scenario's practice repo has been set up initialized: type: boolean description: The playground contains a git repository solved: type: boolean description: The grader has genuinely passed at least once path: type: string description: Absolute path of the scenario's practice repository required: [id, number, hasPlayground, initialized, solved, path] CrisisSetupResult: type: object properties: ok: type: boolean message: type: string path: type: string description: Absolute path of the scenario's practice repository required: [ok, message, path]