Skip to content

generate: check a copy as a copy even when its values read as the row's own key - #1839

Merged
abrichr merged 1 commit into
mainfrom
agent/1722
Nov 4, 2026
Merged

abrichr merged 1 commit into
mainfrom
agent/1722

Conversation

@abrichr

@abrichr abrichr commented Nov 4, 2026

Copy link
Copy Markdown
Member

Closes #1722

What changed

  • column_roles in generate/demo_analysis.py used to label a column "holds the row's own key" before it checked for a copy. Now that label applies only after _copied finds no copy. A copied price of 15 and 25 on rows 1 and 2 reads as {key}5, but it is now copied, and the contract checks it. A column that really holds its own key (AUD-{id}) is still listed with that reason in the question.
  • _key_template became _holds_own_key, which returns a bool. Nothing read detail["template"].
  • In docs/GENERATE_CONTRACTS.md, the own-key paragraph now describes what the classification does: it is a reason shown in the question, the column is left unchecked only if the answer names it, and a copy is checked as a copy even when its values read as the own key.
  • tests/test_generate_coincidences_r1.py:
    • The fixture no longer names sales.price under unchecked.
    • test_a_value_that_reads_as_the_own_key_is_asked_never_templated is replaced by test_a_copy_that_reads_as_the_own_key_is_checked_as_a_copy, parametrized over the correct price and a wrong price of 45. sales.price is in neither the refused list nor the questions. Only the correct price is CONFIRMED.

How it was tested

  • packages/flow: test_generate_coincidences*.py, test_generate_verify_contract*.py and test_zero_touch.py: 114 passed, against a local Postgres.
  • Control: with the base demo_analysis.py, both new cases fail, because sales.price is refused as unchecked.
  • mypy is clean on 591 sources. ruff check and format are clean on the changed Python files.

What couldn't be tested

  • No live app or recorded demonstrations. The tests use synthetic SQLite and Postgres fixtures only.

@abrichr abrichr added the review-needed Needs an independent review from another vendor's agent label Nov 4, 2026
@abrichr

abrichr commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Codex. Reviewed actual head 6d4a3a8 in a fresh detached worktree and locked environment.

packages/flow/openadapt_flow/generate/demo_analysis.py:709–716 classifies a demonstrated copy before considering the own-key coincidence. The resulting contract checks the source value. An actual own-key audit column still appears as a question and requires an explicit answer.

Validation: all 114 author-tested generator/coincidence/zero-touch tests pass with PostgreSQL 16. Full Flow Ruff/format and mypy pass (591 sources). Nine independent live generated-contract probes pass: correct price 40, five wrong prices, a changed source price of 55 versus stale 40, and the explicit own-key answer. The unchanged exact-parent fixture accepts all five wrong prices; the correct-price control passes there. This reproduces the original gap and confirms the new contract closes it.

Locked dependencies plus pinned psycopg2-binary 2.9.10; synthetic fixtures and private test state, headless resource gate. No live application or recorded demonstrations were tested. I did not edit or push this PR. CI must pass at the exact head before merge.

@abrichr abrichr removed the review-needed Needs an independent review from another vendor's agent label Nov 4, 2026
@abrichr
abrichr merged commit 3b09c28 into main Nov 4, 2026
48 checks passed
@abrichr
abrichr deleted the agent/1722 branch November 4, 2026 13:01
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.

Generator: the own-key template branch hides a checkable copy (follow-up to #1682)

1 participant