Skip to content

1/4 Add generated Go protocol models - #2414

Merged
monadoid merged 4 commits into
v4-spikefrom
go-models
Jul 28, 2026
Merged

1/4 Add generated Go protocol models#2414
monadoid merged 4 commits into
v4-spikefrom
go-models

Conversation

@monadoid

@monadoid monadoid commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Adds generated Go structs, enums, and union types for the Stagehand protocol.

@changeset-bot

changeset-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ef7354e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@socket-security

socket-security Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgolang/​github.com/​atombender/​go-jsonschema@​v0.23.199100100100100

View full report

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 16 files

Confidence score: 5/5

  • In packages/sdk-go/scalar_unions.go, VariablePrimitive and ScrollPercent decoding paths (especially discriminator/default branches) are under-tested, so subtle union-regression bugs could slip through and mis-handle numeric/string payloads at runtime; add focused round-trip tests for each variant and invalid non-scalar inputs to lock behavior down.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/sdk-go/scalar_unions.go">

<violation number="1" location="packages/sdk-go/scalar_unions.go:213">
P3: Successful numeric/string decoding for `VariablePrimitive` and `ScrollPercent` lacks focused coverage, leaving their discriminator/default branches unprotected. Add round-trip cases for each variant plus invalid non-scalar input.

(Based on your team's feedback about unit tests for new behavior.) [FEEDBACK_USED]</violation>
</file>
Architecture diagram
sequenceDiagram
    participant Proto as Protocol Schema
    participant Gen as Go Generator
    participant SDK as Go SDK Package
    participant CI as CI Pipeline
    participant Dev as Developer

    Note over Proto,Dev: Code Generation Pipeline

    Dev->>Gen: Run "go generate ./..."
    Gen->>Proto: Read stagehand.v4.json
    Proto-->>Gen: Schema definitions
    Gen->>Gen: Project schema (remove unions/unsupported)
    Gen->>Gen: Pass projected schema to go-jsonschema
    Gen-->>SDK: Write models.gen.go

    alt CI check mode
        CI->>Gen: Run generator --check
        Gen->>Proto: Read stagehand.v4.json
        Gen->>SDK: Read existing models.gen.go
        alt Generated files match
            Gen-->>CI: Exit 0
        else Stale generated files
            Gen-->>CI: Exit 1
        end
    end

    Note over Dev,SDK: Build & Test Workflow

    Dev->>SDK: go build ./...
    Dev->>SDK: go vet ./...
    Dev->>SDK: go test ./...
    SDK->>SDK: Run unit tests

    Note over SDK,Proto: Type System Boundary

    SDK->>SDK: Generated types (models.gen.go)
    SDK->>SDK: Hand-written union types (object_unions.go)
    SDK->>SDK: Hand-written union types (scalar_unions.go)
    SDK->>SDK: Hand-written union types (llm_unions.go)
    SDK->>SDK: Flexible object handling (flexible_objects.go)

    Note over SDK: Marshal/Unmarshal Flow

    SDK->>SDK: JSON input arrives
    alt Object union (type discriminator)
        SDK->>SDK: Check "type" field
        alt Known type
            SDK->>SDK: Unmarshal to specific struct
        else Unknown type
            SDK-->>SDK: Return error
        end
    else Scalar union (JSON type)
        SDK->>SDK: Check first JSON byte
        alt String
            SDK->>SDK: Unmarshal as string
        else Number
            SDK->>SDK: Unmarshal as number
        else Boolean
            SDK->>SDK: Unmarshal as bool
        end
    else Flexible object
        SDK->>SDK: Unmarshal known fields
        SDK->>SDK: Capture additional properties
    end
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/sdk-go/models.gen.go
Comment thread packages/sdk-go/scalar_unions.go Outdated
Comment thread justfile Outdated
Comment thread packages/sdk-go/llm_unions.go
Comment thread packages/sdk-go/flexible_objects.go
Comment thread packages/sdk-go/idiomatic_go.md Outdated
Comment thread packages/sdk-go/scalar_unions.go
Comment thread justfile Outdated
Comment thread packages/sdk-go/models.gen.go
@monadoid monadoid changed the title Add generated Go protocol models 1/4 Add generated Go protocol models Jul 28, 2026
@monadoid
monadoid merged commit 77b4231 into v4-spike Jul 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants