SDKs

View as Markdown

The TypeScript and Python SDKs are generated from the review API's OpenAPI document and add pagination, waiting for a review, retries and typed errors.

The document is version 9.1.0. The API reference lists the methods available in each SDK and shows HTTP examples for operations without a method.

The source is available on GitHub: TypeScript SDK and Python SDK.

Install#

The TypeScript package is @proofline/sdk and needs Node 22 or newer. The Python package needs Python 3.11 or newer. Install TypeScript with npm install @proofline/sdk and Python with python -m pip install proofline-sdk.

Both clients take a token explicitly or read PROOFLINE_TOKEN from the environment. They keep the token in memory, never write it to disk, and redact it from their diagnostic output.

Create a client#

import { ProoflineClient } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});

baseUrl and base_url name the console the client calls. The examples name https://proofline.sh, and an example filled with a test token names the console that issued it. The Python client holds HTTP connections, so use it as a context manager or call close(). AsyncProoflineClient has the same methods as coroutines. The TypeScript client uses the platform's fetch and has nothing to close.

Page through reviews#

iterReviews and iter_reviews follow the cursor from page to page with the same filters. They read at most 100 pages or 10,000 reviews unless you set other bounds. When more reviews match than a bound allows, they raise ProoflineError with the type urn:proofline:sdk:pagination-limit instead of returning part of the list. Narrow the filters or raise the bound. They also refuse a cursor that repeats.

These examples list the reviews that need attention. A repository audit has kind REVISION_SCAN and a recorded audit_mode. An ordinary revision scan has the same kind without a mode.

import { ProoflineClient } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const reviews = client.iterReviews({
  path: { org_id: process.env.PROOFLINE_ORGANIZATION_ID! },
  query: { attention: "needed" },
});
for await (const review of reviews) {
  const kind = review.kind === "REVISION_SCAN" && review.audit_mode
    ? `Repository audit (${review.audit_mode})` : review.kind;
  console.log(review.id, kind, review.status);
}

Filter reviews#

The review list takes filters that narrow it to the reviews you need. listReviews, iterReviews, list_reviews and iter_reviews take the same filters, and a review must match every filter you set.

FilterAccepted values
repositoryA repository ID, as Find a repository ID describes
environmentAn environment ID; lists the reviews that assessed that environment
kindOne review kind: PULL_REQUEST, DEPLOYMENT, PATCH, COMMIT, FILES, MERGE_GROUP or REVISION_SCAN
statusOne review status: PENDING, RUNNING, COMPLETED, INCOMPLETE, FAILED, SUPERSEDED, STOPPED or EXCLUDED
authormine for your own pull requests, or a GitHub user ID
findingspresent for reviews with at least one finding, none for reviews with no finding
auditsonly for repository audits, none to leave them out
attentionneeded, as in Page through reviews
searchA full head commit SHA, which returns the latest run at that commit
queryConditions joined with AND and OR, described below

author=mine needs a person's sign-in or token. An organization token has no GitHub account, so the request is refused. Every other filter works with any token that can read reviews.

Each page of the list carries filters, the values you can filter by: filters.repositories and filters.environments give the id and name of each repository and environment that has a review you can see. Pass an id as repository or environment.

query combines conditions that a single filter cannot express. A condition is a qualifier and a value, such as status:FAILED, which takes the status values above. Join conditions with AND, or a space, and with OR. Group them in parentheses, quote a value that contains spaces, and put - before a condition to exclude the reviews that match it.

These examples list one repository's reviews that failed or ended incomplete:

import { ProoflineClient } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const reviews = client.iterReviews({
  path: { org_id: process.env.PROOFLINE_ORGANIZATION_ID! },
  query: {
    repository: process.env.PROOFLINE_REPOSITORY_ID!,
    query: "status:FAILED OR status:INCOMPLETE",
  },
});
for await (const review of reviews) {
  console.log(review.id, review.status, review.pull_request_number);
}

A filter only narrows the list. An empty list means that no review you can see matched, not that the repository or environment carries no risk.

Read a deployment review#

To list an environment's deployment reviews, set kind to DEPLOYMENT and environment to the environment's ID. Each summary carries public_key, the review's stable public address: rev_ followed by its identifier without hyphens. A deployment review's console address ends with the same key, after /reviews/deployments/.

getDeploymentReview and get_deployment_review read a deployment review by that key. The response has the same shape as a review read by its ID, so Read a review's findings applies to it.

These examples read the newest deployment review of the environment in PROOFLINE_ENVIRONMENT_ID:

import { ProoflineClient } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const org_id = process.env.PROOFLINE_ORGANIZATION_ID!;
const page = await client.listReviews({
  path: { org_id },
  query: { kind: "DEPLOYMENT", environment: process.env.PROOFLINE_ENVIRONMENT_ID!, limit: 1 },
});
const newest = page.items[0];
if (newest !== undefined) {
  const review = await client.getDeploymentReview({ path: { org_id, public_key: newest.public_key } });
  console.log(review.id, review.status);
}

Find a repository ID#

Requests about one repository take its Proofline ID, not its owner/name. listRepositories and list_repositories return the ID and full_name of each repository the token can reach; a token restricted to repositories sees only those. Keep the ID: a repository keeps it when it is renamed on GitHub, and its full_name changes.

The examples on this page read the ID from PROOFLINE_REPOSITORY_ID. These examples print the ID of owner/name:

import { ProoflineClient } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const { repositories } = await client.listRepositories({
  path: { org_id: process.env.PROOFLINE_ORGANIZATION_ID! },
});
const repository = repositories.find((candidate) => candidate.full_name.toLowerCase() === "owner/name");
console.log(repository?.id);

Request a review#

Each request needs a token with the reviews:request scope, and Proofline checks your current GitHub access to the repository on every request. A request is sent once and never retried, because sending it again can start another review.

