From ecad521c75c602c348ced668acc356e3531b3e81 Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot Date: Thu, 29 Oct 2026 15:24:27 -0400 Subject: [PATCH] refactor(schema): conform to the effect-tsgo 0.54 lint rules Claude-Session: https://claude.ai/code/session_017rX35xUAHEjVVaDKVVzubW --- .../src/MicroVMMedium/WorkloadExit.schema.ts | 12 ++- .../classify-workload-exit.workflow.ts | 8 +- .../plan-vm-teardown.workflow.ts | 20 ++-- .../__fixtures__/microvm-runtime.fixture.ts | 18 ++-- .../examples/boot-alpine.ts | 6 +- .../src/JobExitStatus.schema.ts | 6 +- .../src/MicroVMError.schema.ts | 68 ++++++++------ .../src/assess-virtualization.workflow.ts | 36 +++++--- .../src/classify-job-exit.workflow.ts | 12 ++- .../classify-probe-observation.workflow.ts | 92 ++++++++++++------- .../src/render-sandbox-plan.workflow.ts | 14 +-- .../src/resolve-wait-strategy.workflow.ts | 24 +++-- 12 files changed, 191 insertions(+), 125 deletions(-) diff --git a/packages/effect-daemon-microvm/src/MicroVMMedium/WorkloadExit.schema.ts b/packages/effect-daemon-microvm/src/MicroVMMedium/WorkloadExit.schema.ts index 931adff..ba99861 100644 --- a/packages/effect-daemon-microvm/src/MicroVMMedium/WorkloadExit.schema.ts +++ b/packages/effect-daemon-microvm/src/MicroVMMedium/WorkloadExit.schema.ts @@ -4,13 +4,17 @@ import { Match, Schema } from 'effect' const WorkloadExitTypeId: unique symbol = Symbol.for('@systemfsoftware/effect-daemon-microvm/WorkloadExit') type WorkloadExitTypeId = typeof WorkloadExitTypeId -export class WorkloadExitedNormal extends Schema.TaggedClass()('WorkloadExitedNormal', {}) { +export class WorkloadExitedNormal + extends Schema.TaggedClass()('WorkloadExitedNormal', {}) +{ readonly [WorkloadExitTypeId] = WorkloadExitTypeId } -export class WorkloadExitedAbnormal extends Schema.TaggedClass()('WorkloadExitedAbnormal', { - code: Schema.Int, -}) { +export class WorkloadExitedAbnormal + extends Schema.TaggedClass()('WorkloadExitedAbnormal', { + code: Schema.Int, + }) +{ readonly [WorkloadExitTypeId] = WorkloadExitTypeId } diff --git a/packages/effect-daemon-microvm/src/MicroVMMedium/classify-workload-exit.workflow.ts b/packages/effect-daemon-microvm/src/MicroVMMedium/classify-workload-exit.workflow.ts index f3f68ac..597c6de 100644 --- a/packages/effect-daemon-microvm/src/MicroVMMedium/classify-workload-exit.workflow.ts +++ b/packages/effect-daemon-microvm/src/MicroVMMedium/classify-workload-exit.workflow.ts @@ -3,9 +3,11 @@ import { Match, Schema } from 'effect' import * as Result from 'effect/Result' import { WorkloadExit, WorkloadExitedAbnormal, WorkloadExitedNormal } from './WorkloadExit.schema.js' -export class ClassifyWorkloadExit extends Schema.TaggedClass()('ClassifyWorkloadExit', { - code: Schema.Int, -}) { +export class ClassifyWorkloadExit + extends Schema.TaggedClass()('ClassifyWorkloadExit', { + code: Schema.Int, + }) +{ static readonly [Workflow.InstrumentationBrand] = { code: 'microvm.workload.exit.code' } as const } diff --git a/packages/effect-daemon-microvm/src/MicroVMMedium/plan-vm-teardown.workflow.ts b/packages/effect-daemon-microvm/src/MicroVMMedium/plan-vm-teardown.workflow.ts index b642f44..c27e317 100644 --- a/packages/effect-daemon-microvm/src/MicroVMMedium/plan-vm-teardown.workflow.ts +++ b/packages/effect-daemon-microvm/src/MicroVMMedium/plan-vm-teardown.workflow.ts @@ -6,26 +6,30 @@ import * as Result from 'effect/Result' const VmTeardownTypeId: unique symbol = Symbol.for('@systemfsoftware/effect-daemon-microvm/VmTeardown') type VmTeardownTypeId = typeof VmTeardownTypeId -export class KillVm extends Schema.TaggedClass()('KillVm', {}) { +export class KillVm extends Schema.TaggedClass()('KillVm', {}) { readonly [VmTeardownTypeId] = VmTeardownTypeId } -export class StopVmWithin extends Schema.TaggedClass()('StopVmWithin', { - millis: Schema.Int, -}) { +export class StopVmWithin + extends Schema.TaggedClass()('StopVmWithin', { + millis: Schema.Int, + }) +{ readonly [VmTeardownTypeId] = VmTeardownTypeId } -export class StopVm extends Schema.TaggedClass()('StopVm', {}) { +export class StopVm extends Schema.TaggedClass()('StopVm', {}) { readonly [VmTeardownTypeId] = VmTeardownTypeId } export const VmTeardown = Schema.Union([KillVm, StopVmWithin, StopVm]) export type VmTeardown = typeof VmTeardown.Type -export class PlanVmTeardown extends Schema.TaggedClass()('PlanVmTeardown', { - mode: Supervisor.Medium.ShutdownMode, -}) { +export class PlanVmTeardown + extends Schema.TaggedClass()('PlanVmTeardown', { + mode: Supervisor.Medium.ShutdownMode, + }) +{ static readonly [Workflow.InstrumentationBrand] = {} as const } diff --git a/packages/effect-daemon-microvm/tests/__fixtures__/microvm-runtime.fixture.ts b/packages/effect-daemon-microvm/tests/__fixtures__/microvm-runtime.fixture.ts index 5031fde..6098297 100644 --- a/packages/effect-daemon-microvm/tests/__fixtures__/microvm-runtime.fixture.ts +++ b/packages/effect-daemon-microvm/tests/__fixtures__/microvm-runtime.fixture.ts @@ -4,13 +4,17 @@ import { Context, Effect, Layer, Match, Option, Schema } from 'effect' import type { ExecEvent, ExecHandle, ExecSink, ResolvedRuntime, Sandbox } from 'microsandbox' import { ABNORMAL_EXIT_CODE, READY_TOKEN } from './child-script.js' -export class MachineLeftBehind extends Schema.TaggedError()('MachineLeftBehind', { - names: Schema.Array(Schema.String), -}) {} - -export class ExceptionalTermination extends Schema.TaggedError()('ExceptionalTermination', { - observed: Schema.String, -}) {} +export class MachineLeftBehind + extends Schema.TaggedError()('MachineLeftBehind', { + names: Schema.Array(Schema.String), + }) +{} + +export class ExceptionalTermination + extends Schema.TaggedError()('ExceptionalTermination', { + observed: Schema.String, + }) +{} export type SandboxBehaviour = 'waits-for-steps' | 'ends-after-started' diff --git a/packages/effect-microsandbox/examples/boot-alpine.ts b/packages/effect-microsandbox/examples/boot-alpine.ts index 48072ec..204eeb5 100755 --- a/packages/effect-microsandbox/examples/boot-alpine.ts +++ b/packages/effect-microsandbox/examples/boot-alpine.ts @@ -11,21 +11,21 @@ import assert from 'node:assert' import { Buffer } from 'node:buffer' import { createServer, type IncomingMessage, type Server, type ServerResponse } from 'node:http' -export class HostListenerError extends Schema.TaggedError()( +export class HostListenerError extends Schema.TaggedError()( 'HostListenerError', { cause: Schema.Unknown, }, ) {} -export class SandboxListingError extends Schema.TaggedError()( +export class SandboxListingError extends Schema.TaggedError()( 'SandboxListingError', { cause: Schema.Unknown, }, ) {} -export class EscapeHatchDefect extends Schema.TaggedError()( +export class EscapeHatchDefect extends Schema.TaggedError()( 'EscapeHatchDefect', {}, ) {} diff --git a/packages/effect-microsandbox/src/JobExitStatus.schema.ts b/packages/effect-microsandbox/src/JobExitStatus.schema.ts index 0272a27..1a69d45 100644 --- a/packages/effect-microsandbox/src/JobExitStatus.schema.ts +++ b/packages/effect-microsandbox/src/JobExitStatus.schema.ts @@ -5,13 +5,15 @@ const JobExitStatusTypeId: unique symbol = Symbol.for( ) type JobExitStatusTypeId = typeof JobExitStatusTypeId -export class JobExited extends Schema.TaggedClass()('JobExited', { +export class JobExited extends Schema.TaggedClass()('JobExited', { code: Schema.Natural, }) { readonly [JobExitStatusTypeId] = JobExitStatusTypeId } -export class JobSignaled extends Schema.TaggedClass()('JobSignaled', {}) { +export class JobSignaled + extends Schema.TaggedClass()('JobSignaled', {}) +{ readonly [JobExitStatusTypeId] = JobExitStatusTypeId } diff --git a/packages/effect-microsandbox/src/MicroVMError.schema.ts b/packages/effect-microsandbox/src/MicroVMError.schema.ts index 6045450..6988794 100644 --- a/packages/effect-microsandbox/src/MicroVMError.schema.ts +++ b/packages/effect-microsandbox/src/MicroVMError.schema.ts @@ -2,24 +2,28 @@ import { Match, Option, Predicate, Schema } from 'effect' import { GuestPort } from './MicroVMSpec.schema.js' -export class VirtualizationUnsupportedError extends Schema.TaggedError()( - 'VirtualizationUnsupportedError', - { - platform: Schema.String, - remediation: Schema.String, - cause: Schema.optional(Schema.Unknown), - }, -) { +export class VirtualizationUnsupportedError + extends Schema.TaggedError()( + 'VirtualizationUnsupportedError', + { + platform: Schema.String, + remediation: Schema.String, + cause: Schema.optional(Schema.Unknown), + }, + ) +{ override get message(): string { return `Virtualization is unsupported on platform "${this.platform}": ${this.remediation}` } } /** The runtime could not start the sandbox; the message carries the runtime's own reason, so a failure names why. */ -export class SandboxBootError extends Schema.TaggedError()('SandboxBootError', { - sandboxName: Schema.String, - cause: Schema.optional(Schema.Unknown), -}) { +export class SandboxBootError + extends Schema.TaggedError()('SandboxBootError', { + sandboxName: Schema.String, + cause: Schema.optional(Schema.Unknown), + }) +{ override get message(): string { const failed = `Sandbox "${this.sandboxName}" failed to boot` return Option.match(Option.fromUndefinedOr(this.cause), { @@ -34,16 +38,18 @@ export class SandboxBootError extends Schema.TaggedError()('Sa } } -export class WaitTimeoutError extends Schema.TaggedError()('WaitTimeoutError', { - wait: Schema.String, - timeoutMs: Schema.Int.pipe(Schema.check(Schema.isGreaterThan(0))), -}) { +export class WaitTimeoutError + extends Schema.TaggedError()('WaitTimeoutError', { + wait: Schema.String, + timeoutMs: Schema.Int.pipe(Schema.check(Schema.isGreaterThan(0))), + }) +{ override get message(): string { return `Timed out after ${this.timeoutMs}ms waiting for "${this.wait}"` } } -export class ExecError extends Schema.TaggedError()('ExecError', { +export class ExecError extends Schema.TaggedError()('ExecError', { argv: Schema.Array(Schema.String), cause: Schema.optional(Schema.Unknown), }) { @@ -52,23 +58,27 @@ export class ExecError extends Schema.TaggedError()('ExecError', { } } -export class PortAllocationError extends Schema.TaggedError()('PortAllocationError', { - guestPort: GuestPort, - cause: Schema.optional(Schema.Unknown), -}) { +export class PortAllocationError + extends Schema.TaggedError()('PortAllocationError', { + guestPort: GuestPort, + cause: Schema.optional(Schema.Unknown), + }) +{ override get message(): string { return `The guest port ${this.guestPort} could not be mapped to a host port` } } -export class LoopbackViolationError extends Schema.TaggedError()( - 'LoopbackViolationError', - { - sandboxName: Schema.String, - host: Schema.String, - guestPort: GuestPort, - }, -) { +export class LoopbackViolationError + extends Schema.TaggedError()( + 'LoopbackViolationError', + { + sandboxName: Schema.String, + host: Schema.String, + guestPort: GuestPort, + }, + ) +{ override get message(): string { return `Sandbox "${this.sandboxName}" refused the network binding "${this.host}:${this.guestPort}" under its loopback policy` } diff --git a/packages/effect-microsandbox/src/assess-virtualization.workflow.ts b/packages/effect-microsandbox/src/assess-virtualization.workflow.ts index 359e6b8..4b3ad13 100644 --- a/packages/effect-microsandbox/src/assess-virtualization.workflow.ts +++ b/packages/effect-microsandbox/src/assess-virtualization.workflow.ts @@ -7,30 +7,36 @@ import { ProbeObservation } from './classify-probe-observation.workflow.js' const VerdictTypeId: unique symbol = Symbol.for('@systemfsoftware/effect-microsandbox/VirtualizationVerdict') type VerdictTypeId = typeof VerdictTypeId -export class VirtualizationEligible extends Schema.TaggedClass()( - 'VirtualizationEligible', - {}, -) { +export class VirtualizationEligible + extends Schema.TaggedClass()( + 'VirtualizationEligible', + {}, + ) +{ readonly [VerdictTypeId] = VerdictTypeId } -export class VirtualizationRefused extends Schema.TaggedClass()( - 'VirtualizationRefused', - { - remediation: Schema.String, - topology: Schema.String, - }, -) { +export class VirtualizationRefused + extends Schema.TaggedClass()( + 'VirtualizationRefused', + { + remediation: Schema.String, + topology: Schema.String, + }, + ) +{ readonly [VerdictTypeId] = VerdictTypeId } export const VirtualizationVerdict = Schema.Union([VirtualizationEligible, VirtualizationRefused]) export type VirtualizationVerdict = typeof VirtualizationVerdict.Type -export class AssessVirtualization extends Schema.TaggedClass()('AssessVirtualization', { - platform: Schema.String, - observation: ProbeObservation, -}) { +export class AssessVirtualization + extends Schema.TaggedClass()('AssessVirtualization', { + platform: Schema.String, + observation: ProbeObservation, + }) +{ static readonly [Workflow.InstrumentationBrand] = { platform: 'microsandbox.virtualization.platform' } as const } const REMEDIATIONS = { diff --git a/packages/effect-microsandbox/src/classify-job-exit.workflow.ts b/packages/effect-microsandbox/src/classify-job-exit.workflow.ts index 7215ce6..d47f6be 100644 --- a/packages/effect-microsandbox/src/classify-job-exit.workflow.ts +++ b/packages/effect-microsandbox/src/classify-job-exit.workflow.ts @@ -3,11 +3,13 @@ import { Option, Schema } from 'effect' import * as Result from 'effect/Result' import { JobExited, JobExitStatus, JobSignaled } from './JobExitStatus.schema.js' -export class ClassifyJobExit extends Schema.TaggedClass()('ClassifyJobExit', { - code: Schema.Int, - stdout: Schema.Uint8Array, - stderr: Schema.Uint8Array, -}) { +export class ClassifyJobExit + extends Schema.TaggedClass()('ClassifyJobExit', { + code: Schema.Int, + stdout: Schema.Uint8Array, + stderr: Schema.Uint8Array, + }) +{ static readonly [Workflow.InstrumentationBrand] = { code: 'microsandbox.job.exit.code' } as const } diff --git a/packages/effect-microsandbox/src/classify-probe-observation.workflow.ts b/packages/effect-microsandbox/src/classify-probe-observation.workflow.ts index 03753dc..a69f372 100644 --- a/packages/effect-microsandbox/src/classify-probe-observation.workflow.ts +++ b/packages/effect-microsandbox/src/classify-probe-observation.workflow.ts @@ -7,32 +7,46 @@ const ProbeObservationTypeId: unique symbol = Symbol.for( ) type ProbeObservationTypeId = typeof ProbeObservationTypeId -export class KvmAccessible extends Schema.TaggedClass()('KvmAccessible', {}) { +export class KvmAccessible + extends Schema.TaggedClass()('KvmAccessible', {}) +{ readonly [ProbeObservationTypeId] = ProbeObservationTypeId } -export class KvmDenied extends Schema.TaggedClass()('KvmDenied', { topology: Schema.String }) { +export class KvmDenied + extends Schema.TaggedClass()('KvmDenied', { topology: Schema.String }) +{ readonly [ProbeObservationTypeId] = ProbeObservationTypeId } -export class KvmAbsent extends Schema.TaggedClass()('KvmAbsent', { topology: Schema.String }) { +export class KvmAbsent + extends Schema.TaggedClass()('KvmAbsent', { topology: Schema.String }) +{ readonly [ProbeObservationTypeId] = ProbeObservationTypeId } -export class HvfUnavailable extends Schema.TaggedClass()('HvfUnavailable', { arch: Schema.String }) { +export class HvfUnavailable + extends Schema.TaggedClass()('HvfUnavailable', { + arch: Schema.String, + }) +{ readonly [ProbeObservationTypeId] = ProbeObservationTypeId } -export class WHPUnavailable extends Schema.TaggedClass()('WHPUnavailable', { - topology: Schema.String, -}) { +export class WHPUnavailable + extends Schema.TaggedClass()('WHPUnavailable', { + topology: Schema.String, + }) +{ readonly [ProbeObservationTypeId] = ProbeObservationTypeId } -export class PlatformUnsupported extends Schema.TaggedClass()('PlatformUnsupported', { - platform: Schema.String, - arch: Schema.String, -}) { +export class PlatformUnsupported + extends Schema.TaggedClass()('PlatformUnsupported', { + platform: Schema.String, + arch: Schema.String, + }) +{ readonly [ProbeObservationTypeId] = ProbeObservationTypeId } @@ -46,33 +60,43 @@ export const ProbeObservation = Schema.Union([ ]) export type ProbeObservation = typeof ProbeObservation.Type -export class KvmDeviceFacts extends Schema.TaggedClass()('KvmDeviceFacts', { - accessible: Schema.Boolean, - present: Schema.Boolean, -}) {} - -export class VmcomputeFacts extends Schema.TaggedClass()('VmcomputeFacts', { - present: Schema.Boolean, -}) {} - -export class AppleHypervisorFacts extends Schema.TaggedClass()('AppleHypervisorFacts', { - arch: Schema.String, -}) {} - -export class NoProbeForPlatform extends Schema.TaggedClass()('NoProbeForPlatform', { - arch: Schema.String, -}) {} +export class KvmDeviceFacts + extends Schema.TaggedClass()('KvmDeviceFacts', { + accessible: Schema.Boolean, + present: Schema.Boolean, + }) +{} + +export class VmcomputeFacts + extends Schema.TaggedClass()('VmcomputeFacts', { + present: Schema.Boolean, + }) +{} + +export class AppleHypervisorFacts + extends Schema.TaggedClass()('AppleHypervisorFacts', { + arch: Schema.String, + }) +{} + +export class NoProbeForPlatform + extends Schema.TaggedClass()('NoProbeForPlatform', { + arch: Schema.String, + }) +{} export const ProbeFacts = Schema.Union([KvmDeviceFacts, VmcomputeFacts, AppleHypervisorFacts, NoProbeForPlatform]) export type ProbeFacts = typeof ProbeFacts.Type -export class ClassifyProbeObservation extends Schema.TaggedClass()( - 'ClassifyProbeObservation', - { - platform: Schema.String, - facts: ProbeFacts, - }, -) { +export class ClassifyProbeObservation + extends Schema.TaggedClass()( + 'ClassifyProbeObservation', + { + platform: Schema.String, + facts: ProbeFacts, + }, + ) +{ static readonly [Workflow.InstrumentationBrand] = { platform: 'microsandbox.virtualization.platform' } as const } diff --git a/packages/effect-microsandbox/src/render-sandbox-plan.workflow.ts b/packages/effect-microsandbox/src/render-sandbox-plan.workflow.ts index 21f5e0a..14ca6b8 100644 --- a/packages/effect-microsandbox/src/render-sandbox-plan.workflow.ts +++ b/packages/effect-microsandbox/src/render-sandbox-plan.workflow.ts @@ -8,14 +8,16 @@ import { PortBinding, SandboxPlan } from './render-sandbox-plan.schema.js' const PlanTypeId: unique symbol = Symbol.for('@systemfsoftware/effect-microsandbox/SandboxPlanDecision') type PlanTypeId = typeof PlanTypeId -export class PlanApproved extends Schema.TaggedClass()('PlanApproved', { - plan: SandboxPlan, - guests: Schema.Array(GuestPort), -}) { +export class PlanApproved + extends Schema.TaggedClass()('PlanApproved', { + plan: SandboxPlan, + guests: Schema.Array(GuestPort), + }) +{ readonly [PlanTypeId] = PlanTypeId } -export class PlanRefused extends Schema.TaggedClass()('PlanRefused', { +export class PlanRefused extends Schema.TaggedClass()('PlanRefused', { sandboxName: Schema.String, host: Schema.String, guestPort: GuestPort, @@ -26,7 +28,7 @@ export class PlanRefused extends Schema.TaggedClass()('PlanRefused' export const SandboxPlanDecision = Schema.Union([PlanApproved, PlanRefused]) export type SandboxPlanDecision = typeof SandboxPlanDecision.Type -export class PlanSandbox extends Schema.TaggedClass()('PlanSandbox', { +export class PlanSandbox extends Schema.TaggedClass()('PlanSandbox', { spec: MicroVMSpec, bindings: Schema.Array(PortBinding), name: Schema.String, diff --git a/packages/effect-microsandbox/src/resolve-wait-strategy.workflow.ts b/packages/effect-microsandbox/src/resolve-wait-strategy.workflow.ts index 975a1d9..23ac201 100644 --- a/packages/effect-microsandbox/src/resolve-wait-strategy.workflow.ts +++ b/packages/effect-microsandbox/src/resolve-wait-strategy.workflow.ts @@ -11,24 +11,30 @@ type WaitStrategyDecisionTypeId = typeof WaitStrategyDecisionTypeId const { Condition } = Readiness -export class WaitRequired extends Schema.TaggedClass()('WaitRequired', { - strategy: WaitStrategy, - condition: Condition, - label: Schema.String, -}) { +export class WaitRequired + extends Schema.TaggedClass()('WaitRequired', { + strategy: WaitStrategy, + condition: Condition, + label: Schema.String, + }) +{ readonly [WaitStrategyDecisionTypeId] = WaitStrategyDecisionTypeId } -export class WaitSkipped extends Schema.TaggedClass()('WaitSkipped', {}) { +export class WaitSkipped + extends Schema.TaggedClass()('WaitSkipped', {}) +{ readonly [WaitStrategyDecisionTypeId] = WaitStrategyDecisionTypeId } export const WaitStrategyDecision = Schema.Union([WaitRequired, WaitSkipped]) export type WaitStrategyDecision = typeof WaitStrategyDecision.Type -export class ResolveWaitStrategy extends Schema.TaggedClass()('ResolveWaitStrategy', { - spec: MicroVMSpec, -}) { +export class ResolveWaitStrategy + extends Schema.TaggedClass()('ResolveWaitStrategy', { + spec: MicroVMSpec, + }) +{ static readonly [Workflow.InstrumentationBrand] = {} as const }