Skip to content

feat(finalizer): add Effect domain and schema validation - #23

Merged
mrevanzak merged 5 commits into
mainfrom
finalizer/effect-domain
Aug 17, 2026
Merged

feat(finalizer): add Effect domain and schema validation#23
mrevanzak merged 5 commits into
mainfrom
finalizer/effect-domain

Conversation

@mrevanzak

@mrevanzak mrevanzak commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add Effect tooling and language-service configuration for the finalizer.
  • Define branded domain identifiers, tagged errors, and pure media helpers.
  • Decode manifests and finalize plans with Effect Schema while retaining compatibility adapters.

Validation

  • pnpm --filter @interview-web/finalizer test
  • pnpm --filter @interview-web/finalizer check-types

@access-time-code-pr-reviewer

access-time-code-pr-reviewer Bot commented Aug 17, 2026

Copy link
Copy Markdown

Review Summary

This PR introduces Effect-based domain modeling and validation for the finalizer, including branded identifiers, tagged errors, manifest/finalization-plan schemas, and pure media helpers. It also preserves the existing public API through compatibility exports and adds focused tests, but duplicated manifest and part contracts create a maintainability risk and can drift from the canonical schemas.

Key Changes:

  • Added branded SessionId and Sha256Hex domain types.
  • Added tagged finalization errors and terminal-error classification.
  • Added Effect Schema validation for manifests and finalization plans.
  • Extracted pure media helpers and retained compatibility exports.
  • Added domain and worker test coverage plus Effect tooling dependencies.

Confidence Score: 5/5

Recommendation: Review findings before merge.

Rationale: The changed files and supplied review finding clearly show duplicated domain contracts between media.ts and schema.ts, while the overall validation flow and compatibility structure are straightforward to assess.

Special Attention

- Consolidate FinalizerPart and FinalizerManifest in media.ts with the canonical definitions from schema.ts. - Verify checksum typing remains consistent across media helpers and schema validation. - Confirm compatibility exports continue exposing the intended public types and functions.

Important Files Changed

File Overview
packages/finalizer/src/domain/schema.ts Defines the canonical Effect schemas and inferred types for manifests, parts, plans, and published objects.
packages/finalizer/src/domain/media.ts Contains media helpers and duplicated FinalizerPart and FinalizerManifest interfaces that should use the canonical schema types.
packages/finalizer/src/domain/validate.ts Decodes and validates manifests and finalization plans, including size, ordering, and consistency checks.
packages/finalizer/src/domain/errors.ts Defines tagged domain errors and classifies terminal finalization failures.
packages/finalizer/src/pure.ts Maintains compatibility exports for the refactored domain helpers and types.

Flowchart

flowchart TD
  A[Unknown manifest input] --> B[Effect Schema decode]
  B -->|Invalid shape or branded fields| C[InvalidManifest]
  B -->|Valid schema| D[Validate segment and part ordering]
  D -->|Invalid or incomplete| E[IncompleteManifest or InvalidPart]
  D --> F[Check total input size]
  F -->|Over limit| G[InputTooLarge]
  F --> H[Validated FinalizerManifest]
  H --> I[Decode finalization plan]
  I -->|Mismatch| J[InvalidFinalizePlan]
  I --> K[Validated FinalizePlan]
Loading
Audit history

@access-time-code-pr-reviewer access-time-code-pr-reviewer 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.


🤖 review-bot · openai/gpt-5.6-luna · standard · 121.0s · 471,360 tokens · diff: 10 files · preloaded context: 11 changed + 7 related · 1 noise filtered · policy: github-pr-review, thermo-nuclear-code-quality-review · optional skills invoked: none

}

export function validateManifest(manifest: unknown): number {
const decoded = Effect.runSync(decodeManifest(manifest));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Warning

Effect.runSync wraps failures in FiberFailure, so processFinalization will not see the underlying InvalidManifest/InvalidFinalizePlan _tag; malformed manifests are therefore treated as transient, requeued, and retried indefinitely instead of being marked failed. Unwrap the Cause via an Exit-based runner or otherwise rethrow the tagged domain error directly.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/finalizer/src/domain/validate.ts
Line: 102
Severity: warning
Comment: `Effect.runSync` wraps failures in `FiberFailure`, so `processFinalization` will not see the underlying `InvalidManifest`/`InvalidFinalizePlan` `_tag`; malformed manifests are therefore treated as transient, requeued, and retried indefinitely instead of being marked failed. Unwrap the `Cause` via an Exit-based runner or otherwise rethrow the tagged domain error directly.

How can I resolve this? If you propose a fix, please make it concise.

Think this is incorrect? Reply false positive: <reason>.

objectKey: string;
sequence: number;
}
export interface FinalizerManifest {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Suggestion

This redeclares FinalizerManifest/FinalizerPart alongside the new canonical Effect schemas in schema.ts, allowing the runtime decoder and media helpers to drift independently. Reuse the schema-derived types here (and similarly consolidate overlapping output types) so the validated boundary remains the single source of truth.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/finalizer/src/domain/media.ts
Line: 11
Severity: suggestion
Comment: This redeclares `FinalizerManifest`/`FinalizerPart` alongside the new canonical Effect schemas in `schema.ts`, allowing the runtime decoder and media helpers to drift independently. Reuse the schema-derived types here (and similarly consolidate overlapping output types) so the validated boundary remains the single source of truth.

How can I resolve this? If you propose a fix, please make it concise.

Think this is incorrect? Reply false positive: <reason>.

@mrevanzak mrevanzak changed the title finalizer/effect domain feat(finalizer): add Effect domain and schema validation Aug 17, 2026
@mrevanzak
mrevanzak force-pushed the finalizer/effect-domain branch from 5a98f5b to 91e53cf Compare August 17, 2026 07:16
An error occurred while trying to automatically change base from recording/e2e-coverage to main August 17, 2026 07:18
@mrevanzak
mrevanzak force-pushed the finalizer/effect-domain branch from 91e53cf to ffbf61e Compare August 17, 2026 07:21
@mrevanzak
mrevanzak changed the base branch from recording/e2e-coverage to main August 17, 2026 07:21

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Critical

The container health probe is configured for container/health, but server.js only serves /health. Cloudflare will receive a 404 health check, mark the container unhealthy, and finalization requests will fail. Set pingEndpoint to /health (or add the matching server route).

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/finalizer/src/worker.ts
Line: 65
Severity: critical
Comment: The container health probe is configured for `container/health`, but `server.js` only serves `/health`. Cloudflare will receive a 404 health check, mark the container unhealthy, and finalization requests will fail. Set `pingEndpoint` to `/health` (or add the matching server route).

How can I resolve this? If you propose a fix, please make it concise.

Think this is incorrect? Reply false positive: <reason>.

pnpm 11 fails frozen installs when @effect/platform-node pulls
@parcel/watcher and msgpackr-extract without allowBuilds entries.
Domain Schema types made the existing fixtures incomplete. Narrow
segment/part access, return Promise<Response> from the fetch mock, and
fill claim with leaseExpiresAt plus the required manifest fields.

@access-time-code-pr-reviewer access-time-code-pr-reviewer 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.


🤖 review-bot · openai/gpt-5.6-luna · standard · 142.2s · 652,197 tokens · diff: 12 files · preloaded context: 13 changed + 6 related · 1 noise filtered · policy: github-pr-review, thermo-nuclear-code-quality-review · optional skills invoked: none

export const MAX_SEGMENTS = 5;
export const MAX_INPUT_BYTES = 2 * 1024 * 1024 * 1024;

export interface FinalizerPart {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Warning

FinalizerPart and FinalizerManifest are duplicated here even though domain/schema.ts defines the canonical versions. These contracts can drift silently (the media helpers already use a different checksum type); import the shared type from schema.ts or consolidate the model so all helpers use one definition.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/finalizer/src/domain/media.ts
Line: 4
Severity: warning
Comment: `FinalizerPart` and `FinalizerManifest` are duplicated here even though `domain/schema.ts` defines the canonical versions. These contracts can drift silently (the media helpers already use a different checksum type); import the shared type from `schema.ts` or consolidate the model so all helpers use one definition.

How can I resolve this? If you propose a fix, please make it concise.

Think this is incorrect? Reply false positive: <reason>.

@mrevanzak
mrevanzak merged commit 87d3d6d into main Aug 17, 2026
3 checks passed
@mrevanzak
mrevanzak deleted the finalizer/effect-domain branch August 17, 2026 08:39
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