Commit Graph

614 Commits

Author SHA1 Message Date
ec52e2116e Fix affinity demo: pass page-plans to content component
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 00:13:48 +00:00
657b631700 Phase 7f: universal page descriptor + render plan visibility
defpage is already portable: server executes via execute_page(),
client via try-client-route. Add render plan logging to client
routing so console shows boundary decisions on navigation:
"sx:route plan pagename — N server, M client"

Mark Phase 7 (Full Isomorphism) as complete:
- 7a: affinity annotations + render-target
- 7b: page render plans (boundary optimizer)
- 7e: cross-host isomorphic testing (61 tests)
- 7f: universal page descriptor + visibility

7c (optimistic updates) and 7d (offline data) remain as future work.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 00:10:45 +00:00
32ca059ed7 Phase 7e: isomorphic testing — cross-host Python/JS comparison
61 tests evaluate the same SX expressions on both Python (sx_ref.py)
and JS (sx-browser.js via Node.js), comparing output:
- 37 eval tests (arithmetic, strings, collections, logic, HO forms)
- 24 render tests (elements, attrs, void elements, components, escaping)

All pass — both hosts produce identical results from the same spec.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 00:08:25 +00:00
2da80c69ed Phase 7b: page render plans — per-page boundary optimizer
Add page-render-plan to deps.sx: given page source + env + IO names,
computes a dict mapping each needed component to "server" or "client",
with server/client lists and IO dep collection. 5 new spec tests.

Integration:
- PageDef.render_plan field caches the plan at registration
- compute_page_render_plans() called from auto_mount_pages()
- Client page registry includes :render-plan per page
- Affinity demo page shows per-page render plans

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 00:02:53 +00:00
a70ff2b153 Phase 7a: affinity annotations + fix parser escape sequences
Add :affinity :client/:server/:auto annotations to defcomp, with
render-target function combining affinity + IO analysis. Includes
spec (eval.sx, deps.sx), tests, Python evaluator, and demo page.

Fix critical bug: Python SX parser _ESCAPE_MAP was missing \r and \0,
causing bootstrapped JS parser to treat 'r' as whitespace — breaking
all client-side SX parsing. Also add \0 to JS string emitter and
fix serializer round-tripping for \r and \0.

Reserved word escaping: bootstrappers now auto-append _ to identifiers
colliding with JS/Python reserved words (e.g. default → default_,
final → final_), so the spec never needs to avoid host language keywords.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:53:33 +00:00
81d8e55fb0 Fix sx-browser.js cache bust: use correct path for hash computation
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 5m4s
_script_hash used relative Path("static") which resolved to /app/static/
inside the container, but the file is at /app/shared/static/. Use
Path(__file__).parent.parent to resolve from shared/ correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 22:38:49 +00:00
179631130c Fix parser escape ordering and prim_get for non-dict objects
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 3m37s
Parser: chained .replace() calls processed \n before \\, causing \\n
to become a real newline. Replaced with character-by-character
_unescape_string. Fixes 2 parser spec test failures.

Primitives: prim_get only handled dict and list. Objects with .get()
methods (like PageDef) returned None. Added hasattr fallback.
Fixes 9 defpage spec test failures.

All 259 spec tests now pass (was 244/259).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 22:17:38 +00:00
5a4a0c0e1c Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 22:15:26 +00:00
621c0bbf42 CSSX plan: add CSS technology comparisons, fix strategy-agnostic claim
Add comparisons with styled-components, CSS Modules, Tailwind, Vanilla
Extract, and Design Tokens. Add example of components emitting <style>
blocks directly. Fix "CSS-agnostic" to "strategy-agnostic" — components
can generate CSS, not just reference existing classes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 22:15:24 +00:00
5a68046bd8 Restore stashed WIP: live streaming plan, forms, CI pipeline, streaming demo
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 22:07:59 +00:00
df1aa4e1d1 Merge branch 'worktree-iso-phase-4' into macros
# Conflicts:
#	sx/sx/nav-data.sx
#	sx/sx/plans.sx
#	sx/sxc/pages/docs.sx
2026-03-07 22:07:09 +00:00
41c3b9f3b8 Add CSSX Components plan: styling via defcomp instead of opaque style dict
Replace the existing CSSX plan with a component-based approach where styling
is handled by regular defcomp components that apply classes, respond to data,
and compose naturally — eliminating opaque hash-based class names.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 22:05:39 +00:00
f5e47678d5 Fix streaming page: SX NIL namespace broke CSS matching on DOM elements
domCreateElement treated SX NIL (a truthy JS object) as a real namespace,
calling createElementNS("nil", tag) instead of createElement(tag). All
elements created by resolveSuspense ended up in the "nil" XML namespace
where CSS class selectors don't match.

