Commit 48d67e2
[EPAC-2304]: Lock bills SQLite artifact schema with a producer-to-consumer seam test (#823)
## Scope
The bills SQLite artifact is an implicit contract between two separate
Go binaries: the **bills-indexer writer** (producer,
`backend/bills-indexer/internal/adapter/sqlite/writer.go`) and the
**bills serving repository** (consumer,
`backend/bills/internal/adapter/sqlite/repository.go`). Nothing fast
verified the assembled contract — only the staging smoke did, which
cannot catch drift before deploy. The serving repo also masked drift
with dynamic column-name fallbacks (`columnExpr`/`firstColumn`/…), so as
shipped the served `BillVersion`'s `title`/`chamber`/`published_on` were
always empty (the indexer never writes those columns) and the version
`label` silently fell back to `stage`.
This PR locks that contract:
- **Seam test** (`backend/bills/artifact_seam_test.go`,
`TestBillsArtifactSeam`). It drives the *real* producer binary in a new
offline fixture mode to write a real `bills.db`, then opens that file
with the *real* serving repository and asserts `ListBills`,
`GetBillDepth`, and `GetBillVersionDiff` return the promised columns
populated — no NULL fallbacks. The two adapters are `internal` to
separate Go modules, so (per the issue's guidance) neither imports the
other's internals; the only thing shared across the seam is the on-disk
SQLite file, exactly as in production.
- **Single-sourced `bill_versions` contract.** The served `BillVersion`
is now exactly `{id, label, stage, source_url}`, where `label` and
`stage` both carry the LEGISinfo publication-type name (the indexer has
no separate label column) and `source_url` is the indexer's `html_url`.
The always-empty `title`, `chamber`, and `published_on` were dropped
from the domain model and `backend/openapi/openapi.json` (schema +
examples). The decision is recorded in
`docs/architecture/bills-artifact-contract-epac2304.md`.
- **Dead fallbacks removed.** The version and amendment reads now use
fixed SQL against the producer's real columns; the
`columnExpr`/`firstColumn`/`tableColumns`/`orderExpr` helpers are gone.
- **Offline producer mode** (`BILLS_FIXTURE_BATCH`) added to the
bills-indexer so the seam test can drive the real writer without
LEGISinfo or AWS. The deployed pipeline never sets it.
- **CI gate.** The `bills` module is now run in `pr-build`'s
`backend-tests` job, so schema drift fails the required gate instead of
in staging smoke or production.
**No runtime response change / no `Release-Note`:** the dropped version
fields were already omitted from responses (always empty, `omitempty`),
and iOS decodes every version field as optional. The served JSON is
byte-identical; this is an API-spec + test/refactor change with no
user-visible effect.
**Out of scope (documented follow-up):** the served `BillAmendment`
over-promises fields the indexer never writes; the consumer now reads
only the producer-backed `id`/`source_url` (identical to today's
production output) with fixed SQL, and the remaining contract
trim/enrich is captured in the "Known limitation" section of the
architecture note.
## Bugfix SPEC
* **Spec:** N/A — architecture/test hardening, not a bug fix.
* **Trace ID:** N/A
## Testing notes
* **Automated tests run:** `go test ./backend/bills/...
./backend/bills-indexer/...` (pass), `go test -tags=integration ./...`
for bills (pass), `go test ./...` for the openapi module (pass),
`gofmt`/`go vet` clean, `actionlint` on the workflow (pass).
* **Manual verification:** N/A — backend-only change, no UI surface. The
seam test is the verification; it builds a real artifact and reads it
back through the serving repository.
## Screenshots
N/A — no UI change.
## Related issue
- Closes:
https://linear.app/riddimsoftware/issue/EPAC-2304/lock-bills-sqlite-artifact-schema-with-a-producer-to-consumer-seam
Co-authored-by: riddim-developer-bot <developer-bot@riddimsoftware.com>1 parent 4eafcd1 commit 48d67e2
9 files changed
Lines changed: 417 additions & 204 deletions
File tree
- .github/workflows
- backend
- bills-indexer
- bills
- internal
- adapter/sqlite
- domain
- openapi
- docs/architecture
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| |||
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
69 | | - | |
| 72 | + | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
| |||
109 | 112 | | |
110 | 113 | | |
111 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
112 | 146 | | |
113 | 147 | | |
114 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
0 commit comments