Skip to content

delphi: a Delphi run can store its topic map with its own results, switched off (migration 000049) - #3465

Merged
colinmegill merged 3 commits into
edgefrom
topic-map/stored-document-publication
Nov 23, 2026
Merged

colinmegill merged 3 commits into
edgefrom
topic-map/stored-document-publication

Conversation

@colinmegill

Copy link
Copy Markdown
Member

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. One INSERT into delphi_result_catalog: the family Delphi_TopicMapDocument, keyed (conversation_id S, part S). 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; 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: the polis-topic-map/1 document, 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 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 as Topic <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_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 is kept on the box.

Provenance. The document gains an optional provenance object, 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 DIR reads 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_map reason 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-run writes 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

colinmegill and others added 3 commits November 22, 2026 15:33
…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>
@github-actions

Copy link
Copy Markdown
Contributor

Delphi Coverage Report

File Stmts Miss Cover
polismath/init.py 2 0 100%
polismath/benchmarks/bench_pca.py 128 107 16%
polismath/benchmarks/bench_repness.py 81 65 20%
polismath/benchmarks/bench_update_votes.py 38 28 26%
polismath/benchmarks/benchmark_utils.py 34 0 100%
polismath/components/init.py 1 0 100%
polismath/components/config.py 165 70 58%
polismath/conversation/init.py 2 0 100%
polismath/conversation/conversation.py 1293 264 80%
polismath/conversation/group_vote_counts.py 38 2 95%
polismath/conversation/manager.py 131 42 68%
polismath/database/init.py 1 0 100%
polismath/database/dynamodb.py 392 176 55%
polismath/database/postgres.py 414 95 77%
polismath/delphi_storage/init.py 1 0 100%
polismath/delphi_storage/codec.py 300 22 93%
polismath/delphi_storage/embedding_spool.py 58 6 90%
polismath/delphi_storage/golden_corpus.py 60 9 85%
polismath/delphi_storage/import_report.py 51 3 94%
polismath/delphi_storage/legacy_import.py 171 16 91%
polismath/delphi_storage/postgres.py 51 22 57%
polismath/delphi_storage/production_import.py 614 131 79%
polismath/delphi_storage/resource.py 179 32 82%
polismath/delphi_storage/scan_pacing.py 77 0 100%
polismath/delphi_storage/topic_map.py 128 7 95%
polismath/delphi_storage/writer.py 200 13 94%
polismath/embedding_model.py 197 49 75%
polismath/empty_output.py 29 2 93%
polismath/engine_adapter.py 317 265 16%
polismath/job_child/init.py 372 52 86%
polismath/job_child/census.py 74 9 88%
polismath/job_child/input_bundle.py 106 7 93%
polismath/pca_kmeans_rep/init.py 5 0 100%
polismath/pca_kmeans_rep/clusters.py 257 38 85%
polismath/pca_kmeans_rep/corr.py 98 17 83%
polismath/pca_kmeans_rep/group_k_smoother.py 28 0 100%
polismath/pca_kmeans_rep/legacy_kmeans.py 197 7 96%
polismath/pca_kmeans_rep/pca.py 162 19 88%
polismath/pca_kmeans_rep/repness.py 226 5 98%
polismath/poller/init.py 4 0 100%
polismath/poller/admission.py 318 15 95%
polismath/poller/backfill.py 936 32 97%
polismath/poller/capacity.py 485 27 94%
polismath/poller/capacity_queue.py 248 13 95%
polismath/poller/coordinator_bridge.py 317 317 0%
polismath/poller/math_writer.py 120 3 98%
polismath/poller/promotion.py 112 4 96%
polismath/poller/readiness.py 368 13 96%
polismath/poller/rebuild_child.py 133 5 96%
polismath/poller/recompute_line.py 141 9 94%
polismath/poller/service.py 760 50 93%
polismath/poller/worker_pool.py 143 0 100%
polismath/queue/executor.py 221 111 50%
polismath/regression/init.py 4 0 100%
polismath/regression/clojure_comparer.py 188 20 89%
polismath/regression/comparer.py 891 640 28%
polismath/regression/datasets.py 126 27 79%
polismath/regression/recorder.py 36 27 25%
polismath/regression/utils.py 130 85 35%
polismath/replay/init.py 2 0 100%
polismath/replay/attribution_capture.py 49 0 100%
polismath/replay/axis_continuity.py 347 24 93%
polismath/replay/certify.py 999 59 94%
polismath/replay/crosslang.py 128 2 98%
polismath/replay/decision_ties.py 51 8 84%
polismath/replay/diagnostics.py 50 7 86%
polismath/replay/driver.py 73 1 99%
polismath/replay/dsn_admission.py 36 1 97%
polismath/replay/equiv_query.py 10 0 100%
polismath/replay/event_ingress.py 95 1 99%
polismath/replay/fixture_bundle.py 815 62 92%
polismath/replay/fixture_config.py 266 11 96%
polismath/replay/fixture_extract.py 285 12 96%
polismath/replay/fixture_generate.py 103 1 99%
polismath/replay/fixture_samples.py 157 14 91%
polismath/replay/fixture_selection.py 119 0 100%
polismath/replay/fixture_survey.py 147 11 93%
polismath/replay/legacy_pca.py 29 17 41%
polismath/replay/polarity.py 319 25 92%
polismath/replay/poller_equiv.py 776 99 87%
polismath/replay/prodclone.py 193 2 99%
polismath/replay/real_data.py 146 10 93%
polismath/replay/schedule.py 205 10 95%
polismath/replay/served_math.py 159 4 97%
polismath/replay/shard_bench.py 189 65 66%
polismath/replay/stagecompare.py 890 161 82%
polismath/replay/stages.py 256 40 84%
polismath/replay/stepcompare.py 86 1 99%
polismath/replay/store.py 120 11 91%
polismath/replay/tie_capture.py 107 19 82%
polismath/replay/types.py 58 6 90%
polismath/run_math_pipeline.py 284 93 67%
polismath/selection.py 58 0 100%
polismath/step_log.py 127 15 88%
polismath/tools/engine_rebuild.py 230 11 95%
polismath/types.py 6 0 100%
polismath/utils/cli_flags.py 15 0 100%
polismath/utils/clj_hash.py 44 0 100%
polismath/utils/env_flags.py 13 0 100%
polismath/utils/general.py 63 39 38%
polismath/utils/output_profile.py 66 2 97%
polismath/utils/serialization.py 10 5 50%
polismath/utils/vote_convention.py 159 5 97%
umap_narrative/700_datamapplot_for_layer.py 514 470 9%
umap_narrative/701_static_datamapplot_for_layer.py 310 310 0%
umap_narrative/702_consensus_divisive_datamapplot.py 435 275 37%
umap_narrative/801_narrative_report_batch.py 657 209 68%
umap_narrative/803_check_batch_status.py 268 148 45%
umap_narrative/llm_factory_constructor/init.py 2 0 100%
umap_narrative/llm_factory_constructor/model_provider.py 232 106 54%
umap_narrative/narrative_data.py 178 55 69%
umap_narrative/numerical_stages.py 111 21 81%
umap_narrative/polismath_commentgraph/init.py 1 0 100%
umap_narrative/polismath_commentgraph/cli.py 268 268 0%
umap_narrative/polismath_commentgraph/core/init.py 3 3 0%
umap_narrative/polismath_commentgraph/core/clustering.py 108 108 0%
umap_narrative/polismath_commentgraph/core/embedding.py 104 104 0%
umap_narrative/polismath_commentgraph/lambda_handler.py 219 219 0%
umap_narrative/polismath_commentgraph/schemas/init.py 2 0 100%
umap_narrative/polismath_commentgraph/schemas/dynamo_models.py 80 6 92%
umap_narrative/polismath_commentgraph/tests/conftest.py 17 17 0%
umap_narrative/polismath_commentgraph/tests/test_clustering.py 74 74 0%
umap_narrative/polismath_commentgraph/tests/test_embedding.py 55 55 0%
umap_narrative/polismath_commentgraph/tests/test_storage.py 87 87 0%
umap_narrative/polismath_commentgraph/utils/init.py 9 7 22%
umap_narrative/polismath_commentgraph/utils/converter.py 283 50 82%
umap_narrative/polismath_commentgraph/utils/group_data.py 332 279 16%
umap_narrative/polismath_commentgraph/utils/storage.py 616 486 21%
umap_narrative/reset_conversation.py 162 53 67%
umap_narrative/run_pipeline.py 474 171 64%
umap_narrative/topic_naming.py 159 9 94%
Total 26459 7422 72%

@colinmegill colinmegill changed the title SCHEMA CHANGE (draft, not for merge without a ruling): a Delphi run can store its topic map with its own results, switched off (migration 000049) delphi: a Delphi run can store its topic map with its own results, switched off (migration 000049) Nov 23, 2026
@colinmegill
colinmegill marked this pull request as ready for review November 23, 2026 21:38
@colinmegill
colinmegill merged commit 508de88 into edge Nov 23, 2026
65 checks passed
@colinmegill
colinmegill deleted the topic-map/stored-document-publication branch November 23, 2026 21:38
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