# DoorBench - full specification

Version 1.0 draft, 30 November 2026, corrected after stages 0 to 4. Author: Michael Slater.
"DoorBench" is a working name. One web search found no clash; a fuller check is due before the first public release (section 17).

**Must** is a requirement of version 1. **Should** may be dropped with a note in LIMITATIONS.md. **Later** is outside version 1.

Decisions already made:

1. The editor and engine are GPL-2.0-or-later, with an exception leaving authors free to license their game packs (section 15).
2. DOS is supported in version 1.
3. The example is an original goldfields prospecting game (section 14).

---

## 1. Purpose and scope

DoorBench lets a sysop with no programming experience design, test and package a multi-player BBS door game.

**In scope:** turn-based doors made of menus, places, tables, shops, fights, trading and daily events; many players sharing one world; DOS, Linux and Windows.

**Not in version 1:** real-time or graphical games; RIP or other non-ANSI graphics; running other programs; sockets or inter-BBS play; browser play; converting existing games into packs.

**Success test:** somebody who has never programmed follows the tutorial and gets a small two-player game, with a shop, a fight and daily maintenance, running on a BBS without writing script.

## 2. Terms

| Term | Meaning |
|---|---|
| Project | The folder of text sources an author edits |
| Pack | The one compiled file (`.DBP`) the engine runs |
| Engine | The programs that run a pack: play, maintenance, set-up |
| Installation | One folder on a BBS holding the engine, a pack and save data |
| Screen | An 80-column ANSI picture with live fields |
| Place | A point in the game: shows something, then offers choices |
| Handler | Blocks or script run when something happens |
| Record | One saved row: a player, the world, or a shared table row |
| Game day | The counter advanced by daily maintenance |

## 3. Parts

| Part | Name | Language | Runs on |
|---|---|---|---|
| Editor | `doorbench` | Rust, egui | Linux, Windows 10+ |
| Compiler | `dbc` | Free Pascal | Linux, Windows |
| Player door | `DBRUN` | Free Pascal | DOS, Linux, Windows |
| Maintenance | `DBMAINT` | Free Pascal | DOS, Linux, Windows |
| Sysop set-up | `DBSETUP` | Free Pascal | DOS, Linux, Windows |
| Test door | `dbtest` | Free Pascal | Linux, Windows; never shipped with a game |
| Simulator | `dbsim` | Free Pascal | Linux, Windows |

- The engine and `dbc` share their units for the pack format, record layouts, expressions and messages. There **must** be only one implementation of the game rules.
- The editor calls `dbc`, `dbtest` and `dbsim` as child processes. It never interprets a pack itself.
- Everything except the editor **must** build and pass its tests on a machine without Rust, such as web-main.
- Free Pascal 3.2.2 for all targets. A trial on 30 Nov 2026 built an existing door for all three systems on web-main with its present compilers.

### 3.1 Code reused

| From | Used for | Note |
|---|---|---|
| `doorkit.pas` + `doordos/doorunix/doorwin.inc` | Drop files, keys, ANSI, FOSSIL/UART, sockets | Start from Broken Seal's copy; compare with Ember Reach's and Long Wake's, which differ |
| `lsys.pas` | Small SysUtils replacement for DOS | |
| `erlock.pas` (Ember Reach), Long Wake's lock | Basis for locking | Reworked, section 8 |
| `dostest.py`, `integration.py` | DOSBox and pty tests | |
| TermBench, EditBench | Terminal pane, VGA font, themes, text editing | MIT, so usable in a GPL program with notices kept |

`doorkit.pas`'s `ConGetStr` is derived from Synchronet's GPL `dorkit.js`. It **must** be replaced by a newly written line editor, so that the section 15 exception covers the whole engine. `RunAttached` and the IGM code are removed. Provenance notes for the rest stay.

## 4. Project format

A folder of plain text that works with git. JSON is UTF-8, two-space indented, keys in a fixed order, LF line ends. The editor **must** rewrite only files that changed.

```
mygame/
  project.json          name, version, author, licence, limits, options
  fields.json           player and world fields
  tables/*.json         tables and their rows
  places/*.json         places, choices and block handlers
  screens/*.ans         ANSI art (CP437), with screens/*.json for live fields
  scripts/*.dbs         script handlers and functions
  functions/*.json      functions made of blocks
  editor.json           where the editor draws things; not part of the game
  modules.json          built-in module settings
  settings.json         settings the sysop may change
  sim.json              simulator strategies and target ranges
  docs/                 text for the sysop and player guides
```

