Skip to content

feat: publish v1 SQL contract, stable read views, and writable-table contract (CR3) - #17

Merged
mwhitham merged 2 commits into
mainfrom
cursor/sql-contract-cr3-2820
Oct 16, 2026
Merged

mwhitham merged 2 commits into
mainfrom
cursor/sql-contract-cr3-2820

Conversation

@mwhitham

Copy link
Copy Markdown
Owner

Implements CR3 from the contribution-readiness plan (step after merged PR #16 / CR1–CR2).

What changed

  • Plain SQL migration: spec/sql/migrations/001-initial.sql is generated from the TypeScript migration source (pnpm generate:sql-contract).
  • Stable read views: sql_v1_database_info, sql_v1_current_records, sql_v1_active_records, sql_v1_record_revisions, and sql_v1_record_deletions are created during schema install.
  • Writable-table contract: spec/sql/contract.json and spec/sql/README.md document stable writable tables, internal tables, required pragmas, migration rules, and transaction recipes (D125).
  • Drift checks: pnpm check:schema-drift and tests/v1-sql-contract.test.ts verify generated files stay fresh and that createDatabase() matches a sqlite3-applied migration.
  • Progress: build-history/v1.0.0/progress.md marks CR3 done.

Out of scope (CR4): ath migrate, interactive migration prompts, and backup flows are not part of this PR.

Verification

pnpm check:public-data && pnpm typecheck && pnpm test && pnpm build
Open in Web Open in Cursor 

Add generated spec/sql migrations and contract metadata, stable sql_v1_* read
views, schema drift verification, and CR3 progress tracking.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: Michael Whitham <mwhitham@users.noreply.github.com>
@mwhitham
mwhitham marked this pull request as ready for review October 15, 2026 23:18
@mwhitham
mwhitham requested a balanced review from Copilot October 15, 2026 23:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Initialization and transaction guidance need corrections so direct clients create valid files and preserve correct state.

3 open findings
What changed in this PR

Implements CR3 by publishing Athletic Standard’s v1 SQL contract for direct SQLite clients, building on CR1–CR2 enforcement.

Changes:

  • Publishes generated SQL migrations and writable-table guidance.
  • Adds five stable read views.
  • Adds contract generation, drift checks, and integration tests.
File Description
tests/​v1-sql-contract.test.ts Tests SQL contract compatibility and enforcement.
src/​db/​sql-contract.ts Defines public contract metadata and transaction recipes.
src/​db/​migrations/​read-views.ts Defines five stable read views.
src/​db/​migrations/​001-initial.ts Installs read views with the schema.
spec/​sql/​README.md Documents direct-client requirements.
spec/​sql/​migrations/​001-initial.sql Publishes the generated SQL migration.
spec/​sql/​contract.json Publishes machine-readable contract metadata.
scripts/​generate-sql-contract.ts Generates contract artifacts.
scripts/​check-schema-drift.ts Checks artifact freshness and schema parity.
scripts/​check-public-data.ts Updates the approved synthetic fixture hash.
package.json Adds generation and drift-check commands.
build-history/​v1.0.0/​progress.md Marks CR3 complete.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/db/sql-contract.ts Resolved
Comment thread src/db/sql-contract.ts Resolved
Comment thread spec/sql/README.md Resolved
Document per-transaction defer_foreign_keys, child collection replacement,
and application_id initialization. Extend drift checks and contract tests.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: Michael Whitham <mwhitham@users.noreply.github.com>
@mwhitham
mwhitham merged commit 7bfcfb5 into main Oct 16, 2026
1 check passed
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.

3 participants