Skip to content

1.0 hardening: upstream-drift fixes, hydration correctness, Laravel floors - #3

Merged
serpentblade merged 6 commits into
mainfrom
release/1.0-hardening
Sep 29, 2026
Merged

serpentblade merged 6 commits into
mainfrom
release/1.0-hardening

Conversation

@serpentblade

Copy link
Copy Markdown
Contributor

Pre-1.0 deep dive. Validated locally on Laravel 13.34 (latest), 13.33.0 (floor, lowest deps) and 12.69.2 (floor, lowest deps); this PR runs the full matrix.

Hydration correctness (independent of Laravel version)

  • Query-time withCasts() was ignored on hydrated rows; a runtime setTable() on the query's model produced rows whose save()/delete() hit the class table. The slim newFromBuilder now carries the prototype's table + casts like vanilla's newInstance(). The caveat for this is removed.
  • getTable() memoizes the derived table name per class, so correct hydration costs ~5–10%/row over the old path.

Upstream drift since the last CI run (June)

Change First in Caught by existing tests?
#[Refreshes] dropped by hydration snapshot 13.33 no
resolveClassAttribute key includes property 13.21 yes
resolveClassAttribute walks traits 13.22 no
Request::all() input-over-files order (probed; 12.x unchanged) 13.26 no
route params escape %/?/# 12.69.2 / 13.31 no
style default gets ; in attribute merge 12.63 / 13.19 yes

Guardrails

  • HasGreaseWholeStateParityTest: compares the entire model instance state against vanilla (cold / warm / hydrated), plus a tripwire that fails when Laravel adds an Eloquent attribute class.
  • CI runs weekly on a schedule + lowest-deps leg for the 13 floor.
  • Requires ^12.69.2 || ^13.33. Livewire proof now also covers v4.

🤖 Generated with Claude Code

serpentblade and others added 6 commits June 29, 2026 10:25
…rked)

The clean_input_ab "large" arm was wide-and-shallow (100 leaves, depth 3),
which misses the cost dimension that actually motivates the tier: vanilla's
TransformsRequest rebuilds the dotted $keyPrefix.$key at every node, so the
penalty grows with DEPTH, not just leaf count. Add a ProseMirror/TipTap-style
deep content post (1,125 leaves, depth 17) — the shape a real CMS body submits
— and surface depth alongside leaf count in the report. Vanilla burns ~1.2ms of
pure middleware on it before the controller runs; greased holds ~−35%.

The deep arm fingered the inherited per-node prefix concat as the shared
bottleneck. Spiked an all-shallow except fast path (skip the prefix build +
except check below depth 1 when every except pattern is a dot-free, wildcard-
free literal — the default): −9.1% vs shipped on the deep payload, free
elsewhere, byte-identical incl. the adversarial nested-'password' case. PASSED
for now (−9% on a slice-of-a-slice, macOS numbers, a third overridden walk
method of parity surface) — documented in LEADS.md with the mechanism captured
for a Linux-confirm revisit. Spike itself was throwaway.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…reshes]

The slim newFromBuilder built hydrated rows from class defaults, skipping the two
things vanilla's newInstance() carries from the *prototype*:

- its casts — so query-time casting (Model::query()->withCasts([...])) was silently
  ignored on every hydrated row;
- its table — so a runtime setTable() on the model a query is built from produced
  rows whose save()/delete() targeted the class table.

Both now match vanilla. The casts check is a pointer compare until the prototype
diverges; getTable() memoizes the derived (no-$table) name per class so correct
hydration costs ~5-10%/row over the old path instead of a per-row pluralStudly().

Also snapshot 13.33's $refreshes in initializeModelAttributes (the warm path
dropped it: every model after the first per class lost refresh-after-write).

HasGreaseWholeStateParityTest is the net that catches this class of bug: it
compares the entire instance state against vanilla (cold / warm / hydrated) for a
model carrying every Eloquent class attribute, with a tripwire that fails when
Laravel adds an attribute class the fixtures don't cover.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Laravel patch releases since the last CI run changed methods Grease overrides:

- resolveClassAttribute (13.21/13.22): key includes the property; attributes on
  traits are resolved. Cache reshaped to [class][attr][property], single fetch —
  still ~11% faster than vanilla warm (benchmarks/class_attribute_ab.php).
- Request::all (13.26): input keys keep position and win a file collision.
  12.x kept the old merge, so the order is behaviour-probed once per process.
- route() params (12.69.2/13.31): %, ? and # are escaped; the URL fast path
  emitted them raw, truncating the path into a query string / fragment.
- ComponentAttributeBag::merge (12.63/13.19): a style default gets its ';'.

Each has parity cases that fail without the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Require each supported major's current patch line so Grease mirrors the latest
  vanilla behaviour without per-patch branches.
- CI: weekly schedule + workflow_dispatch (upstream drift now fails within days,
  not at the next push), and a lowest-deps leg proving the 13 floor.
- Livewire proof widened to ^3.0 || ^4.0 (normalize v4's wire:name, which is
  the twin components' own names).
- Pipeline probe subprocess ignores E_DEPRECATED so old deps on a new PHP can't
  corrupt its JSON.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vanilla re-derives Str::snake(Str::pluralStudly()) on every getTable() for a
convention-named model: ~2.2us/call vs ~81ns memoized (-96%, macOS), and a
20-row get() calls it 23 times. Every existing fixture declares $table, so no
other bench exercises the default Laravel shape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tTable only

Review of #3: the trait-level getTable() override froze an instance-dependent
parent getTable() (sharding) to its first result, and collided fatally with any
other trait defining getTable() (`use AsPivot, HasGrease;` no longer loaded).

Drop the trait getTable() entirely; newFromBuilder memoizes the derived name per
class only when the model inherits vanilla Model::getTable(), and calls any
override per row exactly as vanilla. Tests: sharded override parity across
prototypes, AsPivot + HasGrease composes and hydrates identically.

Bench re-pointed at what's optimized: convention-named hydration, -74% vs
vanilla with the correct table (macOS; confirm on Linux).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@serpentblade
serpentblade marked this pull request as ready for review September 29, 2026 18:36
@serpentblade
serpentblade merged commit 1b398e4 into main Sep 29, 2026
9 checks 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.

1 participant