Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
644aa83
Add version-aware capability queries to the mod API
Roxas2712 Oct 21, 2026
044ff92
Add opt-in unified mod content records across generations
Roxas2712 Oct 21, 2026
4822a59
Add opt-in unified hook and event record boundaries
Roxas2712 Oct 21, 2026
886fca5
Add detached read-only world and party queries
Roxas2712 Oct 21, 2026
9b7bc09
Add guarded public world actions and native flight
Roxas2712 Oct 21, 2026
5934814
Allow capability tests to follow additive native flight support
Roxas2712 Oct 21, 2026
52b0055
Add detached read-only battle snapshots for mods
Roxas2712 Oct 21, 2026
9044909
Add revision-bound public battle actions through native commands
Roxas2712 Oct 21, 2026
418b55f
Add revision-bound public party, bag and dialogue UI actions
Roxas2712 Oct 21, 2026
4bfa668
Add opt-in prevalidated portable world dialogue scripts
Roxas2712 Oct 22, 2026
b46e128
Add read-only map overview and encounter table queries
Roxas2712 Oct 22, 2026
40e8980
Integrate public API prerequisites (#90–#97)
Roxas2712 Oct 22, 2026
61edab0
Integrate portable script prerequisite (#98)
Roxas2712 Oct 22, 2026
4008ae2
Integrate world-overview prerequisite (#99)
Roxas2712 Oct 22, 2026
69c3474
Add shared API 3 entry and pinned cross-engine contracts
Roxas2712 Oct 22, 2026
6406891
Normalize public GBA enemy move choices and preserve native PP ownership
Roxas2712 Oct 24, 2026
206052f
Align API-3 GBA enemy-action battler selectors
Roxas2712 Oct 24, 2026
3f01f29
Expose shared API-3 GBA native move records
Roxas2712 Oct 24, 2026
f84dfb5
Honor portable GBA action targets through native execution
Roxas2712 Oct 24, 2026
c944bc0
Implement native GBA Follow Me targeting and round lifetime
Roxas2712 Oct 24, 2026
3edf776
Load composed effect probes in a single real mod session
Roxas2712 Oct 24, 2026
8052c79
Keep the composed effect probe within public content fields
Roxas2712 Oct 24, 2026
7f93af9
Use native GBA base-damage rounding
Roxas2712 Oct 24, 2026
45f5b4e
Apply native Gen-3 critical multiplier before type rounding
Roxas2712 Oct 24, 2026
8200b8d
Implement native GBA Helping Hand and shared damage modifier
Roxas2712 Oct 24, 2026
f09b570
Pin the composed effect proof's critical and variation inputs
Roxas2712 Oct 24, 2026
8c7df4d
Execute native GBA Spit Up with set-damage semantics
Roxas2712 Oct 24, 2026
ade8abd
Execute native GBA Beat Up with live party damage
Roxas2712 Oct 24, 2026
5538fa4
Use the shared canonical Beat Up effect identifier
Roxas2712 Oct 24, 2026
92ade2b
Read the active target species for native Beat Up defense
Roxas2712 Oct 24, 2026
45220e4
Align native GBA AI held-item knowledge and observation producers
Roxas2712 Oct 24, 2026
03d68a4
Verify native Beat Up held-item adjustment across engines
Roxas2712 Oct 24, 2026
c2a1a03
Read native Beat Up participants across both side parties
Roxas2712 Oct 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/api3-contract.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: API 3 contracts
on:
pull_request:
paths:
- '.github/workflows/api3-contract.yml'
- 'src/**'
- 'tests/api3_contract/**'
- 'tests/engine/api3_*.lua'
- 'tools/api3-contract-check/**'
push:
branches: [main, dev]
paths:
- '.github/workflows/api3-contract.yml'
- 'src/**'
- 'tests/api3_contract/**'
- 'tests/engine/api3_*.lua'
- 'tools/api3-contract-check/**'
permissions:
contents: read
concurrency:
group: api3-contract-${{ github.ref }}
cancel-in-progress: true
jobs:
compare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
path: gen2
sparse-checkout: |
src
data
tests
tools/api3-contract-check
- uses: actions/checkout@v7
with:
repository: bryanthaboi/gen1recomp
ref: 79ea62f45fb2ea8f65d081a109431e4eb1bbdb36
path: gen1-reference
sparse-checkout: |
src
data
tests
assets/fonts
- name: install LuaJIT
run: sudo apt-get update && sudo apt-get install -y luajit
- name: identical mod contracts on both engines
run: >-
python3 gen2/tools/api3-contract-check/check.py
--gen1 gen1-reference --gen2 gen2
--report "${{ runner.temp }}/api3-report.json"
- uses: actions/upload-artifact@v7
with:
name: api3-contract-report
path: ${{ runner.temp }}/api3-report.json
if-no-files-found: error
37 changes: 37 additions & 0 deletions .github/workflows/critical-order-contract.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: native critical/type ordering
on:
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: critical-order-${{ github.ref }}
cancel-in-progress: true
jobs:
contract:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v7
with:
repository: bryanthaboi/gen1recomp
ref: 535a5ec088c1ae1bf4d91dd3e35a56f64cf46d91
path: .contract-reference/gen1
- name: Install runtime
run: sudo apt-get update && sudo apt-get install -y luajit
- name: Check critical/type boundaries
run: |
luajit tests/engine/gen3_critical_order.lua
luajit tests/engine/critical_order_contract.lua
- name: Compare unchanged public consumer
run: |
mkdir -p /tmp/critical-order
python3 tools/critical-order-contract-check/check.py --gen1 .contract-reference/gen1 --host-api 3 --report /tmp/critical-order/api3.json
python3 tools/critical-order-contract-check/check.py --gen1 .contract-reference/gen1 --host-api 2 --report /tmp/critical-order/api2.json
- uses: actions/upload-artifact@v6
if: always()
with:
name: critical-order
path: /tmp/critical-order
if-no-files-found: ignore
58 changes: 58 additions & 0 deletions .github/workflows/enemy-action-contract.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Enemy move choice contracts
on:
pull_request:
paths:
- '.github/workflows/enemy-action-contract.yml'
- 'src/**'
- 'examples/portable_enemy_action/**'
- 'tests/enemy_actions/**'
- 'tests/engine/portable_enemy_action_*.lua'
- 'tests/engine/portable_enemy_move_records.lua'
- 'tests/engine/portable_enemy_targets.lua'
- 'tests/engine/gen3_follow_me.lua'
- 'tests/engine/gen3_helping_hand.lua'
- 'tests/engine/gen3_spit_up.lua'
- 'tests/engine/gen3_beat_up.lua'
- 'tests/engine/gen3_beat_up_adjustment.lua'
- 'tests/engine/gen3_beat_up_side_party.lua'
- 'tools/enemy-action-contract-check/**'
push:
branches: [main, dev]
permissions:
contents: read
concurrency:
group: enemy-action-contract-${{ github.ref }}
cancel-in-progress: true
jobs:
compare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
path: gen2
- uses: actions/checkout@v7
with:
repository: bryanthaboi/gen1recomp
ref: 535a5ec088c1ae1bf4d91dd3e35a56f64cf46d91
path: gen1-reference
# Pin the maintained VM: the local 2.1.1700008891 ARM64 runtime
# produces JIT-dependent Thick Fat results in unchanged reference code.
- uses: actions/checkout@v7
with:
repository: LuaJIT/LuaJIT
ref: a4c064539ea931274d407e1249b4bb575424a0f4
path: luajit-runtime
- name: Build pinned LuaJIT
run: make -C luajit-runtime -j2
- name: Actual public hook and native move execution
run: >-
python3 gen2/tools/enemy-action-contract-check/check.py
--gen1 gen1-reference --gen2 gen2
--lua "${{ github.workspace }}/luajit-runtime/src/luajit"
--report "${{ runner.temp }}/enemy-action-report.json"
- uses: actions/upload-artifact@v7
if: always()
with:
name: enemy-action-contract-report
path: ${{ runner.temp }}/enemy-action-report.json
if-no-files-found: error
34 changes: 34 additions & 0 deletions .github/workflows/gba-damage-base-contract.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: ordinary GBA base damage
on:
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: gba-damage-base-${{ github.ref }}
cancel-in-progress: true
jobs:
contract:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v7
with:
repository: bryanthaboi/gen1recomp
ref: 535a5ec088c1ae1bf4d91dd3e35a56f64cf46d91
path: .contract-reference/gen1
- name: Install runtime
run: sudo apt-get update && sudo apt-get install -y luajit
- name: Check GBA damage and older-profile retention
run: luajit tests/engine/gba_damage_base.lua
- name: Compare actual ordinary damage calculators
run: |
mkdir -p /tmp/gba-damage-base
python3 tools/gba-damage-base-contract-check/check.py --gen1 .contract-reference/gen1 --report /tmp/gba-damage-base/records.json
- uses: actions/upload-artifact@v6
if: always()
with:
name: gba-damage-base
path: /tmp/gba-damage-base
if-no-files-found: ignore
34 changes: 34 additions & 0 deletions .github/workflows/gen3-ai-item-knowledge-contract.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: native GBA AI item knowledge
on:
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: gen3-ai-item-knowledge-${{ github.ref }}
cancel-in-progress: true
jobs:
contract:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v7
with:
repository: Roxas2712/gen1recomp-Mac-fix
ref: 12c9e5b5a2325470d6bb266c9a1f37b7954b698e
path: .contract-reference/gen1
- name: Install runtime
run: sudo apt-get update && sudo apt-get install -y luajit
- name: Check native item queries and observation producers
run: luajit tests/engine/gen3_ai_item_knowledge.lua
- name: Compare actual native AI and effect paths
run: |
mkdir -p /tmp/gen3-ai-item-knowledge
python3 tools/gen3-ai-item-knowledge-contract-check/check.py --gen1 .contract-reference/gen1 --report /tmp/gen3-ai-item-knowledge/records.json
- uses: actions/upload-artifact@v6
if: always()
with:
name: gen3-ai-item-knowledge
path: /tmp/gen3-ai-item-knowledge
if-no-files-found: ignore
148 changes: 148 additions & 0 deletions docs/api3-portability.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Shared API 3 entry

Use the same manifest and entry file on Gen1Recomp and Gen2Recomped:

```json
{
"id": "portable_example",
"name": "Portable Example",
"version": "1.0.0",
"api": 3,
"games": ["gen1", "gen2", "gen3"],
"entry": "main.lua"
}
```

```lua
local mod = ...
if mod.content.moves:has("TACKLE") then
local ok, reason = mod.content.moves:patch("TACKLE", {power = 45})
if not ok then mod.log:warn("%s", reason) end
end
```

Create a portable starter with:

```sh
python3 tools/modkit.py scaffold portable_example --api 3
```

It generates the shared games list and a guarded canonical move patch. It
omits an engine-release range because Gen1 and Gen2 have independent engine
version numbers. The default scaffold remains API 2 with its existing range
and profile templates. The `--api` value is now honored instead of silently
emitting API 2 for every value.

API 3 automatically selects unified content, callbacks and portable scripts.
No `content_format`, `callback_format` or `script_format` fields are needed.
An explicit `"native"` for one of those fields is an error under API 3;
`"unified"` is accepted. API 1/2 retain native defaults, and API 2 retains
its existing individual opt-ins. The engine advertises `Version.modApi = 3`.
A higher unknown API remains a load error.

This is a common entry and a tested compatibility subset, not a claim that
all of Gen1Recomp's services have been ported. It builds on PRs #90–#99.
The existing unified-content limitations still apply: unsupported writes
return `nil, reason` before recording an operation, native diagnostics are
read-only, and ordinary schema errors raise an attributed load error.
Entry failure rolls back the mod's content and subscriptions. Content is
frozen after loading.

## Public contracts

Core `pokemon`, `moves`, `items`, `trainers` and `encounters` handles use the
existing unified adapters. Other registries retain their native record
shapes, rather than inventing canonical fields. Every content handle exposes
`has(id)`, `supports()` and `available`. API-3 passthrough reads and iteration
return detached values too; change data through the write methods.

The API-3 Pokemon boundary uses short statuses (`SLP`, `PSN`, `BRN`, `FRZ`,
`PAR`, `TOX`), nickname-first display names and a common Special alias.
Writing `stats.special` in a writable callback sets both later Special stats;
contradictory split values are rejected before commit. API-2 unified status
names and callback behavior are unchanged. DVs/shiny presentation is read-only
in the callback boundary. Party and battle reads remain detached snapshots.

Capture `mod.world` and `mod.battle` at entry time. World methods can be called
before Game exists and return `nil, reason`; reading the facade never boots
Game. The same world handle follows the loader's current Game/save instead of
retaining an earlier one. Battle snapshots and intents retain their existing
revision/replay validation.

The common world calls currently enabled for generations 1–3 are:

- `overworld`, `current`, `party`, `activeBlockAt`, `liveMaps`, `mapOverview`,
`effectiveEncounters`;
- `canReorderParty`, `reorderParty`, `availableFieldActions`, `useFieldAction`,
`canFly`, `flyTo`;
- `getFlag`/`setFlag` for private `mod:<key>` boolean flags;
- `queueScript` for the existing bounded portable script language.

Check `mod:supports("world", name)` before relying on a call. The other
Gen1 world method names remain callable but explicitly return
`nil, "unsupported: ..."`: warp/object/block mutations, runtime NPC operations,
`startWildBattle` and `invalidateMap` have not yet been verified against the
Gen1 API-3 contract. Their native/API-2 counterparts are unaffected. Native
symbolic flag mappings and `mod.datasets:open` are also explicitly unavailable.
Gen4/5 do not claim the shared world surface in this first entry PR.

Private flags use `save.modData[modId].worldFlags`, independently of native
flags and other mods. A read does not create a bucket. Clearing removes the
stored key. A change emits `flag.changed` with
`name = "mod.<modId>.<key>"` and the boolean value; setting the same value
emits nothing. Invalid save stores are refused without overwriting them.

Gen1 API-3 callback names from the pinned reference are recognized even when
this engine has no call site for them. Registration is allowed; availability
still requires a native call site in the selected version. For example,
`render.output` can be subscribed to but reports unavailable here. Unknown
names remain errors. An accepted subscription is not proof that a feature
runs. Source-specific engine handles in lifecycle/UI payloads remain native.

For scripts, use `mod:supports("scripts", verb)` to test Gen2Recomped's current
bounded vocabulary. A `queueScript` method does not imply support for every
Gen1 script verb. See [portable world scripts](portable-world-scripts.md).

## Reproducible contract checks

```sh
luajit tests/engine/api3_entry.lua
luajit tests/engine/api3_compat.lua
python3 tools/api3-contract-check/check.py \
--gen1 /path/to/clean/pinned/gen1recomp --lua luajit \
--report /tmp/api3-contract-report.json
```

The external reference must be a clean checkout at
`bryanthaboi/gen1recomp@79ea62f45fb2ea8f65d081a109431e4eb1bbdb36`.
Use a separate checkout; do not reset a working installation. No Gen1 engine
implementation is vendored into this repository. Only public callback names
are recorded as a compatibility catalog.

The exact same manifest and mod entry run on both engines for Red, Blue,
Yellow, Gold, Silver, Crystal, FireRed and Emerald, in both success and
intentional-rollback cases. Each engine/version/case has its own LuaJIT
process. The shared harness constructs native-shaped synthetic datasets;
the mod fixtures contain no engine imports or engine-specific branches.
The runner also generates an API-3 mod through the real scaffold CLI and
loads those same generated files on both engines for each version. This adds
eight comparisons to the sixteen normal/rollback cases: 24 comparisons and
48 isolated loader runs. It compares JSON projections of public results and
records hashes of both shared and generated fixture files. It refuses a different or modified reference.

Coverage includes canonical content reads/writes/iteration and native merge
results, detached core and passthrough reads, callable early handles, later
Game replacement, party fields, private flags, Gen1 battle snapshot/invalid-intent boundaries, callback payloads and native
writeback, custom events, unsupported-name handling, frozen content and failed
owner cleanup. Separate Gen2 tests check API-1/2 behavior, contradictory
manifest fields, honest availability and malformed flag stores. CI pins the
same external commit and uploads the report.

These are ROM-free loader/runtime-boundary tests, not retail-ROM gameplay
or a proof of every exposed native callback's payload. Native action details
remain covered by the prerequisite PR suites. Extend these shared fixtures
whenever another API-3 service becomes portable; do not make a failing
comparison pass by changing only one engine's mod fixture.

For the native damage-order correction used by portable `battle.crit` mods,
see [Gen-3 critical/type rounding](gen3-critical-order.md).
Loading