Awesome Reviewers

When implementing idempotency or caching via markers/ledger “done” signals, treat cached state as valid only if (a) the key reflects the content/version being applied and (b) the signal is scoped to the current execution context.

Apply these rules: 1) Key by content/version, not just identity.

2) Scope “done” signals to the current run window.

3) Detect same-key conflicts and don’t fail silently.

Example (marker replacement with hash):

const markerOpen = `<!-- plugin:${bundle}:${anchor}:${order}:${hash} -->`;
const markerClose = `<!-- /plugin:${bundle}:${anchor}:${order}:${hash} -->`;

// When the marker exists with a different hash, replace the whole block.
// When the marker exists with the same hash, skip (true idempotency).

Example (scoping cached convergence by stage start):

// Only consider SWARM_UNIT_CONVERGED rows emitted after the current stage-run start.
const since = latestStageStartedAt;
const rows = auditRows.filter(r => r.type === 'SWARM_UNIT_CONVERGED' && r.at >= since);
const converged = new Set(rows.map(r => r.unitName));

Result: upgrades land correctly, re-runs don’t get incorrectly skipped, and collisions are visible—avoiding the two most common “stale cache” failure modes shown here (perma-skip on upgrade, and reuse of historical convergence across re-entry).