ReviewTypeScriptPythonWhat it takes
A pull request's current headrequestReviewrequest_reviewThe pull request number. Needs write access.
Local changesrequestPatchReviewrequest_patch_reviewbase_commit_sha, a full 40-character commit GitHub has, and patch, the changes as git diff --no-ext-diff --no-color BASE prints them against that commit. Needs read access.
Pushed commitsrequestCommitReviewrequest_commit_reviewbase_commit_sha and head_commit_sha, both full 40-character commits GitHub has. The base must be an ancestor of the head. Needs read access.
Named filesrequestFileReviewrequest_file_reviewcommit_sha, one full 40-character pushed commit, and paths, one to twenty repository-relative paths of regular files. Needs read access.

A patch may hold text changes to regular and executable files, including renames and mode changes, and is refused when it holds binary content, symbolic links or submodules, is over 5 MiB or touches more than 3,000 files. Reviews of local changes, commits and named files are never posted to GitHub, and commit and named-file reviews check no environment.

Each response has the review's review_id and existing. When existing is true, the same pull request head, patch on the same base, commits or file selection already had a review, and the response returns that review instead of starting another.

These examples request a review of pull request 42, then a review of the changes in change.patch, which git diff --no-ext-diff --no-color wrote against the commit in BASE_COMMIT_SHA. PROOFLINE_REPOSITORY_ID holds the ID from Find a repository ID.

import { readFileSync } from "node:fs";
import { ProoflineClient, ProoflineError } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const path = {
  org_id: process.env.PROOFLINE_ORGANIZATION_ID!,
  repo_id: process.env.PROOFLINE_REPOSITORY_ID!,
};

try {
  const pullRequest = await client.requestReview({ path: { ...path, number: 42 } });
  console.log(pullRequest.review_id, pullRequest.existing);
  const local = await client.requestPatchReview(
    { path },
    { base_commit_sha: process.env.BASE_COMMIT_SHA!, patch: readFileSync("change.patch", "utf8") },
  );
  console.log(local.review_id, local.existing);
} catch (error) {
  if (!(error instanceof ProoflineError) || error.refusal === undefined) throw error;
  console.error(error.refusal.reason, error.repositoryName);
}

Request a full review of the current head#

By default, a pull request review request returns the review that already owns the pull request's live head, even a finished one, with existing true, and starts a review only when none does. To review the whole change again at the current head after an earlier review finished, send the request with the mode FULL.

A full request returns a review of the live head that is still pending or running, with existing true and its review_id, and starts nothing; repeated full requests return that same review. Otherwise it starts a new review and returns its new review_id and run_number, with existing false. The new review reads the pull request's live head and the base branch's current commit, reviews the whole change instead of only what changed since an earlier review, and does not wait for pushes to settle. It is withheld: Proofline posts nothing to GitHub, and publishing it takes an action in the console. Earlier reviews stay unchanged.

A rerun differs: it reviews again the code that an earlier review recorded, even after the pull request has moved on. These examples request a full review of pull request 42:

import { ProoflineClient } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const full = await client.requestReview(
  {
    path: {
      org_id: process.env.PROOFLINE_ORGANIZATION_ID!,
      repo_id: process.env.PROOFLINE_REPOSITORY_ID!,
      number: 42,
    },
  },
  { mode: "FULL" },
);
console.log(full.review_id, full.run_number, full.existing);

Read a refusal#

When a review request creates nothing because of a repository's setup, the error carries refusal. Its reason names the setting to change, such as NO_LINKED_ENVIRONMENT or ENVIRONMENT_NOT_READY, and the error names the repository: repositoryName in TypeScript, repository_name in Python. Any other refused request has no refusal. That includes the 402 a review request returns when credits cannot pay for the review, which is a plain problem with its status, type and detail.

Wait for a review#

waitForReview and wait_for_review poll a review until it finishes or the deadline passes. They wait 5 seconds first, then double the wait up to 60 seconds. The result has a status, the review's console address and what each assessment could not establish.

StatusMeaning
COMPLETEDThe review completed and lists every assessment it recorded. Each environment assessment finished with its checks recorded and settled, or, in a review with no environment assessment, the code assessment finished.
INCOMPLETEThe review ended, but its result has a gap: an assessment with an unknown state, an unresolved check or an evidence gap, missing assessment history, or a code-only review without a usable finished code assessment.
FAILEDThe review recorded a failure.
STOPPEDThe review stopped before it finished, or a newer review superseded it.
TIMED_OUTThe deadline passed before the review recorded an end. The result keeps the latest review it read.
import { ProoflineClient, ProoflineError } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const orgId = process.env.PROOFLINE_ORGANIZATION_ID!;

try {
  const page = await client.listReviews({ path: { org_id: orgId }, query: { limit: 1 } });
  const latest = page.items[0];
  if (latest !== undefined) {
    const result = await client.waitForReview(orgId, latest.id, { timeoutMs: 20 * 60_000 });
    const detail = result.review;
    const destination = detail?.kind === "REVISION_SCAN" && detail.audit_mode
      ? `Findings in audit report (${detail.audit_mode})` : "Review";
    console.log(result.status, detail?.status, destination, result.reviewUrl);
    for (const gap of result.gaps) console.log(gap.assessmentId, gap.reasonCodes);
  }
} catch (error) {
  if (error instanceof ProoflineError) console.error(error.status, error.type);
  else throw error;
}

Read the result#

For a repository audit, the review detail and the list entry both carry the recorded mode, CODE_ONLY or INFRASTRUCTURE_AWARE. Even a completed audit can show finding_count: 0 and no open_items because those fields describe review assessments. Label the review URL Findings in audit report and include the mode. Keep both statuses and any gaps the wait reports. For example, a recorded COMPLETED audit with missing assessment history returns INCOMPLETE and ASSESSMENT_HISTORY_UNAVAILABLE from the SDK. An authorized reader opens that review and follows its report to the audit's findings and coverage. Read an audit report

TIMED_OUT is the only status the client sets without a recorded end. The review was still going when the deadline passed, and review holds the last review the client read, with its own status, such as RUNNING. It is empty when no read succeeded. Every other status follows the status the review recorded. A superseded review returns STOPPED, and its review.status stays SUPERSEDED, so you can tell it from a stopped one and look for the newer review.

