# Continuation Prompt — REBOL/View 2.7.8.3.1 Clone (`demo28`)

Paste the short start prompt at the bottom into a fresh **pi** session on this
VPS.  This file is the detailed handoff.  It is self-contained; all history is
preserved in this repo (see §11).

---

## 1. Mission and current status

We are building a **functional clone of REBOL/View 2.7.8.3.1 (Win32)** by
reverse-engineering the original executable with **REA**.  Work lives in
`/root/rebol-view-clone/`.  The clone is a clean-room C interpreter that loads
the original R2 boot image/mezzanine/View-Desktop source recovered from the
reference EXE.

Current state (build marker **demo28-2026-11-14**):

- **Golden conformance suite: 84/84 passing on native Linux and 84/84 on the
  Windows PE build under Wine.**
- **re-bol.com corpus:** 325 extracted snippets, 20 sections, **0 errors**,
  all sections complete (no timeouts/no-result) on Linux and Wine.  Five
  non-runnable paragraphs are explicitly skipped (infinite console app,
  invalid `parse` example, incomplete PORTS snippet, MySQL/SQLite GUI
  examples needing external servers).  See `examples-corpus/REPORT.md`.
- **The 10-app demo (`examples/demo.r`) works for the local apps:** Paint
  (freehand draw, Save to PNG, Clear), Game (rate-driven board/keys, clean
  SCORE alert), Puzzle (visual tile swap), Calendar (`request-date`, month
  arrows, selected date) and Days (two real dates → computed days).  Sounds
  opens and lists `C:\Windows\media`; clicking a row `load`s the WAV,
  plays it through the real `sound://` port, waits for its duration and
  closes.  HTTP redirects, `load http://` images, FTP (list/read/write/
  `dir?`), POP3/IMAP mailbox reads and SMTP `send` are implemented; the
  themed `request-list`/`request-dir` popups navigate/select correctly; the
  editor Find dialog focuses its field and Enter runs field actions; Windows
  close/`unview/only` remove only the intended window.  Video/Email/FTP still
  need live external sites/credentials and IPs reads an external CGI page.
- Published (see §9 for versioned URLs):
  - `rebol-view.exe` / `rebol-view-demo28-2026-11-14.exe`
    - 1003520 bytes
    - sha256 `0a8772ed018e010e01a7d050cd49b8243eac697914445d9da7d94c27343e240d`
  - `rebol-view-2-clone.zip` / `rebol-view-2-clone-demo28-2026-11-14.zip`
    - 1225225 bytes
    - sha256 `49896178c57fd245fb911843da4dfab2ecce9b6bc4664ac699b5d1e7d3fa199a`
- Reference oracle: `reference-rebol-view-278-3-1.exe`
  (sha256 `215e28f9660472b6271a9902573c9d190e4d7ccca33fcf8d6054941d52a3ab85`).

**Verify the binary before debugging user reports:** `rebol-view.exe -v`
must print:

```
REBOL/View 2.7.8.3.1 (demo28-2026-11-14)
```

If the marker is missing, the user is running an old/cached download.  Always
publish **uniquely versioned filenames** (`…-demo28-2026-11-14.exe`) in addition
to the stable name; browsers/CDNs cache the stable URL.

Always establish a baseline first:

```bash
cd /root/rebol-view-clone
python3 tests/tools/run.py test          # Linux clone
python3 tests/tools/run.py test --wine   # Windows PE under Wine
python3 tools/examples_sections.py       # corpus sweep
```

Expected: `84/84 passed` both modes; corpus `20 sections errors: 0`; and
`python3 tools/examples_smoke.py [--wine]`, `python3 tools/net_smoke.py
[--wine]`, `python3 tools/ports_smoke.py [--wine] [--mix]` and
`python3 tools/gui_shots.py` all PASS.

---

## 2. Key paths

```
r2clone/                     C interpreter clone (Linux `r2` + Windows objects)
  reb.h value.c scan.c eval.c native.c port.c view_win.c net.c ffi.c
  main.c image.c draw.c hash.c zlib.c boot_image.c modules.c
  vendor/zlib/               vendored zlib 1.2.11 deflate (Z_SOLO/NO_GZIP)
  stb_image.h font8x8.h Makefile
reference-rebol-view-278-3-1.exe   original R2 oracle
r2-extracted/                21 recovered REBOL source modules
downloads/                   copies of the current exe/zip/sha256 for browser download
                             (mirrored through pi-web's /api/files/<path>?type=download)
tests/                       84-case golden suite: cases/, expected/, fixtures/, tools/run.py
tests/README.md              suite usage + R2 quirks (READ THIS)
examples/demo.r              the 10-app Paint/Game/Puzzle/... demo
examples/ports.r             loopback TCP/UDP/file/console port demo
examples/{hello,tour,gui,draw,effects}.r
tools/examples_corpus.py     fetch/extract/validate the re-bol.com examples
tools/examples_sections.py   replay the examples section by section
tools/extract_boot.py        reproducible boot-image extractor
tools/net_smoke.py           local HTTP/FTP/POP/SMTP/IMAP smoke test
tools/ports_smoke.py         two-party port harness (clone<->reference TCP/UDP/awake)
tools/gui_shots.py           GUI screenshot regression (tests/gui -> tests/gui-baseline)
tests/gui/                   static VID layouts used by the screenshot harness
tests/gui-baseline/          expected screenshots (widgets, image effects, text list)
tools/examples_smoke.py      run every examples/*.r (native + Wine GUI)
examples-corpus/             cached examples.txt, cases/, index.json, REPORT.md
dist-r2/                     shipped package (exe + sources + tests + docs + zip)
docs/history/                preserved prompt/report snapshots (do not delete)
debug/                       instrumented demo harnesses used for GUI debugging
evidence/                    REA evidence bundle
README.md                    project overview
REVERSE-ENGINEERING.md       method + coverage + known gaps
HANDOFF-PROMPT.md            historical state / bug list / earlier fixes
CONTINUE-PROMPT.md           this file
START-PROMPT.txt             short prompt for a new session
/root/download/              Caddy-served static directory (published files)
```

---

## 3. Build

### Linux (native, default test mode)

```bash
cd /root/rebol-view-clone/r2clone
make clean && make                      # produces ./r2
```

`make clean` is mandatory (limited header dependencies).  The Makefile builds
the vendored zlib objects and links `-lm -ldl`.

### Windows PE32 (mingw-w64, used by `--wine`)

```bash
cd /root/rebol-view-clone/r2clone
for f in value scan eval native port view_win net boot_image modules main image draw hash zlib ffi; do
  i686-w64-mingw32-gcc -O2 -std=gnu99 -c $f.c -o /tmp/rel-$f.o
done
for f in deflate trees adler32 crc32 zutil; do
  i686-w64-mingw32-gcc -O2 -std=gnu99 -DZ_SOLO -DNO_GZIP -Ivendor/zlib \
    -c vendor/zlib/$f.c -o /tmp/rel-z-$f.o
done
i686-w64-mingw32-gcc -O2 -s -o /tmp/rebol-view.exe /tmp/rel-*.o \
  -lm -luser32 -lgdi32 -lwinhttp -lws2_32 -lmsimg32 -lcomdlg32 -lshell32 -lwinmm
```

- `port.c`, `ffi.c` and the five vendored zlib sources **must** be included.
- `-lws2_32` is required for `dns://` (Winsock); `-lwinmm` is required for
  `sound://` (`PlaySoundA`).
- `rebol-view.exe -v` prints the build marker; keep `R2CLONE_BUILD` in
  `reb.h` bumped for each published change (currently `demo28-2026-11-14`).

Run the PE under Wine (Xvfb for GUI):

```bash
WINEPREFIX=/root/.wine32 WINEARCH=win32 WINEDEBUG=-all \
  xvfb-run -a /usr/lib/wine/wine /tmp/rebol-view.exe -s Z:/tmp/script.r
```

---

## 4. Golden-output suite (primary oracle)

`tests/cases/*.r` are deterministic R2 scripts (no REBOL header, no quit).
`tests/expected/*.txt` are generated by the **reference** under Wine.

```bash
python3 tests/tools/run.py test            # Linux clone
python3 tests/tools/run.py test --wine     # Windows PE under Wine
python3 tests/tools/run.py test --diff
python3 tests/tools/run.py test --only 64 --diff
python3 tests/tools/run.py gen             # generate missing goldens (oracle)
python3 tests/tools/run.py gen --all       # regenerate every golden
```

The runner wraps cases with a `print`/`prin`/`probe` capture layer and
`either error? try [...]` (use this form: R2 re-raises an error stored in a
word).

Critical R2 quirks (see `tests/README.md` for the full list):

- `try` does **not** catch “has no value”; a case with an undefined word drops
  the reference into its error console and times out.  Only use words R2
  defines; define your own `charset`s (`alpha`/`digit` are unset globals).
- Tuples hold at most 10 components and preserve their length; dates are
  ordered `[year month day]`; times `[hour minute seconds]`; binary bytes are
  integers; image pixels are tuples.
- `parse` without `/all` skips whitespace.  `parse/all s delimiter` splits.
  `parse set` on **string** input is an R2 error; `copy` works on strings and
  blocks; both create previously undefined words in their binding context.
- `checksum/hash` requires its `size` argument.  `compress` is zlib level 6
  + 4-byte little-endian length.  `random n` → 1..n, pair → 1..n per
  component, tuple → 0..n-1.
- `make routine!`/`make struct!` require datatype spelling (`integer!`, not
  `integer`); struct fields are packed; `mold :routine` is `routine`.
- `view`/`view/new`/`layout` need a real View renderer (Windows PE under
  Wine/Xvfb); the Linux build's `layout` is a stub (GUI cases still pass via
  the editor path).
- Don't use `now`, `random`, `alert`, `request-*`, `editor`, network or
  `view` in golden cases unless the case is specifically about them and
  deterministic.

Cases 56–69: `56-ffi-library`, `57-draw-aa`, `58-first-series`,
`59-compress-zlib`, `60-random-types`, `61-object-globals`, `62-dns`,
`63-parse-copy-new`, `64-file-change-dir`, `65-sound-load`,
`66-text-list-pane`, `67-file-series-ops`, `68-draw-arc-pattern`,
`69-operator-function-calls`.

Case 84 (new in demo27, extended in demo28) pins **formatted MOLD**: loaded multi-line blocks
keep their line breaks (space + newline + 4 spaces per level; a multi-line
block closes on its own line), `load "1 2 3"` molds with a trailing newline,
parens behave the same, markers survive `copy`/`reduce`/`compose`, and a
function body written across lines molds that way.  Nested blocks keep a
leading break only when the block does not start the line (`[if true [^/x: 1]]`
indents `x: 1`, `[[^/1 2]]` does not).  Implementation: a per-element marker
array in `Series` (`nl`) maintained by the loader, the series ops and MOLD,
with the indentation computed from an explicit block depth; `copy`/`reduce`/
`compose` carry the markers.  Known cosmetic limit: one `stylize`-built style
object (the scroller feel) still molds without its breaks.

