Skip to content

docs(rfc): split component build lifecycle into four phases#25848

Open
pront wants to merge 2 commits into
masterfrom
pront-rfc-split-transform-lifecycle
Open

docs(rfc): split component build lifecycle into four phases#25848
pront wants to merge 2 commits into
masterfrom
pront-rfc-split-transform-lifecycle

Conversation

@pront

@pront pront commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

Adds an RFC proposing a shared ComponentConfig trait that splits the monolithic build() into four explicit lifecycle phases: validate_structure, validate_environment, build (pure/sync), and start.

Motivation: build() currently conflates structural validation, environment validation, pure construction, and task spawning, which breaks vector validate --no-environment and leaks background tasks on topology reload rollback.

Scope: TransformConfig and SinkConfig. SourceConfig is deferred to future work.

Vector configuration

N/A -- no behavior change.

How did you test this PR?

RFC only -- no code changes.

Change Type

  • Bug fix
  • New feature
  • Dependencies
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

@github-actions github-actions Bot added domain: ci Anything related to Vector's CI environment domain: rfc labels Jul 15, 2026
@datadog-vectordotdev

This comment has been minimized.

@pront pront added the no-changelog Changes in this PR do not need user-facing explanations in the release changelog label Jul 16, 2026
@pront
pront force-pushed the pront-rfc-split-transform-lifecycle branch from 7563720 to 8ea1964 Compare July 20, 2026 18:33
@github-actions github-actions Bot removed the domain: ci Anything related to Vector's CI environment label Jul 20, 2026
@pront
pront force-pushed the pront-rfc-split-transform-lifecycle branch from 8ea1964 to 9d53fd9 Compare July 20, 2026 19:10
@pront pront changed the title docs(rfc): split TransformConfig build lifecycle into four phases docs(rfc): split build lifecycle into four phases Jul 20, 2026
@pront pront changed the title docs(rfc): split build lifecycle into four phases docs(rfc): split build lifecycle into distinct phases Jul 20, 2026
Proposes a shared ComponentConfig trait with validate_structure,
validate_environment, build, and start phases for TransformConfig and
SinkConfig, deferring SourceConfig to future work.
@pront
pront force-pushed the pront-rfc-split-transform-lifecycle branch from 9d53fd9 to e59f2fe Compare July 20, 2026 19:40
@pront pront changed the title docs(rfc): split build lifecycle into distinct phases docs(rfc): split component build lifecycle into four phases Jul 20, 2026
@pront
pront marked this pull request as ready for review July 20, 2026 19:41
@pront
pront requested a review from a team as a code owner July 20, 2026 19:41

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e59f2fe827

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


| Call site | Phases invoked (transforms) | Phases invoked (sinks) |
| --- | --- | --- |
| `vector validate --no-environment` | `validate_structure` | `validate_structure` |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep VRL checks in no-environment validation

For vector validate --no-environment, this row would only invoke validate_structure, but current validation deliberately runs transform validation before the no_environment gate (src/validate.rs:170-174) and chains validate_env() for every transform (src/validate.rs:284-290). Following this matrix would skip VRL/condition compilation again for --no-environment, contradicting the stated no-user-visible-change goal and reopening the gap this RFC cites as the immediate motivation; either this path needs transform validate_environment with stubs/no I/O, or those checks need to be classified as structural.

Useful? React with 👍 / 👎.

Comment on lines +107 to +109
/// Phase 3: pure, synchronous construction. Receives context; produces `Self::Built`.
/// No task spawning, no I/O. Safe to discard on topology rollback.
fn build(&self, cx: &Self::Context) -> crate::Result<Self::Built>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve async setup needed to build sinks

This makes build() synchronous and gives validate_environment only a Result, but some sinks need awaited setup artifacts to construct the sink itself, not just to run healthchecks: checked src/sinks/aws_s3/config.rs:232/:366-375 (create_service(...).await) and HTTP AWS auth in src/sinks/http/config.rs:371-383 (credentials_provider(...).await?). Since the RFC later rejects returning artifacts from validation, normal startup would have no way to construct these sinks under this trait; the proposal needs either async build or a validation artifact that build can consume.

Useful? React with 👍 / 👎.


| Call site | Phases invoked (transforms) | Phases invoked (sinks) |
| --- | --- | --- |
| `vector validate --no-environment` | `validate_structure` | `validate_structure` |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Run sink construction during no-environment validation

This row leaves sinks at validate_structure only under vector validate --no-environment, so the split still does not exercise the pure sink construction checks that the motivation calls out as currently skipped when build() is tied to healthchecks. Current validation only enters the component/healthcheck path when no_environment is false (src/validate.rs:172-174); after healthchecks are separated, this path needs to call build or an equivalent construction-validation phase for sinks, otherwise auth, encoder, and template checks left in pure construction remain skipped.

Useful? React with 👍 / 👎.

Comment on lines +145 to +147
1. Add `ComponentConfig` with `validate_structure`, `validate_environment`, and sync `build` as
required methods, with a blanket adapter that delegates all three to each trait's existing async
`build()` for un-migrated components.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the adapter from calling legacy build in structure checks

The blanket adapter cannot safely delegate validate_structure to the existing async build(): combined with the no-environment call matrix, every un-migrated transform or sink would run the legacy build path during vector validate --no-environment, which is the side-effectful path this RFC is trying to split. I checked existing transforms such as aws_ec2_metadata, whose build refreshes metadata and then spawns a spawn_timed worker (src/transforms/aws_ec2_metadata.rs:226-247), so the adapter needs a side-effect-free/default structure implementation and should not call legacy build except on environment/startup paths.

Useful? React with 👍 / 👎.

impl Transform {
/// Phase 4: startup. Spawns background tasks, opens connections, registers metrics.
/// Called only after the topology diff is committed.
async fn start(self, cx: &TransformContext) -> RunningTransform { ... }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pass topology streams into transform start

As written, Transform::start(self, cx: &TransformContext) has no input receiver or output controls. Current startup constructs the transform task with input_rx and TransformOutputs (src/topology/builder.rs:824-845) and registers the returned controls before spawning (src/topology/builder.rs:621-627); implementing this signature would leave post-commit start unable to wire events through the transform. The phase split needs a start API that receives or returns these topology channels, or it should keep task construction in TopologyPiecesBuilder.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: rfc no-changelog Changes in this PR do not need user-facing explanations in the release changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant