chore: Enforce Side-Effects in SDK Pipeline#350
Merged
Conversation
- Add SideEffectSpec to ir-schema.ts with typed reason enum - Add sideEffects declarations to domain-map.json for Project - Add generator validation: method collision check + spec file existence - Remove stitch-ext.ts passthrough (import Stitch from generated directly) - Add sideeffect-manifest.test.ts (bidirectional consistency guard) - Add prepublishOnly script to package.json - Document Side-Effect Membrane in stitch-sdk-development skill - 8 new IR contract tests, 3 new manifest guard tests
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.
This PR formalizes the boundary between generated and handwritten code in the SDK. It fixes three concrete problems and adds six architectural guardrails to prevent future drift.
Fixes #317
The Problem
The SDK has handwritten extensions (
project-ext.ts) that add methods the generator can't express — filesystem I/O, binary uploads, private REST. These extensions worked, but relied on two unsafe patterns:as anycasts — Extension code used(this as any).clientto access the base class client, bypassing TypeScript's type system entirely.extensionPathwas configured. Other generated files importingProjectgot the base class withoutuploadImageordownloadAssets.What Changed
Constructor Visibility Fix
The generator now emits
protectedscope (instead ofprivate) for theclientparameter when a class has anextensionPath. This lets-ext.tsfiles accessthis.clientwithoutas any.Inheritance Depth Resolution
When a generated class (e.g.,
Stitch) returns instances of another class (e.g.,Project) that has an extension, the generator now imports the extension class instead of the base:Scan-Based Projections (
find)Added a
findkeyword to the projection IR that replaces brittle indexed array access with a scan pattern:Side-Effect Membrane (IR + Generator)
Added
SideEffectSpectoir-schema.tsandsideEffectsdeclarations todomain-map.json. Each handwritten extension method now formally declares:filesystem_io,binary_data,private_rest,complex_orchestration)The generator validates at Stage 3:
sideEffect.methodcollides with a generated binding methodspecPathresolves to an existing filePassthrough Removal
Deleted
stitch-ext.ts, an empty passthrough re-export of the generatedStitchclass.index.tsandsingleton.tsnow importStitchdirectly fromgenerated/src/stitch.js.Architectural Guardrails Added
constructor-visibility.test.tsas anycasts to access private memberscircular-deps.test.tsghost-method-guard.test.tsinheritance-depth.test.tsextension-resolution.test.tssideeffect-manifest.test.tsFiles Changed
Generator & IR (pipeline)
scripts/ir-schema.ts— AddedSideEffectSpecschema,sideEffectsonDomainClassConfigscripts/generate-sdk.ts—findprojection,protectedscope, extension imports, side-effect validationscripts/test/ir-schema.test.ts— 8 new contract tests forSideEffectSpecDomain Map
packages/sdk/generated/domain-map.json—sideEffectsentries foruploadImageanddownloadAssetspackages/sdk/generated/src/*.ts— Regenerated (protected constructors, extension imports)SDK Source
packages/sdk/src/project-ext.ts— Removedas anycastspackages/sdk/src/index.ts— ImportStitchfrom generated (not passthrough)packages/sdk/src/singleton.ts— ImportStitchfrom generated (not passthrough)packages/sdk/src/stitch-ext.ts— Deletedpackages/sdk/src/download-handler.ts— Minor cleanuppackages/sdk/package.json— AddedprepublishOnlyscriptDocumentation
.agents/skills/stitch-sdk-development/SKILL.md— Documented Side-Effect Membrane and extension pattern