feat(delphi): Python math poller service (phase 1) — Clojure math-container replacement - #2625
Draft
jucor wants to merge 1 commit into
Draft
feat(delphi): Python math poller service (phase 1) — Clojure math-container replacement#2625jucor wants to merge 1 commit into
jucor wants to merge 1 commit into
Conversation
This was referenced Jul 18, 2026
docs(delphi): R1-parity goal docs, journal (2026-07-18 → 07-24 s5), quirks + divergence ledger
#2626
Draft
jucor
marked this pull request as draft
July 18, 2026 02:43
This was referenced Jul 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a new Python-based “math poller” service under polismath.poller to replace the production responsibilities of the legacy Clojure math container (phase 1), including Postgres polling (votes + moderation), per-zid serialized processing, and writing math outputs back to Postgres under a configurable math_env (shadow-mode by default).
Changes:
- Add
MathPollerService(dual watermark poll loops + per-zid compute pipeline + error dump/retry/park) and a per-zid serializedConversationWorkerPoolwith batch coalescing. - Add
MathWriterorchestration formath_main,math_bidtopid, andmath_ptptstatsusing a sharedmath_tickper cycle and Clojure-parity SQL inPostgresClient. - Add CLI entrypoint, docker-compose profile wiring, and a comprehensive unit + opt-in integration test suite.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| example.env | Documents configuration knobs for running the new poller, including shadow-mode defaults. |
| docker-compose.yml | Adds a profile-gated delphi-math-poller service that runs the poller CLI with shadow MATH_ENV. |
| delphi/pyproject.toml | Registers a new integration pytest marker for Postgres-backed tests. |
| delphi/scripts/math_poller.py | CLI wrapper to run the poller once or continuously with signal-based shutdown. |
| delphi/polismath/poller/init.py | Package-level architecture + contract documentation and public exports. |
| delphi/polismath/poller/service.py | Core poller service: watermark loops, dispatch, load-or-init, recompute/write, and error handling. |
| delphi/polismath/poller/worker_pool.py | Per-zid serialized worker pool with batch coalescing and bounded cross-zid concurrency. |
| delphi/polismath/poller/math_writer.py | Derives bidToPid/ptptstats envelopes and writes all tables with one shared math_tick. |
| delphi/tests/poller/init.py | Declares the new poller test package. |
| delphi/tests/poller/test_watermark.py | Unit tests for watermark advancement and allow/block filtering invariants. |
| delphi/tests/poller/test_service.py | Tests service dispatch behavior, watermark advancement, env engine-mode passthrough, and LRU eviction. |
| delphi/tests/poller/test_serialization.py | Thread-safety tests for per-zid serialization, cross-zid concurrency, and parking behavior. |
| delphi/tests/poller/test_coalescing.py | Tests batch coalescing rules (votes before moderation, arrival-order flattening). |
| delphi/tests/poller/test_math_writer.py | Tests bidToPid derivation, shared math_tick behavior, and SQL shape via a recorder client. |
| delphi/tests/poller/test_load_or_init.py | Tests from_dict restoration limits and the required full-history rebuild behavior. |
| delphi/tests/poller/test_error_path.py | Tests dump→retry→park circuit breaker behavior and “self-heal on new batch”. |
| delphi/tests/poller/test_integration_postgres.py | Opt-in end-to-end integration test that provisions Postgres, seeds data, runs poll→compute→write, and verifies restart-resume semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jucor
force-pushed
the
spr/edge/6324b652
branch
2 times, most recently
from
July 21, 2026 19:49
1791ca3 to
d05e53d
Compare
This was referenced Jul 24, 2026
Draft
Draft
Draft
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.
The poller half of MATH_POLLER_DESIGN.md phase 1: a Python service that
replaces the Clojure math container's production duties (vote/mod watermark
polling, per-zid serialized compute, four-table Postgres writes).
loops mirroring poller.clj:12-37 (strict >, max-of-batch advancement,
POLL_FROM_DAYS_AGO=10 boot window, allowlist/blocklist), per-zid engine chain
update_votes -> update_moderation -> recompute() with load-or-init from
math_main + full-history rebuild (conv_man.clj:188-207 analog), error path
dump -> one retry -> park (errorconv analog).
serialization), take-all!/split-batches coalescing (votes before moderation),
bounded cross-zid ThreadPoolExecutor.
math_main / math_bidtopid / math_ptptstats (conv_man.clj:158-169);
bidToPid positionally aligned with base-clusters.id ascending
(prep-bidToPid conv_man.clj:35-40; server participants.ts:33-51).
docker-compose service delphi-math-poller (profile delphi-math, shadow
MATH_ENV by default) + example.env documentation.
thread-safety, writer SQL incl. caching_tick MAX+1 subquery + shared tick,
bidToPid shape, allow/block, engine-mode passthrough, error path,
load-or-init restoration boundary) + 1 opt-in integration test (throwaway
postgres:17 on port 5435): end-to-end poll->compute->write, shadow math_env
isolation, shared math_tick, caching_tick=1 on first write, restart-resumes.
Cutover phasing per MATH_POLLER_DESIGN.md: this ships SHADOW mode only —
writes under a math_env the server does not read. The flip is gated on the
blob-shape alignment work (to_dict vs prep-main deltas catalogued by the H-B
cross-language comparison).
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
commit-id:18c7048f
Stack: