Add 5 MCP tools, refactor nav-data, fix deep path bug, fix Playwright failures

Nav refactoring:
- Split nav-data.sx (32 forms) into 6 files: nav-geography, nav-language,
  nav-applications, nav-etc, nav-tools, nav-tree
- Add Tools top-level nav category with SX Tools and Services pages
- New services-tools.sx page documenting the rose-ash-services MCP server

JS build fixes (fixes 5 Playwright failures):
- Wire web/web-signals.sx into JS build (stores, events, resources)
- Add cek-try primitive to JS platform (island hydration error handling)
- Merge PRIMITIVES into getRenderEnv (island env was missing primitives)
- Rename web/signals.sx → web/web-signals.sx to avoid spec/ collision

New MCP tools:
- sx_trace: step-through CEK evaluation showing lookups, calls, returns
- sx_deps: dependency analysis — free symbols + cross-file resolution
- sx_build_manifest: show build contents for JS and OCaml targets
- sx_harness_eval extended: multi-file loading + setup expressions

Deep path bug fix:
- Native OCaml list-replace and navigate bypass CEK callback chain
- Fixes sx_replace_node and sx_read_subtree corruption on paths 6+ deep

Tests: 1478/1478 JS full suite, 91/91 Playwright

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-26 12:09:22 +00:00
parent 4e88b8a9dd
commit 5ed984e7e3
18 changed files with 3620 additions and 112 deletions

View File

@@ -0,0 +1,8 @@
;; Navigation items for the Applications section
(define protocols-nav-items (list (dict :label "Wire Format" :href "/sx/(applications.(protocol.wire-format))") (dict :label "Fragments" :href "/sx/(applications.(protocol.fragments))") (dict :label "Resolver I/O" :href "/sx/(applications.(protocol.resolver-io))") (dict :label "Internal Services" :href "/sx/(applications.(protocol.internal-services))") (dict :label "ActivityPub" :href "/sx/(applications.(protocol.activitypub))") (dict :label "Future" :href "/sx/(applications.(protocol.future))")))
(define cssx-nav-items (list (dict :label "Overview" :href "/sx/(applications.(cssx))") (dict :label "Patterns" :href "/sx/(applications.(cssx.patterns))") (dict :label "Delivery" :href "/sx/(applications.(cssx.delivery))") (dict :label "Async CSS" :href "/sx/(applications.(cssx.async))") (dict :label "Live Styles" :href "/sx/(applications.(cssx.live))") (dict :label "Comparisons" :href "/sx/(applications.(cssx.comparison))") (dict :label "Philosophy" :href "/sx/(applications.(cssx.philosophy))")))
(define reactive-runtime-nav-items (list (dict :label "Ref" :href "/sx/(applications.(reactive-runtime.ref))") (dict :label "Foreign FFI" :href "/sx/(applications.(reactive-runtime.foreign))") (dict :label "State Machines" :href "/sx/(applications.(reactive-runtime.machine))") (dict :label "Commands" :href "/sx/(applications.(reactive-runtime.commands))") (dict :label "Render Loop" :href "/sx/(applications.(reactive-runtime.loop))") (dict :label "Keyed Lists" :href "/sx/(applications.(reactive-runtime.keyed-lists))") (dict :label "App Shell" :href "/sx/(applications.(reactive-runtime.app-shell))")))

8
sx/sx/nav-etc.sx Normal file

File diff suppressed because one or more lines are too long

16
sx/sx/nav-geography.sx Normal file
View File