Each gap names an assessment and its reason codes. A gap that belongs to no assessment has an empty assessmentId in TypeScript and an assessment_id of None in Python. The review's assessment_count is the number of environment assessments it recorded, and 0 makes it a code-only review:

ReviewStatusGaps
Environment assessments finished, code assessment partialCOMPLETEDNone. The code assessment doesn't decide the status when environment assessments exist, so read review.code_assessment for its state, as Read a review's findings shows.
Code-only, with a usable finished code assessmentCOMPLETEDNone
Code-only, with no usable code assessmentINCOMPLETECODE_ASSESSMENT_UNAVAILABLE, in a gap with no assessment
Code-only, with a code assessment that is unfinished or records a reason codeINCOMPLETEThe code assessment's reason codes and incompleteness kind, or CODE_ASSESSMENT_STATE_UNAVAILABLE when it records neither
assessment_count differs from the assessments listedINCOMPLETEASSESSMENT_HISTORY_UNAVAILABLE, in a gap with no assessment, beside any gap of a listed assessment

A code assessment never stands in for a missing environment assessment. A review that lists fewer environment assessments than it recorded is INCOMPLETE, even when the review recorded COMPLETED and its code assessment finished.

COMPLETED and an empty list of findings say the review ran and recorded no finding. Neither approves a deployment: read the findings and their evidence before you decide to deploy.

Hold a wait to a commit#

A pull request review request names no commit: the review belongs to the head the pull request has when the request arrives. To accept a result only for the commit you hold, pass that commit to the Python client's wait_for_review as head_commit_sha, a full SHA of 40 or 64 hexadecimal characters. As above, PROOFLINE_REPOSITORY_ID holds the repository's ID:

import os
from uuid import UUID
from proofline import ProoflineClient

with ProoflineClient(os.environ["PROOFLINE_TOKEN"], base_url="https://proofline.sh") as client:
    organization_id = UUID(os.environ["PROOFLINE_ORGANIZATION_ID"])
    repository_id = UUID(os.environ["PROOFLINE_REPOSITORY_ID"])
    requested = client.request_review(organization_id, repository_id, 42)
    outcome = client.wait_for_review(
        organization_id,
        requested.review_id,
        head_commit_sha=os.environ["PULL_REQUEST_HEAD_SHA"],
    )
    if outcome.status != "COMPLETED":
        print(outcome.status, outcome.reason)

A review pinned to another head ends the wait as INCOMPLETE, whatever the review's own status, and its last gap has the reason code HEAD_COMMIT_MISMATCH. A finished review that names no head has the reason code HEAD_COMMIT_UNAVAILABLE instead and is not COMPLETED either. The TypeScript client's waitForReview takes no commit. A review of local changes has a derived head that matches no commit. In a GitHub Actions pull_request job, GITHUB_SHA is the merge commit, so pass the pull request's head instead.

Read a pull request's runs#

A pull request can have several recorded runs, and the review list in Page through reviews holds only the latest one. listPullRequestReviews and list_pull_request_reviews list every run of one pull request, newest first, and getPullRequestReview and get_pull_request_review read one run by its number. They make the reads that proofline history and proofline run make from a terminal, which List reviews and runs describes. The API reference documents listing the runs and reading one run.

A run's number is its place among the pull request's runs, counted from 1. A new run takes the next number, and earlier runs keep theirs. Each run is also a review with its own ID: the id both reads return is the review ID that Wait for a review and Read a review's findings take. The number names a run only within its pull request, so pass the ID to the other methods on this page.

Both routes take the repository as {repository}: its name without the owner, such as web for acme/web, or a name it had before a rename. They do not take the Proofline ID that a review request takes, and a value that contains / returns 400. Both need a token with reviews:read. The list returns one page with truncated and next_cursor, like the review list; pass next_cursor as cursor for the next page.

A token reaches only its organization's repositories, and a token restricted to repositories reaches only those. For a repository outside that reach, the list is an empty page, the same answer as a pull request with no recorded run, and reading a run returns 404, the same as a run that does not exist. An empty list therefore does not show that Proofline never reviewed the pull request.

These examples list the runs of pull request 42 in acme/web, then read its run 2:

import { ProoflineClient } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const path = {
  org_id: process.env.PROOFLINE_ORGANIZATION_ID!,
  repository: "web",
  pull_request_number: 42,
};

const runs = await client.listPullRequestReviews({ path });
for (const run of runs.items) {
  console.log(run.run_number, run.id, run.status, run.head_commit_sha);
}
const run = await client.getPullRequestReview({ path: { ...path, run_number: 2 } });
console.log(run.run_number, run.id, run.status, run.head_commit_sha);

Read a review's findings#

For a repository audit, follow the report link described in Read the result. For other reviews, findings come from two kinds of assessment. Its code assessment reads only the pinned code and arrives with the review in code_assessment, which is null when the review recorded none. Its environment assessments, one per environment it checked, are listed in assessments; read each with getAssessment or get_assessment for its findings. Both list findings SERIOUS first, with each finding's claim, impact and cited evidence. Reading a review, its code findings included, needs reviews:read, and reading an environment assessment needs findings:read.

An assessment's status says how far its evidence went. A COMPLETED assessment finished and recorded its checks. An INCOMPLETE assessment still lists the findings it supported, and its incompleteness_kind and reason_codes name what it could not check; what it could not check stays unknown. An assessment with no findings means that no supported finding emerged from the evidence available to it.

Code findings rest on the code alone. They never show that an environment was checked: a review with no environment assessments checked none. When the review's protected evidence is missing or has expired, the API withholds every code finding's text and puts [withheld: environment value] in its risk domain. Treat such a code assessment as unavailable, like a missing one, and never as a list of findings. waitForReview and wait_for_review likewise report a code-only review whose code assessment is withheld as CODE_ASSESSMENT_UNAVAILABLE.

