[EPAC-2303]: Relocate ComputeBillVersionDiff policy to bills-indexer use-case layer#822
Merged
riddim-developer-bot[bot] merged 1 commit intoJun 14, 2026
Conversation
…use-case layer The clause-diff algorithm (DiffClauses + buildDiffs) was application policy living in the LEGISinfo source adapter and running inside toDomain, which did not match the documented ComputeBillVersionDiff use case. The algorithm operates purely on domain.VersionSection -> domain.BillClauseDiff and is independent of the LEGISinfo wire format, so it belongs in the application layer. - Move DiffClauses and buildDiffs into internal/usecase/compute_bill_version_diff.go as exported ComputeBillVersionDiff + DiffClauses, importing only the standard library plus the local domain package. - Compose parsing (adapter) then diff (use case): IngestBills.Execute now computes diffs over the fetched batch before writing. The legisinfo adapter keeps XML/HTML retrieval and parseBillXML section extraction only. - Output is unchanged for existing fixtures (bill.Number, bill.Versions, and bill.SourceURL feed the policy with the same values toDomain passed before). - Move the diff unit tests to the use-case package; add a test that Execute actually composes the diff during ingestion. parseBillXML's test stays in the adapter (parse_test.go). - Update the use-case catalog: ComputeBillVersionDiff now lists real paths and the accurate port/adapter split, and IngestBillVersionText gains its Current implementation block. Verification: go test ./backend/bills-indexer/... passes; go vet clean; no file under internal/usecase/ imports net/http, encoding/xml, or the legisinfo adapter.
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.
Scope
Relocates the clause-diff application policy out of the LEGISinfo source adapter and into the bills-indexer use-case layer, so the boundary matches the documented
ComputeBillVersionDiffuse case (EPAC-2303; found during EPAC-2293 verification).The diff algorithm (
DiffClauses+buildDiffs) operates purely ondomain.VersionSection→domain.BillClauseDiffand is independent of the LEGISinfo wire format, so it belongs inward in the application layer, not in a source-named adapter. This is a behavior-preserving move — the artifact output is unchanged.What changed
DiffClauses+buildDiffsmoved intointernal/usecase/compute_bill_version_diff.goas exportedComputeBillVersionDiff+DiffClauses, importing only the standard library plus the localdomainpackage.IngestBills.Executenow computes diffs over the fetched batch (after the adapter has parsed sections) and before the SQLite write. The LEGISinfo adapter keeps XML/HTML retrieval andparseBillXMLsection extraction only.bill.Number,bill.Versions, andbill.SourceURLfeed the policy with exactly the valuestoDomainpassed tobuildDiffsbefore, so diff/clause IDs and rows are byte-identical.parseBillXML's test stays in the adapter (parse_test.go). AddedTestExecuteComputesVersionDiffsDuringIngest, which proves the use case composes the diff during ingestion (not just that the standalone policy works).ComputeBillVersionDiffnow lists real implementation paths and the accurate port/adapter split (pure domain→domain policy; no port of its own);IngestBillVersionTextgains its missingCurrent implementation:block.Acceptance criteria
DiffClauses/buildDiffsmoved intointernal/usecase/importing only stdlib +domain.parseBillXMLremain in the legisinfo adapter.domain.Batchoutput preserved for existing fixtures.internal/usecase/importsnet/http,encoding/xml, or the legisinfo adapter package.ComputeBillVersionDiffupdated;IngestBillVersionTextgains itsCurrent implementation:block.Bugfix SPEC
Testing notes
go test ./backend/bills-indexer/...— all pass.go vet ./...clean.grep -rE '"net/http"|"encoding/xml"|adapter/legisinfo' internal/usecase/returns nothing.Screenshots
N/A — no UI change.
Related issue