Also fix ~suspense fallback: empty &rest list is truthy in SX, so
fallback content never rendered.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 20:24:29 +00:00
6596fac758 Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 19:37:18 +00:00
299de98ea8 Fix resolveSuspense: iterate parsed exprs instead of passing array
parse() returns a list of expressions. resolveSuspense was passing the
entire array to renderToDom, which interpreted [(<> ...)] as a call
expression ((<> ...)) — causing "Not callable: {}". Now iterates
each expression individually, matching the public render() API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 19:37:15 +00:00
e7a511d40a Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 19:34:40 +00:00
aeac3c0b13 Debug: log head and args on evalCall "Not callable" error
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 19:34:36 +00:00
25edc7d64a Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 19:23:32 +00:00
5cca22ae6d Revert make-raw-html wrapping from eval.sx spec
The make-raw-html wrapper in eval-list was host-specific: it fixed
server-side HTML escaping but broke the client DOM adapter (render-expr
returns DOM nodes, not strings). The raw-html wrapping belongs in the
host (async_eval_ref.py line 94-101), not the spec.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 19:23:27 +00:00
260475a4da Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 19:20:57 +00:00
2c9d7c95a2 resolve-suspense: process new SX scripts before resolving
Streaming resolve scripts arrive after boot, so any extra component
defs sent as <script type="text/sx"> tags weren't being loaded.
Fix in the spec (boot.sx): call (process-sx-scripts nil) at the
start of resolve-suspense so late-arriving component defs are
available in componentEnv before rendering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 19:20:54 +00:00
fd03eeb0fe Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 19:08:35 +00:00
47448a6d37 Stream extra component defs with resolve scripts
Resolved SX content may reference components not in the initial shell
scan (e.g. ~cart-mini from IO-generated headers). Diff the needed
components against what the shell already sent and prepend any extra
defcomps as a <script type="text/sx"> block before the resolve script.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 19:08:32 +00:00
cdd775c999 Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 19:02:31 +00:00
7294f07f5b Include layout + content component deps in streaming page scan
The streaming page's component scan only covered the suspense
placeholders, missing transitive deps from layout headers (e.g.
~cart-mini, ~auth-menu). Add layout.component_names to Layout class
and include them plus page content_expr in the scan source.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 19:02:29 +00:00
dd774efc18 Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 18:58:48 +00:00
668a46bec0 Fix render-expr in eval position: wrap result in raw-html
The spec's eval-list calls render-expr for HTML tags/components in eval
position but returned a plain string. When that string was later passed
through _arender (e.g. as a component keyword arg), it got HTML-escaped.

Fix in eval.sx: wrap render-expr result in make-raw-html so the value
carries the raw-html type through any evaluator boundary. Also add
is_render_expr check in async_eval_ref.py as belt-and-suspenders for
the same issue in the async wrapper.

This fixes the streaming demo where suspense placeholder divs were
displayed as escaped text instead of real DOM elements.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:58:42 +00:00
9d70599416 Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 18:34:24 +00:00
309579aec7 Fix streaming: render initial shell as HTML, not SX wire format
The streaming shell now uses render_to_html so [data-suspense] elements
are real DOM elements immediately when the browser parses the HTML.
Previously the shell used SX wire format in a <script data-mount> tag,
requiring sx-browser.js to boot and render before suspense elements
existed — creating a race condition where resolution scripts fired
before the elements were in the DOM.

Now: server renders HTML with suspense placeholders → browser has real
DOM elements → resolution scripts find and replace them reliably.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:34:24 +00:00
ca0ea69ca1 Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 18:24:38 +00:00
44095c0a04 Fix streaming: split setup (needs context) from generator (just yields)
Async generator bodies don't execute until __anext__(), by which time
the request context is gone. Restructure execute_page_streaming as a
regular async function that does all context-dependent work (g, request,
current_app access, layout resolution, task creation) while the context
is live, then returns an inner async generator that only yields strings
and awaits pre-created tasks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:24:38 +00:00
5991a5b397 Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 18:20:59 +00:00
b9b315c86f Fix stream_with_context usage: it's a decorator, not a wrapper
stream_with_context decorates a generator function, not a generator
instance. Wrap execute_page_streaming in a decorated inner function.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:20:59 +00:00
ccf9a155ad Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 18:18:32 +00:00
fa70c5f297 Fix streaming demo: preserve app context across async generator yields
Quart's ASGI layer doesn't propagate request/app context into async
generator iterations. Wrap execute_page_streaming with stream_with_context
so current_app and request remain accessible after each yield.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:18:28 +00:00
3574f7e163 Restructure boundary specs: move app-specific I/O out of language contract
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m42s
boundary.sx now contains only generic web-platform I/O primitives that
any SX host would provide (current-user, request-arg, url-for, etc.).

