Repository navigation
delphi: a Delphi run can store its topic map with its own results, switched off (migration 000049) - #3465
Merged
Conversation
…an store its topic map with its own results, switched off (migration 000049) What a person observes: nothing. The step is off unless the Delphi job daemon sets DELPHI_TOPIC_MAP_DOCUMENT=1; with it absent every run, stored row and log line is what it was, and every topic label a page shows is unchanged. Migration 000049 is data-only: one INSERT of the result family Delphi_TopicMapDocument, keyed (conversation_id S, part S), into delphi_result_catalog. No table, column, index, constraint, function, trigger or grant changes. The INSERT takes ROW EXCLUSIVE on delphi_result_catalog until commit (milliseconds), which conflicts with no lock any reader or writer of that table takes; nothing on the vote, comment or next-comment path reads it. lock_timeout is 200 ms. Declared additive in compat.txt and docs/migrations.md, listed in release.txt, in the forward proof's additive set, the first-deploy report (regenerated) and the coordinator's schema census. Reversal: down/000049 refuses while any batch holds the family. With the setting on, a full pipeline run ends by handing the codec files of the three families it has just written (UMAP positions, clusters at every layer, topic names) to polis-topic-map store, now built into the Delphi image, and writes the family it returns into the same attempt scratch, so the daemon stores it in the run's own result batch: the map publishes with the run or not at all. A map is three rows: the polis-topic-map/1 document without comment text, its gzip and its SHA-256. A run with nothing to draw, or whose document would be a row over 1 MiB, stores one no_map row with the reason. Beside either, an execution row holds the run's own record of its steps. Every row names the run's job id. Nothing calls a model; nothing is kept on the box. - The run's own record of its steps (delphi-run-execution/1). With the step on, polismath.step_log keeps in memory one entry per step that ends (status, seconds and the step's facts) and per note: UMAP's parameters read back from UMAP itself, the clustering (EVoC or its KMeans fallback, seed, min_samples), the keyword vectorizer, and per layer the topic naming's provider and model and how many names a model wrote and how many are fallbacks. Who wrote each name is decided by the naming where it makes the name (a model's cleaned response, or a fallback after a missing or empty response, or a keyword label), never read from the name's shape; the labels returned are unchanged. The record also holds the comment selection and its counts, and what the run cannot know: its code version and image are in the run record and the deploy. The document's optional provenance (serialized last; absent, documents are byte for byte as before) names the env, job, run and batch, the publication scope and comment rule, the models, the three input families by SHA-256 and row count, the execution record, and how the topic names were taken. - No comment text in names (rule polis-topic-map.names/2). The stored map keeps generic names (Topic <n>, with or without its layer_cluster prefix) and keyword fallback labels whose every keyword has the vectorizer's shape, as their keywords only, never the example comment the fallback appends. Every other name, a model's free-form name among them, is shown as Topic <n>, because nothing checks a model's name to be free of a comment's words. The step and the backfill share the rule. - polis-topic-map from-run --env --job --out reads a stored run (its record and its three families, one read-only snapshot, the daemon's queue login and transport rules) and writes the same family file and the document to a directory; it never writes to the database, and says whether a stored map equals the one it made. A run stored before the step says it has no execution record instead of guessing one. - The family is Postgres-only: it is not in the storage codec's DynamoDB catalogue (FAMILIES, its golden files and the server's mirror are as before) but in a separate table of Postgres-only result families encoded by the same rules. The writer holds and spools it only when written: a run's reset neither clears nor emits it, and a map in an earlier batch is never copied into a later run's scratch. - docs: the setting, and the rollback floor. Once a run has stored a map, an older Delphi image refuses that conversation's next run in that scope and an older API refuses that run's record; turning the setting off does not undo it. Tests: the stored rows, gzip, digest, provenance, the no_map reasons, the row limit and refusals on the two public fixtures; the name rule's kept and replaced shapes, including cut labels and a prefixed example; each name's origin after a missing response, a response that cleans to nothing, a partly failed batch and the keyword fallback; the step command's bytes; a PostgreSQL 17 test in which runs admitted, claimed and finalized through the release's functions store maps under two comment rules in their own batches and scopes, and from-run writes the step's bytes for each, and for a run stored with the step off; the recorder off and on; the Python step on a real attempt writer, off and on; the family's key against its catalog row; the Compose default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ails the run (setting off: no change) With DELPHI_TOPIC_MAP_DOCUMENT off (the default) nothing a person sees changes: every run, stored row and log line is what it was. With it on: - A topic name the naming recorded as written by the model is stored in the map as the model wrote it. The stored-name rule is now polis-topic-map.names/3, and the provenance counts these names as written_by_model. The origin reaches the generator through the run's execution record: each layer's topic_names entry now lists the clusters whose names the model wrote (model_clusters, ids only). A name of a fallback or of no recorded origin (a run stored before the step) is taken as before: generic names and the keyword fallback's keywords are kept, everything else is shown as "Topic <n>". A name's shape or prefix is never read as its origin. - When the generator fails (not installed, did not run, timed out, refused the run's families, or wrote something else), the run no longer fails. Its other results publish, an error is logged, and the map's family holds one no_map row with reason generator_failed and a closed failure label; the generator's message is never stored. A writer that cannot hold the map (another conversation's frame, no result scope) still fails the run. Nothing new runs with the setting off: the note is made only while the run records its steps. No handler, pool, lock or migration is added; the change runs inside the existing Delphi child, keeps nothing on the box (the failure is a row with the run's results and a log line), calls no model and reads or writes no vote. Tests: a Rust test that recorded model names are kept and unrecorded ones are not; Python tests for each failure label, for the one row and the other families publishing, and for names kept from the recorded origin; a naming test for the origin facts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…se diagnostics are not UTF-8, no longer fails the run (setting off: no change)
With DELPHI_TOPIC_MAP_DOCUMENT unset (the default) nothing changes.
With it on, two generator faults that still escaped the failed-draw handling
now end the same way as every other failed draw: the run's other results
publish, the map's family holds one no_map row with reason generator_failed,
and one error line is logged.
- Diagnostics that are not valid UTF-8: the generator's output is captured as
bytes and its stderr is decoded with replacement for the log only, so a
stray byte is a refusal ("refused"), never a decode error that fails the run.
- A family the codec reads but that is not a whole map (a map without its
document or gzip row or byte counts, a no_map row without a reason): the
parts and attributes the step reports are now read inside the failed-draw
handling, before anything is stored, and such a family is "wrong_output".
An incomplete family is never put.
Writer faults (another conversation's frame, no result scope) still fail the
run, as before. No row holds stderr or comment text. Tests: the failed-draw
test gains a generator that writes invalid bytes to stdout and stderr, and two
that write a canonical but incomplete family.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Delphi Coverage Report
|
colinmegill
marked this pull request as ready for review
November 23, 2026 21:38
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.
What a person observes: nothing. The step is off unless the Delphi job daemon sets
DELPHI_TOPIC_MAP_DOCUMENT=1; with it absent every run, stored row and log line is what it was, and every topic label a page shows is unchanged. No page reads the new family yet.Schema: one data-only migration,
000049_add_topic_map_document_family.sql. OneINSERTintodelphi_result_catalog: the familyDelphi_TopicMapDocument, keyed (conversation_idS,partS). No table, column, index, constraint, function, trigger or grant changes. TheINSERTtakes ROW EXCLUSIVE ondelphi_result_cataloguntil commit (milliseconds), which conflicts with no lock any reader or writer of that table takes; nothing on the vote, comment or next-comment path reads it.lock_timeoutis 200 ms. Declared additive; the reversal refuses while any batch holds the family.With the setting on, a full pipeline run ends by drawing its topic map from the three families it has just written (UMAP positions, clusters at every layer, topic names) with
polis-topic-map store, now built into the Delphi image, and stores it in the run's own result batch. A map is three rows: thepolis-topic-map/1document, its gzip and its SHA-256. A run with nothing to draw, or whose document would be a row over 1 MiB, stores oneno_maprow saying why. Every row names the run's job. Runs of one conversation under different comment rules are different jobs with their own batches and publication scopes, so their maps never replace or mix with each other.Topic names. A name the naming step recorded as written by a model is stored as the model wrote it (rule
polis-topic-map.names/3; the origin is decided where the name is made and travels in the run's execution record, never read from a name's shape or prefix). A name of a fallback or of no recorded origin is taken by the earlier shape rule: generic names and the keyword fallback's keywords are kept, everything else is shown asTopic <n>. The document carries no per-comment text.A failed draw never fails the run. When the generator is not installed, does not run, times out, refuses the run's families, writes something that is not a whole map, or emits diagnostics that are not UTF-8, the run's other results publish, one error is logged, and the map's family holds one
no_maprow with reasongenerator_failedand a closed failure label; the generator's message is never stored. A writer that cannot hold the map (another conversation's frame, no result scope) still fails the run. Nothing is kept on the box.Provenance. The document gains an optional
provenanceobject, serialized last (documents without it are byte for byte as before): the run, its publication scope and comment rule, its models as its output manifest names them, the three families it was drawn from by SHA-256 and row count, and the name counts.Runs stored before the step:
polis-topic-map from-run --env ENV --job ID --out DIRreads a stored run in one read-only snapshot and writes the same family file and the document to a directory. It never writes to the database.Tests: the stored rows, gzip, digest and provenance on two public fixtures; every
no_mapreason and every failure label, with the other families still publishing; names kept from the recorded origin and not from shape; PostgreSQL 17 with the release migrations (runs admitted, claimed and finalized through the release's own functions store their maps;from-runwrites the step's bytes; two comment rules in their own batches and scopes); the Python step on a real attempt writer, off and on; the Compose default; the contracts' catalog test.🤖 Generated with Claude Code