Skip to content

feat!: commit flat wire-protocol schema documents and lattice:schema - #455

Draft
bambamboole wants to merge 3 commits into
mainfrom
feat/wire-schema-artifacts
Draft

feat!: commit flat wire-protocol schema documents and lattice:schema#455
bambamboole wants to merge 3 commits into
mainfrom
feat/wire-schema-artifacts

Conversation

@bambamboole

Copy link
Copy Markdown
Contributor

Revives the schema-artifact layer from the stale feat/wire-schema-documents branch, ported onto the core wire model (#454).

  • Lattice\Core\JsonSchema\{FlatProjection, SchemaBundler, SchemaDocumentWriter}: every wire source gets a flat, self-contained committed document at packages/<name>/resources/schema/<name>.schema.json (12 files, no cross-document refs — only the recursive envelope core is copy-once per file), merged into packages/framework/resources/schema/lattice.schema.json (356 defs, npm-exported as @lattice-php/lattice/schema/lattice.schema.json).
  • lattice:schema exports a consumer app's merged document (committed vendor docs + fresh reflection of the app's own discover paths, app defs marked origin: "app"); composer types chains schema → typescript.
  • Fixes a real gap: buildAll() per-source documents never emitted the envelope core, strict unions, or the RemoteManifest contract despite the docblock claiming so. Opt-in via $includeFrameworkEnvelope so TypeScript emission stays byte-identical (those defs are hand-written on the TS side).
  • Tests: opis/json-schema (dev) validates the merged document and a real captured page payload against #/$defs/PagePayload; snapshot test byte-compares the committed artifact; CI regenerates and diffs all schema files alongside generated.ts.
  • Docs: new advanced/wire-protocol page (entry points, x-lattice vocabulary, structured-output usage, lattice:schema).

Gates: full Pest suite (1714 passed), PHPStan level 8 both configs, composer types idempotent, npm run check green, docs build green.

Adds the projection machinery (FlatProjection, SchemaBundler, SchemaDocumentWriter
in Lattice\Core\JsonSchema), the lattice:schema command, and its two profiles:
ExportSchemaProfile merges installed packages' committed schema documents with a
fresh reflection of the app's own wire types for consumer apps, while the
workbench's BaseSchemaProfile regenerates every package's committed document plus
the merged framework bundle. WireModelBuilder::buildAll() grows an opt-in
$includeFrameworkEnvelope flag so the framework document can carry the recursive
envelope core, strict unions, and the remote-manifest contract as real, resolvable
defs for schema consumers without changing what the TypeScript emitter sees.

opis/json-schema is added as a dev dependency to validate the generated documents
in tests. composer's "types" script now runs lattice:schema before lattice:typescript.
One flat, self-contained .schema.json per wire-contributing package (core, ui,
form, table, action, media, tree, calendar, search, api-reference,
signature-example), plus the merged packages/framework/resources/schema/lattice.schema.json
bundle — generated by `composer types` (lattice:schema) and idempotent.
Unit-tests FlatProjection's dereferencing rules and feature-tests the schema
bundler, the per-package documents, the flat committed artifacts (opis-validated,
no cross-document refs, envelope-core carried where referenced), the
lattice:schema command's app/vendor merge behavior, and a byte-stable snapshot of
the committed bundle against the builder.

CI's generated-types job now regenerates and diffs every .schema.json alongside
generated.ts. Adds the wire-protocol docs page describing the PHP-reflection to
TypeScript/JSON-Schema fan-out, sidebar entry, and a cross-link from the remote
components page to the RemoteManifest schema contract.
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.34211% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...amework/src/Support/Schema/ExportSchemaProfile.php 97.43% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@bambamboole
bambamboole marked this pull request as draft August 15, 2026 13:03
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