Skip to content

Log in on the assistant host and give it a genki-test hostname - #838

Open
nlundee wants to merge 4 commits into
mainfrom
ka-assistant
Open

nlundee wants to merge 4 commits into
mainfrom
ka-assistant

Conversation

@nlundee

@nlundee nlundee commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

What and why

The assistant host now logs a person in and draws the service's published layout, so a service such as Kunnskapsassistenten can run on a genki-test hostname for acceptance (#771, M4). Stacks on #832.

  • apps/assistant logs in in the browser with the authorization code flow and PKCE, as a public client of the hosted Client the host route names (ADR 0034 allows this in the locked test environment). All token handling is in apps/assistant/src/login.ts behind a small Login interface, so the BFF can replace it. The dev login is gone from the host; locally it uses the mock Ansattporten.
  • GET /v1/hosts/{hostname} also names login.audience and login.altinnResource, which the login needs: without the Altinn resource a registered client's login carries no rights for the tenant.
  • GENAI_ASSISTANT_HOSTNAME names genki's own assistant hostname, the one name under genki's zones a hosted Client may claim, and only once GENAI_HOSTED_HOSTNAMES opens it to the tenant.
  • Infra: assistant.genki-test.digdir.cloud beside the other four hostnames, bound on the host app with the same CUSTOM_DOMAINS_STAGE runs, its managed certificate and DNS verification in the host's own environment, the issuer in the host's CSP, and test opening it to PLATFORM_TENANT.
  • The assistant no longer overflows at phone width, and the language choice sits on one line in the header.

Risk

Sensitive: login, tokens in sessionStorage, a public route's answer and infra. The token stays per tab, with no refresh; state, nonce, the issuer in the metadata and a same-origin return path are checked. The reserved-zone exception is one exact name set by the template, still gated by the operator's list.

Undo

Revert is enough. The infra part only acts while assistantHostEnabled is on, which no parameter file sets.

How it was tested

  • npx vitest run apps/assistant apps/api scripts/assistant-host-infra.test.ts, npx vitest run --root scripts, npx tsc -b, eslint and prettier on touched files, npm run atlas:build and atlas:test.

  • New rules: "sends the person to the issuer with the host's client, PKCE and its own callback", "draws the service's layout once the callback has exchanged the code", "refuses a callback whose state is not the one it sent", "starts no login on a hostname genki does not answer for, such as one opened to another tenant", "returns after login only to a path on the same hostname", "genki's own assistant hostname is the one name in its zones a hosted client may claim", "genki's own assistant hostname stays closed while no operator opens it to the tenant", and the template tests for the binding and the DNS record.

  • By hand: a local API with Kunnskapsassistenten published with the knowledge-assistant-next layout and its profile, a hosted Client, and the host on localhost with the mock Ansattporten: login, organisation choice and the layout drawn, at 1280 and 390 in light and dark, beside the portal's preview. The model was the local echo model and no Kudos dataset, so no answers were compared. Not run against real Ansattporten or Entra.

  • npm run check passes

Checklist

  • Every new rule has a test whose name states it
  • User-facing text is in the i18n catalogues, in bokmål and English, with no em-dashes
  • Vendor SDKs stay in packages/providers-*
  • ADRs, docs and docs/architecture/modules are updated if a contract, boundary or module changed
  • No secrets, personal data or local paths

A service's assistant layout now lives in its definition as spec.interface.layout, so the builder saves to and opens from the draft instead of the browser's session storage. The layout is drafted, checked, published and versioned with the service through the existing draft and publish routes; no new route, store or right.

The shape is closed and bounded in @genai/definitions: catalogue or x- block ids, boolean or string settings, profile texts as one string or { nb, en }, https document links, the builder's profile limits and 256 KiB for the whole interface. definitionSubject leaves the interface out, so a change of look alone keeps the eval runs a gate needs.

The builder writes only what the person changes, stores blocks the draft cannot back yet where they were chosen, refuses to edit a layout it would lose part of (texts per language, x- blocks), and offers once to save or discard a layout kept in the browser before.

ADR 0065 records the decision, building on the proposal for ADR 0056 in #570. The catalogue check on publish, the read route and the hosted assistant come later.
genki can now draw a service's assistant on a hostname of its own,
from the service's interface, without code from the service owner.

- A Client with spec.hosted and hostnames is a hosted frontend; its
  origins follow its hostnames, and an operator opens each hostname to
  one tenant with GENAI_HOSTED_HOSTNAMES.
- GET /v1/hosts/{hostname} and /pages/{id} answer what the host draws
  before login, and nothing more: no Client registration id, version,
  layout or profile. Every hostname that is not active gets the same
  404 urn:genai:problem:host-not-found. GET /v1/models/{id}/interface
  answers the layout after login.
- spec.interface gains menu and pages. A publish refuses a block the
  catalogue does not hold, and an x- block while genki hosts the
  service, reported together with a missing dataset.
- In lockdown a hosted Client in the platform tenant admits the
  service groups. Only a platform operator sets spec.hosted there,
  through platform.client.hosted, audited, and a tenant cannot move a
  hosted Client's client id.
- apps/assistant draws the name, menu, pages and the assistant, with
  dev login locally and a notice in production until the BFF.
- APP=assistant in the apps image, and Bicep behind
  assistantHostEnabled: its own environment, an identity with AcrPull
  only, and a Key Vault of its own.

ADR 0065 and ADR 0033 say what is built, including what the public
host route reveals. The hostname pattern's linear-time test now uses a
hard name within the 253-character limit, beside a test of the limit.
The assistant host now logs a person in and draws the service's
published layout, so a service can run on a genki-test hostname for
acceptance.

- apps/assistant logs in in the browser with the authorization code
  flow and PKCE, as a public client of the hosted Client the host route
  names, and keeps the token in sessionStorage (ADR 0034). All of it is
  in login.ts behind a Login interface the BFF replaces. The host's dev
  login is gone; locally it uses the mock Ansattporten.
- GET /v1/hosts/{hostname} also names login.audience and
  login.altinnResource, which a registered client's login needs.
- GENAI_ASSISTANT_HOSTNAME names genki's own assistant hostname, the one
  name in genki's zones a hosted Client may claim, still only once
  GENAI_HOSTED_HOSTNAMES opens it to the tenant.
- Infra binds assistant.genki-test.digdir.cloud on the host app in the
  usual CUSTOM_DOMAINS_STAGE runs, with its certificate and DNS
  verification in the host's own environment, puts the issuer in the
  host's CSP, and opens the name to PLATFORM_TENANT in test.
- The assistant no longer overflows at phone width.

Docs: development (pointing a hostname at a service), the API changes,
infra README, and the Built lines of ADR 0034 and 0065.
# Conflicts:
#	apps/api/src/composition.ts
#	apps/api/src/hosts.test.ts
#	apps/api/src/hosts.ts
#	apps/api/src/main.ts
#	apps/api/src/openapi/access.ts
#	apps/assistant/src/App.tsx
#	apps/assistant/src/app.css
#	apps/assistant/src/app.test.tsx
#	apps/assistant/src/host.ts
#	apps/assistant/src/i18n.ts
#	apps/assistant/src/main.tsx
#	apps/portal/src/screens/services/Builder.tsx
#	apps/portal/src/screens/services/blocks/interface.test.tsx
#	docs/adr/0033-locked-test-environment.md
#	docs/adr/0034-tokens-in-the-browser.md
#	docs/adr/README.md
#	docs/api/README.md
#	docs/architecture/modules/assistant-host.yaml
#	docs/architecture/system-atlas.html
#	docs/development.md
#	infra/README.md
#	infra/main.bicep
#	infra/modules/assistant-host.bicep
#	scripts/assistant-host-infra.test.ts
@nlundee
nlundee added this pull request to the merge queue Nov 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 19, 2026

This branch has not been deployed

No deployments
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