carl_artifact.facts is a text column queried as JSON for balance-sheet and plan-effect selection #15

Open
opened 2026-10-01 22:50:44 +00:00 by KofTwentyTwo · 0 comments
KofTwentyTwo commented 2026-10-01 22:50:44 +00:00 (Migrated from github.com)

Summary

V54__native_balance_selection.sql:12 and DashboardFacts.java:229,307 select artifacts with f.facts::jsonb->>'calculationVersion' over carl_artifact.facts, which is declared text. Selection logic depends on JSON paths over an untyped column with no jsonb type and no expression index. The foundation contract says to avoid opaque JSON for core searchable entities. carl_plan_version.snapshot (V9:15) and carl_home_history.snapshot (V58:20) are similar history blobs, acceptable as audit snapshots.

Suggested resolution

Either promote facts to jsonb with an expression index on the keys used for selection, or lift calculationVersion (and any other selector) into typed columns.

Priority rationale

P2: contract deviation on a hot query path.


Filed from the 2026-10-01 real-versus-fake audit of Carl (branch feature/cicd-liquibase-gitops, HEAD 5414d7a, main 1b334d1). Four read-only reviews covered domain and services, QQQ metadata and data model, tests/CI/evidence, and docs/integrations. A local offline build of a Carl copy against the installed foundation 0.5.0-SNAPSHOT is in progress; its result will be added as a comment. Existing issues #3, #4 and #5 (real Monarch accounts, Authentik with real data, CI/CD with Liquibase and ArgoCD) are referenced rather than duplicated.

## Summary `V54__native_balance_selection.sql:12` and `DashboardFacts.java:229,307` select artifacts with `f.facts::jsonb->>'calculationVersion'` over `carl_artifact.facts`, which is declared `text`. Selection logic depends on JSON paths over an untyped column with no jsonb type and no expression index. The foundation contract says to avoid opaque JSON for core searchable entities. `carl_plan_version.snapshot` (`V9:15`) and `carl_home_history.snapshot` (`V58:20`) are similar history blobs, acceptable as audit snapshots. ## Suggested resolution Either promote `facts` to `jsonb` with an expression index on the keys used for selection, or lift `calculationVersion` (and any other selector) into typed columns. ## Priority rationale P2: contract deviation on a hot query path. --- Filed from the 2026-10-01 real-versus-fake audit of Carl (branch `feature/cicd-liquibase-gitops`, HEAD `5414d7a`, main `1b334d1`). Four read-only reviews covered domain and services, QQQ metadata and data model, tests/CI/evidence, and docs/integrations. A local offline build of a Carl copy against the installed foundation 0.5.0-SNAPSHOT is in progress; its result will be added as a comment. Existing issues #3, #4 and #5 (real Monarch accounts, Authentik with real data, CI/CD with Liquibase and ArgoCD) are referenced rather than duplicated.
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KofTwentyTwo/carl#15