Skip to content

WIP: support draft APIs - #853

Draft
mavemuri wants to merge 5 commits into
mainfrom
api-next
Draft

WIP: support draft APIs #853
mavemuri wants to merge 5 commits into
mainfrom
api-next

Conversation

@mavemuri

Copy link
Copy Markdown
Contributor

What changed?

Why?

Breaking changes

Server PR

@stephanos
stephanos self-requested a review August 18, 2026 19:00
@mavemuri
mavemuri force-pushed the api-next branch 5 times, most recently from a1fbfa1 to ed02781 Compare August 28, 2026 23:56
)

// draftTags is the set of fully-qualified extension names that mark a
// declaration as experimental/draft.

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.

nit: we should align on "experimental" or "draft" and not use them interchangeably. I think "draft" makes most sense as we already use "experimental" in stable API comments.

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.

This also applies to the proto file name.


package temporal.api.batch.v1;

option go_package = "go.temporal.io/api/batch/v1;batch";

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.

Given there's some churn in these files (e.g. moved options, changed indentation), why don't we land a PR before any of this to only format these files the same way already? That makes the change here much smaller. If I see this right, a simple buf format -w should do the trick. That also ensures that both set of files (api and api_next) look the same structurally; it'd be odd if they didn't.

session := &ir.Session{}
opener := baseOpener(root)

// first, lower the api_next set into ir

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.

nit: IMO it's a good habit to write all comments as full sentences ie capitalized and with .. For consistency.

@@ -0,0 +1,762 @@
syntax = "proto3";

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.

nit: calling out the obvious but still calling it out; these files should me "moved" as far as git must be concerned.


stableOrder := make([]string, 0, len(paths))
protoTexts := make(map[string]string, len(paths))
for p, irFile := range byPath {

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.

do we need stableOrder? I'd simplify it and only return protoTexts and use paths := slices.Sorted(maps.Keys(texts)) as needed. Less efficient; but that doesn't matter here and it's simpler.

return writeFiles(outDir, stableProtos)
}

func addGeneratedHeader(protos map[string]string) {

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.

nit: personally; I'd inline a function like this (ie both fairly short and only used once) as I find it easier to read from top to bottom than jump back and forth between function calls.

}

// re-lower one more time to ensure there are no compilation issues
func verifyGeneratedProtos(ctx context.Context, root string, stableTexts map[string]string) error {

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.

Good idea!

Comment on lines +26 to +28
// of the disk corpus and WKTs. Used by stripUnusedImports (re-lowering
// draft-stripped text) and verifyStrippedProtos (combined cross-file
// verification of the final stable tree).

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.

nit: I strip the used by ... part as (a) it's easy to lookup where a function is used and (b) it's easy to become stale

Comment on lines +163 to +170
relowerQueries := make([]incremental.Query[*ir.File], len(order))
for i, p := range order {
relowerQueries[i] = queries.IR{Opener: opener, Session: session, Path: p}
}
results, err := lowerFiles(ctx, relowerQueries...)
if err != nil {
return nil, fmt.Errorf("re-lower draft-stripped corpus: %w", err)
}

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.

There might be a helper opportunity here; I see three places create a session, construct queries, lower.

if err != nil {
return fmt.Errorf("verify stable tree failed: %w", err)
}
var jErr error

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.

what's the j for?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants