OpenTPW

Script mods (TPW Script)#

Mods (MODS.md) may carry scripts that change simulation decisions, such as which attraction a guest prefers. Scripts are written in TPW Script, a small deterministic language that OpenTPW interprets itself. There is no external scripting engine, and a mod can never ship native code or .NET assemblies.

Status. The language, the manifest and loading, and the four guest-decision hooks are implemented and tested: source/OpenTPW/Scripting/ holds the lexer, compiler, interpreter and the state codec; a mod's scripts are loaded and compiled at start-up with "Contains scripts" on the mods screen and safe mode; and the hooks run through the IGuestDecisions seam with failure counters, a disabled flag, the ScriptMods park-resume section, its part of the WorldStateHash and measured budgets. opentpw.example.patient-guests is a working example. Scripts run in the desktop app only. The browser does not run script mods yet: it does not embed the example and has no folders for community mods. --test-mod does not exist yet (Phases).

Quick start#

  1. Enable the shipped example to see a script mod at work: Options > OpenTPW > Extensions and mods > Community mods > Patient guests (example) > on, then restart (or run once with --enable-mod opentpw.example.patient-guests). It is off by default (MODS.md).

  2. Copy content/mods/opentpw.example.patient-guests/ to <config>/mods/community.my-hook/ and edit the manifest (id: community.my-hook, category: community).

  3. Write your first hook in scripts/main.tps (delete the example's script file). A hook is a top-level function named in the manifest's content.scripts.hooks; it receives read-only views and prev, the answer the game (and the mods before yours) would give, and returns the answer to use. For example, let a guest with at least 30 happiness join a ride whose excitement is up to 10 points further from its taste than the game allows (the game refuses from a difference of 45):

    function joinQueue(guest, attraction, prev)
      if prev then
        return true
      end
      return guest.happiness >= 30 and attraction.joinDifference < 55 and attraction.queueCount < attraction.queueLimit
    end
    "content": { "scripts": { "files": ["scripts/main.tps"], "hooks": { "joinQueue": "joinQueue" } } }
  4. Restart. A compile error, a missing function or a wrong parameter count refuses the mod with the file, line and message (startup log and mods screen). At run time a failing call answers prev, and after 16 failures the mod is disabled for the park (Failure counters). The tables in The views list every field; the example mod (below) is the model to start from.

Why our own language#

A general engine (Lua, JavaScript) cannot give the guarantees a deterministic, saveable simulation needs:

The language#

TPW Script is a subset of Lua syntax, so modders recognise it, with different semantics where Lua's would break determinism. A script is a source file of UTF-8 text (no byte order mark).

local base = 10                      -- a top-level constant (literal values only)
local rate = fx(1.25)                -- fixed point: 125 (hundredths)

function score(visits, cost)         -- a top-level function
  local s = base * 100 // (cost + 1)
  for i = 1, visits do
    if s > 1000 then break end
    s = s + 3
  end
  state.lastScore = s                -- mutable data lives in `state`
  return clamp(s, 0, 1000)
end

Statements and expressions#

Values#

TypeNotes
int64-bit signed. The only number type.
booltrue, false.
stringImmutable, at most 1024 UTF-16 characters, an opaque sequence compared ordinally (no Unicode normalisation anywhere). Literals use "..." or '...' with \n \t \r \\ \" \'.
tableAn array (1-based) or a map with string keys, never both. Plain data: tables of ints, bools, strings and tables.
host viewA read-only table a hook receives (for example a guest or an attraction), with the same entry, key and string limits as any table. It cannot be changed or stored.

There is no nil and no unit value you can keep: a function without return value can only be called as a statement.

Nil semantics (decided). Reading an absent map key, an out-of-range array index or an empty table's key is a runtime error, not a silent nil. Test first with has(t, k). This keeps a typo from turning into a quiet wrong score.

Truthiness (decided). if, while, and, or and not need real bools. if 1 then is a runtime error. == and ~= compare two ints, two bools or two strings; any other pairing, and tables, is an error. < and friends compare two ints or two strings.

Integers#

Host functions (the whole whitelist)#

All are resolved by the compiler to a fixed table of typed delegates; nothing is looked up by name or reflection at run time.

FunctionMeaning
min(a, b), max(a, b), abs(a), clamp(v, lo, hi)Integer helpers. clamp with lo > hi is an error.
fxmul(a, b), fxdiv(a, b)Fixed-point multiply and divide (above).
len(x)Characters of a string (UTF-16 units) or entries of a table.
has(t, k)Is the array index or map key present.
keys(m)The keys of a map as a new array, sorted ordinally.
push(a, v), pop(a)Append to an array; remove and return its last element (error if empty).
del(m, k)Remove a map key (error if absent).
rng(n)A deterministic value in 0 .. n-1, see Random numbers. n >= 1.

Anything else (print, io, os, require, load, string, math, pcall, pairs, tostring, ...) is an unknown name and a parse error. Maps are iterated with keys(m) and a numeric for.

What is excluded, and why#

ExcludedWhy
Closures, upvalues, function values, nested functionsThey keep state alive outside state. A function sees only its own locals, the top-level constants and state. Functions are called by name and are not values.
CoroutinesThey would let a script keep a suspended computation (hidden state) and reset step counters.
Metatables, prototypes, methods (:)Behaviour hidden behind indexing; no way to audit what t.x does.
try/catch, pcall, errorThe budget and every runtime error must be uncatchable. A failing call fails as a whole.
Top-level mutable variables, globalsHidden state. The top level holds only functions and constant locals with literal values; assigning to an undeclared name is a parse error.
Floats, /, exponent and hex literalsNot bit-exact across platforms. Use integers and fx.
pairs, next, ipairs, generic forMap iteration order must never leak into the simulation. Use keys(m) (sorted).
nil, repeat, goto, varargs, #, long stringsNot needed; nil and truthiness are the usual sources of silent mistakes.
string, math, os, io, debug, loadNo libraries; nothing outside the whitelist exists.

Execution contract#

The numbers below are in ScriptLimits; they are part of the language version (ScriptLimits.BehaviourVersion, currently

  1. and any change to them or to the semantics bumps it.

Static limits (checked while parsing; errors carry line and column).

LimitValue
Source size64 KiB
Tokens20 000
Nesting depth (blocks, parentheses, tables, unary chains, concatenation chains)32
Functions64
Parameters per function / arguments per call8
Locals per function64
String literal length, any string1024 characters
Name length64
Entries per table (constructors, host views and runtime growth alike)4096

The executed bytes are the hashed bytes. ScriptProgram.Compile(bytes) hashes the byte span (SHA-256, lowercase hex), then decodes and compiles that same span. Hosts keep the compiled program in memory and never re-read the path, so a file swapped after hashing cannot run.

Budgets.

Transactional state. A call works on a copy-on-write view of state. Nothing is copied until the script first touches state; then the root is copied, and each nested table the first time it is read through a writable path. Every copy is charged to the call's step and memory meters inside the failure boundary, so a call that never touches state pays nothing for it, and one that does pays in proportion to the entries it copies. Committed data is never modified, so the previous state is a free snapshot. Only a call that returns normally and has a valid result commits:

  1. the result has the hook's declared type and range (ScriptResultSpec), otherwise InvalidResult;

  2. the new state passes the schema (below), otherwise InvalidResult. Validating it is charged to the same step and memory meters as the work happens, on every path: one step per node, one per 16 characters of string content and one per 16 characters written. The budget is checked while it runs, so a call can run out of steps while committing (it fails like any other budget exhaustion), and a commit that fails validation still pays for the work it did. Maps are visited in sorted key order, so the charge does not depend on how a dictionary was built and is identical after a save round trip;

  3. then the new state replaces the old one. A call that changed no table, or never touched state, keeps the same state object.

Failure. A runtime error, budget exhaustion or invalid result rolls state back and the call returns the prev value the caller passed in: the previous mod's result in the chain, or the game's own rule, not the original rule. A failing later mod therefore does not undo earlier mods. The typed outcome is ScriptCallResult(Value, Outcome, Message, Line, Steps) from ScriptHost.Call(hook, args, prev, spec, identity) with Outcome one of Ok, RuntimeError (message and line), BudgetExhausted or InvalidResult.

Failure counters and the disabled flag belong to the game wiring (ScriptModInstance), not to the language core, which only reports the outcome. They are described under Failure counters.

The state schema#

state is the one mutable global. Its root is a map; everything inside is plain data:

LimitValue
Depth (root = 1)16
Nodes (every table and every value)4096
Canonical size64 KiB of UTF-8

Validation walks the tree once and stops at the node limit and at 64 KiB of string content (keys and values together). It then serialises, checking the byte limit after every token, so it never builds more than about 64 KiB of text. The walk visits at most 4096 nodes, and each costs steps as above; the 64 KiB bound is on the serialised text, not on the walk. Hook results are an int, a bool or a string (ScriptResultSpec with a table or no kind is refused); a table can never be a result.

Canonical serialisation. ScriptState.Serialize writes compact JSON with maps in ordinal key order, integers in plain decimal, and strings with only ", \ and the control characters (and DEL) escaped as \uXXXX; other characters are written as they are. Equal states give equal bytes on every platform, which is what the save hash needs. ScriptState.Parse accepts ordinary JSON whitespace and any key order, refuses everything outside the schema (null, floats, exponents, -0, leading zeros, duplicate keys, an array root, a non-ASCII or over-long key, any limit exceeded) and validates. Serialize(Parse(x)) is a fixed point. An empty map and an empty untouched table both serialise as {} and an emptied array as [], and the interpreter's behaviour after a save round trip equals continuing without one (tested).

Random numbers#

rng(n) is a stateless hash, never a generator with state. The call identity is the tuple

(park seed, mod id, hook name, guest birth id, park turn, draw ordinal)

where the ordinal counts the rng calls inside this one call (0, 1, 2, ...) and the host supplies the rest. The hook name is hashed, not the name of the function that implements it (ScriptHost.Call(function, ..., hookName)), so renaming a function does not change a mod's numbers. The host takes the park seed from the guests' identity state (the saved park seed), the birth id from the guest and the turn from the park turn. The value is a SplitMix64-style mix of the tuple, taken modulo n (ScriptRng.Draw). Replays, save resumes and other platforms get the same numbers, a failed call consumes nothing, and scripts never see WorldRng. The exact values are pinned by a test: saves will depend on them.

Saves and versioning#

A new optional ScriptMods section in the park-resume data (ParkResumeSnapshot.ScriptMods, class ScriptModsSave) holds, keyed by mod id:

FieldMeaning
BehaviourVersionScriptLimits.BehaviourVersion when the park was saved.
ApiVersionScriptLimits.ScriptApiVersion when the park was saved.
StateThe mod's state as canonical text (ScriptState.Serialize).
RuntimeErrors, BudgetFailures, InvalidResultsThe failure counters (they count toward disabling).
TicksOverBudgetTicks in which the mod used up its per-tick budget (diagnostic; not a failure).
DisabledThe disabled flag.

Loading and the manifest#

A mod's scripts are declared in its manifest (MODS.md):

{ "scriptApi": ">=1.0.0 <2.0.0",
  "content": { "scripts": { "files": ["scripts/main.tps"], "hooks": { "leaveQueue": "leaveQueue", "joinQueue": "joinQueue" } } } }

Executed bytes. The manifest bytes parsed at discovery are kept (DiscoveredMod.ManifestBytes), and resolving refuses the mod if the manifest file it hashes is not byte-identical, so the file list and the hook map provably come from hashed bytes. ModSet.Resolve reads each script file once; the SHA-256 that goes into ContentSha256 and the bytes that are compiled come from that one read, and the bytes are kept in memory. ResolvedMod.Scripts (a ModScriptSet) exposes, per file, its path, the retained Source bytes, and the ScriptProgram compiled from exactly those bytes, plus the Hooks table (file index and function per declared hook). The hooks run these programs and never read the path again (ScriptModInstance builds its hosts from Files[i].Program): a file changed after resolve cannot run (tested in phase 3). A script file larger than the per-file cap is hashed but not kept, and the mod is refused.

Classification. A mod with scripts changes the simulation unless every declared hook is UI-only (ScriptLimits.UiOnlyHooks, empty in v1), so in practice it always does. It is therefore in ModSet.SimulationMods and recorded in park saves like any simulation-changing mod (ParkResumeMods): loading a save needs the same mod, version and content digest.

Mods screen. A mod with scripts shows "Contains scripts" in its details (nine languages). A refused script mod shows the compile error or other reason in the "Why not" line.

Safe mode#

A script mod that breaks the start of the game must not lock the player out. The desktop startup keeps a crash marker, script-mods-starting.marker in the configuration folder (next to mods.json). It holds the writing process's id and start time.

Mods without scripts are never affected by safe mode.

Hook API v1#

The hooks sit on the decision seam of the guests (SMARTER-GUESTS.md, IGuestDecisions). ScriptGuestDecisions (World/Guests/Decisions/) wraps the base policy (the faithful guests, or the smarter-guests policy when that extension is on): every decision first takes the base policy's answer, and a hook a mod implements then receives it as prev and returns the answer to use, mod after mod in the resolved, saved mod order, each receiving the previous result. A mod that fails returns prev, so it undoes neither the base policy nor the mods before it. The host keeps every effect and every WorldRng draw; a hook can only change an answer. The policy is picked once, when the guest simulation is built, from the active mod set; without a script mod nothing is wrapped (ScriptMods is null, nothing is saved or hashed).

HookSeam pointWhen it runsResult
scoreAttraction(guest, candidate, prev)ScoreAttractionper candidate, in the major and the minor decision (the faithful base also offers disconnected typed queue backs to the major decision; the smarter base keeps its join-cell filter); the work counts per candidateint, 0 to 4294967295 (the host's unsigned score)
joinQueue(guest, attraction, prev)DecideAdmissionwhen the guest has reached the back cell and the physical checks (open, not listed, room) passedbool, true admits
leaveQueue(guest, attraction, prev)DecideQueuePatienceafter the existing leave tests, on every turn a waiting guest stays (never while called forward or in an interlude)bool, true leaves
wanderGoal(guest, prev)ChooseWanderGoalafter the host's own destination search and its drawsint, y * 1024 + x of a cell inside the map

The booth verdict, the two comparison rules (BeatsInMajorDecision, BeatsInMinorDecision) and the use memory are not hooks in API 1; they pass through. Tie-breaking and the final choice stay the host's. Notes on the mapping:

The views#

Views are plain read-only tables built from the seam's immutable views when the hook is called: ASCII camelCase keys, values are ints, bools and (for the two history fields) arrays of ints. Meters are the whole number the original tests (0 to 100). Things have stable ids (a guest's thing id and birth id, an attraction's id), never an index into a list. A view cannot be changed or kept.

Each table has 17 to 28 entries, far below the view caps (4096 entries, 1024-character strings).

Quick reference#

All hooks receive the host's answer as the last parameter, prev, and every view is a read-only table of ints and bools (history fields are arrays of ints).

HookParametersReturnsViews
scoreAttraction(guest, candidate, prev)guest view, candidate view, prev intint, 0 to 4294967295guest; candidate (attraction fields)
joinQueue(guest, attraction, prev)guest view, attraction view, prev boolbool (true admits)guest; attraction plus joinDifference, excitementWord, queueCount
leaveQueue(guest, attraction, prev)guest view, attraction view, prev boolbool (true leaves)guest; attraction plus joinTurn, waitedTurns, position, queueCount
wanderGoal(guest, prev)guest view, prev int (y * 1024 + x)int, y * 1024 + x of a cell inside the mapguest

Guest fields: id, birthId, type, happiness, thirst, hunger, toilet, nausea, money, cellX, cellY, usedHistory, temporaryHistory, turn, raining, mapWidth, mapHeight. Attraction fields: id, typeId, kind, hasJoinCell, backX, backY, entranceX, entranceY, cellModifier, queueLength, queueSizeInCells, queueLimit, excitement, excitementLevel, thirstEffect, hungerEffect, providesRelief, ageDays, isIndoors, goldenTicketCost, upgradeCost, isOpen, isBroken, sameTypeAsLast. A mod can implement any subset of the four hooks (scriptApi >=1.0.0 <2.0.0).

Failure counters and the disabled flag#

Per mod, ScriptModInstance keeps three failure counters, a ticks-over-budget counter and a flag, simulation state (saved in the ScriptMods section, hashed), because they change which hooks run:

The tick budget and a decision. The tick budget protects frame time; it must not punish a mod for a busy park (a park holds up to 1000 guests, and the calls of a tick grow with guests times attractions) and must not mix two scales of score in one comparison. So: outside a candidate loop (joinQueue, leaveQueue, wanderGoal, a single score) a call needs budget left in the tick; a call cut short by what is left of the tick rolls back its state, answers prev and is an overrun, no failure; later calls of the tick answer prev without running. A scoreAttraction candidate loop is one decision: the host brackets it (IGuestDecisions.BeginDecision / EndDecision), and at its start each mod is either admitted for all candidates or skipped for all (and then every candidate has the previous result, so the scores of one decision never mix the mod's scale with the base policy's). An admitted decision runs against the per-call budget only; the tick meter is charged and may go below zero, so the next decision of the tick is skipped. One decision costs at most candidates times 5 000 steps. A call inside an admitted decision that fails on its own (error, invalid result, own budget) still counts as a failure and answers prev for that candidate only.

Every failure rolls the call's state back and returns prev. After 16 failures in total (ScriptLimits.DisableAfterFailures) the mod is disabled for the rest of the park: the call that reaches 16 returns prev, sets the flag and writes one warning to the log naming the mod, the counters and the last failure; its hooks never run again, its state stays as it was and is still saved. The flag is saved, so a resumed park stays disabled. Reasons for 16: a mod that is wrong fails on nearly every call and is gone within a tick or two, while a rare edge case (an overflow in an unusual park) has a few failures to show itself in the log before the mod stops. The other mods keep running. There is no re-enabling in the park; start it without the mod or fix the mod and start a new park. --guest-report --guest-mod prints failures and the number of seeds that disabled a mod.

Budgets (measured)#

The budgets are in ScriptLimits: DefaultStepsPerCall 5 000 and DefaultStepsPerTick 50 000 (per mod, over all its calls; the tick is one GuestSimulation tick, 60 per second). They were set from measured workloads, with the guest report and its --guest-mod option (--guest-scale extended, 8 seeds, park-scenario and the four level parks of the M3 gate, so the real queues and scripts of the shipped themes). Three mods ran:

Mod / parkCalls (8 seeds)Steps per call, meanSteps per call, maxSteps per tick, max (calls)
example, park-scenario43 6189.850150 (13)
example, jungle274 32010.131382 (32)
example, hallow44 1959.91074 (8)
example, fantasy356 35310.031422 (40)
example, space331 89110.028456 (43)
light, park-scenario64 97135.61122 142 (30)
light, jungle341 47920.11202 738 (55)
light, hallow71 05621.21241 018 (16)
light, fantasy407 06316.31202 034 (56)
light, space376 93016.31202 534 (65)
state, park-scenario65 64072.1842 438 (30)
state, jungle341 87749.1542 548 (52)
state, hallow69 07236.045591 (16)
state, fantasy405 09550.6542 813 (57)
state, space380 97350.3543 188 (64)

No failure of any kind occurred. The heaviest call took 124 steps and the busiest tick 3 188 steps (64 calls); the defaults leave a factor of 40 per call and 15 per tick over those. Speed: the interpreter ran 77 million steps a second in a Debug build on the development Mac (a simple arithmetic loop; release builds and the browser's AOT differ), so the per-tick budget is about 0.65 ms there: per mod, a mod that burns all of it every tick costs under 4% of a 16.7 ms tick (under 15% if the browser build runs four times slower). That counts interpreter steps only; building the views for each call and the host's path search (FindPath) that a wanderGoal can force by naming a far cell are unmetered host work, outside the budget. A larger park raises the tick's calls roughly with guests times attractions, so the per-tick budget is the one to watch. The calibration parks above hold about 30 to 90 guests and 4 to 7 attractions. Scaled up (ParkScenario with a group every turn, test ACrowdedParkNeverDisablesTheStateMod) the scenario peaked at 271 guests and the state mod's busiest tick took 2 352 steps (49 calls), under the budget; projecting to the 1000-guest cap with 20 attractions (about 10 times the calls) gives 25 000 to 35 000 steps for that mod, and a mod five times heavier than state in such a park would overrun the tick. That is allowed to happen: the mod is then skipped for the rest of the tick (the base policy answers) and TicksOverBudget grows, but it is never disabled for it. Because the whole of state is copied (on the first write of a call) and validated (on every write), a mod that writes a large state on every call pays about two steps per node: a call that writes into a 2 000-node state is at the call budget. Keep the state small or write it rarely.

Object lights are not a script-mod hook#

TPW Script mods answer the four guest hooks only. Lights belong to the objects' own RSE scripts (ENABLELIGHT, DISABLELIGHT, SETLIGHT, COLOURLIGHT) and their models, which a data mod brings with objects.json: see LIGHTS.md and the example opentpw.example.lamp-lights. A light is presentation, so such a mod needs no script and changes no simulation hash (a mod with objects is still recorded in park saves as MODS.md describes).

The example mod#

opentpw.example.patient-guests (official, off by default, not in the web build) implements joinQueue and leaveQueue and keeps two counters in state:

--guest-report --guest-scale extended --guest-mod opentpw.example.patient-guests against the same run without it, through --guest-compare (3 standard errors, 8 seeds):

ScenarioMetricBaselineWith the modChangeVerdict
park-scenarioqueue.boarded.rate0.5600.630+8.7 SEimproved
park-scenarioqueue.rejected.rate0.3920.322-9.2 SEimproved
park-scenariouse.giniRides0.1970.108-10.6 SEimproved
park-scenariouse.giniAll0.2970.246-5.0 SEchanged
level-junglequeue.wait.p99653593-8.3 SEimproved
level-fantasyqueue.wait.p991048599-40.0 SEimproved
level-fantasyqueue.abandoned.rate0.0340.087+11.6 SEchanged

In the scenario the excitement refusals fall from 233 (95 too boring, 138 too scary) to 37 across the eight seeds. The long waits of the level parks are cut off by the 600-turn patience, which is also why more guests abandon queues there. The guests' end state differs from the baseline in all 8 seeds of the scenario, of jungle and of fantasy, in 2 of 8 of space and in none of hallow (that park never refuses on excitement nor keeps a guest waiting 600 turns); the mod reports no failure. The same seeds give the same report.

Safety and recovery#

Security notes#

TPW Script is a cooperative sandbox: its safety comes from the language having no way to name anything dangerous, plus budgets, not from operating-system isolation. It is meant to stop accidents and hostile-looking content from shared mods, not to contain a compromised host process. Concretely:

Implementation map (phase 2)#

File (source/OpenTPW/Scripting/)Role
ScriptLexer.cs, ScriptCompiler.csLexer and single-pass parser that emits bytecode, with all static limits and language restrictions.
ScriptProgram.csCompiled program, bytecode and the source hash.
ScriptInterpreter.csThe budgeted bytecode loop.
ScriptHostFunctions.cs, ScriptRng.csThe whitelist and the stateless rng.
ScriptValue.cs, ScriptState.csValues and tables; the state schema, canonical form and parser.
ScriptHost.csCall: transactions, typed results, prev semantics, the per-tick budget.
ScriptLimits.cs, ScriptErrors.csEvery limit; error types.

Phase 4 (game wiring, source/OpenTPW/World/Guests/):

FileRole
Decisions/ScriptGuestDecisions.cs, Decisions/ScriptHookViews.csThe wrapping policy, the hook mapping and the script views.
ScriptMods/ScriptModRuntime.cs, ScriptMods/ScriptModInstance.csThe enabled mods in chain order; per mod the compiled programs, state, step meters, counters and the disabled flag.
ScriptMods/ScriptModsSave.csThe ScriptMods section: capture, strict validation, restore.
Client/GuestReport.cs--guest-mod and the per-mod step statistics.

Tests: ScriptHooksTests (chain, prev, failures, budgets, disabling, every hook's mapping, views, rng), ScriptModsSaveTests (the section, validation, restore, hash, a resumed park, the whole park save) and the two script pins in DeterminismTests (ScriptModsFixedRunHash, ScriptModsAllHooksFixedRunHash).

Tests: ScriptLanguageTests (grammar and semantics), ScriptSandboxTests (escape and denial-of-service corpus, limits at their boundaries), ScriptStateTests (transactions, the canonical round trip, the schema, the RNG and a golden hash of a script corpus that must match on the windows, macOS and ubuntu CI runs). Scripting/ is also part of the forbidden-API scan in DeterminismTests.

Phases#

  1. Docs: this page and the rewritten rule in MODS.md. Done.

  2. Language core (this folder, tests, determinism scan). Done. No game wiring.

  3. Manifest and loading: content.scripts, hooks, scriptApi ranges, the verified bytes, script limits, "contains scripts", safe mode, and the compile-only opentpw.example.patient-guests. Done. No hooks into the simulation.

  4. Hooks with persistence: the IGuestDecisions seam, the ScriptMods section, counters, hashing (no schema bump, see above), the patient-guests example and a cross-platform continuation hash. Done.

  5. Browser: an AOT publish-and-run check and the example mod in the browser; script mods through OPFS import once mod-system phase 8 exists. Later.

  6. Read-only event hooks, UI-only hooks, more decision points, a mod-author guide and --test-mod. Later.

Source: docs/SCRIPT-MODS.md in the project repository.