Skip to content

feat: verify the database server at startup - #19

Merged
cardmagic merged 2 commits into
mainfrom
agent/database-version-checks
Aug 10, 2026
Merged

feat: verify the database server at startup#19
cardmagic merged 2 commits into
mainfrom
agent/database-version-checks

Conversation

@cardmagic

Copy link
Copy Markdown
Owner

Roadmap milestone 4.

What it adds

Each adapter reports server_version against minimum_server_version, the oldest server Solid Objects is actually exercised against: PostgreSQL 13, MySQL 8.0, SQLite 3.35. MySQL additionally verifies that Solid Objects tables use InnoDB, because a non-transactional engine would silently break fenced commits, which is the property the whole activation model rests on.

The doctor surfaces this as a database_server check.

Warn, do not refuse

The check warns rather than failing, and an unsupported server does not make the report unhealthy. Refusing to boot on an untested server would be a worse failure than running on one: the minimums record what has been exercised, not what is known to break. Verification failures are also caught and reported rather than raised, so an unreadable version cannot take down a runtime role.

A bug the PostgreSQL run caught

PostgreSQL's database_version returns a packed integer, 170010 for 17.10. Comparing that against 13 passes, but so would 90600 for PostgreSQL 9.6, making the check useless on the adapter it matters most for. The adapter now normalises it, and a test asserts the reported version is a human version rather than a packed integer, so this cannot regress silently.

Tests

Ten tests: the version is reported and is not a packed integer, an old PostgreSQL server is still detected, a supported server passes, an old server is reported rather than raised, an unreadable version does not raise, the doctor passes and warns appropriately, an unsupported server does not fail the report, and the two MySQL InnoDB cases.

Verified against SQLite and a real PostgreSQL 17 locally; MySQL paths run in CI.

Roadmap

Milestone 4 removed and recorded under "Implemented and tested", with the remaining milestones renumbered, per the requirement in #15.

Compatibility

No database change, no migration, no initializer regeneration. Additive adapter methods. The doctor gains a check that can warn on servers it previously said nothing about; nothing fails that did not fail before.

bundle exec rake                                     # 322 runs, 0 failures
SOLID_OBJECTS_DATABASE_URL=postgresql://... rake test # 322 runs, 0 failures

@greptile-apps

greptile-apps Bot commented Aug 10, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds non-blocking database compatibility checks to the doctor.

  • Reports adapter-specific server versions against tested minimums.
  • Normalizes PostgreSQL’s packed version representation.
  • Checks MySQL Solid Objects tables for InnoDB storage.
  • Adds generated signatures, integration coverage, and roadmap and changelog updates.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
lib/solid_objects/database_adapter.rb Adds shared server-version reporting and unsupported-server reason collection.
lib/solid_objects/database_adapters/mysql.rb Adds the MySQL tested minimum and InnoDB table-engine verification.
lib/solid_objects/database_adapters/postgresql.rb Adds the PostgreSQL tested minimum and converts packed database versions into human-readable Gem versions.
lib/solid_objects/database_adapters/sqlite.rb Adds SQLite’s tested minimum server version.
lib/solid_objects/doctor.rb Adds a non-failing database_server check using one observed server version.
test/integration/database_version_test.rb Covers version normalization, warning behavior, single observation, and MySQL engine checks.

Reviews (2): Last reviewed commit: "fix: observe the server version once" | Re-trigger Greptile

Comment thread lib/solid_objects/database_adapter.rb Outdated
Comment on lines +54 to +56
if minimum && server_version < minimum
reasons << "#{self.class.name.demodulize} #{server_version} is older than " \
"Solid Objects requires, which is #{minimum}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Repeated server-version reads

unsupported_server_reasons reads server_version separately for the comparison and warning text, and the doctor reads it again for a passing message. A transient failure on a later read replaces an already determined unsupported-version result with a generic verification error, while normal checks perform an avoidable extra database round trip; preserve one observed version for both the status and message.

Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/solid_objects/database_adapter.rb
Line: 54-56

Comment:
**Repeated server-version reads**

`unsupported_server_reasons` reads `server_version` separately for the comparison and warning text, and the doctor reads it again for a passing message. A transient failure on a later read replaces an already determined unsupported-version result with a generic verification error, while normal checks perform an avoidable extra database round trip; preserve one observed version for both the status and message.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Valid. The version was read for the comparison, again for the message, and a third time by the doctor for its passing text. Beyond the wasted round trips, a transient failure on a later read would have replaced an already determined unsupported-version result with a generic verification error, which is the worse half of the problem.

One observed version now flows through: the doctor reads it once and passes it to unsupported_server_reasons, which keeps its no-argument form for direct callers. A test asserts the doctor observes the version exactly once.

@cardmagic

Copy link
Copy Markdown
Owner Author

@greptileai review

Each adapter now reports its version against the oldest server Solid Objects is exercised against, and MySQL additionally confirms Solid Objects tables use InnoDB, since a non-transactional engine would silently break fenced commits. The doctor reports this as database_server and warns rather than failing, because refusing to run on an untested server would be a worse failure than running on one. PostgreSQL reports a packed integer, so it is normalised: comparing 170010 directly would make a 9.6 server look newer than any minimum, which the PostgreSQL run caught.
The reasons list read the version for its comparison and again for its message, and the doctor read it a third time for the passing text. A transient failure on a later read would have replaced an already determined result with a generic verification error, and every healthy check paid extra round trips. One observed version now decides both status and message.
@cardmagic
cardmagic force-pushed the agent/database-version-checks branch from 49f920b to f4d302e Compare August 10, 2026 14:26
@cardmagic
cardmagic merged commit 3d49fed into main Aug 10, 2026
18 checks passed
@cardmagic
cardmagic deleted the agent/database-version-checks branch August 10, 2026 14:26
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