SX spec introspection: the spec examines itself via sx-parse

spec-introspect.sx: pure SX functions that read, parse, and analyze
spec files. No Python. The spec IS data — a macro transforms it into
explorer UI components.

- spec-explore: reads spec file via IO, parses with sx-parse, extracts
  sections/defines/effects/params, produces explorer data dict
- spec-form-name/kind/effects/params/source: individual extractors
- spec-group-sections: groups defines into sections
- spec-compute-stats: aggregate effect/define counts

OCaml kernel fixes:
- nth handles strings (character indexing for parser)
- ident-start?, ident-char?, char-numeric?, parse-number: platform
  primitives needed by spec/parser.sx when loaded at runtime
- _find_spec_file: searches spec/, web/, shared/sx/ref/ for spec files

83/84 Playwright tests pass. The 1 failure is client-side re-rendering
of the spec explorer (the client evaluates defpage content which calls
find-spec — unavailable on the client).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-18 17:57:19 +00:00
parent fac97883f9
commit 8373c6cf16
4 changed files with 225 additions and 2 deletions

View File

@@ -230,13 +230,14 @@
`(~specs/not-found :slug ,slug)))))))
;; Spec explorer (under language → spec)
;; Uses spec-explore from spec-introspect.sx — the spec examines itself.
(define explore
(fn (slug)
(if (nil? slug)
'(~specs/architecture-content)
(let ((found-spec (find-spec slug)))
(if found-spec
(let ((data (helper "spec-explorer-data"
(let ((data (spec-explore
(get found-spec "filename")
(get found-spec "title")
(get found-spec "desc"))))