INNER CODE UNIT · JavaScript

checkAndRevokeStaleGates

rancher/terraform-provider-rancher2 · agent-scripts/gating.js:168

export function checkAndRevokeStaleGates(targetDir, activeDiffHash, expectedPlanHash) {
  const reviewApprovalFile = path.join(targetDir, 'review-approval.json');

  let hasRevoked = false;

  // Check review approval
  if (fs.existsSync(reviewApprovalFile)) {
    try {
      const content = JSON.parse(fs.readFileSync(reviewApprovalFile, 'utf-8'));
      if (
        activeDiffHash &&
        expectedPlanHash &&
        (content.diff_hash !== activeDiffHash || content.plan_hash !== expectedPlanHash)
      ) {
        fs.unlinkSync(reviewApprovalFile);
        console.error(
          '❌ Active Gate Revocation: Stale review signature deleted because workspace changes were modified since your last review!',
        );

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…