Skip to content

Harden monitor-meta workflow baseline normalization and diffing - #44

Draft
melscoop with Copilot wants to merge 1 commit into
fix/monitor-meta-exit-code-5from
copilot/fix-monitor-meta-workflow
Draft

Harden monitor-meta workflow baseline normalization and diffing#44
melscoop with Copilot wants to merge 1 commit into
fix/monitor-meta-exit-code-5from
copilot/fix-monitor-meta-workflow

Conversation

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The monitor-meta workflow was failing with exit code 5 after the deterministic-hash rewrite because it compared newly normalized output against a stale pre-normalization baseline and let brittle jq/shell behavior fail the job. This change keeps the workflow structure intact while making baseline handling, hashing, and diff generation deterministic and failure-tolerant.

  • Workflow hardening

    • Adds shell: bash to every run: step
    • Starts each script with set -euo pipefail so failures surface at the actual command boundary instead of as an opaque step exit
  • Deterministic baseline comparison

    • Writes trimmed-meta.json with stable key ordering via jq -S
    • Normalizes .meta.last.json with the same sort/shape transform before any section diffing
    • Falls back to {} when the stored baseline is missing or invalid, so comparisons stay well-defined
  • Diff generation without fragile sub-jq failures

    • Replaces per-section added_count / removed_count jq length calls with single-pass value emission
    • Counts non-empty diff lines with grep -c ., avoiding the non-zero jq behavior that was bubbling into step failure under strict shell settings
    • Keeps existing issue body structure and changed-section reporting
  • Baseline persistence behavior

    • Guards the first-baseline commit path with || echo "Nothing to commit" to avoid failing when no commit is needed
    • Preserves the existing first-run initialization and change-driven baseline update flow
  • Expected next-run behavior

    • The committed .meta.last.hash was produced by the older pipeline, so the next scheduled or manual run should detect one change and rewrite .meta.last.json / .meta.last.hash into the normalized deterministic format
    • That self-heal is expected once and should not recur
- name: Compare for changes
  shell: bash
  run: |
    set -euo pipefail

    jq -S 'with_entries(.value |= (if type == "array" then sort else . end))' \
      .meta.last.json > normalized-old.json 2>/dev/null || echo '{}' > normalized-old.json

    CHANGED_SECTIONS=$(jq -r --slurpfile old normalized-old.json '
      to_entries
      | map(select(.value != ($old[0][.key] // [])) | .key)
      | join(",")
    ' trimmed-meta.json)

Copilot AI changed the title [WIP] Fix GitHub meta monitor workflow exit code 5 Harden monitor-meta workflow baseline normalization and diffing Jul 1, 2026
Copilot AI requested a review from melscoop July 1, 2026 21:58
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