Skip to content

feat: first-class handlers, validation, and documentation for deploy verifications and scans - #94

Open
AnkitaPriyadarshini-repos wants to merge 5 commits into
prooflinedev:mainfrom
ankita-proofline-eval:main
Open

AnkitaPriyadarshini-repos wants to merge 5 commits into
prooflinedev:mainfrom
ankita-proofline-eval:main

Conversation

@AnkitaPriyadarshini-repos

Copy link
Copy Markdown

Summary

This pull request introduces first-class client methods, pre-request validation, package exports, and documentation for two public OpenAPI operations that previously fell through to raw generated stubs:

  1. get_commit_deploy_verifications (GET /api/v1/organizations/{org_id}/repositories/{repo_id}/commits/{commit_sha}/deploy-verifications):

    • Added first-class methods on both ProoflineClient and AsyncProoflineClient.
    • Enforces strict commit SHA validation before dispatching requests via _head_commit(commit_sha) (requiring a full 40- or 64-character hexadecimal SHA).
    • Supports both canonical keyword arguments (organization_id, repository_id) and backward-compatible aliases (org_id, repo_id) with conflict detection.
    • Decodes and returns typed CommitDeployVerifications.
  2. request_scan (POST /api/v1/organizations/{org_id}/repositories/{repo_id}/scans):

    • Added first-class methods on both ProoflineClient and AsyncProoflineClient.
    • Supports canonical and alias arguments with conflict detection.
    • Accepts typed ScanRequestBody and decodes ScanResponse.
  3. Models & Code Generation:

    • Added private _resolve_id() helper to handle canonical and alias IDs consistently across client operations.
    • Exported CommitDeployVerifications at the package root.
    • Synchronized proofline/_generated/api/operations.py via scripts/generate.py, cleanly excluding operations with hand-written client adapters.

Problem & Motivation

The public OpenAPI contract defines operations for checking commit deployment verifications and triggering repository scans. In the Python SDK:

  • These operations previously lacked custom facades in proofline/client.py, leaving callers to interact with raw generated methods in Operations / AsyncOperations.
  • Generated methods strictly required parameter names org_id and repo_id, creating an ergonomic discrepancy with the rest of the hand-written client which standardizes on organization_id and repository_id.
  • Unlike wait_for_review, get_commit_deploy_verifications did not perform client-side hexadecimal SHA validation, permitting malformed or non-commit strings to reach the server.
  • CommitDeployVerifications was not exported from the top-level proofline package namespace alongside ScanRequestBody and ScanResponse.

Implementation & Trade-offs

  • _resolve_id() Helper: Resolves either canonical or alias parameters cleanly. If callers pass both with identical values, execution proceeds normally; if conflicting values are provided, a descriptive ValueError is raised immediately.
  • _head_commit() Pre-flight Check: Reuses existing commit validation logic to reject non-hexadecimal, truncated, or branch-name inputs prior to HTTP execution.
  • Single Source of Truth: Custom methods defined on ProoflineClient and AsyncProoflineClient are automatically excluded from proofline/_generated/api/operations.py by scripts/generate.py, preventing duplicate method signatures or maintenance drift.
  • Documentation & Examples: Updated README.md with idiomatic examples for both operations.

Proofline Self-Review Evaluation

Before opening this upstream pull request, these changes were deployed to our fork (ankita-proofline-eval/sdk-python) and evaluated in an end-to-end self-review workflow using the installed ProoflineDev GitHub App (fork PR #2).

Proofline's automated review analyzed the changes and provided 4 actionable findings on our documentation snippets:

  1. deploy.status AttributeError (Serious): Proofline detected that the get_commit_deploy_verifications example referenced deploy.status, whereas the underlying CommitDeployVerification model attribute is deploy.state.
  2. ScanRequestBody TypeError (Serious): Proofline detected that initializing ScanRequestBody(budget_credits=100) omitted the required request_id: UUID parameter.
  3. Commit SHA Validation Scope (Warning): Proofline flagged that client-side hexadecimal SHA validation was over-generalized in prose to repository scans, when it is specifically executed on get_commit_deploy_verifications.
  4. Scan Attribute Scoping (Warning): Proofline recommended separating shared alias handling from parameter-specific validation rules.

All 4 findings were evaluated, verified against the model contracts, and fixed in commit a654dbe before opening this upstream pull request.


Verification

The full test and verification suite passes locally with zero errors:

pytest: 226 passed in 56.72s
ruff: 237 files formatted, 0 issues
mypy: Success: no issues found in 228 source files
scripts/contracts.py: Python operation and outcome-vocabulary contracts passed.
scripts/generate.py --check: Clean (generated code matches specification)

Added 8 new unit tests in tests/test_http.py across sync and async modes testing:

  • Canonical keyword arguments (organization_id, repository_id).
  • Backward-compatible alias arguments (org_id, repo_id).
  • Positional arguments.
  • Conflicting argument detection (ValueError).
  • Missing required argument rejection (TypeError).
  • Full 40/64 hex SHA format enforcement and rejection.
  • Mock HTTP response decoding.

Copilot AI balanced review requested due to automatic review settings November 23, 2026 05:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants