Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(aot): the fixture carries an event and a despawn, on both roads at once

yhh33b6f186d02e
diff --git a/fixtures/aot-conformance/src/main.ts b/fixtures/aot-conformance/src/main.ts
index 8de858708..0347f6817 100644
--- a/fixtures/aot-conformance/src/main.ts
+++ b/fixtures/aot-conformance/src/main.ts
@@ -6,14 +6,18 @@ import {
Query, Res, Schedule, Time,
} from 'esengine';
-import { Mover, Tally, driftSystem, clampSystem, tallySystem } from './systems.generated';
-import { SEED } from './seed.generated';
+import {
+ Doomed, Mover, Tally, absorbSystem, announceSystem, clampSystem, driftSystem,
+ reapSystem, tallySystem,
+} from './systems.generated';
+import { DOOMED, SEED } from './seed.generated';
/** Spawned in the order the trace records rows in, which is pool order. */
const spawnSystem = defineSystem(
[Commands()],
(cmds) => {
for (const [x, speed] of SEED) cmds.spawn().insert(Mover, { x, speed, bounces: 0 });
+ for (const ttl of DOOMED) cmds.spawn().insert(Doomed, { ttl });
},
{ name: 'ConfSpawn' },
);
@@ -35,12 +39,16 @@ const watchSystem = defineSystem(
* The delta goes out with the rows because a road that stepped by another one
* is a different question from a road that computed the step wrong. */
const reportSystem = defineSystem(
- [Query(Mover), Res(Time), Res(Tally)],
- (query, time, tally) => {
+ [Query(Mover), Query(Doomed), Res(Time), Res(Tally)],
+ (query, doomed, time, tally) => {
const rows: number[][] = [];
for (const [, m] of query) rows.push([m.x, m.speed, m.bounces]);
+ let alive = 0;
+ let ttl = 0;
+ for (const [, d] of doomed) { alive++; ttl += d.ttl; }
console.log(`CONF ${frame} ${time.delta} ${JSON.stringify(rows)} `
- + `${JSON.stringify([tally.bounces, tally.frames])} ${ticked}`);
+ + `${JSON.stringify([tally.bounces, tally.frames])} ${ticked} `
+ + `${JSON.stringify([alive, ttl])}`);
frame++;
},
{ name: 'ConfReport' },
@@ -50,5 +58,8 @@ addStartupSystem(spawnSystem);
addSystemToSchedule(Schedule.Update, driftSystem);
addSystemToSchedule(Schedule.Update, clampSystem);
addSystemToSchedule(Schedule.Update, tallySystem);
+addSystemToSchedule(Schedule.Update, announceSystem);
+addSystemToSchedule(Schedule.Update, absorbSystem);
+addSystemToSchedule(Schedule.Update, reapSystem);
addSystemToSchedule(Schedule.Update, watchSystem);
addSystemToSchedule(Schedule.Update, reportSystem);
diff --git a/fixtures/aot-conformance/src/seed.generated.ts b/fixtures/aot-conformance/src/seed.generated.ts
index be88f25fc..aa3a934c2 100644
--- a/fixtures/aot-conformance/src/seed.generated.ts
+++ b/fixtures/aot-conformance/src/seed.generated.ts
@@ -8,4 +8,7 @@ export const SEED: readonly (readonly [number, number])[] = [
[3, -300],
];
+/** The population an event feeds and a command removes. */
+export const DOOMED: readonly number[] = [0, 2, 4];
+
export const FRAMES = 12;
diff --git a/fixtures/aot-conformance/src/systems.generated.ts b/fixtures/aot-conformance/src/systems.generated.ts
index 6f9542f47..4c5ee7be6 100644
--- a/fixtures/aot-conformance/src/systems.generated.ts
+++ b/fixtures/aot-conformance/src/systems.generated.ts
@@ -13,7 +13,7 @@
* compiler — which matches `defineSystem` by name, not by where it
* came from.
*/
-import { defineComponent, defineSystem, Query, Mut, Res, ResMut, Time, defineResource } from 'esengine';
+import { defineComponent, defineSystem, Query, Mut, defineEvent, EventReader, EventWriter, Commands, Res, ResMut, Time, defineResource } from 'esengine';
export const Mover = defineComponent('ConfMover', { x: 0, speed: 0, bounces: 0 });
@@ -21,6 +21,13 @@ export const Mover = defineComponent('ConfMover', { x: 0, speed: 0, bounces: 0 }
* nowhere else, so it is in the world only if the road copied it back. */
export const Tally = defineResource({ bounces: 0, frames: 0 }, 'ConfTally');
+/** A second population, so the road that despawns never touches the rows the
+ * C++ harness models. */
+export const Doomed = defineComponent('ConfDoomed', { ttl: 0 });
+
+/** The payload is a VALUE, because a compiled system reads its layout. */
+export const Bounced = defineEvent<{ amount: number }>('ConfBounced', { amount: 0 });
+
/**
* @compiled
*/
@@ -72,3 +79,44 @@ export const tallySystem = defineSystem(
},
{ name: 'ConfTally' },
);
+
+/**
+ * @compiled
+ */
+export const announceSystem = defineSystem(
+ [Query(Mover), EventWriter(Bounced)],
+ (query, out) => {
+ for (const [, m] of query) {
+ if (m.bounces > 0) out.send({ amount: 1 });
+ }
+ },
+ { name: 'ConfAnnounce' },
+);
+
+/**
+ * @compiled
+ */
+export const absorbSystem = defineSystem(
+ [EventReader(Bounced), Query(Mut(Doomed))],
+ (hits, query) => {
+ for (const h of hits) {
+ for (const [, d] of query) {
+ d.ttl = d.ttl + h.amount;
+ }
+ }
+ },
+ { name: 'ConfAbsorb' },
+);
+
+/**
+ * @compiled
+ */
+export const reapSystem = defineSystem(
+ [Query(Mut(Doomed)), Commands()],
+ (query, cmds) => {
+ for (const [e, d] of query) {
+ if (d.ttl >= 8) cmds.despawn(e);
+ }
+ },
+ { name: 'ConfReap' },
+);
diff --git a/sdk/tests/aot-conformance.test.ts b/sdk/tests/aot-conformance.test.ts
index 4e7b9984d..ac8da855e 100644
--- a/sdk/tests/aot-conformance.test.ts
+++ b/sdk/tests/aot-conformance.test.ts
@@ -47,6 +47,10 @@ const DT = 1 / 60;
const SEEDS: readonly (readonly [number, number])[] =
[[0, 120], [9.5, 60], [-9.5, -60], [3, -300]];
+/** The population an event feeds and a command removes, at three thresholds so
+ * they leave on three different frames rather than all at once. */
+const DOOMED: readonly number[] = [0, 2, 4];
+
/** Where the native harness reads its inputs. Its own directory: the emitted C
* includes `estella_offsets.h` by that name and guards it by that name, so two
* fixtures cannot share one. */
@@ -86,9 +90,12 @@ type Trace = number[][][];
type ResTrace = number[][];
/** How many rows a `Changed(Mover)` watcher matched, after each frame. */
type TickTrace = number[];
+/** The despawned population, after each frame: [alive, total ttl]. */
+type PopTrace = number[][];
async function play(compiled: { wasm: Uint8Array; manifest: AotManifest } | null): Promise<{
- trace: Trace; resource: ResTrace; ticks: TickTrace; calls: number; delta: number;
+ trace: Trace; resource: ResTrace; ticks: TickTrace; pop: PopTrace;
+ calls: number; delta: number;
}> {
// One context for both roads on purpose: the fixture's `defineComponent`
// runs once, at import, and a road that reset the registry under it would
@@ -101,6 +108,11 @@ async function play(compiled: { wasm: Uint8Array; manifest: AotManifest } | null
app.addSystemToSchedule(Schedule.Update, fixture.driftSystem);
app.addSystemToSchedule(Schedule.Update, fixture.clampSystem);
app.addSystemToSchedule(Schedule.Update, fixture.tallySystem);
+ // The three the LOADING road refuses: a writer, a reader and a despawn.
+ // On that road they interpret, which is what makes the trace one answer.
+ app.addSystemToSchedule(Schedule.Update, fixture.announceSystem);
+ app.addSystemToSchedule(Schedule.Update, fixture.absorbSystem);
+ app.addSystemToSchedule(Schedule.Update, fixture.reapSystem);
// Interpreted, and last: the Changed ticks a twin leaves are the one duty
// no value in the trace can show. A watcher counts what a filter matched,
// which is the same question a game asks of change detection.
@@ -131,8 +143,15 @@ async function play(compiled: { wasm: Uint8Array; manifest: AotManifest } | null
return e;
});
+ const doomed: Entity[] = DOOMED.map((ttl) => {
+ const e = app.world.spawn();
+ app.world.insert(e, fixture.Doomed, { ttl });
+ return e;
+ });
+
const trace: Trace = [];
const resource: ResTrace = [];
+ const pop: PopTrace = [];
for (let f = 0; f < FRAMES; f++) {
await app.tick(DT);
trace.push(entities.map((e) => {
@@ -143,13 +162,18 @@ async function play(compiled: { wasm: Uint8Array; manifest: AotManifest } | null
// where it lands only if the road copied it back.
const tally = app.getResource(fixture.Tally) as { bounces: number; frames: number };
resource.push([tally.bounces, tally.frames]);
+ // What the event fed and the command removed. A despawn that reached
+ // one world and not the other is a count that stops agreeing.
+ const alive = doomed.filter((e) => app.world.valid(e));
+ pop.push([alive.length, alive.reduce((n, e) =>
+ n + (app.world.get(e, fixture.Doomed) as { ttl: number }).ttl, 0)]);
}
// The delta the interpreter was HANDED, which is what the native harness is
// given: `tick` scales what it is asked for, and a harness restating 1/60
// would be a second opinion about the frame rather than a reading of it.
const time = (app as unknown as { resources_: { get: (r: unknown) => { delta: number } } })
.resources_.get(Time);
- return { trace, resource, ticks, calls: runtime?.systems.calls ?? 0, delta: time.delta };
+ return { trace, resource, ticks, pop, calls: runtime?.systems.calls ?? 0, delta: time.delta };
}
describe.skipIf(!EMCC)('one source, interpreted and compiled', () => {
@@ -164,7 +188,7 @@ describe.skipIf(!EMCC)('one source, interpreted and compiled', () => {
// Installed is not the same question as ran, and a differential cannot
// tell them apart — the closure that would have run produces the same
// numbers. Three systems, every frame.
- expect(twins.calls).toBe(FRAMES * 3);
+ expect(twins.calls).toBe(FRAMES * 6);
expect(interpreted.calls).toBe(0);
// Frame for frame, so a divergence names the frame it began on rather
@@ -178,6 +202,7 @@ describe.skipIf(!EMCC)('one source, interpreted and compiled', () => {
// The ticks the compiled code could not leave, which the host has
// to mark instead. Nothing in the world's VALUES shows them.
expect([f, twins.ticks[f]]).toEqual([f, interpreted.ticks[f]]);
+ expect([f, twins.pop[f]]).toEqual([f, interpreted.pop[f]]);
}
// And the run went somewhere: a fixture whose systems do nothing agrees
// on every road.
@@ -185,6 +210,10 @@ describe.skipIf(!EMCC)('one source, interpreted and compiled', () => {
// A watcher that matched nothing agrees on every road: the tick
// comparison above is only worth running if something was ticked.
expect(interpreted.ticks.some((n) => n > 0)).toBe(true);
+ // The event fed the population and the command emptied it: without both,
+ // the five duties this fixture carries for the wasm road are untouched.
+ expect(interpreted.pop[0]![1]).toBeGreaterThan(0);
+ expect(interpreted.pop[FRAMES - 1]![0]).toBeLessThan(DOOMED.length);
});
});
@@ -259,6 +288,9 @@ function projectSeed(): string {
...SEEDS.map(([x, speed]) => ` [${x}, ${speed}],`),
'];',
'',
+ '/** The population an event feeds and a command removes. */',
+ `export const DOOMED: readonly number[] = [${DOOMED.join(', ')}];`,
+ '',
`export const FRAMES = ${FRAMES};`,
'',
].join('\n');
@@ -370,6 +402,10 @@ describe('the inputs a loading host builds against', () => {
// in the values above shows a tick, and a road that stopped marking
// them agrees with every other column.
ticks: run.ticks,
+ // The population an event fed and a command emptied. The despawn is
+ // the one effect no field of any surviving row can show.
+ popFields: ['alive', 'ttl'],
+ pop: run.pop,
}, null, 2)}\n`);
});
diff --git a/sdk/tests/fixtures/conformance-systems.ts b/sdk/tests/fixtures/conformance-systems.ts
index d9e516679..6a4511e00 100644
--- a/sdk/tests/fixtures/conformance-systems.ts
+++ b/sdk/tests/fixtures/conformance-systems.ts
@@ -13,6 +13,8 @@
import { defineComponent } from '../../src/ecs/component';
import { defineSystem } from '../../src/ecs/system';
import { Query, Mut } from '../../src/ecs/query';
+import { defineEvent, EventReader, EventWriter } from '../../src/ecs/event';
+import { Commands } from '../../src/ecs/commands';
import { Res, ResMut, Time, defineResource } from '../../src/ecs/resource';
export const Mover = defineComponent('ConfMover', { x: 0, speed: 0, bounces: 0 });
@@ -21,6 +23,13 @@ export const Mover = defineComponent('ConfMover', { x: 0, speed: 0, bounces: 0 }
* nowhere else, so it is in the world only if the road copied it back. */
export const Tally = defineResource({ bounces: 0, frames: 0 }, 'ConfTally');
+/** A second population, so the road that despawns never touches the rows the
+ * C++ harness models. */
+export const Doomed = defineComponent('ConfDoomed', { ttl: 0 });
+
+/** The payload is a VALUE, because a compiled system reads its layout. */
+export const Bounced = defineEvent<{ amount: number }>('ConfBounced', { amount: 0 });
+
/**
* @compiled
*/
@@ -72,3 +81,44 @@ export const tallySystem = defineSystem(
},
{ name: 'ConfTally' },
);
+
+/**
+ * @compiled
+ */
+export const announceSystem = defineSystem(
+ [Query(Mover), EventWriter(Bounced)],
+ (query, out) => {
+ for (const [, m] of query) {
+ if (m.bounces > 0) out.send({ amount: 1 });
+ }
+ },
+ { name: 'ConfAnnounce' },
+);
+
+/**
+ * @compiled
+ */
+export const absorbSystem = defineSystem(
+ [EventReader(Bounced), Query(Mut(Doomed))],
+ (hits, query) => {
+ for (const h of hits) {
+ for (const [, d] of query) {
+ d.ttl = d.ttl + h.amount;
+ }
+ }
+ },
+ { name: 'ConfAbsorb' },
+);
+
+/**
+ * @compiled
+ */
+export const reapSystem = defineSystem(
+ [Query(Mut(Doomed)), Commands()],
+ (query, cmds) => {
+ for (const [e, d] of query) {
+ if (d.ttl >= 8) cmds.despawn(e);
+ }
+ },
+ { name: 'ConfReap' },
+);
diff --git a/tests/aot/generated/conformance/estella_offsets.h b/tests/aot/generated/conformance/estella_offsets.h
index 4b49e6164..6fe68587b 100644
--- a/tests/aot/generated/conformance/estella_offsets.h
+++ b/tests/aot/generated/conformance/estella_offsets.h
@@ -5,6 +5,8 @@
#ifndef ESTELLA_OFFSETS_H
#define ESTELLA_OFFSETS_H
+#define ES_OFF_ConfBounced_amount 0u
+#define ES_OFF_ConfDoomed_ttl 0u
#define ES_OFF_ConfMover_bounces 16u
#define ES_OFF_ConfMover_speed 8u
#define ES_OFF_ConfMover_x 0u
diff --git a/tests/aot/generated/conformance/handshake.h b/tests/aot/generated/conformance/handshake.h
index 2ad56e404..dce8ff564 100644
--- a/tests/aot/generated/conformance/handshake.h
+++ b/tests/aot/generated/conformance/handshake.h
@@ -2,4 +2,4 @@
/* The contract half of the handshake. The width half is the harness. */
#define ES_CONF_EXPECTED_CONTRACT_HASH 0xaa8849ed8d31d9a0ULL
/* And which BUILD the artifact beside this one is. */
-#define ES_CONF_EXPECTED_MODULE_CONTRACT 0xa45bab2f04e812a6ULL
+#define ES_CONF_EXPECTED_MODULE_CONTRACT 0x1f3a750c220381a4ULL
diff --git a/tests/aot/generated/conformance/systems.c b/tests/aot/generated/conformance/systems.c
index c49fb43d3..7708ab83a 100644
--- a/tests/aot/generated/conformance/systems.c
+++ b/tests/aot/generated/conformance/systems.c
@@ -6,8 +6,8 @@
/* Which BUILD this is, for a loader holding the sidecar written beside
it. The two digests above answer "is this engine right" and "are the
project shapes right"; neither answers "are these two the same pair". */
-ES_EXPORT uint32_t es_module_contract_lo(void) { return 0x04e812a6u; }
-ES_EXPORT uint32_t es_module_contract_hi(void) { return 0xa45bab2fu; }
+ES_EXPORT uint32_t es_module_contract_lo(void) { return 0x220381a4u; }
+ES_EXPORT uint32_t es_module_contract_hi(void) { return 0x1f3a750cu; }
ES_EXPORT void es_sys_ConfDrift(es_addr_t es_ctx) {
const EsSysCtx *es_c = (const EsSysCtx *)ES_PTR(es_ctx);
@@ -65,3 +65,81 @@ ES_EXPORT void es_sys_ConfTally(es_addr_t es_ctx) {
}
}
}
+
+ES_EXPORT void es_sys_ConfAnnounce(es_addr_t es_ctx) {
+ const EsSysCtx *es_c = (const EsSysCtx *)ES_PTR(es_ctx);
+ const EsQueryRows *es_queries = (const EsQueryRows *)ES_PTR(es_c->queries);
+ const EsEventOut *es_ev = (const EsEventOut *)ES_PTR(es_c->events);
+ double *es_ev_buf = (double *)ES_PTR(es_ev->buf);
+ const uint32_t es_ev_cap = (uint32_t)es_ev->cap;
+ uint32_t *es_ev_at = (uint32_t *)ES_PTR(es_ev->count);
+ uint32_t es_ev_n = *es_ev_at;
+ {
+ const es_addr_t *es_rows0 = (const es_addr_t *)ES_PTR(es_queries[0].rows);
+ const es_addr_t es_n0 = es_queries[0].count;
+ for (es_addr_t es_i0 = 0; es_i0 < es_n0; ++es_i0) {
+ const es_addr_t *es_row0 = es_rows0 + es_i0 * 2u;
+ unsigned char *m_2 = ES_PTR(es_row0[1]);
+ if ((es_f64(m_2 + ES_OFF_ConfMover_bounces) > 0.0)) {
+ if (es_ev_n + 2u <= es_ev_cap) {
+ double *es_rec = es_ev_buf + es_ev_n;
+ es_rec[0] = 0.0;
+ es_rec[1] = 1.0;
+ es_ev_n += 2u;
+ }
+ }
+ }
+ }
+ *es_ev_at = es_ev_n;
+}
+
+ES_EXPORT void es_sys_ConfAbsorb(es_addr_t es_ctx) {
+ const EsSysCtx *es_c = (const EsSysCtx *)ES_PTR(es_ctx);
+ const EsQueryRows *es_queries = (const EsQueryRows *)ES_PTR(es_c->queries);
+ {
+ const es_addr_t *es_rows0 = (const es_addr_t *)ES_PTR(es_queries[0].rows);
+ const es_addr_t es_n0 = es_queries[0].count;
+ for (es_addr_t es_i0 = 0; es_i0 < es_n0; ++es_i0) {
+ const es_addr_t *es_row0 = es_rows0 + es_i0 * 2u;
+ unsigned char *h_2 = ES_PTR(es_row0[1]);
+ {
+ const es_addr_t *es_rows1 = (const es_addr_t *)ES_PTR(es_queries[1].rows);
+ const es_addr_t es_n1 = es_queries[1].count;
+ for (es_addr_t es_i1 = 0; es_i1 < es_n1; ++es_i1) {
+ const es_addr_t *es_row1 = es_rows1 + es_i1 * 2u;
+ unsigned char *d_3 = ES_PTR(es_row1[1]);
+ es_set_f64(d_3 + ES_OFF_ConfDoomed_ttl, (es_f64(d_3 + ES_OFF_ConfDoomed_ttl) + es_f64(h_2 + ES_OFF_ConfBounced_amount)));
+ }
+ }
+ }
+ }
+}
+
+ES_EXPORT void es_sys_ConfReap(es_addr_t es_ctx) {
+ const EsSysCtx *es_c = (const EsSysCtx *)ES_PTR(es_ctx);
+ const EsQueryRows *es_queries = (const EsQueryRows *)ES_PTR(es_c->queries);
+ EsCmd *es_cmd_buf = (EsCmd *)ES_PTR(es_c->cmdBuf);
+ const uint32_t es_cmd_cap = (uint32_t)es_c->cmdCap;
+ uint32_t *es_cmd_at = (uint32_t *)ES_PTR(es_c->cmdCount);
+ uint32_t es_cmd_n = *es_cmd_at;
+ {
+ const es_addr_t *es_rows0 = (const es_addr_t *)ES_PTR(es_queries[0].rows);
+ const es_addr_t es_n0 = es_queries[0].count;
+ for (es_addr_t es_i0 = 0; es_i0 < es_n0; ++es_i0) {
+ const es_addr_t *es_row0 = es_rows0 + es_i0 * 2u;
+ const uint32_t e_2 = (uint32_t)es_row0[0];
+ unsigned char *d_3 = ES_PTR(es_row0[1]);
+ if ((es_f64(d_3 + ES_OFF_ConfDoomed_ttl) >= 8.0)) {
+ if (es_cmd_n < es_cmd_cap) {
+ EsCmd *es_at = &es_cmd_buf[es_cmd_n];
+ es_at->kind = ES_CMD_DESPAWN; /* despawn */
+ es_at->a = e_2;
+ es_at->b = 0u;
+ es_at->c = 0u;
+ es_cmd_n += 1u;
+ }
+ }
+ }
+ }
+ *es_cmd_at = es_cmd_n;
+}
diff --git a/tests/aot/generated/conformance/systems_decl.c b/tests/aot/generated/conformance/systems_decl.c
index b2384b471..8dff9fd51 100644
--- a/tests/aot/generated/conformance/systems_decl.c
+++ b/tests/aot/generated/conformance/systems_decl.c
@@ -17,6 +17,9 @@ ES_EXPORT const uint64_t es_abi_hash =
ES_EXPORT void es_sys_ConfDrift(es_addr_t es_ctx);
ES_EXPORT void es_sys_ConfClamp(es_addr_t es_ctx);
ES_EXPORT void es_sys_ConfTally(es_addr_t es_ctx);
+ES_EXPORT void es_sys_ConfAnnounce(es_addr_t es_ctx);
+ES_EXPORT void es_sys_ConfAbsorb(es_addr_t es_ctx);
+ES_EXPORT void es_sys_ConfReap(es_addr_t es_ctx);
/* The systems in this file, and what each one needs filled in. */
static const char *const es_sys_ConfDrift_q0_comps[] = { "ConfMover" };
@@ -32,10 +35,24 @@ static const unsigned char es_sys_ConfTally_q0_mut[] = { 0u };
static const EsQueryDecl es_sys_ConfTally_queries[] = { { es_sys_ConfTally_q0_comps, es_sys_ConfTally_q0_mut, 1u } };
static const char *const es_sys_ConfTally_resources[] = { "ConfTally" };
static const unsigned char es_sys_ConfTally_resources_mut[] = { 1u };
+static const char *const es_sys_ConfAnnounce_q0_comps[] = { "ConfMover" };
+static const unsigned char es_sys_ConfAnnounce_q0_mut[] = { 0u };
+static const EsQueryDecl es_sys_ConfAnnounce_queries[] = { { es_sys_ConfAnnounce_q0_comps, es_sys_ConfAnnounce_q0_mut, 1u } };
+static const char *const es_sys_ConfAbsorb_q0_comps[] = { "ConfBounced" };
+static const unsigned char es_sys_ConfAbsorb_q0_mut[] = { 0u };
+static const char *const es_sys_ConfAbsorb_q1_comps[] = { "ConfDoomed" };
+static const unsigned char es_sys_ConfAbsorb_q1_mut[] = { 1u };
+static const EsQueryDecl es_sys_ConfAbsorb_queries[] = { { es_sys_ConfAbsorb_q0_comps, es_sys_ConfAbsorb_q0_mut, 1u }, { es_sys_ConfAbsorb_q1_comps, es_sys_ConfAbsorb_q1_mut, 1u } };
+static const char *const es_sys_ConfReap_q0_comps[] = { "ConfDoomed" };
+static const unsigned char es_sys_ConfReap_q0_mut[] = { 1u };
+static const EsQueryDecl es_sys_ConfReap_queries[] = { { es_sys_ConfReap_q0_comps, es_sys_ConfReap_q0_mut, 1u } };
ES_EXPORT const EsSystemDecl es_systems[] = {
{ "ConfDrift", es_sys_ConfDrift, es_sys_ConfDrift_queries, es_sys_ConfDrift_resources, es_sys_ConfDrift_resources_mut, 1u, 1u },
{ "ConfClamp", es_sys_ConfClamp, es_sys_ConfClamp_queries, NULL, NULL, 1u, 0u },
{ "ConfTally", es_sys_ConfTally, es_sys_ConfTally_queries, es_sys_ConfTally_resources, es_sys_ConfTally_resources_mut, 1u, 1u },
+ { "ConfAnnounce", es_sys_ConfAnnounce, es_sys_ConfAnnounce_queries, NULL, NULL, 1u, 0u },
+ { "ConfAbsorb", es_sys_ConfAbsorb, es_sys_ConfAbsorb_queries, NULL, NULL, 2u, 0u },
+ { "ConfReap", es_sys_ConfReap, es_sys_ConfReap_queries, NULL, NULL, 1u, 0u },
};
-ES_EXPORT const uint32_t es_system_count = 3u;
+ES_EXPORT const uint32_t es_system_count = 6u;
diff --git a/tests/aot/generated/conformance/trace.json b/tests/aot/generated/conformance/trace.json
index 0730e3e29..e05be7641 100644
--- a/tests/aot/generated/conformance/trace.json
+++ b/tests/aot/generated/conformance/trace.json
@@ -360,5 +360,59 @@
4,
4,
4
+ ],
+ "popFields": [
+ "alive",
+ "ttl"
+ ],
+ "pop": [
+ [
+ 3,
+ 6
+ ],
+ [
+ 3,
+ 12
+ ],
+ [
+ 2,
+ 10
+ ],
+ [
+ 1,
+ 7
+ ],
+ [
+ 0,
+ 0
+ ],
+ [
+ 0,
+ 0
+ ],
+ [
+ 0,
+ 0
+ ],
+ [
+ 0,
+ 0
+ ],
+ [
+ 0,
+ 0
+ ],
+ [
+ 0,
+ 0
+ ],
+ [
+ 0,
+ 0
+ ],
+ [
+ 0,
+ 0
+ ]
]
}
diff --git a/tools/lib/aotDuties.mjs b/tools/lib/aotDuties.mjs
index ab9e4c45f..9368c62ab 100644
--- a/tools/lib/aotDuties.mjs
+++ b/tools/lib/aotDuties.mjs
@@ -105,7 +105,9 @@ export const DUTIES = [
web: ['runtime.addresses.payloadRows'],
native: null,
excusedBy: 'eventRead',
- owed: 'the fixture has no events and no despawn, so nothing holds the WEB road here',
+ // The WASM road only, and that is the whole entry: on the loading road
+ // these systems are refused, so its agreement is the interpreter's own.
+ differential: [{ path: 'sdk/tests/aot-conformance.test.ts', probe: /twins\.pop\[f\]/ }],
},
{
id: 'event-payloads-released',
@@ -113,7 +115,9 @@ export const DUTIES = [
web: ['runtime.addresses.releasePayloads'],
native: null,
excusedBy: 'eventRead',
- owed: 'the fixture has no events and no despawn, so nothing holds the WEB road here',
+ // The WASM road only, and that is the whole entry: on the loading road
+ // these systems are refused, so its agreement is the interpreter's own.
+ differential: [{ path: 'sdk/tests/aot-conformance.test.ts', probe: /twins\.pop\[f\]/ }],
},
{
id: 'event-records-sized',
@@ -121,7 +125,9 @@ export const DUTIES = [
web: ['runtime.ctx.setRecordLengths'],
native: null,
excusedBy: 'eventWrite',
- owed: 'the fixture has no events and no despawn, so nothing holds the WEB road here',
+ // The WASM road only, and that is the whole entry: on the loading road
+ // these systems are refused, so its agreement is the interpreter's own.
+ differential: [{ path: 'sdk/tests/aot-conformance.test.ts', probe: /twins\.pop\[f\]/ }],
},
{
id: 'events-out',
@@ -129,7 +135,9 @@ export const DUTIES = [
web: ['runtime.ctx.events', 'runtime.addresses.sendEvent'],
native: null,
excusedBy: 'eventWrite',
- owed: 'the fixture has no events and no despawn, so nothing holds the WEB road here',
+ // The WASM road only, and that is the whole entry: on the loading road
+ // these systems are refused, so its agreement is the interpreter's own.
+ differential: [{ path: 'sdk/tests/aot-conformance.test.ts', probe: /twins\.pop\[f\]/ }],
},
{
id: 'commands-out',
@@ -137,7 +145,9 @@ export const DUTIES = [
web: ['runtime.ctx.commands', 'world.despawn'],
native: null,
excusedBy: 'commands',
- owed: 'the fixture has no events and no despawn, so nothing holds the WEB road here',
+ // The WASM road only, and that is the whole entry: on the loading road
+ // these systems are refused, so its agreement is the interpreter's own.
+ differential: [{ path: 'sdk/tests/aot-conformance.test.ts', probe: /twins\.pop\[f\]/ }],
},
];
diff --git a/tools/verify-native-conformance.mjs b/tools/verify-native-conformance.mjs
index b8603b248..4a334c242 100644
--- a/tools/verify-native-conformance.mjs
+++ b/tools/verify-native-conformance.mjs
@@ -101,14 +101,14 @@ function play(compiled) {
}
}
-/** `CONF <frame> <delta> <rows> <resource> <ticks>` — what the reporter says. */
+/** `CONF <frame> <delta> <rows> <resource> <ticks> <pop>` — the reporter's line. */
function framesIn(log) {
const out = [];
for (const line of log.split('\n')) {
- const m = /CONF (\d+) (\S+) (\[.*\]) (\[[^\]]*\]) (\d+)\s*$/.exec(line);
+ const m = /CONF (\d+) (\S+) (\[.*\]) (\[[^\]]*\]) (\d+) (\[[^\]]*\])\s*$/.exec(line);
if (m !== null) {
out.push({ at: Number(m[1]), delta: Number(m[2]), rows: JSON.parse(m[3]),
- resource: JSON.parse(m[4]), ticks: Number(m[5]) });
+ resource: JSON.parse(m[4]), ticks: Number(m[5]), pop: JSON.parse(m[6]) });
}
}
return out;
@@ -147,6 +147,15 @@ function compare(road, got) {
host ${frame.resource[k]}`);
}
}
+ // What an event fed and a command emptied. On the loading road all three
+ // systems are REFUSED and interpret, which is what makes this one answer.
+ for (let k = 0; k < want.pop[f].length; k++) {
+ if (frame.pop[k] !== want.pop[f][k]) {
+ fail(`${road} disagrees at frame ${f} about the population, ${want.popFields[k]}`,
+ `interpreter ${want.pop[f][k]}
+host ${frame.pop[k]}`);
+ }
+ }
// The Changed ticks a twin could not leave, which the host marks instead.
if (frame.ticks !== want.ticks[f]) {
fail(`${road} matched ${frame.ticks} changed row(s) at frame ${f}, and the `
@@ -166,6 +175,7 @@ host ${frame.resource[k]}`);
const RUNNING = /AOT: (\w+) is running compiled/;
const RUNNING_ALL = /AOT: (\w+) is running compiled/g;
const INSTALLED = /AOT: (\d+) compiled system\(s\) installed/;
+const REFUSED = /AOT: (\w+) needs .*which this host cannot hand compiled code/g;
const interpreted = play(false);
if (interpreted === null) fail('the interpreted export could not be built');
@@ -197,7 +207,18 @@ if (ran.size !== Number(installed[1])) {
`compiled: ${[...ran].join(', ') || '(none)'}`);
}
+// The other half of the capability model, in a shipped game. A road that took
+// one of these would have crashed or desynced quietly; this one agrees above
+// BECAUSE the interpreter kept them.
+const refused = [...compiled.log.matchAll(REFUSED)].map((m) => m[1]);
+if (refused.length === 0) {
+ fail('nothing was refused by capability — the fixture carries an event and a despawn, '
+ + 'and this road can hand compiled code neither');
+}
+
console.log(`✓ native conformance: both roads answer the interpreter, frame for frame `
+ `(${FRAMES} frames, ${want.frames[0].length} entities).`);
console.log(` interpreted, and every one of ${installed[1]} compiled system(s) dispatched to `
+ `on the packaged host: ${[...ran].join(', ')}.`);
+console.log(` ${refused.length} refused by capability and kept by the interpreter: `
+ + `${refused.join(', ')}.`);