Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

Add agent-free resilience assay harness for Eidoverse world foundations (#7460)

[._.]/ Adam Eivye93799b15908
diff --git a/docs/features/eidoverse.md b/docs/features/eidoverse.md
index b9052b243b..e1ce55632e 100644
--- a/docs/features/eidoverse.md
+++ b/docs/features/eidoverse.md
@@ -630,3 +630,47 @@ repeat, chat focus, overlays, distance, and occlusion suppress accidental use.
The renderer implementation and a toggle-lamp example live in the separate
Worlds repository. Controller support is tracked in
[Worlds #11](https://github.com/atomantic/eidoverse-worlds/issues/11).
+
+### Agent-free resilience assay (promote-path pre-check)
+
+Part of the [SwarmWorld-inspired stigmergic Eidoverse epic](https://github.com/atomantic/PortOS/issues/7453):
+a world foundation should not promote from an instance's local vernacular into
+the shared PortOS baseline just because it "worked" while its author mind was
+still narrating it live. `server/services/eidoverseResilienceAssay.js` runs a
+candidate contribution through a clean, agent-free sandbox before that
+decision is made:
+
+- `createSandbox()` is called fresh per scenario, so no state can leak in from
+ a previous run or a live process handle.
+- `buildProjectionPlan()` (`eidoverseWorldProjection.js`, already pure) loads
+ once against the sandbox's initial state, standing in for "replay in a
+ clean sandbox instance."
+- The controller then replays through the fixed disturbance suite —
+ `reconnect`, `restart-world-host`, `missing-optional-deps` — each with a
+ warm-up run, the disturbance, and required recovery ticks.
+- A controller `step()` (or `applyDisturbance()`) that returns a Promise is
+ itself a failure: the assay is synchronous by contract, so an "agent-free"
+ contribution cannot reach for a live network, disk, or provider call during
+ replay.
+- Every tick is checked against a built-in JSON-serializability invariant
+ (a promoted foundation has to be loadable by a peer that never saw the
+ authoring session) plus any contribution-supplied invariants.
+
+`runResilienceAssay(contribution)` returns `{ contributionId, pass, scenarios,
+projection, reasons }` with a readable reason per failure, naming the
+disturbance and tick. `scripts/eidoverse-resilience-assay.js`
+(`npm run eidoverse:assay`) is the CLI/CI entry point — with no arguments it
+runs every reference contribution under
+`server/services/eidoverseResilienceAssayFixtures/*.contribution.js`; given
+module paths, it runs the assay against those instead and exits non-zero on
+any failure. Two reference fixtures live beside the harness: a passing
+`beaconRelay.contribution.js` and a deliberately-failing
+`narratedOnly.failing.fixture.js` (named so the CLI's default fixture glob
+skips it; only `eidoverseResilienceAssay.test.js` exercises it, proving the
+harness catches the "author-mind-only" failure mode).
+
+This harness is standalone and does not yet gate anything — the actual
+promote-to-baseline pipeline is
+[#7455](https://github.com/atomantic/PortOS/issues/7455), not yet built. Once
+it exists, it is expected to call `runResilienceAssay()` (or shell out to this
+script) per candidate contribution and block promotion on a failing verdict.
diff --git a/package.json b/package.json
index 8cf44833ac..ccf5899097 100644
--- a/package.json
+++ b/package.json
@@ -46,6 +46,7 @@
"test": "npm test --prefix server && npm test --prefix client",
"quality:snapshot": "node scripts/publish-quality-snapshot.js",
"scan:hidden-content": "node scripts/scan-diff-hidden-content.js",
+ "eidoverse:assay": "node scripts/eidoverse-resilience-assay.js",
"theme:check": "node scripts/check-themes.js",
"smoke": "node scripts/smoke-boot.js"
},
diff --git a/scripts/eidoverse-resilience-assay.js b/scripts/eidoverse-resilience-assay.js
new file mode 100644
index 0000000000..4a0418a6ab
--- /dev/null
+++ b/scripts/eidoverse-resilience-assay.js
@@ -0,0 +1,87 @@
+#!/usr/bin/env node
+/**
+ * Command-line entry point for the agent-free resilience assay (#7460, part
+ * of epic #7453). Runs a candidate Eidoverse world contribution through
+ * `runResilienceAssay()` (server/services/eidoverseResilienceAssay.js) and
+ * prints a readable pass/fail per disturbance scenario.
+ *
+ * Usage:
+ * node scripts/eidoverse-resilience-assay.js
+ * Runs every reference contribution module under
+ * server/services/eidoverseResilienceAssayFixtures/*.contribution.js.
+ * (The deliberately-failing fixture in that directory is named
+ * `*.failing.fixture.js` on purpose, so it is exercised only by
+ * eidoverseResilienceAssay.test.js and never trips this default run.)
+ *
+ * node scripts/eidoverse-resilience-assay.js <module-path> [...more]
+ * Runs the assay against specific contribution modules instead. Each
+ * module must have a default export, or a single named export, that is
+ * a zero-argument factory returning `{ id, createSandbox, invariants? }`
+ * — see server/services/eidoverseResilienceAssayFixtures/beaconRelay.contribution.js.
+ * This is the shape the promote path (#7455, not yet built) is expected
+ * to call with each candidate contribution's module path, or it may
+ * import `runResilienceAssay` directly instead of shelling out here.
+ *
+ * Exits 0 when every contribution passes, 1 otherwise. Makes no network,
+ * filesystem-beyond-the-fixtures, provider, or agent call.
+ */
+import { readdirSync } from 'node:fs';
+import { dirname, join, resolve } from 'node:path';
+import { fileURLToPath, pathToFileURL } from 'node:url';
+import { runResilienceAssay } from '../server/services/eidoverseResilienceAssay.js';
+
+const __dirname = dirname(fileURLToPath(import.meta.url));
+const DEFAULT_FIXTURES_DIR = join(__dirname, '..', 'server', 'services', 'eidoverseResilienceAssayFixtures');
+
+function defaultContributionModulePaths() {
+ return readdirSync(DEFAULT_FIXTURES_DIR)
+ .filter((file) => file.endsWith('.contribution.js'))
+ .sort()
+ .map((file) => join(DEFAULT_FIXTURES_DIR, file));
+}
+
+async function loadContribution(modulePath) {
+ const mod = await import(pathToFileURL(modulePath).href);
+ const factory = mod.default || Object.values(mod).find((value) => typeof value === 'function');
+ if (typeof factory !== 'function') {
+ throw new Error(`${modulePath} does not export a contribution factory function`);
+ }
+ return factory();
+}
+
+function printResult(modulePath, result) {
+ const icon = result.pass ? '✅' : '❌';
+ console.log(`${icon} ${result.contributionId} (${modulePath})`);
+ for (const reason of result.reasons) {
+ console.log(` - ${reason}`);
+ }
+}
+
+export async function runAssayCli(args) {
+ const modulePaths = args.length > 0
+ ? args.map((path) => resolve(process.cwd(), path))
+ : defaultContributionModulePaths();
+
+ if (modulePaths.length === 0) {
+ console.log('ℹ️ No resilience-assay contributions to run.');
+ return 0;
+ }
+
+ let allPassed = true;
+ for (const modulePath of modulePaths) {
+ const contribution = await loadContribution(modulePath);
+ const result = runResilienceAssay(contribution);
+ printResult(modulePath, result);
+ if (!result.pass) allPassed = false;
+ }
+ return allPassed ? 0 : 1;
+}
+
+if (import.meta.url === pathToFileURL(process.argv[1] || '').href) {
+ runAssayCli(process.argv.slice(2))
+ .then((code) => process.exit(code))
+ .catch((error) => {
+ console.error(`❌ Resilience assay script failed: ${error.message}`);
+ process.exit(1);
+ });
+}
diff --git a/server/services/eidoverseResilienceAssay.js b/server/services/eidoverseResilienceAssay.js
new file mode 100644
index 0000000000..6eb2795040
--- /dev/null
+++ b/server/services/eidoverseResilienceAssay.js
@@ -0,0 +1,245 @@
+/**
+ * Agent-free resilience assay for Eidoverse world foundations, run before a
+ * contribution is eligible to promote from an instance's local vernacular
+ * into the shared PortOS baseline (#7460, part of epic #7453).
+ *
+ * SwarmWorld's premise: a build only earns "promote" once it still works
+ * with its author mind gone. This harness enforces that mechanically —
+ * `runResilienceAssay()` never receives, imports, or invokes any mind, CoS
+ * agent, or AI-provider handle, and it rejects a controller step that
+ * returns a Promise (an async step is the shape a live network/provider call
+ * would take, so "agent-free" is enforced as "synchronous", not merely
+ * documented). A contribution's `createSandbox()` is re-invoked fresh for
+ * every scenario, so no state can leak in from a previous run or from a
+ * closure captured back when the contribution's author was still narrating
+ * it live.
+ *
+ * A contribution supplies:
+ * - `id` / `description`: identity for readable failure output.
+ * - `createSandbox()`: returns `{ worldState, controller, projectionSource? }`.
+ * `worldState` is plain, JSON-serializable state (a promoted foundation
+ * must be loadable by a peer that never saw the authoring session).
+ * - `controller.step(worldState, tick)`: advances one tick, returning the
+ * next `worldState` (or mutating and returning it — the harness does not
+ * require immutability, only determinism and survival).
+ * - `controller.applyDisturbance(worldState, disturbanceId)` (optional):
+ * called once per scenario between the warm-up ticks and the recovery
+ * ticks. A controller that omits it is asserting the disturbance is a
+ * no-op, which the recovery ticks still have to prove out.
+ * - `invariants` (optional): `(worldState, tick) => true | false | { ok, reason }`
+ * checks specific to the contribution (e.g. "no entity outside its
+ * district bounds"), run after every tick alongside the harness's own
+ * built-in serializability check.
+ *
+ * This module makes no network, filesystem, or provider calls and depends
+ * only on `buildProjectionPlan` (already pure) for the "load projections in
+ * a clean sandbox" leg of the assay. The promote path (#7455, not yet built)
+ * is expected to call `runResilienceAssay()` per candidate contribution and
+ * block promotion on a failing verdict; `scripts/eidoverse-resilience-assay.js`
+ * gives CI (or a human) the same verdict from the command line.
+ *
+ * try/catch here is deliberate, not the "errors bubble to middleware" default
+ * (AGENTS.md "Code Conventions"): a contribution's controller is untrusted,
+ * isolated code the assay evaluates rather than internal PortOS request
+ * handling, and turning its exceptions into a readable pass/fail verdict is
+ * this module's whole job — same rationale as the PTY/child-process boundary
+ * exception, applied to a sandboxed replay boundary instead of a process one.
+ */
+
+import { buildProjectionPlan } from './eidoverseWorldProjection.js';
+
+/** The fixed, mild disturbance suite every contribution is replayed against. */
+export const RESILIENCE_DISTURBANCES = Object.freeze([
+ // A peer/session dropping and re-establishing its connection to the world.
+ 'reconnect',
+ // The Eidoverse host bridge (server/services/eidoverseHost.js) bouncing —
+ // the controller has to resume from serialized state, not an in-memory
+ // handle to the process that just died.
+ 'restart-world-host',
+ // An optional dependency (a feature flag, a peer, an asset) going missing —
+ // the controller must degrade rather than assume everything it saw during
+ // authoring is still there.
+ 'missing-optional-deps',
+]);
+
+const DEFAULT_WARMUP_TICKS = 5;
+const DEFAULT_RECOVERY_TICKS = 3;
+
+function describeInvariant(invariant, index) {
+ return invariant.name || `invariant[${index}]`;
+}
+
+/** Built-in structural check: state a promoted foundation carries must be
+ * loadable by a peer that never ran the authoring session, so it has to
+ * round-trip through JSON without throwing or losing identity to `NaN`/
+ * `undefined` coercion. */
+function serializabilityFailure(worldState) {
+ let json;
+ try {
+ json = JSON.stringify(worldState);
+ } catch (error) {
+ return `world state is not JSON-serializable: ${error.message}`;
+ }
+ if (json === undefined) return 'world state serialized to undefined (functions/symbols at the top level are not portable to a peer sandbox)';
+ return null;
+}
+
+function runInvariants(worldState, tick, invariants) {
+ const failures = [];
+ const structural = serializabilityFailure(worldState);
+ if (structural) failures.push(`tick ${tick}: ${structural}`);
+
+ invariants.forEach((invariant, index) => {
+ const label = describeInvariant(invariant, index);
+ let result;
+ try {
+ result = invariant(worldState, tick);
+ } catch (error) {
+ failures.push(`tick ${tick}: invariant "${label}" threw: ${error.message}`);
+ return;
+ }
+ if (result === true || result == null) return;
+ if (result === false) {
+ failures.push(`tick ${tick}: invariant "${label}" failed`);
+ return;
+ }
+ if (typeof result === 'object' && result.ok === false) {
+ failures.push(`tick ${tick}: invariant "${label}" failed${result.reason ? `: ${result.reason}` : ''}`);
+ }
+ });
+ return failures;
+}
+
+function isThenable(value) {
+ return Boolean(value) && typeof value === 'object' && typeof value.then === 'function';
+}
+
+const ASYNC_STEP_REASON = 'controller.step() returned a Promise — the resilience assay replays contributions synchronously and agent-free; a controller that needs to await anything is reaching for a live network, disk, or provider call the assay does not permit';
+
+function runStep(controller, worldState, tick) {
+ const next = controller.step(worldState, tick);
+ if (isThenable(next)) throw new Error(ASYNC_STEP_REASON);
+ return next === undefined ? worldState : next;
+}
+
+function runScenario({ contribution, disturbance, warmupTicks, recoveryTicks }) {
+ let sandbox;
+ try {
+ sandbox = contribution.createSandbox();
+ } catch (error) {
+ return { disturbance, pass: false, reasons: [`createSandbox() threw: ${error.message}`] };
+ }
+ if (!sandbox || typeof sandbox.controller?.step !== 'function') {
+ return { disturbance, pass: false, reasons: ['createSandbox() must return { worldState, controller } with a controller.step(worldState, tick) function'] };
+ }
+
+ const invariants = Array.isArray(contribution.invariants) ? contribution.invariants : [];
+ let worldState = sandbox.worldState;
+ let tick = 0;
+ const reasons = [];
+
+ for (; tick < warmupTicks; tick += 1) {
+ try {
+ worldState = runStep(sandbox.controller, worldState, tick);
+ } catch (error) {
+ return { disturbance, pass: false, reasons: [`tick ${tick} (warm-up, before "${disturbance}"): ${error.message}`] };
+ }
+ reasons.push(...runInvariants(worldState, tick, invariants));
+ }
+ if (reasons.length > 0) return { disturbance, pass: false, reasons };
+
+ if (typeof sandbox.controller.applyDisturbance === 'function') {
+ try {
+ const disturbed = sandbox.controller.applyDisturbance(worldState, disturbance);
+ if (isThenable(disturbed)) return { disturbance, pass: false, reasons: [`applyDisturbance("${disturbance}") returned a Promise — disturbances are applied synchronously`] };
+ worldState = disturbed === undefined ? worldState : disturbed;
+ } catch (error) {
+ return { disturbance, pass: false, reasons: [`applyDisturbance("${disturbance}") threw: ${error.message}`] };
+ }
+ }
+
+ for (let recovered = 0; recovered < recoveryTicks; recovered += 1, tick += 1) {
+ try {
+ worldState = runStep(sandbox.controller, worldState, tick);
+ } catch (error) {
+ return { disturbance, pass: false, reasons: [`tick ${tick} (recovering from "${disturbance}"): ${error.message}`] };
+ }
+ reasons.push(...runInvariants(worldState, tick, invariants));
+ }
+
+ return { disturbance, pass: reasons.length === 0, reasons };
+}
+
+/**
+ * Try loading projections against the sandbox's initial world state, the
+ * "replay ... / load projections in a clean sandbox instance" leg of the
+ * assay. `buildProjectionPlan` is already pure/deterministic, so this only
+ * proves the contribution's state shape survives that boundary — it does
+ * not touch a live world or Eidoverse host.
+ */
+function checkProjectionLoad(contribution) {
+ let sandbox;
+ try {
+ sandbox = contribution.createSandbox();
+ } catch (error) {
+ return { pass: false, reason: `createSandbox() threw before projection load: ${error.message}` };
+ }
+ try {
+ const plan = buildProjectionPlan({
+ source: sandbox.projectionSource || {},
+ currentState: sandbox.worldState || {},
+ });
+ if (!plan || !Array.isArray(plan.operations)) {
+ return { pass: false, reason: 'buildProjectionPlan() did not return a plan with an operations array' };
+ }
+ } catch (error) {
+ return { pass: false, reason: `buildProjectionPlan() threw against this contribution's world state: ${error.message}` };
+ }
+ return { pass: true, reason: null };
+}
+
+/**
+ * Run the full agent-free resilience assay for one contribution.
+ *
+ * @param {object} contribution
+ * @param {string} [contribution.id]
+ * @param {() => { worldState: object, controller: object, projectionSource?: object }} contribution.createSandbox
+ * @param {Array<Function>} [contribution.invariants]
+ * @param {object} [options]
+ * @param {string[]} [options.disturbances]
+ * @param {number} [options.warmupTicks]
+ * @param {number} [options.recoveryTicks]
+ * @returns {{ contributionId: string, pass: boolean, scenarios: Array, projection: {pass: boolean, reason: string|null}, reasons: string[] }}
+ */
+export function runResilienceAssay(contribution, {
+ disturbances = RESILIENCE_DISTURBANCES,
+ warmupTicks = DEFAULT_WARMUP_TICKS,
+ recoveryTicks = DEFAULT_RECOVERY_TICKS,
+} = {}) {
+ const contributionId = contribution?.id || 'unknown-contribution';
+ if (!contribution || typeof contribution.createSandbox !== 'function') {
+ return {
+ contributionId,
+ pass: false,
+ scenarios: [],
+ projection: { pass: false, reason: 'contribution did not run: missing createSandbox()' },
+ reasons: ['contribution must provide createSandbox()'],
+ };
+ }
+
+ const projection = checkProjectionLoad(contribution);
+ const scenarios = disturbances.map((disturbance) => runScenario({ contribution, disturbance, warmupTicks, recoveryTicks }));
+
+ const reasons = [
+ ...(projection.pass ? [] : [`[load-projection] ${projection.reason}`]),
+ ...scenarios.flatMap((scenario) => (scenario.pass ? [] : scenario.reasons.map((reason) => `[${scenario.disturbance}] ${reason}`))),
+ ];
+
+ return {
+ contributionId,
+ pass: reasons.length === 0,
+ scenarios,
+ projection,
+ reasons,
+ };
+}
diff --git a/server/services/eidoverseResilienceAssay.test.js b/server/services/eidoverseResilienceAssay.test.js
new file mode 100644
index 0000000000..0433273d77
--- /dev/null
+++ b/server/services/eidoverseResilienceAssay.test.js
@@ -0,0 +1,146 @@
+import { describe, expect, it } from 'vitest';
+import { runResilienceAssay, RESILIENCE_DISTURBANCES } from './eidoverseResilienceAssay.js';
+import { createBeaconRelayContribution } from './eidoverseResilienceAssayFixtures/beaconRelay.contribution.js';
+import { createNarratedOnlyContribution } from './eidoverseResilienceAssayFixtures/narratedOnly.failing.fixture.js';
+
+describe('runResilienceAssay', () => {
+ it('passes a contribution that keeps all state in worldState and survives every disturbance', () => {
+ const result = runResilienceAssay(createBeaconRelayContribution());
+
+ expect(result.pass).toBe(true);
+ expect(result.reasons).toEqual([]);
+ expect(result.projection.pass).toBe(true);
+ expect(result.scenarios).toHaveLength(RESILIENCE_DISTURBANCES.length);
+ expect(result.scenarios.every((scenario) => scenario.pass)).toBe(true);
+ });
+
+ it('fails a contribution that only works via a live author-session handle a world-host restart drops', () => {
+ const result = runResilienceAssay(createNarratedOnlyContribution());
+
+ expect(result.pass).toBe(false);
+ const restartScenario = result.scenarios.find((scenario) => scenario.disturbance === 'restart-world-host');
+ expect(restartScenario.pass).toBe(false);
+ expect(restartScenario.reasons[0]).toMatch(/author session handle is gone/);
+ // Readable failure reasons name the offending disturbance so a promote
+ // path can surface exactly why a contribution was blocked.
+ expect(result.reasons.some((reason) => reason.startsWith('[restart-world-host]'))).toBe(true);
+
+ // The unrelated disturbances this fixture happens to survive still pass —
+ // the assay isolates each scenario rather than failing everything once
+ // one disturbance breaks the contribution.
+ const reconnectScenario = result.scenarios.find((scenario) => scenario.disturbance === 'reconnect');
+ expect(reconnectScenario.pass).toBe(true);
+ });
+
+ it('re-creates the sandbox per scenario, so no state leaks from one disturbance run into the next', () => {
+ let sandboxBuilds = 0;
+ const contribution = {
+ id: 'isolation-probe',
+ createSandbox() {
+ sandboxBuilds += 1;
+ return {
+ worldState: { pulses: 0 },
+ controller: { step: (state, tick) => ({ ...state, pulses: state.pulses + 1, lastTick: tick }) },
+ };
+ },
+ };
+
+ runResilienceAssay(contribution);
+
+ // Once for the projection-load preflight, once per disturbance scenario.
+ expect(sandboxBuilds).toBe(RESILIENCE_DISTURBANCES.length + 1);
+ });
+
+ it('rejects a contribution missing createSandbox() with a readable reason instead of throwing', () => {
+ const result = runResilienceAssay({ id: 'no-sandbox' });
+
+ expect(result.pass).toBe(false);
+ expect(result.reasons).toEqual(['contribution must provide createSandbox()']);
+ expect(result.scenarios).toEqual([]);
+ });
+
+ it('rejects an async controller.step() as an agent-free violation instead of hanging on a promise', () => {
+ const contribution = {
+ id: 'async-step',
+ createSandbox() {
+ return {
+ worldState: { pulses: 0 },
+ controller: { step: async (state) => ({ ...state, pulses: state.pulses + 1 }) },
+ };
+ },
+ };
+
+ const result = runResilienceAssay(contribution);
+
+ expect(result.pass).toBe(false);
+ expect(result.reasons.some((reason) => reason.includes('agent-free'))).toBe(true);
+ });
+
+ it('surfaces a contribution-supplied invariant failure with its reason and tick', () => {
+ const contribution = {
+ id: 'invariant-probe',
+ createSandbox() {
+ return {
+ worldState: { pulses: 0 },
+ controller: { step: (state) => ({ ...state, pulses: state.pulses + 1 }) },
+ };
+ },
+ invariants: [
+ function pulsesStayUnderThree(worldState) {
+ return worldState.pulses < 3
+ ? true
+ : { ok: false, reason: `pulses reached ${worldState.pulses}, over the fixture's cap of 3` };
+ },
+ ],
+ };
+
+ const result = runResilienceAssay(contribution, { warmupTicks: 5, recoveryTicks: 0 });
+
+ expect(result.pass).toBe(false);
+ expect(result.reasons.some((reason) => reason.includes('pulsesStayUnderThree') && reason.includes('cap of 3'))).toBe(true);
+ });
+
+ it('flags world state that cannot round-trip through JSON, even with no contribution invariants', () => {
+ const contribution = {
+ id: 'unserializable-state',
+ createSandbox() {
+ const worldState = { pulses: 0 };
+ worldState.self = worldState; // circular — not portable to a peer sandbox
+ return {
+ worldState,
+ controller: { step: (state) => state },
+ };
+ },
+ };
+
+ const result = runResilienceAssay(contribution);
+
+ expect(result.pass).toBe(false);
+ expect(result.reasons.some((reason) => reason.includes('not JSON-serializable'))).toBe(true);
+ });
+
+ it('fails the projection-load leg with a readable reason when buildProjectionPlan cannot use the sandbox state', () => {
+ const contribution = {
+ id: 'bad-projection-source',
+ createSandbox() {
+ return {
+ worldState: { entities: {} },
+ controller: { step: (state) => state },
+ // A source whose `health` read throws makes buildProjectionPlan's
+ // own property access fail well before any assay code is involved.
+ projectionSource: {
+ get health() {
+ throw new Error('synthetic source read failure');
+ },
+ },
+ };
+ },
+ };
+
+ const result = runResilienceAssay(contribution);
+
+ expect(result.projection.pass).toBe(false);
+ expect(result.pass).toBe(false);
+ expect(result.reasons.some((reason) => reason.startsWith('[load-projection]'))).toBe(true);
+ });
+});
diff --git a/server/services/eidoverseResilienceAssayFixtures/beaconRelay.contribution.js b/server/services/eidoverseResilienceAssayFixtures/beaconRelay.contribution.js
new file mode 100644
index 0000000000..526b52b0d9
--- /dev/null
+++ b/server/services/eidoverseResilienceAssayFixtures/beaconRelay.contribution.js
@@ -0,0 +1,74 @@
+/**
+ * Reference PASSING fixture for the agent-free resilience assay (#7460).
+ *
+ * A minimal "beacon relay" world foundation: every tick it advances a pulse
+ * counter and derives a label from an optional peer id. Everything the
+ * controller needs lives in `worldState`, so it survives a fresh
+ * `createSandbox()` call, a simulated host restart, and a missing optional
+ * peer without throwing or drifting into an invalid state. This is the
+ * "still works with no author narrating it" example the harness exists to
+ * recognize as promotable.
+ */
+
+const RESTART_CARRYOVER_KEYS = ['pulses', 'optionalPeerId', 'entities'];
+
+function beaconLabel(worldState) {
+ return worldState.optionalPeerId
+ ? `beacon-relay-to-${worldState.optionalPeerId}`
+ : 'beacon-relay-idle';
+}
+
+function createBeaconRelayController() {
+ return {
+ step(worldState, tick) {
+ return {
+ ...worldState,
+ pulses: worldState.pulses + 1,
+ lastBeaconLabel: beaconLabel(worldState),
+ lastTick: tick,
+ };
+ },
+ applyDisturbance(worldState, disturbance) {
+ if (disturbance === 'reconnect') {
+ return { ...worldState, connected: true };
+ }
+ if (disturbance === 'restart-world-host') {
+ // Rehydrate from only the durable, serializable fields — proves the
+ // controller does not depend on an in-process handle to the host
+ // that just bounced.
+ const carried = {};
+ for (const key of RESTART_CARRYOVER_KEYS) carried[key] = worldState[key];
+ return { ...carried, connected: true };
+ }
+ if (disturbance === 'missing-optional-deps') {
+ return { ...worldState, optionalPeerId: null };
+ }
+ return worldState;
+ },
+ };
+}
+
+export function createBeaconRelayContribution() {
+ return {
+ id: 'beacon-relay-demo',
+ description: 'Reference passing contribution: a pulse-counting beacon relay that keeps all state in worldState.',
+ createSandbox() {
+ return {
+ worldState: { pulses: 0, connected: true, optionalPeerId: 'peer-a', entities: {} },
+ controller: createBeaconRelayController(),
+ projectionSource: {},
+ };
+ },
+ invariants: [
+ function pulsesAreMonotonicIntegers(worldState) {
+ return Number.isInteger(worldState.pulses) && worldState.pulses >= 0;
+ },
+ function beaconLabelIsSet(worldState) {
+ if (typeof worldState.lastBeaconLabel !== 'string' || worldState.lastBeaconLabel.length === 0) {
+ return { ok: false, reason: `lastBeaconLabel was ${JSON.stringify(worldState.lastBeaconLabel)}` };
+ }
+ return true;
+ },
+ ],
+ };
+}
diff --git a/server/services/eidoverseResilienceAssayFixtures/narratedOnly.failing.fixture.js b/server/services/eidoverseResilienceAssayFixtures/narratedOnly.failing.fixture.js
new file mode 100644
index 0000000000..9b53377769
--- /dev/null
+++ b/server/services/eidoverseResilienceAssayFixtures/narratedOnly.failing.fixture.js
@@ -0,0 +1,58 @@
+/**
+ * Reference DELIBERATELY-FAILING fixture for the agent-free resilience
+ * assay (#7460).
+ *
+ * Named `.failing.fixture.js` (not `.contribution.js`) on purpose: the CI
+ * script's default fixture glob only picks up `*.contribution.js`, so this
+ * one is exercised only by `eidoverseResilienceAssay.test.js`, which asserts
+ * the harness correctly rejects it. It is proof the assay works, not a
+ * contribution anyone should promote.
+ *
+ * The bug it demonstrates: an "author session" handle captured outside
+ * `worldState` at sandbox-creation time. It behaves fine for `reconnect` and
+ * `missing-optional-deps`, but a simulated `restart-world-host` invalidates
+ * that live-only handle — exactly the "only works because the author mind is
+ * narrating it" failure mode SwarmWorld's agent-free evaluation targets.
+ */
+
+function createNarratedOnlyController() {
+ // Captured OUTSIDE worldState. A real world host restart would drop this
+ // along with the process that created it; nothing here re-derives it from
+ // serialized state the way the beacon-relay fixture does.
+ const authorSession = { narrate: (tick) => `authored beacon pulse ${tick}` };
+ let hostAlive = true;
+
+ return {
+ step(worldState, tick) {
+ if (!hostAlive) {
+ throw new Error('author session handle is gone after the world host restarted, and this contribution has no fallback path that re-derives it from worldState');
+ }
+ return { ...worldState, pulses: worldState.pulses + 1, lastNarration: authorSession.narrate(tick) };
+ },
+ applyDisturbance(worldState, disturbance) {
+ if (disturbance === 'restart-world-host') {
+ hostAlive = false;
+ }
+ return worldState;
+ },
+ };
+}
+
+export function createNarratedOnlyContribution() {
+ return {
+ id: 'narrated-only-demo',
+ description: 'Reference failing contribution: depends on an in-memory author-session handle a world-host restart invalidates.',
+ createSandbox() {
+ return {
+ worldState: { pulses: 0, entities: {} },
+ controller: createNarratedOnlyController(),
+ projectionSource: {},
+ };
+ },
+ invariants: [
+ function pulsesAreNonNegative(worldState) {
+ return Number.isInteger(worldState.pulses) && worldState.pulses >= 0;
+ },
+ ],
+ };
+}