Tighten ast-grep rules in CI - #2753
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Architecture diagram
sequenceDiagram
participant CI as CI Pipeline
participant Unit as Unit Tests (vitest)
participant Protocol as Protocol Schema (stagehand.v4.json)
participant Registry as Schema Registry (TS)
participant TS as TypeScript SDK
participant PY as Python SDK
participant GO as Go SDK
participant Ext as Extension rpcRouter
participant Docs as Documentation MDX
Note over CI,Unit: NEW: Cross-language protocol validation pipeline
CI->>Unit: pnpm test:unit
Unit->>Protocol: Read protocol document
Unit->>Registry: Read StagehandMethods registry
Note over Unit,TS: Field Pipeline Verification
Unit->>TS: Extract public RPC calls (source AST)
Unit->>PY: Extract public RPC calls (source AST)
Unit->>GO: Extract public RPC calls (source AST)
TS-->>Unit: Request/result field usage
PY-->>Unit: Request/result field usage
GO-->>Unit: Request/result field usage
Unit->>Unit: Verify every request field constructed & forwarded
Unit->>Unit: Verify every result field consumed & returned
Note over Unit,Ext: Routing Parity Verification
Unit->>Ext: Find request.method route switch
Ext-->>Unit: Extension inbound operations list
Unit->>TS: Find outbound .send() calls
Unit->>PY: Find outbound .send() calls
Unit->>GO: Find outbound .call() calls
TS-->>Unit: Outbound operation set
PY-->>Unit: Outbound operation set
GO-->>Unit: Outbound operation set
alt Operations handled by both endpoints
Unit->>Unit: Fail - duplicate routing detected
else Every operation has exactly one receiver
Unit->>Unit: Pass - extension and SDK boundaries match
end
Note over Unit,Docs: Schema Parity Verification
Unit->>TS: Read Zod client schemas (clientSchemas.ts)
TS-->>Unit: Canonical field names
Unit->>PY: Parse TypedDict declarations (client_types.py)
PY-->>Unit: Public input fields
Unit->>PY: Parse Pydantic models (client_models.py)
PY-->>Unit: Runtime model fields
alt Python input != runtime model
Unit->>Unit: Fail - declaration drift detected
end
Unit->>GO: Parse struct definitions (client_options.go, browser_factories.go)
GO-->>Unit: Struct field names
alt Go struct fields != TypeScript Zod fields
Unit->>Unit: Fail - cross-language schema drift detected
end
Note over Unit,Docs: Documentation Completeness
Unit->>Docs: Scan Stagehand.create reference sections
Unit->>Docs: Scan browser configuration sections
Docs-->>Unit: Documented ParamField entries
alt Stagehand.create fields missing from docs
Unit->>Unit: Fail - reference documentation incomplete
end
alt Browser/extension options undocumented
Unit->>Unit: Fail - configuration guide incomplete
end
Note over Unit,CI: Lint Rule Update
Unit->>Unit: Verify no-loose-json-schema rule targets params/result
alt Operation uses loose schema instead of canonical registry
Unit->>Unit: Fail - lint error reported
else Operation references canonical $defs schema
Unit->>Unit: Pass - schema usage valid
end
CI-->>CI: Pipeline completes with gating results
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
4931836 to
06c7528
Compare
Summary
Before: a developer could add, rename, or remove a protocol field without every SDK constructing or consuming it.
Before: SDK-only options could drift between TypeScript Zod schemas, Python declarations and runtime models, and Go structs.
Before: public creation and browser options could be added without updating the reference and configuration docs.
Stagehand.createfields are checked structurally, and browser and logging fields must appear in the guides.Before: a registered operation could be omitted from its receiving endpoint or wired in the wrong direction.
Before: the protocol-schema lint checked obsolete
paramsSchemaandresultSchemaproperties.paramsandresultregistry entries.Validation
page.screenshot.result.typedrift; PR Remove screenshot type from protocol results #2754 removes the exemption with the protocol fix.Summary by cubic
Tightens cross-language protocol pipeline checks and documentation completeness to prevent SDK drift. AST-based tests now enforce field construction/consumption, single-endpoint routing, and canonical schema references across TypeScript, Python, and Go, and CI runs them.
Field pipeline: constructs or forwards every request field and consumes every result field; supports rest-spread adapters; exempts
page.screenshot.type.Routing parity: each protocol operation is handled by exactly one receiving endpoint (extension or SDK); SDK outbound/inbound sets match the extension router.
SDK schema parity and docs: compares TS Zod schemas with Python declarations/runtime models and Go structs;
Stagehand.createfields align across languages and are documented structurally; browser and logging fields appear in configuration guides; every RPC-backed TypeScript object with public methods has a reference page; exempts legacyextension_idoverrides inLocalBrowserConnectOptionsandBrowserbaseConnectOptionsfrom doc mention checks.Linting and CI:
no-loose-json-schema-in-protocol-operationsrequiresparams/resultinStagehandMethods/StagehandNotificationsto reference canonical schemas; CI runs viapnpm test:unit.Required migration: replace any remaining
paramsSchema/resultSchemawithparams/resultthat reference the canonical schemas.Written for commit 677e7e5. Summary will update on new commits.