ART-Compare / Engineering case study

How to prove that two datasets diverged

After a migration, the first pages of two tables can match even when records are missing. ART-Compare defines how rows match and checks the entire selected slice in PostgreSQL. The author uses that bounded problem to test a document-core architecture with explicit ownership of the model, query execution and database connections.

  • Desktop
  • PostgreSQL
  • Read-only
  • 1 Source → N Targets
ART / 01Architecture map
Architecture mapQt sends commands through the Application API. Application Service manages multiple independent session documents and one active SessionRuntime, invokes the Compare module and reads data through a port. PostgreSQL is implemented. Analytics and adapters for Excel, the clipboard and other databases are shown as possible extensions.01 / FACEQt Desktop02 / APIApplication APIApplication ServiceSessionRuntime1 active sessionCompare moduleStreaming comparisonAnalytics moduleConceptADAPTER PORTData source accessPostgreSQLExcelClipboardOther databasesINDEPENDENT SESSIONSSessionDocumentVirtualTableDefinitionSource / TargetsQuerySpec / Match Key

Solid lines show working connections. Dashed lines mark the proposed analytics module and possible adapters.

01 / Concept

One reference, multiple targets

ART-Compare is a local Python and PySide6 desktop application for read-only table reconciliation. The analyst picks a Source, connects one or more Targets, and defines the filters, Match Key and comparison fields. Each Target has its own connection profile. The implemented PostgreSQL slice resolves the target table using the Source schema and table names.

For example, when checking orders after a migration, (tenant_id, order_id) identifies the records while status and amount explain the differences. Missing means an order exists only in Source. Extra means it exists only in Target. Different means the key matched and a compared field differed. The report supports migration investigation. Changing data is a separate task.

Figure 01Source defines the rules for each pair

Pair A

  1. Source · reference
  2. Target A · profile A
  3. Result A

Pair B

  1. Same Source
  2. Target B · profile B
  3. Result B

The same rules apply separately to each pair. A failure on one Target leaves the other successful results available.

02 / Architecture

The Document Core and execution boundaries

SessionDocument is the Document Core of ART-Compare and the source of truth for a session’s domain model. It defines the Source and Targets, the Source’s virtual table definition, shared filters and sort order, the Match Key and the comparison fields. The virtual table describes the logical object, including its columns and types. The provider resolves it against a particular database.

The author chose table reconciliation as a bounded problem for testing the document model and the contracts between components. The proposed next project, ART-Explore, would let users trace how data moves between tables and through transformations. Whether the core can support that richer model is a question for ART-Explore.

Application manages documents and the tab lifecycle. Qt issues commands through the Application API and reads immutable state snapshots, keeping comparison rules outside the interface. The core uses provider-neutral contracts, while the PostgreSQL adapter translates requests into SQL through psycopg.

In the current implementation, SessionRuntime holds temporary state for the active session, including datasets and results. When the user switches tabs, Application releases that state and retains the document. The application-level ConnectionManager owns physical connections by profile ID, so tabs can reuse a shared connection. The document references profiles. Windows Credential Manager stores passwords separately.

Figure 02Ownership of the model, execution and resources

Commands and reads

  1. PySide6 / Face
  2. Application API
  3. PostgreSQL adapter

Document

  1. SessionDocument
  2. Profile ID
  3. Local profile

Execution

  1. Application
  2. SessionRuntime
  3. Datasets and results

SessionRuntime owns temporary session state. ConnectionManager owns physical connections by profile ID. Windows Credential Manager stores passwords.

03 / Architecture principles

Architecture principles: the core, modules and virtual data

The author chose table reconciliation as a bounded experiment. A working scenario makes it possible to follow a data definition through a query to a result and see which parts of the system need to change when the interface, source or comparison rule changes.

Use contracts to keep changes local

Qt calls the Application API, and orchestration uses ports to access data sources. The PostgreSQL adapter implements those ports and keeps SQL and driver details inside its module. As long as the contract holds, changes inside the adapter stay out of unrelated components. Architecture tests enforce import boundaries. The working client is a desktop application. A web client or a game-engine interface could use the same application commands through its own integration layer.

Describe the domain in the document

SessionDocument holds the typed definition of a session, including the logical Source object, Targets, profile references, the query specification and comparison rules. Components take their definitions from this common model. Adding a domain entity starts by defining what it means and where it belongs in the document, then extending the contracts of the operations that use it.

Give different sources a common logical model

A schema and table name locate a physical object. VirtualTableDefinition describes the object the application works with. It gives the object a logical ID, a source reference and typed column definitions. The comparison configuration defines the Match Key separately. The current adapter reads PostgreSQL physical-table metadata and retrieves rows in a separate Dataset. The target model could represent a SQL query, an acquired Dataset, an Excel file or a transformation result as a virtual table. Each source needs an adapter with explicit rules for types, row identity and supported operations. A file adapter would need its own filtering implementation if its contract includes filtering.

Isolate each session’s context

Two tabs can use the same physical table with different filters and Match Keys. Each tab has its own SessionDocument, so editing a filter in one leaves the other intact. One session is active at a time. On a tab switch, Application keeps the tab configurations in the workspace, releases the previous datasets and results, and creates a new SessionRuntime.

Route changes to the model through Application

SessionDocument is the source of truth for the session’s domain state. The UI sends commands and reads immutable snapshots. A draft filter, for example, stays in the interface until confirmation, when Application replaces the specification in the document. The adapter supplies metadata and rows, while execution components take operation parameters from the model. Connections, operation results and external data have their own owners.

Separate model and execution lifecycles

A document can outlive a retrieved dataset, and the next tab may need an existing physical connection. SessionRuntime can therefore be released on deactivation, while ConnectionManager manages connections by profile ID at application level. The .artcmp format stores the session definition so data can be retrieved again. Save and open remain work in progress at the checkpoint recorded in the log. The UI works with application operations, leaving SQL and retrieval strategies behind execution ports.

Publish data only for the current query

When the user changes a filter on the same object, the last successful Dataset remains available as STALE. Application checks that an operation is still current before publishing, so a late response to a superseded query cannot become the current dataset. Selecting a different logical object discards incompatible data. This lets the query model and the visible grid update at different times while keeping their states explicit.

Test the same boundaries in ART-Explore

ART-Explore is conceived as a visual environment for tracing data through tables, datasets and transformations. The hypothesis is that the Document Core and virtual tables will support these new entities and operations within the same fundamental module boundaries. ART-Compare exercises those boundaries in PostgreSQL reconciliation. A graph of transformations is a separate test for ART-Explore.

Figure 03Command paths, model ownership and source access

Client

  1. Qt desktop
  2. Application API
  3. Application Service

Session A

  1. Application Service
  2. SessionDocument A
  3. VirtualTableDefinition A

Session B

  1. Application Service
  2. SessionDocument B
  3. VirtualTableDefinition B

Read path

  1. Application orchestration
  2. Data access port
  3. PostgreSQL adapter

The rows show distinct relationships. The client calls the API, Application manages independent documents, and the adapter implements a read port. A web client or game-engine interface could connect at the API boundary through its own integration layer.

04 / Execution

Two read paths with different guarantees

For preview, Application retrieves a Dataset with an explicit row limit, 1,000 by default. PostgreSQL applies typed filters and sorting. During a refresh of the same object, the last successful Dataset stays available as STALE. A successful read replaces it as a unit.

Compare applies the same logical filters across the full selected slice. To read every batch on a given side from one snapshot, Application reserves the connections and opens a read-only REPEATABLE READ transaction at each endpoint. Preflight then checks keys across the entire scope. Invalid or duplicate canonical keys prevent streaming. Server-side cursors deliver batches in a common order, and the merge engine walks the two sequences by key.

Each snapshot is consistent within its own transaction. If the databases change during reconciliation, the result can reflect different points in time at the two endpoints. Batch reads bound the engine buffers. The in-memory result store grows with the number and width of differences.

Figure 04How QuerySpec feeds a dataset and a report

Preview

  1. Filters + sort + LIMIT
  2. Dataset
  3. Data grid

Compare

  1. Filters + preflight
  2. Ordered streams → merge
  3. Result Store → Compare grid

The row limit and user sorting belong to preview. Compare orders rows by the canonical Match Key.

05 / Author’s role

The author’s role and engineering decisions

The project author made all architectural decisions. That included modeling the reconciliation domain, drawing component and ownership boundaries, and defining key-matching rules and the lifecycles of sessions, connections and results. Acceptance criteria included rejecting ambiguous keys and publishing outcomes independently for each Target.

AI agents implemented the software under the author’s direction. The author scoped the work, specified contracts, invariants, constraints and acceptance criteria, checked the results and decided how the architecture would evolve. The log below distinguishes implemented behavior, automated checks and manual acceptance.

06 / Build Log

Engineering Build Log

Chronology drawn from the private ART_Compare repository’s Git history, architecture decisions and verification records.

  1. 10–12 September 2026 · ADR-0001–0005, ADR-0007–0009 · 913d3f8, ea39eae

    Assign ownership before adding features

    The first vertical slice connected Qt, Application and PostgreSQL. Source defined the logical object, while Target supplied the connection on which to resolve it. Part 5 records manual acceptance of data acquisition against real PostgreSQL. It covers the path from object selection to the UI grid.

  2. 12–13 September 2026 · dc31868, 200b0c6, 8715570

    Make the query part of the model

    Filters and sort order became one Source-owned DatasetQuerySpec. The filter editor keeps a draft until confirmation, distinct value lookup is bounded, and Application distinguishes an absent dataset from a current or stale one. A configuration change, a query and the publication of a result each have distinct states.

  3. 13–16 September 2026 · 8409071, 58856d9, 5033fa7, 410f654

    Prove the keys can be matched before emitting a difference

    PK and UNIQUE describe constraints within a table. The application Match Key defines row identity across the two endpoints, even when their types differ. Source types define canonicalization. If two raw values collapse to one canonical key, the match becomes ambiguous. Preflight rejects that scope, and the merge engine checks order and uniqueness again while reading.

  4. 21–23 September 2026 · bd0776e, a6ee9dd, e981f64 · ADR-0011

    Publish independently for each Target

    Application runs comparisons in the background and tracks progress per Target. After success, Compare reads a bounded page of the published result without another SQL query. Different stores the Target projection and the before-and-after values of changed fields. Missing uses the Source row, and Extra uses the Target row. Equal rows contribute to counters.

    The presentation cache is keyed by run_id. A new run can finish between UI polls, so the interface handles a direct transition between two completed results. The documentation records 389 of 389 automated tests for this slice. Manual end-to-end acceptance of the full Compare workflow remained a separate task at that checkpoint.

  5. 6 November 2026 · 0a2a8d3, 392761b · WIP

    Save the reconciliation recipe as .artcmp

    Versioned JSON stores the Source, Targets, query specification and comparison settings. On open, the document is validated before the workspace changes and receives a fresh runtime identity. Rows, results and passwords stay out of the file.

    At GitHub revision 392761b, save and open are still in progress. The report records 429 passing tests out of 430 and pending integration of Save As into the menu. This is the November checkpoint. The 389 of 389 result belongs to the September Compare slice.

← Back to projects