- Fields, tables and the rows of fixed tables have permanent ids. Saves use them, so renaming never breaks a saved game. The sources refer to things by name; the editor renames every use, and shows them first.
- Ids are never reused. Deleted ids are kept in `project.json`.
- `project.json` carries `"format": 1`. A newer format is refused with a clear message; an older one is upgraded after a copy is kept.
- Paths in project files are relative and may not leave the project folder.
- Game text is limited to CP437. The editor shows characters that cannot be used.

## 5. Data model

### 5.1 Types

| Type | Meaning | Stored as |
|---|---|---|
| number | Whole, -999,999,999,999,999 to +999,999,999,999,999 | 8 bytes |
| text(n) | CP437, 1 to 79 characters | length byte + n |
| flag | Yes or no | 1 byte |
| choice | One of a named list, up to 255 | 1 byte |
| day | Game day number | 4 bytes |
| ref(table) | A row in a table, or none | 2 bytes |
| player ref | A player, or none | 4 bytes, permanent id |

There are no fractions. Percentages use `percent(a, b)`, which multiplies before dividing and rounds toward zero. Results out of range stop at the limit and write a warning to the log; numbers never wrap. Dividing by zero gives zero and logs a warning.

### 5.2 Records

- **Player:** one per player. System fields: id, key, display name, created day, last played day, turns left, status, deleted flag.
- **World:** one record for the installation.
- **Fixed table:** rows in the pack, read only (items, opponents, levels). Each row has a permanent number, so links survive rows being added or removed.
- **Shared table:** saved rows every player sees, with a set maximum (claims, listings).
- **Owned table:** saved rows belonging to a player, with a maximum each (carried items).

Records are fixed length and start with a 4-byte change counter and a CRC-32.

### 5.3 Who a player is

The default key is the BBS alias, upper-cased and trimmed. The sysop may choose BBS user number or real name at set-up. Changing it once players exist needs an explicit conversion in `DBSETUP`. Player ids are never reused.

### 5.4 Limits

| Item | Limit | Item | Limit |
|---|---|---|---|
| Players | 2,000 (default 500) | Screens | 500 |
| Player fields | 120 | Places | 1,000 |
| Player record | 2,048 bytes | Choices per place | 24 |
| World fields | 120 | Handlers and functions | 2,000 |
| Tables | 40 | Fields per table | 40 |
| Fixed rows per table | 2,000 | Pack size | 4 MB |
| Shared rows per table | 5,000 | Nodes | 255 |
| Owned rows per player, all tables | 200 | Settings | 64 |

`dbc` **must** report each limit that is passed, with the object's name.

## 6. Places, screens and input

### 6.1 Places

A place has, in order: an optional *on enter* handler, a screen or text, up to 24 choices, and an optional default on timeout. A choice has a hotkey, label, *show when* and *allowed when* conditions, a turn cost, a handler and a destination.

Destinations are a place, *back*, *stay* or *quit*. *Back* uses a stack of 16; beyond that the oldest entry is dropped. Choices whose hotkeys could both be shown at once are a compile error when their conditions do not rule it out by construction, and otherwise a warning.

### 6.2 Screens

- The canvas is 80x24. Row 25 is allowed only for local-only screens and is warned about.
- 16 foreground and 8 background colours. iCE colours are off unless the project enables them, since many terminals blink instead.
- Live fields: position, width, alignment, colour, number format and an expression. Text too long is cut; a number too long shows `*` across the width.
- Callers without ANSI get a plain version, generated automatically (making it editable is *later*).
- Output **must** send only differences when a place is refreshed, and never position text in the last column of the last row.

### 6.3 Input

Hotkey, light bar (ANSI only), number (minimum, maximum, default), text line, yes/no, list with paging, short message editor, pause. Callers with fewer than 24 rows get paging.

Player text is limited to printable CP437 from 32 up, excluding 127. Control codes are removed. Colour codes are never read from player text.

Idle limit: 5 minutes, sysop setting. Warnings are shown at 2 minutes and 1 minute of BBS time left. Both end in the same clean exit as *quit*.

## 7. Handlers and script

### 7.1 Blocks

Handlers are lists of *when / if / then* blocks kept as a JSON tree:

| Group | Blocks |
|---|---|
| Decide | if, else, chance, choose by weight, repeat |
| Change | set, add, subtract, spend, give, take |
| Show | text, screen, pause, ask |
| Rows | find, for each, add row, remove row |
| Others | send mail, post news, log |
| Move | go to place, back, quit |
| Group | atomic, call function |

Any handler can be converted to script. Converting back is not offered.

### 7.2 Script

```
function buy_water(n)
  let cost = n * world.water_price
  if n < 1 or n > 20 then return end
  atomic
    if player.water + n > 40 then
      let result = 1
    elseif spend(player.cash, cost) then
      player.water += n
      let result = 0
    else
      let result = 2
    end
  end
  if result == 0 then say("You buy {n} gallons.")
  elseif result == 1 then say("You cannot carry that much.")
  else say("You cannot afford that.") end
end
```

- Number, text and flag values; local variables belong to the function, start at zero or empty, and are checked at compile time.
- `if/elseif/else`, `while`, `for i = a to b`, `for row in table where ...`, `return`, `and`, `or`, `not`.
- Text inserts use `{expression}`. A literal brace is doubled.
- Built-in functions cover random numbers, number and text handling, tables, players, days, mail, news and rankings. The full list is `docs/SCRIPT.md`, written with stage 1.
- There is **no** way to open files, run programs, use the network, read memory or read BBS data other than alias, real name if the sysop allows it, security level and time left.

### 7.3 Virtual machine

Both forms compile to the same stack bytecode. Limits per handler run:

| Limit | Play | Maintenance |
|---|---|---|
| Instructions | 200,000 | 5,000,000 per handler |
| Call depth | 32 | 32 |
| Numbers on the stack | 256 | 256 |
| Texts on the stack | 32 | 32 |
| Values in a function | 200 numbers, 24 texts | same |
| Text value | 255 characters; `say` of a longer text is shown in parts | 255 characters |
| Code chunk | 16 KB | 16 KB |

Reaching a limit stops the handler, discards its uncommitted changes, logs the place and line, and returns the player to the last place. The count resets at each wait for input, but a handler may wait at most 500 times.

Numbers and texts have stacks of their own, so neither can be taken for the other.

All jumps, stack depths, ids and offsets **must** be checked when a chunk is loaded or run. A damaged or hostile pack must produce an error message, never a crash.

### 7.4 Random numbers

One 32-bit xorshift generator, the same on every platform. Seeded from the clock and node normally, or from a given seed in tests. `random(a, b)` discards values that would make the result uneven.

## 8. Saving and several nodes

### 8.1 Rules

1. Nothing is held locked while waiting for a player.
2. Writes to the world, shared tables or other players are allowed only inside `atomic`. Elsewhere they are a compile error.
3. Inside `atomic`, reads are fresh, and input or output is a compile error, including through called functions.
4. A single change to the player's own record, such as `player.cash -= 10`, is an atomic step by itself, because other nodes may change it too.
5. `spend(field, amount)` checks and subtracts in one step, refuses negative amounts, and returns yes or no.
6. Blocks apply these rules for the author: *spend* and *give* blocks are atomic automatically, and the editor offers to wrap a group.
7. Nested `atomic` joins the outer one. Mail and news sent inside it are saved with it, or not at all.

### 8.2 Commit

1. Take the lock, read records afresh and run the block in memory (at most 64 records and 48 KB).
2. Write changes and their CRC to `JOURNAL.NEW` and flush.
3. Check that the lock is still ours, then rename it to `JOURNAL.DAT`. This is the commit point.
4. Apply the records, flush, delete `JOURNAL.DAT`, release the lock.

Whoever next takes the lock **must** replay a valid `JOURNAL.DAT` first. Replaying twice gives the same result. A leftover `JOURNAL.NEW` is deleted.

### 8.3 Lock

- A directory, `DB.LCK`, since creating one is atomic on all three systems. It holds an `OWNER` file: platform, process id, time, random token.
- Linux and Windows may break a lock at once when its owner, on the same computer, is proved dead; after 10 seconds when no owner was ever written; after 60 seconds when the owner cannot be checked; and after 5 minutes when it runs but has not let go. The owner file holds the time, and is created so that only one program can ever make it.
- DOS never breaks a lock by itself: it tells the caller to try later and tells the sysop to run `DBMAINT unlock`. Commits are short, so this matters only after a crash.
- An owner whose token has gone **must** abandon the commit. A small window remains between that check and the rename if a process stalls there for a full minute; LIMITATIONS.md will say so.
- An installation is run by one platform at a time. Data files are the same on all three, so it may be moved between them. Network shares are unsupported.

