torb: wait for a task without a task top level, so the client can use std/http #30
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The package manager downloads with
curl/wgetbecausetorbcannot wait for a task without making its top level one.Source
Acceptance criteria
torbto run a task to completion from synchronous codestd/httpcurl/wgetno longer requiredDependencies
None known.
Moved from the planning lists of the docs; the design record stays the specification.
[loop:torbscript] intake: in scope as an issue (author orion, label loop), with an owner question: a way to run a task to completion from synchronous code is a language/runtime design choice not settled in a design record (and touches task semantics). To be filed as owner decision in refine. Release freeze for 0.1.0 (2026-10-06) holds new PRs, next: refine (owner decision expected)
[loop:torbscript] refine: still queued behind the intake order. next: waiting (ready buffer full: #4, #163, #164, #223 are ready) until 2026-10-10T04:00:00Z
[loop:torbscript] claim refine by session:loop-torbscript-20261012 until 2026-10-12T15:14Z
[loop:torbscript] decided by the loop: scope of #30 is the language/runtime half only; the client migration is split into #333 (depends on this issue and on a seed refresh). Reasoning from the code:
torb's top level must not await (anawait()makes the entry file the main task, andruntime/task.ctorb_scheduler_runrefuses to run "from inside a task", whichtorb run/torb testneed to start the VM). Sotorbneeds a wait that does not make its caller a task.Task<Value>.runToEnd(): Result<Value, Cancelled>(method, not a free function, per #146 and the design rules;Resultlikeresult()because a task can be cancelled, e.g. bywithin). From synchronous code on the main thread it runs the scheduler until the task completes (torb_scheduler_run(task), the primitive the generatedmainand the VM'sRUN_MAINalready use) and returns the answer; the scheduler is idle again afterwards, so a latertorb runis unaffected.torb_internal_error); no checker change, since a sync function cannot know its caller.torb_scheduler_run(until)+torb_task_result, in the C back end and the VM (runtime/machine.chas the operation pattern).Acceptance criteria (replace those in the issue body)
Task.runToEnd()is declared instd(preludeTask), documented indocs/design/CONCURRENCY.md(section 8/16 nearawait()/result()), with the single-caller rule (not inside a task, not on a worker) statedtests/conformance/programs where a top level without anyawait()runs astd/timesleeptask and astd/httprequest against a localstd/httpserver task to the end and reads the valuewithin(...)answersFail(Cancelled); a panicking task panics as it does todayrunToEnd()returned,torb_scheduler_runcan be called again (conformance: two sequential calls, then the VM'sRUN_MAINpath viatorb runof a program works)runtime/tests/task_test.cpins the nested-call refusal and the sequential-call case;skills/regenerated if docs changerunToEnd()incompiler/src(that is #333); the seed refresh after merge is the owner'sfeat(task): ...,docs(concurrency): ...)Design record:
docs/design/CONCURRENCY.md(task/main-task sections),docs/design/RELEASE.mdsection 7.13 (the "How the client fetches" row records this as the reason forcurl). ROADMAP: "The package manager" bullet.[loop:torbscript] refine: ready with narrowed scope (Task.runToEnd; client migration split to #333, waits on #30 + seed refresh), next: implement. Tokens: ~100k (sonnet worker)
[loop:torbscript] claim implement by session:loop-torbscript-20261012 until 2026-10-12T22:02Z
[loop:torbscript] release implement: the worker was terminated by a gateway restart before pushing anything; nothing to keep, restarting implementation.
[loop:torbscript] claim implement by session:loop-torbscript-20261012 until 2026-10-12T22:22Z