← Book Writer case study

Interactive engineering example · October 7, 2026

Protect the manuscript.

An AI revision can read smoothly while losing a code example. Try the failure cases below and see when the original section is retained.

A standalone teaching adaptation of Book Writer’s guard-and-fallback approach. The text and candidate replies are synthetic. All checks run in your browser, with no model call or manuscript upload.

1. Choose a candidate reply

A missing example rejects the entire candidate section and retains the original.

2. Inspect the decision

Original retained — candidate rejected

  • ✕ Code markers occur once, in order
  • ✓ Heading levels and count are retained
  • ✓ At least 50% of the masked section remains
  • ✓ No new code fences bypass the markers
Inspect resulting manuscript
## Restore a document

Keep the original section until its replacement is ready for review. Preserve the examples so a wording change cannot silently remove the runnable steps.

```python
print("restore original")
```

### Verify the result

Check the result before accepting it. Structure checks help detect lost content, while a person still reviews meaning and technical correctness.

```python
assert 2 + 2 == 4
```

3. Reproduce the checks

Download both files into one folder, then run the command with Node.js 20 or later. Eight tests cover the presets, unknown/reordered markers, original fallback, and unchanged code restoration.

node --test guard.test.mjs

Browse public example source ↗

What this demonstrates

Book Writer’s reviewed Python implementation masks code, retains a section when code markers disappear, and applies heading and length checks in its revision helpers. Different stages use different length thresholds.

This smaller JavaScript example combines checks into one rule, uses a 50% masked-length threshold, and additionally rejects duplicated or reordered markers. It is not a port of every runtime path or a full Markdown parser.

Passing structure checks does not establish factual accuracy, translation quality, safe code, or measured time savings. Select “Meaning changed” to see why author review remains necessary.

My independent work: revision workflow, retrieval, checkpoints, and manuscript protection. Applied to two technical books; this demo is newly prepared for public inspection. Explore the books →