### 8.4 One login per player

A player record stores the node playing it. A second login by the same player is refused. Stale marks clear by process check on Linux and Windows, or after 4 hours, or through `DBSETUP`.

### 8.5 Hanging up

Committed changes stay. An unfinished handler is dropped. A short `on_hangup` handler (20,000 instructions, no input or output) may run. The fight module lets the author choose between loss and escape (resuming next time is *later*).

## 9. Daily maintenance

`DBMAINT daily` runs once per date; a second run the same day does nothing and succeeds. Steps:

1. Take the maintenance mark; doors finish their current step, then show a "maintenance" message and exit. New callers are refused.
2. Wait up to 5 minutes for nodes to leave, then stop with an error if any remain.
3. Back up the save files. Seven backups are kept by default.
4. For each missed day, up to 7: advance the game day, run `on_day`, reset turns, run the modules, run each table's `on_row_day` and `on_player_day` for each player. Each call is one atomic step that also records the progress; a game fault is logged and the day goes on.
5. Remove inactive players if set (default off; warned by a news item a week earlier).
6. Trim mail, news and logs; rebuild rankings; verify all records.

- Progress is recorded by step and player, so an interrupted run **must** continue without repeating a finished step.
- If the date goes backward, nothing runs and it is logged. More than 7 missed days run as 7, with the rest logged.
- The sysop may choose "first caller of the day runs it" instead of a timed event.

Other commands: `new`, `check`, `repair`, `backup`, `restore`, `unlock`, `export` (JSON), `reset` (asks for the game name to be typed), `version`.

## 10. Built-in modules

Each is optional, set by tables and options, and can be overridden at named points. The compiler writes a module out as script, so there is no second set of rules. All are in MODULES.md.

| Module | Provides |
|---|---|
| Turns | Daily turns, carry-over limit, costs |
| Shop | Stock, prices by expression, buy and sell, limits |
| Fight | Player against opponent: attack, use item, run; formulas, rewards, defeat rule |
| Player fight | Attack a player who is online or not; level range, protection for new players, daily limits, report by mail |
| Bank | Deposit, withdraw, optional daily interest with a cap |
| Mail | Short messages, 50 per inbox, 10 sent a day |
| News | Daily news, 200 lines kept |
| Rankings | Up to 5 lists |
| Players | List, look up, who is on |
| Level | Experience table, rewards at each level |
| Season | Fixed length, ending, hall of fame, automatic restart |

In a fight the opponent's state is private to the session. A player fight against someone offline takes a fresh copy of the defender, and the result is applied in one atomic step that re-checks both players. It fails politely if either changed in a way that matters, such as having been beaten already.

## 11. Pack file

Little-endian, read in pieces, never loaded whole on DOS.

| Part | Contents |
|---|---|
| Header, 64 bytes | `DBP1`, format, minimum engine, flags, game id, game version, counts, directory offset, CRC-32 |
| Directory | Type, id, offset, length, CRC-32 for each chunk |
| Chunks | Schema, text, screens, places, tables, code, modules, settings, about |
| Debug chunk | Names and line numbers; left out of release packs unless asked for |

- A chunk is at most 16 KB; larger tables are split. Every chunk's CRC is checked on reading.
- CRCs find damage. They are not protection against tampering, and the pack is not encrypted.
- The game id is a random 128-bit value made with the project. An engine refuses to open saves belonging to a different game id.
- The same sources and compiler version **must** give byte-identical packs.

## 12. Updating an installed game

Saves store a schema: field ids, types, sizes. When a pack's schema differs, `DBRUN` refuses to start and asks for `DBSETUP update`, which takes the lock, checks no node is on, backs up, converts to new files, verifies them and swaps them in.

| Change | Result |
|---|---|
| New field | Filled with its default |
| Field removed | Dropped; kept in the backup |
| Text made shorter, number to text | Converted; warned in the editor |
| Other type change | Refused (a conversion handler is *later*) |
| Table rows added or removed | Links to a removed row become none |
| Maximum rows reduced below those in use | Refused |

Failure at any point leaves the old files in use. Going back to an earlier version uses `DBMAINT restore`.

## 13. Engine on each system

### 13.1 Connections

Drop files: DOOR32.SYS, DOOR.SYS, DORINFOx.DEF, CHAIN.TXT, CALLINFO.BBS, SFDOORS.DAT, PCBOARD.SYS, EXITINFO.BBS. Found by file or by node folder; on DOS the search includes `*.*`, as fixed in the earlier doors.

| System | Connection |
|---|---|
| Linux | Standard input and output, terminal |
| Windows | DOOR32 socket, standard input and output, local console |
| DOS | FOSSIL, UART when there is no FOSSIL, local screen |

```
DBRUN -d DROPFILE|NODEFOLDER [-n NODE] [-g GAMEFOLDER] [-p COMPORT]
DBRUN -l -u NAME [-g GAMEFOLDER]
```

`-p` (DOS) gives the port when the drop file has none. Without either, the door refuses to start unless `-l` is given, since it would otherwise play on the sysop's screen while the caller waits.

Files in an installation have 8.3 names. The author sets a base name of up to 8 characters; packaging renames `DBRUN` and the pack to it. The programs find the pack as the only `.DBP` file in the game folder.

Windows serial (DOOR32 communication type 1) is not supported and says so.

### 13.2 DOS budget

Large memory model, 8086, as the existing doors. For comparison SEAL.EXE is 296,122 bytes with 44,904 bytes of its 64 KB data group used.

| Item | Must be within |
|---|---|
| `DBRUN.EXE` | 300,000 bytes |
| Data group used | 50,000 bytes |
| Conventional memory free to run | 480 KB |
| Pack cache | 48 KB, oldest chunk dropped first |
| Transaction buffer | 48 KB |

- Short strings only in the VM and records, so there is no heap fragmentation.
- No floating point and no SysUtils or Classes in the DOS build.
- Lack of memory at start **must** give a message, not a crash.
- Every stage runs the DOS tests. A feature that does not fit is cut or moved to `DBMAINT`.

### 13.3 Sysop set-up

`DBSETUP` is full screen text: game settings declared by the author (with ranges and help), player key, idle limit, maintenance mode, real name permission, player editor, node marks, update, backups. Every setting also works from the command line for scripts.

### 13.4 Logs

`DB.LOG`, plain text, 256 KB with one old copy. Records starts, errors, limits reached, maintenance, sysop changes. It never holds mail text or real names.

## 14. Example game

Working title **Goldfield Claims**; name check still to do. Original setting, map and text: an unnamed invented field in the 1890s, with no real people. Plain wording throughout. Its purpose is to exercise every engine feature, and it ships as a template under CC0 text, art and pack sources so anyone may build on it.

### 14.1 Play

- A season is 60 game days. The winner has the greatest net worth: cash, gold at today's price, and half the cost of improvements.
- Each day: 10 turns. A player starts with 100 cash, 10 gallons of water, 10 food, 1 pick and no timber.
- The field is a shared map of 12x8 squares. Each has hidden richness (0 to 100), depth (1 to 5) and a water distance.
- A day costs 2 water and 1 food, taken at maintenance. Going short halves the next day's turns; nobody is killed or removed by shortage.

| Action | Turns | Effect |
|---|---|---|
| Prospect a square | 2 | A rough reading, error up to 30; repeated readings average out |
| Peg a claim | 1 | 25 cash; one owner per square; at most 4 each |
| Work a claim | 1 | Gold from richness, tools and depth; richness falls |
| Sink deeper | 2 | Needs timber; reaches the next depth |
| Cart water | 1 | Water according to the square's distance |
| Trade | 0 | Water, food, timber, tools, gold |
| Dispute a claim | 2 | See below |
| Send mail, read news | 0 | |

Added after simulation: **labour** for wages (4 a turn), so that nobody can be stuck with nothing; **giving up** a claim; a claim whose owner is away over 10 days is open ground again. Tools bought count half in net worth, as shafts do. A turn's work makes the ground 1 poorer 4 times in 10, not every time. Timber has a limited stock.

Yield per turn, in pennyweights: `(richness * (100 + 20 * tool level) / 100) / 10`, plus a random -2 to +2, never below 0. A new depth restores half of the original richness. These numbers are first values for `dbsim` to tune.

