feat(ingestion): analyse ingested files with the language model of the tenant #64

Merged
crapougnax merged 1 commit from feat/38-ingestion-analysis into develop 2026-11-19 20:22:44 +00:00
Owner

Refs #38 (step 4b, second part: the analysis)

Model of a tenant (src/instance/tenant-model.ts, per-tenant resource)

  • own: provider and model of the tenant, key read from the sealed secret ai.key inside its scope on each call, address checked against local and private networks before each call. Gemini through @quatrain/ai-gemini, the others through the OpenAI-compatible adapter.
  • instance: the model of the instance configuration, for a tenant an instance administrator granted it; each call is traced in the log until the usage log of step 5.
  • none: no analysis.

Analysis (src/instance/document-analysis.ts)

  • Text read from PDF (pdf-parse), text, Markdown, HTML; DOCX, ODT, EPUB are not read yet (bare record).
  • The text is kept beside the original, extracts/sha256/<hash>.txt, in the private storage.
  • The model gets the first 60 000 characters and a schema; the prompt asks for an original summary, never copied sentences, and names the vocabularies of the facets.
  • The answer is checked: shapes, lengths, a 4-digit year, only the facets of the tenant.

Record written (TenantIngestion.process)

  • Title, description, type, tags, language, facet values (canonical; others dropped), and creators, publisher, year, isbn, doi on the source, beside file_name.
  • Body: the summary of the model, never the text (rights unknown).
  • Commit trailer Analysed-by: <provider>/<model>. A failing model leaves the bare record, logged.

Docs: section 10 of docs/MULTI-TENANCY.md (EN, FR). Dialog note updated.

Checks: yarn test 255/255 (10 new: record from the analysis, extract stored, body free of the text, failing model, answer checking, prompt, models own/instance/none). yarn build passes. tsc --noEmit: the same 11 errors as on develop. Not tried against a real model.

🤖 Generated with Claude Code

Refs #38 (step 4b, second part: the analysis) **Model of a tenant** (`src/instance/tenant-model.ts`, per-tenant resource) - `own`: provider and model of the tenant, key read from the sealed secret `ai.key` inside its scope on each call, address checked against local and private networks before each call. Gemini through `@quatrain/ai-gemini`, the others through the OpenAI-compatible adapter. - `instance`: the model of the instance configuration, for a tenant an instance administrator granted it; each call is traced in the log until the usage log of step 5. - `none`: no analysis. **Analysis** (`src/instance/document-analysis.ts`) - Text read from PDF (`pdf-parse`), text, Markdown, HTML; DOCX, ODT, EPUB are not read yet (bare record). - The text is kept **beside the original**, `extracts/sha256/<hash>.txt`, in the private storage. - The model gets the first 60 000 characters and a schema; the prompt asks for an **original summary, never copied sentences**, and names the vocabularies of the facets. - The answer is checked: shapes, lengths, a 4-digit year, only the facets of the tenant. **Record written** (`TenantIngestion.process`) - Title, description, type, tags, language, facet values (canonical; others dropped), and `creators`, `publisher`, `year`, `isbn`, `doi` on the source, beside `file_name`. - Body: the summary of the model, never the text (rights `unknown`). - Commit trailer `Analysed-by: <provider>/<model>`. A failing model leaves the bare record, logged. Docs: section 10 of `docs/MULTI-TENANCY.md` (EN, FR). Dialog note updated. Checks: `yarn test` 255/255 (10 new: record from the analysis, extract stored, body free of the text, failing model, answer checking, prompt, models own/instance/none). `yarn build` passes. `tsc --noEmit`: the same 11 errors as on `develop`. **Not tried against a real model.** 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(ingestion): analyse ingested files with the language model of the tenant (#38)
All checks were successful
Build and Publish OCI Image / Build & Push ARM64 OCI Image (pull_request) Successful in 56s
777d5fac5b
With a model (the tenant's own, or the instance's when granted), the
ingestion task reads the text of the file (PDF, text, Markdown, HTML),
keeps it beside the original under extracts/sha256/<hash>.txt, and asks
the model for the record: title, description, type, keywords, language,
facet values brought to the vocabularies, and creators, publisher, year,
ISBN, DOI on the source. The body is an original summary written by the
model, never the text of the document, whose rights are not established.
The commit names the model; a failing model leaves the bare record.

Models are per-tenant resources: the key of the tenant is read from the
sealed secrets inside its scope and the address checked before each
call; each call on the key of the instance is traced until the usage
log exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
crapougnax merged commit 2396748b90 into develop 2026-11-19 20:22:44 +00:00
crapougnax deleted branch feat/38-ingestion-analysis 2026-11-19 20:22:44 +00:00
Sign in to join this conversation.
No reviewers
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!64
No description provided.