Skip to content

feat(artifact-compiler): emit companion_plugin_payload producer seam (#491 slice 2)#240

Merged
chubes4 merged 1 commit into
trunkfrom
feat/companion-plugin-payload-slice2
Jun 27, 2026
Merged

feat(artifact-compiler): emit companion_plugin_payload producer seam (#491 slice 2)#240
chubes4 merged 1 commit into
trunkfrom
feat/companion-plugin-payload-slice2

Conversation

@chubes4

@chubes4 chubes4 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Refs #491 (slice 2 of N). Slice 1 is SSI #492 (merged), which built the consumer: Static_Site_Importer_Companion_Plugin::scaffold() turns a "companion plugin payload" into an installable, theme-independent plugin that houses generated custom blocks (registered from their own block.json) plus preserved island JS. This PR is the producer: it extends the blocks-engine ArtifactCompiler to emit a companion_plugin_payload whose shape exactly matches what slice-1's scaffold() consumes.

This is purely the packaging seam. It does not change mapping/routing — core/html stays the safe fallback, and there is no "generate a custom block instead of core/html" path here (that is a later wire-up / recognizer hook). The producer only packages generated blocks the artifact already declares via block.json (the compiler already detects/validates these — see invalid_block_json / block_json_missing_name).

Payload shape -> slice-1 contract

source_reports.companion_plugin_payload:

  • schema — stamps static-site-importer/companion-plugin/v1 (mirrors SSI's PAYLOAD_SCHEMA) so the consumer can assert conformance.
  • blocks[] — one per detected generated block: name (local slug; SSI namespaces it to ssi-<site>/<name>), block_json (decoded array), render (render.php content), view_js (viewScript content), assets{} (remaining block-dir files keyed by block-relative path). Render / view JS / block.json are excluded from assets so the consumer doesn't write them twice.
  • preserved_js[] — empty slot today; reserved for the JS->plugin wire-up (SSI #488).
  • site_slug / site_name / mu_plugin — derived from the artifact envelope when carried; omitted otherwise (SSI supplies site identity at install time).

Producer behavior

Proven end-to-end

A scratch harness ran the emitted payload through slice-1's real scaffold() (fetched from origin/main): it materializes a complete ssi-acme/... plugin file set (main plugin file, blocks/hero/block.json rewritten to ssi-acme/hero, render.php, view.js, style.css, index.js). Confirms the shape conforms to slice-1 with no slice-1 change required.

Tests

  • composer test:canonical — pass (added contract assertions: payload present with a synthetic block, present without site identity, absent without blocks; render/view/block.json not duplicated into assets).
  • composer parity — pass (125 fixtures).
  • composer test (incl. packaging install-proof) — pass.

DO NOT MERGE.

🤖 Generated with Claude Code

Add the producer half of the companion-plugin / plugin-materialization
keystone (issue #491). Slice 1 (SSI #492) built the consumer
(Static_Site_Importer_Companion_Plugin::scaffold()); this slice packages
the generated block definitions the ArtifactCompiler already detects
(block.json + render + view JS + assets) into a companion_plugin_payload
whose shape exactly matches what scaffold() consumes.

- New CompanionPluginPayload builder collects detected block types plus
  their file contents into per-block entries (name, block_json, render,
  view_js, assets) and stamps the shared consumer schema.
- Payload includes an empty preserved_js slot for the later JS->plugin
  wire-up (SSI #488), and derives site_slug/site_name/mu_plugin from the
  artifact when carried (SSI may override site identity at install time).
- Emitted under source_reports.companion_plugin_payload only when at
  least one generated block exists; absent otherwise (core/html fallback
  unchanged). No mapping/routing changes.

Proven end-to-end against slice-1's real scaffold(): the emitted payload
materializes a complete ssi-<site> plugin file set. Contract tests cover
present-with-block, present-without-site, and absent-without-blocks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chubes4 chubes4 merged commit 2d3da4e into trunk Jun 27, 2026
1 check passed
@chubes4 chubes4 deleted the feat/companion-plugin-payload-slice2 branch June 27, 2026 23:25
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