Add <response> element validation for SPS 1.10 compliance#1138
Draft
Add <response> element validation for SPS 1.10 compliance#1138
Conversation
Implements 7 validation rules for <response> element: - Rule 1: @response-type presence (CRITICAL) - Rule 2: @response-type value must be "reply" (ERROR) - Rule 3: @xml:lang presence (CRITICAL) - Rule 4: @id presence (CRITICAL) - Rule 5: @id uniqueness (ERROR) - Rule 6: <front-stub> presence (WARNING) - Rule 7: <body> presence (WARNING) New files: - packtools/sps/validation/response.py - Validation class - packtools/sps/validation_rules/response_rules.json - Rules config - tests/sps/validation/test_response.py - 31 unit tests Modified files: - packtools/sps/validation/xml_validations.py - Import + wrapper function - packtools/sps/validation/xml_validator.py - Orchestrator integration Co-authored-by: robertatakenaka <505143+robertatakenaka@users.noreply.github.com>
Co-authored-by: robertatakenaka <505143+robertatakenaka@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement validations for the response element
Add <response> element validation for SPS 1.10 compliance
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
O que esse PR faz?
Implementa 7 regras de validação para o elemento
<response>conforme SPS 1.10, cobrindo atributos obrigatórios, unicidade de IDs e estrutura mínima esperada.@response-typepresença@response-typevalor ="reply"@xml:langpresença@idpresença@idunicidade<front-stub>presença<body>presençaOnde a revisão poderia começar?
packtools/sps/validation/response.py— contém a classeResponseValidationcom todos os 7 métodos de validação.Como este poderia ser testado manualmente?
Testar também via orchestrator:
31 testes unitários em
tests/sps/validation/test_response.pycobrem: atributos ausentes/vazios/whitespace, valores incorretos, IDs duplicados, respostas em<sub-article>, error levels customizáveis.Algum cenário de contexto que queira dar?
O
<response>identifica respostas a cartas/comentários publicadas no mesmo documento. Segue o mesmo padrão arquitetural dos validadores existentes (HistoryValidation,XMLPeerReviewValidation): classe de validação + rules JSON + integração no orchestrator viaxml_validations.py/xml_validator.py.Arquivos criados:
packtools/sps/validation/response.py—ResponseValidationpacktools/sps/validation_rules/response_rules.json— configuração de níveis de errotests/sps/validation/test_response.py— 31 testesArquivos modificados:
packtools/sps/validation/xml_validations.py— import +validate_response()packtools/sps/validation/xml_validator.py— yield do grupo"response"Screenshots
N/A — validação backend sem componente visual.
Quais são tickets relevantes?
Referências
<response>Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.crossref.orgfrom lxml import etree
from packtools.sps.validation.xml_validator import get_validation_results
from packtools.sps.validation.xml_validator_rules import get_default_rules
Test that response_rules loads from the JSON
rules = get_default_rules()
assert` (dns block)
Original prompt
This section details on the original issue you should resolve
<issue_title>Criar validações para o elemento </issue_title>
<issue_description>## Objetivo
Implementar validações para o elemento
<response>conforme a especificação SPS 1.10, aumentando a conformidade de X% para 70% (7 de 10 regras).Nota: Algumas validações para
<response>podem já estar parcialmente implementadas no repositório. Este Issue visa reavaliar, complementar e garantir cobertura completa das regras SPS 1.10.Contexto
O elemento
<response>identifica um conjunto de respostas referente a uma carta ou comentário, obrigatoriamente publicadas juntamente com a carta/comentário. É usado quando há múltiplas respostas no mesmo documento. Validações corretas garantem presença de atributos obrigatórios, unicidade de IDs, e estrutura mínima necessária.Conformidade atual: X de 10 regras implementadas (X%)
Meta após implementação: 7 de 10 regras (70%)
Documentação SPS
Referência oficial: https://docs.google.com/document/d/1GTv4Inc2LS_AXY-ToHT3HmO66UT0VAHWJNOIqzBNSgA/edit?tab=t.0#heading=h.response
Regras principais conforme SPS 1.10:
Ocorrência:
<response>pode aparecer zero ou mais vezes em<article>e<sub-article>Contexto de uso:
<sub-article article-type="reply"><article article-type="reply">Atributos obrigatórios:
@response-type="reply"(obrigatório)@xml:lang(obrigatório)@id(obrigatório)Unicidade de IDs:
@iddiferente para cada<response>Estrutura esperada:
<front-stub>- Metadados da resposta<body>- Conteúdo da resposta<back>- Seção final (opcional, pode conter<ref-list>)Regras a Implementar
P0 – Críticas (implementar obrigatoriamente)
@response-type@response-typeé obrigatório em<response>@response-type@response-typedeve ser"reply"@xml:lang@xml:langé obrigatório em<response>@id@idé obrigatório em<response>@id<response>deve ter um@idúnico (não pode repetir valores)P1 – Importantes (implementar se possível)
<front-stub><response>contenha<front-stub>com metadados da resposta<body><response>contenha<body>com o conteúdo da respostaP2 – Futuras (fora do escopo deste Issue)
Arquivos a Criar/Modificar
Avaliar existentes (podem ter validações parciais):
packtools/sps/models/response.pyou similar – Verificar se modelo existepacktools/sps/validation/response.py– Verificar validações existentespacktools/sps/validation/rules/response_rules.jsonou similar – Verificar configuraçãoCriar (se não existirem):
packtools/sps/models/response.py– Modelo de extração de dadospacktools/sps/validation/response.py– Validaçõespacktools/sps/validation/rules/response_rules.json– Configuração de níveis de errotests/sps/validation/test_response.py– Testes unitáriosReferenciar (implementações similares):
packtools/sps/validation/sub_article.py– Validação de estrutura similarpacktools/sps/validation/utils.py– Funções auxiliares (build_response)Exemplos de XML
XML Válido (deve passar sem erros):