@@ -0,0 +1,16 @@
;; Navigation items for the Geography section
(define reference-nav-items (list (dict :label "Attributes" :href "/sx/(geography.(hypermedia.(reference.attributes)))") (dict :label "Headers" :href "/sx/(geography.(hypermedia.(reference.headers)))") (dict :label "Events" :href "/sx/(geography.(hypermedia.(reference.events)))") (dict :label "JS API" :href "/sx/(geography.(hypermedia.(reference.js-api)))")))
(define examples-nav-items (list (dict :label "Click to Load" :href "/sx/(geography.(hypermedia.(example.click-to-load)))") (dict :label "Form Submission" :href "/sx/(geography.(hypermedia.(example.form-submission)))") (dict :label "Polling" :href "/sx/(geography.(hypermedia.(example.polling)))") (dict :label "Delete Row" :href "/sx/(geography.(hypermedia.(example.delete-row)))") (dict :label "Inline Edit" :href "/sx/(geography.(hypermedia.(example.inline-edit)))") (dict :label "OOB Swaps" :href "/sx/(geography.(hypermedia.(example.oob-swaps)))") (dict :label "Lazy Loading" :href "/sx/(geography.(hypermedia.(example.lazy-loading)))") (dict :label "Infinite Scroll" :href "/sx/(geography.(hypermedia.(example.infinite-scroll)))") (dict :label "Progress Bar" :href "/sx/(geography.(hypermedia.(example.progress-bar)))") (dict :label "Active Search" :href "/sx/(geography.(hypermedia.(example.active-search)))") (dict :label "Inline Validation" :href "/sx/(geography.(hypermedia.(example.inline-validation)))") (dict :label "Value Select" :href "/sx/(geography.(hypermedia.(example.value-select)))") (dict :label "Reset on Submit" :href "/sx/(geography.(hypermedia.(example.reset-on-submit)))") (dict :label "Edit Row" :href "/sx/(geography.(hypermedia.(example.edit-row)))") (dict :label "Bulk Update" :href "/sx/(geography.(hypermedia.(example.bulk-update)))") (dict :label "Swap Positions" :href "/sx/(geography.(hypermedia.(example.swap-positions)))") (dict :label "Select Filter" :href "/sx/(geography.(hypermedia.(example.select-filter)))") (dict :label "Tabs" :href "/sx/(geography.(hypermedia.(example.tabs)))") (dict :label "Animations" :href "/sx/(geography.(hypermedia.(example.animations)))") (dict :label "Dialogs" :href "/sx/(geography.(hypermedia.(example.dialogs)))") (dict :label "Keyboard Shortcuts" :href "/sx/(geography.(hypermedia.(example.keyboard-shortcuts)))") (dict :label "PUT / PATCH" :href "/sx/(geography.(hypermedia.(example.put-patch)))") (dict :label "JSON Encoding" :href "/sx/(geography.(hypermedia.(example.json-encoding)))") (dict :label "Vals & Headers" :href "/sx/(geography.(hypermedia.(example.vals-and-headers)))") (dict :label "Loading States" :href "/sx/(geography.(hypermedia.(example.loading-states)))") (dict :label "Request Abort" :href "/sx/(geography.(hypermedia.(example.sync-replace)))") (dict :label "Retry" :href "/sx/(geography.(hypermedia.(example.retry)))")))
(define isomorphism-nav-items (list (dict :label "Roadmap" :href "/sx/(geography.(isomorphism))") (dict :label "Bundle Analyzer" :href "/sx/(geography.(isomorphism.bundle-analyzer))") (dict :label "Routing Analyzer" :href "/sx/(geography.(isomorphism.routing-analyzer))") (dict :label "Data Test" :href "/sx/(geography.(isomorphism.data-test))") (dict :label "Async IO" :href "/sx/(geography.(isomorphism.async-io))") (dict :label "Streaming" :href "/sx/(geography.(isomorphism.streaming))") (dict :label "Affinity" :href "/sx/(geography.(isomorphism.affinity))") (dict :label "Optimistic" :href "/sx/(geography.(isomorphism.optimistic))") (dict :label "Offline" :href "/sx/(geography.(isomorphism.offline))")))
(define cek-nav-items (list (dict :label "Overview" :href "/sx/(geography.(cek))" :summary "The CEK machine — explicit evaluator with Control, Environment, Kontinuation. Three registers, pure step function.") (dict :label "Demo" :href "/sx/(geography.(cek.demo))" :summary "Live islands evaluated by the CEK machine. Counter, computed chains, reactive attributes — all through explicit continuation frames.") (dict :label "Freeze / Thaw" :href "/sx/(geography.(cek.freeze))" :summary "Serialize a CEK state to s-expressions. Ship it, store it, content-address it. Thaw and resume anywhere.") (dict :label "Content Addressing" :href "/sx/(geography.(cek.content))" :summary "Hash frozen state to a CID. Same state = same address. Store, share, verify, reproduce.")))
(define reactive-examples-nav-items (list {:href "/sx/(geography.(reactive.(examples.counter)))" :label "Counter"} {:href "/sx/(geography.(reactive.(examples.temperature)))" :label "Temperature"} {:href "/sx/(geography.(reactive.(examples.stopwatch)))" :label "Stopwatch"} {:href "/sx/(geography.(reactive.(examples.imperative)))" :label "Imperative"} {:href "/sx/(geography.(reactive.(examples.reactive-list)))" :label "Reactive List"} {:href "/sx/(geography.(reactive.(examples.input-binding)))" :label "Input Binding"} {:href "/sx/(geography.(reactive.(examples.portal)))" :label "Portals"} {:href "/sx/(geography.(reactive.(examples.error-boundary)))" :label "Error Boundary"} {:href "/sx/(geography.(reactive.(examples.refs)))" :label "Refs"} {:href "/sx/(geography.(reactive.(examples.dynamic-class)))" :label "Dynamic Class"} {:href "/sx/(geography.(reactive.(examples.resource)))" :label "Resource"} {:href "/sx/(geography.(reactive.(examples.transition)))" :label "Transitions"} {:href "/sx/(geography.(reactive.(examples.stores)))" :label "Stores"} {:href "/sx/(geography.(reactive.(examples.event-bridge-demo)))" :label "Event Bridge"} {:href "/sx/(geography.(reactive.(examples.defisland)))" :label "defisland"} {:href "/sx/(geography.(reactive.(examples.tests)))" :label "Tests"} {:href "/sx/(geography.(reactive.(examples.coverage)))" :label "Coverage"} {:href "/sx/(geography.(reactive.(examples.cyst)))" :label "Cyst"} {:href "/sx/(geography.(reactive.(examples.reactive-expressions)))" :label "Reactive Expressions"}))
(define reactive-islands-nav-items (list (dict :label "Examples" :href "/sx/(geography.(reactive.(examples)))" :summary "Live interactive islands — click the buttons, type in the inputs." :children reactive-examples-nav-items)))
(define marshes-examples-nav-items (list {:href "/sx/(geography.(marshes.hypermedia-feeds))" :label "Hypermedia Feeds State"} {:href "/sx/(geography.(marshes.server-signals))" :label "Server Writes to Signals"} {:href "/sx/(geography.(marshes.on-settle))" :label "sx-on-settle"} {:href "/sx/(geography.(marshes.signal-triggers))" :label "Signal-Bound Triggers"} {:href "/sx/(geography.(marshes.view-transform))" :label "Reactive View Transform"}))