These examples read the review in REVIEW_ID, then print its code assessment's status, gaps and findings, labelled code-only, and each environment assessment's status, gaps and findings:

import { ProoflineClient } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const orgId = process.env.PROOFLINE_ORGANIZATION_ID!;
const reviewId = process.env.REVIEW_ID!;

const review = await client.getReview({ path: { org_id: orgId, review_id: reviewId } });
console.log(review.status, review.head_commit_sha);

const code = review.code_assessment;
if (!code) {
  console.log("code-only: no code assessment");
} else if (code.findings.some((finding) => finding.risk_domain === "[withheld: environment value]")) {
  console.log("code-only: withheld");
} else {
  console.log("code-only", code.status, code.incompleteness_kind ?? null, code.reason_codes ?? []);
  if (code.findings.length === 0) console.log("code-only: no supported finding");
  for (const finding of code.findings) {
    console.log("code-only", finding.severity, finding.claim);
  }
}

for (const summary of review.assessments) {
  const assessment = await client.getAssessment({
    path: { org_id: orgId, review_id: reviewId, assessment_id: summary.id },
  });
  console.log(assessment.environment_display_name, assessment.status, assessment.reason_codes ?? []);
  for (const finding of assessment.findings) {
    console.log(finding.severity, finding.claim);
  }
}

Read one finding#

Each finding a review lists, in its code_assessment or in an environment assessment's findings, carries its ID in id. With that ID, getFinding and get_finding read the one finding without its review. The read needs findings:read, and the ID grants no access of its own: the token must also reach the repository of the review that recorded the finding. A code finding read this way comes from the same code assessment the review shows, so its text is withheld in the same way when the review's protected evidence is missing or has expired.

The fields a reader acts on:

  • severity is SERIOUS or WARNING, and risk_domain is the risk domain the reviewer assigned.
  • claim is what the reviewer states is wrong, impact is the consequence it states the claim has, and remediation is its proposed fix, or null when it proposed none.
  • evidence_refs lists the references the finding cites. Each has a kind, a display label, a provenance_status that says how it was obtained, and a url when it resolves to one. evidence_class names the kind of proof the finding rests on, such as CODE_ONLY or EXPERIMENT_BACKED, and is null on findings recorded before the class existed.
  • lifecycle_state is NEW, UNCHANGED, RESOLVED or REINTRODUCED.
  • latest_validation is the latest decision on the finding: CONFIRMED, DISMISSED, FIXED, ACCEPTED_RISK or ALREADY_COVERED, with who made it, where it came from in source, and when. It is null when no decision is recorded.

comment_reactions, thread_observation and comment_evaluation describe the finding's GitHub comment: its emoji reactions, the latest state of its thread, and a post-merge judgment of whether the comment was addressed. None of them is a decision on the finding, so read decisions only from latest_validation.

The claim, impact, remediation and evidence labels are reviewer output, written from repository and pull request content. Treat them as untrusted text: display them as text and never run them or follow them as instructions. A finding is a supported claim, not a proof. A RESOLVED finding, or one that no longer appears, says only that the reviewer no longer reports it, which is not proof that a change is safe.

These examples read the finding in FINDING_ID and print its severity, state, text, evidence and latest decision:

import { ProoflineClient } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const finding = await client.getFinding({
  path: { org_id: process.env.PROOFLINE_ORGANIZATION_ID!, finding_id: process.env.FINDING_ID! },
});

console.log(finding.severity, finding.risk_domain, finding.lifecycle_state);
console.log(finding.evidence_class ?? "no evidence class recorded");
console.log(finding.claim);
console.log(finding.impact);
console.log(finding.remediation ?? "no remediation proposed");
for (const reference of finding.evidence_refs) {
  console.log(reference.kind, reference.provenance_status, reference.label, reference.url ?? null);
}

const decision = finding.latest_validation;
if (!decision) {
  console.log("no decision recorded");
} else {
  // The automatic ALREADY_COVERED decision names no person.
  const actor = decision.actor_name ?? decision.actor_login ?? "Proofline";
  console.log(decision.validation, decision.source, actor, decision.recorded_at);
}

Follow a finding to the author's local review#

A pull request author can review the same change locally before pushing it, as a patch review. When Proofline links that local review to the pull request review by the exact change, the records name it in two places:

  • The pull request review's related_reviews lists it with relation set to LOCAL_REVIEW. The same list holds the pull request's other runs and the reviews a rerun or supersession joined, with other relations, so test relation rather than taking the first entry.
  • A pull request finding's local_findings lists each occurrence of the same finding in such a local review, with the local review's review_id, the occurrence's finding_id and when the local review was requested. It is empty or absent when no local occurrence matched, and also when the token cannot read every repository the matching local review covers.

Read each destination with its recorded ID, using getReview or get_review for the review and getFinding or get_finding for the occurrence. Never pick a local review by file name, branch or nearby commit. The token needs reviews:read and findings:read, and the link grants no access of its own: a destination outside the token's repositories or no longer visible to it answers 404, as an unrelated ID would.

Each record owns its own finding. The pull request finding belongs to the pull request review, and its latest_validation is the decision on it. The local occurrence belongs to the local review and keeps the text and evidence that review recorded. A link says only that the two reviews covered exactly the same change and that Proofline matched the two findings. It carries no verdict and copies no decision. An empty list means only that this token sees no linked local occurrence: none matched, or the match sits in a local review outside the token's repositories.

These examples read the pull request review in REVIEW_ID and its finding in FINDING_ID, list the local reviews linked to the review, and read each local occurrence of the finding:

import { ProoflineClient, ProoflineError } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const orgId = process.env.PROOFLINE_ORGANIZATION_ID!;

// A linked record this token cannot see answers 404; any other failure stops.
function notVisible(error: unknown): null {
  if (error instanceof ProoflineError && error.status === 404) return null;
  throw error;
}

const review = await client.getReview({ path: { org_id: orgId, review_id: process.env.REVIEW_ID! } });
const localReviews = review.related_reviews.filter((related) => related.relation === "LOCAL_REVIEW");
if (localReviews.length === 0) console.log("no linked local review is visible to this token");
for (const related of localReviews) {
  console.log("local review", related.review_id, related.status, related.created_at);
}

const finding = await client.getFinding({ path: { org_id: orgId, finding_id: process.env.FINDING_ID! } });
const matches = finding.local_findings ?? [];
if (matches.length === 0) console.log("no local occurrence of this finding is visible to this token");
for (const match of matches) {
  const local = await client
    .getFinding({ path: { org_id: orgId, finding_id: match.finding_id } })
    .catch(notVisible);
  const localReview = await client
    .getReview({ path: { org_id: orgId, review_id: match.review_id } })
    .catch(notVisible);
  if (!local || !localReview) {
    console.log("local occurrence", match.finding_id, "is not visible to this token");
    continue;
  }
  // The local occurrence's own text; the pull request finding's decision stays on that finding.
  console.log(localReview.status, match.created_at, local.severity, local.claim);
}

In the console, the pull request finding links to the same occurrences, as Trace a pull request finding to an earlier local review shows.

Read the merge gate decision#

On a repository with the merge gate on, a pull request review carries the gate's decision in merge_gate. A release script can read that decision instead of inferring one from the findings: status is the gate's state, decision is ALLOW or BLOCK once recorded, and reason_code names why. Set up a merge gate explains the gate and its GitHub Check, and the API reference documents the review operation. The policy is changed in the console; an API token cannot change it.

The decision belongs to the review's repository and its exact head SHA, which head_sha names, so compare it with the commit you are about to release. Once recorded, the decision is immutable. A rerun of a review at the same head reads the original decision and cannot replace it.

merge_gate is null when no gate was captured. A review someone runs from Proofline, for example, stays withheld until someone publishes it and captures no gate before then. Treat a null gate, or one whose decision is still null, as not passed. An ALLOW decision means the captured policy allowed that head, not that deploying it carries no risk.

Reading the review needs reviews:read. A token restricted to repositories also needs reviews:read for every code subject of the review that captured the gate, not only for the review you request.

These examples read the review in REVIEW_ID and print its gate's head, status, decision and reason:

import { ProoflineClient } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const review = await client.getReview({
  path: { org_id: process.env.PROOFLINE_ORGANIZATION_ID!, review_id: process.env.REVIEW_ID! },
});

const gate = review.merge_gate;
if (!gate) {
  console.log("no merge gate captured: not passed");
} else {
  console.log(gate.head_sha, gate.status, gate.decision ?? "no decision yet", gate.reason_code ?? null);
}

Rerun or stop a review#

rerunReview and rerun_review review the code the original review recorded again, and create a new review beside it; the original review is never changed. The new review does not move to the pull request's current head: a pull request review request reads the live head, so use requestReview or request_review for that. A rerun needs a token with the reviews:rerun scope and your live GitHub write access to the repository, and an organization token with that scope must name its repositories. Only a pull request review can be rerun, as Check that a review can be rerun describes. A rerun is sent once, because sending it again can start another review.

A rerun of a published review is published to GitHub too, unless an organization token requested it: an organization token's rerun is always withheld. A rerun of a withheld review stays withheld, and publishing a withheld review takes an action in the console.

stopReview and stop_review stop a review of local changes, pushed commits or named files that you requested and that is still pending or running. A stop needs a personal or CLI device token with the reviews:request scope and your live GitHub read access to the repository. Organization, CI job and MCP OAuth tokens cannot stop reviews, and no token stops a pull request review. The stopped review keeps the findings it had and publishes nothing. Stopping it again returns 400 with its current status and changes nothing, and requesting the same changes again returns the stopped review.

These examples rerun the review in REVIEW_ID, then request a review of the changes in change.patch against the commit in BASE_COMMIT_SHA and stop it. The command-line client does the same with proofline rerun and proofline stop, and the API reference describes Rerun a review and Stop your local review.

import { readFileSync } from "node:fs";
import { ProoflineClient, ProoflineError } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const orgId = process.env.PROOFLINE_ORGANIZATION_ID!;

try {
  const rerun = await client.rerunReview({ path: { org_id: orgId, review_id: process.env.REVIEW_ID! } });
  console.log(rerun.review_id, rerun.run_number);
  const local = await client.requestPatchReview(
    { path: { org_id: orgId, repo_id: process.env.PROOFLINE_REPOSITORY_ID! } },
    { base_commit_sha: process.env.BASE_COMMIT_SHA!, patch: readFileSync("change.patch", "utf8") },
  );
  const stopped = await client.stopReview({ path: { org_id: orgId, review_id: local.review_id } });
  console.log(stopped.status, stopped.stopped_at);
} catch (error) {
  if (error instanceof ProoflineError) console.error(error.status, error.type, error.detail);
  else throw error;
}

Check that a review can be rerun#

Read the original review before you rerun it; the read changes nothing. Only a review whose kind is PULL_REQUEST can be rerun. A rerun reviews the original's head_commit_sha against its base_commit_sha again, even after the pull request has moved on. A single-review read sets current_head_commit_sha to the pull request's head as Proofline last saw it. When that differs from head_commit_sha and you want the code the pull request holds now, request a review of the live head with requestReview or request_review, as Request a review describes.

A refused rerun creates nothing, and its status says why:

  • 400, with the title invalid request: the review cannot be rerun. Its detail names the kind, such as a commit, merge-group or deployment review, a repository audit or an on-demand scan, or says that the review's repository is no longer connected. The same rerun is refused again, so request a new review of that subject instead.
  • 403: the authority is missing. The token lacks reviews:rerun, or GitHub does not show you write access to the repository now. A token with that scope, held by a person with write access, can send it.
  • 404: the organization has no such review, or the token's repositories leave it out.
  • 402: credits cannot pay for the rerun, as Read a refusal describes.

Recover a rerun whose response was lost#

If rerunReview or rerun_review raises ProoflineError with status 0, which the SDKs use when no response arrived, or with a 5xx status, Proofline may have recorded the rerun without its answer reaching you. Sending it again can start a second review. Look for the run with reads first.

Before you send the rerun, list the pull request's runs and note the highest run_number. A rerun takes the next number, so a run it creates is numbered above every run you listed. After a lost response, list the runs again and keep each run that matches all of these:

  • Its run_number is above the one you noted.
  • Its trigger_origin is RERUN.
  • It reviewed the original's head_commit_sha and, in its own read, the original's base_commit_sha, because a rerun keeps the original's code.
  • When its requested_by names a person, that person is you. Compare github_user_id, not the login. gh api user --jq .id prints your GitHub user ID.

One match is your rerun; read it as any other review. No match means Proofline had not recorded a rerun when you read, so read again after a minute before you decide to send another. Several matches mean you cannot tell which run is yours, for example because someone else reran the same review with a token that names no person. Report their run numbers and leave the next rerun to a deliberate choice.

The recovery reads publish nothing, and the run they find keeps the publication the rerun gave it. A rerun of a withheld review, and any rerun an organization token requested, stays withheld until someone publishes it in the console. Another rerun does not publish it.

These examples check that the review in REVIEW_ID can be rerun, note the pull request's runs, send the rerun once and, if its response is lost, look for the run it created with reads only. GITHUB_USER_ID holds your GitHub user ID:

import { ProoflineClient, ProoflineError } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const orgId = process.env.PROOFLINE_ORGANIZATION_ID!;
const githubUserId = Number(process.env.GITHUB_USER_ID);

const original = await client.getReview({ path: { org_id: orgId, review_id: process.env.REVIEW_ID! } });
if (original.kind !== "PULL_REQUEST" || !original.repository_name || !original.pull_request_number) {
  throw new Error(`a ${original.kind} review is not rerun; request a new review instead`);
}
if (original.current_head_commit_sha && original.current_head_commit_sha !== original.head_commit_sha) {
  console.log("the pull request has moved on; requestReview reviews its live head");
}
const path = {
  org_id: orgId,
  repository: original.repository_name,
  pull_request_number: original.pull_request_number,
};
const before = await client.listPullRequestReviews({ path });
const lastRun = Math.max(0, ...before.items.map((run) => run.run_number ?? 0));

try {
  const rerun = await client.rerunReview({ path: { org_id: orgId, review_id: original.id } });
  console.log("rerun", rerun.review_id, rerun.run_number);
} catch (error) {
  // A refusal created nothing; only a lost response needs the search below.
  if (!(error instanceof ProoflineError) || (error.status !== 0 && error.status < 500)) throw error;
  const after = await client.listPullRequestReviews({ path });
  const matches = [];
  for (const run of after.items) {
    if (!run.run_number || run.run_number <= lastRun || run.trigger_origin !== "RERUN") continue;
    if (run.head_commit_sha !== original.head_commit_sha) continue;
    const detail = await client.getPullRequestReview({ path: { ...path, run_number: run.run_number } });
    if (detail.base_commit_sha !== original.base_commit_sha) continue;
    if (detail.requested_by && detail.requested_by.github_user_id !== githubUserId) continue;
    matches.push(detail);
  }
  if (matches.length === 1) {
    console.log("recovered", matches[0].id, matches[0].run_number, matches[0].publication);
  } else if (matches.length === 0) {
    console.log("no rerun recorded yet; read the runs again before sending another");
  } else {
    console.log("ambiguous: runs", matches.map((run) => run.run_number).join(", "));
  }
}

Read a wiki page at a listed build#

client.knowledge reads a repository's codebase wiki through the hosted tools that proofline wiki calls. listWikiPages and list_wiki_pages list the pages of one build, and getWikiPage and get_wiki_page read one page by its key. Both need a personal token with reviews:read and knowledge:read, as Use a personal token describes. The token that Generate a token creates on this page lacks knowledge:read, so these calls refuse it. The token selects the organization, so the calls need no organization ID.

Without commit, each call reads the newest completed build at the moment it arrives. A build that completes between the list and the read moves the read to another commit: the page can have another body, cite lines at another commit, or be missing from the new build. Take build.commit_sha from the list result and pass it as commit to the read. The read then answers from the newest completed build at that commit and returns that build with the page. Compare the returned build.commit_sha with the commit you sent before you present a citation, because each citation's path, start_line, end_line and blob_sha locate lines in that commit only.

The commit pins the code, not the build. If the wiki was built again at the same commit, for example by a newer generator, the read returns that later build, with another id and generator_version. Its citations still resolve at the commit.

These examples list the wiki of acme/web, select the page for src/auth, read it at the listed build's commit and print its verification, body and citations:

import { ProoflineClient, type KnowledgeResult } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const repository = "acme/web";

// Repository text arrives wrapped; keep the wrapper until you display it.
type Untrusted = { untrusted_text: string };
type Build = {
  id: string;
  commit_sha: string;
  generator_version: string;
  finished_at: string | null;
};
type Verification = "VERIFIED" | "UNVERIFIED";
type Pages = {
  build: Build;
  pages: { page_key: string; module_path: Untrusted; verification: Verification }[];
};
type Page = {
  build: Build;
  page_key: string;
  module_path: Untrusted;
  verification: Verification;
  body_markdown: Untrusted | null;
  citations: { path: Untrusted; start_line: number; end_line: number; blob_sha: string }[];
};
type Reply =
  | { ok: true; data: unknown }
  | { ok: false; error: { code: string; message: string; retryable: boolean } };

// A refused call sets isError, and its reply holds the error.
function data(result: KnowledgeResult): unknown {
  const reply = result.structuredContent as Reply;
  if (!reply.ok) throw new Error(`${reply.error.code}: ${reply.error.message}`);
  return reply.data;
}

const listed = data(await client.knowledge.listWikiPages({ repository })) as Pages;
const commit = listed.build.commit_sha;
const selected = listed.pages.find((page) => page.module_path.untrusted_text === "src/auth");
if (!selected) throw new Error(`no page for src/auth at ${commit}`);

