Coding standard for hook/compose-style tooling: never fail silently; parse defensively; gate writes by installed compatibility; and make transient failures self-healing. Diagnostics must only fail on real faults (e.g., stale markers), not normal in-flight states.
Apply: 1) Normalize & parse defensively
const t = toolResult.trim();
const m = t.match(/^Created the (.+) file\.$/);
field: [] and block lists; don’t rely on a regex that only matches one form.2) No silent no-ops: log “can’t apply” cases
if (!hasField(content, 'produces')) {
recordDrop(`contribution to ${target}: no 'produces:' field; adds dropped`);
return content;
}
3) Compatibility gate writes by installed schema
4) Make transient failures recoverable
5) Health/doctor outputs: fail only on real faults
pass accordingly (fresh = pass, stale = fail). This prevents false red CI runs.
const pass = ageMs <= COMPOSE_MARKER_TTL_MS; // fresh advisory ok
results.push({ pass, message: pass ? 'fresh' : 'stale' });