Commit Graph

2 Commits

Author SHA1 Message Date
Bo 10db732740 fix(evolve): guard jq|wc pipefail so a malformed line cannot abort the script (ag-1j1 #jq-wc-guards) (#584)
## What

Under `set -euo pipefail`, a `jq ... 2>/dev/null | wc -l` substitution
aborts the entire script when `jq` hits a malformed JSON line:
`2>/dev/null` suppresses jq's stderr but not its non-zero exit code,
`pipefail` propagates that through the pipeline, and `set -e` then kills
the script mid-run (leaving partial state).

## Fix

Append `|| echo 0` to the unguarded substitutions:

- **`scripts/bootstrap-maturity.sh` line 65** — reads the raw `.jsonl`
file directly, so a malformed line genuinely aborts the migration before
the summary prints. Verified empirically and caught by the regression
test (test fails against the unguarded copy with `status != 0`).
- **`scripts/evolve-capture-daily-learning.sh` lines 59-62 (4x)** —
matches the already-guarded `grep -c` on line 58. Verification note: in
normal operation `TODAY_CYCLES` is pre-sanitized by the line-55 `jq ...
|| true` filter, so these lines don't see malformed input in practice.
The guard is defense-in-depth that pins abort-proof behavior if
malformed content ever reaches them (e.g., a future refactor drops the
line-55 sanitization).

`halt-check.sh` is intentionally out of scope (`set -uo`, no `-e` —
degrades, doesn't abort).

## Test

`tests/scripts/jq-wc-pipefail-guards.bats` (5 tests):
- Malformed-input fixtures for both scripts prove neither aborts and the
consolidated artifacts still get written.
- A guarded/unguarded expression pair (positive + negative control) pins
the `|| echo 0` mechanism so a future edit can't silently drop it.

## Local validation

- `bats tests/scripts/jq-wc-pipefail-guards.bats` — 5/5 green
- `shellcheck scripts/evolve-capture-daily-learning.sh
scripts/bootstrap-maturity.sh` — clean
- Existing `tests/scripts/bootstrap-maturity.bats` — still 4/4 green

Closes-scenario: ag-1j1#jq-wc-guards
Bounded-context: BC5-Runtime
Evidence: bats tests/scripts/jq-wc-pipefail-guards.bats
2026-05-28 17:19:15 -04:00
Boden Fuller c02661de8a plan(evolve): add Learning Capture epic — daily self-reflection compounds across days
Three-layer protocol so each /evolve day improves the next:
1. Per-cycle micro-capture: 1 line to .agents/evolve/daily-learning-log-YYYY-MM-DD.md
2. Every-5th-productive reflect: pattern annotation inline in cycle-history note;
   3+-occurrence frictions matching prior days auto-file an evolve-improvement bead
3. End-of-day consolidate via scripts/evolve-capture-daily-learning.sh:
   - Reads daily log + cycle-history (filtered to today)
   - Writes .agents/learnings/YYYY-MM-DD-evolve-loop-learnings.md with counts,
     ledger, frictions, recurring patterns
   - Auto-files LC-followup beads (label: evolution-roadmap,evolve-improvement)
     for any FRICTION tag that recurred on 2+ days
   - Idempotent (re-run overwrites today's consolidated file; daily log untouched)
   - Supports --dry-run

Seeder updates:
- LC epic + LC1 leaf bead added (closes loop on the loop's own behavior)
- Pagination bug fixed: bd list --status=open --json (default 50 cap) caused
  duplicate beads on re-run when total open > 50. Changed all idempotency
  checks to bd list --status=open --limit 0 --json. Re-run is now safely
  idempotent — verified with dry-run reporting 41 skips, 0 would-create.
- 13 duplicate beads from the prior re-run already closed manually with
  reason="duplicate from seeder idempotency bug"; their close is the
  evidence the bug existed and is now fixed.

Road-map plan extended with LC section + table entry. 41 evolution-roadmap
labeled beads now open (39 original + LC epic + LC1).

Local-only artifacts (in .agents/, gitignored by policy):
- .agents/evolve/all-day-starter-prompt.md (revised with mandatory steps 9-10
  + end-of-day consolidator invocation)
- .agents/evolve/daily-learning-log.template.md (tag taxonomy + examples)
- .agents/evolve/daily-learning-log-2026-05-11.md (seeded for smoke test)
2026-05-11 08:57:38 -04:00