Module: Ruact::ServerFunctions::Introspection
- Defined in:
- lib/ruact/server_functions/introspection.rb
Overview
Story 15.3 (FR107) — the machine-readable ruact:routes --json document:
a read-only, side-effect-free view of the accessor/route table for headless
agents and CI gates. Reuses the SAME collectors codegen consumes (via
introspect), so the introspection can never fork a
parallel derivation and never writes the codegen bridge / TS module.
Shape
{ "schema_version" => Integer,
"accessors" => [
{ "accessor" => String, # the JS identifier (js_identifier)
"kind" => String, # "action" | "query"
"verb" => String, # HTTP method
"path" => String, # cleaned route path
"segments" => Array<String>,
"params" => [{ "name" => String, "required" => Boolean }] } ] }
Queries carry their declared kwargs as params (Story 13.4); actions carry
their required path segments, uniformly shaped as { name, required: true }.
Per Story 15.3 decision D3 there is NO per-accessor component-contract link
(accessors are server functions, not components) — the table reports
accessors faithfully and omits the "target component contract" clause.
Constant Summary collapse
- SCHEMA_VERSION =
Version of the
ruact:routes --jsondocument. EXPERIMENTAL / UNSTABLE:0signals the shape may change without a major version bump while the agent-facing surface is iterated — gate any parser on it. Distinct from Doctor::SCHEMA_VERSION (a separate, independently-versioned document) and from Snapshot::VERSION_V2 (the internal codegen bridge). 0
Class Method Summary collapse
-
.as_json(route_set:, host_predicate: nil, overrides_for: nil, query_class_for: nil) ⇒ Hash
Builds the
ruact:routes --jsondocument fromroute_set.
Class Method Details
.as_json(route_set:, host_predicate: nil, overrides_for: nil, query_class_for: nil) ⇒ Hash
Builds the ruact:routes --json document from route_set. The resolver
callables default to real constant resolution; specs inject lambdas.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ruact/server_functions/introspection.rb', line 45 def as_json(route_set:, host_predicate: nil, overrides_for: nil, query_class_for: nil) entries = ServerFunctions.introspect( route_set: route_set, host_predicate: host_predicate, overrides_for: overrides_for, query_class_for: query_class_for ) { "schema_version" => SCHEMA_VERSION, "accessors" => entries.map { |entry| shape(entry) } } end |