#2271·LifeOS

isa-utils appendDecisionRow: string replacement expands $1/$2 inside ISA text, shredding the Decisions block on auto-resume

Author: jacobo-ortizCreated Oct 1, 2026Updated Oct 1, 2026

File: LifeOS/install/hooks/lib/isa-utils.ts (current main), appendDecisionRow()

What happens: when an ISA in phase: complete gets a body edit, the Resume-After-Complete path calls appendDecisionRow(), which rebuilds the ## Decisions block with a string replacement:

typescript
return content.replace(decisionsRe, `${match[1]}${match[2].trimEnd()}\n${row}\n${match[3]}`);

In a string replacement, $1, $2, $&, $`, $' and $$ are special. The ISA's own Decisions text is interpolated into that string, so any decision that mentions a price or amount written with a dollar sign ($2,000,000, $1 per unit, very common outside the US where $ precedes local currency) is expanded as a capture-group reference. The block gets duplicated and shredded, silently, on every auto-resume.

Repro:

typescript
const isa = "# X\n\n## Decisions\n\n- D4: $2,000,000 in two payments of $1,000,000.\n\n## Changelog\n\n- x\n";
appendDecisionRow(isa, "T", 2); // returns 15 lines with "## Decisions" twice; expected 11 lines

Fix: pass the replacement as a function so nothing is interpreted:

typescript
return content.replace(decisionsRe, () => `${match[1]}${match[2].trimEnd()}\n${row}\n${match[3]}`);

Same class, one sibling: hooks/handlers/DocCrossRefIntegrity.ts, applyInferenceEdits(), does content.replace(edit.old_text, edit.new_text) with model-generated new_text; with a string pattern $&, $`, $' and $$ still apply. Same fix: content.replace(edit.old_text, () => edit.new_text).

Other .replace() calls in hooks/ that interpolate only numbers, timestamps or HOME are not affected.