videogen/docs/apps-vision/PLATFORM_ARCHITECTURE.md
caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

32 KiB

Menivor (videogen) — Platform Architecture

Status: Architecture + the headline structural decision — split the rail out of the product. The Mint settlement rail (the durable asset) and the products that live on it move to a separate infra project — Railyard — and videogen/ becomes the Menivor video product that consumes Railyard as an external dependency. Two former app ideas are resolved: rust-git-forge is extracted to its own repo (kept, not built under videogen); context-passport is repurposed as "Character Lock," a real Menivor video feature.

Authorities this defers to (does not restate): rail thesis — PORTFOLIO.md; product API/client boundaries — docs/reelforge/PLATFORM_ARCHITECTURE_SPEC.md; repo layout — MONOREPO.md, REPO_STRUCTURE.md; per-app visions — docs/apps-vision/{vend,prism-media-gateway,abacus,turnstile,ledgerline}.md; money invariants — ADR-0001 (integer µ$), ADR-0002 (success-only).

Convention templates: apps/ledgerline/ (single-crate axum service) and apps/mint/ (multi-crate axum service) for the rail; apps/api + the additive convention in REPO_STRUCTURE.md §4 for Menivor product features.


1. Headline: the rail is infra, not a feature of the video product

Per PORTFOLIO.md, the durable, billion-dollar asset is Mint — a fiat-backed, gasless, success-only settlement ledger with hash-linked receipts — the rail underneath all apps, not one product's internal component. Today it lives inside videogen/ next to the ReelForge video code. That couples a company-defining piece of infrastructure to a single demand product.

Decision: extract the rail (and the products that live on it) into a separate infra project/repo; videogen/ keeps only the Menivor video product and consumes the rail the way any company consumes Stripe — over the network, against a versioned wire contract, with no source coupling.

   ┌───────────────────────────────┐          ┌──────────────────────────────────────────┐
   │  videogen/  (MENIVOR product) │          │  Railyard/  (INFRA PROJECT — its own repo)│
   │  the AI UGC video demand gen   │          │  the durable asset: the payments rail      │
   │                                │  HTTP    │  CORE: mint (settlement) · relay (models) ·│
   │  apps/api  (FastAPI + workers) │─────────▶│        agent-runtime (AITP-402 SDK)        │
   │  apps/web  apps/mobile         │  + shared│  EXPANSION: vend · abacus · turnstile ·    │
   │  apps/desktop · prism (media)  │◀─────────│             ledgerline                     │
   │  + Character Lock feature      │  events  │  (prism → promote to Railyard on 2nd user) │
   └───────────────────────────────┘          └──────────────────────────────────────────┘
        consumes the rail                            owns Mint = record-of-truth for AI money
        (like it consumes Stripe)                    installs the rail under many payers

This matches the thesis exactly: Mint is the record-of-truth beneath every payer (ReelForge video is just the first and largest), so it must not be a subdirectory of one payer.

1.1 What goes where

Destination Contents Why
Railyard/ (new infra repo) Rail core: mint (settlement ledger), relay (model gateway), agent-runtime (the shared AITP-402 payment-SDK substrate). Expansion products: vend, abacus, turnstile, ledgerline (+ prism-media-gateway — flagged decision, §4.1). These are platform, not Menivor. Each is already a standalone workspace / service; each either is the rail or is a wedge that installs Mint under a new payer class.
videogen/ (Menivor product, stays) apps/api, apps/web, apps/mobile, apps/desktop, + Character Lock (new feature in apps/api) The video demand generator. It consumes Railyard; it does not own it.
Leaves entirely rust-git-forge → EXTRACT to its own repo (owner keeps building it, just not under videogen); context-passport → repurposed as Character Lock (see §6), the OAuth/identity concept discarded Neither served video or the rail.

