@@ -700,47 +700,33 @@ runs:
700700 working-directory : target-repo
701701 env :
702702 BASE_SHA : ${{ steps.guard.outputs.base_sha }}
703- HEAD_SHA : ${{ steps.guard.outputs.head_sha }}
704703 ACTION_PATH : ${{ github.action_path }}
704+ DEPTH : ${{ steps.resolve_depth.outputs.depth }}
705705 run : |
706706 BASE_DIR="${RUNNER_TEMP}/cb-base"
707707 HEAD_DIR="${RUNNER_TEMP}/cb-head"
708708 mkdir -p "$BASE_DIR" "$HEAD_DIR"
709709 echo "base_dir=$BASE_DIR" >> $GITHUB_OUTPUT
710710 echo "head_dir=$HEAD_DIR" >> $GITHUB_OUTPUT
711- BASELINE_SHA=""
712- # Use the newest analysis.json reachable by walking backwards through
713- # the PR head branch ancestry. If the PR branch is a->b->c->d and master
714- # is a->b->m1->m2, this deliberately searches d,c,b,a — not m2,m1,b,a.
715- while IFS= read -r candidate; do
716- if git cat-file -e "${candidate}:.codeboarding/analysis.json" 2>/dev/null; then
717- BASELINE_SHA="$candidate"
718- break
719- fi
720- done < <(git rev-list "$HEAD_SHA" -- .codeboarding/analysis.json 2>/dev/null || true)
721-
722- if [ -n "$BASELINE_SHA" ] && git show "${BASELINE_SHA}:.codeboarding/analysis.json" > "${BASE_DIR}/analysis.json" 2>/dev/null; then
711+ if git show "${BASE_SHA}:.codeboarding/analysis.json" > "${BASE_DIR}/analysis.json" 2>/dev/null; then
723712 if python3 "$ACTION_PATH/scripts/engine_adapter.py" validate-base \
724713 --analysis "${BASE_DIR}/analysis.json" \
725- --expected-sha "$BASELINE_SHA"; then
714+ --expected-sha "$BASE_SHA" \
715+ --expected-depth "$DEPTH"; then
726716 echo "committed=true" >> $GITHUB_OUTPUT
727- echo "baseline_sha=$BASELINE_SHA" >> $GITHUB_OUTPUT
728- if [ "$BASELINE_SHA" = "$HEAD_SHA" ]; then
729- echo "Using committed .codeboarding/analysis.json at PR head ${HEAD_SHA}."
730- else
731- echo "Using nearest committed .codeboarding/analysis.json at ${BASELINE_SHA} from PR head history ${HEAD_SHA}."
732- fi
717+ echo "baseline_sha=$BASE_SHA" >> $GITHUB_OUTPUT
718+ echo "Using committed .codeboarding/analysis.json at PR base ${BASE_SHA}."
733719 else
734720 rm -f "${BASE_DIR}/analysis.json"
735721 echo "committed=false" >> $GITHUB_OUTPUT
736722 echo "baseline_sha=$BASE_SHA" >> $GITHUB_OUTPUT
737- echo "Committed baseline at ${BASELINE_SHA } is unusable; will generate a fresh base analysis at ${BASE_SHA} ."
723+ echo "Committed baseline at PR base ${BASE_SHA } is unusable; will generate a fresh base analysis."
738724 fi
739725 else
740726 rm -f "${BASE_DIR}/analysis.json"
741727 echo "committed=false" >> $GITHUB_OUTPUT
742728 echo "baseline_sha=$BASE_SHA" >> $GITHUB_OUTPUT
743- echo "No committed baseline found in PR head history ; will generate one via a full analysis on the base commit ${BASE_SHA} ."
729+ echo "No committed baseline found at PR base ${BASE_SHA} ; will generate one via a full analysis on the base commit."
744730 fi
745731
746732 - name : Restore base artifacts (keyed by baseline SHA)
@@ -757,6 +743,27 @@ runs:
757743 # analyses; the mode discriminator keeps them from reusing each other's cache.
758744 key : cb-base-v2-${{ runner.os }}-${{ steps.base.outputs.baseline_sha }}-d${{ steps.resolve_depth.outputs.depth }}-${{ inputs.engine_ref }}-${{ steps.llm.outputs.mode }}-${{ inputs.llm_provider }}-${{ inputs.agent_model }}-${{ inputs.parsing_model }}
759745
746+ - name : Reassert committed base analysis after cache restore
747+ if : steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review' && steps.base.outputs.committed == 'true'
748+ shell : bash
749+ working-directory : target-repo
750+ env :
751+ BASE_SHA : ${{ steps.guard.outputs.base_sha }}
752+ BASE_DIR : ${{ steps.base.outputs.base_dir }}
753+ ACTION_PATH : ${{ github.action_path }}
754+ DEPTH : ${{ steps.resolve_depth.outputs.depth }}
755+ run : |
756+ # The cache stores generated base artifacts under the baseline SHA so the
757+ # static-analysis pkl can be reused. It must never replace the committed
758+ # target-branch baseline used for the PR diff. Re-copy the versioned
759+ # baseline after restore: cache may supply pkl/sha, but git is the source
760+ # of truth for cb-base/analysis.json.
761+ git show "${BASE_SHA}:.codeboarding/analysis.json" > "${BASE_DIR}/analysis.json"
762+ python3 "$ACTION_PATH/scripts/engine_adapter.py" validate-base \
763+ --analysis "${BASE_DIR}/analysis.json" \
764+ --expected-sha "$BASE_SHA" \
765+ --expected-depth "$DEPTH"
766+
760767 # A committed analysis.json gives the head analysis stable component ids,
761768 # but the engine's incremental path ALSO needs the base static_analysis.pkl
762769 # with its cluster baseline — which git can't provide (the pkl is never
0 commit comments