fix(types): validate persisted session rows - #1712
Conversation
Terraform Validation Results
Pushed by: @open-inspect[bot], Action: |
There was a problem hiding this comment.
The schemas remove unsafe assertions, but the new fallback policy is not behavior-preserving: malformed persisted state is repeatedly converted into ordinary absence. In these paths, absence controls alarm delivery, participant creation, and duplicate-PR protection, so corruption now triggers unsafe control flow rather than a visible integrity failure. Please make invalid-row handling explicit per boundary: preserve fail-closed authentication, distinguish invalid identity rows from missing rows, and do not silently erase authoritative alarm or artifact state.
I found no file-size regression; no changed file approaches 1,000 lines. The blockers are the storage-boundary semantics, not the use of Zod itself.
The authenticated GitHub App is also the PR author, so this is submitted as COMMENT; the findings should nevertheless be treated as request-changes blockers.
Terraform Validation Results
Pushed by: @open-inspect[bot], Action: |
This is an automated nightly unsafe-cast remediation sweep. It replaces three selected unsafe assertions of opaque persisted session data with package-local Zod row schemas and
safeParseat the D1 read boundaries, following the TypeScript Coding Standards guidance for unsafe-cast / parse-don't-assert and the Zod boundary-validation pattern established in PR #807.packages/control-plane/src/session/artifact-repository.ts:51result.toArray() as ArtifactRow[]for persisted artifact rowsartifactRowSchemainsession/types.ts;listArtifactsfilters malformed rows andgetArtifactByIdreturnsnullfor malformed rows while preserving nullableurl/metadata.packages/control-plane/src/session/participant-repository.ts:39,:44,:49,:129result.toArray() as ParticipantRow[]for persisted participant rows, including WebSocket token lookupparticipantRowSchemainsession/types.ts; single-row lookups parse before returning and list reads filter malformed rows while preserving nullable identity/token columns.packages/control-plane/src/session/alarm/scheduler.ts:89.toArray() as AlarmStateRow[]for the persisted alarm singleton rowalarmStateRowSchema; malformed alarm state is treated as absent while nullable pending/in-flight deadlines remain valid.Verification:
npm run build -w @open-inspect/sharednpm run build -w @open-inspect/control-planenpm run typechecknpm run lintnpm run formatnpm test -w @open-inspect/control-planegit diff --checkReferences: TypeScript Coding Standards unsafe-cast / parse-don't-assert guidance, and the Zod boundary-validation pattern established in PR #807.
Created with Open-Inspect