diff --git a/dist/openapi.json b/dist/openapi.json index 5eb5faf..f3ef595 100644 --- a/dist/openapi.json +++ b/dist/openapi.json @@ -3,12 +3,12 @@ "info": { "title": "seal-use Wrapped API", "version": "0.10.24", - "description": "Planned HTTP contract for the seal-use wrapped backend API.\n\nThese endpoints describe the intended stable API for frontend developers and agents once\nthe HTTP adapter is implemented.\nThey are not the raw downstream Seal endpoints. seal-use is responsible for enterprise\nselection, source authentication, response compaction, and diagnostics-friendly fields.\n" + "description": "HTTP contract for the seal-use wrapped backend API, served by the local HTTP adapter\n(`seal-use http`, or the `seal-use service start` daemon; default http://127.0.0.1:8787).\n\nThese endpoints describe the stable wrapped API for frontend developers and agents. They are\nnot the raw downstream Seal endpoints: seal-use is responsible for enterprise selection,\nsource authentication, response compaction, and diagnostics-friendly fields.\n\nEvery operation declares `x-implementation-status`, so a caller can tell what the running\nadapter actually serves:\n\n- `implemented` — routed by `src/http/routes.ts` today. `src/http/openapi-implementation.test.ts`\n fails when an `implemented` operation has no matching route.\n- `planned` — contract-only, designed but not routed yet. Calling it returns 404.\n\nThe same capabilities are reachable through the CLI, and through the optional MCP server when\nit is enabled.\n" }, "servers": [ { "url": "http://localhost:8787", - "description": "Reserved for a future local HTTP adapter; the current service uses MCP stdio." + "description": "Local HTTP adapter (`seal-use http`, or the `seal-use service start` daemon). Loopback-only by default." } ], "security": [ @@ -49,6 +49,7 @@ "Corps" ], "operationId": "listCorps", + "x-implementation-status": "implemented", "summary": "List configured enterprises", "responses": { "200": { @@ -98,6 +99,7 @@ "Corps" ], "operationId": "getCurrentCorp", + "x-implementation-status": "planned", "summary": "Get current enterprise", "description": "Returns the configured default enterprise in stateful mode. Stateless mode has no current enterprise and requires an explicit corpId for enterprise operations.", "responses": { @@ -145,6 +147,7 @@ "Corps" ], "operationId": "switchCurrentCorp", + "x-implementation-status": "planned", "summary": "Switch current enterprise", "requestBody": { "required": true, @@ -223,6 +226,7 @@ "Source" ], "operationId": "getSourceConfig", + "x-implementation-status": "planned", "summary": "Resolve source-derived Seal enterprise config", "parameters": [ { @@ -279,6 +283,7 @@ "Auth" ], "operationId": "diagnoseAuth", + "x-implementation-status": "planned", "summary": "Diagnose wrapped source-to-Seal authentication", "parameters": [ { @@ -321,6 +326,7 @@ "Auth" ], "operationId": "whoami", + "x-implementation-status": "implemented", "summary": "Get current wrapped Seal identity", "parameters": [ { @@ -387,6 +393,7 @@ "Auth" ], "operationId": "getSession", + "x-implementation-status": "implemented", "summary": "Get current wrapped Seal session metadata", "parameters": [ { @@ -455,6 +462,7 @@ "Approval Knowledge" ], "operationId": "getApprovalContext", + "x-implementation-status": "planned", "summary": "Get rules, documents, and style preferences together", "parameters": [ { @@ -518,6 +526,7 @@ "Approval Knowledge" ], "operationId": "searchApprovalKnowledge", + "x-implementation-status": "planned", "summary": "Search approval rules, documents, and preferences", "requestBody": { "required": true, @@ -583,6 +592,7 @@ "Approval Knowledge" ], "operationId": "listApprovalRules", + "x-implementation-status": "implemented", "summary": "List current draft approval rules", "responses": { "200": { @@ -616,6 +626,7 @@ "Approval Knowledge" ], "operationId": "createApprovalRule", + "x-implementation-status": "planned", "summary": "Create draft approval rule", "requestBody": { "required": true, @@ -708,6 +719,7 @@ "Approval Knowledge" ], "operationId": "updateApprovalRule", + "x-implementation-status": "planned", "summary": "Update draft approval rule", "requestBody": { "required": true, @@ -783,6 +795,7 @@ "Approval Knowledge" ], "operationId": "deleteApprovalRule", + "x-implementation-status": "planned", "summary": "Delete draft approval rule", "responses": { "200": { @@ -797,6 +810,7 @@ "Approval Knowledge" ], "operationId": "listApprovalRuleVersions", + "x-implementation-status": "planned", "summary": "List published approval rule versions", "responses": { "200": { @@ -860,6 +874,7 @@ "Approval Knowledge" ], "operationId": "getApprovalRuleVersion", + "x-implementation-status": "planned", "summary": "Get published approval rule version", "responses": { "200": { @@ -909,6 +924,7 @@ "Approval Knowledge" ], "operationId": "getApprovalRuleByVersion", + "x-implementation-status": "planned", "summary": "Get one wrapped rule from a published version", "parameters": [ { @@ -986,6 +1002,7 @@ "Approval Knowledge" ], "operationId": "publishApprovalRuleVersion", + "x-implementation-status": "planned", "summary": "Publish current draft rules", "requestBody": { "required": true, @@ -1026,6 +1043,7 @@ "Approval Knowledge" ], "operationId": "listApprovalDocuments", + "x-implementation-status": "planned", "summary": "List approval knowledge documents", "parameters": [ { @@ -1092,6 +1110,7 @@ "Approval Knowledge" ], "operationId": "createApprovalDocument", + "x-implementation-status": "planned", "summary": "Create approval knowledge document", "requestBody": { "required": true, @@ -1210,6 +1229,7 @@ "Approval Knowledge" ], "operationId": "getApprovalDocument", + "x-implementation-status": "planned", "summary": "Get approval knowledge document", "responses": { "200": { @@ -1271,6 +1291,7 @@ "Approval Knowledge" ], "operationId": "updateApprovalDocument", + "x-implementation-status": "planned", "summary": "Update approval knowledge document", "requestBody": { "required": true, @@ -1375,6 +1396,7 @@ "Approval Knowledge" ], "operationId": "deleteApprovalDocument", + "x-implementation-status": "planned", "summary": "Delete approval knowledge document", "responses": { "200": { @@ -1389,6 +1411,7 @@ "Approval Knowledge" ], "operationId": "getApprovalStylePreferences", + "x-implementation-status": "planned", "summary": "Get approval style preferences", "responses": { "200": { @@ -1438,6 +1461,7 @@ "Approval Knowledge" ], "operationId": "updateApprovalStylePreferences", + "x-implementation-status": "planned", "summary": "Update approval style preferences", "requestBody": { "required": true, @@ -1523,12 +1547,165 @@ } } }, + "/v1/preferences": { + "get": { + "tags": [ + "Approval Knowledge" + ], + "operationId": "getPreferences", + "x-implementation-status": "implemented", + "summary": "Get current decision, thinking-depth and rule-version preferences", + "parameters": [ + { + "name": "corpId", + "in": "query", + "schema": { + "type": "string" + }, + "description": "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + } + ], + "responses": { + "200": { + "description": "Decision preferences, thinking depth preference and the bound rule set version.", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": true, + "properties": { + "tone": { + "type": "string" + }, + "language": { + "type": "string" + }, + "detailLevel": { + "type": "string" + }, + "outputFormat": { + "type": "string" + }, + "examples": { + "type": "array", + "items": { + "type": "string" + } + }, + "prohibitedPhrases": { + "type": "array", + "items": { + "type": "string" + } + }, + "customInstructions": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/v1/preferences/decision": { + "post": { + "tags": [ + "Approval Knowledge" + ], + "operationId": "updatePreferenceDecision", + "x-implementation-status": "implemented", + "summary": "Update decision preferences (takes effect immediately for the running approval agent)", + "parameters": [ + { + "name": "corpId", + "in": "query", + "schema": { + "type": "string" + }, + "description": "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "explicitApprove": { + "type": "string" + }, + "explicitReject": { + "type": "string" + }, + "exemptApprove": { + "type": "string" + }, + "review": { + "type": "string" + }, + "dryRun": { + "type": "boolean", + "description": "Return the before/after diff without writing." + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Updated preferences, or the previewed diff when dryRun is set.", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": true, + "properties": { + "tone": { + "type": "string" + }, + "language": { + "type": "string" + }, + "detailLevel": { + "type": "string" + }, + "outputFormat": { + "type": "string" + }, + "examples": { + "type": "array", + "items": { + "type": "string" + } + }, + "prohibitedPhrases": { + "type": "array", + "items": { + "type": "string" + } + }, + "customInstructions": { + "type": "string" + } + } + } + } + } + } + } + } + }, "/v1/approval-runs": { "get": { "tags": [ "Approval Runs" ], "operationId": "searchApprovalRuns", + "x-implementation-status": "implemented", "summary": "Search wrapped approval run history", "parameters": [ { @@ -1690,6 +1867,7 @@ "Approval Runs" ], "operationId": "summarizeApprovalRuns", + "x-implementation-status": "implemented", "summary": "Summarize approval runs by local date", "parameters": [ { @@ -1780,12 +1958,88 @@ } } }, + "/v1/approval-runs/stats": { + "get": { + "tags": [ + "Approval Runs" + ], + "operationId": "statApprovalRuns", + "x-implementation-status": "implemented", + "summary": "Aggregate approval run counts by status and source system", + "parameters": [ + { + "name": "corpId", + "in": "query", + "schema": { + "type": "string" + }, + "description": "Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used." + }, + { + "name": "since", + "in": "query", + "schema": { + "type": "string" + }, + "description": "Time window such as 3months, 7days or 24hours." + }, + { + "name": "dedupeBy", + "in": "query", + "schema": { + "type": "string", + "enum": [ + "sourceDocumentSN", + "sourceDocumentId", + "id" + ], + "default": "sourceDocumentSN" + }, + "description": "Field used to count distinct business documents." + }, + { + "name": "status", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "sourceSystem", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "taskMode", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Counts grouped by status and source system, plus the deduplicated total.", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, "/v1/approval-runs/pick": { "get": { "tags": [ "Approval Runs" ], "operationId": "pickApprovalRuns", + "x-implementation-status": "implemented", "summary": "Pick likely approval runs by document number or trace key", "parameters": [ { @@ -1872,6 +2126,7 @@ "Approval Runs" ], "operationId": "getApprovalRunLangfuseBridge", + "x-implementation-status": "planned", "summary": "Resolve approval runs to Langfuse trace or session hints", "parameters": [ { @@ -1950,6 +2205,7 @@ "Approval Runs" ], "operationId": "getApprovalRunUrl", + "x-implementation-status": "implemented", "summary": "Get enterprise assist URL and optional source document URL", "parameters": [ { @@ -2031,6 +2287,7 @@ "Approval Runs" ], "operationId": "getApprovalRun", + "x-implementation-status": "implemented", "summary": "Get wrapped approval run detail", "parameters": [ { @@ -2081,6 +2338,7 @@ "Approval Runs" ], "operationId": "getApprovalRunCitedRules", + "x-implementation-status": "implemented", "summary": "Extract rules cited or matched by the AI result", "responses": { "200": { @@ -2114,6 +2372,7 @@ "Approval Runs" ], "operationId": "getApprovalRunDocumentSummary", + "x-implementation-status": "implemented", "summary": "Get key document fields and compact AI/manual result", "responses": { "200": { @@ -2147,6 +2406,7 @@ "Approval Runs" ], "operationId": "getApprovalRunAttachments", + "x-implementation-status": "implemented", "summary": "List compact attachment metadata", "parameters": [ { @@ -2189,6 +2449,7 @@ "Approval Runs" ], "operationId": "getApprovalRunResult", + "x-implementation-status": "implemented", "summary": "Get AI result, optionally as a compact summary", "parameters": [ { @@ -2220,6 +2481,7 @@ "Simulation" ], "operationId": "createSimulationBatch", + "x-implementation-status": "implemented", "summary": "Create a simulation batch", "requestBody": { "required": true, @@ -2253,6 +2515,7 @@ "Simulation" ], "operationId": "createMaterialPackBatch", + "x-implementation-status": "planned", "summary": "Create a material pack simulation batch", "requestBody": { "required": true, @@ -2286,6 +2549,7 @@ "Simulation" ], "operationId": "listSimulationBatches", + "x-implementation-status": "implemented", "summary": "List simulation batches", "parameters": [ { @@ -2332,6 +2596,7 @@ "Simulation" ], "operationId": "getSimulationBatch", + "x-implementation-status": "implemented", "summary": "Get a simulation batch detail including echoed create params", "responses": { "200": { @@ -2365,6 +2630,7 @@ "Simulation" ], "operationId": "getSimulationBatchRecords", + "x-implementation-status": "planned", "summary": "Get wrapped simulation batch records", "parameters": [ { @@ -2397,6 +2663,7 @@ "Simulation" ], "operationId": "listSimulationTemplates", + "x-implementation-status": "planned", "summary": "List simulation test templates", "responses": { "200": { @@ -2422,6 +2689,7 @@ "Simulation" ], "operationId": "getSimulationIntegrationStatus", + "x-implementation-status": "planned", "summary": "Get available source integration status for simulation", "responses": { "200": { @@ -2444,6 +2712,7 @@ "Simulation" ], "operationId": "listSimulationHosecloudIntegrations", + "x-implementation-status": "planned", "summary": "List hosecloud source integrations available for simulation", "responses": { "200": { @@ -2469,6 +2738,7 @@ "Simulation" ], "operationId": "uploadMaterialPackage", + "x-implementation-status": "planned", "summary": "Upload a material package ZIP for simulation", "requestBody": { "required": true, @@ -2508,7 +2778,7 @@ "type": "apiKey", "in": "header", "name": "X-Seal-Home-Session", - "description": "Optional local service session header for future HTTP deployments." + "description": "Reserved header. The local adapter does not currently authenticate requests: it acts with\nthe credentials already stored on this machine for the selected enterprise. Keep it bound\nto loopback (`--host 127.0.0.1`) and do not expose the port to a network or an origin you\ndo not control.\n" } }, "parameters": { diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index f768999..5d304b8 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -3,15 +3,25 @@ info: title: seal-use Wrapped API version: 0.10.24 description: | - Planned HTTP contract for the seal-use wrapped backend API. + HTTP contract for the seal-use wrapped backend API, served by the local HTTP adapter + (`seal-use http`, or the `seal-use service start` daemon; default http://127.0.0.1:8787). - These endpoints describe the intended stable API for frontend developers and agents once - the HTTP adapter is implemented. - They are not the raw downstream Seal endpoints. seal-use is responsible for enterprise - selection, source authentication, response compaction, and diagnostics-friendly fields. + These endpoints describe the stable wrapped API for frontend developers and agents. They are + not the raw downstream Seal endpoints: seal-use is responsible for enterprise selection, + source authentication, response compaction, and diagnostics-friendly fields. + + Every operation declares `x-implementation-status`, so a caller can tell what the running + adapter actually serves: + + - `implemented` — routed by `src/http/routes.ts` today. `src/http/openapi-implementation.test.ts` + fails when an `implemented` operation has no matching route. + - `planned` — contract-only, designed but not routed yet. Calling it returns 404. + + The same capabilities are reachable through the CLI, and through the optional MCP server when + it is enabled. servers: - url: http://localhost:8787 - description: Reserved for a future local HTTP adapter; the current service uses MCP stdio. + description: Local HTTP adapter (`seal-use http`, or the `seal-use service start` daemon). Loopback-only by default. security: - localSession: [] tags: @@ -35,7 +45,11 @@ components: type: apiKey in: header name: X-Seal-Home-Session - description: Optional local service session header for future HTTP deployments. + description: | + Reserved header. The local adapter does not currently authenticate requests: it acts with + the credentials already stored on this machine for the selected enterprise. Keep it bound + to loopback (`--host 127.0.0.1`) and do not expose the port to a network or an origin you + do not control. parameters: $ref: ./components/parameters.yaml responses: diff --git a/openapi/paths/approval-knowledge.yaml b/openapi/paths/approval-knowledge.yaml index 4391df3..187f660 100644 --- a/openapi/paths/approval-knowledge.yaml +++ b/openapi/paths/approval-knowledge.yaml @@ -3,6 +3,7 @@ paths: get: tags: [Approval Knowledge] operationId: getApprovalContext + x-implementation-status: planned summary: Get rules, documents, and style preferences together parameters: - $ref: ../components/parameters.yaml#/CorpId @@ -30,6 +31,7 @@ paths: post: tags: [Approval Knowledge] operationId: searchApprovalKnowledge + x-implementation-status: planned summary: Search approval rules, documents, and preferences requestBody: required: true @@ -48,6 +50,7 @@ paths: get: tags: [Approval Knowledge] operationId: listApprovalRules + x-implementation-status: implemented summary: List current draft approval rules responses: "200": @@ -59,6 +62,7 @@ paths: post: tags: [Approval Knowledge] operationId: createApprovalRule + x-implementation-status: planned summary: Create draft approval rule requestBody: required: true @@ -79,6 +83,7 @@ paths: patch: tags: [Approval Knowledge] operationId: updateApprovalRule + x-implementation-status: planned summary: Update draft approval rule requestBody: required: true @@ -96,6 +101,7 @@ paths: delete: tags: [Approval Knowledge] operationId: deleteApprovalRule + x-implementation-status: planned summary: Delete draft approval rule responses: "200": @@ -104,6 +110,7 @@ paths: get: tags: [Approval Knowledge] operationId: listApprovalRuleVersions + x-implementation-status: planned summary: List published approval rule versions responses: "200": @@ -120,6 +127,7 @@ paths: get: tags: [Approval Knowledge] operationId: getApprovalRuleVersion + x-implementation-status: planned summary: Get published approval rule version responses: "200": @@ -132,6 +140,7 @@ paths: get: tags: [Approval Knowledge] operationId: getApprovalRuleByVersion + x-implementation-status: planned summary: Get one wrapped rule from a published version parameters: - $ref: ../components/parameters.yaml#/CorpId @@ -174,6 +183,7 @@ paths: post: tags: [Approval Knowledge] operationId: publishApprovalRuleVersion + x-implementation-status: planned summary: Publish current draft rules requestBody: required: true @@ -193,6 +203,7 @@ paths: get: tags: [Approval Knowledge] operationId: listApprovalDocuments + x-implementation-status: planned summary: List approval knowledge documents parameters: - $ref: ../components/parameters.yaml#/Offset @@ -220,6 +231,7 @@ paths: post: tags: [Approval Knowledge] operationId: createApprovalDocument + x-implementation-status: planned summary: Create approval knowledge document requestBody: required: true @@ -240,6 +252,7 @@ paths: get: tags: [Approval Knowledge] operationId: getApprovalDocument + x-implementation-status: planned summary: Get approval knowledge document responses: "200": @@ -251,6 +264,7 @@ paths: patch: tags: [Approval Knowledge] operationId: updateApprovalDocument + x-implementation-status: planned summary: Update approval knowledge document requestBody: required: true @@ -268,6 +282,7 @@ paths: delete: tags: [Approval Knowledge] operationId: deleteApprovalDocument + x-implementation-status: planned summary: Delete approval knowledge document responses: "200": @@ -276,6 +291,7 @@ paths: get: tags: [Approval Knowledge] operationId: getApprovalStylePreferences + x-implementation-status: planned summary: Get approval style preferences responses: "200": @@ -287,6 +303,7 @@ paths: patch: tags: [Approval Knowledge] operationId: updateApprovalStylePreferences + x-implementation-status: planned summary: Update approval style preferences requestBody: required: true @@ -301,3 +318,51 @@ paths: application/json: schema: $ref: ../components/schemas/index.yaml#/ApprovalStylePreferences + /v1/preferences: + get: + tags: [Approval Knowledge] + operationId: getPreferences + x-implementation-status: implemented + summary: Get current decision, thinking-depth and rule-version preferences + parameters: + - $ref: ../components/parameters.yaml#/CorpId + responses: + "200": + description: Decision preferences, thinking depth preference and the bound rule set version. + content: + application/json: + schema: + $ref: ../components/schemas/index.yaml#/ApprovalStylePreferences + /v1/preferences/decision: + post: + tags: [Approval Knowledge] + operationId: updatePreferenceDecision + x-implementation-status: implemented + summary: Update decision preferences (takes effect immediately for the running approval agent) + parameters: + - $ref: ../components/parameters.yaml#/CorpId + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + explicitApprove: + type: string + explicitReject: + type: string + exemptApprove: + type: string + review: + type: string + dryRun: + type: boolean + description: Return the before/after diff without writing. + responses: + "200": + description: Updated preferences, or the previewed diff when dryRun is set. + content: + application/json: + schema: + $ref: ../components/schemas/index.yaml#/ApprovalStylePreferences diff --git a/openapi/paths/approval-runs.yaml b/openapi/paths/approval-runs.yaml index 04c1ca9..4046a93 100644 --- a/openapi/paths/approval-runs.yaml +++ b/openapi/paths/approval-runs.yaml @@ -3,6 +3,7 @@ paths: get: tags: [Approval Runs] operationId: searchApprovalRuns + x-implementation-status: implemented summary: Search wrapped approval run history parameters: - $ref: ../components/parameters.yaml#/CorpId @@ -70,6 +71,7 @@ paths: get: tags: [Approval Runs] operationId: summarizeApprovalRuns + x-implementation-status: implemented summary: Summarize approval runs by local date parameters: - $ref: ../components/parameters.yaml#/CorpId @@ -99,10 +101,50 @@ paths: application/json: schema: $ref: ../components/schemas/index.yaml#/ApprovalRunsSummary + /v1/approval-runs/stats: + get: + tags: [Approval Runs] + operationId: statApprovalRuns + x-implementation-status: implemented + summary: Aggregate approval run counts by status and source system + parameters: + - $ref: ../components/parameters.yaml#/CorpId + - name: since + in: query + schema: + type: string + description: Time window such as 3months, 7days or 24hours. + - name: dedupeBy + in: query + schema: + type: string + enum: [sourceDocumentSN, sourceDocumentId, id] + default: sourceDocumentSN + description: Field used to count distinct business documents. + - name: status + in: query + schema: + type: string + - name: sourceSystem + in: query + schema: + type: string + - name: taskMode + in: query + schema: + type: string + responses: + "200": + description: Counts grouped by status and source system, plus the deduplicated total. + content: + application/json: + schema: + type: object /v1/approval-runs/pick: get: tags: [Approval Runs] operationId: pickApprovalRuns + x-implementation-status: implemented summary: Pick likely approval runs by document number or trace key parameters: - $ref: ../components/parameters.yaml#/CorpId @@ -151,6 +193,7 @@ paths: get: tags: [Approval Runs] operationId: getApprovalRunLangfuseBridge + x-implementation-status: planned summary: Resolve approval runs to Langfuse trace or session hints parameters: - $ref: ../components/parameters.yaml#/CorpId @@ -181,6 +224,7 @@ paths: get: tags: [Approval Runs] operationId: getApprovalRunUrl + x-implementation-status: implemented summary: Get enterprise assist URL and optional source document URL parameters: - $ref: ../components/parameters.yaml#/CorpId @@ -209,6 +253,7 @@ paths: get: tags: [Approval Runs] operationId: getApprovalRun + x-implementation-status: implemented summary: Get wrapped approval run detail parameters: - name: summary @@ -234,6 +279,7 @@ paths: get: tags: [Approval Runs] operationId: getApprovalRunCitedRules + x-implementation-status: implemented summary: Extract rules cited or matched by the AI result responses: "200": @@ -249,6 +295,7 @@ paths: get: tags: [Approval Runs] operationId: getApprovalRunDocumentSummary + x-implementation-status: implemented summary: Get key document fields and compact AI/manual result responses: "200": @@ -264,6 +311,7 @@ paths: get: tags: [Approval Runs] operationId: getApprovalRunAttachments + x-implementation-status: implemented summary: List compact attachment metadata parameters: - name: summary @@ -284,6 +332,7 @@ paths: get: tags: [Approval Runs] operationId: getApprovalRunResult + x-implementation-status: implemented summary: Get AI result, optionally as a compact summary parameters: - name: summary diff --git a/openapi/paths/auth.yaml b/openapi/paths/auth.yaml index b31a23d..1634972 100644 --- a/openapi/paths/auth.yaml +++ b/openapi/paths/auth.yaml @@ -3,6 +3,7 @@ paths: get: tags: [Auth] operationId: diagnoseAuth + x-implementation-status: planned summary: Diagnose wrapped source-to-Seal authentication parameters: - $ref: ../components/parameters.yaml#/CorpId @@ -17,6 +18,7 @@ paths: get: tags: [Auth] operationId: whoami + x-implementation-status: implemented summary: Get current wrapped Seal identity parameters: - $ref: ../components/parameters.yaml#/CorpId @@ -33,6 +35,7 @@ paths: get: tags: [Auth] operationId: getSession + x-implementation-status: implemented summary: Get current wrapped Seal session metadata parameters: - $ref: ../components/parameters.yaml#/CorpId diff --git a/openapi/paths/corps.yaml b/openapi/paths/corps.yaml index ea86a3a..056fb07 100644 --- a/openapi/paths/corps.yaml +++ b/openapi/paths/corps.yaml @@ -3,6 +3,7 @@ paths: get: tags: [Corps] operationId: listCorps + x-implementation-status: implemented summary: List configured enterprises responses: "200": @@ -17,6 +18,7 @@ paths: get: tags: [Corps] operationId: getCurrentCorp + x-implementation-status: planned summary: Get current enterprise description: Returns the configured default enterprise in stateful mode. Stateless mode has no current enterprise and requires an explicit corpId for enterprise operations. responses: @@ -30,6 +32,7 @@ paths: post: tags: [Corps] operationId: switchCurrentCorp + x-implementation-status: planned summary: Switch current enterprise requestBody: required: true diff --git a/openapi/paths/index.yaml b/openapi/paths/index.yaml index 55f5585..cc923bd 100644 --- a/openapi/paths/index.yaml +++ b/openapi/paths/index.yaml @@ -34,10 +34,16 @@ $ref: ./approval-knowledge.yaml#/paths/~1v1~1approval~1documents~1{documentId} /v1/approval/style-preferences: $ref: ./approval-knowledge.yaml#/paths/~1v1~1approval~1style-preferences +/v1/preferences: + $ref: ./approval-knowledge.yaml#/paths/~1v1~1preferences +/v1/preferences/decision: + $ref: ./approval-knowledge.yaml#/paths/~1v1~1preferences~1decision /v1/approval-runs: $ref: ./approval-runs.yaml#/paths/~1v1~1approval-runs /v1/approval-runs/summary: $ref: ./approval-runs.yaml#/paths/~1v1~1approval-runs~1summary +/v1/approval-runs/stats: + $ref: ./approval-runs.yaml#/paths/~1v1~1approval-runs~1stats /v1/approval-runs/pick: $ref: ./approval-runs.yaml#/paths/~1v1~1approval-runs~1pick /v1/approval-runs/bridge: diff --git a/openapi/paths/simulation.yaml b/openapi/paths/simulation.yaml index 3f857a8..9a0191a 100644 --- a/openapi/paths/simulation.yaml +++ b/openapi/paths/simulation.yaml @@ -3,6 +3,7 @@ paths: post: tags: [Simulation] operationId: createSimulationBatch + x-implementation-status: implemented summary: Create a simulation batch requestBody: required: true @@ -23,6 +24,7 @@ paths: post: tags: [Simulation] operationId: createMaterialPackBatch + x-implementation-status: planned summary: Create a material pack simulation batch requestBody: required: true @@ -43,6 +45,7 @@ paths: get: tags: [Simulation] operationId: listSimulationBatches + x-implementation-status: implemented summary: List simulation batches parameters: - name: limit @@ -66,6 +69,7 @@ paths: get: tags: [Simulation] operationId: getSimulationBatch + x-implementation-status: implemented summary: Get a simulation batch detail including echoed create params responses: "200": @@ -81,6 +85,7 @@ paths: get: tags: [Simulation] operationId: getSimulationBatchRecords + x-implementation-status: planned summary: Get wrapped simulation batch records parameters: - name: query @@ -100,6 +105,7 @@ paths: get: tags: [Simulation] operationId: listSimulationTemplates + x-implementation-status: planned summary: List simulation test templates responses: "200": @@ -115,6 +121,7 @@ paths: get: tags: [Simulation] operationId: getSimulationIntegrationStatus + x-implementation-status: planned summary: Get available source integration status for simulation responses: "200": @@ -128,6 +135,7 @@ paths: get: tags: [Simulation] operationId: listSimulationHosecloudIntegrations + x-implementation-status: planned summary: List hosecloud source integrations available for simulation responses: "200": @@ -143,6 +151,7 @@ paths: post: tags: [Simulation] operationId: uploadMaterialPackage + x-implementation-status: planned summary: Upload a material package ZIP for simulation requestBody: required: true diff --git a/openapi/paths/source.yaml b/openapi/paths/source.yaml index 54ceb71..db16e2e 100644 --- a/openapi/paths/source.yaml +++ b/openapi/paths/source.yaml @@ -3,6 +3,7 @@ paths: get: tags: [Source] operationId: getSourceConfig + x-implementation-status: planned summary: Resolve source-derived Seal enterprise config parameters: - $ref: ../components/parameters.yaml#/CorpId diff --git a/src/http/openapi-implementation.test.ts b/src/http/openapi-implementation.test.ts new file mode 100644 index 0000000..967b226 --- /dev/null +++ b/src/http/openapi-implementation.test.ts @@ -0,0 +1,106 @@ +import { describe, expect, test } from "bun:test"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; +import { getOpenApiSchema } from "../core/embedded-openapi.js"; + +// The bundled contract is what consumers read: `seal-use http` serves it at /openapi.json and +// `dist/openapi.json` is committed. It had drifted from the adapter in both directions — it +// documented /v1/approval/rules/{ruleId} PATCH/DELETE and /v1/approval/documents* that no route +// serves (a caller following it gets 404), and it omitted /v1/approval-runs/stats, which the +// adapter does serve. Marking each operation here turns that drift into a failing test. +// +// What this proves: every operation claimed `implemented` has a matching route in routes.ts, and +// every exact /v1 route in routes.ts is in the contract. What it does not prove: that a +// `planned` operation's *placeholder* prefix is unrouted (prefix branches are matched loosely), +// nor that an operation's request/response schema matches its handler. +const IMPLEMENTATION_KEY = "x-implementation-status"; +const OPERATION_METHODS = ["get", "post", "put", "patch", "delete"] as const; +const VALID_STATUSES = ["implemented", "planned"]; + +type Operation = { method: string; path: string; status: string }; + +function collectOperations(): Operation[] { + const schema = getOpenApiSchema() as { + paths?: Record>; + }; + const operations: Operation[] = []; + + for (const [path, pathItem] of Object.entries(schema.paths ?? {})) { + for (const method of OPERATION_METHODS) { + const operation = pathItem[method]; + if (operation === undefined) continue; + if (typeof operation !== "object" || operation === null) continue; + const status = (operation as Record)[IMPLEMENTATION_KEY]; + operations.push({ method, path, status: typeof status === "string" ? status : "" }); + } + } + + return operations; +} + +const routesSource = readFileSync(join(import.meta.dir, "routes.ts"), "utf8"); + +/** Literals compared with `pathname === "…"`, i.e. routes with no path parameters. */ +function exactRouteLiterals(): string[] { + return Array.from(routesSource.matchAll(/pathname === "([^"]+)"/g), (match) => match[1]!).filter( + (literal) => literal.startsWith("/v1/") + ); +} + +/** Prefix literals compared with `pathname.startsWith("…")`, which carry the path parameters. */ +function prefixRouteLiterals(): string[] { + return Array.from(routesSource.matchAll(/pathname\.startsWith\("([^"]+)"\)/g), (match) => match[1]!); +} + +describe("OpenAPI contract vs HTTP adapter", () => { + test("every operation declares its implementation status", () => { + const operations = collectOperations(); + expect(operations.length).toBeGreaterThan(40); + + for (const { method, path, status } of operations) { + expect({ method, path, status, valid: VALID_STATUSES.includes(status) }).toEqual({ + method, + path, + status, + valid: true + }); + } + }); + + test("both statuses are in use, so the marking cannot go vacuous", () => { + const operations = collectOperations(); + const implemented = operations.filter((operation) => operation.status === "implemented"); + const planned = operations.filter((operation) => operation.status === "planned"); + + // A minimum count fails loudly if `planned` operations are mass-promoted by accident. + expect(implemented.length).toBeGreaterThanOrEqual(15); + expect(planned.length).toBeGreaterThanOrEqual(15); + }); + + test("every operation claimed implemented is actually routed", () => { + const exactLiterals = new Set(exactRouteLiterals()); + const prefixLiterals = new Set(prefixRouteLiterals()); + + for (const { method, path, status } of collectOperations()) { + if (status !== "implemented") continue; + + // `/v1/approval-runs/{recordId}/result` is served by the `/v1/approval-runs/` prefix + // branch, so a placeholder path is proven by its static prefix rather than by equality. + const hasPlaceholder = path.includes("{"); + const prefix = path.split("/{")[0]!; + const routed = hasPlaceholder + ? prefixLiterals.has(`${prefix}/`) + : exactLiterals.has(path); + + expect({ method, path, routed }).toEqual({ method, path, routed: true }); + } + }); + + test("every exact /v1 route is documented", () => { + const documented = new Set(collectOperations().map((operation) => operation.path)); + + for (const literal of exactRouteLiterals()) { + expect({ literal, documented: documented.has(literal) }).toEqual({ literal, documented: true }); + } + }); +});