Per-tenant resources: repository, storage and language model declared by each tenant #38

Open
opened 2026-11-17 16:15:22 +00:00 by claude-bot · 0 comments
Member

Goal

The instance holds no content of its own. Each tenant declares the resources its curation runs on:

  • its git repository (the OKF authority),
  • its object storage (S3) for the source documents,
  • optionally its language model (provider, model, key).

An instance administrator may let a tenant use the language model configured for the instance; every call is then logged with the tokens consumed. A private repository can be created for a tenant on the forge of the instance, on request.

Today every curation route reads instance-wide singletons (one repository path, one storage, one model adapter) and the themes come from the instance configuration, so a new instance shows themes nobody declared.

Design

Subject Choice
Tenant settings (not secret) In tenants.settings: repository (url, branch), storage (endpoint, region, bucket), ai (mode own / instance / none, provider, model, base URL), soa, axes, facets.
Tenant secrets S3 keys, model key, repository credential: a dedicated table, values sealed with AES-256-GCM under an instance key given by the environment. Write-only through the API: a route reports whether a secret is set, never its value. Never logged.
Per-tenant resources TenantResources of @quatrain/tenancy: working copy of the repository, storage adapter, model adapter, each built on first use and rebuilt when the settings change.
Routes Curation routes are served under /t/<tenant>/… only, inside the tenant scope. Instance-wide content routes disappear. Ingestion jobs carry the tenant.
Instance configuration axes no longer required; axes and facets of the instance file are ignored for content.
Instance model ai.mode = instance can only be set by an instance administrator.
Usage log One row per model call: tenant, account, provider, model, whose key (tenant or instance), input and output tokens, purpose, time. Needs the model adapters to report usage (@quatrain/ai).
Repository on request An instance administrator creates a private repository for a tenant on the forge configured for the instance (address, organisation and token in the instance environment), through @quatrain/git-forgejo.
Who edits A tenant admin declares the repository, storage and model of its tenant. Only an instance administrator authorises the instance model and creates a repository.

Steps (one pull request each)

  • 1. @quatrain/ai: adapters report token usage of each call.
  • 2. Tenant settings and sealed secrets: model, validation, storage, API. No behaviour change yet.
  • 3. Tenant page "Resources" to declare repository, storage and model.
  • 4. Per-tenant resources; curation routes and ingestion inside the tenant scope; axes and facets from the tenant; instance-wide content removed; effective tenant selector.
  • 5. Usage log and authorisation of the instance model; usage page for the instance administrator.
  • 6. Creation of a private repository on the forge for a tenant.

Part of #25 (effective tenant selector).

## Goal The instance holds no content of its own. Each tenant declares the resources its curation runs on: - its **git repository** (the OKF authority), - its **object storage** (S3) for the source documents, - optionally its **language model** (provider, model, key). An instance administrator may let a tenant use the language model configured for the instance; every call is then **logged with the tokens consumed**. A private repository can be **created for a tenant on the forge of the instance**, on request. Today every curation route reads instance-wide singletons (one repository path, one storage, one model adapter) and the themes come from the instance configuration, so a new instance shows themes nobody declared. ## Design | Subject | Choice | | --- | --- | | Tenant settings (not secret) | In `tenants.settings`: `repository` (url, branch), `storage` (endpoint, region, bucket), `ai` (mode `own` / `instance` / `none`, provider, model, base URL), `soa`, `axes`, `facets`. | | Tenant secrets | S3 keys, model key, repository credential: a dedicated table, values sealed with AES-256-GCM under an instance key given by the environment. Write-only through the API: a route reports whether a secret is set, never its value. Never logged. | | Per-tenant resources | `TenantResources` of `@quatrain/tenancy`: working copy of the repository, storage adapter, model adapter, each built on first use and rebuilt when the settings change. | | Routes | Curation routes are served under `/t/<tenant>/…` only, inside the tenant scope. Instance-wide content routes disappear. Ingestion jobs carry the tenant. | | Instance configuration | `axes` no longer required; axes and facets of the instance file are ignored for content. | | Instance model | `ai.mode = instance` can only be set by an instance administrator. | | Usage log | One row per model call: tenant, account, provider, model, whose key (tenant or instance), input and output tokens, purpose, time. Needs the model adapters to report usage (`@quatrain/ai`). | | Repository on request | An instance administrator creates a private repository for a tenant on the forge configured for the instance (address, organisation and token in the instance environment), through `@quatrain/git-forgejo`. | | Who edits | A tenant `admin` declares the repository, storage and model of its tenant. Only an instance administrator authorises the instance model and creates a repository. | ## Steps (one pull request each) - [ ] 1. `@quatrain/ai`: adapters report token usage of each call. - [x] 2. Tenant settings and sealed secrets: model, validation, storage, API. No behaviour change yet. - [x] 3. Tenant page "Resources" to declare repository, storage and model. - [ ] 4. Per-tenant resources; curation routes and ingestion inside the tenant scope; axes and facets from the tenant; instance-wide content removed; effective tenant selector. - [ ] 5. Usage log and authorisation of the instance model; usage page for the instance administrator. - [ ] 6. Creation of a private repository on the forge for a tenant. Part of #25 (effective tenant selector).
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
modaka/studio#38
No description provided.