Skip to content

feat(ui): serve local documentation from data bundles - #1

Open
deem0n wants to merge 4 commits into
mainfrom
feat/docs-data-bundle
Open

deem0n wants to merge 4 commits into
mainfrom
feat/docs-data-bundle

Conversation

@deem0n

@deem0n deem0n commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Adds an optional documentation data bundle served from memory. The existing Documentation globe icon opens local documentation inside the gateway UI, keeping the gateway navigation visible. If no bundle is loaded, the icon continues to open the public documentation website.

Implementation

  • Configuration and startup: adds the YAML setting config.documentationBundle and documents it in the generated schema. The management service loads the file once at startup into a shared Bytes buffer and indexes its assets. Relative paths resolve against the process working directory. An unset or missing file leaves local documentation disabled and uses the public link; an existing unreadable or invalid bundle fails startup.
  • Portable data format: AGWDOCS1, a little-endian manifest length, a JSON manifest, and concatenated asset payloads. The manifest records the documentation version, landing page, MIME types, encodings, offsets, lengths, original lengths, and SHA-256 checksums. This is a data archive, with no native-library ABI or loader hooks.
  • Builder: tools/build-docs-bundle.py uses only the Python 3.9+ standard library. It sorts assets, gzips each file when that reduces its size, records checksums, rejects symlinks and unsupported paths, and publishes a complete pack by atomic rename. The builder packages an already generated website; it does not invoke Hugo or rewrite URLs. No new Rust dependencies are introduced.
  • Validation and HTTP serving: the reader validates the format, paths, MIME headers, contiguous non-overlapping payload ranges, checksums, gzip streams, and declared uncompressed lengths. /ui/docs/ supports GET/HEAD, directory redirects, content negotiation, representation-specific ETags and conditional requests, Vary: Accept-Encoding, and Cache-Control: private, no-cache. Gzip responses use shared byte slices; identity responses decompress as a stream. Missing assets return 404 rather than the UI SPA fallback. Range requests receive the complete representation.
  • UI integration: /api/runtime exposes ui.documentationPath only when a bundle was loaded. The existing footer globe icon opens /ui/documentation, which displays the local site in a frame within the normal application shell. Sidebar navigation and the header remain available while browsing documentation. The public link remains the fallback while runtime information is pending or unavailable. The routes use the existing UI base-path and authentication handling; the admin listener retains its existing access rules.
  • Documentation and checks: adds architecture/documentation-bundles.md, links it from DEVELOPMENT.md, includes a small generated fixture, and adds Python builder tests to Linux CI alongside Rust reader/HTTP tests and browser coverage.

Build and configuration

Generate the static website for /ui/docs/, including navigation, search indexes, styles, and scripts. With a YAML setting such as ui.basePath: /gateway, the site's prefix must instead be /gateway/ui/docs/. Theme-specific URL assumptions must also be handled by the website build.

python3 tools/build-docs-bundle.py /path/to/built-site /tmp/docs.pack \
  --version 1.7.0 --entrypoint docs/standalone/latest/
config:
  documentationBundle: /opt/agentgateway/docs.pack

Replace the pack atomically and restart the gateway to update the documentation. Existing processes retain their in-memory copy; replicas can receive the new file before a rolling restart. There is no file watcher or configuration-reload trigger for reloading the pack.

The pack contains trusted HTML and JavaScript served on the UI origin. Checksums detect corruption, not publisher identity. Production website content is distributed separately from the gateway source; the committed pack is a 1,005-byte test fixture.

Validation

Local checks on the UI/runtime implementation at 3866ec2f:

  • Python builder tests: 2 passed.
  • Rust formatting check: passed.
  • UI type checking, Biome, and unit tests: passed; 26 unit tests.
  • Full Playwright run: 67 passed, 1 timed out (refreshes a reopened policy diff, at its 30-second test deadline). That existing policy-editor test then passed in 6.1 seconds when rerun alone with one worker, without code changes. All documentation tests passed in the full run, including local/public link selection, embedded navigation, refresh, and returning to gateway pages.

Earlier implementation checks:

  • The bundle implementation at 2d59ea65 passed the full Rust suite: 3,690 passed, 6 ignored, plus Clippy with warnings denied. The subsequent feature commit changes the UI, documentation/schema wording, and the missing-file warning text; it does not change the reader or HTTP behavior.
  • The first Dranik integration passed 2,586 Rust library tests. The final branded integration was rebuilt and checked live with the existing model configuration.
  • The deployed Russian pack was checked for internal links and source-code-fence preservation. Live browser checks covered article links, search, both sidebars at six desktop widths, mobile drawer/resize behavior, and the standalone layout.

These are local results; GitHub CI status is reported separately by the PR checks.

CI follow-up

  • b9b0b692 pins the documentation fixture source to LF and marks .pack files as binary. Windows checks out ordinary text as CRLF, which made two Rust tests compare the unchanged LF bundle payload against CRLF source files. The correction keeps the byte-exact assertions and serving behavior unchanged. All five Rust documentation tests passed locally on the corrected source. A disposable checkout with core.autocrlf=true reproduced the mismatch before the attributes change and passed both Python fixture tests afterward.
  • 01748939 lets forks run Linux jobs on GitHub-hosted Ubuntu runners. The Luxms fork has no Blacksmith runners, so those jobs previously stayed queued. Linux dependency setup now checks the runner OS; forks use the standard Go cache instead of Blacksmith's disk cache. Upstream's Blacksmith runner and cache selection is preserved. Workflow validation with tools/actionlint passed.
  • The GitHub UI job on 01748939 passed lint, unit tests, and all 68 Playwright tests; the Linux Python builder step also passed. The new full CI run is available here; its status is pending and must be checked separately.

Dranik integration and companion website change

The feature is already merged into the Luxms dranik branch at eddec2a9, including the fixture and CI fixes. The source branch feat/docs-data-bundle is retained. This PR targets Luxms's main for review of the reusable feature; the upstream repository is not modified.

The documentation theme's embedded-sidebar breakpoint adjustment is maintained in the separate website fork: luxms/ag-website e77ba1116. It keeps the documentation's own navigation visible alongside the gateway sidebar in narrower desktop frames, while preserving standalone layout behavior. That website change is delivered through the data bundle.

Signed-off-by: Dmitry Dorofeev <dima@yasp.com>
Signed-off-by: Dmitry Dorofeev <dima@yasp.com>
Signed-off-by: Dmitry Dorofeev <dima@yasp.com>
Signed-off-by: Dmitry Dorofeev <dima@yasp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant