Repository navigation
feat(go)!: the traust package: typed calls, iterators, ProcessExecutor, traustest, a user guide - #48
Merged
Merged
Conversation
…cutor, apitest, a user guide
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: smith-xyz The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
….Client, traustest
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.
What
The SDK does the work for the user, on par with cloud SDKs: every operation is a typed call, every listing an iterator, the run lifecycle includes a ready executor, there's a fake core for tests, and the README is a guide.
api:api.NewBoundClient(api.ClientConfig{…})→*api.BoundClienttraust(go/v1/traust):traust.NewClient(traust.Config{…})→*traust.Client;traust.Repository,traust.ProblemError, …; the raw generated client isRawClient/NewRawClient(oapi-codegenclient-type-name+ the calls generator)resp, err := c.GetRepositoryWithResponse(…), thentraust.Decode(resp.HTTPResponse, resp.Body, resp.JSON200)on every callc.GetRepository(ctx, id)→(*traust.Repository, error): one generated call per operation (calls.gen.go, 69 ops). Lists return[]T; artifact content returns the bytes;Claimreturnsnil, nilon 204EachProduct/EachRepository…Alliterator for every paged listing (12, includingReadFeedAll), Go 1.23range-over-funcops.ProcessExecutor: no shell, own process group, killed with its descendants on lease loss; stdout is the command'sJobResultJSON, or setOutcomePackdidn't expose its digest, so nobody outsideopscouldSubmita runnable orderPack.Pin()→ thetraust.ConfigDigestforSubmit;Pack.Assets()httptesttraustest:New(t)/Start(),Handle("GET /v1/…", apitest.JSON/Problem/Status),Client(),Requests(); unknown routes are a 404 problem naming themFileTokenSourcetraust.StaticTokenfor scripts, local dev and testsledger/skillsgo docexamples fortraust(lookup by URL, iterate pages, summarize findings, problem errors) andops(LoadPack,ProcessExecutor,Runner)go/README.mdopened withstorage/*sql.DB, ledger URLs and review-status proseThe calls and iterators are generated from the oapi-codegen client (
internal/generate/calls, run bymake api-generate, covered bycheck-drift), so there's no hand-written method per endpoint;AGENTS.mdnow says a better call shape is a generator change.opsuses the new calls internally (lease, recording run, record, runner), which removes the…WithResponse+Decodepairs there.Not in this PR: release tags (paused), and a local
traust-serverquickstart plus a token command in core.Breaking
The client package is
traust(wasapi), withNewClient/Client/Config(wereNewBoundClient/BoundClient/ClientConfig) andtraustest(wasapitest). The generated calls take the operation names, shadowing the raw*http.Responsemethods (still reachable asclient.ClientWithResponses.ClientInterface.X);…WithResponsekeeps the full response.EachProduct/EachRepository→ListProductsAll/ListRepositoriesAll. SCI'sinternal/traustcoreand the worker change the import togo/v1/traustandEachProduct/EachRepositoryto the iterators on their next bump.Changed tests
v1/traust/client_test.go(wasv1/api):TestFileTokenSourceRotates,TestEachProductFollowsCursorAndReportsProblems→TestListProductsAllFollowsCursorAndReportsProblems,TestProblemErrorCarriesTheDocument,TestRetryAbsorbsTransientFailures,TestCallerHTTPClientPolicySurvivesclient.EachProduct(ctx, n, fn)→ aproducts(client, n)helper overListProductsAll; assertions unchangedEachProductis replaced by the generated iteratorv1/traust/e2e_test.go::TestE2EPagingDecodesAnEmptyInventoryEachRepository→ListRepositoriesAllv1/ops/runner_e2e_test.go::TestE2ERunnerRunsASubmittedPackCommandSubmitWithResponse+Decode+ hand-builtConfigDigest→Submit+pack.Pin(); private executor →ProcessExecutor;testdata/local-command.yamlprints aJobResultJSONv1/api→v1/traustapi→traust,BoundClient/NewBoundClient/ClientConfig→Client/NewClient/Config, error prefixesapi:→traust:; assertions unchangedTestE2ERunnerLocalCommandStopsDescendantsOnLeaseLoss→v1/ops/runner_unix_test.go::TestRunnerStopsACommandsDescendantsOnLeaseLossProcessExecutorwithsh, a "started" marker proving the command ran, lease lost on the 6th heartbeat; same assertions (no complete, descendant dead)New: an
traustesttest,TestProcessExecutorTurnsOutputIntoTheResult,TestProcessExecutorStopsDescendantsOnCancel,TestPackPinsOrdersAndListsItsAssets, examples with// Output:.Checks
make lint test security guardrails,go test -race ./v1/traust/... ./v1/opsmake -C go check-drift;GOOS=windows go build ./v1/ops ./v1/traust/...(non-unixProcessExecutorstub)make e2eagainst coreb72bf77(6 passed)