### 14.2 Gold price

Starts at 40 for an ounce (20 pennyweights), between 20 and 80. Each day it moves by a random -3 to +3, drifts one toward 40, and falls by 1 for every 100 ounces sold the day before, to a limit of 5. Selling uses the day's fixed price.

### 14.3 Disputes

A claim not worked for 3 days can be disputed for a 50 cash deposit. The owner is told by mail. If the owner works it before the second maintenance after that, they keep it and receive the deposit. Otherwise it passes to the challenger, who gets the deposit back. Improvements pass with it. One dispute per claim at a time, and none in a player's first 5 days.

### 14.4 Events

Dust storm (one turn fewer for all), dry spell (water price doubles for 3 days), rush (news names a square within two of a rich one), carrier arrives (cheap timber for a day), ground fall (unused timber lost on one claim in twenty). At most one a day.

### 14.5 Proof it must give

Two nodes pegging the same square give one owner; two nodes buying the last stock cannot both get it; a season ends and restarts by itself; a hang-up at any prompt loses and duplicates nothing; the game runs on all three systems.

## 15. Licence

- Editor, compiler, engine, simulator: GPL-2.0-or-later. Copyright Michael Slater, with retained notices.
- `EXCEPT.TXT`, as an additional permission: a pack, its sources, art and text are not covered by the engine's licence merely because DoorBench made them, the engine runs them, or they are distributed beside it. Engine data that the compiler copies into a pack is included in this permission.
- The wording is mine to draft and **must** be looked over by the owner before release. It is not legal advice.
- Because the engine is GPL, every game ZIP carries `COPYING`, `NOTICE.TXT`, `EXCEPT.TXT` and either the engine source or a link that satisfies the licence for that exact version. Packaging adds these and cannot be told not to. The default is to include the source ZIP, which is simplest for authors to get right.
- Fugue icons: CC BY 3.0, credited in About and the documents. ANSI and fonts: own work or with recorded permission.

## 16. Editor

Rust with egui, Fugue icons, the shared ten themes. Linux (.deb, .tar.gz; AppImage is *later*) and Windows (installer, portable ZIP, both signed).

### 16.1 Window

A project tree on the left, documents in tabs, properties on the right, problems and test output below. Undo and redo cover every edit in a project. Autosave goes to a recovery folder, and saving is atomic. Changes made outside the editor are noticed and offered as reload or keep mine.

### 16.2 Views

1. **Screens:** 80x24 canvas, VGA font, draw, box, fill, block, copy, text, colour picker, live fields, preview with sample values, plain version. Imports and exports .ANS; SAUCE is read and kept. .BIN and .XB import are *should*.
2. **Flow:** places as a graph; drag to link; marks unreachable places, places with no way out, and missing destinations.
3. **Fields and tables:** grid editing, filter, CSV import and export.
4. **Handlers:** block editor with conditions picked from lists; script editor with colouring, completion and errors in place.
5. **Modules and settings:** forms with help beside each option.
6. **Problems:** errors and warnings from `dbc`; clicking opens the object.
7. **Find:** text, names, and every use of an object. Deleting something in use lists the uses first.

### 16.3 Test play

- Runs `dbtest` in a terminal pane, up to 4 players at once, on a throw-away copy of the save data.
- Shows and changes player and world values, sets the random seed, advances a day, shows the handler and line, and pauses on chosen lines.
- Slow line speeds, no-ANSI, 24 rows and hang-up can be simulated.
- The control link is a loopback connection with a random one-time token. It is compiled only into `dbtest`, and the release engine **must not** contain it.

### 16.4 Balance check

`dbsim` runs 1 to 500 simulated players for up to 365 days, using random play, a choice-weight strategy, or a script. Runs are repeatable by seed. It reports level and wealth by day, win and loss rates, turns used, choices never taken, handlers never run, limits reached and values stuck at their maximum, as a table, CSV and charts. Authors may set target ranges that show as pass or fail.

### 16.5 Packaging

Choose systems, then get one ZIP each containing the renamed engine, pack, licence files, sysop and player guides, FILE_ID.DIZ (45 columns, 10 lines), and sample set-up for Synchronet, Mystic and generic BBSes. It checks version number, licence, names and 8.3 file names, refuses with errors present, and unpacks and starts the result as a last test. Building a package does not upload anything.

