Skip to content

fix: store no errored row in a scope deleted while its batch was with the provider - #16

Merged
JDCyllene merged 1 commit into
CylleneDigital:mainfrom
JDCyllene:fix/no-errored-rows-for-a-gone-scope
Oct 16, 2026
Merged

JDCyllene merged 1 commit into
CylleneDigital:mainfrom
JDCyllene:fix/no-errored-rows-for-a-gone-scope

Conversation

@JDCyllene

Copy link
Copy Markdown
Member

What this pull request does

A run whose scope is deleted, and purged, while a batch is with the provider stops before its next batch. But when that very call failed, SuggestionGenerator::storeFailures() stored an errored suggestion for every key the run had not sent yet, under the deleted code. A scope created again under that code then found errored suggestions nobody asked it for, and cyllene:ai-translation:purge-scopes no longer saw the code to remove them.

The failure path now checks the scope before creating a row: a scope that is gone gets no new errored row. The rows reserved before the call are handled as before (a purge has deleted them; otherwise they record the failure), and the run is journaled as a failure as before.

  • docs/public-contract.md (what a generation run guarantees) and docs/concepts/scopes.md say so.
  • TranslationAiServiceTest::testAProviderFailureAfterTheScopeIsDeletedLeavesNoNewRowInIt deletes the scope during the first call, which then fails: 20 rows (the reserved batch) instead of 25. It fails without the change.

Found while adopting ScopePurger in the Sylius plugin (CylleneDigital/SyliusAiTranslationPlugin#8), whose record on a deleted channel mentions this case until the plugin requires the release carrying this fix.

Points to watch

  • Tests pass (vendor/bin/phpunit): 692 tests
  • PHPStan and PHP-CS-Fixer are green (vendor/bin/phpstan analyse, vendor/bin/php-cs-fixer check)
  • UPGRADE.md is up to date if the public contract changes: everything
    docs/public-contract.md lists, method signatures included - nothing breaks: one guarantee is added to what a generation run promises, no signature changes
  • A decision taken or reversed has its record in docs/adr/ - none: a fix within record 0025 (a deleted scope is purged, its journal kept)
  • No real API key appears in the code, the tests or this description

If the pull request touches the entity mapping

It does not.

If the pull request touches a provider bridge

It does not.

… the provider

A run whose scope is deleted and purged during a provider call stops
before its next batch, but a failure of that call stored errored rows
for every key never sent, under the deleted code: a scope created again
under it found them, and purge-scopes no longer saw the code. The
failure path now checks the scope before creating a row.
@JDCyllene
JDCyllene requested a review from a team as a code owner October 16, 2026 06:02
@JDCyllene
JDCyllene merged commit 63f268a into CylleneDigital:main Oct 16, 2026
12 checks passed
@JDCyllene
JDCyllene deleted the fix/no-errored-rows-for-a-gone-scope branch October 16, 2026 06:36
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