26
sx/sx/nav-language.sx Normal file
View File

@@ -0,0 +1,26 @@
;; Navigation items for the Language section (docs, specs, testing, bootstrappers)
(define docs-nav-items (list (dict :label "Introduction" :href "/sx/(language.(doc.introduction))") (dict :label "Getting Started" :href "/sx/(language.(doc.getting-started))") (dict :label "Components" :href "/sx/(language.(doc.components))") (dict :label "Evaluator" :href "/sx/(language.(doc.evaluator))") (dict :label "Primitives" :href "/sx/(language.(doc.primitives))") (dict :label "Special Forms" :href "/sx/(language.(doc.special-forms))") (dict :label "Server Rendering" :href "/sx/(language.(doc.server-rendering))")))
(define specs-nav-items (list {:href "/sx/(language.(spec.core))" :children (list {:href "/sx/(language.(spec.parser))" :label "Parser"} {:href "/sx/(language.(spec.evaluator))" :label "Evaluator"} {:href "/sx/(language.(spec.primitives))" :label "Primitives"} {:href "/sx/(language.(spec.special-forms))" :label "Special Forms"} {:href "/sx/(language.(spec.renderer))" :label "Renderer"}) :label "Core"} {:href "/sx/(language.(spec.adapters))" :children (list {:href "/sx/(language.(spec.adapter-dom))" :label "DOM Adapter"} {:href "/sx/(language.(spec.adapter-html))" :label "HTML Adapter"} {:href "/sx/(language.(spec.adapter-sx))" :label "SX Wire Adapter"} {:href "/sx/(language.(spec.adapter-async))" :label "Async Adapter"}) :label "Adapters"} {:href "/sx/(language.(spec.browser))" :children (list {:href "/sx/(language.(spec.engine))" :label "SxEngine"} {:href "/sx/(language.(spec.orchestration))" :label "Orchestration"} {:href "/sx/(language.(spec.boot))" :label "Boot"} {:href "/sx/(language.(spec.router))" :label "Router"}) :label "Browser"} {:href "/sx/(language.(spec.reactive))" :children (list {:href "/sx/(language.(spec.signals))" :label "Signals"} {:href "/sx/(language.(spec.frames))" :label "CEK Frames"} {:href "/sx/(language.(spec.cek))" :label "CEK Machine"}) :label "Reactive"} {:href "/sx/(language.(spec.host))" :children (list {:href "/sx/(language.(spec.boundary))" :label "Boundary"} {:href "/sx/(language.(spec.forms))" :label "Forms"} {:href "/sx/(language.(spec.page-helpers))" :label "Page Helpers"}) :label "Host Interface"} {:href "/sx/(language.(spec.extensions))" :children (list {:href "/sx/(language.(spec.continuations))" :label "Continuations"} {:href "/sx/(language.(spec.callcc))" :label "call/cc"} {:href "/sx/(language.(spec.types))" :label "Types"} {:href "/sx/(language.(spec.deps))" :label "Deps"}) :label "Extensions"}))
(define testing-nav-items (list (dict :label "Overview" :href "/sx/(language.(test))") (dict :label "Evaluator" :href "/sx/(language.(test.eval))") (dict :label "Parser" :href "/sx/(language.(test.parser))") (dict :label "Router" :href "/sx/(language.(test.router))") (dict :label "Renderer" :href "/sx/(language.(test.render))") (dict :label "Dependencies" :href "/sx/(language.(test.deps))") (dict :label "Engine" :href "/sx/(language.(test.engine))") (dict :label "Orchestration" :href "/sx/(language.(test.orchestration))") (dict :label "Runners" :href "/sx/(language.(test.runners))")))
(define bootstrappers-nav-items (list (dict :label "Overview" :href "/sx/(language.(bootstrapper))") (dict :label "JavaScript" :href "/sx/(language.(bootstrapper.javascript))") (dict :label "Python" :href "/sx/(language.(bootstrapper.python))") (dict :label "Self-Hosting (py.sx)" :href "/sx/(language.(bootstrapper.self-hosting))") (dict :label "Self-Hosting JS (js.sx)" :href "/sx/(language.(bootstrapper.self-hosting-js))") (dict :label "Page Helpers" :href "/sx/(language.(bootstrapper.page-helpers))")))
(define core-spec-items (list (dict :slug "parser" :filename "parser.sx" :title "Parser" :desc "Tokenization and parsing of SX source text into AST." :prose "The parser converts SX source text into an abstract syntax tree. It tokenizes the input into atoms, strings, numbers, keywords, and delimiters, then assembles them into nested list structures. The parser is intentionally minimal — s-expressions need very little syntax to parse. Special reader macros handle quasiquote (\\`), unquote (~), splice (~@), and the quote (') shorthand. The output is a tree of plain lists, symbols, keywords, strings, and numbers that the evaluator can walk directly.") (dict :slug "evaluator" :filename "evaluator.sx" :title "Evaluator" :desc "CEK machine evaluator." :prose "The evaluator walks the AST produced by the parser and reduces it to values. It implements lexical scoping with closures, special forms (define, let, if, cond, fn, defcomp, defmacro, quasiquote, set!, do), and function application. Macros are expanded at eval time. Component definitions (defcomp) create callable component objects that participate in the rendering pipeline. The evaluator delegates rendering expressions — HTML tags, components, fragments — to whichever adapter is active, making the same source renderable to DOM nodes, HTML strings, or SX wire format.") (dict :slug "primitives" :filename "primitives.sx" :title "Primitives" :desc "All built-in pure functions and their signatures." :prose "Primitives are the built-in functions available in every SX environment. Each entry declares a name, parameter signature, and semantics. Bootstrap compilers implement these natively per target (JavaScript, Python, etc.). The registry covers arithmetic, comparison, string manipulation, list operations, dict operations, type predicates, and control flow helpers. All primitives are pure — they take values and return values with no side effects. Platform-specific operations (DOM access, HTTP, file I/O) are provided separately via platform bridge functions, not primitives.") (dict :slug "special-forms" :filename "special-forms.sx" :title "Special Forms" :desc "All special forms — syntactic constructs with custom evaluation rules." :prose "Special forms are the syntactic constructs whose arguments are NOT evaluated before dispatch. Each form has its own evaluation rules — unlike primitives, which receive pre-evaluated values. Together with primitives, special forms define the complete language surface. The registry covers control flow (if, when, cond, case, and, or), binding (let, letrec, define, set!), functions (lambda, defcomp, defmacro), sequencing (begin, do, thread-first), quoting (quote, quasiquote), continuations (reset, shift), guards (dynamic-wind), higher-order forms (map, filter, reduce), and domain-specific definitions (defstyle, defhandler, defpage, defquery, defaction).") (dict :slug "renderer" :filename "render.sx" :title "Renderer" :desc "Shared rendering registries and utilities used by all adapters." :prose "The renderer defines what is renderable and how arguments are parsed, but not the output format. It maintains registries of known HTML tags, SVG tags, void elements, and boolean attributes. It specifies how keyword arguments on elements become HTML attributes, how children are collected, and how special attributes (class, style, data-*) are handled. All three adapters (DOM, HTML, SX wire) share these definitions so they agree on what constitutes valid markup.")))
(define adapter-spec-items (list (dict :slug "adapter-dom" :filename "adapter-dom.sx" :title "DOM Adapter" :desc "Renders SX expressions to live DOM nodes. Browser-only." :prose "The DOM adapter renders evaluated SX expressions into live browser DOM nodes — Elements, Text nodes, and DocumentFragments. It mirrors the HTML adapter's logic but produces DOM objects instead of strings. This is the adapter used by the browser-side SX runtime for initial mount, hydration, and dynamic updates. It handles element creation, attribute setting (including event handlers and style objects), SVG namespace handling, and fragment composition.") (dict :slug "adapter-html" :filename "adapter-html.sx" :title "HTML Adapter" :desc "Renders SX expressions to HTML strings. Server-side." :prose "The HTML adapter renders evaluated SX expressions to HTML strings. It is used server-side to produce complete HTML pages and fragments. It handles void elements (self-closing tags like <br>, <img>), boolean attributes, style serialization, class merging, and proper escaping. The output is standard HTML5 that any browser can parse.") (dict :slug "adapter-sx" :filename "adapter-sx.sx" :title "SX Wire Adapter" :desc "Serializes SX for client-side rendering. Component calls stay unexpanded." :prose "The SX wire adapter serializes expressions as SX source text for transmission to the browser, where sx.js renders them client-side. Unlike the HTML adapter, component calls (~plans/content-addressed-components/name ...) are NOT expanded — they are sent to the client as-is, allowing the browser to render them with its local component registry. HTML tags ARE serialized as s-expression source. This is the format used for SX-over-HTTP responses and the page boot payload.") (dict :slug "adapter-async" :filename "adapter-async.sx" :title "Async Adapter" :desc "Async versions of HTML and SX wire adapters for server-side rendering with I/O." :prose "The async adapter provides async-aware versions of the HTML and SX wire rendering functions. It intercepts I/O operations (database queries, service calls, fragment fetches) during evaluation, awaiting them before continuing. Entry points: async-render (HTML output with awaited I/O), async-aser (SX wire format with awaited I/O). The bootstrapper emits async def and automatic await insertion for all define-async functions. This adapter is what makes server-side SX pages work with real data.")))
(define browser-spec-items (list (dict :slug "engine" :filename "engine.sx" :title "SxEngine" :desc "Pure logic for fetch, swap, history, SSE, triggers, morph, and indicators." :prose "The engine specifies the pure logic of the browser-side fetch/swap/history system. Like HTMX but native to SX. It defines trigger parsing (click, submit, intersect, poll, load, revealed), swap algorithms (innerHTML, outerHTML, morph, beforebegin, etc.), the morph/diff algorithm for patching existing DOM, history management (push-url, replace-url, popstate), out-of-band swap identification, Server-Sent Events parsing, retry logic with exponential backoff, request header building, response header processing, and optimistic UI updates. This file contains no browser API calls — all platform interaction is in orchestration.sx.") (dict :slug "orchestration" :filename "orchestration.sx" :title "Orchestration" :desc "Browser wiring that binds engine logic to DOM events, fetch, and lifecycle." :prose "Orchestration is the browser wiring layer. It binds the pure engine logic to actual browser APIs: DOM event listeners, fetch(), AbortController, setTimeout/setInterval, IntersectionObserver, history.pushState, and EventSource (SSE). It implements the full request lifecycle — from trigger through fetch through swap — including CSS tracking, response type detection (SX vs HTML), OOB swap processing, script activation, element boosting, and preload. Dependency is strictly one-way: orchestration depends on engine, never the reverse.") (dict :slug "boot" :filename "boot.sx" :title "Boot" :desc "Browser startup lifecycle: mount, hydrate, script processing." :prose "Boot handles the browser startup sequence and provides the public API for mounting SX content. On page load it: (1) initializes CSS tracking, (2) processes <script type=\"text/sx\"> tags (component definitions and mount directives), (3) hydrates [data-sx] elements, and (4) activates the engine on all elements. It also provides the public mount/hydrate/update/render-component API, and the head element hoisting logic that moves <meta>, <title>, and <link> tags from rendered content into <head>.") (dict :slug "router" :filename "router.sx" :title "Router" :desc "Client-side route matching — Flask-style pattern parsing, segment matching, route table search." :prose "The router module provides pure functions for matching URL paths against Flask-style route patterns (e.g. /docs/<slug>). Used by client-side routing to determine if a page can be rendered locally without a server roundtrip. split-path-segments breaks a path into segments, parse-route-pattern converts patterns into typed segment descriptors, match-route-segments tests a path against a parsed pattern returning extracted params, and find-matching-route searches a route table for the first match.")))
(define reactive-spec-items (list (dict :slug "signals" :filename "signals.sx" :title "Signals" :desc "Fine-grained reactive primitives — signal, computed, effect, batch." :prose "The signals module defines a fine-grained reactive system for client-side islands. Signals are containers for values that notify subscribers on change. Computed signals derive values lazily from other signals. Effects run side-effects when their dependencies change, with automatic cleanup. Batch coalesces multiple signal writes into a single notification pass. Island scope management ensures all signals, computeds, and effects are cleaned up when an island is removed from the DOM. The spec defines the reactive graph topology and update algorithm — each platform implements the actual signal/tracking types natively.") (dict :slug "frames" :filename "frames.sx" :title "CEK Frames" :desc "Continuation frame types for the explicit CEK machine." :prose "Frames define what to do next when a sub-evaluation completes. Each frame type is a dict with a type key and frame-specific data. IfFrame, WhenFrame, BeginFrame handle control flow. LetFrame, DefineFrame, SetFrame handle bindings. ArgFrame tracks function call argument evaluation. MapFrame, FilterFrame, ReduceFrame, ForEachFrame drive higher-order forms element by element through the CEK machine. ReactiveResetFrame and DerefFrame enable deref-as-shift — the core reactive mechanism where deref inside a reactive boundary captures the continuation as a signal subscriber.") (dict :slug "cek" :filename "cek.sx" :title "CEK Machine" :desc "Explicit CEK machine evaluator — step function, run loop, reactive shift." :prose "The CEK machine makes evaluation explicit. Every step is a pure function from state to state: Control (expression), Environment (bindings), Kontinuation (stack of frames). step-eval dispatches on expression type — literals pass through, symbols are looked up, lists dispatch on head (special forms, higher-order forms, macros, function calls). step-continue dispatches on the top frame type. Higher-order forms (map, filter, reduce, for-each, some, every?) step element by element, so deref-as-shift works inside callbacks. cek-call replaces invoke as the universal function dispatch — lambdas go through cek-run, native callables through apply.")))
(define host-spec-items (list (dict :slug "boundary" :filename "boundary.sx" :title "Boundary" :desc "Language boundary contract — declares I/O primitives the host must provide." :prose "The boundary defines the contract between SX and its host environment. Tier 1 declares pure primitives (from primitives.sx). Tier 2 declares async I/O primitives the host must implement: fetch, async-eval, call-action, send-activity, and other operations that require network or database access. Tier 3 declares page helpers: format, highlight, scan-css-classes, parse-datetime. This is the interface every host must satisfy to run SX — framework-agnostic, universal to all targets. Boundary enforcement validates at registration time that all declared primitives are provided.") (dict :slug "forms" :filename "forms.sx" :title "Forms" :desc "Server-side definition forms — defhandler, defquery, defaction, defpage." :prose "Forms defines the server-side definition macros that compose the application layer. defhandler registers an HTTP route handler. defquery defines a read-only data source. defaction defines a mutation (write). defpage declares a client-routable page with path, auth, layout, data dependencies, and content. Each form parses &key parameter lists and creates typed definition objects. Platform-specific constructors are provided by the host — these have different bindings on server (Python/Quart) vs client (route matching only).") (dict :slug "page-helpers" :filename "page-helpers.sx" :title "Page Helpers" :desc "Pure data-transformation helpers for page rendering." :prose "Page helpers are pure functions that assist page rendering: categorizing special forms by type, formatting numbers and dates, highlighting code, scanning CSS classes, constructing page titles and descriptions. Unlike boundary I/O primitives, these are pure — they take data and return data with no side effects. They run identically on server and client. The host registers native implementations that match these declarations.")))
(define extension-spec-items (list (dict :slug "continuations" :filename "continuations.sx" :title "Continuations" :desc "Delimited continuations — shift/reset for suspendable rendering and cooperative scheduling." :prose "Delimited continuations capture the rest of a computation up to a delimiter. shift captures the continuation to the nearest reset as a first-class callable value. Unlike full call/cc, delimited continuations are composable — invoking one returns a value. This covers the practical use cases: suspendable server rendering, cooperative scheduling, linear async flows, wizard-style multi-step UIs, and undo. Each bootstrapper target implements the mechanism differently — generators in Python/JS, native shift/reset in Scheme, ContT in Haskell, CPS transform in Rust — but the semantics are identical. Optional extension: code that doesn't use continuations pays zero cost.") (dict :slug "callcc" :filename "callcc.sx" :title "call/cc" :desc "Full first-class continuations — call-with-current-continuation." :prose "Full call/cc captures the entire remaining computation as a first-class function — not just up to a delimiter, but all the way to the top level. Invoking the continuation abandons the current computation entirely and resumes from where it was captured. Strictly more powerful than delimited continuations, but harder to implement in targets that don't support it natively. Recommended for Scheme and Haskell targets where it's natural. Python, JavaScript, and Rust targets should prefer delimited continuations (continuations.sx) unless full escape semantics are genuinely needed. Optional extension: the continuation type is shared with continuations.sx if both are loaded.") (dict :slug "types" :filename "types.sx" :title "Types" :desc "Gradual type system — registration-time checking with zero runtime cost." :prose "The types module defines a gradual type system for SX. Type annotations on function parameters and return values are checked at registration time (when defcomp or define is evaluated), not at every call site. Base types include number, string, boolean, nil, symbol, keyword, element, any, and never. Union types (string|nil), function types, and type narrowing through control flow are supported. The system catches composition errors and boundary mismatches at definition time without any runtime overhead — unannotated code is unaffected.") (dict :slug "deps" :filename "deps.sx" :title "Deps" :desc "Component dependency analysis and IO detection — per-page bundling, transitive closure, CSS scoping." :prose "The deps module analyzes component dependency graphs and classifies components as pure or IO-dependent. Phase 1 (bundling): walks component AST bodies to find transitive ~component references, computes the minimal set needed per page, and collects per-page CSS classes from only the used components. Phase 2 (IO detection): scans component ASTs for references to IO primitive names (from boundary.sx declarations), computes transitive IO refs through the component graph, and caches the result. Components with no transitive IO refs are pure — they can render anywhere without server data. IO-dependent components must expand server-side.")))
(define all-spec-items (concat core-spec-items (concat adapter-spec-items (concat browser-spec-items (concat reactive-spec-items (concat host-spec-items extension-spec-items))))))
(define find-spec (fn (slug) (some (fn (item) (when (= (get item "slug") slug) item)) all-spec-items)))

