Repository navigation
Run a template's logic in Clojure, with Trustblocks' own runtime - #1
Merged
Merged
Conversation
The playground's TypeScript logic runtime is replaced by Trustblocks' clause runtime -- trustblocks-logic.js, built from trustblocks-templates' runtime/ -- so a request gets exactly the answer it gets in Trustblocks, lifecycle and all. Accord's own playground remains the place for TypeScript logic. - The sandbox iframe receives the runtime's text once and keeps a worker holding it; check, nextSteps and trigger run there, with the same timeout kill-switch, and the iframe still loads no script by URL. - "Compile" is the runtime's check: the clause is built without running, and anything outside the vocabulary is refused. "Init" starts with no state and asks what can happen first; "trigger" is one step -- lifecycle, then clause -- with a simulated certification and a settable `now`. A lifecycle with no clause (the vendor form) runs too. - The Logic step edits clause.clj in Monaco's Clojure mode; its skeleton from the model is a Clojure clause, tested against the runtime. - scripts/sync-trustblocks.mjs brings in the runtime and Trustblocks' templates as samples, from the trustblocks-templates commit trustblocks.json pins, and bundles the shared models they import. Design-v2's start cards are the pay request, the Town Manager contract and the vendor form. Accord's TypeScript-logic samples stay in the tree, unlisted, for easy merges from upstream. - GitHub Pages: base path, router basename, share links and public assets work under a sub-path; .github/workflows/pages.yml builds the runtime and samples from source, tests, and deploys. - Branded as Trustblocks' fork of Accord Project's playground. Tests: upstream's unit tests rewritten where they asserted the TypeScript path (309 pass); e2e/trustblocks.spec.ts drives a pay request and the vendor form through their lifecycles in a browser. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Step 3 of the SCI playground. The playground's TypeScript logic runtime is replaced by Trustblocks' clause runtime:
trustblocks-logic.js, built from trustblocks-templates'runtime/. A request gets exactly the answer it gets in Trustblocks, lifecycle and all. Accord's own playground stays the place for TypeScript logic.Base:
trustblocksis Accord'swebmcp-poc(so the WebMCP agent relay is kept in the dev build) with Accord's latestmainmerged in.upstream= accordproject/template-playground, for pulling their updates.What changes
The sandbox runs our runtime.
trustblocks-logic.jsas text, once. It still loads no script by URL.check,nextStepsandtriggerrun there, with the same 5-second kill switch; a timed-out worker is replaced."Compile" is the runtime's check. The clause is built without running, and anything outside the vocabulary is refused. For example,
(rand)is refused with Refused by the clause vocabulary: …."Init" starts with no state and asks the lifecycle what can happen first.
"Trigger" is one step, exactly as Trustblocks takes it: the lifecycle, then the clause.
simulateNow; with none set, the step is taken at the current time. There's no UI control for it yet.The Logic step edits
clause.cljin Monaco's Clojure mode. The skeleton it builds frommodel.ctois now a Clojure clause, and it's tested against the real runtime.Samples come from trustblocks-templates.
scripts/sync-trustblocks.mjsbrings in:agreement,attestation,usa.state), added to the built-in set;request.json, a default request: the first event its lifecycle allows.It reads the trustblocks-templates commit pinned in
trustblocks.json.Design-v2's start cards are the Contractor Pay Request, the Town Manager Contract and the Vendor Information Form. Design-v2 and logic are on by default. Accord's TypeScript-logic samples stay in the tree, unlisted, so merges from upstream stay clean.
GitHub Pages.
/template-playground/..github/workflows/pages.ymlchecks out trustblocks-templates at the pinned commit, runsbb logic-bundle, syncs, and fails if the committed samples differ from what that commit gives. Then it runs the unit tests, builds, and deploys on push totrustblocks.Branding: "Trustblocks · Template Playground", described as Trustblocks' fork of Accord Project's playground, with Accord's wordmark as credit. The README says what the fork is.
Tests
executionHistory,sandbox,compileLogic,SandboxFrame,logicSource,LogicViewand others. The logic skeleton is now checked and run through the real runtime.e2e/trustblocks.spec.ts, run in Chrome withPW_CHANNEL=chrome: 2 of 2 pass.InspectionCertified cannot happen before the lifecycle has begun (no-transition), then received underRECEIVE_PAY_APPLICATIONS, then inspected, with the clause recording the approved item./template-playground/in Chrome: the runtime loads, the clause is checked, and the refusal reads as in Trustblocks.npm run lintfails upstream too;store.tsalone had 23 errors before this change.Known, and left alone
webmcp-poc, dev only.🤖 Generated with Claude Code