const page = data(
  await client.knowledge.getWikiPage({ repository, page_key: selected.page_key, commit }),
) as Page;
if (page.build.commit_sha !== commit) {
  throw new Error(`asked for ${commit}, read ${page.build.commit_sha}`);
}
console.log(page.page_key, page.verification, commit);
console.log(page.body_markdown === null ? "body no longer retained" : JSON.stringify(page.body_markdown));
for (const citation of page.citations) {
  console.log(JSON.stringify(citation.path), citation.blob_sha, citation.start_line, citation.end_line);
}

Each result's structuredContent holds the tool's reply. A successful call holds "ok": true and its data. The list's data has the build, with its id, commit_sha, generator_version and finished_at, and the pages, each with a page_key, a module_path and a verification. The page's data has the same build and page fields, its body_markdown and its citations. A refused call sets isError, and its reply holds "ok": false and an error with a code, a message and retryable. The SDKs return a refusal without retrying it; a protocol or HTTP failure raises ProoflineError.

Handle a missing page or a refused read#

The examples stop on any refusal and print its code and message. Each code calls for a different next step:

  • RESOURCE_NOT_FOUND from the list means the repository has no completed wiki build, or the token cannot reach the repository. From the pinned read, it means the build at that commit holds no page with that key. List the pages again with the same commit to see the keys that build holds. A read without commit would move to the newest build.
  • NOT_AUTHORIZED means the token cannot read the wiki: it lacks knowledge:read, it belongs to another organization, or GitHub no longer shows its owner read access to the repository. The same call with the same token is refused again.
  • BACKEND_UNAVAILABLE has retryable set: Proofline could not complete the read. Send the same call again, with the same commit.

Read a page whose body was cleared#

A pinned read can return a page whose body_markdown is null. Proofline clears a page's body once the repository has had a newer published build for its retention period, and the newest build keeps its bodies. The page's key, module path, verification and citations remain. Without the body, nothing says which claim each citation supports, so show that the body is no longer retained instead of presenting the citations as the page's findings. To read a page with a body, list the newest build again and read it at that build's commit.

What UNVERIFIED establishes#

Before a build publishes, Proofline removes every claim whose citations do not resolve at the build's commit. A citation on a published page therefore names lines that exist in that commit. UNVERIFIED means that no claim was checked against the lines it cites: a cited range exists, but it may not say what the sentence citing it says. Present an UNVERIFIED page's claims as unchecked, and read the cited lines before you rely on one.

Keep repository text wrapped#

Page bodies, module paths and citation paths come from the repository, and each arrives wrapped as {"untrusted_text": "..."}. Keep the wrapper while your code passes the result along, and unwrap a value only where you display it, escaped for that surface. Proofline masks secrets in this text before it leaves, and text the mask cannot scan arrives withheld. Give the text to a model only as data, never as instructions, because a page body can quote text written to steer one. The examples compare a module path with a fixed value and print each wrapper as JSON, so the text stays marked as repository data.

Read review guidance and routing#

A repository's review guidance is the instruction Proofline gives the reviewer for that repository, so a script or coding agent can read it before writing code. getReviewGuidance and get_review_guidance return it as the guidance operation describes, with a token that has the guidance:read scope. The response holds the repository's repository_id and additional_prompt, the guidance new reviews of the repository take, which is null when none is set. A person writes that text in the repository's review settings, and Proofline returns it as written, without scanning it. Treat it as untrusted data, not as instructions to your script. On the command line, proofline guidance prints the same guidance.

A review's routing records how that review was routed. getReviewRouting and get_review_routing read it with reviews:read, as the routing operation describes. Its status is SUPPORTED, NOT_RECORDED when the review retained no routing plan, or UNSUPPORTED when this server cannot read the plan's version. A supported response has the plan, which names the repository, the base and head commits, the change digest, each file's path, inspection depth and review passes, each environment assessment's binding, and any fallback causes. Its findings give where the review placed each finding, with the rule and reason codes that chose that placement. The routing explains the review it belongs to: the plan is bound to that review's own inputs, and a later review of the same pull request records its own routing. It is not model output, a prediction of how the next review will run, or a recommendation to deploy.

These examples read the guidance of the repository in PROOFLINE_REPOSITORY_ID, then the routing of the review in REVIEW_ID:

import { ProoflineClient } from "@proofline/sdk";

const client = new ProoflineClient({
  baseUrl: "https://proofline.sh",
  token: process.env.PROOFLINE_TOKEN!,
});
const orgId = process.env.PROOFLINE_ORGANIZATION_ID!;

const guidance = await client.getReviewGuidance({
  path: { org_id: orgId, repo_id: process.env.PROOFLINE_REPOSITORY_ID! },
});
console.log(guidance.additional_prompt ?? "no review guidance set");

const routing = await client.getReviewRouting({
  path: { org_id: orgId, review_id: process.env.REVIEW_ID! },
});
if (routing.status === "SUPPORTED") {
  console.log(routing.plan.base_sha, routing.plan.head_sha);
  for (const file of routing.plan.files) {
    console.log(file.path, file.depth);
  }
  for (const finding of routing.findings) {
    console.log(finding.finding_id, finding.placement, finding.rule, finding.reason_codes);
  }
} else {
  console.log(routing.status);
}

Find your pipeline's deploy#

A commit can be deployed more than once, so the first deploy listed for it may be an older run's. To read the checks of the deploy your pipeline made, read the commit's deploys and select yours by its identity. proofline ci deploy makes this read and selection for you; this section shows them over HTTP.

The read needs a token with reviews:read for the repository, such as the CI_JOB token a GitHub Actions job exchanges, or a personal, organization or CLI token whose repository restriction includes it. Set DEPLOYED_SHA to the full 40-character lowercase SHA of the commit the workflow deployed, not a branch or an abbreviated SHA, and PROOFLINE_REPOSITORY_ID to the repository's Proofline ID. The API reference documents the operation and its response schema.