Moved to boundary-app.sx (deployment-specific):
- Inter-service: frag, query, action, service
- Framework: htmx-request?, g, jinja-global
- Domain: nav-tree, get-children, relations-from

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:04:53 +00:00
6312eb66a2 Merge branch 'worktree-iso-phase-4' into macros
# Conflicts:
#	shared/static/scripts/sx-browser.js
2026-03-07 18:01:56 +00:00
917a487195 Add deps and engine test specs, bootstrap engine to Python
New test specs (test-deps.sx: 33 tests, test-engine.sx: 37 tests) covering
component dependency analysis and engine pure functions. All 6 spec modules
now have formal SX tests: eval (81), parser (39), router (18), render (23),
deps (33), engine (37) = 231 total.

- Add engine as spec module in bootstrap_py.py (alongside deps)
- Add primitive aliases (trim, replace, parse_int, upper) for engine functions
- Fix parse-int to match JS parseInt semantics (strip trailing non-digits)
- Regenerate sx_ref.py with --spec-modules deps,engine
- Update all three test runners (run.js, run.py, sx-test-runner.js)
- Add Dependencies and Engine nav items and testing page entries
- Wire deps-source/engine-source through testing overview UI

Node.js: 231/231 pass. Python: 226/231 (5 pre-existing parser/router gaps).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:01:33 +00:00
605aafa2eb Fix client routing: fall through to server on layout/section change
Client-side routing was only swapping #main-panel content without
updating OOB headers (nav rows, sub-rows). Now each page entry in the
registry includes a layout identity (e.g. "sx-section:Testing") and
try-client-route falls through to server when layout changes, so OOB
header updates are applied correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 17:46:01 +00:00
7f466f0fd6 Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 17:36:04 +00:00
6421a23223 Update isomorphic plan: Phase 6 status badge, demo section, file list
- Add Complete badge with live demo link to Phase 6 section
- Replace Verification with Demonstration + What to verify sections
- Update Files list: boot.sx spec, bootstrap_js.py, demo files
- Add streaming/suspense and client IO to Current State summary

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 17:35:57 +00:00
342da2bd44 Merge branch 'worktree-iso-phase-4' into macros 2026-03-07 17:34:14 +00:00
a05d642461 Phase 6: Streaming & Suspense — chunked HTML with suspense resolution
Server streams HTML shell with ~suspense placeholders immediately,
then sends resolution <script> chunks as async IO completes. Browser
renders loading skeletons instantly, replacing them with real content
as data arrives via __sxResolve().

- defpage :stream true opts pages into streaming response
- ~suspense component renders fallback with data-suspense attr
- resolve-suspense in boot.sx (spec) + bootstrapped to sx-browser.js
- __sxPending queue handles resolution before sx-browser.js loads
- execute_page_streaming() async generator with concurrent IO tasks
- Streaming demo page at /isomorphism/streaming with 1.5s simulated delay

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 17:34:10 +00:00
1fe258e3f7 Fix plans.sx parse error: restore correct paren count for isomorphic section
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 3m15s
The SX parser counts \n inside string literals as line breaks, so the
parser's line numbers differ from file line numbers. The naive paren
counter was wrong — the original 8 closing parens was correct.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 17:18:08 +00:00
bec0397c3c Merge branch 'worktree-iso-phase-4' into macros
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 4m47s
2026-03-07 17:03:11 +00:00
85083a0fff Formalise Phase 5 (Client IO Proxy) as complete
Phase 5 was solved by IO proxy registration + async DOM renderer +
JavaScript Promises — no continuations needed on the client side.
Continuations remain a prerequisite for Phase 6 (server-side streaming).

Updated plan status: Phases 1-5 complete. Phase 4 moved from Partial.
Renumbered: streaming/suspense is now Phase 6, full iso is Phase 7.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 17:03:07 +00:00
fab9bffc49 Plan: SX CI Pipeline — build/test/deploy in s-expressions
Pipeline definitions as .sx files evaluated by a minimal Python runner.
CI primitives (shell-run, docker-build, git-diff-files) are boundary-declared
IO, only available to the runner. Steps are defcomp components composable
by nesting. Fixes pre-existing unclosed parens in isomorphic roadmap section.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 13:37:24 +00:00
d618530f29 Merge branch 'worktree-iso-phase-4' into macros
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 4m15s
2026-03-07 13:14:20 +00:00
624d1872e3 Fix testing pages: move read-spec-file into :data for client routing
read-spec-file is a server-only page helper. When the client router
tried to evaluate :content, it couldn't find the function. Move all
file reads into the :data expression (evaluated server-side) so
:content only references data bindings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 13:14:15 +00:00
3b3c904953 Merge branch 'worktree-iso-phase-4' into macros
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 3m49s
2026-03-07 12:37:34 +00:00