2026-03-22

2026-03-22
Signal
The accumulate-then-flush pattern for DocGuard : accumulating documentation events and flushing them in a batch : avoids the problem of triggering a documentation review for every individual file save during a refactor where 20 files change in 2 minutes.
Evidence
- Project: projects/peon-notify/_index : v1.0.0 shipped: CodeGuard v2 (26 fixes), DocGuard hook, 4-layer JSON validation, YAML/TOML validation, language-specific review prompts for all 7 languages
- Pattern adopted: accumulate-then-flush for DocGuard : accumulates write events, flushes as batch
- Pattern adopted: content-hash-dedup for preventing review loops on unchanged files
- 4-layer JSON validation: jq (syntax) → python3 (duplicate keys) → nesting/mixed arrays → schema
- Bugs fixed: 2026-03-22-macos-cooldown-timestamp-corruption, 2026-03-22-codeguard-session-id-always-unknown, 2026-03-22-codeguard-76-percent-killed-by-timeout, 2026-03-22-flock-fd9-reuse-releasing-lock
- Patterns captured: bash-set-e-arithmetic-trap, hook-paths-must-be-absolute, unset-claudecode-nested-cli
- Project: projects/jobs-apply/_index : 4 interactive sessions; investigated domain-config.ts; debugged job huntr trace behavior; 69 code-review sessions
So What (Why Should You Care)
The accumulate-then-flush pattern solves a rate problem that’s easy to overlook when designing hook systems: the semantic unit of work is not a single file write. During a refactor, 20 files change in 2 minutes : triggering 20 individual documentation reviews produces noise and wastes API budget. Accumulating those events into a batch and treating the batch as one documentation unit produces signal. This is the same principle behind database batch inserts, log aggregation buffers, and metrics flush intervals. Whenever you have a high-frequency event stream feeding an expensive downstream operation, accumulate-then-flush is the architectural pattern that keeps costs proportional to semantic work, not raw event volume.
The 4-layer JSON validation (jq → python3 duplicate keys → nesting/mixed arrays → schema) deserves more attention than it usually gets. Most JSON validation stops at syntax. But syntactically valid JSON can be semantically broken in ways that cause silent data corruption: duplicate keys (last value wins : silently overwriting earlier values), mixed arrays (arrays where some elements are objects and some are primitives), and schema violations (required fields missing or wrong types). Each layer catches a class of error the previous layer misses. None of them are redundant.
The content-hash-dedup pattern for preventing review loops is the complement to accumulate-then-flush. Without it, saving a file without changing its content would trigger a documentation review on unchanged code. With it, the review system compares the hash of the current content against the hash it last reviewed : and skips if nothing changed. Together, the two patterns mean documentation reviews fire exactly when they should: after a logical unit of work, on content that actually changed.
The 26 CodeGuard v2 fixes (W1-W26) also tell a story about the difference between v1 (proof of concept) and v2 (production reliability). The fixes address timeout handling, linter reliability, deduplication, and observability : the categories that only become visible after sustained real-world use. You can’t test for these in a demo. They emerge from running the system hundreds of times and watching it fail in unexpected environments.
What’s Next
- Validate accumulate-then-flush behavior under real refactor workloads
- Monitor CodeGuard v2 reliability improvements from the 26 fixes
Log
- projects/peon-notify/_index v1.0.0 shipped
- CodeGuard v2 audit: 26 fixes (W1-W26) covering linter reliability, file guards, AI review hardening, observability, validation, dedup, timeout, blocking mode
- DocGuard hook built with accumulate-then-flush architecture for auto-documentation
- Deep JSON validation (4-layer): syntax (jq), duplicate keys (python3), nesting/mixed arrays, schema
- YAML and TOML validation added
- Language-specific review prompts for all 7 languages
- Patterns captured and wikilinked: bash-set-e-arithmetic-trap, hook-paths-must-be-absolute, unset-claudecode-nested-cli
- Bugs fixed: 2026-03-22-macos-cooldown-timestamp-corruption, 2026-03-22-codeguard-session-id-always-unknown, 2026-03-22-codeguard-76-percent-killed-by-timeout, 2026-03-22-flock-fd9-reuse-releasing-lock
- projects/jobs-apply/_index: 4 interactive sessions : reviewed project state, investigated domain-config.ts, debugged job huntr trace
- 69 automated code-review sessions