diff --git a/.github/workflows/maintenance-check.yml b/.github/workflows/maintenance-check.yml
index 45a3b24..e882515 100644
--- a/.github/workflows/maintenance-check.yml
+++ b/.github/workflows/maintenance-check.yml
@@ -71,49 +71,229 @@ jobs:
name: audit-report
path: specs/audit-report.md
- - name: Build issue body
+ - name: Classify severity and build issue
+ id: classify
if: steps.fetch.outputs.changes == 'true'
run: |
+ SEVERITY="low"
+ DATE=$(date -u +%Y-%m-%d)
+
+ # --- Parse diff report for high/medium signals ---
+ DIFF_FILE="specs/diff-report.md"
+ NEW_ENDPOINTS=0
+ REMOVED_ENDPOINTS=0
+ CHANGED_ENDPOINTS=0
+ SCHEMA_CHANGES=0
+
+ if [ -f "$DIFF_FILE" ]; then
+ # Count sections that have content (not just "No ... endpoints/changes")
+ if ! grep -q "No new endpoints" "$DIFF_FILE"; then
+ NEW_ENDPOINTS=$(grep -c '^\- \*\*' "$DIFF_FILE" 2>/dev/null || echo 0)
+ fi
+ if ! grep -q "No removed endpoints" "$DIFF_FILE"; then
+ REMOVED_ENDPOINTS=1
+ fi
+ if ! grep -q "No changed endpoints" "$DIFF_FILE"; then
+ CHANGED_ENDPOINTS=1
+ fi
+ if ! grep -q "No schema changes" "$DIFF_FILE"; then
+ SCHEMA_CHANGES=1
+ fi
+ fi
+
+ # --- Parse audit report for drift signals ---
+ AUDIT_FILE="specs/audit-report.md"
+ MISSING_ENDPOINTS=0
+ BODY_DRIFT=0
+ PARAM_DRIFT=0
+ CODE_ISSUES=0
+
+ if [ -f "$AUDIT_FILE" ]; then
+ MISSING_ENDPOINTS=$(grep -oP 'Missing from SDK: \K[0-9]+' "$AUDIT_FILE" | head -1 || echo 0)
+ [ -z "$MISSING_ENDPOINTS" ] && MISSING_ENDPOINTS=0
+
+ if ! grep -q "No request body drift" "$AUDIT_FILE"; then
+ BODY_DRIFT=1
+ fi
+ if ! grep -q "No query/path parameter drift" "$AUDIT_FILE"; then
+ PARAM_DRIFT=1
+ fi
+ CODE_ISSUES=$(grep -oP 'Code issues found: \K[0-9]+' "$AUDIT_FILE" | head -1 || echo 0)
+ [ -z "$CODE_ISSUES" ] && CODE_ISSUES=0
+ fi
+
+ # --- Determine severity ---
+ # High: removed endpoints, missing endpoints, breaking schema changes, body drift
+ if [ "$REMOVED_ENDPOINTS" -gt 0 ] || [ "$MISSING_ENDPOINTS" -gt 0 ] || [ "$BODY_DRIFT" -gt 0 ]; then
+ SEVERITY="high"
+ # Medium: new endpoints, changed endpoints, param drift, schema changes, real code issues
+ elif [ "$NEW_ENDPOINTS" -gt 0 ] || [ "$CHANGED_ENDPOINTS" -gt 0 ] || [ "$PARAM_DRIFT" -gt 0 ] || [ "$SCHEMA_CHANGES" -gt 0 ]; then
+ SEVERITY="medium"
+ # Low: cosmetic changes only (descriptions, formatting)
+ else
+ SEVERITY="low"
+ fi
+
+ echo "severity=$SEVERITY" >> $GITHUB_OUTPUT
+ echo "date=$DATE" >> $GITHUB_OUTPUT
+
+ # --- Build summary line ---
+ SUMMARY=""
+ [ "$REMOVED_ENDPOINTS" -gt 0 ] && SUMMARY="${SUMMARY}removed endpoints, "
+ [ "$MISSING_ENDPOINTS" -gt 0 ] && SUMMARY="${SUMMARY}${MISSING_ENDPOINTS} missing SDK methods, "
+ [ "$BODY_DRIFT" -gt 0 ] && SUMMARY="${SUMMARY}request body drift, "
+ [ "$PARAM_DRIFT" -gt 0 ] && SUMMARY="${SUMMARY}parameter drift, "
+ [ "$NEW_ENDPOINTS" -gt 0 ] && SUMMARY="${SUMMARY}${NEW_ENDPOINTS} new endpoints, "
+ [ "$CHANGED_ENDPOINTS" -gt 0 ] && SUMMARY="${SUMMARY}changed endpoints, "
+ [ "$SCHEMA_CHANGES" -gt 0 ] && SUMMARY="${SUMMARY}schema changes, "
+ [ "$CODE_ISSUES" -gt 0 ] && SUMMARY="${SUMMARY}${CODE_ISSUES} code issues, "
+
+ if [ -z "$SUMMARY" ]; then
+ SUMMARY="cosmetic spec changes only"
+ else
+ SUMMARY="${SUMMARY%, }"
+ fi
+
+ # --- Build issue body ---
{
- echo "## Etsy API Drift Detected"
- echo ""
- echo "The weekly maintenance check found changes in the Etsy OpenAPI spec."
+ echo "## Etsy API Drift — \`${SEVERITY}\` severity"
echo ""
- echo "### Diff Report"
+ echo "**Detected:** ${DATE} | **Severity:** \`${SEVERITY}\` | **Summary:** ${SUMMARY}"
echo ""
- cat specs/diff-report.md
+
+ echo "### What Changed (Diff Report)"
echo ""
- echo "### SDK Coverage"
+ if [ -f "$DIFF_FILE" ]; then
+ cat "$DIFF_FILE"
+ else
+ echo "No diff report generated."
+ fi
echo ""
- sed -n '/## Coverage Summary/,/^## [^C]/p' specs/audit-report.md | head -20
+
+ echo "### SDK Impact (Audit Report)"
echo ""
+ if [ -f "$AUDIT_FILE" ]; then
+ # Coverage summary
+ sed -n '/## Coverage Summary/,/^## Missing Endpoints/p' "$AUDIT_FILE" | head -15
+ echo ""
+
+ # Missing endpoints (if any)
+ MISSING_SECTION=$(sed -n '/## Missing Endpoints/,/^## Not Implemented/p' "$AUDIT_FILE")
+ if ! echo "$MISSING_SECTION" | grep -q "All OAS operations are covered"; then
+ echo "#### Missing Endpoints"
+ echo "$MISSING_SECTION" | tail -n +2 | head -20
+ echo ""
+ fi
+
+ # Body drift (if any)
+ if ! grep -q "No request body drift" "$AUDIT_FILE"; then
+ echo "#### Request Body Drift"
+ sed -n '/## Request Body Drift/,/^## /p' "$AUDIT_FILE" | head -30
+ echo ""
+ fi
+
+ # Param drift (if any)
+ if ! grep -q "No query/path parameter drift" "$AUDIT_FILE"; then
+ echo "#### Parameter Drift"
+ sed -n '/## Query\/Path Parameter Drift/,/^## /p' "$AUDIT_FILE" | head -30
+ echo ""
+ fi
+
+ # Enum staleness (if any — only show real drift, not the known holiday IDs)
+ ENUM_SECTION=$(sed -n '/## Enum Staleness/,/^## /p' "$AUDIT_FILE")
+ if [ -n "$ENUM_SECTION" ] && ! echo "$ENUM_SECTION" | grep -q "^$"; then
+ ENUM_LINE_COUNT=$(echo "$ENUM_SECTION" | wc -l)
+ if [ "$ENUM_LINE_COUNT" -gt 3 ]; then
+ echo "#### Enum Staleness"
+ echo "$ENUM_SECTION" | head -30
+ echo ""
+ fi
+ fi
+
+ # Code issues (if any)
+ if [ "$CODE_ISSUES" -gt 0 ]; then
+ echo "#### Code Issues (${CODE_ISSUES})"
+ sed -n '/## Code Issues/,/^## /p' "$AUDIT_FILE" | head -30
+ echo ""
+ fi
+
+ # Extra SDK methods
+ EXTRA_SECTION=$(sed -n '/## Extra SDK Methods/,/^## /p' "$AUDIT_FILE")
+ if ! echo "$EXTRA_SECTION" | grep -q "no matching OAS operation" || echo "$EXTRA_SECTION" | grep -q "\*\*"; then
+ echo "Extra SDK Methods (no OAS match)
"
+ echo ""
+ echo "$EXTRA_SECTION" | head -20
+ echo ""
+ echo "
This endpoint is ready for production use.
This endpoint is ready for production use.