Skip to content

feat(components): preset library — EcsFargateComponent, LambdaComponent, SingleHostComposeComponent (#566) - #590

Merged
lex00 merged 1 commit into
mainfrom
feat/566-preset-library
Jul 3, 2026
Merged

lex00 merged 1 commit into
mainfrom
feat/566-preset-library

Conversation

@lex00

@lex00 lex00 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Closes #566

Summary

Phase 4 preset library (epic #551 §"6. Presets (Level 2 reuse)"): named composition builders that expand to a full, valid Component, mirroring the shipping pattern in lexicons/temporal/src/composites/apply-op.ts (a function returning a composed contract, not a new orchestrator behavior).

Three presets, covering the three archetypes' most common shapes:

  • EcsFargateComponent({ name, service, healthPath, sharedAlbStack, ... }) — packages/core/src/components/presets/ecs-fargate.ts. Expands to the ALB/ECS shape (docker-build → publish-image → cfn-deploy [+ optional shared-ALB stackOutput() cross-stack wiring] → ecs-update-service → wait-steady-state + health-gate, with the same rollback-previous compensation phase). Re-derives pilots/alb-ecs.pilot.ts's hand-composed searchService byte-for-byte (as data).
  • LambdaComponent({ name, functionName, alias, ... }) — presets/lambda.ts. Expands to the container-image Lambda shape (docker-build → publish-image → lambda-deploy → health-gate, no CloudFormation at all). Re-derives pilots/lambda.pilot.ts's hand-composed imageProcessor byte-for-byte.
  • SingleHostComposeComponent({ name, healthPath, healthPort, ... }) — presets/single-host-compose.ts. Expands to the registry-less single-host Docker Compose shape (docker-build → load-image-on-host → copy-to-host + remote-exec → wait-endpoint). Re-derives the hand-written __fixtures__/single-host-compose.json fixture byte-for-byte (no *.pilot.ts TS form exists yet for this shape, so the JSON fixture is the comparison baseline, matching how pilots.test.ts treats fixtures as authoritative).

Each preset returns a plain Component — a caller either uses it as-is, or spreads the result and edits deploy/rollback directly to drop to raw capabilities where a component is special (demonstrated in ecs-fargate.test.ts's "customized shape" case). No new orchestrator behavior, no changes to driver.ts, component.schema.json, or the capability interface.

Verification (acceptance criteria)

  • At least three presets expand to valid components: ecs-fargate.test.ts, lambda.test.ts, single-host-compose.test.ts each assert the preset's projectToJson output validates against component.schema.json (ajv 2020).
  • Preset-based and hand-composed produce equivalent contracts, both run through the driver (mocked cloud): presets-e2e.test.ts runs all three presets to completion through the real runInterpretDriver against a MockCloudExecutor (no live AWS/docker), and additionally runs EcsFargateComponent's expansion side by side with alb-ecs.pilot.ts's hand-composed searchService through the same driver instance, asserting identical capability dispatch.
  • Presets reduce identical-composition duplication (COMP007): comp007-reduction.test.ts shows the concrete before/after — two hand-authored components with an identical phase/step shape trigger COMP007's declaration-sprawl warning and require a fully duplicated composition; expressed via EcsFargateComponent instead, each declaration collapses to its own distinguishing params while the shared shape is defined exactly once in the preset (COMP007 still — correctly — fires on the expanded shape, since its fingerprint is structural; the reduction is in what the author has to write and maintain, not in silencing the lint hint).

tsc/eslint clean on all new/changed files (packages/core/src/components/presets/*, packages/core/src/components/index.ts). Full component + lint suites green: 58 files / 683 tests. No new test failures introduced — repo-wide vitest run shows the same ~49 pre-existing failing files (missing lexicons/k8s generated barrels, ajv not installed in this environment, and other unrelated init/import gaps) with or without this change; confirmed by diffing the failing-file list before/after.

Decisions / assumptions for review

  • Config field naming diverges slightly from each pilot's literal defaults in a couple of spots (documented inline in the tests): EcsFargateComponent's default template path is derived from the component name, while alb-ecs.pilot.ts derives it from service (search.template.json, not search-service.template.json) — the equivalence test passes template explicitly to match. Similarly SingleHostComposeComponent's default on-host path is /opt/<name>/..., while the fixture uses /opt/monitoring/... for a monitoring-host-named component — the test passes hostComposePath explicitly. Worth a second look: should the preset's defaulting convention change to match the pre-existing pilots' naming exactly, or is explicit override the right ergonomic here?
  • No preset for the infra archetype (e.g. a "sticky CFN table" or "fan-out cluster" preset) — the DynamoDB and Neo4j pilots' shapes felt more bespoke/parameter-heavy than a clean preset would help with with only three presets in scope; left for a future preset addition if a second infra-shaped component needing the same shape shows up (the COMP007 hint is exactly the signal to watch for).
  • SingleHostComposeComponent has no reference *.pilot.ts TypeScript form to diff against (only the hand-written JSON fixture) — the equivalence test compares against __fixtures__/single-host-compose.json instead, consistent with how pilots.test.ts already treats that fixture as authoritative.
  • Did not touch driver.ts, component.schema.json, or capability.ts per the constraint — presets are pure composition-time convenience, expanding to the same typed Component any hand-composed component produces.

🤖 Generated with Claude Code

…nt, SingleHostComposeComponent (#566)

Level 2 reuse over the existing Component/capability contract (epic #551):
named composition builders that expand to a full, valid `Component`, so a
preset-based component and a hand-composed one are indistinguishable to
projectToJson, schema validation, lint, and the driver. Ties to the COMP007
copy-paste hint — presets collapse a shared phase/step shape to a single
maintained definition instead of N hand-copied declarations, per the epic's
"declaration sprawl" guardrail.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lex00
lex00 merged commit 05d7bee into main Jul 3, 2026
5 checks passed
@lex00
lex00 deleted the feat/566-preset-library branch July 3, 2026 08:33
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.

Preset library (EcsFargateComponent, LambdaComponent, ...)

1 participant