8000 refactor(ci): extract pr-approval-timeline domain module by VLukiantsev · Pull Request #753 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

refactor(ci): extract pr-approval-timeline domain module - #753

Merged
VLukiantsev merged 1 commit into
mainfrom
refactor/decompose-incremental-approval-modules
Sep 4, 2026
Merged

VLukiantsev merged 1 commit into
mainfrom
refactor/decompose-incremental-approval-modules

Conversation

@VLukiantsev
@VLukiantsev VLukiantsev commented Sep 3, 2026 •
Copy link
Copy Markdown
Collaborator

Summary

Extracts GitHub review and timeline reconstruction logic from .github/scripts/incremental-approval.js into .github/scripts/pr-approval-timeline.js with comprehensive companion unit tests in pr-approval-timeline.test.js.

Concludes the mechanical SRP modularization by transforming .github/scripts/incremental-approval.js into a thin orchestrator while maintaining 100% backward compatibility by re-exporting all symbols.

Motivation & Context

Decomposing the monolithic incremental approval script into focused domain modules isolates GitHub review timeline parsing from Git range-diff execution and approval policies.

Architectural Contract Compliance

  • Single Responsibility Principle (SRP): Isolates GitHub API timeline querying (GraphQL/REST), review dismissal classification (manual vs stale-push), and active approval reconstruction into a focused module.
  • Dead Code Invariant: All extracted functions are directly invoked by incremental-approval.js.run().
  • Diff Sizing Gate:
    • Production code lines: 385 (threshold: 400)
    • Total code lines: 979 (threshold: 1000)
    • Sizing status: ✅ Within limits

Key Changes

  • Created .github/scripts/pr-approval-timeline.js exporting timeline event querying, event normalization, and approval state tracking.
  • Created .github/scripts/pr-approval-timeline.test.js covering GraphQL/REST timeline parsing, manual vs automatic dismissal detection, and blocking change requests.
  • Streamlined .github/scripts/incremental-approval.js into a lightweight orchestrator delegating to domain modules and re-exporting all interfaces.
  • Added orchestrator unit tests for run() in incremental-approval.test.js.

Assumptions

None — requirements were fully specified.

Verification & Testing

  • Unit Tests: node --test .github/scripts/*.test.js (76/76 passing on this layer).
  • Pre-commit Hooks: Passes cleanly across buildifier, gofmt, golangci-lint, and addlicense.

Related Issues / Bugs

Part of Stack #782 (Layer 1 of 4). Builds on top of main (following merged PRs #758, #759, #760). Follow-up Layer 2 is PR #768.

TAG=agy
CONV=ced76c7b-e554-4b82-8631-a07a1a2f203d


Stack created with GitHub Stacks CLI • Give Feedback 💬

@VLukiantsev VLukiantsev changed the title refactor/decompose incremental approval modules refactor(ci): decompose incremental-approval into domain modules Sep 3, 2026
@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors the incremental approval script by modularizing its components into separate files (approval-policy.js, git-range-diff.js, pr-approval-timeline.js, and range-diff-parser.js) and introduces a helper function verifyCodeOwnership. The reviewer identified two critical safety improvements: adding a pagination limit to the timeline event fetching to prevent infinite loops and ensuring that failures in calculating commit line deltas throw an error rather than silently returning a zero delta, which prevents potentially unsafe auto-reapprovals.

Comment thread .github/scripts/pr-approval-timeline.js Resolved
Comment thread .github/scripts/git-range-diff.js Resolved
@VLukiantsev
VLukiantsev force-pushed the refactor/decompose-incremental-approval-modules branch from 3a31df7 to 7c262fc Compare September 3, 2026 10:49
@VLukiantsev
VLukiantsev changed the base branch from main to refactor/ci-extract-approval-policy September 3, 2026 10:49
@VLukiantsev VLukiantsev changed the title refactor(ci): decompose incremental-approval into domain modules refactor(ci): extract pr-approval-timeline domain module Sep 3, 2026
@VLukiantsev
VLukiantsev marked this pull request as ready for review September 3, 2026 11:13
@VLukiantsev
VLukiantsev force-pushed the refactor/decompose-incremental-approval-modules branch from 7c262fc to 70d2682 Compare September 3, 2026 11:22
@VLukiantsev
VLukiantsev force-pushed the refactor/decompose-incremental-approval-modules branch from 70d2682 to e43e8ba Compare September 3, 2026 12:55
@VLukiantsev
VLukiantsev force-pushed the refactor/decompose-incremental-approval-modules branch from e43e8ba to 7e7e666 Compare September 3, 2026 13:01
janzak-dev
janzak-dev previously approved these changes Sep 3, 2026
janzak-dev
janzak-dev previously approved these changes Sep 4, 2026
@VLukiantsev
VLukiantsev added this pull request to the merge queue Sep 4, 2026
Base automatically changed from refactor/ci-extract-approval-policy to refactor/ci-extract-git-range-diff September 4, 2026 08:23
@VLukiantsev
VLukiantsev deleted the branch main September 4, 2026 08:23
@VLukiantsev VLukiantsev closed this Sep 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a manual request Sep 4, 2026
@VLukiantsev VLukiantsev reopened this Sep 4, 2026
@VLukiantsev
VLukiantsev changed the base branch from refactor/ci-extract-git-range-diff to main September 4, 2026 08:31
@VLukiantsev
VLukiantsev dismissed janzak-dev’s stale review September 4, 2026 08:31

The base branch was changed.

@github-actions
github-actions Bot requested a review from AntonTyb September 4, 2026 08:31
Extracts timeline event parsing, review dismissal tracking, GraphQL/REST
timeline queries, and approval state resolution into
.github/scripts/pr-approval-timeline.js with companion unit tests in
pr-approval-timeline.test.js.

Transforms .github/scripts/incremental-approval.js into a thin, focused
orchestrator while preserving 100% backward compatibility via symbol re-exports.

TAG=agy
CONV=ced76c7b-e554-4b82-8631-a07a1a2f203d
@VLukiantsev
VLukiantsev added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit a34b8f1 Sep 4, 2026
11 checks passed
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

0