fix(3805): schema-aware log_to_state row appending in fast.md (#85)

* fix(3805): schema-aware log_to_state row appending in fast.md

REPRO: fast.md log_to_state unconditionally echoed a hardcoded 4-cell
row (| date | fast | task | ✅ |) into STATE.md. When quick.md Step 7
had already created the "Quick Tasks Completed" table with 5 columns
(| # | Description | Date | Commit | Directory |), fast.md appended a
malformed 4-cell row → broken Markdown table.

FIX: fast.md log_to_state now reads the existing table header, counts
columns, and checks for the expected column names from quick.md Step 7.
If the 5-column schema is confirmed, it appends a properly-formed 5-cell
row. If the schema is unrecognized, it skips the write with a warning
rather than corrupt the table.

Pattern source: quick.md Step 7 (schema-aware matching).

ANTI-PATTERN SWEEP: Only fast.md and quick.md contain direct STATE.md
table writes in workflows/. quick.md Step 7 is already schema-aware.
No other workflow candidates found.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: add changeset for #3805

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-05-22 11:39:51 -04:00
committed by GitHub
parent 4a19d4db2b
commit dcacf3eea9
3 changed files with 172 additions and 5 deletions

View File

@@ -63,14 +63,33 @@ Use conventional commit format: `fix:`, `feat:`, `docs:`, `chore:`, `refactor:`
</step>
<step name="log_to_state">
If `.planning/STATE.md` exists, append to the "Quick Tasks Completed" table.
If the table doesn't exist, skip this step silently.
If `.planning/STATE.md` exists and has a "Quick Tasks Completed" table, append a row
that matches the existing table's schema. If no table exists, skip silently.
If the table's schema is unrecognized, skip with a brief log rather than append a
malformed row.
```bash
# Check if STATE.md has quick tasks table
# Detect whether STATE.md has a Quick Tasks Completed table
if grep -q "Quick Tasks Completed" .planning/STATE.md 2>/dev/null; then
# Append entry — workflow handles the format
echo "| $(date +%Y-%m-%d) | fast | $TASK | ✅ |" >> .planning/STATE.md
# Read the table header line to determine the column schema.
# quick.md Step 7 creates a 5-column table:
# | # | Description | Date | Commit | Directory |
# Count pipe characters in the header to determine column count.
HEADER_LINE=$(grep -A2 "Quick Tasks Completed" .planning/STATE.md 2>/dev/null | grep "^|" | head -1)
# Count columns: number of | separators minus 1 gives column count
COL_COUNT=$(echo "$HEADER_LINE" | awk -F'|' '{print NF-1}')
if [ "$COL_COUNT" -eq 5 ] && echo "$HEADER_LINE" | grep -qi "Description" && echo "$HEADER_LINE" | grep -qi "Commit" && echo "$HEADER_LINE" | grep -qi "Directory"; then
# 5-column schema from quick.md Step 7: | # | Description | Date | Commit | Directory |
# Determine the next row number by counting existing data rows (non-separator, non-header).
NEXT_NUM=$(awk '/Quick Tasks Completed/{found=1} found && /^\|/ && !/^[|][-: |]*[|]$/ && !/Description/{count++} END{print count+1}' .planning/STATE.md 2>/dev/null || echo "1")
# Get the latest commit hash (short)
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "—")
echo "| $NEXT_NUM | $TASK | $(date +%Y-%m-%d) | $COMMIT_HASH | — |" >> .planning/STATE.md
else
# Unrecognized table schema — skip to avoid appending a malformed row.
echo "⚠ fast.md log_to_state: Quick Tasks Completed table has unrecognized schema (${COL_COUNT} columns); skipping STATE.md update."
fi
fi
```
</step>