feat/rpu-history
needs attentionviewing older commita4117da · incrementalPR #324reviewed 2026-07-22 20:40 UTC0H · 2M · 3L · 6I- Purpose
- Close the RPU-agreements arc (#314/#319/#321/#323 already on main): rate-tag chip, regime timeline drawer, RPU-union bill count, evidence display refresh
- Goal
- Land §3 of rpu-agreements-model.md — the agreements-model UX
- Sub-goals
- Rate-tag chip (tariff code + Autoabasto) in Contratos backed by migration 0062
- Per-bill regime in Historial's Tarifa column (bill's own TARIFA_REG wins)
- RPU-union bill count across all non-deleted chapters sharing contract_number
- Regime-timeline drawer: one card per chapter, deep-linked ?detail=<id>
- RPU-complete exports audit (already correct — no code change)
- Evidence display refresh: strictly-newer guard for serviceName/address rename + FCIS fix
- What
- This commit (a4117da1): removes step 2a unconditional rename, narrows evidenceName to contractFields?.serviceName only, adds 3 integration tests, clarifies 4+ unit tests, adds prod promote runbook.
- Why
- serviceName is the CFE access credential — a stale XML batch reverting it deadlocks Gobierno collection. Legacy step 2a (PR #34) had this defect.
- Areas
- apps/platform+851−97domains/utility+897−32packages/database+13488−0docs+471−0
- Blast
- 39 files, +15,578/−129 across apps/platform (UI), domains/utility (domain logic), packages/database (migration 0062 + snapshot), docs
Findings · 11
correctness2
Absent contractFields silently produces no-op rename (intended)
domains/utility/src/utility-contract/utility-contract.decisions.ts:541
Behavioral contract change: job-level serviceName callers no longer rename
domains/utility/src/bill/bill.shells.ts:822
security1
Runbook SQL is dev-executed only — no injection surface
docs/development/rpu-history-promote-runbook.md:1
conventions1
Step 2a deletion correctly removes ad-hoc read-modify-write from shell (FCIS fix)
domains/utility/src/bill/bill.shells.ts:822
tests4
Negative-path unit tests no longer guard their stated temporal invariant
domains/utility/src/utility-contract/__tests__/utility-contract.decisions.test.ts:632
4 pre-existing tests use withEvidence() which sets input.serviceName but NOT contractFields.serviceName. After the fix evidenceName=undefined in all four — they trivially pass regardless of date logic.
Missing unit test: contractFields.serviceName matching stored name does not refresh
domains/utility/src/utility-contract/__tests__/utility-contract.decisions.test.ts:668
The same-name no-refresh test uses withEvidence (no contractFields). The evidenceName !== existingByCompoundKey.serviceName guard has no direct unit coverage with contractFields.serviceName present.
Rename idempotency not tested
domains/utility/src/bill/__tests__/persist-historical-site.integration.test.ts:376
Second call with same strictly-newer bill not verified to be a no-op event-wise.
cfeAvailable gate makes new integration tests vacuous in offline CI
domains/utility/src/bill/__tests__/persist-historical-site.integration.test.ts:343
improvement3
Orphaned prose comment block where step 2a was deleted
domains/utility/src/bill/bill.shells.ts:825
Lines 825-829 are a documentation comment with no code following. The policy is already in decisions.ts and tests. Remove or collapse to one line.
regimeBill helper inside describe scope — inconsistent with module-level staleBill
domains/utility/src/bill/__tests__/persist-historical-site.integration.test.ts:321
staleBill is at module scope; regimeBill is inside the describe block. Minor inconsistency.
buildContractInput create path still uses input.serviceName fallback (intentional)
domains/utility/src/utility-contract/utility-contract.decisions.ts:460