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

fix: unify EIDOVERSE_PORT into a shared leaf constant (#8901)

[._.]/ Adam Eivy8721daec8aee
diff --git a/server/lib/README.md b/server/lib/README.md
index 9ef17fd0d2..2cda3f37d9 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -643,6 +643,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `eidoverseControllers.js` | Executable Eidoverse world controllers — the install schema and the sandboxed step boundary (#7456). `eidoverseControllerInstallSchema` / `eidoverseControllerRecordSchema` describe an install (a registry `controllerId`, a bounded `config`, a `tickIntervalMs`, and a `deliverEffects` flag that is FALSE by default, so installing arms bookkeeping and never a world verb). `runControllerStep` is the sandbox: it hands the controller JSON copies of its state and config, REFUSES a step that returns a Promise (an await is the shape every network/disk/AI-provider call takes, so the tick path is provider-free structurally rather than by convention), caps the state it may return, and validates its effects against a closed vocabulary — `note` (never leaves the ledger), `say`, and `augment`, which reuses `eidoverseValidation.js`'s own world-verb operation schema. `controllerTickDue` / `nextControllerTickAt` are the scheduling math, measured from now so a machine that slept wakes to ONE tick and not a replayed backlog. `summarizeControllerInstall` is the prompt-shaped projection that keeps a 16KB state blob out of a mind turn; it surfaces `derivedFrom`, the edge an install adopted from a peer's foundation carries (#7626). Pure: callers pass `now`. |
| `eidoverseFoundations.js` | Local-vs-baseline ownership for Eidoverse world foundations and the promote-candidate packaging gate (#7455). `EIDOVERSE_FOUNDATION_LAYERS` (`runtime` / `baseline` / `vernacular`, defaulting to `vernacular` so nothing is shared by omission) and `layerPromoteRefusal`; the record / input / candidate-envelope Zod schemas, where a foundation is `{ body, style }` BY CONSTRUCTION — packaging carries `body` and drops `style`, so an inheriting peer never receives its author's cosmetics, and `styleLeakFindings` REFUSES an unambiguously cosmetic key smuggled into `body` (spatial/asset keys stay allowed — they are a district template's substance). `assayEvidenceFromVerdict` folds an agent-free resilience verdict (#7460) into the evidence the gate reads, including the binding that it ran against the contribution this foundation names. `packageFoundationCandidate` and `verifyFoundationCandidate` are the one gate seen from the sending and receiving sides, over a content-addressed `fingerprint` hashed from the payload AS SENT; federation safety comes from `federationSafety.js`. `summarizeFoundation` is the prompt-shaped projection of a ledger record (layer, identity, assay outcome, whether a candidate exists) that keeps the local style layer and the packaged envelope out of a mind turn, and `detailFoundation` is its read-ONE counterpart, adding the `body` and `disclosure` the list deliberately omits (#7626). `eidoverseFoundationTargetSchema` + `foundationLedgerKey` are how a caller NAMES one record — `{ id, originInstanceId }`, where the origin addresses a local copy of a peer's foundation without making the internal `peer:<origin>:<id>` storage key user-typeable. `planFoundationAdoption` decides, per kind, what ADOPTING an inherited foundation means: a `controller` yields a disarmed install of the shipped controller its body names plus a `derived-from` edge, while `schema` / `affordance` / `district-template` are refused by name rather than silently succeeding. Pure: callers pass `now`. `derivedContributionId({ kind, id, body })` and `controllerDefinitionIdFromBody(body)` derive the assay binding label from the record itself, so neither an author nor a sending peer can name it (#7625); they live here rather than beside the sandbox that replays the body because the sandbox reaches this module through the creative toolkit. |
| `eidoverseFoundationSandbox.js` | Derives the agent-free resilience-assay sandbox for a foundation FROM ITS OWN BODY (#7625), closing the hole where the promote gate replayed whatever module the author named in a free-text `contributionId`. `foundationSandbox({ kind, id, body }, { findControllerDefinition })` returns the `{ id, createSandbox, invariants }` contribution `runResilienceAssay()` consumes, or a reader-facing refusal. One derivation per declared kind: `controller` replays the shipped definition named by `body.controller.definitionId` against THIS INSTALL'S `body.controller.config` (not upstream's `exampleConfig`); `district-template` requires `body.placement` to reproduce from its own layout/anchor/seed through `generateDistrictTemplatePlacement` and hands the body to the harness as the projection source; `schema`/`affordance` are replayed by the declarative interpreter over `EIDOVERSE_DECLARED_FIELD_TYPES`, which refuses an affordance recorded as prose rather than as `{ reads, writes }` over declared fields. The binding label both the packaging side and a receiving peer re-derive is computed by `derivedContributionId` in `eidoverseFoundations.js`, which declares the schema that carries it (and which this module would otherwise import in a cycle, via the creative toolkit). Executes only code PortOS ships; no caller-supplied path is ever resolved. Pure apart from the injected definition lookup. |
+| `eidoversePort.js` | `EIDOVERSE_PORT` (8940) — the Eidoverse Worlds HTTP port as a dependency-free leaf (#8901), so `services/managedVisitorHost.js` can default to it without pulling in the heavy `services/eidoverse.js` graph (os/path/spawn/git/apps). `services/eidoverse.js` re-exports it rather than declaring its own copy. |
| `eidoverseObservation.js` | Pure observation-first discovery report for the Eidoverse (#7457) — the read behind `eidoverse.observe`. `buildEidoverseObservation` turns already-collected snapshots (world signals, the install's RESOLVED design districts/includes, the foundation ledger, summarized controller installs) plus the previously persisted visit marker into `{ report, marker }`: districts as places a mind can describe, peers keyed to the foundations inherited through each, a peer contribution's origin/arrival instances, controllers filtered to the ones actually failing, and a `changes` diff against the last visit. Places come from the recipe rather than a constant, so a mind never names a district a later design version renamed; an unreadable source stays `null` and a recipe-disabled one reports `disabled`, neither collapsing to `0`; a first observation reports `firstObservation` rather than declaring a settled world new; and places diff on status flips only so routine signal churn never becomes noise. Scalar-vs-list source shape is shared with the projection via `EIDOVERSE_SCALAR_SOURCE_KEYS`. Pure: the caller passes `observedAt` and decides whether to commit the returned marker. |
| `eidoverseWorldDesign.js` | Immutable Eidoverse World Design V1/V2/V3 registry, override migration, semantic districts, 48-signal ceiling, and install-local asset locks for PortOS Commons. |
| `eidoverseWorldLabels.js` | The `comp.label` component PortOS attaches to every entity it projects into Eidoverse (eidoverse-worlds#5), so a rendered building says what it represents instead of only naming its decorative model. `buildEidoverseLabel(component, alias?)` reads one already-built `comp.portos` payload and returns `{name, description?, visibility, offset?}` — district and world-identity landmarks always visible, live indicators labelled `nearby`, path markers `inspect`-only so a walkway cannot bury the district it leads to — and `null` for anything not `managedBy: 'portos'`, so a caller cannot label somebody else's entity. Names and descriptions are built from PortOS's own vocabulary (district label, kind label, resource category, coarse status, freshness) plus an opaque hashed resource ref for disambiguation, never from record contents, machine identity, addresses, or filesystem paths — the append-only world log is the strictest privacy boundary PortOS writes to. Also owns bounded opaque-key alias normalization and V1 renderer capability parsing; aliases are explicit opt-in names and are never inferred from private records. Owns `safeWorldText`, the one control-character/length sanitizer shared with `services/eidoverseWorldProjection.js` so a component field and the label built from it cannot disagree about what is safe. Pure. |
diff --git a/server/lib/eidoversePort.js b/server/lib/eidoversePort.js
new file mode 100644
index 0000000000..c2925022b8
--- /dev/null
+++ b/server/lib/eidoversePort.js
@@ -0,0 +1,6 @@
+// Canonical Eidoverse Worlds HTTP port, a dependency-free leaf so
+// `managedVisitorHost.js` can default to it without pulling in the heavy
+// `services/eidoverse.js` graph (os/path/spawn/git/apps) it doesn't otherwise
+// need (#8901). `services/eidoverse.js` re-exports this rather than declaring
+// its own copy, so the two never drift.
+export const EIDOVERSE_PORT = 8940;
diff --git a/server/lib/index.js b/server/lib/index.js
index 44d4e07eeb..e396d6f60b 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -622,6 +622,7 @@ export * from './eidoverseControllers.js';
export * from './eidoverseFoundationSandbox.js';
export * from './eidoverseFoundations.js';
export * from './eidoverseObservation.js';
+export * from './eidoversePort.js';
export * from './federationSafety.js';
export * from './secretKeys.js';
export * from './eidoverseWorldDesign.js';
diff --git a/server/services/eidoverse.js b/server/services/eidoverse.js
index b4bdbefc46..fbeedb259d 100644
--- a/server/services/eidoverse.js
+++ b/server/services/eidoverse.js
@@ -9,10 +9,11 @@ import { parseGitHubUrl } from '../lib/repoUrl.js';
import { cloneRepo } from './repoCloner.js';
import { createApp, getAllApps, notifyAppsChanged, updateApp } from './apps.js';
import { getAppStatusStrict } from './pm2.js';
+import { EIDOVERSE_PORT } from '../lib/eidoversePort.js';
export const DEFAULT_EIDOVERSE_WORLDS_REPO = 'https://github.com/atomantic/eidoverse-worlds';
export const EIDOVERSE_VIDEO_REPO = 'https://github.com/anima-research/eidoverse-video';
-export const EIDOVERSE_PORT = 8940;
+export { EIDOVERSE_PORT };
export const EIDOVERSE_PROCESS_NAME = 'eidoverse-worlds';
const BUN_INSTALL_URL = 'https://bun.com/install';
diff --git a/server/services/eidoverseWorld.runtime.test.js b/server/services/eidoverseWorld.runtime.test.js
index abbb27767f..bb890c3fb9 100644
--- a/server/services/eidoverseWorld.runtime.test.js
+++ b/server/services/eidoverseWorld.runtime.test.js
@@ -274,6 +274,14 @@ beforeEach(async () => {
}));
});
+it('the eidoverse.js mock port matches the shared leaf so the mock cannot silently diverge from the real constant', async () => {
+ const [{ EIDOVERSE_PORT: mockedPort }, { EIDOVERSE_PORT: leafPort }] = await Promise.all([
+ import('./eidoverse.js'),
+ import('../lib/eidoversePort.js'),
+ ]);
+ expect(mockedPort).toBe(leafPort);
+});
+
describe('Eidoverse private-world lifecycle', () => {
it('reports connection refusal without an unhandled rejection and allows a subsequent retry', async () => {
mocks.connectionError = new Error('connect ECONNREFUSED');
diff --git a/server/services/managedVisitorHost.js b/server/services/managedVisitorHost.js
index 7e326a3ac8..abff74a814 100644
--- a/server/services/managedVisitorHost.js
+++ b/server/services/managedVisitorHost.js
@@ -1,4 +1,5 @@
import { ServerError } from '../lib/errorHandler.js';
+import { EIDOVERSE_PORT } from '../lib/eidoversePort.js';
// Settings win over the env var so the owner can set/rotate the credential from
// Settings > Credentials without restarting PortOS — same precedence and
@@ -14,7 +15,7 @@ async function resolveVisitorToken() {
}
/** Explicitly configured local host only; construction and disabled capability reads make no requests. */
-export function createManagedVisitorHost({ token, fetchImpl = fetch, port = 8940 } = {}) {
+export function createManagedVisitorHost({ token, fetchImpl = fetch, port = EIDOVERSE_PORT } = {}) {
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new ServerError('Invalid managed visitor host port.', { status: 400 });
// An explicitly passed `token` (including '' in tests) is honored verbatim and
// resolved statically, exactly as before. Omitting it entirely resolves fresh
diff --git a/server/services/managedVisitorHost.test.js b/server/services/managedVisitorHost.test.js
index f584b8835e..0e536270ca 100644
--- a/server/services/managedVisitorHost.test.js
+++ b/server/services/managedVisitorHost.test.js
@@ -1,5 +1,6 @@
import { expect, it, vi } from 'vitest';
import { createManagedVisitorHost } from './managedVisitorHost.js';
+import { EIDOVERSE_PORT } from '../lib/eidoversePort.js';
it('disabled transport makes no requests and explicit configuration keeps host credentials on the fixed loopback namespace', async () => {
const fetchImpl = vi.fn(async () => new Response(JSON.stringify({ capabilities: { managedVisitors: null } })));
const disabled = createManagedVisitorHost({ token: '', fetchImpl });
@@ -7,7 +8,7 @@ it('disabled transport makes no requests and explicit configuration keeps host c
expect(fetchImpl).not.toHaveBeenCalled();
const token = 'a'.repeat(64), host = createManagedVisitorHost({ token, fetchImpl }); await host.capabilities();
const [url, options] = fetchImpl.mock.calls[0];
- expect(url).toBe('http://127.0.0.1:8940/api/managed-visitors/v1/version');
+ expect(url).toBe(`http://127.0.0.1:${EIDOVERSE_PORT}/api/managed-visitors/v1/version`);
expect(options.headers.Authorization).toBe(`Bearer ${token}`); expect(options.redirect).toBe('error'); expect(options.signal).toBeInstanceOf(AbortSignal);
});
it('host response buffering is bounded and malformed/non-success replies do not become capabilities', async () => {