Case 83 (demo26) pins the **script path**: `what-dir` is absolute
(R2's `%/Z/dir/` form on Windows), a directory, starts/ends with a separator
and is unchanged by `dirize`; file create/read/delete relative to it are
checked.  Cases must not `change-dir` (the harness writes its result file
relative to the script path).

Case 82 (demo25) pins `size-text` against the embedded Arial metric
table measured from the reference (single characters at several sizes, short
strings, multi-line text and the line heights 8..48).  Long strings are not
asserted: R2's inter-character spacing (≈2 px per gap, sometimes 3) cannot be
derived from single-character probes, so long text may be off by a few
pixels.  If you need exact long-line widths, probe the full string from the
oracle and extend the table.

The **GUI screenshot regression** (`tools/gui_shots.py`, new in demo24)
renders `tests/gui/*.r` under Wine/Xvfb, crops the clone's window and diffs
it against `tests/gui-baseline/*.png` (Pillow; a shot fails when >2% of pixels
differ by more than 12/255 per channel, tolerating Wine font antialiasing).
`--update` rewrites the baselines after intentional rendering changes; add a
new `tests/gui/*.r` layout whenever you touch the renderer.

Case 81 (demo23) pins READ/WRITE with **port specs** (block or
object with `scheme`/`target`): file create/read through a spec, `/binary`
and `/lines` with a spec, `write/append` through a spec, spec reuse, and
`form` of the spec block.  `tools/net_smoke.py` now also exercises HTTP and
FTP block specs (including an FTP write).  Related fix: `form` of
set-word/get-word/lit-word/refinement values now yields the bare name (R2:
`form [a: :b 'c /d]` = `"a b c d"`; `mold` keeps the marks).

Case 80 (demo22) pins the pixel-transforming effects with
`checksum to-binary` of `to-image` of layout faces: `blur`/`sharpen`
(3x3 convolutions, R2 kernels, truncated, edge-clamped), `luma`, `multiply`,
`key`, `crop`, all flips/rotations (including the reference's odd-size 180°
centre-pixel quirk) and one chained geometry+colour combination.  Do **not**
chain two convolutions in one effect block — the reference's second pass
reads a different buffer and the result diverges.

Cases 78–79 (demo21) pin the image side: `78-image-mold-binary`
(mold/form/to-string of images, alpha-block rule, 10-pixel lines, 32-byte
binary wrapping, `to-binary` byte order) and `79-face-effects` (flip axes,
rotate 90/180/270, invert, grayscale weights, key, crop, chained effects,
sampled by `to-image` corner pixels).

Cases 76–77 (demo20) pin the port event model:
`76-port-awake-accept` (awake called with the port, once per wait, the
returned port and its fields, timeout returns `none` without firing) and
`77-port-awake-read` (data and EOF arrive as separate read events, `copy`
returns data then `none`, two events counted).  Write port cases so the
**client** closes first, otherwise the listener port lands in TIME_WAIT and
the next run cannot always rebind it.

Cases 70–75 (demo19) pin the generic port system:
`70-port-object-model` (mold/form of a listener, port fields, close flags),
`71-tcp-client-server` (listen/accept/connect, wait results, copy + EOF),
`72-udp-port` (datagrams, local-ip, flags), `73-file-port`
(`open/new`, `open/read`, `length?`, `status`), `74-port-read-io`
(`read-io`/`write-io` byte counts and appending) and `75-port-wait-errors`
(`wait` timeout, `wait/all`, `first` on a non-listener raising, failed
connect raising).  Port cases must be self-contained loopback scripts; see
`tests/README.md` for the rules (close every port, write then **close** to
flush in R2, use `copy` not `read`, never set `port/state/misc` on a port
you then close).

---

## 5. re-bol.com example corpus

Source: <https://re-bol.com/examples.txt> (638 KB).  325 snippets extracted;
replayed by document section.

```bash
python3 tools/examples_corpus.py fetch
python3 tools/examples_corpus.py extract
python3 tools/examples_corpus.py validate
python3 tools/examples_sections.py
python3 tools/examples_sections.py --section "LANGUAGE" --detail
python3 tools/examples_sections.py --wine --section DRAW
python3 tools/examples_sections.py --timeout 180
```

How it works (do not regress these harness behaviours):

- The prelude stubs interactive/GUI words (`alert`, `request-*`, `editor`,
  `browse`, `view` → `layout`, `wait`/`do-events` no-ops, deterministic
  advancing `now`).  Loops are capped by the clone's native
  **`R2_LOOP_LIMIT=1000`**, not by overriding `repeat`/`loop` (overriding
  `repeat` broke its loop-variable binding).
- Each snippet is wrapped in `try`/`catch`; failures report
  `ERROR: <id> <arg1> <code>` with `--detail`.
- The runner writes the result to an **absolute** path (`write to-file
  {/tmp/…/result.txt}`), so snippets that `change-dir` cannot hide it.
- Network/interactive-port snippets (`http`/`ftp`/`tcp`/`udp`/`console://`/
  `sound://` …), control-flow (`exit`/`return`/`break`), and the interactive
  `echo`+`editor` Quick Manual are skipped.  (The clone now implements
  `sound://`; the harness still skips those snippets because they reference
  media files outside the corpus or mixed network code.)  Skipped snippets
  still emit a marker so the section completes.
- No remaining corpus errors.  Five non-runnable paragraphs are explicitly
  skipped: an infinite interactive console app, an invalid `parse` example,
  an incomplete PORTS snippet, and MySQL/SQLite GUI examples that need a
  running database server/driver.  The remaining NETWORK PORTS snippets are
  one half of a client/server pair or need broadcast chat/external servers,
  so they stay skipped as single snippets; `examples/ports.r` covers the
  single-process behaviour and `tools/ports_smoke.py` covers the two-party
  (client/server) behaviour, including against the reference binary.
- `examples-corpus/REPORT.md` is the current report; update it after every
  sweep if the counts change.  Error detail now reports the missing word
  (`no-value an-integer`) rather than a generic `not-defined`.

---

## 6. What is implemented / recent history

The clone loads the recovered R2 boot image, mezzanine library, Internet
Protocols, Graphics/Draw, View/VID and View Desktop modules.  It implements:

- Core language, series/blocks/strings/binary/files, objects, functions,
  refinements, `parse` (including `/all`, `into`, `copy`/`set`, `to`/`thru`),
  dates/times/money/tuples/pairs, codecs (`enbase`/`debase`, zlib
  compress/decompress, all `checksum` variants), bitsets.
- **DLL FFI** (`clone-source/ffi.c`): `load/library`, `make routine!`,
  `make struct!`, `free`; Win32 `LoadLibraryA`/`GetProcAddress`/`__stdcall`,
  POSIX `dlopen`; structs integer!/char!/logic!/decimal!/string!/pair!.
- **Anti-aliased DRAW** (`draw.c`): AGG-style coverage, lines, polygon,
  triangle, circle/ellipse, curve, spline, **arc**, **line-pattern**,
  caps, `anti-alias`; `emboss` effect; `arrow` effect for the Calendar.
- **Compress byte parity**: vendored zlib 1.2.11 deflate, level 6 + R2 length.
- **DNS**: `read dns://` (local host name), `read dns://host` (IP).
- **Network schemes** (`net.c`): HTTP redirects, `load http://` image/sound
  decode, passive-mode FTP (`read`/`read/binary`/`read/lines`/`write`/
  `dir?`, MLSD + LIST fallback), POP3/IMAP mailbox reads (blocks of message
  strings, POP dot-unstuffing, IMAP literals) and SMTP sending (`send` and
  direct ESMTP ports, AUTH PLAIN/LOGIN).  `tools/net_smoke.py` verifies
  them with local servers on Linux and Wine.
- **`sound://` + WAV codec** (`native.c`): `load` of RIFF/WAVE returns the
  reference sound object (`type/rate/channels/bits/volume/data`),
  `open sound://` returns a `port!`, `insert` plays (`PlaySoundA` with
  `SND_MEMORY|SND_ASYNC`), `wait` waits the duration, `close` stops.
- **Images**: `mold`/`form`/`to-string` of an image reproduce R2's
  `make image! [WxH #{rgb} #{alpha}]` (10 pixels/line, alpha block only when
  needed); `to-binary` gives the raw `B,G,R,A` bytes; face image effects
  `flip` (axes), `rotate 90/180/270`, `invert`, `grayscale`, `key`,
  `colorize`, `crop`, `luma`, `multiply`, `blur`, `sharpen` run through one
  portable filter shared by the window renderer and `to-image` (R2 kernels
  and the odd-size 180° quirk).  Gaps: `contrast`, `tint`, `hsv`, `reflect`,
  `merge`, `grid`, `shadow`, `scale`, `extend`, `aspect`/`fit` placement,
  and chained convolutions (some are no-ops or size-dependent in the
  reference too).  `hline`/`vline`/`shape`/`fill-rule`/`matrix` are
  accepted-but-ignored by R2 itself, so nothing to implement there.
- **Port specs**: `read`/`write` accept a block or object spec
  (`scheme`/`host`/`port-id`/`user`/`pass`/`target`/`path`); file specs read
  and write files, other schemes build the URL, `tcp`/`udp`/`console` go
  through the port layer.  Spec blocks are evaluated **key by key** (each
  `key:` value is an expression, matching R2), and TCP connects are bounded
  (non-blocking connect, 10 s) so a dead host fails instead of hanging.
  `form` of words fixed (bare names; mold keeps marks).  The corpus harness
  also skips `scheme: '<net-scheme>` specs (external services).
- **Generic ports** (`port.c`): `open` of `tcp://`, `udp://`, `file://`,
  `console://` (URL/file/block/object specs, all R2 refinements) creates a
  real `port!` with R2's 45-field spec, `mold`/`form`, `state` object and
  port numbering; `insert`/`write` (TCP, UDP incl. broadcast, `/lines` CRLF),
  `copy`/`read` (buffered, EOF → `none`, `copy/part`, `/binary`, `/lines`,
  `/direct`/`/seek`), `first` (accept), `wait`/`wait/all` (+timeouts),
  `close`, `read-io`/`write-io`, `length?`, `get-modes`/`set-modes`,
  `port/timeout`.  **Event model**: `port/awake` is called with the port
  itself, once per `wait` that includes the port (before `wait` returns);
  `wait/all` dispatches every ready port and returns a block; timeouts return
  `none` without firing; EOF is a read event (`copy` → `none`);
  `wait <time>`/`wait []` do not process port events (matching the
  reference).  `examples/ports.r` is the loopback demo (identical output on
  the reference); `tools/ports_smoke.py` cross-tests TCP/UDP/async servers
  against the reference in both directions.
- **View/VID engine**: recovered View Desktop styles, native controls,
  canvas faces, nested panes (block/object/function, incl. TEXT-LIST/LIST
  rows with selection highlight + row actions; request-list/request-dir),
  file/url/tag series ops (`first`/`last`/`length?`/`pick`/`find`/`remove`/
  `copy`, `path/:file`), Find-dialog field focus, Enter-to-run field actions,
  `unview/only`/`unview/all`, rate/time events, popup-aware
  `wait []`, modal alert timer guard, face-relative mouse offsets, per-move
  `over`, window placement at `face/offset`, activation/raise, control
  repositioning after actions.
- **`to-image` of a face** and **`save/png`** (valid RGBA PNG).
- **Port quirks**: R2 only flushes TCP writes when the writing port is
  closed or the event loop runs; `copy` on a file port returns the whole
  buffered image each time; `read port` raises in R2 (the clone returns the
  data — a deliberate deviation); setting `port/state/misc` then `close`
  hangs the reference (avoid in cases).
- **R2 file paths**: relative values resolve against `system/script/path`
  (set by `change-dir`), Windows `%/c/...` maps to `C:`; `to-file` is
  NUL-terminated (fixed a corrupted long-path bug).
- Script header title when a script is **run** (`REBOL - Demo`); `load`
  only strips the header.
- `random` R2 ranges; clone style/feel functions keep global bindings;
  `get-func` is absent in R2 2.7.8.3.1 (use `make routine!`).
- **Examples/text corpus fixes**: operators `+ - * /` no longer mutate the
  underlying `add`/`subtract` Func objects (so `++`, `--`, `add` as a function
  and `set word add ...` work); `paren?` exists; `get`/`set` use normal word
  args; requestor stubs match R2's refinement-only specs; corpus fixtures
  supply `form1.db`, `time_sheet.txt`, `employees`; `verbalize` is supplied
  as document context.  `tools/examples_smoke.py` runs every bundled example.

Important historical context: `docs/history/` contains snapshots of the
previous handoff/report; `HANDOFF-PROMPT.md` has the older bug list; the
recovered source is in `r2-extracted/`.

---

## 7. Current demo status and next priorities

`examples/demo.r` (the 2890-character 10-app demo):

**Working:** Paint (draw, Save PNG, Clear), Game (board, RATE timers, arrow
keys, SCORE alert + clean unview), Puzzle (visible tile swap), Calendar
(`request-date`, month arrows, selected date window), Days (real dates →
computed days).  Menu/window placement, focus and input are fixed.

**Working:** Sounds (`C:\Windows\media` list, `sound://` WAV playback,
text-list row selection/actions and nested-pane rendering).

**Working:** FTP app (`dir?`, listing, read, file editor/upload), Email
(POP3/IMAP mailbox reads) and `send` (SMTP) against real servers; Video
follows HTTP redirects and `load`s the image URL.

**Partial:** Network apps still need live external sites/credentials: IPs
reads an external CGI page (DNS works; the page currently returns 500) and
Video's tinyurl target can disappear.

**Priority order for next work:**

1. **Draw effects completion**: `contrast`/`tint`/`hsv` pixel math (the
   reference works in a YIQ-style chroma space; `tint` looks like a hue
   rotation, `contrast` scales luma+chroma — derive the integer formula),
   `scale`/`extend`/`fit`/`aspect` placement parity for faces whose size
   differs from their image, `merge`/`grid`/`tile-view`, `reflect`/`shadow`,
   and the chained-convolution buffer quirk.
   high-level schemes (a REBOL-level `open http://` port with an awake
   handler, `port/spec`-style block targets), `query`/`get-modes` for file
   ports, `port/async-modes`, and running the book's two-party GUI snippets
   (messenger, binary file transfer, UDP chat) end to end with the ports
   harness.
3. **Editor/requestor polish**: visible Find highlight/scroll, live filters,
   themed request-file fallback, request-list/dir keyboard/multi-select.
3. **DRAW/effects completeness**: exact AGG gamma/subpixel parity, line-join
   on all paths, remaining draw commands/effects (`hline`, `vline`, `shape`,
   `fill-rule`, `matrix`, `image-filter`, blur/sharpen/crop/flip/multiply/
   add/mix/hsv/grayscale/contrast/reflect/etc.).
4. **Network depth**: TLS for FTP/POP/IMAP/SMTP, SMTP CRAM-MD5/MIME edges,
   HTTP chunked/proxy/HTTPS on Linux, IMAP folders/search/flags.
5. **Memory reclamation**: series/context/function refcounts, window/control
   teardown; ASan first.
6. **Language fidelity edge cases**: typed parse actions, `copy/part`,
   `find/with`, `select/part`, secure/error-console formatting.
7. **GUI screenshot regression** (Xvfb + xdotool + image compare) and more
   local-server corpus coverage (a two-party port harness).

---

## 8. Debugging tips (learned the hard way)

- **Old downloads**: always verify `-v` shows the current marker.  Publish
  both stable and versioned names; the stable URL can be browser/CDN cached.
- **Stale Wine processes**: `pkill -x wine` does **not** kill
  `rebol-view.exe`.  Use `pkill -x rebol-view.exe`, `pkill -x wine`,
  `pkill -x Xvfb`, `pkill -x matchbox-window` (never `pkill -f` with a
  pattern matching your own shell command).
- GUI recipe (no window manager gives real window positions; matchbox
  maximizes and can confuse click coordinates):
  ```bash
  pkill -x rebol-view.exe; pkill -x wine; pkill -x Xvfb; pkill -x matchbox-window; sleep 1
  Xvfb :99 -screen 0 1280x1024x24 -ac & sleep 2
  # optional: DISPLAY=:99 matchbox-window-manager & sleep 1
  WINEPREFIX=/root/.wine32 WINEARCH=win32 WINEDEBUG=-all DISPLAY=:99 \
    timeout 120 /usr/lib/wine/wine /tmp/rebol-view.exe -s Z:/path/demo.r &
  sleep 16
  DISPLAY=:99 xwininfo -root -tree | grep REBOL       # window ids/positions
  DISPLAY=:99 ffmpeg -y -f x11grab -video_size 1280x1024 -i :99 -frames:v 1 /tmp/shot.png
  DISPLAY=:99 xdotool mousemove X Y click 1
  ```
  Screenshots are the quickest way to see window placement/controls.
- Enable `R2_VIEW_DEBUG=1` for `[view]`/`[key]`/`[timer]`/`[repos]` traces
  (PE stdout must be flushed; redirect to a file).
- `R2_TRACE=1` prints the `near` context for Linux script errors;
  `R2_SKIP_VIEW=1` skips the View Desktop module; `R2_EXTRA_MODULE=/path.r`
  evaluates an extra module.
- ASan build:
  ```bash
  cd r2clone
  make clean && make CFLAGS="-g -O1 -std=gnu99 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function"
  ASAN_OPTIONS=detect_leaks=0 ./r2 /tmp/case.r
  ```
- If the reference hangs, it dropped into its error console (screenshot with
  ffmpeg).  R2's `try` does not catch “has no value”.
- R3 source (for checksum/CRC/hash algorithms): <https://github.com/rebol/rebol>
  (a copy may be at `/tmp/rebol-src`).

---

## 9. Packaging and publishing

After code/docs changes, run both suites and the corpus.  Then:

```bash
cd /root/rebol-view-clone
# bump R2CLONE_BUILD in r2clone/reb.h for a new release, rebuild the PE
# refresh dist-r2 docs/sources/tests (exclude .o files!)
make -C r2clone clean
cp /tmp/rebol-view.exe dist-r2/rebol-view.exe
cp README.md REVERSE-ENGINEERING.md dist-r2/
rm -rf dist-r2/tests && cp -r tests dist-r2/tests
rm -rf dist-r2/clone-source && mkdir -p dist-r2/clone-source
cp r2clone/*.c r2clone/*.h r2clone/Makefile dist-r2/clone-source/
cp -r r2clone/vendor dist-r2/clone-source/
mkdir -p dist-r2/tools
cp tools/examples_corpus.py tools/examples_sections.py tools/net_smoke.py tools/examples_smoke.py tools/ports_smoke.py tools/gui_shots.py dist-r2/tools/
cp examples-corpus/REPORT.md dist-r2/
cp examples/*.r dist-r2/examples/
# The prompts are published separately (dated copies + prompt bundle), never
# inside the package zip: they quote the zip's own hash.
cd dist-r2 && rm -f rebol-view-2-clone.zip && zip -qr rebol-view-2-clone.zip .
unzip -l rebol-view-2-clone.zip | grep -c '\.o$'     # must be 0
sha256sum rebol-view.exe rebol-view-2-clone.zip
```

Publish to `/root/download` (Caddy serves `https://download.xqx1.com/`).
The human-friendly landing page lives at
`/root/download/rebol-view-clone.html` (source copy: `docs/download-page.html`);
update its version, sizes and hashes on each release.  The continuation prompt
is published alongside it as a dated file and in a prompt/docs bundle:
`CONTINUE-PROMPT.md`, `START-PROMPT.txt`,
`rebol-view-clone-CONTINUE-PROMPT-YYYY-MM-DD.md`,
`rebol-view-clone-START-PROMPT-YYYY-MM-DD.txt`, and
`rebol-view-clone-next-session-YYYY-MM-DD.zip` (with a `.sha256`).

```bash
cp dist-r2/rebol-view.exe dist-r2/rebol-view-2-clone.zip /root/download/
cd /root/download
cp rebol-view.exe rebol-view-demo28-2026-11-14.exe
cp rebol-view-2-clone.zip rebol-view-2-clone-demo28-2026-11-14.zip
sha256sum rebol-view-2-clone.zip rebol-view.exe | tee rebol-view-2-clone.sha256
sha256sum rebol-view-demo28-2026-11-14.exe rebol-view-2-clone-demo28-2026-11-14.zip \
  | tee rebol-view-demo28-2026-11-14.sha256
```

Also mirror the release into the repo so it is downloadable from the Pi Web
browser (Pi Web serves any file under the session cwd):

```bash
mkdir -p /root/rebol-view-clone/downloads
cp dist-r2/rebol-view.exe dist-r2/rebol-view-2-clone.zip \
   /root/rebol-view-clone/downloads/rebol-view-demoN-YYYY-MM-DD.exe
cp dist-r2/rebol-view-2-clone.zip \
   /root/rebol-view-clone/downloads/rebol-view-2-clone-demoN-YYYY-MM-DD.zip
cp /root/download/rebol-view-demoN-YYYY-MM-DD.sha256 \
   /root/rebol-view-clone/downloads/
# refresh downloads/README.txt with the new names, links and hashes
sha256sum -c /root/rebol-view-clone/downloads/rebol-view-demoN-YYYY-MM-DD.sha256
```

Browser URLs (Pi Web requires the logged-in session):
`https://pi.xqx1.com/api/files/root/rebol-view-clone/downloads/<file>?type=download`.
Clicking the plain absolute path in a transcript opens Pi Web's file viewer,
which has a download button as well.

Then update **every** place with the new sizes/hashes/build marker:
`CONTINUE-PROMPT.md`, `HANDOFF-PROMPT.md`, `README.md` if counts changed,
`tests/README.md`, `dist-r2/README.txt`, and this file's §1.  Verify:

```bash
curl -s https://download.xqx1.com/rebol-view-demo28-2026-11-14.sha256
curl -s -o /tmp/pub.exe https://download.xqx1.com/rebol-view-demo28-2026-11-14.exe
sha256sum /tmp/pub.exe
WINEPREFIX=/root/.wine32 ... wine /tmp/pub.exe -v    # marker check
```

Do not ship `.o` files in `clone-source/vendor/zlib`; `make clean` before
copying.  Keep the versioned filename in the release notes/commands.

---

## 10. First actions in the new session

1. Read this file, `tests/README.md`, `examples-corpus/REPORT.md`, and
   `REVERSE-ENGINEERING.md` §6a/§7.  Skim `HANDOFF-PROMPT.md` and
   `docs/history/` for older context.
2. Run both baselines: `84/84` Linux and `84/84` Wine.  Run
   `python3 tools/examples_sections.py` and confirm 0 errors, all sections
   complete.  Run `python3 tools/examples_smoke.py`,
   `python3 tools/examples_smoke.py --wine`, `python3 tools/net_smoke.py`,
   `python3 tools/net_smoke.py --wine`, `python3 tools/ports_smoke.py --mix`,
   `python3 tools/ports_smoke.py --mix --wine` and
   `python3 tools/gui_shots.py`.
3. Verify `rebol-view.exe -v` shows `(demo28-2026-11-14)`; if not, rebuild
   with `make clean` and the full Windows loop.
4. Pick the top gap: **editor/requestor polish** (Find highlight/scroll,
   request-list keyboard, live filters — lock the result with
   `tools/gui_shots.py`), then the remaining DRAW effects
   (contrast/tint/hsv chroma math, scale/extend/fit placement,
   merge/grid/tile-view) and port depth.  Add a golden/corpus check where
   deterministic, fix, rerun both suites, the corpus, examples smoke and
   network smoke, update docs, bump the build marker, repackage with a new
   versioned filename, publish, and verify the live hash and `-v`.
5. Do not ask for permission between steps.  Preserve history: never delete
   `docs/history/`, `HANDOFF-PROMPT.md`, `r2-extracted/`, `evidence/`, or the
   reference oracle.

---

## 11. Preservation / where the history lives

- `docs/history/` — dated snapshots of the handoff, report and prompt.
- `HANDOFF-PROMPT.md` — historical state, older bug list and fidelity list.
- `REVERSE-ENGINEERING.md` — REA method, recovered-source analysis, coverage,
  known gaps.
- `README.md`, `tests/README.md`, `examples-corpus/REPORT.md` — current
  user/test/corpus docs.
- `r2-extracted/` — the 21 recovered REBOL modules.
- `evidence/` — REA evidence bundle.
- `dist-r2/` — the shipped package (sources, tests, docs, exe, zip).
- `/root/download/` — published artifacts and `.sha256` manifests.
- Create a snapshot tarball when handing off if desired:
  ```bash
  cd /root
  tar czf rebol-view-clone-snapshot-$(date +%Y%m%d).tar.gz \
    --exclude='rebol-view-clone/r2clone/*.o' \
    --exclude='rebol-view-clone/r2clone/r2' \
    rebol-view-clone
  ```

---

## Short start prompt

```
Read /root/rebol-view-clone/CONTINUE-PROMPT.md (and /root/rebol-view-clone/START-PROMPT.txt) and continue the REBOL/View 2 clone work from exactly where it leaves off. Baseline: 84/84 golden cases on Linux and Wine, examples.txt corpus 0 errors, all bundled examples pass, the port harness cross-tests against the reference and tools/gui_shots.py diffs the GUI against stored baselines. Next priority is editor/requestor polish (Find highlight/scroll, request-list keyboard), then the remaining DRAW effects (contrast/tint/hsv, scale/extend/fit placement, merge/grid/tile-view). Work autonomously: keep the golden suite, re-bol.com corpus, examples smoke and docs updated, rebuild and re-verify on Linux and Wine, bump the build marker, and republish versioned artifacts when appropriate. Don't ask for permission between steps.
```
