Skip to main content

GoCPG storage schema

Inspect GoCPG architecture result tables in a local DuckDB and distinguish missing findings from missing data before interpreting a run.

GoCPG

This reference helps developers and operators inspect a local CPG or investigate an architecture audit discrepancy. It explains how to check that architecture run tables exist and how to distinguish missing data from a run with no findings.

GoCPG owns writes to the project DuckDB. Application consumers should read through gRPC. The gocpg query command is for local diagnostics and integration checks; it does not replace the API contract.

This reference covers architecture result tables. It does not enumerate core graph nodes and edges; application consumers should use the gRPC contracts.

Architecture result tables

Architecture result tables
Table Stored data
cpg_architecture_components Components and their stable UIDs for one run.
cpg_architecture_memberships File and symbol classification with selector provenance.
cpg_architecture_edges Direct and transitive component dependencies.
cpg_architecture_runs Completed run identity: commit, model, rules, completeness and mode.
cpg_architecture_result_heads Pointer to a project’s latest completed canonical run.
cpg_architecture_findings Findings bound to a run ID and stable fingerprint.

An empty cpg_architecture_findings result means there are no findings for the selected run. A missing table means the database has an older or incomplete schema. It cannot establish that the architecture passed a check.

Inspect a local database

Open PowerShell at the root of a CodeGraph source checkout. You need a GoCPG binary with DuckDB support and an existing CPG. Replace <path-to-cpg.duckdb> with your database path. This command reads the schema and does not change source files:

.\gocpg\gocpg.exe query --db "<path-to-cpg.duckdb>" --sql "SELECT table_name FROM information_schema.tables WHERE table_name IN ('cpg_architecture_runs', 'cpg_architecture_result_heads', 'cpg_architecture_findings') ORDER BY table_name"

A successful check returns three table names. If the database does not exist, create a CPG using gocpg parse or a managed update. If fewer than three rows are returned, update GoCPG and recreate or migrate the database through the supported runtime process.

Implementation check

Run this command from the gocpg directory in the source checkout. It requires Go and the DuckDB build dependencies described in the environment setup. The repository test creates temporary storage, persists a canonical result and checks deterministic export. It verifies the implementation; it is not a procedure for inspecting a user’s database:

go test ./pkg/architecture -run '^TestCanonicalResultsPersistAndExportDeterministicEvidence$' -count=1

Expect ok gocpg/pkg/architecture. Build failures and missing dependencies indicate an environment problem rather than a result about the quality of the analyzed code.

For operational result access and export, use the interfaces and results reference.