Skip to content

Feat/v2 monorepo#4

Merged
mrdulasolutions merged 4 commits intomainfrom
feat/v2-monorepo
Apr 21, 2026
Merged

Feat/v2 monorepo#4
mrdulasolutions merged 4 commits intomainfrom
feat/v2-monorepo

Conversation

@mrdulasolutions
Copy link
Copy Markdown
Owner

No description provided.

MRDula and others added 4 commits April 20, 2026 17:21
The old deploy.sh assumed \`railway up --config template.yaml\` (doesn't
exist) and other commands that never shipped. Replaced with a phased
script that uses only verified CLI 4.40 commands:

- \`railway init --name\` for project create
- \`railway add --database\` / \`--image\` / \`--repo\` / \`--service\`
- \`railway variable set K=V --service N --skip-deploys\`
- \`railway domain --service N\` for public URL
- \`railway up\` from services/mcp-router to ship the router (CLI has no
  rootDirectory flag for \`add --repo\`, so we create empty + push local)

Phases — each independently re-runnable:
  init       project + Postgres/FalkorDB/Qdrant
  services   nakatomi, automem, mcp-router (env vars, public domain)
  seed       admin user + Rev A pipeline/custom-field overlay
  finalize   print public URL + signup token (what admins hand to PMs)

Generated secrets (Nakatomi SECRET_KEY, AutoMem API/admin tokens, signup
token) persist in railway/.deploy-state across phases. Gitignored.

README rewritten to match: removed the aspirational \"one-click\"
template button claim, added the CLI phase flow as the recommended path
and a web-UI fallback for when things go sideways.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Two fixes after a live run hit real edge cases:

1. \`railway add\` happily creates duplicates on re-run (made two Postgres
   services when we re-ran phase 1). Added \`have_service <name>\` helper
   that queries \`railway status --json\` and skips the add if the name
   already exists. Every service add in phases 1 and 2 now gated by it.

2. \`railway add --repo\` returns "Unauthorized" silently if Railway's
   GitHub App isn't authorized on the target org — which surprised me
   mid-deploy on mrdulasolutions/NakatomiCRM and automem. Added a
   pre-flight warning block at the top of phase 2 pointing at the exact
   fix (Railway dashboard → Integrations → GitHub → grant org access),
   and called it out as a prerequisite in railway/README.md.

These make the script safe to re-run after any failure without leaving
orphaned or duplicated services.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The Railway GitHub App is installed inline when you add the first
repo-sourced service in the web UI — there's no standalone Integrations
page to click. My previous README step sent users to a page that doesn't
exist. Corrected both README and deploy.sh pre-flight warning to walk
through the actual UI path: + Create → GitHub Repo → Configure GitHub
App → grant org access → name the service.

Called out that the script is safe to re-run after the UI step because
have_service() will skip the existing service.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Shaken out by actually running the phased deploy against a fresh Railway
project. Every fix here comes from a concrete failure mode hit during the
first reva-ops bring-up.

mcp-router
- router/main.py: wire FastMCP session_manager.run() into FastAPI's
  lifespan. Without it, mounting mcp.streamable_http_app() leaves the
  anyio task group uninitialized and every /mcp/ request 500s with
  "Task group is not initialized. Make sure to use run()."
- requirements.txt: add email-validator — signup.py uses pydantic
  EmailStr which fails ImportError at import time without it.
- railway.toml: drop startCommand. Railway runs it exec-style without
  shell, so "--port $PORT" stays literal and uvicorn rejects it. The
  Dockerfile CMD already wraps in `sh -c` which expands correctly.

Nakatomi seed overlay (services/nakatomi-backend/seed/reva.py)
- Rewrite against Nakatomi's real pipeline API: stages are nested in
  the POST /pipelines body (there is no /pipelines/{id}/stages route);
  pipeline + stage both require a `slug` matching [a-z0-9][a-z0-9_-]*.
- Custom fields live at POST /custom-fields, not /schema/custom-fields.
  Schema is {entity_type, name, label, field_type, description} with
  field_type restricted to scalars (string|text|number|bool|date|url|
  email|select) — no object/array. JSON-shaped fields now ride as text.
- Idempotent by (entity_type, name) pre-check on GET.

railway/deploy.sh
- phase_seed: switch from `railway run` (which injects env vars locally
  rather than running in the container and can't reach the in-container
  DB) to `railway ssh` and execute `python -m scripts.seed` against
  /app directly. Ship reva.py into the container via base64 pipe since
  the upstream Nakatomi image doesn't vendor the overlay; run it
  against http://localhost:8000.
- discover_nakatomi_service(): tolerate UI rename drift
  (Nakatomi-backend vs nakatomi-backend) by matching case-insensitively
  from railway status --json.
- Cross-service wiring: stop hardcoding `<service>.railway.internal`
  hostnames — Railway derives those from the *original* service name
  at creation, so a later rename leaves the DNS stale. Use
  `${{service.RAILWAY_PRIVATE_DOMAIN}}` refs which Railway resolves to
  the real current domain at deploy time.
- Migrate variable writes from the deprecated `railway variable set`
  flag-form to the batched `railway variables --set k=v --set k=v`.
- Fix `railway domain --json` parsing: shape is {domains: [url, ...]},
  not [{domain}]. Strip the https:// prefix to get the bare host.
- Extend save_state to persist ADMIN_EMAIL/PASSWORD/WORKSPACE_* so a
  seed retry doesn't lose the generated password.

railway/README.md
- Update rotation hint to the new `railway variables --set ...` syntax.

Verified against live deploy: /health 200, /signup 200 (HTML page
renders), POST /mcp/ with Accept: text/event-stream returns a valid
initialize response advertising REVA Router + crm_/mem_/reva_ tool
namespaces.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@mrdulasolutions
Copy link
Copy Markdown
Owner Author

approved

@mrdulasolutions mrdulasolutions merged commit 3feb3ef into main Apr 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant