agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

sqlc regenerate breaks the build: app_settings.cloud_offering hand-typed as bool without a sqlc.yaml override

Open axisrow opened this issue 3 months ago • 2 comments

What's wrong

Running the documented regen command on a pristine main breaks the build:

``` cd backend && go run github.com/sqlc-dev/sqlc/cmd/[email protected] generate go build ./...

internal/storage/sqlite/store/app_settings_store.go:41:23: cannot use row.CloudOffering (variable of type int64) as bool value in struct literal

internal/storage/sqlite/store/app_settings_store.go:67:18: cannot use enabled (variable of type bool) as int64 value in struct literal

```

Root cause

app_settings.cloud_offering is declared as a plain INTEGER NOT NULL DEFAULT 0 CHECK (cloud_offering IN (0, 1)) (migration 0112_app_settings_cloud_offering.sql). sqlc cannot infer bool from that shape without an explicit override — and unlike its sibling boolean-ish columns (pr_comment.resolved, sessions.auto_review_enabled, agent_switches.semantic_handoff_included), backend/sqlc.yaml never got a column: "app_settings.cloud_offering" go_type: "bool" entry.

The committed gen/models.go and gen/app_settings.sql.go do type CloudOffering as bool (matching every consumer — store/app_settings_store.go, service/settings/service.go, daemon/settings_wiring.go, httpd/controllers/dto.go) — but that file was hand-edited to add bool, not generated. Two tells confirm it:

  • GetAppSettings's row.Scan is a single-line call; sqlc emits it multi-line once a struct has 4+ fields.
  • SetCloudOffering is appended at the end of the file; sqlc orders declarations alphabetically, so it belongs before SetDefaultSessionMode.

This violates the repo's own "do not hand-edit gen/*" rule, and nothing catches it: CI regenerates and diff-checks the OpenAPI spec (schema.ts) but has no equivalent step for sqlc's gen/ output, so the drift went unnoticed since it was introduced (feat(cloud) — the AO cloud offering integration).

Fix

Add the missing override to backend/sqlc.yaml, alongside app_settings.default_session_mode:

```yaml

  • column: "app_settings.cloud_offering" go_type: "bool" ```

Regenerating with that in place reproduces the current committed types exactly (plus the two cosmetic normalizations above). Also worth adding a CI guard mirroring the existing schema.ts drift check: npm run sqlc && git diff --exit-code -- backend/internal/storage/sqlite/gen/, so hand-edited gen/ output can't silently ship again.

Repro

``` git clone && cd agent-orchestrator/backend go run github.com/sqlc-dev/sqlc/cmd/[email protected] generate git diff -- internal/storage/sqlite/gen/models.go # CloudOffering flips to int64 go build ./... # fails ```

axisrow avatar Aug 29 '26 03:08 axisrow

Thanks for contributing to Agent Orchestrator.

This issue is being picked up by the current external contributor on-call pair:

  • @illegalcall
  • @somewherelostt

If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @illegalcall and @somewherelostt here.

For faster context or live questions, you can also join the AO Discord.

Join the session here: https://discord.gg/H6ZDcUXmq

Come by if you want to see what is being built, ask questions, or just hang around with the community.

somewherelostt avatar Aug 29 '26 15:08 somewherelostt

Closing as fixed on current main. The missing app_settings.cloud_offering boolean override is present in backend/sqlc.yaml, and merged PR #5190 added a pinned npm run sqlc drift CI job plus regression coverage requiring the boolean override. Current generated storage code is reproducible rather than hand-maintained.

codebanditssss avatar Sep 23 '26 14:09 codebanditssss