Skip to content

[db] Close the review of the generated schema - #199

Merged
mcraveiro merged 10 commits into
mainfrom
feature/schema-review-fixes
Nov 23, 2026
Merged

mcraveiro merged 10 commits into
mainfrom
feature/schema-review-fixes

Conversation

@mcraveiro

Copy link
Copy Markdown
Member

Follow-up to #196. This closes the review's should-fix findings 1, 2 and 4 to 7, and nits 3, 11 (enum width only), 12, 13, 14 and 15. The #195 findings on the loader and context builder are left for a later change.

What changes

1. CI checks compass with the compass it built. On a pull request, the release build runs compass check --no-blame --set document_index.enabled=false --ratchet HEAD^1. HEAD^1 is the first parent of the merge commit, which is main as merged, so fetch-depth: 2 is enough. document_index is off because its output goes under the ignored build/output/, so a fresh checkout always lacks it. Pushes and scheduled runs skip the step. Main holds 70 findings that only a base excuses, so a plain check there would always fail, and main changes only through pull requests. The relevance guard now builds a change to a modeling/ directory, to share/, or to .compass.org. Before, it skipped those as documentation, and they are exactly what compass generates from.

2. check --ratchet keeps going when the merge base cannot run a codec. A codec that throws during a run now throws codec::types::codec_failure, which names the codec and keeps its message. The ratchet catches it, checks the base again with that codec off, and prints <codec> did not run at the merge base (<why>), so its findings at HEAD are new. Decision: all of that codec's HEAD findings count as new. Nothing at the base can excuse them, and the change that makes the codec runnable owns what it reports. The usual case is a library added together with its generated outputs. That case has no findings, so it passes.

4. The catalog comparison covers every kind of object. It adds collation; triggers; row security and policies; persistence and storage parameters; privileges on schemas, relations, columns, functions and types; default privileges; sequence options; enum, domain and range types with their labels; comments; view definitions; columns of every relation kind; extensions; and the rows of every table except compass.migration. A new probe test builds schema.sql with and without 21 kinds of object and requires the two catalogs to differ.

5 and 6. The migrations are tested on rows, against the released schema. The test takes a database to the last release through the released migrations, puts one fully filled row in every table, and requires the later migrations to apply. Each table the release retains is pinned in the test as released_retained. It must keep every row and every column, with type and collation, unless allowed_losses names the column with the :ID: of the document that decides the loss. I put the allowance in the test, not in a marker in the migration, for three reasons. The check lives in the test. The edit shows in the pull request's diff. And a released migration is frozen, so a marker in it could never be added or removed. Because the set is pinned, a model that drops the retained profile no longer drops its table from the check.

7. The freeze test. It now looks up every released version and REQUIREs it to exist. It also pins the blob ID of bookkeeping_sql() as v0.0.13 shipped it.

Nits.

  • 3: origin() gets the checkout root and names the library that actually holds the template. compass generate now prints share/masd/templates/....
  • 11: a generated enum is : std::uint8_t again. This needed one token in masd_context.cpp for the <cstdint> include, plus the template change.
  • 12: copy_writer::field(bool) writes t/f. It is a constrained template, so a pointer cannot silently match it.
  • 15: one case covers each field overload.
  • 13: compass.bench uses the generated step_outcome_of, and corpus.cpp has one integer parser.
  • 14: the stale profile prose and the tsv expression in the models are fixed.

Evidence

The new tests fail on main and pass here:

  • Each of the review's ten probes appended to schema.sql alone: main's catalog test passes all ten. The new test fails all ten, and also fails an added view and an added partitioned table.
  • A migration 3 that adds a NOT NULL column with no default, drops activity.run.tester, or deletes activity.attached's rows (with schema.sql matching where needed): main's tests pass. The new rows test or retained test fails.
  • Removing released migration 2: main's freeze test passes, though main's catalog test fails. The new freeze test fails.
  • Editing bookkeeping_sql(): main passes. The new freeze test fails.
  • The new ratchet test exits 2 on main's sources. Here it exits 1 with the output not generated, and 0 once generated.
  • The new attribution test names extra/templates/ on main's sources and lib/templates/ here.
  • The CI command in a fresh --depth 2 clone exits 0. After a model column is retyped and a template's org page is edited without regenerating, it exits 1, with codegen/drift on schema.sql and tangle/drift on the template.

Integration, after merging origin/main (#197, #198):

  • compass generate wrote nothing committed.
  • compass check --ratchet --no-blame: 0 new, 70 excused.
  • ctest: 1707 of 1707 pass.

The task page task_close_the_schema_review.org records each measurement.

🤖 Generated with Claude Code

mcraveiro and others added 10 commits November 23, 2026 18:40
The catalog comparison now covers triggers, row security and policies,
collations, identity options, storage parameters and persistence,
comments, types and enum labels, privileges, default privileges, views
and the columns of every kind of relation, and the rows of every table.
A probe test proves each kind is seen.

The migrations since the last release now run on a database at that
release holding a row in every table. A retained table pinned at the
release must keep every row and column across them unless the loss is
named in allowed_losses with its decision. The freeze test requires each
released migration to be present and pins bookkeeping_sql().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A codec that throws during a run now throws codec_failure, which names
it. check --ratchet checks the merge base again without that codec,
says so, and counts the codec's findings at HEAD as new, instead of
exiting 2 when HEAD adds a library the base lacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
origin() named the last library of the checkout for every template, as
it could not look into the checkout. It now gets the checkout's root and
names the last library that holds the template, so compass's outputs
name share/masd/templates rather than the project library.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A generated enum is over std::uint8_t again.
- copy_writer::field writes a bool as t or f, and a test covers each
  overload of field.
- compass.bench parses a step outcome with the generated parser, and
  corpus.cpp parses both integer types with one function.
- The model prose no longer says the profiles fix features they do not
  assign, and the section model shows the tsv expression the insert runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A release build now runs the built compass on the checkout: check
--ratchet against the merge commit's first parent on a pull request,
plain check elsewhere. It fails on generated drift and diagnostics, so a
model or template edited without compass generate no longer passes. The
relevance guard builds a change to the models, the MASD library or
.compass.org, which it skipped as documentation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main holds 70 findings that only a base excuses, so a plain check on a
push or a schedule would always fail; main changes only through pull
requests. document_index is off in the check: its output is not
committed, so a fresh checkout always lacks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mcraveiro
mcraveiro merged commit d3f3282 into main Nov 23, 2026
4 checks passed
@mcraveiro
mcraveiro deleted the feature/schema-review-fixes branch November 23, 2026 21:41

This branch was previously deployed

1 inactive deployment
CI — ebd394d5 Deployed Nov 23, 2026 by mcraveiro via linux-clang-release-ninja #186
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.

1 participant