Repository navigation
delphi: a run whose configuration names a namer asks a model for its topic names (no run names one yet) - #3480
Draft
colinmegill wants to merge 11 commits into
Draft
colinmegill wants to merge 11 commits into
colinmegill wants to merge 11 commits into
Conversation
…ilure an outcome (nothing calls it yet) A new crate in the queue-rs workspace. Given a Delphi run's topic hierarchy (hierarchy.json), `polis-topic-names name` asks Claude Haiku 5.5 or Claude Sonnet 5.5 to name every topic in one call, checks the reply, and writes names.json: the names, or the outcome word and reason the caller keeps its keyword names for (no_key, over_run_cap, too_large, http_<status>, timeout, connect_error, refused, truncated, bad_json, bad_cover, wrong_language, bad_length, repeated_names). At most one retry; the worst case is priced before the call and compared with the per-run cap. The request body is a measured whole-hierarchy call's body, byte for byte, plus one sentence asking for names in the comments' language; a test compares it with two saved bodies. All tests are offline, through a local HTTP stub, over the saved replies of three public conversations. Nothing in Polis runs it: no route, pipeline step, setting or stored data changes. The checks run as `make check-polis-topic-names`, which the queue-rs workflow's new job calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KvftUARCjBArGpuPBmjRZ1
…ion names one
A full pipeline run whose configuration carries `naming` with `by: model`
gets one more argument, `--namer={"model":..,"prompt":..,"thinking":..}`,
after its selection. Absent, null or `{"by": "keywords"}`, the arguments
are byte for byte what they were.
Refused before a child starts: an unknown model, prompt version or
thinking setting, any other key, a namer that is not an object, and a
namer under any comment rule but participant_visible/1 (so no comment a
moderator removed can be sent to a model). Nothing admits a run with a
namer yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KvftUARCjBArGpuPBmjRZ1
…s keyword labels With `--namer` (run_delphi.py and run_pipeline.py; only with the selection participant_visible/1), the naming step no longer uses the older per-topic provider path. It builds hierarchy.json (every non-noise topic of every layer: id, layer, size, parent, five keywords and the three comments nearest its centre; comment text and keywords only), runs `polis-topic-names name --in hierarchy.json --out names.json --namer <json>`, and on outcome `named` writes the model's names as the layer labels, recorded as written by the model, so the stored map keeps them under polis-topic-map.names/3. On any other outcome, or when the program is missing, crashes, is stopped or breaks its file contract (`namer_failed`), the keyword labels are kept, recorded as fallbacks under "keywords", with the outcome and reason in the step log. A naming failure never fails the run and nothing retries. The manifest's models.topic is the model only when it named, else "keywords"; cost.llm_tokens_in/out are the call's tokens. A run without a namer passes the same arguments and writes the same record and results as before (tests check the pipeline call, the step-log entries and the manifest). The naming's files live in a directory of the attempt, removed when the run ends. Tests run the step against a stand-in program; no test makes a model call. The Bowling Green 2050 hierarchy the step builds equals the one a naming study built from the same public layout (fixtures and their public source in tests/fixtures/topic_names/README.md). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KvftUARCjBArGpuPBmjRZ1
The image builds the topic namer in the same stage as polis-jobs and polis-topic-map and installs it at /usr/local/bin/polis-topic-names, where the naming step looks for it. Nothing runs it unless a run is given --namer, and no admission gives one. This commit needs the queue-rs/polis-topic-names crate in the workspace; it merges after that crate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KvftUARCjBArGpuPBmjRZ1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KvftUARCjBArGpuPBmjRZ1
The naming step runs the topic names program; the Delphi image builds it. This branch carries the program's crate so the two can be checked together. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KvftUARCjBArGpuPBmjRZ1
Checked addition of the reply's usage counts (an overflowing count is bad_json, not a panic), only known stop reasons kept, the cost check counts the body's UTF-8 bytes, and the vTaiwan and Mobilitaet fixture samples replaced by invented sentences. Three regression tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KvftUARCjBArGpuPBmjRZ1
…abels Creating the step's directory, writing hierarchy.json or reading names.json can fail (an occupied path, a directory where a file belongs). Each is now a naming outcome (namer_failed, scratch_unavailable) instead of an exception that fails the run. Applied as the independent review supplied it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KvftUARCjBArGpuPBmjRZ1
…g but checked names and fixed words; the cost bound counted in bytes The reply boundary. The body of an HTTP 200 reply is read to at most 4 MiB (a longer one is bad_json, unread). Usage must be an object of non-negative integer counts whose prompt total fits in a u64, else bad_json with a fixed reason; output_tokens of the wrong type is no longer read as zero. A name holding a control character or an invisible formatting character (bidirectional controls, zero-width space, byte-order mark, tag characters) is refused as wrong_language; the zero-width joiner and non-joiner stay accepted. New tests: reply_boundary (oversize, invalid UTF-8, usage types, control characters, an error body, the program's log line with a planted marker) and unit tests that run the parser over 3,000 random edits of a saved reply and 2,000 random byte strings. The cost bound. The counted input is the body's UTF-8 bytes; the README gives why that bounds the provider's input tokens in any script, its one assumption (every token stands for at least one byte), and Bowling Green's arithmetic: 70,540 bytes, $0.0231 on Haiku, $0.4611 on Sonnet. counted_input tests it on the fixtures' Chinese and German text, on ten other scripts, and against Bowling Green's recorded input tokens. The fixtures. The vTaiwan and Mobilitaet hierarchies keep no source text: their samples were already invented sentences, and their keywords, words taken from the comments, are now empty lists. Bowling Green keeps its samples for the request-body test's byte comparison. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KvftUARCjBArGpuPBmjRZ1
…scratch never outlives the run What a named run stores and what it records now agree in every case. The naming's record (outcome, namer, token counts) is sent to run_delphi.py on a pipe the pipeline is given (--naming-record-fd) before any label is written. If it cannot be sent, the model's names are not published: the keyword labels are, under a record that says namer_failed (record_unsent) and keeps the token counts of the call that was made, sent again. The only partial state is keyword labels recorded as keywords with the reason. The record no longer lives in a scratch file, so nothing the manifest needs is there. Scratch failures are naming outcomes: the step removes hierarchy.json and names.json once read, and a failure to make, write, read or remove them, or to make or remove a temporary directory, keeps the keyword labels with the reason scratch_unavailable and the call's token counts. The step makes its own directory; run_delphi.py only names it. Termination: under the job daemon the step's directory is inside the attempt directory (beside DELPHI_OUTPUT_MANIFEST) that the daemon removes once it has reaped the child group, however the child ended, SIGKILL included. A run started by hand removes it on SIGTERM as well as on exit. A run without a namer is unchanged: same arguments, same child start (run_child passes descriptors only when given some), same manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KvftUARCjBArGpuPBmjRZ1
Brings the topic names program's review fixes (reply boundary, cost bound, smaller fixtures) beside the naming step. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KvftUARCjBArGpuPBmjRZ1
Contributor
Delphi Coverage Report
|
This branch has not been deployed
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.
Delphi: a run can name its topics with a model in one call, switched off
What anyone will observe: nothing. No admission names a namer, so no run passes
--namer, and every run's arguments, step log, manifest and stored results are what they were. Tests prove it at each layer:namingin the configuration,null, or{"by": "keywords"}, the full run's arguments equal today's list exactly (Rust test inqueue-rs/src/jobs/child.rs);run_delphi.py: without--namer, the pipeline is called with today's exact argument list, and the manifest'smodelsandcostare today's (delphi/tests/test_topic_namer.py);run_pipeline.py: without a namer, the older naming path runs as before, its step-log entries have exactly today's fields, and the new program is never started (same file).No schema change, no migration, no Node change, no route, Compose or scheduler change.
What the step does when a run one day names a namer
A run given
--namer='{"model":"claude-haiku-5-5","prompt":"polis-topic-names/1","thinking":"default"}'(only with--selection=participant_visible/1):hierarchy.json: every non-noise topic of every layer with its id, layer, size, parent (the topic one layer up holding most of its non-noise comments), five keywords and the three comments nearest its centre in the 2D map;polis-topic-names name --in hierarchy.json --out names.json --namer <json>(the Rust topic namer, built into the Delphi image by the last commit), which makes the one model call and checks the reply;named, writes the model's names where the keyword labels go, recorded in the step log as written by the model (model_clusters), so the stored topic map keeps them as written underpolis-topic-map.names/3; the manifest'smodels.topicnames the model andcost.llm_tokens_in/outthe call's tokens;keywords(never under the model that was asked), with the outcome and its reason in the step log;models.topiciskeywords.A naming failure never fails the run and nothing retries. The outcomes are the program's (
no_key,over_run_cap,too_large,http_<status>,timeout,connect_error,refused,truncated,bad_json,bad_cover,repeated_names,bad_length,wrong_language) plusnamer_failedwhen the program is missing, exits non-zero, does not finish within 900 s, or writes a file that is not its contract, andnamer_failedwith reasonscratch_unavailablewhen the step's own files or directory cannot be made, written, read or removed (the token counts of a call that was made are kept).What is stored and what is recorded always agree. The order of writes: the naming's record (outcome, namer, token counts) goes to
run_delphi.pyfirst, on a pipe it hands the pipeline (--naming-record-fd), and only then are any labels written. If the record cannot be sent, the model's names are not published: the keyword labels are, under a record that saysnamer_failed(reasonrecord_unsent) with the call's token counts, sent again. So the only partial state is keyword labels recorded as keywords with the reason; the manifest'smodels.topic, itscost, the step log and the stored map's provenance all come from that one record.What would leave the network then
Only what is in
hierarchy.json, which the namer sends to the model provider: topic ids, layers, sizes, parent ids, five keywords per topic, and the text of three comments per topic. Never an author, participant, vote, time, comment id, or the conversation's name, description or code. Only the participant-visible comment rule may name a namer (refused in the job child and again in both Python entry points), so its layout holds only comments participants are shown and no comment a moderator removed is sent. Nothing in this change reads, prints or checks a key; the program reads its own.The step runs inside the Delphi run's own process tree on the Delphi box. By the time it runs, the run's input reads have closed their database connection, so no connection or transaction is held across the model call, and nothing is shared with the web boxes or the vote, comment or next-comment path. Its two files (
hierarchy.json,names.json) are removed by the step once read. Under the job daemon their directory is inside the attempt directory that the daemon removes after it has reaped the child's process group, however the child ended (exit, timeout, fence, shutdown, SIGKILL); a run started by hand removes it on exit and on SIGTERM. Nothing a later step or a later run needs is kept there: the record travels on the pipe, and what happened is recorded in the run's step log, stored map and manifest.Tests
queue-rs/src/jobs/child.rs: the namer reaches the pipeline only when named; an unknown model, prompt, thinking setting or key, a non-object, and any other comment rule start no child.delphi/tests/test_topic_namer.py(no model call; a stand-in executable plays the program):delphi/tests/fixtures/topic_names/, with their public source in its README);namer_failed;run_delphi.pyrefuses a namer under another comment rule or an unknown model and runs nothing.delphi/tests/test_topic_namer_scratch.py: an occupied directory path, a directory wherehierarchy.jsonornames.jsonbelongs, a file that cannot be removed, and a temporary directory that cannot be made each keep the keyword labels withscratch_unavailable, without failing the run; under the daemon the scratch directory is inside the attempt directory; a run terminated with SIGTERM leaves no scratch directory.delphi/tests/test_topic_namer_record.py: a record that cannot be sent publishes keyword labels under a keyword record that keeps the token counts, and the map's models and the manifest's agree; a record that is never sent never publishes the model's names; the record is read without waiting on a process that still holds the pipe.The last commit (the image) needs the
polis-topic-namescrate in the workspace and merges after it.🤖 Generated with Claude Code