Skip to content

feat: add readReviewMergeGate helper to evaluate CustomerReviewDetail… - #120

Closed
Devnil434 wants to merge 1 commit into
prooflinedev:mainfrom
Devnil434:feat/read-review-merge-gate
Closed

Devnil434 wants to merge 1 commit into
prooflinedev:mainfrom
Devnil434:feat/read-review-merge-gate

Conversation

@Devnil434

Copy link
Copy Markdown

Problem

CustomerReviewDetail exposes merge_gate (PullRequestMergeGate | null), which records Proofline's server-evaluated deterministic merge policy for an opted-in repository and commit (status, decision, policy_version, blocking_severity, severity_applied, finding_count, assessment_count, coverage_digest, reason_code, head_sha, and bypass history).

Callers using getReview() or waitForReview() in CI/CD pipelines previously had to manually inspect review.merge_gate, distinguish review === null (e.g., TIMED_OUT before first response) from merge_gate === null (not opted in), validate GateStatus / Outcome consistency, extract GitHub bypass metadata, and check head_sha alignment.

Approach

Add a pure, typed helper readReviewMergeGate(source, options?) in src/merge-gate.ts and re-export it (and its types) from src/index.ts:

  • Accepts either a Review (CustomerReviewDetail) or a ReviewOutcome (waitForReview).
  • Distinguishes "UNAVAILABLE" (outcome.review === null) from "NOT_CONFIGURED" (review.merge_gate === null).
  • Normalizes all documented GateStatus values (REQUESTED, EVALUATING, ALLOWED, BLOCKED, BYPASSED, SUPERSEDED), Outcome (ALLOW | BLOCK | null), and structured MergeGateBypass fields.
  • Supports optional headSha pinning (TypeError on invalid 40-char SHA; returns status: "HEAD_MISMATCH" with decision: null if the recorded gate belongs to another commit).
  • Validates contract types and status/decision invariants (ALLOWED requires ALLOW; BLOCKED requires BLOCK), throwing ProoflineError(0, "urn:proofline:sdk:invalid-response", ...) on malformed payloads.
  • Leaves openapi.public.json, generated types/operations, and CI workflows untouched, and satisfies check-claims.mjs.

Verification

  • npm run typecheck — passed
  • npm run build — passed (dist/merge-gate.js and dist/merge-gate.d.ts emitted)
  • node generate.mjs — no changes to src/operations.ts or src/schema.d.ts
  • node check-claims.mjs — passed
  • .\node_modules\.bin\biome check src/merge-gate.ts tests/merge-gate.test.mjs — passed
  • .\node_modules\.bin\biome lint src/index.ts — passed
  • node --test tests/merge-gate.test.mjs — 5/5 passed (covering unavailable/unconfigured states, all 6 GateStatus values and bypass metadata, headSha pinning, 14 malformed/contradictory payloads, and local HTTP waitForReview + getReview integration)
  • npm test — 110/111 passed (the single failure is the pre-existing tests/http.test.mjs:2121 test "a new public operation generates a callable typed client method" failing on Windows sandbox with EPERM: operation not permitted, symlink ... -> ...\node_modules)

@Devnil434 Devnil434 closed this Dec 3, 2026
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.

1 participant