Infra name (decided): Railyard. Railyard = Mint (settlement core) + Relay (model gateway) + agent-runtime (shared AITP-402 payment-SDK substrate) + the expansion products Vend / Abacus / Turnstile / Ledgerline (+ Prism, pending the §4.1 decision). Menivor/videogen consumes Railyard over the network + shared contract packages.


2. The consumption boundary — how Menivor uses the rail without owning it

Three coupling options were considered; the recommendation is a strict network + contract boundary, no source sharing.

Option Mechanism Verdict
(a) Shared contract packages Publish/vendor the wire contracts + typed clients: packages/eventbus-types (event catalog), a new Mint client SDK (Python for apps/api, TS for apps/web), packages/sdk-*. Both repos depend on the published version, not each other's source. KEEP — necessary. This is the seam that lets both sides evolve independently while agreeing on the wire.
(b) Rail as network services The infra project runs Mint/Relay/etc. as HTTP services; apps/api calls them over HTTPS with X-API-Key, exactly as apps/ledgerline/src/mint.rs calls Mint today (POST /v1/holds, /holds/:id/capture, /v1/transfers). KEEP — recommended primary. Already the real pattern. Rail is treated like Stripe: an external, independently-deployed dependency.
(c) Source coupling (git submodule / cargo path/git dep) Menivor builds the rail from source. REJECT. apps/api is Python and Mint/Relay are Rust — source coupling is both impossible cross-language and undesirable (it recouples release cycles and drags the rail back into the product build graph).

Recommended boundary = (b) + (a): the infra project deploys the rail as network services; videogen/apps/api consumes them through a small Mint client (Python port of the ledgerline/src/mint.rs seam: a MintSettlement-style interface + a reqwest-equivalent httpx client, injectable so tests fake it) and a Relay client, plus the shared eventbus-types catalog for cross-boundary events. Config is env-only: MINT_BASE_URL, MINT_API_KEY, RELAY_BASE_URL, RELAY_API_KEY — fail-closed at startup (the house rule: services that own money name their missing env vars and refuse to run without them).

This preserves every existing invariant across the boundary: integer-µ$ money (ADR-0001), success-only capture (ADR-0002), idempotent per-operation settlement keys, correlation ids threaded into receipts, and DB-per-service isolation (Menivor never reads Mint's tables; it calls Mint's HTTP API).


3. Migration plan — splitting the rail out

The split is unusually clean because mint, relay, vend, abacus, turnstile, ledgerline are already standalone Cargo workspaces excluded from the root desktop build graph (root Cargo.toml exclude = ["apps/relay", "apps/mint", "apps/agent-runtime", "apps/vend", "apps/turnstile", "apps/abacus", "apps/ledgerline"]). They have no source dependency on the desktop workspace or on apps/api; extraction is a directory move plus wiring cleanup.

