Skip to content

feat(delphi): Python math poller service (phase 1) — Clojure math-container replacement#2625

Draft
jucor wants to merge 1 commit into
spr/edge/6324b652from
spr/edge/18c7048f
Draft

feat(delphi): Python math poller service (phase 1) — Clojure math-container replacement#2625
jucor wants to merge 1 commit into
spr/edge/6324b652from
spr/edge/18c7048f

Conversation

@jucor

@jucor jucor commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

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).

  • polismath/poller/service.py: MathPollerService — vote + moderation watermark
    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).
  • polismath/poller/worker_pool.py: per-zid FIFO + single-owner flag (strict
    serialization), take-all!/split-batches coalescing (votes before moderation),
    bounded cross-zid ThreadPoolExecutor.
  • polismath/poller/math_writer.py: one math_tick per cycle shared across
    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).
  • scripts/math_poller.py CLI (--once / run-forever, SIGTERM/SIGINT) +
    docker-compose service delphi-math-poller (profile delphi-math, shadow
    MATH_ENV by default) + example.env documentation.
  • tests/poller/: 44 unit tests (watermark, coalescing, serialization
    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:


⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.

@jucor
jucor marked this pull request as draft July 18, 2026 02:43
@jucor
jucor force-pushed the spr/edge/6324b652 branch from b962042 to bb3b05d Compare July 18, 2026 13:28
@jucor
jucor force-pushed the spr/edge/18c7048f branch from 73b4cb9 to 4a152dd Compare July 18, 2026 13:28
@jucor
jucor force-pushed the spr/edge/6324b652 branch from bb3b05d to 9b25900 Compare July 18, 2026 13:32
@jucor
jucor force-pushed the spr/edge/18c7048f branch from 4a152dd to 4576fbb Compare July 18, 2026 13:32
…tainer replacement

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).

- polismath/poller/service.py: MathPollerService — vote + moderation watermark
  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).
- polismath/poller/worker_pool.py: per-zid FIFO + single-owner flag (strict
  serialization), take-all!/split-batches coalescing (votes before moderation),
  bounded cross-zid ThreadPoolExecutor.
- polismath/poller/math_writer.py: one math_tick per cycle shared across
  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).
- scripts/math_poller.py CLI (--once / run-forever, SIGTERM/SIGINT) +
  docker-compose service delphi-math-poller (profile delphi-math, shadow
  MATH_ENV by default) + example.env documentation.
- tests/poller/: 44 unit tests (watermark, coalescing, serialization
  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
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