scriptmem: Execute — one entry, backend-routed, tagged Outcome#20
Merged
Conversation
The unified execution entry that hides the backend split behind a single
call. A front end hands over prose (+ discovery + an LLM) and gets back
an Outcome that is EITHER a finished in-memory result OR a temporal plan
to submit. The front end branches only on the Outcome's execution shape
— never on the grammar, the verbs, or the backend keyword.
Execute(ctx, complete, GrammarInfo, MemoryConfig, prose) -> Outcome
translate (LLM) -> parse -> resolve -> inspect backend -> either:
memory : RunMemory in-process -> Outcome{Memory, Result}
temporal : Compile to a durable plan -> Outcome{Temporal, Plan}
Outcome is a tagged union: Backend selects which arm is meaningful
(Result for memory, Plan for temporal). The caller (loom) branches on
Backend to pick its delivery shape — post the result now, or submit +
correlate + await — learning only the execution shape, never the
grammar. The backend itself is chosen by the DSL the LLM emits
(memory|temporal keyword), driven by the grammar prompt, not the caller.
Lives in scriptmem (not script): executing memory needs the in-process
runtime + its dep tree, so the envelope that may run memory belongs with
it. pkg/script stays lean (verified) — callers that only translate/
compile pay nothing for the runtime; a caller that wants real execution
imports scriptmem and accepts the deps, which is honest.
Tests (execute_test.go):
- temporal program -> Outcome{Temporal} with a 2-node plan, no result;
- memory program ROUTES to the runtime (asserts no plan is produced;
live verb output needs credentials and is covered by runtime tests);
- unknown verb rejected on both backends (UnknownBuiltinError) before
any execution — safety net through the envelope;
- historical verb on temporal -> NotImplementedOnBackendError, no plan.
KNOWN FOLLOW-UP (not this PR): the catalog marks echo memory-capable, but
the in-memory runtime has no echo case, so 'memory static ( echo )'
resolves then fails at runtime ('unknown action: echo'). The catalog and
the runtime's actual verb set are slightly misaligned (echo is a
temporal-only builtin). Worth a small reconciliation PR — either add echo
to the runtime or mark it temporal-only in the catalog.
CI: vet, gofmt, staticcheck, go test -race ./..., go build ./... pass.
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 unified execution entry that hides the backend split behind a single call. A front end hands over prose (+ discovery + an LLM) and gets back an
Outcomethat is either a finished in-memory result or a temporal plan to submit. The front end branches only on the Outcome's execution shape — never on the grammar, the verbs, or the backend keyword.The tagged Outcome
Outcome{ Backend, Result, Plan }—Backendselects which arm is meaningful (Resultfor memory,Planfor temporal). The caller (loom) branches onBackendto pick its delivery shape — post the result now, or submit + correlate + await — learning only the execution shape, never the grammar. The backend is chosen by the DSL the LLM emits (thememory|temporalkeyword), driven by the grammar prompt, not the caller.Why it lives in
scriptmem(notscript)Executing memory needs the in-process runtime + its dep tree, so the envelope that may run memory belongs with it.
pkg/scriptstays lean (verified) — callers that only translate/compile pay nothing for the runtime; a caller that wants real execution importsscriptmemand accepts the deps, which is honest (running memory is the runtime).Tests
Outcome{Temporal}with a 2-node plan, no resultUnknownBuiltinError) before any execution — safety net through the envelopeNotImplementedOnBackendError, no plango vet/gofmt/staticcheckgo test -race ./...go build ./...pkg/scriptstays leanFound while testing: the catalog marks
echomemory-capable, but the in-memory runtime has noechocase, somemory static ( echo )resolves then fails at runtime ("unknown action: echo"). The catalog and the runtime's actual verb set are slightly misaligned (echois effectively temporal-only). Worth a small reconciliation PR — either addechoto the runtime or mark it temporal-only in the catalog.Next
loom's memory-routing branch: import
scriptmem, callExecute, branch onOutcome.Backend— postResultimmediately (memory) or submitPlan+ correlate + await (temporal, today's path). That's the last mile: prose in Slack → actually runs.