feat(mods): flow patches, new events in an event flow #2656

Merged
HumanBean merged 3 commits from ChloeNow/Longshot:feat/mods-flow-patches-v2 into mod-api 2026-11-28 04:27:59 +00:00
Contributor

Summary

A mod can't change one of the game's event flows (the cutscenes and scripted moments: a song played, a door's question,
a chest) without shipping a whole replaced copy of the game's file. That copy is game data, so it can't be shared, and
two mods changing one flow overwrite each other.

This adds a new kind of typed patch, "flow", next to ops, rows, placements, texts, flags and rails, in a mod's
patches/ folder or through content.patch. It names the flow's own events, so the mod ships none of the game's file:

{ "target": "Event/EventFlow/Dm_SY_Ocarina.bfevfl.zs",
  "flow": [
    { "op": "action", "id": "Tune", "actor": "GameSystemActor", "action": "EventTriggerPlayAutoFixedTune",
      "params": { "IsLearningWarpMelodyDemo": false }, "next": "Event137" },
    { "op": "branch", "id": "TuneIfSung", "before": "Event171", "flag": ":Sung", "then": "Tune" } ] }
  • action: a new action event, an actor and action the flow already has, with params, then its next event.
  • branch: a check of a bool flag before an event. Whatever went to that event (events before it, a switch's
    cases, a fork's branches, an entry point) goes to the check; clear goes on as before, set goes to then. Two checks
    before one event chain. A fork's join is never moved. The flag is the game's by its name, or a content flag by its id
    (":Sung" the mod's own, "owner/name:Sung" another's), as the runtime takes content.

Each mod's new events are named after it (local/my-mod.Tune: its id, a . and the op's), so mods never collide, and their patches
apply in the Mods list's order, each on the one before's output. An op naming something the flow doesn't have is left
out with its reason in the log; the rest apply, as with the other typed patches. Flow patches never conflict. The
target's own header (BFEVFL) picks the applier: a flow patch aimed at another file fails by itself, and that file's
other patches still apply. A patched flow's cached file is named by each flow patch's mod id as well as its text, since
its events and flags are named after the mod.

Longshot writes the patched flow with its own writer: every byte of the game's file before its relocation table is
kept (a flow is taken only when its flowchart, events and the pointers its table names are all before that table), the
events move to a longer array after it, the new events' params (with a DIC built as Nintendo's tree, so the
game finds each param by name), cases and texts follow, then a new relocation table. The game's
EventQueryIsGameDataBool answers 0 for a set flag and 1 for a clear one, so a check's case 0 is "then". A text
param is at most 65535 bytes, the longest the format's u16 length holds.

Read first: game/crates/content/src/evfl.rs (the reader, the ops and the writer), then read_flow_op in
content/src/patch/parse.rs and the flow branch of apply in content/src/merge.rs; the schema's
ContentPatchFlowOp types it for content.patch (the test game reads patches with the same reader). Docs:
docs/modding/files.md, "Event flows".

This is #2578 moved onto the current mod-api (rewritten since), on a new branch so the pull request is only this
change; #2578 can close. It was #2268's change to the C mod API first. Part of #1958's Modding API; targets mod-api.
Magic Singing uses it with songPlayed (#2658).

Testing

Tested: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24. In the game (a quick build of this head on
current mod-api, which has the flags by id, #2657, and songPlayed, #2658; dev.py game-tests, the repository's
kokiri-start): a
test mod with Magic Singing's 96-op patch on the ocarina's flow (Dm_SY_Ocarina) and its two content flags. The patch
applies at the start with no op refused, the game loads the patched flow (Dm_SY_Ocarina.bfevfl.zs <- modcache\files\... (made of the mods' copies)), and the mod's test passes in play. This build made the patched flow
fresh, and it is byte for byte the file served on the previous mod-api, which was read back with the evfl library: all 96 ops as written (the actions' actors, actions, params and next; each
check EventQueryIsGameDataBool on the mod's flag, case 0 to then), the 330 original events unchanged but their
links, the 102 links into the 46 checked events moved to each chain's first check, no fork's join moved, the 20 entry
points as they were.

Checks: cargo test -p content (evfl's own tests on a made-up flow, read back by a reader of the test's own: two
mods' actions and checks in order, their params found by name through the DIC as the game looks them up, the bytes
kept, every pointer in the relocation table; a flag by a mod's id, the patching mod's own and another's; bad patch
files and a file that is not an event flow refused; the output past the largest flow refused; the DIC finding every
name of many; a flow whose flowchart is after its relocation table, or whose table names a pointer past the data,
refused; a text param of 65535 bytes applied whole and one of 65536 left out. merge's tests: two mods' flow patches
served in order; the same patch text under another mod's id made again for it; a flow patch aimed at a parameter file
failing alone, the file's other patch applied. Each of the review's four tests failed on the commit before the fix. The content vectors, which hold the reader to
the flow rules); cargo check --workspace --all-targets; cargo run -p schema-gen -- --check; rustfmt.

Still to test:

  • Linux, and clippy with warnings as errors: mise run rust and mise run test (by hand, or CI)
  • The patched flow played with a check's flag set (songPlayed is in mod-api now): a by-hand playtest, as a headless
    run cannot play the ocarina

Measurements

Nothing to measure in play: the patch is applied once at the start, with the merged files; a patched flow is a few
kilobytes larger than the game's.

Risks

Only mods that ship a "flow" patch reach the new code; with none, nothing changes. A flow patch that routes the game
somewhere wrong is the mod's to fix (turning the mod off restores the game's flow). The generated docs' schema hash
(docs/modding/*.md) conflicts with any other schema change: whichever of this and #2657 merges second needs
cargo run -p schema-gen again.

Checklist

Ready for review

  • One topic, on current mod-api; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary A mod can't change one of the game's event flows (the cutscenes and scripted moments: a song played, a door's question, a chest) without shipping a whole replaced copy of the game's file. That copy is game data, so it can't be shared, and two mods changing one flow overwrite each other. This adds a new kind of typed patch, `"flow"`, next to `ops`, `rows`, `placements`, `texts`, `flags` and `rails`, in a mod's `patches/` folder or through `content.patch`. It names the flow's own events, so the mod ships none of the game's file: ```json { "target": "Event/EventFlow/Dm_SY_Ocarina.bfevfl.zs", "flow": [ { "op": "action", "id": "Tune", "actor": "GameSystemActor", "action": "EventTriggerPlayAutoFixedTune", "params": { "IsLearningWarpMelodyDemo": false }, "next": "Event137" }, { "op": "branch", "id": "TuneIfSung", "before": "Event171", "flag": ":Sung", "then": "Tune" } ] } ``` - **`action`**: a new action event, an actor and action the flow already has, with params, then its next event. - **`branch`**: a check of a bool flag before an event. Whatever went to that event (events before it, a switch's cases, a fork's branches, an entry point) goes to the check; clear goes on as before, set goes to `then`. Two checks before one event chain. A fork's join is never moved. The flag is the game's by its name, or a content flag by its id (`":Sung"` the mod's own, `"owner/name:Sung"` another's), as the runtime takes content. Each mod's new events are named after it (`local/my-mod.Tune`: its id, a `.` and the op's), so mods never collide, and their patches apply in the Mods list's order, each on the one before's output. An op naming something the flow doesn't have is left out with its reason in the log; the rest apply, as with the other typed patches. Flow patches never conflict. The target's own header (`BFEVFL`) picks the applier: a flow patch aimed at another file fails by itself, and that file's other patches still apply. A patched flow's cached file is named by each flow patch's mod id as well as its text, since its events and flags are named after the mod. Longshot writes the patched flow with its own writer: every byte of the game's file before its relocation table is kept (a flow is taken only when its flowchart, events and the pointers its table names are all before that table), the events move to a longer array after it, the new events' params (with a DIC built as Nintendo's tree, so the game finds each param by name), cases and texts follow, then a new relocation table. The game's `EventQueryIsGameDataBool` answers **0 for a set flag and 1 for a clear one**, so a check's case 0 is "then". A text param is at most 65535 bytes, the longest the format's u16 length holds. Read first: `game/crates/content/src/evfl.rs` (the reader, the ops and the writer), then `read_flow_op` in `content/src/patch/parse.rs` and the flow branch of `apply` in `content/src/merge.rs`; the schema's `ContentPatchFlowOp` types it for `content.patch` (the test game reads patches with the same reader). Docs: `docs/modding/files.md`, "Event flows". This is #2578 moved onto the current `mod-api` (rewritten since), on a new branch so the pull request is only this change; #2578 can close. It was #2268's change to the C mod API first. Part of #1958's Modding API; targets `mod-api`. Magic Singing uses it with `songPlayed` (#2658). ## Testing **Tested:** Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24. In the game (a quick build of this head on current `mod-api`, which has the flags by id, #2657, and `songPlayed`, #2658; `dev.py game-tests`, the repository's `kokiri-start`): a test mod with Magic Singing's 96-op patch on the ocarina's flow (`Dm_SY_Ocarina`) and its two content flags. The patch applies at the start with no op refused, the game loads the patched flow (`Dm_SY_Ocarina.bfevfl.zs <- modcache\files\... (made of the mods' copies)`), and the mod's test passes in play. This build made the patched flow fresh, and it is byte for byte the file served on the previous `mod-api`, which was read back with the evfl library: all 96 ops as written (the actions' actors, actions, params and next; each check `EventQueryIsGameDataBool` on the mod's flag, case 0 to `then`), the 330 original events unchanged but their links, the 102 links into the 46 checked events moved to each chain's first check, no fork's join moved, the 20 entry points as they were. Checks: `cargo test -p content` (`evfl`'s own tests on a made-up flow, read back by a reader of the test's own: two mods' actions and checks in order, their params found by name through the DIC as the game looks them up, the bytes kept, every pointer in the relocation table; a flag by a mod's id, the patching mod's own and another's; bad patch files and a file that is not an event flow refused; the output past the largest flow refused; the DIC finding every name of many; a flow whose flowchart is after its relocation table, or whose table names a pointer past the data, refused; a text param of 65535 bytes applied whole and one of 65536 left out. `merge`'s tests: two mods' flow patches served in order; the same patch text under another mod's id made again for it; a flow patch aimed at a parameter file failing alone, the file's other patch applied. Each of the review's four tests failed on the commit before the fix. The content vectors, which hold the reader to the flow rules); `cargo check --workspace --all-targets`; `cargo run -p schema-gen -- --check`; rustfmt. **Still to test:** - Linux, and clippy with warnings as errors: `mise run rust` and `mise run test` (by hand, or CI) - The patched flow played with a check's flag set (`songPlayed` is in `mod-api` now): a by-hand playtest, as a headless run cannot play the ocarina ## Measurements Nothing to measure in play: the patch is applied once at the start, with the merged files; a patched flow is a few kilobytes larger than the game's. ## Risks Only mods that ship a `"flow"` patch reach the new code; with none, nothing changes. A flow patch that routes the game somewhere wrong is the mod's to fix (turning the mod off restores the game's flow). The generated docs' schema hash (`docs/modding/*.md`) conflicts with any other schema change: whichever of this and #2657 merges second needs `cargo run -p schema-gen` again. ## Checklist ### Ready for review - [x] One topic, on current `mod-api`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). <!-- Windows run as Testing says; clippy and Linux: CI --> - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. <!-- Windows built and played; Linux: CI --> - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(mods): flow patches, new events in an event flow (Rust)
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
0fa1c22a4f
A "flow" patch adds events to an event flow (Event/EventFlow/<name>.bfevfl.zs) by the flow's own event names:
"action" (an actor's action the flow has, its params, then next) and "branch" (a bool flag checked before an
event: set, on to "then"; clear, on to "before"). The flag is the game's by its name or a content flag by its id
(":Sung", "owner/name:Sung"); each op's id is the mod's own, its event named after the mod.

content::evfl reads the BFEVFL (0x300/0x400), keeps every byte of the game's file and writes the new events,
their params, names and the relocation table after it. merge applies a flow's patches in the mods' order, each on
the previous one's output; an op that does not apply is left out and logged. Flow patches never conflict.

The patch reader and the schema's ContentPatch take the new kind (the test game reads patches with the same
reader); the content vectors hold it to the flow rules. Ported from the C mod API's PR #2268.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: Windows 11, RTX 4060 Laptop, a quick build of current mod-api with this and the flags by id: a test mod with Magic Singing's 96-op patch on Dm_SY_Ocarina applies it with no op refused, the game makes and loads the patched flow, and the mod's test passes in play (dev.py game-tests, kokiri-start); the flow is byte for byte the one read back with the evfl library before.

Tested in game: Windows 11, RTX 4060 Laptop, a quick build of current mod-api with this and the flags by id: a test mod with Magic Singing's 96-op patch on Dm_SY_Ocarina applies it with no op refused, the game makes and loads the patched flow, and the mod's test passes in play (dev.py game-tests, kokiri-start); the flow is byte for byte the one read back with the evfl library before.
Owner
@review
BeanBot requested changes 2026-11-27 23:10:07 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. Flow patches can reuse another mod’s cached output, and an invalid flow patch can suppress valid patches to the same file. Malformed flow data can also reach unchecked writes during startup.

Adds typed patches that let mods add actions and flag checks to event flows without distributing game data. The approach enables composition, but its cache key and input handling need correction before players can rely on it.

Blocking (4): must change before merging.

  1. L1 game/crates/content/src/merge.rs:869: The merged-file cache key does not include the mod IDs that determine flow event and flag names. (more on the line) Do: Include each flow patch’s owning mod ID in the cache key, and test switching between two owners with identical patch text.
  2. L2 game/crates/content/src/merge.rs:860: Any flow patch selects the flow applier for the entire target, even when the target is a BYML or text file. (more on the line) Do: Select the applier from the target data or otherwise reject incompatible patches without suppressing compatible patches.
  3. L3 game/crates/content/src/evfl.rs:341: The reader checks writable structures against the whole input, but the writer copies only the bytes before the relocation table. (more on the line) Do: Validate that the flowchart and every structure the writer modifies fit wholly before RELT, and reject invalid relocation pointers and ranges before writing.
  4. L6: It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first). (for the author)

Should fix (1): not blocking, but worth doing before merging.

  • L4 game/crates/content/src/evfl.rs:669: String parameters can exceed the format’s 16-bit length, but the writer silently records 65535 for every longer string. (more on the line) Do: Reject string parameters that cannot be represented in the flow format, with a boundary test.

Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)

  • L5: The set-flag route of the new branch has not been exercised in the game. When: A mod sets its content flag and reaches a patched branch; the reported run only covers the clear state, so it does not show that the game takes the new action when the flag is set. Do: Run a patched flow in game with the flag both clear and set, and record the observed destinations.

@fix can do L1, L2, L3 and L4.

Checks: Still running: Guide screenshots / Guide images and local UI source review (pull_request), Third-party parts / As their notes say (pull_request), Third-party parts / The same as upstream (pull_request).

More: does it help, other systems, switches, what was read

Does it help: Unproven: the reported Windows play test loaded and played a 96-op patch with clear flags, but the set-flag route has not been played. This is a feature, not a performance change.

Other systems: The patcher runs on Windows and Linux and can process mod-supplied replacement files as well as game files. The reported game run covers Windows and one flow; Linux and the set-flag route remain untested. No renderer, audio, input, or save changes are apparent.

Switches: None.

Reviewed: 0fa1c22a4f against 3391f978eb: Read the repository rules, available PR template, standards, commit, changed flow writer and patch integration, and their relevant callers. Reviewed the changed schema and documentation; skimmed generated documentation and content vectors. The Tooling checkout and docs/review-checklist.md were absent. Large existing files were read around the changed paths rather than in full.; nothing run (a code review).

Checked and fine:

  • The commit records AI assistance.
  • The reported Windows run provides evidence that the patched flow loads and the clear-flag path plays.
  • No switch or renderer API change is introduced.

Testing: No commands from the project, builds, or tests were run; this was a read-only review. The author reports content tests, workspace checking, schema checking, formatting, and a Windows game run; Linux and the set-flag game run remain outstanding.

Overlaps and merge order: #2578 is the earlier version of this change and is identified for closure; #2657 supplies the flag-by-ID integration used in the reported game run and overlaps generated schema documentation.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** Flow patches can reuse another mod’s cached output, and an invalid flow patch can suppress valid patches to the same file. Malformed flow data can also reach unchecked writes during startup. Adds typed patches that let mods add actions and flag checks to event flows without distributing game data. The approach enables composition, but its cache key and input handling need correction before players can rely on it. **Blocking (4)**: must change before merging. 1. **L1** `game/crates/content/src/merge.rs:869`: The merged-file cache key does not include the mod IDs that determine flow event and flag names. (more on the line) **Do:** Include each flow patch’s owning mod ID in the cache key, and test switching between two owners with identical patch text. 2. **L2** `game/crates/content/src/merge.rs:860`: Any flow patch selects the flow applier for the entire target, even when the target is a BYML or text file. (more on the line) **Do:** Select the applier from the target data or otherwise reject incompatible patches without suppressing compatible patches. 3. **L3** `game/crates/content/src/evfl.rs:341`: The reader checks writable structures against the whole input, but the writer copies only the bytes before the relocation table. (more on the line) **Do:** Validate that the flowchart and every structure the writer modifies fit wholly before RELT, and reject invalid relocation pointers and ranges before writing. 4. **L6**: It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first). *(for the author)* **Should fix (1)**: not blocking, but worth doing before merging. - **L4** `game/crates/content/src/evfl.rs:669`: String parameters can exceed the format’s 16-bit length, but the writer silently records 65535 for every longer string. (more on the line) **Do:** Reject string parameters that cannot be represented in the flow format, with a boundary test. **Testing before merging (1)** (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation) - **L5**: The set-flag route of the new branch has not been exercised in the game. *When:* A mod sets its content flag and reaches a patched branch; the reported run only covers the clear state, so it does not show that the game takes the new action when the flag is set. **Do:** Run a patched flow in game with the flag both clear and set, and record the observed destinations. `@fix` can do L1, L2, L3 and L4. **Checks:** Still running: `Guide screenshots / Guide images and local UI source review (pull_request)`, `Third-party parts / As their notes say (pull_request)`, `Third-party parts / The same as upstream (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven: the reported Windows play test loaded and played a 96-op patch with clear flags, but the set-flag route has not been played. This is a feature, not a performance change. **Other systems:** The patcher runs on Windows and Linux and can process mod-supplied replacement files as well as game files. The reported game run covers Windows and one flow; Linux and the set-flag route remain untested. No renderer, audio, input, or save changes are apparent. **Switches:** None. **Reviewed:** 0fa1c22a4f8b against 3391f978ebd9: Read the repository rules, available PR template, standards, commit, changed flow writer and patch integration, and their relevant callers. Reviewed the changed schema and documentation; skimmed generated documentation and content vectors. The Tooling checkout and docs/review-checklist.md were absent. Large existing files were read around the changed paths rather than in full.; nothing run (a code review). **Checked and fine:** - The commit records AI assistance. - The reported Windows run provides evidence that the patched flow loads and the clear-flag path plays. - No switch or renderer API change is introduced. **Testing:** No commands from the project, builds, or tests were run; this was a read-only review. The author reports content tests, workspace checking, schema checking, formatting, and a Windows game run; Linux and the set-flag game run remain outstanding. **Overlaps and merge order:** #2578 is the earlier version of this change and is identified for closure; #2657 supplies the flag-by-ID integration used in the reported game run and overlaps generated schema documentation. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -0,0 +338,4 @@
f.nevents = usize::from(r16(b, f.fc + FC_EVENTS_N));
f.nentries = usize::from(r16(b, f.fc + 0x18));
let (actors, events, entries) = (r64(b, f.fc + FC_ACTORS), r64(b, f.fc + FC_EVENTS), r64(b, f.fc + FC_ENTRIES));
if (f.nactors > 0 && !f.holds(actors, (f.nactors * ACTOR_SIZE) as u64))
Member

L3 (blocking): The reader checks writable structures against the whole input, but the writer copies only the bytes before the relocation table.

When: A malformed mod-supplied flow can place its flowchart after a valid RELT header while keeping it inside the input. flow_read accepts it, but a valid action op reaches write, which indexes the shorter pre-RELT copy at the flowchart offset and panics during startup.

Do: Validate that the flowchart and every structure the writer modifies fit wholly before RELT, and reject invalid relocation pointers and ranges before writing.

**L3** (blocking): The reader checks writable structures against the whole input, but the writer copies only the bytes before the relocation table. *When:* A malformed mod-supplied flow can place its flowchart after a valid RELT header while keeping it inside the input. flow_read accepts it, but a valid action op reaches write, which indexes the shorter pre-RELT copy at the flowchart offset and panics during startup. **Do:** Validate that the flowchart and every structure the writer modifies fit wholly before RELT, and reject invalid relocation pointers and ranges before writing.
@ -0,0 +666,4 @@
let str_at = o.room(2 + s.len() + 1)?;
w64(&mut o.b, slot, str_at as u64);
o.ptr(slot);
w16(&mut o.b, str_at, u16_of(s.len()));
Member

L4 (should fix): String parameters can exceed the format’s 16-bit length, but the writer silently records 65535 for every longer string.

When: A patch under the 1 MiB patch limit can supply a 65536-byte action parameter. It is accepted and written in full with a 65535 length, so the game reads a different value from the one the mod supplied.

Do: Reject string parameters that cannot be represented in the flow format, with a boundary test.

**L4** (should fix): String parameters can exceed the format’s 16-bit length, but the writer silently records 65535 for every longer string. *When:* A patch under the 1 MiB patch limit can supply a 65536-byte action parameter. It is accepted and written in full with a 65535 length, so the game reads a different value from the one the mod supplied. **Do:** Reject string parameters that cannot be represented in the flow format, with a boundary test.
@ -858,2 +858,3 @@
let texts = reads.iter().any(|r| r.patch.kind == PatchKind::Texts);
let (made, failures) = if texts {
let flows = reads.iter().any(|r| r.patch.kind == PatchKind::Flow);
let (made, failures) = if flows {
Member

L2 (blocking): Any flow patch selects the flow applier for the entire target, even when the target is a BYML or text file.

When: If one mod has a valid BYML patch and another mistakenly targets the same file with a flow patch, the flow reader rejects the BYML and the valid patch is also rejected instead of being applied.

Do: Select the applier from the target data or otherwise reject incompatible patches without suppressing compatible patches.

**L2** (blocking): Any flow patch selects the flow applier for the entire target, even when the target is a BYML or text file. *When:* If one mod has a valid BYML patch and another mistakenly targets the same file with a flow patch, the flow reader rejects the BYML and the valid patch is also rejected instead of being applied. **Do:** Select the applier from the target data or otherwise reject incompatible patches without suppressing compatible patches.
@ -860,0 +866,4 @@
uses.iter().filter(|u| u.patch.kind == PatchKind::Flow).copied().collect();
let index: Vec<usize> =
uses.iter().enumerate().filter(|(_, u)| u.patch.kind == PatchKind::Flow).map(|(i, _)| i).collect();
let out = crate::evfl::apply(base, &flow_uses, &mod_id);
Member

L1 (blocking): The merged-file cache key does not include the mod IDs that determine flow event and flag names.

When: Two mods ship identical flow patch text, including a branch on :Sung. After the first mod’s output is cached, replacing it with the second leaves the target, base and patch text unchanged, so serve reuses the first mod’s flow and checks the first mod’s flag.

Do: Include each flow patch’s owning mod ID in the cache key, and test switching between two owners with identical patch text.

**L1** (blocking): The merged-file cache key does not include the mod IDs that determine flow event and flag names. *When:* Two mods ship identical flow patch text, including a branch on :Sung. After the first mod’s output is cached, replacing it with the second leaves the target, base and patch text unchanged, so serve reuses the first mod’s flow and checks the first mod’s flag. **Do:** Include each flow patch’s owning mod ID in the cache key, and test switching between two owners with identical patch text.
ChloeNow force-pushed feat/mods-flow-patches-v2 from 0fa1c22a4f
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
to f277e0d263
Some checks are pending
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 5s
2026-11-28 02:08:59 +00:00
Compare
Author
Contributor

Review answered, on f277e0d2 (rebased on current mod-api). The review's points are each a test first (9b3cbfa4, every one failing for its reason), then the fix (f277e0d2):

  • L1 (cache key): a patched file's cache name now takes each flow patch's mod id beside its text, so the same text under another mod (or a renamed one) is made again with its own event names and flags. Test: one patch, two runs naming its mod differently over one cache.
  • L2 (applier): the target's own header (BFEVFL) picks the applier, not the patches' kind. A flow patch aimed at any other file fails by itself ("is no event flow"), and that file's other patches still apply; the reverse is as before. Test: a parameter patch and a flow patch on one parameter file, the parameter patch applied. (Text patches still pick their applier by kind, as on mod-api; that rule is older than this PR.)
  • L3 (bounds): a flow is taken only when its flowchart, actors, events and entry points all end before its relocation table, and its table only when every pointer it names does. Test: the made-up flow with its flowchart moved past the table, and one whose table names a pointer in it, both refused (before, the first was written, quietly wrong).
  • L4 (long texts): an action's param over 65535 bytes, name or text, leaves its op out with why. Test: 65535 applies and is written whole, 65536 is refused.
  • L5 (the set route): still a playtest, which a headless run cannot do (it would have to play the ocarina). The headless run passes on this head: Magic Singing's 96-op patch applies with no op refused and the game loads the patched flow. A playtest mod that toggles the patch's flag is with the author; Still to test says so.
  • L6: rebased.
Review answered, on `f277e0d2` (rebased on current `mod-api`). The review's points are each a test first (`9b3cbfa4`, every one failing for its reason), then the fix (`f277e0d2`): - **L1 (cache key):** a patched file's cache name now takes each flow patch's mod id beside its text, so the same text under another mod (or a renamed one) is made again with its own event names and flags. Test: one patch, two runs naming its mod differently over one cache. - **L2 (applier):** the target's own header (`BFEVFL`) picks the applier, not the patches' kind. A flow patch aimed at any other file fails by itself ("is no event flow"), and that file's other patches still apply; the reverse is as before. Test: a parameter patch and a flow patch on one parameter file, the parameter patch applied. (Text patches still pick their applier by kind, as on `mod-api`; that rule is older than this PR.) - **L3 (bounds):** a flow is taken only when its flowchart, actors, events and entry points all end before its relocation table, and its table only when every pointer it names does. Test: the made-up flow with its flowchart moved past the table, and one whose table names a pointer in it, both refused (before, the first was written, quietly wrong). - **L4 (long texts):** an action's param over 65535 bytes, name or text, leaves its op out with why. Test: 65535 applies and is written whole, 65536 is refused. - **L5 (the set route):** still a playtest, which a headless run cannot do (it would have to play the ocarina). The headless run passes on this head: Magic Singing's 96-op patch applies with no op refused and the game loads the patched flow. A playtest mod that toggles the patch's flag is with the author; Still to test says so. - **L6:** rebased.
ChloeNow force-pushed feat/mods-flow-patches-v2 from f277e0d263
Some checks are pending
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 5s
to 611ec0d1a9
All checks were successful
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Title and description (pull_request_target) Successful in 6s
2026-11-28 02:26:09 +00:00
Compare
Author
Contributor

Rebased on current mod-api (f8193c1e): 611ec0d1, only the generated docs made again. cargo test -p content (268, the review's four tests among them), -p game-core, -p api (the same mod-api failure only), cargo check --workspace --all-targets and schema-gen --check pass.

Rebased on current `mod-api` (`f8193c1e`): `611ec0d1`, only the generated docs made again. `cargo test -p content` (268, the review's four tests among them), `-p game-core`, `-p api` (the same `mod-api` failure only), `cargo check --workspace --all-targets` and `schema-gen --check` pass.
Owner
@review
BeanBot left a comment

Recommendation: Request changes. It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first). (L6) The cache, applier, bounds and string-length fixes address the reported defects. The set-flag branch still needs an in-game playtest, and Forgejo reports the pull request as not mergeable.

Flow patches let mods add actions and flag checks without distributing replacement game files. The fixes preserve mod-specific cache output, isolate patches aimed at the wrong file type, and reject the reported unsafe flow layouts and oversized strings.

Blocking (1): must change before merging.

  1. L6: It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first). (for the author)

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5: The set-flag route of the new branch has not been exercised in the game. When: A mod sets its content flag and reaches a patched branch; the reported run only covers the clear state, so it does not show that the game takes the new action when the flag is set. Do: Run a patched flow in game with the flag both clear and set, and record the observed destinations.

Since the last review (on 0fa1c22a4f)
Resolved: L1 (The merged-file cache key does not include the mod IDs that determine flow event and flag…); L2 (Any flow patch selects the flow applier for the entire target, even when the target is a B…); L3 (The reader checks writable structures against the whole input, but the writer copies only…); L4 (String parameters can exceed the format’s 16-bit length, but the writer silently records 6…)
Still open: L5 (The set-flag route of the new branch has not been exercised in the game.); L6 (It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first).)

Also noticed (2; not asked for, not blocking)
  • Forgejo still reports the pull request as not mergeable, despite the rebase; its cause needs confirmation before merge.
  • Linux and the full project checks remain listed as untested.
More: does it help, other systems, switches, what was read

Does it help: Yes: the author reports that a 96-op patch applied and its test passed in play on Windows; the set-flag route remains untested in game. This is a feature, not a performance change.

Other systems: The writer runs during content merging on Windows and Linux and can affect patched flows and files targeted by mixed patch kinds. The reported Windows run and game-free tests cover the main path; Linux remains untested. GPU-specific behavior is not expected from this content change.

Switches: None.

Reviewed: 611ec0d1a9 against f8193c1ed1: Read the repository rules and pull request template, the flow reader, writer and operations relevant to the ledger, and the merge dispatch and cache paths. Skimmed the remaining diff, schema and generated documentation; the full changed code and recorded vectors were not read.; nothing run (a code review).

Checked and fine:

  • The reported boundary tests cover 65535- and 65536-byte text values.
  • Failure indices are mapped back to the original patch list after filtering mismatched kinds.

Testing: No commands from the project were run. The author reports content tests, workspace checking, schema checking and a Windows game run; the set-flag playtest and Linux checks remain outstanding.

Overlaps and merge order: #2578 is described as superseded by this pull request; #2657 can conflict in generated schema documentation.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first). (L6) The cache, applier, bounds and string-length fixes address the reported defects. The set-flag branch still needs an in-game playtest, and Forgejo reports the pull request as not mergeable. Flow patches let mods add actions and flag checks without distributing replacement game files. The fixes preserve mod-specific cache output, isolate patches aimed at the wrong file type, and reject the reported unsafe flow layouts and oversized strings. **Blocking (1)**: must change before merging. 1. **L6**: It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first). *(for the author)* **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5**: The set-flag route of the new branch has not been exercised in the game. *When:* A mod sets its content flag and reaches a patched branch; the reported run only covers the clear state, so it does not show that the game takes the new action when the flag is set. **Do:** Run a patched flow in game with the flag both clear and set, and record the observed destinations. **Since the last review** (on 0fa1c22a4f8b) Resolved: L1 (The merged-file cache key does not include the mod IDs that determine flow event and flag…); L2 (Any flow patch selects the flow applier for the entire target, even when the target is a B…); L3 (The reader checks writable structures against the whole input, but the writer copies only…); L4 (String parameters can exceed the format’s 16-bit length, but the writer silently records 6…) Still open: L5 (The set-flag route of the new branch has not been exercised in the game.); L6 (It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first).) <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - Forgejo still reports the pull request as not mergeable, despite the rebase; its cause needs confirmation before merge. - Linux and the full project checks remain listed as untested. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes: the author reports that a 96-op patch applied and its test passed in play on Windows; the set-flag route remains untested in game. This is a feature, not a performance change. **Other systems:** The writer runs during content merging on Windows and Linux and can affect patched flows and files targeted by mixed patch kinds. The reported Windows run and game-free tests cover the main path; Linux remains untested. GPU-specific behavior is not expected from this content change. **Switches:** None. **Reviewed:** 611ec0d1a90e against f8193c1ed1bf: Read the repository rules and pull request template, the flow reader, writer and operations relevant to the ledger, and the merge dispatch and cache paths. Skimmed the remaining diff, schema and generated documentation; the full changed code and recorded vectors were not read.; nothing run (a code review). **Checked and fine:** - The reported boundary tests cover 65535- and 65536-byte text values. - Failure indices are mapped back to the original patch list after filtering mismatched kinds. **Testing:** No commands from the project were run. The author reports content tests, workspace checking, schema checking and a Windows game run; the set-flag playtest and Linux checks remain outstanding. **Overlaps and merge order:** #2578 is described as superseded by this pull request; #2657 can conflict in generated schema documentation. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
Owner
@rebase
Member

I rebased this pull request onto mod-api (67a113a710): the new head is 3969aeb70d.

Conflicts resolved

  • docs/modding/permissions.md: Updated the combined schema hash.
  • docs/modding/reference.md: Updated the combined schema hash.
  • docs/modding/scripting.md: Updated the abbreviated combined schema hash.

Nothing was built or run: read the resolution before merging.


Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

I rebased this pull request onto `mod-api` (67a113a710ac): the new head is 3969aeb70d3b. **Conflicts resolved** - docs/modding/permissions.md: Updated the combined schema hash. - docs/modding/reference.md: Updated the combined schema hash. - docs/modding/scripting.md: Updated the abbreviated combined schema hash. Nothing was built or run: read the resolution before merging. --- <sub>Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
BeanBot force-pushed feat/mods-flow-patches-v2 from 611ec0d1a9
All checks were successful
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Title and description (pull_request_target) Successful in 6s
to 3969aeb70d
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Title and description (pull_request_target) Failing after 6s
2026-11-28 04:27:15 +00:00
Compare
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The set-flag route still needs an in-game playtest, and the pull request is reported as not mergeable despite the rebase. Recommend approval; not approved on the forge.

Flow patches let mods add actions and flag checks without distributing or replacing a whole game file. The change adds a flow reader and writer and makes patched files somewhat larger.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5: The set-flag route of the new branch has not been exercised in the game. When: A mod sets its content flag and reaches a patched branch; the reported run only covers the clear state, so it does not show that the game takes the new action when the flag is set. Do: Run a patched flow in game with the flag both clear and set, and record the observed destinations.

Since the last review (on 611ec0d1a9)
Resolved: L6 (It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first).)
Still open: L5 (The set-flag route of the new branch has not been exercised in the game.)

Checks: Still running: PR description / Title and description (pull_request_target).

More: does it help, other systems, switches, what was read

Does it help: Unproven for the complete feature: the reported Windows playtest loaded a 96-operation patch, but did not exercise a set flag routing to its target.

Other systems: The flow writer affects patched event flows on Windows and Linux; the reported playtest covers Windows. Unpatched files do not use the new flow writer.

Switches: None.

Reviewed: 3969aeb70d against 67a113a710: Read AGENTS.md and CONTRIBUTING.md, the current diffs for the three regenerated documentation files, the commit list, and the relevant set-flag references in evfl.rs and files.md. The remaining changed code and generated files were not read in full in this re-check.; nothing run (a code review).

Checked and fine:

  • The three changed generated-documentation lines use the same schema hash, with the scripting guide using its prefix.
  • The flow writer documents case 0 as the set-flag route.

Testing: No commands that build or run the project were executed. The author reports a Windows playtest and content tests; Linux and the set-flag playtest remain outstanding.

Overlaps and merge order: #2578 is the earlier version of this change; the description says it can close. #2657 and #2658 are related dependencies mentioned in the description.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The set-flag route still needs an in-game playtest, and the pull request is reported as not mergeable despite the rebase. Recommend approval; not approved on the forge. Flow patches let mods add actions and flag checks without distributing or replacing a whole game file. The change adds a flow reader and writer and makes patched files somewhat larger. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5**: The set-flag route of the new branch has not been exercised in the game. *When:* A mod sets its content flag and reaches a patched branch; the reported run only covers the clear state, so it does not show that the game takes the new action when the flag is set. **Do:** Run a patched flow in game with the flag both clear and set, and record the observed destinations. **Since the last review** (on 611ec0d1a90e) Resolved: L6 (It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first).) Still open: L5 (The set-flag route of the new branch has not been exercised in the game.) **Checks:** Still running: `PR description / Title and description (pull_request_target)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven for the complete feature: the reported Windows playtest loaded a 96-operation patch, but did not exercise a set flag routing to its target. **Other systems:** The flow writer affects patched event flows on Windows and Linux; the reported playtest covers Windows. Unpatched files do not use the new flow writer. **Switches:** None. **Reviewed:** 3969aeb70d3b against 67a113a710ac: Read AGENTS.md and CONTRIBUTING.md, the current diffs for the three regenerated documentation files, the commit list, and the relevant set-flag references in evfl.rs and files.md. The remaining changed code and generated files were not read in full in this re-check.; nothing run (a code review). **Checked and fine:** - The three changed generated-documentation lines use the same schema hash, with the scripting guide using its prefix. - The flow writer documents case 0 as the set-flag route. **Testing:** No commands that build or run the project were executed. The author reports a Windows playtest and content tests; Linux and the set-flag playtest remain outstanding. **Overlaps and merge order:** #2578 is the earlier version of this change; the description says it can close. #2657 and #2658 are related dependencies mentioned in the description. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.</sub>
HumanBean changed title from WIP: feat(mods): flow patches, new events in an event flow to feat(mods): flow patches, new events in an event flow 2026-11-28 04:27:51 +00:00
HumanBean merged commit bbfae8e8ef into mod-api 2026-11-28 04:27:59 +00:00
HumanBean deleted branch feat/mods-flow-patches-v2 2026-11-28 04:27:59 +00:00
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Title and description (pull_request_target) Failing after 6s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2656
No description provided.