6
sx/sx/nav-tools.sx Normal file
View File

@@ -0,0 +1,6 @@
;; Navigation items for the Tools section
(define tools-nav-items
(list
(dict :label "SX Tools" :href "/sx/(tools.(sx-tools))")
(dict :label "Services" :href "/sx/(tools.(services))")))

16
sx/sx/nav-tree.sx Normal file
View File

@@ -0,0 +1,16 @@
;; Navigation tree structure and utility functions
(define find-current (fn (items slug) (when slug (some (fn (item) (when (ends-with? (get item "href") (str "." slug "))")) (get item "label"))) items))))
(defcomp ~nav-data/section-nav (&key items current) (<> (map (fn (item) (~shared:layout/nav-link :href (get item "href") :label (get item "label") :is-selected (when (= (get item "label") current) "true") :select-colours "aria-selected:bg-violet-200 aria-selected:text-violet-900")) items)))
(define sx-nav-tree {:href "/sx/" :children (list {:href "/sx/(geography)" :children (list {:href "/sx/(geography.(reactive))" :children reactive-islands-nav-items :label "Reactive Islands"} {:href "/sx/(geography.(hypermedia))" :children (list {:href "/sx/(geography.(hypermedia.(reference)))" :children reference-nav-items :label "Reference"} {:href "/sx/(geography.(hypermedia.(example)))" :children examples-nav-items :label "Examples"}) :label "Hypermedia Lakes"} {:href "/sx/(geography.(scopes))" :summary "The unified primitive beneath provide, collect!, spreads, and islands. Named scope with downward value, upward accumulation, and a dedup flag." :label "Scopes"} {:href "/sx/(geography.(provide))" :summary "Sugar for scope-with-value. Render-time dynamic scope — the substrate beneath spreads, CSSX, and script collection." :label "Provide / Emit!"} {:href "/sx/(geography.(spreads))" :summary "Child-to-parent communication across render boundaries — spread, collect!, reactive-spread, built on scopes." :label "Spreads"} {:href "/sx/(geography.(marshes))" :children marshes-examples-nav-items :summary "Where reactivity and hypermedia interpenetrate — server writes to signals, reactive transforms reshape server content, client state modifies how hypermedia is interpreted." :label "Marshes"} {:href "/sx/(geography.(isomorphism))" :children isomorphism-nav-items :label "Isomorphism"} {:href "/sx/(geography.(cek))" :children cek-nav-items :label "CEK Machine"}) :label "Geography"} {:href "/sx/(language)" :children (list {:href "/sx/(language.(doc))" :children docs-nav-items :label "Docs"} {:href "/sx/(language.(spec))" :children specs-nav-items :label "Specs"} {:href "/sx/(language.(spec.(explore.evaluator)))" :label "Spec Explorer"} {:href "/sx/(language.(bootstrapper))" :children bootstrappers-nav-items :label "Bootstrappers"} {:href "/sx/(language.(test))" :children testing-nav-items :label "Testing"}) :label "Language"} {:href "/sx/(applications)" :children (list {:href "/sx/(applications.(sx-urls))" :label "SX URLs"} {:href "/sx/(applications.(cssx))" :children cssx-nav-items :label "CSSX"} {:href "/sx/(applications.(protocol))" :children protocols-nav-items :label "Protocols"} {:href "/sx/(applications.(sx-pub))" :label "sx-pub"} {:href "/sx/(applications.(reactive-runtime))" :children reactive-runtime-nav-items :label "Reactive Runtime"}) :label "Applications"} {:href "/sx/(tools)" :children tools-nav-items :label "Tools"} {:href "/sx/(etc)" :children (list {:href "/sx/(etc.(essay))" :children essays-nav-items :label "Essays"} {:href "/sx/(etc.(philosophy))" :children philosophy-nav-items :label "Philosophy"} {:href "/sx/(etc.(plan))" :children plans-nav-items :label "Plans"}) :label "Etc"}) :label "sx"})
(define has-descendant-href? (fn (node path) (let ((children (get node "children"))) (when children (some (fn (child) (or (= (get child "href") path) (has-descendant-href? child path))) children)))))
(define find-nav-match (fn (items path) (or (some (fn (item) (when (= (get item "href") path) item)) items) (some (fn (item) (when (has-descendant-href? item path) item)) items))))
(define resolve-nav-path (fn (tree path) (let ((trail (list))) (define walk (fn (node) (let ((children (get node "children"))) (when children (let ((match (find-nav-match children path))) (when match (append! trail {:siblings children :node match}) (when (not (= (get match "href") path)) (walk match)))))))) (walk tree) (let ((depth (len trail))) (if (= depth 0) {:children (get tree "children") :depth 0 :trail trail} (let ((deepest (nth trail (- depth 1)))) {:children (get (get deepest "node") "children") :depth depth :trail trail}))))))
(define find-nav-index (fn (items node) (let ((target-href (get node "href")) (count (len items))) (define find-loop (fn (i) (if (>= i count) 0 (if (= (get (nth items i) "href") target-href) i (find-loop (+ i 1)))))) (find-loop 0))))

