Skip to content

feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B)#2646

Draft
jucor wants to merge 1 commit into
spr/edge/a85047a7from
spr/edge/9f45b733
Draft

feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B)#2646
jucor wants to merge 1 commit into
spr/edge/a85047a7from
spr/edge/9f45b733

Conversation

@jucor

@jucor jucor commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Sonnet-agent build from SPEC_B: scripts/prodclone_extract.py (click CLI:
survey + extract) over polismath/replay/prodclone.py (pure SQL builders,
feature classifiers, CSV writers, slug minting, path-safety guard).

Privacy invariants (reviewed): output path resolved + asserted under
real_data/.local/ (refuses anything else); dir prefix is a salted sha256 of
the zid, never a real report id; comment-body column present but ALWAYS
empty (text redacted — the math pipeline never reads it); slug→zid map only
in .local/prodclone_map.json (merge-update). Export mirrors the public
format byte-layout (votes: full revote history ORDER BY created, ctid — no
dedup; comments: agrees/disagrees counted over all vote rows like
report.ts).

Feature classes: modheavy / revote / banned (participants.mod=-1 voters) /
meta / zerovote / smallmix / midmix (unremarkable volume coverage).

Tests: 52 passed — pure-function units (no DB) + one integration test on
the repo's require_polis_postgres throwaway-Postgres fixture, round-tripping
survey→extract→load_export_votes. TDD (RED commit first in agent clone).

commit-id:9f45b733


Stack:


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

…Spec B)

Sonnet-agent build from SPEC_B: scripts/prodclone_extract.py (click CLI:
survey + extract) over polismath/replay/prodclone.py (pure SQL builders,
feature classifiers, CSV writers, slug minting, path-safety guard).

Privacy invariants (reviewed): output path resolved + asserted under
real_data/.local/ (refuses anything else); dir prefix is a salted sha256 of
the zid, never a real report id; comment-body column present but ALWAYS
empty (text redacted — the math pipeline never reads it); slug→zid map only
in .local/prodclone_map.json (merge-update). Export mirrors the public
format byte-layout (votes: full revote history ORDER BY created, ctid — no
dedup; comments: agrees/disagrees counted over all vote rows like
report.ts).

Feature classes: modheavy / revote / banned (participants.mod=-1 voters) /
meta / zerovote / smallmix / midmix (unremarkable volume coverage).

Tests: 52 passed — pure-function units (no DB) + one integration test on
the repo's require_polis_postgres throwaway-Postgres fixture, round-tripping
survey→extract→load_export_votes. TDD (RED commit first in agent clone).

