Repository navigation
flip the served math to the Python engine: readers follow MATH_ENV, the Clojure writer keeps its prod label - #2911
Merged
Merged
Conversation
…he Clojure writer keeps its prod label
The served-label switch moves only the readers. The server (MATH_ENV from
.env) and Delphi (${MATH_ENV:-prod} in compose) follow the shared MATH_ENV
in the production env secret; setting it to `python` serves the rows
math-python has been writing, and setting it back to `prod` is the rollback.
Before this change the Clojure `math` service also took ${MATH_ENV:-prod},
so the switch would have made Clojure write `python` beside math-python: two
writers on one label. Clojure now writes ${MATH_ENV_CLOJURE:-prod}, so it
keeps running and keeps its `prod` rows current through the switch, which
is what a rollback serves. math-python's label still comes only from
MATH_PYTHON_ENV (default `python`). The dev overlay keeps Clojure on
MATH_ENV unless MATH_ENV_CLOJURE is set, so existing dev .env files behave
as before.
- docker-compose.yml: `math` reads MATH_ENV_CLOJURE; comments on delphi and
math-python say which label each reads or writes.
- docker-compose.dev.yml: `math` falls back to MATH_ENV in dev.
- example.env, math/example.env, docs/configuration.md: document
MATH_ENV_CLOJURE ("the label the legacy Clojure engine writes; keep prod").
- scripts/after_install.sh: comments only; no role starts or stops anything
new. Clojure keeps running on the math role.
- delphi/docs/CUTOVER_RUNBOOK.md: "Step 2 as built": merge to stable, secret
MATH_ENV=python, deploy, verify the pca2 ETag prefix is `python-`;
rollback MATH_ENV=prod and redeploy; retiring Clojure is a later PR.
- delphi/tests/test_compose_math_env.py: Clojure writes `prod` whatever
MATH_ENV says, its label comes only from MATH_ENV_CLOJURE, and the switch
and rollback move only delphi. Four of these fail on the previous compose.
No server change (the label-prefixed pca2 ETag is already on edge). No
schema change.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s
Contributor
Delphi Coverage Report
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switches the served math from the Clojure engine (label
prod) to the Python engine (labelpython) by moving the readers only. Clojure keeps running and keeps writingprodfor the rollback window; removing it is a later PR.Mechanism
MATH_ENVin the production env secret (polis-web-app-env-vars): the server reads it from.env(Config.mathEnv), Delphi through${MATH_ENV:-prod}indocker-compose.yml. Unchanged by this PR.pythonwhatever the readers serve. Its label comes only fromMATH_PYTHON_ENV(pinnedpythonin the secret, compose fallbackpython). Its startup guard still refusesprodwhileMATH_POLLER_ALLOW_SERVED_ENVstays unset. Unchanged.${MATH_ENV_CLOJURE:-prod}, not${MATH_ENV:-prod}. Before this change, flipping the secret'sMATH_ENVtopythonwould have made Clojure writepythonbeside math-python (two writers on one label). Now it keeps writingprod, so the rollback target stays current. LeaveMATH_ENV_CLOJUREunset in the secret.docker-compose.dev.ymlgives Clojure${MATH_ENV_CLOJURE:-${MATH_ENV:-prod}}, so existing dev.envfiles (MATH_ENV=dev) behave as before.docker-compose.test.ymlis unchanged (its ownmathservice,dev).scripts/after_install.shderives Clojure's label fromMATH_ENV. The unknown-role fallback in the hook (up -dof every unprofiled service) now also starts Clojure onprod, not on the served label.Operator sequence
edge, then tostable. Boxes takedocker-compose.ymlfromstableat deploy, so this must land before the secret changes; under an older compose file Clojure followsMATH_ENV. Do not movestableback past this change while the secret sayspython.pythonrow (the backfill covers conversations older than the poller's boot window).MATH_ENV=pythonin the env secret..envfrom the secret on every box; server and Delphi restart readingpython; the math box restarts Clojure, still onprod./api/v3/math/pca2for an active conversation returns anETagstarting"python-(was"prod-) with groups and base clusters present; Delphi reports find their math rows;max(math_tick)underprodkeeps advancing.Clients refetch after the flip without further work: pca2's
"<math_env>-<math_tick>"ETag (already on edge) is compared as an opaque value, so a browser holding aprod-tag gets a 200 with thepythonbody, even at an equal tick.Rollback: set
MATH_ENV=prodin the secret and redeploy. No hook or compose edit.Changes
docker-compose.yml:mathreadsMATH_ENV_CLOJURE; comments ondelphiandmath-pythonname the label each reads or writes.docker-compose.dev.yml: dev fallback described above.example.env,math/example.env,docs/configuration.md: documentMATH_ENV_CLOJURE("the label the legacy Clojure engine writes; keep prod").scripts/after_install.sh: comments only. No role starts or stops anything new.delphi/docs/CUTOVER_RUNBOOK.md: "Step 2 as built" (flip, verification, ETag rule, rollback).delphi/tests/test_compose_math_env.py: Clojure writesprodunder anyMATH_ENV(unset,prod,python, a probe value, emptyMATH_ENV_CLOJURE); its label comes only fromMATH_ENV_CLOJURE; the switch and rollback move only Delphi; the two writers never share a label. The production-stack agreement test is now scoped to the test stack, where reader and writer still shareMATH_ENV. Four of the new cases fail on the previous compose file.What was dropped from #2895 and why
This replaces the draft #2895 (based on an older edge). Nothing from it is cherry-picked.
isSynthesizedPca, tests): already on edge (75be08a35,7d452d41c).git diff origin/edge origin/pr-s2-math-python-flip -- server/shows only edge being ahead, so no server hunk is needed to readpythonrows.after_install.shmath role starting nothing / starting Clojure only underprodwith a retirement check, and the fail-closed unknown role: dropped. Clojure keeps running through the rollback window; with its label decoupled there is nothing to gate.math/bin/runlabel guard and its shell test, and thepython-ci.ymlcopy step: dropped with the above; the compose decoupling removes the case it guarded against.Tests
delphi:pytest tests/test_compose_math_env.py tests/test_before_install_hook.py: 37 passed.server:jest __tests__/unit/pcaMathTickZeroHttp.test.ts __tests__/unit/pcaMathTickZero.test.ts: 50 passed (no server change; run to confirm the label-prefixed ETag on this base).docker compose configresolvesmath/delphi/math-pythontoprod/prod/pythonwithMATH_ENVunset orprod, and toprod/python/pythonwithMATH_ENV=python; with the dev overlay andMATH_ENV=dev, Clojure and Delphi both resolve todev.No schema change.
🤖 Generated with Claude Code
https://claude.ai/code/session_018NVGBuYCk4EZmiz4csUv9s