Engine files for all systems ship inside the editor, so authors need no compiler.

### 16.6 Command line

`doorbench build`, `check`, `test`, `sim`, `package` call the same tools, for scripts. `dbc` alone can build a pack.

## 17. Naming, documents and release

- Before release: search for DoorBench and Goldfield Claims in web, software, trademark and BBS file listings.
- Documents: tutorial (the success test), author guide, `SCRIPT.md`, `FORMAT.md`, sysop guide, player guide template, CHANGELOG, LIMITATIONS.
- Templates: empty game, goldfields, small fantasy town, trading route; each original.
- Release: kalretro.au page, wiki changelog, BBS file area, FTP, signed Windows files, email notice. Public release and any GitHub push need the owner's approval.

## 18. Security

| Risk | Measure |
|---|---|
| Hostile pack | No file, program or network access in script; every offset checked; instruction limits |
| Hostile project folder | Paths kept inside; size limits; nothing is run on opening |
| Player input | Filtered text; no codes passed to other callers' terminals |
| Damaged saves | CRCs, journal, backups, `check` and `repair` |
| Hostile drop file | Length limits; DOOR32 handle tested before use |
| Flooding | Daily limit on mail; news and disputes are the author's to limit, with modules that do so |

The compiler's output and the drop file readers **must** be fuzz tested, at least 1 million cases each before release.

## 19. Tests

| Kind | What |
|---|---|
| Unit | Types, limits, expressions, random numbers, pack reading, conversion |
| Compiler | Good and bad sources with expected messages; identical output |
| Same results | One seed and one key list give the same screen text and saves on Linux, Windows (Wine, then real) and DOS |
| Crash | Process killed at each step of a commit and of maintenance; totals still balance |
| Contention | 8 doors making 10,000 transfers with no money made or lost |
| Door | Pty and socket on Linux, socket under Wine (opened by a test build, as Wine 10 cannot send on an inherited one) and the hand-over on real Windows, DOSBox with KFOSSIL and with plain UART |
| Editor | Project round trip, undo, opening every template, packaging |
| People | One person who is not a programmer does the tutorial unaided |

What cannot be done here: real DOS hardware and other vendors' BBS programs. Those are listed as untested until someone reports.

## 20. Stages

Each stage ends with its tests passing, a git commit and a short report.

| Stage | Contents | Done when |
|---|---|---|
| 0 Foundation | git, layout, builds for three systems, doorkit merged, new line editor, licence files | A "hello" door runs on all three; no derived `ConGetStr` left |
| 1 Engine | Pack, schema, VM, script, places, screens, input, saving, locks, maintenance, `dbc`, `DBSETUP` | A hand-written small pack passes same-results, crash and contention tests; DOS budget met |
| 2 Example | Modules it needs, Goldfield Claims, `dbsim` | Section 14.5 is proved; sysop-only trial on the BBS after approval |
| 3 Editor | Views, blocks, problems, test play | The example opens, edits and tests without hand-written JSON |
| 4 Packaging | Remaining modules, ZIPs, guides, templates, balance charts | A package made on one machine installs on a clean one |
| 5 Release | Name check, fuzzing, tutorial trial, signing, page | Owner approves |
| 6 Later | Browser play through a web terminal, inter-BBS through Door Hub, game library, translation | Separate specification |

Stages 0 to 2 need only web-main, apart from real Windows checks. Rust was not found there, so stage 3 needs it installed (or kbuntu), and a desktop to look at the result.

### 20.1 Biggest risks

1. **DOS size.** Measured in stage 1 before anything depends on it. If it does not fit: first trim modules, then split the fight and mail screens into a second program, then raise it with the owner.
2. **Too general.** The example game decides what the engine needs. Features neither it nor a template uses are put off.
3. **Two ways to write handlers.** Blocks and script share one bytecode and one test set.
4. **GPL duties for authors.** Packaging does the work for them.

## 21. Still open

| # | Question | Assumed until decided |
|---|---|---|
| 1 | Final names | DoorBench, Goldfield Claims |
| 2 | Include engine source in every game ZIP, or link to it | Include |
| 3 | Example sources under CC0, or GPL | CC0 |
| 4 | Which machine is used for stage 3 while travelling | Wait for kbuntu |
