Repository navigation
feat: let a solution name the Task its module work contexts are minted under (Gateway.ForTask) - #43
Closed
met-obin-ai wants to merge 2 commits into
Closed
met-obin-ai wants to merge 2 commits into
met-obin-ai wants to merge 2 commits into
Conversation
…d under
ForModule draws a fresh taskId for every mint. A module that fences reads by
the Task a capability was minted under (a durable task runtime reads and lists
only the tasks admitted under the caller's own Task) therefore refuses every
read a later viewer request makes of work an earlier request started: the
second request's capability names a different Task.
Gateway.ForTask(ctx, Task{ID, TTLSeconds}, audience, scopes...) is ForModule
under a Task the solution names:
- Task.ID is sent to accounts' StartTask verbatim as taskId (accounts signs
it as given and accepts the same id again on a later mint). It must be a
hyphenated UUID, the form accounts validates (buf.validate string.uuid);
anything else, including an empty id, is refused before any request.
- Task.ID and Task.TTLSeconds are part of the cache identity, so two Tasks
never share a capability; one Task's ask still mints once per request.
- Task.TTLSeconds, when non-zero, is sent as ttlSeconds, which
StartTaskWorkContextRequest already carries; zero sends nothing.
- The org and session stay the viewer's, exactly as for ForModule.
ForModule is unchanged: same cache key bytes, a fresh taskId per mint, no
ttlSeconds on the wire. Additive API; no consumer breaks.
solution_test.go still named its second consumed module/scope after a document genre and business line (billing/invoices), the exact pattern IMPLEMENTER-RULES.md rule 3 forbids in a platform repo (never names a solution or a customer) and that a sibling commit (fb851fd, on the old pre-rebase fortask branch) already cleaned up elsewhere in this same file. That commit's patch does not apply here (this branch's solution_test.go has diverged), so this reapplies the identical mapping (billing -> alpha, invoices -> items) by hand at every site. Values and assertions are unchanged; no test is weakened.
Contributor
|
Superseded by e80369a: Gateway.ForModule and the accounts StartTask mint are deleted; minting goes through the authority (IssueForModule). Closed in the 2026-10-27 clean-up on the owner's instruction. |
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.
Why
Gateway.ForModulemints every module Work Context under a new Task:ask.TaskID = uuid.NewString()for each mint, and each viewer request gets a new gateway and cache. Some modules only let a caller read work admitted under the caller's own Task. A durable task runtime, for example, answersReadwithNOT_FOUNDunless tenant, owner and boundary match. With such a module, a later request can't read work that an earlier request started. So polling a run, reloading a page, and asking the same question again all get a 404.What changed
499bd4bfeat: let a solution name the Task its module work contexts are minted under. This is an additive API.ForModuleis unchanged: its cache-key bytes are the same, it still mints a newtaskIdeach time, and it sends nottlSeconds.Task.IDis sent to accounts'StartTaskexactly as given, astaskId. It must be a hyphenated UUID, the form accounts validates (buf.validate string.uuid). Any other value, including an empty id, is refused before a request is made.Task.IDandTask.TTLSecondsare part of the cache identity, so two Tasks never share a capability. One Task's ask still mints once per request.Task.TTLSecondsis sent asttlSeconds, a fieldStartTaskWorkContextRequestalready has. Zero sends nothing.ForModule.ForTask, andForModule's doc comment says when to useForTaskinstead.9081020test: use structural fixture names instead of a business genre.solution_test.gorenamed a consumed module and scopealpha/items. Values and assertions are unchanged.4 files, +353 −22 (
README.md,solution.go,solution_test.go,work_context_task_test.go).Tests
New tests are in
work_context_task_test.go:TestForTaskSendsTheNamedTaskVerbatim,TestForTaskNeverSharesAContextBetweenTasks,TestForTaskReusesTheContextOfTheSameTask,TestForTaskRefusesATaskIDAccountsWouldNot,TestForTaskSendsTheTTLWhenGiven,TestForModuleStillNamesAFreshTaskPerMint.Mutations of
solution.go, each run against this suite (all red, and green again once restored):…SendsTheNamedTaskVerbatimand…NeverSharesAContextBetweenTasks.…RefusesATaskIDAccountsWouldNot.TTLSecondsfails…SendsTheTTLWhenGiven.…NeverSharesAContextBetweenTasks.These are the
go.ymlsteps, run locally with go 1.27.1 (the workflow uses 1.27.0 fromgo.mod):9081020(this branch)main(8da58cd, merges without conflicts)go mod download && go mod verifygo test -race ./... -count=1 -timeout=5mgo vet ./...gofmt -l ./*.goNot verified
task_idwas measured separately against a live host (two mints with the sametask_idand different nonces), outside this suite.ttlSecondshas never been sent to a live Accounts.v0.0.11(89e1aea) and is 9 commits behindmain. It merges cleanly, and the merged tree passes the table above, but the branch has not been merged forward, so the commit shas stay stable for a downstream consumer that pins this change as a pseudo-version.