Repository navigation
feat(components): preset library — EcsFargateComponent, LambdaComponent, SingleHostComposeComponent (#566) - #590
Merged
Merged
Conversation
…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>
21 of 35 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inlexicons/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-ALBstackOutput()cross-stack wiring] →ecs-update-service→wait-steady-state+health-gate, with the samerollback-previouscompensation phase). Re-derivespilots/alb-ecs.pilot.ts's hand-composedsearchServicebyte-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-derivespilots/lambda.pilot.ts's hand-composedimageProcessorbyte-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.jsonfixture byte-for-byte (no*.pilot.tsTS form exists yet for this shape, so the JSON fixture is the comparison baseline, matching howpilots.test.tstreats fixtures as authoritative).Each preset returns a plain
Component— a caller either uses it as-is, or spreads the result and editsdeploy/rollbackdirectly to drop to raw capabilities where a component is special (demonstrated inecs-fargate.test.ts's "customized shape" case). No new orchestrator behavior, no changes todriver.ts,component.schema.json, or the capability interface.Verification (acceptance criteria)
ecs-fargate.test.ts,lambda.test.ts,single-host-compose.test.tseach assert the preset'sprojectToJsonoutput validates againstcomponent.schema.json(ajv 2020).presets-e2e.test.tsruns all three presets to completion through the realrunInterpretDriveragainst aMockCloudExecutor(no live AWS/docker), and additionally runsEcsFargateComponent's expansion side by side withalb-ecs.pilot.ts's hand-composedsearchServicethrough the same driver instance, asserting identical capability dispatch.comp007-reduction.test.tsshows 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 viaEcsFargateComponentinstead, 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/eslintclean 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-widevitest runshows the same ~49 pre-existing failing files (missinglexicons/k8sgenerated barrels,ajvnot 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
EcsFargateComponent's defaulttemplatepath is derived from the componentname, whilealb-ecs.pilot.tsderives it fromservice(search.template.json, notsearch-service.template.json) — the equivalence test passestemplateexplicitly to match. SimilarlySingleHostComposeComponent's default on-host path is/opt/<name>/..., while the fixture uses/opt/monitoring/...for amonitoring-host-named component — the test passeshostComposePathexplicitly. 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?infraarchetype (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 secondinfra-shaped component needing the same shape shows up (the COMP007 hint is exactly the signal to watch for).SingleHostComposeComponenthas no reference*.pilot.tsTypeScript form to diff against (only the hand-written JSON fixture) — the equivalence test compares against__fixtures__/single-host-compose.jsoninstead, consistent with howpilots.test.tsalready treats that fixture as authoritative.driver.ts,component.schema.json, orcapability.tsper the constraint — presets are pure composition-time convenience, expanding to the same typedComponentany hand-composed component produces.🤖 Generated with Claude Code