Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Native knowledge, plan, fix and configuration commands send the selected organiz

`proofline rerun REVIEW_ID` requests the original immutable subject and waits, while `--no-wait` returns its link. Reruns require `reviews:rerun`. `proofline guidance --repo owner/name` requires `guidance:read`, and `proofline fix-prompt FINDING_ID` requires `findings:read`. History, guidance, and fix prompts print JSON; prompt text remains untrusted.

`proofline evidence inspect REVIEW_ID` inspects commit-pinned primary-repository source evidence from a pull-request review against the local Git checkout (pass `--json` for the typed `proofline.evidence-inspection.v1` projection, or `--remote` / `--source-provider` to select the checkout's remote). It validates the checkout's actual Git remote against the review's recorded repository ID (with no `--repo` override), pins local `HEAD` once, and reports two independent observations per reference: whether the raw immutable Git blob bytes at the reviewed commit match Proofline's recorded `file_sha256` (`matched`, `mismatch`, `not_recorded`, `unavailable`, or `outside_scope`), and whether the cited path's Git blob object identity at local `HEAD` equals or differs from a known regular-file blob at the reviewed commit (`unchanged`, `changed`, `absent`, `unavailable`, or `outside_scope`) without independently reading both blobs' bytes or assuming branch ancestry. Inspection is strictly local-only and diagnostic (exit 0 when a report is produced, exit 1 on usage, authentication, repository-identity, or unsupported-review errors): it ignores replacement objects and uncommitted changes, does not invoke smudge or Git LFS filters (so LFS pointer blobs compare pointer bytes rather than materialized objects), supports ordinary and shallow clones (reporting missing commits or original entries as `unavailable`), and refuses partial or promisor clones where local-only object access cannot be guaranteed across Git versions. It does not verify AI reasoning, reassess findings, or establish whether a finding is resolved.

Repository commands use the checkout’s `origin` by default. Use `--remote NAME` to select another remote or `--repo URL` to supply a clone URL. The CLI sends the host and full project path to Proofline, including subgroup names. The CLI recognizes gitlab.com and otherwise looks for a GitHub repository on the exact remote host, including GitHub Enterprise Server. Use `--source-provider gitlab` for private GitLab hosts or `--source-provider git` for other Git servers. Hooks can read the same choice from `PROOFLINE_SOURCE_PROVIDER`. A connected private Git repository can use `proofline review --source-provider git --range BASE..HEAD` to request a review of two pushed commits.

`proofline review --range BASE..HEAD --fail-on serious` exits 3 when a complete review has an unresolved finding at or above the threshold. PR reviews use the server’s effective open-item counts; other reviews count unresolved findings, including those a partial code assessment recorded. Incomplete and unavailable results retain their nonzero exits. `--fail-on` cannot be combined with `--no-wait`.
Expand Down
152 changes: 152 additions & 0 deletions src/evidence.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
//! Read-only inspection of commit-pinned pull-request source evidence against
//! the local Git checkout.
//!
//! Two independent questions are answered for each eligible primary-repository
//! file reference:
//! 1. Whether the raw immutable Git blob bytes at the reviewed commit match
//! Proofline's recorded `file_sha256`.
//! 2. Whether the cited path's Git blob object identity at a single immutable
//! snapshot of local `HEAD` equals or differs from a known regular-file blob
//! at the reviewed commit (without independently reading both blobs' bytes
//! or assuming branch ancestry).
//!
//! Neither observation establishes AI reasoning correctness, finding validity,
//! or whether a finding has been resolved.

mod inspect;
mod render;
mod report;

#[cfg(test)]
mod tests;

use std::io::Write as _;
use std::path::Path;

use anyhow::bail;
use clap::{Args, Subcommand};
use uuid::Uuid;

use crate::api::Api;
use crate::git::inspection::{self, InspectionLimits};
use crate::git::{self, GitError};
use crate::outcome;
use crate::text::one_line;
use crate::{RepositoryRead, SourceProvider, Verdict};

use self::report::InspectionReport;

#[derive(Debug, Subcommand)]
pub(crate) enum EvidenceCommand {
/// Inspect commit-pinned source evidence of a pull-request review against
/// the local Git checkout.
Inspect(InspectArgs),
}

#[derive(Debug, Args)]
pub(crate) struct InspectArgs {
/// Review ID to inspect.
review_id: Uuid,
/// Print JSON instead of text.
#[arg(long)]
json: bool,
/// Git remote that names this checkout's repository.
#[arg(long, default_value = "origin")]
remote: String,
/// Source provider. Defaults to GitLab on gitlab.com and GitHub on other hosts.
#[arg(long, env = "PROOFLINE_SOURCE_PROVIDER")]
source_provider: Option<SourceProvider>,
}

pub(crate) async fn run(api: &Api, args: &InspectArgs) -> anyhow::Result<Verdict> {
let report = inspect_checkout(api, Path::new("."), args, InspectionLimits::default()).await?;
let mut stdout = std::io::stdout().lock();
if args.json {
writeln!(stdout, "{}", serde_json::to_string_pretty(&report)?)?;
} else {
write!(stdout, "{}", render::render(&report))?;
}
Ok(Verdict::Done)
}

async fn inspect_checkout(
api: &Api,
dir: &Path,
args: &InspectArgs,
limits: InspectionLimits,
) -> anyhow::Result<InspectionReport> {
let remote = inspection::remote_repository_in(dir, &args.remote, limits)
.await
.map_err(|error| match error {
GitError::UnknownRemote => anyhow::anyhow!(
"the Git remote {:?} does not name a hosted repository; configure a hosted remote or select one with --remote",
one_line(&args.remote)
),
other => other.into(),
})?;
let provider = match (args.source_provider, remote.host.as_str()) {
(Some(provider), _) => provider,
(None, "gitlab.com") => SourceProvider::Gitlab,
(None, _) => SourceProvider::Github,
};
let (local_repo_name, local_repo_id) = api
.resolve_source(provider.as_str(), &remote, RepositoryRead::History)
.await?;
let (_raw, detail) = api.review(args.review_id).await?;
outcome::same_review(&detail, args.review_id)?;

let Some(review_repo_id) = detail.repository_id else {
bail!(
"review {} records no repository identity; evidence inspection requires a repository-bound review",
detail.id
);
};
if review_repo_id != local_repo_id {
let review_repo = detail
.repository_full_name
.as_deref()
.map_or_else(|| review_repo_id.to_string(), one_line);
bail!(
"review {} belongs to repository {} ({review_repo_id}), not the local checkout's repository {} ({local_repo_id})",
detail.id,
review_repo,
one_line(&local_repo_name)
);
}
if detail.kind != "PULL_REQUEST" {
bail!(
"review {} has kind {}; evidence inspection supports only commit-pinned pull-request reviews",
detail.id,
one_line(&detail.kind)
);
}
let Some(reviewed_head_sha) = detail
.head_commit_sha
.as_deref()
.and_then(|raw| git::commit_sha(raw).ok())
else {
bail!(
"review {} does not record a full head commit SHA; evidence inspection requires a commit-pinned pull-request head",
detail.id
);
};

inspection::ensure_no_partial_clone(dir, limits).await?;
let local_head_sha = inspection::head_in(dir, limits).await?;
let repo_name = detail
.repository_full_name
.as_deref()
.filter(|name| !name.trim().is_empty())
.map_or(local_repo_name, str::to_owned);

Ok(inspect::inspect_review(
dir,
&detail,
review_repo_id,
repo_name,
reviewed_head_sha,
local_head_sha,
limits,
)
.await)
}
Loading