View File

@@ -58,6 +58,10 @@
(define sx-tools (fn (&key title &rest args) (quasiquote (~sx-tools/overview-content :title (unquote (or title "SX Tools")) (splice-unquote args)))))
(define tools (fn (content) (if (nil? content) nil content)))
(define services (fn (&key title &rest args) (quasiquote (~services-tools/overview-content :title (unquote (or title "Services")) (splice-unquote args)))))
(define reactive-runtime (make-page-fn "~reactive-runtime/overview-content" "~reactive-runtime/" nil "-content"))
(define essay (make-page-fn "~essays/index/essays-index-content" "~essays/" "/essay-" ""))

76
sx/sx/services-tools.sx Normal file
View File

@@ -0,0 +1,76 @@
(defcomp ~services-tools/overview-content (&key (title "Services") &rest extra)
(~docs/page :title title
(p :class "text-stone-500 text-sm italic mb-8"
"Python-based MCP server for understanding the rose-ash microservice topology. Static analysis — works without running services.")
(~docs/section :title "Service introspection" :id "introspection"
(p "The rose-ash-services MCP server provides 12 tools for exploring the microservice architecture. Every tool operates via static analysis of the codebase — no running containers needed.")
(table :class "min-w-full text-sm mb-6"
(thead
(tr
(th :class "text-left pr-4 pb-2 font-semibold text-stone-700" "Tool")
(th :class "text-left pb-2 font-semibold text-stone-700" "Purpose")))
(tbody :class "text-stone-600"
(tr
(td :class "pr-4 py-1 font-mono text-xs" "svc_status")
(td :class "py-1" "Docker container status for all rose-ash services."))
(tr
(td :class "pr-4 py-1 font-mono text-xs" "svc_routes")
(td :class "py-1" "List all HTTP routes for a service by scanning blueprints."))
(tr
(td :class "pr-4 py-1 font-mono text-xs" "svc_calls")
(td :class "py-1" "Map inter-service calls: fetch_data, call_action, send_internal_activity, fetch_fragment."))
(tr
(td :class "pr-4 py-1 font-mono text-xs" "svc_config")
(td :class "py-1" "Environment variables and config for a service."))
(tr
(td :class "pr-4 py-1 font-mono text-xs" "svc_models")
(td :class "py-1" "SQLAlchemy models, columns, and relationships for a service."))
(tr
(td :class "pr-4 py-1 font-mono text-xs" "svc_schema")
(td :class "py-1" "Live defquery/defaction manifest from a running service."))
(tr
(td :class "pr-4 py-1 font-mono text-xs" "svc_queries")
(td :class "py-1" "List all defquery definitions from queries.sx files."))
(tr
(td :class "pr-4 py-1 font-mono text-xs" "svc_actions")
(td :class "py-1" "List all defaction definitions from actions.sx files."))
(tr
(td :class "pr-4 py-1 font-mono text-xs" "alembic_status")
(td :class "py-1" "Migration count and latest migration per service."))
(tr
(td :class "pr-4 py-1 font-mono text-xs" "svc_logs")
(td :class "py-1" "Recent Docker logs for a service."))
(tr
(td :class "pr-4 py-1 font-mono text-xs" "svc_start")
(td :class "py-1" "Start services via dev.sh."))
(tr
(td :class "pr-4 py-1 font-mono text-xs" "svc_stop")
(td :class "py-1" "Stop all services.")))))
(~docs/section :title "Service topology" :id "topology"
(p "The rose-ash platform runs as independent Quart microservices, each with its own database. Services communicate via HMAC-signed internal HTTP and ActivityPub events.")
(table :class "min-w-full text-sm mb-6"
(thead
(tr
(th :class "text-left pr-4 pb-2 font-semibold text-stone-700" "Service")
(th :class "text-left pr-4 pb-2 font-semibold text-stone-700" "Domain")
(th :class "text-left pb-2 font-semibold text-stone-700" "Port")))
(tbody :class "text-stone-600"
(tr (td :class "pr-4 py-1 font-mono text-xs" "blog") (td :class "pr-4 py-1" "Content management, Ghost CMS sync") (td :class "py-1" "8001"))
(tr (td :class "pr-4 py-1 font-mono text-xs" "market") (td :class "pr-4 py-1" "Product catalog, marketplace") (td :class "py-1" "8002"))
(tr (td :class "pr-4 py-1 font-mono text-xs" "cart") (td :class "pr-4 py-1" "Shopping cart, checkout") (td :class "py-1" "8003"))
(tr (td :class "pr-4 py-1 font-mono text-xs" "events") (td :class "pr-4 py-1" "Calendar, ticketing") (td :class "py-1" "8004"))
(tr (td :class "pr-4 py-1 font-mono text-xs" "federation") (td :class "pr-4 py-1" "ActivityPub social hub") (td :class "py-1" "8005"))
(tr (td :class "pr-4 py-1 font-mono text-xs" "account") (td :class "pr-4 py-1" "OAuth2, user dashboard") (td :class "py-1" "8006"))
(tr (td :class "pr-4 py-1 font-mono text-xs" "orders") (td :class "pr-4 py-1" "Order history, SumUp payments") (td :class "py-1" "8010"))
(tr (td :class "pr-4 py-1 font-mono text-xs" "relations") (td :class "pr-4 py-1" "Cross-domain relationship tracking (internal)") (td :class "py-1" "8008"))
(tr (td :class "pr-4 py-1 font-mono text-xs" "likes") (td :class "pr-4 py-1" "Unified like/favourite tracking (internal)") (td :class "py-1" "8009")))))
(~docs/section :title "Inter-service communication" :id "communication"
(p "Services communicate through three mechanisms, all HMAC-signed:")
(h4 :class "font-semibold text-stone-700 mt-6 mb-2" "Data queries")
(p "Read-only cross-service data via GET /internal/data/{query}. 3-second timeout. Used for fetching data owned by another service.")
(~docs/code :src ";; Example: blog fetching product data from market\nfetch_data(\"market\", \"products-by-category\", {\"category\": \"prints\"})")
(h4 :class "font-semibold text-stone-700 mt-6 mb-2" "Actions")
(p "Write operations via POST /internal/actions/{action}. 5-second timeout. Used when one service needs to trigger a state change in another.")
(~docs/code :src ";; Example: cart creating an order in the orders service\ncall_action(\"orders\", \"create-order\", {\"items\": [...], \"customer\": ...})")
(h4 :class "font-semibold text-stone-700 mt-6 mb-2" "ActivityPub inbox")
(p "AP-shaped activities via POST /internal/inbox. Used for cross-service writes that follow the ActivityPub pattern — Create, Update, Delete activities with typed objects."))))

File diff suppressed because one or more lines are too long