Skip to content

Add a full database docdb SQLite database - #1502

Open
msuozzo wants to merge 2 commits into
google:mainfrom
msuozzo:push-pnkpvutxolvu
Open

Add a full database docdb SQLite database#1502
msuozzo wants to merge 2 commits into
google:mainfrom
msuozzo:push-pnkpvutxolvu

Conversation

@msuozzo

@msuozzo msuozzo commented Aug 25, 2026

Copy link
Copy Markdown
Member

Scan Firestore into docdb doc tables (attempts, runs, agent sessions
and iterations, scratch VMs and execs, repo metrics) and write the
result as a single rebuild-v.db, gzip-encoded where the destination
supports it. The registry in tables.go is the entire snapshot schema:
entity columns are extractions over the source documents (the strategy
oneof labels itself via json_each) so no row structs or Go
projection code exist anywhere. The database meta watermark records the
scan start so incremental replay can resume from it. It will run as a
scheduled job periodically (daily?).

The object name carries the schema version, so a version bump ensures
new consumers will require deployment instead of getting unexpected
data. And the schema safety is enforced with a golden test which pins
the materialized column shapes (generated columns included) against a
committed golden per SchemaVersion. Additive changes may regenerate it
in-place with -update, while removals, renames, retypes, and key changes
fail until the version is bumped, and -update itself refuses to rewrite
an incompatible golden.

In terms of mapping safety, a saturation test stores a fully populated
instance of every source type and asserts every column reads non-NULL
with its declared storage type, so an extraction path whose identity
departs from its struct (a renamed field, a newly added json tag) fails
rather than silently reading as empty data.

Parents: #1500
Children: #1503

@msuozzo
msuozzo requested a review from wbxyz August 25, 2026 23:45
@msuozzo
msuozzo force-pushed the push-pnkpvutxolvu branch from d5cf0bc to feed925 Compare August 28, 2026 19:52
In order to provide better support and interoperability with local-first
workflows, this SQLite data layer provides flexible downstream query and
storage without requiring changes to the existing firestore schema and
usage. Updates can be streamed in periodically to ensure freshness and
full snapshots are made ~daily which ensures accuracy.
Scan Firestore into docdb doc tables (attempts, runs, agent sessions
and iterations, scratch VMs and execs, repo metrics) and write the
result as a single rebuild-v<N>.db, gzip-encoded where the destination
supports it. The registry in tables.go is the entire snapshot schema:
entity columns are extractions over the source documents (the strategy
oneof labels itself via json_each) so no row structs or Go
projection code exist anywhere. The database meta watermark records the
scan start so incremental replay can resume from it. It will run as a
scheduled job periodically (daily?).

The object name carries the schema version, so a version bump ensures
new consumers will require deployment instead of getting unexpected
data. And the schema safety is enforced with a golden test which pins
the materialized column shapes (generated columns included) against a
committed golden per SchemaVersion. Additive changes may regenerate it
in-place with -update, while removals, renames, retypes, and key changes
fail until the version is bumped, and -update itself refuses to rewrite
an incompatible golden.

In terms of mapping safety, a saturation test stores a fully populated
instance of every source type and asserts every column reads non-NULL
with its declared storage type, so an extraction path whose identity
departs from its struct (a renamed field, a newly added json tag) fails
rather than silently reading as empty data.

forge-parent: krxuzqzswono
@msuozzo
msuozzo force-pushed the push-pnkpvutxolvu branch from feed925 to 224417c Compare August 31, 2026 16:05
Comment thread cmd/api/main.go
agentLogsBucket = flag.String("agent-logs-bucket", "", "GCS bucket for agent build logs")
agentTimeoutSeconds = flag.Int("agent-timeout-seconds", 3600, "Seconds to allow agent to run")
rebuildJobName = flag.String("rebuild-job-name", "", "Name of the pre-created Cloud Run Job for rebuilds")
analyticsURI = flag.String("analytics-uri", "", "URI for snapshots (supported schemea: gs, file). Empty disables /snapshot/rollup")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be set in terraform? And does the orchestrator need to be granted access?

// Rollup scans the source and writes the snapshot database to the configured
// analytics destination, replacing the published object wholesale.
func Rollup(ctx context.Context, _ RollupRequest, deps *RollupDeps) (*RollupResponse, error) {
if deps.Dest == nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also check for deps.Source being nil?

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.

2 participants