Steps:

  1. Create the infra repo Railyard/ with its own apps/ (or top-level services/). git subtree split / git filter-repo each rail service dir preserving history: mint, relay, agent-runtime (rail core), plus vend, abacus, turnstile, ledgerline (expansion). Prism stays in videogen/ for now (§4.1) — it wraps apps/api's media adapters and has no second consumer yet.
  2. Relocate the standalone workspaces as-is. Because each already declares its own [workspace] (or is excluded), no member/exclude edits are needed inside them — they compile identically in the new repo.
  3. Split the shared contracts. Move rail-owned wire contracts to Railyard/ and publish them: the Mint/Relay wire schemas + typed client SDKs (Python + TS). Keep packages/eventbus-types as a shared, published package both repos depend on (it is the cross-service event catalog, not product-specific). packages/api-contract (ReelForge /api/v1) stays in videogen/ — it is the product's own contract, not the rail's.
  4. Rewrite videogen/ to consume over the network. Add apps/api Mint + Relay clients (the httpx port of ledgerline/src/mint.rs); replace any in-repo assumption that Mint/Relay are local crates with MINT_BASE_URL/RELAY_BASE_URL env config.
  5. Clean up videogen/ root wiring — what breaks and the fix:
    • Root Cargo.toml exclude list → remove the moved services' entries.
    • Makefile.products, apps/README.md, docs/apps-vision/PORTFOLIO.md launch map → drop the moved products; point runbooks at the rail as an external dependency.
    • docker-compose.reelforge.yml / docker-compose.{vend,full}.yml and .env.* → the rail composes move to Railyard/; videogen/ compose gains MINT_BASE_URL/RELAY_BASE_URL pointing at the running rail (local dev: a docker-compose that brings up the rail alongside, or a shared dev URL).
    • Doc cross-links from docs/reelforge/* and docs/apps-vision/* to the moved services → update to the new repo.
  6. Handle the two departing dirs in videogen/: git subtree split apps/rust-git-forge into its own repo (GitGram's or standalone — §5), then remove it from videogen/; and delete the discarded apps/context-passport Python scaffold (its concept is reborn as Character Lock, §6 — nothing is reused verbatim).
  7. Verify: videogen/ builds + tests green with the rail stubbed/faked (the Mint client's injectable seam makes this a unit-test concern, exactly as Ledgerline fakes Mint today); the rail repo builds each standalone workspace and passes its own suites (Mint already carries hold_property_storms, concurrency, gate_million).

What does NOT break: because the rail services already talk to each other over HTTP with X-API-Key (e.g. Ledgerline → Mint), moving them together preserves all intra-rail calls unchanged. Only the product → rail edge changes from "same repo" to "network dependency," and that edge was already HTTP-shaped.


4. The rail (infra project) — money + event flow

For completeness (this now lives in Railyard/, but Menivor depends on it):

Mint settlement primitives (mint-server/src/router.rs): accounts/addresses; POST /v1/transfers; holds POST /v1/holds → /capture | /release (the success-only primitive); streams /v1/streams → /tick → /close; allowances /v1/allowances → /spend | /revoke (Abacus enforces on these); hash-linked receipts; AITP-402 /v1/aitp/{challenge,verify,capture,release} (Turnstile fronts these); reserve + mint/redeem + signature-verified on-ramp webhooks (outside the API-key layer).

The settle seam every payer reuses (apps/ledgerline/src/mint.rs): a MintSettlement trait + rustls client that, per successful event, does hold → capture (revenue) + transfer (COGS) with per-operation deterministic idempotency keys so a crash mid-settlement resumes without double charge; failed events move no money (ADR-0002). Menivor's apps/api uses a Python port of this exact seam.

Who pays through the rail:

Payer Payer class installed Mint primitives
Menivor / ReelForge (in videogen/) creators/agencies buying video credits → hold/capture on job success; creator payouts
Vend AI-SaaS apps reselling inference reserve wallet (reserve + holds + streams), dunning
Prism media devs success-only capture per media job; marketplace payouts
Abacus autonomous agents allowances (hold the budget) → capture on enforced request
Turnstile any paid HTTP/MCP endpoint AITP-402 challenge/verify/capture
Ledgerline any company wanting true margin hold→capture (revenue) + transfer (COGS)

Events: cross-boundary signals use the shared packages/eventbus-types catalog (EventEnvelope + push/deep-link map). Transport stays per-service; only schema is shared.

Cross-cutting axum skeleton (every rail service): own standalone Cargo workspace; error.rs/domain.rs/store.rs/<external>.rs/server.rs(or *-server crate)/main.rs/migrations/; money validated as integer µ$ before any external call; MemoryStore + PostgresStore with idempotent INSERT … ON CONFLICT DO NOTHING; /healthz (204) + /readyz (SELECT 1) unauthenticated; X-API-Key constant-time (subtle::ConstantTimeEq); webhooks by raw-body signature outside the key layer; TraceLayer + redacted logs. (Grounded in ledgerline/src/* and mint/crates/mint-server/src/*.)

4.1 Prism — flagged decision: Railyard infra vs Menivor product

Prism (apps/prism-media-gateway, Python/FastAPI) is genuinely borderline. Evaluation shows it directly wraps apps/api's own media adapters/routing (image + video generation) — the same avatar/B-roll/generation providers the video product already owns. That makes it read as part of the Menivor video product (media generation is the video demand), not neutral rail infra like Mint/Relay.

  • Argument to STAY in Menivor: it shares media adapters and routing with apps/api; splitting it forces either duplicated adapter code or a second network hop for the product's core generation path. Media = video demand.
  • Argument to MOVE to Railyard: the portfolio thesis frames Prism as a general media-generation gateway (one OpenAI-compatible endpoint for every media model across every provider, cloud and local GPU) that markups + pays out on Mint — i.e. infra that many payers (not just ReelForge) route media spend through, exactly like Relay is for text.

Recommendation: keep Prism with Menivor for now, factored behind a clean media-provider interface (packages/provider-adapter-kit), and promote it to Railyard only when a second non-ReelForge consumer appears. Reasoning: today its sole consumer is the video product and it shares that product's adapters, so the network/duplication cost of extraction buys nothing yet; the moment Vend/Abacus or an external dev needs media routing, it graduates to rail infra with the adapter interface already in place. Until then it is Menivor's media plane, and only text (Relay) + settlement (Mint) are extracted as pure rail.

4.2 Railyard hardening — the shared-datastore + price-catalog workstream (first-class)

Evaluation of the rail apps (relay-billing, abacus, turnstile, agent-runtime) found them high-quality and tested, but with one shared blocker and one gap that Railyard must fix as a first-class workstream before it is a production multi-tenant rail:

  1. In-process state blocks horizontal scale. Holds, AITP-402 nonces, and receipts are held in process-local memory in several rail services (mirrors the InMemoryNonceStore / memory-store seams visible in mint), so no two replicas share settlement truth. Fix: a shared, transactional Railyard datastore (Postgres) behind the existing LedgerStore / nonce-store / receipt-log ports — the ports already exist (mint is generic over S: LedgerStore with a PgStore), so this is wiring every rail service to the shared Postgres impl and removing in-memory production paths, then proving it under the concurrency / hold_property_storms / gate_million suites Mint already carries.
  2. Relay has no per-model price catalog. Exact-COGS billing needs a versioned price source. Fix: a Railyard price catalog (per-model, per-provider, versioned, effective-dated) that Relay reads to price each request and that Ledgerline/Vend/Abacus reconcile against — a small service or a table behind a PriceCatalog port, seeded from provider manifests.

These two — shared transactional datastore + price catalog — are the gating work that turns the current single-node rail slices into a horizontally-scalable, correctly-priced Railyard. They are prerequisites for onboarding any second payer beyond ReelForge and belong at the top of the Railyard roadmap (§8).


5. rust-git-forge — verdict: EXTRACT to its own repo

A from-scratch Rust Git implementation with zero connection to video, Mint, or payments. Its own PLAN.md ties it to GitGram (the social-git product) and AITimeMachine — not to Menivor or the rail. Nothing in its six release stages touches money. It does not belong in videogen/. But the owner intends to keep building it, so it is extracted, not dropped.

Action: git subtree split apps/rust-git-forge/ (preserving history) into its own repository — GitGram's repo (whose Git engine it is) or a standalone rust-git-forge/ repo. It is already fully standalone (empty [workspace], not in the root exclude, no dependency on any videogen crate or packages/*), so the extraction is a clean move that breaks nothing in videogen/. The useful engineering — the git-exact SHA-1 loose-object core, Odb/Refs/Repository modules, and the real-git interop harness (src/* + tests/interop.rs) — travels intact to the new repo. It is removed from the Menivor architecture entirely; its own PLAN's crates/* roadmap and core-before-forge gate are governed in that repo.


6. context-passport → Character Lock (KEEP + build — a Menivor video feature)

The OAuth2 / identity-portability concept is discarded. The reusable core idea — structured, versioned, sourced fields with a stable identity and immutable "locks" — is repurposed to solve one of the hardest, highest-value problems in AI UGC video: generating the same character consistently across many reels (same face/appearance, same voice, same style/personality). This is a real Menivor feature and fits the video thesis cleanly.

Kept from the passport concept: structured + versioned + sourced fields; a stable character identity; immutable locks once approved. Dropped entirely: OAuth2 authorize/PKCE, third-party grants, developer apps, access/refresh tokens, consent screens, per-read receipts — all of it was for external-app identity portability, irrelevant to character consistency.

6.1 Where it lives — recommendation: a module inside apps/api, not a standalone service

A locked character definition is durable product data the API owns (platform rule AD-3: apps/api owns durable product data and business transactions), and it references assets the API already manages — ElevenLabs voices (app/services/ voice.py, tts/), HeyGen/latentsync avatars (app/services/avatar/), LoRA/ character weights, and R2 image keys (app/services/storage/r2.py). It feeds the API's own Celery render stages (script → tts → {avatar ∥ captions} → compose). A standalone service would have to duplicate access to those tables/assets and re-cross the pipeline boundary for zero benefit. So Character Lock is a new backend feature module in apps/api, built by the additive convention in REPO_STRUCTURE.md §4.1 — new files in the right place, appends to the shared "append-point" files, no existing file moved.

6.2 Folder / file blueprint (house convention, additive)

apps/api/
├── app/
│   ├── services/
│   │   └── character/                     # NEW multi-file service (mirrors avatar/, billing/, tts/ subdir pattern)
│   │       ├── __init__.py                #   exports the service surface
│   │       ├── service.py                 #   create / edit-as-new-version / approve+lock workflows; immutability rules
│   │       │                              #     (a locked CharacterVersion is frozen; edits fork a new draft version)
│   │       ├── traits.py                  #   structured schema: appearance (age/build/hair/wardrobe/features),
│   │       │                              #     personality/tone (traits, speaking style, catchphrases, do/don't),
│   │       │                              #     branding (logo, colors, outfit) + per-field `source` provenance
│   │       ├── assets.py                  #   validate + bind locked asset refs to existing API records:
│   │       │                              #     voice_id → voice.py/ElevenLabs, avatar_ref → avatar/ registry,
│   │       │                              #     lora_ref/embedding_ref (+ trigger word), reference_image R2 keys
│   │       └── resolver.py                #   resolve a locked CharacterVersion → a pipeline-injection payload
│   │                                      #     (voice_id, avatar_ref, lora_ref, ref-image keys, style prompt frags)
│   │
│   ├── controllers/v1/
│   │   └── characters.py                  # NEW v1 controller via app.controllers.v1.base.new_router();
│   │                                      #   x-api-key → User; responses via utils.get_response(); HttpException
│   │
│   ├── models/
│   │   ├── schema.py            (APPEND)  # + CharacterCreate, CharacterUpdate, CharacterOut,
│   │   │                                  #   CharacterVersionOut, LockRequest, GenerateAsCharacterRequest DTOs
│   │   └── db/
│   │       ├── models.py        (APPEND)  # + Character, CharacterVersion ORM tables (Mapped[] columns)
│   │       └── repositories.py  (APPEND)  # + CharacterRepository (create/list/get/add_version/lock/current_locked)
│   │
│   ├── router.py               (APPEND)   # + include_router(characters.router) — one line
│   │
│   └── workers/
│       └── tasks.py            (APPEND)   # pipeline stages read the resolved character payload (see §6.4)
│   └── services/
│       └── reelforge.py        (APPEND)   # + character fields on ReelForgeParams; stage transforms consume them
│
├── migrations/versions/
│   └── <YYYYMMDD_HHMM>_<rev>_character_lock.py   # NEW Alembic revision; down_revision = current head; linear chain
│
└── tests/reelforge/
    ├── test_characters.py                 # unit: version/lock immutability, trait schema, asset binding, resolver
    └── test_characters_api.py             # API: create → version → lock → get; generate-as-character seeds the job

apps/api/controllers/v1/jobs.py (APPEND-POINT) also gains an optional character_id (+ optional character_version, defaulting to the current locked version) on POST /jobs, so the existing reel-creation path can render "as character X" without a parallel endpoint.

6.3 Data model

  • Character — id, workspace_id/owner_id, name, slug, status (draft | locked | archived), current_version_id (the locked version the pipeline uses), created_at, updated_at.
  • CharacterVersion (immutable once locked) — id, character_id, version (monotonic int), status (draft | approved | locked), locked_at, and the sourced, structured definition:
    • appearance (JSON: age range, build, hair, distinguishing features, wardrobe)
    • reference_image_keys (R2 keys: face refs + full-body refs)
    • voice_id (ElevenLabs voice) + voice_sample_key
    • avatar_ref (HeyGen avatar id / talking-photo preset)
    • lora_ref / embedding_ref (+ trigger_word) for consistent generation
    • style (JSON: personality traits, tone, speaking style, catchphrases, do/don't)
    • branding (JSON: logo key, colors, outfit)
    • sources (JSON: per-field provenance — uploaded | generated | cloned)
    • created_at.

Lock rule (kept from the passport idea): approving a version sets it immutable and points Character.current_version_id at it; any later edit creates a new draft version — history is preserved, and every render references an exact, frozen character version for reproducibility.

6.4 API surface + render integration

POST   /v1/characters                       create a draft character
GET    /v1/characters                       list characters
GET    /v1/characters/{id}                  get character + current locked version
POST   /v1/characters/{id}/versions         create a new draft version (edit)
GET    /v1/characters/{id}/versions         version history
POST   /v1/characters/{id}/versions/{v}/lock  approve + FREEZE a version (immutable)
POST   /v1/characters/{id}/generate         "generate video AS character X"
                                            (thin wrapper: POST /jobs with character_id + locked version)

How the pipeline stays consistent (the whole point): when a job carries a character_id, the worker calls character.resolver.resolve() once to get the locked payload, then injects it into each stage:

  • script stage → style/personality prompt fragments so the character talks in character.
  • tts stage → the locked voice_id (ElevenLabs) so the voice is identical.
  • avatar stage → the locked avatar_ref (HeyGen/latentsync) so the face is identical.
  • generation / B-roll stage → lora_ref/embedding_ref + reference_image_keys passed to the media gateway (Prism, now in the infra repo) or the desktop local render farm (ComfyUI/Wan), so generated shots keep the same appearance.
  • compose / captions stage → branding (logo, colors, outfit) for consistent styling.

Clients: apps/web and apps/mobile add a Character manager screen (create / version / lock / pick a character when creating a reel) following their per-feature convention (lib/<feature>.ts client + components/<feature>/). apps/desktop (Rust/GPUI local render farm) reads the locked lora_ref + reference images to keep locally-generated shots on-model. Prism (infra) receives the locked embedding/LoRA refs on each media call — Character Lock is the thing that makes "the same person" appear across every reel.

6.5 Phasing

  1. v1 (core): Character + CharacterVersion tables, create/version/lock API, resolver, and wiring voice_id + avatar_ref into the tts/avatar stages (highest-value consistency with assets the API already owns). Web/mobile picker.
  2. v2: lora_ref/embedding_ref + reference_image_keys into the generation/ Prism/desktop stages for generated-shot appearance lock; style into the script stage; branding into compose.

7. Updated product-fit verdicts (final dispositions)

App Group Fit Disposition
mint Railyard (rail core) IS the settlement rail MOVE → Railyard/
relay Railyard (rail core) model rail + exact COGS MOVE → Railyard/
agent-runtime Railyard (rail core) shared AITP-402 payment-SDK substrate MOVE → Railyard/
vend Railyard (expansion) reserve wallet on Mint MOVE → Railyard/
abacus Railyard (expansion) enforces on allowances/holds MOVE → Railyard/
turnstile Railyard (expansion) fronts AITP-402 MOVE → Railyard/
ledgerline Railyard (expansion) rev+COGS on Mint MOVE → Railyard/
prism-media-gateway borderline wraps apps/api media adapters STAY (Menivor) for now — promote to Railyard on a 2nd consumer (§4.1)
api (ReelForge) Menivor the video product STAY
web Menivor video client STAY
mobile Menivor video client STAY
desktop Menivor video client + local render STAY
Character Lock (ex-context-passport) Menivor character consistency in render STAY — build as apps/api module
rust-git-forge neither no video / no rail (GitGram's engine) EXTRACT → its own repo

After the split, videogen/ = the Menivor video product (api/web/mobile/desktop + Character Lock, + Prism as the media plane for now) that consumes Railyard/ over the network.


8. Build order + owner decisions

Build order:

  1. Define the boundary contract — publish eventbus-types + a Mint client SDK (Python for apps/api, TS for apps/web); add MINT_BASE_URL/RELAY_BASE_URL config to apps/api. (Enables the split without a big-bang cutover.)
  2. Execute the rail split (§3) — subtree-split the seven rail services (mint, relay, agent-runtime, vend, abacus, turnstile, ledgerline) into Railyard/, rewire videogen/ to consume over HTTP, remove root exclude entries, git subtree split rust-git-forge to its own repo, and delete the old context-passport scaffold. (Prism stays in Menivor for now — §4.1.)
  3. Harden Railyard first (§4.2) — the shared transactional datastore (wire every rail service's LedgerStore/nonce/receipt ports to the shared Postgres impl; remove in-memory production paths) and the per-model price catalog for Relay. This is the gate to multi-tenant, horizontally-scalable rail.
  4. Build Character Lock v1 (§6) in apps/api — the highest-value new Menivor feature; consistency via voice_id + avatar_ref first.
  5. Continue the rail roadmap in Railyard/ per PORTFOLIO.md rank order (Vend → Prism-as-infra-if-promoted → Abacus → Turnstile → Ledgerline), independent of Menivor's release cycle.

Owner decisions:

  1. Infra repo hosting — name is decided (Railyard); remaining call is one repo with services/* vs an org of repos. Recommendation: one Railyard repo mirroring today's apps/* standalone-workspace layout.
  2. Prism disposition (§4.1) — stay in Menivor (recommended, single consumer + shared adapters) vs move to Railyard as general media infra now. Recommendation: stay until a second non-ReelForge media consumer exists, then promote.
  3. Contract distribution — publish contract packages to a registry (npm/PyPI) vs a shared private feed vs vendored copies. Recommendation: published versioned packages; both repos pin a version (no cross-repo source deps).
  4. Local dev ergonomics after the split — a docker-compose in videogen/ that pulls the rail images vs a shared hosted dev rail. Recommendation: compose that brings up Railyard alongside for hermetic local runs; MINT_BASE_URL points at it.
  5. Character Lock home — confirm — apps/api module (recommended, per AD-3 and asset reuse) vs a standalone service. Recommendation: apps/api module.
  6. rust-git-forge extraction target — GitGram's repo (its engine) vs a standalone rust-git-forge/ repo. Recommendation: subtree-split to GitGram (preserves history + the interop harness), then remove from videogen/.
  7. Railyard hardening priority (§4.2) — confirm the shared datastore + price catalog lead the Railyard roadmap ahead of new expansion products, since they gate horizontal scale and correct pricing for every payer.
  8. DB-per-service across the boundary (confirm, not change) — Menivor never reads Mint's tables; it settles via Mint's HTTP API only. Flagging to confirm no one proposes a shared DB across the repo boundary.