A suggestion the editor already accepted or dismissed goes back to pending when it is suggested again

Problem/motivation

An editor's decision on a suggestion is lost when the same source suggests again. DisclosureRecorder::suggest() stores through SuggestionStorage::upsert(), which keeps one row per entity, language and source and always writes the status pending. So a suggestion the editor accepted or dismissed goes back to pending, and a new suggestion with a different grade replaces the earlier one.

Content Credentials runs into this when a second file with a trusted credential is added to the same article: its read calls suggest() again with the same source.

Steps to reproduce

  1. Create an article with an AI disclosure field (1.0.0-alpha3).
  2. Call \Drupal::service('ai_disclosure.recorder')->suggest($node, 'ai_generated_autonomous', 'example_source');
  3. Accept or dismiss the suggestion on the edit form.
  4. Call suggest() again with the same grade and source.
  5. The suggestion is pending again.

Proposed resolution

Keep the status of an accepted or dismissed suggestion when the same grade is suggested again. What should happen with a different grade is up to you; today it replaces the earlier suggestion as pending.

Remaining tasks

  • Fix and test, for beta1.
  • One suggestion per file is out of scope for now, as it needs a schema change.

User interface changes

None.

API changes

None.

Data model changes

None.

Edited by Giorgio Alfredo Pagano