Skip to content

feat: schema switches, schema-shape file and drift detection (phase 2b) - #6

Merged
imanimanyara merged 7 commits into
mainfrom
feat/phase-2b-switches
Nov 10, 2026
Merged

imanimanyara merged 7 commits into
mainfrom
feat/phase-2b-switches

Conversation

@imanimanyara

Copy link
Copy Markdown
Member

Summary

Phase 2b of the settings design: every schema switch, the schema-shape file, and the Phase 2 follow-ups.

  • Non-default values of every switch, defaults unchanged: identity slug_per_row / uid_only; ids.type uuid / ulid (following db-tools unless set) and typed owner keys; dedicated stores with a fallback store; table prefix and per-table names; the optional settings_definitions table with sync-definitions; JSON translations; soft deletes with restore-on-set, for stores and categories.
  • database/settings-schema.php records the shape install produced; migrations and the runtime read it, and doctor reports drift against it.
  • Pairwise switch matrix (10 shapes covering all 141 value pairs) run on SQLite, MySQL and Postgres; the full product (576 shapes) runs weekly and on dispatch.
  • Audit queries: $settings->audit() with filters, cursor and paging, gated by view_audit.
  • A plain set() retries once after a write conflict (writes.retry_on_conflict); version-named writes never retry.
  • Prune commands gated by a new prune ability and audited; schema readiness flushes on stancl/tenancy and spatie/laravel-multitenancy tenant events (by event name, no dependency).

Checks run locally

  • Pest (SQLite): 404 passed (1554 assertions); coverage 97.1 %; mutation 72.08 %; full matrix 577 passed
  • PHPStan max, Rector, Pint: clean
  • Guards proven red: restore branch, prune gate, view_audit gate, is_system skip, pairwise coverage, retry, deleted_at drift, id-type drift

Add the non-default value of every schema switch (identity modes, uuid/ulid
keys, typed owner keys, dedicated stores, soft deletes with restore-on-set,
JSON translations, the definitions table), record the produced shape in
database/settings-schema.php and read it instead of live config, and report
drift in doctor. Add a pairwise switch matrix (10 shapes, 141 pairs) on
SQLite/MySQL/Postgres and a weekly full product, audit queries via
$settings->audit(), a single retry for plain set() after a conflict, the
prune ability, and readiness flushes on tenancy events.
Copilot AI balanced review requested due to automatic review settings November 9, 2026 21:20

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Comment on lines +85 to +107
name: Schema switches · full product
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 20
env:
LARANAIL_SETTINGS_MATRIX: full
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
steps:
- uses: actions/checkout@v7

- name: Setup PHP 8.4
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
with:
php-version: '8.4'
extensions: dom, curl, libxml, mbstring, zip, fileinfo, pdo, sqlite3, pdo_sqlite
coverage: none
tools: composer:v2

- name: Install dependencies
run: composer update --prefer-dist --no-interaction --no-progress

- name: Run the full switch matrix
run: vendor/bin/pest --group=matrix
Both were generated by make-store test runs during phase 2 and committed by mistake in 1dba487; nothing references them.
Laravel appends fluent indexes after every other command, so with uuid or ulid ids PostgreSQL saw the parent_id foreign key before the primary key it references (SQLSTATE 42830). The audit and prune tests no longer write non-JSON into a json column or compare JSON text byte for byte, which MySQL and PostgreSQL do not preserve.
Phase 2b's end-to-end matrix covers almost every line, so every mutant re-ran it and the job hit its 45-minute limit. The shapes stay tested in the Tests workflow; the limit rises to 60 minutes.
Whole-package mutation passed 45 minutes once phase 2b landed. Pull requests now mutate the src/ files they add or modify (in parallel, 15-minute limit); the full run moves to a weekly schedule and manual dispatch.
…rocesses

A pull request touching 35 src files produced 2,572 mutants and still passed 15 minutes on Xdebug with four processes. PCOV collects coverage several times faster, and restoring Pest's per-mutant cache means a re-run only tests what changed.
…tation

With eight processes, one worker's install test deleted config/laranail/settings.php while another was booting. Those tests are grouped shared-app and run in the sequential Tests workflow.
@imanimanyara
imanimanyara merged commit 953b531 into main Nov 10, 2026
15 checks passed
@imanimanyara
imanimanyara deleted the feat/phase-2b-switches branch November 11, 2026 17:52
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