Skip to content

[EPAC-2303]: Relocate ComputeBillVersionDiff policy to bills-indexer use-case layer#822

Merged
riddim-developer-bot[bot] merged 1 commit into
mainfrom
symphony/epac-2303-implement-computebillversiondiff-use-case-in-bil
Jun 14, 2026
Merged

[EPAC-2303]: Relocate ComputeBillVersionDiff policy to bills-indexer use-case layer#822
riddim-developer-bot[bot] merged 1 commit into
mainfrom
symphony/epac-2303-implement-computebillversiondiff-use-case-in-bil

Conversation

@riddim-developer-bot

Copy link
Copy Markdown
Contributor

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 ComputeBillVersionDiff use case (EPAC-2303; found during EPAC-2293 verification).

The diff algorithm (DiffClauses + buildDiffs) operates purely on domain.VersionSectiondomain.BillClauseDiff and 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 + buildDiffs moved into internal/usecase/compute_bill_version_diff.go as exported ComputeBillVersionDiff + DiffClauses, importing only the standard library plus the local domain package.
  • Composition: IngestBills.Execute now computes diffs over the fetched batch (after the adapter has parsed sections) and before the SQLite write. 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 exactly the values toDomain passed to buildDiffs before, so diff/clause IDs and rows are byte-identical.
  • Tests: the diff unit tests moved to the use-case package; parseBillXML's test stays in the adapter (parse_test.go). Added TestExecuteComputesVersionDiffsDuringIngest, which proves the use case composes the diff during ingestion (not just that the standalone policy works).
  • Catalog: ComputeBillVersionDiff now lists real implementation paths and the accurate port/adapter split (pure domain→domain policy; no port of its own); IngestBillVersionText gains its missing Current implementation: block.

Acceptance criteria

  • DiffClauses/buildDiffs moved into internal/usecase/ importing only stdlib + domain.
  • XML/HTML retrieval and parseBillXML remain in the legisinfo adapter.
  • Pipeline composes parsing (adapter) then diff (use case); domain.Batch output preserved for existing fixtures.
  • Diff unit tests moved with the policy and pass against the use-case package.
  • No file under internal/usecase/ imports net/http, encoding/xml, or the legisinfo adapter package.
  • Catalog ComputeBillVersionDiff updated; IngestBillVersionText gains its Current implementation: block.

Bugfix SPEC

  • N/A — architecture refactor from a Linear issue, not a bug fix.

Testing notes

  • Automated tests run: go test ./backend/bills-indexer/... — all pass. go vet ./... clean.
  • Boundary check: grep -rE '"net/http"|"encoding/xml"|adapter/legisinfo' internal/usecase/ returns nothing.
  • Manual verification: N/A — internal backend refactor with no UI surface; bills artifact output and CLI run logs are unchanged. (No simulator screenshot applicable.)

Screenshots

N/A — no UI change.

Related issue

…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.
@riddim-developer-bot riddim-developer-bot Bot enabled auto-merge (squash) June 14, 2026 19:56
@riddim-developer-bot riddim-developer-bot Bot merged commit 4eafcd1 into main Jun 14, 2026
62 checks passed
@riddim-developer-bot riddim-developer-bot Bot deleted the symphony/epac-2303-implement-computebillversiondiff-use-case-in-bil branch June 14, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants