Repository navigation
comment scores: the program in the Delphi image, its Compose service and its start on the Delphi box (off) - #3614
Merged
Merged
Conversation
…ntil one line is set docker-compose.yml gains math-worker: polis-jobs as worker class math_compute (PCA, k-means and representativeness, each its own job) with a login, queue env and conversation list of its own, a read-only root, no volume, 1 CPU and 2 GiB, restarted at most ten times, behind its own profile. The deploy hook starts it on the Delphi box only, on the exact line POLIS_JOBS_MATH_WORKER=1, after reading its composed settings back and naming what is wrong without a value. Ten seconds later it says in the deploy log whether the worker is up and logged in. Nothing about it fails a deploy, and every Delphi deploy with the line off removes its container. make start starts it when the env file has the switch at 1; the development overlay gives it the Postgres container's network. Nothing serves its results. math-python, its lock and its settings are unchanged. No schema change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… with Python's document, one log line (off with the worker) Right after a representativeness job's finishing transaction has committed as succeeded, the math worker reads the update's three results, its capture and its chains' last facts in one bounded read-only transaction, releases, compares them with the Python engine's own document, and logs one JSON line (math_shadow_observation): agrees, differs_in_window, differs or not_compared. Discrete values are compared exactly (clusters as sets of participants, never by id), floats within the tolerance of the replay step comparer (1e-6 + 0.01 of the Python value), centres through the crate's one axis function. A difference is expected only when a named reason read from Postgres covers the field or one it is computed from; the table is in src/math/compare.rs. Whatever goes wrong in the comparison becomes a line and never reaches the job, its chain or the loop. The line carries no participant, comment, vote, coordinate or conversation. No schema change, nothing served, no new switch, and no stored byte changes: the steps' code identity covers neither new file. The recorder gains --documents (the engine's whole captured document per update, representativeness and consensus included) and five recordings made with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vice it does not know - The Delphi role's removal of the services it does not name falls back, only when Compose's own removal fails, to removing those services' containers of this project by their labels, stopped first. Compose refuses the whole list for one name its file does not have, so a rollback to this release from a later one would have failed after it had taken Delphi down. A container that still cannot be removed fails the deploy, as before. - math-worker restarts unless stopped, like the box's other daemons: it comes back after a restart of the box or of Docker, and a refused setting is tried again about once a minute. The deploy log's line for a worker that is not up says so. - make names the math-worker profile from the last POLIS_JOBS_MATH_WORKER line in the env file, the one Compose uses. - Docs: not together with the queue worker boxes, whose daemon refuses two of the settings; a password of letters and digits only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… tested A reason in the line now excuses only what it can cause, for as long as it can cause it. - A chain's first update that equals Python's is agrees_at_seed, not agrees: the chain had just started from Python's document of that same update. - Each line has judged (1 or 0) and first_chain, the root job of the conversation's oldest PCA chain, which stays the same when a chain is seeded again. One log query over them shows the conversations that were never judged. The lookup is one step down math_job_results_newest; a test holds the plan at 10,000 chains. - An update passed over excuses the in-conversation set only when the chain began with fewer than 7 comments or 15 participants in conversation. - What only the k-means chain did excuses no PCA component and no order. Older start vectors excuse no order either. - Another column order excuses a representativeness difference only among comments of exactly equal rank, and a consensus tie needs the same comments with the same counts. - The PCA's centre and the representativeness and consensus statistics are held to 1e-6 + 0.0001 * |python|, as the retirement's stage comparer held them. - A float field with nothing to compare is null, not equal. New database tests: updates arriving in bursts, an update passed over in a conversation that is not small, and a finish whose COMMIT went unanswered. No schema change, and no stored byte changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… on the math worker's loop (off) The math worker's loop takes what it runs as a Program: its steps, its admission pass and what it does after a committed success. polis-jobs runs the same three steps and admission as before through it. polis-routing-jobs (polis-math-routing) runs that loop with the routing step: it reads the admission manifest, the stored capture and the chain's previous result by their digests, builds the plan from the capture alone and stores its stored form with a run record naming every input. One attempt per job; a failure stops the chain with its reason. Off unless POLIS_JOBS_ROUTING_WORKER=1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ld when new scores are stored (off) A routing weights job that ended because it was lost (its process died, its lease ended, the database went away) is due once more for the same update under the same build, the chain's first job included; a new build does a lost first job again too. An input the step refused waits for the next update, as before. The due query reads which it was from two stored facts, the queue's state of the job and the chain's last_failure_reason, and the repeat is bounded by the new job's source id, which names the builds that did it again. After a job has committed as succeeded, an uncertain commit that turns out to have happened included, the program sends one NOTIFY on the draw crate's channel with its notice type, as a transaction of its own. A refused notice or a lost connection is one log line and changes nothing about the job. Tests added for what the review of the previous change found untested: the result names the running build, and nothing runs after a lease the heartbeat found lost. The README says why two builds must not run side by side and how to deploy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The one conflict is a paragraph of queue-rs/README.md: both sides are kept (the routing weights job's own program, and the Compose service that runs this binary). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t on the Delphi box, off until one line is set polis-routing-jobs is built into the Delphi image by a cargo command of its own, so the four programs already there are byte for byte what they were. scores-worker runs it with the math worker's hardening, login and queue env and its own switch, list, rule and memory ceiling. The deploy hook reads its settings back, starts it and says whether it is up, as it does for the math worker: the start is now one function for the two, and each read-back lets the other worker, and no third service, have its login and queue env. The participation load test's series can run a second program through its loaded windows; the scores crate's test runs the real program there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ild, and the shared login's connection limit is 20 A routing weights job whose process died is done again once by the same build. When that repeat was refused, its chain had no result to name the build that made it, so a later release that mends the refusal waited for the next vote. The repeat's source id already names the builds that did it; the due rule now reads it there. A build named in it never does it again, so each build still does it at most once, eight builds at most. Docs: the login the two workers share is created with CONNECTION LIMIT 20 (room for two Delphi boxes); what a rule written in unescaped double quotes does to every deploy; one Delphi box in service before the turn-on. The loaded test says that its resident size and connections are samples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Edge carries this branch's first parts (the math worker's service and the comparison with Python) as squashed merges with the same content; merged from that state, with no conflict. The web side's draw comes in from edge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
This branch contains two drafts that are not on edge yet: PR #3613 (the comment scores program) and PR #3607 (the math worker's Compose service), joined by a merge commit. Until both are on edge this page shows their changes too. What is new here is the last two commits,
git diff 964695764..7432fcdf9.What a person would observe
Nothing. No page, route, number or label changes, and the next comment is chosen as before. With none of the new settings present, every box starts and replaces exactly the services it does today, and
make startruns the same command.When an operator later sets one line, the Delphi box also runs a program that stores comment scores nothing reads, and the deploy log says whether it is up.
What changed
polis-routing-jobsbesidepolis-jobs, built in the same stage by a cargo command of its own. In one command with the others, cargo would compile their shared dependencies with this crate's features as well, and all four existing programs came out different; built apart, they are compiled by the same command as before, with the same features.docker-compose.yml, the servicescores-worker: the math worker's hardening, restart rule, CPU weight and OOM score; 1 CPU and 512 MiB (measured on a document of 10,000 comments: 0.25 s a job, a peak of 179 MB).POLIS_JOBS_ROUTING_WORKER,POLIS_JOBS_ROUTING_CONVERSATIONS,POLIS_JOBS_ROUTING_RULESandPOLIS_JOBS_ROUTING_EVERY_UPDATES(default 1).POLIS_MATH_QUEUE_DATABASE_URL), the queue env (POLIS_MATH_QUEUE_ENV), the TLS settings and the label's source. Either service runs without the other.scripts/after_install.sh: selection on the Delphi role and the exact line, the release's image, the read-back of the composed settings, the start and the look ten seconds later, as for the math worker.queue-rs/polis-math-routing/src/due.rs). A job whose process died is done again once by the same build. When that repeat was refused, its chain had no result to name the build, so a release that mends the refusal waited for the next vote. The repeat's source id already names the builds that did it, and the due rule now reads it there. It cannot loop: a build named there never does it again, and at most eight are named. A refused first job of a conversation that has no result yet still waits for the next vote, as before.Makefile,docker-compose.dev.yml,example.env,docs/configuration.md("Comment Scores Worker"), the crate's README: as for the math worker.polis-math-routing/tests/participation_load.rsincludes that file and runs the real program there at its cap, its notices counted. The memory and the connections it prints are samples taken about once a second, so they can miss a peak. Ignored by default.Schema
None. No migration, grant, role, function or index.
Participation path
Not touched. The service runs on the Delphi box, which serves no participant, on connections of its own (at most five, beside the math worker's three), never a web pool. It reads no vote; its reads of
math_mainare plain SELECTs under a 2 s statement timeout. The load test runs votes and next comments against both workers at their caps on a conversation of a million votes. In one short run on a busy box (45 s windows) it passed:No vote was refused or lost. The last two rows are close to the bound; other work was running on that box (load average 25 on 14 cores), and the workers and the database share it, which in production they do not. The run before it kept every latency bound too, but counted 12 paced requests over their 50 ms period, which the test also refuses (that run failed, on a check of mine that took the program's ordinary last line for an error). The quiet series of longer windows is still to run.
Vote sign
Not touched. The new program reads no vote. The load test's votes go through the code that was there.
Identity and deploy mechanics
CONNECTION LIMIT 20. The two programs hold at most eight on one box (seven was the most in the load test's samples), and a second Delphi box, or a replaced one while the server still holds the lost box's connections, needs eight more. A deploy has no overlap, since both old containers are removed first. A connection refused at the limit is tried again at a start, but one refused during a job can end that job.polis-jobs. That daemon reads none of the new settings, and starts with all of them present (run), so the docs' warning about those boxes stays the math worker's alone.Checks (local build box)
bash scripts/test-deploy-hooks.sh(the entry point CI uses, with the realjq)docker build --target polis-jobswith the old and the new Dockerfilepolis-routing-jobsruns, and exits 0 when off. Clean builds without a cache gavepolis-jobs,polis-delphi-shadowandpolis-topic-mapin one of two forms, with the old Dockerfile as with the new onecargo fmt --all --check; clippy with-D warningsonpolis-math-routing(with and withoutjobs-integration) and on the queue packagecargo test --locked -p polis-math-routing --features jobs-integrationcargo test --locked --features jobs-integration --test math_participation_loadcargo test --locked -p polis-api --test no_rule_evaluation_crate, and itscargo treecheckdocker-compose.ymlwith the development overlays and a migrated Postgres, started by the hook's own functionmath_routing_weights; read-only root, no mount, 512 MiB, 60 s to stop. Then beside the math worker; then the math worker removed and this one still running. A bad rule and a superuser login: not up, exit 2. Two rules in one env line. A stop: exit 0docker compose configwith a production-shaped env file through bothjqprogramsmake -n startwith the switch 0 and 1make check-nginx-upstreams,make check-vote-sign-lintNot run, or not in full:
Turning it on
Until it is on, it is not done.
docs/configuration.md, Math Worker, "Its login"), withCONNECTION LIMIT 20; nothing more is granted to it. Exactly one Delphi box is in service.POLIS_JOBS_ROUTING_WORKER=1,POLIS_JOBS_ROUTING_CONVERSATIONS(numeric ids, comma-separated) andPOLIS_JOBS_ROUTING_RULES={"rule":"stored-weights/1","params":{},"terms":[]}, andPOLIS_MATH_QUEUE_DATABASE_URL(a secret) if the math worker has not put it there.The comment scores worker is up 10 seconds after its start, logged in to its database;polis_jobs math admitted routing_weights job ...and thenpolis_jobs math job ... notice sentfor the same job;math_routing_weightsholds an active row for each listed conversation, at the number ofmath-python's newest update or just behind it.Nothing deletes old results yet, so a busy conversation waits for that, or is listed with a larger
POLIS_JOBS_ROUTING_EVERY_UPDATES.To turn it off, remove the line and deploy. The results stay stored.
🤖 Generated with Claude Code