commit-id:9f45b733
This was referenced Jul 22, 2026
@jucor
jucor marked this pull request as draft July 22, 2026 00:52
@jucor jucor changed the title feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B) feat(delphi): prodclone extractor — feature-filtered dataset export (… Jul 22, 2026
@jucor
jucor changed the base branch from spr/edge/a85047a7 to edge July 22, 2026 02:01
@jucor jucor changed the title feat(delphi): prodclone extractor — feature-filtered dataset export (… feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B) Jul 22, 2026
@jucor
jucor changed the base branch from edge to spr/edge/a85047a7 July 22, 2026 02:02
@jucor jucor changed the title feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B) feat(delphi): prodclone extractor — feature-filtered dataset export (… Jul 22, 2026
@jucor
jucor changed the base branch from spr/edge/a85047a7 to edge July 22, 2026 02:10
@jucor jucor changed the title feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B) feat(delphi): prodclone extractor — feature-filtered dataset export (… Jul 22, 2026
@jucor
jucor changed the base branch from spr/edge/a85047a7 to edge July 22, 2026 06:50
@jucor jucor changed the title feat(delphi): prodclone extractor — feature-filtered dataset export (… feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B) Jul 22, 2026
@jucor
jucor changed the base branch from edge to spr/edge/a85047a7 July 22, 2026 06:50
@jucor jucor changed the title feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B) feat(delphi): prodclone extractor — feature-filtered dataset export (… Jul 22, 2026
@jucor
jucor changed the base branch from spr/edge/a85047a7 to edge July 22, 2026 08:11
@jucor jucor changed the title feat(delphi): prodclone extractor — feature-filtered dataset export (… feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B) Jul 22, 2026
@jucor
jucor changed the base branch from edge to spr/edge/a85047a7 July 22, 2026 08:11
@jucor jucor changed the title feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B) feat(delphi): prodclone extractor — feature-filtered dataset export (… Jul 22, 2026
@jucor
jucor changed the base branch from spr/edge/a85047a7 to edge July 22, 2026 09:58
@jucor jucor changed the title feat(delphi): prodclone extractor — feature-filtered dataset export (… feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B) Jul 22, 2026
@jucor
jucor changed the base branch from edge to spr/edge/a85047a7 July 22, 2026 09:58
@jucor jucor changed the title feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B) feat(delphi): prodclone extractor — feature-filtered dataset export (… Jul 22, 2026
@jucor
jucor changed the base branch from spr/edge/a85047a7 to edge July 22, 2026 11:20
@jucor jucor changed the title feat(delphi): prodclone extractor — feature-filtered dataset export (… feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B) Jul 22, 2026
@jucor
jucor changed the base branch from edge to spr/edge/a85047a7 July 22, 2026 11:21
@jucor jucor changed the title feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B) feat(delphi): prodclone extractor — feature-filtered dataset export (… Jul 24, 2026
@jucor
jucor changed the base branch from spr/edge/a85047a7 to edge July 24, 2026 06:02
@jucor jucor changed the title feat(delphi): prodclone extractor — feature-filtered dataset export (… feat(delphi): prodclone extractor — feature-filtered dataset export (Spec B) Jul 24, 2026
@jucor
jucor changed the base branch from edge to spr/edge/a85047a7 July 24, 2026 06:02
@jucor
jucor requested a review from Copilot July 25, 2026 22:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Delphi-side “prodclone extractor” to survey and export feature-filtered conversation datasets from a production-clone Postgres DB into the existing replay-dataset CSV format used for Clojure↔Python parity work, with tests covering both pure helpers and a Postgres-backed round trip.

Changes:

  • Introduces polismath.replay.prodclone with SQL builders, feature classifiers, CSV writers, slug/prefix generation, path-safety guard, and prodclone_map.json merge-update.
  • Adds a thin Click CLI (scripts/prodclone_extract.py) exposing survey and extract commands.
  • Adds a comprehensive test suite including an opt-in Postgres integration test exercising survey → extract → load_export_votes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
delphi/polismath/replay/prodclone.py Core implementation: SQL builders, classification, path guard, CSV formatting/writing, and extraction orchestration.
delphi/scripts/prodclone_extract.py Click CLI wiring for surveying candidates and extracting a selected zid into the replay export format.
delphi/tests/test_prodclone_extract.py Unit tests for pure helpers + one opt-in integration test using the existing throwaway-Postgres fixture.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +512 to +516
if feature not in FEATURES:
raise ValueError(f"unknown feature {feature!r}; must be one of {FEATURES}")
if map_path is None:
map_path = out_root / ".local" / "prodclone_map.json"

Comment on lines +102 to +110
@click.option("--out-root", type=click.Path(path_type=Path), default=None,
help="real_data root — a .local/ subdir is created beneath it "
f"(default: {REAL_DATA_ROOT}).")
def extract(database_url: str, zid: int, feature: str, out_root: Path | None) -> None:
"""Mint the next free slug for FEATURE and export ZID's votes (full
revote history) + comments (text redacted) into
<out-root>/.local/<fake-prefix>-<slug>/, then merge-update
prodclone_map.json."""
out_root = out_root or REAL_DATA_ROOT
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.

2 participants