Skip to content

test(agent): simetria com o lado Go no teste de preservação (CRM-464) - #62

Merged
gomessguii merged 1 commit into
developfrom
chore/crm-464-simetria-teste-preservacao
Aug 31, 2026
Merged

test(agent): simetria com o lado Go no teste de preservação (CRM-464)#62
gomessguii merged 1 commit into
developfrom
chore/crm-464-simetria-teste-preservacao

Conversation

@gomessguii

@gomessguii gomessguii commented Aug 31, 2026

Copy link
Copy Markdown
Member

O que muda

Uma linha em tests/unit/test_agent_repair_default_model.py:
test_repair_keeps_a_model_the_agent_already_has passa a aferir db.commit.called,
como os outros dois testes do arquivo já faziam.

De onde veio

Sobra do review do CRM-464. Na PR irmã do core-service (#41), a Sourcery apontou que o
teste de preservação aferia só o modelo em memória, nunca o valor persistido — e o buraco
era real: fazendo o sanitizeAgent persistir uma cópia com o Model sobrescrito, os dois
testes Go passavam. Corrigido lá em 22fed83.

Aqui a asserção equivalente não cabe. O SQLAlchemy comita o próprio objeto mutado; não
há cópia de onde o valor devolvido e o valor persistido possam divergir. O que dá para
documentar é o outro lado da garantia: o reparo escreve — muda o tipo para llm e
comita — e o modelo que o cliente escolheu sobrevive a essa escrita.

Sem isso, os três testes do arquivo ficavam assimétricos: os dois de carimbo provavam a
persistência, e justo o que guarda a restrição de não reapontar modelo de cliente não
provava.

Por que em PR separada

O commit nasceu na branch do #61 e ficou órfão quando a PR foi mergeada e a branch apagada,
antes de eu conseguir empurrar.

Verificação

352 passed em tests/unit, mesmo baseline da develop. O ImportError de
tests/unit/test_exception_handlers.py é pré-existente e não tem relação com esta mudança.

Summary by Sourcery

Ensure the agent repair preservation test verifies both the repair write and retention of the client-selected model.

Enhancements:

  • Verify that repairing an agent with an existing model still commits the repair while preserving the selected model.

Tests:

  • Make the existing-model repair test assert that the database commit occurs, keeping persistence coverage consistent with the related tests.

…review)

test_repair_keeps_a_model_the_agent_already_has passa a aferir db.commit.called,
como os outros dois testes do arquivo. Aqui nao cabe a assercao de valor
persistido que a PR irma ganhou — o SQLAlchemy comita o proprio objeto mutado,
nao ha copia de onde os dois valores possam divergir. O que se documenta e que
o reparo ESCREVE e o modelo do cliente sobrevive a escrita.
@gomessguii
gomessguii merged commit 5ab9a72 into develop Aug 31, 2026
4 checks passed
@gomessguii
gomessguii deleted the chore/crm-464-simetria-teste-preservacao branch August 31, 2026 17:16

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @gomessguii, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR strengthens the agent repair regression test by verifying both sides of the guarantee: the repair persists its type change while preserving an already configured model, matching the persistence coverage of the companion tests.

File-Level Changes

Change Details Files
Complements the existing model-preservation test with an assertion that repair persistence is invoked.
  • Verifies that the database commit occurs after the agent type is repaired to llm.
  • Keeps validating that the client-selected model remains unchanged through the write.
tests/unit/test_agent_repair_default_model.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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