diff --git a/openapi.public.json b/openapi.public.json index 7ab1d71a..be32a154 100644 --- a/openapi.public.json +++ b/openapi.public.json @@ -263,6 +263,22 @@ ], "type": "string" }, + "ApprovalGap": { + "properties": { + "assessment_id": { + "format": "uuid", + "type": "string" + }, + "code": { + "type": "string" + } + }, + "required": [ + "assessment_id", + "code" + ], + "type": "object" + }, "AssessmentProjection": { "properties": { "assessment_id": { @@ -457,6 +473,36 @@ } ] }, + "CaptureState": { + "description": "How the capture ended.", + "oneOf": [ + { + "const": "PENDING", + "description": "Still waiting for an authorized execution or a decidable look.", + "type": "string" + }, + { + "const": "RECORDED", + "description": "World recorded every deferred question.", + "type": "string" + }, + { + "const": "UNBOUND", + "description": "At least one deferred question is not bound to the execution.", + "type": "string" + }, + { + "const": "NOT_EXECUTED", + "description": "The gate never authorized the execution.", + "type": "string" + }, + { + "const": "INCOMPLETE", + "description": "The capture failed before it wrote its receipt. The gate is\n unchanged; nothing is inferred about the deferred questions.", + "type": "string" + } + ] + }, "ChangeAttributionView": { "description": "Which conditions behind a check's result the change brought, and which\n World found at the review's base revision. It sits beside the result and\n never changes it: a condition already at the base is still a condition.", "properties": { @@ -1702,7 +1748,7 @@ "type": "string" }, "kind": { - "description": "`PULL_REQUEST`, `DEPLOYMENT`, `PATCH`, a review of local changes\n sent as a patch, or `COMMIT`, a review of pushed commits.", + "description": "`PULL_REQUEST`, `DEPLOYMENT`, `PATCH`, a review of local changes\n sent as a patch, `COMMIT`, a review of pushed commits, or `FILES`,\n complete selected files at one pushed commit.", "type": "string" }, "merge_gate": { @@ -2091,7 +2137,8 @@ "PULL_REQUEST", "DEPLOYMENT", "PATCH", - "COMMIT" + "COMMIT", + "FILES" ], "type": "string" }, @@ -2172,6 +2219,67 @@ ], "type": "object" }, + "FileReviewRequest": { + "additionalProperties": false, + "description": "Whole files selected at one exact pushed commit.", + "properties": { + "commit_sha": { + "description": "The exact pushed commit whose whole files are reviewed.", + "type": "string" + }, + "paths": { + "description": "Between one and twenty exact repository-relative file paths.", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "commit_sha", + "paths" + ], + "type": "object" + }, + "FileReviewResponse": { + "description": "What a named-file review request produced.", + "properties": { + "existing": { + "description": "True when this exact selection already had a review and that one is\n returned. Sending the same selection twice by the same person reviews it once.", + "type": "boolean" + }, + "review_id": { + "description": "The review of this selection, readable through the review and findings\n routes.", + "format": "uuid", + "type": "string" + } + }, + "required": [ + "review_id", + "existing" + ], + "type": "object" + }, + "FileScope": { + "additionalProperties": false, + "description": "The retained selection, not a digest of file contents. Its identity uses\n a version prefix and length-framed UTF-8 paths in their sorted order.", + "properties": { + "paths": { + "items": { + "type": "string" + }, + "type": "array" + }, + "paths_digest": { + "type": "string" + } + }, + "required": [ + "paths", + "paths_digest" + ], + "type": "object" + }, "FilterChoice": { "properties": { "id": { @@ -3010,6 +3118,13 @@ }, "GateState": { "properties": { + "occurrence_captures": { + "description": "The occurrence questions the gate's approval deferred, as each\n observed execution of its deployment answered them. Outcome-only\n records: none of them changes the gate or grades a prediction.", + "items": { + "$ref": "#/components/schemas/OccurrenceCapture" + }, + "type": "array" + }, "override_record": { "anyOf": [ { @@ -3027,7 +3142,8 @@ } }, "required": [ - "status" + "status", + "occurrence_captures" ], "type": "object" }, @@ -3061,6 +3177,91 @@ ], "type": "object" }, + "OccurrenceCapture": { + "description": "The capture of one observed execution of a gate's deployment.", + "properties": { + "approval_gaps": { + "description": "Assessments whose approval could defer nothing, with the reason.", + "items": { + "$ref": "#/components/schemas/ApprovalGap" + }, + "type": "array" + }, + "detail": { + "type": [ + "string", + "null" + ] + }, + "occurrence_key": { + "type": [ + "string", + "null" + ] + }, + "questions": { + "items": { + "$ref": "#/components/schemas/OccurrenceQuestion" + }, + "type": "array" + }, + "state": { + "$ref": "#/components/schemas/CaptureState" + } + }, + "required": [ + "state", + "approval_gaps", + "questions" + ], + "type": "object" + }, + "OccurrenceQuestion": { + "description": "One deferred question as the gate presents it.", + "properties": { + "assessment_id": { + "format": "uuid", + "type": "string" + }, + "code": { + "description": "World's binding or refusal code, or the control plane's own gap.", + "type": [ + "string", + "null" + ] + }, + "family_key": { + "type": "string" + }, + "family_version": { + "format": "int32", + "type": "integer" + }, + "observed_result": { + "description": "World's observed result once it recorded the question.", + "type": [ + "string", + "null" + ] + }, + "outcome_id": { + "type": [ + "string", + "null" + ] + }, + "state": { + "$ref": "#/components/schemas/QuestionState" + } + }, + "required": [ + "assessment_id", + "family_key", + "family_version", + "state" + ], + "type": "object" + }, "OpenFindingCounts": { "properties": { "serious": { @@ -3590,6 +3791,31 @@ ], "type": "object" }, + "QuestionState": { + "description": "Where one deferred question stands.", + "oneOf": [ + { + "const": "PENDING", + "description": "World has stored no record yet: the execution is not yet decidable\n inside the question's window.", + "type": "string" + }, + { + "const": "RECORDED", + "description": "World recorded what the execution was observed to do.", + "type": "string" + }, + { + "const": "UNBOUND", + "description": "The question is not bound to the execution: World's binding code, its\n refusal of the replay, or the control plane's own gap says why.", + "type": "string" + }, + { + "const": "NOT_EXECUTED", + "description": "The gate never authorized the execution, so nothing ran to observe.", + "type": "string" + } + ] + }, "RefusedEnvironment": { "description": "An environment a refusal names. `external_key` is how its pages are\n addressed.", "properties": { @@ -4151,7 +4377,7 @@ "type": "string" }, "kind": { - "description": "`PULL_REQUEST`, `DEPLOYMENT`, `PATCH`, a review of local changes\n sent as a patch, or `COMMIT`, a review of pushed commits.", + "description": "`PULL_REQUEST`, `DEPLOYMENT`, `PATCH`, a review of local changes\n sent as a patch, `COMMIT`, a review of pushed commits, or `FILES`,\n complete selected files at one pushed commit.", "type": "string" }, "public_key": { @@ -4377,7 +4603,7 @@ "$ref": "#/components/schemas/ExportReviewKind" } ], - "description": "Whether the review analyzes a pull request, a deployment, a local patch or pushed\n commits." + "description": "Whether the review analyzes a pull request, a deployment, a local patch, pushed\n commits or selected whole files." }, "organization_id": { "description": "The organization that owns the review.", @@ -5014,6 +5240,33 @@ ], "type": "object" }, + "StopResponse": { + "description": "What stopping a review recorded.", + "properties": { + "review_id": { + "format": "uuid", + "type": "string" + }, + "status": { + "description": "Always `STOPPED`: the review's status once the stop is committed.", + "type": "string" + }, + "stopped_at": { + "format": "date-time", + "type": "string" + }, + "stopped_by": { + "$ref": "#/components/schemas/ActorView" + } + }, + "required": [ + "review_id", + "status", + "stopped_by", + "stopped_at" + ], + "type": "object" + }, "SubjectAuthorization": { "description": "One assessment's authorization of one subject, by identity.\n\n The display name is not the answer on its own: an environment's external key\n is unique within its organization and a display name is mutable metadata,\n so two environments of one review can carry the same one.\n Collapsing to it would leave a reader unable to tell which assessment\n authorized the subject and which one gapped, which is the confusion this\n field exists to remove.", "properties": { @@ -5067,6 +5320,17 @@ "null" ] }, + "file_scope": { + "anyOf": [ + { + "$ref": "#/components/schemas/FileScope" + }, + { + "type": "null" + } + ], + "description": "Whole-file selection at the pinned revision; absent for comparisons." + }, "id": { "description": "The subject's stable identifier. It holds across a poll refresh even\n when a concurrently populated subject shifts this response's\n `(kind, id)` order: a client keying its own local UI state (an open\n disclosure, a focused control) by array index would otherwise lose\n that state to a reorder that changed nothing it owns.", "format": "uuid", @@ -5813,6 +6077,84 @@ "x-proofline-token-scope": "reviews:request" } }, + "/api/v1/organizations/{org_id}/repositories/{repo_id}/file-reviews": { + "post": { + "description": "Reviews up to twenty exact file paths at one pushed commit. Requires live GitHub read access and verifies every path at that commit. The retained selection is immutable; a repeat by the same person returns its review. Results remain in Proofline and are never posted to GitHub.", + "operationId": "request_file_review", + "parameters": [ + { + "in": "path", + "name": "org_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + }, + "style": "simple" + }, + { + "in": "path", + "name": "repo_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + }, + "style": "simple" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FileReviewRequest" + } + } + }, + "description": "Whole files selected at one exact pushed commit.", + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FileReviewResponse" + } + } + }, + "description": "What a named-file review request produced." + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RunNowRefused" + } + } + }, + "description": "A run-now request that created nothing, as the 400 it is answered with.\n\n The refusal is a configuration fact, not a failure, and it is still sent\n as an RFC 9457 problem: `title`, `status` and `detail` are what a client\n that knows only problems shows, and `repository_name` and `refusal` are\n the extension members a client that knows refusals links from. During a\n rollout a page loaded from the previous bundle keeps working against\n this server, because a refusal was a 400 with a `detail` before too." + }, + "default": { + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/Problem" + } + } + }, + "description": "An RFC 9457 problem; the HTTP status remains authoritative." + } + }, + "security": [ + { + "bearerAuth": [] + } + ], + "summary": "Review selected whole files", + "x-proofline-token-scope": "reviews:request" + } + }, "/api/v1/organizations/{org_id}/repositories/{repo_id}/patch-reviews": { "post": { "description": "Reviews a unified diff against a commit GitHub has in the repository, and returns that patch's review when one exists. The review reads only that commit and the patch, and is never posted to a pull request. Requires live GitHub read access; the same patch on the same base always returns the same review.", @@ -6824,6 +7166,63 @@ "summary": "Get review routing", "x-proofline-token-scope": "reviews:read" } + }, + "/api/v1/organizations/{org_id}/reviews/{review_id}/stop": { + "post": { + "description": "Stops the holder's own pending or running withheld patch, commit or named-file review. Requires a personal or CLI device token with live GitHub read access to the review's repository. Organization, CI job and MCP OAuth tokens cannot stop reviews. The stopped review retains its findings and exact code identity; requesting the same input returns that stopped review.", + "operationId": "stop_review", + "parameters": [ + { + "in": "path", + "name": "org_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + }, + "style": "simple" + }, + { + "in": "path", + "name": "review_id", + "required": true, + "schema": { + "format": "uuid", + "type": "string" + }, + "style": "simple" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StopResponse" + } + } + }, + "description": "What stopping a review recorded." + }, + "default": { + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/Problem" + } + } + }, + "description": "An RFC 9457 problem; the HTTP status remains authoritative." + } + }, + "security": [ + { + "bearerAuth": [] + } + ], + "summary": "Stop your local review", + "x-proofline-token-scope": "reviews:request" + } } } } diff --git a/proofline/__init__.py b/proofline/__init__.py index f78fdf8e..0b6b82ea 100644 --- a/proofline/__init__.py +++ b/proofline/__init__.py @@ -11,6 +11,8 @@ CustomerAssessmentDetail, CustomerFinding, CustomerReviewDetail, + FileReviewRequest, + FileReviewResponse, PatchReviewRequest, PatchReviewResponse, PatchTriggerSource, @@ -22,6 +24,7 @@ RunNowRequest, RunNowResponse, StartSession, + StopResponse, ) from ._transport import VERSION as __version__ from ._transport import ProoflineError @@ -39,6 +42,8 @@ "CustomerAssessmentDetail", "CustomerFinding", "CustomerReviewDetail", + "FileReviewRequest", + "FileReviewResponse", "PatchReviewRequest", "PatchReviewResponse", "PatchTriggerSource", @@ -55,6 +60,7 @@ "RunNowResponse", "SecretStr", "StartSession", + "StopResponse", "__version__", "models", ] diff --git a/proofline/_generated/api/default/request_file_review.py b/proofline/_generated/api/default/request_file_review.py new file mode 100644 index 00000000..eca1ea2a --- /dev/null +++ b/proofline/_generated/api/default/request_file_review.py @@ -0,0 +1,212 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote +from uuid import UUID + +import httpx + +from ...client import AuthenticatedClient, Client +from ...models.file_review_request import FileReviewRequest +from ...models.file_review_response import FileReviewResponse +from ...models.problem import Problem +from ...models.run_now_refused import RunNowRefused +from ...types import Response + + +def _get_kwargs( + org_id: UUID, + repo_id: UUID, + *, + body: FileReviewRequest, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/api/v1/organizations/{org_id}/repositories/{repo_id}/file-reviews".format( + org_id=quote(str(org_id), safe=""), + repo_id=quote(str(repo_id), safe=""), + ), + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> FileReviewResponse | Problem | RunNowRefused: + if response.status_code == 200: + response_200 = FileReviewResponse.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = RunNowRefused.from_dict(response.json()) + + return response_400 + + response_default = Problem.from_dict(response.json()) + + return response_default + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[FileReviewResponse | Problem | RunNowRefused]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + org_id: UUID, + repo_id: UUID, + *, + client: AuthenticatedClient, + body: FileReviewRequest, +) -> Response[FileReviewResponse | Problem | RunNowRefused]: + """Review selected whole files + + Reviews up to twenty exact file paths at one pushed commit. Requires live GitHub read access and + verifies every path at that commit. The retained selection is immutable; a repeat by the same person + returns its review. Results remain in Proofline and are never posted to GitHub. + + Args: + org_id (UUID): + repo_id (UUID): + body (FileReviewRequest): Whole files selected at one exact pushed commit. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[FileReviewResponse | Problem | RunNowRefused] + """ + + kwargs = _get_kwargs( + org_id=org_id, + repo_id=repo_id, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + org_id: UUID, + repo_id: UUID, + *, + client: AuthenticatedClient, + body: FileReviewRequest, +) -> FileReviewResponse | Problem | RunNowRefused | None: + """Review selected whole files + + Reviews up to twenty exact file paths at one pushed commit. Requires live GitHub read access and + verifies every path at that commit. The retained selection is immutable; a repeat by the same person + returns its review. Results remain in Proofline and are never posted to GitHub. + + Args: + org_id (UUID): + repo_id (UUID): + body (FileReviewRequest): Whole files selected at one exact pushed commit. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + FileReviewResponse | Problem | RunNowRefused + """ + + return sync_detailed( + org_id=org_id, + repo_id=repo_id, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + org_id: UUID, + repo_id: UUID, + *, + client: AuthenticatedClient, + body: FileReviewRequest, +) -> Response[FileReviewResponse | Problem | RunNowRefused]: + """Review selected whole files + + Reviews up to twenty exact file paths at one pushed commit. Requires live GitHub read access and + verifies every path at that commit. The retained selection is immutable; a repeat by the same person + returns its review. Results remain in Proofline and are never posted to GitHub. + + Args: + org_id (UUID): + repo_id (UUID): + body (FileReviewRequest): Whole files selected at one exact pushed commit. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[FileReviewResponse | Problem | RunNowRefused] + """ + + kwargs = _get_kwargs( + org_id=org_id, + repo_id=repo_id, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + org_id: UUID, + repo_id: UUID, + *, + client: AuthenticatedClient, + body: FileReviewRequest, +) -> FileReviewResponse | Problem | RunNowRefused | None: + """Review selected whole files + + Reviews up to twenty exact file paths at one pushed commit. Requires live GitHub read access and + verifies every path at that commit. The retained selection is immutable; a repeat by the same person + returns its review. Results remain in Proofline and are never posted to GitHub. + + Args: + org_id (UUID): + repo_id (UUID): + body (FileReviewRequest): Whole files selected at one exact pushed commit. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + FileReviewResponse | Problem | RunNowRefused + """ + + return ( + await asyncio_detailed( + org_id=org_id, + repo_id=repo_id, + client=client, + body=body, + ) + ).parsed diff --git a/proofline/_generated/api/default/stop_review.py b/proofline/_generated/api/default/stop_review.py new file mode 100644 index 00000000..6a58ba43 --- /dev/null +++ b/proofline/_generated/api/default/stop_review.py @@ -0,0 +1,188 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote +from uuid import UUID + +import httpx + +from ...client import AuthenticatedClient, Client +from ...models.problem import Problem +from ...models.stop_response import StopResponse +from ...types import Response + + +def _get_kwargs( + org_id: UUID, + review_id: UUID, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/api/v1/organizations/{org_id}/reviews/{review_id}/stop".format( + org_id=quote(str(org_id), safe=""), + review_id=quote(str(review_id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Problem | StopResponse: + if response.status_code == 200: + response_200 = StopResponse.from_dict(response.json()) + + return response_200 + + response_default = Problem.from_dict(response.json()) + + return response_default + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Problem | StopResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + org_id: UUID, + review_id: UUID, + *, + client: AuthenticatedClient, +) -> Response[Problem | StopResponse]: + """Stop your local review + + Stops the holder's own pending or running withheld patch, commit or named-file review. Requires a + personal or CLI device token with live GitHub read access to the review's repository. Organization, + CI job and MCP OAuth tokens cannot stop reviews. The stopped review retains its findings and exact + code identity; requesting the same input returns that stopped review. + + Args: + org_id (UUID): + review_id (UUID): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Problem | StopResponse] + """ + + kwargs = _get_kwargs( + org_id=org_id, + review_id=review_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + org_id: UUID, + review_id: UUID, + *, + client: AuthenticatedClient, +) -> Problem | StopResponse | None: + """Stop your local review + + Stops the holder's own pending or running withheld patch, commit or named-file review. Requires a + personal or CLI device token with live GitHub read access to the review's repository. Organization, + CI job and MCP OAuth tokens cannot stop reviews. The stopped review retains its findings and exact + code identity; requesting the same input returns that stopped review. + + Args: + org_id (UUID): + review_id (UUID): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Problem | StopResponse + """ + + return sync_detailed( + org_id=org_id, + review_id=review_id, + client=client, + ).parsed + + +async def asyncio_detailed( + org_id: UUID, + review_id: UUID, + *, + client: AuthenticatedClient, +) -> Response[Problem | StopResponse]: + """Stop your local review + + Stops the holder's own pending or running withheld patch, commit or named-file review. Requires a + personal or CLI device token with live GitHub read access to the review's repository. Organization, + CI job and MCP OAuth tokens cannot stop reviews. The stopped review retains its findings and exact + code identity; requesting the same input returns that stopped review. + + Args: + org_id (UUID): + review_id (UUID): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Problem | StopResponse] + """ + + kwargs = _get_kwargs( + org_id=org_id, + review_id=review_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + org_id: UUID, + review_id: UUID, + *, + client: AuthenticatedClient, +) -> Problem | StopResponse | None: + """Stop your local review + + Stops the holder's own pending or running withheld patch, commit or named-file review. Requires a + personal or CLI device token with live GitHub read access to the review's repository. Organization, + CI job and MCP OAuth tokens cannot stop reviews. The stopped review retains its findings and exact + code identity; requesting the same input returns that stopped review. + + Args: + org_id (UUID): + review_id (UUID): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Problem | StopResponse + """ + + return ( + await asyncio_detailed( + org_id=org_id, + review_id=review_id, + client=client, + ) + ).parsed diff --git a/proofline/_generated/models/__init__.py b/proofline/_generated/models/__init__.py index 10b7fefc..926b50be 100644 --- a/proofline/_generated/models/__init__.py +++ b/proofline/_generated/models/__init__.py @@ -7,6 +7,7 @@ from .agent_session_prompt_type_1 import AgentSessionPromptType1 from .agent_session_target import AgentSessionTarget from .agent_vendor import AgentVendor +from .approval_gap import ApprovalGap from .assessment_projection import AssessmentProjection from .attributed_condition_view import AttributedConditionView from .author_choice import AuthorChoice @@ -47,6 +48,9 @@ from .export_validation import ExportValidation from .export_validation_source import ExportValidationSource from .file_projection import FileProjection +from .file_review_request import FileReviewRequest +from .file_review_response import FileReviewResponse +from .file_scope import FileScope from .filter_choice import FilterChoice from .finding_causal_edge_view import FindingCausalEdgeView from .finding_causal_graph_view import FindingCausalGraphView @@ -75,6 +79,8 @@ from .gate_state import GateState from .gate_status import GateStatus from .not_assessed_view import NotAssessedView +from .occurrence_capture import OccurrenceCapture +from .occurrence_question import OccurrenceQuestion from .open_finding_counts import OpenFindingCounts from .open_item_environment import OpenItemEnvironment from .open_items_gap_reason import OpenItemsGapReason @@ -136,6 +142,7 @@ from .spend_account_kind import SpendAccountKind from .spend_export_row import SpendExportRow from .start_session import StartSession +from .stop_response import StopResponse from .subject_authorization import SubjectAuthorization from .subject_view import SubjectView from .thread_observation_freshness import ThreadObservationFreshness @@ -152,6 +159,7 @@ "AgentSessionPromptType1", "AgentSessionTarget", "AgentVendor", + "ApprovalGap", "AssessmentProjection", "AttributedConditionView", "AuthorChoice", @@ -192,6 +200,9 @@ "ExportValidation", "ExportValidationSource", "FileProjection", + "FileReviewRequest", + "FileReviewResponse", + "FileScope", "FilterChoice", "FindingCausalEdgeView", "FindingCausalGraphView", @@ -220,6 +231,8 @@ "GateState", "GateStatus", "NotAssessedView", + "OccurrenceCapture", + "OccurrenceQuestion", "OpenFindingCounts", "OpenItemEnvironment", "OpenItemsGapReason", @@ -281,6 +294,7 @@ "SpendAccountKind", "SpendExportRow", "StartSession", + "StopResponse", "SubjectAuthorization", "SubjectView", "ThreadObservationFreshness", diff --git a/proofline/_generated/models/approval_gap.py b/proofline/_generated/models/approval_gap.py new file mode 100644 index 00000000..8994c305 --- /dev/null +++ b/proofline/_generated/models/approval_gap.py @@ -0,0 +1,70 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ApprovalGap") + + +@_attrs_define +class ApprovalGap: + """ + Attributes: + assessment_id (UUID): + code (str): + """ + + assessment_id: UUID + code: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + assessment_id = str(self.assessment_id) + + code = self.code + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "assessment_id": assessment_id, + "code": code, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + assessment_id = UUID(d.pop("assessment_id")) + + code = d.pop("code") + + approval_gap = cls( + assessment_id=assessment_id, + code=code, + ) + + approval_gap.additional_properties = d + return approval_gap + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/proofline/_generated/models/customer_review_detail.py b/proofline/_generated/models/customer_review_detail.py index 6a47549e..6bfc9f49 100644 --- a/proofline/_generated/models/customer_review_detail.py +++ b/proofline/_generated/models/customer_review_detail.py @@ -41,7 +41,8 @@ class CustomerReviewDetail: finding_count (int): How many findings this review's assessments recorded, across all of them. id (UUID): The review's identifier. kind (str): `PULL_REQUEST`, `DEPLOYMENT`, `PATCH`, a review of local changes - sent as a patch, or `COMMIT`, a review of pushed commits. + sent as a patch, `COMMIT`, a review of pushed commits, or `FILES`, + complete selected files at one pushed commit. public_key (str): The review's stable public address: `rev_` followed by its identifier without hyphens. publication (str): Whether the review reached the pull request: `PUBLISHED`, `WITHHELD`, `PUBLICATION_REQUESTED` or `PUBLICATION_REFUSED`. A review run from diff --git a/proofline/_generated/models/export_review_kind.py b/proofline/_generated/models/export_review_kind.py index 9ba28b14..f7b81df3 100644 --- a/proofline/_generated/models/export_review_kind.py +++ b/proofline/_generated/models/export_review_kind.py @@ -4,6 +4,7 @@ class ExportReviewKind(StrEnum): COMMIT = "COMMIT" DEPLOYMENT = "DEPLOYMENT" + FILES = "FILES" PATCH = "PATCH" PULL_REQUEST = "PULL_REQUEST" diff --git a/proofline/_generated/models/file_review_request.py b/proofline/_generated/models/file_review_request.py new file mode 100644 index 00000000..eabbef2e --- /dev/null +++ b/proofline/_generated/models/file_review_request.py @@ -0,0 +1,51 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define + +T = TypeVar("T", bound="FileReviewRequest") + + +@_attrs_define +class FileReviewRequest: + """Whole files selected at one exact pushed commit. + + Attributes: + commit_sha (str): The exact pushed commit whose whole files are reviewed. + paths (list[str]): Between one and twenty exact repository-relative file paths. + """ + + commit_sha: str + paths: list[str] + + def to_dict(self) -> dict[str, Any]: + commit_sha = self.commit_sha + + paths = self.paths + + field_dict: dict[str, Any] = {} + + field_dict.update( + { + "commit_sha": commit_sha, + "paths": paths, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + commit_sha = d.pop("commit_sha") + + paths = cast(list[str], d.pop("paths")) + + file_review_request = cls( + commit_sha=commit_sha, + paths=paths, + ) + + return file_review_request diff --git a/proofline/_generated/models/file_review_response.py b/proofline/_generated/models/file_review_response.py new file mode 100644 index 00000000..d59f17b1 --- /dev/null +++ b/proofline/_generated/models/file_review_response.py @@ -0,0 +1,73 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="FileReviewResponse") + + +@_attrs_define +class FileReviewResponse: + """What a named-file review request produced. + + Attributes: + existing (bool): True when this exact selection already had a review and that one is + returned. Sending the same selection twice by the same person reviews it once. + review_id (UUID): The review of this selection, readable through the review and findings + routes. + """ + + existing: bool + review_id: UUID + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + existing = self.existing + + review_id = str(self.review_id) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "existing": existing, + "review_id": review_id, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + existing = d.pop("existing") + + review_id = UUID(d.pop("review_id")) + + file_review_response = cls( + existing=existing, + review_id=review_id, + ) + + file_review_response.additional_properties = d + return file_review_response + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/proofline/_generated/models/file_scope.py b/proofline/_generated/models/file_scope.py new file mode 100644 index 00000000..04e33bdc --- /dev/null +++ b/proofline/_generated/models/file_scope.py @@ -0,0 +1,52 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define + +T = TypeVar("T", bound="FileScope") + + +@_attrs_define +class FileScope: + """The retained selection, not a digest of file contents. Its identity uses + a version prefix and length-framed UTF-8 paths in their sorted order. + + Attributes: + paths (list[str]): + paths_digest (str): + """ + + paths: list[str] + paths_digest: str + + def to_dict(self) -> dict[str, Any]: + paths = self.paths + + paths_digest = self.paths_digest + + field_dict: dict[str, Any] = {} + + field_dict.update( + { + "paths": paths, + "paths_digest": paths_digest, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + paths = cast(list[str], d.pop("paths")) + + paths_digest = d.pop("paths_digest") + + file_scope = cls( + paths=paths, + paths_digest=paths_digest, + ) + + return file_scope diff --git a/proofline/_generated/models/gate_state.py b/proofline/_generated/models/gate_state.py index ae53a8a9..7aad04c2 100644 --- a/proofline/_generated/models/gate_state.py +++ b/proofline/_generated/models/gate_state.py @@ -9,6 +9,7 @@ from ..types import UNSET, Unset if TYPE_CHECKING: + from ..models.occurrence_capture import OccurrenceCapture from ..models.override import Override @@ -19,12 +20,16 @@ class GateState: """ Attributes: + occurrence_captures (list[OccurrenceCapture]): The occurrence questions the gate's approval deferred, as each + observed execution of its deployment answered them. Outcome-only + records: none of them changes the gate or grades a prediction. status (str): Local gate state. ALLOWED/BLOCKED can precede provider delivery. This field does not confirm that GitHub released or blocked a run. override_record (None | Override | Unset): Recorded override authorization, not confirmation of provider delivery. """ + occurrence_captures: list[OccurrenceCapture] status: str override_record: None | Override | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -32,6 +37,11 @@ class GateState: def to_dict(self) -> dict[str, Any]: from ..models.override import Override # noqa: PLC0415 + occurrence_captures = [] + for occurrence_captures_item_data in self.occurrence_captures: + occurrence_captures_item = occurrence_captures_item_data.to_dict() + occurrence_captures.append(occurrence_captures_item) + status = self.status override_record: dict[str, Any] | None | Unset @@ -46,6 +56,7 @@ def to_dict(self) -> dict[str, Any]: field_dict.update(self.additional_properties) field_dict.update( { + "occurrence_captures": occurrence_captures, "status": status, } ) @@ -56,9 +67,17 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.occurrence_capture import OccurrenceCapture # noqa: PLC0415 from ..models.override import Override # noqa: PLC0415 d = dict(src_dict) + occurrence_captures = [] + _occurrence_captures = d.pop("occurrence_captures") + for occurrence_captures_item_data in _occurrence_captures: + occurrence_captures_item = OccurrenceCapture.from_dict(occurrence_captures_item_data) + + occurrence_captures.append(occurrence_captures_item) + status = d.pop("status") def _parse_override_record(data: object) -> None | Override | Unset: @@ -79,6 +98,7 @@ def _parse_override_record(data: object) -> None | Override | Unset: override_record = _parse_override_record(d.pop("override_record", UNSET)) gate_state = cls( + occurrence_captures=occurrence_captures, status=status, override_record=override_record, ) diff --git a/proofline/_generated/models/occurrence_capture.py b/proofline/_generated/models/occurrence_capture.py new file mode 100644 index 00000000..1242419a --- /dev/null +++ b/proofline/_generated/models/occurrence_capture.py @@ -0,0 +1,220 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, Literal, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.approval_gap import ApprovalGap + from ..models.occurrence_question import OccurrenceQuestion + + +T = TypeVar("T", bound="OccurrenceCapture") + + +@_attrs_define +class OccurrenceCapture: + """The capture of one observed execution of a gate's deployment. + + Attributes: + approval_gaps (list[ApprovalGap]): Assessments whose approval could defer nothing, with the reason. + questions (list[OccurrenceQuestion]): + state (Literal['INCOMPLETE'] | Literal['NOT_EXECUTED'] | Literal['PENDING'] | Literal['RECORDED'] | + Literal['UNBOUND']): How the capture ended. + detail (None | str | Unset): + occurrence_key (None | str | Unset): + """ + + approval_gaps: list[ApprovalGap] + questions: list[OccurrenceQuestion] + state: ( + Literal["INCOMPLETE"] + | Literal["NOT_EXECUTED"] + | Literal["PENDING"] + | Literal["RECORDED"] + | Literal["UNBOUND"] + ) + detail: None | str | Unset = UNSET + occurrence_key: None | str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + approval_gaps = [] + for approval_gaps_item_data in self.approval_gaps: + approval_gaps_item = approval_gaps_item_data.to_dict() + approval_gaps.append(approval_gaps_item) + + questions = [] + for questions_item_data in self.questions: + questions_item = questions_item_data.to_dict() + questions.append(questions_item) + + state: ( + Literal["INCOMPLETE"] + | Literal["NOT_EXECUTED"] + | Literal["PENDING"] + | Literal["RECORDED"] + | Literal["UNBOUND"] + ) + state = self.state + + detail: None | str | Unset + if isinstance(self.detail, Unset): + detail = UNSET + else: + detail = self.detail + + occurrence_key: None | str | Unset + if isinstance(self.occurrence_key, Unset): + occurrence_key = UNSET + else: + occurrence_key = self.occurrence_key + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "approval_gaps": approval_gaps, + "questions": questions, + "state": state, + } + ) + if detail is not UNSET: + field_dict["detail"] = detail + if occurrence_key is not UNSET: + field_dict["occurrence_key"] = occurrence_key + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.approval_gap import ApprovalGap # noqa: PLC0415 + from ..models.occurrence_question import OccurrenceQuestion # noqa: PLC0415 + + d = dict(src_dict) + approval_gaps = [] + _approval_gaps = d.pop("approval_gaps") + for approval_gaps_item_data in _approval_gaps: + approval_gaps_item = ApprovalGap.from_dict(approval_gaps_item_data) + + approval_gaps.append(approval_gaps_item) + + questions = [] + _questions = d.pop("questions") + for questions_item_data in _questions: + questions_item = OccurrenceQuestion.from_dict(questions_item_data) + + questions.append(questions_item) + + def _parse_state( + data: object, + ) -> ( + Literal["INCOMPLETE"] + | Literal["NOT_EXECUTED"] + | Literal["PENDING"] + | Literal["RECORDED"] + | Literal["UNBOUND"] + ): + try: + if not (type(data) is str and data == "PENDING"): + raise TypeError() + componentsschemas_capture_state_type_0 = cast(Literal["PENDING"], data) + if componentsschemas_capture_state_type_0 != "PENDING": + raise ValueError( + f"/components/schemas/CaptureState_type_0 must match const 'PENDING', got '{componentsschemas_capture_state_type_0}'" + ) + return componentsschemas_capture_state_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + try: + if not (type(data) is str and data == "RECORDED"): + raise TypeError() + componentsschemas_capture_state_type_1 = cast(Literal["RECORDED"], data) + if componentsschemas_capture_state_type_1 != "RECORDED": + raise ValueError( + f"/components/schemas/CaptureState_type_1 must match const 'RECORDED', got '{componentsschemas_capture_state_type_1}'" + ) + return componentsschemas_capture_state_type_1 + except (TypeError, ValueError, AttributeError, KeyError): + pass + try: + if not (type(data) is str and data == "UNBOUND"): + raise TypeError() + componentsschemas_capture_state_type_2 = cast(Literal["UNBOUND"], data) + if componentsschemas_capture_state_type_2 != "UNBOUND": + raise ValueError( + f"/components/schemas/CaptureState_type_2 must match const 'UNBOUND', got '{componentsschemas_capture_state_type_2}'" + ) + return componentsschemas_capture_state_type_2 + except (TypeError, ValueError, AttributeError, KeyError): + pass + try: + if not (type(data) is str and data == "NOT_EXECUTED"): + raise TypeError() + componentsschemas_capture_state_type_3 = cast(Literal["NOT_EXECUTED"], data) + if componentsschemas_capture_state_type_3 != "NOT_EXECUTED": + raise ValueError( + f"/components/schemas/CaptureState_type_3 must match const 'NOT_EXECUTED', got '{componentsschemas_capture_state_type_3}'" + ) + return componentsschemas_capture_state_type_3 + except (TypeError, ValueError, AttributeError, KeyError): + pass + if not (type(data) is str and data == "INCOMPLETE"): + raise TypeError() + componentsschemas_capture_state_type_4 = cast(Literal["INCOMPLETE"], data) + if componentsschemas_capture_state_type_4 != "INCOMPLETE": + raise ValueError( + f"/components/schemas/CaptureState_type_4 must match const 'INCOMPLETE', got '{componentsschemas_capture_state_type_4}'" + ) + return componentsschemas_capture_state_type_4 + + state = _parse_state(d.pop("state")) + + def _parse_detail(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + detail = _parse_detail(d.pop("detail", UNSET)) + + def _parse_occurrence_key(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + occurrence_key = _parse_occurrence_key(d.pop("occurrence_key", UNSET)) + + occurrence_capture = cls( + approval_gaps=approval_gaps, + questions=questions, + state=state, + detail=detail, + occurrence_key=occurrence_key, + ) + + occurrence_capture.additional_properties = d + return occurrence_capture + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/proofline/_generated/models/occurrence_question.py b/proofline/_generated/models/occurrence_question.py new file mode 100644 index 00000000..a6fffe20 --- /dev/null +++ b/proofline/_generated/models/occurrence_question.py @@ -0,0 +1,200 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, Literal, TypeVar, cast +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="OccurrenceQuestion") + + +@_attrs_define +class OccurrenceQuestion: + """One deferred question as the gate presents it. + + Attributes: + assessment_id (UUID): + family_key (str): + family_version (int): + state (Literal['NOT_EXECUTED'] | Literal['PENDING'] | Literal['RECORDED'] | Literal['UNBOUND']): Where one + deferred question stands. + code (None | str | Unset): World's binding or refusal code, or the control plane's own gap. + observed_result (None | str | Unset): World's observed result once it recorded the question. + outcome_id (None | str | Unset): + """ + + assessment_id: UUID + family_key: str + family_version: int + state: Literal["NOT_EXECUTED"] | Literal["PENDING"] | Literal["RECORDED"] | Literal["UNBOUND"] + code: None | str | Unset = UNSET + observed_result: None | str | Unset = UNSET + outcome_id: None | str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + assessment_id = str(self.assessment_id) + + family_key = self.family_key + + family_version = self.family_version + + state: ( + Literal["NOT_EXECUTED"] | Literal["PENDING"] | Literal["RECORDED"] | Literal["UNBOUND"] + ) + state = self.state + + code: None | str | Unset + if isinstance(self.code, Unset): + code = UNSET + else: + code = self.code + + observed_result: None | str | Unset + if isinstance(self.observed_result, Unset): + observed_result = UNSET + else: + observed_result = self.observed_result + + outcome_id: None | str | Unset + if isinstance(self.outcome_id, Unset): + outcome_id = UNSET + else: + outcome_id = self.outcome_id + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "assessment_id": assessment_id, + "family_key": family_key, + "family_version": family_version, + "state": state, + } + ) + if code is not UNSET: + field_dict["code"] = code + if observed_result is not UNSET: + field_dict["observed_result"] = observed_result + if outcome_id is not UNSET: + field_dict["outcome_id"] = outcome_id + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + assessment_id = UUID(d.pop("assessment_id")) + + family_key = d.pop("family_key") + + family_version = d.pop("family_version") + + def _parse_state( + data: object, + ) -> ( + Literal["NOT_EXECUTED"] | Literal["PENDING"] | Literal["RECORDED"] | Literal["UNBOUND"] + ): + try: + if not (type(data) is str and data == "PENDING"): + raise TypeError() + componentsschemas_question_state_type_0 = cast(Literal["PENDING"], data) + if componentsschemas_question_state_type_0 != "PENDING": + raise ValueError( + f"/components/schemas/QuestionState_type_0 must match const 'PENDING', got '{componentsschemas_question_state_type_0}'" + ) + return componentsschemas_question_state_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + try: + if not (type(data) is str and data == "RECORDED"): + raise TypeError() + componentsschemas_question_state_type_1 = cast(Literal["RECORDED"], data) + if componentsschemas_question_state_type_1 != "RECORDED": + raise ValueError( + f"/components/schemas/QuestionState_type_1 must match const 'RECORDED', got '{componentsschemas_question_state_type_1}'" + ) + return componentsschemas_question_state_type_1 + except (TypeError, ValueError, AttributeError, KeyError): + pass + try: + if not (type(data) is str and data == "UNBOUND"): + raise TypeError() + componentsschemas_question_state_type_2 = cast(Literal["UNBOUND"], data) + if componentsschemas_question_state_type_2 != "UNBOUND": + raise ValueError( + f"/components/schemas/QuestionState_type_2 must match const 'UNBOUND', got '{componentsschemas_question_state_type_2}'" + ) + return componentsschemas_question_state_type_2 + except (TypeError, ValueError, AttributeError, KeyError): + pass + if not (type(data) is str and data == "NOT_EXECUTED"): + raise TypeError() + componentsschemas_question_state_type_3 = cast(Literal["NOT_EXECUTED"], data) + if componentsschemas_question_state_type_3 != "NOT_EXECUTED": + raise ValueError( + f"/components/schemas/QuestionState_type_3 must match const 'NOT_EXECUTED', got '{componentsschemas_question_state_type_3}'" + ) + return componentsschemas_question_state_type_3 + + state = _parse_state(d.pop("state")) + + def _parse_code(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + code = _parse_code(d.pop("code", UNSET)) + + def _parse_observed_result(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + observed_result = _parse_observed_result(d.pop("observed_result", UNSET)) + + def _parse_outcome_id(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + outcome_id = _parse_outcome_id(d.pop("outcome_id", UNSET)) + + occurrence_question = cls( + assessment_id=assessment_id, + family_key=family_key, + family_version=family_version, + state=state, + code=code, + observed_result=observed_result, + outcome_id=outcome_id, + ) + + occurrence_question.additional_properties = d + return occurrence_question + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/proofline/_generated/models/review_summary.py b/proofline/_generated/models/review_summary.py index 01860738..1e0d7108 100644 --- a/proofline/_generated/models/review_summary.py +++ b/proofline/_generated/models/review_summary.py @@ -24,7 +24,8 @@ class ReviewSummary: finding_count (int): How many findings this review's assessments recorded, across all of them. id (UUID): The review's identifier. kind (str): `PULL_REQUEST`, `DEPLOYMENT`, `PATCH`, a review of local changes - sent as a patch, or `COMMIT`, a review of pushed commits. + sent as a patch, `COMMIT`, a review of pushed commits, or `FILES`, + complete selected files at one pushed commit. public_key (str): The review's stable public address: `rev_` followed by its identifier without hyphens. publication (str): Whether the review reached the pull request: `PUBLISHED`, `WITHHELD`, `PUBLICATION_REQUESTED` or `PUBLICATION_REFUSED`. A review run from diff --git a/proofline/_generated/models/stop_response.py b/proofline/_generated/models/stop_response.py new file mode 100644 index 00000000..3f4eff51 --- /dev/null +++ b/proofline/_generated/models/stop_response.py @@ -0,0 +1,94 @@ +from __future__ import annotations + +import datetime +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.actor_view import ActorView + + +T = TypeVar("T", bound="StopResponse") + + +@_attrs_define +class StopResponse: + """What stopping a review recorded. + + Attributes: + review_id (UUID): + status (str): Always `STOPPED`: the review's status once the stop is committed. + stopped_at (datetime.datetime): + stopped_by (ActorView): The person behind an action on a review, as the page names them. + """ + + review_id: UUID + status: str + stopped_at: datetime.datetime + stopped_by: ActorView + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + review_id = str(self.review_id) + + status = self.status + + stopped_at = self.stopped_at.isoformat() + + stopped_by = self.stopped_by.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "review_id": review_id, + "status": status, + "stopped_at": stopped_at, + "stopped_by": stopped_by, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.actor_view import ActorView # noqa: PLC0415 + + d = dict(src_dict) + review_id = UUID(d.pop("review_id")) + + status = d.pop("status") + + stopped_at = datetime.datetime.fromisoformat(d.pop("stopped_at")) + + stopped_by = ActorView.from_dict(d.pop("stopped_by")) + + stop_response = cls( + review_id=review_id, + status=status, + stopped_at=stopped_at, + stopped_by=stopped_by, + ) + + stop_response.additional_properties = d + return stop_response + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/proofline/_generated/models/subject_view.py b/proofline/_generated/models/subject_view.py index be6157f2..3e20a373 100644 --- a/proofline/_generated/models/subject_view.py +++ b/proofline/_generated/models/subject_view.py @@ -10,6 +10,7 @@ from ..types import UNSET, Unset if TYPE_CHECKING: + from ..models.file_scope import FileScope from ..models.subject_authorization import SubjectAuthorization @@ -47,6 +48,7 @@ class SubjectView: `GIT_PATCH` subject applies to. Absent for other kinds. deployment_external_id (None | str | Unset): The GitHub deployment identifier a `GITHUB_WORKFLOW_RUN` subject ran for. Absent when the run was not for a deployment. + file_scope (FileScope | None | Unset): Whole-file selection at the pinned revision; absent for comparisons. patch_digest (None | str | Unset): The SHA-256 of a `GIT_PATCH` subject's canonical patch. Absent for other kinds. repository_full_name (None | str | Unset): Absent only when the subject's repository record itself is gone. @@ -67,6 +69,7 @@ class SubjectView: artifact_digest: None | str | Unset = UNSET commit_sha: None | str | Unset = UNSET deployment_external_id: None | str | Unset = UNSET + file_scope: FileScope | None | Unset = UNSET patch_digest: None | str | Unset = UNSET repository_full_name: None | str | Unset = UNSET repository_id: None | Unset | UUID = UNSET @@ -76,6 +79,8 @@ class SubjectView: additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + from ..models.file_scope import FileScope # noqa: PLC0415 + id = str(self.id) kind = self.kind @@ -105,6 +110,14 @@ def to_dict(self) -> dict[str, Any]: else: deployment_external_id = self.deployment_external_id + file_scope: dict[str, Any] | None | Unset + if isinstance(self.file_scope, Unset): + file_scope = UNSET + elif isinstance(self.file_scope, FileScope): + file_scope = self.file_scope.to_dict() + else: + file_scope = self.file_scope + patch_digest: None | str | Unset if isinstance(self.patch_digest, Unset): patch_digest = UNSET @@ -159,6 +172,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["commit_sha"] = commit_sha if deployment_external_id is not UNSET: field_dict["deployment_external_id"] = deployment_external_id + if file_scope is not UNSET: + field_dict["file_scope"] = file_scope if patch_digest is not UNSET: field_dict["patch_digest"] = patch_digest if repository_full_name is not UNSET: @@ -176,6 +191,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.file_scope import FileScope # noqa: PLC0415 from ..models.subject_authorization import SubjectAuthorization # noqa: PLC0415 d = dict(src_dict) @@ -223,6 +239,23 @@ def _parse_deployment_external_id(data: object) -> None | str | Unset: d.pop("deployment_external_id", UNSET) ) + def _parse_file_scope(data: object) -> FileScope | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + file_scope_type_0 = FileScope.from_dict(data) + + return file_scope_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(FileScope | None | Unset, data) + + file_scope = _parse_file_scope(d.pop("file_scope", UNSET)) + def _parse_patch_digest(data: object) -> None | str | Unset: if data is None: return data @@ -293,6 +326,7 @@ def _parse_workflow_run_id(data: object) -> int | None | Unset: artifact_digest=artifact_digest, commit_sha=commit_sha, deployment_external_id=deployment_external_id, + file_scope=file_scope, patch_digest=patch_digest, repository_full_name=repository_full_name, repository_id=repository_id, diff --git a/proofline/client.py b/proofline/client.py index 689fa292..1ff185f4 100644 --- a/proofline/client.py +++ b/proofline/client.py @@ -30,10 +30,12 @@ list_repositories, list_reviews, request_commit_review, + request_file_review, request_patch_review, request_review, rerun_review, start_agent_session, + stop_review, ) from ._generated.client import AuthenticatedClient from ._generated.models.agent_session import AgentSession @@ -44,6 +46,8 @@ from ._generated.models.customer_assessment_detail import CustomerAssessmentDetail from ._generated.models.customer_finding import CustomerFinding from ._generated.models.customer_review_detail import CustomerReviewDetail +from ._generated.models.file_review_request import FileReviewRequest +from ._generated.models.file_review_response import FileReviewResponse from ._generated.models.finding_fix_prompt_type_0 import FindingFixPromptType0 from ._generated.models.finding_fix_prompt_type_1 import FindingFixPromptType1 from ._generated.models.patch_review_request import PatchReviewRequest @@ -59,6 +63,7 @@ from ._generated.models.run_now_request import RunNowRequest from ._generated.models.run_now_response import RunNowResponse from ._generated.models.start_session import StartSession +from ._generated.models.stop_response import StopResponse from ._generated.types import UNSET, Response, Unset from ._transport import ProoflineError from .outcomes import ReviewOutcome, outcome @@ -370,6 +375,20 @@ def request_patch_review( body=body, ) + def request_file_review( + self, organization_id: UUID, repository_id: UUID, *, body: FileReviewRequest + ) -> FileReviewResponse: + return self._call( + request_file_review.sync_detailed, + FileReviewResponse, + organization_id, + repository_id, + body=body, + ) + + def stop_review(self, organization_id: UUID, review_id: UUID) -> StopResponse: + return self._call(stop_review.sync_detailed, StopResponse, organization_id, review_id) + def request_commit_review( self, organization_id: UUID, repository_id: UUID, *, body: CommitReviewRequest ) -> CommitReviewResponse: @@ -661,6 +680,22 @@ async def request_patch_review( body=body, ) + async def request_file_review( + self, organization_id: UUID, repository_id: UUID, *, body: FileReviewRequest + ) -> FileReviewResponse: + return await self._call( + request_file_review.asyncio_detailed, + FileReviewResponse, + organization_id, + repository_id, + body=body, + ) + + async def stop_review(self, organization_id: UUID, review_id: UUID) -> StopResponse: + return await self._call( + stop_review.asyncio_detailed, StopResponse, organization_id, review_id + ) + async def request_commit_review( self, organization_id: UUID, repository_id: UUID, *, body: CommitReviewRequest ) -> CommitReviewResponse: diff --git a/scripts/contracts.py b/scripts/contracts.py index 09f34623..f372bfc0 100644 --- a/scripts/contracts.py +++ b/scripts/contracts.py @@ -24,9 +24,9 @@ def main() -> None: for path in (ROOT / "proofline/_generated/api/default").glob("*.py") if path.name != "__init__.py" } - if declared != generated or len(declared) != 18: + if declared != generated or len(declared) != 20: raise SystemExit( - "The generated JSON operations must match the eighteen public JSON token routes." + "The generated JSON operations must match the twenty public JSON token routes." ) tree = ast.parse((ROOT / "proofline/client.py").read_text()) helpers = {"close", "aclose", "iter_reviews", "wait_for_review"}