Generate and publish the Lua API reference from declared exports
Plan a mostly automatic Markdown API reference bundled with each client publish. Related work: native Lua/XML UI first slice in feature/client-lua-actions and draft PR2797. User wants the full exposed game API, with optional C# tagging for clarification; document implemented Lua-facing functions/types/callbacks and restrictions, not arbitrary public .NET types or imagined future APIs. Inspection: current public wrappers are hand-written in UI/Packages/Core/ui.lua, native dispatch is a string switch in LuaWidgetHost/ScriptedActionsWindow, and action snapshots are manually projected by ActionPresentationSource. There is no unified export registry or metadata. A docs-only reflection scan of C# classes would describe the wrong surface and miss wrapper semantics (e.g. ui.find converts missing native handle0 into a Lua error). Prefer one explicit build-time export/type contract that can drive Lua bindings and documentation, with checks against native dispatch, rather than a second hand-maintained API inventory. Design intent: C# attributes/typed contract declarations for exported Lua name, actual signature and semantic types, summary, parameters/results, execution/ownership restrictions and optional examples. Use attributes rather than new XML/source comments per client rules. Infer ordinary signatures automatically where actual typed exports exist; require explicit schema for projected data and opaque handles. Generate deterministically at build time, not runtime reflection/CLR exposure, preserving NativeAOT and the protected boundary. Publish Markdown under docs/lua-api/ with an index, UI functions, implemented game namespaces, shared types and callback/component contracts. Include only the API available in that build. Keep internal transport/private component entrypoints distinct from public package API. Acceptance: build/publish emits complete current Lua API Markdown and bundles it in artifacts; registration/binding and docs share declarations or enforce mismatches as build failures; descriptions for limits/failure/activation/ownership are explicit; no runtime reflection or new steady-state allocations; deterministic output; coverage includes current ui API, game.actions.execute and actual action payload/callbacks; validate generation, missing/duplicate/type mismatches, publishing and AOT. No standalone prose report, hand-maintained full-game reference, future API stubs or broad unrelated client rewrite. Implementation in progress in existing feature/client-lua-actions worktree, based on fd1e15323; all current API-generator changes uncommitted/unpushed. DraftPR2797 unchanged. No new commit permission. Implemented: PRK.ClientScripting/Api/LuaApiAttributes.cs declares export/parameter/opaque/record/field/callback/component metadata. UI/Scripting/LuaApiContracts.cs defines current opaque handles, actual readonly Action projection and component signatures. LuaWidgetHost.Api.cs now contains annotated typed implementations; LuaWidgetHost.Invoke delegates to generated dispatcher, replacing the native string-switch inventory. ScriptedActionsWindow is partial, its annotated typed ExecuteAction uses a generated activation-policy guard via AuthorizeLuaActivation; it no longer manually duplicates the guard. ActionPresentationSource consumes generated LuaApiProjection.Write for LuaActionDescription structs, no per-row object allocation. C# native entry calls use generated LuaApiEntries names. PRK.LuaApiGenerator is a net10 build-only console using SDK Roslyn syntax parsing (no NuGet/runtime reflection). It emits allocation-free partial C# dispatch, Lua wrappers, projection writers, entry constants and5 Markdown files. Explicit literal metadata; primitive types inferred, opaque/callback types declared. Checks duplicate exports/operations/types, unsupported types/modifiers, missing fields, opaque base compatibility/cycles, exported namespace conflicts and builtin Lua entry existence/arity; current build preprocessor defines select exports. Parser deliberately supports the declared C# contract shapes rather than arbitrary type aliases/reflection. Shared LuaApi/LuaApi.targets imported by client and PRK.Client.UI.AotTests; generator ProjectReference is build-only, ReferenceOutputAssembly=false/Private=false, RID/AOT properties removed. Tool's ShouldBeValidatedAsExecutableReference=false classifies it correctly as a build tool for self-contained parents, not a runtime dependency. GenerateLuaApi executes before compile; generated outputs under target-specific obj/.../lua-api. Core/ui.lua handwritten source deleted, generated binding copied to UI/Packages/Core/ui.lua. docs/lua-api/ contains README.md,ui.md,game-actions.md,types.md,callbacks.md. Private component callbacks distinguished from public APIs. --no-build publish uses existing generated code/content artifacts and fails if missing, never re-generates from newer declarations. Verified milestones: generator --self-test passes deterministic output/stale cleanup/binding+doc projection checks and negative duplicate/type/field/entry cases, including conditional exports. Initial UI run failed because generated None content was added after AssignTargetPaths; fixed using explicit ContentWithTargetPath and correctly qualified per-doc metadata. Current Actions tests37 pass/1skip narrower; full targeted96 pass/1skip with warnings-as-errors. New native/Actions AOT tests pass (including activation/snapshot refusal, unchanged-update zero allocation, identities, list/grid, sorting, teardown) and7/7 native+7/7 ASan/UBSan remain pass. Initial AOT publish caught SDK treating framework-dependent tool as app reference; fixed build-tool classification. Fresh published component artifact verified to contain docs+bindings and NOT tool apphost/deps/runtimeconfig/Roslyn. Private=false fixed initial content leakage. Actual full Linux client NativeAOT publish succeeded with existing production Silk warning policy unchanged and freshly available native package paths; artifact .dev-data/lua-api/client-publish. Automated artifact inspection confirmed exact16-export equality between generated Lua functions and public doc headings,7 actual Action fields, enforced activation docs, valid local Markdown links and no generator/Roslyn files anywhere in artifact. Generated Lua passes luac5.4. Normal and --no-build fresh component publishes both verified and executed; no-build path .dev-data/lua-api/no-build-verified-final. Final verified outcome: actual contract generation repeated twice gives11 byte-identical artifacts incl manifest; current output16 public exports,4 opaque types,1 Action record,1 public callback and4 separately labelled builtin entry contracts. Public bindings/docs names match exactly; all projected fields and activation policy documented. Full client Release Linux NativeAOT publish with existing production Silk policy succeeded to .dev-data/lua-api/client-publish; published docs/lua-api contains README.md,ui.md,game-actions.md,types.md,callbacks.md plus generated Core/ui.lua at its runtime path. Artifact-wide checks found no generator/Roslyn payload; local Markdown links/anchors and generated Lua syntax validated. Both normal and --no-build component publish paths ran successfully; --no-build now skips source regeneration, includes built generated source/content for SDK AOT command computation and reuses matching configuration artifacts. Final ./run-client-lua-tests.sh passed after new CI/self-test wiring: generator contract checks (including conditional exports),7/7 native Release,7/7 ASan+UBSan, bridge AOT tests and actual Actions AOT tests. UI AOT executable now also requires all5 API pages and enforced activation documentation in published output. Full targeted client run96 passed/1 install-dependent skip with compiler warnings as errors. Core UI behavior, one-action/user-activation enforcement, state feedback-loop containment, snapshot projection, metadata identities, list/grid/sort and zero managed allocations for1000 unchanged updates remain green. No runtime reflection or native safety change. XML/MSBuild/workflow/shell syntax and whitespace checks passed. Author guide is PRK.Client/LuaApi/README.md; UI package README points at C# declarations and generated reference. Metadata intentionally literal and contract-shape constrained; unsupported types/shapes fail rather than invent docs. Build-only ProjectReference.Private=false avoids tool apphost/deps/runtimeconfig leakage observed in first fresh publish. Existing source Core/ui.lua is staged deleted; replacement is generated at build. Generated files remain in obj/output only. Source-linked UI AOT target imports same generation targets; publisher/release scripts need no extra manual docs copy. Current state: implementation and Linux acceptance complete. User explicitly requested push; committed as8d1fc5854 (feature: Generate Lua bindings and API documentation from contracts) and pushed to origin/feature/client-lua-actions, updating draftPR2797. Worktree clean. Validation was already completed before this commit-only push; no claim that remote CI has passed. Do not silently mark draftPR2797 ready or merge. Native Windows/macOS build/publish remains unexecuted; real project uses SDK Roslyn assemblies so matching .NET10 SDK required. Validation evidence copied to .dev-data/lua-api/validation (including final AOT/contracts, full client publish, targeted regressions, no-build and determinism logs). No further implementation blocker identified. Review API generator integration when reviewing the overall WIP feature.
Checklist
3 of 3 complete- Define the Lua-facing export/type contract and reuse it for binding metadata rather than maintaining an independent documentation inventory.
- Bundle generated API files in client publish artifacts and verify drift diagnostics, output completeness and Native AOT compatibility.
- Generate deterministic Markdown with current functions, projected types, callbacks, ownership/activation rules and optional authored examples.
- Area
- Project Rubi-Ka
- Project
- engines
- Kind
- Feature
- Task ID
tsk_gspv652hn5- Updated