Skip to content

scriptmem: Execute — one entry, backend-routed, tagged Outcome#20

Merged
vinodhalaharvi merged 1 commit into
mainfrom
claude/execute-envelope
May 24, 2026
Merged

scriptmem: Execute — one entry, backend-routed, tagged Outcome#20
vinodhalaharvi merged 1 commit into
mainfrom
claude/execute-envelope

Conversation

@vinodhalaharvi-claude
Copy link
Copy Markdown
Collaborator

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 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}

The tagged Outcome

Outcome{ Backend, Result, Plan }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 is chosen by the DSL the LLM emits (the memory|temporal keyword), driven by the grammar prompt, not the caller.

Why it 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 (running memory is the runtime).

Tests

  • 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, covered by runtime's own tests)
  • unknown verb rejected on both backends (UnknownBuiltinError) before any execution — safety net through the envelope
  • historical verb on temporal → NotImplementedOnBackendError, no plan
Step Result
go vet / gofmt / staticcheck
go test -race ./...
go build ./...
pkg/script stays lean

⚠️ Known follow-up (not this PR)

Found while testing: 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 effectively temporal-only). Worth a small reconciliation PR — either add echo to the runtime or mark it temporal-only in the catalog.

Next

loom's memory-routing branch: import scriptmem, call Execute, branch on Outcome.Backend — post Result immediately (memory) or submit Plan + correlate + await (temporal, today's path). That's the last mile: prose in Slack → actually runs.

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.
@vinodhalaharvi vinodhalaharvi merged commit 24e7df4 into main May 24, 2026
1 check passed
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