166 lines
9.6 KiB
Python
166 lines
9.6 KiB
Python
"""Document-only reconciliation. Never writes CSV/application/configuration/DB."""
|
||
from pathlib import Path
|
||
from hashlib import sha256
|
||
from collections import Counter
|
||
import csv
|
||
import json
|
||
import zipfile
|
||
|
||
ROOT = Path(__file__).resolve().parents[2]
|
||
OUT = Path(__file__).resolve().parent
|
||
DOC = ROOT / 'docs/investmoz/v2/auditoria-portal'
|
||
MARK = '<!-- product-three-deliveries-20261013 -->'
|
||
END = '<!-- /product-three-deliveries-20261013 -->'
|
||
|
||
def digest(path):
|
||
return sha256(path.read_bytes()).hexdigest()
|
||
|
||
def write_json(path, value):
|
||
path.write_text(json.dumps(value, ensure_ascii=False, indent=2) + '\n', encoding='utf-8')
|
||
|
||
csv.field_size_limit(10_000_000)
|
||
matrix = DOC / 'matriz-requisitos.csv'
|
||
backlog = DOC / 'backlog-priorizado.csv'
|
||
assert digest(matrix) == 'ae78518d09647475011fc26e4ab04c0865c33484205be6203797cc8dddd98244'
|
||
assert digest(backlog) == 'aae49753c1788b27b3bfca02bfff8178444d5d7baa49905e85910b1bb51f1ed3'
|
||
with matrix.open(encoding='utf-8-sig', newline='') as handle:
|
||
rows = list(csv.DictReader(handle))
|
||
assert len(rows) == 3401
|
||
|
||
# Every tuple is (corrections, remaining implementation, verification).
|
||
core = [
|
||
('Perfis e acesso', (1, 2), (0, 0), (1, 2)),
|
||
('Contratos/materialidade/workflow', (3, 5), (5, 9), (4, 6)),
|
||
('Países/origem/filtros/estatísticas', (2, 3), (1, 3), (3, 4)),
|
||
('Mapas/seletores do núcleo', (1, 2), (2, 4), (3, 4)),
|
||
('Documentos privados do núcleo', (2, 4), (1, 3), (3, 5)),
|
||
('Acessibilidade do núcleo', (2, 4), (0, 0), (2, 4)),
|
||
]
|
||
later = [
|
||
('Mapas de outros consumidores', (1, 2), (2, 3), (1, 3)),
|
||
('Balcão/orientação/CRM adicional', (1, 2), (1, 3), (2, 3)),
|
||
('Negócios/salas/bolsa adicionais', (1, 2), (1, 3), (2, 3)),
|
||
('Dossier/percurso adicional', (1, 2), (1, 3), (2, 3)),
|
||
('Legado existente restante', (1, 2), (3, 5), (2, 3)),
|
||
('Acessibilidade adicional', (1, 2), (0, 0), (1, 2)),
|
||
]
|
||
increments = [
|
||
('Fiscal/contributivo', (16, 32)),
|
||
('Educação', (12, 24)),
|
||
('Fundos', (8, 16)),
|
||
('Comparador/modelos', (8, 16)),
|
||
('Capitalização/guião', (8, 16)),
|
||
('Negócios similares/importação', (12, 24)),
|
||
('Editor/checklists', (8, 16)),
|
||
('Indicadores de utilização', (4, 8)),
|
||
]
|
||
|
||
def sum_ranges(values):
|
||
return [sum(v[0] for v in values), sum(v[1] for v in values)]
|
||
|
||
def totals(items):
|
||
phase = {key: sum_ranges([r[index] for r in items]) for index, key in
|
||
[(1, 'corrections'), (2, 'remaining_implementation'), (3, 'verification')]}
|
||
phase['total'] = sum_ranges(phase.values())
|
||
return phase
|
||
|
||
assert totals(core) == {'corrections': [11,20], 'remaining_implementation': [9,19],
|
||
'verification': [16,25], 'total': [36,64]}
|
||
assert totals(later)['total'] == [24,46]
|
||
assert totals(core + later) == {'corrections': [17,32], 'remaining_implementation': [17,36],
|
||
'verification': [26,42], 'total': [60,110]}
|
||
assert sum_ranges([r[1] for r in increments]) == [76,152]
|
||
assert sum_ranges([totals(core + later)['total'], [76,152]]) == [136,262]
|
||
assert sum_ranges([totals(core)['total'], later[3][1], later[3][2], later[3][3]]) == [40,72]
|
||
assert sum_ranges([[24,46], [76,152]]) == [100,198]
|
||
|
||
plan = {
|
||
'date': '2026-10-13', 'purpose': 'Scope decision, not activation or a new backlog',
|
||
'estimation_status': 'Planning allocation of previous remaining budget, not measured duration',
|
||
'core': [{'item': r[0], 'corrections': r[1], 'remaining_implementation': r[2],
|
||
'verification': r[3], 'total': sum_ranges(r[1:])} for r in core],
|
||
'existing_complement': [{'item': r[0], 'corrections': r[1], 'remaining_implementation': r[2],
|
||
'verification': r[3], 'total': sum_ranges(r[1:])} for r in later],
|
||
'later_increments': [{'item': r[0], 'total': r[1]} for r in increments],
|
||
'totals': {'core': totals(core), 'existing_complement': totals(later),
|
||
'previous_60_110': totals(core + later), 'later_76_152': [76,152],
|
||
'all_previous_scope': [136,262], 'deferred_if_A': [100,198]},
|
||
'options': {'A': [36,64], 'B': [40,72], 'C': [60,110]},
|
||
'categories_budget_already_in_workflow': {
|
||
'project': [2,4], 'property_sale_lease': [2,3], 'land_rights': [2,4],
|
||
'business_sale': [2,3], 'partnership': [2,3], 'franchise': [2,3]},
|
||
'no_overlap_rules': [
|
||
'Workflow category allocations are not added to their aggregate again.',
|
||
'Common documents/maps/countries/accessibility costs belong to their own lines.',
|
||
'Existing statistics are distinct from new utilisation indicators.',
|
||
'Existing business-interest consumer differs from new similar-business/import functionality.',
|
||
'Existing workflow checklists differ from the new checklist editor/versioning.',
|
||
'A/B and C37 accepted criteria are not re-estimated.'
|
||
],
|
||
'support_C135': {'submitted': False, 'reason': 'No connected support submission capability',
|
||
'prepared_text': 'C135-pedido-suporte.md', 'reinitializations_repeated': 0,
|
||
'visual_criteria_closed': 0},
|
||
'active_changes': 0, 'QA_application_changes': 0, 'new_requirement_ids': 0,
|
||
'requirements_state_changes': 0,
|
||
}
|
||
assert sum_ranges(plan['categories_budget_already_in_workflow'].values()) == [12,20]
|
||
write_json(OUT / 'three-deliveries-budget.json', plan)
|
||
|
||
decision = (DOC / 'decisao-produto-tres-entregas.md').read_text(encoding='utf-8')
|
||
notice = '''## Decisão do produto em três entregas — 13/10/2026
|
||
|
||
**Recomendação para decisão da Tempo: núcleo operacional das seis categorias base, 36–64 h.** Alternativas: núcleo + percurso integrado existente, 40–72 h; todos os consumidores existentes, 60–110 h. Nenhuma escolha foi aplicada a flags, permissões, dados ou código.
|
||
|
||
1. **Produto utilizável agora:** workflow base/perfis/COUNTRY02 disponibilizados no ativo, com primeiro processo documental legítimo ainda por observar; percursos QA das seis categorias, arrendamento, A/B e piloto agronegócio já demonstrados, com os respetivos limites.
|
||
2. **Essencial:** contratos/materialidade, países/estatísticas, mapas, documentos e acessibilidade dos consumidores incluídos; parcelas e saídas objetivas na proposta.
|
||
3. **Evolução:** complemento existente 24–46 h e incrementos distintos 76–152 h. Não somar categorias ou componentes comuns duas vezes.
|
||
|
||
Decomposição das **60–110 h**: **17–32 correções + 17–36 implementação restante + 26–42 verificação**. Núcleo: 11–20 + 9–19 + 16–25 = 36–64 h. São horas técnicas de planeamento, não prazo/SLA; espera do conector, C132, dados ausentes e intervenção ativa ficam separados.
|
||
|
||
Detalhe, evidências reutilizadas, limites ativos/QA, estimativas por categoria e opções: [Três entregas para decisão](decisao-produto-tres-entregas.md). C135: [pedido de suporte sanitizado](C135-pedido-suporte.md), preparado e **não submetido**, sem ferramenta de envio disponível; nenhuma nova reinicialização ou contorno. Provas visuais novas abertas. C132 separado; A/B e C37 preservados.
|
||
|
||
Mesma matriz: 3.401 linhas/IDs, referências e estados intactos. Esta reorganização não acrescenta requisitos nem encerra critérios. A síntese anterior abaixo conserva o histórico; a classificação de prioridade e a decomposição atuais são as desta secção e do detalhe referido.
|
||
'''
|
||
|
||
def prepend(path, body):
|
||
original = path.read_text(encoding='utf-8-sig')
|
||
assert MARK not in original, 'Document already reconciled; inspect rather than duplicate'
|
||
backup = OUT / 'document-history-before-three-deliveries-20261013' / path.name
|
||
backup.parent.mkdir(exist_ok=True)
|
||
assert not backup.exists()
|
||
backup.write_bytes(path.read_bytes())
|
||
updated = MARK + '\n' + body + '\n' + END + '\n\n' + original
|
||
path.write_text(updated, encoding='utf-8')
|
||
assert path.read_text(encoding='utf-8').endswith(original)
|
||
return {'file': str(path.relative_to(ROOT)), 'before': digest(backup),
|
||
'after': digest(path), 'history_preserved': True}
|
||
|
||
changes = []
|
||
for name in ['relatorio-executivo.md', 'backlog.md']:
|
||
changes.append(prepend(DOC / name, notice))
|
||
changes.append(prepend(DOC / 'visao-consolidada-modulos.md', decision))
|
||
# Existing OUT summary is a review copy, not another requirement inventory.
|
||
out_decision = decision.replace('(C135-pedido-suporte.md)', '(para-revisao/C135-pedido-suporte.md)')
|
||
changes.append(prepend(OUT / 'sintese-fecho-por-modulo.md', out_decision))
|
||
|
||
review = OUT / 'para-revisao'
|
||
review.mkdir(exist_ok=True)
|
||
for name in ['relatorio-executivo.md', 'backlog.md', 'visao-consolidada-modulos.md',
|
||
'decisao-produto-tres-entregas.md', 'C135-pedido-suporte.md']:
|
||
(review / name).write_bytes((DOC / name).read_bytes())
|
||
|
||
assert digest(matrix) == 'ae78518d09647475011fc26e4ab04c0865c33484205be6203797cc8dddd98244'
|
||
assert digest(backlog) == 'aae49753c1788b27b3bfca02bfff8178444d5d7baa49905e85910b1bb51f1ed3'
|
||
proof = {'date': '2026-10-13', 'document_changes': changes,
|
||
'matrix': {'rows': len(rows), 'sha256': digest(matrix), 'unchanged': True},
|
||
'backlog_csv': {'sha256': digest(backlog), 'unchanged': True},
|
||
'arithmetic_verified': True, 'new_tests_or_code': False,
|
||
'active_configuration_or_DB_mutations': 0, 'support_submission': False,
|
||
'previous_ZIP_preserved': digest(OUT / 'investmoz-sintese-modulos-PDF-C137-revisao-20261012.zip') ==
|
||
'a49823898d7c9f92df6b934337f08d94c14c4111b36f5b7d257413d7da0ee86e'}
|
||
write_json(OUT / 'three-deliveries-reconciliation.json', proof)
|
||
|
||
print(json.dumps({'matrix_unchanged': True, 'states_unchanged': True,
|
||
'totals': plan['totals'], 'options': plan['options'],
|
||
'documents_updated': len(changes), 'support_submitted': False}, ensure_ascii=False))
|