Skip to content

Simple guide · Core platform

Page status: HistoricalHistory group: Updates

Backend Wiki Qwen Runtime

How the backend-hosted Qwen runtime generates bounded NutsNews merge documentation without OpenAI API usage.

Visual overview

Primary diagram

System map

A serialized GitHub Actions job sends an authenticated Responses API request through Caddy and a bounded proxy to loopback Ollama, then validates the generated documentation before publication.

Render the repository-owned system map when you need it.

Diagram is not rendered yet.

View as text
Backend-hosted Qwen wiki generation flow

A serialized GitHub Actions job sends an authenticated Responses API request through Caddy and a bounded proxy to loopback Ollama, then validates the generated documentation before publication.

flowchart LR
  accTitle: Backend-hosted Qwen wiki generation flow
  accDescr {
    A serialized GitHub Actions job sends an authenticated Responses API request through Caddy
    and a bounded proxy to loopback Ollama, then validates the generated documentation before
    publication.
  }
  merge["Up to three merged PRs"] --> bundle["Isolated five-file bundle"]
  bundle --> action["GitHub-hosted Codex Action"]
  action --> caddy["backend.nutsnews.com /wiki-ai/v1/responses"]
  caddy --> auth{"Bearer key and request valid?"}
  auth -->|"No"| reject["Reject without publishing"]
  auth -->|"Yes"| proxy["One active inference plus one bounded waiter"]
  proxy -. "15-second SSE keep-alive" .-> action
  proxy --> ollama["Loopback Ollama"]
  ollama --> qwen["nutsnews-wiki-qwen"]
  qwen --> files["Generated wiki artifacts"]
  files --> gates{"All deterministic gates pass?"}
  gates -->|"No"| retry["Keep current wiki and bounded retry state"]
  gates -->|"Yes"| publish["Advance cursor and publish validated wiki"]

Backend-hosted Qwen wiki generation flow

Fullscreen diagram view.

Automatic NutsNews wiki updates use a Qwen model running on the NutsNews backend server. The scheduled GitHub job no longer needs a paid OpenAI API project. The public wiki itself never calls Qwen when someone reads a page.

If Qwen is unavailable, the update job fails safely. The last validated wiki stays online and no incomplete documentation is published.

GitHub sends one authenticated documentation request to backend.nutsnews.com. Caddy exposes only a health route and the required Responses API route. A small proxy checks the dedicated key, request size, and approved model before sending the request to Ollama over the server’s private loopback connection.

Ollama and its management port are not public. The model handles only one wiki request at a time so it cannot consume all backend resources. One authenticated request may wait for that slot for up to 10 minutes; any additional overlap is rejected.

The protected backend pipeline installs Ollama 0.32.5 and the pinned qwen3.5:4b-q4_K_M model. GitHub refers to the model as nutsnews-wiki-qwen. It has a 49,152-token context, a 6,144-token response limit, and systemd CPU and memory ceilings.

This smaller model fits the four-core, 9.7 GiB server. The larger Qwen3-Coder model would not leave safe capacity for the database, queues, proxy, and Worker services.

These limits still give Qwen enough room for the five-file wiki bundle while preventing the known slowest case: an 8,192-token production response exceeded the server’s 55-minute request limit. The normal validation checks remain the publication authority.

All software installation and model changes go through the existing protected backend Ansible workflow. Operators run check mode first, review the diff, then run apply with the exact backend confirmation. Apply must pass public health, authentication, a real Qwen tool call, and the normal backend safety checks.

The first installation may take longer because it downloads Ollama and the model. Later runs reuse the same verified files and model layers.

The wiki job runs every 30 minutes and handles no more than the oldest three pending pull requests in one event. Runs are serialized and each job has a 180-minute timeout. Qwen can see only bounded merge evidence and the five files allowed by the existing isolated bundle. Patch text is limited to 30,000 characters across a batch and 10,000 characters for any one pull request, so a single large changed file cannot crowd out the other merges.

Qwen is instructed to read the bounded inputs once, edit the five files with direct patches, avoid shell-redirection writes, and perform only one narrow final check. The longer overall window allows a CPU-only multi-turn edit to finish; each individual model request still has its 55-minute limit, and all normal publication checks remain mandatory.

The job turns off Qwen’s long thinking trace for this file-editing task. Qwen can still use its editing tools, but it spends less server time narrating hidden reasoning. The normal content and build checks still decide whether its work is safe to publish.

Long requests receive a small keep-alive message every 15 seconds while they wait for Qwen. These messages keep GitHub’s connection open without pretending that Qwen has produced content. When Qwen begins responding, the proxy forwards the real stream as it arrives.

Nothing is committed until the content, links, diagram, secret checks, and full wiki build pass. The cursor advances only after a successful validated push.

The backend and docs repositories store the same generated key under different secret names. The key is not shared with the older article AI service, printed in logs, or committed. The proxy logs only a request identifier, route, status, and duration—not prompts, patches, generated text, or credentials.

The manual npm run docs:prepare helper is separate and still uses OpenAI when someone deliberately runs it with an OpenAI key. It is not part of automatic merge documentation and should not be used when avoiding OpenAI charges.

Bad keys, wrong models, oversized requests, excess concurrent jobs, or an unavailable model are rejected before publication. The current wiki and merge cursor stay unchanged. If the new model is too slow or produces poor documentation, disable the wiki job first and roll back both repositories through their normal pull request and protected deployment paths. Never expose Ollama directly or repair the production server by hand.