repo="https://proofline.sh/api/v1/organizations/$PROOFLINE_ORGANIZATION_ID/repositories/$PROOFLINE_REPOSITORY_ID"
curl --fail-with-body -sS -H "Authorization: Bearer $PROOFLINE_TOKEN" \
  "$repo/commits/$DEPLOYED_SHA/deploy-verifications" -o deploys.json || exit 1

In this response, Actions run 801 deployed the commit to the production GitHub Environment with the task deploy:web and regressed. Run 805 deployed the same commit again with the same environment and task, and its deploy job failed once and succeeded on attempt 2. The list puts the earliest landing first, so taking its first deploy would report run 801's regression as run 805's result.

{
  "recorded": true,
  "deploys": [
    {
      "environment_id": "10000000-0000-4000-8000-000000000001",
      "github_environment": "production", "deployment_task": "deploy:web",
      "workflow_run_id": 801, "workflow_run_attempt": 1, "workflow_run_attempts": [1],
      "state": "VERIFIED", "regressed": true, "gaps": [],
      "checkpoints": [
        {"checkpoint": "LANDING", "due_at": "2026-06-01T12:15:00Z", "result": "HEALTHY", "gaps": []},
        {"checkpoint": "MINUTES_20", "due_at": "2026-06-01T12:35:00Z", "result": "REGRESSED", "gaps": []},
        {"checkpoint": "HOUR_1", "due_at": "2026-06-01T13:15:00Z", "result": "REGRESSED", "gaps": []},
        {"checkpoint": "DAY_1", "due_at": "2026-06-02T12:15:00Z", "result": "REGRESSED", "gaps": []}
      ],
      "deploy_url": "https://proofline.sh/orgs/github/example/environments/production/deploys/901"
    },
    {
      "environment_id": "10000000-0000-4000-8000-000000000001",
      "github_environment": "production", "deployment_task": "deploy:web",
      "workflow_run_id": 805, "workflow_run_attempt": 2, "workflow_run_attempts": [1, 2],
      "state": "NOT_YET_DUE", "regressed": false, "gaps": [],
      "checkpoints": [
        {"checkpoint": "LANDING", "due_at": "2026-06-03T09:15:00Z", "result": "HEALTHY", "gaps": []},
        {"checkpoint": "MINUTES_20", "due_at": "2026-06-03T09:35:00Z", "result": "HEALTHY", "gaps": []},
        {"checkpoint": "HOUR_1", "due_at": "2026-06-03T10:15:00Z", "gaps": []},
        {"checkpoint": "DAY_1", "due_at": "2026-06-04T09:15:00Z", "gaps": []}
      ],
      "deploy_url": "https://proofline.sh/orgs/github/example/environments/production/deploys/905"
    }
  ]
}

Select the deploy by the run that created it, its GitHub Environment and its task, then by the attempt. Take the run ID and attempt from the deploy job itself, GITHUB_RUN_ID and GITHUB_RUN_ATTEMPT in Actions; a job in a separate workflow has a run of its own and must receive them from the deploy job. Match the attempt against workflow_run_attempts, the attempts whose deployments the deploy holds. A job retried after a failure joins the deploy of its first attempt, as run 805's attempt 2 did, so workflow_run_attempt alone would miss attempt 1. A re-run of a job that had already landed is a deploy of its own. A deploy outside Actions, or one recorded before the ledger read attempts, lists no attempts and cannot be matched by attempt.

This filter reads one check of the selected deploy. Unless exactly one deploy matches, it returns {"observation": null} and reads nothing:

jq --argjson run 805 --argjson attempt 2 --arg env production --arg task deploy:web \
  --arg check MINUTES_20 '
  [.deploys[] | select(.workflow_run_id == $run
    and .github_environment == $env and .deployment_task == $task
    and ((.workflow_run_attempts // []) | any(. == $attempt)))]
  | if length != 1 then {observation: null} else .[0]
    | (.checkpoints | map(select(.checkpoint == $check)) | first) as $c
    | {state, regressed, gaps, deploy_url, checkpoint: $c,
       observation: (
         if .state == "FAILED" or .regressed then "FAILED_OR_REGRESSED"
         elif $c.result == "HEALTHY" and ($c.gaps | length) == 0 then "HEALTHY"
         else "NOT_ESTABLISHED" end)}
    end
' deploys.json

For run 805 at MINUTES_20, the observation is HEALTHY, with the check, the deploy's state and its deploy_url beside it. Open the deploy's page to read what each check compared.

  • A deploy that reads FAILED, or any of whose checks recorded REGRESSED, reports FAILED_OR_REGRESSED whatever the chosen check recorded. Selected with --argjson run 801 --argjson attempt 1, run 801's deploy reports it even at LANDING, where its check recorded HEALTHY.
  • A check with no result has not been recorded. With --arg check HOUR_1, run 805 reports NOT_ESTABLISHED, as it would for an INCOMPLETE or SUPERSEDED result.
  • A HEALTHY check that names a gap does not establish the deploy's health for that window, so it reports NOT_ESTABLISHED too. The deploy's own gaps gather what leaves any of its checks unproven.

If the response held only run 801's deploy, or two deploys matched, the filter would return {"observation": null}: the run's own deploy is not identified, and another deploy's checks are not its result. A deploy may be recorded only after its run completes, so read again later. A response with "recorded": false and no deploys means the ledger holds no deploy of the commit yet. A refused read is different: --fail-with-body makes curl exit with an error, leaving the problem document in deploys.json, and the script stops before any selection. A repository outside the token's organization or restriction returns the same 404 as a missing one.

Errors and retries#

A refused request raises ProoflineError with the problem's status, type and detail. An invalid response or a network failure raises it with a fixed SDK problem type.

For a GET that returns 429 or 503, the clients retry up to 3 times. They honor Retry-After up to 60 seconds and refuse a longer wait.

Review requests and reruns are sent once: repeating a pull request review request or a rerun can start another review. Requests time out after 30 seconds, and a response body is limited to 8 MiB.